Files
nextcloud-server-mirror/dist/8943-8943.js
2026-10-07 08:58:40 +00:00

2 lines
11 KiB
JavaScript

"use strict";(globalThis.webpackChunknextcloud_ui_legacy||=[]).push([[8943],{28943(e,a,l){var n=l(32288),t=l(12416),u=l(72746),i=l(51784),o=l(28215),r=l(95082),v=l(96080),c=l(71866),d=l(98831),f=l(23277),s=l(51104),p=l(22286);!function(){try{if("undefined"!=typeof document){var e=document.createElement("style");e.appendChild(document.createTextNode(".image_container[data-v-8dfcf839] {\n display: flex;\n align-items: center;\n height: 100%;\n justify-content: center;\n}\nimg[data-v-8dfcf839], video[data-v-8dfcf839] {\n align-self: center;\n justify-self: center;\n background-color: #000;\n transition: none !important;\n touch-action: none;\n}\nimg[data-v-8dfcf839]:hover, video[data-v-8dfcf839]:hover {\n background-image: linear-gradient(45deg, #efefef 25%, transparent 25%), linear-gradient(45deg, transparent 75%, #efefef 75%), linear-gradient(45deg, transparent 75%, #efefef 75%), linear-gradient(45deg, #efefef 25%, #fff 25%);\n background-size: 16px 16px;\n background-position: 0 0, 0 0, -8px -8px, 8px 8px;\n}\nimg.loaded[data-v-8dfcf839], video.loaded[data-v-8dfcf839] {\n background-color: #fff;\n}\nimg.zoomed[data-v-8dfcf839], video.zoomed[data-v-8dfcf839] {\n z-index: 10010;\n cursor: move;\n}\nimg.dragging[data-v-8dfcf839], video.dragging[data-v-8dfcf839] {\n transition: none !important;\n cursor: move;\n}\n.live-photo_play_button[data-v-8dfcf839] {\n position: absolute;\n top: 0;\n margin: 16px !important;\n display: flex;\n align-items: center;\n border: none;\n gap: 4px;\n border-radius: var(--border-radius);\n padding: 4px 8px;\n background-color: var(--color-main-background-blur);\n}")),document.head.appendChild(e)}}catch(e){console.error("vite-plugin-css-injected-by-js",e)}}();const g={name:"PlayCircleOutlineIcon",emits:["click"],props:{title:{type:String},fillColor:{type:String,default:"currentColor"},size:{type:Number,default:24}}},h=["aria-hidden","aria-label"],m=["fill","width","height"],b={d:"M12,20C7.59,20 4,16.41 4,12C4,7.59 7.59,4 12,4C16.41,4 20,7.59 20,12C20,16.41 16.41,20 12,20M12,2A10,10 0 0,0 2,12A10,10 0 0,0 12,22A10,10 0 0,0 22,12A10,10 0 0,0 12,2M10,16.5L16,12L10,7.5V16.5Z"},y={key:0},x=(0,v._)(g,[["render",function(e,a,l,t,u,o){return(0,n.uX)(),(0,n.CE)("span",(0,n.v6)(e.$attrs,{"aria-hidden":l.title?null:"true","aria-label":l.title,class:"material-design-icon play-circle-outline-icon",role:"img",onClick:a[0]||(a[0]=a=>e.$emit("click",a))}),[((0,n.uX)(),(0,n.CE)("svg",{fill:l.fillColor,class:"material-design-icon__svg",width:l.size,height:l.size,viewBox:"0 0 24 24"},[(0,n.Lk)("path",b,[l.title?((0,n.uX)(),(0,n.CE)("title",y,(0,i.v_)(l.title),1)):(0,n.Q3)("",!0)])],8,m))],16,h)}]]),w={class:"image_container"},E=["alt","src"],R=["poster","src"],k=["disabled","aria-label"],C=(0,n.pM)({name:"ViewerImages",__name:"Images",props:{file:{},files:{},maxHeight:{},maxWidth:{},editing:{type:Boolean,default:!1},isSidebarShown:{type:Boolean},turns:{},localSource:{}},emits:["loaded","errored","update:canSwipe","update:editing","update:playing"],setup(e,{emit:a}){const v=e,g=a,{filename:h,src:m}=(0,c.u)(v),b=(0,t.KR)(),y=(0,t.KR)(),C=(0,t.KR)(!1),W=(0,t.KR)(0),$=(0,t.KR)(0),M=(0,t.KR)(0),K=(0,t.KR)(1),_=(0,t.KR)([]),L=(0,t.KR)(0),D=(0,t.KR)(0),X=(0,t.KR)(!1),I=(0,t.KR)(1),P=(0,t.KR)(null),S=(0,t.KR)(!1),B=(0,t.KR)(!1),j=(0,t.KR)(!1),z=(0,t.KR)(0),A=(0,t.KR)(0),U=(0,t.KR)(!1),T=(0,t.KR)(0);let Y=null,F=!1,H=null;const O=(0,n.EW)(()=>A.value>0?Math.max(5,4*T.value/A.value):5),Q=(0,n.EW)(()=>v.file.mime),N=(0,n.EW)(()=>v.file.attributes?.hasPreview??!1),V=(0,n.EW)(()=>v.file.attributes?.previewUrl),q=(0,n.EW)(()=>v.file.attributes?.["metadata-files-live-photo"]),G=(0,n.EW)(()=>(0,p.g)(v.file,{width:v.maxWidth,height:v.maxHeight})),Z=(0,n.EW)(()=>Number(v.turns??0)%4),J=(0,n.EW)(()=>Z.value%2==1),ee=(0,n.EW)(()=>J.value?z.value:A.value),ae=(0,n.EW)(()=>J.value?A.value:z.value),le=(0,n.EW)(()=>Math.round(z.value*I.value)),ne=(0,n.EW)(()=>Math.round(A.value*I.value)),te=(0,n.EW)(()=>v.file.displayname),ue=(0,n.EW)(()=>{const e=0===Z.value?void 0:`rotate(${-90*Z.value}deg)`;return 1===I.value?{height:le.value+"px",width:ne.value+"px",transform:e}:{marginTop:Math.round(2*D.value)+"px",marginLeft:Math.round(2*L.value)+"px",height:le.value+"px",width:ne.value+"px",transform:e}}),ie=(0,n.EW)(()=>{if(void 0!==q.value)return(0,s.f)(q.value,v.files)}),oe=(0,n.EW)(()=>ie.value?.encodedSource??null);let re=null,ve=null;function ce(e){null!==ve&&URL.revokeObjectURL(ve),ve=e,P.value=e}function de(){fe().catch(e=>{d.l.error(`Loading of file ${h.value} failed`,{error:e}),g("errored",new Error((0,d.t)("Failed to load image.")))})}async function fe(){null!==re&&re.source!==v.file.source&&re.controller.abort();const e=new AbortController;re={controller:e,source:v.file.source};const{signal:a}=e;if(U.value=!1,v.localSource)P.value=v.localSource;else if("image/svg+xml"!==Q.value){if(S.value){const e=(0,f.c)(v.file);return ce(e?await(0,c.p)(v.file,a):await(0,c.a)(G.value,a)),void(U.value=!e&&N.value&&!V.value)}"image/gif"===Q.value||v.file.source&&!N.value&&!V.value?P.value=m.value:(P.value=G.value,U.value=N.value&&!V.value)}else P.value=await async function(e){const a=await o.Ay.get(m.value,{signal:e}),{default:n}=await Promise.resolve().then(()=>l(97519)),t=n.sanitize(a.data);return`data:${Q.value};base64,${btoa(unescape(encodeURIComponent(t)))}`}(a)}function se(){j.value=!0,T.value=Math.max(T.value,b.value?.naturalWidth??0),null!==P.value&&P.value===Y||ge()}async function pe(){if(F||!U.value)return;const e=(0,p.a)(v.file);if(void 0===e)return;F=!0;const a=new AbortController;H=a;const{signal:l}=a;let n=null;try{const a=(0,f.c)(v.file)?e:await(0,c.a)(e,l);n=a===e?null:a;const t=await(0,c.b)(a,l);if(l.aborted)return;if(T.value=Math.max(T.value,t),t<=(b.value?.naturalWidth??0))return;Y=a,null===n?P.value=a:(ce(a),n=null)}catch(e){l.aborted||d.l.debug(`Could not fetch a sharper preview of ${h.value}`,{error:e})}finally{null!==n&&URL.revokeObjectURL(n)}}function ge(){const e=b.value?.naturalWidth||y.value?.videoWidth,a=b.value?.naturalHeight||y.value?.videoHeight;if(!e||!a)return;const l=J.value?a:e,n=J.value?e:a,t=Math.min(v.maxHeight/n,v.maxWidth/l);A.value=Math.floor(e*t),z.value=Math.floor(a*t)}function he(e,a,l){const n=ee.value*l-ee.value,t=ae.value*l-ae.value;L.value=Math.min(Math.max(e,-n/2),n/2),D.value=Math.min(Math.max(a,-t/2),t/2)}function me(e,a,l){const n=b.value??y.value;if(!n)return;const t=e-n.getBoundingClientRect().x-ee.value*I.value/2,u=a-n.getBoundingClientRect().y-ae.value*I.value/2,i=t/(ee.value*I.value),o=u/(ae.value*I.value),r=ee.value*l-ee.value*I.value,v=ae.value*l-ae.value*I.value;he(L.value-i*r,D.value-o*v,l),I.value=l,l>1&&pe()}function be(){const e=_.value[0],a=_.value[1];if(!e||!a)return 0;const l=a.x-e.x,n=a.y-e.y;return Math.sqrt(l*l+n*n)}function ye(e){const a=e.deltaY<0?Math.min(1.1*I.value,O.value):Math.max(I.value/1.1,1);if(1===a)return xe();g("update:canSwipe",!1),me(e.clientX,e.clientY,a)}function xe(){g("update:canSwipe",!0),I.value=1,L.value=0,D.value=0}function we(e){_.value.push({pointerId:e.pointerId,x:e.clientX,y:e.clientY}),1===_.value.length&&(W.value=e.clientX,$.value=e.clientY,C.value=!0),2===_.value.length&&(M.value=be(),K.value=I.value,X.value=!0,g("update:canSwipe",!1))}function Ee(e){const a=_.value.findIndex(a=>a.pointerId===e.pointerId);-1!==a&&(_.value.splice(a,1),C.value=!1,X.value=!1)}function Re(e){Ee(e),0===_.value.length&&1===I.value&&g("update:canSwipe",!0)}function ke(e){if(_.value.length>0){const a=_.value.findIndex(a=>a.pointerId===e.pointerId),l=a>=0?_.value[a]:void 0;l&&(l.x=e.clientX,l.y=e.clientY)}if(1===_.value.length&&C.value&&!X.value&&I.value>1){const{clientX:a,clientY:l}=e;he(L.value+(a-W.value),D.value+(l-$.value),I.value),W.value=a,$.value=l}if(2===_.value.length&&X.value){const e=be(),a=Math.min(Math.max(K.value*(e/M.value),1),O.value),l=_.value[0],n=_.value[1];if(!l||!n)return;me((l.x+n.x)/2,(l.y+n.y)/2,a)}}function Ce(){I.value>1?xe():(I.value=1.3,pe())}function We(){return(0,f.c)(v.file)?(0,d.t)("Failed to load image."):(0,d.t)("No preview available, download is disabled.")}async function $e(){if(S.value)return d.l.error(`Loading of file ${h.value} failed even after fallback`),void g("errored",new Error(We()));d.l.error(`Loading of file ${h.value} failed, falling back to fetching it by hand`),S.value=!0;try{await fe()}catch(e){d.l.error(`Fallback fetch of ${h.value} failed`,{error:e}),g("errored",new Error(We()))}}function Me(){B.value=!0,se()}function Ke(){B.value&&y.value&&y.value.play().catch(e=>{d.l.debug("The browser refused to play the live photo",{error:e})})}function _e(){y.value&&y.value.load()}return(0,n.wB)(()=>v.file.source,()=>{H?.abort(),H=null,Y=null,F=!1,T.value=0,de()}),(0,n.wB)(P,e=>{null!==e&&e===Y||(j.value=!1,async function(){await(0,n.dY)();const e=b.value;e?.complete&&e.naturalWidth>0&&!j.value&&se()}())}),(0,n.wB)(()=>v.localSource,e=>{e&&(P.value=e)}),de(),(0,n.wB)(j,e=>{e&&g("loaded")},{flush:"post"}),(0,n.wB)([()=>v.maxWidth,()=>v.maxHeight],ge),(0,n.wB)(Z,()=>{xe(),ge()}),(0,n.hi)(()=>{re?.controller.abort(),H?.abort(),null!==ve&&(URL.revokeObjectURL(ve),ve=null)}),(e,a)=>((0,n.uX)(),(0,n.CE)("div",w,[null!==P.value?((0,n.uX)(),(0,n.CE)(n.FK,{key:0},[B.value?(0,n.Q3)("",!0):((0,n.uX)(),(0,n.CE)("img",{key:0,ref_key:"image",ref:b,alt:te.value,class:(0,i.C4)({dragging:C.value,loaded:j.value,zoomed:I.value>1}),src:P.value,style:(0,i.Tr)(ue.value),onErrorCapture:(0,u.D$)($e,["prevent","stop"]),onLoad:se,onWheel:(0,u.D$)(ye,["stop","prevent"]),onDblclick:(0,u.D$)(Ce,["prevent"]),onPointerdown:(0,u.D$)(we,["prevent"]),onPointerup:(0,u.D$)(Ee,["prevent"]),onPointercancel:(0,u.D$)(Re,["prevent"]),onPointermove:(0,u.D$)(ke,["prevent"])},null,46,E)),ie.value?((0,n.uX)(),(0,n.CE)(n.FK,{key:1},[(0,n.bo)((0,n.Lk)("video",{ref_key:"video",ref:y,class:(0,i.C4)({dragging:C.value,loaded:j.value,zoomed:I.value>1}),style:(0,i.Tr)(ue.value),playsinline:!0,muted:"",poster:P.value??void 0,src:oe.value??void 0,preload:"metadata",onCanplaythrough:Me,onLoadedmetadata:ge,onWheel:(0,u.D$)(ye,["stop","prevent"]),onErrorCaptureOnce:(0,u.D$)($e,["prevent","stop"]),onDblclick:(0,u.D$)(Ce,["prevent"]),onPointerdown:(0,u.D$)(we,["prevent"]),onPointerup:(0,u.D$)(Ee,["prevent"]),onPointercancel:(0,u.D$)(Re,["prevent"]),onPointermove:(0,u.D$)(ke,["prevent"]),onEnded:_e},null,46,R),[[u.aG,B.value]]),0!==A.value?((0,n.uX)(),(0,n.CE)("button",{key:0,class:"live-photo_play_button",style:(0,i.Tr)({left:`calc(50% - ${A.value/2}px)`}),disabled:!B.value,"aria-label":(0,t.R1)(d.t)("Play the live photo"),onClick:Ke,onPointerenter:Ke,onFocus:Ke,onPointerleave:_e,onBlur:_e},[B.value?((0,n.uX)(),(0,n.Wv)(x,{key:0})):((0,n.uX)(),(0,n.Wv)((0,t.R1)(r.A),{key:1})),(0,n.eW)(" "+(0,i.v_)((0,t.R1)(d.t)("LIVE")),1)],44,k)):(0,n.Q3)("",!0)],64)):(0,n.Q3)("",!0)],64)):(0,n.Q3)("",!0)]))}}),W=(0,v._)(C,[["__scopeId","data-v-8dfcf839"]]);l.d(a,["default",0,W])},51104(e,a,l){l.d(a,{a:()=>i,f:()=>t});const n=new RegExp(`\\.(${["jpg","jpeg","png"].join("|")})$`,"i");function t(e,a){return a.find(a=>a.fileid===e)}function u(e){const a=e.extension??"";return""===a?e.basename:e.basename.slice(0,-a.length)}function i(e,a){const l=u(e);return a.find(a=>a.source!==e.source&&u(a)===l&&n.test(a.basename))}}}]);
//# sourceMappingURL=8943-8943.js.map?v=d6780561a31b4e42aec9