var w=Object.defineProperty;var _=(t,e,o)=>e in t?w(t,e,{enumerable:!0,configurable:!0,writable:!0,value:o}):t[e]=o;var d=(t,e,o)=>_(t,typeof e!="symbol"?e+"":e,o);import{V as x,f as P,e as g,M as B,I as E,a as D,b as k,C as N,_ as T,g as f,h as u,i as m,j as s,k as b,F as S,x as h}from"./index-BLqts8WY.js";import{P as $}from"./PhotoDialog-Dn3GjI9b.js";import{Q as A}from"./QuickNav-DgCyvgDx.js";import{aU as y,aV as I,aP as F}from"./index-MyY_xqVN.js";import"./index-CsfPLOYu.js";var R=Object.defineProperty,V=Object.getOwnPropertyDescriptor,C=(t,e,o,a)=>{for(var r=a>1?void 0:a?V(e,o):e,l=t.length-1,n;l>=0;l--)(n=t[l])&&(r=(a?n(e,o,r):n(r))||r);return a&&r&&R(e,o,r),r};let v=class extends x{constructor(){super(...arguments);d(this,"$notify");d(this,"activeDid");d(this,"imageBlob");d(this,"imageFileName");d(this,"uploading",!1);d(this,"URL",window.URL||window.webkitURL)}async mounted(){try{const o=await P();this.activeDid=o.activeDid;const a=await g.temp.get(y),r=a==null?void 0:a.blobB64;a?(this.imageBlob=I(r),g.temp.delete(y),this.imageFileName=this.$route.query.fileName):console.error("No appropriate image found in temp storage.",a)}catch(o){console.error("Got an error loading an identifier:",o),this.$notify({group:"alert",type:"danger",title:"Error",text:"Got an error loading this data."},-1)}}async recordGift(){await this.sendToImageServer("GiveAction").then(o=>{if(o){const a={name:"gifted-details",query:{destinationPathAfter:"/",hideBackButton:!0,imageUrl:o,recipientDid:this.activeDid}};this.$router.push(a)}})}recordProfile(){this.$refs.photoDialog.open(async o=>{await g.settings.update(B,{profileImageUrl:o}),this.$router.push({name:"account"})},E,!0,this.imageBlob,this.imageFileName)}async cancel(){this.imageBlob=void 0,this.imageFileName=void 0,this.$router.push({name:"home"})}async sendToImageServer(o){var r,l;this.uploading=!0;let a;try{const c={Authorization:"Bearer "+await F(this.activeDid)},p=new FormData;p.append("image",this.imageBlob,this.imageFileName),p.append("claimType",o);const i=await D.post(k+"/image",p,{headers:c});(r=i==null?void 0:i.data)!=null&&r.url?(this.imageBlob=void 0,this.imageFileName=void 0,a=i.data.url):(console.error("Problem uploading the image",i.data),this.$notify({group:"alert",type:"danger",title:"Error",text:"There was a problem saving the picture. "+(((l=i==null?void 0:i.data)==null?void 0:l.message)||"")},5e3)),this.uploading=!1}catch(n){console.error("Error uploading the image",n),this.$notify({group:"alert",type:"danger",title:"Error",text:"There was an error saving the picture."},5e3),this.uploading=!1}return a}};v=C([N({components:{PhotoDialog:$,QuickNav:A}})],v);const G={id:"Content",class:"p-6 pb-24 max-w-3xl mx-auto"},U={key:0},O={key:0,class:"text-center mb-4"},L={key:1},j={class:"grid grid-cols-1 sm:grid-cols-3 gap-4"},H={class:"flex justify-center"},M=["src"],Q={key:1,class:"text-center mb-4"};function Y(t,e,o,a,r,l){const n=f("QuickNav"),c=f("fa"),p=f("PhotoDialog");return h(),u(S,null,[m(n),s("section",G,[e[8]||(e[8]=s("h1",{id:"ViewHeading",class:"text-4xl text-center font-light pt-4 mb-8"}," Image ",-1)),t.imageBlob?(h(),u("div",U,[t.uploading?(h(),u("div",O,[m(c,{icon:"spinner",class:"fa-spin-pulse"})])):(h(),u("div",L,[e[6]||(e[6]=s("div",{class:"text-center mb-4"},"Choose how to use this image",-1)),s("div",j,[s("button",{onClick:e[0]||(e[0]=(...i)=>t.recordGift&&t.recordGift(...i)),class:"text-center text-md font-bold bg-gradient-to-b from-blue-400 to-blue-700 shadow-[inset_0_-1px_0_0_rgba(0,0,0,0.5)] text-white px-2 py-3 rounded-md"},[m(c,{icon:"gift",class:"fa-fw"}),e[3]||(e[3]=b(" Record a Gift "))]),s("button",{onClick:e[1]||(e[1]=(...i)=>t.recordProfile&&t.recordProfile(...i)),class:"text-center text-md font-bold bg-gradient-to-b from-blue-400 to-blue-700 shadow-[inset_0_-1px_0_0_rgba(0,0,0,0.5)] text-white px-2 py-3 rounded-md"},[m(c,{icon:"circle-user",class:"fa-fw"}),e[4]||(e[4]=b(" Save as Profile Image "))]),s("button",{onClick:e[2]||(e[2]=(...i)=>t.cancel&&t.cancel(...i)),class:"text-center text-md font-bold bg-gradient-to-b from-slate-400 to-slate-700 shadow-[inset_0_-1px_0_0_rgba(0,0,0,0.5)] text-white px-2 py-3 rounded-md"},[m(c,{icon:"ban",class:"fa-fw"}),e[5]||(e[5]=b(" Cancel "))])]),m(p,{ref:"photoDialog"},null,512)])),s("div",H,[s("img",{src:t.URL.createObjectURL(t.imageBlob),alt:"Shared Image",class:"rounded mt-4"},null,8,M)])])):(h(),u("div",Q,e[7]||(e[7]=[s("p",null,"No image found.",-1),s("p",{class:"mt-4"},' If you shared an image, the cause is usually that you do not have the recent version of this app, or that the app has not refreshed the service code underneath. To fix this, first make sure you have latest version by comparing your version at the bottom of "Help" with the version at the bottom of https://timesafari.app/help in a browser. After that, it may eventually work, but you can speed up the process by clearing your data cache (in the browser on mobile, even if you installed it) and/or reinstalling the app (after backing up all your data, of course). ',-1)])))])],64)}const ee=T(v,[["render",Y]]);export{ee as default};