!function(e){"use strict";window.Reci.Form||(window.Reci.Form={});let r=window.Reci.Utils.common,t=window.Reci.Utils.form,n=window.Reci.Utils.promise,o=window.Reci.Utils.eh,a=window.Reci.Mst,l=window.Reci.Func,c=!0;e.loader_selector=null,e.msg_container_selector="#"+e.form_id+" ul.err",e.back_selector="#"+e.form_id+" [data-act=back]",e.err_cls="notyet",e.base_url=new URL(e.base_url,location.href);let i=$("#"+e.form_id);window.Reci.Form.dom=i;let s=new ReciAjaxFormUtils(e);window.Reci.Form.instance=s,window.Reci.Form.ipt={};let f={};window.Reci.Form.blk=f;let m=r.getCurQsObj(e.base_url);m.ajax="chkall";let u=new window.Reci.Class.Fetch,h=n.singleton(),d=function(){function r(e){return String(e.attr("name")).replace(/\[\]$/,"")}return{refreshStep:function e(r){$("[data-step]").each(function(){$(this).data("step")===r?$(this).addClass("on"):$(this).removeClass("on")}),setTimeout(function(){$("html").scrollTop(0)},0)},addBlk:function n(o,a){let l=new window.Reci.Class.FrmBlk(a);f[o]=l,l.on("do_err",function(n){if(!n.dom)return;let o=r(n.dom);t.refreshMsg(e.msg_container_selector,o,n.err);let a=t.chkGrpErr(n.err);t.doRefreshHighlight(n.dom,e.err_cls,a)}),l.on("clear_err",function(n){if(!n.dom)return;let o=r(n.dom);t.refreshAllMsg(e.msg_container_selector,o,!0),t.doRefreshHighlight(n.dom,e.err_cls,!0)})},refreshReq:function e(){let r=a.req?a.req:{};if(arguments.length>0){let t=arguments[0],n=$("[data-require='"+t+"']");r[t]?n.show():n.hide()}else for(let o in r){let l=$("[data-require='"+o+"']");r[o]?l.show():l.hide()}}}}();window.Reci.Form.func=d,s.on("before",function(){o._call("loader.start")}),s.on("always",function(){o._call("loader.stop")}),s.ajax.on("before",function(){o._call("loader.start")}),s.ajax.on("always",function(){o._call("loader.stop")}),s.on("ajaxFail",function(e,r,t,n){return l.onAjaxFail(r,t,n),!1}),s.on("fail",function(){o._call("msg","warn","ËÍÐŤËʧ”¡¤·¤Þ¤·¤¿¡£")}),s.on("refresh",function(e){d.refreshStep(e),d.refreshReq(),c&&(c=!1,setTimeout(function(){do{if(!location.hash)break;let e=document.querySelector(location.hash);if(!e)break;e.scrollIntoView({behavior:"smooth"})}while(!1)}))}),s.on("err",function(e,t){t.cool_down?o._call("msg","warn","áá"+t.cool_down+"Ãë¤ò¤ª´ý¤ÁϤµ¤¤¡£"):e!==r.constobj.ipt?(o._call("msg","warn","ËÍÐŤËʧ”¡¤·¤Þ¤·¤¿¡£"),s.replaceState(r.constobj.ipt),s.refresh(r.constobj.ipt)):t.err||o._call("msg","warn","¥µ©`¥Ð©`„IÀí¤Ëʧ”¡¤·¤Þ¤·¤¿¡£")}),o.addSeq("form.beforeSubmit","chkall",function(n){return h.cancel("by new thread").then(function(){return n.act===r.constobj.ipt?h.exec(function(r){let t=new FormData(i.get(0));return u.send(e.base_url.pathname+"?"+$.param(m),{method:e.method,body:t,signal:r.signal})}).then(function(r){if(!r.json)throw{type:"fail"};i.find("[name]."+e.err_cls+", label."+e.err_cls).removeClass(e.err_cls),n.err=r.json.err?r.json.err:{};let o=i.find("[name='membership']");n.err.membership={notEmpty:0===o.length||o.is(":checked")};let a=i.find("[name='privacy']");if(n.err.privacy={notEmpty:0===a.length||a.is(":checked")},!t.chkAllErr(n.err))throw{type:"err",data:n};return n}):n})},0),o.addSeq("form.beforeSubmit.err","doErr",function(e){return e&&"err"===e.type&&s.doError(e.act,e.data),e&&e.msg&&o._call("msg","warn",e.msg),e},0),s.on("beforeSubmit",function(n){return n===r.constobj.ipt&&($(e.msg_container_selector+"[data-name]").each(function(){s.refreshAllMsg($(this).data("name"),!0)}),t.refreshAllMsg(e.msg_container_selector,"recap",!0)),o._call("loader.start"),o.exeSeq("form.beforeSubmit",{act:n,err:{}}).then(function(){s.doSubmit(n)}).catch(l.onReject).catch(function(e){return e.act=n,o.exeSeq("form.beforeSubmit.err",e)}).finally(function(){o._call("loader.stop")}),!1})}(window.Reci.Form.param);