050103e83ce221d455aeb7ef92d71a1656495face8dcd92d8f31c11a7b3c6cdf.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 { IconButtonComponent, LoggerService, NavComponent, NostrHelper, ProfileMetadataService, StorageService, ToastComponent } from '@common';\nimport * as i0 from \"@angular/core\";\nconst _c0 = () => [];\nconst _forTrack0 = ($index, $item) => $item.id;\nfunction IdentitiesComponent_Conditional_5_Template(rf, ctx) {\n if (rf & 1) {\n const _r2 = i0.ɵɵgetCurrentView();\n i0.ɵɵelementStart(0, \"button\", 15);\n i0.ɵɵlistener(\"click\", function IdentitiesComponent_Conditional_5_Template_button_click_0_listener() {\n i0.ɵɵrestoreView(_r2);\n const ctx_r2 = i0.ɵɵnextContext();\n return i0.ɵɵresetView(ctx_r2.onTestPrompt());\n });\n i0.ɵɵelementStart(1, \"span\", 4);\n i0.ɵɵtext(2, \"\\u2728\");\n i0.ɵɵelementEnd()();\n }\n}\nfunction IdentitiesComponent_Conditional_21_Template(rf, ctx) {\n if (rf & 1) {\n i0.ɵɵelementStart(0, \"div\", 13)(1, \"span\", 16);\n i0.ɵɵtext(2, \" Create your first identity by clicking on the button in the upper right corner. \");\n i0.ɵɵelementEnd()();\n }\n}\nfunction IdentitiesComponent_For_23_Template(rf, ctx) {\n if (rf & 1) {\n const _r4 = i0.ɵɵgetCurrentView();\n i0.ɵɵdeclareLet(0);\n i0.ɵɵelementStart(1, \"div\", 17);\n i0.ɵɵlistener(\"click\", function IdentitiesComponent_For_23_Template_div_click_1_listener() {\n const identity_r5 = i0.ɵɵrestoreView(_r4).$implicit;\n const ctx_r2 = i0.ɵɵnextContext();\n return i0.ɵɵresetView(ctx_r2.onClickSelectIdentity(identity_r5.id));\n });\n i0.ɵɵelementStart(2, \"img\", 18);\n i0.ɵɵlistener(\"error\", function IdentitiesComponent_For_23_Template_img_error_2_listener($event) {\n i0.ɵɵrestoreView(_r4);\n return i0.ɵɵresetView($event.target.src = \"person-fill.svg\");\n });\n i0.ɵɵelementEnd();\n i0.ɵɵelementStart(3, \"span\", 19);\n i0.ɵɵtext(4);\n i0.ɵɵelementEnd();\n i0.ɵɵelementStart(5, \"lib-icon-button\", 20);\n i0.ɵɵlistener(\"click\", function IdentitiesComponent_For_23_Template_lib_icon_button_click_5_listener($event) {\n const identity_r5 = i0.ɵɵrestoreView(_r4).$implicit;\n const ctx_r2 = i0.ɵɵnextContext();\n return i0.ɵɵresetView(ctx_r2.onClickEditIdentity(identity_r5.id, $event));\n });\n i0.ɵɵelementEnd()();\n }\n if (rf & 2) {\n const identity_r5 = ctx.$implicit;\n const ctx_r2 = i0.ɵɵnextContext();\n const sessionData_r6 = i0.ɵɵreadContextLet(19);\n const isSelected_r7 = identity_r5.id === (sessionData_r6 == null ? null : sessionData_r6.selectedIdentityId);\n i0.ɵɵadvance();\n i0.ɵɵclassProp(\"selected\", isSelected_r7);\n i0.ɵɵadvance();\n i0.ɵɵproperty(\"src\", ctx_r2.getAvatarUrl(identity_r5), i0.ɵɵsanitizeUrl);\n i0.ɵɵadvance(2);\n i0.ɵɵtextInterpolate(ctx_r2.getDisplayName(identity_r5));\n }\n}\nexport let IdentitiesComponent = /*#__PURE__*/(() => {\n class IdentitiesComponent extends NavComponent {\n storage = inject(StorageService);\n #router = inject(Router);\n #profileMetadata = inject(ProfileMetadataService);\n #logger = inject(LoggerService);\n // Cache of pubkey -> profile for quick lookup\n #profileCache = new Map();\n get isRecklessMode() {\n return this.storage.getSignerMetaHandler().signerMetaData?.recklessMode ?? false;\n }\n ngOnInit() {\n var _this = this;\n return _asyncToGenerator(function* () {\n yield _this.#profileMetadata.initialize();\n _this.#loadProfiles();\n })();\n }\n #loadProfiles() {\n const identities = this.storage.getBrowserSessionHandler().browserSessionData?.identities ?? [];\n for (const identity of identities) {\n const pubkey = NostrHelper.pubkeyFromPrivkey(identity.privkey);\n const profile = this.#profileMetadata.getCachedProfile(pubkey);\n this.#profileCache.set(identity.id, profile);\n }\n }\n getAvatarUrl(identity) {\n const profile = this.#profileCache.get(identity.id);\n return profile?.picture || 'person-fill.svg';\n }\n getDisplayName(identity) {\n const profile = this.#profileCache.get(identity.id) ?? null;\n return this.#profileMetadata.getDisplayName(profile) || identity.nick;\n }\n onClickNewIdentity() {\n this.#router.navigateByUrl('/new-identity');\n }\n onClickEditIdentity(identityId, event) {\n event.stopPropagation();\n this.#router.navigateByUrl(`/edit-identity/${identityId}/home`);\n }\n onClickSelectIdentity(identityId) {\n var _this2 = this;\n return _asyncToGenerator(function* () {\n yield _this2.storage.switchIdentity(identityId);\n })();\n }\n onToggleRecklessMode() {\n var _this3 = this;\n return _asyncToGenerator(function* () {\n const newValue = !_this3.isRecklessMode;\n yield _this3.storage.getSignerMetaHandler().setRecklessMode(newValue);\n })();\n }\n onClickWhitelistedApps() {\n this.#router.navigateByUrl('/whitelisted-apps');\n }\n onClickLock() {\n var _this4 = this;\n return _asyncToGenerator(function* () {\n _this4.#logger.logVaultLock();\n yield _this4.storage.lockVault();\n _this4.#router.navigateByUrl('/vault-login');\n })();\n }\n static ɵfac = /*@__PURE__*/(() => {\n let ɵIdentitiesComponent_BaseFactory;\n return function IdentitiesComponent_Factory(__ngFactoryType__) {\n return (ɵIdentitiesComponent_BaseFactory || (ɵIdentitiesComponent_BaseFactory = i0.ɵɵgetInheritedFactory(IdentitiesComponent)))(__ngFactoryType__ || IdentitiesComponent);\n };\n })();\n static ɵcmp = /*@__PURE__*/i0.ɵɵdefineComponent({\n type: IdentitiesComponent,\n selectors: [[\"app-identities\"]],\n features: [i0.ɵɵInheritDefinitionFeature],\n decls: 26,\n vars: 5,\n consts: [[\"toast\", \"\"], [1, \"custom-header\", 2, \"position\", \"sticky\", \"top\", \"0\"], [1, \"header-buttons\"], [\"title\", \"Lock\", 1, \"header-btn\", 3, \"click\"], [1, \"emoji\"], [\"title\", \"Test Permission Prompt\", 1, \"header-btn\"], [1, \"text\"], [\"title\", \"New Identity\", 1, \"add-btn\", 3, \"click\"], [1, \"reckless-mode-row\"], [1, \"reckless-label\", 3, \"click\"], [\"type\", \"checkbox\", 3, \"click\", \"change\", \"checked\"], [\"data-bs-toggle\", \"tooltip\", \"data-bs-placement\", \"bottom\", \"title\", \"Auto-approve all actions. If whitelist has entries, only those apps are auto-approved.\", 1, \"reckless-text\"], [\"title\", \"Manage whitelisted apps\", 1, \"gear-btn\", 3, \"click\"], [1, \"empty-state\"], [1, \"identity\", 3, \"selected\"], [\"title\", \"Test Permission Prompt\", 1, \"header-btn\", 3, \"click\"], [1, \"sam-text-muted\"], [1, \"identity\", 3, \"click\"], [\"alt\", \"\", 1, \"avatar\", 3, \"error\", \"src\"], [1, \"name\"], [\"icon\", \"\\u2699\\uFE0F\", \"title\", \"Identity settings\", 3, \"click\"]],\n template: function IdentitiesComponent_Template(rf, ctx) {\n if (rf & 1) {\n const _r1 = i0.ɵɵgetCurrentView();\n i0.ɵɵelementStart(0, \"div\", 1)(1, \"div\", 2)(2, \"button\", 3);\n i0.ɵɵlistener(\"click\", function IdentitiesComponent_Template_button_click_2_listener() {\n i0.ɵɵrestoreView(_r1);\n return i0.ɵɵresetView(ctx.onClickLock());\n });\n i0.ɵɵelementStart(3, \"span\", 4);\n i0.ɵɵtext(4, \"\\uD83D\\uDD12\");\n i0.ɵɵelementEnd()();\n i0.ɵɵtemplate(5, IdentitiesComponent_Conditional_5_Template, 3, 0, \"button\", 5);\n i0.ɵɵelementEnd();\n i0.ɵɵelementStart(6, \"span\", 6);\n i0.ɵɵtext(7, \"Identities\");\n i0.ɵɵelementEnd();\n i0.ɵɵelementStart(8, \"button\", 7);\n i0.ɵɵlistener(\"click\", function IdentitiesComponent_Template_button_click_8_listener() {\n i0.ɵɵrestoreView(_r1);\n return i0.ɵɵresetView(ctx.onClickNewIdentity());\n });\n i0.ɵɵelementStart(9, \"span\", 4);\n i0.ɵɵtext(10, \"\\u2795\");\n i0.ɵɵelementEnd()()();\n i0.ɵɵelementStart(11, \"div\", 8)(12, \"label\", 9);\n i0.ɵɵlistener(\"click\", function IdentitiesComponent_Template_label_click_12_listener() {\n i0.ɵɵrestoreView(_r1);\n return i0.ɵɵresetView(ctx.onToggleRecklessMode());\n });\n i0.ɵɵelementStart(13, \"input\", 10);\n i0.ɵɵlistener(\"click\", function IdentitiesComponent_Template_input_click_13_listener($event) {\n i0.ɵɵrestoreView(_r1);\n return i0.ɵɵresetView($event.stopPropagation());\n })(\"change\", function IdentitiesComponent_Template_input_change_13_listener() {\n i0.ɵɵrestoreView(_r1);\n return i0.ɵɵresetView(ctx.onToggleRecklessMode());\n });\n i0.ɵɵelementEnd();\n i0.ɵɵelementStart(14, \"span\", 11);\n i0.ɵɵtext(15, \"Reckless mode\");\n i0.ɵɵelementEnd()();\n i0.ɵɵelementStart(16, \"button\", 12);\n i0.ɵɵlistener(\"click\", function IdentitiesComponent_Template_button_click_16_listener() {\n i0.ɵɵrestoreView(_r1);\n return i0.ɵɵresetView(ctx.onClickWhitelistedApps());\n });\n i0.ɵɵelementStart(17, \"span\", 4);\n i0.ɵɵtext(18, \"\\u2699\\uFE0F\");\n i0.ɵɵelementEnd()()();\n i0.ɵɵdeclareLet(19)(20);\n i0.ɵɵtemplate(21, IdentitiesComponent_Conditional_21_Template, 3, 0, \"div\", 13);\n i0.ɵɵrepeaterCreate(22, IdentitiesComponent_For_23_Template, 6, 4, \"div\", 14, _forTrack0);\n i0.ɵɵelement(24, \"lib-toast\", null, 0);\n }\n if (rf & 2) {\n let tmp_4_0;\n i0.ɵɵadvance(5);\n i0.ɵɵconditional(ctx.devMode ? 5 : -1);\n i0.ɵɵadvance(8);\n i0.ɵɵproperty(\"checked\", ctx.isRecklessMode);\n i0.ɵɵadvance(6);\n const sessionData_r8 = i0.ɵɵstoreLet(ctx.storage.getBrowserSessionHandler().browserSessionData);\n const identities_r9 = (tmp_4_0 = sessionData_r8 == null ? null : sessionData_r8.identities) !== null && tmp_4_0 !== undefined ? tmp_4_0 : i0.ɵɵpureFunction0(4, _c0);\n i0.ɵɵadvance(2);\n i0.ɵɵconditional(identities_r9.length === 0 ? 21 : -1);\n i0.ɵɵadvance();\n i0.ɵɵrepeater(identities_r9);\n }\n },\n dependencies: [IconButtonComponent, ToastComponent],\n styles: [\"[_nghost-%COMP%] {\\n height: 100%;\\n display: flex;\\n flex-direction: column;\\n overflow-y: auto;\\n}\\n[_nghost-%COMP%] > *[_ngcontent-%COMP%]:not(.custom-header) {\\n margin-left: var(--size);\\n margin-right: var(--size);\\n}\\n[_nghost-%COMP%] .custom-header[_ngcontent-%COMP%] {\\n height: 48px;\\n min-height: 48px;\\n display: grid;\\n grid-template-columns: 1fr;\\n grid-template-rows: auto;\\n align-items: center;\\n background: var(--background);\\n position: relative;\\n}\\n[_nghost-%COMP%] .custom-header[_ngcontent-%COMP%] .header-buttons[_ngcontent-%COMP%] {\\n position: absolute;\\n left: 0;\\n display: flex;\\n flex-direction: row;\\n align-items: center;\\n}\\n[_nghost-%COMP%] .custom-header[_ngcontent-%COMP%] .header-btn[_ngcontent-%COMP%], \\n[_nghost-%COMP%] .custom-header[_ngcontent-%COMP%] .add-btn[_ngcontent-%COMP%] {\\n background: transparent;\\n border: none;\\n padding: 8px;\\n cursor: pointer;\\n display: flex;\\n align-items: center;\\n justify-content: center;\\n border-radius: 4px;\\n transition: background-color 0.2s;\\n}\\n[_nghost-%COMP%] .custom-header[_ngcontent-%COMP%] .header-btn[_ngcontent-%COMP%]:hover, \\n[_nghost-%COMP%] .custom-header[_ngcontent-%COMP%] .add-btn[_ngcontent-%COMP%]:hover {\\n background-color: var(--background-light);\\n}\\n[_nghost-%COMP%] .custom-header[_ngcontent-%COMP%] .header-btn[_ngcontent-%COMP%] .emoji[_ngcontent-%COMP%], \\n[_nghost-%COMP%] .custom-header[_ngcontent-%COMP%] .add-btn[_ngcontent-%COMP%] .emoji[_ngcontent-%COMP%] {\\n font-size: 20px;\\n}\\n[_nghost-%COMP%] .custom-header[_ngcontent-%COMP%] .add-btn[_ngcontent-%COMP%] {\\n position: absolute;\\n right: 0;\\n}\\n[_nghost-%COMP%] .custom-header[_ngcontent-%COMP%] .text[_ngcontent-%COMP%] {\\n font-family: var(--font-heading);\\n font-size: 24px;\\n font-weight: 700;\\n letter-spacing: 0.1rem;\\n justify-self: center;\\n}\\n[_nghost-%COMP%] .reckless-mode-row[_ngcontent-%COMP%] {\\n display: flex;\\n flex-direction: row;\\n align-items: center;\\n justify-content: space-between;\\n padding: 8px 12px;\\n margin-bottom: 12px;\\n background: var(--background-light);\\n border-radius: 8px;\\n}\\n[_nghost-%COMP%] .reckless-mode-row[_ngcontent-%COMP%] .reckless-label[_ngcontent-%COMP%] {\\n display: flex;\\n flex-direction: row;\\n align-items: center;\\n gap: 8px;\\n cursor: pointer;\\n -webkit-user-select: none;\\n user-select: none;\\n}\\n[_nghost-%COMP%] .reckless-mode-row[_ngcontent-%COMP%] .reckless-label[_ngcontent-%COMP%] input[type=checkbox][_ngcontent-%COMP%] {\\n width: 16px;\\n height: 16px;\\n accent-color: var(--primary);\\n cursor: pointer;\\n}\\n[_nghost-%COMP%] .reckless-mode-row[_ngcontent-%COMP%] .reckless-label[_ngcontent-%COMP%] .reckless-text[_ngcontent-%COMP%] {\\n font-size: 14px;\\n color: var(--foreground);\\n}\\n[_nghost-%COMP%] .reckless-mode-row[_ngcontent-%COMP%] .gear-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%] .reckless-mode-row[_ngcontent-%COMP%] .gear-btn[_ngcontent-%COMP%]:hover {\\n color: var(--foreground);\\n background: var(--background-light-hover);\\n}\\n[_nghost-%COMP%] .reckless-mode-row[_ngcontent-%COMP%] .gear-btn[_ngcontent-%COMP%] i[_ngcontent-%COMP%] {\\n font-size: 16px;\\n}\\n[_nghost-%COMP%] .empty-state[_ngcontent-%COMP%] {\\n height: 100%;\\n display: flex;\\n align-items: center;\\n justify-content: center;\\n text-align: center;\\n}\\n[_nghost-%COMP%] .identity[_ngcontent-%COMP%] {\\n height: 56px;\\n min-height: 56px;\\n display: flex;\\n flex-direction: row;\\n align-items: center;\\n gap: 12px;\\n padding-left: 12px;\\n padding-right: 8px;\\n background: var(--background-light);\\n border-radius: 8px;\\n margin-bottom: 8px;\\n cursor: pointer;\\n transition: background-color 0.15s ease;\\n}\\n[_nghost-%COMP%] .identity[_ngcontent-%COMP%]:hover {\\n background: var(--background-light-hover);\\n}\\n[_nghost-%COMP%] .identity.selected[_ngcontent-%COMP%] {\\n background: rgba(245, 158, 11, 0.15);\\n border: 1px solid var(--primary);\\n}\\n[_nghost-%COMP%] .identity[_ngcontent-%COMP%] .avatar[_ngcontent-%COMP%] {\\n width: 36px;\\n height: 36px;\\n border-radius: 50%;\\n object-fit: cover;\\n flex-shrink: 0;\\n background: var(--muted);\\n}\\n[_nghost-%COMP%] .identity[_ngcontent-%COMP%] .name[_ngcontent-%COMP%] {\\n flex-grow: 1;\\n overflow: hidden;\\n text-overflow: ellipsis;\\n white-space: nowrap;\\n font-weight: 500;\\n}\"]\n });\n }\n return IdentitiesComponent;\n})();","map":null,"metadata":{},"sourceType":"module","externalDependencies":[]}