diff --git a/assets/img/editor-icon.svg b/assets/img/editor-icon.svg new file mode 100644 index 000000000..14f855bbe --- /dev/null +++ b/assets/img/editor-icon.svg @@ -0,0 +1,3 @@ + + + diff --git a/classifai.php b/classifai.php index 7e9f73976..0fb1bacc4 100644 --- a/classifai.php +++ b/classifai.php @@ -4,7 +4,7 @@ * Plugin URI: https://github.com/10up/classifai * Update URI: https://classifaiplugin.com * Description: Enhance your WordPress content with Artificial Intelligence and Machine Learning services. - * Version: 1.7.2 + * Version: 1.7.3 * Author: 10up * Author URI: https://10up.com * License: GPLv2 diff --git a/config.php b/config.php index 681798aae..14abfb402 100644 --- a/config.php +++ b/config.php @@ -4,7 +4,7 @@ * declared here instead of a Class. */ -$plugin_version = '1.7.2'; +$plugin_version = '1.7.3'; if ( file_exists( __DIR__ . '/.commit' ) ) { $plugin_version .= '-' . file_get_contents( __DIR__ . '/.commit' ); diff --git a/dist/js/admin.min.js b/dist/js/admin.min.js index 6011cf4be..cafefaf8d 100644 --- a/dist/js/admin.min.js +++ b/dist/js/admin.min.js @@ -1 +1,2 @@ -!function(e){var t={};function n(r){if(t[r])return t[r].exports;var o=t[r]={i:r,l:!1,exports:{}};return e[r].call(o.exports,o,o.exports,n),o.l=!0,o.exports}n.m=e,n.c=t,n.d=function(e,t,r){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:r})},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(e,t){if(1&t&&(e=n(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var o in e)n.d(r,o,function(t){return e[t]}.bind(null,o));return r},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="",n(n.s=3)}({3:function(e,t){function n(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var n=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null==n)return;var r,o,i=[],l=!0,a=!1;try{for(n=n.call(e);!(l=(r=n.next()).done)&&(i.push(r.value),!t||i.length!==t);l=!0);}catch(e){a=!0,o=e}finally{try{l||null==n.return||n.return()}finally{if(a)throw o}}return i}(e,t)||function(e,t){if(!e)return;if("string"==typeof e)return r(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return r(e,t)}(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function r(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n{var e={529:e=>{var t;window,t=function(){return function(){"use strict";var e={282:function(e,t,i){Object.defineProperty(t,"__esModule",{value:!0}),t.clearChoices=t.activateChoices=t.filterChoices=t.addChoice=void 0;var n=i(883);t.addChoice=function(e){var t=e.value,i=e.label,o=e.id,s=e.groupId,r=e.disabled,a=e.elementId,c=e.customProperties,l=e.placeholder,h=e.keyCode;return{type:n.ACTION_TYPES.ADD_CHOICE,value:t,label:i,id:o,groupId:s,disabled:r,elementId:a,customProperties:c,placeholder:l,keyCode:h}},t.filterChoices=function(e){return{type:n.ACTION_TYPES.FILTER_CHOICES,results:e}},t.activateChoices=function(e){return void 0===e&&(e=!0),{type:n.ACTION_TYPES.ACTIVATE_CHOICES,active:e}},t.clearChoices=function(){return{type:n.ACTION_TYPES.CLEAR_CHOICES}}},783:function(e,t,i){Object.defineProperty(t,"__esModule",{value:!0}),t.addGroup=void 0;var n=i(883);t.addGroup=function(e){var t=e.value,i=e.id,o=e.active,s=e.disabled;return{type:n.ACTION_TYPES.ADD_GROUP,value:t,id:i,active:o,disabled:s}}},464:function(e,t,i){Object.defineProperty(t,"__esModule",{value:!0}),t.highlightItem=t.removeItem=t.addItem=void 0;var n=i(883);t.addItem=function(e){var t=e.value,i=e.label,o=e.id,s=e.choiceId,r=e.groupId,a=e.customProperties,c=e.placeholder,l=e.keyCode;return{type:n.ACTION_TYPES.ADD_ITEM,value:t,label:i,id:o,choiceId:s,groupId:r,customProperties:a,placeholder:c,keyCode:l}},t.removeItem=function(e,t){return{type:n.ACTION_TYPES.REMOVE_ITEM,id:e,choiceId:t}},t.highlightItem=function(e,t){return{type:n.ACTION_TYPES.HIGHLIGHT_ITEM,id:e,highlighted:t}}},137:function(e,t,i){Object.defineProperty(t,"__esModule",{value:!0}),t.setIsLoading=t.resetTo=t.clearAll=void 0;var n=i(883);t.clearAll=function(){return{type:n.ACTION_TYPES.CLEAR_ALL}},t.resetTo=function(e){return{type:n.ACTION_TYPES.RESET_TO,state:e}},t.setIsLoading=function(e){return{type:n.ACTION_TYPES.SET_IS_LOADING,isLoading:e}}},373:function(e,t,i){var n=this&&this.__spreadArray||function(e,t,i){if(i||2===arguments.length)for(var n,o=0,s=t.length;o=0?this._store.getGroupById(o):null;return this._store.dispatch((0,l.highlightItem)(i,!0)),t&&this.passedElement.triggerEvent(d.EVENTS.highlightItem,{id:i,value:r,label:c,groupValue:h&&h.value?h.value:null}),this},e.prototype.unhighlightItem=function(e){if(!e||!e.id)return this;var t=e.id,i=e.groupId,n=void 0===i?-1:i,o=e.value,s=void 0===o?"":o,r=e.label,a=void 0===r?"":r,c=n>=0?this._store.getGroupById(n):null;return this._store.dispatch((0,l.highlightItem)(t,!1)),this.passedElement.triggerEvent(d.EVENTS.highlightItem,{id:t,value:s,label:a,groupValue:c&&c.value?c.value:null}),this},e.prototype.highlightAll=function(){var e=this;return this._store.items.forEach((function(t){return e.highlightItem(t)})),this},e.prototype.unhighlightAll=function(){var e=this;return this._store.items.forEach((function(t){return e.unhighlightItem(t)})),this},e.prototype.removeActiveItemsByValue=function(e){var t=this;return this._store.activeItems.filter((function(t){return t.value===e})).forEach((function(e){return t._removeItem(e)})),this},e.prototype.removeActiveItems=function(e){var t=this;return this._store.activeItems.filter((function(t){return t.id!==e})).forEach((function(e){return t._removeItem(e)})),this},e.prototype.removeHighlightedItems=function(e){var t=this;return void 0===e&&(e=!1),this._store.highlightedActiveItems.forEach((function(i){t._removeItem(i),e&&t._triggerChange(i.value)})),this},e.prototype.showDropdown=function(e){var t=this;return this.dropdown.isActive||requestAnimationFrame((function(){t.dropdown.show(),t.containerOuter.open(t.dropdown.distanceFromTopWindow),!e&&t._canSearch&&t.input.focus(),t.passedElement.triggerEvent(d.EVENTS.showDropdown,{})})),this},e.prototype.hideDropdown=function(e){var t=this;return this.dropdown.isActive?(requestAnimationFrame((function(){t.dropdown.hide(),t.containerOuter.close(),!e&&t._canSearch&&(t.input.removeActiveDescendant(),t.input.blur()),t.passedElement.triggerEvent(d.EVENTS.hideDropdown,{})})),this):this},e.prototype.getValue=function(e){void 0===e&&(e=!1);var t=this._store.activeItems.reduce((function(t,i){var n=e?i.value:i;return t.push(n),t}),[]);return this._isSelectOneElement?t[0]:t},e.prototype.setValue=function(e){var t=this;return this.initialised?(e.forEach((function(e){return t._setChoiceOrItem(e)})),this):this},e.prototype.setChoiceByValue=function(e){var t=this;return!this.initialised||this._isTextElement||(Array.isArray(e)?e:[e]).forEach((function(e){return t._findAndSelectChoiceByValue(e)})),this},e.prototype.setChoices=function(e,t,i,n){var o=this;if(void 0===e&&(e=[]),void 0===t&&(t="value"),void 0===i&&(i="label"),void 0===n&&(n=!1),!this.initialised)throw new ReferenceError("setChoices was called on a non-initialized instance of Choices");if(!this._isSelectElement)throw new TypeError("setChoices can't be used with INPUT based Choices");if("string"!=typeof t||!t)throw new TypeError("value parameter must be a name of 'value' field in passed objects");if(n&&this.clearChoices(),"function"==typeof e){var s=e(this);if("function"==typeof Promise&&s instanceof Promise)return new Promise((function(e){return requestAnimationFrame(e)})).then((function(){return o._handleLoadingState(!0)})).then((function(){return s})).then((function(e){return o.setChoices(e,t,i,n)})).catch((function(e){o.config.silent||console.error(e)})).then((function(){return o._handleLoadingState(!1)})).then((function(){return o}));if(!Array.isArray(s))throw new TypeError(".setChoices first argument function must return either array of choices or Promise, got: ".concat(typeof s));return this.setChoices(s,t,i,!1)}if(!Array.isArray(e))throw new TypeError(".setChoices must be called either with array of choices with a function resulting into Promise of array of choices");return this.containerOuter.removeLoadingState(),this._startLoading(),e.forEach((function(e){if(e.choices)o._addGroup({id:e.id?parseInt("".concat(e.id),10):null,group:e,valueKey:t,labelKey:i});else{var n=e;o._addChoice({value:n[t],label:n[i],isSelected:!!n.selected,isDisabled:!!n.disabled,placeholder:!!n.placeholder,customProperties:n.customProperties})}})),this._stopLoading(),this},e.prototype.clearChoices=function(){return this._store.dispatch((0,a.clearChoices)()),this},e.prototype.clearStore=function(){return this._store.dispatch((0,h.clearAll)()),this},e.prototype.clearInput=function(){var e=!this._isSelectOneElement;return this.input.clear(e),!this._isTextElement&&this._canSearch&&(this._isSearching=!1,this._store.dispatch((0,a.activateChoices)(!0))),this},e.prototype._render=function(){if(!this._store.isLoading()){this._currentState=this._store.state;var e=this._currentState.choices!==this._prevState.choices||this._currentState.groups!==this._prevState.groups||this._currentState.items!==this._prevState.items,t=this._isSelectElement,i=this._currentState.items!==this._prevState.items;e&&(t&&this._renderChoices(),i&&this._renderItems(),this._prevState=this._currentState)}},e.prototype._renderChoices=function(){var e=this,t=this._store,i=t.activeGroups,n=t.activeChoices,o=document.createDocumentFragment();if(this.choiceList.clear(),this.config.resetScrollPosition&&requestAnimationFrame((function(){return e.choiceList.scrollToTop()})),i.length>=1&&!this._isSearching){var s=n.filter((function(e){return!0===e.placeholder&&-1===e.groupId}));s.length>=1&&(o=this._createChoicesFragment(s,o)),o=this._createGroupsFragment(i,n,o)}else n.length>=1&&(o=this._createChoicesFragment(n,o));if(o.childNodes&&o.childNodes.length>0){var r=this._store.activeItems,a=this._canAddItem(r,this.input.value);if(a.response)this.choiceList.append(o),this._highlightChoice();else{var c=this._getTemplate("notice",a.notice);this.choiceList.append(c)}}else{var l=void 0;c=void 0,this._isSearching?(c="function"==typeof this.config.noResultsText?this.config.noResultsText():this.config.noResultsText,l=this._getTemplate("notice",c,"no-results")):(c="function"==typeof this.config.noChoicesText?this.config.noChoicesText():this.config.noChoicesText,l=this._getTemplate("notice",c,"no-choices")),this.choiceList.append(l)}},e.prototype._renderItems=function(){var e=this._store.activeItems||[];this.itemList.clear();var t=this._createItemsFragment(e);t.childNodes&&this.itemList.append(t)},e.prototype._createGroupsFragment=function(e,t,i){var n=this;return void 0===i&&(i=document.createDocumentFragment()),this.config.shouldSort&&e.sort(this.config.sorter),e.forEach((function(e){var o=function(e){return t.filter((function(t){return n._isSelectOneElement?t.groupId===e.id:t.groupId===e.id&&("always"===n.config.renderSelectedChoices||!t.selected)}))}(e);if(o.length>=1){var s=n._getTemplate("choiceGroup",e);i.appendChild(s),n._createChoicesFragment(o,i,!0)}})),i},e.prototype._createChoicesFragment=function(e,t,i){var o=this;void 0===t&&(t=document.createDocumentFragment()),void 0===i&&(i=!1);var s=this.config,r=s.renderSelectedChoices,a=s.searchResultLimit,c=s.renderChoiceLimit,l=this._isSearching?f.sortByScore:this.config.sorter,h=function(e){if("auto"!==r||o._isSelectOneElement||!e.selected){var i=o._getTemplate("choice",e,o.config.itemSelectText);t.appendChild(i)}},u=e;"auto"!==r||this._isSelectOneElement||(u=e.filter((function(e){return!e.selected})));var d=u.reduce((function(e,t){return t.placeholder?e.placeholderChoices.push(t):e.normalChoices.push(t),e}),{placeholderChoices:[],normalChoices:[]}),p=d.placeholderChoices,m=d.normalChoices;(this.config.shouldSort||this._isSearching)&&m.sort(l);var g=u.length,_=this._isSelectOneElement?n(n([],p,!0),m,!0):m;this._isSearching?g=a:c&&c>0&&!i&&(g=c);for(var v=0;v=n){var r=o?this._searchChoices(e):0;this.passedElement.triggerEvent(d.EVENTS.search,{value:e,resultCount:r})}else s&&(this._isSearching=!1,this._store.dispatch((0,a.activateChoices)(!0)))}},e.prototype._canAddItem=function(e,t){var i=!0,n="function"==typeof this.config.addItemText?this.config.addItemText(t):this.config.addItemText;if(!this._isSelectOneElement){var o=(0,f.existsInArray)(e,t);this.config.maxItemCount>0&&this.config.maxItemCount<=e.length&&(i=!1,n="function"==typeof this.config.maxItemText?this.config.maxItemText(this.config.maxItemCount):this.config.maxItemText),!this.config.duplicateItemsAllowed&&o&&i&&(i=!1,n="function"==typeof this.config.uniqueItemText?this.config.uniqueItemText(t):this.config.uniqueItemText),this._isTextElement&&this.config.addItems&&i&&"function"==typeof this.config.addItemFilter&&!this.config.addItemFilter(t)&&(i=!1,n="function"==typeof this.config.customAddItemText?this.config.customAddItemText(t):this.config.customAddItemText)}return{response:i,notice:n}},e.prototype._searchChoices=function(e){var t="string"==typeof e?e.trim():e,i="string"==typeof this._currentValue?this._currentValue.trim():this._currentValue;if(t.length<1&&t==="".concat(i," "))return 0;var o=this._store.searchableChoices,s=t,c=Object.assign(this.config.fuseOptions,{keys:n([],this.config.searchFields,!0),includeMatches:!0}),l=new r.default(o,c).search(s);return this._currentValue=t,this._highlightPosition=0,this._isSearching=!0,this._store.dispatch((0,a.filterChoices)(l)),l.length},e.prototype._addEventListeners=function(){var e=document.documentElement;e.addEventListener("touchend",this._onTouchEnd,!0),this.containerOuter.element.addEventListener("keydown",this._onKeyDown,!0),this.containerOuter.element.addEventListener("mousedown",this._onMouseDown,!0),e.addEventListener("click",this._onClick,{passive:!0}),e.addEventListener("touchmove",this._onTouchMove,{passive:!0}),this.dropdown.element.addEventListener("mouseover",this._onMouseOver,{passive:!0}),this._isSelectOneElement&&(this.containerOuter.element.addEventListener("focus",this._onFocus,{passive:!0}),this.containerOuter.element.addEventListener("blur",this._onBlur,{passive:!0})),this.input.element.addEventListener("keyup",this._onKeyUp,{passive:!0}),this.input.element.addEventListener("focus",this._onFocus,{passive:!0}),this.input.element.addEventListener("blur",this._onBlur,{passive:!0}),this.input.element.form&&this.input.element.form.addEventListener("reset",this._onFormReset,{passive:!0}),this.input.addEventListeners()},e.prototype._removeEventListeners=function(){var e=document.documentElement;e.removeEventListener("touchend",this._onTouchEnd,!0),this.containerOuter.element.removeEventListener("keydown",this._onKeyDown,!0),this.containerOuter.element.removeEventListener("mousedown",this._onMouseDown,!0),e.removeEventListener("click",this._onClick),e.removeEventListener("touchmove",this._onTouchMove),this.dropdown.element.removeEventListener("mouseover",this._onMouseOver),this._isSelectOneElement&&(this.containerOuter.element.removeEventListener("focus",this._onFocus),this.containerOuter.element.removeEventListener("blur",this._onBlur)),this.input.element.removeEventListener("keyup",this._onKeyUp),this.input.element.removeEventListener("focus",this._onFocus),this.input.element.removeEventListener("blur",this._onBlur),this.input.element.form&&this.input.element.form.removeEventListener("reset",this._onFormReset),this.input.removeEventListeners()},e.prototype._onKeyDown=function(e){var t=e.keyCode,i=this._store.activeItems,n=this.input.isFocussed,o=this.dropdown.isActive,s=this.itemList.hasChildren(),r=String.fromCharCode(t),a=/[a-zA-Z0-9-_ ]/.test(r),c=d.KEY_CODES.BACK_KEY,l=d.KEY_CODES.DELETE_KEY,h=d.KEY_CODES.ENTER_KEY,u=d.KEY_CODES.A_KEY,p=d.KEY_CODES.ESC_KEY,f=d.KEY_CODES.UP_KEY,m=d.KEY_CODES.DOWN_KEY,g=d.KEY_CODES.PAGE_UP_KEY,_=d.KEY_CODES.PAGE_DOWN_KEY;switch(this._isTextElement||o||!a||(this.showDropdown(),this.input.isFocussed||(this.input.value+=r.toLowerCase())),t){case u:return this._onSelectKey(e,s);case h:return this._onEnterKey(e,i,o);case p:return this._onEscapeKey(o);case f:case g:case m:case _:return this._onDirectionKey(e,o);case l:case c:return this._onDeleteKey(e,i,n)}},e.prototype._onKeyUp=function(e){var t=e.target,i=e.keyCode,n=this.input.value,o=this._store.activeItems,s=this._canAddItem(o,n),r=d.KEY_CODES.BACK_KEY,c=d.KEY_CODES.DELETE_KEY;if(this._isTextElement)if(s.notice&&n){var l=this._getTemplate("notice",s.notice);this.dropdown.element.innerHTML=l.outerHTML,this.showDropdown(!0)}else this.hideDropdown(!0);else{var h=(i===r||i===c)&&t&&!t.value,u=!this._isTextElement&&this._isSearching,p=this._canSearch&&s.response;h&&u?(this._isSearching=!1,this._store.dispatch((0,a.activateChoices)(!0))):p&&this._handleSearch(this.input.rawValue)}this._canSearch=this.config.searchEnabled},e.prototype._onSelectKey=function(e,t){var i=e.ctrlKey,n=e.metaKey;(i||n)&&t&&(this._canSearch=!1,this.config.removeItems&&!this.input.value&&this.input.element===document.activeElement&&this.highlightAll())},e.prototype._onEnterKey=function(e,t,i){var n=e.target,o=d.KEY_CODES.ENTER_KEY,s=n&&n.hasAttribute("data-button");if(this._isTextElement&&n&&n.value){var r=this.input.value;this._canAddItem(t,r).response&&(this.hideDropdown(!0),this._addItem({value:r}),this._triggerChange(r),this.clearInput())}if(s&&(this._handleButtonAction(t,n),e.preventDefault()),i){var a=this.dropdown.getChild(".".concat(this.config.classNames.highlightedState));a&&(t[0]&&(t[0].keyCode=o),this._handleChoiceAction(t,a)),e.preventDefault()}else this._isSelectOneElement&&(this.showDropdown(),e.preventDefault())},e.prototype._onEscapeKey=function(e){e&&(this.hideDropdown(!0),this.containerOuter.focus())},e.prototype._onDirectionKey=function(e,t){var i=e.keyCode,n=e.metaKey,o=d.KEY_CODES.DOWN_KEY,s=d.KEY_CODES.PAGE_UP_KEY,r=d.KEY_CODES.PAGE_DOWN_KEY;if(t||this._isSelectOneElement){this.showDropdown(),this._canSearch=!1;var a=i===o||i===r?1:-1,c="[data-choice-selectable]",l=void 0;if(n||i===r||i===s)l=a>0?this.dropdown.element.querySelector("".concat(c,":last-of-type")):this.dropdown.element.querySelector(c);else{var h=this.dropdown.element.querySelector(".".concat(this.config.classNames.highlightedState));l=h?(0,f.getAdjacentEl)(h,c,a):this.dropdown.element.querySelector(c)}l&&((0,f.isScrolledIntoView)(l,this.choiceList.element,a)||this.choiceList.scrollToChildElement(l,a),this._highlightChoice(l)),e.preventDefault()}},e.prototype._onDeleteKey=function(e,t,i){var n=e.target;this._isSelectOneElement||n.value||!i||(this._handleBackspace(t),e.preventDefault())},e.prototype._onTouchMove=function(){this._wasTap&&(this._wasTap=!1)},e.prototype._onTouchEnd=function(e){var t=(e||e.touches[0]).target;this._wasTap&&this.containerOuter.element.contains(t)&&((t===this.containerOuter.element||t===this.containerInner.element)&&(this._isTextElement?this.input.focus():this._isSelectMultipleElement&&this.showDropdown()),e.stopPropagation()),this._wasTap=!0},e.prototype._onMouseDown=function(e){var t=e.target;if(t instanceof HTMLElement){if(v&&this.choiceList.element.contains(t)){var i=this.choiceList.element.firstElementChild,n="ltr"===this._direction?e.offsetX>=i.offsetWidth:e.offsetX0&&this.unhighlightAll(),this.containerOuter.removeFocusState(),this.hideDropdown(!0))},e.prototype._onFocus=function(e){var t,i=this,n=e.target;n&&this.containerOuter.element.contains(n)&&((t={})[d.TEXT_TYPE]=function(){n===i.input.element&&i.containerOuter.addFocusState()},t[d.SELECT_ONE_TYPE]=function(){i.containerOuter.addFocusState(),n===i.input.element&&i.showDropdown(!0)},t[d.SELECT_MULTIPLE_TYPE]=function(){n===i.input.element&&(i.showDropdown(!0),i.containerOuter.addFocusState())},t)[this.passedElement.element.type]()},e.prototype._onBlur=function(e){var t,i=this,n=e.target;if(n&&this.containerOuter.element.contains(n)&&!this._isScrollingOnIe){var o=this._store.activeItems.some((function(e){return e.highlighted}));((t={})[d.TEXT_TYPE]=function(){n===i.input.element&&(i.containerOuter.removeFocusState(),o&&i.unhighlightAll(),i.hideDropdown(!0))},t[d.SELECT_ONE_TYPE]=function(){i.containerOuter.removeFocusState(),(n===i.input.element||n===i.containerOuter.element&&!i._canSearch)&&i.hideDropdown(!0)},t[d.SELECT_MULTIPLE_TYPE]=function(){n===i.input.element&&(i.containerOuter.removeFocusState(),i.hideDropdown(!0),o&&i.unhighlightAll())},t)[this.passedElement.element.type]()}else this._isScrollingOnIe=!1,this.input.element.focus()},e.prototype._onFormReset=function(){this._store.dispatch((0,h.resetTo)(this._initialState))},e.prototype._highlightChoice=function(e){var t=this;void 0===e&&(e=null);var i=Array.from(this.dropdown.element.querySelectorAll("[data-choice-selectable]"));if(i.length){var n=e;Array.from(this.dropdown.element.querySelectorAll(".".concat(this.config.classNames.highlightedState))).forEach((function(e){e.classList.remove(t.config.classNames.highlightedState),e.setAttribute("aria-selected","false")})),n?this._highlightPosition=i.indexOf(n):(n=i.length>this._highlightPosition?i[this._highlightPosition]:i[i.length-1])||(n=i[0]),n.classList.add(this.config.classNames.highlightedState),n.setAttribute("aria-selected","true"),this.passedElement.triggerEvent(d.EVENTS.highlightChoice,{el:n}),this.dropdown.isActive&&(this.input.setActiveDescendant(n.id),this.containerOuter.setActiveDescendant(n.id))}},e.prototype._addItem=function(e){var t=e.value,i=e.label,n=void 0===i?null:i,o=e.choiceId,s=void 0===o?-1:o,r=e.groupId,a=void 0===r?-1:r,c=e.customProperties,h=void 0===c?{}:c,u=e.placeholder,p=void 0!==u&&u,f=e.keyCode,m=void 0===f?-1:f,g="string"==typeof t?t.trim():t,_=this._store.items,v=n||g,y=s||-1,b=a>=0?this._store.getGroupById(a):null,E=_?_.length+1:1;this.config.prependValue&&(g=this.config.prependValue+g.toString()),this.config.appendValue&&(g+=this.config.appendValue.toString()),this._store.dispatch((0,l.addItem)({value:g,label:v,id:E,choiceId:y,groupId:a,customProperties:h,placeholder:p,keyCode:m})),this._isSelectOneElement&&this.removeActiveItems(E),this.passedElement.triggerEvent(d.EVENTS.addItem,{id:E,value:g,label:v,customProperties:h,groupValue:b&&b.value?b.value:null,keyCode:m})},e.prototype._removeItem=function(e){var t=e.id,i=e.value,n=e.label,o=e.customProperties,s=e.choiceId,r=e.groupId,a=r&&r>=0?this._store.getGroupById(r):null;t&&s&&(this._store.dispatch((0,l.removeItem)(t,s)),this.passedElement.triggerEvent(d.EVENTS.removeItem,{id:t,value:i,label:n,customProperties:o,groupValue:a&&a.value?a.value:null}))},e.prototype._addChoice=function(e){var t=e.value,i=e.label,n=void 0===i?null:i,o=e.isSelected,s=void 0!==o&&o,r=e.isDisabled,c=void 0!==r&&r,l=e.groupId,h=void 0===l?-1:l,u=e.customProperties,d=void 0===u?{}:u,p=e.placeholder,f=void 0!==p&&p,m=e.keyCode,g=void 0===m?-1:m;if(null!=t){var _=this._store.choices,v=n||t,y=_?_.length+1:1,b="".concat(this._baseId,"-").concat(this._idNames.itemChoice,"-").concat(y);this._store.dispatch((0,a.addChoice)({id:y,groupId:h,elementId:b,value:t,label:v,disabled:c,customProperties:d,placeholder:f,keyCode:g})),s&&this._addItem({value:t,label:v,choiceId:y,customProperties:d,placeholder:f,keyCode:g})}},e.prototype._addGroup=function(e){var t=this,i=e.group,n=e.id,o=e.valueKey,s=void 0===o?"value":o,r=e.labelKey,a=void 0===r?"label":r,l=(0,f.isType)("Object",i)?i.choices:Array.from(i.getElementsByTagName("OPTION")),h=n||Math.floor((new Date).valueOf()*Math.random()),u=!!i.disabled&&i.disabled;l?(this._store.dispatch((0,c.addGroup)({value:i.label,id:h,active:!0,disabled:u})),l.forEach((function(e){var i=e.disabled||e.parentNode&&e.parentNode.disabled;t._addChoice({value:e[s],label:(0,f.isType)("Object",e)?e[a]:e.innerHTML,isSelected:e.selected,isDisabled:i,groupId:h,customProperties:e.customProperties,placeholder:e.placeholder})}))):this._store.dispatch((0,c.addGroup)({value:i.label,id:i.id,active:!1,disabled:i.disabled}))},e.prototype._getTemplate=function(e){for(var t,i=[],o=1;o0?this.element.scrollTop+r-o:e.offsetTop;requestAnimationFrame((function(){i._animateScroll(a,t)}))}},e.prototype._scrollDown=function(e,t,i){var n=(i-e)/t,o=n>1?n:1;this.element.scrollTop=e+o},e.prototype._scrollUp=function(e,t,i){var n=(e-i)/t,o=n>1?n:1;this.element.scrollTop=e-o},e.prototype._animateScroll=function(e,t){var i=this,o=n.SCROLLING_SPEED,s=this.element.scrollTop,r=!1;t>0?(this._scrollDown(s,o,e),se&&(r=!0)),r&&requestAnimationFrame((function(){i._animateScroll(e,t)}))},e}();t.default=o},730:function(e,t,i){Object.defineProperty(t,"__esModule",{value:!0});var n=i(799),o=function(){function e(e){var t=e.element,i=e.classNames;if(this.element=t,this.classNames=i,!(t instanceof HTMLInputElement||t instanceof HTMLSelectElement))throw new TypeError("Invalid element passed");this.isDisabled=!1}return Object.defineProperty(e.prototype,"isActive",{get:function(){return"active"===this.element.dataset.choice},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"dir",{get:function(){return this.element.dir},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"value",{get:function(){return this.element.value},set:function(e){this.element.value=e},enumerable:!1,configurable:!0}),e.prototype.conceal=function(){this.element.classList.add(this.classNames.input),this.element.hidden=!0,this.element.tabIndex=-1;var e=this.element.getAttribute("style");e&&this.element.setAttribute("data-choice-orig-style",e),this.element.setAttribute("data-choice","active")},e.prototype.reveal=function(){this.element.classList.remove(this.classNames.input),this.element.hidden=!1,this.element.removeAttribute("tabindex");var e=this.element.getAttribute("data-choice-orig-style");e?(this.element.removeAttribute("data-choice-orig-style"),this.element.setAttribute("style",e)):this.element.removeAttribute("style"),this.element.removeAttribute("data-choice"),this.element.value=this.element.value},e.prototype.enable=function(){this.element.removeAttribute("disabled"),this.element.disabled=!1,this.isDisabled=!1},e.prototype.disable=function(){this.element.setAttribute("disabled",""),this.element.disabled=!0,this.isDisabled=!0},e.prototype.triggerEvent=function(e,t){(0,n.dispatchEvent)(this.element,e,t)},e}();t.default=o},541:function(e,t,i){var n,o=this&&this.__extends||(n=function(e,t){return n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var i in t)Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i])},n(e,t)},function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function i(){this.constructor=e}n(e,t),e.prototype=null===t?Object.create(t):(i.prototype=t.prototype,new i)}),s=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});var r=function(e){function t(t){var i=t.element,n=t.classNames,o=t.delimiter,s=e.call(this,{element:i,classNames:n})||this;return s.delimiter=o,s}return o(t,e),Object.defineProperty(t.prototype,"value",{get:function(){return this.element.value},set:function(e){this.element.setAttribute("value",e),this.element.value=e},enumerable:!1,configurable:!0}),t}(s(i(730)).default);t.default=r},982:function(e,t,i){var n,o=this&&this.__extends||(n=function(e,t){return n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var i in t)Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i])},n(e,t)},function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function i(){this.constructor=e}n(e,t),e.prototype=null===t?Object.create(t):(i.prototype=t.prototype,new i)}),s=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});var r=function(e){function t(t){var i=t.element,n=t.classNames,o=t.template,s=e.call(this,{element:i,classNames:n})||this;return s.template=o,s}return o(t,e),Object.defineProperty(t.prototype,"placeholderOption",{get:function(){return this.element.querySelector('option[value=""]')||this.element.querySelector("option[placeholder]")},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"optionGroups",{get:function(){return Array.from(this.element.getElementsByTagName("OPTGROUP"))},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"options",{get:function(){return Array.from(this.element.options)},set:function(e){var t=this,i=document.createDocumentFragment();e.forEach((function(e){return n=e,o=t.template(n),void i.appendChild(o);var n,o})),this.appendDocFragment(i)},enumerable:!1,configurable:!0}),t.prototype.appendDocFragment=function(e){this.element.innerHTML="",this.element.appendChild(e)},t}(s(i(730)).default);t.default=r},883:function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.SCROLLING_SPEED=t.SELECT_MULTIPLE_TYPE=t.SELECT_ONE_TYPE=t.TEXT_TYPE=t.KEY_CODES=t.ACTION_TYPES=t.EVENTS=void 0,t.EVENTS={showDropdown:"showDropdown",hideDropdown:"hideDropdown",change:"change",choice:"choice",search:"search",addItem:"addItem",removeItem:"removeItem",highlightItem:"highlightItem",highlightChoice:"highlightChoice",unhighlightItem:"unhighlightItem"},t.ACTION_TYPES={ADD_CHOICE:"ADD_CHOICE",FILTER_CHOICES:"FILTER_CHOICES",ACTIVATE_CHOICES:"ACTIVATE_CHOICES",CLEAR_CHOICES:"CLEAR_CHOICES",ADD_GROUP:"ADD_GROUP",ADD_ITEM:"ADD_ITEM",REMOVE_ITEM:"REMOVE_ITEM",HIGHLIGHT_ITEM:"HIGHLIGHT_ITEM",CLEAR_ALL:"CLEAR_ALL",RESET_TO:"RESET_TO",SET_IS_LOADING:"SET_IS_LOADING"},t.KEY_CODES={BACK_KEY:46,DELETE_KEY:8,ENTER_KEY:13,A_KEY:65,ESC_KEY:27,UP_KEY:38,DOWN_KEY:40,PAGE_UP_KEY:33,PAGE_DOWN_KEY:34},t.TEXT_TYPE="text",t.SELECT_ONE_TYPE="select-one",t.SELECT_MULTIPLE_TYPE="select-multiple",t.SCROLLING_SPEED=4},789:function(e,t,i){Object.defineProperty(t,"__esModule",{value:!0}),t.DEFAULT_CONFIG=t.DEFAULT_CLASSNAMES=void 0;var n=i(799);t.DEFAULT_CLASSNAMES={containerOuter:"choices",containerInner:"choices__inner",input:"choices__input",inputCloned:"choices__input--cloned",list:"choices__list",listItems:"choices__list--multiple",listSingle:"choices__list--single",listDropdown:"choices__list--dropdown",item:"choices__item",itemSelectable:"choices__item--selectable",itemDisabled:"choices__item--disabled",itemChoice:"choices__item--choice",placeholder:"choices__placeholder",group:"choices__group",groupHeading:"choices__heading",button:"choices__button",activeState:"is-active",focusState:"is-focused",openState:"is-open",disabledState:"is-disabled",highlightedState:"is-highlighted",selectedState:"is-selected",flippedState:"is-flipped",loadingState:"is-loading",noResults:"has-no-results",noChoices:"has-no-choices"},t.DEFAULT_CONFIG={items:[],choices:[],silent:!1,renderChoiceLimit:-1,maxItemCount:-1,addItems:!0,addItemFilter:null,removeItems:!0,removeItemButton:!1,editItems:!1,allowHTML:!0,duplicateItemsAllowed:!0,delimiter:",",paste:!0,searchEnabled:!0,searchChoices:!0,searchFloor:1,searchResultLimit:4,searchFields:["label","value"],position:"auto",resetScrollPosition:!0,shouldSort:!0,shouldSortItems:!1,sorter:n.sortByAlpha,placeholder:!0,placeholderValue:null,searchPlaceholderValue:null,prependValue:null,appendValue:null,renderSelectedChoices:"auto",loadingText:"Loading...",noResultsText:"No results found",noChoicesText:"No choices to choose from",itemSelectText:"Press to select",uniqueItemText:"Only unique values can be added",customAddItemText:"Only values matching specific conditions can be added",addItemText:function(e){return'Press Enter to add "'.concat((0,n.sanitise)(e),'"')},maxItemText:function(e){return"Only ".concat(e," values can be added")},valueComparer:function(e,t){return e===t},fuseOptions:{includeScore:!0},labelId:"",callbackOnInit:null,callbackOnCreateTemplates:null,classNames:t.DEFAULT_CLASSNAMES}},18:function(e,t){Object.defineProperty(t,"__esModule",{value:!0})},978:function(e,t){Object.defineProperty(t,"__esModule",{value:!0})},948:function(e,t){Object.defineProperty(t,"__esModule",{value:!0})},359:function(e,t){Object.defineProperty(t,"__esModule",{value:!0})},285:function(e,t){Object.defineProperty(t,"__esModule",{value:!0})},533:function(e,t){Object.defineProperty(t,"__esModule",{value:!0})},187:function(e,t,i){var n=this&&this.__createBinding||(Object.create?function(e,t,i,n){void 0===n&&(n=i),Object.defineProperty(e,n,{enumerable:!0,get:function(){return t[i]}})}:function(e,t,i,n){void 0===n&&(n=i),e[n]=t[i]}),o=this&&this.__exportStar||function(e,t){for(var i in e)"default"===i||Object.prototype.hasOwnProperty.call(t,i)||n(t,e,i)};Object.defineProperty(t,"__esModule",{value:!0}),o(i(18),t),o(i(978),t),o(i(948),t),o(i(359),t),o(i(285),t),o(i(533),t),o(i(287),t),o(i(132),t),o(i(837),t),o(i(598),t),o(i(369),t),o(i(37),t),o(i(47),t),o(i(923),t),o(i(876),t)},287:function(e,t){Object.defineProperty(t,"__esModule",{value:!0})},132:function(e,t){Object.defineProperty(t,"__esModule",{value:!0})},837:function(e,t){Object.defineProperty(t,"__esModule",{value:!0})},598:function(e,t){Object.defineProperty(t,"__esModule",{value:!0})},37:function(e,t){Object.defineProperty(t,"__esModule",{value:!0})},369:function(e,t){Object.defineProperty(t,"__esModule",{value:!0})},47:function(e,t){Object.defineProperty(t,"__esModule",{value:!0})},923:function(e,t){Object.defineProperty(t,"__esModule",{value:!0})},876:function(e,t){Object.defineProperty(t,"__esModule",{value:!0})},799:function(e,t){var i;Object.defineProperty(t,"__esModule",{value:!0}),t.diff=t.cloneObject=t.existsInArray=t.dispatchEvent=t.sortByScore=t.sortByAlpha=t.strToEl=t.sanitise=t.isScrolledIntoView=t.getAdjacentEl=t.wrap=t.isType=t.getType=t.generateId=t.generateChars=t.getRandomNumber=void 0,t.getRandomNumber=function(e,t){return Math.floor(Math.random()*(t-e)+e)},t.generateChars=function(e){return Array.from({length:e},(function(){return(0,t.getRandomNumber)(0,36).toString(36)})).join("")},t.generateId=function(e,i){var n=e.id||e.name&&"".concat(e.name,"-").concat((0,t.generateChars)(2))||(0,t.generateChars)(4);return n=n.replace(/(:|\.|\[|\]|,)/g,""),"".concat(i,"-").concat(n)},t.getType=function(e){return Object.prototype.toString.call(e).slice(8,-1)},t.isType=function(e,i){return null!=i&&(0,t.getType)(i)===e},t.wrap=function(e,t){return void 0===t&&(t=document.createElement("div")),e.parentNode&&(e.nextSibling?e.parentNode.insertBefore(t,e.nextSibling):e.parentNode.appendChild(t)),t.appendChild(e)},t.getAdjacentEl=function(e,t,i){void 0===i&&(i=1);for(var n="".concat(i>0?"next":"previous","ElementSibling"),o=e[n];o;){if(o.matches(t))return o;o=o[n]}return o},t.isScrolledIntoView=function(e,t,i){return void 0===i&&(i=1),!!e&&(i>0?t.scrollTop+t.offsetHeight>=e.offsetTop+e.offsetHeight:e.offsetTop>=t.scrollTop)},t.sanitise=function(e){return"string"!=typeof e?e:e.replace(/&/g,"&").replace(/>/g,">").replace(/-1?e.map((function(e){var t=e;return t.id===parseInt("".concat(r.choiceId),10)&&(t.selected=!0),t})):e;case"REMOVE_ITEM":var a=n;return a.choiceId&&a.choiceId>-1?e.map((function(e){var t=e;return t.id===parseInt("".concat(a.choiceId),10)&&(t.selected=!1),t})):e;case"FILTER_CHOICES":var c=n;return e.map((function(e){var t=e;return t.active=c.results.some((function(e){var i=e.item,n=e.score;return i.id===t.id&&(t.score=n,!0)})),t}));case"ACTIVATE_CHOICES":var l=n;return e.map((function(e){var t=e;return t.active=l.active,t}));case"CLEAR_CHOICES":return t.defaultState;default:return e}}},871:function(e,t){var i=this&&this.__spreadArray||function(e,t,i){if(i||2===arguments.length)for(var n,o=0,s=t.length;o0?"treeitem":"option"),Object.assign(b.dataset,{choice:"",id:d,value:p,selectText:i}),_?(b.classList.add(h),b.dataset.choiceDisabled="",b.setAttribute("aria-disabled","true")):(b.classList.add(c),b.dataset.choiceSelectable=""),b},input:function(e,t){var i=e.classNames,n=i.input,o=i.inputCloned,s=Object.assign(document.createElement("input"),{type:"search",name:"search_terms",className:"".concat(n," ").concat(o),autocomplete:"off",autocapitalize:"off",spellcheck:!1});return s.setAttribute("role","textbox"),s.setAttribute("aria-autocomplete","list"),s.setAttribute("aria-label",t),s},dropdown:function(e){var t=e.classNames,i=t.list,n=t.listDropdown,o=document.createElement("div");return o.classList.add(i,n),o.setAttribute("aria-expanded","false"),o},notice:function(e,t,i){var n,o=e.allowHTML,s=e.classNames,r=s.item,a=s.itemChoice,c=s.noResults,l=s.noChoices;void 0===i&&(i="");var h=[r,a];return"no-choices"===i?h.push(l):"no-results"===i&&h.push(c),Object.assign(document.createElement("div"),((n={})[o?"innerHTML":"innerText"]=t,n.className=h.join(" "),n))},option:function(e){var t=e.label,i=e.value,n=e.customProperties,o=e.active,s=e.disabled,r=new Option(t,i,!1,o);return n&&(r.dataset.customProperties="".concat(n)),r.disabled=!!s,r}};t.default=i},996:function(e){var t=function(e){return function(e){return!!e&&"object"==typeof e}(e)&&!function(e){var t=Object.prototype.toString.call(e);return"[object RegExp]"===t||"[object Date]"===t||function(e){return e.$$typeof===i}(e)}(e)},i="function"==typeof Symbol&&Symbol.for?Symbol.for("react.element"):60103;function n(e,t){return!1!==t.clone&&t.isMergeableObject(e)?a((i=e,Array.isArray(i)?[]:{}),e,t):e;var i}function o(e,t,i){return e.concat(t).map((function(e){return n(e,i)}))}function s(e){return Object.keys(e).concat(function(e){return Object.getOwnPropertySymbols?Object.getOwnPropertySymbols(e).filter((function(t){return e.propertyIsEnumerable(t)})):[]}(e))}function r(e,t){try{return t in e}catch(e){return!1}}function a(e,i,c){(c=c||{}).arrayMerge=c.arrayMerge||o,c.isMergeableObject=c.isMergeableObject||t,c.cloneUnlessOtherwiseSpecified=n;var l=Array.isArray(i);return l===Array.isArray(e)?l?c.arrayMerge(e,i,c):function(e,t,i){var o={};return i.isMergeableObject(e)&&s(e).forEach((function(t){o[t]=n(e[t],i)})),s(t).forEach((function(s){(function(e,t){return r(e,t)&&!(Object.hasOwnProperty.call(e,t)&&Object.propertyIsEnumerable.call(e,t))})(e,s)||(r(e,s)&&i.isMergeableObject(t[s])?o[s]=function(e,t){if(!t.customMerge)return a;var i=t.customMerge(e);return"function"==typeof i?i:a}(s,i)(e[s],t[s],i):o[s]=n(t[s],i))})),o}(e,i,c):n(i,c)}a.all=function(e,t){if(!Array.isArray(e))throw new Error("first argument should be an array");return e.reduce((function(e,i){return a(e,i,t)}),{})};var c=a;e.exports=c},221:function(e,t,i){function n(e){return Array.isArray?Array.isArray(e):"[object Array]"===l(e)}function o(e){return"string"==typeof e}function s(e){return"number"==typeof e}function r(e){return"object"==typeof e}function a(e){return null!=e}function c(e){return!e.trim().length}function l(e){return null==e?void 0===e?"[object Undefined]":"[object Null]":Object.prototype.toString.call(e)}i.r(t),i.d(t,{default:function(){return K}});const h=Object.prototype.hasOwnProperty;class u{constructor(e){this._keys=[],this._keyMap={};let t=0;e.forEach((e=>{let i=d(e);t+=i.weight,this._keys.push(i),this._keyMap[i.id]=i,t+=i.weight})),this._keys.forEach((e=>{e.weight/=t}))}get(e){return this._keyMap[e]}keys(){return this._keys}toJSON(){return JSON.stringify(this._keys)}}function d(e){let t=null,i=null,s=null,r=1;if(o(e)||n(e))s=e,t=p(e),i=f(e);else{if(!h.call(e,"name"))throw new Error("Missing name property in key");const n=e.name;if(s=n,h.call(e,"weight")&&(r=e.weight,r<=0))throw new Error((e=>`Property 'weight' in key '${e}' must be a positive integer`)(n));t=p(n),i=f(n)}return{path:t,id:i,weight:r,src:s}}function p(e){return n(e)?e:e.split(".")}function f(e){return n(e)?e.join("."):e}var m={isCaseSensitive:!1,includeScore:!1,keys:[],shouldSort:!0,sortFn:(e,t)=>e.score===t.score?e.idx{if(a(e))if(t[u]){const d=e[t[u]];if(!a(d))return;if(u===t.length-1&&(o(d)||s(d)||function(e){return!0===e||!1===e||function(e){return r(e)&&null!==e}(e)&&"[object Boolean]"==l(e)}(d)))i.push(function(e){return null==e?"":function(e){if("string"==typeof e)return e;let t=e+"";return"0"==t&&1/e==-1/0?"-0":t}(e)}(d));else if(n(d)){c=!0;for(let e=0,i=d.length;e{this._keysMap[e.id]=t}))}create(){!this.isCreated&&this.docs.length&&(this.isCreated=!0,o(this.docs[0])?this.docs.forEach(((e,t)=>{this._addString(e,t)})):this.docs.forEach(((e,t)=>{this._addObject(e,t)})),this.norm.clear())}add(e){const t=this.size();o(e)?this._addString(e,t):this._addObject(e,t)}removeAt(e){this.records.splice(e,1);for(let t=e,i=this.size();t{let r=this.getFn(e,t.path);if(a(r))if(n(r)){let e=[];const t=[{nestedArrIndex:-1,value:r}];for(;t.length;){const{nestedArrIndex:i,value:s}=t.pop();if(a(s))if(o(s)&&!c(s)){let t={v:s,i,n:this.norm.get(s)};e.push(t)}else n(s)&&s.forEach(((e,i)=>{t.push({nestedArrIndex:i,value:e})}))}i.$[s]=e}else if(!c(r)){let e={v:r,n:this.norm.get(r)};i.$[s]=e}})),this.records.push(i)}toJSON(){return{keys:this.keys,records:this.records}}}function v(e,t,{getFn:i=m.getFn,fieldNormWeight:n=m.fieldNormWeight}={}){const o=new _({getFn:i,fieldNormWeight:n});return o.setKeys(e.map(d)),o.setSources(t),o.create(),o}function y(e,{errors:t=0,currentLocation:i=0,expectedLocation:n=0,distance:o=m.distance,ignoreLocation:s=m.ignoreLocation}={}){const r=t/e.length;if(s)return r;const a=Math.abs(n-i);return o?r+a/o:a?1:r}const b=32;function E(e){let t={};for(let i=0,n=e.length;i{this.chunks.push({pattern:e,alphabet:E(e),startIndex:t})},h=this.pattern.length;if(h>b){let e=0;const t=h%b,i=h-t;for(;e{const{isMatch:f,score:g,indices:_}=function(e,t,i,{location:n=m.location,distance:o=m.distance,threshold:s=m.threshold,findAllMatches:r=m.findAllMatches,minMatchCharLength:a=m.minMatchCharLength,includeMatches:c=m.includeMatches,ignoreLocation:l=m.ignoreLocation}={}){if(t.length>b)throw new Error("Pattern length exceeds max of 32.");const h=t.length,u=e.length,d=Math.max(0,Math.min(n,u));let p=s,f=d;const g=a>1||c,_=g?Array(u):[];let v;for(;(v=e.indexOf(t,f))>-1;){let e=y(t,{currentLocation:v,expectedLocation:d,distance:o,ignoreLocation:l});if(p=Math.min(e,p),f=v+h,g){let e=0;for(;e=c;s-=1){let r=s-1,a=i[e.charAt(r)];if(g&&(_[r]=+!!a),v[s]=(v[s+1]<<1|1)&a,n&&(v[s]|=(E[s+1]|E[s])<<1|1|E[s+1]),v[s]&S&&(I=y(t,{errors:n,currentLocation:r,expectedLocation:d,distance:o,ignoreLocation:l}),I<=p)){if(p=I,f=r,f<=d)break;c=Math.max(1,2*d-f)}}if(y(t,{errors:n+1,currentLocation:d,expectedLocation:d,distance:o,ignoreLocation:l})>p)break;E=v}const O={isMatch:f>=0,score:Math.max(.001,I)};if(g){const e=function(e=[],t=m.minMatchCharLength){let i=[],n=-1,o=-1,s=0;for(let r=e.length;s=t&&i.push([n,o]),n=-1)}return e[s-1]&&s-n>=t&&i.push([n,s-1]),i}(_,a);e.length?c&&(O.indices=e):O.isMatch=!1}return O}(e,t,d,{location:n+p,distance:o,threshold:s,findAllMatches:r,minMatchCharLength:a,includeMatches:i,ignoreLocation:c});f&&(u=!0),h+=g,f&&_&&(l=[...l,..._])}));let d={isMatch:u,score:u?h/this.chunks.length:1};return u&&i&&(d.indices=l),d}}class w{constructor(e){this.pattern=e}static isMultiMatch(e){return S(e,this.multiRegex)}static isSingleMatch(e){return S(e,this.singleRegex)}search(){}}function S(e,t){const i=e.match(t);return i?i[1]:null}class O extends w{constructor(e,{location:t=m.location,threshold:i=m.threshold,distance:n=m.distance,includeMatches:o=m.includeMatches,findAllMatches:s=m.findAllMatches,minMatchCharLength:r=m.minMatchCharLength,isCaseSensitive:a=m.isCaseSensitive,ignoreLocation:c=m.ignoreLocation}={}){super(e),this._bitapSearch=new I(e,{location:t,threshold:i,distance:n,includeMatches:o,findAllMatches:s,minMatchCharLength:r,isCaseSensitive:a,ignoreLocation:c})}static get type(){return"fuzzy"}static get multiRegex(){return/^"(.*)"$/}static get singleRegex(){return/^(.*)$/}search(e){return this._bitapSearch.searchIn(e)}}class x extends w{constructor(e){super(e)}static get type(){return"include"}static get multiRegex(){return/^'"(.*)"$/}static get singleRegex(){return/^'(.*)$/}search(e){let t,i=0;const n=[],o=this.pattern.length;for(;(t=e.indexOf(this.pattern,i))>-1;)i=t+o,n.push([t,i-1]);const s=!!n.length;return{isMatch:s,score:s?0:1,indices:n}}}const C=[class extends w{constructor(e){super(e)}static get type(){return"exact"}static get multiRegex(){return/^="(.*)"$/}static get singleRegex(){return/^=(.*)$/}search(e){const t=e===this.pattern;return{isMatch:t,score:t?0:1,indices:[0,this.pattern.length-1]}}},x,class extends w{constructor(e){super(e)}static get type(){return"prefix-exact"}static get multiRegex(){return/^\^"(.*)"$/}static get singleRegex(){return/^\^(.*)$/}search(e){const t=e.startsWith(this.pattern);return{isMatch:t,score:t?0:1,indices:[0,this.pattern.length-1]}}},class extends w{constructor(e){super(e)}static get type(){return"inverse-prefix-exact"}static get multiRegex(){return/^!\^"(.*)"$/}static get singleRegex(){return/^!\^(.*)$/}search(e){const t=!e.startsWith(this.pattern);return{isMatch:t,score:t?0:1,indices:[0,e.length-1]}}},class extends w{constructor(e){super(e)}static get type(){return"inverse-suffix-exact"}static get multiRegex(){return/^!"(.*)"\$$/}static get singleRegex(){return/^!(.*)\$$/}search(e){const t=!e.endsWith(this.pattern);return{isMatch:t,score:t?0:1,indices:[0,e.length-1]}}},class extends w{constructor(e){super(e)}static get type(){return"suffix-exact"}static get multiRegex(){return/^"(.*)"\$$/}static get singleRegex(){return/^(.*)\$$/}search(e){const t=e.endsWith(this.pattern);return{isMatch:t,score:t?0:1,indices:[e.length-this.pattern.length,e.length-1]}}},class extends w{constructor(e){super(e)}static get type(){return"inverse-exact"}static get multiRegex(){return/^!"(.*)"$/}static get singleRegex(){return/^!(.*)$/}search(e){const t=-1===e.indexOf(this.pattern);return{isMatch:t,score:t?0:1,indices:[0,e.length-1]}}},O],T=C.length,L=/ +(?=([^\"]*\"[^\"]*\")*[^\"]*$)/,A=new Set([O.type,x.type]);const M=[];function P(e,t){for(let i=0,n=M.length;i!(!e.$and&&!e.$or),D=e=>({[N]:Object.keys(e).map((t=>({[t]:e[t]})))});function k(e,t,{auto:i=!0}={}){const s=e=>{let a=Object.keys(e);const c=(e=>!!e.$path)(e);if(!c&&a.length>1&&!j(e))return s(D(e));if((e=>!n(e)&&r(e)&&!j(e))(e)){const n=c?e.$path:a[0],s=c?e.$val:e[n];if(!o(s))throw new Error((e=>`Invalid value for key ${e}`)(n));const r={keyId:f(n),pattern:s};return i&&(r.searcher=P(s,t)),r}let l={children:[],operator:a[0]};return a.forEach((t=>{const i=e[t];n(i)&&i.forEach((e=>{l.children.push(s(e))}))})),l};return j(e)||(e=D(e)),s(e)}function F(e,t){const i=e.matches;t.matches=[],a(i)&&i.forEach((e=>{if(!a(e.indices)||!e.indices.length)return;const{indices:i,value:n}=e;let o={indices:i,value:n};e.key&&(o.key=e.key.src),e.idx>-1&&(o.refIndex=e.idx),t.matches.push(o)}))}function R(e,t){t.score=e.score}class K{constructor(e,t={},i){this.options={...m,...t},this.options.useExtendedSearch,this._keyStore=new u(this.options.keys),this.setCollection(e,i)}setCollection(e,t){if(this._docs=e,t&&!(t instanceof _))throw new Error("Incorrect 'index' type");this._myIndex=t||v(this.options.keys,this._docs,{getFn:this.options.getFn,fieldNormWeight:this.options.fieldNormWeight})}add(e){a(e)&&(this._docs.push(e),this._myIndex.add(e))}remove(e=(()=>!1)){const t=[];for(let i=0,n=this._docs.length;i{let i=1;e.matches.forEach((({key:e,norm:n,score:o})=>{const s=e?e.weight:null;i*=Math.pow(0===o&&s?Number.EPSILON:o,(s||1)*(t?1:n))})),e.score=i}))}(l,{ignoreFieldNorm:c}),r&&l.sort(a),s(t)&&t>-1&&(l=l.slice(0,t)),function(e,t,{includeMatches:i=m.includeMatches,includeScore:n=m.includeScore}={}){const o=[];return i&&o.push(F),n&&o.push(R),e.map((e=>{const{idx:i}=e,n={item:t[i],refIndex:i};return o.length&&o.forEach((t=>{t(e,n)})),n}))}(l,this._docs,{includeMatches:i,includeScore:n})}_searchStringList(e){const t=P(e,this.options),{records:i}=this._myIndex,n=[];return i.forEach((({v:e,i,n:o})=>{if(!a(e))return;const{isMatch:s,score:r,indices:c}=t.searchIn(e);s&&n.push({item:e,idx:i,matches:[{score:r,value:e,norm:o,indices:c}]})})),n}_searchLogical(e){const t=k(e,this.options),i=(e,t,n)=>{if(!e.children){const{keyId:i,searcher:o}=e,s=this._findMatches({key:this._keyStore.get(i),value:this._myIndex.getValueForItemAtKeyId(t,i),searcher:o});return s&&s.length?[{idx:n,item:t,matches:s}]:[]}const o=[];for(let s=0,r=e.children.length;s{if(a(e)){let r=i(t,e,n);r.length&&(o[n]||(o[n]={idx:n,item:e,matches:[]},s.push(o[n])),r.forEach((({matches:e})=>{o[n].matches.push(...e)})))}})),s}_searchObjectList(e){const t=P(e,this.options),{keys:i,records:n}=this._myIndex,o=[];return n.forEach((({$:e,i:n})=>{if(!a(e))return;let s=[];i.forEach(((i,n)=>{s.push(...this._findMatches({key:i,value:e[n],searcher:t}))})),s.length&&o.push({idx:n,item:e,matches:s})})),o}_findMatches({key:e,value:t,searcher:i}){if(!a(t))return[];let o=[];if(n(t))t.forEach((({v:t,i:n,n:s})=>{if(!a(t))return;const{isMatch:r,score:c,indices:l}=i.searchIn(t);r&&o.push({score:c,key:e,value:t,idx:n,norm:s,indices:l})}));else{const{v:n,n:s}=t,{isMatch:r,score:a,indices:c}=i.searchIn(n);r&&o.push({score:a,key:e,value:n,norm:s,indices:c})}return o}}K.version="6.5.3",K.createIndex=v,K.parseIndex=function(e,{getFn:t=m.getFn,fieldNormWeight:i=m.fieldNormWeight}={}){const{keys:n,records:o}=e,s=new _({getFn:t,fieldNormWeight:i});return s.setKeys(n),s.setIndexRecords(o),s},K.config=m,K.parseQuery=k,function(...e){M.push(...e)}(class{constructor(e,{isCaseSensitive:t=m.isCaseSensitive,includeMatches:i=m.includeMatches,minMatchCharLength:n=m.minMatchCharLength,ignoreLocation:o=m.ignoreLocation,findAllMatches:s=m.findAllMatches,location:r=m.location,threshold:a=m.threshold,distance:c=m.distance}={}){this.query=null,this.options={isCaseSensitive:t,includeMatches:i,minMatchCharLength:n,findAllMatches:s,ignoreLocation:o,location:r,threshold:a,distance:c},this.pattern=t?e:e.toLowerCase(),this.query=function(e,t={}){return e.split("|").map((e=>{let i=e.trim().split(L).filter((e=>e&&!!e.trim())),n=[];for(let e=0,o=i.length;e{"use strict";i.d(t,{Z:()=>f});var n=i(81),o=i.n(n),s=i(645),r=i.n(s),a=i(667),c=i.n(a),l=new URL(i(225),i.b),h=new URL(i(886),i.b),u=r()(o()),d=c()(l),p=c()(h);u.push([e.id,".choices{position:relative;overflow:hidden;margin-bottom:24px;font-size:16px}.choices:focus{outline:0}.choices:last-child{margin-bottom:0}.choices.is-open{overflow:visible}.choices.is-disabled .choices__inner,.choices.is-disabled .choices__input{background-color:#eaeaea;cursor:not-allowed;-webkit-user-select:none;user-select:none}.choices.is-disabled .choices__item{cursor:not-allowed}.choices [hidden]{display:none!important}.choices[data-type*=select-one]{cursor:pointer}.choices[data-type*=select-one] .choices__inner{padding-bottom:7.5px}.choices[data-type*=select-one] .choices__input{display:block;width:100%;padding:10px;border-bottom:1px solid #ddd;background-color:#fff;margin:0}.choices[data-type*=select-one] .choices__button{background-image:url("+d+');padding:0;background-size:8px;position:absolute;top:50%;right:0;margin-top:-10px;margin-right:25px;height:20px;width:20px;border-radius:10em;opacity:.25}.choices[data-type*=select-one] .choices__button:focus,.choices[data-type*=select-one] .choices__button:hover{opacity:1}.choices[data-type*=select-one] .choices__button:focus{box-shadow:0 0 0 2px #00bcd4}.choices[data-type*=select-one] .choices__item[data-value=""] .choices__button{display:none}.choices[data-type*=select-one]::after{content:"";height:0;width:0;border-style:solid;border-color:#333 transparent transparent;border-width:5px;position:absolute;right:11.5px;top:50%;margin-top:-2.5px;pointer-events:none}.choices[data-type*=select-one].is-open::after{border-color:transparent transparent #333;margin-top:-7.5px}.choices[data-type*=select-one][dir=rtl]::after{left:11.5px;right:auto}.choices[data-type*=select-one][dir=rtl] .choices__button{right:auto;left:0;margin-left:25px;margin-right:0}.choices[data-type*=select-multiple] .choices__inner,.choices[data-type*=text] .choices__inner{cursor:text}.choices[data-type*=select-multiple] .choices__button,.choices[data-type*=text] .choices__button{position:relative;display:inline-block;margin:0 -4px 0 8px;padding-left:16px;border-left:1px solid #008fa1;background-image:url('+p+");background-size:8px;width:8px;line-height:1;opacity:.75;border-radius:0}.choices[data-type*=select-multiple] .choices__button:focus,.choices[data-type*=select-multiple] .choices__button:hover,.choices[data-type*=text] .choices__button:focus,.choices[data-type*=text] .choices__button:hover{opacity:1}.choices__inner{display:inline-block;vertical-align:top;width:100%;background-color:#f9f9f9;padding:7.5px 7.5px 3.75px;border:1px solid #ddd;border-radius:2.5px;font-size:14px;min-height:44px;overflow:hidden}.is-focused .choices__inner,.is-open .choices__inner{border-color:#b7b7b7}.is-open .choices__inner{border-radius:2.5px 2.5px 0 0}.is-flipped.is-open .choices__inner{border-radius:0 0 2.5px 2.5px}.choices__list{margin:0;padding-left:0;list-style:none}.choices__list--single{display:inline-block;padding:4px 16px 4px 4px;width:100%}[dir=rtl] .choices__list--single{padding-right:4px;padding-left:16px}.choices__list--single .choices__item{width:100%}.choices__list--multiple{display:inline}.choices__list--multiple .choices__item{display:inline-block;vertical-align:middle;border-radius:20px;padding:4px 10px;font-size:12px;font-weight:500;margin-right:3.75px;margin-bottom:3.75px;background-color:#00bcd4;border:1px solid #00a5bb;color:#fff;word-break:break-all;box-sizing:border-box}.choices__list--multiple .choices__item[data-deletable]{padding-right:5px}[dir=rtl] .choices__list--multiple .choices__item{margin-right:0;margin-left:3.75px}.choices__list--multiple .choices__item.is-highlighted{background-color:#00a5bb;border:1px solid #008fa1}.is-disabled .choices__list--multiple .choices__item{background-color:#aaa;border:1px solid #919191}.choices__list--dropdown,.choices__list[aria-expanded]{visibility:hidden;z-index:1;position:absolute;width:100%;background-color:#fff;border:1px solid #ddd;top:100%;margin-top:-1px;border-bottom-left-radius:2.5px;border-bottom-right-radius:2.5px;overflow:hidden;word-break:break-all;will-change:visibility}.is-active.choices__list--dropdown,.is-active.choices__list[aria-expanded]{visibility:visible}.is-open .choices__list--dropdown,.is-open .choices__list[aria-expanded]{border-color:#b7b7b7}.is-flipped .choices__list--dropdown,.is-flipped .choices__list[aria-expanded]{top:auto;bottom:100%;margin-top:0;margin-bottom:-1px;border-radius:.25rem .25rem 0 0}.choices__list--dropdown .choices__list,.choices__list[aria-expanded] .choices__list{position:relative;max-height:300px;overflow:auto;-webkit-overflow-scrolling:touch;will-change:scroll-position}.choices__list--dropdown .choices__item,.choices__list[aria-expanded] .choices__item{position:relative;padding:10px;font-size:14px}[dir=rtl] .choices__list--dropdown .choices__item,[dir=rtl] .choices__list[aria-expanded] .choices__item{text-align:right}@media (min-width:640px){.choices__list--dropdown .choices__item--selectable,.choices__list[aria-expanded] .choices__item--selectable{padding-right:100px}.choices__list--dropdown .choices__item--selectable::after,.choices__list[aria-expanded] .choices__item--selectable::after{content:attr(data-select-text);font-size:12px;opacity:0;position:absolute;right:10px;top:50%;transform:translateY(-50%)}[dir=rtl] .choices__list--dropdown .choices__item--selectable,[dir=rtl] .choices__list[aria-expanded] .choices__item--selectable{text-align:right;padding-left:100px;padding-right:10px}[dir=rtl] .choices__list--dropdown .choices__item--selectable::after,[dir=rtl] .choices__list[aria-expanded] .choices__item--selectable::after{right:auto;left:10px}}.choices__list--dropdown .choices__item--selectable.is-highlighted,.choices__list[aria-expanded] .choices__item--selectable.is-highlighted{background-color:#f2f2f2}.choices__list--dropdown .choices__item--selectable.is-highlighted::after,.choices__list[aria-expanded] .choices__item--selectable.is-highlighted::after{opacity:.5}.choices__item{cursor:default}.choices__item--selectable{cursor:pointer}.choices__item--disabled{cursor:not-allowed;-webkit-user-select:none;user-select:none;opacity:.5}.choices__heading{font-weight:600;font-size:12px;padding:10px;border-bottom:1px solid #f7f7f7;color:gray}.choices__button{text-indent:-9999px;-webkit-appearance:none;appearance:none;border:0;background-color:transparent;background-repeat:no-repeat;background-position:center;cursor:pointer}.choices__button:focus,.choices__input:focus{outline:0}.choices__input{display:inline-block;vertical-align:baseline;background-color:#f9f9f9;font-size:14px;margin-bottom:5px;border:0;border-radius:0;max-width:100%;padding:4px 0 4px 2px}.choices__input::-webkit-search-cancel-button,.choices__input::-webkit-search-decoration,.choices__input::-webkit-search-results-button,.choices__input::-webkit-search-results-decoration{display:none}.choices__input::-ms-clear,.choices__input::-ms-reveal{display:none;width:0;height:0}[dir=rtl] .choices__input{padding-right:2px;padding-left:0}.choices__placeholder{opacity:.5}",""]);const f=u},778:(e,t,i)=>{"use strict";i.d(t,{Z:()=>l});var n=i(81),o=i.n(n),s=i(645),r=i.n(s),a=i(973),c=r()(o());c.i(a.Z),c.push([e.id,'@keyframes loading-rotation{0%{transform:translate(-50%, -50%) rotate(0deg)}100%{transform:translate(-50%, -50%) rotate(360deg)}}#classifai-post-preview-controls,#classifai-post-preview-wrapper{background-color:#fff;padding:1.5rem 1rem;border-left:1px solid #c3c4c7;border-bottom:1px solid #c3c4c7;border-right:1px solid #c3c4c7}#classifai-post-preview-controls{display:flex;border:1px solid #c3c4c7}#classifai-post-preview-controls .choices{margin-bottom:0;margin-right:1rem;width:100%;border:1px solid #ddd}#classifai-post-preview-controls .choices__inner{border:0;width:auto}#classifai-post-preview-controls #get-classifier-preview-data-btn{position:relative}#classifai-post-preview-controls .get-classifier-preview-data-btn--loading span{opacity:0}#classifai-post-preview-controls .get-classifier-preview-data-btn--loading:after{opacity:0;content:"ï‘£";animation:loading-rotation 2s infinite linear;font-family:dashicons;font-size:1.5rem;position:absolute;top:50%;left:50%;width:1.5rem;height:1.5rem;line-height:1.5rem;transform:translate(-50%, -50%) rotate(0deg)}#classifai-post-preview-controls .get-classifier-preview-data-btn--loading:after{opacity:1}#classifai-post-preview-wrapper .tax-row{margin-bottom:1rem;border:1px solid #ccc;padding:.5rem}#classifai-post-preview-wrapper .tax-row--hide{display:none}#classifai-post-preview-wrapper .tax-type{font-weight:bold;font-size:14px;margin-bottom:.75rem;text-transform:capitalize}#classifai-post-preview-wrapper .tax-cell{margin-bottom:8px;padding:2px 8px;border-radius:15px;text-transform:capitalize;background-color:rgba(70,180,80,.7294117647)}#classifai-post-preview-wrapper .tax-score{display:inline-block;color:#fff;font-weight:bold}#classifai-post-preview-wrapper .tax-label{text-transform:capitalize;font-size:14px;margin-left:8px}.classifai-nlu-sections{display:flex}.classifai-nlu-sections form{min-width:550px}.wrap--nlu{position:relative}.wrap--nlu #classifai-post-preview-app{flex:1;margin-top:250px;align-self:flex-start;position:sticky;top:3rem;margin-left:-5rem}.wrap--nlu #classifai-post-preview-app .choices__inner{display:block;min-height:auto}',""]);const l=c},645:e=>{"use strict";e.exports=function(e){var t=[];return t.toString=function(){return this.map((function(t){var i="",n=void 0!==t[5];return t[4]&&(i+="@supports (".concat(t[4],") {")),t[2]&&(i+="@media ".concat(t[2]," {")),n&&(i+="@layer".concat(t[5].length>0?" ".concat(t[5]):""," {")),i+=e(t),n&&(i+="}"),t[2]&&(i+="}"),t[4]&&(i+="}"),i})).join("")},t.i=function(e,i,n,o,s){"string"==typeof e&&(e=[[null,e,void 0]]);var r={};if(n)for(var a=0;a0?" ".concat(h[5]):""," {").concat(h[1],"}")),h[5]=s),i&&(h[2]?(h[1]="@media ".concat(h[2]," {").concat(h[1],"}"),h[2]=i):h[2]=i),o&&(h[4]?(h[1]="@supports (".concat(h[4],") {").concat(h[1],"}"),h[4]=o):h[4]="".concat(o)),t.push(h))}},t}},667:e=>{"use strict";e.exports=function(e,t){return t||(t={}),e?(e=String(e.__esModule?e.default:e),/^['"].*['"]$/.test(e)&&(e=e.slice(1,-1)),t.hash&&(e+=t.hash),/["'() \t\n]|(%20)/.test(e)||t.needQuotes?'"'.concat(e.replace(/"/g,'\\"').replace(/\n/g,"\\n"),'"'):e):e}},81:e=>{"use strict";e.exports=function(e){return e[1]}},379:e=>{"use strict";var t=[];function i(e){for(var i=-1,n=0;n{"use strict";var t={};e.exports=function(e,i){var n=function(e){if(void 0===t[e]){var i=document.querySelector(e);if(window.HTMLIFrameElement&&i instanceof window.HTMLIFrameElement)try{i=i.contentDocument.head}catch(e){i=null}t[e]=i}return t[e]}(e);if(!n)throw new Error("Couldn't find a style target. This probably means that the value for the 'insert' parameter is invalid.");n.appendChild(i)}},216:e=>{"use strict";e.exports=function(e){var t=document.createElement("style");return e.setAttributes(t,e.attributes),e.insert(t,e.options),t}},565:(e,t,i)=>{"use strict";e.exports=function(e){var t=i.nc;t&&e.setAttribute("nonce",t)}},795:e=>{"use strict";e.exports=function(e){var t=e.insertStyleElement(e);return{update:function(i){!function(e,t,i){var n="";i.supports&&(n+="@supports (".concat(i.supports,") {")),i.media&&(n+="@media ".concat(i.media," {"));var o=void 0!==i.layer;o&&(n+="@layer".concat(i.layer.length>0?" ".concat(i.layer):""," {")),n+=i.css,o&&(n+="}"),i.media&&(n+="}"),i.supports&&(n+="}");var s=i.sourceMap;s&&"undefined"!=typeof btoa&&(n+="\n/*# sourceMappingURL=data:application/json;base64,".concat(btoa(unescape(encodeURIComponent(JSON.stringify(s))))," */")),t.styleTagTransform(n,e,t.options)}(t,e,i)},remove:function(){!function(e){if(null===e.parentNode)return!1;e.parentNode.removeChild(e)}(t)}}}},589:e=>{"use strict";e.exports=function(e,t){if(t.styleSheet)t.styleSheet.cssText=e;else{for(;t.firstChild;)t.removeChild(t.firstChild);t.appendChild(document.createTextNode(e))}}},225:e=>{"use strict";e.exports="data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMjEiIGhlaWdodD0iMjEiIHZpZXdCb3g9IjAgMCAyMSAyMSIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj48ZyBmaWxsPSIjMDAwIiBmaWxsLXJ1bGU9ImV2ZW5vZGQiPjxwYXRoIGQ9Ik0yLjU5Mi4wNDRsMTguMzY0IDE4LjM2NC0yLjU0OCAyLjU0OEwuMDQ0IDIuNTkyeiIvPjxwYXRoIGQ9Ik0wIDE4LjM2NEwxOC4zNjQgMGwyLjU0OCAyLjU0OEwyLjU0OCAyMC45MTJ6Ii8+PC9nPjwvc3ZnPg=="},886:e=>{"use strict";e.exports="data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMjEiIGhlaWdodD0iMjEiIHZpZXdCb3g9IjAgMCAyMSAyMSIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj48ZyBmaWxsPSIjRkZGIiBmaWxsLXJ1bGU9ImV2ZW5vZGQiPjxwYXRoIGQ9Ik0yLjU5Mi4wNDRsMTguMzY0IDE4LjM2NC0yLjU0OCAyLjU0OEwuMDQ0IDIuNTkyeiIvPjxwYXRoIGQ9Ik0wIDE4LjM2NEwxOC4zNjQgMGwyLjU0OCAyLjU0OEwyLjU0OCAyMC45MTJ6Ii8+PC9nPjwvc3ZnPg=="}},t={};function i(n){var o=t[n];if(void 0!==o)return o.exports;var s=t[n]={id:n,exports:{}};return e[n](s,s.exports,i),s.exports}i.m=e,i.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return i.d(t,{a:t}),t},i.d=(e,t)=>{for(var n in t)i.o(t,n)&&!i.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:t[n]})},i.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),i.b=document.baseURI||self.location.href,i.nc=void 0,(()=>{"use strict";var e=i(529),t=i.n(e),n=i(379),o=i.n(n),s=i(795),r=i.n(s),a=i(569),c=i.n(a),l=i(565),h=i.n(l),u=i(216),d=i.n(u),p=i(589),f=i.n(p),m=i(778),g={};function _(e,t,i){return t in e?Object.defineProperty(e,t,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[t]=i,e}function v(e,t){(null==t||t>e.length)&&(t=e.length);for(var i=0,n=new Array(t);i0&&void 0!==arguments[0]?arguments[0]:{},t=arguments.length>1?arguments[1]:void 0;return Object.keys(e).map((function(i){return _({},i,e[i].filter((function(e){return null!=e&&e.score&&100*e.score>t[i]||null!=e&&e.relevance&&100*e.relevance>t[i]?e:void 0})))}))}({categories:o,keywords:void 0===d?[]:d,entities:u,concepts:a},l),f=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[],t="";return e.forEach((function(e){Object.keys(e).forEach((function(i){t+='
').concat(i,"
"),e[i].forEach((function(e){var i=0,n=0;null!=e&&e.score?i=e.score:null!=e&&e.relevance&&(i=e.relevance),null!=e&&e.text?n=e.text:null!=e&&e.label&&(n=e.label);var o=300+300*i;i=(100*i).toFixed(2),n=n.split("/").filter((function(e){return""!==e})).join(", "),t+='
'),t+=''.concat(i,'% ').concat(n,""),t+="
"})),t+="
"}))})),t}(p);r.style.display="block",r.innerHTML=f,e.target.closest(".button").classList.remove("get-classifier-preview-data-btn--loading")}))}));var h,u,d,p=document.getElementById("classifai-preview-post-selector"),f=new(t())(p,{noResultsText:""}),m=(h=function(e){var t=[].slice.call(document.querySelectorAll('input[name*="classifai_watson_nlu[post_types"]:checked')).map((function(e){return e.id.split("-").at(-1)})),i=[].slice.call(document.querySelectorAll('input[name*="classifai_watson_nlu[post_statuses"]:checked')).map((function(e){return e.id.split("-").at(-1)})),n=new FormData;n.append("post_types",t),n.append("post_status",i),n.append("search",e.detail.value),n.append("action","classifai_get_post_search_results"),n.append("nonce",a),fetch("".concat(ajaxurl),{method:"POST",body:n}).then((function(e){return e.json()})).then((function(e){var t=e.data;f.setChoices(t.map((function(e){return{value:e.ID,label:e.post_title}})),"value","label",!0)}))},300,function(){var e=this,t=arguments,i=function(){d=null,h.apply(e,t)},n=u;clearTimeout(d),d=setTimeout(i,300),n&&h.apply(e,t)});p.addEventListener("search",m)}}}()})()})(); \ No newline at end of file diff --git a/dist/js/admin.min.js.LICENSE.txt b/dist/js/admin.min.js.LICENSE.txt new file mode 100644 index 000000000..81c265b73 --- /dev/null +++ b/dist/js/admin.min.js.LICENSE.txt @@ -0,0 +1 @@ +/*! choices.js v10.1.0 | © 2022 Josh Johnson | https://github.com/jshjohnson/Choices#readme */ diff --git a/dist/js/editor-ocr.min.js b/dist/js/editor-ocr.min.js index 708ec03fd..7713bed88 100644 --- a/dist/js/editor-ocr.min.js +++ b/dist/js/editor-ocr.min.js @@ -1 +1,2 @@ -!function(t){var e={};function r(n){if(e[n])return e[n].exports;var o=e[n]={i:n,l:!1,exports:{}};return t[n].call(o.exports,o,o.exports,r),o.l=!0,o.exports}r.m=t,r.c=e,r.d=function(t,e,n){r.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:n})},r.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},r.t=function(t,e){if(1&e&&(t=r(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var n=Object.create(null);if(r.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var o in t)r.d(n,o,function(e){return t[e]}.bind(null,o));return n},r.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return r.d(e,"a",e),e},r.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},r.p="",r(r.s=1)}([,function(t,e){function r(t){return(r="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}function n(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){var r=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null==r)return;var n,o,i=[],a=!0,c=!1;try{for(r=r.call(t);!(a=(n=r.next()).done)&&(i.push(n.value),!e||i.length!==e);a=!0);}catch(t){c=!0,o=t}finally{try{a||null==r.return||r.return()}finally{if(c)throw o}}return i}(t,e)||function(t,e){if(!t)return;if("string"==typeof t)return o(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);"Object"===r&&t.constructor&&(r=t.constructor.name);if("Map"===r||"Set"===r)return Array.from(t);if("Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return o(t,e)}(t,e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function o(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);r=0;--o){var i=this.tryEntries[o],a=i.completion;if("root"===i.tryLoc)return r("end");if(i.tryLoc<=this.prev){var c=n.call(i,"catchLoc"),u=n.call(i,"finallyLoc");if(c&&u){if(this.prev=0;--r){var o=this.tryEntries[r];if(o.tryLoc<=this.prev&&n.call(o,"finallyLoc")&&this.prev=0;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),S(r),d}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.tryLoc===t){var n=r.completion;if("throw"===n.type){var o=n.arg;S(r)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(t,e,r){return this.delegate={iterator:L(t),resultName:e,nextLoc:r},"next"===this.method&&(this.arg=void 0),d}},t}function a(t,e,r,n,o,i,a){try{var c=t[i](a),u=c.value}catch(t){return void r(t)}c.done?e(u):Promise.resolve(u).then(n,o)}function c(t){return function(){var e=this,r=arguments;return new Promise((function(n,o){var i=t.apply(e,r);function c(t){a(i,n,o,c,u,"next",t)}function u(t){a(i,n,o,c,u,"throw",t)}c(void 0)}))}}var u=wp.data,l=u.select,s=u.dispatch,f=u.subscribe,d=wp.blocks.createBlock,p=wp.apiFetch,h=lodash,y=h.find,m=h.debounce,v=wp.hooks.addFilter,g=wp.compose.createHigherOrderComponent,b=wp.blockEditor.BlockControls,w=wp.components,x=w.Button,k=w.Modal,E=w.Flex,S=w.FlexItem,O=w.ToolbarGroup,L=w.ToolbarButton,_=wp.i18n.__,j=wp.element,I=j.useState,T=j.Fragment,B=React.createElement("span",{className:"dashicons dashicons-editor-paste-text"}),P=function(){var t=c(i().mark((function t(e){var r;return i().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,p({path:"/wp/v2/media/".concat(e)});case 2:if(r=t.sent,Object.prototype.hasOwnProperty.call(r,"classifai_has_ocr")&&r.classifai_has_ocr){t.next=5;break}return t.abrupt("return",!1);case 5:if(Object.prototype.hasOwnProperty.call(r,"description")&&Object.prototype.hasOwnProperty.call(r.description,"rendered")&&r.description.rendered){t.next=7;break}return t.abrupt("return",!1);case 7:return t.abrupt("return",r.description.rendered.replace(/(<([^>]+)>)/gi,"").replace(/(\r\n|\n|\r)/gm,"").trim());case 8:case"end":return t.stop()}}),t)})));return function(e){return t.apply(this,arguments)}}(),C=function(){var t=c(i().mark((function t(e,r,n){var o,a,c,u;return i().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(o=l("core/block-editor"),a=o.getBlockIndex,n){t.next=3;break}return t.abrupt("return");case 3:return c=d("core/group",{anchor:"classifai-ocr-".concat(r),className:"is-style-classifai-ocr-text"}),u=d("core/paragraph",{content:n}),t.next=7,s("core/block-editor").insertBlock(c,a(e)+1);case 7:s("core/block-editor").insertBlock(u,0,c.clientId);case 8:case"end":return t.stop()}}),t)})));return function(e,r,n){return t.apply(this,arguments)}}(),R=function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[];if(0===e.length){var r=l("core/block-editor"),n=r.getBlocks;e=n()}return!!y(e,(function(e){return e.attributes.anchor==="classifai-ocr-".concat(t)}))};v("editor.BlockEdit","classifai/image-processing-ocr",g((function(t){return function(e){var r=n(I(!1),2),o=r[0],i=r[1],a=e.attributes,c=e.clientId,u=e.isSelected,l=e.name,s=e.setAttributes;return u&&"core/image"==l?(!a.ocrChecked&&a.id&&P(a.id).then((function(t){t?(s({ocrScannedText:t,ocrChecked:!0}),i(!0)):s({ocrChecked:!0})})),React.createElement(T,null,React.createElement(t,e),a.ocrScannedText&&React.createElement(b,null,React.createElement(O,null,React.createElement(L,{label:_("Insert scanned text into content","classifai"),icon:B,onClick:function(){return C(c,a.id,a.ocrScannedText)},disabled:R(a.id)}))),o&&React.createElement(k,{title:_("ClassifAI detected text in your image","classifai")},React.createElement("p",null,_("Would you like you insert the scanned text under this image block? This enhances search indexing and accessibility for readers.","classifai")),React.createElement(E,{align:"flex-end",justify:"flex-end"},React.createElement(S,null,React.createElement(x,{isPrimary:!0,onClick:function(){C(c,a.id,a.ocrScannedText),i(!1)}},_("Insert text","classifai"))),React.createElement(S,null,React.createElement(x,{isSecondary:!0,onClick:function(){return i(!1)}},_("Dismiss","classifai"))))))):React.createElement(t,e)}}),"imageOcrControl"));v("blocks.registerBlockType","classifai/image-processing-ocr",(function(t,e){return"core/image"!==e||t.attributes&&(t.attributes.ocrScannedText={type:"string",default:""},t.attributes.ocrChecked={type:"boolean",default:!1}),t})),wp.blocks.registerBlockStyle("core/group",{name:"classifai-ocr-text",label:_("Scanned Text from Image","classifai")});var N,A=[];f(m((function(){var t=l("core/block-editor"),e=t.getSelectedBlock(),r=t.getBlocks();if(null===e)return G(),void(N=e);if(e!==N&&!A.includes(e.clientId))if(G(),N=e,"core/image"===e.name){var o=y(r,(function(t){return t.attributes.anchor==="classifai-ocr-".concat(e.attributes.id)}));void 0!==o&&F([o.clientId,e.clientId])}else{var i=t.getBlock(t.getBlockHierarchyRootClientId(e.clientId));if("core/group"===i.name){var a=/classifai-ocr-([0-9]+)/.exec(i.attributes.anchor);if(null!==a){var c=n(a,2);a=c[1];var u=y(r,(function(t){return t.attributes.id==a}));void 0!==u&&F([u.clientId,i.clientId])}}}}),100));var F=function(t){var e,r=null!==(e=document.getElementById("classifai-ocr-style"))&&void 0!==e?e:function(){var t=document.head||document.getElementsByTagName("head")[0],e=document.createElement("style");return e.setAttribute("id","classifai-ocr-style"),t.appendChild(e),e}(),n=t.map((function(t){return"#block-".concat(t,":before")})).join(", "),o="".concat(n,' {\n\t\t\tcontent: "";\n\t\t\tposition: absolute;\n\t\t\tdisplay: block;\n\t\t\ttop: 0;\n\t\t\tleft: -15px;\n\t\t\tbottom: 0;\n\t\t\tborder-left: 4px solid #cfe7f3;\n\t\t\tmix-blend-mode: difference;\n\t\t\topacity: 0.25;\n\t\t}');r.appendChild(document.createTextNode(o)),A=t},G=function(){if(0!==A.length){var t=document.getElementById("classifai-ocr-style");t&&(t.innerText=""),A=[]}}}]); \ No newline at end of file +/*! For license information please see editor-ocr.min.js.LICENSE.txt */ +(()=>{function t(e){return t="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},t(e)}function e(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){var r=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=r){var n,o,i=[],a=!0,c=!1;try{for(r=r.call(t);!(a=(n=r.next()).done)&&(i.push(n.value),!e||i.length!==e);a=!0);}catch(t){c=!0,o=t}finally{try{a||null==r.return||r.return()}finally{if(c)throw o}}return i}}(t,e)||function(t,e){if(t){if("string"==typeof t)return r(t,e);var n=Object.prototype.toString.call(t).slice(8,-1);return"Object"===n&&t.constructor&&(n=t.constructor.name),"Map"===n||"Set"===n?Array.from(t):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?r(t,e):void 0}}(t,e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function r(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);r=0;--n){var i=this.tryEntries[n],a=i.completion;if("root"===i.tryLoc)return r("end");if(i.tryLoc<=this.prev){var c=o.call(i,"catchLoc"),l=o.call(i,"finallyLoc");if(c&&l){if(this.prev=0;--r){var n=this.tryEntries[r];if(n.tryLoc<=this.prev&&o.call(n,"finallyLoc")&&this.prev=0;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),L(r),d}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.tryLoc===t){var n=r.completion;if("throw"===n.type){var o=n.arg;L(r)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(t,e,r){return this.delegate={iterator:I(t),resultName:e,nextLoc:r},"next"===this.method&&(this.arg=void 0),d}},e}function o(t,e,r,n,o,i,a){try{var c=t[i](a),l=c.value}catch(t){return void r(t)}c.done?e(l):Promise.resolve(l).then(n,o)}function i(t){return function(){var e=this,r=arguments;return new Promise((function(n,i){var a=t.apply(e,r);function c(t){o(a,n,i,c,l,"next",t)}function l(t){o(a,n,i,c,l,"throw",t)}c(void 0)}))}}var a=wp.data,c=a.select,l=a.dispatch,u=a.subscribe,s=wp.blocks.createBlock,f=wp.apiFetch,d=lodash,h=d.find,p=d.debounce,y=wp.hooks.addFilter,m=wp.compose.createHigherOrderComponent,v=wp.blockEditor.BlockControls,g=wp.components,b=g.Button,w=g.Modal,x=g.Flex,k=g.FlexItem,E=g.ToolbarGroup,L=g.ToolbarButton,S=wp.i18n.__,I=wp.element,O=I.useState,_=I.Fragment,j=React.createElement("span",{className:"dashicons dashicons-editor-paste-text"}),T=function(){var t=i(n().mark((function t(e){var r;return n().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,f({path:"/wp/v2/media/".concat(e)});case 2:if(r=t.sent,Object.prototype.hasOwnProperty.call(r,"classifai_has_ocr")&&r.classifai_has_ocr){t.next=5;break}return t.abrupt("return",!1);case 5:if(Object.prototype.hasOwnProperty.call(r,"description")&&Object.prototype.hasOwnProperty.call(r.description,"rendered")&&r.description.rendered){t.next=7;break}return t.abrupt("return",!1);case 7:return t.abrupt("return",r.description.rendered.replace(/(<([^>]+)>)/gi,"").replace(/(\r\n|\n|\r)/gm,"").trim());case 8:case"end":return t.stop()}}),t)})));return function(e){return t.apply(this,arguments)}}(),B=function(){var t=i(n().mark((function t(e,r,o){var i,a,u,f;return n().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(i=c("core/block-editor"),a=i.getBlockIndex,o){t.next=3;break}return t.abrupt("return");case 3:return u=s("core/group",{anchor:"classifai-ocr-".concat(r),className:"is-style-classifai-ocr-text"}),f=s("core/paragraph",{content:o}),t.next=7,l("core/block-editor").insertBlock(u,a(e)+1);case 7:l("core/block-editor").insertBlock(f,0,u.clientId);case 8:case"end":return t.stop()}}),t)})));return function(e,r,n){return t.apply(this,arguments)}}(),C=function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[];if(0===e.length){var r=c("core/block-editor"),n=r.getBlocks;e=n()}return!!h(e,(function(e){return e.attributes.anchor==="classifai-ocr-".concat(t)}))};y("editor.BlockEdit","classifai/image-processing-ocr",m((function(t){return function(r){var n=e(O(!1),2),o=n[0],i=n[1],a=r.attributes,c=r.clientId,l=r.isSelected,u=r.name,s=r.setAttributes;return l&&"core/image"==u?(!a.ocrChecked&&a.id&&T(a.id).then((function(t){t?(s({ocrScannedText:t,ocrChecked:!0}),i(!0)):s({ocrChecked:!0})})),React.createElement(_,null,React.createElement(t,r),a.ocrScannedText&&React.createElement(v,null,React.createElement(E,null,React.createElement(L,{label:S("Insert scanned text into content","classifai"),icon:j,onClick:function(){return B(c,a.id,a.ocrScannedText)},disabled:C(a.id)}))),o&&React.createElement(w,{title:S("ClassifAI detected text in your image","classifai")},React.createElement("p",null,S("Would you like you insert the scanned text under this image block? This enhances search indexing and accessibility for readers.","classifai")),React.createElement(x,{align:"flex-end",justify:"flex-end"},React.createElement(k,null,React.createElement(b,{isPrimary:!0,onClick:function(){B(c,a.id,a.ocrScannedText),i(!1)}},S("Insert text","classifai"))),React.createElement(k,null,React.createElement(b,{isSecondary:!0,onClick:function(){return i(!1)}},S("Dismiss","classifai"))))))):React.createElement(t,r)}}),"imageOcrControl")),y("blocks.registerBlockType","classifai/image-processing-ocr",(function(t,e){return"core/image"!==e||t.attributes&&(t.attributes.ocrScannedText={type:"string",default:""},t.attributes.ocrChecked={type:"boolean",default:!1}),t})),wp.blocks.registerBlockStyle("core/group",{name:"classifai-ocr-text",label:S("Scanned Text from Image","classifai")});var R,N=[];u(p((function(){var t=c("core/block-editor"),r=t.getSelectedBlock(),n=t.getBlocks();if(null===r)return A(),void(R=r);if(r!==R&&!N.includes(r.clientId))if(A(),R=r,"core/image"===r.name){var o=h(n,(function(t){return t.attributes.anchor==="classifai-ocr-".concat(r.attributes.id)}));void 0!==o&&P([o.clientId,r.clientId])}else{var i=t.getBlock(t.getBlockHierarchyRootClientId(r.clientId));if("core/group"===i.name){var a=/classifai-ocr-([0-9]+)/.exec(i.attributes.anchor);if(null!==a){var l=e(a,2);a=l[1];var u=h(n,(function(t){return t.attributes.id==a}));void 0!==u&&P([u.clientId,i.clientId])}}}}),100));var P=function(t){var e,r=null!==(e=document.getElementById("classifai-ocr-style"))&&void 0!==e?e:function(){var t=document.head||document.getElementsByTagName("head")[0],e=document.createElement("style");return e.setAttribute("id","classifai-ocr-style"),t.appendChild(e),e}(),n=t.map((function(t){return"#block-".concat(t,":before")})).join(", "),o="".concat(n,' {\n\t\t\tcontent: "";\n\t\t\tposition: absolute;\n\t\t\tdisplay: block;\n\t\t\ttop: 0;\n\t\t\tleft: -15px;\n\t\t\tbottom: 0;\n\t\t\tborder-left: 4px solid #cfe7f3;\n\t\t\tmix-blend-mode: difference;\n\t\t\topacity: 0.25;\n\t\t}');r.appendChild(document.createTextNode(o)),N=t},A=function(){if(0!==N.length){var t=document.getElementById("classifai-ocr-style");t&&(t.innerText=""),N=[]}}})(); \ No newline at end of file diff --git a/dist/js/editor-ocr.min.js.LICENSE.txt b/dist/js/editor-ocr.min.js.LICENSE.txt new file mode 100644 index 000000000..ae386fb79 --- /dev/null +++ b/dist/js/editor-ocr.min.js.LICENSE.txt @@ -0,0 +1 @@ +/*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ diff --git a/dist/js/editor.min.js b/dist/js/editor.min.js index bbc36f884..3adb4bace 100644 --- a/dist/js/editor.min.js +++ b/dist/js/editor.min.js @@ -1 +1 @@ -!function(e){var t={};function r(o){if(t[o])return t[o].exports;var n=t[o]={i:o,l:!1,exports:{}};return e[o].call(n.exports,n,n.exports,r),n.l=!0,n.exports}r.m=e,r.c=t,r.d=function(e,t,o){r.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:o})},r.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},r.t=function(e,t){if(1&t&&(e=r(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var o=Object.create(null);if(r.r(o),Object.defineProperty(o,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var n in e)r.d(o,n,function(t){return e[t]}.bind(null,n));return o},r.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return r.d(t,"a",t),t},r.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},r.p="",r(r.s=0)}([function(e,t){var r=wp.data,o=r.subscribe,n=r.select,i=r.dispatch,a=!1,c=!1;o((function(){if(!1===a&&(a=!0===wp.data.select("core/editor").isSavingPost()),a&&!1===wp.data.select("core/editor").isSavingPost()&&!1===c){var e=n("core/editor").getCurrentPostAttribute("meta");if(e&&e._classifai_error){c=!0;var t=JSON.parse(e._classifai_error);i("core/notices").createErrorNotice("Failed to classify content with the IBM Watson NLU API. Error: ".concat(t.code," - ").concat(t.message)),a=!1,c=!1}}}))}]); \ No newline at end of file +(()=>{var e=wp.data,t=e.subscribe,r=e.select,a=e.dispatch,o=!1,c=!1;t((function(){if(!1===o&&(o=!0===wp.data.select("core/editor").isSavingPost()),o&&!1===wp.data.select("core/editor").isSavingPost()&&!1===c){var e=r("core/editor").getCurrentPostAttribute("meta");if(e&&e._classifai_error){c=!0;var t=JSON.parse(e._classifai_error);a("core/notices").createErrorNotice("Failed to classify content with the IBM Watson NLU API. Error: ".concat(t.code," - ").concat(t.message)),o=!1,c=!1}}}))})(); \ No newline at end of file diff --git a/dist/js/gutenberg-plugin.min.js b/dist/js/gutenberg-plugin.min.js new file mode 100644 index 000000000..e23f634ff --- /dev/null +++ b/dist/js/gutenberg-plugin.min.js @@ -0,0 +1 @@ +(()=>{var e={437:(e,t,n)=>{var s=n(363);function r(e){return s.createElement("svg",e,s.createElement("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M3.51922 0C1.57575 0 0 1.5842 0 3.53846V42.4615C0 44.4158 1.57575 46 3.51922 46H57.4808C59.4243 46 61 44.4158 61 42.4615V3.53846C61 1.5842 59.4243 0 57.4808 0H3.51922ZM16.709 8.13836H21.4478L33.58 39.5542H27.524L24.0318 30.5144H13.9699L10.5169 39.5542H4.55669L16.709 8.13836ZM19.0894 16.7007C18.9846 17.041 18.878 17.3735 18.7702 17.698L18.7582 17.7344L15.9976 25.1398H22.1464L19.4013 17.6851L19.0894 16.7007ZM40.3164 8.13836H52.9056V12.1528L49.4929 12.9715V34.6306L52.9056 35.41V39.4338H40.3164V35.41L43.7291 34.6306V12.9715L40.3164 12.1528V8.13836Z",fill:"#aaa"}))}r.defaultProps={width:"20",height:"15",viewBox:"0 0 61 46",fill:"none"},e.exports=r,r.default=r},363:e=>{"use strict";e.exports=React}},t={};function n(s){var r=t[s];if(void 0!==r)return r.exports;var o=t[s]={exports:{}};return e[s](o,o.exports,n),o.exports}n.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return n.d(t,{a:t}),t},n.d=(e,t)=>{for(var s in t)n.o(t,s)&&!n.o(e,s)&&Object.defineProperty(e,s,{enumerable:!0,get:t[s]})},n.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),(()=>{"use strict";var e=n(437),t=n.n(e),s=wp.components.Icon,r=wp.data,o=r.useSelect,a=r.useDispatch,i=wp.editPost.PluginDocumentSettingPanel,l=wp.components.ToggleControl,c=wp.i18n.__,u=wp.plugins.registerPlugin,p=window.classifaiPostData,d=function(){return React.createElement(s,{className:"components-panel__icon",icon:React.createElement(t(),null),size:20})},f=function(){var e=o((function(e){return e("core/editor").getEditedPostAttribute("classifai_process_content")})),t=a("core/editor").editPost,n="no"===e?"no":"yes";return React.createElement(l,{label:c("Process content on update","classifai"),help:c("yes"===n?"ClassifAI language processing is enabled":"ClassifAI language processing is disabled","classifai"),checked:"yes"===n,onChange:function(e){t({classifai_process_content:e?"yes":"no"})}})};u("classifai-plugin",{render:function(){if(p.noPermissions&&1===parseInt(p.noPermissions))return null;if(!p.NLUEnabled)return null;var e=o((function(e){return e("core/editor").getCurrentPostType()})),t=o((function(e){return e("core/editor").getCurrentPostAttribute("status")}));return p.supportedPostTypes&&!p.supportedPostTypes.includes(e)||p.supportedPostStatues&&!p.supportedPostStatues.includes(t)?null:React.createElement(i,{title:c("ClassifAI","classifai"),icon:d,className:"classifai-panel"},React.createElement(f,null))}})})()})(); \ No newline at end of file diff --git a/dist/js/media.min.js b/dist/js/media.min.js index 480731511..91f65282d 100644 --- a/dist/js/media.min.js +++ b/dist/js/media.min.js @@ -1 +1 @@ -!function(t){var e={};function n(r){if(e[r])return e[r].exports;var a=e[r]={i:r,l:!1,exports:{}};return t[r].call(a.exports,a,a.exports,n),a.l=!0,a.exports}n.m=t,n.c=e,n.d=function(t,e,r){n.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:r})},n.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},n.t=function(t,e){if(1&e&&(t=n(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var a in t)n.d(r,a,function(e){return t[e]}.bind(null,a));return r},n.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return n.d(e,"a",e),e},n.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},n.p="",n(n.s=2)}({2:function(t,e){function n(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){var n=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null==n)return;var r,a,i=[],o=!0,c=!1;try{for(n=n.call(t);!(o=(r=n.next()).done)&&(i.push(r.value),!e||i.length!==e);o=!0);}catch(t){c=!0,a=t}finally{try{o||null==n.return||n.return()}finally{if(c)throw a}}return i}(t,e)||function(t,e){if(!t)return;if("string"==typeof t)return r(t,e);var n=Object.prototype.toString.call(t).slice(8,-1);"Object"===n&&t.constructor&&(n=t.constructor.name);if("Map"===n||"Set"===n)return Array.from(t);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return r(t,e)}(t,e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function r(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,r=new Array(e);n{function t(t,n){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){var n=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=n){var a,i,r=[],o=!0,c=!1;try{for(n=n.call(t);!(o=(a=n.next()).done)&&(r.push(a.value),!e||r.length!==e);o=!0);}catch(t){c=!0,i=t}finally{try{o||null==n.return||n.return()}finally{if(c)throw i}}return r}}(t,n)||function(t,n){if(t){if("string"==typeof t)return e(t,n);var a=Object.prototype.toString.call(t).slice(8,-1);return"Object"===a&&t.constructor&&(a=t.constructor.name),"Map"===a||"Set"===a?Array.from(t):"Arguments"===a||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(a)?e(t,n):void 0}}(t,n)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function e(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,a=new Array(e);nsave_post_handler = new SavePostHandler(); + $this->computer_vision = new ComputerVision( false ); foreach ( $post_types as $post_type ) { add_filter( "bulk_actions-edit-$post_type", [ $this, 'register_bulk_actions' ] ); @@ -44,6 +51,9 @@ public function register() { } } + add_filter( 'bulk_actions-upload', [ $this, 'register_media_bulk_actions' ] ); + add_filter( 'handle_bulk_actions-upload', [ $this, 'media_bulk_action_handler' ], 10, 3 ); + add_action( 'admin_notices', [ $this, 'bulk_action_admin_notice' ] ); } @@ -59,6 +69,30 @@ public function register_bulk_actions( $bulk_actions ) { return $bulk_actions; } + /** + * Register Classifai media bulk actions. + * + * @param array $bulk_actions Current bulk actions. + * + * @return array + */ + public function register_media_bulk_actions( $bulk_actions ) { + $settings = $this->computer_vision->get_settings(); + + if ( + 'no' !== $settings['enable_image_tagging'] || + 'no' !== $settings['enable_image_captions'] + ) { + $bulk_actions['scan_image'] = __( 'Scan Image', 'classifai' ); + } + + if ( isset( $settings['enable_smart_cropping'] ) && '1' === $settings['enable_smart_cropping'] ) { + $bulk_actions['smart_crop'] = __( 'Smart Crop', 'classifai' ); + } + + return $bulk_actions; + } + /** * Handle bulk actions. * @@ -76,29 +110,84 @@ public function bulk_action_handler( $redirect_to, $doaction, $post_ids ) { foreach ( $post_ids as $post_id ) { $this->save_post_handler->classify( $post_id ); } + $redirect_to = remove_query_arg( [ 'bulk_classified', 'bulk_scanned', 'bulk_cropped' ], $redirect_to ); $redirect_to = add_query_arg( 'bulk_classified', count( $post_ids ), $redirect_to ); return $redirect_to; } /** - * Display an admin notice after classifying posts in bulk. + * Handle media bulk actions. + * + * @param string $redirect_to Redirect URL after bulk actions. + * @param string $doaction Action ID. + * @param array $attachment_ids Attachment ids to apply bulk actions to. + * + * @return string + */ + public function media_bulk_action_handler( $redirect_to, $doaction, $attachment_ids ) { + if ( + empty( $attachment_ids ) || + ! in_array( $doaction, [ 'scan_image', 'smart_crop' ], true ) + ) { + return $redirect_to; + } + + foreach ( $attachment_ids as $attachment_id ) { + $current_meta = wp_get_attachment_metadata( $attachment_id ); + + if ( 'smart_crop' === $doaction ) { + $this->computer_vision->smart_crop_image( $current_meta, $attachment_id ); + } else { + $this->computer_vision->generate_image_alt_tags( $current_meta, $attachment_id ); + } + } + + $action = 'scan_image' === $doaction ? 'scanned' : 'cropped'; + + $redirect_to = remove_query_arg( [ 'bulk_classified', 'bulk_scanned', 'bulk_cropped' ], $redirect_to ); + $redirect_to = add_query_arg( rawurlencode( "bulk_{$action}" ), count( $attachment_ids ), $redirect_to ); + return esc_url_raw( $redirect_to ); + } + + /** + * Display an admin notice after bulk updates. */ public function bulk_action_admin_notice() { - if ( empty( $_REQUEST['bulk_classified'] ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Recommended + + $classified = ! empty( $_GET['bulk_classified'] ) ? intval( wp_unslash( $_GET['bulk_classified'] ) ) : 0; // phpcs:ignore WordPress.Security.NonceVerification.Recommended + $scanned = ! empty( $_GET['bulk_scanned'] ) ? intval( wp_unslash( $_GET['bulk_scanned'] ) ) : 0; // phpcs:ignore WordPress.Security.NonceVerification.Recommended + $cropped = ! empty( $_GET['bulk_cropped'] ) ? intval( wp_unslash( $_GET['bulk_cropped'] ) ) : 0; // phpcs:ignore WordPress.Security.NonceVerification.Recommended + + if ( ! $classified && ! $scanned && ! $cropped ) { return; } - $classified_posts_count = intval( $_REQUEST['bulk_classified'] ); // phpcs:ignore WordPress.Security.NonceVerification.Recommended + if ( $classified ) { + $classified_posts_count = $classified; + $post_type = 'post'; + $action = __( 'Classified', 'classifai' ); + } elseif ( $scanned ) { + $classified_posts_count = $scanned; + $post_type = 'image'; + $action = __( 'Scanned', 'classifai' ); + } elseif ( $cropped ) { + $classified_posts_count = $cropped; + $post_type = 'image'; + $action = __( 'Cropped', 'classifai' ); + } $output = '

'; $output .= sprintf( + /* translators: %1$s: action, %2$s: number of posts, %3$s: post type*/ _n( - 'Classified %s post.', - 'Classified %s posts.', + '%1$s %2$s %3$s.', + '%1$s %2$s %3$ss.', $classified_posts_count, 'classifai' ), - $classified_posts_count + $action, + $classified_posts_count, + $post_type ); $output .= '

'; echo wp_kses( diff --git a/includes/Classifai/Admin/PreviewClassifierData.php b/includes/Classifai/Admin/PreviewClassifierData.php new file mode 100644 index 000000000..cfd8cdd0d --- /dev/null +++ b/includes/Classifai/Admin/PreviewClassifierData.php @@ -0,0 +1,75 @@ + false, + 'sentiment' => false, + 'limit' => defined( 'WATSON_KEYWORD_LIMIT' ) ? WATSON_KEYWORD_LIMIT : 10, + ]; + + $text_to_classify = $normalizer->normalize( $post_id ); + $body = $classifier->get_body( $text_to_classify, $features ); + $request_options['body'] = $body; + $request = $classifier->get_request(); + + $classified_data = $request->post( $classifier->get_endpoint(), $request_options ); + + wp_send_json_success( $classified_data ); + } + + /** + * Searches and returns posts. + */ + public function get_post_search_results() { + $nonce = isset( $_POST['nonce'] ) ? sanitize_text_field( $_POST['nonce'] ) : false; + + if ( ! $nonce || ! wp_verify_nonce( $nonce, 'classifai-previewer-action' ) ) { + wp_send_json_error( esc_html__( 'Failed nonce check.', 'classifai' ) ); + } + + $search_term = isset( $_POST['search'] ) ? sanitize_text_field( $_POST['search'] ) : ''; + $post_types = isset( $_POST['post_types'] ) ? explode( ',', sanitize_text_field( $_POST['post_types'] ) ) : 'post'; + $post_statuses = isset( $_POST['post_status'] ) ? explode( ',', sanitize_text_field( $_POST['post_status'] ) ) : 'publish'; + + $posts = get_posts( + array( + 'post_type' => $post_types, + 'post_status' => $post_statuses, + 's' => $search_term, + ) + ); + + wp_send_json_success( $posts ); + } +} + diff --git a/includes/Classifai/Admin/SavePostHandler.php b/includes/Classifai/Admin/SavePostHandler.php index fac331d28..54ec702cb 100644 --- a/includes/Classifai/Admin/SavePostHandler.php +++ b/includes/Classifai/Admin/SavePostHandler.php @@ -89,6 +89,11 @@ public function did_save_post( $post_id ) { // Process posts in allowed post statuses, supported items and only if features are enabled if ( in_array( $post_status, $post_statuses, true ) && in_array( $post_type, $supported, true ) && \Classifai\language_processing_features_enabled() ) { + // Check if processing content on save is disabled. + $classifai_process_content = get_post_meta( $post_id, '_classifai_process_content', true ); + if ( 'no' === $classifai_process_content ) { + return; + } $this->classify( $post_id ); } } diff --git a/includes/Classifai/Providers/Azure/ComputerVision.php b/includes/Classifai/Providers/Azure/ComputerVision.php index ad4f4b0dd..3b2c3ba5f 100644 --- a/includes/Classifai/Providers/Azure/ComputerVision.php +++ b/includes/Classifai/Providers/Azure/ComputerVision.php @@ -528,6 +528,14 @@ protected function scan_image( $image_url, array $routes = [] ) { $settings = $this->get_settings(); $url = $this->prep_api_url( $routes ); + /* + * MS Computer Vision requires full image URL. So, if the file URL is relative, + * then we transform it into a full URL. + */ + if ( '/' === substr( $image_url, 0, 1 ) ) { + $image_url = get_site_url() . $image_url; + } + $request = wp_remote_post( $url, [ diff --git a/includes/Classifai/Providers/Watson/NLU.php b/includes/Classifai/Providers/Watson/NLU.php index 50a24ee76..c6cf0390a 100644 --- a/includes/Classifai/Providers/Watson/NLU.php +++ b/includes/Classifai/Providers/Watson/NLU.php @@ -6,6 +6,7 @@ namespace Classifai\Providers\Watson; use Classifai\Admin\SavePostHandler; +use Classifai\Admin\PreviewClassifierData; use Classifai\Providers\Provider; use Classifai\Taxonomy\TaxonomyFactory; use function Classifai\get_post_types_for_language_settings; @@ -118,6 +119,13 @@ public function can_register() { public function register() { add_action( 'enqueue_block_editor_assets', [ $this, 'enqueue_editor_assets' ] ); add_action( 'admin_enqueue_scripts', [ $this, 'enqueue_admin_assets' ] ); + + // Add classifai meta box to classic editor. + add_action( 'add_meta_boxes', [ $this, 'add_classifai_meta_box' ], 10, 2 ); + add_action( 'save_post', [ $this, 'classifai_save_post_metadata' ], 5 ); + + add_filter( 'rest_api_init', [ $this, 'add_process_content_meta_to_rest_api' ] ); + $this->taxonomy_factory = new TaxonomyFactory(); $this->taxonomy_factory->build_all(); @@ -126,6 +134,8 @@ public function register() { if ( $this->save_post_handler->can_register() ) { $this->save_post_handler->register(); } + + new PreviewClassifierData(); } /** @@ -172,6 +182,7 @@ public function get_settings( $index = false ) { * Enqueue the editor scripts. */ public function enqueue_editor_assets() { + global $post; wp_enqueue_script( 'classifai-editor', // Handle. CLASSIFAI_PLUGIN_URL . 'dist/js/editor.min.js', @@ -179,6 +190,29 @@ public function enqueue_editor_assets() { CLASSIFAI_PLUGIN_VERSION, true ); + + if ( empty( $post ) ) { + return; + } + + wp_enqueue_script( + 'classifai-gutenberg-plugin', + CLASSIFAI_PLUGIN_URL . 'dist/js/gutenberg-plugin.min.js', + array( 'wp-blocks', 'wp-i18n', 'wp-element', 'wp-editor', 'wp-edit-post', 'wp-components', 'wp-data', 'wp-plugins' ), + CLASSIFAI_PLUGIN_VERSION, + true + ); + + wp_localize_script( + 'classifai-gutenberg-plugin', + 'classifaiPostData', + [ + 'NLUEnabled' => \Classifai\language_processing_features_enabled(), + 'supportedPostTypes' => \Classifai\get_supported_post_types(), + 'supportedPostStatues' => \Classifai\get_supported_post_statuses(), + 'noPermissions' => ! is_user_logged_in() || ! current_user_can( 'edit_posts' ), + ] + ); } /** @@ -196,10 +230,11 @@ public function enqueue_admin_assets() { 'classifai-admin', 'ClassifAI', [ - 'api_password' => __( 'API Password', 'classifai' ), - 'api_key' => __( 'API Key', 'classifai' ), - 'use_key' => __( 'Use an API Key instead?', 'classifai' ), - 'use_password' => __( 'Use a username/password instead?', 'classifai' ), + 'api_password' => __( 'API Password', 'classifai' ), + 'api_key' => __( 'API Key', 'classifai' ), + 'use_key' => __( 'Use an API Key instead?', 'classifai' ), + 'use_password' => __( 'Use a username/password instead?', 'classifai' ), + 'loading_preview' => __( 'Loading Preview', 'classifai' ), ] ); } @@ -736,4 +771,103 @@ private function get_formatted_latest_response() { return preg_replace( '/,"/', ', "', wp_json_encode( $formatted_data ) ); } + + /** + * Add metabox to enable/disable language processing on post/post types. + * + * @param string $post_type Post Type. + * @param WP_Post $post WP_Post object. + * + * @since 1.8.0 + */ + public function add_classifai_meta_box( $post_type, $post ) { + $supported_post_types = \Classifai\get_supported_post_types(); + if ( in_array( $post_type, $supported_post_types, true ) ) { + add_meta_box( + 'classifai-nlu-meta-box', + __( 'ClassifAI Language Processing', 'classifai' ), + [ $this, 'render_classifai_meta_box' ], + null, + 'side', + 'low', + array( '__back_compat_meta_box' => true ) + ); + } + } + + /** + * Render metabox content. + * + * @param WP_Post $post WP_Post object. + * + * @since 1.8.0 + */ + public function render_classifai_meta_box( $post ) { + wp_nonce_field( 'classifai_language_processing_meta_action', 'classifai_language_processing_meta' ); + $classifai_process_content = get_post_meta( $post->ID, '_classifai_process_content', true ); + $classifai_process_content = ( 'no' === $classifai_process_content ) ? 'no' : 'yes'; + ?> +

+ +

+ function( $object ) { + $process_content = get_post_meta( $object['id'], '_classifai_process_content', true ); + return ( 'no' === $process_content ) ? 'no' : 'yes'; + }, + 'update_callback' => function ( $value, $object ) { + $value = ( 'no' === $value ) ? 'no' : 'yes'; + return update_post_meta( $object->ID, '_classifai_process_content', $value ); + }, + 'schema' => [ + 'type' => 'string', + 'context' => [ 'view', 'edit' ], + ], + ) + ); + } } diff --git a/includes/Classifai/Services/Service.php b/includes/Classifai/Services/Service.php index 50d68bfa4..5d2a87994 100644 --- a/includes/Classifai/Services/Service.php +++ b/includes/Classifai/Services/Service.php @@ -106,7 +106,7 @@ public function get_display_name() { public function render_settings_page() { $active_tab = isset( $_GET['tab'] ) ? sanitize_text_field( $_GET['tab'] ) : $this->provider_classes[0]->get_settings_section(); // phpcs:ignore WordPress.Security.NonceVerification.Recommended ?> -
+

display_name ); ?>

provider_classes ) ) : ?> -
- -
+
+
+ +
+
+ $supported_post_types, + 'post_status' => $supported_post_statuses, + 'posts_per_page' => 10, + ) + ); + + $features = array( + 'category' => array( + 'name' => esc_html__( 'Category', 'classifai' ), + 'enabled' => \Classifai\get_feature_enabled( 'category' ), + 'plural' => 'categories', + ), + 'keyword' => array( + 'name' => esc_html__( 'Keyword', 'classifai' ), + 'enabled' => \Classifai\get_feature_enabled( 'keyword' ), + 'plural' => 'keywords', + ), + 'entity' => array( + 'name' => esc_html__( 'Entity', 'classifai' ), + 'enabled' => \Classifai\get_feature_enabled( 'entity' ), + 'plural' => 'entities', + ), + 'concept' => array( + 'name' => esc_html__( 'Concept', 'classifai' ), + 'enabled' => \Classifai\get_feature_enabled( 'concept' ), + 'plural' => 'concepts', + ), + ); + ?> +

+
+ + + +
+
+ $feature ) : ?> +
+
+
+ +
+
+
the stable version of ClassifAI instead." msgstr "" -#: includes/Classifai/Admin/BulkActions.php:58 -#: includes/Classifai/Admin/BulkActions.php:134 +#: includes/Classifai/Admin/BulkActions.php:68 +#: includes/Classifai/Admin/BulkActions.php:223 msgid "Classify" msgstr "" -#: includes/Classifai/Admin/BulkActions.php:95 -msgid "Classified %s post." -msgid_plural "Classified %s posts." +#: includes/Classifai/Admin/BulkActions.php:86 +msgid "Scan Image" +msgstr "" + +#: includes/Classifai/Admin/BulkActions.php:90 +msgid "Smart Crop" +msgstr "" + +#: includes/Classifai/Admin/BulkActions.php:168 +msgid "Classified" +msgstr "" + +#: includes/Classifai/Admin/BulkActions.php:172 +msgid "Scanned" +msgstr "" + +#: includes/Classifai/Admin/BulkActions.php:176 +msgid "Cropped" +msgstr "" + +#: includes/Classifai/Admin/BulkActions.php:182 +#. translators: %1$s: action, %2$s: number of posts, %3$s: post type +msgid "%1$s %2$s %3$s." +msgid_plural "%1$s %2$s %3$ss." msgstr[0] "" msgstr[1] "" @@ -67,6 +88,11 @@ msgstr "" msgid "ClassifAI requires setup" msgstr "" +#: includes/Classifai/Admin/PreviewClassifierData.php:24 +#: includes/Classifai/Admin/PreviewClassifierData.php:57 +msgid "Failed nonce check." +msgstr "" + #: includes/Classifai/Providers/Azure/ComputerVision.php:212 msgid "ClassifAI Image Processing" msgstr "" @@ -80,7 +106,7 @@ msgid "No alt text? Rescan image" msgstr "" #: includes/Classifai/Providers/Azure/ComputerVision.php:239 -#: includes/Classifai/Providers/Azure/ComputerVision.php:768 +#: includes/Classifai/Providers/Azure/ComputerVision.php:776 msgid "Generate alt text" msgstr "" @@ -123,11 +149,11 @@ msgstr "" msgid "In progress!" msgstr "" -#: includes/Classifai/Providers/Azure/ComputerVision.php:743 +#: includes/Classifai/Providers/Azure/ComputerVision.php:751 msgid "Endpoint URL" msgstr "" -#: includes/Classifai/Providers/Azure/ComputerVision.php:751 +#: includes/Classifai/Providers/Azure/ComputerVision.php:759 msgid "" "Supported protocol and hostname endpoints, e.g., " "https://REGION.api.cognitive.microsoft.com or " @@ -135,126 +161,126 @@ msgid "" "different based on your setting choices in Azure." msgstr "" -#: includes/Classifai/Providers/Azure/ComputerVision.php:756 -#: includes/Classifai/Providers/Watson/NLU.php:200 -#: includes/Classifai/Providers/Watson/NLU.php:295 +#: includes/Classifai/Providers/Azure/ComputerVision.php:764 +#: includes/Classifai/Providers/Watson/NLU.php:234 +#: includes/Classifai/Providers/Watson/NLU.php:330 msgid "API Key" msgstr "" -#: includes/Classifai/Providers/Azure/ComputerVision.php:776 +#: includes/Classifai/Providers/Azure/ComputerVision.php:784 msgid "The alt text field will be filled out automatically." msgstr "" -#: includes/Classifai/Providers/Azure/ComputerVision.php:781 +#: includes/Classifai/Providers/Azure/ComputerVision.php:789 msgid "Alt text confidence threshold" msgstr "" -#: includes/Classifai/Providers/Azure/ComputerVision.php:789 +#: includes/Classifai/Providers/Azure/ComputerVision.php:797 msgid "" "Minimum confidence score for automatically added alt text, numeric value " "from 0-100. Recommended to be set to at least 75." msgstr "" -#: includes/Classifai/Providers/Azure/ComputerVision.php:794 +#: includes/Classifai/Providers/Azure/ComputerVision.php:802 msgid "Tag images" msgstr "" -#: includes/Classifai/Providers/Azure/ComputerVision.php:802 +#: includes/Classifai/Providers/Azure/ComputerVision.php:810 msgid "Image tags will be added automatically." msgstr "" -#: includes/Classifai/Providers/Azure/ComputerVision.php:807 +#: includes/Classifai/Providers/Azure/ComputerVision.php:815 msgid "Tag confidence threshold" msgstr "" -#: includes/Classifai/Providers/Azure/ComputerVision.php:815 +#: includes/Classifai/Providers/Azure/ComputerVision.php:823 msgid "" "Minimum confidence score for automatically added image tags, numeric value " "from 0-100. Recommended to be set to at least 70." msgstr "" -#: includes/Classifai/Providers/Azure/ComputerVision.php:826 +#: includes/Classifai/Providers/Azure/ComputerVision.php:834 msgid "Tag taxonomy" msgstr "" -#: includes/Classifai/Providers/Azure/ComputerVision.php:838 +#: includes/Classifai/Providers/Azure/ComputerVision.php:846 msgid "Enable smart cropping" msgstr "" -#: includes/Classifai/Providers/Azure/ComputerVision.php:846 +#: includes/Classifai/Providers/Azure/ComputerVision.php:854 msgid "" "ComputerVision detects and saves the most visually interesting part of your " "image (i.e., faces, animals, notable text)." msgstr "" -#: includes/Classifai/Providers/Azure/ComputerVision.php:854 +#: includes/Classifai/Providers/Azure/ComputerVision.php:862 msgid "Scan images for text" msgstr "" -#: includes/Classifai/Providers/Azure/ComputerVision.php:862 +#: includes/Classifai/Providers/Azure/ComputerVision.php:870 msgid "" "OCR detects text in images (e.g., handwritten notes) and saves that as post " "content." msgstr "" -#: includes/Classifai/Providers/Azure/ComputerVision.php:870 +#: includes/Classifai/Providers/Azure/ComputerVision.php:878 msgid "Enable scanning PDF" msgstr "" -#: includes/Classifai/Providers/Azure/ComputerVision.php:878 +#: includes/Classifai/Providers/Azure/ComputerVision.php:886 msgid "" "Extract visible text from multi-pages PDF documents. Store the result as " "the attachment description." msgstr "" -#: includes/Classifai/Providers/Azure/ComputerVision.php:910 +#: includes/Classifai/Providers/Azure/ComputerVision.php:918 msgid "Please enter your credentials" msgstr "" -#: includes/Classifai/Providers/Azure/ComputerVision.php:1014 +#: includes/Classifai/Providers/Azure/ComputerVision.php:1022 msgid "Authenticated" msgstr "" -#: includes/Classifai/Providers/Azure/ComputerVision.php:1014 -#: includes/Classifai/Providers/Watson/NLU.php:700 +#: includes/Classifai/Providers/Azure/ComputerVision.php:1022 +#: includes/Classifai/Providers/Watson/NLU.php:735 #: includes/Classifai/Services/ServicesManager.php:354 msgid "yes" msgstr "" -#: includes/Classifai/Providers/Azure/ComputerVision.php:1014 -#: includes/Classifai/Providers/Watson/NLU.php:700 +#: includes/Classifai/Providers/Azure/ComputerVision.php:1022 +#: includes/Classifai/Providers/Watson/NLU.php:735 #: includes/Classifai/Services/ServicesManager.php:354 msgid "no" msgstr "" -#: includes/Classifai/Providers/Azure/ComputerVision.php:1015 -#: includes/Classifai/Providers/Watson/NLU.php:267 -#: includes/Classifai/Providers/Watson/NLU.php:701 +#: includes/Classifai/Providers/Azure/ComputerVision.php:1023 +#: includes/Classifai/Providers/Watson/NLU.php:302 +#: includes/Classifai/Providers/Watson/NLU.php:736 msgid "API URL" msgstr "" -#: includes/Classifai/Providers/Azure/ComputerVision.php:1016 +#: includes/Classifai/Providers/Azure/ComputerVision.php:1024 msgid "Caption threshold" msgstr "" -#: includes/Classifai/Providers/Azure/ComputerVision.php:1017 +#: includes/Classifai/Providers/Azure/ComputerVision.php:1025 msgid "Latest response - Image Scan" msgstr "" -#: includes/Classifai/Providers/Azure/ComputerVision.php:1018 +#: includes/Classifai/Providers/Azure/ComputerVision.php:1026 msgid "Latest response - Smart Cropping" msgstr "" -#: includes/Classifai/Providers/Azure/ComputerVision.php:1019 +#: includes/Classifai/Providers/Azure/ComputerVision.php:1027 msgid "Latest response - OCR" msgstr "" -#: includes/Classifai/Providers/Azure/ComputerVision.php:1032 -#: includes/Classifai/Providers/Watson/NLU.php:718 +#: includes/Classifai/Providers/Azure/ComputerVision.php:1040 +#: includes/Classifai/Providers/Watson/NLU.php:753 msgid "N/A" msgstr "" -#: includes/Classifai/Providers/Azure/ComputerVision.php:1104 +#: includes/Classifai/Providers/Azure/ComputerVision.php:1112 msgid "Valid image size not found. Make sure the image is less than 4MB." msgstr "" @@ -310,69 +336,77 @@ msgstr "" msgid "Please Choose" msgstr "" -#: includes/Classifai/Providers/Watson/NLU.php:41 +#: includes/Classifai/Providers/Watson/NLU.php:42 +#: includes/Classifai/Services/Service.php:142 msgid "Category" msgstr "" -#: includes/Classifai/Providers/Watson/NLU.php:42 +#: includes/Classifai/Providers/Watson/NLU.php:43 msgid "Category Threshold (%)" msgstr "" -#: includes/Classifai/Providers/Watson/NLU.php:43 +#: includes/Classifai/Providers/Watson/NLU.php:44 msgid "Category Taxonomy" msgstr "" -#: includes/Classifai/Providers/Watson/NLU.php:48 +#: includes/Classifai/Providers/Watson/NLU.php:49 +#: includes/Classifai/Services/Service.php:147 msgid "Keyword" msgstr "" -#: includes/Classifai/Providers/Watson/NLU.php:49 +#: includes/Classifai/Providers/Watson/NLU.php:50 msgid "Keyword Threshold (%)" msgstr "" -#: includes/Classifai/Providers/Watson/NLU.php:50 +#: includes/Classifai/Providers/Watson/NLU.php:51 msgid "Keyword Taxonomy" msgstr "" -#: includes/Classifai/Providers/Watson/NLU.php:55 +#: includes/Classifai/Providers/Watson/NLU.php:56 +#: includes/Classifai/Services/Service.php:152 msgid "Entity" msgstr "" -#: includes/Classifai/Providers/Watson/NLU.php:56 +#: includes/Classifai/Providers/Watson/NLU.php:57 msgid "Entity Threshold (%)" msgstr "" -#: includes/Classifai/Providers/Watson/NLU.php:57 +#: includes/Classifai/Providers/Watson/NLU.php:58 msgid "Entity Taxonomy" msgstr "" -#: includes/Classifai/Providers/Watson/NLU.php:62 +#: includes/Classifai/Providers/Watson/NLU.php:63 +#: includes/Classifai/Services/Service.php:157 msgid "Concept" msgstr "" -#: includes/Classifai/Providers/Watson/NLU.php:63 +#: includes/Classifai/Providers/Watson/NLU.php:64 msgid "Concept Threshold (%)" msgstr "" -#: includes/Classifai/Providers/Watson/NLU.php:64 +#: includes/Classifai/Providers/Watson/NLU.php:65 msgid "Concept Taxonomy" msgstr "" -#: includes/Classifai/Providers/Watson/NLU.php:199 +#: includes/Classifai/Providers/Watson/NLU.php:233 msgid "API Password" msgstr "" -#: includes/Classifai/Providers/Watson/NLU.php:201 -#: includes/Classifai/Providers/Watson/NLU.php:314 +#: includes/Classifai/Providers/Watson/NLU.php:235 +#: includes/Classifai/Providers/Watson/NLU.php:349 msgid "Use an API Key instead?" msgstr "" -#: includes/Classifai/Providers/Watson/NLU.php:202 -#: includes/Classifai/Providers/Watson/NLU.php:313 +#: includes/Classifai/Providers/Watson/NLU.php:236 +#: includes/Classifai/Providers/Watson/NLU.php:348 msgid "Use a username/password instead?" msgstr "" -#: includes/Classifai/Providers/Watson/NLU.php:218 +#: includes/Classifai/Providers/Watson/NLU.php:237 +msgid "Loading Preview" +msgstr "" + +#: includes/Classifai/Providers/Watson/NLU.php:253 msgid "" "Don't have an IBM Cloud account yet? Register for one and set up a here for details." msgstr "" -#: includes/Classifai/Providers/Watson/NLU.php:280 +#: includes/Classifai/Providers/Watson/NLU.php:315 msgid "API Username" msgstr "" -#: includes/Classifai/Providers/Watson/NLU.php:343 +#: includes/Classifai/Providers/Watson/NLU.php:378 msgid "Post Types to Classify" msgstr "" -#: includes/Classifai/Providers/Watson/NLU.php:354 +#: includes/Classifai/Providers/Watson/NLU.php:389 msgid "Post Statuses to Classify" msgstr "" -#: includes/Classifai/Providers/Watson/NLU.php:505 +#: includes/Classifai/Providers/Watson/NLU.php:540 msgid "Watson Category Settings" msgstr "" -#: includes/Classifai/Providers/Watson/NLU.php:510 +#: includes/Classifai/Providers/Watson/NLU.php:545 msgid "Enable" msgstr "" -#: includes/Classifai/Providers/Watson/NLU.php:614 +#: includes/Classifai/Providers/Watson/NLU.php:649 msgid "IBM Watson NLU Authentication Failed. Please check credentials." msgstr "" -#: includes/Classifai/Providers/Watson/NLU.php:700 +#: includes/Classifai/Providers/Watson/NLU.php:735 msgid "Configured" msgstr "" -#: includes/Classifai/Providers/Watson/NLU.php:702 +#: includes/Classifai/Providers/Watson/NLU.php:737 msgid "API username" msgstr "" -#: includes/Classifai/Providers/Watson/NLU.php:703 +#: includes/Classifai/Providers/Watson/NLU.php:738 msgid "Post types" msgstr "" -#: includes/Classifai/Providers/Watson/NLU.php:704 +#: includes/Classifai/Providers/Watson/NLU.php:739 msgid "Features" msgstr "" -#: includes/Classifai/Providers/Watson/NLU.php:705 +#: includes/Classifai/Providers/Watson/NLU.php:740 msgid "Latest response" msgstr "" +#: includes/Classifai/Providers/Watson/NLU.php:788 +msgid "ClassifAI Language Processing" +msgstr "" + +#: includes/Classifai/Providers/Watson/NLU.php:813 +msgid "Process content on update" +msgstr "" + #: includes/Classifai/Services/ImageProcessing.php:55 #: includes/Classifai/Services/ImageProcessing.php:74 msgid "Scan" @@ -469,6 +511,14 @@ msgstr "" msgid "Language Processing" msgstr "" +#: includes/Classifai/Services/Service.php:163 +msgid "Preview Language Processing" +msgstr "" + +#: includes/Classifai/Services/Service.php:172 +msgid "Preview" +msgstr "" + #: includes/Classifai/Services/ServicesManager.php:134 msgid "Invalid ClassifAI registration info. Please check and try again." msgstr "" diff --git a/readme.txt b/readme.txt index ac45004c1..5a94599d6 100644 --- a/readme.txt +++ b/readme.txt @@ -1,29 +1,29 @@ -=== ClassifAI === -Contributors: 10up -Tags: AI, Artifical Intelligence, ML, Machine Learning, Microsoft Azure, IBM Watson, Content Tagging, Classification, Smart Cropping, Alt Text -Requires at least: 5.0 -Tested up to: 6.0 -Requires PHP: 7.0 -Stable tag: 1.7.2 -License: GPLv2 or later -License URI: http://www.gnu.org/licenses/gpl-2.0.html - -Enhance your WordPress content with Artificial Intelligence and Machine Learning services. - -== Description == - -**Features** - -* Classify your content using [Microsoft Azure's Computer Vision API](https://azure.microsoft.com/en-us/services/cognitive-services/computer-vision/) and [IBM Watson's Natural Language Understanding API](https://www.ibm.com/watson/services/natural-language-understanding/) -* Supports Azure's [Describe Image](https://westus.dev.cognitive.microsoft.com/docs/services/5adf991815e1060e6355ad44/operations/56f91f2e778daf14a499e1fe) -* Supports Watson's [Categories](https://cloud.ibm.com/docs/natural-language-understanding?topic=natural-language-understanding-about#categories), [Keywords](https://cloud.ibm.com/docs/natural-language-understanding?topic=natural-language-understanding-about#keywords), [Concepts](https://cloud.ibm.com/docs/natural-language-understanding?topic=natural-language-understanding-about#concepts) & [Entities](https://cloud.ibm.com/docs/natural-language-understanding?topic=natural-language-understanding-about#entities) -* Automatically classify content and images on save -* Automatically generate alt text and image tags for images -* Automatically scan images and PDF files for embedded text and save for use in WordPress -* [Smartly crop images](https://docs.microsoft.com/en-us/rest/api/cognitiveservices/computervision/generatethumbnail) around a region of interest identified by Computer Vision -* Bulk classify content with [WP-CLI](https://wp-cli.org/) - -**Requirements** - -* To utilize the Language Processing functionality, you will need an active [IBM Watson](https://cloud.ibm.com/registration) account. -* To utilize the Image Processing functionality, you will need an active [Microsoft Azure](https://signup.azure.com/signup) account. +=== ClassifAI === +Contributors: 10up +Tags: AI, Artifical Intelligence, ML, Machine Learning, Microsoft Azure, IBM Watson, Content Tagging, Classification, Smart Cropping, Alt Text +Requires at least: 5.6 +Tested up to: 6.0 +Requires PHP: 7.0 +Stable tag: 1.7.3 +License: GPLv2 or later +License URI: http://www.gnu.org/licenses/gpl-2.0.html + +Enhance your WordPress content with Artificial Intelligence and Machine Learning services. + +== Description == + +**Features** + +* Classify your content using [Microsoft Azure's Computer Vision API](https://azure.microsoft.com/en-us/services/cognitive-services/computer-vision/) and [IBM Watson's Natural Language Understanding API](https://www.ibm.com/watson/services/natural-language-understanding/) +* Supports Azure's [Describe Image](https://westus.dev.cognitive.microsoft.com/docs/services/5adf991815e1060e6355ad44/operations/56f91f2e778daf14a499e1fe) +* Supports Watson's [Categories](https://cloud.ibm.com/docs/natural-language-understanding?topic=natural-language-understanding-about#categories), [Keywords](https://cloud.ibm.com/docs/natural-language-understanding?topic=natural-language-understanding-about#keywords), [Concepts](https://cloud.ibm.com/docs/natural-language-understanding?topic=natural-language-understanding-about#concepts) & [Entities](https://cloud.ibm.com/docs/natural-language-understanding?topic=natural-language-understanding-about#entities) +* Automatically classify content and images on save +* Automatically generate alt text and image tags for images +* Automatically scan images and PDF files for embedded text and save for use in WordPress +* [Smartly crop images](https://docs.microsoft.com/en-us/rest/api/cognitiveservices/computervision/generatethumbnail) around a region of interest identified by Computer Vision +* Bulk classify content with [WP-CLI](https://wp-cli.org/) + +**Requirements** + +* To utilize the Language Processing functionality, you will need an active [IBM Watson](https://cloud.ibm.com/registration) account. +* To utilize the Image Processing functionality, you will need an active [Microsoft Azure](https://signup.azure.com/signup) account.