You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

2 lines
14 KiB

var R=Object.defineProperty;var B=(e,i,t)=>i in e?R(e,i,{enumerable:!0,configurable:!0,writable:!0,value:t}):e[i]=t;var d=(e,i,t)=>B(e,typeof i!="symbol"?i+"":i,t);import{y as _,d as G}from"./js-yaml-CxlQHuPU.js";import{V as z,f as Y,e as g,C as P,_ as Q,g as v,h as p,i as h,j as s,k as C,t as f,p as w,l as y,m as q,s as J,w as H,F as M,x as r,z as K}from"./index-BLqts8WY.js";import{Q as W}from"./QuickNav-DgCyvgDx.js";import{I as X}from"./InfiniteScroll-B5tl9k_n.js";import{T as Z}from"./TopMessage-BE0GBIgW.js";import{l as ee,al as te,am as ie,A as k,e as se,an as I,ae as oe,g as L,K as ne}from"./index-MyY_xqVN.js";import{E as ae}from"./EntityIcon-CF1RwQI5.js";import"./index-CsfPLOYu.js";var re=Object.defineProperty,le=Object.getOwnPropertyDescriptor,de=(e,i,t,o)=>{for(var n=o>1?void 0:o?le(i,t):i,c=e.length-1,a;c>=0;c--)(a=e[c])&&(n=(o?a(i,t,n):a(n))||n);return o&&n&&re(i,t,n),n};let x=class extends z{constructor(){super(...arguments);d(this,"$notify");d(this,"libsUtil",ee);d(this,"yaml",_);d(this,"activeDid","");d(this,"apiServer","");d(this,"claims",[]);d(this,"contactFromDid");d(this,"contactEdit",!1);d(this,"contactNewName","");d(this,"contactYaml","");d(this,"hitEnd",!1);d(this,"isLoading",!1);d(this,"isMyDid",!1);d(this,"searchBox",null);d(this,"showDidDetails",!1);d(this,"showLargeIdenticonId");d(this,"showLargeIdenticonUrl");d(this,"viewingDid");d(this,"capitalizeAndInsertSpacesBeforeCaps",te);d(this,"didInfoForContact",ie);d(this,"displayAmount",k)}async mounted(){const t=await Y();this.activeDid=t.activeDid||"",this.apiServer=t.apiServer||"";const o=window.location.pathname.substring(5);if(o){this.viewingDid=decodeURIComponent(o),this.contactFromDid=await g.contacts.get(this.viewingDid),this.contactFromDid&&(this.contactYaml=G(this.contactFromDid)),await this.loadClaimsAbout();const n=await se();this.isMyDid=n.includes(this.viewingDid)}}async loadMoreData(t){this.claims.length>0&&!this.hitEnd&&t&&this.loadClaimsAbout()}confirmDeleteContact(t){let o="Are you sure you want to remove "+I(t,!1)+" from your contact list?";t.seesMe&&(o+=" Note that they can see your activity, so if you want to hide your activity from them then you should do that first."),this.$notify({group:"modal",type:"confirm",title:"Delete",text:o,onYes:async()=>{await this.deleteContact(t)}},-1)}async deleteContact(t){await g.open(),await g.contacts.delete(t.did),this.$notify({group:"alert",type:"success",title:"Deleted",text:"Contact has been removed."},3e3),this.$router.push({name:"contacts"})}async confirmRegister(t){this.$notify({group:"modal",type:"confirm",title:"Register",text:"Are you sure you want to register "+I(this.contactFromDid,!1)+(t.registered?" -- especially since they are already marked as registered":"")+"?",onYes:async()=>{await this.register(t)}},-1)}async register(t){var o,n,c;this.$notify({group:"alert",type:"toast",title:"Sent..."},1e3);try{const a=await oe(this.activeDid,this.apiServer,this.axios,t);a.success?(t.registered=!0,await g.contacts.update(t.did,{registered:!0}),this.$notify({group:"alert",type:"success",title:"Registration Success",text:(t.name||"That unnamed person")+" has been registered."},5e3)):this.$notify({group:"alert",type:"danger",title:"Registration Error",text:a.error||"Something went wrong during registration."},5e3)}catch(a){console.error("Error when registering:",a);let l="There was an error.";const m=a;m?(c=(n=(o=m.response)==null?void 0:o.data)==null?void 0:n.error)!=null&&c.message?l=m.response.data.error.message:m.message?l=m.message:l=JSON.stringify(m.toJSON()):l=a,this.$notify({group:"alert",type:"danger",title:"Registration Error",text:l},5e3)}}async loadClaimsAbout(){if(!this.viewingDid){console.error("This should never be called without a DID.");return}const t="claimContents="+encodeURIComponent(this.viewingDid);let o="";this.claims.length>0&&(o="&beforeId="+this.claims[this.claims.length-1].id);try{this.isLoading=!0;const n=await fetch(this.apiServer+"/api/v2/report/claims?"+t+o,{method:"GET",headers:await L(this.activeDid)});if(n.status!==200){const a=await n.text();console.error("Pro