/******/ (() => { // webpackBootstrap
/******/ 	"use strict";
/******/ 	var __webpack_modules__ = ({

/***/ "./assets/src/blocks/courses/edit.js":
/*!*******************************************!*\
  !*** ./assets/src/blocks/courses/edit.js ***!
  \*******************************************/
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {

__webpack_require__.r(__webpack_exports__);
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */   "default": () => (__WEBPACK_DEFAULT_EXPORT__)
/* harmony export */ });
/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react */ "react");
/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(react__WEBPACK_IMPORTED_MODULE_0__);
/* harmony import */ var _wordpress_i18n__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @wordpress/i18n */ "@wordpress/i18n");
/* harmony import */ var _wordpress_i18n__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(_wordpress_i18n__WEBPACK_IMPORTED_MODULE_1__);
/* harmony import */ var _wordpress_components__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! @wordpress/components */ "@wordpress/components");
/* harmony import */ var _wordpress_components__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(_wordpress_components__WEBPACK_IMPORTED_MODULE_2__);
/* harmony import */ var _wordpress_block_editor__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! @wordpress/block-editor */ "@wordpress/block-editor");
/* harmony import */ var _wordpress_block_editor__WEBPACK_IMPORTED_MODULE_3___default = /*#__PURE__*/__webpack_require__.n(_wordpress_block_editor__WEBPACK_IMPORTED_MODULE_3__);
/* harmony import */ var _wordpress_html_entities__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! @wordpress/html-entities */ "@wordpress/html-entities");
/* harmony import */ var _wordpress_html_entities__WEBPACK_IMPORTED_MODULE_4___default = /*#__PURE__*/__webpack_require__.n(_wordpress_html_entities__WEBPACK_IMPORTED_MODULE_4__);
/* harmony import */ var _wordpress_data__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! @wordpress/data */ "@wordpress/data");
/* harmony import */ var _wordpress_data__WEBPACK_IMPORTED_MODULE_5___default = /*#__PURE__*/__webpack_require__.n(_wordpress_data__WEBPACK_IMPORTED_MODULE_5__);
/* harmony import */ var _wordpress_element__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! @wordpress/element */ "@wordpress/element");
/* harmony import */ var _wordpress_element__WEBPACK_IMPORTED_MODULE_6___default = /*#__PURE__*/__webpack_require__.n(_wordpress_element__WEBPACK_IMPORTED_MODULE_6__);
/* harmony import */ var _editor_slider__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./editor-slider */ "./assets/src/blocks/courses/editor-slider.js");








const Edit = props => {
  var _slider$dotStyle, _slider$navStyle, _slider$autoplaySpeed, _slider$dotOffset, _slider$navOffset, _slider$infinite, _slider$slidesToScrol, _slider$responsive$ta, _slider$responsive$mo;
  const {
    attributes,
    setAttributes,
    clientId
  } = props;
  const {
    courseQuery,
    slider,
    gridGap
  } = attributes;
  const [forceUpdate, setForceUpdate] = (0,_wordpress_element__WEBPACK_IMPORTED_MODULE_6__.useState)(0);
  const blockRef = (0,_wordpress_element__WEBPACK_IMPORTED_MODULE_6__.useRef)(null);
  const {
    categories,
    tags
  } = (0,_wordpress_data__WEBPACK_IMPORTED_MODULE_5__.useSelect)(select => {
    const {
      getEntityRecords
    } = select('core');
    return {
      categories: getEntityRecords('taxonomy', 'course_category', {
        per_page: -1
      }) || getEntityRecords('taxonomy', 'course-category', {
        per_page: -1
      }) || getEntityRecords('taxonomy', 'lp_course_category', {
        per_page: -1
      }) || [],
      tags: getEntityRecords('taxonomy', 'course_tag', {
        per_page: -1
      }) || getEntityRecords('taxonomy', 'course-tag', {
        per_page: -1
      }) || getEntityRecords('taxonomy', 'lp_course_tag', {
        per_page: -1
      }) || []
    };
  }, [courseQuery]);

  // Init editor slider (CSS scroll-snap, no Swiper in editor)
  (0,_wordpress_element__WEBPACK_IMPORTED_MODULE_6__.useEffect)(() => {
    const el = blockRef.current;
    if (!el) return;
    if (!slider.enable) {
      (0,_editor_slider__WEBPACK_IMPORTED_MODULE_7__.destroyEditorSlider)(el);
      return;
    }

    // Small delay to allow InnerBlocks to render
    const timer = setTimeout(() => {
      (0,_editor_slider__WEBPACK_IMPORTED_MODULE_7__.initEditorSlider)(el);
    }, 200);
    return () => {
      clearTimeout(timer);
    };
  }, [slider.enable, slider.slidesToShow, slider.spaceBetween, slider.autoplay, slider.autoplaySpeed, slider.dots, slider.dotStyle, slider.dotOffset, slider.arrows, slider.navStyle, slider.navOffset, slider.infinite, slider.responsive?.tablet?.slidesToShow, slider.responsive?.mobile?.slidesToShow, forceUpdate]);

  // Cleanup on unmount
  (0,_wordpress_element__WEBPACK_IMPORTED_MODULE_6__.useEffect)(() => {
    return () => {
      const el = blockRef.current;
      if (el) (0,_editor_slider__WEBPACK_IMPORTED_MODULE_7__.destroyEditorSlider)(el);
    };
  }, []);
  const QUERY_LOOP_TEMPLATE = [['learnpress/course-item-template']];
  const selectedCategories = courseQuery.term_slug ? courseQuery.term_slug.split(',').filter(Boolean) : [];
  const selectedTags = courseQuery.tag_slug ? courseQuery.tag_slug.split(',').filter(Boolean) : [];
  const selectedCategoryTokens = selectedCategories.map(slug => {
    const cat = categories.find(c => c.slug === slug);
    return cat ? (0,_wordpress_html_entities__WEBPACK_IMPORTED_MODULE_4__.decodeEntities)(cat.name) : slug;
  }).filter(Boolean);
  const categorySuggestions = categories.map(cat => (0,_wordpress_html_entities__WEBPACK_IMPORTED_MODULE_4__.decodeEntities)(cat.name));
  const selectedTagTokens = selectedTags.map(slug => {
    const tag = tags.find(t => t.slug === slug);
    return tag ? (0,_wordpress_html_entities__WEBPACK_IMPORTED_MODULE_4__.decodeEntities)(tag.name) : slug;
  }).filter(Boolean);
  const tagSuggestions = tags.map(tag => (0,_wordpress_html_entities__WEBPACK_IMPORTED_MODULE_4__.decodeEntities)(tag.name));
  const handleCategoryChangeTokens = tokens => {
    const newSlugs = tokens.map(token => {
      const cat = categories.find(c => (0,_wordpress_html_entities__WEBPACK_IMPORTED_MODULE_4__.decodeEntities)(c.name) === token);
      return cat ? cat.slug : token;
    });
    setAttributes({
      courseQuery: {
        ...courseQuery,
        term_slug: newSlugs.join(',')
      }
    });
    setTimeout(() => setForceUpdate(p => p + 1), 100);
  };
  const handleTagChangeTokens = tokens => {
    const newSlugs = tokens.map(token => {
      const tag = tags.find(t => (0,_wordpress_html_entities__WEBPACK_IMPORTED_MODULE_4__.decodeEntities)(t.name) === token);
      return tag ? tag.slug : token;
    });
    setAttributes({
      courseQuery: {
        ...courseQuery,
        tag_slug: newSlugs.join(',')
      }
    });
    setTimeout(() => setForceUpdate(p => p + 1), 100);
  };
  const blockProps = (0,_wordpress_block_editor__WEBPACK_IMPORTED_MODULE_3__.useBlockProps)({
    className: slider.enable ? 'thim-courses-slider' : '',
    style: {
      '--gap': `${gridGap}px`,
      ...(slider.enable && {
        '--nav-size': slider.navSize ? `${slider.navSize}px` : undefined,
        '--nav-color': slider.navColor,
        '--nav-bg': slider.navBackground,
        '--nav-hover-color': slider.navHoverColor,
        '--nav-hover-bg': slider.navHoverBackground,
        '--dot-color': slider.dotColor,
        '--dot-active-color': slider.dotHoverColor
      })
    },
    ...(slider.enable && {
      'data-slider': 'true',
      'data-slides-to-show': slider.slidesToShow,
      'data-space-between': slider.spaceBetween,
      'data-autoplay': slider.autoplay ? 'true' : 'false',
      'data-autoplay-speed': slider.autoplaySpeed,
      'data-dots': slider.dots ? 'true' : 'false',
      'data-dot-style': (_slider$dotStyle = slider.dotStyle) !== null && _slider$dotStyle !== void 0 ? _slider$dotStyle : 'default',
      'data-arrows': slider.arrows ? 'true' : 'false',
      'data-nav-style': (_slider$navStyle = slider.navStyle) !== null && _slider$navStyle !== void 0 ? _slider$navStyle : 'default',
      'data-infinite': slider.infinite ? 'true' : 'false',
      'data-responsive-tablet': slider.responsive?.tablet?.slidesToShow,
      'data-responsive-mobile': slider.responsive?.mobile?.slidesToShow
    })
  });
  return (0,react__WEBPACK_IMPORTED_MODULE_0__.createElement)(react__WEBPACK_IMPORTED_MODULE_0__.Fragment, null, (0,react__WEBPACK_IMPORTED_MODULE_0__.createElement)(_wordpress_block_editor__WEBPACK_IMPORTED_MODULE_3__.InspectorControls, null, (0,react__WEBPACK_IMPORTED_MODULE_0__.createElement)(_wordpress_components__WEBPACK_IMPORTED_MODULE_2__.PanelBody, {
    title: "Query Settings"
  }, (0,react__WEBPACK_IMPORTED_MODULE_0__.createElement)(_wordpress_components__WEBPACK_IMPORTED_MODULE_2__.RangeControl, {
    label: (0,_wordpress_i18n__WEBPACK_IMPORTED_MODULE_1__.__)("Posts per page", "thim-blocks"),
    value: courseQuery.limit,
    onChange: limit => setAttributes({
      courseQuery: {
        ...courseQuery,
        limit
      }
    }),
    min: 1,
    max: 20
  }), (0,react__WEBPACK_IMPORTED_MODULE_0__.createElement)(_wordpress_components__WEBPACK_IMPORTED_MODULE_2__.SelectControl, {
    label: (0,_wordpress_i18n__WEBPACK_IMPORTED_MODULE_1__.__)('Order By', 'thim-blocks'),
    value: courseQuery.order_by || 'post_date',
    options: [{
      value: 'post_date',
      label: (0,_wordpress_i18n__WEBPACK_IMPORTED_MODULE_1__.__)('Newly published', 'thim-blocks')
    }, {
      value: 'post_title',
      label: (0,_wordpress_i18n__WEBPACK_IMPORTED_MODULE_1__.__)('Title a-z', 'thim-blocks')
    }, {
      value: 'post_title_desc',
      label: (0,_wordpress_i18n__WEBPACK_IMPORTED_MODULE_1__.__)('Title z-a', 'thim-blocks')
    }, {
      value: 'price',
      label: (0,_wordpress_i18n__WEBPACK_IMPORTED_MODULE_1__.__)('Price high to low', 'thim-blocks')
    }, {
      value: 'price_low',
      label: (0,_wordpress_i18n__WEBPACK_IMPORTED_MODULE_1__.__)('Price low to high', 'thim-blocks')
    }, {
      value: 'popular',
      label: (0,_wordpress_i18n__WEBPACK_IMPORTED_MODULE_1__.__)('Popular', 'thim-blocks')
    }, {
      value: 'rating',
      label: (0,_wordpress_i18n__WEBPACK_IMPORTED_MODULE_1__.__)('Average Ratings', 'thim-blocks')
    }],
    onChange: order_by => setAttributes({
      courseQuery: {
        ...courseQuery,
        order_by
      }
    })
  }), (0,react__WEBPACK_IMPORTED_MODULE_0__.createElement)("hr", null), (0,react__WEBPACK_IMPORTED_MODULE_0__.createElement)("div", {
    style: {
      marginBottom: '15px'
    }
  }), (0,react__WEBPACK_IMPORTED_MODULE_0__.createElement)(_wordpress_components__WEBPACK_IMPORTED_MODULE_2__.FormTokenField, {
    label: (0,_wordpress_i18n__WEBPACK_IMPORTED_MODULE_1__.__)('Categories', 'thim-blocks'),
    value: selectedCategoryTokens,
    suggestions: categorySuggestions,
    onChange: handleCategoryChangeTokens,
    __experimentalExpandOnFocus: true
  }), (0,react__WEBPACK_IMPORTED_MODULE_0__.createElement)(_wordpress_components__WEBPACK_IMPORTED_MODULE_2__.FormTokenField, {
    label: (0,_wordpress_i18n__WEBPACK_IMPORTED_MODULE_1__.__)('Tags', 'thim-blocks'),
    value: selectedTagTokens,
    suggestions: tagSuggestions,
    onChange: handleTagChangeTokens,
    __experimentalExpandOnFocus: true
  })), (0,react__WEBPACK_IMPORTED_MODULE_0__.createElement)(_wordpress_components__WEBPACK_IMPORTED_MODULE_2__.PanelBody, {
    title: "Slider Settings",
    initialOpen: false
  }, (0,react__WEBPACK_IMPORTED_MODULE_0__.createElement)(_wordpress_components__WEBPACK_IMPORTED_MODULE_2__.ToggleControl, {
    label: "Enable Slider",
    checked: slider.enable,
    onChange: enable => setAttributes({
      slider: {
        ...slider,
        enable
      }
    })
  }), slider.enable && (0,react__WEBPACK_IMPORTED_MODULE_0__.createElement)(react__WEBPACK_IMPORTED_MODULE_0__.Fragment, null, (0,react__WEBPACK_IMPORTED_MODULE_0__.createElement)(_wordpress_components__WEBPACK_IMPORTED_MODULE_2__.RangeControl, {
    label: "Slides to Show",
    value: slider.slidesToShow,
    onChange: v => setAttributes({
      slider: {
        ...slider,
        slidesToShow: v
      }
    }),
    min: 1,
    max: 6
  }), (0,react__WEBPACK_IMPORTED_MODULE_0__.createElement)(_wordpress_components__WEBPACK_IMPORTED_MODULE_2__.RangeControl, {
    label: "Space Between",
    value: slider.spaceBetween,
    onChange: v => setAttributes({
      slider: {
        ...slider,
        spaceBetween: v
      }
    }),
    min: 0,
    max: 100
  }), (0,react__WEBPACK_IMPORTED_MODULE_0__.createElement)(_wordpress_components__WEBPACK_IMPORTED_MODULE_2__.ToggleControl, {
    label: "Autoplay",
    checked: slider.autoplay,
    onChange: v => setAttributes({
      slider: {
        ...slider,
        autoplay: v
      }
    })
  }), slider.autoplay && (0,react__WEBPACK_IMPORTED_MODULE_0__.createElement)(_wordpress_components__WEBPACK_IMPORTED_MODULE_2__.RangeControl, {
    label: "Autoplay Speed (ms)",
    value: (_slider$autoplaySpeed = slider.autoplaySpeed) !== null && _slider$autoplaySpeed !== void 0 ? _slider$autoplaySpeed : 3000,
    onChange: v => setAttributes({
      slider: {
        ...slider,
        autoplaySpeed: v
      }
    }),
    min: 500,
    max: 10000,
    step: 500
  }), (0,react__WEBPACK_IMPORTED_MODULE_0__.createElement)(_wordpress_components__WEBPACK_IMPORTED_MODULE_2__.ToggleControl, {
    label: "Dots",
    checked: slider.dots,
    onChange: v => setAttributes({
      slider: {
        ...slider,
        dots: v
      }
    })
  }), slider.dots && (0,react__WEBPACK_IMPORTED_MODULE_0__.createElement)(_wordpress_components__WEBPACK_IMPORTED_MODULE_2__.RangeControl, {
    label: "Dot Offset (px)",
    value: (_slider$dotOffset = slider.dotOffset) !== null && _slider$dotOffset !== void 0 ? _slider$dotOffset : -50,
    onChange: v => setAttributes({
      slider: {
        ...slider,
        dotOffset: v
      }
    }),
    min: -200,
    max: 100
  }), (0,react__WEBPACK_IMPORTED_MODULE_0__.createElement)(_wordpress_components__WEBPACK_IMPORTED_MODULE_2__.ToggleControl, {
    label: "Arrows",
    checked: slider.arrows,
    onChange: v => setAttributes({
      slider: {
        ...slider,
        arrows: v
      }
    })
  }), slider.arrows && (0,react__WEBPACK_IMPORTED_MODULE_0__.createElement)(_wordpress_components__WEBPACK_IMPORTED_MODULE_2__.RangeControl, {
    label: "Nav Offset (px)",
    value: (_slider$navOffset = slider.navOffset) !== null && _slider$navOffset !== void 0 ? _slider$navOffset : 30,
    onChange: v => setAttributes({
      slider: {
        ...slider,
        navOffset: v
      }
    }),
    min: -200,
    max: 200
  }), (0,react__WEBPACK_IMPORTED_MODULE_0__.createElement)(_wordpress_components__WEBPACK_IMPORTED_MODULE_2__.ToggleControl, {
    label: "Infinite Loop",
    checked: (_slider$infinite = slider.infinite) !== null && _slider$infinite !== void 0 ? _slider$infinite : true,
    onChange: v => setAttributes({
      slider: {
        ...slider,
        infinite: v
      }
    })
  }), (0,react__WEBPACK_IMPORTED_MODULE_0__.createElement)(_wordpress_components__WEBPACK_IMPORTED_MODULE_2__.RangeControl, {
    label: "Slides to Scroll",
    value: (_slider$slidesToScrol = slider.slidesToScroll) !== null && _slider$slidesToScrol !== void 0 ? _slider$slidesToScrol : 1,
    onChange: v => setAttributes({
      slider: {
        ...slider,
        slidesToScroll: v
      }
    }),
    min: 1,
    max: 6
  }), (0,react__WEBPACK_IMPORTED_MODULE_0__.createElement)(_wordpress_components__WEBPACK_IMPORTED_MODULE_2__.RangeControl, {
    label: "Responsive Tablet (slides)",
    value: (_slider$responsive$ta = slider.responsive?.tablet?.slidesToShow) !== null && _slider$responsive$ta !== void 0 ? _slider$responsive$ta : 2,
    onChange: v => setAttributes({
      slider: {
        ...slider,
        responsive: {
          ...slider.responsive,
          tablet: {
            ...slider.responsive?.tablet,
            slidesToShow: v
          }
        }
      }
    }),
    min: 1,
    max: 4
  }), (0,react__WEBPACK_IMPORTED_MODULE_0__.createElement)(_wordpress_components__WEBPACK_IMPORTED_MODULE_2__.RangeControl, {
    label: "Responsive Mobile (slides)",
    value: (_slider$responsive$mo = slider.responsive?.mobile?.slidesToShow) !== null && _slider$responsive$mo !== void 0 ? _slider$responsive$mo : 1,
    onChange: v => setAttributes({
      slider: {
        ...slider,
        responsive: {
          ...slider.responsive,
          mobile: {
            ...slider.responsive?.mobile,
            slidesToShow: v
          }
        }
      }
    }),
    min: 1,
    max: 3
  })))), (0,react__WEBPACK_IMPORTED_MODULE_0__.createElement)(_wordpress_block_editor__WEBPACK_IMPORTED_MODULE_3__.InspectorControls, {
    group: "styles"
  }, slider.enable && (0,react__WEBPACK_IMPORTED_MODULE_0__.createElement)(react__WEBPACK_IMPORTED_MODULE_0__.Fragment, null, (0,react__WEBPACK_IMPORTED_MODULE_0__.createElement)(_wordpress_components__WEBPACK_IMPORTED_MODULE_2__.PanelBody, {
    title: (0,_wordpress_i18n__WEBPACK_IMPORTED_MODULE_1__.__)('Slider Nav', 'thim-blocks'),
    initialOpen: false
  }, (0,react__WEBPACK_IMPORTED_MODULE_0__.createElement)(_wordpress_components__WEBPACK_IMPORTED_MODULE_2__.RangeControl, {
    label: (0,_wordpress_i18n__WEBPACK_IMPORTED_MODULE_1__.__)('Size', 'thim-blocks'),
    value: slider.navSize,
    onChange: v => setAttributes({
      slider: {
        ...slider,
        navSize: v
      }
    }),
    min: 10,
    max: 100
  }), (0,react__WEBPACK_IMPORTED_MODULE_0__.createElement)(_wordpress_block_editor__WEBPACK_IMPORTED_MODULE_3__.PanelColorSettings, {
    title: (0,react__WEBPACK_IMPORTED_MODULE_0__.createElement)("div", {
      style: {
        paddingBottom: '12px'
      }
    }, (0,_wordpress_i18n__WEBPACK_IMPORTED_MODULE_1__.__)('Nav Arrow (Normal)', 'thim-blocks')),
    initialOpen: false,
    colorSettings: [{
      value: slider.navColor,
      onChange: v => setAttributes({
        slider: {
          ...slider,
          navColor: v
        }
      }),
      label: (0,_wordpress_i18n__WEBPACK_IMPORTED_MODULE_1__.__)('Text', 'thim-blocks')
    }, {
      value: slider.navBackground,
      onChange: v => setAttributes({
        slider: {
          ...slider,
          navBackground: v
        }
      }),
      label: (0,_wordpress_i18n__WEBPACK_IMPORTED_MODULE_1__.__)('Background', 'thim-blocks')
    }]
  }), (0,react__WEBPACK_IMPORTED_MODULE_0__.createElement)(_wordpress_block_editor__WEBPACK_IMPORTED_MODULE_3__.PanelColorSettings, {
    title: (0,react__WEBPACK_IMPORTED_MODULE_0__.createElement)("div", {
      style: {
        paddingBottom: '12px'
      }
    }, (0,_wordpress_i18n__WEBPACK_IMPORTED_MODULE_1__.__)('Nav Arrow (Hover)', 'thim-blocks')),
    initialOpen: false,
    colorSettings: [{
      value: slider.navHoverColor,
      onChange: v => setAttributes({
        slider: {
          ...slider,
          navHoverColor: v
        }
      }),
      label: (0,_wordpress_i18n__WEBPACK_IMPORTED_MODULE_1__.__)('Text', 'thim-blocks')
    }, {
      value: slider.navHoverBackground,
      onChange: v => setAttributes({
        slider: {
          ...slider,
          navHoverBackground: v
        }
      }),
      label: (0,_wordpress_i18n__WEBPACK_IMPORTED_MODULE_1__.__)('Background', 'thim-blocks')
    }]
  })), (0,react__WEBPACK_IMPORTED_MODULE_0__.createElement)(_wordpress_components__WEBPACK_IMPORTED_MODULE_2__.PanelBody, {
    title: (0,_wordpress_i18n__WEBPACK_IMPORTED_MODULE_1__.__)('Slider Dots', 'thim-blocks'),
    initialOpen: true
  }, (0,react__WEBPACK_IMPORTED_MODULE_0__.createElement)(_wordpress_block_editor__WEBPACK_IMPORTED_MODULE_3__.PanelColorSettings, {
    title: (0,react__WEBPACK_IMPORTED_MODULE_0__.createElement)("div", {
      style: {
        paddingBottom: '12px'
      }
    }, (0,_wordpress_i18n__WEBPACK_IMPORTED_MODULE_1__.__)('Dots Color', 'thim-blocks')),
    initialOpen: false,
    colorSettings: [{
      value: slider.dotColor,
      onChange: v => setAttributes({
        slider: {
          ...slider,
          dotColor: v
        }
      }),
      label: (0,_wordpress_i18n__WEBPACK_IMPORTED_MODULE_1__.__)('Normal', 'thim-blocks')
    }, {
      value: slider.dotHoverColor,
      onChange: v => setAttributes({
        slider: {
          ...slider,
          dotHoverColor: v
        }
      }),
      label: (0,_wordpress_i18n__WEBPACK_IMPORTED_MODULE_1__.__)('Hover / Active', 'thim-blocks')
    }]
  })))), (0,react__WEBPACK_IMPORTED_MODULE_0__.createElement)("div", {
    ...blockProps,
    ref: blockRef
  }, (0,react__WEBPACK_IMPORTED_MODULE_0__.createElement)(_wordpress_block_editor__WEBPACK_IMPORTED_MODULE_3__.InnerBlocks, {
    template: QUERY_LOOP_TEMPLATE,
    templateLock: false
  })));
};
/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (Edit);

/***/ }),

/***/ "./assets/src/blocks/courses/editor-slider.js":
/*!****************************************************!*\
  !*** ./assets/src/blocks/courses/editor-slider.js ***!
  \****************************************************/
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {

__webpack_require__.r(__webpack_exports__);
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */   destroyEditorSlider: () => (/* binding */ destroyEditorSlider),
/* harmony export */   initEditorSlider: () => (/* binding */ initEditorSlider)
/* harmony export */ });
/**
 * Editor Slider - CSS Scroll Snap based preview
 * Uses CSS scroll-snap instead of Swiper to avoid conflicts with React DOM in the editor.
 * Styles defined in style.scss (class .thim-slider-active, .thim-editor-dot.is-active)
 *
 * DOM structure in editor (from LearnPress InnerBlocks):
 *   .block-editor-block-list__layout
 *     └── ul.learn-press-courses
 *           ├── li.course (slide 1)
 *           ├── li.course (slide 2)
 *           └── li.course (slide 3)
 *     └── .block-list-appender
 */

const instances = new Map();
const observers = new Map();
function initEditorSlider(blockEl) {
  if (!blockEl) return;
  destroyEditorSlider(blockEl);
  const tryInit = () => {
    const courseList = blockEl.querySelector('ul.learn-press-courses');
    if (!courseList) return false;
    const courseItems = Array.from(courseList.querySelectorAll('li.course')).filter(item => item.style.display !== 'none');
    if (courseItems.length === 0) return false;

    // Check if this exact DOM is already initialized
    if (courseList.classList.contains('thim-slider-active') && courseItems[0].style.minWidth) {
      return true;
    }
    applySlider(blockEl, courseList, courseItems);
    return true;
  };
  tryInit();

  // Persistent MutationObserver to handle LearnPress dynamic DOM reloads
  const observer = new MutationObserver(mutations => {
    let shouldCheck = false;
    for (const m of mutations) {
      if (m.type === 'childList' && m.addedNodes.length > 0) {
        // Ignore our own added nav elements to prevent infinite loops
        for (const node of m.addedNodes) {
          if (node.nodeType === 1 && !node.classList.contains('thim-editor-slider-nav') && !node.classList.contains('thim-editor-arrow')) {
            shouldCheck = true;
            break;
          }
        }
      }
      if (shouldCheck) break;
    }
    if (shouldCheck) {
      tryInit();
    }
  });
  observer.observe(blockEl, {
    childList: true,
    subtree: true
  });
  observers.set(blockEl, observer);
}
function applySlider(blockEl, courseList, courseItems) {
  const slidesToShow = parseInt(blockEl.dataset.slidesToShow) || 3;
  const spaceBetween = parseInt(blockEl.dataset.spaceBetween) || 30;
  const showArrows = blockEl.dataset.arrows === 'true';
  const showDots = blockEl.dataset.dots === 'true';
  const autoplay = blockEl.dataset.autoplay === 'true';
  const autoplaySpeed = parseInt(blockEl.dataset.autoplaySpeed) || 3000;
  const infinite = blockEl.dataset.infinite === 'true';
  const slideWidth = `calc((100% - ${spaceBetween * (slidesToShow - 1)}px) / ${slidesToShow})`;

  // Apply class to activate CSS scroll-snap from style.scss
  courseList.classList.add('thim-slider-active');
  courseList.style.gap = `${spaceBetween}px`;

  // Remove LearnPress grid styles
  courseList.style.removeProperty('--columns');
  courseList.removeAttribute('data-layout');

  // Set fixed width for each li
  courseItems.forEach(item => {
    item.style.minWidth = slideWidth;
    item.style.maxWidth = slideWidth;
  });
  let currentIndex = 0;
  const maxIndex = Math.max(0, courseItems.length - slidesToShow);
  const isSliderActive = maxIndex > 0;
  const getItems = () => Array.from(courseList.querySelectorAll('li.course')).filter(item => item.style.display !== 'none');

  // Remove old nav elements if any to prevent duplicates during re-renders
  blockEl.querySelector('.thim-editor-slider-nav')?.remove();
  blockEl.querySelectorAll('.thim-editor-arrow').forEach(el => el.remove());
  const navEl = document.createElement('div');
  navEl.className = 'thim-editor-slider-nav';
  let autoplayTimer = null;
  const scrollTo = index => {
    const items = getItems();
    if (infinite && isSliderActive) {
      if (index > maxIndex) index = 0;else if (index < 0) index = maxIndex;
    } else {
      index = Math.max(0, Math.min(index, maxIndex));
    }
    currentIndex = index;
    items[currentIndex]?.scrollIntoView({
      behavior: 'smooth',
      block: 'nearest',
      inline: 'start'
    });
    navEl.querySelectorAll('.thim-editor-dot').forEach((dot, i) => {
      dot.classList.toggle('is-active', i === currentIndex);
    });
  };
  let prevBtn = null;
  let nextBtn = null;
  if (showArrows && isSliderActive) {
    prevBtn = createArrowBtn('<i class="tb-icon-angle-left"></i>', 'is-prev', () => {
      if (autoplayTimer) clearInterval(autoplayTimer); // pause on interaction
      scrollTo(currentIndex - 1);
    });
    nextBtn = createArrowBtn('<i class="tb-icon-angle-right"></i>', 'is-next', () => {
      if (autoplayTimer) clearInterval(autoplayTimer); // pause on interaction
      scrollTo(currentIndex + 1);
    });
    blockEl.appendChild(prevBtn);
    blockEl.appendChild(nextBtn);
  }
  if (showDots && isSliderActive) {
    const dotsWrap = document.createElement('div');
    dotsWrap.style.cssText = 'display:flex;gap:6px;align-items:center;';

    // Generate exactly (maxIndex + 1) dots so we don't end up with dots that scroll to empty space
    for (let i = 0; i <= maxIndex; i++) {
      const dot = document.createElement('button');
      dot.className = 'thim-editor-dot' + (i === 0 ? ' is-active' : '');
      dot.addEventListener('click', e => {
        e.preventDefault();
        e.stopPropagation();
        if (autoplayTimer) clearInterval(autoplayTimer); // pause on interaction
        scrollTo(i);
      });
      dotsWrap.appendChild(dot);
    }
    navEl.appendChild(dotsWrap);
  }
  if (autoplay && isSliderActive) {
    autoplayTimer = setInterval(() => {
      let nextIndex = currentIndex + 1;
      if (nextIndex > maxIndex) {
        if (infinite) {
          nextIndex = 0;
        } else {
          clearInterval(autoplayTimer);
          return;
        }
      }
      scrollTo(nextIndex);
    }, Math.max(1000, autoplaySpeed)); // minimum 1s to prevent chaos
  }
  if (navEl.children.length > 0) {
    blockEl.appendChild(navEl);
  }
  instances.set(blockEl, {
    courseList,
    courseItems,
    navEl,
    prevBtn,
    nextBtn,
    autoplayTimer
  });
}
function createArrowBtn(symbol, direction, onClick) {
  const btn = document.createElement('button');
  btn.className = `thim-editor-arrow ${direction}`;
  btn.innerHTML = symbol;
  btn.addEventListener('click', e => {
    e.preventDefault();
    e.stopPropagation();
    onClick();
  });
  return btn;
}

/**
 * Destroy slider and restore original layout
 */
function destroyEditorSlider(blockEl) {
  if (!blockEl) return;

  // Stop observer if waiting for LP to load
  if (observers.has(blockEl)) {
    observers.get(blockEl).disconnect();
    observers.delete(blockEl);
  }
  const inst = instances.get(blockEl);
  if (inst) {
    if (inst.autoplayTimer) {
      clearInterval(inst.autoplayTimer);
    }
    inst.navEl?.remove();
    if (inst.courseList) {
      inst.courseList.classList.remove('thim-slider-active');
      inst.courseList.style.removeProperty('gap');
    }
    inst.courseItems?.forEach(item => {
      item.style.removeProperty('min-width');
      item.style.removeProperty('max-width');
    });
    instances.delete(blockEl);
  }

  // Remove any leftover nav/arrow elements
  blockEl.querySelector('.thim-editor-slider-nav')?.remove();
  blockEl.querySelectorAll('.thim-editor-arrow').forEach(el => el.remove());
}

/***/ }),

/***/ "./assets/src/blocks/courses/index.js":
/*!********************************************!*\
  !*** ./assets/src/blocks/courses/index.js ***!
  \********************************************/
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {

__webpack_require__.r(__webpack_exports__);
/* harmony import */ var _edit__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./edit */ "./assets/src/blocks/courses/edit.js");
/* harmony import */ var _save__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./save */ "./assets/src/blocks/courses/save.js");
/* harmony import */ var _block_json__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./block.json */ "./assets/src/blocks/courses/block.json");
/* harmony import */ var _wordpress_blocks__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! @wordpress/blocks */ "@wordpress/blocks");
/* harmony import */ var _wordpress_blocks__WEBPACK_IMPORTED_MODULE_3___default = /*#__PURE__*/__webpack_require__.n(_wordpress_blocks__WEBPACK_IMPORTED_MODULE_3__);
/* harmony import */ var _style_scss__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./style.scss */ "./assets/src/blocks/courses/style.scss");
/**
 * Register block course title.
 */





(0,_wordpress_blocks__WEBPACK_IMPORTED_MODULE_3__.registerBlockType)('thim-blocks/courses', {
  ..._block_json__WEBPACK_IMPORTED_MODULE_2__,
  edit: _edit__WEBPACK_IMPORTED_MODULE_0__["default"],
  save: _save__WEBPACK_IMPORTED_MODULE_1__["default"]
});

/***/ }),

/***/ "./assets/src/blocks/courses/save.js":
/*!*******************************************!*\
  !*** ./assets/src/blocks/courses/save.js ***!
  \*******************************************/
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {

__webpack_require__.r(__webpack_exports__);
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */   "default": () => (__WEBPACK_DEFAULT_EXPORT__)
/* harmony export */ });
/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react */ "react");
/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(react__WEBPACK_IMPORTED_MODULE_0__);
/* harmony import */ var _wordpress_block_editor__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @wordpress/block-editor */ "@wordpress/block-editor");
/* harmony import */ var _wordpress_block_editor__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(_wordpress_block_editor__WEBPACK_IMPORTED_MODULE_1__);


const Save = props => {
  const {
    attributes
  } = props;
  const {
    slider
  } = attributes;

  // Create block props with slider class if enabled
  const blockProps = _wordpress_block_editor__WEBPACK_IMPORTED_MODULE_1__.useBlockProps.save({
    className: slider.enable ? 'thim-courses-slider' : '',
    ...(slider.enable ? {
      'data-slider': 'true',
      'data-slides-to-show': slider.slidesToShow,
      'data-slides-to-scroll': slider.slidesToScroll,
      'data-autoplay': slider.autoplay ? 'true' : 'false',
      'data-autoplay-speed': slider.autoplaySpeed,
      'data-dots': slider.dots ? 'true' : 'false',
      'data-arrows': slider.arrows ? 'true' : 'false',
      'data-infinite': slider.infinite ? 'true' : 'false',
      'data-responsive-tablet': slider.responsive.tablet.slidesToShow,
      'data-responsive-mobile': slider.responsive.mobile.slidesToShow
    } : {})
  });
  return (0,react__WEBPACK_IMPORTED_MODULE_0__.createElement)("div", {
    ...blockProps
  }, (0,react__WEBPACK_IMPORTED_MODULE_0__.createElement)(_wordpress_block_editor__WEBPACK_IMPORTED_MODULE_1__.InnerBlocks.Content, null));
};
/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (Save);

/***/ }),

/***/ "./assets/src/blocks/courses/style.scss":
/*!**********************************************!*\
  !*** ./assets/src/blocks/courses/style.scss ***!
  \**********************************************/
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {

__webpack_require__.r(__webpack_exports__);
// extracted by mini-css-extract-plugin


/***/ }),

/***/ "react":
/*!************************!*\
  !*** external "React" ***!
  \************************/
/***/ ((module) => {

module.exports = window["React"];

/***/ }),

/***/ "@wordpress/block-editor":
/*!*************************************!*\
  !*** external ["wp","blockEditor"] ***!
  \*************************************/
/***/ ((module) => {

module.exports = window["wp"]["blockEditor"];

/***/ }),

/***/ "@wordpress/blocks":
/*!********************************!*\
  !*** external ["wp","blocks"] ***!
  \********************************/
/***/ ((module) => {

module.exports = window["wp"]["blocks"];

/***/ }),

/***/ "@wordpress/components":
/*!************************************!*\
  !*** external ["wp","components"] ***!
  \************************************/
/***/ ((module) => {

module.exports = window["wp"]["components"];

/***/ }),

/***/ "@wordpress/data":
/*!******************************!*\
  !*** external ["wp","data"] ***!
  \******************************/
/***/ ((module) => {

module.exports = window["wp"]["data"];

/***/ }),

/***/ "@wordpress/element":
/*!*********************************!*\
  !*** external ["wp","element"] ***!
  \*********************************/
/***/ ((module) => {

module.exports = window["wp"]["element"];

/***/ }),

/***/ "@wordpress/html-entities":
/*!**************************************!*\
  !*** external ["wp","htmlEntities"] ***!
  \**************************************/
/***/ ((module) => {

module.exports = window["wp"]["htmlEntities"];

/***/ }),

/***/ "@wordpress/i18n":
/*!******************************!*\
  !*** external ["wp","i18n"] ***!
  \******************************/
/***/ ((module) => {

module.exports = window["wp"]["i18n"];

/***/ }),

/***/ "./assets/src/blocks/courses/block.json":
/*!**********************************************!*\
  !*** ./assets/src/blocks/courses/block.json ***!
  \**********************************************/
/***/ ((module) => {

module.exports = /*#__PURE__*/JSON.parse('{"$schema":"https://schemas.wp.org/trunk/block.json","apiVersion":3,"name":"thim-blocks/courses","title":"Thim Courses","category":"thim-block-category","description":"Course Listing block","textdomain":"thim-blocks","keywords":["listing course","thim","query loop"],"usesContext":[],"attributes":{"courseQuery":{"type":"object","default":{"limit":10,"order_by":"post_date","tag_slug":"","term_slug":""}},"gridGap":{"type":"number","default":20},"slider":{"type":"object","default":{"enable":false,"slidesToShow":3,"slidesToScroll":1,"spaceBetween":30,"autoplay":false,"autoplaySpeed":3000,"dots":true,"dotStyle":"default","dotOffset":-50,"arrows":true,"navStyle":"default","navOffset":30,"infinite":true,"responsive":{"tablet":{"slidesToShow":2},"mobile":{"slidesToShow":1}}}}},"providesContext":{"lpCourseQuery":"courseQuery"},"supports":{"html":false,"align":["wide","full"]}}');

/***/ })

/******/ 	});
/************************************************************************/
/******/ 	// The module cache
/******/ 	var __webpack_module_cache__ = {};
/******/ 	
/******/ 	// The require function
/******/ 	function __webpack_require__(moduleId) {
/******/ 		// Check if module is in cache
/******/ 		var cachedModule = __webpack_module_cache__[moduleId];
/******/ 		if (cachedModule !== undefined) {
/******/ 			return cachedModule.exports;
/******/ 		}
/******/ 		// Create a new module (and put it into the cache)
/******/ 		var module = __webpack_module_cache__[moduleId] = {
/******/ 			// no module.id needed
/******/ 			// no module.loaded needed
/******/ 			exports: {}
/******/ 		};
/******/ 	
/******/ 		// Execute the module function
/******/ 		__webpack_modules__[moduleId](module, module.exports, __webpack_require__);
/******/ 	
/******/ 		// Return the exports of the module
/******/ 		return module.exports;
/******/ 	}
/******/ 	
/******/ 	// expose the modules object (__webpack_modules__)
/******/ 	__webpack_require__.m = __webpack_modules__;
/******/ 	
/************************************************************************/
/******/ 	/* webpack/runtime/chunk loaded */
/******/ 	(() => {
/******/ 		var deferred = [];
/******/ 		__webpack_require__.O = (result, chunkIds, fn, priority) => {
/******/ 			if(chunkIds) {
/******/ 				priority = priority || 0;
/******/ 				for(var i = deferred.length; i > 0 && deferred[i - 1][2] > priority; i--) deferred[i] = deferred[i - 1];
/******/ 				deferred[i] = [chunkIds, fn, priority];
/******/ 				return;
/******/ 			}
/******/ 			var notFulfilled = Infinity;
/******/ 			for (var i = 0; i < deferred.length; i++) {
/******/ 				var [chunkIds, fn, priority] = deferred[i];
/******/ 				var fulfilled = true;
/******/ 				for (var j = 0; j < chunkIds.length; j++) {
/******/ 					if ((priority & 1 === 0 || notFulfilled >= priority) && Object.keys(__webpack_require__.O).every((key) => (__webpack_require__.O[key](chunkIds[j])))) {
/******/ 						chunkIds.splice(j--, 1);
/******/ 					} else {
/******/ 						fulfilled = false;
/******/ 						if(priority < notFulfilled) notFulfilled = priority;
/******/ 					}
/******/ 				}
/******/ 				if(fulfilled) {
/******/ 					deferred.splice(i--, 1)
/******/ 					var r = fn();
/******/ 					if (r !== undefined) result = r;
/******/ 				}
/******/ 			}
/******/ 			return result;
/******/ 		};
/******/ 	})();
/******/ 	
/******/ 	/* webpack/runtime/compat get default export */
/******/ 	(() => {
/******/ 		// getDefaultExport function for compatibility with non-harmony modules
/******/ 		__webpack_require__.n = (module) => {
/******/ 			var getter = module && module.__esModule ?
/******/ 				() => (module['default']) :
/******/ 				() => (module);
/******/ 			__webpack_require__.d(getter, { a: getter });
/******/ 			return getter;
/******/ 		};
/******/ 	})();
/******/ 	
/******/ 	/* webpack/runtime/define property getters */
/******/ 	(() => {
/******/ 		// define getter functions for harmony exports
/******/ 		__webpack_require__.d = (exports, definition) => {
/******/ 			for(var key in definition) {
/******/ 				if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {
/******/ 					Object.defineProperty(exports, key, { enumerable: true, get: definition[key] });
/******/ 				}
/******/ 			}
/******/ 		};
/******/ 	})();
/******/ 	
/******/ 	/* webpack/runtime/hasOwnProperty shorthand */
/******/ 	(() => {
/******/ 		__webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))
/******/ 	})();
/******/ 	
/******/ 	/* webpack/runtime/make namespace object */
/******/ 	(() => {
/******/ 		// define __esModule on exports
/******/ 		__webpack_require__.r = (exports) => {
/******/ 			if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
/******/ 				Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
/******/ 			}
/******/ 			Object.defineProperty(exports, '__esModule', { value: true });
/******/ 		};
/******/ 	})();
/******/ 	
/******/ 	/* webpack/runtime/jsonp chunk loading */
/******/ 	(() => {
/******/ 		// no baseURI
/******/ 		
/******/ 		// object to store loaded and loading chunks
/******/ 		// undefined = chunk not loaded, null = chunk preloaded/prefetched
/******/ 		// [resolve, reject, Promise] = chunk loading, 0 = chunk loaded
/******/ 		var installedChunks = {
/******/ 			"blocks/courses": 0,
/******/ 			"blocks/style-courses": 0
/******/ 		};
/******/ 		
/******/ 		// no chunk on demand loading
/******/ 		
/******/ 		// no prefetching
/******/ 		
/******/ 		// no preloaded
/******/ 		
/******/ 		// no HMR
/******/ 		
/******/ 		// no HMR manifest
/******/ 		
/******/ 		__webpack_require__.O.j = (chunkId) => (installedChunks[chunkId] === 0);
/******/ 		
/******/ 		// install a JSONP callback for chunk loading
/******/ 		var webpackJsonpCallback = (parentChunkLoadingFunction, data) => {
/******/ 			var [chunkIds, moreModules, runtime] = data;
/******/ 			// add "moreModules" to the modules object,
/******/ 			// then flag all "chunkIds" as loaded and fire callback
/******/ 			var moduleId, chunkId, i = 0;
/******/ 			if(chunkIds.some((id) => (installedChunks[id] !== 0))) {
/******/ 				for(moduleId in moreModules) {
/******/ 					if(__webpack_require__.o(moreModules, moduleId)) {
/******/ 						__webpack_require__.m[moduleId] = moreModules[moduleId];
/******/ 					}
/******/ 				}
/******/ 				if(runtime) var result = runtime(__webpack_require__);
/******/ 			}
/******/ 			if(parentChunkLoadingFunction) parentChunkLoadingFunction(data);
/******/ 			for(;i < chunkIds.length; i++) {
/******/ 				chunkId = chunkIds[i];
/******/ 				if(__webpack_require__.o(installedChunks, chunkId) && installedChunks[chunkId]) {
/******/ 					installedChunks[chunkId][0]();
/******/ 				}
/******/ 				installedChunks[chunkId] = 0;
/******/ 			}
/******/ 			return __webpack_require__.O(result);
/******/ 		}
/******/ 		
/******/ 		var chunkLoadingGlobal = globalThis["webpackChunkthim_blocks"] = globalThis["webpackChunkthim_blocks"] || [];
/******/ 		chunkLoadingGlobal.forEach(webpackJsonpCallback.bind(null, 0));
/******/ 		chunkLoadingGlobal.push = webpackJsonpCallback.bind(null, chunkLoadingGlobal.push.bind(chunkLoadingGlobal));
/******/ 	})();
/******/ 	
/************************************************************************/
/******/ 	
/******/ 	// startup
/******/ 	// Load entry module and return exports
/******/ 	// This entry module depends on other loaded chunks and execution need to be delayed
/******/ 	var __webpack_exports__ = __webpack_require__.O(undefined, ["blocks/style-courses"], () => (__webpack_require__("./assets/src/blocks/courses/index.js")))
/******/ 	__webpack_exports__ = __webpack_require__.O(__webpack_exports__);
/******/ 	
/******/ })()
;
//# sourceMappingURL=courses.js.map