mario-education 2.0.194-staging → 2.0.196-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"),b=require("react"),y=require("./index-CFIo7NaO.cjs"),ie=require("./index-B7GKbXi8.cjs"),ue=require("@dnd-kit/core"),me=require("@dnd-kit/sortable"),Ae=require("react-dom"),p=require("moment"),U=require("./wellbeingService-BWnDQzX4.cjs"),Je=require("./utilities.esm-DImhXrxQ.cjs"),Xe=require("mario-core"),de=require("@mui/x-date-pickers"),Ne=require("./AdapterMoment-B-q0UCj0.cjs"),Oe=require("react-router-dom"),pe=require("./Loading-CHowA_dQ.cjs"),Ze=require("react-redux"),Te=require("@mui/material"),s={"v2-container":"_v2-container_15x1h_4","v2-header":"_v2-header_15x1h_16","v2-header-row":"_v2-header-row_15x1h_22","v2-btn-back-overview":"_v2-btn-back-overview_15x1h_29","v2-title":"_v2-title_15x1h_49","v2-description":"_v2-description_15x1h_57","v2-mode-tabs":"_v2-mode-tabs_15x1h_66","v2-mode-tabs__btn":"_v2-mode-tabs__btn_15x1h_77","v2-mode-tabs__btn--active":"_v2-mode-tabs__btn--active_15x1h_95","v2-power-card":"_v2-power-card_15x1h_100","v2-power-card--active":"_v2-power-card--active_15x1h_110","v2-power-card__icon":"_v2-power-card__icon_15x1h_114","v2-power-card__content":"_v2-power-card__content_15x1h_124","v2-power-card__title":"_v2-power-card__title_15x1h_128","v2-power-card__sub":"_v2-power-card__sub_15x1h_133","v2-power-card__state-text":"_v2-power-card__state-text_15x1h_138","v2-power-card__state-text--active":"_v2-power-card__state-text--active_15x1h_143","v2-power-card__switch":"_v2-power-card__switch_15x1h_146","v2-power-card__switch--active":"_v2-power-card__switch--active_15x1h_157","v2-power-card__knob":"_v2-power-card__knob_15x1h_160","v2-power-card__knob--active":"_v2-power-card__knob--active_15x1h_171","v2-info-callout":"_v2-info-callout_15x1h_175","v2-info-callout__icon":"_v2-info-callout__icon_15x1h_184","v2-info-callout__text":"_v2-info-callout__text_15x1h_192","v2-section-box":"_v2-section-box_15x1h_200","v2-section-box__header":"_v2-section-box__header_15x1h_208","v2-section-box__num":"_v2-section-box__num_15x1h_213","v2-section-box__title":"_v2-section-box__title_15x1h_225","v2-section-box__sub":"_v2-section-box__sub_15x1h_230","v2-section-box__body":"_v2-section-box__body_15x1h_237","v2-field-label":"_v2-field-label_15x1h_243","v2-cadence-grid":"_v2-cadence-grid_15x1h_252","v2-cadence-card":"_v2-cadence-card_15x1h_258","v2-cadence-card--selected":"_v2-cadence-card--selected_15x1h_273","v2-cadence-card__top":"_v2-cadence-card__top_15x1h_277","v2-cadence-card__radio":"_v2-cadence-card__radio_15x1h_282","v2-cadence-card__radio--selected":"_v2-cadence-card__radio--selected_15x1h_291","v2-cadence-card__title":"_v2-cadence-card__title_15x1h_301","v2-cadence-card__badge":"_v2-cadence-card__badge_15x1h_306","v2-cadence-card__sub":"_v2-cadence-card__sub_15x1h_316","v2-days-row":"_v2-days-row_15x1h_322","v2-day-pill":"_v2-day-pill_15x1h_328","v2-day-pill--selected":"_v2-day-pill--selected_15x1h_343","v2-rotation-box":"_v2-rotation-box_15x1h_352","v2-rotation-box__head":"_v2-rotation-box__head_15x1h_358","v2-rotation-box__desc":"_v2-rotation-box__desc_15x1h_367","v2-rotation-box__list":"_v2-rotation-box__list_15x1h_373","v2-rotation-box__item":"_v2-rotation-box__item_15x1h_378","v2-rotation-box__cycle":"_v2-rotation-box__cycle_15x1h_387","v2-rotation-box__title":"_v2-rotation-box__title_15x1h_394","v2-rotation-box__tag":"_v2-rotation-box__tag_15x1h_400","v2-email-box":"_v2-email-box_15x1h_409","v2-email-box--active":"_v2-email-box--active_15x1h_419","v2-email-box__icon":"_v2-email-box__icon_15x1h_423","v2-email-box__content":"_v2-email-box__content_15x1h_432","v2-email-box__title":"_v2-email-box__title_15x1h_436","v2-email-box__sub":"_v2-email-box__sub_15x1h_441","v2-email-box__state-text":"_v2-email-box__state-text_15x1h_446","v2-email-box__state-text--active":"_v2-email-box__state-text--active_15x1h_451","v2-email-box__switch":"_v2-email-box__switch_15x1h_454","v2-email-box__switch--active":"_v2-email-box__switch--active_15x1h_465","v2-email-box__knob":"_v2-email-box__knob_15x1h_468","v2-email-box__knob--active":"_v2-email-box__knob--active_15x1h_479","v2-email-preview-wrapper":"_v2-email-preview-wrapper_15x1h_483","v2-btn-preview-email":"_v2-btn-preview-email_15x1h_489","v2-email-preview-popover":"_v2-email-preview-popover_15x1h_509","v2-email-preview-popover__head":"_v2-email-preview-popover__head_15x1h_522","v2-email-preview-popover__logo-wrap":"_v2-email-preview-popover__logo-wrap_15x1h_530","v2-email-preview-popover__logo-img":"_v2-email-preview-popover__logo-img_15x1h_546","v2-email-preview-popover__brand":"_v2-email-preview-popover__brand_15x1h_558","v2-email-preview-popover__body":"_v2-email-preview-popover__body_15x1h_563","v2-email-preview-popover__to":"_v2-email-preview-popover__to_15x1h_570","v2-email-preview-popover__title":"_v2-email-preview-popover__title_15x1h_575","v2-email-preview-popover__desc":"_v2-email-preview-popover__desc_15x1h_582","v2-email-preview-popover__btn-start":"_v2-email-preview-popover__btn-start_15x1h_588","v2-send-warning-box":"_v2-send-warning-box_15x1h_608","v2-send-warning-box__icon":"_v2-send-warning-box__icon_15x1h_622","v2-btn-primary":"_v2-btn-primary_15x1h_626","v2-stat-banner":"_v2-stat-banner_15x1h_653","v2-stat-banner__left":"_v2-stat-banner__left_15x1h_663","v2-stat-banner__icon":"_v2-stat-banner__icon_15x1h_668","v2-stat-banner__label":"_v2-stat-banner__label_15x1h_677","v2-stat-banner__num":"_v2-stat-banner__num_15x1h_682","v2-stat-banner__right":"_v2-stat-banner__right_15x1h_688","v2-stat-banner__meta-sub":"_v2-stat-banner__meta-sub_15x1h_692","v2-stat-banner__meta-num":"_v2-stat-banner__meta-num_15x1h_696","v2-cluster-card":"_v2-cluster-card_15x1h_701","v2-cluster-card--collapsed":"_v2-cluster-card--collapsed_15x1h_711","v2-cluster-card__head":"_v2-cluster-card__head_15x1h_716","v2-cluster-card__num":"_v2-cluster-card__num_15x1h_721","v2-cluster-card__info":"_v2-cluster-card__info_15x1h_733","v2-cluster-card__title":"_v2-cluster-card__title_15x1h_737","v2-cluster-card__count":"_v2-cluster-card__count_15x1h_742","v2-cluster-card__pill":"_v2-cluster-card__pill_15x1h_747","v2-cluster-card-ext__bottom-actions":"_v2-cluster-card-ext__bottom-actions_15x1h_758","v2-cluster-card-ext__btn-add-cluster":"_v2-cluster-card-ext__btn-add-cluster_15x1h_762","v2-cluster-card-ext__btn-toggle-bank":"_v2-cluster-card-ext__btn-toggle-bank_15x1h_762","v2-cluster-card-ext__bank-panel":"_v2-cluster-card-ext__bank-panel_15x1h_783","v2-cluster-card-ext__bank-empty":"_v2-cluster-card-ext__bank-empty_15x1h_795","v2-cluster-card-ext__bank-item":"_v2-cluster-card-ext__bank-item_15x1h_801","v2-cluster-card-ext__bank-icon-circle":"_v2-cluster-card-ext__bank-icon-circle_15x1h_817","v2-cluster-card-ext__bank-text-wrap":"_v2-cluster-card-ext__bank-text-wrap_15x1h_826","v2-cluster-card-ext__bank-item-title":"_v2-cluster-card-ext__bank-item-title_15x1h_833","v2-cluster-card-ext__bank-item-desc":"_v2-cluster-card-ext__bank-item-desc_15x1h_839","v2-cluster-card-ext__bank-divider":"_v2-cluster-card-ext__bank-divider_15x1h_844","v2-cluster-card-ext__btn-write-custom":"_v2-cluster-card-ext__btn-write-custom_15x1h_849","v2-cluster-card-ext__drag-handle":"_v2-cluster-card-ext__drag-handle_15x1h_869","v2-cluster-card-ext__drag-handle--disabled":"_v2-cluster-card-ext__drag-handle--disabled_15x1h_879","v2-cluster-card-ext__guidance-box":"_v2-cluster-card-ext__guidance-box_15x1h_883","v2-cluster-card-ext__questions-list":"_v2-cluster-card-ext__questions-list_15x1h_893","v2-cluster-card-ext__empty":"_v2-cluster-card-ext__empty_15x1h_898","v2-question-row":"_v2-question-row_15x1h_908","v2-question-row--disabled":"_v2-question-row--disabled_15x1h_916","v2-question-row__title":"_v2-question-row__title_15x1h_920","v2-question-row__desc":"_v2-question-row__desc_15x1h_923","v2-question-row__cluster-badge":"_v2-question-row__cluster-badge_15x1h_926","v2-question-row__type-text":"_v2-question-row__type-text_15x1h_930","v2-question-row__top":"_v2-question-row__top_15x1h_933","v2-question-row__left":"_v2-question-row__left_15x1h_939","v2-question-row__head-row":"_v2-question-row__head-row_15x1h_943","v2-question-row__checkbox-label":"_v2-question-row__checkbox-label_15x1h_954","v2-question-row__checkbox-text":"_v2-question-row__checkbox-text_15x1h_960","v2-question-row__checkbox":"_v2-question-row__checkbox_15x1h_954","v2-question-row__enabled-text":"_v2-question-row__enabled-text_15x1h_971","v2-question-row__enabled-text--active":"_v2-question-row__enabled-text--active_15x1h_976","v2-question-row__enabled-text--disabled":"_v2-question-row__enabled-text--disabled_15x1h_979","v2-question-row__right":"_v2-question-row__right_15x1h_988","v2-question-row__actions":"_v2-question-row__actions_15x1h_1009","v2-question-row__btn-action":"_v2-question-row__btn-action_15x1h_1013","v2-question-row__btn-action--active":"_v2-question-row__btn-action--active_15x1h_1028","v2-question-form":"_v2-question-form_15x1h_1033","v2-question-form__field":"_v2-question-form__field_15x1h_1041","v2-question-form__label":"_v2-question-form__label_15x1h_1046","v2-question-form__label--spaced":"_v2-question-form__label--spaced_15x1h_1053","v2-question-form__input":"_v2-question-form__input_15x1h_1056","v2-question-form__hint":"_v2-question-form__hint_15x1h_1075","v2-question-form__descriptors-grid":"_v2-question-form__descriptors-grid_15x1h_1081","v2-question-form__descriptor-item":"_v2-question-form__descriptor-item_15x1h_1086","v2-question-form__descriptor-num":"_v2-question-form__descriptor-num_15x1h_1091","v2-question-form__descriptor-input":"_v2-question-form__descriptor-input_15x1h_1096","v2-question-form__meta-row":"_v2-question-form__meta-row_15x1h_1111","v2-question-form__select-label":"_v2-question-form__select-label_15x1h_1118","v2-question-form__select":"_v2-question-form__select_15x1h_1118","v2-question-form__actions":"_v2-question-form__actions_15x1h_1139","v2-question-form__btn-cancel":"_v2-question-form__btn-cancel_15x1h_1148","v2-question-form__btn-save":"_v2-question-form__btn-save_15x1h_1161","v2-dates-list":"_v2-dates-list_15x1h_1180","v2-date-row":"_v2-date-row_15x1h_1186","v2-date-row--past":"_v2-date-row--past_15x1h_1191","v2-date-row__idx":"_v2-date-row__idx_15x1h_1194","v2-date-row__idx--past":"_v2-date-row__idx--past_15x1h_1206","v2-date-row__past-badge":"_v2-date-row__past-badge_15x1h_1210","v2-date-row__btn-remove":"_v2-date-row__btn-remove_15x1h_1236","v2-saved-wrapper":"_v2-saved-wrapper_15x1h_1254","v2-saved-card":"_v2-saved-card_15x1h_1263","v2-saved-badge":"_v2-saved-badge_15x1h_1290","v2-saved-title":"_v2-saved-title_15x1h_1307","v2-saved-desc":"_v2-saved-desc_15x1h_1321","v2-saved-list":"_v2-saved-list_15x1h_1342","v2-saved-item":"_v2-saved-item_15x1h_1349","v2-saved-item__icon":"_v2-saved-item__icon_15x1h_1365","v2-saved-item__icon--routine":"_v2-saved-item__icon--routine_15x1h_1373","v2-saved-item__icon--comprehensive":"_v2-saved-item__icon--comprehensive_15x1h_1376","v2-saved-item__icon--oneoff":"_v2-saved-item__icon--oneoff_15x1h_1379","v2-saved-item__info":"_v2-saved-item__info_15x1h_1382","v2-saved-item__title":"_v2-saved-item__title_15x1h_1386","v2-saved-item__sub":"_v2-saved-item__sub_15x1h_1393","v2-saved-item__actions":"_v2-saved-item__actions_15x1h_1407","v2-saved-item__switch-box":"_v2-saved-item__switch-box_15x1h_1413","v2-saved-item__switch":"_v2-saved-item__switch_15x1h_1413","v2-saved-item__switch--on":"_v2-saved-item__switch--on_15x1h_1433","v2-saved-item__knob":"_v2-saved-item__knob_15x1h_1436","v2-saved-item__knob--on":"_v2-saved-item__knob--on_15x1h_1447","v2-saved-item__btn-edit":"_v2-saved-item__btn-edit_15x1h_1450","v2-saved-loading-wrap":"_v2-saved-loading-wrap_15x1h_1487","v2-saved-loading-wrap__text":"_v2-saved-loading-wrap__text_15x1h_1494","v2-saved-retry-btn":"_v2-saved-retry-btn_15x1h_1499","v2-saved-item-loading":"_v2-saved-item-loading_15x1h_1510","v2-saved-item-loading__text":"_v2-saved-item-loading__text_15x1h_1515","v2-saved-item-spinner":"_v2-saved-item-spinner_15x1h_1520","v2-saved-item-dash":"_v2-saved-item-dash_15x1h_1528","v2-saved-btn-dashboard":"_v2-saved-btn-dashboard_15x1h_1533","v2-oneoff-container":"_v2-oneoff-container_15x1h_1559","v2-oneoff-accordion":"_v2-oneoff-accordion_15x1h_1566","v2-oneoff-accordion__header":"_v2-oneoff-accordion__header_15x1h_1572","v2-oneoff-accordion__icon-box":"_v2-oneoff-accordion__icon-box_15x1h_1587","v2-oneoff-accordion__title-group":"_v2-oneoff-accordion__title-group_15x1h_1596","v2-oneoff-accordion__title":"_v2-oneoff-accordion__title_15x1h_1596","v2-oneoff-accordion__subtitle":"_v2-oneoff-accordion__subtitle_15x1h_1605","v2-oneoff-accordion__body":"_v2-oneoff-accordion__body_15x1h_1610","v2-oneoff-accordion__empty":"_v2-oneoff-accordion__empty_15x1h_1615","v2-oneoff-accordion__item":"_v2-oneoff-accordion__item_15x1h_1621","v2-oneoff-accordion__item-info":"_v2-oneoff-accordion__item-info_15x1h_1631","v2-oneoff-accordion__item-name":"_v2-oneoff-accordion__item-name_15x1h_1635","v2-oneoff-accordion__item-meta":"_v2-oneoff-accordion__item-meta_15x1h_1640","v2-oneoff-accordion__item-actions":"_v2-oneoff-accordion__item-actions_15x1h_1645","v2-oneoff-accordion__btn-view":"_v2-oneoff-accordion__btn-view_15x1h_1650","v2-oneoff-accordion__btn-send-again":"_v2-oneoff-accordion__btn-send-again_15x1h_1668","v2-name-box":"_v2-name-box_15x1h_1687","v2-name-box__label":"_v2-name-box__label_15x1h_1693","v2-name-box__input":"_v2-name-box__input_15x1h_1700","v2-name-box__hint":"_v2-name-box__hint_15x1h_1718","v2-sendagain-modal__icon-box":"_v2-sendagain-modal__icon-box_15x1h_1723","v2-comprehensive-container":"_v2-comprehensive-container_15x1h_1775","v2-comprehensive-body":"_v2-comprehensive-body_15x1h_1782","v2-comprehensive-body--disabled":"_v2-comprehensive-body--disabled_15x1h_1788","v2-comprehensive-date-picker-wrap":"_v2-comprehensive-date-picker-wrap_15x1h_1793","v2-comprehensive-btn-add-date":"_v2-comprehensive-btn-add-date_15x1h_1798","v2-comprehensive-note-box":"_v2-comprehensive-note-box_15x1h_1820","v2-comprehensive-note-box__icon":"_v2-comprehensive-note-box__icon_15x1h_1830","v2-comprehensive-note-box__text":"_v2-comprehensive-note-box__text_15x1h_1834","v2-delete-modal-overlay":"_v2-delete-modal-overlay_15x1h_1847","v2-delete-modal":"_v2-delete-modal_15x1h_1847","v2-delete-modal__title":"_v2-delete-modal__title_15x1h_1867","v2-delete-modal__message":"_v2-delete-modal__message_15x1h_1872","v2-delete-modal__actions":"_v2-delete-modal__actions_15x1h_1878","v2-delete-modal__btn-cancel":"_v2-delete-modal__btn-cancel_15x1h_1884","v2-delete-modal__btn-delete":"_v2-delete-modal__btn-delete_15x1h_1899","v2-restore-modal-overlay":"_v2-restore-modal-overlay_15x1h_1917","v2-restore-modal":"_v2-restore-modal_15x1h_1917","v2-restore-modal__icon-box":"_v2-restore-modal__icon-box_15x1h_1939","v2-restore-modal__title":"_v2-restore-modal__title_15x1h_1949","v2-restore-modal__message":"_v2-restore-modal__message_15x1h_1954","v2-restore-modal__actions":"_v2-restore-modal__actions_15x1h_1960","v2-restore-modal__btn-cancel":"_v2-restore-modal__btn-cancel_15x1h_1966","v2-restore-modal__btn-confirm":"_v2-restore-modal__btn-confirm_15x1h_1985","v2-launch-modal-overlay":"_v2-launch-modal-overlay_15x1h_2010","v2-launch-modal":"_v2-launch-modal_15x1h_2010","v2-launch-modal__btn-close":"_v2-launch-modal__btn-close_15x1h_2030","v2-launch-modal__icon-box":"_v2-launch-modal__icon-box_15x1h_2048","v2-launch-modal__title":"_v2-launch-modal__title_15x1h_2057","v2-launch-modal__sub":"_v2-launch-modal__sub_15x1h_2062","v2-launch-modal__form":"_v2-launch-modal__form_15x1h_2068","v2-launch-modal__field-label":"_v2-launch-modal__field-label_15x1h_2074","v2-launch-modal__warning-box":"_v2-launch-modal__warning-box_15x1h_2099","v2-launch-modal__warning-icon":"_v2-launch-modal__warning-icon_15x1h_2109","v2-launch-modal__warning-text":"_v2-launch-modal__warning-text_15x1h_2114","v2-launch-modal__actions":"_v2-launch-modal__actions_15x1h_2120","v2-launch-modal__btn-cancel":"_v2-launch-modal__btn-cancel_15x1h_2125","v2-launch-modal__btn-start":"_v2-launch-modal__btn-start_15x1h_2141","v2-launch-modal__btn-start--valid":"_v2-launch-modal__btn-start--valid_15x1h_2157","v2-view-modal":"_v2-view-modal_15x1h_2168","v2-view-modal__header":"_v2-view-modal__header_15x1h_2182","v2-view-modal__btn-close":"_v2-view-modal__btn-close_15x1h_2191","v2-view-modal__icon-box":"_v2-view-modal__icon-box_15x1h_2209","v2-view-modal__title-wrap":"_v2-view-modal__title-wrap_15x1h_2218","v2-view-modal__title":"_v2-view-modal__title_15x1h_2218","v2-view-modal__meta":"_v2-view-modal__meta_15x1h_2227","v2-view-modal__body":"_v2-view-modal__body_15x1h_2232","v2-view-modal__section-label":"_v2-view-modal__section-label_15x1h_2259","v2-view-modal__sent-section":"_v2-view-modal__sent-section_15x1h_2268","v2-view-modal__sent-badges-list":"_v2-view-modal__sent-badges-list_15x1h_2272","v2-view-modal__sent-badge":"_v2-view-modal__sent-badge_15x1h_2272","v2-view-modal__sent-badge--past":"_v2-view-modal__sent-badge--past_15x1h_2290","v2-view-modal__sent-badge--future":"_v2-view-modal__sent-badge--future_15x1h_2295","v2-view-modal__questions-section":"_v2-view-modal__questions-section_15x1h_2300","v2-view-modal__cluster-group":"_v2-view-modal__cluster-group_15x1h_2304","v2-view-modal__cluster-header":"_v2-view-modal__cluster-header_15x1h_2314","v2-view-modal__questions-list":"_v2-view-modal__questions-list_15x1h_2322","v2-view-modal__question-row":"_v2-view-modal__question-row_15x1h_2328","v2-view-modal__question-num":"_v2-view-modal__question-num_15x1h_2338","v2-view-modal__question-text":"_v2-view-modal__question-text_15x1h_2344","v2-view-modal__empty":"_v2-view-modal__empty_15x1h_2350","v2-view-modal__footer-single":"_v2-view-modal__footer-single_15x1h_2356","v2-view-modal__btn-close-footer":"_v2-view-modal__btn-close-footer_15x1h_2364","v2-review-questions":"_v2-review-questions_15x1h_2384","v2-review-questions__builder-card":"_v2-review-questions__builder-card_15x1h_2389","v2-review-questions__builder-card--transparent":"_v2-review-questions__builder-card--transparent_15x1h_2398","v2-review-questions__reorder-bar":"_v2-review-questions__reorder-bar_15x1h_2403","v2-review-questions__reorder-hint":"_v2-review-questions__reorder-hint_15x1h_2411","v2-review-questions__btn-restore":"_v2-review-questions__btn-restore_15x1h_2415","v2-review-questions__cluster-list":"_v2-review-questions__cluster-list_15x1h_2433","v2-review-questions__cluster-list--dragging":"_v2-review-questions__cluster-list--dragging_15x1h_2438","v2-routine-container":"_v2-routine-container_15x1h_2445","v2-routine-body":"_v2-routine-body_15x1h_2452","v2-routine-body--disabled":"_v2-routine-body--disabled_15x1h_2458","v2-snackbar-wrap":"_v2-snackbar-wrap_15x1h_2466","v2-snackbar-alert":"_v2-snackbar-alert_15x1h_2470"},es=[{id:"routine",label:"Routine check-in",icon:e.jsx(y.LuRepeat,{size:18})},{id:"comprehensive",label:"Comprehensive check-in",icon:e.jsx(y.LuCalendarRange,{size:18})},{id:"oneoff",label:"One-off check-in",icon:e.jsx(y.LuCalendarClock,{size:18})}],ss=({activeTab:t,onSelectTab:o})=>e.jsx("div",{className:s["v2-mode-tabs"],children:es.map(n=>{const a=t===n.id;return e.jsxs("button",{type:"button",onClick:()=>o(n.id),className:`${s["v2-mode-tabs__btn"]} ${a?s["v2-mode-tabs__btn--active"]:""}`,children:[n.icon,e.jsx("span",{children:n.label})]},n.id)})}),ts=({open:t,onClose:o,onDelete:n})=>{if(!t)return null;const a=e.jsx("div",{onClick:o,className:s["v2-delete-modal-overlay"],children:e.jsxs("div",{onClick:r=>r.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:o,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"?Ae.createPortal(a,document.body):a},xe=[],S=(t,o="success")=>{xe.forEach(n=>n({open:!0,message:t,severity:o}))},ns=t=>(xe.push(t),()=>{const o=xe.indexOf(t);o>=0&&xe.splice(o,1)}),D="YYYY-MM-DD",os="MMM DD, YYYY",fe="MMMM DD, YYYY",as="Your comprehensive well-being check-in is coming",is="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.",rs=["Strongly disagree","Disagree","Neutral","Agree","Strongly agree"],ls=4e3,cs=[{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"}],ds=["Monday","Tuesday","Wednesday","Thursday","Friday","Saturday","Sunday"],_s=[["Week 1","Physical well-being","4 questions"],["Week 2","Emotional well-being","4 questions"],["Week 3","Environmental well-being","4 questions"]],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:[]}],we={routine:{isEnabled:!1,frequency:"biweekly",dayOfWeek:"Monday",emailNotify:!1},comprehensive:{isEnabled:!1,frequency:"quarterly",sendDates:[],durationDays:14,emailNotify:!1},pastOneOffs:[]},ke=t=>t?t.replace(/&rsquo;/g,"'").replace(/&lsquo;/g,"'").replace(/&rdquo;/g,'"').replace(/&ldquo;/g,'"').replace(/&quot;/g,'"').replace(/&#39;/g,"'").replace(/&amp;/g,"&").replace(/&nbsp;/g," "):"",Me=t=>{const o=ke(t),n=o.indexOf(":"),a=n>=0?o.slice(0,n).trim():o,r=n>=0?o.slice(n+1).trim():"";return{title:a,desc:r}},us=(t,o,n,a)=>{const r=o.find(_=>_.id===n);if(t)return r?.name||"Cluster";if(!!a.includedInBulk)return"All clusters";const l=a.clusterId?o.find(_=>String(_.id)===String(a.clusterId)):null;return l?l.label||l.name:r?.name||"Open field"},ve=t=>t&&t.length===5?[...t]:[...rs],vs=(t,o)=>{const n=(t||o||"").trim(),a=n.toLowerCase();return a.startsWith("open")?"Open field well-being":a.startsWith("social")?"Social (relationships) well-being":a.includes("well-being")?n:`${n} well-being`},hs=(t=[],o=[])=>{const n=new Set(o.map(a=>a.text));return t.filter(a=>!n.has(a.text))},ms=t=>{const o=t.filter(a=>a.kind!=="open"&&!a.name.toLowerCase().includes("open")),n=t.find(a=>a.kind==="open"||a.name.toLowerCase().includes("open"));return{draggableClusters:o,openCluster:n}},xs=(t,o,n,a)=>t.map(r=>{if(r.id===o){const c=[...r.questions];return c[n]=a,{...r,questions:c}}return r}),fs=(t,o,n)=>t.map(a=>{if(a.id===o){const r=[...a.questions];return r.splice(n,1),{...a,questions:r}}return a}),Ee=(t,o,n)=>t.map(a=>a.id===o?{...a,questions:[...a.questions||[],n]}:a),bs=(t,o,n,a)=>{let r=null;const c=t.map(l=>{if(l.id===o){const _=[...l.questions];return r={..._[n],clusterId:a},_.splice(n,1),{...l,questions:_}}return l});return r?c.map(l=>l.id===a?{...l,questions:[...l.questions||[],r]}:l):t},ps=(t,o="biweekly")=>{const n=!t.isEnabled;return{...t,isEnabled:n,frequency:n&&(!t.frequency||t.frequency==="monthly")?o:t.frequency||o}},ws=t=>t==="biweekly"?"two weeks":t==="monthly"?"month":"week",gs=(t,o)=>{if(!t.isEnabled)return"Paused — no check-ins are being sent";const n=t.frequency==="weekly"?"Weekly (every 7 days)":t.frequency==="monthly"?"Monthly (every 30 days)":"Bi-weekly (every 14 days)",a=o&&p(o,D).isValid()?` · Starts ${p(o,D).format("MMM D, YYYY")}`:"";return`Per cluster · ${n}${a}`},js=(t,o)=>{if(!t.isEnabled)return"Paused — no check-ins are being sent";const n=t.frequency==="yearly"?"Yearly (once a year)":t.frequency==="semesterly"?"Semesterly (every ~6 months)":t.frequency==="monthly"?"Monthly (every 30 days)":"Quarterly (every term (~3 months))",a=o&&p(o,D).isValid()?` · First launch ${p(o,D).format("MMM D, YYYY")}`:"";return`Comprehensive · ${n}${a}`},ys=t=>t.routine?.isEnabled&&t.routineLaunchDate&&p(t.routineLaunchDate,D).isValid()?p(t.routineLaunchDate,D).format("dddd, MMMM D, YYYY"):t.comprehensive?.isEnabled&&t.comprehensiveLaunchDate&&p(t.comprehensiveLaunchDate,D).isValid()?p(t.comprehensiveLaunchDate,D).format("dddd, MMMM D, YYYY"):t.launchDate&&p(t.launchDate,D).isValid()?p(t.launchDate,D).format("dddd, MMMM D, YYYY"):"Monday, September 7, 2026",Ns=t=>{const o=new Set;return t&&(t.sentDate&&p(t.sentDate,D).isValid()&&o.add(p(t.sentDate,D).format(D)),t.sendDates&&Array.isArray(t.sendDates)&&t.sendDates.forEach(n=>{n&&p(n,D).isValid()&&o.add(p(n,D).format(D))})),o},ks=t=>{if(!t)return[];const o=[];return t.sendDates&&Array.isArray(t.sendDates)&&t.sendDates.length>0?t.sendDates.forEach(n=>{n&&!o.includes(n)&&o.push(n)}):t.sentDate&&o.push(t.sentDate),je(o)},qs=t=>t==null?"":typeof t=="object"?String(t.id||t.Id||t.questionId||t.QuestionId||t.value||""):String(t).trim(),Cs=(t,o=[])=>{const n=(o||[]).flatMap(u=>u.questions||[]);let a=[];if(t.questions&&t.questions.length>0)a=t.questions;else{const u=new Set((t.questionIds||[]).map(qs).filter(Boolean));if(a=n.filter(v=>u.has(String(v.id))),a.length===0&&u.size>0&&(a=Array.from(u).map(v=>{const d=Number(v);if(!isNaN(d)){if(n[d-1])return n[d-1];if(n[d])return n[d]}return null}).filter(Boolean)),a.length===0&&(t.questionCount>0||u.size>0)&&n.length>0){const v=t.questionCount>0?Math.min(t.questionCount,n.length):Math.min(u.size,n.length);a=n.slice(0,v)}}const r=a.filter(u=>u.kind!=="open"),c=a.filter(u=>u.kind==="open"),l=[],_=(o||[]).filter(u=>u.kind!=="open");for(const u of _){const v=r.filter(k=>String(k.clusterId)===String(u.id)),d=c.filter(k=>!k.isAppliedToAllClusters&&k.clusterId&&k.clusterId!==999&&String(k.clusterId)===String(u.id)),f=v.length>0||d.length>0?c.filter(k=>k.isAppliedToAllClusters):[],C=[...v,...d,...f];C.length>0&&l.push({cluster:u,questions:C})}const w=(o||[]).find(u=>u.kind==="open");if(w&&c.length>0){const u=new Set(l.flatMap(d=>d.questions.map(f=>String(f.id)))),v=c.filter(d=>!u.has(String(d.id)));(v.length>0||l.length===0)&&l.push({cluster:w,questions:v.length>0?v:c})}if(l.length===0&&a.length>0){const u=new Map;a.forEach(v=>{const d=v.clusterId||1;u.has(d)||u.set(d,[]),u.get(d).push(v)}),u.forEach((v,d)=>{const f=(o||[]).find(C=>String(C.id)===String(d))||{id:Number(d)||1,name:"Well-being Cluster",label:"Well-being Cluster",icon:"dumbbell",order:1,kind:"indicator",questions:[]};l.push({cluster:f,questions:v})})}return l},ge=t=>{if(!t)return"";try{return new Date(t+(t.includes("T")?"":"T00:00:00")).toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric"})}catch{return t}},Le=t=>t.reduce((o,n)=>o+(n.questions?.length||0),0),$e=t=>t.questions&&t.questions.length>0?t.questions.length:t.questionCount?t.questionCount:t.questionIds&&t.questionIds.length>0?t.questionIds.length:0,Ss=t=>Array.from(new Set([...t.sendDates||[],...t.sentDate?[t.sentDate]:[]])).filter(Boolean).sort((a,r)=>p(a,D).valueOf()-p(r,D).valueOf()).map(a=>ge(a)).join(", ")||ge(t.sentDate),je=t=>[...t].sort((o,n)=>o?n?p(o,"YYYY-MM-DD").valueOf()-p(n,"YYYY-MM-DD").valueOf():-1:1),Be=t=>!t||!p(t,"YYYY-MM-DD").isValid()?!1:p(t,"YYYY-MM-DD").isBefore(p().startOf("day")),ye=(t,o=D)=>!!(t&&p(t,o).isValid()),Ds=(t,o=D)=>ye(t,o)?p(t,o):null,Is=(t="weekly",o=!1,n,a)=>{const r=o?"comprehensive":t==="biweekly"?"weekly":t==="monthly"?"monthly":"weekly",c=o?"this term":t==="monthly"?"this month":"this week",l=n||(o?as:`Time for your ${r} well-being check-in`),_=a||(o?is:`Hi Educator, take care of yourself and complete ${c}'s check-in for Physical well-being. It only takes a couple of minutes, and your responses help us support you.`);return{title:l,body:_}},Ts=(t,o,n)=>{if(t==="routine"){const r=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"].findIndex(w=>w.toLowerCase()===o.dayOfWeek?.toLowerCase());if(r===-1)return p().format(D);const c=p().startOf("day"),l=c.day(),_=(r-l+7)%7;return c.add(_,"days").format(D)}if(t==="comprehensive"){const r=[...(n.sendDates||[]).filter(l=>l&&p(l,D).isValid())].sort((l,_)=>p(l).valueOf()-p(_).valueOf()),c=r.filter(l=>!p(l,D).isBefore(p().startOf("day")));return c.length>0?c[0]:r.length>0?r[0]:p().format(D)}},Es=(t,o,n)=>{if(o!=="comprehensive"||!t||!p(t,D).isValid())return null;const r=[...(n||[]).filter(u=>u&&p(u,D).isValid())].sort((u,v)=>p(u).valueOf()-p(v).valueOf()),c=r.filter(u=>!p(u,D).isBefore(p().startOf("day"))),l=c.length>0?c[0]:r.length>0?r[0]:null;if(!l||t===l)return null;const _=r.includes(t),w=p(t).isBefore(p(l));if(!_&&w){const u=[...r,t].sort((v,d)=>p(v).valueOf()-p(d).valueOf());return{type:"earlier_than_scheduled",message:`The date you selected (${p(t).format("MMMM D, YYYY")}) is earlier than your first scheduled check-in date (${p(l).format("MMMM D, YYYY")}). It will become the new first check-in date.`,updatedSendDates:u}}if(!w){const v=c.filter(f=>p(f).isBefore(p(t))).map(f=>p(f).format("MMMM D, YYYY")).join(", "),d=_?n:[...r,t].sort((f,C)=>p(f).valueOf()-p(C).valueOf());return{type:"skipping_dates",message:`${p(t).format("MMMM D, YYYY")} will be the first comprehensive check-in date sent to teachers.${v?` The scheduled date(s): ${v} will not be sent.`:""}`,updatedSendDates:d}}return null},As=({item:t,kind:o,clusterId:n,clusters:a,onChange:r,onMove:c,onDelete:l,isOneOff:_=!1,scope:w})=>{const[u,v]=b.useState(!1),[d,f]=b.useState(!1),[C,k]=b.useState(!1),I=o!=="open",q=a.find(m=>m.kind==="open")||{id:999},$=()=>I?n:t.isAppliedToAllClusters||t.includedInBulk||!t.clusterId?q.id:Number(t.clusterId),R=()=>I?!1:!!t.includedInBulk,[B,F]=b.useState(t.text),[A,Z]=b.useState(ve(t.descriptors)),[T,Q]=b.useState($()),[H,V]=b.useState(R()),K=ke(t.text),{title:Y,desc:z}=Me(t.text),J=a.find(m=>m.id===n),X=us(I,a,n,t),W=I?"Scale 1–5":"Open text",h=t.isEnabled!==!1,x=()=>{F(K),Z(ve(t.descriptors)),Q($()),V(!!t.includedInBulk),v(!0)},L=()=>{v(!1)},E=m=>{Q(m),I||(m!==q.id?V(!1):V(!0))},O=m=>{V(m),m&&Q(q.id)},G=async()=>{if(B.trim())if(I){const m={...t,text:B.trim(),descriptors:A,clusterId:T};if(r(m),T!==n&&c(T),v(!1),t.id&&typeof t.id=="number")try{k(!0),await U.updateWellbeingQuestionApi(t.id,{text:B.trim(),clusterId:T,descriptors:A}),S("Question updated successfully","success")}catch(M){console.error("Failed to update question via API",M),S("Failed to update question","error")}finally{k(!1)}}else{const m=H,M=T!==q.id,P=M?T:null,ce={...t,text:B.trim(),descriptors:null,includedInBulk:m,isAppliedToAllClusters:m,clusterId:P,sectionName:m?"All clusters":M?a.find(te=>String(te.id)===String(P))?.name||"Cluster":J?.name||"Open field"};if(r(ce),v(!1),t.id&&typeof t.id=="number")try{k(!0),await U.updateWellbeingQuestionApi(t.id,{text:B.trim(),clusterId:P,descriptors:null,isAppliedToAllClusters:m,includedInBulk:m}),S("Question updated successfully","success")}catch(te){console.error("Failed to update question via API",te),S("Failed to update question","error")}finally{k(!1)}}},se=async m=>{if(r({...t,isEnabled:m}),t.id&&typeof t.id=="number")try{await U.toggleWellbeingQuestionStatusApi(t.id,m,w),S(m?"Question enabled":"Question disabled","success")}catch(M){console.error("Failed to toggle question status via API",M),S("Failed to update question status","error")}},re=async()=>{if(l(),f(!1),t.id&&typeof t.id=="number")try{await U.deleteWellbeingQuestionApi(t.id),S("Question removed from cluster","success")}catch(m){console.error("Failed to delete question via API",m),S("Failed to remove question","error")}},g=(m,M)=>{const P=[...A];P[m]=M,Z(P)};return e.jsxs("div",{className:`${s["v2-question-row"]} ${h?"":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:Y||"Untitled question"}),e.jsxs("label",{className:s["v2-question-row__checkbox-label"],children:[e.jsx("input",{type:"checkbox",checked:h,onChange:m=>se(m.target.checked),className:s["v2-question-row__checkbox"]}),e.jsx("span",{className:`${s["v2-question-row__enabled-text"]} ${h?s["v2-question-row__enabled-text--active"]:s["v2-question-row__enabled-text--disabled"]}`,children:h?"Enabled":"Disabled"})]})]}),z&&e.jsx("div",{className:s["v2-question-row__desc"],children:z})]}),e.jsxs("div",{className:s["v2-question-row__right"],children:[w!=="comprehensive"&&e.jsx("span",{className:s["v2-question-row__cluster-badge"],children:X}),e.jsx("span",{className:s["v2-question-row__type-text"],children:W}),e.jsxs("div",{className:s["v2-question-row__actions"],children:[e.jsx("button",{type:"button",onClick:()=>u?L():x(),title:"Edit question",className:`${s["v2-question-row__btn-action"]} ${u?s["v2-question-row__btn-action--active"]:""}`,children:u?e.jsx(ie.FiChevronUp,{size:16,color:"#316CD9"}):e.jsx(y.LuPencil,{size:16,color:"#316CD9"})}),e.jsx("button",{type:"button",onClick:()=>{_?(l(),S("Question returned to question bank","info")):f(!0)},title:_?"Remove question (returns to bank)":"Delete question",className:s["v2-question-row__btn-action"],children:e.jsx(y.LuTrash2,{size:16,color:"#C44140"})})]})]})]}),u&&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:B,onChange:m=>F(m.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."})]}),I&&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:A.map((m,M)=>e.jsxs("label",{className:s["v2-question-form__descriptor-item"],children:[e.jsx("span",{className:s["v2-question-form__descriptor-num"],children:M+1}),e.jsx("input",{value:m,onChange:P=>g(M,P.target.value),className:s["v2-question-form__descriptor-input"]})]},M))})]}),!I&&w!=="comprehensive"&&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:T,onChange:m=>E(Number(m.target.value)),className:s["v2-question-form__select"],children:a.map(m=>{const M=m.kind==="open"?"Open field":m.label||m.name;return e.jsx("option",{value:m.id,children:M},m.id)})})]}),e.jsxs("label",{className:s["v2-question-row__checkbox-label"],children:[e.jsx("input",{type:"checkbox",checked:H,onChange:m=>O(m.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:L,className:s["v2-question-form__btn-cancel"],children:"Cancel"}),e.jsx("button",{type:"button",onClick:G,disabled:!B.trim()||C,className:s["v2-question-form__btn-save"],children:C?"Saving...":"Save Question"})]})]}),e.jsx(ts,{open:d,onClose:()=>f(!1),onDelete:re})]})},Re=({cluster:t,clusterIndex:o,clusters:n,onUpdateQuestion:a,onDeleteQuestion:r,onAddQuestion:c,onMoveQuestion:l,bankQuestions:_,onAddFromBank:w,isDraggable:u=!1,dragHandleProps:v,cardRef:d,cardStyle:f,isCollapsed:C=!1,isOneOff:k=!1,scope:I,isBankOpen:q,onToggleBank:$})=>{const[R,B]=b.useState(!1),F=q!==void 0?q:R,A=g=>{$?$(g):B(m=>!m)},[Z,T]=b.useState(!1),[Q,H]=b.useState(""),[V,K]=b.useState(ve()),Y=n.find(g=>g.kind==="open")||{id:999},[z,J]=b.useState(Y.id),[X,W]=b.useState(!0),h=t.questions||[],x=t.kind!=="open",L=g=>{J(g),x||(g!==Y.id?W(!1):W(!0))},E=g=>{W(g),g&&J(Y.id)},O=hs(_,h),G=x?0:h.filter(g=>g.includedInBulk).length,se=async()=>{const g=x?!1:X,m=!x&&z!==Y.id,M=x?t.id:m?z:null;let P=Date.now();try{const te=await U.createWellbeingQuestionApi({text:Q.trim(),clusterId:M,descriptors:x?V:null,kind:t.kind,scope:I||null,isAppliedToAllClusters:x?void 0:g,includedInBulk:x?void 0:g});te?.data?.id&&(P=te.data.id),S("Custom question created successfully","success")}catch(te){console.error("Failed to create question via API",te),S("Failed to create custom question","error")}const ce={id:P,text:Q.trim(),isEnabled:!0,clusterId:M,kind:t.kind,scope:I||null,descriptors:x?V:null,includedInBulk:x?void 0:g,isAppliedToAllClusters:x?void 0:g,sectionName:x?void 0:g?"All clusters":m?n.find(te=>String(te.id)===String(M))?.name||"Cluster":t.name||"Open field"};c(ce),H(""),K(ve()),J(Y.id),W(!0),T(!1)},re=()=>{H(""),K(ve()),J(Y.id),W(!0),T(!1)};return e.jsxs("div",{ref:d,style:f,className:`${s["v2-cluster-card"]} ${C?s["v2-cluster-card--collapsed"]:""}`,children:[e.jsxs("div",{className:s["v2-cluster-card__head"],children:[u?e.jsx("span",{...v,className:s["v2-cluster-card-ext__drag-handle"],title:"Drag to reorder cluster",children:e.jsx(y.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(y.LuGripVertical,{size:20,color:"#94A3B8"})}),e.jsx("span",{className:s["v2-cluster-card__num"],children:o}),e.jsxs("div",{className:s["v2-cluster-card__info"],children:[e.jsx("div",{className:s["v2-cluster-card__title"],children:vs(t.label,t.name)}),e.jsxs("div",{className:s["v2-cluster-card__count"],children:[h.length," question",h.length===1?"":"s"]})]}),e.jsxs("span",{className:s["v2-cluster-card__pill"],children:["Cluster ",o]})]}),!C&&e.jsxs(e.Fragment,{children:[!x&&I!=="comprehensive"&&e.jsxs("div",{className:s["v2-cluster-card-ext__guidance-box"],children:[e.jsx(ie.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:[G," selected."]})]})]}),e.jsxs("div",{className:s["v2-cluster-card-ext__questions-list"],children:[h.map((g,m)=>e.jsx(As,{item:g,kind:t.kind,clusterId:t.id,clusters:n,onChange:M=>a(m,M),onMove:M=>l(m,M),onDelete:()=>r(m),isOneOff:k||!!_,scope:I},g.id||m)),h.length===0&&e.jsx("div",{className:s["v2-cluster-card-ext__empty"],children:"No questions yet. Add one below."})]}),Z&&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:Q,onChange:g=>H(g.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."})]}),x&&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:V.map((g,m)=>e.jsxs("label",{className:s["v2-question-form__descriptor-item"],children:[e.jsx("span",{className:s["v2-question-form__descriptor-num"],children:m+1}),e.jsx("input",{value:g,onChange:M=>{const P=[...V];P[m]=M.target.value,K(P)},className:s["v2-question-form__descriptor-input"]})]},m))})]}),!x&&I!=="comprehensive"&&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:z,onChange:g=>L(Number(g.target.value)),className:s["v2-question-form__select"],children:n.map(g=>{const m=g.kind==="open"?"Open field":g.label||g.name;return e.jsx("option",{value:g.id,children:m},g.id)})})]}),e.jsxs("label",{className:s["v2-question-row__checkbox-label"],children:[e.jsx("input",{type:"checkbox",checked:X,onChange:g=>E(g.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:re,className:s["v2-question-form__btn-cancel"],children:"Cancel"}),e.jsx("button",{type:"button",onClick:se,disabled:!Q.trim(),className:s["v2-question-form__btn-save"],children:"Save Question"})]})]}),_?e.jsxs("div",{children:[e.jsxs("button",{type:"button",onClick:()=>A(),className:s["v2-cluster-card-ext__btn-toggle-bank"],children:[F?e.jsx(ie.FiChevronUp,{size:18}):e.jsx(y.LuPlus,{size:18}),F?"Close question bank":`Add from question bank (${O.length} available)`]}),F&&e.jsxs("div",{className:s["v2-cluster-card-ext__bank-panel"],children:[O.length===0?e.jsxs("div",{className:s["v2-cluster-card-ext__bank-empty"],children:["All ",t.name.toLowerCase()," bank questions have been added."]}):O.map((g,m)=>{const{title:M,desc:P}=Me(g.text);return e.jsxs("button",{type:"button",onClick:()=>w&&w(g),className:s["v2-cluster-card-ext__bank-item"],children:[e.jsx("span",{className:s["v2-cluster-card-ext__bank-icon-circle"],children:e.jsx(y.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:M}),P&&e.jsx("span",{className:s["v2-cluster-card-ext__bank-item-desc"],children:P})]})]},g.id||m)}),e.jsx("div",{className:s["v2-cluster-card-ext__bank-divider"]}),e.jsxs("button",{type:"button",onClick:()=>T(!0),className:s["v2-cluster-card-ext__btn-write-custom"],children:[e.jsx(y.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:()=>T(!0),className:s["v2-cluster-card-ext__btn-add-cluster"],children:[e.jsx(y.LuPlus,{size:16})," Add question to this cluster"]})})]})]})},Os=({cluster:t,isDraggable:o=!0,isCollapsed:n=!1,...a})=>{const{attributes:r,listeners:c,setNodeRef:l,transform:_,transition:w,isDragging:u}=me.useSortable({id:t.id,disabled:!o}),v={transform:Je.CSS.Transform.toString(_),transition:w,opacity:u?.6:1,zIndex:u?999:void 0,position:"relative"};return e.jsx(Re,{...a,cluster:t,isDraggable:o,isCollapsed:n,cardRef:l,cardStyle:v,dragHandleProps:o?{...r,...c}:void 0})},Ms=({open:t,onClose:o,onConfirm:n,loading:a=!1})=>{if(!t)return null;const r=e.jsx("div",{onClick:a?void 0:o,className:s["v2-restore-modal-overlay"],children:e.jsxs("div",{onClick:c=>c.stopPropagation(),className:s["v2-restore-modal"],children:[e.jsx("div",{className:s["v2-restore-modal__icon-box"],children:e.jsx(y.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:o,disabled:a,className:s["v2-restore-modal__btn-cancel"],children:"Cancel"}),e.jsx("button",{type:"button",onClick:n,disabled:a,className:s["v2-restore-modal__btn-confirm"],children:a?"Restoring...":"Restore defaults"})]})]})});return typeof document<"u"?Ae.createPortal(r,document.body):r},qe=({clusters:t,onChangeClusters:o,blank:n=!1,embedded:a=!1,masterBankClusters:r=le,scope:c="routine",onRestoreDefaults:l})=>{const[_,w]=b.useState(!1),[u,v]=b.useState(null),d=b.useRef(null),[f,C]=b.useState(null);b.useEffect(()=>{if(f===null)return;const h=x=>{if(!d.current)return;if(x.composedPath){const E=x.composedPath();if(E&&E.includes(d.current))return}const L=x.target;L&&!document.body.contains(L)||L&&d.current.contains(L)||C(null)};return document.addEventListener("click",h),()=>{document.removeEventListener("click",h)}},[f]);const[k,I]=b.useState(!1),[q,$]=b.useState(!1),R=u!==null,B=Le(t),{draggableClusters:F,openCluster:A}=ms(t),Z=ue.useSensors(ue.useSensor(ue.PointerSensor,{activationConstraint:{distance:5}})),T=h=>{v(h.active.id)},Q=async h=>{v(null);const{active:x,over:L}=h;if(!L||x.id===L.id)return;const E=F.findIndex(g=>g.id===x.id),O=F.findIndex(g=>g.id===L.id);if(E<0||O<0)return;const G=[...t],se=me.arrayMove(F,E,O),re=A?[...se,A]:se;if(o(re),!n)try{const g=se.filter(m=>m.id&&m.id!==999).map(m=>({id:m.id,name:m.name}));g.length>0&&(await U.orderSectionApi({sections:g}),S("Cluster order saved successfully","success"))}catch(g){console.error("Failed to auto-save cluster order, reverting",g),o(G),S("Failed to update cluster order on server. Reverted.","error")}},H=(h,x,L)=>{o(xs(t,h,x,L))},V=(h,x)=>{o(fs(t,h,x))},K=(h,x)=>{o(Ee(t,h,x))},Y=(h,x,L)=>{o(bs(t,h,x,L))},z=(h,x)=>{const L={...x,isEnabled:!0,clusterId:h};o(Ee(t,h,L)),S(`Added "${x.text.slice(0,30)}..." to cluster`,"success")},J=()=>{I(!0)},X=async()=>{try{if($(!0),l)await l();else{const x=(await U.restoreDefaultQuestionsApi(c)).data;x&&(c==="routine"&&x.routineClusters?o(x.routineClusters):c==="comprehensive"&&x.comprehensiveClusters?o(x.comprehensiveClusters):(x.clusters||x.masterBankClusters)&&o(x.clusters||x.masterBankClusters)),S("Default questions restored successfully","success")}I(!1)}catch(h){console.error("Failed to restore default questions",h),S("Failed to restore default questions","error")}finally{$(!1)}},W=n||a||_;return e.jsxs("div",{ref:d,className:s["v2-review-questions"],children:[!n&&!a&&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(y.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:B})]})]}),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:()=>w(h=>!h),className:s["v2-btn-primary"],children:[_?e.jsx(y.LuEyeOff,{size:20}):e.jsx(y.LuEye,{size:20}),e.jsx("span",{children:_?"Hide all questions":"View & edit all questions"})]})]}),n&&e.jsxs("div",{className:s["v2-info-callout"],children:[e.jsx(ie.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."})]}),W&&e.jsxs("div",{className:`${s["v2-review-questions__builder-card"]} ${n||a?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:J,className:s["v2-review-questions__btn-restore"],children:[e.jsx(y.LuRotateCcw,{size:16,color:"#316CD9"})," Restore default questions"]})]}),e.jsx(ue.DndContext,{sensors:Z,collisionDetection:ue.rectIntersection,onDragStart:T,onDragEnd:Q,onDragCancel:()=>v(null),children:e.jsx(me.SortableContext,{items:F.map(h=>h.id),strategy:me.verticalListSortingStrategy,children:e.jsx("div",{className:`${s["v2-review-questions__cluster-list"]} ${R?s["v2-review-questions__cluster-list--dragging"]:""}`,children:F.map((h,x)=>{const L=r.find(E=>E.id===h.id||E.name===h.name)?.questions||[];return e.jsx(Os,{cluster:h,clusterIndex:x+1,clusters:t,isDraggable:!0,isCollapsed:R,onUpdateQuestion:(E,O)=>H(h.id,E,O),onDeleteQuestion:E=>V(h.id,E),onAddQuestion:E=>K(h.id,E),onMoveQuestion:(E,O)=>Y(h.id,E,O),bankQuestions:n?L:void 0,onAddFromBank:E=>z(h.id,E),isOneOff:n,scope:c,isBankOpen:f===h.id,onToggleBank:E=>{C(E===!1?O=>O===h.id?null:O:O=>O===h.id?null:h.id)}},h.id||x)})})})}),A&&e.jsx(Re,{cluster:A,clusterIndex:F.length+1,clusters:t,isDraggable:!1,isCollapsed:R,onUpdateQuestion:(h,x)=>H(A.id,h,x),onDeleteQuestion:h=>V(A.id,h),onAddQuestion:h=>K(A.id,h),onMoveQuestion:(h,x)=>Y(A.id,h,x),bankQuestions:n?r.find(h=>h.id===A.id||h.name===A.name)?.questions||[]:void 0,onAddFromBank:h=>z(A.id,h),isOneOff:n,scope:c,isBankOpen:f===A.id,onToggleBank:h=>{C(h===!1?x=>x===A.id?null:x:x=>x===A.id?null:A.id)}},A.id||"open")]}),e.jsx(Ms,{open:k,onClose:()=>I(!1),onConfirm:X,loading:q})]})},Fe=({frequency:t="weekly",isComprehensive:o=!1,subject:n,body:a})=>{const[r,c]=b.useState(!1),{title:l,body:_}=Is(t,o,n,a);return e.jsxs("div",{className:s["v2-email-preview-wrapper"],children:[e.jsxs("button",{type:"button",onMouseEnter:()=>c(!0),onMouseLeave:()=>c(!1),onClick:()=>c(w=>!w),className:s["v2-btn-preview-email"],children:[e.jsx(y.LuEye,{size:16}),e.jsx("span",{children:"Preview email"})]}),r&&e.jsxs("div",{className:s["v2-email-preview-popover"],onMouseEnter:()=>c(!0),onMouseLeave:()=>c(!1),children:[e.jsxs("div",{className:s["v2-email-preview-popover__head"],children:[e.jsx("div",{className:s["v2-email-preview-popover__logo-wrap"],children:e.jsx("img",{src:Xe.getStaticFileUrl("/images/logo-white.png"),alt:"MARIO",className:s["v2-email-preview-popover__logo-img"]})}),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:l}),e.jsx("p",{className:s["v2-email-preview-popover__desc"],children:_}),e.jsxs("button",{type:"button",className:s["v2-email-preview-popover__btn-start"],children:[e.jsx("span",{children:"Start check-in"}),e.jsx(y.LuArrowRight,{size:14})]})]})]})]})},Ls=({config:t,onChangeConfig:o,clusters:n,onChangeClusters:a,onSave:r,onRestoreDefaults:c})=>{const l=t.isEnabled,_=()=>{o(ps(t))},w=d=>{o({...t,frequency:d})},u=d=>{o({...t,dayOfWeek:d})},v=()=>{o({...t,emailNotify:!t.emailNotify})};return e.jsxs("div",{className:s["v2-routine-container"],children:[e.jsxs("div",{className:`${s["v2-power-card"]} ${l?s["v2-power-card--active"]:""}`,children:[e.jsx("span",{className:s["v2-power-card__icon"],children:e.jsx(y.LuPower,{size:22,color:l?"#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 ",l?"on":"off"]}),e.jsx("div",{className:s["v2-power-card__sub"],children:l?"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"]} ${l?s["v2-power-card__state-text--active"]:""}`,children:l?"On":"Off"}),e.jsx("button",{type:"button",onClick:_,className:`${s["v2-power-card__switch"]} ${l?s["v2-power-card__switch--active"]:""}`,children:e.jsx("span",{className:`${s["v2-power-card__knob"]} ${l?s["v2-power-card__knob--active"]:""}`})})]}),e.jsxs("div",{className:`${s["v2-routine-body"]} ${l?"":s["v2-routine-body--disabled"]}`,children:[e.jsxs("div",{className:s["v2-info-callout"],children:[e.jsx(ie.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:cs.map(d=>{const f=t.frequency===d.id;return e.jsxs("button",{type:"button",onClick:()=>w(d.id),className:`${s["v2-cadence-card"]} ${f?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"]} ${f?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:ds.map(d=>{const f=t.dayOfWeek===d;return e.jsx("button",{type:"button",onClick:()=>u(d),className:`${s["v2-day-pill"]} ${f?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(ie.FiInfo,{size:17,color:"#316CD9"}),e.jsx("span",{children:"How the rotation works"})]}),e.jsxs("p",{className:s["v2-rotation-box__desc"],children:["Each ",ws(t.frequency),", 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:_s.map((d,f)=>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]})]},f))})]})]})]}),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(qe,{clusters:n,onChangeClusters:a,scope:"routine",onRestoreDefaults: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:"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(ie.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:v,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(Fe,{frequency:t.frequency})]}),e.jsxs("button",{type:"button",onClick:r,className:s["v2-btn-primary"],children:[e.jsx(y.LuCheck,{size:20,color:"#fff"})," Save configuration"]})]})]})},$s=({config:t,onChangeConfig:o,clusters:n,onChangeClusters:a,onSave:r,onRestoreDefaults:c})=>{const l=t.isEnabled,_=()=>{o({...t,isEnabled:!t.isEnabled})},w=(f,C)=>{if(C&&t.sendDates.some((q,$)=>$!==f&&q===C)){S("This date has already been added to the schedule.","warning");return}const k=[...t.sendDates];k[f]=C;const I=je(k);o({...t,sendDates:I})},u=()=>{o({...t,sendDates:[...t.sendDates,""]})},v=f=>{const C=t.sendDates.filter((k,I)=>I!==f);o({...t,sendDates:je(C)})},d=()=>{o({...t,emailNotify:!t.emailNotify})};return e.jsxs("div",{className:s["v2-comprehensive-container"],children:[e.jsxs("div",{className:`${s["v2-power-card"]} ${l?s["v2-power-card--active"]:""}`,children:[e.jsx("span",{className:s["v2-power-card__icon"],children:e.jsx(y.LuPower,{size:22,color:l?"#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 ",l?"on":"off"]}),e.jsx("div",{className:s["v2-power-card__sub"],children:l?"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"]} ${l?s["v2-power-card__state-text--active"]:""}`,children:l?"On":"Off"}),e.jsx("button",{type:"button",onClick:_,className:`${s["v2-power-card__switch"]} ${l?s["v2-power-card__switch--active"]:""}`,children:e.jsx("span",{className:`${s["v2-power-card__knob"]} ${l?s["v2-power-card__knob--active"]:""}`})})]}),e.jsxs("div",{className:`${s["v2-comprehensive-body"]} ${l?"":s["v2-comprehensive-body--disabled"]}`,children:[e.jsxs("div",{className:s["v2-info-callout"],children:[e.jsx(ie.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:Ne.AdapterMoment,children:e.jsxs("div",{className:s["v2-dates-list"],children:[t.sendDates.map((f,C)=>{const k=f&&p(f,D).isValid()?p(f,D):null,I=Be(f);return e.jsxs("div",{className:`${s["v2-date-row"]} ${I?s["v2-date-row--past"]:""}`,children:[e.jsx("span",{className:`${s["v2-date-row__idx"]} ${I?s["v2-date-row__idx--past"]:""}`,children:C+1}),e.jsx("div",{className:s["v2-comprehensive-date-picker-wrap"],children:e.jsx(de.DatePicker,{value:k,shouldDisableDate:q=>{if(!q||!q.isValid())return!1;const $=q.format(D);return t.sendDates.some((R,B)=>B!==C&&R===$)},onChange:q=>{const $=q&&p(q).isValid()?p(q).format(D):"";w(C,$)},format:os,slotProps:{textField:{size:"small",fullWidth:!0,variant:"outlined",sx:{background:I?"#F5F6F8":"#fff","& .MuiOutlinedInput-root":{borderRadius:"10px",fontSize:"14.5px",fontWeight:500,color:I?"#6B7280":"#242424",height:42,"& fieldset":{borderColor:I?"#E5E7EB":"#D3D3D3"},"&:hover fieldset":{borderColor:"#316CD9"},"&.Mui-focused fieldset":{borderColor:"#316CD9"}},"& .MuiInputBase-input":{padding:"8px 12px"}}}}})}),I&&e.jsx("span",{className:s["v2-date-row__past-badge"],children:"Past date"}),t.sendDates.length>1&&e.jsx("button",{type:"button",onClick:()=>v(C),title:"Remove date",className:s["v2-date-row__btn-remove"],children:e.jsx(y.LuTrash2,{size:16,color:"#C44140"})})]},C)}),e.jsxs("button",{type:"button",onClick:u,className:s["v2-comprehensive-btn-add-date"],children:[e.jsx(y.LuPlus,{size:17,color:"#316CD9"})," Add send date"]})]})})]}),e.jsxs("div",{className:s["v2-comprehensive-note-box"],children:[e.jsx(y.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(qe,{clusters:n,onChangeClusters:a,scope:"comprehensive",onRestoreDefaults: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:"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(ie.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:d,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(Fe,{isComprehensive:!0})]}),e.jsxs("button",{type:"button",onClick:r,className:s["v2-btn-primary"],children:[e.jsx(y.LuCheck,{size:20,color:"#fff"})," Save configuration"]})]})]})},Bs=({open:t,onClose:o,pastOneOff:n,masterBankClusters:a})=>{if(!t||!n)return null;const r=ks(n),c=Cs(n,a),l=c.reduce((_,w)=>_+w.questions.length,0);return e.jsx("div",{onClick:o,className:s["v2-launch-modal-overlay"],children:e.jsxs("div",{onClick:_=>_.stopPropagation(),className:s["v2-view-modal"],children:[e.jsxs("div",{className:s["v2-view-modal__header"],children:[e.jsx("button",{type:"button",onClick:o,className:s["v2-view-modal__btn-close"],title:"Close modal",children:e.jsx(y.LuX,{size:18,color:"#6B6B6B"})}),e.jsx("div",{className:s["v2-view-modal__icon-box"],children:e.jsx(y.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:`${l||n.questionCount} questions · ${n.responseCount} of ${n.totalTeachers} responded`})]})]}),e.jsxs("div",{className:s["v2-view-modal__body"],children:[r.length>0&&e.jsxs("div",{className:s["v2-view-modal__sent-section"],children:[e.jsx("span",{className:s["v2-view-modal__section-label"],children:r.length>1?"SCHEDULED & SENT DATES":"SENT ON"}),e.jsx("div",{className:s["v2-view-modal__sent-badges-list"],children:r.map((_,w)=>{const u=Be(_);return e.jsxs("div",{className:`${s["v2-view-modal__sent-badge"]} ${u?s["v2-view-modal__sent-badge--past"]:s["v2-view-modal__sent-badge--future"]}`,children:[e.jsx(y.LuCalendar,{size:15,color:u?"#9CA3AF":"#2563EB"}),e.jsx("span",{children:ge(_)})]},_||w)})})]}),e.jsxs("div",{className:s["v2-view-modal__questions-section"],children:[e.jsx("span",{className:s["v2-view-modal__section-label"],children:"QUESTIONS"}),c.length===0?e.jsx("div",{className:s["v2-view-modal__empty"],children:"No question details found for this check-in."}):c.map(({cluster:_,questions:w})=>e.jsxs("div",{className:s["v2-view-modal__cluster-group"],children:[e.jsx("div",{className:s["v2-view-modal__cluster-header"],children:_.label||_.name}),e.jsx("div",{className:s["v2-view-modal__questions-list"],children:w.map((u,v)=>e.jsxs("div",{className:s["v2-view-modal__question-row"],children:[e.jsx("span",{className:s["v2-view-modal__question-num"],children:v+1}),e.jsx("span",{className:s["v2-view-modal__question-text"],children:ke(u.text)})]},u.id||v))})]},_.id))]})]}),e.jsx("div",{className:s["v2-view-modal__footer-single"],children:e.jsx("button",{type:"button",onClick:o,className:s["v2-view-modal__btn-close-footer"],children:"Close"})})]})})},Rs=({open:t,onClose:o,pastOneOff:n,onConfirm:a})=>{const[r,c]=b.useState("");if(!t||!n)return null;const l=Ns(n),_=r&&p(r,D).isValid()?p(r,D):null,w=!!(r&&p(r,D).isValid()&&!l.has(r)),u=$e(n),v=()=>{if(w){if(l.has(r)){S("This check-in has already been scheduled or sent on this date.","warning");return}a?a(n,r):S(`Scheduled "${n.name}" to send on ${p(r).format(fe)}`,"success"),o()}};return e.jsx("div",{onClick:o,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:o,className:s["v2-launch-modal__btn-close"],children:e.jsx(y.LuX,{size:18,color:"#6B6B6B"})}),e.jsx("div",{className:s["v2-sendagain-modal__icon-box"],children:e.jsx(y.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 ",u," question",u>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:Ne.AdapterMoment,children:e.jsx(de.DatePicker,{value:_,minDate:p().startOf("day"),shouldDisableDate:d=>{if(!d||!d.isValid())return!1;const f=d.format(D);return l.has(f)},onChange:d=>{const f=d&&p(d).isValid()?p(d).format(D):"";if(f&&l.has(f)){S("This check-in has already been scheduled or sent on this date.","warning");return}c(f)},format:fe,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:o,className:s["v2-launch-modal__btn-cancel"],children:"Cancel"}),e.jsxs("button",{type:"button",onClick:v,disabled:!w,className:`${s["v2-launch-modal__btn-start"]} ${w?s["v2-launch-modal__btn-start--valid"]:""}`,children:[e.jsx(y.LuSend,{size:18,color:"#fff"})," Schedule send"]})]})]})})},Fs=({clusters:t,onChangeClusters:o,pastOneOffs:n,masterBankClusters:a=le,onSaveAndContinue:r,onSendItAgain:c,isOn:l=!0,onToggle:_})=>{const[w,u]=b.useState(!0),v=l!==void 0?l:w,d=()=>{_?_(!v):u(T=>!T)},[f,C]=b.useState(!1),[k,I]=b.useState(""),[q,$]=b.useState(null),[R,B]=b.useState(null),F=(T,Q)=>{c?c(T,Q):S(`Scheduled "${T.name}" to send on ${p(Q).format(fe)}`,"success"),B(null)},A=Le(t),Z=!k.trim()||A===0;return e.jsxs("div",{className:s["v2-oneoff-container"],children:[e.jsxs("div",{className:`${s["v2-power-card"]} ${v?s["v2-power-card--active"]:""}`,children:[e.jsx("span",{className:s["v2-power-card__icon"],children:e.jsx(y.LuCalendarClock,{size:22,color:v?"#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"]} ${v?s["v2-power-card__state-text--active"]:""}`,children:v?"On":"Off"}),e.jsx("button",{type:"button",onClick:d,className:`${s["v2-power-card__switch"]} ${v?s["v2-power-card__switch--active"]:""}`,children:e.jsx("span",{className:`${s["v2-power-card__knob"]} ${v?s["v2-power-card__knob--active"]:""}`})})]}),e.jsxs("div",{className:s["v2-oneoff-accordion"],children:[e.jsxs("button",{type:"button",onClick:()=>C(T=>!T),className:s["v2-oneoff-accordion__header"],children:[e.jsx("span",{className:s["v2-oneoff-accordion__icon-box"],children:e.jsx(y.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."]})]}),f?e.jsx(ie.FiChevronUp,{size:18,color:"#6B6B6B"}):e.jsx(ie.FiChevronDown,{size:18,color:"#6B6B6B"})]}),f&&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((T,Q)=>{const H=Ss(T);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:T.name}),e.jsx("div",{className:s["v2-oneoff-accordion__item-meta"],children:`Sent ${H} · ${$e(T)} questions · ${T.responseCount||0} of ${T.totalTeachers||0} responded`})]}),e.jsxs("div",{className:s["v2-oneoff-accordion__item-actions"],children:[e.jsxs("button",{type:"button",onClick:()=>$(T),className:s["v2-oneoff-accordion__btn-view"],children:[e.jsx(y.LuEye,{size:15,color:"#4B5563"})," View"]}),e.jsxs("button",{type:"button",onClick:()=>B(T),className:s["v2-oneoff-accordion__btn-send-again"],children:[e.jsx(y.LuSend,{size:14,color:"#316CD9"})," Send it again"]})]})]},T.id||Q)})})]}),e.jsx(Bs,{open:!!q,onClose:()=>$(null),pastOneOff:q,masterBankClusters:a}),R&&e.jsx(Rs,{open:!!R,onClose:()=>B(null),pastOneOff:R,onConfirm:F},R.id),v&&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:k,onChange:T=>I(T.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(qe,{clusters:t,onChangeClusters:o,blank:!0,masterBankClusters:a,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(y.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:k.trim()?`“${k.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."}),!k.trim()&&e.jsxs("div",{className:s["v2-send-warning-box"],children:[e.jsx(y.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:()=>r(k.trim()),disabled:Z,className:s["v2-btn-primary"],title:k.trim()?A===0?"Please add at least 1 question to continue":"":"Please enter a check-in name to continue",children:[e.jsx(y.LuCheck,{size:20,color:"#fff"}),"Save & continue"]})]})]})]})},Ys=({size:t=40,color:o="#0F9655",...n})=>e.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:t,height:t,viewBox:"0 0 24 24",fill:"none",stroke:o,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"})]}),Qs=({data:t,loading:o=!1,hasError:n=!1,onRetry:a,onEditMode:r,onToggleRoutine:c,onToggleComprehensive:l,onToggleOneOff:_,isOneOffEnabled:w})=>{const u=Oe.useNavigate(),v=t.routine,d=t.comprehensive,f=w!==void 0?w:t.isOneOffEnabled!==!1,C=()=>gs(v,t.routineLaunchDate),k=()=>js(d,t.comprehensiveLaunchDate),I=[{id:"routine",title:"Routine check-in",icon:e.jsx(y.LuRepeat,{size:20,color:"#316CD9"}),iconModifierClass:s["v2-saved-item__icon--routine"],subText:C(),loadingText:"Loading routine status...",errorText:"Unable to load routine status",isEnabled:!!v.isEnabled,onToggle:()=>c&&c(!v.isEnabled)},{id:"comprehensive",title:"Comprehensive check-in",icon:e.jsx(y.LuCalendarRange,{size:20,color:"#0284C7"}),iconModifierClass:s["v2-saved-item__icon--comprehensive"],subText:k(),loadingText:"Loading survey status...",errorText:"Unable to load survey status",isEnabled:!!d.isEnabled,onToggle:()=>l&&l(!d.isEnabled)},{id:"oneoff",title:"One-off check-in",icon:e.jsx(y.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:!!f,onToggle:()=>_?_(!f):r("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(y.LuTriangleAlert,{size:36,color:"#DC2626"}):e.jsx(Ys,{size:38,color:"#0F9655"})}),e.jsx("h2",{className:s["v2-saved-title"],children:n?"Unable to load settings":"Staff check-in saved"}),o?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."," ",a&&e.jsx("button",{type:"button",onClick:a,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:[ys(t),"."]})," Teachers will be notified when it goes live."]}),e.jsx("div",{className:s["v2-saved-list"],children:I.map(q=>e.jsxs("div",{className:s["v2-saved-item"],children:[e.jsx("div",{className:`${s["v2-saved-item__icon"]} ${q.iconModifierClass}`,children:q.icon}),e.jsxs("div",{className:s["v2-saved-item__info"],children:[e.jsx("div",{className:s["v2-saved-item__title"],children:q.title}),e.jsx("div",{className:s["v2-saved-item__sub"],children:o?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:q.loadingText})]}):n&&q.errorText?e.jsx("span",{className:s["v2-saved-error-text"],children:q.errorText}):q.subText})]}),e.jsxs("div",{className:s["v2-saved-item__actions"],children:[o?e.jsx("div",{className:s["v2-saved-item-spinner"],children:e.jsx(pe.Loading,{size:16})}):n&&q.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:q.isEnabled?"On":"Off"}),e.jsx("button",{type:"button",onClick:q.onToggle,className:`${s["v2-saved-item__switch"]} ${q.isEnabled?s["v2-saved-item__switch--on"]:""}`,children:e.jsx("span",{className:`${s["v2-saved-item__knob"]} ${q.isEnabled?s["v2-saved-item__knob--on"]:""}`})})]}),e.jsxs("button",{type:"button",disabled:o||n,onClick:()=>r(q.id),className:s["v2-saved-item__btn-edit"],children:[e.jsx(y.LuPencil,{size:14}),e.jsx("span",{children:"Edit"})]})]})]},q.id))}),e.jsxs("button",{type:"button",onClick:()=>u("/admin/well-being-dashboard"),className:s["v2-saved-btn-dashboard"],children:[e.jsx(y.LuGauge,{size:18}),e.jsx("span",{children:"Go to dashboard"})]})]})})},ne=(t,o)=>{if(!o||!t)return t;const n=new Map;return o.forEach(a=>{a.questions?.forEach(r=>{r.id&&n.set(r.id,{question:r,clusterId:a.id})})}),t.map(a=>{let r=[...a.questions||[]];return r=r.map(c=>{if(c.id&&n.has(c.id)){const _=n.get(c.id).question;return{...c,text:_.text,descriptors:_.descriptors!==void 0?_.descriptors:c.descriptors,includedInBulk:_.includedInBulk!==void 0?_.includedInBulk:c.includedInBulk,isAppliedToAllClusters:_.isAppliedToAllClusters!==void 0?_.isAppliedToAllClusters:c.isAppliedToAllClusters,clusterId:_.clusterId!==void 0?_.clusterId:c.clusterId,sectionName:_.sectionName!==void 0?_.sectionName:c.sectionName,kind:_.kind||c.kind}}return c}),o.forEach(c=>{c.questions?.forEach(l=>{l.id&&l.kind!=="open"&&(c.id===a.id?r.some(w=>w.id===l.id)||t.some(u=>u.id!==a.id&&u.questions?.some(v=>v.id===l.id))&&r.push({...l}):o.some(w=>w.id!==a.id&&w.questions?.some(u=>u.id===l.id))&&(r=r.filter(w=>w.id!==l.id)))})}),{...a,questions:r}})},zs=()=>{const n=`WELLBEING_ONE_OFF_DRAFT_${Ze.useSelector(i=>i.common?.user)?.id||localStorage.getItem("USER_EMAIL")||"default_user"}`,[a,r]=b.useState(!0),[c,l]=b.useState(!1),[_,w]=b.useState(!1),[u,v]=b.useState("routine"),[d,f]=b.useState(!0),[C,k]=b.useState(!1),[I,q]=b.useState("routine"),[$,R]=b.useState(null),[B,F]=b.useState(null),[A,Z]=b.useState(null),[T,Q]=b.useState(1),[H,V]=b.useState(!0),[K,Y]=b.useState(we.routine),[z,J]=b.useState(we.comprehensive),[X,W]=b.useState(le),[h,x]=b.useState(le),[L,E]=b.useState(le),[O,G]=b.useState(()=>{try{const i=localStorage.getItem(n);if(i){const j=JSON.parse(i);if(localStorage.removeItem(n),j?.clusters&&Array.isArray(j.clusters)&&j.clusters.reduce((ee,oe)=>ee+(oe.questions?.length||0),0)>0)return j.clusters}}catch{}return le.map(i=>({...i,questions:[]}))}),[se,re]=b.useState(!1),[g,m]=b.useState(null),M=b.useRef(!0);b.useEffect(()=>{if(M.current){M.current=!1;return}try{if(O.reduce((j,N)=>j+(N.questions?.length||0),0)>0){const j=new Date().toISOString();localStorage.setItem(n,JSON.stringify({clusters:O,updatedAt:j}))}else localStorage.removeItem(n)}catch(i){console.error("Error saving one-off draft to storage",i)}},[O,n]),b.useEffect(()=>{const i=()=>{try{O.reduce((N,ee)=>N+(ee.questions?.length||0),0)>0&&localStorage.setItem(n,JSON.stringify({clusters:O,updatedAt:new Date().toISOString()}))}catch{}};return window.addEventListener("beforeunload",i),()=>window.removeEventListener("beforeunload",i)},[O,n]);const P=()=>{try{localStorage.removeItem(n),re(!1),m(null),G(L.map(i=>({...i,questions:[]}))),S("Draft cleared. Starting with a blank form.","info")}catch(i){console.error("Error clearing draft",i)}},[ce,te]=b.useState(we.pastOneOffs),he=b.useCallback(i=>{if(Q(i.setupId||1),i.isOneOffEnabled!==void 0&&V(i.isOneOffEnabled),i.launchDate&&R(i.launchDate),i.routineLaunchDate&&F(i.routineLaunchDate),i.comprehensiveLaunchDate&&Z(i.comprehensiveLaunchDate),i.routine&&Y(i.routine),i.comprehensive){const oe=[...i.comprehensive.sendDates||[]].sort((ae,Ge)=>new Date(ae).getTime()-new Date(Ge).getTime());J({...i.comprehensive,sendDates:oe})}const j=i.routineClusters&&i.routineClusters.length>0?i.routineClusters:i.clusters||le,N=i.comprehensiveClusters&&i.comprehensiveClusters.length>0?i.comprehensiveClusters:i.clusters||le,ee=i.masterBankClusters&&i.masterBankClusters.length>0?i.masterBankClusters:i.clusters||le;W(j),x(N),E(ee);try{localStorage.getItem(n)||G(ee.map(ae=>({...ae,questions:[]})))}catch{}i.pastOneOffs&&i.pastOneOffs.length>0&&te(i.pastOneOffs)},[n]),_e=b.useCallback(async()=>{try{r(!0),l(!1);const i=await U.getWellBeingSetupV2();i.data&&he(i.data)}catch(i){console.error("Failed to load wellbeing setup v2, using defaults",i),l(!0)}finally{r(!1)}},[he]);b.useEffect(()=>{let i=!0;return document.title="Staff Well-being Setup",(async()=>{try{const N=await U.getWellBeingSetupV2();i&&N.data&&he(N.data)}catch(N){i&&(console.error("Failed to load wellbeing setup v2, using defaults",N),l(!0))}finally{i&&r(!1)}})(),()=>{i=!1}},[he]);const Ce=Oe.useLocation();b.useEffect(()=>{const i=()=>{f(!0),k(!1),v("routine"),_e()};return window.addEventListener("RESET_FREQUENCY_AND_SETUP_SAVED_VIEW",i),()=>{window.removeEventListener("RESET_FREQUENCY_AND_SETUP_SAVED_VIEW",i)}},[_e]),b.useEffect(()=>{Ce.pathname.includes("frequency-and-setup")&&(f(!0),k(!1))},[Ce.key]);const Ye=i=>{u!==i&&(v(i),f(!1))},Qe=()=>{f(!0)},ze=async i=>{try{w(!0),await U.updateWellBeingSetupV2Api({scope:"routine",routine:K,clusters:X,routineLaunchDate:i,launchDate:i}),F(i),R(i),S("Routine check-in configuration saved successfully","success"),k(!1),f(!0)}catch(j){console.error("Failed to save routine setup",j),S("Failed to save configuration","error")}finally{w(!1)}},Pe=async(i,j)=>{try{w(!0);const N=j||z.sendDates,ee={...z,sendDates:N};await U.updateWellBeingSetupV2Api({scope:"comprehensive",comprehensive:ee,clusters:h,comprehensiveLaunchDate:i,launchDate:i}),J(ee),Z(i),R(i),S("Comprehensive survey configuration saved successfully","success"),k(!1),f(!0)}catch(N){console.error("Failed to save comprehensive setup",N),S("Failed to save configuration","error")}finally{w(!1)}},Ve=async(i,j)=>{try{w(!0);const N=[];if(O.forEach(oe=>{oe.questions.forEach(ae=>{ae.isEnabled&&N.push(Number(ae.id))})}),N.length===0){S("Please select at least one question before launching.","warning");return}const ee=j?.trim()||`One-off pulse (${i})`;await U.createOneOffCheckInApi({name:ee,startDate:i,questionIds:N,questions:O.flatMap(oe=>oe.questions.map(ae=>({id:Number(ae.id),text:ae.text,clusterId:oe.id,kind:ae.kind,descriptors:ae.descriptors||null})))}),await _e();try{localStorage.removeItem(n),re(!1),m(null),G(L.map(oe=>({...oe,questions:[]})))}catch{}S("One-off check-in launched successfully","success"),k(!1),f(!0)}catch(N){console.error("Failed to create one-off check-in",N),S("Failed to launch one-off check-in","error")}finally{w(!1)}},We=async(i,j)=>{try{w(!0),await U.sendItAgainApi({oneOffId:i.id,sendDate:j}),S(`Scheduled "${i.name}" to send on ${j}`,"success"),await _e()}catch(N){console.error("Failed to schedule send it again",N),S("Failed to schedule send","error")}finally{w(!1)}},Ue=async i=>{const j={...K,isEnabled:i};Y(j);try{await U.updateWellBeingSetupV2Api({scope:"routine",routine:j,clusters:X}),S(i?"Routine check-in enabled":"Routine check-in disabled","info")}catch(N){console.error("Failed to toggle routine",N),S("Failed to update routine status","error")}},He=async i=>{const j={...z,isEnabled:i};J(j);try{await U.updateWellBeingSetupV2Api({scope:"comprehensive",comprehensive:j,clusters:h}),S(i?"Comprehensive survey enabled":"Comprehensive survey disabled","info")}catch(N){console.error("Failed to toggle comprehensive",N),S("Failed to update comprehensive status","error")}},Ke=async i=>{V(i);try{await U.updateWellBeingSetupV2Api({scope:"oneoff",isOneOffEnabled:i}),S(i?"One-off check-in enabled":"One-off check-in disabled","info")}catch(j){console.error("Failed to toggle one-off",j),S("Failed to update one-off status","error")}},be=b.useCallback(i=>{W(i),x(j=>ne(j,i)),E(j=>ne(j,i)),G(j=>ne(j,i))},[]),Se=b.useCallback(i=>{x(i),W(j=>ne(j,i)),E(j=>ne(j,i)),G(j=>ne(j,i))},[]),De=b.useCallback(i=>{E(i),W(j=>ne(j,i)),x(j=>ne(j,i)),G(j=>ne(j,i))},[]),Ie=b.useCallback(i=>{G(i);const j=i.reduce((N,ee)=>N+(ee.questions?.length||0),0);m(j>0?new Date().toISOString():null),W(N=>ne(N,i)),x(N=>ne(N,i)),E(N=>ne(N,i))},[]);return{loading:a,hasError:c,refetch:_e,saving:_,activeTab:u,setActiveTab:v,isSavedView:d,setIsSavedView:f,isLaunchModalOpen:C,setIsLaunchModalOpen:k,launchScope:I,setLaunchScope:q,launchDate:$,setLaunchDate:R,routineLaunchDate:B,setRoutineLaunchDate:F,comprehensiveLaunchDate:A,setComprehensiveLaunchDate:Z,isOneOffEnabled:H,setIsOneOffEnabled:V,routineConfig:K,setRoutineConfig:Y,comprehensiveConfig:z,setComprehensiveConfig:J,clusters:X,setClusters:be,routineClusters:X,setRoutineClusters:be,comprehensiveClusters:h,setComprehensiveClusters:Se,masterBankClusters:L,setMasterBankClusters:De,oneOffClusters:O,setOneOffClusters:Ie,handleRoutineClustersChange:be,handleComprehensiveClustersChange:Se,handleMasterBankClustersChange:De,handleOneOffClustersChange:Ie,hasDraft:se,draftSavedAt:g,handleClearDraft:P,pastOneOffs:ce,fullSetupData:{setupId:T,isOneOffEnabled:H,launchDate:$,routineLaunchDate:B,comprehensiveLaunchDate:A,routine:K,comprehensive:z,clusters:X,routineClusters:X,comprehensiveClusters:h,masterBankClusters:L,pastOneOffs:ce},handleSelectTab:Ye,handleBackToOverview:Qe,handleSaveRoutine:ze,handleSaveComprehensive:Pe,handleLaunchOneOff:Ve,handleSendItAgain:We,handleToggleRoutine:Ue,handleToggleComprehensive:He,handleToggleOneOff:Ke,handleRestoreDefaults:async i=>{try{r(!0);const N=(await U.restoreDefaultQuestionsApi(i)).data;N&&(N.routineClusters&&W(N.routineClusters),N.comprehensiveClusters&&x(N.comprehensiveClusters),N.masterBankClusters&&E(N.masterBankClusters)),S("Default questions restored successfully","success")}catch(j){console.error("Failed to restore default questions",j),S("Failed to restore default questions","error")}finally{r(!1)}}}},Ps=({onClose:t,onStart:o,initialDate:n,scope:a,comprehensiveSendDates:r})=>{const[c,l]=b.useState(()=>ye(n)?n:""),_=Ds(c),w=ye(c),u=Es(c,a,r),v=()=>{w&&o(c,u?.updatedSendDates)};return e.jsx("div",{onClick:t,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:t,className:s["v2-launch-modal__btn-close"],children:e.jsx(y.LuX,{size:18,color:"#6B6B6B"})}),e.jsx("div",{className:s["v2-launch-modal__icon-box"],children:e.jsx(y.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.jsxs("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:Ne.AdapterMoment,children:e.jsx(de.DatePicker,{value:_,minDate:p().startOf("day"),onChange:d=>{const f=d&&p(d).isValid()?p(d).format(D):"";l(f)},format:fe,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"}}}}})})]}),u&&e.jsxs("div",{className:s["v2-launch-modal__warning-box"],children:[e.jsx(y.LuTriangleAlert,{size:18,className:s["v2-launch-modal__warning-icon"]}),e.jsx("div",{className:s["v2-launch-modal__warning-text"],children:u.message})]})]}),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:v,disabled:!w,className:`${s["v2-launch-modal__btn-start"]} ${w?s["v2-launch-modal__btn-start--valid"]:""}`,children:[e.jsx(y.LuSend,{size:18,color:"#fff"})," Start check-in"]})]})]})})},Vs=()=>{const[t,o]=b.useState({open:!1,message:"",severity:"success"});b.useEffect(()=>ns(r=>o(r)),[]);const n=(a,r)=>{r!=="clickaway"&&o(c=>({...c,open:!1}))};return e.jsx(Te.Snackbar,{open:t.open,autoHideDuration:ls,onClose:n,anchorOrigin:{vertical:"top",horizontal:"right"},className:s["v2-snackbar-wrap"],children:e.jsx(Te.Alert,{onClose:n,severity:t.severity,variant:"filled",elevation:6,className:s["v2-snackbar-alert"],children:t.message})})},Ws=()=>{const[t,o]=b.useState(""),{loading:n,hasError:a,refetch:r,activeTab:c,setActiveTab:l,isSavedView:_,setIsSavedView:w,isLaunchModalOpen:u,setIsLaunchModalOpen:v,routineConfig:d,setRoutineConfig:f,comprehensiveConfig:C,setComprehensiveConfig:k,routineClusters:I,setRoutineClusters:q,comprehensiveClusters:$,setComprehensiveClusters:R,masterBankClusters:B,oneOffClusters:F,setOneOffClusters:A,hasDraft:Z,draftSavedAt:T,handleClearDraft:Q,pastOneOffs:H,fullSetupData:V,isOneOffEnabled:K,launchScope:Y,setLaunchScope:z,handleSelectTab:J,handleBackToOverview:X,handleSaveRoutine:W,handleSaveComprehensive:h,handleLaunchOneOff:x,handleSendItAgain:L,handleToggleRoutine:E,handleToggleComprehensive:O,handleToggleOneOff:G,handleRestoreDefaults:se}=zs(),re=(g,m)=>{if(Y==="routine"){W(g);return}if(Y==="oneoff"){x(g,t);return}if(Y==="comprehensive"){h(g,m);return}};return e.jsxs("div",{className:_?"":s["v2-container"],children:[_?e.jsx(Qs,{data:V,loading:n,hasError:a,onRetry:r,onEditMode:g=>{l(g),w(!1)},onToggleRoutine:E,onToggleComprehensive:O,onToggleOneOff:G,isOneOffEnabled:K}):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(y.LuArrowLeft,{size:16})," Back to Overview"]})]}),e.jsx("p",{className:s["v2-description"],children:"Configure your staff check-in by reviewing questions, choosing how they are grouped, arranging clusters, and setting how often check-ins are sent."}),e.jsx(ss,{activeTab:c,onSelectTab:J})]}),c==="routine"&&e.jsx(Ls,{config:d,onChangeConfig:f,clusters:I,onChangeClusters:q,onSave:()=>{z("routine"),v(!0)},onRestoreDefaults:()=>se("routine")}),c==="comprehensive"&&e.jsx($s,{config:C,onChangeConfig:k,clusters:$,onChangeClusters:R,onSave:()=>{z("comprehensive"),v(!0)},onRestoreDefaults:()=>se("comprehensive")}),c==="oneoff"&&e.jsx(Fs,{clusters:F,onChangeClusters:A,pastOneOffs:H,masterBankClusters:B,hasDraft:Z,draftSavedAt:T,onClearDraft:Q,isOn:K,onToggle:G,onSaveAndContinue:g=>{o(g),z("oneoff"),v(!0)},onSendItAgain:L})]}),u&&e.jsx(Ps,{initialDate:Ts(Y,d,C),scope:Y,comprehensiveSendDates:C.sendDates,onClose:()=>v(!1),onStart:re}),e.jsx(Vs,{})]})};exports.default=Ws;