@ai-ecoverse/slicc-spectrum 1.94.2 → 1.95.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.
@@ -6,7 +6,7 @@ import {
6
6
  DummySettings,
7
7
  clock,
8
8
  dummySettingsKey
9
- } from "./chunk-2R4DLSKG.js";
9
+ } from "./chunk-QGY4KBEB.js";
10
10
  import {
11
11
  Emitter
12
12
  } from "./chunk-T5NHW4KC.js";
package/dist/slicc-ui.js CHANGED
@@ -49643,7 +49643,8 @@ var accountStatus = {
49643
49643
  "signing-in": ["info", "Signing in\u2026"],
49644
49644
  rejected: ["notice", "Rejected"],
49645
49645
  "needs-sign-in": ["neutral", "Needs sign-in"],
49646
- "sign-in-expired": ["notice", "Sign-in expired"]
49646
+ "sign-in-expired": ["notice", "Sign-in expired"],
49647
+ unreachable: ["notice", "Unreachable"]
49647
49648
  };
49648
49649
  var authHints = {
49649
49650
  "api-key": "API key",
@@ -49677,6 +49678,7 @@ function draft(option2) {
49677
49678
  fields: option2.fields,
49678
49679
  keyUrl: option2.keyUrl,
49679
49680
  needs: option2.needs,
49681
+ blocked: option2.blocked,
49680
49682
  vaultName: option2.vaultName
49681
49683
  };
49682
49684
  }
@@ -49716,6 +49718,7 @@ var SliccSettings = class extends ThemedElement {
49716
49718
  };
49717
49719
  #waits = new SignInWaits(() => this.requestUpdate());
49718
49720
  #landing = null;
49721
+ #away = false;
49719
49722
  #bases = /* @__PURE__ */ new Map();
49720
49723
  #scroll = new ViewScroll(this, "settings:scroll", { scroller: () => this, rows: "[data-id]" });
49721
49724
  constructor() {
@@ -49954,6 +49957,10 @@ var SliccSettings = class extends ThemedElement {
49954
49957
  .option[aria-disabled='true'] .name {
49955
49958
  color: var(--swc-neutral-subdued-content-color-default);
49956
49959
  }
49960
+ .option[data-blocked] .name,
49961
+ .option[data-blocked] .description {
49962
+ color: var(--swc-disabled-content-color);
49963
+ }
49957
49964
  .option .tag {
49958
49965
  justify-self: end;
49959
49966
  color: var(--swc-neutral-subdued-content-color-default);
@@ -50261,6 +50268,7 @@ var SliccSettings = class extends ThemedElement {
50261
50268
  }
50262
50269
  #submit(event2, account) {
50263
50270
  event2.preventDefault();
50271
+ if (account.blocked) return;
50264
50272
  const form = event2.currentTarget;
50265
50273
  this.problem = null;
50266
50274
  this.filled = new Set([...this.filled].filter((name) => name !== "value"));
@@ -50369,6 +50377,7 @@ var SliccSettings = class extends ThemedElement {
50369
50377
  return this.adding?.id === account.id ? "Connect" : "Save";
50370
50378
  }
50371
50379
  #ready(account) {
50380
+ if (account.blocked) return false;
50372
50381
  if (!this.#offered()) return true;
50373
50382
  const required = (account.fields ?? []).filter((field) => field.required && !field.options);
50374
50383
  return ["value", ...required.map((field) => field.name)].every((name) => this.filled.has(name));
@@ -50533,12 +50542,13 @@ var SliccSettings = class extends ThemedElement {
50533
50542
  data-action="connect"
50534
50543
  accessible-label=${popup(account) ? `Sign in to ${account.provider}` : `${label} ${account.provider}`}
50535
50544
  ?pending=${busy}
50536
- ?disabled=${entering}
50545
+ ?disabled=${entering || !!account.blocked}
50537
50546
  @click=${() => this.#start(account)}
50538
50547
  >${label}</swc-button>`;
50539
50548
  }
50540
50549
  #status(account) {
50541
50550
  if (this.#signingIn(account)) return "signing-in";
50551
+ if (account.status === "connected" && account.blocked) return "unreachable";
50542
50552
  if (account.status === "expired" && account.auth === "api-key") return "rejected";
50543
50553
  if (popup(account) && account.status === "disconnected") return "needs-sign-in";
50544
50554
  if (popup(account) && account.status === "expired") return "sign-in-expired";
@@ -50578,6 +50588,14 @@ var SliccSettings = class extends ThemedElement {
50578
50588
  ><swc-icon-delete slot="icon"></swc-icon-delete></swc-action-button
50579
50589
  ><swc-tooltip for=${id} placement="top">${label}</swc-tooltip>`;
50580
50590
  }
50591
+ async #closeTip(id) {
50592
+ const tip = this.renderRoot.querySelector(
50593
+ `swc-tooltip[for="${CSS.escape(id)}"]`
50594
+ );
50595
+ if (!tip) return;
50596
+ tip.open = false;
50597
+ await tip.updateComplete;
50598
+ }
50581
50599
  async #remove(account) {
50582
50600
  const model = this.model;
50583
50601
  const body4 = removeBodies[account.auth ?? ""] ?? "Its key is deleted from the vault. Models from it stop working.";
@@ -50590,6 +50608,7 @@ var SliccSettings = class extends ThemedElement {
50590
50608
  const keyed = account.store === "vault" && account.auth === "api-key" && !!vault?.remove;
50591
50609
  if (keyed && !await this.#forget(account, vault)) return;
50592
50610
  if (this.model !== model) return;
50611
+ await this.#closeTip(`remove-${account.id}`);
50593
50612
  this.#busy(account.id, true);
50594
50613
  this.failure = null;
50595
50614
  try {
@@ -50603,9 +50622,25 @@ var SliccSettings = class extends ThemedElement {
50603
50622
  this.focusOn("[data-action=add-provider]");
50604
50623
  for (const field of account.fields ?? []) this.#bases.delete(`${account.id} ${field.name}`);
50605
50624
  }
50606
- #notice(needs, size4 = "long") {
50625
+ #notice(row, size4 = "long") {
50626
+ const needs = row.blocked;
50607
50627
  if (needs !== "cors-free-transport") return A;
50608
- return b`<p class="notice" data-notice=${needs}><swc-icon-alert-triangle size="s" aria-hidden="true"></swc-icon-alert-triangle><span>${corsNotice[size4]}</span></p>`;
50628
+ return b`<p class="notice" data-notice=${needs} data-blocked><swc-icon-alert-triangle size="s" aria-hidden="true"></swc-icon-alert-triangle><span>${corsNotice[size4]} <a class="swc-Link" href="#network" data-action="setup-network" aria-label="Set up the SLICC extension or CLI" @click=${(event2) => this.#setUp(event2)}>Set up</a></span></p>`;
50629
+ }
50630
+ #setUp(event2) {
50631
+ event2.preventDefault();
50632
+ event2.stopPropagation();
50633
+ if (this.picking) {
50634
+ this.#away = true;
50635
+ this.#closePicker();
50636
+ }
50637
+ this.dispatchEvent(
50638
+ new CustomEvent("show-surface", {
50639
+ detail: { id: "network", section: "whole" },
50640
+ bubbles: true,
50641
+ composed: true
50642
+ })
50643
+ );
50609
50644
  }
50610
50645
  #signingNote(account) {
50611
50646
  const key2 = `settings:${account.id}`;
@@ -50616,7 +50651,7 @@ var SliccSettings = class extends ThemedElement {
50616
50651
  return b`<p class="hint" role="status" data-signing>${signInText(this.#waits.waited(key2))}</p>`;
50617
50652
  }
50618
50653
  #rowNotes(account) {
50619
- const notice = this.#notice(account.needs);
50654
+ const notice = this.#notice(account);
50620
50655
  const signing = this.adding?.id === account.id ? A : this.#signingNote(account);
50621
50656
  if (notice === A && signing === A) return A;
50622
50657
  return b`<div class="notes">${notice}${signing}</div>`;
@@ -50653,6 +50688,9 @@ var SliccSettings = class extends ThemedElement {
50653
50688
  this.query = "";
50654
50689
  const landing = this.#landing;
50655
50690
  this.#landing = null;
50691
+ const away2 = this.#away;
50692
+ this.#away = false;
50693
+ if (away2) return;
50656
50694
  void this.updateComplete.then(() => {
50657
50695
  const root2 = this.renderRoot;
50658
50696
  const row = landing ? root2.querySelector(`.account[data-id="${CSS.escape(landing)}"] swc-button`) : null;
@@ -50664,7 +50702,7 @@ var SliccSettings = class extends ThemedElement {
50664
50702
  this.#closePicker();
50665
50703
  }
50666
50704
  #choose(option2) {
50667
- if (this.#added(option2.id)) return;
50705
+ if (option2.blocked || this.#added(option2.id)) return;
50668
50706
  this.adding = option2;
50669
50707
  this.failure = null;
50670
50708
  if (option2.auth === "api-key" || option2.auth === "fields") {
@@ -50703,11 +50741,13 @@ var SliccSettings = class extends ThemedElement {
50703
50741
  if (event2.key !== "Enter") return;
50704
50742
  event2.preventDefault();
50705
50743
  const first2 = matchProviders(this.#offered() ?? [], this.query).find(
50706
- (option2) => !this.#added(option2.id)
50744
+ (option2) => !option2.blocked && !this.#added(option2.id)
50707
50745
  );
50708
50746
  if (first2) this.#choose(first2);
50709
50747
  }
50710
50748
  #optionKey(event2, option2) {
50749
+ const inner = event2.target !== event2.currentTarget;
50750
+ if (inner && (event2.key === "Enter" || event2.key === " ")) return;
50711
50751
  const options2 = this.#options();
50712
50752
  const at = options2.indexOf(event2.currentTarget);
50713
50753
  const moves = {
@@ -50736,14 +50776,15 @@ var SliccSettings = class extends ThemedElement {
50736
50776
  tabindex="-1"
50737
50777
  data-provider=${option2.id}
50738
50778
  data-auth=${option2.auth}
50739
- aria-disabled=${added ? "true" : "false"}
50779
+ ?data-blocked=${!!option2.blocked}
50780
+ aria-disabled=${added || option2.blocked ? "true" : "false"}
50740
50781
  @click=${() => this.#choose(option2)}
50741
50782
  @keydown=${(event2) => this.#optionKey(event2, option2)}
50742
50783
  >
50743
50784
  <span class="name">${option2.name}</span>
50744
50785
  <span class="tag">${added ? b`<span class="added" data-added><swc-icon-checkmark size="s" aria-hidden="true"></swc-icon-checkmark>Added</span>` : authHints[option2.auth]}</span>
50745
50786
  ${option2.description ? b`<span class="description">${option2.description}</span>` : A}
50746
- ${this.#notice(option2.needs, "short")}
50787
+ ${this.#notice(option2, "short")}
50747
50788
  </div>`;
50748
50789
  }
50749
50790
  #pickStep(offered) {
@@ -50768,23 +50809,24 @@ var SliccSettings = class extends ThemedElement {
50768
50809
  ${signing ? this.#signingNote(account) : A}
50769
50810
  <div class="buttons">
50770
50811
  ${cancel ? b`<swc-button size="m" variant="secondary" data-action="cancel-sign-in" @click=${() => this.#stopSigningIn(account)}>Cancel</swc-button>` : A}
50771
- <swc-button size="m" variant="accent" data-action="sign-in" ?pending=${signing} @click=${() => this.connect(account.id)}>${signing ? "Signing in\u2026" : "Sign in"}</swc-button>
50812
+ <swc-button size="m" variant="accent" data-action="sign-in" ?pending=${signing} ?disabled=${!!account.blocked} @click=${() => this.connect(account.id)}>${signing ? "Signing in\u2026" : "Sign in"}</swc-button>
50772
50813
  ${signing ? A : this.#leave(account)}
50773
50814
  </div>`;
50774
50815
  }
50775
50816
  #localStep(account) {
50776
50817
  return b`<p class="hint">SLICC connects to ${account.provider} on this device.</p>
50777
50818
  <div class="buttons">
50778
- <swc-button size="m" variant="accent" data-action="connect" ?pending=${this.pending.has(account.id)} @click=${() => this.connect(account.id)}>Connect</swc-button>
50819
+ <swc-button size="m" variant="accent" data-action="connect" ?pending=${this.pending.has(account.id)} ?disabled=${!!account.blocked} @click=${() => this.connect(account.id)}>Connect</swc-button>
50779
50820
  ${this.#leave(account)}
50780
50821
  </div>`;
50781
50822
  }
50782
- #connectStep(option2) {
50823
+ #connectStep(adding) {
50824
+ const option2 = this.#offered()?.find((candidate) => candidate.id === adding.id) ?? adding;
50783
50825
  const account = this.#added(option2.id) ?? draft(option2);
50784
50826
  const step = option2.auth === "oauth" ? this.#signInStep(account) : option2.auth === "local" ? this.#localStep(account) : this.#key(account);
50785
50827
  return b`<div class="step" data-step=${option2.auth} data-provider=${option2.id}>
50786
50828
  ${option2.description ? b`<p class="lead">${option2.description}</p>` : A}
50787
- ${this.#notice(option2.needs)}
50829
+ ${this.#notice(option2)}
50788
50830
  ${step}
50789
50831
  ${this.failure?.id === option2.id ? b`<div class="failure" role="alert"><swc-icon-alert-triangle size="s" aria-hidden="true"></swc-icon-alert-triangle><span>${this.failure.message}</span></div>` : A}
50790
50832
  </div>`;