"use strict";function _toConsumableArray2(arr){return _arrayWithoutHoles2(arr)||_iterableToArray2(arr)||_unsupportedIterableToArray2(arr)||_nonIterableSpread2()}function _nonIterableSpread2(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function _iterableToArray2(iter){if(typeof Symbol!=="undefined"&&iter[Symbol.iterator]!=null||iter["@@iterator"]!=null)return Array.from(iter)}function _arrayWithoutHoles2(arr){if(Array.isArray(arr))return _arrayLikeToArray2(arr)}function _classCallCheck2(instance,Constructor){if(!(instance instanceof Constructor)){throw new TypeError("Cannot call a class as a function")}}function _defineProperties(target,props){for(var i=0;i=o.length)return{done:true};return{done:false,value:o[i++]}},e:function e(_e){throw _e},f:F}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var normalCompletion=true,didErr=false,err;return{s:function s(){it=it.call(o)},n:function n(){var step=it.next();normalCompletion=step.done;return step},e:function e(_e2){didErr=true;err=_e2},f:function f(){try{if(!normalCompletion&&it["return"]!=null)it["return"]()}finally{if(didErr)throw err}}}}function _unsupportedIterableToArray2(o,minLen){if(!o)return;if(typeof o==="string")return _arrayLikeToArray2(o,minLen);var n=Object.prototype.toString.call(o).slice(8,-1);if(n==="Object"&&o.constructor)n=o.constructor.name;if(n==="Map"||n==="Set")return Array.from(o);if(n==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return _arrayLikeToArray2(o,minLen)}function _arrayLikeToArray2(arr,len){if(len==null||len>arr.length)len=arr.length;for(var i=0,arr2=new Array(len);i":".","?":"/","|":"\\"};var _SPECIAL_ALIASES={"option":"alt","command":"meta","return":"enter","escape":"esc","plus":"+","mod":/Mac|iPod|iPhone|iPad/.test(navigator.platform)?"meta":"ctrl"};var _REVERSE_MAP;for(var i2=1;i2<20;++i2){_MAP[111+i2]="f"+i2}for(i2=0;i2<=9;++i2){_MAP[i2+96]=i2.toString()}function _addEvent(object,type,callback){if(object.addEventListener){object.addEventListener(type,callback,false);return}object.attachEvent("on"+type,callback)}function _characterFromEvent(e){if(e.type=="keypress"){var character=String.fromCharCode(e.which);if(!e.shiftKey){character=character.toLowerCase()}return character}if(_MAP[e.which]){return _MAP[e.which]}if(_KEYCODE_MAP[e.which]){return _KEYCODE_MAP[e.which]}return String.fromCharCode(e.which).toLowerCase()}function _modifiersMatch(modifiers1,modifiers2){return modifiers1.sort().join(",")===modifiers2.sort().join(",")}function _eventModifiers(e){var modifiers=[];if(e.shiftKey){modifiers.push("shift")}if(e.altKey){modifiers.push("alt")}if(e.ctrlKey){modifiers.push("ctrl")}if(e.metaKey){modifiers.push("meta")}return modifiers}function _preventDefault(e){if(e.preventDefault){e.preventDefault();return}e.returnValue=false}function _stopPropagation(e){if(e.stopPropagation){e.stopPropagation();return}e.cancelBubble=true}function _isModifier(key){return key=="shift"||key=="ctrl"||key=="alt"||key=="meta"}function _getReverseMap(){if(!_REVERSE_MAP){_REVERSE_MAP={};for(var key in _MAP){if(key>95&&key<112){continue}if(_MAP.hasOwnProperty(key)){_REVERSE_MAP[_MAP[key]]=key}}}return _REVERSE_MAP}function _pickBestAction(key,modifiers,action){if(!action){action=_getReverseMap()[key]?"keydown":"keypress"}if(action=="keypress"&&modifiers.length){action="keydown"}return action}function _keysFromString(combination){if(combination==="+"){return["+"]}combination=combination.replace(/\+{2}/g,"+plus");return combination.split("+")}function _getKeyInfo(combination,action){var keys;var key;var i3;var modifiers=[];keys=_keysFromString(combination);for(i3=0;i31){_bindSequence(combination,sequence,callback,action);return}info=_getKeyInfo(combination,action);self2._callbacks[info.key]=self2._callbacks[info.key]||[];_getMatches(info.key,info.modifiers,{type:info.action},sequenceName,combination,level);self2._callbacks[info.key][sequenceName?"unshift":"push"]({callback:callback,modifiers:info.modifiers,action:info.action,seq:sequenceName,level:level,combo:combination})}self2._bindMultiple=function(combinations,callback,action){for(var i3=0;i3-1){return false}if(_belongsTo(element,self2.target)){return false}if("composedPath"in e&&typeof e.composedPath==="function"){var initialEventTarget=e.composedPath()[0];if(initialEventTarget!==e.target){element=initialEventTarget}}return element.tagName=="INPUT"||element.tagName=="SELECT"||element.tagName=="TEXTAREA"||element.isContentEditable};Mousetrap3.prototype.handleKey=function(){var self2=this;return self2._handleKey.apply(self2,arguments)};Mousetrap3.addKeycodes=function(object){for(var key in object){if(object.hasOwnProperty(key)){_MAP[key]=object[key]}}_REVERSE_MAP=null};Mousetrap3.init=function(){var documentMousetrap=Mousetrap3(document2);for(var method in documentMousetrap){if(method.charAt(0)!=="_"){Mousetrap3[method]=function(method2){return function(){return documentMousetrap[method2].apply(documentMousetrap,arguments)}}(method)}}};Mousetrap3.init();window2.Mousetrap=Mousetrap3;if(typeof module!=="undefined"&&module.exports){module.exports=Mousetrap3}if(typeof define==="function"&&define.amd){define(function(){return Mousetrap3})}})(typeof window!=="undefined"?window:null,typeof window!=="undefined"?document:null)}});// node_modules/@rails/ujs/lib/assets/compiled/rails-ujs.js var require_rails_ujs=__commonJS({"node_modules/@rails/ujs/lib/assets/compiled/rails-ujs.js":function node_modulesRailsUjsLibAssetsCompiledRailsUjsJs(exports,module){(function(){var context=this;(function(){(function(){this.Rails={linkClickSelector:"a[data-confirm], a[data-method], a[data-remote]:not([disabled]), a[data-disable-with], a[data-disable]",buttonClickSelector:{selector:"button[data-remote]:not([form]), button[data-confirm]:not([form])",exclude:"form button"},inputChangeSelector:"select[data-remote], input[data-remote], textarea[data-remote]",formSubmitSelector:"form:not([data-turbo=true])",formInputClickSelector:"form:not([data-turbo=true]) input[type=submit], form:not([data-turbo=true]) input[type=image], form:not([data-turbo=true]) button[type=submit], form:not([data-turbo=true]) button:not([type]), input[type=submit][form], input[type=image][form], button[type=submit][form], button[form]:not([type])",formDisableSelector:"input[data-disable-with]:enabled, button[data-disable-with]:enabled, textarea[data-disable-with]:enabled, input[data-disable]:enabled, button[data-disable]:enabled, textarea[data-disable]:enabled",formEnableSelector:"input[data-disable-with]:disabled, button[data-disable-with]:disabled, textarea[data-disable-with]:disabled, input[data-disable]:disabled, button[data-disable]:disabled, textarea[data-disable]:disabled",fileInputSelector:"input[name][type=file]:not([disabled])",linkDisableSelector:"a[data-disable-with], a[data-disable]",buttonDisableSelector:"button[data-remote][data-disable-with], button[data-remote][data-disable]"}}).call(this)}).call(context);var Rails2=context.Rails;(function(){(function(){var nonce;nonce=null;Rails2.loadCSPNonce=function(){var ref;return nonce=(ref=document.querySelector("meta[name=csp-nonce]"))!=null?ref.content:void 0};Rails2.cspNonce=function(){return nonce!=null?nonce:Rails2.loadCSPNonce()}}).call(this);(function(){var expando,m;m=Element.prototype.matches||Element.prototype.matchesSelector||Element.prototype.mozMatchesSelector||Element.prototype.msMatchesSelector||Element.prototype.oMatchesSelector||Element.prototype.webkitMatchesSelector;Rails2.matches=function(element,selector){if(selector.exclude!=null){return m.call(element,selector.selector)&&!m.call(element,selector.exclude)}else{return m.call(element,selector)}};expando="_ujsData";Rails2.getData=function(element,key){var ref;return(ref=element[expando])!=null?ref[key]:void 0};Rails2.setData=function(element,key,value){if(element[expando]==null){element[expando]={}}return element[expando][key]=value};Rails2.$=function(selector){return Array.prototype.slice.call(document.querySelectorAll(selector))}}).call(this);(function(){var $27,csrfParam,csrfToken;$27=Rails2.$;csrfToken=Rails2.csrfToken=function(){var meta;meta=document.querySelector("meta[name=csrf-token]");return meta&&meta.content};csrfParam=Rails2.csrfParam=function(){var meta;meta=document.querySelector("meta[name=csrf-param]");return meta&&meta.content};Rails2.CSRFProtection=function(xhr){var token;token=csrfToken();if(token!=null){return xhr.setRequestHeader("X-CSRF-Token",token)}};Rails2.refreshCSRFTokens=function(){var param,token;token=csrfToken();param=csrfParam();if(token!=null&¶m!=null){return $27("form input[name=\""+param+"\"]").forEach(function(input){return input.value=token})}}}).call(this);(function(){var CustomEvent2,fire,matches,preventDefault;matches=Rails2.matches;CustomEvent2=window.CustomEvent;if(typeof CustomEvent2!=="function"){CustomEvent2=function CustomEvent2(event,params){var evt;evt=document.createEvent("CustomEvent");evt.initCustomEvent(event,params.bubbles,params.cancelable,params.detail);return evt};CustomEvent2.prototype=window.Event.prototype;preventDefault=CustomEvent2.prototype.preventDefault;CustomEvent2.prototype.preventDefault=function(){var result;result=preventDefault.call(this);if(this.cancelable&&!this.defaultPrevented){Object.defineProperty(this,"defaultPrevented",{get:function get(){return true}})}return result}}fire=Rails2.fire=function(obj,name,data){var event;event=new CustomEvent2(name,{bubbles:true,cancelable:true,detail:data});obj.dispatchEvent(event);return!event.defaultPrevented};Rails2.stopEverything=function(e){fire(e.target,"ujs:everythingStopped");e.preventDefault();e.stopPropagation();return e.stopImmediatePropagation()};Rails2.delegate=function(element,selector,eventType,handler){return element.addEventListener(eventType,function(e){var target;target=e.target;while(!(!(target instanceof Element)||matches(target,selector))){target=target.parentNode}if(target instanceof Element&&handler.call(target,e)===false){e.preventDefault();return e.stopPropagation()}})}}).call(this);(function(){var AcceptHeaders,CSRFProtection,createXHR,cspNonce,fire,prepareOptions,processResponse;cspNonce=Rails2.cspNonce,CSRFProtection=Rails2.CSRFProtection,fire=Rails2.fire;AcceptHeaders={"*":"*/*",text:"text/plain",html:"text/html",xml:"application/xml, text/xml",json:"application/json, text/javascript",script:"text/javascript, application/javascript, application/ecmascript, application/x-ecmascript"};Rails2.ajax=function(options){var xhr;options=prepareOptions(options);xhr=createXHR(options,function(){var ref,response;response=processResponse((ref=xhr.response)!=null?ref:xhr.responseText,xhr.getResponseHeader("Content-Type"));if(Math.floor(xhr.status/100)===2){if(typeof options.success==="function"){options.success(response,xhr.statusText,xhr)}}else{if(typeof options.error==="function"){options.error(response,xhr.statusText,xhr)}}return typeof options.complete==="function"?options.complete(xhr,xhr.statusText):void 0});if(options.beforeSend!=null&&!options.beforeSend(xhr,options)){return false}if(xhr.readyState===XMLHttpRequest.OPENED){return xhr.send(options.data)}};prepareOptions=function prepareOptions(options){options.url=options.url||location.href;options.type=options.type.toUpperCase();if(options.type==="GET"&&options.data){if(options.url.indexOf("?")<0){options.url+="?"+options.data}else{options.url+="&"+options.data}}if(AcceptHeaders[options.dataType]==null){options.dataType="*"}options.accept=AcceptHeaders[options.dataType];if(options.dataType!=="*"){options.accept+=", */*; q=0.01"}return options};createXHR=function createXHR(options,done){var xhr;xhr=new XMLHttpRequest;xhr.open(options.type,options.url,true);xhr.setRequestHeader("Accept",options.accept);if(typeof options.data==="string"){xhr.setRequestHeader("Content-Type","application/x-www-form-urlencoded; charset=UTF-8")}if(!options.crossDomain){xhr.setRequestHeader("X-Requested-With","XMLHttpRequest");CSRFProtection(xhr)}xhr.withCredentials=!!options.withCredentials;xhr.onreadystatechange=function(){if(xhr.readyState===XMLHttpRequest.DONE){return done(xhr)}};return xhr};processResponse=function processResponse(response,type){var parser,script;if(typeof response==="string"&&typeof type==="string"){if(type.match(/\bjson\b/)){try{response=JSON.parse(response)}catch(error){}}else if(type.match(/\b(?:java|ecma)script\b/)){script=document.createElement("script");script.setAttribute("nonce",cspNonce());script.text=response;document.head.appendChild(script).parentNode.removeChild(script)}else if(type.match(/\b(xml|html|svg)\b/)){parser=new DOMParser;type=type.replace(/;.+/,"");try{response=parser.parseFromString(response,type)}catch(error){}}}return response};Rails2.href=function(element){return element.href};Rails2.isCrossDomain=function(url){var e,originAnchor,urlAnchor;originAnchor=document.createElement("a");originAnchor.href=location.href;urlAnchor=document.createElement("a");try{urlAnchor.href=url;return!((!urlAnchor.protocol||urlAnchor.protocol===":")&&!urlAnchor.host||originAnchor.protocol+"//"+originAnchor.host===urlAnchor.protocol+"//"+urlAnchor.host)}catch(error){e=error;return true}}}).call(this);(function(){var matches,toArray;matches=Rails2.matches;toArray=function toArray(e){return Array.prototype.slice.call(e)};Rails2.serializeElement=function(element,additionalParam){var inputs,params;inputs=[element];if(matches(element,"form")){inputs=toArray(element.elements)}params=[];inputs.forEach(function(input){if(!input.name||input.disabled){return}if(matches(input,"fieldset[disabled] *")){return}if(matches(input,"select")){return toArray(input.options).forEach(function(option){if(option.selected){return params.push({name:input.name,value:option.value})}})}else if(input.checked||["radio","checkbox","submit"].indexOf(input.type)===-1){return params.push({name:input.name,value:input.value})}});if(additionalParam){params.push(additionalParam)}return params.map(function(param){if(param.name!=null){return encodeURIComponent(param.name)+"="+encodeURIComponent(param.value)}else{return param}}).join("&")};Rails2.formElements=function(form,selector){if(matches(form,"form")){return toArray(form.elements).filter(function(el){return matches(el,selector)})}else{return toArray(form.querySelectorAll(selector))}}}).call(this);(function(){var allowAction,fire,stopEverything;fire=Rails2.fire,stopEverything=Rails2.stopEverything;Rails2.handleConfirm=function(e){if(!allowAction(this)){return stopEverything(e)}};Rails2.confirm=function(message,element){return confirm(message)};allowAction=function allowAction(element){var answer,callback,message;message=element.getAttribute("data-confirm");if(!message){return true}answer=false;if(fire(element,"confirm")){try{answer=Rails2.confirm(message,element)}catch(error){}callback=fire(element,"confirm:complete",[answer])}return answer&&callback}}).call(this);(function(){var disableFormElement,disableFormElements,disableLinkElement,enableFormElement,enableFormElements,enableLinkElement,formElements,getData,isXhrRedirect,matches,setData,stopEverything;matches=Rails2.matches,getData=Rails2.getData,setData=Rails2.setData,stopEverything=Rails2.stopEverything,formElements=Rails2.formElements;Rails2.handleDisabledElement=function(e){var element;element=this;if(element.disabled){return stopEverything(e)}};Rails2.enableElement=function(e){var element;if(e instanceof Event){if(isXhrRedirect(e)){return}element=e.target}else{element=e}if(matches(element,Rails2.linkDisableSelector)){return enableLinkElement(element)}else if(matches(element,Rails2.buttonDisableSelector)||matches(element,Rails2.formEnableSelector)){return enableFormElement(element)}else if(matches(element,Rails2.formSubmitSelector)){return enableFormElements(element)}};Rails2.disableElement=function(e){var element;element=e instanceof Event?e.target:e;if(matches(element,Rails2.linkDisableSelector)){return disableLinkElement(element)}else if(matches(element,Rails2.buttonDisableSelector)||matches(element,Rails2.formDisableSelector)){return disableFormElement(element)}else if(matches(element,Rails2.formSubmitSelector)){return disableFormElements(element)}};disableLinkElement=function disableLinkElement(element){var replacement;if(getData(element,"ujs:disabled")){return}replacement=element.getAttribute("data-disable-with");if(replacement!=null){setData(element,"ujs:enable-with",element.innerHTML);element.innerHTML=replacement}element.addEventListener("click",stopEverything);return setData(element,"ujs:disabled",true)};enableLinkElement=function enableLinkElement(element){var originalText;originalText=getData(element,"ujs:enable-with");if(originalText!=null){element.innerHTML=originalText;setData(element,"ujs:enable-with",null)}element.removeEventListener("click",stopEverything);return setData(element,"ujs:disabled",null)};disableFormElements=function disableFormElements(form){return formElements(form,Rails2.formDisableSelector).forEach(disableFormElement)};disableFormElement=function disableFormElement(element){var replacement;if(getData(element,"ujs:disabled")){return}replacement=element.getAttribute("data-disable-with");if(replacement!=null){if(matches(element,"button")){setData(element,"ujs:enable-with",element.innerHTML);element.innerHTML=replacement}else{setData(element,"ujs:enable-with",element.value);element.value=replacement}}element.disabled=true;return setData(element,"ujs:disabled",true)};enableFormElements=function enableFormElements(form){return formElements(form,Rails2.formEnableSelector).forEach(enableFormElement)};enableFormElement=function enableFormElement(element){var originalText;originalText=getData(element,"ujs:enable-with");if(originalText!=null){if(matches(element,"button")){element.innerHTML=originalText}else{element.value=originalText}setData(element,"ujs:enable-with",null)}element.disabled=false;return setData(element,"ujs:disabled",null)};isXhrRedirect=function isXhrRedirect(event){var ref,xhr;xhr=(ref=event.detail)!=null?ref[0]:void 0;return(xhr!=null?xhr.getResponseHeader("X-Xhr-Redirect"):void 0)!=null}}).call(this);(function(){var stopEverything;stopEverything=Rails2.stopEverything;Rails2.handleMethod=function(e){var csrfParam,csrfToken,form,formContent,href,link,method;link=this;method=link.getAttribute("data-method");if(!method){return}href=Rails2.href(link);csrfToken=Rails2.csrfToken();csrfParam=Rails2.csrfParam();form=document.createElement("form");formContent="";if(csrfParam!=null&&csrfToken!=null&&!Rails2.isCrossDomain(href)){formContent+=""}formContent+="";form.method="post";form.action=href;form.target=link.target;form.innerHTML=formContent;form.style.display="none";document.body.appendChild(form);form.querySelector("[type=\"submit\"]").click();return stopEverything(e)}}).call(this);(function(){var ajax,fire,getData,isCrossDomain,isRemote,matches,serializeElement,setData,stopEverything,slice=[].slice;matches=Rails2.matches,getData=Rails2.getData,setData=Rails2.setData,fire=Rails2.fire,stopEverything=Rails2.stopEverything,ajax=Rails2.ajax,isCrossDomain=Rails2.isCrossDomain,serializeElement=Rails2.serializeElement;isRemote=function isRemote(element){var value;value=element.getAttribute("data-remote");return value!=null&&value!=="false"};Rails2.handleRemote=function(e){var button,data,dataType,element,method,url,withCredentials;element=this;if(!isRemote(element)){return true}if(!fire(element,"ajax:before")){fire(element,"ajax:stopped");return false}withCredentials=element.getAttribute("data-with-credentials");dataType=element.getAttribute("data-type")||"script";if(matches(element,Rails2.formSubmitSelector)){button=getData(element,"ujs:submit-button");method=getData(element,"ujs:submit-button-formmethod")||element.method;url=getData(element,"ujs:submit-button-formaction")||element.getAttribute("action")||location.href;if(method.toUpperCase()==="GET"){url=url.replace(/\?.*$/,"")}if(element.enctype==="multipart/form-data"){data=new FormData(element);if(button!=null){data.append(button.name,button.value)}}else{data=serializeElement(element,button)}setData(element,"ujs:submit-button",null);setData(element,"ujs:submit-button-formmethod",null);setData(element,"ujs:submit-button-formaction",null)}else if(matches(element,Rails2.buttonClickSelector)||matches(element,Rails2.inputChangeSelector)){method=element.getAttribute("data-method");url=element.getAttribute("data-url");data=serializeElement(element,element.getAttribute("data-params"))}else{method=element.getAttribute("data-method");url=Rails2.href(element);data=element.getAttribute("data-params")}ajax({type:method||"GET",url:url,data:data,dataType:dataType,beforeSend:function beforeSend(xhr,options){if(fire(element,"ajax:beforeSend",[xhr,options])){return fire(element,"ajax:send",[xhr])}else{fire(element,"ajax:stopped");return false}},success:function success(){var args;args=1<=arguments.length?slice.call(arguments,0):[];return fire(element,"ajax:success",args)},error:function error(){var args;args=1<=arguments.length?slice.call(arguments,0):[];return fire(element,"ajax:error",args)},complete:function complete(){var args;args=1<=arguments.length?slice.call(arguments,0):[];return fire(element,"ajax:complete",args)},crossDomain:isCrossDomain(url),withCredentials:withCredentials!=null&&withCredentials!=="false"});return stopEverything(e)};Rails2.formSubmitButtonClick=function(e){var button,form;button=this;form=button.form;if(!form){return}if(button.name){setData(form,"ujs:submit-button",{name:button.name,value:button.value})}setData(form,"ujs:formnovalidate-button",button.formNoValidate);setData(form,"ujs:submit-button-formaction",button.getAttribute("formaction"));return setData(form,"ujs:submit-button-formmethod",button.getAttribute("formmethod"))};Rails2.preventInsignificantClick=function(e){var data,insignificantMetaClick,link,metaClick,method,nonPrimaryMouseClick;link=this;method=(link.getAttribute("data-method")||"GET").toUpperCase();data=link.getAttribute("data-params");metaClick=e.metaKey||e.ctrlKey;insignificantMetaClick=metaClick&&method==="GET"&&!data;nonPrimaryMouseClick=e.button!=null&&e.button!==0;if(nonPrimaryMouseClick||insignificantMetaClick){return e.stopImmediatePropagation()}}}).call(this);(function(){var $27,CSRFProtection,delegate,disableElement,enableElement,fire,formSubmitButtonClick,getData,handleConfirm,handleDisabledElement,handleMethod,handleRemote,loadCSPNonce,preventInsignificantClick,refreshCSRFTokens;fire=Rails2.fire,delegate=Rails2.delegate,getData=Rails2.getData,$27=Rails2.$,refreshCSRFTokens=Rails2.refreshCSRFTokens,CSRFProtection=Rails2.CSRFProtection,loadCSPNonce=Rails2.loadCSPNonce,enableElement=Rails2.enableElement,disableElement=Rails2.disableElement,handleDisabledElement=Rails2.handleDisabledElement,handleConfirm=Rails2.handleConfirm,preventInsignificantClick=Rails2.preventInsignificantClick,handleRemote=Rails2.handleRemote,formSubmitButtonClick=Rails2.formSubmitButtonClick,handleMethod=Rails2.handleMethod;if(typeof jQuery!=="undefined"&&jQuery!==null&&jQuery.ajax!=null){if(jQuery.rails){throw new Error("If you load both jquery_ujs and rails-ujs, use rails-ujs only.")}jQuery.rails=Rails2;jQuery.ajaxPrefilter(function(options,originalOptions,xhr){if(!options.crossDomain){return CSRFProtection(xhr)}})}Rails2.start=function(){if(window._rails_loaded){throw new Error("rails-ujs has already been loaded!")}window.addEventListener("pageshow",function(){$27(Rails2.formEnableSelector).forEach(function(el){if(getData(el,"ujs:disabled")){return enableElement(el)}});return $27(Rails2.linkDisableSelector).forEach(function(el){if(getData(el,"ujs:disabled")){return enableElement(el)}})});delegate(document,Rails2.linkDisableSelector,"ajax:complete",enableElement);delegate(document,Rails2.linkDisableSelector,"ajax:stopped",enableElement);delegate(document,Rails2.buttonDisableSelector,"ajax:complete",enableElement);delegate(document,Rails2.buttonDisableSelector,"ajax:stopped",enableElement);delegate(document,Rails2.linkClickSelector,"click",preventInsignificantClick);delegate(document,Rails2.linkClickSelector,"click",handleDisabledElement);delegate(document,Rails2.linkClickSelector,"click",handleConfirm);delegate(document,Rails2.linkClickSelector,"click",disableElement);delegate(document,Rails2.linkClickSelector,"click",handleRemote);delegate(document,Rails2.linkClickSelector,"click",handleMethod);delegate(document,Rails2.buttonClickSelector,"click",preventInsignificantClick);delegate(document,Rails2.buttonClickSelector,"click",handleDisabledElement);delegate(document,Rails2.buttonClickSelector,"click",handleConfirm);delegate(document,Rails2.buttonClickSelector,"click",disableElement);delegate(document,Rails2.buttonClickSelector,"click",handleRemote);delegate(document,Rails2.inputChangeSelector,"change",handleDisabledElement);delegate(document,Rails2.inputChangeSelector,"change",handleConfirm);delegate(document,Rails2.inputChangeSelector,"change",handleRemote);delegate(document,Rails2.formSubmitSelector,"submit",handleDisabledElement);delegate(document,Rails2.formSubmitSelector,"submit",handleConfirm);delegate(document,Rails2.formSubmitSelector,"submit",handleRemote);delegate(document,Rails2.formSubmitSelector,"submit",function(e){return setTimeout(function(){return disableElement(e)},13)});delegate(document,Rails2.formSubmitSelector,"ajax:send",disableElement);delegate(document,Rails2.formSubmitSelector,"ajax:complete",enableElement);delegate(document,Rails2.formInputClickSelector,"click",preventInsignificantClick);delegate(document,Rails2.formInputClickSelector,"click",handleDisabledElement);delegate(document,Rails2.formInputClickSelector,"click",handleConfirm);delegate(document,Rails2.formInputClickSelector,"click",formSubmitButtonClick);document.addEventListener("DOMContentLoaded",refreshCSRFTokens);document.addEventListener("DOMContentLoaded",loadCSPNonce);return window._rails_loaded=true};if(window.Rails===Rails2&&fire(document,"rails:attachBindings")){Rails2.start()}}).call(this)}).call(this);if(_typeof2(module)==="object"&&module.exports){module.exports=Rails2}else if(typeof define==="function"&&define.amd){define(Rails2)}}).call(exports)}});// node_modules/autocompleter/autocomplete.js var require_autocomplete=__commonJS({"node_modules/autocompleter/autocomplete.js":function node_modulesAutocompleterAutocompleteJs(exports,module){(function(global,factory){_typeof2(exports)==="object"&&typeof module!=="undefined"?module.exports=factory():typeof define==="function"&&define.amd?define(factory):(global=typeof globalThis!=="undefined"?globalThis:global||self,global.autocomplete=factory())})(exports,function(){"use strict";function autocomplete(settings){var doc=document;var container=settings.container||doc.createElement("div");var containerStyle=container.style;var userAgent=navigator.userAgent;var mobileFirefox=userAgent.indexOf("Firefox")!==-1&&userAgent.indexOf("Mobile")!==-1;var debounceWaitMs=settings.debounceWaitMs||0;var preventSubmit=settings.preventSubmit||false;var disableAutoSelect=settings.disableAutoSelect||false;var keyUpEventName=mobileFirefox?"input":"keyup";var items=[];var inputValue="";var minLen=2;var showOnFocus=settings.showOnFocus;var selected;var keypressCounter=0;var debounceTimer;if(settings.minLength!==void 0){minLen=settings.minLength}if(!settings.input){throw new Error("input undefined")}var input=settings.input;container.className="autocomplete "+(settings.className||"");containerStyle.position="absolute";function detach(){var parent=container.parentNode;if(parent){parent.removeChild(container)}}function clearDebounceTimer(){if(debounceTimer){window.clearTimeout(debounceTimer)}}function attach(){if(!container.parentNode){doc.body.appendChild(container)}}function containerDisplayed(){return!!container.parentNode}function clear(){keypressCounter++;items=[];inputValue="";selected=void 0;detach()}function updatePosition(){if(!containerDisplayed()){return}containerStyle.height="auto";containerStyle.width=input.offsetWidth+"px";var maxHeight=0;var inputRect;function calc(){var docEl=doc.documentElement;var clientTop=docEl.clientTop||doc.body.clientTop||0;var clientLeft=docEl.clientLeft||doc.body.clientLeft||0;var scrollTop=window.pageYOffset||docEl.scrollTop;var scrollLeft=window.pageXOffset||docEl.scrollLeft;inputRect=input.getBoundingClientRect();var top=inputRect.top+input.offsetHeight+scrollTop-clientTop;var left=inputRect.left+scrollLeft-clientLeft;containerStyle.top=top+"px";containerStyle.left=left+"px";maxHeight=window.innerHeight-(inputRect.top+input.offsetHeight);if(maxHeight<0){maxHeight=0}containerStyle.top=top+"px";containerStyle.bottom="";containerStyle.left=left+"px";containerStyle.maxHeight=maxHeight+"px"}calc();calc();if(settings.customize&&inputRect){settings.customize(input,inputRect,container,maxHeight)}}function update(){while(container.firstChild){container.removeChild(container.firstChild)}var render=function render(item,currentValue){var itemElement=doc.createElement("div");itemElement.textContent=item.label||"";return itemElement};if(settings.render){render=settings.render}var renderGroup=function renderGroup(groupName,currentValue){var groupDiv=doc.createElement("div");groupDiv.textContent=groupName;return groupDiv};if(settings.renderGroup){renderGroup=settings.renderGroup}var fragment=doc.createDocumentFragment();var prevGroup="#9?$";items.forEach(function(item){if(item.group&&item.group!==prevGroup){prevGroup=item.group;var groupDiv=renderGroup(item.group,inputValue);if(groupDiv){groupDiv.className+=" group";fragment.appendChild(groupDiv)}}var div=render(item,inputValue);if(div){div.addEventListener("click",function(ev){settings.onSelect(item,input);clear();ev.preventDefault();ev.stopPropagation()});if(item===selected){div.className+=" selected"}fragment.appendChild(div)}});container.appendChild(fragment);if(items.length<1){if(settings.emptyMsg){var empty=doc.createElement("div");empty.className="empty";empty.textContent=settings.emptyMsg;container.appendChild(empty)}else{clear();return}}attach();updatePosition();updateScroll()}function updateIfDisplayed(){if(containerDisplayed()){update()}}function resizeEventHandler(){updateIfDisplayed()}function scrollEventHandler(e){if(e.target!==container){updateIfDisplayed()}else{e.preventDefault()}}function keyupEventHandler(ev){var keyCode=ev.which||ev.keyCode||0;var ignore=[38,13,27,39,37,16,17,18,20,91,9];for(var _i=0,ignore_1=ignore;_i=112&&keyCode<=123){return}if(keyCode===40&&containerDisplayed()){return}startFetch(0)}function updateScroll(){var elements=container.getElementsByClassName("selected");if(elements.length>0){var element=elements[0];var previous=element.previousElementSibling;if(previous&&previous.className.indexOf("group")!==-1&&!previous.previousElementSibling){element=previous}if(element.offsetTopcontainerBottom){container.scrollTop+=selectBottom-containerBottom}}}}function selectPrev(){if(items.length<1){selected=void 0}else{if(selected===items[0]){selected=items[items.length-1]}else{for(var i2=items.length-1;i2>0;i2--){if(selected===items[i2]||i2===1){selected=items[i2-1];break}}}}}function selectNext(){if(items.length<1){selected=void 0}if(!selected||selected===items[items.length-1]){selected=items[0];return}for(var i2=0;i2=minLen||trigger===1){clearDebounceTimer();debounceTimer=window.setTimeout(function(){settings.fetch(val,function(elements){if(keypressCounter===savedKeypressCounter&&elements){items=elements;inputValue=val;selected=items.length<1||disableAutoSelect?void 0:items[0];update()}},trigger)},trigger===0?debounceWaitMs:0)}else{clear()}}function blurEventHandler(){setTimeout(function(){if(doc.activeElement!==input){clear()}},200)}container.addEventListener("mousedown",function(evt){evt.stopPropagation();evt.preventDefault()});container.addEventListener("focus",function(){return input.focus()});function destroy(){input.removeEventListener("focus",focusEventHandler);input.removeEventListener("keydown",keydownEventHandler);input.removeEventListener(keyUpEventName,keyupEventHandler);input.removeEventListener("blur",blurEventHandler);window.removeEventListener("resize",resizeEventHandler);doc.removeEventListener("scroll",scrollEventHandler,true);clearDebounceTimer();clear()}input.addEventListener("keydown",keydownEventHandler);input.addEventListener(keyUpEventName,keyupEventHandler);input.addEventListener("blur",blurEventHandler);input.addEventListener("focus",focusEventHandler);window.addEventListener("resize",resizeEventHandler);doc.addEventListener("scroll",scrollEventHandler,true);return{destroy:destroy}}return autocomplete})}});// node_modules/cropperjs/dist/cropper.js var require_cropper=__commonJS({"node_modules/cropperjs/dist/cropper.js":function node_modulesCropperjsDistCropperJs(exports,module){(function(global,factory){_typeof2(exports)==="object"&&typeof module!=="undefined"?module.exports=factory():typeof define==="function"&&define.amd?define(factory):(global=typeof globalThis!=="undefined"?globalThis:global||self,global.Cropper=factory())})(exports,function(){"use strict";function ownKeys(object,enumerableOnly){var keys=Object.keys(object);if(Object.getOwnPropertySymbols){var symbols=Object.getOwnPropertySymbols(object);if(enumerableOnly){symbols=symbols.filter(function(sym){return Object.getOwnPropertyDescriptor(object,sym).enumerable})}keys.push.apply(keys,symbols)}return keys}function _objectSpread2(target){for(var i2=1;i2arr.length)len=arr.length;for(var i2=0,arr2=new Array(len);i2
";var isNaN=Number.isNaN||WINDOW.isNaN;function isNumber(value){return typeof value==="number"&&!isNaN(value)}var isPositiveNumber=function isPositiveNumber2(value){return value>0&&value1?_len-1:0),_key=1;_key<_len;_key++){args[_key-1]=arguments[_key]}if(isObject(target)&&args.length>0){args.forEach(function(arg){if(isObject(arg)){Object.keys(arg).forEach(function(key){target[key]=arg[key]})}})}return target};var REGEXP_DECIMALS=/\.\d*(?:0|9){12}\d*$/;function normalizeDecimalNumber(value){var times=arguments.length>1&&arguments[1]!==void 0?arguments[1]:1e11;return REGEXP_DECIMALS.test(value)?Math.round(value*times)/times:value}var REGEXP_SUFFIX=/^width|height|left|top|marginLeft|marginTop$/;function setStyle(element,styles){var style=element.style;forEach(styles,function(value,property){if(REGEXP_SUFFIX.test(property)&&isNumber(value)){value="".concat(value,"px")}style[property]=value})}function hasClass(element,value){return element.classList?element.classList.contains(value):element.className.indexOf(value)>-1}function addClass(element,value){if(!value){return}if(isNumber(element.length)){forEach(element,function(elem){addClass(elem,value)});return}if(element.classList){element.classList.add(value);return}var className=element.className.trim();if(!className){element.className=value}else if(className.indexOf(value)<0){element.className="".concat(className," ").concat(value)}}function removeClass(element,value){if(!value){return}if(isNumber(element.length)){forEach(element,function(elem){removeClass(elem,value)});return}if(element.classList){element.classList.remove(value);return}if(element.className.indexOf(value)>=0){element.className=element.className.replace(value,"")}}function toggleClass(element,value,added){if(!value){return}if(isNumber(element.length)){forEach(element,function(elem){toggleClass(elem,value,added)});return}if(added){addClass(element,value)}else{removeClass(element,value)}}var REGEXP_CAMEL_CASE=/([a-z\d])([A-Z])/g;function toParamCase(value){return value.replace(REGEXP_CAMEL_CASE,"$1-$2").toLowerCase()}function getData(element,name){if(isObject(element[name])){return element[name]}if(element.dataset){return element.dataset[name]}return element.getAttribute("data-".concat(toParamCase(name)))}function setData(element,name,data){if(isObject(data)){element[name]=data}else if(element.dataset){element.dataset[name]=data}else{element.setAttribute("data-".concat(toParamCase(name)),data)}}function removeData(element,name){if(isObject(element[name])){try{delete element[name]}catch(error){element[name]=void 0}}else if(element.dataset){try{delete element.dataset[name]}catch(error){element.dataset[name]=void 0}}else{element.removeAttribute("data-".concat(toParamCase(name)))}}var REGEXP_SPACES=/\s\s*/;var onceSupported=function(){var supported=false;if(IS_BROWSER){var once=false;var listener=function listener2(){};var options=Object.defineProperty({},"once",{get:function get(){supported=true;return once},set:function set(value){once=value}});WINDOW.addEventListener("test",listener,options);WINDOW.removeEventListener("test",listener,options)}return supported}();function removeListener(element,type,listener){var options=arguments.length>3&&arguments[3]!==void 0?arguments[3]:{};var handler=listener;type.trim().split(REGEXP_SPACES).forEach(function(event){if(!onceSupported){var listeners=element.listeners;if(listeners&&listeners[event]&&listeners[event][listener]){handler=listeners[event][listener];delete listeners[event][listener];if(Object.keys(listeners[event]).length===0){delete listeners[event]}if(Object.keys(listeners).length===0){delete element.listeners}}}element.removeEventListener(event,handler,options)})}function addListener(element,type,listener){var options=arguments.length>3&&arguments[3]!==void 0?arguments[3]:{};var _handler=listener;type.trim().split(REGEXP_SPACES).forEach(function(event){if(options.once&&!onceSupported){var _element$listeners=element.listeners,listeners=_element$listeners===void 0?{}:_element$listeners;_handler=function handler(){delete listeners[event][listener];element.removeEventListener(event,_handler,options);for(var _len2=arguments.length,args=new Array(_len2),_key2=0;_key2<_len2;_key2++){args[_key2]=arguments[_key2]}listener.apply(element,args)};if(!listeners[event]){listeners[event]={}}if(listeners[event][listener]){element.removeEventListener(event,listeners[event][listener],options)}listeners[event][listener]=_handler;element.listeners=listeners}element.addEventListener(event,_handler,options)})}function dispatchEvent(element,type,data){var event;if(isFunction(Event)&&isFunction(CustomEvent)){event=new CustomEvent(type,{detail:data,bubbles:true,cancelable:true})}else{event=document.createEvent("CustomEvent");event.initCustomEvent(type,true,true,data)}return element.dispatchEvent(event)}function getOffset(element){var box=element.getBoundingClientRect();return{left:box.left+(window.pageXOffset-document.documentElement.clientLeft),top:box.top+(window.pageYOffset-document.documentElement.clientTop)}}var location2=WINDOW.location;var REGEXP_ORIGINS=/^(\w+:)\/\/([^:/?#]*):?(\d*)/i;function isCrossOriginURL(url){var parts=url.match(REGEXP_ORIGINS);return parts!==null&&(parts[1]!==location2.protocol||parts[2]!==location2.hostname||parts[3]!==location2.port)}function addTimestamp(url){var timestamp="timestamp=".concat(new Date().getTime());return url+(url.indexOf("?")===-1?"?":"&")+timestamp}function getTransforms(_ref){var rotate=_ref.rotate,scaleX=_ref.scaleX,scaleY=_ref.scaleY,translateX=_ref.translateX,translateY=_ref.translateY;var values=[];if(isNumber(translateX)&&translateX!==0){values.push("translateX(".concat(translateX,"px)"))}if(isNumber(translateY)&&translateY!==0){values.push("translateY(".concat(translateY,"px)"))}if(isNumber(rotate)&&rotate!==0){values.push("rotate(".concat(rotate,"deg)"))}if(isNumber(scaleX)&&scaleX!==1){values.push("scaleX(".concat(scaleX,")"))}if(isNumber(scaleY)&&scaleY!==1){values.push("scaleY(".concat(scaleY,")"))}var transform=values.length?values.join(" "):"none";return{WebkitTransform:transform,msTransform:transform,transform:transform}}function getMaxZoomRatio(pointers){var pointers2=_objectSpread2({},pointers);var maxRatio=0;forEach(pointers,function(pointer,pointerId){delete pointers2[pointerId];forEach(pointers2,function(pointer2){var x1=Math.abs(pointer.startX-pointer2.startX);var y1=Math.abs(pointer.startY-pointer2.startY);var x2=Math.abs(pointer.endX-pointer2.endX);var y2=Math.abs(pointer.endY-pointer2.endY);var z1=Math.sqrt(x1*x1+y1*y1);var z2=Math.sqrt(x2*x2+y2*y2);var ratio=(z2-z1)/z1;if(Math.abs(ratio)>Math.abs(maxRatio)){maxRatio=ratio}})});return maxRatio}function getPointer(_ref2,endOnly){var pageX=_ref2.pageX,pageY=_ref2.pageY;var end={endX:pageX,endY:pageY};return endOnly?end:_objectSpread2({startX:pageX,startY:pageY},end)}function getPointersCenter(pointers){var pageX=0;var pageY=0;var count=0;forEach(pointers,function(_ref3){var startX=_ref3.startX,startY=_ref3.startY;pageX+=startX;pageY+=startY;count+=1});pageX/=count;pageY/=count;return{pageX:pageX,pageY:pageY}}function getAdjustedSizes(_ref4){var aspectRatio=_ref4.aspectRatio,height=_ref4.height,width=_ref4.width;var type=arguments.length>1&&arguments[1]!==void 0?arguments[1]:"contain";var isValidWidth=isPositiveNumber(width);var isValidHeight=isPositiveNumber(height);if(isValidWidth&&isValidHeight){var adjustedWidth=height*aspectRatio;if(type==="contain"&&adjustedWidth>width||type==="cover"&&adjustedWidth90?{width:newHeight,height:newWidth}:{width:newWidth,height:newHeight}}function getSourceCanvas(image,_ref6,_ref7,_ref8){var imageAspectRatio=_ref6.aspectRatio,imageNaturalWidth=_ref6.naturalWidth,imageNaturalHeight=_ref6.naturalHeight,_ref6$rotate=_ref6.rotate,rotate=_ref6$rotate===void 0?0:_ref6$rotate,_ref6$scaleX=_ref6.scaleX,scaleX=_ref6$scaleX===void 0?1:_ref6$scaleX,_ref6$scaleY=_ref6.scaleY,scaleY=_ref6$scaleY===void 0?1:_ref6$scaleY;var aspectRatio=_ref7.aspectRatio,naturalWidth=_ref7.naturalWidth,naturalHeight=_ref7.naturalHeight;var _ref8$fillColor=_ref8.fillColor,fillColor=_ref8$fillColor===void 0?"transparent":_ref8$fillColor,_ref8$imageSmoothingE=_ref8.imageSmoothingEnabled,imageSmoothingEnabled=_ref8$imageSmoothingE===void 0?true:_ref8$imageSmoothingE,_ref8$imageSmoothingQ=_ref8.imageSmoothingQuality,imageSmoothingQuality=_ref8$imageSmoothingQ===void 0?"low":_ref8$imageSmoothingQ,_ref8$maxWidth=_ref8.maxWidth,maxWidth=_ref8$maxWidth===void 0?Infinity:_ref8$maxWidth,_ref8$maxHeight=_ref8.maxHeight,maxHeight=_ref8$maxHeight===void 0?Infinity:_ref8$maxHeight,_ref8$minWidth=_ref8.minWidth,minWidth=_ref8$minWidth===void 0?0:_ref8$minWidth,_ref8$minHeight=_ref8.minHeight,minHeight=_ref8$minHeight===void 0?0:_ref8$minHeight;var canvas=document.createElement("canvas");var context=canvas.getContext("2d");var maxSizes=getAdjustedSizes({aspectRatio:aspectRatio,width:maxWidth,height:maxHeight});var minSizes=getAdjustedSizes({aspectRatio:aspectRatio,width:minWidth,height:minHeight},"cover");var width=Math.min(maxSizes.width,Math.max(minSizes.width,naturalWidth));var height=Math.min(maxSizes.height,Math.max(minSizes.height,naturalHeight));var destMaxSizes=getAdjustedSizes({aspectRatio:imageAspectRatio,width:maxWidth,height:maxHeight});var destMinSizes=getAdjustedSizes({aspectRatio:imageAspectRatio,width:minWidth,height:minHeight},"cover");var destWidth=Math.min(destMaxSizes.width,Math.max(destMinSizes.width,imageNaturalWidth));var destHeight=Math.min(destMaxSizes.height,Math.max(destMinSizes.height,imageNaturalHeight));var params=[-destWidth/2,-destHeight/2,destWidth,destHeight];canvas.width=normalizeDecimalNumber(width);canvas.height=normalizeDecimalNumber(height);context.fillStyle=fillColor;context.fillRect(0,0,width,height);context.save();context.translate(width/2,height/2);context.rotate(rotate*Math.PI/180);context.scale(scaleX,scaleY);context.imageSmoothingEnabled=imageSmoothingEnabled;context.imageSmoothingQuality=imageSmoothingQuality;context.drawImage.apply(context,[image].concat(_toConsumableArray(params.map(function(param){return Math.floor(normalizeDecimalNumber(param))}))));context.restore();return canvas}var fromCharCode=String.fromCharCode;function getStringFromCharCode(dataView,start,length){var str="";length+=start;for(var i2=start;i20){chunks.push(fromCharCode.apply(null,toArray(uint8.subarray(0,chunkSize))));uint8=uint8.subarray(chunkSize)}return"data:".concat(mimeType,";base64,").concat(btoa(chunks.join("")))}function resetAndGetOrientation(arrayBuffer){var dataView=new DataView(arrayBuffer);var orientation;try{var littleEndian;var app1Start;var ifdStart;if(dataView.getUint8(0)===255&&dataView.getUint8(1)===216){var length=dataView.byteLength;var offset=2;while(offset+1=8){ifdStart=tiffOffset+firstIFDOffset}}}}}if(ifdStart){var _length=dataView.getUint16(ifdStart,littleEndian);var _offset;var i2;for(i2=0;i2<_length;i2+=1){_offset=ifdStart+i2*12+2;if(dataView.getUint16(_offset,littleEndian)===274){_offset+=8;orientation=dataView.getUint16(_offset,littleEndian);dataView.setUint16(_offset,1,littleEndian);break}}}}catch(error){orientation=1}return orientation}function parseOrientation(orientation){var rotate=0;var scaleX=1;var scaleY=1;switch(orientation){case 2:scaleX=-1;break;case 3:rotate=-180;break;case 4:scaleY=-1;break;case 5:rotate=90;scaleY=-1;break;case 6:rotate=90;break;case 7:rotate=90;scaleX=-1;break;case 8:rotate=-90;break;}return{rotate:rotate,scaleX:scaleX,scaleY:scaleY}}var render={render:function render2(){this.initContainer();this.initCanvas();this.initCropBox();this.renderCanvas();if(this.cropped){this.renderCropBox()}},initContainer:function initContainer(){var element=this.element,options=this.options,container=this.container,cropper=this.cropper;var minWidth=Number(options.minContainerWidth);var minHeight=Number(options.minContainerHeight);addClass(cropper,CLASS_HIDDEN);removeClass(element,CLASS_HIDDEN);var containerData={width:Math.max(container.offsetWidth,minWidth>=0?minWidth:MIN_CONTAINER_WIDTH),height:Math.max(container.offsetHeight,minHeight>=0?minHeight:MIN_CONTAINER_HEIGHT)};this.containerData=containerData;setStyle(cropper,{width:containerData.width,height:containerData.height});addClass(element,CLASS_HIDDEN);removeClass(cropper,CLASS_HIDDEN)},initCanvas:function initCanvas(){var containerData=this.containerData,imageData=this.imageData;var viewMode=this.options.viewMode;var rotated=Math.abs(imageData.rotate)%180===90;var naturalWidth=rotated?imageData.naturalHeight:imageData.naturalWidth;var naturalHeight=rotated?imageData.naturalWidth:imageData.naturalHeight;var aspectRatio=naturalWidth/naturalHeight;var canvasWidth=containerData.width;var canvasHeight=containerData.height;if(containerData.height*aspectRatio>containerData.width){if(viewMode===3){canvasWidth=containerData.height*aspectRatio}else{canvasHeight=containerData.width/aspectRatio}}else if(viewMode===3){canvasHeight=containerData.width/aspectRatio}else{canvasWidth=containerData.height*aspectRatio}var canvasData={aspectRatio:aspectRatio,naturalWidth:naturalWidth,naturalHeight:naturalHeight,width:canvasWidth,height:canvasHeight};this.canvasData=canvasData;this.limited=viewMode===1||viewMode===2;this.limitCanvas(true,true);canvasData.width=Math.min(Math.max(canvasData.width,canvasData.minWidth),canvasData.maxWidth);canvasData.height=Math.min(Math.max(canvasData.height,canvasData.minHeight),canvasData.maxHeight);canvasData.left=(containerData.width-canvasData.width)/2;canvasData.top=(containerData.height-canvasData.height)/2;canvasData.oldLeft=canvasData.left;canvasData.oldTop=canvasData.top;this.initialCanvasData=assign2({},canvasData)},limitCanvas:function limitCanvas(sizeLimited,positionLimited){var options=this.options,containerData=this.containerData,canvasData=this.canvasData,cropBoxData=this.cropBoxData;var viewMode=options.viewMode;var aspectRatio=canvasData.aspectRatio;var cropped=this.cropped&&cropBoxData;if(sizeLimited){var minCanvasWidth=Number(options.minCanvasWidth)||0;var minCanvasHeight=Number(options.minCanvasHeight)||0;if(viewMode>1){minCanvasWidth=Math.max(minCanvasWidth,containerData.width);minCanvasHeight=Math.max(minCanvasHeight,containerData.height);if(viewMode===3){if(minCanvasHeight*aspectRatio>minCanvasWidth){minCanvasWidth=minCanvasHeight*aspectRatio}else{minCanvasHeight=minCanvasWidth/aspectRatio}}}else if(viewMode>0){if(minCanvasWidth){minCanvasWidth=Math.max(minCanvasWidth,cropped?cropBoxData.width:0)}else if(minCanvasHeight){minCanvasHeight=Math.max(minCanvasHeight,cropped?cropBoxData.height:0)}else if(cropped){minCanvasWidth=cropBoxData.width;minCanvasHeight=cropBoxData.height;if(minCanvasHeight*aspectRatio>minCanvasWidth){minCanvasWidth=minCanvasHeight*aspectRatio}else{minCanvasHeight=minCanvasWidth/aspectRatio}}}var _getAdjustedSizes=getAdjustedSizes({aspectRatio:aspectRatio,width:minCanvasWidth,height:minCanvasHeight});minCanvasWidth=_getAdjustedSizes.width;minCanvasHeight=_getAdjustedSizes.height;canvasData.minWidth=minCanvasWidth;canvasData.minHeight=minCanvasHeight;canvasData.maxWidth=Infinity;canvasData.maxHeight=Infinity}if(positionLimited){if(viewMode>(cropped?0:1)){var newCanvasLeft=containerData.width-canvasData.width;var newCanvasTop=containerData.height-canvasData.height;canvasData.minLeft=Math.min(0,newCanvasLeft);canvasData.minTop=Math.min(0,newCanvasTop);canvasData.maxLeft=Math.max(0,newCanvasLeft);canvasData.maxTop=Math.max(0,newCanvasTop);if(cropped&&this.limited){canvasData.minLeft=Math.min(cropBoxData.left,cropBoxData.left+(cropBoxData.width-canvasData.width));canvasData.minTop=Math.min(cropBoxData.top,cropBoxData.top+(cropBoxData.height-canvasData.height));canvasData.maxLeft=cropBoxData.left;canvasData.maxTop=cropBoxData.top;if(viewMode===2){if(canvasData.width>=containerData.width){canvasData.minLeft=Math.min(0,newCanvasLeft);canvasData.maxLeft=Math.max(0,newCanvasLeft)}if(canvasData.height>=containerData.height){canvasData.minTop=Math.min(0,newCanvasTop);canvasData.maxTop=Math.max(0,newCanvasTop)}}}}else{canvasData.minLeft=-canvasData.width;canvasData.minTop=-canvasData.height;canvasData.maxLeft=containerData.width;canvasData.maxTop=containerData.height}}},renderCanvas:function renderCanvas(changed,transformed){var canvasData=this.canvasData,imageData=this.imageData;if(transformed){var _getRotatedSizes=getRotatedSizes({width:imageData.naturalWidth*Math.abs(imageData.scaleX||1),height:imageData.naturalHeight*Math.abs(imageData.scaleY||1),degree:imageData.rotate||0}),naturalWidth=_getRotatedSizes.width,naturalHeight=_getRotatedSizes.height;var width=canvasData.width*(naturalWidth/canvasData.naturalWidth);var height=canvasData.height*(naturalHeight/canvasData.naturalHeight);canvasData.left-=(width-canvasData.width)/2;canvasData.top-=(height-canvasData.height)/2;canvasData.width=width;canvasData.height=height;canvasData.aspectRatio=naturalWidth/naturalHeight;canvasData.naturalWidth=naturalWidth;canvasData.naturalHeight=naturalHeight;this.limitCanvas(true,false)}if(canvasData.width>canvasData.maxWidth||canvasData.widthcanvasData.maxHeight||canvasData.heightcanvasData.width){cropBoxData.height=cropBoxData.width/aspectRatio}else{cropBoxData.width=cropBoxData.height*aspectRatio}}this.cropBoxData=cropBoxData;this.limitCropBox(true,true);cropBoxData.width=Math.min(Math.max(cropBoxData.width,cropBoxData.minWidth),cropBoxData.maxWidth);cropBoxData.height=Math.min(Math.max(cropBoxData.height,cropBoxData.minHeight),cropBoxData.maxHeight);cropBoxData.width=Math.max(cropBoxData.minWidth,cropBoxData.width*autoCropArea);cropBoxData.height=Math.max(cropBoxData.minHeight,cropBoxData.height*autoCropArea);cropBoxData.left=canvasData.left+(canvasData.width-cropBoxData.width)/2;cropBoxData.top=canvasData.top+(canvasData.height-cropBoxData.height)/2;cropBoxData.oldLeft=cropBoxData.left;cropBoxData.oldTop=cropBoxData.top;this.initialCropBoxData=assign2({},cropBoxData)},limitCropBox:function limitCropBox(sizeLimited,positionLimited){var options=this.options,containerData=this.containerData,canvasData=this.canvasData,cropBoxData=this.cropBoxData,limited=this.limited;var aspectRatio=options.aspectRatio;if(sizeLimited){var minCropBoxWidth=Number(options.minCropBoxWidth)||0;var minCropBoxHeight=Number(options.minCropBoxHeight)||0;var maxCropBoxWidth=limited?Math.min(containerData.width,canvasData.width,canvasData.width+canvasData.left,containerData.width-canvasData.left):containerData.width;var maxCropBoxHeight=limited?Math.min(containerData.height,canvasData.height,canvasData.height+canvasData.top,containerData.height-canvasData.top):containerData.height;minCropBoxWidth=Math.min(minCropBoxWidth,containerData.width);minCropBoxHeight=Math.min(minCropBoxHeight,containerData.height);if(aspectRatio){if(minCropBoxWidth&&minCropBoxHeight){if(minCropBoxHeight*aspectRatio>minCropBoxWidth){minCropBoxHeight=minCropBoxWidth/aspectRatio}else{minCropBoxWidth=minCropBoxHeight*aspectRatio}}else if(minCropBoxWidth){minCropBoxHeight=minCropBoxWidth/aspectRatio}else if(minCropBoxHeight){minCropBoxWidth=minCropBoxHeight*aspectRatio}if(maxCropBoxHeight*aspectRatio>maxCropBoxWidth){maxCropBoxHeight=maxCropBoxWidth/aspectRatio}else{maxCropBoxWidth=maxCropBoxHeight*aspectRatio}}cropBoxData.minWidth=Math.min(minCropBoxWidth,maxCropBoxWidth);cropBoxData.minHeight=Math.min(minCropBoxHeight,maxCropBoxHeight);cropBoxData.maxWidth=maxCropBoxWidth;cropBoxData.maxHeight=maxCropBoxHeight}if(positionLimited){if(limited){cropBoxData.minLeft=Math.max(0,canvasData.left);cropBoxData.minTop=Math.max(0,canvasData.top);cropBoxData.maxLeft=Math.min(containerData.width,canvasData.left+canvasData.width)-cropBoxData.width;cropBoxData.maxTop=Math.min(containerData.height,canvasData.top+canvasData.height)-cropBoxData.height}else{cropBoxData.minLeft=0;cropBoxData.minTop=0;cropBoxData.maxLeft=containerData.width-cropBoxData.width;cropBoxData.maxTop=containerData.height-cropBoxData.height}}},renderCropBox:function renderCropBox(){var options=this.options,containerData=this.containerData,cropBoxData=this.cropBoxData;if(cropBoxData.width>cropBoxData.maxWidth||cropBoxData.widthcropBoxData.maxHeight||cropBoxData.height=containerData.width&&cropBoxData.height>=containerData.height?ACTION_MOVE:ACTION_ALL)}setStyle(this.cropBox,assign2({width:cropBoxData.width,height:cropBoxData.height},getTransforms({translateX:cropBoxData.left,translateY:cropBoxData.top})));if(this.cropped&&this.limited){this.limitCanvas(true,true)}if(!this.disabled){this.output()}},output:function output(){this.preview();dispatchEvent(this.element,EVENT_CROP,this.getData())}};var preview={initPreview:function initPreview(){var element=this.element,crossOrigin=this.crossOrigin;var preview2=this.options.preview;var url=crossOrigin?this.crossOriginUrl:this.url;var alt=element.alt||"The image to preview";var image=document.createElement("img");if(crossOrigin){image.crossOrigin=crossOrigin}image.src=url;image.alt=alt;this.viewBox.appendChild(image);this.viewBoxImage=image;if(!preview2){return}var previews=preview2;if(typeof preview2==="string"){previews=element.ownerDocument.querySelectorAll(preview2)}else if(preview2.querySelector){previews=[preview2]}this.previews=previews;forEach(previews,function(el){var img=document.createElement("img");setData(el,DATA_PREVIEW,{width:el.offsetWidth,height:el.offsetHeight,html:el.innerHTML});if(crossOrigin){img.crossOrigin=crossOrigin}img.src=url;img.alt=alt;img.style.cssText="display:block;width:100%;height:auto;min-width:0!important;min-height:0!important;max-width:none!important;max-height:none!important;image-orientation:0deg!important;\"";el.innerHTML="";el.appendChild(img)})},resetPreview:function resetPreview(){forEach(this.previews,function(element){var data=getData(element,DATA_PREVIEW);setStyle(element,{width:data.width,height:data.height});element.innerHTML=data.html;removeData(element,DATA_PREVIEW)})},preview:function preview2(){var imageData=this.imageData,canvasData=this.canvasData,cropBoxData=this.cropBoxData;var cropBoxWidth=cropBoxData.width,cropBoxHeight=cropBoxData.height;var width=imageData.width,height=imageData.height;var left=cropBoxData.left-canvasData.left-imageData.left;var top=cropBoxData.top-canvasData.top-imageData.top;if(!this.cropped||this.disabled){return}setStyle(this.viewBoxImage,assign2({width:width,height:height},getTransforms(assign2({translateX:-left,translateY:-top},imageData))));forEach(this.previews,function(element){var data=getData(element,DATA_PREVIEW);var originalWidth=data.width;var originalHeight=data.height;var newWidth=originalWidth;var newHeight=originalHeight;var ratio=1;if(cropBoxWidth){ratio=originalWidth/cropBoxWidth;newHeight=cropBoxHeight*ratio}if(cropBoxHeight&&newHeight>originalHeight){ratio=originalHeight/cropBoxHeight;newWidth=cropBoxWidth*ratio;newHeight=originalHeight}setStyle(element,{width:newWidth,height:newHeight});setStyle(element.getElementsByTagName("img")[0],assign2({width:width*ratio,height:height*ratio},getTransforms(assign2({translateX:-left*ratio,translateY:-top*ratio},imageData))))})}};var events={bind:function bind(){var element=this.element,options=this.options,cropper=this.cropper;if(isFunction(options.cropstart)){addListener(element,EVENT_CROP_START,options.cropstart)}if(isFunction(options.cropmove)){addListener(element,EVENT_CROP_MOVE,options.cropmove)}if(isFunction(options.cropend)){addListener(element,EVENT_CROP_END,options.cropend)}if(isFunction(options.crop)){addListener(element,EVENT_CROP,options.crop)}if(isFunction(options.zoom)){addListener(element,EVENT_ZOOM,options.zoom)}addListener(cropper,EVENT_POINTER_DOWN,this.onCropStart=this.cropStart.bind(this));if(options.zoomable&&options.zoomOnWheel){addListener(cropper,EVENT_WHEEL,this.onWheel=this.wheel.bind(this),{passive:false,capture:true})}if(options.toggleDragModeOnDblclick){addListener(cropper,EVENT_DBLCLICK,this.onDblclick=this.dblclick.bind(this))}addListener(element.ownerDocument,EVENT_POINTER_MOVE,this.onCropMove=this.cropMove.bind(this));addListener(element.ownerDocument,EVENT_POINTER_UP,this.onCropEnd=this.cropEnd.bind(this));if(options.responsive){addListener(window,EVENT_RESIZE,this.onResize=this.resize.bind(this))}},unbind:function unbind(){var element=this.element,options=this.options,cropper=this.cropper;if(isFunction(options.cropstart)){removeListener(element,EVENT_CROP_START,options.cropstart)}if(isFunction(options.cropmove)){removeListener(element,EVENT_CROP_MOVE,options.cropmove)}if(isFunction(options.cropend)){removeListener(element,EVENT_CROP_END,options.cropend)}if(isFunction(options.crop)){removeListener(element,EVENT_CROP,options.crop)}if(isFunction(options.zoom)){removeListener(element,EVENT_ZOOM,options.zoom)}removeListener(cropper,EVENT_POINTER_DOWN,this.onCropStart);if(options.zoomable&&options.zoomOnWheel){removeListener(cropper,EVENT_WHEEL,this.onWheel,{passive:false,capture:true})}if(options.toggleDragModeOnDblclick){removeListener(cropper,EVENT_DBLCLICK,this.onDblclick)}removeListener(element.ownerDocument,EVENT_POINTER_MOVE,this.onCropMove);removeListener(element.ownerDocument,EVENT_POINTER_UP,this.onCropEnd);if(options.responsive){removeListener(window,EVENT_RESIZE,this.onResize)}}};var handlers={resize:function resize(){if(this.disabled){return}var options=this.options,container=this.container,containerData=this.containerData;var ratioX=container.offsetWidth/containerData.width;var ratioY=container.offsetHeight/containerData.height;var ratio=Math.abs(ratioX-1)>Math.abs(ratioY-1)?ratioX:ratioY;if(ratio!==1){var canvasData;var cropBoxData;if(options.restore){canvasData=this.getCanvasData();cropBoxData=this.getCropBoxData()}this.render();if(options.restore){this.setCanvasData(forEach(canvasData,function(n,i2){canvasData[i2]=n*ratio}));this.setCropBoxData(forEach(cropBoxData,function(n,i2){cropBoxData[i2]=n*ratio}))}}},dblclick:function dblclick(){if(this.disabled||this.options.dragMode===DRAG_MODE_NONE){return}this.setDragMode(hasClass(this.dragBox,CLASS_CROP)?DRAG_MODE_MOVE:DRAG_MODE_CROP)},wheel:function wheel(event){var _this=this;var ratio=Number(this.options.wheelZoomRatio)||0.1;var delta=1;if(this.disabled){return}event.preventDefault();if(this.wheeling){return}this.wheeling=true;setTimeout(function(){_this.wheeling=false},50);if(event.deltaY){delta=event.deltaY>0?1:-1}else if(event.wheelDelta){delta=-event.wheelDelta/120}else if(event.detail){delta=event.detail>0?1:-1}this.zoom(-delta*ratio,event)},cropStart:function cropStart(event){var buttons=event.buttons,button=event.button;if(this.disabled||(event.type==="mousedown"||event.type==="pointerdown"&&event.pointerType==="mouse")&&(isNumber(buttons)&&buttons!==1||isNumber(button)&&button!==0||event.ctrlKey)){return}var options=this.options,pointers=this.pointers;var action;if(event.changedTouches){forEach(event.changedTouches,function(touch){pointers[touch.identifier]=getPointer(touch)})}else{pointers[event.pointerId||0]=getPointer(event)}if(Object.keys(pointers).length>1&&options.zoomable&&options.zoomOnTouch){action=ACTION_ZOOM}else{action=getData(event.target,DATA_ACTION)}if(!REGEXP_ACTIONS.test(action)){return}if(dispatchEvent(this.element,EVENT_CROP_START,{originalEvent:event,action:action})===false){return}event.preventDefault();this.action=action;this.cropping=false;if(action===ACTION_CROP){this.cropping=true;addClass(this.dragBox,CLASS_MODAL)}},cropMove:function cropMove(event){var action=this.action;if(this.disabled||!action){return}var pointers=this.pointers;event.preventDefault();if(dispatchEvent(this.element,EVENT_CROP_MOVE,{originalEvent:event,action:action})===false){return}if(event.changedTouches){forEach(event.changedTouches,function(touch){assign2(pointers[touch.identifier]||{},getPointer(touch,true))})}else{assign2(pointers[event.pointerId||0]||{},getPointer(event,true))}this.change(event)},cropEnd:function cropEnd(event){if(this.disabled){return}var action=this.action,pointers=this.pointers;if(event.changedTouches){forEach(event.changedTouches,function(touch){delete pointers[touch.identifier]})}else{delete pointers[event.pointerId||0]}if(!action){return}event.preventDefault();if(!Object.keys(pointers).length){this.action=""}if(this.cropping){this.cropping=false;toggleClass(this.dragBox,CLASS_MODAL,this.cropped&&this.options.modal)}dispatchEvent(this.element,EVENT_CROP_END,{originalEvent:event,action:action})}};var change={change:function change2(event){var options=this.options,canvasData=this.canvasData,containerData=this.containerData,cropBoxData=this.cropBoxData,pointers=this.pointers;var action=this.action;var aspectRatio=options.aspectRatio;var left=cropBoxData.left,top=cropBoxData.top,width=cropBoxData.width,height=cropBoxData.height;var right=left+width;var bottom=top+height;var minLeft=0;var minTop=0;var maxWidth=containerData.width;var maxHeight=containerData.height;var renderable=true;var offset;if(!aspectRatio&&event.shiftKey){aspectRatio=width&&height?width/height:1}if(this.limited){minLeft=cropBoxData.minLeft;minTop=cropBoxData.minTop;maxWidth=minLeft+Math.min(containerData.width,canvasData.width,canvasData.left+canvasData.width);maxHeight=minTop+Math.min(containerData.height,canvasData.height,canvasData.top+canvasData.height)}var pointer=pointers[Object.keys(pointers)[0]];var range={x:pointer.endX-pointer.startX,y:pointer.endY-pointer.startY};var check=function check2(side){switch(side){case ACTION_EAST:if(right+range.x>maxWidth){range.x=maxWidth-right}break;case ACTION_WEST:if(left+range.xmaxHeight){range.y=maxHeight-bottom}break;}};switch(action){case ACTION_ALL:left+=range.x;top+=range.y;break;case ACTION_EAST:if(range.x>=0&&(right>=maxWidth||aspectRatio&&(top<=minTop||bottom>=maxHeight))){renderable=false;break}check(ACTION_EAST);width+=range.x;if(width<0){action=ACTION_WEST;width=-width;left-=width}if(aspectRatio){height=width/aspectRatio;top+=(cropBoxData.height-height)/2}break;case ACTION_NORTH:if(range.y<=0&&(top<=minTop||aspectRatio&&(left<=minLeft||right>=maxWidth))){renderable=false;break}check(ACTION_NORTH);height-=range.y;top+=range.y;if(height<0){action=ACTION_SOUTH;height=-height;top-=height}if(aspectRatio){width=height*aspectRatio;left+=(cropBoxData.width-width)/2}break;case ACTION_WEST:if(range.x<=0&&(left<=minLeft||aspectRatio&&(top<=minTop||bottom>=maxHeight))){renderable=false;break}check(ACTION_WEST);width-=range.x;left+=range.x;if(width<0){action=ACTION_EAST;width=-width;left-=width}if(aspectRatio){height=width/aspectRatio;top+=(cropBoxData.height-height)/2}break;case ACTION_SOUTH:if(range.y>=0&&(bottom>=maxHeight||aspectRatio&&(left<=minLeft||right>=maxWidth))){renderable=false;break}check(ACTION_SOUTH);height+=range.y;if(height<0){action=ACTION_NORTH;height=-height;top-=height}if(aspectRatio){width=height*aspectRatio;left+=(cropBoxData.width-width)/2}break;case ACTION_NORTH_EAST:if(aspectRatio){if(range.y<=0&&(top<=minTop||right>=maxWidth)){renderable=false;break}check(ACTION_NORTH);height-=range.y;top+=range.y;width=height*aspectRatio}else{check(ACTION_NORTH);check(ACTION_EAST);if(range.x>=0){if(rightminTop){height-=range.y;top+=range.y}}else{height-=range.y;top+=range.y}}if(width<0&&height<0){action=ACTION_SOUTH_WEST;height=-height;width=-width;top-=height;left-=width}else if(width<0){action=ACTION_NORTH_WEST;width=-width;left-=width}else if(height<0){action=ACTION_SOUTH_EAST;height=-height;top-=height}break;case ACTION_NORTH_WEST:if(aspectRatio){if(range.y<=0&&(top<=minTop||left<=minLeft)){renderable=false;break}check(ACTION_NORTH);height-=range.y;top+=range.y;width=height*aspectRatio;left+=cropBoxData.width-width}else{check(ACTION_NORTH);check(ACTION_WEST);if(range.x<=0){if(left>minLeft){width-=range.x;left+=range.x}else if(range.y<=0&&top<=minTop){renderable=false}}else{width-=range.x;left+=range.x}if(range.y<=0){if(top>minTop){height-=range.y;top+=range.y}}else{height-=range.y;top+=range.y}}if(width<0&&height<0){action=ACTION_SOUTH_EAST;height=-height;width=-width;top-=height;left-=width}else if(width<0){action=ACTION_NORTH_EAST;width=-width;left-=width}else if(height<0){action=ACTION_SOUTH_WEST;height=-height;top-=height}break;case ACTION_SOUTH_WEST:if(aspectRatio){if(range.x<=0&&(left<=minLeft||bottom>=maxHeight)){renderable=false;break}check(ACTION_WEST);width-=range.x;left+=range.x;height=width/aspectRatio}else{check(ACTION_SOUTH);check(ACTION_WEST);if(range.x<=0){if(left>minLeft){width-=range.x;left+=range.x}else if(range.y>=0&&bottom>=maxHeight){renderable=false}}else{width-=range.x;left+=range.x}if(range.y>=0){if(bottom=0&&(right>=maxWidth||bottom>=maxHeight)){renderable=false;break}check(ACTION_EAST);width+=range.x;height=width/aspectRatio}else{check(ACTION_SOUTH);check(ACTION_EAST);if(range.x>=0){if(right=0&&bottom>=maxHeight){renderable=false}}else{width+=range.x}if(range.y>=0){if(bottom0){action=range.y>0?ACTION_SOUTH_EAST:ACTION_NORTH_EAST}else if(range.x<0){left-=width;action=range.y>0?ACTION_SOUTH_WEST:ACTION_NORTH_WEST}if(range.y<0){top-=height}if(!this.cropped){removeClass(this.cropBox,CLASS_HIDDEN);this.cropped=true;if(this.limited){this.limitCropBox(true,true)}}break;}if(renderable){cropBoxData.width=width;cropBoxData.height=height;cropBoxData.left=left;cropBoxData.top=top;this.action=action;this.renderCropBox()}forEach(pointers,function(p){p.startX=p.endX;p.startY=p.endY})}};var methods={crop:function crop(){if(this.ready&&!this.cropped&&!this.disabled){this.cropped=true;this.limitCropBox(true,true);if(this.options.modal){addClass(this.dragBox,CLASS_MODAL)}removeClass(this.cropBox,CLASS_HIDDEN);this.setCropBoxData(this.initialCropBoxData)}return this},reset:function reset(){if(this.ready&&!this.disabled){this.imageData=assign2({},this.initialImageData);this.canvasData=assign2({},this.initialCanvasData);this.cropBoxData=assign2({},this.initialCropBoxData);this.renderCanvas();if(this.cropped){this.renderCropBox()}}return this},clear:function clear(){if(this.cropped&&!this.disabled){assign2(this.cropBoxData,{left:0,top:0,width:0,height:0});this.cropped=false;this.renderCropBox();this.limitCanvas(true,true);this.renderCanvas();removeClass(this.dragBox,CLASS_MODAL);addClass(this.cropBox,CLASS_HIDDEN)}return this},replace:function replace(url){var hasSameSize=arguments.length>1&&arguments[1]!==void 0?arguments[1]:false;if(!this.disabled&&url){if(this.isImg){this.element.src=url}if(hasSameSize){this.url=url;this.image.src=url;if(this.ready){this.viewBoxImage.src=url;forEach(this.previews,function(element){element.getElementsByTagName("img")[0].src=url})}}else{if(this.isImg){this.replaced=true}this.options.data=null;this.uncreate();this.load(url)}}return this},enable:function enable(){if(this.ready&&this.disabled){this.disabled=false;removeClass(this.cropper,CLASS_DISABLED)}return this},disable:function disable(){if(this.ready&&!this.disabled){this.disabled=true;addClass(this.cropper,CLASS_DISABLED)}return this},destroy:function destroy(){var element=this.element;if(!element[NAMESPACE]){return this}element[NAMESPACE]=void 0;if(this.isImg&&this.replaced){element.src=this.originalUrl}this.uncreate();return this},move:function move(offsetX){var offsetY=arguments.length>1&&arguments[1]!==void 0?arguments[1]:offsetX;var _this$canvasData=this.canvasData,left=_this$canvasData.left,top=_this$canvasData.top;return this.moveTo(isUndefined(offsetX)?offsetX:left+Number(offsetX),isUndefined(offsetY)?offsetY:top+Number(offsetY))},moveTo:function moveTo(x){var y=arguments.length>1&&arguments[1]!==void 0?arguments[1]:x;var canvasData=this.canvasData;var changed=false;x=Number(x);y=Number(y);if(this.ready&&!this.disabled&&this.options.movable){if(isNumber(x)){canvasData.left=x;changed=true}if(isNumber(y)){canvasData.top=y;changed=true}if(changed){this.renderCanvas(true)}}return this},zoom:function zoom(ratio,_originalEvent){var canvasData=this.canvasData;ratio=Number(ratio);if(ratio<0){ratio=1/(1-ratio)}else{ratio=1+ratio}return this.zoomTo(canvasData.width*ratio/canvasData.naturalWidth,null,_originalEvent)},zoomTo:function zoomTo(ratio,pivot,_originalEvent){var options=this.options,canvasData=this.canvasData;var width=canvasData.width,height=canvasData.height,naturalWidth=canvasData.naturalWidth,naturalHeight=canvasData.naturalHeight;ratio=Number(ratio);if(ratio>=0&&this.ready&&!this.disabled&&options.zoomable){var newWidth=naturalWidth*ratio;var newHeight=naturalHeight*ratio;if(dispatchEvent(this.element,EVENT_ZOOM,{ratio:ratio,oldRatio:width/naturalWidth,originalEvent:_originalEvent})===false){return this}if(_originalEvent){var pointers=this.pointers;var offset=getOffset(this.cropper);var center=pointers&&Object.keys(pointers).length?getPointersCenter(pointers):{pageX:_originalEvent.pageX,pageY:_originalEvent.pageY};canvasData.left-=(newWidth-width)*((center.pageX-offset.left-canvasData.left)/width);canvasData.top-=(newHeight-height)*((center.pageY-offset.top-canvasData.top)/height)}else if(isPlainObject(pivot)&&isNumber(pivot.x)&&isNumber(pivot.y)){canvasData.left-=(newWidth-width)*((pivot.x-canvasData.left)/width);canvasData.top-=(newHeight-height)*((pivot.y-canvasData.top)/height)}else{canvasData.left-=(newWidth-width)/2;canvasData.top-=(newHeight-height)/2}canvasData.width=newWidth;canvasData.height=newHeight;this.renderCanvas(true)}return this},rotate:function rotate(degree){return this.rotateTo((this.imageData.rotate||0)+Number(degree))},rotateTo:function rotateTo(degree){degree=Number(degree);if(isNumber(degree)&&this.ready&&!this.disabled&&this.options.rotatable){this.imageData.rotate=degree%360;this.renderCanvas(true,true)}return this},scaleX:function scaleX(_scaleX){var scaleY=this.imageData.scaleY;return this.scale(_scaleX,isNumber(scaleY)?scaleY:1)},scaleY:function scaleY(_scaleY){var scaleX=this.imageData.scaleX;return this.scale(isNumber(scaleX)?scaleX:1,_scaleY)},scale:function scale(scaleX){var scaleY=arguments.length>1&&arguments[1]!==void 0?arguments[1]:scaleX;var imageData=this.imageData;var transformed=false;scaleX=Number(scaleX);scaleY=Number(scaleY);if(this.ready&&!this.disabled&&this.options.scalable){if(isNumber(scaleX)){imageData.scaleX=scaleX;transformed=true}if(isNumber(scaleY)){imageData.scaleY=scaleY;transformed=true}if(transformed){this.renderCanvas(true,true)}}return this},getData:function getData2(){var rounded=arguments.length>0&&arguments[0]!==void 0?arguments[0]:false;var options=this.options,imageData=this.imageData,canvasData=this.canvasData,cropBoxData=this.cropBoxData;var data;if(this.ready&&this.cropped){data={x:cropBoxData.left-canvasData.left,y:cropBoxData.top-canvasData.top,width:cropBoxData.width,height:cropBoxData.height};var ratio=imageData.width/imageData.naturalWidth;forEach(data,function(n,i2){data[i2]=n/ratio});if(rounded){var bottom=Math.round(data.y+data.height);var right=Math.round(data.x+data.width);data.x=Math.round(data.x);data.y=Math.round(data.y);data.width=right-data.x;data.height=bottom-data.y}}else{data={x:0,y:0,width:0,height:0}}if(options.rotatable){data.rotate=imageData.rotate||0}if(options.scalable){data.scaleX=imageData.scaleX||1;data.scaleY=imageData.scaleY||1}return data},setData:function setData2(data){var options=this.options,imageData=this.imageData,canvasData=this.canvasData;var cropBoxData={};if(this.ready&&!this.disabled&&isPlainObject(data)){var transformed=false;if(options.rotatable){if(isNumber(data.rotate)&&data.rotate!==imageData.rotate){imageData.rotate=data.rotate;transformed=true}}if(options.scalable){if(isNumber(data.scaleX)&&data.scaleX!==imageData.scaleX){imageData.scaleX=data.scaleX;transformed=true}if(isNumber(data.scaleY)&&data.scaleY!==imageData.scaleY){imageData.scaleY=data.scaleY;transformed=true}}if(transformed){this.renderCanvas(true,true)}var ratio=imageData.width/imageData.naturalWidth;if(isNumber(data.x)){cropBoxData.left=data.x*ratio+canvasData.left}if(isNumber(data.y)){cropBoxData.top=data.y*ratio+canvasData.top}if(isNumber(data.width)){cropBoxData.width=data.width*ratio}if(isNumber(data.height)){cropBoxData.height=data.height*ratio}this.setCropBoxData(cropBoxData)}return this},getContainerData:function getContainerData(){return this.ready?assign2({},this.containerData):{}},getImageData:function getImageData(){return this.sized?assign2({},this.imageData):{}},getCanvasData:function getCanvasData(){var canvasData=this.canvasData;var data={};if(this.ready){forEach(["left","top","width","height","naturalWidth","naturalHeight"],function(n){data[n]=canvasData[n]})}return data},setCanvasData:function setCanvasData(data){var canvasData=this.canvasData;var aspectRatio=canvasData.aspectRatio;if(this.ready&&!this.disabled&&isPlainObject(data)){if(isNumber(data.left)){canvasData.left=data.left}if(isNumber(data.top)){canvasData.top=data.top}if(isNumber(data.width)){canvasData.width=data.width;canvasData.height=data.width/aspectRatio}else if(isNumber(data.height)){canvasData.height=data.height;canvasData.width=data.height*aspectRatio}this.renderCanvas(true)}return this},getCropBoxData:function getCropBoxData(){var cropBoxData=this.cropBoxData;var data;if(this.ready&&this.cropped){data={left:cropBoxData.left,top:cropBoxData.top,width:cropBoxData.width,height:cropBoxData.height}}return data||{}},setCropBoxData:function setCropBoxData(data){var cropBoxData=this.cropBoxData;var aspectRatio=this.options.aspectRatio;var widthChanged;var heightChanged;if(this.ready&&this.cropped&&!this.disabled&&isPlainObject(data)){if(isNumber(data.left)){cropBoxData.left=data.left}if(isNumber(data.top)){cropBoxData.top=data.top}if(isNumber(data.width)&&data.width!==cropBoxData.width){widthChanged=true;cropBoxData.width=data.width}if(isNumber(data.height)&&data.height!==cropBoxData.height){heightChanged=true;cropBoxData.height=data.height}if(aspectRatio){if(widthChanged){cropBoxData.height=cropBoxData.width/aspectRatio}else if(heightChanged){cropBoxData.width=cropBoxData.height*aspectRatio}}this.renderCropBox()}return this},getCroppedCanvas:function getCroppedCanvas(){var options=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};if(!this.ready||!window.HTMLCanvasElement){return null}var canvasData=this.canvasData;var source=getSourceCanvas(this.image,this.imageData,canvasData,options);if(!this.cropped){return source}var _this$getData=this.getData(),initialX=_this$getData.x,initialY=_this$getData.y,initialWidth=_this$getData.width,initialHeight=_this$getData.height;var ratio=source.width/Math.floor(canvasData.naturalWidth);if(ratio!==1){initialX*=ratio;initialY*=ratio;initialWidth*=ratio;initialHeight*=ratio}var aspectRatio=initialWidth/initialHeight;var maxSizes=getAdjustedSizes({aspectRatio:aspectRatio,width:options.maxWidth||Infinity,height:options.maxHeight||Infinity});var minSizes=getAdjustedSizes({aspectRatio:aspectRatio,width:options.minWidth||0,height:options.minHeight||0},"cover");var _getAdjustedSizes=getAdjustedSizes({aspectRatio:aspectRatio,width:options.width||(ratio!==1?source.width:initialWidth),height:options.height||(ratio!==1?source.height:initialHeight)}),width=_getAdjustedSizes.width,height=_getAdjustedSizes.height;width=Math.min(maxSizes.width,Math.max(minSizes.width,width));height=Math.min(maxSizes.height,Math.max(minSizes.height,height));var canvas=document.createElement("canvas");var context=canvas.getContext("2d");canvas.width=normalizeDecimalNumber(width);canvas.height=normalizeDecimalNumber(height);context.fillStyle=options.fillColor||"transparent";context.fillRect(0,0,width,height);var _options$imageSmoothi=options.imageSmoothingEnabled,imageSmoothingEnabled=_options$imageSmoothi===void 0?true:_options$imageSmoothi,imageSmoothingQuality=options.imageSmoothingQuality;context.imageSmoothingEnabled=imageSmoothingEnabled;if(imageSmoothingQuality){context.imageSmoothingQuality=imageSmoothingQuality}var sourceWidth=source.width;var sourceHeight=source.height;var srcX=initialX;var srcY=initialY;var srcWidth;var srcHeight;var dstX;var dstY;var dstWidth;var dstHeight;if(srcX<=-initialWidth||srcX>sourceWidth){srcX=0;srcWidth=0;dstX=0;dstWidth=0}else if(srcX<=0){dstX=-srcX;srcX=0;srcWidth=Math.min(sourceWidth,initialWidth+srcX);dstWidth=srcWidth}else if(srcX<=sourceWidth){dstX=0;srcWidth=Math.min(initialWidth,sourceWidth-srcX);dstWidth=srcWidth}if(srcWidth<=0||srcY<=-initialHeight||srcY>sourceHeight){srcY=0;srcHeight=0;dstY=0;dstHeight=0}else if(srcY<=0){dstY=-srcY;srcY=0;srcHeight=Math.min(sourceHeight,initialHeight+srcY);dstHeight=srcHeight}else if(srcY<=sourceHeight){dstY=0;srcHeight=Math.min(initialHeight,sourceHeight-srcY);dstHeight=srcHeight}var params=[srcX,srcY,srcWidth,srcHeight];if(dstWidth>0&&dstHeight>0){var scale=width/initialWidth;params.push(dstX*scale,dstY*scale,dstWidth*scale,dstHeight*scale)}context.drawImage.apply(context,[source].concat(_toConsumableArray(params.map(function(param){return Math.floor(normalizeDecimalNumber(param))}))));return canvas},setAspectRatio:function setAspectRatio(aspectRatio){var options=this.options;if(!this.disabled&&!isUndefined(aspectRatio)){options.aspectRatio=Math.max(0,aspectRatio)||NaN;if(this.ready){this.initCropBox();if(this.cropped){this.renderCropBox()}}}return this},setDragMode:function setDragMode(mode){var options=this.options,dragBox=this.dragBox,face=this.face;if(this.ready&&!this.disabled){var croppable=mode===DRAG_MODE_CROP;var movable=options.movable&&mode===DRAG_MODE_MOVE;mode=croppable||movable?mode:DRAG_MODE_NONE;options.dragMode=mode;setData(dragBox,DATA_ACTION,mode);toggleClass(dragBox,CLASS_CROP,croppable);toggleClass(dragBox,CLASS_MOVE,movable);if(!options.cropBoxMovable){setData(face,DATA_ACTION,mode);toggleClass(face,CLASS_CROP,croppable);toggleClass(face,CLASS_MOVE,movable)}}return this}};var AnotherCropper=WINDOW.Cropper;var Cropper2=/* @__PURE__ */function(){function Cropper3(element){var options=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};_classCallCheck(this,Cropper3);if(!element||!REGEXP_TAG_NAME.test(element.tagName)){throw new Error("The first argument is required and must be an or element.")}this.element=element;this.options=assign2({},DEFAULTS,isPlainObject(options)&&options);this.cropped=false;this.disabled=false;this.pointers={};this.ready=false;this.reloading=false;this.replaced=false;this.sized=false;this.sizing=false;this.init()}_createClass(Cropper3,[{key:"init",value:function init2(){var element=this.element;var tagName=element.tagName.toLowerCase();var url;if(element[NAMESPACE]){return}element[NAMESPACE]=this;if(tagName==="img"){this.isImg=true;url=element.getAttribute("src")||"";this.originalUrl=url;if(!url){return}url=element.src}else if(tagName==="canvas"&&window.HTMLCanvasElement){url=element.toDataURL()}this.load(url)}},{key:"load",value:function load(url){var _this=this;if(!url){return}this.url=url;this.imageData={};var element=this.element,options=this.options;if(!options.rotatable&&!options.scalable){options.checkOrientation=false}if(!options.checkOrientation||!window.ArrayBuffer){this.clone();return}if(REGEXP_DATA_URL.test(url)){if(REGEXP_DATA_URL_JPEG.test(url)){this.read(dataURLToArrayBuffer(url))}else{this.clone()}return}var xhr=new XMLHttpRequest;var clone=this.clone.bind(this);this.reloading=true;this.xhr=xhr;xhr.onabort=clone;xhr.onerror=clone;xhr.ontimeout=clone;xhr.onprogress=function(){if(xhr.getResponseHeader("content-type")!==MIME_TYPE_JPEG){xhr.abort()}};xhr.onload=function(){_this.read(xhr.response)};xhr.onloadend=function(){_this.reloading=false;_this.xhr=null};if(options.checkCrossOrigin&&isCrossOriginURL(url)&&element.crossOrigin){url=addTimestamp(url)}xhr.open("GET",url,true);xhr.responseType="arraybuffer";xhr.withCredentials=element.crossOrigin==="use-credentials";xhr.send()}},{key:"read",value:function read(arrayBuffer){var options=this.options,imageData=this.imageData;var orientation=resetAndGetOrientation(arrayBuffer);var rotate=0;var scaleX=1;var scaleY=1;if(orientation>1){this.url=arrayBufferToDataURL(arrayBuffer,MIME_TYPE_JPEG);var _parseOrientation=parseOrientation(orientation);rotate=_parseOrientation.rotate;scaleX=_parseOrientation.scaleX;scaleY=_parseOrientation.scaleY}if(options.rotatable){imageData.rotate=rotate}if(options.scalable){imageData.scaleX=scaleX;imageData.scaleY=scaleY}this.clone()}},{key:"clone",value:function clone(){var element=this.element,url=this.url;var crossOrigin=element.crossOrigin;var crossOriginUrl=url;if(this.options.checkCrossOrigin&&isCrossOriginURL(url)){if(!crossOrigin){crossOrigin="anonymous"}crossOriginUrl=addTimestamp(url)}this.crossOrigin=crossOrigin;this.crossOriginUrl=crossOriginUrl;var image=document.createElement("img");if(crossOrigin){image.crossOrigin=crossOrigin}image.src=crossOriginUrl||url;image.alt=element.alt||"The image to crop";this.image=image;image.onload=this.start.bind(this);image.onerror=this.stop.bind(this);addClass(image,CLASS_HIDE);element.parentNode.insertBefore(image,element.nextSibling)}},{key:"start",value:function start(){var _this2=this;var image=this.image;image.onload=null;image.onerror=null;this.sizing=true;var isIOSWebKit=WINDOW.navigator&&/(?:iPad|iPhone|iPod).*?AppleWebKit/i.test(WINDOW.navigator.userAgent);var done=function done2(naturalWidth,naturalHeight){assign2(_this2.imageData,{naturalWidth:naturalWidth,naturalHeight:naturalHeight,aspectRatio:naturalWidth/naturalHeight});_this2.initialImageData=assign2({},_this2.imageData);_this2.sizing=false;_this2.sized=true;_this2.build()};if(image.naturalWidth&&!isIOSWebKit){done(image.naturalWidth,image.naturalHeight);return}var sizingImage=document.createElement("img");var body=document.body||document.documentElement;this.sizingImage=sizingImage;sizingImage.onload=function(){done(sizingImage.width,sizingImage.height);if(!isIOSWebKit){body.removeChild(sizingImage)}};sizingImage.src=image.src;if(!isIOSWebKit){sizingImage.style.cssText="left:0;max-height:none!important;max-width:none!important;min-height:0!important;min-width:0!important;opacity:0;position:absolute;top:0;z-index:-1;";body.appendChild(sizingImage)}}},{key:"stop",value:function stop(){var image=this.image;image.onload=null;image.onerror=null;image.parentNode.removeChild(image);this.image=null}},{key:"build",value:function build(){if(!this.sized||this.ready){return}var element=this.element,options=this.options,image=this.image;var container=element.parentNode;var template=document.createElement("div");template.innerHTML=TEMPLATE;var cropper=template.querySelector(".".concat(NAMESPACE,"-container"));var canvas=cropper.querySelector(".".concat(NAMESPACE,"-canvas"));var dragBox=cropper.querySelector(".".concat(NAMESPACE,"-drag-box"));var cropBox=cropper.querySelector(".".concat(NAMESPACE,"-crop-box"));var face=cropBox.querySelector(".".concat(NAMESPACE,"-face"));this.container=container;this.cropper=cropper;this.canvas=canvas;this.dragBox=dragBox;this.cropBox=cropBox;this.viewBox=cropper.querySelector(".".concat(NAMESPACE,"-view-box"));this.face=face;canvas.appendChild(image);addClass(element,CLASS_HIDDEN);container.insertBefore(cropper,element.nextSibling);if(!this.isImg){removeClass(image,CLASS_HIDE)}this.initPreview();this.bind();options.initialAspectRatio=Math.max(0,options.initialAspectRatio)||NaN;options.aspectRatio=Math.max(0,options.aspectRatio)||NaN;options.viewMode=Math.max(0,Math.min(3,Math.round(options.viewMode)))||0;addClass(cropBox,CLASS_HIDDEN);if(!options.guides){addClass(cropBox.getElementsByClassName("".concat(NAMESPACE,"-dashed")),CLASS_HIDDEN)}if(!options.center){addClass(cropBox.getElementsByClassName("".concat(NAMESPACE,"-center")),CLASS_HIDDEN)}if(options.background){addClass(cropper,"".concat(NAMESPACE,"-bg"))}if(!options.highlight){addClass(face,CLASS_INVISIBLE)}if(options.cropBoxMovable){addClass(face,CLASS_MOVE);setData(face,DATA_ACTION,ACTION_ALL)}if(!options.cropBoxResizable){addClass(cropBox.getElementsByClassName("".concat(NAMESPACE,"-line")),CLASS_HIDDEN);addClass(cropBox.getElementsByClassName("".concat(NAMESPACE,"-point")),CLASS_HIDDEN)}this.render();this.ready=true;this.setDragMode(options.dragMode);if(options.autoCrop){this.crop()}this.setData(options.data);if(isFunction(options.ready)){addListener(element,EVENT_READY,options.ready,{once:true})}dispatchEvent(element,EVENT_READY)}},{key:"unbuild",value:function unbuild(){if(!this.ready){return}this.ready=false;this.unbind();this.resetPreview();this.cropper.parentNode.removeChild(this.cropper);removeClass(this.element,CLASS_HIDDEN)}},{key:"uncreate",value:function uncreate(){if(this.ready){this.unbuild();this.ready=false;this.cropped=false}else if(this.sizing){this.sizingImage.onload=null;this.sizing=false;this.sized=false}else if(this.reloading){this.xhr.onabort=null;this.xhr.abort()}else if(this.image){this.stop()}}}],[{key:"noConflict",value:function noConflict(){window.Cropper=AnotherCropper;return Cropper3}},{key:"setDefaults",value:function setDefaults(options){assign2(DEFAULTS,isPlainObject(options)&&options)}}]);return Cropper3}();assign2(Cropper2.prototype,render,preview,events,handlers,change,methods);return Cropper2})}});// app/javascript/src/i18n.coffee I18n.defaultLocale=locale["default"];I18n.locale=locale.current;I18n.scopify=function(scope){return function(label,options){if(label[0]==="."){label="".concat(scope).concat(label)}return I18n.t(label,options)}};// node_modules/js-cookie/dist/js.cookie.mjs function assign(target){for(var i2=1;i20){return $3("#moderate").addClass("mod-pending")}});// app/javascript/src/post.coffee (function($27){var Post2;Post2=function Post2(){this.posts={}};Post2.prototype={registerPosts:function registerPosts(posts){var th;th=this;if(posts.length===1){this.current=posts[0]}posts.forEach(function(p,idx,arr){p.tags=p.tags.match(/\S+/g)||[];p.metatags=p.tags.clone();p.metatags.push("rating:"+p.rating[0]);p.metatags.push("status:"+p.status);th.posts[p.id]=p});return false},get:function get(post_id){return this.posts[post_id]}};$27(function(){var inLargerVersion,post;post=new Post2;inLargerVersion=false;Moe.on("post:add",function(e,data){post.registerPosts(data)});$27(".highres-show").on("click",function(){var h,img,w;img=$27("#image");w=img.attr("large_width");h=img.attr("large_height");if(inLargerVersion){return false}inLargerVersion=true;$27("#resized_notice").hide();img.hide();img.attr("src","");img.attr("width",w);img.attr("height",h);img.attr("src",this.href);img.show();notesManager.all.invoke("adjustScale");return false});$27("#post_tags").on("keydown",function(e){if(e.which===13){e.preventDefault();$27("#edit-form").submit()}})})})(jQuery);// app/javascript/src/vote.coffee var import_mousetrap=__toESM(require_mousetrap(),1);var $4;var FAVORITE;var GOOD;var GREAT;var REMOVE;var getScore;var t;var hasProp={}.hasOwnProperty;$4=jQuery;t=I18n.scopify("js.vote");REMOVE=0;GOOD=1;GREAT=2;FAVORITE=3;getScore=function getScore(star){return parseInt(star.dataset.star,10)};window.Vote=/*#__PURE__*/function(){function Vote2(container,id2){_classCallCheck2(this,Vote2);var nodes;this.set=this.set.bind(this);this.setupEvents=this.setupEvents.bind(this);this.updateWidget=this.updateWidget.bind(this);this.initShortcut=this.initShortcut.bind(this);this.setMouseover=this.setMouseover.bind(this);this.mouseout=this.mouseout.bind(this);this.activateItem=this.activateItem.bind(this);nodes=container.find("*");this.desc=nodes.filter(".vote-desc");this.stars=nodes.filter(".star-off");this.post_score=nodes.filter("#post-score-".concat(id2,", .post-score"));this.vote_up=nodes.filter(".vote-up");this.post_id=id2;this.label=[t(".remove"),t(".good"),t(".great"),t(".fav")];this.setupEvents();this.data={score:null,vote:null}}_createClass2(Vote2,[{key:"set",value:function set(vote){var _this3=this;notice(t(".voting"));return $4.ajax({url:Moebooru.path("/post/vote.json"),data:{id:this.post_id,score:vote},dataType:"json",type:"post",statusCode:{403:function _(){return notice("".concat(t("js.error")).concat(t("js.denied")))}}}).done(function(data){_this3.updateWidget(vote,data.posts[0].score);$4("#favorited-by").html(favorite.linkToUsers(data.voted_by[FAVORITE]));return notice(t(".saved"))})}},{key:"setupEvents",value:function setupEvents(){var _this4=this;this.stars.on("click",function(e){var score;e.preventDefault();score=getScore(e.currentTarget);_this4.set(score)});this.stars.on("mouseover",function(e){return _this4.setMouseover(e.currentTarget)});this.stars.on("mouseout",function(){return _this4.setMouseover(null)});this.vote_up.on("click",function(e){e.preventDefault();if(_this4.vote a").on("click",function(e){e.preventDefault();return _this4.set(FAVORITE)});return $4("#remove-from-favs > a").on("click",function(e){e.preventDefault();return _this4.set(GREAT)})}},{key:"updateWidget",value:function updateWidget(vote,targetScore){var $star,add,i2,len,ref,rm,score,star;add=$4("#add-to-favs");rm=$4("#remove-from-favs");this.vote=vote||0;this.data.score=targetScore;this.data.vote=vote;ref=this.stars;for(i2=0,len=ref.length;i2=0){ret.push(list[idx-distance])}if(idx+distancewindow.innerHeight-10){console.debug("Dragged off the bottom");this.stop_dragging(event,true);return}x=touch.pageX;y=touch.pageY;this.handle_move_event(event,x,y)};DragElement.prototype.handle_move_event=function(event,x,y){var distance,snap_pixels;if(!this.dragging){return}if(!this.dragged){distance=Math.pow(x-this.anchor_x,2)+Math.pow(y-this.anchor_y,2);snap_pixels=this.options.snap_pixels;snap_pixels*=snap_pixels;if(distance512){data=data.slice(0,512)}report+="localStorage."+key+" (size: "+length+"): "+data+"\n"}catch(error1){e=error1;report+="(ignored errors retrieving localStorage for "+key+": "+e+")\n"}++i2}}if(exc&&exc.stack){report+="\n"+exc.stack+"\n"}if(file){report+="File: "+file;if(line!=null){report+=" line "+line+"\n"}}return report};window.reported_error=false;window.ReportError=function(message,file,line,exc,info){var e,expiration,report;if(navigator.userAgent.match(/.*MSIE [67]/)){return}if(window.reported_error){return}window.reported_error=true;if(document.cookie.indexOf("reported_error=1")!==-1){return}expiration=new Date;expiration.setTime(expiration.getTime()+60*60*1e3);document.cookie="reported_error=1; path=/; expires="+expiration.toGMTString();report=FormatError(exc?exc.message:message,file,line,exc,info);try{jQuery.post("/user/error.json",{report:report})}catch(error1){e=error1;alert("Error: "+e)}};window.LocalStorageDisabled=function(){var cleared_storage,e;if(!("localStorage"in window)){return"unsupported"}cleared_storage=false;while(true){try{localStorage.x="1";if(localStorage.x!=="1"){throw"disabled"}delete localStorage.x;return null}catch(error1){e=error1;if(!cleared_storage){cleared_storage=true;try{localStorage.clear()}catch(error12){e=error12}++i;++i;continue}if(navigator.userAgent.indexOf("Gecko/")!==-1){if(e.message.indexOf("Security error")!==-1){return"ff-disabled"}}return"error"}}};if(navigator.userAgent.indexOf("AppleWebKit/")!==-1){document.documentElement.className+=" webkit"}// app/javascript/src/utils/math.coffee var clamp=function clamp(n,min,max){return Math.max(Math.min(n,max),min)};var numberToHumanSize=function numberToHumanSize(size,precision){var text;if(precision==null){precision=1}text=void 0;size=Number(size);if(size.toFixed(0)==="1"){text="1 Byte"}else if(size<1024){text=size.toFixed(0)+" Bytes"}else if(size<1024*1024){text=(size/1024).toFixed(precision)+" KB"}else if(size<1024*1024*1024){text=(size/(1024*1024)).toFixed(precision)+" MB"}else if(size<1024*1024*1024*1024){text=(size/(1024*1024*1024)).toFixed(precision)+" GB"}else{text=(size/(1024*1024*1024*1024)).toFixed(precision)+" TB"}return text.gsub(/([0-9]\.\d*?)0+ /,"#{1} ").gsub(/\. /," ")};// app/javascript/src/legacy/post.coffee window.Post={posts:new Hash,tag_types:new Hash,votes:new Hash,tag_type_names:["general","artist","","copyright","character","circle","faults"],make_request:function make_request(path,params,finished){return jQuery.ajax(path,{data:params,dataType:"json",method:"POST"}).fail(function(xhr){var ref,ref1;return notice("Error: ".concat((ref=(ref1=xhr.responseJSON)!=null?ref1.reason:void 0)!=null?ref:"unknown error"))}).done(function(resp2){Post.register_resp(resp2);if(resp2.posts!=null&&resp2.posts.length>0){jQuery(document).trigger("posts:update",[new Set(resp2.posts.map(function(post){return post.id}))])}return typeof finished==="function"?finished(resp2):void 0})},approve:function approve(post_id,delete_reason,finished){var completion,params;notice("Approving post #"+post_id);params={};params["ids["+post_id+"]"]="1";params["commit"]=delete_reason?"Delete":"Approve";if(delete_reason){params["reason"]=delete_reason}completion=function completion(){notice(delete_reason?"Post deleted":"Post approved");if(finished){finished(post_id)}else{if($("p"+post_id)){$("p"+post_id).removeClassName("pending")}if($("pending-notice")){$("pending-notice").hide()}}};return Post.make_request("/post/moderate.json",params,completion)},undelete:function undelete(post_id,finished){return Post.make_request("/post/undelete.json",{id:post_id},finished)},applied_list:[],reset_tag_script_applied:function reset_tag_script_applied(){var i2;i2=0;while(i2 .directlink");if(element.length>0){element[0].addClassName("tag-script-applied");Post.applied_list.push(element[0])}});notice((original_count===1?"Post":"Posts")+" updated");if(finished){finished(resp2.posts)}};params=params_array.join("&");Post.make_request("/post/update_batch.json",params,complete)},update_styles:function update_styles(post){var e;e=$("p"+post.id);if(!e){return}if(post["has_children"]){e.addClassName("has-children")}else{e.removeClassName("has-children")}if(post["parent_id"]){e.addClassName("has-parent")}else{e.removeClassName("has-parent")}},activate_posts:function activate_posts(postIds,finished){notice("Activating ".concat(postIds.length," ").concat(postIds.length===1?"post":"posts"));return jQuery.ajax("/post/activate.json",{data:{post_ids:postIds},dataType:"json",method:"POST"}).done(finished).fail(function(xhr){var ref,ref1;return notice("Error: ".concat((ref=(ref1=xhr.responseJSON)!=null?ref1.reason:void 0)!=null?ref:"unknown error"))})},activate_all_posts:function activate_all_posts(){var post_ids;post_ids=[];Post.posts.each(function(pair){if($("p"+pair.key)){post_ids.push(pair.key)}});Post.activate_posts(post_ids,function(resp2){if(resp2.count===0){notice("No posts were activated.")}else{notice(resp2.count+(resp2.count===1?" post":" posts")+" activated")}})},activate_post:function activate_post(post_id){Post.update_batch([{id:post_id,is_held:false}],function(){var post;post=Post.posts.get(post_id);if(post.is_held){notice("Couldn't activate post")}else{$("held-notice").remove()}})},init_add_to_favs:function init_add_to_favs(postId,addToFavs,removeFromFavs){var updateAddToFavs;updateAddToFavs=function updateAddToFavs(e,postIds){var vote;if(postIds!=null&&postIds.has(postId)==null){return}vote=Post.votes.get(postId)||0;addToFavs.show(vote<3);removeFromFavs.show(vote>=3)};updateAddToFavs();jQuery(document).on("posts:update",updateAddToFavs)},vote:function vote(post_id,score){if(score>3){return}notice("Voting...");Post.make_request("/post/vote.json",{id:post_id,score:score},function(resp2){notice("Vote saved")})},flag:function flag(id2,finished){var complete,reason;reason=prompt("Why should this post be flagged for deletion?","");if(!reason){return false}complete=function complete(){var e;notice("Post was flagged for deletion");if(finished){finished(id2)}else{e=$("p"+id2);if(e){e.addClassName("flagged")}}};return Post.make_request("/post/flag.json",{"id":id2,"reason":reason},complete)},unflag:function unflag(id2,finished){var complete;complete=function complete(){var e;notice("Post was approved");if(finished){finished(id2)}else{e=$("p"+id2);if(e){e.removeClassName("flagged")}}};return Post.make_request("/post/flag.json",{id:id2,unflag:1},complete)},observe_text_area:function observe_text_area(field_id){$(field_id).observe("keydown",function(e){if(e.keyCode===Event.KEY_RETURN){e.stop();this.up("form").simulate_submit()}})},get_post_tags_by_type:function get_post_tags_by_type(post){var results;results=new Hash;post.tags.each(function(tag){var list,tag_type;tag_type=Post.tag_types.get(tag);if(!tag_type){tag_type="general"}list=results.get(tag_type);if(!list){list=[];results.set(tag_type,list)}list.push(tag)});return results},get_post_tags_with_type:function get_post_tags_with_type(post){var results,tag_types,type_order,types;tag_types=Post.get_post_tags_by_type(post);types=tag_types.keys();type_order=["artist","circle","copyright","character","faults","general"];types=types.sort(function(a,b){var a_idx,b_idx;a_idx=type_order.indexOf(a);if(a_idx===-1){a_idx=999}b_idx=type_order.indexOf(b);if(b_idx===-1){b_idx=999}return a_idx-b_idx});results=new Array;types.each(function(type){var tags;tags=tag_types.get(type);tags.each(function(tag){results.push([tag,type])})});return results},register_resp:function register_resp(resp2){if(resp2.posts){Post.register_posts(resp2.posts)}if(resp2.tags){Post.register_tags(resp2.tags)}if(resp2.votes){Post.register_votes(resp2.votes)}if(resp2.pools){Pool.register_pools(resp2.pools)}if(resp2.pool_posts){Pool.register_pool_posts(resp2.pool_posts,resp2.posts)}},register:function register(post){post.tags=post.tags.match(/\S+/g)||[];post.match_tags=post.tags.clone();post.match_tags.push("rating:"+post.rating.charAt(0));post.match_tags.push("status:"+post.status);this.posts.set(post.id,post)},register_posts:function register_posts(posts){posts.each(function(post){Post.register(post)})},unregister_all:function unregister_all(){this.posts=new Hash},register_tags:function register_tags(tags,no_send_to_completion){this.tag_types.update(tags);if(TagCompletion&&!no_send_to_completion){TagCompletion.update_tag_types()}},register_votes:function register_votes(votes){this.votes.update(votes)},blacklists:[],is_blacklisted:function is_blacklisted(post_id){var b,blacklist_applies,blacklists,has_tag,i2,len,post;post=Post.posts.get(post_id);if(post==null){return false}has_tag=function has_tag(tag){return post.match_tags.indexOf(tag)!==-1};blacklist_applies=function blacklist_applies(b2){var exclude,exclude_len,j,require2,require_len;require2=b2.require;require_len=require2.length;j=void 0;j=0;while(j0;count+=bld;if(Post.blacklist_options.replace){if(bld){thumb.src=Vars.asset["blank.gif"];f=function f(event){var img;img=event.target;img.stopObserving("load");img.stopObserving("error");img.src="/blacklisted-preview.png";img.removeClassName("javascript-hide")};thumb.observe("load",f);thumb.observe("error",f)}else{thumb.src=post.preview_url;thumb.removeClassName("javascript-hide")}}else{if(bld){thumb.addClassName("javascript-hide")}else{thumb.removeClassName("javascript-hide")}}});if(Post.countText){Post.countText.update(count)}notice2=$("blacklisted-notice");if(notice2){notice2.show(count>0)}return count},current_blacklists:null,hide_inactive_blacklists:true,disabled_blacklists:{},blacklists_update_disabled:function blacklists_update_disabled(){Post.blacklists.each(function(b){if(!b.a){return}if(Post.disabled_blacklists[b.tags]||b.hits===0){b.a.addClassName("blacklisted-tags-disabled")}else{b.a.removeClassName("blacklisted-tags-disabled")}})},init_blacklisted:function init_blacklisted(options){var a,bl_entries,inactive_blacklists_hidden,li,list,sidebar,tags;Post.blacklist_options=Object.extend({replace:false,exclude:null},options);bl_entries=void 0;if(Post.current_blacklists){bl_entries=Post.current_blacklists}else{bl_entries=JSON.parse(jQuery("#user-blacklisted-tags").text())}Post.blacklists=[];bl_entries.each(function(val){var b,s,tags2;s=val.replace(/(rating:[qes])\w+/,"$1");tags2=s.match(/\S+/g);if(!tags2){return}b={tags:tags2,original_tag_string:val,require:[],exclude:[],hits:0};tags2.each(function(tag){if(tag.charAt(0)==="-"){b.exclude.push(tag.slice(1))}else{b.require.push(tag)}});Post.blacklists.push(b)});Post.countText=$("blacklist-count");if(Post.countText){Post.countText.update("")}Post.apply_blacklists();sidebar=$("blacklisted-sidebar");if(sidebar){sidebar.show()}list=$("blacklisted-list");if(list){while(list.firstChild){list.removeChild(list.firstChild)}Post.blacklists.sort(function(a2,b){if(a2.hits===0&&b.hits>0){return 1}if(a2.hits>0&&b.hits===0){return-1}return a2.tags.join(" ").localeCompare(b.tags.join(" "))});inactive_blacklists_hidden=0;Post.blacklists.each(function(b){var a2,del,li2,span,tags2;if(Post.hide_inactive_blacklists&&!b.hits){++inactive_blacklists_hidden;return}li2=list.appendChild(document.createElement("li"));li2.className="blacklisted-tags";li2.style.position="relative";del=li2.appendChild($(document.createElement("a")));del.style.position="absolute";del.style.left="-0.75em";del.href="#";del.update("\u2298");del.observe("click",function(event){var tag;if(!User.run_login_onclick(event)){return false}event.stop();tag=b.original_tag_string;User.modify_blacklist([],[tag],function(resp2){notice("Unblacklisted \""+tag+"\"");Post.current_blacklists=resp2.result;Post.init_blacklisted()})});li2.appendChild(document.createTextNode("\xBB "));a2=li2.appendChild(document.createElement("a"));b.a=a2;a2.href="#";a2.className="no-focus-outline";if(!b.hits){a2.addClassName("blacklisted-tags-disabled")}else{$(a2).observe("click",function(event){Post.disabled_blacklists[b.tags]=!Post.disabled_blacklists[b.tags];Post.apply_blacklists();Post.blacklists_update_disabled();event.stop()})}tags2=a2.appendChild(document.createTextNode(b.tags.join(" ")));li2.appendChild(document.createTextNode(" "));span=li2.appendChild(document.createElement("span"));span.className="post-count";if(b.hits>0){span.appendChild(document.createTextNode("("+b.hits+")"))}});if(Post.hide_inactive_blacklists&&inactive_blacklists_hidden>0){li=list.appendChild(document.createElement("li"));li.className="no-focus-outline";li.id="blacklisted-tag-show-all";a=li.appendChild(document.createElement("a"));a.href="#";a.className="no-focus-outline";$(a).observe("click",function(event){event.stop();$("blacklisted-tag-show-all").hide();Post.hide_inactive_blacklists=false;Post.init_blacklisted()});tags=a.appendChild(document.createTextNode("\xBB Show all blacklists"));li.appendChild(document.createTextNode(" "))}}Post.blacklists_update_disabled()},blacklist_add_commit:function blacklist_add_commit(){var tag;tag=$("add-blacklist").value;if(tag===""){return}$("add-blacklist").value="";User.modify_blacklist([tag],[],function(resp2){notice("Blacklisted \""+tag+"\"");Post.current_blacklists=resp2.result;Post.init_blacklisted()})},last_click_id:null,check_avatar_blacklist:function check_avatar_blacklist(post_id,id2){if(id2&&id2===this.last_click_id){return true}this.last_click_id=id2;if(!Post.is_blacklisted(post_id)){return true}notice("This post matches one of your blacklists. Click again to open.");return false},resize_image:function resize_image(){var client_height,client_width,i2,img,ratio;img=$("image");if(img.original_width==null){img.original_width=img.width;img.original_height=img.height}ratio=1;if(img.scale_factor===1||img.scale_factor==null){client_width=$("right-col").clientWidth-15;client_height=window.innerHeight-15;ratio=Math.min(ratio,client_width/img.original_width);ratio=Math.min(ratio,client_height/img.original_height)}img.width=img.original_width*ratio;img.height=img.original_height*ratio;img.scale_factor=ratio;if(notesManager){i2=0;while(i2client_height){ratio=client_height/img.original_height}if(ratio<1){img.width=img.original_width*ratio;img.height=img.original_height*ratio}this.center_image(img);Post.adjust_notes()},adjust_notes:function adjust_notes(){var i2;if(!notesManager){return}i2=0;while(i2container_bottom){bottom_aligned_y=container_bottom-image.getHeight()-4;if(bottom_aligned_y>=container_top){y=bottom_aligned_y}}image.style.top=y+"px";image.show()},hover_thumb_mouse_out:function hover_thumb_mouse_out(image){image.hide()},acknowledge_new_deleted_posts:function acknowledge_new_deleted_posts(){return jQuery.ajax("/post/acknowledge_new_deleted_posts.json",{method:"POST",dataType:"json"}).done(function(resp2){var noticeLabel;noticeLabel=document.querySelector("#posts-deleted-notice");if(noticeLabel!=null){return noticeLabel.style.display="none"}}).fail(function(xhr){var ref,ref1;return notice("Error: ".concat((ref=(ref1=xhr.responseJSON)!=null?ref1.reason:void 0)!=null?ref:"unknown error"))})},hover_info_pin:function hover_info_pin(post_id){var post;post=null;if(post_id!=null){post=Post.posts.get(post_id)}Post.hover_info_pinned_post=post;Post.hover_info_update()},hover_info_mouseover:function hover_info_mouseover(post_id){var post;post=Post.posts.get(post_id);if(Post.hover_info_hovered_post===post){return}Post.hover_info_hovered_post=post;Post.hover_info_update()},hover_info_mouseout:function hover_info_mouseout(){if(Post.hover_info_hovered_post==null){return}Post.hover_info_hovered_post=null;Post.hover_info_update()},hover_info_hovered_post:null,hover_info_displayed_post:null,hover_info_shift_held:false,hover_info_pinned_post:null,hover_info_update:function hover_info_update(){var client_width,hover,hover_height,hover_thumb,hover_width,overlay,post,set_text_content,tags_by_type,thumb_center_x,thumb_offset,thumb_top_y,x,y;post=Post.hover_info_pinned_post;if(!post){post=Post.hover_info_hovered_post;if(!Post.hover_info_shift_held){post=null}}if(Post.hover_info_displayed_post===post){return}Post.hover_info_displayed_post=post;hover=$("index-hover-info");overlay=$("index-hover-overlay");if(!post){hover.hide();overlay.hide();overlay.down("IMG").src=Vars.asset["blank.gif"];return}hover.down("#hover-dimensions").innerHTML=post.width+"x"+post.height;hover.select("#hover-tags SPAN A").each(function(elem){elem.innerHTML=""});tags_by_type=Post.get_post_tags_by_type(post);tags_by_type.each(function(key){var elem,list;elem=$("hover-tag-"+key[0]);list=[];key[1].each(function(tag){list.push(tag)});elem.innerHTML=list.join(" ")});if(post.rating==="s"){hover.down("#hover-rating").innerHTML="s"}else if(post.rating==="q"){hover.down("#hover-rating").innerHTML="q"}else if(post.rating==="e"){hover.down("#hover-rating").innerHTML="e"}hover.down("#hover-post-id").innerHTML=post.id;hover.down("#hover-score").innerHTML=post.score;if(post.is_shown_in_index){hover.down("#hover-not-shown").hide()}else{hover.down("#hover-not-shown").show()}hover.down("#hover-is-parent").show(post.has_children);hover.down("#hover-is-child").show(post.parent_id!=null);hover.down("#hover-is-pending").show(post.status==="pending");hover.down("#hover-is-flagged").show(post.status==="flagged");set_text_content=function set_text_content(element,text){(element.innerText||element).textContent=text};if(post.status==="flagged"){hover.down("#hover-flagged-reason").setTextContent(post.flag_detail.reason);hover.down("#hover-flagged-by").setTextContent(post.flag_detail.flagged_by)}hover.down("#hover-file-size").innerHTML=numberToHumanSize(post.file_size);hover.down("#hover-author").innerHTML=post.author;hover.show();hover.style.left="0px";hover.style.top="0px";hover_width=hover.scrollWidth;hover_height=hover.scrollHeight;hover_thumb=$("p"+post.id).down("IMG");thumb_offset=hover_thumb.cumulativeOffset();thumb_center_x=thumb_offset[0]+hover_thumb.scrollWidth/2;thumb_top_y=thumb_offset[1];x=thumb_center_x-hover_width/2;y=thumb_top_y-hover_height;client_width=document.viewport.getDimensions()["width"];if(x<0){x=0}if(x+hover_width>client_width){x=client_width-hover_width}hover.style.left=x+"px";hover.style.top=y+"px";overlay.down("A").href=(User.get_use_browser()?"/post/browse#":"/post/show/")+post.id;overlay.down("IMG").src=post.preview_url;x=thumb_center_x-post.actual_preview_width/2;y=thumb_offset[1];overlay.style.left=x+"px";overlay.style.top=y+"px";overlay.show()},hover_info_shift_down:function hover_info_shift_down(){if(Post.hover_info_shift_held){return}Post.hover_info_shift_held=true;Post.hover_info_update()},hover_info_shift_up:function hover_info_shift_up(){if(!Post.hover_info_shift_held){return}Post.hover_info_shift_held=false;Post.hover_info_update()},hover_info_init:function hover_info_init(){var overlay;document.observe("keydown",function(e){if(e.keyCode!==16){return}Post.hover_info_shift_down()});document.observe("keyup",function(e){if(e.keyCode!==16){return}Post.hover_info_shift_up()});document.observe("blur",function(e){Post.hover_info_shift_up()});overlay=$("index-hover-overlay");Post.posts.each(function(p){var post,post_id,span;post_id=p[0];post=p[1];span=$("p"+post.id);if(span==null){return}span.down("A").observe("mouseover",function(e){Post.hover_info_mouseover(post_id)});span.down("A").observe("mouseout",function(e){if(e.relatedTarget&&e.relatedTarget.isParentNode(overlay)){return}Post.hover_info_mouseout()})});overlay.observe("mouseout",function(e){Post.hover_info_mouseout()})},highlight_posts_with_tag:function highlight_posts_with_tag(tag){Post.posts.each(function(p){var post,post_id,thumb;post_id=p[0];post=p[1];thumb=$("p"+post.id);if(!thumb){return}if(tag&&post.tags.indexOf(tag)!==-1){thumb.addClassName("highlighted-post")}else{thumb.removeClassName("highlighted-post")}})},reparent_post:function reparent_post(post_id,old_parent_id,has_grandparent,finished){if(has_grandparent){alert("The parent post has a parent, so this post can't be automatically reparented.");return}jQuery.ajax({url:"/post.json",data:{tags:"parent:"+old_parent_id},dataType:"json"}).done(function(resp2){var change_requests,i2,post;post=void 0;i2=void 0;change_requests=[];i2=0;while(i20?done/total:1;return _this6.set_progress(progress)};this.current_request=jQuery.ajax("/post/create.json",{contentType:false,data:formData,dataType:"json",method:"POST",processData:false,xhr:function xhr(){var xhr;xhr=new XMLHttpRequest;xhr.upload.addEventListener("progress",onprogress);return xhr}}).always(function(){_this6.current_request=null;return _this6.request_ending()}).done(function(json){return window.location.href=json.similar_location&&json.has_similar_hits?json.similar_location:json.location}).fail(function(xhr){var a,errorLabel,json,ref;json=xhr.responseJSON;if(json!=null&&json.location){a=document.querySelector("#post-exists-link");a.text="post #".concat(json.post_id);a.href=json.location;document.querySelector("#post-exists").style.display="";return}errorLabel=document.querySelector("#post-upload-error");errorLabel.text=(ref=json!=null?json.reason:void 0)!=null?ref:"unknown error";return errorLabel.style.display=""})};PostUploadForm.prototype.cancel=function(){if(this.current_request==null){return}this.current_request.abort()};window.UploadSimilarSearch=function(file_field,results){if(!ThumbnailUserImage){return}this.file_field=file_field;this.results=results;file_field.on("change",this.field_changed_event.bindAsEventListener(this))};UploadSimilarSearch.prototype.field_changed_event=function(event){var file,similar;this.results.hide();if(this.file_field.files==null||this.file_field.files.length===0){return}this.results.innerHTML="Searching...";this.results.show();file=this.file_field.files[0];similar=new ThumbnailUserImage(file,this.thumbnail_complete.bind(this))};UploadSimilarSearch.prototype.thumbnail_complete=function(result){var _this7=this;if(!result.success){this.results.innerHTML="Image load failed.";this.results.style.display="";return}return jQuery.ajax("/post/similar.json",{data:{url:result.canvas.toDataURL()},dataType:"json",method:"POST"}).always(function(){_this7.results.innerHTML="";return _this7.results.style.display=""}).done(function(json){var html,makeUrl,message,posts,remainingPosts,seeAll,shownPosts;if(json.posts.length>0){posts=[];shownPosts=3;makeUrl=User.get_use_browser()?function(post){return"/post/browse#".concat(post.id)}:function(post){return"/post/show/".concat(post.id)};posts=json.posts.slice(0,shownPosts).map(function(post){return"post #").concat(post.id,"")});seeAll="(see all)");html="Similar posts ".concat(seeAll,": ").concat(posts.join(", "));if(json.posts.length>shownPosts){remainingPosts=json.posts.length-shownPosts;html+=" (".concat(remainingPosts," more)")}message=html}else{message="No similar posts found."}return _this7.results.innerHTML=message}).fail(function(xhr){var ref,ref1;return _this7.results.innerHTML=(ref=(ref1=xhr.responseJSON)!=null?ref1.reason:void 0)!=null?ref:"unknown error"})};// app/javascript/src/legacy/post_mode_menu.coffee window.PostModeMenu={mode:"view",init:function init(pool_id){var color_element,e;try{this.pool_id=pool_id;color_element=$("mode-box");this.original_style={border:color_element.getStyle("border")};if(Cookie.get("mode")===""){Cookie.put("mode","view");$("mode").value="view"}else{$("mode").value=Cookie.get("mode")}}catch(error){e=error}this.vote_score=Cookie.get("vote");if(this.vote_score===""){this.vote_score=1;Cookie.put("vote",this.vote_score)}else{this.vote_score=+this.vote_score}Post.posts.each(function(p){var post,post_id,span;post_id=p[0];post=p[1];span=$("p"+post.id);if(span==null){return}span.down("A").observe("click",function(e2){PostModeMenu.click(e2,post_id)});span.down("A").observe("mousedown",function(e2){PostModeMenu.post_mousedown(e2,post_id)});span.down("A").observe("mouseover",function(e2){PostModeMenu.post_mouseover(e2,post_id)});span.down("A").observe("mouseout",function(e2){PostModeMenu.post_mouseout(e2,post_id)});span.down("A").observe("mouseup",function(e2){PostModeMenu.post_mouseup(e2,post_id)})});document.observe("mouseup",function(e2){PostModeMenu.post_mouseup(e2,null)});Event.observe(window,"pagehide",function(e2){PostModeMenu.post_end_drag()});this.change()},set_vote:function set_vote(score){this.vote_score=score;Cookie.put("vote",this.vote_score);Post.update_vote_widget("vote-menu",this.vote_score)},get_style_for_mode:function get_style_for_mode(s){if(s==="view"){return{background:""}}else if(s==="edit"){return{background:"#3A3"}}else if(s==="rating-q"){return{background:"#AAA"}}else if(s==="rating-s"){return{background:"#6F6"}}else if(s==="rating-e"){return{background:"#F66"}}else if(s==="vote"){return{background:"#FAA"}}else if(s==="lock-rating"){return{background:"#AA3"}}else if(s==="lock-note"){return{background:"#3AA"}}else if(s==="approve"){return{background:"#26A"}}else if(s==="flag"){return{background:"#F66"}}else if(s==="add-to-pool"){return{background:"#26A"}}else if(s==="apply-tag-script"){return{background:"#A3A"}}else if(s==="reparent-quick"){return{background:"#CCA"}}else if(s==="remove-from-pool"){return{background:"#CCA"}}else if(s==="reparent"){return{background:"#0C0"}}else if(s==="dupe"){return{background:"#0C0"}}else{return{background:"#AFA"}}},change:function change(){var s;if(!$("mode")){return}s=$F("mode");Cookie.put("mode",s,7);PostModeMenu.mode=s;if(s!=="edit"){$("quick-edit").hide()}if(s!=="apply-tag-script"){$("edit-tag-script").hide();Post.reset_tag_script_applied()}if(s==="vote"){Post.update_vote_widget("vote-menu",this.vote_score);$("vote-score").show()}else if(s==="apply-tag-script"){$("edit-tag-script").show();$("edit-tag-script").focus()}},click:function click(event,post_id){var s;s=$("mode");if(!s){return}if(s.value==="view"){return true}if(s.value==="edit"){post_quick_edit.show(post_id)}else if(s.value==="vote"){Post.vote(post_id,this.vote_score)}else if(s.value==="rating-q"){Post.update_batch([{id:post_id,rating:"questionable"}])}else if(s.value==="rating-s"){Post.update_batch([{id:post_id,rating:"safe"}])}else if(s.value==="rating-e"){Post.update_batch([{id:post_id,rating:"explicit"}])}else if(s.value==="reparent"){if(post_id===window.id){return false}TagScript.run(post_id,"parent:"+id)}else if(s.value==="dupe"){if(post_id===window.id){return false}TagScript.run(post_id,"duplicate parent:"+window.id)}else if(s.value==="lock-rating"){Post.update_batch([{id:post_id,is_rating_locked:"1"}])}else if(s.value==="lock-note"){Post.update_batch([{id:post_id,is_note_locked:"1"}])}else if(s.value==="flag"){Post.flag(post_id)}else if(s.value==="approve"){Post.approve(post_id)}else if(s.value==="add-to-pool"){Pool.add_post(post_id,0)}else if(s.value==="remove-from-pool"){Pool.remove_post(post_id,PostModeMenu.pool_id)}event.stopPropagation();event.preventDefault()},dragging_from_post:null,dragging_active:false,dragging_list:null,dragging_hash:null,post_add_to_hovered_list:function post_add_to_hovered_list(post_id){var element;element=element=$$("#p"+post_id+" > .directlink");if(element.length>0){element[0].addClassName("tag-script-applied");Post.applied_list.push(element[0])}if(!PostModeMenu.dragging_hash.get(post_id)){PostModeMenu.dragging_hash.set(post_id,true);PostModeMenu.dragging_list.push(post_id)}},post_mousedown:function post_mousedown(event,post_id){if(event.button!==0){return}if(PostModeMenu.mode==="reparent-quick"){PostModeMenu.dragging_from_post=post_id;PostModeMenu.post_begin_drag()}else if(PostModeMenu.mode==="apply-tag-script"){Post.reset_tag_script_applied();PostModeMenu.dragging_from_post=post_id;PostModeMenu.dragging_list=new Array;PostModeMenu.dragging_hash=new Hash;PostModeMenu.post_add_to_hovered_list(post_id)}else{return}event.preventDefault();event.stopPropagation()},post_begin_drag:function post_begin_drag(type){document.body.addClassName("dragging-to-post")},post_end_drag:function post_end_drag(){document.body.removeClassName("dragging-to-post");PostModeMenu.dragging_from_post=null},post_mouseup:function post_mouseup(event,post_id){var tag_script;if(event.button!==0){return}if(!PostModeMenu.dragging_from_post){return}if(PostModeMenu.mode==="reparent-quick"){if(post_id){notice("Updating post");Post.update_batch([{id:PostModeMenu.dragging_from_post,parent_id:post_id}])}PostModeMenu.post_end_drag();return}else if(PostModeMenu.mode==="apply-tag-script"){if(post_id){return}tag_script=TagScript.TagEditArea.value;TagScript.run(PostModeMenu.dragging_list,tag_script);PostModeMenu.dragging_from_post=null;PostModeMenu.dragging_active=false;PostModeMenu.dragging_list=null;PostModeMenu.dragging_hash=null}},post_mouseover:function post_mouseover(event,post_id){var post,style;post=$("p"+post_id);style=PostModeMenu.get_style_for_mode(PostModeMenu.mode);post.down("span").setStyle(style);if(PostModeMenu.mode!=="apply-tag-script"){return}if(!PostModeMenu.dragging_from_post){return}if(post_id!==PostModeMenu.dragging_from_post){PostModeMenu.dragging_active=true}PostModeMenu.post_add_to_hovered_list(post_id)},post_mouseout:function post_mouseout(event,post_id){var post;post=$("p"+post_id);post.down("span").setStyle({background:""})},apply_tag_script_to_all_posts:function apply_tag_script_to_all_posts(){var post_ids,tag_script;tag_script=TagScript.TagEditArea.value;post_ids=Post.posts.inject([],function(list,pair){list.push(pair[0]);return list});TagScript.run(post_ids,tag_script)}};window.TagScript={TagEditArea:null,load:function load(){this.TagEditArea.value=Cookie.get("tag-script")},save:function save(){Cookie.put("tag-script",this.TagEditArea.value)},init:function init(element,x){this.TagEditArea=element;TagScript.load();this.TagEditArea.observe("change",function(e){TagScript.save()});this.TagEditArea.observe("focus",function(e){Post.reset_tag_script_applied()});Event.on(window,"unload",function(){TagScript.save()});document.observe("focus",function(e){TagScript.load()})},parse:function parse(script){return script.match(/\[.+?\]|\S+/g)},test:function test(tags,predicate){var is_true,split_pred;split_pred=predicate.match(/\S+/g);is_true=true;split_pred.each(function(x){if(x[0]==="-"){if(tags.include(x.substr(1,100))){is_true=false;throw $break}}else{if(!tags.include(x)){is_true=false;throw $break}}});return is_true},process:function process(tags,command){var match;if(command.match(/^\[if/)){match=command.match(/\[if\s+(.+?)\s*,\s*(.+?)\]/);if(TagScript.test(tags,match[1])){return TagScript.process(tags,match[2])}else{return tags}}else if(command==="[reset]"){return[]}else if(command[0]==="-"&&command.indexOf("-pool:")!==0){return tags.reject(function(x){return x===command.substr(1,100)})}else{tags.push(command);return tags}},run:function run(post_ids,tag_script,finished){var commands,posts;if(!Object.isArray(post_ids)){post_ids=$A([post_ids])}commands=TagScript.parse(tag_script)||[];posts=new Array;post_ids.each(function(post_id){var old_tags,post;post=Post.posts.get(post_id);old_tags=post.tags.join(" ");commands.each(function(x){post.tags=TagScript.process(post.tags,x)});posts.push({id:post_id,old_tags:old_tags,tags:post.tags.join(" ")})});notice("Updating "+posts.length+(post_ids.length===1?" post":" posts"));Post.update_batch(posts,finished)}};// app/javascript/src/legacy/tag_completion.coffee var get_tag_from_string;var join_data;var split_data;window.TagCompletionClass=function(){var current_version;this.loading=false;this.loaded=false;current_version="5";if(localStorage.tag_data_format!==current_version){delete localStorage.tag_data;delete localStorage.tag_data_version;delete localStorage.recent_tags;localStorage.tag_data_format=current_version}this.recent_tags=localStorage.recent_tags||"";this.load_data_complete_callbacks=[];this.rapid_backspaces_received=0;this.updates_deferred=false};TagCompletionClass.prototype.init=function(current_version){if(this.loaded){return}this.most_recent_tag_data_version=current_version};TagCompletionClass.prototype.load_data=function(onComplete){var _this8=this;var complete;if(this.loaded){if(typeof onComplete==="function"){onComplete()}return this.tag_data!=null}if(onComplete!=null){this.load_data_complete_callbacks.push(onComplete)}if(this.loading){return this.tag_data!=null}this.loading=true;complete=function complete(){var callback,callbacks,j,len,results1;_this8.loading=false;_this8.loaded=true;_this8.update_tag_types();callbacks=_this8.load_data_complete_callbacks;_this8.load_data_complete_callbacks=[];results1=[];for(j=0,len=callbacks.length;jmax_recent_tags_size*10/9){purge_at=this.recent_tags.indexOf(" ",max_recent_tags_size);if(purge_at!==-1){this.recent_tags=this.recent_tags.slice(0,purge_at+1)}}localStorage.recent_tags=this.recent_tags};TagCompletionClass.prototype.remove_recent_tag=function(tag){var escaped_tag,re;escaped_tag=RegExp.escape(tag);re=new RegExp("\\d`"+escaped_tag+"` ","g");this.recent_tags=this.recent_tags.replace(re,"");localStorage.recent_tags=this.recent_tags};TagCompletionClass.prototype.add_recent_tags_from_update=function(tags,old_tags){tags=tags.split(" ");if(old_tags!=null){old_tags=old_tags.split(" ")}tags.each(function(tag){if(tag.indexOf("`")!==-1){return}if("sqe".indexOf(tag)!==-1){return}if(old_tags&&old_tags.indexOf(tag)!==-1){return}if(old_tags==null&&tag.indexOf(":")===-1){if(this.tag_data.indexOf("`"+tag+"`")===-1){return}}this.add_recent_tag(tag)}.bind(this))};TagCompletionClass.prototype.reorder_search_results=function(tag,results){var bottom_results,re,top_results;re=this.create_tag_search_regex(tag,{top_results_only:true,global:false});top_results=[];bottom_results=[];results.each(function(tag2){if(re.test(tag2)){top_results.push(tag2)}else{bottom_results.push(tag2)}});return top_results.concat(bottom_results)};TagCompletionClass.prototype.complete_tag=function(tag,options){var final_aliases,final_results,main_results,re,recent_result_count,recent_results,results,tag_types;if(this.tag_data==null){throw"Tag data isn't loaded"}if(options==null){options={}}if(tag===""){return[[],0]}re=this.create_tag_search_regex(tag,{global:true});recent_results=this.retrieve_tag_search(re,this.recent_tags,{max_results:100});main_results=this.retrieve_tag_search(re,this.tag_data,{max_results:100});recent_results=this.reorder_search_results(tag,recent_results);main_results=this.reorder_search_results(tag,main_results);recent_result_count=recent_results.length;results=recent_results.concat(main_results);if("sqe".indexOf(tag)!==-1){results.unshift("0`"+tag+"` ")}results=results.slice(0,options.max_results!=null?options.max_results:10);recent_result_count=Math.min(results.length,recent_result_count);final_results=[];tag_types={};final_aliases=[];results.each(function(tag2){var aliases,m,tag_type;m=tag2.match(/(\d+)`([^`]*)`(([^ ]*)`)? /);if(!m){ReportError("Unparsable cached tag: '"+tag2+"'",null,null,null,null);throw"Unparsable cached tag: '"+tag2+"'"}tag2=m[2];tag_type=Post.tag_type_names[m[1]];aliases=m[4];if(m[4]){aliases=aliases.split("`")}else{aliases=[]}tag_types[tag2]=tag_type;if(final_results.indexOf(tag2)===-1){final_results.push(tag2);final_aliases.push(aliases)}});Post.register_tags(tag_types,true);return[final_results,recent_result_count,final_aliases]};if(!LocalStorageDisabled()&&"addEventListener"in document){window.TagCompletion=new TagCompletionClass}else{window.TagCompletion=null}window.TagCompletionBox=function(input_field){var div,html;this.input_field=input_field;this.update=this.update.bind(this);this.last_value=this.input_field.value;this.input_field.setAttribute("autocomplete","off");html="
    ";div=html.createElement();div.tabindex=-1;document.body.appendChild(div);this.completion_box=div;document.on("mousedown",function(event){if(event.target.isParentNode(this.input_field)||event.target.isParentNode(this.completion_box)){return}this.hide()}.bindAsEventListener(this));this.input_field.on("mousedown",this.input_mouse.bindAsEventListener(this));this.input_field.on("mouseup",this.input_mouse.bindAsEventListener(this));this.input_field.parentNode.addEventListener("keydown",this.input_keydown.bindAsEventListener(this),true);this.completion_box.on("mouseover",".completed-tag",function(event,element){this.focus_element(element)}.bind(this));this.completion_box.on("click","li",this.click_result.bind(this));this.hide()};TagCompletionBox.prototype.input_mouse=function(event){this.update.defer()};TagCompletionBox.prototype.input_keydown=function(event){var focused;if(event.target!==this.input_field){return}if(event.keyCode===Event.KEY_BACKSPACE){++this.rapid_backspaces_received;if(this.backspace_timeout){clearTimeout(this.backspace_timeout)}this.backspace_timeout=setTimeout(function(){this.rapid_backspaces_received=0}.bind(this),100);if(this.rapid_backspaces_received>1){this.updates_deferred=true;if(this.defer_timeout!=null){clearTimeout(this.defer_timeout)}this.defer_timeout=setTimeout(function(){this.updates_deferred=false;this.update()}.bind(this),100)}}if(!this.shown){this.update.defer();return}if(event.keyCode===Event.KEY_DOWN){event.stop();this.select_next(true)}else if(event.keyCode===Event.KEY_UP){event.stop();this.select_next(false)}else if(event.keyCode===Event.KEY_ESC){event.stop();this.hide()}else if(event.keyCode===Event.KEY_RETURN){focused=this.completion_box.down(".focused");if(focused){event.stop();this.set_current_word(focused.result_tag)}else{this.hide()}}else{this.update.defer()}};TagCompletionBox.prototype.focus_element=function(element){var previous;if(element==null){throw"Can't select no element"}previous=this.completion_box.down(".focused");if(previous){previous.removeClassName("focused")}if(element){element.addClassName("focused")}};TagCompletionBox.prototype.select_next=function(next){var focused,new_focus,siblings;focused=this.completion_box.down(".focused");siblings=next?focused.nextSiblings():focused.previousSiblings();new_focus=Prototype.Selector.find(siblings,".completed-tag",0);if(new_focus==null){new_focus=this.completion_box.down(next?".completed-tag":".completed-tag:last-child")}this.focus_element(new_focus)};TagCompletionBox.prototype.show=function(){var offset;this.shown=true;offset=this.input_field.cumulativeOffset();this.completion_box.style.top=offset.top+this.input_field.offsetHeight+"px";this.completion_box.style.left=offset.left+"px";this.completion_box.style.minWidth=this.input_field.offsetWidth+"px"};TagCompletionBox.prototype.hide=function(){this.shown=false;this.current_tag=null;this.completion_box.hide()};TagCompletionBox.prototype.click_result=function(event,element){event.stop();if(event.target.hasClassName("remove-recent-tag")){TagCompletion.remove_recent_tag(element.result_tag);this.update(true);return}this.set_current_word(element.result_tag)};TagCompletionBox.prototype.get_input_word_offset=function(field){var end_idx,start_idx,text;text=field.value;start_idx=text.lastIndexOf(" ",field.selectionStart-1);if(start_idx===-1){start_idx=0}else{++start_idx}end_idx=text.indexOf(" ",field.selectionStart);if(end_idx===-1){end_idx=text.length}return{start:start_idx,end:end_idx}};TagCompletionBox.prototype.set_current_word=function(tag){var after,before,cursor_position,offset,tag_text,text;offset=this.get_input_word_offset(this.input_field);text=this.input_field.value;before=text.substr(0,offset.start);after=text.substr(offset.end);tag_text=tag;if(after.match(/^ +$/)){after=""}if(after===""){tag_text+=" "}this.input_field.value=before+tag_text+after;cursor_position=before.length+tag_text.length;this.input_field.selectionStart=this.input_field.selectionEnd=cursor_position;TagCompletion.add_recent_tag(tag);this.hide()};TagCompletionBox.prototype.update=function(force){var aliases,data_available,h,i2,li,offset,recent_result_count,span,tag,tag_aliases,tag_type,tags,tags_and_recent_count,ul;if(this.updates_deferred&&!force){return}if(TagCompletion.tag_data==null){data_available=TagCompletion.load_data(function(){if(data_available){return}this.current_tag=null;this.update()}.bind(this));if(!data_available){return}}offset=this.get_input_word_offset(this.input_field);tag=this.input_field.value.substr(offset.start,offset.end-offset.start);if(tag===this.current_tag&&!force){return}this.hide();if(this.last_value===this.input_field.value&&!force){return}this.last_value=this.input_field.value;this.current_tag=tag;if(!this.input_field.recursivelyVisible()){return}tags_and_recent_count=TagCompletion.complete_tag(tag);tags=tags_and_recent_count[0];tag_aliases=tags_and_recent_count[2];recent_result_count=tags_and_recent_count[1];if(tags.length===0){return}if(tags.length===1&&tags[0]===tag){return}this.show();ul=this.completion_box.down("UL");this.completion_box.hide();while(ul.firstChild){ul.removeChild(ul.firstChild)}i2=0;while(i20){span=document.createElement("span");span.className="completed-tag-alias";span.setTextContent(aliases[0]);li.appendChild(span)}tag_type=Post.tag_types.get(tag);li.className+=" tag-type-"+tag_type;if(i21){return}time_since_previous=event.timeStamp-last_click.timeStamp;if(time_since_previous>500){return}distance=Math.pow(this_touch.screenX-last_click.position[0],2)+Math.pow(this_touch.screenY-last_click.position[1],2);if(distance>500){return}if(event.target!==last_click.target){return}e=document.createEvent("MouseEvent");e.initMouseEvent("dblclick",true,true,window,2,last_click.position[0],last_click.position[1],last_click.clientPosition[0],last_click.clientPosition[1],false,false,false,false,0,null);this.last_click=null;event.target.dispatchEvent(e)};EmulateDoubleClick.prototype.touchend_event=function(event){var distance,last_click_identifier,last_click_position,this_click;if(this.last_click==null){return}last_click_identifier=this.last_click.identifier;if(last_click_identifier==null){return}last_click_position=this.last_click.position;this_click=event.changedTouches[0];if(this_click.identifier===last_click_identifier){distance=Math.pow(this_click.screenX-last_click_position[0],2)+Math.pow(this_click.screenY-last_click_position[1],2);if(distance>500){this.last_click=null;return}}};window.ResponsiveSingleClick=function(){this.click_event=this.click_event.bindAsEventListener(this);this.touchstart_event=this.touchstart_event.bindAsEventListener(this);this.touchend_event=this.touchend_event.bindAsEventListener(this);this.last_touch=null;window.addEventListener("touchstart",this.touchstart_event,false);window.addEventListener("touchend",this.touchend_event,false);window.addEventListener("click",this.click_event,true)};ResponsiveSingleClick.prototype.touchstart_event=function(event){var touch;if(this.last_touch!=null){console.debug("Cancelling click (multitouch)");this.last_touch=null;return}touch=event.changedTouches[0];this.last_touch=[touch.screenX,touch.screenY]};ResponsiveSingleClick.prototype.touchend_event=function(event){var distance,e,last_touch,this_touch,touch;last_touch=this.last_touch;if(last_touch==null){return}this.last_touch=null;touch=event.changedTouches[0];this_touch=[touch.screenX,touch.screenY];distance=distance_squared(this_touch[0],this_touch[1],last_touch[0],last_touch[1]);if(distance>50){return}e=document.createEvent("MouseEvent");e.initMouseEvent("click",true,true,window,1,touch.screenX,touch.screenY,touch.clientX,touch.clientY,false,false,false,false,0,null);e.synthesized_click=true;(function(){event.target.dispatchEvent(e)}).defer()};ResponsiveSingleClick.prototype.click_event=function(event){if(!event.synthesized_click){event.stop()}};window.PreventDragScrolling=function(){Element.observe(document,"touchmove",function(event){event.preventDefault()})};MaintainUrlHash=function MaintainUrlHash(){var hash,update_stored_hash;if(LocalStorageDisabled()){return}update_stored_hash=function update_stored_hash(changed_hash_keys,old_hash,new_hash){var hash2;hash2=localStorage.current_hash=UrlHash.get_raw_hash()};UrlHash.observe(null,update_stored_hash);hash=localStorage.getItem("current_hash");if(hash){UrlHash.set_raw_hash(hash)}};window.SendMissingResizeEvents=function(){var last_seen_orientation;if(window.navigator.standalone){return}if(navigator.userAgent.indexOf("Version/4.0.5")===-1){return}last_seen_orientation=window.orientation;window.addEventListener("orientationchange",function(e){if(last_seen_orientation===window.orientation){return}last_seen_orientation=window.orientation;console.debug("dispatch fake resize event");e=document.createEvent("Event");e.initEvent("resize",true,true);document.documentElement.dispatchEvent(e)},true)};window.InitializeFullScreenBrowserHandlers=function(){if(navigator.userAgent.indexOf("Android")!==-1&&navigator.userAgent.indexOf("WebKit")!==-1){new ResponsiveSingleClick;new EmulateDoubleClick}else if((navigator.userAgent.indexOf("iPhone")!==-1||navigator.userAgent.indexOf("iPad")!==-1||navigator.userAgent.indexOf("iPod")!==-1)&&navigator.userAgent.indexOf("WebKit")!==-1){new ResponsiveSingleClick;new EmulateDoubleClick;if(window.navigator.standalone){MaintainUrlHash()}SendMissingResizeEvents()}PreventDragScrolling()};window.SwipeHandler=function(element){this.element=element;this.dragger=new DragElement(element,{ondrag:this.ondrag.bind(this),onstartdrag:this.startdrag.bind(this)})};SwipeHandler.prototype.startdrag=function(){this.swiped_horizontal=false;this.swiped_vertical=false};SwipeHandler.prototype.ondrag=function(e){if(!this.swiped_horizontal){if(Math.abs(e.aX)>100){this.element.fire("swipe:horizontal",{right:e.aX>0});this.swiped_horizontal=true}}if(!this.swiped_vertical){if(Math.abs(e.aY)>100){this.element.fire("swipe:vertical",{down:e.aY>0});this.swiped_vertical=true}}};SwipeHandler.prototype.destroy=function(){this.dragger.destroy()};// app/javascript/src/legacy/user.coffee window.User={checkXhr:null,cancel_check:function cancel_check(){var ref;return(ref=User.checkXhr)!=null?ref.abort():void 0},reset_password:function reset_password(username,email,func){jQuery.ajax("/user/reset_password.json",{data:{user:{name:username,email:email}},dataType:"json",method:"POST"}).done(func).fail(function(xhr){var json;json=xhr.responseJSON;if(json!=null){return func(json)}else{return notice("Error: unknown error")}})},check:function check(username,password,background,func){var parameters;parameters={username:username};if(password){parameters.password=password}User.cancel_check();User.checkXhr=jQuery.ajax("/user/check.json",{data:parameters,dataType:"json",method:"POST"}).done(func)},create:function create(username,password,email,func){var parameters;parameters={user:{name:username,password:password}};if(email){parameters.user.email=email}jQuery.ajax("/user/create.json",{data:parameters,dataType:"json",method:"POST"}).done(func)},check_name_timer:null,last_username_in_form:null,success_func:null,messages:[],init:function init(){$("login-popup-notices").select("SPAN").each(function(e){User.messages.push(e.id)});$$("FORM.need-signup").each(function(form){form.observe("submit",User.run_login_onsubmit)});$("login-popup").observe("submit",function(e){e.stop();User.form_submitted()});$("login-popup-submit").observe("click",function(e){e.stop();User.form_submitted()});$("login-popup-cancel").observe("click",function(e){e.stop();User.close(false)});$("login-popup-username").observe("blur",function(e){User.form_username_blur()});$("login-popup-username").observe("focus",function(e){User.form_username_focus()});$("login-popup-username").observe("keyup",function(e){User.form_username_changed(true)});$("login-tabs").select("LI").each(function(a){a.observe("mousedown",function(e){e.stop()})});$("login-tabs").select("LI").each(function(a){a.observe("click",function(e){e.stop();User.set_tab(a.id)})});OnKey(13,{AllowInputFields:true,Element:$("login-popup")},function(e){e.stop();User.form_submitted()});OnKey(27,{AllowInputFields:true,AlwaysAllowOpera:true},function(e){if(!User.success_func){return false}User.close(false);return true})},open:function open(success){if(User.success_func){User.close(false)}User.success_func=success;$("login-background").show();$("login-container").show();User.set_tab("tab-login")},close:function close(run_success_func){var func;if(!User.success_func){return}$("login-background").hide();$("login-container").hide();User.active_tab=null;User.check_name_timer=null;func=User.success_func;User.success_func=null;if(run_success_func){window.setTimeout(func,0)}},run_login_onclick:function run_login_onclick(event){var e,target;event=Event.extend(event);target=$(event.target);e=clone_event(event);if(User.run_login(true,function(){if(target.hasClassName("login-button")){Cookie.put("notice","You have been logged in.");document.location.reload();return}target.simulate_anchor_click(e)})){return true}event.stop();return false},run_login_onsubmit:function run_login_onsubmit(event){var target;target=$(event.target);if(!User.run_login(true,function(){target.simulate_submit()})){event.stop()}},run_login:function run_login(only_complete_on_login,complete){if(Cookie.get("user_info")!==""){if(!only_complete_on_login){complete()}return true}User.open(complete);return false},active_tab:null,set_tab:function set_tab(tab){if(User.active_tab===tab){return}User.active_tab=tab;User.check_name_timer=null;User.last_username_in_form=null;$("login-tabs").select("LI").each(function(li){li.removeClassName("selected")});$("login-tabs").down("#"+tab).addClassName("selected");$$(".tab-header-text").each(function(li){li.hide()});$(tab+"-text").show();if(tab==="tab-login"){if($("login-popup-password").value===""&&$("login-popup-username").value!==""){$("login-popup-password").focus()}else{$("login-popup-username").focus()}User.set_state("login-blank")}else if(tab==="tab-reset"){User.set_state("reset-blank");$("login-popup-username").focus()}User.form_username_changed()},message:function message(text){var elem,i2,l;i2=0;l=User.messages.length;while(i2"))}})}return}User.check(username,password,false,function(resp2){if(!resp2.exists){User.set_state("login-confirm-password");return}if(resp2.response==="wrong-password"){notice("Incorrect password");return}User.close(true)})}else if(User.active_tab==="tab-reset"){if(email===""){return}User.reset_password(username,email,function(resp2){if(resp2.result==="success"){User.set_state("reset-successful")}else if(resp2.result==="unknown-user"){User.set_state("reset-unknown-user")}else if(resp2.result==="wrong-email"){User.set_state("reset-user-email-incorrect")}else if(resp2.result==="no-email"){User.set_state("reset-user-has-no-email")}else if(resp2.result==="invalid-email"){User.set_state("reset-user-email-invalid")}})}},modify_blacklist:function modify_blacklist(add,remove,success){jQuery.ajax("/user/modify_blacklist.json",{data:{add:add,remove:remove},dataType:"json",method:"POST"}).done(function(resp2){return typeof success==="function"?success(resp2):void 0}).fail(function(xhr){var ref,ref1;return notice("Error: ".concat((ref=(ref1=xhr.responseJSON)!=null?ref1.reason:void 0)!=null?ref:"unknown error"))})},set_pool_browse_mode:function set_pool_browse_mode(browse_mode){jQuery.ajax("/user/update.json",{data:{user:{pool_browse_mode:browse_mode}},dataType:"json",method:"POST"}).done(function(resp2){return window.location.reload()}).fail(function(xhr){var ref,ref1;return notice("Error: ".concat((ref=(ref1=xhr.responseJSON)!=null?ref1.reason:void 0)!=null?ref:"unknown error"))})},get_current_user_info:function get_current_user_info(){var user_info;user_info=Cookie.get("user_info");if(!user_info){return null}return user_info.split(";")},get_current_user_info_field:function get_current_user_info_field(idx,def){var user_info;user_info=User.get_current_user_info();if(!user_info){return def}if(idx>=user_info.length){return def}return user_info[idx]},get_current_user_id:function get_current_user_id(){return parseInt(User.get_current_user_info_field(0,0))},get_current_user_level:function get_current_user_level(){return parseInt(User.get_current_user_info_field(1,0))},get_use_browser:function get_use_browser(){var setting;setting=User.get_current_user_info_field(2,"0");return setting==="1"},is_member_or_higher:function is_member_or_higher(){return User.get_current_user_level()>=20},is_mod_or_higher:function is_mod_or_higher(){return User.get_current_user_level()>=40}};// app/javascript/src/boot.coffee var import_ujs=__toESM(require_rails_ujs(),1);// app/javascript/src/classes/autocomplete.coffee var import_autocompleter=__toESM(require_autocomplete(),1);var $5;var Autocomplete;var autocompleterMap;$5=jQuery;autocompleterMap=function autocompleterMap(match){return{label:match,value:match}};var autocomplete_default=Autocomplete=/*#__PURE__*/function(){function Autocomplete2(){var _this9=this;_classCallCheck2(this,Autocomplete2);this._genericCompletion=this._genericCompletion.bind(this);this._genericCompletionAll=this._genericCompletionAll.bind(this);this._tagCompletion=this._tagCompletion.bind(this);$5(function(){_this9._genericCompletionAll();return _this9._tagCompletion()})}_createClass2(Autocomplete2,[{key:"_genericCompletion",value:function _genericCompletion(input){var url;url=input.dataset.autocomplete;return(0,import_autocompleter["default"])({input:input,fetch:function fetch(text,update){return $5.ajax(url,{data:{term:text},dataType:"json"}).done(function(matches){return update(matches.map(autocompleterMap))})},onSelect:function onSelect(match){return input.value=match.value}})}},{key:"_genericCompletionAll",value:function _genericCompletionAll(){var i2,input,len,ref,results;ref=document.querySelectorAll("[data-autocomplete]");results=[];for(i2=0,len=ref.length;i20){this.focus(0)}this.update()}},{key:"create_dragger",value:function create_dragger(){var _this13=this;var dragElementOptions,ref;if((ref=this.dragger)!=null){ref.destroy()}dragElementOptions={ondown:function ondown(e){var clickedElement,clicked_elements,element,frame,frame_element,frame_idx,j,k,l,len,len1,len2,len3,m,post,ref1,ref2;post=Post.posts.get(_this13.post_id);ref1=_this13.image_frames;for(j=0,len=ref1.length;j0&&e.aY>0?"se-resize":e.aX>0&&e.aY<0?"ne-resize":e.aX<0&&e.aY>0?"sw-resize":e.aX<0&&e.aY<0?"nw-resize":void 0;if(_this13.dragging_mode==null){return}_this13.dragging_new=false;frame_offset=$6(_this13.main_frame).offset();dims={left:e.dragger.anchor_x-frame_offset.left,top:e.dragger.anchor_y-frame_offset.top,height:0,width:0};_this13.dragging_anchor=dims;source_dims=frameDimensionsFromImage(dims,_this13.image_dimensions,post);_this13.dragging_idx=_this13.add_frame(source_dims);post.frames_pending[_this13.editing_frame]=source_dims}if(_this13.dragging_idx==null){return}dims=applyDrag(_this13.dragging_mode,e.aX,e.aY,_this13.image_dimensions,_this13.dragging_anchor);post.frames_pending[_this13.editing_frame]=frameDimensionsFromImage(dims,_this13.image_dimensions,post);_this13.update_frame_in_list(_this13.editing_frame);_this13.update_image_frame(_this13.editing_frame)}};this.dragger=new DragElement(this.main_frame,dragElementOptions)}},{key:"repopulate_table",value:function repopulate_table(){var _frame,i2,imageFrame,j,k,len,len1,post,ref,ref1,tbody;post=Post.posts.get(this.post_id);tbody=this.container.querySelector(".frame-list tbody");while(tbody.firstChild!=null){tbody.removeChild(tbody.firstChild)}ref=this.image_frames;for(j=0,len=ref.length;jFrame "+frame_idx+"";html+="";html+="";html+="";html+="";html+="X";html+="\u21E1";html+="\u21E3";tr.innerHTML=html;this.update_frame_in_list(frame_idx)}},{key:"update_frame_in_list",value:function update_frame_in_list(frame_idx){var frame,post,tr;post=Post.posts.get(this.post_id);frame=post.frames_pending[frame_idx];tr=this.container.querySelector(".frame-list tbody .frame-".concat(frame_idx));tr.querySelector(".frame-left").value=frame.source_left;tr.querySelector(".frame-top").value=frame.source_top;tr.querySelector(".frame-width").value=frame.source_width;tr.querySelector(".frame-height").value=frame.source_height}},{key:"update_frame_from_list",value:function update_frame_from_list(frame_idx){var frame,post,tr;post=Post.posts.get(this.post_id);frame=post.frames_pending[frame_idx];tr=this.container.querySelector(".frame-list tbody .frame-".concat(frame_idx));frame.source_left=tr.querySelector(".frame-left").value;frame.source_top=tr.querySelector(".frame-top").value;frame.source_width=tr.querySelector(".frame-width").value;frame.source_height=tr.querySelector(".frame-height").value}},{key:"add_frame",value:function add_frame(new_frame){var post;post=Post.posts.get(this.post_id);if(new_frame==null){new_frame={source_top:post.height*1/4,source_left:post.width*1/4,source_width:post.width/2,source_height:post.height/2}}post.frames_pending.push(new_frame);this.add_frame_to_list(post.frames_pending.length-1);this.create_image_frame();this.update_image_frame(post.frames_pending.length-1);this.focus(post.frames_pending.length-1);return post.frames_pending.length-1}},{key:"delete_frame",value:function delete_frame(frame_idx){var post,switch_to_frame;post=Post.posts.get(this.post_id);switch_to_frame=null;if(this.editing_frame===frame_idx){switch_to_frame=this.editing_frame;this.focus(null);if(frame_idx===post.frames_pending.length-1){--switch_to_frame}if(switch_to_frame<0){switch_to_frame=null}}post.frames_pending.splice(frame_idx,1);this.repopulate_table();this.focus(switch_to_frame)}},{key:"focus",value:function focus(post_frame){var cornerDragger,j,len,ref;if(this.editing_frame===post_frame){return}if(this.editing_frame!=null){this.container.querySelector(".frame-".concat(this.editing_frame)).classList.remove("frame-focused")}this.editing_frame=post_frame;if(this.editing_frame!=null){this.container.querySelector(".frame-".concat(this.editing_frame)).classList.add("frame-focused")}ref=this.corner_draggers;for(j=0,len=ref.length;j0.1||change_y>0.1){this.locked_to_x=change_x>change_y}}if(this.locked_to_x!=null){if(this.locked_to_x){coords[1]=this.shift_lock_anchor[1]}else{coords[0]=this.shift_lock_anchor[0]}}}coords[0]=Math.max(0,Math.min(coords[0],1));coords[1]=Math.max(0,Math.min(coords[1],1));return this.target.fire("viewer:center-on",{x:coords[0],y:coords[1]})}},{key:"set_autohide",value:function set_autohide(autohide){this.autohide=autohide;return this.update_visibility()}},{key:"update_visibility",value:function update_visibility(){var box,visible;box=this.container.down(".image-navigator-box");visible=!this.autohide||this.hovering||this.dragger.dragging;return box.style.visibility=visible?"visible":"hidden"}},{key:"destroy",value:function destroy(){this.dragger.destroy();this.handlers.each(function(h){return h.stop()});this.dragger=this.handlers=null;return this.container.hide()}}]);return Navigator2}();// app/javascript/src/classes/browser_view.coffee var $7;var BrowserView;var hasProp3={}.hasOwnProperty;$7=jQuery;var browser_view_default=BrowserView=/*#__PURE__*/function(){function BrowserView2(container){var _this15=this;_classCallCheck2(this,BrowserView2);var post_edit,tag_span;this.image_loaded_event=this.image_loaded_event.bind(this);this.edit_post_area_changed=this.edit_post_area_changed.bind(this);this.window_resize_event=this.window_resize_event.bind(this);this.toggle_view_large_image=this.toggle_view_large_image.bind(this);this.update_navigator=this.update_navigator.bind(this);this.parent_post_click_event=this.parent_post_click_event.bind(this);this.child_posts_click_event=this.child_posts_click_event.bind(this);this.container=container;this.wanted_post_id=null;this.wanted_post_frame=null;this.displayed_post_id=null;this.displayed_post_frame=null;this.current_ajax_request=null;this.last_preload_request=[];this.last_preload_request_active=false;this.img_box=this.container.down(".image-box");if(!Prototype.Browser.Opera){this.canvas=create_canvas_2d()}if(this.canvas){this.canvas.hide();this.img_box.appendChild(this.canvas)}this.zoom_level=0;this.post_ui_visible=true;Event.on(window,"resize",this.window_resize_event);document.on("viewer:vote",function(event){if(_this15.vote_widget){return _this15.vote_widget.set(event.memo.score)}});if(TagCompletion){TagCompletion.init()}this.container.down(".image-container").on("dblclick",".image-container",function(event){if(event.button){return}event.stop();return document.fire("viewer:set-thumb-bar",{toggle:true})});document.on("viewer:view-large-toggle",function(e){return _this15.toggle_view_large_image()});this.container.down(".post-info").on("click",".toggle-zoom",function(e){e.stop();return _this15.toggle_view_large_image()});this.container.down(".parent-post").down("A").on("click",this.parent_post_click_event);this.container.down(".child-posts").down("A").on("click",this.child_posts_click_event);this.container.down(".post-frames").on("click",".post-frame-link",function(e,item){e.stop();return document.fire("viewer:set-active-post",{post_id:_this15.displayed_post_id,post_frame:item.post_frame,center_thumbs:true})});this.thumb_bar_height=0;document.on("viewer:thumb-bar-changed",function(e){_this15.thumb_bar_height=e.memo.height;_this15.update_image_window_size();_this15.set_post_ui(e.memo.shown);return _this15.scale_and_position_image(true)});$7(document.body).toggleClass("not-member",!User.is_member_or_higher()).toggleClass("not-moderator",!User.is_mod_or_higher());tag_span=this.container.down(".post-tags");tag_span.on("click",".post-tag",function(e,element){e.stop();return document.fire("viewer:perform-search",{tags:element.tag_name})});this.container.down(".post-approve").on("click",function(e){var post_id;e.stop();if(!confirm("Approve this post?")){return}post_id=_this15.displayed_post_id;return Post.approve(post_id,false)});this.container.down(".post-unflag").on("click",function(e){var post_id;e.stop();if(!confirm("Unflag this post?")){return}post_id=_this15.displayed_post_id;return Post.unflag(post_id)});this.container.down(".post-delete").on("click",function(e){var default_reason,post,post_id,reason;e.stop();post=Post.posts.get(_this15.displayed_post_id);default_reason="";if(post.flag_detail){default_reason=post.flag_detail.reason}reason=prompt("Reason:",default_reason);if(!reason||reason===""){return}post_id=_this15.displayed_post_id;return Post.approve(post_id,reason)});this.container.down(".post-undelete").on("click",function(e){var post_id;e.stop();if(!confirm("Undelete this post?")){return}post_id=_this15.displayed_post_id;return Post.undelete(post_id)});this.container.down(".flag-button").on("click",function(e){var post_id;e.stop();post_id=_this15.displayed_post_id;return Post.flag(post_id)});this.container.down(".activate-post").on("click",function(e){var post_id;e.stop();post_id=_this15.displayed_post_id;if(!confirm("Activate this post?")){return}return Post.update_batch([{id:post_id,is_held:false}],function(){var post;post=Post.posts.get(post_id);if(post.is_held){return notice("Couldn't activate post")}else{return notice("Activated post")}})});this.container.down(".reparent-post").on("click",function(e){var post,post_id;e.stop();if(!confirm("Make this post the parent?")){return}post_id=_this15.displayed_post_id;post=Post.posts.get(post_id);if(post==null){return}return Post.reparent_post(post_id,post.parent_id,false)});this.container.down(".pool-info").on("click",".remove-pool-from-post",function(e,element){var pool,pool_info,pool_name;e.stop();pool_info=element.up(".pool-info");pool=Pool.pools[pool_info.pool_id];pool_name=pool.name.replace(/_/g," ");if(!confirm("Remove this post from pool #".concat(pool_info.pool_id,": ").concat(pool_name,"?"))){return}return Pool.remove_post(pool_info.post_id,pool_info.pool_id)});post_edit=this.container.down(".post-edit");post_edit.down("FORM").on("submit",function(e){e.stop();return _this15.edit_save()});this.container.down(".show-tag-edit").on("click",function(e){e.stop();return _this15.edit_show(true)});this.container.down(".edit-save").on("click",function(e){e.stop();return _this15.edit_save()});this.container.down(".edit-cancel").on("click",function(e){e.stop();return _this15.edit_show(false)});post_edit.down(".edit-tags").on("paste",function(){return _this15.edit_post_area_changed.defer()});post_edit.down(".edit-tags").on("keydown",function(){return _this15.edit_post_area_changed.defer()});new TagCompletionBox(post_edit.down(".edit-tags"));this.container.down(".post-edit").on("keydown",function(e){if(e.keyCode===Event.KEY_ESC){return _this15.edit_show(false)}else if(e.keyCode===Event.KEY_RETURN){e.stop();return _this15.edit_save()}});document.on("viewer:edit-post",function(e){document.fire("viewer:set-thumb-bar",{set:true});return _this15.edit_show(true)});$7(document).on("posts:update",function(e,postIds){if(postIds.has(_this15.displayed_post_id)==null){return}return _this15.set_post_info()});this.vote_widget=new Vote($7(this.container.down(".vote-container"),null));this.vote_widget.initShortcut();this.blacklist_override_post_id=null;this.container.down(".show-blacklisted").on("click",function(e){return e.preventDefault()});this.container.down(".show-blacklisted").on("dblclick",function(e){var post;e.stop();_this15.blacklist_override_post_id=_this15.displayed_post_id;post=Post.posts.get(_this15.displayed_post_id);return _this15.set_main_image(post,_this15.displayed_post_frame)});this.img_box.on("viewer:center-on",function(e){return _this15.center_image_on(e.memo.x,e.memo.y)});this.navigator=new navigator_default(this.container.down(".image-navigator"),this.img_box);this.container.on("swipe:horizontal",function(e){return document.fire("viewer:show-next-post",{prev:e.memo.right})});if(Prototype.BrowserFeatures.Touchscreen){this.create_voting_popup();this.image_swipe=new SwipeHandler(this.container.down(".image-container"))}this.container.down(".edit-frames-button").on("click",function(e){e.stop();return _this15.show_frame_editor()});this.frame_editor=new frame_editor_default(this.container.down(".frame-editor"),this.img_box,this.container.down(".frame-editor-popup"),{onClose:function onClose(){return _this15.hide_frame_editor()}});if(this.image_swipe==null){this.image_dragger=new WindowDragElementAbsolute(this.img_box,this.update_navigator)}}_createClass2(BrowserView2,[{key:"create_voting_popup",value:function create_voting_popup(){var _this16=this;var flash,last_dragged_over,popup_expand,popup_vote_widget_container;popup_vote_widget_container=this.container.down(".vote-popup-container");popup_vote_widget_container.show();this.popup_vote_widget=new Vote($7(popup_vote_widget_container),null);this.popup_vote_widget.initShortcut();flash=this.container.down(".vote-popup-flash");popup_expand=this.container.down(".vote-popup-expand");popup_expand.show();last_dragged_over=null;return this.popup_vote_dragger=new DragElement(popup_expand,{ondown:function ondown(drag){drag.latest_event.stop();flash.hide();flash.removeClassName("flash-star");_this16.popup_vote_widget.setMouseover(null);last_dragged_over=null;return popup_vote_widget_container.removeClassName("vote-popup-hidden")},onup:function onup(drag){var flash_x,flash_y,i2,offset,star;if(drag.cancelling){console.debug("cancelling drag");last_dragged_over=null}_this16.popup_vote_widget.setMouseover(last_dragged_over);star=_this16.popup_vote_widget.activateItem(last_dragged_over);if(star!=null){i2=0;while(i2<4){flash.removeClassName("star-".concat(i2));++i2}flash.addClassName("star-".concat(star));flash.show();offset=_this16.image_window_size;flash_x=offset.width/2-flash.offsetWidth/2;flash_y=offset.height/2-flash.offsetHeight/2;flash.setStyle({left:flash_x+"px",top:flash_y+"px"});flash.addClassName("flash-star")}popup_vote_widget_container.addClassName("vote-popup-hidden");return last_dragged_over=null},ondrag:function ondrag(drag){last_dragged_over=document.elementFromPoint(drag.x,drag.y);return _this16.popup_vote_widget.setMouseover(last_dragged_over)}})}},{key:"set_post_ui",value:function set_post_ui(visible){if(Prototype.BrowserFeatures.Touchscreen&&window.screen.availWidth<1024){visible=false}this.container.down(".post-info").show(visible)&&this.displayed_post_id!=null;if(visible===this.post_ui_visible){return}this.post_ui_visible=visible;if(this.navigator){this.navigator.set_autohide(!visible)}if(!this.post_ui_visible){return this.edit_show(false)}}},{key:"image_loaded_event",value:function image_loaded_event(event){this.img.fully_loaded=true;document.fire("viewer:displayed-image-loaded",{post_id:this.displayed_post_id,post_frame:this.displayed_post_frame});return this.update_canvas()}},{key:"post_frame_list_includes",value:function post_frame_list_includes(post_id_list,post_id,post_frame){var found_preload;found_preload=post_id_list.find(function(post){return post[0]===post_id&&post[1]===post_frame});return found_preload!=null}},{key:"preload",value:function preload(post_ids){var frame,i2,last_preload_request,new_preload_container,post,post_frame,post_id,ref;last_preload_request=this.last_preload_request;this.last_preload_request=post_ids;if(!this.post_frame_list_includes(last_preload_request,this.wanted_post_id,this.wanted_post_frame)){this.last_preload_request_active=false;return}this.last_preload_request_active=true;new_preload_container=new preload_container_default;i2=0;while(i20;if(!_this17.success){notice("Post #".concat(post_id," doesn't exist"));return}return Post.register_resp(resp2)}).always(function(resp2){var success;_this17.current_ajax_request=null;success=ok&&_this17.success;if(!success&&post_id===_this17.wanted_post_id){if(_this17.displayed_post_id==null){document.fire("viewer:set-thumb-bar",{set:true})}return}return _this17.set_post(_this17.wanted_post_id,_this17.wanted_post_frame)}).fail(function(resp2){return notice("Error ".concat(resp2.status," loading post"))})}},{key:"set_viewing_larger_version",value:function set_viewing_larger_version(b){var can_zoom,post;this.viewing_larger_version=b;post=Post.posts.get(this.displayed_post_id);can_zoom=post!=null&&post.jpeg_url!==post.sample_url;this.container.down(".zoom-icon-none").show(!can_zoom);this.container.down(".zoom-icon-in").show(can_zoom&&!this.viewing_larger_version);this.container.down(".zoom-icon-out").show(can_zoom&&this.viewing_larger_version);if(Prototype.BrowserFeatures.Touchscreen&&this.image_dragger){this.image_dragger.set_disabled(!b)}if(this.frame_editor){this.frame_editor.set_drag_to_create(!b);return this.frame_editor.set_show_corner_drag(!b)}}},{key:"set_main_image",value:function set_main_image(post,post_frame){var frame,hide_post;$7(this.img).off();this.img=removeImageElement(this.img);hide_post=Post.is_blacklisted(post.id)&&post.id!==this.blacklist_override_post_id;this.container.down(".blacklisted-message").show(hide_post);if(hide_post){return}this.img=document.createElement("img");this.img.className="main-image";if(this.canvas){this.canvas.hide()}this.img.show();this.img.setStyle({pointerEvents:"none"});$7(this.img).on("load",this.image_loaded_event);this.img.fully_loaded=false;if(post_frame!==-1&&post_frame0){return 0}else{return-1}}},{key:"get_post_frame_hash",value:function get_post_frame_hash(post,post_frame){var default_frame;default_frame=post.frames.length>0?0:-1;if(post_frame===default_frame){return null}else{return post_frame}}},{key:"set_post_info",value:function set_post_info(){var _postId,a,byEl,by_container,can_unflag,child_posts,deleted,div,file_extension,first,flag_post,flagged,frame_list,has_image,has_jpeg,has_permission,has_sample,html,i2,image_desc,is_flagger,m,m_old,parent_post,pending,png_desc,pool,pool_id,pool_info,pool_post,pool_title,post,ratings,reason,ref,sequence,source_box,tag_span,tags_by_type,text,url;post=Post.posts.get(this.displayed_post_id);if(!post){return}this.container.down(".post-id").setTextContent(post.id);this.container.down(".post-id-link").href="/post/show/"+post.id;this.container.down(".posted-by").show();timeago.constructor.set(this.container.down(".posted-at"),new Date(post.created_at*1e3));pool_info=this.container.down(".pool-info");while(pool_info.firstChild){pool_info.removeChild(pool_info.firstChild)}if(post.pool_posts!=null){ref=post.pool_posts;for(_postId in ref){if(!hasProp3.call(ref,_postId))continue;pool_post=ref[_postId];pool_id=pool_post.pool_id;pool=Pool.pools[pool_id];pool_title=pool.name.replace(/_/g," ");sequence=pool_post.sequence;if(sequence.match(/^[0-9]/)){sequence="#"+sequence}html="
    Post ${sequence} in ${desc} (pool page)";if(Pool.can_edit_pool(pool)){html+=" (remove)"}html+="
    ";div=html.subst({sequence:sequence,pool_id:pool_id,desc:pool_title.escapeHTML()}).createElement();div.post_id=post.id;div.pool_id=pool_id;pool_info.appendChild(div)}}if(post.creator_id!=null){this.container.down(".posted-by").down("A").href="/user/show/".concat(post.creator_id);this.container.down(".posted-by").down("A").setTextContent(post.author)}else{this.container.down(".posted-by").down("A").href="#";this.container.down(".posted-by").down("A").setTextContent("Anonymous")}this.container.down(".post-dimensions").setTextContent(post.width+"x"+post.height);this.container.down(".post-source").show(post.source!=="");if(post.source!==""){text=post.source;url=null;m_old=post.source.match(/^http:\/\/.*pixiv\.net\/(img\d+\/)?img\/([-\w]+)\/(\d+)(_.+)?\.\w+$/);m=post.source.match(/^https?:\/\/.*(?:pixiv\.net|pximg\.net)\/img.*?(\d+)(_s|_m|(_big)?_p\d+)?\.\w+(\?\d+)?$/);if(m_old){text="pixiv #".concat(m_old[3]," (").concat(m_old[2],")");url="http://www.pixiv.net/member_illust.php?mode=medium&illust_id=".concat(m_old[3])}else if(m){text="pixiv #".concat(m[1]);url="http://www.pixiv.net/member_illust.php?mode=medium&illust_id=".concat(m[1])}else if(post.source.substr(0,7)==="http://"){text=text.substr(7);if(text.substr(0,4)==="www."){text=text.substr(4)}if(text.length>20){text=text.substr(0,20)+"..."}url=post.source}source_box=this.container.down(".post-source");source_box.down("A").show(url!=null);source_box.down("SPAN").show(url==null);if(url){source_box.down("A").href=url;source_box.down("A").setTextContent(text)}else{source_box.down("SPAN").setTextContent(text)}}if(post.frames.length>0){this.container.down(".post-frames").removeClassName("no-frames");frame_list=this.container.down(".post-frame-list");while(frame_list.firstChild){frame_list.removeChild(frame_list.firstChild)}i2=-1;while(i2");a.tag_name=tag;span.appendChild(a);tag_span.appendChild(span)});flag_post=this.container.down(".flag-button");flag_post.show(post.status==="active");this.container.down(".post-approve").show(post.status==="flagged"||post.status==="pending");this.container.down(".post-delete").show(post.status!=="deleted");this.container.down(".post-undelete").show(post.status==="deleted");flagged=this.container.down(".flagged-info");flagged.show(post.status==="flagged");if(post.status==="flagged"&&post.flag_detail){byEl=flagged.down(".by");flagged.down(".flagged-by-box").show(post.flag_detail.user_id!=null);if(post.flag_detail.user_id!=null){byEl.setTextContent(post.flag_detail.flagged_by);byEl.href="/user/show/"+post.flag_detail.user_id}reason=flagged.down(".reason");reason.setTextContent(post.flag_detail.reason)}is_flagger=post.flag_detail&&post.flag_detail.user_id===User.get_current_user_id();can_unflag=flagged&&(User.is_mod_or_higher()||is_flagger);flagged.down(".post-unflag").show(can_unflag);pending=this.container.down(".status-pending");pending.show(post.status==="pending");this.container.down(".pending-reason-box").show(post.flag_detail&&post.flag_detail.reason);if(post.flag_detail){this.container.down(".pending-reason").setTextContent(post.flag_detail.reason)}deleted=this.container.down(".status-deleted");deleted.show(post.status==="deleted");if(post.status==="deleted"){by_container=deleted.down(".by-container");by_container.show(post.flag_detail.flagged_by!=null);byEl=by_container.down(".by");byEl.setTextContent(post.flag_detail.flagged_by);byEl.href="/user/show/"+post.flag_detail.user_id;reason=deleted.down(".reason");reason.setTextContent(post.flag_detail.reason)}this.container.down(".status-held").show(post.is_held);has_permission=User.get_current_user_id()===post.creator_id||User.is_mod_or_higher();this.container.down(".activate-post").show(has_permission)}},{key:"edit_show",value:function edit_show(shown){var post,rating_class,tags,tags_by_type;post=Post.posts.get(this.displayed_post_id);if(!post){shown=false}if(!User.is_member_or_higher()){shown=false}this.edit_shown=shown;this.container.down(".post-tags-box").show(!shown);this.container.down(".post-edit").show(shown);if(!shown){this.frame_editor.discard();return}this.select_edit_box(".post-edit-main");tags_by_type=Post.get_post_tags_with_type(post);tags=tags_by_type.pluck(0);tags=tags.join(" ")+" ";this.container.down(".edit-tags").old_value=tags;this.container.down(".edit-tags").value=tags;this.container.down(".edit-source").value=post.source;this.container.down(".edit-parent").value=post.parent_id;this.container.down(".edit-shown-in-index").checked=post.is_shown_in_index;rating_class=new Hash({s:".edit-safe",q:".edit-questionable",e:".edit-explicit"});this.container.down(rating_class.get(post.rating)).checked=true;this.edit_post_area_changed();return this.container.down(".edit-tags").focus()}},{key:"edit_post_area_changed",value:function edit_post_area_changed(){var element,parent_id,post_edit,rating,source;post_edit=this.container.down(".post-edit");element=post_edit.down(".edit-tags");element.style.height="0px";element.style.height=element.scrollHeight+"px";if(0){rating=null;source=null;parent_id=null;element.value.split(" ").each(function(tag){var m;tag=tag.toLowerCase();m=tag.match(/^(rating:)?([qse])$/);if(m){rating=m[2];return}m=tag.match(/^(parent):([0-9]+)$/);if(m){if(m[1]==="parent"){parent_id=m[2]}}m=tag.match(/^(source):(.*)$/);if(m){if(m[1]==="source"){source=m[2]}}}.bind(this));console.debug("rating: "+rating);console.debug("source: "+source);console.debug("parent: "+parent_id)}}},{key:"edit_save",value:function edit_save(){var _this19=this;var edit_tags,post_id,rating_class,save_completed,selected_rating,tags;save_completed=function(){notice("Post saved");if(this.displayed_post_id===post_id){this.edit_show(false)}}.bind(this);post_id=this.displayed_post_id;if(this.frame_editor){if(this.frame_editor.is_opened()){this.frame_editor.save(save_completed);return}}edit_tags=this.container.down(".edit-tags");tags=edit_tags.value;edit_tags.blur();rating_class=new Hash({s:".edit-safe",q:".edit-questionable",e:".edit-explicit"});selected_rating="s";rating_class.each(function(c){if(_this19.container.down(c[1]).checked){return selected_rating=c[0]}});Post.update_batch([{id:post_id,tags:this.container.down(".edit-tags").value,old_tags:this.container.down(".edit-tags").old_value,source:this.container.down(".edit-source").value,parent_id:this.container.down(".edit-parent").value,is_shown_in_index:this.container.down(".edit-shown-in-index").checked,rating:selected_rating}],save_completed)}},{key:"window_resize_event",value:function window_resize_event(e){if(e.stopped){return}this.update_image_window_size();return this.scale_and_position_image(true)}},{key:"toggle_view_large_image",value:function toggle_view_large_image(){var post;post=Post.posts.get(this.displayed_post_id);if(post==null){return}if(this.img==null){return}if(post.jpeg_url===post.sample_url){return}this.set_viewing_larger_version(!this.viewing_larger_version);this.set_main_image(post)}},{key:"update_image_window_size",value:function update_image_window_size(){this.image_window_size=getWindowSize();this.image_window_size.height-=this.thumb_bar_height;this.image_window_size.height=Math.max(this.image_window_size.height,0);this.update_navigator()}},{key:"scale_and_position_image",value:function scale_and_position_image(resizing){var img_box,original_height,original_width,post,ratio,window_size,x,y;img_box=this.img_box;if(!this.img){return}original_width=img_box.original_width;original_height=img_box.original_height;post=Post.posts.get(this.displayed_post_id);if(!post){console.debug("unexpected: displayed post "+this.displayed_post_id+" unknown");return}window_size=this.image_window_size;ratio=1;if(!this.viewing_larger_version){ratio=window_size.width/original_width;if(original_height*ratio>window_size.height){ratio=window_size.height/original_height}}ratio*=Math.pow(0.9,this.zoom_level);this.displayed_image_width=Math.round(original_width*ratio);this.displayed_image_height=Math.round(original_height*ratio);this.img.width=this.displayed_image_width;this.img.height=this.displayed_image_height;this.update_canvas();if(this.frame_editor){this.frame_editor.set_image_dimensions(this.displayed_image_width,this.displayed_image_height)}if(resizing&&this.viewing_larger_version){return}x=0.5;y=0.5;if(this.viewing_larger_version){y=this.image_window_size.height/2;y/=this.displayed_image_height}this.center_image_on(x,y)}},{key:"update_navigator",value:function update_navigator(){var height_percent,percent_x,percent_y,scroll_x,scroll_y,width_percent,x,y;if(!this.navigator){return}if(!this.img){return}scroll_x=-this.img_box.offsetLeft;scroll_y=-this.img_box.offsetTop;x=scroll_x+this.image_window_size.width/2;y=scroll_y+this.image_window_size.height/2;percent_x=x/this.displayed_image_width;percent_y=y/this.displayed_image_height;height_percent=this.image_window_size.height/this.displayed_image_height;width_percent=this.image_window_size.width/this.displayed_image_width;this.navigator.image_position_changed(percent_x,percent_y,height_percent,width_percent)}},{key:"update_canvas",value:function update_canvas(){var ctx;if(!this.img.fully_loaded){console.debug("image incomplete; can't render to canvas");return false}if(!this.canvas){return}if(this.canvas.rendered_url===this.img.src&&this.canvas.width===this.displayed_image_width&&this.canvas.height===this.displayed_image_height){return}this.canvas.rendered_url=this.img.src;this.canvas.width=this.displayed_image_width;this.canvas.height=this.displayed_image_height;ctx=this.canvas.getContext("2d");ctx.drawImage(this.img,0,0,this.displayed_image_width,this.displayed_image_height);this.canvas.show();this.img.hide();return true}},{key:"center_image_on",value:function center_image_on(percent_x,percent_y){var scroll_x,scroll_y,x,y;x=percent_x*this.displayed_image_width;y=percent_y*this.displayed_image_height;scroll_x=x-this.image_window_size.width/2;scroll_x=Math.round(scroll_x);scroll_y=y-this.image_window_size.height/2;scroll_y=Math.round(scroll_y);this.img_box.setStyle({left:-scroll_x+"px",top:-scroll_y+"px"});this.update_navigator()}},{key:"cancel_lazily_load",value:function cancel_lazily_load(){if(this.lazy_load_timer==null){return}window.clearTimeout(this.lazy_load_timer);this.lazy_load_timer=null}},{key:"parent_post_click_event",value:function parent_post_click_event(event){var post;event.stop();post=Post.posts.get(this.displayed_post_id);if(post==null||post.parent_id==null){return}this.set_post(post.parent_id)}},{key:"child_posts_click_event",value:function child_posts_click_event(event){event.stop();document.fire("viewer:perform-search",{tags:"parent:"+this.displayed_post_id,results_mode:"center-on-current"})}},{key:"select_edit_box",value:function select_edit_box(className){if(this.shown_edit_container){this.shown_edit_container.hide()}this.shown_edit_container=this.container.down(className);this.shown_edit_container.show()}},{key:"show_frame_editor",value:function show_frame_editor(){var post_frame;this.select_edit_box(".frame-editor");post_frame=null;if(this.displayed_post_frame!==-1){post_frame=this.displayed_post_frame;document.fire("viewer:set-active-post",{post_id:this.displayed_post_id,post_frame:-1})}this.frame_editor.open(this.displayed_post_id);this.container.down(".post-frames").hide();if(post_frame!=null){this.frame_editor.focus(post_frame)}}},{key:"hide_frame_editor",value:function hide_frame_editor(){this.frame_editor.discard();this.container.down(".post-frames").show()}}]);return BrowserView2}();// app/javascript/src/classes/check_all.coffee var $8;var CheckAll;$8=jQuery;var check_all_default=CheckAll=/*#__PURE__*/function(){function CheckAll2(){_classCallCheck2(this,CheckAll2);this._checkAll=this._checkAll.bind(this);this._target=this._target.bind(this);$8(document).on("click",".js-check_all",this._checkAll)}_createClass2(CheckAll2,[{key:"_checkAll",value:function _checkAll(e){e.preventDefault();return this._target(e.currentTarget.getAttribute("data-target")).attr("checked",true)}},{key:"_target",value:function _target(name){return $8(".js-check_all-target[data-target='".concat(name,"']"))}}]);return CheckAll2}();// app/javascript/src/classes/comment.coffee var $9;var Comment;var t2;$9=jQuery;t2=I18n.scopify("js.comment");var comment_default=Comment=/*#__PURE__*/function(){function Comment2(){_classCallCheck2(this,Comment2);$9(document).on("click",".js-comment--destroy",this.destroy);$9(document).on("click",".js-comment--flag",this.flag);$9(document).on("click",".js-comment--quote",this.quote);$9(document).on("click",".js-comment--show-reply-form",this.showReplyForm);$9(document).on("click",".js-comment--spoiler",this.spoiler)}_createClass2(Comment2,[{key:"spoiler",value:function spoiler(e){return $9(e.currentTarget).hide().next(".spoilertext").show()}},{key:"flag",value:function flag(e){var id2;e.preventDefault();if(!confirm(t2(".flag_ask"))){return}id2=e.currentTarget.dataset.commentId;notice(t2(".flag_process"));return $9.ajax({url:Moebooru.path("/comment/mark_as_spam.json"),type:"post",data:{id:id2,comment:{is_spam:1}}}).done(function(resp2){return notice(t2(".flag_notice"))}).fail(function(resp2){resp2=$9.parseJSON(resp2.responseText);return notice("".concat(t2("js.error")).concat(resp2.reason))})}},{key:"quote",value:function quote(e){var id2;e.preventDefault();id2=e.currentTarget.dataset.commentId;return $9.ajax({url:Moebooru.path("/comment/show.json"),type:"get",data:{id:id2}}).done(function(resp2){var body,replyBox,strippedBody;strippedBody=resp2.body.replace(/\[quote\](?:.|\n|\r)+?\[\/quote\](?:\r\n|\r|\n)*/gm,"");body="[quote]".concat(resp2.creator," ").concat(t2("js.said"),"\n").concat(strippedBody,"\n[/quote]\n\n");$9("#reply-".concat(resp2.post_id)).show();$9("#respond-link-".concat(resp2.post_id)).hide();replyBox=$9("#reply-text-".concat(resp2.post_id));replyBox.val("".concat(replyBox.val()).concat(body));return replyBox.focus()}).fail(function(){return notice(t2(".quote_error"))})}},{key:"destroy",value:function destroy(e){var id2;e.preventDefault();if(!confirm(t2(".delete_ask"))){return}id2=e.currentTarget.dataset.commentId;return $9.ajax({url:Moebooru.path("/comment/destroy.json"),type:"post",data:{id:id2}}).done(function(resp2){return document.location.reload()}).fail(function(resp2){resp2=$9.parseJSON(resp2.responseText);return notice("".concat(t2(".delete_error")).concat(resp2.reason))})}},{key:"showReplyForm",value:function showReplyForm(e){var postId;e.preventDefault();postId=e.currentTarget.dataset.commentPostId;$9("#respond-link-".concat(postId)).hide();return $9("#reply-".concat(postId)).show().find("textarea").focus()}}]);return Comment2}();// app/javascript/src/classes/dmail.coffee var $10;var Dmail;var t3;$10=jQuery;t3=I18n.scopify("js.dmail");var dmail_default=Dmail=/*#__PURE__*/function(){function Dmail2(){_classCallCheck2(this,Dmail2);$10(document).on("click",".js-dmail--respond",this.respond);$10(document).on("click",".js-dmail--expand",this.expand)}_createClass2(Dmail2,[{key:"expand",value:function expand(e){var id2,parentId;e.preventDefault();parentId=e.currentTarget.dataset.dmailParentId;id2=e.currentTarget.dataset.dmailId;notice(t3(".fetch_prev_msg"));return $10.ajax({url:Moebooru.path("/dmail/show_previous_messages"),type:"get",data:{id:id2,parent_id:parentId}}).done(function(data){$10("#previous-messages").html(data);$10("#previous-messages").show();return notice(t3(".prev_msg_loaded"))})}},{key:"respond",value:function respond(e){var strippedBody,to;e.preventDefault();to=e.currentTarget.dataset.dmailName;$10("#dmail_to_name").val(to);strippedBody=$10("#dmail_body").val().replace(/\[quote\](?:.|\n)+?\[\/quote\]\n*/gm,"");$10("#dmail_body").val("[quote]You said:\n".concat(strippedBody,"\n[/quote]\n\n"));return $10("#response").show()}}]);return Dmail2}();// app/javascript/src/classes/favorite.coffee var $11;var Favorite;var userLink;var usersLinks;$11=jQuery;userLink=function userLink(id2,name){return"").concat(name,"")};usersLinks=function usersLinks(users){return users.map(function(user){return userLink(user.id,user.name)}).join(", ")};var favorite_default=Favorite=/*#__PURE__*/function(){function Favorite2(){_classCallCheck2(this,Favorite2);this.onShowMoreFavoritedBy=this.onShowMoreFavoritedBy.bind(this);$11(document).on("click",".js-favorite--show-more",this.onShowMoreFavoritedBy)}_createClass2(Favorite2,[{key:"linkToUsers",value:function linkToUsers(users){var html;if(users==null){users=[]}if(users.length===0){return I18n.t("js.noone")}html=usersLinks(users.slice(0,7));if(users.length>6){html+="");html+=" (".concat(users.length-6," more)")}return html}},{key:"onShowMoreFavoritedBy",value:function onShowMoreFavoritedBy(e){e.preventDefault();$11(e.target).closest("span").hide();return $11("#remaining-favs").show()}}]);return Favorite2}();// app/javascript/src/classes/history.coffee var $12;var History;$12=jQuery;var history_default=History=/*#__PURE__*/function(){function History2(){_classCallCheck2(this,History2);this.doc_mouseup=this.doc_mouseup.bind(this);this.last_click=-1;this.checked=[];this.dragging=false}_createClass2(History2,[{key:"init",value:function init(){var _this20=this;$12("#history").on("mousedown",function(event){if(!event.shiftKey){_this20.last_click=-1}_this20.mouse_is_down();event.stopPropagation();return event.preventDefault()});return this.update()}},{key:"add_change",value:function add_change(change_id,group_by_type,group_by_id,ids,user_id){var _this21=this;var row;row=$12("#r".concat(change_id));this.checked.push({id:change_id,ids:ids,group_by_type:group_by_type,group_by_id:group_by_id,user_id:user_id,on:false,row:row});row.on("mousedown",function(e){return _this21.mousedown(change_id,e)});row.on("mouseover",function(e){return _this21.mouseover(change_id,e)});row.find(".id").on("click",function(event){return _this21.id_click(change_id)});row.find(".author").on("click",function(event){return _this21.author_click(change_id)});return row.find(".change").on("click",function(event){return _this21.change_click(change_id)})}},{key:"update",value:function update(){var entry,j,len,ref,row;ref=this.checked;for(j=0,len=ref.length;j0){$12("#undo").removeClass("footer-disabled");return $12("#redo").removeClass("footer-disabled")}else{$12("#undo").addClass("footer-disabled");return $12("#redo").addClass("footer-disabled")}}},{key:"id_click",value:function id_click(id2){var entry;id2=this.get_row_by_id(id2);entry=this.checked[id2];return $12("#search").val("".concat(entry.group_by_type.toLowerCase(),":").concat(entry.group_by_id))}},{key:"author_click",value:function author_click(id2){id2=this.get_row_by_id(id2);return $12("#search").val("user:".concat(this.checked[id2].user_id))}},{key:"change_click",value:function change_click(id2){id2=this.get_row_by_id(id2);return $12("#search").val("change:".concat(this.checked[id2].id))}},{key:"count_selected",value:function count_selected(){var entry,j,len,ref,ret;ret=0;ref=this.checked;for(j=0,len=ref.length;j0){mainMessage="Changes ".concat(redo?"reapplied":"undone",".");text.unshift(mainMessage)}return notice(text.join("
    "))}).fail(function(resp2){return notice("Error: ".concat(resp2.reason))})}}]);return History2}();// app/javascript/src/classes/image_crop.coffee var import_cropperjs=__toESM(require_cropper(),1);var $13;var ImageCrop;var convertCropperToForm;var convertFormToCropper;var hasProp4={}.hasOwnProperty;$13=jQuery;convertCropperToForm=function convertCropperToForm(cropper){var coord,cropperData,form,formParsed,rect,value;rect=cropper.getCanvasData();cropperData=cropper.getData();formParsed={left:cropperData.x/rect.width,right:(cropperData.x+cropperData.width)/rect.width,top:cropperData.y/rect.height,bottom:(cropperData.y+cropperData.height)/rect.height};form={};for(coord in formParsed){if(!hasProp4.call(formParsed,coord))continue;value=formParsed[coord];form[coord]=value.toFixed(4)}return form};convertFormToCropper=function convertFormToCropper(cropper,form){var base,coord,formParsed,parsed,rect,validForm,value;rect=cropper.getCanvasData();formParsed={};validForm=true;for(coord in form){if(!hasProp4.call(form,coord))continue;value=form[coord];parsed=parseFloat(value);if(parsed===0){validForm=false;break}else{formParsed[coord]=parsed}}if(validForm){return{x:formParsed.left*rect.width,width:(formParsed.right-formParsed.left)*rect.width,y:formParsed.top*rect.height,height:(formParsed.bottom-formParsed.top)*rect.height}}else{base=Math.min(rect.width,rect.height)/4;return{x:base,width:base,y:base,height:base}}};var image_crop_default=ImageCrop=/*#__PURE__*/function(){function ImageCrop2(){_classCallCheck2(this,ImageCrop2);this.focusSubmit=this.focusSubmit.bind(this);this.initialize=this.initialize.bind(this);this.onCropend=this.onCropend.bind(this);this.onReady=this.onReady.bind(this);this.onWindowChange=this.onWindowChange.bind(this);this.positionPreview=this.positionPreview.bind(this);$13(this.initialize)}_createClass2(ImageCrop2,[{key:"focusSubmit",value:function focusSubmit(){var ref;return(ref=this.submit)!=null?ref.focus({preventScroll:true}):void 0}},{key:"initialize",value:function initialize(){var options;this.form=document.querySelector(".js-image-crop");if(this.form==null){return}this.image=this.form.querySelector(".js-image-crop--image");this.preview=this.form.querySelector(".js-image-crop--preview");this.submit=this.form.querySelector("input[type=\"submit\"]");options={checkCrossOrigin:false,movable:false,preview:this.preview,rotatable:false,scalable:false,zoomable:false};this.image.addEventListener("cropend",this.onCropend);this.image.addEventListener("ready",this.onReady);this.cropper=new import_cropperjs["default"](this.image,options);if(this.preview!=null){this.previewContainer=document.querySelector(".js-image-crop--preview-container");$13(window).on("resize scroll",this.onWindowChange);this.positionPreview()}return this.focusSubmit()}},{key:"onCropend",value:function onCropend(e){var coord,ref,value;ref=convertCropperToForm(this.cropper);for(coord in ref){if(!hasProp4.call(ref,coord))continue;value=ref[coord];this.form.querySelector("#".concat(coord)).value=value}return this.focusSubmit()}},{key:"onReady",value:function onReady(){var coord,form,i2,len,ref;form={};ref=["left","right","top","bottom"];for(i2=0,len=ref.length;i2maxRight){left=Math.min(imageRect.right,maxRight)-previewRect.width-10}top=Math.max(0,imageRect.top)+10;this.previewContainer.style.left="".concat(left,"px");return this.previewContainer.style.top="".concat(top,"px")}}]);return ImageCrop2}();// app/javascript/src/classes/inline_image.coffee var InlineImage;var inline_image_default=InlineImage=/*#__PURE__*/function(){function InlineImage2(){_classCallCheck2(this,InlineImage2);this.mouse_down=null;this.zoom_levels=[1,1.5,2,4]}_createClass2(InlineImage2,[{key:"init",value:function init(){var _this22=this;document.observe("mouseup",function(e){var data;if(e.button!==0){return}if(_this22.mouse_down==null){return}e.stop();data=_this22.mouse_down;_this22.mouse_down=null;_this22.show_image_no(data.html_id,data.toggled_from);data.toggled_from=null})}},{key:"get_zoom",value:function get_zoom(level){if(level>=0){return this.zoom_levels[level]}else{return 1/this.zoom_levels[-level]}}},{key:"register",value:function register(id2,data){var _this23=this;var button_id,container,idx,text,ui_html,viewer_img,zoom_id;container=$(id2);data.html_id=id2;container.inline_image=data;data.initted=false;data.expanded=false;data.toggled_from=null;data.current=-1;data.zoom_level=0;ui_html="";if(data.images.length>1){idx=0;while(idx"+text+"";++idx}}ui_html+="+";ui_html+="-";zoom_id=data.html_id+"-zoom";ui_html+="100%";ui_html+="Close";ui_html+="Image #"+data.id+"";container.down(".expanded-image-ui").innerHTML=ui_html;container.down(".inline-thumb").observe("click",function(e){e.stop();_this23.expand(data.html_id)});container.observe("dblclick",function(e){e.stop()});viewer_img=container.down(".main-inline-image");if(data.images.length>1){viewer_img.addClassName("clickable")}viewer_img.observe("mousedown",function(e){if(e.button!==0){return}data.toggled_from=data.current;idx=(data.current+1)%data.images.length;_this23.show_image_no(data.html_id,idx);_this23.mouse_down=data;e.stop()})}},{key:"expand",value:function expand(id2){var container,data,height,idx,image,images,img_html,img_id,src,viewer_img,width;container=$(id2);data=container.inline_image;data.expanded=true;if(!data.initted){data.initted=true;images=data["images"];img_html="";idx=0;while(idx