@frybynite/image-cloud 0.7.5 → 0.7.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/image-cloud-auto-init.js +566 -560
- package/dist/image-cloud-auto-init.js.map +1 -1
- package/dist/image-cloud.js +943 -937
- package/dist/image-cloud.js.map +1 -1
- package/dist/image-cloud.umd.js +3 -3
- package/dist/image-cloud.umd.js.map +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/react.d.ts +2 -2
- package/dist/react.js +928 -922
- package/dist/react.js.map +1 -1
- package/dist/vue.d.ts +2 -2
- package/dist/vue.js +942 -936
- package/dist/vue.js.map +1 -1
- package/dist/web-component.d.ts +2 -2
- package/dist/web-component.js +657 -651
- package/dist/web-component.js.map +1 -1
- package/package.json +1 -1
package/dist/image-cloud.umd.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
(function(A,J){typeof exports=="object"&&typeof module<"u"?J(exports):typeof define=="function"&&define.amd?define(["exports"],J):(A=typeof globalThis<"u"?globalThis:A||self,J(A.ImageCloud={}))})(this,(function(A){"use strict";const J=Object.freeze({none:"none",sm:"0 2px 4px rgba(0,0,0,0.1)",md:"0 4px 16px rgba(0,0,0,0.4)",lg:"0 8px 32px rgba(0,0,0,0.5)",glow:"0 0 30px rgba(255,255,255,0.6)"}),rt=Object.freeze({energetic:Object.freeze({overshoot:.25,bounces:2,decayRatio:.5}),playful:Object.freeze({overshoot:.15,bounces:1,decayRatio:.5}),subtle:Object.freeze({overshoot:.08,bounces:1,decayRatio:.5})}),ct=Object.freeze({gentle:Object.freeze({stiffness:150,damping:30,mass:1,oscillations:2}),bouncy:Object.freeze({stiffness:300,damping:15,mass:1,oscillations:4}),wobbly:Object.freeze({stiffness:180,damping:12,mass:1.5,oscillations:5}),snappy:Object.freeze({stiffness:400,damping:25,mass:.8,oscillations:2})}),lt=Object.freeze({gentle:Object.freeze({amplitude:30,frequency:1.5,decay:!0,decayRate:.9,phase:0}),playful:Object.freeze({amplitude:50,frequency:2.5,decay:!0,decayRate:.7,phase:0}),serpentine:Object.freeze({amplitude:60,frequency:3,decay:!1,decayRate:1,phase:0}),flutter:Object.freeze({amplitude:20,frequency:4,decay:!0,decayRate:.5,phase:0})}),ht=Object.freeze({type:"linear"}),dt=Object.freeze({mode:"none"}),ut=Object.freeze({mode:"none"}),At=Object.freeze({default:Object.freeze({border:Object.freeze({width:0,color:"#000000",radius:0,style:"solid"}),shadow:"none",clipPath:void 0,filter:Object.freeze({}),opacity:1,cursor:"pointer",outline:Object.freeze({width:0,color:"#000000",style:"solid",offset:0})}),hover:Object.freeze({shadow:"none"}),focused:Object.freeze({shadow:"none"})}),Kt=Object.freeze({rows:1,amplitude:100,frequency:2,phaseShift:0,synchronization:"offset"}),Qt=Object.freeze({mobile:Object.freeze({maxWidth:767}),tablet:Object.freeze({maxWidth:1199})}),te=Object.freeze({mode:"adaptive",minSize:50,maxSize:400,variance:Object.freeze({min:1,max:1})}),ee=Object.freeze({mode:"none",range:Object.freeze({min:-15,max:15})}),Ct=Object.freeze({sizing:te,rotation:ee}),gt=Object.freeze({validateUrls:!0,validationTimeout:5e3,validationMethod:"head",allowedExtensions:["jpg","jpeg","png","gif","webp","bmp"]}),Tt=Object.freeze({enabled:!1,centers:!1,loaders:!1}),b=Object.freeze({loaders:[],config:Object.freeze({loaders:gt,debug:Tt}),image:Ct,layout:Object.freeze({algorithm:"radial",scaleDecay:0,responsive:Qt,targetCoverage:.6,densityFactor:1,spacing:Object.freeze({padding:50,minGap:20})}),animation:Object.freeze({duration:600,easing:Object.freeze({default:"cubic-bezier(0.4, 0.0, 0.2, 1)",bounce:"cubic-bezier(0.68, -0.55, 0.265, 1.55)",focus:"cubic-bezier(0.4, 0.0, 0.2, 1)"}),queue:Object.freeze({enabled:!0,interval:150,maxConcurrent:void 0}),performance:Object.freeze({useGPU:void 0,reduceMotion:void 0}),entry:Object.freeze({start:Object.freeze({position:"nearest-edge",offset:100,circular:Object.freeze({radius:"120%",distribution:"even"})}),timing:Object.freeze({duration:600}),easing:"cubic-bezier(0.25, 1, 0.5, 1)",path:ht,rotation:dt,scale:ut})}),interaction:Object.freeze({focus:Object.freeze({scalePercent:.8,zIndex:1e3,animationDuration:void 0}),navigation:Object.freeze({keyboard:void 0,swipe:void 0,mouseWheel:void 0}),gestures:Object.freeze({pinchToZoom:void 0,doubleTapToFocus:void 0})}),rendering:Object.freeze({responsive:Object.freeze({breakpoints:Object.freeze({mobile:768,tablet:void 0,desktop:void 0}),mobileDetection:()=>typeof window>"u"?!1:window.innerWidth<=768}),ui:Object.freeze({showLoadingSpinner:!1,showImageCounter:!1}),performance:Object.freeze({lazyLoad:void 0,preloadCount:void 0,imageQuality:void 0})}),styling:At});function tt(n,t){if(!n)return t||{};if(!t)return{...n};const e={...n};return t.border!==void 0&&(e.border={...n.border,...t.border}),t.borderTop!==void 0&&(e.borderTop={...n.borderTop,...t.borderTop}),t.borderRight!==void 0&&(e.borderRight={...n.borderRight,...t.borderRight}),t.borderBottom!==void 0&&(e.borderBottom={...n.borderBottom,...t.borderBottom}),t.borderLeft!==void 0&&(e.borderLeft={...n.borderLeft,...t.borderLeft}),t.filter!==void 0&&(e.filter={...n.filter,...t.filter}),t.outline!==void 0&&(e.outline={...n.outline,...t.outline}),t.shadow!==void 0&&(e.shadow=t.shadow),t.clipPath!==void 0&&(e.clipPath=t.clipPath),t.opacity!==void 0&&(e.opacity=t.opacity),t.cursor!==void 0&&(e.cursor=t.cursor),t.className!==void 0&&(e.className=t.className),t.objectFit!==void 0&&(e.objectFit=t.objectFit),t.aspectRatio!==void 0&&(e.aspectRatio=t.aspectRatio),t.borderRadiusTopLeft!==void 0&&(e.borderRadiusTopLeft=t.borderRadiusTopLeft),t.borderRadiusTopRight!==void 0&&(e.borderRadiusTopRight=t.borderRadiusTopRight),t.borderRadiusBottomRight!==void 0&&(e.borderRadiusBottomRight=t.borderRadiusBottomRight),t.borderRadiusBottomLeft!==void 0&&(e.borderRadiusBottomLeft=t.borderRadiusBottomLeft),e}function ie(n,t){if(!t)return{...n};const e=tt(n.default,t.default),i=tt(tt(e,n.hover),t.hover),o=tt(tt(e,n.focused),t.focused);return{default:e,hover:i,focused:o}}function ne(n,t){if(!t)return{...n};const e={...n};if(t.sizing!==void 0&&(e.sizing={...n.sizing,...t.sizing},t.sizing.variance)){const i=t.sizing.variance,o=i.min!==void 0&&i.min>=.25&&i.min<=1?i.min:n.sizing?.variance?.min??1,a=i.max!==void 0&&i.max>=1&&i.max<=1.75?i.max:n.sizing?.variance?.max??1;e.sizing.variance={min:o,max:a}}if(t.rotation!==void 0&&(e.rotation={...n.rotation,...t.rotation},t.rotation.range)){const i=t.rotation.range,o=i.min!==void 0&&i.min>=-180&&i.min<=0?i.min:n.rotation?.range?.min??-15,a=i.max!==void 0&&i.max>=0&&i.max<=180?i.max:n.rotation?.range?.max??15;e.rotation.range={min:o,max:a}}return e}function oe(n){const t=n.layout?.rotation;if(t&&"enabled"in t)return{rotation:{mode:t.enabled?"random":"none",range:t.range}}}function se(n){const t=n.layout?.sizing?.variance;if(t)return{sizing:{mode:"adaptive",variance:t}}}function ae(n={}){const t=oe(n),e=se(n);let i=n.image;(t||e)&&(i={...e||{},...t||{},...i},i.rotation&&t?.rotation&&n.image?.rotation&&(i.rotation={...t.rotation,...n.image.rotation}));const o=[...n.loaders??[]];n.images&&n.images.length>0&&o.unshift({static:{sources:[{urls:n.images}]}});const r={loaders:{...gt,...n.config?.loaders??{}}},s={loaders:o,config:r,image:ne(Ct,i),layout:{...b.layout},animation:{...b.animation},interaction:{...b.interaction},rendering:{...b.rendering},styling:ie(At,n.styling)};return n.layout&&(s.layout={...b.layout,...n.layout},n.layout.responsive&&(s.layout.responsive={...b.layout.responsive,mobile:n.layout.responsive.mobile?{...b.layout.responsive.mobile,...n.layout.responsive.mobile}:b.layout.responsive.mobile,tablet:n.layout.responsive.tablet?{...b.layout.responsive.tablet,...n.layout.responsive.tablet}:b.layout.responsive.tablet}),n.layout.spacing&&(s.layout.spacing={...b.layout.spacing,...n.layout.spacing})),n.animation&&(s.animation={...b.animation,...n.animation},n.animation.easing&&(s.animation.easing={...b.animation.easing,...n.animation.easing}),n.animation.queue&&(s.animation.queue={...b.animation.queue,...n.animation.queue}),n.animation.performance&&(s.animation.performance={...b.animation.performance,...n.animation.performance}),n.animation.entry&&(s.animation.entry={...b.animation.entry,...n.animation.entry,start:n.animation.entry.start?{...b.animation.entry.start,...n.animation.entry.start,circular:n.animation.entry.start.circular?{...b.animation.entry.start.circular,...n.animation.entry.start.circular}:b.animation.entry.start.circular}:b.animation.entry.start,timing:n.animation.entry.timing?{...b.animation.entry.timing,...n.animation.entry.timing}:b.animation.entry.timing,path:n.animation.entry.path?{...ht,...n.animation.entry.path}:b.animation.entry.path,rotation:n.animation.entry.rotation?{...dt,...n.animation.entry.rotation}:b.animation.entry.rotation,scale:n.animation.entry.scale?{...ut,...n.animation.entry.scale}:b.animation.entry.scale})),n.interaction&&(s.interaction={...b.interaction,...n.interaction},n.interaction.focus&&(s.interaction.focus={...b.interaction.focus,...n.interaction.focus}),n.interaction.navigation&&(s.interaction.navigation={...b.interaction.navigation,...n.interaction.navigation}),n.interaction.gestures&&(s.interaction.gestures={...b.interaction.gestures,...n.interaction.gestures})),n.rendering&&(s.rendering={...b.rendering,...n.rendering},n.rendering.responsive&&(s.rendering.responsive={...b.rendering.responsive,...n.rendering.responsive,breakpoints:n.rendering.responsive.breakpoints?{...b.rendering.responsive.breakpoints,...n.rendering.responsive.breakpoints}:b.rendering.responsive.breakpoints,mobileDetection:n.rendering.responsive.mobileDetection?n.rendering.responsive.mobileDetection:b.rendering.responsive.mobileDetection}),n.rendering.ui&&(s.rendering.ui={...b.rendering.ui,...n.rendering.ui}),n.rendering.performance&&(s.rendering.performance={...b.rendering.performance,...n.rendering.performance})),s.config.debug={...Tt,...n.config?.debug??{}},s}function re(n,t){return{...n?rt[n]:rt.playful,...t}}function ce(n,t){return{...n?ct[n]:ct.gentle,...t}}function le(n,t){return{...n?lt[n]:lt.gentle,...t}}class Rt{constructor(t){this.activeAnimations=new Map,this.animationIdCounter=0,this.config=t}buildTransformString(t){const e=["translate(-50%, -50%)"];if(t.x!==void 0||t.y!==void 0){const i=t.x??0,o=t.y??0;e.push(`translate(${i}px, ${o}px)`)}return t.rotation!==void 0&&e.push(`rotate(${t.rotation}deg)`),t.scale!==void 0&&e.push(`scale(${t.scale})`),e.join(" ")}animateTransformCancellable(t,e,i,o=null,a=null){this.cancelAllAnimations(t);const r=o??this.config.duration,s=a??this.config.easing.default,h=this.buildTransformString(e),c=this.buildTransformString(i);t.style.transition="none";const d=t.animate([{transform:h},{transform:c}],{duration:r,easing:s,fill:"forwards"}),l={id:`anim-${++this.animationIdCounter}`,element:t,animation:d,fromState:e,toState:i,startTime:performance.now(),duration:r};return this.activeAnimations.set(t,l),d.finished.then(()=>{t.style.transform=c,this.activeAnimations.delete(t)}).catch(()=>{this.activeAnimations.delete(t)}),l}cancelAnimation(t,e=!0){const i=this.getCurrentTransform(t.element);if(t.animation.cancel(),e){const o=this.buildTransformString({x:i.x,y:i.y,rotation:i.rotation,scale:i.scale});t.element.style.transform=o}return this.activeAnimations.delete(t.element),i}cancelAllAnimations(t){const e=this.activeAnimations.get(t);e&&this.cancelAnimation(e,!1);const i=t.getAnimations();for(const o of i)o.cancel()}getCurrentTransform(t){const i=getComputedStyle(t).transform;if(i==="none"||!i)return{x:0,y:0,rotation:0,scale:1};const o=new DOMMatrix(i),a=Math.sqrt(o.a*o.a+o.b*o.b),r=Math.atan2(o.b,o.a)*(180/Math.PI),s=o.e,h=o.f;return{x:s,y:h,rotation:r,scale:a}}hasActiveAnimation(t){return this.activeAnimations.has(t)}getAnimationHandle(t){return this.activeAnimations.get(t)}animateTransform(t,e,i=null,o=null){return new Promise(a=>{const r=i??this.config.duration,s=o??this.config.easing.default;t.style.transition=`transform ${r}ms ${s}, box-shadow ${r}ms ${s}`,t.style.transform=this.buildTransformString(e),setTimeout(()=>{a()},r)})}resetTransform(t,e){return this.animateTransform(t,e)}clearTransition(t){t.style.transition=""}wait(t){return new Promise(e=>setTimeout(e,t))}}function Z(n,t,e){return n+(t-n)*e}function he(n,t,e,i){const{overshoot:o,bounces:a,decayRatio:r}=i,s=e.x-t.x,h=e.y-t.y,c=de(a,r);let d=0,l=0,u=1,g=o,p=!1;for(let f=0;f<c.length;f++)if(n<=c[f].time){l=f===0?0:c[f-1].time,u=c[f].time,g=c[f].overshoot,p=c[f].isOvershoot;break}const y=(n-l)/(u-l);if(p)d=1+g*it(y);else if(l===0)d=it(y);else{const m=1+(c.find((x,v)=>x.time>l&&v>0&&c[v-1].isOvershoot)?.overshoot||g);d=Z(m,1,it(y))}return{x:t.x+s*d,y:t.y+h*d}}function de(n,t){const e=[];let i=.6;e.push({time:i,overshoot:0,isOvershoot:!1});let o=.15;const r=.4/(n*2);for(let s=0;s<n;s++)i+=r,e.push({time:i,overshoot:o,isOvershoot:!0}),i+=r,e.push({time:i,overshoot:o*t,isOvershoot:!1}),o*=t;return e.push({time:1,overshoot:0,isOvershoot:!1}),e}function ue(n,t,e,i){const{stiffness:o,damping:a,mass:r,oscillations:s}=i,h=e.x-t.x,c=e.y-t.y,d=Math.sqrt(o/r),l=a/(2*Math.sqrt(o*r));let u;if(l<1){const g=d*Math.sqrt(1-l*l),p=Math.exp(-l*d*n*3),y=Math.cos(g*n*s*Math.PI);u=1-p*y}else u=1-Math.exp(-d*n*3);return u=Math.max(0,Math.min(u,1.3)),{x:t.x+h*u,y:t.y+c*u}}function ge(n,t,e,i){const{amplitude:o,frequency:a,decay:r,decayRate:s,phase:h}=i,c=e.x-t.x,d=e.y-t.y,l=Math.sqrt(c*c+d*d),u=l>0?-d/l:0,g=l>0?c/l:1,p=a*Math.PI*2*n+h,y=r?Math.pow(1-n,s):1,f=o*Math.sin(p)*y,m=fe(n);return{x:Z(t.x,e.x,m)+f*u,y:Z(t.y,e.y,m)+f*g}}function it(n){return 1-(1-n)*(1-n)}function fe(n){return 1-Math.pow(1-n,3)}function me(n,t,e){const{amplitude:i,frequency:o,decay:a}=e,r=Math.sin(n*o*Math.PI*2),s=a?Math.pow(1-n,2):1,h=i*r*s;return t+h}function pe(n,t,e){const{overshoot:i,bounces:o}=e,a=[];a.push({time:.5,scale:i});let r=i;const s=.5,c=.5/(o*2);let d=.5;for(let u=0;u<o;u++){const g=1-(r-1)*s;d+=c,a.push({time:d,scale:g}),r=1+(r-1)*s*s,d+=c,u<o-1&&a.push({time:d,scale:r})}a.push({time:1,scale:1});let l=1;for(let u=0;u<a.length;u++)if(n<=a[u].time){const g=u===0?0:a[u-1].time,p=u===0?1:a[u-1].scale,y=(n-g)/(a[u].time-g),f=it(y);l=p+(a[u].scale-p)*f;break}return l*t}function Lt(n){const{element:t,startPosition:e,endPosition:i,pathConfig:o,duration:a,imageWidth:r,imageHeight:s,rotation:h,scale:c,onComplete:d,rotationConfig:l,startRotation:u,scaleConfig:g,startScale:p}=n,y=o.type,f=u!==void 0&&u!==h,m=l?.mode==="wobble",x=l?.wobble||{amplitude:15,frequency:3,decay:!0},v=f||m,w=p!==void 0&&p!==c,I=g?.mode==="pop",E=g?.pop||{overshoot:1.2,bounces:1};if((y==="linear"||y==="arc")&&!v&&!(w||I)){d&&d();return}const F=performance.now(),z=-r/2,_=-s/2;function H(X){const j=X-F,T=Math.min(j/a,1);let O;switch(y){case"bounce":{const $=re(o.bouncePreset,o.bounce);O=he(T,e,i,$);break}case"elastic":{const $=ce(o.elasticPreset,o.elastic);O=ue(T,e,i,$);break}case"wave":{const $=le(o.wavePreset,o.wave);O=ge(T,e,i,$);break}default:O={x:Z(e.x,i.x,T),y:Z(e.y,i.y,T)}}const k=O.x-i.x,N=O.y-i.y;let L;m?L=me(T,h,x):f?L=Z(u,h,T):L=h;let R;I?R=pe(T,c,E):w?R=Z(p,c,T):R=c,t.style.transform=`translate(${z}px, ${_}px) translate(${k}px, ${N}px) rotate(${L}deg) scale(${R})`,T<1?requestAnimationFrame(H):(t.style.transform=`translate(${z}px, ${_}px) rotate(${h}deg) scale(${c})`,d&&d())}requestAnimationFrame(H)}function Mt(n){return n==="bounce"||n==="elastic"||n==="wave"}const ye={radial:"center",spiral:"center",grid:"top",cluster:"nearest-edge",random:"nearest-edge",wave:"left"};class Ft{constructor(t,e){this.config=t,this.layoutAlgorithm=e,this.resolvedStartPosition=this.resolveStartPosition(),this.pathConfig=t.path||ht,this.rotationConfig=t.rotation||dt,this.scaleConfig=t.scale||ut}resolveStartPosition(){return this.config.start.position?this.config.start.position:ye[this.layoutAlgorithm]||"nearest-edge"}calculateStartPosition(t,e,i,o,a){const r=this.resolvedStartPosition,s=this.config.start.offset??100;switch(r){case"nearest-edge":return this.calculateNearestEdge(t,e,i,s);case"top":return this.calculateEdgePosition("top",t,e,i,s);case"bottom":return this.calculateEdgePosition("bottom",t,e,i,s);case"left":return this.calculateEdgePosition("left",t,e,i,s);case"right":return this.calculateEdgePosition("right",t,e,i,s);case"center":return this.calculateCenterPosition(i,t,e);case"random-edge":return this.calculateRandomEdge(t,e,i,s);case"circular":return this.calculateCircularPosition(t,e,i,o,a);default:return this.calculateNearestEdge(t,e,i,s)}}calculateNearestEdge(t,e,i,o){const a=t.x,r=t.y,s=a,h=i.width-a,c=r,d=i.height-r,l=Math.min(s,h,c,d);let u=t.x,g=t.y;return l===s?u=-(e.width+o):l===h?u=i.width+o:l===c?g=-(e.height+o):g=i.height+o,{x:u,y:g}}calculateEdgePosition(t,e,i,o,a){let r=e.x,s=e.y;switch(t){case"top":s=-(i.height+a);break;case"bottom":s=o.height+a;break;case"left":r=-(i.width+a);break;case"right":r=o.width+a;break}return{x:r,y:s}}calculateCenterPosition(t,e,i){const o=t.width/2,a=t.height/2;return{x:o,y:a,useScale:!0}}calculateRandomEdge(t,e,i,o){const a=["top","bottom","left","right"],r=a[Math.floor(Math.random()*a.length)];return this.calculateEdgePosition(r,t,e,i,o)}calculateCircularPosition(t,e,i,o,a){const r=this.config.start.circular||{},s=r.distribution||"even";let h;const c=r.radius||"120%";if(typeof c=="string"&&c.endsWith("%")){const y=parseFloat(c)/100;h=Math.sqrt(i.width**2+i.height**2)*y/2}else h=typeof c=="number"?c:500;let d;s==="even"?d=o/a*2*Math.PI:d=Math.random()*2*Math.PI;const l=i.width/2,u=i.height/2,g=l+Math.cos(d)*h,p=u+Math.sin(d)*h;return{x:g,y:p}}getAnimationParams(t){const e=this.config.timing.duration,i=this.config.easing;return{startTransform:"",duration:e,delay:0,easing:i}}buildStartTransform(t,e,i,o,a,r,s,h){const c=t.x-e.x,d=t.y-e.y,l=s!==void 0?s:i,u=h!==void 0?h:o,g=a!==void 0?-a/2:0,p=r!==void 0?-r/2:0,y=a!==void 0?`translate(${g}px, ${p}px)`:"translate(-50%, -50%)";return t.useScale?`${y} translate(${c}px, ${d}px) rotate(${l}deg) scale(0)`:`${y} translate(${c}px, ${d}px) rotate(${l}deg) scale(${u})`}buildFinalTransform(t,e,i,o){if(i!==void 0&&o!==void 0){const a=-i/2,r=-o/2;return`translate(${a}px, ${r}px) rotate(${t}deg) scale(${e})`}return`translate(-50%, -50%) rotate(${t}deg) scale(${e})`}getTransitionCSS(){const t=this.config.timing.duration,e=this.config.easing;return this.requiresJSAnimation()?`opacity ${t}ms ease-out`:`opacity ${t}ms ease-out, transform ${t}ms ${e}`}requiresJSAnimation(){return Mt(this.pathConfig.type)}getPathConfig(){return this.pathConfig}getPathType(){return this.pathConfig.type}getTiming(){return{duration:this.config.timing.duration}}getRotationConfig(){return this.rotationConfig}getRotationMode(){return this.rotationConfig.mode}calculateStartRotation(t){switch(this.rotationConfig.mode){case"none":return t;case"settle":{const i=this.rotationConfig.startRotation;if(i===void 0)return t+(Math.random()-.5)*60;if(typeof i=="number")return i;const o=i.max-i.min;return i.min+Math.random()*o}case"spin":{const i=this.rotationConfig.spinCount??1,o=this.resolveSpinDirection(t);return t+i*360*o}case"random":return t+(Math.random()-.5)*60;case"wobble":return t;default:return t}}resolveSpinDirection(t){switch(this.rotationConfig.direction??"auto"){case"clockwise":return-1;case"counterclockwise":return 1;case"random":return Math.random()<.5?1:-1;default:return t>=0?1:-1}}requiresJSRotation(){return this.rotationConfig.mode==="wobble"}calculateWobbleRotation(t,e){if(this.rotationConfig.mode!=="wobble")return e;const i=this.rotationConfig.wobble||{amplitude:15,frequency:3,decay:!0},{amplitude:o,frequency:a,decay:r}=i,s=Math.sin(t*a*Math.PI*2),h=r?Math.pow(1-t,2):1,c=o*s*h;return e+c}getScaleConfig(){return this.scaleConfig}getScaleMode(){return this.scaleConfig.mode}calculateStartScale(t){switch(this.scaleConfig.mode){case"none":return t;case"grow":return(this.scaleConfig.startScale??.3)*t;case"shrink":return(this.scaleConfig.startScale??1.5)*t;case"pop":return t;case"random":{const i=this.scaleConfig.range??{min:.5,max:1};return(i.min+Math.random()*(i.max-i.min))*t}default:return t}}requiresJSScale(){return this.scaleConfig.mode==="pop"}calculatePopScale(t,e){if(this.scaleConfig.mode!=="pop")return e;const i=this.scaleConfig.pop||{overshoot:1.2,bounces:1},{overshoot:o,bounces:a}=i,r=this.generateScaleBounceKeyframes(a,o);let s=e;for(let h=0;h<r.length;h++)if(t<=r[h].time){const c=h===0?0:r[h-1].time,d=h===0?e:r[h-1].scale,l=(t-c)/(r[h].time-c),u=this.easeOutQuad(l);s=d+(r[h].scale-d)*u;break}return s*e}generateScaleBounceKeyframes(t,e){const i=[];i.push({time:.5,scale:e});let o=e;const a=.5,s=.5/(t*2);let h=.5;for(let c=0;c<t;c++){const d=1-(o-1)*a;h+=s,i.push({time:h,scale:d}),o=1+(o-1)*a*a,h+=s,c<t-1&&i.push({time:h,scale:o})}return i.push({time:1,scale:1}),i}easeOutQuad(t){return 1-(1-t)*(1-t)}}class zt{constructor(t,e={}){this.config=t,this.imageConfig=e}generate(t,e,i={}){const o=[],{width:a,height:r}=e,s=this.config.spacing.padding,h=i.fixedHeight??200,c=this.imageConfig.rotation?.mode??"none",d=this.imageConfig.rotation?.range?.min??-15,l=this.imageConfig.rotation?.range?.max??15,u=this.imageConfig.sizing?.variance?.min??1,g=this.imageConfig.sizing?.variance?.max??1,p=u!==1||g!==1,f=h*1.5/2,m=h/2,x=a-s-f,v=r-s-m,w=s+f,I=s+m;for(let E=0;E<t;E++){const C=this.random(w,x),F=this.random(I,v),z=c==="random"?this.random(d,l):0,_=p?this.random(u,g):1,H=h*_,X={id:E,x:C,y:F,rotation:z,scale:_,baseSize:H};o.push(X)}return o}random(t,e){return Math.random()*(e-t)+t}}class Dt{constructor(t,e={}){this.config=t,this.imageConfig=e}generate(t,e,i={}){const o=[],{width:a,height:r}=e,s=i.fixedHeight??200,h=this.imageConfig.rotation?.mode??"none",c=this.imageConfig.rotation?.range?.min??-15,d=this.imageConfig.rotation?.range?.max??15,l=this.imageConfig.sizing?.variance?.min??1,u=this.imageConfig.sizing?.variance?.max??1,g=l!==1||u!==1,p=this.config.scaleDecay??0,y=i.fixedHeight??s,f=a/2,m=r/2,x=Math.ceil(Math.sqrt(t));if(t>0){const I=g?this.random(l,u):1,E=y*I;o.push({id:0,x:f,y:m,rotation:h==="random"?this.random(c*.33,d*.33):0,scale:I,baseSize:E,zIndex:100})}let v=1,w=1;for(;v<t;){const I=w/x,E=p>0?1-I*p*.5:1,C=w*(y*.8),F=C*1.5,z=Math.PI*(3*(F+C)-Math.sqrt((3*F+C)*(F+3*C))),_=this.estimateWidth(y),H=Math.floor(z/(_*.7));if(H===0){w++;continue}const X=2*Math.PI/H,j=w*(20*Math.PI/180);for(let T=0;T<H&&v<t;T++){const O=T*X+j,k=g?this.random(l,u):1,N=E*k,L=y*N;let R=f+Math.cos(O)*F,$=m+Math.sin(O)*C;const P=this.config.spacing.padding??50,U=L*1.5/2,M=L/2;R-U<P?R=P+U:R+U>a-P&&(R=a-P-U),$-M<P?$=P+M:$+M>r-P&&($=r-P-M);const G=h==="random"?this.random(c,d):0;o.push({id:v,x:R,y:$,rotation:G,scale:N,baseSize:L,zIndex:Math.max(1,100-w)}),v++}w++}return o}estimateWidth(t){return t*1.4}random(t,e){return Math.random()*(e-t)+t}}const be={columns:"auto",rows:"auto",stagger:"none",jitter:0,overlap:0,fillDirection:"row",alignment:"center",gap:10,overflowOffset:.25},Ot=[{x:1,y:1},{x:-1,y:-1},{x:1,y:-1},{x:-1,y:1},{x:-1,y:0},{x:1,y:0},{x:0,y:-1},{x:0,y:1}];class $t{constructor(t,e={}){this.config=t,this.imageConfig=e}generate(t,e,i={}){const o=[],{width:a,height:r}=e,s={...be,...this.config.grid},h=this.config.spacing.padding,c=i.fixedHeight??200,d=this.imageConfig.rotation?.mode??"none",l=this.imageConfig.sizing?.variance?.min??1,u=this.imageConfig.sizing?.variance?.max??1,g=l!==1||u!==1,p=a-2*h,y=r-2*h,{columns:f,rows:m}=this.calculateGridDimensions(t,p,y,c,s),x=s.stagger==="row",v=s.stagger==="column",w=x?f+.5:f,I=v?m+.5:m,E=(p-s.gap*(f-1))/w,C=(y-s.gap*(m-1))/I,F=x?E/2:0,z=v?C/2:0,_=1+s.overlap,H=Math.min(E,C)*_,X=i.fixedHeight?Math.min(i.fixedHeight,H):H,j=f*E+(f-1)*s.gap+F,T=m*C+(m-1)*s.gap+z,O=h+(p-j)/2,k=h+(y-T)/2,N=f*m,L=s.columns!=="auto"&&s.rows!=="auto",R=L&&t>N;typeof window<"u"&&(window.__gridOverflowDebug={gridConfigColumns:s.columns,gridConfigRows:s.rows,columns:f,rows:m,cellCount:N,hasFixedGrid:L,imageCount:t,isOverflowMode:R});const $=R?new Array(N).fill(0):[],P=Math.min(E,C)*s.overflowOffset;for(let D=0;D<t;D++){let U,M,G=0;if(R&&D>=N){const Y=D-N,W=Y%N;G=Math.floor(Y/N)+1,$[W]++,s.fillDirection==="row"?(U=W%f,M=Math.floor(W/f)):(M=W%m,U=Math.floor(W/m))}else s.fillDirection==="row"?(U=D%f,M=Math.floor(D/f)):(M=D%m,U=Math.floor(D/m));let q=O+U*(E+s.gap)+E/2,B=k+M*(C+s.gap)+C/2;if(s.stagger==="row"&&M%2===1?q+=E/2:s.stagger==="column"&&U%2===1&&(B+=C/2),G>0){const Y=(G-1)%Ot.length,W=Ot[Y];q+=W.x*P,B+=W.y*P}if(s.jitter>0){const Y=E/2*s.jitter,W=C/2*s.jitter;q+=this.random(-Y,Y),B+=this.random(-W,W)}let V=q,K=B;if(!R&&s.fillDirection==="row"){const Y=t%f||f;if(M===Math.floor((t-1)/f)&&Y<f){const Zt=Y*E+(Y-1)*s.gap;let It=0;s.alignment==="center"?It=(j-Zt)/2:s.alignment==="end"&&(It=j-Zt),V+=It}}const bt=g?this.random(l,u):1,Q=X*bt,st=Q*1.5/2,at=Q/2,wt=h+st,Et=a-h-st,$e=h+at,Pe=r-h-at;V=Math.max(wt,Math.min(V,Et)),K=Math.max($e,Math.min(K,Pe));let St=0;if(d==="random"){const Y=this.imageConfig.rotation?.range?.min??-15,W=this.imageConfig.rotation?.range?.max??15;s.jitter>0?St=this.random(Y*s.jitter,W*s.jitter):St=this.random(Y,W)}let xt;R&&G>0?xt=50-G:xt=R?100+D:D+1,o.push({id:D,x:V,y:K,rotation:St,scale:bt,baseSize:Q,zIndex:xt})}return o}calculateGridDimensions(t,e,i,o,a){let r,s;if(a.columns!=="auto"&&a.rows!=="auto")r=a.columns,s=a.rows;else if(a.columns!=="auto")r=a.columns,s=Math.ceil(t/r);else if(a.rows!=="auto")s=a.rows,r=Math.ceil(t/s);else{const h=e/i;for(r=Math.max(1,Math.round(Math.sqrt(t*h/1.4))),s=Math.ceil(t/r);r>1&&(r-1)*s>=t;)r--}return{columns:Math.max(1,r),rows:Math.max(1,s)}}random(t,e){return Math.random()*(e-t)+t}}const ve=Math.PI*(3-Math.sqrt(5)),we={spiralType:"golden",direction:"counterclockwise",tightness:1,scaleDecay:0,startAngle:0};class Pt{constructor(t,e={}){this.config=t,this.imageConfig=e}generate(t,e,i={}){const o=[],{width:a,height:r}=e,s={...we,...this.config.spiral},h=this.config.spacing.padding,c=i.fixedHeight??200,d=this.imageConfig.rotation?.mode??"none",l=this.imageConfig.rotation?.range?.min??-15,u=this.imageConfig.rotation?.range?.max??15,g=this.imageConfig.sizing?.variance?.min??1,p=this.imageConfig.sizing?.variance?.max??1,y=g!==1||p!==1,f=this.config.scaleDecay??s.scaleDecay,m=a/2,x=r/2,v=Math.min(m-h-c/2,x-h-c/2),w=s.direction==="clockwise"?-1:1;for(let I=0;I<t;I++){let E,C;if(s.spiralType==="golden")E=I*ve*w+s.startAngle,C=this.calculateGoldenRadius(I,t,v,s.tightness);else if(s.spiralType==="archimedean"){const q=I*.5*s.tightness;E=q*w+s.startAngle,C=this.calculateArchimedeanRadius(q,t,v,s.tightness)}else{const q=I*.3*s.tightness;E=q*w+s.startAngle,C=this.calculateLogarithmicRadius(q,t,v,s.tightness)}const F=m+Math.cos(E)*C,z=x+Math.sin(E)*C,_=C/v,H=f>0?1-_*f*.5:1,X=y?this.random(g,p):1,j=H*X,T=c*j,k=T*1.5/2,N=T/2,L=h+k,R=a-h-k,$=h+N,P=r-h-N,D=Math.max(L,Math.min(F,R)),U=Math.max($,Math.min(z,P));let M=0;if(d==="random"){const q=E*180/Math.PI%360,B=this.random(l,u);M=s.spiralType==="golden"?B:q*.1+B*.9}else d==="tangent"&&(M=this.calculateSpiralTangent(E,C,s));const G=t-I;o.push({id:I,x:D,y:U,rotation:M,scale:j,baseSize:T,zIndex:G})}return o}calculateSpiralTangent(t,e,i){let o;if(i.spiralType==="golden")o=t+Math.PI/2;else if(i.spiralType==="archimedean"){const r=1/i.tightness,s=Math.atan(e/r);o=t+s}else{const r=.15/i.tightness,s=Math.atan(1/r);o=t+s}return o*180/Math.PI%360-90}calculateGoldenRadius(t,e,i,o){const r=i/Math.sqrt(e)*Math.sqrt(t)/o;return Math.min(r,i)}calculateArchimedeanRadius(t,e,i,o){const a=e*.5*o;return t/a*i}calculateLogarithmicRadius(t,e,i,o){const a=i*.05,r=.15/o,s=a*Math.exp(r*t),h=e*.3*o,c=a*Math.exp(r*h);return s/c*i}random(t,e){return Math.random()*(e-t)+t}}const Ee={clusterCount:"auto",clusterSpread:150,clusterSpacing:200,density:"uniform",overlap:.3,distribution:"gaussian"};class Ut{constructor(t,e={}){this.config=t,this.imageConfig=e}generate(t,e,i={}){const o=[],{width:a,height:r}=e,s={...Ee,...this.config.cluster},h=this.config.spacing.padding,c=i.fixedHeight??200,d=this.imageConfig.rotation?.mode??"none",l=this.imageConfig.rotation?.range?.min??-15,u=this.imageConfig.rotation?.range?.max??15,g=this.imageConfig.sizing?.variance?.min??1,p=this.imageConfig.sizing?.variance?.max??1,y=g!==1||p!==1,f=this.calculateClusterCount(t,s.clusterCount,a,r,s.clusterSpacing),m=this.generateClusterCenters(f,a,r,h,s),x=new Array(f).fill(0);for(let w=0;w<t;w++)x[w%f]++;let v=0;for(let w=0;w<f;w++){const I=m[w],E=x[w];for(let C=0;C<E;C++){let F,z;if(s.distribution==="gaussian")F=this.gaussianRandom()*I.spread,z=this.gaussianRandom()*I.spread;else{const M=this.random(0,Math.PI*2),G=this.random(0,I.spread);F=Math.cos(M)*G,z=Math.sin(M)*G}const _=1+s.overlap*.5,H=1+s.overlap*.3;F/=_,z/=_;const X=y?this.random(g,p):1,j=H*X,T=c*j;let O=I.x+F,k=I.y+z;const L=T*1.5/2,R=T/2;O=Math.max(h+L,Math.min(O,a-h-L)),k=Math.max(h+R,Math.min(k,r-h-R));const $=d==="random"?this.random(l,u):0,D=Math.sqrt(F*F+z*z)/I.spread,U=Math.round((1-D)*50)+1;o.push({id:v,x:O,y:k,rotation:$,scale:j,baseSize:T,zIndex:U}),v++}}return o}calculateClusterCount(t,e,i,o,a){if(e!=="auto")return Math.max(1,Math.min(e,t));const s=Math.max(1,Math.ceil(t/8)),h=Math.floor(i/a*(o/a)*.6);return Math.max(1,Math.min(s,h,10))}generateClusterCenters(t,e,i,o,a){const r=[],h=o+a.clusterSpread,c=e-o-a.clusterSpread,d=o+a.clusterSpread,l=i-o-a.clusterSpread;for(let u=0;u<t;u++){let g=null,p=-1;for(let y=0;y<100;y++){const f={x:this.random(h,c),y:this.random(d,l),spread:this.calculateClusterSpread(a)};let m=1/0;for(const x of r){const v=f.x-x.x,w=f.y-x.y,I=Math.sqrt(v*v+w*w);m=Math.min(m,I)}if((r.length===0||m>p)&&(g=f,p=m),m>=a.clusterSpacing)break}g&&r.push(g)}return r}calculateClusterSpread(t){return t.density==="uniform"?t.clusterSpread:t.clusterSpread*this.random(.5,1.5)}gaussianRandom(){let t=0,e=0;for(;t===0;)t=Math.random();for(;e===0;)e=Math.random();const i=Math.sqrt(-2*Math.log(t))*Math.cos(2*Math.PI*e);return Math.max(-3,Math.min(3,i))/3}random(t,e){return Math.random()*(e-t)+t}}class _t{constructor(t,e={}){this.config=t,this.imageConfig=e}generate(t,e,i={}){const o=[],{width:a,height:r}=e,s=i.fixedHeight??200,h=this.config.spacing.padding??50,c=this.imageConfig.rotation?.mode??"none",d=this.imageConfig.rotation?.range?.min??-15,l=this.imageConfig.rotation?.range?.max??15,u=this.imageConfig.sizing?.variance?.min??1,g=this.imageConfig.sizing?.variance?.max??1,p=u!==1||g!==1,y=i.fixedHeight??s,f={...Kt,...this.config.wave},{rows:m,amplitude:x,frequency:v,phaseShift:w,synchronization:I}=f,E=Math.ceil(t/m),z=y*1.5/2,_=h+z,H=a-h-z,X=H-_,j=E>1?X/(E-1):0,T=h+x+y/2,O=r-h-x-y/2,k=O-T,N=m>1?k/(m-1):0;let L=0;for(let R=0;R<m&&L<t;R++){const $=m===1?(T+O)/2:T+R*N;let P=0;I==="offset"?P=R*w:I==="alternating"&&(P=R*Math.PI);for(let D=0;D<E&&L<t;D++){const U=E===1?(_+H)/2:_+D*j,M=this.calculateWaveY(U,a,x,v,P),G=U,q=$+M,B=p?this.random(u,g):1,V=y*B;let K=0;c==="tangent"?K=this.calculateRotation(U,a,x,v,P):c==="random"&&(K=this.random(d,l));const Q=V*1.5/2,vt=V/2,st=h+Q,at=a-h-Q,wt=h+vt,Et=r-h-vt;o.push({id:L,x:Math.max(st,Math.min(G,at)),y:Math.max(wt,Math.min(q,Et)),rotation:K,scale:B,baseSize:V,zIndex:L+1}),L++}}return o}calculateWaveY(t,e,i,o,a){const r=t/e;return i*Math.sin(o*r*2*Math.PI+a)}calculateRotation(t,e,i,o,a){const r=t/e,s=i*o*2*Math.PI*Math.cos(o*r*2*Math.PI+a)/e;return Math.atan(s)*(180/Math.PI)}random(t,e){return Math.random()*(e-t)+t}}class Ht{constructor(t){this.config=t.layout,this.imageConfig=t.image,this.layouts=new Map,this.placementLayout=this.initLayout()}initLayout(){switch(this.config.algorithm){case"radial":return new Dt(this.config,this.imageConfig);case"grid":return new $t(this.config,this.imageConfig);case"spiral":return new Pt(this.config,this.imageConfig);case"cluster":return new Ut(this.config,this.imageConfig);case"wave":return new _t(this.config,this.imageConfig);default:return new zt(this.config,this.imageConfig)}}generateLayout(t,e,i={}){const o=this.placementLayout.generate(t,e,i);return o.forEach(a=>{this.layouts.set(a.id,a)}),o}getOriginalState(t){return this.layouts.get(Number(t))}reset(){this.layouts.clear()}updateConfig(t){t.layout&&(Object.assign(this.config,t.layout),t.layout.algorithm&&t.layout.algorithm!==this.config.algorithm&&(this.placementLayout=this.initLayout())),t.image&&Object.assign(this.imageConfig,t.image)}getBreakpoints(){return this.config.responsive??{mobile:{maxWidth:767},tablet:{maxWidth:1199}}}resolveBreakpoint(t){const e=this.getBreakpoints();return t<=e.mobile.maxWidth?"mobile":t<=e.tablet.maxWidth?"tablet":"screen"}resolveBaseHeight(t){const e=this.imageConfig.sizing;if(!e||e.mode==="adaptive")return;const i=e.height;if(i===void 0)return;if(typeof i=="number")return i;const o=i,a=this.resolveBreakpoint(t);return a==="mobile"?o.mobile??o.tablet??o.screen:a==="tablet"?o.tablet??o.screen??o.mobile:o.screen??o.tablet??o.mobile}calculateAdaptiveSize(t,e,i,o){const a=this.imageConfig.sizing,r=this.resolveBaseHeight(o);if(r!==void 0)return{height:r};const s=a?.minSize??50,h=a?.maxSize??400,c=this.config.targetCoverage??.6,d=this.config.densityFactor??1,{width:l,height:u}=t,y=l*u*c/e;let m=Math.sqrt(y/1.4);m*=d,m=Math.min(m,i);let x=this.clamp(m,s,h);if(x===s&&m<s){const v=Math.max(s*.05,20);x=Math.max(v,m)}return{height:x}}clamp(t,e,i){return Math.max(e,Math.min(i,t))}}var S=(n=>(n.IDLE="idle",n.FOCUSING="focusing",n.FOCUSED="focused",n.UNFOCUSING="unfocusing",n.CROSS_ANIMATING="cross_animating",n))(S||{});const Nt={circle:"circle(50%)",square:"polygon(0% 0%, 100% 0%, 100% 100%, 0% 100%)",triangle:"polygon(50% 0%, 100% 100%, 0% 100%)",pentagon:"polygon(50% 0%, 100% 38%, 82% 100%, 18% 100%, 0% 38%)",hexagon:"polygon(25% 0%, 75% 0%, 100% 50%, 75% 100%, 25% 100%, 0% 50%)",octagon:"polygon(30% 0%, 70% 0%, 100% 30%, 100% 70%, 70% 100%, 30% 100%, 0% 70%, 0% 30%)",diamond:"polygon(50% 0%, 100% 50%, 50% 100%, 0% 50%)"},Se={circle:{refHeight:100,points:[]},square:{refHeight:100,points:[[0,0],[100,0],[100,100],[0,100]]},triangle:{refHeight:100,points:[[50,0],[100,100],[0,100]]},pentagon:{refHeight:100,points:[[50,0],[100,38],[82,100],[18,100],[0,38]]},hexagon:{refHeight:100,points:[[25,0],[75,0],[100,50],[75,100],[25,100],[0,50]]},octagon:{refHeight:100,points:[[30,0],[70,0],[100,30],[100,70],[70,100],[30,100],[0,70],[0,30]]},diamond:{refHeight:100,points:[[50,0],[100,50],[50,100],[0,50]]}};function xe(n){if(n)return n in Nt?Nt[n]:n}function Ie(n,t,e){const i=Se[n];if(!i)return"";const o=t/i.refHeight;if(n==="circle")return`circle(${Math.round(50*o*100)/100}px)`;const a=i.refHeight*o,r=a/2,s=a/2,h=(e??a)/2,c=t/2,d=h-r,l=c-s;return`polygon(${i.points.map(([g,p])=>{const y=Math.round((g*o+d)*100)/100,f=Math.round((p*o+l)*100)/100;return`${y}px ${f}px`}).join(", ")})`}function Ae(n){return n in J}function Ce(n){return n?Ae(n)?J[n]:n:J.md}function Te(n){if(!n)return"";const t=[];if(n.grayscale!==void 0&&t.push(`grayscale(${n.grayscale})`),n.blur!==void 0&&t.push(`blur(${n.blur}px)`),n.brightness!==void 0&&t.push(`brightness(${n.brightness})`),n.contrast!==void 0&&t.push(`contrast(${n.contrast})`),n.saturate!==void 0&&t.push(`saturate(${n.saturate})`),n.opacity!==void 0&&t.push(`opacity(${n.opacity})`),n.sepia!==void 0&&t.push(`sepia(${n.sepia})`),n.hueRotate!==void 0&&t.push(`hue-rotate(${n.hueRotate}deg)`),n.invert!==void 0&&t.push(`invert(${n.invert})`),n.dropShadow!==void 0)if(typeof n.dropShadow=="string")t.push(`drop-shadow(${n.dropShadow})`);else{const e=n.dropShadow;t.push(`drop-shadow(${e.x}px ${e.y}px ${e.blur}px ${e.color})`)}return t.join(" ")}function et(n){if(!n||n.style==="none"||n.width===0)return"none";const t=n.width??0,e=n.style??"solid",i=n.color??"#000000";return`${t}px ${e} ${i}`}function ft(n,t,e){if(!n)return{};const i={};if(n.borderRadiusTopLeft!==void 0||n.borderRadiusTopRight!==void 0||n.borderRadiusBottomRight!==void 0||n.borderRadiusBottomLeft!==void 0){const s=n.border?.radius??0;n.borderRadiusTopLeft!==void 0?i.borderTopLeftRadius=`${n.borderRadiusTopLeft}px`:s&&(i.borderTopLeftRadius=`${s}px`),n.borderRadiusTopRight!==void 0?i.borderTopRightRadius=`${n.borderRadiusTopRight}px`:s&&(i.borderTopRightRadius=`${s}px`),n.borderRadiusBottomRight!==void 0?i.borderBottomRightRadius=`${n.borderRadiusBottomRight}px`:s&&(i.borderBottomRightRadius=`${s}px`),n.borderRadiusBottomLeft!==void 0?i.borderBottomLeftRadius=`${n.borderRadiusBottomLeft}px`:s&&(i.borderBottomLeftRadius=`${s}px`)}else n.border?.radius!==void 0&&(i.borderRadius=`${n.border.radius}px`);if(n.borderTop||n.borderRight||n.borderBottom||n.borderLeft){const s=n.border||{},h={...s,...n.borderTop},c={...s,...n.borderRight},d={...s,...n.borderBottom},l={...s,...n.borderLeft};i.borderTop=et(h),i.borderRight=et(c),i.borderBottom=et(d),i.borderLeft=et(l)}else n.border&&(i.border=et(n.border));n.shadow!==void 0&&(i.boxShadow=Ce(n.shadow));const r=Te(n.filter);if(i.filter=r||"none",n.opacity!==void 0&&(i.opacity=String(n.opacity)),n.cursor!==void 0&&(i.cursor=n.cursor),n.outline&&n.outline.style!=="none"&&(n.outline.width??0)>0){const s=n.outline.width??0,h=n.outline.style??"solid",c=n.outline.color??"#000000";i.outline=`${s}px ${h} ${c}`,n.outline.offset!==void 0&&(i.outlineOffset=`${n.outline.offset}px`)}if(n.objectFit!==void 0&&(i.objectFit=n.objectFit),n.aspectRatio!==void 0&&(i.aspectRatio=n.aspectRatio),n.clipPath!==void 0){let s;const h=typeof n.clipPath=="object"&&n.clipPath!==null&&"shape"in n.clipPath,c=h?n.clipPath:void 0;if(c?.mode==="height-relative"&&t)s=Ie(c.shape,t,e);else{const d=h&&c?c.shape:n.clipPath;s=xe(d)}s&&(s==="none"?i.clipPath="unset":(i.clipPath=s,i.overflow="hidden"))}return i}function Re(n,t){t.borderRadius!==void 0&&(n.style.borderRadius=t.borderRadius),t.borderTopLeftRadius!==void 0&&(n.style.borderTopLeftRadius=t.borderTopLeftRadius),t.borderTopRightRadius!==void 0&&(n.style.borderTopRightRadius=t.borderTopRightRadius),t.borderBottomRightRadius!==void 0&&(n.style.borderBottomRightRadius=t.borderBottomRightRadius),t.borderBottomLeftRadius!==void 0&&(n.style.borderBottomLeftRadius=t.borderBottomLeftRadius),t.border!==void 0&&(n.style.border=t.border),t.borderTop!==void 0&&(n.style.borderTop=t.borderTop),t.borderRight!==void 0&&(n.style.borderRight=t.borderRight),t.borderBottom!==void 0&&(n.style.borderBottom=t.borderBottom),t.borderLeft!==void 0&&(n.style.borderLeft=t.borderLeft),t.boxShadow!==void 0&&(n.style.boxShadow=t.boxShadow),t.filter!==void 0&&(n.style.filter=t.filter),t.opacity!==void 0&&(n.style.opacity=t.opacity),t.cursor!==void 0&&(n.style.cursor=t.cursor),t.outline!==void 0&&(n.style.outline=t.outline),t.outlineOffset!==void 0&&(n.style.outlineOffset=t.outlineOffset),t.objectFit!==void 0&&(n.style.objectFit=t.objectFit),t.aspectRatio!==void 0&&(n.style.aspectRatio=t.aspectRatio),t.clipPath!==void 0&&(n.style.clipPath=t.clipPath),t.overflow!==void 0&&(n.style.overflow=t.overflow)}function mt(n,t,e,i){const o=ft(t,e,i);Re(n,o)}function jt(n){return n?Array.isArray(n)?n.join(" "):n:""}function nt(n,t){const e=jt(t);e&&e.split(" ").forEach(i=>{i.trim()&&n.classList.add(i.trim())})}function pt(n,t){const e=jt(t);e&&e.split(" ").forEach(i=>{i.trim()&&n.classList.remove(i.trim())})}const Wt={UNFOCUSING:999,FOCUSING:1e3};class kt{constructor(t,e,i){this.state=S.IDLE,this.currentFocus=null,this.focusData=null,this.outgoing=null,this.incoming=null,this.focusGeneration=0,this.config=t,this.animationEngine=e,this.styling=i,this.focusedClassName=i?.focused?.className}getState(){return this.state}isAnimating(){return this.state!==S.IDLE&&this.state!==S.FOCUSED}normalizeScalePercent(t){return t>1?t/100:t}calculateFocusDimensions(t,e,i){const o=this.normalizeScalePercent(this.config.scalePercent),a=i.height*o,r=t/e;let s=a,h=s*r;const c=i.width*o;return h>c&&(h=c,s=h/r),{width:h,height:s}}calculateFocusTransform(t,e){const i=t.width/2,o=t.height/2,a=i-e.x,r=o-e.y;return{x:a,y:r,rotation:0,scale:1}}buildDimensionZoomTransform(t){const e=["translate(-50%, -50%)"];if(t.x!==void 0||t.y!==void 0){const i=t.x??0,o=t.y??0;e.push(`translate(${i}px, ${o}px)`)}return t.rotation!==void 0&&e.push(`rotate(${t.rotation}deg)`),e.join(" ")}animateWithDimensions(t,e,i,o,a,r,s,h){const c=this.buildDimensionZoomTransform(e),d=this.buildDimensionZoomTransform(i);return t.style.transition="none",t.animate([{transform:c,width:`${o}px`,height:`${a}px`},{transform:d,width:`${r}px`,height:`${s}px`}],{duration:h,easing:"cubic-bezier(0.4, 0, 0.2, 1)",fill:"forwards"})}applyFocusedStyling(t,e){t.style.zIndex=String(e),t.classList.add("fbn-ic-focused"),nt(t,this.focusedClassName)}removeFocusedStyling(t,e){t.style.zIndex=e,t.classList.remove("fbn-ic-focused"),pt(t,this.focusedClassName)}startClipPathAnimation(t,e,i){let o=i?this.styling?.focused??this.styling?.default:this.styling?.default;i&&this.styling?.focused&&this.styling.focused.clipPath===void 0&&(o={...o,clipPath:void 0});const a=()=>{const r=t.offsetHeight,s=t.offsetWidth,h=ft(o,r,s);h.clipPath!==void 0?t.style.clipPath=h.clipPath:t.style.clipPath="unset",h.overflow!==void 0&&(t.style.overflow=h.overflow),e.animation.playState==="running"&&requestAnimationFrame(a)};requestAnimationFrame(a)}startFocusAnimation(t,e,i,o,a){const r=t.style.zIndex||"",s=t.offsetWidth,h=t.offsetHeight,c=this.calculateFocusDimensions(s,h,e),d=this.calculateFocusTransform(e,i);this.animationEngine.cancelAllAnimations(t);const l=this.config.animationDuration??600;this.applyFocusedStyling(t,Wt.FOCUSING);const u=o??{x:0,y:0,rotation:i.rotation,scale:1},g=a?.width??s,p=a?.height??h,y=this.animateWithDimensions(t,u,d,g,p,c.width,c.height,l),f={id:`focus-${Date.now()}`,element:t,animation:y,fromState:u,toState:d,startTime:performance.now(),duration:l};return this.focusData={element:t,originalState:i,focusTransform:d,originalZIndex:r,originalWidth:s,originalHeight:h,focusWidth:c.width,focusHeight:c.height},this.startClipPathAnimation(t,f,!0),{element:t,originalState:i,animationHandle:f,direction:"in",originalWidth:s,originalHeight:h}}startUnfocusAnimation(t,e,i,o){t.style.zIndex=String(Wt.UNFOCUSING),this.animationEngine.cancelAllAnimations(t);const a=this.config.animationDuration??600;t.classList.remove("fbn-ic-focused"),pt(t,this.focusedClassName);const r=i??this.focusData?.focusTransform??{x:0,y:0,rotation:0,scale:1},s=o?.width??this.focusData?.focusWidth??t.offsetWidth,h=o?.height??this.focusData?.focusHeight??t.offsetHeight,c={x:0,y:0,rotation:e.rotation,scale:1},d=this.focusData?.originalWidth??t.offsetWidth,l=this.focusData?.originalHeight??t.offsetHeight,u=this.animateWithDimensions(t,r,c,s,h,d,l,a),g={id:`unfocus-${Date.now()}`,element:t,animation:u,fromState:r,toState:c,startTime:performance.now(),duration:a};return this.startClipPathAnimation(t,g,!1),{element:t,originalState:e,animationHandle:g,direction:"out",originalWidth:d,originalHeight:l}}captureMidAnimationState(t){const e=getComputedStyle(t),i=new DOMMatrix(e.transform),o=t.offsetWidth,a=t.offsetHeight,r=i.e+o*.5,s=i.f+a*.5,h=Math.atan2(i.b,i.a)*(180/Math.PI);return t.style.width=`${o}px`,t.style.height=`${a}px`,t.style.transform=`translate(-50%, -50%) translate(${r}px, ${s}px) rotate(${h}deg)`,t.style.transition="none",{transform:{x:r,y:s,rotation:h,scale:1},dimensions:{width:o,height:a}}}async waitForAnimation(t){try{await t.animation.finished}catch{}}resetElementInstantly(t,e,i,o,a){this.animationEngine.cancelAllAnimations(t);const r=["translate(-50%, -50%)"];r.push("translate(0px, 0px)"),r.push(`rotate(${e.rotation}deg)`),t.style.transition="none",t.style.transform=r.join(" "),o!==void 0&&a!==void 0&&(t.style.width=`${o}px`,t.style.height=`${a}px`),this.removeFocusedStyling(t,i)}async focusImage(t,e,i){if(this.currentFocus===t&&this.state===S.FOCUSED)return this.unfocusImage();if(this.incoming?.element===t&&this.state===S.FOCUSING){const{transform:a,dimensions:r}=this.captureMidAnimationState(t);this.animationEngine.cancelAllAnimations(t),this.outgoing=this.startUnfocusAnimation(t,this.incoming.originalState,a,r),this.incoming=null,this.state=S.UNFOCUSING,await this.waitForAnimation(this.outgoing.animationHandle),this.removeFocusedStyling(this.outgoing.element,this.focusData?.originalZIndex||""),this.outgoing=null,this.currentFocus=null,this.focusData=null,this.state=S.IDLE;return}const o=++this.focusGeneration;switch(this.state){case S.IDLE:if(this.state=S.FOCUSING,this.incoming=this.startFocusAnimation(t,e,i),await this.waitForAnimation(this.incoming.animationHandle),this.focusGeneration!==o)return;this.currentFocus=t,this.incoming=null,this.state=S.FOCUSED;break;case S.FOCUSED:if(this.state=S.CROSS_ANIMATING,this.currentFocus&&this.focusData&&(this.outgoing=this.startUnfocusAnimation(this.currentFocus,this.focusData.originalState)),this.incoming=this.startFocusAnimation(t,e,i),await Promise.all([this.outgoing?this.waitForAnimation(this.outgoing.animationHandle):Promise.resolve(),this.waitForAnimation(this.incoming.animationHandle)]),this.focusGeneration!==o)return;this.outgoing&&(this.removeFocusedStyling(this.outgoing.element,this.outgoing.originalState.zIndex?.toString()||""),this.outgoing=null),this.currentFocus=t,this.incoming=null,this.state=S.FOCUSED;break;case S.FOCUSING:if(this.incoming&&(this.animationEngine.cancelAnimation(this.incoming.animationHandle,!1),this.resetElementInstantly(this.incoming.element,this.incoming.originalState,this.focusData?.originalZIndex||"",this.focusData?.originalWidth,this.focusData?.originalHeight),this.incoming=null),this.incoming=this.startFocusAnimation(t,e,i),await this.waitForAnimation(this.incoming.animationHandle),this.focusGeneration!==o)return;this.currentFocus=t,this.incoming=null,this.state=S.FOCUSED;break;case S.UNFOCUSING:if(this.state=S.CROSS_ANIMATING,this.incoming=this.startFocusAnimation(t,e,i),await Promise.all([this.outgoing?this.waitForAnimation(this.outgoing.animationHandle):Promise.resolve(),this.waitForAnimation(this.incoming.animationHandle)]),this.focusGeneration!==o)return;this.outgoing&&(this.removeFocusedStyling(this.outgoing.element,this.outgoing.originalState.zIndex?.toString()||""),this.outgoing=null),this.currentFocus=t,this.incoming=null,this.state=S.FOCUSED;break;case S.CROSS_ANIMATING:if(this.incoming?.element===t)return;if(this.outgoing?.element===t){const{transform:a,dimensions:r}=this.captureMidAnimationState(t);if(this.animationEngine.cancelAllAnimations(t),this.incoming){const{transform:s,dimensions:h}=this.captureMidAnimationState(this.incoming.element);this.animationEngine.cancelAllAnimations(this.incoming.element),this.outgoing=this.startUnfocusAnimation(this.incoming.element,this.incoming.originalState,s,h)}else this.outgoing=null;if(this.incoming=this.startFocusAnimation(t,e,i,a,r),await Promise.all([this.outgoing?this.waitForAnimation(this.outgoing.animationHandle):Promise.resolve(),this.waitForAnimation(this.incoming.animationHandle)]),this.focusGeneration!==o)return;this.outgoing&&(this.removeFocusedStyling(this.outgoing.element,this.outgoing.originalState.zIndex?.toString()||""),this.outgoing=null),this.currentFocus=t,this.incoming=null,this.state=S.FOCUSED;return}if(this.outgoing&&(this.animationEngine.cancelAnimation(this.outgoing.animationHandle,!1),this.resetElementInstantly(this.outgoing.element,this.outgoing.originalState,this.outgoing.originalState.zIndex?.toString()||"",this.outgoing.originalWidth,this.outgoing.originalHeight),this.outgoing=null),this.incoming){const{transform:a,dimensions:r}=this.captureMidAnimationState(this.incoming.element);this.animationEngine.cancelAllAnimations(this.incoming.element),this.outgoing=this.startUnfocusAnimation(this.incoming.element,this.incoming.originalState,a,r)}if(this.incoming=this.startFocusAnimation(t,e,i),await Promise.all([this.outgoing?this.waitForAnimation(this.outgoing.animationHandle):Promise.resolve(),this.waitForAnimation(this.incoming.animationHandle)]),this.focusGeneration!==o)return;this.outgoing&&(this.removeFocusedStyling(this.outgoing.element,this.outgoing.originalState.zIndex?.toString()||""),this.outgoing=null),this.currentFocus=t,this.incoming=null,this.state=S.FOCUSED;break}}async unfocusImage(){if(this.state===S.UNFOCUSING)return;const t=++this.focusGeneration;if(!this.currentFocus||!this.focusData){if(this.incoming&&this.state===S.FOCUSING){const{transform:a,dimensions:r}=this.captureMidAnimationState(this.incoming.element);if(this.animationEngine.cancelAllAnimations(this.incoming.element),this.outgoing=this.startUnfocusAnimation(this.incoming.element,this.incoming.originalState,a,r),this.incoming=null,this.state=S.UNFOCUSING,await this.waitForAnimation(this.outgoing.animationHandle),this.focusGeneration!==t)return;this.removeFocusedStyling(this.outgoing.element,this.focusData?.originalZIndex||""),this.outgoing=null,this.focusData=null,this.state=S.IDLE}return}if(this.state===S.CROSS_ANIMATING&&this.incoming){const{transform:a,dimensions:r}=this.captureMidAnimationState(this.incoming.element);this.animationEngine.cancelAllAnimations(this.incoming.element);const s=this.startUnfocusAnimation(this.incoming.element,this.incoming.originalState,a,r);if(await Promise.all([this.outgoing?this.waitForAnimation(this.outgoing.animationHandle):Promise.resolve(),this.waitForAnimation(s.animationHandle)]),this.focusGeneration!==t)return;this.outgoing&&this.removeFocusedStyling(this.outgoing.element,this.outgoing.originalState.zIndex?.toString()||""),this.removeFocusedStyling(s.element,this.incoming.originalState.zIndex?.toString()||""),this.outgoing=null,this.incoming=null,this.currentFocus=null,this.focusData=null,this.state=S.IDLE;return}this.state=S.UNFOCUSING;const e=this.currentFocus,i=this.focusData.originalState,o=this.focusData.originalZIndex;this.outgoing=this.startUnfocusAnimation(e,i),await this.waitForAnimation(this.outgoing.animationHandle),this.focusGeneration===t&&(this.removeFocusedStyling(e,o),this.outgoing=null,this.currentFocus=null,this.focusData=null,this.state=S.IDLE)}async swapFocus(t,e,i){return this.focusImage(t,e,i)}getCurrentFocus(){return this.currentFocus}isFocused(t){return this.currentFocus===t&&this.state===S.FOCUSED}isTargetingFocus(t){return this.incoming?.element===t}isInvolved(t){return this.currentFocus===t||this.incoming?.element===t||this.outgoing?.element===t}setDragOffset(t){if(!this.currentFocus||!this.focusData||this.state!==S.FOCUSED)return;const e=this.currentFocus,i=this.focusData.focusTransform,o=["translate(-50%, -50%)"],a=(i.x??0)+t,r=i.y??0;o.push(`translate(${a}px, ${r}px)`),i.rotation!==void 0&&o.push(`rotate(${i.rotation}deg)`),e.style.transition="none",e.style.transform=o.join(" ")}clearDragOffset(t,e=150){if(!this.currentFocus||!this.focusData||this.state!==S.FOCUSED)return;const i=this.currentFocus,o=this.focusData.focusTransform,a=["translate(-50%, -50%)"],r=o.x??0,s=o.y??0;a.push(`translate(${r}px, ${s}px)`),o.rotation!==void 0&&a.push(`rotate(${o.rotation}deg)`);const h=a.join(" ");t?(i.style.transition=`transform ${e}ms ease-out`,i.style.transform=h,setTimeout(()=>{this.currentFocus===i&&(i.style.transition="none")},e)):(i.style.transition="none",i.style.transform=h)}reset(){this.outgoing&&(this.animationEngine.cancelAnimation(this.outgoing.animationHandle,!1),this.resetElementInstantly(this.outgoing.element,this.outgoing.originalState,this.outgoing.originalState.zIndex?.toString()||"",this.outgoing.originalWidth,this.outgoing.originalHeight)),this.incoming&&(this.animationEngine.cancelAnimation(this.incoming.animationHandle,!1),this.resetElementInstantly(this.incoming.element,this.incoming.originalState,this.focusData?.originalZIndex||"",this.focusData?.originalWidth,this.focusData?.originalHeight)),this.currentFocus&&this.focusData&&this.resetElementInstantly(this.currentFocus,this.focusData.originalState,this.focusData.originalZIndex,this.focusData.originalWidth,this.focusData.originalHeight),this.state=S.IDLE,this.currentFocus=null,this.focusData=null,this.outgoing=null,this.incoming=null}}const Le=50,Me=.5,Fe=20,ze=.3,De=150,Oe=30,ot=class ot{constructor(t,e){this.enabled=!1,this.touchState=null,this.recentTouchTimestamp=0,this.container=t,this.callbacks=e,this.boundTouchStart=this.handleTouchStart.bind(this),this.boundTouchMove=this.handleTouchMove.bind(this),this.boundTouchEnd=this.handleTouchEnd.bind(this),this.boundTouchCancel=this.handleTouchCancel.bind(this)}enable(){this.enabled||(this.enabled=!0,this.container.style.touchAction="pan-y",this.container.addEventListener("touchstart",this.boundTouchStart,{passive:!1}),this.container.addEventListener("touchmove",this.boundTouchMove,{passive:!1}),this.container.addEventListener("touchend",this.boundTouchEnd,{passive:!0}),this.container.addEventListener("touchcancel",this.boundTouchCancel,{passive:!0}))}disable(){this.enabled&&(this.enabled=!1,this.container.style.touchAction="",this.container.removeEventListener("touchstart",this.boundTouchStart),this.container.removeEventListener("touchmove",this.boundTouchMove),this.container.removeEventListener("touchend",this.boundTouchEnd),this.container.removeEventListener("touchcancel",this.boundTouchCancel),this.touchState?.isDragging&&this.callbacks.onDragEnd(!1),this.touchState=null)}destroy(){this.disable()}hadRecentTouch(){return Date.now()-this.recentTouchTimestamp<ot.TOUCH_CLICK_DELAY}handleTouchStart(t){if(t.touches.length!==1)return;this.recentTouchTimestamp=Date.now();const e=t.touches[0];this.touchState={startX:e.clientX,startY:e.clientY,startTime:performance.now(),currentX:e.clientX,isDragging:!1,isHorizontalSwipe:null}}handleTouchMove(t){if(!this.touchState||t.touches.length!==1)return;const e=t.touches[0],i=e.clientX-this.touchState.startX,o=e.clientY-this.touchState.startY;if(this.touchState.isHorizontalSwipe===null&&Math.sqrt(i*i+o*o)>10){const s=Math.atan2(Math.abs(o),Math.abs(i))*(180/Math.PI);this.touchState.isHorizontalSwipe=s<=Oe}if(this.touchState.isHorizontalSwipe!==!1&&this.touchState.isHorizontalSwipe===!0){t.preventDefault(),this.touchState.isDragging=!0,this.touchState.currentX=e.clientX;const a=i*ze;this.callbacks.onDragOffset(a)}}handleTouchEnd(t){if(!this.touchState)return;this.recentTouchTimestamp=Date.now();const e=this.touchState.currentX-this.touchState.startX,i=performance.now()-this.touchState.startTime,o=Math.abs(e)/i,a=Math.abs(e);let r=!1;this.touchState.isHorizontalSwipe===!0&&this.touchState.isDragging&&(a>=Le||o>=Me&&a>=Fe)&&(r=!0,e<0?this.callbacks.onNext():this.callbacks.onPrev()),this.touchState.isDragging&&this.callbacks.onDragEnd(r),this.touchState=null}handleTouchCancel(t){this.touchState?.isDragging&&this.callbacks.onDragEnd(!1),this.touchState=null}};ot.TOUCH_CLICK_DELAY=300;let yt=ot;class Gt{constructor(t){if(this._prepared=!1,this._discoveredUrls=[],this.apiKey=t.apiKey??"",this.apiEndpoint=t.apiEndpoint??"https://www.googleapis.com/drive/v3/files",this.debugLogging=t.debugLogging??!1,this.sources=t.sources??[],!this.sources||this.sources.length===0)throw new Error("GoogleDriveLoader requires at least one source to be configured")}async prepare(t){this._discoveredUrls=[];for(const e of this.sources)if("folders"in e)for(const i of e.folders){const o=e.recursive!==void 0?e.recursive:!0,a=await this.loadFromFolder(i,t,o);this._discoveredUrls.push(...a)}else if("files"in e){const i=await this.loadFiles(e.files,t);this._discoveredUrls.push(...i)}this._prepared=!0}imagesLength(){if(!this._prepared)throw new Error("GoogleDriveLoader.imagesLength() called before prepare()");return this._discoveredUrls.length}imageURLs(){if(!this._prepared)throw new Error("GoogleDriveLoader.imageURLs() called before prepare()");return[...this._discoveredUrls]}isPrepared(){return this._prepared}extractFolderId(t){const e=[/\/folders\/([a-zA-Z0-9_-]+)/,/id=([a-zA-Z0-9_-]+)/];for(const i of e){const o=t.match(i);if(o&&o[1])return o[1]}return null}async loadFromFolder(t,e,i=!0){const o=this.extractFolderId(t);if(!o)throw new Error("Invalid Google Drive folder URL. Please check the URL format.");if(!this.apiKey||this.apiKey==="YOUR_API_KEY_HERE")return this.loadImagesDirectly(o,e);try{return i?await this.loadImagesRecursively(o,e):await this.loadImagesFromSingleFolder(o,e)}catch(a){return console.error("Error loading from Google Drive API:",a),this.loadImagesDirectly(o,e)}}async loadImagesFromSingleFolder(t,e){const i=[],o=`'${t}' in parents and trashed=false`,r=`${this.apiEndpoint}?q=${encodeURIComponent(o)}&fields=files(id,name,mimeType,thumbnailLink)&key=${this.apiKey}`,s=await fetch(r);if(!s.ok)throw new Error(`API request failed: ${s.status} ${s.statusText}`);const c=(await s.json()).files.filter(d=>d.mimeType.startsWith("image/")&&e.isAllowed(d.name));return this.log(`Found ${c.length} images in folder ${t} (non-recursive)`),c.forEach(d=>{i.push(`https://lh3.googleusercontent.com/d/${d.id}=s1600`),this.log(`Added file: ${d.name}`)}),i}async loadFiles(t,e){const i=[];for(const o of t){const a=this.extractFileId(o);if(!a){this.log(`Skipping invalid file URL: ${o}`);continue}if(this.apiKey&&this.apiKey!=="YOUR_API_KEY_HERE")try{const r=`${this.apiEndpoint}/${a}?fields=name,mimeType&key=${this.apiKey}`,s=await fetch(r);if(s.ok){const h=await s.json();h.mimeType.startsWith("image/")&&e.isAllowed(h.name)?(i.push(`https://lh3.googleusercontent.com/d/${a}=s1600`),this.log(`Added file: ${h.name}`)):this.log(`Skipping non-image file: ${h.name} (${h.mimeType})`)}else this.log(`Failed to fetch metadata for file ${a}: ${s.status}`)}catch(r){this.log(`Error fetching metadata for file ${a}:`,r)}else i.push(`https://lh3.googleusercontent.com/d/${a}=s1600`)}return i}extractFileId(t){if(!/[/:.]/.test(t))return t;const e=[/\/file\/d\/([a-zA-Z0-9_-]+)/,/\/open\?id=([a-zA-Z0-9_-]+)/,/id=([a-zA-Z0-9_-]+)/];for(const i of e){const o=t.match(i);if(o&&o[1])return o[1]}return null}async loadImagesRecursively(t,e){const i=[],o=`'${t}' in parents and trashed=false`,r=`${this.apiEndpoint}?q=${encodeURIComponent(o)}&fields=files(id,name,mimeType,thumbnailLink)&key=${this.apiKey}`,s=await fetch(r);if(!s.ok)throw new Error(`API request failed: ${s.status} ${s.statusText}`);const h=await s.json(),c=h.files.filter(l=>l.mimeType.startsWith("image/")&&e.isAllowed(l.name)),d=h.files.filter(l=>l.mimeType==="application/vnd.google-apps.folder");this.log(`Found ${h.files.length} total items in folder ${t}`),h.files.forEach(l=>this.log(` - File: ${l.name} (${l.mimeType})`)),this.log(`- ${c.length} valid files (images only)`),this.log(`- ${d.length} subfolders`),c.forEach(l=>{i.push(`https://lh3.googleusercontent.com/d/${l.id}=s1600`),this.log(`Added file: ${l.name}`)});for(const l of d){this.log(`Loading images from subfolder: ${l.name}`);const u=await this.loadImagesRecursively(l.id,e);i.push(...u)}return i}async loadImagesDirectly(t,e){try{const i=`https://drive.google.com/embeddedfolderview?id=${t}`,o=await fetch(i,{mode:"cors"});if(!o.ok)throw new Error("Cannot access folder directly (CORS or permissions issue)");const a=await o.text(),r=/\/file\/d\/([a-zA-Z0-9_-]+)/g,s=[...a.matchAll(r)];return[...new Set(s.map(d=>d[1]))].map(d=>`https://drive.google.com/uc?export=view&id=${d}`)}catch(i){throw console.error("Direct loading failed:",i),new Error(`Unable to load images. Please ensure:
|
|
1
|
+
(function(I,J){typeof exports=="object"&&typeof module<"u"?J(exports):typeof define=="function"&&define.amd?define(["exports"],J):(I=typeof globalThis<"u"?globalThis:I||self,J(I.ImageCloud={}))})(this,(function(I){"use strict";const J=Object.freeze({none:"none",sm:"0 2px 4px rgba(0,0,0,0.1)",md:"0 4px 16px rgba(0,0,0,0.4)",lg:"0 8px 32px rgba(0,0,0,0.5)",glow:"0 0 30px rgba(255,255,255,0.6)"}),ct=Object.freeze({energetic:Object.freeze({overshoot:.25,bounces:2,decayRatio:.5}),playful:Object.freeze({overshoot:.15,bounces:1,decayRatio:.5}),subtle:Object.freeze({overshoot:.08,bounces:1,decayRatio:.5})}),lt=Object.freeze({gentle:Object.freeze({stiffness:150,damping:30,mass:1,oscillations:2}),bouncy:Object.freeze({stiffness:300,damping:15,mass:1,oscillations:4}),wobbly:Object.freeze({stiffness:180,damping:12,mass:1.5,oscillations:5}),snappy:Object.freeze({stiffness:400,damping:25,mass:.8,oscillations:2})}),ht=Object.freeze({gentle:Object.freeze({amplitude:30,frequency:1.5,decay:!0,decayRate:.9,phase:0}),playful:Object.freeze({amplitude:50,frequency:2.5,decay:!0,decayRate:.7,phase:0}),serpentine:Object.freeze({amplitude:60,frequency:3,decay:!1,decayRate:1,phase:0}),flutter:Object.freeze({amplitude:20,frequency:4,decay:!0,decayRate:.5,phase:0})}),dt=Object.freeze({type:"linear"}),ut=Object.freeze({mode:"none"}),gt=Object.freeze({mode:"none"}),It=Object.freeze({default:Object.freeze({border:Object.freeze({width:0,color:"#000000",radius:0,style:"solid"}),shadow:"none",clipPath:void 0,filter:Object.freeze({}),opacity:1,cursor:"pointer",outline:Object.freeze({width:0,color:"#000000",style:"solid",offset:0})}),hover:Object.freeze({shadow:"none"}),focused:Object.freeze({shadow:"none"})}),Kt=Object.freeze({rows:1,amplitude:100,frequency:2,phaseShift:0,synchronization:"offset"}),Qt=Object.freeze({mobile:Object.freeze({maxWidth:767}),tablet:Object.freeze({maxWidth:1199})}),te=Object.freeze({mode:"adaptive",minSize:50,maxSize:400,variance:Object.freeze({min:1,max:1})}),ee=Object.freeze({mode:"none",range:Object.freeze({min:-15,max:15})}),Tt=Object.freeze({sizing:te,rotation:ee}),ft=Object.freeze({validateUrls:!0,validationTimeout:5e3,validationMethod:"head",allowedExtensions:["jpg","jpeg","png","gif","webp","bmp"]}),At=Object.freeze({enabled:!1,centers:!1,loaders:!1}),y=Object.freeze({loaders:[],config:Object.freeze({loaders:ft,debug:At}),image:Tt,layout:Object.freeze({algorithm:"radial",scaleDecay:0,responsive:Qt,targetCoverage:.6,densityFactor:1,spacing:Object.freeze({padding:50,minGap:20})}),animation:Object.freeze({duration:600,easing:Object.freeze({default:"cubic-bezier(0.4, 0.0, 0.2, 1)",bounce:"cubic-bezier(0.68, -0.55, 0.265, 1.55)",focus:"cubic-bezier(0.4, 0.0, 0.2, 1)"}),queue:Object.freeze({enabled:!0,interval:150,maxConcurrent:void 0}),performance:Object.freeze({useGPU:void 0,reduceMotion:void 0}),entry:Object.freeze({start:Object.freeze({position:"nearest-edge",offset:100,circular:Object.freeze({radius:"120%",distribution:"even"})}),timing:Object.freeze({duration:600}),easing:"cubic-bezier(0.25, 1, 0.5, 1)",path:dt,rotation:ut,scale:gt})}),interaction:Object.freeze({focus:Object.freeze({scalePercent:.8,zIndex:1e3,animationDuration:void 0}),navigation:Object.freeze({keyboard:void 0,swipe:void 0,mouseWheel:void 0}),gestures:Object.freeze({pinchToZoom:void 0,doubleTapToFocus:void 0})}),rendering:Object.freeze({responsive:Object.freeze({breakpoints:Object.freeze({mobile:768,tablet:void 0,desktop:void 0}),mobileDetection:()=>typeof window>"u"?!1:window.innerWidth<=768}),ui:Object.freeze({showLoadingSpinner:!1,showImageCounter:!1}),performance:Object.freeze({lazyLoad:void 0,preloadCount:void 0,imageQuality:void 0})}),styling:It});function tt(n,t){if(!n)return t||{};if(!t)return{...n};const i={...n};return t.border!==void 0&&(i.border={...n.border,...t.border}),t.borderTop!==void 0&&(i.borderTop={...n.borderTop,...t.borderTop}),t.borderRight!==void 0&&(i.borderRight={...n.borderRight,...t.borderRight}),t.borderBottom!==void 0&&(i.borderBottom={...n.borderBottom,...t.borderBottom}),t.borderLeft!==void 0&&(i.borderLeft={...n.borderLeft,...t.borderLeft}),t.filter!==void 0&&(i.filter={...n.filter,...t.filter}),t.outline!==void 0&&(i.outline={...n.outline,...t.outline}),t.shadow!==void 0&&(i.shadow=t.shadow),t.clipPath!==void 0&&(i.clipPath=t.clipPath),t.opacity!==void 0&&(i.opacity=t.opacity),t.cursor!==void 0&&(i.cursor=t.cursor),t.className!==void 0&&(i.className=t.className),t.objectFit!==void 0&&(i.objectFit=t.objectFit),t.aspectRatio!==void 0&&(i.aspectRatio=t.aspectRatio),t.borderRadiusTopLeft!==void 0&&(i.borderRadiusTopLeft=t.borderRadiusTopLeft),t.borderRadiusTopRight!==void 0&&(i.borderRadiusTopRight=t.borderRadiusTopRight),t.borderRadiusBottomRight!==void 0&&(i.borderRadiusBottomRight=t.borderRadiusBottomRight),t.borderRadiusBottomLeft!==void 0&&(i.borderRadiusBottomLeft=t.borderRadiusBottomLeft),i}function ie(n,t){if(!t)return{...n};const i=tt(n.default,t.default),e=tt(tt(i,n.hover),t.hover),o=tt(tt(i,n.focused),t.focused);return{default:i,hover:e,focused:o}}function ne(n,t){if(!t)return{...n};const i={...n};if(t.sizing!==void 0&&(i.sizing={...n.sizing,...t.sizing},t.sizing.variance)){const e=t.sizing.variance,o=e.min!==void 0&&e.min>=.25&&e.min<=1?e.min:n.sizing?.variance?.min??1,a=e.max!==void 0&&e.max>=1&&e.max<=1.75?e.max:n.sizing?.variance?.max??1;i.sizing.variance={min:o,max:a}}if(t.rotation!==void 0&&(i.rotation={...n.rotation,...t.rotation},t.rotation.range)){const e=t.rotation.range,o=e.min!==void 0&&e.min>=-180&&e.min<=0?e.min:n.rotation?.range?.min??-15,a=e.max!==void 0&&e.max>=0&&e.max<=180?e.max:n.rotation?.range?.max??15;i.rotation.range={min:o,max:a}}return i}function oe(n){const t=n.layout?.rotation;if(t&&"enabled"in t)return{rotation:{mode:t.enabled?"random":"none",range:t.range}}}function se(n){const t=n.layout?.sizing?.variance;if(t)return{sizing:{mode:"adaptive",variance:t}}}function ae(n={}){const t=oe(n),i=se(n);let e=n.image;(t||i)&&(e={...i||{},...t||{},...e},e.rotation&&t?.rotation&&n.image?.rotation&&(e.rotation={...t.rotation,...n.image.rotation}));const o=[...n.loaders??[]];n.images&&n.images.length>0&&o.unshift({static:{sources:[{urls:n.images}]}});const r={loaders:{...ft,...n.config?.loaders??{}}},s={loaders:o,config:r,image:ne(Tt,e),layout:{...y.layout},animation:{...y.animation},interaction:{...y.interaction},rendering:{...y.rendering},styling:ie(It,n.styling)};return n.layout&&(s.layout={...y.layout,...n.layout},n.layout.responsive&&(s.layout.responsive={...y.layout.responsive,mobile:n.layout.responsive.mobile?{...y.layout.responsive.mobile,...n.layout.responsive.mobile}:y.layout.responsive.mobile,tablet:n.layout.responsive.tablet?{...y.layout.responsive.tablet,...n.layout.responsive.tablet}:y.layout.responsive.tablet}),n.layout.spacing&&(s.layout.spacing={...y.layout.spacing,...n.layout.spacing})),n.animation&&(s.animation={...y.animation,...n.animation},n.animation.easing&&(s.animation.easing={...y.animation.easing,...n.animation.easing}),n.animation.queue&&(s.animation.queue={...y.animation.queue,...n.animation.queue}),n.animation.performance&&(s.animation.performance={...y.animation.performance,...n.animation.performance}),n.animation.entry&&(s.animation.entry={...y.animation.entry,...n.animation.entry,start:n.animation.entry.start?{...y.animation.entry.start,...n.animation.entry.start,circular:n.animation.entry.start.circular?{...y.animation.entry.start.circular,...n.animation.entry.start.circular}:y.animation.entry.start.circular}:y.animation.entry.start,timing:n.animation.entry.timing?{...y.animation.entry.timing,...n.animation.entry.timing}:y.animation.entry.timing,path:n.animation.entry.path?{...dt,...n.animation.entry.path}:y.animation.entry.path,rotation:n.animation.entry.rotation?{...ut,...n.animation.entry.rotation}:y.animation.entry.rotation,scale:n.animation.entry.scale?{...gt,...n.animation.entry.scale}:y.animation.entry.scale})),n.interaction&&(s.interaction={...y.interaction,...n.interaction},n.interaction.focus&&(s.interaction.focus={...y.interaction.focus,...n.interaction.focus}),n.interaction.navigation&&(s.interaction.navigation={...y.interaction.navigation,...n.interaction.navigation}),n.interaction.gestures&&(s.interaction.gestures={...y.interaction.gestures,...n.interaction.gestures})),n.rendering&&(s.rendering={...y.rendering,...n.rendering},n.rendering.responsive&&(s.rendering.responsive={...y.rendering.responsive,...n.rendering.responsive,breakpoints:n.rendering.responsive.breakpoints?{...y.rendering.responsive.breakpoints,...n.rendering.responsive.breakpoints}:y.rendering.responsive.breakpoints,mobileDetection:n.rendering.responsive.mobileDetection?n.rendering.responsive.mobileDetection:y.rendering.responsive.mobileDetection}),n.rendering.ui&&(s.rendering.ui={...y.rendering.ui,...n.rendering.ui}),n.rendering.performance&&(s.rendering.performance={...y.rendering.performance,...n.rendering.performance})),s.config.debug={...At,...n.config?.debug??{}},s}function re(n,t){return{...n?ct[n]:ct.playful,...t}}function ce(n,t){return{...n?lt[n]:lt.gentle,...t}}function le(n,t){return{...n?ht[n]:ht.gentle,...t}}class Ct{constructor(t){this.activeAnimations=new Map,this.animationIdCounter=0,this.config=t}buildTransformString(t){const i=["translate(-50%, -50%)"];if(t.x!==void 0||t.y!==void 0){const e=t.x??0,o=t.y??0;i.push(`translate(${e}px, ${o}px)`)}return t.rotation!==void 0&&i.push(`rotate(${t.rotation}deg)`),t.scale!==void 0&&i.push(`scale(${t.scale})`),i.join(" ")}animateTransformCancellable(t,i,e,o=null,a=null){this.cancelAllAnimations(t);const r=o??this.config.duration,s=a??this.config.easing.default,h=this.buildTransformString(i),c=this.buildTransformString(e);t.style.transition="none";const d=t.animate([{transform:h},{transform:c}],{duration:r,easing:s,fill:"forwards"}),l={id:`anim-${++this.animationIdCounter}`,element:t,animation:d,fromState:i,toState:e,startTime:performance.now(),duration:r};return this.activeAnimations.set(t,l),d.finished.then(()=>{t.style.transform=c,this.activeAnimations.delete(t)}).catch(()=>{this.activeAnimations.delete(t)}),l}cancelAnimation(t,i=!0){const e=this.getCurrentTransform(t.element);if(t.animation.cancel(),i){const o=this.buildTransformString({x:e.x,y:e.y,rotation:e.rotation,scale:e.scale});t.element.style.transform=o}return this.activeAnimations.delete(t.element),e}cancelAllAnimations(t){const i=this.activeAnimations.get(t);i&&this.cancelAnimation(i,!1);const e=t.getAnimations();for(const o of e)o.cancel()}getCurrentTransform(t){const e=getComputedStyle(t).transform;if(e==="none"||!e)return{x:0,y:0,rotation:0,scale:1};const o=new DOMMatrix(e),a=Math.sqrt(o.a*o.a+o.b*o.b),r=Math.atan2(o.b,o.a)*(180/Math.PI),s=o.e,h=o.f;return{x:s,y:h,rotation:r,scale:a}}hasActiveAnimation(t){return this.activeAnimations.has(t)}getAnimationHandle(t){return this.activeAnimations.get(t)}animateTransform(t,i,e=null,o=null){return new Promise(a=>{const r=e??this.config.duration,s=o??this.config.easing.default;t.style.transition=`transform ${r}ms ${s}, box-shadow ${r}ms ${s}`,t.style.transform=this.buildTransformString(i),setTimeout(()=>{a()},r)})}resetTransform(t,i){return this.animateTransform(t,i)}clearTransition(t){t.style.transition=""}wait(t){return new Promise(i=>setTimeout(i,t))}}function Z(n,t,i){return n+(t-n)*i}function he(n,t,i,e){const{overshoot:o,bounces:a,decayRatio:r}=e,s=i.x-t.x,h=i.y-t.y,c=de(a,r);let d=0,l=0,u=1,g=o,p=!1;for(let f=0;f<c.length;f++)if(n<=c[f].time){l=f===0?0:c[f-1].time,u=c[f].time,g=c[f].overshoot,p=c[f].isOvershoot;break}const b=(n-l)/(u-l);if(p)d=1+g*nt(b);else if(l===0)d=nt(b);else{const m=1+(c.find((x,v)=>x.time>l&&v>0&&c[v-1].isOvershoot)?.overshoot||g);d=Z(m,1,nt(b))}return{x:t.x+s*d,y:t.y+h*d}}function de(n,t){const i=[];let e=.6;i.push({time:e,overshoot:0,isOvershoot:!1});let o=.15;const r=.4/(n*2);for(let s=0;s<n;s++)e+=r,i.push({time:e,overshoot:o,isOvershoot:!0}),e+=r,i.push({time:e,overshoot:o*t,isOvershoot:!1}),o*=t;return i.push({time:1,overshoot:0,isOvershoot:!1}),i}function ue(n,t,i,e){const{stiffness:o,damping:a,mass:r,oscillations:s}=e,h=i.x-t.x,c=i.y-t.y,d=Math.sqrt(o/r),l=a/(2*Math.sqrt(o*r));let u;if(l<1){const g=d*Math.sqrt(1-l*l),p=Math.exp(-l*d*n*3),b=Math.cos(g*n*s*Math.PI);u=1-p*b}else u=1-Math.exp(-d*n*3);return u=Math.max(0,Math.min(u,1.3)),{x:t.x+h*u,y:t.y+c*u}}function ge(n,t,i,e){const{amplitude:o,frequency:a,decay:r,decayRate:s,phase:h}=e,c=i.x-t.x,d=i.y-t.y,l=Math.sqrt(c*c+d*d),u=l>0?-d/l:0,g=l>0?c/l:1,p=a*Math.PI*2*n+h,b=r?Math.pow(1-n,s):1,f=o*Math.sin(p)*b,m=fe(n);return{x:Z(t.x,i.x,m)+f*u,y:Z(t.y,i.y,m)+f*g}}function nt(n){return 1-(1-n)*(1-n)}function fe(n){return 1-Math.pow(1-n,3)}function me(n,t,i){const{amplitude:e,frequency:o,decay:a}=i,r=Math.sin(n*o*Math.PI*2),s=a?Math.pow(1-n,2):1,h=e*r*s;return t+h}function pe(n,t,i){const{overshoot:e,bounces:o}=i,a=[];a.push({time:.5,scale:e});let r=e;const s=.5,c=.5/(o*2);let d=.5;for(let u=0;u<o;u++){const g=1-(r-1)*s;d+=c,a.push({time:d,scale:g}),r=1+(r-1)*s*s,d+=c,u<o-1&&a.push({time:d,scale:r})}a.push({time:1,scale:1});let l=1;for(let u=0;u<a.length;u++)if(n<=a[u].time){const g=u===0?0:a[u-1].time,p=u===0?1:a[u-1].scale,b=(n-g)/(a[u].time-g),f=nt(b);l=p+(a[u].scale-p)*f;break}return l*t}function Lt(n){const{element:t,startPosition:i,endPosition:e,pathConfig:o,duration:a,imageWidth:r,imageHeight:s,rotation:h,scale:c,onComplete:d,rotationConfig:l,startRotation:u,scaleConfig:g,startScale:p}=n,b=o.type,f=u!==void 0&&u!==h,m=l?.mode==="wobble",x=l?.wobble||{amplitude:15,frequency:3,decay:!0},v=f||m,w=p!==void 0&&p!==c,R=g?.mode==="pop",E=g?.pop||{overshoot:1.2,bounces:1};if((b==="linear"||b==="arc")&&!v&&!(w||R)){d&&d();return}const F=performance.now(),z=-r/2,_=-s/2;function H(Y){const j=Y-F,A=Math.min(j/a,1);let D;switch(b){case"bounce":{const $=re(o.bouncePreset,o.bounce);D=he(A,i,e,$);break}case"elastic":{const $=ce(o.elasticPreset,o.elastic);D=ue(A,i,e,$);break}case"wave":{const $=le(o.wavePreset,o.wave);D=ge(A,i,e,$);break}default:D={x:Z(i.x,e.x,A),y:Z(i.y,e.y,A)}}const k=D.x-e.x,N=D.y-e.y;let L;m?L=me(A,h,x):f?L=Z(u,h,A):L=h;let C;R?C=pe(A,c,E):w?C=Z(p,c,A):C=c,t.style.transform=`translate(${z}px, ${_}px) translate(${k}px, ${N}px) rotate(${L}deg) scale(${C})`,A<1?requestAnimationFrame(H):(t.style.transform=`translate(${z}px, ${_}px) rotate(${h}deg) scale(${c})`,d&&d())}requestAnimationFrame(H)}function Mt(n){return n==="bounce"||n==="elastic"||n==="wave"}const be={radial:"center",spiral:"center",grid:"top",cluster:"nearest-edge",random:"nearest-edge",wave:"left"};class Ft{constructor(t,i){this.config=t,this.layoutAlgorithm=i,this.resolvedStartPosition=this.resolveStartPosition(),this.pathConfig=t.path||dt,this.rotationConfig=t.rotation||ut,this.scaleConfig=t.scale||gt}resolveStartPosition(){return this.config.start.position?this.config.start.position:be[this.layoutAlgorithm]||"nearest-edge"}calculateStartPosition(t,i,e,o,a){const r=this.resolvedStartPosition,s=this.config.start.offset??100;switch(r){case"nearest-edge":return this.calculateNearestEdge(t,i,e,s);case"top":return this.calculateEdgePosition("top",t,i,e,s);case"bottom":return this.calculateEdgePosition("bottom",t,i,e,s);case"left":return this.calculateEdgePosition("left",t,i,e,s);case"right":return this.calculateEdgePosition("right",t,i,e,s);case"center":return this.calculateCenterPosition(e,t,i);case"random-edge":return this.calculateRandomEdge(t,i,e,s);case"circular":return this.calculateCircularPosition(t,i,e,o,a);default:return this.calculateNearestEdge(t,i,e,s)}}calculateNearestEdge(t,i,e,o){const a=t.x,r=t.y,s=a,h=e.width-a,c=r,d=e.height-r,l=Math.min(s,h,c,d);let u=t.x,g=t.y;return l===s?u=-(i.width+o):l===h?u=e.width+o:l===c?g=-(i.height+o):g=e.height+o,{x:u,y:g}}calculateEdgePosition(t,i,e,o,a){let r=i.x,s=i.y;switch(t){case"top":s=-(e.height+a);break;case"bottom":s=o.height+a;break;case"left":r=-(e.width+a);break;case"right":r=o.width+a;break}return{x:r,y:s}}calculateCenterPosition(t,i,e){const o=t.width/2,a=t.height/2;return{x:o,y:a,useScale:!0}}calculateRandomEdge(t,i,e,o){const a=["top","bottom","left","right"],r=a[Math.floor(Math.random()*a.length)];return this.calculateEdgePosition(r,t,i,e,o)}calculateCircularPosition(t,i,e,o,a){const r=this.config.start.circular||{},s=r.distribution||"even";let h;const c=r.radius||"120%";if(typeof c=="string"&&c.endsWith("%")){const b=parseFloat(c)/100;h=Math.sqrt(e.width**2+e.height**2)*b/2}else h=typeof c=="number"?c:500;let d;s==="even"?d=o/a*2*Math.PI:d=Math.random()*2*Math.PI;const l=e.width/2,u=e.height/2,g=l+Math.cos(d)*h,p=u+Math.sin(d)*h;return{x:g,y:p}}getAnimationParams(t){const i=this.config.timing.duration,e=this.config.easing;return{startTransform:"",duration:i,delay:0,easing:e}}buildStartTransform(t,i,e,o,a,r,s,h){const c=t.x-i.x,d=t.y-i.y,l=s!==void 0?s:e,u=h!==void 0?h:o,g=a!==void 0?-a/2:0,p=r!==void 0?-r/2:0,b=a!==void 0?`translate(${g}px, ${p}px)`:"translate(-50%, -50%)";return t.useScale?`${b} translate(${c}px, ${d}px) rotate(${l}deg) scale(0)`:`${b} translate(${c}px, ${d}px) rotate(${l}deg) scale(${u})`}buildFinalTransform(t,i,e,o){if(e!==void 0&&o!==void 0){const a=-e/2,r=-o/2;return`translate(${a}px, ${r}px) rotate(${t}deg) scale(${i})`}return`translate(-50%, -50%) rotate(${t}deg) scale(${i})`}getTransitionCSS(){const t=this.config.timing.duration,i=this.config.easing;return this.requiresJSAnimation()?`opacity ${t}ms ease-out`:`opacity ${t}ms ease-out, transform ${t}ms ${i}`}requiresJSAnimation(){return Mt(this.pathConfig.type)}getPathConfig(){return this.pathConfig}getPathType(){return this.pathConfig.type}getTiming(){return{duration:this.config.timing.duration}}getRotationConfig(){return this.rotationConfig}getRotationMode(){return this.rotationConfig.mode}calculateStartRotation(t){switch(this.rotationConfig.mode){case"none":return t;case"settle":{const e=this.rotationConfig.startRotation;if(e===void 0)return t+(Math.random()-.5)*60;if(typeof e=="number")return e;const o=e.max-e.min;return e.min+Math.random()*o}case"spin":{const e=this.rotationConfig.spinCount??1,o=this.resolveSpinDirection(t);return t+e*360*o}case"random":return t+(Math.random()-.5)*60;case"wobble":return t;default:return t}}resolveSpinDirection(t){switch(this.rotationConfig.direction??"auto"){case"clockwise":return-1;case"counterclockwise":return 1;case"random":return Math.random()<.5?1:-1;default:return t>=0?1:-1}}requiresJSRotation(){return this.rotationConfig.mode==="wobble"}calculateWobbleRotation(t,i){if(this.rotationConfig.mode!=="wobble")return i;const e=this.rotationConfig.wobble||{amplitude:15,frequency:3,decay:!0},{amplitude:o,frequency:a,decay:r}=e,s=Math.sin(t*a*Math.PI*2),h=r?Math.pow(1-t,2):1,c=o*s*h;return i+c}getScaleConfig(){return this.scaleConfig}getScaleMode(){return this.scaleConfig.mode}calculateStartScale(t){switch(this.scaleConfig.mode){case"none":return t;case"grow":return(this.scaleConfig.startScale??.3)*t;case"shrink":return(this.scaleConfig.startScale??1.5)*t;case"pop":return t;case"random":{const e=this.scaleConfig.range??{min:.5,max:1};return(e.min+Math.random()*(e.max-e.min))*t}default:return t}}requiresJSScale(){return this.scaleConfig.mode==="pop"}calculatePopScale(t,i){if(this.scaleConfig.mode!=="pop")return i;const e=this.scaleConfig.pop||{overshoot:1.2,bounces:1},{overshoot:o,bounces:a}=e,r=this.generateScaleBounceKeyframes(a,o);let s=i;for(let h=0;h<r.length;h++)if(t<=r[h].time){const c=h===0?0:r[h-1].time,d=h===0?i:r[h-1].scale,l=(t-c)/(r[h].time-c),u=this.easeOutQuad(l);s=d+(r[h].scale-d)*u;break}return s*i}generateScaleBounceKeyframes(t,i){const e=[];e.push({time:.5,scale:i});let o=i;const a=.5,s=.5/(t*2);let h=.5;for(let c=0;c<t;c++){const d=1-(o-1)*a;h+=s,e.push({time:h,scale:d}),o=1+(o-1)*a*a,h+=s,c<t-1&&e.push({time:h,scale:o})}return e.push({time:1,scale:1}),e}easeOutQuad(t){return 1-(1-t)*(1-t)}}class zt{constructor(t,i={}){this.config=t,this.imageConfig=i}generate(t,i,e={}){const o=[],{width:a,height:r}=i,s=this.config.spacing.padding,h=e.fixedHeight??200,c=this.imageConfig.rotation?.mode??"none",d=this.imageConfig.rotation?.range?.min??-15,l=this.imageConfig.rotation?.range?.max??15,u=this.imageConfig.sizing?.variance?.min??1,g=this.imageConfig.sizing?.variance?.max??1,p=u!==1||g!==1,f=h*1.5/2,m=h/2,x=a-s-f,v=r-s-m,w=s+f,R=s+m;for(let E=0;E<t;E++){const T=this.random(w,x),F=this.random(R,v),z=c==="random"?this.random(d,l):0,_=p?this.random(u,g):1,H=h*_,Y={id:E,x:T,y:F,rotation:z,scale:_,baseSize:H};o.push(Y)}return o}random(t,i){return Math.random()*(i-t)+t}}class Ot{constructor(t,i={}){this.config=t,this.imageConfig=i}generate(t,i,e={}){const o=[],{width:a,height:r}=i,s=e.fixedHeight??200,h=this.imageConfig.rotation?.mode??"none",c=this.imageConfig.rotation?.range?.min??-15,d=this.imageConfig.rotation?.range?.max??15,l=this.imageConfig.sizing?.variance?.min??1,u=this.imageConfig.sizing?.variance?.max??1,g=l!==1||u!==1,p=this.config.scaleDecay??0,b=e.fixedHeight??s,f=a/2,m=r/2,x=Math.ceil(Math.sqrt(t));if(t>0){const R=g?this.random(l,u):1,E=b*R;o.push({id:0,x:f,y:m,rotation:h==="random"?this.random(c*.33,d*.33):0,scale:R,baseSize:E,zIndex:100})}let v=1,w=1;for(;v<t;){const R=w/x,E=p>0?1-R*p*.5:1,T=w*(b*.8),F=T*1.5,z=Math.PI*(3*(F+T)-Math.sqrt((3*F+T)*(F+3*T))),_=this.estimateWidth(b),H=Math.floor(z/(_*.7));if(H===0){w++;continue}const Y=2*Math.PI/H,j=w*(20*Math.PI/180);for(let A=0;A<H&&v<t;A++){const D=A*Y+j,k=g?this.random(l,u):1,N=E*k,L=b*N;let C=f+Math.cos(D)*F,$=m+Math.sin(D)*T;const P=this.config.spacing.padding??50,U=L*1.5/2,M=L/2;C-U<P?C=P+U:C+U>a-P&&(C=a-P-U),$-M<P?$=P+M:$+M>r-P&&($=r-P-M);const G=h==="random"?this.random(c,d):0;o.push({id:v,x:C,y:$,rotation:G,scale:N,baseSize:L,zIndex:Math.max(1,100-w)}),v++}w++}return o}estimateWidth(t){return t*1.4}random(t,i){return Math.random()*(i-t)+t}}const ye={columns:"auto",rows:"auto",stagger:"none",jitter:0,overlap:0,fillDirection:"row",alignment:"center",gap:10,overflowOffset:.25},Dt=[{x:1,y:1},{x:-1,y:-1},{x:1,y:-1},{x:-1,y:1},{x:-1,y:0},{x:1,y:0},{x:0,y:-1},{x:0,y:1}];class $t{constructor(t,i={}){this.config=t,this.imageConfig=i}generate(t,i,e={}){const o=[],{width:a,height:r}=i,s={...ye,...this.config.grid},h=this.config.spacing.padding,c=e.fixedHeight??200,d=this.imageConfig.rotation?.mode??"none",l=this.imageConfig.sizing?.variance?.min??1,u=this.imageConfig.sizing?.variance?.max??1,g=l!==1||u!==1,p=a-2*h,b=r-2*h,{columns:f,rows:m}=this.calculateGridDimensions(t,p,b,c,s),x=s.stagger==="row",v=s.stagger==="column",w=x?f+.5:f,R=v?m+.5:m,E=(p-s.gap*(f-1))/w,T=(b-s.gap*(m-1))/R,F=x?E/2:0,z=v?T/2:0,_=1+s.overlap,H=Math.min(E,T)*_,Y=e.fixedHeight?Math.min(e.fixedHeight,H):H,j=f*E+(f-1)*s.gap+F,A=m*T+(m-1)*s.gap+z,D=h+(p-j)/2,k=h+(b-A)/2,N=f*m,L=s.columns!=="auto"&&s.rows!=="auto",C=L&&t>N;typeof window<"u"&&(window.__gridOverflowDebug={gridConfigColumns:s.columns,gridConfigRows:s.rows,columns:f,rows:m,cellCount:N,hasFixedGrid:L,imageCount:t,isOverflowMode:C});const $=C?new Array(N).fill(0):[],P=Math.min(E,T)*s.overflowOffset;for(let O=0;O<t;O++){let U,M,G=0;if(C&&O>=N){const B=O-N,W=B%N;G=Math.floor(B/N)+1,$[W]++,s.fillDirection==="row"?(U=W%f,M=Math.floor(W/f)):(M=W%m,U=Math.floor(W/m))}else s.fillDirection==="row"?(U=O%f,M=Math.floor(O/f)):(M=O%m,U=Math.floor(O/m));let q=D+U*(E+s.gap)+E/2,X=k+M*(T+s.gap)+T/2;if(s.stagger==="row"&&M%2===1?q+=E/2:s.stagger==="column"&&U%2===1&&(X+=T/2),G>0){const B=(G-1)%Dt.length,W=Dt[B];q+=W.x*P,X+=W.y*P}if(s.jitter>0){const B=E/2*s.jitter,W=T/2*s.jitter;q+=this.random(-B,B),X+=this.random(-W,W)}let V=q,K=X;if(!C&&s.fillDirection==="row"){const B=t%f||f;if(M===Math.floor((t-1)/f)&&B<f){const Zt=B*E+(B-1)*s.gap;let Rt=0;s.alignment==="center"?Rt=(j-Zt)/2:s.alignment==="end"&&(Rt=j-Zt),V+=Rt}}const yt=g?this.random(l,u):1,Q=Y*yt,at=Q*1.5/2,rt=Q/2,wt=h+at,Et=a-h-at,$e=h+rt,Pe=r-h-rt;V=Math.max(wt,Math.min(V,Et)),K=Math.max($e,Math.min(K,Pe));let St=0;if(d==="random"){const B=this.imageConfig.rotation?.range?.min??-15,W=this.imageConfig.rotation?.range?.max??15;s.jitter>0?St=this.random(B*s.jitter,W*s.jitter):St=this.random(B,W)}let xt;C&&G>0?xt=50-G:xt=C?100+O:O+1,o.push({id:O,x:V,y:K,rotation:St,scale:yt,baseSize:Q,zIndex:xt})}return o}calculateGridDimensions(t,i,e,o,a){let r,s;if(a.columns!=="auto"&&a.rows!=="auto")r=a.columns,s=a.rows;else if(a.columns!=="auto")r=a.columns,s=Math.ceil(t/r);else if(a.rows!=="auto")s=a.rows,r=Math.ceil(t/s);else{const h=i/e;for(r=Math.max(1,Math.round(Math.sqrt(t*h/1.4))),s=Math.ceil(t/r);r>1&&(r-1)*s>=t;)r--}return{columns:Math.max(1,r),rows:Math.max(1,s)}}random(t,i){return Math.random()*(i-t)+t}}const ve=Math.PI*(3-Math.sqrt(5)),we={spiralType:"golden",direction:"counterclockwise",tightness:1,scaleDecay:0,startAngle:0};class Pt{constructor(t,i={}){this.config=t,this.imageConfig=i}generate(t,i,e={}){const o=[],{width:a,height:r}=i,s={...we,...this.config.spiral},h=this.config.spacing.padding,c=e.fixedHeight??200,d=this.imageConfig.rotation?.mode??"none",l=this.imageConfig.rotation?.range?.min??-15,u=this.imageConfig.rotation?.range?.max??15,g=this.imageConfig.sizing?.variance?.min??1,p=this.imageConfig.sizing?.variance?.max??1,b=g!==1||p!==1,f=this.config.scaleDecay??s.scaleDecay,m=a/2,x=r/2,v=Math.min(m-h-c/2,x-h-c/2),w=s.direction==="clockwise"?-1:1;for(let R=0;R<t;R++){let E,T;if(s.spiralType==="golden")E=R*ve*w+s.startAngle,T=this.calculateGoldenRadius(R,t,v,s.tightness);else if(s.spiralType==="archimedean"){const q=R*.5*s.tightness;E=q*w+s.startAngle,T=this.calculateArchimedeanRadius(q,t,v,s.tightness)}else{const q=R*.3*s.tightness;E=q*w+s.startAngle,T=this.calculateLogarithmicRadius(q,t,v,s.tightness)}const F=m+Math.cos(E)*T,z=x+Math.sin(E)*T,_=T/v,H=f>0?1-_*f*.5:1,Y=b?this.random(g,p):1,j=H*Y,A=c*j,k=A*1.5/2,N=A/2,L=h+k,C=a-h-k,$=h+N,P=r-h-N,O=Math.max(L,Math.min(F,C)),U=Math.max($,Math.min(z,P));let M=0;if(d==="random"){const q=E*180/Math.PI%360,X=this.random(l,u);M=s.spiralType==="golden"?X:q*.1+X*.9}else d==="tangent"&&(M=this.calculateSpiralTangent(E,T,s));const G=t-R;o.push({id:R,x:O,y:U,rotation:M,scale:j,baseSize:A,zIndex:G})}return o}calculateSpiralTangent(t,i,e){let o;if(e.spiralType==="golden")o=t+Math.PI/2;else if(e.spiralType==="archimedean"){const r=1/e.tightness,s=Math.atan(i/r);o=t+s}else{const r=.15/e.tightness,s=Math.atan(1/r);o=t+s}return o*180/Math.PI%360-90}calculateGoldenRadius(t,i,e,o){const r=e/Math.sqrt(i)*Math.sqrt(t)/o;return Math.min(r,e)}calculateArchimedeanRadius(t,i,e,o){const a=i*.5*o;return t/a*e}calculateLogarithmicRadius(t,i,e,o){const a=e*.05,r=.15/o,s=a*Math.exp(r*t),h=i*.3*o,c=a*Math.exp(r*h);return s/c*e}random(t,i){return Math.random()*(i-t)+t}}const Ee={clusterCount:"auto",clusterSpread:150,clusterSpacing:200,density:"uniform",overlap:.3,distribution:"gaussian"};class Ut{constructor(t,i={}){this.config=t,this.imageConfig=i}generate(t,i,e={}){const o=[],{width:a,height:r}=i,s={...Ee,...this.config.cluster},h=this.config.spacing.padding,c=e.fixedHeight??200,d=this.imageConfig.rotation?.mode??"none",l=this.imageConfig.rotation?.range?.min??-15,u=this.imageConfig.rotation?.range?.max??15,g=this.imageConfig.sizing?.variance?.min??1,p=this.imageConfig.sizing?.variance?.max??1,b=g!==1||p!==1,f=this.calculateClusterCount(t,s.clusterCount,a,r,s.clusterSpacing),m=this.generateClusterCenters(f,a,r,h,s),x=new Array(f).fill(0);for(let w=0;w<t;w++)x[w%f]++;let v=0;for(let w=0;w<f;w++){const R=m[w],E=x[w];for(let T=0;T<E;T++){let F,z;if(s.distribution==="gaussian")F=this.gaussianRandom()*R.spread,z=this.gaussianRandom()*R.spread;else{const M=this.random(0,Math.PI*2),G=this.random(0,R.spread);F=Math.cos(M)*G,z=Math.sin(M)*G}const _=1+s.overlap*.5,H=1+s.overlap*.3;F/=_,z/=_;const Y=b?this.random(g,p):1,j=H*Y,A=c*j;let D=R.x+F,k=R.y+z;const L=A*1.5/2,C=A/2;D=Math.max(h+L,Math.min(D,a-h-L)),k=Math.max(h+C,Math.min(k,r-h-C));const $=d==="random"?this.random(l,u):0,O=Math.sqrt(F*F+z*z)/R.spread,U=Math.round((1-O)*50)+1;o.push({id:v,x:D,y:k,rotation:$,scale:j,baseSize:A,zIndex:U}),v++}}return o}calculateClusterCount(t,i,e,o,a){if(i!=="auto")return Math.max(1,Math.min(i,t));const s=Math.max(1,Math.ceil(t/8)),h=Math.floor(e/a*(o/a)*.6);return Math.max(1,Math.min(s,h,10))}generateClusterCenters(t,i,e,o,a){const r=[],h=o+a.clusterSpread,c=i-o-a.clusterSpread,d=o+a.clusterSpread,l=e-o-a.clusterSpread;for(let u=0;u<t;u++){let g=null,p=-1;for(let b=0;b<100;b++){const f={x:this.random(h,c),y:this.random(d,l),spread:this.calculateClusterSpread(a)};let m=1/0;for(const x of r){const v=f.x-x.x,w=f.y-x.y,R=Math.sqrt(v*v+w*w);m=Math.min(m,R)}if((r.length===0||m>p)&&(g=f,p=m),m>=a.clusterSpacing)break}g&&r.push(g)}return r}calculateClusterSpread(t){return t.density==="uniform"?t.clusterSpread:t.clusterSpread*this.random(.5,1.5)}gaussianRandom(){let t=0,i=0;for(;t===0;)t=Math.random();for(;i===0;)i=Math.random();const e=Math.sqrt(-2*Math.log(t))*Math.cos(2*Math.PI*i);return Math.max(-3,Math.min(3,e))/3}random(t,i){return Math.random()*(i-t)+t}}class _t{constructor(t,i={}){this.config=t,this.imageConfig=i}generate(t,i,e={}){const o=[],{width:a,height:r}=i,s=e.fixedHeight??200,h=this.config.spacing.padding??50,c=this.imageConfig.rotation?.mode??"none",d=this.imageConfig.rotation?.range?.min??-15,l=this.imageConfig.rotation?.range?.max??15,u=this.imageConfig.sizing?.variance?.min??1,g=this.imageConfig.sizing?.variance?.max??1,p=u!==1||g!==1,b=e.fixedHeight??s,f={...Kt,...this.config.wave},{rows:m,amplitude:x,frequency:v,phaseShift:w,synchronization:R}=f,E=Math.ceil(t/m),z=b*1.5/2,_=h+z,H=a-h-z,Y=H-_,j=E>1?Y/(E-1):0,A=h+x+b/2,D=r-h-x-b/2,k=D-A,N=m>1?k/(m-1):0;let L=0;for(let C=0;C<m&&L<t;C++){const $=m===1?(A+D)/2:A+C*N;let P=0;R==="offset"?P=C*w:R==="alternating"&&(P=C*Math.PI);for(let O=0;O<E&&L<t;O++){const U=E===1?(_+H)/2:_+O*j,M=this.calculateWaveY(U,a,x,v,P),G=U,q=$+M,X=p?this.random(u,g):1,V=b*X;let K=0;c==="tangent"?K=this.calculateRotation(U,a,x,v,P):c==="random"&&(K=this.random(d,l));const Q=V*1.5/2,vt=V/2,at=h+Q,rt=a-h-Q,wt=h+vt,Et=r-h-vt;o.push({id:L,x:Math.max(at,Math.min(G,rt)),y:Math.max(wt,Math.min(q,Et)),rotation:K,scale:X,baseSize:V,zIndex:L+1}),L++}}return o}calculateWaveY(t,i,e,o,a){const r=t/i;return e*Math.sin(o*r*2*Math.PI+a)}calculateRotation(t,i,e,o,a){const r=t/i,s=e*o*2*Math.PI*Math.cos(o*r*2*Math.PI+a)/i;return Math.atan(s)*(180/Math.PI)}random(t,i){return Math.random()*(i-t)+t}}class Ht{constructor(t){this.config=t.layout,this.imageConfig=t.image,this.layouts=new Map,this.placementLayout=this.initLayout()}initLayout(){switch(this.config.algorithm){case"radial":return new Ot(this.config,this.imageConfig);case"grid":return new $t(this.config,this.imageConfig);case"spiral":return new Pt(this.config,this.imageConfig);case"cluster":return new Ut(this.config,this.imageConfig);case"wave":return new _t(this.config,this.imageConfig);default:return new zt(this.config,this.imageConfig)}}generateLayout(t,i,e={}){const o=this.placementLayout.generate(t,i,e);return o.forEach(a=>{this.layouts.set(a.id,a)}),o}getOriginalState(t){return this.layouts.get(Number(t))}reset(){this.layouts.clear()}updateConfig(t){t.layout&&(Object.assign(this.config,t.layout),t.layout.algorithm&&t.layout.algorithm!==this.config.algorithm&&(this.placementLayout=this.initLayout())),t.image&&Object.assign(this.imageConfig,t.image)}getBreakpoints(){return this.config.responsive??{mobile:{maxWidth:767},tablet:{maxWidth:1199}}}resolveBreakpoint(t){const i=this.getBreakpoints();return t<=i.mobile.maxWidth?"mobile":t<=i.tablet.maxWidth?"tablet":"screen"}resolveBaseHeight(t){const i=this.imageConfig.sizing;if(!i||i.mode==="adaptive")return;const e=i.height;if(e===void 0)return;if(typeof e=="number")return e;const o=e,a=this.resolveBreakpoint(t);return a==="mobile"?o.mobile??o.tablet??o.screen:a==="tablet"?o.tablet??o.screen??o.mobile:o.screen??o.tablet??o.mobile}calculateAdaptiveSize(t,i,e,o){const a=this.imageConfig.sizing,r=this.resolveBaseHeight(o);if(r!==void 0)return{height:r};const s=a?.minSize??50,h=a?.maxSize??400,c=this.config.targetCoverage??.6,d=this.config.densityFactor??1,{width:l,height:u}=t,b=l*u*c/i;let m=Math.sqrt(b/1.4);m*=d,m=Math.min(m,e);let x=this.clamp(m,s,h);if(x===s&&m<s){const v=Math.max(s*.05,20);x=Math.max(v,m)}return{height:x}}clamp(t,i,e){return Math.max(i,Math.min(e,t))}}var S=(n=>(n.IDLE="idle",n.FOCUSING="focusing",n.FOCUSED="focused",n.UNFOCUSING="unfocusing",n.CROSS_ANIMATING="cross_animating",n))(S||{});const Nt={circle:"circle(50%)",square:"polygon(0% 0%, 100% 0%, 100% 100%, 0% 100%)",triangle:"polygon(50% 0%, 100% 100%, 0% 100%)",pentagon:"polygon(50% 0%, 100% 38%, 82% 100%, 18% 100%, 0% 38%)",hexagon:"polygon(25% 0%, 75% 0%, 100% 50%, 75% 100%, 25% 100%, 0% 50%)",octagon:"polygon(30% 0%, 70% 0%, 100% 30%, 100% 70%, 70% 100%, 30% 100%, 0% 70%, 0% 30%)",diamond:"polygon(50% 0%, 100% 50%, 50% 100%, 0% 50%)"},Se={circle:{refHeight:100,points:[]},square:{refHeight:100,points:[[0,0],[100,0],[100,100],[0,100]]},triangle:{refHeight:100,points:[[50,0],[100,100],[0,100]]},pentagon:{refHeight:100,points:[[50,0],[100,38],[82,100],[18,100],[0,38]]},hexagon:{refHeight:100,points:[[25,0],[75,0],[100,50],[75,100],[25,100],[0,50]]},octagon:{refHeight:100,points:[[30,0],[70,0],[100,30],[100,70],[70,100],[30,100],[0,70],[0,30]]},diamond:{refHeight:100,points:[[50,0],[100,50],[50,100],[0,50]]}};function xe(n){if(n)return n in Nt?Nt[n]:n}function Re(n,t,i){const e=Se[n];if(!e)return"";const o=t/e.refHeight;if(n==="circle")return`circle(${Math.round(50*o*100)/100}px)`;const a=e.refHeight*o,r=a/2,s=a/2,h=(i??a)/2,c=t/2,d=h-r,l=c-s;return`polygon(${e.points.map(([g,p])=>{const b=Math.round((g*o+d)*100)/100,f=Math.round((p*o+l)*100)/100;return`${b}px ${f}px`}).join(", ")})`}function Ie(n){return n in J}function Te(n){return n?Ie(n)?J[n]:n:J.md}function Ae(n){if(!n)return"";const t=[];if(n.grayscale!==void 0&&t.push(`grayscale(${n.grayscale})`),n.blur!==void 0&&t.push(`blur(${n.blur}px)`),n.brightness!==void 0&&t.push(`brightness(${n.brightness})`),n.contrast!==void 0&&t.push(`contrast(${n.contrast})`),n.saturate!==void 0&&t.push(`saturate(${n.saturate})`),n.opacity!==void 0&&t.push(`opacity(${n.opacity})`),n.sepia!==void 0&&t.push(`sepia(${n.sepia})`),n.hueRotate!==void 0&&t.push(`hue-rotate(${n.hueRotate}deg)`),n.invert!==void 0&&t.push(`invert(${n.invert})`),n.dropShadow!==void 0)if(typeof n.dropShadow=="string")t.push(`drop-shadow(${n.dropShadow})`);else{const i=n.dropShadow;t.push(`drop-shadow(${i.x}px ${i.y}px ${i.blur}px ${i.color})`)}return t.join(" ")}function et(n){if(!n||n.style==="none"||n.width===0)return"none";const t=n.width??0,i=n.style??"solid",e=n.color??"#000000";return`${t}px ${i} ${e}`}function it(n,t,i){if(!n)return{};const e={};if(n.borderRadiusTopLeft!==void 0||n.borderRadiusTopRight!==void 0||n.borderRadiusBottomRight!==void 0||n.borderRadiusBottomLeft!==void 0){const s=n.border?.radius??0;n.borderRadiusTopLeft!==void 0?e.borderTopLeftRadius=`${n.borderRadiusTopLeft}px`:s&&(e.borderTopLeftRadius=`${s}px`),n.borderRadiusTopRight!==void 0?e.borderTopRightRadius=`${n.borderRadiusTopRight}px`:s&&(e.borderTopRightRadius=`${s}px`),n.borderRadiusBottomRight!==void 0?e.borderBottomRightRadius=`${n.borderRadiusBottomRight}px`:s&&(e.borderBottomRightRadius=`${s}px`),n.borderRadiusBottomLeft!==void 0?e.borderBottomLeftRadius=`${n.borderRadiusBottomLeft}px`:s&&(e.borderBottomLeftRadius=`${s}px`)}else n.border?.radius!==void 0&&(e.borderRadius=`${n.border.radius}px`);if(n.borderTop||n.borderRight||n.borderBottom||n.borderLeft){const s=n.border||{},h={...s,...n.borderTop},c={...s,...n.borderRight},d={...s,...n.borderBottom},l={...s,...n.borderLeft};e.borderTop=et(h),e.borderRight=et(c),e.borderBottom=et(d),e.borderLeft=et(l)}else n.border&&(e.border=et(n.border));n.shadow!==void 0&&(e.boxShadow=Te(n.shadow));const r=Ae(n.filter);if(e.filter=r||"none",n.opacity!==void 0&&(e.opacity=String(n.opacity)),n.cursor!==void 0&&(e.cursor=n.cursor),n.outline&&n.outline.style!=="none"&&(n.outline.width??0)>0){const s=n.outline.width??0,h=n.outline.style??"solid",c=n.outline.color??"#000000";e.outline=`${s}px ${h} ${c}`,n.outline.offset!==void 0&&(e.outlineOffset=`${n.outline.offset}px`)}if(n.objectFit!==void 0&&(e.objectFit=n.objectFit),n.aspectRatio!==void 0&&(e.aspectRatio=n.aspectRatio),n.clipPath!==void 0){let s;const h=typeof n.clipPath=="object"&&n.clipPath!==null&&"shape"in n.clipPath,c=h?n.clipPath:void 0;if(c?.mode==="height-relative"&&t)s=Re(c.shape,t,i);else{const d=h&&c?c.shape:n.clipPath;s=xe(d)}s&&(s==="none"?e.clipPath="unset":(e.clipPath=s,e.overflow="hidden"))}return e}function Ce(n,t){t.borderRadius!==void 0&&(n.style.borderRadius=t.borderRadius),t.borderTopLeftRadius!==void 0&&(n.style.borderTopLeftRadius=t.borderTopLeftRadius),t.borderTopRightRadius!==void 0&&(n.style.borderTopRightRadius=t.borderTopRightRadius),t.borderBottomRightRadius!==void 0&&(n.style.borderBottomRightRadius=t.borderBottomRightRadius),t.borderBottomLeftRadius!==void 0&&(n.style.borderBottomLeftRadius=t.borderBottomLeftRadius),t.border!==void 0&&(n.style.border=t.border),t.borderTop!==void 0&&(n.style.borderTop=t.borderTop),t.borderRight!==void 0&&(n.style.borderRight=t.borderRight),t.borderBottom!==void 0&&(n.style.borderBottom=t.borderBottom),t.borderLeft!==void 0&&(n.style.borderLeft=t.borderLeft),t.boxShadow!==void 0&&(n.style.boxShadow=t.boxShadow),t.filter!==void 0&&(n.style.filter=t.filter),t.opacity!==void 0&&(n.style.opacity=t.opacity),t.cursor!==void 0&&(n.style.cursor=t.cursor),t.outline!==void 0&&(n.style.outline=t.outline),t.outlineOffset!==void 0&&(n.style.outlineOffset=t.outlineOffset),t.objectFit!==void 0&&(n.style.objectFit=t.objectFit),t.aspectRatio!==void 0&&(n.style.aspectRatio=t.aspectRatio),t.clipPath!==void 0&&(n.style.clipPath=t.clipPath),t.overflow!==void 0&&(n.style.overflow=t.overflow)}function mt(n,t,i,e){const o=it(t,i,e);Ce(n,o)}function jt(n){return n?Array.isArray(n)?n.join(" "):n:""}function ot(n,t){const i=jt(t);i&&i.split(" ").forEach(e=>{e.trim()&&n.classList.add(e.trim())})}function pt(n,t){const i=jt(t);i&&i.split(" ").forEach(e=>{e.trim()&&n.classList.remove(e.trim())})}const Wt={UNFOCUSING:999,FOCUSING:1e3};class kt{constructor(t,i,e){this.state=S.IDLE,this.currentFocus=null,this.focusData=null,this.outgoing=null,this.incoming=null,this.focusGeneration=0,this.config=t,this.animationEngine=i,this.styling=e,this.focusedClassName=e?.focused?.className}getState(){return this.state}isAnimating(){return this.state!==S.IDLE&&this.state!==S.FOCUSED}normalizeScalePercent(t){return t>1?t/100:t}calculateFocusDimensions(t,i,e){const o=this.normalizeScalePercent(this.config.scalePercent),a=e.height*o,r=t/i;let s=a,h=s*r;const c=e.width*o;return h>c&&(h=c,s=h/r),{width:h,height:s}}calculateFocusTransform(t,i){const e=t.width/2,o=t.height/2,a=e-i.x,r=o-i.y;return{x:a,y:r,rotation:0,scale:1}}buildDimensionZoomTransform(t){const i=["translate(-50%, -50%)"];if(t.x!==void 0||t.y!==void 0){const e=t.x??0,o=t.y??0;i.push(`translate(${e}px, ${o}px)`)}return t.rotation!==void 0&&i.push(`rotate(${t.rotation}deg)`),i.join(" ")}animateWithDimensions(t,i,e,o,a,r,s,h){const c=this.buildDimensionZoomTransform(i),d=this.buildDimensionZoomTransform(e);return t.style.transition="none",t.animate([{transform:c,width:`${o}px`,height:`${a}px`},{transform:d,width:`${r}px`,height:`${s}px`}],{duration:h,easing:"cubic-bezier(0.4, 0, 0.2, 1)",fill:"forwards"})}applyFocusedStyling(t,i){if(t.style.zIndex=String(i),t.classList.add("fbn-ic-focused"),ot(t,this.focusedClassName),this.styling?.focused){const e=it(this.styling.focused,t.offsetHeight,t.offsetWidth);e.borderRadius!==void 0&&(t.style.borderRadius=e.borderRadius),e.borderTopLeftRadius!==void 0&&(t.style.borderTopLeftRadius=e.borderTopLeftRadius),e.borderTopRightRadius!==void 0&&(t.style.borderTopRightRadius=e.borderTopRightRadius),e.borderBottomRightRadius!==void 0&&(t.style.borderBottomRightRadius=e.borderBottomRightRadius),e.borderBottomLeftRadius!==void 0&&(t.style.borderBottomLeftRadius=e.borderBottomLeftRadius),e.border!==void 0&&(t.style.border=e.border),e.borderTop!==void 0&&(t.style.borderTop=e.borderTop),e.borderRight!==void 0&&(t.style.borderRight=e.borderRight),e.borderBottom!==void 0&&(t.style.borderBottom=e.borderBottom),e.borderLeft!==void 0&&(t.style.borderLeft=e.borderLeft),e.boxShadow!==void 0&&(t.style.boxShadow=e.boxShadow),e.filter!==void 0&&(t.style.filter=e.filter),e.opacity!==void 0&&(t.style.opacity=e.opacity),e.cursor!==void 0&&(t.style.cursor=e.cursor),e.outline!==void 0&&(t.style.outline=e.outline),e.outlineOffset!==void 0&&(t.style.outlineOffset=e.outlineOffset),e.objectFit!==void 0&&(t.style.objectFit=e.objectFit),e.aspectRatio!==void 0&&(t.style.aspectRatio=e.aspectRatio)}}removeFocusedStyling(t,i){if(t.style.zIndex=i,t.classList.remove("fbn-ic-focused"),pt(t,this.focusedClassName),this.styling?.default){const e=it(this.styling.default,t.offsetHeight,t.offsetWidth);e.borderRadius!==void 0&&(t.style.borderRadius=e.borderRadius),e.borderTopLeftRadius!==void 0&&(t.style.borderTopLeftRadius=e.borderTopLeftRadius),e.borderTopRightRadius!==void 0&&(t.style.borderTopRightRadius=e.borderTopRightRadius),e.borderBottomRightRadius!==void 0&&(t.style.borderBottomRightRadius=e.borderBottomRightRadius),e.borderBottomLeftRadius!==void 0&&(t.style.borderBottomLeftRadius=e.borderBottomLeftRadius),e.border!==void 0&&(t.style.border=e.border),e.borderTop!==void 0&&(t.style.borderTop=e.borderTop),e.borderRight!==void 0&&(t.style.borderRight=e.borderRight),e.borderBottom!==void 0&&(t.style.borderBottom=e.borderBottom),e.borderLeft!==void 0&&(t.style.borderLeft=e.borderLeft),e.boxShadow!==void 0&&(t.style.boxShadow=e.boxShadow),e.filter!==void 0&&(t.style.filter=e.filter),e.opacity!==void 0&&(t.style.opacity=e.opacity),e.cursor!==void 0&&(t.style.cursor=e.cursor),e.outline!==void 0&&(t.style.outline=e.outline),e.outlineOffset!==void 0&&(t.style.outlineOffset=e.outlineOffset),e.objectFit!==void 0&&(t.style.objectFit=e.objectFit),e.aspectRatio!==void 0&&(t.style.aspectRatio=e.aspectRatio)}}startClipPathAnimation(t,i,e){let o=e?this.styling?.focused??this.styling?.default:this.styling?.default;e&&this.styling?.focused&&this.styling.focused.clipPath===void 0&&(o={...o,clipPath:void 0});const a=()=>{const r=t.offsetHeight,s=t.offsetWidth,h=it(o,r,s);h.clipPath!==void 0?t.style.clipPath=h.clipPath:t.style.clipPath="unset",h.overflow!==void 0&&(t.style.overflow=h.overflow),i.animation.playState==="running"&&requestAnimationFrame(a)};requestAnimationFrame(a)}startFocusAnimation(t,i,e,o,a){const r=t.style.zIndex||"",s=t.offsetWidth,h=t.offsetHeight,c=this.calculateFocusDimensions(s,h,i),d=this.calculateFocusTransform(i,e);this.animationEngine.cancelAllAnimations(t);const l=this.config.animationDuration??600;this.applyFocusedStyling(t,Wt.FOCUSING);const u=o??{x:0,y:0,rotation:e.rotation,scale:1},g=a?.width??s,p=a?.height??h,b=this.animateWithDimensions(t,u,d,g,p,c.width,c.height,l),f={id:`focus-${Date.now()}`,element:t,animation:b,fromState:u,toState:d,startTime:performance.now(),duration:l};return this.focusData={element:t,originalState:e,focusTransform:d,originalZIndex:r,originalWidth:s,originalHeight:h,focusWidth:c.width,focusHeight:c.height},this.startClipPathAnimation(t,f,!0),{element:t,originalState:e,animationHandle:f,direction:"in",originalWidth:s,originalHeight:h}}startUnfocusAnimation(t,i,e,o){t.style.zIndex=String(Wt.UNFOCUSING),this.animationEngine.cancelAllAnimations(t);const a=this.config.animationDuration??600;t.classList.remove("fbn-ic-focused"),pt(t,this.focusedClassName);const r=e??this.focusData?.focusTransform??{x:0,y:0,rotation:0,scale:1},s=o?.width??this.focusData?.focusWidth??t.offsetWidth,h=o?.height??this.focusData?.focusHeight??t.offsetHeight,c={x:0,y:0,rotation:i.rotation,scale:1},d=this.focusData?.originalWidth??t.offsetWidth,l=this.focusData?.originalHeight??t.offsetHeight,u=this.animateWithDimensions(t,r,c,s,h,d,l,a),g={id:`unfocus-${Date.now()}`,element:t,animation:u,fromState:r,toState:c,startTime:performance.now(),duration:a};return this.startClipPathAnimation(t,g,!1),{element:t,originalState:i,animationHandle:g,direction:"out",originalWidth:d,originalHeight:l}}captureMidAnimationState(t){const i=getComputedStyle(t),e=new DOMMatrix(i.transform),o=t.offsetWidth,a=t.offsetHeight,r=e.e+o*.5,s=e.f+a*.5,h=Math.atan2(e.b,e.a)*(180/Math.PI);return t.style.width=`${o}px`,t.style.height=`${a}px`,t.style.transform=`translate(-50%, -50%) translate(${r}px, ${s}px) rotate(${h}deg)`,t.style.transition="none",{transform:{x:r,y:s,rotation:h,scale:1},dimensions:{width:o,height:a}}}async waitForAnimation(t){try{await t.animation.finished}catch{}}resetElementInstantly(t,i,e,o,a){this.animationEngine.cancelAllAnimations(t);const r=["translate(-50%, -50%)"];r.push("translate(0px, 0px)"),r.push(`rotate(${i.rotation}deg)`),t.style.transition="none",t.style.transform=r.join(" "),o!==void 0&&a!==void 0&&(t.style.width=`${o}px`,t.style.height=`${a}px`),this.removeFocusedStyling(t,e)}async focusImage(t,i,e){if(this.currentFocus===t&&this.state===S.FOCUSED)return this.unfocusImage();if(this.incoming?.element===t&&this.state===S.FOCUSING){const{transform:a,dimensions:r}=this.captureMidAnimationState(t);this.animationEngine.cancelAllAnimations(t),this.outgoing=this.startUnfocusAnimation(t,this.incoming.originalState,a,r),this.incoming=null,this.state=S.UNFOCUSING,await this.waitForAnimation(this.outgoing.animationHandle),this.removeFocusedStyling(this.outgoing.element,this.focusData?.originalZIndex||""),this.outgoing=null,this.currentFocus=null,this.focusData=null,this.state=S.IDLE;return}const o=++this.focusGeneration;switch(this.state){case S.IDLE:if(this.state=S.FOCUSING,this.incoming=this.startFocusAnimation(t,i,e),await this.waitForAnimation(this.incoming.animationHandle),this.focusGeneration!==o)return;this.currentFocus=t,this.incoming=null,this.state=S.FOCUSED;break;case S.FOCUSED:if(this.state=S.CROSS_ANIMATING,this.currentFocus&&this.focusData&&(this.outgoing=this.startUnfocusAnimation(this.currentFocus,this.focusData.originalState)),this.incoming=this.startFocusAnimation(t,i,e),await Promise.all([this.outgoing?this.waitForAnimation(this.outgoing.animationHandle):Promise.resolve(),this.waitForAnimation(this.incoming.animationHandle)]),this.focusGeneration!==o)return;this.outgoing&&(this.removeFocusedStyling(this.outgoing.element,this.outgoing.originalState.zIndex?.toString()||""),this.outgoing=null),this.currentFocus=t,this.incoming=null,this.state=S.FOCUSED;break;case S.FOCUSING:if(this.incoming&&(this.animationEngine.cancelAnimation(this.incoming.animationHandle,!1),this.resetElementInstantly(this.incoming.element,this.incoming.originalState,this.focusData?.originalZIndex||"",this.focusData?.originalWidth,this.focusData?.originalHeight),this.incoming=null),this.incoming=this.startFocusAnimation(t,i,e),await this.waitForAnimation(this.incoming.animationHandle),this.focusGeneration!==o)return;this.currentFocus=t,this.incoming=null,this.state=S.FOCUSED;break;case S.UNFOCUSING:if(this.state=S.CROSS_ANIMATING,this.incoming=this.startFocusAnimation(t,i,e),await Promise.all([this.outgoing?this.waitForAnimation(this.outgoing.animationHandle):Promise.resolve(),this.waitForAnimation(this.incoming.animationHandle)]),this.focusGeneration!==o)return;this.outgoing&&(this.removeFocusedStyling(this.outgoing.element,this.outgoing.originalState.zIndex?.toString()||""),this.outgoing=null),this.currentFocus=t,this.incoming=null,this.state=S.FOCUSED;break;case S.CROSS_ANIMATING:if(this.incoming?.element===t)return;if(this.outgoing?.element===t){const{transform:a,dimensions:r}=this.captureMidAnimationState(t);if(this.animationEngine.cancelAllAnimations(t),this.incoming){const{transform:s,dimensions:h}=this.captureMidAnimationState(this.incoming.element);this.animationEngine.cancelAllAnimations(this.incoming.element),this.outgoing=this.startUnfocusAnimation(this.incoming.element,this.incoming.originalState,s,h)}else this.outgoing=null;if(this.incoming=this.startFocusAnimation(t,i,e,a,r),await Promise.all([this.outgoing?this.waitForAnimation(this.outgoing.animationHandle):Promise.resolve(),this.waitForAnimation(this.incoming.animationHandle)]),this.focusGeneration!==o)return;this.outgoing&&(this.removeFocusedStyling(this.outgoing.element,this.outgoing.originalState.zIndex?.toString()||""),this.outgoing=null),this.currentFocus=t,this.incoming=null,this.state=S.FOCUSED;return}if(this.outgoing&&(this.animationEngine.cancelAnimation(this.outgoing.animationHandle,!1),this.resetElementInstantly(this.outgoing.element,this.outgoing.originalState,this.outgoing.originalState.zIndex?.toString()||"",this.outgoing.originalWidth,this.outgoing.originalHeight),this.outgoing=null),this.incoming){const{transform:a,dimensions:r}=this.captureMidAnimationState(this.incoming.element);this.animationEngine.cancelAllAnimations(this.incoming.element),this.outgoing=this.startUnfocusAnimation(this.incoming.element,this.incoming.originalState,a,r)}if(this.incoming=this.startFocusAnimation(t,i,e),await Promise.all([this.outgoing?this.waitForAnimation(this.outgoing.animationHandle):Promise.resolve(),this.waitForAnimation(this.incoming.animationHandle)]),this.focusGeneration!==o)return;this.outgoing&&(this.removeFocusedStyling(this.outgoing.element,this.outgoing.originalState.zIndex?.toString()||""),this.outgoing=null),this.currentFocus=t,this.incoming=null,this.state=S.FOCUSED;break}}async unfocusImage(){if(this.state===S.UNFOCUSING)return;const t=++this.focusGeneration;if(!this.currentFocus||!this.focusData){if(this.incoming&&this.state===S.FOCUSING){const{transform:a,dimensions:r}=this.captureMidAnimationState(this.incoming.element);if(this.animationEngine.cancelAllAnimations(this.incoming.element),this.outgoing=this.startUnfocusAnimation(this.incoming.element,this.incoming.originalState,a,r),this.incoming=null,this.state=S.UNFOCUSING,await this.waitForAnimation(this.outgoing.animationHandle),this.focusGeneration!==t)return;this.removeFocusedStyling(this.outgoing.element,this.focusData?.originalZIndex||""),this.outgoing=null,this.focusData=null,this.state=S.IDLE}return}if(this.state===S.CROSS_ANIMATING&&this.incoming){const{transform:a,dimensions:r}=this.captureMidAnimationState(this.incoming.element);this.animationEngine.cancelAllAnimations(this.incoming.element);const s=this.startUnfocusAnimation(this.incoming.element,this.incoming.originalState,a,r);if(await Promise.all([this.outgoing?this.waitForAnimation(this.outgoing.animationHandle):Promise.resolve(),this.waitForAnimation(s.animationHandle)]),this.focusGeneration!==t)return;this.outgoing&&this.removeFocusedStyling(this.outgoing.element,this.outgoing.originalState.zIndex?.toString()||""),this.removeFocusedStyling(s.element,this.incoming.originalState.zIndex?.toString()||""),this.outgoing=null,this.incoming=null,this.currentFocus=null,this.focusData=null,this.state=S.IDLE;return}this.state=S.UNFOCUSING;const i=this.currentFocus,e=this.focusData.originalState,o=this.focusData.originalZIndex;this.outgoing=this.startUnfocusAnimation(i,e),await this.waitForAnimation(this.outgoing.animationHandle),this.focusGeneration===t&&(this.removeFocusedStyling(i,o),this.outgoing=null,this.currentFocus=null,this.focusData=null,this.state=S.IDLE)}async swapFocus(t,i,e){return this.focusImage(t,i,e)}getCurrentFocus(){return this.currentFocus}isFocused(t){return this.currentFocus===t&&this.state===S.FOCUSED}isTargetingFocus(t){return this.incoming?.element===t}isInvolved(t){return this.currentFocus===t||this.incoming?.element===t||this.outgoing?.element===t}setDragOffset(t){if(!this.currentFocus||!this.focusData||this.state!==S.FOCUSED)return;const i=this.currentFocus,e=this.focusData.focusTransform,o=["translate(-50%, -50%)"],a=(e.x??0)+t,r=e.y??0;o.push(`translate(${a}px, ${r}px)`),e.rotation!==void 0&&o.push(`rotate(${e.rotation}deg)`),i.style.transition="none",i.style.transform=o.join(" ")}clearDragOffset(t,i=150){if(!this.currentFocus||!this.focusData||this.state!==S.FOCUSED)return;const e=this.currentFocus,o=this.focusData.focusTransform,a=["translate(-50%, -50%)"],r=o.x??0,s=o.y??0;a.push(`translate(${r}px, ${s}px)`),o.rotation!==void 0&&a.push(`rotate(${o.rotation}deg)`);const h=a.join(" ");t?(e.style.transition=`transform ${i}ms ease-out`,e.style.transform=h,setTimeout(()=>{this.currentFocus===e&&(e.style.transition="none")},i)):(e.style.transition="none",e.style.transform=h)}reset(){this.outgoing&&(this.animationEngine.cancelAnimation(this.outgoing.animationHandle,!1),this.resetElementInstantly(this.outgoing.element,this.outgoing.originalState,this.outgoing.originalState.zIndex?.toString()||"",this.outgoing.originalWidth,this.outgoing.originalHeight)),this.incoming&&(this.animationEngine.cancelAnimation(this.incoming.animationHandle,!1),this.resetElementInstantly(this.incoming.element,this.incoming.originalState,this.focusData?.originalZIndex||"",this.focusData?.originalWidth,this.focusData?.originalHeight)),this.currentFocus&&this.focusData&&this.resetElementInstantly(this.currentFocus,this.focusData.originalState,this.focusData.originalZIndex,this.focusData.originalWidth,this.focusData.originalHeight),this.state=S.IDLE,this.currentFocus=null,this.focusData=null,this.outgoing=null,this.incoming=null}}const Le=50,Me=.5,Fe=20,ze=.3,Oe=150,De=30,st=class st{constructor(t,i){this.enabled=!1,this.touchState=null,this.recentTouchTimestamp=0,this.container=t,this.callbacks=i,this.boundTouchStart=this.handleTouchStart.bind(this),this.boundTouchMove=this.handleTouchMove.bind(this),this.boundTouchEnd=this.handleTouchEnd.bind(this),this.boundTouchCancel=this.handleTouchCancel.bind(this)}enable(){this.enabled||(this.enabled=!0,this.container.style.touchAction="pan-y",this.container.addEventListener("touchstart",this.boundTouchStart,{passive:!1}),this.container.addEventListener("touchmove",this.boundTouchMove,{passive:!1}),this.container.addEventListener("touchend",this.boundTouchEnd,{passive:!0}),this.container.addEventListener("touchcancel",this.boundTouchCancel,{passive:!0}))}disable(){this.enabled&&(this.enabled=!1,this.container.style.touchAction="",this.container.removeEventListener("touchstart",this.boundTouchStart),this.container.removeEventListener("touchmove",this.boundTouchMove),this.container.removeEventListener("touchend",this.boundTouchEnd),this.container.removeEventListener("touchcancel",this.boundTouchCancel),this.touchState?.isDragging&&this.callbacks.onDragEnd(!1),this.touchState=null)}destroy(){this.disable()}hadRecentTouch(){return Date.now()-this.recentTouchTimestamp<st.TOUCH_CLICK_DELAY}handleTouchStart(t){if(t.touches.length!==1)return;this.recentTouchTimestamp=Date.now();const i=t.touches[0];this.touchState={startX:i.clientX,startY:i.clientY,startTime:performance.now(),currentX:i.clientX,isDragging:!1,isHorizontalSwipe:null}}handleTouchMove(t){if(!this.touchState||t.touches.length!==1)return;const i=t.touches[0],e=i.clientX-this.touchState.startX,o=i.clientY-this.touchState.startY;if(this.touchState.isHorizontalSwipe===null&&Math.sqrt(e*e+o*o)>10){const s=Math.atan2(Math.abs(o),Math.abs(e))*(180/Math.PI);this.touchState.isHorizontalSwipe=s<=De}if(this.touchState.isHorizontalSwipe!==!1&&this.touchState.isHorizontalSwipe===!0){t.preventDefault(),this.touchState.isDragging=!0,this.touchState.currentX=i.clientX;const a=e*ze;this.callbacks.onDragOffset(a)}}handleTouchEnd(t){if(!this.touchState)return;this.recentTouchTimestamp=Date.now();const i=this.touchState.currentX-this.touchState.startX,e=performance.now()-this.touchState.startTime,o=Math.abs(i)/e,a=Math.abs(i);let r=!1;this.touchState.isHorizontalSwipe===!0&&this.touchState.isDragging&&(a>=Le||o>=Me&&a>=Fe)&&(r=!0,i<0?this.callbacks.onNext():this.callbacks.onPrev()),this.touchState.isDragging&&this.callbacks.onDragEnd(r),this.touchState=null}handleTouchCancel(t){this.touchState?.isDragging&&this.callbacks.onDragEnd(!1),this.touchState=null}};st.TOUCH_CLICK_DELAY=300;let bt=st;class Gt{constructor(t){if(this._prepared=!1,this._discoveredUrls=[],this.apiKey=t.apiKey??"",this.apiEndpoint=t.apiEndpoint??"https://www.googleapis.com/drive/v3/files",this.debugLogging=t.debugLogging??!1,this.sources=t.sources??[],!this.sources||this.sources.length===0)throw new Error("GoogleDriveLoader requires at least one source to be configured")}async prepare(t){this._discoveredUrls=[];for(const i of this.sources)if("folders"in i)for(const e of i.folders){const o=i.recursive!==void 0?i.recursive:!0,a=await this.loadFromFolder(e,t,o);this._discoveredUrls.push(...a)}else if("files"in i){const e=await this.loadFiles(i.files,t);this._discoveredUrls.push(...e)}this._prepared=!0}imagesLength(){if(!this._prepared)throw new Error("GoogleDriveLoader.imagesLength() called before prepare()");return this._discoveredUrls.length}imageURLs(){if(!this._prepared)throw new Error("GoogleDriveLoader.imageURLs() called before prepare()");return[...this._discoveredUrls]}isPrepared(){return this._prepared}extractFolderId(t){const i=[/\/folders\/([a-zA-Z0-9_-]+)/,/id=([a-zA-Z0-9_-]+)/];for(const e of i){const o=t.match(e);if(o&&o[1])return o[1]}return null}async loadFromFolder(t,i,e=!0){const o=this.extractFolderId(t);if(!o)throw new Error("Invalid Google Drive folder URL. Please check the URL format.");if(!this.apiKey||this.apiKey==="YOUR_API_KEY_HERE")return this.loadImagesDirectly(o,i);try{return e?await this.loadImagesRecursively(o,i):await this.loadImagesFromSingleFolder(o,i)}catch(a){return console.error("Error loading from Google Drive API:",a),this.loadImagesDirectly(o,i)}}async loadImagesFromSingleFolder(t,i){const e=[],o=`'${t}' in parents and trashed=false`,r=`${this.apiEndpoint}?q=${encodeURIComponent(o)}&fields=files(id,name,mimeType,thumbnailLink)&key=${this.apiKey}`,s=await fetch(r);if(!s.ok)throw new Error(`API request failed: ${s.status} ${s.statusText}`);const c=(await s.json()).files.filter(d=>d.mimeType.startsWith("image/")&&i.isAllowed(d.name));return this.log(`Found ${c.length} images in folder ${t} (non-recursive)`),c.forEach(d=>{e.push(`https://lh3.googleusercontent.com/d/${d.id}=s1600`),this.log(`Added file: ${d.name}`)}),e}async loadFiles(t,i){const e=[];for(const o of t){const a=this.extractFileId(o);if(!a){this.log(`Skipping invalid file URL: ${o}`);continue}if(this.apiKey&&this.apiKey!=="YOUR_API_KEY_HERE")try{const r=`${this.apiEndpoint}/${a}?fields=name,mimeType&key=${this.apiKey}`,s=await fetch(r);if(s.ok){const h=await s.json();h.mimeType.startsWith("image/")&&i.isAllowed(h.name)?(e.push(`https://lh3.googleusercontent.com/d/${a}=s1600`),this.log(`Added file: ${h.name}`)):this.log(`Skipping non-image file: ${h.name} (${h.mimeType})`)}else this.log(`Failed to fetch metadata for file ${a}: ${s.status}`)}catch(r){this.log(`Error fetching metadata for file ${a}:`,r)}else e.push(`https://lh3.googleusercontent.com/d/${a}=s1600`)}return e}extractFileId(t){if(!/[/:.]/.test(t))return t;const i=[/\/file\/d\/([a-zA-Z0-9_-]+)/,/\/open\?id=([a-zA-Z0-9_-]+)/,/id=([a-zA-Z0-9_-]+)/];for(const e of i){const o=t.match(e);if(o&&o[1])return o[1]}return null}async loadImagesRecursively(t,i){const e=[],o=`'${t}' in parents and trashed=false`,r=`${this.apiEndpoint}?q=${encodeURIComponent(o)}&fields=files(id,name,mimeType,thumbnailLink)&key=${this.apiKey}`,s=await fetch(r);if(!s.ok)throw new Error(`API request failed: ${s.status} ${s.statusText}`);const h=await s.json(),c=h.files.filter(l=>l.mimeType.startsWith("image/")&&i.isAllowed(l.name)),d=h.files.filter(l=>l.mimeType==="application/vnd.google-apps.folder");this.log(`Found ${h.files.length} total items in folder ${t}`),h.files.forEach(l=>this.log(` - File: ${l.name} (${l.mimeType})`)),this.log(`- ${c.length} valid files (images only)`),this.log(`- ${d.length} subfolders`),c.forEach(l=>{e.push(`https://lh3.googleusercontent.com/d/${l.id}=s1600`),this.log(`Added file: ${l.name}`)});for(const l of d){this.log(`Loading images from subfolder: ${l.name}`);const u=await this.loadImagesRecursively(l.id,i);e.push(...u)}return e}async loadImagesDirectly(t,i){try{const e=`https://drive.google.com/embeddedfolderview?id=${t}`,o=await fetch(e,{mode:"cors"});if(!o.ok)throw new Error("Cannot access folder directly (CORS or permissions issue)");const a=await o.text(),r=/\/file\/d\/([a-zA-Z0-9_-]+)/g,s=[...a.matchAll(r)];return[...new Set(s.map(d=>d[1]))].map(d=>`https://drive.google.com/uc?export=view&id=${d}`)}catch(e){throw console.error("Direct loading failed:",e),new Error(`Unable to load images. Please ensure:
|
|
2
2
|
1. The folder is shared publicly (Anyone with the link can view)
|
|
3
3
|
2. The folder contains image files
|
|
4
|
-
3. Consider adding a Google Drive API key in config.js for better reliability`)}}manualImageUrls(t){return t.map(
|
|
4
|
+
3. Consider adding a Google Drive API key in config.js for better reliability`)}}manualImageUrls(t){return t.map(i=>`https://drive.google.com/uc?export=view&id=${i}`)}log(...t){this.debugLogging&&typeof console<"u"&&console.log(...t)}}class qt{constructor(t){if(this._prepared=!1,this._discoveredUrls=[],this.validateUrls=t.validateUrls!==!1,this.validationTimeout=t.validationTimeout??5e3,this.validationMethod=t.validationMethod??"head",this.debugLogging=t.debugLogging??!1,this.sources=t.sources??[],!this.sources||this.sources.length===0)throw new Error("StaticImageLoader requires at least one source to be configured");this.log("StaticImageLoader initialized with config:",t)}async prepare(t){this._discoveredUrls=[],this.log(`Processing ${this.sources.length} source(s)`);for(const i of this.sources)try{const e=await this.processSource(i,t);this._discoveredUrls.push(...e)}catch(e){console.warn("Failed to process source:",i,e)}this._prepared=!0,this.log(`Successfully loaded ${this._discoveredUrls.length} image(s)`)}imagesLength(){if(!this._prepared)throw new Error("StaticImageLoader.imagesLength() called before prepare()");return this._discoveredUrls.length}imageURLs(){if(!this._prepared)throw new Error("StaticImageLoader.imageURLs() called before prepare()");return[...this._discoveredUrls]}isPrepared(){return this._prepared}async processSource(t,i){return t?"urls"in t?await this.processUrls(t.urls,i):"path"in t?await this.processPath(t.path,t.files,i):"json"in t?await this.processJson(t.json,i):(console.warn("Unknown source shape:",t),[]):(console.warn("Invalid source object:",t),[])}async processUrls(t,i){if(!Array.isArray(t))return console.warn("URLs must be an array:",t),[];const e=[];for(const o of t){const a=o.split("/").pop()||o;if(!i.isAllowed(a)){this.log(`Skipping filtered URL: ${o}`);continue}this.validateUrls?await this.validateUrl(o)?e.push(o):console.warn(`Skipping invalid/missing URL: ${o}`):e.push(o)}return e}async processPath(t,i,e){if(!Array.isArray(i))return console.warn("files must be an array:",i),[];const o=[];for(const a of i){if(!e.isAllowed(a)){this.log(`Skipping filtered file: ${a}`);continue}const r=this.constructUrl(t,a);this.validateUrls?await this.validateUrl(r)?o.push(r):console.warn(`Skipping invalid/missing file: ${r}`):o.push(r)}return o}async processJson(t,i){this.log(`Fetching JSON endpoint: ${t}`);const e=new AbortController,o=setTimeout(()=>e.abort(),1e4);try{const a=await fetch(t,{signal:e.signal});if(clearTimeout(o),!a.ok)throw new Error(`HTTP ${a.status} fetching ${t}`);const r=await a.json();if(!r||!Array.isArray(r.images))throw new Error('JSON source must return JSON with shape { "images": ["url1", "url2", ...] }');return this.log(`JSON endpoint returned ${r.images.length} image(s)`),await this.processUrls(r.images,i)}catch(a){throw clearTimeout(o),a instanceof Error&&a.name==="AbortError"?new Error(`Timeout fetching JSON endpoint: ${t}`):a}}async validateUrl(t){if(this.validationMethod==="none")return!0;if(this.validationMethod==="simple")try{return typeof window<"u"?new URL(t,window.location.origin):new URL(t),!0}catch{return!1}if(typeof window>"u")return!0;if(!(t.startsWith(window.location.origin)||t.startsWith("/")))return this.log(`Skipping validation for cross-origin URL: ${t}`),!0;try{const e=new AbortController,o=setTimeout(()=>e.abort(),this.validationTimeout),a=await fetch(t,{method:"HEAD",signal:e.signal});return clearTimeout(o),a.ok?!0:(this.log(`Validation failed for ${t}: HTTP ${a.status}`),!1)}catch(e){return e instanceof Error&&(e.name==="AbortError"?this.log(`Validation timeout for ${t}`):this.log(`Validation failed for ${t}:`,e.message)),!1}}constructUrl(t,i){const e=t.replace(/\/$/,"");if(this.isAbsoluteUrl(t))return`${e}/${i}`;if(typeof window>"u")return`${e}/${i}`;const o=window.location.origin,r=(t.startsWith("/")?t:"/"+t).replace(/\/$/,"");return`${o}${r}/${i}`}isAbsoluteUrl(t){try{return new URL(t),!0}catch{return!1}}log(...t){this.debugLogging&&typeof console<"u"&&console.log(...t)}}class Bt{constructor(t){if(this._prepared=!1,this._discoveredUrls=[],this.loaders=t.loaders,this.debugLogging=t.debugLogging??!1,!this.loaders||this.loaders.length===0)throw new Error("CompositeLoader requires at least one loader to be configured");this.log(`CompositeLoader initialized with ${this.loaders.length} loader(s)`)}async prepare(t){this._discoveredUrls=[],this.log(`Preparing ${this.loaders.length} loader(s) in parallel`);const i=this.loaders.map((e,o)=>e.prepare(t).then(()=>{this.log(`Loader ${o} prepared with ${e.imagesLength()} images`)}).catch(a=>{console.warn(`Loader ${o} failed to prepare:`,a)}));await Promise.all(i);for(const e of this.loaders)if(e.isPrepared()){const o=e.imageURLs();this._discoveredUrls.push(...o)}this._prepared=!0,this.log(`CompositeLoader prepared with ${this._discoveredUrls.length} total images`)}imagesLength(){if(!this._prepared)throw new Error("CompositeLoader.imagesLength() called before prepare()");return this._discoveredUrls.length}imageURLs(){if(!this._prepared)throw new Error("CompositeLoader.imageURLs() called before prepare()");return[...this._discoveredUrls]}isPrepared(){return this._prepared}log(...t){this.debugLogging&&typeof console<"u"&&console.log("[CompositeLoader]",...t)}}class Yt{constructor(t){this.allowedExtensions=t||["jpg","jpeg","png","gif","webp","bmp"]}isAllowed(t){const e=t.split("?")[0].split(".").pop()?.toLowerCase();return e?this.allowedExtensions.includes(e):!1}getAllowedExtensions(){return[...this.allowedExtensions]}}const Xt=`
|
|
5
5
|
.fbn-ic-gallery {
|
|
6
6
|
position: relative;
|
|
7
7
|
width: 100%;
|
|
@@ -50,5 +50,5 @@
|
|
|
50
50
|
.fbn-ic-hidden {
|
|
51
51
|
display: none !important;
|
|
52
52
|
}
|
|
53
|
-
`;function Vt(){if(typeof document>"u")return;const n="fbn-ic-functional-styles";if(document.getElementById(n))return;const t=document.createElement("style");t.id=n,t.textContent=Bt,document.head.appendChild(t)}class Jt{constructor(t={}){this.fullConfig=ae(t),t.container instanceof HTMLElement?(this.containerRef=t.container,this.containerId=null):(this.containerRef=null,this.containerId=t.container||"imageCloud"),this.imagesLoaded=!1,this.imageElements=[],this.imageLayouts=[],this.currentImageHeight=225,this.currentFocusIndex=null,this.hoveredImage=null,this.resizeTimeout=null,this.displayQueue=[],this.queueInterval=null,this.loadGeneration=0,this.loadingElAutoCreated=!1,this.errorElAutoCreated=!1,this.counterEl=null,this.counterElAutoCreated=!1,this.animationEngine=new Rt(this.fullConfig.animation),this.layoutEngine=new Ht({layout:this.fullConfig.layout,image:this.fullConfig.image}),this.zoomEngine=new kt(this.fullConfig.interaction.focus,this.animationEngine,this.fullConfig.styling),this.defaultStyles=ft(this.fullConfig.styling?.default),this.defaultClassName=this.fullConfig.styling?.default?.className,this.hoverClassName=this.fullConfig.styling?.hover?.className;const e=this.fullConfig.animation.entry||b.animation.entry;this.entryAnimationEngine=new Ft(e,this.fullConfig.layout.algorithm),this.swipeEngine=null,this.imageFilter=this.createImageFilter(),this.imageLoader=this.createLoader(),this.containerEl=null,this.loadingEl=null,this.errorEl=null}createImageFilter(){const t=this.fullConfig.config.loaders?.allowedExtensions;return new Xt(t)}createLoader(){const t=this.fullConfig.loaders,e=this.fullConfig.config.loaders??{};if(!t||t.length===0)throw new Error("No loaders configured. Provide `images`, `loaders`, or both.");const i=t.map(o=>this.createLoaderFromEntry(o,e));return i.length===1?i[0]:new Yt({loaders:i,debugLogging:this.fullConfig.config.debug?.loaders})}createLoaderFromEntry(t,e){if("static"in t){const i=t.static,o={...i,validateUrls:i.validateUrls??e.validateUrls,validationTimeout:i.validationTimeout??e.validationTimeout,validationMethod:i.validationMethod??e.validationMethod,allowedExtensions:i.allowedExtensions??e.allowedExtensions,debugLogging:i.debugLogging??this.fullConfig.config.debug?.loaders};return new qt(o)}else if("googleDrive"in t){const i=t.googleDrive,o={...i,allowedExtensions:i.allowedExtensions??e.allowedExtensions,debugLogging:i.debugLogging??this.fullConfig.config.debug?.loaders};return new Gt(o)}else throw new Error(`Unknown loader entry: ${JSON.stringify(t)}`)}async init(){try{if(Vt(),this.containerRef)this.containerEl=this.containerRef;else if(this.containerEl=document.getElementById(this.containerId),!this.containerEl)throw new Error(`Container #${this.containerId} not found`);this.containerEl.classList.add("fbn-ic-gallery"),this.swipeEngine=new yt(this.containerEl,{onNext:()=>this.navigateToNextImage(),onPrev:()=>this.navigateToPreviousImage(),onDragOffset:t=>this.zoomEngine.setDragOffset(t),onDragEnd:t=>{t?this.zoomEngine.clearDragOffset(!1):this.zoomEngine.clearDragOffset(!0,De)}}),this.setupUI(),this.setupEventListeners(),this.logDebug("ImageCloud initialized"),await this.loadImages()}catch(t){console.error("Gallery initialization failed:",t),this.errorEl&&t instanceof Error&&this.showError("Gallery failed to initialize: "+t.message)}}setupUI(){const t=this.fullConfig.rendering.ui;t.showLoadingSpinner&&(t.loadingElement?(this.loadingEl=this.resolveElement(t.loadingElement),this.loadingElAutoCreated=!1):(this.loadingEl=this.createDefaultLoadingElement(),this.loadingElAutoCreated=!0)),t.errorElement?(this.errorEl=this.resolveElement(t.errorElement),this.errorElAutoCreated=!1):(this.errorEl=this.createDefaultErrorElement(),this.errorElAutoCreated=!0),t.showImageCounter&&(t.counterElement?(this.counterEl=this.resolveElement(t.counterElement),this.counterElAutoCreated=!1):(this.counterEl=this.createDefaultCounterElement(),this.counterElAutoCreated=!0))}resolveElement(t){return t instanceof HTMLElement?t:document.getElementById(t)}createDefaultLoadingElement(){const t=document.createElement("div");t.className="fbn-ic-loading fbn-ic-hidden";const e=document.createElement("div");e.className="fbn-ic-spinner",t.appendChild(e);const i=document.createElement("p");return i.textContent="Loading images...",t.appendChild(i),this.containerEl.appendChild(t),t}createDefaultErrorElement(){const t=document.createElement("div");return t.className="fbn-ic-error fbn-ic-hidden",this.containerEl.appendChild(t),t}createDefaultCounterElement(){const t=document.createElement("div");return t.className="fbn-ic-counter fbn-ic-hidden",this.containerEl.appendChild(t),t}setupEventListeners(){document.addEventListener("keydown",t=>{t.key==="Escape"?(this.zoomEngine.unfocusImage(),this.currentFocusIndex=null,this.swipeEngine?.disable(),this.hideCounter()):t.key==="ArrowRight"?this.navigateToNextImage():t.key==="ArrowLeft"?this.navigateToPreviousImage():(t.key==="Enter"||t.key===" ")&&this.hoveredImage&&(this.handleImageClick(this.hoveredImage.element,this.hoveredImage.layout),t.preventDefault())}),document.addEventListener("click",t=>{this.swipeEngine?.hadRecentTouch()||t.target.closest(".fbn-ic-image")||(this.zoomEngine.unfocusImage(),this.currentFocusIndex=null,this.swipeEngine?.disable(),this.hideCounter())}),window.addEventListener("resize",()=>this.handleResize())}navigateToNextImage(){if(this.currentFocusIndex===null||this.imageElements.length===0)return;const t=(this.currentFocusIndex+1)%this.imageLayouts.length,e=this.imageElements.find(o=>o.dataset.imageId===String(t));if(!e)return;const i=this.imageLayouts[t];i&&(this.currentFocusIndex=t,this.handleImageClick(e,i),this.updateCounter(t))}navigateToPreviousImage(){if(this.currentFocusIndex===null||this.imageElements.length===0)return;const t=(this.currentFocusIndex-1+this.imageLayouts.length)%this.imageLayouts.length,e=this.imageElements.find(o=>o.dataset.imageId===String(t));if(!e)return;const i=this.imageLayouts[t];i&&(this.currentFocusIndex=t,this.handleImageClick(e,i),this.updateCounter(t))}handleResize(){this.imagesLoaded&&(this.resizeTimeout!==null&&clearTimeout(this.resizeTimeout),this.resizeTimeout=window.setTimeout(()=>{const t=this.getImageHeight();t!==this.currentImageHeight?(this.logDebug(`Window resized to new breakpoint (height: ${t}px). Reloading images...`),this.loadImages()):this.logDebug("Window resized (no breakpoint change)")},500))}getImageHeight(){const t=window.innerWidth,e=this.fullConfig.layout.responsive,o=this.fullConfig.image.sizing?.maxSize??400;return e?t<=e.mobile.maxWidth?Math.min(100,o):t<=e.tablet.maxWidth?Math.min(180,o):Math.min(225,o):t<=767?Math.min(100,o):t<=1199?Math.min(180,o):Math.min(225,o)}getContainerBounds(){return this.containerEl?{width:this.containerEl.offsetWidth,height:this.containerEl.offsetHeight||window.innerHeight*.7}:{width:window.innerWidth,height:window.innerHeight*.7}}async loadImages(){try{this.showLoading(!0),this.hideError(),this.clearImageCloud(),await this.imageLoader.prepare(this.imageFilter);const t=this.imageLoader.imagesLength();let e=this.imageLoader.imageURLs();if(t===0){this.showError("No images found."),this.showLoading(!1);return}const i=this.getContainerBounds(),o=this.getImageHeight(),a=window.innerWidth;this.logDebug(`Adaptive sizing input: container=${i.width}x${i.height}px, images=${t}, responsiveMax=${o}px`);const r=this.layoutEngine.calculateAdaptiveSize(i,t,o,a);this.logDebug(`Adaptive sizing result: height=${r.height}px`),await this.createImageCloud(e,r.height),this.showLoading(!1),this.imagesLoaded=!0}catch(t){console.error("Error loading images:",t),t instanceof Error&&this.showError(t.message||"Failed to load images."),this.showLoading(!1)}}logDebug(...t){this.fullConfig.config.debug?.enabled&&typeof console<"u"&&console.log(...t)}async createImageCloud(t,e){if(!this.containerEl)return;const i=this.getContainerBounds();this.currentImageHeight=e;const o=this.loadGeneration,a=this.layoutEngine.generateLayout(t.length,i,{fixedHeight:e});this.imageLayouts=a,this.displayQueue=[];let r=0;const s=c=>{this.containerEl&&(this.containerEl.appendChild(c),this.imageElements.push(c),requestAnimationFrame(()=>{if(c.offsetWidth,c.style.opacity=this.defaultStyles.opacity??"1",c.dataset.startX&&(this.entryAnimationEngine.requiresJSAnimation()||this.entryAnimationEngine.requiresJSRotation()||this.entryAnimationEngine.requiresJSScale()||c.dataset.startRotation!==c.dataset.rotation||c.dataset.startScale!==c.dataset.scale)){const u={x:parseFloat(c.dataset.startX),y:parseFloat(c.dataset.startY)},g={x:parseFloat(c.dataset.endX),y:parseFloat(c.dataset.endY)},p=parseFloat(c.dataset.imageWidth),y=parseFloat(c.dataset.imageHeight),f=parseFloat(c.dataset.rotation),m=parseFloat(c.dataset.scale),x=c.dataset.startRotation?parseFloat(c.dataset.startRotation):f,v=c.dataset.startScale?parseFloat(c.dataset.startScale):m,w=this.entryAnimationEngine.getTiming();Lt({element:c,startPosition:u,endPosition:g,pathConfig:this.entryAnimationEngine.getPathConfig(),duration:w.duration,imageWidth:p,imageHeight:y,rotation:f,scale:m,rotationConfig:this.entryAnimationEngine.getRotationConfig(),startRotation:x,scaleConfig:this.entryAnimationEngine.getScaleConfig(),startScale:v})}else{const u=c.dataset.finalTransform||"";c.style.transform=u}const l=parseInt(c.dataset.imageId||"0");if(this.fullConfig.config.debug?.enabled&&l<3){const u=c.dataset.finalTransform||"";console.log(`Image ${l} final state:`,{left:c.style.left,top:c.style.top,width:c.style.width,height:c.style.height,computedWidth:c.offsetWidth,computedHeight:c.offsetHeight,transform:u,pathType:this.entryAnimationEngine.getPathType()})}}),r++)},h=()=>{if(this.logDebug("Starting queue processing, enabled:",this.fullConfig.animation.queue.enabled),!this.fullConfig.animation.queue.enabled){for(;this.displayQueue.length>0;){const c=this.displayQueue.shift();c&&s(c)}return}this.queueInterval!==null&&clearInterval(this.queueInterval),this.queueInterval=window.setInterval(()=>{if(o!==this.loadGeneration){this.queueInterval!==null&&(clearInterval(this.queueInterval),this.queueInterval=null);return}if(this.displayQueue.length>0){const c=this.displayQueue.shift();c&&s(c)}r>=t.length&&this.displayQueue.length===0&&this.queueInterval!==null&&(clearInterval(this.queueInterval),this.queueInterval=null)},this.fullConfig.animation.queue.interval)};if("IntersectionObserver"in window&&this.containerEl){const c=new IntersectionObserver(d=>{d.forEach(l=>{l.isIntersecting&&(h(),c.disconnect())})},{threshold:.1,rootMargin:"50px"});c.observe(this.containerEl)}else h();this.fullConfig.config.debug?.centers&&this.containerEl&&(this.containerEl.querySelectorAll(".fbn-ic-debug-center").forEach(c=>c.remove()),a.forEach((c,d)=>{const l=document.createElement("div");l.className="fbn-ic-debug-center",l.style.position="absolute",l.style.width="12px",l.style.height="12px",l.style.borderRadius="50%",l.style.backgroundColor="red",l.style.border="2px solid yellow",l.style.zIndex="9999",l.style.pointerEvents="none";const u=c.x,g=c.y;l.style.left=`${u-6}px`,l.style.top=`${g-6}px`,l.title=`Image ${d}: center (${Math.round(u)}, ${Math.round(g)})`,this.containerEl.appendChild(l)})),t.forEach((c,d)=>{const l=document.createElement("img");l.referrerPolicy="no-referrer",l.classList.add("fbn-ic-image"),l.dataset.imageId=String(d),l.dataset.createdFlag="true";const u=a[d];l.style.position="absolute",l.style.width="auto",l.style.height=`${e}px`,l.style.left=`${u.x}px`,l.style.top=`${u.y}px`,u.zIndex&&(l.style.zIndex=String(u.zIndex)),nt(l,this.defaultClassName),l.addEventListener("mouseenter",()=>{if(this.hoveredImage={element:l,layout:u},!this.zoomEngine.isInvolved(l)){const g=l.cachedRenderedWidth;mt(l,this.fullConfig.styling?.hover,e,g),nt(l,this.hoverClassName)}}),l.addEventListener("mouseleave",()=>{if(this.hoveredImage=null,!this.zoomEngine.isInvolved(l)){const g=l.cachedRenderedWidth;mt(l,this.fullConfig.styling?.default,e,g),pt(l,this.hoverClassName),nt(l,this.defaultClassName)}}),l.addEventListener("click",g=>{g.stopPropagation(),this.handleImageClick(l,u)}),l.style.opacity="0",l.style.transition=this.entryAnimationEngine.getTransitionCSS(),l.onload=()=>{if(o!==this.loadGeneration)return;const g=l.naturalWidth/l.naturalHeight,p=e*g;l.dataset.onloadCalled="true",window.DEBUG_CLIPPATH&&console.log(`[onload #${d}] Called with imageHeight=${e}, renderedWidth=${p}`),l.style.width=`${p}px`,l.cachedRenderedWidth=p,l.aspectRatio=g,mt(l,this.fullConfig.styling?.default,e,p);const y={x:u.x,y:u.y},f={width:p,height:e},m=this.entryAnimationEngine.calculateStartPosition(y,f,i,d,t.length),x=this.entryAnimationEngine.calculateStartRotation(u.rotation),v=this.entryAnimationEngine.calculateStartScale(u.scale),w=this.entryAnimationEngine.buildFinalTransform(u.rotation,u.scale,p,e),I=this.entryAnimationEngine.buildStartTransform(m,y,u.rotation,u.scale,p,e,x,v);this.fullConfig.config.debug?.enabled&&d<3&&console.log(`Image ${d}:`,{finalPosition:y,imageSize:f,left:u.x,top:u.y,finalTransform:w,renderedWidth:p,renderedHeight:e}),l.style.transform=I,l.dataset.finalTransform=w,(this.entryAnimationEngine.requiresJSAnimation()||this.entryAnimationEngine.requiresJSRotation()||this.entryAnimationEngine.requiresJSScale()||x!==u.rotation||v!==u.scale)&&(l.dataset.startX=String(m.x),l.dataset.startY=String(m.y),l.dataset.endX=String(y.x),l.dataset.endY=String(y.y),l.dataset.imageWidth=String(p),l.dataset.imageHeight=String(e),l.dataset.rotation=String(u.rotation),l.dataset.scale=String(u.scale),l.dataset.startRotation=String(x),l.dataset.startScale=String(v)),this.displayQueue.push(l)},l.onerror=()=>r++,l.src=c})}async handleImageClick(t,e){if(!this.containerEl)return;const i=this.zoomEngine.isFocused(t),o={width:this.containerEl.offsetWidth,height:this.containerEl.offsetHeight};if(i)await this.zoomEngine.unfocusImage(),this.currentFocusIndex=null,this.swipeEngine?.disable(),this.hideCounter();else{const a=t.dataset.imageId;this.currentFocusIndex=a!==void 0?parseInt(a,10):null,this.swipeEngine?.enable(),await this.zoomEngine.focusImage(t,o,e),this.currentFocusIndex!==null&&this.updateCounter(this.currentFocusIndex)}}clearImageCloud(){this.queueInterval!==null&&(clearInterval(this.queueInterval),this.queueInterval=null),this.loadGeneration++,this.displayQueue=[],this.containerEl&&this.containerEl.querySelectorAll(".fbn-ic-image, .fbn-ic-debug-center").forEach(t=>t.remove()),this.imageElements=[],this.imageLayouts=[],this.currentFocusIndex=null,this.hoveredImage=null,this.layoutEngine.reset(),this.zoomEngine.reset(),this.imagesLoaded=!1}showLoading(t){!this.fullConfig.rendering.ui.showLoadingSpinner||!this.loadingEl||(t?this.loadingEl.classList.remove("fbn-ic-hidden"):this.loadingEl.classList.add("fbn-ic-hidden"))}showError(t){this.errorEl&&(this.errorEl.textContent=t,this.errorEl.classList.remove("fbn-ic-hidden"))}hideError(){this.errorEl&&this.errorEl.classList.add("fbn-ic-hidden")}updateCounter(t){!this.fullConfig.rendering.ui.showImageCounter||!this.counterEl||(this.counterEl.textContent=`${t+1} of ${this.imageElements.length}`,this.counterEl.classList.remove("fbn-ic-hidden"))}hideCounter(){this.counterEl&&this.counterEl.classList.add("fbn-ic-hidden")}destroy(){this.clearImageCloud(),this.loadingElAutoCreated&&this.loadingEl&&(this.loadingEl.remove(),this.loadingEl=null),this.errorElAutoCreated&&this.errorEl&&(this.errorEl.remove(),this.errorEl=null),this.counterElAutoCreated&&this.counterEl&&(this.counterEl.remove(),this.counterEl=null),this.resizeTimeout!==null&&clearTimeout(this.resizeTimeout),this.swipeEngine?.destroy()}}A.AnimationEngine=Rt,A.BOUNCE_PRESETS=rt,A.ClusterPlacementLayout=Ut,A.CompositeLoader=Yt,A.DEFAULT_CONFIG=b,A.DEFAULT_SHARED_LOADER_CONFIG=gt,A.ELASTIC_PRESETS=ct,A.EntryAnimationEngine=Ft,A.FUNCTIONAL_CSS=Bt,A.GoogleDriveLoader=Gt,A.GridPlacementLayout=$t,A.ImageCloud=Jt,A.ImageFilter=Xt,A.ImageGallery=Jt,A.LayoutEngine=Ht,A.RadialPlacementLayout=Dt,A.RandomPlacementLayout=zt,A.SpiralPlacementLayout=Pt,A.StaticImageLoader=qt,A.WAVE_PATH_PRESETS=lt,A.WavePlacementLayout=_t,A.ZoomEngine=kt,A.animatePath=Lt,A.injectFunctionalStyles=Vt,A.requiresJSAnimation=Mt,Object.defineProperty(A,Symbol.toStringTag,{value:"Module"})}));
|
|
53
|
+
`;function Vt(){if(typeof document>"u")return;const n="fbn-ic-functional-styles";if(document.getElementById(n))return;const t=document.createElement("style");t.id=n,t.textContent=Xt,document.head.appendChild(t)}class Jt{constructor(t={}){this.fullConfig=ae(t),t.container instanceof HTMLElement?(this.containerRef=t.container,this.containerId=null):(this.containerRef=null,this.containerId=t.container||"imageCloud"),this.imagesLoaded=!1,this.imageElements=[],this.imageLayouts=[],this.currentImageHeight=225,this.currentFocusIndex=null,this.hoveredImage=null,this.resizeTimeout=null,this.displayQueue=[],this.queueInterval=null,this.loadGeneration=0,this.loadingElAutoCreated=!1,this.errorElAutoCreated=!1,this.counterEl=null,this.counterElAutoCreated=!1,this.animationEngine=new Ct(this.fullConfig.animation),this.layoutEngine=new Ht({layout:this.fullConfig.layout,image:this.fullConfig.image}),this.zoomEngine=new kt(this.fullConfig.interaction.focus,this.animationEngine,this.fullConfig.styling),this.defaultStyles=it(this.fullConfig.styling?.default),this.defaultClassName=this.fullConfig.styling?.default?.className,this.hoverClassName=this.fullConfig.styling?.hover?.className;const i=this.fullConfig.animation.entry||y.animation.entry;this.entryAnimationEngine=new Ft(i,this.fullConfig.layout.algorithm),this.swipeEngine=null,this.imageFilter=this.createImageFilter(),this.imageLoader=this.createLoader(),this.containerEl=null,this.loadingEl=null,this.errorEl=null}createImageFilter(){const t=this.fullConfig.config.loaders?.allowedExtensions;return new Yt(t)}createLoader(){const t=this.fullConfig.loaders,i=this.fullConfig.config.loaders??{};if(!t||t.length===0)throw new Error("No loaders configured. Provide `images`, `loaders`, or both.");const e=t.map(o=>this.createLoaderFromEntry(o,i));return e.length===1?e[0]:new Bt({loaders:e,debugLogging:this.fullConfig.config.debug?.loaders})}createLoaderFromEntry(t,i){if("static"in t){const e=t.static,o={...e,validateUrls:e.validateUrls??i.validateUrls,validationTimeout:e.validationTimeout??i.validationTimeout,validationMethod:e.validationMethod??i.validationMethod,allowedExtensions:e.allowedExtensions??i.allowedExtensions,debugLogging:e.debugLogging??this.fullConfig.config.debug?.loaders};return new qt(o)}else if("googleDrive"in t){const e=t.googleDrive,o={...e,allowedExtensions:e.allowedExtensions??i.allowedExtensions,debugLogging:e.debugLogging??this.fullConfig.config.debug?.loaders};return new Gt(o)}else throw new Error(`Unknown loader entry: ${JSON.stringify(t)}`)}async init(){try{if(Vt(),this.containerRef)this.containerEl=this.containerRef;else if(this.containerEl=document.getElementById(this.containerId),!this.containerEl)throw new Error(`Container #${this.containerId} not found`);this.containerEl.classList.add("fbn-ic-gallery"),this.swipeEngine=new bt(this.containerEl,{onNext:()=>this.navigateToNextImage(),onPrev:()=>this.navigateToPreviousImage(),onDragOffset:t=>this.zoomEngine.setDragOffset(t),onDragEnd:t=>{t?this.zoomEngine.clearDragOffset(!1):this.zoomEngine.clearDragOffset(!0,Oe)}}),this.setupUI(),this.setupEventListeners(),this.logDebug("ImageCloud initialized"),await this.loadImages()}catch(t){console.error("Gallery initialization failed:",t),this.errorEl&&t instanceof Error&&this.showError("Gallery failed to initialize: "+t.message)}}setupUI(){const t=this.fullConfig.rendering.ui;t.showLoadingSpinner&&(t.loadingElement?(this.loadingEl=this.resolveElement(t.loadingElement),this.loadingElAutoCreated=!1):(this.loadingEl=this.createDefaultLoadingElement(),this.loadingElAutoCreated=!0)),t.errorElement?(this.errorEl=this.resolveElement(t.errorElement),this.errorElAutoCreated=!1):(this.errorEl=this.createDefaultErrorElement(),this.errorElAutoCreated=!0),t.showImageCounter&&(t.counterElement?(this.counterEl=this.resolveElement(t.counterElement),this.counterElAutoCreated=!1):(this.counterEl=this.createDefaultCounterElement(),this.counterElAutoCreated=!0))}resolveElement(t){return t instanceof HTMLElement?t:document.getElementById(t)}createDefaultLoadingElement(){const t=document.createElement("div");t.className="fbn-ic-loading fbn-ic-hidden";const i=document.createElement("div");i.className="fbn-ic-spinner",t.appendChild(i);const e=document.createElement("p");return e.textContent="Loading images...",t.appendChild(e),this.containerEl.appendChild(t),t}createDefaultErrorElement(){const t=document.createElement("div");return t.className="fbn-ic-error fbn-ic-hidden",this.containerEl.appendChild(t),t}createDefaultCounterElement(){const t=document.createElement("div");return t.className="fbn-ic-counter fbn-ic-hidden",this.containerEl.appendChild(t),t}setupEventListeners(){document.addEventListener("keydown",t=>{t.key==="Escape"?(this.zoomEngine.unfocusImage(),this.currentFocusIndex=null,this.swipeEngine?.disable(),this.hideCounter()):t.key==="ArrowRight"?this.navigateToNextImage():t.key==="ArrowLeft"?this.navigateToPreviousImage():(t.key==="Enter"||t.key===" ")&&this.hoveredImage&&(this.handleImageClick(this.hoveredImage.element,this.hoveredImage.layout),t.preventDefault())}),document.addEventListener("click",t=>{this.swipeEngine?.hadRecentTouch()||t.target.closest(".fbn-ic-image")||(this.zoomEngine.unfocusImage(),this.currentFocusIndex=null,this.swipeEngine?.disable(),this.hideCounter())}),window.addEventListener("resize",()=>this.handleResize())}navigateToNextImage(){if(this.currentFocusIndex===null||this.imageElements.length===0)return;const t=(this.currentFocusIndex+1)%this.imageLayouts.length,i=this.imageElements.find(o=>o.dataset.imageId===String(t));if(!i)return;const e=this.imageLayouts[t];e&&(this.currentFocusIndex=t,this.handleImageClick(i,e),this.updateCounter(t))}navigateToPreviousImage(){if(this.currentFocusIndex===null||this.imageElements.length===0)return;const t=(this.currentFocusIndex-1+this.imageLayouts.length)%this.imageLayouts.length,i=this.imageElements.find(o=>o.dataset.imageId===String(t));if(!i)return;const e=this.imageLayouts[t];e&&(this.currentFocusIndex=t,this.handleImageClick(i,e),this.updateCounter(t))}handleResize(){this.imagesLoaded&&(this.resizeTimeout!==null&&clearTimeout(this.resizeTimeout),this.resizeTimeout=window.setTimeout(()=>{const t=this.getImageHeight();t!==this.currentImageHeight?(this.logDebug(`Window resized to new breakpoint (height: ${t}px). Reloading images...`),this.loadImages()):this.logDebug("Window resized (no breakpoint change)")},500))}getImageHeight(){const t=window.innerWidth,i=this.fullConfig.layout.responsive,o=this.fullConfig.image.sizing?.maxSize??400;return i?t<=i.mobile.maxWidth?Math.min(100,o):t<=i.tablet.maxWidth?Math.min(180,o):Math.min(225,o):t<=767?Math.min(100,o):t<=1199?Math.min(180,o):Math.min(225,o)}getContainerBounds(){return this.containerEl?{width:this.containerEl.offsetWidth,height:this.containerEl.offsetHeight||window.innerHeight*.7}:{width:window.innerWidth,height:window.innerHeight*.7}}async loadImages(){try{this.showLoading(!0),this.hideError(),this.clearImageCloud(),await this.imageLoader.prepare(this.imageFilter);const t=this.imageLoader.imagesLength();let i=this.imageLoader.imageURLs();if(t===0){this.showError("No images found."),this.showLoading(!1);return}const e=this.getContainerBounds(),o=this.getImageHeight(),a=window.innerWidth;this.logDebug(`Adaptive sizing input: container=${e.width}x${e.height}px, images=${t}, responsiveMax=${o}px`);const r=this.layoutEngine.calculateAdaptiveSize(e,t,o,a);this.logDebug(`Adaptive sizing result: height=${r.height}px`),await this.createImageCloud(i,r.height),this.showLoading(!1),this.imagesLoaded=!0}catch(t){console.error("Error loading images:",t),t instanceof Error&&this.showError(t.message||"Failed to load images."),this.showLoading(!1)}}logDebug(...t){this.fullConfig.config.debug?.enabled&&typeof console<"u"&&console.log(...t)}async createImageCloud(t,i){if(!this.containerEl)return;const e=this.getContainerBounds();this.currentImageHeight=i;const o=this.loadGeneration,a=this.layoutEngine.generateLayout(t.length,e,{fixedHeight:i});this.imageLayouts=a,this.displayQueue=[];let r=0;const s=c=>{this.containerEl&&(this.containerEl.appendChild(c),this.imageElements.push(c),requestAnimationFrame(()=>{if(c.offsetWidth,c.style.opacity=this.defaultStyles.opacity??"1",c.dataset.startX&&(this.entryAnimationEngine.requiresJSAnimation()||this.entryAnimationEngine.requiresJSRotation()||this.entryAnimationEngine.requiresJSScale()||c.dataset.startRotation!==c.dataset.rotation||c.dataset.startScale!==c.dataset.scale)){const u={x:parseFloat(c.dataset.startX),y:parseFloat(c.dataset.startY)},g={x:parseFloat(c.dataset.endX),y:parseFloat(c.dataset.endY)},p=parseFloat(c.dataset.imageWidth),b=parseFloat(c.dataset.imageHeight),f=parseFloat(c.dataset.rotation),m=parseFloat(c.dataset.scale),x=c.dataset.startRotation?parseFloat(c.dataset.startRotation):f,v=c.dataset.startScale?parseFloat(c.dataset.startScale):m,w=this.entryAnimationEngine.getTiming();Lt({element:c,startPosition:u,endPosition:g,pathConfig:this.entryAnimationEngine.getPathConfig(),duration:w.duration,imageWidth:p,imageHeight:b,rotation:f,scale:m,rotationConfig:this.entryAnimationEngine.getRotationConfig(),startRotation:x,scaleConfig:this.entryAnimationEngine.getScaleConfig(),startScale:v})}else{const u=c.dataset.finalTransform||"";c.style.transform=u}const l=parseInt(c.dataset.imageId||"0");if(this.fullConfig.config.debug?.enabled&&l<3){const u=c.dataset.finalTransform||"";console.log(`Image ${l} final state:`,{left:c.style.left,top:c.style.top,width:c.style.width,height:c.style.height,computedWidth:c.offsetWidth,computedHeight:c.offsetHeight,transform:u,pathType:this.entryAnimationEngine.getPathType()})}}),r++)},h=()=>{if(this.logDebug("Starting queue processing, enabled:",this.fullConfig.animation.queue.enabled),!this.fullConfig.animation.queue.enabled){for(;this.displayQueue.length>0;){const c=this.displayQueue.shift();c&&s(c)}return}this.queueInterval!==null&&clearInterval(this.queueInterval),this.queueInterval=window.setInterval(()=>{if(o!==this.loadGeneration){this.queueInterval!==null&&(clearInterval(this.queueInterval),this.queueInterval=null);return}if(this.displayQueue.length>0){const c=this.displayQueue.shift();c&&s(c)}r>=t.length&&this.displayQueue.length===0&&this.queueInterval!==null&&(clearInterval(this.queueInterval),this.queueInterval=null)},this.fullConfig.animation.queue.interval)};if("IntersectionObserver"in window&&this.containerEl){const c=new IntersectionObserver(d=>{d.forEach(l=>{l.isIntersecting&&(h(),c.disconnect())})},{threshold:.1,rootMargin:"50px"});c.observe(this.containerEl)}else h();this.fullConfig.config.debug?.centers&&this.containerEl&&(this.containerEl.querySelectorAll(".fbn-ic-debug-center").forEach(c=>c.remove()),a.forEach((c,d)=>{const l=document.createElement("div");l.className="fbn-ic-debug-center",l.style.position="absolute",l.style.width="12px",l.style.height="12px",l.style.borderRadius="50%",l.style.backgroundColor="red",l.style.border="2px solid yellow",l.style.zIndex="9999",l.style.pointerEvents="none";const u=c.x,g=c.y;l.style.left=`${u-6}px`,l.style.top=`${g-6}px`,l.title=`Image ${d}: center (${Math.round(u)}, ${Math.round(g)})`,this.containerEl.appendChild(l)})),t.forEach((c,d)=>{const l=document.createElement("img");l.referrerPolicy="no-referrer",l.classList.add("fbn-ic-image"),l.dataset.imageId=String(d),l.dataset.createdFlag="true";const u=a[d];l.style.position="absolute",l.style.width="auto",l.style.height=`${i}px`,l.style.left=`${u.x}px`,l.style.top=`${u.y}px`,u.zIndex&&(l.style.zIndex=String(u.zIndex)),ot(l,this.defaultClassName),l.addEventListener("mouseenter",()=>{if(this.hoveredImage={element:l,layout:u},!this.zoomEngine.isInvolved(l)){const g=l.cachedRenderedWidth;mt(l,this.fullConfig.styling?.hover,i,g),ot(l,this.hoverClassName)}}),l.addEventListener("mouseleave",()=>{if(this.hoveredImage=null,!this.zoomEngine.isInvolved(l)){const g=l.cachedRenderedWidth;mt(l,this.fullConfig.styling?.default,i,g),pt(l,this.hoverClassName),ot(l,this.defaultClassName)}}),l.addEventListener("click",g=>{g.stopPropagation(),this.handleImageClick(l,u)}),l.style.opacity="0",l.style.transition=this.entryAnimationEngine.getTransitionCSS(),l.onload=()=>{if(o!==this.loadGeneration)return;const g=l.naturalWidth/l.naturalHeight,p=i*g;l.dataset.onloadCalled="true",window.DEBUG_CLIPPATH&&console.log(`[onload #${d}] Called with imageHeight=${i}, renderedWidth=${p}`),l.style.width=`${p}px`,l.cachedRenderedWidth=p,l.aspectRatio=g,mt(l,this.fullConfig.styling?.default,i,p);const b={x:u.x,y:u.y},f={width:p,height:i},m=this.entryAnimationEngine.calculateStartPosition(b,f,e,d,t.length),x=this.entryAnimationEngine.calculateStartRotation(u.rotation),v=this.entryAnimationEngine.calculateStartScale(u.scale),w=this.entryAnimationEngine.buildFinalTransform(u.rotation,u.scale,p,i),R=this.entryAnimationEngine.buildStartTransform(m,b,u.rotation,u.scale,p,i,x,v);this.fullConfig.config.debug?.enabled&&d<3&&console.log(`Image ${d}:`,{finalPosition:b,imageSize:f,left:u.x,top:u.y,finalTransform:w,renderedWidth:p,renderedHeight:i}),l.style.transform=R,l.dataset.finalTransform=w,(this.entryAnimationEngine.requiresJSAnimation()||this.entryAnimationEngine.requiresJSRotation()||this.entryAnimationEngine.requiresJSScale()||x!==u.rotation||v!==u.scale)&&(l.dataset.startX=String(m.x),l.dataset.startY=String(m.y),l.dataset.endX=String(b.x),l.dataset.endY=String(b.y),l.dataset.imageWidth=String(p),l.dataset.imageHeight=String(i),l.dataset.rotation=String(u.rotation),l.dataset.scale=String(u.scale),l.dataset.startRotation=String(x),l.dataset.startScale=String(v)),this.displayQueue.push(l)},l.onerror=()=>r++,l.src=c})}async handleImageClick(t,i){if(!this.containerEl)return;const e=this.zoomEngine.isFocused(t),o={width:this.containerEl.offsetWidth,height:this.containerEl.offsetHeight};if(e)await this.zoomEngine.unfocusImage(),this.currentFocusIndex=null,this.swipeEngine?.disable(),this.hideCounter();else{const a=t.dataset.imageId;this.currentFocusIndex=a!==void 0?parseInt(a,10):null,this.swipeEngine?.enable(),await this.zoomEngine.focusImage(t,o,i),this.currentFocusIndex!==null&&this.updateCounter(this.currentFocusIndex)}}clearImageCloud(){this.queueInterval!==null&&(clearInterval(this.queueInterval),this.queueInterval=null),this.loadGeneration++,this.displayQueue=[],this.containerEl&&this.containerEl.querySelectorAll(".fbn-ic-image, .fbn-ic-debug-center").forEach(t=>t.remove()),this.imageElements=[],this.imageLayouts=[],this.currentFocusIndex=null,this.hoveredImage=null,this.layoutEngine.reset(),this.zoomEngine.reset(),this.imagesLoaded=!1}showLoading(t){!this.fullConfig.rendering.ui.showLoadingSpinner||!this.loadingEl||(t?this.loadingEl.classList.remove("fbn-ic-hidden"):this.loadingEl.classList.add("fbn-ic-hidden"))}showError(t){this.errorEl&&(this.errorEl.textContent=t,this.errorEl.classList.remove("fbn-ic-hidden"))}hideError(){this.errorEl&&this.errorEl.classList.add("fbn-ic-hidden")}updateCounter(t){!this.fullConfig.rendering.ui.showImageCounter||!this.counterEl||(this.counterEl.textContent=`${t+1} of ${this.imageElements.length}`,this.counterEl.classList.remove("fbn-ic-hidden"))}hideCounter(){this.counterEl&&this.counterEl.classList.add("fbn-ic-hidden")}destroy(){this.clearImageCloud(),this.loadingElAutoCreated&&this.loadingEl&&(this.loadingEl.remove(),this.loadingEl=null),this.errorElAutoCreated&&this.errorEl&&(this.errorEl.remove(),this.errorEl=null),this.counterElAutoCreated&&this.counterEl&&(this.counterEl.remove(),this.counterEl=null),this.resizeTimeout!==null&&clearTimeout(this.resizeTimeout),this.swipeEngine?.destroy()}}I.AnimationEngine=Ct,I.BOUNCE_PRESETS=ct,I.ClusterPlacementLayout=Ut,I.CompositeLoader=Bt,I.DEFAULT_CONFIG=y,I.DEFAULT_SHARED_LOADER_CONFIG=ft,I.ELASTIC_PRESETS=lt,I.EntryAnimationEngine=Ft,I.FUNCTIONAL_CSS=Xt,I.GoogleDriveLoader=Gt,I.GridPlacementLayout=$t,I.ImageCloud=Jt,I.ImageFilter=Yt,I.ImageGallery=Jt,I.LayoutEngine=Ht,I.RadialPlacementLayout=Ot,I.RandomPlacementLayout=zt,I.SpiralPlacementLayout=Pt,I.StaticImageLoader=qt,I.WAVE_PATH_PRESETS=ht,I.WavePlacementLayout=_t,I.ZoomEngine=kt,I.animatePath=Lt,I.injectFunctionalStyles=Vt,I.requiresJSAnimation=Mt,Object.defineProperty(I,Symbol.toStringTag,{value:"Module"})}));
|
|
54
54
|
//# sourceMappingURL=image-cloud.umd.js.map
|