/******/ (function() { // webpackBootstrap from here https://github.com/MarieComet/core-block-custom-attributes
/******/ 	var __webpack_modules__ = ({

/***/ "./src/attributes/toolbarButton.js":
/*!*****************************************!*\
  !*** ./src/attributes/toolbarButton.js ***!
  \*****************************************/
/***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) {

"use strict";
__webpack_require__.r(__webpack_exports__);
/* harmony import */ var _babel_runtime_helpers_extends__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @babel/runtime/helpers/extends */ "./node_modules/@babel/runtime/helpers/esm/extends.js");
/* harmony import */ var _wordpress_element__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @wordpress/element */ "@wordpress/element");
/* harmony import */ var _wordpress_element__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(_wordpress_element__WEBPACK_IMPORTED_MODULE_1__);
/* harmony import */ var classnames__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! classnames */ "./node_modules/classnames/index.js");
/* harmony import */ var classnames__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(classnames__WEBPACK_IMPORTED_MODULE_2__);



/* Add custom attribute to image block, in Toolbar */
const {
  __
} = wp.i18n; // Enable custom attributes on image block

const enableToolbarButtonOnBlocks = ['core/image'];
const {  createHigherOrderComponent} = wp.compose;
const {  Fragment} = wp.element;
const {  BlockControls} = wp.blockEditor;
const {  ToolbarGroup,  ToolbarButton,	Icon} = wp.components;
const {  onSelectURL } = wp.editor.MediaPlaceholder;

/**
 * Declare our custom attribute
 */
const setToolbarButtonAttribute = (settings, name) => {
  // Do nothing if it's another block than our defined ones.
  if (!enableToolbarButtonOnBlocks.includes(name)) {
    return settings;
  }
  return Object.assign({}, settings, {
    attributes: Object.assign({}, settings.attributes, {
      imageAttribute: {
        type: 'string',
				default: 'notset'
      },
			//url:{type:'string'} //  H R E F
    })
  });
};
wp.hooks.addFilter('blocks.registerBlockType', 'custom-attributes/set-toolbar-button-attribute', setToolbarButtonAttribute);


/**
 * Add Custom Button to image Toolbar abandon use class
 */

const withToolbarButton = createHigherOrderComponent(BlockEdit => {
  return props => {
    // If current block is not allowed
    if (!enableToolbarButtonOnBlocks.includes(props.name)) {
      return (0,_wordpress_element__WEBPACK_IMPORTED_MODULE_1__.createElement)(BlockEdit, props);
    }

    const {      attributes,      setAttributes    } = props;
    const {      imageAttribute    } = attributes;
		//callback for when image is ready on eloopimageready event
		function setImageCB( newBg ) {
      console.log("block^^^^ setImageCB^^^have props?"+props+"^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^");
      console.log("block^^^^ setImageCB(blockid:"+newBg.blockid+" =? myid:"+props.attributes.id+":");
      if(newBg.blockid==props.attributes.id){
        var newurl = newBg.mediaurl;
        var thecode= newBg.blockcode;
        // e.g. newurl  = '/wp-content/uploads/2026/01/genolve-' + thecode.replace(/\s+/g,"-") +'.jpg';

        console.log("block^^^^ setImageCB to:"+thecode+" url:"+newurl);
        props.setAttributes( {
          imageAttribute: thecode,
          url: newurl
        } );
        }
      }
    return (0,_wordpress_element__WEBPACK_IMPORTED_MODULE_1__.createElement)(Fragment, null, (0,_wordpress_element__WEBPACK_IMPORTED_MODULE_1__.createElement)(BlockControls, {
      group: "block"
    }, (0,_wordpress_element__WEBPACK_IMPORTED_MODULE_1__.createElement)(ToolbarGroup, null, (0,_wordpress_element__WEBPACK_IMPORTED_MODULE_1__.createElement)(ToolbarButton, {
     icon: 'howtochangethisicon',
      label: __('Make Image with Genolve', 'core-block-custom-attributes'),
      isActive: imageAttribute === 'custom',
      onClick: () => {
				/* ogrig class logic
				if (imageAttribute === 'custom') {
          setAttributes({      imageAttribute: false    });
        } else {
          setAttributes({      imageAttribute: 'custom'  });
				}
				*/
					// genolve popup:
				 console.log("custom button clicked, have props?"+typeof(props));
				 if(genolve_customize){// this is null: this.parentElement.getAttribute('data-block')
						jQuery(window).off('eloopimageready');
						jQuery(window).on('eloopimageready',setImageCB);
						
						console.log('genolve_customize startup! for block id:' +props.attributes.id+' code attr:'+props.attributes.imageAttribute+' src:'+props.attributes.url+' templatediv?'+jQuery('#templatediv').length+' onSelect?'+typeof(onSelectURL));
						var zurl = 'http://localhost/wp-content/uploads/2023/04/863418.jpg';
						//onSelectURL(zurl);
						
						genolve_customize.startupGenolve('block-image',{blockid:props.attributes.id,blockcode:imageAttribute,blockurl:props.attributes.url});
						}
					else 
						console.log('found no genolve_customize!');
				}
    }))), (0,_wordpress_element__WEBPACK_IMPORTED_MODULE_1__.createElement)(BlockEdit, props));
  };
}, 'withToolbarButton');
wp.hooks.addFilter('editor.BlockEdit', 'custom-attributes/with-toolbar-button', withToolbarButton);
/**
 * Add custom class to block in Edit
 */

const withToolbarButtonProp = createHigherOrderComponent(BlockListBlock => {
  return props => {
    // If current block is not allowed
    if (!enableToolbarButtonOnBlocks.includes(props.name)) {
      return (0,_wordpress_element__WEBPACK_IMPORTED_MODULE_1__.createElement)(BlockListBlock, props);
    }

    const {      attributes    } = props;
    const {      imageAttribute    } = attributes;
console.log('imageblock ==================withToolbarButtonProp with attr'+imageAttribute);
    if (imageAttribute && 'custom' === imageAttribute) {
      return (0,_wordpress_element__WEBPACK_IMPORTED_MODULE_1__.createElement)(BlockListBlock, (0,_babel_runtime_helpers_extends__WEBPACK_IMPORTED_MODULE_0__["default"])({}, props, {
       // orig 
			 //className: 'has-custom-attribute',
			 'dataCode':'NOTSET',
			 //url:'http://localhost/wp-content/uploads/2023/04/863418.jpg'   //  H R E F
      }));
    } else {
      return (0,_wordpress_element__WEBPACK_IMPORTED_MODULE_1__.createElement)(BlockListBlock, props);
    }
  };
}, 'withToolbarButtonProp');
wp.hooks.addFilter('editor.BlockListBlock', 'custom-attributes/with-toolbar-button-prop', withToolbarButtonProp);
/**
 * Save our custom attribute
 */

const saveToolbarButtonAttribute = (extraProps, blockType, attributes) => {
  // Do nothing if it's another block than our defined ones.
  if (enableToolbarButtonOnBlocks.includes(blockType.name)) {
    const {      imageAttribute    } = attributes;
		console.log('imageblock ==================saveToolbarButtonAttribute with attr:'+imageAttribute);
    if (imageAttribute && 'custom' === imageAttribute) {
      // orig 
			//extraProps.className = classnames__WEBPACK_IMPORTED_MODULE_2___default()(extraProps.className, 'has-custom-attribute');
			extraProps.dataCode =  'some-custom-name';
			//extraProps.url = classnames__WEBPACK_IMPORTED_MODULE_2___default()(extraProps.url, 'http://localhost/wp-content/uploads/2023/04/863418.jpg');//  H R E F
    }
  }

  return extraProps;
};

wp.hooks.addFilter('blocks.getSaveContent.extraProps', 'custom-attributes/save-toolbar-button-attribute', saveToolbarButtonAttribute);

/***/ }),

/***/ "./node_modules/classnames/index.js":
/*!******************************************!*\
  !*** ./node_modules/classnames/index.js ***!
  \******************************************/
/***/ (function(module, exports) {

var __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;/*!
  Copyright (c) 2018 Jed Watson.
  Licensed under the MIT License (MIT), see
  http://jedwatson.github.io/classnames
*/
/* global define */

(function () {
	'use strict';

	var hasOwn = {}.hasOwnProperty;

	function classNames() {
		var classes = [];

		for (var i = 0; i < arguments.length; i++) {
			var arg = arguments[i];
			if (!arg) continue;

			var argType = typeof arg;

			if (argType === 'string' || argType === 'number') {
				classes.push(arg);
			} else if (Array.isArray(arg)) {
				if (arg.length) {
					var inner = classNames.apply(null, arg);
					if (inner) {
						classes.push(inner);
					}
				}
			} else if (argType === 'object') {
				if (arg.toString === Object.prototype.toString) {
					for (var key in arg) {
						if (hasOwn.call(arg, key) && arg[key]) {
							classes.push(key);
						}
					}
				} else {
					classes.push(arg.toString());
				}
			}
		}

		return classes.join(' ');
	}

	if ( true && module.exports) {
		classNames.default = classNames;
		module.exports = classNames;
	} else if (true) {
		// register as 'classnames', consistent with npm package name
		!(__WEBPACK_AMD_DEFINE_ARRAY__ = [], __WEBPACK_AMD_DEFINE_RESULT__ = (function () {
			return classNames;
		}).apply(exports, __WEBPACK_AMD_DEFINE_ARRAY__),
		__WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__));
	} else {}
}());


/***/ }),

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

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

/***/ }),

/***/ "./node_modules/@babel/runtime/helpers/esm/extends.js":
/*!************************************************************!*\
  !*** ./node_modules/@babel/runtime/helpers/esm/extends.js ***!
  \************************************************************/
/***/ (function(__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {

"use strict";
__webpack_require__.r(__webpack_exports__);
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */   "default": function() { return /* binding */ _extends; }
/* harmony export */ });
function _extends() {
  _extends = Object.assign || function (target) {
    for (var i = 1; i < arguments.length; i++) {
      var source = arguments[i];

      for (var key in source) {
        if (Object.prototype.hasOwnProperty.call(source, key)) {
          target[key] = source[key];
        }
      }
    }

    return target;
  };

  return _extends.apply(this, arguments);
}

/***/ })

/******/ 	});
/************************************************************************/
/******/ 	// 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;
/******/ 	}
/******/ 	
/************************************************************************/
/******/ 	/* webpack/runtime/compat get default export */
/******/ 	!function() {
/******/ 		// getDefaultExport function for compatibility with non-harmony modules
/******/ 		__webpack_require__.n = function(module) {
/******/ 			var getter = module && module.__esModule ?
/******/ 				function() { return module['default']; } :
/******/ 				function() { return module; };
/******/ 			__webpack_require__.d(getter, { a: getter });
/******/ 			return getter;
/******/ 		};
/******/ 	}();
/******/ 	
/******/ 	/* webpack/runtime/define property getters */
/******/ 	!function() {
/******/ 		// define getter functions for harmony exports
/******/ 		__webpack_require__.d = function(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 */
/******/ 	!function() {
/******/ 		__webpack_require__.o = function(obj, prop) { return Object.prototype.hasOwnProperty.call(obj, prop); }
/******/ 	}();
/******/ 	
/******/ 	/* webpack/runtime/make namespace object */
/******/ 	!function() {
/******/ 		// define __esModule on exports
/******/ 		__webpack_require__.r = function(exports) {
/******/ 			if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
/******/ 				Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
/******/ 			}
/******/ 			Object.defineProperty(exports, '__esModule', { value: true });
/******/ 		};
/******/ 	}();
/******/ 	
/************************************************************************/
var __webpack_exports__ = {};
// This entry need to be wrapped in an IIFE because it need to be in strict mode.
!function() {
"use strict";
/*!**********************!*\
  !*** ./src/index.js ***!
  \**********************/
__webpack_require__.r(__webpack_exports__);
/* harmony import */ var _attributes_toolbarButton__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./attributes/toolbarButton */ "./src/attributes/toolbarButton.js");


}();
/******/ })()
;
//# sourceMappingURL=index.js.map