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C;IAC5C,CAAC;;AAjOM,iCAAe,GAAW,CAAX,AAAY,CAAC","file":"daytool_plan.js","sourcesContent":["import { daytool_need, daytool_note, daytool_person, daytool_stat } from \"../daytool_entity.js\";\r\nimport { daytool_file } from \"../daytool_file.js\";\r\nimport { DateTimeTimeZone, DAYTOOL_PERIOD_UNITS, MICROSOFT_RECURRENCE_PATTERN_TYPE, MICROSOFT_RECURRENCE_RANGE_TYPE } from \"./daytool_event.js\";\r\n\r\n\r\n\r\nexport class daytool_plan_item {\r\n static plan_item_count: number = 0;\r\n id: number = daytool_plan_item.plan_item_count + 1;\r\n title: string[] = [\"New item to complete.\"];\r\n order: number = 10;\r\n completed: boolean = false;\r\n repeats: boolean = false;\r\n repetition_count: number = 0;\r\n notes_entity_id: number[] = [];\r\n stats_entity_id: number[] = [];\r\n needs_entity_id: number[] = [];\r\n persons_entity_id: number[] = [];\r\n files: daytool_file[] = [];\r\n timed: boolean = false;\r\n timing: {\r\n start: DateTimeTimeZone[];\r\n end: DateTimeTimeZone[];\r\n } = {\r\n start: [],\r\n end: [],\r\n };\r\n time_allocated: number;\r\n time_spent: number;\r\n energy: number[];\r\n importance: number[];\r\n experience: number[];\r\n duration: number = 0;\r\n type: string = \"\";\r\n repeating: boolean = false; // Not repeating by default\r\n frequency: DAYTOOL_PERIOD_UNITS;\r\n last_repetition_start: Date;\r\n last_repetition_end: Date;\r\n recurrence: {\r\n recurring_series_id: number | null;\r\n next_repetition_number: number;\r\n recurrence_pattern: {\r\n dayOfMonth: number;\r\n daysOfWeek: string[];\r\n firstDayOfWeek: string;\r\n index: string;\r\n interval: number;\r\n month: number;\r\n type: MICROSOFT_RECURRENCE_PATTERN_TYPE | null;\r\n };\r\n recurrence_range: {\r\n startDate: Date;\r\n endDate: Date;\r\n numberOfOccurrences: number;\r\n recurrenceTimeZone: string;\r\n type: MICROSOFT_RECURRENCE_RANGE_TYPE | null;\r\n };\r\n };\r\n\r\n constructor() {\r\n daytool_plan_item.plan_item_count++;\r\n }\r\n\r\n addToTimeSpent(duration: number) {\r\n // In millisec\r\n this.time_spent = this.time_spent + duration;\r\n }\r\n\r\n returnRepetitionNumbersForTimestampWindow(\r\n start_timestamp: number,\r\n end_timestamp: number\r\n ): number[] {\r\n // Repetitions ended before period start timestamp\r\n if (\r\n this.recurrence.recurrence_range.endDate != null &&\r\n this.recurrence.recurrence_range.endDate.getTime() < start_timestamp\r\n ) {\r\n return null;\r\n }\r\n // Doesn't repeat\r\n else if (this.recurrence.recurrence_pattern.type == null) {\r\n var non_repeatinevent_timestamps = this.returnPlanTimestamps(null);\r\n if (\r\n (non_repeatinevent_timestamps[1] > end_timestamp &&\r\n non_repeatinevent_timestamps[0] < end_timestamp) ||\r\n (non_repeatinevent_timestamps[0] < start_timestamp &&\r\n non_repeatinevent_timestamps[1] > start_timestamp)\r\n ) {\r\n return [1];\r\n }\r\n }\r\n // Repeating event\r\n else if (this.recurrence.recurrence_pattern.type != null) {\r\n var repetition_numbers_to_return = [];\r\n var done = 0;\r\n var repetition_counter = this.recurrence.next_repetition_number;\r\n while (done == 0) {\r\n var timestamps = this.returnPlanTimestamps(repetition_counter);\r\n // If current repetition is already past window, stop loop\r\n if (timestamps[0] > end_timestamp) {\r\n done = 1;\r\n continue;\r\n }\r\n // If current repetition is before window, skip loop\r\n if (timestamps[1] < start_timestamp) {\r\n continue;\r\n }\r\n // If overlapping, adding to array to return\r\n if (\r\n (timestamps[1] > end_timestamp && timestamps[0] < end_timestamp) ||\r\n (timestamps[0] < start_timestamp && timestamps[1] > start_timestamp)\r\n ) {\r\n repetition_numbers_to_return.push(repetition_counter);\r\n }\r\n repetition_counter++;\r\n }\r\n }\r\n }\r\n\r\n returnPlanTimestamps(repetition_number: number | null): number[] {\r\n // If repetition_number is not provided - get current repetition timestamps\r\n if (repetition_number == null && this.recurrence) {\r\n repetition_number = this.recurrence.next_repetition_number;\r\n }\r\n var event_start = null;\r\n var event_end = null;\r\n if (this.timing.start.at(-1)) {\r\n event_start = this.timing.start.at(-1).dateTime;\r\n }\r\n if (this.timing.end.at(-1)) {\r\n event_end = this.timing.end.at(-1).dateTime;\r\n }\r\n var first_event_start_date = new Date(event_start);\r\n var first_event_end_date = new Date(event_end);\r\n if (this.recurrence) {\r\n if (\r\n this.recurrence.recurrence_pattern.type &&\r\n this.recurrence.recurrence_pattern.type != null\r\n ) {\r\n switch (this.recurrence.recurrence_pattern.type) {\r\n case MICROSOFT_RECURRENCE_PATTERN_TYPE.daily:\r\n first_event_start_date.setDate(\r\n first_event_start_date.getDate() +\r\n repetition_number * this.recurrence.recurrence_pattern.interval\r\n );\r\n first_event_end_date.setDate(\r\n first_event_end_date.getDate() +\r\n repetition_number * this.recurrence.recurrence_pattern.interval\r\n );\r\n break;\r\n case MICROSOFT_RECURRENCE_PATTERN_TYPE.weekly:\r\n var current_days_repeated_in_week =\r\n this.recurrence.recurrence_pattern.daysOfWeek.length;\r\n var current_weeks_ahead = Math.floor(\r\n repetition_number / current_days_repeated_in_week\r\n );\r\n var current_day_in_week_number =\r\n repetition_number % current_days_repeated_in_week;\r\n first_event_start_date.setDate(\r\n first_event_start_date.getDate() +\r\n current_weeks_ahead *\r\n this.recurrence.recurrence_pattern.interval +\r\n current_day_in_week_number\r\n );\r\n first_event_end_date.setDate(\r\n first_event_end_date.getDate() +\r\n current_weeks_ahead *\r\n this.recurrence.recurrence_pattern.interval +\r\n current_day_in_week_number\r\n );\r\n break;\r\n case MICROSOFT_RECURRENCE_PATTERN_TYPE.absoluteMonthly:\r\n first_event_start_date.setMonth(\r\n first_event_start_date.getMonth() +\r\n repetition_number * this.recurrence.recurrence_pattern.interval\r\n );\r\n first_event_end_date.setMonth(\r\n first_event_end_date.getMonth() +\r\n repetition_number * this.recurrence.recurrence_pattern.interval\r\n );\r\n break;\r\n case MICROSOFT_RECURRENCE_PATTERN_TYPE.relativeMonthly:\r\n first_event_start_date.setFullYear(\r\n first_event_start_date.getFullYear() +\r\n repetition_number * this.recurrence.recurrence_pattern.interval\r\n );\r\n first_event_end_date.setFullYear(\r\n first_event_end_date.getFullYear() +\r\n repetition_number * this.recurrence.recurrence_pattern.interval\r\n );\r\n break;\r\n case MICROSOFT_RECURRENCE_PATTERN_TYPE.absoluteYearly:\r\n first_event_start_date.setFullYear(\r\n first_event_start_date.getFullYear() +\r\n 10 *\r\n repetition_number *\r\n this.recurrence.recurrence_pattern.interval\r\n );\r\n first_event_end_date.setFullYear(\r\n first_event_end_date.getFullYear() +\r\n 10 *\r\n repetition_number *\r\n this.recurrence.recurrence_pattern.interval\r\n );\r\n break;\r\n case MICROSOFT_RECURRENCE_PATTERN_TYPE.relativeYearly:\r\n first_event_start_date.setFullYear(\r\n first_event_start_date.getFullYear() +\r\n 10 *\r\n repetition_number *\r\n this.recurrence.recurrence_pattern.interval\r\n );\r\n first_event_end_date.setFullYear(\r\n first_event_end_date.getFullYear() +\r\n 10 *\r\n repetition_number *\r\n this.recurrence.recurrence_pattern.interval\r\n );\r\n break;\r\n }\r\n }\r\n }\r\n return [first_event_start_date.getTime(), first_event_end_date.getTime()];\r\n }\r\n\r\n completeItem() {\r\n this.completed = true;\r\n }\r\n\r\n allocateTime(duration: number) {\r\n // In millisec\r\n this.time_allocated = this.time_allocated;\r\n }\r\n\r\n\r\n}\r\n\r\n\r\n"]}