mario-education 2.0.157-staging → 2.0.159-staging

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),p=require("react"),q=require("./index-I5aAFQd1.cjs"),oe=require("./index-cPRlZIiA.cjs"),ue=require("@dnd-kit/core"),me=require("@dnd-kit/sortable"),Ce=require("react-dom"),ke=require("@mui/material"),se=require("./wellbeingService-BiQK74Rh.cjs"),Ee=require("./utilities.esm-DImhXrxQ.cjs"),M=require("moment"),de=require("@mui/x-date-pickers"),we=require("./AdapterMoment-B-q0UCj0.cjs"),Oe=require("react-router-dom"),pe=require("./Loading-CHowA_dQ.cjs"),$e=require("react-redux"),s={"v2-container":"_v2-container_1w169_4","v2-header":"_v2-header_1w169_16","v2-header-row":"_v2-header-row_1w169_22","v2-btn-back-overview":"_v2-btn-back-overview_1w169_29","v2-title":"_v2-title_1w169_47","v2-description":"_v2-description_1w169_55","v2-mode-tabs":"_v2-mode-tabs_1w169_62","v2-mode-tabs__btn":"_v2-mode-tabs__btn_1w169_73","v2-mode-tabs__btn--active":"_v2-mode-tabs__btn--active_1w169_91","v2-power-card":"_v2-power-card_1w169_96","v2-power-card--active":"_v2-power-card--active_1w169_106","v2-power-card__icon":"_v2-power-card__icon_1w169_110","v2-power-card__content":"_v2-power-card__content_1w169_120","v2-power-card__title":"_v2-power-card__title_1w169_124","v2-power-card__sub":"_v2-power-card__sub_1w169_129","v2-power-card__state-text":"_v2-power-card__state-text_1w169_134","v2-power-card__state-text--active":"_v2-power-card__state-text--active_1w169_139","v2-power-card__switch":"_v2-power-card__switch_1w169_142","v2-power-card__switch--active":"_v2-power-card__switch--active_1w169_153","v2-power-card__knob":"_v2-power-card__knob_1w169_156","v2-power-card__knob--active":"_v2-power-card__knob--active_1w169_167","v2-info-callout":"_v2-info-callout_1w169_171","v2-info-callout__icon":"_v2-info-callout__icon_1w169_180","v2-info-callout__text":"_v2-info-callout__text_1w169_188","v2-section-box":"_v2-section-box_1w169_196","v2-section-box__header":"_v2-section-box__header_1w169_204","v2-section-box__num":"_v2-section-box__num_1w169_209","v2-section-box__title":"_v2-section-box__title_1w169_221","v2-section-box__sub":"_v2-section-box__sub_1w169_226","v2-section-box__body":"_v2-section-box__body_1w169_232","v2-field-label":"_v2-field-label_1w169_239","v2-cadence-grid":"_v2-cadence-grid_1w169_248","v2-cadence-card":"_v2-cadence-card_1w169_254","v2-cadence-card--selected":"_v2-cadence-card--selected_1w169_269","v2-cadence-card__top":"_v2-cadence-card__top_1w169_273","v2-cadence-card__radio":"_v2-cadence-card__radio_1w169_278","v2-cadence-card__radio--selected":"_v2-cadence-card__radio--selected_1w169_287","v2-cadence-card__title":"_v2-cadence-card__title_1w169_297","v2-cadence-card__badge":"_v2-cadence-card__badge_1w169_302","v2-cadence-card__sub":"_v2-cadence-card__sub_1w169_312","v2-days-row":"_v2-days-row_1w169_318","v2-day-pill":"_v2-day-pill_1w169_324","v2-day-pill--selected":"_v2-day-pill--selected_1w169_339","v2-rotation-box":"_v2-rotation-box_1w169_348","v2-rotation-box__head":"_v2-rotation-box__head_1w169_354","v2-rotation-box__desc":"_v2-rotation-box__desc_1w169_363","v2-rotation-box__list":"_v2-rotation-box__list_1w169_369","v2-rotation-box__item":"_v2-rotation-box__item_1w169_374","v2-rotation-box__cycle":"_v2-rotation-box__cycle_1w169_383","v2-rotation-box__title":"_v2-rotation-box__title_1w169_390","v2-rotation-box__tag":"_v2-rotation-box__tag_1w169_396","v2-email-box":"_v2-email-box_1w169_405","v2-email-box--active":"_v2-email-box--active_1w169_415","v2-email-box__icon":"_v2-email-box__icon_1w169_419","v2-email-box__content":"_v2-email-box__content_1w169_428","v2-email-box__title":"_v2-email-box__title_1w169_432","v2-email-box__sub":"_v2-email-box__sub_1w169_437","v2-email-box__state-text":"_v2-email-box__state-text_1w169_442","v2-email-box__state-text--active":"_v2-email-box__state-text--active_1w169_447","v2-email-box__switch":"_v2-email-box__switch_1w169_450","v2-email-box__switch--active":"_v2-email-box__switch--active_1w169_461","v2-email-box__knob":"_v2-email-box__knob_1w169_464","v2-email-box__knob--active":"_v2-email-box__knob--active_1w169_475","v2-email-preview-wrapper":"_v2-email-preview-wrapper_1w169_479","v2-btn-preview-email":"_v2-btn-preview-email_1w169_485","v2-email-preview-popover":"_v2-email-preview-popover_1w169_505","v2-email-preview-popover__head":"_v2-email-preview-popover__head_1w169_518","v2-email-preview-popover__logo-wrap":"_v2-email-preview-popover__logo-wrap_1w169_526","v2-email-preview-popover__logo-circle":"_v2-email-preview-popover__logo-circle_1w169_531","v2-email-preview-popover__logo-text":"_v2-email-preview-popover__logo-text_1w169_542","v2-email-preview-popover__brand":"_v2-email-preview-popover__brand_1w169_548","v2-email-preview-popover__body":"_v2-email-preview-popover__body_1w169_553","v2-email-preview-popover__to":"_v2-email-preview-popover__to_1w169_560","v2-email-preview-popover__title":"_v2-email-preview-popover__title_1w169_565","v2-email-preview-popover__desc":"_v2-email-preview-popover__desc_1w169_572","v2-email-preview-popover__btn-start":"_v2-email-preview-popover__btn-start_1w169_578","v2-send-warning-box":"_v2-send-warning-box_1w169_598","v2-send-warning-box__icon":"_v2-send-warning-box__icon_1w169_612","v2-btn-primary":"_v2-btn-primary_1w169_616","v2-stat-banner":"_v2-stat-banner_1w169_643","v2-stat-banner__left":"_v2-stat-banner__left_1w169_653","v2-stat-banner__icon":"_v2-stat-banner__icon_1w169_658","v2-stat-banner__label":"_v2-stat-banner__label_1w169_667","v2-stat-banner__num":"_v2-stat-banner__num_1w169_672","v2-stat-banner__right":"_v2-stat-banner__right_1w169_678","v2-stat-banner__meta-sub":"_v2-stat-banner__meta-sub_1w169_682","v2-stat-banner__meta-num":"_v2-stat-banner__meta-num_1w169_686","v2-cluster-card":"_v2-cluster-card_1w169_691","v2-cluster-card--collapsed":"_v2-cluster-card--collapsed_1w169_701","v2-cluster-card__head":"_v2-cluster-card__head_1w169_706","v2-cluster-card__num":"_v2-cluster-card__num_1w169_711","v2-cluster-card__info":"_v2-cluster-card__info_1w169_723","v2-cluster-card__title":"_v2-cluster-card__title_1w169_727","v2-cluster-card__count":"_v2-cluster-card__count_1w169_732","v2-cluster-card__pill":"_v2-cluster-card__pill_1w169_737","v2-cluster-card-ext__bottom-actions":"_v2-cluster-card-ext__bottom-actions_1w169_748","v2-cluster-card-ext__btn-add-cluster":"_v2-cluster-card-ext__btn-add-cluster_1w169_752","v2-cluster-card-ext__btn-toggle-bank":"_v2-cluster-card-ext__btn-toggle-bank_1w169_752","v2-cluster-card-ext__bank-panel":"_v2-cluster-card-ext__bank-panel_1w169_773","v2-cluster-card-ext__bank-empty":"_v2-cluster-card-ext__bank-empty_1w169_785","v2-cluster-card-ext__bank-item":"_v2-cluster-card-ext__bank-item_1w169_791","v2-cluster-card-ext__bank-icon-circle":"_v2-cluster-card-ext__bank-icon-circle_1w169_807","v2-cluster-card-ext__bank-text-wrap":"_v2-cluster-card-ext__bank-text-wrap_1w169_816","v2-cluster-card-ext__bank-item-title":"_v2-cluster-card-ext__bank-item-title_1w169_823","v2-cluster-card-ext__bank-item-desc":"_v2-cluster-card-ext__bank-item-desc_1w169_829","v2-cluster-card-ext__bank-divider":"_v2-cluster-card-ext__bank-divider_1w169_834","v2-cluster-card-ext__btn-write-custom":"_v2-cluster-card-ext__btn-write-custom_1w169_839","v2-cluster-card-ext__drag-handle":"_v2-cluster-card-ext__drag-handle_1w169_859","v2-cluster-card-ext__drag-handle--disabled":"_v2-cluster-card-ext__drag-handle--disabled_1w169_869","v2-cluster-card-ext__guidance-box":"_v2-cluster-card-ext__guidance-box_1w169_873","v2-cluster-card-ext__questions-list":"_v2-cluster-card-ext__questions-list_1w169_883","v2-cluster-card-ext__empty":"_v2-cluster-card-ext__empty_1w169_888","v2-question-row":"_v2-question-row_1w169_898","v2-question-row--disabled":"_v2-question-row--disabled_1w169_906","v2-question-row__title":"_v2-question-row__title_1w169_910","v2-question-row__desc":"_v2-question-row__desc_1w169_913","v2-question-row__cluster-badge":"_v2-question-row__cluster-badge_1w169_916","v2-question-row__type-text":"_v2-question-row__type-text_1w169_920","v2-question-row__top":"_v2-question-row__top_1w169_923","v2-question-row__left":"_v2-question-row__left_1w169_929","v2-question-row__head-row":"_v2-question-row__head-row_1w169_933","v2-question-row__checkbox-label":"_v2-question-row__checkbox-label_1w169_944","v2-question-row__checkbox-text":"_v2-question-row__checkbox-text_1w169_950","v2-question-row__checkbox":"_v2-question-row__checkbox_1w169_944","v2-question-row__enabled-text":"_v2-question-row__enabled-text_1w169_961","v2-question-row__enabled-text--active":"_v2-question-row__enabled-text--active_1w169_966","v2-question-row__enabled-text--disabled":"_v2-question-row__enabled-text--disabled_1w169_969","v2-question-row__right":"_v2-question-row__right_1w169_978","v2-question-row__actions":"_v2-question-row__actions_1w169_999","v2-question-row__btn-action":"_v2-question-row__btn-action_1w169_1003","v2-question-row__btn-action--active":"_v2-question-row__btn-action--active_1w169_1018","v2-question-form":"_v2-question-form_1w169_1023","v2-question-form__field":"_v2-question-form__field_1w169_1031","v2-question-form__label":"_v2-question-form__label_1w169_1036","v2-question-form__label--spaced":"_v2-question-form__label--spaced_1w169_1043","v2-question-form__input":"_v2-question-form__input_1w169_1046","v2-question-form__hint":"_v2-question-form__hint_1w169_1065","v2-question-form__descriptors-grid":"_v2-question-form__descriptors-grid_1w169_1071","v2-question-form__descriptor-item":"_v2-question-form__descriptor-item_1w169_1076","v2-question-form__descriptor-num":"_v2-question-form__descriptor-num_1w169_1081","v2-question-form__descriptor-input":"_v2-question-form__descriptor-input_1w169_1086","v2-question-form__meta-row":"_v2-question-form__meta-row_1w169_1101","v2-question-form__select-label":"_v2-question-form__select-label_1w169_1108","v2-question-form__select":"_v2-question-form__select_1w169_1108","v2-question-form__actions":"_v2-question-form__actions_1w169_1129","v2-question-form__btn-cancel":"_v2-question-form__btn-cancel_1w169_1138","v2-question-form__btn-save":"_v2-question-form__btn-save_1w169_1151","v2-dates-list":"_v2-dates-list_1w169_1170","v2-date-row":"_v2-date-row_1w169_1176","v2-date-row__idx":"_v2-date-row__idx_1w169_1181","v2-date-row__btn-remove":"_v2-date-row__btn-remove_1w169_1207","v2-saved-wrapper":"_v2-saved-wrapper_1w169_1225","v2-saved-card":"_v2-saved-card_1w169_1234","v2-saved-badge":"_v2-saved-badge_1w169_1261","v2-saved-title":"_v2-saved-title_1w169_1278","v2-saved-desc":"_v2-saved-desc_1w169_1292","v2-saved-list":"_v2-saved-list_1w169_1313","v2-saved-item":"_v2-saved-item_1w169_1320","v2-saved-item__icon":"_v2-saved-item__icon_1w169_1336","v2-saved-item__icon--routine":"_v2-saved-item__icon--routine_1w169_1344","v2-saved-item__icon--comprehensive":"_v2-saved-item__icon--comprehensive_1w169_1347","v2-saved-item__icon--oneoff":"_v2-saved-item__icon--oneoff_1w169_1350","v2-saved-item__info":"_v2-saved-item__info_1w169_1353","v2-saved-item__title":"_v2-saved-item__title_1w169_1357","v2-saved-item__sub":"_v2-saved-item__sub_1w169_1364","v2-saved-item__actions":"_v2-saved-item__actions_1w169_1378","v2-saved-item__switch-box":"_v2-saved-item__switch-box_1w169_1384","v2-saved-item__switch":"_v2-saved-item__switch_1w169_1384","v2-saved-item__switch--on":"_v2-saved-item__switch--on_1w169_1404","v2-saved-item__knob":"_v2-saved-item__knob_1w169_1407","v2-saved-item__knob--on":"_v2-saved-item__knob--on_1w169_1418","v2-saved-item__btn-edit":"_v2-saved-item__btn-edit_1w169_1421","v2-saved-loading-wrap":"_v2-saved-loading-wrap_1w169_1458","v2-saved-loading-wrap__text":"_v2-saved-loading-wrap__text_1w169_1465","v2-saved-retry-btn":"_v2-saved-retry-btn_1w169_1470","v2-saved-item-loading":"_v2-saved-item-loading_1w169_1481","v2-saved-item-loading__text":"_v2-saved-item-loading__text_1w169_1486","v2-saved-item-spinner":"_v2-saved-item-spinner_1w169_1491","v2-saved-item-dash":"_v2-saved-item-dash_1w169_1499","v2-saved-btn-dashboard":"_v2-saved-btn-dashboard_1w169_1504","v2-oneoff-container":"_v2-oneoff-container_1w169_1530","v2-oneoff-accordion":"_v2-oneoff-accordion_1w169_1537","v2-oneoff-accordion__header":"_v2-oneoff-accordion__header_1w169_1543","v2-oneoff-accordion__icon-box":"_v2-oneoff-accordion__icon-box_1w169_1558","v2-oneoff-accordion__title-group":"_v2-oneoff-accordion__title-group_1w169_1567","v2-oneoff-accordion__title":"_v2-oneoff-accordion__title_1w169_1567","v2-oneoff-accordion__subtitle":"_v2-oneoff-accordion__subtitle_1w169_1576","v2-oneoff-accordion__body":"_v2-oneoff-accordion__body_1w169_1581","v2-oneoff-accordion__empty":"_v2-oneoff-accordion__empty_1w169_1586","v2-oneoff-accordion__item":"_v2-oneoff-accordion__item_1w169_1592","v2-oneoff-accordion__item-info":"_v2-oneoff-accordion__item-info_1w169_1602","v2-oneoff-accordion__item-name":"_v2-oneoff-accordion__item-name_1w169_1606","v2-oneoff-accordion__item-meta":"_v2-oneoff-accordion__item-meta_1w169_1611","v2-oneoff-accordion__item-actions":"_v2-oneoff-accordion__item-actions_1w169_1616","v2-oneoff-accordion__btn-view":"_v2-oneoff-accordion__btn-view_1w169_1621","v2-oneoff-accordion__btn-send-again":"_v2-oneoff-accordion__btn-send-again_1w169_1639","v2-name-box":"_v2-name-box_1w169_1658","v2-name-box__label":"_v2-name-box__label_1w169_1664","v2-name-box__input":"_v2-name-box__input_1w169_1671","v2-name-box__hint":"_v2-name-box__hint_1w169_1689","v2-sendagain-modal__icon-box":"_v2-sendagain-modal__icon-box_1w169_1694","v2-comprehensive-container":"_v2-comprehensive-container_1w169_1746","v2-comprehensive-body":"_v2-comprehensive-body_1w169_1753","v2-comprehensive-body--disabled":"_v2-comprehensive-body--disabled_1w169_1759","v2-comprehensive-date-picker-wrap":"_v2-comprehensive-date-picker-wrap_1w169_1764","v2-comprehensive-btn-add-date":"_v2-comprehensive-btn-add-date_1w169_1769","v2-comprehensive-note-box":"_v2-comprehensive-note-box_1w169_1791","v2-comprehensive-note-box__icon":"_v2-comprehensive-note-box__icon_1w169_1801","v2-comprehensive-note-box__text":"_v2-comprehensive-note-box__text_1w169_1805","v2-delete-modal-overlay":"_v2-delete-modal-overlay_1w169_1818","v2-delete-modal":"_v2-delete-modal_1w169_1818","v2-delete-modal__title":"_v2-delete-modal__title_1w169_1838","v2-delete-modal__message":"_v2-delete-modal__message_1w169_1843","v2-delete-modal__actions":"_v2-delete-modal__actions_1w169_1849","v2-delete-modal__btn-cancel":"_v2-delete-modal__btn-cancel_1w169_1855","v2-delete-modal__btn-delete":"_v2-delete-modal__btn-delete_1w169_1870","v2-restore-modal-overlay":"_v2-restore-modal-overlay_1w169_1888","v2-restore-modal":"_v2-restore-modal_1w169_1888","v2-restore-modal__icon-box":"_v2-restore-modal__icon-box_1w169_1910","v2-restore-modal__title":"_v2-restore-modal__title_1w169_1920","v2-restore-modal__message":"_v2-restore-modal__message_1w169_1925","v2-restore-modal__actions":"_v2-restore-modal__actions_1w169_1931","v2-restore-modal__btn-cancel":"_v2-restore-modal__btn-cancel_1w169_1937","v2-restore-modal__btn-confirm":"_v2-restore-modal__btn-confirm_1w169_1956","v2-launch-modal-overlay":"_v2-launch-modal-overlay_1w169_1981","v2-launch-modal":"_v2-launch-modal_1w169_1981","v2-launch-modal__btn-close":"_v2-launch-modal__btn-close_1w169_2001","v2-launch-modal__icon-box":"_v2-launch-modal__icon-box_1w169_2019","v2-launch-modal__title":"_v2-launch-modal__title_1w169_2028","v2-launch-modal__sub":"_v2-launch-modal__sub_1w169_2033","v2-launch-modal__form":"_v2-launch-modal__form_1w169_2039","v2-launch-modal__field-label":"_v2-launch-modal__field-label_1w169_2045","v2-launch-modal__actions":"_v2-launch-modal__actions_1w169_2070","v2-launch-modal__btn-cancel":"_v2-launch-modal__btn-cancel_1w169_2075","v2-launch-modal__btn-start":"_v2-launch-modal__btn-start_1w169_2091","v2-launch-modal__btn-start--valid":"_v2-launch-modal__btn-start--valid_1w169_2107","v2-view-modal":"_v2-view-modal_1w169_2118","v2-view-modal__header":"_v2-view-modal__header_1w169_2132","v2-view-modal__btn-close":"_v2-view-modal__btn-close_1w169_2141","v2-view-modal__icon-box":"_v2-view-modal__icon-box_1w169_2159","v2-view-modal__title-wrap":"_v2-view-modal__title-wrap_1w169_2168","v2-view-modal__title":"_v2-view-modal__title_1w169_2168","v2-view-modal__meta":"_v2-view-modal__meta_1w169_2177","v2-view-modal__body":"_v2-view-modal__body_1w169_2182","v2-view-modal__section-label":"_v2-view-modal__section-label_1w169_2209","v2-view-modal__sent-section":"_v2-view-modal__sent-section_1w169_2218","v2-view-modal__sent-badges-list":"_v2-view-modal__sent-badges-list_1w169_2222","v2-view-modal__sent-badge":"_v2-view-modal__sent-badge_1w169_2222","v2-view-modal__sent-badge--past":"_v2-view-modal__sent-badge--past_1w169_2240","v2-view-modal__sent-badge--future":"_v2-view-modal__sent-badge--future_1w169_2245","v2-view-modal__questions-section":"_v2-view-modal__questions-section_1w169_2250","v2-view-modal__cluster-group":"_v2-view-modal__cluster-group_1w169_2254","v2-view-modal__cluster-header":"_v2-view-modal__cluster-header_1w169_2264","v2-view-modal__questions-list":"_v2-view-modal__questions-list_1w169_2272","v2-view-modal__question-row":"_v2-view-modal__question-row_1w169_2278","v2-view-modal__question-num":"_v2-view-modal__question-num_1w169_2288","v2-view-modal__question-text":"_v2-view-modal__question-text_1w169_2294","v2-view-modal__empty":"_v2-view-modal__empty_1w169_2300","v2-view-modal__footer-single":"_v2-view-modal__footer-single_1w169_2306","v2-view-modal__btn-close-footer":"_v2-view-modal__btn-close-footer_1w169_2314","v2-review-questions":"_v2-review-questions_1w169_2334","v2-review-questions__builder-card":"_v2-review-questions__builder-card_1w169_2339","v2-review-questions__builder-card--transparent":"_v2-review-questions__builder-card--transparent_1w169_2348","v2-review-questions__reorder-bar":"_v2-review-questions__reorder-bar_1w169_2353","v2-review-questions__reorder-hint":"_v2-review-questions__reorder-hint_1w169_2361","v2-review-questions__btn-restore":"_v2-review-questions__btn-restore_1w169_2365","v2-review-questions__cluster-list":"_v2-review-questions__cluster-list_1w169_2383","v2-review-questions__cluster-list--dragging":"_v2-review-questions__cluster-list--dragging_1w169_2388","v2-routine-container":"_v2-routine-container_1w169_2395","v2-routine-body":"_v2-routine-body_1w169_2402","v2-routine-body--disabled":"_v2-routine-body--disabled_1w169_2408","v2-snackbar-wrap":"_v2-snackbar-wrap_1w169_2416","v2-snackbar-alert":"_v2-snackbar-alert_1w169_2420"},Le=({activeTab:t,onSelectTab:l})=>{const n=[{id:"routine",label:"Routine check-in",icon:e.jsx(q.LuRepeat,{size:18})},{id:"comprehensive",label:"Comprehensive check-in",icon:e.jsx(q.LuCalendarRange,{size:18})},{id:"oneoff",label:"One-off check-in",icon:e.jsx(q.LuCalendarClock,{size:18})}];return e.jsx("div",{className:s["v2-mode-tabs"],children:n.map(_=>{const c=t===_.id;return e.jsxs("button",{type:"button",onClick:()=>l(_.id),className:`${s["v2-mode-tabs__btn"]} ${c?s["v2-mode-tabs__btn--active"]:""}`,children:[_.icon,e.jsx("span",{children:_.label})]},_.id)})})},Be=({open:t,onClose:l,onDelete:n})=>{if(!t)return null;const _=e.jsx("div",{onClick:l,className:s["v2-delete-modal-overlay"],children:e.jsxs("div",{onClick:c=>c.stopPropagation(),className:s["v2-delete-modal"],children:[e.jsx("div",{className:s["v2-delete-modal__title"],children:"Delete question?"}),e.jsx("p",{className:s["v2-delete-modal__message"],children:"Are you sure you want to remove this question?"}),e.jsxs("div",{className:s["v2-delete-modal__actions"],children:[e.jsx("button",{type:"button",onClick:l,className:s["v2-delete-modal__btn-cancel"],children:"Cancel"}),e.jsx("button",{type:"button",onClick:n,className:s["v2-delete-modal__btn-delete"],children:"Delete"})]})]})});return typeof document<"u"?Ce.createPortal(_,document.body):_},he=[],S=(t,l="success")=>{he.forEach(n=>n({open:!0,message:t,severity:l}))},Re=()=>{const[t,l]=p.useState({open:!1,message:"",severity:"success"});p.useEffect(()=>{const _=c=>l(c);return he.push(_),()=>{const c=he.indexOf(_);c>=0&&he.splice(c,1)}},[]);const n=(_,c)=>{c!=="clickaway"&&l(b=>({...b,open:!1}))};return e.jsx(ke.Snackbar,{open:t.open,autoHideDuration:4e3,onClose:n,anchorOrigin:{vertical:"top",horizontal:"right"},className:s["v2-snackbar-wrap"],children:e.jsx(ke.Alert,{onClose:n,severity:t.severity,variant:"filled",elevation:6,className:s["v2-snackbar-alert"],children:t.message})})},ve=["Strongly disagree","Disagree","Neutral","Agree","Strongly agree"],qe=[{id:"weekly",title:"Weekly",sub:"Every 7 days"},{id:"biweekly",title:"Bi-weekly",sub:"Every 14 days",rec:!0},{id:"monthly",title:"Monthly",sub:"Every 30 days"}],Fe=["Monday","Tuesday","Wednesday","Thursday","Friday","Saturday","Sunday"],le=[{id:1,name:"Physical",label:"Physical well-being",icon:"Dumbbell",order:1,kind:"indicator",questions:[]},{id:2,name:"Emotional",label:"Emotional well-being",icon:"Heart",order:2,kind:"indicator",questions:[]},{id:3,name:"Environmental",label:"Environmental well-being",icon:"Leaf",order:3,kind:"indicator",questions:[]},{id:4,name:"Spiritual",label:"Spiritual well-being",icon:"Sparkles",order:4,kind:"indicator",questions:[]},{id:5,name:"Social",label:"Social (relationships) well-being",icon:"Users",order:5,kind:"indicator",questions:[]},{id:6,name:"Intellectual",label:"Intellectual well-being",icon:"Brain",order:6,kind:"indicator",questions:[]},{id:7,name:"Open",label:"Open field well-being",icon:"PenLine",order:7,kind:"open",questions:[]}],fe={routine:{isEnabled:!1,frequency:"biweekly",dayOfWeek:"Monday",emailNotify:!1},comprehensive:{isEnabled:!1,frequency:"quarterly",sendDates:[],durationDays:14,emailNotify:!1},pastOneOffs:[]},ze=({item:t,kind:l,clusterId:n,clusters:_,onChange:c,onMove:b,onDelete:m,isOneOff:h=!1})=>{const[x,Y]=p.useState(!1),[k,d]=p.useState(!1),[C,D]=p.useState(!1),w=l!=="open",o=_.find(j=>j.kind==="open")||{id:999},r=()=>w?n:t.isAppliedToAllClusters||t.includedInBulk||!t.clusterId?o.id:Number(t.clusterId),y=()=>w?!1:!!(t.includedInBulk||t.isAppliedToAllClusters),[I,z]=p.useState(t.text),[T,E]=p.useState(t.descriptors&&t.descriptors.length===5?[...t.descriptors]:[...ve]),[J,H]=p.useState(r()),[K,g]=p.useState(y()),Q=(j=>j?j.replace(/&rsquo;/g,"'").replace(/&lsquo;/g,"'").replace(/&rdquo;/g,'"').replace(/&ldquo;/g,'"').replace(/&quot;/g,'"').replace(/&#39;/g,"'").replace(/&amp;/g,"&").replace(/&nbsp;/g," "):"")(t.text),R=Q.indexOf(":"),G=R>=0?Q.slice(0,R).trim():Q,W=R>=0?Q.slice(R+1).trim():"",ee=_.find(j=>j.id===n),X=!w&&!!(t.isAppliedToAllClusters||t.includedInBulk),a=!w&&!X&&t.clusterId?_.find(j=>String(j.id)===String(t.clusterId)):null,u=w?ee?.name||"Cluster":X?"All clusters":a?a.label||a.name:ee?.name||"Open field",O=w?"Scale 1–5":"Open text",N=t.isEnabled!==!1,$=()=>{z(Q),E(t.descriptors&&t.descriptors.length===5?[...t.descriptors]:[...ve]),H(r()),g(y()),Y(!0)},F=()=>{Y(!1)},V=j=>{H(j),w||(j!==o.id?g(!1):g(!0))},ae=j=>{g(j),j&&H(o.id)},P=async()=>{if(I.trim())if(w){const j={...t,text:I.trim(),descriptors:T,clusterId:J};if(c(j),J!==n&&b(J),Y(!1),t.id&&typeof t.id=="number")try{D(!0),await se.updateWellbeingQuestionApi(t.id,{text:I.trim(),clusterId:J,descriptors:T}),S("Question updated successfully","success")}catch(L){console.error("Failed to update question via API",L),S("Failed to update question","error")}finally{D(!1)}}else{const j=J===o.id||K,L=j?null:J,re={...t,text:I.trim(),descriptors:null,includedInBulk:K,isAppliedToAllClusters:j,clusterId:L,sectionName:j?"All clusters":_.find(_e=>String(_e.id)===String(L))?.name||"Cluster"};if(c(re),Y(!1),t.id&&typeof t.id=="number")try{D(!0),await se.updateWellbeingQuestionApi(t.id,{text:I.trim(),clusterId:L,descriptors:null,isAppliedToAllClusters:j,includedInBulk:K}),S("Question updated successfully","success")}catch(_e){console.error("Failed to update question via API",_e),S("Failed to update question","error")}finally{D(!1)}}},f=async j=>{if(c({...t,isEnabled:j}),t.id&&typeof t.id=="number")try{await se.toggleWellbeingQuestionStatusApi(t.id,j),S(j?"Question enabled":"Question disabled","success")}catch(L){console.error("Failed to toggle question status via API",L),S("Failed to update question status","error")}},A=async()=>{if(m(),d(!1),t.id&&typeof t.id=="number")try{await se.deleteWellbeingQuestionApi(t.id),S("Question removed from cluster","success")}catch(j){console.error("Failed to delete question via API",j),S("Failed to remove question","error")}},Z=(j,L)=>{const re=[...T];re[j]=L,E(re)};return e.jsxs("div",{className:`${s["v2-question-row"]} ${N?"":s["v2-question-row--disabled"]}`,children:[e.jsxs("div",{className:s["v2-question-row__top"],children:[e.jsxs("div",{className:s["v2-question-row__left"],children:[e.jsxs("div",{className:s["v2-question-row__head-row"],children:[e.jsx("span",{className:s["v2-question-row__title"],children:G||"Untitled question"}),e.jsxs("label",{className:s["v2-question-row__checkbox-label"],children:[e.jsx("input",{type:"checkbox",checked:N,onChange:j=>f(j.target.checked),className:s["v2-question-row__checkbox"]}),e.jsx("span",{className:`${s["v2-question-row__enabled-text"]} ${N?s["v2-question-row__enabled-text--active"]:s["v2-question-row__enabled-text--disabled"]}`,children:N?"Enabled":"Disabled"})]})]}),W&&e.jsx("div",{className:s["v2-question-row__desc"],children:W})]}),e.jsxs("div",{className:s["v2-question-row__right"],children:[e.jsx("span",{className:s["v2-question-row__cluster-badge"],children:u}),e.jsx("span",{className:s["v2-question-row__type-text"],children:O}),e.jsxs("div",{className:s["v2-question-row__actions"],children:[e.jsx("button",{type:"button",onClick:()=>x?F():$(),title:"Edit question",className:`${s["v2-question-row__btn-action"]} ${x?s["v2-question-row__btn-action--active"]:""}`,children:x?e.jsx(oe.FiChevronUp,{size:16,color:"#316CD9"}):e.jsx(q.LuPencil,{size:16,color:"#316CD9"})}),e.jsx("button",{type:"button",onClick:()=>{h?(m(),S("Question returned to question bank","info")):d(!0)},title:h?"Remove question (returns to bank)":"Delete question",className:s["v2-question-row__btn-action"],children:e.jsx(q.LuTrash2,{size:16,color:"#C44140"})})]})]})]}),x&&e.jsxs("div",{className:s["v2-question-form"],children:[e.jsxs("label",{className:s["v2-question-form__field"],children:[e.jsx("span",{className:s["v2-question-form__label"],children:"QUESTION TEXT"}),e.jsx("input",{value:I,onChange:j=>z(j.target.value),placeholder:"Short title: full question?",className:s["v2-question-form__input"]}),e.jsx("span",{className:s["v2-question-form__hint"],children:"Format as “Short title: full question?” — the title shows bold and the rest becomes the prompt."})]}),w&&e.jsxs("div",{children:[e.jsx("div",{className:`${s["v2-question-form__label"]} ${s["v2-question-form__label--spaced"]}`,children:"LINKED DESCRIPTORS (SCORE 1 ➜ 5)"}),e.jsx("div",{className:s["v2-question-form__descriptors-grid"],children:T.map((j,L)=>e.jsxs("label",{className:s["v2-question-form__descriptor-item"],children:[e.jsx("span",{className:s["v2-question-form__descriptor-num"],children:L+1}),e.jsx("input",{value:j,onChange:re=>Z(L,re.target.value),className:s["v2-question-form__descriptor-input"]})]},L))})]}),e.jsxs("div",{className:s["v2-question-form__meta-row"],children:[e.jsxs("label",{className:s["v2-question-form__select-label"],children:[e.jsx("span",{children:"Well-being cluster"}),e.jsx("select",{value:J,onChange:j=>V(Number(j.target.value)),className:s["v2-question-form__select"],children:_.map(j=>{const L=j.kind==="open"?"Open field":j.label||j.name;return e.jsx("option",{value:j.id,children:L},j.id)})})]}),!w&&e.jsxs("label",{className:s["v2-question-row__checkbox-label"],children:[e.jsx("input",{type:"checkbox",checked:K,onChange:j=>ae(j.target.checked),className:s["v2-question-row__checkbox"]}),e.jsx("span",{className:s["v2-question-row__checkbox-text"],children:"Include in bulk check-in"})]})]}),e.jsxs("div",{className:s["v2-question-form__actions"],children:[e.jsx("button",{type:"button",onClick:F,className:s["v2-question-form__btn-cancel"],children:"Cancel"}),e.jsx("button",{type:"button",onClick:P,disabled:!I.trim()||C,className:s["v2-question-form__btn-save"],children:C?"Saving...":"Save Question"})]})]}),e.jsx(Be,{open:k,onClose:()=>d(!1),onDelete:A})]})},De=({cluster:t,clusterIndex:l,clusters:n,onUpdateQuestion:_,onDeleteQuestion:c,onAddQuestion:b,onMoveQuestion:m,bankQuestions:h,onAddFromBank:x,isDraggable:Y=!1,dragHandleProps:k,cardRef:d,cardStyle:C,isCollapsed:D=!1,isOneOff:w=!1,scope:o,isBankOpen:r,onToggleBank:y})=>{const[I,z]=p.useState(!1),T=r!==void 0?r:I,E=f=>{y?y(f):z(A=>!A)},[J,H]=p.useState(!1),[K,g]=p.useState(""),[U,Q]=p.useState([...ve]),R=n.find(f=>f.kind==="open")||{id:999},[G,W]=p.useState(R.id),[ee,X]=p.useState(!0),a=t.questions||[],u=t.kind!=="open",O=f=>{W(f),u||(f!==R.id?X(!1):X(!0))},N=f=>{X(f),f&&W(R.id)},$=new Set(a.map(f=>f.text)),F=(h||[]).filter(f=>!$.has(f.text)),V=u?0:a.filter(f=>f.includedInBulk).length,ae=async()=>{if(!K.trim())return;const f=u?void 0:G===R.id||ee,A=u?t.id:f?null:G;let Z=Date.now();try{const L=await se.createWellbeingQuestionApi({text:K.trim(),clusterId:A,descriptors:u?U:null,kind:t.kind,scope:o||null,isAppliedToAllClusters:u?void 0:f,includedInBulk:u?void 0:ee});L?.data?.id&&(Z=L.data.id),S("Custom question created successfully","success")}catch(L){console.error("Failed to create question via API",L),S("Failed to create custom question","error")}const j={id:Z,text:K.trim(),isEnabled:!0,clusterId:A,kind:t.kind,scope:o||null,descriptors:u?U:null,includedInBulk:u?void 0:ee,isAppliedToAllClusters:u?void 0:f,sectionName:u?void 0:f?"All clusters":n.find(L=>String(L.id)===String(A))?.name||"Cluster"};b(j),g(""),Q([...ve]),W(R.id),X(!0),H(!1)},P=()=>{g(""),Q([...ve]),W(R.id),X(!0),H(!1)};return e.jsxs("div",{ref:d,style:C,className:`${s["v2-cluster-card"]} ${D?s["v2-cluster-card--collapsed"]:""}`,children:[e.jsxs("div",{className:s["v2-cluster-card__head"],children:[Y?e.jsx("span",{...k,className:s["v2-cluster-card-ext__drag-handle"],title:"Drag to reorder cluster",children:e.jsx(q.LuGripVertical,{size:20,color:"#94A3B8"})}):e.jsx("span",{className:`${s["v2-cluster-card-ext__drag-handle"]} ${s["v2-cluster-card-ext__drag-handle--disabled"]}`,title:"Open field questions cannot be reordered",children:e.jsx(q.LuGripVertical,{size:20,color:"#94A3B8"})}),e.jsx("span",{className:s["v2-cluster-card__num"],children:l}),e.jsxs("div",{className:s["v2-cluster-card__info"],children:[e.jsx("div",{className:s["v2-cluster-card__title"],children:(()=>{const f=(t.label||t.name||"").trim(),A=f.toLowerCase();return A.startsWith("open")?"Open field well-being":A.startsWith("social")?"Social (relationships) well-being":A.includes("well-being")?f:`${f} well-being`})()}),e.jsxs("div",{className:s["v2-cluster-card__count"],children:[a.length," question",a.length===1?"":"s"]})]}),e.jsxs("span",{className:s["v2-cluster-card__pill"],children:["Cluster ",l]})]}),!D&&e.jsxs(e.Fragment,{children:[!u&&e.jsxs("div",{className:s["v2-cluster-card-ext__guidance-box"],children:[e.jsx(oe.FiInfo,{size:16,color:"#1F5FB8"}),e.jsxs("span",{children:["Tick 1 - 2 open field questions (in a question's edit panel) to include in the bulk check-in. ",e.jsxs("strong",{children:[V," selected."]})]})]}),e.jsxs("div",{className:s["v2-cluster-card-ext__questions-list"],children:[a.map((f,A)=>e.jsx(ze,{item:f,kind:t.kind,clusterId:t.id,clusters:n,onChange:Z=>_(A,Z),onMove:Z=>m(A,Z),onDelete:()=>c(A),isOneOff:w||!!h},f.id||A)),a.length===0&&e.jsx("div",{className:s["v2-cluster-card-ext__empty"],children:"No questions yet. Add one below."})]}),J&&e.jsxs("div",{className:`${s["v2-question-form"]} ${s["v2-cluster-card-ext__custom-form-card"]}`,children:[e.jsx("div",{className:s["v2-cluster-card-ext__custom-form-title"],children:"Write custom question"}),e.jsxs("label",{className:s["v2-question-form__field"],children:[e.jsx("span",{className:s["v2-question-form__label"],children:"QUESTION TEXT"}),e.jsx("input",{value:K,onChange:f=>g(f.target.value),placeholder:"Short title: full question?",className:s["v2-question-form__input"],autoFocus:!0}),e.jsx("span",{className:s["v2-question-form__hint"],children:"Format as “Short title: full question?” — the title shows bold and the rest becomes the prompt."})]}),u&&e.jsxs("div",{children:[e.jsx("div",{className:`${s["v2-question-form__label"]} ${s["v2-question-form__label--spaced"]}`,children:"LINKED DESCRIPTORS (SCORE 1 ➜ 5)"}),e.jsx("div",{className:s["v2-question-form__descriptors-grid"],children:U.map((f,A)=>e.jsxs("label",{className:s["v2-question-form__descriptor-item"],children:[e.jsx("span",{className:s["v2-question-form__descriptor-num"],children:A+1}),e.jsx("input",{value:f,onChange:Z=>{const j=[...U];j[A]=Z.target.value,Q(j)},className:s["v2-question-form__descriptor-input"]})]},A))})]}),!u&&e.jsxs("div",{className:s["v2-question-form__meta-row"],children:[e.jsxs("label",{className:s["v2-question-form__select-label"],children:[e.jsx("span",{children:"Well-being cluster"}),e.jsx("select",{value:G,onChange:f=>O(Number(f.target.value)),className:s["v2-question-form__select"],children:n.map(f=>{const A=f.kind==="open"?"Open field":f.label||f.name;return e.jsx("option",{value:f.id,children:A},f.id)})})]}),e.jsxs("label",{className:s["v2-question-row__checkbox-label"],children:[e.jsx("input",{type:"checkbox",checked:ee,onChange:f=>N(f.target.checked),className:s["v2-question-row__checkbox"]}),e.jsx("span",{className:s["v2-question-row__checkbox-text"],children:"Include in bulk check-in"})]})]}),e.jsxs("div",{className:s["v2-question-form__actions"],children:[e.jsx("button",{type:"button",onClick:P,className:s["v2-question-form__btn-cancel"],children:"Cancel"}),e.jsx("button",{type:"button",onClick:ae,disabled:!K.trim(),className:s["v2-question-form__btn-save"],children:"Save Question"})]})]}),h?e.jsxs("div",{children:[e.jsxs("button",{type:"button",onClick:()=>E(),className:s["v2-cluster-card-ext__btn-toggle-bank"],children:[T?e.jsx(oe.FiChevronUp,{size:18}):e.jsx(q.LuPlus,{size:18}),T?"Close question bank":`Add from question bank (${F.length} available)`]}),T&&e.jsxs("div",{className:s["v2-cluster-card-ext__bank-panel"],children:[F.length===0?e.jsxs("div",{className:s["v2-cluster-card-ext__bank-empty"],children:["All ",t.name.toLowerCase()," bank questions have been added."]}):F.map((f,A)=>{const Z=f.text.indexOf(":"),j=Z>=0?f.text.slice(0,Z).trim():f.text,L=Z>=0?f.text.slice(Z+1).trim():"";return e.jsxs("button",{type:"button",onClick:()=>x&&x(f),className:s["v2-cluster-card-ext__bank-item"],children:[e.jsx("span",{className:s["v2-cluster-card-ext__bank-icon-circle"],children:e.jsx(q.LuPlus,{size:15,color:"#316CD9"})}),e.jsxs("span",{className:s["v2-cluster-card-ext__bank-text-wrap"],children:[e.jsx("span",{className:s["v2-cluster-card-ext__bank-item-title"],children:j}),L&&e.jsx("span",{className:s["v2-cluster-card-ext__bank-item-desc"],children:L})]})]},f.id||A)}),e.jsx("div",{className:s["v2-cluster-card-ext__bank-divider"]}),e.jsxs("button",{type:"button",onClick:()=>H(!0),className:s["v2-cluster-card-ext__btn-write-custom"],children:[e.jsx(q.LuPencil,{size:16,color:"#316CD9"}),e.jsx("span",{children:"Write a custom question instead"})]})]})]}):e.jsx("div",{className:s["v2-cluster-card-ext__bottom-actions"],children:e.jsxs("button",{type:"button",onClick:()=>H(!0),className:s["v2-cluster-card-ext__btn-add-cluster"],children:[e.jsx(q.LuPlus,{size:16})," Add question to this cluster"]})})]})]})},Qe=({cluster:t,isDraggable:l=!0,isCollapsed:n=!1,..._})=>{const{attributes:c,listeners:b,setNodeRef:m,transform:h,transition:x,isDragging:Y}=me.useSortable({id:t.id,disabled:!l}),k={transform:Ee.CSS.Transform.toString(h),transition:x,opacity:Y?.6:1,zIndex:Y?999:void 0,position:"relative"};return e.jsx(De,{..._,cluster:t,isDraggable:l,isCollapsed:n,cardRef:m,cardStyle:k,dragHandleProps:l?{...c,...b}:void 0})},Pe=({open:t,onClose:l,onConfirm:n,loading:_=!1})=>{if(!t)return null;const c=e.jsx("div",{onClick:_?void 0:l,className:s["v2-restore-modal-overlay"],children:e.jsxs("div",{onClick:b=>b.stopPropagation(),className:s["v2-restore-modal"],children:[e.jsx("div",{className:s["v2-restore-modal__icon-box"],children:e.jsx(q.LuRotateCcw,{size:26,color:"#316CD9"})}),e.jsx("div",{className:s["v2-restore-modal__title"],children:"Restore the default question set?"}),e.jsx("p",{className:s["v2-restore-modal__message"],children:"This replaces the current questions in every cluster with the MARIO defaults. Any custom edits or deletions will be lost."}),e.jsxs("div",{className:s["v2-restore-modal__actions"],children:[e.jsx("button",{type:"button",onClick:l,disabled:_,className:s["v2-restore-modal__btn-cancel"],children:"Cancel"}),e.jsx("button",{type:"button",onClick:n,disabled:_,className:s["v2-restore-modal__btn-confirm"],children:_?"Restoring...":"Restore defaults"})]})]})});return typeof document<"u"?Ce.createPortal(c,document.body):c},je=({clusters:t,onChangeClusters:l,blank:n=!1,embedded:_=!1,masterBankClusters:c=le,scope:b="routine",onRestoreDefaults:m})=>{const[h,x]=p.useState(!1),[Y,k]=p.useState(null),d=p.useRef(null),[C,D]=p.useState(null);p.useEffect(()=>{if(C===null)return;const a=u=>{if(!d.current)return;if(u.composedPath){const N=u.composedPath();if(N&&N.includes(d.current))return}const O=u.target;O&&!document.body.contains(O)||O&&d.current.contains(O)||D(null)};return document.addEventListener("click",a),()=>{document.removeEventListener("click",a)}},[C]);const[w,o]=p.useState(!1),[r,y]=p.useState(!1),I=Y!==null,z=t.reduce((a,u)=>a+(u.questions?.length||0),0),T=t.filter(a=>a.kind!=="open"&&!a.name.toLowerCase().includes("open")),E=t.find(a=>a.kind==="open"||a.name.toLowerCase().includes("open")),J=ue.useSensors(ue.useSensor(ue.PointerSensor,{activationConstraint:{distance:5}})),H=a=>{k(a.active.id)},K=async a=>{k(null);const{active:u,over:O}=a;if(!O||u.id===O.id)return;const N=T.findIndex(P=>P.id===u.id),$=T.findIndex(P=>P.id===O.id);if(N<0||$<0)return;const F=[...t],V=me.arrayMove(T,N,$),ae=E?[...V,E]:V;if(l(ae),!n)try{const P=V.filter(f=>f.id&&f.id!==999).map(f=>({id:f.id,name:f.name}));P.length>0&&(await se.orderSectionApi({sections:P}),S("Cluster order saved successfully","success"))}catch(P){console.error("Failed to auto-save cluster order, reverting",P),l(F),S("Failed to update cluster order on server. Reverted.","error")}},g=(a,u,O)=>{const N=t.map($=>{if($.id===a){const F=[...$.questions];return F[u]=O,{...$,questions:F}}return $});l(N)},U=(a,u)=>{const O=t.map(N=>{if(N.id===a){const $=[...N.questions];return $.splice(u,1),{...N,questions:$}}return N});l(O)},Q=(a,u)=>{const O=t.map(N=>N.id===a?{...N,questions:[...N.questions||[],u]}:N);l(O)},R=(a,u,O)=>{let N=null;const $=t.map(F=>{if(F.id===a){const V=[...F.questions];return N={...V[u],clusterId:O},V.splice(u,1),{...F,questions:V}}return F});if(N){const F=$.map(V=>V.id===O?{...V,questions:[...V.questions||[],N]}:V);l(F)}},G=(a,u)=>{const O=t.map(N=>N.id===a?{...N,questions:[...N.questions||[],{...u,isEnabled:!0,clusterId:a}]}:N);l(O),S(`Added "${u.text.slice(0,30)}..." to cluster`,"success")},W=()=>{o(!0)},ee=async()=>{try{if(y(!0),m)await m();else{const u=(await se.restoreDefaultQuestionsApi(b)).data;u&&(b==="routine"&&u.routineClusters?l(u.routineClusters):b==="comprehensive"&&u.comprehensiveClusters?l(u.comprehensiveClusters):(u.clusters||u.masterBankClusters)&&l(u.clusters||u.masterBankClusters)),S("Default questions restored successfully","success")}o(!1)}catch(a){console.error("Failed to restore default questions",a),S("Failed to restore default questions","error")}finally{y(!1)}},X=n||_||h;return e.jsxs("div",{ref:d,className:s["v2-review-questions"],children:[!n&&!_&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:s["v2-stat-banner"],children:[e.jsxs("div",{className:s["v2-stat-banner__left"],children:[e.jsx("span",{className:s["v2-stat-banner__icon"],children:e.jsx(q.LuFileText,{size:26,color:"#fff"})}),e.jsxs("div",{children:[e.jsx("div",{className:s["v2-stat-banner__label"],children:"Total available questions"}),e.jsx("div",{className:s["v2-stat-banner__num"],children:z})]})]}),e.jsxs("div",{className:s["v2-stat-banner__right"],children:[e.jsx("div",{className:s["v2-stat-banner__meta-sub"],children:"Across"}),e.jsx("div",{className:s["v2-stat-banner__meta-num"],children:t.length}),e.jsx("div",{className:s["v2-stat-banner__meta-sub"],children:"clusters"})]})]}),e.jsxs("button",{type:"button",onClick:()=>x(a=>!a),className:s["v2-btn-primary"],children:[h?e.jsx(q.LuEyeOff,{size:20}):e.jsx(q.LuEye,{size:20}),e.jsx("span",{children:h?"Hide all questions":"View & edit all questions"})]})]}),n&&e.jsxs("div",{className:s["v2-info-callout"],children:[e.jsx(oe.FiInfo,{size:18,color:"#316CD9",className:s["v2-info-callout__icon"]}),e.jsx("p",{className:s["v2-info-callout__text"],children:"Build your one-off check-in from scratch. Add questions to any cluster below and set their details — nothing is included until you add it."})]}),X&&e.jsxs("div",{className:`${s["v2-review-questions__builder-card"]} ${n||_?s["v2-review-questions__builder-card--transparent"]:""}`,children:[!n&&e.jsxs("div",{className:s["v2-review-questions__reorder-bar"],children:[e.jsx("span",{className:s["v2-review-questions__reorder-hint"],children:"Deleted a question by mistake? Restore the full default set at any time."}),e.jsxs("button",{type:"button",onClick:W,className:s["v2-review-questions__btn-restore"],children:[e.jsx(q.LuRotateCcw,{size:16,color:"#316CD9"})," Restore default questions"]})]}),e.jsx(ue.DndContext,{sensors:J,collisionDetection:ue.rectIntersection,onDragStart:H,onDragEnd:K,onDragCancel:()=>k(null),children:e.jsx(me.SortableContext,{items:T.map(a=>a.id),strategy:me.verticalListSortingStrategy,children:e.jsx("div",{className:`${s["v2-review-questions__cluster-list"]} ${I?s["v2-review-questions__cluster-list--dragging"]:""}`,children:T.map((a,u)=>{const O=c.find(N=>N.id===a.id||N.name===a.name)?.questions||[];return e.jsx(Qe,{cluster:a,clusterIndex:u+1,clusters:t,isDraggable:!0,isCollapsed:I,onUpdateQuestion:(N,$)=>g(a.id,N,$),onDeleteQuestion:N=>U(a.id,N),onAddQuestion:N=>Q(a.id,N),onMoveQuestion:(N,$)=>R(a.id,N,$),bankQuestions:n?O:void 0,onAddFromBank:N=>G(a.id,N),isOneOff:n,scope:b,isBankOpen:C===a.id,onToggleBank:N=>{D(N===!1?$=>$===a.id?null:$:$=>$===a.id?null:a.id)}},a.id||u)})})})}),E&&e.jsx(De,{cluster:E,clusterIndex:T.length+1,clusters:t,isDraggable:!1,isCollapsed:I,onUpdateQuestion:(a,u)=>g(E.id,a,u),onDeleteQuestion:a=>U(E.id,a),onAddQuestion:a=>Q(E.id,a),onMoveQuestion:(a,u)=>R(E.id,a,u),bankQuestions:n?c.find(a=>a.id===E.id||a.name===E.name)?.questions||[]:void 0,onAddFromBank:a=>G(E.id,a),isOneOff:n,scope:b,isBankOpen:C===E.id,onToggleBank:a=>{D(a===!1?u=>u===E.id?null:u:u=>u===E.id?null:E.id)}},E.id||"open")]}),e.jsx(Pe,{open:w,onClose:()=>o(!1),onConfirm:ee,loading:r})]})},Se=({frequency:t="weekly",isComprehensive:l=!1,subject:n,body:_})=>{const[c,b]=p.useState(!1),m=l?"comprehensive":t==="biweekly"?"weekly":t==="monthly"?"monthly":"weekly",h=l?"this term":t==="monthly"?"this month":"this week",x=n||(l?"Your comprehensive well-being check-in is coming":`Time for your ${m} well-being check-in`),Y=_||(l?"Hi Educator, the comprehensive check-in is coming up. Take some time to answer the full set of questions about your well-being. Your voice helps shape the support we provide.":`Hi Educator, take care of yourself and complete ${h}'s check-in for Physical well-being. It only takes a couple of minutes, and your responses help us support you.`);return e.jsxs("div",{className:s["v2-email-preview-wrapper"],children:[e.jsxs("button",{type:"button",onMouseEnter:()=>b(!0),onMouseLeave:()=>b(!1),onClick:()=>b(k=>!k),className:s["v2-btn-preview-email"],children:[e.jsx(q.LuEye,{size:16}),e.jsx("span",{children:"Preview email"})]}),c&&e.jsxs("div",{className:s["v2-email-preview-popover"],onMouseEnter:()=>b(!0),onMouseLeave:()=>b(!1),children:[e.jsxs("div",{className:s["v2-email-preview-popover__head"],children:[e.jsxs("div",{className:s["v2-email-preview-popover__logo-wrap"],children:[e.jsx("span",{className:s["v2-email-preview-popover__logo-circle"],children:"M"}),e.jsx("span",{className:s["v2-email-preview-popover__logo-text"],children:"MARIO"})]}),e.jsx("span",{className:s["v2-email-preview-popover__brand"],children:"MARIO for Me"})]}),e.jsxs("div",{className:s["v2-email-preview-popover__body"],children:[e.jsx("div",{className:s["v2-email-preview-popover__to"],children:"To: All educators"}),e.jsx("h4",{className:s["v2-email-preview-popover__title"],children:x}),e.jsx("p",{className:s["v2-email-preview-popover__desc"],children:Y}),e.jsxs("button",{type:"button",className:s["v2-email-preview-popover__btn-start"],children:[e.jsx("span",{children:"Start check-in"}),e.jsx(q.LuArrowRight,{size:14})]})]})]})]})},We=({config:t,onChangeConfig:l,clusters:n,onChangeClusters:_,onSave:c,onRestoreDefaults:b})=>{const m=t.isEnabled,h=()=>{const d=!t.isEnabled,C=qe.find(D=>D.rec)?.id||"biweekly";l({...t,isEnabled:d,frequency:d&&(!t.frequency||t.frequency==="monthly")?C:t.frequency||C})},x=d=>{l({...t,frequency:d})},Y=d=>{l({...t,dayOfWeek:d})},k=()=>{l({...t,emailNotify:!t.emailNotify})};return e.jsxs("div",{className:s["v2-routine-container"],children:[e.jsxs("div",{className:`${s["v2-power-card"]} ${m?s["v2-power-card--active"]:""}`,children:[e.jsx("span",{className:s["v2-power-card__icon"],children:e.jsx(q.LuPower,{size:22,color:m?"#316CD9":"#858585"})}),e.jsxs("div",{className:s["v2-power-card__content"],children:[e.jsxs("div",{className:s["v2-power-card__title"],children:["Routine check-in is ",m?"on":"off"]}),e.jsx("div",{className:s["v2-power-card__sub"],children:m?"This check-in is active and will be sent on the schedule below.":"This check-in is turned off. Turn it on to configure and send it."})]}),e.jsx("span",{className:`${s["v2-power-card__state-text"]} ${m?s["v2-power-card__state-text--active"]:""}`,children:m?"On":"Off"}),e.jsx("button",{type:"button",onClick:h,className:`${s["v2-power-card__switch"]} ${m?s["v2-power-card__switch--active"]:""}`,children:e.jsx("span",{className:`${s["v2-power-card__knob"]} ${m?s["v2-power-card__knob--active"]:""}`})})]}),e.jsxs("div",{className:`${s["v2-routine-body"]} ${m?"":s["v2-routine-body--disabled"]}`,children:[e.jsxs("div",{className:s["v2-info-callout"],children:[e.jsx(oe.FiInfo,{size:20,color:"#316CD9",className:s["v2-info-callout__icon"]}),e.jsx("p",{className:s["v2-info-callout__text"],children:"MARIO recommends running the primary check-in on a bi-weekly basis, sending a smaller section of questions that rotate each time so teachers get a quick, focused pulse."})]}),e.jsxs("div",{className:s["v2-section-box"],children:[e.jsxs("div",{className:s["v2-section-box__header"],children:[e.jsx("span",{className:s["v2-section-box__num"],children:"1"}),e.jsx("div",{className:s["v2-section-box__title"],children:"How often it is sent"})]}),e.jsx("p",{className:s["v2-section-box__sub"],children:"Questions are grouped per section (a rotating cluster each time). Choose the cadence and the day of the week it goes out."}),e.jsxs("div",{className:s["v2-section-box__body"],children:[e.jsx("div",{className:s["v2-cadence-grid"],children:qe.map(d=>{const C=t.frequency===d.id;return e.jsxs("button",{type:"button",onClick:()=>x(d.id),className:`${s["v2-cadence-card"]} ${C?s["v2-cadence-card--selected"]:""}`,children:[e.jsxs("span",{className:s["v2-cadence-card__top"],children:[e.jsx("span",{className:`${s["v2-cadence-card__radio"]} ${C?s["v2-cadence-card__radio--selected"]:""}`}),e.jsx("span",{className:s["v2-cadence-card__title"],children:d.title}),d.rec&&e.jsx("span",{className:s["v2-cadence-card__badge"],children:"Recommended"})]}),e.jsx("span",{className:s["v2-cadence-card__sub"],children:d.sub})]},d.id)})}),e.jsxs("div",{children:[e.jsx("div",{className:s["v2-field-label"],children:"DAY OF THE WEEK IT GOES OUT"}),e.jsx("div",{className:s["v2-days-row"],children:Fe.map(d=>{const C=t.dayOfWeek===d;return e.jsx("button",{type:"button",onClick:()=>Y(d),className:`${s["v2-day-pill"]} ${C?s["v2-day-pill--selected"]:""}`,children:d},d)})})]}),e.jsxs("div",{className:s["v2-rotation-box"],children:[e.jsxs("div",{className:s["v2-rotation-box__head"],children:[e.jsx(oe.FiInfo,{size:17,color:"#316CD9"}),e.jsx("span",{children:"How the rotation works"})]}),e.jsxs("p",{className:s["v2-rotation-box__desc"],children:["Each ",t.frequency==="biweekly"?"two weeks":t.frequency==="monthly"?"month":"week",", educators receive one well-being section to answer. The next cycle rotates to the following section, and so on. For example:"]}),e.jsx("div",{className:s["v2-rotation-box__list"],children:[["Week 1","Physical well-being","4 questions"],["Week 2","Emotional well-being","4 questions"],["Week 3","Environmental well-being","4 questions"]].map((d,C)=>e.jsxs("div",{className:s["v2-rotation-box__item"],children:[e.jsx("span",{className:s["v2-rotation-box__cycle"],children:d[0]}),e.jsx("span",{className:s["v2-rotation-box__title"],children:d[1]}),e.jsx("span",{className:s["v2-rotation-box__tag"],children:d[2]})]},C))})]})]})]}),e.jsxs("div",{className:s["v2-section-box"],children:[e.jsxs("div",{className:s["v2-section-box__header"],children:[e.jsx("span",{className:s["v2-section-box__num"],children:"2"}),e.jsx("div",{className:s["v2-section-box__title"],children:"Review & edit questions"})]}),e.jsx("p",{className:s["v2-section-box__sub"],children:"Review and customize the questions sent in this check-in across all well-being sections."}),e.jsx(je,{clusters:n,onChangeClusters:_,scope:"routine",onRestoreDefaults:b})]}),e.jsxs("div",{className:s["v2-section-box"],children:[e.jsxs("div",{className:s["v2-section-box__header"],children:[e.jsx("span",{className:s["v2-section-box__num"],children:"3"}),e.jsx("div",{className:s["v2-section-box__title"],children:"Notify by email"})]}),e.jsx("p",{className:s["v2-section-box__sub"],children:"Send an email to educators when this check-in goes out. Hover the preview to see the message."}),e.jsxs("div",{className:`${s["v2-email-box"]} ${t.emailNotify?s["v2-email-box--active"]:""}`,children:[e.jsx("span",{className:s["v2-email-box__icon"],children:e.jsx(oe.FiMail,{size:20,color:t.emailNotify?"#316CD9":"#858585"})}),e.jsxs("div",{className:s["v2-email-box__content"],children:[e.jsx("div",{className:s["v2-email-box__title"],children:"Notify educators by email"}),e.jsx("div",{className:s["v2-email-box__sub"],children:t.emailNotify?"An email is sent to each educator when this check-in goes out.":"No email is sent. Educators see it in the app only."})]}),e.jsx("span",{className:`${s["v2-email-box__state-text"]} ${t.emailNotify?s["v2-email-box__state-text--active"]:""}`,children:t.emailNotify?"On":"Off"}),e.jsx("button",{type:"button",onClick:k,className:`${s["v2-email-box__switch"]} ${t.emailNotify?s["v2-email-box__switch--active"]:""}`,children:e.jsx("span",{className:`${s["v2-email-box__knob"]} ${t.emailNotify?s["v2-email-box__knob--active"]:""}`})})]}),e.jsx(Se,{frequency:t.frequency})]}),e.jsxs("button",{type:"button",onClick:c,className:s["v2-btn-primary"],children:[e.jsx(q.LuCheck,{size:20,color:"#fff"})," Save configuration"]})]})]})},Ve=({config:t,onChangeConfig:l,clusters:n,onChangeClusters:_,onSave:c,onRestoreDefaults:b})=>{const m=t.isEnabled,h=()=>{l({...t,isEnabled:!t.isEnabled})},x=D=>[...D].sort((w,o)=>w?o?M(w,"YYYY-MM-DD").valueOf()-M(o,"YYYY-MM-DD").valueOf():-1:1),Y=(D,w)=>{if(w&&t.sendDates.some((y,I)=>I!==D&&y===w)){S("This date has already been added to the schedule.","warning");return}const o=[...t.sendDates];o[D]=w;const r=x(o);l({...t,sendDates:r})},k=()=>{const D=x(t.sendDates.filter(r=>r&&M(r,"YYYY-MM-DD").isValid()));let w=M().add(1,"month").format("YYYY-MM-DD");if(D.length>0){const r=D[D.length-1];w=M(r,"YYYY-MM-DD").add(1,"month").format("YYYY-MM-DD")}for(;t.sendDates.includes(w);)w=M(w,"YYYY-MM-DD").add(1,"month").format("YYYY-MM-DD");const o=x([...t.sendDates,w]);l({...t,sendDates:o})},d=D=>{const w=t.sendDates.filter((o,r)=>r!==D);l({...t,sendDates:x(w)})},C=()=>{l({...t,emailNotify:!t.emailNotify})};return e.jsxs("div",{className:s["v2-comprehensive-container"],children:[e.jsxs("div",{className:`${s["v2-power-card"]} ${m?s["v2-power-card--active"]:""}`,children:[e.jsx("span",{className:s["v2-power-card__icon"],children:e.jsx(q.LuPower,{size:22,color:m?"#316CD9":"#858585"})}),e.jsxs("div",{className:s["v2-power-card__content"],children:[e.jsxs("div",{className:s["v2-power-card__title"],children:["Comprehensive check-in is ",m?"on":"off"]}),e.jsx("div",{className:s["v2-power-card__sub"],children:m?"This check-in is active and will be sent on the schedule below.":"This check-in is turned off. Turn it on to configure and send it."})]}),e.jsx("span",{className:`${s["v2-power-card__state-text"]} ${m?s["v2-power-card__state-text--active"]:""}`,children:m?"On":"Off"}),e.jsx("button",{type:"button",onClick:h,className:`${s["v2-power-card__switch"]} ${m?s["v2-power-card__switch--active"]:""}`,children:e.jsx("span",{className:`${s["v2-power-card__knob"]} ${m?s["v2-power-card__knob--active"]:""}`})})]}),e.jsxs("div",{className:`${s["v2-comprehensive-body"]} ${m?"":s["v2-comprehensive-body--disabled"]}`,children:[e.jsxs("div",{className:s["v2-info-callout"],children:[e.jsx(oe.FiInfo,{size:20,color:"#316CD9",className:s["v2-info-callout__icon"]}),e.jsx("p",{className:s["v2-info-callout__text"],children:"The comprehensive check-in sends all of the questions at once for a complete picture of staff well-being. The question bank is long, around 29 questions, so we recommend spacing it out over longer periods and not repeating it too often. Sending it too frequently tends to lower how thoughtfully teachers engage. When a comprehensive check-in is running, the routine check-in is paused for that period so teachers only receive one check-in at a time."})]}),e.jsxs("div",{className:s["v2-section-box"],children:[e.jsxs("div",{className:s["v2-section-box__header"],children:[e.jsx("span",{className:s["v2-section-box__num"],children:"1"}),e.jsx("div",{className:s["v2-section-box__title"],children:"How often it is sent"})]}),e.jsx("p",{className:s["v2-section-box__sub"],children:"A comprehensive check-in that sends all of the questions at once. Choose the dates it is sent. Each one stays open for 14 days."}),e.jsxs("div",{className:s["v2-section-box__body"],children:[e.jsxs("div",{children:[e.jsx("div",{className:s["v2-field-label"],children:"DATES IT IS SENT"}),e.jsx(de.LocalizationProvider,{dateAdapter:we.AdapterMoment,children:e.jsxs("div",{className:s["v2-dates-list"],children:[t.sendDates.map((D,w)=>{const o=D&&M(D,"YYYY-MM-DD").isValid()?M(D,"YYYY-MM-DD"):null;return e.jsxs("div",{className:s["v2-date-row"],children:[e.jsx("span",{className:s["v2-date-row__idx"],children:w+1}),e.jsx("div",{className:s["v2-comprehensive-date-picker-wrap"],children:e.jsx(de.DatePicker,{value:o,shouldDisableDate:r=>{if(!r||!r.isValid())return!1;const y=r.format("YYYY-MM-DD");return t.sendDates.some((I,z)=>z!==w&&I===y)},onChange:r=>{const y=r&&M(r).isValid()?M(r).format("YYYY-MM-DD"):"";Y(w,y)},format:"MMM DD, YYYY",slotProps:{textField:{size:"small",fullWidth:!0,variant:"outlined",sx:{background:"#fff","& .MuiOutlinedInput-root":{borderRadius:"10px",fontSize:"14.5px",fontWeight:500,color:"#242424",height:42,"& fieldset":{borderColor:"#D3D3D3"},"&:hover fieldset":{borderColor:"#316CD9"},"&.Mui-focused fieldset":{borderColor:"#316CD9"}},"& .MuiInputBase-input":{padding:"8px 12px"}}}}})}),t.sendDates.length>1&&e.jsx("button",{type:"button",onClick:()=>d(w),title:"Remove date",className:s["v2-date-row__btn-remove"],children:e.jsx(q.LuTrash2,{size:16,color:"#C44140"})})]},w)}),e.jsxs("button",{type:"button",onClick:k,className:s["v2-comprehensive-btn-add-date"],children:[e.jsx(q.LuPlus,{size:17,color:"#316CD9"})," Add send date"]})]})})]}),e.jsxs("div",{className:s["v2-comprehensive-note-box"],children:[e.jsx(q.LuCalendar,{size:20,color:"#316CD9",className:s["v2-comprehensive-note-box__icon"]}),e.jsxs("p",{className:s["v2-comprehensive-note-box__text"],children:["Each check-in stays open for ",e.jsx("strong",{children:"14 days"})," from the date you set. Add a date at the end of every quarter for a quarterly rhythm, a single date at year end for a yearly one, or combine both. For example: send on Oct 15, Jan 15, Mar 30 and Jun 15 for a quarterly cadence, or just Jun 15 for a yearly one."]})]})]})]}),e.jsxs("div",{className:s["v2-section-box"],children:[e.jsxs("div",{className:s["v2-section-box__header"],children:[e.jsx("span",{className:s["v2-section-box__num"],children:"2"}),e.jsx("div",{className:s["v2-section-box__title"],children:"Review & edit questions"})]}),e.jsx("p",{className:s["v2-section-box__sub"],children:"Review and customize the questions sent in this comprehensive check-in across all well-being sections."}),e.jsx(je,{clusters:n,onChangeClusters:_,scope:"comprehensive",onRestoreDefaults:b})]}),e.jsxs("div",{className:s["v2-section-box"],children:[e.jsxs("div",{className:s["v2-section-box__header"],children:[e.jsx("span",{className:s["v2-section-box__num"],children:"3"}),e.jsx("div",{className:s["v2-section-box__title"],children:"Notify by email"})]}),e.jsx("p",{className:s["v2-section-box__sub"],children:"Send an email to educators when this check-in goes out. Hover the preview to see the message."}),e.jsxs("div",{className:`${s["v2-email-box"]} ${t.emailNotify?s["v2-email-box--active"]:""}`,children:[e.jsx("span",{className:s["v2-email-box__icon"],children:e.jsx(oe.FiMail,{size:20,color:t.emailNotify?"#316CD9":"#858585"})}),e.jsxs("div",{className:s["v2-email-box__content"],children:[e.jsx("div",{className:s["v2-email-box__title"],children:"Notify educators by email"}),e.jsx("div",{className:s["v2-email-box__sub"],children:t.emailNotify?"An email is sent to each educator when this check-in goes out.":"No email is sent. Educators see it in the app only."})]}),e.jsx("span",{className:`${s["v2-email-box__state-text"]} ${t.emailNotify?s["v2-email-box__state-text--active"]:""}`,children:t.emailNotify?"On":"Off"}),e.jsx("button",{type:"button",onClick:C,className:`${s["v2-email-box__switch"]} ${t.emailNotify?s["v2-email-box__switch--active"]:""}`,children:e.jsx("span",{className:`${s["v2-email-box__knob"]} ${t.emailNotify?s["v2-email-box__knob--active"]:""}`})})]}),e.jsx(Se,{isComprehensive:!0})]}),e.jsxs("button",{type:"button",onClick:c,className:s["v2-btn-primary"],children:[e.jsx(q.LuCheck,{size:20,color:"#fff"})," Save configuration"]})]})]})},Ue=({open:t,onClose:l,pastOneOff:n,masterBankClusters:_})=>{if(!t||!n)return null;const c=[];n.sendDates&&Array.isArray(n.sendDates)&&n.sendDates.length>0?n.sendDates.forEach(o=>{o&&!c.includes(o)&&c.push(o)}):n.sentDate&&c.push(n.sentDate),c.sort((o,r)=>M(o,"YYYY-MM-DD").valueOf()-M(r,"YYYY-MM-DD").valueOf());const b=o=>{if(!o)return"";try{const r=o.includes("T")?o:`${o}T00:00:00`,y=new Date(r);return isNaN(y.getTime())?o:y.toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric"})}catch{return o||""}},m=o=>o==null?"":typeof o=="object"?String(o.id||o.Id||o.questionId||o.QuestionId||o.value||""):String(o).trim(),h=(_||[]).flatMap(o=>o.questions||[]);let x=[];if(n.questions&&n.questions.length>0)x=n.questions;else{const o=new Set((n.questionIds||[]).map(m).filter(Boolean));if(x=h.filter(r=>o.has(String(r.id))),x.length===0&&o.size>0&&(x=Array.from(o).map(r=>{const y=Number(r);if(!isNaN(y)){if(h[y-1])return h[y-1];if(h[y])return h[y]}return null}).filter(Boolean)),x.length===0&&(n.questionCount>0||o.size>0)&&h.length>0){const r=n.questionCount>0?Math.min(n.questionCount,h.length):Math.min(o.size,h.length);x=h.slice(0,r)}}const Y=x.filter(o=>o.kind!=="open"),k=x.filter(o=>o.kind==="open"),d=[],C=(_||[]).filter(o=>o.kind!=="open");for(const o of C){const r=Y.filter(T=>String(T.clusterId)===String(o.id)),y=k.filter(T=>!T.isAppliedToAllClusters&&T.clusterId&&T.clusterId!==999&&String(T.clusterId)===String(o.id)),I=r.length>0||y.length>0?k.filter(T=>T.isAppliedToAllClusters):[],z=[...r,...y,...I];z.length>0&&d.push({cluster:o,questions:z})}const D=(_||[]).find(o=>o.kind==="open");if(D&&k.length>0){const o=new Set(d.flatMap(y=>y.questions.map(I=>String(I.id)))),r=k.filter(y=>!o.has(String(y.id)));(r.length>0||d.length===0)&&d.push({cluster:D,questions:r.length>0?r:k})}if(d.length===0&&x.length>0){const o=new Map;x.forEach(r=>{const y=r.clusterId||1;o.has(y)||o.set(y,[]),o.get(y).push(r)}),o.forEach((r,y)=>{const I=(_||[]).find(z=>String(z.id)===String(y))||{id:Number(y)||1,name:"Well-being Cluster",label:"Well-being Cluster",icon:"dumbbell",order:1,kind:"indicator",questions:[]};d.push({cluster:I,questions:r})})}const w=d.reduce((o,r)=>o+r.questions.length,0);return e.jsx("div",{onClick:l,className:s["v2-launch-modal-overlay"],children:e.jsxs("div",{onClick:o=>o.stopPropagation(),className:s["v2-view-modal"],children:[e.jsxs("div",{className:s["v2-view-modal__header"],children:[e.jsx("button",{type:"button",onClick:l,className:s["v2-view-modal__btn-close"],title:"Close modal",children:e.jsx(q.LuX,{size:18,color:"#6B6B6B"})}),e.jsx("div",{className:s["v2-view-modal__icon-box"],children:e.jsx(q.LuHistory,{size:22,color:"#A56F1A"})}),e.jsxs("div",{className:s["v2-view-modal__title-wrap"],children:[e.jsx("div",{className:s["v2-view-modal__title"],children:n.name||"One-off check-in"}),e.jsx("div",{className:s["v2-view-modal__meta"],children:`${w||n.questionCount} questions · ${n.responseCount} of ${n.totalTeachers} responded`})]})]}),e.jsxs("div",{className:s["v2-view-modal__body"],children:[c.length>0&&e.jsxs("div",{className:s["v2-view-modal__sent-section"],children:[e.jsx("span",{className:s["v2-view-modal__section-label"],children:c.length>1?"SCHEDULED & SENT DATES":"SENT ON"}),e.jsx("div",{className:s["v2-view-modal__sent-badges-list"],children:c.map((o,r)=>{const y=M(o,"YYYY-MM-DD").startOf("day").isBefore(M().startOf("day"));return e.jsxs("div",{className:`${s["v2-view-modal__sent-badge"]} ${y?s["v2-view-modal__sent-badge--past"]:s["v2-view-modal__sent-badge--future"]}`,children:[e.jsx(q.LuCalendar,{size:15,color:y?"#9CA3AF":"#2563EB"}),e.jsx("span",{children:b(o)})]},o||r)})})]}),e.jsxs("div",{className:s["v2-view-modal__questions-section"],children:[e.jsx("span",{className:s["v2-view-modal__section-label"],children:"QUESTIONS"}),d.length===0?e.jsx("div",{className:s["v2-view-modal__empty"],children:"No question details found for this check-in."}):d.map(({cluster:o,questions:r})=>e.jsxs("div",{className:s["v2-view-modal__cluster-group"],children:[e.jsx("div",{className:s["v2-view-modal__cluster-header"],children:o.label||o.name}),e.jsx("div",{className:s["v2-view-modal__questions-list"],children:r.map((y,I)=>{const z=(y.text||"").replace(/&rsquo;/g,"'").replace(/&lsquo;/g,"'").replace(/&rdquo;/g,'"').replace(/&ldquo;/g,'"').replace(/&quot;/g,'"').replace(/&#39;/g,"'").replace(/&amp;/g,"&").replace(/&nbsp;/g," ");return e.jsxs("div",{className:s["v2-view-modal__question-row"],children:[e.jsx("span",{className:s["v2-view-modal__question-num"],children:I+1}),e.jsx("span",{className:s["v2-view-modal__question-text"],children:z})]},y.id||I)})})]},o.id))]})]}),e.jsx("div",{className:s["v2-view-modal__footer-single"],children:e.jsx("button",{type:"button",onClick:l,className:s["v2-view-modal__btn-close-footer"],children:"Close"})})]})})},He=({open:t,onClose:l,pastOneOff:n,onConfirm:_})=>{const[c,b]=p.useState("");if(p.useEffect(()=>{t&&b("")},[t,n?.id]),!t||!n)return null;const m=new Set;n.sentDate&&M(n.sentDate).isValid()&&m.add(M(n.sentDate).format("YYYY-MM-DD")),n.sendDates&&Array.isArray(n.sendDates)&&n.sendDates.forEach(d=>{d&&M(d).isValid()&&m.add(M(d).format("YYYY-MM-DD"))});const h=c&&M(c,"YYYY-MM-DD").isValid()?M(c,"YYYY-MM-DD"):null,x=!!(c&&M(c,"YYYY-MM-DD").isValid()&&!m.has(c)),Y=n.questionCount||n.questionIds?.length||n.questions?.length||0,k=()=>{if(x){if(m.has(c)){S("This check-in has already been scheduled or sent on this date.","warning");return}_?_(n,c):S(`Scheduled "${n.name}" to send on ${M(c).format("MMMM DD, YYYY")}`,"success"),l()}};return e.jsx("div",{onClick:l,className:s["v2-launch-modal-overlay"],children:e.jsxs("div",{onClick:d=>d.stopPropagation(),className:s["v2-launch-modal"],children:[e.jsx("button",{type:"button",onClick:l,className:s["v2-launch-modal__btn-close"],children:e.jsx(q.LuX,{size:18,color:"#6B6B6B"})}),e.jsx("div",{className:s["v2-sendagain-modal__icon-box"],children:e.jsx(q.LuSend,{size:24,color:"#316CD9"})}),e.jsx("div",{className:s["v2-launch-modal__title"],children:"Send it again"}),e.jsxs("p",{className:s["v2-launch-modal__sub"],children:["“",n.name,"” will be sent again with the same ",Y," question",Y>1?"s":"",". Choose the date it should go out."]}),e.jsx("div",{className:s["v2-launch-modal__form"],children:e.jsxs("div",{children:[e.jsx("span",{className:s["v2-launch-modal__field-label"],children:"SEND DATE"}),e.jsx(de.LocalizationProvider,{dateAdapter:we.AdapterMoment,children:e.jsx(de.DatePicker,{value:h,minDate:M().startOf("day"),shouldDisableDate:d=>{if(!d||!d.isValid())return!1;const C=d.format("YYYY-MM-DD");return m.has(C)},onChange:d=>{const C=d&&M(d).isValid()?M(d).format("YYYY-MM-DD"):"";if(C&&m.has(C)){S("This check-in has already been scheduled or sent on this date.","warning");return}b(C)},format:"MMMM DD, YYYY",slotProps:{textField:{fullWidth:!0,variant:"outlined",placeholder:"mm/dd/yyyy",sx:{background:"#fff","& .MuiOutlinedInput-root":{borderRadius:"12px",fontSize:"15px",fontWeight:500,color:"#242424",height:48,"& fieldset":{borderColor:"#D3D3D3"},"&:hover fieldset":{borderColor:"#316CD9"},"&.Mui-focused fieldset":{borderColor:"#316CD9"}},"& .MuiInputBase-input":{padding:"12px 14px"}}}}})})]})}),e.jsxs("div",{className:s["v2-launch-modal__actions"],children:[e.jsx("button",{type:"button",onClick:l,className:s["v2-launch-modal__btn-cancel"],children:"Cancel"}),e.jsxs("button",{type:"button",onClick:k,disabled:!x,className:`${s["v2-launch-modal__btn-start"]} ${x?s["v2-launch-modal__btn-start--valid"]:""}`,children:[e.jsx(q.LuSend,{size:18,color:"#fff"})," Schedule send"]})]})]})})},Ke=({clusters:t,onChangeClusters:l,pastOneOffs:n,masterBankClusters:_=le,onSaveAndContinue:c,onSendItAgain:b,isOn:m=!0,onToggle:h})=>{const[x,Y]=p.useState(!0),k=m!==void 0?m:x,d=()=>{h?h(!k):Y(g=>!g)},[C,D]=p.useState(!1),[w,o]=p.useState(""),[r,y]=p.useState(null),[I,z]=p.useState(null),T=(g,U)=>{b?b(g,U):S(`Scheduled "${g.name}" to send on ${M(U).format("MMMM DD, YYYY")}`,"success"),z(null)},E=g=>{try{return new Date(g+"T00:00:00").toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric"})}catch{return g}},J=g=>g.questions&&g.questions.length>0?g.questions.length:g.questionCount?g.questionCount:g.questionIds&&g.questionIds.length>0?g.questionIds.length:0,H=t.reduce((g,U)=>g+(U.questions?.length||0),0),K=!w.trim()||H===0;return e.jsxs("div",{className:s["v2-oneoff-container"],children:[e.jsxs("div",{className:`${s["v2-power-card"]} ${k?s["v2-power-card--active"]:""}`,children:[e.jsx("span",{className:s["v2-power-card__icon"],children:e.jsx(q.LuCalendarClock,{size:22,color:k?"#316CD9":"#858585"})}),e.jsxs("div",{className:s["v2-power-card__content"],children:[e.jsx("div",{className:s["v2-power-card__title"],children:"One-off check-in"}),e.jsx("div",{className:s["v2-power-card__sub"],children:"Turn this on to build and send a single check-in. It does not repeat, and it does not affect your routine or comprehensive schedules."})]}),e.jsx("span",{className:`${s["v2-power-card__state-text"]} ${k?s["v2-power-card__state-text--active"]:""}`,children:k?"On":"Off"}),e.jsx("button",{type:"button",onClick:d,className:`${s["v2-power-card__switch"]} ${k?s["v2-power-card__switch--active"]:""}`,children:e.jsx("span",{className:`${s["v2-power-card__knob"]} ${k?s["v2-power-card__knob--active"]:""}`})})]}),e.jsxs("div",{className:s["v2-oneoff-accordion"],children:[e.jsxs("button",{type:"button",onClick:()=>D(g=>!g),className:s["v2-oneoff-accordion__header"],children:[e.jsx("span",{className:s["v2-oneoff-accordion__icon-box"],children:e.jsx(q.LuHistory,{size:20,color:"#A56F1A"})}),e.jsxs("div",{className:s["v2-oneoff-accordion__title-group"],children:[e.jsx("div",{className:s["v2-oneoff-accordion__title"],children:"Previous one-off check-ins"}),e.jsxs("div",{className:s["v2-oneoff-accordion__subtitle"],children:[n.length," sent. Review what went out and reuse it as a starting point."]})]}),C?e.jsx(oe.FiChevronUp,{size:18,color:"#6B6B6B"}):e.jsx(oe.FiChevronDown,{size:18,color:"#6B6B6B"})]}),C&&e.jsx("div",{className:s["v2-oneoff-accordion__body"],children:n.length===0?e.jsx("div",{className:s["v2-oneoff-accordion__empty"],children:"No previous one-off check-ins found."}):n.map((g,U)=>{const R=Array.from(new Set([...g.sendDates||[],...g.sentDate?[g.sentDate]:[]])).filter(Boolean).sort((G,W)=>M(G,"YYYY-MM-DD").valueOf()-M(W,"YYYY-MM-DD").valueOf()).map(E).join(", ");return e.jsxs("div",{className:s["v2-oneoff-accordion__item"],children:[e.jsxs("div",{className:s["v2-oneoff-accordion__item-info"],children:[e.jsx("div",{className:s["v2-oneoff-accordion__item-name"],children:g.name}),e.jsx("div",{className:s["v2-oneoff-accordion__item-meta"],children:`Sent ${R||E(g.sentDate)} · ${J(g)} questions · ${g.responseCount||0} of ${g.totalTeachers||0} responded`})]}),e.jsxs("div",{className:s["v2-oneoff-accordion__item-actions"],children:[e.jsxs("button",{type:"button",onClick:()=>y(g),className:s["v2-oneoff-accordion__btn-view"],children:[e.jsx(q.LuEye,{size:15,color:"#4B5563"})," View"]}),e.jsxs("button",{type:"button",onClick:()=>z(g),className:s["v2-oneoff-accordion__btn-send-again"],children:[e.jsx(q.LuSend,{size:14,color:"#316CD9"})," Send it again"]})]})]},g.id||U)})})]}),e.jsx(Ue,{open:!!r,onClose:()=>y(null),pastOneOff:r,masterBankClusters:_}),e.jsx(He,{open:!!I,onClose:()=>z(null),pastOneOff:I,onConfirm:T}),k&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:s["v2-section-box"],children:[e.jsxs("div",{className:s["v2-section-box__header"],children:[e.jsx("span",{className:s["v2-section-box__num"],children:"1"}),e.jsx("div",{className:s["v2-section-box__title"],children:"Name this check-in"})]}),e.jsx("p",{className:s["v2-section-box__sub"],children:"Give it a name so you can find it later. The name appears in the list of previous one-off check-ins and is not shown to staff."}),e.jsxs("div",{className:s["v2-name-box"],children:[e.jsx("span",{className:s["v2-name-box__label"],children:"CHECK-IN NAME"}),e.jsx("input",{type:"text",value:w,onChange:g=>o(g.target.value),placeholder:"e.g. Start of term pulse",className:s["v2-name-box__input"]}),e.jsx("span",{className:s["v2-name-box__hint"],children:"Required before sending."})]})]}),e.jsxs("div",{className:s["v2-section-box"],children:[e.jsxs("div",{className:s["v2-section-box__header"],children:[e.jsx("span",{className:s["v2-section-box__num"],children:"2"}),e.jsx("div",{className:s["v2-section-box__title"],children:"Build your questions"})]}),e.jsx("p",{className:s["v2-section-box__sub"],children:"A one-off check-in starts blank. Add questions to any cluster, tag them, and set their descriptors before sending."}),e.jsx(je,{clusters:t,onChangeClusters:l,blank:!0,masterBankClusters:_,scope:"oneoff"})]}),e.jsxs("div",{className:s["v2-section-box"],children:[e.jsxs("div",{className:s["v2-section-box__header"],children:[e.jsx("span",{className:s["v2-section-box__num"],children:e.jsx(q.LuSend,{size:16,color:"#fff"})}),e.jsx("div",{className:s["v2-section-box__title"],children:"Send the check-in"})]}),e.jsx("p",{className:s["v2-section-box__sub"],children:w.trim()?`“${w.trim()}” will be sent once to all teachers. You'll choose the start date next.`:"Send this one-time staff check-in to all teachers. You'll choose the start date next."}),!w.trim()&&e.jsxs("div",{className:s["v2-send-warning-box"],children:[e.jsx(q.LuInfo,{size:16,color:"#B45309",className:s["v2-send-warning-box__icon"]}),e.jsx("span",{children:"Add a name above before sending, so this check-in shows correctly in your list."})]}),e.jsxs("button",{type:"button",onClick:()=>c(w.trim()),disabled:K,className:s["v2-btn-primary"],title:w.trim()?H===0?"Please add at least 1 question to continue":"":"Please enter a check-in name to continue",children:[e.jsx(q.LuCheck,{size:20,color:"#fff"}),"Save & continue"]})]})]})]})},Ge=({size:t=40,color:l="#0F9655",...n})=>e.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:t,height:t,viewBox:"0 0 24 24",fill:"none",stroke:l,strokeWidth:"2.2",strokeLinecap:"round",strokeLinejoin:"round",...n,children:[e.jsx("circle",{cx:"12",cy:"12",r:"10"}),e.jsx("path",{d:"m9 12 2 2 4-4"})]}),Je=({data:t,loading:l=!1,hasError:n=!1,onRetry:_,onEditMode:c,onToggleRoutine:b,onToggleComprehensive:m,onToggleOneOff:h,isOneOffEnabled:x})=>{const Y=Oe.useNavigate(),k=t.routine,d=t.comprehensive,C=x!==void 0?x:t.isOneOffEnabled!==!1,D=()=>k.isEnabled?`Per cluster · ${k.frequency==="weekly"?"Weekly (every 7 days)":k.frequency==="monthly"?"Monthly (every 30 days)":"Bi-weekly (every 14 days)"}`:"Paused — no check-ins are being sent",w=()=>d.isEnabled?`Comprehensive · ${d.frequency==="yearly"?"Yearly (once a year)":d.frequency==="semesterly"?"Semesterly (every ~6 months)":d.frequency==="monthly"?"Monthly (every 30 days)":"Quarterly (every term (~3 months))"}`:"Paused — no check-ins are being sent",o=[{id:"routine",title:"Routine check-in",icon:e.jsx(q.LuRepeat,{size:20,color:"#316CD9"}),iconModifierClass:s["v2-saved-item__icon--routine"],subText:D(),loadingText:"Loading routine status...",errorText:"Unable to load routine status",isEnabled:!!k.isEnabled,onToggle:()=>b&&b(!k.isEnabled)},{id:"comprehensive",title:"Comprehensive check-in",icon:e.jsx(q.LuCalendarRange,{size:20,color:"#0284C7"}),iconModifierClass:s["v2-saved-item__icon--comprehensive"],subText:w(),loadingText:"Loading survey status...",errorText:"Unable to load survey status",isEnabled:!!d.isEnabled,onToggle:()=>m&&m(!d.isEnabled)},{id:"oneoff",title:"One-off check-in",icon:e.jsx(q.LuCalendarClock,{size:20,color:"#D97706"}),iconModifierClass:s["v2-saved-item__icon--oneoff"],subText:"Off — turn on to build and send a one-time check-in",loadingText:"Loading one-off status...",errorText:void 0,isEnabled:!!C,onToggle:()=>h?h(!C):c("oneoff")}];return e.jsx("div",{className:s["v2-saved-wrapper"],children:e.jsxs("div",{className:s["v2-saved-card"],children:[e.jsx("div",{className:`${s["v2-saved-badge"]} ${n?s["v2-saved-error-badge"]:""}`,children:n?e.jsx(q.LuTriangleAlert,{size:36,color:"#DC2626"}):e.jsx(Ge,{size:38,color:"#0F9655"})}),e.jsx("h2",{className:s["v2-saved-title"],children:n?"Unable to load settings":"Staff check-in saved"}),l?e.jsxs("div",{className:s["v2-saved-loading-wrap"],children:[e.jsx(pe.Loading,{size:18}),e.jsx("span",{className:s["v2-saved-loading-wrap__text"],children:"Loading staff check-in configuration..."})]}):n?e.jsxs("p",{className:s["v2-saved-desc"],children:["Failed to fetch setup configuration from server."," ",_&&e.jsx("button",{type:"button",onClick:_,className:s["v2-saved-retry-btn"],children:"Click here to retry"})]}):e.jsxs("p",{className:s["v2-saved-desc"],children:["Your staff check-in is scheduled and will start launching on"," ",e.jsxs("strong",{children:[t.launchDate&&M(t.launchDate,"YYYY-MM-DD").isValid()?M(t.launchDate,"YYYY-MM-DD").format("dddd, MMMM D, YYYY"):"Monday, September 7, 2026","."]})," Teachers will be notified when it goes live."]}),e.jsx("div",{className:s["v2-saved-list"],children:o.map(r=>e.jsxs("div",{className:s["v2-saved-item"],children:[e.jsx("div",{className:`${s["v2-saved-item__icon"]} ${r.iconModifierClass}`,children:r.icon}),e.jsxs("div",{className:s["v2-saved-item__info"],children:[e.jsx("div",{className:s["v2-saved-item__title"],children:r.title}),e.jsx("div",{className:s["v2-saved-item__sub"],children:l?e.jsxs("div",{className:s["v2-saved-item-loading"],children:[e.jsx(pe.Loading,{size:14,defaultColor:!1}),e.jsx("span",{className:s["v2-saved-item-loading__text"],children:r.loadingText})]}):n&&r.errorText?e.jsx("span",{className:s["v2-saved-error-text"],children:r.errorText}):r.subText})]}),e.jsxs("div",{className:s["v2-saved-item__actions"],children:[l?e.jsx("div",{className:s["v2-saved-item-spinner"],children:e.jsx(pe.Loading,{size:16})}):n&&r.errorText?e.jsx("span",{className:s["v2-saved-item-dash"],children:"—"}):e.jsxs("div",{className:s["v2-saved-item__switch-box"],children:[e.jsx("span",{children:r.isEnabled?"On":"Off"}),e.jsx("button",{type:"button",onClick:r.onToggle,className:`${s["v2-saved-item__switch"]} ${r.isEnabled?s["v2-saved-item__switch--on"]:""}`,children:e.jsx("span",{className:`${s["v2-saved-item__knob"]} ${r.isEnabled?s["v2-saved-item__knob--on"]:""}`})})]}),e.jsxs("button",{type:"button",disabled:l||n,onClick:()=>c(r.id),className:s["v2-saved-item__btn-edit"],children:[e.jsx(q.LuPencil,{size:14}),e.jsx("span",{children:"Edit"})]})]})]},r.id))}),e.jsxs("button",{type:"button",onClick:()=>Y("/admin/well-being-dashboard"),className:s["v2-saved-btn-dashboard"],children:[e.jsx(q.LuGauge,{size:18}),e.jsx("span",{children:"Go to dashboard"})]})]})})},te=(t,l)=>{if(!l||!t)return t;const n=new Map;return l.forEach(_=>{_.questions?.forEach(c=>{c.id&&n.set(c.id,{question:c,clusterId:_.id})})}),t.map(_=>{let c=[..._.questions||[]];return c=c.map(b=>{if(b.id&&n.has(b.id)){const h=n.get(b.id).question;return{...b,text:h.text,descriptors:h.descriptors!==void 0?h.descriptors:b.descriptors,includedInBulk:h.includedInBulk!==void 0?h.includedInBulk:b.includedInBulk,isAppliedToAllClusters:h.isAppliedToAllClusters!==void 0?h.isAppliedToAllClusters:b.isAppliedToAllClusters,clusterId:h.clusterId!==void 0?h.clusterId:b.clusterId,sectionName:h.sectionName!==void 0?h.sectionName:b.sectionName,kind:h.kind||b.kind}}return b}),l.forEach(b=>{b.questions?.forEach(m=>{m.id&&m.kind!=="open"&&(b.id===_.id?c.some(x=>x.id===m.id)||t.some(Y=>Y.id!==_.id&&Y.questions?.some(k=>k.id===m.id))&&c.push({...m}):l.some(x=>x.id!==_.id&&x.questions?.some(Y=>Y.id===m.id))&&(c=c.filter(x=>x.id!==m.id)))})}),{..._,questions:c}})},Xe=()=>{const n=`WELLBEING_ONE_OFF_DRAFT_${$e.useSelector(v=>v.common?.user)?.id||localStorage.getItem("USER_EMAIL")||"default_user"}`,[_,c]=p.useState(!0),[b,m]=p.useState(!1),[h,x]=p.useState(!1),[Y,k]=p.useState("routine"),[d,C]=p.useState(!0),[D,w]=p.useState(!1),[o,r]=p.useState("routine"),[y,I]=p.useState(null),[z,T]=p.useState(1),[E,J]=p.useState(!0),[H,K]=p.useState(fe.routine),[g,U]=p.useState(fe.comprehensive),[Q,R]=p.useState(le),[G,W]=p.useState(le),[ee,X]=p.useState(le),[a,u]=p.useState(()=>{try{const v=localStorage.getItem(n);if(v){const i=JSON.parse(v);if(localStorage.removeItem(n),i?.clusters&&Array.isArray(i.clusters)&&i.clusters.reduce((ce,ne)=>ce+(ne.questions?.length||0),0)>0)return i.clusters}}catch{}return le.map(v=>({...v,questions:[]}))}),[O,N]=p.useState(!1),[$,F]=p.useState(null),V=p.useRef(!0);p.useEffect(()=>{if(V.current){V.current=!1;return}try{if(a.reduce((i,B)=>i+(B.questions?.length||0),0)>0){const i=new Date().toISOString();localStorage.setItem(n,JSON.stringify({clusters:a,updatedAt:i})),F(i)}else localStorage.removeItem(n),F(null)}catch(v){console.error("Error saving one-off draft to storage",v)}},[a,n]),p.useEffect(()=>{const v=()=>{try{a.reduce((B,ce)=>B+(ce.questions?.length||0),0)>0&&localStorage.setItem(n,JSON.stringify({clusters:a,updatedAt:new Date().toISOString()}))}catch{}};return window.addEventListener("beforeunload",v),()=>window.removeEventListener("beforeunload",v)},[a,n]);const ae=()=>{try{localStorage.removeItem(n),N(!1),F(null),u(ee.map(v=>({...v,questions:[]}))),S("Draft cleared. Starting with a blank form.","info")}catch(v){console.error("Error clearing draft",v)}},[P,f]=p.useState(fe.pastOneOffs),A=p.useCallback(async()=>{try{c(!0),m(!1);const i=(await se.getWellBeingSetupV2()).data;if(i){if(T(i.setupId||1),i.isOneOffEnabled!==void 0&&J(i.isOneOffEnabled),i.launchDate&&I(i.launchDate),i.routine&&K(i.routine),i.comprehensive){const ie=[...i.comprehensive.sendDates||[]].sort((be,Ae)=>new Date(be).getTime()-new Date(Ae).getTime());U({...i.comprehensive,sendDates:ie})}const B=i.routineClusters&&i.routineClusters.length>0?i.routineClusters:i.clusters||le,ce=i.comprehensiveClusters&&i.comprehensiveClusters.length>0?i.comprehensiveClusters:i.clusters||le,ne=i.masterBankClusters&&i.masterBankClusters.length>0?i.masterBankClusters:i.clusters||le;R(B),W(ce),X(ne);try{localStorage.getItem(n)||u(ne.map(be=>({...be,questions:[]})))}catch{}i.pastOneOffs&&i.pastOneOffs.length>0&&f(i.pastOneOffs)}}catch(v){console.error("Failed to load wellbeing setup v2, using defaults",v),m(!0)}finally{c(!1)}},[n]);p.useEffect(()=>{A()},[A]);const Z=v=>{Y!==v&&(k(v),C(!1))},j=()=>{C(!0)},L=async v=>{try{x(!0),await se.updateWellBeingSetupV2Api({scope:"routine",routine:H,clusters:Q,launchDate:v}),I(v),S("Routine check-in configuration saved successfully","success"),w(!1),C(!0)}catch(i){console.error("Failed to save routine setup",i),S("Failed to save configuration","error")}finally{x(!1)}},re=async v=>{try{x(!0),await se.updateWellBeingSetupV2Api({scope:"comprehensive",comprehensive:g,clusters:G,launchDate:v}),I(v),S("Comprehensive survey configuration saved successfully","success"),w(!1),C(!0)}catch(i){console.error("Failed to save comprehensive setup",i),S("Failed to save configuration","error")}finally{x(!1)}},_e=async(v,i)=>{try{x(!0);const B=[];if(a.forEach(ne=>{ne.questions.forEach(ie=>{ie.isEnabled&&B.push(Number(ie.id))})}),B.length===0){S("Please select at least one question before launching.","warning");return}const ce=i?.trim()||`One-off pulse (${v})`;await se.createOneOffCheckInApi({name:ce,startDate:v,questionIds:B,questions:a.flatMap(ne=>ne.questions.map(ie=>({id:Number(ie.id),text:ie.text,clusterId:ne.id,kind:ie.kind,descriptors:ie.descriptors||null})))}),await A();try{localStorage.removeItem(n),N(!1),F(null),u(ee.map(ne=>({...ne,questions:[]})))}catch{}S("One-off check-in launched successfully","success"),w(!1),C(!0)}catch(B){console.error("Failed to create one-off check-in",B),S("Failed to launch one-off check-in","error")}finally{x(!1)}},Me=async(v,i)=>{try{x(!0),await se.sendItAgainApi({oneOffId:v.id,sendDate:i}),S(`Scheduled "${v.name}" to send on ${i}`,"success"),await A()}catch(B){console.error("Failed to schedule send it again",B),S("Failed to schedule send","error")}finally{x(!1)}},Ye=async v=>{const i={...H,isEnabled:v};K(i);try{await se.updateWellBeingSetupV2Api({scope:"routine",routine:i,clusters:Q}),S(v?"Routine check-in enabled":"Routine check-in disabled","info")}catch(B){console.error("Failed to toggle routine",B),S("Failed to update routine status","error")}},Ie=async v=>{const i={...g,isEnabled:v};U(i);try{await se.updateWellBeingSetupV2Api({scope:"comprehensive",comprehensive:i,clusters:G}),S(v?"Comprehensive survey enabled":"Comprehensive survey disabled","info")}catch(B){console.error("Failed to toggle comprehensive",B),S("Failed to update comprehensive status","error")}},Te=async v=>{J(v);try{await se.updateWellBeingSetupV2Api({scope:"oneoff",isOneOffEnabled:v}),S(v?"One-off check-in enabled":"One-off check-in disabled","info")}catch(i){console.error("Failed to toggle one-off",i),S("Failed to update one-off status","error")}},xe=p.useCallback(v=>{R(v),W(i=>te(i,v)),X(i=>te(i,v)),u(i=>te(i,v))},[]),ge=p.useCallback(v=>{W(v),R(i=>te(i,v)),X(i=>te(i,v)),u(i=>te(i,v))},[]),Ne=p.useCallback(v=>{X(v),R(i=>te(i,v)),W(i=>te(i,v)),u(i=>te(i,v))},[]),ye=p.useCallback(v=>{u(v),R(i=>te(i,v)),W(i=>te(i,v)),X(i=>te(i,v))},[]);return{loading:_,hasError:b,refetch:A,saving:h,activeTab:Y,setActiveTab:k,isSavedView:d,setIsSavedView:C,isLaunchModalOpen:D,setIsLaunchModalOpen:w,launchScope:o,setLaunchScope:r,launchDate:y,setLaunchDate:I,isOneOffEnabled:E,setIsOneOffEnabled:J,routineConfig:H,setRoutineConfig:K,comprehensiveConfig:g,setComprehensiveConfig:U,clusters:Q,setClusters:xe,routineClusters:Q,setRoutineClusters:xe,comprehensiveClusters:G,setComprehensiveClusters:ge,masterBankClusters:ee,setMasterBankClusters:Ne,oneOffClusters:a,setOneOffClusters:ye,handleRoutineClustersChange:xe,handleComprehensiveClustersChange:ge,handleMasterBankClustersChange:Ne,handleOneOffClustersChange:ye,hasDraft:O,draftSavedAt:$,handleClearDraft:ae,pastOneOffs:P,fullSetupData:{setupId:z,isOneOffEnabled:E,launchDate:y,routine:H,comprehensive:g,clusters:Q,routineClusters:Q,comprehensiveClusters:G,masterBankClusters:ee,pastOneOffs:P},handleSelectTab:Z,handleBackToOverview:j,handleSaveRoutine:L,handleSaveComprehensive:re,handleLaunchOneOff:_e,handleSendItAgain:Me,handleToggleRoutine:Ye,handleToggleComprehensive:Ie,handleToggleOneOff:Te,handleRestoreDefaults:async v=>{try{c(!0);const B=(await se.restoreDefaultQuestionsApi(v)).data;B&&(B.routineClusters&&R(B.routineClusters),B.comprehensiveClusters&&W(B.comprehensiveClusters),B.masterBankClusters&&X(B.masterBankClusters)),S("Default questions restored successfully","success")}catch(i){console.error("Failed to restore default questions",i),S("Failed to restore default questions","error")}finally{c(!1)}}}},Ze=({onClose:t,onStart:l,initialDate:n})=>{const[_,c]=p.useState(()=>n&&M(n,"YYYY-MM-DD").isValid()?n:""),b=_&&M(_,"YYYY-MM-DD").isValid()?M(_,"YYYY-MM-DD"):null,m=!!(_&&M(_,"YYYY-MM-DD").isValid());return e.jsx("div",{onClick:t,className:s["v2-launch-modal-overlay"],children:e.jsxs("div",{onClick:h=>h.stopPropagation(),className:s["v2-launch-modal"],children:[e.jsx("button",{type:"button",onClick:t,className:s["v2-launch-modal__btn-close"],children:e.jsx(q.LuX,{size:18,color:"#6B6B6B"})}),e.jsx("div",{className:s["v2-launch-modal__icon-box"],children:e.jsx(q.LuRocket,{size:30,color:"#316CD9"})}),e.jsx("div",{className:s["v2-launch-modal__title"],children:"Your staff check-in is launching"}),e.jsx("p",{className:s["v2-launch-modal__sub"],children:"Choose the date this check-in starts sending to teachers. You can change it any time before it goes out."}),e.jsx("div",{className:s["v2-launch-modal__form"],children:e.jsxs("div",{children:[e.jsx("span",{className:s["v2-launch-modal__field-label"],children:"START DATE *"}),e.jsx(de.LocalizationProvider,{dateAdapter:we.AdapterMoment,children:e.jsx(de.DatePicker,{value:b,minDate:M().startOf("day"),onChange:h=>{const x=h&&M(h).isValid()?M(h).format("YYYY-MM-DD"):"";c(x)},format:"MMMM DD, YYYY",slotProps:{textField:{fullWidth:!0,variant:"outlined",placeholder:"Select a date",sx:{background:"#fff","& .MuiOutlinedInput-root":{borderRadius:"12px",fontSize:"15px",fontWeight:500,color:"#242424",height:48,"& fieldset":{borderColor:"#D3D3D3"},"&:hover fieldset":{borderColor:"#316CD9"},"&.Mui-focused fieldset":{borderColor:"#316CD9"}},"& .MuiInputBase-input":{padding:"12px 14px"}}}}})})]})}),e.jsxs("div",{className:s["v2-launch-modal__actions"],children:[e.jsx("button",{type:"button",onClick:t,className:s["v2-launch-modal__btn-cancel"],children:"Cancel"}),e.jsxs("button",{type:"button",onClick:()=>m&&l(_),disabled:!m,className:`${s["v2-launch-modal__btn-start"]} ${m?s["v2-launch-modal__btn-start--valid"]:""}`,children:[e.jsx(q.LuSend,{size:18,color:"#fff"})," Start check-in"]})]})]})})},es=()=>{const[t,l]=p.useState(""),{loading:n,hasError:_,refetch:c,activeTab:b,setActiveTab:m,isSavedView:h,setIsSavedView:x,isLaunchModalOpen:Y,setIsLaunchModalOpen:k,routineConfig:d,setRoutineConfig:C,comprehensiveConfig:D,setComprehensiveConfig:w,routineClusters:o,setRoutineClusters:r,comprehensiveClusters:y,setComprehensiveClusters:I,masterBankClusters:z,oneOffClusters:T,setOneOffClusters:E,hasDraft:J,draftSavedAt:H,handleClearDraft:K,pastOneOffs:g,fullSetupData:U,isOneOffEnabled:Q,launchDate:R,launchScope:G,setLaunchScope:W,handleSelectTab:ee,handleBackToOverview:X,handleSaveRoutine:a,handleSaveComprehensive:u,handleLaunchOneOff:O,handleSendItAgain:N,handleToggleRoutine:$,handleToggleComprehensive:F,handleToggleOneOff:V,handleRestoreDefaults:ae}=Xe();return e.jsxs("div",{className:h?"":s["v2-container"],children:[h?e.jsx(Je,{data:U,loading:n,hasError:_,onRetry:c,onEditMode:P=>{m(P),x(!1)},onToggleRoutine:$,onToggleComprehensive:F,onToggleOneOff:V,isOneOffEnabled:Q}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:s["v2-header"],children:[e.jsxs("div",{className:s["v2-header-row"],children:[e.jsx("h1",{className:s["v2-title"],children:"Staff Well-being Setup"}),e.jsxs("button",{type:"button",onClick:X,className:s["v2-btn-back-overview"],children:[e.jsx(q.LuArrowLeft,{size:16})," Back to Overview"]})]}),e.jsxs("p",{className:s["v2-description"],children:["Configure your staff check-in by reviewing questions, choosing how they are grouped, arranging",e.jsx("br",{})," clusters, and setting how often check-ins are sent."]}),e.jsx(Le,{activeTab:b,onSelectTab:ee})]}),b==="routine"&&e.jsx(We,{config:d,onChangeConfig:C,clusters:o,onChangeClusters:r,onSave:()=>{W("routine"),k(!0)},onRestoreDefaults:()=>ae("routine")}),b==="comprehensive"&&e.jsx(Ve,{config:D,onChangeConfig:w,clusters:y,onChangeClusters:I,onSave:()=>{W("comprehensive"),k(!0)},onRestoreDefaults:()=>ae("comprehensive")}),b==="oneoff"&&e.jsx(Ke,{clusters:T,onChangeClusters:E,pastOneOffs:g,masterBankClusters:z,hasDraft:J,draftSavedAt:H,onClearDraft:K,isOn:Q,onToggle:V,onSaveAndContinue:P=>{l(P),W("oneoff"),k(!0)},onSendItAgain:N})]}),Y&&e.jsx(Ze,{initialDate:G==="oneoff"?void 0:R,onClose:()=>k(!1),onStart:P=>{G==="routine"?a(P):G==="comprehensive"?u(P):G==="oneoff"&&O(P,t)}}),e.jsx(Re,{})]})};exports.default=es;