@vue-skuilder/standalone-ui 0.1.38 → 0.1.40

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.
@@ -25818,7 +25818,11 @@ async function initializeDataLayer(t) {
25818
25818
  if (dataLayerInstance) return logger.warn("Data layer already initialized. Returning existing instance."), dataLayerInstance;
25819
25819
  if (await initializeNavigatorRegistry(), t.options.localStoragePrefix && (ENV.LOCAL_STORAGE_PREFIX = t.options.localStoragePrefix), t.type === "couch") {
25820
25820
  if (!t.options.COUCHDB_SERVER_URL || !t.options.COUCHDB_SERVER_PROTOCOL) throw Error("Missing CouchDB server URL or protocol");
25821
- if (ENV.COUCHDB_SERVER_PROTOCOL = t.options.COUCHDB_SERVER_PROTOCOL, ENV.COUCHDB_SERVER_URL = t.options.COUCHDB_SERVER_URL, ENV.COUCHDB_USERNAME = t.options.COUCHDB_USERNAME, ENV.COUCHDB_PASSWORD = t.options.COUCHDB_PASSWORD, t.options.COUCHDB_PASSWORD && t.options.COUCHDB_USERNAME && typeof window < "u") {
25821
+ if (ENV.COUCHDB_SERVER_PROTOCOL = t.options.COUCHDB_SERVER_PROTOCOL, ENV.COUCHDB_SERVER_URL = t.options.COUCHDB_SERVER_URL, ENV.COUCHDB_USERNAME = t.options.COUCHDB_USERNAME, ENV.COUCHDB_PASSWORD = t.options.COUCHDB_PASSWORD, t.options.courseSync) {
25822
+ let { CourseSyncService: c } = await Promise.resolve().then(() => (init_CourseSyncService(), CourseSyncService_exports));
25823
+ c.getInstance().configure(t.options.courseSync);
25824
+ }
25825
+ if (t.options.COUCHDB_PASSWORD && t.options.COUCHDB_USERNAME && typeof window < "u") {
25822
25826
  let { CouchDBSyncStrategy: c } = await Promise.resolve().then(() => (init_CouchDBSyncStrategy(), CouchDBSyncStrategy_exports)), u = new c(), d = await (await BaseUser.instance(u, t.options.COUCHDB_USERNAME)).login(t.options.COUCHDB_USERNAME, t.options.COUCHDB_PASSWORD);
25823
25827
  d.ok ? logger.info(`Successfully authenticated as ${t.options.COUCHDB_USERNAME}`) : logger.warn(`Authentication failed: ${d.error}`);
25824
25828
  }
@@ -26595,7 +26599,7 @@ function mountSessionDebugger() {
26595
26599
  let t = window;
26596
26600
  t.skuilder = t.skuilder || {}, t.skuilder.session = sessionDebugAPI;
26597
26601
  }
26598
- var import___vite_browser_external, import___vite_browser_external$1, import___vite_browser_external$2, import_browser_ponyfill, import_browser_ponyfill$1, import_browser, _SessionController2, __defProp, __getOwnPropNames, __glob, __esm, __export, init_adminDB, init_classroomDB, init_SyncStrategy, isDevelopment, logger, init_logger, GuestUsername, log, DocType, DocTypePrefixes, init_types_legacy, init_util, pouchdb_setup_default, init_pouchdb_setup, init_dataDirectory, REVIEW_TIME_FORMAT, log2, init_userDBHelpers, Loggable, init_Loggable, UpdateQueue, init_updateQueue, UsrCrsData, init_user_course_relDB, CLIENT_CACHE, init_clientCache, AlreadyTaggedErr, init_courseAPI, courseLookupDBTitle, CourseLookup, init_courseLookupDB, PipelineDebugger_exports, _activePipeline, MAX_RUNS, runHistory, DISCARDED_KEEP_TOP, _uiContainer, _selectedRunIndex, _cardSearchQuery, pipelineDebugAPI, init_PipelineDebugger, CompositeGenerator_exports, AggregationMode, DEFAULT_AGGREGATION_MODE, FREQUENCY_BOOST_FACTOR, CompositeGenerator, init_CompositeGenerator, elo_exports, ELONavigator, init_elo, generators_exports, init_generators, prescribed_exports, DEFAULT_FRESHNESS_WINDOW, DEFAULT_MAX_DIRECT_PER_RUN, DEFAULT_MAX_SUPPORT_PER_RUN, DEFAULT_HIERARCHY_DEPTH, DEFAULT_MIN_COUNT, BASE_TARGET_SCORE, BASE_SUPPORT_SCORE, DISCOVERED_SUPPORT_SCORE, MAX_TARGET_MULTIPLIER, MAX_SUPPORT_MULTIPLIER, PRESCRIBED_DEBUG_VERSION, PrescribedCardsGenerator, init_prescribed, srs_exports, DEFAULT_HEALTHY_BACKLOG, MAX_BACKLOG_PRESSURE, SRSNavigator, init_srs, types_exports, init_types, globImport_generators, init_, DEFAULT_LEARNABLE_WEIGHT, init_contentNavigationStrategy, WeightedFilter_exports, WeightedFilter, init_WeightedFilter, eloDistance_exports, DEFAULT_HALF_LIFE, DEFAULT_MIN_MULTIPLIER, DEFAULT_MAX_MULTIPLIER, init_eloDistance, hierarchyDefinition_exports, DEFAULT_MIN_COUNT2, HierarchyDefinitionNavigator, init_hierarchyDefinition, userTagPreference_exports, UserTagPreferenceFilter, init_userTagPreference, filters_exports, init_filters, inferredPreferenceStub_exports, INFERRED_PREFERENCE_NAVIGATOR_STUB, init_inferredPreferenceStub, interferenceMitigator_exports, DEFAULT_MIN_COUNT3, DEFAULT_MIN_ELAPSED_DAYS, DEFAULT_INTERFERENCE_DECAY, InterferenceMitigatorNavigator, init_interferenceMitigator, relativePriority_exports, DEFAULT_PRIORITY, DEFAULT_PRIORITY_INFLUENCE, DEFAULT_COMBINE_MODE, RelativePriorityNavigator, init_relativePriority, types_exports2, init_types2, userGoalStub_exports, USER_GOAL_NAVIGATOR_STUB, init_userGoalStub, globImport_filters, init_2, init_gradient, MIN_OBSERVATIONS_FOR_UPDATE, LEARNING_RATE, MAX_WEIGHT_DELTA, MIN_R_SQUARED_FOR_GRADIENT, FLAT_GRADIENT_THRESHOLD, MAX_HISTORY_LENGTH, init_learning, init_signal, init_recording, MIN_SPREAD, MAX_SPREAD, MIN_WEIGHT, MAX_WEIGHT, init_orchestration, Pipeline_exports, VERBOSE_RESULTS, Pipeline, init_Pipeline, defaults_exports, init_defaults, PipelineAssembler_exports, PipelineAssembler, init_PipelineAssembler, globImport, init_3, navigators_exports, navigatorRegistry, Navigators, NavigatorRole, NavigatorRoles, ContentNavigator, init_navigators, CoursesDB, CourseDB, init_courseDB, classroomLookupDBTitle, CLASSROOM_CONFIG, ClassroomDBBase, StudentClassroomDB, TeacherClassroomDB, ClassroomLookupDB, init_classroomDB2, AdminDB, init_adminDB2, CourseSyncService, init_CourseSyncService, init_auth, CouchDBSyncStrategy_exports, log3, CouchDBSyncStrategy, init_CouchDBSyncStrategy, isBrowser, GUEST_LOCAL_DB, localUserDB, pouchDBincludeCredentialsConfig, REVIEW_TIME_FORMAT2, init_couch, log4, BaseUser, userCoursesDoc, userClassroomsDoc, init_BaseUserDB, init_common, PouchDataLayerProvider_exports, CouchDataLayerProvider, init_PouchDataLayerProvider, pathUtils, nodeFS, StaticDataUnpacker, init_StaticDataUnpacker, StaticCourseDB, init_courseDB2, StaticCoursesDB, init_coursesDB, NoOpSyncStrategy, init_NoOpSyncStrategy, StaticDataLayerProvider_exports, StaticDataLayerProvider, init_StaticDataLayerProvider, NOT_SET, ENV, dataLayerInstance, init_factory, TagFilteredContentSource, init_TagFilteredContentSource, init_contentSource, init_courseDB3, init_dataLayerProvider, init_userDB, init_interfaces, init_user, init_strategyState, init_userOutcome, init_cardProcessor, init_types3, init_bulkImport, userDBDebugAPI, init_UserDBDebugger, init_core, duration, SrsService, EloService, ResponseProcessor, CardHydrationService, ItemQueue, CouchDBToStaticPacker, DEFAULT_MIGRATION_OPTIONS, FileSystemError, nodeFS2, nodeFS3, nodePath, StaticToCouchDBMigrator, QuotaRoundRobinMixer, MAX_RUNS2, runHistory2, mixerDebugAPI, activeSession, sessionHistory, MAX_HISTORY, sessionDebugAPI, SessionController, init_dist = __esmMin((() => {
26602
+ var import___vite_browser_external, import___vite_browser_external$1, import___vite_browser_external$2, import_browser_ponyfill, import_browser_ponyfill$1, import_browser, _SessionController2, __defProp, __getOwnPropNames, __glob, __esm, __export, init_adminDB, init_classroomDB, init_SyncStrategy, isDevelopment, logger, init_logger, GuestUsername, log, DocType, DocTypePrefixes, init_types_legacy, init_util, pouchdb_setup_default, init_pouchdb_setup, init_dataDirectory, REVIEW_TIME_FORMAT, log2, init_userDBHelpers, Loggable, init_Loggable, UpdateQueue, init_updateQueue, UsrCrsData, init_user_course_relDB, CLIENT_CACHE, init_clientCache, AlreadyTaggedErr, init_courseAPI, courseLookupDBTitle, CourseLookup, init_courseLookupDB, PipelineDebugger_exports, _activePipeline, MAX_RUNS, runHistory, DISCARDED_KEEP_TOP, _uiContainer, _selectedRunIndex, _cardSearchQuery, pipelineDebugAPI, init_PipelineDebugger, CompositeGenerator_exports, AggregationMode, DEFAULT_AGGREGATION_MODE, FREQUENCY_BOOST_FACTOR, CompositeGenerator, init_CompositeGenerator, elo_exports, ELONavigator, init_elo, generators_exports, init_generators, prescribed_exports, DEFAULT_FRESHNESS_WINDOW, DEFAULT_MAX_DIRECT_PER_RUN, DEFAULT_MAX_SUPPORT_PER_RUN, DEFAULT_HIERARCHY_DEPTH, DEFAULT_MIN_COUNT, BASE_TARGET_SCORE, BASE_SUPPORT_SCORE, DISCOVERED_SUPPORT_SCORE, MAX_TARGET_MULTIPLIER, MAX_SUPPORT_MULTIPLIER, PRESCRIBED_DEBUG_VERSION, PrescribedCardsGenerator, init_prescribed, srs_exports, DEFAULT_HEALTHY_BACKLOG, MAX_BACKLOG_PRESSURE, SRSNavigator, init_srs, types_exports, init_types, globImport_generators, init_, DEFAULT_LEARNABLE_WEIGHT, init_contentNavigationStrategy, WeightedFilter_exports, WeightedFilter, init_WeightedFilter, eloDistance_exports, DEFAULT_HALF_LIFE, DEFAULT_MIN_MULTIPLIER, DEFAULT_MAX_MULTIPLIER, init_eloDistance, hierarchyDefinition_exports, DEFAULT_MIN_COUNT2, HierarchyDefinitionNavigator, init_hierarchyDefinition, userTagPreference_exports, UserTagPreferenceFilter, init_userTagPreference, filters_exports, init_filters, inferredPreferenceStub_exports, INFERRED_PREFERENCE_NAVIGATOR_STUB, init_inferredPreferenceStub, interferenceMitigator_exports, DEFAULT_MIN_COUNT3, DEFAULT_MIN_ELAPSED_DAYS, DEFAULT_INTERFERENCE_DECAY, InterferenceMitigatorNavigator, init_interferenceMitigator, relativePriority_exports, DEFAULT_PRIORITY, DEFAULT_PRIORITY_INFLUENCE, DEFAULT_COMBINE_MODE, RelativePriorityNavigator, init_relativePriority, types_exports2, init_types2, userGoalStub_exports, USER_GOAL_NAVIGATOR_STUB, init_userGoalStub, globImport_filters, init_2, init_gradient, MIN_OBSERVATIONS_FOR_UPDATE, LEARNING_RATE, MAX_WEIGHT_DELTA, MIN_R_SQUARED_FOR_GRADIENT, FLAT_GRADIENT_THRESHOLD, MAX_HISTORY_LENGTH, init_learning, init_signal, init_recording, MIN_SPREAD, MAX_SPREAD, MIN_WEIGHT, MAX_WEIGHT, init_orchestration, Pipeline_exports, VERBOSE_RESULTS, Pipeline, init_Pipeline, defaults_exports, init_defaults, PipelineAssembler_exports, PipelineAssembler, init_PipelineAssembler, globImport, init_3, navigators_exports, navigatorRegistry, Navigators, NavigatorRole, NavigatorRoles, ContentNavigator, init_navigators, CoursesDB, CourseDB, init_courseDB, classroomLookupDBTitle, CLASSROOM_CONFIG, ClassroomDBBase, StudentClassroomDB, TeacherClassroomDB, ClassroomLookupDB, init_classroomDB2, AdminDB, init_adminDB2, CourseSyncService_exports, DEFAULT_REPLICATION, CourseSyncService, init_CourseSyncService, init_auth, CouchDBSyncStrategy_exports, log3, CouchDBSyncStrategy, init_CouchDBSyncStrategy, isBrowser, GUEST_LOCAL_DB, localUserDB, pouchDBincludeCredentialsConfig, REVIEW_TIME_FORMAT2, init_couch, log4, BaseUser, userCoursesDoc, userClassroomsDoc, init_BaseUserDB, init_common, PouchDataLayerProvider_exports, CouchDataLayerProvider, init_PouchDataLayerProvider, pathUtils, nodeFS, StaticDataUnpacker, init_StaticDataUnpacker, StaticCourseDB, init_courseDB2, StaticCoursesDB, init_coursesDB, NoOpSyncStrategy, init_NoOpSyncStrategy, StaticDataLayerProvider_exports, StaticDataLayerProvider, init_StaticDataLayerProvider, NOT_SET, ENV, dataLayerInstance, init_factory, TagFilteredContentSource, init_TagFilteredContentSource, init_contentSource, init_courseDB3, init_dataLayerProvider, init_userDB, init_interfaces, init_user, init_strategyState, init_userOutcome, init_cardProcessor, init_types3, init_bulkImport, userDBDebugAPI, init_UserDBDebugger, init_core, duration, SrsService, EloService, ResponseProcessor, CardHydrationService, ItemQueue, CouchDBToStaticPacker, DEFAULT_MIGRATION_OPTIONS, FileSystemError, nodeFS2, nodeFS3, nodePath, StaticToCouchDBMigrator, QuotaRoundRobinMixer, MAX_RUNS2, runHistory2, mixerDebugAPI, activeSession, sessionHistory, MAX_HISTORY, sessionDebugAPI, SessionController, init_dist = __esmMin((() => {
26599
26603
  init_defineProperty(), init_index_browser_es$5(), init_index_browser_es(), init_index_es(), import___vite_browser_external = /* @__PURE__ */ __toESM$2(require___vite_browser_external(), 1), import___vite_browser_external$1 = /* @__PURE__ */ __toESM$2(require___vite_browser_external(), 1), import___vite_browser_external$2 = /* @__PURE__ */ __toESM$2(require___vite_browser_external(), 1), init_moment(), init_dist$1(), init_esm_browser(), import_browser_ponyfill = /* @__PURE__ */ __toESM$2(require_browser_ponyfill(), 1), import_browser_ponyfill$1 = /* @__PURE__ */ __toESM$2(require_browser_ponyfill(), 1), import_browser = /* @__PURE__ */ __toESM$2(require_browser(), 1), __defProp = Object.defineProperty, __getOwnPropNames = Object.getOwnPropertyNames, __glob = (t) => (c) => {
26600
26604
  var u = t[c];
26601
26605
  if (u) return u();
@@ -28943,15 +28947,24 @@ ${t.stack}` : JSON.stringify(t);
28943
28947
  }));
28944
28948
  }
28945
28949
  };
28946
- } }), init_CourseSyncService = __esm({ "src/impl/couch/CourseSyncService.ts"() {
28950
+ } }), CourseSyncService_exports = {}, __export(CourseSyncService_exports, { CourseSyncService: () => CourseSyncService }), init_CourseSyncService = __esm({ "src/impl/couch/CourseSyncService.ts"() {
28947
28951
  var t;
28948
- init_pouchdb_setup(), init_couch(), init_logger(), CourseSyncService = (t = class _CourseSyncService {
28952
+ init_pouchdb_setup(), init_couch(), init_logger(), DEFAULT_REPLICATION = {
28953
+ batchSize: 1e3,
28954
+ batchesLimit: 5
28955
+ }, CourseSyncService = (t = class _CourseSyncService {
28949
28956
  constructor() {
28950
- _defineProperty$2(this, "entries", /* @__PURE__ */ new Map());
28957
+ _defineProperty$2(this, "entries", /* @__PURE__ */ new Map()), _defineProperty$2(this, "replicationOptions", DEFAULT_REPLICATION);
28951
28958
  }
28952
28959
  static getInstance() {
28953
28960
  return _CourseSyncService.instance || (_CourseSyncService.instance = new _CourseSyncService()), _CourseSyncService.instance;
28954
28961
  }
28962
+ configure(t) {
28963
+ t.replication && (this.replicationOptions = {
28964
+ ...DEFAULT_REPLICATION,
28965
+ ...t.replication
28966
+ }, logger.info(`[CourseSyncService] Replication configured: batch_size=${this.replicationOptions.batchSize}, batches_limit=${this.replicationOptions.batchesLimit}`));
28967
+ }
28955
28968
  static resetInstance() {
28956
28969
  if (_CourseSyncService.instance) {
28957
28970
  for (let [, t] of _CourseSyncService.instance.entries) t.localDB && t.localDB.close().catch(() => {});
@@ -28998,7 +29011,7 @@ ${t.stack}` : JSON.stringify(t);
28998
29011
  let d = this.localDBName(t), m = new pouchdb_setup_default(d);
28999
29012
  await this.isLocalEpochStale(t, m) && (logger.info(`[CourseSyncService] Stale local DB detected for course ${t} \u2014 destroying before sync`), await m.destroy(), m = new pouchdb_setup_default(d)), c.localDB = m;
29000
29013
  let g = this.getRemoteDB(t), b = Date.now();
29001
- logger.info(`[CourseSyncService] Starting one-shot replication for course ${t}`);
29014
+ logger.info(`[CourseSyncService] Starting one-shot replication for course ${t} (batch_size=${this.replicationOptions.batchSize}, batches_limit=${this.replicationOptions.batchesLimit})`);
29002
29015
  let S = await this.replicate(g, m), C = Date.now() - b;
29003
29016
  logger.info(`[CourseSyncService] Replication complete for course ${t}: ${S.docs_written} docs in ${C}ms`), c.status = { state: "warming-views" };
29004
29017
  let w = Date.now();
@@ -29032,7 +29045,10 @@ ${t.stack}` : JSON.stringify(t);
29032
29045
  }
29033
29046
  replicate(t, c) {
29034
29047
  return new Promise((u, d) => {
29035
- pouchdb_setup_default.replicate(t, c, {}).on("complete", (t) => {
29048
+ pouchdb_setup_default.replicate(t, c, {
29049
+ batch_size: this.replicationOptions.batchSize,
29050
+ batches_limit: this.replicationOptions.batchesLimit
29051
+ }).on("complete", (t) => {
29036
29052
  u(t);
29037
29053
  }).on("error", (t) => {
29038
29054
  d(t);
@@ -31690,7 +31706,7 @@ ${c.id}:`), logger.info(JSON.stringify(c.doc, null, 2));
31690
31706
  return this.newQ.toString + "\n" + this.reviewQ.toString + "\n" + this.failedQ.toString;
31691
31707
  }
31692
31708
  constructor(t, c, u, d, m, g) {
31693
- super(), _defineProperty$2(this, "_className", "SessionController"), _defineProperty$2(this, "services", void 0), _defineProperty$2(this, "srsService", void 0), _defineProperty$2(this, "eloService", void 0), _defineProperty$2(this, "hydrationService", void 0), _defineProperty$2(this, "mixer", void 0), _defineProperty$2(this, "dataLayer", void 0), _defineProperty$2(this, "courseNameCache", /* @__PURE__ */ new Map()), _defineProperty$2(this, "_defaultBatchLimit", 20), _defineProperty$2(this, "_initialReviewCap", 200), _defineProperty$2(this, "sources", void 0), _defineProperty$2(this, "_sessionRecord", []), _defineProperty$2(this, "_currentCard", null), _defineProperty$2(this, "reviewQ", new ItemQueue()), _defineProperty$2(this, "newQ", new ItemQueue()), _defineProperty$2(this, "failedQ", new ItemQueue()), _defineProperty$2(this, "_replanPromise", null), _defineProperty$2(this, "_wellIndicatedRemaining", 0), _defineProperty$2(this, "_suppressQualityReplan", !1), _defineProperty$2(this, "_depletionReplanAttempted", !1), _defineProperty$2(this, "_minCardsGuarantee", 0), _defineProperty$2(this, "startTime", void 0), _defineProperty$2(this, "endTime", void 0), _defineProperty$2(this, "_secondsRemaining", void 0), _defineProperty$2(this, "_intervalHandle", void 0), this.dataLayer = u, this.mixer = m || new QuotaRoundRobinMixer(), this.srsService = new SrsService(u.getUserDB()), this.eloService = new EloService(u, u.getUserDB()), this.hydrationService = new CardHydrationService(d, (t) => u.getCourseDB(t), () => this._getItemsToHydrate()), this.services = { response: new ResponseProcessor(this.srsService, this.eloService) }, this.sources = t, this.startTime = /* @__PURE__ */ new Date(), this._secondsRemaining = c, this.endTime = new Date(this.startTime.valueOf() + 1e3 * this._secondsRemaining), g?.defaultBatchLimit !== void 0 && (this._defaultBatchLimit = g.defaultBatchLimit), g?.initialReviewCap !== void 0 && (this._initialReviewCap = g.initialReviewCap), this.log(`Session constructed:
31709
+ super(), _defineProperty$2(this, "_className", "SessionController"), _defineProperty$2(this, "services", void 0), _defineProperty$2(this, "srsService", void 0), _defineProperty$2(this, "eloService", void 0), _defineProperty$2(this, "hydrationService", void 0), _defineProperty$2(this, "mixer", void 0), _defineProperty$2(this, "dataLayer", void 0), _defineProperty$2(this, "courseNameCache", /* @__PURE__ */ new Map()), _defineProperty$2(this, "_defaultBatchLimit", 20), _defineProperty$2(this, "_initialReviewCap", 200), _defineProperty$2(this, "sources", void 0), _defineProperty$2(this, "_sessionRecord", []), _defineProperty$2(this, "_currentCard", null), _defineProperty$2(this, "reviewQ", new ItemQueue()), _defineProperty$2(this, "newQ", new ItemQueue()), _defineProperty$2(this, "failedQ", new ItemQueue()), _defineProperty$2(this, "_replanPromise", null), _defineProperty$2(this, "_wellIndicatedRemaining", 0), _defineProperty$2(this, "_suppressQualityReplan", !1), _defineProperty$2(this, "_minCardsGuarantee", 0), _defineProperty$2(this, "startTime", void 0), _defineProperty$2(this, "endTime", void 0), _defineProperty$2(this, "_secondsRemaining", void 0), _defineProperty$2(this, "_intervalHandle", void 0), this.dataLayer = u, this.mixer = m || new QuotaRoundRobinMixer(), this.srsService = new SrsService(u.getUserDB()), this.eloService = new EloService(u, u.getUserDB()), this.hydrationService = new CardHydrationService(d, (t) => u.getCourseDB(t), () => this._getItemsToHydrate()), this.services = { response: new ResponseProcessor(this.srsService, this.eloService) }, this.sources = t, this.startTime = /* @__PURE__ */ new Date(), this._secondsRemaining = c, this.endTime = new Date(this.startTime.valueOf() + 1e3 * this._secondsRemaining), g?.defaultBatchLimit !== void 0 && (this._defaultBatchLimit = g.defaultBatchLimit), g?.initialReviewCap !== void 0 && (this._initialReviewCap = g.initialReviewCap), this.log(`Session constructed:
31694
31710
  startTime: ${this.startTime}
31695
31711
  endTime: ${this.endTime}
31696
31712
  defaultBatchLimit: ${this._defaultBatchLimit}
@@ -31723,9 +31739,7 @@ ${c.id}:`), logger.info(JSON.stringify(c.doc, null, 2));
31723
31739
  }, 1e3);
31724
31740
  }
31725
31741
  async requestReplan(t) {
31726
- let c = this.normalizeReplanOptions(t);
31727
- (c.hints || c.label || c.limit) && (this._depletionReplanAttempted = !1);
31728
- let u = this._replanHasIntent(c);
31742
+ let c = this.normalizeReplanOptions(t), u = this._replanHasIntent(c);
31729
31743
  if (this._replanPromise) {
31730
31744
  if (!u) return this.log("Replan already in progress, coalescing unhinted auto-replan"), this._replanPromise;
31731
31745
  let t = c.label ? ` [${c.label}]` : "";
@@ -31758,6 +31772,12 @@ ${c.id}:`), logger.info(JSON.stringify(c.doc, null, 2));
31758
31772
  let d = t.label ? ` [${t.label}]` : "";
31759
31773
  this.log(`Mid-session replan requested${d} (limit: ${t.limit ?? "default"}, mode: ${t.mode ?? "replace"}${t.hints ? ", with hints" : ""})`), t.minFollowUpCards !== void 0 && t.minFollowUpCards > 0 && (this._minCardsGuarantee = Math.max(this._minCardsGuarantee, t.minFollowUpCards), this.log(`[Replan] Card guarantee set to ${this._minCardsGuarantee}`)), await this._executeReplan(t);
31760
31774
  }
31775
+ async _replanUncoalesced(t) {
31776
+ let c = this._runReplan(t);
31777
+ this._replanPromise = c.finally(() => {
31778
+ this._replanPromise === c && (this._replanPromise = null);
31779
+ }), await c;
31780
+ }
31761
31781
  normalizeReplanOptions(t) {
31762
31782
  if (!t) return {};
31763
31783
  let c = [
@@ -31775,7 +31795,7 @@ ${c.id}:`), logger.info(JSON.stringify(c.doc, null, 2));
31775
31795
  additive: u === "merge",
31776
31796
  limit: c
31777
31797
  });
31778
- this._wellIndicatedRemaining = d, c !== void 0 && c < this._defaultBatchLimit ? (this._suppressQualityReplan = !0, this.log(`[Replan] Burst mode (limit=${c}): suppressing quality-based auto-replan`)) : this._suppressQualityReplan = !1, d >= 0 && d < _SessionController.MIN_WELL_INDICATED && this.log(`[Replan] Only ${d}/${_SessionController.MIN_WELL_INDICATED} well-indicated cards after replan`), this.newQ.length > 0 && (this._depletionReplanAttempted = !1), await this.hydrationService.ensureHydratedCards();
31798
+ this._wellIndicatedRemaining = d, c !== void 0 && c < this._defaultBatchLimit ? (this._suppressQualityReplan = !0, this.log(`[Replan] Burst mode (limit=${c}): suppressing quality-based auto-replan`)) : this._suppressQualityReplan = !1, d >= 0 && d < _SessionController.MIN_WELL_INDICATED && this.log(`[Replan] Only ${d}/${_SessionController.MIN_WELL_INDICATED} well-indicated cards after replan`), await this.hydrationService.ensureHydratedCards();
31779
31799
  let m = t.label ? ` [${t.label}]` : "";
31780
31800
  this.log(`Replan complete${m}: newQ now has ${this.newQ.length} cards (mode=${u})`), snapshotQueues(this.reviewQ.length, this.newQ.length, this.failedQ.length);
31781
31801
  }
@@ -31914,13 +31934,21 @@ ${c.id}:`), logger.info(JSON.stringify(c.doc, null, 2));
31914
31934
  return this._secondsRemaining - (d + m) > 20 ? (c = .5, u = .9) : this._secondsRemaining - d > 20 ? (c = .05, u = .9) : (c = .01, u = .1), this.failedQ.length === 0 && (u = 1), this.reviewQ.length === 0 && (c = u), t < c && this.newQ.length ? this.newQ.peek(0) : t < u && this.reviewQ.length ? this.reviewQ.peek(0) : this.failedQ.length ? this.failedQ.peek(0) : (this.log("No more cards available for the session!"), null);
31915
31935
  }
31916
31936
  async nextCard(t = "dismiss-success") {
31917
- if (this.dismissCurrentCard(t), this._minCardsGuarantee > 0 && (this._minCardsGuarantee--, this.log(`[CardGuarantee] ${this._minCardsGuarantee} guaranteed cards remaining`)), this._replanPromise && (this.log("nextCard: awaiting in-flight replan before drawing"), await this._replanPromise), this.newQ.length <= 1 && this._secondsRemaining > 0 && !this._replanPromise && !this._depletionReplanAttempted) {
31918
- this._suppressQualityReplan = !1, this._depletionReplanAttempted = !0;
31937
+ if (this.dismissCurrentCard(t), this._minCardsGuarantee > 0 && (this._minCardsGuarantee--, this.log(`[CardGuarantee] ${this._minCardsGuarantee} guaranteed cards remaining`)), this._replanPromise && this.newQ.length === 0 && this.reviewQ.length === 0 && this.failedQ.length === 0 && (this.log("nextCard: queues empty, awaiting in-flight replan before drawing"), await this._replanPromise), this.newQ.length <= 1 && this._secondsRemaining > 0 && !this._replanPromise) {
31938
+ this._suppressQualityReplan = !1;
31919
31939
  let t = this.reviewQ.length + this.failedQ.length;
31920
- this.newQ.length === 0 && t === 0 ? (this.log(`[AutoReplan:depletion] All queues empty with ${this._secondsRemaining}s remaining. Awaiting replan.`), await this.requestReplan()) : (this.log(`[AutoReplan:depletion] newQ has ${this.newQ.length} card(s) (${t} in other queues) with ${this._secondsRemaining}s remaining. Triggering background replan.`), this.requestReplan());
31940
+ this.log(`[AutoReplan:depletion] newQ has ${this.newQ.length} card(s) (${t} in other queues) with ${this._secondsRemaining}s remaining. Triggering background replan.`), this.requestReplan();
31921
31941
  }
31922
31942
  if (!this._suppressQualityReplan && this._wellIndicatedRemaining <= 3 && this.newQ.length > 0 && !this._replanPromise && (this.log(`[AutoReplan:quality] ${this._wellIndicatedRemaining} well-indicated cards remaining (newQ: ${this.newQ.length}). Triggering background replan.`), this.requestReplan()), this._secondsRemaining <= 0 && this.failedQ.length === 0 && this._minCardsGuarantee <= 0) return this._currentCard = null, endSessionTracking(), null;
31923
- let c = 20;
31943
+ let c = 3, u = 250, d = 0;
31944
+ for (; this._secondsRemaining > 0 && this.newQ.length === 0 && this.reviewQ.length === 0 && this.failedQ.length === 0;) if (this.log(`[WedgeBreaker] All queues empty with ${this._secondsRemaining}s remaining. Running pipeline (attempt ${d + 1}/3).`), await this._replanUncoalesced({ label: "wedge-breaker" }), this.newQ.length === 0 && this.reviewQ.length === 0 && this.failedQ.length === 0) {
31945
+ if (d++, d >= 3) {
31946
+ this.log("[WedgeBreaker] Pipeline returned no content 3 consecutive times. Giving up; session will end.");
31947
+ break;
31948
+ }
31949
+ await new Promise((t) => setTimeout(t, 250));
31950
+ } else d = 0;
31951
+ let m = 20;
31924
31952
  for (let t = 0; t < 20; t++) {
31925
31953
  let t = this._selectNextItemToHydrate();
31926
31954
  if (!t) return this._currentCard = null, endSessionTracking(), null;