@vestcards/shared 1.0.3 → 1.1.0

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.
package/dist/index.js CHANGED
@@ -1,7 +1,19 @@
1
- import { R as f, a as v, r as y, b as p } from "./fsrs-C8QUsZ5l.js";
2
- const c = ["not-reviewed", "card-updated", "demand-rejected", "card-removed"];
3
- var i = /* @__PURE__ */ ((a) => (a.Draft = "draft", a.Review = "to_review", a.Published = "published", a.Archived = "archived", a))(i || {});
4
- const s = [
1
+ import { R as W, a as y, r as v, b as g } from "./fsrs-sJJWxUiC.js";
2
+ import { c as o } from "./colors-G1GHbBJq.js";
3
+ const m = 9999;
4
+ function S({ data: e, error: r }, a) {
5
+ if (r) {
6
+ const t = r.value, i = t && typeof t == "object" && t !== null && "message" in t ? String(t.message) : a;
7
+ throw new Error(i || a);
8
+ }
9
+ if (!e || typeof e == "object" && "error" in e)
10
+ throw new Error(a);
11
+ return e;
12
+ }
13
+ var R = /* @__PURE__ */ ((e) => (e.Draft = "draft", e.Published = "published", e))(R || {});
14
+ const U = ["not-reviewed", "card-updated", "demand-rejected", "card-removed"];
15
+ var c = /* @__PURE__ */ ((e) => (e.Draft = "draft", e.Review = "to_review", e.Published = "published", e.Archived = "archived", e))(c || {});
16
+ const N = [
5
17
  "matemática",
6
18
  // azul
7
19
  "geografia",
@@ -28,7 +40,150 @@ const s = [
28
40
  // amarelo
29
41
  "inglês"
30
42
  // verde
31
- ], r = {
43
+ ];
44
+ var d = /* @__PURE__ */ ((e) => (e.Admin = "admin", e.Moderator = "moderator", e.User = "user", e))(d || {}), _ = /* @__PURE__ */ ((e) => (e.Owner = "owner", e.Admin = "admin", e.Member = "member", e))(_ || {}), D = /* @__PURE__ */ ((e) => (e.Premium = "premium", e))(D || {}), s = /* @__PURE__ */ ((e) => (e.Active = "active", e.Canceled = "canceled", e.Pending = "pending", e.Expired = "expired", e))(s || {});
45
+ const E = {
46
+ DECK: {
47
+ CREATE_OWN: "deck:create:own",
48
+ CREATE_PUBLIC: "deck:create:public",
49
+ READ_OWN: "deck:read:own",
50
+ READ_OTHERS: "deck:read:others",
51
+ READ_UNPUBLISHED: "deck:read:unpublished",
52
+ READ_FREE: "deck:read:free",
53
+ READ_PREMIUM: "deck:read:premium",
54
+ READ_PRIVATE: "deck:read:private",
55
+ UPDATE_OWN: "deck:update:own",
56
+ UPDATE_PUBLIC: "deck:update:public",
57
+ DELETE_OWN: "deck:delete:own",
58
+ DELETE_PUBLIC: "deck:delete:public"
59
+ },
60
+ CARD_DEMAND: {
61
+ READ_ALL: "card-demand:read:*",
62
+ CREATE: "card-demand:create",
63
+ ACTION: "card-demand:action"
64
+ },
65
+ USER: {
66
+ UPDATE_OWN: "user:update:own",
67
+ UPDATE_ALL: "user:update:*",
68
+ DELETE_OWN: "user:delete:own",
69
+ DELETE_ALL: "user:delete:*",
70
+ READ_OWN: "user:read:own",
71
+ READ_ALL: "user:read:*"
72
+ },
73
+ STATS: {
74
+ VIEW: "stats:view"
75
+ },
76
+ MEMBERSHIP: {
77
+ MANAGE: "membership:manage"
78
+ },
79
+ PLAN: {
80
+ CREATE: "plan:create",
81
+ UPDATE: "plan:update",
82
+ DELETE: "plan:delete"
83
+ },
84
+ BLOGPOST: {
85
+ CREATE: "blogpost:create",
86
+ UPDATE: "blogpost:update",
87
+ DELETE: "blogpost:delete"
88
+ },
89
+ VESTY: {
90
+ CHAT: "vesty:chat"
91
+ },
92
+ STUDY: {
93
+ READ: "study:read",
94
+ WRITE: "study:write"
95
+ },
96
+ LIBRARY: {
97
+ READ: "library:read",
98
+ WRITE: "library:write",
99
+ WRITE_PREMIUM: "library:write:premium"
100
+ },
101
+ ADMIN_PANEL: {
102
+ VIEW: "admin-panel:view"
103
+ }
104
+ }, p = {
105
+ DECK_CREATE_OWN: E.DECK.CREATE_OWN,
106
+ DECK_CREATE_PUBLIC: E.DECK.CREATE_PUBLIC,
107
+ DECK_READ_OWN: E.DECK.READ_OWN,
108
+ DECK_READ_OTHERS: E.DECK.READ_OTHERS,
109
+ DECK_READ_UNPUBLISHED: E.DECK.READ_UNPUBLISHED,
110
+ DECK_READ_FREE: E.DECK.READ_FREE,
111
+ DECK_READ_PREMIUM: E.DECK.READ_PREMIUM,
112
+ DECK_READ_PRIVATE: E.DECK.READ_PRIVATE,
113
+ DECK_UPDATE_OWN: E.DECK.UPDATE_OWN,
114
+ DECK_UPDATE_PUBLIC: E.DECK.UPDATE_PUBLIC,
115
+ DECK_DELETE_OWN: E.DECK.DELETE_OWN,
116
+ DECK_DELETE_PUBLIC: E.DECK.DELETE_PUBLIC,
117
+ CARD_DEMAND_READ_ALL: E.CARD_DEMAND.READ_ALL,
118
+ CARD_DEMAND_CREATE: E.CARD_DEMAND.CREATE,
119
+ CARD_DEMAND_ACTION: E.CARD_DEMAND.ACTION,
120
+ USER_UPDATE_OWN: E.USER.UPDATE_OWN,
121
+ USER_UPDATE_ALL: E.USER.UPDATE_ALL,
122
+ USER_DELETE_OWN: E.USER.DELETE_OWN,
123
+ USER_DELETE_ALL: E.USER.DELETE_ALL,
124
+ USER_READ_OWN: E.USER.READ_OWN,
125
+ USER_READ_ALL: E.USER.READ_ALL,
126
+ STATS_VIEW: E.STATS.VIEW,
127
+ MEMBERSHIP_MANAGE: E.MEMBERSHIP.MANAGE,
128
+ PLAN_CREATE: E.PLAN.CREATE,
129
+ PLAN_UPDATE: E.PLAN.UPDATE,
130
+ PLAN_DELETE: E.PLAN.DELETE,
131
+ BLOGPOST_CREATE: E.BLOGPOST.CREATE,
132
+ BLOGPOST_UPDATE: E.BLOGPOST.UPDATE,
133
+ BLOGPOST_DELETE: E.BLOGPOST.DELETE,
134
+ VESTY_CHAT: E.VESTY.CHAT,
135
+ STUDY_READ: E.STUDY.READ,
136
+ STUDY_WRITE: E.STUDY.WRITE,
137
+ LIBRARY_READ: E.LIBRARY.READ,
138
+ LIBRARY_WRITE: E.LIBRARY.WRITE,
139
+ LIBRARY_WRITE_PREMIUM: E.LIBRARY.WRITE_PREMIUM,
140
+ ADMIN_PANEL_VIEW: E.ADMIN_PANEL.VIEW
141
+ }, T = Object.values(E).flatMap((e) => Object.values(e)), u = {
142
+ [d.User]: [
143
+ "deck:read:free",
144
+ "deck:read:own",
145
+ "deck:delete:own",
146
+ "study:read",
147
+ "study:write",
148
+ "library:read",
149
+ "library:write",
150
+ "card-demand:create",
151
+ "user:update:own",
152
+ "user:delete:own",
153
+ "user:read:own"
154
+ ],
155
+ [d.Moderator]: [
156
+ "deck:read:free",
157
+ "deck:read:own",
158
+ "deck:read:premium",
159
+ "deck:read:private",
160
+ "deck:read:unpublished",
161
+ "deck:delete:own",
162
+ "card-demand:read:*",
163
+ "card-demand:create",
164
+ "card-demand:action",
165
+ "study:read",
166
+ "study:write",
167
+ "library:read",
168
+ "library:write",
169
+ "library:write:premium",
170
+ "user:update:own",
171
+ "user:delete:own",
172
+ "user:read:own",
173
+ "admin-panel:view"
174
+ ],
175
+ [d.Admin]: T
176
+ }, l = {
177
+ [D.Premium]: ["deck:create:own", "deck:update:own", "deck:read:premium", "stats:view", "vesty:chat", "library:write:premium"]
178
+ }, O = (e, r, a) => {
179
+ if (!r) return !1;
180
+ if (u[r].includes(e)) return !0;
181
+ for (const i of a ?? [])
182
+ if ((l[i] ?? []).includes(e)) return !0;
183
+ return !1;
184
+ };
185
+ var L = /* @__PURE__ */ ((e) => (e.Published = "published", e.Draft = "draft", e.Archived = "archived", e))(L || {});
186
+ const A = {
32
187
  história: "quaternary",
33
188
  geografia: "tertiary",
34
189
  matemática: "secondary",
@@ -43,7 +198,7 @@ const s = [
43
198
  artes: "tertiary",
44
199
  inglês: "quinary",
45
200
  default: "default"
46
- }, e = {
201
+ }, n = {
47
202
  matemática: "radical",
48
203
  gramática: "spell-check",
49
204
  literatura: "book-open",
@@ -58,22 +213,35 @@ const s = [
58
213
  artes: "palette",
59
214
  inglês: "languages",
60
215
  default: "graduation-cap"
61
- }, u = (a) => e[a] || e.default, l = (a) => r[a] || r.default;
62
- var t = /* @__PURE__ */ ((a) => (a.Admin = "admin", a.Moderator = "moderator", a.User = "user", a))(t || {}), o = /* @__PURE__ */ ((a) => (a.Owner = "owner", a.Admin = "admin", a.Member = "member", a))(o || {}), n = /* @__PURE__ */ ((a) => (a.Premium = "premium", a))(n || {}), d = /* @__PURE__ */ ((a) => (a.Active = "active", a.Canceled = "canceled", a.Pending = "pending", a.Expired = "expired", a))(d || {});
216
+ }, w = (e) => n[e] || n.default, P = (e) => A[e] || A.default, f = (e) => {
217
+ const r = P(e);
218
+ return o[r === "default" ? "gray" : r].DEFAULT;
219
+ };
63
220
  export {
64
- i as DeckStatus,
65
- n as Entitlement,
66
- d as MembershipStatus,
67
- o as OrganizationRole,
68
- f as ReviewRating,
69
- v as ReviewState,
70
- s as SUBJECTS,
71
- r as SUBJECT_COLORS,
72
- e as SUBJECT_ICONS,
73
- t as UserRole,
74
- c as cardDemandStatus,
75
- l as getSubjectColor,
76
- u as getSubjectIcon,
77
- y as reviewRatings,
78
- p as reviewStates
221
+ T as ALL_PERMISSIONS,
222
+ R as BlogPostStatus,
223
+ c as DeckStatus,
224
+ l as ENTITLEMENT_PERMISSIONS,
225
+ D as Entitlement,
226
+ L as EntranceExamProgramStatus,
227
+ s as MembershipStatus,
228
+ _ as OrganizationRole,
229
+ E as PERMISSIONS,
230
+ p as Permission,
231
+ u as ROLE_PERMISSIONS,
232
+ W as ReviewRating,
233
+ y as ReviewState,
234
+ N as SUBJECTS,
235
+ A as SUBJECT_COLORS,
236
+ n as SUBJECT_ICONS,
237
+ m as UNPAGINATED_SIZE,
238
+ d as UserRole,
239
+ U as cardDemandStatus,
240
+ f as getSubjectCSSColor,
241
+ P as getSubjectColor,
242
+ w as getSubjectIcon,
243
+ O as hasPermission,
244
+ v as reviewRatings,
245
+ g as reviewStates,
246
+ S as unwrapApiResponse
79
247
  };
@@ -1 +1 @@
1
- "use strict";var Ae=Object.defineProperty;var Ie=(t,e,i)=>e in t?Ae(t,e,{enumerable:!0,configurable:!0,writable:!0,value:i}):t[e]=i;var _=(t,e,i)=>Ie(t,typeof e!="symbol"?e+"":e,i);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const R=require("./fsrs-HJutnIWm.cjs");require("date-fns/locale");const Pe=require("date-fns");require("date-fns-tz");const fe=.9,Te=50,He=200,ke=10,je=10;var h=(t=>(t[t.New=0]="New",t[t.Learning=1]="Learning",t[t.Review=2]="Review",t[t.Relearning=3]="Relearning",t))(h||{}),l=(t=>(t[t.Manual=0]="Manual",t[t.Again=1]="Again",t[t.Hard=2]="Hard",t[t.Good=3]="Good",t[t.Easy=4]="Easy",t))(l||{});class d{static card(e){return{...e,state:d.state(e.state),due:d.time(e.due),last_review:e.last_review?d.time(e.last_review):void 0}}static rating(e){if(typeof e=="string"){const i=e.charAt(0).toUpperCase(),r=e.slice(1).toLowerCase(),s=l[`${i}${r}`];if(s===void 0)throw new Error(`Invalid rating:[${e}]`);return s}else if(typeof e=="number")return e;throw new Error(`Invalid rating:[${e}]`)}static state(e){if(typeof e=="string"){const i=e.charAt(0).toUpperCase(),r=e.slice(1).toLowerCase(),s=h[`${i}${r}`];if(s===void 0)throw new Error(`Invalid state:[${e}]`);return s}else if(typeof e=="number")return e;throw new Error(`Invalid state:[${e}]`)}static time(e){if(typeof e=="object"&&e instanceof Date)return e;if(typeof e=="string"){const i=Date.parse(e);if(isNaN(i))throw new Error(`Invalid date:[${e}]`);return new Date(i)}else if(typeof e=="number")return new Date(e);throw new Error(`Invalid date:[${e}]`)}static review_log(e){return{...e,due:d.time(e.due),rating:d.rating(e.rating),state:d.state(e.state),review:d.time(e.review)}}}Date.prototype.scheduler=function(t,e){return $e(this,t,e)},Date.prototype.diff=function(t,e){return Le(this,t,e)},Date.prototype.format=function(){return Ge(this)},Date.prototype.dueFormat=function(t,e,i){return Ue(this,t,e,i)};function $e(t,e,i){return new Date(i?d.time(t).getTime()+e*24*60*60*1e3:d.time(t).getTime()+e*60*1e3)}function Le(t,e,i){if(!t||!e)throw new Error("Invalid date");const r=d.time(t).getTime()-d.time(e).getTime();let s=0;switch(i){case"days":s=Math.floor(r/(1440*60*1e3));break;case"minutes":s=Math.floor(r/(60*1e3));break}return s}function Ge(t){const e=d.time(t),i=e.getFullYear(),r=e.getMonth()+1,s=e.getDate(),n=e.getHours(),a=e.getMinutes(),o=e.getSeconds();return`${i}-${D(r)}-${D(s)} ${D(n)}:${D(a)}:${D(o)}`}function D(t){return t<10?`0${t}`:`${t}`}const G=[60,60,24,31,12],U=["second","min","hour","day","month","year"];function Ue(t,e,i,r=U){t=d.time(t),e=d.time(e),r.length!==U.length&&(r=U);let s=t.getTime()-e.getTime(),n;for(s/=1e3,n=0;n<G.length&&!(s<G[n]);n++)s/=G[n];return`${Math.floor(s)}${i?r[n]:""}`}const he=Object.freeze([l.Again,l.Hard,l.Good,l.Easy]),qe=[{start:2.5,end:7,factor:.15},{start:7,end:20,factor:.1},{start:20,end:1/0,factor:.05}];function We(t,e,i){let r=1;for(const a of qe)r+=a.factor*Math.max(Math.min(t,a.end)-a.start,0);t=Math.min(t,i);let s=Math.max(2,Math.round(t-r));const n=Math.min(Math.round(t+r),i);return t>e&&(s=Math.max(s,e+1)),s=Math.min(s,n),{min_ivl:s,max_ivl:n}}function b(t,e,i){return Math.min(Math.max(t,e),i)}function Ye(t,e){const i=Date.UTC(t.getUTCFullYear(),t.getUTCMonth(),t.getUTCDate()),r=Date.UTC(e.getUTCFullYear(),e.getUTCMonth(),e.getUTCDate());return Math.floor((r-i)/864e5)}const Xe=.9,Ke=36500,Be=Object.freeze([.40255,1.18385,3.173,15.69105,7.1949,.5345,1.4604,.0046,1.54575,.1192,1.01925,1.9395,.11,.29605,2.2698,.2315,2.9898,.51655,.6621]),Ze=!1,Je=!0,g=.01,A=100,ie=Object.freeze([Object.freeze([g,A]),Object.freeze([g,A]),Object.freeze([g,A]),Object.freeze([g,A]),Object.freeze([1,10]),Object.freeze([.001,4]),Object.freeze([.001,4]),Object.freeze([.001,.75]),Object.freeze([0,4.5]),Object.freeze([0,.8]),Object.freeze([.001,3.5]),Object.freeze([.001,5]),Object.freeze([.001,.25]),Object.freeze([.001,.9]),Object.freeze([0,4]),Object.freeze([0,1]),Object.freeze([1,6]),Object.freeze([0,2]),Object.freeze([0,2])]),Y=t=>{let e=[...Be];return t!=null&&t.w&&(t.w.length===19?e=[...t.w]:t.w.length===17&&(e=t==null?void 0:t.w.concat([0,0]),e[4]=+(e[5]*2+e[4]).toFixed(8),e[5]=+(Math.log(e[5]*3+1)/3).toFixed(8),e[6]=+(e[6]+.5).toFixed(8),console.debug("[FSRS V5]auto fill w to 19 length"))),e=e.map((i,r)=>b(i,ie[r][0],ie[r][1])),{request_retention:(t==null?void 0:t.request_retention)||Xe,maximum_interval:(t==null?void 0:t.maximum_interval)||Ke,w:e,enable_fuzz:(t==null?void 0:t.enable_fuzz)??Ze,enable_short_term:(t==null?void 0:t.enable_short_term)??Je}};function P(t,e){const i={due:t?d.time(t):new Date,stability:0,difficulty:0,elapsed_days:0,scheduled_days:0,reps:0,lapses:0,state:h.New,last_review:void 0};return e&&typeof e=="function"?e(i):i}class Qe{constructor(e){_(this,"c");_(this,"s0");_(this,"s1");_(this,"s2");const i=Ve();this.c=1,this.s0=i(" "),this.s1=i(" "),this.s2=i(" "),e==null&&(e=+new Date),this.s0-=i(e),this.s0<0&&(this.s0+=1),this.s1-=i(e),this.s1<0&&(this.s1+=1),this.s2-=i(e),this.s2<0&&(this.s2+=1)}next(){const e=2091639*this.s0+this.c*23283064365386963e-26;return this.s0=this.s1,this.s1=this.s2,this.s2=e-(this.c=e|0),this.s2}set state(e){this.c=e.c,this.s0=e.s0,this.s1=e.s1,this.s2=e.s2}get state(){return{c:this.c,s0:this.s0,s1:this.s1,s2:this.s2}}}function Ve(){let t=4022871197;return function(e){e=String(e);for(let i=0;i<e.length;i++){t+=e.charCodeAt(i);let r=.02519603282416938*t;t=r>>>0,r-=t,r*=t,t=r>>>0,r-=t,t+=r*4294967296}return(t>>>0)*23283064365386963e-26}}function et(t){const e=new Qe(t),i=()=>e.next();return i.int32=()=>e.next()*4294967296|0,i.double=()=>i()+(i()*2097152|0)*11102230246251565e-32,i.state=()=>e.state,i.importState=r=>(e.state=r,i),i}const _e=-.5,ye=19/81;function tt(t,e){return+Math.pow(1+ye*t/e,_e).toFixed(8)}class it{constructor(e){_(this,"param");_(this,"intervalModifier");_(this,"_seed");_(this,"forgetting_curve",tt);this.param=new Proxy(Y(e),this.params_handler_proxy()),this.intervalModifier=this.calculate_interval_modifier(this.param.request_retention)}get interval_modifier(){return this.intervalModifier}set seed(e){this._seed=e}calculate_interval_modifier(e){if(e<=0||e>1)throw new Error("Requested retention rate should be in the range (0,1]");return+((Math.pow(e,1/_e)-1)/ye).toFixed(8)}get parameters(){return this.param}set parameters(e){this.update_parameters(e)}params_handler_proxy(){const e=this;return{set:function(i,r,s){return r==="request_retention"&&Number.isFinite(s)&&(e.intervalModifier=e.calculate_interval_modifier(Number(s))),Reflect.set(i,r,s),!0}}}update_parameters(e){const i=Y(e);for(const r in i)if(r in this.param){const s=r;this.param[s]=i[s]}}init_stability(e){return Math.max(this.param.w[e-1],.1)}init_difficulty(e){return this.constrain_difficulty(this.param.w[4]-Math.exp((e-1)*this.param.w[5])+1)}apply_fuzz(e,i){if(!this.param.enable_fuzz||e<2.5)return Math.round(e);const r=et(this._seed)(),{min_ivl:s,max_ivl:n}=We(e,i,this.param.maximum_interval);return Math.floor(r*(n-s+1)+s)}next_interval(e,i){const r=Math.min(Math.max(1,Math.round(e*this.intervalModifier)),this.param.maximum_interval);return this.apply_fuzz(r,i)}linear_damping(e,i){return+(e*(10-i)/9).toFixed(8)}next_difficulty(e,i){const r=-this.param.w[6]*(i-3),s=e+this.linear_damping(r,e);return this.constrain_difficulty(this.mean_reversion(this.init_difficulty(l.Easy),s))}constrain_difficulty(e){return Math.min(Math.max(+e.toFixed(8),1),10)}mean_reversion(e,i){return+(this.param.w[7]*e+(1-this.param.w[7])*i).toFixed(8)}next_recall_stability(e,i,r,s){const n=l.Hard===s?this.param.w[15]:1,a=l.Easy===s?this.param.w[16]:1;return+b(i*(1+Math.exp(this.param.w[8])*(11-e)*Math.pow(i,-this.param.w[9])*(Math.exp((1-r)*this.param.w[10])-1)*n*a),g,36500).toFixed(8)}next_forget_stability(e,i,r){return+b(this.param.w[11]*Math.pow(e,-this.param.w[12])*(Math.pow(i+1,this.param.w[13])-1)*Math.exp((1-r)*this.param.w[14]),g,36500).toFixed(8)}next_short_term_stability(e,i){return+b(e*Math.exp(this.param.w[17]*(i-3+this.param.w[18])),g,36500).toFixed(8)}next_state(e,i,r){const{difficulty:s,stability:n}=e??{difficulty:0,stability:0};if(i<0)throw new Error(`Invalid delta_t "${i}"`);if(r<0||r>4)throw new Error(`Invalid grade "${r}"`);if(s===0&&n===0)return{difficulty:this.init_difficulty(r),stability:this.init_stability(r)};if(r===0)return{difficulty:s,stability:n};if(s<1||n<g)throw new Error(`Invalid memory state { difficulty: ${s}, stability: ${n} }`);const a=this.forgetting_curve(i,n),o=this.next_recall_stability(s,n,a,r),c=this.next_forget_stability(s,n,a),u=this.next_short_term_stability(n,r);let f=o;if(r===1){let[y,p]=[0,0];this.param.enable_short_term&&(y=this.param.w[17],p=this.param.w[18]);const E=n/Math.exp(y*p);f=b(+E.toFixed(8),g,c)}return i===0&&this.param.enable_short_term&&(f=u),{difficulty:this.next_difficulty(s,r),stability:f}}}function me(){const t=this.review_time.getTime(),e=this.current.reps,i=this.current.difficulty*this.current.stability;return`${t}_${e}_${i}`}var X=(t=>(t.SCHEDULER="Scheduler",t.SEED="Seed",t))(X||{});class we{constructor(e,i,r,s={seed:me}){_(this,"last");_(this,"current");_(this,"review_time");_(this,"next",new Map);_(this,"algorithm");_(this,"initSeedStrategy");this.algorithm=r,this.initSeedStrategy=s.seed.bind(this),this.last=d.card(e),this.current=d.card(e),this.review_time=d.time(i),this.init()}init(){const{state:e,last_review:i}=this.current;let r=0;e!==h.New&&i&&(r=Ye(i,this.review_time)),this.current.last_review=this.review_time,this.current.elapsed_days=r,this.current.reps+=1,this.algorithm.seed=this.initSeedStrategy()}preview(){return{[l.Again]:this.review(l.Again),[l.Hard]:this.review(l.Hard),[l.Good]:this.review(l.Good),[l.Easy]:this.review(l.Easy),[Symbol.iterator]:this.previewIterator.bind(this)}}*previewIterator(){for(const e of he)yield this.review(e)}review(e){const{state:i}=this.last;let r;switch(i){case h.New:r=this.newState(e);break;case h.Learning:case h.Relearning:r=this.learningState(e);break;case h.Review:r=this.reviewState(e);break}if(r)return r;throw new Error("Invalid grade")}buildLog(e){const{last_review:i,due:r,elapsed_days:s}=this.last;return{rating:e,state:this.current.state,due:i||r,stability:this.current.stability,difficulty:this.current.difficulty,elapsed_days:this.current.elapsed_days,last_elapsed_days:s,scheduled_days:this.current.scheduled_days,review:this.review_time}}}class re extends we{newState(e){const i=this.next.get(e);if(i)return i;const r=d.card(this.current);switch(r.difficulty=this.algorithm.init_difficulty(e),r.stability=this.algorithm.init_stability(e),e){case l.Again:r.scheduled_days=0,r.due=this.review_time.scheduler(1),r.state=h.Learning;break;case l.Hard:r.scheduled_days=0,r.due=this.review_time.scheduler(5),r.state=h.Learning;break;case l.Good:r.scheduled_days=0,r.due=this.review_time.scheduler(10),r.state=h.Learning;break;case l.Easy:{const n=this.algorithm.next_interval(r.stability,this.current.elapsed_days);r.scheduled_days=n,r.due=this.review_time.scheduler(n,!0),r.state=h.Review;break}default:throw new Error("Invalid grade")}const s={card:r,log:this.buildLog(e)};return this.next.set(e,s),s}learningState(e){const i=this.next.get(e);if(i)return i;const{state:r,difficulty:s,stability:n}=this.last,a=d.card(this.current),o=this.current.elapsed_days;switch(a.difficulty=this.algorithm.next_difficulty(s,e),a.stability=this.algorithm.next_short_term_stability(n,e),e){case l.Again:{a.scheduled_days=0,a.due=this.review_time.scheduler(5,!1),a.state=r;break}case l.Hard:{a.scheduled_days=0,a.due=this.review_time.scheduler(10),a.state=r;break}case l.Good:{const u=this.algorithm.next_interval(a.stability,o);a.scheduled_days=u,a.due=this.review_time.scheduler(u,!0),a.state=h.Review;break}case l.Easy:{const u=this.algorithm.next_short_term_stability(n,l.Good),f=this.algorithm.next_interval(u,o),y=Math.max(this.algorithm.next_interval(a.stability,o),f+1);a.scheduled_days=y,a.due=this.review_time.scheduler(y,!0),a.state=h.Review;break}default:throw new Error("Invalid grade")}const c={card:a,log:this.buildLog(e)};return this.next.set(e,c),c}reviewState(e){const i=this.next.get(e);if(i)return i;const r=this.current.elapsed_days,{difficulty:s,stability:n}=this.last,a=this.algorithm.forgetting_curve(r,n),o=d.card(this.current),c=d.card(this.current),u=d.card(this.current),f=d.card(this.current);this.next_ds(o,c,u,f,s,n,a),this.next_interval(o,c,u,f,r),this.next_state(o,c,u,f),o.lapses+=1;const y={card:o,log:this.buildLog(l.Again)},p={card:c,log:super.buildLog(l.Hard)},E={card:u,log:super.buildLog(l.Good)},C={card:f,log:super.buildLog(l.Easy)};return this.next.set(l.Again,y),this.next.set(l.Hard,p),this.next.set(l.Good,E),this.next.set(l.Easy,C),this.next.get(e)}next_ds(e,i,r,s,n,a,o){e.difficulty=this.algorithm.next_difficulty(n,l.Again);const c=a/Math.exp(this.algorithm.parameters.w[17]*this.algorithm.parameters.w[18]),u=this.algorithm.next_forget_stability(n,a,o);e.stability=b(+c.toFixed(8),g,u),i.difficulty=this.algorithm.next_difficulty(n,l.Hard),i.stability=this.algorithm.next_recall_stability(n,a,o,l.Hard),r.difficulty=this.algorithm.next_difficulty(n,l.Good),r.stability=this.algorithm.next_recall_stability(n,a,o,l.Good),s.difficulty=this.algorithm.next_difficulty(n,l.Easy),s.stability=this.algorithm.next_recall_stability(n,a,o,l.Easy)}next_interval(e,i,r,s,n){let a,o;a=this.algorithm.next_interval(i.stability,n),o=this.algorithm.next_interval(r.stability,n),a=Math.min(a,o),o=Math.max(o,a+1);const c=Math.max(this.algorithm.next_interval(s.stability,n),o+1);e.scheduled_days=0,e.due=this.review_time.scheduler(5),i.scheduled_days=a,i.due=this.review_time.scheduler(a,!0),r.scheduled_days=o,r.due=this.review_time.scheduler(o,!0),s.scheduled_days=c,s.due=this.review_time.scheduler(c,!0)}next_state(e,i,r,s){e.state=h.Relearning,i.state=h.Review,r.state=h.Review,s.state=h.Review}}class se extends we{newState(e){const i=this.next.get(e);if(i)return i;this.current.scheduled_days=0,this.current.elapsed_days=0;const r=d.card(this.current),s=d.card(this.current),n=d.card(this.current),a=d.card(this.current);return this.init_ds(r,s,n,a),this.next_interval(r,s,n,a,0),this.next_state(r,s,n,a),this.update_next(r,s,n,a),this.next.get(e)}init_ds(e,i,r,s){e.difficulty=this.algorithm.init_difficulty(l.Again),e.stability=this.algorithm.init_stability(l.Again),i.difficulty=this.algorithm.init_difficulty(l.Hard),i.stability=this.algorithm.init_stability(l.Hard),r.difficulty=this.algorithm.init_difficulty(l.Good),r.stability=this.algorithm.init_stability(l.Good),s.difficulty=this.algorithm.init_difficulty(l.Easy),s.stability=this.algorithm.init_stability(l.Easy)}learningState(e){return this.reviewState(e)}reviewState(e){const i=this.next.get(e);if(i)return i;const r=this.current.elapsed_days,{difficulty:s,stability:n}=this.last,a=this.algorithm.forgetting_curve(r,n),o=d.card(this.current),c=d.card(this.current),u=d.card(this.current),f=d.card(this.current);return this.next_ds(o,c,u,f,s,n,a),this.next_interval(o,c,u,f,r),this.next_state(o,c,u,f),o.lapses+=1,this.update_next(o,c,u,f),this.next.get(e)}next_ds(e,i,r,s,n,a,o){e.difficulty=this.algorithm.next_difficulty(n,l.Again);const c=this.algorithm.next_forget_stability(n,a,o);e.stability=b(a,g,c),i.difficulty=this.algorithm.next_difficulty(n,l.Hard),i.stability=this.algorithm.next_recall_stability(n,a,o,l.Hard),r.difficulty=this.algorithm.next_difficulty(n,l.Good),r.stability=this.algorithm.next_recall_stability(n,a,o,l.Good),s.difficulty=this.algorithm.next_difficulty(n,l.Easy),s.stability=this.algorithm.next_recall_stability(n,a,o,l.Easy)}next_interval(e,i,r,s,n){let a,o,c,u;a=this.algorithm.next_interval(e.stability,n),o=this.algorithm.next_interval(i.stability,n),c=this.algorithm.next_interval(r.stability,n),u=this.algorithm.next_interval(s.stability,n),a=Math.min(a,o),o=Math.max(o,a+1),c=Math.max(c,o+1),u=Math.max(u,c+1),e.scheduled_days=a,e.due=this.review_time.scheduler(a,!0),i.scheduled_days=o,i.due=this.review_time.scheduler(o,!0),r.scheduled_days=c,r.due=this.review_time.scheduler(c,!0),s.scheduled_days=u,s.due=this.review_time.scheduler(u,!0)}next_state(e,i,r,s){e.state=h.Review,i.state=h.Review,r.state=h.Review,s.state=h.Review}update_next(e,i,r,s){const n={card:e,log:this.buildLog(l.Again)},a={card:i,log:super.buildLog(l.Hard)},o={card:r,log:super.buildLog(l.Good)},c={card:s,log:super.buildLog(l.Easy)};this.next.set(l.Again,n),this.next.set(l.Hard,a),this.next.set(l.Good,o),this.next.set(l.Easy,c)}}class rt{constructor(e){_(this,"fsrs");this.fsrs=e}replay(e,i,r){return this.fsrs.next(e,i,r)}handleManualRating(e,i,r,s,n,a,o){if(typeof i>"u")throw new Error("reschedule: state is required for manual rating");let c,u;if(i===h.New)c={rating:l.Manual,state:i,due:o??r,stability:e.stability,difficulty:e.difficulty,elapsed_days:s,last_elapsed_days:e.elapsed_days,scheduled_days:e.scheduled_days,review:r},u=P(r),u.last_review=r;else{if(typeof o>"u")throw new Error("reschedule: due is required for manual rating");const f=o.diff(r,"days");c={rating:l.Manual,state:e.state,due:e.last_review||e.due,stability:e.stability,difficulty:e.difficulty,elapsed_days:s,last_elapsed_days:e.elapsed_days,scheduled_days:e.scheduled_days,review:r},u={...e,state:i,due:o,last_review:r,stability:n||e.stability,difficulty:a||e.difficulty,elapsed_days:s,scheduled_days:f,reps:e.reps+1}}return{card:u,log:c}}reschedule(e,i){const r=[];let s=P(e.due);for(const n of i){let a;if(n.review=d.time(n.review),n.rating===l.Manual){let o=0;s.state!==h.New&&s.last_review&&(o=n.review.diff(s.last_review,"days")),a=this.handleManualRating(s,n.state,n.review,o,n.stability,n.difficulty,n.due?d.time(n.due):void 0)}else a=this.replay(s,n.review,n.rating);r.push(a),s=a.card}return r}calculateManualRecord(e,i,r,s){if(!r)return null;const{card:n,log:a}=r,o=d.card(e);return o.due.getTime()===n.due.getTime()?null:(o.scheduled_days=n.due.diff(o.due,"days"),this.handleManualRating(o,n.state,d.time(i),a.elapsed_days,s?n.stability:void 0,s?n.difficulty:void 0,n.due))}}class st extends it{constructor(i){super(i);_(this,"strategyHandler",new Map);_(this,"Scheduler");const{enable_short_term:r}=this.parameters;this.Scheduler=r?re:se}params_handler_proxy(){const i=this;return{set:function(r,s,n){return s==="request_retention"&&Number.isFinite(n)?i.intervalModifier=i.calculate_interval_modifier(Number(n)):s==="enable_short_term"&&(i.Scheduler=n===!0?re:se),Reflect.set(r,s,n),!0}}}useStrategy(i,r){return this.strategyHandler.set(i,r),this}clearStrategy(i){return i?this.strategyHandler.delete(i):this.strategyHandler.clear(),this}getScheduler(i,r){const s=this.strategyHandler.get(X.SEED),n=this.strategyHandler.get(X.SCHEDULER)||this.Scheduler,a=s||me;return new n(i,r,this,{seed:a})}repeat(i,r,s){const n=this.getScheduler(i,r).preview();return s&&typeof s=="function"?s(n):n}next(i,r,s,n){const a=this.getScheduler(i,r),o=d.rating(s);if(o===l.Manual)throw new Error("Cannot review a manual rating");const c=a.review(o);return n&&typeof n=="function"?n(c):c}get_retrievability(i,r,s=!0){const n=d.card(i);r=r?d.time(r):new Date;const a=n.state!==h.New?Math.max(r.diff(n.last_review,"days"),0):0,o=n.state!==h.New?this.forgetting_curve(a,+n.stability.toFixed(8)):0;return s?`${(o*100).toFixed(2)}%`:o}rollback(i,r,s){const n=d.card(i),a=d.review_log(r);if(a.rating===l.Manual)throw new Error("Cannot rollback a manual rating");let o,c,u;switch(a.state){case h.New:o=a.due,c=void 0,u=0;break;case h.Learning:case h.Relearning:case h.Review:o=a.review,c=a.due,u=n.lapses-(a.rating===l.Again&&a.state===h.Review?1:0);break}const f={...n,due:o,stability:a.stability,difficulty:a.difficulty,elapsed_days:a.last_elapsed_days,scheduled_days:a.scheduled_days,reps:Math.max(0,n.reps-1),lapses:Math.max(0,u),state:a.state,last_review:c};return s&&typeof s=="function"?s(f):f}forget(i,r,s=!1,n){const a=d.card(i);r=d.time(r);const o=a.state===h.New?0:r.diff(a.last_review,"days"),c={rating:l.Manual,state:a.state,due:a.due,stability:a.stability,difficulty:a.difficulty,elapsed_days:0,last_elapsed_days:a.elapsed_days,scheduled_days:o,review:r},u={card:{...a,due:r,stability:0,difficulty:0,elapsed_days:0,scheduled_days:0,reps:s?0:a.reps,lapses:s?0:a.lapses,state:h.New,last_review:a.last_review},log:c};return n&&typeof n=="function"?n(u):u}reschedule(i,r=[],s={}){const{recordLogHandler:n,reviewsOrderBy:a,skipManual:o=!0,now:c=new Date,update_memory_state:u=!1}=s;a&&typeof a=="function"&&r.sort(a),o&&(r=r.filter(Ne=>Ne.rating!==l.Manual));const f=new rt(this),y=f.reschedule(s.first_card||P(),r),p=y.length,E=d.card(i),C=f.calculateManualRecord(E,c,p?y[p-1]:void 0,u);return n&&typeof n=="function"?{collections:y.map(n),reschedule_item:C?n(C):null}:{collections:y,reschedule_item:C}}}const nt=t=>new st(t||{}),at=Y({request_retention:fe,enable_fuzz:!0,maximum_interval:100}),ge=nt(at),pe=t=>t.due?t:{...t,due:new Date},ot=t=>R.reviewStates.indexOf(t),ve=t=>({due:t.due,stability:t.stability,difficulty:t.difficulty,elapsed_days:t.elapsedDays,scheduled_days:t.scheduledDays,reps:t.reps,lapses:t.lapses,state:ot(t.state),last_review:t.lastReview}),be=(t,e,i)=>{const r=new Date,s=ve(pe(t));return ge.repeat(s,r,a=>{const o=ut(e),c=a[o],u=Se(c.card,t),f=c.log,y={id:0,cardReviewId:t.id,grade:e,state:xe(f.state),due:f.due,stability:f.stability,difficulty:f.difficulty,elapsedDays:f.elapsed_days,lastElapsedDays:f.last_elapsed_days,scheduledDays:f.scheduled_days,review:f.review,duration:i};return{nextCard:u,reviewLog:y}})};function lt(t){const e=new Date,i=ve(pe(t)),r=ge.repeat(i,e),s=Object.fromEntries(R.reviewRatings.map(n=>[n,new Date]));for(const n of he){const a=r[n].card.due,o=ct(n);s[o]=a}return s}function ct(t){return R.reviewRatings[t]}function xe(t){return R.reviewStates[t]}function Se(t,e){return{...e,due:t.due,stability:t.stability,difficulty:t.difficulty,elapsedDays:t.elapsed_days,scheduledDays:t.scheduled_days,reps:t.reps,lapses:t.lapses,state:xe(t.state),lastReview:t.last_review??null}}function ut(t){const e=R.reviewRatings.indexOf(t);if(e===-1)throw new Error(`Invalid rating: ${t}`);return e}function dt(t,e){const i=P();return{id:"",due:null,stability:i.stability,difficulty:i.difficulty,elapsedDays:i.elapsed_days,scheduledDays:i.scheduled_days,reps:i.reps,lapses:i.lapses,state:R.ReviewState.New,lastReview:i.last_review??null,userDeckStudyId:t,cardId:e}}var Me=Symbol.for("immer-nothing"),ne=Symbol.for("immer-draftable"),w=Symbol.for("immer-state"),ft=process.env.NODE_ENV!=="production"?[function(t){return`The plugin for '${t}' has not been loaded into Immer. To enable the plugin, import and call \`enable${t}()\` when initializing your application.`},function(t){return`produce can only be called on things that are draftable: plain objects, arrays, Map, Set or classes that are marked with '[immerable]: true'. Got '${t}'`},"This object has been frozen and should not be mutated",function(t){return"Cannot use a proxy that has been revoked. Did you pass an object from inside an immer function to an async process? "+t},"An immer producer returned a new value *and* modified its draft. Either return a new value *or* modify the draft.","Immer forbids circular references","The first or second argument to `produce` must be a function","The third argument to `produce` must be a function or undefined","First argument to `createDraft` must be a plain object, an array, or an immerable object","First argument to `finishDraft` must be a draft returned by `createDraft`",function(t){return`'current' expects a draft, got: ${t}`},"Object.defineProperty() cannot be used on an Immer draft","Object.setPrototypeOf() cannot be used on an Immer draft","Immer only supports deleting array indices","Immer only supports setting array indices and the 'length' property",function(t){return`'original' expects a draft, got: ${t}`}]:[];function m(t,...e){if(process.env.NODE_ENV!=="production"){const i=ft[t],r=typeof i=="function"?i.apply(null,e):i;throw new Error(`[Immer] ${r}`)}throw new Error(`[Immer] minified error nr: ${t}. Full error at: https://bit.ly/3cXEKWf`)}var F=Object.getPrototypeOf;function M(t){return!!t&&!!t[w]}function x(t){var e;return t?Re(t)||Array.isArray(t)||!!t[ne]||!!((e=t.constructor)!=null&&e[ne])||N(t)||$(t):!1}var ht=Object.prototype.constructor.toString(),ae=new WeakMap;function Re(t){if(!t||typeof t!="object")return!1;const e=Object.getPrototypeOf(t);if(e===null||e===Object.prototype)return!0;const i=Object.hasOwnProperty.call(e,"constructor")&&e.constructor;if(i===Object)return!0;if(typeof i!="function")return!1;let r=ae.get(i);return r===void 0&&(r=Function.toString.call(i),ae.set(i,r)),r===ht}function T(t,e,i=!0){j(t)===0?(i?Reflect.ownKeys(t):Object.keys(t)).forEach(s=>{e(s,t[s],t)}):t.forEach((r,s)=>e(s,r,t))}function j(t){const e=t[w];return e?e.type_:Array.isArray(t)?1:N(t)?2:$(t)?3:0}function K(t,e){return j(t)===2?t.has(e):Object.prototype.hasOwnProperty.call(t,e)}function Ee(t,e,i){const r=j(t);r===2?t.set(e,i):r===3?t.add(i):t[e]=i}function _t(t,e){return t===e?t!==0||1/t===1/e:t!==t&&e!==e}function N(t){return t instanceof Map}function $(t){return t instanceof Set}function v(t){return t.copy_||t.base_}function B(t,e){if(N(t))return new Map(t);if($(t))return new Set(t);if(Array.isArray(t))return Array.prototype.slice.call(t);const i=Re(t);if(e===!0||e==="class_only"&&!i){const r=Object.getOwnPropertyDescriptors(t);delete r[w];let s=Reflect.ownKeys(r);for(let n=0;n<s.length;n++){const a=s[n],o=r[a];o.writable===!1&&(o.writable=!0,o.configurable=!0),(o.get||o.set)&&(r[a]={configurable:!0,writable:!0,enumerable:o.enumerable,value:t[a]})}return Object.create(F(t),r)}else{const r=F(t);if(r!==null&&i)return{...t};const s=Object.create(r);return Object.assign(s,t)}}function ee(t,e=!1){return L(t)||M(t)||!x(t)||(j(t)>1&&Object.defineProperties(t,{set:I,add:I,clear:I,delete:I}),Object.freeze(t),e&&Object.values(t).forEach(i=>ee(i,!0))),t}function yt(){m(2)}var I={value:yt};function L(t){return t===null||typeof t!="object"?!0:Object.isFrozen(t)}var mt={};function S(t){const e=mt[t];return e||m(0,t),e}var z;function Ce(){return z}function wt(t,e){return{drafts_:[],parent_:t,immer_:e,canAutoFreeze_:!0,unfinalizedDrafts_:0}}function oe(t,e){e&&(S("Patches"),t.patches_=[],t.inversePatches_=[],t.patchListener_=e)}function Z(t){J(t),t.drafts_.forEach(gt),t.drafts_=null}function J(t){t===z&&(z=t.parent_)}function le(t){return z=wt(z,t)}function gt(t){const e=t[w];e.type_===0||e.type_===1?e.revoke_():e.revoked_=!0}function ce(t,e){e.unfinalizedDrafts_=e.drafts_.length;const i=e.drafts_[0];return t!==void 0&&t!==i?(i[w].modified_&&(Z(e),m(4)),x(t)&&(t=H(e,t),e.parent_||k(e,t)),e.patches_&&S("Patches").generateReplacementPatches_(i[w].base_,t,e.patches_,e.inversePatches_)):t=H(e,i,[]),Z(e),e.patches_&&e.patchListener_(e.patches_,e.inversePatches_),t!==Me?t:void 0}function H(t,e,i){if(L(e))return e;const r=t.immer_.shouldUseStrictIteration(),s=e[w];if(!s)return T(e,(n,a)=>ue(t,s,e,n,a,i),r),e;if(s.scope_!==t)return e;if(!s.modified_)return k(t,s.base_,!0),s.base_;if(!s.finalized_){s.finalized_=!0,s.scope_.unfinalizedDrafts_--;const n=s.copy_;let a=n,o=!1;s.type_===3&&(a=new Set(n),n.clear(),o=!0),T(a,(c,u)=>ue(t,s,n,c,u,i,o),r),k(t,n,!1),i&&t.patches_&&S("Patches").generatePatches_(s,i,t.patches_,t.inversePatches_)}return s.copy_}function ue(t,e,i,r,s,n,a){if(s==null||typeof s!="object"&&!a)return;const o=L(s);if(!(o&&!a)){if(process.env.NODE_ENV!=="production"&&s===i&&m(5),M(s)){const c=n&&e&&e.type_!==3&&!K(e.assigned_,r)?n.concat(r):void 0,u=H(t,s,c);if(Ee(i,r,u),M(u))t.canAutoFreeze_=!1;else return}else a&&i.add(s);if(x(s)&&!o){if(!t.immer_.autoFreeze_&&t.unfinalizedDrafts_<1||e&&e.base_&&e.base_[r]===s&&o)return;H(t,s),(!e||!e.scope_.parent_)&&typeof r!="symbol"&&(N(i)?i.has(r):Object.prototype.propertyIsEnumerable.call(i,r))&&k(t,s)}}}function k(t,e,i=!1){!t.parent_&&t.immer_.autoFreeze_&&t.canAutoFreeze_&&ee(e,i)}function pt(t,e){const i=Array.isArray(t),r={type_:i?1:0,scope_:e?e.scope_:Ce(),modified_:!1,finalized_:!1,assigned_:{},parent_:e,base_:t,draft_:null,copy_:null,revoke_:null,isManual_:!1};let s=r,n=te;i&&(s=[r],n=O);const{revoke:a,proxy:o}=Proxy.revocable(s,n);return r.draft_=o,r.revoke_=a,o}var te={get(t,e){if(e===w)return t;const i=v(t);if(!K(i,e))return vt(t,i,e);const r=i[e];return t.finalized_||!x(r)?r:r===q(t.base_,e)?(W(t),t.copy_[e]=V(r,t)):r},has(t,e){return e in v(t)},ownKeys(t){return Reflect.ownKeys(v(t))},set(t,e,i){const r=De(v(t),e);if(r!=null&&r.set)return r.set.call(t.draft_,i),!0;if(!t.modified_){const s=q(v(t),e),n=s==null?void 0:s[w];if(n&&n.base_===i)return t.copy_[e]=i,t.assigned_[e]=!1,!0;if(_t(i,s)&&(i!==void 0||K(t.base_,e)))return!0;W(t),Q(t)}return t.copy_[e]===i&&(i!==void 0||e in t.copy_)||Number.isNaN(i)&&Number.isNaN(t.copy_[e])||(t.copy_[e]=i,t.assigned_[e]=!0),!0},deleteProperty(t,e){return q(t.base_,e)!==void 0||e in t.base_?(t.assigned_[e]=!1,W(t),Q(t)):delete t.assigned_[e],t.copy_&&delete t.copy_[e],!0},getOwnPropertyDescriptor(t,e){const i=v(t),r=Reflect.getOwnPropertyDescriptor(i,e);return r&&{writable:!0,configurable:t.type_!==1||e!=="length",enumerable:r.enumerable,value:i[e]}},defineProperty(){m(11)},getPrototypeOf(t){return F(t.base_)},setPrototypeOf(){m(12)}},O={};T(te,(t,e)=>{O[t]=function(){return arguments[0]=arguments[0][0],e.apply(this,arguments)}});O.deleteProperty=function(t,e){return process.env.NODE_ENV!=="production"&&isNaN(parseInt(e))&&m(13),O.set.call(this,t,e,void 0)};O.set=function(t,e,i){return process.env.NODE_ENV!=="production"&&e!=="length"&&isNaN(parseInt(e))&&m(14),te.set.call(this,t[0],e,i,t[0])};function q(t,e){const i=t[w];return(i?v(i):t)[e]}function vt(t,e,i){var s;const r=De(e,i);return r?"value"in r?r.value:(s=r.get)==null?void 0:s.call(t.draft_):void 0}function De(t,e){if(!(e in t))return;let i=F(t);for(;i;){const r=Object.getOwnPropertyDescriptor(i,e);if(r)return r;i=F(i)}}function Q(t){t.modified_||(t.modified_=!0,t.parent_&&Q(t.parent_))}function W(t){t.copy_||(t.copy_=B(t.base_,t.scope_.immer_.useStrictShallowCopy_))}var bt=class{constructor(t){this.autoFreeze_=!0,this.useStrictShallowCopy_=!1,this.useStrictIteration_=!0,this.produce=(e,i,r)=>{if(typeof e=="function"&&typeof i!="function"){const n=i;i=e;const a=this;return function(c=n,...u){return a.produce(c,f=>i.call(this,f,...u))}}typeof i!="function"&&m(6),r!==void 0&&typeof r!="function"&&m(7);let s;if(x(e)){const n=le(this),a=V(e,void 0);let o=!0;try{s=i(a),o=!1}finally{o?Z(n):J(n)}return oe(n,r),ce(s,n)}else if(!e||typeof e!="object"){if(s=i(e),s===void 0&&(s=e),s===Me&&(s=void 0),this.autoFreeze_&&ee(s,!0),r){const n=[],a=[];S("Patches").generateReplacementPatches_(e,s,n,a),r(n,a)}return s}else m(1,e)},this.produceWithPatches=(e,i)=>{if(typeof e=="function")return(a,...o)=>this.produceWithPatches(a,c=>e(c,...o));let r,s;return[this.produce(e,i,(a,o)=>{r=a,s=o}),r,s]},typeof(t==null?void 0:t.autoFreeze)=="boolean"&&this.setAutoFreeze(t.autoFreeze),typeof(t==null?void 0:t.useStrictShallowCopy)=="boolean"&&this.setUseStrictShallowCopy(t.useStrictShallowCopy),typeof(t==null?void 0:t.useStrictIteration)=="boolean"&&this.setUseStrictIteration(t.useStrictIteration)}createDraft(t){x(t)||m(8),M(t)&&(t=xt(t));const e=le(this),i=V(t,void 0);return i[w].isManual_=!0,J(e),i}finishDraft(t,e){const i=t&&t[w];(!i||!i.isManual_)&&m(9);const{scope_:r}=i;return oe(r,e),ce(void 0,r)}setAutoFreeze(t){this.autoFreeze_=t}setUseStrictShallowCopy(t){this.useStrictShallowCopy_=t}setUseStrictIteration(t){this.useStrictIteration_=t}shouldUseStrictIteration(){return this.useStrictIteration_}applyPatches(t,e){let i;for(i=e.length-1;i>=0;i--){const s=e[i];if(s.path.length===0&&s.op==="replace"){t=s.value;break}}i>-1&&(e=e.slice(i+1));const r=S("Patches").applyPatches_;return M(t)?r(t,e):this.produce(t,s=>r(s,e))}};function V(t,e){const i=N(t)?S("MapSet").proxyMap_(t,e):$(t)?S("MapSet").proxySet_(t,e):pt(t,e);return(e?e.scope_:Ce()).drafts_.push(i),i}function xt(t){return M(t)||m(10,t),Fe(t)}function Fe(t){if(!x(t)||L(t))return t;const e=t[w];let i,r=!0;if(e){if(!e.modified_)return e.base_;e.finalized_=!0,i=B(t,e.scope_.immer_.useStrictShallowCopy_),r=e.scope_.immer_.shouldUseStrictIteration()}else i=B(t,!0);return T(i,(s,n)=>{Ee(i,s,Fe(n))},r),e&&(e.finalized_=!1),i}var St=new bt,Mt=St.produce;function Rt(t,e){const i=t+e;let r=0;for(let s=0;s<i.length;s++){const n=i.charCodeAt(s);r=(r<<5)-r+n,r|=0}return r}function Et(t,e){return(Rt(t,e)>>>0)/4294967295}function Ct(t,e=new Set){if(t.reviewCards.length===0&&t.newCards.length===0)return;if(t.reviewCards.length===0)return t.newCards[0];if(t.newCards.length===0)return t.reviewCards[0];const i=de(t.newCards,e),r=de(t.reviewCards,e);if(!i)return r??t.newCards[0];if(!r)return i??t.reviewCards[0];const s=t.newCards.length,n=t.reviewCards.length,a=s+n,o=.33,c=s/a,u=(o+c)/2;return Et(i.card.id,r.card.id)<u?i:r}function de(t,e){return t.find(i=>!e.has(i.card.id))}function Dt(t,e,i){const r=Oe(e,i);if(!r)return e;const{nextCard:s}=be(r.cardReview,t,30),n=s.due&&Pe.isSameDay(s.due,new Date);return Mt(e,a=>{if(Ft(a,r),n){const o={...r,cardReview:s};zt(a,o)}})}function Ft(t,e){e.cardReview.state==="New"?t.newCards=t.newCards.filter(i=>i.card.id!==e.card.id):t.reviewCards=t.reviewCards.filter(i=>i.card.id!==e.card.id),ze(t,e.cardReview.state,"decrease")}function zt(t,e){if(e.cardReview.state==="New"){const i=t.newCards.findIndex(r=>r.cardReview.due&&e.cardReview.due&&r.cardReview.due>=e.cardReview.due||r.cardReview.difficulty>=e.cardReview.difficulty);i===-1?t.newCards.push(e):t.newCards.splice(i,0,e)}else{const i=Ot(t,t.reviewCards);t.reviewCards.splice(i,0,e)}ze(t,e.cardReview.state,"increase")}function ze(t,e,i){const r=i==="increase"?1:-1;switch(e){case"New":t.stats.new+=r;break;case"Learning":case"Relearning":t.stats.learning+=r;break;case"Review":t.stats.review+=r;break;default:t.stats.new+=r;break}t.stats.total+=r}function Oe(t,e){return t.newCards.find(i=>i.card.id===e)??t.reviewCards.find(i=>i.card.id===e)}function Ot(t,e){if(e.length===0)return 0;const i=Math.max(4,Math.floor(e.length/3));return Math.min(i,e.length)}exports.FSRS_RETENTION=fe;exports.MAX_CARDS_TO_FETCH=Te;exports.MAX_LEARN_PER_DAY=He;exports.MAX_NEW_PER_DECK_DAY=ke;exports.THRESHOLD_CARDS_FOR_REFETCH=je;exports.getNextCardFromSession=Ct;exports.getReviewDateForEachRating=lt;exports.getSessionCard=Oe;exports.gradeCard=be;exports.mergeFsrsCard=Se;exports.newCardReview=dt;exports.removeCardFromSessionData=Dt;
1
+ "use strict";var Ae=Object.defineProperty;var Ie=(t,e,i)=>e in t?Ae(t,e,{enumerable:!0,configurable:!0,writable:!0,value:i}):t[e]=i;var _=(t,e,i)=>Ie(t,typeof e!="symbol"?e+"":e,i);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const R=require("./fsrs-DEA3eLGO.cjs");require("date-fns/locale");const Pe=require("date-fns");require("date-fns-tz");const fe=.9,Te=50,He=200,ke=10,je=10;var h=(t=>(t[t.New=0]="New",t[t.Learning=1]="Learning",t[t.Review=2]="Review",t[t.Relearning=3]="Relearning",t))(h||{}),l=(t=>(t[t.Manual=0]="Manual",t[t.Again=1]="Again",t[t.Hard=2]="Hard",t[t.Good=3]="Good",t[t.Easy=4]="Easy",t))(l||{});class d{static card(e){return{...e,state:d.state(e.state),due:d.time(e.due),last_review:e.last_review?d.time(e.last_review):void 0}}static rating(e){if(typeof e=="string"){const i=e.charAt(0).toUpperCase(),r=e.slice(1).toLowerCase(),s=l[`${i}${r}`];if(s===void 0)throw new Error(`Invalid rating:[${e}]`);return s}else if(typeof e=="number")return e;throw new Error(`Invalid rating:[${e}]`)}static state(e){if(typeof e=="string"){const i=e.charAt(0).toUpperCase(),r=e.slice(1).toLowerCase(),s=h[`${i}${r}`];if(s===void 0)throw new Error(`Invalid state:[${e}]`);return s}else if(typeof e=="number")return e;throw new Error(`Invalid state:[${e}]`)}static time(e){if(typeof e=="object"&&e instanceof Date)return e;if(typeof e=="string"){const i=Date.parse(e);if(isNaN(i))throw new Error(`Invalid date:[${e}]`);return new Date(i)}else if(typeof e=="number")return new Date(e);throw new Error(`Invalid date:[${e}]`)}static review_log(e){return{...e,due:d.time(e.due),rating:d.rating(e.rating),state:d.state(e.state),review:d.time(e.review)}}}Date.prototype.scheduler=function(t,e){return $e(this,t,e)},Date.prototype.diff=function(t,e){return Le(this,t,e)},Date.prototype.format=function(){return Ge(this)},Date.prototype.dueFormat=function(t,e,i){return Ue(this,t,e,i)};function $e(t,e,i){return new Date(i?d.time(t).getTime()+e*24*60*60*1e3:d.time(t).getTime()+e*60*1e3)}function Le(t,e,i){if(!t||!e)throw new Error("Invalid date");const r=d.time(t).getTime()-d.time(e).getTime();let s=0;switch(i){case"days":s=Math.floor(r/(1440*60*1e3));break;case"minutes":s=Math.floor(r/(60*1e3));break}return s}function Ge(t){const e=d.time(t),i=e.getFullYear(),r=e.getMonth()+1,s=e.getDate(),n=e.getHours(),a=e.getMinutes(),o=e.getSeconds();return`${i}-${D(r)}-${D(s)} ${D(n)}:${D(a)}:${D(o)}`}function D(t){return t<10?`0${t}`:`${t}`}const G=[60,60,24,31,12],U=["second","min","hour","day","month","year"];function Ue(t,e,i,r=U){t=d.time(t),e=d.time(e),r.length!==U.length&&(r=U);let s=t.getTime()-e.getTime(),n;for(s/=1e3,n=0;n<G.length&&!(s<G[n]);n++)s/=G[n];return`${Math.floor(s)}${i?r[n]:""}`}const he=Object.freeze([l.Again,l.Hard,l.Good,l.Easy]),qe=[{start:2.5,end:7,factor:.15},{start:7,end:20,factor:.1},{start:20,end:1/0,factor:.05}];function We(t,e,i){let r=1;for(const a of qe)r+=a.factor*Math.max(Math.min(t,a.end)-a.start,0);t=Math.min(t,i);let s=Math.max(2,Math.round(t-r));const n=Math.min(Math.round(t+r),i);return t>e&&(s=Math.max(s,e+1)),s=Math.min(s,n),{min_ivl:s,max_ivl:n}}function b(t,e,i){return Math.min(Math.max(t,e),i)}function Ye(t,e){const i=Date.UTC(t.getUTCFullYear(),t.getUTCMonth(),t.getUTCDate()),r=Date.UTC(e.getUTCFullYear(),e.getUTCMonth(),e.getUTCDate());return Math.floor((r-i)/864e5)}const Xe=.9,Ke=36500,Be=Object.freeze([.40255,1.18385,3.173,15.69105,7.1949,.5345,1.4604,.0046,1.54575,.1192,1.01925,1.9395,.11,.29605,2.2698,.2315,2.9898,.51655,.6621]),Ze=!1,Je=!0,g=.01,A=100,ie=Object.freeze([Object.freeze([g,A]),Object.freeze([g,A]),Object.freeze([g,A]),Object.freeze([g,A]),Object.freeze([1,10]),Object.freeze([.001,4]),Object.freeze([.001,4]),Object.freeze([.001,.75]),Object.freeze([0,4.5]),Object.freeze([0,.8]),Object.freeze([.001,3.5]),Object.freeze([.001,5]),Object.freeze([.001,.25]),Object.freeze([.001,.9]),Object.freeze([0,4]),Object.freeze([0,1]),Object.freeze([1,6]),Object.freeze([0,2]),Object.freeze([0,2])]),Y=t=>{let e=[...Be];return t!=null&&t.w&&(t.w.length===19?e=[...t.w]:t.w.length===17&&(e=t==null?void 0:t.w.concat([0,0]),e[4]=+(e[5]*2+e[4]).toFixed(8),e[5]=+(Math.log(e[5]*3+1)/3).toFixed(8),e[6]=+(e[6]+.5).toFixed(8),console.debug("[FSRS V5]auto fill w to 19 length"))),e=e.map((i,r)=>b(i,ie[r][0],ie[r][1])),{request_retention:(t==null?void 0:t.request_retention)||Xe,maximum_interval:(t==null?void 0:t.maximum_interval)||Ke,w:e,enable_fuzz:(t==null?void 0:t.enable_fuzz)??Ze,enable_short_term:(t==null?void 0:t.enable_short_term)??Je}};function P(t,e){const i={due:t?d.time(t):new Date,stability:0,difficulty:0,elapsed_days:0,scheduled_days:0,reps:0,lapses:0,state:h.New,last_review:void 0};return e&&typeof e=="function"?e(i):i}class Qe{constructor(e){_(this,"c");_(this,"s0");_(this,"s1");_(this,"s2");const i=Ve();this.c=1,this.s0=i(" "),this.s1=i(" "),this.s2=i(" "),e==null&&(e=+new Date),this.s0-=i(e),this.s0<0&&(this.s0+=1),this.s1-=i(e),this.s1<0&&(this.s1+=1),this.s2-=i(e),this.s2<0&&(this.s2+=1)}next(){const e=2091639*this.s0+this.c*23283064365386963e-26;return this.s0=this.s1,this.s1=this.s2,this.s2=e-(this.c=e|0),this.s2}set state(e){this.c=e.c,this.s0=e.s0,this.s1=e.s1,this.s2=e.s2}get state(){return{c:this.c,s0:this.s0,s1:this.s1,s2:this.s2}}}function Ve(){let t=4022871197;return function(e){e=String(e);for(let i=0;i<e.length;i++){t+=e.charCodeAt(i);let r=.02519603282416938*t;t=r>>>0,r-=t,r*=t,t=r>>>0,r-=t,t+=r*4294967296}return(t>>>0)*23283064365386963e-26}}function et(t){const e=new Qe(t),i=()=>e.next();return i.int32=()=>e.next()*4294967296|0,i.double=()=>i()+(i()*2097152|0)*11102230246251565e-32,i.state=()=>e.state,i.importState=r=>(e.state=r,i),i}const _e=-.5,ye=19/81;function tt(t,e){return+Math.pow(1+ye*t/e,_e).toFixed(8)}class it{constructor(e){_(this,"param");_(this,"intervalModifier");_(this,"_seed");_(this,"forgetting_curve",tt);this.param=new Proxy(Y(e),this.params_handler_proxy()),this.intervalModifier=this.calculate_interval_modifier(this.param.request_retention)}get interval_modifier(){return this.intervalModifier}set seed(e){this._seed=e}calculate_interval_modifier(e){if(e<=0||e>1)throw new Error("Requested retention rate should be in the range (0,1]");return+((Math.pow(e,1/_e)-1)/ye).toFixed(8)}get parameters(){return this.param}set parameters(e){this.update_parameters(e)}params_handler_proxy(){const e=this;return{set:function(i,r,s){return r==="request_retention"&&Number.isFinite(s)&&(e.intervalModifier=e.calculate_interval_modifier(Number(s))),Reflect.set(i,r,s),!0}}}update_parameters(e){const i=Y(e);for(const r in i)if(r in this.param){const s=r;this.param[s]=i[s]}}init_stability(e){return Math.max(this.param.w[e-1],.1)}init_difficulty(e){return this.constrain_difficulty(this.param.w[4]-Math.exp((e-1)*this.param.w[5])+1)}apply_fuzz(e,i){if(!this.param.enable_fuzz||e<2.5)return Math.round(e);const r=et(this._seed)(),{min_ivl:s,max_ivl:n}=We(e,i,this.param.maximum_interval);return Math.floor(r*(n-s+1)+s)}next_interval(e,i){const r=Math.min(Math.max(1,Math.round(e*this.intervalModifier)),this.param.maximum_interval);return this.apply_fuzz(r,i)}linear_damping(e,i){return+(e*(10-i)/9).toFixed(8)}next_difficulty(e,i){const r=-this.param.w[6]*(i-3),s=e+this.linear_damping(r,e);return this.constrain_difficulty(this.mean_reversion(this.init_difficulty(l.Easy),s))}constrain_difficulty(e){return Math.min(Math.max(+e.toFixed(8),1),10)}mean_reversion(e,i){return+(this.param.w[7]*e+(1-this.param.w[7])*i).toFixed(8)}next_recall_stability(e,i,r,s){const n=l.Hard===s?this.param.w[15]:1,a=l.Easy===s?this.param.w[16]:1;return+b(i*(1+Math.exp(this.param.w[8])*(11-e)*Math.pow(i,-this.param.w[9])*(Math.exp((1-r)*this.param.w[10])-1)*n*a),g,36500).toFixed(8)}next_forget_stability(e,i,r){return+b(this.param.w[11]*Math.pow(e,-this.param.w[12])*(Math.pow(i+1,this.param.w[13])-1)*Math.exp((1-r)*this.param.w[14]),g,36500).toFixed(8)}next_short_term_stability(e,i){return+b(e*Math.exp(this.param.w[17]*(i-3+this.param.w[18])),g,36500).toFixed(8)}next_state(e,i,r){const{difficulty:s,stability:n}=e??{difficulty:0,stability:0};if(i<0)throw new Error(`Invalid delta_t "${i}"`);if(r<0||r>4)throw new Error(`Invalid grade "${r}"`);if(s===0&&n===0)return{difficulty:this.init_difficulty(r),stability:this.init_stability(r)};if(r===0)return{difficulty:s,stability:n};if(s<1||n<g)throw new Error(`Invalid memory state { difficulty: ${s}, stability: ${n} }`);const a=this.forgetting_curve(i,n),o=this.next_recall_stability(s,n,a,r),c=this.next_forget_stability(s,n,a),u=this.next_short_term_stability(n,r);let f=o;if(r===1){let[y,p]=[0,0];this.param.enable_short_term&&(y=this.param.w[17],p=this.param.w[18]);const E=n/Math.exp(y*p);f=b(+E.toFixed(8),g,c)}return i===0&&this.param.enable_short_term&&(f=u),{difficulty:this.next_difficulty(s,r),stability:f}}}function me(){const t=this.review_time.getTime(),e=this.current.reps,i=this.current.difficulty*this.current.stability;return`${t}_${e}_${i}`}var X=(t=>(t.SCHEDULER="Scheduler",t.SEED="Seed",t))(X||{});class we{constructor(e,i,r,s={seed:me}){_(this,"last");_(this,"current");_(this,"review_time");_(this,"next",new Map);_(this,"algorithm");_(this,"initSeedStrategy");this.algorithm=r,this.initSeedStrategy=s.seed.bind(this),this.last=d.card(e),this.current=d.card(e),this.review_time=d.time(i),this.init()}init(){const{state:e,last_review:i}=this.current;let r=0;e!==h.New&&i&&(r=Ye(i,this.review_time)),this.current.last_review=this.review_time,this.current.elapsed_days=r,this.current.reps+=1,this.algorithm.seed=this.initSeedStrategy()}preview(){return{[l.Again]:this.review(l.Again),[l.Hard]:this.review(l.Hard),[l.Good]:this.review(l.Good),[l.Easy]:this.review(l.Easy),[Symbol.iterator]:this.previewIterator.bind(this)}}*previewIterator(){for(const e of he)yield this.review(e)}review(e){const{state:i}=this.last;let r;switch(i){case h.New:r=this.newState(e);break;case h.Learning:case h.Relearning:r=this.learningState(e);break;case h.Review:r=this.reviewState(e);break}if(r)return r;throw new Error("Invalid grade")}buildLog(e){const{last_review:i,due:r,elapsed_days:s}=this.last;return{rating:e,state:this.current.state,due:i||r,stability:this.current.stability,difficulty:this.current.difficulty,elapsed_days:this.current.elapsed_days,last_elapsed_days:s,scheduled_days:this.current.scheduled_days,review:this.review_time}}}class re extends we{newState(e){const i=this.next.get(e);if(i)return i;const r=d.card(this.current);switch(r.difficulty=this.algorithm.init_difficulty(e),r.stability=this.algorithm.init_stability(e),e){case l.Again:r.scheduled_days=0,r.due=this.review_time.scheduler(1),r.state=h.Learning;break;case l.Hard:r.scheduled_days=0,r.due=this.review_time.scheduler(5),r.state=h.Learning;break;case l.Good:r.scheduled_days=0,r.due=this.review_time.scheduler(10),r.state=h.Learning;break;case l.Easy:{const n=this.algorithm.next_interval(r.stability,this.current.elapsed_days);r.scheduled_days=n,r.due=this.review_time.scheduler(n,!0),r.state=h.Review;break}default:throw new Error("Invalid grade")}const s={card:r,log:this.buildLog(e)};return this.next.set(e,s),s}learningState(e){const i=this.next.get(e);if(i)return i;const{state:r,difficulty:s,stability:n}=this.last,a=d.card(this.current),o=this.current.elapsed_days;switch(a.difficulty=this.algorithm.next_difficulty(s,e),a.stability=this.algorithm.next_short_term_stability(n,e),e){case l.Again:{a.scheduled_days=0,a.due=this.review_time.scheduler(5,!1),a.state=r;break}case l.Hard:{a.scheduled_days=0,a.due=this.review_time.scheduler(10),a.state=r;break}case l.Good:{const u=this.algorithm.next_interval(a.stability,o);a.scheduled_days=u,a.due=this.review_time.scheduler(u,!0),a.state=h.Review;break}case l.Easy:{const u=this.algorithm.next_short_term_stability(n,l.Good),f=this.algorithm.next_interval(u,o),y=Math.max(this.algorithm.next_interval(a.stability,o),f+1);a.scheduled_days=y,a.due=this.review_time.scheduler(y,!0),a.state=h.Review;break}default:throw new Error("Invalid grade")}const c={card:a,log:this.buildLog(e)};return this.next.set(e,c),c}reviewState(e){const i=this.next.get(e);if(i)return i;const r=this.current.elapsed_days,{difficulty:s,stability:n}=this.last,a=this.algorithm.forgetting_curve(r,n),o=d.card(this.current),c=d.card(this.current),u=d.card(this.current),f=d.card(this.current);this.next_ds(o,c,u,f,s,n,a),this.next_interval(o,c,u,f,r),this.next_state(o,c,u,f),o.lapses+=1;const y={card:o,log:this.buildLog(l.Again)},p={card:c,log:super.buildLog(l.Hard)},E={card:u,log:super.buildLog(l.Good)},C={card:f,log:super.buildLog(l.Easy)};return this.next.set(l.Again,y),this.next.set(l.Hard,p),this.next.set(l.Good,E),this.next.set(l.Easy,C),this.next.get(e)}next_ds(e,i,r,s,n,a,o){e.difficulty=this.algorithm.next_difficulty(n,l.Again);const c=a/Math.exp(this.algorithm.parameters.w[17]*this.algorithm.parameters.w[18]),u=this.algorithm.next_forget_stability(n,a,o);e.stability=b(+c.toFixed(8),g,u),i.difficulty=this.algorithm.next_difficulty(n,l.Hard),i.stability=this.algorithm.next_recall_stability(n,a,o,l.Hard),r.difficulty=this.algorithm.next_difficulty(n,l.Good),r.stability=this.algorithm.next_recall_stability(n,a,o,l.Good),s.difficulty=this.algorithm.next_difficulty(n,l.Easy),s.stability=this.algorithm.next_recall_stability(n,a,o,l.Easy)}next_interval(e,i,r,s,n){let a,o;a=this.algorithm.next_interval(i.stability,n),o=this.algorithm.next_interval(r.stability,n),a=Math.min(a,o),o=Math.max(o,a+1);const c=Math.max(this.algorithm.next_interval(s.stability,n),o+1);e.scheduled_days=0,e.due=this.review_time.scheduler(5),i.scheduled_days=a,i.due=this.review_time.scheduler(a,!0),r.scheduled_days=o,r.due=this.review_time.scheduler(o,!0),s.scheduled_days=c,s.due=this.review_time.scheduler(c,!0)}next_state(e,i,r,s){e.state=h.Relearning,i.state=h.Review,r.state=h.Review,s.state=h.Review}}class se extends we{newState(e){const i=this.next.get(e);if(i)return i;this.current.scheduled_days=0,this.current.elapsed_days=0;const r=d.card(this.current),s=d.card(this.current),n=d.card(this.current),a=d.card(this.current);return this.init_ds(r,s,n,a),this.next_interval(r,s,n,a,0),this.next_state(r,s,n,a),this.update_next(r,s,n,a),this.next.get(e)}init_ds(e,i,r,s){e.difficulty=this.algorithm.init_difficulty(l.Again),e.stability=this.algorithm.init_stability(l.Again),i.difficulty=this.algorithm.init_difficulty(l.Hard),i.stability=this.algorithm.init_stability(l.Hard),r.difficulty=this.algorithm.init_difficulty(l.Good),r.stability=this.algorithm.init_stability(l.Good),s.difficulty=this.algorithm.init_difficulty(l.Easy),s.stability=this.algorithm.init_stability(l.Easy)}learningState(e){return this.reviewState(e)}reviewState(e){const i=this.next.get(e);if(i)return i;const r=this.current.elapsed_days,{difficulty:s,stability:n}=this.last,a=this.algorithm.forgetting_curve(r,n),o=d.card(this.current),c=d.card(this.current),u=d.card(this.current),f=d.card(this.current);return this.next_ds(o,c,u,f,s,n,a),this.next_interval(o,c,u,f,r),this.next_state(o,c,u,f),o.lapses+=1,this.update_next(o,c,u,f),this.next.get(e)}next_ds(e,i,r,s,n,a,o){e.difficulty=this.algorithm.next_difficulty(n,l.Again);const c=this.algorithm.next_forget_stability(n,a,o);e.stability=b(a,g,c),i.difficulty=this.algorithm.next_difficulty(n,l.Hard),i.stability=this.algorithm.next_recall_stability(n,a,o,l.Hard),r.difficulty=this.algorithm.next_difficulty(n,l.Good),r.stability=this.algorithm.next_recall_stability(n,a,o,l.Good),s.difficulty=this.algorithm.next_difficulty(n,l.Easy),s.stability=this.algorithm.next_recall_stability(n,a,o,l.Easy)}next_interval(e,i,r,s,n){let a,o,c,u;a=this.algorithm.next_interval(e.stability,n),o=this.algorithm.next_interval(i.stability,n),c=this.algorithm.next_interval(r.stability,n),u=this.algorithm.next_interval(s.stability,n),a=Math.min(a,o),o=Math.max(o,a+1),c=Math.max(c,o+1),u=Math.max(u,c+1),e.scheduled_days=a,e.due=this.review_time.scheduler(a,!0),i.scheduled_days=o,i.due=this.review_time.scheduler(o,!0),r.scheduled_days=c,r.due=this.review_time.scheduler(c,!0),s.scheduled_days=u,s.due=this.review_time.scheduler(u,!0)}next_state(e,i,r,s){e.state=h.Review,i.state=h.Review,r.state=h.Review,s.state=h.Review}update_next(e,i,r,s){const n={card:e,log:this.buildLog(l.Again)},a={card:i,log:super.buildLog(l.Hard)},o={card:r,log:super.buildLog(l.Good)},c={card:s,log:super.buildLog(l.Easy)};this.next.set(l.Again,n),this.next.set(l.Hard,a),this.next.set(l.Good,o),this.next.set(l.Easy,c)}}class rt{constructor(e){_(this,"fsrs");this.fsrs=e}replay(e,i,r){return this.fsrs.next(e,i,r)}handleManualRating(e,i,r,s,n,a,o){if(typeof i>"u")throw new Error("reschedule: state is required for manual rating");let c,u;if(i===h.New)c={rating:l.Manual,state:i,due:o??r,stability:e.stability,difficulty:e.difficulty,elapsed_days:s,last_elapsed_days:e.elapsed_days,scheduled_days:e.scheduled_days,review:r},u=P(r),u.last_review=r;else{if(typeof o>"u")throw new Error("reschedule: due is required for manual rating");const f=o.diff(r,"days");c={rating:l.Manual,state:e.state,due:e.last_review||e.due,stability:e.stability,difficulty:e.difficulty,elapsed_days:s,last_elapsed_days:e.elapsed_days,scheduled_days:e.scheduled_days,review:r},u={...e,state:i,due:o,last_review:r,stability:n||e.stability,difficulty:a||e.difficulty,elapsed_days:s,scheduled_days:f,reps:e.reps+1}}return{card:u,log:c}}reschedule(e,i){const r=[];let s=P(e.due);for(const n of i){let a;if(n.review=d.time(n.review),n.rating===l.Manual){let o=0;s.state!==h.New&&s.last_review&&(o=n.review.diff(s.last_review,"days")),a=this.handleManualRating(s,n.state,n.review,o,n.stability,n.difficulty,n.due?d.time(n.due):void 0)}else a=this.replay(s,n.review,n.rating);r.push(a),s=a.card}return r}calculateManualRecord(e,i,r,s){if(!r)return null;const{card:n,log:a}=r,o=d.card(e);return o.due.getTime()===n.due.getTime()?null:(o.scheduled_days=n.due.diff(o.due,"days"),this.handleManualRating(o,n.state,d.time(i),a.elapsed_days,s?n.stability:void 0,s?n.difficulty:void 0,n.due))}}class st extends it{constructor(i){super(i);_(this,"strategyHandler",new Map);_(this,"Scheduler");const{enable_short_term:r}=this.parameters;this.Scheduler=r?re:se}params_handler_proxy(){const i=this;return{set:function(r,s,n){return s==="request_retention"&&Number.isFinite(n)?i.intervalModifier=i.calculate_interval_modifier(Number(n)):s==="enable_short_term"&&(i.Scheduler=n===!0?re:se),Reflect.set(r,s,n),!0}}}useStrategy(i,r){return this.strategyHandler.set(i,r),this}clearStrategy(i){return i?this.strategyHandler.delete(i):this.strategyHandler.clear(),this}getScheduler(i,r){const s=this.strategyHandler.get(X.SEED),n=this.strategyHandler.get(X.SCHEDULER)||this.Scheduler,a=s||me;return new n(i,r,this,{seed:a})}repeat(i,r,s){const n=this.getScheduler(i,r).preview();return s&&typeof s=="function"?s(n):n}next(i,r,s,n){const a=this.getScheduler(i,r),o=d.rating(s);if(o===l.Manual)throw new Error("Cannot review a manual rating");const c=a.review(o);return n&&typeof n=="function"?n(c):c}get_retrievability(i,r,s=!0){const n=d.card(i);r=r?d.time(r):new Date;const a=n.state!==h.New?Math.max(r.diff(n.last_review,"days"),0):0,o=n.state!==h.New?this.forgetting_curve(a,+n.stability.toFixed(8)):0;return s?`${(o*100).toFixed(2)}%`:o}rollback(i,r,s){const n=d.card(i),a=d.review_log(r);if(a.rating===l.Manual)throw new Error("Cannot rollback a manual rating");let o,c,u;switch(a.state){case h.New:o=a.due,c=void 0,u=0;break;case h.Learning:case h.Relearning:case h.Review:o=a.review,c=a.due,u=n.lapses-(a.rating===l.Again&&a.state===h.Review?1:0);break}const f={...n,due:o,stability:a.stability,difficulty:a.difficulty,elapsed_days:a.last_elapsed_days,scheduled_days:a.scheduled_days,reps:Math.max(0,n.reps-1),lapses:Math.max(0,u),state:a.state,last_review:c};return s&&typeof s=="function"?s(f):f}forget(i,r,s=!1,n){const a=d.card(i);r=d.time(r);const o=a.state===h.New?0:r.diff(a.last_review,"days"),c={rating:l.Manual,state:a.state,due:a.due,stability:a.stability,difficulty:a.difficulty,elapsed_days:0,last_elapsed_days:a.elapsed_days,scheduled_days:o,review:r},u={card:{...a,due:r,stability:0,difficulty:0,elapsed_days:0,scheduled_days:0,reps:s?0:a.reps,lapses:s?0:a.lapses,state:h.New,last_review:a.last_review},log:c};return n&&typeof n=="function"?n(u):u}reschedule(i,r=[],s={}){const{recordLogHandler:n,reviewsOrderBy:a,skipManual:o=!0,now:c=new Date,update_memory_state:u=!1}=s;a&&typeof a=="function"&&r.sort(a),o&&(r=r.filter(Ne=>Ne.rating!==l.Manual));const f=new rt(this),y=f.reschedule(s.first_card||P(),r),p=y.length,E=d.card(i),C=f.calculateManualRecord(E,c,p?y[p-1]:void 0,u);return n&&typeof n=="function"?{collections:y.map(n),reschedule_item:C?n(C):null}:{collections:y,reschedule_item:C}}}const nt=t=>new st(t||{}),at=Y({request_retention:fe,enable_fuzz:!0,maximum_interval:100}),ge=nt(at),pe=t=>t.due?t:{...t,due:new Date},ot=t=>R.reviewStates.indexOf(t),ve=t=>({due:t.due,stability:t.stability,difficulty:t.difficulty,elapsed_days:t.elapsedDays,scheduled_days:t.scheduledDays,reps:t.reps,lapses:t.lapses,state:ot(t.state),last_review:t.lastReview}),be=(t,e,i)=>{const r=new Date,s=ve(pe(t));return ge.repeat(s,r,a=>{const o=ut(e),c=a[o],u=Se(c.card,t),f=c.log,y={id:0,cardReviewId:t.id,grade:e,state:xe(f.state),due:f.due,stability:f.stability,difficulty:f.difficulty,elapsedDays:f.elapsed_days,lastElapsedDays:f.last_elapsed_days,scheduledDays:f.scheduled_days,review:f.review,duration:i};return{nextCard:u,reviewLog:y}})};function lt(t){const e=new Date,i=ve(pe(t)),r=ge.repeat(i,e),s=Object.fromEntries(R.reviewRatings.map(n=>[n,new Date]));for(const n of he){const a=r[n].card.due,o=ct(n);s[o]=a}return s}function ct(t){return R.reviewRatings[t]}function xe(t){return R.reviewStates[t]}function Se(t,e){return{...e,due:t.due,stability:t.stability,difficulty:t.difficulty,elapsedDays:t.elapsed_days,scheduledDays:t.scheduled_days,reps:t.reps,lapses:t.lapses,state:xe(t.state),lastReview:t.last_review??null}}function ut(t){const e=R.reviewRatings.indexOf(t);if(e===-1)throw new Error(`Invalid rating: ${t}`);return e}function dt(t,e){const i=P();return{id:"",due:null,stability:i.stability,difficulty:i.difficulty,elapsedDays:i.elapsed_days,scheduledDays:i.scheduled_days,reps:i.reps,lapses:i.lapses,state:R.ReviewState.New,lastReview:i.last_review??null,userDeckStudyId:t,cardId:e}}var Me=Symbol.for("immer-nothing"),ne=Symbol.for("immer-draftable"),w=Symbol.for("immer-state"),ft=process.env.NODE_ENV!=="production"?[function(t){return`The plugin for '${t}' has not been loaded into Immer. To enable the plugin, import and call \`enable${t}()\` when initializing your application.`},function(t){return`produce can only be called on things that are draftable: plain objects, arrays, Map, Set or classes that are marked with '[immerable]: true'. Got '${t}'`},"This object has been frozen and should not be mutated",function(t){return"Cannot use a proxy that has been revoked. Did you pass an object from inside an immer function to an async process? "+t},"An immer producer returned a new value *and* modified its draft. Either return a new value *or* modify the draft.","Immer forbids circular references","The first or second argument to `produce` must be a function","The third argument to `produce` must be a function or undefined","First argument to `createDraft` must be a plain object, an array, or an immerable object","First argument to `finishDraft` must be a draft returned by `createDraft`",function(t){return`'current' expects a draft, got: ${t}`},"Object.defineProperty() cannot be used on an Immer draft","Object.setPrototypeOf() cannot be used on an Immer draft","Immer only supports deleting array indices","Immer only supports setting array indices and the 'length' property",function(t){return`'original' expects a draft, got: ${t}`}]:[];function m(t,...e){if(process.env.NODE_ENV!=="production"){const i=ft[t],r=typeof i=="function"?i.apply(null,e):i;throw new Error(`[Immer] ${r}`)}throw new Error(`[Immer] minified error nr: ${t}. Full error at: https://bit.ly/3cXEKWf`)}var F=Object.getPrototypeOf;function M(t){return!!t&&!!t[w]}function x(t){var e;return t?Re(t)||Array.isArray(t)||!!t[ne]||!!((e=t.constructor)!=null&&e[ne])||N(t)||$(t):!1}var ht=Object.prototype.constructor.toString(),ae=new WeakMap;function Re(t){if(!t||typeof t!="object")return!1;const e=Object.getPrototypeOf(t);if(e===null||e===Object.prototype)return!0;const i=Object.hasOwnProperty.call(e,"constructor")&&e.constructor;if(i===Object)return!0;if(typeof i!="function")return!1;let r=ae.get(i);return r===void 0&&(r=Function.toString.call(i),ae.set(i,r)),r===ht}function T(t,e,i=!0){j(t)===0?(i?Reflect.ownKeys(t):Object.keys(t)).forEach(s=>{e(s,t[s],t)}):t.forEach((r,s)=>e(s,r,t))}function j(t){const e=t[w];return e?e.type_:Array.isArray(t)?1:N(t)?2:$(t)?3:0}function K(t,e){return j(t)===2?t.has(e):Object.prototype.hasOwnProperty.call(t,e)}function Ee(t,e,i){const r=j(t);r===2?t.set(e,i):r===3?t.add(i):t[e]=i}function _t(t,e){return t===e?t!==0||1/t===1/e:t!==t&&e!==e}function N(t){return t instanceof Map}function $(t){return t instanceof Set}function v(t){return t.copy_||t.base_}function B(t,e){if(N(t))return new Map(t);if($(t))return new Set(t);if(Array.isArray(t))return Array.prototype.slice.call(t);const i=Re(t);if(e===!0||e==="class_only"&&!i){const r=Object.getOwnPropertyDescriptors(t);delete r[w];let s=Reflect.ownKeys(r);for(let n=0;n<s.length;n++){const a=s[n],o=r[a];o.writable===!1&&(o.writable=!0,o.configurable=!0),(o.get||o.set)&&(r[a]={configurable:!0,writable:!0,enumerable:o.enumerable,value:t[a]})}return Object.create(F(t),r)}else{const r=F(t);if(r!==null&&i)return{...t};const s=Object.create(r);return Object.assign(s,t)}}function ee(t,e=!1){return L(t)||M(t)||!x(t)||(j(t)>1&&Object.defineProperties(t,{set:I,add:I,clear:I,delete:I}),Object.freeze(t),e&&Object.values(t).forEach(i=>ee(i,!0))),t}function yt(){m(2)}var I={value:yt};function L(t){return t===null||typeof t!="object"?!0:Object.isFrozen(t)}var mt={};function S(t){const e=mt[t];return e||m(0,t),e}var z;function Ce(){return z}function wt(t,e){return{drafts_:[],parent_:t,immer_:e,canAutoFreeze_:!0,unfinalizedDrafts_:0}}function oe(t,e){e&&(S("Patches"),t.patches_=[],t.inversePatches_=[],t.patchListener_=e)}function Z(t){J(t),t.drafts_.forEach(gt),t.drafts_=null}function J(t){t===z&&(z=t.parent_)}function le(t){return z=wt(z,t)}function gt(t){const e=t[w];e.type_===0||e.type_===1?e.revoke_():e.revoked_=!0}function ce(t,e){e.unfinalizedDrafts_=e.drafts_.length;const i=e.drafts_[0];return t!==void 0&&t!==i?(i[w].modified_&&(Z(e),m(4)),x(t)&&(t=H(e,t),e.parent_||k(e,t)),e.patches_&&S("Patches").generateReplacementPatches_(i[w].base_,t,e.patches_,e.inversePatches_)):t=H(e,i,[]),Z(e),e.patches_&&e.patchListener_(e.patches_,e.inversePatches_),t!==Me?t:void 0}function H(t,e,i){if(L(e))return e;const r=t.immer_.shouldUseStrictIteration(),s=e[w];if(!s)return T(e,(n,a)=>ue(t,s,e,n,a,i),r),e;if(s.scope_!==t)return e;if(!s.modified_)return k(t,s.base_,!0),s.base_;if(!s.finalized_){s.finalized_=!0,s.scope_.unfinalizedDrafts_--;const n=s.copy_;let a=n,o=!1;s.type_===3&&(a=new Set(n),n.clear(),o=!0),T(a,(c,u)=>ue(t,s,n,c,u,i,o),r),k(t,n,!1),i&&t.patches_&&S("Patches").generatePatches_(s,i,t.patches_,t.inversePatches_)}return s.copy_}function ue(t,e,i,r,s,n,a){if(s==null||typeof s!="object"&&!a)return;const o=L(s);if(!(o&&!a)){if(process.env.NODE_ENV!=="production"&&s===i&&m(5),M(s)){const c=n&&e&&e.type_!==3&&!K(e.assigned_,r)?n.concat(r):void 0,u=H(t,s,c);if(Ee(i,r,u),M(u))t.canAutoFreeze_=!1;else return}else a&&i.add(s);if(x(s)&&!o){if(!t.immer_.autoFreeze_&&t.unfinalizedDrafts_<1||e&&e.base_&&e.base_[r]===s&&o)return;H(t,s),(!e||!e.scope_.parent_)&&typeof r!="symbol"&&(N(i)?i.has(r):Object.prototype.propertyIsEnumerable.call(i,r))&&k(t,s)}}}function k(t,e,i=!1){!t.parent_&&t.immer_.autoFreeze_&&t.canAutoFreeze_&&ee(e,i)}function pt(t,e){const i=Array.isArray(t),r={type_:i?1:0,scope_:e?e.scope_:Ce(),modified_:!1,finalized_:!1,assigned_:{},parent_:e,base_:t,draft_:null,copy_:null,revoke_:null,isManual_:!1};let s=r,n=te;i&&(s=[r],n=O);const{revoke:a,proxy:o}=Proxy.revocable(s,n);return r.draft_=o,r.revoke_=a,o}var te={get(t,e){if(e===w)return t;const i=v(t);if(!K(i,e))return vt(t,i,e);const r=i[e];return t.finalized_||!x(r)?r:r===q(t.base_,e)?(W(t),t.copy_[e]=V(r,t)):r},has(t,e){return e in v(t)},ownKeys(t){return Reflect.ownKeys(v(t))},set(t,e,i){const r=De(v(t),e);if(r!=null&&r.set)return r.set.call(t.draft_,i),!0;if(!t.modified_){const s=q(v(t),e),n=s==null?void 0:s[w];if(n&&n.base_===i)return t.copy_[e]=i,t.assigned_[e]=!1,!0;if(_t(i,s)&&(i!==void 0||K(t.base_,e)))return!0;W(t),Q(t)}return t.copy_[e]===i&&(i!==void 0||e in t.copy_)||Number.isNaN(i)&&Number.isNaN(t.copy_[e])||(t.copy_[e]=i,t.assigned_[e]=!0),!0},deleteProperty(t,e){return q(t.base_,e)!==void 0||e in t.base_?(t.assigned_[e]=!1,W(t),Q(t)):delete t.assigned_[e],t.copy_&&delete t.copy_[e],!0},getOwnPropertyDescriptor(t,e){const i=v(t),r=Reflect.getOwnPropertyDescriptor(i,e);return r&&{writable:!0,configurable:t.type_!==1||e!=="length",enumerable:r.enumerable,value:i[e]}},defineProperty(){m(11)},getPrototypeOf(t){return F(t.base_)},setPrototypeOf(){m(12)}},O={};T(te,(t,e)=>{O[t]=function(){return arguments[0]=arguments[0][0],e.apply(this,arguments)}});O.deleteProperty=function(t,e){return process.env.NODE_ENV!=="production"&&isNaN(parseInt(e))&&m(13),O.set.call(this,t,e,void 0)};O.set=function(t,e,i){return process.env.NODE_ENV!=="production"&&e!=="length"&&isNaN(parseInt(e))&&m(14),te.set.call(this,t[0],e,i,t[0])};function q(t,e){const i=t[w];return(i?v(i):t)[e]}function vt(t,e,i){var s;const r=De(e,i);return r?"value"in r?r.value:(s=r.get)==null?void 0:s.call(t.draft_):void 0}function De(t,e){if(!(e in t))return;let i=F(t);for(;i;){const r=Object.getOwnPropertyDescriptor(i,e);if(r)return r;i=F(i)}}function Q(t){t.modified_||(t.modified_=!0,t.parent_&&Q(t.parent_))}function W(t){t.copy_||(t.copy_=B(t.base_,t.scope_.immer_.useStrictShallowCopy_))}var bt=class{constructor(t){this.autoFreeze_=!0,this.useStrictShallowCopy_=!1,this.useStrictIteration_=!0,this.produce=(e,i,r)=>{if(typeof e=="function"&&typeof i!="function"){const n=i;i=e;const a=this;return function(c=n,...u){return a.produce(c,f=>i.call(this,f,...u))}}typeof i!="function"&&m(6),r!==void 0&&typeof r!="function"&&m(7);let s;if(x(e)){const n=le(this),a=V(e,void 0);let o=!0;try{s=i(a),o=!1}finally{o?Z(n):J(n)}return oe(n,r),ce(s,n)}else if(!e||typeof e!="object"){if(s=i(e),s===void 0&&(s=e),s===Me&&(s=void 0),this.autoFreeze_&&ee(s,!0),r){const n=[],a=[];S("Patches").generateReplacementPatches_(e,s,n,a),r(n,a)}return s}else m(1,e)},this.produceWithPatches=(e,i)=>{if(typeof e=="function")return(a,...o)=>this.produceWithPatches(a,c=>e(c,...o));let r,s;return[this.produce(e,i,(a,o)=>{r=a,s=o}),r,s]},typeof(t==null?void 0:t.autoFreeze)=="boolean"&&this.setAutoFreeze(t.autoFreeze),typeof(t==null?void 0:t.useStrictShallowCopy)=="boolean"&&this.setUseStrictShallowCopy(t.useStrictShallowCopy),typeof(t==null?void 0:t.useStrictIteration)=="boolean"&&this.setUseStrictIteration(t.useStrictIteration)}createDraft(t){x(t)||m(8),M(t)&&(t=xt(t));const e=le(this),i=V(t,void 0);return i[w].isManual_=!0,J(e),i}finishDraft(t,e){const i=t&&t[w];(!i||!i.isManual_)&&m(9);const{scope_:r}=i;return oe(r,e),ce(void 0,r)}setAutoFreeze(t){this.autoFreeze_=t}setUseStrictShallowCopy(t){this.useStrictShallowCopy_=t}setUseStrictIteration(t){this.useStrictIteration_=t}shouldUseStrictIteration(){return this.useStrictIteration_}applyPatches(t,e){let i;for(i=e.length-1;i>=0;i--){const s=e[i];if(s.path.length===0&&s.op==="replace"){t=s.value;break}}i>-1&&(e=e.slice(i+1));const r=S("Patches").applyPatches_;return M(t)?r(t,e):this.produce(t,s=>r(s,e))}};function V(t,e){const i=N(t)?S("MapSet").proxyMap_(t,e):$(t)?S("MapSet").proxySet_(t,e):pt(t,e);return(e?e.scope_:Ce()).drafts_.push(i),i}function xt(t){return M(t)||m(10,t),Fe(t)}function Fe(t){if(!x(t)||L(t))return t;const e=t[w];let i,r=!0;if(e){if(!e.modified_)return e.base_;e.finalized_=!0,i=B(t,e.scope_.immer_.useStrictShallowCopy_),r=e.scope_.immer_.shouldUseStrictIteration()}else i=B(t,!0);return T(i,(s,n)=>{Ee(i,s,Fe(n))},r),e&&(e.finalized_=!1),i}var St=new bt,Mt=St.produce;function Rt(t,e){const i=t+e;let r=0;for(let s=0;s<i.length;s++){const n=i.charCodeAt(s);r=(r<<5)-r+n,r|=0}return r}function Et(t,e){return(Rt(t,e)>>>0)/4294967295}function Ct(t,e=new Set){if(t.reviewCards.length===0&&t.newCards.length===0)return;if(t.reviewCards.length===0)return t.newCards[0];if(t.newCards.length===0)return t.reviewCards[0];const i=de(t.newCards,e),r=de(t.reviewCards,e);if(!i)return r??t.newCards[0];if(!r)return i??t.reviewCards[0];const s=t.newCards.length,n=t.reviewCards.length,a=s+n,o=.33,c=s/a,u=(o+c)/2;return Et(i.card.id,r.card.id)<u?i:r}function de(t,e){return t.find(i=>!e.has(i.card.id))}function Dt(t,e,i){const r=Oe(e,i);if(!r)return e;const{nextCard:s}=be(r.cardReview,t,30),n=s.due&&Pe.isSameDay(s.due,new Date);return Mt(e,a=>{if(Ft(a,r),n){const o={...r,cardReview:s};zt(a,o)}})}function Ft(t,e){e.cardReview.state==="New"?t.newCards=t.newCards.filter(i=>i.card.id!==e.card.id):t.reviewCards=t.reviewCards.filter(i=>i.card.id!==e.card.id),ze(t,e.cardReview.state,"decrease")}function zt(t,e){if(e.cardReview.state==="New"){const i=t.newCards.findIndex(r=>r.cardReview.due&&e.cardReview.due&&r.cardReview.due>=e.cardReview.due||r.cardReview.difficulty>=e.cardReview.difficulty);i===-1?t.newCards.push(e):t.newCards.splice(i,0,e)}else{const i=Ot(t,t.reviewCards);t.reviewCards.splice(i,0,e)}ze(t,e.cardReview.state,"increase")}function ze(t,e,i){const r=i==="increase"?1:-1;switch(e){case"New":t.stats.new+=r;break;case"Learning":case"Relearning":t.stats.learning+=r;break;case"Review":t.stats.review+=r;break;default:t.stats.new+=r;break}t.stats.total+=r}function Oe(t,e){return t.newCards.find(i=>i.card.id===e)??t.reviewCards.find(i=>i.card.id===e)}function Ot(t,e){if(e.length===0)return 0;const i=Math.max(4,Math.floor(e.length/3));return Math.min(i,e.length)}exports.FSRS_RETENTION=fe;exports.MAX_CARDS_TO_FETCH=Te;exports.MAX_LEARN_PER_DAY=He;exports.MAX_NEW_PER_DECK_DAY=ke;exports.THRESHOLD_CARDS_FOR_REFETCH=je;exports.getNextCardFromSession=Ct;exports.getReviewDateForEachRating=lt;exports.getSessionCard=Oe;exports.gradeCard=be;exports.mergeFsrsCard=Se;exports.newCardReview=dt;exports.removeCardFromSessionData=Dt;
@@ -109,13 +109,15 @@ export declare function newCardReview(userDeckStudyId: string, cardId: string):
109
109
  */
110
110
  export declare function removeCardFromSessionData(grade: ReviewRating, data: ISessionData, cardId: string): ISessionData;
111
111
 
112
- declare enum ReviewRating {
113
- Manual = "Manual",
114
- Again = "Again",
115
- Hard = "Hard",
116
- Good = "Good",
117
- Easy = "Easy"
118
- }
112
+ declare const ReviewRating: {
113
+ readonly Manual: "Manual";
114
+ readonly Again: "Again";
115
+ readonly Hard: "Hard";
116
+ readonly Good: "Good";
117
+ readonly Easy: "Easy";
118
+ };
119
+
120
+ declare type ReviewRating = (typeof ReviewRating)[keyof typeof ReviewRating];
119
121
 
120
122
  declare enum ReviewState {
121
123
  New = "New",
@@ -1,7 +1,7 @@
1
1
  var Oe = Object.defineProperty;
2
2
  var Fe = (t, e, i) => e in t ? Oe(t, e, { enumerable: !0, configurable: !0, writable: !0, value: i }) : t[e] = i;
3
3
  var _ = (t, e, i) => Fe(t, typeof e != "symbol" ? e + "" : e, i);
4
- import { r as V, a as Ne, b as fe } from "./fsrs-C8QUsZ5l.js";
4
+ import { r as V, a as Ne, b as fe } from "./fsrs-sJJWxUiC.js";
5
5
  import "date-fns/locale";
6
6
  import { isSameDay as Ie } from "date-fns";
7
7
  import "date-fns-tz";
package/dist/theme.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const b=require("@radix-ui/colors");function u(r){const a=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(r){for(const t in r)if(t!=="default"){const n=Object.getOwnPropertyDescriptor(r,t);Object.defineProperty(a,t,n.get?n:{enumerable:!0,get:()=>r[t]})}}return a.default=r,Object.freeze(a)}const i=u(b),c=["primary","secondary","tertiary","quaternary","quinary"];function l(r){if(!r)return c[0];let a=0;for(let n=0;n<r.length;n++)a=r.charCodeAt(n)+((a<<5)-a);const t=Math.abs(a)%c.length;return c[t]}const e=(r,a)=>{var n;const t=`${r}${a.charAt(0).toUpperCase()+a.slice(1)}`;return((n=i[r])==null?void 0:n[t])??`var(--${r}-${a})`},s=(r,a,t)=>[r,e(a,t)];function o(r){const a=Array.from({length:12},(t,n)=>{const g=n+1;return[s(g.toString(),r,g.toString()),s(`a${g}`,r,`a${g}`)]}).flat();return a.push(s("DEFAULT",r,"9")),a.push(s("hover",r,"10")),a.push(s("dark",r,"11")),a.push(s("light",r,"4")),a.push(s("lightness",r,"2")),Object.fromEntries(a)}const d={transparent:"transparent",current:"currentColor",brand:{DEFAULT:"#FF7824"},primary:{...o("orange")},secondary:{...o("blue")},tertiary:{...o("amber")},quaternary:{...o("crimson")},quinary:{...o("jade")},gray:{...o("sand")},success:{...o("grass")},warning:{...o("amber")},danger:{...o("red")},black:{DEFAULT:"#000000",a1:"rgba(0, 0, 0, 0.05)",a2:"rgba(0, 0, 0, 0.1)",a3:"rgba(0, 0, 0, 0.15)",a4:"rgba(0, 0, 0, 0.2)",a5:"rgba(0, 0, 0, 0.3)",a6:"rgba(0, 0, 0, 0.4)",a7:"rgba(0, 0, 0, 0.5)",a8:"rgba(0, 0, 0, 0.6)",a9:"rgba(0, 0, 0, 0.7)",a10:"rgba(0, 0, 0, 0.8)",a11:"rgba(0, 0, 0, 0.9)",a12:"rgba(0, 0, 0, 0.95)"},white:{DEFAULT:"#FFFFFF",a1:"rgba(255, 255, 255, 0.05)",a2:"rgba(255, 255, 255, 0.1)",a3:"rgba(255, 255, 255, 0.15)",a4:"rgba(255, 255, 255, 0.2)",a5:"rgba(255, 255, 255, 0.3)",a6:"rgba(255, 255, 255, 0.4)",a7:"rgba(255, 255, 255, 0.5)",a8:"rgba(255, 255, 255, 0.6)",a9:"rgba(255, 255, 255, 0.7)",a10:"rgba(255, 255, 255, 0.8)",a11:"rgba(255, 255, 255, 0.9)",a12:"rgba(255, 255, 255, 0.95)"},foreground:e("sand","12"),background:e("sand","2"),ring:e("blue","6"),muted:{DEFAULT:e("sand","3"),foreground:e("sand","10")},border:e("sand","5"),input:e("sand","4"),accent:e("blue","2"),sidebar:{DEFAULT:e("sand","3"),foreground:e("sand","11"),accent:"white","accent-foreground":e("orange","11"),border:e("sand","6"),ring:e("blue","6")},popover:{DEFAULT:"#FFFFFF",foreground:e("sand","11")}};exports.colors=d;exports.generateScale=o;exports.hashColor=l;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("./colors-c6Q-ORB_.cjs"),a=t=>{const r=Object.keys(o.colors.data).length,e=t%r;return Object.values(o.colors.data)[e]},s={card:"2px",button:"2px",input:"2px"},c={card:"16px",button:"8px",input:"8px"};exports.colors=o.colors;exports.borderRadius=c;exports.borderWidth=s;exports.getDataColor=a;
package/dist/theme.d.ts CHANGED
@@ -1,3 +1,15 @@
1
+ export declare const borderRadius: {
2
+ card: string;
3
+ button: string;
4
+ input: string;
5
+ };
6
+
7
+ export declare const borderWidth: {
8
+ card: string;
9
+ button: string;
10
+ input: string;
11
+ };
12
+
1
13
  export declare const colors: {
2
14
  readonly transparent: "transparent";
3
15
  readonly current: "currentColor";
@@ -5,11 +17,11 @@ export declare const colors: {
5
17
  readonly DEFAULT: "#FF7824";
6
18
  };
7
19
  readonly primary: {
8
- readonly 4: string;
9
- readonly 5: string;
10
20
  readonly 1: string;
11
21
  readonly 2: string;
12
22
  readonly 3: string;
23
+ readonly 4: string;
24
+ readonly 5: string;
13
25
  readonly 6: string;
14
26
  readonly 7: string;
15
27
  readonly 8: string;
@@ -36,11 +48,11 @@ export declare const colors: {
36
48
  readonly lightness: string;
37
49
  };
38
50
  readonly secondary: {
39
- readonly 4: string;
40
- readonly 5: string;
41
51
  readonly 1: string;
42
52
  readonly 2: string;
43
53
  readonly 3: string;
54
+ readonly 4: string;
55
+ readonly 5: string;
44
56
  readonly 6: string;
45
57
  readonly 7: string;
46
58
  readonly 8: string;
@@ -67,11 +79,11 @@ export declare const colors: {
67
79
  readonly lightness: string;
68
80
  };
69
81
  readonly tertiary: {
70
- readonly 4: string;
71
- readonly 5: string;
72
82
  readonly 1: string;
73
83
  readonly 2: string;
74
84
  readonly 3: string;
85
+ readonly 4: string;
86
+ readonly 5: string;
75
87
  readonly 6: string;
76
88
  readonly 7: string;
77
89
  readonly 8: string;
@@ -98,11 +110,11 @@ export declare const colors: {
98
110
  readonly lightness: string;
99
111
  };
100
112
  readonly quaternary: {
101
- readonly 4: string;
102
- readonly 5: string;
103
113
  readonly 1: string;
104
114
  readonly 2: string;
105
115
  readonly 3: string;
116
+ readonly 4: string;
117
+ readonly 5: string;
106
118
  readonly 6: string;
107
119
  readonly 7: string;
108
120
  readonly 8: string;
@@ -129,11 +141,11 @@ export declare const colors: {
129
141
  readonly lightness: string;
130
142
  };
131
143
  readonly quinary: {
132
- readonly 4: string;
133
- readonly 5: string;
134
144
  readonly 1: string;
135
145
  readonly 2: string;
136
146
  readonly 3: string;
147
+ readonly 4: string;
148
+ readonly 5: string;
137
149
  readonly 6: string;
138
150
  readonly 7: string;
139
151
  readonly 8: string;
@@ -160,11 +172,11 @@ export declare const colors: {
160
172
  readonly lightness: string;
161
173
  };
162
174
  readonly gray: {
163
- readonly 4: string;
164
- readonly 5: string;
165
175
  readonly 1: string;
166
176
  readonly 2: string;
167
177
  readonly 3: string;
178
+ readonly 4: string;
179
+ readonly 5: string;
168
180
  readonly 6: string;
169
181
  readonly 7: string;
170
182
  readonly 8: string;
@@ -191,11 +203,11 @@ export declare const colors: {
191
203
  readonly lightness: string;
192
204
  };
193
205
  readonly success: {
194
- readonly 4: string;
195
- readonly 5: string;
196
206
  readonly 1: string;
197
207
  readonly 2: string;
198
208
  readonly 3: string;
209
+ readonly 4: string;
210
+ readonly 5: string;
199
211
  readonly 6: string;
200
212
  readonly 7: string;
201
213
  readonly 8: string;
@@ -222,11 +234,11 @@ export declare const colors: {
222
234
  readonly lightness: string;
223
235
  };
224
236
  readonly warning: {
225
- readonly 4: string;
226
- readonly 5: string;
227
237
  readonly 1: string;
228
238
  readonly 2: string;
229
239
  readonly 3: string;
240
+ readonly 4: string;
241
+ readonly 5: string;
230
242
  readonly 6: string;
231
243
  readonly 7: string;
232
244
  readonly 8: string;
@@ -253,11 +265,11 @@ export declare const colors: {
253
265
  readonly lightness: string;
254
266
  };
255
267
  readonly danger: {
256
- readonly 4: string;
257
- readonly 5: string;
258
268
  readonly 1: string;
259
269
  readonly 2: string;
260
270
  readonly 3: string;
271
+ readonly 4: string;
272
+ readonly 5: string;
261
273
  readonly 6: string;
262
274
  readonly 7: string;
263
275
  readonly 8: string;
@@ -313,6 +325,23 @@ export declare const colors: {
313
325
  readonly a11: "rgba(255, 255, 255, 0.9)";
314
326
  readonly a12: "rgba(255, 255, 255, 0.95)";
315
327
  };
328
+ readonly data: {
329
+ readonly 1: "#1d4aff";
330
+ readonly 2: "#621da6";
331
+ readonly 3: "#42827e";
332
+ readonly 4: "#ce0e74";
333
+ readonly 5: "#f14f58";
334
+ readonly 6: "#7c440e";
335
+ readonly 7: "#529a0a";
336
+ readonly 8: "#0476fb";
337
+ readonly 9: "#fe729e";
338
+ readonly 10: "#35416b";
339
+ readonly 11: "#41cbc4";
340
+ readonly 12: "#b64b02";
341
+ readonly 13: "#e4a604";
342
+ readonly 14: "#a56eff";
343
+ readonly 15: "#30d5c8";
344
+ };
316
345
  readonly foreground: string;
317
346
  readonly background: string;
318
347
  readonly ring: string;
@@ -337,14 +366,6 @@ export declare const colors: {
337
366
  };
338
367
  };
339
368
 
340
- export declare function generateScale(name: string): Scale;
341
-
342
- export declare function hashColor(str: string): "primary" | "secondary" | "tertiary" | "quaternary" | "quinary";
343
-
344
- declare type Scale = Record<ScaleKeys, string>;
345
-
346
- declare type ScaleIndex = 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12;
347
-
348
- declare type ScaleKeys = `${ScaleIndex}` | `a${ScaleIndex}` | 'DEFAULT' | 'hover' | 'dark' | 'light' | 'lightness';
369
+ export declare const getDataColor: (index: number) => string;
349
370
 
350
371
  export { }