@michaelyagi/shoji 0.1.0-alpha.6

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.
Files changed (67) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +81 -0
  3. package/dist/esm/core/EventBus.d.ts +16 -0
  4. package/dist/esm/core/FocusTrap.d.ts +9 -0
  5. package/dist/esm/core/Gallery.d.ts +221 -0
  6. package/dist/esm/core/GestureController.d.ts +50 -0
  7. package/dist/esm/core/LiveRegion.d.ts +6 -0
  8. package/dist/esm/core/SlideManager.d.ts +83 -0
  9. package/dist/esm/core/bodyScrollLock.d.ts +2 -0
  10. package/dist/esm/core/dom.d.ts +27 -0
  11. package/dist/esm/core/icons.d.ts +6 -0
  12. package/dist/esm/core/index.d.ts +5 -0
  13. package/dist/esm/core/index.js +1966 -0
  14. package/dist/esm/core/index.js.map +1 -0
  15. package/dist/esm/core/plugin.d.ts +54 -0
  16. package/dist/esm/core/rotateFlipNormalize.d.ts +19 -0
  17. package/dist/esm/core/scan.d.ts +8 -0
  18. package/dist/esm/core/types.d.ts +268 -0
  19. package/dist/esm/core/zoomTransition.d.ts +33 -0
  20. package/dist/esm/gestures/GestureEngine.d.ts +78 -0
  21. package/dist/esm/index.css +475 -0
  22. package/dist/esm/index.d.ts +32 -0
  23. package/dist/esm/index.js +24 -0
  24. package/dist/esm/index.js.map +1 -0
  25. package/dist/esm/index2.css +22 -0
  26. package/dist/esm/index3.css +166 -0
  27. package/dist/esm/index4.css +27 -0
  28. package/dist/esm/plugins/activeThumbnail/index.d.ts +26 -0
  29. package/dist/esm/plugins/activeThumbnail/index.js +48 -0
  30. package/dist/esm/plugins/activeThumbnail/index.js.map +1 -0
  31. package/dist/esm/plugins/autoplay/icons.d.ts +3 -0
  32. package/dist/esm/plugins/autoplay/index.d.ts +17 -0
  33. package/dist/esm/plugins/autoplay/index.js +177 -0
  34. package/dist/esm/plugins/autoplay/index.js.map +1 -0
  35. package/dist/esm/plugins/fullscreen/icons.d.ts +3 -0
  36. package/dist/esm/plugins/fullscreen/index.d.ts +17 -0
  37. package/dist/esm/plugins/fullscreen/index.js +74 -0
  38. package/dist/esm/plugins/fullscreen/index.js.map +1 -0
  39. package/dist/esm/plugins/layout/index.d.ts +191 -0
  40. package/dist/esm/plugins/layout/index.js +746 -0
  41. package/dist/esm/plugins/layout/index.js.map +1 -0
  42. package/dist/esm/plugins/layout/justified.d.ts +68 -0
  43. package/dist/esm/plugins/layout/masonry.d.ts +92 -0
  44. package/dist/esm/plugins/rotateFlip/icons.d.ts +5 -0
  45. package/dist/esm/plugins/rotateFlip/index.d.ts +17 -0
  46. package/dist/esm/plugins/rotateFlip/index.js +138 -0
  47. package/dist/esm/plugins/rotateFlip/index.js.map +1 -0
  48. package/dist/esm/plugins/video/index.d.ts +13 -0
  49. package/dist/esm/plugins/video/index.js +95 -0
  50. package/dist/esm/plugins/video/index.js.map +1 -0
  51. package/dist/esm/plugins/video/youtube.d.ts +61 -0
  52. package/dist/esm/plugins/zoom/icons.d.ts +4 -0
  53. package/dist/esm/plugins/zoom/index.d.ts +30 -0
  54. package/dist/esm/plugins/zoom/index.js +274 -0
  55. package/dist/esm/plugins/zoom/index.js.map +1 -0
  56. package/dist/esm/plugins/zoom/zoomMath.d.ts +24 -0
  57. package/dist/esm/transitions/SlideTransition.d.ts +25 -0
  58. package/dist/esm/transitions/presets.d.ts +21 -0
  59. package/dist/esm/zoomTransition-bbKHpVpA.js +110 -0
  60. package/dist/esm/zoomTransition-bbKHpVpA.js.map +1 -0
  61. package/dist/shoji.css +690 -0
  62. package/dist/shoji.js +3605 -0
  63. package/dist/shoji.js.map +1 -0
  64. package/dist/shoji.min.css +1 -0
  65. package/dist/shoji.min.js +2 -0
  66. package/dist/shoji.min.js.map +1 -0
  67. package/package.json +77 -0
@@ -0,0 +1 @@
1
+ .shoji-autoplay-progress{position:absolute;left:0;right:0;bottom:0;height:3px;background:#ffffff26;z-index:var(--shoji-z-toolbar)}.shoji-autoplay-progress[hidden]{display:none}.shoji-autoplay-progress-bar{height:100%;width:0%;background:var(--shoji-progress)}.shoji-layout{position:relative}.shoji-layout--masonry,.shoji-layout--justified{contain:layout style}.shoji-layout-tile{display:block;cursor:pointer}.shoji-layout-tile img{display:block;width:100%;height:100%;object-fit:cover}.shoji-layout--masonry .shoji-layout-tile,.shoji-layout--justified .shoji-layout-tile{position:absolute;top:0;left:0;visibility:hidden}.shoji-layout--masonry.shoji-layout--animate .shoji-layout-tile,.shoji-layout--justified.shoji-layout--animate .shoji-layout-tile{transition:transform var(--shoji-duration) var(--shoji-easing)}.shoji-layout--grid{display:grid;grid-template-columns:repeat(auto-fill,minmax(var(--shoji-layout-column-width, 240px),1fr));gap:var(--shoji-layout-gutter, 8px)}.shoji-layout--grid .shoji-layout-tile{aspect-ratio:var(--shoji-layout-tile-aspect, 1)}.shoji-layout-heading{margin:0}.shoji-layout--grid .shoji-layout-heading{grid-column:1 / -1}.shoji-layout--masonry .shoji-layout-heading,.shoji-layout--justified .shoji-layout-heading{position:absolute;top:0;left:0;width:100%}.shoji-layout--justified .shoji-layout-heading{width:auto;white-space:nowrap}.shoji-layout--masonry.shoji-layout--animate .shoji-layout-heading,.shoji-layout--justified.shoji-layout--animate .shoji-layout-heading{transition:transform var(--shoji-duration) var(--shoji-easing)}.shoji-layout-heading{font-family:var(--shoji-layout-heading-font-family, inherit)}.shoji-layout-heading-title{font-size:var(--shoji-layout-heading-title-font-size, .875rem);font-weight:var(--shoji-layout-heading-title-font-weight, 400);color:var(--shoji-layout-heading-title-color, #767676);overflow-wrap:break-word}.shoji-layout-heading-subtitle{margin-left:.6em;font-size:var(--shoji-layout-heading-subtitle-font-size, .875rem);font-weight:var(--shoji-layout-heading-subtitle-font-weight, 700);color:var(--shoji-layout-heading-subtitle-color, inherit);overflow-wrap:break-word}.shoji-layout--grid .shoji-layout-heading--sticky{position:sticky;top:0;z-index:1}.shoji-zoom-enabled{cursor:zoom-in}.shoji-zoom-enabled.shoji-zoomed{cursor:grab;will-change:transform}.shoji-zoom-enabled.shoji-zoomed:active{cursor:grabbing}:root{--shoji-z-base: 9000;--shoji-z-backdrop: 0;--shoji-z-slides: 10;--shoji-z-overlay: 20;--shoji-z-toolbar: 30;--shoji-z-toast: 40;--shoji-color-bg: #0b0b0d;--shoji-color-fg: #f5f5f5;--shoji-color-accent: #4da3ff;--shoji-color-backdrop: rgba(0, 0, 0, .92);--shoji-color-toolbar-bg: rgba(20, 20, 22, .85);--shoji-color-disabled: rgba(245, 245, 245, .35);--shoji-focus-ring: 2px solid var(--shoji-color-accent);--shoji-progress: var(--shoji-color-accent);--shoji-spacing-sm: .5rem;--shoji-spacing-md: 1rem;--shoji-spacing-lg: 1.5rem;--shoji-easing: cubic-bezier(.4, 0, .2, 1);--shoji-duration: .3s;--shoji-caption-max-height: min(8rem, 30%);--shoji-provider-video-top-inset: calc(44px + 2 * var(--shoji-spacing-sm));--shoji-momentum-easing: cubic-bezier(.2, 0, 0, 1);--shoji-font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji"}.shoji-light{--shoji-color-bg: #fafafa;--shoji-color-fg: #111111;--shoji-color-backdrop: rgba(255, 255, 255, .96);--shoji-color-toolbar-bg: rgba(255, 255, 255, .9);--shoji-color-disabled: rgba(17, 17, 17, .35)}@media(prefers-reduced-motion:reduce){:root{--shoji-duration: 0ms}}.shoji-outer{display:none;position:fixed;top:0;right:0;bottom:0;left:0;z-index:var(--shoji-z-base)}.shoji-outer.shoji-open{display:block}.shoji-backdrop{position:absolute;top:0;right:0;bottom:0;left:0;z-index:var(--shoji-z-backdrop);background:var(--shoji-color-backdrop)}.shoji-dialog{position:relative;z-index:var(--shoji-z-slides);display:flex;flex-direction:column;height:100%;color:var(--shoji-color-fg);font-family:var(--shoji-font-family);outline:none;touch-action:none}.shoji-toolbar{position:absolute;inset:0 0 auto 0;z-index:var(--shoji-z-toolbar);display:flex;justify-content:space-between;padding:var(--shoji-spacing-sm);pointer-events:none;will-change:transform}.shoji-toolbar-slot{display:flex;flex-wrap:wrap;align-items:center;gap:var(--shoji-spacing-sm);pointer-events:auto;max-width:45%}.shoji-toolbar-left{justify-content:flex-start}.shoji-toolbar-right{justify-content:flex-end}.shoji-close,.shoji-nav,.shoji-toolbar-button{-webkit-appearance:none;-moz-appearance:none;appearance:none;border:none;padding:0;width:44px;height:44px;border-radius:50%;display:flex;align-items:center;justify-content:center;background:#0006;color:var(--shoji-color-fg);cursor:pointer}.shoji-close:hover,.shoji-nav:hover,.shoji-toolbar-button:hover{background:#0009}.shoji-close:focus-visible,.shoji-nav:focus-visible,.shoji-toolbar-button:focus-visible{outline:var(--shoji-focus-ring);outline-offset:2px}.shoji-nav{position:absolute;top:50%;transform:translateY(-50%);z-index:var(--shoji-z-toolbar)}.shoji-nav-prev{left:var(--shoji-spacing-md)}.shoji-nav-next{right:var(--shoji-spacing-md)}.shoji-nav:disabled{opacity:.3;cursor:default;pointer-events:none}.shoji-close[hidden],.shoji-nav[hidden],.shoji-toolbar-button[hidden]{display:none}.shoji-outer.shoji-slide-loading .shoji-toolbar-button{opacity:.3;cursor:default;pointer-events:none}.shoji-slides{position:relative;flex:1;overflow:hidden}.shoji-slide{position:absolute;top:0;right:0;bottom:0;left:0;display:flex;align-items:center;justify-content:center}.shoji-slide-media{width:100%;height:100%;display:flex;align-items:center;justify-content:center;position:relative}.shoji-slide-img,.shoji-slide-video{display:block;max-width:100%;max-height:100%;object-fit:contain}.shoji-slide-open-placeholder{width:100%;height:100%}.shoji-slide-provider-video{width:100%;height:100%;box-sizing:border-box;padding-top:var(--shoji-provider-video-top-inset)}.shoji-slide-provider-video[hidden]{display:none}.shoji-slide-provider-video iframe{display:block;width:100%;height:100%;border:0}.shoji-video-play-overlay{position:absolute;top:50%;left:50%;transform:translate(-50%,-50%);width:var(--shoji-video-overlay-size, 64px);height:var(--shoji-video-overlay-size, 64px);border-radius:50%;border:none;padding:0;display:flex;align-items:center;justify-content:center;background:var(--shoji-video-overlay-bg, rgba(0, 0, 0, .4));color:var(--shoji-video-overlay-color, var(--shoji-color-fg));cursor:pointer}.shoji-video-play-overlay[hidden]{display:none}.shoji-slide-ghost{position:absolute;top:0;right:0;bottom:0;left:0;z-index:1;pointer-events:none}.shoji-slide-placeholder{color:var(--shoji-color-disabled)}.shoji-slide-spinner{width:var(--shoji-spinner-size, 40px);height:var(--shoji-spinner-size, 40px);border-radius:50%;border:var(--shoji-spinner-thickness, 3px) solid var(--shoji-color-disabled);border-top-color:var(--shoji-color-accent);animation:shoji-spin .8s linear infinite}@keyframes shoji-spin{to{transform:rotate(360deg)}}@media(prefers-reduced-motion:reduce){.shoji-slide-spinner{animation:none}}.shoji-counter{padding:.25rem .6rem;border-radius:999px;background:#0006;font-size:.875rem;white-space:nowrap}.shoji-counter[hidden]{display:none}.shoji-caption{position:absolute;bottom:var(--shoji-spacing-md);left:var(--shoji-spacing-md);z-index:var(--shoji-z-toolbar);width:fit-content;max-width:calc(100% - 2 * var(--shoji-spacing-md));max-height:var(--shoji-caption-max-height);overflow-y:auto;overscroll-behavior:contain;padding:var(--shoji-spacing-sm) var(--shoji-spacing-md);border-radius:8px;background:var(--shoji-color-toolbar-bg);text-align:left}.shoji-caption--video{pointer-events:none}.shoji-caption--video>*{pointer-events:auto}.shoji-caption[hidden]{display:none}.shoji-toolbar,.shoji-nav,.shoji-counter,.shoji-caption{transition:opacity var(--shoji-duration) var(--shoji-easing)}.shoji-controls-hidden .shoji-toolbar,.shoji-controls-hidden .shoji-nav,.shoji-controls-hidden .shoji-counter,.shoji-controls-hidden .shoji-caption{opacity:0;pointer-events:none}.shoji-controls-hidden,.shoji-controls-hidden *{cursor:none!important}.shoji-live-region{position:absolute;width:1px;height:1px;overflow:hidden;clip:rect(0 0 0 0);white-space:nowrap}
@@ -0,0 +1,2 @@
1
+ (function(tt,et){typeof exports=="object"&&typeof module<"u"?module.exports=et():typeof define=="function"&&define.amd?define(et):(tt=typeof globalThis<"u"?globalThis:tt||self,tt.Shoji=et())})(this,(function(){"use strict";var Xi=Object.defineProperty;var _i=(tt,et,mt)=>et in tt?Xi(tt,et,{enumerable:!0,configurable:!0,writable:!0,value:mt}):tt[et]=mt;var p=(tt,et,mt)=>_i(tt,typeof et!="symbol"?et+"":et,mt);let tt=0,et="",mt="";function pe(){tt===0&&(et=document.body.style.overflow,document.body.style.overflow="hidden",mt=document.documentElement.style.overflow,document.documentElement.style.overflow="hidden"),tt++}function me(){tt=Math.max(0,tt-1),tt===0&&(document.body.style.overflow=et,document.documentElement.style.overflow=mt)}class ge{constructor(){p(this,"listeners",new Map)}on(t,e){let n=this.listeners.get(t);return n||(n=new Set,this.listeners.set(t,n)),n.add(e),()=>this.off(t,e)}off(t,e){var n;(n=this.listeners.get(t))==null||n.delete(e)}emit(t,e){const n=this.listeners.get(t);if(n)for(const o of n)o(e)}clear(){this.listeners.clear()}}const ve='<svg viewBox="0 0 24 24" width="24" height="24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round"><path d="M6 6l12 12M18 6L6 18"/></svg>',ye='<svg viewBox="0 0 24 24" width="24" height="24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M15 6l-6 6 6 6"/></svg>',be='<svg viewBox="0 0 24 24" width="24" height="24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M9 6l6 6-6 6"/></svg>',we='<svg viewBox="0 0 24 24" width="28" height="28" fill="currentColor"><path d="M8 5v14l11-7z"/></svg>',Ee='<svg viewBox="0 0 24 24" width="24" height="24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><rect x="3" y="5" width="18" height="14" rx="2"/><path d="M7 10h10M7 14h6"/></svg>';let Se=0;function At(i,t,e){const n=document.createElement("button");return n.type="button",n.className=i,n.ariaLabel=n.title=e,n.innerHTML=t,n}function Ce(i,t){const e=`shoji-counter-${++Se}`,n=document.createElement("div");n.className="shoji-outer";const o=document.createElement("div");o.className="shoji-backdrop",n.appendChild(o);const s=document.createElement("div");s.className="shoji-dialog",s.setAttribute("role","dialog"),s.setAttribute("aria-modal","true"),s.setAttribute("aria-labelledby",e),s.tabIndex=-1;const r=document.createElement("div");r.className="shoji-toolbar";const a=document.createElement("div");a.className="shoji-toolbar-slot shoji-toolbar-left";const l=document.createElement("div");l.className="shoji-toolbar-slot shoji-toolbar-center";const c=document.createElement("div");c.className="shoji-toolbar-slot shoji-toolbar-right";const m=At("shoji-close",ve,t.close),g=At("shoji-toolbar-button shoji-caption-toggle",Ee,t.showCaption);g.setAttribute("aria-pressed","false"),g.hidden=!0,c.append(g,m);const j=document.createElement("div");j.className="shoji-counter",j.id=e,a.appendChild(j),r.append(a,l,c),s.appendChild(r);const L=At("shoji-nav shoji-nav-prev",ye,t.previous),w=At("shoji-nav shoji-nav-next",be,t.next);s.appendChild(L),s.appendChild(w),s.appendChild(i);const T=document.createElement("div");return T.className="shoji-caption",s.appendChild(T),n.appendChild(s),{outer:n,dialog:s,counter:j,caption:T,closeButton:m,prevButton:L,nextButton:w,captionToggleButton:g,toolbarLeft:a,toolbarCenter:l,toolbarRight:c}}const xe='a[href], button:not([disabled]), textarea:not([disabled]), input:not([disabled]), select:not([disabled]), video[controls], [tabindex]:not([tabindex="-1"])';class Le{constructor(){p(this,"container",null);p(this,"previouslyFocused",null);p(this,"onKeydown",t=>{if(t.key!=="Tab"||!this.container)return;const e=this.getFocusable();if(e.length===0){t.preventDefault(),this.container.focus();return}const n=e[0],o=e[e.length-1],s=document.activeElement,r=s instanceof HTMLElement&&e.includes(s);t.shiftKey?(!r||s===n)&&(t.preventDefault(),o.focus()):(!r||s===o)&&(t.preventDefault(),n.focus())})}getFocusable(){return this.container?Array.from(this.container.querySelectorAll(xe)):[]}activate(t){this.previouslyFocused=document.activeElement,this.container=t,document.addEventListener("keydown",this.onKeydown,!0),t.focus()}deactivate(){var t;document.removeEventListener("keydown",this.onKeydown,!0),this.container=null,(t=this.previouslyFocused)==null||t.focus(),this.previouslyFocused=null}}const Me=300,Te=30,je=500;class Ae{constructor(t,e,n){p(this,"target");p(this,"options");p(this,"callbacks");p(this,"pointers",new Map);p(this,"primaryPointerId",null);p(this,"direction",null);p(this,"dragStartDistance",0);p(this,"pinching",!1);p(this,"pinchStartDistance",0);p(this,"lastTapTime",-1/0);p(this,"lastTapX",0);p(this,"lastTapY",0);p(this,"onPointerDown",t=>{var e,n,o,s;if(!(t.isPrimary===!1&&this.pointers.size===0)&&!(this.pointers.size===0&&((n=(e=this.callbacks).ignore)!=null&&n.call(e,t)))){if(this.pointers.set(t.pointerId,{startX:t.clientX,startY:t.clientY,startTime:t.timeStamp,lastX:t.clientX,lastY:t.clientY,lastTime:t.timeStamp}),this.pointers.size===1)this.primaryPointerId=t.pointerId,this.direction=null;else if(this.pointers.size===2){this.direction=null,this.pinching=!0;const[r,a]=[...this.pointers.values()];this.pinchStartDistance=Zt(r,a);const l=qt(r,a);(s=(o=this.callbacks).onPinchStart)==null||s.call(o,l.x,l.y)}}});p(this,"onPointerMove",t=>{var r,a,l,c,m,g,j,L;const e=this.pointers.get(t.pointerId);if(!e)return;if(e.lastX=t.clientX,e.lastY=t.clientY,e.lastTime=t.timeStamp,this.pinching){if(this.pointers.size<2)return;const[w,T]=[...this.pointers.values()],$=Zt(w,T),O=this.pinchStartDistance>0?$/this.pinchStartDistance:1,E=qt(w,T);(a=(r=this.callbacks).onPinchMove)==null||a.call(r,O,E.x,E.y);return}if(t.pointerId!==this.primaryPointerId)return;const n=t.clientX-e.startX,o=t.clientY-e.startY;if(this.direction===null){const w=Math.abs(n),T=Math.abs(o);if(Math.max(w,T)<this.options.lockThreshold)return;this.direction=w>T?"horizontal":"vertical",this.dragStartDistance=this.direction==="horizontal"?n:o,(((c=(l=this.callbacks).shouldCapture)==null?void 0:c.call(l))??!0)&&this.target.setPointerCapture(t.pointerId),(g=(m=this.callbacks).onDragStart)==null||g.call(m,this.direction,t)}this.direction==="horizontal"&&t.preventDefault();const s=(this.direction==="horizontal"?n:o)-this.dragStartDistance;(L=(j=this.callbacks).onDragMove)==null||L.call(j,this.direction,s,t)});p(this,"onPointerUp",t=>{this.finishPointer(t,!1)});p(this,"onPointerCancel",t=>{this.finishPointer(t,!0)});p(this,"onWheel",t=>{var n,o;if(!t.ctrlKey)return;t.preventDefault();const e=-t.deltaY*.01;(o=(n=this.callbacks).onWheelZoom)==null||o.call(n,e,t.clientX,t.clientY,t)});this.target=t,this.callbacks=e,this.options={lockThreshold:(n==null?void 0:n.lockThreshold)??10,swipeThreshold:(n==null?void 0:n.swipeThreshold)??50,swipeVelocity:(n==null?void 0:n.swipeVelocity)??.3},this.target.addEventListener("pointerdown",this.onPointerDown),this.target.addEventListener("pointermove",this.onPointerMove),this.target.addEventListener("pointerup",this.onPointerUp),this.target.addEventListener("pointercancel",this.onPointerCancel),this.target.addEventListener("wheel",this.onWheel,{passive:!1})}destroy(){this.target.removeEventListener("pointerdown",this.onPointerDown),this.target.removeEventListener("pointermove",this.onPointerMove),this.target.removeEventListener("pointerup",this.onPointerUp),this.target.removeEventListener("pointercancel",this.onPointerCancel),this.target.removeEventListener("wheel",this.onWheel),this.pointers.clear()}finishPointer(t,e){var o,s,r,a;const n=this.pointers.get(t.pointerId);if(n){if(n.lastX=t.clientX,n.lastY=t.clientY,n.lastTime=t.timeStamp,this.pointers.delete(t.pointerId),this.pinching){this.pointers.size<2&&(this.pinching=!1,(s=(o=this.callbacks).onPinchEnd)==null||s.call(o));return}if(t.pointerId===this.primaryPointerId){if(this.direction===null)!e&&t.timeStamp-n.startTime<=je&&this.registerTap(n.lastX,n.lastY,t);else{const l=Math.max(1,n.lastTime-n.startTime),c=(this.direction==="horizontal"?n.lastX-n.startX:n.lastY-n.startY)-this.dragStartDistance,m=c/l,g=!e&&(Math.abs(c)>=this.options.swipeThreshold||Math.abs(m)>=this.options.swipeVelocity);(a=(r=this.callbacks).onDragEnd)==null||a.call(r,this.direction,c,m,g,e)}this.primaryPointerId=null,this.direction=null}}}registerTap(t,e,n){var r,a,l,c;const o=n.timeStamp;o-this.lastTapTime<=Me&&Math.hypot(t-this.lastTapX,e-this.lastTapY)<=Te?((a=(r=this.callbacks).onDoubleTap)==null||a.call(r,t,e,n),this.lastTapTime=0):((c=(l=this.callbacks).onTap)==null||c.call(l,t,e,n),this.lastTapTime=o,this.lastTapX=t,this.lastTapY=e)}}function Zt(i,t){return Math.hypot(i.lastX-t.lastX,i.lastY-t.lastY)}function qt(i,t){return{x:(i.lastX+t.lastX)/2,y:(i.lastY+t.lastY)/2}}function Gt(){return typeof window.matchMedia=="function"&&window.matchMedia("(prefers-reduced-motion: reduce)").matches}function Ie(i){var e;const t=((e=i.split(",")[0])==null?void 0:e.trim())??"";return t.endsWith("ms")?parseFloat(t):t.endsWith("s")?parseFloat(t)*1e3:0}function ke(i,t){const e=i.width/i.height,n=t>e?i.width:i.height*t,o=t>e?i.width/t:i.height;return{left:i.left+(i.width-n)/2,top:i.top+(i.height-o)/2,width:n,height:o}}function Pe(i,t){const e=i.firstElementChild,n=e instanceof HTMLElement&&(e.classList.contains("shoji-slide-spinner")||e.classList.contains("shoji-slide-open-placeholder"));if(e instanceof HTMLElement&&!n){const s=e.getBoundingClientRect();if(s.width>0&&s.height>0)return s}const o=i.getBoundingClientRect();return t&&o.width>0&&o.height>0?ke(o,t):o}function Ut(i,t,e){const n=i.getBoundingClientRect(),o=Pe(t,e);if(o.width===0||o.height===0||n.width===0||n.height===0)return null;const s=Math.min(n.width/o.width,n.height/o.height),r=n.left+n.width/2-(o.left+o.width/2),a=n.top+n.height/2-(o.top+o.height/2);return`translate3d(${r}px, ${a}px, 0) scale3d(${s}, ${s}, 1)`}function yt(i,t){const e=Ie(getComputedStyle(i).transitionDuration);let n=!1;const o=()=>{n||(n=!0,i.removeEventListener("transitionend",s),t())},s=r=>{r.target===i&&r.propertyName==="transform"&&o()};i.addEventListener("transitionend",s),setTimeout(o,e+100)}function Kt(i,t){i.style.transition="",i.style.transformOrigin="",i.style.willChange="",i.style.transform===t&&(i.style.transform="")}function He({origin:i,target:t,aspectRatio:e}){if(Gt())return;const n=Ut(i,t,e);n&&(t.style.transition="none",t.style.transformOrigin="center",t.style.willChange="transform",t.style.transform=n,t.offsetHeight,t.style.transition="transform var(--shoji-duration) var(--shoji-easing)",t.style.transform="none",yt(t,()=>Kt(t,"none")))}function Re({origin:i,target:t,aspectRatio:e},n){if(Gt()){n();return}const o=Ut(i,t,e);if(!o){n();return}t.style.transformOrigin="center",t.style.willChange="transform",t.style.transition="transform var(--shoji-duration) var(--shoji-easing)",t.offsetHeight,t.style.transform=o;const s=t.style.transform;yt(t,()=>{Kt(t,s),n()})}const Oe="transform var(--shoji-duration) var(--shoji-momentum-easing)",De="transform var(--shoji-duration) var(--shoji-momentum-easing), opacity var(--shoji-duration) var(--shoji-momentum-easing)",Ne=160;function Be(i){return i.composedPath().some(t=>t instanceof Element&&t.matches("button, video, input, select, textarea, a[href], [data-shoji-no-drag]"))}class Ve{constructor(t,e,n){p(this,"engine");p(this,"onDragMove",(t,e)=>{this.host.isZoomed()||(t==="horizontal"?this.host.slides.setDragOffset(e,null):this.host.canClose()&&this.applyVerticalDragFeedback(e))});p(this,"onDragEnd",(t,e,n,o)=>{this.host.isZoomed()||(t==="horizontal"?this.finishHorizontalDrag(e,o):this.finishVerticalDrag(o))});this.host=t,this.engine=new Ae(t.dialog,{ignore:Be,shouldCapture:()=>!t.isZoomed(),onDragStart:()=>t.onActivity(),onDragMove:this.onDragMove,onDragEnd:this.onDragEnd,onTap:(o,s)=>e.onTap(o,s),onDoubleTap:(o,s)=>e.onDoubleTap(o,s),onPinchStart:(o,s)=>e.onPinchStart(o,s),onPinchMove:(o,s,r)=>e.onPinchMove(o,s,r),onPinchEnd:()=>e.onPinchEnd(),onWheelZoom:(o,s,r)=>e.onWheelZoom(o,s,r)},n)}destroy(){this.engine.destroy()}finishHorizontalDrag(t,e){const n=t<0,o=n?this.host.canGoNext():this.host.canGoPrev();if(!e||t===0||!o){this.settleDragOffset(0,()=>{});return}const s=this.host.dialog.getBoundingClientRect().width||1,r=n?-s:s;this.settleDragOffset(r,()=>{this.host.slides.setDragOffset(0,null),n?this.host.next():this.host.prev()})}settleDragOffset(t,e){const n=this.host.slides.getSlotRoot(0);if(this.host.slides.setDragOffset(t,Oe),!n){e();return}yt(n,e)}applyVerticalDragFeedback(t){const e=Math.min(Math.abs(t)/Ne,1),n=this.host.dialog;n.style.transition="",n.style.transform=`translateY(${t}px) scale(${1-e*.15})`,n.style.opacity=String(1-e*.6)}clearVerticalDragFeedback(t){const e=this.host.dialog;e.style.transition=t?De:"",e.style.transform="",e.style.opacity=""}finishVerticalDrag(t){t&&this.host.canClose()?(this.clearVerticalDragFeedback(!1),this.host.close()):this.clearVerticalDragFeedback(!0)}}class $e{constructor(){p(this,"element");this.element=document.createElement("div"),this.element.className="shoji-live-region",this.element.setAttribute("role","status"),this.element.setAttribute("aria-live","polite")}announce(t){this.element.textContent="",this.element.offsetWidth,this.element.textContent=t}}const Bt=":scope > a, :scope > [data-shoji-src], :scope > [data-shoji-video]";function Jt(i,t=Bt){const e=Array.from(i.querySelectorAll(t)),n=[];for(const o of e){const s=We(o)??Ye(o);s&&n.push({element:o,item:s})}return n}function lt(i,t){return i.getAttribute(t)??void 0}function Qt(i,t){const e=i.getAttribute(t);if(e===null)return;const n=Number(e);return Number.isFinite(n)?n:void 0}function Vt(i,t,e){const n=lt(i,"data-shoji-caption");n&&(t.caption=n),t.id=lt(i,"data-shoji-id")??e;let o;for(const s of i.attributes){if(!s.name.startsWith("data-shoji-"))continue;const r=s.name.slice(11);r!=="no-drag"&&!(r in t)&&((o??(o={}))[r]=s.value)}o&&(t.data=o)}function Ye(i){const t=lt(i,"href")??lt(i,"data-shoji-src");if(!t)return;const e={src:t},n=i.querySelector("img"),o=(n==null?void 0:n.getAttribute("src"))??lt(i,"data-shoji-thumb");o&&(e.thumb=o);const s=(n==null?void 0:n.getAttribute("alt"))??lt(i,"data-shoji-alt");s&&(e.alt=s);const r=Qt(i,"data-shoji-width");r!==void 0&&(e.width=r);const a=Qt(i,"data-shoji-height");a!==void 0&&(e.height=a);const l=lt(i,"data-shoji-srcset");l&&(e.srcset=l);const c=lt(i,"data-shoji-sizes");return c&&(e.sizes=c),Vt(i,e,t),e}function We(i){var n;const t=i.querySelector("video");if(t){const o=Array.from(t.querySelectorAll("source")).map(l=>({src:l.getAttribute("src")??"",type:l.getAttribute("type")??""})).filter(l=>l.src),s=t.getAttribute("src")??((n=o[0])==null?void 0:n.src);if(!s)return;const r={src:s,video:{provider:"html5"}};o.length&&(r.sources=o);const a=t.getAttribute("poster");return a&&(r.poster=a),Vt(i,r,s),r}const e=lt(i,"data-shoji-video");if(e){const o=ze(e),s=o?{src:e,video:{provider:"youtube",id:o,url:e}}:{src:e,video:{provider:"html5"},sources:[{src:e,type:Fe(e)}]},r=lt(i,"data-shoji-poster");return r&&(s.poster=r),Vt(i,s,e),s}}function ze(i){let t;try{t=new URL(i,window.location.href)}catch{return}const e=t.hostname.replace(/^(www|m)\./,"");if(e==="youtu.be")return t.pathname.slice(1).split("/")[0]||void 0;if(e!=="youtube.com")return;if(t.pathname==="/watch")return t.searchParams.get("v")??void 0;const n=t.pathname.match(/^\/(?:embed|shorts)\/([^/?]+)/);return n==null?void 0:n[1]}function Fe(i){const t=i.split(/[?#]/)[0]??i,e=t.slice(t.lastIndexOf(".")+1).toLowerCase();return e==="webm"?"video/webm":e==="ogg"||e==="ogv"?"video/ogg":"video/mp4"}const Xe=200;class _e{constructor(t){p(this,"element");p(this,"slots");p(this,"preload");p(this,"playVideoLabel");p(this,"videoProviders");p(this,"dragOffsetPx",0);p(this,"cache",new Map);p(this,"pending",new Map);this.element=document.createElement("div"),this.element.className="shoji-slides",this.preload=t.preload,this.playVideoLabel=t.playVideoLabel,this.videoProviders=t.videoProviders;const e=t.preload*2+1;this.slots=Array.from({length:e},(n,o)=>{const s=o-t.preload,r=document.createElement("div");r.className="shoji-slide";const a=document.createElement("div");return a.className="shoji-slide-media",r.appendChild(a),this.element.appendChild(r),{root:r,media:a,offset:s,assignedIndex:null,ready:!1}}),this.applyTransforms(null)}getActiveMedia(){var t;return((t=this.slots.find(e=>e.offset===0))==null?void 0:t.media)??null}isActiveReady(){var t;return((t=this.slots.find(e=>e.offset===0))==null?void 0:t.ready)??!1}setDragOffset(t,e){this.dragOffsetPx=t,this.applyTransforms(e)}getSlotRoot(t){var e;return((e=this.slots.find(n=>n.offset===t))==null?void 0:e.root)??null}applyTransforms(t){for(const e of this.slots)e.root.style.transition=t??"",e.root.style.transform=`translateX(calc(${e.offset*100}% + ${this.dragOffsetPx}px))`}render(t,e,n,o){var r;for(const[a,l]of this.cache)(a<e-this.preload||a>e+this.preload)&&(te(l.node),this.cache.delete(a));const s=this.slots.map(a=>{const l=e+a.offset,c=l>=0&&l<t.length?t[l]:void 0;return{slot:a,index:l,item:c}});for(const{slot:a,index:l,item:c}of s){if(!c||a.assignedIndex===l)continue;const m=this.cache.get(l);m&&(m.node.classList.contains("shoji-slide-provider-video")||(a.assignedIndex=l,this.moveIn(a,m,l),n(l)))}for(const{slot:a,index:l,item:c}of s){if(!c){a.assignedIndex=null,a.ready=!1,It(a.media),a.media.replaceChildren();continue}a.assignedIndex!==l&&(a.assignedIndex=l,a.ready=!1,It(a.media),a.media.replaceChildren(qe()),l===e&&o&&this.revealOpenPlaceholder(o,a,l),((r=c.video)==null?void 0:r.provider)==="html5"?this.renderVideo(c,a,l,n):c.video?this.renderProviderVideo(c,a,l,n):this.ensureImageDecoding(c,l,n))}}applyAspect(t,e){e.width&&e.height?t.media.style.aspectRatio=`${e.width} / ${e.height}`:t.media.style.removeProperty("aspect-ratio")}swapIn(t,e,n,o,s){It(t.media),this.applyAspect(t,n),s?t.media.replaceChildren(e,s):t.media.replaceChildren(e),t.ready=!0,this.cache.set(o,{node:e,item:n,extra:s})}moveIn(t,e,n){this.applyAspect(t,e.item),e.extra?t.media.replaceChildren(e.node,e.extra):t.media.replaceChildren(e.node),t.ready=!0,this.cache.set(n,e)}ensureImageDecoding(t,e,n){if(this.pending.has(e))return;const o=document.createElement("img");o.className="shoji-slide-img",o.alt=t.alt??"",o.draggable=!1,"fetchPriority"in o&&(o.fetchPriority="high"),t.srcset&&(o.srcset=t.srcset),t.sizes&&(o.sizes=t.sizes),o.src=t.src,this.pending.set(e,o);const s=()=>{this.pending.delete(e);const r={node:o,item:t};this.cache.set(e,r);const a=this.slots.find(l=>l.assignedIndex===e);a&&(this.moveIn(a,r,e),n(e))};typeof o.decode=="function"?o.decode().then(s,s):(o.addEventListener("load",s,{once:!0}),o.addEventListener("error",s,{once:!0}))}revealOpenPlaceholder(t,e,n){const o=Ze(t),s=()=>{var r;e.assignedIndex!==n||e.ready||((r=e.media.querySelector(".shoji-slide-spinner"))==null||r.remove(),e.media.appendChild(o))};typeof o.decode=="function"?o.decode().then(s,s):(o.addEventListener("load",s,{once:!0}),o.addEventListener("error",s,{once:!0}))}renderVideo(t,e,n,o){if(!(!!t.src||!!(t.sources&&t.sources.length>0))){const l=document.createElement("div");l.className="shoji-slide-placeholder",l.textContent="Video",this.swapIn(e,l,t,n),o(n);return}const r=document.createElement("video");if(r.className="shoji-slide-video",r.controls=!0,r.playsInline=!0,t.poster&&(r.poster=t.poster),t.sources&&t.sources.length>0)for(const l of t.sources){const c=document.createElement("source");c.src=l.src,c.type=l.type,r.appendChild(c)}else r.src=t.src;this.swapIn(e,r,t,n,this.createVideoPlayOverlay(r));const a=()=>o(n);r.addEventListener("loadedmetadata",a,{once:!0}),r.addEventListener("error",a,{once:!0})}createVideoPlayOverlay(t){const e=document.createElement("button");e.type="button",e.className="shoji-video-play-overlay",e.innerHTML=we,e.ariaLabel=e.title=this.playVideoLabel,e.hidden=!t.paused;let n=null;const o=()=>{n!==null&&(clearTimeout(n),n=null)};return e.addEventListener("click",s=>{s.stopPropagation(),t.play().catch(()=>{})}),t.addEventListener("play",()=>{o(),e.hidden=!0}),t.addEventListener("pause",()=>{o(),n=setTimeout(()=>{n=null,t.paused&&(e.hidden=!1)},Xe)}),t.addEventListener("ended",()=>{o(),e.hidden=!1}),e}renderProviderVideo(t,e,n,o){const s=t.video,r=s.provider==="custom"?s.render:this.videoProviders.get(s.provider);if(!r){const g=document.createElement("div");g.className="shoji-slide-placeholder",g.textContent="Video",this.swapIn(e,g,t,n),o(n);return}const a=document.createElement("div");a.className="shoji-slide-provider-video",a.hidden=!0;const l=new AbortController;$t.set(a,l),e.media.appendChild(a);let c=!1;r(a,t,()=>{var g;c||l.signal.aborted||(c=!0,a.hidden=!1,(g=e.media.querySelector(".shoji-slide-spinner, .shoji-slide-open-placeholder"))==null||g.remove(),this.applyAspect(e,t),e.ready=!0,this.cache.set(n,{node:a,item:t}),o(n))},l.signal)}destroy(){for(const t of this.slots)It(t.media),t.media.replaceChildren(),t.assignedIndex=null,t.ready=!1;this.cache.clear(),this.pending.clear(),this.element.remove()}}function Ze(i){const t=document.createElement("img");return t.className="shoji-slide-img shoji-slide-open-placeholder",t.alt="",t.draggable=!1,t.src=i,t}function qe(){const i=document.createElement("div");return i.className="shoji-slide-spinner",i.setAttribute("aria-hidden","true"),i}const $t=new WeakMap;function It(i){const t=i.querySelector("video");t&&te(t);const e=i.querySelector(".shoji-slide-provider-video");e&&ee(e)}function te(i){if(i.tagName!=="VIDEO"){ee(i);return}const t=i;t.pause(),t.removeAttribute("src"),t.load()}function ee(i){const t=$t.get(i);t&&($t.delete(i),t.abort())}function ie(i,t){const e=i.directional?t:1,n=[];i.perspective&&n.push(`perspective(${i.perspective}px)`);const o=i.translateX!==void 0?i.translateX*e:0,s=i.translateY??0;return(o!==0||s!==0)&&n.push(`translate(${o}%, ${s}%)`),i.rotateY!==void 0&&n.push(`rotateY(${i.rotateY*e}deg)`),i.rotateX!==void 0&&n.push(`rotateX(${i.rotateX}deg)`),i.rotateZ!==void 0&&n.push(`rotateZ(${i.rotateZ*e}deg)`),i.scale!==void 0&&n.push(`scale(${i.scale})`),{transform:n.length>0?n.join(" "):"none",opacity:i.opacity??1}}function _(i){return{name:i.name,enter:t=>ie(i.enter,t),leave:t=>ie(i.leave,t)}}const Ge=[_({name:"slide",enter:{directional:!0,translateX:100},leave:{directional:!0,translateX:-100}}),_({name:"fade",enter:{opacity:0},leave:{opacity:0}}),_({name:"zoom",enter:{scale:.6,opacity:0},leave:{scale:1.4,opacity:0}}),_({name:"deck",enter:{translateY:6,scale:.85,opacity:0},leave:{translateY:-4,scale:.92,opacity:0}}),_({name:"slideVertical",enter:{directional:!0,translateY:100},leave:{directional:!0,translateY:-100}}),_({name:"push",enter:{directional:!0,translateX:120},leave:{directional:!0,translateX:-120}}),_({name:"fadeUp",enter:{translateY:12,opacity:0},leave:{translateY:-12,opacity:0}}),_({name:"fadeDown",enter:{translateY:-12,opacity:0},leave:{translateY:12,opacity:0}}),_({name:"fadeLeft",enter:{translateX:-12,opacity:0},leave:{translateX:12,opacity:0}}),_({name:"fadeRight",enter:{translateX:12,opacity:0},leave:{translateX:-12,opacity:0}}),_({name:"zoomOut",enter:{scale:1.4,opacity:0},leave:{scale:.6,opacity:0}}),_({name:"scaleUp",enter:{scale:.7},leave:{scale:1.3}}),_({name:"scaleDown",enter:{scale:1.3},leave:{scale:.7}}),_({name:"rotate",enter:{rotateZ:15,opacity:0},leave:{rotateZ:-15,opacity:0}}),_({name:"rotateLeft",enter:{directional:!0,rotateZ:-25,opacity:0},leave:{directional:!0,rotateZ:25,opacity:0}}),_({name:"rotateRight",enter:{directional:!0,rotateZ:25,opacity:0},leave:{directional:!0,rotateZ:-25,opacity:0}}),_({name:"flipX",enter:{rotateX:90,perspective:1200,opacity:0},leave:{rotateX:-90,perspective:1200,opacity:0}}),_({name:"flipY",enter:{directional:!0,rotateY:90,perspective:1200,opacity:0},leave:{directional:!0,rotateY:-90,perspective:1200,opacity:0}}),_({name:"cube",enter:{directional:!0,rotateY:70,translateX:40,perspective:1600,opacity:1},leave:{directional:!0,rotateY:-70,translateX:-40,perspective:1600,opacity:1}}),_({name:"coverflow",enter:{directional:!0,rotateY:35,translateX:60,scale:.8,perspective:1400,opacity:0},leave:{directional:!0,rotateY:-35,translateX:-60,scale:.8,perspective:1400,opacity:0}}),_({name:"drop",enter:{translateY:-30,opacity:0},leave:{translateY:20,opacity:0}})],Ue=Object.fromEntries(Ge.map(i=>[i.name,i]));function Ke(){return typeof window.matchMedia=="function"&&window.matchMedia("(prefers-reduced-motion: reduce)").matches}function ne(i){var e;const t=((e=i.split(",")[0])==null?void 0:e.trim())??"";return t.endsWith("ms")?parseFloat(t):t.endsWith("s")?parseFloat(t)*1e3:0}function oe(i,t){const e=getComputedStyle(i),n=Math.max(ne(e.transitionDuration),ne(e.animationDuration));let o=!1;const s=()=>{o||(o=!0,i.removeEventListener("transitionend",r),i.removeEventListener("animationend",r),t())},r=a=>{a.target===i&&s()};i.addEventListener("transitionend",r),i.addEventListener("animationend",r),setTimeout(s,n+100)}function Je(i,t,e){i.style.transition="none",i.style.transformOrigin="center",i.style.transform=t,i.style.opacity=String(e),i.offsetHeight,i.style.transition="transform var(--shoji-duration) var(--shoji-easing), opacity var(--shoji-duration) var(--shoji-easing)",i.style.transform="none",i.style.opacity="1"}function Qe(i,t,e){i.style.transformOrigin="center",i.style.transition="transform var(--shoji-duration) var(--shoji-easing), opacity var(--shoji-duration) var(--shoji-easing)",i.offsetHeight,i.style.transform=t,i.style.opacity=String(e)}function ti(i){i.style.transition="",i.style.transform="",i.style.opacity="",i.style.transformOrigin=""}class ei{constructor(t){this.slides=t}animate(t,e,n){this.run(n,(o,s)=>{const r=t.leave(e);Qe(o,r.transform,r.opacity);const a=t.enter(e);Je(s,a.transform,a.opacity)})}animateCustom(t,e,n){const o=e===1?"next":"prev";this.run(n,(s,r)=>{s.dataset.shojiDirection=o,s.classList.add(`shoji-transition-${t}-leave`),r.dataset.shojiDirection=o,r.classList.add(`shoji-transition-${t}-enter`)},s=>{s.classList.remove(`shoji-transition-${t}-enter`),delete s.dataset.shojiDirection})}run(t,e,n=ti){if(Ke()){t();return}const o=this.slides.getActiveMedia();if(!o){t();return}const s=document.createElement("div");s.className="shoji-slide-ghost",s.appendChild(o.cloneNode(!0)),this.slides.element.appendChild(s),s.offsetHeight,t();const r=this.slides.getActiveMedia();if(!r){s.remove();return}e(s,r),oe(s,()=>s.remove()),oe(r,()=>n(r))}}function Yt(i){return i.id??i.src}function ii(i){if(typeof i!="string")return i;const t=document.querySelector(i);if(!t)throw new Error(`Shoji: no element matches selector "${i}"`);return t}const kt=new WeakMap,Wt=new Set,se={close:"Close",previous:"Previous image",next:"Next image",playVideo:"Play video",showCaption:"Show caption",hideCaption:"Hide caption"};function ni(i){return!i.composedPath().some(t=>t instanceof Element&&t.matches(".shoji-slide-img, button, video, .shoji-counter, .shoji-caption"))}function oi(i){return typeof i=="object"&&i!==null&&typeof i.dangerouslySetInnerHTML=="string"}class si{constructor(t,e={}){p(this,"options",{});p(this,"element");p(this,"bus",new ge);p(this,"selector",Bt);p(this,"isDynamicMode",!1);p(this,"preload",1);p(this,"locale",se);p(this,"showCounter",!0);p(this,"captionVisibleOnVideo",!1);p(this,"loop",!0);p(this,"closable",!0);p(this,"autoHideDelay",5e3);p(this,"focusTrap",new Le);p(this,"liveRegion",new $e);p(this,"autoHideTimer",null);p(this,"autoHidden",!1);p(this,"hoveredControlCount",0);p(this,"isClosing",!1);p(this,"itemList",[]);p(this,"scannedElements",[]);p(this,"activeIndex",0);p(this,"opened",!1);p(this,"destroyed",!1);p(this,"slides",null);p(this,"dom",null);p(this,"gesture",null);p(this,"transition",null);p(this,"shortcuts",new Map);p(this,"pluginStorage",new Map);p(this,"activePluginNames",new Set);p(this,"videoProviders",new Map);p(this,"zoomGate",null);p(this,"pluginCleanups",[]);p(this,"onContainerClick",t=>{let e=t.target;for(;e&&e!==this.element;){if(e instanceof HTMLElement){const n=this.scannedElements.indexOf(e);if(n!==-1){t.preventDefault(),this.open(n);return}}e=e.parentNode}});p(this,"onOuterClick",t=>{this.closable&&ni(t)&&this.close()});p(this,"onActivity",()=>{this.autoHideDelay!==0&&(this.showControls(),this.scheduleAutoHide())});p(this,"onKeydown",t=>{if(!(document.activeElement instanceof HTMLVideoElement&&t.key!=="Escape")){switch(this.onActivity(),t.key){case"Escape":this.closable&&this.close();break;case"ArrowLeft":case"a":case"A":this.prev();break;case"ArrowRight":case"d":case"D":this.next();break;case"Home":this.goTo(0);break;case"End":this.goTo(this.itemList.length-1);break;default:{const e=this.shortcuts.get(t.key);if(!e)return;e(t)}}t.preventDefault()}});this.element=ii(t),kt.set(this.element,this),Wt.add(this),this.applyOptions(e)}static getInstance(t){return kt.get(t)}static instances(){return Wt.values()}applyOptions(t){if(this.options=t,this.selector=t.selector??Bt,this.isDynamicMode=t.items!==void 0,this.preload=t.preload??1,this.locale={...se,...t.locale},this.showCounter=t.counter??!0,this.loop=t.loop??!0,this.closable=t.closable??!0,this.autoHideDelay=t.autoHideDelay??5e3,this.activeIndex=0,this.scannedElements=[],this.isDynamicMode)this.itemList=t.items??[];else{const e=Jt(this.element,this.selector);this.itemList=e.map(n=>n.item),this.scannedElements=e.map(n=>n.element),this.element.addEventListener("click",this.onContainerClick)}this.ensureLightbox(),this.dom.closeButton.hidden=!this.closable,t.openOnInit&&this.itemList.length>0&&this.open(t.index??0)}get items(){return this.itemList}get currentIndex(){return this.activeIndex}get isOpen(){return this.opened}get isDestroyed(){return this.destroyed}get controlsHidden(){return this.autoHidden}getActivePlugins(){return[...this.activePluginNames]}getActiveMedia(){var t;return((t=this.slides)==null?void 0:t.getActiveMedia())??null}registerZoomGate(t){return this.zoomGate=t,()=>{this.zoomGate===t&&(this.zoomGate=null)}}on(t,e){return this.bus.on(t,e)}clampToRange(t){return Math.min(Math.max(t,0),Math.max(this.itemList.length-1,0))}ensureLightbox(){if(this.dom)return;this.slides=new _e({preload:this.preload,playVideoLabel:this.locale.playVideo,videoProviders:this.videoProviders}),this.transition=new ei(this.slides);const t=Ce(this.slides.element,this.locale);this.dom=t,t.outer.appendChild(this.liveRegion.element),t.closeButton.addEventListener("click",()=>this.close()),t.prevButton.addEventListener("click",()=>this.prev()),t.nextButton.addEventListener("click",()=>this.next()),t.captionToggleButton.addEventListener("click",()=>{this.captionVisibleOnVideo=!this.captionVisibleOnVideo,this.updateCaptionVisibility()}),t.outer.addEventListener("click",this.onOuterClick),t.outer.addEventListener("pointermove",this.onActivity,{passive:!0}),t.outer.addEventListener("pointerdown",this.onActivity,{passive:!0}),t.outer.addEventListener("touchstart",this.onActivity,{passive:!0}),t.outer.addEventListener("wheel",this.onActivity,{passive:!0}),t.outer.addEventListener("focusin",this.onActivity),t.outer.addEventListener("focusout",()=>this.scheduleAutoHide());for(const e of[t.closeButton,t.prevButton,t.nextButton,t.captionToggleButton,t.caption,t.counter,t.toolbarLeft,t.toolbarCenter,t.toolbarRight])this.wireControlHover(e);document.body.appendChild(t.outer),this.gesture=new Ve({dialog:t.dialog,slides:this.slides,canGoNext:()=>this.loop||this.activeIndex<this.itemList.length-1,canGoPrev:()=>this.loop||this.activeIndex>0,next:()=>this.navigate(this.nextIndex(),1,!1),prev:()=>this.navigate(this.prevIndex(),-1,!1),close:()=>this.close(),canClose:()=>this.closable,onActivity:()=>this.onActivity(),isZoomed:()=>{var e;return((e=this.zoomGate)==null?void 0:e.call(this))??!1}},{onTap:(e,n)=>this.bus.emit("tap",{x:e,y:n}),onDoubleTap:(e,n)=>this.bus.emit("doubleTap",{x:e,y:n}),onPinchStart:(e,n)=>this.bus.emit("pinchStart",{centerX:e,centerY:n}),onPinchMove:(e,n,o)=>this.bus.emit("pinchMove",{scale:e,centerX:n,centerY:o}),onPinchEnd:()=>this.bus.emit("pinchEnd",{}),onWheelZoom:(e,n,o)=>this.bus.emit("wheelZoom",{deltaScale:e,x:n,y:o})},this.options.gestures),this.initPlugins()}initPlugins(){this.activePluginNames.clear(),this.videoProviders.clear();for(const t of this.options.plugins??[]){if(!t||typeof t.init!="function"){console.error("Shoji: skipping an invalid plugins[] entry (not a ShojiPlugin object):",t);continue}const e=(t.requires??[]).filter(r=>!this.activePluginNames.has(r));if(e.length>0){console.error(`Shoji: plugin "${t.name}" requires [${e.join(", ")}] to be registered first — skipping.`);continue}const n={...t.defaults,...this.options[t.name]},o={gallery:this,options:n,on:this.on.bind(this),emit:(r,a)=>this.bus.emit(r,a),ui:{toolbar:(r,a)=>this.pluginToolbar(r,a),overlay:(r,a)=>this.pluginOverlay(r,a),outer:()=>this.dom.outer,registerShortcut:(r,a)=>(this.shortcuts.set(r,a),()=>this.shortcuts.delete(r)),registerVideoProvider:(r,a)=>(this.videoProviders.set(r,a),()=>{this.videoProviders.get(r)===a&&this.videoProviders.delete(r)})},storage:{get:r=>this.pluginStorage.get(r),set:(r,a)=>{this.pluginStorage.set(r,a)}}},s=t.init(o);typeof s=="function"&&this.pluginCleanups.push(s),this.activePluginNames.add(t.name)}}pluginToolbar(t,e){const n=this.dom,o=e instanceof HTMLElement,s=o?e:this.buildToolbarButton(e),r=o?this.wireControlHover(s):null;return t==="right"?n.toolbarRight.insertBefore(s,n.closeButton):(t==="left"?n.toolbarLeft:n.toolbarCenter).appendChild(s),()=>{r==null||r(),s.remove()}}buildToolbarButton(t){const e=document.createElement("button");return e.type="button",e.className="shoji-toolbar-button",t.icon?(e.ariaLabel=e.title=t.label,e.innerHTML=t.icon):e.textContent=t.label,e.addEventListener("click",t.onClick),this.wireControlHover(e),e}pluginOverlay(t,e){e!==void 0&&(t.style.zIndex=String(e)),this.dom.dialog.appendChild(t);const n=this.wireControlHover(t);return()=>{n(),t.remove()}}wireControlHover(t){let e=!1;const n=()=>{e=!0,this.hoveredControlCount++,this.onActivity()},o=()=>{e=!1,this.hoveredControlCount--,this.scheduleAutoHide()};return t.addEventListener("pointerenter",n),t.addEventListener("pointerleave",o),()=>{t.removeEventListener("pointerenter",n),t.removeEventListener("pointerleave",o),e&&(e=!1,this.hoveredControlCount--,this.scheduleAutoHide())}}isControlActive(){return this.hoveredControlCount>0}getOriginElement(t){const e=this.itemList[t];if(e!=null&&e.id&&typeof CSS<"u"&&typeof CSS.escape=="function"){const n=document.querySelector(`[data-shoji-id="${CSS.escape(e.id)}"]`);if(n)return n}return this.scannedElements[t]??null}scheduleAutoHide(){if(this.autoHideTimer!==null&&(clearTimeout(this.autoHideTimer),this.autoHideTimer=null),!!this.opened){if(this.autoHideDelay===0){this.hideControls();return}this.autoHideTimer=setTimeout(()=>this.hideControls(),this.autoHideDelay)}}hideControls(){!this.dom||this.autoHidden||this.isControlActive()||(this.autoHidden=!0,this.dom.dialog.classList.add("shoji-controls-hidden"),this.bus.emit("controls:hide",{}))}showControls(){!this.dom||!this.autoHidden||(this.autoHidden=!1,this.dom.dialog.classList.remove("shoji-controls-hidden"),this.bus.emit("controls:show",{}))}renderCaption(t,e){return e instanceof HTMLElement?(t.replaceChildren(e),!1):oi(e)?(t.innerHTML=e.dangerouslySetInnerHTML,e.dangerouslySetInnerHTML===""):(t.textContent=e??"",!e)}setSlideLoading(t){if(this.dom){this.dom.outer.classList.toggle("shoji-slide-loading",t);for(const e of this.dom.outer.querySelectorAll(".shoji-toolbar-button"))e.ariaDisabled=t?"true":null,t?e.tabIndex=-1:e.removeAttribute("tabindex")}}updateCaptionVisibility(){if(!this.dom||!this.slides)return;const t=this.itemList[this.activeIndex],e=this.renderCaption(this.dom.caption,t==null?void 0:t.caption),n=!!(t!=null&&t.video);this.dom.caption.classList.toggle("shoji-caption--video",n);const o=n&&!this.captionVisibleOnVideo;this.dom.caption.hidden=e||!this.slides.isActiveReady()||o;const s=this.dom.captionToggleButton;s.hidden=!n||e,s.hidden||(s.setAttribute("aria-pressed",String(this.captionVisibleOnVideo)),s.ariaLabel=s.title=this.captionVisibleOnVideo?this.locale.hideCaption:this.locale.showCaption)}renderCurrentSlide(t){if(!this.slides||!this.dom)return;const e=this.dom;this.slides.render(this.itemList,this.activeIndex,r=>{r===this.activeIndex&&(this.bus.emit("slideItemLoad",{index:r}),this.setSlideLoading(!1),this.updateCaptionVisibility())},t),this.setSlideLoading(!this.slides.isActiveReady());const n=this.itemList[this.activeIndex],o=this.itemList.length;e.counter.textContent=o>0?`${this.activeIndex+1} / ${o}`:"",e.counter.hidden=!this.showCounter||o===0,this.updateCaptionVisibility();const s=`Image ${this.activeIndex+1} of ${o}${n!=null&&n.alt?`: ${n.alt}`:""}`;this.liveRegion.announce(s),e.prevButton.hidden=o<=1,e.nextButton.hidden=o<=1,e.prevButton.disabled=!this.loop&&this.activeIndex<=0,e.nextButton.disabled=!this.loop&&this.activeIndex>=o-1}open(t=this.options.index??0){var o;if(this.destroyed||this.opened)return;this.bus.emit("beforeOpen",{index:t}),this.ensureLightbox(),this.opened=!0,this.activeIndex=t,this.captionVisibleOnVideo=!!this.options.showVideoCaption,pe();const e=this.getOriginElement(t);this.renderCurrentSlide(this.resolveOpenPlaceholderSrc(this.itemList[t],e)),this.dom.outer.classList.add("shoji-open"),document.addEventListener("keydown",this.onKeydown),this.focusTrap.activate(this.dom.dialog),this.scheduleAutoHide(),this.applyMobileControlsSetting();const n=(o=this.slides)==null?void 0:o.getActiveMedia();n&&e&&He({origin:e,target:n,aspectRatio:this.resolveAspectRatio(t,e)}),this.bus.emit("open",{index:t}),this.bus.emit("afterOpen",{index:t})}resolveOpenPlaceholderSrc(t,e){if(t!=null&&t.thumb)return t.thumb;const n=e==null?void 0:e.getAttribute("data-shoji-thumb");if(n)return n;const o=e==null?void 0:e.querySelector("img");return(o==null?void 0:o.currentSrc)||(o==null?void 0:o.src)||void 0}goTo(t,e){if(this.destroyed||!this.opened||this.itemList.length===0)return;const n=this.clampToRange(t);if(n===this.activeIndex)return;const o=n>this.activeIndex?1:-1;this.navigate(n,o,(e==null?void 0:e.animate)??!0)}next(){this.navigate(this.nextIndex(),1,!0)}prev(){this.navigate(this.prevIndex(),-1,!0)}nextIndex(){return this.activeIndex>=this.itemList.length-1&&this.loop?0:this.activeIndex+1}prevIndex(){return this.activeIndex<=0&&this.loop?this.itemList.length-1:this.activeIndex-1}navigate(t,e,n){if(this.destroyed||!this.opened||this.itemList.length===0)return;const o=this.clampToRange(t);if(o===this.activeIndex)return;const s=this.activeIndex;this.bus.emit("beforeSlide",{from:s,to:o}),this.activeIndex=o;const r=()=>this.renderCurrentSlide();if(n&&this.transition){const a=this.resolveTransitionMode(),l=Ue[a];l?this.transition.animate(l,e,r):this.transition.animateCustom(a,e,r)}else r();this.bus.emit("afterSlide",{from:s,to:o})}resolveTransitionMode(){var t;return this.isMobileQuery()&&((t=this.options.mobileSettings)!=null&&t.mode)?this.options.mobileSettings.mode:this.options.mode??"slide"}isMobileQuery(){return typeof window.matchMedia=="function"&&window.matchMedia("(pointer: coarse)").matches}applyMobileControlsSetting(){var t;this.isMobileQuery()&&((t=this.options.mobileSettings)==null?void 0:t.controls)===!1&&this.hideControls()}close(){var n;if(this.destroyed||!this.opened||this.isClosing)return;this.bus.emit("beforeClose",{}),this.isClosing=!0;const t=(n=this.slides)==null?void 0:n.getActiveMedia(),e=this.getOriginElement(this.activeIndex);if(t&&e){const o=this.resolveAspectRatio(this.activeIndex,e);Re({origin:e,target:t,aspectRatio:o},()=>this.finishClose())}else this.finishClose()}resolveAspectRatio(t,e){const n=this.itemList[t];if(n!=null&&n.width&&n.height)return n.width/n.height;const o=e==null?void 0:e.querySelector("img");if(o!=null&&o.naturalWidth&&o.naturalHeight)return o.naturalWidth/o.naturalHeight}finishClose(){var t,e;this.opened&&(this.isClosing=!1,this.opened=!1,me(),document.removeEventListener("keydown",this.onKeydown),this.focusTrap.deactivate(),(t=this.dom)==null||t.outer.classList.remove("shoji-open"),this.autoHideTimer!==null&&(clearTimeout(this.autoHideTimer),this.autoHideTimer=null),this.autoHidden=!1,this.hoveredControlCount=0,(e=this.dom)==null||e.dialog.classList.remove("shoji-controls-hidden"),this.bus.emit("close",{}),this.bus.emit("afterClose",{}))}updateSlides(t,e){if(this.destroyed)return;const n=this.itemList[this.activeIndex],o=n?Yt(n):void 0;this.itemList=t;let s=e;if(s===void 0&&o!==void 0){const r=t.findIndex(a=>Yt(a)===o);r!==-1&&(s=r)}this.activeIndex=Math.min(Math.max(s??this.activeIndex,0),Math.max(t.length-1,0)),this.opened&&this.renderCurrentSlide(),this.bus.emit("itemsUpdated",{items:this.itemList})}addSlides(t,e){if(this.destroyed)return;const n=[...this.itemList];n.splice(e??n.length,0,...t),this.updateSlides(n)}removeSlides(t){if(this.destroyed)return;const e=Array.isArray(t)?t:[t],n=new Set(e.filter(r=>typeof r=="number")),o=new Set(e.filter(r=>typeof r=="string")),s=this.itemList.filter((r,a)=>!n.has(a)&&!o.has(Yt(r)));this.updateSlides(s)}refresh(){if(this.destroyed)return;if(this.isDynamicMode){console.warn("Shoji: refresh() is a no-op in dynamic mode — call updateSlides() instead.");return}const t=Jt(this.element,this.selector);this.scannedElements=t.map(e=>e.element),this.updateSlides(t.map(e=>e.item))}teardown(){var t,e,n;this.opened&&(this.isClosing||this.bus.emit("beforeClose",{}),this.finishClose());for(const o of this.pluginCleanups)o();this.pluginCleanups=[],this.shortcuts.clear(),this.pluginStorage.clear(),this.activePluginNames.clear(),this.videoProviders.clear(),this.isDynamicMode||this.element.removeEventListener("click",this.onContainerClick),(t=this.gesture)==null||t.destroy(),this.gesture=null,this.transition=null,(e=this.slides)==null||e.destroy(),(n=this.dom)==null||n.outer.remove(),this.slides=null,this.dom=null}destroy(){this.destroyed||(kt.get(this.element)===this&&kt.delete(this.element),Wt.delete(this),this.teardown(),this.bus.emit("destroy",{}),this.bus.clear(),this.destroyed=!0)}reinit(t=this.options){this.destroyed||(this.teardown(),this.bus.clear(),this.applyOptions(t))}}function ri(){return typeof window.matchMedia=="function"&&window.matchMedia("(prefers-reduced-motion: reduce)").matches}const ai={name:"activeThumbnail",defaults:{activeClass:"shoji-thumb-active",scrollIntoView:!0},init(i){const{gallery:t}=i,e=String(i.options.activeClass??"shoji-thumb-active"),n=i.options.scrollIntoView!==!1;let o=null;function s(m){const g=t.getOriginElement(m);o&&o!==g&&o.classList.remove(e),g&&(g.classList.add(e),n&&g.scrollIntoView({block:"nearest",inline:"nearest",behavior:ri()?"auto":"smooth"})),o=g}function r(){o==null||o.classList.remove(e),o=null}const a=i.on("afterOpen",({index:m})=>s(m)),l=i.on("afterSlide",({to:m})=>s(m)),c=i.on("close",r);return()=>{a(),l(),c(),r()}}},re='<svg viewBox="0 0 24 24" width="24" height="24" fill="currentColor"><path d="M8 5v14l11-7z"/></svg>',li='<svg viewBox="0 0 24 24" width="24" height="24" fill="currentColor"><path d="M7 5h4v14H7zM13 5h4v14h-4z"/></svg>';function ci(i){const t=i==null?void 0:i.querySelector("video");if(t)return t;const e=i==null?void 0:i.querySelector(".shoji-slide-provider-video");return e&&typeof e.play=="function"?e:null}function di(i){const t=i==null?void 0:i.querySelector(".shoji-slide-provider-video");return!!t&&typeof t.play!="function"}const hi=400,ui=8,fi={name:"autoplay",defaults:{interval:5e3,showProgress:!0},init(i){const{gallery:t}=i,e=Number(i.options.interval??5e3),n=i.options.showProgress!==!1,o=i.options.locale,s=(o==null?void 0:o.play)??"Play slideshow",r=(o==null?void 0:o.pause)??"Pause slideshow";let a=!1,l=null,c=null,m=!1;const g=t.getActiveMedia();function j(){a&&A()}g==null||g.addEventListener("error",j);const L=document.createElement("button");L.type="button",L.className="shoji-toolbar-button",L.setAttribute("aria-label",s),L.title=s,L.innerHTML=re;const w=document.createElement("div");w.className="shoji-autoplay-progress",w.hidden=!0;const T=document.createElement("div");T.className="shoji-autoplay-progress-bar",w.appendChild(T);function $(){l!==null&&(clearTimeout(l),l=null)}function O(){n&&(w.hidden=!0,T.style.transition="none",T.style.width="0%")}function E(F){n&&(w.hidden=!1,T.style.transition="none",T.style.width="0%",T.offsetWidth,T.style.transition=`width ${F}ms linear`,T.style.width="100%")}function X(F){a=F,L.innerHTML=F?li:re,L.setAttribute("aria-label",F?r:s),L.title=F?r:s}function N(){a&&A()}function P(){c!=null&&c.ended||J()}function H(){c&&(c.removeEventListener("ended",N),c.removeEventListener("pause",P),c=null)}function Z(F,K){F.muted=!0,F.play(),setTimeout(()=>{c!==F||!a||F.paused&&(K>0?Z(F,K-1):J())},hi)}function C(){if($(),H(),O(),m=!1,!a)return;const F=t.getActiveMedia(),K=ci(F);if(K){if(c=K,K.addEventListener("ended",N),K.addEventListener("pause",P),K instanceof HTMLVideoElement){const dt=K.play();dt&&typeof dt.catch=="function"&&dt.catch(()=>J())}else Z(K,ui);return}m=di(F),E(e),l=setTimeout(A,e)}function A(){const F=t.currentIndex;t.next(),t.currentIndex===F&&J()}function B(){a||(X(!0),i.emit("autoplayStart",{}),C())}function J(){a&&(X(!1),$(),O(),c&&!c.paused&&c.pause(),H(),i.emit("autoplayStop",{}))}function I(){a?J():B()}L.addEventListener("click",I);const V=i.ui.toolbar("right",L),x=n?i.ui.overlay(w):null,ct=i.ui.registerShortcut(" ",I),rt=i.on("afterSlide",()=>{a&&C()}),it=i.on("slideItemLoad",({index:F})=>{a&&m&&F===t.currentIndex&&C()}),wt=i.on("close",()=>J());return()=>{J(),g==null||g.removeEventListener("error",j),V(),x==null||x(),ct(),rt(),it(),wt()}}},ae='<svg viewBox="0 0 24 24" width="24" height="24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M4 9V4h5M20 9V4h-5M4 15v5h5M20 15v5h-5"/></svg>',pi='<svg viewBox="0 0 24 24" width="24" height="24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M9 4v5H4M15 4v5h5M9 20v-5H4M15 20v-5h5"/></svg>';function mi(){return!!(document.fullscreenEnabled||document.webkitFullscreenEnabled)}function gi(){return document.fullscreenElement??document.webkitFullscreenElement??null}function vi(i){var e;const t=i;t.requestFullscreen?t.requestFullscreen().catch(()=>{}):(e=t.webkitRequestFullscreen)==null||e.call(t)}function zt(){var t;const i=document;document.exitFullscreen?document.exitFullscreen().catch(()=>{}):(t=i.webkitExitFullscreen)==null||t.call(i)}const yi={name:"fullscreen",init(i){if(!mi())return;const t=i.ui.outer(),e=i.gallery.options.locale??{},n=e.enterFullscreen??"Enter fullscreen",o=e.exitFullscreen??"Exit fullscreen",s=document.createElement("button");s.type="button",s.className="shoji-toolbar-button",s.innerHTML=ae,s.setAttribute("aria-label",n),s.title=n,s.setAttribute("aria-pressed","false");function r(){return gi()===t}function a(g){s.innerHTML=g?pi:ae,s.setAttribute("aria-label",g?o:n),s.title=g?o:n,s.setAttribute("aria-pressed",String(g))}s.addEventListener("click",()=>{r()?zt():vi(t)});const l=()=>{const g=r();a(g),i.emit("fullscreenChange",{fullscreen:g})};document.addEventListener("fullscreenchange",l),document.addEventListener("webkitfullscreenchange",l);const c=i.ui.toolbar("right",s),m=i.on("close",()=>{r()&&zt()});return()=>{document.removeEventListener("fullscreenchange",l),document.removeEventListener("webkitfullscreenchange",l),c(),m(),r()&&zt()}}};function bi(i){const{containerWidth:t,gutterX:e,columns:n}=i;if(typeof n=="number")return Math.max(1,Math.floor(n));const o=Math.max(1,Math.floor((t+e)/(i.columnWidth+e))),s=Math.max(1,Math.floor((t+e)/(i.minColumnWidth+e))),r=Math.max(1,Math.ceil((t+e)/(i.maxColumnWidth+e)));return Math.max(r,Math.min(o,s))}function wi(i,t,e){return(i-t*(e-1))/e}function le(i,t,e){const n=bi(t),o=wi(t.containerWidth,t.gutterX,n),s=e&&e.length===n?[...e]:new Array(n).fill(0),r=i.map((l,c)=>{const m=t.fill==="ordered"?c%n:Ei(s),g=l.width>0?o*(l.height/l.width):o,j=m*(o+t.gutterX),L=s[m];return s[m]=L+g+t.gutterY,{x:j,y:L,width:o,height:g}}),a=i.length===0?0:Math.max(...s)-t.gutterY;return{positions:r,columnCount:n,columnWidth:o,columnHeights:s,containerHeight:a}}function Ei(i){let t=0;for(let e=1;e<i.length;e++)i[e]<i[t]&&(t=e);return t}function Si(i,t){const{containerWidth:e,gutterX:n,gutterY:o,rowHeight:s}=t,r=new Array(i.length);let a=0,l=0,c=0,m=0;function g(w){return w.height>0?s*(w.width/w.height):s}function j(w,T){let $=0;for(let O=w;O<T;O++){const E=g(i[O]);r[O]={x:$,y:a,width:E,height:s},$+=E+n}m++,a+=s+o}for(let w=0;w<i.length;w++){const T=g(i[w]),$=w-l,O=c+($>0?n:0)+T;$>0&&O>e?(j(l,w),l=w,c=T):c=O}l<i.length&&j(l,i.length);const L=i.length===0?0:a-o;return{positions:r,rowCount:m,containerHeight:L}}function xt(i){return i.width>0&&i.height>0?i.width/i.height:1}function Pt(i,t){const{containerWidth:e,gutterX:n,gutterY:o,rowHeight:s,minRowHeight:r,maxRowHeight:a,lastRow:l}=t,c=new Array(i.length).fill(null),m=[];let g=0,j=0,L=0;function w(E,X,N){return(e-n*(X-E-1))/N}function T(E,X,N){let P=0;for(let H=E;H<X;H++){const Z=N*xt(i[H]);c[H]={x:P,y:g,width:Z,height:N},P+=Z+n}m.push({start:E,end:X,y:g,height:N}),g+=N+o}function $(E,X,N){let P=X,H=N;for(;P-E>1&&w(E,P,H)<r;)P--,H-=xt(i[P]);const Z=w(E,P,H),C=P-E===1&&Z<r?Z:Math.min(Math.max(Z,r),a);return T(E,P,C),P}for(let E=0;E<i.length;E++){L+=xt(i[E]);const X=E-j+1;if(s*L+n*(X-1)>=e){const P=$(j,E+1,L);j=P,L=0;for(let H=P;H<=E;H++)L+=xt(i[H])}}if(j<i.length)if(l==="justify"){let E=j;for(;E<i.length;){let X=0;for(let N=E;N<i.length;N++)X+=xt(i[N]);E=$(E,i.length,X)}}else l==="left"&&T(j,i.length,s);const O=i.length===0?0:Math.max(0,g-o);return{positions:c,containerHeight:O,rows:m}}const Ci={width:4,height:3};function ce(i){if(i&&typeof i=="object"){const e=i;return{x:Number(e.x??8),y:Number(e.y??8)}}const t=Number(i??8);return{x:t,y:t}}function de(i){return i.id??i.src}function xi(i,t){if(t.length<=i.length)return!1;for(let e=0;e<i.length;e++)if(de(i[e])!==de(t[e]))return!1;return!0}const Li={name:"layout",defaults:{type:"justified",gutter:8,columns:"auto",columnWidth:240,minColumnWidth:160,maxColumnWidth:480,fill:"shortest",animate:!0,autoMeasure:!0},init(i){const{gallery:t}=i,e=i.options.type??"justified",n=ce(i.options.gutter),o=Number(i.options.aspectRatio??1),s=i.options.orientation??"vertical",r=i.options.columns??"auto",a=Number(i.options.columnWidth??240),l=Number(i.options.minColumnWidth??160),c=Number(i.options.maxColumnWidth??480),m=i.options.fill??"shortest",g=Number(i.options.rowHeight??220),j=Number(i.options.minRowHeight??120),L=Number(i.options.maxRowHeight??360),w=i.options.lastRow??"justify",T=i.options.animate!==!1,$=i.options.autoMeasure!==!1,O=e==="masonry"&&s==="horizontal",E=i.options.groupBy,X=i.options.renderHeading,N=i.options.headingOverflow??"show",P=i.options.stickyHeadings===!0,H=P&&e==="grid";P&&e!=="grid"&&console.warn("Shoji: layout plugin — stickyHeadings is only implemented for type: 'grid'; ignored (see the option's doc comment)."),E&&O&&console.warn("Shoji: layout plugin — groupBy isn't supported with orientation: 'horizontal'; ignored.");const Z=!!E&&!O,C={gutter:n,columns:r,columnWidth:a,minColumnWidth:l,maxColumnWidth:c,fill:m,rowHeight:g,minRowHeight:j,maxRowHeight:L,lastRow:w},A=i.options.breakpoints,B=A?Object.entries(A).map(([f,u])=>[Number(f),u]).sort((f,u)=>f[0]-u[0]):[];function J(f){const u=B.find(([b])=>f<=b);if(!u)return C;const h=u[1];return{gutter:h.gutter!==void 0?ce(h.gutter):C.gutter,columns:h.columns??C.columns,columnWidth:h.columnWidth??C.columnWidth,minColumnWidth:h.minColumnWidth??C.minColumnWidth,maxColumnWidth:h.maxColumnWidth??C.maxColumnWidth,fill:h.fill??C.fill,rowHeight:h.rowHeight??C.rowHeight,minRowHeight:h.minRowHeight??C.minRowHeight,maxRowHeight:h.maxRowHeight??C.maxRowHeight,lastRow:h.lastRow??C.lastRow}}const I=t.element;I.classList.add("shoji-layout",`shoji-layout--${e}`),T&&I.classList.add("shoji-layout--animate");let V=[],x=[],ct,rt=[],it=!1;function wt(f){const u=[];for(let h=0;h<f.length;h++){const b=E(f[h]),k=u[u.length-1];!k||k.key!==b?u.push({key:b,startIndex:h,endIndex:h+1}):k.endIndex=h+1}return u}function F(f,u){const h=X?X(f,u):f;let b,k=null;if(typeof h=="string")b=document.createElement("h2"),b.textContent=h;else if(h instanceof HTMLElement)b=h;else{b=document.createElement("h2");const Y=document.createElement("span");Y.className="shoji-layout-heading-title",Y.textContent=h.title,b.appendChild(Y);let Q=null;h.subtitle&&(Q=document.createElement("span"),Q.className="shoji-layout-heading-subtitle",Q.textContent=h.subtitle,b.appendChild(Q)),k={titleEl:Y,subtitleEl:Q}}return b.classList.add("shoji-layout-heading"),H&&b.classList.add("shoji-layout-heading--sticky"),{root:b,structured:k}}function K(){return x.map((f,u)=>({heading:f,start:f.tileStart,end:u+1<x.length?x[u+1].tileStart:V.length}))}function dt(f){return f.thumb??f.poster??(f.video?void 0:f.src)}function ht(f){if(f!=null&&f.width&&f.height)return{width:f.width,height:f.height};const u=$&&!!f&&!!dt(f);return!it&&!u&&(it=!0,console.warn($?"Shoji: layout plugin — item(s) missing width/height with no measurable thumb/poster/src to auto-measure from either; falling back to a 4:3 placeholder ratio permanently for those.":"Shoji: layout plugin — item(s) missing width/height and autoMeasure is disabled. Masonry/justified positions are computed from aspect ratios up front, never by measuring loaded images (DESIGN.md §5.2 — that causes layout-jump), so items without dimensions fall back to a 4:3 placeholder ratio instead.")),Ci}function Et(f,u){const h=document.createElement("a");h.className="shoji-layout-tile",f.id&&(h.dataset.shojiId=f.id),h.dataset.shojiIndex=String(u);const b=document.createElement("img");b.src=f.thumb??f.poster??f.src,b.loading="lazy",b.alt=f.alt??"",h.appendChild(b);const k={index:u,root:h,img:b};return h.addEventListener("click",Y=>{Y.preventDefault(),t.open(k.index)}),k}function St(f){const u=I.getBoundingClientRect().width,h=J(u);I.style.setProperty("--shoji-layout-column-width",`${h.columnWidth}px`),I.style.setProperty("--shoji-layout-gutter",`${h.gutter.y}px ${h.gutter.x}px`);for(const b of f)b.root.style.setProperty("--shoji-layout-tile-aspect",`${o}`)}function Lt(f){const u=I.getBoundingClientRect().width;if(u<=0)return;const h=J(u),b={containerWidth:u,gutterX:h.gutter.x,gutterY:h.gutter.y,columns:h.columns,columnWidth:h.columnWidth,minColumnWidth:h.minColumnWidth,maxColumnWidth:h.maxColumnWidth,fill:h.fill};if(Z&&x.length>0){const at=K(),jt=at.map(ft=>ft.heading.root.getBoundingClientRect().height);let st=0;at.forEach(({heading:ft,start:pt,end:v},S)=>{const M=V.slice(pt,v);ft.root.style.transform=`translate(0px, ${st}px)`,st+=jt[S]+h.gutter.y;const D=le(M.map(R=>ht(t.items[R.index])),b);M.forEach((R,q)=>{const U=D.positions[q];R.root.style.width=`${U.width}px`,R.root.style.height=`${U.height}px`,R.root.style.visibility="visible",R.root.style.transform=`translate(${U.x}px, ${st+U.y}px)`}),st+=D.containerHeight+h.gutter.y}),ct=void 0,I.style.height=`${Math.max(0,st-h.gutter.y)}px`;return}const k=f??V,Y=k.map(at=>ht(t.items[at.index])),ot=le(Y,b,f?ct:void 0);k.forEach((at,jt)=>{const st=ot.positions[jt];at.root.style.width=`${st.width}px`,at.root.style.height=`${st.height}px`,at.root.style.visibility="visible",at.root.style.transform=`translate(${st.x}px, ${st.y}px)`}),ct=ot.columnHeights,I.style.height=`${ot.containerHeight}px`}function Mt(){const f=I.getBoundingClientRect().width;if(f<=0)return;const u=J(f),h=V.map(k=>ht(t.items[k.index])),b=Si(h,{containerWidth:f,gutterX:u.gutter.x,gutterY:u.gutter.y,rowHeight:u.rowHeight});V.forEach((k,Y)=>{const Q=b.positions[Y];k.root.style.width=`${Q.width}px`,k.root.style.height=`${Q.height}px`,k.root.style.visibility="visible",k.root.style.transform=`translate(${Q.x}px, ${Q.y}px)`}),I.style.height=`${b.containerHeight}px`}function Rt(f,u,h){const b=new Map,k=new Map;if(N==="fit")for(const v of x){if(!v.structured)continue;const{subtitleEl:S}=v.structured;v.root.style.maxWidth="none",v.root.style.whiteSpace="nowrap",S&&(S.hidden=!1),b.set(v.tileStart,v.root.getBoundingClientRect().width),S?(S.hidden=!0,k.set(v.tileStart,v.root.getBoundingClientRect().width),S.hidden=!1):k.set(v.tileStart,b.get(v.tileStart))}function Y(v,S){return V.slice(v,S).map(M=>ht(t.items[M.index]))}function Q(v,S){const M=x[v].tileStart,D=S<x.length?x[S].tileStart:V.length,R=Pt(Y(M,D),f);for(let q=v;q<S;q++){const U=x[q];if(!U.structured)continue;const z=R.positions[U.tileStart-M];if(!z)continue;const G=q+1<S?x[q+1]:void 0,nt=G?R.positions[G.tileStart-M]:null,_t=(!!nt&&Math.abs(nt.y-z.y)<.5?nt.x:h)-z.x-u.gutter.x;if(Math.min(b.get(U.tileStart)??1/0,k.get(U.tileStart)??1/0)>_t)return null}return R}function ot(){if(N!=="fit")return[{startSection:0,endSection:x.length,tileStart:0,tileEnd:V.length,result:Pt(Y(0,V.length),f)}];const v=[];let S=0;for(;S<x.length;){const M=Q(S,S+1),D=x[S].tileStart;if(M===null){const z=S+1<x.length?x[S+1].tileStart:V.length;v.push({startSection:S,endSection:S+1,tileStart:D,tileEnd:z,result:Pt(Y(D,z),f)}),S+=1;continue}let R=S+1,q=M;for(;R<x.length;){const z=Q(S,R+1);if(z===null)break;R+=1,q=z}const U=R<x.length?x[R].tileStart:V.length;v.push({startSection:S,endSection:R,tileStart:D,tileEnd:U,result:q}),S=R}return v}function at(v){for(let S=v.startSection;S<v.endSection;S++){const M=x[S];if(!M.structured)continue;const D=v.result.positions[M.tileStart-v.tileStart];if(!D)continue;const R=S+1<v.endSection?x[S+1]:void 0,q=R?v.result.positions[R.tileStart-v.tileStart]:null,z=(!!q&&Math.abs(q.y-D.y)<.5?q.x:h)-D.x-u.gutter.x,{subtitleEl:G}=M.structured;M.root.style.whiteSpace="nowrap",M.root.style.maxWidth="none",M.root.style.overflow="",M.root.style.textOverflow="",G&&(G.hidden=!1),!((b.get(M.tileStart)??0)<=z)&&(G&&(G.hidden=!0,(k.get(M.tileStart)??0)<=z)||(M.root.style.maxWidth=`${Math.max(0,z)}px`,M.root.style.overflow="hidden",M.root.style.textOverflow="ellipsis"))}}function jt(v){for(let S=v.startSection;S<v.endSection;S++){const M=x[S];if(!M.structured)continue;const D=v.result.positions[M.tileStart-v.tileStart];if(!D)continue;const R=S+1<v.endSection?x[S+1]:void 0,q=R?v.result.positions[R.tileStart-v.tileStart]:null,z=(!!q&&Math.abs(q.y-D.y)<.5?q.x:h)-D.x-u.gutter.x;M.root.style.whiteSpace="normal",M.root.style.maxWidth=`${Math.max(0,z)}px`;const G=getComputedStyle(M.root),nt=parseFloat(G.lineHeight),Xt=Number.isFinite(nt)?nt:parseFloat(G.fontSize)*1.2,_t=Math.max(1,Math.floor(u.maxRowHeight/Xt));M.root.style.display="-webkit-box",M.root.style.overflow="hidden",M.root.style.setProperty("-webkit-box-orient","vertical"),M.root.style.setProperty("-webkit-line-clamp",`${_t}`)}}const st=ot();let ft=0,pt=0;for(const v of st){N==="fit"?at(v):N==="wrap"&&jt(v);const S=new Map;for(let D=v.startSection;D<v.endSection;D++){const R=x[D];S.set(R.tileStart,R.root.getBoundingClientRect().height)}for(const D of v.result.rows){const R=D.start+v.tileStart,q=D.end+v.tileStart;let U=0;for(;pt<v.endSection&&x[pt].tileStart<q;){const z=x[pt],G=v.result.positions[z.tileStart-v.tileStart];G&&(z.root.hidden=!1,z.root.style.transform=`translate(${G.x}px, ${D.y+ft}px)`,U=Math.max(U,S.get(z.tileStart)??0)),pt++}U>0&&(ft+=U+u.gutter.y);for(let z=R;z<q;z++){const G=v.result.positions[z-v.tileStart],nt=V[z];nt.root.hidden=G===null,G&&(nt.root.style.width=`${G.width}px`,nt.root.style.height=`${G.height}px`,nt.root.style.visibility="visible",nt.root.style.transform=`translate(${G.x}px, ${G.y+ft}px)`)}}const M=v.result.rows.length>0?v.result.rows[v.result.rows.length-1].end+v.tileStart:v.tileStart;for(let D=M;D<v.tileEnd;D++)V[D].root.hidden=!0;ft+=v.result.containerHeight+u.gutter.y}for(;pt<x.length;)x[pt].root.hidden=!0,pt++;I.style.height=`${Math.max(0,ft-u.gutter.y)}px`}function Ot(){const f=I.getBoundingClientRect().width;if(f<=0)return;const u=J(f),h={containerWidth:f,gutterX:u.gutter.x,gutterY:u.gutter.y,rowHeight:u.rowHeight,minRowHeight:u.minRowHeight,maxRowHeight:u.maxRowHeight,lastRow:u.lastRow};if(Z&&x.length>0){Rt(h,u,f);return}const b=V.map(Y=>ht(t.items[Y.index])),k=Pt(b,h);V.forEach((Y,Q)=>{const ot=k.positions[Q];Y.root.hidden=ot===null,ot&&(Y.root.style.width=`${ot.width}px`,Y.root.style.height=`${ot.height}px`,Y.root.style.visibility="visible",Y.root.style.transform=`translate(${ot.x}px, ${ot.y}px)`)}),I.style.height=`${k.containerHeight}px`}function Tt(){O?Mt():e==="masonry"?Lt(null):e==="justified"?Ot():St(V)}let Ct=!1,gt=null;function Ft(){gt!==null||Ct||(gt=requestAnimationFrame(()=>{gt=null,!Ct&&(Z?d(t.items):Tt())}))}function Dt(f){if($)for(const u of f){const h=t.items[u.index];if(!h||h.width&&h.height||!dt(h))continue;const b=()=>{Ct||u.img.naturalWidth>0&&u.img.naturalHeight>0&&(h.width=u.img.naturalWidth,h.height=u.img.naturalHeight,Ft())};u.img.complete?b():u.img.addEventListener("load",b,{once:!0})}}function Nt(f){i.emit("layoutRender",{tiles:f.map(u=>({index:u.index,element:u.root}))})}function d(f){if(I.replaceChildren(),V=f.map((u,h)=>Et(u,h)),x=[],Z)for(const u of wt(f)){const h=f.slice(u.startIndex,u.endIndex),{root:b,structured:k}=F(u.key,h);I.appendChild(b),x.push({root:b,tileStart:u.startIndex,structured:k});for(let Y=u.startIndex;Y<u.endIndex;Y++)I.appendChild(V[Y].root)}else for(const u of V)I.appendChild(u.root);ct=void 0,Tt(),Dt(V),Nt(V)}function y(f,u){const h=f.map((b,k)=>Et(b,u+k));for(const b of h)I.appendChild(b.root);V=[...V,...h],O?Mt():e==="masonry"?Lt(h):e==="justified"?Ot():St(h),Dt(h),Nt(h)}d(t.items),rt=t.items;const W=i.on("itemsUpdated",({items:f})=>{Z?d(f):xi(rt,f)?y(f.slice(rt.length),rt.length):d(f),rt=f});let ut=null,vt;return(e==="masonry"||e==="justified"||B.length>0)&&(vt=new ResizeObserver(()=>{ut===null&&(ut=requestAnimationFrame(()=>{ut=null,Tt()}))}),vt.observe(I)),()=>{Ct=!0,gt!==null&&cancelAnimationFrame(gt),vt==null||vt.disconnect(),ut!==null&&cancelAnimationFrame(ut),W(),I.classList.remove("shoji-layout",`shoji-layout--${e}`,"shoji-layout--animate"),I.style.removeProperty("height"),I.style.removeProperty("width"),I.replaceChildren()}}};function Mi(i){const t=(i.rotation%360+360)%360;return i.flipH&&i.flipV?{flipH:!1,flipV:!1,rotation:(t+180)%360}:{flipH:i.flipH,flipV:i.flipV,rotation:t}}const Ti='<svg viewBox="0 0 24 24" width="24" height="24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M9 14 4 9l5-5"/><path d="M4 9h10a6 6 0 1 1 0 12H9"/></svg>',ji='<svg viewBox="0 0 24 24" width="24" height="24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M15 14 20 9l-5-5"/><path d="M20 9H10a6 6 0 1 0 0 12h5"/></svg>',Ai='<svg viewBox="0 0 24 24" width="24" height="24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M12 3v18"/><path d="M17 7l3 5-3 5"/><path d="M7 7l-3 5 3 5"/></svg>',Ii='<svg viewBox="0 0 24 24" width="24" height="24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M3 12h18"/><path d="M7 17l5 3 5-3"/><path d="M7 7l5-3 5 3"/></svg>',he={flipH:!1,flipV:!1,rotation:0};function ki(i,t,e,n){if(!i&&!t&&e===0&&n===1)return"none";const o=(i?-1:1)*n,s=(t?-1:1)*n;return`scaleX(${o}) scaleY(${s}) rotate(${e}deg)`}function Pi(i,t,e,n,o){if(!i||!t||!n||!o||e/90%2===0)return 1;const s=Math.min(1,i/n,t/o);return Math.min(1,i/o,t/n)/s}const Hi={name:"rotateFlip",init(i){const{gallery:t}=i,e=t.options.locale??{},n=e.rotateLeft??"Rotate left",o=e.rotateRight??"Rotate right",s=e.flipHorizontal??"Flip horizontal",r=e.flipVertical??"Flip vertical";let a={...he},l=0,c=!1,m=!1;function g(C){const A=t.items[t.currentIndex];if(A!=null&&A.width&&A.height)return{width:A.width,height:A.height};const B=C.querySelector("img");if(B!=null&&B.naturalWidth&&B.naturalHeight)return{width:B.naturalWidth,height:B.naturalHeight}}function j(C){const A=t.getActiveMedia();if(!A)return;const B=g(A),J=Pi(A.clientWidth,A.clientHeight,l,B==null?void 0:B.width,B==null?void 0:B.height),I=ki(c,m,l,J);if(!C){A.style.transform=I;return}A.style.transition="transform var(--shoji-duration) var(--shoji-easing)",A.style.transform=I,yt(A,()=>{A.style.transition=""})}function L(C,A){const B=document.createElement("button");return B.type="button",B.className="shoji-toolbar-button",B.innerHTML=C,B.setAttribute("aria-label",A),B.title=A,B}const w=L(Ti,n),T=L(ji,o),$=L(Ai,s),O=L(Ii,r);$.setAttribute("aria-pressed","false"),O.setAttribute("aria-pressed","false");function E(C,A){a=Mi({...a,...C}),A!==void 0&&(l+=A),j(!0),$.setAttribute("aria-pressed",String(a.flipH)),O.setAttribute("aria-pressed",String(a.flipV)),i.emit("rotateFlipChange",{index:t.currentIndex,...a})}function X(C){return C!==(c!==m)?90:-90}w.addEventListener("click",()=>{const C=X(!1);E({rotation:a.rotation+C},C)}),T.addEventListener("click",()=>{const C=X(!0);E({rotation:a.rotation+C},C)}),$.addEventListener("click",()=>{c=!c,E({flipH:!a.flipH})}),O.addEventListener("click",()=>{m=!m,E({flipV:!a.flipV})});function N(){a={...he},l=0,c=!1,m=!1,j(!1),$.setAttribute("aria-pressed","false"),O.setAttribute("aria-pressed","false")}const P=[w,T,$,O].map(C=>i.ui.toolbar("right",C)),H=i.on("afterOpen",N),Z=i.on("afterSlide",N);return()=>{for(const C of P)C();H(),Z()}}};let Ht=null;function Ri(){var i;return(i=window.YT)!=null&&i.Player?Promise.resolve(window.YT):Ht||(Ht=new Promise(t=>{const e=window.onYouTubeIframeAPIReady;window.onYouTubeIframeAPIReady=()=>{e==null||e(),t(window.YT)};const n=document.createElement("script");n.src="https://www.youtube.com/iframe_api",document.head.appendChild(n)}),Ht)}function Oi(i,t){const e=i;return e.paused=!0,e.ended=!1,e.play=()=>t.playVideo(),e.pause=()=>t.pauseVideo(),Object.defineProperty(e,"muted",{configurable:!0,get:()=>t.isMuted(),set:n=>n?t.mute():t.unMute()}),e}function Di(i,t,e){i.data===t.PlayerState.PLAYING?(e.paused=!1,e.dispatchEvent(new Event("play"))):i.data===t.PlayerState.PAUSED?(e.paused=!0,e.dispatchEvent(new Event("pause"))):i.data===t.PlayerState.ENDED&&(e.paused=!0,e.ended=!0,e.dispatchEvent(new Event("ended")))}const Ni=(i,t,e,n)=>{var r;if(((r=t.video)==null?void 0:r.provider)!=="youtube")return;const o=t.video.id,s=document.createElement("div");i.appendChild(s),Ri().then(a=>{if(n.aborted)return;const l=i,c=new a.Player(s,{videoId:o,playerVars:{playsinline:1,rel:0},events:{onReady:()=>{Oi(i,c),e()},onStateChange:m=>Di(m,a,l),onError:m=>l.dispatchEvent(new CustomEvent("error",{bubbles:!0,detail:{code:m.data}}))}});n.addEventListener("abort",()=>c.destroy(),{once:!0})})},Bi={name:"video",init(i){return i.ui.registerVideoProvider("youtube",Ni)}},Vi='<svg viewBox="0 0 24 24" width="24" height="24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><circle cx="10" cy="10" r="7"/><path d="M21 21l-5.5-5.5M10 7v6M7 10h6"/></svg>',$i='<svg viewBox="0 0 24 24" width="24" height="24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><circle cx="10" cy="10" r="7"/><path d="M21 21l-5.5-5.5M7 10h6"/></svg>',Yi='<svg viewBox="0 0 24 24" width="24" height="24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><rect x="4" y="4" width="16" height="16" rx="1"/><path d="M9 15l6-6M9 9h0M15 15h0"/></svg>';function Wi(i,t,e){return Math.min(e,Math.max(t,i))}function ue(i,t,e,n,o,s){const r=t*e;if(r<=o)return n+(o-r)/2-i;const a=n+o-r,l=n,c=i+s;return Math.min(l,Math.max(a,c))-i}function fe(i,t,e,n){return{tx:ue(i.left,i.width,e,t.left,t.width,n.tx),ty:ue(i.top,i.height,e,t.top,t.height,n.ty)}}function zi(i,t,e,n,o,s){const r=i.left+t.tx,a=i.top+t.ty,l=o-r,c=s-a,m=1-n/e;return{tx:t.tx+l*m,ty:t.ty+c*m}}const bt=1.001;function Fi(i){return i.composedPath().some(t=>t instanceof Element&&t.matches("button, video, input, select, textarea, a[href], [data-shoji-no-drag]"))}return Object.assign(si,{Autoplay:fi,Layout:Li,ActiveThumbnail:ai,Fullscreen:yi,RotateFlip:Hi,Video:Bi,Zoom:{name:"zoom",defaults:{maxScale:4,doubleTapScale:2,buttonStep:1.5},init(i){const{gallery:t}=i,e=Number(i.options.maxScale??4),n=Number(i.options.doubleTapScale??2),o=Number(i.options.buttonStep??1.5),s=t.options.locale??{},r=s.zoomIn??"Zoom in",a=s.zoomOut??"Zoom out",l=s.zoomActualSize??"Actual size";let c=1,m={tx:0,ty:0},g=null,j=null,L=1;function w(){const d=t.getActiveMedia(),y=d==null?void 0:d.firstElementChild;return y instanceof HTMLImageElement?y:null}function T(d){const y=d.getBoundingClientRect();return{left:y.left,top:y.top,width:y.width,height:y.height}}function $(d){return g&&j?!0:c!==1?!1:(g=T(d),j=T(d.parentElement??d),!0)}function O(d){const y=t.getActiveMedia();if(!y||y.style.transition===""){d();return}yt(y,d)}function E(){const d=w();d&&(d.style.transformOrigin="0 0",d.style.transform=c===1&&m.tx===0&&m.ty===0?"none":`translate3d(${m.tx}px, ${m.ty}px, 0) scale3d(${c}, ${c}, 1)`,d.classList.toggle("shoji-zoomed",c>1))}function X(){i.emit("zoomChange",{index:t.currentIndex,scale:c})}function N(d,y,W){d.style.transition="transform var(--shoji-duration) var(--shoji-easing)",y(),yt(d,()=>{d.style.transition="",W==null||W()})}function P(d,y,W,ut=e,vt=!1){O(()=>{const f=w();if(!f||!$(f))return;const u=Wi(d,1,Math.max(ut,1));m=zi(g,m,c,u,y,W),c=u,m=fe(g,j,c,m),vt?N(f,E):E(),X()})}function H(d=!1){c=1,m={tx:0,ty:0},g=null,j=null;const y=w();if(!y)return;const W=()=>{y.style.transform="",y.classList.remove("shoji-zoomed")};d?N(y,W,()=>{y.style.transformOrigin=""}):(W(),y.style.transformOrigin="")}function Z(){var d;(d=w())==null||d.classList.add("shoji-zoom-enabled")}function C(d,y){c>bt?H(!0):P(n,d,y,e,!0)}const A=i.on("pinchStart",()=>{L=c}),B=i.on("pinchMove",({scale:d,centerX:y,centerY:W})=>{P(L*d,y,W)}),J=i.on("pinchEnd",()=>{c<=bt&&H()}),I=i.on("doubleTap",({x:d,y})=>C(d,y)),V=i.on("wheelZoom",({deltaScale:d,x:y,y:W})=>{P(c+d,y,W)});let x=null,ct=0,rt=0;const it=i.ui.outer();function wt(d){c<=bt||Fi(d)||(x=d.pointerId,ct=d.clientX,rt=d.clientY)}function F(d){if(x!==d.pointerId||!g||!j)return;d.preventDefault();const y=d.clientX-ct,W=d.clientY-rt;ct=d.clientX,rt=d.clientY,m=fe(g,j,c,{tx:m.tx+y,ty:m.ty+W}),E()}function K(d){x===d.pointerId&&(x=null)}it.addEventListener("pointerdown",wt),it.addEventListener("pointermove",F,{passive:!1}),it.addEventListener("pointerup",K),it.addEventListener("pointercancel",K);function dt(d,y){const W=document.createElement("button");return W.type="button",W.className="shoji-toolbar-button",W.innerHTML=d,W.setAttribute("aria-label",y),W.title=y,W}function ht(){const d=t.getActiveMedia(),y=d==null?void 0:d.getBoundingClientRect();return y?{x:y.left+y.width/2,y:y.top+y.height/2}:{x:0,y:0}}function Et(){const{x:d,y}=ht();P(c*o,d,y,e,!0)}function St(){const{x:d,y}=ht();c/o<=bt?H(!0):P(c/o,d,y,e,!0)}const Lt=dt(Vi,r),Mt=dt($i,a),Rt=dt(Yi,l);Lt.addEventListener("click",Et),Mt.addEventListener("click",St),Rt.addEventListener("click",()=>{O(()=>{const d=w();if(!d||!d.naturalWidth||!$(d))return;if(c>bt){H(!0);return}const y=d.naturalWidth/g.width,{x:W,y:ut}=ht();P(y,W,ut,y,!0)})});const Ot=[Lt,Mt,Rt].map(d=>i.ui.toolbar("right",d)),Tt=[i.ui.registerShortcut("w",Et),i.ui.registerShortcut("W",Et),i.ui.registerShortcut("s",St),i.ui.registerShortcut("S",St)],Ct=i.on("afterOpen",()=>{H(),Z()}),gt=i.on("beforeSlide",()=>H()),Ft=i.on("afterSlide",()=>{H(),Z()}),Dt=i.on("beforeClose",()=>H()),Nt=t.registerZoomGate(()=>c>bt);return Z(),()=>{var d;for(const y of Ot)y();for(const y of Tt)y();Ct(),gt(),Ft(),Dt(),A(),B(),J(),I(),V(),it.removeEventListener("pointerdown",wt),it.removeEventListener("pointermove",F),it.removeEventListener("pointerup",K),it.removeEventListener("pointercancel",K),Nt(),H(),(d=w())==null||d.classList.remove("shoji-zoom-enabled")}}},version:"0.1.0-alpha.6"})}));
2
+ //# sourceMappingURL=shoji.min.js.map