8f2fb5f54db5b3e6ad4644e4d2f38a2957e118563dcd6341e9126579a3ab8ed6.json raw

   1  {"ast":null,"code":"import _asyncToGenerator from \"/home/mleku/src/orly.dev/next/signer/node_modules/@babel/runtime/helpers/esm/asyncToGenerator.js\";\nimport { NgTemplateOutlet } from '@angular/common';\nimport { inject } from '@angular/core';\nimport { ActivatedRoute } from '@angular/router';\nimport { IconButtonComponent, NavComponent, NostrHelper, RelayListService, RelayRwComponent, StorageService, VisualRelayPipe } from '@common';\nimport * as i0 from \"@angular/core\";\nconst _c0 = a0 => ({\n  relay: a0\n});\nconst _forTrack0 = ($index, $item) => $item.url;\nfunction RelaysComponent_ng_template_0_Template(rf, ctx) {\n  if (rf & 1) {\n    i0.ɵɵelementStart(0, \"div\", 9)(1, \"div\", 10)(2, \"span\");\n    i0.ɵɵtext(3);\n    i0.ɵɵpipe(4, \"visualRelay\");\n    i0.ɵɵelementEnd();\n    i0.ɵɵelementStart(5, \"div\", 11);\n    i0.ɵɵelement(6, \"lib-relay-rw\", 12)(7, \"lib-relay-rw\", 13);\n    i0.ɵɵelementEnd()()();\n  }\n  if (rf & 2) {\n    const relay_r2 = ctx.relay;\n    i0.ɵɵadvance(3);\n    i0.ɵɵtextInterpolate(i0.ɵɵpipeBind1(4, 5, relay_r2.url));\n    i0.ɵɵadvance(3);\n    i0.ɵɵproperty(\"model\", relay_r2.read)(\"readonly\", true);\n    i0.ɵɵadvance();\n    i0.ɵɵproperty(\"model\", relay_r2.write)(\"readonly\", true);\n  }\n}\nfunction RelaysComponent_Conditional_11_Template(rf, ctx) {\n  if (rf & 1) {\n    i0.ɵɵelementStart(0, \"div\", 6);\n    i0.ɵɵelement(1, \"i\", 14);\n    i0.ɵɵelementStart(2, \"span\");\n    i0.ɵɵtext(3, \"Fetching relay list...\");\n    i0.ɵɵelementEnd()();\n  }\n}\nfunction RelaysComponent_Conditional_12_Template(rf, ctx) {\n  if (rf & 1) {\n    i0.ɵɵelementStart(0, \"div\", 7);\n    i0.ɵɵelement(1, \"i\", 15);\n    i0.ɵɵelementStart(2, \"span\");\n    i0.ɵɵtext(3);\n    i0.ɵɵelementEnd()();\n  }\n  if (rf & 2) {\n    const ctx_r2 = i0.ɵɵnextContext();\n    i0.ɵɵadvance(3);\n    i0.ɵɵtextInterpolate(ctx_r2.errorMessage);\n  }\n}\nfunction RelaysComponent_Conditional_13_Template(rf, ctx) {\n  if (rf & 1) {\n    i0.ɵɵelementStart(0, \"div\", 8);\n    i0.ɵɵelement(1, \"i\", 16);\n    i0.ɵɵelementStart(2, \"span\");\n    i0.ɵɵtext(3, \"No relay list found\");\n    i0.ɵɵelementEnd();\n    i0.ɵɵelementStart(4, \"span\", 17);\n    i0.ɵɵtext(5, \"Publish a NIP-65 relay list using a Nostr client to see your relays here.\");\n    i0.ɵɵelementEnd()();\n  }\n}\nfunction RelaysComponent_For_15_ng_container_0_Template(rf, ctx) {\n  if (rf & 1) {\n    i0.ɵɵelementContainer(0);\n  }\n}\nfunction RelaysComponent_For_15_Template(rf, ctx) {\n  if (rf & 1) {\n    i0.ɵɵtemplate(0, RelaysComponent_For_15_ng_container_0_Template, 1, 0, \"ng-container\", 18);\n  }\n  if (rf & 2) {\n    const relay_r4 = ctx.$implicit;\n    i0.ɵɵnextContext();\n    const relayTemplate_r5 = i0.ɵɵreference(1);\n    i0.ɵɵproperty(\"ngTemplateOutlet\", relayTemplate_r5)(\"ngTemplateOutletContext\", i0.ɵɵpureFunction1(2, _c0, relay_r4));\n  }\n}\nexport let RelaysComponent = /*#__PURE__*/(() => {\n  class RelaysComponent extends NavComponent {\n    identity;\n    relays = [];\n    loading = true;\n    errorMessage = '';\n    #activatedRoute = inject(ActivatedRoute);\n    #storage = inject(StorageService);\n    #relayListService = inject(RelayListService);\n    ngOnInit() {\n      const selectedIdentityId = this.#activatedRoute.parent?.snapshot.params['id'];\n      if (!selectedIdentityId) {\n        this.loading = false;\n        return;\n      }\n      this.#loadData(selectedIdentityId);\n    }\n    #loadData(identityId) {\n      var _this = this;\n      return _asyncToGenerator(function* () {\n        try {\n          _this.loading = true;\n          _this.errorMessage = '';\n          _this.identity = _this.#storage.getBrowserSessionHandler().browserSessionData?.identities.find(x => x.id === identityId);\n          if (!_this.identity) {\n            _this.loading = false;\n            _this.errorMessage = 'Identity not found';\n            return;\n          }\n          // Get the pubkey for this identity\n          const pubkey = NostrHelper.pubkeyFromPrivkey(_this.identity.privkey);\n          // Fetch NIP-65 relay list\n          const nip65Relays = yield _this.#relayListService.fetchRelayList(pubkey);\n          _this.relays = nip65Relays;\n          _this.loading = false;\n        } catch (error) {\n          console.error('Failed to load relay list:', error);\n          _this.loading = false;\n          _this.errorMessage = 'Failed to fetch relay list';\n        }\n      })();\n    }\n    static ɵfac = /*@__PURE__*/(() => {\n      let ɵRelaysComponent_BaseFactory;\n      return function RelaysComponent_Factory(__ngFactoryType__) {\n        return (ɵRelaysComponent_BaseFactory || (ɵRelaysComponent_BaseFactory = i0.ɵɵgetInheritedFactory(RelaysComponent)))(__ngFactoryType__ || RelaysComponent);\n      };\n    })();\n    static ɵcmp = /*@__PURE__*/i0.ɵɵdefineComponent({\n      type: RelaysComponent,\n      selectors: [[\"app-relays\"]],\n      features: [i0.ɵɵInheritDefinitionFeature],\n      decls: 16,\n      vars: 3,\n      consts: [[\"relayTemplate\", \"\"], [1, \"header-pane\"], [\"icon\", \"chevron-left\", 3, \"click\"], [1, \"header-title\"], [1, \"info-banner\"], [1, \"emoji\"], [1, \"loading-state\"], [1, \"error-state\"], [1, \"empty-state\"], [1, \"sam-flex-row\", \"gap\", \"relay\"], [1, \"sam-flex-column\", \"sam-flex-grow\"], [1, \"sam-flex-row\", \"gap-h\"], [\"type\", \"read\", 3, \"model\", \"readonly\"], [\"type\", \"write\", 3, \"model\", \"readonly\"], [1, \"bi\", \"bi-circle\", \"color-activity\"], [1, \"bi\", \"bi-exclamation-triangle\", \"sam-color-danger\"], [1, \"bi\", \"bi-broadcast\"], [1, \"hint\"], [4, \"ngTemplateOutlet\", \"ngTemplateOutletContext\"]],\n      template: function RelaysComponent_Template(rf, ctx) {\n        if (rf & 1) {\n          const _r1 = i0.ɵɵgetCurrentView();\n          i0.ɵɵtemplate(0, RelaysComponent_ng_template_0_Template, 8, 7, \"ng-template\", null, 0, i0.ɵɵtemplateRefExtractor);\n          i0.ɵɵelementStart(2, \"div\", 1)(3, \"lib-icon-button\", 2);\n          i0.ɵɵlistener(\"click\", function RelaysComponent_Template_lib_icon_button_click_3_listener() {\n            i0.ɵɵrestoreView(_r1);\n            return i0.ɵɵresetView(ctx.navigateBack());\n          });\n          i0.ɵɵelementEnd();\n          i0.ɵɵelementStart(4, \"span\", 3);\n          i0.ɵɵtext(5, \"Relays\");\n          i0.ɵɵelementEnd()();\n          i0.ɵɵelementStart(6, \"div\", 4)(7, \"span\", 5);\n          i0.ɵɵtext(8, \"\\uD83D\\uDCA1\");\n          i0.ɵɵelementEnd();\n          i0.ɵɵelementStart(9, \"span\");\n          i0.ɵɵtext(10, \"These relays are fetched from your NIP-65 relay list (kind 10002). To update your relay list, use a Nostr client that supports NIP-65.\");\n          i0.ɵɵelementEnd()();\n          i0.ɵɵtemplate(11, RelaysComponent_Conditional_11_Template, 4, 0, \"div\", 6)(12, RelaysComponent_Conditional_12_Template, 4, 1, \"div\", 7)(13, RelaysComponent_Conditional_13_Template, 6, 0, \"div\", 8);\n          i0.ɵɵrepeaterCreate(14, RelaysComponent_For_15_Template, 1, 4, \"ng-container\", null, _forTrack0);\n        }\n        if (rf & 2) {\n          i0.ɵɵadvance(11);\n          i0.ɵɵconditional(ctx.loading ? 11 : -1);\n          i0.ɵɵadvance();\n          i0.ɵɵconditional(!ctx.loading && ctx.errorMessage ? 12 : -1);\n          i0.ɵɵadvance();\n          i0.ɵɵconditional(!ctx.loading && !ctx.errorMessage && ctx.relays.length === 0 ? 13 : -1);\n          i0.ɵɵadvance();\n          i0.ɵɵrepeater(ctx.relays);\n        }\n      },\n      dependencies: [IconButtonComponent, RelayRwComponent, NgTemplateOutlet, VisualRelayPipe],\n      styles: [\"[_nghost-%COMP%] {\\n  height: 100%;\\n  overflow-y: auto;\\n  display: flex;\\n  flex-direction: column;\\n  padding-left: var(--size);\\n  padding-right: var(--size);\\n}\\n[_nghost-%COMP%]   .header-pane[_ngcontent-%COMP%] {\\n  display: flex;\\n  flex-direction: row;\\n  column-gap: var(--size-h);\\n  align-items: center;\\n  padding-bottom: var(--size);\\n  background-color: var(--background);\\n  position: sticky;\\n  top: 0;\\n}\\n[_nghost-%COMP%]   .header-title[_ngcontent-%COMP%] {\\n  font-family: var(--font-heading);\\n  font-size: 20px;\\n  font-weight: 700;\\n  letter-spacing: 0.05rem;\\n}\\n[_nghost-%COMP%]   .info-banner[_ngcontent-%COMP%] {\\n  display: flex;\\n  flex-direction: row;\\n  align-items: flex-start;\\n  gap: var(--size-h);\\n  padding: var(--size-h) var(--size);\\n  margin-bottom: var(--size);\\n  background: var(--background-light);\\n  border-radius: var(--radius-md);\\n  border: 1px solid var(--border);\\n}\\n[_nghost-%COMP%]   .info-banner[_ngcontent-%COMP%]   i[_ngcontent-%COMP%] {\\n  color: var(--primary);\\n  font-size: 14px;\\n  margin-top: 2px;\\n}\\n[_nghost-%COMP%]   .info-banner[_ngcontent-%COMP%]   span[_ngcontent-%COMP%] {\\n  font-size: 12px;\\n  color: var(--muted-foreground);\\n  line-height: 1.4;\\n}\\n[_nghost-%COMP%]   .loading-state[_ngcontent-%COMP%], \\n[_nghost-%COMP%]   .empty-state[_ngcontent-%COMP%], \\n[_nghost-%COMP%]   .error-state[_ngcontent-%COMP%] {\\n  display: flex;\\n  flex-direction: column;\\n  align-items: center;\\n  justify-content: center;\\n  gap: var(--size-h);\\n  padding: var(--size-2);\\n  color: var(--muted-foreground);\\n}\\n[_nghost-%COMP%]   .loading-state[_ngcontent-%COMP%]   i[_ngcontent-%COMP%], \\n[_nghost-%COMP%]   .empty-state[_ngcontent-%COMP%]   i[_ngcontent-%COMP%], \\n[_nghost-%COMP%]   .error-state[_ngcontent-%COMP%]   i[_ngcontent-%COMP%] {\\n  font-size: 32px;\\n}\\n[_nghost-%COMP%]   .loading-state[_ngcontent-%COMP%]   span[_ngcontent-%COMP%], \\n[_nghost-%COMP%]   .empty-state[_ngcontent-%COMP%]   span[_ngcontent-%COMP%], \\n[_nghost-%COMP%]   .error-state[_ngcontent-%COMP%]   span[_ngcontent-%COMP%] {\\n  font-size: 14px;\\n}\\n[_nghost-%COMP%]   .loading-state[_ngcontent-%COMP%]   .hint[_ngcontent-%COMP%], \\n[_nghost-%COMP%]   .empty-state[_ngcontent-%COMP%]   .hint[_ngcontent-%COMP%], \\n[_nghost-%COMP%]   .error-state[_ngcontent-%COMP%]   .hint[_ngcontent-%COMP%] {\\n  font-size: 12px;\\n  text-align: center;\\n  max-width: 280px;\\n}\\n[_nghost-%COMP%]   .color-activity[_ngcontent-%COMP%] {\\n  color: var(--muted-foreground);\\n  animation: _ngcontent-%COMP%_pulse 1.5s infinite;\\n}\\n@keyframes _ngcontent-%COMP%_pulse {\\n  0%, 100% {\\n    opacity: 0.4;\\n  }\\n  50% {\\n    opacity: 1;\\n  }\\n}\\n[_nghost-%COMP%]   .relay[_ngcontent-%COMP%] {\\n  margin-bottom: 4px;\\n  padding: 4px 8px 6px 8px;\\n  border-radius: 8px;\\n  background: var(--background-light);\\n}\"]\n    });\n  }\n  return RelaysComponent;\n})();","map":null,"metadata":{},"sourceType":"module","externalDependencies":[]}