@artooi/ag-ui-web-component 0.41.2 → 0.42.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
@@ -1731,11 +1731,19 @@ var ToolDispatch = class {
1731
1731
  * Execute one frontend tool call the round produced, against its own card:
1732
1732
  * refused when the page moved under the round, asked about when a rule gates
1733
1733
  * it, and settled with what the handler returned or threw.
1734
+ *
1735
+ * Every await below is a place the run can end, so each is followed by a
1736
+ * check that it has not. A Stop while the host's predicate is pending ends
1737
+ * the call there, and one while the card is open declines it. A handover
1738
+ * during any of the three leaves the call with no transcript to draw in and
1739
+ * no store to write to, so it does neither.
1734
1740
  */
1735
1741
  async execute(call) {
1736
1742
  if (skillNameFrom(call) !== null) {
1737
1743
  return null;
1738
1744
  }
1745
+ const tenure = this.#host.tenure();
1746
+ const threadId = this.#host.threadId();
1739
1747
  const card = this.#host.transcript.cardFor(call);
1740
1748
  this.#host.transcript.forgetCard(call.id);
1741
1749
  this.#host.transcript.setCardElement(call.id, card.element);
@@ -1752,7 +1760,12 @@ var ToolDispatch = class {
1752
1760
  this.#host.transcript.showPending();
1753
1761
  return { content: `Error: ${message}`, error: message, outcome: TOOL_OUTCOME.FAILED };
1754
1762
  }
1763
+ const asking = this.#host.decision.open();
1755
1764
  const rule = await this.#confirmationRule(call, tool);
1765
+ this.#host.decision.close();
1766
+ if (asking.aborted) {
1767
+ return this.#abandoned(card);
1768
+ }
1756
1769
  if (rule === "unanswered") {
1757
1770
  const message = this.#host.strings().confirmCheckFailed;
1758
1771
  card.settle(TOOL_CALL_STATUS.DECLINED, message);
@@ -1776,6 +1789,9 @@ var ToolDispatch = class {
1776
1789
  this.#host.transcript.follow();
1777
1790
  const accepted = await decision;
1778
1791
  this.#host.decision.close();
1792
+ if (this.#host.tenure() !== tenure) {
1793
+ return null;
1794
+ }
1779
1795
  card.recordDecision(accepted ? "approved" : "declined");
1780
1796
  if (!accepted) {
1781
1797
  const message = this.#host.strings().declinedAction;
@@ -1783,13 +1799,19 @@ var ToolDispatch = class {
1783
1799
  this.#host.transcript.showPending();
1784
1800
  return { content: message, outcome: TOOL_OUTCOME.DENIED };
1785
1801
  }
1802
+ if (signal.aborted) {
1803
+ return this.#abandoned(card);
1804
+ }
1786
1805
  }
1787
1806
  const navigates = isNavigates(tool.parameters) && this.#host.navigate() === null;
1788
1807
  if (navigates) {
1789
- this.#host.conversationStore().saveCheckpoint(this.#host.threadId(), { toolCallId: call.id });
1808
+ this.#host.conversationStore().saveCheckpoint(threadId, { toolCallId: call.id });
1790
1809
  }
1791
1810
  try {
1792
1811
  const result = await tool.handler(call.args, call.id);
1812
+ if (this.#host.tenure() !== tenure) {
1813
+ return null;
1814
+ }
1793
1815
  if (tool.render !== void 0) {
1794
1816
  this.#host.transcript.renderToolOutput(tool.render, call);
1795
1817
  }
@@ -1802,8 +1824,11 @@ var ToolDispatch = class {
1802
1824
  this.#host.transcript.showPending();
1803
1825
  return { content };
1804
1826
  } catch (error) {
1827
+ if (this.#host.tenure() !== tenure) {
1828
+ return null;
1829
+ }
1805
1830
  if (navigates) {
1806
- this.#host.conversationStore().saveCheckpoint(this.#host.threadId(), null);
1831
+ this.#host.conversationStore().saveCheckpoint(threadId, null);
1807
1832
  }
1808
1833
  const message = error instanceof Error ? error.message : String(error);
1809
1834
  card.settle(TOOL_CALL_STATUS.ERROR, message);
@@ -1960,6 +1985,25 @@ var ToolDispatch = class {
1960
1985
  }
1961
1986
  return isDestructive(tool.parameters) ? "destructive" : null;
1962
1987
  }
1988
+ /**
1989
+ * Settle a call whose run ended while it waited, and give the loop nothing.
1990
+ *
1991
+ * The card is settled here because nothing else will: dispatch took it out
1992
+ * of the end-of-run sweep before it waited, so left alone it read "running…"
1993
+ * for good. It says the call did not finish, which is true -- nothing ran and
1994
+ * nobody refused it.
1995
+ *
1996
+ * `null` rather than a result, because a stopped run has no next round to
1997
+ * send one in. The loop moves on and finds the run stopped, and the call is
1998
+ * left unanswered like every call after it in the round, so the client
1999
+ * answers it as not finished on the next request -- in the same words as
2000
+ * this card. After a handover the card is in a transcript already cleared,
2001
+ * and settling it there is seen by no one.
2002
+ */
2003
+ #abandoned(card) {
2004
+ card.settle(TOOL_CALL_STATUS.INTERRUPTED, this.#host.strings().callNotFinished);
2005
+ return null;
2006
+ }
1963
2007
  /**
1964
2008
  * Whether the page moved since the current round's context was built.
1965
2009
  *
@@ -1998,12 +2042,12 @@ function seriesColor(index) {
1998
2042
  }
1999
2043
  function geometryFor(width) {
2000
2044
  const w = Math.max(MIN_WIDTH, width);
2001
- const h = Math.min(MAX_HEIGHT, Math.max(MIN_HEIGHT, Math.round(w * HEIGHT_RATIO)));
2045
+ const h2 = Math.min(MAX_HEIGHT, Math.max(MIN_HEIGHT, Math.round(w * HEIGHT_RATIO)));
2002
2046
  return {
2003
2047
  width: w,
2004
- height: h,
2048
+ height: h2,
2005
2049
  plotW: w - PAD.left - PAD.right,
2006
- plotH: h - PAD.top - PAD.bottom
2050
+ plotH: h2 - PAD.top - PAD.bottom
2007
2051
  };
2008
2052
  }
2009
2053
  function el(name, attrs) {
@@ -3065,6 +3109,12 @@ var VoiceInput = class {
3065
3109
  this.#fail(this.#strings.transcriptionFailed);
3066
3110
  return;
3067
3111
  }
3112
+ if (this.#disposed) {
3113
+ for (const track of stream.getTracks()) {
3114
+ track.stop();
3115
+ }
3116
+ return;
3117
+ }
3068
3118
  this.#stream = stream;
3069
3119
  this.#chunks = [];
3070
3120
  this.#hitCap = false;
@@ -3095,10 +3145,16 @@ var VoiceInput = class {
3095
3145
  }
3096
3146
  }
3097
3147
  /**
3098
- * Tear the control down, for a host element removed mid-recording. Stops any
3099
- * live `MediaRecorder`, releases the mic tracks so the browser's recording
3100
- * indicator clears, and suppresses the pending transcription — a
3101
- * disconnected control must not fire `onText` into a detached element.
3148
+ * Tear the control down, for a host element removed mid-recording or handed
3149
+ * to the next principal. Stops any live `MediaRecorder`, releases the mic
3150
+ * tracks so the browser's recording indicator clears, and suppresses the
3151
+ * pending transcription — a disconnected control must not fire `onText` into
3152
+ * a detached element.
3153
+ *
3154
+ * Disposal is final: nothing un-disposes an instance, and the host's next
3155
+ * wiring builds a new one. So the disposed flag alone tells a stale
3156
+ * continuation from a live one, and a clip already posted when this runs is
3157
+ * dropped whenever its answer arrives.
3102
3158
  */
3103
3159
  dispose() {
3104
3160
  this.#disposed = true;
@@ -3118,6 +3174,9 @@ var VoiceInput = class {
3118
3174
  const audio = new Blob(this.#chunks, { type: mimeType || "audio/webm" });
3119
3175
  try {
3120
3176
  const text4 = await this.#transcribe(audio);
3177
+ if (this.#disposed) {
3178
+ return;
3179
+ }
3121
3180
  this.#setState("idle");
3122
3181
  if (this.#hitCap) {
3123
3182
  this.element.title = fillUiString(this.#strings.recordingLimit, {
@@ -3141,6 +3200,9 @@ var VoiceInput = class {
3141
3200
  this.#stream = null;
3142
3201
  }
3143
3202
  #fail(message) {
3203
+ if (this.#disposed) {
3204
+ return;
3205
+ }
3144
3206
  this.#releaseStream();
3145
3207
  this.#recorder = null;
3146
3208
  this.#setState("idle");
@@ -4104,6 +4166,8 @@ function toolStatusFromOutcome(outcome) {
4104
4166
  }
4105
4167
 
4106
4168
  // src/ui/history/conversation_history.ts
4169
+ var UNHELD = Object.freeze({ release: () => {
4170
+ } });
4107
4171
  var ConversationHistory = class {
4108
4172
  #host;
4109
4173
  /** The active thread's id. Empty until the element connects. */
@@ -4119,9 +4183,20 @@ var ConversationHistory = class {
4119
4183
  * the one it continued is still on screen when it saves.
4120
4184
  */
4121
4185
  #cleared = 0;
4122
- // Bumped on every rehydrate; a replay whose generation is stale (a newer
4123
- // thread switch started while it awaited a slow store) drops its result.
4186
+ /**
4187
+ * Which restore may draw: bumped by every rehydrate, and by every clear of
4188
+ * the conversation on screen. A restore whose generation is stale draws
4189
+ * nothing more and resumes nothing: a newer one has started, or New chat, a
4190
+ * thread switch or a `user-key` handover has cleared what it was restoring.
4191
+ */
4124
4192
  #generation = 0;
4193
+ /**
4194
+ * The conversation the latest restore claimed, written by every restore as
4195
+ * it starts; `null` before the first. It speaks for the restore now current
4196
+ * only while its generation is the current one, because clearing the
4197
+ * conversation moves that on. See `#forgetStopped` for the one reader.
4198
+ */
4199
+ #claim = null;
4125
4200
  /** Built lazily from `data-runs-url`; `null` when the host didn't opt in. */
4126
4201
  #runIndex = null;
4127
4202
  /**
@@ -4169,6 +4244,7 @@ var ConversationHistory = class {
4169
4244
  forgetRestored() {
4170
4245
  this.#restored = [];
4171
4246
  this.#cleared += 1;
4247
+ this.#generation += 1;
4172
4248
  }
4173
4249
  /** Delete the active thread if nothing was ever sent in it. */
4174
4250
  reapUnsent() {
@@ -4281,6 +4357,7 @@ var ConversationHistory = class {
4281
4357
  this.#refuse(this.#host.strings().continueNeedsTurn);
4282
4358
  return;
4283
4359
  }
4360
+ this.#host.recordTurn(content);
4284
4361
  this.#host.input.value = "";
4285
4362
  this.#host.autoGrow();
4286
4363
  const cleared = this.#cleared;
@@ -4307,6 +4384,10 @@ var ConversationHistory = class {
4307
4384
  });
4308
4385
  this.#continuation = client;
4309
4386
  try {
4387
+ this.#host.announceTurn(content);
4388
+ if (this.#continuation !== client) {
4389
+ return;
4390
+ }
4310
4391
  await client.send(content);
4311
4392
  } finally {
4312
4393
  if (this.#continuation === client) {
@@ -4353,48 +4434,197 @@ var ConversationHistory = class {
4353
4434
  * because the resume path answers it from the page the reload landed on; that
4354
4435
  * exclusion is held by "resumes with the landed page's result, and its card says
4355
4436
  * so" in `ag_ui_chat_reload_mid_run.test.ts`.
4437
+ *
4438
+ * **A restore that resumes holds the composer from before the load.** The
4439
+ * resume is a run, and it starts only once the store has answered. With a
4440
+ * remote store that is a real request, and a send, a Retry or a pick in it
4441
+ * was refused by nothing: each built the conversation's client before the
4442
+ * conversation had loaded, so a send went out carrying none of it and its
4443
+ * first save replaced the stored one, and the resume then ran on that same
4444
+ * client as a second run, answering a call the request no longer held. So
4445
+ * the composer is held as a send holds it, and the resume gives way to
4446
+ * nothing: what was typed parks behind the resumed run and goes out after its
4447
+ * answer, and a host's send or Retry is refused as it is behind any run.
4448
+ *
4449
+ * The other way round, the resume standing down for the send, was rejected.
4450
+ * The send that got in first had already gone out without the conversation,
4451
+ * so standing down kept that loss, and it also dropped the run the navigation
4452
+ * was part of, which the user asked for before the reload: the agent stopped
4453
+ * halfway through the task, with the navigating call never answered.
4454
+ *
4455
+ * **A restore stops where it was stopped, held or not.** New chat, a thread
4456
+ * switch, a `user-key` handover, a newer restore or the element leaving the
4457
+ * page can each come while the store answers, and from host code the restore
4458
+ * runs itself: the activity and tool renderers each replayed message draws
4459
+ * through, and `navigationResult`. From then on it draws nothing more and
4460
+ * resumes nothing. The hold cannot say so, because a restore with no run to
4461
+ * resume holds nothing. So the restore asks its generation, which clearing
4462
+ * the conversation moves on as a newer restore does, and asks it after the
4463
+ * load, after each replayed message -- as a Retry asks after each one -- and
4464
+ * once more before the resume. Stopped by anything but the element leaving
4465
+ * the page, it also forgets the checkpoint it loaded, since that was a Stop
4466
+ * for the run it would have resumed -- unless what replaced it is a restore
4467
+ * of the same conversation, still current, which answers for that run
4468
+ * instead; see `#forgetStopped`.
4469
+ *
4470
+ * What a restore with no run to resume still does not do is refuse a send
4471
+ * made while it loads. That send goes out without the stored conversation,
4472
+ * and its save replaces it.
4356
4473
  */
4357
4474
  async rehydrate() {
4358
4475
  this.#generation += 1;
4359
4476
  const generation = this.#generation;
4360
- this.#host.element.setAttribute("data-restoring", "");
4361
- let messages;
4477
+ const threadId = this.#threadId;
4478
+ const store = this.#host.conversationStore();
4479
+ this.#claim = { generation, store, threadId };
4480
+ const checkpoint = store.loadCheckpoint(threadId);
4481
+ const hold = checkpoint === null ? UNHELD : this.#host.holdRun();
4362
4482
  try {
4363
- messages = await this.#host.conversationStore().loadMessages(this.#threadId);
4364
- } finally {
4365
- if (generation === this.#generation) {
4366
- this.#host.element.removeAttribute("data-restoring");
4483
+ this.#host.element.setAttribute("data-restoring", "");
4484
+ let messages;
4485
+ try {
4486
+ messages = await store.loadMessages(threadId);
4487
+ } finally {
4488
+ if (generation === this.#generation) {
4489
+ this.#host.element.removeAttribute("data-restoring");
4490
+ }
4367
4491
  }
4368
- }
4369
- if (generation !== this.#generation) {
4370
- return;
4371
- }
4372
- const checkpoint = this.#host.conversationStore().loadCheckpoint(this.#threadId);
4373
- if (messages !== null) {
4374
- const unfinished = this.#host.strings().callNotFinished;
4375
- const restored = answerUnansweredCalls(
4376
- messages,
4377
- // The shape the store holds for a call the client answered the same way:
4378
- // its tool message, with the outcome in its metadata.
4379
- (toolCallId) => ({
4380
- id: randomUUID3(),
4381
- role: "tool",
4382
- content: unfinished,
4383
- toolCallId,
4384
- metadata: { outcome: TOOL_OUTCOME.INTERRUPTED }
4385
- }),
4386
- new Set(checkpoint === null ? [] : [checkpoint.toolCallId])
4387
- );
4388
- this.#restored = restored;
4389
- for (const message of restored) {
4390
- this.replay(message);
4492
+ if (!this.#restoring(generation)) {
4493
+ this.#forgetStopped(store, threadId, checkpoint);
4494
+ return;
4495
+ }
4496
+ if (messages !== null) {
4497
+ const unfinished = this.#host.strings().callNotFinished;
4498
+ const restored = answerUnansweredCalls(
4499
+ messages,
4500
+ // The shape the store holds for a call the client answered the same
4501
+ // way: its tool message, with the outcome in its metadata.
4502
+ (toolCallId) => ({
4503
+ id: randomUUID3(),
4504
+ role: "tool",
4505
+ content: unfinished,
4506
+ toolCallId,
4507
+ metadata: { outcome: TOOL_OUTCOME.INTERRUPTED }
4508
+ }),
4509
+ new Set(checkpoint === null ? [] : [checkpoint.toolCallId])
4510
+ );
4511
+ this.#restored = restored;
4512
+ for (const message of restored) {
4513
+ this.replay(message);
4514
+ if (!this.#restoring(generation)) {
4515
+ this.#forgetStopped(store, threadId, checkpoint);
4516
+ return;
4517
+ }
4518
+ }
4519
+ }
4520
+ if (checkpoint !== null) {
4521
+ await this.#resumeFrom(checkpoint, generation);
4522
+ return;
4391
4523
  }
4524
+ this.#noticeIfRunUnfinished(messages);
4525
+ } finally {
4526
+ hold.release();
4392
4527
  }
4393
- if (checkpoint !== null) {
4394
- await this.#resumeFrom(checkpoint);
4395
- return;
4528
+ }
4529
+ /**
4530
+ * Whether the restore that claimed `generation` may go on: nothing has
4531
+ * replaced or cleared the conversation it is restoring, and the element is
4532
+ * still on the page.
4533
+ *
4534
+ * On the page, because leaving it is the one stop that clears nothing: the
4535
+ * element is not reset until it connects again, and connecting restores the
4536
+ * conversation afresh. A restore with nothing to resume went on regardless,
4537
+ * drawing into a node that had gone and running the host's renderers for it.
4538
+ * One that resumes learnt it from the Stop letting go of its hold; nothing
4539
+ * asks the hold that now, so this is what keeps the resume's request in.
4540
+ *
4541
+ * One `&&`, so coverage cannot tell whether either half is held. Removing the
4542
+ * generation fails "draws nothing into a new chat started while it loads" in
4543
+ * `conversation_history.test.ts`, and "drops a stale thread replay when a
4544
+ * newer switch started" in `ag_ui_chat.test.ts`; removing the connection
4545
+ * fails "draws nothing into an element that left the page while it loads".
4546
+ */
4547
+ #restoring(generation) {
4548
+ return generation === this.#generation && this.#host.element.isConnected;
4549
+ }
4550
+ /**
4551
+ * Forget the checkpoint a stopped restore loaded, when what stopped it also
4552
+ * stopped the run it was about to resume.
4553
+ *
4554
+ * New chat, a thread switch, a `user-key` handover and a newer restore all
4555
+ * move the generation, and each is a Stop for that run. Left in the store,
4556
+ * the checkpoint outlived the Stop: coming back to the conversation later
4557
+ * resumed the navigating call with whatever page was current by then.
4558
+ * Forgotten, the call is answered as not finished there, as any stopped call
4559
+ * is.
4560
+ *
4561
+ * Not while the restore now current claimed the same conversation, which it
4562
+ * has in two cases. It is this restore, when only the element left the page,
4563
+ * which moves no generation: a move or a framework re-render is not a
4564
+ * farewell, and the restore connecting starts has to find the checkpoint to
4565
+ * resume from. Or it is a newer restore of the same thread in the same store
4566
+ * -- `reload()`, switching away and back, or the element connecting again --
4567
+ * which read the checkpoint as it started, or found it gone, and answers for
4568
+ * it from then on: its resume clears it, and when it is stopped in turn this
4569
+ * same rule decides.
4570
+ *
4571
+ * The newer restore's case used to forget it too, on the grounds that the
4572
+ * newer one had read it and would resume once from that copy. It did until
4573
+ * the element left the page while the newer one loaded: that one stood down
4574
+ * keeping the checkpoint for the reconnect, as a departure should, but the
4575
+ * store no longer held it, so the element came back with no run to resume.
4576
+ *
4577
+ * Written to the store and the thread it was read from. After a handover
4578
+ * that is the previous principal's: the built-in store's clear is a removal
4579
+ * from a namespace the handover has already purged, so it changes nothing,
4580
+ * and nothing reaches the next principal's. A host's store is the same object
4581
+ * either side of a handover; one the host replaced is held by "still refuses
4582
+ * a send for the newer restore once the older has stood down".
4583
+ *
4584
+ * Two conditions. Clearing with no checkpoint fails "draws nothing into a new
4585
+ * chat started while it loads", which runs no store code for one. Clearing
4586
+ * what the current restore claimed fails "resumes nothing once the element
4587
+ * leaves the page while the store answers", where the claim is this
4588
+ * restore's own and the re-inserted element resumes, and "resumes once the
4589
+ * element is back when the host reloads and it then leaves the page", where
4590
+ * it is the reload's. The claim's own three are named on `#claimedByCurrent`.
4591
+ */
4592
+ #forgetStopped(store, threadId, checkpoint) {
4593
+ if (checkpoint !== null && !this.#claimedByCurrent(store, threadId)) {
4594
+ store.saveCheckpoint(threadId, null);
4396
4595
  }
4397
- this.#noticeIfRunUnfinished(messages);
4596
+ }
4597
+ /**
4598
+ * Whether the restore now current claimed the conversation a stopped restore
4599
+ * read its checkpoint from: the same thread, in the same store.
4600
+ *
4601
+ * A claim from an earlier generation speaks for nobody: the conversation was
4602
+ * cleared after it was made, so whatever it would have resumed was stopped,
4603
+ * and that holds of a stopped restore's own claim as much as of any other.
4604
+ * The store is compared as an object, because a store the host assigned
4605
+ * since is a different record of the conversation, and the one the
4606
+ * checkpoint was read from still has to forget it.
4607
+ *
4608
+ * As an object, a store the element builds for itself -- the built-in one
4609
+ * under a namespace, and the remote one `data-threads-url` wraps around it
4610
+ * -- is a different one after a reconnect, which builds it afresh over the
4611
+ * same storage, so a restore from before the reconnect forgets the
4612
+ * checkpoint there once it answers. The reconnect's own restore read it as
4613
+ * it started and resumes from that copy, as a newer restore always did here;
4614
+ * what that copy cannot survive is the element leaving again before the
4615
+ * load answers.
4616
+ *
4617
+ * One `&&` of three, so coverage cannot tell whether any is held. Dropping
4618
+ * the generation fails "forgets the checkpoint when New chat stops the
4619
+ * resume, so the call ends as not finished", where the claim is the stopped
4620
+ * restore's own; dropping the store fails "still refuses a send for the newer
4621
+ * restore once the older has stood down", whose host replaces the store
4622
+ * between the two; dropping the thread fails "forgets the checkpoint of a
4623
+ * thread switched away from, though the next has one of its own".
4624
+ */
4625
+ #claimedByCurrent(store, threadId) {
4626
+ const claim = this.#claim;
4627
+ return claim?.generation === this.#generation && claim.store === store && claim.threadId === threadId;
4398
4628
  }
4399
4629
  /**
4400
4630
  * Notice a previous run that never produced a response.
@@ -4514,12 +4744,15 @@ var ConversationHistory = class {
4514
4744
  * guard is held by "resumes a checkpointed navigating tool call on mount" in
4515
4745
  * `ag_ui_chat.test.ts`, whose transcript never made the call.
4516
4746
  */
4517
- async #resumeFrom(checkpoint) {
4747
+ async #resumeFrom(checkpoint, generation) {
4518
4748
  this.#host.conversationStore().saveCheckpoint(this.#threadId, null);
4519
4749
  const client = this.#host.ensureClient();
4520
4750
  const landed = JSON.stringify(
4521
4751
  this.#host.navigationResult().call(this.#host.element, checkpoint)
4522
4752
  );
4753
+ if (!this.#restoring(generation)) {
4754
+ return;
4755
+ }
4523
4756
  client.addToolResult(checkpoint.toolCallId, landed);
4524
4757
  this.#host.transcript.card(checkpoint.toolCallId)?.settle(TOOL_CALL_STATUS.DONE, landed);
4525
4758
  await client.resume();
@@ -5534,7 +5767,7 @@ var PanelPlacement = class {
5534
5767
  #probeAnchor(before, delta) {
5535
5768
  this.#applySize({ width: before.width + delta, height: before.height + delta });
5536
5769
  const after = this.#host.element.getBoundingClientRect();
5537
- const moved = (a, b2) => Math.abs(a - b2) >= 0.5;
5770
+ const moved = (a, b) => Math.abs(a - b) >= 0.5;
5538
5771
  return {
5539
5772
  x: moved(after.width, before.width) ? moved(after.left, before.left) ? "right" : "left" : null,
5540
5773
  y: moved(after.height, before.height) ? moved(after.top, before.top) ? "bottom" : "top" : null
@@ -10794,7 +11027,10 @@ var AnswerActions = class {
10794
11027
  }
10795
11028
  };
10796
11029
 
10797
- // node_modules/.pnpm/dompurify@3.4.15/node_modules/dompurify/dist/purify.es.mjs
11030
+ // node_modules/.pnpm/dompurify@3.4.16/node_modules/dompurify/dist/purify.es.mjs
11031
+ function _OverloadYield(e, d) {
11032
+ this.v = e, this.k = d;
11033
+ }
10798
11034
  function _arrayLikeToArray(r, a) {
10799
11035
  (null == a || a > r.length) && (a = r.length);
10800
11036
  for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e];
@@ -10803,18 +11039,20 @@ function _arrayLikeToArray(r, a) {
10803
11039
  function _arrayWithHoles(r) {
10804
11040
  if (Array.isArray(r)) return r;
10805
11041
  }
10806
- function _iterableToArrayLimit(r, l) {
11042
+ function _iterableToArrayLimit(r, l3) {
10807
11043
  var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"];
10808
11044
  if (null != t) {
10809
- var e, n, i, u3, a = [], f2 = true, o = false;
11045
+ var e, n, i, u, a = [], f = true, o = false;
10810
11046
  try {
10811
- if (i = (t = t.call(r)).next, 0 === l) ;
10812
- else for (; !(f2 = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f2 = true) ;
11047
+ if (i = (t = t.call(r)).next, 0 === l3) {
11048
+ if (Object(t) !== t) return;
11049
+ f = false;
11050
+ } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l3); f = true) ;
10813
11051
  } catch (r2) {
10814
11052
  o = true, n = r2;
10815
11053
  } finally {
10816
11054
  try {
10817
- if (!f2 && null != t.return && (u3 = t.return(), Object(u3) !== u3)) return;
11055
+ if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return;
10818
11056
  } finally {
10819
11057
  if (o) throw n;
10820
11058
  }
@@ -10835,6 +11073,53 @@ function _unsupportedIterableToArray(r, a) {
10835
11073
  return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0;
10836
11074
  }
10837
11075
  }
11076
+ function AsyncGenerator(e) {
11077
+ var t, n;
11078
+ function resume(t2, n2) {
11079
+ try {
11080
+ var r = e[t2](n2), o = r.value, u = o instanceof _OverloadYield;
11081
+ Promise.resolve(u ? o.v : o).then(function(n3) {
11082
+ if (u) {
11083
+ var i = "return" === t2 && o.k ? t2 : "next";
11084
+ if (!o.k || n3.done) return resume(i, n3);
11085
+ n3 = e[i](n3).value;
11086
+ }
11087
+ settle(!!r.done, n3);
11088
+ }, function(e2) {
11089
+ resume("throw", e2);
11090
+ });
11091
+ } catch (e2) {
11092
+ settle(2, e2);
11093
+ }
11094
+ }
11095
+ function settle(e2, r) {
11096
+ 2 === e2 ? t.reject(r) : t.resolve({
11097
+ value: r,
11098
+ done: e2
11099
+ }), (t = t.next) ? resume(t.key, t.arg) : n = null;
11100
+ }
11101
+ this._invoke = function(e2, r) {
11102
+ return new Promise(function(o, u) {
11103
+ var i = {
11104
+ key: e2,
11105
+ arg: r,
11106
+ resolve: o,
11107
+ reject: u,
11108
+ next: null
11109
+ };
11110
+ n ? n = n.next = i : (t = n = i, resume(e2, r));
11111
+ });
11112
+ }, "function" != typeof e.return && (this.return = void 0);
11113
+ }
11114
+ AsyncGenerator.prototype["function" == typeof Symbol && Symbol.asyncIterator || "@@asyncIterator"] = function() {
11115
+ return this;
11116
+ }, AsyncGenerator.prototype.next = function(e) {
11117
+ return this._invoke("next", e);
11118
+ }, AsyncGenerator.prototype.throw = function(e) {
11119
+ return this._invoke("throw", e);
11120
+ }, AsyncGenerator.prototype.return = function(e) {
11121
+ return this._invoke("return", e);
11122
+ };
10838
11123
  var entries = Object.entries;
10839
11124
  var setPrototypeOf = Object.setPrototypeOf;
10840
11125
  var isFrozen = Object.isFrozen;
@@ -10846,36 +11131,26 @@ var create = Object.create;
10846
11131
  var _ref = typeof Reflect !== "undefined" && Reflect;
10847
11132
  var apply = _ref.apply;
10848
11133
  var construct = _ref.construct;
10849
- if (!freeze) {
10850
- freeze = function freeze2(x2) {
10851
- return x2;
10852
- };
10853
- }
10854
- if (!seal) {
10855
- seal = function seal2(x2) {
10856
- return x2;
10857
- };
10858
- }
10859
- if (!apply) {
10860
- apply = function apply2(func, thisArg) {
10861
- for (var _len = arguments.length, args = new Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++) {
10862
- args[_key - 2] = arguments[_key];
10863
- }
10864
- return func.apply(thisArg, args);
10865
- };
10866
- }
10867
- if (!construct) {
10868
- construct = function construct2(Func) {
10869
- for (var _len2 = arguments.length, args = new Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) {
10870
- args[_key2 - 1] = arguments[_key2];
10871
- }
10872
- return new Func(...args);
10873
- };
10874
- }
11134
+ if (!freeze) freeze = function freeze2(x2) {
11135
+ return x2;
11136
+ };
11137
+ if (!seal) seal = function seal2(x2) {
11138
+ return x2;
11139
+ };
11140
+ if (!apply) apply = function apply2(func, thisArg) {
11141
+ for (var _len = arguments.length, args = new Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++) args[_key - 2] = arguments[_key];
11142
+ return func.apply(thisArg, args);
11143
+ };
11144
+ if (!construct) construct = function construct2(Func) {
11145
+ for (var _len2 = arguments.length, args = new Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) args[_key2 - 1] = arguments[_key2];
11146
+ return new Func(...args);
11147
+ };
10875
11148
  var arrayForEach = unapply(Array.prototype.forEach);
11149
+ Array.prototype.indexOf;
10876
11150
  var arrayLastIndexOf = unapply(Array.prototype.lastIndexOf);
10877
11151
  var arrayPop = unapply(Array.prototype.pop);
10878
11152
  var arrayPush = unapply(Array.prototype.push);
11153
+ Array.prototype.slice;
10879
11154
  var arraySplice = unapply(Array.prototype.splice);
10880
11155
  var arrayIsArray = Array.isArray;
10881
11156
  var stringToLowerCase = unapply(String.prototype.toLowerCase);
@@ -10894,40 +11169,28 @@ var regExpTest = unapply(RegExp.prototype.test);
10894
11169
  var typeErrorCreate = unconstruct(TypeError);
10895
11170
  function unapply(func) {
10896
11171
  return function(thisArg) {
10897
- if (thisArg instanceof RegExp) {
10898
- thisArg.lastIndex = 0;
10899
- }
10900
- for (var _len3 = arguments.length, args = new Array(_len3 > 1 ? _len3 - 1 : 0), _key3 = 1; _key3 < _len3; _key3++) {
10901
- args[_key3 - 1] = arguments[_key3];
10902
- }
11172
+ if (thisArg instanceof RegExp) thisArg.lastIndex = 0;
11173
+ for (var _len3 = arguments.length, args = new Array(_len3 > 1 ? _len3 - 1 : 0), _key3 = 1; _key3 < _len3; _key3++) args[_key3 - 1] = arguments[_key3];
10903
11174
  return apply(func, thisArg, args);
10904
11175
  };
10905
11176
  }
10906
11177
  function unconstruct(Func) {
10907
11178
  return function() {
10908
- for (var _len4 = arguments.length, args = new Array(_len4), _key4 = 0; _key4 < _len4; _key4++) {
10909
- args[_key4] = arguments[_key4];
10910
- }
11179
+ for (var _len4 = arguments.length, args = new Array(_len4), _key4 = 0; _key4 < _len4; _key4++) args[_key4] = arguments[_key4];
10911
11180
  return construct(Func, args);
10912
11181
  };
10913
11182
  }
10914
11183
  function addToSet(set, array) {
10915
11184
  let transformCaseFunc = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : stringToLowerCase;
10916
- if (setPrototypeOf) {
10917
- setPrototypeOf(set, null);
10918
- }
10919
- if (!arrayIsArray(array)) {
10920
- return set;
10921
- }
10922
- let l = array.length;
10923
- while (l--) {
10924
- let element = array[l];
11185
+ if (setPrototypeOf) setPrototypeOf(set, null);
11186
+ if (!arrayIsArray(array)) return set;
11187
+ let l3 = array.length;
11188
+ while (l3--) {
11189
+ let element = array[l3];
10925
11190
  if (typeof element === "string") {
10926
11191
  const lcElement = transformCaseFunc(element);
10927
11192
  if (lcElement !== element) {
10928
- if (!isFrozen(array)) {
10929
- array[l] = lcElement;
10930
- }
11193
+ if (!isFrozen(array)) array[l3] = lcElement;
10931
11194
  element = lcElement;
10932
11195
  }
10933
11196
  }
@@ -10936,12 +11199,7 @@ function addToSet(set, array) {
10936
11199
  return set;
10937
11200
  }
10938
11201
  function cleanArray(array) {
10939
- for (let index = 0; index < array.length; index++) {
10940
- const isPropertyExist = objectHasOwnProperty(array, index);
10941
- if (!isPropertyExist) {
10942
- array[index] = null;
10943
- }
10944
- }
11202
+ for (let index = 0; index < array.length; index++) if (!objectHasOwnProperty(array, index)) array[index] = null;
10945
11203
  return array;
10946
11204
  }
10947
11205
  function clone(object) {
@@ -10950,44 +11208,31 @@ function clone(object) {
10950
11208
  var _ref3 = _slicedToArray(_ref2, 2);
10951
11209
  const property = _ref3[0];
10952
11210
  const value = _ref3[1];
10953
- const isPropertyExist = objectHasOwnProperty(object, property);
10954
- if (isPropertyExist) {
10955
- if (arrayIsArray(value)) {
10956
- newObject[property] = cleanArray(value);
10957
- } else if (value && typeof value === "object" && value.constructor === Object) {
10958
- newObject[property] = clone(value);
10959
- } else {
10960
- newObject[property] = value;
10961
- }
11211
+ if (objectHasOwnProperty(object, property)) {
11212
+ if (arrayIsArray(value)) newObject[property] = cleanArray(value);
11213
+ else if (value && typeof value === "object" && value.constructor === Object) newObject[property] = clone(value);
11214
+ else newObject[property] = value;
10962
11215
  }
10963
11216
  }
10964
11217
  return newObject;
10965
11218
  }
10966
11219
  function stringifyValue(value) {
10967
11220
  switch (typeof value) {
10968
- case "string": {
11221
+ case "string":
10969
11222
  return value;
10970
- }
10971
- case "number": {
11223
+ case "number":
10972
11224
  return numberToString(value);
10973
- }
10974
- case "boolean": {
11225
+ case "boolean":
10975
11226
  return booleanToString(value);
10976
- }
10977
- case "bigint": {
11227
+ case "bigint":
10978
11228
  return bigintToString ? bigintToString(value) : "0";
10979
- }
10980
- case "symbol": {
11229
+ case "symbol":
10981
11230
  return symbolToString ? symbolToString(value) : "Symbol()";
10982
- }
10983
- case "undefined": {
11231
+ case "undefined":
10984
11232
  return objectToString(value);
10985
- }
10986
11233
  case "function":
10987
11234
  case "object": {
10988
- if (value === null) {
10989
- return objectToString(value);
10990
- }
11235
+ if (value === null) return objectToString(value);
10991
11236
  const valueAsRecord = value;
10992
11237
  const valueToString = lookupGetter(valueAsRecord, "toString");
10993
11238
  if (typeof valueToString === "function") {
@@ -10996,21 +11241,16 @@ function stringifyValue(value) {
10996
11241
  }
10997
11242
  return objectToString(value);
10998
11243
  }
10999
- default: {
11244
+ default:
11000
11245
  return objectToString(value);
11001
- }
11002
11246
  }
11003
11247
  }
11004
11248
  function lookupGetter(object, prop) {
11005
11249
  while (object !== null) {
11006
11250
  const desc = getOwnPropertyDescriptor(object, prop);
11007
11251
  if (desc) {
11008
- if (desc.get) {
11009
- return unapply(desc.get);
11010
- }
11011
- if (typeof desc.value === "function") {
11012
- return unapply(desc.value);
11013
- }
11252
+ if (desc.get) return unapply(desc.get);
11253
+ if (typeof desc.value === "function") return unapply(desc.value);
11014
11254
  }
11015
11255
  object = getPrototypeOf(object);
11016
11256
  }
@@ -11027,31 +11267,662 @@ function isRegex(value) {
11027
11267
  return false;
11028
11268
  }
11029
11269
  }
11030
- var html$1 = freeze(["a", "abbr", "acronym", "address", "area", "article", "aside", "audio", "b", "bdi", "bdo", "big", "blink", "blockquote", "body", "br", "button", "canvas", "caption", "center", "cite", "code", "col", "colgroup", "content", "data", "datalist", "dd", "decorator", "del", "details", "dfn", "dialog", "dir", "div", "dl", "dt", "element", "em", "fieldset", "figcaption", "figure", "font", "footer", "form", "h1", "h2", "h3", "h4", "h5", "h6", "head", "header", "hgroup", "hr", "html", "i", "img", "input", "ins", "kbd", "label", "legend", "li", "main", "map", "mark", "marquee", "menu", "menuitem", "meter", "nav", "nobr", "ol", "optgroup", "option", "output", "p", "picture", "pre", "progress", "q", "rp", "rt", "ruby", "s", "samp", "search", "section", "select", "shadow", "slot", "small", "source", "spacer", "span", "strike", "strong", "style", "sub", "summary", "sup", "table", "tbody", "td", "template", "textarea", "tfoot", "th", "thead", "time", "tr", "track", "tt", "u", "ul", "var", "video", "wbr"]);
11031
- var svg$1 = freeze(["svg", "a", "altglyph", "altglyphdef", "altglyphitem", "animatecolor", "animatemotion", "animatetransform", "circle", "clippath", "defs", "desc", "ellipse", "enterkeyhint", "exportparts", "filter", "font", "g", "glyph", "glyphref", "hkern", "image", "inputmode", "line", "lineargradient", "marker", "mask", "metadata", "mpath", "part", "path", "pattern", "polygon", "polyline", "radialgradient", "rect", "stop", "style", "switch", "symbol", "text", "textpath", "title", "tref", "tspan", "view", "vkern"]);
11032
- var svgFilters = freeze(["feBlend", "feColorMatrix", "feComponentTransfer", "feComposite", "feConvolveMatrix", "feDiffuseLighting", "feDisplacementMap", "feDistantLight", "feDropShadow", "feFlood", "feFuncA", "feFuncB", "feFuncG", "feFuncR", "feGaussianBlur", "feImage", "feMerge", "feMergeNode", "feMorphology", "feOffset", "fePointLight", "feSpecularLighting", "feSpotLight", "feTile", "feTurbulence"]);
11033
- var svgDisallowed = freeze(["animate", "color-profile", "cursor", "discard", "font-face", "font-face-format", "font-face-name", "font-face-src", "font-face-uri", "foreignobject", "hatch", "hatchpath", "mesh", "meshgradient", "meshpatch", "meshrow", "missing-glyph", "script", "set", "solidcolor", "unknown", "use"]);
11034
- var mathMl$1 = freeze(["math", "menclose", "merror", "mfenced", "mfrac", "mglyph", "mi", "mlabeledtr", "mmultiscripts", "mn", "mo", "mover", "mpadded", "mphantom", "mroot", "mrow", "ms", "mspace", "msqrt", "mstyle", "msub", "msup", "msubsup", "mtable", "mtd", "mtext", "mtr", "munder", "munderover", "mprescripts"]);
11035
- var mathMlDisallowed = freeze(["maction", "maligngroup", "malignmark", "mlongdiv", "mscarries", "mscarry", "msgroup", "mstack", "msline", "msrow", "semantics", "annotation", "annotation-xml", "mprescripts", "none"]);
11270
+ var html$1 = freeze([
11271
+ "a",
11272
+ "abbr",
11273
+ "acronym",
11274
+ "address",
11275
+ "area",
11276
+ "article",
11277
+ "aside",
11278
+ "audio",
11279
+ "b",
11280
+ "bdi",
11281
+ "bdo",
11282
+ "big",
11283
+ "blink",
11284
+ "blockquote",
11285
+ "body",
11286
+ "br",
11287
+ "button",
11288
+ "canvas",
11289
+ "caption",
11290
+ "center",
11291
+ "cite",
11292
+ "code",
11293
+ "col",
11294
+ "colgroup",
11295
+ "content",
11296
+ "data",
11297
+ "datalist",
11298
+ "dd",
11299
+ "decorator",
11300
+ "del",
11301
+ "details",
11302
+ "dfn",
11303
+ "dialog",
11304
+ "dir",
11305
+ "div",
11306
+ "dl",
11307
+ "dt",
11308
+ "element",
11309
+ "em",
11310
+ "fieldset",
11311
+ "figcaption",
11312
+ "figure",
11313
+ "font",
11314
+ "footer",
11315
+ "form",
11316
+ "h1",
11317
+ "h2",
11318
+ "h3",
11319
+ "h4",
11320
+ "h5",
11321
+ "h6",
11322
+ "head",
11323
+ "header",
11324
+ "hgroup",
11325
+ "hr",
11326
+ "html",
11327
+ "i",
11328
+ "img",
11329
+ "input",
11330
+ "ins",
11331
+ "kbd",
11332
+ "label",
11333
+ "legend",
11334
+ "li",
11335
+ "main",
11336
+ "map",
11337
+ "mark",
11338
+ "marquee",
11339
+ "menu",
11340
+ "menuitem",
11341
+ "meter",
11342
+ "nav",
11343
+ "nobr",
11344
+ "ol",
11345
+ "optgroup",
11346
+ "option",
11347
+ "output",
11348
+ "p",
11349
+ "picture",
11350
+ "pre",
11351
+ "progress",
11352
+ "q",
11353
+ "rp",
11354
+ "rt",
11355
+ "ruby",
11356
+ "s",
11357
+ "samp",
11358
+ "search",
11359
+ "section",
11360
+ "select",
11361
+ "shadow",
11362
+ "slot",
11363
+ "small",
11364
+ "source",
11365
+ "spacer",
11366
+ "span",
11367
+ "strike",
11368
+ "strong",
11369
+ "style",
11370
+ "sub",
11371
+ "summary",
11372
+ "sup",
11373
+ "table",
11374
+ "tbody",
11375
+ "td",
11376
+ "template",
11377
+ "textarea",
11378
+ "tfoot",
11379
+ "th",
11380
+ "thead",
11381
+ "time",
11382
+ "tr",
11383
+ "track",
11384
+ "tt",
11385
+ "u",
11386
+ "ul",
11387
+ "var",
11388
+ "video",
11389
+ "wbr"
11390
+ ]);
11391
+ var svg$1 = freeze([
11392
+ "svg",
11393
+ "a",
11394
+ "altglyph",
11395
+ "altglyphdef",
11396
+ "altglyphitem",
11397
+ "animatecolor",
11398
+ "animatemotion",
11399
+ "animatetransform",
11400
+ "circle",
11401
+ "clippath",
11402
+ "defs",
11403
+ "desc",
11404
+ "ellipse",
11405
+ "enterkeyhint",
11406
+ "exportparts",
11407
+ "filter",
11408
+ "font",
11409
+ "g",
11410
+ "glyph",
11411
+ "glyphref",
11412
+ "hkern",
11413
+ "image",
11414
+ "inputmode",
11415
+ "line",
11416
+ "lineargradient",
11417
+ "marker",
11418
+ "mask",
11419
+ "metadata",
11420
+ "mpath",
11421
+ "part",
11422
+ "path",
11423
+ "pattern",
11424
+ "polygon",
11425
+ "polyline",
11426
+ "radialgradient",
11427
+ "rect",
11428
+ "stop",
11429
+ "style",
11430
+ "switch",
11431
+ "symbol",
11432
+ "text",
11433
+ "textpath",
11434
+ "title",
11435
+ "tref",
11436
+ "tspan",
11437
+ "view",
11438
+ "vkern"
11439
+ ]);
11440
+ var svgFilters = freeze([
11441
+ "feBlend",
11442
+ "feColorMatrix",
11443
+ "feComponentTransfer",
11444
+ "feComposite",
11445
+ "feConvolveMatrix",
11446
+ "feDiffuseLighting",
11447
+ "feDisplacementMap",
11448
+ "feDistantLight",
11449
+ "feDropShadow",
11450
+ "feFlood",
11451
+ "feFuncA",
11452
+ "feFuncB",
11453
+ "feFuncG",
11454
+ "feFuncR",
11455
+ "feGaussianBlur",
11456
+ "feImage",
11457
+ "feMerge",
11458
+ "feMergeNode",
11459
+ "feMorphology",
11460
+ "feOffset",
11461
+ "fePointLight",
11462
+ "feSpecularLighting",
11463
+ "feSpotLight",
11464
+ "feTile",
11465
+ "feTurbulence"
11466
+ ]);
11467
+ var svgDisallowed = freeze([
11468
+ "animate",
11469
+ "color-profile",
11470
+ "cursor",
11471
+ "discard",
11472
+ "font-face",
11473
+ "font-face-format",
11474
+ "font-face-name",
11475
+ "font-face-src",
11476
+ "font-face-uri",
11477
+ "foreignobject",
11478
+ "hatch",
11479
+ "hatchpath",
11480
+ "mesh",
11481
+ "meshgradient",
11482
+ "meshpatch",
11483
+ "meshrow",
11484
+ "missing-glyph",
11485
+ "script",
11486
+ "set",
11487
+ "solidcolor",
11488
+ "unknown",
11489
+ "use"
11490
+ ]);
11491
+ var mathMl$1 = freeze([
11492
+ "math",
11493
+ "menclose",
11494
+ "merror",
11495
+ "mfenced",
11496
+ "mfrac",
11497
+ "mglyph",
11498
+ "mi",
11499
+ "mlabeledtr",
11500
+ "mmultiscripts",
11501
+ "mn",
11502
+ "mo",
11503
+ "mover",
11504
+ "mpadded",
11505
+ "mphantom",
11506
+ "mroot",
11507
+ "mrow",
11508
+ "ms",
11509
+ "mspace",
11510
+ "msqrt",
11511
+ "mstyle",
11512
+ "msub",
11513
+ "msup",
11514
+ "msubsup",
11515
+ "mtable",
11516
+ "mtd",
11517
+ "mtext",
11518
+ "mtr",
11519
+ "munder",
11520
+ "munderover",
11521
+ "mprescripts"
11522
+ ]);
11523
+ var mathMlDisallowed = freeze([
11524
+ "maction",
11525
+ "maligngroup",
11526
+ "malignmark",
11527
+ "mlongdiv",
11528
+ "mscarries",
11529
+ "mscarry",
11530
+ "msgroup",
11531
+ "mstack",
11532
+ "msline",
11533
+ "msrow",
11534
+ "semantics",
11535
+ "annotation",
11536
+ "annotation-xml",
11537
+ "mprescripts",
11538
+ "none"
11539
+ ]);
11036
11540
  var text3 = freeze(["#text"]);
11037
- var html = freeze(["accept", "action", "align", "alt", "autocapitalize", "autocomplete", "autopictureinpicture", "autoplay", "background", "bgcolor", "border", "capture", "cellpadding", "cellspacing", "checked", "cite", "class", "clear", "color", "cols", "colspan", "command", "commandfor", "controls", "controlslist", "coords", "crossorigin", "datetime", "decoding", "default", "dir", "disabled", "disablepictureinpicture", "disableremoteplayback", "download", "draggable", "enctype", "enterkeyhint", "exportparts", "face", "for", "headers", "height", "hidden", "high", "href", "hreflang", "id", "inert", "inputmode", "integrity", "ismap", "kind", "label", "lang", "list", "loading", "loop", "low", "max", "maxlength", "media", "method", "min", "minlength", "multiple", "muted", "name", "nonce", "noshade", "novalidate", "nowrap", "open", "optimum", "part", "pattern", "placeholder", "playsinline", "popover", "popovertarget", "popovertargetaction", "poster", "preload", "pubdate", "radiogroup", "readonly", "rel", "required", "rev", "reversed", "role", "rows", "rowspan", "spellcheck", "scope", "selected", "shape", "size", "sizes", "slot", "span", "srclang", "start", "src", "srcset", "step", "style", "summary", "tabindex", "title", "translate", "type", "usemap", "valign", "value", "width", "wrap", "xmlns"]);
11038
- var svg = freeze(["accent-height", "accumulate", "additive", "alignment-baseline", "amplitude", "ascent", "attributename", "attributetype", "azimuth", "basefrequency", "baseline-shift", "begin", "bias", "by", "class", "clip", "clippathunits", "clip-path", "clip-rule", "color", "color-interpolation", "color-interpolation-filters", "color-profile", "color-rendering", "cx", "cy", "d", "dx", "dy", "diffuseconstant", "direction", "display", "divisor", "dominant-baseline", "dur", "edgemode", "elevation", "end", "exponent", "fill", "fill-opacity", "fill-rule", "filter", "filterunits", "flood-color", "flood-opacity", "font-family", "font-size", "font-size-adjust", "font-stretch", "font-style", "font-variant", "font-weight", "fx", "fy", "g1", "g2", "glyph-name", "glyphref", "gradientunits", "gradienttransform", "height", "href", "id", "image-rendering", "in", "in2", "intercept", "k", "k1", "k2", "k3", "k4", "kerning", "keypoints", "keysplines", "keytimes", "lang", "lengthadjust", "letter-spacing", "kernelmatrix", "kernelunitlength", "lighting-color", "local", "marker-end", "marker-mid", "marker-start", "markerheight", "markerunits", "markerwidth", "maskcontentunits", "maskunits", "max", "mask", "mask-type", "media", "method", "mode", "min", "name", "numoctaves", "offset", "operator", "opacity", "order", "orient", "orientation", "origin", "overflow", "paint-order", "path", "pathlength", "patterncontentunits", "patterntransform", "patternunits", "pointer-events", "points", "preservealpha", "preserveaspectratio", "primitiveunits", "r", "rx", "ry", "radius", "refx", "refy", "repeatcount", "repeatdur", "restart", "result", "rotate", "scale", "seed", "shape-rendering", "slope", "specularconstant", "specularexponent", "spreadmethod", "startoffset", "stddeviation", "stitchtiles", "stop-color", "stop-opacity", "stroke-dasharray", "stroke-dashoffset", "stroke-linecap", "stroke-linejoin", "stroke-miterlimit", "stroke-opacity", "stroke", "stroke-width", "style", "surfacescale", "systemlanguage", "tabindex", "tablevalues", "targetx", "targety", "transform", "transform-origin", "text-anchor", "text-decoration", "text-orientation", "text-rendering", "textlength", "type", "u1", "u2", "unicode", "values", "vector-effect", "viewbox", "visibility", "version", "vert-adv-y", "vert-origin-x", "vert-origin-y", "width", "word-spacing", "wrap", "writing-mode", "xchannelselector", "ychannelselector", "x", "x1", "x2", "xmlns", "y", "y1", "y2", "z", "zoomandpan"]);
11039
- var mathMl = freeze(["accent", "accentunder", "align", "bevelled", "close", "columnalign", "columnlines", "columnspacing", "columnspan", "denomalign", "depth", "dir", "display", "displaystyle", "encoding", "fence", "frame", "height", "href", "id", "largeop", "length", "linethickness", "lquote", "lspace", "mathbackground", "mathcolor", "mathsize", "mathvariant", "maxsize", "minsize", "movablelimits", "notation", "numalign", "open", "rowalign", "rowlines", "rowspacing", "rowspan", "rspace", "rquote", "scriptlevel", "scriptminsize", "scriptsizemultiplier", "selection", "separator", "separators", "stretchy", "subscriptshift", "supscriptshift", "symmetric", "voffset", "width", "xmlns"]);
11040
- var xml = freeze(["xlink:href", "xml:id", "xlink:title", "xml:space", "xmlns:xlink"]);
11541
+ var html = freeze([
11542
+ "accept",
11543
+ "action",
11544
+ "align",
11545
+ "alt",
11546
+ "autocapitalize",
11547
+ "autocomplete",
11548
+ "autopictureinpicture",
11549
+ "autoplay",
11550
+ "background",
11551
+ "bgcolor",
11552
+ "border",
11553
+ "capture",
11554
+ "cellpadding",
11555
+ "cellspacing",
11556
+ "checked",
11557
+ "cite",
11558
+ "class",
11559
+ "clear",
11560
+ "color",
11561
+ "cols",
11562
+ "colspan",
11563
+ "command",
11564
+ "commandfor",
11565
+ "controls",
11566
+ "controlslist",
11567
+ "coords",
11568
+ "crossorigin",
11569
+ "datetime",
11570
+ "decoding",
11571
+ "default",
11572
+ "dir",
11573
+ "disabled",
11574
+ "disablepictureinpicture",
11575
+ "disableremoteplayback",
11576
+ "download",
11577
+ "draggable",
11578
+ "enctype",
11579
+ "enterkeyhint",
11580
+ "exportparts",
11581
+ "face",
11582
+ "for",
11583
+ "headers",
11584
+ "height",
11585
+ "hidden",
11586
+ "high",
11587
+ "href",
11588
+ "hreflang",
11589
+ "id",
11590
+ "inert",
11591
+ "inputmode",
11592
+ "integrity",
11593
+ "ismap",
11594
+ "kind",
11595
+ "label",
11596
+ "lang",
11597
+ "list",
11598
+ "loading",
11599
+ "loop",
11600
+ "low",
11601
+ "max",
11602
+ "maxlength",
11603
+ "media",
11604
+ "method",
11605
+ "min",
11606
+ "minlength",
11607
+ "multiple",
11608
+ "muted",
11609
+ "name",
11610
+ "nonce",
11611
+ "noshade",
11612
+ "novalidate",
11613
+ "nowrap",
11614
+ "open",
11615
+ "optimum",
11616
+ "part",
11617
+ "pattern",
11618
+ "placeholder",
11619
+ "playsinline",
11620
+ "popover",
11621
+ "popovertarget",
11622
+ "popovertargetaction",
11623
+ "poster",
11624
+ "preload",
11625
+ "pubdate",
11626
+ "radiogroup",
11627
+ "readonly",
11628
+ "rel",
11629
+ "required",
11630
+ "rev",
11631
+ "reversed",
11632
+ "role",
11633
+ "rows",
11634
+ "rowspan",
11635
+ "spellcheck",
11636
+ "scope",
11637
+ "selected",
11638
+ "shape",
11639
+ "size",
11640
+ "sizes",
11641
+ "slot",
11642
+ "span",
11643
+ "srclang",
11644
+ "start",
11645
+ "src",
11646
+ "srcset",
11647
+ "step",
11648
+ "style",
11649
+ "summary",
11650
+ "tabindex",
11651
+ "title",
11652
+ "translate",
11653
+ "type",
11654
+ "usemap",
11655
+ "valign",
11656
+ "value",
11657
+ "width",
11658
+ "wrap",
11659
+ "xmlns"
11660
+ ]);
11661
+ var svg = freeze([
11662
+ "accent-height",
11663
+ "accumulate",
11664
+ "additive",
11665
+ "alignment-baseline",
11666
+ "amplitude",
11667
+ "ascent",
11668
+ "attributename",
11669
+ "attributetype",
11670
+ "azimuth",
11671
+ "basefrequency",
11672
+ "baseline-shift",
11673
+ "begin",
11674
+ "bias",
11675
+ "by",
11676
+ "class",
11677
+ "clip",
11678
+ "clippathunits",
11679
+ "clip-path",
11680
+ "clip-rule",
11681
+ "color",
11682
+ "color-interpolation",
11683
+ "color-interpolation-filters",
11684
+ "color-profile",
11685
+ "color-rendering",
11686
+ "cx",
11687
+ "cy",
11688
+ "d",
11689
+ "dx",
11690
+ "dy",
11691
+ "diffuseconstant",
11692
+ "direction",
11693
+ "display",
11694
+ "divisor",
11695
+ "dominant-baseline",
11696
+ "dur",
11697
+ "edgemode",
11698
+ "elevation",
11699
+ "end",
11700
+ "exponent",
11701
+ "fill",
11702
+ "fill-opacity",
11703
+ "fill-rule",
11704
+ "filter",
11705
+ "filterunits",
11706
+ "flood-color",
11707
+ "flood-opacity",
11708
+ "font-family",
11709
+ "font-size",
11710
+ "font-size-adjust",
11711
+ "font-stretch",
11712
+ "font-style",
11713
+ "font-variant",
11714
+ "font-weight",
11715
+ "fx",
11716
+ "fy",
11717
+ "g1",
11718
+ "g2",
11719
+ "glyph-name",
11720
+ "glyphref",
11721
+ "gradientunits",
11722
+ "gradienttransform",
11723
+ "height",
11724
+ "href",
11725
+ "id",
11726
+ "image-rendering",
11727
+ "in",
11728
+ "in2",
11729
+ "intercept",
11730
+ "k",
11731
+ "k1",
11732
+ "k2",
11733
+ "k3",
11734
+ "k4",
11735
+ "kerning",
11736
+ "keypoints",
11737
+ "keysplines",
11738
+ "keytimes",
11739
+ "lang",
11740
+ "lengthadjust",
11741
+ "letter-spacing",
11742
+ "kernelmatrix",
11743
+ "kernelunitlength",
11744
+ "lighting-color",
11745
+ "local",
11746
+ "marker-end",
11747
+ "marker-mid",
11748
+ "marker-start",
11749
+ "markerheight",
11750
+ "markerunits",
11751
+ "markerwidth",
11752
+ "maskcontentunits",
11753
+ "maskunits",
11754
+ "max",
11755
+ "mask",
11756
+ "mask-type",
11757
+ "media",
11758
+ "method",
11759
+ "mode",
11760
+ "min",
11761
+ "name",
11762
+ "numoctaves",
11763
+ "offset",
11764
+ "operator",
11765
+ "opacity",
11766
+ "order",
11767
+ "orient",
11768
+ "orientation",
11769
+ "origin",
11770
+ "overflow",
11771
+ "paint-order",
11772
+ "path",
11773
+ "pathlength",
11774
+ "patterncontentunits",
11775
+ "patterntransform",
11776
+ "patternunits",
11777
+ "pointer-events",
11778
+ "points",
11779
+ "preservealpha",
11780
+ "preserveaspectratio",
11781
+ "primitiveunits",
11782
+ "r",
11783
+ "rx",
11784
+ "ry",
11785
+ "radius",
11786
+ "refx",
11787
+ "refy",
11788
+ "repeatcount",
11789
+ "repeatdur",
11790
+ "restart",
11791
+ "result",
11792
+ "rotate",
11793
+ "scale",
11794
+ "seed",
11795
+ "shape-rendering",
11796
+ "slope",
11797
+ "specularconstant",
11798
+ "specularexponent",
11799
+ "spreadmethod",
11800
+ "startoffset",
11801
+ "stddeviation",
11802
+ "stitchtiles",
11803
+ "stop-color",
11804
+ "stop-opacity",
11805
+ "stroke-dasharray",
11806
+ "stroke-dashoffset",
11807
+ "stroke-linecap",
11808
+ "stroke-linejoin",
11809
+ "stroke-miterlimit",
11810
+ "stroke-opacity",
11811
+ "stroke",
11812
+ "stroke-width",
11813
+ "style",
11814
+ "surfacescale",
11815
+ "systemlanguage",
11816
+ "tabindex",
11817
+ "tablevalues",
11818
+ "targetx",
11819
+ "targety",
11820
+ "transform",
11821
+ "transform-origin",
11822
+ "text-anchor",
11823
+ "text-decoration",
11824
+ "text-orientation",
11825
+ "text-rendering",
11826
+ "textlength",
11827
+ "type",
11828
+ "u1",
11829
+ "u2",
11830
+ "unicode",
11831
+ "values",
11832
+ "vector-effect",
11833
+ "viewbox",
11834
+ "visibility",
11835
+ "version",
11836
+ "vert-adv-y",
11837
+ "vert-origin-x",
11838
+ "vert-origin-y",
11839
+ "width",
11840
+ "word-spacing",
11841
+ "wrap",
11842
+ "writing-mode",
11843
+ "xchannelselector",
11844
+ "ychannelselector",
11845
+ "x",
11846
+ "x1",
11847
+ "x2",
11848
+ "xmlns",
11849
+ "y",
11850
+ "y1",
11851
+ "y2",
11852
+ "z",
11853
+ "zoomandpan"
11854
+ ]);
11855
+ var mathMl = freeze([
11856
+ "accent",
11857
+ "accentunder",
11858
+ "align",
11859
+ "bevelled",
11860
+ "close",
11861
+ "columnalign",
11862
+ "columnlines",
11863
+ "columnspacing",
11864
+ "columnspan",
11865
+ "denomalign",
11866
+ "depth",
11867
+ "dir",
11868
+ "display",
11869
+ "displaystyle",
11870
+ "encoding",
11871
+ "fence",
11872
+ "frame",
11873
+ "height",
11874
+ "href",
11875
+ "id",
11876
+ "largeop",
11877
+ "length",
11878
+ "linethickness",
11879
+ "lquote",
11880
+ "lspace",
11881
+ "mathbackground",
11882
+ "mathcolor",
11883
+ "mathsize",
11884
+ "mathvariant",
11885
+ "maxsize",
11886
+ "minsize",
11887
+ "movablelimits",
11888
+ "notation",
11889
+ "numalign",
11890
+ "open",
11891
+ "rowalign",
11892
+ "rowlines",
11893
+ "rowspacing",
11894
+ "rowspan",
11895
+ "rspace",
11896
+ "rquote",
11897
+ "scriptlevel",
11898
+ "scriptminsize",
11899
+ "scriptsizemultiplier",
11900
+ "selection",
11901
+ "separator",
11902
+ "separators",
11903
+ "stretchy",
11904
+ "subscriptshift",
11905
+ "supscriptshift",
11906
+ "symmetric",
11907
+ "voffset",
11908
+ "width",
11909
+ "xmlns"
11910
+ ]);
11911
+ var xml = freeze([
11912
+ "xlink:href",
11913
+ "xml:id",
11914
+ "xlink:title",
11915
+ "xml:space",
11916
+ "xmlns:xlink"
11917
+ ]);
11041
11918
  var MUSTACHE_EXPR = seal(/{{[\w\W]*|^[\w\W]*}}/g);
11042
11919
  var ERB_EXPR = seal(/<%[\w\W]*|^[\w\W]*%>/g);
11043
11920
  var TMPLIT_EXPR = seal(/\${[\w\W]*/g);
11044
11921
  var DATA_ATTR = seal(/^data-[\-\w.\u00B7-\uFFFF]+$/);
11045
11922
  var ARIA_ATTR = seal(/^aria-[\-\w]+$/);
11046
- var IS_ALLOWED_URI = seal(
11047
- /^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp|matrix):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i
11048
- // eslint-disable-line no-useless-escape
11049
- );
11923
+ var IS_ALLOWED_URI = seal(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp|matrix):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i);
11050
11924
  var IS_SCRIPT_OR_DATA = seal(/^(?:\w+script|data):/i);
11051
- var ATTR_WHITESPACE = seal(
11052
- /[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g
11053
- // eslint-disable-line no-control-regex
11054
- );
11925
+ var ATTR_WHITESPACE = seal(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g);
11055
11926
  var DOCTYPE_NAME = seal(/^html$/i);
11056
11927
  var CUSTOM_ELEMENT = seal(/^[a-z][.\w]*(-[.\w]+)+$/i);
11057
11928
  var ELEMENT_MARKUP_PROBE = seal(/<[/\w!]/g);
@@ -11064,18 +11935,24 @@ var NODE_TYPE = {
11064
11935
  text: 3,
11065
11936
  cdataSection: 4,
11066
11937
  entityReference: 5,
11067
- // Deprecated
11068
11938
  entityNode: 6,
11069
- // Deprecated
11070
11939
  processingInstruction: 7,
11071
11940
  comment: 8,
11072
11941
  document: 9,
11073
11942
  documentType: 10,
11074
11943
  documentFragment: 11,
11075
11944
  notation: 12
11076
- // Deprecated
11077
11945
  };
11078
- var LITERAL_TEXT_ELEMENT_NAMES = ["style", "script", "xmp", "iframe", "noembed", "noframes", "plaintext", "noscript"];
11946
+ var LITERAL_TEXT_ELEMENT_NAMES = [
11947
+ "style",
11948
+ "script",
11949
+ "xmp",
11950
+ "iframe",
11951
+ "noembed",
11952
+ "noframes",
11953
+ "plaintext",
11954
+ "noscript"
11955
+ ];
11079
11956
  var LITERAL_TEXT_ELEMENTS = freeze(addToSet({}, LITERAL_TEXT_ELEMENT_NAMES));
11080
11957
  var LITERAL_TEXT_CLOSE = (function() {
11081
11958
  const map = {};
@@ -11088,14 +11965,10 @@ var getGlobal = function getGlobal2() {
11088
11965
  return typeof window === "undefined" ? null : window;
11089
11966
  };
11090
11967
  var _createTrustedTypesPolicy = function _createTrustedTypesPolicy2(trustedTypes, purifyHostElement) {
11091
- if (typeof trustedTypes !== "object" || typeof trustedTypes.createPolicy !== "function") {
11092
- return null;
11093
- }
11968
+ if (typeof trustedTypes !== "object" || typeof trustedTypes.createPolicy !== "function") return null;
11094
11969
  let suffix = null;
11095
11970
  const ATTR_NAME = "data-tt-policy-suffix";
11096
- if (purifyHostElement && purifyHostElement.hasAttribute(ATTR_NAME)) {
11097
- suffix = purifyHostElement.getAttribute(ATTR_NAME);
11098
- }
11971
+ if (purifyHostElement && purifyHostElement.hasAttribute(ATTR_NAME)) suffix = purifyHostElement.getAttribute(ATTR_NAME);
11099
11972
  const policyName = "dompurify" + (suffix ? "#" + suffix : "");
11100
11973
  try {
11101
11974
  return trustedTypes.createPolicy(policyName, {
@@ -11134,7 +12007,7 @@ var _resolveObjectOption = function _resolveObjectOption2(cfg, key, makeFallback
11134
12007
  function createDOMPurify() {
11135
12008
  let window2 = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : getGlobal();
11136
12009
  const DOMPurify = (root) => createDOMPurify(root);
11137
- DOMPurify.version = "3.4.15";
12010
+ DOMPurify.version = "3.4.16";
11138
12011
  DOMPurify.removed = [];
11139
12012
  if (!window2 || !window2.document || window2.document.nodeType !== NODE_TYPE.document || !window2.Element) {
11140
12013
  DOMPurify.isSupported = false;
@@ -11144,8 +12017,8 @@ function createDOMPurify() {
11144
12017
  const originalDocument = document2;
11145
12018
  const currentScript = originalDocument.currentScript;
11146
12019
  window2.DocumentFragment;
11147
- const HTMLTemplateElement = window2.HTMLTemplateElement, Node2 = window2.Node, Element2 = window2.Element, NodeFilter2 = window2.NodeFilter, _window$NamedNodeMap = window2.NamedNodeMap;
11148
- _window$NamedNodeMap === void 0 ? window2.NamedNodeMap || window2.MozNamedAttrMap : _window$NamedNodeMap;
12020
+ const HTMLTemplateElement = window2.HTMLTemplateElement, Node2 = window2.Node, Element2 = window2.Element, NodeFilter2 = window2.NodeFilter;
12021
+ window2.NamedNodeMap === void 0 && (window2.NamedNodeMap || window2.MozNamedAttrMap);
11149
12022
  window2.HTMLFormElement;
11150
12023
  const DOMParser = window2.DOMParser, trustedTypes = window2.trustedTypes;
11151
12024
  const ElementPrototype = Element2.prototype;
@@ -11168,9 +12041,7 @@ function createDOMPurify() {
11168
12041
  };
11169
12042
  if (typeof HTMLTemplateElement === "function") {
11170
12043
  const template = document2.createElement("template");
11171
- if (template.content && template.content.ownerDocument) {
11172
- document2 = template.content.ownerDocument;
11173
- }
12044
+ if (template.content && template.content.ownerDocument) document2 = template.content.ownerDocument;
11174
12045
  }
11175
12046
  let trustedTypesPolicy;
11176
12047
  let emptyHTML = "";
@@ -11178,9 +12049,7 @@ function createDOMPurify() {
11178
12049
  let defaultTrustedTypesPolicyResolved = false;
11179
12050
  let IN_TRUSTED_TYPES_POLICY = 0;
11180
12051
  const _assertNotInTrustedTypesPolicy = function _assertNotInTrustedTypesPolicy2() {
11181
- if (IN_TRUSTED_TYPES_POLICY > 0) {
11182
- throw typeErrorCreate('A configured TRUSTED_TYPES_POLICY callback (createHTML or createScriptURL) must not call DOMPurify.sanitize, as that causes infinite recursion. Do not pass a policy whose callbacks wrap DOMPurify as TRUSTED_TYPES_POLICY; see the "DOMPurify and Trusted Types" section of the README.');
11183
- }
12052
+ if (IN_TRUSTED_TYPES_POLICY > 0) throw typeErrorCreate('A configured TRUSTED_TYPES_POLICY callback (createHTML or createScriptURL) must not call DOMPurify.sanitize, as that causes infinite recursion. Do not pass a policy whose callbacks wrap DOMPurify as TRUSTED_TYPES_POLICY; see the "DOMPurify and Trusted Types" section of the README.');
11184
12053
  };
11185
12054
  const _createTrustedHTML = function _createTrustedHTML2(html2) {
11186
12055
  _assertNotInTrustedTypesPolicy();
@@ -11214,9 +12083,20 @@ function createDOMPurify() {
11214
12083
  const MUSTACHE_EXPR$1 = MUSTACHE_EXPR, ERB_EXPR$1 = ERB_EXPR, TMPLIT_EXPR$1 = TMPLIT_EXPR, DATA_ATTR$1 = DATA_ATTR, ARIA_ATTR$1 = ARIA_ATTR, IS_SCRIPT_OR_DATA$1 = IS_SCRIPT_OR_DATA, ATTR_WHITESPACE$1 = ATTR_WHITESPACE, CUSTOM_ELEMENT$1 = CUSTOM_ELEMENT;
11215
12084
  let IS_ALLOWED_URI$1 = IS_ALLOWED_URI;
11216
12085
  let ALLOWED_TAGS2 = null;
11217
- const DEFAULT_ALLOWED_TAGS = addToSet({}, [...html$1, ...svg$1, ...svgFilters, ...mathMl$1, ...text3]);
12086
+ const DEFAULT_ALLOWED_TAGS = addToSet({}, [
12087
+ ...html$1,
12088
+ ...svg$1,
12089
+ ...svgFilters,
12090
+ ...mathMl$1,
12091
+ ...text3
12092
+ ]);
11218
12093
  let ALLOWED_ATTR2 = null;
11219
- const DEFAULT_ALLOWED_ATTR = addToSet({}, [...html, ...svg, ...mathMl, ...xml]);
12094
+ const DEFAULT_ALLOWED_ATTR = addToSet({}, [
12095
+ ...html,
12096
+ ...svg,
12097
+ ...mathMl,
12098
+ ...xml
12099
+ ]);
11220
12100
  let CUSTOM_ELEMENT_HANDLING = Object.seal(create(null, {
11221
12101
  tagNameCheck: {
11222
12102
  writable: true,
@@ -11293,15 +12173,6 @@ function createDOMPurify() {
11293
12173
  "noscript",
11294
12174
  "plaintext",
11295
12175
  "script",
11296
- // <selectedcontent> mirrors the selected <option>'s subtree, cloned by
11297
- // the UA (customizable <select>) — including any on* handlers — and the
11298
- // engine re-mirrors synchronously whenever a removal changes which
11299
- // option/selectedcontent is current, even inside DOMPurify's inert
11300
- // DOMParser document. Hoisting its children on removal re-inserts a fresh
11301
- // mirror target ahead of the walk, which the engine refills, looping
11302
- // forever (DoS) and amplifying output. Dropping its content on removal
11303
- // (rather than hoisting) breaks that cascade; the content is a duplicate
11304
- // of the option, which is sanitized on its own. See campaign-3 F1/F6.
11305
12176
  "selectedcontent",
11306
12177
  "style",
11307
12178
  "svg",
@@ -11312,21 +12183,59 @@ function createDOMPurify() {
11312
12183
  "xmp"
11313
12184
  ]);
11314
12185
  let DATA_URI_TAGS = null;
11315
- const DEFAULT_DATA_URI_TAGS = addToSet({}, ["audio", "video", "img", "source", "image", "track"]);
12186
+ const DEFAULT_DATA_URI_TAGS = addToSet({}, [
12187
+ "audio",
12188
+ "video",
12189
+ "img",
12190
+ "source",
12191
+ "image",
12192
+ "track"
12193
+ ]);
11316
12194
  let URI_SAFE_ATTRIBUTES = null;
11317
- const DEFAULT_URI_SAFE_ATTRIBUTES = addToSet({}, ["alt", "class", "for", "id", "label", "name", "pattern", "placeholder", "role", "summary", "title", "value", "style", "xmlns"]);
12195
+ const DEFAULT_URI_SAFE_ATTRIBUTES = addToSet({}, [
12196
+ "alt",
12197
+ "class",
12198
+ "for",
12199
+ "id",
12200
+ "label",
12201
+ "name",
12202
+ "pattern",
12203
+ "placeholder",
12204
+ "role",
12205
+ "summary",
12206
+ "title",
12207
+ "value",
12208
+ "style",
12209
+ "xmlns"
12210
+ ]);
11318
12211
  const MATHML_NAMESPACE = "http://www.w3.org/1998/Math/MathML";
11319
12212
  const SVG_NAMESPACE = "http://www.w3.org/2000/svg";
11320
12213
  const HTML_NAMESPACE = "http://www.w3.org/1999/xhtml";
11321
12214
  let NAMESPACE = HTML_NAMESPACE;
11322
12215
  let IS_EMPTY_INPUT = false;
11323
12216
  let ALLOWED_NAMESPACES = null;
11324
- const DEFAULT_ALLOWED_NAMESPACES = addToSet({}, [MATHML_NAMESPACE, SVG_NAMESPACE, HTML_NAMESPACE], stringToString);
11325
- const DEFAULT_MATHML_TEXT_INTEGRATION_POINTS = freeze(["mi", "mo", "mn", "ms", "mtext"]);
12217
+ const DEFAULT_ALLOWED_NAMESPACES = addToSet({}, [
12218
+ MATHML_NAMESPACE,
12219
+ SVG_NAMESPACE,
12220
+ HTML_NAMESPACE
12221
+ ], stringToString);
12222
+ const DEFAULT_MATHML_TEXT_INTEGRATION_POINTS = freeze([
12223
+ "mi",
12224
+ "mo",
12225
+ "mn",
12226
+ "ms",
12227
+ "mtext"
12228
+ ]);
11326
12229
  let MATHML_TEXT_INTEGRATION_POINTS = addToSet({}, DEFAULT_MATHML_TEXT_INTEGRATION_POINTS);
11327
12230
  const DEFAULT_HTML_INTEGRATION_POINTS = freeze(["annotation-xml"]);
11328
12231
  let HTML_INTEGRATION_POINTS = addToSet({}, DEFAULT_HTML_INTEGRATION_POINTS);
11329
- const COMMON_SVG_AND_HTML_ELEMENTS = addToSet({}, ["title", "style", "font", "a", "script"]);
12232
+ const COMMON_SVG_AND_HTML_ELEMENTS = addToSet({}, [
12233
+ "title",
12234
+ "style",
12235
+ "font",
12236
+ "a",
12237
+ "script"
12238
+ ]);
11330
12239
  let PARSER_MEDIA_TYPE = null;
11331
12240
  const SUPPORTED_PARSER_MEDIA_TYPES = ["application/xhtml+xml", "text/html"];
11332
12241
  const DEFAULT_PARSER_MEDIA_TYPE = "text/html";
@@ -11338,25 +12247,14 @@ function createDOMPurify() {
11338
12247
  };
11339
12248
  const _parseConfig = function _parseConfig2() {
11340
12249
  let cfg = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {};
11341
- if (CONFIG && CONFIG === cfg) {
11342
- return;
11343
- }
11344
- if (!cfg || typeof cfg !== "object") {
11345
- cfg = {};
11346
- }
12250
+ if (CONFIG && CONFIG === cfg) return;
12251
+ if (!cfg || typeof cfg !== "object") cfg = {};
11347
12252
  cfg = clone(cfg);
11348
- PARSER_MEDIA_TYPE = // eslint-disable-next-line unicorn/prefer-includes
11349
- SUPPORTED_PARSER_MEDIA_TYPES.indexOf(cfg.PARSER_MEDIA_TYPE) === -1 ? DEFAULT_PARSER_MEDIA_TYPE : cfg.PARSER_MEDIA_TYPE;
12253
+ PARSER_MEDIA_TYPE = SUPPORTED_PARSER_MEDIA_TYPES.indexOf(cfg.PARSER_MEDIA_TYPE) === -1 ? DEFAULT_PARSER_MEDIA_TYPE : cfg.PARSER_MEDIA_TYPE;
11350
12254
  transformCaseFunc = PARSER_MEDIA_TYPE === "application/xhtml+xml" ? stringToString : stringToLowerCase;
11351
- ALLOWED_TAGS2 = _resolveSetOption(cfg, "ALLOWED_TAGS", DEFAULT_ALLOWED_TAGS, {
11352
- transform: transformCaseFunc
11353
- });
11354
- ALLOWED_ATTR2 = _resolveSetOption(cfg, "ALLOWED_ATTR", DEFAULT_ALLOWED_ATTR, {
11355
- transform: transformCaseFunc
11356
- });
11357
- ALLOWED_NAMESPACES = _resolveSetOption(cfg, "ALLOWED_NAMESPACES", DEFAULT_ALLOWED_NAMESPACES, {
11358
- transform: stringToString
11359
- });
12255
+ ALLOWED_TAGS2 = _resolveSetOption(cfg, "ALLOWED_TAGS", DEFAULT_ALLOWED_TAGS, { transform: transformCaseFunc });
12256
+ ALLOWED_ATTR2 = _resolveSetOption(cfg, "ALLOWED_ATTR", DEFAULT_ALLOWED_ATTR, { transform: transformCaseFunc });
12257
+ ALLOWED_NAMESPACES = _resolveSetOption(cfg, "ALLOWED_NAMESPACES", DEFAULT_ALLOWED_NAMESPACES, { transform: stringToString });
11360
12258
  URI_SAFE_ATTRIBUTES = _resolveSetOption(cfg, "ADD_URI_SAFE_ATTR", DEFAULT_URI_SAFE_ATTRIBUTES, {
11361
12259
  transform: transformCaseFunc,
11362
12260
  base: DEFAULT_URI_SAFE_ATTRIBUTES
@@ -11365,15 +12263,9 @@ function createDOMPurify() {
11365
12263
  transform: transformCaseFunc,
11366
12264
  base: DEFAULT_DATA_URI_TAGS
11367
12265
  });
11368
- FORBID_CONTENTS = _resolveSetOption(cfg, "FORBID_CONTENTS", DEFAULT_FORBID_CONTENTS, {
11369
- transform: transformCaseFunc
11370
- });
11371
- FORBID_TAGS = _resolveSetOption(cfg, "FORBID_TAGS", clone({}), {
11372
- transform: transformCaseFunc
11373
- });
11374
- FORBID_ATTR = _resolveSetOption(cfg, "FORBID_ATTR", clone({}), {
11375
- transform: transformCaseFunc
11376
- });
12266
+ FORBID_CONTENTS = _resolveSetOption(cfg, "FORBID_CONTENTS", DEFAULT_FORBID_CONTENTS, { transform: transformCaseFunc });
12267
+ FORBID_TAGS = _resolveSetOption(cfg, "FORBID_TAGS", clone({}), { transform: transformCaseFunc });
12268
+ FORBID_ATTR = _resolveSetOption(cfg, "FORBID_ATTR", clone({}), { transform: transformCaseFunc });
11377
12269
  USE_PROFILES = objectHasOwnProperty(cfg, "USE_PROFILES") ? cfg.USE_PROFILES && typeof cfg.USE_PROFILES === "object" ? clone(cfg.USE_PROFILES) : cfg.USE_PROFILES : false;
11378
12270
  ALLOW_ARIA_ATTR = cfg.ALLOW_ARIA_ATTR !== false;
11379
12271
  ALLOW_DATA_ATTR = cfg.ALLOW_DATA_ATTR !== false;
@@ -11392,36 +12284,16 @@ function createDOMPurify() {
11392
12284
  IN_PLACE = cfg.IN_PLACE || false;
11393
12285
  IS_ALLOWED_URI$1 = isRegex(cfg.ALLOWED_URI_REGEXP) ? cfg.ALLOWED_URI_REGEXP : IS_ALLOWED_URI;
11394
12286
  NAMESPACE = typeof cfg.NAMESPACE === "string" ? cfg.NAMESPACE : HTML_NAMESPACE;
11395
- MATHML_TEXT_INTEGRATION_POINTS = _resolveObjectOption(
11396
- cfg,
11397
- "MATHML_TEXT_INTEGRATION_POINTS",
11398
- () => addToSet({}, DEFAULT_MATHML_TEXT_INTEGRATION_POINTS)
11399
- // Default built-in map
11400
- );
11401
- HTML_INTEGRATION_POINTS = _resolveObjectOption(
11402
- cfg,
11403
- "HTML_INTEGRATION_POINTS",
11404
- () => addToSet({}, DEFAULT_HTML_INTEGRATION_POINTS)
11405
- // Default built-in map
11406
- );
12287
+ MATHML_TEXT_INTEGRATION_POINTS = _resolveObjectOption(cfg, "MATHML_TEXT_INTEGRATION_POINTS", () => addToSet({}, DEFAULT_MATHML_TEXT_INTEGRATION_POINTS));
12288
+ HTML_INTEGRATION_POINTS = _resolveObjectOption(cfg, "HTML_INTEGRATION_POINTS", () => addToSet({}, DEFAULT_HTML_INTEGRATION_POINTS));
11407
12289
  const customElementHandling = _resolveObjectOption(cfg, "CUSTOM_ELEMENT_HANDLING", () => create(null));
11408
12290
  CUSTOM_ELEMENT_HANDLING = create(null);
11409
- if (objectHasOwnProperty(customElementHandling, "tagNameCheck") && isRegexOrFunction(customElementHandling.tagNameCheck)) {
11410
- CUSTOM_ELEMENT_HANDLING.tagNameCheck = customElementHandling.tagNameCheck;
11411
- }
11412
- if (objectHasOwnProperty(customElementHandling, "attributeNameCheck") && isRegexOrFunction(customElementHandling.attributeNameCheck)) {
11413
- CUSTOM_ELEMENT_HANDLING.attributeNameCheck = customElementHandling.attributeNameCheck;
11414
- }
11415
- if (objectHasOwnProperty(customElementHandling, "allowCustomizedBuiltInElements") && typeof customElementHandling.allowCustomizedBuiltInElements === "boolean") {
11416
- CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements = customElementHandling.allowCustomizedBuiltInElements;
11417
- }
12291
+ if (objectHasOwnProperty(customElementHandling, "tagNameCheck") && isRegexOrFunction(customElementHandling.tagNameCheck)) CUSTOM_ELEMENT_HANDLING.tagNameCheck = customElementHandling.tagNameCheck;
12292
+ if (objectHasOwnProperty(customElementHandling, "attributeNameCheck") && isRegexOrFunction(customElementHandling.attributeNameCheck)) CUSTOM_ELEMENT_HANDLING.attributeNameCheck = customElementHandling.attributeNameCheck;
12293
+ if (objectHasOwnProperty(customElementHandling, "allowCustomizedBuiltInElements") && typeof customElementHandling.allowCustomizedBuiltInElements === "boolean") CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements = customElementHandling.allowCustomizedBuiltInElements;
11418
12294
  seal(CUSTOM_ELEMENT_HANDLING);
11419
- if (SAFE_FOR_TEMPLATES) {
11420
- ALLOW_DATA_ATTR = false;
11421
- }
11422
- if (RETURN_DOM_FRAGMENT) {
11423
- RETURN_DOM = true;
11424
- }
12295
+ if (SAFE_FOR_TEMPLATES) ALLOW_DATA_ATTR = false;
12296
+ if (RETURN_DOM_FRAGMENT) RETURN_DOM = true;
11425
12297
  if (USE_PROFILES) {
11426
12298
  ALLOWED_TAGS2 = addToSet({}, text3);
11427
12299
  ALLOWED_ATTR2 = create(null);
@@ -11448,48 +12320,36 @@ function createDOMPurify() {
11448
12320
  EXTRA_ELEMENT_HANDLING.tagCheck = null;
11449
12321
  EXTRA_ELEMENT_HANDLING.attributeCheck = null;
11450
12322
  if (objectHasOwnProperty(cfg, "ADD_TAGS")) {
11451
- if (typeof cfg.ADD_TAGS === "function") {
11452
- EXTRA_ELEMENT_HANDLING.tagCheck = cfg.ADD_TAGS;
11453
- } else if (arrayIsArray(cfg.ADD_TAGS)) {
11454
- if (ALLOWED_TAGS2 === DEFAULT_ALLOWED_TAGS) {
11455
- ALLOWED_TAGS2 = clone(ALLOWED_TAGS2);
11456
- }
12323
+ if (typeof cfg.ADD_TAGS === "function") EXTRA_ELEMENT_HANDLING.tagCheck = cfg.ADD_TAGS;
12324
+ else if (arrayIsArray(cfg.ADD_TAGS)) {
12325
+ if (ALLOWED_TAGS2 === DEFAULT_ALLOWED_TAGS) ALLOWED_TAGS2 = clone(ALLOWED_TAGS2);
11457
12326
  addToSet(ALLOWED_TAGS2, cfg.ADD_TAGS, transformCaseFunc);
11458
12327
  }
11459
12328
  }
11460
12329
  if (objectHasOwnProperty(cfg, "ADD_ATTR")) {
11461
- if (typeof cfg.ADD_ATTR === "function") {
11462
- EXTRA_ELEMENT_HANDLING.attributeCheck = cfg.ADD_ATTR;
11463
- } else if (arrayIsArray(cfg.ADD_ATTR)) {
11464
- if (ALLOWED_ATTR2 === DEFAULT_ALLOWED_ATTR) {
11465
- ALLOWED_ATTR2 = clone(ALLOWED_ATTR2);
11466
- }
12330
+ if (typeof cfg.ADD_ATTR === "function") EXTRA_ELEMENT_HANDLING.attributeCheck = cfg.ADD_ATTR;
12331
+ else if (arrayIsArray(cfg.ADD_ATTR)) {
12332
+ if (ALLOWED_ATTR2 === DEFAULT_ALLOWED_ATTR) ALLOWED_ATTR2 = clone(ALLOWED_ATTR2);
11467
12333
  addToSet(ALLOWED_ATTR2, cfg.ADD_ATTR, transformCaseFunc);
11468
12334
  }
11469
12335
  }
11470
12336
  if (objectHasOwnProperty(cfg, "ADD_FORBID_CONTENTS") && arrayIsArray(cfg.ADD_FORBID_CONTENTS)) {
11471
- if (FORBID_CONTENTS === DEFAULT_FORBID_CONTENTS) {
11472
- FORBID_CONTENTS = clone(FORBID_CONTENTS);
11473
- }
12337
+ if (FORBID_CONTENTS === DEFAULT_FORBID_CONTENTS) FORBID_CONTENTS = clone(FORBID_CONTENTS);
11474
12338
  addToSet(FORBID_CONTENTS, cfg.ADD_FORBID_CONTENTS, transformCaseFunc);
11475
12339
  }
11476
- if (KEEP_CONTENT) {
11477
- ALLOWED_TAGS2["#text"] = true;
11478
- }
11479
- if (WHOLE_DOCUMENT) {
11480
- addToSet(ALLOWED_TAGS2, ["html", "head", "body"]);
11481
- }
12340
+ if (KEEP_CONTENT) ALLOWED_TAGS2["#text"] = true;
12341
+ if (WHOLE_DOCUMENT) addToSet(ALLOWED_TAGS2, [
12342
+ "html",
12343
+ "head",
12344
+ "body"
12345
+ ]);
11482
12346
  if (ALLOWED_TAGS2.table) {
11483
12347
  addToSet(ALLOWED_TAGS2, ["tbody"]);
11484
12348
  delete FORBID_TAGS.tbody;
11485
12349
  }
11486
12350
  if (cfg.TRUSTED_TYPES_POLICY) {
11487
- if (typeof cfg.TRUSTED_TYPES_POLICY.createHTML !== "function") {
11488
- throw typeErrorCreate('TRUSTED_TYPES_POLICY configuration option must provide a "createHTML" hook.');
11489
- }
11490
- if (typeof cfg.TRUSTED_TYPES_POLICY.createScriptURL !== "function") {
11491
- throw typeErrorCreate('TRUSTED_TYPES_POLICY configuration option must provide a "createScriptURL" hook.');
11492
- }
12351
+ if (typeof cfg.TRUSTED_TYPES_POLICY.createHTML !== "function") throw typeErrorCreate('TRUSTED_TYPES_POLICY configuration option must provide a "createHTML" hook.');
12352
+ if (typeof cfg.TRUSTED_TYPES_POLICY.createScriptURL !== "function") throw typeErrorCreate('TRUSTED_TYPES_POLICY configuration option must provide a "createScriptURL" hook.');
11493
12353
  const previousTrustedTypesPolicy = trustedTypesPolicy;
11494
12354
  trustedTypesPolicy = cfg.TRUSTED_TYPES_POLICY;
11495
12355
  try {
@@ -11502,85 +12362,55 @@ function createDOMPurify() {
11502
12362
  trustedTypesPolicy = void 0;
11503
12363
  emptyHTML = "";
11504
12364
  } else {
11505
- if (trustedTypesPolicy === void 0) {
11506
- trustedTypesPolicy = _getDefaultTrustedTypesPolicy();
11507
- }
11508
- if (trustedTypesPolicy && typeof emptyHTML === "string") {
11509
- emptyHTML = _createTrustedHTML("");
11510
- }
11511
- }
11512
- if (freeze) {
11513
- freeze(cfg);
12365
+ if (trustedTypesPolicy === void 0) trustedTypesPolicy = _getDefaultTrustedTypesPolicy();
12366
+ if (trustedTypesPolicy && typeof emptyHTML === "string") emptyHTML = _createTrustedHTML("");
11514
12367
  }
12368
+ if (freeze) freeze(cfg);
11515
12369
  CONFIG = cfg;
11516
12370
  };
11517
- const ALL_SVG_TAGS = addToSet({}, [...svg$1, ...svgFilters, ...svgDisallowed]);
12371
+ const ALL_SVG_TAGS = addToSet({}, [
12372
+ ...svg$1,
12373
+ ...svgFilters,
12374
+ ...svgDisallowed
12375
+ ]);
11518
12376
  const ALL_MATHML_TAGS = addToSet({}, [...mathMl$1, ...mathMlDisallowed]);
11519
12377
  const _checkSvgNamespace = function _checkSvgNamespace2(tagName, parent, parentTagName) {
11520
- if (parent.namespaceURI === HTML_NAMESPACE) {
11521
- return tagName === "svg";
11522
- }
11523
- if (parent.namespaceURI === MATHML_NAMESPACE) {
11524
- return tagName === "svg" && (parentTagName === "annotation-xml" || MATHML_TEXT_INTEGRATION_POINTS[parentTagName]);
11525
- }
12378
+ if (parent.namespaceURI === HTML_NAMESPACE) return tagName === "svg";
12379
+ if (parent.namespaceURI === MATHML_NAMESPACE) return tagName === "svg" && (parentTagName === "annotation-xml" || MATHML_TEXT_INTEGRATION_POINTS[parentTagName]);
11526
12380
  return Boolean(ALL_SVG_TAGS[tagName]);
11527
12381
  };
11528
12382
  const _checkMathMlNamespace = function _checkMathMlNamespace2(tagName, parent, parentTagName) {
11529
- if (parent.namespaceURI === HTML_NAMESPACE) {
11530
- return tagName === "math";
11531
- }
11532
- if (parent.namespaceURI === SVG_NAMESPACE) {
11533
- return tagName === "math" && HTML_INTEGRATION_POINTS[parentTagName];
11534
- }
12383
+ if (parent.namespaceURI === HTML_NAMESPACE) return tagName === "math";
12384
+ if (parent.namespaceURI === SVG_NAMESPACE) return tagName === "math" && HTML_INTEGRATION_POINTS[parentTagName];
11535
12385
  return Boolean(ALL_MATHML_TAGS[tagName]);
11536
12386
  };
11537
12387
  const _checkHtmlNamespace = function _checkHtmlNamespace2(tagName, parent, parentTagName) {
11538
- if (parent.namespaceURI === SVG_NAMESPACE && !HTML_INTEGRATION_POINTS[parentTagName]) {
11539
- return false;
11540
- }
11541
- if (parent.namespaceURI === MATHML_NAMESPACE && !MATHML_TEXT_INTEGRATION_POINTS[parentTagName]) {
11542
- return false;
11543
- }
12388
+ if (parent.namespaceURI === SVG_NAMESPACE && !HTML_INTEGRATION_POINTS[parentTagName]) return false;
12389
+ if (parent.namespaceURI === MATHML_NAMESPACE && !MATHML_TEXT_INTEGRATION_POINTS[parentTagName]) return false;
11544
12390
  return !ALL_MATHML_TAGS[tagName] && (COMMON_SVG_AND_HTML_ELEMENTS[tagName] || !ALL_SVG_TAGS[tagName]);
11545
12391
  };
11546
12392
  const _checkValidNamespace = function _checkValidNamespace2(element) {
11547
12393
  let parent = getParentNode(element);
11548
- if (!parent || !parent.tagName) {
11549
- parent = {
11550
- namespaceURI: NAMESPACE,
11551
- tagName: "template"
11552
- };
11553
- }
12394
+ if (!parent || !parent.tagName) parent = {
12395
+ namespaceURI: NAMESPACE,
12396
+ tagName: "template"
12397
+ };
11554
12398
  const tagName = stringToLowerCase(element.tagName);
11555
12399
  const parentTagName = stringToLowerCase(parent.tagName);
11556
- if (!ALLOWED_NAMESPACES[element.namespaceURI]) {
11557
- return false;
11558
- }
11559
- if (element.namespaceURI === SVG_NAMESPACE) {
11560
- return _checkSvgNamespace(tagName, parent, parentTagName);
11561
- }
11562
- if (element.namespaceURI === MATHML_NAMESPACE) {
11563
- return _checkMathMlNamespace(tagName, parent, parentTagName);
11564
- }
11565
- if (element.namespaceURI === HTML_NAMESPACE) {
11566
- return _checkHtmlNamespace(tagName, parent, parentTagName);
11567
- }
11568
- if (PARSER_MEDIA_TYPE === "application/xhtml+xml" && ALLOWED_NAMESPACES[element.namespaceURI]) {
11569
- return true;
11570
- }
12400
+ if (!ALLOWED_NAMESPACES[element.namespaceURI]) return false;
12401
+ if (element.namespaceURI === SVG_NAMESPACE) return _checkSvgNamespace(tagName, parent, parentTagName);
12402
+ if (element.namespaceURI === MATHML_NAMESPACE) return _checkMathMlNamespace(tagName, parent, parentTagName);
12403
+ if (element.namespaceURI === HTML_NAMESPACE) return _checkHtmlNamespace(tagName, parent, parentTagName);
12404
+ if (PARSER_MEDIA_TYPE === "application/xhtml+xml" && ALLOWED_NAMESPACES[element.namespaceURI]) return true;
11571
12405
  return false;
11572
12406
  };
11573
12407
  const _forceRemove = function _forceRemove2(node) {
11574
- arrayPush(DOMPurify.removed, {
11575
- element: node
11576
- });
12408
+ arrayPush(DOMPurify.removed, { element: node });
11577
12409
  try {
11578
12410
  getParentNode(node).removeChild(node);
11579
12411
  } catch (_2) {
11580
12412
  remove(node);
11581
- if (!getParentNode(node)) {
11582
- throw typeErrorCreate("a node selected for removal could not be detached from its tree and cannot be safely returned; refusing to sanitize in place");
11583
- }
12413
+ if (!getParentNode(node)) throw typeErrorCreate("a node selected for removal could not be detached from its tree and cannot be safely returned; refusing to sanitize in place");
11584
12414
  }
11585
12415
  };
11586
12416
  const _stripAttributeNode = function _stripAttributeNode2(element, attribute, name) {
@@ -11609,34 +12439,25 @@ function createDOMPurify() {
11609
12439
  });
11610
12440
  }
11611
12441
  const attributes = getAttributes(root);
11612
- if (attributes) {
11613
- for (let i = attributes.length - 1; i >= 0; --i) {
11614
- const attribute = attributes[i];
11615
- const name = attribute && attribute.name;
11616
- if (typeof name === "string") {
11617
- _stripAttributeNode(root, attribute, name);
11618
- }
11619
- }
12442
+ if (attributes) for (let i = attributes.length - 1; i >= 0; --i) {
12443
+ const attribute = attributes[i];
12444
+ const name = attribute && attribute.name;
12445
+ if (typeof name === "string") _stripAttributeNode(root, attribute, name);
11620
12446
  }
11621
12447
  };
11622
12448
  const _removeAttribute = function _removeAttribute2(name, element, attr) {
11623
- if (!attr) {
11624
- try {
11625
- attr = element.getAttributeNode(name);
11626
- } catch (_2) {
11627
- attr = null;
11628
- }
12449
+ if (!attr) try {
12450
+ attr = element.getAttributeNode(name);
12451
+ } catch (_2) {
12452
+ attr = null;
11629
12453
  }
11630
12454
  arrayPush(DOMPurify.removed, {
11631
12455
  attribute: attr || null,
11632
12456
  from: element
11633
12457
  });
11634
12458
  try {
11635
- if (attr) {
11636
- removeAttributeNode(element, attr);
11637
- } else {
11638
- element.removeAttribute(name);
11639
- }
12459
+ if (attr) removeAttributeNode(element, attr);
12460
+ else element.removeAttribute(name);
11640
12461
  } catch (_2) {
11641
12462
  try {
11642
12463
  element.removeAttribute(name);
@@ -11644,30 +12465,23 @@ function createDOMPurify() {
11644
12465
  }
11645
12466
  }
11646
12467
  if (name === "is") {
11647
- if (RETURN_DOM || RETURN_DOM_FRAGMENT) {
11648
- try {
11649
- _forceRemove(element);
11650
- } catch (_2) {
11651
- }
11652
- } else {
11653
- try {
11654
- element.setAttribute(name, "");
11655
- } catch (_2) {
11656
- }
12468
+ if (RETURN_DOM || RETURN_DOM_FRAGMENT) try {
12469
+ _forceRemove(element);
12470
+ } catch (_2) {
12471
+ }
12472
+ else try {
12473
+ element.setAttribute(name, "");
12474
+ } catch (_2) {
11657
12475
  }
11658
12476
  }
11659
12477
  };
11660
12478
  const _stripDisallowedAttributes = function _stripDisallowedAttributes2(element) {
11661
12479
  const attributes = getAttributes(element);
11662
- if (!attributes) {
11663
- return;
11664
- }
12480
+ if (!attributes) return;
11665
12481
  for (let i = attributes.length - 1; i >= 0; --i) {
11666
12482
  const attribute = attributes[i];
11667
12483
  const name = attribute && attribute.name;
11668
- if (typeof name !== "string" || ALLOWED_ATTR2[transformCaseFunc(name)]) {
11669
- continue;
11670
- }
12484
+ if (typeof name !== "string" || ALLOWED_ATTR2[transformCaseFunc(name)]) continue;
11671
12485
  _stripAttributeNode(element, attribute, name);
11672
12486
  }
11673
12487
  };
@@ -11675,31 +12489,18 @@ function createDOMPurify() {
11675
12489
  const stack = [root];
11676
12490
  while (stack.length > 0) {
11677
12491
  const node = stack.pop();
11678
- const nodeType = _readNodeType(node);
11679
- if (nodeType === NODE_TYPE.element) {
11680
- _stripDisallowedAttributes(node);
11681
- }
12492
+ if (_readNodeType(node) === NODE_TYPE.element) _stripDisallowedAttributes(node);
11682
12493
  const childNodes = getChildNodes(node);
11683
- if (childNodes) {
11684
- for (let i = childNodes.length - 1; i >= 0; --i) {
11685
- stack.push(childNodes[i]);
11686
- }
11687
- }
12494
+ if (childNodes) for (let i = childNodes.length - 1; i >= 0; --i) stack.push(childNodes[i]);
11688
12495
  }
11689
12496
  };
11690
12497
  const _isPatchLinkageAttribute = function _isPatchLinkageAttribute2(lcName, lcTag) {
11691
- if (!SAFE_FOR_XML) {
11692
- return false;
11693
- }
11694
- if (lcName === "patchsrc") {
11695
- return true;
11696
- }
12498
+ if (!SAFE_FOR_XML) return false;
12499
+ if (lcName === "patchsrc") return true;
11697
12500
  return lcName === "for" && lcTag !== "label" && lcTag !== "output";
11698
12501
  };
11699
12502
  const _neutralizePatchLinkage = function _neutralizePatchLinkage2(root) {
11700
- if (!SAFE_FOR_XML) {
11701
- return;
11702
- }
12503
+ if (!SAFE_FOR_XML) return;
11703
12504
  const stack = [root];
11704
12505
  while (stack.length > 0) {
11705
12506
  const node = stack.pop();
@@ -11715,41 +12516,28 @@ function createDOMPurify() {
11715
12516
  const element = node;
11716
12517
  const lcTag = transformCaseFunc(_readNodeName(node));
11717
12518
  try {
11718
- if (element.hasAttribute && element.hasAttribute("patchsrc")) {
11719
- element.removeAttribute("patchsrc");
11720
- }
11721
- if (element.hasAttribute && element.hasAttribute("for") && _isPatchLinkageAttribute("for", lcTag)) {
11722
- element.removeAttribute("for");
11723
- }
12519
+ if (element.hasAttribute && element.hasAttribute("patchsrc")) element.removeAttribute("patchsrc");
12520
+ if (element.hasAttribute && element.hasAttribute("for") && _isPatchLinkageAttribute("for", lcTag)) element.removeAttribute("for");
11724
12521
  } catch (_2) {
11725
12522
  }
11726
12523
  }
11727
12524
  const childNodes = getChildNodes(node);
11728
- if (childNodes) {
11729
- for (let i = childNodes.length - 1; i >= 0; --i) {
11730
- stack.push(childNodes[i]);
11731
- }
11732
- }
12525
+ if (childNodes) for (let i = childNodes.length - 1; i >= 0; --i) stack.push(childNodes[i]);
11733
12526
  }
11734
12527
  };
11735
12528
  const _initDocument = function _initDocument2(dirty) {
11736
12529
  let doc = null;
11737
12530
  let leadingWhitespace = null;
11738
- if (FORCE_BODY) {
11739
- dirty = "<remove></remove>" + dirty;
11740
- } else {
12531
+ if (FORCE_BODY) dirty = "<remove></remove>" + dirty;
12532
+ else {
11741
12533
  const matches = stringMatch(dirty, /^[\r\n\t ]+/);
11742
12534
  leadingWhitespace = matches && matches[0];
11743
12535
  }
11744
- if (PARSER_MEDIA_TYPE === "application/xhtml+xml" && NAMESPACE === HTML_NAMESPACE) {
11745
- dirty = '<html xmlns="http://www.w3.org/1999/xhtml"><head></head><body>' + dirty + "</body></html>";
11746
- }
12536
+ if (PARSER_MEDIA_TYPE === "application/xhtml+xml" && NAMESPACE === HTML_NAMESPACE) dirty = '<html xmlns="http://www.w3.org/1999/xhtml"><head></head><body>' + dirty + "</body></html>";
11747
12537
  const dirtyPayload = trustedTypesPolicy ? _createTrustedHTML(dirty) : dirty;
11748
- if (NAMESPACE === HTML_NAMESPACE) {
11749
- try {
11750
- doc = new DOMParser().parseFromString(dirtyPayload, PARSER_MEDIA_TYPE);
11751
- } catch (_2) {
11752
- }
12538
+ if (NAMESPACE === HTML_NAMESPACE) try {
12539
+ doc = new DOMParser().parseFromString(dirtyPayload, PARSER_MEDIA_TYPE);
12540
+ } catch (_2) {
11753
12541
  }
11754
12542
  if (!doc || !doc.documentElement) {
11755
12543
  doc = implementation.createDocument(NAMESPACE, "template", null);
@@ -11759,23 +12547,13 @@ function createDOMPurify() {
11759
12547
  }
11760
12548
  }
11761
12549
  const body = doc.body || doc.documentElement;
11762
- if (dirty && leadingWhitespace) {
11763
- body.insertBefore(document2.createTextNode(leadingWhitespace), body.childNodes[0] || null);
11764
- }
11765
- if (NAMESPACE === HTML_NAMESPACE) {
11766
- return getElementsByTagName.call(doc, WHOLE_DOCUMENT ? "html" : "body")[0];
11767
- }
12550
+ if (dirty && leadingWhitespace) body.insertBefore(document2.createTextNode(leadingWhitespace), body.childNodes[0] || null);
12551
+ if (NAMESPACE === HTML_NAMESPACE) return getElementsByTagName.call(doc, WHOLE_DOCUMENT ? "html" : "body")[0];
11768
12552
  return WHOLE_DOCUMENT ? doc.documentElement : body;
11769
12553
  };
11770
12554
  const _createNodeIterator = function _createNodeIterator2(root) {
11771
12555
  const doc = getOwnerDocument ? getOwnerDocument(root) : root.ownerDocument;
11772
- return createNodeIterator.call(
11773
- doc || root,
11774
- root,
11775
- // eslint-disable-next-line no-bitwise
11776
- NodeFilter2.SHOW_ELEMENT | NodeFilter2.SHOW_COMMENT | NodeFilter2.SHOW_TEXT | NodeFilter2.SHOW_PROCESSING_INSTRUCTION | NodeFilter2.SHOW_CDATA_SECTION,
11777
- null
11778
- );
12556
+ return createNodeIterator.call(doc || root, root, NodeFilter2.SHOW_ELEMENT | NodeFilter2.SHOW_COMMENT | NodeFilter2.SHOW_TEXT | NodeFilter2.SHOW_PROCESSING_INSTRUCTION | NodeFilter2.SHOW_CDATA_SECTION, null);
11779
12557
  };
11780
12558
  const _stripTemplateExpressions = function _stripTemplateExpressions2(value) {
11781
12559
  value = stringReplace(value, MUSTACHE_EXPR$1, " ");
@@ -11787,73 +12565,25 @@ function createDOMPurify() {
11787
12565
  var _node$querySelectorAl;
11788
12566
  node.normalize();
11789
12567
  const doc = getOwnerDocument ? getOwnerDocument(node) : node.ownerDocument;
11790
- const walker = createNodeIterator.call(
11791
- doc || node,
11792
- node,
11793
- // eslint-disable-next-line no-bitwise
11794
- NodeFilter2.SHOW_TEXT | NodeFilter2.SHOW_COMMENT | NodeFilter2.SHOW_CDATA_SECTION | NodeFilter2.SHOW_PROCESSING_INSTRUCTION,
11795
- null
11796
- );
12568
+ const walker = createNodeIterator.call(doc || node, node, NodeFilter2.SHOW_TEXT | NodeFilter2.SHOW_COMMENT | NodeFilter2.SHOW_CDATA_SECTION | NodeFilter2.SHOW_PROCESSING_INSTRUCTION, null);
11797
12569
  let currentNode = walker.nextNode();
11798
12570
  while (currentNode) {
11799
12571
  currentNode.data = _stripTemplateExpressions(currentNode.data);
11800
12572
  currentNode = walker.nextNode();
11801
12573
  }
11802
12574
  const templates = (_node$querySelectorAl = node.querySelectorAll) === null || _node$querySelectorAl === void 0 ? void 0 : _node$querySelectorAl.call(node, "template");
11803
- if (templates) {
11804
- arrayForEach(templates, (tmpl) => {
11805
- if (_isDocumentFragment(tmpl.content)) {
11806
- _scrubTemplateExpressions2(tmpl.content);
11807
- }
11808
- });
11809
- }
12575
+ if (templates) arrayForEach(templates, (tmpl) => {
12576
+ if (_isDocumentFragment(tmpl.content)) _scrubTemplateExpressions2(tmpl.content);
12577
+ });
11810
12578
  };
11811
12579
  const _isClobbered = function _isClobbered2(element) {
11812
12580
  const realTagName = getNodeName ? getNodeName(element) : null;
11813
- if (typeof realTagName !== "string") {
11814
- return false;
11815
- }
11816
- if (transformCaseFunc(realTagName) !== "form") {
11817
- return false;
11818
- }
11819
- return typeof element.nodeName !== "string" || typeof element.textContent !== "string" || typeof element.removeChild !== "function" || // Realm-safe NamedNodeMap detection: equality against the cached
11820
- // prototype getter. Clobbered .attributes (e.g. <input name="attributes">)
11821
- // makes the direct read diverge from the cached read; a clean form
11822
- // (same-realm OR foreign-realm) has both reads pointing at the same
11823
- // canonical NamedNodeMap.
11824
- element.attributes !== getAttributes(element) || typeof element.removeAttribute !== "function" || // A form descendant named "removeAttributeNode" or "getAttributeNode"
11825
- // shadows these Attr-node methods via [LegacyOverrideBuiltIns].
11826
- // _removeAttribute() / _stripAttributeNode() reach for
11827
- // element.removeAttributeNode(attr) first; when it is shadowed the call
11828
- // throws and the name-based fallback element.removeAttribute(name)
11829
- // ASCII-lowercases its lookup key in an HTML document, silently missing
11830
- // a case-preserved event-handler attribute (e.g. an ONANIMATIONSTART
11831
- // that reached the sanitizer through an XML/XHTML parse). Flag the form
11832
- // so it is removed wholesale, exactly as for the other shadowed methods.
11833
- typeof element.removeAttributeNode !== "function" || typeof element.getAttributeNode !== "function" || typeof element.setAttribute !== "function" || typeof element.namespaceURI !== "string" || typeof element.insertBefore !== "function" || typeof element.hasChildNodes !== "function" || // NodeType clobbering probe. Cached Node.prototype.nodeType getter
11834
- // returns the integer 1 for any Element regardless of realm; direct
11835
- // read on a clobbered form (e.g. <input name="nodeType">) returns
11836
- // the named child element. Cheap addition — nodeType is read from
11837
- // an internal slot, no serialization cost — and removes a residual
11838
- // clobbering surface used by several mXSS / PI / comment branches
11839
- // in _sanitizeElements that compare currentNode.nodeType directly.
11840
- element.nodeType !== getNodeType(element) || // HTMLFormElement has [LegacyOverrideBuiltIns]: a descendant named
11841
- // "childNodes" shadows the prototype getter. Direct reads of
11842
- // form.childNodes from a clobbered form return the named child
11843
- // instead of the real NodeList, so any walk that reads it directly
11844
- // skips the form's real children. Compare the direct read to the
11845
- // cached Node.prototype getter — when the form's named-property
11846
- // getter intercepts the read, the two values differ and we flag
11847
- // the form. This catches every clobbering child type (input,
11848
- // select, etc.) regardless of whether the named child happens to
11849
- // carry a numeric .length, which a typeof-based probe would miss
11850
- // (e.g. HTMLSelectElement.length is a defined unsigned-long).
11851
- element.childNodes !== getChildNodes(element);
12581
+ if (typeof realTagName !== "string") return false;
12582
+ if (transformCaseFunc(realTagName) !== "form") return false;
12583
+ return typeof element.nodeName !== "string" || typeof element.textContent !== "string" || typeof element.removeChild !== "function" || element.attributes !== getAttributes(element) || typeof element.removeAttribute !== "function" || typeof element.removeAttributeNode !== "function" || typeof element.getAttributeNode !== "function" || typeof element.setAttribute !== "function" || typeof element.namespaceURI !== "string" || typeof element.insertBefore !== "function" || typeof element.hasChildNodes !== "function" || element.nodeType !== getNodeType(element) || element.childNodes !== getChildNodes(element);
11852
12584
  };
11853
12585
  const _isDocumentFragment = function _isDocumentFragment2(value) {
11854
- if (!getNodeType || typeof value !== "object" || value === null) {
11855
- return false;
11856
- }
12586
+ if (!getNodeType || typeof value !== "object" || value === null) return false;
11857
12587
  try {
11858
12588
  return getNodeType(value) === NODE_TYPE.documentFragment;
11859
12589
  } catch (_2) {
@@ -11861,9 +12591,7 @@ function createDOMPurify() {
11861
12591
  }
11862
12592
  };
11863
12593
  const _isNode = function _isNode2(value) {
11864
- if (!getNodeType || typeof value !== "object" || value === null) {
11865
- return false;
11866
- }
12594
+ if (!getNodeType || typeof value !== "object" || value === null) return false;
11867
12595
  try {
11868
12596
  return typeof getNodeType(value) === "number";
11869
12597
  } catch (_2) {
@@ -11871,44 +12599,28 @@ function createDOMPurify() {
11871
12599
  }
11872
12600
  };
11873
12601
  function _executeHooks(hooks2, currentNode, data) {
11874
- if (hooks2.length === 0) {
11875
- return;
11876
- }
12602
+ if (hooks2.length === 0) return;
11877
12603
  arrayForEach(hooks2, (hook) => {
11878
12604
  hook.call(DOMPurify, currentNode, data, CONFIG);
11879
12605
  });
11880
12606
  }
11881
12607
  const _isUnsafeNode = function _isUnsafeNode2(currentNode, tagName) {
11882
- if (SAFE_FOR_XML && currentNode.hasChildNodes() && !_isNode(currentNode.firstElementChild) && regExpTest(ELEMENT_MARKUP_PROBE, currentNode.textContent) && regExpTest(ELEMENT_MARKUP_PROBE, currentNode.innerHTML)) {
11883
- return true;
11884
- }
11885
- if (SAFE_FOR_XML && currentNode.namespaceURI === HTML_NAMESPACE && LITERAL_TEXT_ELEMENTS[tagName] && (_isNode(currentNode.firstElementChild) || typeof currentNode.textContent === "string" && regExpTest(LITERAL_TEXT_CLOSE[tagName], currentNode.textContent))) {
11886
- return true;
11887
- }
11888
- if (currentNode.nodeType === NODE_TYPE.processingInstruction) {
11889
- return true;
11890
- }
11891
- if (SAFE_FOR_XML && currentNode.nodeType === NODE_TYPE.comment && regExpTest(COMMENT_MARKUP_PROBE, currentNode.data)) {
11892
- return true;
11893
- }
12608
+ if (SAFE_FOR_XML && currentNode.hasChildNodes() && !_isNode(currentNode.firstElementChild) && regExpTest(ELEMENT_MARKUP_PROBE, currentNode.textContent) && regExpTest(ELEMENT_MARKUP_PROBE, currentNode.innerHTML)) return true;
12609
+ if (SAFE_FOR_XML && currentNode.namespaceURI === HTML_NAMESPACE && LITERAL_TEXT_ELEMENTS[tagName] && (_isNode(currentNode.firstElementChild) || typeof currentNode.textContent === "string" && regExpTest(LITERAL_TEXT_CLOSE[tagName], currentNode.textContent))) return true;
12610
+ if (currentNode.nodeType === NODE_TYPE.processingInstruction) return true;
12611
+ if (SAFE_FOR_XML && currentNode.nodeType === NODE_TYPE.comment && regExpTest(COMMENT_MARKUP_PROBE, currentNode.data)) return true;
11894
12612
  return false;
11895
12613
  };
11896
12614
  const _matchesNameCheck = function _matchesNameCheck2(check, name) {
11897
- if (check instanceof RegExp) {
11898
- return regExpTest(check, name);
11899
- }
12615
+ if (check instanceof RegExp) return regExpTest(check, name);
11900
12616
  if (check instanceof Function) {
11901
- for (var _len = arguments.length, args = new Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++) {
11902
- args[_key - 2] = arguments[_key];
11903
- }
12617
+ for (var _len = arguments.length, args = new Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++) args[_key - 2] = arguments[_key];
11904
12618
  return Boolean(check(name, ...args));
11905
12619
  }
11906
12620
  return false;
11907
12621
  };
11908
12622
  const _sanitizeDisallowedNode = function _sanitizeDisallowedNode2(currentNode, tagName, root) {
11909
- if (!FORBID_TAGS[tagName] && _isBasicCustomElement(tagName) && _matchesNameCheck(CUSTOM_ELEMENT_HANDLING.tagNameCheck, tagName)) {
11910
- return false;
11911
- }
12623
+ if (!FORBID_TAGS[tagName] && _isBasicCustomElement(tagName) && _matchesNameCheck(CUSTOM_ELEMENT_HANDLING.tagNameCheck, tagName)) return false;
11912
12624
  if (KEEP_CONTENT && !FORBID_CONTENTS[tagName]) {
11913
12625
  const parentNode = getParentNode(currentNode);
11914
12626
  const childNodes = getChildNodes(currentNode);
@@ -11924,25 +12636,17 @@ function createDOMPurify() {
11924
12636
  return true;
11925
12637
  };
11926
12638
  const _forkSharedAllowlist = function _forkSharedAllowlist2(hookList, set, defaultSet, setConfigSet) {
11927
- if (hookList.length === 0) {
11928
- return set;
11929
- }
12639
+ if (hookList.length === 0) return set;
11930
12640
  return set === defaultSet || set === setConfigSet ? clone(set) : set;
11931
12641
  };
11932
12642
  const _handleHookDetachedNode = function _handleHookDetachedNode2(currentNode, root) {
11933
- if (currentNode === root || getParentNode(currentNode) !== null) {
11934
- return false;
11935
- }
11936
- if (IN_PLACE) {
11937
- _neutralizeSubtree(currentNode);
11938
- }
12643
+ if (currentNode === root || getParentNode(currentNode) !== null) return false;
12644
+ if (IN_PLACE) _neutralizeSubtree(currentNode);
11939
12645
  return true;
11940
12646
  };
11941
12647
  const _sanitizeElements = function _sanitizeElements2(currentNode, root) {
11942
12648
  _executeHooks(hooks.beforeSanitizeElements, currentNode, null);
11943
- if (_handleHookDetachedNode(currentNode, root)) {
11944
- return true;
11945
- }
12649
+ if (_handleHookDetachedNode(currentNode, root)) return true;
11946
12650
  if (_isClobbered(currentNode)) {
11947
12651
  _forceRemove(currentNode);
11948
12652
  return true;
@@ -11953,9 +12657,7 @@ function createDOMPurify() {
11953
12657
  tagName,
11954
12658
  allowedTags: ALLOWED_TAGS2
11955
12659
  });
11956
- if (_handleHookDetachedNode(currentNode, root)) {
11957
- return true;
11958
- }
12660
+ if (_handleHookDetachedNode(currentNode, root)) return true;
11959
12661
  if (_isUnsafeNode(currentNode, tagName)) {
11960
12662
  _forceRemove(currentNode);
11961
12663
  return true;
@@ -11964,11 +12666,11 @@ function createDOMPurify() {
11964
12666
  const removed = _sanitizeDisallowedNode(currentNode, tagName, root);
11965
12667
  if (removed === false) {
11966
12668
  _executeHooks(hooks.afterSanitizeElements, currentNode, null);
12669
+ if (_handleHookDetachedNode(currentNode, root)) return true;
11967
12670
  }
11968
12671
  return removed;
11969
12672
  }
11970
- const nt2 = _readNodeType(currentNode);
11971
- if (nt2 === NODE_TYPE.element && !_checkValidNamespace(currentNode)) {
12673
+ if (_readNodeType(currentNode) === NODE_TYPE.element && !_checkValidNamespace(currentNode)) {
11972
12674
  _forceRemove(currentNode);
11973
12675
  return true;
11974
12676
  }
@@ -11979,81 +12681,53 @@ function createDOMPurify() {
11979
12681
  if (SAFE_FOR_TEMPLATES && currentNode.nodeType === NODE_TYPE.text) {
11980
12682
  const content = _stripTemplateExpressions(currentNode.textContent);
11981
12683
  if (currentNode.textContent !== content) {
11982
- arrayPush(DOMPurify.removed, {
11983
- element: currentNode.cloneNode()
11984
- });
12684
+ arrayPush(DOMPurify.removed, { element: currentNode.cloneNode() });
11985
12685
  currentNode.textContent = content;
11986
12686
  }
11987
12687
  }
11988
12688
  _executeHooks(hooks.afterSanitizeElements, currentNode, null);
11989
- return false;
12689
+ return _handleHookDetachedNode(currentNode, root);
11990
12690
  };
11991
12691
  const _isValidAttribute = function _isValidAttribute2(lcTag, lcName, value) {
11992
- if (FORBID_ATTR[lcName]) {
11993
- return false;
11994
- }
11995
- if (_isPatchLinkageAttribute(lcName, lcTag)) {
11996
- return false;
11997
- }
11998
- if (SANITIZE_DOM && (lcName === "id" || lcName === "name") && (value in document2 || value in formElement)) {
11999
- return false;
12000
- }
12692
+ if (FORBID_ATTR[lcName]) return false;
12693
+ if (_isPatchLinkageAttribute(lcName, lcTag)) return false;
12694
+ if (SANITIZE_DOM && (lcName === "id" || lcName === "name") && (value in document2 || value in formElement)) return false;
12001
12695
  const nameIsPermitted = ALLOWED_ATTR2[lcName] || EXTRA_ELEMENT_HANDLING.attributeCheck instanceof Function && EXTRA_ELEMENT_HANDLING.attributeCheck(lcName, lcTag);
12002
- if (ALLOW_DATA_ATTR && regExpTest(DATA_ATTR$1, lcName)) {
12003
- return true;
12004
- }
12005
- if (ALLOW_ARIA_ATTR && regExpTest(ARIA_ATTR$1, lcName)) {
12006
- return true;
12007
- }
12008
- if (!nameIsPermitted) {
12009
- return (
12010
- // Condition a) covers a basically valid custom element tag name whose
12011
- // tag passes the configured tagNameCheck and whose attribute name
12012
- // passes the configured attributeNameCheck ...
12013
- _isBasicCustomElement(lcTag) && _matchesNameCheck(CUSTOM_ELEMENT_HANDLING.tagNameCheck, lcTag) && _matchesNameCheck(CUSTOM_ELEMENT_HANDLING.attributeNameCheck, lcName, lcTag) || // Condition b) covers an `is` attribute whose value passes the
12014
- // configured tagNameCheck while customized built-in elements are
12015
- // allowed.
12016
- lcName === "is" && CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements && _matchesNameCheck(CUSTOM_ELEMENT_HANDLING.tagNameCheck, value)
12017
- );
12018
- }
12019
- if (URI_SAFE_ATTRIBUTES[lcName]) {
12020
- return true;
12021
- }
12022
- if (regExpTest(IS_ALLOWED_URI$1, stringReplace(value, ATTR_WHITESPACE$1, ""))) {
12023
- return true;
12024
- }
12025
- if ((lcName === "src" || lcName === "xlink:href" || lcName === "href") && lcTag !== "script" && stringIndexOf(value, "data:") === 0 && DATA_URI_TAGS[lcTag]) {
12026
- return true;
12027
- }
12028
- if (ALLOW_UNKNOWN_PROTOCOLS && !regExpTest(IS_SCRIPT_OR_DATA$1, stringReplace(value, ATTR_WHITESPACE$1, ""))) {
12029
- return true;
12030
- }
12696
+ if (ALLOW_DATA_ATTR && regExpTest(DATA_ATTR$1, lcName)) return true;
12697
+ if (ALLOW_ARIA_ATTR && regExpTest(ARIA_ATTR$1, lcName)) return true;
12698
+ if (!nameIsPermitted) return _isBasicCustomElement(lcTag) && _matchesNameCheck(CUSTOM_ELEMENT_HANDLING.tagNameCheck, lcTag) && _matchesNameCheck(CUSTOM_ELEMENT_HANDLING.attributeNameCheck, lcName, lcTag) || lcName === "is" && CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements && _matchesNameCheck(CUSTOM_ELEMENT_HANDLING.tagNameCheck, value);
12699
+ if (URI_SAFE_ATTRIBUTES[lcName]) return true;
12700
+ if (regExpTest(IS_ALLOWED_URI$1, stringReplace(value, ATTR_WHITESPACE$1, ""))) return true;
12701
+ if ((lcName === "src" || lcName === "xlink:href" || lcName === "href") && lcTag !== "script" && stringIndexOf(value, "data:") === 0 && DATA_URI_TAGS[lcTag]) return true;
12702
+ if (ALLOW_UNKNOWN_PROTOCOLS && !regExpTest(IS_SCRIPT_OR_DATA$1, stringReplace(value, ATTR_WHITESPACE$1, ""))) return true;
12031
12703
  return !value;
12032
12704
  };
12033
- const RESERVED_CUSTOM_ELEMENT_NAMES = addToSet({}, ["annotation-xml", "color-profile", "font-face", "font-face-format", "font-face-name", "font-face-src", "font-face-uri", "missing-glyph"]);
12705
+ const RESERVED_CUSTOM_ELEMENT_NAMES = addToSet({}, [
12706
+ "annotation-xml",
12707
+ "color-profile",
12708
+ "font-face",
12709
+ "font-face-format",
12710
+ "font-face-name",
12711
+ "font-face-src",
12712
+ "font-face-uri",
12713
+ "missing-glyph"
12714
+ ]);
12034
12715
  const _isBasicCustomElement = function _isBasicCustomElement2(tagName) {
12035
12716
  return !RESERVED_CUSTOM_ELEMENT_NAMES[stringToLowerCase(tagName)] && regExpTest(CUSTOM_ELEMENT$1, tagName);
12036
12717
  };
12037
12718
  const _applyTrustedTypesToAttribute = function _applyTrustedTypesToAttribute2(lcTag, lcName, namespaceURI, value) {
12038
- if (trustedTypesPolicy && typeof trustedTypes === "object" && typeof trustedTypes.getAttributeType === "function" && !namespaceURI) {
12039
- switch (trustedTypes.getAttributeType(lcTag, lcName)) {
12040
- case "TrustedHTML": {
12041
- return _createTrustedHTML(value);
12042
- }
12043
- case "TrustedScriptURL": {
12044
- return _createTrustedScriptURL(value);
12045
- }
12046
- }
12719
+ if (trustedTypesPolicy && typeof trustedTypes === "object" && typeof trustedTypes.getAttributeType === "function" && !namespaceURI) switch (trustedTypes.getAttributeType(lcTag, lcName)) {
12720
+ case "TrustedHTML":
12721
+ return _createTrustedHTML(value);
12722
+ case "TrustedScriptURL":
12723
+ return _createTrustedScriptURL(value);
12047
12724
  }
12048
12725
  return value;
12049
12726
  };
12050
12727
  const _setAttributeValue = function _setAttributeValue2(currentNode, name, namespaceURI, value) {
12051
12728
  try {
12052
- if (namespaceURI) {
12053
- currentNode.setAttributeNS(namespaceURI, name, value);
12054
- } else {
12055
- currentNode.setAttribute(name, value);
12056
- }
12729
+ if (namespaceURI) currentNode.setAttributeNS(namespaceURI, name, value);
12730
+ else currentNode.setAttribute(name, value);
12057
12731
  if (_isClobbered(currentNode)) {
12058
12732
  _forceRemove(currentNode);
12059
12733
  return false;
@@ -12064,12 +12738,11 @@ function createDOMPurify() {
12064
12738
  return false;
12065
12739
  }
12066
12740
  };
12067
- const _sanitizeAttributes = function _sanitizeAttributes2(currentNode) {
12741
+ const _sanitizeAttributes = function _sanitizeAttributes2(currentNode, root) {
12068
12742
  _executeHooks(hooks.beforeSanitizeAttributes, currentNode, null);
12743
+ if (_handleHookDetachedNode(currentNode, root)) return;
12069
12744
  const attributes = currentNode.attributes;
12070
- if (!attributes || _isClobbered(currentNode)) {
12071
- return;
12072
- }
12745
+ if (!attributes || _isClobbered(currentNode)) return;
12073
12746
  ALLOWED_ATTR2 = _forkSharedAllowlist(hooks.uponSanitizeAttribute, ALLOWED_ATTR2, DEFAULT_ALLOWED_ATTR, SET_CONFIG_ALLOWED_ATTR);
12074
12747
  const hookEvent = {
12075
12748
  attrName: "",
@@ -12078,10 +12751,10 @@ function createDOMPurify() {
12078
12751
  allowedAttributes: ALLOWED_ATTR2,
12079
12752
  forceKeepAttr: void 0
12080
12753
  };
12081
- let l = attributes.length;
12754
+ let l3 = attributes.length;
12082
12755
  const lcTag = transformCaseFunc(currentNode.nodeName);
12083
- while (l--) {
12084
- const attr = attributes[l];
12756
+ while (l3--) {
12757
+ const attr = attributes[l3];
12085
12758
  const name = attr.name, namespaceURI = attr.namespaceURI, attrValue = attr.value;
12086
12759
  const lcName = transformCaseFunc(name);
12087
12760
  const initValue = attrValue;
@@ -12106,9 +12779,7 @@ function createDOMPurify() {
12106
12779
  _removeAttribute(name, currentNode, attr);
12107
12780
  continue;
12108
12781
  }
12109
- if (hookEvent.forceKeepAttr) {
12110
- continue;
12111
- }
12782
+ if (hookEvent.forceKeepAttr) continue;
12112
12783
  if (!hookEvent.keepAttr) {
12113
12784
  _removeAttribute(name, currentNode, attr);
12114
12785
  continue;
@@ -12117,22 +12788,18 @@ function createDOMPurify() {
12117
12788
  _removeAttribute(name, currentNode, attr);
12118
12789
  continue;
12119
12790
  }
12120
- if (SAFE_FOR_TEMPLATES) {
12121
- value = _stripTemplateExpressions(value);
12122
- }
12791
+ if (SAFE_FOR_TEMPLATES) value = _stripTemplateExpressions(value);
12123
12792
  if (!_isValidAttribute(lcTag, lcName, value)) {
12124
12793
  _removeAttribute(name, currentNode, attr);
12125
12794
  continue;
12126
12795
  }
12127
12796
  value = _applyTrustedTypesToAttribute(lcTag, lcName, namespaceURI, value);
12128
12797
  if (value !== initValue) {
12129
- const cleanWrite = _setAttributeValue(currentNode, name, namespaceURI, value);
12130
- if (cleanWrite && recreatedNamedProp) {
12131
- arrayPop(DOMPurify.removed);
12132
- }
12798
+ if (_setAttributeValue(currentNode, name, namespaceURI, value) && recreatedNamedProp) arrayPop(DOMPurify.removed);
12133
12799
  }
12134
12800
  }
12135
12801
  _executeHooks(hooks.afterSanitizeAttributes, currentNode, null);
12802
+ _handleHookDetachedNode(currentNode, root);
12136
12803
  };
12137
12804
  const _sanitizeShadowDOM2 = function _sanitizeShadowDOM(fragment) {
12138
12805
  let shadowNode = null;
@@ -12141,10 +12808,8 @@ function createDOMPurify() {
12141
12808
  while (shadowNode = shadowIterator.nextNode()) {
12142
12809
  _executeHooks(hooks.uponSanitizeShadowNode, shadowNode, null);
12143
12810
  _sanitizeElements(shadowNode, fragment);
12144
- _sanitizeAttributes(shadowNode);
12145
- if (_isDocumentFragment(shadowNode.content)) {
12146
- _sanitizeShadowDOM2(shadowNode.content);
12147
- }
12811
+ _sanitizeAttributes(shadowNode, fragment);
12812
+ if (_isDocumentFragment(shadowNode.content)) _sanitizeShadowDOM2(shadowNode.content);
12148
12813
  if (_readNodeType(shadowNode) === NODE_TYPE.element) {
12149
12814
  const innerSr = getShadowRoot(shadowNode);
12150
12815
  if (_isDocumentFragment(innerSr)) {
@@ -12167,40 +12832,31 @@ function createDOMPurify() {
12167
12832
  continue;
12168
12833
  }
12169
12834
  const node = item.node;
12170
- const nodeType = _readNodeType(node);
12171
- const isElement = nodeType === NODE_TYPE.element;
12835
+ const isElement = _readNodeType(node) === NODE_TYPE.element;
12172
12836
  const childNodes = getChildNodes(node);
12173
- if (childNodes) {
12174
- for (let i = childNodes.length - 1; i >= 0; --i) {
12175
- stack.push({
12176
- node: childNodes[i],
12177
- shadow: null
12178
- });
12179
- }
12180
- }
12837
+ if (childNodes) for (let i = childNodes.length - 1; i >= 0; --i) stack.push({
12838
+ node: childNodes[i],
12839
+ shadow: null
12840
+ });
12181
12841
  if (isElement) {
12182
12842
  const rootName = getNodeName ? getNodeName(node) : null;
12183
12843
  if (typeof rootName === "string" && transformCaseFunc(rootName) === "template") {
12184
12844
  const content = node.content;
12185
- if (_isDocumentFragment(content)) {
12186
- stack.push({
12187
- node: content,
12188
- shadow: null
12189
- });
12190
- }
12845
+ if (_isDocumentFragment(content)) stack.push({
12846
+ node: content,
12847
+ shadow: null
12848
+ });
12191
12849
  }
12192
12850
  }
12193
12851
  if (isElement) {
12194
12852
  const sr = getShadowRoot(node);
12195
- if (_isDocumentFragment(sr)) {
12196
- stack.push({
12197
- node: null,
12198
- shadow: sr
12199
- }, {
12200
- node: sr,
12201
- shadow: null
12202
- });
12203
- }
12853
+ if (_isDocumentFragment(sr)) stack.push({
12854
+ node: null,
12855
+ shadow: sr
12856
+ }, {
12857
+ node: sr,
12858
+ shadow: null
12859
+ });
12204
12860
  }
12205
12861
  }
12206
12862
  };
@@ -12211,30 +12867,18 @@ function createDOMPurify() {
12211
12867
  let currentNode = null;
12212
12868
  let returnNode = null;
12213
12869
  IS_EMPTY_INPUT = !dirty;
12214
- if (IS_EMPTY_INPUT) {
12215
- dirty = "<!-->";
12216
- }
12870
+ if (IS_EMPTY_INPUT) dirty = "<!-->";
12217
12871
  if (typeof dirty !== "string" && !_isNode(dirty)) {
12218
12872
  dirty = stringifyValue(dirty);
12219
- if (typeof dirty !== "string") {
12220
- throw typeErrorCreate("dirty is not a string, aborting");
12221
- }
12222
- }
12223
- if (!DOMPurify.isSupported) {
12224
- return dirty;
12873
+ if (typeof dirty !== "string") throw typeErrorCreate("dirty is not a string, aborting");
12225
12874
  }
12875
+ if (!DOMPurify.isSupported) return dirty;
12226
12876
  if (SET_CONFIG) {
12227
12877
  ALLOWED_TAGS2 = SET_CONFIG_ALLOWED_TAGS;
12228
12878
  ALLOWED_ATTR2 = SET_CONFIG_ALLOWED_ATTR;
12229
- } else {
12230
- _parseConfig(cfg);
12231
- }
12232
- if (hooks.uponSanitizeElement.length > 0 || hooks.uponSanitizeAttribute.length > 0) {
12233
- ALLOWED_TAGS2 = clone(ALLOWED_TAGS2);
12234
- }
12235
- if (hooks.uponSanitizeAttribute.length > 0) {
12236
- ALLOWED_ATTR2 = clone(ALLOWED_ATTR2);
12237
- }
12879
+ } else _parseConfig(cfg);
12880
+ if (hooks.uponSanitizeElement.length > 0 || hooks.uponSanitizeAttribute.length > 0) ALLOWED_TAGS2 = clone(ALLOWED_TAGS2);
12881
+ if (hooks.uponSanitizeAttribute.length > 0) ALLOWED_ATTR2 = clone(ALLOWED_ATTR2);
12238
12882
  DOMPurify.removed = [];
12239
12883
  const inPlace = IN_PLACE && typeof dirty !== "string" && _isNode(dirty);
12240
12884
  if (inPlace) {
@@ -12260,83 +12904,57 @@ function createDOMPurify() {
12260
12904
  } else if (_isNode(dirty)) {
12261
12905
  body = _initDocument("<!---->");
12262
12906
  importedNode = body.ownerDocument.importNode(dirty, true);
12263
- if (importedNode.nodeType === NODE_TYPE.element && importedNode.nodeName === "BODY") {
12264
- body = importedNode;
12265
- } else if (importedNode.nodeName === "HTML") {
12266
- body = importedNode;
12267
- } else {
12268
- body.appendChild(importedNode);
12269
- }
12907
+ if (importedNode.nodeType === NODE_TYPE.element && importedNode.nodeName === "BODY") body = importedNode;
12908
+ else if (importedNode.nodeName === "HTML") body = importedNode;
12909
+ else body.appendChild(importedNode);
12270
12910
  _sanitizeAttachedShadowRoots(body);
12271
12911
  } else {
12272
- if (!RETURN_DOM && !SAFE_FOR_TEMPLATES && !WHOLE_DOCUMENT && // eslint-disable-next-line unicorn/prefer-includes
12273
- dirty.indexOf("<") === -1) {
12274
- return trustedTypesPolicy && RETURN_TRUSTED_TYPE ? _createTrustedHTML(dirty) : dirty;
12275
- }
12912
+ if (!RETURN_DOM && !SAFE_FOR_TEMPLATES && !WHOLE_DOCUMENT && dirty.indexOf("<") === -1) return trustedTypesPolicy && RETURN_TRUSTED_TYPE ? _createTrustedHTML(dirty) : dirty;
12276
12913
  body = _initDocument(dirty);
12277
- if (!body) {
12278
- return RETURN_DOM ? null : RETURN_TRUSTED_TYPE ? emptyHTML : "";
12279
- }
12280
- }
12281
- if (body && FORCE_BODY) {
12282
- _forceRemove(body.firstChild);
12914
+ if (!body) return RETURN_DOM ? null : RETURN_TRUSTED_TYPE ? emptyHTML : "";
12283
12915
  }
12916
+ if (body && FORCE_BODY) _forceRemove(body.firstChild);
12284
12917
  const walkRoot = inPlace ? dirty : body;
12285
12918
  try {
12286
12919
  const nodeIterator = _createNodeIterator(walkRoot);
12287
12920
  while (currentNode = nodeIterator.nextNode()) {
12288
12921
  _sanitizeElements(currentNode, walkRoot);
12289
- _sanitizeAttributes(currentNode);
12290
- if (_isDocumentFragment(currentNode.content)) {
12291
- _sanitizeShadowDOM2(currentNode.content);
12292
- }
12922
+ _sanitizeAttributes(currentNode, walkRoot);
12923
+ if (_isDocumentFragment(currentNode.content)) _sanitizeShadowDOM2(currentNode.content);
12293
12924
  }
12294
12925
  } catch (error) {
12295
12926
  if (inPlace) {
12296
12927
  _neutralizeRoot(dirty);
12297
12928
  arrayForEach(DOMPurify.removed, (entry) => {
12298
- if (entry.element) {
12299
- _neutralizeSubtree(entry.element);
12300
- }
12929
+ if (entry.element) _neutralizeSubtree(entry.element);
12301
12930
  });
12302
12931
  }
12303
12932
  throw error;
12304
12933
  }
12305
12934
  if (inPlace) {
12935
+ let rootWasRemoved = false;
12306
12936
  arrayForEach(DOMPurify.removed, (entry) => {
12307
12937
  if (entry.element) {
12938
+ if (entry.element === dirty) rootWasRemoved = true;
12308
12939
  _neutralizeSubtree(entry.element);
12309
12940
  }
12310
12941
  });
12311
- if (SAFE_FOR_TEMPLATES) {
12312
- _scrubTemplateExpressions2(dirty);
12313
- }
12942
+ if (rootWasRemoved) throw typeErrorCreate("a node selected for removal could not be safely returned; refusing to sanitize in place");
12943
+ if (SAFE_FOR_TEMPLATES) _scrubTemplateExpressions2(dirty);
12314
12944
  return dirty;
12315
12945
  }
12316
12946
  if (RETURN_DOM) {
12317
- if (SAFE_FOR_TEMPLATES) {
12318
- _scrubTemplateExpressions2(body);
12319
- }
12947
+ if (SAFE_FOR_TEMPLATES) _scrubTemplateExpressions2(body);
12320
12948
  if (RETURN_DOM_FRAGMENT) {
12321
12949
  returnNode = createDocumentFragment.call(body.ownerDocument);
12322
- while (body.firstChild) {
12323
- returnNode.appendChild(body.firstChild);
12324
- }
12325
- } else {
12326
- returnNode = body;
12327
- }
12328
- if (ALLOWED_ATTR2.shadowroot || ALLOWED_ATTR2.shadowrootmode) {
12329
- returnNode = importNode.call(originalDocument, returnNode, true);
12330
- }
12950
+ while (body.firstChild) returnNode.appendChild(body.firstChild);
12951
+ } else returnNode = body;
12952
+ if (ALLOWED_ATTR2.shadowroot || ALLOWED_ATTR2.shadowrootmode) returnNode = importNode.call(originalDocument, returnNode, true);
12331
12953
  return returnNode;
12332
12954
  }
12333
12955
  let serializedHTML = WHOLE_DOCUMENT ? body.outerHTML : body.innerHTML;
12334
- if (WHOLE_DOCUMENT && ALLOWED_TAGS2["!doctype"] && body.ownerDocument && body.ownerDocument.doctype && body.ownerDocument.doctype.name && regExpTest(DOCTYPE_NAME, body.ownerDocument.doctype.name)) {
12335
- serializedHTML = "<!DOCTYPE " + body.ownerDocument.doctype.name + ">\n" + serializedHTML;
12336
- }
12337
- if (SAFE_FOR_TEMPLATES) {
12338
- serializedHTML = _stripTemplateExpressions(serializedHTML);
12339
- }
12956
+ if (WHOLE_DOCUMENT && ALLOWED_TAGS2["!doctype"] && body.ownerDocument && body.ownerDocument.doctype && body.ownerDocument.doctype.name && regExpTest(DOCTYPE_NAME, body.ownerDocument.doctype.name)) serializedHTML = "<!DOCTYPE " + body.ownerDocument.doctype.name + ">\n" + serializedHTML;
12957
+ if (SAFE_FOR_TEMPLATES) serializedHTML = _stripTemplateExpressions(serializedHTML);
12340
12958
  return trustedTypesPolicy && RETURN_TRUSTED_TYPE ? _createTrustedHTML(serializedHTML) : serializedHTML;
12341
12959
  };
12342
12960
  DOMPurify.setConfig = function() {
@@ -12355,26 +12973,18 @@ function createDOMPurify() {
12355
12973
  emptyHTML = "";
12356
12974
  };
12357
12975
  DOMPurify.isValidAttribute = function(tag, attr, value) {
12358
- if (!CONFIG) {
12359
- _parseConfig({});
12360
- }
12976
+ if (!CONFIG) _parseConfig({});
12361
12977
  const lcTag = transformCaseFunc(tag);
12362
12978
  const lcName = transformCaseFunc(attr);
12363
12979
  return _isValidAttribute(lcTag, lcName, value);
12364
12980
  };
12365
12981
  DOMPurify.addHook = function(entryPoint, hookFunction) {
12366
- if (typeof hookFunction !== "function") {
12367
- return;
12368
- }
12369
- if (!objectHasOwnProperty(hooks, entryPoint)) {
12370
- return;
12371
- }
12982
+ if (typeof hookFunction !== "function") return;
12983
+ if (!objectHasOwnProperty(hooks, entryPoint)) return;
12372
12984
  arrayPush(hooks[entryPoint], hookFunction);
12373
12985
  };
12374
12986
  DOMPurify.removeHook = function(entryPoint, hookFunction) {
12375
- if (!objectHasOwnProperty(hooks, entryPoint)) {
12376
- return void 0;
12377
- }
12987
+ if (!objectHasOwnProperty(hooks, entryPoint)) return;
12378
12988
  if (hookFunction !== void 0) {
12379
12989
  const index = arrayLastIndexOf(hooks[entryPoint], hookFunction);
12380
12990
  return index === -1 ? void 0 : arraySplice(hooks[entryPoint], index, 1)[0];
@@ -12382,9 +12992,7 @@ function createDOMPurify() {
12382
12992
  return arrayPop(hooks[entryPoint]);
12383
12993
  };
12384
12994
  DOMPurify.removeHooks = function(entryPoint) {
12385
- if (!objectHasOwnProperty(hooks, entryPoint)) {
12386
- return;
12387
- }
12995
+ if (!objectHasOwnProperty(hooks, entryPoint)) return;
12388
12996
  hooks[entryPoint] = [];
12389
12997
  };
12390
12998
  DOMPurify.removeAllHooks = function() {
@@ -12392,190 +13000,203 @@ function createDOMPurify() {
12392
13000
  };
12393
13001
  return DOMPurify;
12394
13002
  }
12395
- var purify = createDOMPurify();
13003
+ var purify_default = createDOMPurify();
12396
13004
 
12397
- // node_modules/.pnpm/marked@18.0.12/node_modules/marked/lib/marked.esm.js
12398
- function A() {
13005
+ // node_modules/.pnpm/marked@18.0.14/node_modules/marked/lib/marked.esm.js
13006
+ function I() {
12399
13007
  return { async: false, breaks: false, extensions: null, gfm: true, hooks: null, pedantic: false, renderer: null, silent: false, tokenizer: null, walkTokens: null };
12400
13008
  }
12401
- var T = A();
12402
- function j(u3) {
12403
- T = u3;
13009
+ var y = I();
13010
+ function W(l3) {
13011
+ y = l3;
12404
13012
  }
12405
- var E = { exec: () => null };
12406
- function I(u3) {
13013
+ var A = { exec: () => null };
13014
+ function C(l3) {
12407
13015
  let e = [];
12408
13016
  return (t) => {
12409
13017
  let n = Math.max(0, Math.min(3, t - 1)), s = e[n];
12410
- return s || (s = u3(n), e[n] = s), s;
13018
+ return s || (s = l3(n), e[n] = s), s;
12411
13019
  };
12412
13020
  }
12413
- function k(u3, e = "") {
12414
- let t = typeof u3 == "string" ? u3 : u3.source, n = { replace: (s, r) => {
13021
+ function h(l3, e = "") {
13022
+ let t = typeof l3 == "string" ? l3 : l3.source, n = { replace: (s, r) => {
12415
13023
  let o = typeof r == "string" ? r : r.source;
12416
- return o = o.replace(m.caret, "$1"), t = t.replace(s, o), n;
13024
+ return o = o.replace(x.caret, "$1"), t = t.replace(s, o), n;
12417
13025
  }, getRegex: () => new RegExp(t, e) };
12418
13026
  return n;
12419
13027
  }
12420
- var Te = ((u3 = "") => {
13028
+ var _e = ((l3 = "") => {
12421
13029
  try {
12422
- return !!new RegExp("(?<=1)(?<!1)" + u3);
13030
+ return !!new RegExp("(?<=1)(?<!1)" + l3);
12423
13031
  } catch {
12424
13032
  return false;
12425
13033
  }
12426
13034
  })();
12427
- var m = { codeRemoveIndent: /^(?: {1,4}| {0,3}\t)/gm, outputLinkReplace: /\\([\[\]])/g, indentCodeCompensation: /^(\s+)(?:```)/, beginningSpace: /^\s+/, endingHash: /#$/, startingSpaceChar: /^ /, endingSpaceChar: / $/, endingSpaceTabChar: /[ \t]$/, nonSpaceChar: /[^ ]/, newLineCharGlobal: /\n/g, tabCharGlobal: /\t/g, multipleSpaceGlobal: /\s+/g, blankLine: /^[ \t]*$/, doubleBlankLine: /\n[ \t]*\n[ \t]*$/, blockquoteStart: /^ {0,3}>/, blockquoteSetextReplace: /\n {0,3}((?:=+|-+) *)(?=\n|$)/g, blockquoteSetextReplace2: /^ {0,3}>[ \t]?/gm, listReplaceNesting: /^ {1,4}(?=( {4})*[^ ])/g, listIsTask: /^\[[ xX]\] +\S/, listReplaceTask: /^\[[ xX]\] +/, listTaskCheckbox: /\[[ xX]\]/, anyLine: /\n.*\n/, hrefBrackets: /^<(.*)>$/, tableDelimiter: /[:|]/, tableAlignChars: /^\||\| *$/g, tableRowBlankLine: /\n[ \t]*$/, tableAlignRight: /^ *-+: *$/, tableAlignCenter: /^ *:-+: *$/, tableAlignLeft: /^ *:-+ *$/, startATag: /^<a /i, endATag: /^<\/a>/i, startPreScriptTag: /^<(pre|code|kbd|script)(\s|>)/i, endPreScriptTag: /^<\/(pre|code|kbd|script)(\s|>)/i, startAngleBracket: /^</, endAngleBracket: />$/, pedanticHrefTitle: /^([^'"]*[^\s])\s+(['"])(.*)\2/, unicodeAlphaNumeric: /[\p{L}\p{N}]/u, escapeTest: /[&<>"']/, escapeReplace: /[&<>"']/g, escapeTestNoEncode: /[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/, escapeReplaceNoEncode: /[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/g, caret: /(^|[^\[])\^/g, percentDecode: /%25/g, findPipe: /\|/g, splitPipe: / \|/, slashPipe: /\\\|/g, carriageReturn: /\r\n|\r/g, spaceLine: /^ +$/gm, notSpaceStart: /^\S*/, endingNewline: /\n$/, listItemRegex: (u3) => new RegExp(`^( {0,3}${u3})((?:[ ][^\\n]*)?(?:\\n|$))`), nextBulletRegex: I((u3) => new RegExp(`^ {0,${u3}}(?:[*+-]|\\d{1,9}[.)])((?:[ ][^\\n]*)?(?:\\n|$))`)), hrRegex: I((u3) => new RegExp(`^ {0,${u3}}((?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$)`)), fencesBeginRegex: I((u3) => new RegExp(`^ {0,${u3}}(?:\`\`\`|~~~)`)), headingBeginRegex: I((u3) => new RegExp(`^ {0,${u3}}#`)), htmlBeginRegex: I((u3) => new RegExp(`^ {0,${u3}}<(?:[a-z].*>|!--)`, "i")), blockquoteBeginRegex: I((u3) => new RegExp(`^ {0,${u3}}>`)) };
12428
- var Oe = /^(?:[ \t]*(?:\n|$))+/;
12429
- var we = /^((?: {4}| {0,3}\t)[^\n]+(?:\n(?:[ \t]*(?:\n|$))*)?)+/;
12430
- var ye = /^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}\1[~`]* *(?=\n|$)|$)/;
12431
- var q = /^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/;
12432
- var Pe = /^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/;
12433
- var U = / {0,3}(?:[*+-]|\d{1,9}[.)])/;
12434
- var oe = /^(?!bull |blockCode|fences|blockquote|heading|html|table)((?:.|\n(?!\s*?\n|bull |blockCode|fences|blockquote|heading|html|table))+?)\n {0,3}(=+|-+) *(?:\n+|$)/;
12435
- var ae = k(oe).replace(/bull/g, U).replace(/blockCode/g, /(?: {4}| {0,3}\t)/).replace(/fences/g, / {0,3}(?:`{3,}|~{3,})/).replace(/blockquote/g, / {0,3}>/).replace(/heading/g, / {0,3}#{1,6}(?:\s|$)/).replace(/html/g, / {0,3}<[^\n>]+>\n/).replace(/\|table/g, "").getRegex();
12436
- var Se = k(oe).replace(/bull/g, U).replace(/blockCode/g, /(?: {4}| {0,3}\t)/).replace(/fences/g, / {0,3}(?:`{3,}|~{3,})/).replace(/blockquote/g, / {0,3}>/).replace(/heading/g, / {0,3}#{1,6}(?:\s|$)/).replace(/html/g, / {0,3}<[^\n>]+>\n/).replace(/table/g, / {0,3}\|?(?:[:\- ]*\|)+[\:\- ]*\n/).getRegex();
12437
- var K = /^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table|[ \t]+\n)[^\n]+)*)/;
12438
- var _e = /^[^\n]+/;
12439
- var W = /(?!\s*\])(?:\\[\s\S]|[^\[\]\\])+/;
12440
- var $e = k(/^ {0,3}\[(label)\]: *(?:\n[ \t]*)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n[ \t]*)?| *\n[ \t]*)(title))? *(?:\n+|$)/).replace("label", W).replace("title", /(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/).getRegex();
12441
- var Le = k(/^(bull)([ \t][^\n]*?)?(?:\n|$)/).replace(/bull/g, U).getRegex();
12442
- var Q = "address|article|aside|base|basefont|blockquote|body|caption|center|col|colgroup|dd|details|dialog|dir|div|dl|dt|fieldset|figcaption|figure|footer|form|frame|frameset|h[1-6]|head|header|hr|html|iframe|legend|li|link|main|menu|menuitem|meta|nav|noframes|ol|optgroup|option|p|param|search|section|summary|table|tbody|td|tfoot|th|thead|title|tr|track|ul";
12443
- var X = /<!--(?:-?>|[\s\S]*?(?:-->|$))/;
12444
- var ze = k("^ {0,3}(?:<(script|pre|style|textarea)[\\s>][\\s\\S]*?(?:</\\1>[^\\n]*\\n*|$)|comment[^\\n]*(\\n+|$)|<\\?[\\s\\S]*?(?:\\?>[^\\n]*\\n*|$)|<![A-Z][\\s\\S]*?(?:>[^\\n]*\\n*|$)|<!\\[CDATA\\[[\\s\\S]*?(?:\\]\\]>[^\\n]*\\n*|$)|</?(tag)(?: +|\\n|/?>)[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$)|<(?!script|pre|style|textarea)([a-z][a-z0-9-]*)(?:attribute)*? */?>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$)|</(?!script|pre|style|textarea)[a-z][a-z0-9-]*\\s*>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$))", "i").replace("comment", X).replace("tag", Q).replace("attribute", / +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex();
12445
- var le = (u3) => k(K).replace("hr", q).replace("heading", " {0,3}#{1,6}(?:\\s|$)").replace("|lheading", "").replace("|table", "").replace("blockquote", " {0,3}>").replace("fences", " {0,3}(?:`{3,}(?=[^`\\n]*(?:\\n|$))|~~~)[^\\n]*(?:\\n|$)").replace("list", u3).replace("html", "</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag", Q).getRegex();
12446
- var Ee = le(/ {0,3}(?:[*+-]|1[.)])[ \t]+[^ \t\n]/);
12447
- var Me = le(/ {0,3}(?:[*+-]|\d{1,9}[.)])(?:[ \t]|\n|$)/);
12448
- var Ae = k(/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/).replace("paragraph", Me).getRegex();
12449
- var J = { blockquote: Ae, code: we, def: $e, fences: ye, heading: Pe, hr: q, html: ze, lheading: ae, list: Le, newline: Oe, paragraph: Ee, table: E, text: _e };
12450
- var se = k("^ *([^\\n ].*)\\n {0,3}((?:\\| *)?:?-+:? *(?:\\| *:?-+:? *)*(?:\\| *)?)(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)").replace("hr", q).replace("heading", " {0,3}#{1,6}(?:\\s|$)").replace("blockquote", " {0,3}>").replace("code", "(?: {4}| {0,3} )[^\\n]").replace("fences", " {0,3}(?:`{3,}(?=[^`\\n]*(?:\\n|$))|~~~)[^\\n]*(?:\\n|$)").replace("list", " {0,3}(?:[*+-]|1[.)])[ \\t]").replace("html", "</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag", Q).getRegex();
12451
- var Ie = { ...J, lheading: Se, table: se, paragraph: k(K).replace("hr", q).replace("heading", " {0,3}#{1,6}(?:\\s|$)").replace("|lheading", "").replace("table", se).replace("blockquote", " {0,3}>").replace("fences", " {0,3}(?:`{3,}(?=[^`\\n]*(?:\\n|$))|~~~)[^\\n]*(?:\\n|$)").replace("list", " {0,3}(?:[*+-]|1[.)])[ \\t]+[^ \\t\\n]").replace("html", "</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag", Q).getRegex() };
12452
- var Ce = { ...J, html: k(`^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:"[^"]*"|'[^']*'|\\s[^'"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))`).replace("comment", X).replace(/tag/g, "(?!(?:a|em|strong|small|s|cite|q|dfn|abbr|data|time|code|var|samp|kbd|sub|sup|i|b|u|mark|ruby|rt|rp|bdi|bdo|span|br|wbr|ins|del|img)\\b)\\w+(?!:|[^\\w\\s@]*@)\\b").getRegex(), def: /^ *\[([^\]]+)\]: *<?([^\s>]+)>?(?: +(["(][^\n]+[")]))? *(?:\n+|$)/, heading: /^(#{1,6})(.*)(?:\n+|$)/, fences: E, lheading: /^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/, paragraph: k(K).replace("hr", q).replace("heading", ` *#{1,6} *[^
12453
- ]`).replace("lheading", ae).replace("|table", "").replace("blockquote", " {0,3}>").replace("|fences", "").replace("|list", "").replace("|html", "").replace("|tag", "").getRegex() };
12454
- var Be = /^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/;
12455
- var De = /^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/;
12456
- var ue = /^( {2,}|\\)\n(?!\s*$)/;
12457
- var qe = /^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/;
12458
- var _ = /[\p{P}\p{S}]/u;
12459
- var C = /[\s\p{P}\p{S}]/u;
12460
- var v = /[^\s\p{P}\p{S}]/u;
12461
- var ve = k(/^((?![*_])punctSpace)/, "u").replace(/punctSpace/g, C).getRegex();
12462
- var He = /[\p{Pi}\p{Ps}"']/u;
12463
- var pe = /(?!~)[\p{P}\p{S}]/u;
12464
- var Ze = /(?!~)[\s\p{P}\p{S}]/u;
12465
- var Ge = /(?:[^\s\p{P}\p{S}]|~)/u;
12466
- var Qe = k(/link|precode-code|html/, "g").replace("link", /\[(?:[^\[\]`]|(?<a>`+)[^`]+\k<a>(?!`))*?\]\((?:\\[\s\S]|[^\\\(\)]|\((?:\\[\s\S]|[^\\\(\)])*\))*\)/).replace("precode-", Te ? "(?<!`)()" : "(^^|[^`])").replace("code", /(?<b>`+)[^`]+\k<b>(?!`)/).replace("html", /<(?! )[^<>]*?>/).getRegex();
12467
- var ce = /^(?:\*+(?:((?!\*)punct)|([^\s*]))?)|^_+(?:((?!_)punct)|([^\s_]))?/;
12468
- var Ne = k(ce, "u").replace(/punct/g, _).getRegex();
12469
- var je = k(ce, "u").replace(/punct/g, pe).getRegex();
12470
- var Fe = /^(?:\*+(?:((?!\*)(?!openQuote)punct)|([^\s*]))?)|^_+(?:((?!_)(?!openQuote)punct)|([^\s_]))?/;
12471
- var Ue = k(Fe, "u").replace(/openQuote/g, He).replace(/punct/g, _).getRegex();
12472
- var he = "^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)punct(\\*+)(?=[\\s]|$)|notPunctSpace(\\*+)(?!\\*)(?=punctSpace|$)|(?!\\*)punctSpace(\\*+)(?=notPunctSpace)|[\\s](\\*+)(?!\\*)(?=punct)|(?!\\*)punct(\\*+)(?!\\*)(?=punct)|notPunctSpace(\\*+)(?=notPunctSpace)";
12473
- var Ke = k(he, "gu").replace(/notPunctSpace/g, v).replace(/punctSpace/g, C).replace(/punct/g, _).getRegex();
12474
- var We = k(he, "gu").replace(/notPunctSpace/g, Ge).replace(/punctSpace/g, Ze).replace(/punct/g, pe).getRegex();
12475
- var Xe = "^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)punct(\\*+)(?=[\\s]|$)|notPunctSpace(\\*+)(?!\\*)(?=punctSpace|$)|(?!\\*)[\\s](\\*+)(?=notPunctSpace)|[\\s](\\*+)(?!\\*)(?=punct)|(?!\\*)punct(\\*+)(?!\\*)(?=punct)|(?:(?!\\*)punct|notPunctSpace)(\\*+)(?!\\*)(?=notPunctSpace)";
12476
- var Je = k(Xe, "gu").replace(/notPunctSpace/g, v).replace(/punctSpace/g, C).replace(/punct/g, _).getRegex();
12477
- var Ve = k("^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)punct(_+)(?=[\\s]|$)|notPunctSpace(_+)(?!_)(?=punctSpace|$)|(?!_)punctSpace(_+)(?=notPunctSpace)|[\\s](_+)(?!_)(?=punct)|(?!_)punct(_+)(?!_)(?=punct)", "gu").replace(/notPunctSpace/g, v).replace(/punctSpace/g, C).replace(/punct/g, _).getRegex();
12478
- var Ye = "^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)punct(_+)(?=[\\s]|$)|notPunctSpace(_+)(?!_)(?=punctSpace|$)|(?!_)[\\s](_+)(?=notPunctSpace)|[\\s](_+)(?!_)(?=punct)|(?!_)punct(_+)(?!_)(?=punct)|(?:(?!_)punct|notPunctSpace)(_+)(?!_)(?=notPunctSpace)";
12479
- var et = k(Ye, "gu").replace(/notPunctSpace/g, v).replace(/punctSpace/g, C).replace(/punct/g, _).getRegex();
12480
- var tt = k(/^~~?(?:((?!~)punct)|[^\s~])/, "u").replace(/punct/g, _).getRegex();
12481
- var nt = "^[^~]+(?=[^~])|(?!~)punct(~~?)(?=[\\s]|$)|notPunctSpace(~~?)(?!~)(?=punctSpace|$)|(?!~)punctSpace(~~?)(?=notPunctSpace)|[\\s](~~?)(?!~)(?=punct)|(?!~)punct(~~?)(?!~)(?=punct)|notPunctSpace(~~?)(?=notPunctSpace)";
12482
- var rt = k(nt, "gu").replace(/notPunctSpace/g, v).replace(/punctSpace/g, C).replace(/punct/g, _).getRegex();
12483
- var st = k(/\\(punct)/, "gu").replace(/punct/g, _).getRegex();
12484
- var it = k(/^<(scheme:[^\s\x00-\x1f<>]*|email)>/).replace("scheme", /[a-zA-Z][a-zA-Z0-9+.-]{1,31}/).replace("email", /[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+(@)[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)+(?![-_])/).getRegex();
12485
- var ot = k(X).replace("(?:-->|$)", "-->").getRegex();
12486
- var at = k("^comment|^</[a-zA-Z][a-zA-Z0-9-]*\\s*>|^<[a-zA-Z][a-zA-Z0-9-]*(?:attribute)*?\\s*/?>|^<\\?[\\s\\S]*?\\?>|^<![a-zA-Z]+\\s[\\s\\S]*?>|^<!\\[CDATA\\[[\\s\\S]*?\\]\\]>").replace("comment", ot).replace("attribute", /\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/).getRegex();
12487
- var lt = /\[(?:\\[\s\S]|[^\[\]\\])*\]/;
12488
- var G = k(/(?:\[(?:brackets|\\[\s\S]|[^\[\]\\])*\]|\\[\s\S]|`+(?!`)[^`]*?`+(?!`)|``+(?=\])|[^\[\]\\`])*?/).replace("brackets", lt).getRegex();
12489
- var ut = k(/^!?\[(label)\]\(\s*(href)(?:(?:[ \t]+(?:\n[ \t]*)?|\n[ \t]*)(title))?\s*\)/).replace("label", G).replace("href", /<(?:\\.|[^\n<>\\])+>|[^ \t\n\x00-\x1f]+|(?=\))/).replace("title", /"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/).getRegex();
12490
- var ke = k(/^!?\[(label)\]\[(ref)\]/).replace("label", G).replace("ref", W).getRegex();
12491
- var de = k(/^!?\[(ref)\](?:\[\])?/).replace("ref", W).getRegex();
12492
- var pt = k("reflink|nolink(?!\\()", "g").replace("reflink", ke).replace("nolink", de).getRegex();
12493
- var ie = /[hH][tT][tT][pP][sS]?|[fF][tT][pP]/;
12494
- var V = { _backpedal: E, anyPunctuation: st, autolink: it, blockSkip: Qe, br: ue, code: De, del: E, delLDelim: E, delRDelim: E, emStrongLDelim: Ne, emStrongRDelimAst: Ke, emStrongRDelimUnd: Ve, escape: Be, link: ut, nolink: de, punctuation: ve, reflink: ke, reflinkSearch: pt, tag: at, text: qe, url: E };
12495
- var ct = { ...V, emStrongLDelim: Ue, emStrongRDelimAst: Je, emStrongRDelimUnd: et, link: k(/^!?\[(label)\]\((.*?)\)/).replace("label", G).getRegex(), reflink: k(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace("label", G).getRegex() };
12496
- var F = { ...V, emStrongRDelimAst: We, emStrongLDelim: je, delLDelim: tt, delRDelim: rt, url: k(/^((?:protocol):\/\/|www\.)(?:[a-zA-Z0-9\-]+\.?)+[^\s<]*|^email/).replace("protocol", ie).replace("email", /[A-Za-z0-9._+-]+(@)[a-zA-Z0-9-_]+(?:\.[a-zA-Z0-9-_]*[a-zA-Z0-9])+(?![\w-])/).getRegex(), _backpedal: /(?:[^?!.,:;*_'"~()&]+|\([^)]*\)|&(?![a-zA-Z0-9]+;$)|[?!.,:;*_'"~)]+(?!$))+/, del: /^(~~?)(?=[^\s~])((?:\\[\s\S]|[^\\])*?(?:\\[\s\S]|[^\s~\\]))\1(?=[^~]|$)/, text: k(/^(`+|~+|[^`~])(?:(?=[`~])|(?= {2,}\n)|(?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)|[\s\S]*?(?:(?=[\\<!\[`*~_]|\b_|protocol:\/\/|www\.|$)|[^ ](?= {2,}\n)|[^a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-](?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)))/).replace("protocol", ie).getRegex() };
12497
- var ht = { ...F, br: k(ue).replace("{2,}", "*").getRegex(), text: k(F.text).replace("\\b_", "\\b_| {2,}\\n").replace(/\{2,\}/g, "*").getRegex() };
12498
- var H = { normal: J, gfm: Ie, pedantic: Ce };
12499
- var B = { normal: V, gfm: F, breaks: ht, pedantic: ct };
12500
- var kt = { "&": "&amp;", "<": "&lt;", ">": "&gt;", '"': "&quot;", "'": "&#39;" };
12501
- var ge = (u3) => kt[u3];
12502
- function R(u3, e) {
13035
+ var x = { codeRemoveIndent: /^(?: {0,3}\t| {1,4})/gm, outputLinkReplace: /\\([\[\]])/g, indentCodeCompensation: /^(\s+)(?:```)/, beginningSpace: /^\s+/, endingHash: /#$/, startingSpaceChar: /^ /, endingSpaceChar: / $/, endingSpaceTabChar: /[ \t]$/, nonSpaceChar: /[^ ]/, newLineCharGlobal: /\n/g, tabCharGlobal: /\t/g, leadingSpaceTab: /^[ \t]+/, multipleSpaceGlobal: /\s+/g, blankLine: /^[ \t]*$/, doubleBlankLine: /\n[ \t]*\n[ \t]*$/, blockquoteStart: /^ {0,3}>/, blockquoteSetextReplace: /\n {0,3}((?:=+|-+) *)(?=\n|$)/g, blockquoteSetextReplace2: /^ {0,3}>[ \t]?/gm, listReplaceNesting: /^ {1,4}(?=( {4})*[^ ])/g, listIsTask: /^\[[ xX]\] +\S/, listReplaceTask: /^\[[ xX]\] +/, listTaskCheckbox: /\[[ xX]\]/, anyLine: /\n.*\n/, hrefBrackets: /^<(.*)>$/, tableDelimiter: /[:|]/, tableAlignChars: /^\||\| *$/g, tableRowBlankLine: /\n[ \t]*$/, tableAlignRight: /^ *-+: *$/, tableAlignCenter: /^ *:-+: *$/, tableAlignLeft: /^ *:-+ *$/, startATag: /^<a /i, endATag: /^<\/a>/i, startPreScriptTag: /^<(pre|code|kbd|script)(\s|>)/i, endPreScriptTag: /^<\/(pre|code|kbd|script)(\s|>)/i, startAngleBracket: /^</, endAngleBracket: />$/, pedanticHrefTitle: /^([^'"]*[^\s])\s+(['"])(.*)\2/, unicodeAlphaNumeric: /[\p{L}\p{N}]/u, numericCharacterReference: /&#(?:(\d{1,7})|[Xx]([A-Fa-f0-9]{1,6}));/g, escapeTest: /[&<>"']/, escapeReplace: /[&<>"']/g, escapeTestNoEncode: /[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/, escapeReplaceNoEncode: /[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/g, caret: /(^|[^\[])\^/g, percentDecode: /%25/g, findPipe: /\|/g, splitPipe: / \|/, slashPipe: /\\\|/g, carriageReturn: /\r\n|\r/g, spaceLine: /^ +$/gm, notSpaceStart: /^\S*/, endingNewline: /\n$/, listItemRegex: (l3) => new RegExp(`^( {0,3}${l3})((?:[ ][^\\n]*)?(?:\\n|$))`), nextBulletRegex: C((l3) => new RegExp(`^ {0,${l3}}(?:[*+-]|\\d{1,9}[.)])((?:[ ][^\\n]*)?(?:\\n|$))`)), hrRegex: C((l3) => new RegExp(`^ {0,${l3}}((?:-[ ]*){3,}|(?:_[ ]*){3,}|(?:\\*[ ]*){3,})(?:\\n+|$)`)), fencesBeginRegex: C((l3) => new RegExp(`^ {0,${l3}}(?:\`\`\`|~~~)`)), headingBeginRegex: C((l3) => new RegExp(`^ {0,${l3}}#`)), htmlBeginRegex: C((l3) => new RegExp(`^ {0,${l3}}(?:</?(?:${N})(?: +|$|/?>)|<(?:script|pre|style|textarea|!--))`, "i")), blockquoteBeginRegex: C((l3) => new RegExp(`^ {0,${l3}}>`)) };
13036
+ var $e = /^(?:[ \t]*(?:\n|$))+/;
13037
+ var Le = /^((?: {4}| {0,3}\t)[^\n]+(?:\n(?:[ \t]*(?:\n|$))*)?)+/;
13038
+ var ze = /^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}\1[~`]* *(?=\n|$)|$)/;
13039
+ var G = /^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/;
13040
+ var Ae = /^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/;
13041
+ var J = / {0,3}(?:[*+-]|\d{1,9}[.)])/;
13042
+ var ce = /^(?!bull |blockCode|fences|blockquote|heading|html|table)((?:.|\n(?!\s*?\n|bull |fences|blockquote|heading|hr|html|table))+?)\n {0,3}(=+|-+) *(?:\n+|$)/;
13043
+ var he = h(ce).replace(/bull/g, J).replace(/blockCode/g, /(?: {4}| {0,3}\t)/).replace(/fences/g, / {0,3}(?:`{3,}|~{3,})/).replace(/blockquote/g, / {0,3}>/).replace(/heading/g, / {0,3}#{1,6}(?:\s|$)/).replace(/hr/g, / {0,3}(?:(?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/).replace(/html/g, / {0,3}<[^\n>]+>\n/).replace(/\|table/g, "").getRegex();
13044
+ var Ee = h(ce).replace(/bull/g, J).replace(/blockCode/g, /(?: {4}| {0,3}\t)/).replace(/fences/g, / {0,3}(?:`{3,}|~{3,})/).replace(/blockquote/g, / {0,3}>/).replace(/heading/g, / {0,3}#{1,6}(?:\s|$)/).replace(/hr/g, / {0,3}(?:(?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/).replace(/html/g, / {0,3}<[^\n>]+>\n/).replace(/table/g, / {0,3}\|?(?:[:\- ]*\|)+[\:\- ]*\n/).getRegex();
13045
+ var V = /^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table|[ \t]+\n)[^\n]+)*)/;
13046
+ var Me = /^[^\n]+/;
13047
+ var Y = /(?!\s*\])(?:\\[\s\S]|[^\[\]\\])+/;
13048
+ var Ie = h(/^ {0,3}\[(label)\]: *(?:\n[ \t]*)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n[ \t]*)?| *\n[ \t]*)(title))? *(?:\n+|$)/).replace("label", Y).replace("title", /(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/).getRegex();
13049
+ var Ce = h(/^(bull)([ \t][^\n]*?)?(?:\n|$)/).replace(/bull/g, J).getRegex();
13050
+ var N = "address|article|aside|base|basefont|blockquote|body|caption|center|col|colgroup|dd|details|dialog|dir|div|dl|dt|fieldset|figcaption|figure|footer|form|frame|frameset|h[1-6]|head|header|hr|html|iframe|legend|li|link|main|menu|menuitem|meta|nav|noframes|ol|optgroup|option|p|param|search|section|summary|table|tbody|td|tfoot|th|thead|title|tr|track|ul";
13051
+ var ee = /<!--(?:-?>|[\s\S]*?(?:-->|$))/;
13052
+ var Be = h("^ {0,3}(?:<(script|pre|style|textarea)[\\s>][\\s\\S]*?(?:</\\1>[^\\n]*\\n*|$)|comment[^\\n]*(\\n+|$)|<\\?[\\s\\S]*?(?:\\?>[^\\n]*\\n*|$)|<![A-Z][\\s\\S]*?(?:>[^\\n]*\\n*|$)|<!\\[CDATA\\[[\\s\\S]*?(?:\\]\\]>[^\\n]*\\n*|$)|</?(tag)(?: +|\\n|/?>)[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$)|<(?!script|pre|style|textarea)([a-z][a-z0-9-]*)(?:attribute)*? */?>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$)|</(?!script|pre|style|textarea)[a-z][a-z0-9-]*\\s*>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$))", "i").replace("comment", ee).replace("tag", N).replace("attribute", / +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex();
13053
+ var de = (l3) => h(V).replace("hr", G).replace("heading", " {0,3}#{1,6}(?:\\s|$)").replace("|lheading", "").replace("|table", "").replace("blockquote", " {0,3}>").replace("fences", " {0,3}(?:`{3,}(?=[^`\\n]*(?:\\n|$))|~~~)[^\\n]*(?:\\n|$)").replace("list", l3).replace("html", "</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag", N).getRegex();
13054
+ var De = de(/ {0,3}(?:[*+-]|1[.)])[ \t]+[^ \t\n]/);
13055
+ var qe = de(/ {0,3}(?:[*+-]|\d{1,9}[.)])(?:[ \t]|\n|$)/);
13056
+ var ve = h(/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/).replace("paragraph", qe).getRegex();
13057
+ var te = { blockquote: ve, code: Le, def: Ie, fences: ze, heading: Ae, hr: G, html: Be, lheading: he, list: Ce, newline: $e, paragraph: De, table: A, text: Me };
13058
+ var le = h("^ *([^\\n ].*)\\n {0,3}((?:\\| *)?:?-+:? *(?:\\| *:?-+:? *)*(?:\\| *)?)(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)").replace("hr", G).replace("heading", " {0,3}#{1,6}(?:\\s|$)").replace("blockquote", " {0,3}>").replace("code", "(?: {4}| {0,3} )[^\\n]").replace("fences", " {0,3}(?:`{3,}(?=[^`\\n]*(?:\\n|$))|~~~)[^\\n]*(?:\\n|$)").replace("list", " {0,3}(?:[*+-]|1[.)])[ \\t]").replace("html", "</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag", N).getRegex();
13059
+ var Ze = { ...te, lheading: Ee, table: le, paragraph: h(V).replace("hr", G).replace("heading", " {0,3}#{1,6}(?:\\s|$)").replace("|lheading", "").replace("table", le).replace("blockquote", " {0,3}>").replace("fences", " {0,3}(?:`{3,}(?=[^`\\n]*(?:\\n|$))|~~~)[^\\n]*(?:\\n|$)").replace("list", " {0,3}(?:[*+-]|1[.)])[ \\t]+[^ \\t\\n]").replace("html", "</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag", N).getRegex() };
13060
+ var He = { ...te, html: h(`^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:"[^"]*"|'[^']*'|\\s[^'"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))`).replace("comment", ee).replace(/tag/g, "(?!(?:a|em|strong|small|s|cite|q|dfn|abbr|data|time|code|var|samp|kbd|sub|sup|i|b|u|mark|ruby|rt|rp|bdi|bdo|span|br|wbr|ins|del|img)\\b)\\w+(?!:|[^\\w\\s@]*@)\\b").getRegex(), def: /^ *\[([^\]]+)\]: *<?([^\s>]+)>?(?: +(["(][^\n]+[")]))? *(?:\n+|$)/, heading: /^(#{1,6})(.*)(?:\n+|$)/, fences: A, lheading: /^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/, paragraph: h(V).replace("hr", G).replace("heading", ` *#{1,6} *[^
13061
+ ]`).replace("lheading", he).replace("|table", "").replace("blockquote", " {0,3}>").replace("|fences", "").replace("|list", "").replace("|html", "").replace("|tag", "").getRegex() };
13062
+ var Ge = /^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/;
13063
+ var Ne = /^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/;
13064
+ var ke = /^( {2,}|\\)\n(?!\s*$)[ \t]*/;
13065
+ var Qe = /^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/;
13066
+ var $ = /[\p{P}\p{S}]/u;
13067
+ var B = /[\s\p{P}\p{S}]/u;
13068
+ var Q = /[^\s\p{P}\p{S}]/u;
13069
+ var je = h(/^((?![*_])punctSpace)/, "u").replace(/punctSpace/g, B).getRegex();
13070
+ var Fe = /[\p{Pi}\p{Ps}"']/u;
13071
+ var ge = /(?!~)[\p{P}\p{S}]/u;
13072
+ var Ue = /(?!~)[\s\p{P}\p{S}]/u;
13073
+ var Ke = /(?:[^\s\p{P}\p{S}]|~)/u;
13074
+ var We = h(/link|precode-code|html/, "g").replace("link", /\[(?:[^\[\]`]|(?<a>`+)[^`]+\k<a>(?!`))*?\]\((?:\\[\s\S]|[^\\\(\)]|\((?:\\[\s\S]|[^\\\(\)])*\))*\)/).replace("precode-", _e ? "(?<!`)()" : "(^^|[^`])").replace("code", /(?<b>`+)[^`]+\k<b>(?!`)/).replace("html", /<(?! )[^<>]*?>/).getRegex();
13075
+ var fe = /^(?:\*+(?:((?!\*)punct)|([^\s*]))?)|^_+(?:((?!_)punct)|([^\s_]))?/;
13076
+ var Xe = h(fe, "u").replace(/punct/g, $).getRegex();
13077
+ var Je = h(fe, "u").replace(/punct/g, ge).getRegex();
13078
+ var Ve = /^(?:\*+(?:((?!\*)(?!openQuote)punct)|([^\s*]))?)|^_+(?:((?!_)(?!openQuote)punct)|([^\s_]))?/;
13079
+ var Ye = h(Ve, "u").replace(/openQuote/g, Fe).replace(/punct/g, $).getRegex();
13080
+ var me = "^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)punct(\\*+)(?=[\\s]|$)|notPunctSpace(\\*+)(?!\\*)(?=punctSpace|$)|(?!\\*)punctSpace(\\*+)(?=notPunctSpace)|[\\s](\\*+)(?!\\*)(?=punct)|(?!\\*)punct(\\*+)(?!\\*)(?=punct)|notPunctSpace(\\*+)(?=notPunctSpace)";
13081
+ var et = h(me, "gu").replace(/notPunctSpace/g, Q).replace(/punctSpace/g, B).replace(/punct/g, $).getRegex();
13082
+ var tt = h(me, "gu").replace(/notPunctSpace/g, Ke).replace(/punctSpace/g, Ue).replace(/punct/g, ge).getRegex();
13083
+ var nt = "^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)punct(\\*+)(?=[\\s]|$)|notPunctSpace(\\*+)(?!\\*)(?=punctSpace|$)|(?!\\*)[\\s](\\*+)(?=notPunctSpace)|[\\s](\\*+)(?!\\*)(?=punct)|(?!\\*)punct(\\*+)(?!\\*)(?=punct)|(?:(?!\\*)punct|notPunctSpace)(\\*+)(?!\\*)(?=notPunctSpace)";
13084
+ var rt = h(nt, "gu").replace(/notPunctSpace/g, Q).replace(/punctSpace/g, B).replace(/punct/g, $).getRegex();
13085
+ var st = h("^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)punct(_+)(?=[\\s]|$)|notPunctSpace(_+)(?!_)(?=punctSpace|$)|(?!_)punctSpace(_+)(?=notPunctSpace)|[\\s](_+)(?!_)(?=punct)|(?!_)punct(_+)(?!_)(?=punct)", "gu").replace(/notPunctSpace/g, Q).replace(/punctSpace/g, B).replace(/punct/g, $).getRegex();
13086
+ var it = "^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)punct(_+)(?=[\\s]|$)|notPunctSpace(_+)(?!_)(?=punctSpace|$)|(?!_)[\\s](_+)(?=notPunctSpace)|[\\s](_+)(?!_)(?=punct)|(?!_)punct(_+)(?!_)(?=punct)|(?:(?!_)punct|notPunctSpace)(_+)(?!_)(?=notPunctSpace)";
13087
+ var ot = h(it, "gu").replace(/notPunctSpace/g, Q).replace(/punctSpace/g, B).replace(/punct/g, $).getRegex();
13088
+ var at = h(/^~~?(?:((?!~)punct)|[^\s~])/, "u").replace(/punct/g, $).getRegex();
13089
+ var lt = "^[^~]+(?=[^~])|(?!~)punct(~~?)(?=[\\s]|$)|notPunctSpace(~~?)(?!~)(?=punctSpace|$)|(?!~)punctSpace(~~?)(?=notPunctSpace)|[\\s](~~?)(?!~)(?=punct)|(?!~)punct(~~?)(?!~)(?=punct)|notPunctSpace(~~?)(?=notPunctSpace)";
13090
+ var ut = h(lt, "gu").replace(/notPunctSpace/g, Q).replace(/punctSpace/g, B).replace(/punct/g, $).getRegex();
13091
+ var pt = h(/\\(punct)/, "gu").replace(/punct/g, $).getRegex();
13092
+ var ct = h(/^<(scheme:[^\s\x00-\x1f<>]*|email)>/).replace("scheme", /[a-zA-Z][a-zA-Z0-9+.-]{1,31}/).replace("email", /[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+(@)[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)+(?![-_])/).getRegex();
13093
+ var ht = h(ee).replace("(?:-->|$)", "-->").getRegex();
13094
+ var dt = h("^comment|^</[a-zA-Z][a-zA-Z0-9-]*\\s*>|^<[a-zA-Z][a-zA-Z0-9-]*(?:attribute)*?\\s*/?>|^<\\?[\\s\\S]*?\\?>|^<![a-zA-Z]+\\s[\\s\\S]*?>|^<!\\[CDATA\\[[\\s\\S]*?\\]\\]>").replace("comment", ht).replace("attribute", /\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/).getRegex();
13095
+ var xe = /\[(?:\\[\s\S]|[^\[\]\\])*\]/;
13096
+ var U = h(/(?:\[(?:brackets|\\[\s\S]|[^\[\]\\])*\]|\\[\s\S]|`+(?!`)[^`]*?`+(?!`)|``+(?=\])|[^\[\]\\`])*?/).replace("brackets", xe).getRegex();
13097
+ var kt = h(/^!?\[(label)\]\(\s*(href)(?:(?:[ \t]+(?:\n[ \t]*)?|\n[ \t]*)(title))?\s*\)/).replace("label", U).replace("href", /<(?:\\.|[^\n<>\\])+>|[^ \t\n\x00-\x1f]+|(?=\))/).replace("title", /"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/).getRegex();
13098
+ var gt = h(/^!?\[(label)\]\[(ref)\]/).replace("label", U).replace("ref", Y).getRegex();
13099
+ var ft = h(/^!?\[(ref)\](?:\[\])?/).replace("ref", Y).getRegex();
13100
+ var ue = /(?!\s*\])(?:\\[\s\S]|[^\[\]\\]){1,999}/;
13101
+ var mt = h(/(?:[^\[\]\\`]*(?:\[(?:brackets|\\[\s\S]|[^\[\]\\])*\]|\\[\s\S]|`+(?!`)[^`]*?`+(?!`)|``+(?=\]))){0,999}?[^\[\]\\`]*?/).replace("brackets", xe).getRegex();
13102
+ var xt = h("reflink|nolink(?!\\()", "g").replace("reflink", h(/^!?\[(label)\]\[(ref)\]/).replace("label", mt).replace("ref", ue).getRegex()).replace("nolink", h(/^!?\[(ref)\](?:\[\])?/).replace("ref", ue).getRegex()).getRegex();
13103
+ var pe = /[hH][tT][tT][pP][sS]?|[fF][tT][pP]/;
13104
+ var bt = /[A-Za-z0-9._+-]+@[a-zA-Z0-9-_]+(?:\.[a-zA-Z0-9-_]*[a-zA-Z0-9])+(?![\w-])/;
13105
+ var Rt = h(/(?:mailto:email|xmpp:email(?:\/[A-Za-z0-9@.]+)?)/).replace(/email/g, bt).getRegex();
13106
+ var ne = { _backpedal: A, anyPunctuation: pt, autolink: ct, blockSkip: We, br: ke, code: Ne, del: A, delLDelim: A, delRDelim: A, emStrongLDelim: Xe, emStrongRDelimAst: et, emStrongRDelimUnd: st, escape: Ge, link: kt, nolink: ft, punctuation: je, reflink: gt, reflinkSearch: xt, tag: dt, text: Qe, url: A };
13107
+ var Tt = { ...ne, emStrongLDelim: Ye, emStrongRDelimAst: rt, emStrongRDelimUnd: ot, link: h(/^!?\[(label)\]\((.*?)\)/).replace("label", U).getRegex(), reflink: h(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace("label", U).getRegex() };
13108
+ var X = { ...ne, emStrongRDelimAst: tt, emStrongLDelim: Je, delLDelim: at, delRDelim: ut, url: h(/^emailProtocol|^((?:protocol):\/\/|www\.)(?:[a-zA-Z0-9\-]+\.?)+[^\s<]*|^email/).replace("emailProtocol", Rt).replace("protocol", pe).replace("email", /[A-Za-z0-9._+-]+(@)[a-zA-Z0-9-_]+(?:\.[a-zA-Z0-9-_]*[a-zA-Z0-9])+(?![\w-])/).getRegex(), _backpedal: /(?:[^?!.,:;*_'"~()&]+|\([^)]*\)|&(?![a-zA-Z0-9]+;$)|[?!.,:;*_'"~)]+(?!$))+/, del: /^(~~?)(?=[^\s~])((?:\\[\s\S]|[^\\])*?(?:\\[\s\S]|[^\s~\\]))\1(?=[^~]|$)/, text: h(/^(?:[^a-zA-Z0-9](?=emailProtocol)|(`+|~+|[^`~])(?:(?=[`~])|(?= {2,}\n)|(?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)|[\s\S]*?(?:(?=[\\<!\[`*~_]|\b_|protocol:\/\/|www\.|$)|[^ ](?= {2,}\n)|[^a-zA-Z0-9](?=emailProtocol)|[^a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-](?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@))))/).replace("protocol", pe).replace(/emailProtocol/g, /(?:mailto|xmpp):/).getRegex() };
13109
+ var Ot = { ...X, br: h(ke).replace("{2,}", "*").getRegex(), text: h(X.text).replace("\\b_", "\\b_| {2,}\\n").replace(/\{2,\}/g, "*").getRegex() };
13110
+ var j = { normal: te, gfm: Ze, pedantic: He };
13111
+ var D = { normal: ne, gfm: X, breaks: Ot, pedantic: Tt };
13112
+ var wt = { "&": "&amp;", "<": "&lt;", ">": "&gt;", '"': "&quot;", "'": "&#39;" };
13113
+ var be = (l3) => wt[l3];
13114
+ function O(l3, e) {
12503
13115
  if (e) {
12504
- if (m.escapeTest.test(u3)) return u3.replace(m.escapeReplace, ge);
12505
- } else if (m.escapeTestNoEncode.test(u3)) return u3.replace(m.escapeReplaceNoEncode, ge);
12506
- return u3;
13116
+ if (x.escapeTest.test(l3)) return l3.replace(x.escapeReplace, be);
13117
+ } else if (x.escapeTestNoEncode.test(l3)) return l3.replace(x.escapeReplaceNoEncode, be);
13118
+ return l3;
13119
+ }
13120
+ function Re(l3) {
13121
+ return l3.replace(x.numericCharacterReference, (e, t, n) => {
13122
+ let s = t === void 0 ? Number.parseInt(n, 16) : Number.parseInt(t, 10);
13123
+ return s === 0 || s > 1114111 || s >= 55296 && s <= 57343 ? "\uFFFD" : String.fromCodePoint(s);
13124
+ });
12507
13125
  }
12508
- function Y(u3) {
13126
+ function re(l3) {
12509
13127
  try {
12510
- u3 = encodeURI(u3).replace(m.percentDecode, "%");
13128
+ l3 = encodeURI(l3).replace(x.percentDecode, "%");
12511
13129
  } catch {
12512
13130
  return null;
12513
13131
  }
12514
- return u3;
13132
+ return l3;
12515
13133
  }
12516
- function ee(u3, e) {
12517
- let t = u3.replace(m.findPipe, (r, o, i) => {
12518
- let l = false, a = o;
12519
- for (; --a >= 0 && i[a] === "\\"; ) l = !l;
12520
- return l ? "|" : " |";
12521
- }), n = t.split(m.splitPipe), s = 0;
13134
+ function se(l3, e) {
13135
+ let t = l3.replace(x.findPipe, (r, o, i) => {
13136
+ let u = false, a = o;
13137
+ for (; --a >= 0 && i[a] === "\\"; ) u = !u;
13138
+ return u ? "|" : " |";
13139
+ }), n = t.split(x.splitPipe), s = 0;
12522
13140
  if (n[0].trim() || n.shift(), n.length > 0 && !n.at(-1)?.trim() && n.pop(), e) if (n.length > e) n.splice(e);
12523
13141
  else for (; n.length < e; ) n.push("");
12524
- for (; s < n.length; s++) n[s] = n[s].trim().replace(m.slashPipe, "|");
13142
+ for (; s < n.length; s++) n[s] = n[s].trim().replace(x.slashPipe, "|");
12525
13143
  return n;
12526
13144
  }
12527
- function $(u3, e, t) {
12528
- let n = u3.length;
13145
+ function L(l3, e, t) {
13146
+ let n = l3.length;
12529
13147
  if (n === 0) return "";
12530
13148
  let s = 0;
12531
13149
  for (; s < n; ) {
12532
- let r = u3.charAt(n - s - 1);
13150
+ let r = l3.charAt(n - s - 1);
12533
13151
  if (r === e && !t) s++;
12534
13152
  else if (r !== e && t) s++;
12535
13153
  else break;
12536
13154
  }
12537
- return u3.slice(0, n - s);
13155
+ return l3.slice(0, n - s);
12538
13156
  }
12539
- function te(u3) {
12540
- let e = u3.split(`
13157
+ function ie(l3) {
13158
+ let e = l3.split(`
12541
13159
  `), t = e.length - 1;
12542
- for (; t >= 0 && m.blankLine.test(e[t]); ) t--;
12543
- return e.length - t <= 2 ? u3 : e.slice(0, t + 1).join(`
13160
+ for (; t >= 0 && x.blankLine.test(e[t]); ) t--;
13161
+ return e.length - t <= 2 ? l3 : e.slice(0, t + 1).join(`
12544
13162
  `);
12545
13163
  }
12546
- function fe(u3, e) {
12547
- if (u3.indexOf(e[1]) === -1) return -1;
13164
+ function q(l3) {
13165
+ return l3.trim().toLowerCase().toUpperCase().toLowerCase();
13166
+ }
13167
+ function Te(l3, e) {
13168
+ if (l3.indexOf(e[1]) === -1) return -1;
12548
13169
  let t = 0;
12549
- for (let n = 0; n < u3.length; n++) if (u3[n] === "\\") n++;
12550
- else if (u3[n] === e[0]) t++;
12551
- else if (u3[n] === e[1] && (t--, t < 0)) return n;
13170
+ for (let n = 0; n < l3.length; n++) if (l3[n] === "\\") n++;
13171
+ else if (l3[n] === e[0]) t++;
13172
+ else if (l3[n] === e[1] && (t--, t < 0)) return n;
12552
13173
  return t > 0 ? -2 : -1;
12553
13174
  }
12554
- function me(u3, e = 0) {
13175
+ function oe(l3, e = 0) {
12555
13176
  let t = e, n = "";
12556
- for (let s of u3) if (s === " ") {
13177
+ for (let s of l3) if (s === " ") {
12557
13178
  let r = 4 - t % 4;
12558
13179
  n += " ".repeat(r), t += r;
12559
13180
  } else n += s, t++;
12560
13181
  return n;
12561
13182
  }
12562
- function xe(u3, e, t, n, s) {
12563
- let r = e.href, o = e.title || null, i = u3[1].replace(s.other.outputLinkReplace, "$1"), l = u3[0].charAt(0) === "!";
13183
+ function Oe(l3, e, t, n, s) {
13184
+ let r = e.href, o = e.title || null, i = l3[1].replace(s.other.outputLinkReplace, "$1"), u = l3[0].charAt(0) === "!";
12564
13185
  n.state.inLink = true;
12565
13186
  let a = n.state.linkEmitted, p = n.state.inRawBlock;
12566
13187
  n.state.linkEmitted = false;
12567
- let c = n.inlineTokens(i), h = n.state.linkEmitted;
12568
- if (n.state.linkEmitted = a, n.state.inLink = false, !l) {
12569
- if (h) {
13188
+ let c = n.inlineTokens(i), d = n.state.linkEmitted;
13189
+ if (n.state.linkEmitted = a, n.state.inLink = false, !u) {
13190
+ if (d) {
12570
13191
  n.state.inRawBlock = p;
12571
13192
  return;
12572
13193
  }
12573
13194
  n.state.linkEmitted = true;
12574
13195
  }
12575
- return { type: l ? "image" : "link", raw: t, href: r, title: o, text: i, tokens: c };
13196
+ return { type: u ? "image" : "link", raw: t, href: r, title: o, text: i, tokens: c };
12576
13197
  }
12577
- function dt(u3, e, t) {
12578
- let n = u3.match(t.other.indentCodeCompensation);
13198
+ function yt(l3, e, t) {
13199
+ let n = l3.match(t.other.indentCodeCompensation);
12579
13200
  if (n === null) return e;
12580
13201
  let s = n[1];
12581
13202
  return e.split(`
@@ -12587,12 +13208,35 @@ function dt(u3, e, t) {
12587
13208
  }).join(`
12588
13209
  `);
12589
13210
  }
12590
- var y = class {
13211
+ function we(l3, e, t, n) {
13212
+ if (!e.includes("<")) return false;
13213
+ for (let s = 0; s < e.length; s++) {
13214
+ if (e[s] === "\\") {
13215
+ s++;
13216
+ continue;
13217
+ }
13218
+ if (e[s] === "`") {
13219
+ let i = n.inline.code.exec(e.slice(s));
13220
+ if (i) {
13221
+ s += i[0].length - 1;
13222
+ continue;
13223
+ }
13224
+ }
13225
+ if (e[s] !== "<") continue;
13226
+ let r = l3.slice(t + s), o = n.inline.tag.exec(r) || n.inline.autolink.exec(r);
13227
+ if (o) {
13228
+ if (o[0].length > e.length - s) return true;
13229
+ s += o[0].length - 1;
13230
+ }
13231
+ }
13232
+ return false;
13233
+ }
13234
+ var P = class {
12591
13235
  options;
12592
13236
  rules;
12593
13237
  lexer;
12594
13238
  constructor(e) {
12595
- this.options = e || T;
13239
+ this.options = e || y;
12596
13240
  }
12597
13241
  space(e) {
12598
13242
  let t = this.rules.block.newline.exec(e);
@@ -12601,14 +13245,14 @@ var y = class {
12601
13245
  code(e) {
12602
13246
  let t = this.rules.block.code.exec(e);
12603
13247
  if (t) {
12604
- let n = this.options.pedantic ? t[0] : te(t[0]), s = n.replace(this.rules.other.codeRemoveIndent, "");
13248
+ let n = this.options.pedantic ? t[0] : ie(t[0]), s = n.replace(this.rules.other.codeRemoveIndent, "");
12605
13249
  return { type: "code", raw: n, codeBlockStyle: "indented", text: s };
12606
13250
  }
12607
13251
  }
12608
13252
  fences(e) {
12609
13253
  let t = this.rules.block.fences.exec(e);
12610
13254
  if (t) {
12611
- let n = t[0], s = dt(n, t[3] || "", this.rules);
13255
+ let n = t[0], s = yt(n, t[3] || "", this.rules);
12612
13256
  return { type: "code", raw: n, lang: t[2] ? t[2].trim().replace(this.rules.inline.anyPunctuation, "$1") : t[2], text: s };
12613
13257
  }
12614
13258
  }
@@ -12617,52 +13261,56 @@ var y = class {
12617
13261
  if (t) {
12618
13262
  let n = t[2].trim();
12619
13263
  if (this.rules.other.endingHash.test(n)) {
12620
- let s = $(n, "#");
13264
+ let s = L(n, "#");
12621
13265
  (this.options.pedantic || !s || this.rules.other.endingSpaceTabChar.test(s)) && (n = s.trim());
12622
13266
  }
12623
- return { type: "heading", raw: $(t[0], `
13267
+ return { type: "heading", raw: L(t[0], `
12624
13268
  `), depth: t[1].length, text: n, tokens: this.lexer.inline(n) };
12625
13269
  }
12626
13270
  }
12627
13271
  hr(e) {
12628
13272
  let t = this.rules.block.hr.exec(e);
12629
- if (t) return { type: "hr", raw: $(t[0], `
13273
+ if (t) return { type: "hr", raw: L(t[0], `
12630
13274
  `) };
12631
13275
  }
12632
13276
  blockquote(e) {
12633
13277
  let t = this.rules.block.blockquote.exec(e);
12634
13278
  if (t) {
12635
- let n = $(t[0], `
13279
+ let n = L(t[0], `
12636
13280
  `).split(`
12637
13281
  `), s = "", r = "", o = [];
12638
13282
  for (; n.length > 0; ) {
12639
- let i = false, l = [], a;
12640
- for (a = 0; a < n.length; a++) if (this.rules.other.blockquoteStart.test(n[a])) l.push(n[a]), i = true;
12641
- else if (!i) l.push(n[a]);
13283
+ let i = false, u = [], a;
13284
+ for (a = 0; a < n.length; a++) if (this.rules.other.blockquoteStart.test(n[a])) u.push(n[a]), i = true;
13285
+ else if (!i) u.push(n[a]);
12642
13286
  else break;
12643
13287
  n = n.slice(a);
12644
- let p = l.join(`
13288
+ let p = u.join(`
12645
13289
  `), c = p.replace(this.rules.other.blockquoteSetextReplace, `
12646
13290
  $1`).replace(this.rules.other.blockquoteSetextReplace2, "");
12647
13291
  s = s ? `${s}
12648
13292
  ${p}` : p, r = r ? `${r}
12649
13293
  ${c}` : c;
12650
- let h = this.lexer.state.top;
12651
- if (this.lexer.state.top = true, this.lexer.blockTokens(c, o, true), this.lexer.state.top = h, n.length === 0) break;
12652
- let d = o.at(-1);
12653
- if (d?.type === "code") break;
12654
- if (d?.type === "blockquote") {
12655
- let O = d, g = n.join(`
12656
- `), w = O.raw + `
12657
- ` + g.replace(this.rules.other.blockquoteSetextReplace2, ""), z = this.blockquote(w);
12658
- o[o.length - 1] = z, s = `${s}
12659
- ${g}`, r = r.substring(0, r.length - O.text.length) + z.text;
13294
+ let d = this.lexer.state.top;
13295
+ if (this.lexer.state.top = true, this.lexer.blockTokens(c, o, true), this.lexer.state.top = d, n.length === 0) break;
13296
+ let m = o.at(-1);
13297
+ if (m?.type === "code") break;
13298
+ if (m?.type === "blockquote") {
13299
+ let b = m, g = n.join(`
13300
+ `), w = b.raw + `
13301
+ ` + g.replace(this.rules.other.blockquoteSetextReplace2, ""), f = this.blockquote(w);
13302
+ o[o.length - 1] = f;
13303
+ let M = w.substring(f.raw.length).replace(/^\n/, ""), v = M ? M.split(`
13304
+ `).length : 0, Z = v ? n.slice(0, -v) : n;
13305
+ Z.length > 0 && (s = `${s}
13306
+ ${Z.join(`
13307
+ `)}`), r = r.substring(0, r.length - b.text.length) + f.text;
12660
13308
  break;
12661
- } else if (d?.type === "list") {
12662
- let O = d, g = O.raw + `
13309
+ } else if (m?.type === "list") {
13310
+ let b = m, g = b.raw + `
12663
13311
  ` + n.join(`
12664
13312
  `), w = this.list(g);
12665
- o[o.length - 1] = w, s = s.substring(0, s.length - d.raw.length) + w.raw, r = r.substring(0, r.length - O.raw.length) + w.raw, n = g.substring(o.at(-1).raw.length).split(`
13313
+ o[o.length - 1] = w, s = s.substring(0, s.length - m.raw.length) + w.raw, r = r.substring(0, r.length - b.raw.length) + w.raw, n = g.substring(o.at(-1).raw.length).split(`
12666
13314
  `);
12667
13315
  continue;
12668
13316
  }
@@ -12680,49 +13328,49 @@ ${g}`, r = r.substring(0, r.length - O.text.length) + z.text;
12680
13328
  let a = false, p = "", c = "";
12681
13329
  if (!(t = o.exec(e)) || this.rules.block.hr.test(e)) break;
12682
13330
  p = t[0], e = e.substring(p.length);
12683
- let h = me(t[2].split(`
12684
- `, 1)[0], t[1].length), d = e.split(`
12685
- `, 1)[0], O = !h.trim(), g = 0;
12686
- if (this.options.pedantic ? (g = 2, c = h.trimStart()) : O ? g = t[1].length + 1 : (g = h.search(this.rules.other.nonSpaceChar), g = g > 4 ? 1 : g, c = h.slice(g), g += t[1].length), O && this.rules.other.blankLine.test(d) && (p += d + `
12687
- `, e = e.substring(d.length + 1), a = true), !a) {
12688
- let w = this.rules.other.nextBulletRegex(g), z = this.rules.other.hrRegex(g), ne = this.rules.other.fencesBeginRegex(g), re = this.rules.other.headingBeginRegex(g), be = this.rules.other.htmlBeginRegex(g), Re = this.rules.other.blockquoteBeginRegex(g);
13331
+ let d = t[2].split(`
13332
+ `, 1)[0], m = t[1].length, b = this.options.pedantic ? oe(d, m) : d.replace(this.rules.other.leadingSpaceTab, (M) => oe(M, m)), g = e.split(`
13333
+ `, 1)[0], w = !b.trim(), f = 0;
13334
+ if (this.options.pedantic ? (f = 2, c = b.trimStart()) : w ? f = m + 1 : (f = b.search(this.rules.other.nonSpaceChar), f = f > 4 ? 1 : f, c = b.slice(f), f += m), w && this.rules.other.blankLine.test(g) && (p += g + `
13335
+ `, e = e.substring(g.length + 1), a = true), !a) {
13336
+ let M = this.rules.other.nextBulletRegex(f), v = this.rules.other.hrRegex(f), Z = this.rules.other.fencesBeginRegex(f), ae = this.rules.other.headingBeginRegex(f), ye = this.rules.other.htmlBeginRegex(f), Pe = this.rules.other.blockquoteBeginRegex(f);
12689
13337
  for (; e; ) {
12690
- let N = e.split(`
12691
- `, 1)[0], D;
12692
- if (d = N, this.options.pedantic ? (d = d.replace(this.rules.other.listReplaceNesting, " "), D = d) : D = d.replace(this.rules.other.tabCharGlobal, " "), ne.test(d) || re.test(d) || be.test(d) || Re.test(d) || w.test(d) || z.test(d)) break;
12693
- if (D.search(this.rules.other.nonSpaceChar) >= g || !d.trim()) c += `
12694
- ` + D.slice(g);
13338
+ let K = e.split(`
13339
+ `, 1)[0], H;
13340
+ if (g = K, this.options.pedantic ? (g = g.replace(this.rules.other.listReplaceNesting, " "), H = g) : H = g.replace(this.rules.other.leadingSpaceTab, (Se) => Se.replace(this.rules.other.tabCharGlobal, " ")), Z.test(g) || ae.test(g) || ye.test(g) || Pe.test(g) || M.test(g) || v.test(g)) break;
13341
+ if (H.search(this.rules.other.nonSpaceChar) >= f || !g.trim()) c += `
13342
+ ` + H.slice(f);
12695
13343
  else {
12696
- if (O || h.replace(this.rules.other.tabCharGlobal, " ").search(this.rules.other.nonSpaceChar) >= 4 || ne.test(h) || re.test(h) || z.test(h)) break;
13344
+ if (w || b.replace(this.rules.other.tabCharGlobal, " ").search(this.rules.other.nonSpaceChar) >= 4 || Z.test(b) || ae.test(b) || v.test(b)) break;
12697
13345
  c += `
12698
- ` + d;
13346
+ ` + g;
12699
13347
  }
12700
- O = !d.trim(), p += N + `
12701
- `, e = e.substring(N.length + 1), h = D.slice(g);
13348
+ w = !g.trim(), p += K + `
13349
+ `, e = e.substring(K.length + 1), b = H.slice(f);
12702
13350
  }
12703
13351
  }
12704
13352
  r.loose || (i ? r.loose = true : this.rules.other.doubleBlankLine.test(p) && (i = true)), r.items.push({ type: "list_item", raw: p, task: !!this.options.gfm && this.rules.other.listIsTask.test(c), loose: false, text: c, tokens: [] }), r.raw += p;
12705
13353
  }
12706
- let l = r.items.at(-1);
12707
- if (l) l.raw = l.raw.trimEnd(), l.text = l.text.trimEnd();
13354
+ let u = r.items.at(-1);
13355
+ if (u) u.raw = u.raw.trimEnd(), u.text = u.text.trimEnd();
12708
13356
  else return;
12709
13357
  r.raw = r.raw.trimEnd();
12710
13358
  for (let a of r.items) if (this.lexer.state.top = false, a.tokens = this.lexer.blockTokens(a.text, []), !r.loose) {
12711
- let p = a.tokens.filter((h) => h.type === "space"), c = p.length > 0 && p.some((h) => this.rules.other.anyLine.test(h.raw));
13359
+ let p = a.tokens.filter((d) => d.type === "space"), c = p.length > 0 && p.some((d) => this.rules.other.anyLine.test(d.raw));
12712
13360
  r.loose = c;
12713
13361
  }
12714
13362
  for (let a of r.items) {
12715
13363
  let p = a.tokens[0];
12716
13364
  if (a.task && (p?.type === "text" || p?.type === "paragraph")) {
12717
13365
  a.text = a.text.replace(this.rules.other.listReplaceTask, ""), p.raw = p.raw.replace(this.rules.other.listReplaceTask, ""), p.text = p.text.replace(this.rules.other.listReplaceTask, "");
12718
- for (let h = this.lexer.inlineQueue.length - 1; h >= 0; h--) if (this.rules.other.listIsTask.test(this.lexer.inlineQueue[h].src)) {
12719
- this.lexer.inlineQueue[h].src = this.lexer.inlineQueue[h].src.replace(this.rules.other.listReplaceTask, "");
13366
+ for (let d = this.lexer.inlineQueue.length - 1; d >= 0; d--) if (this.rules.other.listIsTask.test(this.lexer.inlineQueue[d].src)) {
13367
+ this.lexer.inlineQueue[d].src = this.lexer.inlineQueue[d].src.replace(this.rules.other.listReplaceTask, "");
12720
13368
  break;
12721
13369
  }
12722
13370
  let c = this.rules.other.listTaskCheckbox.exec(a.raw);
12723
13371
  if (c) {
12724
- let h = { type: "checkbox", raw: c[0] + " ", checked: c[0] !== "[ ]" };
12725
- a.checked = h.checked, r.loose ? a.tokens[0] && ["paragraph", "text"].includes(a.tokens[0].type) && "tokens" in a.tokens[0] && a.tokens[0].tokens ? (a.tokens[0].raw = h.raw + a.tokens[0].raw, a.tokens[0].text = h.raw + a.tokens[0].text, a.tokens[0].tokens.unshift(h)) : a.tokens.unshift({ type: "paragraph", raw: h.raw, text: h.raw, tokens: [h] }) : a.tokens.unshift(h);
13372
+ let d = { type: "checkbox", raw: c[0] + " ", checked: c[0] !== "[ ]" };
13373
+ a.checked = d.checked, r.loose ? a.tokens[0] && ["paragraph", "text"].includes(a.tokens[0].type) && "tokens" in a.tokens[0] && a.tokens[0].tokens ? (a.tokens[0].raw = d.raw + a.tokens[0].raw, a.tokens[0].text = d.raw + a.tokens[0].text, a.tokens[0].tokens.unshift(d)) : a.tokens.unshift({ type: "paragraph", raw: d.raw, text: d.raw, tokens: [d] }) : a.tokens.unshift(d);
12726
13374
  }
12727
13375
  } else a.task && (a.task = false);
12728
13376
  }
@@ -12736,28 +13384,28 @@ ${g}`, r = r.substring(0, r.length - O.text.length) + z.text;
12736
13384
  html(e) {
12737
13385
  let t = this.rules.block.html.exec(e);
12738
13386
  if (t) {
12739
- let n = te(t[0]);
13387
+ let n = ie(t[0]);
12740
13388
  return { type: "html", block: true, raw: n, pre: t[1] === "pre" || t[1] === "script" || t[1] === "style", text: n };
12741
13389
  }
12742
13390
  }
12743
13391
  def(e) {
12744
13392
  let t = this.rules.block.def.exec(e);
12745
13393
  if (t) {
12746
- let n = t[1].toLowerCase().replace(this.rules.other.multipleSpaceGlobal, " "), s = t[2] ? t[2].replace(this.rules.other.hrefBrackets, "$1").replace(this.rules.inline.anyPunctuation, "$1") : "", r = t[3] ? t[3].substring(1, t[3].length - 1).replace(this.rules.inline.anyPunctuation, "$1") : t[3];
12747
- return { type: "def", tag: n, raw: $(t[0], `
13394
+ let n = q(t[1]).replace(this.rules.other.multipleSpaceGlobal, " "), s = t[2] ? t[2].replace(this.rules.other.hrefBrackets, "$1").replace(this.rules.inline.anyPunctuation, "$1") : "", r = t[3] ? t[3].substring(1, t[3].length - 1).replace(this.rules.inline.anyPunctuation, "$1") : t[3];
13395
+ return { type: "def", tag: n, raw: L(t[0], `
12748
13396
  `), href: s, title: r };
12749
13397
  }
12750
13398
  }
12751
13399
  table(e) {
12752
13400
  let t = this.rules.block.table.exec(e);
12753
13401
  if (!t || !this.rules.other.tableDelimiter.test(t[2])) return;
12754
- let n = ee(t[1]), s = t[2].replace(this.rules.other.tableAlignChars, "").split("|"), r = t[3]?.trim() ? t[3].replace(this.rules.other.tableRowBlankLine, "").split(`
12755
- `) : [], o = { type: "table", raw: $(t[0], `
13402
+ let n = se(t[1]), s = t[2].replace(this.rules.other.tableAlignChars, "").split("|"), r = t[3]?.trim() ? t[3].replace(this.rules.other.tableRowBlankLine, "").split(`
13403
+ `) : [], o = { type: "table", raw: L(t[0], `
12756
13404
  `), header: [], align: [], rows: [] };
12757
13405
  if (n.length === s.length) {
12758
13406
  for (let i of s) this.rules.other.tableAlignRight.test(i) ? o.align.push("right") : this.rules.other.tableAlignCenter.test(i) ? o.align.push("center") : this.rules.other.tableAlignLeft.test(i) ? o.align.push("left") : o.align.push(null);
12759
13407
  for (let i = 0; i < n.length; i++) o.header.push({ text: n[i], tokens: this.lexer.inline(n[i]), header: true, align: o.align[i] });
12760
- for (let i of r) o.rows.push(ee(i, o.header.length).map((l, a) => ({ text: l, tokens: this.lexer.inline(l), header: false, align: o.align[a] })));
13408
+ for (let i of r) o.rows.push(se(i, o.header.length).map((u, a) => ({ text: u, tokens: this.lexer.inline(u), header: false, align: o.align[a] })));
12761
13409
  return o;
12762
13410
  }
12763
13411
  }
@@ -12765,7 +13413,7 @@ ${g}`, r = r.substring(0, r.length - O.text.length) + z.text;
12765
13413
  let t = this.rules.block.lheading.exec(e);
12766
13414
  if (t) {
12767
13415
  let n = t[1].trim();
12768
- return { type: "heading", raw: $(t[0], `
13416
+ return { type: "heading", raw: L(t[0], `
12769
13417
  `), depth: t[2].charAt(0) === "=" ? 1 : 2, text: n, tokens: this.lexer.inline(n) };
12770
13418
  }
12771
13419
  }
@@ -12792,61 +13440,65 @@ ${g}`, r = r.substring(0, r.length - O.text.length) + z.text;
12792
13440
  link(e) {
12793
13441
  let t = this.rules.inline.link.exec(e);
12794
13442
  if (t) {
12795
- let n = t[2].trim();
12796
- if (!this.options.pedantic && this.rules.other.startAngleBracket.test(n)) {
12797
- if (!this.rules.other.endAngleBracket.test(n)) return;
12798
- let o = $(n.slice(0, -1), "\\");
12799
- if ((n.length - o.length) % 2 === 0) return;
13443
+ let n = t[0].charAt(0) === "!" ? 2 : 1;
13444
+ if (!this.options.pedantic && we(e, t[1], n, this.rules)) return;
13445
+ let s = t[2].trim();
13446
+ if (!this.options.pedantic && this.rules.other.startAngleBracket.test(s)) {
13447
+ if (!this.rules.other.endAngleBracket.test(s)) return;
13448
+ let i = L(s.slice(0, -1), "\\");
13449
+ if ((s.length - i.length) % 2 === 0) return;
12800
13450
  } else {
12801
- let o = fe(t[2], "()");
12802
- if (o === -2) return;
12803
- if (o > -1) {
12804
- let l = (t[0].indexOf("!") === 0 ? 5 : 4) + t[1].length + o;
12805
- t[2] = t[2].substring(0, o), t[0] = t[0].substring(0, l).trim(), t[3] = "";
13451
+ let i = Te(t[2], "()");
13452
+ if (i === -2) return;
13453
+ if (i > -1) {
13454
+ let a = (t[0].indexOf("!") === 0 ? 5 : 4) + t[1].length + i;
13455
+ t[2] = t[2].substring(0, i), t[0] = t[0].substring(0, a).trim(), t[3] = "";
12806
13456
  }
12807
13457
  }
12808
- let s = t[2], r = "";
13458
+ let r = t[2], o = "";
12809
13459
  if (this.options.pedantic) {
12810
- let o = this.rules.other.pedanticHrefTitle.exec(s);
12811
- o && (s = o[1], r = o[3]);
12812
- } else r = t[3] ? t[3].slice(1, -1) : "";
12813
- return s = s.trim(), this.rules.other.startAngleBracket.test(s) && (this.options.pedantic && !this.rules.other.endAngleBracket.test(n) ? s = s.slice(1) : s = s.slice(1, -1)), xe(t, { href: s && s.replace(this.rules.inline.anyPunctuation, "$1"), title: r && r.replace(this.rules.inline.anyPunctuation, "$1") }, t[0], this.lexer, this.rules);
13460
+ let i = this.rules.other.pedanticHrefTitle.exec(r);
13461
+ i && (r = i[1], o = i[3]);
13462
+ } else o = t[3] ? t[3].slice(1, -1) : "";
13463
+ return r = r.trim(), this.rules.other.startAngleBracket.test(r) && (this.options.pedantic && !this.rules.other.endAngleBracket.test(s) ? r = r.slice(1) : r = r.slice(1, -1)), Oe(t, { href: r && r.replace(this.rules.inline.anyPunctuation, "$1"), title: o && o.replace(this.rules.inline.anyPunctuation, "$1") }, t[0], this.lexer, this.rules);
12814
13464
  }
12815
13465
  }
12816
13466
  reflink(e, t) {
12817
13467
  let n;
12818
13468
  if ((n = this.rules.inline.reflink.exec(e)) || (n = this.rules.inline.nolink.exec(e))) {
12819
- let s = (n[2] || n[1]).replace(this.rules.other.multipleSpaceGlobal, " "), r = t[s.toLowerCase()];
12820
- if (!r) {
12821
- let o = n[0].charAt(0);
12822
- return { type: "text", raw: o, text: o };
13469
+ let s = n[0].charAt(0) === "!" ? 2 : 1;
13470
+ if (!this.options.pedantic && we(e, n[1], s, this.rules)) return;
13471
+ let r = (n[2] || n[1]).replace(this.rules.other.multipleSpaceGlobal, " "), o = t[q(r)];
13472
+ if (!o) {
13473
+ let i = n[0].charAt(0);
13474
+ return { type: "text", raw: i, text: i };
12823
13475
  }
12824
- return xe(n, r, n[0], this.lexer, this.rules);
13476
+ return Oe(n, o, n[0], this.lexer, this.rules);
12825
13477
  }
12826
13478
  }
12827
13479
  emStrong(e, t, n = "") {
12828
13480
  let s = this.rules.inline.emStrongLDelim.exec(e);
12829
13481
  if (!s || !s[1] && !s[2] && !s[3] && !s[4] || s[4] && n.match(this.rules.other.unicodeAlphaNumeric)) return;
12830
13482
  if (!(s[1] || s[3] || "") || !n || this.rules.inline.punctuation.exec(n)) {
12831
- let o = [...s[0]].length - 1, i, l, a = o, p = 0, c = s[0][0], h = n === c, d = c === "*" ? this.rules.inline.emStrongRDelimAst : this.rules.inline.emStrongRDelimUnd;
12832
- for (d.lastIndex = 0, t = t.slice(-1 * e.length + o); (s = d.exec(t)) !== null; ) {
13483
+ let o = [...s[0]].length - 1, i, u, a = o, p = 0, c = s[0][0], d = n === c, m = c === "*" ? this.rules.inline.emStrongRDelimAst : this.rules.inline.emStrongRDelimUnd;
13484
+ for (m.lastIndex = 0, t = t.slice(-1 * e.length + o); (s = m.exec(t)) !== null; ) {
12833
13485
  if (i = s[1] || s[2] || s[3] || s[4] || s[5] || s[6], !i) continue;
12834
- if (l = [...i].length, s[3] || s[4]) {
12835
- a += l;
13486
+ if (u = [...i].length, s[3] || s[4]) {
13487
+ a += u;
12836
13488
  continue;
12837
13489
  } else if (s[5] || s[6]) {
12838
- if (o % 3 && !((o + l) % 3)) {
12839
- p += l;
13490
+ if (o % 3 && !((o + u) % 3)) {
13491
+ p += u;
12840
13492
  continue;
12841
13493
  }
12842
- if (h) break;
13494
+ if (d) break;
12843
13495
  }
12844
- if (a -= l, a > 0) continue;
12845
- l = Math.min(l, l + a + p);
12846
- let O = [...s[0]][0].length, g = e.slice(0, o + s.index + O + l);
12847
- if (Math.min(o, l) % 2) {
12848
- let z = g.slice(1, -1);
12849
- return { type: "em", raw: g, text: z, tokens: this.lexer.inlineTokens(z) };
13496
+ if (a -= u, a > 0) continue;
13497
+ u = Math.min(u, u + a + p);
13498
+ let b = [...s[0]][0].length, g = e.slice(0, o + s.index + b + u);
13499
+ if (Math.min(o, u) % 2) {
13500
+ let f = g.slice(1, -1);
13501
+ return { type: "em", raw: g, text: f, tokens: this.lexer.inlineTokens(f) };
12850
13502
  }
12851
13503
  let w = g.slice(2, -2);
12852
13504
  return { type: "strong", raw: g, text: w, tokens: this.lexer.inlineTokens(w) };
@@ -12868,17 +13520,17 @@ ${g}`, r = r.substring(0, r.length - O.text.length) + z.text;
12868
13520
  let s = this.rules.inline.delLDelim.exec(e);
12869
13521
  if (!s) return;
12870
13522
  if (!(s[1] || "") || !n || this.rules.inline.punctuation.exec(n)) {
12871
- let o = [...s[0]].length - 1, i, l, a = o, p = this.rules.inline.delRDelim;
13523
+ let o = [...s[0]].length - 1, i, u, a = o, p = this.rules.inline.delRDelim;
12872
13524
  for (p.lastIndex = 0, t = t.slice(-1 * e.length + o); (s = p.exec(t)) !== null; ) {
12873
- if (i = s[1] || s[2] || s[3] || s[4] || s[5] || s[6], !i || (l = [...i].length, l !== o)) continue;
13525
+ if (i = s[1] || s[2] || s[3] || s[4] || s[5] || s[6], !i || (u = [...i].length, u !== o)) continue;
12874
13526
  if (s[3] || s[4]) {
12875
- a += l;
13527
+ a += u;
12876
13528
  continue;
12877
13529
  }
12878
- if (a -= l, a > 0) continue;
12879
- l = Math.min(l, l + a);
12880
- let c = [...s[0]][0].length, h = e.slice(0, o + s.index + c + l), d = h.slice(o, -o);
12881
- return { type: "del", raw: h, text: d, tokens: this.lexer.inlineTokens(d) };
13530
+ if (a -= u, a > 0) continue;
13531
+ u = Math.min(u, u + a);
13532
+ let c = [...s[0]][0].length, d = e.slice(0, o + s.index + c + u), m = d.slice(o, -o);
13533
+ return { type: "del", raw: d, text: m, tokens: this.lexer.inlineTokens(m) };
12882
13534
  }
12883
13535
  }
12884
13536
  }
@@ -12908,32 +13560,32 @@ ${g}`, r = r.substring(0, r.length - O.text.length) + z.text;
12908
13560
  let t = this.rules.inline.text.exec(e);
12909
13561
  if (t) {
12910
13562
  let n = this.lexer.state.inRawBlock;
12911
- return { type: "text", raw: t[0], text: t[0], escaped: n };
13563
+ return { type: "text", raw: t[0], text: n ? t[0] : Re(t[0]), escaped: n };
12912
13564
  }
12913
13565
  }
12914
13566
  };
12915
- var x = class u {
13567
+ var R = class l {
12916
13568
  tokens;
12917
13569
  options;
12918
13570
  state;
12919
13571
  inlineQueue;
12920
13572
  tokenizer;
12921
13573
  constructor(e) {
12922
- this.tokens = [], this.tokens.links = /* @__PURE__ */ Object.create(null), this.options = e || T, this.options.tokenizer = this.options.tokenizer || new y(), this.tokenizer = this.options.tokenizer, this.tokenizer.options = this.options, this.tokenizer.lexer = this, this.inlineQueue = [], this.state = { inLink: false, inRawBlock: false, linkEmitted: false, top: true };
12923
- let t = { other: m, block: H.normal, inline: B.normal };
12924
- this.options.pedantic ? (t.block = H.pedantic, t.inline = B.pedantic) : this.options.gfm && (t.block = H.gfm, this.options.breaks ? t.inline = B.breaks : t.inline = B.gfm), this.tokenizer.rules = t;
13574
+ this.tokens = [], this.tokens.links = /* @__PURE__ */ Object.create(null), this.options = e || y, this.options.tokenizer = this.options.tokenizer || new P(), this.tokenizer = this.options.tokenizer, this.tokenizer.options = this.options, this.tokenizer.lexer = this, this.inlineQueue = [], this.state = { inLink: false, inRawBlock: false, linkEmitted: false, top: true };
13575
+ let t = { other: x, block: j.normal, inline: D.normal };
13576
+ this.options.pedantic ? (t.block = j.pedantic, t.inline = D.pedantic) : this.options.gfm && (t.block = j.gfm, this.options.breaks ? t.inline = D.breaks : t.inline = D.gfm), this.tokenizer.rules = t;
12925
13577
  }
12926
13578
  static get rules() {
12927
- return { block: H, inline: B };
13579
+ return { block: j, inline: D };
12928
13580
  }
12929
13581
  static lex(e, t) {
12930
- return new u(t).lex(e);
13582
+ return new l(t).lex(e);
12931
13583
  }
12932
13584
  static lexInline(e, t) {
12933
- return new u(t).inlineTokens(e);
13585
+ return new l(t).inlineTokens(e);
12934
13586
  }
12935
13587
  lex(e) {
12936
- e = e.replace(m.carriageReturn, `
13588
+ e = e.replace(x.carriageReturn, `
12937
13589
  `), this.blockTokens(e, this.tokens);
12938
13590
  for (let t = 0; t < this.inlineQueue.length; t++) {
12939
13591
  let n = this.inlineQueue[t];
@@ -12942,7 +13594,7 @@ var x = class u {
12942
13594
  return this.inlineQueue = [], this.tokens;
12943
13595
  }
12944
13596
  blockTokens(e, t = [], n = false) {
12945
- this.tokenizer.lexer = this, this.options.pedantic && (e = e.replace(m.tabCharGlobal, " ").replace(m.spaceLine, ""));
13597
+ this.tokenizer.lexer = this, this.options.pedantic && (e = e.replace(x.tabCharGlobal, " ").replace(x.spaceLine, ""));
12946
13598
  let s = 1 / 0;
12947
13599
  for (; e; ) {
12948
13600
  if (e.length < s) s = e.length;
@@ -13011,9 +13663,9 @@ var x = class u {
13011
13663
  }
13012
13664
  let o = e;
13013
13665
  if (this.options.extensions?.startBlock) {
13014
- let i = 1 / 0, l = e.slice(1), a;
13666
+ let i = 1 / 0, u = e.slice(1), a;
13015
13667
  this.options.extensions.startBlock.forEach((p) => {
13016
- a = p.call({ lexer: this }, l), typeof a == "number" && a >= 0 && (i = Math.min(i, a));
13668
+ a = p.call({ lexer: this }, u), typeof a == "number" && a >= 0 && (i = Math.min(i, a));
13017
13669
  }), i < 1 / 0 && i >= 0 && (o = e.substring(0, i + 1));
13018
13670
  }
13019
13671
  if (this.state.top && (r = this.tokenizer.paragraph(o))) {
@@ -13049,7 +13701,7 @@ var x = class u {
13049
13701
  for (let n of e.matchAll(this.tokenizer.rules.inline.blockSkip)) if (t.test(n[0]) && e.charAt(n.index - 1) !== "!") return true;
13050
13702
  for (let n of e.matchAll(this.tokenizer.rules.inline.reflinkSearch)) {
13051
13703
  let s = n[0], r = s.lastIndexOf("[");
13052
- if (!(s.charAt(0) === "!" || !Object.hasOwn(this.tokens.links, s.slice(r + 1, -1))) && !(r > 1 && this.linkInText(s.slice(1, r - 1)))) return true;
13704
+ if (!(s.charAt(0) === "!" || !Object.hasOwn(this.tokens.links, q(s.slice(r + 1, -1)))) && !(r > 1 && this.linkInText(s.slice(1, r - 1)))) return true;
13053
13705
  }
13054
13706
  return false;
13055
13707
  }
@@ -13057,18 +13709,18 @@ var x = class u {
13057
13709
  this.tokenizer.lexer = this;
13058
13710
  let n = e;
13059
13711
  if (this.tokens.links && e.includes("[")) {
13060
- let i = this.tokenizer.rules.inline.reflinkSearch, l = (a) => {
13712
+ let i = this.tokenizer.rules.inline.reflinkSearch, u = (a) => {
13061
13713
  let p = a.lastIndexOf("[");
13062
- if (!Object.hasOwn(this.tokens.links, a.slice(p + 1, -1))) return a;
13714
+ if (!Object.hasOwn(this.tokens.links, q(a.slice(p + 1, -1)))) return a;
13063
13715
  if (p > 1 && a.charAt(0) !== "!") {
13064
13716
  let c = a.slice(1, p - 1);
13065
- if (this.linkInText(c)) return "[" + c.replace(i, l) + "][" + "a".repeat(a.length - p - 2) + "]";
13717
+ if (this.linkInText(c)) return "[" + c.replace(i, u) + "][" + "a".repeat(a.length - p - 2) + "]";
13066
13718
  }
13067
13719
  return "[" + "a".repeat(a.length - 2) + "]";
13068
13720
  };
13069
- n = n.replace(i, l);
13721
+ n = n.replace(i, u);
13070
13722
  }
13071
- n = n.replace(this.tokenizer.rules.inline.anyPunctuation, (i) => "+".repeat(i.length)), n = n.replace(this.tokenizer.rules.inline.blockSkip, (i, l, a) => {
13723
+ n = n.replace(this.tokenizer.rules.inline.anyPunctuation, (i) => "+".repeat(i.length)), n = n.replace(this.tokenizer.rules.inline.blockSkip, (i, u, a) => {
13072
13724
  let p = a ? a.length : 0;
13073
13725
  return i.slice(0, p) + "[" + "a".repeat(i.length - p - 2) + "]";
13074
13726
  }), n = this.options.hooks?.emStrongMask?.call({ lexer: this }, n) ?? n;
@@ -13124,14 +13776,14 @@ var x = class u {
13124
13776
  e = e.substring(i.raw.length), t.push(i);
13125
13777
  continue;
13126
13778
  }
13127
- let l = e;
13779
+ let u = e;
13128
13780
  if (this.options.extensions?.startInline) {
13129
13781
  let a = 1 / 0, p = e.slice(1), c;
13130
- this.options.extensions.startInline.forEach((h) => {
13131
- c = h.call({ lexer: this }, p), typeof c == "number" && c >= 0 && (a = Math.min(a, c));
13132
- }), a < 1 / 0 && a >= 0 && (l = e.substring(0, a + 1));
13782
+ this.options.extensions.startInline.forEach((d) => {
13783
+ c = d.call({ lexer: this }, p), typeof c == "number" && c >= 0 && (a = Math.min(a, c));
13784
+ }), a < 1 / 0 && a >= 0 && (u = e.substring(0, a + 1));
13133
13785
  }
13134
- if (i = this.tokenizer.inlineText(l)) {
13786
+ if (i = this.tokenizer.inlineText(u)) {
13135
13787
  e = e.substring(i.raw.length), i.raw.slice(-1) !== "_" && (r = i.raw.slice(-1)), s = true;
13136
13788
  let a = t.at(-1);
13137
13789
  a?.type === "text" ? (a.raw += i.raw, a.text += i.text) : t.push(i);
@@ -13150,20 +13802,20 @@ var x = class u {
13150
13802
  else throw new Error(t);
13151
13803
  }
13152
13804
  };
13153
- var P = class {
13805
+ var S = class {
13154
13806
  options;
13155
13807
  parser;
13156
13808
  constructor(e) {
13157
- this.options = e || T;
13809
+ this.options = e || y;
13158
13810
  }
13159
13811
  space(e) {
13160
13812
  return "";
13161
13813
  }
13162
13814
  code({ text: e, lang: t, escaped: n }) {
13163
- let s = (t || "").match(m.notSpaceStart)?.[0], r = e ? e.replace(m.endingNewline, "") + `
13815
+ let s = (t || "").match(x.notSpaceStart)?.[0], r = e ? e.replace(x.endingNewline, "") + `
13164
13816
  ` : "";
13165
- return s ? '<pre><code class="language-' + R(s) + '">' + (n ? r : R(r, true)) + `</code></pre>
13166
- ` : "<pre><code>" + (n ? r : R(r, true)) + `</code></pre>
13817
+ return s ? '<pre><code class="language-' + O(s) + '">' + (n ? r : O(r, true)) + `</code></pre>
13818
+ ` : "<pre><code>" + (n ? r : O(r, true)) + `</code></pre>
13167
13819
  `;
13168
13820
  }
13169
13821
  blockquote({ tokens: e }) {
@@ -13188,8 +13840,8 @@ ${this.parser.parse(e)}</blockquote>
13188
13840
  list(e) {
13189
13841
  let t = e.ordered, n = e.start, s = "";
13190
13842
  for (let i = 0; i < e.items.length; i++) {
13191
- let l = e.items[i];
13192
- s += this.listitem(l);
13843
+ let u = e.items[i];
13844
+ s += this.listitem(u);
13193
13845
  }
13194
13846
  let r = t ? "ol" : "ul", o = t && n !== 1 ? ' start="' + n + '"' : "";
13195
13847
  return "<" + r + o + `>
@@ -13241,7 +13893,7 @@ ${e}</tr>
13241
13893
  return `<em>${this.parser.parseInline(e)}</em>`;
13242
13894
  }
13243
13895
  codespan({ text: e }) {
13244
- return `<code>${R(e, true)}</code>`;
13896
+ return `<code>${O(e, true)}</code>`;
13245
13897
  }
13246
13898
  br(e) {
13247
13899
  return "<br>";
@@ -13250,25 +13902,25 @@ ${e}</tr>
13250
13902
  return `<del>${this.parser.parseInline(e)}</del>`;
13251
13903
  }
13252
13904
  link({ href: e, title: t, text: n, tokens: s, autolink: r }) {
13253
- let o = r ? R(n, true) : this.parser.parseInline(s), i = Y(e);
13905
+ let o = r ? O(n, true) : this.parser.parseInline(s), i = re(e);
13254
13906
  if (i === null) return o;
13255
- e = R(i, r);
13256
- let l = '<a href="' + e + '"';
13257
- return t && (l += ' title="' + R(t) + '"'), l += ">" + o + "</a>", l;
13907
+ e = O(i, r);
13908
+ let u = '<a href="' + e + '"';
13909
+ return t && (u += ' title="' + O(t) + '"'), u += ">" + o + "</a>", u;
13258
13910
  }
13259
13911
  image({ href: e, title: t, text: n, tokens: s }) {
13260
13912
  s && (n = this.parser.parseInline(s, this.parser.textRenderer));
13261
- let r = Y(e);
13262
- if (r === null) return R(n);
13913
+ let r = re(e);
13914
+ if (r === null) return O(n);
13263
13915
  e = r;
13264
- let o = `<img src="${R(e)}" alt="${R(n)}"`;
13265
- return t && (o += ` title="${R(t)}"`), o += ">", o;
13916
+ let o = `<img src="${O(e)}" alt="${O(n)}"`;
13917
+ return t && (o += ` title="${O(t)}"`), o += ">", o;
13266
13918
  }
13267
13919
  text(e) {
13268
- return "tokens" in e && e.tokens ? this.parser.parseInline(e.tokens) : "escaped" in e && e.escaped ? e.text : R(e.text);
13920
+ return "tokens" in e && e.tokens ? this.parser.parseInline(e.tokens) : "escaped" in e && e.escaped ? e.text : O(e.text);
13269
13921
  }
13270
13922
  };
13271
- var L = class {
13923
+ var z = class {
13272
13924
  strong({ text: e }) {
13273
13925
  return e;
13274
13926
  }
@@ -13300,18 +13952,18 @@ var L = class {
13300
13952
  return e;
13301
13953
  }
13302
13954
  };
13303
- var b = class u2 {
13955
+ var T = class l2 {
13304
13956
  options;
13305
13957
  renderer;
13306
13958
  textRenderer;
13307
13959
  constructor(e) {
13308
- this.options = e || T, this.options.renderer = this.options.renderer || new P(), this.renderer = this.options.renderer, this.renderer.options = this.options, this.renderer.parser = this, this.textRenderer = new L();
13960
+ this.options = e || y, this.options.renderer = this.options.renderer || new S(), this.renderer = this.options.renderer, this.renderer.options = this.options, this.renderer.parser = this, this.textRenderer = new z();
13309
13961
  }
13310
13962
  static parse(e, t) {
13311
- return new u2(t).parse(e);
13963
+ return new l2(t).parse(e);
13312
13964
  }
13313
13965
  static parseInline(e, t) {
13314
- return new u2(t).parseInline(e);
13966
+ return new l2(t).parseInline(e);
13315
13967
  }
13316
13968
  parse(e) {
13317
13969
  this.renderer.parser = this;
@@ -13452,11 +14104,11 @@ var b = class u2 {
13452
14104
  return n;
13453
14105
  }
13454
14106
  };
13455
- var S = class {
14107
+ var _ = class {
13456
14108
  options;
13457
14109
  block;
13458
14110
  constructor(e) {
13459
- this.options = e || T;
14111
+ this.options = e || y;
13460
14112
  }
13461
14113
  static passThroughHooks = /* @__PURE__ */ new Set(["preprocess", "postprocess", "processAllTokens", "emStrongMask"]);
13462
14114
  static passThroughHooksRespectAsync = /* @__PURE__ */ new Set(["preprocess", "postprocess", "processAllTokens"]);
@@ -13473,23 +14125,23 @@ var S = class {
13473
14125
  return e;
13474
14126
  }
13475
14127
  provideLexer(e = this.block) {
13476
- return e ? x.lex : x.lexInline;
14128
+ return e ? R.lex : R.lexInline;
13477
14129
  }
13478
14130
  provideParser(e = this.block) {
13479
- return e ? b.parse : b.parseInline;
14131
+ return e ? T.parse : T.parseInline;
13480
14132
  }
13481
14133
  };
13482
- var Z = class {
13483
- defaults = A();
14134
+ var F = class {
14135
+ defaults = I();
13484
14136
  options = this.setOptions;
13485
14137
  parse = this.parseMarkdown(true);
13486
14138
  parseInline = this.parseMarkdown(false);
13487
- Parser = b;
13488
- Renderer = P;
13489
- TextRenderer = L;
13490
- Lexer = x;
13491
- Tokenizer = y;
13492
- Hooks = S;
14139
+ Parser = T;
14140
+ Renderer = S;
14141
+ TextRenderer = z;
14142
+ Lexer = R;
14143
+ Tokenizer = P;
14144
+ Hooks = _;
13493
14145
  constructor(...e) {
13494
14146
  this.use(...e);
13495
14147
  }
@@ -13526,8 +14178,8 @@ var Z = class {
13526
14178
  if ("renderer" in r) {
13527
14179
  let o = t.renderers[r.name];
13528
14180
  o ? t.renderers[r.name] = function(...i) {
13529
- let l = r.renderer.apply(this, i);
13530
- return l === false && (l = o.apply(this, i)), l;
14181
+ let u = r.renderer.apply(this, i);
14182
+ return u === false && (u = o.apply(this, i)), u;
13531
14183
  } : t.renderers[r.name] = r.renderer;
13532
14184
  }
13533
14185
  if ("tokenizer" in r) {
@@ -13537,50 +14189,50 @@ var Z = class {
13537
14189
  }
13538
14190
  "childTokens" in r && r.childTokens && (t.childTokens[r.name] = r.childTokens);
13539
14191
  }), s.extensions = t), n.renderer) {
13540
- let r = this.defaults.renderer || new P(this.defaults);
14192
+ let r = this.defaults.renderer || new S(this.defaults);
13541
14193
  for (let o in n.renderer) {
13542
14194
  if (!(o in r)) throw new Error(`renderer '${o}' does not exist`);
13543
14195
  if (["options", "parser"].includes(o)) continue;
13544
- let i = o, l = n.renderer[i], a = r[i];
14196
+ let i = o, u = n.renderer[i], a = r[i];
13545
14197
  r[i] = (...p) => {
13546
- let c = l.apply(r, p);
14198
+ let c = u.apply(r, p);
13547
14199
  return c === false && (c = a.apply(r, p)), c || "";
13548
14200
  };
13549
14201
  }
13550
14202
  s.renderer = r;
13551
14203
  }
13552
14204
  if (n.tokenizer) {
13553
- let r = this.defaults.tokenizer || new y(this.defaults);
14205
+ let r = this.defaults.tokenizer || new P(this.defaults);
13554
14206
  for (let o in n.tokenizer) {
13555
14207
  if (!(o in r)) throw new Error(`tokenizer '${o}' does not exist`);
13556
14208
  if (["options", "rules", "lexer"].includes(o)) continue;
13557
- let i = o, l = n.tokenizer[i], a = r[i];
14209
+ let i = o, u = n.tokenizer[i], a = r[i];
13558
14210
  r[i] = (...p) => {
13559
- let c = l.apply(r, p);
14211
+ let c = u.apply(r, p);
13560
14212
  return c === false && (c = a.apply(r, p)), c;
13561
14213
  };
13562
14214
  }
13563
14215
  s.tokenizer = r;
13564
14216
  }
13565
14217
  if (n.hooks) {
13566
- let r = this.defaults.hooks || new S();
14218
+ let r = this.defaults.hooks || new _();
13567
14219
  for (let o in n.hooks) {
13568
14220
  if (!(o in r)) throw new Error(`hook '${o}' does not exist`);
13569
14221
  if (["options", "block"].includes(o)) continue;
13570
- let i = o, l = n.hooks[i], a = r[i];
13571
- S.passThroughHooks.has(o) ? r[i] = (p) => {
13572
- if (this.defaults.async && S.passThroughHooksRespectAsync.has(o)) return (async () => {
13573
- let h = await l.call(r, p);
13574
- return a.call(r, h);
14222
+ let i = o, u = n.hooks[i], a = r[i];
14223
+ _.passThroughHooks.has(o) ? r[i] = (p) => {
14224
+ if (this.defaults.async && _.passThroughHooksRespectAsync.has(o)) return (async () => {
14225
+ let d = await u.call(r, p);
14226
+ return a.call(r, d);
13575
14227
  })();
13576
- let c = l.call(r, p);
14228
+ let c = u.call(r, p);
13577
14229
  return a.call(r, c);
13578
14230
  } : r[i] = (...p) => {
13579
14231
  if (this.defaults.async) return (async () => {
13580
- let h = await l.apply(r, p);
13581
- return h === false && (h = await a.apply(r, p)), h;
14232
+ let d = await u.apply(r, p);
14233
+ return d === false && (d = await a.apply(r, p)), d;
13582
14234
  })();
13583
- let c = l.apply(r, p);
14235
+ let c = u.apply(r, p);
13584
14236
  return c === false && (c = a.apply(r, p)), c;
13585
14237
  };
13586
14238
  }
@@ -13589,8 +14241,8 @@ var Z = class {
13589
14241
  if (n.walkTokens) {
13590
14242
  let r = this.defaults.walkTokens, o = n.walkTokens;
13591
14243
  s.walkTokens = function(i) {
13592
- let l = [];
13593
- return l.push(o.call(this, i)), r && (l = l.concat(r.call(this, i))), l;
14244
+ let u = [];
14245
+ return u.push(o.call(this, i)), r && (u = u.concat(r.call(this, i))), u;
13594
14246
  };
13595
14247
  }
13596
14248
  this.defaults = { ...this.defaults, ...s };
@@ -13600,10 +14252,10 @@ var Z = class {
13600
14252
  return this.defaults = { ...this.defaults, ...e }, this;
13601
14253
  }
13602
14254
  lexer(e, t) {
13603
- return x.lex(e, t ?? this.defaults);
14255
+ return R.lex(e, t ?? this.defaults);
13604
14256
  }
13605
14257
  parser(e, t) {
13606
- return b.parse(e, t ?? this.defaults);
14258
+ return T.parse(e, t ?? this.defaults);
13607
14259
  }
13608
14260
  parseMarkdown(e) {
13609
14261
  return (n, s) => {
@@ -13612,19 +14264,19 @@ var Z = class {
13612
14264
  if (typeof n > "u" || n === null) return i(new Error("marked(): input parameter is undefined or null"));
13613
14265
  if (typeof n != "string") return i(new Error("marked(): input parameter is of type " + Object.prototype.toString.call(n) + ", string expected"));
13614
14266
  if (o.hooks && (o.hooks.options = o, o.hooks.block = e), o.async) return (async () => {
13615
- let l = o.hooks ? await o.hooks.preprocess(n) : n, p = await (o.hooks ? await o.hooks.provideLexer(e) : e ? x.lex : x.lexInline)(l, o), c = o.hooks ? await o.hooks.processAllTokens(p) : p;
14267
+ let u = o.hooks ? await o.hooks.preprocess(n) : n, p = await (o.hooks ? await o.hooks.provideLexer(e) : e ? R.lex : R.lexInline)(u, o), c = o.hooks ? await o.hooks.processAllTokens(p) : p;
13616
14268
  o.walkTokens && await Promise.all(this.walkTokens(c, o.walkTokens));
13617
- let d = await (o.hooks ? await o.hooks.provideParser(e) : e ? b.parse : b.parseInline)(c, o);
13618
- return o.hooks ? await o.hooks.postprocess(d) : d;
14269
+ let m = await (o.hooks ? await o.hooks.provideParser(e) : e ? T.parse : T.parseInline)(c, o);
14270
+ return o.hooks ? await o.hooks.postprocess(m) : m;
13619
14271
  })().catch(i);
13620
14272
  try {
13621
14273
  o.hooks && (n = o.hooks.preprocess(n));
13622
- let a = (o.hooks ? o.hooks.provideLexer(e) : e ? x.lex : x.lexInline)(n, o);
14274
+ let a = (o.hooks ? o.hooks.provideLexer(e) : e ? R.lex : R.lexInline)(n, o);
13623
14275
  o.hooks && (a = o.hooks.processAllTokens(a)), o.walkTokens && this.walkTokens(a, o.walkTokens);
13624
- let c = (o.hooks ? o.hooks.provideParser(e) : e ? b.parse : b.parseInline)(a, o);
14276
+ let c = (o.hooks ? o.hooks.provideParser(e) : e ? T.parse : T.parseInline)(a, o);
13625
14277
  return o.hooks && (c = o.hooks.postprocess(c)), c;
13626
- } catch (l) {
13627
- return i(l);
14278
+ } catch (u) {
14279
+ return i(u);
13628
14280
  }
13629
14281
  };
13630
14282
  }
@@ -13632,7 +14284,7 @@ var Z = class {
13632
14284
  return (n) => {
13633
14285
  if (n.message += `
13634
14286
  Please report this to https://github.com/markedjs/marked.`, e) {
13635
- let s = "<p>An error occurred:</p><pre>" + R(n.message + "", true) + "</pre>";
14287
+ let s = "<p>An error occurred:</p><pre>" + O(n.message + "", true) + "</pre>";
13636
14288
  return t ? Promise.resolve(s) : s;
13637
14289
  }
13638
14290
  if (t) return Promise.reject(n);
@@ -13640,41 +14292,41 @@ Please report this to https://github.com/markedjs/marked.`, e) {
13640
14292
  };
13641
14293
  }
13642
14294
  };
13643
- var M = new Z();
13644
- function f(u3, e) {
13645
- return M.parse(u3, e);
14295
+ var E = new F();
14296
+ function k(l3, e) {
14297
+ return E.parse(l3, e);
13646
14298
  }
13647
- f.options = f.setOptions = function(u3) {
13648
- return M.setOptions(u3), f.defaults = M.defaults, j(f.defaults), f;
14299
+ k.options = k.setOptions = function(l3) {
14300
+ return E.setOptions(l3), k.defaults = E.defaults, W(k.defaults), k;
13649
14301
  };
13650
- f.getDefaults = A;
13651
- f.defaults = T;
13652
- function gt(...u3) {
13653
- return M.use(...u3), f.defaults = M.defaults, j(f.defaults), f;
13654
- }
13655
- f.use = gt;
13656
- f.walkTokens = function(u3, e) {
13657
- return M.walkTokens(u3, e);
14302
+ k.getDefaults = I;
14303
+ k.defaults = y;
14304
+ function Pt(...l3) {
14305
+ return E.use(...l3), k.defaults = E.defaults, W(k.defaults), k;
14306
+ }
14307
+ k.use = Pt;
14308
+ k.walkTokens = function(l3, e) {
14309
+ return E.walkTokens(l3, e);
13658
14310
  };
13659
- f.parseInline = M.parseInline;
13660
- f.Parser = b;
13661
- f.parser = b.parse;
13662
- f.Renderer = P;
13663
- f.TextRenderer = L;
13664
- f.Lexer = x;
13665
- f.lexer = x.lex;
13666
- f.Tokenizer = y;
13667
- f.Hooks = S;
13668
- f.parse = f;
13669
- var rn = f.options;
13670
- var sn = f.setOptions;
13671
- var on = f.walkTokens;
13672
- var an = f.parseInline;
13673
- var un = b.parse;
13674
- var pn = x.lex;
14311
+ k.parseInline = E.parseInline;
14312
+ k.Parser = T;
14313
+ k.parser = T.parse;
14314
+ k.Renderer = S;
14315
+ k.TextRenderer = z;
14316
+ k.Lexer = R;
14317
+ k.lexer = R.lex;
14318
+ k.Tokenizer = P;
14319
+ k.Hooks = _;
14320
+ k.parse = k;
14321
+ var gn = k.options;
14322
+ var fn = k.setOptions;
14323
+ var mn = k.walkTokens;
14324
+ var xn = k.parseInline;
14325
+ var Rn = T.parse;
14326
+ var Tn = R.lex;
13675
14327
 
13676
14328
  // src/ui/transcript/render_markdown.ts
13677
- var parser = new Z({ gfm: true, breaks: true });
14329
+ var parser = new F({ gfm: true, breaks: true });
13678
14330
  var ALLOWED_TAGS = [
13679
14331
  "a",
13680
14332
  "p",
@@ -13743,7 +14395,7 @@ function harden(node) {
13743
14395
  var purifier = null;
13744
14396
  function sanitizer() {
13745
14397
  if (purifier === null) {
13746
- purifier = purify();
14398
+ purifier = purify_default();
13747
14399
  purifier.addHook("afterSanitizeAttributes", harden);
13748
14400
  }
13749
14401
  return purifier;
@@ -14576,8 +15228,10 @@ var AgUiClient = class {
14576
15228
  #unfinishedMessage;
14577
15229
  #declinedMessage;
14578
15230
  #maxToolRounds;
14579
- // Set by cancel(); reset at the top of each #run(). Checked by the loop so
14580
- // a cancel between frontend-tool rounds doesn't start another round.
15231
+ // Set by cancel(); reset as send() or resume() begins, before either runs
15232
+ // any host code. Checked by the loop so a cancel between frontend-tool
15233
+ // rounds doesn't start another round, and again just before each request,
15234
+ // so a cancel from host code the round itself runs is not sent anyway.
14581
15235
  #cancelled = false;
14582
15236
  constructor(config) {
14583
15237
  this.#agent = config.agent;
@@ -14633,6 +15287,7 @@ var AgUiClient = class {
14633
15287
  * {@link messageAttachments}.
14634
15288
  */
14635
15289
  async send(content, attachments = []) {
15290
+ this.#cancelled = false;
14636
15291
  const message = {
14637
15292
  id: randomUUID4(),
14638
15293
  role: "user",
@@ -14648,11 +15303,14 @@ var AgUiClient = class {
14648
15303
  * can be asked again.
14649
15304
  *
14650
15305
  * Returns the retained history, or `null` when there is nothing to retry (no
14651
- * user message has been sent yet). **Truncates only** -- the caller re-renders
14652
- * from the returned list and then calls {@link resume}, because the transcript
14653
- * belongs to the element and a client that reached into it would own two
14654
- * things. Running here instead would stream the new answer in underneath the
14655
- * old one.
15306
+ * user message has been sent yet). The shortened history is saved before it
15307
+ * replaces the current one, so a save that throws changes nothing and the
15308
+ * throw propagates.
15309
+ *
15310
+ * **Truncates only** -- the caller re-renders from the returned list and then
15311
+ * calls {@link resume}, because the transcript belongs to the element and a
15312
+ * client that reached into it would own two things. Running here instead
15313
+ * would stream the new answer in underneath the old one.
14656
15314
  *
14657
15315
  * Re-running answers the question the agent was last asked, rather than
14658
15316
  * telling it its answer was wrong, which is what makes the result a
@@ -14674,8 +15332,8 @@ var AgUiClient = class {
14674
15332
  return null;
14675
15333
  }
14676
15334
  const kept = messages.slice(0, lastUser + 1);
15335
+ this.#onPersist(kept);
14677
15336
  this.#agent.setMessages(kept);
14678
- this.#persist();
14679
15337
  return kept;
14680
15338
  }
14681
15339
  /**
@@ -14684,6 +15342,7 @@ var AgUiClient = class {
14684
15342
  * message; it continues the conversation already in history.
14685
15343
  */
14686
15344
  async resume() {
15345
+ this.#cancelled = false;
14687
15346
  await this.#run();
14688
15347
  }
14689
15348
  /** Append a frontend tool result to history (used by the resume path). */
@@ -14697,13 +15356,19 @@ var AgUiClient = class {
14697
15356
  * disconnect). Safe to call with no run in flight. Partial text already
14698
15357
  * streamed stays in history; {@link AgUiClientHandlers.onCancelled} fires
14699
15358
  * instead of `onError`, and `onSettled` still follows.
15359
+ *
15360
+ * Also stops a {@link send} or {@link resume} whose request has not been made
15361
+ * yet, when host code it runs on the way calls this: the save of the turn,
15362
+ * the tool and context providers, the save answering a call left open. No
15363
+ * request is made then, and `onCancelled` and `onSettled` fire as for any
15364
+ * other Stop. A cancel with nothing in flight is forgotten when the next
15365
+ * send or resume begins.
14700
15366
  */
14701
15367
  cancel() {
14702
15368
  this.#cancelled = true;
14703
15369
  this.#agent.abortRun();
14704
15370
  }
14705
15371
  async #run() {
14706
- this.#cancelled = false;
14707
15372
  try {
14708
15373
  await this.#runLoop();
14709
15374
  if (this.#cancelled) {
@@ -14861,6 +15526,9 @@ var AgUiClient = class {
14861
15526
  params.resume = resume;
14862
15527
  }
14863
15528
  this.#answerUnansweredCalls(resuming);
15529
+ if (this.#cancelled) {
15530
+ return;
15531
+ }
14864
15532
  await this.#agent.runAgent(params, this.#buildSubscriber(pending, runState));
14865
15533
  resume = void 0;
14866
15534
  resuming = /* @__PURE__ */ new Set();
@@ -14918,13 +15586,13 @@ var AgUiClient = class {
14918
15586
  }
14919
15587
  }
14920
15588
  #buildSubscriber(pending, runState) {
14921
- const h = this.#handlers;
15589
+ const h2 = this.#handlers;
14922
15590
  const closed = this.#closedMessageIds;
14923
15591
  const cancelled = () => this.#cancelled;
14924
15592
  const pendingDeltas = /* @__PURE__ */ new Set();
14925
15593
  return {
14926
15594
  onRunInitialized() {
14927
- h.onRunStart();
15595
+ h2.onRunStart();
14928
15596
  },
14929
15597
  onTextMessageStartEvent({ event }) {
14930
15598
  if (closed.has(event.messageId)) {
@@ -14934,11 +15602,11 @@ var AgUiClient = class {
14934
15602
  }
14935
15603
  },
14936
15604
  onTextMessageContentEvent({ textMessageBuffer }) {
14937
- h.onTextDelta(textMessageBuffer);
15605
+ h2.onTextDelta(textMessageBuffer);
14938
15606
  },
14939
15607
  onTextMessageEndEvent({ event, textMessageBuffer }) {
14940
15608
  closed.add(event.messageId);
14941
- h.onTextEnd(textMessageBuffer);
15609
+ h2.onTextEnd(textMessageBuffer);
14942
15610
  },
14943
15611
  onToolCallEndEvent({ event, toolCallName, toolCallArgs }) {
14944
15612
  const call = {
@@ -14947,21 +15615,21 @@ var AgUiClient = class {
14947
15615
  args: toolCallArgs
14948
15616
  };
14949
15617
  pending.push(call);
14950
- h.onToolCall(call);
15618
+ h2.onToolCall(call);
14951
15619
  },
14952
15620
  onToolCallResultEvent({ event }) {
14953
15621
  const outcome = event.metadata?.["outcome"];
14954
- h.onToolResult(event.toolCallId, contentToText2(event.content), outcome);
15622
+ h2.onToolResult(event.toolCallId, contentToText2(event.content), outcome);
14955
15623
  },
14956
15624
  onActivitySnapshotEvent({ event, messages }) {
14957
15625
  const known = messages.some(
14958
15626
  (message) => message.id === event.messageId && message.role === "activity"
14959
15627
  );
14960
15628
  if (known) {
14961
- h.onActivityChanged(event.messageId, event.activityType, event.content);
15629
+ h2.onActivityChanged(event.messageId, event.activityType, event.content);
14962
15630
  return;
14963
15631
  }
14964
- h.onActivity(event.activityType, event.content, event.messageId);
15632
+ h2.onActivity(event.activityType, event.content, event.messageId);
14965
15633
  },
14966
15634
  // Deliberately does *not* read the message here. `@ag-ui/client`
14967
15635
  // dispatches this subscriber **before** applying the patch, so the
@@ -14976,7 +15644,7 @@ var AgUiClient = class {
14976
15644
  // first moment the result exists. Only the ids marked above are looked at,
14977
15645
  // so an ordinary text delta does not walk the transcript.
14978
15646
  onCustomEvent({ event }) {
14979
- h.onCustomEvent(event.name, event.value);
15647
+ h2.onCustomEvent(event.name, event.value);
14980
15648
  },
14981
15649
  // The delegation lifecycle. Forwarded rather than interpreted here, for
14982
15650
  // the reason every other subscriber in this block is thin: this file
@@ -14986,16 +15654,16 @@ var AgUiClient = class {
14986
15654
  // `parentToolCallId` is optional on the wire and normalised to `null` so
14987
15655
  // the handler has one absent-value to check rather than two.
14988
15656
  onSubagentStartedEvent({ event }) {
14989
- h.onSubAgentStarted(event.subagentRunId, event.name, event.parentToolCallId ?? null);
15657
+ h2.onSubAgentStarted(event.subagentRunId, event.name, event.parentToolCallId ?? null);
14990
15658
  },
14991
15659
  onSubagentFinishedEvent({ event }) {
14992
- h.onSubAgentFinished(event.subagentRunId);
15660
+ h2.onSubAgentFinished(event.subagentRunId);
14993
15661
  },
14994
15662
  onSubagentErrorEvent({ event }) {
14995
- h.onSubAgentError(event.subagentRunId, event.message);
15663
+ h2.onSubAgentError(event.subagentRunId, event.message);
14996
15664
  },
14997
15665
  onMessagesSnapshotEvent({ event }) {
14998
- h.onMessagesSnapshot(event.messages);
15666
+ h2.onMessagesSnapshot(event.messages);
14999
15667
  },
15000
15668
  onMessagesChanged({ messages }) {
15001
15669
  if (pendingDeltas.size === 0) {
@@ -15004,7 +15672,7 @@ var AgUiClient = class {
15004
15672
  for (const id of pendingDeltas) {
15005
15673
  const message = messages.find((entry) => entry.id === id);
15006
15674
  if (message !== void 0 && message.role === "activity") {
15007
- h.onActivityChanged(id, message.activityType, message.content);
15675
+ h2.onActivityChanged(id, message.activityType, message.content);
15008
15676
  }
15009
15677
  }
15010
15678
  pendingDeltas.clear();
@@ -15015,10 +15683,10 @@ var AgUiClient = class {
15015
15683
  // family emits THINKING_*: pydantic-ai has sent REASONING_* at every
15016
15684
  // protocol version django-ag-ui admits.
15017
15685
  onReasoningStartEvent() {
15018
- h.onReasoningStart();
15686
+ h2.onReasoningStart();
15019
15687
  },
15020
15688
  onReasoningMessageContentEvent({ reasoningMessageBuffer }) {
15021
- h.onReasoningDelta(reasoningMessageBuffer);
15689
+ h2.onReasoningDelta(reasoningMessageBuffer);
15022
15690
  },
15023
15691
  // The delta callback reports the buffer as it stood *before* the announced
15024
15692
  // delta was appended, so on its own it always trails the stream by one and
@@ -15028,10 +15696,10 @@ var AgUiClient = class {
15028
15696
  // REASONING_MESSAGE_END rather than REASONING_END, because only the former
15029
15697
  // carries a buffer.
15030
15698
  onReasoningMessageEndEvent({ reasoningMessageBuffer }) {
15031
- h.onReasoningDelta(reasoningMessageBuffer);
15699
+ h2.onReasoningDelta(reasoningMessageBuffer);
15032
15700
  },
15033
15701
  onReasoningEndEvent() {
15034
- h.onReasoningEnd();
15702
+ h2.onReasoningEnd();
15035
15703
  },
15036
15704
  onRunFinishedEvent(params) {
15037
15705
  runState.terminal = true;
@@ -15045,11 +15713,11 @@ var AgUiClient = class {
15045
15713
  if (cancelled()) {
15046
15714
  return;
15047
15715
  }
15048
- h.onError(event.message);
15716
+ h2.onError(event.message);
15049
15717
  },
15050
15718
  onRunFinalized() {
15051
15719
  runState.terminal = true;
15052
- h.onRunEnd();
15720
+ h2.onRunEnd();
15053
15721
  }
15054
15722
  };
15055
15723
  }
@@ -15193,7 +15861,7 @@ var SessionStorageStore = class _SessionStorageStore {
15193
15861
  }
15194
15862
  }
15195
15863
  listThreads() {
15196
- const metas = this.#readThreads().sort((a, b2) => b2.updatedAt - a.updatedAt).map(({ threadId, title, updatedAt, preview }) => ({ threadId, title, updatedAt, preview }));
15864
+ const metas = this.#readThreads().sort((a, b) => b.updatedAt - a.updatedAt).map(({ threadId, title, updatedAt, preview }) => ({ threadId, title, updatedAt, preview }));
15197
15865
  return Promise.resolve(metas);
15198
15866
  }
15199
15867
  setActiveThread(threadId) {
@@ -15783,9 +16451,12 @@ var StorageScope = class {
15783
16451
  // remounts, but re-resolves if the host answers the warning with an `id`.
15784
16452
  #generatedNs = "";
15785
16453
  #generatedFor = "";
15786
- // The `sessionStorage`-backed store, which the element may therefore re-scope
15787
- // on a principal change. `null` when the host injected a store of its own
15788
- // kind, whose keying the element does not know and must not guess at.
16454
+ // The `sessionStorage`-backed store this scope handed out, which the element
16455
+ // may therefore re-scope on a principal change -- while it is still the store
16456
+ // in use, which rescopeStore asks, since a host can assign its own at any
16457
+ // time. `null` until connecting has met the built-in store at all. A store of
16458
+ // the host's own kind is never held here: the element does not know its
16459
+ // keying and must not guess at it.
15789
16460
  #builtinStore = null;
15790
16461
  constructor(host) {
15791
16462
  this.#host = host;
@@ -15839,12 +16510,22 @@ var StorageScope = class {
15839
16510
  return this.#builtinStore;
15840
16511
  }
15841
16512
  /**
15842
- * Rebuild the built-in store under `namespace`, or `null` for a store of the
15843
- * host's own kind, which holds its data somewhere the element cannot see and
15844
- * has to scope itself.
16513
+ * Rebuild the built-in store under `namespace`, or `null` when `current` --
16514
+ * the store the element is using now, unwrapped from any remote it wrapped
16515
+ * it in -- is not the one this scope handed out.
16516
+ *
16517
+ * Asked of the store in use rather than of what connecting remembered,
16518
+ * because the two part company the moment a host assigns a store of its own
16519
+ * to a connected element. Remembering was enough to tell a host's store from
16520
+ * the built-in one at connect; after it, the built-in one was still
16521
+ * remembered, so a key change replaced the host's store with a fresh
16522
+ * `sessionStorage` one -- and a host that had chosen to keep message bodies
16523
+ * off the client found every one of them cached in the tab again. A store
16524
+ * the element did not make holds its data somewhere the element cannot see,
16525
+ * and has to scope itself.
15845
16526
  */
15846
- rescopeStore(namespace) {
15847
- if (this.#builtinStore === null) {
16527
+ rescopeStore(current, namespace) {
16528
+ if (current !== this.#builtinStore) {
15848
16529
  return null;
15849
16530
  }
15850
16531
  this.#builtinStore = new SessionStorageStore(namespace);
@@ -16368,6 +17049,13 @@ var AgUiChat = class extends HTMLElement {
16368
17049
  #queuedRow = document.createElement("div");
16369
17050
  /** How far back the composer has been walked; null while the user is typing. */
16370
17051
  #recallIndex = null;
17052
+ /**
17053
+ * What the walk last put in the composer, read back from it. A walk is live
17054
+ * only while the composer still holds exactly this, so a write from anywhere
17055
+ * else ends it. Stale while no walk is in progress, which is harmless: the
17056
+ * comparison can only ever end a walk, never start one.
17057
+ */
17058
+ #recalled = "";
16371
17059
  /**
16372
17060
  * Re-clamp the dragged launcher when the window changes size. Bound once as
16373
17061
  * a field so `removeEventListener` on disconnect gets the same reference.
@@ -16403,6 +17091,39 @@ var AgUiChat = class extends HTMLElement {
16403
17091
  * history replay would draw the conversation a second time beneath it.
16404
17092
  */
16405
17093
  #connectedBefore = false;
17094
+ /**
17095
+ * The `user-key` whose state the element holds -- the transcript, the recall
17096
+ * history, the Always allow waivers and the shared state -- or `null` before
17097
+ * the first connect, when it holds nobody's.
17098
+ *
17099
+ * Not the same thing as the attribute. The attribute names the principal the
17100
+ * host says is here now, and it can change while the element is out of the
17101
+ * document, where nothing acts on it; this is who the state still belongs
17102
+ * to. Connecting compares the two, which is how a key changed while detached
17103
+ * still gets the handover a live change gets.
17104
+ */
17105
+ #principalKey = null;
17106
+ /**
17107
+ * The current principal's tenure: replaced on every handover from one
17108
+ * principal to another, and captured by each client as it is built, so that
17109
+ * a client can tell whether the principal it was built for is still the one
17110
+ * this element serves.
17111
+ *
17112
+ * A client outlives the handover that stops it. A stopped run saves what it
17113
+ * had once its request closes, a tool handler cannot be aborted and its
17114
+ * result is kept, and an event already read off the wire is still applied --
17115
+ * all of it after the store was purged and scoped to whoever arrived, so
17116
+ * each one wrote the previous principal's words into the next one's storage
17117
+ * or state. Writing into the previous principal's store instead would only
17118
+ * re-create what the purge just removed, so such a client writes nothing.
17119
+ *
17120
+ * An identity rather than the key itself, for two reasons. The key's first
17121
+ * arrival is an adoption, not a handover, and a run in flight across it is
17122
+ * the same person's and keeps saving. And a key that leaves and comes back
17123
+ * is a second tenure: the first one's stopped run must not re-create a
17124
+ * conversation the handover purged.
17125
+ */
17126
+ #tenure = {};
16406
17127
  /**
16407
17128
  * The remote store `data-threads-url` wrapped around the conversation store,
16408
17129
  * and the store inside it, so connecting again can wrap that store rather
@@ -16421,6 +17142,33 @@ var AgUiChat = class extends HTMLElement {
16421
17142
  // the Send⇄Stop button: `agent.isRunning` is false between frontend-tool
16422
17143
  // rounds, but the user must still be able to stop there.
16423
17144
  #running = false;
17145
+ /**
17146
+ * The send {@link sendMessage} has taken, or the retry {@link retryLastTurn}
17147
+ * has, whose run has not started yet; null otherwise.
17148
+ *
17149
+ * `running` turns on when the client starts the run, a microtask after it is
17150
+ * asked for one, and a send does two things before it asks: it draws the
17151
+ * turn, and it dispatches the submit event, whose listeners run in the middle
17152
+ * of the send. A send from one of them, or a second call in the same task,
17153
+ * passed every guard and started a second run on the same client -- two
17154
+ * requests, and the listener's turn drawn between the user's turn and its
17155
+ * answer. It is the gap a picked checkpoint closes by counting from the pick,
17156
+ * closed the same way for a send. A retry asks for its run the same way, so
17157
+ * it takes the same hold, and so does a restore that will resume a run, from
17158
+ * before it asks the store for the conversation, through the history host's
17159
+ * `holdRun`.
17160
+ *
17161
+ * Let go of once the run starts, because `running` holds from then until the
17162
+ * run settles, and a send held past that would refuse a host's follow-up from
17163
+ * the run-finished event, which fires as the run settles. Let go of by the
17164
+ * send's, the retry's or the restore's end when its run never starts.
17165
+ *
17166
+ * An object rather than a flag, so a send or a retry ending releases only
17167
+ * what it took. By the time either ends, the turn queued behind it has
17168
+ * usually taken the field for itself, and a Stop lets go of it for the next
17169
+ * send to take; the earlier one ending must release neither.
17170
+ */
17171
+ #sending = null;
16424
17172
  /** The decision a run is suspended on, which a Stop abandons. */
16425
17173
  #decision = new PendingDecision();
16426
17174
  /**
@@ -16510,7 +17258,10 @@ var AgUiChat = class extends HTMLElement {
16510
17258
  approvalRenderer: () => this.approvalRenderer,
16511
17259
  getContext: () => this.getContext(),
16512
17260
  conversationStore: () => this.conversationStore,
16513
- threadId: () => this.#history.threadId
17261
+ threadId: () => this.#history.threadId,
17262
+ // Read live and compared, the way each client compares the one it was
17263
+ // built with: see #tenure.
17264
+ tenure: () => this.#tenure
16514
17265
  });
16515
17266
  this.#runHandlers = new RunHandlers({
16516
17267
  element: this,
@@ -16643,6 +17394,10 @@ var AgUiChat = class extends HTMLElement {
16643
17394
  headersFor: (url) => this.#headersFor(url),
16644
17395
  requestCredentials: () => this.#requestCredentials(),
16645
17396
  appendMessage: (role, content) => this.appendMessage(role, content),
17397
+ // A continuation sends only what the composer holds. The tray is not
17398
+ // read, so nothing rides along to be drawn or announced.
17399
+ announceTurn: (content) => this.#announceTurn(content, []),
17400
+ recordTurn: (content) => this.#recordTurn(content),
16646
17401
  autoGrow: () => autoGrow(this.#input),
16647
17402
  continuationEnded: () => this.#flushQueued(),
16648
17403
  client: () => this.#client,
@@ -16651,7 +17406,37 @@ var AgUiChat = class extends HTMLElement {
16651
17406
  releaseClient: () => {
16652
17407
  this.#client = null;
16653
17408
  },
16654
- running: () => this.#running,
17409
+ // A held send or retry is as much in flight to a pick as a run is: it has
17410
+ // asked this element's client for a run that has not started, and a
17411
+ // continuation started beside it was a second run in one conversation.
17412
+ // So is a restore that will resume a run, which holds through the same
17413
+ // field from before the store answers.
17414
+ running: () => this.#running || this.#sending !== null,
17415
+ // The hold a send takes, taken for a restore that will resume a run, so
17416
+ // what refuses a send held short of its run refuses one made while the
17417
+ // store is still answering: `sendMessage` returns, Send parks the turn,
17418
+ // a Retry and a pick refuse. The same field rather than a flag beside it,
17419
+ // because what lets go of a send's hold is right for this one too. The
17420
+ // resumed run starting lets go, in `#setRunning`, so there is no gap
17421
+ // after the resume is asked for, and a Stop does, in `#cancelRun`. A flag
17422
+ // the restore cleared itself would still be set when the resumed run
17423
+ // settles and sends the parked turn, so that send would be refused after
17424
+ // the turn had left the queue, and lost.
17425
+ //
17426
+ // Whether the restore was stopped is not read off this hold, because one
17427
+ // with nothing to resume takes none; the restore asks its own generation.
17428
+ holdRun: () => {
17429
+ const hold = {};
17430
+ this.#sending = hold;
17431
+ return {
17432
+ release: () => {
17433
+ if (this.#sending === hold) {
17434
+ this.#sending = null;
17435
+ this.#flushQueued();
17436
+ }
17437
+ }
17438
+ };
17439
+ },
16655
17440
  cancelRun: () => this.#cancelRun(),
16656
17441
  resetState: () => this.#resetState(),
16657
17442
  setRunning: (running) => this.#setRunning(running)
@@ -16961,6 +17746,12 @@ var AgUiChat = class extends HTMLElement {
16961
17746
  }
16962
17747
  this.#syncLauncher();
16963
17748
  this.#skills.init();
17749
+ const held = this.#principalKey;
17750
+ const changed = held !== null && held !== this.userKey;
17751
+ if (changed) {
17752
+ this.#changePrincipal(held, this.userKey);
17753
+ }
17754
+ this.#principalKey = this.userKey;
16964
17755
  this.conversationStore = this.#storage.scopeStore(this.#unwrappedStore(), this.userKey);
16965
17756
  window.addEventListener("resize", this.#onViewportResize);
16966
17757
  window.visualViewport?.addEventListener("resize", this.#onViewportResize);
@@ -16972,6 +17763,9 @@ var AgUiChat = class extends HTMLElement {
16972
17763
  this.#history.adoptActiveThread();
16973
17764
  queueMicrotask(() => this.#startup());
16974
17765
  void this.#history.rehydrate();
17766
+ if (changed) {
17767
+ void this.#history.refreshDrawer();
17768
+ }
16975
17769
  this.#connected = true;
16976
17770
  }
16977
17771
  /**
@@ -17296,23 +18090,49 @@ var AgUiChat = class extends HTMLElement {
17296
18090
  * logout, because a logout is a navigation (or, in a single-page app, not
17297
18091
  * even that) rather than a tab close. Nothing remounts, so the host naming
17298
18092
  * the new principal is the only signal the element will ever get.
18093
+ *
18094
+ * Two callers. A live change runs all of it. connectedCallback runs it for a
18095
+ * key that changed while the element was out of the document, and there it
18096
+ * runs before the store is scoped and before `#connected` is set -- which is
18097
+ * what `live` reads, since `isConnected` is already true by then. That call
18098
+ * does the half about what storage and the element still hold. The half
18099
+ * about the principal arriving -- the store scoped under the new key, its
18100
+ * active thread, the replay -- is what connecting goes on to do anyway, and
18101
+ * run here too it would read the old store before the new one exists,
18102
+ * minting a thread pointer in the namespace just purged and replaying the
18103
+ * history twice. Nor would it leave alone a store the host assigned while
18104
+ * the element was out.
17299
18105
  */
17300
18106
  #changePrincipal(previousKey, nextKey) {
18107
+ this.#principalKey = nextKey;
18108
+ const live = this.#connected;
17301
18109
  const previous = this.#storage.conversationNamespace(previousKey);
17302
18110
  const next = this.#storage.conversationNamespace(nextKey);
17303
18111
  if (previousKey === "") {
17304
18112
  SessionStorageStore.adopt(previous, next);
17305
- this.#rescopeStore(next);
18113
+ if (live) {
18114
+ this.#rescopeStore(next);
18115
+ }
17306
18116
  return;
17307
18117
  }
18118
+ this.#tenure = {};
17308
18119
  SessionStorageStore.purge(previous);
17309
- this.#rescopeStore(next);
18120
+ if (live) {
18121
+ this.#rescopeStore(next);
18122
+ }
17310
18123
  this.#dispatch.forgetWaivers();
17311
18124
  this.#cancelRun();
17312
18125
  this.#resetState();
17313
18126
  this.#sharedState = {};
18127
+ this.#input.value = "";
18128
+ this.#onInput();
17314
18129
  this.#setRunning(false);
17315
18130
  this.#setUnread(0);
18131
+ if (!live) {
18132
+ return;
18133
+ }
18134
+ this.#voice.dispose();
18135
+ this.#voice.wire();
17316
18136
  this.#history.adoptActiveThread();
17317
18137
  void this.#history.rehydrate();
17318
18138
  void this.#history.refreshDrawer();
@@ -17321,13 +18141,17 @@ var AgUiChat = class extends HTMLElement {
17321
18141
  * Rebuild the `sessionStorage` store under `namespace`, re-wrapping it for
17322
18142
  * `data-threads-url` exactly as connecting did.
17323
18143
  *
17324
- * A store of the host's own kind is left alone: a store that holds its data
17325
- * somewhere the element cannot see has to scope itself. The transcript on
18144
+ * A store the host assigned is left alone, whether before connecting or
18145
+ * since: a store that holds its data somewhere the element cannot see has to
18146
+ * scope itself. The exception is a plain `SessionStorageStore` assigned
18147
+ * before connecting, which connecting cannot tell from the default and so
18148
+ * took for the element's own. Hence the unwrapped store in use is what the scope is asked
18149
+ * about, rather than what it remembered when connecting. The transcript on
17326
18150
  * screen is still cleared either way — the host swapped principals, and that
17327
18151
  * much is the element's to act on.
17328
18152
  */
17329
18153
  #rescopeStore(namespace) {
17330
- const store = this.#storage.rescopeStore(namespace);
18154
+ const store = this.#storage.rescopeStore(this.#unwrappedStore(), namespace);
17331
18155
  if (store === null) {
17332
18156
  return;
17333
18157
  }
@@ -17450,8 +18274,17 @@ var AgUiChat = class extends HTMLElement {
17450
18274
  *
17451
18275
  * History is truncated to the most recent user message inclusive and the run
17452
18276
  * repeats, so the agent answers what it was asked rather than being told its
17453
- * last answer was wrong. Returns `false` when there is nothing to retry or a
17454
- * run is already in flight.
18277
+ * last answer was wrong. Returns `false` when there is nothing to retry, or
18278
+ * while anything that refuses a send is in flight: a run, a send or another
18279
+ * retry whose run has not started yet, a checkpoint continuation, or a
18280
+ * reload's restore that will resume a run. Also `false` when host code it
18281
+ * runs before its run starts -- the store's save, or an activity or tool
18282
+ * renderer the replay draws through -- has stopped it by starting a new chat
18283
+ * or changing `user-key`. A tool or context provider that stops it does so
18284
+ * inside the client's resume, past the last point this can see: nothing is
18285
+ * sent, and this resolves `true`, because both a run starting and a Stop let
18286
+ * go of the hold it checks. Rejects with the store's error when the store
18287
+ * refuses the save, and then the conversation is as it was.
17455
18288
  *
17456
18289
  * Public because a host with its own message UI wants the same button, and
17457
18290
  * because the failed-run notice reaches it from outside the action row.
@@ -17462,20 +18295,35 @@ var AgUiChat = class extends HTMLElement {
17462
18295
  * again -- unless the user waived it for this session.
17463
18296
  */
17464
18297
  async retryLastTurn() {
17465
- if (this.#running) {
17466
- return false;
17467
- }
17468
- const client = this.#ensureClient();
17469
- const kept = client.truncateToLastUser();
17470
- if (kept === null) {
18298
+ if (this.#running || this.#sending !== null || this.#history.continuation !== null) {
17471
18299
  return false;
17472
18300
  }
17473
- this.#clearTranscript();
17474
- for (const message of kept) {
17475
- this.#history.replay(message);
18301
+ const hold = {};
18302
+ this.#sending = hold;
18303
+ try {
18304
+ const client = this.#ensureClient();
18305
+ const kept = client.truncateToLastUser();
18306
+ if (kept === null) {
18307
+ return false;
18308
+ }
18309
+ if (this.#sending !== hold) {
18310
+ return false;
18311
+ }
18312
+ this.#clearTranscript();
18313
+ for (const message of kept) {
18314
+ this.#history.replay(message);
18315
+ if (this.#sending !== hold) {
18316
+ return false;
18317
+ }
18318
+ }
18319
+ await client.resume();
18320
+ return true;
18321
+ } finally {
18322
+ if (this.#sending === hold) {
18323
+ this.#sending = null;
18324
+ this.#flushQueued();
18325
+ }
17476
18326
  }
17477
- await client.resume();
17478
- return true;
17479
18327
  }
17480
18328
  /**
17481
18329
  * Append a message bubble and return it.
@@ -17787,6 +18635,9 @@ var AgUiChat = class extends HTMLElement {
17787
18635
  * which is what every shell and every coding agent means by this. Arrowing
17788
18636
  * forward past the newest empties the composer again rather than sticking on
17789
18637
  * it, so the way out is the same key that got you in.
18638
+ *
18639
+ * A walk ends with any write into the composer that is not its own, so that
18640
+ * whatever was written is never replaced by the next step.
17790
18641
  */
17791
18642
  #recallHistory(event) {
17792
18643
  const back = event.key === "ArrowUp";
@@ -17797,6 +18648,9 @@ var AgUiChat = class extends HTMLElement {
17797
18648
  if (drafts.length === 0) {
17798
18649
  return;
17799
18650
  }
18651
+ if (this.#input.value !== this.#recalled) {
18652
+ this.#recallIndex = null;
18653
+ }
17800
18654
  if (this.#recallIndex === null && (!back || this.#input.value !== "")) {
17801
18655
  return;
17802
18656
  }
@@ -17807,6 +18661,7 @@ var AgUiChat = class extends HTMLElement {
17807
18661
  event.preventDefault();
17808
18662
  this.#recallIndex = next < 0 ? null : next;
17809
18663
  this.#input.value = next < 0 ? "" : drafts[next];
18664
+ this.#recalled = this.#input.value;
17810
18665
  this.#input.setSelectionRange(this.#input.value.length, this.#input.value.length);
17811
18666
  autoGrow(this.#input);
17812
18667
  }
@@ -17817,15 +18672,11 @@ var AgUiChat = class extends HTMLElement {
17817
18672
  * observes the disconnect).
17818
18673
  */
17819
18674
  #cancelRun() {
17820
- for (const text4 of this.#queued) {
17821
- if (this.#sentDrafts[0] !== text4) {
17822
- this.#sentDrafts.unshift(text4);
17823
- }
17824
- }
17825
18675
  this.#queued.length = 0;
17826
18676
  this.#renderQueued();
17827
18677
  this.#decision.abort();
17828
18678
  this.#client?.cancel();
18679
+ this.#sending = null;
17829
18680
  this.#history.stopContinuation();
17830
18681
  }
17831
18682
  /**
@@ -17838,6 +18689,9 @@ var AgUiChat = class extends HTMLElement {
17838
18689
  #setRunning(running) {
17839
18690
  const settled = this.#running && !running;
17840
18691
  this.#running = running;
18692
+ if (running) {
18693
+ this.#sending = null;
18694
+ }
17841
18695
  const label = running ? this.#strings.stop : this.#strings.send;
17842
18696
  this.#send.title = label;
17843
18697
  this.#send.setAttribute("aria-label", label);
@@ -17888,13 +18742,29 @@ var AgUiChat = class extends HTMLElement {
17888
18742
  this.#queuedRow.appendChild(chip);
17889
18743
  }
17890
18744
  }
18745
+ /**
18746
+ * Put a turn that has left the composer at the front of the recall history,
18747
+ * and start the next walk from it.
18748
+ *
18749
+ * Every turn the user typed and pressed a key to send comes through here:
18750
+ * sent at once, queued behind a run, or sent to continue a checkpoint. A
18751
+ * host's own `sendMessage` does not, because its text was never in the
18752
+ * composer, and the arrow keys walk back through what the user wrote there.
18753
+ */
18754
+ #recordTurn(content) {
18755
+ if (content !== "" && this.#sentDrafts[0] !== content) {
18756
+ this.#sentDrafts.unshift(content);
18757
+ }
18758
+ this.#recallIndex = null;
18759
+ }
17891
18760
  async #submit() {
17892
18761
  const content = this.#input.value.trim();
17893
18762
  const attachments = this.#attachments.tray?.readyRefs() ?? [];
17894
18763
  if (content === "" && attachments.length === 0) {
17895
18764
  return;
17896
18765
  }
17897
- if (this.#running || this.#history.continuation !== null) {
18766
+ this.#recordTurn(content);
18767
+ if (this.#running || this.#sending !== null || this.#history.continuation !== null) {
17898
18768
  if (content !== "") {
17899
18769
  this.#queued.push(content);
17900
18770
  this.#renderQueued();
@@ -17903,10 +18773,6 @@ var AgUiChat = class extends HTMLElement {
17903
18773
  }
17904
18774
  return;
17905
18775
  }
17906
- if (content !== "" && this.#sentDrafts[0] !== content) {
17907
- this.#sentDrafts.unshift(content);
17908
- }
17909
- this.#recallIndex = null;
17910
18776
  this.#input.value = "";
17911
18777
  autoGrow(this.#input);
17912
18778
  if (this.#attachments.tray?.hasPending() === true) {
@@ -17934,17 +18800,49 @@ var AgUiChat = class extends HTMLElement {
17934
18800
  *
17935
18801
  * No-ops on an empty message, and while a run or a picked checkpoint's
17936
18802
  * continuation is in flight, since a second concurrent run would orphan the
17937
- * first. Unlike the built-in Send it does not queue: it returns, and the
17938
- * caller keeps what it tried to send. Nor does it consult the tray -- what
17939
- * you pass is what is sent.
18803
+ * first. A send is in flight from the moment it is taken rather than from
18804
+ * its run's start, so this no-ops from a {@link SUBMIT_EVENT} listener and
18805
+ * for a second call in the same task too.
18806
+ * Unlike the built-in Send it does not queue: it returns, and the caller
18807
+ * keeps what it tried to send. Nor does it consult the tray -- what you pass
18808
+ * is what is sent.
17940
18809
  */
17941
18810
  async sendMessage(content, attachments = []) {
17942
- if (this.#running || this.#history.continuation !== null || content === "" && attachments.length === 0) {
18811
+ if (this.#running || this.#sending !== null || this.#history.continuation !== null || content === "" && attachments.length === 0) {
17943
18812
  return;
17944
18813
  }
17945
- if (this.#transcript.isEmpty()) {
17946
- this.setAttribute("data-composer-settling", "");
18814
+ const send = {};
18815
+ this.#sending = send;
18816
+ try {
18817
+ if (this.#transcript.isEmpty()) {
18818
+ this.setAttribute("data-composer-settling", "");
18819
+ }
18820
+ this.#announceTurn(content, attachments);
18821
+ if (this.#sending !== send) {
18822
+ return;
18823
+ }
18824
+ await this.#client_send(content, attachments);
18825
+ } finally {
18826
+ if (this.#sending === send) {
18827
+ this.#sending = null;
18828
+ this.#flushQueued();
18829
+ }
17947
18830
  }
18831
+ }
18832
+ /**
18833
+ * Put a turn the user sent on screen, and tell the host it was sent.
18834
+ *
18835
+ * The half of a send that does not depend on where it goes, so both senders
18836
+ * take it from here: {@link sendMessage}, and a checkpoint continuation, which
18837
+ * posts to the resume or fork endpoint on a client of its own. The
18838
+ * continuation used to call that client directly, so the turn went out and
18839
+ * its answer streamed in under no question -- while the save it made held the
18840
+ * turn, and a reload showed what the live transcript never had.
18841
+ *
18842
+ * Arming the composer's travel stays with {@link sendMessage}: continuing a
18843
+ * run is a change of context, and docks at once.
18844
+ */
18845
+ #announceTurn(content, attachments) {
17948
18846
  const bubble = this.appendMessage(MESSAGE_ROLE.USER, content);
17949
18847
  if (attachments.length > 0) {
17950
18848
  bubble.appendChild(renderAttachmentChips(attachments));
@@ -17956,7 +18854,6 @@ var AgUiChat = class extends HTMLElement {
17956
18854
  composed: true
17957
18855
  })
17958
18856
  );
17959
- await this.#client_send(content, attachments);
17960
18857
  }
17961
18858
  /**
17962
18859
  * Queue a file for upload into the attachment tray, exactly as the file
@@ -18030,6 +18927,7 @@ var AgUiChat = class extends HTMLElement {
18030
18927
  */
18031
18928
  #buildClient(seed) {
18032
18929
  const threadId = this.#history.threadId;
18930
+ const tenure = this.#tenure;
18033
18931
  const agent = this.agentFactory({
18034
18932
  endpoint: seed.endpoint,
18035
18933
  headers: this.#requestHeaders(),
@@ -18054,12 +18952,30 @@ var AgUiChat = class extends HTMLElement {
18054
18952
  // list per thread. For the conversation's own client that is its
18055
18953
  // history; a continuation holds only what it adds, and writes the
18056
18954
  // conversation it continues ahead of that.
18955
+ //
18956
+ // Every message list a client saves reaches the store through here -- a
18957
+ // send, a round's end, a tool's result, the answers it writes for calls
18958
+ // left open or declined by a Stop, a Stop's last save -- and so does a
18959
+ // `data-threads-url` store's local copy, which is the only thing that
18960
+ // wrapper does on a save. So this is the one gate for them. `onSaved` is
18961
+ // behind it as well: it hands the saved conversation on as the seed of
18962
+ // the next client, which would be the next principal's.
18057
18963
  onPersist: (messages) => {
18964
+ if (tenure !== this.#tenure) {
18965
+ return;
18966
+ }
18058
18967
  const conversation = [...seed.follows, ...messages];
18059
18968
  this.conversationStore.saveMessages(threadId, conversation);
18060
18969
  seed.onSaved?.(conversation);
18061
18970
  },
18062
- onStateChanged: (state) => this.#onSharedStateChanged(state),
18971
+ // Shared state is the next principal's first `RunAgentInput.state`, and
18972
+ // the handover has just emptied it. A snapshot already read off the wire
18973
+ // is applied after the Stop, and would put it back.
18974
+ onStateChanged: (state) => {
18975
+ if (tenure === this.#tenure) {
18976
+ this.#onSharedStateChanged(state);
18977
+ }
18978
+ },
18063
18979
  connectionLostMessage: this.#strings.connectionLost,
18064
18980
  unfinishedMessage: this.#strings.callNotFinished,
18065
18981
  declinedMessage: this.#strings.declinedAction,
@@ -18221,7 +19137,7 @@ function setControlValue(el2, value) {
18221
19137
  }
18222
19138
 
18223
19139
  // src/version.ts
18224
- var VERSION = "0.41.2";
19140
+ var VERSION = "0.42.0";
18225
19141
  export {
18226
19142
  ATTACHMENT_EVENT,
18227
19143
  AgUiChat,
@@ -18319,6 +19235,7 @@ export {
18319
19235
  /*! Bundled license information:
18320
19236
 
18321
19237
  dompurify/dist/purify.es.mjs:
18322
- (*! @license DOMPurify 3.4.15 | (c) Cure53 and other contributors | Released under the Apache license 2.0 and Mozilla Public License 2.0 | github.com/cure53/DOMPurify/blob/3.4.15/LICENSE *)
19238
+ (*! @license DOMPurify 3.4.16 | (c) Cure53 and other contributors | Released under the Apache license 2.0 and Mozilla Public License 2.0 | github.com/cure53/DOMPurify/blob/3.4.16/LICENSE *)
19239
+ (*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/babel/babel/blob/main/packages/babel-helpers/LICENSE *)
18323
19240
  */
18324
19241
  //# sourceMappingURL=index.js.map