nextclaw 0.16.11 → 0.16.13

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.
Files changed (28) hide show
  1. package/dist/cli/index.js +149 -92
  2. package/package.json +8 -8
  3. package/ui-dist/assets/{ChannelsList-dsxeZk5v.js → ChannelsList-XGMfinnc.js} +1 -1
  4. package/ui-dist/assets/ChatPage-DYTcCRPp.js +37 -0
  5. package/ui-dist/assets/{DocBrowser-B9RfxWIh.js → DocBrowser-DTRCNsSM.js} +1 -1
  6. package/ui-dist/assets/{LogoBadge-iVDzhkNu.js → LogoBadge-CPMOwWdA.js} +1 -1
  7. package/ui-dist/assets/{MarketplacePage-4MZIcD0K.js → MarketplacePage-De2qZ9C0.js} +1 -1
  8. package/ui-dist/assets/{McpMarketplacePage-cwLMty-D.js → McpMarketplacePage-cjVKSQ2f.js} +1 -1
  9. package/ui-dist/assets/{ModelConfig-CNICBWzw.js → ModelConfig-CMn3-VZk.js} +1 -1
  10. package/ui-dist/assets/{ProvidersList-CEHGsRSL.js → ProvidersList-CArDOswN.js} +1 -1
  11. package/ui-dist/assets/{RemoteAccessPage-uYxoaQ8V.js → RemoteAccessPage-C0I4tHey.js} +1 -1
  12. package/ui-dist/assets/{RuntimeConfig-CYQq4S_m.js → RuntimeConfig-B4o6uJq9.js} +1 -1
  13. package/ui-dist/assets/{SearchConfig-CaFAgBMN.js → SearchConfig-a38m8Ynx.js} +1 -1
  14. package/ui-dist/assets/{SecretsConfig-DzWq8hGZ.js → SecretsConfig-B6mf4JY9.js} +1 -1
  15. package/ui-dist/assets/{SessionsConfig-CJJTcxyQ.js → SessionsConfig-B_WQ1lVd.js} +1 -1
  16. package/ui-dist/assets/{index-BlrweCCh.js → index-D-wEIgPn.js} +2 -2
  17. package/ui-dist/assets/{label-DtssWSI4.js → label-usOOP7mv.js} +1 -1
  18. package/ui-dist/assets/{ncp-session-adapter-C-jqQqcV.js → ncp-session-adapter-DSacECph.js} +1 -1
  19. package/ui-dist/assets/{page-layout-DnRqSldv.js → page-layout-CuIf20mx.js} +1 -1
  20. package/ui-dist/assets/{popover-Un2VFGcS.js → popover-CTtTCP5d.js} +1 -1
  21. package/ui-dist/assets/{security-config-B7Bkebpm.js → security-config-Bxrrv8Ac.js} +1 -1
  22. package/ui-dist/assets/{skeleton-DTFzTqqO.js → skeleton-BNUaFYE7.js} +1 -1
  23. package/ui-dist/assets/{status-dot-DOJX6vii.js → status-dot-BeHTBy9k.js} +1 -1
  24. package/ui-dist/assets/{switch-utBdpBRv.js → switch-CtNnWZpa.js} +1 -1
  25. package/ui-dist/assets/{tabs-custom-ExyfvfgG.js → tabs-custom-Dz_4tV62.js} +1 -1
  26. package/ui-dist/assets/{useConfirmDialog-DjNtKs4n.js → useConfirmDialog-C_n_JIEq.js} +1 -1
  27. package/ui-dist/index.html +1 -1
  28. package/ui-dist/assets/ChatPage-CWK4Bckz.js +0 -37
package/dist/cli/index.js CHANGED
@@ -452,6 +452,49 @@ function isRecord(value) {
452
452
  return typeof value === "object" && value !== null && !Array.isArray(value);
453
453
  }
454
454
 
455
+ // src/cli/skills/marketplace-network-retry.ts
456
+ var MARKETPLACE_NETWORK_RETRY_ATTEMPTS = 5;
457
+ var MARKETPLACE_NETWORK_RETRY_BASE_MS = 350;
458
+ function sleepMs(ms) {
459
+ return new Promise((resolve15) => {
460
+ setTimeout(resolve15, ms);
461
+ });
462
+ }
463
+ function isRetryableMarketplaceNetworkError(error) {
464
+ if (!(error instanceof Error)) {
465
+ return false;
466
+ }
467
+ if (error.name === "AbortError") {
468
+ return false;
469
+ }
470
+ const cause = error.cause;
471
+ if (cause && typeof cause === "object" && cause !== null && "code" in cause) {
472
+ const code = cause.code;
473
+ if (code === "ECONNRESET" || code === "ECONNREFUSED" || code === "ETIMEDOUT" || code === "EPIPE" || code === "ENOTFOUND" || code === "EAI_AGAIN") {
474
+ return true;
475
+ }
476
+ }
477
+ if (error instanceof TypeError && error.message === "fetch failed") {
478
+ return true;
479
+ }
480
+ return false;
481
+ }
482
+ async function runWithMarketplaceNetworkRetry(action) {
483
+ let last;
484
+ for (let attempt = 1; attempt <= MARKETPLACE_NETWORK_RETRY_ATTEMPTS; attempt++) {
485
+ try {
486
+ return await action();
487
+ } catch (error) {
488
+ last = error;
489
+ if (attempt === MARKETPLACE_NETWORK_RETRY_ATTEMPTS || !isRetryableMarketplaceNetworkError(error)) {
490
+ throw error;
491
+ }
492
+ await sleepMs(MARKETPLACE_NETWORK_RETRY_BASE_MS * 2 ** (attempt - 1));
493
+ }
494
+ }
495
+ throw last;
496
+ }
497
+
455
498
  // src/cli/skills/marketplace.ts
456
499
  var DEFAULT_MARKETPLACE_API_BASE = "https://marketplace-api.nextclaw.io";
457
500
  async function installMarketplaceSkill(options) {
@@ -594,28 +637,30 @@ async function publishMarketplaceSkill(options) {
594
637
  if (options.requireExisting) {
595
638
  await fetchMarketplaceSkillItem(apiBase, slug);
596
639
  }
597
- const response = await fetch(`${apiBase}/api/v1/admin/skills/upsert`, {
598
- method: "POST",
599
- headers: {
600
- "content-type": "application/json",
601
- ...token ? { Authorization: `Bearer ${token}` } : {}
602
- },
603
- body: JSON.stringify({
604
- slug,
605
- name,
606
- summary,
607
- summaryI18n,
608
- description,
609
- descriptionI18n,
610
- author,
611
- tags,
612
- sourceRepo: options.sourceRepo?.trim() || metadata.sourceRepo,
613
- homepage: options.homepage?.trim() || metadata.homepage,
614
- publishedAt: options.publishedAt?.trim() || metadata.publishedAt,
615
- updatedAt: options.updatedAt?.trim() || metadata.updatedAt,
616
- files
640
+ const response = await runWithMarketplaceNetworkRetry(
641
+ () => fetch(`${apiBase}/api/v1/admin/skills/upsert`, {
642
+ method: "POST",
643
+ headers: {
644
+ "content-type": "application/json",
645
+ ...token ? { Authorization: `Bearer ${token}` } : {}
646
+ },
647
+ body: JSON.stringify({
648
+ slug,
649
+ name,
650
+ summary,
651
+ summaryI18n,
652
+ description,
653
+ descriptionI18n,
654
+ author,
655
+ tags,
656
+ sourceRepo: options.sourceRepo?.trim() || metadata.sourceRepo,
657
+ homepage: options.homepage?.trim() || metadata.homepage,
658
+ publishedAt: options.publishedAt?.trim() || metadata.publishedAt,
659
+ updatedAt: options.updatedAt?.trim() || metadata.updatedAt,
660
+ files
661
+ })
617
662
  })
618
- });
663
+ );
619
664
  const payload = await readMarketplaceEnvelope(response);
620
665
  if (!payload.ok || !payload.data) {
621
666
  const message = payload.error?.message || `marketplace publish failed: HTTP ${response.status}`;
@@ -660,70 +705,76 @@ function installBuiltinSkill(workdir, destinationDir, skillName) {
660
705
  cpSync(dirname(builtin.path), destinationDir, { recursive: true, force: true });
661
706
  }
662
707
  async function fetchMarketplaceSkillItem(apiBase, slug) {
663
- const response = await fetch(`${apiBase}/api/v1/skills/items/${encodeURIComponent(slug)}`, {
664
- headers: {
665
- Accept: "application/json"
708
+ return runWithMarketplaceNetworkRetry(async () => {
709
+ const response = await fetch(`${apiBase}/api/v1/skills/items/${encodeURIComponent(slug)}`, {
710
+ headers: {
711
+ Accept: "application/json"
712
+ }
713
+ });
714
+ const payload = await readMarketplaceEnvelope(response);
715
+ if (!payload.ok || !payload.data) {
716
+ const message = payload.error?.message || `marketplace skill fetch failed: ${response.status}`;
717
+ throw new Error(message);
666
718
  }
667
- });
668
- const payload = await readMarketplaceEnvelope(response);
669
- if (!payload.ok || !payload.data) {
670
- const message = payload.error?.message || `marketplace skill fetch failed: ${response.status}`;
671
- throw new Error(message);
672
- }
673
- const kind = payload.data.install?.kind;
674
- if (kind !== "builtin" && kind !== "marketplace") {
675
- throw new Error(`Unsupported skill install kind from marketplace: ${String(kind)}`);
676
- }
677
- return {
678
- install: {
679
- kind
719
+ const kind = payload.data.install?.kind;
720
+ if (kind !== "builtin" && kind !== "marketplace") {
721
+ throw new Error(`Unsupported skill install kind from marketplace: ${String(kind)}`);
680
722
  }
681
- };
723
+ return {
724
+ install: {
725
+ kind
726
+ }
727
+ };
728
+ });
682
729
  }
683
730
  async function fetchMarketplaceSkillFiles(apiBase, slug) {
684
- const response = await fetch(`${apiBase}/api/v1/skills/items/${encodeURIComponent(slug)}/files`, {
685
- headers: {
686
- Accept: "application/json"
687
- }
688
- });
689
- const payload = await readMarketplaceEnvelope(response);
690
- if (!payload.ok || !payload.data) {
691
- const message = payload.error?.message || `marketplace skill file fetch failed: ${response.status}`;
692
- throw new Error(message);
693
- }
694
- if (!isRecord2(payload.data) || !Array.isArray(payload.data.files)) {
695
- throw new Error("Invalid marketplace skill file manifest response");
696
- }
697
- const files = payload.data.files.map((entry, index) => {
698
- if (!isRecord2(entry) || typeof entry.path !== "string" || entry.path.trim().length === 0) {
699
- throw new Error(`Invalid marketplace skill file manifest at index ${index}`);
700
- }
701
- const normalized = {
702
- path: entry.path.trim()
703
- };
704
- if (typeof entry.downloadPath === "string" && entry.downloadPath.trim().length > 0) {
705
- normalized.downloadPath = entry.downloadPath.trim();
731
+ return runWithMarketplaceNetworkRetry(async () => {
732
+ const response = await fetch(`${apiBase}/api/v1/skills/items/${encodeURIComponent(slug)}/files`, {
733
+ headers: {
734
+ Accept: "application/json"
735
+ }
736
+ });
737
+ const payload = await readMarketplaceEnvelope(response);
738
+ if (!payload.ok || !payload.data) {
739
+ const message = payload.error?.message || `marketplace skill file fetch failed: ${response.status}`;
740
+ throw new Error(message);
706
741
  }
707
- if (typeof entry.contentBase64 === "string" && entry.contentBase64.trim().length > 0) {
708
- normalized.contentBase64 = entry.contentBase64.trim();
742
+ if (!isRecord2(payload.data) || !Array.isArray(payload.data.files)) {
743
+ throw new Error("Invalid marketplace skill file manifest response");
709
744
  }
710
- return normalized;
745
+ const files = payload.data.files.map((entry, index) => {
746
+ if (!isRecord2(entry) || typeof entry.path !== "string" || entry.path.trim().length === 0) {
747
+ throw new Error(`Invalid marketplace skill file manifest at index ${index}`);
748
+ }
749
+ const normalized = {
750
+ path: entry.path.trim()
751
+ };
752
+ if (typeof entry.downloadPath === "string" && entry.downloadPath.trim().length > 0) {
753
+ normalized.downloadPath = entry.downloadPath.trim();
754
+ }
755
+ if (typeof entry.contentBase64 === "string" && entry.contentBase64.trim().length > 0) {
756
+ normalized.contentBase64 = entry.contentBase64.trim();
757
+ }
758
+ return normalized;
759
+ });
760
+ return { files };
711
761
  });
712
- return { files };
713
762
  }
714
763
  async function fetchMarketplaceSkillFileBlob(apiBase, slug, file) {
715
764
  const downloadUrl = resolveSkillFileDownloadUrl(apiBase, slug, file);
716
- const response = await fetch(downloadUrl, {
717
- headers: {
718
- Accept: "application/octet-stream"
765
+ return runWithMarketplaceNetworkRetry(async () => {
766
+ const response = await fetch(downloadUrl, {
767
+ headers: {
768
+ Accept: "application/octet-stream"
769
+ }
770
+ });
771
+ if (!response.ok) {
772
+ const message = await tryReadMarketplaceError(response);
773
+ throw new Error(message || `marketplace skill file download failed: ${response.status}`);
719
774
  }
775
+ const arrayBuffer = await response.arrayBuffer();
776
+ return Buffer.from(arrayBuffer);
720
777
  });
721
- if (!response.ok) {
722
- const message = await tryReadMarketplaceError(response);
723
- throw new Error(message || `marketplace skill file download failed: ${response.status}`);
724
- }
725
- const arrayBuffer = await response.arrayBuffer();
726
- return Buffer.from(arrayBuffer);
727
778
  }
728
779
  function decodeMarketplaceFileContent(path2, contentBase64) {
729
780
  const normalized = contentBase64.replace(/\s+/g, "");
@@ -6142,6 +6193,7 @@ var NextclawAgentSessionStore = class {
6142
6193
  session.updatedAt = new Date(ensureIsoTimestamp(sessionRecord.updatedAt, (/* @__PURE__ */ new Date()).toISOString()));
6143
6194
  }
6144
6195
  this.sessionManager.save(session);
6196
+ this.options.onSessionUpdated?.(sessionRecord.sessionId);
6145
6197
  }
6146
6198
  async deleteSession(sessionId) {
6147
6199
  const existing = await this.getSession(sessionId);
@@ -6149,6 +6201,7 @@ var NextclawAgentSessionStore = class {
6149
6201
  return null;
6150
6202
  }
6151
6203
  this.sessionManager.delete(sessionId);
6204
+ this.options.onSessionUpdated?.(sessionId);
6152
6205
  return existing;
6153
6206
  }
6154
6207
  };
@@ -6552,7 +6605,9 @@ function createUiNcpAgentHandle(params) {
6552
6605
  };
6553
6606
  }
6554
6607
  async function createUiNcpAgent(params) {
6555
- const sessionStore = new NextclawAgentSessionStore(params.sessionManager);
6608
+ const sessionStore = new NextclawAgentSessionStore(params.sessionManager, {
6609
+ onSessionUpdated: params.onSessionUpdated
6610
+ });
6556
6611
  const runtimeRegistry = new UiNcpRuntimeRegistry();
6557
6612
  const { toolRegistryAdapter, applyMcpConfig } = await createMcpRuntimeSupport(params.getConfig);
6558
6613
  const assetStore = new LocalAssetStore({
@@ -6620,8 +6675,10 @@ function buildUpdatedMetadata(params) {
6620
6675
  }
6621
6676
  var UiSessionService = class {
6622
6677
  sessionStore;
6623
- constructor(sessionManager) {
6624
- this.sessionStore = new NextclawAgentSessionStore(sessionManager);
6678
+ constructor(sessionManager, options = {}) {
6679
+ this.sessionStore = new NextclawAgentSessionStore(sessionManager, {
6680
+ onSessionUpdated: options.onSessionUpdated
6681
+ });
6625
6682
  }
6626
6683
  async listSessions(options) {
6627
6684
  const sessions = await this.sessionStore.listSessions();
@@ -7943,6 +8000,14 @@ function createDeferredUiNcpAgent(basePath = DEFAULT_BASE_PATH) {
7943
8000
  }
7944
8001
 
7945
8002
  // src/cli/commands/service-gateway-startup.ts
8003
+ function wireSystemSessionUpdatedPublisher(params) {
8004
+ params.runtimePool.setSystemSessionUpdatedHandler(({ sessionKey }) => {
8005
+ params.publishUiEvent?.({
8006
+ type: "session.updated",
8007
+ payload: { sessionKey }
8008
+ });
8009
+ });
8010
+ }
7946
8011
  async function startUiShell(params) {
7947
8012
  logStartupTrace("service.start_ui_shell.begin");
7948
8013
  if (!params.uiConfig.enabled) {
@@ -8000,6 +8065,7 @@ async function startDeferredGatewayStartup(params) {
8000
8065
  gatewayController: params.gatewayController,
8001
8066
  getConfig: params.getConfig,
8002
8067
  getExtensionRegistry: params.getExtensionRegistry,
8068
+ onSessionUpdated: (sessionKey) => params.uiStartup?.publish({ type: "session.updated", payload: { sessionKey } }),
8003
8069
  resolveMessageToolHints: ({ channel, accountId }) => params.resolveMessageToolHints({ channel, accountId })
8004
8070
  })
8005
8071
  );
@@ -8639,18 +8705,9 @@ var ServiceCommands = class {
8639
8705
  };
8640
8706
  let runtimeState = null;
8641
8707
  const bootstrapStatus = createBootstrapStatus(shellContext.config.remote.enabled);
8642
- const ncpSessionService = new UiSessionService(shellContext.sessionManager);
8643
- const marketplaceInstaller = new ServiceMarketplaceInstaller({
8644
- applyLiveConfigReload,
8645
- runCliSubcommand: (args) => this.runCliSubcommand(args),
8646
- installBuiltinSkill: (slug, force) => this.installBuiltinMarketplaceSkill(slug, force)
8647
- }).createInstaller();
8648
- const remoteAccess = createRemoteAccessHost({
8649
- serviceCommands: this,
8650
- requestRestart: this.deps.requestRestart,
8651
- uiConfig: shellContext.uiConfig,
8652
- remoteModule: shellContext.remoteModule
8653
- });
8708
+ const ncpSessionService = new UiSessionService(shellContext.sessionManager, { onSessionUpdated: (sessionKey) => uiStartup?.publish({ type: "session.updated", payload: { sessionKey } }) });
8709
+ const marketplaceInstaller = new ServiceMarketplaceInstaller({ applyLiveConfigReload, runCliSubcommand: (args) => this.runCliSubcommand(args), installBuiltinSkill: (slug, force) => this.installBuiltinMarketplaceSkill(slug, force) }).createInstaller();
8710
+ const remoteAccess = createRemoteAccessHost({ serviceCommands: this, requestRestart: this.deps.requestRestart, uiConfig: shellContext.uiConfig, remoteModule: shellContext.remoteModule });
8654
8711
  const uiStartup = await measureStartupAsync(
8655
8712
  "service.start_ui_shell",
8656
8713
  async () => await startUiShell({
@@ -8690,10 +8747,10 @@ var ServiceCommands = class {
8690
8747
  runtimeState = gatewayRuntimeState;
8691
8748
  uiStartup?.publish({ type: "config.updated", payload: { path: "channels" } });
8692
8749
  uiStartup?.publish({ type: "config.updated", payload: { path: "plugins" } });
8693
- configureGatewayPluginRuntime({
8694
- gateway,
8695
- state: gatewayRuntimeState,
8696
- getLiveUiNcpAgent: () => this.liveUiNcpAgent
8750
+ configureGatewayPluginRuntime({ gateway, state: gatewayRuntimeState, getLiveUiNcpAgent: () => this.liveUiNcpAgent });
8751
+ wireSystemSessionUpdatedPublisher({
8752
+ runtimePool: gateway.runtimePool,
8753
+ publishUiEvent: uiStartup?.publish
8697
8754
  });
8698
8755
  console.log("\u2713 Capability hydration: scheduled in background");
8699
8756
  await measureStartupAsync(
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nextclaw",
3
- "version": "0.16.11",
3
+ "version": "0.16.13",
4
4
  "description": "Lightweight personal AI assistant with CLI, multi-provider routing, and channel integrations.",
5
5
  "private": false,
6
6
  "type": "module",
@@ -39,16 +39,16 @@
39
39
  "chokidar": "^3.6.0",
40
40
  "commander": "^12.1.0",
41
41
  "yaml": "^2.8.1",
42
- "@nextclaw/ncp": "0.4.0",
43
42
  "@nextclaw/core": "0.11.5",
44
- "@nextclaw/ncp-toolkit": "0.4.4",
43
+ "@nextclaw/mcp": "0.1.52",
44
+ "@nextclaw/ncp": "0.4.0",
45
45
  "@nextclaw/ncp-agent-runtime": "0.3.0",
46
- "@nextclaw/server": "0.11.6",
46
+ "@nextclaw/ncp-toolkit": "0.4.5",
47
47
  "@nextclaw/ncp-mcp": "0.1.52",
48
48
  "@nextclaw/runtime": "0.2.19",
49
- "@nextclaw/openclaw-compat": "0.3.41",
50
- "@nextclaw/remote": "0.1.58",
51
- "@nextclaw/mcp": "0.1.52"
49
+ "@nextclaw/remote": "0.1.60",
50
+ "@nextclaw/server": "0.11.8",
51
+ "@nextclaw/openclaw-compat": "0.3.42"
52
52
  },
53
53
  "devDependencies": {
54
54
  "@types/node": "^20.17.6",
@@ -57,7 +57,7 @@
57
57
  "tsx": "^4.19.2",
58
58
  "typescript": "^5.6.3",
59
59
  "vitest": "^2.1.2",
60
- "@nextclaw/ui": "0.11.8"
60
+ "@nextclaw/ui": "0.11.9"
61
61
  },
62
62
  "scripts": {
63
63
  "dev": "tsx watch --tsconfig tsconfig.json src/cli/index.ts",
@@ -1,4 +1,4 @@
1
- import{r as L,j as u,X as It,K as Pt,av as Bt,a$ as Tt,b0 as Mt,b1 as Rt,a0 as Lt,g as ut,f as kt,b2 as Me,ae as Re,b3 as Dt,ai as dt,e as q,a3 as Ut,i as Ft,G as qt,H as _t}from"./vendor-BEQcLDx6.js";import{Q as zt,t as c,c as K,I as Q,S as Ot,e as Ht,f as Kt,g as Vt,h as Jt,U as ft,B as je,i as Gt,u as gt,a as ht,b as mt,V as Yt,W as Qt}from"./index-BlrweCCh.js";import{S as pt}from"./status-dot-DOJX6vii.js";import{L as yt}from"./LogoBadge-iVDzhkNu.js";import{h as Se}from"./config-hints-CApS3K_7.js";import{c as Wt,b as Xt,a as Zt,C as $t}from"./config-layout-BHnOoweL.js";import{L as en}from"./label-DtssWSI4.js";import{S as tn}from"./switch-utBdpBRv.js";import{T as nn}from"./tabs-custom-ExyfvfgG.js";import{P as rn,a as sn}from"./page-layout-DnRqSldv.js";function bt(e){var n,t;const s=zt();return((n=e.tutorialUrls)==null?void 0:n[s])||((t=e.tutorialUrls)==null?void 0:t.default)||e.tutorialUrl}const an={telegram:"telegram.svg",slack:"slack.svg",discord:"discord.svg",whatsapp:"whatsapp.svg",qq:"qq.svg",feishu:"feishu.svg",dingtalk:"dingtalk.svg",wecom:"wecom.svg",weixin:"weixin.svg",mochat:"mochat.svg",email:"email.svg"};function on(e,s){const a=s.toLowerCase(),n=e[a];return n?`/logos/${n}`:null}function wt(e){return on(an,e)}function ln({value:e,onChange:s,className:a,placeholder:n=""}){const[t,r]=L.useState(""),i=l=>{l.key==="Enter"&&t.trim()?(l.preventDefault(),s([...e,t.trim()]),r("")):l.key==="Backspace"&&!t&&e.length>0&&s(e.slice(0,-1))},o=l=>{s(e.filter((d,h)=>h!==l))};return u.jsxs("div",{className:K("flex flex-wrap gap-2 p-2 border rounded-md min-h-[42px]",a),children:[e.map((l,d)=>u.jsxs("span",{className:"inline-flex items-center gap-1 px-2 py-1 bg-primary text-primary-foreground rounded text-sm",children:[l,u.jsx("button",{type:"button",onClick:()=>o(d),className:"hover:text-red-300 transition-colors",children:u.jsx(It,{className:"h-3 w-3"})})]},d)),u.jsx("input",{type:"text",value:t,onChange:l=>r(l.target.value),onKeyDown:i,className:"flex-1 outline-none min-w-[100px] bg-transparent text-sm",placeholder:n||c("enterTag")})]})}function cn(e){return e.includes("token")||e.includes("secret")||e.includes("password")?u.jsx(Pt,{className:"h-3.5 w-3.5 text-gray-500"}):e.includes("url")||e.includes("host")?u.jsx(Bt,{className:"h-3.5 w-3.5 text-gray-500"}):e.includes("email")||e.includes("mail")?u.jsx(Tt,{className:"h-3.5 w-3.5 text-gray-500"}):e.includes("id")||e.includes("from")?u.jsx(Mt,{className:"h-3.5 w-3.5 text-gray-500"}):e==="enabled"||e==="consentGranted"?u.jsx(Rt,{className:"h-3.5 w-3.5 text-gray-500"}):u.jsx(Lt,{className:"h-3.5 w-3.5 text-gray-500"})}function Le({channelName:e,fields:s,formData:a,jsonDrafts:n,setJsonDrafts:t,updateField:r,uiHints:i}){return u.jsx(u.Fragment,{children:s.map(o=>{const l=Se(`channels.${e}.${o.name}`,i),d=(l==null?void 0:l.label)??o.label,h=l==null?void 0:l.placeholder;return u.jsxs("div",{className:"space-y-2.5",children:[u.jsxs(en,{htmlFor:o.name,className:"flex items-center gap-2 text-sm font-medium text-gray-900",children:[cn(o.name),d]}),o.type==="boolean"&&u.jsxs("div",{className:"flex items-center justify-between rounded-xl bg-gray-50 p-3",children:[u.jsx("span",{className:"text-sm text-gray-500",children:a[o.name]?c("enabled"):c("disabled")}),u.jsx(tn,{id:o.name,checked:a[o.name]||!1,onCheckedChange:f=>r(o.name,f),className:"data-[state=checked]:bg-emerald-500"})]}),(o.type==="text"||o.type==="email")&&u.jsx(Q,{id:o.name,type:o.type,value:a[o.name]||"",onChange:f=>r(o.name,f.target.value),placeholder:h,className:"rounded-xl"}),o.type==="password"&&u.jsx(Q,{id:o.name,type:"password",value:a[o.name]||"",onChange:f=>r(o.name,f.target.value),placeholder:h??c("leaveBlankToKeepUnchanged"),className:"rounded-xl"}),o.type==="number"&&u.jsx(Q,{id:o.name,type:"number",value:a[o.name]||0,onChange:f=>r(o.name,parseInt(f.target.value,10)||0),placeholder:h,className:"rounded-xl"}),o.type==="tags"&&u.jsx(ln,{value:a[o.name]||[],onChange:f=>r(o.name,f)}),o.type==="select"&&u.jsxs(Ot,{value:a[o.name]||"",onValueChange:f=>r(o.name,f),children:[u.jsx(Ht,{className:"rounded-xl",children:u.jsx(Kt,{})}),u.jsx(Vt,{children:(o.options??[]).map(f=>u.jsx(Jt,{value:f.value,children:f.label},f.value))})]}),o.type==="json"&&u.jsx("textarea",{id:o.name,value:n[o.name]??"{}",onChange:f=>t(x=>({...x,[o.name]:f.target.value})),className:"min-h-[120px] w-full resize-none rounded-lg border border-gray-200 bg-white px-3 py-2 text-xs font-mono"})]},o.name)})})}const te=[{value:"pairing",label:"pairing"},{value:"allowlist",label:"allowlist"},{value:"open",label:"open"},{value:"disabled",label:"disabled"}],ne=[{value:"open",label:"open"},{value:"allowlist",label:"allowlist"},{value:"disabled",label:"disabled"}],un=[{value:"off",label:"off"},{value:"partial",label:"partial"},{value:"block",label:"block"},{value:"progress",label:"progress"}];function ke(){return{telegram:[{name:"enabled",type:"boolean",label:c("enabled")},{name:"token",type:"password",label:c("botToken")},{name:"allowFrom",type:"tags",label:c("allowFrom")},{name:"proxy",type:"text",label:c("proxy")},{name:"accountId",type:"text",label:c("accountId")},{name:"dmPolicy",type:"select",label:c("dmPolicy"),options:te},{name:"groupPolicy",type:"select",label:c("groupPolicy"),options:ne},{name:"groupAllowFrom",type:"tags",label:c("groupAllowFrom")},{name:"requireMention",type:"boolean",label:c("requireMention")},{name:"mentionPatterns",type:"tags",label:c("mentionPatterns")},{name:"groups",type:"json",label:c("groupRulesJson")}],discord:[{name:"enabled",type:"boolean",label:c("enabled")},{name:"token",type:"password",label:c("botToken")},{name:"allowBots",type:"boolean",label:c("allowBotMessages")},{name:"allowFrom",type:"tags",label:c("allowFrom")},{name:"gatewayUrl",type:"text",label:c("gatewayUrl")},{name:"intents",type:"number",label:c("intents")},{name:"proxy",type:"text",label:c("proxy")},{name:"mediaMaxMb",type:"number",label:c("attachmentMaxSizeMb")},{name:"streaming",type:"select",label:c("streamingMode"),options:un},{name:"draftChunk",type:"json",label:c("draftChunkingJson")},{name:"textChunkLimit",type:"number",label:c("textChunkLimit")},{name:"accountId",type:"text",label:c("accountId")},{name:"dmPolicy",type:"select",label:c("dmPolicy"),options:te},{name:"groupPolicy",type:"select",label:c("groupPolicy"),options:ne},{name:"groupAllowFrom",type:"tags",label:c("groupAllowFrom")},{name:"requireMention",type:"boolean",label:c("requireMention")},{name:"mentionPatterns",type:"tags",label:c("mentionPatterns")},{name:"groups",type:"json",label:c("groupRulesJson")}],whatsapp:[{name:"enabled",type:"boolean",label:c("enabled")},{name:"bridgeUrl",type:"text",label:c("bridgeUrl")},{name:"allowFrom",type:"tags",label:c("allowFrom")}],feishu:[{name:"enabled",type:"boolean",label:c("enabled")},{name:"appId",type:"text",label:c("appId")},{name:"appSecret",type:"password",label:c("appSecret")},{name:"encryptKey",type:"password",label:c("encryptKey")},{name:"verificationToken",type:"password",label:c("verificationToken")},{name:"domain",type:"text",label:"Domain"},{name:"allowFrom",type:"tags",label:c("allowFrom")},{name:"dmPolicy",type:"select",label:c("dmPolicy"),options:te},{name:"groupPolicy",type:"select",label:c("groupPolicy"),options:ne},{name:"groupAllowFrom",type:"tags",label:c("groupAllowFrom")},{name:"requireMention",type:"boolean",label:c("requireMention")},{name:"mentionPatterns",type:"tags",label:c("mentionPatterns")},{name:"groups",type:"json",label:c("groupRulesJson")},{name:"accounts",type:"json",label:c("accountsJson")}],dingtalk:[{name:"enabled",type:"boolean",label:c("enabled")},{name:"clientId",type:"text",label:c("clientId")},{name:"clientSecret",type:"password",label:c("clientSecret")},{name:"allowFrom",type:"tags",label:c("allowFrom")}],wecom:[{name:"enabled",type:"boolean",label:c("enabled")},{name:"corpId",type:"text",label:c("corpId")},{name:"agentId",type:"text",label:c("agentId")},{name:"secret",type:"password",label:c("secret")},{name:"token",type:"password",label:c("token")},{name:"callbackPort",type:"number",label:c("callbackPort")},{name:"callbackPath",type:"text",label:c("callbackPath")},{name:"allowFrom",type:"tags",label:c("allowFrom")}],weixin:[{name:"enabled",type:"boolean",label:c("enabled")},{name:"defaultAccountId",type:"text",label:c("defaultAccountId")},{name:"baseUrl",type:"text",label:c("baseUrl")},{name:"pollTimeoutMs",type:"number",label:c("pollTimeoutMs")},{name:"allowFrom",type:"tags",label:c("allowFrom")},{name:"accounts",type:"json",label:c("accountsJson")}],slack:[{name:"enabled",type:"boolean",label:c("enabled")},{name:"mode",type:"text",label:c("mode")},{name:"webhookPath",type:"text",label:c("webhookPath")},{name:"allowBots",type:"boolean",label:c("allowBotMessages")},{name:"botToken",type:"password",label:c("botToken")},{name:"appToken",type:"password",label:c("appToken")}],email:[{name:"enabled",type:"boolean",label:c("enabled")},{name:"consentGranted",type:"boolean",label:c("consentGranted")},{name:"imapHost",type:"text",label:c("imapHost")},{name:"imapPort",type:"number",label:c("imapPort")},{name:"imapUsername",type:"text",label:c("imapUsername")},{name:"imapPassword",type:"password",label:c("imapPassword")},{name:"fromAddress",type:"email",label:c("fromAddress")}],mochat:[{name:"enabled",type:"boolean",label:c("enabled")},{name:"baseUrl",type:"text",label:c("baseUrl")},{name:"clawToken",type:"password",label:c("clawToken")},{name:"agentUserId",type:"text",label:c("agentUserId")},{name:"allowFrom",type:"tags",label:c("allowFrom")}],qq:[{name:"enabled",type:"boolean",label:c("enabled")},{name:"appId",type:"text",label:c("appId")},{name:"secret",type:"password",label:c("appSecret")},{name:"markdownSupport",type:"boolean",label:c("markdownSupport")},{name:"allowFrom",type:"tags",label:c("allowFrom")}]}}var H={},re,De;function dn(){return De||(De=1,re=function(){return typeof Promise=="function"&&Promise.prototype&&Promise.prototype.then}),re}var se={},F={},Ue;function _(){if(Ue)return F;Ue=1;let e;const s=[0,26,44,70,100,134,172,196,242,292,346,404,466,532,581,655,733,815,901,991,1085,1156,1258,1364,1474,1588,1706,1828,1921,2051,2185,2323,2465,2611,2761,2876,3034,3196,3362,3532,3706];return F.getSymbolSize=function(n){if(!n)throw new Error('"version" cannot be null or undefined');if(n<1||n>40)throw new Error('"version" should be in range from 1 to 40');return n*4+17},F.getSymbolTotalCodewords=function(n){return s[n]},F.getBCHDigit=function(a){let n=0;for(;a!==0;)n++,a>>>=1;return n},F.setToSJISFunction=function(n){if(typeof n!="function")throw new Error('"toSJISFunc" is not a valid function.');e=n},F.isKanjiModeEnabled=function(){return typeof e<"u"},F.toSJIS=function(n){return e(n)},F}var ae={},Fe;function Ie(){return Fe||(Fe=1,(function(e){e.L={bit:1},e.M={bit:0},e.Q={bit:3},e.H={bit:2};function s(a){if(typeof a!="string")throw new Error("Param is not a string");switch(a.toLowerCase()){case"l":case"low":return e.L;case"m":case"medium":return e.M;case"q":case"quartile":return e.Q;case"h":case"high":return e.H;default:throw new Error("Unknown EC Level: "+a)}}e.isValid=function(n){return n&&typeof n.bit<"u"&&n.bit>=0&&n.bit<4},e.from=function(n,t){if(e.isValid(n))return n;try{return s(n)}catch{return t}}})(ae)),ae}var oe,qe;function fn(){if(qe)return oe;qe=1;function e(){this.buffer=[],this.length=0}return e.prototype={get:function(s){const a=Math.floor(s/8);return(this.buffer[a]>>>7-s%8&1)===1},put:function(s,a){for(let n=0;n<a;n++)this.putBit((s>>>a-n-1&1)===1)},getLengthInBits:function(){return this.length},putBit:function(s){const a=Math.floor(this.length/8);this.buffer.length<=a&&this.buffer.push(0),s&&(this.buffer[a]|=128>>>this.length%8),this.length++}},oe=e,oe}var ie,_e;function gn(){if(_e)return ie;_e=1;function e(s){if(!s||s<1)throw new Error("BitMatrix size must be defined and greater than 0");this.size=s,this.data=new Uint8Array(s*s),this.reservedBit=new Uint8Array(s*s)}return e.prototype.set=function(s,a,n,t){const r=s*this.size+a;this.data[r]=n,t&&(this.reservedBit[r]=!0)},e.prototype.get=function(s,a){return this.data[s*this.size+a]},e.prototype.xor=function(s,a,n){this.data[s*this.size+a]^=n},e.prototype.isReserved=function(s,a){return this.reservedBit[s*this.size+a]},ie=e,ie}var le={},ze;function hn(){return ze||(ze=1,(function(e){const s=_().getSymbolSize;e.getRowColCoords=function(n){if(n===1)return[];const t=Math.floor(n/7)+2,r=s(n),i=r===145?26:Math.ceil((r-13)/(2*t-2))*2,o=[r-7];for(let l=1;l<t-1;l++)o[l]=o[l-1]-i;return o.push(6),o.reverse()},e.getPositions=function(n){const t=[],r=e.getRowColCoords(n),i=r.length;for(let o=0;o<i;o++)for(let l=0;l<i;l++)o===0&&l===0||o===0&&l===i-1||o===i-1&&l===0||t.push([r[o],r[l]]);return t}})(le)),le}var ce={},Oe;function mn(){if(Oe)return ce;Oe=1;const e=_().getSymbolSize,s=7;return ce.getPositions=function(n){const t=e(n);return[[0,0],[t-s,0],[0,t-s]]},ce}var ue={},He;function pn(){return He||(He=1,(function(e){e.Patterns={PATTERN000:0,PATTERN001:1,PATTERN010:2,PATTERN011:3,PATTERN100:4,PATTERN101:5,PATTERN110:6,PATTERN111:7};const s={N1:3,N2:3,N3:40,N4:10};e.isValid=function(t){return t!=null&&t!==""&&!isNaN(t)&&t>=0&&t<=7},e.from=function(t){return e.isValid(t)?parseInt(t,10):void 0},e.getPenaltyN1=function(t){const r=t.size;let i=0,o=0,l=0,d=null,h=null;for(let f=0;f<r;f++){o=l=0,d=h=null;for(let x=0;x<r;x++){let g=t.get(f,x);g===d?o++:(o>=5&&(i+=s.N1+(o-5)),d=g,o=1),g=t.get(x,f),g===h?l++:(l>=5&&(i+=s.N1+(l-5)),h=g,l=1)}o>=5&&(i+=s.N1+(o-5)),l>=5&&(i+=s.N1+(l-5))}return i},e.getPenaltyN2=function(t){const r=t.size;let i=0;for(let o=0;o<r-1;o++)for(let l=0;l<r-1;l++){const d=t.get(o,l)+t.get(o,l+1)+t.get(o+1,l)+t.get(o+1,l+1);(d===4||d===0)&&i++}return i*s.N2},e.getPenaltyN3=function(t){const r=t.size;let i=0,o=0,l=0;for(let d=0;d<r;d++){o=l=0;for(let h=0;h<r;h++)o=o<<1&2047|t.get(d,h),h>=10&&(o===1488||o===93)&&i++,l=l<<1&2047|t.get(h,d),h>=10&&(l===1488||l===93)&&i++}return i*s.N3},e.getPenaltyN4=function(t){let r=0;const i=t.data.length;for(let l=0;l<i;l++)r+=t.data[l];return Math.abs(Math.ceil(r*100/i/5)-10)*s.N4};function a(n,t,r){switch(n){case e.Patterns.PATTERN000:return(t+r)%2===0;case e.Patterns.PATTERN001:return t%2===0;case e.Patterns.PATTERN010:return r%3===0;case e.Patterns.PATTERN011:return(t+r)%3===0;case e.Patterns.PATTERN100:return(Math.floor(t/2)+Math.floor(r/3))%2===0;case e.Patterns.PATTERN101:return t*r%2+t*r%3===0;case e.Patterns.PATTERN110:return(t*r%2+t*r%3)%2===0;case e.Patterns.PATTERN111:return(t*r%3+(t+r)%2)%2===0;default:throw new Error("bad maskPattern:"+n)}}e.applyMask=function(t,r){const i=r.size;for(let o=0;o<i;o++)for(let l=0;l<i;l++)r.isReserved(l,o)||r.xor(l,o,a(t,l,o))},e.getBestMask=function(t,r){const i=Object.keys(e.Patterns).length;let o=0,l=1/0;for(let d=0;d<i;d++){r(d),e.applyMask(d,t);const h=e.getPenaltyN1(t)+e.getPenaltyN2(t)+e.getPenaltyN3(t)+e.getPenaltyN4(t);e.applyMask(d,t),h<l&&(l=h,o=d)}return o}})(ue)),ue}var Y={},Ke;function xt(){if(Ke)return Y;Ke=1;const e=Ie(),s=[1,1,1,1,1,1,1,1,1,1,2,2,1,2,2,4,1,2,4,4,2,4,4,4,2,4,6,5,2,4,6,6,2,5,8,8,4,5,8,8,4,5,8,11,4,8,10,11,4,9,12,16,4,9,16,16,6,10,12,18,6,10,17,16,6,11,16,19,6,13,18,21,7,14,21,25,8,16,20,25,8,17,23,25,9,17,23,34,9,18,25,30,10,20,27,32,12,21,29,35,12,23,34,37,12,25,34,40,13,26,35,42,14,28,38,45,15,29,40,48,16,31,43,51,17,33,45,54,18,35,48,57,19,37,51,60,19,38,53,63,20,40,56,66,21,43,59,70,22,45,62,74,24,47,65,77,25,49,68,81],a=[7,10,13,17,10,16,22,28,15,26,36,44,20,36,52,64,26,48,72,88,36,64,96,112,40,72,108,130,48,88,132,156,60,110,160,192,72,130,192,224,80,150,224,264,96,176,260,308,104,198,288,352,120,216,320,384,132,240,360,432,144,280,408,480,168,308,448,532,180,338,504,588,196,364,546,650,224,416,600,700,224,442,644,750,252,476,690,816,270,504,750,900,300,560,810,960,312,588,870,1050,336,644,952,1110,360,700,1020,1200,390,728,1050,1260,420,784,1140,1350,450,812,1200,1440,480,868,1290,1530,510,924,1350,1620,540,980,1440,1710,570,1036,1530,1800,570,1064,1590,1890,600,1120,1680,1980,630,1204,1770,2100,660,1260,1860,2220,720,1316,1950,2310,750,1372,2040,2430];return Y.getBlocksCount=function(t,r){switch(r){case e.L:return s[(t-1)*4+0];case e.M:return s[(t-1)*4+1];case e.Q:return s[(t-1)*4+2];case e.H:return s[(t-1)*4+3];default:return}},Y.getTotalCodewordsCount=function(t,r){switch(r){case e.L:return a[(t-1)*4+0];case e.M:return a[(t-1)*4+1];case e.Q:return a[(t-1)*4+2];case e.H:return a[(t-1)*4+3];default:return}},Y}var de={},J={},Ve;function yn(){if(Ve)return J;Ve=1;const e=new Uint8Array(512),s=new Uint8Array(256);return(function(){let n=1;for(let t=0;t<255;t++)e[t]=n,s[n]=t,n<<=1,n&256&&(n^=285);for(let t=255;t<512;t++)e[t]=e[t-255]})(),J.log=function(n){if(n<1)throw new Error("log("+n+")");return s[n]},J.exp=function(n){return e[n]},J.mul=function(n,t){return n===0||t===0?0:e[s[n]+s[t]]},J}var Je;function bn(){return Je||(Je=1,(function(e){const s=yn();e.mul=function(n,t){const r=new Uint8Array(n.length+t.length-1);for(let i=0;i<n.length;i++)for(let o=0;o<t.length;o++)r[i+o]^=s.mul(n[i],t[o]);return r},e.mod=function(n,t){let r=new Uint8Array(n);for(;r.length-t.length>=0;){const i=r[0];for(let l=0;l<t.length;l++)r[l]^=s.mul(t[l],i);let o=0;for(;o<r.length&&r[o]===0;)o++;r=r.slice(o)}return r},e.generateECPolynomial=function(n){let t=new Uint8Array([1]);for(let r=0;r<n;r++)t=e.mul(t,new Uint8Array([1,s.exp(r)]));return t}})(de)),de}var fe,Ge;function wn(){if(Ge)return fe;Ge=1;const e=bn();function s(a){this.genPoly=void 0,this.degree=a,this.degree&&this.initialize(this.degree)}return s.prototype.initialize=function(n){this.degree=n,this.genPoly=e.generateECPolynomial(this.degree)},s.prototype.encode=function(n){if(!this.genPoly)throw new Error("Encoder not initialized");const t=new Uint8Array(n.length+this.degree);t.set(n);const r=e.mod(t,this.genPoly),i=this.degree-r.length;if(i>0){const o=new Uint8Array(this.degree);return o.set(r,i),o}return r},fe=s,fe}var ge={},he={},me={},Ye;function Ct(){return Ye||(Ye=1,me.isValid=function(s){return!isNaN(s)&&s>=1&&s<=40}),me}var k={},Qe;function At(){if(Qe)return k;Qe=1;const e="[0-9]+",s="[A-Z $%*+\\-./:]+";let a="(?:[u3000-u303F]|[u3040-u309F]|[u30A0-u30FF]|[uFF00-uFFEF]|[u4E00-u9FAF]|[u2605-u2606]|[u2190-u2195]|u203B|[u2010u2015u2018u2019u2025u2026u201Cu201Du2225u2260]|[u0391-u0451]|[u00A7u00A8u00B1u00B4u00D7u00F7])+";a=a.replace(/u/g,"\\u");const n="(?:(?![A-Z0-9 $%*+\\-./:]|"+a+`)(?:.|[\r
1
+ import{r as L,j as u,X as It,K as Pt,av as Bt,a$ as Tt,b0 as Mt,b1 as Rt,a0 as Lt,g as ut,f as kt,b2 as Me,ae as Re,b3 as Dt,ai as dt,e as q,a3 as Ut,i as Ft,G as qt,H as _t}from"./vendor-BEQcLDx6.js";import{Q as zt,t as c,c as K,I as Q,S as Ot,e as Ht,f as Kt,g as Vt,h as Jt,U as ft,B as je,i as Gt,u as gt,a as ht,b as mt,V as Yt,W as Qt}from"./index-D-wEIgPn.js";import{S as pt}from"./status-dot-BeHTBy9k.js";import{L as yt}from"./LogoBadge-CPMOwWdA.js";import{h as Se}from"./config-hints-CApS3K_7.js";import{c as Wt,b as Xt,a as Zt,C as $t}from"./config-layout-BHnOoweL.js";import{L as en}from"./label-usOOP7mv.js";import{S as tn}from"./switch-CtNnWZpa.js";import{T as nn}from"./tabs-custom-Dz_4tV62.js";import{P as rn,a as sn}from"./page-layout-CuIf20mx.js";function bt(e){var n,t;const s=zt();return((n=e.tutorialUrls)==null?void 0:n[s])||((t=e.tutorialUrls)==null?void 0:t.default)||e.tutorialUrl}const an={telegram:"telegram.svg",slack:"slack.svg",discord:"discord.svg",whatsapp:"whatsapp.svg",qq:"qq.svg",feishu:"feishu.svg",dingtalk:"dingtalk.svg",wecom:"wecom.svg",weixin:"weixin.svg",mochat:"mochat.svg",email:"email.svg"};function on(e,s){const a=s.toLowerCase(),n=e[a];return n?`/logos/${n}`:null}function wt(e){return on(an,e)}function ln({value:e,onChange:s,className:a,placeholder:n=""}){const[t,r]=L.useState(""),i=l=>{l.key==="Enter"&&t.trim()?(l.preventDefault(),s([...e,t.trim()]),r("")):l.key==="Backspace"&&!t&&e.length>0&&s(e.slice(0,-1))},o=l=>{s(e.filter((d,h)=>h!==l))};return u.jsxs("div",{className:K("flex flex-wrap gap-2 p-2 border rounded-md min-h-[42px]",a),children:[e.map((l,d)=>u.jsxs("span",{className:"inline-flex items-center gap-1 px-2 py-1 bg-primary text-primary-foreground rounded text-sm",children:[l,u.jsx("button",{type:"button",onClick:()=>o(d),className:"hover:text-red-300 transition-colors",children:u.jsx(It,{className:"h-3 w-3"})})]},d)),u.jsx("input",{type:"text",value:t,onChange:l=>r(l.target.value),onKeyDown:i,className:"flex-1 outline-none min-w-[100px] bg-transparent text-sm",placeholder:n||c("enterTag")})]})}function cn(e){return e.includes("token")||e.includes("secret")||e.includes("password")?u.jsx(Pt,{className:"h-3.5 w-3.5 text-gray-500"}):e.includes("url")||e.includes("host")?u.jsx(Bt,{className:"h-3.5 w-3.5 text-gray-500"}):e.includes("email")||e.includes("mail")?u.jsx(Tt,{className:"h-3.5 w-3.5 text-gray-500"}):e.includes("id")||e.includes("from")?u.jsx(Mt,{className:"h-3.5 w-3.5 text-gray-500"}):e==="enabled"||e==="consentGranted"?u.jsx(Rt,{className:"h-3.5 w-3.5 text-gray-500"}):u.jsx(Lt,{className:"h-3.5 w-3.5 text-gray-500"})}function Le({channelName:e,fields:s,formData:a,jsonDrafts:n,setJsonDrafts:t,updateField:r,uiHints:i}){return u.jsx(u.Fragment,{children:s.map(o=>{const l=Se(`channels.${e}.${o.name}`,i),d=(l==null?void 0:l.label)??o.label,h=l==null?void 0:l.placeholder;return u.jsxs("div",{className:"space-y-2.5",children:[u.jsxs(en,{htmlFor:o.name,className:"flex items-center gap-2 text-sm font-medium text-gray-900",children:[cn(o.name),d]}),o.type==="boolean"&&u.jsxs("div",{className:"flex items-center justify-between rounded-xl bg-gray-50 p-3",children:[u.jsx("span",{className:"text-sm text-gray-500",children:a[o.name]?c("enabled"):c("disabled")}),u.jsx(tn,{id:o.name,checked:a[o.name]||!1,onCheckedChange:f=>r(o.name,f),className:"data-[state=checked]:bg-emerald-500"})]}),(o.type==="text"||o.type==="email")&&u.jsx(Q,{id:o.name,type:o.type,value:a[o.name]||"",onChange:f=>r(o.name,f.target.value),placeholder:h,className:"rounded-xl"}),o.type==="password"&&u.jsx(Q,{id:o.name,type:"password",value:a[o.name]||"",onChange:f=>r(o.name,f.target.value),placeholder:h??c("leaveBlankToKeepUnchanged"),className:"rounded-xl"}),o.type==="number"&&u.jsx(Q,{id:o.name,type:"number",value:a[o.name]||0,onChange:f=>r(o.name,parseInt(f.target.value,10)||0),placeholder:h,className:"rounded-xl"}),o.type==="tags"&&u.jsx(ln,{value:a[o.name]||[],onChange:f=>r(o.name,f)}),o.type==="select"&&u.jsxs(Ot,{value:a[o.name]||"",onValueChange:f=>r(o.name,f),children:[u.jsx(Ht,{className:"rounded-xl",children:u.jsx(Kt,{})}),u.jsx(Vt,{children:(o.options??[]).map(f=>u.jsx(Jt,{value:f.value,children:f.label},f.value))})]}),o.type==="json"&&u.jsx("textarea",{id:o.name,value:n[o.name]??"{}",onChange:f=>t(x=>({...x,[o.name]:f.target.value})),className:"min-h-[120px] w-full resize-none rounded-lg border border-gray-200 bg-white px-3 py-2 text-xs font-mono"})]},o.name)})})}const te=[{value:"pairing",label:"pairing"},{value:"allowlist",label:"allowlist"},{value:"open",label:"open"},{value:"disabled",label:"disabled"}],ne=[{value:"open",label:"open"},{value:"allowlist",label:"allowlist"},{value:"disabled",label:"disabled"}],un=[{value:"off",label:"off"},{value:"partial",label:"partial"},{value:"block",label:"block"},{value:"progress",label:"progress"}];function ke(){return{telegram:[{name:"enabled",type:"boolean",label:c("enabled")},{name:"token",type:"password",label:c("botToken")},{name:"allowFrom",type:"tags",label:c("allowFrom")},{name:"proxy",type:"text",label:c("proxy")},{name:"accountId",type:"text",label:c("accountId")},{name:"dmPolicy",type:"select",label:c("dmPolicy"),options:te},{name:"groupPolicy",type:"select",label:c("groupPolicy"),options:ne},{name:"groupAllowFrom",type:"tags",label:c("groupAllowFrom")},{name:"requireMention",type:"boolean",label:c("requireMention")},{name:"mentionPatterns",type:"tags",label:c("mentionPatterns")},{name:"groups",type:"json",label:c("groupRulesJson")}],discord:[{name:"enabled",type:"boolean",label:c("enabled")},{name:"token",type:"password",label:c("botToken")},{name:"allowBots",type:"boolean",label:c("allowBotMessages")},{name:"allowFrom",type:"tags",label:c("allowFrom")},{name:"gatewayUrl",type:"text",label:c("gatewayUrl")},{name:"intents",type:"number",label:c("intents")},{name:"proxy",type:"text",label:c("proxy")},{name:"mediaMaxMb",type:"number",label:c("attachmentMaxSizeMb")},{name:"streaming",type:"select",label:c("streamingMode"),options:un},{name:"draftChunk",type:"json",label:c("draftChunkingJson")},{name:"textChunkLimit",type:"number",label:c("textChunkLimit")},{name:"accountId",type:"text",label:c("accountId")},{name:"dmPolicy",type:"select",label:c("dmPolicy"),options:te},{name:"groupPolicy",type:"select",label:c("groupPolicy"),options:ne},{name:"groupAllowFrom",type:"tags",label:c("groupAllowFrom")},{name:"requireMention",type:"boolean",label:c("requireMention")},{name:"mentionPatterns",type:"tags",label:c("mentionPatterns")},{name:"groups",type:"json",label:c("groupRulesJson")}],whatsapp:[{name:"enabled",type:"boolean",label:c("enabled")},{name:"bridgeUrl",type:"text",label:c("bridgeUrl")},{name:"allowFrom",type:"tags",label:c("allowFrom")}],feishu:[{name:"enabled",type:"boolean",label:c("enabled")},{name:"appId",type:"text",label:c("appId")},{name:"appSecret",type:"password",label:c("appSecret")},{name:"encryptKey",type:"password",label:c("encryptKey")},{name:"verificationToken",type:"password",label:c("verificationToken")},{name:"domain",type:"text",label:"Domain"},{name:"allowFrom",type:"tags",label:c("allowFrom")},{name:"dmPolicy",type:"select",label:c("dmPolicy"),options:te},{name:"groupPolicy",type:"select",label:c("groupPolicy"),options:ne},{name:"groupAllowFrom",type:"tags",label:c("groupAllowFrom")},{name:"requireMention",type:"boolean",label:c("requireMention")},{name:"mentionPatterns",type:"tags",label:c("mentionPatterns")},{name:"groups",type:"json",label:c("groupRulesJson")},{name:"accounts",type:"json",label:c("accountsJson")}],dingtalk:[{name:"enabled",type:"boolean",label:c("enabled")},{name:"clientId",type:"text",label:c("clientId")},{name:"clientSecret",type:"password",label:c("clientSecret")},{name:"allowFrom",type:"tags",label:c("allowFrom")}],wecom:[{name:"enabled",type:"boolean",label:c("enabled")},{name:"corpId",type:"text",label:c("corpId")},{name:"agentId",type:"text",label:c("agentId")},{name:"secret",type:"password",label:c("secret")},{name:"token",type:"password",label:c("token")},{name:"callbackPort",type:"number",label:c("callbackPort")},{name:"callbackPath",type:"text",label:c("callbackPath")},{name:"allowFrom",type:"tags",label:c("allowFrom")}],weixin:[{name:"enabled",type:"boolean",label:c("enabled")},{name:"defaultAccountId",type:"text",label:c("defaultAccountId")},{name:"baseUrl",type:"text",label:c("baseUrl")},{name:"pollTimeoutMs",type:"number",label:c("pollTimeoutMs")},{name:"allowFrom",type:"tags",label:c("allowFrom")},{name:"accounts",type:"json",label:c("accountsJson")}],slack:[{name:"enabled",type:"boolean",label:c("enabled")},{name:"mode",type:"text",label:c("mode")},{name:"webhookPath",type:"text",label:c("webhookPath")},{name:"allowBots",type:"boolean",label:c("allowBotMessages")},{name:"botToken",type:"password",label:c("botToken")},{name:"appToken",type:"password",label:c("appToken")}],email:[{name:"enabled",type:"boolean",label:c("enabled")},{name:"consentGranted",type:"boolean",label:c("consentGranted")},{name:"imapHost",type:"text",label:c("imapHost")},{name:"imapPort",type:"number",label:c("imapPort")},{name:"imapUsername",type:"text",label:c("imapUsername")},{name:"imapPassword",type:"password",label:c("imapPassword")},{name:"fromAddress",type:"email",label:c("fromAddress")}],mochat:[{name:"enabled",type:"boolean",label:c("enabled")},{name:"baseUrl",type:"text",label:c("baseUrl")},{name:"clawToken",type:"password",label:c("clawToken")},{name:"agentUserId",type:"text",label:c("agentUserId")},{name:"allowFrom",type:"tags",label:c("allowFrom")}],qq:[{name:"enabled",type:"boolean",label:c("enabled")},{name:"appId",type:"text",label:c("appId")},{name:"secret",type:"password",label:c("appSecret")},{name:"markdownSupport",type:"boolean",label:c("markdownSupport")},{name:"allowFrom",type:"tags",label:c("allowFrom")}]}}var H={},re,De;function dn(){return De||(De=1,re=function(){return typeof Promise=="function"&&Promise.prototype&&Promise.prototype.then}),re}var se={},F={},Ue;function _(){if(Ue)return F;Ue=1;let e;const s=[0,26,44,70,100,134,172,196,242,292,346,404,466,532,581,655,733,815,901,991,1085,1156,1258,1364,1474,1588,1706,1828,1921,2051,2185,2323,2465,2611,2761,2876,3034,3196,3362,3532,3706];return F.getSymbolSize=function(n){if(!n)throw new Error('"version" cannot be null or undefined');if(n<1||n>40)throw new Error('"version" should be in range from 1 to 40');return n*4+17},F.getSymbolTotalCodewords=function(n){return s[n]},F.getBCHDigit=function(a){let n=0;for(;a!==0;)n++,a>>>=1;return n},F.setToSJISFunction=function(n){if(typeof n!="function")throw new Error('"toSJISFunc" is not a valid function.');e=n},F.isKanjiModeEnabled=function(){return typeof e<"u"},F.toSJIS=function(n){return e(n)},F}var ae={},Fe;function Ie(){return Fe||(Fe=1,(function(e){e.L={bit:1},e.M={bit:0},e.Q={bit:3},e.H={bit:2};function s(a){if(typeof a!="string")throw new Error("Param is not a string");switch(a.toLowerCase()){case"l":case"low":return e.L;case"m":case"medium":return e.M;case"q":case"quartile":return e.Q;case"h":case"high":return e.H;default:throw new Error("Unknown EC Level: "+a)}}e.isValid=function(n){return n&&typeof n.bit<"u"&&n.bit>=0&&n.bit<4},e.from=function(n,t){if(e.isValid(n))return n;try{return s(n)}catch{return t}}})(ae)),ae}var oe,qe;function fn(){if(qe)return oe;qe=1;function e(){this.buffer=[],this.length=0}return e.prototype={get:function(s){const a=Math.floor(s/8);return(this.buffer[a]>>>7-s%8&1)===1},put:function(s,a){for(let n=0;n<a;n++)this.putBit((s>>>a-n-1&1)===1)},getLengthInBits:function(){return this.length},putBit:function(s){const a=Math.floor(this.length/8);this.buffer.length<=a&&this.buffer.push(0),s&&(this.buffer[a]|=128>>>this.length%8),this.length++}},oe=e,oe}var ie,_e;function gn(){if(_e)return ie;_e=1;function e(s){if(!s||s<1)throw new Error("BitMatrix size must be defined and greater than 0");this.size=s,this.data=new Uint8Array(s*s),this.reservedBit=new Uint8Array(s*s)}return e.prototype.set=function(s,a,n,t){const r=s*this.size+a;this.data[r]=n,t&&(this.reservedBit[r]=!0)},e.prototype.get=function(s,a){return this.data[s*this.size+a]},e.prototype.xor=function(s,a,n){this.data[s*this.size+a]^=n},e.prototype.isReserved=function(s,a){return this.reservedBit[s*this.size+a]},ie=e,ie}var le={},ze;function hn(){return ze||(ze=1,(function(e){const s=_().getSymbolSize;e.getRowColCoords=function(n){if(n===1)return[];const t=Math.floor(n/7)+2,r=s(n),i=r===145?26:Math.ceil((r-13)/(2*t-2))*2,o=[r-7];for(let l=1;l<t-1;l++)o[l]=o[l-1]-i;return o.push(6),o.reverse()},e.getPositions=function(n){const t=[],r=e.getRowColCoords(n),i=r.length;for(let o=0;o<i;o++)for(let l=0;l<i;l++)o===0&&l===0||o===0&&l===i-1||o===i-1&&l===0||t.push([r[o],r[l]]);return t}})(le)),le}var ce={},Oe;function mn(){if(Oe)return ce;Oe=1;const e=_().getSymbolSize,s=7;return ce.getPositions=function(n){const t=e(n);return[[0,0],[t-s,0],[0,t-s]]},ce}var ue={},He;function pn(){return He||(He=1,(function(e){e.Patterns={PATTERN000:0,PATTERN001:1,PATTERN010:2,PATTERN011:3,PATTERN100:4,PATTERN101:5,PATTERN110:6,PATTERN111:7};const s={N1:3,N2:3,N3:40,N4:10};e.isValid=function(t){return t!=null&&t!==""&&!isNaN(t)&&t>=0&&t<=7},e.from=function(t){return e.isValid(t)?parseInt(t,10):void 0},e.getPenaltyN1=function(t){const r=t.size;let i=0,o=0,l=0,d=null,h=null;for(let f=0;f<r;f++){o=l=0,d=h=null;for(let x=0;x<r;x++){let g=t.get(f,x);g===d?o++:(o>=5&&(i+=s.N1+(o-5)),d=g,o=1),g=t.get(x,f),g===h?l++:(l>=5&&(i+=s.N1+(l-5)),h=g,l=1)}o>=5&&(i+=s.N1+(o-5)),l>=5&&(i+=s.N1+(l-5))}return i},e.getPenaltyN2=function(t){const r=t.size;let i=0;for(let o=0;o<r-1;o++)for(let l=0;l<r-1;l++){const d=t.get(o,l)+t.get(o,l+1)+t.get(o+1,l)+t.get(o+1,l+1);(d===4||d===0)&&i++}return i*s.N2},e.getPenaltyN3=function(t){const r=t.size;let i=0,o=0,l=0;for(let d=0;d<r;d++){o=l=0;for(let h=0;h<r;h++)o=o<<1&2047|t.get(d,h),h>=10&&(o===1488||o===93)&&i++,l=l<<1&2047|t.get(h,d),h>=10&&(l===1488||l===93)&&i++}return i*s.N3},e.getPenaltyN4=function(t){let r=0;const i=t.data.length;for(let l=0;l<i;l++)r+=t.data[l];return Math.abs(Math.ceil(r*100/i/5)-10)*s.N4};function a(n,t,r){switch(n){case e.Patterns.PATTERN000:return(t+r)%2===0;case e.Patterns.PATTERN001:return t%2===0;case e.Patterns.PATTERN010:return r%3===0;case e.Patterns.PATTERN011:return(t+r)%3===0;case e.Patterns.PATTERN100:return(Math.floor(t/2)+Math.floor(r/3))%2===0;case e.Patterns.PATTERN101:return t*r%2+t*r%3===0;case e.Patterns.PATTERN110:return(t*r%2+t*r%3)%2===0;case e.Patterns.PATTERN111:return(t*r%3+(t+r)%2)%2===0;default:throw new Error("bad maskPattern:"+n)}}e.applyMask=function(t,r){const i=r.size;for(let o=0;o<i;o++)for(let l=0;l<i;l++)r.isReserved(l,o)||r.xor(l,o,a(t,l,o))},e.getBestMask=function(t,r){const i=Object.keys(e.Patterns).length;let o=0,l=1/0;for(let d=0;d<i;d++){r(d),e.applyMask(d,t);const h=e.getPenaltyN1(t)+e.getPenaltyN2(t)+e.getPenaltyN3(t)+e.getPenaltyN4(t);e.applyMask(d,t),h<l&&(l=h,o=d)}return o}})(ue)),ue}var Y={},Ke;function xt(){if(Ke)return Y;Ke=1;const e=Ie(),s=[1,1,1,1,1,1,1,1,1,1,2,2,1,2,2,4,1,2,4,4,2,4,4,4,2,4,6,5,2,4,6,6,2,5,8,8,4,5,8,8,4,5,8,11,4,8,10,11,4,9,12,16,4,9,16,16,6,10,12,18,6,10,17,16,6,11,16,19,6,13,18,21,7,14,21,25,8,16,20,25,8,17,23,25,9,17,23,34,9,18,25,30,10,20,27,32,12,21,29,35,12,23,34,37,12,25,34,40,13,26,35,42,14,28,38,45,15,29,40,48,16,31,43,51,17,33,45,54,18,35,48,57,19,37,51,60,19,38,53,63,20,40,56,66,21,43,59,70,22,45,62,74,24,47,65,77,25,49,68,81],a=[7,10,13,17,10,16,22,28,15,26,36,44,20,36,52,64,26,48,72,88,36,64,96,112,40,72,108,130,48,88,132,156,60,110,160,192,72,130,192,224,80,150,224,264,96,176,260,308,104,198,288,352,120,216,320,384,132,240,360,432,144,280,408,480,168,308,448,532,180,338,504,588,196,364,546,650,224,416,600,700,224,442,644,750,252,476,690,816,270,504,750,900,300,560,810,960,312,588,870,1050,336,644,952,1110,360,700,1020,1200,390,728,1050,1260,420,784,1140,1350,450,812,1200,1440,480,868,1290,1530,510,924,1350,1620,540,980,1440,1710,570,1036,1530,1800,570,1064,1590,1890,600,1120,1680,1980,630,1204,1770,2100,660,1260,1860,2220,720,1316,1950,2310,750,1372,2040,2430];return Y.getBlocksCount=function(t,r){switch(r){case e.L:return s[(t-1)*4+0];case e.M:return s[(t-1)*4+1];case e.Q:return s[(t-1)*4+2];case e.H:return s[(t-1)*4+3];default:return}},Y.getTotalCodewordsCount=function(t,r){switch(r){case e.L:return a[(t-1)*4+0];case e.M:return a[(t-1)*4+1];case e.Q:return a[(t-1)*4+2];case e.H:return a[(t-1)*4+3];default:return}},Y}var de={},J={},Ve;function yn(){if(Ve)return J;Ve=1;const e=new Uint8Array(512),s=new Uint8Array(256);return(function(){let n=1;for(let t=0;t<255;t++)e[t]=n,s[n]=t,n<<=1,n&256&&(n^=285);for(let t=255;t<512;t++)e[t]=e[t-255]})(),J.log=function(n){if(n<1)throw new Error("log("+n+")");return s[n]},J.exp=function(n){return e[n]},J.mul=function(n,t){return n===0||t===0?0:e[s[n]+s[t]]},J}var Je;function bn(){return Je||(Je=1,(function(e){const s=yn();e.mul=function(n,t){const r=new Uint8Array(n.length+t.length-1);for(let i=0;i<n.length;i++)for(let o=0;o<t.length;o++)r[i+o]^=s.mul(n[i],t[o]);return r},e.mod=function(n,t){let r=new Uint8Array(n);for(;r.length-t.length>=0;){const i=r[0];for(let l=0;l<t.length;l++)r[l]^=s.mul(t[l],i);let o=0;for(;o<r.length&&r[o]===0;)o++;r=r.slice(o)}return r},e.generateECPolynomial=function(n){let t=new Uint8Array([1]);for(let r=0;r<n;r++)t=e.mul(t,new Uint8Array([1,s.exp(r)]));return t}})(de)),de}var fe,Ge;function wn(){if(Ge)return fe;Ge=1;const e=bn();function s(a){this.genPoly=void 0,this.degree=a,this.degree&&this.initialize(this.degree)}return s.prototype.initialize=function(n){this.degree=n,this.genPoly=e.generateECPolynomial(this.degree)},s.prototype.encode=function(n){if(!this.genPoly)throw new Error("Encoder not initialized");const t=new Uint8Array(n.length+this.degree);t.set(n);const r=e.mod(t,this.genPoly),i=this.degree-r.length;if(i>0){const o=new Uint8Array(this.degree);return o.set(r,i),o}return r},fe=s,fe}var ge={},he={},me={},Ye;function Ct(){return Ye||(Ye=1,me.isValid=function(s){return!isNaN(s)&&s>=1&&s<=40}),me}var k={},Qe;function At(){if(Qe)return k;Qe=1;const e="[0-9]+",s="[A-Z $%*+\\-./:]+";let a="(?:[u3000-u303F]|[u3040-u309F]|[u30A0-u30FF]|[uFF00-uFFEF]|[u4E00-u9FAF]|[u2605-u2606]|[u2190-u2195]|u203B|[u2010u2015u2018u2019u2025u2026u201Cu201Du2225u2260]|[u0391-u0451]|[u00A7u00A8u00B1u00B4u00D7u00F7])+";a=a.replace(/u/g,"\\u");const n="(?:(?![A-Z0-9 $%*+\\-./:]|"+a+`)(?:.|[\r
2
2
  ]))+`;k.KANJI=new RegExp(a,"g"),k.BYTE_KANJI=new RegExp("[^A-Z0-9 $%*+\\-./:]+","g"),k.BYTE=new RegExp(n,"g"),k.NUMERIC=new RegExp(e,"g"),k.ALPHANUMERIC=new RegExp(s,"g");const t=new RegExp("^"+a+"$"),r=new RegExp("^"+e+"$"),i=new RegExp("^[A-Z0-9 $%*+\\-./:]+$");return k.testKanji=function(l){return t.test(l)},k.testNumeric=function(l){return r.test(l)},k.testAlphanumeric=function(l){return i.test(l)},k}var We;function z(){return We||(We=1,(function(e){const s=Ct(),a=At();e.NUMERIC={id:"Numeric",bit:1,ccBits:[10,12,14]},e.ALPHANUMERIC={id:"Alphanumeric",bit:2,ccBits:[9,11,13]},e.BYTE={id:"Byte",bit:4,ccBits:[8,16,16]},e.KANJI={id:"Kanji",bit:8,ccBits:[8,10,12]},e.MIXED={bit:-1},e.getCharCountIndicator=function(r,i){if(!r.ccBits)throw new Error("Invalid mode: "+r);if(!s.isValid(i))throw new Error("Invalid version: "+i);return i>=1&&i<10?r.ccBits[0]:i<27?r.ccBits[1]:r.ccBits[2]},e.getBestModeForData=function(r){return a.testNumeric(r)?e.NUMERIC:a.testAlphanumeric(r)?e.ALPHANUMERIC:a.testKanji(r)?e.KANJI:e.BYTE},e.toString=function(r){if(r&&r.id)return r.id;throw new Error("Invalid mode")},e.isValid=function(r){return r&&r.bit&&r.ccBits};function n(t){if(typeof t!="string")throw new Error("Param is not a string");switch(t.toLowerCase()){case"numeric":return e.NUMERIC;case"alphanumeric":return e.ALPHANUMERIC;case"kanji":return e.KANJI;case"byte":return e.BYTE;default:throw new Error("Unknown mode: "+t)}}e.from=function(r,i){if(e.isValid(r))return r;try{return n(r)}catch{return i}}})(he)),he}var Xe;function xn(){return Xe||(Xe=1,(function(e){const s=_(),a=xt(),n=Ie(),t=z(),r=Ct(),i=7973,o=s.getBCHDigit(i);function l(x,g,y){for(let A=1;A<=40;A++)if(g<=e.getCapacity(A,y,x))return A}function d(x,g){return t.getCharCountIndicator(x,g)+4}function h(x,g){let y=0;return x.forEach(function(A){const T=d(A.mode,g);y+=T+A.getBitsLength()}),y}function f(x,g){for(let y=1;y<=40;y++)if(h(x,y)<=e.getCapacity(y,g,t.MIXED))return y}e.from=function(g,y){return r.isValid(g)?parseInt(g,10):y},e.getCapacity=function(g,y,A){if(!r.isValid(g))throw new Error("Invalid QR Code version");typeof A>"u"&&(A=t.BYTE);const T=s.getSymbolTotalCodewords(g),E=a.getTotalCodewordsCount(g,y),B=(T-E)*8;if(A===t.MIXED)return B;const b=B-d(A,g);switch(A){case t.NUMERIC:return Math.floor(b/10*3);case t.ALPHANUMERIC:return Math.floor(b/11*2);case t.KANJI:return Math.floor(b/13);case t.BYTE:default:return Math.floor(b/8)}},e.getBestVersionForData=function(g,y){let A;const T=n.from(y,n.M);if(Array.isArray(g)){if(g.length>1)return f(g,T);if(g.length===0)return 1;A=g[0]}else A=g;return l(A.mode,A.getLength(),T)},e.getEncodedBits=function(g){if(!r.isValid(g)||g<7)throw new Error("Invalid QR Code version");let y=g<<12;for(;s.getBCHDigit(y)-o>=0;)y^=i<<s.getBCHDigit(y)-o;return g<<12|y}})(ge)),ge}var pe={},Ze;function Cn(){if(Ze)return pe;Ze=1;const e=_(),s=1335,a=21522,n=e.getBCHDigit(s);return pe.getEncodedBits=function(r,i){const o=r.bit<<3|i;let l=o<<10;for(;e.getBCHDigit(l)-n>=0;)l^=s<<e.getBCHDigit(l)-n;return(o<<10|l)^a},pe}var ye={},be,$e;function An(){if($e)return be;$e=1;const e=z();function s(a){this.mode=e.NUMERIC,this.data=a.toString()}return s.getBitsLength=function(n){return 10*Math.floor(n/3)+(n%3?n%3*3+1:0)},s.prototype.getLength=function(){return this.data.length},s.prototype.getBitsLength=function(){return s.getBitsLength(this.data.length)},s.prototype.write=function(n){let t,r,i;for(t=0;t+3<=this.data.length;t+=3)r=this.data.substr(t,3),i=parseInt(r,10),n.put(i,10);const o=this.data.length-t;o>0&&(r=this.data.substr(t),i=parseInt(r,10),n.put(i,o*3+1))},be=s,be}var we,et;function vn(){if(et)return we;et=1;const e=z(),s=["0","1","2","3","4","5","6","7","8","9","A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z"," ","$","%","*","+","-",".","/",":"];function a(n){this.mode=e.ALPHANUMERIC,this.data=n}return a.getBitsLength=function(t){return 11*Math.floor(t/2)+6*(t%2)},a.prototype.getLength=function(){return this.data.length},a.prototype.getBitsLength=function(){return a.getBitsLength(this.data.length)},a.prototype.write=function(t){let r;for(r=0;r+2<=this.data.length;r+=2){let i=s.indexOf(this.data[r])*45;i+=s.indexOf(this.data[r+1]),t.put(i,11)}this.data.length%2&&t.put(s.indexOf(this.data[r]),6)},we=a,we}var xe,tt;function Nn(){if(tt)return xe;tt=1;const e=z();function s(a){this.mode=e.BYTE,typeof a=="string"?this.data=new TextEncoder().encode(a):this.data=new Uint8Array(a)}return s.getBitsLength=function(n){return n*8},s.prototype.getLength=function(){return this.data.length},s.prototype.getBitsLength=function(){return s.getBitsLength(this.data.length)},s.prototype.write=function(a){for(let n=0,t=this.data.length;n<t;n++)a.put(this.data[n],8)},xe=s,xe}var Ce,nt;function En(){if(nt)return Ce;nt=1;const e=z(),s=_();function a(n){this.mode=e.KANJI,this.data=n}return a.getBitsLength=function(t){return t*13},a.prototype.getLength=function(){return this.data.length},a.prototype.getBitsLength=function(){return a.getBitsLength(this.data.length)},a.prototype.write=function(n){let t;for(t=0;t<this.data.length;t++){let r=s.toSJIS(this.data[t]);if(r>=33088&&r<=40956)r-=33088;else if(r>=57408&&r<=60351)r-=49472;else throw new Error("Invalid SJIS character: "+this.data[t]+`
3
3
  Make sure your charset is UTF-8`);r=(r>>>8&255)*192+(r&255),n.put(r,13)}},Ce=a,Ce}var Ae={exports:{}},rt;function jn(){return rt||(rt=1,(function(e){var s={single_source_shortest_paths:function(a,n,t){var r={},i={};i[n]=0;var o=s.PriorityQueue.make();o.push(n,0);for(var l,d,h,f,x,g,y,A,T;!o.empty();){l=o.pop(),d=l.value,f=l.cost,x=a[d]||{};for(h in x)x.hasOwnProperty(h)&&(g=x[h],y=f+g,A=i[h],T=typeof i[h]>"u",(T||A>y)&&(i[h]=y,o.push(h,y),r[h]=d))}if(typeof t<"u"&&typeof i[t]>"u"){var E=["Could not find a path from ",n," to ",t,"."].join("");throw new Error(E)}return r},extract_shortest_path_from_predecessor_list:function(a,n){for(var t=[],r=n;r;)t.push(r),a[r],r=a[r];return t.reverse(),t},find_path:function(a,n,t){var r=s.single_source_shortest_paths(a,n,t);return s.extract_shortest_path_from_predecessor_list(r,t)},PriorityQueue:{make:function(a){var n=s.PriorityQueue,t={},r;a=a||{};for(r in n)n.hasOwnProperty(r)&&(t[r]=n[r]);return t.queue=[],t.sorter=a.sorter||n.default_sorter,t},default_sorter:function(a,n){return a.cost-n.cost},push:function(a,n){var t={value:a,cost:n};this.queue.push(t),this.queue.sort(this.sorter)},pop:function(){return this.queue.shift()},empty:function(){return this.queue.length===0}}};e.exports=s})(Ae)),Ae.exports}var st;function Sn(){return st||(st=1,(function(e){const s=z(),a=An(),n=vn(),t=Nn(),r=En(),i=At(),o=_(),l=jn();function d(E){return unescape(encodeURIComponent(E)).length}function h(E,B,b){const N=[];let M;for(;(M=E.exec(b))!==null;)N.push({data:M[0],index:M.index,mode:B,length:M[0].length});return N}function f(E){const B=h(i.NUMERIC,s.NUMERIC,E),b=h(i.ALPHANUMERIC,s.ALPHANUMERIC,E);let N,M;return o.isKanjiModeEnabled()?(N=h(i.BYTE,s.BYTE,E),M=h(i.KANJI,s.KANJI,E)):(N=h(i.BYTE_KANJI,s.BYTE,E),M=[]),B.concat(b,N,M).sort(function(S,I){return S.index-I.index}).map(function(S){return{data:S.data,mode:S.mode,length:S.length}})}function x(E,B){switch(B){case s.NUMERIC:return a.getBitsLength(E);case s.ALPHANUMERIC:return n.getBitsLength(E);case s.KANJI:return r.getBitsLength(E);case s.BYTE:return t.getBitsLength(E)}}function g(E){return E.reduce(function(B,b){const N=B.length-1>=0?B[B.length-1]:null;return N&&N.mode===b.mode?(B[B.length-1].data+=b.data,B):(B.push(b),B)},[])}function y(E){const B=[];for(let b=0;b<E.length;b++){const N=E[b];switch(N.mode){case s.NUMERIC:B.push([N,{data:N.data,mode:s.ALPHANUMERIC,length:N.length},{data:N.data,mode:s.BYTE,length:N.length}]);break;case s.ALPHANUMERIC:B.push([N,{data:N.data,mode:s.BYTE,length:N.length}]);break;case s.KANJI:B.push([N,{data:N.data,mode:s.BYTE,length:d(N.data)}]);break;case s.BYTE:B.push([{data:N.data,mode:s.BYTE,length:d(N.data)}])}}return B}function A(E,B){const b={},N={start:{}};let M=["start"];for(let w=0;w<E.length;w++){const S=E[w],I=[];for(let v=0;v<S.length;v++){const P=S[v],j=""+w+v;I.push(j),b[j]={node:P,lastCount:0},N[j]={};for(let m=0;m<M.length;m++){const p=M[m];b[p]&&b[p].node.mode===P.mode?(N[p][j]=x(b[p].lastCount+P.length,P.mode)-x(b[p].lastCount,P.mode),b[p].lastCount+=P.length):(b[p]&&(b[p].lastCount=P.length),N[p][j]=x(P.length,P.mode)+4+s.getCharCountIndicator(P.mode,B))}}M=I}for(let w=0;w<M.length;w++)N[M[w]].end=0;return{map:N,table:b}}function T(E,B){let b;const N=s.getBestModeForData(E);if(b=s.from(B,N),b!==s.BYTE&&b.bit<N.bit)throw new Error('"'+E+'" cannot be encoded with mode '+s.toString(b)+`.
4
4
  Suggested mode is: `+s.toString(N));switch(b===s.KANJI&&!o.isKanjiModeEnabled()&&(b=s.BYTE),b){case s.NUMERIC:return new a(E);case s.ALPHANUMERIC:return new n(E);case s.KANJI:return new r(E);case s.BYTE:return new t(E)}}e.fromArray=function(B){return B.reduce(function(b,N){return typeof N=="string"?b.push(T(N,null)):N.data&&b.push(T(N.data,N.mode)),b},[])},e.fromString=function(B,b){const N=f(B,o.isKanjiModeEnabled()),M=y(N),w=A(M,b),S=l.find_path(w.map,"start","end"),I=[];for(let v=1;v<S.length-1;v++)I.push(w.table[S[v]].node);return e.fromArray(g(I))},e.rawSplit=function(B){return e.fromArray(f(B,o.isKanjiModeEnabled()))}})(ye)),ye}var at;function In(){if(at)return se;at=1;const e=_(),s=Ie(),a=fn(),n=gn(),t=hn(),r=mn(),i=pn(),o=xt(),l=wn(),d=xn(),h=Cn(),f=z(),x=Sn();function g(w,S){const I=w.size,v=r.getPositions(S);for(let P=0;P<v.length;P++){const j=v[P][0],m=v[P][1];for(let p=-1;p<=7;p++)if(!(j+p<=-1||I<=j+p))for(let C=-1;C<=7;C++)m+C<=-1||I<=m+C||(p>=0&&p<=6&&(C===0||C===6)||C>=0&&C<=6&&(p===0||p===6)||p>=2&&p<=4&&C>=2&&C<=4?w.set(j+p,m+C,!0,!0):w.set(j+p,m+C,!1,!0))}}function y(w){const S=w.size;for(let I=8;I<S-8;I++){const v=I%2===0;w.set(I,6,v,!0),w.set(6,I,v,!0)}}function A(w,S){const I=t.getPositions(S);for(let v=0;v<I.length;v++){const P=I[v][0],j=I[v][1];for(let m=-2;m<=2;m++)for(let p=-2;p<=2;p++)m===-2||m===2||p===-2||p===2||m===0&&p===0?w.set(P+m,j+p,!0,!0):w.set(P+m,j+p,!1,!0)}}function T(w,S){const I=w.size,v=d.getEncodedBits(S);let P,j,m;for(let p=0;p<18;p++)P=Math.floor(p/3),j=p%3+I-8-3,m=(v>>p&1)===1,w.set(P,j,m,!0),w.set(j,P,m,!0)}function E(w,S,I){const v=w.size,P=h.getEncodedBits(S,I);let j,m;for(j=0;j<15;j++)m=(P>>j&1)===1,j<6?w.set(j,8,m,!0):j<8?w.set(j+1,8,m,!0):w.set(v-15+j,8,m,!0),j<8?w.set(8,v-j-1,m,!0):j<9?w.set(8,15-j-1+1,m,!0):w.set(8,15-j-1,m,!0);w.set(v-8,8,1,!0)}function B(w,S){const I=w.size;let v=-1,P=I-1,j=7,m=0;for(let p=I-1;p>0;p-=2)for(p===6&&p--;;){for(let C=0;C<2;C++)if(!w.isReserved(P,p-C)){let R=!1;m<S.length&&(R=(S[m]>>>j&1)===1),w.set(P,p-C,R),j--,j===-1&&(m++,j=7)}if(P+=v,P<0||I<=P){P-=v,v=-v;break}}}function b(w,S,I){const v=new a;I.forEach(function(C){v.put(C.mode.bit,4),v.put(C.getLength(),f.getCharCountIndicator(C.mode,w)),C.write(v)});const P=e.getSymbolTotalCodewords(w),j=o.getTotalCodewordsCount(w,S),m=(P-j)*8;for(v.getLengthInBits()+4<=m&&v.put(0,4);v.getLengthInBits()%8!==0;)v.putBit(0);const p=(m-v.getLengthInBits())/8;for(let C=0;C<p;C++)v.put(C%2?17:236,8);return N(v,w,S)}function N(w,S,I){const v=e.getSymbolTotalCodewords(S),P=o.getTotalCodewordsCount(S,I),j=v-P,m=o.getBlocksCount(S,I),p=v%m,C=m-p,R=Math.floor(v/m),V=Math.floor(j/m),Et=V+1,Pe=R-V,jt=new l(Pe);let X=0;const G=new Array(m),Be=new Array(m);let Z=0;const St=new Uint8Array(w.buffer);for(let O=0;O<m;O++){const ee=O<C?V:Et;G[O]=St.slice(X,X+ee),Be[O]=jt.encode(G[O]),X+=ee,Z=Math.max(Z,ee)}const $=new Uint8Array(v);let Te=0,D,U;for(D=0;D<Z;D++)for(U=0;U<m;U++)D<G[U].length&&($[Te++]=G[U][D]);for(D=0;D<Pe;D++)for(U=0;U<m;U++)$[Te++]=Be[U][D];return $}function M(w,S,I,v){let P;if(Array.isArray(w))P=x.fromArray(w);else if(typeof w=="string"){let R=S;if(!R){const V=x.rawSplit(w);R=d.getBestVersionForData(V,I)}P=x.fromString(w,R||40)}else throw new Error("Invalid data");const j=d.getBestVersionForData(P,I);if(!j)throw new Error("The amount of data is too big to be stored in a QR Code");if(!S)S=j;else if(S<j)throw new Error(`