(function(a){"object"==typeof exports&&"object"==typeof module?a(require("../../lib/codemirror")):"function"==typeof define&&define.amd?define(["../../lib/codemirror"],a):a(CodeMirror)})(function(a){function m(c,a,b){c=c.getWrapperElement().appendChild(document.createElement("div"));c.className=b?"CodeMirror-dialog CodeMirror-dialog-bottom":"CodeMirror-dialog CodeMirror-dialog-top";"string"==typeof a?c.innerHTML=a:c.appendChild(a);return c}function n(a,g){a.state.currentNotificationClose&&a.state.currentNotificationClose();
a.state.currentNotificationClose=g}a.defineExtension("openDialog",function(c,g,b){function e(a){if("string"==typeof a)d.value=a;else if(!h&&(h=!0,f.parentNode.removeChild(f),k.focus(),b.onClose))b.onClose(f)}b||(b={});n(this,null);var f=m(this,c,b.bottom),h=!1,k=this,d=f.getElementsByTagName("input")[0];if(d){d.focus();b.value&&(d.value=b.value,!1!==b.selectValueOnOpen&&d.select());if(b.onInput)a.on(d,"input",function(a){b.onInput(a,d.value,e)});if(b.onKeyUp)a.on(d,"keyup",function(a){b.onKeyUp(a,
d.value,e)});a.on(d,"keydown",function(c){if(!(b&&b.onKeyDown&&b.onKeyDown(c,d.value,e))){if(27==c.keyCode||!1!==b.closeOnEnter&&13==c.keyCode)d.blur(),a.e_stop(c),e();13==c.keyCode&&g(d.value,c)}});if(!1!==b.closeOnBlur)a.on(d,"blur",e)}else if(c=f.getElementsByTagName("button")[0]){a.on(c,"click",function(){e();k.focus()});if(!1!==b.closeOnBlur)a.on(c,"blur",e);c.focus()}return e});a.defineExtension("openConfirm",function(c,g,b){function e(){if(!h&&(h=!0,f.parentNode.removeChild(f),k.focus(),b.onClose))b.onClose(f)}
b||(b={});n(this,null);var f=m(this,c,b.bottom);c=f.getElementsByTagName("button");var h=!1,k=this,d=1;c[0].focus();for(var l=0;l<c.length;++l){var p=c[l];(function(b){a.on(p,"click",function(c){a.e_preventDefault(c);e();b&&b(k)})})(g[l]);!1!==b.closeOnBlur&&(a.on(p,"blur",function(){--d;setTimeout(function(){0>=d&&e()},200)}),a.on(p,"focus",function(){++d}))}a.on(f,"keydown",function(a){b.onKeyDown&&b.onKeyDown(a,e)});return e});a.defineExtension("openNotification",function(c,g){function b(){f||
(f=!0,clearTimeout(h),e.parentNode.removeChild(e))}n(this,b);var e=m(this,c,g&&g.bottom),f=!1,h,k=g&&"undefined"!==typeof g.duration?g.duration:5E3;a.on(e,"click",function(c){a.e_preventDefault(c);b()});k&&(h=setTimeout(b,k));return b})});
