this.wp=this.wp||{},this.wp.richText=function(e){var t={};function n(r){if(t[r])return t[r].exports;var a=t[r]={i:r,l:!1,exports:{}};return e[r].call(a.exports,a,a.exports,n),a.l=!0,a.exports}return 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 a in e)n.d(r,a,function(t){return e[t]}.bind(null,a));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=346)}({0:function(e,t){!function(){e.exports=this.wp.element}()},10:function(e,t,n){"use strict";function r(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}n.d(t,"a",(function(){return r}))},11:function(e,t,n){"use strict";function r(e,t){for(var n=0;n=0||(a[n]=e[n]);return a}(e,t);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);for(r=0;r=0||Object.prototype.propertyIsEnumerable.call(e,n)&&(a[n]=e[n])}return a}n.d(t,"a",(function(){return r}))},27:function(e,t){!function(){e.exports=this.wp.hooks}()},30:function(e,t,n){"use strict";function r(e){if(Symbol.iterator in Object(e)||"[object Arguments]"===Object.prototype.toString.call(e))return Array.from(e)}n.d(t,"a",(function(){return r}))},31:function(e,t,n){"use strict";function r(e){return(r="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function a(e){return(a="function"==typeof Symbol&&"symbol"===r(Symbol.iterator)?function(e){return r(e)}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":r(e)})(e)}n.d(t,"a",(function(){return a}))},346:function(e,t,n){"use strict";n.r(t);var r={};n.r(r),n.d(r,"getFormatTypes",(function(){return u})),n.d(r,"getFormatType",(function(){return f})),n.d(r,"getFormatTypeForBareElement",(function(){return d})),n.d(r,"getFormatTypeForClassName",(function(){return p}));var a={};n.r(a),n.d(a,"addFormatTypes",(function(){return h})),n.d(a,"removeFormatTypes",(function(){return m}));var o=n(4),i=n(7),c=n(2);var s=Object(o.combineReducers)({formatTypes:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=arguments.length>1?arguments[1]:void 0;switch(t.type){case"ADD_FORMAT_TYPES":return Object(i.a)({},e,Object(c.keyBy)(t.formatTypes,"name"));case"REMOVE_FORMAT_TYPES":return Object(c.omit)(e,t.names)}return e}}),l=n(36),u=Object(l.a)((function(e){return Object.values(e.formatTypes)}),(function(e){return[e.formatTypes]}));function f(e,t){return e.formatTypes[t]}function d(e,t){return Object(c.find)(u(e),(function(e){var n=e.className,r=e.tagName;return null===n&&t===r}))}function p(e,t){return Object(c.find)(u(e),(function(e){var n=e.className;return null!==n&&" ".concat(t," ").indexOf(" ".concat(n," "))>=0}))}function h(e){return{type:"ADD_FORMAT_TYPES",formatTypes:Object(c.castArray)(e)}}function m(e){return{type:"REMOVE_FORMAT_TYPES",names:Object(c.castArray)(e)}}Object(o.registerStore)("core/rich-text",{reducer:s,selectors:r,actions:a});var v=n(17);function b(e,t){if(e===t)return!0;if(!e||!t)return!1;if(e.type!==t.type)return!1;var n=e.attributes,r=t.attributes;if(n===r)return!0;if(!n||!r)return!1;var a=Object.keys(n),o=Object.keys(r);if(a.length!==o.length)return!1;for(var i=a.length,c=0;c2&&void 0!==arguments[2]?arguments[2]:e.start,r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:e.end,a=e.formats,o=e.activeFormats,s=a.slice();if(n===r){var l=Object(c.find)(s[n],{type:t.type});if(l){for(var u=s[n].indexOf(l);s[n]&&s[n][u]===l;)s[n]=y(s[n],u,t),n--;for(r++;s[r]&&s[r][u]===l;)s[r]=y(s[r],u,t),r++}}else{for(var f=1/0,d=n;d0&&void 0!==arguments[0]?arguments[0]:{},t=e.element,n=e.text,r=e.html,a=e.range,o=e.multilineTag,i=e.multilineWrapperTags,c=e.__unstableIsEditableTree;return"string"==typeof n&&n.length>0?{formats:Array(n.length),replacements:Array(n.length),text:n}:("string"==typeof r&&r.length>0&&(t=j(document,r)),"object"!==Object(T.a)(t)?{formats:[],replacements:[],text:""}:o?D({element:t,range:a,multilineTag:o,multilineWrapperTags:i,isEditableTree:c}):P({element:t,range:a,isEditableTree:c}))}function A(e,t,n,r){if(n){var a=t.parentNode,o=n.startContainer,i=n.startOffset,c=n.endContainer,s=n.endOffset,l=e.text.length;void 0!==r.start?e.start=l+r.start:t===o&&t.nodeType===w?e.start=l+i:a===o&&t===o.childNodes[i]?e.start=l:a===o&&t===o.childNodes[i-1]?e.start=l+r.text.length:t===o&&(e.start=l),void 0!==r.end?e.end=l+r.end:t===c&&t.nodeType===w?e.end=l+s:a===c&&t===c.childNodes[s-1]?e.end=l+r.text.length:a===c&&t===c.childNodes[s]?e.end=l:t===c&&(e.end=l+s)}}var k=new RegExp(_,"g");function R(e){return e.replace(/[\n\r\t]+/g," ").replace(k,"")}function P(e){var t=e.element,n=e.range,r=e.multilineTag,a=e.multilineWrapperTags,c=e.currentWrapperTags,s=void 0===c?[]:c,l=e.isEditableTree,u={formats:[],replacements:[],text:""};if(!t)return u;if(!t.hasChildNodes())return A(u,t,n,{formats:[],replacements:[],text:""}),u;for(var f=t.childNodes.length,d=function(e){var c=t.childNodes[e],f=c.nodeName.toLowerCase();if(c.nodeType===w){var d=R(c.nodeValue);return n=function(e,t,n){if(t){var r=t.startContainer,a=t.endContainer,o=t.startOffset,i=t.endOffset;return e===r&&(o=n(e.nodeValue.slice(0,o)).length),e===a&&(i=n(e.nodeValue.slice(0,i)).length),{startContainer:r,startOffset:o,endContainer:a,endOffset:i}}}(c,n,R),A(u,c,n,{text:d}),u.formats.length+=d.length,u.replacements.length+=d.length,u.text+=d,"continue"}if(c.nodeType!==F)return"continue";if(l&&(c.getAttribute("data-rich-text-placeholder")||"br"===f&&!c.getAttribute("data-rich-text-line-break")))return A(u,c,n,{formats:[],replacements:[],text:""}),"continue";if("br"===f)return A(u,c,n,{formats:[],replacements:[],text:""}),I(u,S({text:"\n"})),"continue";var p=u.formats[u.formats.length-1],h=p&&p[p.length-1],m=function(e){var t,n=e.type,r=e.attributes;if(r&&r.class&&(t=Object(o.select)("core/rich-text").getFormatTypeForClassName(r.class))&&(r.class=" ".concat(r.class," ").replace(" ".concat(t.className," ")," ").trim(),r.class||delete r.class),t||(t=Object(o.select)("core/rich-text").getFormatTypeForBareElement(n)),!t)return r?{type:n,attributes:r}:{type:n};if(t.__experimentalCreatePrepareEditableTree&&!t.__experimentalCreateOnChangeEditableValue)return null;if(!r)return{type:t.name};var a={},i={};for(var c in r){var s=N(t.attributes,c);s?a[s]=r[c]:i[c]=r[c]}return{type:t.name,attributes:a,unregisteredAttributes:i}}({type:f,attributes:L({element:c})}),g=b(m,h)?h:m;if(a&&-1!==a.indexOf(f)){var y=D({element:c,range:n,multilineTag:r,multilineWrapperTags:a,currentWrapperTags:[].concat(Object(v.a)(s),[g]),isEditableTree:l});return A(u,c,n,y),I(u,y),"continue"}var O=P({element:c,range:n,multilineTag:r,multilineWrapperTags:a,isEditableTree:l});A(u,c,n,O),g?0===O.text.length?g.attributes&&I(u,{formats:[,],replacements:[g],text:E}):I(u,Object(i.a)({},O,{formats:Array.from(O.formats,(function(e){return e?[g].concat(Object(v.a)(e)):[g]}))})):I(u,O)},p=0;p0)&&I(s,{formats:[,],replacements:i.length>0?[i]:[,],text:x}),A(s,f,n,d),I(s,d)}}return s}function L(e){var t=e.element;if(t.hasAttributes()){for(var n,r=t.attributes.length,a=0;a1&&void 0!==arguments[1]?arguments[1]:t;r--;)if(n[r]===x)return r}function U(e){var t=e.replacements[V(e,e.start)];return!t||t.length<1}function z(e,t,n){var r=e.replacements[V(e,e.start)];return r&&0!==r.length?r[r.length-1].type===t:t===n}function q(e){var t=e.start,n=e.end;if(void 0!==t&&void 0!==n)return t===n}function G(e){return 0===e.text.length}function Y(e){var t=e.text,n=e.start,r=e.end;return n===r&&(0===t.length||(0===n&&t.slice(0,1)===x||(n===t.length&&t.slice(-1)===x||t.slice(n-1,r+1)==="".concat(x).concat(x))))}function $(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"";return"string"==typeof t&&(t=S({text:t})),g(e.reduce((function(e,n){var r=n.formats,a=n.replacements,o=n.text;return{formats:e.formats.concat(t.formats,r),replacements:e.replacements.concat(t.replacements,a),text:e.text+t.text+o}})))}var X=n(0),Z=n(27),J=n(8);function Q(e,t){if("string"==typeof(t=Object(i.a)({name:e},t)).name)if(/^[a-z][a-z0-9-]*\/[a-z][a-z0-9-]*$/.test(t.name))if(Object(o.select)("core/rich-text").getFormatType(t.name))window.console.error('Format "'+t.name+'" is already registered.');else if("string"==typeof t.tagName&&""!==t.tagName)if("string"==typeof t.className&&""!==t.className||null===t.className)if(/^[_a-zA-Z]+[a-zA-Z0-9-]*$/.test(t.className)){if(null===t.className){var n=Object(o.select)("core/rich-text").getFormatTypeForBareElement(t.tagName);if(n)return void window.console.error('Format "'.concat(n.name,'" is already registered to handle bare tag name "').concat(t.tagName,'".'))}else{var r=Object(o.select)("core/rich-text").getFormatTypeForClassName(t.className);if(r)return void window.console.error('Format "'.concat(r.name,'" is already registered to handle class name "').concat(t.className,'".'))}if("title"in t&&""!==t.title)if("keywords"in t&&t.keywords.length>3)window.console.error('The format "'+t.name+'" can have a maximum of 3 keywords.');else{if("string"==typeof t.title)return Object(o.dispatch)("core/rich-text").addFormatTypes(t),t.__experimentalCreatePrepareEditableTree&&Object(Z.addFilter)("experimentalRichText",e,(function(n){var r="format_prepare_props_(".concat(e,")_"),a="format_on_change_props_(".concat(e,")_"),s=function(o){var c=Object(i.a)({},o),s=Object.keys(o).reduce((function(e,t){return t.startsWith(r)&&(e[t.slice(r.length)]=o[t]),t.startsWith(a)&&(e[t.slice(a.length)]=o[t]),e}),{}),l={richTextIdentifier:o.identifier,blockClientId:o.clientId};return t.__experimentalCreateOnChangeEditableValue?(c["format_value_functions_(".concat(e,")")]=t.__experimentalCreatePrepareEditableTree(s,l),c["format_on_change_functions_(".concat(e,")")]=t.__experimentalCreateOnChangeEditableValue(s,l)):c["format_prepare_functions_(".concat(e,")")]=t.__experimentalCreatePrepareEditableTree(s,l),Object(X.createElement)(n,c)},l=[];return t.__experimentalGetPropsForEditableTreePreparation&&l.push(Object(o.withSelect)((function(e,n){var a=n.clientId,o=n.identifier;return Object(c.mapKeys)(t.__experimentalGetPropsForEditableTreePreparation(e,{richTextIdentifier:o,blockClientId:a}),(function(e,t){return r+t}))}))),t.__experimentalGetPropsForEditableTreeChangeHandler&&l.push(Object(o.withDispatch)((function(e,n){var r=n.clientId,o=n.identifier;return Object(c.mapKeys)(t.__experimentalGetPropsForEditableTreeChangeHandler(e,{richTextIdentifier:o,blockClientId:r}),(function(e,t){return a+t}))}))),l.length?Object(J.compose)(l)(s):s})),t;window.console.error("Format titles must be strings.")}else window.console.error('The format "'+t.name+'" must have a title.')}else window.console.error("A class name must begin with a letter, followed by any number of hyphens, letters, or numbers.");else window.console.error("Format class names must be a string, or null to handle bare elements.");else window.console.error("Format tag names must be a string.");else window.console.error("Format names must contain a namespace prefix, include only lowercase alphanumeric characters or dashes, and start with a letter. Example: my-plugin/my-custom-format");else window.console.error("Format names must be strings.")}function ee(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:e.start,r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:e.end,a=e.formats,o=e.activeFormats,s=a.slice();if(n===r){var l=Object(c.find)(s[n],{type:t});if(l){for(;Object(c.find)(s[n],l);)te(s,n,t),n--;for(r++;Object(c.find)(s[r],l);)te(s,r,t),r++}}else for(var u=n;u2&&void 0!==arguments[2]?arguments[2]:e.start,r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:e.end,a=e.formats,o=e.replacements,i=e.text;"string"==typeof t&&(t=S({text:t}));var c=n+t.text.length;return g({formats:a.slice(0,n).concat(t.formats,a.slice(r)),replacements:o.slice(0,n).concat(t.replacements,o.slice(r)),text:i.slice(0,n)+t.text+i.slice(r),start:c,end:c})}function re(e,t,n){return ne(e,S(),t,n)}function ae(e,t,n){var r=e.formats,a=e.replacements,o=e.text,i=e.start,c=e.end;return o=o.replace(t,(function(e){for(var t=arguments.length,o=new Array(t>1?t-1:0),s=1;s1&&void 0!==arguments[1]?arguments[1]:e.start,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:e.end,r=B(e).slice(0,t).lastIndexOf(x),a=e.replacements[r],o=[,];return a&&(o=[a]),ne(e,{formats:[,],replacements:o,text:x},t,n)}function ie(e){var t=!(arguments.length>1&&void 0!==arguments[1])||arguments[1],n=e.replacements,r=e.text,a=e.start,o=e.end,c=q(e),s=a-1,l=c?a-1:a,u=o;if(t||(s=o,l=a,u=c?o+1:o),r[s]===x){var f;if(c&&n[s]&&n[s].length){var d=n.slice();d[s]=n[s].slice(0,-1),f=Object(i.a)({},e,{replacements:d})}else f=re(e,l,u);return f}}var ce="";function se(e,t,n,r){return ne(e,{formats:[,],replacements:[t],text:ce},n,r)}function le(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:e.start,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:e.end,r=e.formats,a=e.replacements,o=e.text;return void 0===t||void 0===n?Object(i.a)({},e):{formats:r.slice(t,n),replacements:a.slice(t,n),text:o.slice(t,n)}}function ue(e,t){var n=e.formats,r=e.replacements,a=e.text,o=e.start,i=e.end;if("string"!=typeof t)return fe.apply(void 0,arguments);var c=0;return a.split(t).map((function(e){var a=c,s={formats:n.slice(a,a+e.length),replacements:r.slice(a,a+e.length),text:e};return c+=t.length+e.length,void 0!==o&&void 0!==i&&(o>=a&&oa&&(s.start=0),i>=a&&ic&&(s.end=e.length)),s}))}function fe(e){var t=e.formats,n=e.replacements,r=e.text,a=e.start,o=e.end,i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:a,c=arguments.length>2&&void 0!==arguments[2]?arguments[2]:o,s={formats:t.slice(0,i),replacements:n.slice(0,i),text:r.slice(0,i)},l={formats:t.slice(c),replacements:n.slice(c),text:r.slice(c),start:0,end:0};return[ae(s,/\u2028+$/,""),ae(l,/^\u2028+/,"")]}function de(e){var t=e.type,n=e.attributes,r=e.unregisteredAttributes,a=e.object,c=e.boundaryClass,s=function(e){return Object(o.select)("core/rich-text").getFormatType(e)}(t),l={};if(c&&(l["data-rich-text-format-boundary"]="true"),!s)return n&&(l=Object(i.a)({},n,l)),{type:t,attributes:l,object:a};for(var u in l=Object(i.a)({},r,l),n){var f=!!s.attributes&&s.attributes[u];f?l[f]=n[u]:l[u]=n[u]}return s.className&&(l.class?l.class="".concat(s.className," ").concat(l.class):l.class=s.className),{type:s.tagName,object:s.object,attributes:l}}function pe(e){var t,n,r,a=e.value,o=e.multilineTag,c=e.createEmpty,s=e.append,l=e.getLastChild,u=e.getParent,f=e.isText,d=e.getText,p=e.remove,h=e.appendText,m=e.onStartIndex,b=e.onEndIndex,g=e.isEditableTree,y=e.placeholder,O=a.formats,T=a.replacements,j=a.text,C=a.start,w=a.end,F=O.length+1,N=c(),S={type:o},A=H(a),k=A[A.length-1];o?(s(s(N,{type:o}),""),n=t=[S]):s(N,"");for(var R=function(e){var a=j.charAt(e),c=g&&(!r||r===x||"\n"===r),F=O[e];o&&(F=a===x?t=(T[e]||[]).reduce((function(e,t){return e.push(t,S),e}),[S]):[].concat(Object(v.a)(t),Object(v.a)(F||[])));var A=l(N);if(c&&a===x){for(var R=A;!f(R);)R=l(R);s(u(R),_)}if(r===x){for(var P=A;!f(P);)P=l(P);m&&C===e&&m(N,P),b&&w===e&&b(N,P)}if(F&&F.forEach((function(e,t){if(!A||!n||e!==n[t]||a===x&&F.length-1===t){var r=e.type,o=e.attributes,i=e.unregisteredAttributes,c=g&&a!==x&&e===k,h=u(A),m=s(h,de({type:r,attributes:o,unregisteredAttributes:i,boundaryClass:c}));f(A)&&0===d(A).length&&p(A),A=s(m,"")}else A=l(A)})),a===x)return n=F,r=a,"continue";0===e&&(m&&0===C&&m(N,A),b&&0===w&&b(N,A)),a===E?(A=s(u(A),de(Object(i.a)({},T[e],{object:!0}))),A=s(u(A),"")):"\n"===a?(A=s(u(A),{type:"br",attributes:g?{"data-rich-text-line-break":"true"}:void 0,object:!0}),A=s(u(A),"")):f(A)?h(A,a):A=s(u(A),a),m&&C===e+1&&m(N,A),b&&w===e+1&&b(N,A),c&&e===j.length&&(s(u(A),_),y&&0===j.length&&s(u(A),{type:"span",attributes:{"data-rich-text-placeholder":y,contenteditable:"false"}})),n=F,r=a},P=0;P1;)e=e.childNodes[t.shift()];return{node:e,offset:t[0]}}var be=function(){return j(document,"")};function ge(e,t){"string"==typeof t&&(t=e.ownerDocument.createTextNode(t));var n=t,r=n.type,a=n.attributes;if(r)for(var o in t=e.ownerDocument.createElement(r),a)t.setAttribute(o,a[o]);return e.appendChild(t)}function ye(e,t){e.appendData(t)}function Oe(e){return e.lastChild}function Te(e){return e.parentNode}function je(e){return e.nodeType===he}function xe(e){return e.nodeValue}function Ee(e){return e.parentNode.removeChild(e)}function _e(e){var t=e.value,n=e.multilineTag,r=e.prepareEditableTree,a=e.isEditableTree,o=void 0===a||a,c=e.placeholder,s=[],l=[];return r&&(t=Object(i.a)({},t,{formats:r(t)})),{body:pe({value:t,multilineTag:n,createEmpty:be,append:ge,getLastChild:Oe,getParent:Te,isText:je,getText:xe,remove:Ee,appendText:ye,onStartIndex:function(e,t){s=me(t,e,[t.nodeValue.length])},onEndIndex:function(e,t){l=me(t,e,[t.nodeValue.length])},isEditableTree:o,placeholder:c}),selection:{startPath:s,endPath:l}}}function Ce(e){var t=e.value,n=e.current,r=e.multilineTag,a=e.prepareEditableTree,o=e.__unstableDomOnly,i=_e({value:t,multilineTag:r,prepareEditableTree:a,placeholder:e.placeholder}),c=i.body,s=i.selection;!function e(t,n){var r=0;var a;for(;a=t.firstChild;){var o=n.childNodes[r];if(o)if(o.isEqualNode(a))t.removeChild(a);else if(o.nodeName!==a.nodeName||o.nodeType===he&&o.data!==a.data)n.replaceChild(a,o);else{var i=o.attributes,c=a.attributes;if(i)for(var s=i.length;s--;){var l=i[s].name;a.getAttribute(l)||o.removeAttribute(l)}if(c)for(var u=0;u0){if(p=d,h=u.getRangeAt(0),p.startContainer===h.startContainer&&p.startOffset===h.startOffset&&p.endContainer===h.endContainer&&p.endOffset===h.endOffset)return;u.removeAllRanges()}var p,h;u.addRange(d)}(s,n)}var we=n(71);function Fe(e){return Ie(pe({value:e.value,multilineTag:e.multilineTag,createEmpty:Ne,append:Ae,getLastChild:Se,getParent:Re,isText:Pe,getText:De,remove:Le,appendText:ke}).children)}function Ne(){return{}}function Se(e){var t=e.children;return t&&t[t.length-1]}function Ae(e,t){return"string"==typeof t&&(t={text:t}),t.parent=e,e.children=e.children||[],e.children.push(t),t}function ke(e,t){e.text+=t}function Re(e){return e.parent}function Pe(e){return"string"==typeof e.text}function De(e){return e.text}function Le(e){var t=e.parent.children.indexOf(e);return-1!==t&&e.parent.children.splice(t,1),e}function Ie(){return(arguments.length>0&&void 0!==arguments[0]?arguments[0]:[]).map((function(e){return void 0===e.text?function(e){var t=e.type,n=e.attributes,r=e.object,a=e.children,o="";for(var i in n)Object(we.isValidAttributeName)(i)&&(o+=" ".concat(i,'="').concat(Object(we.escapeAttribute)(n[i]),'"'));return r?"<".concat(t).concat(o,">"):"<".concat(t).concat(o,">").concat(Ie(a),"")}(e):Object(we.escapeHTML)(e.text)})).join("")}function Me(e,t){return W(e,t.type)?ee(e,t.type):O(e,t)}function He(e){var t=Object(o.select)("core/rich-text").getFormatType(e);if(t)return t.__experimentalCreatePrepareEditableTree&&Object(Z.removeFilter)("experimentalRichText",e),Object(o.dispatch)("core/rich-text").removeFormatTypes(e),t;window.console.error("Format ".concat(e," is not registered."))}function We(e,t){var n=V(e);if(void 0===n)return e;var r=e.text,a=e.replacements,o=e.end,c=V(e,n),s=a[n]||[],l=a[c]||[];if(s.length>l.length)return e;for(var u=a.slice(),f=function(e,t){for(var n=e.text,r=e.replacements,a=r[t]||[],o=t;o-- >=0;)if(n[o]===x){var i=r[o]||[];if(i.length===a.length+1)return o;if(i.length<=a.length)return}}(e,n),d=n;d=0;){if(n[o]===x)if((r[o]||[]).length===a.length-1)return o}}function Be(e){var t=e.text,n=e.replacements,r=e.start,a=e.end,o=V(e,r);if(void 0===n[o])return e;for(var c=n.slice(0),s=n[Ke(e,o)]||[],l=function(e,t){for(var n=e.text,r=e.replacements,a=r[t]||[],o=t,i=t||0;i=a.length))return o;o=i}return o}(e,V(e,a)),u=o;u<=l;u++)if(t[u]===x){var f=c[u]||[];c[u]=s.concat(f.slice(s.length+1)),0===c[u].length&&delete c[u]}return Object(i.a)({},e,{replacements:c})}function Ve(e,t){for(var n,r=e.text,a=e.replacements,o=e.start,c=e.end,s=V(e,o),l=a[s]||[],u=a[V(e,c)]||[],f=Ke(e,s),d=a.slice(),p=l.length-1,h=u.length-1,m=f+1||0;mh?e:t})))}return n?Object(i.a)({},e,{replacements:d}):e}var Ue=n(18),ze=n(12),qe=n(11),Ge=n(13),Ye=n(14),$e=n(5),Xe=n(15),Ze=n(16),Je=n.n(Ze),Qe=n(19),et=n(41),tt=n.n(et),nt=n(37),rt=n.n(nt),at=new Set(["a","audio","button","details","embed","iframe","input","label","select","textarea","video"]),ot=Object(o.withSelect)((function(e){return{formatTypes:e("core/rich-text").getFormatTypes()}}))((function(e){var t=e.formatTypes,n=e.onChange,r=e.value,a=e.allowedFormats,o=e.withoutInteractiveFormatting;return t.map((function(e){var t=e.name,i=e.edit,c=e.tagName;if(!i)return null;if(a&&-1===a.indexOf(t))return null;if(o&&at.has(c))return null;var s=W(r,t),l=void 0!==s,u=K(r),f=void 0!==u&&u.type===t;return Object(X.createElement)(i,{key:t,isActive:l,activeAttributes:l&&s.attributes||{},isObjectActive:f,activeObjectAttributes:f&&u.attributes||{},value:r,onChange:n})}))})),it=n(21),ct=function(e){return Object(c.pickBy)(e,(function(e,t){return n=t,Object(c.startsWith)(n,"aria-")&&!Object(c.isNil)(e);var n}))},st=function(e){function t(){var e;return Object(ze.a)(this,t),(e=Object(Ge.a)(this,Object(Ye.a)(t).call(this))).bindEditorNode=e.bindEditorNode.bind(Object($e.a)(e)),e}return Object(Xe.a)(t,e),Object(qe.a)(t,[{key:"shouldComponentUpdate",value:function(e){var t=this;Object(c.isEqual)(this.props.style,e.style)||(this.editorNode.setAttribute("style",""),Object.assign(this.editorNode.style,Object(i.a)({},e.style||{},{whiteSpace:"pre-wrap"}))),Object(c.isEqual)(this.props.className,e.className)||(this.editorNode.className=e.className),this.props.start!==e.start&&this.editorNode.setAttribute("start",e.start),this.props.reversed!==e.reversed&&(this.editorNode.reversed=e.reversed);var n=function(e,t){var n=Object(c.keys)(ct(e)),r=Object(c.keys)(ct(t));return{removedKeys:Object(c.difference)(n,r),updatedKeys:r.filter((function(n){return!Object(c.isEqual)(e[n],t[n])}))}}(this.props,e),r=n.removedKeys,a=n.updatedKeys;return r.forEach((function(e){return t.editorNode.removeAttribute(e)})),a.forEach((function(n){return t.editorNode.setAttribute(n,e[n])})),!1}},{key:"bindEditorNode",value:function(e){this.editorNode=e,this.props.setRef(e)}},{key:"render",value:function(){var e=this.props,t=e.tagName,n=void 0===t?"div":t,r=e.style,a=void 0===r?{}:r,o=e.record,c=e.valueToEditableHTML,s=e.className,l=Object(it.a)(e,["tagName","style","record","valueToEditableHTML","className"]);delete l.setRef;return Object(X.createElement)(n,Object(i.a)({role:"textbox","aria-multiline":!0,className:s,contentEditable:!0,ref:this.bindEditorNode,style:Object(i.a)({},a,{whiteSpace:"pre-wrap"}),suppressContentEditableWarning:!0,dangerouslySetInnerHTML:{__html:c(o)}},l))}}]),t}(X.Component);var lt=window,ut=lt.getSelection,ft=lt.getComputedStyle,dt=new Set(["insertParagraph","insertOrderedList","insertUnorderedList","insertHorizontalRule","insertLink"]),pt=document.createElement("style");function ht(e,t){var n=Object.keys(e).reduce((function(n,r){return r.startsWith(t)&&n.push(e[r]),n}),[]);return function(e){return n.reduce((function(t,n){return n(t,e.text)}),e.formats)}}document.head.appendChild(pt);var mt=function(e){function t(e){var n,r=e.value,a=e.selectionStart,o=e.selectionEnd;return Object(ze.a)(this,t),(n=Object(Ge.a)(this,Object(Ye.a)(t).apply(this,arguments))).onFocus=n.onFocus.bind(Object($e.a)(n)),n.onBlur=n.onBlur.bind(Object($e.a)(n)),n.onChange=n.onChange.bind(Object($e.a)(n)),n.handleDelete=n.handleDelete.bind(Object($e.a)(n)),n.handleEnter=n.handleEnter.bind(Object($e.a)(n)),n.handleSpace=n.handleSpace.bind(Object($e.a)(n)),n.handleHorizontalNavigation=n.handleHorizontalNavigation.bind(Object($e.a)(n)),n.onPaste=n.onPaste.bind(Object($e.a)(n)),n.onCreateUndoLevel=n.onCreateUndoLevel.bind(Object($e.a)(n)),n.onInput=n.onInput.bind(Object($e.a)(n)),n.onCompositionEnd=n.onCompositionEnd.bind(Object($e.a)(n)),n.onSelectionChange=n.onSelectionChange.bind(Object($e.a)(n)),n.createRecord=n.createRecord.bind(Object($e.a)(n)),n.applyRecord=n.applyRecord.bind(Object($e.a)(n)),n.valueToFormat=n.valueToFormat.bind(Object($e.a)(n)),n.setRef=n.setRef.bind(Object($e.a)(n)),n.valueToEditableHTML=n.valueToEditableHTML.bind(Object($e.a)(n)),n.onPointerDown=n.onPointerDown.bind(Object($e.a)(n)),n.formatToValue=n.formatToValue.bind(Object($e.a)(n)),n.Editable=n.Editable.bind(Object($e.a)(n)),n.onKeyDown=function(e){e.defaultPrevented||(n.handleDelete(e),n.handleEnter(e),n.handleSpace(e),n.handleHorizontalNavigation(e))},n.state={},n.lastHistoryValue=r,n.value=r,n.record=n.formatToValue(r),n.record.start=a,n.record.end=o,n}return Object(Xe.a)(t,e),Object(qe.a)(t,[{key:"componentWillUnmount",value:function(){document.removeEventListener("selectionchange",this.onSelectionChange),window.cancelAnimationFrame(this.rafId)}},{key:"setRef",value:function(e){e?this.editableRef=e:delete this.editableRef}},{key:"createRecord",value:function(){var e=this.props.__unstableMultilineTag,t=ut(),n=t.rangeCount>0?t.getRangeAt(0):null;return S({element:this.editableRef,range:n,multilineTag:e,multilineWrapperTags:"li"===e?["ul","ol"]:void 0,__unstableIsEditableTree:!0})}},{key:"applyRecord",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=t.domOnly,r=this.props.__unstableMultilineTag;Ce({value:e,current:this.editableRef,multilineTag:r,multilineWrapperTags:"li"===r?["ul","ol"]:void 0,prepareEditableTree:ht(this.props,"format_prepare_functions"),__unstableDomOnly:n,placeholder:this.props.placeholder})}},{key:"onPaste",value:function(e){var t=this.props,n=t.formatTypes,r=t.onPaste,a=e.clipboardData,o=a.items,i=a.files;o=Object(c.isNil)(o)?[]:o,i=Object(c.isNil)(i)?[]:i;var s="",l="";try{s=a.getData("text/plain"),l=a.getData("text/html")}catch(e){try{l=a.getData("Text")}catch(e){return}}e.preventDefault(),window.console.log("Received HTML:\n\n",l),window.console.log("Received plain text:\n\n",s);var u=this.record,f=n.reduce((function(e,t){var n=t.__unstablePasteRule;return n&&e===u&&(e=n(u,{html:l,plainText:s})),e}),u);if(f===u){if(r){var d=Object(c.find)([].concat(Object(v.a)(o),Object(v.a)(i)),(function(e){var t=e.type;return/^image\/(?:jpe?g|png|gif)$/.test(t)}));r({value:this.removeEditorOnlyFormats(u),onChange:this.onChange,html:l,plainText:s,image:d})}}else this.onChange(f)}},{key:"onFocus",value:function(){var e=this.props.unstableOnFocus;e&&e(),this.recalculateBoundaryStyle();this.record=Object(i.a)({},this.record,{start:void 0,end:void 0,activeFormats:void 0}),this.props.onSelectionChange(void 0,void 0),this.setState({activeFormats:void 0}),this.rafId=window.requestAnimationFrame(this.onSelectionChange),document.addEventListener("selectionchange",this.onSelectionChange),this.props.setFocusedElement&&(rt()("wp.blockEditor.RichText setFocusedElement prop",{alternative:"selection state from the block editor store."}),this.props.setFocusedElement(this.props.instanceId))}},{key:"onBlur",value:function(){document.removeEventListener("selectionchange",this.onSelectionChange)}},{key:"onInput",value:function(e){var t;if(e&&e.nativeEvent&&e.nativeEvent.isComposing)document.removeEventListener("selectionchange",this.onSelectionChange);else if(e&&(t=e.inputType),t||(t=e.nativeEvent.inputType),!t||0!==t.indexOf("format")&&!dt.has(t)){var n=this.createRecord(),r=this.record,a=r.start,o=r.activeFormats,c=void 0===o?[]:o,s=function(e){var t=e.value,n=e.start,r=e.end,a=e.formats,o=t.formats[n-1]||[],i=t.formats[r]||[];for(t.activeFormats=a.map((function(e,t){if(o[t]){if(b(e,o[t]))return o[t]}else if(i[t]&&b(e,i[t]))return i[t];return e}));--r>=n;)t.activeFormats.length>0?t.formats[r]=t.activeFormats:delete t.formats[r];return t}({value:n,start:a,end:n.start,formats:c});this.onChange(s,{withoutHistory:!0});var l=this.props,u=l.__unstableInputRule,f=l.__unstableMarkAutomaticChange,d=l.formatTypes,p=l.setTimeout;if((0,l.clearTimeout)(this.onInput.timeout),this.onInput.timeout=p(this.onCreateUndoLevel,1e3),"insertText"===t){u&&u(s,this.valueToFormat);var h=d.reduce((function(e,t){var n=t.__unstableInputRule;return n&&(e=n(e)),e}),s);h!==s&&(this.onCreateUndoLevel(),this.onChange(Object(i.a)({},h,{activeFormats:c})),f())}}else this.applyRecord(this.record)}},{key:"onCompositionEnd",value:function(){this.onInput({inputType:"insertText"}),document.addEventListener("selectionchange",this.onSelectionChange)}},{key:"onSelectionChange",value:function(e){if(("selectionchange"===e.type||this.props.__unstableIsSelected)&&(!e.nativeEvent||!e.nativeEvent.isComposing)){var t=this.createRecord(),n=t.start,r=t.end,a=t.text,o=this.record;if(a===o.text)if(n!==o.start||r!==o.end){var c=this.props,s=c.__unstableIsCaretWithinFormattedText,l=c.__unstableOnEnterFormattedText,u=c.__unstableOnExitFormattedText,f=Object(i.a)({},o,{start:n,end:r,activeFormats:void 0}),d=H(f);f.activeFormats=d,!s&&d.length?l():s&&!d.length&&u(),this.record=f,this.applyRecord(f,{domOnly:!0}),this.props.onSelectionChange(n,r),this.setState({activeFormats:d}),d.length>0&&this.recalculateBoundaryStyle()}else 0===o.text.length&&0===n&&function(){var e=window.getSelection(),t=e.anchorNode,n=e.anchorOffset;if(t.nodeType===t.ELEMENT_NODE){var r=t.childNodes[n];r&&r.nodeType===r.ELEMENT_NODE&&r.getAttribute("data-rich-text-placeholder")&&e.collapseToStart()}}();else this.onInput()}}},{key:"recalculateBoundaryStyle",value:function(){var e=this.editableRef.querySelector("*[data-rich-text-format-boundary]");if(e){var t=ft(e).color.replace(")",", 0.2)").replace("rgb","rgba"),n=".rich-text:focus ".concat("*[data-rich-text-format-boundary]"),r="background-color: ".concat(t);pt.innerHTML="".concat(n," {").concat(r,"}")}}},{key:"onChange",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=t.withoutHistory;this.applyRecord(e);var r=e.start,a=e.end,o=e.activeFormats,i=void 0===o?[]:o,s=Object(c.pickBy)(this.props,(function(e,t){return t.startsWith("format_on_change_functions_")}));Object.values(s).forEach((function(t){t(e.formats,e.text)})),this.value=this.valueToFormat(e),this.record=e,this.props.onChange(this.value),this.props.onSelectionChange(r,a),this.setState({activeFormats:i}),n||this.onCreateUndoLevel()}},{key:"onCreateUndoLevel",value:function(){this.lastHistoryValue!==this.value&&(this.props.__unstableOnCreateUndoLevel(),this.lastHistoryValue=this.value)}},{key:"handleDelete",value:function(e){var t=e.keyCode;if(t===Qe.DELETE||t===Qe.BACKSPACE||t===Qe.ESCAPE){if(this.props.__unstableDidAutomaticChange)return e.preventDefault(),void this.props.__unstableUndo();if(t!==Qe.ESCAPE){var n=this.props,r=n.onDelete,a=n.__unstableMultilineTag,o=this.state.activeFormats,i=void 0===o?[]:o,c=this.createRecord(),s=c.start,l=c.end,u=c.text,f=t===Qe.BACKSPACE;if(a){var d=ie(c,f);d&&(this.onChange(d),e.preventDefault())}if(0===s&&0!==l&&l===u.length)return this.onChange(re(c)),void e.preventDefault();!r||!q(c)||i.length||f&&0!==s||!f&&l!==u.length||(r({isReverse:f,value:c}),e.preventDefault())}}}},{key:"handleEnter",value:function(e){if(e.keyCode===Qe.ENTER){e.preventDefault();var t=this.props.onEnter;t&&t({value:this.removeEditorOnlyFormats(this.createRecord()),onChange:this.onChange,shiftKey:e.shiftKey})}}},{key:"handleSpace",value:function(e){var t=e.keyCode,n=e.shiftKey,r=e.altKey,a=e.metaKey,o=e.ctrlKey,i=this.props,c=i.tagName,s=i.__unstableMultilineTag;if(!(n||r||a||o||t!==Qe.SPACE||"li"!==s)){var l=this.createRecord();if(q(l)){var u=l.text[l.start-1];u&&u!==x||(this.onChange(We(l,{type:c})),e.preventDefault())}}}},{key:"handleHorizontalNavigation",value:function(e){var t=this,n=e.keyCode,r=e.shiftKey,a=e.altKey,o=e.metaKey,c=e.ctrlKey;if(!(r||a||o||c||n!==Qe.LEFT&&n!==Qe.RIGHT)){var s=this.record,l=s.text,u=s.formats,f=s.start,d=s.end,p=s.activeFormats,h=void 0===p?[]:p,m=q(s),v="rtl"===ft(this.editableRef).direction?Qe.RIGHT:Qe.LEFT,b=e.keyCode===v;if(m&&0===h.length){if(0===f&&b)return;if(d===l.length&&!b)return}if(m){e.preventDefault();var g=u[f-1]||[],y=u[f]||[],O=h.length,T=y;if(g.length>y.length&&(T=g),g.lengthg.length&&O--):g.length>y.length&&(!b&&h.length>y.length&&O--,b&&h.length