!function(g){varr=wp.i18n.__,d=window.imageEdit={iasapi:{},hold:{},postid:"",_view:!1,handleCropToolClick:function(i,t,e){vara=g("#image-preview-"+i),o=this.iasapi.getSelection();isNaN(o.x1)&&(this.setCropSelection(i,{x1:0,y1:0,x2:a.innerWidth(),y2:a.innerHeight(),width:a.innerWidth(),height:a.innerHeight()}),o=this.iasapi.getSelection()),0===o.x1&&0===o.y1&&0===o.x2&&0===o.y2?(this.iasapi.setSelection(0,0,a.innerWidth(),a.innerHeight(),!0),this.iasapi.setOptions({show:!0}),this.iasapi.update()):d.crop(i,t,e)},intval:function(i){return0|i},setDisabled:function(i,t){t?i.removeClass("disabled").prop("disabled",!1):i.addClass("disabled").prop("disabled",!0)},init:function(i){vart=this,e=g("#image-editor-"+t.postid),a=t.intval(g("#imgedit-x-"+i).val()),o=t.intval(g("#imgedit-y-"+i).val());t.postid!==i&&e.length&&t.close(t.postid),t.hold.w=t.hold.ow=a,t.hold.h=t.hold.oh=o,t.hold.xy_ratio=a/o,t.hold.sizer=parseFloat(g("#imgedit-sizer-"+i).val()),t.postid=i,g("#imgedit-response-"+i).empty(),g("#imgedit-panel-"+i).on("keypress",'input[type="text"]',function(i){vart=i.keyCode;if(36<t&&t<41&&g(this).trigger("blur"),13===t)returni.preventDefault(),i.stopPropagation(),!1}),g(document).on("image-editor-ui-ready",this.focusManager)},toggleEditor:function(i,t,e){i=g("#imgedit-wait-"+i);t?i.fadeIn("fast"):i.fadeOut("fast",function(){e&&g(document).trigger("image-editor-ui-ready")})},toggleHelp:function(i){i=g(i);returni.attr("aria-expanded","false"===i.attr("aria-expanded")?"true":"false").parents(".imgedit-group-top").toggleClass("imgedit-help-toggled").find(".imgedit-help").slideToggle("fast"),!1},getTarget:function(i){returng('input[name="imgedit-target-'+i+'"]:checked',"#imgedit-save-target-"+i).val()||"full"},scaleChanged:function(i,t,e){vara=g("#imgedit-scale-width-"+i),o=g("#imgedit-scale-height-"+i),i=g("#imgedit-scale-warn-"+i),s="",n="";!1!==this.validateNumeric(e)&&(t?(n=""!==a.val()?Math.round(a.val()/this.hold.xy_ratio):"",o.val(n)):(s=""!==o.val()?Math.round(o.val()*this.hold.xy_ratio):"",a.val(s)),n&&n>this.hold.oh||s&&s>this.hold.ow?i.css("visibility","visible"):i.css("visibility","hidden"))},getSelRatio:function(i){vart=this.hold.w,e=this.hold.h,a=this.intval(g("#imgedit-crop-width-"+i).val()),i=this.intval(g("#imgedit-crop-height-"+i).val());returna&&i?a+":"+i:t&&e?t+":"+e:"1:1"},filterHistory:function(i,t){vare,a,o,s=g("#imgedit-history-"+i).val(),n=[];if(""===s)return"";if(s=JSON.parse(s),0<(e=this.intval(g("#imgedit-undone-"+i).val())))for(;0<e;)s.pop(),e--;if(t){if(!s.length)returnthis.hold.w=this.hold.ow,this.hold.h=this.hold.oh,"";(i=(i=s[s.length-1]).c||i.r||i.f||!1)&&(this.hold.w=i.fw,this.hold.h=i.fh)}for(ains)(o=s[a]).hasOwnProperty("c")?n[a]={c:{x:o.c.x,y:o.c.y,w:o.c.w,h:o.c.h}}:o.hasOwnProperty("r")?n[a]={r:o.r.r}:o.hasOwnProperty("f")&&(n[a]={f:o.f.f});returnJSON.stringify(n)},refreshEditor:function(o,i,s){varn,t=this;t.toggleEditor(o,1),i={action:"imgedit-preview",_ajax_nonce:i,postid:o,history:t.filterHistory(o,1),rand:t.intval(1e6*Math.random())},n=g('<img id="image-preview-'+o+'" alt="" />').on("load",{history:i.history},function(i){vart,e=g("#imgedit-crop-"+o),a=d;""!==i.data.history&&(i=JSON.parse(i.data.history))[i.length-1].hasOwnProperty("c")&&(a.setDisabled(g("#image-undo-"+o),!0),g("#image-undo-"+o).trigger("focus")),e.empty().append(n),i=Math.max(a.hold.w,a.hold.h),t=Math.max(g(n).width(),g(n).height()),a.hold.sizer=t<i?t/i:1,a.initCrop(o,n,e),null!=s&&s(),g("#imgedit-history-"+o).val()&&"0"===g("#imgedit-undone-"+o).val()?g("input.imgedit-submit-btn","#imgedit-panel-"+o).prop("disabled",!1):g("input.imgedit-submit-btn","#imgedit-panel-"+o).prop("disabled",!0),a.toggleEditor(o,0)}).on("error",function(){vari=r("Could not load the preview image. Please reload the page and try again.");g("#imgedit-crop-"+o).empty().append('<div class="notice notice-error" tabindex="-1" role="alert"><p>'+i+"</p></div>"),t.toggleEditor(o,0,!0),wp.a11y.speak(i,"assertive")}).attr("src",ajaxurl+"?"+g.param(i))},action:function(t,i,e){vara,o,s,n,r=this;if(r.notsaved(t))return!1;if(i={action:"image