@drincs/nqtr
Version:
A complete system introducing the concepts of location, time and event, producing the framework of a not-quite-point-and-click adventure game.
1 lines • 24.3 kB
JavaScript
import {timeTracker,navigator,routine}from'@drincs/nqtr/handlers';export*from'@drincs/nqtr/handlers';import*as Ne from'@drincs/nqtr/registries';import {fixedCommitments,RegisteredRooms,RegisteredLocations,RegisteredMaps,RegisteredQuests,RegisteredCommitments,RegisteredActivities}from'@drincs/nqtr/registries';export{RegisteredActivities,RegisteredCommitments,RegisteredLocations,RegisteredMaps,RegisteredQuests,RegisteredRooms}from'@drincs/nqtr/registries';import {StoredClassModel,storage}from'@drincs/pixi-vn/storage';import {narration}from'@drincs/pixi-vn/narration';import {PixiError}from'@drincs/pixi-vn/core';var U=Object.defineProperty;var me=(o,r,e)=>r in o?U(o,r,{enumerable:true,configurable:true,writable:true,value:e}):o[r]=e;var W=(o,r)=>{for(var e in r)U(o,e,{get:r[e],enumerable:true});};var n=(o,r,e)=>me(o,typeof r!="symbol"?r+"":r,e);var F={};W(F,{ActivityBaseModel:()=>b,ActivityStoredClass:()=>g,CommitmentBaseModel:()=>P,CommitmentStoredClass:()=>y,LocationBaseModel:()=>E,LocationStoredClass:()=>S,MapBaseModel:()=>C,MapStoredClass:()=>v,QuestBaseModel:()=>w,QuestStoredClass:()=>_,RoomBaseModel:()=>D,RoomStoredClass:()=>I,StageBaseModel:()=>O,StageStoredClass:()=>T});var ge="__nqtr-activity__",g=class extends StoredClassModel{constructor(e,t,i,a=ge){super(a,e);this._onRun=t;n(this,"_timeSlot");n(this,"_dateScheduling");this._timeSlot=i.timeSlot,this._dateScheduling=i.dateScheduling;}_onRun;get timeSlot(){return this._timeSlot}get dateScheduling(){return this._dateScheduling}addTempHistoryItem(){narration.addCurrentStepToHistory();}get run(){return async e=>(this.addTempHistoryItem(),await this._onRun(this,e))}get expired(){return !!(this.dateScheduling?.to&&this.dateScheduling.to<=timeTracker.currentDate)}isActive(e={}){let{timeSlot:t=this.timeSlot,dateScheduling:i=this.dateScheduling}=e;if(i?.from!=null&&i.from>timeTracker.currentDate||i?.to!=null&&i.to<timeTracker.currentDate)return false;t&&!Array.isArray(t)&&(t=[t]);for(let a of t||[])if(!timeTracker.nowIsBetween(a?.from,a?.to))return false;return true}};var b=class extends g{constructor(e,t,i){super(e,t,{dateScheduling:i.dateScheduling,timeSlot:i.timeSlot});n(this,"defaultName");n(this,"defaultDisabled");n(this,"defaultHidden");n(this,"_icon");this.defaultName=i.name||"",this.defaultDisabled=i.disabled||false,this.defaultHidden=i.hidden||false,this._icon=i.renderIcon;}get name(){return this.getStorageProperty("name")||this.defaultName}set name(e){this.setStorageProperty("name",e);}get disabled(){let e=this.getStorageProperty("disabled")||this.defaultDisabled;return typeof e=="string"?storage.getFlag(e):e}set disabled(e){this.setStorageProperty("disabled",e);}get hidden(){let e=this.getStorageProperty("hidden")||this.defaultHidden;return typeof e=="string"?storage.getFlag(e):e}set hidden(e){this.setStorageProperty("hidden",e);}get icon(){return this._icon}};var m="___nqtr-time_manager_data___",p="___nqtr-current_room_memory___",Y="___nqtr-last_event_memory___";function R(o){storage.set(Y,o);}function J(){return storage.get(Y)}var pe="__nqtr-commitment__",y=class extends g{constructor(e,t,i,a){i=i||(()=>{});super(e,i,a,pe);this._characters=t;n(this,"defaultExecutionType");n(this,"defaultPriority");this.defaultExecutionType=a.executionType||"interaction",this.defaultPriority=a.priority;}_characters;get characters(){return this._characters}get executionType(){return this.getStorageProperty("executionType")||this.defaultExecutionType}set executionType(e){this.setStorageProperty("executionType",e);}get priority(){return this.getStorageProperty("priority")||this.defaultPriority||0}set priority(e){this.setStorageProperty("priority",e);}addTempHistoryItem(){let e=navigator.currentRoom;if(!e||this.executionType!=="automatic")return super.addTempHistoryItem();let t=J();switch(t?.type){case "editroom":storage.set(p,t.prev),super.addTempHistoryItem(),storage.set(p,e.id);break;case "edittime":let i=storage.get(m)||{};storage.set(m,t.prev),super.addTempHistoryItem(),storage.set(m,i);break}}};var P=class extends y{constructor(e,t,i){super(e,t?Array.isArray(t)?t:[t]:[],i.onRun,{executionType:i.executionType,priority:i.priority,timeSlot:i.timeSlot,dateScheduling:i.dateScheduling});n(this,"_name");n(this,"_image");n(this,"_icon");n(this,"defaultDisabled");n(this,"defaultHidden");this._name=i.name||"",this._image=i.image,this.defaultDisabled=i.disabled||false,this.defaultHidden=i.hidden||false,this._icon=i.icon;}get name(){return this._name}get image(){return this._image}get icon(){return this._icon}get disabled(){let e=this.getStorageProperty("disabled")||this.defaultDisabled;return typeof e=="string"?storage.getFlag(e):e}set disabled(e){this.setStorageProperty("disabled",e);}get hidden(){let e=this.getStorageProperty("hidden")||this.defaultHidden;return typeof e=="string"?storage.getFlag(e):e}set hidden(e){this.setStorageProperty("hidden",e);}};var d;(i=>(i.log=(a,...s)=>console.log(`[NQTR] ${a}`,...s),i.warn=(a,...s)=>console.warn(`[NQTR] ${a}`,...s),i.error=(a,...s)=>console.error(`[NQTR] ${a}`,...s),i.info=(a,...s)=>console.info(`[NQTR] ${a}`,...s)))(d||(d={}));var h=class extends StoredClassModel{constructor(e,t,i=[]){super(e,t);this.defaultActivities=i;}defaultActivities;get defaultActivitiesIds(){return this.defaultActivities.map(e=>e.id)}get activeActivityScheduling(){return this.getStorageProperty("activeActivityScheduling")||{}}get excludedActivitiesScheduling(){return this.getStorageProperty("excludedActivitiesScheduling")||{}}removeActivityScheduling(e){let t=this.activeActivityScheduling;delete t[e],this.setStorageProperty("activeActivityScheduling",t);let i=this.excludedActivitiesScheduling;delete i[e],this.setStorageProperty("excludedActivitiesScheduling",i);}editActivityScheduling(e,t){this.removeActivityScheduling(e);let i=this.activeActivityScheduling;i[e]=t,this.setStorageProperty("activeActivityScheduling",i);}editExcludedActivityScheduling(e,t){this.removeActivityScheduling(e);let i=this.excludedActivitiesScheduling;i[e]=t,this.setStorageProperty("excludedActivitiesScheduling",i);}get additionalActivitiesIds(){return this.getStorageProperty("additionalActivitiesIds")||[]}get excludedActivitiesIds(){return this.getStorageProperty("excludedActivitiesIds")||[]}get activitiesIds(){return this.additionalActivitiesIds.concat(this.defaultActivitiesIds)}addActivity(e,t={}){let{timeSlot:i,dateScheduling:a}=t;if(i&&!Array.isArray(i)&&(i=[i]),i?.forEach(c=>{let{to:l=timeTracker.dayEndTime+1}=c||{};if(c&&c.from>=l)throw d.error("The from time must be less than the to time."),new PixiError("invalid_usage","The from time must be less than the to time.")}),a?.from!==void 0&&a?.to!==void 0&&a?.from>=a?.to)throw d.error("The from day/date must be less than the to day/date."),new PixiError("invalid_usage","The from day/date must be less than the to day/date.");let s=this.additionalActivitiesIds;this.defaultActivitiesIds.includes(e.id)||s.includes(e.id)?d.info(`Activity with id ${e.id} already exists in the ${this.id}, so it will be updated with the new scheduling options if they are provided.`):(s.push(e.id),this.setStorageProperty("additionalActivitiesIds",s)),this.excludedActivitiesIds.includes(e.id)&&(this.removeActivityScheduling(e.id),d.log(`Activity with id ${e.id} was excluded from the ${this.id}, but now it will be added again with the new scheduling options. So it will be removed from the excluded activities list.`)),(i||a)&&this.editActivityScheduling(e.id,{timeSlot:i,dateScheduling:a});}removeActivity(e){let t=typeof e=="string"?e:e.id,i=this.additionalActivitiesIds;if(i.includes(t))i=i.filter(a=>a!==t),this.setStorageProperty("additionalActivitiesIds",i);else if(this.defaultActivitiesIds.includes(t)){let a=this.excludedActivitiesIds;a.push(t),this.setStorageProperty("excludedActivitiesIds",a);}else d.warn(`Activity with id ${t} not found, so it will be ignored.`);}clearExpiredActivities(){let e=this.activeActivityScheduling,t=this.excludedActivitiesScheduling,i=this.additionalActivitiesIds,a=this.excludedActivitiesIds;i.forEach(s=>{if(s in e){let{to:c}=e[s].dateScheduling||{};c&&c<timeTracker.currentDate&&(this.removeActivityScheduling(s),i=i.filter(l=>l!==s));}}),a.forEach(s=>{s in t&&t[s]&&(this.removeActivityScheduling(s),a=a.filter(c=>c!==s));});}get activities(){return [...new Set([...this.additionalActivitiesIds,...this.defaultActivitiesIds])].reduce((e,t)=>{let i=RegisteredActivities.get(t);return i&&i.isActive(this.activeActivityScheduling[t])&&!this.excludedActivitiesScheduling[t]&&e.push(i),e},[])}};var Ie="__nqtr-location__",S=class extends h{constructor(e,t,i=[]){super(Ie,e,i);this._map=t;}_map;get map(){return this._map}get rooms(){return navigator.rooms.filter(e=>e.location.id===this.id)}};var E=class extends S{constructor(e,t,i={}){super(e,t,i.activities||[]);n(this,"defaultName");n(this,"defaultDisabled");n(this,"defaultHidden");n(this,"_icon");this.defaultName=i.name||"",this.defaultDisabled=i.disabled||false,this.defaultHidden=i.hidden||false,this._icon=i.icon;}get name(){return this.getStorageProperty("name")||this.defaultName}set name(e){this.setStorageProperty("name",e);}get disabled(){let e=this.getStorageProperty("disabled")||this.defaultDisabled;return typeof e=="string"?storage.getFlag(e):e}set disabled(e){this.setStorageProperty("disabled",e);}get hidden(){let e=this.getStorageProperty("hidden")||this.defaultHidden;return typeof e=="string"?storage.getFlag(e):e}set hidden(e){this.setStorageProperty("hidden",e);}get icon(){return this._icon}};var Te="__nqtr-map__",v=class extends h{constructor(r,e=[]){super(Te,r,e);}get locations(){return navigator.locations.filter(r=>r.map.id===this.id)}};var C=class extends v{constructor(e,t={}){super(e,t.activities||[]);n(this,"defaultName");n(this,"_image");this.defaultName=t.name||"",this._image=t.image;}get name(){return this.getStorageProperty("name")||this.defaultName}set name(e){this.setStorageProperty("name",e);}get image(){return this._image}};var ie="__nqtr-room__",I=class extends h{constructor(e,t,i=[]){var r=(...Qt)=>(super(...Qt),this._location=t,this);Array.isArray(i)?r(ie,e,i):(r(ie,e,i.activities),i.routine.forEach(a=>fixedCommitments.set(a.id,[a,e])));}_location;get routine(){return routine.roomCommitments[this.id]||[]}addCommitment(e,t={}){let{timeSlot:i,dateScheduling:a}=t;if(i&&!Array.isArray(i)&&(i=[i]),i?.forEach(s=>{let{to:c=timeTracker.dayEndTime+1}=s||{};if(s&&s.from>=c)throw d.error("The from time must be less than the to time."),new PixiError("invalid_usage","The from time must be less than the to time.")}),a?.from!==void 0&&a?.to!==void 0&&a?.from>=a?.to)throw d.error("The from day/date must be less than the to day/date."),new PixiError("invalid_usage","The from day/date must be less than the to day/date.");routine.add(e,this.id,{timeSlot:i,dateScheduling:a});}removeCommitment(e){routine.remove(e,this.id);}get location(){return this._location}get characters(){return this.routine.reduce((e,t)=>(e.push(...t.characters),e),[])}get automaticFunctions(){return this.routine.reduce((e,t)=>{if(t.executionType==="automatic"&&t.run){let i=async a=>{await t.run(a);};e.push(i);}return e},[])}};var D=class extends I{constructor(e,t,i={}){super(e,t,{activities:i.activities||[],routine:i.routine||[]});n(this,"defaultName");n(this,"_image");n(this,"defaultDisabled");n(this,"defaultHidden");n(this,"_icon");this.defaultName=i.name||"",this._image=i.image,this.defaultDisabled=i.disabled||false,this.defaultHidden=i.hidden||false,this._icon=i.icon;}get name(){return this.getStorageProperty("name")||this.defaultName}set name(e){this.setStorageProperty("name",e);}get image(){return this._image}get disabled(){let e=this.getStorageProperty("disabled")||this.defaultDisabled;return typeof e=="string"?storage.getFlag(e):e}set disabled(e){this.setStorageProperty("disabled",e);}get hidden(){let e=this.getStorageProperty("hidden")||this.defaultHidden;return typeof e=="string"?storage.getFlag(e):e}set hidden(e){this.setStorageProperty("hidden",e);}get icon(){return this._icon}};var Ae="__nqtr-quest__",_=class extends StoredClassModel{constructor(e,t,i={}){super(Ae,e);this._stages=t;n(this,"_onStart");n(this,"_onContinue");this._onStart=i.onStart,this._onContinue=i.onContinue||i.onNextStage;}_stages;get stages(){return this._stages}get currentStageIndex(){return this.getStorageProperty("currentStageIndex")}set currentStageIndex(e){this.setStorageProperty("currentStageIndex",e);}get currentStage(){let e=this.currentStageIndex;if(!(e===void 0||e>=this.stages.length))return this.stages[e]}get started(){return this.currentStageIndex!==void 0}get completed(){return this.currentStageIndex===void 0?false:this.currentStageIndex>this.stages.length-1}get inProgress(){return this.completed||this.failed?false:this.started}get failed(){return this.getStorageProperty("failed")||false}set failed(e){this.setStorageProperty("failed",e);}get onStart(){return this._onStart}get onContinue(){return this._onContinue}get onNextStage(){return this._onContinue}async start(e){if(this.started){console.warn(`[NQTR] Quest ${this.id} is already started`);return}if(this.stages.length===0){d.error(`Quest ${this.id} has no stages`);return}this.currentStageIndex=0;let t=this.currentStage;if(t&&t.start)return this.onStart&&await this.onStart(this,e),await t.start(e);d.error(`Quest ${this.id} has no start stage`);}async goNextIfCompleted(e){return await this.advanceIfCompleted(e)}async advanceIfCompleted(e){if(!this.inProgress)return false;let t=this.currentStage;return t?t.completed?await this.advanceUnconditionally(e):false:(d.error(`Quest ${this.id} has no current stage`),false)}async goNext(e){return await this.continue(e)}async continue(e){let t=this.currentStage;return t?(t.completed=true,await this.advanceUnconditionally(e)):(d.error(`Quest ${this.id} has no current stage`),false)}async forceGoNext(e){return await this.advanceUnconditionally(e)}async advanceUnconditionally(e){if(!this.inProgress)return console.warn(`[NQTR] Quest ${this.id} is not in progress`),false;let t=this.currentStage,i=this.currentStageIndex;if(!t||i===void 0)return d.error(`Quest ${this.id} has no current stage`),false;this.currentStageIndex=i+1,this.onContinue&&await this.onContinue(this,e),t&&t.onEnd&&await t.onEnd(t,e);let a=this.currentStage;return a&&(a.inizialize(),this.currentStageMustStart&&await this.startCurrentStage(e)),true}get currentStageMustStart(){let e=this.currentStage;return e?!e.started&&e.canStart&&!e.completed:false}async startCurrentStage(e){let t=this.currentStage;t&&this.currentStageMustStart?await t.start(e):console.warn(`[NQTR] Quest ${this.id} can't start the current stage`);}};var w=class extends _{constructor(e,t,i){super(e,t,{onStart:i.onStart,onContinue:i.onContinue||i.onNextStage});n(this,"_name");n(this,"_description");n(this,"_icon");n(this,"_image");n(this,"_inDevelopment");this._name=i.name||"",this._description=i.description||"",this._icon=i.icon,this._image=i.image,this._inDevelopment=i.inDevelopment||false;}get name(){return this._name}get description(){return this._description}get icon(){return this._icon}get image(){return this._image}get inDevelopment(){return this._inDevelopment}};var Ee="__nqtr-stage__",T=class extends StoredClassModel{constructor(e,t={}){super(Ee,e);n(this,"_onStart");n(this,"_onEnd");n(this,"_deltaDateRequired");n(this,"_questsRequired");this._onStart=t.onStart,this._onEnd=t.onEnd,this._deltaDateRequired=t.deltaDateRequired,this._questsRequired=t.questsRequired||[];}get onStart(){return this._onStart}get onEnd(){return this._onEnd}get completed(){return this.getStorageProperty("completed")||false}set completed(e){this.setStorageProperty("completed",e);}get started(){return this.getStorageProperty("started")||false}set started(e){this.setStorageProperty("started",e);}get inizializeDate(){return this.getStorageProperty("inizializeDate")}set inizializeDate(e){this.setStorageProperty("inizializeDate",e);}get startDate(){let e=this.inizializeDate;if(e!==void 0)return e+this.deltaDateRequired}get canStart(){let e=this.deltaDateRequired;if(e>0){let t=this.inizializeDate;if(t===void 0||t+e>timeTracker.currentDate)return false}return !(this.questsRequired.length>0&&!this.questsRequired.every(t=>t.quest.currentStageIndex&&t.quest.currentStageIndex>=t.stageNumber))}inizialize(){this.deltaDateRequired>0&&(this.inizializeDate=timeTracker.currentDate,console.log(`[NQTR] Stage ${this.id} will start on date ${this.startDate}`));}async start(e){this.canStart?(this.started=true,this.onStart&&await this.onStart(this,e)):console.warn(`[NQTR] Stage ${this.id} can't start`);}get deltaDateRequired(){return this._deltaDateRequired||0}get questsRequired(){return this._questsRequired||[]}};var O=class extends T{constructor(e,t){super(e,{onStart:t.onStart,onEnd:t.onEnd,deltaDateRequired:t.deltaDateRequired,questsRequired:t.questsRequired});n(this,"_name");n(this,"_description");n(this,"_adviceDescription");n(this,"_image");n(this,"_flags");n(this,"_flagsRequired");n(this,"_requestDescriptionToStart");this._name=t.name||"",this._flags=t.flags||[],this._description=t.description||"",this._adviceDescription=t.adviceDescription||"",this._image=t.image,this._flagsRequired=t.flagsRequired||[],this._requestDescriptionToStart=t.requestDescriptionToStart||"";}get name(){return this._name}get description(){return this._description}get adviceDescription(){return this._adviceDescription}get image(){return this._image}get flags(){return this._flags}get flagsRequired(){return this._flagsRequired}get requestDescriptionToStart(){return this._requestDescriptionToStart}get completed(){return super.completed?true:this.flags.length>0?!!this.flags.every(e=>storage.getFlag(e.flag)):false}set completed(e){super.completed=e;}get canStart(){return this.flagsRequired.length>0&&!this.flagsRequired.every(e=>storage.getFlag(e.flag))?false:super.canStart}};var oe={};var de={};var K={};W(K,{navigator:()=>qe,questsNotebook:()=>Qe,routine:()=>Me,timeTracker:()=>Oe});var q=class{get rooms(){return RegisteredRooms.values()}get locations(){return RegisteredLocations.values()}get maps(){return RegisteredMaps.values()}get currentRoomId(){return storage.get(p)}get currentRoom(){let r=this.currentRoomId;if(!r){d.error("The current room has not yet been set");return}let e=RegisteredRooms.get(r);if(!e){d.error(`Current room ${r} not found`);return}return e}set currentRoom(r){if(typeof r!="string"&&(r=r.id),!RegisteredRooms.get(r)){d.error(`The room ${r} is not registered, so it can't be set as current room`);return}let t=storage.get(p);t!==r&&(R({type:"editroom",prev:t,value:r}),storage.set(p,r));}get currentLocation(){return this.currentRoom?.location}get currentMap(){return this.currentRoom?.location.map}clearExpiredActivities(){RegisteredRooms.values().forEach(r=>{r.clearExpiredActivities();});}};var M=class{get quests(){return RegisteredQuests.values()}get startedQuests(){return this.quests.filter(r=>r.started)}get inProgressQuests(){return this.quests.filter(r=>r.inProgress)}get completedQuests(){return this.quests.filter(r=>r.completed)}get failedQuests(){return this.quests.filter(r=>r.failed)}get notStartedQuests(){return this.quests.filter(r=>!r.started)}find(r){return RegisteredQuests.get(r)}async startsStageMustBeStarted(r){let e=this.quests.map(t=>t.currentStageMustStart?t.startCurrentStage(r):Promise.resolve());await Promise.all(e);}};var H="___nqtr-temporary_commitment___",N=class{get temporaryRoutine(){let r=storage.get(H);if(r){if(Array.isArray(r)){if(r.length>0)throw new PixiError("obsolete_save","The save you loaded is not compatible with the current version of NQTR. Please delete the save and start a new game.");return {}}}else return {};return r}get commitmentsIds(){return [...fixedCommitments.keys(),...Object.keys(this.temporaryRoutine)]}add(r,e,t={}){Array.isArray(r)||(r=[r]);let i=this.temporaryRoutine;r.forEach(a=>{RegisteredCommitments.get(a.id)&&d.warn(`The commitment ${a.id} is already registered, it will be overwritten`),RegisteredCommitments.add(a),i[a.id]={id:a.id,roomId:e,...t};}),storage.set(H,i);}find(r){return RegisteredCommitments.get(r)}remove(r,e){typeof r!="string"&&(r=r.id);let t=this.temporaryRoutine;t[r]?(!e||t[r].roomId===e)&&delete t[r]:d.warn(`The commitment ${r} was not found in the temporary routine, so it will be ignored. If you want to remove a fixed commitment, you can add it to the temporary routine with a same character.`),storage.set(H,t);}clearExpiredRoutine(){RegisteredCommitments.values().forEach(r=>{r.expired&&this.remove(r);});}get characterCommitments(){let r=this.temporaryRoutine;return this.commitmentsIds.reduce((e,t)=>{let i=RegisteredCommitments.get(t),a=r[t],s=a?.roomId||fixedCommitments.get(t)?.[1];return s&&i&&i.isActive(a)&&(i.characters.length>0?i.characters.every(l=>!e[l.id]||i.priority>e[l.id][0].priority)&&i.characters.forEach(l=>{e[l.id]=[i,s];}):d.error(`The commitment ${i.id} has no characters assigned`)),e},{})}get currentRoutine(){return Object.values(this.characterCommitments).map(([r])=>r)}get roomCommitments(){return Object.values(this.characterCommitments).reduce((r,e)=>{let t=e[1];return r[t]||(r[t]=[]),r[t].push(e[0]),r},{})}getCommitmentByCharacter(r){return this.currentRoutine.find(e=>{if(e.characters.map(t=>t.id).includes(r.id))return e})}};var f=class f{};n(f,"dayStartTime",0),n(f,"dayEndTime",24),n(f,"defaultTimeSpent",1),n(f,"timeSlots",[]),n(f,"weekLength",7),n(f,"weekendStartDay",f.weekLength-1),n(f,"getDayName");var u=f;var L=class{initialize(r){let{dayStartTime:e=0,dayEndTime:t=24,defaultTimeSpent:i=1,timeSlots:a=[],weekLength:s=7,weekendStartDay:c=s-1,getDayName:l}=r;u.dayStartTime=e,u.dayEndTime=t,u.defaultTimeSpent=i,u.timeSlots=a,u.weekLength=s,c>=u.weekLength?console.warn(`[NQTR] Weekend start day should be less than week length ${s}, so will be ignored`):u.weekendStartDay=c,u.getDayName=l;}get dayStartTime(){return u.dayStartTime}get dayEndTime(){return u.dayEndTime}get defaultTimeSpent(){return u.defaultTimeSpent}get timeSlots(){return u.timeSlots}get weekLength(){return u.weekLength}get weekendStartDay(){return u.weekendStartDay}get getDayName(){return u.getDayName}get currentTime(){let r=storage.get(m)||{};return r.hasOwnProperty("currentTime")&&typeof r.currentTime=="number"?r.currentTime:this.dayStartTime}set currentTime(r){let e=storage.get(m)||{},t={...e};typeof r=="number"?t.currentTime=r:delete t.currentTime,R({type:"edittime",prev:e,value:t}),storage.set(m,t);}get currentDate(){let r=storage.get(m)||{};return r.hasOwnProperty("currentDate")&&typeof r.currentDate=="number"?r.currentDate:0}set currentDate(r){let e=storage.get(m)||{},t={...e};typeof r=="number"?t.currentDate=r:delete t.currentDate,R({type:"edittime",prev:e,value:t}),storage.set(m,t);}get isWeekend(){return this.currentWeekDayNumber>=this.weekendStartDay}get currentWeekDayNumber(){return this.currentDate%this.weekLength+1}get currentDayName(){return this.getDayName?this.getDayName(this.currentWeekDayNumber-1):(console.warn("[NQTR] Week days names are not defined, so currentDayName will be empty"),"")}get currentTimeSlot(){if(this.timeSlots.length===0)return console.warn("[NQTR] Time slots are not defined"),0;for(let r=0;r<this.timeSlots.length;r++){let e=this.timeSlots[r];if(this.timeSlots.length>r+1&&this.nowIsBetween(e.startTime,this.timeSlots[r+1].startTime))return r}return this.timeSlots.length-1}increaseTime(r=this.defaultTimeSpent){let e=this.currentTime+r;return e>=this.dayEndTime&&(this.increaseDate(),e=this.dayStartTime+(e-this.dayEndTime)),this.currentTime=e,this.currentTime}increaseDate(r=1,e=this.dayStartTime){let t=this.currentDate+r;return this.currentDate=t,this.currentTime=e,this.currentDate}nowIsBetween(r,e){r===void 0&&(r=this.dayStartTime-1),e===void 0&&(e=this.dayEndTime+1);let t=this.currentTime;return r<e?t>=r&&t<e:t>=r||t<e}};var Oe=new L,qe=new q,Me=new N,Qe=new M;var Le={...F,...oe,...de,handlers:K,registries:Ne},zr=Le;export{b as ActivityBaseModel,g as ActivityStoredClass,P as CommitmentBaseModel,y as CommitmentStoredClass,E as LocationBaseModel,S as LocationStoredClass,C as MapBaseModel,v as MapStoredClass,w as QuestBaseModel,_ as QuestStoredClass,D as RoomBaseModel,I as RoomStoredClass,O as StageBaseModel,T as StageStoredClass,zr as default};