!function(){var a={},b=function(b){for(var c=a[b],e=c.deps,f=c.defn,g=e.length,h=new Array(g),i=0;i"},i=function(a){var b='';return a.poster&&(b+=''),b+=""},j=function(a,b){return b?b(a):'"},k=function(a,b){return b?b(a):'"},l=function(a){return''},m=function(m,n){var o=a.extend({},n);if(!o.source1&&(a.extend(o,c.htmlToData(b.getScripts(m),o.embed)),!o.source1))return"";if(o.source2||(o.source2=""),o.poster||(o.poster=""),o.source1=m.convertURL(o.source1,"source"),o.source2=m.convertURL(o.source2,"source"),o.source1mime=d.guess(o.source1),o.source2mime=d.guess(o.source2),o.poster=m.convertURL(o.poster,"poster"),a.each(f.urlPatterns,function(a){var b,c,d=a.regex.exec(o.source1);if(d){for(c=a.url,b=0;d[b];b++)c=c.replace("$"+b,function(){return d[b]});o.source1=c,o.type=a.type,o.allowFullscreen=a.allowFullscreen,o.width=o.width||a.w,o.height=o.height||a.h}}),o.embed)return e.updateHtml(o.embed,o,!0);var p=g.getVideoScriptMatch(b.getScripts(m),o.source1);p&&(o.type="script",o.width=p.width,o.height=p.height);var q=b.getAudioTemplateCallback(m),r=b.getVideoTemplateCallback(m);return o.width=o.width||300,o.height=o.height||150,a.each(o,function(a,b){o[b]=m.dom.encode(a)}),"iframe"===o.type?h(o):"application/x-shockwave-flash"===o.source1mime?i(o):o.source1mime.indexOf("audio")!==-1?j(o,q):"script"===o.type?l(o):k(o,r)};return{dataToHtml:m}}),g("i",["q","g","r"],function(a,b,c){var d={},e=function(b,c,e){return new a(function(a,f){var g=function(e){return e.html&&(d[b.source1]=e),a({url:b.source1,html:e.html?e.html:c(b)})};d[b.source1]?g(d[b.source1]):e({url:b.source1},g,f)})},f=function(b,c){return new a(function(a){a({html:c(b),url:b.source1})})},g=function(a){return function(b){return c.dataToHtml(a,b)}},h=function(a,c){var d=b.getUrlResolver(a);return d?e(c,g(a),d):f(c,g(a))},i=function(a){return d.hasOwnProperty(a)};return{getEmbedHtml:h,isCached:i}}),g("o",[],function(){var a=function(a,b){a.state.set("oldVal",a.value()),b.state.set("oldVal",b.value())},b=function(a,b){var c=a.find("#width")[0],d=a.find("#height")[0],e=a.find("#constrain")[0];c&&d&&e&&b(c,d,e.checked())},c=function(b,c,d){var e=b.state.get("oldVal"),f=c.state.get("oldVal"),g=b.value(),h=c.value();d&&e&&f&&g&&h&&(g!==e?(h=Math.round(g/e*h),isNaN(h)||c.value(h)):(g=Math.round(h/f*g),isNaN(g)||b.value(g))),a(b,c)},d=function(c){b(c,a)},e=function(a){b(a,c)},f=function(a){var b=function(){a(function(a){e(a)})};return{type:"container",label:"Dimensions",layout:"flex",align:"center",spacing:5,items:[{name:"width",type:"textbox",maxLength:5,size:5,onchange:b,ariaLabel:"Width"},{type:"label",text:"x"},{name:"height",type:"textbox",maxLength:5,size:5,onchange:b,ariaLabel:"Height"},{name:"constrain",type:"checkbox",checked:!0,text:"Constrain proportions"}]}};return{createUi:f,syncSize:d,updateSize:e}}),g("9",["f","b","g","h","i","j","e","o"],function(a,b,c,d,e,f,g,h){var i=a.ie&&a.ie<=8?"onChange":"onInput",j=function(a){return function(b){var c=b&&b.msg?"Media embed handler error: "+b.msg:"Media embed handler threw unknown error.";a.notificationManager.open({type:"error",text:c})}},k=function(a){var b=a.selection.getNode(),e=b.getAttribute("data-ephox-embed-iri");return e?{source1:e,"data-ephox-embed-iri":e,width:f.getMaxWidth(b),height:f.getMaxHeight(b)}:b.getAttribute("data-mce-object")?d.htmlToData(c.getScripts(a),a.serializer.serialize(b,{selection:!0})):{}},l=function(a){var b=a.selection.getNode();if(b.getAttribute("data-mce-object")||b.getAttribute("data-ephox-embed-iri"))return a.selection.getContent()},m=function(a,e){return function(f){var g=f.html,i=a.find("#embed")[0],j=b.extend(d.htmlToData(c.getScripts(e),g),{source1:f.url});a.fromJSON(j),i&&(i.value(g),h.updateSize(a))}},n=function(a,b){var c,d,e=a.dom.select("img[data-mce-object]");for(c=0;c=0;d--)b[c]===e[d]&&e.splice(d,1);a.selection.select(e[0])},o=function(a,b){var c=a.dom.select("img[data-mce-object]");a.insertContent(b),n(a,c),a.nodeChanged()},p=function(a,b){var c=a.toJSON();c.embed=g.updateHtml(c.embed,c),c.embed&&e.isCached(c.source1)?o(b,c.embed):e.getEmbedHtml(b,c).then(function(a){o(b,a.html)})["catch"](j(b))},q=function(a,c){b.each(c,function(b,c){a.find("#"+c).value(b)})},r=function(a){var f,n,o=[{name:"source1",type:"filepicker",filetype:"media",size:40,autofocus:!0,label:"Source",onpaste:function(){setTimeout(function(){e.getEmbedHtml(a,f.toJSON()).then(m(f,a))["catch"](j(a))},1)},onchange:function(b){e.getEmbedHtml(a,f.toJSON()).then(m(f,a))["catch"](j(a)),q(f,b.meta)},onbeforecall:function(a){a.meta=f.toJSON()}}],r=[],s=function(a){a(f),n=f.toJSON(),f.find("#embed").value(g.updateHtml(n.embed,n))};if(c.hasAltSource(a)&&r.push({name:"source2",type:"filepicker",filetype:"media",size:40,label:"Alternative source"}),c.hasPoster(a)&&r.push({name:"poster",type:"filepicker",filetype:"image",size:40,label:"Poster"}),c.hasDimensions(a)){var t=h.createUi(s);o.push(t)}n=k(a);var u={id:"mcemediasource",type:"textbox",flex:1,name:"embed",value:l(a),multiline:!0,rows:5,label:"Source"},v=function(){n=b.extend({},d.htmlToData(c.getScripts(a),this.value())),this.parent().parent().fromJSON(n)};u[i]=v,f=a.windowManager.open({title:"Insert/edit media",data:n,bodyType:"tabpanel",body:[{title:"General",type:"form",items:o},{title:"Embed",type:"container",layout:"flex",direction:"column",align:"stretch",padding:10,spacing:10,items:[{type:"label",text:"Paste your embed code below:",forId:"mcemediasource"},u]},{title:"Advanced",type:"form",items:r}],onSubmit:function(){h.updateSize(f),p(f,a)}}),h.syncSize(f)};return{showDialog:r}}),g("2",["9"],function(a){var b=function(b){var c=function(){a.showDialog(b)};return{showDialog:c}};return{get:b}}),g("3",["9"],function(a){var b=function(b){var c=function(){a.showDialog(b)};b.addCommand("mceMedia",c)};return{register:b}}),g("a",["8"],function(a){return a("tinymce.html.Node")}),g("d",["l","m","k","b","g"],function(a,b,c,d,e){var f=function(d,f){if(e.shouldFilterHtml(d)===!1)return f;var g,h=new c;return new a({validate:!1,allow_conditional_comments:!1,special:"script,noscript",comment:function(a){h.comment(a)},cdata:function(a){h.cdata(a)},text:function(a,b){h.text(a,b)},start:function(a,b,c){if(g=!0,"script"!==a&&"noscript"!==a){for(var e=0;e]*>","gi")});var g=e.schema.getBoolAttrs();b.each("webkitallowfullscreen mozallowfullscreen allowfullscreen".split(" "),function(a){g[a]={}}),e.parser.addNodeFilter("iframe,video,audio,object,embed,script",c.placeHolderConverter(e)),e.serializer.addAttributeFilter("data-mce-object",function(b,c){for(var f,g,h,i,j,k,l,m,n=b.length;n--;)if(f=b[n],f.parent){for(l=f.attr(c),g=new a(l,1),"audio"!==l&&"script"!==l&&(m=f.attr("class"),m&&m.indexOf("mce-preview-object")!==-1?g.attr({width:f.firstChild.attr("width"),height:f.firstChild.attr("height")}):g.attr({width:f.attr("width"),height:f.attr("height")})),g.attr({style:f.attr("style")}),i=f.attributes,h=i.length;h--;){var o=i[h].name;0===o.indexOf("data-mce-p-")&&g.attr(o.substr(11),i[h].value)}"script"===l&&g.attr("type","text/javascript"),j=f.attr("data-mce-html"),j&&(k=new a("#text",3),k.raw=!0,k.value=d.sanitize(e,unescape(j)),g.append(k)),f.replace(g)}})}),e.on("setContent",function(){e.$("span.mce-preview-object").each(function(a,b){var c=e.$(b);0===c.find("span.mce-shim",b).length&&c.append('')})})};return{setup:e}}),g("5",[],function(){var a=function(a){a.on("ResolveName",function(a){var b;1===a.target.nodeType&&(b=a.target.getAttribute("data-mce-object"))&&(a.name=b)})};return{setup:a}}),g("6",["e"],function(a){var b=function(b){b.on("click keyup",function(){var a=b.selection.getNode();a&&b.dom.hasClass(a,"mce-preview-object")&&b.dom.getAttrib(a,"data-mce-selected")&&a.setAttribute("data-mce-selected","2")}),b.on("ObjectSelected",function(a){var b=a.target.getAttribute("data-mce-object");"audio"!==b&&"script"!==b||a.preventDefault()}),b.on("objectResized",function(b){var c,d=b.target;d.getAttribute("data-mce-object")&&(c=d.getAttribute("data-mce-html"),c&&(c=unescape(c),d.setAttribute("data-mce-html",escape(a.updateHtml(c,{width:b.width,height:b.height})))))})};return{setup:b}}),g("7",[],function(){var a=function(a){a.addButton("media",{tooltip:"Insert/edit media",cmd:"mceMedia",stateSelector:["img[data-mce-object]","span[data-mce-object]","div[data-ephox-embed-iri]"]}),a.addMenuItem("media",{icon:"media",text:"Media",cmd:"mceMedia",context:"insert",prependToContext:!0})};return{register:a}}),g("0",["1","2","3","4","5","6","7"],function(a,b,c,d,e,f,g){return a.add("media",function(a){return c.register(a),g.register(a),e.setup(a),d.setup(a),f.setup(a),b.get(a)}),function(){}}),d("0")()}();