badc0878ae38e4f3241a4dbbdc914d2c6c859a722d02769f8430f97c6d5ee755.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 { inject } from '@angular/core';\nimport { Router } from '@angular/router';\nimport { ConfirmComponent, NavComponent, StorageService, ToastComponent } from '@common';\nimport browser from 'webextension-polyfill';\nimport * as i0 from \"@angular/core\";\nconst _c0 = [\"toast\"];\nconst _c1 = [\"confirm\"];\nfunction WhitelistedAppsComponent_Conditional_11_Conditional_3_Template(rf, ctx) {\n  if (rf & 1) {\n    i0.ɵɵelementStart(0, \"div\", 13)(1, \"span\");\n    i0.ɵɵtext(2, \"\\u26A0 All sites will be auto-approved without prompting\");\n    i0.ɵɵelementEnd()();\n  }\n}\nfunction WhitelistedAppsComponent_Conditional_11_Template(rf, ctx) {\n  if (rf & 1) {\n    i0.ɵɵelementStart(0, \"div\", 11)(1, \"span\", 12);\n    i0.ɵɵtext(2, \"No whitelisted apps yet\");\n    i0.ɵɵelementEnd()();\n    i0.ɵɵtemplate(3, WhitelistedAppsComponent_Conditional_11_Conditional_3_Template, 3, 0, \"div\", 13);\n  }\n  if (rf & 2) {\n    const ctx_r1 = i0.ɵɵnextContext();\n    i0.ɵɵadvance(3);\n    i0.ɵɵconditional(ctx_r1.isRecklessMode ? 3 : -1);\n  }\n}\nfunction WhitelistedAppsComponent_For_13_Template(rf, ctx) {\n  if (rf & 1) {\n    const _r3 = i0.ɵɵgetCurrentView();\n    i0.ɵɵelementStart(0, \"div\", 10)(1, \"span\", 14);\n    i0.ɵɵtext(2);\n    i0.ɵɵelementEnd();\n    i0.ɵɵelementStart(3, \"button\", 15);\n    i0.ɵɵlistener(\"click\", function WhitelistedAppsComponent_For_13_Template_button_click_3_listener() {\n      const host_r4 = i0.ɵɵrestoreView(_r3).$implicit;\n      const ctx_r1 = i0.ɵɵnextContext();\n      return i0.ɵɵresetView(ctx_r1.onClickRemoveHost(host_r4));\n    });\n    i0.ɵɵelement(4, \"i\", 16);\n    i0.ɵɵelementEnd()();\n  }\n  if (rf & 2) {\n    const host_r4 = ctx.$implicit;\n    i0.ɵɵadvance(2);\n    i0.ɵɵtextInterpolate(host_r4);\n  }\n}\nexport let WhitelistedAppsComponent = /*#__PURE__*/(() => {\n  class WhitelistedAppsComponent extends NavComponent {\n    toast;\n    confirm;\n    storage = inject(StorageService);\n    #router = inject(Router);\n    get whitelistedHosts() {\n      return this.storage.getSignerMetaHandler().signerMetaData?.whitelistedHosts ?? [];\n    }\n    get isRecklessMode() {\n      return this.storage.getSignerMetaHandler().signerMetaData?.recklessMode ?? false;\n    }\n    onClickWhitelistCurrentTab() {\n      var _this = this;\n      return _asyncToGenerator(function* () {\n        try {\n          // Get current active tab\n          const tabs = yield browser.tabs.query({\n            active: true,\n            currentWindow: true\n          });\n          if (tabs.length === 0 || !tabs[0].url) {\n            _this.toast.show('No active tab found');\n            return;\n          }\n          const url = new URL(tabs[0].url);\n          const host = url.host;\n          if (!host) {\n            _this.toast.show('Cannot get host from current tab');\n            return;\n          }\n          // Check if already whitelisted\n          if (_this.whitelistedHosts.includes(host)) {\n            _this.toast.show(`${host} is already whitelisted`);\n            return;\n          }\n          yield _this.storage.getSignerMetaHandler().addWhitelistedHost(host);\n          _this.toast.show(`Added ${host} to whitelist`);\n        } catch (error) {\n          console.error('Error getting current tab:', error);\n          _this.toast.show('Error getting current tab');\n        }\n      })();\n    }\n    onClickRemoveHost(host) {\n      var _this2 = this;\n      this.confirm.show(`Remove ${host} from whitelist?`, /*#__PURE__*/_asyncToGenerator(function* () {\n        yield _this2.storage.getSignerMetaHandler().removeWhitelistedHost(host);\n        _this2.toast.show(`Removed ${host} from whitelist`);\n      }));\n    }\n    onClickBack() {\n      this.#router.navigateByUrl('/home/identities');\n    }\n    static ɵfac = /*@__PURE__*/(() => {\n      let ɵWhitelistedAppsComponent_BaseFactory;\n      return function WhitelistedAppsComponent_Factory(__ngFactoryType__) {\n        return (ɵWhitelistedAppsComponent_BaseFactory || (ɵWhitelistedAppsComponent_BaseFactory = i0.ɵɵgetInheritedFactory(WhitelistedAppsComponent)))(__ngFactoryType__ || WhitelistedAppsComponent);\n      };\n    })();\n    static ɵcmp = /*@__PURE__*/i0.ɵɵdefineComponent({\n      type: WhitelistedAppsComponent,\n      selectors: [[\"app-whitelisted-apps\"]],\n      viewQuery: function WhitelistedAppsComponent_Query(rf, ctx) {\n        if (rf & 1) {\n          i0.ɵɵviewQuery(_c0, 5);\n          i0.ɵɵviewQuery(_c1, 5);\n        }\n        if (rf & 2) {\n          let _t;\n          i0.ɵɵqueryRefresh(_t = i0.ɵɵloadQuery()) && (ctx.toast = _t.first);\n          i0.ɵɵqueryRefresh(_t = i0.ɵɵloadQuery()) && (ctx.confirm = _t.first);\n        }\n      },\n      features: [i0.ɵɵInheritDefinitionFeature],\n      decls: 18,\n      vars: 1,\n      consts: [[\"toast\", \"\"], [\"confirm\", \"\"], [1, \"custom-header\"], [1, \"back-btn\", 3, \"click\"], [1, \"bi\", \"bi-chevron-left\"], [1, \"text\"], [1, \"content\"], [1, \"btn\", \"btn-primary\", \"whitelist-btn\", 3, \"click\"], [1, \"bi\", \"bi-plus-lg\"], [1, \"hosts-list\"], [1, \"host-item\"], [1, \"empty-state\"], [1, \"sam-text-muted\"], [1, \"warning-note\"], [1, \"host-name\"], [\"title\", \"Remove from whitelist\", 1, \"remove-btn\", 3, \"click\"], [1, \"bi\", \"bi-trash\"]],\n      template: function WhitelistedAppsComponent_Template(rf, ctx) {\n        if (rf & 1) {\n          const _r1 = i0.ɵɵgetCurrentView();\n          i0.ɵɵelementStart(0, \"div\", 2)(1, \"button\", 3);\n          i0.ɵɵlistener(\"click\", function WhitelistedAppsComponent_Template_button_click_1_listener() {\n            i0.ɵɵrestoreView(_r1);\n            return i0.ɵɵresetView(ctx.onClickBack());\n          });\n          i0.ɵɵelement(2, \"i\", 4);\n          i0.ɵɵelementEnd();\n          i0.ɵɵelementStart(3, \"span\", 5);\n          i0.ɵɵtext(4, \"Whitelisted Apps\");\n          i0.ɵɵelementEnd()();\n          i0.ɵɵelementStart(5, \"div\", 6)(6, \"button\", 7);\n          i0.ɵɵlistener(\"click\", function WhitelistedAppsComponent_Template_button_click_6_listener() {\n            i0.ɵɵrestoreView(_r1);\n            return i0.ɵɵresetView(ctx.onClickWhitelistCurrentTab());\n          });\n          i0.ɵɵelement(7, \"i\", 8);\n          i0.ɵɵelementStart(8, \"span\");\n          i0.ɵɵtext(9, \"Whitelist current tab\");\n          i0.ɵɵelementEnd()();\n          i0.ɵɵelementStart(10, \"div\", 9);\n          i0.ɵɵtemplate(11, WhitelistedAppsComponent_Conditional_11_Template, 4, 1);\n          i0.ɵɵrepeaterCreate(12, WhitelistedAppsComponent_For_13_Template, 5, 1, \"div\", 10, i0.ɵɵrepeaterTrackByIdentity);\n          i0.ɵɵelementEnd()();\n          i0.ɵɵelement(14, \"lib-toast\", null, 0)(16, \"lib-confirm\", null, 1);\n        }\n        if (rf & 2) {\n          i0.ɵɵadvance(11);\n          i0.ɵɵconditional(ctx.whitelistedHosts.length === 0 ? 11 : -1);\n          i0.ɵɵadvance();\n          i0.ɵɵrepeater(ctx.whitelistedHosts);\n        }\n      },\n      dependencies: [ToastComponent, ConfirmComponent],\n      styles: [\"[_nghost-%COMP%] {\\n  height: 100%;\\n  display: flex;\\n  flex-direction: column;\\n  overflow-y: auto;\\n}\\n[_nghost-%COMP%]   .custom-header[_ngcontent-%COMP%] {\\n  padding: var(--size);\\n  display: grid;\\n  grid-template-columns: 1fr;\\n  grid-template-rows: auto;\\n  align-items: center;\\n  background: var(--background);\\n  position: sticky;\\n  top: 0;\\n  z-index: 10;\\n}\\n[_nghost-%COMP%]   .custom-header[_ngcontent-%COMP%]   .back-btn[_ngcontent-%COMP%] {\\n  grid-column-start: 1;\\n  grid-column-end: 2;\\n  grid-row-start: 1;\\n  grid-row-end: 2;\\n  justify-self: start;\\n  background: transparent;\\n  border: none;\\n  color: var(--foreground);\\n  padding: 4px 8px;\\n  cursor: pointer;\\n  border-radius: 4px;\\n  z-index: 1;\\n}\\n[_nghost-%COMP%]   .custom-header[_ngcontent-%COMP%]   .back-btn[_ngcontent-%COMP%]:hover {\\n  background: var(--background-light);\\n}\\n[_nghost-%COMP%]   .custom-header[_ngcontent-%COMP%]   .back-btn[_ngcontent-%COMP%]   i[_ngcontent-%COMP%] {\\n  font-size: 20px;\\n}\\n[_nghost-%COMP%]   .custom-header[_ngcontent-%COMP%]   .text[_ngcontent-%COMP%] {\\n  grid-column-start: 1;\\n  grid-column-end: 2;\\n  grid-row-start: 1;\\n  grid-row-end: 2;\\n  font-family: var(--font-heading);\\n  font-size: 20px;\\n  font-weight: 700;\\n  letter-spacing: 0.05rem;\\n  justify-self: center;\\n}\\n[_nghost-%COMP%]   .content[_ngcontent-%COMP%] {\\n  padding: 0 var(--size) var(--size) var(--size);\\n  flex-grow: 1;\\n  display: flex;\\n  flex-direction: column;\\n}\\n[_nghost-%COMP%]   .content[_ngcontent-%COMP%]   .whitelist-btn[_ngcontent-%COMP%] {\\n  display: flex;\\n  flex-direction: row;\\n  align-items: center;\\n  justify-content: center;\\n  gap: 8px;\\n  margin-bottom: var(--size);\\n}\\n[_nghost-%COMP%]   .content[_ngcontent-%COMP%]   .hosts-list[_ngcontent-%COMP%] {\\n  flex-grow: 1;\\n}\\n[_nghost-%COMP%]   .content[_ngcontent-%COMP%]   .hosts-list[_ngcontent-%COMP%]   .empty-state[_ngcontent-%COMP%] {\\n  display: flex;\\n  align-items: center;\\n  justify-content: center;\\n  padding: 32px;\\n  text-align: center;\\n}\\n[_nghost-%COMP%]   .content[_ngcontent-%COMP%]   .hosts-list[_ngcontent-%COMP%]   .warning-note[_ngcontent-%COMP%] {\\n  display: flex;\\n  align-items: center;\\n  justify-content: center;\\n  padding: 12px;\\n  background: rgba(255, 193, 7, 0.15);\\n  border: 1px solid rgba(255, 193, 7, 0.4);\\n  border-radius: 8px;\\n  text-align: center;\\n}\\n[_nghost-%COMP%]   .content[_ngcontent-%COMP%]   .hosts-list[_ngcontent-%COMP%]   .warning-note[_ngcontent-%COMP%]   span[_ngcontent-%COMP%] {\\n  font-size: 13px;\\n  color: #ffc107;\\n}\\n[_nghost-%COMP%]   .content[_ngcontent-%COMP%]   .hosts-list[_ngcontent-%COMP%]   .host-item[_ngcontent-%COMP%] {\\n  display: flex;\\n  flex-direction: row;\\n  align-items: center;\\n  justify-content: space-between;\\n  padding: 12px;\\n  background: var(--background-light);\\n  border-radius: 8px;\\n  margin-bottom: 8px;\\n}\\n[_nghost-%COMP%]   .content[_ngcontent-%COMP%]   .hosts-list[_ngcontent-%COMP%]   .host-item[_ngcontent-%COMP%]   .host-name[_ngcontent-%COMP%] {\\n  font-size: 14px;\\n  overflow: hidden;\\n  text-overflow: ellipsis;\\n  white-space: nowrap;\\n}\\n[_nghost-%COMP%]   .content[_ngcontent-%COMP%]   .hosts-list[_ngcontent-%COMP%]   .host-item[_ngcontent-%COMP%]   .remove-btn[_ngcontent-%COMP%] {\\n  background: transparent;\\n  border: none;\\n  color: var(--muted-foreground);\\n  padding: 4px 8px;\\n  cursor: pointer;\\n  border-radius: 4px;\\n  transition: color 0.15s ease, background-color 0.15s ease;\\n}\\n[_nghost-%COMP%]   .content[_ngcontent-%COMP%]   .hosts-list[_ngcontent-%COMP%]   .host-item[_ngcontent-%COMP%]   .remove-btn[_ngcontent-%COMP%]:hover {\\n  color: var(--destructive);\\n  background: var(--background-light-hover);\\n}\\n[_nghost-%COMP%]   .content[_ngcontent-%COMP%]   .hosts-list[_ngcontent-%COMP%]   .host-item[_ngcontent-%COMP%]   .remove-btn[_ngcontent-%COMP%]   i[_ngcontent-%COMP%] {\\n  font-size: 14px;\\n}\"]\n    });\n  }\n  return WhitelistedAppsComponent;\n})();","map":null,"metadata":{},"sourceType":"module","externalDependencies":[]}