🎩 You're Invited:Meet the Socket team at Black Hat in Las Vegas, August 3-6.RSVP
Sign In

@libreform/libreform

Package Overview
Dependencies
Maintainers
2
Versions
16
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@libreform/libreform - npm Package Compare versions

Comparing version
2.0.0
to
2.0.3
+1
-1
dist/wplf-frontend.min.js

@@ -1,1 +0,1 @@

!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.WPLF=t():e.WPLF=t()}(this,(function(){return function(e){var t={};function r(n){if(t[n])return t[n].exports;var a=t[n]={i:n,l:!1,exports:{}};return e[n].call(a.exports,a,a.exports,r),a.l=!0,a.exports}return r.m=e,r.c=t,r.d=function(e,t,n){r.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:n})},r.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},r.t=function(e,t){if(1&t&&(e=r(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var n=Object.create(null);if(r.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var a in e)r.d(n,a,function(t){return e[t]}.bind(null,a));return n},r.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return r.d(t,"a",t),t},r.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},r.p="",r(r.s=32)}([,function(e,t,r){"use strict";t.a=function(e){return Object.assign({backendUrl:null,fetchCredentials:"same-origin",requestHeaders:{"X-WP-Nonce":null},assetsDir:null,settings:{autoinit:!0,parseLibreformShortcodeInRestApi:!0,hasUnfilteredHtml:!0,debugLevel:"all"},post:null,i18n:{}},e.wplfData)}(window)},function(e,t,r){"use strict";var n=r(1).a.settings.debugLevel,a=window.console||{log(){},error(){}};t.a={notice:function(e){for(var t=arguments.length,r=new Array(t>1?t-1:0),o=1;o<t;o++)r[o-1]=arguments[o];return"all"===n&&a.log("WPLF: ".concat(e),r)},error:function(e){for(var t=arguments.length,r=new Array(t>1?t-1:0),o=1;o<t;o++)r[o-1]=arguments[o];return"none"!==n&&a.error("WPLF error: ".concat(e),r)}}},function(e,t,r){"use strict";t.a=function(e){return!!e&&("getAttribute"in e&&"tagName"in e)}},function(e,t,r){"use strict";var n,a;r.d(t,"b",(function(){return n})),r.d(t,"a",(function(){return a})),function(e){e[e.Unsubmitted=0]="Unsubmitted",e[e.Submitting=1]="Submitting",e[e.Success=2]="Success",e[e.Error=3]="Error"}(n||(n={})),function(e){e.GetForm="getForm",e.GetForms="getForms",e.GetSubmissions="getSubmissions",e.GetSubmission="getSubmission",e.DeleteSubmissions="deleteSubmissions",e.RenderForm="renderForm",e.SubmitForm="submitForm",e.ApiError="apiError"}(a||(a={}))},function(e,t,r){"use strict";r.d(t,"a",(function(){return y}));var n=r(9),a=r.n(n),o=r(1);function i(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function u(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?i(Object(r),!0).forEach((function(t){c(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):i(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}function c(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function s(e,t,r,n,a,o,i){try{var u=e[o](i),c=u.value}catch(e){return void r(e)}u.done?t(c):Promise.resolve(c).then(n,a)}function f(e){return function(){var t=this,r=arguments;return new Promise((function(n,a){var o=e.apply(t,r);function i(e){s(o,n,a,i,u,"next",e)}function u(e){s(o,n,a,i,u,"throw",e)}i(void 0)}))}}function l(e){var t,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=function(){t&&t.abort&&t.abort()},i=f(regeneratorRuntime.mark((function n(){var i,c,s,f,l,h,d;return regeneratorRuntime.wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return n.prev=0,t=new a.a,n.next=4,fetch(o.a.backendUrl+e,u({method:"GET",signal:t.signal,credentials:o.a.fetchCredentials||"same-origin",headers:o.a.requestHeaders||{}},r));case 4:return i=n.sent,c=i.headers,s=i.status,f=i.statusText,l=i.url,h=i.ok,n.next=8,i.json();case 8:return d=n.sent,t=null,n.abrupt("return",{headers:c,status:s,statusText:f,url:l,ok:h,data:d});case 13:if(n.prev=13,n.t0=n.catch(0),t=null,"AbortError"===n.t0.name){n.next=18;break}throw n.t0;case 18:return n.abrupt("return",n.t0);case 19:case"end":return n.stop()}}),n,null,[[0,13]])})))();return Object.assign(i,{abort:n})}var h=r(4);function d(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function m(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?d(Object(r),!0).forEach((function(t){b(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):d(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}function b(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function p(e,t,r,n,a,o,i){try{var u=e[o](i),c=u.value}catch(e){return void r(e)}u.done?t(c):Promise.resolve(c).then(n,a)}function v(e){return function(){var t=this,r=arguments;return new Promise((function(n,a){var o=e.apply(t,r);function i(e){p(o,n,a,i,u,"next",e)}function u(e){p(o,n,a,i,u,"throw",e)}i(void 0)}))}}function g(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}var y=new(function(){function e(){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e)}var t,r,n,a,i,u,c,s,f,d;return t=e,(r=[{key:"requestRender",value:(d=v(regeneratorRuntime.mark((function e(t,r){var n,a,i;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return(n=new FormData).append("content",r),n.append("form",t.toString()),o.a.lang&&n.append("lang",o.a.lang),e.next=6,l("/renderForm",{method:"POST",body:n});case 6:return(a=e.sent).ok,i=m(m({},a),{},{kind:h.a.RenderForm}),e.abrupt("return",i);case 10:case"end":return e.stop()}}),e)}))),function(e,t){return d.apply(this,arguments)})},{key:"requestForm",value:(f=v(regeneratorRuntime.mark((function e(t){var r,n,a,i;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return r="",o.a.lang&&(r="&lang=".concat(o.a.lang)),n="/getForm?form=".concat(t).concat(r),e.next=5,l(n,{method:"GET"});case 5:return(a=e.sent).ok,i=m(m({},a),{},{kind:h.a.GetForm}),e.abrupt("return",i);case 9:case"end":return e.stop()}}),e)}))),function(e){return f.apply(this,arguments)})},{key:"requestForms",value:(s=v(regeneratorRuntime.mark((function e(t){var r,n,a,i;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return r="",o.a.lang&&(r="&lang=".concat(o.a.lang)),n="/getForms?page=".concat(t).concat(r),e.next=5,l(n,{method:"GET"});case 5:return(a=e.sent).ok,i=m(m({},a),{},{kind:h.a.GetForms}),e.abrupt("return",i);case 9:case"end":return e.stop()}}),e)}))),function(e){return s.apply(this,arguments)})},{key:"deleteSubmissions",value:(c=v(regeneratorRuntime.mark((function e(t,r){var n,a;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,l("/deleteSubmissions",{method:"DELETE",headers:m(m({},o.a.requestHeaders),{},{"Content-Type":"application/json"}),body:JSON.stringify({form:t,submissionUuids:r})});case 2:return(n=e.sent).ok,a=m(m({},n),{},{kind:h.a.DeleteSubmissions}),e.abrupt("return",a);case 6:case"end":return e.stop()}}),e)}))),function(e,t){return c.apply(this,arguments)})},{key:"requestSubmissions",value:(u=v(regeneratorRuntime.mark((function e(t,r,n){var a,o;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,l("/getSubmissions?form=".concat(t,"&page=").concat(r,"&limit=").concat(n),{method:"GET"});case 2:return(a=e.sent).ok,o=m(m({},a),{},{kind:h.a.GetSubmissions}),e.abrupt("return",o);case 6:case"end":return e.stop()}}),e)}))),function(e,t,r){return u.apply(this,arguments)})},{key:"requestSubmission",value:(i=v(regeneratorRuntime.mark((function e(t,r){var n,a;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,l("/getSubmission?form=".concat(t,"&uuid=").concat(r),{method:"GET"});case 2:return(n=e.sent).ok,a=m(m({},n),{},{kind:h.a.GetSubmission}),e.abrupt("return",a);case 6:case"end":return e.stop()}}),e)}))),function(e,t){return i.apply(this,arguments)})},{key:"sendSubmission",value:(a=v(regeneratorRuntime.mark((function e(t){var r,n;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,l("/submitForm",{method:"POST",body:t});case 2:return(r=e.sent).ok,n=m(m({},r),{},{kind:h.a.SubmitForm}),e.abrupt("return",n);case 6:case"end":return e.stop()}}),e)}))),function(e){return a.apply(this,arguments)})}])&&g(t.prototype,r),n&&g(t,n),e}())},function(e,t,r){"use strict";function n(e){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];return"number"==typeof e?e:t?parseFloat(e):parseInt(e,10)}function a(e){return!!(e&&e.length>0&&e.match(/^[0-9]*$/))}r.d(t,"a",(function(){return n})),r.d(t,"b",(function(){return a}))},function(e,t,r){"use strict";r.d(t,"a",(function(){return s}));var n=r(2);function a(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function o(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}var i=new(function(){function e(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"wplf";a(this,e),this.prefix=t}var t,r,i;return t=e,(r=[{key:"get",value:function(e,t){var r=localStorage.getItem(this.prefix+e);return null!==r?r?JSON.parse(r):r:(n.a.notice("No value found for ".concat(e,", falling back to default"),t),t)}},{key:"set",value:function(e,t){try{return localStorage.setItem(this.prefix+e,JSON.stringify(t)),!0}catch(r){return n.a.error(r,e,t),!1}}}])&&o(t.prototype,r),i&&o(t,i),e}()),u=r(3);function c(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}var s=function(){function e(t){var r=this;if(function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.remember=!1,this.name="",this.handleClick=function(e){var t=e.target;if(Object(u.a)(t)){var a=t.getAttribute("data-target");a?r.switchTab(a):n.a.notice("Unable to switch tab as data-target was empty")}e.preventDefault()},t instanceof Element!=!0)throw new Error("Tab element invalid or missing");if(this.root=t,this.name=this.root.getAttribute("data-name")||"",this.remember=null!==this.root.getAttribute("data-remember"),this.activeTab=this.root.getAttribute("data-default")||"",!this.name||!this.activeTab)throw new Error("Required attributes are missing");this.remember&&(this.activeTab=i.get(this.name,this.activeTab)),this.refresh()}var t,r,a;return t=e,(r=[{key:"refresh",value:function(){var e=this;this.getHandles().forEach((function(t){t.addEventListener("click",e.handleClick,{passive:!1})})),this.switchTab(this.activeTab)}},{key:"getTabs",value:function(){return Array.from(this.root.querySelectorAll('.wplf-tabs__tab[data-name="'.concat(this.name,'"]')))}},{key:"getHandles",value:function(){return Array.from(this.root.querySelectorAll('.wplf-tabs__tabSwitcher[data-name="'.concat(this.name,'"]')))}},{key:"switchTab",value:function(e){var t=this.getTabs(),r=this.getHandles(),n=t.filter((function(t){return t.getAttribute("data-tab")===e})),a=t.filter((function(t){return t.getAttribute("data-tab")!==e}));n.forEach((function(e){var t=e.getAttribute("data-tab"),n=r.filter((function(e){return e.getAttribute("data-target")===t}));e.classList.add("active"),n.forEach((function(e){e.classList.add("active")}))})),a.forEach((function(e){var t=e.getAttribute("data-tab"),n=r.filter((function(e){return e.getAttribute("data-target")===t}));e.classList.remove("active"),n.forEach((function(e){e.classList.remove("active")}))})),this.remember&&i.set(this.name,e)}}])&&c(t.prototype,r),a&&c(t,a),e}()},function(e,t,r){"use strict";r.d(t,"a",(function(){return p}));var n=r(1),a=r(2),o=r(7),i=r(4),u=r(3),c=r(6),s=r(5);function f(e,t,r,n,a,o,i){try{var u=e[o](i),c=u.value}catch(e){return void r(e)}u.done?t(c):Promise.resolve(c).then(n,a)}function l(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}var h=function(e,t){var r=e.form;r.reset&&r.reset()},d=function(e,t){Object(u.a)(e.form.parentNode)&&e.form.parentNode.querySelectorAll(".wplf-errorMessage, .wplf-successMessage").forEach((function(e){Object(u.a)(e.parentNode)&&e.parentNode.removeChild(e)}))},m=function(e,t){console.log(t);var r=t.data.data.message,n=void 0===r?"":r,a=document.createElement("div");a.classList.add("wplf-successMessage"),a.insertAdjacentHTML("afterbegin",n.replace(/\n/g,"<br />")),e.form.insertAdjacentElement("beforebegin",a),e.form.classList.add("submitted")},b=function(e,t){var r=t.error,n=document.createElement("div");n.classList.add("wplf-errorMessage"),n.insertAdjacentHTML("afterbegin",r.message),e.form.insertAdjacentElement("beforebegin",n)},p=function(){function e(t){if(function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.submitState=i.b.Unsubmitted,this.submitHandler=null,this.callbacks={beforeSend:{default:d},success:{default:m,clearOnSuccess:h},error:{default:b}},this.tabs=[],this.key="",t instanceof HTMLElement!=!0)throw new Error("Form element invalid or missing");this.form=t,this.id=Object(c.a)(t.dataset.formId||0),this.slug=t.dataset.formSlug||"",this.key="_"+Math.random().toString(36).substr(2,9),this.tabs=Array.from(this.form.querySelectorAll(".wplf-tabs")).map((function(e){return new o.a(e)})),this.createSubmitHandler(),this.attachSubmitHandler();var r=t.querySelector('[name="_nojs"]');r&&Object(u.a)(r.parentNode)&&r.parentNode.removeChild(r)}var t,r,p;return t=e,(r=[{key:"getDefaultCallbacks",value:function(){return{beforeSend:{default:d},success:{default:m,clearOnSuccess:h},error:{default:b}}}},{key:"addCallback",value:function(e,t,r){var n=this.callbacks,a=n.beforeSend,o=n.success,i=n.error;switch(t){case"beforeSend":a[e]=r;break;case"success":o[e]=r;break;case"error":i[e]=r;break;default:throw new Error("Unknown callback type ".concat(t))}return this}},{key:"removeCallback",value:function(e,t){var r=this.callbacks,n=r.beforeSend,a=r.success,o=r.error;switch(t){case"beforeSend":delete n[e];break;case"success":delete a[e];break;case"error":delete o[e];break;default:throw new Error("Unknown callback ".concat(e," ").concat(t))}return this}},{key:"runCallback",value:function(e){var t=this,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=this.callbacks,a=n.beforeSend,o=n.success,i=n.error;switch(e){case"beforeSend":Object.values(a).forEach((function(e){e(t,r)}));break;case"success":Object.values(o).forEach((function(e){e(t,r)}));break;case"error":Object.values(i).forEach((function(e){e(t,r)}));break;default:throw new Error("Unknown callback ".concat(name," ").concat(e))}}},{key:"attachSubmitHandler",value:function(){return this.submitHandler?(a.a.notice("Attaching form submit handler"),this.form.addEventListener("submit",this.submitHandler,{passive:!1})):a.a.error("Unable to attach submit handler, as it does not exist"),this}},{key:"removeSubmitHandler",value:function(){return this.submitHandler?(a.a.notice("Removing form submit handler"),this.form.removeEventListener("submit",this.submitHandler)):a.a.error("Unable to remove submit handler, as it does not exist"),this}},{key:"createSubmitHandler",value:function(e){var t=this;return e?(this.submitHandler=e,this):(this.submitHandler=function(){var e,r=(e=regeneratorRuntime.mark((function e(r){var o,u,c,f,l;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(r.preventDefault(),t.submitState!==i.b.Submitting){e.next=4;break}return a.a.notice("Preventing double doubmission"),e.abrupt("return");case 4:return e.prev=4,o=t.form,u=new FormData(o),n.a.lang&&u.append("lang",n.a.lang),t.submitState=i.b.Submitting,o.classList.add("submitting"),t.runCallback("beforeSend",{formData:u,form:o}),e.next=13,s.a.sendSubmission(u);case 13:if(c=e.sent,f=c.data,l=c.ok,o.classList.remove("submitting"),!("error"in f)){e.next=21;break}throw a.a.error("Invalid submission!",c),new Error(f.error);case 21:if(l){e.next=25;break}throw new Error(n.a.i18n.formSubmissionRequestFailed);case 25:t.submitState=i.b.Success,t.runCallback("success",{data:f});case 27:e.next=33;break;case 29:e.prev=29,e.t0=e.catch(4),t.submitState=i.b.Error,t.runCallback("error",{error:e.t0});case 33:case"end":return e.stop()}}),e,null,[[4,29]])})),function(){var t=this,r=arguments;return new Promise((function(n,a){var o=e.apply(t,r);function i(e){f(o,n,a,i,u,"next",e)}function u(e){f(o,n,a,i,u,"throw",e)}i(void 0)}))});return function(e){return r.apply(this,arguments)}}(),this)}}])&&l(t.prototype,r),p&&l(t,p),e}()},function(e,t,r){"use strict";const{AbortController:n,AbortSignal:a}="undefined"!=typeof self?self:"undefined"!=typeof window?window:void 0;e.exports=n,e.exports.AbortSignal=a,e.exports.default=n},function(e,t,r){"use strict";r.d(t,"a",(function(){return i}));var n=r(8),a=r(1);function o(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}var i=function(){function e(){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.forms={},a.a.settings.autoinit&&this.initialize()}var t,r,i;return t=e,(r=[{key:"initialize",value:function(){var e=this;Array.from(document.querySelectorAll(".wplf-form")).map((function(t){e.attach(t)}))}},{key:"findFormsById",value:function(e){var t=this;return Object.keys(this.forms).reduce((function(r,n){var a=t.forms[n];return a?(e===a.id&&r.push(a),r):r}),[])}},{key:"findFormsBySlug",value:function(e){var t=this;return Object.keys(this.forms).reduce((function(r,n){var a=t.forms[n];return a&&a?(e===a.slug&&r.push(a),r):r}),[])}},{key:"attach",value:function(e){if(e instanceof n.a){var t=e;return this.forms[t.key]=t,t}var r=e;if(r instanceof Element!=1)throw new Error(a.a.i18n.unableToAttachWPLF);var o=new n.a(r);return this.forms[o.key]=o,o.form.removeAttribute("tabindex"),o.form.removeAttribute("style"),o}},{key:"detach",value:function(e){return this.forms[e.key].removeSubmitHandler(),delete this.forms[e.key],!0}}])&&o(t.prototype,r),i&&o(t,i),e}()},function(e,t,r){var n=function(e){"use strict";var t,r=Object.prototype,n=r.hasOwnProperty,a="function"==typeof Symbol?Symbol:{},o=a.iterator||"@@iterator",i=a.asyncIterator||"@@asyncIterator",u=a.toStringTag||"@@toStringTag";function c(e,t,r){return Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}),e[t]}try{c({},"")}catch(e){c=function(e,t,r){return e[t]=r}}function s(e,t,r,n){var a=t&&t.prototype instanceof p?t:p,o=Object.create(a.prototype),i=new P(n||[]);return o._invoke=function(e,t,r){var n=l;return function(a,o){if(n===d)throw new Error("Generator is already running");if(n===m){if("throw"===a)throw o;return T()}for(r.method=a,r.arg=o;;){var i=r.delegate;if(i){var u=E(i,r);if(u){if(u===b)continue;return u}}if("next"===r.method)r.sent=r._sent=r.arg;else if("throw"===r.method){if(n===l)throw n=m,r.arg;r.dispatchException(r.arg)}else"return"===r.method&&r.abrupt("return",r.arg);n=d;var c=f(e,t,r);if("normal"===c.type){if(n=r.done?m:h,c.arg===b)continue;return{value:c.arg,done:r.done}}"throw"===c.type&&(n=m,r.method="throw",r.arg=c.arg)}}}(e,r,i),o}function f(e,t,r){try{return{type:"normal",arg:e.call(t,r)}}catch(e){return{type:"throw",arg:e}}}e.wrap=s;var l="suspendedStart",h="suspendedYield",d="executing",m="completed",b={};function p(){}function v(){}function g(){}var y={};y[o]=function(){return this};var w=Object.getPrototypeOf,k=w&&w(w(F([])));k&&k!==r&&n.call(k,o)&&(y=k);var S=g.prototype=p.prototype=Object.create(y);function O(e){["next","throw","return"].forEach((function(t){c(e,t,(function(e){return this._invoke(t,e)}))}))}function x(e,t){function r(a,o,i,u){var c=f(e[a],e,o);if("throw"!==c.type){var s=c.arg,l=s.value;return l&&"object"==typeof l&&n.call(l,"__await")?t.resolve(l.__await).then((function(e){r("next",e,i,u)}),(function(e){r("throw",e,i,u)})):t.resolve(l).then((function(e){s.value=e,i(s)}),(function(e){return r("throw",e,i,u)}))}u(c.arg)}var a;this._invoke=function(e,n){function o(){return new t((function(t,a){r(e,n,t,a)}))}return a=a?a.then(o,o):o()}}function E(e,r){var n=e.iterator[r.method];if(n===t){if(r.delegate=null,"throw"===r.method){if(e.iterator.return&&(r.method="return",r.arg=t,E(e,r),"throw"===r.method))return b;r.method="throw",r.arg=new TypeError("The iterator does not provide a 'throw' method")}return b}var a=f(n,e.iterator,r.arg);if("throw"===a.type)return r.method="throw",r.arg=a.arg,r.delegate=null,b;var o=a.arg;return o?o.done?(r[e.resultName]=o.value,r.next=e.nextLoc,"return"!==r.method&&(r.method="next",r.arg=t),r.delegate=null,b):o:(r.method="throw",r.arg=new TypeError("iterator result is not an object"),r.delegate=null,b)}function j(e){var t={tryLoc:e[0]};1 in e&&(t.catchLoc=e[1]),2 in e&&(t.finallyLoc=e[2],t.afterLoc=e[3]),this.tryEntries.push(t)}function L(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function P(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(j,this),this.reset(!0)}function F(e){if(e){var r=e[o];if(r)return r.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length)){var a=-1,i=function r(){for(;++a<e.length;)if(n.call(e,a))return r.value=e[a],r.done=!1,r;return r.value=t,r.done=!0,r};return i.next=i}}return{next:T}}function T(){return{value:t,done:!0}}return v.prototype=S.constructor=g,g.constructor=v,v.displayName=c(g,u,"GeneratorFunction"),e.isGeneratorFunction=function(e){var t="function"==typeof e&&e.constructor;return!!t&&(t===v||"GeneratorFunction"===(t.displayName||t.name))},e.mark=function(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,g):(e.__proto__=g,c(e,u,"GeneratorFunction")),e.prototype=Object.create(S),e},e.awrap=function(e){return{__await:e}},O(x.prototype),x.prototype[i]=function(){return this},e.AsyncIterator=x,e.async=function(t,r,n,a,o){void 0===o&&(o=Promise);var i=new x(s(t,r,n,a),o);return e.isGeneratorFunction(r)?i:i.next().then((function(e){return e.done?e.value:i.next()}))},O(S),c(S,u,"Generator"),S[o]=function(){return this},S.toString=function(){return"[object Generator]"},e.keys=function(e){var t=[];for(var r in e)t.push(r);return t.reverse(),function r(){for(;t.length;){var n=t.pop();if(n in e)return r.value=n,r.done=!1,r}return r.done=!0,r}},e.values=F,P.prototype={constructor:P,reset:function(e){if(this.prev=0,this.next=0,this.sent=this._sent=t,this.done=!1,this.delegate=null,this.method="next",this.arg=t,this.tryEntries.forEach(L),!e)for(var r in this)"t"===r.charAt(0)&&n.call(this,r)&&!isNaN(+r.slice(1))&&(this[r]=t)},stop:function(){this.done=!0;var e=this.tryEntries[0].completion;if("throw"===e.type)throw e.arg;return this.rval},dispatchException:function(e){if(this.done)throw e;var r=this;function a(n,a){return u.type="throw",u.arg=e,r.next=n,a&&(r.method="next",r.arg=t),!!a}for(var o=this.tryEntries.length-1;o>=0;--o){var i=this.tryEntries[o],u=i.completion;if("root"===i.tryLoc)return a("end");if(i.tryLoc<=this.prev){var c=n.call(i,"catchLoc"),s=n.call(i,"finallyLoc");if(c&&s){if(this.prev<i.catchLoc)return a(i.catchLoc,!0);if(this.prev<i.finallyLoc)return a(i.finallyLoc)}else if(c){if(this.prev<i.catchLoc)return a(i.catchLoc,!0)}else{if(!s)throw new Error("try statement without catch or finally");if(this.prev<i.finallyLoc)return a(i.finallyLoc)}}}},abrupt:function(e,t){for(var r=this.tryEntries.length-1;r>=0;--r){var a=this.tryEntries[r];if(a.tryLoc<=this.prev&&n.call(a,"finallyLoc")&&this.prev<a.finallyLoc){var o=a;break}}o&&("break"===e||"continue"===e)&&o.tryLoc<=t&&t<=o.finallyLoc&&(o=null);var i=o?o.completion:{};return i.type=e,i.arg=t,o?(this.method="next",this.next=o.finallyLoc,b):this.complete(i)},complete:function(e,t){if("throw"===e.type)throw e.arg;return"break"===e.type||"continue"===e.type?this.next=e.arg:"return"===e.type?(this.rval=this.arg=e.arg,this.method="return",this.next="end"):"normal"===e.type&&t&&(this.next=t),b},finish:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var r=this.tryEntries[t];if(r.finallyLoc===e)return this.complete(r.completion,r.afterLoc),L(r),b}},catch:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var r=this.tryEntries[t];if(r.tryLoc===e){var n=r.completion;if("throw"===n.type){var a=n.arg;L(r)}return a}}throw new Error("illegal catch attempt")},delegateYield:function(e,r,n){return this.delegate={iterator:F(e),resultName:r,nextLoc:n},"next"===this.method&&(this.arg=t),b}},e}(e.exports);try{regeneratorRuntime=n}catch(e){Function("r","regeneratorRuntime = r")(n)}},,,,,,,,,,,,,,,,,,,,,function(e,t,r){r(11),e.exports=r(33)},function(e,t,r){"use strict";r.r(t);var n=r(10),a=r(7),o=r(8),i=r(5);r(34);t.default={api:i.a,manager:new n.a,WPLF_Tabs:a.a,WPLF_Form:o.a}},function(e,t,r){}]).default}));
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.WPLF=t():e.WPLF=t()}(this,(function(){return function(e){var t={};function r(n){if(t[n])return t[n].exports;var a=t[n]={i:n,l:!1,exports:{}};return e[n].call(a.exports,a,a.exports,r),a.l=!0,a.exports}return r.m=e,r.c=t,r.d=function(e,t,n){r.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:n})},r.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},r.t=function(e,t){if(1&t&&(e=r(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var n=Object.create(null);if(r.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var a in e)r.d(n,a,function(t){return e[t]}.bind(null,a));return n},r.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return r.d(t,"a",t),t},r.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},r.p="",r(r.s=32)}([,function(e,t,r){"use strict";t.a=function(e){return Object.assign({backendUrl:null,fetchCredentials:"same-origin",requestHeaders:{"X-WP-Nonce":null},assetsDir:null,settings:{autoinit:!0,parseLibreformShortcodeInRestApi:!0,hasUnfilteredHtml:!0,debugLevel:"all"},post:null,i18n:{}},e.wplfData)}(window)},function(e,t,r){"use strict";var n=r(1).a.settings.debugLevel,a=window.console||{log(){},error(){}};t.a={notice:function(e){for(var t=arguments.length,r=new Array(t>1?t-1:0),o=1;o<t;o++)r[o-1]=arguments[o];return"all"===n&&a.log("WPLF: ".concat(e),r)},error:function(e){for(var t=arguments.length,r=new Array(t>1?t-1:0),o=1;o<t;o++)r[o-1]=arguments[o];return"none"!==n&&a.error("WPLF error: ".concat(e),r)}}},function(e,t,r){"use strict";t.a=function(e){return!!e&&("getAttribute"in e&&"tagName"in e)}},function(e,t,r){"use strict";var n,a;r.d(t,"b",(function(){return n})),r.d(t,"a",(function(){return a})),function(e){e[e.Unsubmitted=0]="Unsubmitted",e[e.Submitting=1]="Submitting",e[e.Success=2]="Success",e[e.Error=3]="Error"}(n||(n={})),function(e){e.GetForm="getForm",e.GetForms="getForms",e.GetSubmissions="getSubmissions",e.GetSubmission="getSubmission",e.DeleteSubmissions="deleteSubmissions",e.RenderForm="renderForm",e.SubmitForm="submitForm",e.ApiError="apiError"}(a||(a={}))},function(e,t,r){"use strict";r.d(t,"a",(function(){return y}));var n=r(9),a=r.n(n),o=r(1);function i(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function u(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?i(Object(r),!0).forEach((function(t){c(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):i(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}function c(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function s(e,t,r,n,a,o,i){try{var u=e[o](i),c=u.value}catch(e){return void r(e)}u.done?t(c):Promise.resolve(c).then(n,a)}function f(e){return function(){var t=this,r=arguments;return new Promise((function(n,a){var o=e.apply(t,r);function i(e){s(o,n,a,i,u,"next",e)}function u(e){s(o,n,a,i,u,"throw",e)}i(void 0)}))}}function l(e){var t,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=function(){t&&t.abort&&t.abort()},i=f(regeneratorRuntime.mark((function n(){var i,c,s,f,l,h,d;return regeneratorRuntime.wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return n.prev=0,t=new a.a,n.next=4,fetch(o.a.backendUrl+e,u({method:"GET",signal:t.signal,credentials:o.a.fetchCredentials||"same-origin",headers:o.a.requestHeaders||{}},r));case 4:return i=n.sent,c=i.headers,s=i.status,f=i.statusText,l=i.url,h=i.ok,n.next=8,i.json();case 8:return d=n.sent,t=null,n.abrupt("return",{headers:c,status:s,statusText:f,url:l,ok:h,data:d});case 13:if(n.prev=13,n.t0=n.catch(0),t=null,"AbortError"===n.t0.name){n.next=18;break}throw n.t0;case 18:return n.abrupt("return",n.t0);case 19:case"end":return n.stop()}}),n,null,[[0,13]])})))();return Object.assign(i,{abort:n})}var h=r(4);function d(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function m(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?d(Object(r),!0).forEach((function(t){b(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):d(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}function b(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function p(e,t,r,n,a,o,i){try{var u=e[o](i),c=u.value}catch(e){return void r(e)}u.done?t(c):Promise.resolve(c).then(n,a)}function v(e){return function(){var t=this,r=arguments;return new Promise((function(n,a){var o=e.apply(t,r);function i(e){p(o,n,a,i,u,"next",e)}function u(e){p(o,n,a,i,u,"throw",e)}i(void 0)}))}}function g(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}var y=new(function(){function e(){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e)}var t,r,n,a,i,u,c,s,f,d;return t=e,(r=[{key:"requestRender",value:(d=v(regeneratorRuntime.mark((function e(t,r){var n,a,i;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return(n=new FormData).append("content",r),n.append("form",t.toString()),o.a.lang&&n.append("lang",o.a.lang),e.next=6,l("/renderForm",{method:"POST",body:n});case 6:return(a=e.sent).ok,i=m(m({},a),{},{kind:h.a.RenderForm}),e.abrupt("return",i);case 10:case"end":return e.stop()}}),e)}))),function(e,t){return d.apply(this,arguments)})},{key:"requestForm",value:(f=v(regeneratorRuntime.mark((function e(t){var r,n,a,i;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return r="",o.a.lang&&(r="&lang=".concat(o.a.lang)),n="/getForm?form=".concat(t).concat(r),e.next=5,l(n,{method:"GET"});case 5:return(a=e.sent).ok,i=m(m({},a),{},{kind:h.a.GetForm}),e.abrupt("return",i);case 9:case"end":return e.stop()}}),e)}))),function(e){return f.apply(this,arguments)})},{key:"requestForms",value:(s=v(regeneratorRuntime.mark((function e(t){var r,n,a,i;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return r="",o.a.lang&&(r="&lang=".concat(o.a.lang)),n="/getForms?page=".concat(t).concat(r),e.next=5,l(n,{method:"GET"});case 5:return(a=e.sent).ok,i=m(m({},a),{},{kind:h.a.GetForms}),e.abrupt("return",i);case 9:case"end":return e.stop()}}),e)}))),function(e){return s.apply(this,arguments)})},{key:"deleteSubmissions",value:(c=v(regeneratorRuntime.mark((function e(t,r){var n,a;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,l("/deleteSubmissions",{method:"DELETE",headers:m(m({},o.a.requestHeaders),{},{"Content-Type":"application/json"}),body:JSON.stringify({form:t,submissionUuids:r})});case 2:return(n=e.sent).ok,a=m(m({},n),{},{kind:h.a.DeleteSubmissions}),e.abrupt("return",a);case 6:case"end":return e.stop()}}),e)}))),function(e,t){return c.apply(this,arguments)})},{key:"requestSubmissions",value:(u=v(regeneratorRuntime.mark((function e(t,r,n){var a,o;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,l("/getSubmissions?form=".concat(t,"&page=").concat(r,"&limit=").concat(n),{method:"GET"});case 2:return(a=e.sent).ok,o=m(m({},a),{},{kind:h.a.GetSubmissions}),e.abrupt("return",o);case 6:case"end":return e.stop()}}),e)}))),function(e,t,r){return u.apply(this,arguments)})},{key:"requestSubmission",value:(i=v(regeneratorRuntime.mark((function e(t,r){var n,a;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,l("/getSubmission?form=".concat(t,"&uuid=").concat(r),{method:"GET"});case 2:return(n=e.sent).ok,a=m(m({},n),{},{kind:h.a.GetSubmission}),e.abrupt("return",a);case 6:case"end":return e.stop()}}),e)}))),function(e,t){return i.apply(this,arguments)})},{key:"sendSubmission",value:(a=v(regeneratorRuntime.mark((function e(t){var r,n;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,l("/submitForm",{method:"POST",body:t});case 2:return(r=e.sent).ok,n=m(m({},r),{},{kind:h.a.SubmitForm}),e.abrupt("return",n);case 6:case"end":return e.stop()}}),e)}))),function(e){return a.apply(this,arguments)})}])&&g(t.prototype,r),n&&g(t,n),e}())},function(e,t,r){"use strict";function n(e){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];return"number"==typeof e?e:t?parseFloat(e):parseInt(e,10)}function a(e){return!!(e&&e.length>0&&e.match(/^[0-9]*$/))}r.d(t,"a",(function(){return n})),r.d(t,"b",(function(){return a}))},function(e,t,r){"use strict";r.d(t,"a",(function(){return s}));var n=r(2);function a(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function o(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}var i=new(function(){function e(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"wplf";a(this,e),this.prefix=t}var t,r,i;return t=e,(r=[{key:"get",value:function(e,t){var r=localStorage.getItem(this.prefix+e);return null!==r?r?JSON.parse(r):r:(n.a.notice("No value found for ".concat(e,", falling back to default"),t),t)}},{key:"set",value:function(e,t){try{return localStorage.setItem(this.prefix+e,JSON.stringify(t)),!0}catch(r){return n.a.error(r,e,t),!1}}}])&&o(t.prototype,r),i&&o(t,i),e}()),u=r(3);function c(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}var s=function(){function e(t){var r=this;if(function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.remember=!1,this.name="",this.handleClick=function(e){var t=e.target;if(Object(u.a)(t)){var a=t.getAttribute("data-target");a?r.switchTab(a):n.a.notice("Unable to switch tab as data-target was empty")}e.preventDefault()},t instanceof Element!=!0)throw new Error("Tab element invalid or missing");if(this.root=t,this.name=this.root.getAttribute("data-name")||"",this.remember=null!==this.root.getAttribute("data-remember"),this.activeTab=this.root.getAttribute("data-default")||"",!this.name||!this.activeTab)throw new Error("Required attributes are missing");this.remember&&(this.activeTab=i.get(this.name,this.activeTab)),this.refresh()}var t,r,a;return t=e,(r=[{key:"refresh",value:function(){var e=this;this.getHandles().forEach((function(t){t.addEventListener("click",e.handleClick,{passive:!1})})),this.switchTab(this.activeTab)}},{key:"getTabs",value:function(){return Array.from(this.root.querySelectorAll('.wplf-tabs__tab[data-name="'.concat(this.name,'"]')))}},{key:"getHandles",value:function(){return Array.from(this.root.querySelectorAll('.wplf-tabs__tabSwitcher[data-name="'.concat(this.name,'"]')))}},{key:"switchTab",value:function(e){var t=this.getTabs(),r=this.getHandles(),n=t.filter((function(t){return t.getAttribute("data-tab")===e})),a=t.filter((function(t){return t.getAttribute("data-tab")!==e}));n.forEach((function(e){var t=e.getAttribute("data-tab"),n=r.filter((function(e){return e.getAttribute("data-target")===t}));e.classList.add("active"),n.forEach((function(e){e.classList.add("active")}))})),a.forEach((function(e){var t=e.getAttribute("data-tab"),n=r.filter((function(e){return e.getAttribute("data-target")===t}));e.classList.remove("active"),n.forEach((function(e){e.classList.remove("active")}))})),this.remember&&i.set(this.name,e)}}])&&c(t.prototype,r),a&&c(t,a),e}()},function(e,t,r){"use strict";r.d(t,"a",(function(){return v}));var n=r(1),a=r(2),o=r(7),i=r(4),u=r(3),c=r(6),s=r(5);function f(e,t,r,n,a,o,i){try{var u=e[o](i),c=u.value}catch(e){return void r(e)}u.done?t(c):Promise.resolve(c).then(n,a)}function l(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}var h=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:1;return new Promise((function(t){return setTimeout(t,e)}))},d=function(e,t){var r=e.form;r.reset&&r.reset()},m=function(e,t){Object(u.a)(e.form.parentNode)&&e.form.parentNode.querySelectorAll(".wplf-errorMessage, .wplf-successMessage").forEach((function(e){Object(u.a)(e.parentNode)&&e.parentNode.removeChild(e)}))},b=function(e,t){console.log(t);var r=t.data.data.message,n=void 0===r?"":r,a=document.createElement("div");a.classList.add("wplf-successMessage"),a.insertAdjacentHTML("afterbegin",n.replace(/\n/g,"<br />")),e.form.insertAdjacentElement("beforebegin",a),e.form.classList.add("submitted")},p=function(e,t){var r=t.error,n=document.createElement("div");n.classList.add("wplf-errorMessage"),n.insertAdjacentHTML("afterbegin",r.message),e.form.insertAdjacentElement("beforebegin",n)},v=function(){function e(t){if(function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.submitState=i.b.Unsubmitted,this.submitHandler=null,this.callbacks={beforeSend:{default:m},success:{default:b,clearOnSuccess:d},error:{default:p}},this.tabs=[],this.key="",t instanceof HTMLElement!=!0)throw new Error("Form element invalid or missing");this.form=t,this.id=Object(c.a)(t.dataset.formId||0),this.slug=t.dataset.formSlug||"",this.key="_"+Math.random().toString(36).substr(2,9),this.tabs=Array.from(this.form.querySelectorAll(".wplf-tabs")).map((function(e){return new o.a(e)})),this.createSubmitHandler(),this.attachSubmitHandler();var r=t.querySelector('[name="_nojs"]');r&&Object(u.a)(r.parentNode)&&r.parentNode.removeChild(r)}var t,r,v;return t=e,(r=[{key:"getDefaultCallbacks",value:function(){return{beforeSend:{default:m},success:{default:b,clearOnSuccess:d},error:{default:p}}}},{key:"addCallback",value:function(e,t,r){var n=this.callbacks,a=n.beforeSend,o=n.success,i=n.error;switch(t){case"beforeSend":a[e]=r;break;case"success":o[e]=r;break;case"error":i[e]=r;break;default:throw new Error("Unknown callback type ".concat(t))}return this}},{key:"removeCallback",value:function(e,t){var r=this.callbacks,n=r.beforeSend,a=r.success,o=r.error;switch(t){case"beforeSend":delete n[e];break;case"success":delete a[e];break;case"error":delete o[e];break;default:throw new Error("Unknown callback ".concat(e," ").concat(t))}return this}},{key:"runCallback",value:function(e){var t=this,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=this.callbacks,a=n.beforeSend,o=n.success,i=n.error;switch(e){case"beforeSend":Object.values(a).forEach((function(e){e(t,r)}));break;case"success":Object.values(o).forEach((function(e){e(t,r)}));break;case"error":Object.values(i).forEach((function(e){e(t,r)}));break;default:throw new Error("Unknown callback ".concat(name," ").concat(e))}}},{key:"attachSubmitHandler",value:function(){return this.submitHandler?(a.a.notice("Attaching form submit handler"),this.form.addEventListener("submit",this.submitHandler,{passive:!1})):a.a.error("Unable to attach submit handler, as it does not exist"),this}},{key:"removeSubmitHandler",value:function(){return this.submitHandler?(a.a.notice("Removing form submit handler"),this.form.removeEventListener("submit",this.submitHandler)):a.a.error("Unable to remove submit handler, as it does not exist"),this}},{key:"createSubmitHandler",value:function(e){var t=this;return e?(this.submitHandler=e,this):(this.submitHandler=function(){var e,r=(e=regeneratorRuntime.mark((function e(r){var o,u,c,f,l;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(r.preventDefault(),t.submitState!==i.b.Submitting){e.next=4;break}return a.a.notice("Preventing double doubmission"),e.abrupt("return");case 4:return e.prev=4,o=t.form,u=new FormData(o),n.a.lang&&u.append("lang",n.a.lang),t.submitState=i.b.Submitting,o.classList.add("submitting"),t.runCallback("beforeSend",{formData:u,form:o}),e.next=13,h();case 13:return u=new FormData(o),e.next=16,s.a.sendSubmission(u);case 16:if(c=e.sent,f=c.data,l=c.ok,o.classList.remove("submitting"),!("error"in f)){e.next=24;break}throw a.a.error("Invalid submission!",c),new Error(f.error);case 24:if(l){e.next=28;break}throw new Error(n.a.i18n.formSubmissionRequestFailed);case 28:t.submitState=i.b.Success,t.runCallback("success",{data:f});case 30:e.next=36;break;case 32:e.prev=32,e.t0=e.catch(4),t.submitState=i.b.Error,t.runCallback("error",{error:e.t0});case 36:case"end":return e.stop()}}),e,null,[[4,32]])})),function(){var t=this,r=arguments;return new Promise((function(n,a){var o=e.apply(t,r);function i(e){f(o,n,a,i,u,"next",e)}function u(e){f(o,n,a,i,u,"throw",e)}i(void 0)}))});return function(e){return r.apply(this,arguments)}}(),this)}}])&&l(t.prototype,r),v&&l(t,v),e}()},function(e,t,r){"use strict";const{AbortController:n,AbortSignal:a}="undefined"!=typeof self?self:"undefined"!=typeof window?window:void 0;e.exports=n,e.exports.AbortSignal=a,e.exports.default=n},function(e,t,r){"use strict";r.d(t,"a",(function(){return i}));var n=r(8),a=r(1);function o(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}var i=function(){function e(){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.forms={},a.a.settings.autoinit&&this.initialize()}var t,r,i;return t=e,(r=[{key:"initialize",value:function(){var e=this;Array.from(document.querySelectorAll(".wplf-form")).map((function(t){e.attach(t)}))}},{key:"findFormsById",value:function(e){var t=this;return Object.keys(this.forms).reduce((function(r,n){var a=t.forms[n];return a?(e===a.id&&r.push(a),r):r}),[])}},{key:"findFormsBySlug",value:function(e){var t=this;return Object.keys(this.forms).reduce((function(r,n){var a=t.forms[n];return a&&a?(e===a.slug&&r.push(a),r):r}),[])}},{key:"attach",value:function(e){if(e instanceof n.a){var t=e;return this.forms[t.key]=t,t}var r=e;if(r instanceof Element!=1)throw new Error(a.a.i18n.unableToAttachWPLF);var o=new n.a(r);return this.forms[o.key]=o,o.form.removeAttribute("tabindex"),o.form.removeAttribute("style"),o}},{key:"detach",value:function(e){return this.forms[e.key].removeSubmitHandler(),delete this.forms[e.key],!0}}])&&o(t.prototype,r),i&&o(t,i),e}()},function(e,t,r){var n=function(e){"use strict";var t,r=Object.prototype,n=r.hasOwnProperty,a="function"==typeof Symbol?Symbol:{},o=a.iterator||"@@iterator",i=a.asyncIterator||"@@asyncIterator",u=a.toStringTag||"@@toStringTag";function c(e,t,r){return Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}),e[t]}try{c({},"")}catch(e){c=function(e,t,r){return e[t]=r}}function s(e,t,r,n){var a=t&&t.prototype instanceof p?t:p,o=Object.create(a.prototype),i=new P(n||[]);return o._invoke=function(e,t,r){var n=l;return function(a,o){if(n===d)throw new Error("Generator is already running");if(n===m){if("throw"===a)throw o;return T()}for(r.method=a,r.arg=o;;){var i=r.delegate;if(i){var u=E(i,r);if(u){if(u===b)continue;return u}}if("next"===r.method)r.sent=r._sent=r.arg;else if("throw"===r.method){if(n===l)throw n=m,r.arg;r.dispatchException(r.arg)}else"return"===r.method&&r.abrupt("return",r.arg);n=d;var c=f(e,t,r);if("normal"===c.type){if(n=r.done?m:h,c.arg===b)continue;return{value:c.arg,done:r.done}}"throw"===c.type&&(n=m,r.method="throw",r.arg=c.arg)}}}(e,r,i),o}function f(e,t,r){try{return{type:"normal",arg:e.call(t,r)}}catch(e){return{type:"throw",arg:e}}}e.wrap=s;var l="suspendedStart",h="suspendedYield",d="executing",m="completed",b={};function p(){}function v(){}function g(){}var y={};y[o]=function(){return this};var w=Object.getPrototypeOf,k=w&&w(w(F([])));k&&k!==r&&n.call(k,o)&&(y=k);var S=g.prototype=p.prototype=Object.create(y);function O(e){["next","throw","return"].forEach((function(t){c(e,t,(function(e){return this._invoke(t,e)}))}))}function x(e,t){function r(a,o,i,u){var c=f(e[a],e,o);if("throw"!==c.type){var s=c.arg,l=s.value;return l&&"object"==typeof l&&n.call(l,"__await")?t.resolve(l.__await).then((function(e){r("next",e,i,u)}),(function(e){r("throw",e,i,u)})):t.resolve(l).then((function(e){s.value=e,i(s)}),(function(e){return r("throw",e,i,u)}))}u(c.arg)}var a;this._invoke=function(e,n){function o(){return new t((function(t,a){r(e,n,t,a)}))}return a=a?a.then(o,o):o()}}function E(e,r){var n=e.iterator[r.method];if(n===t){if(r.delegate=null,"throw"===r.method){if(e.iterator.return&&(r.method="return",r.arg=t,E(e,r),"throw"===r.method))return b;r.method="throw",r.arg=new TypeError("The iterator does not provide a 'throw' method")}return b}var a=f(n,e.iterator,r.arg);if("throw"===a.type)return r.method="throw",r.arg=a.arg,r.delegate=null,b;var o=a.arg;return o?o.done?(r[e.resultName]=o.value,r.next=e.nextLoc,"return"!==r.method&&(r.method="next",r.arg=t),r.delegate=null,b):o:(r.method="throw",r.arg=new TypeError("iterator result is not an object"),r.delegate=null,b)}function j(e){var t={tryLoc:e[0]};1 in e&&(t.catchLoc=e[1]),2 in e&&(t.finallyLoc=e[2],t.afterLoc=e[3]),this.tryEntries.push(t)}function L(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function P(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(j,this),this.reset(!0)}function F(e){if(e){var r=e[o];if(r)return r.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length)){var a=-1,i=function r(){for(;++a<e.length;)if(n.call(e,a))return r.value=e[a],r.done=!1,r;return r.value=t,r.done=!0,r};return i.next=i}}return{next:T}}function T(){return{value:t,done:!0}}return v.prototype=S.constructor=g,g.constructor=v,v.displayName=c(g,u,"GeneratorFunction"),e.isGeneratorFunction=function(e){var t="function"==typeof e&&e.constructor;return!!t&&(t===v||"GeneratorFunction"===(t.displayName||t.name))},e.mark=function(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,g):(e.__proto__=g,c(e,u,"GeneratorFunction")),e.prototype=Object.create(S),e},e.awrap=function(e){return{__await:e}},O(x.prototype),x.prototype[i]=function(){return this},e.AsyncIterator=x,e.async=function(t,r,n,a,o){void 0===o&&(o=Promise);var i=new x(s(t,r,n,a),o);return e.isGeneratorFunction(r)?i:i.next().then((function(e){return e.done?e.value:i.next()}))},O(S),c(S,u,"Generator"),S[o]=function(){return this},S.toString=function(){return"[object Generator]"},e.keys=function(e){var t=[];for(var r in e)t.push(r);return t.reverse(),function r(){for(;t.length;){var n=t.pop();if(n in e)return r.value=n,r.done=!1,r}return r.done=!0,r}},e.values=F,P.prototype={constructor:P,reset:function(e){if(this.prev=0,this.next=0,this.sent=this._sent=t,this.done=!1,this.delegate=null,this.method="next",this.arg=t,this.tryEntries.forEach(L),!e)for(var r in this)"t"===r.charAt(0)&&n.call(this,r)&&!isNaN(+r.slice(1))&&(this[r]=t)},stop:function(){this.done=!0;var e=this.tryEntries[0].completion;if("throw"===e.type)throw e.arg;return this.rval},dispatchException:function(e){if(this.done)throw e;var r=this;function a(n,a){return u.type="throw",u.arg=e,r.next=n,a&&(r.method="next",r.arg=t),!!a}for(var o=this.tryEntries.length-1;o>=0;--o){var i=this.tryEntries[o],u=i.completion;if("root"===i.tryLoc)return a("end");if(i.tryLoc<=this.prev){var c=n.call(i,"catchLoc"),s=n.call(i,"finallyLoc");if(c&&s){if(this.prev<i.catchLoc)return a(i.catchLoc,!0);if(this.prev<i.finallyLoc)return a(i.finallyLoc)}else if(c){if(this.prev<i.catchLoc)return a(i.catchLoc,!0)}else{if(!s)throw new Error("try statement without catch or finally");if(this.prev<i.finallyLoc)return a(i.finallyLoc)}}}},abrupt:function(e,t){for(var r=this.tryEntries.length-1;r>=0;--r){var a=this.tryEntries[r];if(a.tryLoc<=this.prev&&n.call(a,"finallyLoc")&&this.prev<a.finallyLoc){var o=a;break}}o&&("break"===e||"continue"===e)&&o.tryLoc<=t&&t<=o.finallyLoc&&(o=null);var i=o?o.completion:{};return i.type=e,i.arg=t,o?(this.method="next",this.next=o.finallyLoc,b):this.complete(i)},complete:function(e,t){if("throw"===e.type)throw e.arg;return"break"===e.type||"continue"===e.type?this.next=e.arg:"return"===e.type?(this.rval=this.arg=e.arg,this.method="return",this.next="end"):"normal"===e.type&&t&&(this.next=t),b},finish:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var r=this.tryEntries[t];if(r.finallyLoc===e)return this.complete(r.completion,r.afterLoc),L(r),b}},catch:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var r=this.tryEntries[t];if(r.tryLoc===e){var n=r.completion;if("throw"===n.type){var a=n.arg;L(r)}return a}}throw new Error("illegal catch attempt")},delegateYield:function(e,r,n){return this.delegate={iterator:F(e),resultName:r,nextLoc:n},"next"===this.method&&(this.arg=t),b}},e}(e.exports);try{regeneratorRuntime=n}catch(e){Function("r","regeneratorRuntime = r")(n)}},,,,,,,,,,,,,,,,,,,,,function(e,t,r){r(11),e.exports=r(33)},function(e,t,r){"use strict";r.r(t);var n=r(10),a=r(7),o=r(8),i=r(5);r(34);t.default={api:i.a,manager:new n.a,WPLF_Tabs:a.a,WPLF_Form:o.a}},function(e,t,r){}]).default}));

@@ -10,5 +10,5 @@ # PHP API

```php
$form = new Form(get_post(123); // does not work
$form = new Form(get_post(123)); // does not work
$form = new \WPLF\Form(get_post(123); // does work
$form = new \WPLF\Form(get_post(123)); // does work
```

@@ -15,0 +15,0 @@

{
"name": "@libreform/libreform",
"version": "2.0.0",
"version": "2.0.3",
"description": "WP Libre Form client",

@@ -5,0 +5,0 @@ "main": "dist/wplf-frontend",

# WP Libre Form
[![Build Status](https://travis-ci.org/libreform/libreform.svg?branch=master)]([travis]) [![npm][npm-badge]][npm] [![Latest Stable Version](https://poser.pugx.org/libreform/libreform/v/stable)](https://packagist.org/packages/libreform/libreform) [![Latest Unstable Version](https://poser.pugx.org/libreform/libreform/v/unstable)](https://packagist.org/packages/libreform/libreform) [![License](https://poser.pugx.org/libreform/libreform/license)](https://packagist.org/packages/libreform/libreform)
[![Build Status](https://travis-ci.org/libreform/libreform.svg?branch=master)](https://travis-ci.org/libreform/libreform) [![npm][npm-badge]][npm] [![Latest Stable Version](https://poser.pugx.org/libreform/libreform/v/stable)](https://packagist.org/packages/libreform/libreform) [![Latest Unstable Version](https://poser.pugx.org/libreform/libreform/v/unstable)](https://packagist.org/packages/libreform/libreform) [![License](https://poser.pugx.org/libreform/libreform/license)](https://packagist.org/packages/libreform/libreform)

@@ -37,2 +37,3 @@ [npm-badge]: https://img.shields.io/npm/v/@libreform/libreform.png?style=flat-square

- PHP 7.3 or newer
- **MariaDB**, MySQL mostly works but [as it turns out](https://github.com/libreform/libreform/issues/22) I managed to code a vendorlokki.

@@ -110,2 +111,2 @@ ## Further reading

So, if you don't want to use Composer to manage the plugin, download the latest release from GitHub. There are plans to integrate an update mechanism to the plugin, but no timeline for that has been established yet. Contributions are welcome.
So, if you don't want to use Composer to manage the plugin, [download the latest release from GitHub](https://github.com/libreform/libreform/releases). There are plans to integrate an update mechanism to the plugin, but no timeline for that has been established yet. Contributions are welcome.
=== Libre Form ===
Contributors: k1sul1, Zuige, sippis
Tags: Libreform, Contact, Form, Lead, Collector, HTML, Upload
Donate link: https://github.com/libreform
Requires at least: 5.0
Tested up to: 5.5.1
Stable tag: 2.0.0
License: GPLv2
License URI: http://www.gnu.org/licenses/gpl-2.0.html
== Description ==
Use standard HTML5 markup to create fully functional forms for WordPress.
This version replaces the old WP Libre Form.
For an up-to-date and more detailed description, see [https://github.com/libreform/libreform/blob/master/README.md](hhttps://github.com/libreform/libreform/blob/master/README.md).
**Contributing**
Please contribute to this project on Github. Pull requests welcome!
[https://github.com/libreform/libreform](https://github.com/libreform/libreform)
== Installation ==
1. Upload plugin to the `/wp-content/plugins/` directory.
2. Activate the plugin through the "Plugins" menu in WordPress.
3. Installation done!
== Frequently Asked Questions ==
None yet.
== Screenshots ==
1. Editing a Form
2. Form displayed in the default theme
3. Email confirmation view
4. Success message
== Changelog ==
Commit log is available at https://github.com/libreform/libreform/commits/master

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display