f7cloud_client/apps/photos/js/FileComponent-Z0cvFFM3.chunk.mjs
root 8b6a0139db f7cloud_client
Co-authored-by: Cursor <cursoragent@cursor.com>
2026-02-17 22:59:26 +00:00

3 lines
6.9 KiB
JavaScript

import{d as E,t as g,_ as x}from"./vue.runtime.esm-Ct3_M7aQ.chunk.mjs";import{N as P}from"./NcCheckboxRadioSwitch-VeztTzpz-CXqdOpK4.chunk.mjs";import{n as k,Z as F,V as N}from"./icons-VGG7keIQ.chunk.mjs";import{e as O}from"./index-BMeBqg0T.chunk.mjs";var R=["0","1","2","3","4","5","6","7","8","9","A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z","a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z","#","$","%","*","+",",","-",".",":",";","=","?","@","[","]","^","_","{","|","}","~"],h=e=>{let t=0;for(let a=0;a<e.length;a++){let i=e[a],l=R.indexOf(i);t=t*83+l}return t},v=e=>{let t=e/255;return t<=.04045?t/12.92:Math.pow((t+.055)/1.055,2.4)},L=e=>{let t=Math.max(0,Math.min(1,e));return t<=.0031308?Math.trunc(t*12.92*255+.5):Math.trunc((1.055*Math.pow(t,.4166666666666667)-.055)*255+.5)},T=e=>e<0?-1:1,b=(e,t)=>T(e)*Math.pow(Math.abs(e),t),C=class extends Error{constructor(e){super(e),this.name="ValidationError",this.message=e}},q=e=>{if(!e||e.length<6)throw new C("The blurhash string must be at least 6 characters");let t=h(e[0]),a=Math.floor(t/9)+1,i=t%9+1;if(e.length!==4+2*i*a)throw new C(`blurhash length mismatch: length is ${e.length} but it should be ${4+2*i*a}`)},A=e=>{let t=e>>16,a=e>>8&255,i=e&255;return[v(t),v(a),v(i)]},D=(e,t)=>{let a=Math.floor(e/361),i=Math.floor(e/19)%19,l=e%19;return[b((a-9)/9,2)*t,b((i-9)/9,2)*t,b((l-9)/9,2)*t]},U=(e,t,a,i)=>{q(e),i=i|1;let l=h(e[0]),S=Math.floor(l/9)+1,u=l%9+1,I=(h(e[1])+1)/166,c=new Array(u*S);for(let r=0;r<c.length;r++)if(r===0){let s=h(e.substring(2,6));c[r]=A(s)}else{let s=h(e.substring(4+r*2,6+r*2));c[r]=D(s,I*i)}let o=t*4,n=new Uint8ClampedArray(o*a);for(let r=0;r<a;r++)for(let s=0;s<t;s++){let y=0,$=0,_=0;for(let d=0;d<S;d++)for(let m=0;m<u;m++){let f=Math.cos(Math.PI*s*m/t)*Math.cos(Math.PI*r*d/a),p=c[m+d*u];y+=p[0]*f,$+=p[1]*f,_+=p[2]*f}let V=L(y),B=L($),z=L(_);n[4*s+0+r*o]=V,n[4*s+1+r*o]=B,n[4*s+2+r*o]=z,n[4*s+3+r*o]=255}return n},W=U;const Z='<svg xmlns="http://www.w3.org/2000/svg" id="mdi-star" viewBox="0 0 24 24"><path d="M12,17.27L18.18,21L16.54,13.97L22,9.24L14.81,8.62L12,2L9.19,8.62L2,9.24L7.45,13.97L5.82,21L12,17.27Z" /></svg>',j=E({name:"FavoriteIcon",components:{NcIconSvgWrapper:O},data(){return{StarSvg:Z}},mounted(){this.$nextTick(()=>{this.$el.querySelector("svg")?.setAttribute?.("viewBox","-4 -4 30 30")})},methods:{t:g}});var G=function(){var e=this,t=e._self._c;return e._self._setupProxy,t("NcIconSvgWrapper",{staticClass:"favorite-marker-icon",attrs:{name:e.t("photos","Favorite"),svg:e.StarSvg}})},H=[],J=k(j,G,H,!1,null,"38da3233");const K=J.exports,Q="images",w=[],M=async function(e){try{if(!w[e]){const t=await(await window.caches?.open(Q))?.match(e);w[e]=t!==void 0}return w[e]}catch{return!1}},X={name:"FileComponent",components:{FavoriteIcon:K,NcCheckboxRadioSwitch:P,VideoOutline:N,PlayCircleOutlineIcon:F},inheritAttrs:!1,props:{file:{type:Object,required:!0},selected:{type:Boolean,default:!1},allowSelection:{type:Boolean,default:!0},distance:{type:Number,default:0}},data(){return{initialized:!1,loadedSmall:!1,errorSmall:!1,loadedLarge:!1,errorLarge:!1}},computed:{ariaLabel(){return this.file.attributes.favorite?g("photos",'Favorite image, open the full size "{name}" image',{name:this.file.basename}):g("photos",'Open the full size "{name}" image',{name:this.file.basename})},isImage(){return this.file.mime?.startsWith("image")??!1},decodedEtag(){return this.file.attributes.etag.replace("&quot;","").replace("&quot;","")},srcLarge(){return this.getItemURL(512)},srcSmall(){return this.getItemURL(64)},isVisible(){return this.distance===0},hasBlurhash(){return this.file.attributes.metadataBlurhash!==void 0}},watch:{async file(){this.initialized=!1,this.loadedSmall=!1,this.errorSmall=!1,this.loadedLarge=!1,this.errorLarge=!1,await this.init()}},async mounted(){await this.init()},beforeDestroy(){this.$refs.imgSmall!==void 0&&(this.$refs.imgSmall.src=""),this.$refs.srcLarge!==void 0&&(this.$refs.srcLarge.src="")},methods:{async init(){[this.loadedSmall,this.loadedLarge]=await Promise.all([await M(this.srcSmall),await M(this.srcLarge)]),this.initialized=!0,await this.$nextTick(),this.drawBlurhash()},emitClick(){this.$emit("click",this.file.fileid)},onLoadSmall(){this.loadedSmall=!0},onLoadLarge(){this.loadedLarge=!0},onErrorSmall(){this.errorSmall=!0},onErrorLarge(){this.errorLarge=!0},onToggle(e){this.$emit("select-toggled",{id:this.file.fileid,value:e})},getItemURL(e){const t=this.$route?.params.token;return t?x(`/apps/photos/api/v1/publicPreview/${this.file.fileid}?etag=${this.decodedEtag}&x=${e}&y=${e}&token=${t}`):x(`/apps/photos/api/v1/preview/${this.file.fileid}?etag=${this.decodedEtag}&x=${e}&y=${e}`)},drawBlurhash(){if(!this.hasBlurhash||!this.$refs.canvas)return;const e=this.$refs.canvas.width,t=this.$refs.canvas.height,a=W(this.file.attributes.metadataBlurhash,e,t),i=this.$refs.canvas.getContext("2d"),l=i.createImageData(e,t);l.data.set(a),i.putImageData(l,0,0)},t:g}};var Y=function(){var e=this,t=e._self._c;return t("div",{staticClass:"file-container",class:{selected:e.selected},attrs:{"data-test":"media"}},[t("a",{staticClass:"file",attrs:{href:e.file.source,"aria-label":e.ariaLabel},on:{click:function(a){return a.stopPropagation(),a.preventDefault(),e.emitClick.apply(null,arguments)}}},[t("div",{staticClass:"file__images"},[e.file.mime?.includes("video")?t("VideoOutline",{staticClass:"icon-overlay",attrs:{size:64}}):e.file.attributes["metadata-files-live-photo"]!==void 0?t("PlayCircleOutlineIcon",{staticClass:"icon-overlay",attrs:{size:64}}):e._e(),e.initialized?[e.hasBlurhash&&!e.loadedSmall&&!e.loadedLarge?t("canvas",{ref:"canvas",staticClass:"file__blurhash",attrs:{"aria-hidden":"true"}}):e._e(),!e.loadedLarge&&(e.loadedSmall||e.distance<5&&!e.errorSmall)?t("img",{key:`${e.file.basename}-small`,ref:"imgSmall",attrs:{src:e.srcSmall,alt:e.file.basename,decoding:e.loadedSmall||e.isVisible?"sync":"async",fetchpriority:e.loadedSmall||e.isVisible?"high":"low",loading:e.loadedSmall||e.isVisible?"eager":e.distance<2?"auto":"lazy"},on:{load:e.onLoadSmall,error:e.onErrorSmall}}):e._e(),e.loadedLarge||(e.isVisible||e.distance<2&&(e.loadedSmall||e.errorSmall))&&!e.errorLarge?t("img",{key:`${e.file.basename}-large`,ref:"imgLarge",attrs:{src:e.srcLarge,alt:e.file.basename,decoding:e.loadedLarge||e.isVisible?"sync":"async",fetchpriority:e.loadedLarge||e.isVisible?"high":"low",loading:e.loadedLarge||e.isVisible?"auto":"lazy"},on:{load:e.onLoadLarge,error:e.onErrorLarge}}):e._e()]:e._e()],2)]),e.allowSelection?t("NcCheckboxRadioSwitch",{staticClass:"selection-checkbox",attrs:{"aria-label":e.t("photos","Select image {imageName}",{imageName:e.file.basename}),checked:e.selected},on:{"update:checked":e.onToggle}}):e._e(),e.file.attributes.favorite===1?e._m(0):e._e()],1)},ee=[function(){var e=this,t=e._self._c;return t("FavoriteIcon",{staticClass:"favorite-state"})}],te=k(X,Y,ee,!1,null,"a2daa207");const le=te.exports;export{le as F};
//# sourceMappingURL=FileComponent-Z0cvFFM3.chunk.mjs.map