agenda-libre-ruby/public/assets/tinymce/plugins/image/plugin-7e12bced00de6b6b0a9bf8c066dcc2e04b602220d044626434153301e4b28d6a.js
2019-08-04 22:45:24 +02:00

11 lines
23 KiB
JavaScript

/**
* Copyright (c) Tiny Technologies, Inc. All rights reserved.
* Licensed under the LGPL or a commercial license.
* For LGPL see License.txt in the project root for license information.
* For commercial licenses see https://www.tiny.cloud/
*
* Version: 5.0.12 (2019-07-18)
*/
!function(l){"use strict";var t,e,n,r,i=tinymce.util.Tools.resolve("tinymce.PluginManager"),a=function(){},o=function(t){return function(){return t}},u=function(t){return t},c=o(!1),s=o(!0),f=c,m=s,d=function(){return g},g=(r={fold:function(t,e){return t()},is:f,isSome:f,isNone:m,getOr:n=function(t){return t},getOrThunk:e=function(t){return t()},getOrDie:function(t){throw new Error(t||"error: getOrDie called on none.")},getOrNull:function(){return null},getOrUndefined:function(){return undefined},or:n,orThunk:e,map:d,ap:d,each:function(){},bind:d,flatten:d,exists:f,forall:m,filter:d,equals:t=function(t){return t.isNone()},equals_:t,toArray:function(){return[]},toString:o("none()")},Object.freeze&&Object.freeze(r),r),p=function(n){var t=function(){return n},e=function(){return i},r=function(t){return t(n)},i={fold:function(t,e){return e(n)},is:function(t){return n===t},isSome:m,isNone:f,getOr:t,getOrThunk:t,getOrDie:t,getOrNull:t,getOrUndefined:t,or:e,orThunk:e,map:function(t){return p(t(n))},ap:function(t){return t.fold(d,function(t){return p(t(n))})},each:function(t){t(n)},bind:r,flatten:t,exists:r,forall:r,filter:function(t){return t(n)?i:g},equals:function(t){return t.is(n)},equals_:function(t,e){return t.fold(f,function(t){return e(n,t)})},toArray:function(){return[n]},toString:function(){return"some("+n+")"}};return i},w={some:p,none:d,from:function(t){return null===t||t===undefined?g:p(t)}},h=function(e){return function(t){return function(t){if(null===t)return"null";var e=typeof t;return"object"===e&&(Array.prototype.isPrototypeOf(t)||t.constructor&&"Array"===t.constructor.name)?"array":"object"===e&&(String.prototype.isPrototypeOf(t)||t.constructor&&"String"===t.constructor.name)?"string":e}(t)===e}},U=h("string"),b=h("object"),v=h("array"),y=h("boolean"),S=h("function"),D=Array.prototype.slice,T=Array.prototype.push,A=function(t){for(var e=[],n=0,r=t.length;n<r;++n){if(!v(t[n]))throw new Error("Arr.flatten item "+n+" was not an array, input: "+t);T.apply(e,t[n])}return e},O=(S(Array.from)&&Array.from,function(){return(O=Object.assign||function(t){for(var e,n=1,r=arguments.length;n<r;n++)for(var i in e=arguments[n])Object.prototype.hasOwnProperty.call(e,i)&&(t[i]=e[i]);return t}).apply(this,arguments)}),C=function(t){var n=w.none(),e=[],r=function(t){i()?o(t):e.push(t)},i=function(){return n.isSome()},a=function(t){!function(t,e){for(var n=0,r=t.length;n<r;n++)e(t[n],n,t)}(t,o)},o=function(e){n.each(function(t){l.setTimeout(function(){e(t)},0)})};return t(function(t){n=w.some(t),a(e),e=[]}),{get:r,map:function(n){return C(function(e){r(function(t){e(n(t))})})},isReady:i}},x={nu:C,pure:function(e){return C(function(t){t(e)})}},I=function(e){var t=function(t){var r;e((r=t,function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];var n=this;l.setTimeout(function(){r.apply(n,t)},0)}))},n=function(){return x.nu(t)};return{map:function(r){return I(function(n){t(function(t){var e=r(t);n(e)})})},bind:function(n){return I(function(e){t(function(t){n(t).get(e)})})},anonBind:function(n){return I(function(e){t(function(t){n.get(e)})})},toLazy:n,toCached:function(){var e=null;return I(function(t){null===e&&(e=n()),e.get(t)})},get:t}},P={nu:I,pure:function(e){return I(function(t){t(e)})}},N=function(n){return{is:function(t){return n===t},isValue:s,isError:c,getOr:o(n),getOrThunk:o(n),getOrDie:o(n),or:function(t){return N(n)},orThunk:function(t){return N(n)},fold:function(t,e){return e(n)},map:function(t){return N(t(n))},mapError:function(t){return N(n)},each:function(t){t(n)},bind:function(t){return t(n)},exists:function(t){return t(n)},forall:function(t){return t(n)},toOption:function(){return w.some(n)}}},L=function(n){return{is:c,isValue:c,isError:s,getOr:u,getOrThunk:function(t){return t()},getOrDie:function(){return t=String(n),function(){throw new Error(t)}();var t},or:function(t){return t},orThunk:function(t){return t()},fold:function(t,e){return t(n)},map:function(t){return L(n)},mapError:function(t){return L(t(n))},each:a,bind:function(t){return L(n)},exists:c,forall:s,toOption:w.none}},E={value:N,error:L,fromOption:function(t,e){return t.fold(function(){return L(e)},N)}},_=function(a){return O({},a,{toCached:function(){return _(a.toCached())},bindFuture:function(e){return _(a.bind(function(t){return t.fold(function(t){return P.pure(E.error(t))},function(t){return e(t)})}))},bindResult:function(e){return _(a.map(function(t){return t.bind(e)}))},mapResult:function(e){return _(a.map(function(t){return t.map(e)}))},mapError:function(e){return _(a.map(function(t){return t.mapError(e)}))},foldResult:function(e,n){return a.map(function(t){return t.fold(e,n)})},withTimeout:function(t,i){return _(P.nu(function(e){var n=!1,r=l.setTimeout(function(){n=!0,e(E.error(i()))},t);a.get(function(t){n||(l.clearTimeout(r),e(t))})}))}})},R=function(t){return _(P.nu(t))},z=R,k=Object.prototype.hasOwnProperty,H=function(o){return function(){for(var t=new Array(arguments.length),e=0;e<t.length;e++)t[e]=arguments[e];if(0===t.length)throw new Error("Can't merge zero objects");for(var n={},r=0;r<t.length;r++){var i=t[r];for(var a in i)k.call(i,a)&&(n[a]=o(n[a],i[a]))}return n}},j=H(function(t,e){return b(t)&&b(e)?j(t,e):e}),B=H(function(t,e){return e}),M="undefined"!=typeof l.window?l.window:Function("return this;")(),F=function(t,e){return function(t,e){for(var n=e!==undefined&&null!==e?e:M,r=0;r<t.length&&n!==undefined&&null!==n;++r)n=n[t[r]];return n}(t.split("."),e)},G={getOrDie:function(t,e){var n=F(t,e);if(n===undefined||null===n)throw new Error(t+" not available on this browser");return n}},W=function(){return G.getOrDie("URL")},q=function(t){return W().createObjectURL(t)},$=function(t){W().revokeObjectURL(t)},J=function(t){var e=t.imageList.map(function(t){return{name:"images",type:"selectbox",label:"Image list",items:t}}),n=t.classList.map(function(t){return{name:"classes",type:"selectbox",label:"Class",items:t}});return A([[{name:"src",type:"urlinput",filetype:"image",label:"Source"}],e.toArray(),t.hasDescription?[{name:"alt",type:"input",label:"Image description"}]:[],t.hasImageTitle?[{name:"title",type:"input",label:"Image title"}]:[],t.hasDimensions?[{name:"dimensions",type:"sizeinput"}]:[],[{type:"grid",columns:2,items:A([n.toArray(),t.hasImageCaption?[{type:"label",label:"Caption",items:[{type:"checkbox",name:"caption",label:"Show caption"}]}]:[]])}]])},V=function(t){return{title:"General",name:"general",items:J(t)}},X=J,Z=tinymce.util.Tools.resolve("tinymce.dom.DOMUtils");var K=tinymce.util.Tools.resolve("tinymce.util.Promise"),Q=tinymce.util.Tools.resolve("tinymce.util.XHR"),Y=function(t){return t.getParam("images_upload_url","","string")},tt=function(t){return t.getParam("images_upload_handler",undefined,"function")},et={hasDimensions:function(t){return t.getParam("image_dimensions",!0,"boolean")},hasUploadTab:function(t){return t.getParam("image_uploadtab",!0,"boolean")},hasAdvTab:function(t){return t.getParam("image_advtab",!1,"boolean")},getPrependUrl:function(t){return t.getParam("image_prepend_url","","string")},getClassList:function(t){return t.getParam("image_class_list")},hasDescription:function(t){return t.getParam("image_description",!0,"boolean")},hasImageTitle:function(t){return t.getParam("image_title",!1,"boolean")},hasImageCaption:function(t){return t.getParam("image_caption",!1,"boolean")},getImageList:function(t){return t.getParam("image_list",!1)},hasUploadUrl:function(t){return!!Y(t)},hasUploadHandler:function(t){return!!tt(t)},getUploadUrl:Y,getUploadHandler:tt,getUploadBasePath:function(t){return t.getParam("images_upload_base_path",undefined,"string")},getUploadCredentials:function(t){return t.getParam("images_upload_credentials",!1,"boolean")}},nt=function(t,e){return Math.max(parseInt(t,10),parseInt(e,10))},rt=function(t,e){var n=l.document.createElement("img"),r=function(t){n.parentNode&&n.parentNode.removeChild(n),e(t)};n.onload=function(){var t={width:nt(n.width,n.clientWidth),height:nt(n.height,n.clientHeight)};r(E.value(t))},n.onerror=function(){r(E.error("Failed to get image dimensions for: "+t))};var i=n.style;i.visibility="hidden",i.position="fixed",i.bottom=i.left="0px",i.width=i.height="auto",l.document.body.appendChild(n),n.src=t},it=function(t){return t&&(t=t.replace(/px$/,"")),t},at=function(t){return 0<t.length&&/^[0-9]+$/.test(t)&&(t+="px"),t},ot=function(t){if(t.margin){var e=String(t.margin).split(" ");switch(e.length){case 1:t["margin-top"]=t["margin-top"]||e[0],t["margin-right"]=t["margin-right"]||e[0],t["margin-bottom"]=t["margin-bottom"]||e[0],t["margin-left"]=t["margin-left"]||e[0];break;case 2:t["margin-top"]=t["margin-top"]||e[0],t["margin-right"]=t["margin-right"]||e[1],t["margin-bottom"]=t["margin-bottom"]||e[0],t["margin-left"]=t["margin-left"]||e[1];break;case 3:t["margin-top"]=t["margin-top"]||e[0],t["margin-right"]=t["margin-right"]||e[1],t["margin-bottom"]=t["margin-bottom"]||e[2],t["margin-left"]=t["margin-left"]||e[1];break;case 4:t["margin-top"]=t["margin-top"]||e[0],t["margin-right"]=t["margin-right"]||e[1],t["margin-bottom"]=t["margin-bottom"]||e[2],t["margin-left"]=t["margin-left"]||e[3]}delete t.margin}return t},ut=function(t,e){var n=et.getImageList(t);"string"==typeof n?Q.send({url:n,success:function(t){e(JSON.parse(t))}}):"function"==typeof n?n(e):e(n)},lt=function(t,e,n){var r=function(){n.onload=n.onerror=null,t.selection&&(t.selection.select(n),t.nodeChanged())};n.onload=function(){e.width||e.height||!et.hasDimensions(t)||t.dom.setAttribs(n,{width:String(n.clientWidth),height:String(n.clientHeight)}),r()},n.onerror=r},ct=function(i){return new K(function(t,e){var n=function r(){return new(G.getOrDie("FileReader"))}();n.onload=function(){t(n.result)},n.onerror=function(){e(n.error.message)},n.readAsDataURL(i)})},st=function(t){return"IMG"===t.nodeName&&(t.hasAttribute("data-mce-object")||t.hasAttribute("data-mce-placeholder"))},ft=Z.DOM,mt=function(t){return t.style.marginLeft&&t.style.marginRight&&t.style.marginLeft===t.style.marginRight?it(t.style.marginLeft):""},dt=function(t){return t.style.marginTop&&t.style.marginBottom&&t.style.marginTop===t.style.marginBottom?it(t.style.marginTop):""},gt=function(t){return t.style.borderWidth?it(t.style.borderWidth):""},pt=function(t,e){return t.hasAttribute(e)?t.getAttribute(e):""},ht=function(t,e){return t.style[e]?t.style[e]:""},bt=function(t){return null!==t.parentNode&&"FIGURE"===t.parentNode.nodeName},vt=function(t,e,n){t.setAttribute(e,n)},yt=function(t){var e,n,r,i;bt(t)?(i=(r=t).parentNode,ft.insertAfter(r,i),ft.remove(i)):(e=t,n=ft.create("figure",{"class":"image"}),ft.insertAfter(n,e),n.appendChild(e),n.appendChild(ft.create("figcaption",{contentEditable:"true"},"Caption")),n.contentEditable="false")},wt=function(t,e){var n=t.getAttribute("style"),r=e(null!==n?n:"");0<r.length?(t.setAttribute("style",r),t.setAttribute("data-mce-style",r)):t.removeAttribute("style")},Ut=function(t,r){return function(t,e,n){t.style[e]?(t.style[e]=at(n),wt(t,r)):vt(t,e,n)}},St=function(t,e){return t.style[e]?it(t.style[e]):pt(t,e)},Dt=function(t,e){var n=at(e);t.style.marginLeft=n,t.style.marginRight=n},Tt=function(t,e){var n=at(e);t.style.marginTop=n,t.style.marginBottom=n},At=function(t,e){var n=at(e);t.style.borderWidth=n},Ot=function(t,e){t.style.borderStyle=e},Ct=function(t){return"FIGURE"===t.nodeName},xt=function(t,e){var n=l.document.createElement("img");return vt(n,"style",e.style),(mt(n)||""!==e.hspace)&&Dt(n,e.hspace),(dt(n)||""!==e.vspace)&&Tt(n,e.vspace),(gt(n)||""!==e.border)&&At(n,e.border),(ht(n,"borderStyle")||""!==e.borderStyle)&&Ot(n,e.borderStyle),t(n.getAttribute("style"))},It=function(t,e){return{src:pt(e,"src"),alt:pt(e,"alt"),title:pt(e,"title"),width:St(e,"width"),height:St(e,"height"),"class":pt(e,"class"),style:t(pt(e,"style")),caption:bt(e),hspace:mt(e),vspace:dt(e),border:gt(e),borderStyle:ht(e,"borderStyle")}},Pt=function(t,e,n,r,i){n[r]!==e[r]&&i(t,r,n[r])},Nt=function(r,i){return function(t,e,n){r(t,n),wt(t,i)}},Lt=function(t,e,n){var r=It(t,n);Pt(n,r,e,"caption",function(t,e,n){return yt(t)}),Pt(n,r,e,"src",vt),Pt(n,r,e,"alt",vt),Pt(n,r,e,"title",vt),Pt(n,r,e,"width",Ut(0,t)),Pt(n,r,e,"height",Ut(0,t)),Pt(n,r,e,"class",vt),Pt(n,r,e,"style",Nt(function(t,e){return vt(t,"style",e)},t)),Pt(n,r,e,"hspace",Nt(Dt,t)),Pt(n,r,e,"vspace",Nt(Tt,t)),Pt(n,r,e,"border",Nt(At,t)),Pt(n,r,e,"borderStyle",Nt(Ot,t))},Et=function(t,e){var n=t.dom.styles.parse(e),r=ot(n),i=t.dom.styles.parse(t.dom.styles.serialize(r));return t.dom.styles.serialize(i)},_t=function(t){var e=t.selection.getNode(),n=t.dom.getParent(e,"figure.image");return n?t.dom.select("img",n)[0]:e&&("IMG"!==e.nodeName||st(e))?null:e},Rt=function(e,t){var n=e.dom,r=n.getParent(t.parentNode,function(t){return e.schema.getTextBlockElements()[t.nodeName]},e.getBody());return r?n.split(r,t):t},zt=function(e,t){var n=function(t,e){var n=l.document.createElement("img");if(Lt(t,B(e,{caption:!1}),n),vt(n,"alt",e.alt),e.caption){var r=ft.create("figure",{"class":"image"});return r.appendChild(n),r.appendChild(ft.create("figcaption",{contentEditable:"true"},"Caption")),r.contentEditable="false",r}return n}(function(t){return Et(e,t)},t);e.dom.setAttrib(n,"data-mce-id","__mcenew"),e.focus(),e.selection.setContent(n.outerHTML);var r=e.dom.select('*[data-mce-id="__mcenew"]')[0];if(e.dom.setAttrib(r,"data-mce-id",null),Ct(r)){var i=Rt(e,r);e.selection.select(i)}else e.selection.select(r)},kt=function(t,e){var n=_t(t);n?e.src?function(e,t){var n,r=_t(e);if(Lt(function(t){return Et(e,t)},t,r),n=r,e.dom.setAttrib(n,"src",n.getAttribute("src")),Ct(r.parentNode)){var i=r.parentNode;Rt(e,i),e.selection.select(r.parentNode)}else e.selection.select(r),lt(e,t,r)}(t,e):function(t,e){if(e){var n=t.dom.is(e.parentNode,"figure.image")?e.parentNode:e;t.dom.remove(n),t.focus(),t.nodeChanged(),t.dom.isEmpty(t.getBody())&&(t.setContent(""),t.selection.setCursorLocation())}}(t,n):e.src&&zt(t,e)},Ht=tinymce.util.Tools.resolve("tinymce.util.Tools"),jt=function(t){return U(t.value)?t.value:""},Bt=function(t,i){var a=[];return Ht.each(t,function(t){var e=U(t.text)?t.text:U(t.title)?t.title:"";if(t.menu!==undefined){var n=Bt(t.menu,i);a.push({text:e,items:n})}else{var r=i(t);a.push({text:e,value:r})}}),a},Mt=function(e){return void 0===e&&(e=jt),function(t){return t?w.from(t).map(function(t){return Bt(t,e)}):w.none()}},Ft=function(t,n){return function(t,e){for(var n=0;n<t.length;n++){var r=e(t[n],n);if(r.isSome())return r}return w.none()}(t,function(t){return e=t,Object.prototype.hasOwnProperty.call(e,"items")?Ft(t.items,n):t.value===n?w.some(t):w.none();var e})},Gt=Mt,Wt=function(t){return Mt(jt)(t)},qt=function(t,e){return t.bind(function(t){return Ft(t,e)})};function $t(u){var e=function(t,r,i,e){var a,n;(a=function o(){return new(G.getOrDie("XMLHttpRequest"))}()).open("POST",u.url),a.withCredentials=u.credentials,a.upload.onprogress=function(t){e(t.loaded/t.total*100)},a.onerror=function(){i("Image upload failed due to a XHR Transport error. Code: "+a.status)},a.onload=function(){var t,e,n;a.status<200||300<=a.status?i("HTTP Error: "+a.status):(t=JSON.parse(a.responseText))&&"string"==typeof t.location?r((e=u.basePath,n=t.location,e?e.replace(/\/$/,"")+"/"+n.replace(/^\//,""):n)):i("Invalid JSON: "+a.responseText)},(n=new l.FormData).append("file",t.blob(),t.filename()),a.send(n)};return u=Ht.extend({credentials:!1,handler:e},u),{upload:function(t){return u.url||u.handler!==e?(r=t,i=u.handler,new K(function(t,e){try{i(r,t,e,a)}catch(n){e(n.message)}})):K.reject("Upload url missing from the settings.");var r,i}}}var Jt=function(t){return{title:"Advanced",name:"advanced",items:[{type:"input",label:"Style",name:"style"},{type:"grid",columns:2,items:[{type:"input",label:"Vertical space",name:"vspace"},{type:"input",label:"Horizontal space",name:"hspace"},{type:"input",label:"Border width",name:"border"},{type:"selectbox",name:"borderstyle",label:"Border style",items:[{text:"Select...",value:""},{text:"Solid",value:"solid"},{text:"Dotted",value:"dotted"},{text:"Dashed",value:"dashed"},{text:"Double",value:"double"},{text:"Groove",value:"groove"},{text:"Ridge",value:"ridge"},{text:"Inset",value:"inset"},{text:"Outset",value:"outset"},{text:"None",value:"none"},{text:"Hidden",value:"hidden"}]}]}]}},Vt=function(n){var e,t,r=Gt(function(t){return n.convertURL(t.value||t.url,"src")}),i=P.nu(function(e){ut(n,function(t){e(r(t).map(function(t){return A([[{text:"None",value:""}],t])}))})}),a=Wt(et.getClassList(n)),o=et.hasAdvTab(n),u=et.hasUploadTab(n),l=et.hasUploadUrl(n),c=et.hasUploadHandler(n),s=(t=_t(e=n))?It(function(t){return Et(e,t)},t):{src:"",alt:"",title:"",width:"",height:"","class":"",style:"",caption:!1,hspace:"",vspace:"",border:"",borderStyle:""},f=et.hasDescription(n),m=et.hasImageTitle(n),d=et.hasDimensions(n),g=et.hasImageCaption(n),p=et.getUploadUrl(n),h=et.getUploadBasePath(n),b=et.getUploadCredentials(n),v=et.getUploadHandler(n),y=w.some(et.getPrependUrl(n)).filter(function(t){return U(t)&&0<t.length});return i.map(function(t){return{image:s,imageList:t,classList:a,hasAdvTab:o,hasUploadTab:u,hasUploadUrl:l,hasUploadHandler:c,hasDescription:f,hasImageTitle:m,hasDimensions:d,hasImageCaption:g,url:p,basePath:h,credentials:b,handler:v,prependURL:y}})},Xt=function(t){return{title:"Upload",name:"upload",items:[{type:"dropzone",name:"fileinput"}]}},Zt=function(t){return{src:{value:t.src,meta:{}},images:t.src,alt:t.alt,title:t.title,dimensions:{width:t.width,height:t.height},classes:t["class"],caption:t.caption,style:t.style,vspace:t.vspace,border:t.border,hspace:t.hspace,borderstyle:t.borderStyle,fileinput:[]}},Kt=function(t){return{src:t.src.value,alt:t.alt,title:t.title,width:t.dimensions.width,height:t.dimensions.height,"class":t.classes,style:t.style,caption:t.caption,hspace:t.hspace,vspace:t.vspace,border:t.border,borderStyle:t.borderstyle}},Qt=function(t,e){var n,r,i=e.getData();(n=t,r=i.src.value,/^(?:[a-zA-Z]+:)?\/\//.test(r)?w.none():n.prependURL.bind(function(t){return r.substring(0,t.length)!==t?w.some(t+r):w.none()})).each(function(t){e.setData({src:{value:t,meta:i.src.meta}})})},Yt=function(t,e){var n,r,i,a=e.getData(),o=a.src.meta;if(o!==undefined){var u=j({},a);r=u,i=o,(n=t).hasDescription&&U(i.alt)&&(r.alt=i.alt),n.hasImageTitle&&U(i.title)&&(r.title=i.title),n.hasDimensions&&(U(i.width)&&(r.dimensions.width=i.width),U(i.height)&&(r.dimensions.height=i.height)),U(i["class"])&&qt(n.classList,i["class"]).each(function(t){r.classes=t.value}),n.hasImageCaption&&y(i.caption)&&(r.caption=i.caption),n.hasAdvTab&&(U(i.vspace)&&(r.vspace=i.vspace),U(i.border)&&(r.border=i.border),U(i.hspace)&&(r.hspace=i.hspace),U(i.borderstyle)&&(r.borderstyle=i.borderstyle)),e.setData(u)}},te=function(t,e,n,r){var i,a,o,u,l,c,s,f,m,d,g,p;Qt(e,r),Yt(e,r),i=t,a=e,o=n,l=(u=r).getData(),c=l.src.value,(s=l.src.meta||{}).width||s.height||!a.hasDimensions||i.imageSize(c).get(function(t){t.each(function(t){o.open&&u.setData({dimensions:t})})}),f=e,m=n,g=(d=r).getData(),p=qt(f.imageList,g.src.value),m.prevImage=p,d.setData({images:p.map(function(t){return t.value}).getOr("")})},ee=function(t,e,n){var r,i,a,o,u,l=ot(t(n.style)),c=j({},n);return c.vspace=(r=l)["margin-top"]&&r["margin-bottom"]&&r["margin-top"]===r["margin-bottom"]?it(String(r["margin-top"])):"",c.hspace=(i=l)["margin-right"]&&i["margin-left"]&&i["margin-right"]===i["margin-left"]?it(String(i["margin-right"])):"",c.border=(a=l)["border-width"]?it(String(a["border-width"])):"",c.borderstyle=(o=l)["border-style"]?String(o["border-style"]):"",c.style=(u=e)(t(u(l))),c},ne=function(o,u,l,c){var t,e=c.getData();c.block("Uploading image"),(t=e.fileinput,0===t.length?w.none():w.some(t[0])).fold(function(){c.unblock()},function(n){var r=q(n),i=$t({url:u.url,basePath:u.basePath,credentials:u.credentials,handler:u.handler}),a=function(){c.unblock(),$(r)};ct(n).then(function(t){var e=o.createBlobCache(n,r,t);i.upload(e).then(function(t){c.setData({src:{value:t,meta:{}}}),c.showTab("general"),te(o,u,l,c),a()})["catch"](function(t){a(),o.alertErr(c,t)})})})},re=function(h,b,v){return function(t,e){var n,r,i,a,o,u,l,c,s,f,m,d,g,p;"src"===e.name?te(h,b,v,t):"images"===e.name?(s=h,f=b,m=v,g=(d=t).getData(),(p=qt(f.imageList,g.images)).each(function(t){""===g.alt||m.prevImage.map(function(t){return t.text===g.alt}).getOr(!1)?""===t.value?d.setData({src:t,alt:m.prevAlt}):d.setData({src:t,alt:t.text}):d.setData({src:t})}),m.prevImage=p,te(s,f,m,d)):"alt"===e.name?v.prevAlt=t.getData().alt:"style"===e.name?(o=h,l=(u=t).getData(),c=ee(o.parseStyle,o.serializeStyle,l),u.setData(c)):"vspace"===e.name||"hspace"===e.name||"border"===e.name||"borderstyle"===e.name?(n=h,r=t,i=j(Zt(b.image),r.getData()),a=xt(n.normalizeCss,Kt(i)),r.setData({style:a})):"fileinput"===e.name&&ne(h,b,v,t)}},ie=function(a){return function(t){var e,n,r,i={prevImage:qt((e=t).imageList,e.image.src),prevAlt:e.image.alt,open:!0};return{title:"Insert/Edit Image",size:"normal",body:(r=t,r.hasAdvTab||r.hasUploadUrl||r.hasUploadHandler?{type:"tabpanel",tabs:A([[V(r)],r.hasAdvTab?[Jt(r)]:[],r.hasUploadTab&&(r.hasUploadUrl||r.hasUploadHandler)?[Xt(r)]:[]])}:{type:"panel",items:X(r)}),buttons:[{type:"cancel",name:"cancel",text:"Cancel"},{type:"submit",name:"save",text:"Save",primary:!0}],initialData:Zt(t.image),onSubmit:a.onSubmit(t),onChange:re(a,t,i),onClose:(n=i,function(){n.open=!1})}}},ae=function(e){var n,r,i,a,o,u,l,t={onSubmit:(l=e,function(n){return function(t){var e=j(Zt(n.image),t.getData());l.undoManager.transact(function(){kt(l,Kt(e))}),l.editorUpload.uploadImagesAuto(),t.close()}}),imageSize:(u=e,function(t){return z(function(n){rt(u.documentBaseURI.toAbsolute(t),function(t){var e=t.map(function(t){return{width:String(t.width),height:String(t.height)}});n(e)})})}),createBlobCache:(o=e,function(t,e,n){return o.editorUpload.blobCache.create({blob:t,blobUri:e,name:t.name?t.name.replace(/\.[^\.]+$/,""):null,base64:n.split(",")[1]})}),alertErr:(a=e,function(t,e){a.windowManager.alert(e,t.close)}),normalizeCss:(i=e,function(t){return Et(i,t)}),parseStyle:(r=e,function(t){return r.dom.parseStyle(t)}),serializeStyle:(n=e,function(t,e){return n.dom.serializeStyle(t,e)})};return{open:function(){return Vt(e).map(ie(t)).get(function(t){e.windowManager.open(t)})}}},oe=function(t){t.addCommand("mceImage",ae(t).open)},ue=function(a){return function(t){for(var e,n=t.length,r=function(t){t.attr("contenteditable",a?"true":null)};n--;){var i=t[n];void 0,(e=i.attr("class"))&&/\bimage\b/.test(e)&&(i.attr("contenteditable",a?"false":null),Ht.each(i.getAll("figcaption"),r))}}},le=function(t){t.on("PreInit",function(){t.parser.addNodeFilter("figure",ue(!0)),t.serializer.addNodeFilter("figure",ue(!1))})},ce=function(e){e.ui.registry.addToggleButton("image",{icon:"image",tooltip:"Insert/edit image",onAction:ae(e).open,onSetup:function(t){return e.selection.selectorChangedWithUnbind("img:not([data-mce-object],[data-mce-placeholder]),figure.image",t.setActive).unbind}}),e.ui.registry.addMenuItem("image",{icon:"image",text:"Image...",onAction:ae(e).open}),e.ui.registry.addContextMenu("image",{update:function(t){return Ct(t)||"IMG"===t.nodeName&&!st(t)?["image"]:[]}})};!function se(){i.add("image",function(t){le(t),ce(t),oe(t)})}()}(window);