/*! License details at fancyapps.com/license */
import{isPlainObject as t}from"../utils/isPlainObject.js";const n={btnTpl:'<button data-expand-action="toggle" class="f-button" title="{{TOGGLE_EXPAND}}"><svg><g><path d="M14.5 9.5 21 3m0 0h-6m6 0v6M3 21l6.5-6.5M3 21v-6m0 6h6"/></g><g><path d="m14 10 7-7m-7 7h6m-6 0V4M3 21l7-7m0 0v6m0-6H4"/></g></svg></button>'},e="in-expanded-mode",o="with-expanded-carousel",i=()=>{let i;function l(e){const o=null==i?void 0:i.getOptions().Expand;let l=(t(o)?Object.assign(Object.assign({},n),o):n)[e];return l&&"function"==typeof l&&i?l(i):l}function s(){var t;null===(t=null==i?void 0:i.getPlugins().Toolbar)||void 0===t||t.add("expand",{tpl:l("btnTpl")})}function d(t,n){const e=n.target;e&&!n.defaultPrevented&&"toggle"===e.dataset.expandAction&&u()}function c(t){"Escape"!==t.key||t.defaultPrevented||u()}function u(){const t=l("el")||(null==i?void 0:i.getContainer());t&&(t.classList.toggle(e),t.classList.contains(e)?(document.documentElement.classList.add(o),document.addEventListener("keydown",c,!0)):(document.documentElement.classList.remove(o),document.removeEventListener("keydown",c,!0)))}return{init:function(t){i=t,i.on("initPlugins",s),i.on("click",d)},destroy:function(){null==i||i.off("initPlugins",s),null==i||i.off("click",d),i=void 0,document.documentElement.classList.remove(o),document.removeEventListener("keydown",c,!0)},toggle:u}};export{i as Expand};
