@frybynite/image-cloud 0.1.2 → 0.2.0

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.
@@ -1,5 +1,45 @@
1
- (function(M,st){typeof exports=="object"&&typeof module<"u"?st(exports):typeof define=="function"&&define.amd?define(["exports"],st):(M=typeof globalThis<"u"?globalThis:M||self,st(M.ImageCloud={}))})(this,function(M){"use strict";const st=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)"}),yt=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})}),bt=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})}),vt=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})}),wt=Object.freeze({type:"linear"}),xt=Object.freeze({mode:"none"}),St=Object.freeze({mode:"none"}),Mt=Object.freeze({default:Object.freeze({border:Object.freeze({width:0,color:"#000000",radius:0,style:"solid"}),shadow:"none",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"}),te=Object.freeze({variance:Object.freeze({min:1,max:1}),scaleDecay:0}),ee=Object.freeze({mode:"none",range:Object.freeze({min:-15,max:15})}),Ct=Object.freeze({sizing:te,rotation:ee}),b=Object.freeze({loader:Object.freeze({type:"googleDrive",googleDrive:Object.freeze({apiKey:"",sources:[],apiEndpoint:"https://www.googleapis.com/drive/v3/files",allowedExtensions:["jpg","jpeg","png","gif","webp","bmp"],debugLogging:!1}),static:Object.freeze({sources:[],validateUrls:!0,validationTimeout:5e3,validationMethod:"head",failOnAllMissing:!0,allowedExtensions:["jpg","jpeg","png","gif","webp","bmp"],debugLogging:!1})}),image:Ct,layout:Object.freeze({algorithm:"radial",sizing:Object.freeze({base:200,responsive:[{minWidth:1200,height:225},{minWidth:768,height:180},{minWidth:0,height:100}],adaptive:Object.freeze({enabled:!0,minSize:50,maxSize:400})}),targetCoverage:.6,densityFactor:1,spacing:Object.freeze({padding:50,minGap:20}),debugRadials:!1,debugCenters:!1}),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,stagger:150}),easing:"cubic-bezier(0.25, 1, 0.5, 1)",path:wt,rotation:xt,scale:St})}),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:void 0,showThumbnails:void 0,theme:void 0}),performance:Object.freeze({lazyLoad:void 0,preloadCount:void 0,imageQuality:void 0})}),styling:Mt,debug:!1});function lt(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.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=lt(n.default,t.default),i=lt(lt(e,n.hover),t.hover),o=lt(lt(e,n.focused),t.focused);return{default:e,hover:i,focused:o}}function ne(n,t){var i,o,s,c,a,h,l,g;if(!t)return{...n};const e={...n};if(t.sizing!==void 0&&(e.sizing={...n.sizing,...t.sizing},t.sizing.variance)){const r=t.sizing.variance,d=r.min!==void 0&&r.min>.1&&r.min<1?r.min:((o=(i=n.sizing)==null?void 0:i.variance)==null?void 0:o.min)??1,f=r.max!==void 0&&r.max>1&&r.max<2?r.max:((c=(s=n.sizing)==null?void 0:s.variance)==null?void 0:c.max)??1;e.sizing.variance={min:d,max:f}}if(t.rotation!==void 0&&(e.rotation={...n.rotation,...t.rotation},t.rotation.range)){const r=t.rotation.range,d=r.min!==void 0&&r.min>=-180&&r.min<=0?r.min:((h=(a=n.rotation)==null?void 0:a.range)==null?void 0:h.min)??-15,f=r.max!==void 0&&r.max>=0&&r.max<=180?r.max:((g=(l=n.rotation)==null?void 0:l.range)==null?void 0:g.max)??15;e.rotation.range={min:d,max:f}}return e}function oe(n){var e;const t=(e=n.layout)==null?void 0:e.rotation;if(t&&"enabled"in t)return{rotation:{mode:t.enabled?"random":"none",range:t.range}}}function se(n){var e,i;const t=(i=(e=n.layout)==null?void 0:e.sizing)==null?void 0:i.variance;if(t)return{sizing:{variance:t}}}function ae(n={}){var s;const t=oe(n),e=se(n);let i=n.image;(t||e)&&(i={...e||{},...t||{},...i},i.rotation&&(t!=null&&t.rotation)&&((s=n.image)!=null&&s.rotation)&&(i.rotation={...t.rotation,...n.image.rotation}));const o={loader:{...b.loader},image:ne(Ct,i),layout:{...b.layout},animation:{...b.animation},interaction:{...b.interaction},rendering:{...b.rendering},styling:ie(Mt,n.styling),debug:b.debug};return n.loader&&(o.loader={...b.loader,...n.loader},n.loader.googleDrive&&(o.loader.googleDrive={...b.loader.googleDrive,...n.loader.googleDrive,sources:n.loader.googleDrive.sources||b.loader.googleDrive.sources,allowedExtensions:n.loader.googleDrive.allowedExtensions||b.loader.googleDrive.allowedExtensions}),n.loader.static&&(o.loader.static={...b.loader.static,...n.loader.static,sources:n.loader.static.sources||b.loader.static.sources,allowedExtensions:n.loader.static.allowedExtensions||b.loader.static.allowedExtensions})),n.layout&&(o.layout={...b.layout,...n.layout},n.layout.sizing&&(o.layout.sizing={...b.layout.sizing,...n.layout.sizing,responsive:n.layout.sizing.responsive||b.layout.sizing.responsive,adaptive:n.layout.sizing.adaptive?{...b.layout.sizing.adaptive,...n.layout.sizing.adaptive}:b.layout.sizing.adaptive}),n.layout.spacing&&(o.layout.spacing={...b.layout.spacing,...n.layout.spacing})),n.animation&&(o.animation={...b.animation,...n.animation},n.animation.easing&&(o.animation.easing={...b.animation.easing,...n.animation.easing}),n.animation.queue&&(o.animation.queue={...b.animation.queue,...n.animation.queue}),n.animation.performance&&(o.animation.performance={...b.animation.performance,...n.animation.performance}),n.animation.entry&&(o.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?{...wt,...n.animation.entry.path}:b.animation.entry.path,rotation:n.animation.entry.rotation?{...xt,...n.animation.entry.rotation}:b.animation.entry.rotation,scale:n.animation.entry.scale?{...St,...n.animation.entry.scale}:b.animation.entry.scale})),n.interaction&&(o.interaction={...b.interaction,...n.interaction},n.interaction.focus&&(o.interaction.focus={...b.interaction.focus,...n.interaction.focus}),n.interaction.navigation&&(o.interaction.navigation={...b.interaction.navigation,...n.interaction.navigation}),n.interaction.gestures&&(o.interaction.gestures={...b.interaction.gestures,...n.interaction.gestures})),n.rendering&&(o.rendering={...b.rendering,...n.rendering},n.rendering.responsive&&(o.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&&(o.rendering.ui={...b.rendering.ui,...n.rendering.ui}),n.rendering.performance&&(o.rendering.performance={...b.rendering.performance,...n.rendering.performance})),n.debug!==void 0&&(o.debug=n.debug),o}function re(n,t){return{...n?yt[n]:yt.playful,...t}}function ce(n,t){return{...n?bt[n]:bt.gentle,...t}}function le(n,t){return{...n?vt[n]:vt.gentle,...t}}class Lt{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,s=null){this.cancelAllAnimations(t);const c=o??this.config.duration,a=s??this.config.easing.default,h=this.buildTransformString(e),l=this.buildTransformString(i);t.style.transition="none";const g=t.animate([{transform:h},{transform:l}],{duration:c,easing:a,fill:"forwards"}),r={id:`anim-${++this.animationIdCounter}`,element:t,animation:g,fromState:e,toState:i,startTime:performance.now(),duration:c};return this.activeAnimations.set(t,r),g.finished.then(()=>{t.style.transform=l,this.activeAnimations.delete(t)}).catch(()=>{this.activeAnimations.delete(t)}),r}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),s=Math.sqrt(o.a*o.a+o.b*o.b),c=Math.atan2(o.b,o.a)*(180/Math.PI),a=o.e,h=o.f;return{x:a,y:h,rotation:c,scale:s}}hasActiveAnimation(t){return this.activeAnimations.has(t)}getAnimationHandle(t){return this.activeAnimations.get(t)}animateTransform(t,e,i=null,o=null){return new Promise(s=>{const c=i??this.config.duration,a=o??this.config.easing.default;t.style.transition=`transform ${c}ms ${a}, box-shadow ${c}ms ${a}`,t.style.transform=this.buildTransformString(e),setTimeout(()=>{s()},c)})}resetTransform(t,e){return this.animateTransform(t,e)}clearTransition(t){t.style.transition=""}wait(t){return new Promise(e=>setTimeout(e,t))}}function at(n,t,e){return n+(t-n)*e}function he(n,t,e,i){const{overshoot:o,bounces:s,decayRatio:c}=i,a=e.x-t.x,h=e.y-t.y,l=de(s,c);let g=0,r=0,d=1,f=o,y=!1;for(let u=0;u<l.length;u++)if(n<=l[u].time){r=u===0?0:l[u-1].time,d=l[u].time,f=l[u].overshoot,y=l[u].isOvershoot;break}const p=(n-r)/(d-r);if(y)g=1+f*ut(p);else if(r===0)g=ut(p);else{const u=l.find((w,v)=>w.time>r&&v>0&&l[v-1].isOvershoot),m=1+((u==null?void 0:u.overshoot)||f);g=at(m,1,ut(p))}return{x:t.x+a*g,y:t.y+h*g}}function de(n,t){const e=[];let i=.6;e.push({time:i,overshoot:0,isOvershoot:!1});let o=.15;const c=.4/(n*2);for(let a=0;a<n;a++)i+=c,e.push({time:i,overshoot:o,isOvershoot:!0}),i+=c,e.push({time:i,overshoot:o*t,isOvershoot:!1}),o*=t;return e.push({time:1,overshoot:0,isOvershoot:!1}),e}function ge(n,t,e,i){const{stiffness:o,damping:s,mass:c,oscillations:a}=i,h=e.x-t.x,l=e.y-t.y,g=Math.sqrt(o/c),r=s/(2*Math.sqrt(o*c));let d;if(r<1){const f=g*Math.sqrt(1-r*r),y=Math.exp(-r*g*n*3),p=Math.cos(f*n*a*Math.PI);d=1-y*p}else d=1-Math.exp(-g*n*3);return d=Math.max(0,Math.min(d,1.3)),{x:t.x+h*d,y:t.y+l*d}}function ue(n,t,e,i){const{amplitude:o,frequency:s,decay:c,decayRate:a,phase:h}=i,l=e.x-t.x,g=e.y-t.y,r=Math.sqrt(l*l+g*g),d=r>0?-g/r:0,f=r>0?l/r:1,y=s*Math.PI*2*n+h,p=c?Math.pow(1-n,a):1,u=o*Math.sin(y)*p,m=me(n);return{x:at(t.x,e.x,m)+u*d,y:at(t.y,e.y,m)+u*f}}function ut(n){return 1-(1-n)*(1-n)}function me(n){return 1-Math.pow(1-n,3)}function fe(n,t,e){const{amplitude:i,frequency:o,decay:s}=e,c=Math.sin(n*o*Math.PI*2),a=s?Math.pow(1-n,2):1,h=i*c*a;return t+h}function pe(n,t,e){const{overshoot:i,bounces:o}=e,s=[];s.push({time:.5,scale:i});let c=i;const a=.5,l=.5/(o*2);let g=.5;for(let d=0;d<o;d++){const f=1-(c-1)*a;g+=l,s.push({time:g,scale:f}),c=1+(c-1)*a*a,g+=l,d<o-1&&s.push({time:g,scale:c})}s.push({time:1,scale:1});let r=1;for(let d=0;d<s.length;d++)if(n<=s[d].time){const f=d===0?0:s[d-1].time,y=d===0?1:s[d-1].scale,p=(n-f)/(s[d].time-f),u=ut(p);r=y+(s[d].scale-y)*u;break}return r*t}function $t(n){const{element:t,startPosition:e,endPosition:i,pathConfig:o,duration:s,imageWidth:c,imageHeight:a,rotation:h,scale:l,onComplete:g,rotationConfig:r,startRotation:d,scaleConfig:f,startScale:y}=n,p=o.type,u=d!==void 0&&d!==h,m=(r==null?void 0:r.mode)==="wobble",w=(r==null?void 0:r.wobble)||{amplitude:15,frequency:3,decay:!0},v=u||m,R=y!==void 0&&y!==l,F=(f==null?void 0:f.mode)==="pop",x=(f==null?void 0:f.pop)||{overshoot:1.2,bounces:1};if((p==="linear"||p==="arc")&&!v&&!(R||F)){g&&g();return}const k=performance.now(),j=-c/2,U=-a/2;function G(W){const C=W-k,I=Math.min(C/s,1);let A;switch(p){case"bounce":{const P=re(o.bouncePreset,o.bounce);A=he(I,e,i,P);break}case"elastic":{const P=ce(o.elasticPreset,o.elastic);A=ge(I,e,i,P);break}case"wave":{const P=le(o.wavePreset,o.wave);A=ue(I,e,i,P);break}default:A={x:at(e.x,i.x,I),y:at(e.y,i.y,I)}}const D=A.x-i.x,S=A.y-i.y;let T;m?T=fe(I,h,w):u?T=at(d,h,I):T=h;let z;F?z=pe(I,l,x):R?z=at(y,l,I):z=l,t.style.transform=`translate(${j}px, ${U}px) translate(${D}px, ${S}px) rotate(${T}deg) scale(${z})`,I<1?requestAnimationFrame(G):(t.style.transform=`translate(${j}px, ${U}px) rotate(${h}deg) scale(${l})`,g&&g())}requestAnimationFrame(G)}function Ot(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 Dt{constructor(t,e){this.config=t,this.layoutAlgorithm=e,this.resolvedStartPosition=this.resolveStartPosition(),this.pathConfig=t.path||wt,this.rotationConfig=t.rotation||xt,this.scaleConfig=t.scale||St}resolveStartPosition(){return this.config.start.position?this.config.start.position:ye[this.layoutAlgorithm]||"nearest-edge"}calculateStartPosition(t,e,i,o,s){const c=this.resolvedStartPosition,a=this.config.start.offset??100;switch(c){case"nearest-edge":return this.calculateNearestEdge(t,e,i,a);case"top":return this.calculateEdgePosition("top",t,e,i,a);case"bottom":return this.calculateEdgePosition("bottom",t,e,i,a);case"left":return this.calculateEdgePosition("left",t,e,i,a);case"right":return this.calculateEdgePosition("right",t,e,i,a);case"center":return this.calculateCenterPosition(i,t,e);case"random-edge":return this.calculateRandomEdge(t,e,i,a);case"circular":return this.calculateCircularPosition(t,e,i,o,s);default:return this.calculateNearestEdge(t,e,i,a)}}calculateNearestEdge(t,e,i,o){const s=t.x,c=t.y,a=s,h=i.width-s,l=c,g=i.height-c,r=Math.min(a,h,l,g);let d=t.x,f=t.y;return r===a?d=-(e.width+o):r===h?d=i.width+o:r===l?f=-(e.height+o):f=i.height+o,{x:d,y:f}}calculateEdgePosition(t,e,i,o,s){let c=e.x,a=e.y;switch(t){case"top":a=-(i.height+s);break;case"bottom":a=o.height+s;break;case"left":c=-(i.width+s);break;case"right":c=o.width+s;break}return{x:c,y:a}}calculateCenterPosition(t,e,i){const o=t.width/2,s=t.height/2;return{x:o,y:s,useScale:!0}}calculateRandomEdge(t,e,i,o){const s=["top","bottom","left","right"],c=s[Math.floor(Math.random()*s.length)];return this.calculateEdgePosition(c,t,e,i,o)}calculateCircularPosition(t,e,i,o,s){const c=this.config.start.circular||{},a=c.distribution||"even";let h;const l=c.radius||"120%";if(typeof l=="string"&&l.endsWith("%")){const p=parseFloat(l)/100;h=Math.sqrt(i.width**2+i.height**2)*p/2}else h=typeof l=="number"?l:500;let g;a==="even"?g=o/s*2*Math.PI:g=Math.random()*2*Math.PI;const r=i.width/2,d=i.height/2,f=r+Math.cos(g)*h,y=d+Math.sin(g)*h;return{x:f,y}}getAnimationParams(t){const e=this.config.timing.duration,i=this.config.timing.stagger,o=this.config.easing;return{startTransform:"",duration:e,delay:t*i,easing:o}}buildStartTransform(t,e,i,o,s,c,a,h){const l=t.x-e.x,g=t.y-e.y,r=a!==void 0?a:i,d=h!==void 0?h:o,f=s!==void 0?-s/2:0,y=c!==void 0?-c/2:0,p=s!==void 0?`translate(${f}px, ${y}px)`:"translate(-50%, -50%)";return t.useScale?`${p} translate(${l}px, ${g}px) rotate(${r}deg) scale(0)`:`${p} translate(${l}px, ${g}px) rotate(${r}deg) scale(${d})`}buildFinalTransform(t,e,i,o){if(i!==void 0&&o!==void 0){const s=-i/2,c=-o/2;return`translate(${s}px, ${c}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 Ot(this.pathConfig.type)}getPathConfig(){return this.pathConfig}getPathType(){return this.pathConfig.type}getTiming(){return{duration:this.config.timing.duration,stagger:this.config.timing.stagger}}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;case"auto":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:s,decay:c}=i,a=Math.sin(t*s*Math.PI*2),h=c?Math.pow(1-t,2):1,l=o*a*h;return e+l}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:s}=i,c=this.generateScaleBounceKeyframes(s,o);let a=e;for(let h=0;h<c.length;h++)if(t<=c[h].time){const l=h===0?0:c[h-1].time,g=h===0?e:c[h-1].scale,r=(t-l)/(c[h].time-l),d=this.easeOutQuad(r);a=g+(c[h].scale-g)*d;break}return a*e}generateScaleBounceKeyframes(t,e){const i=[];i.push({time:.5,scale:e});let o=e;const s=.5,a=.5/(t*2);let h=.5;for(let l=0;l<t;l++){const g=1-(o-1)*s;h+=a,i.push({time:h,scale:g}),o=1+(o-1)*s*s,h+=a,l<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 Pt{constructor(t,e={}){this.config=t,this.imageConfig=e}generate(t,e,i={}){var x,$,k,j,U,G,W,C,I;const o=[],{width:s,height:c}=e,a=this.config.spacing.padding,h=i.fixedHeight??this.config.sizing.base,l=((x=this.imageConfig.rotation)==null?void 0:x.mode)??"none",g=((k=($=this.imageConfig.rotation)==null?void 0:$.range)==null?void 0:k.min)??-15,r=((U=(j=this.imageConfig.rotation)==null?void 0:j.range)==null?void 0:U.max)??15,d=((W=(G=this.imageConfig.sizing)==null?void 0:G.variance)==null?void 0:W.min)??1,f=((I=(C=this.imageConfig.sizing)==null?void 0:C.variance)==null?void 0:I.max)??1,y=d!==1||f!==1,u=h*1.5/2,m=h/2,w=s-a-u,v=c-a-m,R=a+u,F=a+m;for(let A=0;A<t;A++){const D=this.random(R,w),S=this.random(F,v),T=l==="random"?this.random(g,r):0,z=y?this.random(d,f):1,P=h*z,Q={id:A,x:D,y:S,rotation:T,scale:z,baseSize:P};o.push(Q)}return o}random(t,e){return Math.random()*(e-t)+t}}class Ut{constructor(t,e={}){this.config=t,this.imageConfig=e}generate(t,e,i={}){var $,k,j,U,G,W,C,I,A,D;const o=[],{width:s,height:c}=e,{debugRadials:a}=this.config,h=this.config.sizing.base,l=(($=this.imageConfig.rotation)==null?void 0:$.mode)??"none",g=((j=(k=this.imageConfig.rotation)==null?void 0:k.range)==null?void 0:j.min)??-15,r=((G=(U=this.imageConfig.rotation)==null?void 0:U.range)==null?void 0:G.max)??15,d=((C=(W=this.imageConfig.sizing)==null?void 0:W.variance)==null?void 0:C.min)??1,f=((A=(I=this.imageConfig.sizing)==null?void 0:I.variance)==null?void 0:A.max)??1,y=d!==1||f!==1,p=((D=this.imageConfig.sizing)==null?void 0:D.scaleDecay)??0,u=["green","blue","red","yellow","orange","purple"],m=i.fixedHeight??h,w=s/2,v=c/2,R=Math.ceil(Math.sqrt(t));if(t>0){const S=y?this.random(d,f):1,T=m*S;o.push({id:0,x:w,y:v,rotation:l==="random"?this.random(g*.33,r*.33):0,scale:S,baseSize:T,zIndex:100,borderColor:a?"cyan":void 0})}let F=1,x=1;for(;F<t;){const S=x/R,T=p>0?1-S*p*.5:1,z=x*(m*.8),P=z*1.5,Q=Math.PI*(3*(P+z)-Math.sqrt((3*P+z)*(P+3*z))),it=this.estimateWidth(m),N=Math.floor(Q/(it*.7));if(N===0){x++;continue}const q=2*Math.PI/N,nt=x*(20*Math.PI/180);for(let K=0;K<N&&F<t;K++){const V=K*q+nt,Y=y?this.random(d,f):1,ot=T*Y,J=m*ot;let L=w+Math.cos(V)*P,H=v+Math.sin(V)*z;const O=this.config.spacing.padding??50,tt=J*1.5/2,_=J/2;L-tt<O?L=O+tt:L+tt>s-O&&(L=s-O-tt),H-_<O?H=O+_:H+_>c-O&&(H=c-O-_);const et=l==="random"?this.random(g,r):0;o.push({id:F,x:L,y:H,rotation:et,scale:ot,baseSize:J,zIndex:Math.max(1,100-x),borderColor:a?u[(x-1)%u.length]:void 0}),F++}x++}return o}estimateWidth(t){return t*1.4}random(t,e){return Math.random()*(e-t)+t}}console.log("[GridPlacementGenerator] Module loaded");const be={columns:"auto",rows:"auto",stagger:"none",jitter:0,overlap:0,fillDirection:"row",alignment:"center",gap:10,overflowOffset:.25},Gt=[{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 Ht{constructor(t,e={}){this.config=t,this.imageConfig=e}generate(t,e,i={}){var it,N,q,nt,K,V,Y,ot,J;const o=[],{width:s,height:c}=e,a={...be,...this.config.grid},h=this.config.spacing.padding,l=i.fixedHeight??this.config.sizing.base,g=((it=this.imageConfig.rotation)==null?void 0:it.mode)??"none",r=((q=(N=this.imageConfig.sizing)==null?void 0:N.variance)==null?void 0:q.min)??1,d=((K=(nt=this.imageConfig.sizing)==null?void 0:nt.variance)==null?void 0:K.max)??1,f=r!==1||d!==1,y=s-2*h,p=c-2*h,{columns:u,rows:m}=this.calculateGridDimensions(t,y,p,l,a),w=a.stagger==="row",v=a.stagger==="column",R=w?u+.5:u,F=v?m+.5:m,x=(y-a.gap*(u-1))/R,$=(p-a.gap*(m-1))/F,k=w?x/2:0,j=v?$/2:0,U=1+a.overlap,G=Math.min(x,$)*U,W=i.fixedHeight?Math.min(i.fixedHeight,G):G,C=u*x+(u-1)*a.gap+k,I=m*$+(m-1)*a.gap+j,A=h+(y-C)/2,D=h+(p-I)/2,S=u*m,T=a.columns!=="auto"&&a.rows!=="auto",z=T&&t>S;console.log("[GridGen] generate called, imageCount:",t,"gridConfig:",JSON.stringify({columns:a.columns,rows:a.rows})),console.log("[GridGen] cellCount:",S,"hasFixedGrid:",T,"isOverflowMode:",z),typeof window<"u"&&(window.__gridOverflowDebug={gridConfigColumns:a.columns,gridConfigRows:a.rows,columns:u,rows:m,cellCount:S,hasFixedGrid:T,imageCount:t,isOverflowMode:z});const P=z?new Array(S).fill(0):[],Q=Math.min(x,$)*a.overflowOffset;for(let L=0;L<t;L++){let H,O,X=0;if(z&&L>=S){const Z=L-S,B=Z%S;X=Math.floor(Z/S)+1,P[B]++,a.fillDirection==="row"?(H=B%u,O=Math.floor(B/u)):(O=B%m,H=Math.floor(B/m))}else a.fillDirection==="row"?(H=L%u,O=Math.floor(L/u)):(O=L%m,H=Math.floor(L/m));let tt=A+H*(x+a.gap)+x/2,_=D+O*($+a.gap)+$/2;if(a.stagger==="row"&&O%2===1?tt+=x/2:a.stagger==="column"&&H%2===1&&(_+=$/2),X>0){const Z=(X-1)%Gt.length,B=Gt[Z];tt+=B.x*Q,_+=B.y*Q}if(a.jitter>0){const Z=x/2*a.jitter,B=$/2*a.jitter;tt+=this.random(-Z,Z),_+=this.random(-B,B)}let et=tt,rt=_;if(!z&&a.fillDirection==="row"){const Z=t%u||u;if(O===Math.floor((t-1)/u)&&Z<u){const Qt=Z*x+(Z-1)*a.gap;let Ft=0;a.alignment==="center"?Ft=(C-Qt)/2:a.alignment==="end"&&(Ft=C-Qt),et+=Ft}}const It=f?this.random(r,d):1,ct=W*It,ft=ct*1.5/2,pt=ct/2,Rt=h+ft,At=s-h-ft,Ae=h+pt,Te=c-h-pt;et=Math.max(Rt,Math.min(et,At)),rt=Math.max(Ae,Math.min(rt,Te));let Tt=0;if(g==="random"){const Z=((Y=(V=this.imageConfig.rotation)==null?void 0:V.range)==null?void 0:Y.min)??-15,B=((J=(ot=this.imageConfig.rotation)==null?void 0:ot.range)==null?void 0:J.max)??15;a.jitter>0?Tt=this.random(Z*a.jitter,B*a.jitter):Tt=this.random(Z,B)}let zt;z&&X>0?zt=50-X:zt=z?100+L:L+1,o.push({id:L,x:et,y:rt,rotation:Tt,scale:It,baseSize:ct,zIndex:zt})}return o}calculateGridDimensions(t,e,i,o,s){let c,a;if(s.columns!=="auto"&&s.rows!=="auto")c=s.columns,a=s.rows;else if(s.columns!=="auto")c=s.columns,a=Math.ceil(t/c);else if(s.rows!=="auto")a=s.rows,c=Math.ceil(t/a);else{const h=e/i;for(c=Math.max(1,Math.round(Math.sqrt(t*h/1.4))),a=Math.ceil(t/c);c>1&&(c-1)*a>=t;)c--}return{columns:Math.max(1,c),rows:Math.max(1,a)}}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 _t{constructor(t,e={}){this.config=t,this.imageConfig=e}generate(t,e,i={}){var F,x,$,k,j,U,G,W,C,I;const o=[],{width:s,height:c}=e,a={...we,...this.config.spiral},h=this.config.spacing.padding,l=i.fixedHeight??this.config.sizing.base,g=((F=this.imageConfig.rotation)==null?void 0:F.mode)??"none",r=(($=(x=this.imageConfig.rotation)==null?void 0:x.range)==null?void 0:$.min)??-15,d=((j=(k=this.imageConfig.rotation)==null?void 0:k.range)==null?void 0:j.max)??15,f=((G=(U=this.imageConfig.sizing)==null?void 0:U.variance)==null?void 0:G.min)??1,y=((C=(W=this.imageConfig.sizing)==null?void 0:W.variance)==null?void 0:C.max)??1,p=f!==1||y!==1,u=((I=this.imageConfig.sizing)==null?void 0:I.scaleDecay)??a.scaleDecay,m=s/2,w=c/2,v=Math.min(m-h-l/2,w-h-l/2),R=a.direction==="clockwise"?-1:1;for(let A=0;A<t;A++){let D,S;if(a.spiralType==="golden")D=A*ve*R+a.startAngle,S=this.calculateGoldenRadius(A,t,v,a.tightness);else if(a.spiralType==="archimedean"){const _=A*.5*a.tightness;D=_*R+a.startAngle,S=this.calculateArchimedeanRadius(_,t,v,a.tightness)}else{const _=A*.3*a.tightness;D=_*R+a.startAngle,S=this.calculateLogarithmicRadius(_,t,v,a.tightness)}const T=m+Math.cos(D)*S,z=w+Math.sin(D)*S,P=S/v,Q=u>0?1-P*u*.5:1,it=p?this.random(f,y):1,N=Q*it,q=l*N,K=q*1.5/2,V=q/2,Y=h+K,ot=s-h-K,J=h+V,L=c-h-V,H=Math.max(Y,Math.min(T,ot)),O=Math.max(J,Math.min(z,L));let X=0;if(g==="random"){const _=D*180/Math.PI%360,et=this.random(r,d);X=a.spiralType==="golden"?et:_*.1+et*.9}else g==="tangent"&&(X=this.calculateSpiralTangent(D,S,a));const tt=t-A;o.push({id:A,x:H,y:O,rotation:X,scale:N,baseSize:q,zIndex:tt})}return o}calculateSpiralTangent(t,e,i){let o;if(i.spiralType==="golden")o=t+Math.PI/2;else if(i.spiralType==="archimedean"){const c=1/i.tightness,a=Math.atan(e/c);o=t+a}else{const c=.15/i.tightness,a=Math.atan(1/c);o=t+a}return o*180/Math.PI%360-90}calculateGoldenRadius(t,e,i,o){const c=i/Math.sqrt(e)*Math.sqrt(t)/o;return Math.min(c,i)}calculateArchimedeanRadius(t,e,i,o){const s=e*.5*o;return t/s*i}calculateLogarithmicRadius(t,e,i,o){const s=i*.05,c=.15/o,a=s*Math.exp(c*t),h=e*.3*o,l=s*Math.exp(c*h);return a/l*i}random(t,e){return Math.random()*(e-t)+t}}const xe={clusterCount:"auto",clusterSpread:150,clusterSpacing:200,density:"uniform",overlap:.3,distribution:"gaussian"};class jt{constructor(t,e={}){this.config=t,this.imageConfig=e}generate(t,e,i={}){var R,F,x,$,k,j,U,G,W;const o=[],{width:s,height:c}=e,a={...xe,...this.config.cluster},h=this.config.spacing.padding,l=i.fixedHeight??this.config.sizing.base,g=((R=this.imageConfig.rotation)==null?void 0:R.mode)??"none",r=((x=(F=this.imageConfig.rotation)==null?void 0:F.range)==null?void 0:x.min)??-15,d=((k=($=this.imageConfig.rotation)==null?void 0:$.range)==null?void 0:k.max)??15,f=((U=(j=this.imageConfig.sizing)==null?void 0:j.variance)==null?void 0:U.min)??1,y=((W=(G=this.imageConfig.sizing)==null?void 0:G.variance)==null?void 0:W.max)??1,p=f!==1||y!==1,u=this.calculateClusterCount(t,a.clusterCount,s,c,a.clusterSpacing),m=this.generateClusterCenters(u,s,c,h,a),w=new Array(u).fill(0);for(let C=0;C<t;C++)w[C%u]++;let v=0;for(let C=0;C<u;C++){const I=m[C],A=w[C];for(let D=0;D<A;D++){let S,T;if(a.distribution==="gaussian")S=this.gaussianRandom()*I.spread,T=this.gaussianRandom()*I.spread;else{const O=this.random(0,Math.PI*2),X=this.random(0,I.spread);S=Math.cos(O)*X,T=Math.sin(O)*X}const z=1+a.overlap*.5,P=1+a.overlap*.3;S/=z,T/=z;const Q=p?this.random(f,y):1,it=P*Q,N=l*it;let q=I.x+S,nt=I.y+T;const V=N*1.5/2,Y=N/2;q=Math.max(h+V,Math.min(q,s-h-V)),nt=Math.max(h+Y,Math.min(nt,c-h-Y));const ot=g==="random"?this.random(r,d):0,L=Math.sqrt(S*S+T*T)/I.spread,H=Math.round((1-L)*50)+1;o.push({id:v,x:q,y:nt,rotation:ot,scale:it,baseSize:N,zIndex:H}),v++}}return o}calculateClusterCount(t,e,i,o,s){if(e!=="auto")return Math.max(1,Math.min(e,t));const a=Math.max(1,Math.ceil(t/8)),h=Math.floor(i/s*(o/s)*.6);return Math.max(1,Math.min(a,h,10))}generateClusterCenters(t,e,i,o,s){const c=[],h=o+s.clusterSpread,l=e-o-s.clusterSpread,g=o+s.clusterSpread,r=i-o-s.clusterSpread;for(let d=0;d<t;d++){let f=null,y=-1;for(let p=0;p<100;p++){const u={x:this.random(h,l),y:this.random(g,r),spread:this.calculateClusterSpread(s)};let m=1/0;for(const w of c){const v=u.x-w.x,R=u.y-w.y,F=Math.sqrt(v*v+R*R);m=Math.min(m,F)}if((c.length===0||m>y)&&(f=u,y=m),m>=s.clusterSpacing)break}f&&c.push(f)}return c}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 Se{constructor(t,e={}){this.config=t,this.imageConfig=e}generate(t,e,i={}){var z,P,Q,it,N,q,nt,K,V;const o=[],{width:s,height:c}=e,a=this.config.sizing.base,h=this.config.spacing.padding??50,l=((z=this.imageConfig.rotation)==null?void 0:z.mode)??"none",g=((Q=(P=this.imageConfig.rotation)==null?void 0:P.range)==null?void 0:Q.min)??-15,r=((N=(it=this.imageConfig.rotation)==null?void 0:it.range)==null?void 0:N.max)??15,d=((nt=(q=this.imageConfig.sizing)==null?void 0:q.variance)==null?void 0:nt.min)??1,f=((V=(K=this.imageConfig.sizing)==null?void 0:K.variance)==null?void 0:V.max)??1,y=d!==1||f!==1,p=i.fixedHeight??a,u={...Kt,...this.config.wave},{rows:m,amplitude:w,frequency:v,phaseShift:R,synchronization:F}=u,x=Math.ceil(t/m),j=p*1.5/2,U=h+j,G=s-h-j,W=G-U,C=x>1?W/(x-1):0,I=h+w+p/2,A=c-h-w-p/2,D=A-I,S=m>1?D/(m-1):0;let T=0;for(let Y=0;Y<m&&T<t;Y++){const ot=m===1?(I+A)/2:I+Y*S;let J=0;F==="offset"?J=Y*R:F==="alternating"&&(J=Y*Math.PI);for(let L=0;L<x&&T<t;L++){const H=x===1?(U+G)/2:U+L*C,O=this.calculateWaveY(H,s,w,v,J),X=H,tt=ot+O,_=y?this.random(d,f):1,et=p*_;let rt=0;l==="tangent"?rt=this.calculateRotation(H,s,w,v,J):l==="random"&&(rt=this.random(g,r));const ct=et*1.5/2,Et=et/2,ft=h+ct,pt=s-h-ct,Rt=h+Et,At=c-h-Et;o.push({id:T,x:Math.max(ft,Math.min(X,pt)),y:Math.max(Rt,Math.min(tt,At)),rotation:rt,scale:_,baseSize:et,zIndex:T+1}),T++}}return o}calculateWaveY(t,e,i,o,s){const c=t/e;return i*Math.sin(o*c*2*Math.PI+s)}calculateRotation(t,e,i,o,s){const c=t/e,a=i*o*2*Math.PI*Math.cos(o*c*2*Math.PI+s)/e;return Math.atan(a)*(180/Math.PI)}random(t,e){return Math.random()*(e-t)+t}}class kt{constructor(t){this.config=t.layout,this.imageConfig=t.image,this.breakpoints=t.breakpoints??{mobile:768},this.layouts=new Map,this.generator=this.initGenerator()}initGenerator(){switch(this.config.algorithm){case"radial":return new Ut(this.config,this.imageConfig);case"grid":return new Ht(this.config,this.imageConfig);case"spiral":return new _t(this.config,this.imageConfig);case"cluster":return new jt(this.config,this.imageConfig);case"wave":return new Se(this.config,this.imageConfig);case"random":default:return new Pt(this.config,this.imageConfig)}}generateLayout(t,e,i={}){const o=this.generator.generate(t,e,i);return o.forEach(s=>{this.layouts.set(s.id,s)}),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.generator=this.initGenerator())),t.image&&Object.assign(this.imageConfig,t.image),t.breakpoints&&(this.breakpoints=t.breakpoints)}resolveBaseHeight(t){var o;const e=(o=this.imageConfig.sizing)==null?void 0:o.baseHeight;if(e===void 0)return;if(typeof e=="number")return e;const i=e;return t<=this.breakpoints.mobile?i.mobile??i.tablet??i.default:this.breakpoints.tablet&&t<=this.breakpoints.tablet?i.tablet??i.default:i.default}calculateAdaptiveSize(t,e,i,o){const s=this.config.sizing.adaptive,c=this.resolveBaseHeight(o);if(c!==void 0){let v=Math.min(c,i);return s&&(v=this.clamp(v,s.minSize,s.maxSize)),{height:v}}if(!s||!s.enabled)return{height:i};const{width:a,height:h}=t,{minSize:l,maxSize:g}=s,r=this.config.targetCoverage??.6,d=this.config.densityFactor??1,p=a*h*r/e;let m=Math.sqrt(p/1.4);m*=d,m=Math.min(m,i);let w=this.clamp(m,l,g);if(w===l&&m<l){const v=Math.max(l*.05,20);w=Math.max(v,m)}return{height:w}}clamp(t,e,i){return Math.max(e,Math.min(i,t))}}var E=(n=>(n.IDLE="idle",n.FOCUSING="focusing",n.FOCUSED="focused",n.UNFOCUSING="unfocusing",n.CROSS_ANIMATING="cross_animating",n))(E||{});function Ie(n){return n in st}function Ee(n){return n?Ie(n)?st[n]:n:st.md}function Re(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 ht(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 mt(n){var s,c;if(!n)return{};const t={};if(n.borderRadiusTopLeft!==void 0||n.borderRadiusTopRight!==void 0||n.borderRadiusBottomRight!==void 0||n.borderRadiusBottomLeft!==void 0){const a=((s=n.border)==null?void 0:s.radius)??0;n.borderRadiusTopLeft!==void 0?t.borderTopLeftRadius=`${n.borderRadiusTopLeft}px`:a&&(t.borderTopLeftRadius=`${a}px`),n.borderRadiusTopRight!==void 0?t.borderTopRightRadius=`${n.borderRadiusTopRight}px`:a&&(t.borderTopRightRadius=`${a}px`),n.borderRadiusBottomRight!==void 0?t.borderBottomRightRadius=`${n.borderRadiusBottomRight}px`:a&&(t.borderBottomRightRadius=`${a}px`),n.borderRadiusBottomLeft!==void 0?t.borderBottomLeftRadius=`${n.borderRadiusBottomLeft}px`:a&&(t.borderBottomLeftRadius=`${a}px`)}else((c=n.border)==null?void 0:c.radius)!==void 0&&(t.borderRadius=`${n.border.radius}px`);if(n.borderTop||n.borderRight||n.borderBottom||n.borderLeft){const a=n.border||{},h={...a,...n.borderTop},l={...a,...n.borderRight},g={...a,...n.borderBottom},r={...a,...n.borderLeft};t.borderTop=ht(h),t.borderRight=ht(l),t.borderBottom=ht(g),t.borderLeft=ht(r)}else n.border&&(t.border=ht(n.border));n.shadow!==void 0&&(t.boxShadow=Ee(n.shadow));const o=Re(n.filter);if(o&&(t.filter=o),n.opacity!==void 0&&(t.opacity=String(n.opacity)),n.cursor!==void 0&&(t.cursor=n.cursor),n.outline&&n.outline.style!=="none"&&(n.outline.width??0)>0){const a=n.outline.width??0,h=n.outline.style??"solid",l=n.outline.color??"#000000";t.outline=`${a}px ${h} ${l}`,n.outline.offset!==void 0&&(t.outlineOffset=`${n.outline.offset}px`)}return n.objectFit!==void 0&&(t.objectFit=n.objectFit),n.aspectRatio!==void 0&&(t.aspectRatio=n.aspectRatio),t}function dt(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)}function Wt(n){return n?Array.isArray(n)?n.join(" "):n:""}function gt(n,t){const e=Wt(t);e&&e.split(" ").forEach(i=>{i.trim()&&n.classList.add(i.trim())})}function Nt(n,t){const e=Wt(t);e&&e.split(" ").forEach(i=>{i.trim()&&n.classList.remove(i.trim())})}const qt={UNFOCUSING:999,FOCUSING:1e3};class Yt{constructor(t,e,i){var o,s;this.state=E.IDLE,this.currentFocus=null,this.focusData=null,this.outgoing=null,this.incoming=null,this.focusGeneration=0,this.config=t,this.animationEngine=e,this.defaultStyles=mt(i==null?void 0:i.default),this.focusedStyles=mt(i==null?void 0:i.focused),this.defaultClassName=(o=i==null?void 0:i.default)==null?void 0:o.className,this.focusedClassName=(s=i==null?void 0:i.focused)==null?void 0:s.className}getState(){return this.state}isAnimating(){return this.state!==E.IDLE&&this.state!==E.FOCUSED}normalizeScalePercent(t){return t>1?t/100:t}calculateFocusDimensions(t,e,i){const o=this.normalizeScalePercent(this.config.scalePercent),s=i.height*o,c=t/e;let a=s,h=a*c;const l=i.width*o;return h>l&&(h=l,a=h/c),{width:h,height:a}}calculateFocusTransform(t,e){const i=t.width/2,o=t.height/2,s=i-e.x,c=o-e.y;return{x:s,y:c,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,s,c,a,h){const l=this.buildDimensionZoomTransform(e),g=this.buildDimensionZoomTransform(i);return t.style.transition="none",t.animate([{transform:l,width:`${o}px`,height:`${s}px`},{transform:g,width:`${c}px`,height:`${a}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"),dt(t,this.focusedStyles),gt(t,this.focusedClassName)}removeFocusedStyling(t,e){t.style.zIndex=e,t.classList.remove("fbn-ic-focused"),Nt(t,this.focusedClassName),dt(t,this.defaultStyles),gt(t,this.defaultClassName)}startFocusAnimation(t,e,i,o,s){const c=t.style.zIndex||"",a=t.offsetWidth,h=t.offsetHeight,l=this.calculateFocusDimensions(a,h,e),g=this.calculateFocusTransform(e,i);this.applyFocusedStyling(t,qt.FOCUSING),this.animationEngine.cancelAllAnimations(t);const r=o??{x:0,y:0,rotation:i.rotation,scale:1},d=(s==null?void 0:s.width)??a,f=(s==null?void 0:s.height)??h,y=this.config.animationDuration??600,p=this.animateWithDimensions(t,r,g,d,f,l.width,l.height,y),u={id:`focus-${Date.now()}`,element:t,animation:p,fromState:r,toState:g,startTime:performance.now(),duration:y};return this.focusData={element:t,originalState:i,focusTransform:g,originalZIndex:c,originalWidth:a,originalHeight:h,focusWidth:l.width,focusHeight:l.height},{element:t,originalState:i,animationHandle:u,direction:"in",originalWidth:a,originalHeight:h}}startUnfocusAnimation(t,e,i,o){var y,p,u,m,w;t.style.zIndex=String(qt.UNFOCUSING),this.animationEngine.cancelAllAnimations(t);const s=i??((y=this.focusData)==null?void 0:y.focusTransform)??{x:0,y:0,rotation:0,scale:1},c=(o==null?void 0:o.width)??((p=this.focusData)==null?void 0:p.focusWidth)??t.offsetWidth,a=(o==null?void 0:o.height)??((u=this.focusData)==null?void 0:u.focusHeight)??t.offsetHeight,h={x:0,y:0,rotation:e.rotation,scale:1},l=((m=this.focusData)==null?void 0:m.originalWidth)??t.offsetWidth,g=((w=this.focusData)==null?void 0:w.originalHeight)??t.offsetHeight,r=this.config.animationDuration??600,d=this.animateWithDimensions(t,s,h,c,a,l,g,r),f={id:`unfocus-${Date.now()}`,element:t,animation:d,fromState:s,toState:h,startTime:performance.now(),duration:r};return{element:t,originalState:e,animationHandle:f,direction:"out",originalWidth:l,originalHeight:g}}async waitForAnimation(t){try{await t.animation.finished}catch{}}resetElementInstantly(t,e,i,o,s){this.animationEngine.cancelAllAnimations(t);const c=["translate(-50%, -50%)"];c.push("translate(0px, 0px)"),c.push(`rotate(${e.rotation}deg)`),t.style.transition="none",t.style.transform=c.join(" "),o!==void 0&&s!==void 0&&(t.style.width=`${o}px`,t.style.height=`${s}px`),this.removeFocusedStyling(t,i)}async focusImage(t,e,i){var s,c,a,h,l,g,r,d,f,y,p,u;if(this.currentFocus===t&&this.state===E.FOCUSED)return this.unfocusImage();if(((s=this.incoming)==null?void 0:s.element)===t&&this.state===E.FOCUSING){const m=this.animationEngine.cancelAnimation(this.incoming.animationHandle,!0),w={x:m.x,y:m.y,rotation:m.rotation,scale:1},v={width:t.offsetWidth,height:t.offsetHeight};this.outgoing=this.startUnfocusAnimation(t,this.incoming.originalState,w,v),this.incoming=null,this.state=E.UNFOCUSING,await this.waitForAnimation(this.outgoing.animationHandle),this.removeFocusedStyling(this.outgoing.element,((c=this.focusData)==null?void 0:c.originalZIndex)||""),this.outgoing=null,this.currentFocus=null,this.focusData=null,this.state=E.IDLE;return}const o=++this.focusGeneration;switch(this.state){case E.IDLE:if(this.state=E.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=E.FOCUSED;break;case E.FOCUSED:if(this.state=E.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,((a=this.outgoing.originalState.zIndex)==null?void 0:a.toString())||""),this.outgoing=null),this.currentFocus=t,this.incoming=null,this.state=E.FOCUSED;break;case E.FOCUSING:if(this.incoming&&(this.animationEngine.cancelAnimation(this.incoming.animationHandle,!1),this.resetElementInstantly(this.incoming.element,this.incoming.originalState,((h=this.focusData)==null?void 0:h.originalZIndex)||"",(l=this.focusData)==null?void 0:l.originalWidth,(g=this.focusData)==null?void 0:g.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=E.FOCUSED;break;case E.UNFOCUSING:if(this.state=E.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,((r=this.outgoing.originalState.zIndex)==null?void 0:r.toString())||""),this.outgoing=null),this.currentFocus=t,this.incoming=null,this.state=E.FOCUSED;break;case E.CROSS_ANIMATING:if(((d=this.incoming)==null?void 0:d.element)===t)return;if(((f=this.outgoing)==null?void 0:f.element)===t){const m=this.animationEngine.cancelAnimation(this.outgoing.animationHandle,!0),w={x:m.x,y:m.y,rotation:m.rotation,scale:1},v={width:t.offsetWidth,height:t.offsetHeight};if(this.incoming){const R=this.animationEngine.cancelAnimation(this.incoming.animationHandle,!0),F={x:R.x,y:R.y,rotation:R.rotation,scale:1},x={width:this.incoming.element.offsetWidth,height:this.incoming.element.offsetHeight};this.outgoing=this.startUnfocusAnimation(this.incoming.element,this.incoming.originalState,F,x)}else this.outgoing=null;if(this.incoming=this.startFocusAnimation(t,e,i,w,v),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,((y=this.outgoing.originalState.zIndex)==null?void 0:y.toString())||""),this.outgoing=null),this.currentFocus=t,this.incoming=null,this.state=E.FOCUSED;return}if(this.outgoing&&(this.animationEngine.cancelAnimation(this.outgoing.animationHandle,!1),this.resetElementInstantly(this.outgoing.element,this.outgoing.originalState,((p=this.outgoing.originalState.zIndex)==null?void 0:p.toString())||"",this.outgoing.originalWidth,this.outgoing.originalHeight),this.outgoing=null),this.incoming){const m=this.animationEngine.cancelAnimation(this.incoming.animationHandle,!0),w={x:m.x,y:m.y,rotation:m.rotation,scale:1},v={width:this.incoming.element.offsetWidth,height:this.incoming.element.offsetHeight};this.outgoing=this.startUnfocusAnimation(this.incoming.element,this.incoming.originalState,w,v)}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,((u=this.outgoing.originalState.zIndex)==null?void 0:u.toString())||""),this.outgoing=null),this.currentFocus=t,this.incoming=null,this.state=E.FOCUSED;break}}async unfocusImage(){var s,c,a;const t=++this.focusGeneration;if(!this.currentFocus||!this.focusData){if(this.incoming&&this.state===E.FOCUSING){const h=this.animationEngine.cancelAnimation(this.incoming.animationHandle,!0),l={x:h.x,y:h.y,rotation:h.rotation,scale:1},g={width:this.incoming.element.offsetWidth,height:this.incoming.element.offsetHeight};if(this.outgoing=this.startUnfocusAnimation(this.incoming.element,this.incoming.originalState,l,g),this.incoming=null,this.state=E.UNFOCUSING,await this.waitForAnimation(this.outgoing.animationHandle),this.focusGeneration!==t)return;this.removeFocusedStyling(this.outgoing.element,((s=this.focusData)==null?void 0:s.originalZIndex)||""),this.outgoing=null,this.focusData=null,this.state=E.IDLE}return}if(this.state===E.CROSS_ANIMATING&&this.incoming){const h=this.animationEngine.cancelAnimation(this.incoming.animationHandle,!0),l={x:h.x,y:h.y,rotation:h.rotation,scale:1},g={width:this.incoming.element.offsetWidth,height:this.incoming.element.offsetHeight},r=this.startUnfocusAnimation(this.incoming.element,this.incoming.originalState,l,g);if(await Promise.all([this.outgoing?this.waitForAnimation(this.outgoing.animationHandle):Promise.resolve(),this.waitForAnimation(r.animationHandle)]),this.focusGeneration!==t)return;this.outgoing&&this.removeFocusedStyling(this.outgoing.element,((c=this.outgoing.originalState.zIndex)==null?void 0:c.toString())||""),this.removeFocusedStyling(r.element,((a=this.incoming.originalState.zIndex)==null?void 0:a.toString())||""),this.outgoing=null,this.incoming=null,this.currentFocus=null,this.focusData=null,this.state=E.IDLE;return}this.state=E.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=E.IDLE)}async swapFocus(t,e,i){return this.focusImage(t,e,i)}getCurrentFocus(){return this.currentFocus}isFocused(t){return this.currentFocus===t&&this.state===E.FOCUSED}isTargetingFocus(t){var e;return((e=this.incoming)==null?void 0:e.element)===t}isInvolved(t){var e,i;return this.currentFocus===t||((e=this.incoming)==null?void 0:e.element)===t||((i=this.outgoing)==null?void 0:i.element)===t}reset(){var t,e,i,o;this.outgoing&&(this.animationEngine.cancelAnimation(this.outgoing.animationHandle,!1),this.resetElementInstantly(this.outgoing.element,this.outgoing.originalState,((t=this.outgoing.originalState.zIndex)==null?void 0:t.toString())||"",this.outgoing.originalWidth,this.outgoing.originalHeight)),this.incoming&&(this.animationEngine.cancelAnimation(this.incoming.animationHandle,!1),this.resetElementInstantly(this.incoming.element,this.incoming.originalState,((e=this.focusData)==null?void 0:e.originalZIndex)||"",(i=this.focusData)==null?void 0:i.originalWidth,(o=this.focusData)==null?void 0:o.originalHeight)),this.currentFocus&&this.focusData&&this.resetElementInstantly(this.currentFocus,this.focusData.originalState,this.focusData.originalZIndex,this.focusData.originalWidth,this.focusData.originalHeight),this.state=E.IDLE,this.currentFocus=null,this.focusData=null,this.outgoing=null,this.incoming=null}}class Xt{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(e.type==="folder")for(const i of e.folders){const o=e.recursive!==void 0?e.recursive:!0,s=await this.loadFromFolder(i,t,o);this._discoveredUrls.push(...s)}else if(e.type==="files"){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(s){return console.error("Error loading from Google Drive API:",s),this.loadImagesDirectly(o,e)}}async loadImagesFromSingleFolder(t,e){const i=[],o=`'${t}' in parents and trashed=false`,c=`${this.apiEndpoint}?q=${encodeURIComponent(o)}&fields=files(id,name,mimeType,thumbnailLink)&key=${this.apiKey}`,a=await fetch(c);if(!a.ok)throw new Error(`API request failed: ${a.status} ${a.statusText}`);const l=(await a.json()).files.filter(g=>g.mimeType.startsWith("image/")&&e.isAllowed(g.name));return this.log(`Found ${l.length} images in folder ${t} (non-recursive)`),l.forEach(g=>{i.push(`https://lh3.googleusercontent.com/d/${g.id}=s1600`),this.log(`Added file: ${g.name}`)}),i}async loadFiles(t,e){const i=[];for(const o of t){const s=this.extractFileId(o);if(!s){this.log(`Skipping invalid file URL: ${o}`);continue}if(this.apiKey&&this.apiKey!=="YOUR_API_KEY_HERE")try{const c=`${this.apiEndpoint}/${s}?fields=name,mimeType&key=${this.apiKey}`,a=await fetch(c);if(a.ok){const h=await a.json();h.mimeType.startsWith("image/")&&e.isAllowed(h.name)?(i.push(`https://lh3.googleusercontent.com/d/${s}=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 ${s}: ${a.status}`)}catch(c){this.log(`Error fetching metadata for file ${s}:`,c)}else i.push(`https://lh3.googleusercontent.com/d/${s}=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`,c=`${this.apiEndpoint}?q=${encodeURIComponent(o)}&fields=files(id,name,mimeType,thumbnailLink)&key=${this.apiKey}`,a=await fetch(c);if(!a.ok)throw new Error(`API request failed: ${a.status} ${a.statusText}`);const h=await a.json(),l=h.files.filter(r=>r.mimeType.startsWith("image/")&&e.isAllowed(r.name)),g=h.files.filter(r=>r.mimeType==="application/vnd.google-apps.folder");this.log(`Found ${h.files.length} total items in folder ${t}`),h.files.forEach(r=>this.log(` - File: ${r.name} (${r.mimeType})`)),this.log(`- ${l.length} valid files (images only)`),this.log(`- ${g.length} subfolders`),l.forEach(r=>{i.push(`https://lh3.googleusercontent.com/d/${r.id}=s1600`),this.log(`Added file: ${r.name}`)});for(const r of g){this.log(`Loading images from subfolder: ${r.name}`);const d=await this.loadImagesRecursively(r.id,e);i.push(...d)}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 s=await o.text(),c=/\/file\/d\/([a-zA-Z0-9_-]+)/g,a=[...s.matchAll(c)];return[...new Set(a.map(g=>g[1]))].map(g=>`https://drive.google.com/uc?export=view&id=${g}`)}catch(i){throw console.error("Direct loading failed:",i),new Error(`Unable to load images. Please ensure:
1
+ (function(A,st){typeof exports=="object"&&typeof module<"u"?st(exports):typeof define=="function"&&define.amd?define(["exports"],st):(A=typeof globalThis<"u"?globalThis:A||self,st(A.ImageCloud={}))})(this,function(A){"use strict";const st=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)"}),yt=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})}),bt=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})}),vt=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})}),wt=Object.freeze({type:"linear"}),xt=Object.freeze({mode:"none"}),St=Object.freeze({mode:"none"}),zt=Object.freeze({default:Object.freeze({border:Object.freeze({width:0,color:"#000000",radius:0,style:"solid"}),shadow:"none",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"})}),ee=Object.freeze({rows:1,amplitude:100,frequency:2,phaseShift:0,synchronization:"offset"}),ie=Object.freeze({mobile:Object.freeze({maxWidth:767}),tablet:Object.freeze({maxWidth:1199})}),ne=Object.freeze({mode:"adaptive",minSize:50,maxSize:400,variance:Object.freeze({min:1,max:1})}),oe=Object.freeze({mode:"none",range:Object.freeze({min:-15,max:15})}),Ct=Object.freeze({sizing:ne,rotation:oe}),b=Object.freeze({loader:Object.freeze({type:"googleDrive",googleDrive:Object.freeze({apiKey:"",sources:[],apiEndpoint:"https://www.googleapis.com/drive/v3/files",allowedExtensions:["jpg","jpeg","png","gif","webp","bmp"],debugLogging:!1}),static:Object.freeze({sources:[],validateUrls:!0,validationTimeout:5e3,validationMethod:"head",failOnAllMissing:!0,allowedExtensions:["jpg","jpeg","png","gif","webp","bmp"],debugLogging:!1})}),image:Ct,layout:Object.freeze({algorithm:"radial",scaleDecay:0,responsive:ie,targetCoverage:.6,densityFactor:1,spacing:Object.freeze({padding:50,minGap:20}),debugRadials:!1,debugCenters:!1}),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,stagger:150}),easing:"cubic-bezier(0.25, 1, 0.5, 1)",path:wt,rotation:xt,scale:St})}),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:void 0,showThumbnails:void 0,theme:void 0}),performance:Object.freeze({lazyLoad:void 0,preloadCount:void 0,imageQuality:void 0})}),styling:zt,debug:!1});function lt(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.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 se(n,t){if(!t)return{...n};const e=lt(n.default,t.default),i=lt(lt(e,n.hover),t.hover),o=lt(lt(e,n.focused),t.focused);return{default:e,hover:i,focused:o}}function ae(n,t){var i,o,s,c,a,h,l,u;if(!t)return{...n};const e={...n};if(t.sizing!==void 0&&(e.sizing={...n.sizing,...t.sizing},t.sizing.variance)){const r=t.sizing.variance,d=r.min!==void 0&&r.min>=.25&&r.min<=1?r.min:((o=(i=n.sizing)==null?void 0:i.variance)==null?void 0:o.min)??1,f=r.max!==void 0&&r.max>=1&&r.max<=1.75?r.max:((c=(s=n.sizing)==null?void 0:s.variance)==null?void 0:c.max)??1;e.sizing.variance={min:d,max:f}}if(t.rotation!==void 0&&(e.rotation={...n.rotation,...t.rotation},t.rotation.range)){const r=t.rotation.range,d=r.min!==void 0&&r.min>=-180&&r.min<=0?r.min:((h=(a=n.rotation)==null?void 0:a.range)==null?void 0:h.min)??-15,f=r.max!==void 0&&r.max>=0&&r.max<=180?r.max:((u=(l=n.rotation)==null?void 0:l.range)==null?void 0:u.max)??15;e.rotation.range={min:d,max:f}}return e}function re(n){var e;const t=(e=n.layout)==null?void 0:e.rotation;if(t&&"enabled"in t)return{rotation:{mode:t.enabled?"random":"none",range:t.range}}}function ce(n){var e,i;const t=(i=(e=n.layout)==null?void 0:e.sizing)==null?void 0:i.variance;if(t)return{sizing:{mode:"adaptive",variance:t}}}function le(n={}){var s;const t=re(n),e=ce(n);let i=n.image;(t||e)&&(i={...e||{},...t||{},...i},i.rotation&&(t!=null&&t.rotation)&&((s=n.image)!=null&&s.rotation)&&(i.rotation={...t.rotation,...n.image.rotation}));const o={loader:{...b.loader},image:ae(Ct,i),layout:{...b.layout},animation:{...b.animation},interaction:{...b.interaction},rendering:{...b.rendering},styling:se(zt,n.styling),debug:b.debug};return n.loader&&(o.loader={...b.loader,...n.loader},n.loader.googleDrive&&(o.loader.googleDrive={...b.loader.googleDrive,...n.loader.googleDrive,sources:n.loader.googleDrive.sources||b.loader.googleDrive.sources,allowedExtensions:n.loader.googleDrive.allowedExtensions||b.loader.googleDrive.allowedExtensions}),n.loader.static&&(o.loader.static={...b.loader.static,...n.loader.static,sources:n.loader.static.sources||b.loader.static.sources,allowedExtensions:n.loader.static.allowedExtensions||b.loader.static.allowedExtensions})),n.layout&&(o.layout={...b.layout,...n.layout},n.layout.responsive&&(o.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&&(o.layout.spacing={...b.layout.spacing,...n.layout.spacing})),n.animation&&(o.animation={...b.animation,...n.animation},n.animation.easing&&(o.animation.easing={...b.animation.easing,...n.animation.easing}),n.animation.queue&&(o.animation.queue={...b.animation.queue,...n.animation.queue}),n.animation.performance&&(o.animation.performance={...b.animation.performance,...n.animation.performance}),n.animation.entry&&(o.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?{...wt,...n.animation.entry.path}:b.animation.entry.path,rotation:n.animation.entry.rotation?{...xt,...n.animation.entry.rotation}:b.animation.entry.rotation,scale:n.animation.entry.scale?{...St,...n.animation.entry.scale}:b.animation.entry.scale})),n.interaction&&(o.interaction={...b.interaction,...n.interaction},n.interaction.focus&&(o.interaction.focus={...b.interaction.focus,...n.interaction.focus}),n.interaction.navigation&&(o.interaction.navigation={...b.interaction.navigation,...n.interaction.navigation}),n.interaction.gestures&&(o.interaction.gestures={...b.interaction.gestures,...n.interaction.gestures})),n.rendering&&(o.rendering={...b.rendering,...n.rendering},n.rendering.responsive&&(o.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&&(o.rendering.ui={...b.rendering.ui,...n.rendering.ui}),n.rendering.performance&&(o.rendering.performance={...b.rendering.performance,...n.rendering.performance})),n.debug!==void 0&&(o.debug=n.debug),o}function he(n,t){return{...n?yt[n]:yt.playful,...t}}function de(n,t){return{...n?bt[n]:bt.gentle,...t}}function ue(n,t){return{...n?vt[n]:vt.gentle,...t}}class Lt{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,s=null){this.cancelAllAnimations(t);const c=o??this.config.duration,a=s??this.config.easing.default,h=this.buildTransformString(e),l=this.buildTransformString(i);t.style.transition="none";const u=t.animate([{transform:h},{transform:l}],{duration:c,easing:a,fill:"forwards"}),r={id:`anim-${++this.animationIdCounter}`,element:t,animation:u,fromState:e,toState:i,startTime:performance.now(),duration:c};return this.activeAnimations.set(t,r),u.finished.then(()=>{t.style.transform=l,this.activeAnimations.delete(t)}).catch(()=>{this.activeAnimations.delete(t)}),r}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),s=Math.sqrt(o.a*o.a+o.b*o.b),c=Math.atan2(o.b,o.a)*(180/Math.PI),a=o.e,h=o.f;return{x:a,y:h,rotation:c,scale:s}}hasActiveAnimation(t){return this.activeAnimations.has(t)}getAnimationHandle(t){return this.activeAnimations.get(t)}animateTransform(t,e,i=null,o=null){return new Promise(s=>{const c=i??this.config.duration,a=o??this.config.easing.default;t.style.transition=`transform ${c}ms ${a}, box-shadow ${c}ms ${a}`,t.style.transform=this.buildTransformString(e),setTimeout(()=>{s()},c)})}resetTransform(t,e){return this.animateTransform(t,e)}clearTransition(t){t.style.transition=""}wait(t){return new Promise(e=>setTimeout(e,t))}}function at(n,t,e){return n+(t-n)*e}function ge(n,t,e,i){const{overshoot:o,bounces:s,decayRatio:c}=i,a=e.x-t.x,h=e.y-t.y,l=me(s,c);let u=0,r=0,d=1,f=o,y=!1;for(let g=0;g<l.length;g++)if(n<=l[g].time){r=g===0?0:l[g-1].time,d=l[g].time,f=l[g].overshoot,y=l[g].isOvershoot;break}const p=(n-r)/(d-r);if(y)u=1+f*gt(p);else if(r===0)u=gt(p);else{const g=l.find((v,w)=>v.time>r&&w>0&&l[w-1].isOvershoot),m=1+((g==null?void 0:g.overshoot)||f);u=at(m,1,gt(p))}return{x:t.x+a*u,y:t.y+h*u}}function me(n,t){const e=[];let i=.6;e.push({time:i,overshoot:0,isOvershoot:!1});let o=.15;const c=.4/(n*2);for(let a=0;a<n;a++)i+=c,e.push({time:i,overshoot:o,isOvershoot:!0}),i+=c,e.push({time:i,overshoot:o*t,isOvershoot:!1}),o*=t;return e.push({time:1,overshoot:0,isOvershoot:!1}),e}function fe(n,t,e,i){const{stiffness:o,damping:s,mass:c,oscillations:a}=i,h=e.x-t.x,l=e.y-t.y,u=Math.sqrt(o/c),r=s/(2*Math.sqrt(o*c));let d;if(r<1){const f=u*Math.sqrt(1-r*r),y=Math.exp(-r*u*n*3),p=Math.cos(f*n*a*Math.PI);d=1-y*p}else d=1-Math.exp(-u*n*3);return d=Math.max(0,Math.min(d,1.3)),{x:t.x+h*d,y:t.y+l*d}}function pe(n,t,e,i){const{amplitude:o,frequency:s,decay:c,decayRate:a,phase:h}=i,l=e.x-t.x,u=e.y-t.y,r=Math.sqrt(l*l+u*u),d=r>0?-u/r:0,f=r>0?l/r:1,y=s*Math.PI*2*n+h,p=c?Math.pow(1-n,a):1,g=o*Math.sin(y)*p,m=ye(n);return{x:at(t.x,e.x,m)+g*d,y:at(t.y,e.y,m)+g*f}}function gt(n){return 1-(1-n)*(1-n)}function ye(n){return 1-Math.pow(1-n,3)}function be(n,t,e){const{amplitude:i,frequency:o,decay:s}=e,c=Math.sin(n*o*Math.PI*2),a=s?Math.pow(1-n,2):1,h=i*c*a;return t+h}function ve(n,t,e){const{overshoot:i,bounces:o}=e,s=[];s.push({time:.5,scale:i});let c=i;const a=.5,l=.5/(o*2);let u=.5;for(let d=0;d<o;d++){const f=1-(c-1)*a;u+=l,s.push({time:u,scale:f}),c=1+(c-1)*a*a,u+=l,d<o-1&&s.push({time:u,scale:c})}s.push({time:1,scale:1});let r=1;for(let d=0;d<s.length;d++)if(n<=s[d].time){const f=d===0?0:s[d-1].time,y=d===0?1:s[d-1].scale,p=(n-f)/(s[d].time-f),g=gt(p);r=y+(s[d].scale-y)*g;break}return r*t}function $t(n){const{element:t,startPosition:e,endPosition:i,pathConfig:o,duration:s,imageWidth:c,imageHeight:a,rotation:h,scale:l,onComplete:u,rotationConfig:r,startRotation:d,scaleConfig:f,startScale:y}=n,p=o.type,g=d!==void 0&&d!==h,m=(r==null?void 0:r.mode)==="wobble",v=(r==null?void 0:r.wobble)||{amplitude:15,frequency:3,decay:!0},w=g||m,E=y!==void 0&&y!==l,T=(f==null?void 0:f.mode)==="pop",x=(f==null?void 0:f.pop)||{overshoot:1.2,bounces:1};if((p==="linear"||p==="arc")&&!w&&!(E||T)){u&&u();return}const G=performance.now(),_=-c/2,P=-a/2;function U(W){const C=W-G,S=Math.min(C/s,1);let F;switch(p){case"bounce":{const j=he(o.bouncePreset,o.bounce);F=ge(S,e,i,j);break}case"elastic":{const j=de(o.elasticPreset,o.elastic);F=fe(S,e,i,j);break}case"wave":{const j=ue(o.wavePreset,o.wave);F=pe(S,e,i,j);break}default:F={x:at(e.x,i.x,S),y:at(e.y,i.y,S)}}const O=F.x-i.x,z=F.y-i.y;let R;m?R=be(S,h,v):g?R=at(d,h,S):R=h;let M;T?M=ve(S,l,x):E?M=at(y,l,S):M=l,t.style.transform=`translate(${_}px, ${P}px) translate(${O}px, ${z}px) rotate(${R}deg) scale(${M})`,S<1?requestAnimationFrame(U):(t.style.transform=`translate(${_}px, ${P}px) rotate(${h}deg) scale(${l})`,u&&u())}requestAnimationFrame(U)}function Ot(n){return n==="bounce"||n==="elastic"||n==="wave"}const we={radial:"center",spiral:"center",grid:"top",cluster:"nearest-edge",random:"nearest-edge",wave:"left"};class Dt{constructor(t,e){this.config=t,this.layoutAlgorithm=e,this.resolvedStartPosition=this.resolveStartPosition(),this.pathConfig=t.path||wt,this.rotationConfig=t.rotation||xt,this.scaleConfig=t.scale||St}resolveStartPosition(){return this.config.start.position?this.config.start.position:we[this.layoutAlgorithm]||"nearest-edge"}calculateStartPosition(t,e,i,o,s){const c=this.resolvedStartPosition,a=this.config.start.offset??100;switch(c){case"nearest-edge":return this.calculateNearestEdge(t,e,i,a);case"top":return this.calculateEdgePosition("top",t,e,i,a);case"bottom":return this.calculateEdgePosition("bottom",t,e,i,a);case"left":return this.calculateEdgePosition("left",t,e,i,a);case"right":return this.calculateEdgePosition("right",t,e,i,a);case"center":return this.calculateCenterPosition(i,t,e);case"random-edge":return this.calculateRandomEdge(t,e,i,a);case"circular":return this.calculateCircularPosition(t,e,i,o,s);default:return this.calculateNearestEdge(t,e,i,a)}}calculateNearestEdge(t,e,i,o){const s=t.x,c=t.y,a=s,h=i.width-s,l=c,u=i.height-c,r=Math.min(a,h,l,u);let d=t.x,f=t.y;return r===a?d=-(e.width+o):r===h?d=i.width+o:r===l?f=-(e.height+o):f=i.height+o,{x:d,y:f}}calculateEdgePosition(t,e,i,o,s){let c=e.x,a=e.y;switch(t){case"top":a=-(i.height+s);break;case"bottom":a=o.height+s;break;case"left":c=-(i.width+s);break;case"right":c=o.width+s;break}return{x:c,y:a}}calculateCenterPosition(t,e,i){const o=t.width/2,s=t.height/2;return{x:o,y:s,useScale:!0}}calculateRandomEdge(t,e,i,o){const s=["top","bottom","left","right"],c=s[Math.floor(Math.random()*s.length)];return this.calculateEdgePosition(c,t,e,i,o)}calculateCircularPosition(t,e,i,o,s){const c=this.config.start.circular||{},a=c.distribution||"even";let h;const l=c.radius||"120%";if(typeof l=="string"&&l.endsWith("%")){const p=parseFloat(l)/100;h=Math.sqrt(i.width**2+i.height**2)*p/2}else h=typeof l=="number"?l:500;let u;a==="even"?u=o/s*2*Math.PI:u=Math.random()*2*Math.PI;const r=i.width/2,d=i.height/2,f=r+Math.cos(u)*h,y=d+Math.sin(u)*h;return{x:f,y}}getAnimationParams(t){const e=this.config.timing.duration,i=this.config.timing.stagger,o=this.config.easing;return{startTransform:"",duration:e,delay:t*i,easing:o}}buildStartTransform(t,e,i,o,s,c,a,h){const l=t.x-e.x,u=t.y-e.y,r=a!==void 0?a:i,d=h!==void 0?h:o,f=s!==void 0?-s/2:0,y=c!==void 0?-c/2:0,p=s!==void 0?`translate(${f}px, ${y}px)`:"translate(-50%, -50%)";return t.useScale?`${p} translate(${l}px, ${u}px) rotate(${r}deg) scale(0)`:`${p} translate(${l}px, ${u}px) rotate(${r}deg) scale(${d})`}buildFinalTransform(t,e,i,o){if(i!==void 0&&o!==void 0){const s=-i/2,c=-o/2;return`translate(${s}px, ${c}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 Ot(this.pathConfig.type)}getPathConfig(){return this.pathConfig}getPathType(){return this.pathConfig.type}getTiming(){return{duration:this.config.timing.duration,stagger:this.config.timing.stagger}}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;case"auto":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:s,decay:c}=i,a=Math.sin(t*s*Math.PI*2),h=c?Math.pow(1-t,2):1,l=o*a*h;return e+l}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:s}=i,c=this.generateScaleBounceKeyframes(s,o);let a=e;for(let h=0;h<c.length;h++)if(t<=c[h].time){const l=h===0?0:c[h-1].time,u=h===0?e:c[h-1].scale,r=(t-l)/(c[h].time-l),d=this.easeOutQuad(r);a=u+(c[h].scale-u)*d;break}return a*e}generateScaleBounceKeyframes(t,e){const i=[];i.push({time:.5,scale:e});let o=e;const s=.5,a=.5/(t*2);let h=.5;for(let l=0;l<t;l++){const u=1-(o-1)*s;h+=a,i.push({time:h,scale:u}),o=1+(o-1)*s*s,h+=a,l<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 Pt{constructor(t,e={}){this.config=t,this.imageConfig=e}generate(t,e,i={}){var x,$,G,_,P,U,W,C,S;const o=[],{width:s,height:c}=e,a=this.config.spacing.padding,h=i.fixedHeight??200,l=((x=this.imageConfig.rotation)==null?void 0:x.mode)??"none",u=((G=($=this.imageConfig.rotation)==null?void 0:$.range)==null?void 0:G.min)??-15,r=((P=(_=this.imageConfig.rotation)==null?void 0:_.range)==null?void 0:P.max)??15,d=((W=(U=this.imageConfig.sizing)==null?void 0:U.variance)==null?void 0:W.min)??1,f=((S=(C=this.imageConfig.sizing)==null?void 0:C.variance)==null?void 0:S.max)??1,y=d!==1||f!==1,g=h*1.5/2,m=h/2,v=s-a-g,w=c-a-m,E=a+g,T=a+m;for(let F=0;F<t;F++){const O=this.random(E,v),z=this.random(T,w),R=l==="random"?this.random(u,r):0,M=y?this.random(d,f):1,j=h*M,K={id:F,x:O,y:z,rotation:R,scale:M,baseSize:j};o.push(K)}return o}random(t,e){return Math.random()*(e-t)+t}}class Ut{constructor(t,e={}){this.config=t,this.imageConfig=e}generate(t,e,i={}){var $,G,_,P,U,W,C,S,F;const o=[],{width:s,height:c}=e,{debugRadials:a}=this.config,h=i.fixedHeight??200,l=(($=this.imageConfig.rotation)==null?void 0:$.mode)??"none",u=((_=(G=this.imageConfig.rotation)==null?void 0:G.range)==null?void 0:_.min)??-15,r=((U=(P=this.imageConfig.rotation)==null?void 0:P.range)==null?void 0:U.max)??15,d=((C=(W=this.imageConfig.sizing)==null?void 0:W.variance)==null?void 0:C.min)??1,f=((F=(S=this.imageConfig.sizing)==null?void 0:S.variance)==null?void 0:F.max)??1,y=d!==1||f!==1,p=this.config.scaleDecay??0,g=["green","blue","red","yellow","orange","purple"],m=i.fixedHeight??h,v=s/2,w=c/2,E=Math.ceil(Math.sqrt(t));if(t>0){const O=y?this.random(d,f):1,z=m*O;o.push({id:0,x:v,y:w,rotation:l==="random"?this.random(u*.33,r*.33):0,scale:O,baseSize:z,zIndex:100,borderColor:a?"cyan":void 0})}let T=1,x=1;for(;T<t;){const O=x/E,z=p>0?1-O*p*.5:1,R=x*(m*.8),M=R*1.5,j=Math.PI*(3*(M+R)-Math.sqrt((3*M+R)*(M+3*R))),K=this.estimateWidth(m),X=Math.floor(j/(K*.7));if(X===0){x++;continue}const V=2*Math.PI/X,Q=x*(20*Math.PI/180);for(let q=0;q<X&&T<t;q++){const tt=q*V+Q,et=y?this.random(d,f):1,Y=z*et,it=m*Y;let B=v+Math.cos(tt)*M,L=w+Math.sin(tt)*R;const D=this.config.spacing.padding??50,k=it*1.5/2,H=it/2;B-k<D?B=D+k:B+k>s-D&&(B=s-D-k),L-H<D?L=D+H:L+H>c-D&&(L=c-D-H);const nt=l==="random"?this.random(u,r):0;o.push({id:T,x:B,y:L,rotation:nt,scale:Y,baseSize:it,zIndex:Math.max(1,100-x),borderColor:a?g[(x-1)%g.length]:void 0}),T++}x++}return o}estimateWidth(t){return t*1.4}random(t,e){return Math.random()*(e-t)+t}}const xe={columns:"auto",rows:"auto",stagger:"none",jitter:0,overlap:0,fillDirection:"row",alignment:"center",gap:10,overflowOffset:.25},_t=[{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 Ht{constructor(t,e={}){this.config=t,this.imageConfig=e}generate(t,e,i={}){var X,V,Q,q,tt,et,Y,it,B;const o=[],{width:s,height:c}=e,a={...xe,...this.config.grid},h=this.config.spacing.padding,l=i.fixedHeight??200,u=((X=this.imageConfig.rotation)==null?void 0:X.mode)??"none",r=((Q=(V=this.imageConfig.sizing)==null?void 0:V.variance)==null?void 0:Q.min)??1,d=((tt=(q=this.imageConfig.sizing)==null?void 0:q.variance)==null?void 0:tt.max)??1,f=r!==1||d!==1,y=s-2*h,p=c-2*h,{columns:g,rows:m}=this.calculateGridDimensions(t,y,p,l,a),v=a.stagger==="row",w=a.stagger==="column",E=v?g+.5:g,T=w?m+.5:m,x=(y-a.gap*(g-1))/E,$=(p-a.gap*(m-1))/T,G=v?x/2:0,_=w?$/2:0,P=1+a.overlap,U=Math.min(x,$)*P,W=i.fixedHeight?Math.min(i.fixedHeight,U):U,C=g*x+(g-1)*a.gap+G,S=m*$+(m-1)*a.gap+_,F=h+(y-C)/2,O=h+(p-S)/2,z=g*m,R=a.columns!=="auto"&&a.rows!=="auto",M=R&&t>z;typeof window<"u"&&(window.__gridOverflowDebug={gridConfigColumns:a.columns,gridConfigRows:a.rows,columns:g,rows:m,cellCount:z,hasFixedGrid:R,imageCount:t,isOverflowMode:M});const j=M?new Array(z).fill(0):[],K=Math.min(x,$)*a.overflowOffset;for(let L=0;L<t;L++){let D,N,k=0;if(M&&L>=z){const Z=L-z,J=Z%z;k=Math.floor(Z/z)+1,j[J]++,a.fillDirection==="row"?(D=J%g,N=Math.floor(J/g)):(N=J%m,D=Math.floor(J/m))}else a.fillDirection==="row"?(D=L%g,N=Math.floor(L/g)):(N=L%m,D=Math.floor(L/m));let H=F+D*(x+a.gap)+x/2,nt=O+N*($+a.gap)+$/2;if(a.stagger==="row"&&N%2===1?H+=x/2:a.stagger==="column"&&D%2===1&&(nt+=$/2),k>0){const Z=(k-1)%_t.length,J=_t[Z];H+=J.x*K,nt+=J.y*K}if(a.jitter>0){const Z=x/2*a.jitter,J=$/2*a.jitter;H+=this.random(-Z,Z),nt+=this.random(-J,J)}let ot=H,rt=nt;if(!M&&a.fillDirection==="row"){const Z=t%g||g;if(N===Math.floor((t-1)/g)&&Z<g){const te=Z*x+(Z-1)*a.gap;let Mt=0;a.alignment==="center"?Mt=(C-te)/2:a.alignment==="end"&&(Mt=C-te),ot+=Mt}}const It=f?this.random(r,d):1,ct=W*It,ft=ct*1.5/2,pt=ct/2,Rt=h+ft,At=s-h-ft,Me=h+pt,ze=c-h-pt;ot=Math.max(Rt,Math.min(ot,At)),rt=Math.max(Me,Math.min(rt,ze));let Tt=0;if(u==="random"){const Z=((Y=(et=this.imageConfig.rotation)==null?void 0:et.range)==null?void 0:Y.min)??-15,J=((B=(it=this.imageConfig.rotation)==null?void 0:it.range)==null?void 0:B.max)??15;a.jitter>0?Tt=this.random(Z*a.jitter,J*a.jitter):Tt=this.random(Z,J)}let Ft;M&&k>0?Ft=50-k:Ft=M?100+L:L+1,o.push({id:L,x:ot,y:rt,rotation:Tt,scale:It,baseSize:ct,zIndex:Ft})}return o}calculateGridDimensions(t,e,i,o,s){let c,a;if(s.columns!=="auto"&&s.rows!=="auto")c=s.columns,a=s.rows;else if(s.columns!=="auto")c=s.columns,a=Math.ceil(t/c);else if(s.rows!=="auto")a=s.rows,c=Math.ceil(t/a);else{const h=e/i;for(c=Math.max(1,Math.round(Math.sqrt(t*h/1.4))),a=Math.ceil(t/c);c>1&&(c-1)*a>=t;)c--}return{columns:Math.max(1,c),rows:Math.max(1,a)}}random(t,e){return Math.random()*(e-t)+t}}const Se=Math.PI*(3-Math.sqrt(5)),Ie={spiralType:"golden",direction:"counterclockwise",tightness:1,scaleDecay:0,startAngle:0};class jt{constructor(t,e={}){this.config=t,this.imageConfig=e}generate(t,e,i={}){var T,x,$,G,_,P,U,W,C;const o=[],{width:s,height:c}=e,a={...Ie,...this.config.spiral},h=this.config.spacing.padding,l=i.fixedHeight??200,u=((T=this.imageConfig.rotation)==null?void 0:T.mode)??"none",r=(($=(x=this.imageConfig.rotation)==null?void 0:x.range)==null?void 0:$.min)??-15,d=((_=(G=this.imageConfig.rotation)==null?void 0:G.range)==null?void 0:_.max)??15,f=((U=(P=this.imageConfig.sizing)==null?void 0:P.variance)==null?void 0:U.min)??1,y=((C=(W=this.imageConfig.sizing)==null?void 0:W.variance)==null?void 0:C.max)??1,p=f!==1||y!==1,g=this.config.scaleDecay??a.scaleDecay,m=s/2,v=c/2,w=Math.min(m-h-l/2,v-h-l/2),E=a.direction==="clockwise"?-1:1;for(let S=0;S<t;S++){let F,O;if(a.spiralType==="golden")F=S*Se*E+a.startAngle,O=this.calculateGoldenRadius(S,t,w,a.tightness);else if(a.spiralType==="archimedean"){const H=S*.5*a.tightness;F=H*E+a.startAngle,O=this.calculateArchimedeanRadius(H,t,w,a.tightness)}else{const H=S*.3*a.tightness;F=H*E+a.startAngle,O=this.calculateLogarithmicRadius(H,t,w,a.tightness)}const z=m+Math.cos(F)*O,R=v+Math.sin(F)*O,M=O/w,j=g>0?1-M*g*.5:1,K=p?this.random(f,y):1,X=j*K,V=l*X,q=V*1.5/2,tt=V/2,et=h+q,Y=s-h-q,it=h+tt,B=c-h-tt,L=Math.max(et,Math.min(z,Y)),D=Math.max(it,Math.min(R,B));let N=0;if(u==="random"){const H=F*180/Math.PI%360,nt=this.random(r,d);N=a.spiralType==="golden"?nt:H*.1+nt*.9}else u==="tangent"&&(N=this.calculateSpiralTangent(F,O,a));const k=t-S;o.push({id:S,x:L,y:D,rotation:N,scale:X,baseSize:V,zIndex:k})}return o}calculateSpiralTangent(t,e,i){let o;if(i.spiralType==="golden")o=t+Math.PI/2;else if(i.spiralType==="archimedean"){const c=1/i.tightness,a=Math.atan(e/c);o=t+a}else{const c=.15/i.tightness,a=Math.atan(1/c);o=t+a}return o*180/Math.PI%360-90}calculateGoldenRadius(t,e,i,o){const c=i/Math.sqrt(e)*Math.sqrt(t)/o;return Math.min(c,i)}calculateArchimedeanRadius(t,e,i,o){const s=e*.5*o;return t/s*i}calculateLogarithmicRadius(t,e,i,o){const s=i*.05,c=.15/o,a=s*Math.exp(c*t),h=e*.3*o,l=s*Math.exp(c*h);return a/l*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 Gt{constructor(t,e={}){this.config=t,this.imageConfig=e}generate(t,e,i={}){var E,T,x,$,G,_,P,U,W;const o=[],{width:s,height:c}=e,a={...Ee,...this.config.cluster},h=this.config.spacing.padding,l=i.fixedHeight??200,u=((E=this.imageConfig.rotation)==null?void 0:E.mode)??"none",r=((x=(T=this.imageConfig.rotation)==null?void 0:T.range)==null?void 0:x.min)??-15,d=((G=($=this.imageConfig.rotation)==null?void 0:$.range)==null?void 0:G.max)??15,f=((P=(_=this.imageConfig.sizing)==null?void 0:_.variance)==null?void 0:P.min)??1,y=((W=(U=this.imageConfig.sizing)==null?void 0:U.variance)==null?void 0:W.max)??1,p=f!==1||y!==1,g=this.calculateClusterCount(t,a.clusterCount,s,c,a.clusterSpacing),m=this.generateClusterCenters(g,s,c,h,a),v=new Array(g).fill(0);for(let C=0;C<t;C++)v[C%g]++;let w=0;for(let C=0;C<g;C++){const S=m[C],F=v[C];for(let O=0;O<F;O++){let z,R;if(a.distribution==="gaussian")z=this.gaussianRandom()*S.spread,R=this.gaussianRandom()*S.spread;else{const N=this.random(0,Math.PI*2),k=this.random(0,S.spread);z=Math.cos(N)*k,R=Math.sin(N)*k}const M=1+a.overlap*.5,j=1+a.overlap*.3;z/=M,R/=M;const K=p?this.random(f,y):1,X=j*K,V=l*X;let Q=S.x+z,q=S.y+R;const et=V*1.5/2,Y=V/2;Q=Math.max(h+et,Math.min(Q,s-h-et)),q=Math.max(h+Y,Math.min(q,c-h-Y));const it=u==="random"?this.random(r,d):0,L=Math.sqrt(z*z+R*R)/S.spread,D=Math.round((1-L)*50)+1;o.push({id:w,x:Q,y:q,rotation:it,scale:X,baseSize:V,zIndex:D}),w++}}return o}calculateClusterCount(t,e,i,o,s){if(e!=="auto")return Math.max(1,Math.min(e,t));const a=Math.max(1,Math.ceil(t/8)),h=Math.floor(i/s*(o/s)*.6);return Math.max(1,Math.min(a,h,10))}generateClusterCenters(t,e,i,o,s){const c=[],h=o+s.clusterSpread,l=e-o-s.clusterSpread,u=o+s.clusterSpread,r=i-o-s.clusterSpread;for(let d=0;d<t;d++){let f=null,y=-1;for(let p=0;p<100;p++){const g={x:this.random(h,l),y:this.random(u,r),spread:this.calculateClusterSpread(s)};let m=1/0;for(const v of c){const w=g.x-v.x,E=g.y-v.y,T=Math.sqrt(w*w+E*E);m=Math.min(m,T)}if((c.length===0||m>y)&&(f=g,y=m),m>=s.clusterSpacing)break}f&&c.push(f)}return c}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 Re{constructor(t,e={}){this.config=t,this.imageConfig=e}generate(t,e,i={}){var M,j,K,X,V,Q,q,tt,et;const o=[],{width:s,height:c}=e,a=i.fixedHeight??200,h=this.config.spacing.padding??50,l=((M=this.imageConfig.rotation)==null?void 0:M.mode)??"none",u=((K=(j=this.imageConfig.rotation)==null?void 0:j.range)==null?void 0:K.min)??-15,r=((V=(X=this.imageConfig.rotation)==null?void 0:X.range)==null?void 0:V.max)??15,d=((q=(Q=this.imageConfig.sizing)==null?void 0:Q.variance)==null?void 0:q.min)??1,f=((et=(tt=this.imageConfig.sizing)==null?void 0:tt.variance)==null?void 0:et.max)??1,y=d!==1||f!==1,p=i.fixedHeight??a,g={...ee,...this.config.wave},{rows:m,amplitude:v,frequency:w,phaseShift:E,synchronization:T}=g,x=Math.ceil(t/m),_=p*1.5/2,P=h+_,U=s-h-_,W=U-P,C=x>1?W/(x-1):0,S=h+v+p/2,F=c-h-v-p/2,O=F-S,z=m>1?O/(m-1):0;let R=0;for(let Y=0;Y<m&&R<t;Y++){const it=m===1?(S+F)/2:S+Y*z;let B=0;T==="offset"?B=Y*E:T==="alternating"&&(B=Y*Math.PI);for(let L=0;L<x&&R<t;L++){const D=x===1?(P+U)/2:P+L*C,N=this.calculateWaveY(D,s,v,w,B),k=D,H=it+N,nt=y?this.random(d,f):1,ot=p*nt;let rt=0;l==="tangent"?rt=this.calculateRotation(D,s,v,w,B):l==="random"&&(rt=this.random(u,r));const ct=ot*1.5/2,Et=ot/2,ft=h+ct,pt=s-h-ct,Rt=h+Et,At=c-h-Et;o.push({id:R,x:Math.max(ft,Math.min(k,pt)),y:Math.max(Rt,Math.min(H,At)),rotation:rt,scale:nt,baseSize:ot,zIndex:R+1}),R++}}return o}calculateWaveY(t,e,i,o,s){const c=t/e;return i*Math.sin(o*c*2*Math.PI+s)}calculateRotation(t,e,i,o,s){const c=t/e,a=i*o*2*Math.PI*Math.cos(o*c*2*Math.PI+s)/e;return Math.atan(a)*(180/Math.PI)}random(t,e){return Math.random()*(e-t)+t}}class Wt{constructor(t){this.config=t.layout,this.imageConfig=t.image,this.layouts=new Map,this.generator=this.initGenerator()}initGenerator(){switch(this.config.algorithm){case"radial":return new Ut(this.config,this.imageConfig);case"grid":return new Ht(this.config,this.imageConfig);case"spiral":return new jt(this.config,this.imageConfig);case"cluster":return new Gt(this.config,this.imageConfig);case"wave":return new Re(this.config,this.imageConfig);case"random":default:return new Pt(this.config,this.imageConfig)}}generateLayout(t,e,i={}){const o=this.generator.generate(t,e,i);return o.forEach(s=>{this.layouts.set(s.id,s)}),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.generator=this.initGenerator())),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,s=this.resolveBreakpoint(t);return s==="mobile"?o.mobile??o.tablet??o.screen:s==="tablet"?o.tablet??o.screen??o.mobile:o.screen??o.tablet??o.mobile}calculateAdaptiveSize(t,e,i,o){const s=this.imageConfig.sizing,c=this.resolveBaseHeight(o);if(c!==void 0)return{height:c};const a=(s==null?void 0:s.minSize)??50,h=(s==null?void 0:s.maxSize)??400,l=this.config.targetCoverage??.6,u=this.config.densityFactor??1,{width:r,height:d}=t,p=r*d*l/e;let m=Math.sqrt(p/1.4);m*=u,m=Math.min(m,i);let v=this.clamp(m,a,h);if(v===a&&m<a){const w=Math.max(a*.05,20);v=Math.max(w,m)}return{height:v}}clamp(t,e,i){return Math.max(e,Math.min(i,t))}}var I=(n=>(n.IDLE="idle",n.FOCUSING="focusing",n.FOCUSED="focused",n.UNFOCUSING="unfocusing",n.CROSS_ANIMATING="cross_animating",n))(I||{});function Ae(n){return n in st}function Te(n){return n?Ae(n)?st[n]:n:st.md}function Fe(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 ht(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 mt(n){var s,c;if(!n)return{};const t={};if(n.borderRadiusTopLeft!==void 0||n.borderRadiusTopRight!==void 0||n.borderRadiusBottomRight!==void 0||n.borderRadiusBottomLeft!==void 0){const a=((s=n.border)==null?void 0:s.radius)??0;n.borderRadiusTopLeft!==void 0?t.borderTopLeftRadius=`${n.borderRadiusTopLeft}px`:a&&(t.borderTopLeftRadius=`${a}px`),n.borderRadiusTopRight!==void 0?t.borderTopRightRadius=`${n.borderRadiusTopRight}px`:a&&(t.borderTopRightRadius=`${a}px`),n.borderRadiusBottomRight!==void 0?t.borderBottomRightRadius=`${n.borderRadiusBottomRight}px`:a&&(t.borderBottomRightRadius=`${a}px`),n.borderRadiusBottomLeft!==void 0?t.borderBottomLeftRadius=`${n.borderRadiusBottomLeft}px`:a&&(t.borderBottomLeftRadius=`${a}px`)}else((c=n.border)==null?void 0:c.radius)!==void 0&&(t.borderRadius=`${n.border.radius}px`);if(n.borderTop||n.borderRight||n.borderBottom||n.borderLeft){const a=n.border||{},h={...a,...n.borderTop},l={...a,...n.borderRight},u={...a,...n.borderBottom},r={...a,...n.borderLeft};t.borderTop=ht(h),t.borderRight=ht(l),t.borderBottom=ht(u),t.borderLeft=ht(r)}else n.border&&(t.border=ht(n.border));n.shadow!==void 0&&(t.boxShadow=Te(n.shadow));const o=Fe(n.filter);if(o&&(t.filter=o),n.opacity!==void 0&&(t.opacity=String(n.opacity)),n.cursor!==void 0&&(t.cursor=n.cursor),n.outline&&n.outline.style!=="none"&&(n.outline.width??0)>0){const a=n.outline.width??0,h=n.outline.style??"solid",l=n.outline.color??"#000000";t.outline=`${a}px ${h} ${l}`,n.outline.offset!==void 0&&(t.outlineOffset=`${n.outline.offset}px`)}return n.objectFit!==void 0&&(t.objectFit=n.objectFit),n.aspectRatio!==void 0&&(t.aspectRatio=n.aspectRatio),t}function dt(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)}function Nt(n){return n?Array.isArray(n)?n.join(" "):n:""}function ut(n,t){const e=Nt(t);e&&e.split(" ").forEach(i=>{i.trim()&&n.classList.add(i.trim())})}function kt(n,t){const e=Nt(t);e&&e.split(" ").forEach(i=>{i.trim()&&n.classList.remove(i.trim())})}const qt={UNFOCUSING:999,FOCUSING:1e3};class Yt{constructor(t,e,i){var o,s;this.state=I.IDLE,this.currentFocus=null,this.focusData=null,this.outgoing=null,this.incoming=null,this.focusGeneration=0,this.config=t,this.animationEngine=e,this.defaultStyles=mt(i==null?void 0:i.default),this.focusedStyles=mt(i==null?void 0:i.focused),this.defaultClassName=(o=i==null?void 0:i.default)==null?void 0:o.className,this.focusedClassName=(s=i==null?void 0:i.focused)==null?void 0:s.className}getState(){return this.state}isAnimating(){return this.state!==I.IDLE&&this.state!==I.FOCUSED}normalizeScalePercent(t){return t>1?t/100:t}calculateFocusDimensions(t,e,i){const o=this.normalizeScalePercent(this.config.scalePercent),s=i.height*o,c=t/e;let a=s,h=a*c;const l=i.width*o;return h>l&&(h=l,a=h/c),{width:h,height:a}}calculateFocusTransform(t,e){const i=t.width/2,o=t.height/2,s=i-e.x,c=o-e.y;return{x:s,y:c,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,s,c,a,h){const l=this.buildDimensionZoomTransform(e),u=this.buildDimensionZoomTransform(i);return t.style.transition="none",t.animate([{transform:l,width:`${o}px`,height:`${s}px`},{transform:u,width:`${c}px`,height:`${a}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"),dt(t,this.focusedStyles),ut(t,this.focusedClassName)}removeFocusedStyling(t,e){t.style.zIndex=e,t.classList.remove("fbn-ic-focused"),kt(t,this.focusedClassName),dt(t,this.defaultStyles),ut(t,this.defaultClassName)}startFocusAnimation(t,e,i,o,s){const c=t.style.zIndex||"",a=t.offsetWidth,h=t.offsetHeight,l=this.calculateFocusDimensions(a,h,e),u=this.calculateFocusTransform(e,i);this.applyFocusedStyling(t,qt.FOCUSING),this.animationEngine.cancelAllAnimations(t);const r=o??{x:0,y:0,rotation:i.rotation,scale:1},d=(s==null?void 0:s.width)??a,f=(s==null?void 0:s.height)??h,y=this.config.animationDuration??600,p=this.animateWithDimensions(t,r,u,d,f,l.width,l.height,y),g={id:`focus-${Date.now()}`,element:t,animation:p,fromState:r,toState:u,startTime:performance.now(),duration:y};return this.focusData={element:t,originalState:i,focusTransform:u,originalZIndex:c,originalWidth:a,originalHeight:h,focusWidth:l.width,focusHeight:l.height},{element:t,originalState:i,animationHandle:g,direction:"in",originalWidth:a,originalHeight:h}}startUnfocusAnimation(t,e,i,o){var y,p,g,m,v;t.style.zIndex=String(qt.UNFOCUSING),this.animationEngine.cancelAllAnimations(t);const s=i??((y=this.focusData)==null?void 0:y.focusTransform)??{x:0,y:0,rotation:0,scale:1},c=(o==null?void 0:o.width)??((p=this.focusData)==null?void 0:p.focusWidth)??t.offsetWidth,a=(o==null?void 0:o.height)??((g=this.focusData)==null?void 0:g.focusHeight)??t.offsetHeight,h={x:0,y:0,rotation:e.rotation,scale:1},l=((m=this.focusData)==null?void 0:m.originalWidth)??t.offsetWidth,u=((v=this.focusData)==null?void 0:v.originalHeight)??t.offsetHeight,r=this.config.animationDuration??600,d=this.animateWithDimensions(t,s,h,c,a,l,u,r),f={id:`unfocus-${Date.now()}`,element:t,animation:d,fromState:s,toState:h,startTime:performance.now(),duration:r};return{element:t,originalState:e,animationHandle:f,direction:"out",originalWidth:l,originalHeight:u}}async waitForAnimation(t){try{await t.animation.finished}catch{}}resetElementInstantly(t,e,i,o,s){this.animationEngine.cancelAllAnimations(t);const c=["translate(-50%, -50%)"];c.push("translate(0px, 0px)"),c.push(`rotate(${e.rotation}deg)`),t.style.transition="none",t.style.transform=c.join(" "),o!==void 0&&s!==void 0&&(t.style.width=`${o}px`,t.style.height=`${s}px`),this.removeFocusedStyling(t,i)}async focusImage(t,e,i){var s,c,a,h,l,u,r,d,f,y,p,g;if(this.currentFocus===t&&this.state===I.FOCUSED)return this.unfocusImage();if(((s=this.incoming)==null?void 0:s.element)===t&&this.state===I.FOCUSING){const m=this.animationEngine.cancelAnimation(this.incoming.animationHandle,!0),v={x:m.x,y:m.y,rotation:m.rotation,scale:1},w={width:t.offsetWidth,height:t.offsetHeight};this.outgoing=this.startUnfocusAnimation(t,this.incoming.originalState,v,w),this.incoming=null,this.state=I.UNFOCUSING,await this.waitForAnimation(this.outgoing.animationHandle),this.removeFocusedStyling(this.outgoing.element,((c=this.focusData)==null?void 0:c.originalZIndex)||""),this.outgoing=null,this.currentFocus=null,this.focusData=null,this.state=I.IDLE;return}const o=++this.focusGeneration;switch(this.state){case I.IDLE:if(this.state=I.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=I.FOCUSED;break;case I.FOCUSED:if(this.state=I.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,((a=this.outgoing.originalState.zIndex)==null?void 0:a.toString())||""),this.outgoing=null),this.currentFocus=t,this.incoming=null,this.state=I.FOCUSED;break;case I.FOCUSING:if(this.incoming&&(this.animationEngine.cancelAnimation(this.incoming.animationHandle,!1),this.resetElementInstantly(this.incoming.element,this.incoming.originalState,((h=this.focusData)==null?void 0:h.originalZIndex)||"",(l=this.focusData)==null?void 0:l.originalWidth,(u=this.focusData)==null?void 0:u.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=I.FOCUSED;break;case I.UNFOCUSING:if(this.state=I.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,((r=this.outgoing.originalState.zIndex)==null?void 0:r.toString())||""),this.outgoing=null),this.currentFocus=t,this.incoming=null,this.state=I.FOCUSED;break;case I.CROSS_ANIMATING:if(((d=this.incoming)==null?void 0:d.element)===t)return;if(((f=this.outgoing)==null?void 0:f.element)===t){const m=this.animationEngine.cancelAnimation(this.outgoing.animationHandle,!0),v={x:m.x,y:m.y,rotation:m.rotation,scale:1},w={width:t.offsetWidth,height:t.offsetHeight};if(this.incoming){const E=this.animationEngine.cancelAnimation(this.incoming.animationHandle,!0),T={x:E.x,y:E.y,rotation:E.rotation,scale:1},x={width:this.incoming.element.offsetWidth,height:this.incoming.element.offsetHeight};this.outgoing=this.startUnfocusAnimation(this.incoming.element,this.incoming.originalState,T,x)}else this.outgoing=null;if(this.incoming=this.startFocusAnimation(t,e,i,v,w),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,((y=this.outgoing.originalState.zIndex)==null?void 0:y.toString())||""),this.outgoing=null),this.currentFocus=t,this.incoming=null,this.state=I.FOCUSED;return}if(this.outgoing&&(this.animationEngine.cancelAnimation(this.outgoing.animationHandle,!1),this.resetElementInstantly(this.outgoing.element,this.outgoing.originalState,((p=this.outgoing.originalState.zIndex)==null?void 0:p.toString())||"",this.outgoing.originalWidth,this.outgoing.originalHeight),this.outgoing=null),this.incoming){const m=this.animationEngine.cancelAnimation(this.incoming.animationHandle,!0),v={x:m.x,y:m.y,rotation:m.rotation,scale:1},w={width:this.incoming.element.offsetWidth,height:this.incoming.element.offsetHeight};this.outgoing=this.startUnfocusAnimation(this.incoming.element,this.incoming.originalState,v,w)}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,((g=this.outgoing.originalState.zIndex)==null?void 0:g.toString())||""),this.outgoing=null),this.currentFocus=t,this.incoming=null,this.state=I.FOCUSED;break}}async unfocusImage(){var s,c,a;const t=++this.focusGeneration;if(!this.currentFocus||!this.focusData){if(this.incoming&&this.state===I.FOCUSING){const h=this.animationEngine.cancelAnimation(this.incoming.animationHandle,!0),l={x:h.x,y:h.y,rotation:h.rotation,scale:1},u={width:this.incoming.element.offsetWidth,height:this.incoming.element.offsetHeight};if(this.outgoing=this.startUnfocusAnimation(this.incoming.element,this.incoming.originalState,l,u),this.incoming=null,this.state=I.UNFOCUSING,await this.waitForAnimation(this.outgoing.animationHandle),this.focusGeneration!==t)return;this.removeFocusedStyling(this.outgoing.element,((s=this.focusData)==null?void 0:s.originalZIndex)||""),this.outgoing=null,this.focusData=null,this.state=I.IDLE}return}if(this.state===I.CROSS_ANIMATING&&this.incoming){const h=this.animationEngine.cancelAnimation(this.incoming.animationHandle,!0),l={x:h.x,y:h.y,rotation:h.rotation,scale:1},u={width:this.incoming.element.offsetWidth,height:this.incoming.element.offsetHeight},r=this.startUnfocusAnimation(this.incoming.element,this.incoming.originalState,l,u);if(await Promise.all([this.outgoing?this.waitForAnimation(this.outgoing.animationHandle):Promise.resolve(),this.waitForAnimation(r.animationHandle)]),this.focusGeneration!==t)return;this.outgoing&&this.removeFocusedStyling(this.outgoing.element,((c=this.outgoing.originalState.zIndex)==null?void 0:c.toString())||""),this.removeFocusedStyling(r.element,((a=this.incoming.originalState.zIndex)==null?void 0:a.toString())||""),this.outgoing=null,this.incoming=null,this.currentFocus=null,this.focusData=null,this.state=I.IDLE;return}this.state=I.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=I.IDLE)}async swapFocus(t,e,i){return this.focusImage(t,e,i)}getCurrentFocus(){return this.currentFocus}isFocused(t){return this.currentFocus===t&&this.state===I.FOCUSED}isTargetingFocus(t){var e;return((e=this.incoming)==null?void 0:e.element)===t}isInvolved(t){var e,i;return this.currentFocus===t||((e=this.incoming)==null?void 0:e.element)===t||((i=this.outgoing)==null?void 0:i.element)===t}reset(){var t,e,i,o;this.outgoing&&(this.animationEngine.cancelAnimation(this.outgoing.animationHandle,!1),this.resetElementInstantly(this.outgoing.element,this.outgoing.originalState,((t=this.outgoing.originalState.zIndex)==null?void 0:t.toString())||"",this.outgoing.originalWidth,this.outgoing.originalHeight)),this.incoming&&(this.animationEngine.cancelAnimation(this.incoming.animationHandle,!1),this.resetElementInstantly(this.incoming.element,this.incoming.originalState,((e=this.focusData)==null?void 0:e.originalZIndex)||"",(i=this.focusData)==null?void 0:i.originalWidth,(o=this.focusData)==null?void 0:o.originalHeight)),this.currentFocus&&this.focusData&&this.resetElementInstantly(this.currentFocus,this.focusData.originalState,this.focusData.originalZIndex,this.focusData.originalWidth,this.focusData.originalHeight),this.state=I.IDLE,this.currentFocus=null,this.focusData=null,this.outgoing=null,this.incoming=null}}class Bt{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(e.type==="folder")for(const i of e.folders){const o=e.recursive!==void 0?e.recursive:!0,s=await this.loadFromFolder(i,t,o);this._discoveredUrls.push(...s)}else if(e.type==="files"){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(s){return console.error("Error loading from Google Drive API:",s),this.loadImagesDirectly(o,e)}}async loadImagesFromSingleFolder(t,e){const i=[],o=`'${t}' in parents and trashed=false`,c=`${this.apiEndpoint}?q=${encodeURIComponent(o)}&fields=files(id,name,mimeType,thumbnailLink)&key=${this.apiKey}`,a=await fetch(c);if(!a.ok)throw new Error(`API request failed: ${a.status} ${a.statusText}`);const l=(await a.json()).files.filter(u=>u.mimeType.startsWith("image/")&&e.isAllowed(u.name));return this.log(`Found ${l.length} images in folder ${t} (non-recursive)`),l.forEach(u=>{i.push(`https://lh3.googleusercontent.com/d/${u.id}=s1600`),this.log(`Added file: ${u.name}`)}),i}async loadFiles(t,e){const i=[];for(const o of t){const s=this.extractFileId(o);if(!s){this.log(`Skipping invalid file URL: ${o}`);continue}if(this.apiKey&&this.apiKey!=="YOUR_API_KEY_HERE")try{const c=`${this.apiEndpoint}/${s}?fields=name,mimeType&key=${this.apiKey}`,a=await fetch(c);if(a.ok){const h=await a.json();h.mimeType.startsWith("image/")&&e.isAllowed(h.name)?(i.push(`https://lh3.googleusercontent.com/d/${s}=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 ${s}: ${a.status}`)}catch(c){this.log(`Error fetching metadata for file ${s}:`,c)}else i.push(`https://lh3.googleusercontent.com/d/${s}=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`,c=`${this.apiEndpoint}?q=${encodeURIComponent(o)}&fields=files(id,name,mimeType,thumbnailLink)&key=${this.apiKey}`,a=await fetch(c);if(!a.ok)throw new Error(`API request failed: ${a.status} ${a.statusText}`);const h=await a.json(),l=h.files.filter(r=>r.mimeType.startsWith("image/")&&e.isAllowed(r.name)),u=h.files.filter(r=>r.mimeType==="application/vnd.google-apps.folder");this.log(`Found ${h.files.length} total items in folder ${t}`),h.files.forEach(r=>this.log(` - File: ${r.name} (${r.mimeType})`)),this.log(`- ${l.length} valid files (images only)`),this.log(`- ${u.length} subfolders`),l.forEach(r=>{i.push(`https://lh3.googleusercontent.com/d/${r.id}=s1600`),this.log(`Added file: ${r.name}`)});for(const r of u){this.log(`Loading images from subfolder: ${r.name}`);const d=await this.loadImagesRecursively(r.id,e);i.push(...d)}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 s=await o.text(),c=/\/file\/d\/([a-zA-Z0-9_-]+)/g,a=[...s.matchAll(c)];return[...new Set(a.map(u=>u[1]))].map(u=>`https://drive.google.com/uc?export=view&id=${u}`)}catch(i){throw console.error("Direct loading failed:",i),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(e=>`https://drive.google.com/uc?export=view&id=${e}`)}log(...t){this.debugLogging&&typeof console<"u"&&console.log(...t)}}class Bt{constructor(t={}){if(this._prepared=!1,this._discoveredUrls=[],this.validateUrls=t.validateUrls!==!1,this.validationTimeout=t.validationTimeout??5e3,this.validationMethod=t.validationMethod??"head",this.sources=t.sources??[],this.debugLogging=t.debugLogging??!1,!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 e of this.sources)try{const i=await this.processSource(e,t);this._discoveredUrls.push(...i)}catch(i){console.warn("Failed to process source:",e,i)}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,e){return!t||!t.type?(console.warn("Invalid source object (missing type):",t),[]):t.type==="urls"?await this.processUrls(t.urls||[],e):t.type==="path"?await this.processPath(t.basePath,t.files||[],e):(console.warn(`Unknown source type: ${t.type}`),[])}async processUrls(t,e){if(!Array.isArray(t))return console.warn("URLs must be an array:",t),[];const i=[];for(const o of t){const s=o.split("/").pop()||o;if(!e.isAllowed(s)){this.log(`Skipping filtered URL: ${o}`);continue}this.validateUrls?await this.validateUrl(o)?i.push(o):console.warn(`Skipping invalid/missing URL: ${o}`):i.push(o)}return i}async processPath(t,e,i){if(!t)return console.warn("basePath is required for path-type sources"),[];if(!Array.isArray(e))return console.warn("files must be an array:",e),[];const o=[];for(const s of e){if(!i.isAllowed(s)){this.log(`Skipping filtered file: ${s}`);continue}const c=this.constructUrl(t,s);this.validateUrls?await this.validateUrl(c)?o.push(c):console.warn(`Skipping invalid/missing file: ${c}`):o.push(c)}return o}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 i=new AbortController,o=setTimeout(()=>i.abort(),this.validationTimeout),s=await fetch(t,{method:"HEAD",signal:i.signal});return clearTimeout(o),s.ok?!0:(this.log(`Validation failed for ${t}: HTTP ${s.status}`),!1)}catch(i){return i instanceof Error&&(i.name==="AbortError"?this.log(`Validation timeout for ${t}`):this.log(`Validation failed for ${t}:`,i.message)),!1}}constructUrl(t,e){const i=t.replace(/\/$/,"");if(this.isAbsoluteUrl(t))return`${i}/${e}`;if(typeof window>"u")return`${i}/${e}`;const o=window.location.origin,c=(t.startsWith("/")?t:"/"+t).replace(/\/$/,"");return`${o}${c}/${e}`}isAbsoluteUrl(t){try{return new URL(t),!0}catch{return!1}}log(...t){this.debugLogging&&typeof console<"u"&&console.log(...t)}}class Vt{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 e=this.loaders.map((i,o)=>i.prepare(t).then(()=>{this.log(`Loader ${o} prepared with ${i.imagesLength()} images`)}).catch(s=>{console.warn(`Loader ${o} failed to prepare:`,s)}));await Promise.all(e);for(const i of this.loaders)if(i.isPrepared()){const o=i.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 Jt{constructor(t){this.allowedExtensions=t||["jpg","jpeg","png","gif","webp","bmp"]}isAllowed(t){var o;const i=(o=t.split("?")[0].split(".").pop())==null?void 0:o.toLowerCase();return i?this.allowedExtensions.includes(i):!1}getAllowedExtensions(){return[...this.allowedExtensions]}}class Zt{constructor(t={}){var i,o,s,c,a,h;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.animationEngine=new Lt(this.fullConfig.animation),this.layoutEngine=new kt({layout:this.fullConfig.layout,image:this.fullConfig.image,breakpoints:this.fullConfig.rendering.responsive.breakpoints}),this.zoomEngine=new Yt(this.fullConfig.interaction.focus,this.animationEngine,this.fullConfig.styling),this.defaultStyles=mt((i=this.fullConfig.styling)==null?void 0:i.default),this.hoverStyles=mt((o=this.fullConfig.styling)==null?void 0:o.hover),this.defaultClassName=(c=(s=this.fullConfig.styling)==null?void 0:s.default)==null?void 0:c.className,this.hoverClassName=(h=(a=this.fullConfig.styling)==null?void 0:a.hover)==null?void 0:h.className;const e=this.fullConfig.animation.entry||b.animation.entry;this.entryAnimationEngine=new Dt(e,this.fullConfig.layout.algorithm),this.imageFilter=this.createImageFilter(),this.imageLoader=this.createLoader(),this.containerEl=null,this.loadingEl=null,this.errorEl=null}createImageFilter(){var i,o;const t=this.fullConfig.loader.type;let e;return t==="googleDrive"?e=(i=this.fullConfig.loader.googleDrive)==null?void 0:i.allowedExtensions:e=(o=this.fullConfig.loader.static)==null?void 0:o.allowedExtensions,new Jt(e)}createLoader(){return this.createLoaderFromConfig(this.fullConfig.loader)}createLoaderFromConfig(t){const e=t.type;if(e==="static"){const i=t.static;return new Bt(i)}else if(e==="composite"){const i=t.composite,o=i.loaders.map(s=>this.createLoaderFromConfig(s));return new Vt({loaders:o,debugLogging:i.debugLogging})}else{const i=t.googleDrive;return new Xt(i)}}async init(){try{if(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.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(){this.loadingEl=document.getElementById("loading"),this.errorEl=document.getElementById("error")}setupEventListeners(){document.addEventListener("keydown",t=>{t.key==="Escape"?(this.zoomEngine.unfocusImage(),this.currentFocusIndex=null):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=>{t.target.closest(".fbn-ic-image")||(this.zoomEngine.unfocusImage(),this.currentFocusIndex=null)}),window.addEventListener("resize",()=>this.handleResize())}navigateToNextImage(){if(this.currentFocusIndex===null||this.imageElements.length===0)return;const t=(this.currentFocusIndex+1)%this.imageElements.length;this.navigateToImage(t)}navigateToPreviousImage(){if(this.currentFocusIndex===null||this.imageElements.length===0)return;const t=(this.currentFocusIndex-1+this.imageElements.length)%this.imageElements.length;this.navigateToImage(t)}async navigateToImage(t){if(t<0||t>=this.imageElements.length)return;const e=this.imageElements[t],i=this.imageLayouts[t];!e||!i||await this.handleImageClick(e,i)}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.sizing.responsive||[];for(const i of e)if(t>=i.minWidth)return i.height;return 120}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(),s=window.innerWidth;this.logDebug(`Adaptive sizing input: container=${i.width}x${i.height}px, images=${t}, responsiveMax=${o}px`);const c=this.layoutEngine.calculateAdaptiveSize(i,t,o,s);this.logDebug(`Adaptive sizing result: height=${c.height}px`),await this.createImageCloud(e,c.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.debug&&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,s=this.layoutEngine.generateLayout(t.length,i,{fixedHeight:e});this.imageLayouts=s,this.displayQueue=[];let c=0;const a=l=>{this.containerEl&&(this.containerEl.appendChild(l),this.imageElements.push(l),requestAnimationFrame(()=>{if(l.offsetWidth,l.style.opacity=this.defaultStyles.opacity??"1",l.dataset.startX&&(this.entryAnimationEngine.requiresJSAnimation()||this.entryAnimationEngine.requiresJSRotation()||this.entryAnimationEngine.requiresJSScale()||l.dataset.startRotation!==l.dataset.rotation||l.dataset.startScale!==l.dataset.scale)){const d={x:parseFloat(l.dataset.startX),y:parseFloat(l.dataset.startY)},f={x:parseFloat(l.dataset.endX),y:parseFloat(l.dataset.endY)},y=parseFloat(l.dataset.imageWidth),p=parseFloat(l.dataset.imageHeight),u=parseFloat(l.dataset.rotation),m=parseFloat(l.dataset.scale),w=l.dataset.startRotation?parseFloat(l.dataset.startRotation):u,v=l.dataset.startScale?parseFloat(l.dataset.startScale):m,R=this.entryAnimationEngine.getTiming();$t({element:l,startPosition:d,endPosition:f,pathConfig:this.entryAnimationEngine.getPathConfig(),duration:R.duration,imageWidth:y,imageHeight:p,rotation:u,scale:m,rotationConfig:this.entryAnimationEngine.getRotationConfig(),startRotation:w,scaleConfig:this.entryAnimationEngine.getScaleConfig(),startScale:v})}else{const d=l.dataset.finalTransform||"";l.style.transform=d}const r=parseInt(l.dataset.imageId||"0");if(this.fullConfig.debug&&r<3){const d=l.dataset.finalTransform||"";console.log(`Image ${r} final state:`,{left:l.style.left,top:l.style.top,width:l.style.width,height:l.style.height,computedWidth:l.offsetWidth,computedHeight:l.offsetHeight,transform:d,pathType:this.entryAnimationEngine.getPathType()})}}),c++)},h=()=>{if(this.logDebug("Starting queue processing, enabled:",this.fullConfig.animation.queue.enabled),!this.fullConfig.animation.queue.enabled){for(;this.displayQueue.length>0;){const l=this.displayQueue.shift();l&&a(l)}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 l=this.displayQueue.shift();l&&a(l)}c>=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 l=new IntersectionObserver(g=>{g.forEach(r=>{r.isIntersecting&&(h(),l.disconnect())})},{threshold:.1,rootMargin:"50px"});l.observe(this.containerEl)}else h();this.fullConfig.layout.debugCenters&&this.containerEl&&(this.containerEl.querySelectorAll(".fbn-ic-debug-center").forEach(l=>l.remove()),s.forEach((l,g)=>{const r=document.createElement("div");r.className="fbn-ic-debug-center",r.style.position="absolute",r.style.width="12px",r.style.height="12px",r.style.borderRadius="50%",r.style.backgroundColor="red",r.style.border="2px solid yellow",r.style.zIndex="9999",r.style.pointerEvents="none";const d=l.x,f=l.y;r.style.left=`${d-6}px`,r.style.top=`${f-6}px`,r.title=`Image ${g}: center (${Math.round(d)}, ${Math.round(f)})`,this.containerEl.appendChild(r)})),t.forEach((l,g)=>{var f,y;const r=document.createElement("img");r.referrerPolicy="no-referrer",r.classList.add("fbn-ic-image"),r.dataset.imageId=String(g);const d=s[g];r.style.position="absolute",r.style.width="auto",r.style.height=`${e}px`,r.style.left=`${d.x}px`,r.style.top=`${d.y}px`,d.borderColor&&!((y=(f=this.fullConfig.styling)==null?void 0:f.default)!=null&&y.border)&&(r.style.border=`5px solid ${d.borderColor}`,r.style.boxSizing="border-box"),d.zIndex&&(r.style.zIndex=String(d.zIndex)),dt(r,this.defaultStyles),gt(r,this.defaultClassName),r.addEventListener("mouseenter",()=>{this.hoveredImage={element:r,layout:d},this.zoomEngine.isInvolved(r)||(dt(r,this.hoverStyles),gt(r,this.hoverClassName))}),r.addEventListener("mouseleave",()=>{this.hoveredImage=null,this.zoomEngine.isInvolved(r)||(dt(r,this.defaultStyles),Nt(r,this.hoverClassName),gt(r,this.defaultClassName))}),r.addEventListener("click",p=>{p.stopPropagation(),this.handleImageClick(r,d)}),r.style.opacity="0",r.style.transition=this.entryAnimationEngine.getTransitionCSS(),r.onload=()=>{if(o!==this.loadGeneration)return;const p=r.naturalWidth/r.naturalHeight,u=e*p;r.style.width=`${u}px`;const m={x:d.x,y:d.y},w={width:u,height:e},v=this.entryAnimationEngine.calculateStartPosition(m,w,i,g,t.length),R=this.entryAnimationEngine.calculateStartRotation(d.rotation),F=this.entryAnimationEngine.calculateStartScale(d.scale),x=this.entryAnimationEngine.buildFinalTransform(d.rotation,d.scale,u,e),$=this.entryAnimationEngine.buildStartTransform(v,m,d.rotation,d.scale,u,e,R,F);this.fullConfig.debug&&g<3&&console.log(`Image ${g}:`,{finalPosition:m,imageSize:w,left:d.x,top:d.y,finalTransform:x,renderedWidth:u,renderedHeight:e}),r.style.transform=$,r.dataset.finalTransform=x,(this.entryAnimationEngine.requiresJSAnimation()||this.entryAnimationEngine.requiresJSRotation()||this.entryAnimationEngine.requiresJSScale()||R!==d.rotation||F!==d.scale)&&(r.dataset.startX=String(v.x),r.dataset.startY=String(v.y),r.dataset.endX=String(m.x),r.dataset.endY=String(m.y),r.dataset.imageWidth=String(u),r.dataset.imageHeight=String(e),r.dataset.rotation=String(d.rotation),r.dataset.scale=String(d.scale),r.dataset.startRotation=String(R),r.dataset.startScale=String(F)),this.displayQueue.push(r)},r.onerror=()=>c++,r.src=l})}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;else{const s=t.dataset.imageId;this.currentFocusIndex=s!==void 0?parseInt(s,10):null,await this.zoomEngine.focusImage(t,o,e)}}clearImageCloud(){this.queueInterval!==null&&(clearInterval(this.queueInterval),this.queueInterval=null),this.loadGeneration++,this.displayQueue=[],this.containerEl&&(this.containerEl.innerHTML=""),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")}destroy(){this.clearImageCloud(),this.resizeTimeout!==null&&clearTimeout(this.resizeTimeout)}}M.AnimationEngine=Lt,M.BOUNCE_PRESETS=yt,M.ClusterPlacementGenerator=jt,M.CompositeLoader=Vt,M.DEFAULT_CONFIG=b,M.ELASTIC_PRESETS=bt,M.EntryAnimationEngine=Dt,M.GoogleDriveLoader=Xt,M.GridPlacementGenerator=Ht,M.ImageCloud=Zt,M.ImageFilter=Jt,M.ImageGallery=Zt,M.LayoutEngine=kt,M.RadialPlacementGenerator=Ut,M.RandomPlacementGenerator=Pt,M.SpiralPlacementGenerator=_t,M.StaticImageLoader=Bt,M.WAVE_PATH_PRESETS=vt,M.ZoomEngine=Yt,M.animatePath=$t,M.requiresJSAnimation=Ot,Object.defineProperty(M,Symbol.toStringTag,{value:"Module"})});
4
+ 3. Consider adding a Google Drive API key in config.js for better reliability`)}}manualImageUrls(t){return t.map(e=>`https://drive.google.com/uc?export=view&id=${e}`)}log(...t){this.debugLogging&&typeof console<"u"&&console.log(...t)}}class Xt{constructor(t={}){if(this._prepared=!1,this._discoveredUrls=[],this.validateUrls=t.validateUrls!==!1,this.validationTimeout=t.validationTimeout??5e3,this.validationMethod=t.validationMethod??"head",this.sources=t.sources??[],this.debugLogging=t.debugLogging??!1,!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 e of this.sources)try{const i=await this.processSource(e,t);this._discoveredUrls.push(...i)}catch(i){console.warn("Failed to process source:",e,i)}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,e){return!t||!t.type?(console.warn("Invalid source object (missing type):",t),[]):t.type==="urls"?await this.processUrls(t.urls||[],e):t.type==="path"?await this.processPath(t.basePath,t.files||[],e):(console.warn(`Unknown source type: ${t.type}`),[])}async processUrls(t,e){if(!Array.isArray(t))return console.warn("URLs must be an array:",t),[];const i=[];for(const o of t){const s=o.split("/").pop()||o;if(!e.isAllowed(s)){this.log(`Skipping filtered URL: ${o}`);continue}this.validateUrls?await this.validateUrl(o)?i.push(o):console.warn(`Skipping invalid/missing URL: ${o}`):i.push(o)}return i}async processPath(t,e,i){if(!t)return console.warn("basePath is required for path-type sources"),[];if(!Array.isArray(e))return console.warn("files must be an array:",e),[];const o=[];for(const s of e){if(!i.isAllowed(s)){this.log(`Skipping filtered file: ${s}`);continue}const c=this.constructUrl(t,s);this.validateUrls?await this.validateUrl(c)?o.push(c):console.warn(`Skipping invalid/missing file: ${c}`):o.push(c)}return o}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 i=new AbortController,o=setTimeout(()=>i.abort(),this.validationTimeout),s=await fetch(t,{method:"HEAD",signal:i.signal});return clearTimeout(o),s.ok?!0:(this.log(`Validation failed for ${t}: HTTP ${s.status}`),!1)}catch(i){return i instanceof Error&&(i.name==="AbortError"?this.log(`Validation timeout for ${t}`):this.log(`Validation failed for ${t}:`,i.message)),!1}}constructUrl(t,e){const i=t.replace(/\/$/,"");if(this.isAbsoluteUrl(t))return`${i}/${e}`;if(typeof window>"u")return`${i}/${e}`;const o=window.location.origin,c=(t.startsWith("/")?t:"/"+t).replace(/\/$/,"");return`${o}${c}/${e}`}isAbsoluteUrl(t){try{return new URL(t),!0}catch{return!1}}log(...t){this.debugLogging&&typeof console<"u"&&console.log(...t)}}class Vt{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 e=this.loaders.map((i,o)=>i.prepare(t).then(()=>{this.log(`Loader ${o} prepared with ${i.imagesLength()} images`)}).catch(s=>{console.warn(`Loader ${o} failed to prepare:`,s)}));await Promise.all(e);for(const i of this.loaders)if(i.isPrepared()){const o=i.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 Jt{constructor(t){this.allowedExtensions=t||["jpg","jpeg","png","gif","webp","bmp"]}isAllowed(t){var o;const i=(o=t.split("?")[0].split(".").pop())==null?void 0:o.toLowerCase();return i?this.allowedExtensions.includes(i):!1}getAllowedExtensions(){return[...this.allowedExtensions]}}const Zt=`
5
+ .fbn-ic-gallery {
6
+ position: relative;
7
+ width: 100%;
8
+ height: 100%;
9
+ overflow: hidden;
10
+ perspective: 1000px;
11
+ }
12
+
13
+ .fbn-ic-image {
14
+ position: absolute;
15
+ cursor: pointer;
16
+ transition: transform 0.6s cubic-bezier(0.4, 0, 0.2, 1),
17
+ box-shadow 0.6s cubic-bezier(0.4, 0, 0.2, 1),
18
+ filter 0.3s cubic-bezier(0.4, 0, 0.2, 1),
19
+ opacity 0.3s cubic-bezier(0.4, 0, 0.2, 1),
20
+ border 0.3s cubic-bezier(0.4, 0, 0.2, 1),
21
+ outline 0.3s cubic-bezier(0.4, 0, 0.2, 1),
22
+ z-index 0s 0.6s;
23
+ will-change: transform;
24
+ user-select: none;
25
+ backface-visibility: hidden;
26
+ -webkit-backface-visibility: hidden;
27
+ }
28
+
29
+ .fbn-ic-image.fbn-ic-focused {
30
+ z-index: 1000;
31
+ transition: transform 0.6s cubic-bezier(0.4, 0, 0.2, 1),
32
+ box-shadow 0.6s cubic-bezier(0.4, 0, 0.2, 1),
33
+ filter 0.3s cubic-bezier(0.4, 0, 0.2, 1),
34
+ opacity 0.3s cubic-bezier(0.4, 0, 0.2, 1),
35
+ border 0.3s cubic-bezier(0.4, 0, 0.2, 1),
36
+ outline 0.3s cubic-bezier(0.4, 0, 0.2, 1),
37
+ z-index 0s 0s;
38
+ will-change: auto;
39
+ }
40
+
41
+ .fbn-ic-hidden {
42
+ display: none !important;
43
+ }
44
+ `;function Kt(){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=Zt,document.head.appendChild(t)}class Qt{constructor(t={}){var i,o,s,c,a,h;this.fullConfig=le(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.animationEngine=new Lt(this.fullConfig.animation),this.layoutEngine=new Wt({layout:this.fullConfig.layout,image:this.fullConfig.image}),this.zoomEngine=new Yt(this.fullConfig.interaction.focus,this.animationEngine,this.fullConfig.styling),this.defaultStyles=mt((i=this.fullConfig.styling)==null?void 0:i.default),this.hoverStyles=mt((o=this.fullConfig.styling)==null?void 0:o.hover),this.defaultClassName=(c=(s=this.fullConfig.styling)==null?void 0:s.default)==null?void 0:c.className,this.hoverClassName=(h=(a=this.fullConfig.styling)==null?void 0:a.hover)==null?void 0:h.className;const e=this.fullConfig.animation.entry||b.animation.entry;this.entryAnimationEngine=new Dt(e,this.fullConfig.layout.algorithm),this.imageFilter=this.createImageFilter(),this.imageLoader=this.createLoader(),this.containerEl=null,this.loadingEl=null,this.errorEl=null}createImageFilter(){var i,o;const t=this.fullConfig.loader.type;let e;return t==="googleDrive"?e=(i=this.fullConfig.loader.googleDrive)==null?void 0:i.allowedExtensions:e=(o=this.fullConfig.loader.static)==null?void 0:o.allowedExtensions,new Jt(e)}createLoader(){return this.createLoaderFromConfig(this.fullConfig.loader)}createLoaderFromConfig(t){const e=t.type;if(e==="static"){const i=t.static;return new Xt(i)}else if(e==="composite"){const i=t.composite,o=i.loaders.map(s=>this.createLoaderFromConfig(s));return new Vt({loaders:o,debugLogging:i.debugLogging})}else{const i=t.googleDrive;return new Bt(i)}}async init(){try{if(Kt(),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.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(){this.loadingEl=document.getElementById("loading"),this.errorEl=document.getElementById("error")}setupEventListeners(){document.addEventListener("keydown",t=>{t.key==="Escape"?(this.zoomEngine.unfocusImage(),this.currentFocusIndex=null):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=>{t.target.closest(".fbn-ic-image")||(this.zoomEngine.unfocusImage(),this.currentFocusIndex=null)}),window.addEventListener("resize",()=>this.handleResize())}navigateToNextImage(){if(this.currentFocusIndex===null||this.imageElements.length===0)return;const t=(this.currentFocusIndex+1)%this.imageElements.length;this.navigateToImage(t)}navigateToPreviousImage(){if(this.currentFocusIndex===null||this.imageElements.length===0)return;const t=(this.currentFocusIndex-1+this.imageElements.length)%this.imageElements.length;this.navigateToImage(t)}async navigateToImage(t){if(t<0||t>=this.imageElements.length)return;const e=this.imageElements[t],i=this.imageLayouts[t];!e||!i||await this.handleImageClick(e,i)}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,i=this.fullConfig.image.sizing,o=(i==null?void 0:i.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(),s=window.innerWidth;this.logDebug(`Adaptive sizing input: container=${i.width}x${i.height}px, images=${t}, responsiveMax=${o}px`);const c=this.layoutEngine.calculateAdaptiveSize(i,t,o,s);this.logDebug(`Adaptive sizing result: height=${c.height}px`),await this.createImageCloud(e,c.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.debug&&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,s=this.layoutEngine.generateLayout(t.length,i,{fixedHeight:e});this.imageLayouts=s,this.displayQueue=[];let c=0;const a=l=>{this.containerEl&&(this.containerEl.appendChild(l),this.imageElements.push(l),requestAnimationFrame(()=>{if(l.offsetWidth,l.style.opacity=this.defaultStyles.opacity??"1",l.dataset.startX&&(this.entryAnimationEngine.requiresJSAnimation()||this.entryAnimationEngine.requiresJSRotation()||this.entryAnimationEngine.requiresJSScale()||l.dataset.startRotation!==l.dataset.rotation||l.dataset.startScale!==l.dataset.scale)){const d={x:parseFloat(l.dataset.startX),y:parseFloat(l.dataset.startY)},f={x:parseFloat(l.dataset.endX),y:parseFloat(l.dataset.endY)},y=parseFloat(l.dataset.imageWidth),p=parseFloat(l.dataset.imageHeight),g=parseFloat(l.dataset.rotation),m=parseFloat(l.dataset.scale),v=l.dataset.startRotation?parseFloat(l.dataset.startRotation):g,w=l.dataset.startScale?parseFloat(l.dataset.startScale):m,E=this.entryAnimationEngine.getTiming();$t({element:l,startPosition:d,endPosition:f,pathConfig:this.entryAnimationEngine.getPathConfig(),duration:E.duration,imageWidth:y,imageHeight:p,rotation:g,scale:m,rotationConfig:this.entryAnimationEngine.getRotationConfig(),startRotation:v,scaleConfig:this.entryAnimationEngine.getScaleConfig(),startScale:w})}else{const d=l.dataset.finalTransform||"";l.style.transform=d}const r=parseInt(l.dataset.imageId||"0");if(this.fullConfig.debug&&r<3){const d=l.dataset.finalTransform||"";console.log(`Image ${r} final state:`,{left:l.style.left,top:l.style.top,width:l.style.width,height:l.style.height,computedWidth:l.offsetWidth,computedHeight:l.offsetHeight,transform:d,pathType:this.entryAnimationEngine.getPathType()})}}),c++)},h=()=>{if(this.logDebug("Starting queue processing, enabled:",this.fullConfig.animation.queue.enabled),!this.fullConfig.animation.queue.enabled){for(;this.displayQueue.length>0;){const l=this.displayQueue.shift();l&&a(l)}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 l=this.displayQueue.shift();l&&a(l)}c>=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 l=new IntersectionObserver(u=>{u.forEach(r=>{r.isIntersecting&&(h(),l.disconnect())})},{threshold:.1,rootMargin:"50px"});l.observe(this.containerEl)}else h();this.fullConfig.layout.debugCenters&&this.containerEl&&(this.containerEl.querySelectorAll(".fbn-ic-debug-center").forEach(l=>l.remove()),s.forEach((l,u)=>{const r=document.createElement("div");r.className="fbn-ic-debug-center",r.style.position="absolute",r.style.width="12px",r.style.height="12px",r.style.borderRadius="50%",r.style.backgroundColor="red",r.style.border="2px solid yellow",r.style.zIndex="9999",r.style.pointerEvents="none";const d=l.x,f=l.y;r.style.left=`${d-6}px`,r.style.top=`${f-6}px`,r.title=`Image ${u}: center (${Math.round(d)}, ${Math.round(f)})`,this.containerEl.appendChild(r)})),t.forEach((l,u)=>{var f,y;const r=document.createElement("img");r.referrerPolicy="no-referrer",r.classList.add("fbn-ic-image"),r.dataset.imageId=String(u);const d=s[u];r.style.position="absolute",r.style.width="auto",r.style.height=`${e}px`,r.style.left=`${d.x}px`,r.style.top=`${d.y}px`,d.borderColor&&!((y=(f=this.fullConfig.styling)==null?void 0:f.default)!=null&&y.border)&&(r.style.border=`5px solid ${d.borderColor}`,r.style.boxSizing="border-box"),d.zIndex&&(r.style.zIndex=String(d.zIndex)),dt(r,this.defaultStyles),ut(r,this.defaultClassName),r.addEventListener("mouseenter",()=>{this.hoveredImage={element:r,layout:d},this.zoomEngine.isInvolved(r)||(dt(r,this.hoverStyles),ut(r,this.hoverClassName))}),r.addEventListener("mouseleave",()=>{this.hoveredImage=null,this.zoomEngine.isInvolved(r)||(dt(r,this.defaultStyles),kt(r,this.hoverClassName),ut(r,this.defaultClassName))}),r.addEventListener("click",p=>{p.stopPropagation(),this.handleImageClick(r,d)}),r.style.opacity="0",r.style.transition=this.entryAnimationEngine.getTransitionCSS(),r.onload=()=>{if(o!==this.loadGeneration)return;const p=r.naturalWidth/r.naturalHeight,g=e*p;r.style.width=`${g}px`;const m={x:d.x,y:d.y},v={width:g,height:e},w=this.entryAnimationEngine.calculateStartPosition(m,v,i,u,t.length),E=this.entryAnimationEngine.calculateStartRotation(d.rotation),T=this.entryAnimationEngine.calculateStartScale(d.scale),x=this.entryAnimationEngine.buildFinalTransform(d.rotation,d.scale,g,e),$=this.entryAnimationEngine.buildStartTransform(w,m,d.rotation,d.scale,g,e,E,T);this.fullConfig.debug&&u<3&&console.log(`Image ${u}:`,{finalPosition:m,imageSize:v,left:d.x,top:d.y,finalTransform:x,renderedWidth:g,renderedHeight:e}),r.style.transform=$,r.dataset.finalTransform=x,(this.entryAnimationEngine.requiresJSAnimation()||this.entryAnimationEngine.requiresJSRotation()||this.entryAnimationEngine.requiresJSScale()||E!==d.rotation||T!==d.scale)&&(r.dataset.startX=String(w.x),r.dataset.startY=String(w.y),r.dataset.endX=String(m.x),r.dataset.endY=String(m.y),r.dataset.imageWidth=String(g),r.dataset.imageHeight=String(e),r.dataset.rotation=String(d.rotation),r.dataset.scale=String(d.scale),r.dataset.startRotation=String(E),r.dataset.startScale=String(T)),this.displayQueue.push(r)},r.onerror=()=>c++,r.src=l})}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;else{const s=t.dataset.imageId;this.currentFocusIndex=s!==void 0?parseInt(s,10):null,await this.zoomEngine.focusImage(t,o,e)}}clearImageCloud(){this.queueInterval!==null&&(clearInterval(this.queueInterval),this.queueInterval=null),this.loadGeneration++,this.displayQueue=[],this.containerEl&&(this.containerEl.innerHTML=""),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")}destroy(){this.clearImageCloud(),this.resizeTimeout!==null&&clearTimeout(this.resizeTimeout)}}A.AnimationEngine=Lt,A.BOUNCE_PRESETS=yt,A.ClusterPlacementGenerator=Gt,A.CompositeLoader=Vt,A.DEFAULT_CONFIG=b,A.ELASTIC_PRESETS=bt,A.EntryAnimationEngine=Dt,A.FUNCTIONAL_CSS=Zt,A.GoogleDriveLoader=Bt,A.GridPlacementGenerator=Ht,A.ImageCloud=Qt,A.ImageFilter=Jt,A.ImageGallery=Qt,A.LayoutEngine=Wt,A.RadialPlacementGenerator=Ut,A.RandomPlacementGenerator=Pt,A.SpiralPlacementGenerator=jt,A.StaticImageLoader=Xt,A.WAVE_PATH_PRESETS=vt,A.ZoomEngine=Yt,A.animatePath=$t,A.injectFunctionalStyles=Kt,A.requiresJSAnimation=Ot,Object.defineProperty(A,Symbol.toStringTag,{value:"Module"})});
5
45
  //# sourceMappingURL=image-cloud.umd.js.map