@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.1 kB
JavaScript
import {timeTracker,navigator,routine}from'@drincs/nqtr/handlers';export*from'@drincs/nqtr/handlers';import*as Qe 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 {narration}from'@drincs/pixi-vn/narration';import {StoredClassModel,storage}from'@drincs/pixi-vn/storage';import {RegisteredCharacters}from'@drincs/pixi-vn/characters';import {PixiError}from'@drincs/pixi-vn/core';var ce=Object.defineProperty;var K=(s,e)=>{for(var t in e)ce(s,t,{get:e[t],enumerable:true});};var $={};K($,{ActivityBaseModel:()=>_,ActivityStoredClass:()=>m,CommitmentBaseModel:()=>A,CommitmentStoredClass:()=>p,LocationBaseModel:()=>b,LocationStoredClass:()=>h,MapBaseModel:()=>C,MapStoredClass:()=>y,QuestBaseModel:()=>P,QuestStoredClass:()=>v,RoomBaseModel:()=>E,RoomStoredClass:()=>S,StageBaseModel:()=>D,StageStoredClass:()=>I});var fe="__nqtr-activity__",m=class extends StoredClassModel{constructor(t,r,i,n=fe){super(n,t);this._onRun=r;this._timeSlot=i.timeSlot,this._dateScheduling=i.dateScheduling;}_onRun;_timeSlot;get timeSlot(){return this._timeSlot}_dateScheduling;get dateScheduling(){return this._dateScheduling}addTempHistoryItem(){return narration.addCurrentStepToHistory()}get run(){return async t=>(this.addTempHistoryItem(),await this._onRun(this,t))}get expired(){return !!(this.dateScheduling?.to&&this.dateScheduling.to<=timeTracker.currentDate)}isActive(t={}){let{timeSlot:r=this.timeSlot,dateScheduling:i=this.dateScheduling}=t;if(i?.from!=null&&i.from>timeTracker.currentDate||i?.to!=null&&i.to<timeTracker.currentDate)return false;r&&!Array.isArray(r)&&(r=[r]);for(let n of r||[])if(!timeTracker.nowIsBetween(n?.from,n?.to))return false;return true}};var _=class extends m{constructor(e,t,r){super(e,t,{dateScheduling:r.dateScheduling,timeSlot:r.timeSlot}),this.defaultName=r.name||"",this.defaultDisabled=r.disabled||false,this.defaultHidden=r.hidden||false,this._icon=r.renderIcon;}defaultName;get name(){return this.getStorageProperty("name")||this.defaultName}set name(e){this.setStorageProperty("name",e);}defaultDisabled;get disabled(){let e=this.getStorageProperty("disabled")||this.defaultDisabled;return typeof e=="string"?storage.getFlag(e):e}set disabled(e){this.setStorageProperty("disabled",e);}defaultHidden;get hidden(){let e=this.getStorageProperty("hidden")||this.defaultHidden;return typeof e=="string"?storage.getFlag(e):e}set hidden(e){this.setStorageProperty("hidden",e);}_icon;get icon(){return this._icon}};var u="___nqtr-time_manager_data___",g="___nqtr-current_room_memory___",L="___nqtr-last_event_memory___";function R(s){storage.set(L,s);}function j(){return storage.get(L)}var he="__nqtr-commitment__",p=class extends m{constructor(e,t,r,i){r=r||(()=>{}),super(e,r,i,he),this.defaultExecutionType=i.executionType||"interaction",this.defaultPriority=i.priority,this.characters=t.reduce((n,a)=>{if(typeof a=="string"){let c=RegisteredCharacters.get(a);c?n.push(c):console.warn(`Character with id ${a} not found for commitment ${e}`);}else n.push(a);return n},[]);}defaultExecutionType;defaultPriority;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(g,t.prev),super.addTempHistoryItem(),storage.set(g,e.id);break;case "edittime":{let r=storage.get(u)||{};storage.set(u,t.prev),super.addTempHistoryItem(),storage.set(u,r);break}}}runOptions;get run(){return async(e,t)=>{let r=t?.removeFromRoutine??this.executionType==="automatic";return this.addTempHistoryItem(),r&&routine.remove(this.id),await this._onRun(this,e)}}};var A=class extends p{constructor(e,t,r){super(e,t?Array.isArray(t)?t:[t]:[],r.onRun,{executionType:r.executionType,priority:r.priority,timeSlot:r.timeSlot,dateScheduling:r.dateScheduling}),this._name=r.name||"",this._image=r.image,this.defaultDisabled=r.disabled||false,this.defaultHidden=r.hidden||false,this._icon=r.icon;}_name;get name(){return this._name}_image;get image(){return this._image}_icon;get icon(){return this._icon}defaultDisabled;get disabled(){let e=this.getStorageProperty("disabled")||this.defaultDisabled;return typeof e=="string"?storage.getFlag(e):e}set disabled(e){this.setStorageProperty("disabled",e);}defaultHidden;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 o;(i=>(i.log=(n,...a)=>console.log(`[NQTR] ${n}`,...a),i.warn=(n,...a)=>console.warn(`[NQTR] ${n}`,...a),i.error=(n,...a)=>console.error(`[NQTR] ${n}`,...a),i.info=(n,...a)=>console.info(`[NQTR] ${n}`,...a)))(o||={});var f=class extends StoredClassModel{constructor(e,t,r=[]){super(e,t),this.defaultActivitiesIds=r.map(i=>typeof i=="string"?i:i.id);}defaultActivitiesIds;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 r=this.excludedActivitiesScheduling;delete r[e],this.setStorageProperty("excludedActivitiesScheduling",r);}editActivityScheduling(e,t){this.removeActivityScheduling(e);let r=this.activeActivityScheduling;r[e]=t,this.setStorageProperty("activeActivityScheduling",r);}editExcludedActivityScheduling(e,t){this.removeActivityScheduling(e);let r=this.excludedActivitiesScheduling;r[e]=t,this.setStorageProperty("excludedActivitiesScheduling",r);}get additionalActivitiesIds(){return this.getStorageProperty("additionalActivitiesIds")||[]}get excludedActivitiesIds(){return this.getStorageProperty("excludedActivitiesIds")||[]}get activitiesIds(){return this.additionalActivitiesIds.concat(this.defaultActivitiesIds)}addActivity(e,t={}){let r=typeof e=="string"?RegisteredActivities.get(e):e;if(!r)throw o.error(`Activity with id ${e} not found.`),new PixiError("unknown_element",`Activity with id ${e} not found.`);let{timeSlot:i,dateScheduling:n}=t;if(i&&!Array.isArray(i)&&(i=[i]),i?.forEach(c=>{let{to:l=timeTracker.dayEndTime+1}=c||{};if(c&&c.from>=l)throw o.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.")}),n?.from!==void 0&&n?.to!==void 0&&n?.from>=n?.to)throw o.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 a=this.additionalActivitiesIds;this.defaultActivitiesIds.includes(r.id)||a.includes(r.id)?o.info(`Activity with id ${r.id} already exists in the ${this.id}, so it will be updated with the new scheduling options if they are provided.`):(a.push(r.id),this.setStorageProperty("additionalActivitiesIds",a)),this.excludedActivitiesIds.includes(r.id)&&(this.removeActivityScheduling(r.id),o.log(`Activity with id ${r.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||n)&&this.editActivityScheduling(r.id,{timeSlot:i,dateScheduling:n});}removeActivity(e){let t=typeof e=="string"?e:e.id,r=this.additionalActivitiesIds;if(r.includes(t))r=r.filter(i=>i!==t),this.setStorageProperty("additionalActivitiesIds",r);else if(this.defaultActivitiesIds.includes(t)){let i=this.excludedActivitiesIds;i.push(t),this.setStorageProperty("excludedActivitiesIds",i);}else o.warn(`Activity with id ${t} not found, so it will be ignored.`);}clearExpiredActivities(){let e=this.activeActivityScheduling,t=this.excludedActivitiesScheduling,r=this.additionalActivitiesIds,i=this.excludedActivitiesIds;r.forEach(n=>{if(n in e){let{to:a}=e[n].dateScheduling||{};a&&a<timeTracker.currentDate&&(this.removeActivityScheduling(n),r=r.filter(c=>c!==n));}}),i.forEach(n=>{n in t&&t[n]&&(this.removeActivityScheduling(n),i=i.filter(a=>a!==n));});}get activities(){return [...new Set([...this.additionalActivitiesIds,...this.defaultActivitiesIds])].reduce((e,t)=>{let r=RegisteredActivities.get(t);return r?.isActive(this.activeActivityScheduling[t])&&!this.excludedActivitiesScheduling[t]&&e.push(r),e},[])}};var ve="__nqtr-location__",h=class extends f{constructor(t,r,i=[]){super(ve,t,i);this._map=r;}_map;get map(){return this._map}get rooms(){return navigator.rooms.filter(t=>t.location.id===this.id)}};var b=class extends h{constructor(e,t,r={}){super(e,t,r.activities||[]),this.defaultName=r.name||"",this.defaultDisabled=r.disabled||false,this.defaultHidden=r.hidden||false,this._icon=r.icon;}defaultName;get name(){return this.getStorageProperty("name")||this.defaultName}set name(e){this.setStorageProperty("name",e);}defaultDisabled;get disabled(){let e=this.getStorageProperty("disabled")||this.defaultDisabled;return typeof e=="string"?storage.getFlag(e):e}set disabled(e){this.setStorageProperty("disabled",e);}defaultHidden;get hidden(){let e=this.getStorageProperty("hidden")||this.defaultHidden;return typeof e=="string"?storage.getFlag(e):e}set hidden(e){this.setStorageProperty("hidden",e);}_icon;get icon(){return this._icon}};var Te="__nqtr-map__",y=class extends f{constructor(e,t=[]){super(Te,e,t);}get locations(){return navigator.locations.filter(e=>e.map.id===this.id)}};var C=class extends y{constructor(e,t={}){super(e,t.activities||[]),this.defaultName=t.name||"",this._image=t.image;}defaultName;get name(){return this.getStorageProperty("name")||this.defaultName}set name(e){this.setStorageProperty("name",e);}_image;get image(){return this._image}};var te="__nqtr-room__",S=class extends f{_location;constructor(e,t,r=[]){Array.isArray(r)?super(te,e,r):(super(te,e,r.activities),r.routine.forEach(i=>{let n=typeof i=="string"?i:i.id;fixedCommitments.set(n,e);})),this._location=t;}get routine(){return routine.roomCommitments[this.id]||[]}addCommitment(e,t={}){let{timeSlot:r,dateScheduling:i}=t;if(r&&!Array.isArray(r)&&(r=[r]),r?.forEach(n=>{let{to:a=timeTracker.dayEndTime+1}=n||{};if(n&&n.from>=a)throw o.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.")}),i?.from!==void 0&&i?.to!==void 0&&i?.from>=i?.to)throw o.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:r,dateScheduling:i});}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 r=async i=>{await t.run(i);};e.push(r);}return e},[])}};var E=class extends S{constructor(e,t,r={}){super(e,t,{activities:r.activities||[],routine:r.routine||[]}),this.defaultName=r.name||"",this._image=r.image,this.defaultDisabled=r.disabled||false,this.defaultHidden=r.hidden||false,this._icon=r.icon;}defaultName;get name(){return this.getStorageProperty("name")||this.defaultName}set name(e){this.setStorageProperty("name",e);}_image;get image(){return this._image}defaultDisabled;get disabled(){let e=this.getStorageProperty("disabled")||this.defaultDisabled;return typeof e=="string"?storage.getFlag(e):e}set disabled(e){this.setStorageProperty("disabled",e);}defaultHidden;get hidden(){let e=this.getStorageProperty("hidden")||this.defaultHidden;return typeof e=="string"?storage.getFlag(e):e}set hidden(e){this.setStorageProperty("hidden",e);}_icon;get icon(){return this._icon}};var Ae="__nqtr-quest__",v=class extends StoredClassModel{constructor(t,r,i={}){super(Ae,t);this._stages=r;this._onStart=i.onStart,this._onContinue=i.onContinue||i.onNextStage;}_stages;get stages(){return this._stages}get currentStageIndex(){return this.getStorageProperty("currentStageIndex")}set currentStageIndex(t){this.setStorageProperty("currentStageIndex",t);}get currentStage(){let t=this.currentStageIndex;if(!(t===void 0||t>=this.stages.length))return this.stages[t]}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(t){this.setStorageProperty("failed",t);}_onStart;get onStart(){return this._onStart}_onContinue;get onContinue(){return this._onContinue}get onNextStage(){return this._onContinue}async start(t){if(this.started){console.warn(`[NQTR] Quest ${this.id} is already started`);return}if(this.stages.length===0){o.error(`Quest ${this.id} has no stages`);return}this.currentStageIndex=0;let r=this.currentStage;if(r?.start)return this.onStart&&await this.onStart(this,t),await r.start(t);o.error(`Quest ${this.id} has no start stage`);}async goNextIfCompleted(t){return await this.advanceIfCompleted(t)}async advanceIfCompleted(t){if(!this.inProgress)return false;let r=this.currentStage;return r?r.completed?await this.advanceUnconditionally(t):false:(o.error(`Quest ${this.id} has no current stage`),false)}async goNext(t){return await this.continue(t)}async continue(t){let r=this.currentStage;return r?(r.completed=true,await this.advanceUnconditionally(t)):(o.error(`Quest ${this.id} has no current stage`),false)}async forceGoNext(t){return await this.advanceUnconditionally(t)}async advanceUnconditionally(t){if(!this.inProgress)return console.warn(`[NQTR] Quest ${this.id} is not in progress`),false;let r=this.currentStage,i=this.currentStageIndex;if(!r||i===void 0)return o.error(`Quest ${this.id} has no current stage`),false;this.currentStageIndex=i+1,this.onContinue&&await this.onContinue(this,t),r?.onEnd&&await r.onEnd(r,t);let n=this.currentStage;return n&&(n.inizialize(),this.currentStageMustStart&&await this.startCurrentStage(t)),true}get currentStageMustStart(){let t=this.currentStage;return t?!t.started&&t.canStart&&!t.completed:false}async startCurrentStage(t){let r=this.currentStage;r&&this.currentStageMustStart?await r.start(t):console.warn(`[NQTR] Quest ${this.id} can't start the current stage`);}};var P=class extends v{constructor(e,t,r){super(e,t,{onStart:r.onStart,onContinue:r.onContinue||r.onNextStage}),this._name=r.name||"",this._description=r.description||"",this._icon=r.icon,this._image=r.image,this._inDevelopment=r.inDevelopment||false;}_name;get name(){return this._name}_description;get description(){return this._description}_icon;get icon(){return this._icon}_image;get image(){return this._image}_inDevelopment;get inDevelopment(){return this._inDevelopment}};var Ce="__nqtr-stage__",I=class extends StoredClassModel{constructor(e,t={}){super(Ce,e),this._onStart=t.onStart,this._onEnd=t.onEnd,this._deltaDateRequired=t.deltaDateRequired,this._questsRequired=t.questsRequired||[];}_onStart;get onStart(){return this._onStart}_onEnd;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`);}_deltaDateRequired;get deltaDateRequired(){return this._deltaDateRequired||0}_questsRequired;get questsRequired(){return this._questsRequired||[]}};var D=class extends I{constructor(e,t){super(e,{onStart:t.onStart,onEnd:t.onEnd,deltaDateRequired:t.deltaDateRequired,questsRequired:t.questsRequired}),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||"";}_name;get name(){return this._name}_description;get description(){return this._description}_adviceDescription;get adviceDescription(){return this._adviceDescription}_image;get image(){return this._image}_flags;get flags(){return this._flags}_flagsRequired;get flagsRequired(){return this._flagsRequired}_requestDescriptionToStart;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 ae={};var oe={};var G={};K(G,{navigator:()=>qe,questsNotebook:()=>Ne,routine:()=>Me,timeTracker:()=>Oe});var w=class{get rooms(){return RegisteredRooms.values()}get locations(){return RegisteredLocations.values()}get maps(){return RegisteredMaps.values()}get currentRoomId(){return storage.get(g)}get currentRoom(){let e=this.currentRoomId;if(!e){o.error("The current room has not yet been set");return}let t=RegisteredRooms.get(e);if(!t){o.error(`Current room ${e} not found`);return}return t}set currentRoom(e){if(typeof e!="string"&&(e=e.id),!RegisteredRooms.get(e)){o.error(`The room ${e} is not registered, so it can't be set as current room`);return}let r=storage.get(g);r!==e&&(R({type:"editroom",prev:r,value:e}),storage.set(g,e));}get currentLocation(){return this.currentRoom?.location}get currentMap(){return this.currentRoom?.location.map}clearExpiredActivities(){RegisteredRooms.values().forEach(e=>{e.clearExpiredActivities();});}};var O=class{get quests(){return RegisteredQuests.values()}get startedQuests(){return this.quests.filter(e=>e.started)}get inProgressQuests(){return this.quests.filter(e=>e.inProgress)}get completedQuests(){return this.quests.filter(e=>e.completed)}get failedQuests(){return this.quests.filter(e=>e.failed)}get notStartedQuests(){return this.quests.filter(e=>!e.started)}find(e){return RegisteredQuests.get(e)}async startsStageMustBeStarted(e){let t=this.quests.map(r=>r.currentStageMustStart?r.startCurrentStage(e):Promise.resolve());await Promise.all(t);}};var H="___nqtr-temporary_commitment___",q=class{get temporaryRoutine(){let e=storage.get(H);if(e){if(Array.isArray(e)){if(e.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 e}get commitmentsIds(){return [...fixedCommitments.keys(),...Object.keys(this.temporaryRoutine)]}add(e,t,r={}){Array.isArray(e)||(e=[e]);let i=this.temporaryRoutine;e.forEach(n=>{let a=typeof n=="string"?n:n.id;i[a]={id:a,roomId:t,...r};}),storage.set(H,i);}find(e){return RegisteredCommitments.get(e)}remove(e,t){typeof e!="string"&&(e=e.id);let r=this.temporaryRoutine;r[e]?(!t||r[e].roomId===t)&&delete r[e]:o.warn(`The commitment ${e} 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,r);}clearExpiredRoutine(){RegisteredCommitments.values().forEach(e=>{e.expired&&this.remove(e);});}get characterCommitments(){let e=this.temporaryRoutine;return this.commitmentsIds.reduce((t,r)=>{let i=RegisteredCommitments.get(r),n=e[r],a=n?.roomId||fixedCommitments.get(r);return a&&i?.isActive(n)&&(i.characters.length>0?i.characters.every(l=>!t[l.id]||i.priority>t[l.id][0].priority)&&i.characters.forEach(l=>{t[l.id]=[i,a];}):o.error(`The commitment ${i.id} has no characters assigned`)),t},{})}get currentRoutine(){return Object.values(this.characterCommitments).map(([e])=>e)}get roomCommitments(){return Object.values(this.characterCommitments).reduce((e,t)=>{let r=t[1];return e[r]||(e[r]=[]),e[r].push(t[0]),e},{})}getCommitmentByCharacter(e){let t=typeof e=="string"?e:e.id;return this.currentRoutine.find(r=>{if(r.characters.map(i=>i.id).includes(t))return r})}};var we={dayStartTime:0,dayEndTime:24,defaultTimeSpent:1,timeSlots:[],weekLength:7,weekendStartDay:6,getDayName:void 0},d=we;var M=class{initialize(e){let{dayStartTime:t=0,dayEndTime:r=24,defaultTimeSpent:i=1,timeSlots:n=[],weekLength:a=7,weekendStartDay:c=a-1,getDayName:l}=e;d.dayStartTime=t,d.dayEndTime=r,d.defaultTimeSpent=i,d.timeSlots=n,d.weekLength=a,c>=d.weekLength?console.warn(`[NQTR] Weekend start day should be less than week length ${a}, so will be ignored`):d.weekendStartDay=c,d.getDayName=l;}get dayStartTime(){return d.dayStartTime}get dayEndTime(){return d.dayEndTime}get defaultTimeSpent(){return d.defaultTimeSpent}get timeSlots(){return d.timeSlots}get weekLength(){return d.weekLength}get weekendStartDay(){return d.weekendStartDay}get getDayName(){return d.getDayName}get currentTime(){let e=storage.get(u)||{};return Object.hasOwn(e,"currentTime")&&typeof e.currentTime=="number"?e.currentTime:this.dayStartTime}set currentTime(e){let t=storage.get(u)||{},r={...t};typeof e=="number"?r.currentTime=e:delete r.currentTime,R({type:"edittime",prev:t,value:r}),storage.set(u,r);}get currentDate(){let e=storage.get(u)||{};return Object.hasOwn(e,"currentDate")&&typeof e.currentDate=="number"?e.currentDate:0}set currentDate(e){let t=storage.get(u)||{},r={...t};typeof e=="number"?r.currentDate=e:delete r.currentDate,R({type:"edittime",prev:t,value:r}),storage.set(u,r);}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 e=0;e<this.timeSlots.length;e++){let t=this.timeSlots[e];if(this.timeSlots.length>e+1&&this.nowIsBetween(t.startTime,this.timeSlots[e+1].startTime))return e}return this.timeSlots.length-1}increaseTime(e=this.defaultTimeSpent){let t=this.currentTime+e;return t>=this.dayEndTime&&(this.increaseDate(),t=this.dayStartTime+(t-this.dayEndTime)),this.currentTime=t,this.currentTime}increaseDate(e=1,t=this.dayStartTime){let r=this.currentDate+e;return this.currentDate=r,this.currentTime=t,this.currentDate}nowIsBetween(e,t){e===void 0&&(e=this.dayStartTime-1),t===void 0&&(t=this.dayEndTime+1);let r=this.currentTime;return e<t?r>=e&&r<t:r>=e||r<t}};var Oe=new M,qe=new w,Me=new q,Ne=new O;var Le={...$,...ae,...oe,handlers:G,registries:Qe},wr=Le;export{_ as ActivityBaseModel,m as ActivityStoredClass,A as CommitmentBaseModel,p as CommitmentStoredClass,b as LocationBaseModel,h as LocationStoredClass,C as MapBaseModel,y as MapStoredClass,P as QuestBaseModel,v as QuestStoredClass,E as RoomBaseModel,S as RoomStoredClass,D as StageBaseModel,I as StageStoredClass,wr as default};