window.quix=window.quix||{},function(){quix.shortcode={next:function(t,e,n){var s,r,i=quix.shortcode.regexp(t);if(i.lastIndex=n||0,s=i.exec(e))return"["===s[1]&&"]"===s[7]?quix.shortcode.next(t,e,i.lastIndex):(r={index:s.index,content:s[0],shortcode:quix.shortcode.fromMatch(s)},s[1]&&(r.content=r.content.slice(1),r.index++),s[7]&&(r.content=r.content.slice(0,-1)),r)},replace:function(t,e,n){return e.replace(quix.shortcode.regexp(t),function(t,e,s,r,i,o,c,u){if("["===e&&"]"===u)return t;var a=n(quix.shortcode.fromMatch(arguments));return a?e+a+u:t})},string:function(t){return new quix.shortcode(t).string()},regexp:_.memoize(function(t){return new RegExp("\\[(\\[?)("+t+")(?![\\w-])([^\\]\\/]*(?:\\/(?!\\])[^\\]\\/]*)*?)(?:(\\/)\\]|\\](?:([^\\[]*(?:\\[(?!\\/\\2\\])[^\\[]*)*)(\\[\\/\\2\\]))?)(\\]?)","g")}),attrs:_.memoize(function(t){var e,n,s={},r=[];for(e=/([\w-]+)\s*=\s*"([^"]*)"(?:\s|$)|([\w-]+)\s*=\s*'([^']*)'(?:\s|$)|([\w-]+)\s*=\s*([^\s'"]+)(?:\s|$)|"([^"]*)"(?:\s|$)|(\S+)(?:\s|$)/g,t=t.replace(/[\u00a0\u200b]/g," ");n=e.exec(t);)n[1]?s[n[1].toLowerCase()]=n[2]:n[3]?s[n[3].toLowerCase()]=n[4]:n[5]?s[n[5].toLowerCase()]=n[6]:n[7]?r.push(n[7]):n[8]&&r.push(n[8]);return{named:s,numeric:r}}),fromMatch:function(t){var e;return e=t[4]?"self-closing":t[6]?"closed":"single",new quix.shortcode({tag:t[2],attrs:t[3],type:e,content:t[5]})}},quix.shortcode=_.extend(function(t){_.extend(this,_.pick(t||{},"tag","attrs","type","content"));var e=this.attrs;this.attrs={named:{},numeric:[]},e&&(_.isString(e)?this.attrs=quix.shortcode.attrs(e):_.isEqual(_.keys(e),["named","numeric"])?this.attrs=e:_.each(t.attrs,function(t,e){this.set(e,t)},this))},quix.shortcode),_.extend(quix.shortcode.prototype,{get:function(t){return this.attrs[_.isNumber(t)?"numeric":"named"][t]},set:function(t,e){return this.attrs[_.isNumber(t)?"numeric":"named"][t]=e,this},string:function(){var t="["+this.tag;return _.each(this.attrs.numeric,function(e){t+=/\s/.test(e)?' "'+e+'"':" "+e}),_.each(this.attrs.named,function(e,n){t+=" "+n+'="'+e+'"'}),"single"===this.type?t+"]":"self-closing"===this.type?t+" /]":(t+="]",this.content&&(t+=this.content),t+"[/"+this.tag+"]")}})}(),function(){quix.html=_.extend(quix.html||{},{attrs:function(t){var e,n;return"/"===t[t.length-1]&&(t=t.slice(0,-1)),e=quix.shortcode.attrs(t),n=e.named,_.each(e.numeric,function(t){/\s/.test(t)||(n[t]="")}),n},string:function(t){var e="<"+t.tag,n=t.content||"";return _.each(t.attrs,function(t,n){e+=" "+n,""!==t&&(_.isBoolean(t)&&(t=t?"true":"false"),e+='="'+t+'"')}),t.single?e+" />":(e+=">",e+=_.isObject(n)?quix.html.string(n):n,e+"</"+t.tag+">")}})}();