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

1 line
14 KiB
JavaScript

"use strict";(globalThis.webpackChunkweb_stories_wp=globalThis.webpackChunkweb_stories_wp||[]).push([[2443],{72443:(t,n,o)=>{o.d(n,{default:()=>PhotoAlbum});var e=o(67294);function r({width:t,height:n}){return t/n}function i(t,n=0){const o=10**n;return Math.round((t+Number.EPSILON)*o)/o}class MinHeap{constructor(t){this.comparator=t,this.heap=[],this.n=0}greater(t,n){return this.comparator(this.heap[t],this.heap[n])<0}swap(t,n){const o=this.heap[t];this.heap[t]=this.heap[n],this.heap[n]=o}swim(t){let n=t,o=Math.floor(n/2);for(;n>1&&this.greater(o,n);)this.swap(o,n),n=o,o=Math.floor(n/2)}sink(t){let n=t,o=2*n;for(;o<=this.n&&(o<this.n&&this.greater(o,o+1)&&(o+=1),this.greater(n,o));)this.swap(n,o),n=o,o=2*n}push(t){this.n+=1,this.heap[this.n]=t,this.swim(this.n)}pop(){if(0===this.n)return;this.swap(1,this.n),this.n-=1;const t=this.heap.pop();return this.sink(1),t}size(){return this.n}}function s(t,n,o){const e=function(t,n,o){const e=new Map,r=new Set,i=new Map;i.set(n,0);const s=new MinHeap((a=t=>t.weight,(t,n)=>a(n)-a(t)));var a;for(s.push({id:n,weight:0});s.size()>0;){const{id:n,weight:o}=s.pop();if(!r.has(n)){const a=t(n);r.add(n),a.forEach(((t,r)=>{const a=o+t,l=e.get(r),c=i.get(r);(void 0===c||c>a&&(c/a>1.005||void 0!==l&&l<n))&&(i.set(r,a),s.push({id:r,weight:a}),e.set(r,n))}))}}return i.has(o)?e:void 0}(t,n,o);return e?function(t,n){const o=[];for(let e=n;void 0!==e;e=t.get(e))o.push(e);return o.reverse()}(e,o):void 0}function a(t,n,o,e){return(n-(t.length-1)*o-2*e*t.length)/t.reduce(((t,n)=>t+r(n)),0)}function l(t,n,o,e,r,i,s){const l=t.slice(n,o),c=a(l,e,i,s);return c>0?(c-r)**2*l.length:void 0}function c({photos:t,layoutOptions:n}){const{spacing:o,padding:e,containerWidth:c,targetRowHeight:u,rowConstraints:h}=n,p=function({photos:t,targetRowHeight:n,containerWidth:o}){return i(o/n/t.reduce(((t,n)=>Math.min(r(n),t)),Number.MAX_VALUE))+2}({photos:t,containerWidth:c,targetRowHeight:u}),d=function({photos:t,layoutOptions:n,targetRowHeight:o,limitNodeSearch:e,rowConstraints:r}){return i=>{var s,a;const{containerWidth:c,spacing:u,padding:h}=n,p=new Map;p.set(i,0);const d=null!=(s=null==r?void 0:r.minPhotos)?s:1,m=Math.min(e,null!=(a=null==r?void 0:r.maxPhotos)?a:1/0);for(let n=i+d;n<t.length+1&&!(n-i>m);n+=1){const e=l(t,i,n,c,o,u,h);if(void 0===e)break;p.set(n,e)}return p}}({photos:t,layoutOptions:n,targetRowHeight:u,limitNodeSearch:p,rowConstraints:h}),m=s(d,0,t.length);if(void 0===m)return;const g=[];for(let n=1;n<m.length;n+=1){const i=t.map(((t,n)=>({photo:t,index:n}))).slice(m[n-1],m[n]),s=a(i.map((({photo:t})=>t)),c,o,e);g.push(i.map((({photo:t,index:n},o)=>({photo:t,layout:{height:s,width:s*r(t),index:n,photoIndex:o,photosCount:i.length}}))))}return g}function u(...t){return[...t].filter((t=>Boolean(t))).join(" ")}function h(t,{width:n,photosCount:o},{spacing:e,padding:r,containerWidth:s}){const a=e*(o-1)+2*r*o;return`calc((${t} - ${a}px) / ${i((s-a)/n,5)})`}function p(t,n){return"rows"!==n.layout?`calc(100% - ${2*n.padding}px)`:h("100%",t,n)}function d(t,n,o){var e,r;return h(null!=(r=null==(e=t.match(/calc\((.*)\)/))?void 0:e[1])?r:t,n,o)}function m(t,n,o){let e,r;const i=t.srcSet||t.images;return i&&i.length>0&&(e=i.concat(i.find((({width:n})=>n===t.width))?[]:[{src:t.src,width:t.width,height:t.height}]).sort(((t,n)=>t.width-n.width)).map((t=>`${t.src} ${t.width}w`)).join(", ")),o.sizes?r=(o.sizes.sizes||[]).map((({viewport:t,size:e})=>`${t} ${d(e,n,o)}`)).concat(d(o.sizes.size,n,o)).join(", "):e&&(r=`${Math.ceil(n.width/o.containerWidth*100)}vw`),{srcSet:e,sizes:r}}function PhotoRenderer(t){var n,o;const{photo:r,layout:i,layoutOptions:s,imageProps:{style:a,className:l,...c}={},renderPhoto:h}=t,{onClick:d}=s,g={display:"block",boxSizing:"content-box",width:p(i,s),height:"auto",aspectRatio:`${r.width} / ${r.height}`,...s.padding?{padding:`${s.padding}px`}:null,...("columns"===s.layout||"masonry"===s.layout)&&i.photoIndex<i.photosCount-1?{marginBottom:`${s.spacing}px`}:null,...d?{cursor:"pointer"}:null,...a},f=d?t=>{d({event:t,photo:r,index:i.index})}:void 0,w={src:r.src,alt:null!=(n=r.alt)?n:"",title:r.tit