Changeset 2925655
- Timestamp:
- 06/14/2023 03:36:34 AM (3 years ago)
- Location:
- bulky-bulk-edit-products-for-woo/trunk
- Files:
-
- 6 edited
-
CHANGELOG.txt (modified) (1 diff)
-
assets/dist/editor.js (modified) (2 diffs)
-
assets/dist/editor.min.js (modified) (1 diff)
-
bulky-bulk-edit-products-for-woo.php (modified) (3 diffs)
-
readme.txt (modified) (1 diff)
-
support/support.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
bulky-bulk-edit-products-for-woo/trunk/CHANGELOG.txt
r2905401 r2925655 1 /** 1.1.3 - 2023.06.02 **/ 2 - Fix: Cannot save after add new product 3 1 4 /** 1.1.2 - 2023.04.28 **/ 2 5 - Fix: DOMPurify exclude object -
bulky-bulk-edit-products-for-woo/trunk/assets/dist/editor.js
r2905401 r2925655 5498 5498 $this.compare.push(pid); 5499 5499 $this.compare = [...new Set($this.compare)]; 5500 console.log($this.compare) 5500 5501 $this.menubar.find('.vi-wbe-save-button').addClass('vi-wbe-saveable'); 5501 5502 … … 5696 5697 for (let pid of this.compare) { 5697 5698 for (let product of products) { 5698 if (p roduct[0]=== parseInt(pid)) {5699 if (parseInt(product[0]) === parseInt(pid)) { 5699 5700 productsForSave.push(product); 5700 5701 } -
bulky-bulk-edit-products-for-woo/trunk/assets/dist/editor.min.js
r2905401 r2925655 1 1 /*! For license information please see editor.min.js.LICENSE.txt */ 2 (()=>{var e={744:function(e){e.exports=function(){"use strict";const{entries:e,setPrototypeOf:t,isFrozen:i,getPrototypeOf:a,getOwnPropertyDescriptor:n}=Object;let{freeze:o,seal:s,create:l}=Object,{apply:r,construct:c}="undefined"!=typeof Reflect&&Reflect;r||(r=function(e,t,i){return e.apply(t,i)}),o||(o=function(e){return e}),s||(s=function(e){return e}),c||(c=function(e,t){return new e(...t)});const d=_(Array.prototype.forEach),u=_(Array.prototype.pop),p=_(Array.prototype.push),h=_(String.prototype.toLowerCase),m=_(String.prototype.toString),b=_(String.prototype.match),f=_(String.prototype.replace),v=_(String.prototype.indexOf),g=_(String.prototype.trim),w=_(RegExp.prototype.test),y=(x=TypeError,function(){for(var e=arguments.length,t=new Array(e),i=0;i<e;i++)t[i]=arguments[i];return c(x,t)});var x;function _(e){return function(t){for(var i=arguments.length,a=new Array(i>1?i-1:0),n=1;n<i;n++)a[n-1]=arguments[n];return r(e,t,a)}}function C(e,a,n){n=n||h,t&&t(e,null);let o=a.length;for(;o--;){let t=a[o];if("string"==typeof t){const e=n(t);e!==t&&(i(a)||(a[o]=e),t=e)}e[t]=!0}return e}function k(t){const i=l(null);for(const[a,n]of e(t))i[a]=n;return i}function T(e,t){for(;null!==e;){const i=n(e,t);if(i){if(i.get)return _(i.get);if("function"==typeof i.value)return _(i.value)}e=a(e)}return function(e){return console.warn("fallback value for",e),null}}const A=o(["a","abbr","acronym","address","area","article","aside","audio","b","bdi","bdo","big","blink","blockquote","body","br","button","canvas","caption","center","cite","code","col","colgroup","content","data","datalist","dd","decorator","del","details","dfn","dialog","dir","div","dl","dt","element","em","fieldset","figcaption","figure","font","footer","form","h1","h2","h3","h4","h5","h6","head","header","hgroup","hr","html","i","img","input","ins","kbd","label","legend","li","main","map","mark","marquee","menu","menuitem","meter","nav","nobr","ol","optgroup","option","output","p","picture","pre","progress","q","rp","rt","ruby","s","samp","section","select","shadow","small","source","spacer","span","strike","strong","style","sub","summary","sup","table","tbody","td","template","textarea","tfoot","th","thead","time","tr","track","tt","u","ul","var","video","wbr"]),$=o(["svg","a","altglyph","altglyphdef","altglyphitem","animatecolor","animatemotion","animatetransform","circle","clippath","defs","desc","ellipse","filter","font","g","glyph","glyphref","hkern","image","line","lineargradient","marker","mask","metadata","mpath","path","pattern","polygon","polyline","radialgradient","rect","stop","style","switch","symbol","text","textpath","title","tref","tspan","view","vkern"]),E=o(["feBlend","feColorMatrix","feComponentTransfer","feComposite","feConvolveMatrix","feDiffuseLighting","feDisplacementMap","feDistantLight","feFlood","feFuncA","feFuncB","feFuncG","feFuncR","feGaussianBlur","feImage","feMerge","feMergeNode","feMorphology","feOffset","fePointLight","feSpecularLighting","feSpotLight","feTile","feTurbulence"]),S=o(["animate","color-profile","cursor","discard","fedropshadow","font-face","font-face-format","font-face-name","font-face-src","font-face-uri","foreignobject","hatch","hatchpath","mesh","meshgradient","meshpatch","meshrow","missing-glyph","script","set","solidcolor","unknown","use"]),N=o(["math","menclose","merror","mfenced","mfrac","mglyph","mi","mlabeledtr","mmultiscripts","mn","mo","mover","mpadded","mphantom","mroot","mrow","ms","mspace","msqrt","mstyle","msub","msup","msubsup","mtable","mtd","mtext","mtr","munder","munderover","mprescripts"]),I=o(["maction","maligngroup","malignmark","mlongdiv","mscarries","mscarry","msgroup","mstack","msline","msrow","semantics","annotation","annotation-xml","mprescripts","none"]),R=o(["#text"]),F=o(["accept","action","align","alt","autocapitalize","autocomplete","autopictureinpicture","autoplay","background","bgcolor","border","capture","cellpadding","cellspacing","checked","cite","class","clear","color","cols","colspan","controls","controlslist","coords","crossorigin","datetime","decoding","default","dir","disabled","disablepictureinpicture","disableremoteplayback","download","draggable","enctype","enterkeyhint","face","for","headers","height","hidden","high","href","hreflang","id","inputmode","integrity","ismap","kind","label","lang","list","loading","loop","low","max","maxlength","media","method","min","minlength","multiple","muted","name","nonce","noshade","novalidate","nowrap","open","optimum","pattern","placeholder","playsinline","poster","preload","pubdate","radiogroup","readonly","rel","required","rev","reversed","role","rows","rowspan","spellcheck","scope","selected","shape","size","sizes","span","srclang","start","src","srcset","step","style","summary","tabindex","title","translate","type","usemap","valign","value","width","xmlns","slot"]),D=o(["accent-height","accumulate","additive","alignment-baseline","ascent","attributename","attributetype","azimuth","basefrequency","baseline-shift","begin","bias","by","class","clip","clippathunits","clip-path","clip-rule","color","color-interpolation","color-interpolation-filters","color-profile","color-rendering","cx","cy","d","dx","dy","diffuseconstant","direction","display","divisor","dur","edgemode","elevation","end","fill","fill-opacity","fill-rule","filter","filterunits","flood-color","flood-opacity","font-family","font-size","font-size-adjust","font-stretch","font-style","font-variant","font-weight","fx","fy","g1","g2","glyph-name","glyphref","gradientunits","gradienttransform","height","href","id","image-rendering","in","in2","k","k1","k2","k3","k4","kerning","keypoints","keysplines","keytimes","lang","lengthadjust","letter-spacing","kernelmatrix","kernelunitlength","lighting-color","local","marker-end","marker-mid","marker-start","markerheight","markerunits","markerwidth","maskcontentunits","maskunits","max","mask","media","method","mode","min","name","numoctaves","offset","operator","opacity","order","orient","orientation","origin","overflow","paint-order","path","pathlength","patterncontentunits","patterntransform","patternunits","points","preservealpha","preserveaspectratio","primitiveunits","r","rx","ry","radius","refx","refy","repeatcount","repeatdur","restart","result","rotate","scale","seed","shape-rendering","specularconstant","specularexponent","spreadmethod","startoffset","stddeviation","stitchtiles","stop-color","stop-opacity","stroke-dasharray","stroke-dashoffset","stroke-linecap","stroke-linejoin","stroke-miterlimit","stroke-opacity","stroke","stroke-width","style","surfacescale","systemlanguage","tabindex","targetx","targety","transform","transform-origin","text-anchor","text-decoration","text-rendering","textlength","type","u1","u2","unicode","values","viewbox","visibility","version","vert-adv-y","vert-origin-x","vert-origin-y","width","word-spacing","wrap","writing-mode","xchannelselector","ychannelselector","x","x1","x2","xmlns","y","y1","y2","z","zoomandpan"]),M=o(["accent","accentunder","align","bevelled","close","columnsalign","columnlines","columnspan","denomalign","depth","dir","display","displaystyle","encoding","fence","frame","height","href","id","largeop","length","linethickness","lspace","lquote","mathbackground","mathcolor","mathsize","mathvariant","maxsize","minsize","movablelimits","notation","numalign","open","rowalign","rowlines","rowspacing","rowspan","rspace","rquote","scriptlevel","scriptminsize","scriptsizemultiplier","selection","separator","separators","stretchy","subscriptshift","supscriptshift","symmetric","voffset","width","xmlns"]),O=o(["xlink:href","xml:id","xlink:title","xml:space","xmlns:xlink"]),j=s(/\{\{[\w\W]*|[\w\W]*\}\}/gm),L=s(/<%[\w\W]*|[\w\W]*%>/gm),P=s(/\${[\w\W]*}/gm),H=s(/^data-[\-\w.\u00B7-\uFFFF]/),U=s(/^aria-[\-\w]+$/),B=s(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i),W=s(/^(?:\w+script|data):/i),z=s(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g),G=s(/^html$/i);var V=Object.freeze({__proto__:null,MUSTACHE_EXPR:j,ERB_EXPR:L,TMPLIT_EXPR:P,DATA_ATTR:H,ARIA_ATTR:U,IS_ALLOWED_URI:B,IS_SCRIPT_OR_DATA:W,ATTR_WHITESPACE:z,DOCTYPE_NAME:G});const J=()=>"undefined"==typeof window?null:window,K=function(e,t){if("object"!=typeof e||"function"!=typeof e.createPolicy)return null;let i=null;const a="data-tt-policy-suffix";t.currentScript&&t.currentScript.hasAttribute(a)&&(i=t.currentScript.getAttribute(a));const n="dompurify"+(i?"#"+i:"");try{return e.createPolicy(n,{createHTML:e=>e,createScriptURL:e=>e})}catch(e){return console.warn("TrustedTypes policy "+n+" could not be created."),null}};return function t(){let i=arguments.length>0&&void 0!==arguments[0]?arguments[0]:J();const a=e=>t(e);if(a.version="3.0.2",a.removed=[],!i||!i.document||9!==i.document.nodeType)return a.isSupported=!1,a;const n=i.document;let{document:s}=i;const{DocumentFragment:l,HTMLTemplateElement:r,Node:c,Element:x,NodeFilter:_,NamedNodeMap:j=i.NamedNodeMap||i.MozNamedAttrMap,HTMLFormElement:L,DOMParser:P,trustedTypes:H}=i,U=x.prototype,W=T(U,"cloneNode"),z=T(U,"nextSibling"),Q=T(U,"childNodes"),q=T(U,"parentNode");if("function"==typeof r){const e=s.createElement("template");e.content&&e.content.ownerDocument&&(s=e.content.ownerDocument)}const X=K(H,n),Y=X?X.createHTML(""):"",{implementation:Z,createNodeIterator:ee,createDocumentFragment:te,getElementsByTagName:ie}=s,{importNode:ae}=n;let ne={};a.isSupported="function"==typeof e&&"function"==typeof q&&Z&&void 0!==Z.createHTMLDocument;const{MUSTACHE_EXPR:oe,ERB_EXPR:se,TMPLIT_EXPR:le,DATA_ATTR:re,ARIA_ATTR:ce,IS_SCRIPT_OR_DATA:de,ATTR_WHITESPACE:ue}=V;let{IS_ALLOWED_URI:pe}=V,he=null;const me=C({},[...A,...$,...E,...N,...R]);let be=null;const fe=C({},[...F,...D,...M,...O]);let ve=Object.seal(Object.create(null,{tagNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},allowCustomizedBuiltInElements:{writable:!0,configurable:!1,enumerable:!0,value:!1}})),ge=null,we=null,ye=!0,xe=!0,_e=!1,Ce=!0,ke=!1,Te=!1,Ae=!1,$e=!1,Ee=!1,Se=!1,Ne=!1,Ie=!0,Re=!1;const Fe="user-content-";let De=!0,Me=!1,Oe={},je=null;const Le=C({},["annotation-xml","audio","colgroup","desc","foreignobject","head","iframe","math","mi","mn","mo","ms","mtext","noembed","noframes","noscript","plaintext","script","style","svg","template","thead","title","video","xmp"]);let Pe=null;const He=C({},["audio","video","img","source","image","track"]);let Ue=null;const Be=C({},["alt","class","for","id","label","name","pattern","placeholder","role","summary","title","value","style","xmlns"]),We="http://www.w3.org/1998/Math/MathML",ze="http://www.w3.org/2000/svg",Ge="http://www.w3.org/1999/xhtml";let Ve=Ge,Je=!1,Ke=null;const Qe=C({},[We,ze,Ge],m);let qe;const Xe=["application/xhtml+xml","text/html"],Ye="text/html";let Ze,et=null;const tt=s.createElement("form"),it=function(e){return e instanceof RegExp||e instanceof Function},at=function(e){et&&et===e||(e&&"object"==typeof e||(e={}),e=k(e),qe=qe=-1===Xe.indexOf(e.PARSER_MEDIA_TYPE)?Ye:e.PARSER_MEDIA_TYPE,Ze="application/xhtml+xml"===qe?m:h,he="ALLOWED_TAGS"in e?C({},e.ALLOWED_TAGS,Ze):me,be="ALLOWED_ATTR"in e?C({},e.ALLOWED_ATTR,Ze):fe,Ke="ALLOWED_NAMESPACES"in e?C({},e.ALLOWED_NAMESPACES,m):Qe,Ue="ADD_URI_SAFE_ATTR"in e?C(k(Be),e.ADD_URI_SAFE_ATTR,Ze):Be,Pe="ADD_DATA_URI_TAGS"in e?C(k(He),e.ADD_DATA_URI_TAGS,Ze):He,je="FORBID_CONTENTS"in e?C({},e.FORBID_CONTENTS,Ze):Le,ge="FORBID_TAGS"in e?C({},e.FORBID_TAGS,Ze):{},we="FORBID_ATTR"in e?C({},e.FORBID_ATTR,Ze):{},Oe="USE_PROFILES"in e&&e.USE_PROFILES,ye=!1!==e.ALLOW_ARIA_ATTR,xe=!1!==e.ALLOW_DATA_ATTR,_e=e.ALLOW_UNKNOWN_PROTOCOLS||!1,Ce=!1!==e.ALLOW_SELF_CLOSE_IN_ATTR,ke=e.SAFE_FOR_TEMPLATES||!1,Te=e.WHOLE_DOCUMENT||!1,Ee=e.RETURN_DOM||!1,Se=e.RETURN_DOM_FRAGMENT||!1,Ne=e.RETURN_TRUSTED_TYPE||!1,$e=e.FORCE_BODY||!1,Ie=!1!==e.SANITIZE_DOM,Re=e.SANITIZE_NAMED_PROPS||!1,De=!1!==e.KEEP_CONTENT,Me=e.IN_PLACE||!1,pe=e.ALLOWED_URI_REGEXP||B,Ve=e.NAMESPACE||Ge,ve=e.CUSTOM_ELEMENT_HANDLING||{},e.CUSTOM_ELEMENT_HANDLING&&it(e.CUSTOM_ELEMENT_HANDLING.tagNameCheck)&&(ve.tagNameCheck=e.CUSTOM_ELEMENT_HANDLING.tagNameCheck),e.CUSTOM_ELEMENT_HANDLING&&it(e.CUSTOM_ELEMENT_HANDLING.attributeNameCheck)&&(ve.attributeNameCheck=e.CUSTOM_ELEMENT_HANDLING.attributeNameCheck),e.CUSTOM_ELEMENT_HANDLING&&"boolean"==typeof e.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements&&(ve.allowCustomizedBuiltInElements=e.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements),ke&&(xe=!1),Se&&(Ee=!0),Oe&&(he=C({},[...R]),be=[],!0===Oe.html&&(C(he,A),C(be,F)),!0===Oe.svg&&(C(he,$),C(be,D),C(be,O)),!0===Oe.svgFilters&&(C(he,E),C(be,D),C(be,O)),!0===Oe.mathMl&&(C(he,N),C(be,M),C(be,O))),e.ADD_TAGS&&(he===me&&(he=k(he)),C(he,e.ADD_TAGS,Ze)),e.ADD_ATTR&&(be===fe&&(be=k(be)),C(be,e.ADD_ATTR,Ze)),e.ADD_URI_SAFE_ATTR&&C(Ue,e.ADD_URI_SAFE_ATTR,Ze),e.FORBID_CONTENTS&&(je===Le&&(je=k(je)),C(je,e.FORBID_CONTENTS,Ze)),De&&(he["#text"]=!0),Te&&C(he,["html","head","body"]),he.table&&(C(he,["tbody"]),delete ge.tbody),o&&o(e),et=e)},nt=C({},["mi","mo","mn","ms","mtext"]),ot=C({},["foreignobject","desc","title","annotation-xml"]),st=C({},["title","style","font","a","script"]),lt=C({},$);C(lt,E),C(lt,S);const rt=C({},N);C(rt,I);const ct=function(e){let t=q(e);t&&t.tagName||(t={namespaceURI:Ve,tagName:"template"});const i=h(e.tagName),a=h(t.tagName);return!!Ke[e.namespaceURI]&&(e.namespaceURI===ze?t.namespaceURI===Ge?"svg"===i:t.namespaceURI===We?"svg"===i&&("annotation-xml"===a||nt[a]):Boolean(lt[i]):e.namespaceURI===We?t.namespaceURI===Ge?"math"===i:t.namespaceURI===ze?"math"===i&&ot[a]:Boolean(rt[i]):e.namespaceURI===Ge?!(t.namespaceURI===ze&&!ot[a])&&!(t.namespaceURI===We&&!nt[a])&&!rt[i]&&(st[i]||!lt[i]):!("application/xhtml+xml"!==qe||!Ke[e.namespaceURI]))},dt=function(e){p(a.removed,{element:e});try{e.parentNode.removeChild(e)}catch(t){e.remove()}},ut=function(e,t){try{p(a.removed,{attribute:t.getAttributeNode(e),from:t})}catch(e){p(a.removed,{attribute:null,from:t})}if(t.removeAttribute(e),"is"===e&&!be[e])if(Ee||Se)try{dt(t)}catch(e){}else try{t.setAttribute(e,"")}catch(e){}},pt=function(e){let t,i;if($e)e="<remove></remove>"+e;else{const t=b(e,/^[\r\n\t ]+/);i=t&&t[0]}"application/xhtml+xml"===qe&&Ve===Ge&&(e='<html xmlns="http://www.w3.org/1999/xhtml"><head></head><body>'+e+"</body></html>");const a=X?X.createHTML(e):e;if(Ve===Ge)try{t=(new P).parseFromString(a,qe)}catch(e){}if(!t||!t.documentElement){t=Z.createDocument(Ve,"template",null);try{t.documentElement.innerHTML=Je?Y:a}catch(e){}}const n=t.body||t.documentElement;return e&&i&&n.insertBefore(s.createTextNode(i),n.childNodes[0]||null),Ve===Ge?ie.call(t,Te?"html":"body")[0]:Te?t.documentElement:n},ht=function(e){return ee.call(e.ownerDocument||e,e,_.SHOW_ELEMENT|_.SHOW_COMMENT|_.SHOW_TEXT,null,!1)},mt=function(e){return e instanceof L&&("string"!=typeof e.nodeName||"string"!=typeof e.textContent||"function"!=typeof e.removeChild||!(e.attributes instanceof j)||"function"!=typeof e.removeAttribute||"function"!=typeof e.setAttribute||"string"!=typeof e.namespaceURI||"function"!=typeof e.insertBefore||"function"!=typeof e.hasChildNodes)},bt=function(e){return"object"==typeof c?e instanceof c:e&&"object"==typeof e&&"number"==typeof e.nodeType&&"string"==typeof e.nodeName},ft=function(e,t,i){ne[e]&&d(ne[e],(e=>{e.call(a,t,i,et)}))},vt=function(e){let t;if(ft("beforeSanitizeElements",e,null),mt(e))return dt(e),!0;const i=Ze(e.nodeName);if(ft("uponSanitizeElement",e,{tagName:i,allowedTags:he}),e.hasChildNodes()&&!bt(e.firstElementChild)&&(!bt(e.content)||!bt(e.content.firstElementChild))&&w(/<[/\w]/g,e.innerHTML)&&w(/<[/\w]/g,e.textContent))return dt(e),!0;if(!he[i]||ge[i]){if(!ge[i]&&wt(i)){if(ve.tagNameCheck instanceof RegExp&&w(ve.tagNameCheck,i))return!1;if(ve.tagNameCheck instanceof Function&&ve.tagNameCheck(i))return!1}if(De&&!je[i]){const t=q(e)||e.parentNode,i=Q(e)||e.childNodes;if(i&&t)for(let a=i.length-1;a>=0;--a)t.insertBefore(W(i[a],!0),z(e))}return dt(e),!0}return e instanceof x&&!ct(e)?(dt(e),!0):"noscript"!==i&&"noembed"!==i||!w(/<\/no(script|embed)/i,e.innerHTML)?(ke&&3===e.nodeType&&(t=e.textContent,t=f(t,oe," "),t=f(t,se," "),t=f(t,le," "),e.textContent!==t&&(p(a.removed,{element:e.cloneNode()}),e.textContent=t)),ft("afterSanitizeElements",e,null),!1):(dt(e),!0)},gt=function(e,t,i){if(Ie&&("id"===t||"name"===t)&&(i in s||i in tt))return!1;if(xe&&!we[t]&&w(re,t));else if(ye&&w(ce,t));else if(!be[t]||we[t]){if(!(wt(e)&&(ve.tagNameCheck instanceof RegExp&&w(ve.tagNameCheck,e)||ve.tagNameCheck instanceof Function&&ve.tagNameCheck(e))&&(ve.attributeNameCheck instanceof RegExp&&w(ve.attributeNameCheck,t)||ve.attributeNameCheck instanceof Function&&ve.attributeNameCheck(t))||"is"===t&&ve.allowCustomizedBuiltInElements&&(ve.tagNameCheck instanceof RegExp&&w(ve.tagNameCheck,i)||ve.tagNameCheck instanceof Function&&ve.tagNameCheck(i))))return!1}else if(Ue[t]);else if(w(pe,f(i,ue,"")));else if("src"!==t&&"xlink:href"!==t&&"href"!==t||"script"===e||0!==v(i,"data:")||!Pe[e])if(_e&&!w(de,f(i,ue,"")));else if(i)return!1;return!0},wt=function(e){return e.indexOf("-")>0},yt=function(e){let t,i,n,o;ft("beforeSanitizeAttributes",e,null);const{attributes:s}=e;if(!s)return;const l={attrName:"",attrValue:"",keepAttr:!0,allowedAttributes:be};for(o=s.length;o--;){t=s[o];const{name:r,namespaceURI:c}=t;if(i="value"===r?t.value:g(t.value),n=Ze(r),l.attrName=n,l.attrValue=i,l.keepAttr=!0,l.forceKeepAttr=void 0,ft("uponSanitizeAttribute",e,l),i=l.attrValue,l.forceKeepAttr)continue;if(ut(r,e),!l.keepAttr)continue;if(!Ce&&w(/\/>/i,i)){ut(r,e);continue}ke&&(i=f(i,oe," "),i=f(i,se," "),i=f(i,le," "));const d=Ze(e.nodeName);if(gt(d,n,i)){if(!Re||"id"!==n&&"name"!==n||(ut(r,e),i=Fe+i),X&&"object"==typeof H&&"function"==typeof H.getAttributeType)if(c);else switch(H.getAttributeType(d,n)){case"TrustedHTML":i=X.createHTML(i);break;case"TrustedScriptURL":i=X.createScriptURL(i)}try{c?e.setAttributeNS(c,r,i):e.setAttribute(r,i),u(a.removed)}catch(e){}}}ft("afterSanitizeAttributes",e,null)},xt=function e(t){let i;const a=ht(t);for(ft("beforeSanitizeShadowDOM",t,null);i=a.nextNode();)ft("uponSanitizeShadowNode",i,null),vt(i)||(i.content instanceof l&&e(i.content),yt(i));ft("afterSanitizeShadowDOM",t,null)};return a.sanitize=function(e){let t,i,o,s,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(Je=!e,Je&&(e="\x3c!--\x3e"),"string"!=typeof e&&!bt(e)){if("function"!=typeof e.toString)throw y("toString is not a function");if("string"!=typeof(e=e.toString()))throw y("dirty is not a string, aborting")}if(!a.isSupported)return e;if(Ae||at(r),a.removed=[],"string"==typeof e&&(Me=!1),Me){if(e.nodeName){const t=Ze(e.nodeName);if(!he[t]||ge[t])throw y("root node is forbidden and cannot be sanitized in-place")}}else if(e instanceof c)t=pt("\x3c!----\x3e"),i=t.ownerDocument.importNode(e,!0),1===i.nodeType&&"BODY"===i.nodeName||"HTML"===i.nodeName?t=i:t.appendChild(i);else{if(!Ee&&!ke&&!Te&&-1===e.indexOf("<"))return X&&Ne?X.createHTML(e):e;if(t=pt(e),!t)return Ee?null:Ne?Y:""}t&&$e&&dt(t.firstChild);const d=ht(Me?e:t);for(;o=d.nextNode();)vt(o)||(o.content instanceof l&&xt(o.content),yt(o));if(Me)return e;if(Ee){if(Se)for(s=te.call(t.ownerDocument);t.firstChild;)s.appendChild(t.firstChild);else s=t;return(be.shadowroot||be.shadowrootmod)&&(s=ae.call(n,s,!0)),s}let u=Te?t.outerHTML:t.innerHTML;return Te&&he["!doctype"]&&t.ownerDocument&&t.ownerDocument.doctype&&t.ownerDocument.doctype.name&&w(G,t.ownerDocument.doctype.name)&&(u="<!DOCTYPE "+t.ownerDocument.doctype.name+">\n"+u),ke&&(u=f(u,oe," "),u=f(u,se," "),u=f(u,le," ")),X&&Ne?X.createHTML(u):u},a.setConfig=function(e){at(e),Ae=!0},a.clearConfig=function(){et=null,Ae=!1},a.isValidAttribute=function(e,t,i){et||at({});const a=Ze(e),n=Ze(t);return gt(a,n,i)},a.addHook=function(e,t){"function"==typeof t&&(ne[e]=ne[e]||[],p(ne[e],t))},a.removeHook=function(e){if(ne[e])return u(ne[e])},a.removeHooks=function(e){ne[e]&&(ne[e]=[])},a.removeAllHooks=function(){ne={}},a}()}()}},t={};function i(a){var n=t[a];if(void 0!==n)return n.exports;var o=t[a]={exports:{}};return e[a].call(o.exports,o,o.exports,i),o.exports}(()=>{"use strict";const e={modal(e={}){let{header:t="",content:i="",actionsHtml:a=""}=e;return`<div class="vi-wbe-modal-container">\n <div class="vi-wbe-modal-main vi-ui form small">\n <i class="close icon"></i>\n <div class="vi-wbe-modal-wrapper">\n <h3 class="header">${t}</h3>\n <div class="content">${i}</div>\n <div class="actions">${a}</div>\n </div>\n </div>\n </div>`},defaultAttributes(e={}){let{html:t}=e;return`<table class="vi-ui celled table">\n <thead>\n <tr>\n <th>Name</th>\n <th>Attribute</th>\n </tr>\n </thead>\n <tbody>\n ${t}\n </tbody>\n </table>`}},t={},a={};jQuery(document).ready((function(i){window.viIsEditing=!1;const o=wp.media({multiple:!0}),s=wp.media({multiple:!1}),r={galleryImage:(e,t)=>`<li class="vi-wbe-gallery-image" data-id="${t}"><i class="vi-wbe-remove-image dashicons dashicons-no-alt"> </i><img src="${e}"></li>`,fileDownload(e={}){let{id:t,name:a,file:n}=e,o=i(`<tr>\n <td><i class="bars icon"></i><input type="text" class="vi-wbe-file-name" value="${a||""}"></td>\n <td>\n <input type="text" class="vi-wbe-file-url" value="${n||""}">\n <input type="hidden" class="vi-wbe-file-hash" value="${t||""}">\n <span class="vi-ui button mini vi-wbe-choose-file">${l.text("Choose file")}</span>\n <i class="vi-wbe-remove-file dashicons dashicons-no-alt"> </i>\n </td>\n </tr>`);return o.on("click",".vi-wbe-remove-file",(function(){o.remove()})),o}};t.textEditor={type:"textEditor",createCell:(e,t,i,a)=>(e.innerHTML=l.stripHtml(i).slice(0,50),e),closeEditor(e,t){window.viIsEditing=!1;let i="";return!0===t&&(i=wp.editor.getContent("vi-wbe-text-editor"),this.isEditing||wp.editor.remove("vi-wbe-text-editor"),this.isEditing=!1),i},openEditor(e,t,a){window.viIsEditing=!0;let n=e.getAttribute("data-y"),o=e.getAttribute("data-x"),s=a.options.data[n][o],l=this,r=i(".vi-ui.modal .close.icon");i(".vi-ui.modal").modal("show"),this.tinymceInit(s),r.off("click"),i(".vi-wbe-text-editor-save").off("click").on("click",(function(){i(this).removeClass("primary"),i(this).hasClass("vi-wbe-close")?i(".vi-ui.modal").modal("hide"):l.isEditing=!0,a.closeEditor(e,!0)})),r.on("click",(function(){a.closeEditor(e,!1)})),i(".vi-ui.modal").parent().on("click",(function(t){t.target===t.delegateTarget&&a.closeEditor(e,!1)}))},updateCell:(e,t,i)=>(e.innerHTML=l.stripHtml(t).slice(0,50),t),tinymceInit(e=""){e=wp.editor.autop(e),null===tinymce.get("vi-wbe-text-editor")&&(i("#vi-wbe-text-editor").val(e),n.tinyMceOptions.tinymce.setup=function(e){e.on("keyup",(function(e){i(".vi-wbe-text-editor-save:not(.vi-wbe-close)").addClass("primary")}))},wp.editor.initialize("vi-wbe-text-editor",n.tinyMceOptions)),tinymce.get("vi-wbe-text-editor").setContent(e)}},t.image={createCell(e,t,a,o){if(a){let t=n.imgStorage[a];l.isUrl(t)?i(e).html(`<img width="40" src="${t}" data-id="${a}">`):i(e).html("")}return e},closeEditor:(e,t)=>i(e).find("img").attr("data-id")||"",openEditor(e,t,a){function o(){s.open().off("select").on("select",(function(t){let o=s.state().get("selection").first().toJSON();l.isUrl(o.url)&&(i(e).html(`<img width="40" src="${o.url}" data-id="${o.id}">`),n.imgStorage[o.id]=o.url,a.closeEditor(e,!0))}))}i(e).on("dblclick",o),o()},updateCell(e,t,a){t=parseInt(t)||"";let o=n.imgStorage[t];return l.isUrl(o)?i(e).html(`<img width="40" src="${o}" data-id="${t}">`):i(e).html(""),t}},t.gallery={type:"gallery",saveData(e){let t=[];i(e).find(".vi-wbe-gallery-image").each((function(){t.push(i(this).data("id"))})),i(e).find(".vi-wbe-ids-list").val(t.join(","))},createCell(e,t,a){let n=a.length?"vi-wbe-gallery-has-item":"";return i(e).addClass("vi-wbe-gallery"),i(e).html(`<div class="vi-wbe-gallery ${n}"><i class="images outline icon"> </i></div>`),e},closeEditor(e,t){window.viIsEditing=!1;let a=[];return t&&i(e).children().find(".vi-wbe-gallery-image").each((function(){a.push(i(this).data("id"))})),i(e).find(".vi-wbe-cell-popup").remove(),a},openEditor(e,t,a){window.viIsEditing=!0;let s=e.getAttribute("data-y"),c=e.getAttribute("data-x"),d=a.options.data[s][c],u="";if(d.length)for(let e of d){let t=n.imgStorage[e];u+=r.galleryImage(t,e)}let p=i(`<div class="vi-wbe-cell-popup-inner">\n <ul class="vi-wbe-gallery-images">${u}</ul>\n <span class="vi-ui button tiny vi-wbe-add-image">${l.text("Add image")}</span>\n <span class="vi-ui button tiny vi-wbe-remove-gallery">${l.text("Remove all")}</span>\n </div>`);l.createEditor(e,"div",p),p.find(".vi-wbe-gallery-images").sortable({items:"li.vi-wbe-gallery-image",cursor:"move",scrollSensitivity:40,forcePlaceholderSize:!0,forceHelperSize:!1,helper:"clone",placeholder:"vi-wbe-sortable-placeholder",tolerance:"pointer"}),p.on("click",".vi-wbe-remove-image",(function(){i(this).parent().remove()})),p.on("click",".vi-wbe-add-image",(function(){o.open().off("select close").on("select",(function(e){o.state().get("selection").each((function(e){"image"===(e=e.toJSON()).type&&(n.imgStorage[e.id]=e.url,p.find(".vi-wbe-gallery-images").append(r.galleryImage(e.url,e.id)))}))}))})),p.on("click",".vi-wbe-remove-gallery",(function(){p.find(".vi-wbe-gallery-images").empty()})),0===d.length&&p.find(".vi-wbe-add-image").trigger("click")},updateCell(e,t,a){let n=i(e).find(".vi-wbe-gallery");return t.length?n.addClass("vi-wbe-gallery-has-item"):n.removeClass("vi-wbe-gallery-has-item"),t}},t.download={createCell:(e,t,a)=>(i(e).html('<div><i class="download icon"> </i></div>'),e),closeEditor(e,t){let a=[];if(t){let t=i(e).children();t.find("table.vi-wbe-files-download tbody tr").each((function(){let e=i(this);a.push({id:e.find(".vi-wbe-file-hash").val(),file:e.find(".vi-wbe-file-url").val(),name:e.find(".vi-wbe-file-name").val()})})),t.remove()}return a},openEditor(e,t,a){let n,o=e.getAttribute("data-y"),c=e.getAttribute("data-x"),d=a.options.data[o][c],u=i("<tbody></tbody>");if(Array.isArray(d))for(let e of d)u.append(r.fileDownload(e));let p=i(`<div class="">\n <table class="vi-wbe-files-download vi-ui celled table">\n <thead>\n <tr>\n <th>${l.text("Name")}</th>\n <th>${l.text("File URL")}</th>\n </tr>\n </thead>\n </table>\n <span class="vi-ui button tiny vi-wbe-add-file">${l.text("Add file")}</span>\n </div>`);p.find(".vi-wbe-files-download").append(u),l.createEditor(e,"div",p),u.sortable(),p.on("click",".vi-wbe-add-file",(()=>p.find(".vi-wbe-files-download tbody").append(r.fileDownload()))),p.on("click",".vi-wbe-choose-file",(function(){n=a.edition,a.edition=null;let e=i(this).closest("tr");s.open().off("select close").on("select",(function(t){let i=s.state().get("selection").first().toJSON();i.url&&e.find(".vi-wbe-file-url").val(i.url).trigger("change")})).on("close",(()=>a.edition=n))})),d.length||p.find(".vi-wbe-add-file").trigger("click")},updateCell:(e,t,a)=>(i(e).html('<div><i class="download icon"> </i></div>'),t)},t.tags={type:"tags",createCell:(e,t,i,a)=>(l.formatText(e,i),e),openEditor(e,t,a){let o=e.getAttribute("data-y"),s=e.getAttribute("data-x"),r=a.options.data[o][s],c=i("<select/>"),d=l.createEditor(e,"div",c);c.select2({data:r,multiple:!0,minimumInputLength:3,placeholder:l.text("Search tags..."),ajax:{url:n.ajaxUrl,type:"post",data:function(e){return{...n.ajaxData,sub_action:"search_tags",search:e.term,type:"public"}},processResults:function(e){return{results:e}}}}),c.find("option").attr("selected",!0).parent().trigger("change"),i(d).find(".select2-search__field").trigger("click")},closeEditor(e,t){let a=i(e).children(),n=a.find("select").select2("data"),o=[];if(n.length)for(let e of n)o.push({id:e.id,text:e.text});return a.remove(),i(".select2-container").remove(),o},updateCell:(e,t,i,a,n)=>(l.formatText(e,t),t)},t.link_products={createCell:(e,t,i,a)=>(l.formatText(e,i),e),closeEditor(e,t){let a=i(e).children(),n=[];if(t){let e=a.find("select").select2("data");if(e.length)for(let t of e)n.push({id:t.id,text:t.text})}return a.remove(),i(".select2-container").remove(),n},openEditor(e,t,a){let o=e.getAttribute("data-y"),s=e.getAttribute("data-x"),r=a.options.data[o][s],c=i("<select/>"),d=l.createEditor(e,"div",c);c.select2({data:r,multiple:!0,minimumInputLength:3,placeholder:l.text("Search products..."),ajax:{url:n.ajaxUrl,type:"post",delay:250,dataType:"json",data:function(e){return{...n.ajaxData,sub_action:"search_products",search:e.term,type:"public"}},processResults:function(e){var t=[];return e&&i.each(e,(function(e,i){t.push({id:e,text:i})})),{results:t}}}}),c.find("option").attr("selected",!0).parent().trigger("change"),i(d).find(".select2-search__field").trigger("click")},updateCell:(e,t,i,a,n)=>(l.formatText(e,t),t)},t.product_attributes={type:"product_attributes",createCell(e,t,a,n){let o=Object.keys(a).length?"vi-wbe-has-attrs":"";return i(e).html(`<div class="vi-wbe-product-attrs ${o}"><i class="icon edit"/></div>`),e},updateCell(e,t,a,n,o){let s=i(e).find(".vi-wbe-product-attrs");return Object.keys(t).length?s.addClass("vi-wbe-has-attrs"):s.removeClass("vi-wbe-has-attrs"),t},openEditor(e,t,a){let o=l.getDataFromCell(a,e),s=l.getProductTypeFromCell(e),r=this,c="";this.productType=s;let d=l.createModal({header:l.text("Edit attributes"),content:"",actions:[{class:"save-attributes",text:l.text("Save")}]});if(i(e).append(d),"variation"!==s){let{attributes:e}=n,t=`<option value="">${l.text("Custom product attribute")}</option>`;for(let i in e)t+=`<option value="${i}">${e[i].data.attribute_label}</option>`;if(t=`<div class="vi-wbe-taxonomy-header">\n <select class="vi-wbe-select-taxonomy">${t}</select>\n <span class="vi-ui button tiny vi-wbe-add-taxonomy">${l.text("Add")}</span>\n </div>`,Array.isArray(o)&&o.length)for(let e of o)c+=r.createRowTable(e);c=`${t}\n <table class="vi-ui celled table">\n <thead>\n <tr>\n <th>Name</th>\n <th>Attributes</th>\n <th width="1">Actions</th>\n </tr>\n </thead>\n <tbody>${c}</tbody>\n </table>`,d.find(".content").append(c),d.find("table select").select2({multiple:!0}),d.find("tbody").sortable({items:"tr",cursor:"move",axis:"y",scrollSensitivity:40,forcePlaceholderSize:!0,helper:"clone",handle:".icon.move"});const a=()=>{d.find("select.vi-wbe-select-taxonomy option").removeAttr("disabled"),d.find("input[type=hidden]").each((function(e,t){let a=i(t).val();d.find(`select.vi-wbe-select-taxonomy option[value='${a}']`).attr("disabled","disabled")}))};a(),d.on("click",(function(e){let t=i(e.target);if(t.hasClass("trash")&&(t.closest("tr").remove(),a()),t.hasClass("vi-wbe-add-taxonomy")){let e=i(".vi-wbe-select-taxonomy"),t=e.val(),n={name:t,options:[]};t&&(n.is_taxonomy=1);let o=i(r.createRowTable(n));d.find("table tbody").append(o),o.find("select").select2({multiple:!0}),a(),e.val("").trigger("change")}if(t.hasClass("vi-wbe-select-all-attributes")){let e=t.closest("td").find("select");e.find("option").attr("selected",!0),e.trigger("change")}if(t.hasClass("vi-wbe-select-no-attributes")){let e=t.closest("td").find("select");e.find("option").attr("selected",!1),e.trigger("change")}if(t.hasClass("vi-wbe-add-new-attribute")){let e=prompt(l.text("Enter a name for the new attribute term:"));if(!e)return;let i=t.closest("tr.vi-wbe-attribute-row"),a=i.attr("data-attr");a&&(a=JSON.parse(a),l.ajax({data:{sub_action:"add_new_attribute",taxonomy:a.name,term:e},beforeSend(){t.addClass("loading")},success(e){if(t.removeClass("loading"),e.success){let t=i.find("select");t.append(`<option value="${e.data.term_id}" selected>${e.data.name}</option>`),t.trigger("change"),n.attributes[a.name].terms[e.data.term_id]={slug:e.data.slug,text:e.data.name}}else alert(e.data.message)}}))}}))}else{let t,i=e.getAttribute("data-y"),s=a.options.data[i][1],r=a.getData();for(let e in r)if(s==r[e][0]){let i=n.idMappingFlip.attributes;t=a.options.data[e][i];break}if(t)for(let e of t){let t,i=`<option value="">${l.text("Any...")}</option>`,a=e.name;if(e.is_taxonomy){let s=n.attributes[a];for(let t of e.options){let e=s.terms[t],n=e.slug===o[a]?"selected":"";i+=`<option value="${e.slug}" ${n}>${e.text}</option>`}t=s.data.attribute_label}else{for(let t of e.options)i+=`<option value="${t}" ${t===o[a]?"selected":""}>${t}</option>`;t=a}c+=`<tr><td>${t}</td><td><select name="${a}">${i}</select></td></tr>`}c=`<table class="vi-ui celled table">\n <thead>\n <tr>\n <th>${l.text("Attribute")}</th>\n <th>${l.text("Option")}</th>\n </tr>\n </thead>\n <tbody>\n ${c}\n </tbody>\n </table>`,d.find(".content").append(c)}d.on("click",(function(t){let n=i(t.target);(n.hasClass("close")||n.hasClass("vi-wbe-modal-container"))&&a.closeEditor(e,!1),n.hasClass("save-attributes")&&a.closeEditor(e,!0)}))},closeEditor(e,t){let a=[];return!0===t&&("variation"!==this.productType?i(e).find(".vi-wbe-attribute-row").each((function(e,t){let n=i(t).data("attr");if(n.is_taxonomy)n.options=i(t).find("select").val().map(Number);else{n.name=i(t).find("input.custom-attr-name").val();let e=i(t).find("textarea.custom-attr-val").val();n.value=e.trim().replace(/\s+/g," "),n.options=e.split("|").map((e=>e.trim().replace(/\s+/g," ")))}n.visible=!!i(t).find(".attr-visibility:checked").length,n.variation=!!i(t).find(".attr-variation:checked").length,n.position=e,a.push(n)})):(a={},i(e).find("select").each((function(e,t){a[i(t).attr("name")]=i(t).val()})))),l.removeModal(e),a},createRowTable(e){let t="",i="";if(e.is_taxonomy){let a=n.attributes[e.name],o=a.terms||[],s="";if(t=`${a.data.attribute_label}<input type="hidden" value="${e.name}"/>`,Object.keys(o).length)for(let t in o)s+=`<option value="${t}" ${e.options.includes(parseInt(t))?"selected":""}>${o[t].text}</option>`;i=`<select multiple>${s}</select>\n <div class="vi-wbe-attributes-button-group">\n <span class="vi-ui button mini vi-wbe-select-all-attributes">${l.text("Select all")}</span>\n <span class="vi-ui button mini vi-wbe-select-no-attributes">${l.text("Select none")}</span>\n <span class="vi-ui button mini vi-wbe-add-new-attribute">${l.text("Add new")}</span>\n </div>`}else t=`<input type="text" class="custom-attr-name" value="${e.name}" placeholder="${l.text("Custom attribute name")}"/>`,i=`<textarea class="custom-attr-val" placeholder="${l.text('Enter some text, or some attributes by "|" separating values.')}">${e.value||""}</textarea>`;return t=`<div class="vi-wbe-attribute-name-label">${t}</div>`,t+=`<div>\n <input type="checkbox" class="attr-visibility" ${e.visible?"checked":""} value="1">\n <label>${l.text("Visible on the product page")}</label>\n </div>`,"variable"===this.productType&&(t+=`<div>\n <input type="checkbox" class="attr-variation" ${e.variation?"checked":""} value="1">\n <label>${l.text("Used for variations")}</label>\n </div>`),`<tr class="vi-wbe-attribute-row" data-attr='${JSON.stringify(e)}'>\n <td class="vi-wbe-left">${t}</td>\n <td>${i}</td>\n <td class="vi-wbe-right"><i class="icon trash"> </i> <i class="icon move"> </i></td>\n </tr>`}},t.default_attributes={createCell:(e,t,a,n)=>(a&&i(e).text(Object.values(a).filter(Boolean).join("; ")),e),updateCell:(e,t,a,n,o)=>(t?i(e).text(Object.values(t).filter(Boolean).join("; ")):i(e).text(""),t),openEditor(t,a,o){let s=l.getDataFromCell(o,t),r=l.getProductTypeFromCell(t),c="";if(this.productType=r,"variable"===r){let a=l.createModal({header:l.text("Set default attributes"),content:"",actions:[{class:"save-attributes",text:l.text("Save")}]});i(t).append(a);let r=t.getAttribute("data-y"),d=n.idMappingFlip.attributes,u=o.options.data[r][d];if(Array.isArray(u)&&u.length)for(let e of u){if(0===e.options.length)continue;let t="",i="";if(e.is_taxonomy){let a=n.attributes[e.name];t=a.data.attribute_label;for(let t of e.options){let n=a.terms[t],o=n.slug===s[e.name]?"selected":"";i+=`<option value="${n.slug}" ${o}>${n.text}</option>`}}else{t=e.name;for(let t of e.options)i+=`<option value="${t}" ${t===s[e.name]?"selected":""}>${t}</option>`}i=`<option value="">No default ${t}</option> ${i}`,c+=`<tr><td>${t}</td><td><select name="${e.name}" class="vi-wbe-default-attribute">${i}</select></td></tr>`}a.find(".content").append(e.defaultAttributes({html:c})),a.on("click",(function(e){let a=i(e.target);(a.hasClass("close")||a.hasClass("vi-wbe-modal-container"))&&o.closeEditor(t,!1),a.hasClass("save-attributes")&&o.closeEditor(t,!0)}))}},closeEditor(e,t){let a={};return!0===t&&i(e).find(".vi-wbe-default-attribute").each(((e,t)=>a[i(t).attr("name")]=i(t).val())),l.removeModal(e),a}},t.array={createCell:(e,t,a,n)=>(i(e).html(a?JSON.stringify(a):a),e),closeEditor(e,t){let i=[];return!0===t&&(i=this.editor.get()),l.removeModal(e),i},openEditor(e,t,a){let n=l.getDataFromCell(a,e),o=l.createModal({header:l.text("Edit metadata"),content:"",actions:[{class:"save-metadata",text:l.text("Save")}]});i(e).append(o),o.find(".content").html('<div id="vi-wbe-jsoneditor"></div>');let s=o.find("#vi-wbe-jsoneditor").get(0);this.editor=new JSONEditor(s,{enableSort:!1,search:!1,enableTransform:!1}),this.editor.set(n),o.on("click",(function(t){let n=i(t.target);(n.hasClass("close")||n.hasClass("vi-wbe-modal-container"))&&a.closeEditor(e,!1),n.hasClass("save-metadata")&&a.closeEditor(e,!0)}))},updateCell:(e,t,a)=>(i(e).html(t?JSON.stringify(t):t),t)},t.order_notes={createCell(e,t,a,n){let o=a.length?"vi-wbe-gallery-has-item":"";return i(e).html(`<div class="${o}"><i class="icon eye"/></div>`),this.obj=n,e},closeEditor(e,t){return i(e).find(".vi-wbe-cell-popup").remove(),this.notes},openEditor(e,t,a){let n=e.getAttribute("data-y"),o=e.getAttribute("data-x"),s=a.options.data[n][o],r="";if(this.notes=s,s.length)for(let e of s){let t=e.content.replace(/(?:\r\n|\r|\n)/g,"<br>");r+=`<div class="vi-wbe-note-row">\n <div class="vi-wbe-note-row-content ${e.customer_note?"customer":"system"===e.added_by?"system":"private"}">${t}</div>\n <span class="vi-wbe-note-row-meta">\n ${e.date}\n <a href="#" data-comment_id="${e.id}" class="vi-wbe-note-row-delete">${l.text("Delete")}</a>\n </span>\n </div>`}let c=i(`<div class="vi-wbe-cell-popup-inner">${r}</div>`);l.createEditor(e,"div",c),c.on("click",".vi-wbe-note-row-delete",(function(){let e=i(this),t=e.data("comment_id");t&&l.ajax({data:{sub_action:"delete_order_note",id:t},beforeSend(){l.loading()},success(i){if(i.success){let i=s.findIndex((e=>e.id===t));s.splice(i,1),e.closest(".vi-wbe-note-row").remove()}l.removeLoading()}})}))},updateCell:(e,t,i)=>t},t.select2={type:"select2",createCell(e,t,i,a){let{source:n}=a.options.columns[t],o=[];return Array.isArray(n)&&n.length&&(o=n.filter((e=>i.includes(e.id)))),l.formatText(e,o),e},openEditor(e,t,a){let n=e.getAttribute("data-y"),o=e.getAttribute("data-x"),s=a.options.data[n][o],r=i("<select/>"),{source:c,multiple:d,placeholder:u}=a.options.columns[o],p=l.createEditor(e,"div",r);r.select2({data:c||[],multiple:d,placeholder:u}),r.val(s).trigger("change"),i(p).find(".select2-search__field").trigger("click")},closeEditor(e,t){let a=i(e).children(),n=a.find("select").val();return n=n.map((e=>isNaN(e)?e:+e)),a.remove(),i(".select2-container").remove(),n},updateCell(e,t,i,a,n){let{source:o}=a.options.columns[n],s=[];return Array.isArray(o)&&o.length&&(s=o.filter((e=>t.includes(e.id)))),l.formatText(e,s),t}},a.sourceForVariation=(e,t,i,a,n)=>{let o=n.options.columns[i].source;return"variation"===l.getProductTypeFromCell(t)&&(o=n.options.columns[i].subSource),o}}));const n={...wbeParams,productTypes:{},filterKey:Date.now(),selectPage:1,ajaxData:{action:"vi_wbe_ajax",vi_wbe_nonce:wbeParams.nonce},tinyMceOptions:{tinymce:{theme:"modern",skin:"lightgray",language:"en",formats:{alignleft:[{selector:"p,h1,h2,h3,h4,h5,h6,td,th,div,ul,ol,li",styles:{textAlign:"left"}},{selector:"img,table,dl.wp-caption",classes:"alignleft"}],aligncenter:[{selector:"p,h1,h2,h3,h4,h5,h6,td,th,div,ul,ol,li",styles:{textAlign:"center"}},{selector:"img,table,dl.wp-caption",classes:"aligncenter"}],alignright:[{selector:"p,h1,h2,h3,h4,h5,h6,td,th,div,ul,ol,li",styles:{textAlign:"right"}},{selector:"img,table,dl.wp-caption",classes:"alignright"}],strikethrough:{inline:"del"}},relative_urls:!1,remove_script_host:!1,convert_urls:!1,browser_spellcheck:!0,fix_list_elements:!0,entities:"38,amp,60,lt,62,gt",entity_encoding:"raw",keep_styles:!1,cache_suffix:"wp-mce-49110-20201110",resize:"vertical",menubar:!1,branding:!1,preview_styles:"font-family font-size font-weight font-style text-decoration text-transform",end_container_on_empty_block:!0,wpeditimage_html5_captions:!0,wp_lang_attr:"en-US",wp_keep_scroll_position:!1,wp_shortcut_labels:{"Heading 1":"access1","Heading 2":"access2","Heading 3":"access3","Heading 4":"access4","Heading 5":"access5","Heading 6":"access6",Paragraph:"access7",Blockquote:"accessQ",Underline:"metaU",Strikethrough:"accessD",Bold:"metaB",Italic:"metaI",Code:"accessX","Align center":"accessC","Align right":"accessR","Align left":"accessL",Justify:"accessJ",Cut:"metaX",Copy:"metaC",Paste:"metaV","Select all":"metaA",Undo:"metaZ",Redo:"metaY","Bullet list":"accessU","Numbered list":"accessO","Insert/edit image":"accessM","Insert/edit link":"metaK","Remove link":"accessS","Toolbar Toggle":"accessZ","Insert Read More tag":"accessT","Insert Page Break tag":"accessP","Distraction-free writing mode":"accessW","Add Media":"accessM","Keyboard Shortcuts":"accessH"},plugins:"charmap,colorpicker,hr,lists,media,paste,tabfocus,textcolor,fullscreen,wordpress,wpautoresize,wpeditimage,wpemoji,wpgallery,wplink,wpdialogs,wptextpattern,wpview",selector:"#vi-wbe-text-editor",wpautop:!0,indent:!1,toolbar1:"formatselect,bold,italic,bullist,numlist,blockquote,alignleft,aligncenter,alignright,link,wp_more,spellchecker,fullscreen,wp_adv",toolbar2:"strikethrough,hr,forecolor,pastetext,removeformat,charmap,outdent,indent,undo,redo,wp_help",tabfocus_elements:":prev,:next",body_class:"excerpt post-type-product post-status-publish page-template-default locale-en-us"},mediaButtons:!0,quicktags:!0},setColumns(e){try{let i=JSON.parse(e);n.columns=i.map((e=>(e&&e.editor&&t[e.editor]&&(e.editor=t[e.editor]),e&&e.filter&&a[e.filter]&&(e.filter=a[e.filter]),e)))}catch(e){console.log(e)}}};window.Attributes=n;const o=wbeI18n.i18n,s=jQuery,l={setJexcel(e){this.jexcel=e},text:e=>o[e]||e,isUrl:e=>/^(http(s?):)\/\/.*\.(?:jpg|jpeg|gif|png|webp)$/i.test(e),formatText(e,t){let i="";if(t.length)for(let e=0;e<t.length;e++)t[e]&&(i+=t[e].text+"; ");e.innerText=i},createEditor(e,t,i="",a=!0){let n=document.createElement(t);"div"===t&&s(n).append(i),n.style.minWidth="300px";let o=s(n).innerHeight(),l=s(e).offset(),r=l.left,c=l.top,d=s(e).innerWidth(),u=e.getBoundingClientRect();a?(n.style.minHeight=u.height-2+"px",n.style.maxHeight=window.innerHeight-c-50+"px"):(n.style.opacity=0,n.style.fontSize=0),n.classList.add("vi-ui","segment","vi-wbe-cell-popup","vi-wbe-editing"),e.classList.add("editor"),e.appendChild(n);let p=s(n).innerWidth();if(s(this.jexcel.el).innerWidth()<r+p+d){let e=r-p>0?r-p:10;s(n).css("left",e+"px")}else s(n).css("left",r+d+"px");if(window.innerHeight<c+o){let e=c-o<0?0:c-o;s(n).css("top",e+"px")}else s(n).css("top",c+"px");return n},createModal(t={}){let{actions:i}=t,a="";if(Array.isArray(i))for(let e of i)a+=`<span class="${e.class} vi-ui button tiny">${e.text}</span>`;return s(e.modal({...t,actionsHtml:a}))},removeModal(e){s(e).find(".vi-wbe-modal-container").remove(),s(".select2-container--open").remove()},getColFromColumnType:e=>n.idMappingFlip[e]||"",getProductTypeFromCell(e){let t=e.getAttribute("data-y"),i=this.getColFromColumnType("product_type");return this.jexcel.options.data[t][i]},getProductTypeFromY(e){let t=this.getColFromColumnType("product_type");return this.jexcel.options.data[e][t]},getColumnType:e=>n.idMapping[e],stripHtml:e=>s(`<div>${e}</div>`).text(),getDataFromCell(e,t){let i=t.getAttribute("data-y"),a=t.getAttribute("data-x");return e.options.data[i][a]},getProductIdOfCell(e,t){if("object"==typeof t){let i=t.getAttribute("data-y");return e.options.data[i][0]}return e.options.data[t][0]},ajax(e={}){let t=Object.assign({url:wbeParams.ajaxUrl,type:"post",dataType:"json"},e);t.data.action="vi_wbe_ajax",t.data.vi_wbe_nonce=wbeParams.nonce,t.data.type=wbeParams.editType,s.ajax(t)},pagination(e,t){let i="",a=`<a class="item ${1===(t=parseInt(t))?"disabled":""}" data-page="${t-1}"><i class="icon angle left"> </i></a>`,n=`<a class="item ${t===(e=parseInt(e))?"disabled":""}" data-page="${t+1}"><i class="icon angle right"> </i></a>`,o=`<input type="number" class="vi-wbe-go-to-page" value="${t}" min="1" max="${e}"/>`;for(let a=1;a<=e;a++)[1,t-1,t,t+1,e].includes(a)&&(i+=`<a class="item ${t===a?"active":""}" data-page="${a}">${a}</a>`),a===t-2&&t-2>1&&(i+='<a class="item disabled">...</a>'),a===t+2&&t+2<e&&(i+='<a class="item disabled">...</a>');return`<div class="vi-ui pagination menu">${a} ${i} ${n} </div> ${o}`},spinner:()=>s('<span class="vi-wbe-spinner"><span class="vi-wbe-spinner-inner"> </span></span>'),is_loading(){return!!this._spinner},loading(){this._spinner=this.spinner(),s(".vi-wbe-menu-bar-center").html(this._spinner)},removeLoading(){this._spinner=null,s(".vi-wbe-menu-bar-center").html("")},notice(e,t="black"){let i=s(`<div class="vi-wbe-notice" style="color:${t}">${e}</div>`);s(".vi-wbe-menu-bar-center").html(i),setTimeout((function(){i.remove()}),5e3)},generateCouponCode(){let e="";for(var t=0;t<n.couponGenerate.char_length;t++)e+=n.couponGenerate.characters.charAt(Math.floor(Math.random()*n.couponGenerate.characters.length));return e=n.couponGenerate.prefix+e+n.couponGenerate.suffix,e}},r=jQuery;let c=null;class d{constructor(e,t){c||r("body").on("mousedown keydown",this.mousedown),c=this,this.popup=r(".vi-wbe-context-popup"),this.render(e,r(t))}mousedown(e){let t=r(e.target),i=r(".vi-wbe-context-popup");(27===e.which||!t.hasClass("vi-wbe-context-popup")&&0===t.closest(".vi-wbe-context-popup").length&&i.hasClass("vi-wbe-popup-active")&&!t.hasClass("select2-search__field"))&&(i.empty().removeClass("vi-wbe-popup-active"),r(".select2-container.select2-container--default.select2-container--open").remove())}render(e,t){let{popup:i}=this,a=t.offset(),n=a.left,o=a.top,s=t.innerWidth();i.empty(),i.addClass("vi-wbe-popup-active").html(e);let l=i.innerWidth(),c=i.innerHeight();if(window.innerWidth<n+l+s){let e=n-l>0?n-l:10;i.css("left",e+"px")}else i.css("left",n+s+"px");if(r("#vi-wbe-editor").innerHeight()<o+c){let e=o-c<0?0:o-c;i.css("top",e+"px")}else i.css("top",o+"px")}hide(){this.popup.removeClass("vi-wbe-popup-active")}}const u=jQuery;class p{constructor(e,t,i,a){this._data={},this._data.jexcel=e,this._data.x=parseInt(t),this._data.y=parseInt(i),this.run()}get(e){return this._data[e]||""}run(){let e=this.content(),t=u(`td[data-x=${this.get("x")||0}][data-y=${this.get("y")||0}]`);new d(e,t),e.on("click",".vi-wbe-apply-formula",this.applyFormula.bind(this)),e.on("change",".vi-wbe-rounded",this.toggleDecimalValue)}content(){return u(`<div class="vi-wbe-formula-container" style="display: flex;">\n <select class="vi-wbe-operator">\n <option value="+">+</option>\n <option value="-">-</option>\n </select>\n <input type="number" min="0" class="vi-wbe-value">\n <select class="vi-wbe-unit">\n <option value="fixed">n</option>\n <option value="percentage">%</option>\n </select>\n <select class="vi-wbe-rounded">\n <option value="no_round">${l.text("No round")}</option>\n <option value="round">${l.text("Round with decimal")}</option>\n <option value="round_up">${l.text("Round up")}</option>\n <option value="round_down">${l.text("Round down")}</option>\n </select>\n <input type="number" min="0" max="10" class="vi-wbe-decimal" value="0">\n <button type="button" class="vi-ui button mini vi-wbe-apply-formula">${l.text("OK")}</button>\n </div>`)}applyFormula(e){let t=u(e.target).closest(".vi-wbe-formula-container"),i=t.find(".vi-wbe-operator").val(),a=parseFloat(t.find(".vi-wbe-value").val()),n=t.find(".vi-wbe-unit").val(),o=t.find(".vi-wbe-rounded").val(),s=parseInt(t.find(".vi-wbe-decimal").val()),l=this.get("jexcel");if(!a)return;let r=[],c=l.selectedContainer,d=c[1],p=c[3],h=c[0];function m(e){e=parseFloat(e.replace(",","."));let t="percentage"===n?e*a/100:a,l="-"===i?e-t:e+t;switch(o){case"round":l=l.toFixed(s);break;case"round_up":l=Math.ceil(l);break;case"round_down":l=Math.floor(l)}return l}for(let e=d;e<=p;e++)if(l.records[e][h]&&!l.records[e][h].classList.contains("readonly")&&"none"!==l.records[e][h].style.display){let t=l.options.data[e][h]||0;r.push(l.updateCell(h,e,m(t))),l.updateFormulaChain(h,e,r)}l.setHistory({action:"setValue",records:r,selection:l.selectedCell}),l.updateTable()}toggleDecimalValue(){let e=u(this).closest(".vi-wbe-formula-container");e.find(".vi-wbe-decimal").hide(),"round"===u(this).val()&&e.find(".vi-wbe-decimal").show()}}class h{constructor(e,t,i,a){this._data={},this._data.jexcel=e,this._data.x=parseInt(t),this._data.y=parseInt(i),this.run()}get(e){return this._data[e]||""}run(){let e=this.content(),t=u(`td[data-x=${this.get("x")||0}][data-y=${this.get("y")||0}]`);new d(e,t),e.on("click",".vi-wbe-apply-formula",this.applyFormula.bind(this)),e.on("change",".vi-wbe-rounded",this.toggleDecimalValue)}content(){return u(`<div class="vi-wbe-formula-container" style="display: flex;">\n <span class="vi-wbe-operator vi-ui button basic small icon"><i class="icon minus"> </i></span>\n <input type="number" min="0" class="vi-wbe-value">\n <select class="vi-wbe-unit">\n <option value="percentage">%</option>\n <option value="fixed">n</option>\n </select>\n <select class="vi-wbe-rounded">\n <option value="no_round">${l.text("No round")}</option>\n <option value="round">${l.text("Round with decimal")}</option>\n <option value="round_up">${l.text("Round up")}</option>\n <option value="round_down">${l.text("Round down")}</option>\n </select>\n <input type="number" min="0" max="10" class="vi-wbe-decimal" value="0">\n <button type="button" class="vi-ui button mini vi-wbe-apply-formula">${l.text("OK")}</button>\n </div>`)}applyFormula(e){let t=u(e.target).closest(".vi-wbe-formula-container"),i=parseFloat(t.find(".vi-wbe-value").val()),a=t.find(".vi-wbe-unit").val(),n=t.find(".vi-wbe-rounded").val(),o=parseInt(t.find(".vi-wbe-decimal").val()),s=this.get("jexcel");if(!i)return;let l=[],r=s.selectedContainer,c=r[1],d=r[3],p=r[0];function h(e){let t=(e=parseFloat(e.replace(",",".")))-("percentage"===a?e*i/100:i);switch(t=t>0?t:0,n){case"round":t=t.toFixed(o);break;case"round_up":t=Math.ceil(t);break;case"round_down":t=Math.floor(t)}return t}for(let e=c;e<=d;e++)if(s.records[e][p]&&!s.records[e][p].classList.contains("readonly")&&"none"!==s.records[e][p].style.display){let t=s.options.data[e][p-1]||0;l.push(s.updateCell(p,e,h(t))),s.updateFormulaChain(p,e,l)}s.setHistory({action:"setValue",records:l,selection:s.selectedCell}),s.updateTable()}toggleDecimalValue(){let e=u(this).closest(".vi-wbe-formula-container");e.find(".vi-wbe-decimal").hide(),"round"===u(this).val()&&e.find(".vi-wbe-decimal").show()}}const m=jQuery,b={init(){return m(".vi-ui.menu .item").vi_tab(),m(".bulky-sort-fields-accordion").vi_accordion(),m("#bulky-sort-fields").sortable({axis:"y",containment:"parent"}),this.revision={},this.sidebar=m("#vi-wbe-sidebar"),this.historyBodyTable=m("#vi-wbe-history-points-list tbody"),this.sidebar.on("click",".vi-wbe-apply-filter",this.applyFilter.bind(this)),this.sidebar.on("click",".vi-wbe-filter-label",this.filterInputLabelFocus),this.sidebar.on("focus",".vi-wbe-filter-input",this.filterInputFocus),this.sidebar.on("blur",".vi-wbe-filter-input",this.filterInputBlur),this.sidebar.on("click",".vi-wbe-get-meta-fields",this.getMetaFields.bind(this)),this.sidebar.on("click",".vi-wbe-save-meta-fields:not(.loading)",this.saveMetaFields.bind(this)),this.sidebar.on("click",".vi-wbe-add-new-meta-field",this.addNewMetaField.bind(this)),this.sidebar.find("table.vi-wbe-meta-fields-container tbody").sortable({axis:"y"}),this.sidebar.find("table.vi-wbe-meta-fields-container").on("click",".vi-wbe-remove-meta-row",this.removeMetaRow),this.sidebar.on("click",".vi-wbe-save-taxonomy-fields:not(.loading)",this.saveTaxonomyFields),this.sidebar.on("click",".vi-wbe-save-settings",this.saveSettings.bind(this)),this.sidebar.on("click",".vi-wbe-view-history-point",this.viewHistoryPoint.bind(this)),this.sidebar.on("click",".vi-wbe-recover",this.recover.bind(this)),this.sidebar.on("click",".vi-wbe-revert-this-point",this.revertAllProducts.bind(this)),this.sidebar.on("click",".vi-wbe-revert-this-key",this.revertProductAttribute.bind(this)),this.sidebar.on("click",".vi-wbe-pagination a.item",this.changePage.bind(this)),this.sidebar.on("change",".vi-wbe-go-to-page",this.changePageByInput.bind(this)),this.sidebar.on("click",".vi-wbe-multi-select-clear",this.clearMultiSelect),this.sidebar.on("change",".vi-wbe-meta-column-type",this.metaFieldChangeType),this.sidebar.on("keyup",".vi-wbe-search-metakey",this.searchMetaKey),this.filter(),this.settings(),this.metafields(),this.history(),this.sidebar},filter(){let e=m("#vi-wbe-products-filter"),t=m(".vi-wbe-filter-input"),i={top:-2},a={top:"50%"};t.each(((e,t)=>{m(t).val()&&m(t).parent().prev().css(i)})),t.on("focus",(function(){let e=m(this).prev();e.css(i),m(this).on("blur",(function(){m(this).val()||e.css(a)}))})),this.sidebar.on("click",".vi-wbe-filter-label",(function(){m(this).next().trigger("focus")}));let n=e.find(".vi-wbe.vi-ui.dropdown").dropdown({clearable:!0}),o=e.find(".vi-ui.compact.dropdown").dropdown();this.sidebar.on("click",".vi-wbe-clear-filter",(function(){m(".vi-wbe-filter-label").css(a),t.val(""),n.dropdown("clear"),o.find(".menu .item:first").trigger("click")})),this.sidebar.on("change","#vi-wbe-has_expire_date",(function(){let e=m(".vi-wbe-expire-date-group");"yes"===m(this).val()?e.show():e.hide()})),this.sidebar.find("#vi-wbe-has_expire_date").trigger("change")},settings(){m(".vi-wbe-settings-tab").find("select.dropdown").dropdown()},metafields(){this.renderMetaFieldsTable(n.metaFields)},history(){this.pagination(1)},pagination(e,t=n.historyPages){this.sidebar.find(".vi-wbe-pagination").html(l.pagination(t,e))},applyFilter(e){let t=this,i=m(e.target);i.hasClass("loading")||l.ajax({data:{sub_action:"add_filter_data",filter_data:m("#vi-wbe-products-filter").serialize(),filter_key:n.filterKey},beforeSend(){i.addClass("loading")},success(e){i.removeClass("loading"),t.sidebar.trigger("afterAddFilter",[e.data])}})},limitProductPerPage(){let e=m(this).val();e>50&&m(this).val(50),e<0&&m(this).val(0)},saveSettings(e){let t=this,i=m(e.target);i.hasClass("loading")||l.ajax({data:{sub_action:"save_settings",fields:m("form.vi-wbe-settings-tab").serialize()},beforeSend(){i.addClass("loading")},success(e){e.success&&(n.settings=e.data.settings,t.sidebar.trigger("afterSaveSettings",[e.data])),i.removeClass("loading")}})},filterInputLabelFocus(){m(this).next().find("input").trigger("focus")},filterInputFocus(){m(this).parent().prev().css({top:-2})},filterInputBlur(){m(this).val()||m(this).parent().prev().css({top:"50%"})},getMetaFields(e){let t=this,i=m(e.target);i.hasClass("loading")||l.ajax({data:{sub_action:"get_meta_fields",current_meta_fields:t.getCurrentMetaFields()},beforeSend(){i.addClass("loading")},success(e){t.renderMetaFieldsTable(e.data),n.metaFields=e.data,i.removeClass("loading")}})},renderMetaFieldsTable(e){let t="";for(let i in e)t+=this.renderRow(i,e);m(".vi-wbe-meta-fields-container tbody").html(t)},renderRow(e,t){let i=t[e]||{},a="",n=i.input_type||"",o={textinput:"Text input",texteditor:"Text editor",numberinput:"Number input",array:"Array",json:"JSON",checkbox:"Checkbox",calendar:"Calendar",image:"Image",select:"Select",multiselect:"Multiselect"},s=i.meta_value||"",l=s.slice(0,15),r=s.length>16?`<div class="vi-wbe-full-meta-value">${s}</div>`:"",c="";for(let e in o)a+=`<option value="${e}" ${e===n?"selected":""}>${o[e]}</option>`;return l+=l.length<s.length?"...":"","select"!==n&&"multiselect"!==n||(c+=`<textarea class="vi-wbe-select-options">${i.select_options}</textarea>`),`<tr>\n <td class="vi-wbe-meta-key">${e}</td>\n <td><input type="text" class="vi-wbe-meta-column-name" value="${i.column_name||""}"></td>\n <td>\n <div class="vi-wbe-display-meta-value">\n <div class="vi-wbe-short-meta-value">${l}</div>\n ${r}\n </div>\n </td>\n <td>\n <select class="vi-wbe-meta-column-type">${a}</select>\n ${c}\n </td>\n <td class="vi-wbe-meta-field-active-column">\n <div class="vi-ui toggle checkbox">\n <input type="checkbox" class="vi-wbe-meta-column-active" ${parseInt(i.active)?"checked":""}>\n <label> </label>\n </div> \n </td>\n <td>\n <div class="vi-wbe-meta-field-actions">\n <span class="vi-ui button basic mini vi-wbe-remove-meta-row"><i class="icon trash"> </i></span>\n <span class="vi-ui button basic mini"><i class="icon move"> </i></span>\n </div>\n </td>\n </tr>`},metaFieldChangeType(){let e=m('<textarea class="vi-wbe-select-options"></textarea>'),t=m(this).val(),i=m(this).siblings();"select"===t||"multiselect"===t?i.length||m(this).after(e):i.remove()},searchMetaKey(){let e=m(this).val().toLowerCase();m(".vi-wbe-meta-fields-container tbody tr").each((function(t,i){m(i).find(".vi-wbe-meta-key").text().trim().toLowerCase().indexOf(e)>-1?m(i).show():m(i).hide()}))},saveMetaFields(e){let t=m(e.target);t.hasClass("loading")||l.ajax({data:{sub_action:"save_meta_fields",meta_fields:this.getCurrentMetaFields()},beforeSend(){t.addClass("loading")},success(e){t.removeClass("loading"),location.reload()},error(e){console.log(e)}})},getCurrentMetaFields(){let e={},t=n.metaFields;return m("table.vi-wbe-meta-fields-container tbody tr").each((function(i,a){let n=m(a).find(".vi-wbe-meta-key").text();e[n]={column_name:m(a).find(".vi-wbe-meta-column-name").val(),input_type:m(a).find(".vi-wbe-meta-column-type").val(),active:m(a).find(".vi-wbe-meta-column-active:checked").length,meta_value:t[n]?t[n].meta_value:"",select_options:m(a).find(".vi-wbe-select-options").val()}})),e},addNewMetaField(e){let t=m(e.currentTarget).prev(),i=t.val(),a=i.match(/^[\w\d_-]*$/g);if(!i||!a||n.metaFields[i])return;let o=this.renderRow(i,{});o&&(t.val(""),m("table.vi-wbe-meta-fields-container tbody").append(o))},removeMetaRow(){m(this).closest("tr").remove()},saveTaxonomyFields(e){let t=m(e.target),i=[];m("table.vi-wbe-taxonomy-fields .vi-wbe-taxonomy-active:checked").each((function(e,t){let a=m(this).closest("tr").find(".vi-wbe-taxonomy-key").text();i.push(a)})),l.ajax({data:{sub_action:"save_taxonomy_fields",taxonomy_fields:i},beforeSend(){t.addClass("loading")},success(e){t.removeClass("loading"),location.reload()},error(e){console.log(e)}})},viewHistoryPoint(e){let t=m(e.currentTarget),i=t.data("id"),a=this;t.hasClass("loading")||l.ajax({data:{sub_action:"view_history_point",id:i},beforeSend(){t.addClass("loading")},complete(){},success(e){if(t.removeClass("loading"),e.success&&e.data){let t=e.data.compare,n="";for(let e in t){let i=t[e];n+=`<div class="vi-wbe-history-product" data-product_id="${e}">\n <div class="title">\n <i class="dropdown icon"></i>\n ${i.name}\n <span class="vi-ui button mini basic vi-wbe-revert-this-product">\n <i class="icon undo"> </i>\n </span>\n \n </div>`;let a="";for(let t in i.fields){let n="string"==typeof i.current[t]?i.current[t]:JSON.stringify(i.current[t]),o="string"==typeof i.history[t]?i.history[t]:JSON.stringify(i.history[t]);a+=`<tr>\n <td>${i.fields[t]}</td>\n <td>${n}</td>\n <td>${o}</td>\n <td class="">\n <span class="vi-ui button basic mini vi-wbe-revert-this-key" data-product_id="${e}" data-product_key="${t}">\n <i class="icon undo"> </i>\n </span>\n </td>\n </tr>`}a=`<table id="vi-wbe-history-point-detail" class="vi-ui celled table">\n <thead>\n <tr>\n <th>Attribute</th>\n <th>Current</th>\n <th>History</th>\n <th class="">Revert</th>\n </tr>\n </thead>\n <tbody>\n ${a}\n </tbody>\n </table>`,n+=`<div class="content">${a}</div></div>`}n=m(`<div class="vi-ui styled fluid accordion">${n}</div>`),m(".vi-wbe-history-review").html(n).attr("data-history_id",i).prepend(`<h4>History point: ${e.data.date}</h4>`).append(`<div class="vi-ui button tiny vi-wbe-revert-this-point">\n ${l.text("Revert all product in this point")}\n </div>\n <p> ${l.text("The current value is the value of the records in database")}</p>`),n.find(".title").on("click",(e=>a.revertSingleProduct(e))),n.vi_accordion(),n.find(".title:first").trigger("click")}}})},recover(e){let t=m(e.currentTarget),i=t.data("id");t.hasClass("loading")||l.ajax({data:{sub_action:"revert_history_all_products",history_id:i},beforeSend(){t.addClass("loading")},complete(){t.removeClass("loading")},success(e){console.log(e)}})},revertSingleProduct(e){let t;if(m(e.target).hasClass("vi-wbe-revert-this-product")&&(t=m(e.target)),m(e.target).parent().hasClass("vi-wbe-revert-this-product")&&(t=m(e.target).parent()),t){e.stopImmediatePropagation();let i=t.closest(".vi-wbe-history-product").data("product_id"),a=t.closest(".vi-wbe-history-review").data("history_id");if(t.hasClass("loading"))return;l.ajax({data:{sub_action:"revert_history_single_product",history_id:a,pid:i},beforeSend(){t.addClass("loading")},complete(){t.removeClass("loading")},success(e){console.log(e)}})}},revertAllProducts(e){let t=m(e.target),i=t.closest(".vi-wbe-history-review").data("history_id");t.hasClass("loading")||l.ajax({data:{sub_action:"revert_history_all_products",history_id:i},beforeSend(){t.addClass("loading")},complete(){t.removeClass("loading")},success(e){console.log(e)}})},revertProductAttribute(e){let t=m(e.currentTarget),i=t.data("product_key"),a=t.closest(".vi-wbe-history-product").data("product_id"),n=t.closest(".vi-wbe-history-review").data("history_id");t.hasClass("loading")||l.ajax({data:{sub_action:"revert_history_product_attribute",attribute:i,history_id:n,pid:a},beforeSend(){t.addClass("loading")},complete(){t.removeClass("loading")},success(e){console.log(e)}})},changePage(e){let t=parseInt(m(e.currentTarget).attr("data-page"));m(e.currentTarget).hasClass("active")||m(e.currentTarget).hasClass("disabled")||!t||this.loadHistoryPage(t)},changePageByInput(e){let t=parseInt(m(e.target).val());t<=parseInt(m(e.target).attr("max"))&&t>0&&this.loadHistoryPage(t)},clearMultiSelect(){m(this).parent().find(".vi-ui.dropdown").dropdown("clear")},loadHistoryPage(e){let t=l.spinner(),i=this;e&&l.ajax({dataType:"text",data:{sub_action:"load_history_page",page:e},beforeSend(){i.sidebar.find(".vi-wbe-pagination").prepend(t)},complete(){t.remove()},success(t){i.pagination(e),m("#vi-wbe-history-points-list tbody").html(t)}})}},f=jQuery;class v{constructor(e,t,i,a){this._data={},this._data.jexcel=e,this._data.x=parseInt(t),this._data.y=parseInt(i),this.run()}get(e){return this._data[e]||""}run(){let e=this.content(),t=f(`td[data-x=${this.get("x")||0}][data-y=${this.get("y")||0}]`);new d(e,t),e.on("click",".vi-wbe-apply-formula",this.applyFormula.bind(this))}content(){return f(`<div class="vi-wbe-formula-container">\n <div class="field">\n <input type="text" placeholder="${l.text("Find")}" class="vi-wbe-find-string">\n </div>\n <div class="field">\n <input type="text" placeholder="${l.text("Replace")}" class="vi-wbe-replace-string">\n </div>\n <button type="button" class="vi-ui button mini vi-wbe-apply-formula">${l.text("Replace")}</button>\n </div>`)}applyFormula(e){let t=f(e.target).closest(".vi-wbe-formula-container"),i=t.find(".vi-wbe-find-string").val(),a=t.find(".vi-wbe-replace-string").val(),n=this.get("jexcel");if(!i)return;let o=[],s=n.selectedContainer,l=s[1],r=s[3],c=s[0];for(let e=l;e<=r;e++)if(n.records[e][c]&&!n.records[e][c].classList.contains("readonly")&&"none"!==n.records[e][c].style.display){let t=n.options.data[e][c].replaceAll(i,a);o.push(n.updateCell(c,e,t)),n.updateFormulaChain(c,e,o)}n.setHistory({action:"setValue",records:o,selection:n.selectedCell}),n.updateTable()}}const g=jQuery;class w{constructor(e,t,i,a,n){this._data={},this._data.jexcel=e,this._data.x=parseInt(t),this._data.y=parseInt(i),this._wordWrap=n,this.run()}get(e){return this._data[e]||""}run(){let e=this.content(),t=g(`td[data-x=${this.get("x")||0}][data-y=${this.get("y")||0}]`);new d(e,t),e.on("click",".vi-wbe-apply-formula",this.applyFormula.bind(this))}content(){let e=this._wordWrap?'<textarea class="vi-wbe-text-input" rows="3"></textarea>':`<input type="text" placeholder="${l.text("Content")}" class="vi-wbe-text-input">`;return g(`<div class="vi-wbe-formula-container">\n <div class="field">\n ${e}\n </div>\n <button type="button" class="vi-ui button mini vi-wbe-apply-formula">${l.text("Save")}</button>\n </div>`)}applyFormula(e){let t=g(e.target).closest(".vi-wbe-formula-container").find(".vi-wbe-text-input").val(),i=this.get("jexcel"),a=[],n=i.selectedContainer,o=n[1],s=n[3],l=n[0];for(let e=o;e<=s;e++)i.records[e][l]&&!i.records[e][l].classList.contains("readonly")&&"none"!==i.records[e][l].style.display&&(a.push(i.updateCell(l,e,t)),i.updateFormulaChain(l,e,a));i.setHistory({action:"setValue",records:a,selection:i.selectedCell}),i.updateTable()}}const y=jQuery;class x{constructor(e,t,i,a,n){this.cells=t,this.obj=e,this.x=parseInt(i),this.y=parseInt(a),this.searchData=[],this.run()}run(){let e=this,t=this.content(),i=this.cells[1],a=this.cells[3],o=[{id:"",text:""}];for(let e=i;e<=a;e++){let t=this.obj.options.data[e][this.x];o.push(...t)}o=o.filter(((e,t,i)=>t===i.findIndex((t=>t.id===e.id&&t.text===e.text))));let s=y(`td[data-x=${this.x||0}][data-y=${this.y||0}]`);new d(t,s),t.find(".vi-wbe-find-string").select2({data:o}),t.find(".vi-wbe-replace-string").select2({multiple:!1,minimumInputLength:3,ajax:{url:n.ajaxUrl,type:"post",data:function(e){return{...n.ajaxData,sub_action:"search_tags",search:e.term,type:"public"}},processResults:function(t){return e.searchData=t,{results:t}}}}),t.on("click",".vi-wbe-apply-formula",this.applyFormula.bind(this))}content(){return y(`<div class="vi-wbe-formula-container">\n <div class="field">\n <div>${l.text("Find")}</div>\n <select placeholder="" class="vi-wbe-find-string"> </select>\n </div>\n <div class="field">\n <div>${l.text("Replace")}</div>\n <select placeholder="" class="vi-wbe-replace-string"> </select>\n </div>\n <button type="button" class="vi-ui button mini vi-wbe-apply-formula">${l.text("Replace")}</button>\n <p>If 'Find' value is empty, add to selected cells with 'Replace' value.</p>\n <p>If 'Replace' value is empty, remove from selected cells with 'Find' value.</p>\n </div>`)}applyFormula(e){let t=y(e.target).closest(".vi-wbe-formula-container"),i=t.find(".vi-wbe-find-string").val(),a=t.find(".vi-wbe-replace-string").val(),n=this.obj;if(!i&&!a)return;let o=this.searchData.filter((e=>e.id===+a)),s=[],l=this.cells,r=l[1],c=l[3],d=l[0];for(let e=r;e<=c;e++)if(n.records[e][d]&&!n.records[e][d].classList.contains("readonly")&&"none"!==n.records[e][d].style.display){let t=n.options.data[e][d];t||(t=[]);let a=t.filter((e=>e.id!==+i));t.length===a.length&&i||a.push(...o),a=a.filter(((e,t,i)=>t===i.findIndex((t=>t.id===e.id&&t.text===e.text)))),s.push(n.updateCell(d,e,a)),n.updateFormulaChain(d,e,s)}n.setHistory({action:"setValue",records:s,selection:n.selectedCell}),n.updateTable()}}const _=jQuery;class C{constructor(e,t,i,a,n){this.cells=t,this.obj=e,this.x=parseInt(i),this.y=parseInt(a),this.searchData=[],this.source=e.options.columns[i].source||[],this.run()}run(){let e=this.content(),t=_(`td[data-x=${this.x||0}][data-y=${this.y||0}]`);new d(e,t),e.find(".vi-wbe-find-string").select2({data:[{id:"",text:""},...this.source]}),e.find(".vi-wbe-replace-string").select2({data:[{id:"",text:""},...this.source]}),e.on("click",".vi-wbe-apply-formula",this.applyFormula.bind(this))}content(){return _(`<div class="vi-wbe-formula-container">\n <div class="field">\n <div>${l.text("Find")}</div>\n <select placeholder="" class="vi-wbe-find-string"> </select>\n </div>\n <div class="field">\n <div>${l.text("Replace")}</div>\n <select placeholder="" class="vi-wbe-replace-string"> </select>\n </div>\n <button type="button" class="vi-ui button mini vi-wbe-apply-formula">${l.text("Replace")}</button>\n <p>If 'Find' value is empty, add to selected cells with 'Replace' value.</p>\n <p>If 'Replace' value is empty, remove from selected cells with 'Find' value.</p>\n </div>`)}applyFormula(e){let t=_(e.target).closest(".vi-wbe-formula-container"),i=t.find(".vi-wbe-find-string").val(),a=t.find(".vi-wbe-replace-string").val(),n=this.obj;if(!i&&!a)return;i=isNaN(i)?i:+i,a=isNaN(a)?a:+a;let o=[],s=this.cells,l=s[1],r=s[3],c=s[0];for(let e=l;e<=r;e++)if(n.records[e][c]&&!n.records[e][c].classList.contains("readonly")&&"none"!==n.records[e][c].style.display){let t=n.options.data[e][c];t||(t=[]);let s=t.filter((e=>e!==i));t.length===s.length&&i||s.push(a),s=[...new Set(s)],o.push(n.updateCell(c,e,s)),n.updateFormulaChain(c,e,o)}n.setHistory({action:"setValue",records:o,selection:n.selectedCell}),n.updateTable()}}class k{constructor(e,t,i,a,n){this.cells=t,this.obj=e,this.x=parseInt(i),this.y=parseInt(a),this.run()}run(){let e=this;const t=wp.media({multiple:!0});t.open().off("select close").on("select",(function(i){t.state().get("selection").each((function(t){if("image"===(t=t.toJSON()).type){let i=t.id;n.imgStorage[i]=t.url,e.addImage(i)}}))}))}addImage(e){let t=this.obj,i=[],a=this.cells,n=a[1],o=a[3],s=a[0];for(let a=n;a<=o;a++)if(t.records[a][s]&&!t.records[a][s].classList.contains("readonly")&&"none"!==t.records[a][s].style.display){let n=t.options.data[a][s];n||(n=[]);let o=[...new Set(n)];o.push(e),i.push(t.updateCell(s,a,o)),t.updateFormulaChain(s,a,i)}t.setHistory({action:"setValue",records:i,selection:t.selectedCell}),t.updateTable()}}const T=jQuery;class A{constructor(e,t,i,a,n){this.cells=t,this.obj=e,this.x=parseInt(i),this.y=parseInt(a),this.run()}run(){let e=T(`td[data-x=${this.x||0}][data-y=${this.y||0}]`),t=this,i=l.createModal({header:l.text("Attributes"),content:"",actions:[{class:"save-attributes",text:l.text("Apply")}]});this.content(i),T(e).append(i),i.on("click",(function(e){let a=T(e.target);(a.hasClass("close")||a.hasClass("vi-wbe-modal-container"))&&i.remove(),a.hasClass("save-attributes")&&t.addAttributes(i)}))}addImage(e){let t=this.obj,i=[],a=this.cells,n=a[1],o=a[3],s=a[0];for(let a=n;a<=o;a++)if(t.records[a][s]&&!t.records[a][s].classList.contains("readonly")&&"none"!==t.records[a][s].style.display){let n=t.options.data[a][s];n||(n=[]);let o=[...new Set(n)];o.push(e),i.push(t.updateCell(s,a,o)),t.updateFormulaChain(s,a,i)}t.setHistory({action:"setValue",records:i,selection:t.selectedCell}),t.updateTable()}addAttributes(e){let t=[],i=e.find(".vi-wbe-add-attributes-option").val();if(e.find(".vi-wbe-attribute-row").each((function(e,i){let a=T(i).data("attr");if(a.is_taxonomy)a.options=T(i).find("select").val().map(Number);else{a.name=T(i).find("input.custom-attr-name").val();let e=T(i).find("textarea.custom-attr-val").val();a.value=e.trim().replace(/\s+/g," "),a.options=e.split("|").map((e=>e.trim().replace(/\s+/g," ")))}a.visible=!!T(i).find(".attr-visibility:checked").length,a.variation=!!T(i).find(".attr-variation:checked").length,a.position=e,t.push(a)})),console.log(t),t.length){let e=this.obj,a=!1,n=[],o=this.cells,s=o[1],l=o[3],r=o[0];const c=(e=[],t)=>{if(e.length)for(let i in e)if(e[i].name===t)return i;return!1};for(let o=s;o<=l;o++)if(e.records[o][r]&&!e.records[o][r].classList.contains("readonly")&&"none"!==e.records[o][r].style.display&&!1===a){let a=e.options.data[o][r];a||(a=[]);let s=[...new Set(a)],l=0;for(let e of t){let t=c(s,e.name);if(!1===t)e.position=s.length+l++,s.push(e);else switch(i){case"replace":e.position=s[t].position,s[t]=e;break;case"merge_terms":let i=[...s[t].options||[],...e.options||[]];s[t].options=[...new Set(i)]}}n.push(e.updateCell(r,o,s)),e.updateFormulaChain(r,o,n)}e.setHistory({action:"setValue",records:n,selection:e.selectedCell}),e.updateTable()}e.remove()}content(e){let t=this,i="",{attributes:a}=n,o=`<option value="">${l.text("Custom product attribute")}</option>`;for(let e in a)o+=`<option value="${e}">${a[e].data.attribute_label}</option>`;o=`<div class="vi-wbe-taxonomy-header">\n <select class="vi-wbe-select-taxonomy">${o}</select>\n <span class="vi-ui button tiny vi-wbe-add-taxonomy">${l.text("Add")}</span>\n </div>`,i=`${o}\n <table class="vi-ui celled table">\n <thead>\n <tr>\n <th>Name</th>\n <th>Attributes</th>\n <th width="1">Actions</th>\n </tr>\n </thead>\n <tbody>${i}</tbody>\n </table>`,e.find(".content").append(i),e.find(".actions").append('<div>\n <div class="vi-wbe-add-attributes-option-label">\n Select action if exist attribute in product\n </div>\n <select class="vi-wbe-add-attributes-option">\n <option value="none">Don\'t add</option>\n <option value="replace">Replace existed attribute</option>\n <option value="merge_terms">Merge terms</option>\n </select>\n </div>'),e.find("table select").select2({multiple:!0}),e.find("tbody").sortable({items:"tr",cursor:"move",axis:"y",scrollSensitivity:40,forcePlaceholderSize:!0,helper:"clone",handle:".icon.move"});const s=()=>{e.find("select.vi-wbe-select-taxonomy option").removeAttr("disabled"),e.find("input[type=hidden]").each((function(t,i){let a=T(i).val();e.find(`select.vi-wbe-select-taxonomy option[value='${a}']`).attr("disabled","disabled")}))};s(),e.on("click",(function(i){let a=T(i.target);if(a.hasClass("trash")&&(a.closest("tr").remove(),s()),a.hasClass("vi-wbe-add-taxonomy")){let i=T(".vi-wbe-select-taxonomy"),a=i.val(),n={name:a,options:[]};a&&(n.is_taxonomy=1);let o=T(t.createRowTable(n));e.find("table tbody").append(o),o.find("select").select2({multiple:!0}),s(),i.val("").trigger("change")}if(a.hasClass("vi-wbe-select-all-attributes")){let e=a.closest("td").find("select");e.find("option").attr("selected",!0),e.trigger("change")}if(a.hasClass("vi-wbe-select-no-attributes")){let e=a.closest("td").find("select");e.find("option").attr("selected",!1),e.trigger("change")}if(a.hasClass("vi-wbe-add-new-attribute")){let e=prompt(l.text("Enter a name for the new attribute term:"));if(!e)return;let t=a.closest("tr.vi-wbe-attribute-row"),i=t.attr("data-attr");i&&(i=JSON.parse(i),l.ajax({data:{sub_action:"add_new_attribute",taxonomy:i.name,term:e},beforeSend(){a.addClass("loading")},success(e){if(a.removeClass("loading"),e.success){let a=t.find("select");a.append(`<option value="${e.data.term_id}" selected>${e.data.name}</option>`),a.trigger("change"),n.attributes[i.name].terms[e.data.term_id]={slug:e.data.slug,text:e.data.name}}else alert(e.data.message)}}))}}))}createRowTable(e){let t="",i="";if(e.is_taxonomy){let a=n.attributes[e.name],o=a.terms||[],s="";if(t=`${a.data.attribute_label}<input type="hidden" value="${e.name}"/>`,Object.keys(o).length)for(let t in o)s+=`<option value="${t}" ${e.options.includes(parseInt(t))?"selected":""}>${o[t].text}</option>`;i=`<select multiple>${s}</select>\n <div class="vi-wbe-attributes-button-group">\n <span class="vi-ui button mini vi-wbe-select-all-attributes">${l.text("Select all")}</span>\n <span class="vi-ui button mini vi-wbe-select-no-attributes">${l.text("Select none")}</span>\n <span class="vi-ui button mini vi-wbe-add-new-attribute">${l.text("Add new")}</span>\n </div>`}else t=`<input type="text" class="custom-attr-name" value="${e.name}" placeholder="${l.text("Custom attribute name")}"/>`,i=`<textarea class="custom-attr-val" placeholder="${l.text('Enter some text, or some attributes by "|" separating values.')}">${e.value||""}</textarea>`;return t=`<div class="vi-wbe-attribute-name-label">${t}</div>`,t+=`<div>\n <input type="checkbox" class="attr-visibility" ${e.visible?"checked":""} value="1">\n <label>${l.text("Visible on the product page")}</label>\n </div>`,t+=`<div>\n <input type="checkbox" class="attr-variation" ${e.variation?"checked":""} value="1">\n <label>${l.text("Used for variations (apply for variable)")}</label>\n </div>`,`<tr class="vi-wbe-attribute-row" data-attr='${JSON.stringify(e)}'>\n <td class="vi-wbe-left">${t}</td>\n <td>${i}</td>\n <td class="vi-wbe-right"><i class="icon trash"> </i> <i class="icon move"> </i></td>\n </tr>`}}const $=jQuery;class E{constructor(e,t,i,a,n){this.cells=t,this.obj=e,this.x=parseInt(i),this.y=parseInt(a),this.run()}run(){let e=$(`td[data-x=${this.x||0}][data-y=${this.y||0}]`),t=this,i=l.createModal({header:l.text("Remove attributes"),content:"",actions:[{class:"save-attributes",text:l.text("Apply")}]});this.content(i),$(e).append(i),i.on("click",(function(e){let a=$(e.target);(a.hasClass("close")||a.hasClass("vi-wbe-modal-container"))&&i.remove(),a.hasClass("save-attributes")&&t.removeAttributes(i)}))}removeAttributes(e){let t=e.find(".vi-wbe-select-taxonomy").dropdown("get values");if(t.length){let e=this.obj,i=!1,a=[],n=this.cells,o=n[1],s=n[3],l=n[0];for(let n=o;n<=s;n++)if(e.records[n][l]&&!e.records[n][l].classList.contains("readonly")&&"none"!==e.records[n][l].style.display&&!1===i){let i=e.options.data[n][l];if(!i||!Array.isArray(i))continue;let o=i.filter((e=>!t.includes(e.name)));a.push(e.updateCell(l,n,o)),e.updateFormulaChain(l,n,a)}e.setHistory({action:"setValue",records:a,selection:e.selectedCell}),e.updateTable()}e.remove()}content(e){let{attributes:t}=n,i=`<option value="">${l.text("Select attributes to remove")}</option>`;for(let e in t)i+=`<option value="${e}">${t[e].data.attribute_label}</option>`;let a=`<div class="vi-wbe-taxonomy-header">\n <select class="vi-wbe-select-taxonomy fluid vi-ui selection" multiple>${i}</select>\n </div>`;e.find(".content").append(a),e.find("table select").select2({multiple:!0}),e.find("tbody").sortable({items:"tr",cursor:"move",axis:"y",scrollSensitivity:40,forcePlaceholderSize:!0,helper:"clone",handle:".icon.move"}),e.find(".vi-wbe-select-taxonomy").dropdown()}}var S=i(744);jQuery(document).ready((function(e){new class{constructor(){this.sidebar=b.init(),this.compare=[],this.trash=[],this.unTrash=[],this.revision={},this.isAdding=!1,this.editor=e("#vi-wbe-container"),this.menubar=e("#vi-wbe-menu-bar"),this.menubar.on("click",".vi-wbe-open-sidebar",this.openMenu.bind(this)),this.menubar.on("click","a.item:not(.vi-wbe-open-sidebar)",this.closeMenu.bind(this)),this.menubar.on("click",".vi-wbe-new-products",this.addNewProduct.bind(this)),this.menubar.on("click",".vi-wbe-new-coupons",this.addNewCoupon.bind(this)),this.menubar.on("click",".vi-wbe-new-orders",this.addNewOrder.bind(this)),this.menubar.on("click",".vi-wbe-full-screen-btn",this.toggleFullScreen.bind(this)),this.menubar.on("click",".vi-wbe-save-button",this.save.bind(this)),this.menubar.on("click",".vi-wbe-pagination a.item",this.changePage.bind(this)),this.menubar.on("click",".vi-wbe-get-product",this.reloadCurrentPage.bind(this)),this.menubar.on("change",".vi-wbe-go-to-page",this.changePageByInput.bind(this)),this.editor.on("cellonchange","tr",this.cellOnChange.bind(this)),this.editor.on("click",".jexcel_content",this.removeExistingEditor.bind(this)),this.editor.on("dblclick",this.removeContextPopup),this.sidebar.on("afterAddFilter",this.afterAddFilter.bind(this)),this.sidebar.on("afterSaveSettings",this.afterSaveSettings.bind(this)),this.sidebar.on("click",".vi-wbe-close-sidebar",this.closeMenu.bind(this)),this.init(),e(document).on("keydown",this.keyDownControl.bind(this)),e(document).on("keyup",this.keyUpControl.bind(this))}removeExistingEditor(e){e.target===e.currentTarget&&this.WorkBook&&this.WorkBook.edition&&this.WorkBook.closeEditor(this.WorkBook.edition[0],!0)}keyDownControl(e){switch(!e.ctrlKey&&!e.metaKey||e.shiftKey||83===e.which&&(e.preventDefault(),this.save()),e.which){case 27:this.sidebar.removeClass("vi-wbe-open")}}keyUpControl(e){if(e.target&&!e.target.getAttribute("readonly")){let t=e.target.getAttribute("data-currency");if(t){let i=e.target.value;if(i)if(i.indexOf(t)<1){let t=i.match(/\d/g);e.target.value=t?t.join(""):""}else{let a,n=i.split(t),o="";a=n[0].match(/[\d]/g).join(""),n[1]&&(o=n[1].match(/[\d]/g),o=o?o.join(""):""),e.target.value=o?`${a}${t}${o}`:`${a}${t}`}}}}removeContextPopup(){e(".vi-wbe-context-popup").removeClass("vi-wbe-popup-active")}init(){wbeParams.columns&&n.setColumns(wbeParams.columns),this.pagination(1,1),this.workBookInit(),this.loadProducts(),l.setJexcel(this.WorkBook)}cellOnChange(t,i){let{col:a=""}=i;if(!a)return;let o=n.idMapping[a],s=e(t.target);switch(o){case"product_type":s.find("td").each((function(t,i){let a=e(i).data("x");a&&0!==a&&1!==a&&e(i).removeClass("readonly")}));let t=n.cellDependType[i.value];Array.isArray(t)&&t.forEach((function(e){let t=n.idMappingFlip[e];s.find(`td[data-x='${t}']`).addClass("readonly")}));break;case"post_date":let a=i.value,o=l.getColFromColumnType("status"),r=s.find(`td[data-x='${o}']`).get(0),c=new Date(a).getTime()>Date.now()?"future":"publish";this.WorkBook.setValue(r,c)}}workBookInit(){let t,i=this,a=0,o=l.text("Delete rows with selected cells"),s=null,r=null;function c(e,t){let i=[],a=e.selectedContainer,n=a[1],o=a[3],s=a[0];for(let a=n;a<=o;a++)e.records[a][s]&&!e.records[a][s].classList.contains("readonly")&&"none"!==e.records[a][s].style.display&&(i.push(e.updateCell(s,a,t)),e.updateFormulaChain(s,a,i));e.setHistory({action:"setValue",records:i,selection:e.selectedCell}),e.updateTable()}switch(n.editType){case"products":o=`${l.text("Delete rows with selected cells")} \n <span class="vi-wbe-context-menu-note">\n (${l.text("Variations cannot revert after save")})\n </span>`,s=function(t,i){let a=l.getProductTypeFromY(i),o=n.cellDependType[a];Array.isArray(o)&&o.forEach((function(i){let a=n.idMappingFlip[i];e(t).find(`td[data-x='${a}']`).addClass("readonly")}))},r=function(t,i,a,o,s,l){if(i===o&&a===s){let t=this.getCellFromCoords(i,a),o=e(t).children();if(o.length&&o.hasClass("vi-wbe-gallery-has-item")){let o=this.options.data[a][i],s="";if(o.length)for(let e of o)s+=`<li class="vi-wbe-gallery-image"><img src="${n.imgStorage[e]}"></li>`;new d(`<ul class="vi-wbe-gallery-images">${s}</ul>`,e(t))}}},t=function(t,a,o,s,r){i.removeContextPopup();let d=a.selectedContainer;if(o=parseInt(o),s=parseInt(s),d[0]===d[2]&&null!==o)switch(a.options.columns[o].type){case"checkbox":t.push({title:l.text("Check"),onclick(e){c(a,!0)}}),t.push({title:l.text("Uncheck"),onclick(e){c(a,!1)}});break;case"number":t.push({title:l.text("Calculator"),onclick(e){new p(a,o,s,e)}}),o>1&&"sale_price"===a.options.columns[o].id&&"regular_price"===a.options.columns[o-1].id&&t.push({title:l.text("Calculator base on Regular price"),onclick(e){new h(a,o,s,e)}});break;case"text":t.push({title:l.text("Edit multiple cells"),onclick(e){new w(a,o,s,e,a.options.columns[o].wordWrap)}}),t.push({title:l.text("Find and Replace"),onclick(e){new v(a,o,s,e)}});break;case"calendar":let i=e(`td[data-x=${o}][data-y=${s}]`).get(0);e(i).hasClass("readonly")||t.push({title:l.text("Open date picker"),onclick(){let e=a.options.data[s][o];var t=l.createEditor(i,"input","",!1);t.value=e,t.style.left="unset";let n=a.selectedContainer,r=n[1],c=n[3];1!=a.options.tableOverflow&&1!=a.options.fullscreen||(a.options.columns[o].options.position=!0),a.options.columns[o].options.value=a.options.data[s][o],a.options.columns[o].options.opened=!0,a.options.columns[o].options.onclose=function(e,t){let i=[];t=e.value;for(let e=r;e<=c;e++)a.records[e][o]&&!a.records[e][o].classList.contains("readonly")&&"none"!==a.records[e][o].style.display&&(i.push(a.updateCell(o,e,t)),a.updateFormulaChain(o,e,i));a.setHistory({action:"setValue",records:i,selection:a.selectedCell}),a.updateTable()},jSuites.calendar(t,a.options.columns[o].options),t.focus()}});break;case"custom":switch(a.options.columns[o].editor.type){case"textEditor":t.push({title:l.text("Edit multiple cells"),onclick(){e(".vi-ui.modal").modal("show"),e(".vi-ui.modal .close.icon").off("click"),null===tinymce.get("vi-wbe-text-editor")?(e("#vi-wbe-text-editor").val(""),wp.editor.initialize("vi-wbe-text-editor",n.tinyMceOptions)):tinymce.get("vi-wbe-text-editor").setContent(""),e(".vi-wbe-text-editor-save").off("click").on("click",(function(){let t=wp.editor.getContent("vi-wbe-text-editor");c(a,t),e(this).hasClass("vi-wbe-close")&&e(".vi-ui.modal").modal("hide")}))}});break;case"tags":t.push({title:l.text("Find and replace tags"),onclick(e){new x(a,d,o,s,e)}});break;case"select2":t.push({title:l.text("Find and replace options"),onclick(e){new C(a,d,o,s,e)}});break;case"gallery":t.push({title:l.text("Add image to selected cells"),onclick(e){new k(a,d,o,s,e)}});break;case"product_attributes":t.push({title:l.text("Add attributes to products"),onclick(e){new A(a,d,o,s,e)}}),t.push({title:l.text("Remove multiple product attribute"),onclick(e){new E(a,d,o,s,e)}})}}if(t.length&&t.push({type:"line"}),d[1]===d[3]&&null!==s){let e=l.getProductTypeFromY(s);if("variable"===e&&(t.push({title:l.text("Add variation"),onclick(){l.is_loading()||l.ajax({data:{sub_action:"add_variation",pid:l.getProductIdOfCell(a,s)},beforeSend(){l.loading()},success(e){e.success&&(a.insertRow(0,s,!1,!0),a.setRowData(s+1,e.data,!0)),l.removeLoading()}})}}),t.push({title:`${l.text("Create variations from all attributes")} <span class="vi-wbe-context-menu-note">(${l.text("Save new attributes before")})</span>`,onclick(){l.is_loading()||l.ajax({data:{sub_action:"link_all_variations",pid:l.getProductIdOfCell(a,s)},beforeSend(){l.loading()},success(e){e.success&&(e.data.length&&e.data.forEach((function(e,t){a.insertRow(0,s+t,!1,!0),a.setRowData(s+t+1,e,!0)})),l.removeLoading(),l.notice(`${e.data.length} ${l.text("variations are added")}`))}})}}),t.push({type:"line"})),"variation"!==e){let e=l.getProductIdOfCell(a,s);t.push({title:l.text("Duplicate"),onclick(){l.ajax({data:{sub_action:"duplicate_product",product_id:e},beforeSend(){l.loading()},success(e){e.data.length&&e.data.forEach((function(e,t){a.insertRow(0,s+t,!0,!0),a.setRowData(s+t,e,!0)})),l.removeLoading()}})}}),t.push({title:l.text("Go to edit product page"),onclick(){window.open(`${n.adminUrl}post.php?post=${e}&action=edit`,"_blank")}}),t.push({title:l.text("View on Single product page"),onclick(){window.open(`${n.frontendUrl}?p=${e}&post_type=product&preview=true`,"_blank")}})}}return t};break;case"orders":t=function(t,i,a,o,s){let r=i.selectedContainer;if(a=parseInt(a),o=parseInt(o),null!==a&&null!==o){for(let e in n.orderActions)t.push({title:n.orderActions[e],onclick(){let t=[];for(let e=r[1];e<=r[3];e++)t.push(l.getProductIdOfCell(i,e));l.ajax({data:{sub_action:e,order_ids:t},beforeSend(){l.loading()},success(e){l.removeLoading()}})}});t.length&&t.push({type:"line"});const a=function(t=0){let a=i.getCellFromCoords(r[0],r[1]),n=e(`<div>\n <div class="field"> \n <textarea rows="3"></textarea>\n </div>\n <div class="field"> \n <span class="vi-wbe-add-note vi-ui button tiny">\n ${l.text("Add")}\n </span>\n </div>\n </div>`),o=new d(n,e(a));n.on("click",".vi-wbe-add-note",(function(){let e=n.find("textarea").val();if(!e)return;let a=i.selectedContainer,s=a[1],r=a[3],c=(a[0],[]);for(let e=s;e<=r;e++)c.push(i.options.data[e][0]);o.hide(),l.ajax({data:{sub_action:"add_order_note",ids:c,note:e,is_customer_note:t},beforeSend(){l.loading()},success(e){l.removeLoading()}})}))};if(t.push({title:l.text("Add private note"),onclick(){a(0)}}),t.push({title:l.text("Add note to customer"),onclick(){a(1)}}),t.length&&t.push({type:"line"}),r[1]===r[3]){let e=l.getProductIdOfCell(i,o);t.push({title:l.text("Go to edit order page"),onclick(){window.open(`${n.adminUrl}post.php?post=${e}&action=edit`,"_blank")}}),t.length&&t.push({type:"line"})}}return t};break;case"coupons":t=function(e,t,i,a,n){let o=t.selectedContainer;return i=parseInt(i),a=parseInt(a),null!==i&&null!==a&&o[0]===o[2]&&("code"===l.getColumnType(i)&&e.push({title:l.text("Generate coupon code"),onclick(){let e=[],i=t.selectedContainer,a=i[1],n=i[3],o=i[0];for(let i=a;i<=n;i++)if(t.records[i][o]&&!t.records[i][o].classList.contains("readonly")&&"none"!==t.records[i][o].style.display){let a=l.generateCouponCode();e.push(t.updateCell(o,i,a)),t.updateFormulaChain(o,i,e)}t.setHistory({action:"setValue",records:e,selection:t.selectedCell}),t.updateTable()}}),"text"===t.options.columns[i].type&&(e.push({title:l.text("Edit multiple cells"),onclick(e){new w(t,i,a,e,t.options.columns[i].wordWrap)}}),e.push({title:l.text("Find and Replace"),onclick(e){new v(t,i,a,e)}})),"checkbox"===t.options.columns[i].type&&(e.push({title:l.text("Check"),onclick(e){c(t,!0)}}),e.push({title:l.text("Uncheck"),onclick(e){c(t,!1)}})),e.length&&e.push({type:"line"})),e}}this.WorkBook=e("#vi-wbe-spreadsheet").jexcel({allowInsertRow:!1,allowInsertColumn:!1,about:!1,freezeColumns:3,tableOverflow:!0,tableWidth:"100%",tableHeight:"100%",columns:n.columns,stripHTML:!1,allowExport:!1,allowDeleteColumn:!1,allowRenameColumn:!1,autoIncrement:!1,allowXCopy:!1,text:{deleteSelectedRows:o},oncreaterow:s,contextMenuItems:t,onselection:r,onchange(t,a,n,o,s,r){if(JSON.stringify(s)!==JSON.stringify(r)){e(a).parent().trigger("cellonchange",{cell:a,col:n,row:o,value:s});let t=this.options.data[o][0];if(i.compare.push(t),i.compare=[...new Set(i.compare)], i.menubar.find(".vi-wbe-save-button").addClass("vi-wbe-saveable"),!i.isAdding){i.revision[t]||(i.revision[t]={});let e=l.getColumnType(n);i.revision[t][e]=r}}},onbeforechange:(e,t,i,a,n)=>("object"!=typeof n&&(n=S.sanitize(n)),n),ondeleterow(e,t,a,n){for(let e of n)i.trash.push(e[0].innerText);i.trash.length&&i.menubar.find(".vi-wbe-save-button").addClass("vi-wbe-saveable")},onundo(e,t){if(t&&"deleteRow"===t.action)for(let e of t.rowData)i.unTrash.push(e[0])},onbeforecopy(){a=0,i.firstCellCopy=null},oncopying(e,t,n){i.firstCellCopy||(i.firstCellCopy=[t,n]),i.firstCellCopy[0]!==t&&a++},onbeforepaste(e,t){if("string"!=typeof e)return e;e=e.trim();let n=t[0],o=this.columns[n].type;if(void 0===i.firstCellCopy)return["text","number","custom"].includes(o)?"custom"===o?"textEditor"===this.columns[n].editor.type?e:"":e:"";let s=+i.firstCellCopy[0],l=+t[0],r=this.columns[s].type,c=this.columns[l].type;if(+i.firstCellCopy[0]!=+t[0]){if(a>0)return alert("Copy single column each time."),"";if(r!==c)return alert("Can not paste data with different column type."),""}return e},onscroll(t){let i=e(t).find("select.select2-hidden-accessible");i.length&&i.select2("close")},oncreateeditor(e,t,i,a,n){this.options.columns[i].currency&&n.setAttribute("data-currency",this.options.columns[i].currency)}})}closeMenu(e){this.sidebar.removeClass("vi-wbe-open")}openMenu(t){let i=e(t.currentTarget).data("menu_tab"),a=this.sidebar.find(`a.item[data-tab='${i}']`);a.hasClass("active")&&this.sidebar.hasClass("vi-wbe-open")?this.sidebar.removeClass("vi-wbe-open"):(this.sidebar.addClass("vi-wbe-open"),a.trigger("click"))}addNewProduct(){if(l.is_loading())return;let e=prompt(l.text("Please enter new product name"));if(e){let t=this;l.ajax({data:{sub_action:"add_new_product",product_name:e},beforeSend(){l.loading()},success(e){t.isAdding=!0,t.WorkBook.insertRow(0,0,!0,!0),t.WorkBook.setRowData(0,e.data,!0),l.removeLoading()},complete(){t.isAdding=!1}})}}addNewCoupon(){if(l.is_loading())return;let e=this;l.ajax({data:{sub_action:"add_new_coupon"},beforeSend(){l.loading()},success(t){e.isAdding=!0,e.WorkBook.insertRow(0,0,!0,!0),e.WorkBook.setRowData(0,t.data,!0),l.removeLoading()},complete(){e.isAdding=!1}})}addNewOrder(){window.open("post-new.php?post_type=shop_order")}toggleFullScreen(t){let i=e(".wp-admin"),a=e(t.currentTarget);i.toggleClass("vi-wbe-full-screen"),i.hasClass("vi-wbe-full-screen")?(a.find("i.icon").removeClass("external alternate").addClass("window close outline"),a.attr("title","Exit full screen")):(a.find("i.icon").removeClass("window close outline").addClass("external alternate"),a.attr("title","Full screen")),e.ajax({url:n.ajaxUrl,type:"post",dataType:"json",data:{...n.ajaxData,sub_action:"set_full_screen_option",status:i.hasClass("vi-wbe-full-screen")}})}getAllRows(){return this.WorkBook.getData(!1,!0)}save(){e("td.error").removeClass("error");let t=this,i=this.getAllRows(),a=[],n=[];for(let e of this.compare)for(let t of i)t[0]===parseInt(e)&&a.push(t);l.is_loading()||function i(o=0){let s=30*o,r=s+30,c=a.slice(s,r),d=30*(o+1)>a.length;if(c.length||t.trash.length||t.unTrash.length)l.ajax({data:{sub_action:"save_products",products:JSON.stringify(c),trash:t.trash,untrash:t.unTrash},beforeSend(){l.loading()},success(e){t.trash=[],t.unTrash=[],t.compare=[],t.menubar.find(".vi-wbe-save-button").removeClass("vi-wbe-saveable"),e.data.skuErrors&&(n=[...new Set([...n,...e.data.skuErrors])]),l.removeLoading(),i(o+1)},error(e){console.log(e)}});else if(0===o&&l.notice(l.text("Nothing change to save")),d){if(n.length){l.notice(l.text("Invalid or duplicated SKU"));let i=l.getColFromColumnType("sku"),a=t.WorkBook.getData();if(a.length)for(let o in a){let s=a[o];if(n.includes(s[0])){let a=t.WorkBook.getCellFromCoords(i,o);e(a).addClass("error")}}}let i=t.WorkBook.history;if(i.length)for(let e of i){if("deleteRow"!==e.action)continue;let t=[];for(let i in e.rowData)e.rowData[i][1]>0&&t.push(parseInt(i));t.length&&(e.rowData=e.rowData.filter(((e,i)=>!t.includes(i))),e.rowNode=e.rowNode.filter(((e,i)=>!t.includes(i))),e.rowRecords=e.rowRecords.filter(((e,i)=>!t.includes(i))),e.numOfRows=e.numOfRows-t.length)}t.saveRevision()}}()}loadProducts(e=1,t=!1){let i=this;l.is_loading()||l.ajax({data:{sub_action:"load_products",page:e,re_create:t},beforeSend(){l.loading()},success(a){a.success&&(n.imgStorage=a.data.img_storage,t&&(i.WorkBook.destroy(),a.data.columns&&n.setColumns(a.data.columns),a.data.idMapping&&(n.idMapping=a.data.idMapping),a.data.idMappingFlip&&(n.idMappingFlip=a.data.idMappingFlip),i.workBookInit()),i.WorkBook.options.data=a.data.products,i.WorkBook.setData(),i.pagination(a.data.max_num_pages,e),l.removeLoading(),a.data.products.length||l.notice(l.text("No item was found")))},error(e){console.log(e)}})}pagination(e,t){this.menubar.find(".vi-wbe-pagination").html(l.pagination(e,t))}changePage(t){let i=parseInt(e(t.currentTarget).attr("data-page"));e(t.currentTarget).hasClass("active")||e(t.currentTarget).hasClass("disabled")||!i||this.loadProducts(i)}changePageByInput(t){let i=parseInt(e(t.target).val());i<=parseInt(e(t.target).attr("max"))&&i>0&&this.loadProducts(i)}reloadCurrentPage(){this.loadProducts(this.getCurrentPage())}getCurrentPage(){return this.menubar.find(".vi-wbe-pagination .item.active").data("page")||1}afterAddFilter(e,t){n.imgStorage=t.img_storage,this.WorkBook.options.data=t.products,this.WorkBook.setData(),this.pagination(t.max_num_pages,1),t.products.length||l.notice(l.text("No item was found"))}afterSaveSettings(e,t){t.fieldsChange&&this.loadProducts(this.getCurrentPage(),!0)}saveRevision(){let t=this;if(Object.keys(t.revision).length){let i=t.sidebar.find(".vi-wbe-pagination a.item.active").data("page")||1;l.ajax({data:{sub_action:"auto_save_revision",data:t.revision,page:i||1},success(a){a.success&&(a.data.updatePage&&e("#vi-wbe-history-points-list tbody").html(a.data.updatePage),t.revision={},t.sidebar.find(".vi-wbe-pagination").html(l.pagination(a.data.pages,i)))}})}}}}))})()})();2 (()=>{var e={744:function(e){e.exports=function(){"use strict";const{entries:e,setPrototypeOf:t,isFrozen:i,getPrototypeOf:a,getOwnPropertyDescriptor:n}=Object;let{freeze:o,seal:s,create:l}=Object,{apply:r,construct:c}="undefined"!=typeof Reflect&&Reflect;r||(r=function(e,t,i){return e.apply(t,i)}),o||(o=function(e){return e}),s||(s=function(e){return e}),c||(c=function(e,t){return new e(...t)});const d=_(Array.prototype.forEach),u=_(Array.prototype.pop),p=_(Array.prototype.push),h=_(String.prototype.toLowerCase),m=_(String.prototype.toString),b=_(String.prototype.match),f=_(String.prototype.replace),v=_(String.prototype.indexOf),g=_(String.prototype.trim),w=_(RegExp.prototype.test),y=(x=TypeError,function(){for(var e=arguments.length,t=new Array(e),i=0;i<e;i++)t[i]=arguments[i];return c(x,t)});var x;function _(e){return function(t){for(var i=arguments.length,a=new Array(i>1?i-1:0),n=1;n<i;n++)a[n-1]=arguments[n];return r(e,t,a)}}function C(e,a,n){n=n||h,t&&t(e,null);let o=a.length;for(;o--;){let t=a[o];if("string"==typeof t){const e=n(t);e!==t&&(i(a)||(a[o]=e),t=e)}e[t]=!0}return e}function k(t){const i=l(null);for(const[a,n]of e(t))i[a]=n;return i}function T(e,t){for(;null!==e;){const i=n(e,t);if(i){if(i.get)return _(i.get);if("function"==typeof i.value)return _(i.value)}e=a(e)}return function(e){return console.warn("fallback value for",e),null}}const A=o(["a","abbr","acronym","address","area","article","aside","audio","b","bdi","bdo","big","blink","blockquote","body","br","button","canvas","caption","center","cite","code","col","colgroup","content","data","datalist","dd","decorator","del","details","dfn","dialog","dir","div","dl","dt","element","em","fieldset","figcaption","figure","font","footer","form","h1","h2","h3","h4","h5","h6","head","header","hgroup","hr","html","i","img","input","ins","kbd","label","legend","li","main","map","mark","marquee","menu","menuitem","meter","nav","nobr","ol","optgroup","option","output","p","picture","pre","progress","q","rp","rt","ruby","s","samp","section","select","shadow","small","source","spacer","span","strike","strong","style","sub","summary","sup","table","tbody","td","template","textarea","tfoot","th","thead","time","tr","track","tt","u","ul","var","video","wbr"]),$=o(["svg","a","altglyph","altglyphdef","altglyphitem","animatecolor","animatemotion","animatetransform","circle","clippath","defs","desc","ellipse","filter","font","g","glyph","glyphref","hkern","image","line","lineargradient","marker","mask","metadata","mpath","path","pattern","polygon","polyline","radialgradient","rect","stop","style","switch","symbol","text","textpath","title","tref","tspan","view","vkern"]),E=o(["feBlend","feColorMatrix","feComponentTransfer","feComposite","feConvolveMatrix","feDiffuseLighting","feDisplacementMap","feDistantLight","feFlood","feFuncA","feFuncB","feFuncG","feFuncR","feGaussianBlur","feImage","feMerge","feMergeNode","feMorphology","feOffset","fePointLight","feSpecularLighting","feSpotLight","feTile","feTurbulence"]),S=o(["animate","color-profile","cursor","discard","fedropshadow","font-face","font-face-format","font-face-name","font-face-src","font-face-uri","foreignobject","hatch","hatchpath","mesh","meshgradient","meshpatch","meshrow","missing-glyph","script","set","solidcolor","unknown","use"]),N=o(["math","menclose","merror","mfenced","mfrac","mglyph","mi","mlabeledtr","mmultiscripts","mn","mo","mover","mpadded","mphantom","mroot","mrow","ms","mspace","msqrt","mstyle","msub","msup","msubsup","mtable","mtd","mtext","mtr","munder","munderover","mprescripts"]),I=o(["maction","maligngroup","malignmark","mlongdiv","mscarries","mscarry","msgroup","mstack","msline","msrow","semantics","annotation","annotation-xml","mprescripts","none"]),R=o(["#text"]),F=o(["accept","action","align","alt","autocapitalize","autocomplete","autopictureinpicture","autoplay","background","bgcolor","border","capture","cellpadding","cellspacing","checked","cite","class","clear","color","cols","colspan","controls","controlslist","coords","crossorigin","datetime","decoding","default","dir","disabled","disablepictureinpicture","disableremoteplayback","download","draggable","enctype","enterkeyhint","face","for","headers","height","hidden","high","href","hreflang","id","inputmode","integrity","ismap","kind","label","lang","list","loading","loop","low","max","maxlength","media","method","min","minlength","multiple","muted","name","nonce","noshade","novalidate","nowrap","open","optimum","pattern","placeholder","playsinline","poster","preload","pubdate","radiogroup","readonly","rel","required","rev","reversed","role","rows","rowspan","spellcheck","scope","selected","shape","size","sizes","span","srclang","start","src","srcset","step","style","summary","tabindex","title","translate","type","usemap","valign","value","width","xmlns","slot"]),D=o(["accent-height","accumulate","additive","alignment-baseline","ascent","attributename","attributetype","azimuth","basefrequency","baseline-shift","begin","bias","by","class","clip","clippathunits","clip-path","clip-rule","color","color-interpolation","color-interpolation-filters","color-profile","color-rendering","cx","cy","d","dx","dy","diffuseconstant","direction","display","divisor","dur","edgemode","elevation","end","fill","fill-opacity","fill-rule","filter","filterunits","flood-color","flood-opacity","font-family","font-size","font-size-adjust","font-stretch","font-style","font-variant","font-weight","fx","fy","g1","g2","glyph-name","glyphref","gradientunits","gradienttransform","height","href","id","image-rendering","in","in2","k","k1","k2","k3","k4","kerning","keypoints","keysplines","keytimes","lang","lengthadjust","letter-spacing","kernelmatrix","kernelunitlength","lighting-color","local","marker-end","marker-mid","marker-start","markerheight","markerunits","markerwidth","maskcontentunits","maskunits","max","mask","media","method","mode","min","name","numoctaves","offset","operator","opacity","order","orient","orientation","origin","overflow","paint-order","path","pathlength","patterncontentunits","patterntransform","patternunits","points","preservealpha","preserveaspectratio","primitiveunits","r","rx","ry","radius","refx","refy","repeatcount","repeatdur","restart","result","rotate","scale","seed","shape-rendering","specularconstant","specularexponent","spreadmethod","startoffset","stddeviation","stitchtiles","stop-color","stop-opacity","stroke-dasharray","stroke-dashoffset","stroke-linecap","stroke-linejoin","stroke-miterlimit","stroke-opacity","stroke","stroke-width","style","surfacescale","systemlanguage","tabindex","targetx","targety","transform","transform-origin","text-anchor","text-decoration","text-rendering","textlength","type","u1","u2","unicode","values","viewbox","visibility","version","vert-adv-y","vert-origin-x","vert-origin-y","width","word-spacing","wrap","writing-mode","xchannelselector","ychannelselector","x","x1","x2","xmlns","y","y1","y2","z","zoomandpan"]),M=o(["accent","accentunder","align","bevelled","close","columnsalign","columnlines","columnspan","denomalign","depth","dir","display","displaystyle","encoding","fence","frame","height","href","id","largeop","length","linethickness","lspace","lquote","mathbackground","mathcolor","mathsize","mathvariant","maxsize","minsize","movablelimits","notation","numalign","open","rowalign","rowlines","rowspacing","rowspan","rspace","rquote","scriptlevel","scriptminsize","scriptsizemultiplier","selection","separator","separators","stretchy","subscriptshift","supscriptshift","symmetric","voffset","width","xmlns"]),O=o(["xlink:href","xml:id","xlink:title","xml:space","xmlns:xlink"]),j=s(/\{\{[\w\W]*|[\w\W]*\}\}/gm),L=s(/<%[\w\W]*|[\w\W]*%>/gm),P=s(/\${[\w\W]*}/gm),H=s(/^data-[\-\w.\u00B7-\uFFFF]/),U=s(/^aria-[\-\w]+$/),B=s(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i),W=s(/^(?:\w+script|data):/i),z=s(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g),G=s(/^html$/i);var V=Object.freeze({__proto__:null,MUSTACHE_EXPR:j,ERB_EXPR:L,TMPLIT_EXPR:P,DATA_ATTR:H,ARIA_ATTR:U,IS_ALLOWED_URI:B,IS_SCRIPT_OR_DATA:W,ATTR_WHITESPACE:z,DOCTYPE_NAME:G});const J=()=>"undefined"==typeof window?null:window,K=function(e,t){if("object"!=typeof e||"function"!=typeof e.createPolicy)return null;let i=null;const a="data-tt-policy-suffix";t.currentScript&&t.currentScript.hasAttribute(a)&&(i=t.currentScript.getAttribute(a));const n="dompurify"+(i?"#"+i:"");try{return e.createPolicy(n,{createHTML:e=>e,createScriptURL:e=>e})}catch(e){return console.warn("TrustedTypes policy "+n+" could not be created."),null}};return function t(){let i=arguments.length>0&&void 0!==arguments[0]?arguments[0]:J();const a=e=>t(e);if(a.version="3.0.2",a.removed=[],!i||!i.document||9!==i.document.nodeType)return a.isSupported=!1,a;const n=i.document;let{document:s}=i;const{DocumentFragment:l,HTMLTemplateElement:r,Node:c,Element:x,NodeFilter:_,NamedNodeMap:j=i.NamedNodeMap||i.MozNamedAttrMap,HTMLFormElement:L,DOMParser:P,trustedTypes:H}=i,U=x.prototype,W=T(U,"cloneNode"),z=T(U,"nextSibling"),Q=T(U,"childNodes"),q=T(U,"parentNode");if("function"==typeof r){const e=s.createElement("template");e.content&&e.content.ownerDocument&&(s=e.content.ownerDocument)}const X=K(H,n),Y=X?X.createHTML(""):"",{implementation:Z,createNodeIterator:ee,createDocumentFragment:te,getElementsByTagName:ie}=s,{importNode:ae}=n;let ne={};a.isSupported="function"==typeof e&&"function"==typeof q&&Z&&void 0!==Z.createHTMLDocument;const{MUSTACHE_EXPR:oe,ERB_EXPR:se,TMPLIT_EXPR:le,DATA_ATTR:re,ARIA_ATTR:ce,IS_SCRIPT_OR_DATA:de,ATTR_WHITESPACE:ue}=V;let{IS_ALLOWED_URI:pe}=V,he=null;const me=C({},[...A,...$,...E,...N,...R]);let be=null;const fe=C({},[...F,...D,...M,...O]);let ve=Object.seal(Object.create(null,{tagNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},allowCustomizedBuiltInElements:{writable:!0,configurable:!1,enumerable:!0,value:!1}})),ge=null,we=null,ye=!0,xe=!0,_e=!1,Ce=!0,ke=!1,Te=!1,Ae=!1,$e=!1,Ee=!1,Se=!1,Ne=!1,Ie=!0,Re=!1;const Fe="user-content-";let De=!0,Me=!1,Oe={},je=null;const Le=C({},["annotation-xml","audio","colgroup","desc","foreignobject","head","iframe","math","mi","mn","mo","ms","mtext","noembed","noframes","noscript","plaintext","script","style","svg","template","thead","title","video","xmp"]);let Pe=null;const He=C({},["audio","video","img","source","image","track"]);let Ue=null;const Be=C({},["alt","class","for","id","label","name","pattern","placeholder","role","summary","title","value","style","xmlns"]),We="http://www.w3.org/1998/Math/MathML",ze="http://www.w3.org/2000/svg",Ge="http://www.w3.org/1999/xhtml";let Ve=Ge,Je=!1,Ke=null;const Qe=C({},[We,ze,Ge],m);let qe;const Xe=["application/xhtml+xml","text/html"],Ye="text/html";let Ze,et=null;const tt=s.createElement("form"),it=function(e){return e instanceof RegExp||e instanceof Function},at=function(e){et&&et===e||(e&&"object"==typeof e||(e={}),e=k(e),qe=qe=-1===Xe.indexOf(e.PARSER_MEDIA_TYPE)?Ye:e.PARSER_MEDIA_TYPE,Ze="application/xhtml+xml"===qe?m:h,he="ALLOWED_TAGS"in e?C({},e.ALLOWED_TAGS,Ze):me,be="ALLOWED_ATTR"in e?C({},e.ALLOWED_ATTR,Ze):fe,Ke="ALLOWED_NAMESPACES"in e?C({},e.ALLOWED_NAMESPACES,m):Qe,Ue="ADD_URI_SAFE_ATTR"in e?C(k(Be),e.ADD_URI_SAFE_ATTR,Ze):Be,Pe="ADD_DATA_URI_TAGS"in e?C(k(He),e.ADD_DATA_URI_TAGS,Ze):He,je="FORBID_CONTENTS"in e?C({},e.FORBID_CONTENTS,Ze):Le,ge="FORBID_TAGS"in e?C({},e.FORBID_TAGS,Ze):{},we="FORBID_ATTR"in e?C({},e.FORBID_ATTR,Ze):{},Oe="USE_PROFILES"in e&&e.USE_PROFILES,ye=!1!==e.ALLOW_ARIA_ATTR,xe=!1!==e.ALLOW_DATA_ATTR,_e=e.ALLOW_UNKNOWN_PROTOCOLS||!1,Ce=!1!==e.ALLOW_SELF_CLOSE_IN_ATTR,ke=e.SAFE_FOR_TEMPLATES||!1,Te=e.WHOLE_DOCUMENT||!1,Ee=e.RETURN_DOM||!1,Se=e.RETURN_DOM_FRAGMENT||!1,Ne=e.RETURN_TRUSTED_TYPE||!1,$e=e.FORCE_BODY||!1,Ie=!1!==e.SANITIZE_DOM,Re=e.SANITIZE_NAMED_PROPS||!1,De=!1!==e.KEEP_CONTENT,Me=e.IN_PLACE||!1,pe=e.ALLOWED_URI_REGEXP||B,Ve=e.NAMESPACE||Ge,ve=e.CUSTOM_ELEMENT_HANDLING||{},e.CUSTOM_ELEMENT_HANDLING&&it(e.CUSTOM_ELEMENT_HANDLING.tagNameCheck)&&(ve.tagNameCheck=e.CUSTOM_ELEMENT_HANDLING.tagNameCheck),e.CUSTOM_ELEMENT_HANDLING&&it(e.CUSTOM_ELEMENT_HANDLING.attributeNameCheck)&&(ve.attributeNameCheck=e.CUSTOM_ELEMENT_HANDLING.attributeNameCheck),e.CUSTOM_ELEMENT_HANDLING&&"boolean"==typeof e.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements&&(ve.allowCustomizedBuiltInElements=e.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements),ke&&(xe=!1),Se&&(Ee=!0),Oe&&(he=C({},[...R]),be=[],!0===Oe.html&&(C(he,A),C(be,F)),!0===Oe.svg&&(C(he,$),C(be,D),C(be,O)),!0===Oe.svgFilters&&(C(he,E),C(be,D),C(be,O)),!0===Oe.mathMl&&(C(he,N),C(be,M),C(be,O))),e.ADD_TAGS&&(he===me&&(he=k(he)),C(he,e.ADD_TAGS,Ze)),e.ADD_ATTR&&(be===fe&&(be=k(be)),C(be,e.ADD_ATTR,Ze)),e.ADD_URI_SAFE_ATTR&&C(Ue,e.ADD_URI_SAFE_ATTR,Ze),e.FORBID_CONTENTS&&(je===Le&&(je=k(je)),C(je,e.FORBID_CONTENTS,Ze)),De&&(he["#text"]=!0),Te&&C(he,["html","head","body"]),he.table&&(C(he,["tbody"]),delete ge.tbody),o&&o(e),et=e)},nt=C({},["mi","mo","mn","ms","mtext"]),ot=C({},["foreignobject","desc","title","annotation-xml"]),st=C({},["title","style","font","a","script"]),lt=C({},$);C(lt,E),C(lt,S);const rt=C({},N);C(rt,I);const ct=function(e){let t=q(e);t&&t.tagName||(t={namespaceURI:Ve,tagName:"template"});const i=h(e.tagName),a=h(t.tagName);return!!Ke[e.namespaceURI]&&(e.namespaceURI===ze?t.namespaceURI===Ge?"svg"===i:t.namespaceURI===We?"svg"===i&&("annotation-xml"===a||nt[a]):Boolean(lt[i]):e.namespaceURI===We?t.namespaceURI===Ge?"math"===i:t.namespaceURI===ze?"math"===i&&ot[a]:Boolean(rt[i]):e.namespaceURI===Ge?!(t.namespaceURI===ze&&!ot[a])&&!(t.namespaceURI===We&&!nt[a])&&!rt[i]&&(st[i]||!lt[i]):!("application/xhtml+xml"!==qe||!Ke[e.namespaceURI]))},dt=function(e){p(a.removed,{element:e});try{e.parentNode.removeChild(e)}catch(t){e.remove()}},ut=function(e,t){try{p(a.removed,{attribute:t.getAttributeNode(e),from:t})}catch(e){p(a.removed,{attribute:null,from:t})}if(t.removeAttribute(e),"is"===e&&!be[e])if(Ee||Se)try{dt(t)}catch(e){}else try{t.setAttribute(e,"")}catch(e){}},pt=function(e){let t,i;if($e)e="<remove></remove>"+e;else{const t=b(e,/^[\r\n\t ]+/);i=t&&t[0]}"application/xhtml+xml"===qe&&Ve===Ge&&(e='<html xmlns="http://www.w3.org/1999/xhtml"><head></head><body>'+e+"</body></html>");const a=X?X.createHTML(e):e;if(Ve===Ge)try{t=(new P).parseFromString(a,qe)}catch(e){}if(!t||!t.documentElement){t=Z.createDocument(Ve,"template",null);try{t.documentElement.innerHTML=Je?Y:a}catch(e){}}const n=t.body||t.documentElement;return e&&i&&n.insertBefore(s.createTextNode(i),n.childNodes[0]||null),Ve===Ge?ie.call(t,Te?"html":"body")[0]:Te?t.documentElement:n},ht=function(e){return ee.call(e.ownerDocument||e,e,_.SHOW_ELEMENT|_.SHOW_COMMENT|_.SHOW_TEXT,null,!1)},mt=function(e){return e instanceof L&&("string"!=typeof e.nodeName||"string"!=typeof e.textContent||"function"!=typeof e.removeChild||!(e.attributes instanceof j)||"function"!=typeof e.removeAttribute||"function"!=typeof e.setAttribute||"string"!=typeof e.namespaceURI||"function"!=typeof e.insertBefore||"function"!=typeof e.hasChildNodes)},bt=function(e){return"object"==typeof c?e instanceof c:e&&"object"==typeof e&&"number"==typeof e.nodeType&&"string"==typeof e.nodeName},ft=function(e,t,i){ne[e]&&d(ne[e],(e=>{e.call(a,t,i,et)}))},vt=function(e){let t;if(ft("beforeSanitizeElements",e,null),mt(e))return dt(e),!0;const i=Ze(e.nodeName);if(ft("uponSanitizeElement",e,{tagName:i,allowedTags:he}),e.hasChildNodes()&&!bt(e.firstElementChild)&&(!bt(e.content)||!bt(e.content.firstElementChild))&&w(/<[/\w]/g,e.innerHTML)&&w(/<[/\w]/g,e.textContent))return dt(e),!0;if(!he[i]||ge[i]){if(!ge[i]&&wt(i)){if(ve.tagNameCheck instanceof RegExp&&w(ve.tagNameCheck,i))return!1;if(ve.tagNameCheck instanceof Function&&ve.tagNameCheck(i))return!1}if(De&&!je[i]){const t=q(e)||e.parentNode,i=Q(e)||e.childNodes;if(i&&t)for(let a=i.length-1;a>=0;--a)t.insertBefore(W(i[a],!0),z(e))}return dt(e),!0}return e instanceof x&&!ct(e)?(dt(e),!0):"noscript"!==i&&"noembed"!==i||!w(/<\/no(script|embed)/i,e.innerHTML)?(ke&&3===e.nodeType&&(t=e.textContent,t=f(t,oe," "),t=f(t,se," "),t=f(t,le," "),e.textContent!==t&&(p(a.removed,{element:e.cloneNode()}),e.textContent=t)),ft("afterSanitizeElements",e,null),!1):(dt(e),!0)},gt=function(e,t,i){if(Ie&&("id"===t||"name"===t)&&(i in s||i in tt))return!1;if(xe&&!we[t]&&w(re,t));else if(ye&&w(ce,t));else if(!be[t]||we[t]){if(!(wt(e)&&(ve.tagNameCheck instanceof RegExp&&w(ve.tagNameCheck,e)||ve.tagNameCheck instanceof Function&&ve.tagNameCheck(e))&&(ve.attributeNameCheck instanceof RegExp&&w(ve.attributeNameCheck,t)||ve.attributeNameCheck instanceof Function&&ve.attributeNameCheck(t))||"is"===t&&ve.allowCustomizedBuiltInElements&&(ve.tagNameCheck instanceof RegExp&&w(ve.tagNameCheck,i)||ve.tagNameCheck instanceof Function&&ve.tagNameCheck(i))))return!1}else if(Ue[t]);else if(w(pe,f(i,ue,"")));else if("src"!==t&&"xlink:href"!==t&&"href"!==t||"script"===e||0!==v(i,"data:")||!Pe[e])if(_e&&!w(de,f(i,ue,"")));else if(i)return!1;return!0},wt=function(e){return e.indexOf("-")>0},yt=function(e){let t,i,n,o;ft("beforeSanitizeAttributes",e,null);const{attributes:s}=e;if(!s)return;const l={attrName:"",attrValue:"",keepAttr:!0,allowedAttributes:be};for(o=s.length;o--;){t=s[o];const{name:r,namespaceURI:c}=t;if(i="value"===r?t.value:g(t.value),n=Ze(r),l.attrName=n,l.attrValue=i,l.keepAttr=!0,l.forceKeepAttr=void 0,ft("uponSanitizeAttribute",e,l),i=l.attrValue,l.forceKeepAttr)continue;if(ut(r,e),!l.keepAttr)continue;if(!Ce&&w(/\/>/i,i)){ut(r,e);continue}ke&&(i=f(i,oe," "),i=f(i,se," "),i=f(i,le," "));const d=Ze(e.nodeName);if(gt(d,n,i)){if(!Re||"id"!==n&&"name"!==n||(ut(r,e),i=Fe+i),X&&"object"==typeof H&&"function"==typeof H.getAttributeType)if(c);else switch(H.getAttributeType(d,n)){case"TrustedHTML":i=X.createHTML(i);break;case"TrustedScriptURL":i=X.createScriptURL(i)}try{c?e.setAttributeNS(c,r,i):e.setAttribute(r,i),u(a.removed)}catch(e){}}}ft("afterSanitizeAttributes",e,null)},xt=function e(t){let i;const a=ht(t);for(ft("beforeSanitizeShadowDOM",t,null);i=a.nextNode();)ft("uponSanitizeShadowNode",i,null),vt(i)||(i.content instanceof l&&e(i.content),yt(i));ft("afterSanitizeShadowDOM",t,null)};return a.sanitize=function(e){let t,i,o,s,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(Je=!e,Je&&(e="\x3c!--\x3e"),"string"!=typeof e&&!bt(e)){if("function"!=typeof e.toString)throw y("toString is not a function");if("string"!=typeof(e=e.toString()))throw y("dirty is not a string, aborting")}if(!a.isSupported)return e;if(Ae||at(r),a.removed=[],"string"==typeof e&&(Me=!1),Me){if(e.nodeName){const t=Ze(e.nodeName);if(!he[t]||ge[t])throw y("root node is forbidden and cannot be sanitized in-place")}}else if(e instanceof c)t=pt("\x3c!----\x3e"),i=t.ownerDocument.importNode(e,!0),1===i.nodeType&&"BODY"===i.nodeName||"HTML"===i.nodeName?t=i:t.appendChild(i);else{if(!Ee&&!ke&&!Te&&-1===e.indexOf("<"))return X&&Ne?X.createHTML(e):e;if(t=pt(e),!t)return Ee?null:Ne?Y:""}t&&$e&&dt(t.firstChild);const d=ht(Me?e:t);for(;o=d.nextNode();)vt(o)||(o.content instanceof l&&xt(o.content),yt(o));if(Me)return e;if(Ee){if(Se)for(s=te.call(t.ownerDocument);t.firstChild;)s.appendChild(t.firstChild);else s=t;return(be.shadowroot||be.shadowrootmod)&&(s=ae.call(n,s,!0)),s}let u=Te?t.outerHTML:t.innerHTML;return Te&&he["!doctype"]&&t.ownerDocument&&t.ownerDocument.doctype&&t.ownerDocument.doctype.name&&w(G,t.ownerDocument.doctype.name)&&(u="<!DOCTYPE "+t.ownerDocument.doctype.name+">\n"+u),ke&&(u=f(u,oe," "),u=f(u,se," "),u=f(u,le," ")),X&&Ne?X.createHTML(u):u},a.setConfig=function(e){at(e),Ae=!0},a.clearConfig=function(){et=null,Ae=!1},a.isValidAttribute=function(e,t,i){et||at({});const a=Ze(e),n=Ze(t);return gt(a,n,i)},a.addHook=function(e,t){"function"==typeof t&&(ne[e]=ne[e]||[],p(ne[e],t))},a.removeHook=function(e){if(ne[e])return u(ne[e])},a.removeHooks=function(e){ne[e]&&(ne[e]=[])},a.removeAllHooks=function(){ne={}},a}()}()}},t={};function i(a){var n=t[a];if(void 0!==n)return n.exports;var o=t[a]={exports:{}};return e[a].call(o.exports,o,o.exports,i),o.exports}(()=>{"use strict";const e={modal(e={}){let{header:t="",content:i="",actionsHtml:a=""}=e;return`<div class="vi-wbe-modal-container">\n <div class="vi-wbe-modal-main vi-ui form small">\n <i class="close icon"></i>\n <div class="vi-wbe-modal-wrapper">\n <h3 class="header">${t}</h3>\n <div class="content">${i}</div>\n <div class="actions">${a}</div>\n </div>\n </div>\n </div>`},defaultAttributes(e={}){let{html:t}=e;return`<table class="vi-ui celled table">\n <thead>\n <tr>\n <th>Name</th>\n <th>Attribute</th>\n </tr>\n </thead>\n <tbody>\n ${t}\n </tbody>\n </table>`}},t={},a={};jQuery(document).ready((function(i){window.viIsEditing=!1;const o=wp.media({multiple:!0}),s=wp.media({multiple:!1}),r={galleryImage:(e,t)=>`<li class="vi-wbe-gallery-image" data-id="${t}"><i class="vi-wbe-remove-image dashicons dashicons-no-alt"> </i><img src="${e}"></li>`,fileDownload(e={}){let{id:t,name:a,file:n}=e,o=i(`<tr>\n <td><i class="bars icon"></i><input type="text" class="vi-wbe-file-name" value="${a||""}"></td>\n <td>\n <input type="text" class="vi-wbe-file-url" value="${n||""}">\n <input type="hidden" class="vi-wbe-file-hash" value="${t||""}">\n <span class="vi-ui button mini vi-wbe-choose-file">${l.text("Choose file")}</span>\n <i class="vi-wbe-remove-file dashicons dashicons-no-alt"> </i>\n </td>\n </tr>`);return o.on("click",".vi-wbe-remove-file",(function(){o.remove()})),o}};t.textEditor={type:"textEditor",createCell:(e,t,i,a)=>(e.innerHTML=l.stripHtml(i).slice(0,50),e),closeEditor(e,t){window.viIsEditing=!1;let i="";return!0===t&&(i=wp.editor.getContent("vi-wbe-text-editor"),this.isEditing||wp.editor.remove("vi-wbe-text-editor"),this.isEditing=!1),i},openEditor(e,t,a){window.viIsEditing=!0;let n=e.getAttribute("data-y"),o=e.getAttribute("data-x"),s=a.options.data[n][o],l=this,r=i(".vi-ui.modal .close.icon");i(".vi-ui.modal").modal("show"),this.tinymceInit(s),r.off("click"),i(".vi-wbe-text-editor-save").off("click").on("click",(function(){i(this).removeClass("primary"),i(this).hasClass("vi-wbe-close")?i(".vi-ui.modal").modal("hide"):l.isEditing=!0,a.closeEditor(e,!0)})),r.on("click",(function(){a.closeEditor(e,!1)})),i(".vi-ui.modal").parent().on("click",(function(t){t.target===t.delegateTarget&&a.closeEditor(e,!1)}))},updateCell:(e,t,i)=>(e.innerHTML=l.stripHtml(t).slice(0,50),t),tinymceInit(e=""){e=wp.editor.autop(e),null===tinymce.get("vi-wbe-text-editor")&&(i("#vi-wbe-text-editor").val(e),n.tinyMceOptions.tinymce.setup=function(e){e.on("keyup",(function(e){i(".vi-wbe-text-editor-save:not(.vi-wbe-close)").addClass("primary")}))},wp.editor.initialize("vi-wbe-text-editor",n.tinyMceOptions)),tinymce.get("vi-wbe-text-editor").setContent(e)}},t.image={createCell(e,t,a,o){if(a){let t=n.imgStorage[a];l.isUrl(t)?i(e).html(`<img width="40" src="${t}" data-id="${a}">`):i(e).html("")}return e},closeEditor:(e,t)=>i(e).find("img").attr("data-id")||"",openEditor(e,t,a){function o(){s.open().off("select").on("select",(function(t){let o=s.state().get("selection").first().toJSON();l.isUrl(o.url)&&(i(e).html(`<img width="40" src="${o.url}" data-id="${o.id}">`),n.imgStorage[o.id]=o.url,a.closeEditor(e,!0))}))}i(e).on("dblclick",o),o()},updateCell(e,t,a){t=parseInt(t)||"";let o=n.imgStorage[t];return l.isUrl(o)?i(e).html(`<img width="40" src="${o}" data-id="${t}">`):i(e).html(""),t}},t.gallery={type:"gallery",saveData(e){let t=[];i(e).find(".vi-wbe-gallery-image").each((function(){t.push(i(this).data("id"))})),i(e).find(".vi-wbe-ids-list").val(t.join(","))},createCell(e,t,a){let n=a.length?"vi-wbe-gallery-has-item":"";return i(e).addClass("vi-wbe-gallery"),i(e).html(`<div class="vi-wbe-gallery ${n}"><i class="images outline icon"> </i></div>`),e},closeEditor(e,t){window.viIsEditing=!1;let a=[];return t&&i(e).children().find(".vi-wbe-gallery-image").each((function(){a.push(i(this).data("id"))})),i(e).find(".vi-wbe-cell-popup").remove(),a},openEditor(e,t,a){window.viIsEditing=!0;let s=e.getAttribute("data-y"),c=e.getAttribute("data-x"),d=a.options.data[s][c],u="";if(d.length)for(let e of d){let t=n.imgStorage[e];u+=r.galleryImage(t,e)}let p=i(`<div class="vi-wbe-cell-popup-inner">\n <ul class="vi-wbe-gallery-images">${u}</ul>\n <span class="vi-ui button tiny vi-wbe-add-image">${l.text("Add image")}</span>\n <span class="vi-ui button tiny vi-wbe-remove-gallery">${l.text("Remove all")}</span>\n </div>`);l.createEditor(e,"div",p),p.find(".vi-wbe-gallery-images").sortable({items:"li.vi-wbe-gallery-image",cursor:"move",scrollSensitivity:40,forcePlaceholderSize:!0,forceHelperSize:!1,helper:"clone",placeholder:"vi-wbe-sortable-placeholder",tolerance:"pointer"}),p.on("click",".vi-wbe-remove-image",(function(){i(this).parent().remove()})),p.on("click",".vi-wbe-add-image",(function(){o.open().off("select close").on("select",(function(e){o.state().get("selection").each((function(e){"image"===(e=e.toJSON()).type&&(n.imgStorage[e.id]=e.url,p.find(".vi-wbe-gallery-images").append(r.galleryImage(e.url,e.id)))}))}))})),p.on("click",".vi-wbe-remove-gallery",(function(){p.find(".vi-wbe-gallery-images").empty()})),0===d.length&&p.find(".vi-wbe-add-image").trigger("click")},updateCell(e,t,a){let n=i(e).find(".vi-wbe-gallery");return t.length?n.addClass("vi-wbe-gallery-has-item"):n.removeClass("vi-wbe-gallery-has-item"),t}},t.download={createCell:(e,t,a)=>(i(e).html('<div><i class="download icon"> </i></div>'),e),closeEditor(e,t){let a=[];if(t){let t=i(e).children();t.find("table.vi-wbe-files-download tbody tr").each((function(){let e=i(this);a.push({id:e.find(".vi-wbe-file-hash").val(),file:e.find(".vi-wbe-file-url").val(),name:e.find(".vi-wbe-file-name").val()})})),t.remove()}return a},openEditor(e,t,a){let n,o=e.getAttribute("data-y"),c=e.getAttribute("data-x"),d=a.options.data[o][c],u=i("<tbody></tbody>");if(Array.isArray(d))for(let e of d)u.append(r.fileDownload(e));let p=i(`<div class="">\n <table class="vi-wbe-files-download vi-ui celled table">\n <thead>\n <tr>\n <th>${l.text("Name")}</th>\n <th>${l.text("File URL")}</th>\n </tr>\n </thead>\n </table>\n <span class="vi-ui button tiny vi-wbe-add-file">${l.text("Add file")}</span>\n </div>`);p.find(".vi-wbe-files-download").append(u),l.createEditor(e,"div",p),u.sortable(),p.on("click",".vi-wbe-add-file",(()=>p.find(".vi-wbe-files-download tbody").append(r.fileDownload()))),p.on("click",".vi-wbe-choose-file",(function(){n=a.edition,a.edition=null;let e=i(this).closest("tr");s.open().off("select close").on("select",(function(t){let i=s.state().get("selection").first().toJSON();i.url&&e.find(".vi-wbe-file-url").val(i.url).trigger("change")})).on("close",(()=>a.edition=n))})),d.length||p.find(".vi-wbe-add-file").trigger("click")},updateCell:(e,t,a)=>(i(e).html('<div><i class="download icon"> </i></div>'),t)},t.tags={type:"tags",createCell:(e,t,i,a)=>(l.formatText(e,i),e),openEditor(e,t,a){let o=e.getAttribute("data-y"),s=e.getAttribute("data-x"),r=a.options.data[o][s],c=i("<select/>"),d=l.createEditor(e,"div",c);c.select2({data:r,multiple:!0,minimumInputLength:3,placeholder:l.text("Search tags..."),ajax:{url:n.ajaxUrl,type:"post",data:function(e){return{...n.ajaxData,sub_action:"search_tags",search:e.term,type:"public"}},processResults:function(e){return{results:e}}}}),c.find("option").attr("selected",!0).parent().trigger("change"),i(d).find(".select2-search__field").trigger("click")},closeEditor(e,t){let a=i(e).children(),n=a.find("select").select2("data"),o=[];if(n.length)for(let e of n)o.push({id:e.id,text:e.text});return a.remove(),i(".select2-container").remove(),o},updateCell:(e,t,i,a,n)=>(l.formatText(e,t),t)},t.link_products={createCell:(e,t,i,a)=>(l.formatText(e,i),e),closeEditor(e,t){let a=i(e).children(),n=[];if(t){let e=a.find("select").select2("data");if(e.length)for(let t of e)n.push({id:t.id,text:t.text})}return a.remove(),i(".select2-container").remove(),n},openEditor(e,t,a){let o=e.getAttribute("data-y"),s=e.getAttribute("data-x"),r=a.options.data[o][s],c=i("<select/>"),d=l.createEditor(e,"div",c);c.select2({data:r,multiple:!0,minimumInputLength:3,placeholder:l.text("Search products..."),ajax:{url:n.ajaxUrl,type:"post",delay:250,dataType:"json",data:function(e){return{...n.ajaxData,sub_action:"search_products",search:e.term,type:"public"}},processResults:function(e){var t=[];return e&&i.each(e,(function(e,i){t.push({id:e,text:i})})),{results:t}}}}),c.find("option").attr("selected",!0).parent().trigger("change"),i(d).find(".select2-search__field").trigger("click")},updateCell:(e,t,i,a,n)=>(l.formatText(e,t),t)},t.product_attributes={type:"product_attributes",createCell(e,t,a,n){let o=Object.keys(a).length?"vi-wbe-has-attrs":"";return i(e).html(`<div class="vi-wbe-product-attrs ${o}"><i class="icon edit"/></div>`),e},updateCell(e,t,a,n,o){let s=i(e).find(".vi-wbe-product-attrs");return Object.keys(t).length?s.addClass("vi-wbe-has-attrs"):s.removeClass("vi-wbe-has-attrs"),t},openEditor(e,t,a){let o=l.getDataFromCell(a,e),s=l.getProductTypeFromCell(e),r=this,c="";this.productType=s;let d=l.createModal({header:l.text("Edit attributes"),content:"",actions:[{class:"save-attributes",text:l.text("Save")}]});if(i(e).append(d),"variation"!==s){let{attributes:e}=n,t=`<option value="">${l.text("Custom product attribute")}</option>`;for(let i in e)t+=`<option value="${i}">${e[i].data.attribute_label}</option>`;if(t=`<div class="vi-wbe-taxonomy-header">\n <select class="vi-wbe-select-taxonomy">${t}</select>\n <span class="vi-ui button tiny vi-wbe-add-taxonomy">${l.text("Add")}</span>\n </div>`,Array.isArray(o)&&o.length)for(let e of o)c+=r.createRowTable(e);c=`${t}\n <table class="vi-ui celled table">\n <thead>\n <tr>\n <th>Name</th>\n <th>Attributes</th>\n <th width="1">Actions</th>\n </tr>\n </thead>\n <tbody>${c}</tbody>\n </table>`,d.find(".content").append(c),d.find("table select").select2({multiple:!0}),d.find("tbody").sortable({items:"tr",cursor:"move",axis:"y",scrollSensitivity:40,forcePlaceholderSize:!0,helper:"clone",handle:".icon.move"});const a=()=>{d.find("select.vi-wbe-select-taxonomy option").removeAttr("disabled"),d.find("input[type=hidden]").each((function(e,t){let a=i(t).val();d.find(`select.vi-wbe-select-taxonomy option[value='${a}']`).attr("disabled","disabled")}))};a(),d.on("click",(function(e){let t=i(e.target);if(t.hasClass("trash")&&(t.closest("tr").remove(),a()),t.hasClass("vi-wbe-add-taxonomy")){let e=i(".vi-wbe-select-taxonomy"),t=e.val(),n={name:t,options:[]};t&&(n.is_taxonomy=1);let o=i(r.createRowTable(n));d.find("table tbody").append(o),o.find("select").select2({multiple:!0}),a(),e.val("").trigger("change")}if(t.hasClass("vi-wbe-select-all-attributes")){let e=t.closest("td").find("select");e.find("option").attr("selected",!0),e.trigger("change")}if(t.hasClass("vi-wbe-select-no-attributes")){let e=t.closest("td").find("select");e.find("option").attr("selected",!1),e.trigger("change")}if(t.hasClass("vi-wbe-add-new-attribute")){let e=prompt(l.text("Enter a name for the new attribute term:"));if(!e)return;let i=t.closest("tr.vi-wbe-attribute-row"),a=i.attr("data-attr");a&&(a=JSON.parse(a),l.ajax({data:{sub_action:"add_new_attribute",taxonomy:a.name,term:e},beforeSend(){t.addClass("loading")},success(e){if(t.removeClass("loading"),e.success){let t=i.find("select");t.append(`<option value="${e.data.term_id}" selected>${e.data.name}</option>`),t.trigger("change"),n.attributes[a.name].terms[e.data.term_id]={slug:e.data.slug,text:e.data.name}}else alert(e.data.message)}}))}}))}else{let t,i=e.getAttribute("data-y"),s=a.options.data[i][1],r=a.getData();for(let e in r)if(s==r[e][0]){let i=n.idMappingFlip.attributes;t=a.options.data[e][i];break}if(t)for(let e of t){let t,i=`<option value="">${l.text("Any...")}</option>`,a=e.name;if(e.is_taxonomy){let s=n.attributes[a];for(let t of e.options){let e=s.terms[t],n=e.slug===o[a]?"selected":"";i+=`<option value="${e.slug}" ${n}>${e.text}</option>`}t=s.data.attribute_label}else{for(let t of e.options)i+=`<option value="${t}" ${t===o[a]?"selected":""}>${t}</option>`;t=a}c+=`<tr><td>${t}</td><td><select name="${a}">${i}</select></td></tr>`}c=`<table class="vi-ui celled table">\n <thead>\n <tr>\n <th>${l.text("Attribute")}</th>\n <th>${l.text("Option")}</th>\n </tr>\n </thead>\n <tbody>\n ${c}\n </tbody>\n </table>`,d.find(".content").append(c)}d.on("click",(function(t){let n=i(t.target);(n.hasClass("close")||n.hasClass("vi-wbe-modal-container"))&&a.closeEditor(e,!1),n.hasClass("save-attributes")&&a.closeEditor(e,!0)}))},closeEditor(e,t){let a=[];return!0===t&&("variation"!==this.productType?i(e).find(".vi-wbe-attribute-row").each((function(e,t){let n=i(t).data("attr");if(n.is_taxonomy)n.options=i(t).find("select").val().map(Number);else{n.name=i(t).find("input.custom-attr-name").val();let e=i(t).find("textarea.custom-attr-val").val();n.value=e.trim().replace(/\s+/g," "),n.options=e.split("|").map((e=>e.trim().replace(/\s+/g," ")))}n.visible=!!i(t).find(".attr-visibility:checked").length,n.variation=!!i(t).find(".attr-variation:checked").length,n.position=e,a.push(n)})):(a={},i(e).find("select").each((function(e,t){a[i(t).attr("name")]=i(t).val()})))),l.removeModal(e),a},createRowTable(e){let t="",i="";if(e.is_taxonomy){let a=n.attributes[e.name],o=a.terms||[],s="";if(t=`${a.data.attribute_label}<input type="hidden" value="${e.name}"/>`,Object.keys(o).length)for(let t in o)s+=`<option value="${t}" ${e.options.includes(parseInt(t))?"selected":""}>${o[t].text}</option>`;i=`<select multiple>${s}</select>\n <div class="vi-wbe-attributes-button-group">\n <span class="vi-ui button mini vi-wbe-select-all-attributes">${l.text("Select all")}</span>\n <span class="vi-ui button mini vi-wbe-select-no-attributes">${l.text("Select none")}</span>\n <span class="vi-ui button mini vi-wbe-add-new-attribute">${l.text("Add new")}</span>\n </div>`}else t=`<input type="text" class="custom-attr-name" value="${e.name}" placeholder="${l.text("Custom attribute name")}"/>`,i=`<textarea class="custom-attr-val" placeholder="${l.text('Enter some text, or some attributes by "|" separating values.')}">${e.value||""}</textarea>`;return t=`<div class="vi-wbe-attribute-name-label">${t}</div>`,t+=`<div>\n <input type="checkbox" class="attr-visibility" ${e.visible?"checked":""} value="1">\n <label>${l.text("Visible on the product page")}</label>\n </div>`,"variable"===this.productType&&(t+=`<div>\n <input type="checkbox" class="attr-variation" ${e.variation?"checked":""} value="1">\n <label>${l.text("Used for variations")}</label>\n </div>`),`<tr class="vi-wbe-attribute-row" data-attr='${JSON.stringify(e)}'>\n <td class="vi-wbe-left">${t}</td>\n <td>${i}</td>\n <td class="vi-wbe-right"><i class="icon trash"> </i> <i class="icon move"> </i></td>\n </tr>`}},t.default_attributes={createCell:(e,t,a,n)=>(a&&i(e).text(Object.values(a).filter(Boolean).join("; ")),e),updateCell:(e,t,a,n,o)=>(t?i(e).text(Object.values(t).filter(Boolean).join("; ")):i(e).text(""),t),openEditor(t,a,o){let s=l.getDataFromCell(o,t),r=l.getProductTypeFromCell(t),c="";if(this.productType=r,"variable"===r){let a=l.createModal({header:l.text("Set default attributes"),content:"",actions:[{class:"save-attributes",text:l.text("Save")}]});i(t).append(a);let r=t.getAttribute("data-y"),d=n.idMappingFlip.attributes,u=o.options.data[r][d];if(Array.isArray(u)&&u.length)for(let e of u){if(0===e.options.length)continue;let t="",i="";if(e.is_taxonomy){let a=n.attributes[e.name];t=a.data.attribute_label;for(let t of e.options){let n=a.terms[t],o=n.slug===s[e.name]?"selected":"";i+=`<option value="${n.slug}" ${o}>${n.text}</option>`}}else{t=e.name;for(let t of e.options)i+=`<option value="${t}" ${t===s[e.name]?"selected":""}>${t}</option>`}i=`<option value="">No default ${t}</option> ${i}`,c+=`<tr><td>${t}</td><td><select name="${e.name}" class="vi-wbe-default-attribute">${i}</select></td></tr>`}a.find(".content").append(e.defaultAttributes({html:c})),a.on("click",(function(e){let a=i(e.target);(a.hasClass("close")||a.hasClass("vi-wbe-modal-container"))&&o.closeEditor(t,!1),a.hasClass("save-attributes")&&o.closeEditor(t,!0)}))}},closeEditor(e,t){let a={};return!0===t&&i(e).find(".vi-wbe-default-attribute").each(((e,t)=>a[i(t).attr("name")]=i(t).val())),l.removeModal(e),a}},t.array={createCell:(e,t,a,n)=>(i(e).html(a?JSON.stringify(a):a),e),closeEditor(e,t){let i=[];return!0===t&&(i=this.editor.get()),l.removeModal(e),i},openEditor(e,t,a){let n=l.getDataFromCell(a,e),o=l.createModal({header:l.text("Edit metadata"),content:"",actions:[{class:"save-metadata",text:l.text("Save")}]});i(e).append(o),o.find(".content").html('<div id="vi-wbe-jsoneditor"></div>');let s=o.find("#vi-wbe-jsoneditor").get(0);this.editor=new JSONEditor(s,{enableSort:!1,search:!1,enableTransform:!1}),this.editor.set(n),o.on("click",(function(t){let n=i(t.target);(n.hasClass("close")||n.hasClass("vi-wbe-modal-container"))&&a.closeEditor(e,!1),n.hasClass("save-metadata")&&a.closeEditor(e,!0)}))},updateCell:(e,t,a)=>(i(e).html(t?JSON.stringify(t):t),t)},t.order_notes={createCell(e,t,a,n){let o=a.length?"vi-wbe-gallery-has-item":"";return i(e).html(`<div class="${o}"><i class="icon eye"/></div>`),this.obj=n,e},closeEditor(e,t){return i(e).find(".vi-wbe-cell-popup").remove(),this.notes},openEditor(e,t,a){let n=e.getAttribute("data-y"),o=e.getAttribute("data-x"),s=a.options.data[n][o],r="";if(this.notes=s,s.length)for(let e of s){let t=e.content.replace(/(?:\r\n|\r|\n)/g,"<br>");r+=`<div class="vi-wbe-note-row">\n <div class="vi-wbe-note-row-content ${e.customer_note?"customer":"system"===e.added_by?"system":"private"}">${t}</div>\n <span class="vi-wbe-note-row-meta">\n ${e.date}\n <a href="#" data-comment_id="${e.id}" class="vi-wbe-note-row-delete">${l.text("Delete")}</a>\n </span>\n </div>`}let c=i(`<div class="vi-wbe-cell-popup-inner">${r}</div>`);l.createEditor(e,"div",c),c.on("click",".vi-wbe-note-row-delete",(function(){let e=i(this),t=e.data("comment_id");t&&l.ajax({data:{sub_action:"delete_order_note",id:t},beforeSend(){l.loading()},success(i){if(i.success){let i=s.findIndex((e=>e.id===t));s.splice(i,1),e.closest(".vi-wbe-note-row").remove()}l.removeLoading()}})}))},updateCell:(e,t,i)=>t},t.select2={type:"select2",createCell(e,t,i,a){let{source:n}=a.options.columns[t],o=[];return Array.isArray(n)&&n.length&&(o=n.filter((e=>i.includes(e.id)))),l.formatText(e,o),e},openEditor(e,t,a){let n=e.getAttribute("data-y"),o=e.getAttribute("data-x"),s=a.options.data[n][o],r=i("<select/>"),{source:c,multiple:d,placeholder:u}=a.options.columns[o],p=l.createEditor(e,"div",r);r.select2({data:c||[],multiple:d,placeholder:u}),r.val(s).trigger("change"),i(p).find(".select2-search__field").trigger("click")},closeEditor(e,t){let a=i(e).children(),n=a.find("select").val();return n=n.map((e=>isNaN(e)?e:+e)),a.remove(),i(".select2-container").remove(),n},updateCell(e,t,i,a,n){let{source:o}=a.options.columns[n],s=[];return Array.isArray(o)&&o.length&&(s=o.filter((e=>t.includes(e.id)))),l.formatText(e,s),t}},a.sourceForVariation=(e,t,i,a,n)=>{let o=n.options.columns[i].source;return"variation"===l.getProductTypeFromCell(t)&&(o=n.options.columns[i].subSource),o}}));const n={...wbeParams,productTypes:{},filterKey:Date.now(),selectPage:1,ajaxData:{action:"vi_wbe_ajax",vi_wbe_nonce:wbeParams.nonce},tinyMceOptions:{tinymce:{theme:"modern",skin:"lightgray",language:"en",formats:{alignleft:[{selector:"p,h1,h2,h3,h4,h5,h6,td,th,div,ul,ol,li",styles:{textAlign:"left"}},{selector:"img,table,dl.wp-caption",classes:"alignleft"}],aligncenter:[{selector:"p,h1,h2,h3,h4,h5,h6,td,th,div,ul,ol,li",styles:{textAlign:"center"}},{selector:"img,table,dl.wp-caption",classes:"aligncenter"}],alignright:[{selector:"p,h1,h2,h3,h4,h5,h6,td,th,div,ul,ol,li",styles:{textAlign:"right"}},{selector:"img,table,dl.wp-caption",classes:"alignright"}],strikethrough:{inline:"del"}},relative_urls:!1,remove_script_host:!1,convert_urls:!1,browser_spellcheck:!0,fix_list_elements:!0,entities:"38,amp,60,lt,62,gt",entity_encoding:"raw",keep_styles:!1,cache_suffix:"wp-mce-49110-20201110",resize:"vertical",menubar:!1,branding:!1,preview_styles:"font-family font-size font-weight font-style text-decoration text-transform",end_container_on_empty_block:!0,wpeditimage_html5_captions:!0,wp_lang_attr:"en-US",wp_keep_scroll_position:!1,wp_shortcut_labels:{"Heading 1":"access1","Heading 2":"access2","Heading 3":"access3","Heading 4":"access4","Heading 5":"access5","Heading 6":"access6",Paragraph:"access7",Blockquote:"accessQ",Underline:"metaU",Strikethrough:"accessD",Bold:"metaB",Italic:"metaI",Code:"accessX","Align center":"accessC","Align right":"accessR","Align left":"accessL",Justify:"accessJ",Cut:"metaX",Copy:"metaC",Paste:"metaV","Select all":"metaA",Undo:"metaZ",Redo:"metaY","Bullet list":"accessU","Numbered list":"accessO","Insert/edit image":"accessM","Insert/edit link":"metaK","Remove link":"accessS","Toolbar Toggle":"accessZ","Insert Read More tag":"accessT","Insert Page Break tag":"accessP","Distraction-free writing mode":"accessW","Add Media":"accessM","Keyboard Shortcuts":"accessH"},plugins:"charmap,colorpicker,hr,lists,media,paste,tabfocus,textcolor,fullscreen,wordpress,wpautoresize,wpeditimage,wpemoji,wpgallery,wplink,wpdialogs,wptextpattern,wpview",selector:"#vi-wbe-text-editor",wpautop:!0,indent:!1,toolbar1:"formatselect,bold,italic,bullist,numlist,blockquote,alignleft,aligncenter,alignright,link,wp_more,spellchecker,fullscreen,wp_adv",toolbar2:"strikethrough,hr,forecolor,pastetext,removeformat,charmap,outdent,indent,undo,redo,wp_help",tabfocus_elements:":prev,:next",body_class:"excerpt post-type-product post-status-publish page-template-default locale-en-us"},mediaButtons:!0,quicktags:!0},setColumns(e){try{let i=JSON.parse(e);n.columns=i.map((e=>(e&&e.editor&&t[e.editor]&&(e.editor=t[e.editor]),e&&e.filter&&a[e.filter]&&(e.filter=a[e.filter]),e)))}catch(e){console.log(e)}}};window.Attributes=n;const o=wbeI18n.i18n,s=jQuery,l={setJexcel(e){this.jexcel=e},text:e=>o[e]||e,isUrl:e=>/^(http(s?):)\/\/.*\.(?:jpg|jpeg|gif|png|webp)$/i.test(e),formatText(e,t){let i="";if(t.length)for(let e=0;e<t.length;e++)t[e]&&(i+=t[e].text+"; ");e.innerText=i},createEditor(e,t,i="",a=!0){let n=document.createElement(t);"div"===t&&s(n).append(i),n.style.minWidth="300px";let o=s(n).innerHeight(),l=s(e).offset(),r=l.left,c=l.top,d=s(e).innerWidth(),u=e.getBoundingClientRect();a?(n.style.minHeight=u.height-2+"px",n.style.maxHeight=window.innerHeight-c-50+"px"):(n.style.opacity=0,n.style.fontSize=0),n.classList.add("vi-ui","segment","vi-wbe-cell-popup","vi-wbe-editing"),e.classList.add("editor"),e.appendChild(n);let p=s(n).innerWidth();if(s(this.jexcel.el).innerWidth()<r+p+d){let e=r-p>0?r-p:10;s(n).css("left",e+"px")}else s(n).css("left",r+d+"px");if(window.innerHeight<c+o){let e=c-o<0?0:c-o;s(n).css("top",e+"px")}else s(n).css("top",c+"px");return n},createModal(t={}){let{actions:i}=t,a="";if(Array.isArray(i))for(let e of i)a+=`<span class="${e.class} vi-ui button tiny">${e.text}</span>`;return s(e.modal({...t,actionsHtml:a}))},removeModal(e){s(e).find(".vi-wbe-modal-container").remove(),s(".select2-container--open").remove()},getColFromColumnType:e=>n.idMappingFlip[e]||"",getProductTypeFromCell(e){let t=e.getAttribute("data-y"),i=this.getColFromColumnType("product_type");return this.jexcel.options.data[t][i]},getProductTypeFromY(e){let t=this.getColFromColumnType("product_type");return this.jexcel.options.data[e][t]},getColumnType:e=>n.idMapping[e],stripHtml:e=>s(`<div>${e}</div>`).text(),getDataFromCell(e,t){let i=t.getAttribute("data-y"),a=t.getAttribute("data-x");return e.options.data[i][a]},getProductIdOfCell(e,t){if("object"==typeof t){let i=t.getAttribute("data-y");return e.options.data[i][0]}return e.options.data[t][0]},ajax(e={}){let t=Object.assign({url:wbeParams.ajaxUrl,type:"post",dataType:"json"},e);t.data.action="vi_wbe_ajax",t.data.vi_wbe_nonce=wbeParams.nonce,t.data.type=wbeParams.editType,s.ajax(t)},pagination(e,t){let i="",a=`<a class="item ${1===(t=parseInt(t))?"disabled":""}" data-page="${t-1}"><i class="icon angle left"> </i></a>`,n=`<a class="item ${t===(e=parseInt(e))?"disabled":""}" data-page="${t+1}"><i class="icon angle right"> </i></a>`,o=`<input type="number" class="vi-wbe-go-to-page" value="${t}" min="1" max="${e}"/>`;for(let a=1;a<=e;a++)[1,t-1,t,t+1,e].includes(a)&&(i+=`<a class="item ${t===a?"active":""}" data-page="${a}">${a}</a>`),a===t-2&&t-2>1&&(i+='<a class="item disabled">...</a>'),a===t+2&&t+2<e&&(i+='<a class="item disabled">...</a>');return`<div class="vi-ui pagination menu">${a} ${i} ${n} </div> ${o}`},spinner:()=>s('<span class="vi-wbe-spinner"><span class="vi-wbe-spinner-inner"> </span></span>'),is_loading(){return!!this._spinner},loading(){this._spinner=this.spinner(),s(".vi-wbe-menu-bar-center").html(this._spinner)},removeLoading(){this._spinner=null,s(".vi-wbe-menu-bar-center").html("")},notice(e,t="black"){let i=s(`<div class="vi-wbe-notice" style="color:${t}">${e}</div>`);s(".vi-wbe-menu-bar-center").html(i),setTimeout((function(){i.remove()}),5e3)},generateCouponCode(){let e="";for(var t=0;t<n.couponGenerate.char_length;t++)e+=n.couponGenerate.characters.charAt(Math.floor(Math.random()*n.couponGenerate.characters.length));return e=n.couponGenerate.prefix+e+n.couponGenerate.suffix,e}},r=jQuery;let c=null;class d{constructor(e,t){c||r("body").on("mousedown keydown",this.mousedown),c=this,this.popup=r(".vi-wbe-context-popup"),this.render(e,r(t))}mousedown(e){let t=r(e.target),i=r(".vi-wbe-context-popup");(27===e.which||!t.hasClass("vi-wbe-context-popup")&&0===t.closest(".vi-wbe-context-popup").length&&i.hasClass("vi-wbe-popup-active")&&!t.hasClass("select2-search__field"))&&(i.empty().removeClass("vi-wbe-popup-active"),r(".select2-container.select2-container--default.select2-container--open").remove())}render(e,t){let{popup:i}=this,a=t.offset(),n=a.left,o=a.top,s=t.innerWidth();i.empty(),i.addClass("vi-wbe-popup-active").html(e);let l=i.innerWidth(),c=i.innerHeight();if(window.innerWidth<n+l+s){let e=n-l>0?n-l:10;i.css("left",e+"px")}else i.css("left",n+s+"px");if(r("#vi-wbe-editor").innerHeight()<o+c){let e=o-c<0?0:o-c;i.css("top",e+"px")}else i.css("top",o+"px")}hide(){this.popup.removeClass("vi-wbe-popup-active")}}const u=jQuery;class p{constructor(e,t,i,a){this._data={},this._data.jexcel=e,this._data.x=parseInt(t),this._data.y=parseInt(i),this.run()}get(e){return this._data[e]||""}run(){let e=this.content(),t=u(`td[data-x=${this.get("x")||0}][data-y=${this.get("y")||0}]`);new d(e,t),e.on("click",".vi-wbe-apply-formula",this.applyFormula.bind(this)),e.on("change",".vi-wbe-rounded",this.toggleDecimalValue)}content(){return u(`<div class="vi-wbe-formula-container" style="display: flex;">\n <select class="vi-wbe-operator">\n <option value="+">+</option>\n <option value="-">-</option>\n </select>\n <input type="number" min="0" class="vi-wbe-value">\n <select class="vi-wbe-unit">\n <option value="fixed">n</option>\n <option value="percentage">%</option>\n </select>\n <select class="vi-wbe-rounded">\n <option value="no_round">${l.text("No round")}</option>\n <option value="round">${l.text("Round with decimal")}</option>\n <option value="round_up">${l.text("Round up")}</option>\n <option value="round_down">${l.text("Round down")}</option>\n </select>\n <input type="number" min="0" max="10" class="vi-wbe-decimal" value="0">\n <button type="button" class="vi-ui button mini vi-wbe-apply-formula">${l.text("OK")}</button>\n </div>`)}applyFormula(e){let t=u(e.target).closest(".vi-wbe-formula-container"),i=t.find(".vi-wbe-operator").val(),a=parseFloat(t.find(".vi-wbe-value").val()),n=t.find(".vi-wbe-unit").val(),o=t.find(".vi-wbe-rounded").val(),s=parseInt(t.find(".vi-wbe-decimal").val()),l=this.get("jexcel");if(!a)return;let r=[],c=l.selectedContainer,d=c[1],p=c[3],h=c[0];function m(e){e=parseFloat(e.replace(",","."));let t="percentage"===n?e*a/100:a,l="-"===i?e-t:e+t;switch(o){case"round":l=l.toFixed(s);break;case"round_up":l=Math.ceil(l);break;case"round_down":l=Math.floor(l)}return l}for(let e=d;e<=p;e++)if(l.records[e][h]&&!l.records[e][h].classList.contains("readonly")&&"none"!==l.records[e][h].style.display){let t=l.options.data[e][h]||0;r.push(l.updateCell(h,e,m(t))),l.updateFormulaChain(h,e,r)}l.setHistory({action:"setValue",records:r,selection:l.selectedCell}),l.updateTable()}toggleDecimalValue(){let e=u(this).closest(".vi-wbe-formula-container");e.find(".vi-wbe-decimal").hide(),"round"===u(this).val()&&e.find(".vi-wbe-decimal").show()}}class h{constructor(e,t,i,a){this._data={},this._data.jexcel=e,this._data.x=parseInt(t),this._data.y=parseInt(i),this.run()}get(e){return this._data[e]||""}run(){let e=this.content(),t=u(`td[data-x=${this.get("x")||0}][data-y=${this.get("y")||0}]`);new d(e,t),e.on("click",".vi-wbe-apply-formula",this.applyFormula.bind(this)),e.on("change",".vi-wbe-rounded",this.toggleDecimalValue)}content(){return u(`<div class="vi-wbe-formula-container" style="display: flex;">\n <span class="vi-wbe-operator vi-ui button basic small icon"><i class="icon minus"> </i></span>\n <input type="number" min="0" class="vi-wbe-value">\n <select class="vi-wbe-unit">\n <option value="percentage">%</option>\n <option value="fixed">n</option>\n </select>\n <select class="vi-wbe-rounded">\n <option value="no_round">${l.text("No round")}</option>\n <option value="round">${l.text("Round with decimal")}</option>\n <option value="round_up">${l.text("Round up")}</option>\n <option value="round_down">${l.text("Round down")}</option>\n </select>\n <input type="number" min="0" max="10" class="vi-wbe-decimal" value="0">\n <button type="button" class="vi-ui button mini vi-wbe-apply-formula">${l.text("OK")}</button>\n </div>`)}applyFormula(e){let t=u(e.target).closest(".vi-wbe-formula-container"),i=parseFloat(t.find(".vi-wbe-value").val()),a=t.find(".vi-wbe-unit").val(),n=t.find(".vi-wbe-rounded").val(),o=parseInt(t.find(".vi-wbe-decimal").val()),s=this.get("jexcel");if(!i)return;let l=[],r=s.selectedContainer,c=r[1],d=r[3],p=r[0];function h(e){let t=(e=parseFloat(e.replace(",",".")))-("percentage"===a?e*i/100:i);switch(t=t>0?t:0,n){case"round":t=t.toFixed(o);break;case"round_up":t=Math.ceil(t);break;case"round_down":t=Math.floor(t)}return t}for(let e=c;e<=d;e++)if(s.records[e][p]&&!s.records[e][p].classList.contains("readonly")&&"none"!==s.records[e][p].style.display){let t=s.options.data[e][p-1]||0;l.push(s.updateCell(p,e,h(t))),s.updateFormulaChain(p,e,l)}s.setHistory({action:"setValue",records:l,selection:s.selectedCell}),s.updateTable()}toggleDecimalValue(){let e=u(this).closest(".vi-wbe-formula-container");e.find(".vi-wbe-decimal").hide(),"round"===u(this).val()&&e.find(".vi-wbe-decimal").show()}}const m=jQuery,b={init(){return m(".vi-ui.menu .item").vi_tab(),m(".bulky-sort-fields-accordion").vi_accordion(),m("#bulky-sort-fields").sortable({axis:"y",containment:"parent"}),this.revision={},this.sidebar=m("#vi-wbe-sidebar"),this.historyBodyTable=m("#vi-wbe-history-points-list tbody"),this.sidebar.on("click",".vi-wbe-apply-filter",this.applyFilter.bind(this)),this.sidebar.on("click",".vi-wbe-filter-label",this.filterInputLabelFocus),this.sidebar.on("focus",".vi-wbe-filter-input",this.filterInputFocus),this.sidebar.on("blur",".vi-wbe-filter-input",this.filterInputBlur),this.sidebar.on("click",".vi-wbe-get-meta-fields",this.getMetaFields.bind(this)),this.sidebar.on("click",".vi-wbe-save-meta-fields:not(.loading)",this.saveMetaFields.bind(this)),this.sidebar.on("click",".vi-wbe-add-new-meta-field",this.addNewMetaField.bind(this)),this.sidebar.find("table.vi-wbe-meta-fields-container tbody").sortable({axis:"y"}),this.sidebar.find("table.vi-wbe-meta-fields-container").on("click",".vi-wbe-remove-meta-row",this.removeMetaRow),this.sidebar.on("click",".vi-wbe-save-taxonomy-fields:not(.loading)",this.saveTaxonomyFields),this.sidebar.on("click",".vi-wbe-save-settings",this.saveSettings.bind(this)),this.sidebar.on("click",".vi-wbe-view-history-point",this.viewHistoryPoint.bind(this)),this.sidebar.on("click",".vi-wbe-recover",this.recover.bind(this)),this.sidebar.on("click",".vi-wbe-revert-this-point",this.revertAllProducts.bind(this)),this.sidebar.on("click",".vi-wbe-revert-this-key",this.revertProductAttribute.bind(this)),this.sidebar.on("click",".vi-wbe-pagination a.item",this.changePage.bind(this)),this.sidebar.on("change",".vi-wbe-go-to-page",this.changePageByInput.bind(this)),this.sidebar.on("click",".vi-wbe-multi-select-clear",this.clearMultiSelect),this.sidebar.on("change",".vi-wbe-meta-column-type",this.metaFieldChangeType),this.sidebar.on("keyup",".vi-wbe-search-metakey",this.searchMetaKey),this.filter(),this.settings(),this.metafields(),this.history(),this.sidebar},filter(){let e=m("#vi-wbe-products-filter"),t=m(".vi-wbe-filter-input"),i={top:-2},a={top:"50%"};t.each(((e,t)=>{m(t).val()&&m(t).parent().prev().css(i)})),t.on("focus",(function(){let e=m(this).prev();e.css(i),m(this).on("blur",(function(){m(this).val()||e.css(a)}))})),this.sidebar.on("click",".vi-wbe-filter-label",(function(){m(this).next().trigger("focus")}));let n=e.find(".vi-wbe.vi-ui.dropdown").dropdown({clearable:!0}),o=e.find(".vi-ui.compact.dropdown").dropdown();this.sidebar.on("click",".vi-wbe-clear-filter",(function(){m(".vi-wbe-filter-label").css(a),t.val(""),n.dropdown("clear"),o.find(".menu .item:first").trigger("click")})),this.sidebar.on("change","#vi-wbe-has_expire_date",(function(){let e=m(".vi-wbe-expire-date-group");"yes"===m(this).val()?e.show():e.hide()})),this.sidebar.find("#vi-wbe-has_expire_date").trigger("change")},settings(){m(".vi-wbe-settings-tab").find("select.dropdown").dropdown()},metafields(){this.renderMetaFieldsTable(n.metaFields)},history(){this.pagination(1)},pagination(e,t=n.historyPages){this.sidebar.find(".vi-wbe-pagination").html(l.pagination(t,e))},applyFilter(e){let t=this,i=m(e.target);i.hasClass("loading")||l.ajax({data:{sub_action:"add_filter_data",filter_data:m("#vi-wbe-products-filter").serialize(),filter_key:n.filterKey},beforeSend(){i.addClass("loading")},success(e){i.removeClass("loading"),t.sidebar.trigger("afterAddFilter",[e.data])}})},limitProductPerPage(){let e=m(this).val();e>50&&m(this).val(50),e<0&&m(this).val(0)},saveSettings(e){let t=this,i=m(e.target);i.hasClass("loading")||l.ajax({data:{sub_action:"save_settings",fields:m("form.vi-wbe-settings-tab").serialize()},beforeSend(){i.addClass("loading")},success(e){e.success&&(n.settings=e.data.settings,t.sidebar.trigger("afterSaveSettings",[e.data])),i.removeClass("loading")}})},filterInputLabelFocus(){m(this).next().find("input").trigger("focus")},filterInputFocus(){m(this).parent().prev().css({top:-2})},filterInputBlur(){m(this).val()||m(this).parent().prev().css({top:"50%"})},getMetaFields(e){let t=this,i=m(e.target);i.hasClass("loading")||l.ajax({data:{sub_action:"get_meta_fields",current_meta_fields:t.getCurrentMetaFields()},beforeSend(){i.addClass("loading")},success(e){t.renderMetaFieldsTable(e.data),n.metaFields=e.data,i.removeClass("loading")}})},renderMetaFieldsTable(e){let t="";for(let i in e)t+=this.renderRow(i,e);m(".vi-wbe-meta-fields-container tbody").html(t)},renderRow(e,t){let i=t[e]||{},a="",n=i.input_type||"",o={textinput:"Text input",texteditor:"Text editor",numberinput:"Number input",array:"Array",json:"JSON",checkbox:"Checkbox",calendar:"Calendar",image:"Image",select:"Select",multiselect:"Multiselect"},s=i.meta_value||"",l=s.slice(0,15),r=s.length>16?`<div class="vi-wbe-full-meta-value">${s}</div>`:"",c="";for(let e in o)a+=`<option value="${e}" ${e===n?"selected":""}>${o[e]}</option>`;return l+=l.length<s.length?"...":"","select"!==n&&"multiselect"!==n||(c+=`<textarea class="vi-wbe-select-options">${i.select_options}</textarea>`),`<tr>\n <td class="vi-wbe-meta-key">${e}</td>\n <td><input type="text" class="vi-wbe-meta-column-name" value="${i.column_name||""}"></td>\n <td>\n <div class="vi-wbe-display-meta-value">\n <div class="vi-wbe-short-meta-value">${l}</div>\n ${r}\n </div>\n </td>\n <td>\n <select class="vi-wbe-meta-column-type">${a}</select>\n ${c}\n </td>\n <td class="vi-wbe-meta-field-active-column">\n <div class="vi-ui toggle checkbox">\n <input type="checkbox" class="vi-wbe-meta-column-active" ${parseInt(i.active)?"checked":""}>\n <label> </label>\n </div> \n </td>\n <td>\n <div class="vi-wbe-meta-field-actions">\n <span class="vi-ui button basic mini vi-wbe-remove-meta-row"><i class="icon trash"> </i></span>\n <span class="vi-ui button basic mini"><i class="icon move"> </i></span>\n </div>\n </td>\n </tr>`},metaFieldChangeType(){let e=m('<textarea class="vi-wbe-select-options"></textarea>'),t=m(this).val(),i=m(this).siblings();"select"===t||"multiselect"===t?i.length||m(this).after(e):i.remove()},searchMetaKey(){let e=m(this).val().toLowerCase();m(".vi-wbe-meta-fields-container tbody tr").each((function(t,i){m(i).find(".vi-wbe-meta-key").text().trim().toLowerCase().indexOf(e)>-1?m(i).show():m(i).hide()}))},saveMetaFields(e){let t=m(e.target);t.hasClass("loading")||l.ajax({data:{sub_action:"save_meta_fields",meta_fields:this.getCurrentMetaFields()},beforeSend(){t.addClass("loading")},success(e){t.removeClass("loading"),location.reload()},error(e){console.log(e)}})},getCurrentMetaFields(){let e={},t=n.metaFields;return m("table.vi-wbe-meta-fields-container tbody tr").each((function(i,a){let n=m(a).find(".vi-wbe-meta-key").text();e[n]={column_name:m(a).find(".vi-wbe-meta-column-name").val(),input_type:m(a).find(".vi-wbe-meta-column-type").val(),active:m(a).find(".vi-wbe-meta-column-active:checked").length,meta_value:t[n]?t[n].meta_value:"",select_options:m(a).find(".vi-wbe-select-options").val()}})),e},addNewMetaField(e){let t=m(e.currentTarget).prev(),i=t.val(),a=i.match(/^[\w\d_-]*$/g);if(!i||!a||n.metaFields[i])return;let o=this.renderRow(i,{});o&&(t.val(""),m("table.vi-wbe-meta-fields-container tbody").append(o))},removeMetaRow(){m(this).closest("tr").remove()},saveTaxonomyFields(e){let t=m(e.target),i=[];m("table.vi-wbe-taxonomy-fields .vi-wbe-taxonomy-active:checked").each((function(e,t){let a=m(this).closest("tr").find(".vi-wbe-taxonomy-key").text();i.push(a)})),l.ajax({data:{sub_action:"save_taxonomy_fields",taxonomy_fields:i},beforeSend(){t.addClass("loading")},success(e){t.removeClass("loading"),location.reload()},error(e){console.log(e)}})},viewHistoryPoint(e){let t=m(e.currentTarget),i=t.data("id"),a=this;t.hasClass("loading")||l.ajax({data:{sub_action:"view_history_point",id:i},beforeSend(){t.addClass("loading")},complete(){},success(e){if(t.removeClass("loading"),e.success&&e.data){let t=e.data.compare,n="";for(let e in t){let i=t[e];n+=`<div class="vi-wbe-history-product" data-product_id="${e}">\n <div class="title">\n <i class="dropdown icon"></i>\n ${i.name}\n <span class="vi-ui button mini basic vi-wbe-revert-this-product">\n <i class="icon undo"> </i>\n </span>\n \n </div>`;let a="";for(let t in i.fields){let n="string"==typeof i.current[t]?i.current[t]:JSON.stringify(i.current[t]),o="string"==typeof i.history[t]?i.history[t]:JSON.stringify(i.history[t]);a+=`<tr>\n <td>${i.fields[t]}</td>\n <td>${n}</td>\n <td>${o}</td>\n <td class="">\n <span class="vi-ui button basic mini vi-wbe-revert-this-key" data-product_id="${e}" data-product_key="${t}">\n <i class="icon undo"> </i>\n </span>\n </td>\n </tr>`}a=`<table id="vi-wbe-history-point-detail" class="vi-ui celled table">\n <thead>\n <tr>\n <th>Attribute</th>\n <th>Current</th>\n <th>History</th>\n <th class="">Revert</th>\n </tr>\n </thead>\n <tbody>\n ${a}\n </tbody>\n </table>`,n+=`<div class="content">${a}</div></div>`}n=m(`<div class="vi-ui styled fluid accordion">${n}</div>`),m(".vi-wbe-history-review").html(n).attr("data-history_id",i).prepend(`<h4>History point: ${e.data.date}</h4>`).append(`<div class="vi-ui button tiny vi-wbe-revert-this-point">\n ${l.text("Revert all product in this point")}\n </div>\n <p> ${l.text("The current value is the value of the records in database")}</p>`),n.find(".title").on("click",(e=>a.revertSingleProduct(e))),n.vi_accordion(),n.find(".title:first").trigger("click")}}})},recover(e){let t=m(e.currentTarget),i=t.data("id");t.hasClass("loading")||l.ajax({data:{sub_action:"revert_history_all_products",history_id:i},beforeSend(){t.addClass("loading")},complete(){t.removeClass("loading")},success(e){console.log(e)}})},revertSingleProduct(e){let t;if(m(e.target).hasClass("vi-wbe-revert-this-product")&&(t=m(e.target)),m(e.target).parent().hasClass("vi-wbe-revert-this-product")&&(t=m(e.target).parent()),t){e.stopImmediatePropagation();let i=t.closest(".vi-wbe-history-product").data("product_id"),a=t.closest(".vi-wbe-history-review").data("history_id");if(t.hasClass("loading"))return;l.ajax({data:{sub_action:"revert_history_single_product",history_id:a,pid:i},beforeSend(){t.addClass("loading")},complete(){t.removeClass("loading")},success(e){console.log(e)}})}},revertAllProducts(e){let t=m(e.target),i=t.closest(".vi-wbe-history-review").data("history_id");t.hasClass("loading")||l.ajax({data:{sub_action:"revert_history_all_products",history_id:i},beforeSend(){t.addClass("loading")},complete(){t.removeClass("loading")},success(e){console.log(e)}})},revertProductAttribute(e){let t=m(e.currentTarget),i=t.data("product_key"),a=t.closest(".vi-wbe-history-product").data("product_id"),n=t.closest(".vi-wbe-history-review").data("history_id");t.hasClass("loading")||l.ajax({data:{sub_action:"revert_history_product_attribute",attribute:i,history_id:n,pid:a},beforeSend(){t.addClass("loading")},complete(){t.removeClass("loading")},success(e){console.log(e)}})},changePage(e){let t=parseInt(m(e.currentTarget).attr("data-page"));m(e.currentTarget).hasClass("active")||m(e.currentTarget).hasClass("disabled")||!t||this.loadHistoryPage(t)},changePageByInput(e){let t=parseInt(m(e.target).val());t<=parseInt(m(e.target).attr("max"))&&t>0&&this.loadHistoryPage(t)},clearMultiSelect(){m(this).parent().find(".vi-ui.dropdown").dropdown("clear")},loadHistoryPage(e){let t=l.spinner(),i=this;e&&l.ajax({dataType:"text",data:{sub_action:"load_history_page",page:e},beforeSend(){i.sidebar.find(".vi-wbe-pagination").prepend(t)},complete(){t.remove()},success(t){i.pagination(e),m("#vi-wbe-history-points-list tbody").html(t)}})}},f=jQuery;class v{constructor(e,t,i,a){this._data={},this._data.jexcel=e,this._data.x=parseInt(t),this._data.y=parseInt(i),this.run()}get(e){return this._data[e]||""}run(){let e=this.content(),t=f(`td[data-x=${this.get("x")||0}][data-y=${this.get("y")||0}]`);new d(e,t),e.on("click",".vi-wbe-apply-formula",this.applyFormula.bind(this))}content(){return f(`<div class="vi-wbe-formula-container">\n <div class="field">\n <input type="text" placeholder="${l.text("Find")}" class="vi-wbe-find-string">\n </div>\n <div class="field">\n <input type="text" placeholder="${l.text("Replace")}" class="vi-wbe-replace-string">\n </div>\n <button type="button" class="vi-ui button mini vi-wbe-apply-formula">${l.text("Replace")}</button>\n </div>`)}applyFormula(e){let t=f(e.target).closest(".vi-wbe-formula-container"),i=t.find(".vi-wbe-find-string").val(),a=t.find(".vi-wbe-replace-string").val(),n=this.get("jexcel");if(!i)return;let o=[],s=n.selectedContainer,l=s[1],r=s[3],c=s[0];for(let e=l;e<=r;e++)if(n.records[e][c]&&!n.records[e][c].classList.contains("readonly")&&"none"!==n.records[e][c].style.display){let t=n.options.data[e][c].replaceAll(i,a);o.push(n.updateCell(c,e,t)),n.updateFormulaChain(c,e,o)}n.setHistory({action:"setValue",records:o,selection:n.selectedCell}),n.updateTable()}}const g=jQuery;class w{constructor(e,t,i,a,n){this._data={},this._data.jexcel=e,this._data.x=parseInt(t),this._data.y=parseInt(i),this._wordWrap=n,this.run()}get(e){return this._data[e]||""}run(){let e=this.content(),t=g(`td[data-x=${this.get("x")||0}][data-y=${this.get("y")||0}]`);new d(e,t),e.on("click",".vi-wbe-apply-formula",this.applyFormula.bind(this))}content(){let e=this._wordWrap?'<textarea class="vi-wbe-text-input" rows="3"></textarea>':`<input type="text" placeholder="${l.text("Content")}" class="vi-wbe-text-input">`;return g(`<div class="vi-wbe-formula-container">\n <div class="field">\n ${e}\n </div>\n <button type="button" class="vi-ui button mini vi-wbe-apply-formula">${l.text("Save")}</button>\n </div>`)}applyFormula(e){let t=g(e.target).closest(".vi-wbe-formula-container").find(".vi-wbe-text-input").val(),i=this.get("jexcel"),a=[],n=i.selectedContainer,o=n[1],s=n[3],l=n[0];for(let e=o;e<=s;e++)i.records[e][l]&&!i.records[e][l].classList.contains("readonly")&&"none"!==i.records[e][l].style.display&&(a.push(i.updateCell(l,e,t)),i.updateFormulaChain(l,e,a));i.setHistory({action:"setValue",records:a,selection:i.selectedCell}),i.updateTable()}}const y=jQuery;class x{constructor(e,t,i,a,n){this.cells=t,this.obj=e,this.x=parseInt(i),this.y=parseInt(a),this.searchData=[],this.run()}run(){let e=this,t=this.content(),i=this.cells[1],a=this.cells[3],o=[{id:"",text:""}];for(let e=i;e<=a;e++){let t=this.obj.options.data[e][this.x];o.push(...t)}o=o.filter(((e,t,i)=>t===i.findIndex((t=>t.id===e.id&&t.text===e.text))));let s=y(`td[data-x=${this.x||0}][data-y=${this.y||0}]`);new d(t,s),t.find(".vi-wbe-find-string").select2({data:o}),t.find(".vi-wbe-replace-string").select2({multiple:!1,minimumInputLength:3,ajax:{url:n.ajaxUrl,type:"post",data:function(e){return{...n.ajaxData,sub_action:"search_tags",search:e.term,type:"public"}},processResults:function(t){return e.searchData=t,{results:t}}}}),t.on("click",".vi-wbe-apply-formula",this.applyFormula.bind(this))}content(){return y(`<div class="vi-wbe-formula-container">\n <div class="field">\n <div>${l.text("Find")}</div>\n <select placeholder="" class="vi-wbe-find-string"> </select>\n </div>\n <div class="field">\n <div>${l.text("Replace")}</div>\n <select placeholder="" class="vi-wbe-replace-string"> </select>\n </div>\n <button type="button" class="vi-ui button mini vi-wbe-apply-formula">${l.text("Replace")}</button>\n <p>If 'Find' value is empty, add to selected cells with 'Replace' value.</p>\n <p>If 'Replace' value is empty, remove from selected cells with 'Find' value.</p>\n </div>`)}applyFormula(e){let t=y(e.target).closest(".vi-wbe-formula-container"),i=t.find(".vi-wbe-find-string").val(),a=t.find(".vi-wbe-replace-string").val(),n=this.obj;if(!i&&!a)return;let o=this.searchData.filter((e=>e.id===+a)),s=[],l=this.cells,r=l[1],c=l[3],d=l[0];for(let e=r;e<=c;e++)if(n.records[e][d]&&!n.records[e][d].classList.contains("readonly")&&"none"!==n.records[e][d].style.display){let t=n.options.data[e][d];t||(t=[]);let a=t.filter((e=>e.id!==+i));t.length===a.length&&i||a.push(...o),a=a.filter(((e,t,i)=>t===i.findIndex((t=>t.id===e.id&&t.text===e.text)))),s.push(n.updateCell(d,e,a)),n.updateFormulaChain(d,e,s)}n.setHistory({action:"setValue",records:s,selection:n.selectedCell}),n.updateTable()}}const _=jQuery;class C{constructor(e,t,i,a,n){this.cells=t,this.obj=e,this.x=parseInt(i),this.y=parseInt(a),this.searchData=[],this.source=e.options.columns[i].source||[],this.run()}run(){let e=this.content(),t=_(`td[data-x=${this.x||0}][data-y=${this.y||0}]`);new d(e,t),e.find(".vi-wbe-find-string").select2({data:[{id:"",text:""},...this.source]}),e.find(".vi-wbe-replace-string").select2({data:[{id:"",text:""},...this.source]}),e.on("click",".vi-wbe-apply-formula",this.applyFormula.bind(this))}content(){return _(`<div class="vi-wbe-formula-container">\n <div class="field">\n <div>${l.text("Find")}</div>\n <select placeholder="" class="vi-wbe-find-string"> </select>\n </div>\n <div class="field">\n <div>${l.text("Replace")}</div>\n <select placeholder="" class="vi-wbe-replace-string"> </select>\n </div>\n <button type="button" class="vi-ui button mini vi-wbe-apply-formula">${l.text("Replace")}</button>\n <p>If 'Find' value is empty, add to selected cells with 'Replace' value.</p>\n <p>If 'Replace' value is empty, remove from selected cells with 'Find' value.</p>\n </div>`)}applyFormula(e){let t=_(e.target).closest(".vi-wbe-formula-container"),i=t.find(".vi-wbe-find-string").val(),a=t.find(".vi-wbe-replace-string").val(),n=this.obj;if(!i&&!a)return;i=isNaN(i)?i:+i,a=isNaN(a)?a:+a;let o=[],s=this.cells,l=s[1],r=s[3],c=s[0];for(let e=l;e<=r;e++)if(n.records[e][c]&&!n.records[e][c].classList.contains("readonly")&&"none"!==n.records[e][c].style.display){let t=n.options.data[e][c];t||(t=[]);let s=t.filter((e=>e!==i));t.length===s.length&&i||s.push(a),s=[...new Set(s)],o.push(n.updateCell(c,e,s)),n.updateFormulaChain(c,e,o)}n.setHistory({action:"setValue",records:o,selection:n.selectedCell}),n.updateTable()}}class k{constructor(e,t,i,a,n){this.cells=t,this.obj=e,this.x=parseInt(i),this.y=parseInt(a),this.run()}run(){let e=this;const t=wp.media({multiple:!0});t.open().off("select close").on("select",(function(i){t.state().get("selection").each((function(t){if("image"===(t=t.toJSON()).type){let i=t.id;n.imgStorage[i]=t.url,e.addImage(i)}}))}))}addImage(e){let t=this.obj,i=[],a=this.cells,n=a[1],o=a[3],s=a[0];for(let a=n;a<=o;a++)if(t.records[a][s]&&!t.records[a][s].classList.contains("readonly")&&"none"!==t.records[a][s].style.display){let n=t.options.data[a][s];n||(n=[]);let o=[...new Set(n)];o.push(e),i.push(t.updateCell(s,a,o)),t.updateFormulaChain(s,a,i)}t.setHistory({action:"setValue",records:i,selection:t.selectedCell}),t.updateTable()}}const T=jQuery;class A{constructor(e,t,i,a,n){this.cells=t,this.obj=e,this.x=parseInt(i),this.y=parseInt(a),this.run()}run(){let e=T(`td[data-x=${this.x||0}][data-y=${this.y||0}]`),t=this,i=l.createModal({header:l.text("Attributes"),content:"",actions:[{class:"save-attributes",text:l.text("Apply")}]});this.content(i),T(e).append(i),i.on("click",(function(e){let a=T(e.target);(a.hasClass("close")||a.hasClass("vi-wbe-modal-container"))&&i.remove(),a.hasClass("save-attributes")&&t.addAttributes(i)}))}addImage(e){let t=this.obj,i=[],a=this.cells,n=a[1],o=a[3],s=a[0];for(let a=n;a<=o;a++)if(t.records[a][s]&&!t.records[a][s].classList.contains("readonly")&&"none"!==t.records[a][s].style.display){let n=t.options.data[a][s];n||(n=[]);let o=[...new Set(n)];o.push(e),i.push(t.updateCell(s,a,o)),t.updateFormulaChain(s,a,i)}t.setHistory({action:"setValue",records:i,selection:t.selectedCell}),t.updateTable()}addAttributes(e){let t=[],i=e.find(".vi-wbe-add-attributes-option").val();if(e.find(".vi-wbe-attribute-row").each((function(e,i){let a=T(i).data("attr");if(a.is_taxonomy)a.options=T(i).find("select").val().map(Number);else{a.name=T(i).find("input.custom-attr-name").val();let e=T(i).find("textarea.custom-attr-val").val();a.value=e.trim().replace(/\s+/g," "),a.options=e.split("|").map((e=>e.trim().replace(/\s+/g," ")))}a.visible=!!T(i).find(".attr-visibility:checked").length,a.variation=!!T(i).find(".attr-variation:checked").length,a.position=e,t.push(a)})),console.log(t),t.length){let e=this.obj,a=!1,n=[],o=this.cells,s=o[1],l=o[3],r=o[0];const c=(e=[],t)=>{if(e.length)for(let i in e)if(e[i].name===t)return i;return!1};for(let o=s;o<=l;o++)if(e.records[o][r]&&!e.records[o][r].classList.contains("readonly")&&"none"!==e.records[o][r].style.display&&!1===a){let a=e.options.data[o][r];a||(a=[]);let s=[...new Set(a)],l=0;for(let e of t){let t=c(s,e.name);if(!1===t)e.position=s.length+l++,s.push(e);else switch(i){case"replace":e.position=s[t].position,s[t]=e;break;case"merge_terms":let i=[...s[t].options||[],...e.options||[]];s[t].options=[...new Set(i)]}}n.push(e.updateCell(r,o,s)),e.updateFormulaChain(r,o,n)}e.setHistory({action:"setValue",records:n,selection:e.selectedCell}),e.updateTable()}e.remove()}content(e){let t=this,i="",{attributes:a}=n,o=`<option value="">${l.text("Custom product attribute")}</option>`;for(let e in a)o+=`<option value="${e}">${a[e].data.attribute_label}</option>`;o=`<div class="vi-wbe-taxonomy-header">\n <select class="vi-wbe-select-taxonomy">${o}</select>\n <span class="vi-ui button tiny vi-wbe-add-taxonomy">${l.text("Add")}</span>\n </div>`,i=`${o}\n <table class="vi-ui celled table">\n <thead>\n <tr>\n <th>Name</th>\n <th>Attributes</th>\n <th width="1">Actions</th>\n </tr>\n </thead>\n <tbody>${i}</tbody>\n </table>`,e.find(".content").append(i),e.find(".actions").append('<div>\n <div class="vi-wbe-add-attributes-option-label">\n Select action if exist attribute in product\n </div>\n <select class="vi-wbe-add-attributes-option">\n <option value="none">Don\'t add</option>\n <option value="replace">Replace existed attribute</option>\n <option value="merge_terms">Merge terms</option>\n </select>\n </div>'),e.find("table select").select2({multiple:!0}),e.find("tbody").sortable({items:"tr",cursor:"move",axis:"y",scrollSensitivity:40,forcePlaceholderSize:!0,helper:"clone",handle:".icon.move"});const s=()=>{e.find("select.vi-wbe-select-taxonomy option").removeAttr("disabled"),e.find("input[type=hidden]").each((function(t,i){let a=T(i).val();e.find(`select.vi-wbe-select-taxonomy option[value='${a}']`).attr("disabled","disabled")}))};s(),e.on("click",(function(i){let a=T(i.target);if(a.hasClass("trash")&&(a.closest("tr").remove(),s()),a.hasClass("vi-wbe-add-taxonomy")){let i=T(".vi-wbe-select-taxonomy"),a=i.val(),n={name:a,options:[]};a&&(n.is_taxonomy=1);let o=T(t.createRowTable(n));e.find("table tbody").append(o),o.find("select").select2({multiple:!0}),s(),i.val("").trigger("change")}if(a.hasClass("vi-wbe-select-all-attributes")){let e=a.closest("td").find("select");e.find("option").attr("selected",!0),e.trigger("change")}if(a.hasClass("vi-wbe-select-no-attributes")){let e=a.closest("td").find("select");e.find("option").attr("selected",!1),e.trigger("change")}if(a.hasClass("vi-wbe-add-new-attribute")){let e=prompt(l.text("Enter a name for the new attribute term:"));if(!e)return;let t=a.closest("tr.vi-wbe-attribute-row"),i=t.attr("data-attr");i&&(i=JSON.parse(i),l.ajax({data:{sub_action:"add_new_attribute",taxonomy:i.name,term:e},beforeSend(){a.addClass("loading")},success(e){if(a.removeClass("loading"),e.success){let a=t.find("select");a.append(`<option value="${e.data.term_id}" selected>${e.data.name}</option>`),a.trigger("change"),n.attributes[i.name].terms[e.data.term_id]={slug:e.data.slug,text:e.data.name}}else alert(e.data.message)}}))}}))}createRowTable(e){let t="",i="";if(e.is_taxonomy){let a=n.attributes[e.name],o=a.terms||[],s="";if(t=`${a.data.attribute_label}<input type="hidden" value="${e.name}"/>`,Object.keys(o).length)for(let t in o)s+=`<option value="${t}" ${e.options.includes(parseInt(t))?"selected":""}>${o[t].text}</option>`;i=`<select multiple>${s}</select>\n <div class="vi-wbe-attributes-button-group">\n <span class="vi-ui button mini vi-wbe-select-all-attributes">${l.text("Select all")}</span>\n <span class="vi-ui button mini vi-wbe-select-no-attributes">${l.text("Select none")}</span>\n <span class="vi-ui button mini vi-wbe-add-new-attribute">${l.text("Add new")}</span>\n </div>`}else t=`<input type="text" class="custom-attr-name" value="${e.name}" placeholder="${l.text("Custom attribute name")}"/>`,i=`<textarea class="custom-attr-val" placeholder="${l.text('Enter some text, or some attributes by "|" separating values.')}">${e.value||""}</textarea>`;return t=`<div class="vi-wbe-attribute-name-label">${t}</div>`,t+=`<div>\n <input type="checkbox" class="attr-visibility" ${e.visible?"checked":""} value="1">\n <label>${l.text("Visible on the product page")}</label>\n </div>`,t+=`<div>\n <input type="checkbox" class="attr-variation" ${e.variation?"checked":""} value="1">\n <label>${l.text("Used for variations (apply for variable)")}</label>\n </div>`,`<tr class="vi-wbe-attribute-row" data-attr='${JSON.stringify(e)}'>\n <td class="vi-wbe-left">${t}</td>\n <td>${i}</td>\n <td class="vi-wbe-right"><i class="icon trash"> </i> <i class="icon move"> </i></td>\n </tr>`}}const $=jQuery;class E{constructor(e,t,i,a,n){this.cells=t,this.obj=e,this.x=parseInt(i),this.y=parseInt(a),this.run()}run(){let e=$(`td[data-x=${this.x||0}][data-y=${this.y||0}]`),t=this,i=l.createModal({header:l.text("Remove attributes"),content:"",actions:[{class:"save-attributes",text:l.text("Apply")}]});this.content(i),$(e).append(i),i.on("click",(function(e){let a=$(e.target);(a.hasClass("close")||a.hasClass("vi-wbe-modal-container"))&&i.remove(),a.hasClass("save-attributes")&&t.removeAttributes(i)}))}removeAttributes(e){let t=e.find(".vi-wbe-select-taxonomy").dropdown("get values");if(t.length){let e=this.obj,i=!1,a=[],n=this.cells,o=n[1],s=n[3],l=n[0];for(let n=o;n<=s;n++)if(e.records[n][l]&&!e.records[n][l].classList.contains("readonly")&&"none"!==e.records[n][l].style.display&&!1===i){let i=e.options.data[n][l];if(!i||!Array.isArray(i))continue;let o=i.filter((e=>!t.includes(e.name)));a.push(e.updateCell(l,n,o)),e.updateFormulaChain(l,n,a)}e.setHistory({action:"setValue",records:a,selection:e.selectedCell}),e.updateTable()}e.remove()}content(e){let{attributes:t}=n,i=`<option value="">${l.text("Select attributes to remove")}</option>`;for(let e in t)i+=`<option value="${e}">${t[e].data.attribute_label}</option>`;let a=`<div class="vi-wbe-taxonomy-header">\n <select class="vi-wbe-select-taxonomy fluid vi-ui selection" multiple>${i}</select>\n </div>`;e.find(".content").append(a),e.find("table select").select2({multiple:!0}),e.find("tbody").sortable({items:"tr",cursor:"move",axis:"y",scrollSensitivity:40,forcePlaceholderSize:!0,helper:"clone",handle:".icon.move"}),e.find(".vi-wbe-select-taxonomy").dropdown()}}var S=i(744);jQuery(document).ready((function(e){new class{constructor(){this.sidebar=b.init(),this.compare=[],this.trash=[],this.unTrash=[],this.revision={},this.isAdding=!1,this.editor=e("#vi-wbe-container"),this.menubar=e("#vi-wbe-menu-bar"),this.menubar.on("click",".vi-wbe-open-sidebar",this.openMenu.bind(this)),this.menubar.on("click","a.item:not(.vi-wbe-open-sidebar)",this.closeMenu.bind(this)),this.menubar.on("click",".vi-wbe-new-products",this.addNewProduct.bind(this)),this.menubar.on("click",".vi-wbe-new-coupons",this.addNewCoupon.bind(this)),this.menubar.on("click",".vi-wbe-new-orders",this.addNewOrder.bind(this)),this.menubar.on("click",".vi-wbe-full-screen-btn",this.toggleFullScreen.bind(this)),this.menubar.on("click",".vi-wbe-save-button",this.save.bind(this)),this.menubar.on("click",".vi-wbe-pagination a.item",this.changePage.bind(this)),this.menubar.on("click",".vi-wbe-get-product",this.reloadCurrentPage.bind(this)),this.menubar.on("change",".vi-wbe-go-to-page",this.changePageByInput.bind(this)),this.editor.on("cellonchange","tr",this.cellOnChange.bind(this)),this.editor.on("click",".jexcel_content",this.removeExistingEditor.bind(this)),this.editor.on("dblclick",this.removeContextPopup),this.sidebar.on("afterAddFilter",this.afterAddFilter.bind(this)),this.sidebar.on("afterSaveSettings",this.afterSaveSettings.bind(this)),this.sidebar.on("click",".vi-wbe-close-sidebar",this.closeMenu.bind(this)),this.init(),e(document).on("keydown",this.keyDownControl.bind(this)),e(document).on("keyup",this.keyUpControl.bind(this))}removeExistingEditor(e){e.target===e.currentTarget&&this.WorkBook&&this.WorkBook.edition&&this.WorkBook.closeEditor(this.WorkBook.edition[0],!0)}keyDownControl(e){switch(!e.ctrlKey&&!e.metaKey||e.shiftKey||83===e.which&&(e.preventDefault(),this.save()),e.which){case 27:this.sidebar.removeClass("vi-wbe-open")}}keyUpControl(e){if(e.target&&!e.target.getAttribute("readonly")){let t=e.target.getAttribute("data-currency");if(t){let i=e.target.value;if(i)if(i.indexOf(t)<1){let t=i.match(/\d/g);e.target.value=t?t.join(""):""}else{let a,n=i.split(t),o="";a=n[0].match(/[\d]/g).join(""),n[1]&&(o=n[1].match(/[\d]/g),o=o?o.join(""):""),e.target.value=o?`${a}${t}${o}`:`${a}${t}`}}}}removeContextPopup(){e(".vi-wbe-context-popup").removeClass("vi-wbe-popup-active")}init(){wbeParams.columns&&n.setColumns(wbeParams.columns),this.pagination(1,1),this.workBookInit(),this.loadProducts(),l.setJexcel(this.WorkBook)}cellOnChange(t,i){let{col:a=""}=i;if(!a)return;let o=n.idMapping[a],s=e(t.target);switch(o){case"product_type":s.find("td").each((function(t,i){let a=e(i).data("x");a&&0!==a&&1!==a&&e(i).removeClass("readonly")}));let t=n.cellDependType[i.value];Array.isArray(t)&&t.forEach((function(e){let t=n.idMappingFlip[e];s.find(`td[data-x='${t}']`).addClass("readonly")}));break;case"post_date":let a=i.value,o=l.getColFromColumnType("status"),r=s.find(`td[data-x='${o}']`).get(0),c=new Date(a).getTime()>Date.now()?"future":"publish";this.WorkBook.setValue(r,c)}}workBookInit(){let t,i=this,a=0,o=l.text("Delete rows with selected cells"),s=null,r=null;function c(e,t){let i=[],a=e.selectedContainer,n=a[1],o=a[3],s=a[0];for(let a=n;a<=o;a++)e.records[a][s]&&!e.records[a][s].classList.contains("readonly")&&"none"!==e.records[a][s].style.display&&(i.push(e.updateCell(s,a,t)),e.updateFormulaChain(s,a,i));e.setHistory({action:"setValue",records:i,selection:e.selectedCell}),e.updateTable()}switch(n.editType){case"products":o=`${l.text("Delete rows with selected cells")} \n <span class="vi-wbe-context-menu-note">\n (${l.text("Variations cannot revert after save")})\n </span>`,s=function(t,i){let a=l.getProductTypeFromY(i),o=n.cellDependType[a];Array.isArray(o)&&o.forEach((function(i){let a=n.idMappingFlip[i];e(t).find(`td[data-x='${a}']`).addClass("readonly")}))},r=function(t,i,a,o,s,l){if(i===o&&a===s){let t=this.getCellFromCoords(i,a),o=e(t).children();if(o.length&&o.hasClass("vi-wbe-gallery-has-item")){let o=this.options.data[a][i],s="";if(o.length)for(let e of o)s+=`<li class="vi-wbe-gallery-image"><img src="${n.imgStorage[e]}"></li>`;new d(`<ul class="vi-wbe-gallery-images">${s}</ul>`,e(t))}}},t=function(t,a,o,s,r){i.removeContextPopup();let d=a.selectedContainer;if(o=parseInt(o),s=parseInt(s),d[0]===d[2]&&null!==o)switch(a.options.columns[o].type){case"checkbox":t.push({title:l.text("Check"),onclick(e){c(a,!0)}}),t.push({title:l.text("Uncheck"),onclick(e){c(a,!1)}});break;case"number":t.push({title:l.text("Calculator"),onclick(e){new p(a,o,s,e)}}),o>1&&"sale_price"===a.options.columns[o].id&&"regular_price"===a.options.columns[o-1].id&&t.push({title:l.text("Calculator base on Regular price"),onclick(e){new h(a,o,s,e)}});break;case"text":t.push({title:l.text("Edit multiple cells"),onclick(e){new w(a,o,s,e,a.options.columns[o].wordWrap)}}),t.push({title:l.text("Find and Replace"),onclick(e){new v(a,o,s,e)}});break;case"calendar":let i=e(`td[data-x=${o}][data-y=${s}]`).get(0);e(i).hasClass("readonly")||t.push({title:l.text("Open date picker"),onclick(){let e=a.options.data[s][o];var t=l.createEditor(i,"input","",!1);t.value=e,t.style.left="unset";let n=a.selectedContainer,r=n[1],c=n[3];1!=a.options.tableOverflow&&1!=a.options.fullscreen||(a.options.columns[o].options.position=!0),a.options.columns[o].options.value=a.options.data[s][o],a.options.columns[o].options.opened=!0,a.options.columns[o].options.onclose=function(e,t){let i=[];t=e.value;for(let e=r;e<=c;e++)a.records[e][o]&&!a.records[e][o].classList.contains("readonly")&&"none"!==a.records[e][o].style.display&&(i.push(a.updateCell(o,e,t)),a.updateFormulaChain(o,e,i));a.setHistory({action:"setValue",records:i,selection:a.selectedCell}),a.updateTable()},jSuites.calendar(t,a.options.columns[o].options),t.focus()}});break;case"custom":switch(a.options.columns[o].editor.type){case"textEditor":t.push({title:l.text("Edit multiple cells"),onclick(){e(".vi-ui.modal").modal("show"),e(".vi-ui.modal .close.icon").off("click"),null===tinymce.get("vi-wbe-text-editor")?(e("#vi-wbe-text-editor").val(""),wp.editor.initialize("vi-wbe-text-editor",n.tinyMceOptions)):tinymce.get("vi-wbe-text-editor").setContent(""),e(".vi-wbe-text-editor-save").off("click").on("click",(function(){let t=wp.editor.getContent("vi-wbe-text-editor");c(a,t),e(this).hasClass("vi-wbe-close")&&e(".vi-ui.modal").modal("hide")}))}});break;case"tags":t.push({title:l.text("Find and replace tags"),onclick(e){new x(a,d,o,s,e)}});break;case"select2":t.push({title:l.text("Find and replace options"),onclick(e){new C(a,d,o,s,e)}});break;case"gallery":t.push({title:l.text("Add image to selected cells"),onclick(e){new k(a,d,o,s,e)}});break;case"product_attributes":t.push({title:l.text("Add attributes to products"),onclick(e){new A(a,d,o,s,e)}}),t.push({title:l.text("Remove multiple product attribute"),onclick(e){new E(a,d,o,s,e)}})}}if(t.length&&t.push({type:"line"}),d[1]===d[3]&&null!==s){let e=l.getProductTypeFromY(s);if("variable"===e&&(t.push({title:l.text("Add variation"),onclick(){l.is_loading()||l.ajax({data:{sub_action:"add_variation",pid:l.getProductIdOfCell(a,s)},beforeSend(){l.loading()},success(e){e.success&&(a.insertRow(0,s,!1,!0),a.setRowData(s+1,e.data,!0)),l.removeLoading()}})}}),t.push({title:`${l.text("Create variations from all attributes")} <span class="vi-wbe-context-menu-note">(${l.text("Save new attributes before")})</span>`,onclick(){l.is_loading()||l.ajax({data:{sub_action:"link_all_variations",pid:l.getProductIdOfCell(a,s)},beforeSend(){l.loading()},success(e){e.success&&(e.data.length&&e.data.forEach((function(e,t){a.insertRow(0,s+t,!1,!0),a.setRowData(s+t+1,e,!0)})),l.removeLoading(),l.notice(`${e.data.length} ${l.text("variations are added")}`))}})}}),t.push({type:"line"})),"variation"!==e){let e=l.getProductIdOfCell(a,s);t.push({title:l.text("Duplicate"),onclick(){l.ajax({data:{sub_action:"duplicate_product",product_id:e},beforeSend(){l.loading()},success(e){e.data.length&&e.data.forEach((function(e,t){a.insertRow(0,s+t,!0,!0),a.setRowData(s+t,e,!0)})),l.removeLoading()}})}}),t.push({title:l.text("Go to edit product page"),onclick(){window.open(`${n.adminUrl}post.php?post=${e}&action=edit`,"_blank")}}),t.push({title:l.text("View on Single product page"),onclick(){window.open(`${n.frontendUrl}?p=${e}&post_type=product&preview=true`,"_blank")}})}}return t};break;case"orders":t=function(t,i,a,o,s){let r=i.selectedContainer;if(a=parseInt(a),o=parseInt(o),null!==a&&null!==o){for(let e in n.orderActions)t.push({title:n.orderActions[e],onclick(){let t=[];for(let e=r[1];e<=r[3];e++)t.push(l.getProductIdOfCell(i,e));l.ajax({data:{sub_action:e,order_ids:t},beforeSend(){l.loading()},success(e){l.removeLoading()}})}});t.length&&t.push({type:"line"});const a=function(t=0){let a=i.getCellFromCoords(r[0],r[1]),n=e(`<div>\n <div class="field"> \n <textarea rows="3"></textarea>\n </div>\n <div class="field"> \n <span class="vi-wbe-add-note vi-ui button tiny">\n ${l.text("Add")}\n </span>\n </div>\n </div>`),o=new d(n,e(a));n.on("click",".vi-wbe-add-note",(function(){let e=n.find("textarea").val();if(!e)return;let a=i.selectedContainer,s=a[1],r=a[3],c=(a[0],[]);for(let e=s;e<=r;e++)c.push(i.options.data[e][0]);o.hide(),l.ajax({data:{sub_action:"add_order_note",ids:c,note:e,is_customer_note:t},beforeSend(){l.loading()},success(e){l.removeLoading()}})}))};if(t.push({title:l.text("Add private note"),onclick(){a(0)}}),t.push({title:l.text("Add note to customer"),onclick(){a(1)}}),t.length&&t.push({type:"line"}),r[1]===r[3]){let e=l.getProductIdOfCell(i,o);t.push({title:l.text("Go to edit order page"),onclick(){window.open(`${n.adminUrl}post.php?post=${e}&action=edit`,"_blank")}}),t.length&&t.push({type:"line"})}}return t};break;case"coupons":t=function(e,t,i,a,n){let o=t.selectedContainer;return i=parseInt(i),a=parseInt(a),null!==i&&null!==a&&o[0]===o[2]&&("code"===l.getColumnType(i)&&e.push({title:l.text("Generate coupon code"),onclick(){let e=[],i=t.selectedContainer,a=i[1],n=i[3],o=i[0];for(let i=a;i<=n;i++)if(t.records[i][o]&&!t.records[i][o].classList.contains("readonly")&&"none"!==t.records[i][o].style.display){let a=l.generateCouponCode();e.push(t.updateCell(o,i,a)),t.updateFormulaChain(o,i,e)}t.setHistory({action:"setValue",records:e,selection:t.selectedCell}),t.updateTable()}}),"text"===t.options.columns[i].type&&(e.push({title:l.text("Edit multiple cells"),onclick(e){new w(t,i,a,e,t.options.columns[i].wordWrap)}}),e.push({title:l.text("Find and Replace"),onclick(e){new v(t,i,a,e)}})),"checkbox"===t.options.columns[i].type&&(e.push({title:l.text("Check"),onclick(e){c(t,!0)}}),e.push({title:l.text("Uncheck"),onclick(e){c(t,!1)}})),e.length&&e.push({type:"line"})),e}}this.WorkBook=e("#vi-wbe-spreadsheet").jexcel({allowInsertRow:!1,allowInsertColumn:!1,about:!1,freezeColumns:3,tableOverflow:!0,tableWidth:"100%",tableHeight:"100%",columns:n.columns,stripHTML:!1,allowExport:!1,allowDeleteColumn:!1,allowRenameColumn:!1,autoIncrement:!1,allowXCopy:!1,text:{deleteSelectedRows:o},oncreaterow:s,contextMenuItems:t,onselection:r,onchange(t,a,n,o,s,r){if(JSON.stringify(s)!==JSON.stringify(r)){e(a).parent().trigger("cellonchange",{cell:a,col:n,row:o,value:s});let t=this.options.data[o][0];if(i.compare.push(t),i.compare=[...new Set(i.compare)],console.log(i.compare),i.menubar.find(".vi-wbe-save-button").addClass("vi-wbe-saveable"),!i.isAdding){i.revision[t]||(i.revision[t]={});let e=l.getColumnType(n);i.revision[t][e]=r}}},onbeforechange:(e,t,i,a,n)=>("object"!=typeof n&&(n=S.sanitize(n)),n),ondeleterow(e,t,a,n){for(let e of n)i.trash.push(e[0].innerText);i.trash.length&&i.menubar.find(".vi-wbe-save-button").addClass("vi-wbe-saveable")},onundo(e,t){if(t&&"deleteRow"===t.action)for(let e of t.rowData)i.unTrash.push(e[0])},onbeforecopy(){a=0,i.firstCellCopy=null},oncopying(e,t,n){i.firstCellCopy||(i.firstCellCopy=[t,n]),i.firstCellCopy[0]!==t&&a++},onbeforepaste(e,t){if("string"!=typeof e)return e;e=e.trim();let n=t[0],o=this.columns[n].type;if(void 0===i.firstCellCopy)return["text","number","custom"].includes(o)?"custom"===o?"textEditor"===this.columns[n].editor.type?e:"":e:"";let s=+i.firstCellCopy[0],l=+t[0],r=this.columns[s].type,c=this.columns[l].type;if(+i.firstCellCopy[0]!=+t[0]){if(a>0)return alert("Copy single column each time."),"";if(r!==c)return alert("Can not paste data with different column type."),""}return e},onscroll(t){let i=e(t).find("select.select2-hidden-accessible");i.length&&i.select2("close")},oncreateeditor(e,t,i,a,n){this.options.columns[i].currency&&n.setAttribute("data-currency",this.options.columns[i].currency)}})}closeMenu(e){this.sidebar.removeClass("vi-wbe-open")}openMenu(t){let i=e(t.currentTarget).data("menu_tab"),a=this.sidebar.find(`a.item[data-tab='${i}']`);a.hasClass("active")&&this.sidebar.hasClass("vi-wbe-open")?this.sidebar.removeClass("vi-wbe-open"):(this.sidebar.addClass("vi-wbe-open"),a.trigger("click"))}addNewProduct(){if(l.is_loading())return;let e=prompt(l.text("Please enter new product name"));if(e){let t=this;l.ajax({data:{sub_action:"add_new_product",product_name:e},beforeSend(){l.loading()},success(e){t.isAdding=!0,t.WorkBook.insertRow(0,0,!0,!0),t.WorkBook.setRowData(0,e.data,!0),l.removeLoading()},complete(){t.isAdding=!1}})}}addNewCoupon(){if(l.is_loading())return;let e=this;l.ajax({data:{sub_action:"add_new_coupon"},beforeSend(){l.loading()},success(t){e.isAdding=!0,e.WorkBook.insertRow(0,0,!0,!0),e.WorkBook.setRowData(0,t.data,!0),l.removeLoading()},complete(){e.isAdding=!1}})}addNewOrder(){window.open("post-new.php?post_type=shop_order")}toggleFullScreen(t){let i=e(".wp-admin"),a=e(t.currentTarget);i.toggleClass("vi-wbe-full-screen"),i.hasClass("vi-wbe-full-screen")?(a.find("i.icon").removeClass("external alternate").addClass("window close outline"),a.attr("title","Exit full screen")):(a.find("i.icon").removeClass("window close outline").addClass("external alternate"),a.attr("title","Full screen")),e.ajax({url:n.ajaxUrl,type:"post",dataType:"json",data:{...n.ajaxData,sub_action:"set_full_screen_option",status:i.hasClass("vi-wbe-full-screen")}})}getAllRows(){return this.WorkBook.getData(!1,!0)}save(){e("td.error").removeClass("error");let t=this,i=this.getAllRows(),a=[],n=[];for(let e of this.compare)for(let t of i)parseInt(t[0])===parseInt(e)&&a.push(t);l.is_loading()||function i(o=0){let s=30*o,r=s+30,c=a.slice(s,r),d=30*(o+1)>a.length;if(c.length||t.trash.length||t.unTrash.length)l.ajax({data:{sub_action:"save_products",products:JSON.stringify(c),trash:t.trash,untrash:t.unTrash},beforeSend(){l.loading()},success(e){t.trash=[],t.unTrash=[],t.compare=[],t.menubar.find(".vi-wbe-save-button").removeClass("vi-wbe-saveable"),e.data.skuErrors&&(n=[...new Set([...n,...e.data.skuErrors])]),l.removeLoading(),i(o+1)},error(e){console.log(e)}});else if(0===o&&l.notice(l.text("Nothing change to save")),d){if(n.length){l.notice(l.text("Invalid or duplicated SKU"));let i=l.getColFromColumnType("sku"),a=t.WorkBook.getData();if(a.length)for(let o in a){let s=a[o];if(n.includes(s[0])){let a=t.WorkBook.getCellFromCoords(i,o);e(a).addClass("error")}}}let i=t.WorkBook.history;if(i.length)for(let e of i){if("deleteRow"!==e.action)continue;let t=[];for(let i in e.rowData)e.rowData[i][1]>0&&t.push(parseInt(i));t.length&&(e.rowData=e.rowData.filter(((e,i)=>!t.includes(i))),e.rowNode=e.rowNode.filter(((e,i)=>!t.includes(i))),e.rowRecords=e.rowRecords.filter(((e,i)=>!t.includes(i))),e.numOfRows=e.numOfRows-t.length)}t.saveRevision()}}()}loadProducts(e=1,t=!1){let i=this;l.is_loading()||l.ajax({data:{sub_action:"load_products",page:e,re_create:t},beforeSend(){l.loading()},success(a){a.success&&(n.imgStorage=a.data.img_storage,t&&(i.WorkBook.destroy(),a.data.columns&&n.setColumns(a.data.columns),a.data.idMapping&&(n.idMapping=a.data.idMapping),a.data.idMappingFlip&&(n.idMappingFlip=a.data.idMappingFlip),i.workBookInit()),i.WorkBook.options.data=a.data.products,i.WorkBook.setData(),i.pagination(a.data.max_num_pages,e),l.removeLoading(),a.data.products.length||l.notice(l.text("No item was found")))},error(e){console.log(e)}})}pagination(e,t){this.menubar.find(".vi-wbe-pagination").html(l.pagination(e,t))}changePage(t){let i=parseInt(e(t.currentTarget).attr("data-page"));e(t.currentTarget).hasClass("active")||e(t.currentTarget).hasClass("disabled")||!i||this.loadProducts(i)}changePageByInput(t){let i=parseInt(e(t.target).val());i<=parseInt(e(t.target).attr("max"))&&i>0&&this.loadProducts(i)}reloadCurrentPage(){this.loadProducts(this.getCurrentPage())}getCurrentPage(){return this.menubar.find(".vi-wbe-pagination .item.active").data("page")||1}afterAddFilter(e,t){n.imgStorage=t.img_storage,this.WorkBook.options.data=t.products,this.WorkBook.setData(),this.pagination(t.max_num_pages,1),t.products.length||l.notice(l.text("No item was found"))}afterSaveSettings(e,t){t.fieldsChange&&this.loadProducts(this.getCurrentPage(),!0)}saveRevision(){let t=this;if(Object.keys(t.revision).length){let i=t.sidebar.find(".vi-wbe-pagination a.item.active").data("page")||1;l.ajax({data:{sub_action:"auto_save_revision",data:t.revision,page:i||1},success(a){a.success&&(a.data.updatePage&&e("#vi-wbe-history-points-list tbody").html(a.data.updatePage),t.revision={},t.sidebar.find(".vi-wbe-pagination").html(l.pagination(a.data.pages,i)))}})}}}}))})()})(); -
bulky-bulk-edit-products-for-woo/trunk/bulky-bulk-edit-products-for-woo.php
r2905401 r2925655 4 4 * Plugin URI: https://villatheme.com/extensions/bulky-woocommerce-bulk-edit-products/ 5 5 * Description: Bulky - Bulk Edit Products for WooCommerce helps easily work with products in bulk. The plugin offers sufficient simple and advanced tools to help filter various available attributes of simple and variable products such as ID, Title, Content, Excerpt, Slugs, SKU, Post date, range of regular price and sale price, Sale date, range of stock quantity, Product type, Categories.... Users can quickly search for wanted products fields and work with the product fields in bulk. The plugin promises to help users to save time and optimize manipulation when working with products in bulk. 6 * Version: 1.1. 26 * Version: 1.1.3 7 7 * Author: VillaTheme 8 8 * Author URI: https://villatheme.com … … 13 13 * Tested up to: 6.2 14 14 * WC requires at least: 5.0 15 * WC tested up to: 7. 415 * WC tested up to: 7.7 16 16 * Requires PHP: 7.0 17 17 **/ … … 37 37 public $plugin_name = 'Bulky - Bulk Edit Products for WooCommerce'; 38 38 39 public $version = '1.1. 2';39 public $version = '1.1.3'; 40 40 41 41 public $conditional = ''; -
bulky-bulk-edit-products-for-woo/trunk/readme.txt
r2905401 r2925655 260 260 261 261 == Changelog == 262 /** 1.1.3 - 2023.06.02 **/ 263 - Fix: Cannot save after add new product 262 264 263 265 /** 1.1.2 - 2023.04.28 **/ -
bulky-bulk-edit-products-for-woo/trunk/support/support.php
r2790645 r2925655 8 8 /** 9 9 * Class VillaTheme_Support 10 * 1.1. 710 * 1.1.8 11 11 */ 12 12 class VillaTheme_Support { 13 13 protected $plugin_base_name; 14 14 protected $ads_data; 15 protected $version = '1.1.7'; 15 protected $version = '1.1.8'; 16 protected $data = []; 16 17 17 18 public function __construct( $data ) {
Note: See TracChangeset
for help on using the changeset viewer.