@printcart/wix-integration
Advanced tools
Comparing version 1.1.2 to 1.1.3
@@ -1131,3 +1131,2 @@ var __defProp2 = Object.defineProperty; | ||
var _a, _b, _c; | ||
console.log(eventName); | ||
switch (eventName) { | ||
@@ -1140,3 +1139,2 @@ case "ViewContent": | ||
case "productPageLoaded": | ||
console.log(data); | ||
if (data.variants && data.variants.length > 1) { | ||
@@ -1143,0 +1141,0 @@ return; |
@@ -1,2 +0,2 @@ | ||
var Ft=Object.defineProperty;var Ht=(p,f,m)=>f in p?Ft(p,f,{enumerable:!0,configurable:!0,writable:!0,value:m}):p[f]=m;var O=(p,f,m)=>(Ht(p,typeof f!="symbol"?f+"":f,m),m),Ne=(p,f,m)=>{if(!f.has(p))throw TypeError("Cannot "+m)};var a=(p,f,m)=>(Ne(p,f,"read from private field"),m?m.call(p):f.get(p)),h=(p,f,m)=>{if(f.has(p))throw TypeError("Cannot add the same private member more than once");f instanceof WeakSet?f.add(p):f.set(p,m)},U=(p,f,m,N)=>(Ne(p,f,"write to private field"),N?N.call(p,m):f.set(p,m),m);var v=(p,f,m)=>(Ne(p,f,"access private method"),m);(function(p){typeof define=="function"&&define.amd?define(p):p()})(function(){var q,te,_,L,x,de,at,ne,We,ue,lt,pe,dt,T,z,fe,ut,he,pt,ve,ft,me,ht,ge,vt,ye,mt,_e,gt,we,yt,Le,_t,Ee,wt,be,Lt,Ie,Et;"use strict";var p=Object.defineProperty,f=(n,e,t)=>e in n?p(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t,m=(n,e,t)=>(f(n,typeof e!="symbol"?e+"":e,t),t),N=(n,e,t)=>{if(!e.has(n))throw TypeError("Cannot "+t)},X=(n,e,t)=>(N(n,e,"read from private field"),t?t.call(n):e.get(n)),W=(n,e,t)=>{if(e.has(n))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(n):e.set(n,t)},$e=(n,e,t,i)=>(N(n,e,"write to private field"),i?i.call(n,t):e.set(n,t),t),E=(n,e,t)=>(N(n,e,"access private method"),t),$,J,Pe,Ae,xe,De,ie,ke,I,C,Se={exports:{}},A=typeof Reflect=="object"?Reflect:null,Be=A&&typeof A.apply=="function"?A.apply:function(e,t,i){return Function.prototype.apply.call(e,t,i)},re;A&&typeof A.ownKeys=="function"?re=A.ownKeys:Object.getOwnPropertySymbols?re=function(e){return Object.getOwnPropertyNames(e).concat(Object.getOwnPropertySymbols(e))}:re=function(e){return Object.getOwnPropertyNames(e)};function bt(n){console&&console.warn&&console.warn(n)}var je=Number.isNaN||function(e){return e!==e};function l(){l.init.call(this)}Se.exports=l,Se.exports.once=xt,l.EventEmitter=l,l.prototype._events=void 0,l.prototype._eventsCount=0,l.prototype._maxListeners=void 0;var Fe=10;function se(n){if(typeof n!="function")throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof n)}Object.defineProperty(l,"defaultMaxListeners",{enumerable:!0,get:function(){return Fe},set:function(n){if(typeof n!="number"||n<0||je(n))throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+n+".");Fe=n}}),l.init=function(){(this._events===void 0||this._events===Object.getPrototypeOf(this)._events)&&(this._events=Object.create(null),this._eventsCount=0),this._maxListeners=this._maxListeners||void 0},l.prototype.setMaxListeners=function(e){if(typeof e!="number"||e<0||je(e))throw new RangeError('The value of "n" is out of range. It must be a non-negative number. Received '+e+".");return this._maxListeners=e,this};function He(n){return n._maxListeners===void 0?l.defaultMaxListeners:n._maxListeners}l.prototype.getMaxListeners=function(){return He(this)},l.prototype.emit=function(e){for(var t=[],i=1;i<arguments.length;i++)t.push(arguments[i]);var r=e==="error",o=this._events;if(o!==void 0)r=r&&o.error===void 0;else if(!r)return!1;if(r){var s;if(t.length>0&&(s=t[0]),s instanceof Error)throw s;var c=new Error("Unhandled error."+(s?" ("+s.message+")":""));throw c.context=s,c}var u=o[e];if(u===void 0)return!1;if(typeof u=="function")Be(u,this,t);else for(var g=u.length,y=Xe(u,g),i=0;i<g;++i)Be(y[i],this,t);return!0};function qe(n,e,t,i){var r,o,s;if(se(t),o=n._events,o===void 0?(o=n._events=Object.create(null),n._eventsCount=0):(o.newListener!==void 0&&(n.emit("newListener",e,t.listener?t.listener:t),o=n._events),s=o[e]),s===void 0)s=o[e]=t,++n._eventsCount;else if(typeof s=="function"?s=o[e]=i?[t,s]:[s,t]:i?s.unshift(t):s.push(t),r=He(n),r>0&&s.length>r&&!s.warned){s.warned=!0;var c=new Error("Possible EventEmitter memory leak detected. "+s.length+" "+String(e)+" listeners added. Use emitter.setMaxListeners() to increase limit");c.name="MaxListenersExceededWarning",c.emitter=n,c.type=e,c.count=s.length,bt(c)}return n}l.prototype.addListener=function(e,t){return qe(this,e,t,!1)},l.prototype.on=l.prototype.addListener,l.prototype.prependListener=function(e,t){return qe(this,e,t,!0)};function It(){if(!this.fired)return this.target.removeListener(this.type,this.wrapFn),this.fired=!0,arguments.length===0?this.listener.call(this.target):this.listener.apply(this.target,arguments)}function Ke(n,e,t){var i={fired:!1,wrapFn:void 0,target:n,type:e,listener:t},r=It.bind(i);return r.listener=t,i.wrapFn=r,r}l.prototype.once=function(e,t){return se(t),this.on(e,Ke(this,e,t)),this},l.prototype.prependOnceListener=function(e,t){return se(t),this.prependListener(e,Ke(this,e,t)),this},l.prototype.removeListener=function(e,t){var i,r,o,s,c;if(se(t),r=this._events,r===void 0)return this;if(i=r[e],i===void 0)return this;if(i===t||i.listener===t)--this._eventsCount===0?this._events=Object.create(null):(delete r[e],r.removeListener&&this.emit("removeListener",e,i.listener||t));else if(typeof i!="function"){for(o=-1,s=i.length-1;s>=0;s--)if(i[s]===t||i[s].listener===t){c=i[s].listener,o=s;break}if(o<0)return this;o===0?i.shift():Ct(i,o),i.length===1&&(r[e]=i[0]),r.removeListener!==void 0&&this.emit("removeListener",e,c||t)}return this},l.prototype.off=l.prototype.removeListener,l.prototype.removeAllListeners=function(e){var t,i,r;if(i=this._events,i===void 0)return this;if(i.removeListener===void 0)return arguments.length===0?(this._events=Object.create(null),this._eventsCount=0):i[e]!==void 0&&(--this._eventsCount===0?this._events=Object.create(null):delete i[e]),this;if(arguments.length===0){var o=Object.keys(i),s;for(r=0;r<o.length;++r)s=o[r],s!=="removeListener"&&this.removeAllListeners(s);return this.removeAllListeners("removeListener"),this._events=Object.create(null),this._eventsCount=0,this}if(t=i[e],typeof t=="function")this.removeListener(e,t);else if(t!==void 0)for(r=t.length-1;r>=0;r--)this.removeListener(e,t[r]);return this};function Ve(n,e,t){var i=n._events;if(i===void 0)return[];var r=i[e];return r===void 0?[]:typeof r=="function"?t?[r.listener||r]:[r]:t?Pt(r):Xe(r,r.length)}l.prototype.listeners=function(e){return Ve(this,e,!0)},l.prototype.rawListeners=function(e){return Ve(this,e,!1)},l.listenerCount=function(n,e){return typeof n.listenerCount=="function"?n.listenerCount(e):ze.call(n,e)},l.prototype.listenerCount=ze;function ze(n){var e=this._events;if(e!==void 0){var t=e[n];if(typeof t=="function")return 1;if(t!==void 0)return t.length}return 0}l.prototype.eventNames=function(){return this._eventsCount>0?re(this._events):[]};function Xe(n,e){for(var t=new Array(e),i=0;i<e;++i)t[i]=n[i];return t}function Ct(n,e){for(;e+1<n.length;e++)n[e]=n[e+1];n.pop()}function Pt(n){for(var e=new Array(n.length),t=0;t<e.length;++t)e[t]=n[t].listener||n[t];return e}function xt(n,e){return new Promise(function(t,i){function r(s){n.removeListener(e,o),i(s)}function o(){typeof n.removeListener=="function"&&n.removeListener("error",r),t([].slice.call(arguments))}Je(n,e,o,{once:!0}),e!=="error"&&kt(n,r,{once:!0})})}function kt(n,e,t){typeof n.on=="function"&&Je(n,"error",e,t)}function Je(n,e,t,i){if(typeof n.on=="function")i.once?n.once(e,t):n.on(e,t);else if(typeof n.addEventListener=="function")n.addEventListener(e,function r(o){i.once&&n.removeEventListener(e,r),t(o)});else throw new TypeError('The "emitter" argument must be of type EventEmitter. Received type '+typeof n)}var St=Se.exports;const Z="pc-designer-iframe-wrapper",oe="pc-designer-iframe";class Tt{constructor(e){W(this,Pe),W(this,xe),W(this,ie),W(this,I),m(this,"token"),m(this,"productId"),m(this,"options"),W(this,$,void 0),W(this,J,void 0);var t;if(this.token=e.token,this.productId=e.productId,this.options=e.options,$e(this,$,(t=this.options)!=null&&t.designerUrl?this.options.designerUrl:{}.VITE_CUSTOMIZER_URL?{}.VITE_CUSTOMIZER_URL:"https://customizer.printcart.com"),$e(this,J,new St),!this.token||!this.productId){console.error("Missing Config Params");return}E(this,Pe,Ae).call(this),E(this,xe,De).call(this)}render(){const e=document.getElementById(Z),t=document.getElementById(oe);if(!t||!(t instanceof HTMLIFrameElement)||!e){console.error("Can not find iframe element");return}const i=E(this,ie,ke).call(this);t.src=i.href,e.style.opacity="1",e.style.visibility="visible",E(this,I,C).call(this,"rendered")}close(){const e=document.getElementById(Z);if(!e){console.error("Can not find iframe element");return}e.style.opacity="0",e.style.visibility="hidden",E(this,I,C).call(this,"closed")}editDesign(e){const t=E(this,ie,ke).call(this);t.searchParams.set("design_id",e),t.searchParams.set("task","edit");const i=document.getElementById(Z),r=document.getElementById(oe);if(!r||!(r instanceof HTMLIFrameElement)||!i){console.error("Can not find iframe element");return}r.src=t.href,i.style.opacity="1",i.style.visibility="visible",E(this,I,C).call(this,"edit")}on(e,t){return X(this,J).on(e,t),this}}$=new WeakMap,J=new WeakMap,Pe=new WeakSet,Ae=function(){const n=document.createElement("div");n.id=Z,n.style.cssText="position:fixed;top:0;left:0;width:100vw;height:100vh;opacity:0;visibility:hidden;z-index:99999";const e=document.createElement("iframe");e.id=oe,e.width="100%",e.height="100%",n.appendChild(e),document.body.appendChild(n)},xe=new WeakSet,De=function(){window.addEventListener("message",n=>{if(n.origin===X(this,$)&&n.data.message==="closeDesignTool"){const e=document.getElementById(Z);if(!e)return;e.style.opacity="0",e.style.visibility="hidden",E(this,I,C).call(this,"closed")}if(n.data.message==="finishLoad"){const e=document.getElementById(oe);E(this,I,C).call(this,"render-finish"),e&&e instanceof HTMLIFrameElement&&e.contentWindow&&e.contentWindow.postMessage({message:"customSettings",settings:this.options},X(this,$))}n.data.message==="finishProcess"&&E(this,I,C).call(this,"upload-success",n.data.data.data),n.data.message==="finishUpdate"&&E(this,I,C).call(this,"edit-success",n.data.data.data),n.data.message==="uploadError"&&E(this,I,C).call(this,"upload-error",n.data)},!1)},ie=new WeakSet,ke=function(){const n=new URL(X(this,$));return n.searchParams.set("api_key",this.token),n.searchParams.set("product_id",this.productId),n.searchParams.set("parentUrl",window.location.href),n},I=new WeakSet,C=function(n,...e){X(this,J).emit(n,...e)};var Te=(n,e,t)=>{if(!e.has(n))throw TypeError("Cannot "+t)},w=(n,e,t)=>(Te(n,e,"read from private field"),t?t.call(n):e.get(n)),P=(n,e,t)=>{if(e.has(n))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(n):e.set(n,t)},D=(n,e,t,i)=>(Te(n,e,"write to private field"),i?i.call(n,t):e.set(n,t),t),M=(n,e,t)=>(Te(n,e,"access private method"),t),G,B,j,Y,Q,ee,R,F,Me,Ze,Re,Ge,Oe={exports:{}},H=typeof Reflect=="object"?Reflect:null,Ye=H&&typeof H.apply=="function"?H.apply:function(e,t,i){return Function.prototype.apply.call(e,t,i)},ce;H&&typeof H.ownKeys=="function"?ce=H.ownKeys:Object.getOwnPropertySymbols?ce=function(e){return Object.getOwnPropertyNames(e).concat(Object.getOwnPropertySymbols(e))}:ce=function(e){return Object.getOwnPropertyNames(e)};function Mt(n){console&&console.warn&&console.warn(n)}var Qe=Number.isNaN||function(e){return e!==e};function d(){d.init.call(this)}Oe.exports=d,Oe.exports.once=Nt,d.EventEmitter=d,d.prototype._events=void 0,d.prototype._eventsCount=0,d.prototype._maxListeners=void 0;var et=10;function ae(n){if(typeof n!="function")throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof n)}Object.defineProperty(d,"defaultMaxListeners",{enumerable:!0,get:function(){return et},set:function(n){if(typeof n!="number"||n<0||Qe(n))throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+n+".");et=n}}),d.init=function(){(this._events===void 0||this._events===Object.getPrototypeOf(this)._events)&&(this._events=Object.create(null),this._eventsCount=0),this._maxListeners=this._maxListeners||void 0},d.prototype.setMaxListeners=function(e){if(typeof e!="number"||e<0||Qe(e))throw new RangeError('The value of "n" is out of range. It must be a non-negative number. Received '+e+".");return this._maxListeners=e,this};function tt(n){return n._maxListeners===void 0?d.defaultMaxListeners:n._maxListeners}d.prototype.getMaxListeners=function(){return tt(this)},d.prototype.emit=function(e){for(var t=[],i=1;i<arguments.length;i++)t.push(arguments[i]);var r=e==="error",o=this._events;if(o!==void 0)r=r&&o.error===void 0;else if(!r)return!1;if(r){var s;if(t.length>0&&(s=t[0]),s instanceof Error)throw s;var c=new Error("Unhandled error."+(s?" ("+s.message+")":""));throw c.context=s,c}var u=o[e];if(u===void 0)return!1;if(typeof u=="function")Ye(u,this,t);else for(var g=u.length,y=ot(u,g),i=0;i<g;++i)Ye(y[i],this,t);return!0};function nt(n,e,t,i){var r,o,s;if(ae(t),o=n._events,o===void 0?(o=n._events=Object.create(null),n._eventsCount=0):(o.newListener!==void 0&&(n.emit("newListener",e,t.listener?t.listener:t),o=n._events),s=o[e]),s===void 0)s=o[e]=t,++n._eventsCount;else if(typeof s=="function"?s=o[e]=i?[t,s]:[s,t]:i?s.unshift(t):s.push(t),r=tt(n),r>0&&s.length>r&&!s.warned){s.warned=!0;var c=new Error("Possible EventEmitter memory leak detected. "+s.length+" "+String(e)+" listeners added. Use emitter.setMaxListeners() to increase limit");c.name="MaxListenersExceededWarning",c.emitter=n,c.type=e,c.count=s.length,Mt(c)}return n}d.prototype.addListener=function(e,t){return nt(this,e,t,!1)},d.prototype.on=d.prototype.addListener,d.prototype.prependListener=function(e,t){return nt(this,e,t,!0)};function Rt(){if(!this.fired)return this.target.removeListener(this.type,this.wrapFn),this.fired=!0,arguments.length===0?this.listener.call(this.target):this.listener.apply(this.target,arguments)}function it(n,e,t){var i={fired:!1,wrapFn:void 0,target:n,type:e,listener:t},r=Rt.bind(i);return r.listener=t,i.wrapFn=r,r}d.prototype.once=function(e,t){return ae(t),this.on(e,it(this,e,t)),this},d.prototype.prependOnceListener=function(e,t){return ae(t),this.prependListener(e,it(this,e,t)),this},d.prototype.removeListener=function(e,t){var i,r,o,s,c;if(ae(t),r=this._events,r===void 0)return this;if(i=r[e],i===void 0)return this;if(i===t||i.listener===t)--this._eventsCount===0?this._events=Object.create(null):(delete r[e],r.removeListener&&this.emit("removeListener",e,i.listener||t));else if(typeof i!="function"){for(o=-1,s=i.length-1;s>=0;s--)if(i[s]===t||i[s].listener===t){c=i[s].listener,o=s;break}if(o<0)return this;o===0?i.shift():Ot(i,o),i.length===1&&(r[e]=i[0]),r.removeListener!==void 0&&this.emit("removeListener",e,c||t)}return this},d.prototype.off=d.prototype.removeListener,d.prototype.removeAllListeners=function(e){var t,i,r;if(i=this._events,i===void 0)return this;if(i.removeListener===void 0)return arguments.length===0?(this._events=Object.create(null),this._eventsCount=0):i[e]!==void 0&&(--this._eventsCount===0?this._events=Object.create(null):delete i[e]),this;if(arguments.length===0){var o=Object.keys(i),s;for(r=0;r<o.length;++r)s=o[r],s!=="removeListener"&&this.removeAllListeners(s);return this.removeAllListeners("removeListener"),this._events=Object.create(null),this._eventsCount=0,this}if(t=i[e],typeof t=="function")this.removeListener(e,t);else if(t!==void 0)for(r=t.length-1;r>=0;r--)this.removeListener(e,t[r]);return this};function rt(n,e,t){var i=n._events;if(i===void 0)return[];var r=i[e];return r===void 0?[]:typeof r=="function"?t?[r.listener||r]:[r]:t?Ut(r):ot(r,r.length)}d.prototype.listeners=function(e){return rt(this,e,!0)},d.prototype.rawListeners=function(e){return rt(this,e,!1)},d.listenerCount=function(n,e){return typeof n.listenerCount=="function"?n.listenerCount(e):st.call(n,e)},d.prototype.listenerCount=st;function st(n){var e=this._events;if(e!==void 0){var t=e[n];if(typeof t=="function")return 1;if(t!==void 0)return t.length}return 0}d.prototype.eventNames=function(){return this._eventsCount>0?ce(this._events):[]};function ot(n,e){for(var t=new Array(e),i=0;i<e;++i)t[i]=n[i];return t}function Ot(n,e){for(;e+1<n.length;e++)n[e]=n[e+1];n.pop()}function Ut(n){for(var e=new Array(n.length),t=0;t<e.length;++t)e[t]=n[t].listener||n[t];return e}function Nt(n,e){return new Promise(function(t,i){function r(s){n.removeListener(e,o),i(s)}function o(){typeof n.removeListener=="function"&&n.removeListener("error",r),t([].slice.call(arguments))}ct(n,e,o,{once:!0}),e!=="error"&&Wt(n,r,{once:!0})})}function Wt(n,e,t){typeof n.on=="function"&&ct(n,"error",e,t)}function ct(n,e,t,i){if(typeof n.on=="function")i.once?n.once(e,t):n.on(e,t);else if(typeof n.addEventListener=="function")n.addEventListener(e,function r(o){i.once&&n.removeEventListener(e,r),t(o)});else throw new TypeError('The "emitter" argument must be of type EventEmitter. Received type '+typeof n)}var $t=Oe.exports;const le="pc-uploader-iframe-wrapper",Ue="pc-uploader-iframe";class At{constructor(e){if(P(this,R),P(this,Me),P(this,Re),P(this,G,void 0),P(this,B,void 0),P(this,j,void 0),P(this,Y,void 0),P(this,Q,void 0),P(this,ee,void 0),D(this,G,e.token),D(this,B,e.sideId||e.productId),D(this,ee,e.productId?"product":"side"),D(this,j,e.uploaderUrl?e.uploaderUrl:"https://upload-tool.pages.dev"),D(this,Y,new $t),D(this,Q,e.locale),!w(this,G)||!w(this,B)){console.warn("Missing Config Params.");return}M(this,Me,Ze).call(this),M(this,Re,Ge).call(this)}get locale(){return w(this,Q)}open(){let e=document.getElementById(le),t=document.getElementById(Ue);const i=new URL(w(this,j));if(i.searchParams.set("token",w(this,G)),w(this,ee)==="side"?i.searchParams.set("sideId",w(this,B)):w(this,ee)==="product"&&i.searchParams.set("productId",w(this,B)),i.searchParams.set("parentUrl",window.location.href),!t||!(t instanceof HTMLIFrameElement)||!e){console.warn("Can not find iframe element.");return}t.src=i.href,e.style.opacity="1",e.style.visibility="visible",M(this,R,F).call(this,"open")}close(){let e=document.getElementById(le);if(!e){console.error("Can not find iframe element");return}e.style.opacity="0",e.style.visibility="hidden"}on(e,t){return w(this,Y).on(e,t),this}}G=new WeakMap,B=new WeakMap,j=new WeakMap,Y=new WeakMap,Q=new WeakMap,ee=new WeakMap,R=new WeakSet,F=function(n,...e){w(this,Y).emit(n,...e)},Me=new WeakSet,Ze=function(){let n=document.createElement("div");n.id=le,n.style.cssText="position:fixed;top:0;left:0;width:100vw;height:100vh;opacity:0;visibility:hidden;z-index:99999";let e=document.createElement("iframe");e.id=Ue,e.width="100%",e.height="100%",e.style.borderWidth="0",n.appendChild(e),document.body.appendChild(n)},Re=new WeakSet,Ge=function(){let n=document.getElementById(le);window.addEventListener("message",e=>{var t;const i=new URL(e.origin),r=new URL(w(this,j));if(i.host===r.host){e.data.uploaderEvent==="close"&&n&&(n.style.opacity="0",n.style.visibility="hidden",M(this,R,F).call(this,"close")),e.data.uploaderEvent==="upload-success"&&M(this,R,F).call(this,"upload-success",e.data.data),e.data.uploaderEvent==="upload-error"&&M(this,R,F).call(this,"upload-error",e.data.error);const o=w(this,Q),s=document.getElementById(Ue);s&&s instanceof HTMLIFrameElement&&(M(this,R,F).call(this,"onload"),o&&e.data.uploaderEvent==="loaded"&&e.data.finished&&(console.log("test"),s.focus(),(t=s.contentWindow)==null||t.postMessage({locale:o},w(this,j))))}},!1)};var qt="";class Dt{constructor(){h(this,de);h(this,ne);h(this,ue);h(this,pe);h(this,T);h(this,fe);h(this,he);h(this,ve);h(this,me);h(this,ge);h(this,ye);h(this,_e);h(this,we);h(this,Le);h(this,Ee);h(this,be);h(this,Ie);h(this,q,void 0);O(this,"token");O(this,"productIdPC");O(this,"orderIdWix");O(this,"orderNumberWix");O(this,"options");h(this,te,void 0);h(this,_,void 0);h(this,L,void 0);h(this,x,void 0);O(this,"registerListener");this.token=v(this,_e,gt).call(this),this.productIdPC=null,this.orderIdWix=null,this.orderNumberWix=null,U(this,x,null),this.options=window.PrintcartDesignerShopifyOptions,U(this,q,{}.VITE_API_URL?{}.VITE_API_URL:"https://api.printcart.com/v1"),U(this,te,{}.VITE_CUSTOMIZER_URL?{}.VITE_CUSTOMIZER_URL:"https://customizer.printcart.com"),this.registerListener=v(this,de,at).bind(this),window.addEventListener("wixDevelopersAnalyticsReady",this.registerListener)}}q=new WeakMap,te=new WeakMap,_=new WeakMap,L=new WeakMap,x=new WeakMap,de=new WeakSet,at=function(){const e=this;window==null||window.wixDevelopersAnalytics.register({}.APP_ID,function(i,r){var o,s,c;switch(console.log(i),i){case"ViewContent":localStorage.getItem("pc-product")&&localStorage.removeItem("pc-product");break;case"productPageLoaded":if(console.log(r),r.variants&&r.variants.length>1)return;v(o=e,ne,We).call(o,r==null?void 0:r.productId);break;case"CustomizeProduct":if(r.variants&&r.variants.length<1)return;v(s=e,ne,We).call(s,r==null?void 0:r.variantId);break;case"Purchase":if(!localStorage.getItem("pc-design-ids"))return;const u=localStorage.getItem("pc-design-ids");if(e.orderIdWix=r==null?void 0:r.orderId,e.orderNumberWix=r==null?void 0:r.id,!e.orderIdWix)throw new Error("Can not find order ID WIX");if(!e.orderNumberWix)throw new Error("Can not find order number WIX");if(!u)throw new Error("Can not find design Ids");v(c=e,Ie,Et).call(c,e.orderNumberWix,e.orderIdWix,JSON.parse(u));break}})},ne=new WeakSet,We=function(e){if(U(this,x,document.querySelector("[data-hook='product-options']")),!a(this,x))throw new Error("This script can only be used inside a Wix Product Page.");if(!e)throw new Error("Can not find product ID WIX");v(this,Ee,wt).call(this,e).then(t=>{var c,u;if(this.productIdPC=(c=t==null?void 0:t.data)==null?void 0:c.id,!this.productIdPC)throw new Error("Can not find product ID Printcart");v(this,Le,_t).call(this),v(this,be,Lt).call(this),v(this,ue,lt).call(this),v(this,fe,ut).call(this),v(this,he,pt).call(this);const i=document.querySelector("button#pc-btn"),r=t.data.enable_design,o=t.data.enable_upload;r&&(U(this,_,new Tt({token:this.token,productId:this.productIdPC,options:{...(u=this.options)==null?void 0:u.designerOptions,designerUrl:a(this,te)}})),v(this,ye,mt).call(this),i&&i instanceof HTMLButtonElement&&(i.disabled=!1)),o&&(U(this,L,new At({token:this.token,productId:this.productIdPC})),v(this,ge,vt).call(this),i&&i instanceof HTMLButtonElement&&(i.disabled=!1));const s=()=>{a(this,_)&&!a(this,L)&&a(this,_).render(),!a(this,_)&&a(this,L)&&a(this,L).open(),a(this,_)&&a(this,L)&&v(this,pe,dt).call(this)};i&&i instanceof HTMLButtonElement&&(i.onclick=s)})},ue=new WeakSet,lt=function(){const i=` | ||
var Ft=Object.defineProperty;var Ht=(p,f,m)=>f in p?Ft(p,f,{enumerable:!0,configurable:!0,writable:!0,value:m}):p[f]=m;var O=(p,f,m)=>(Ht(p,typeof f!="symbol"?f+"":f,m),m),Ne=(p,f,m)=>{if(!f.has(p))throw TypeError("Cannot "+m)};var c=(p,f,m)=>(Ne(p,f,"read from private field"),m?m.call(p):f.get(p)),h=(p,f,m)=>{if(f.has(p))throw TypeError("Cannot add the same private member more than once");f instanceof WeakSet?f.add(p):f.set(p,m)},U=(p,f,m,N)=>(Ne(p,f,"write to private field"),N?N.call(p,m):f.set(p,m),m);var v=(p,f,m)=>(Ne(p,f,"access private method"),m);(function(p){typeof define=="function"&&define.amd?define(p):p()})(function(){var q,te,_,L,x,de,ct,ne,We,ue,lt,pe,dt,T,z,fe,ut,he,pt,ve,ft,me,ht,ge,vt,ye,mt,_e,gt,we,yt,Le,_t,Ee,wt,be,Lt,Ie,Et;"use strict";var p=Object.defineProperty,f=(n,e,t)=>e in n?p(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t,m=(n,e,t)=>(f(n,typeof e!="symbol"?e+"":e,t),t),N=(n,e,t)=>{if(!e.has(n))throw TypeError("Cannot "+t)},X=(n,e,t)=>(N(n,e,"read from private field"),t?t.call(n):e.get(n)),W=(n,e,t)=>{if(e.has(n))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(n):e.set(n,t)},$e=(n,e,t,i)=>(N(n,e,"write to private field"),i?i.call(n,t):e.set(n,t),t),E=(n,e,t)=>(N(n,e,"access private method"),t),$,J,Pe,Ae,xe,De,ie,ke,I,C,Se={exports:{}},A=typeof Reflect=="object"?Reflect:null,Be=A&&typeof A.apply=="function"?A.apply:function(e,t,i){return Function.prototype.apply.call(e,t,i)},re;A&&typeof A.ownKeys=="function"?re=A.ownKeys:Object.getOwnPropertySymbols?re=function(e){return Object.getOwnPropertyNames(e).concat(Object.getOwnPropertySymbols(e))}:re=function(e){return Object.getOwnPropertyNames(e)};function bt(n){console&&console.warn&&console.warn(n)}var je=Number.isNaN||function(e){return e!==e};function l(){l.init.call(this)}Se.exports=l,Se.exports.once=xt,l.EventEmitter=l,l.prototype._events=void 0,l.prototype._eventsCount=0,l.prototype._maxListeners=void 0;var Fe=10;function se(n){if(typeof n!="function")throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof n)}Object.defineProperty(l,"defaultMaxListeners",{enumerable:!0,get:function(){return Fe},set:function(n){if(typeof n!="number"||n<0||je(n))throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+n+".");Fe=n}}),l.init=function(){(this._events===void 0||this._events===Object.getPrototypeOf(this)._events)&&(this._events=Object.create(null),this._eventsCount=0),this._maxListeners=this._maxListeners||void 0},l.prototype.setMaxListeners=function(e){if(typeof e!="number"||e<0||je(e))throw new RangeError('The value of "n" is out of range. It must be a non-negative number. Received '+e+".");return this._maxListeners=e,this};function He(n){return n._maxListeners===void 0?l.defaultMaxListeners:n._maxListeners}l.prototype.getMaxListeners=function(){return He(this)},l.prototype.emit=function(e){for(var t=[],i=1;i<arguments.length;i++)t.push(arguments[i]);var r=e==="error",o=this._events;if(o!==void 0)r=r&&o.error===void 0;else if(!r)return!1;if(r){var s;if(t.length>0&&(s=t[0]),s instanceof Error)throw s;var a=new Error("Unhandled error."+(s?" ("+s.message+")":""));throw a.context=s,a}var u=o[e];if(u===void 0)return!1;if(typeof u=="function")Be(u,this,t);else for(var g=u.length,y=Xe(u,g),i=0;i<g;++i)Be(y[i],this,t);return!0};function qe(n,e,t,i){var r,o,s;if(se(t),o=n._events,o===void 0?(o=n._events=Object.create(null),n._eventsCount=0):(o.newListener!==void 0&&(n.emit("newListener",e,t.listener?t.listener:t),o=n._events),s=o[e]),s===void 0)s=o[e]=t,++n._eventsCount;else if(typeof s=="function"?s=o[e]=i?[t,s]:[s,t]:i?s.unshift(t):s.push(t),r=He(n),r>0&&s.length>r&&!s.warned){s.warned=!0;var a=new Error("Possible EventEmitter memory leak detected. "+s.length+" "+String(e)+" listeners added. Use emitter.setMaxListeners() to increase limit");a.name="MaxListenersExceededWarning",a.emitter=n,a.type=e,a.count=s.length,bt(a)}return n}l.prototype.addListener=function(e,t){return qe(this,e,t,!1)},l.prototype.on=l.prototype.addListener,l.prototype.prependListener=function(e,t){return qe(this,e,t,!0)};function It(){if(!this.fired)return this.target.removeListener(this.type,this.wrapFn),this.fired=!0,arguments.length===0?this.listener.call(this.target):this.listener.apply(this.target,arguments)}function Ke(n,e,t){var i={fired:!1,wrapFn:void 0,target:n,type:e,listener:t},r=It.bind(i);return r.listener=t,i.wrapFn=r,r}l.prototype.once=function(e,t){return se(t),this.on(e,Ke(this,e,t)),this},l.prototype.prependOnceListener=function(e,t){return se(t),this.prependListener(e,Ke(this,e,t)),this},l.prototype.removeListener=function(e,t){var i,r,o,s,a;if(se(t),r=this._events,r===void 0)return this;if(i=r[e],i===void 0)return this;if(i===t||i.listener===t)--this._eventsCount===0?this._events=Object.create(null):(delete r[e],r.removeListener&&this.emit("removeListener",e,i.listener||t));else if(typeof i!="function"){for(o=-1,s=i.length-1;s>=0;s--)if(i[s]===t||i[s].listener===t){a=i[s].listener,o=s;break}if(o<0)return this;o===0?i.shift():Ct(i,o),i.length===1&&(r[e]=i[0]),r.removeListener!==void 0&&this.emit("removeListener",e,a||t)}return this},l.prototype.off=l.prototype.removeListener,l.prototype.removeAllListeners=function(e){var t,i,r;if(i=this._events,i===void 0)return this;if(i.removeListener===void 0)return arguments.length===0?(this._events=Object.create(null),this._eventsCount=0):i[e]!==void 0&&(--this._eventsCount===0?this._events=Object.create(null):delete i[e]),this;if(arguments.length===0){var o=Object.keys(i),s;for(r=0;r<o.length;++r)s=o[r],s!=="removeListener"&&this.removeAllListeners(s);return this.removeAllListeners("removeListener"),this._events=Object.create(null),this._eventsCount=0,this}if(t=i[e],typeof t=="function")this.removeListener(e,t);else if(t!==void 0)for(r=t.length-1;r>=0;r--)this.removeListener(e,t[r]);return this};function Ve(n,e,t){var i=n._events;if(i===void 0)return[];var r=i[e];return r===void 0?[]:typeof r=="function"?t?[r.listener||r]:[r]:t?Pt(r):Xe(r,r.length)}l.prototype.listeners=function(e){return Ve(this,e,!0)},l.prototype.rawListeners=function(e){return Ve(this,e,!1)},l.listenerCount=function(n,e){return typeof n.listenerCount=="function"?n.listenerCount(e):ze.call(n,e)},l.prototype.listenerCount=ze;function ze(n){var e=this._events;if(e!==void 0){var t=e[n];if(typeof t=="function")return 1;if(t!==void 0)return t.length}return 0}l.prototype.eventNames=function(){return this._eventsCount>0?re(this._events):[]};function Xe(n,e){for(var t=new Array(e),i=0;i<e;++i)t[i]=n[i];return t}function Ct(n,e){for(;e+1<n.length;e++)n[e]=n[e+1];n.pop()}function Pt(n){for(var e=new Array(n.length),t=0;t<e.length;++t)e[t]=n[t].listener||n[t];return e}function xt(n,e){return new Promise(function(t,i){function r(s){n.removeListener(e,o),i(s)}function o(){typeof n.removeListener=="function"&&n.removeListener("error",r),t([].slice.call(arguments))}Je(n,e,o,{once:!0}),e!=="error"&&kt(n,r,{once:!0})})}function kt(n,e,t){typeof n.on=="function"&&Je(n,"error",e,t)}function Je(n,e,t,i){if(typeof n.on=="function")i.once?n.once(e,t):n.on(e,t);else if(typeof n.addEventListener=="function")n.addEventListener(e,function r(o){i.once&&n.removeEventListener(e,r),t(o)});else throw new TypeError('The "emitter" argument must be of type EventEmitter. Received type '+typeof n)}var St=Se.exports;const Z="pc-designer-iframe-wrapper",oe="pc-designer-iframe";class Tt{constructor(e){W(this,Pe),W(this,xe),W(this,ie),W(this,I),m(this,"token"),m(this,"productId"),m(this,"options"),W(this,$,void 0),W(this,J,void 0);var t;if(this.token=e.token,this.productId=e.productId,this.options=e.options,$e(this,$,(t=this.options)!=null&&t.designerUrl?this.options.designerUrl:{}.VITE_CUSTOMIZER_URL?{}.VITE_CUSTOMIZER_URL:"https://customizer.printcart.com"),$e(this,J,new St),!this.token||!this.productId){console.error("Missing Config Params");return}E(this,Pe,Ae).call(this),E(this,xe,De).call(this)}render(){const e=document.getElementById(Z),t=document.getElementById(oe);if(!t||!(t instanceof HTMLIFrameElement)||!e){console.error("Can not find iframe element");return}const i=E(this,ie,ke).call(this);t.src=i.href,e.style.opacity="1",e.style.visibility="visible",E(this,I,C).call(this,"rendered")}close(){const e=document.getElementById(Z);if(!e){console.error("Can not find iframe element");return}e.style.opacity="0",e.style.visibility="hidden",E(this,I,C).call(this,"closed")}editDesign(e){const t=E(this,ie,ke).call(this);t.searchParams.set("design_id",e),t.searchParams.set("task","edit");const i=document.getElementById(Z),r=document.getElementById(oe);if(!r||!(r instanceof HTMLIFrameElement)||!i){console.error("Can not find iframe element");return}r.src=t.href,i.style.opacity="1",i.style.visibility="visible",E(this,I,C).call(this,"edit")}on(e,t){return X(this,J).on(e,t),this}}$=new WeakMap,J=new WeakMap,Pe=new WeakSet,Ae=function(){const n=document.createElement("div");n.id=Z,n.style.cssText="position:fixed;top:0;left:0;width:100vw;height:100vh;opacity:0;visibility:hidden;z-index:99999";const e=document.createElement("iframe");e.id=oe,e.width="100%",e.height="100%",n.appendChild(e),document.body.appendChild(n)},xe=new WeakSet,De=function(){window.addEventListener("message",n=>{if(n.origin===X(this,$)&&n.data.message==="closeDesignTool"){const e=document.getElementById(Z);if(!e)return;e.style.opacity="0",e.style.visibility="hidden",E(this,I,C).call(this,"closed")}if(n.data.message==="finishLoad"){const e=document.getElementById(oe);E(this,I,C).call(this,"render-finish"),e&&e instanceof HTMLIFrameElement&&e.contentWindow&&e.contentWindow.postMessage({message:"customSettings",settings:this.options},X(this,$))}n.data.message==="finishProcess"&&E(this,I,C).call(this,"upload-success",n.data.data.data),n.data.message==="finishUpdate"&&E(this,I,C).call(this,"edit-success",n.data.data.data),n.data.message==="uploadError"&&E(this,I,C).call(this,"upload-error",n.data)},!1)},ie=new WeakSet,ke=function(){const n=new URL(X(this,$));return n.searchParams.set("api_key",this.token),n.searchParams.set("product_id",this.productId),n.searchParams.set("parentUrl",window.location.href),n},I=new WeakSet,C=function(n,...e){X(this,J).emit(n,...e)};var Te=(n,e,t)=>{if(!e.has(n))throw TypeError("Cannot "+t)},w=(n,e,t)=>(Te(n,e,"read from private field"),t?t.call(n):e.get(n)),P=(n,e,t)=>{if(e.has(n))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(n):e.set(n,t)},D=(n,e,t,i)=>(Te(n,e,"write to private field"),i?i.call(n,t):e.set(n,t),t),M=(n,e,t)=>(Te(n,e,"access private method"),t),G,B,j,Y,Q,ee,R,F,Me,Ze,Re,Ge,Oe={exports:{}},H=typeof Reflect=="object"?Reflect:null,Ye=H&&typeof H.apply=="function"?H.apply:function(e,t,i){return Function.prototype.apply.call(e,t,i)},ae;H&&typeof H.ownKeys=="function"?ae=H.ownKeys:Object.getOwnPropertySymbols?ae=function(e){return Object.getOwnPropertyNames(e).concat(Object.getOwnPropertySymbols(e))}:ae=function(e){return Object.getOwnPropertyNames(e)};function Mt(n){console&&console.warn&&console.warn(n)}var Qe=Number.isNaN||function(e){return e!==e};function d(){d.init.call(this)}Oe.exports=d,Oe.exports.once=Nt,d.EventEmitter=d,d.prototype._events=void 0,d.prototype._eventsCount=0,d.prototype._maxListeners=void 0;var et=10;function ce(n){if(typeof n!="function")throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof n)}Object.defineProperty(d,"defaultMaxListeners",{enumerable:!0,get:function(){return et},set:function(n){if(typeof n!="number"||n<0||Qe(n))throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+n+".");et=n}}),d.init=function(){(this._events===void 0||this._events===Object.getPrototypeOf(this)._events)&&(this._events=Object.create(null),this._eventsCount=0),this._maxListeners=this._maxListeners||void 0},d.prototype.setMaxListeners=function(e){if(typeof e!="number"||e<0||Qe(e))throw new RangeError('The value of "n" is out of range. It must be a non-negative number. Received '+e+".");return this._maxListeners=e,this};function tt(n){return n._maxListeners===void 0?d.defaultMaxListeners:n._maxListeners}d.prototype.getMaxListeners=function(){return tt(this)},d.prototype.emit=function(e){for(var t=[],i=1;i<arguments.length;i++)t.push(arguments[i]);var r=e==="error",o=this._events;if(o!==void 0)r=r&&o.error===void 0;else if(!r)return!1;if(r){var s;if(t.length>0&&(s=t[0]),s instanceof Error)throw s;var a=new Error("Unhandled error."+(s?" ("+s.message+")":""));throw a.context=s,a}var u=o[e];if(u===void 0)return!1;if(typeof u=="function")Ye(u,this,t);else for(var g=u.length,y=ot(u,g),i=0;i<g;++i)Ye(y[i],this,t);return!0};function nt(n,e,t,i){var r,o,s;if(ce(t),o=n._events,o===void 0?(o=n._events=Object.create(null),n._eventsCount=0):(o.newListener!==void 0&&(n.emit("newListener",e,t.listener?t.listener:t),o=n._events),s=o[e]),s===void 0)s=o[e]=t,++n._eventsCount;else if(typeof s=="function"?s=o[e]=i?[t,s]:[s,t]:i?s.unshift(t):s.push(t),r=tt(n),r>0&&s.length>r&&!s.warned){s.warned=!0;var a=new Error("Possible EventEmitter memory leak detected. "+s.length+" "+String(e)+" listeners added. Use emitter.setMaxListeners() to increase limit");a.name="MaxListenersExceededWarning",a.emitter=n,a.type=e,a.count=s.length,Mt(a)}return n}d.prototype.addListener=function(e,t){return nt(this,e,t,!1)},d.prototype.on=d.prototype.addListener,d.prototype.prependListener=function(e,t){return nt(this,e,t,!0)};function Rt(){if(!this.fired)return this.target.removeListener(this.type,this.wrapFn),this.fired=!0,arguments.length===0?this.listener.call(this.target):this.listener.apply(this.target,arguments)}function it(n,e,t){var i={fired:!1,wrapFn:void 0,target:n,type:e,listener:t},r=Rt.bind(i);return r.listener=t,i.wrapFn=r,r}d.prototype.once=function(e,t){return ce(t),this.on(e,it(this,e,t)),this},d.prototype.prependOnceListener=function(e,t){return ce(t),this.prependListener(e,it(this,e,t)),this},d.prototype.removeListener=function(e,t){var i,r,o,s,a;if(ce(t),r=this._events,r===void 0)return this;if(i=r[e],i===void 0)return this;if(i===t||i.listener===t)--this._eventsCount===0?this._events=Object.create(null):(delete r[e],r.removeListener&&this.emit("removeListener",e,i.listener||t));else if(typeof i!="function"){for(o=-1,s=i.length-1;s>=0;s--)if(i[s]===t||i[s].listener===t){a=i[s].listener,o=s;break}if(o<0)return this;o===0?i.shift():Ot(i,o),i.length===1&&(r[e]=i[0]),r.removeListener!==void 0&&this.emit("removeListener",e,a||t)}return this},d.prototype.off=d.prototype.removeListener,d.prototype.removeAllListeners=function(e){var t,i,r;if(i=this._events,i===void 0)return this;if(i.removeListener===void 0)return arguments.length===0?(this._events=Object.create(null),this._eventsCount=0):i[e]!==void 0&&(--this._eventsCount===0?this._events=Object.create(null):delete i[e]),this;if(arguments.length===0){var o=Object.keys(i),s;for(r=0;r<o.length;++r)s=o[r],s!=="removeListener"&&this.removeAllListeners(s);return this.removeAllListeners("removeListener"),this._events=Object.create(null),this._eventsCount=0,this}if(t=i[e],typeof t=="function")this.removeListener(e,t);else if(t!==void 0)for(r=t.length-1;r>=0;r--)this.removeListener(e,t[r]);return this};function rt(n,e,t){var i=n._events;if(i===void 0)return[];var r=i[e];return r===void 0?[]:typeof r=="function"?t?[r.listener||r]:[r]:t?Ut(r):ot(r,r.length)}d.prototype.listeners=function(e){return rt(this,e,!0)},d.prototype.rawListeners=function(e){return rt(this,e,!1)},d.listenerCount=function(n,e){return typeof n.listenerCount=="function"?n.listenerCount(e):st.call(n,e)},d.prototype.listenerCount=st;function st(n){var e=this._events;if(e!==void 0){var t=e[n];if(typeof t=="function")return 1;if(t!==void 0)return t.length}return 0}d.prototype.eventNames=function(){return this._eventsCount>0?ae(this._events):[]};function ot(n,e){for(var t=new Array(e),i=0;i<e;++i)t[i]=n[i];return t}function Ot(n,e){for(;e+1<n.length;e++)n[e]=n[e+1];n.pop()}function Ut(n){for(var e=new Array(n.length),t=0;t<e.length;++t)e[t]=n[t].listener||n[t];return e}function Nt(n,e){return new Promise(function(t,i){function r(s){n.removeListener(e,o),i(s)}function o(){typeof n.removeListener=="function"&&n.removeListener("error",r),t([].slice.call(arguments))}at(n,e,o,{once:!0}),e!=="error"&&Wt(n,r,{once:!0})})}function Wt(n,e,t){typeof n.on=="function"&&at(n,"error",e,t)}function at(n,e,t,i){if(typeof n.on=="function")i.once?n.once(e,t):n.on(e,t);else if(typeof n.addEventListener=="function")n.addEventListener(e,function r(o){i.once&&n.removeEventListener(e,r),t(o)});else throw new TypeError('The "emitter" argument must be of type EventEmitter. Received type '+typeof n)}var $t=Oe.exports;const le="pc-uploader-iframe-wrapper",Ue="pc-uploader-iframe";class At{constructor(e){if(P(this,R),P(this,Me),P(this,Re),P(this,G,void 0),P(this,B,void 0),P(this,j,void 0),P(this,Y,void 0),P(this,Q,void 0),P(this,ee,void 0),D(this,G,e.token),D(this,B,e.sideId||e.productId),D(this,ee,e.productId?"product":"side"),D(this,j,e.uploaderUrl?e.uploaderUrl:"https://upload-tool.pages.dev"),D(this,Y,new $t),D(this,Q,e.locale),!w(this,G)||!w(this,B)){console.warn("Missing Config Params.");return}M(this,Me,Ze).call(this),M(this,Re,Ge).call(this)}get locale(){return w(this,Q)}open(){let e=document.getElementById(le),t=document.getElementById(Ue);const i=new URL(w(this,j));if(i.searchParams.set("token",w(this,G)),w(this,ee)==="side"?i.searchParams.set("sideId",w(this,B)):w(this,ee)==="product"&&i.searchParams.set("productId",w(this,B)),i.searchParams.set("parentUrl",window.location.href),!t||!(t instanceof HTMLIFrameElement)||!e){console.warn("Can not find iframe element.");return}t.src=i.href,e.style.opacity="1",e.style.visibility="visible",M(this,R,F).call(this,"open")}close(){let e=document.getElementById(le);if(!e){console.error("Can not find iframe element");return}e.style.opacity="0",e.style.visibility="hidden"}on(e,t){return w(this,Y).on(e,t),this}}G=new WeakMap,B=new WeakMap,j=new WeakMap,Y=new WeakMap,Q=new WeakMap,ee=new WeakMap,R=new WeakSet,F=function(n,...e){w(this,Y).emit(n,...e)},Me=new WeakSet,Ze=function(){let n=document.createElement("div");n.id=le,n.style.cssText="position:fixed;top:0;left:0;width:100vw;height:100vh;opacity:0;visibility:hidden;z-index:99999";let e=document.createElement("iframe");e.id=Ue,e.width="100%",e.height="100%",e.style.borderWidth="0",n.appendChild(e),document.body.appendChild(n)},Re=new WeakSet,Ge=function(){let n=document.getElementById(le);window.addEventListener("message",e=>{var t;const i=new URL(e.origin),r=new URL(w(this,j));if(i.host===r.host){e.data.uploaderEvent==="close"&&n&&(n.style.opacity="0",n.style.visibility="hidden",M(this,R,F).call(this,"close")),e.data.uploaderEvent==="upload-success"&&M(this,R,F).call(this,"upload-success",e.data.data),e.data.uploaderEvent==="upload-error"&&M(this,R,F).call(this,"upload-error",e.data.error);const o=w(this,Q),s=document.getElementById(Ue);s&&s instanceof HTMLIFrameElement&&(M(this,R,F).call(this,"onload"),o&&e.data.uploaderEvent==="loaded"&&e.data.finished&&(console.log("test"),s.focus(),(t=s.contentWindow)==null||t.postMessage({locale:o},w(this,j))))}},!1)};var qt="";class Dt{constructor(){h(this,de);h(this,ne);h(this,ue);h(this,pe);h(this,T);h(this,fe);h(this,he);h(this,ve);h(this,me);h(this,ge);h(this,ye);h(this,_e);h(this,we);h(this,Le);h(this,Ee);h(this,be);h(this,Ie);h(this,q,void 0);O(this,"token");O(this,"productIdPC");O(this,"orderIdWix");O(this,"orderNumberWix");O(this,"options");h(this,te,void 0);h(this,_,void 0);h(this,L,void 0);h(this,x,void 0);O(this,"registerListener");this.token=v(this,_e,gt).call(this),this.productIdPC=null,this.orderIdWix=null,this.orderNumberWix=null,U(this,x,null),this.options=window.PrintcartDesignerShopifyOptions,U(this,q,{}.VITE_API_URL?{}.VITE_API_URL:"https://api.printcart.com/v1"),U(this,te,{}.VITE_CUSTOMIZER_URL?{}.VITE_CUSTOMIZER_URL:"https://customizer.printcart.com"),this.registerListener=v(this,de,ct).bind(this),window.addEventListener("wixDevelopersAnalyticsReady",this.registerListener)}}q=new WeakMap,te=new WeakMap,_=new WeakMap,L=new WeakMap,x=new WeakMap,de=new WeakSet,ct=function(){const e=this;window==null||window.wixDevelopersAnalytics.register({}.APP_ID,function(i,r){var o,s,a;switch(i){case"ViewContent":localStorage.getItem("pc-product")&&localStorage.removeItem("pc-product");break;case"productPageLoaded":if(r.variants&&r.variants.length>1)return;v(o=e,ne,We).call(o,r==null?void 0:r.productId);break;case"CustomizeProduct":if(r.variants&&r.variants.length<1)return;v(s=e,ne,We).call(s,r==null?void 0:r.variantId);break;case"Purchase":if(!localStorage.getItem("pc-design-ids"))return;const u=localStorage.getItem("pc-design-ids");if(e.orderIdWix=r==null?void 0:r.orderId,e.orderNumberWix=r==null?void 0:r.id,!e.orderIdWix)throw new Error("Can not find order ID WIX");if(!e.orderNumberWix)throw new Error("Can not find order number WIX");if(!u)throw new Error("Can not find design Ids");v(a=e,Ie,Et).call(a,e.orderNumberWix,e.orderIdWix,JSON.parse(u));break}})},ne=new WeakSet,We=function(e){if(U(this,x,document.querySelector("[data-hook='product-options']")),!c(this,x))throw new Error("This script can only be used inside a Wix Product Page.");if(!e)throw new Error("Can not find product ID WIX");v(this,Ee,wt).call(this,e).then(t=>{var a,u;if(this.productIdPC=(a=t==null?void 0:t.data)==null?void 0:a.id,!this.productIdPC)throw new Error("Can not find product ID Printcart");v(this,Le,_t).call(this),v(this,be,Lt).call(this),v(this,ue,lt).call(this),v(this,fe,ut).call(this),v(this,he,pt).call(this);const i=document.querySelector("button#pc-btn"),r=t.data.enable_design,o=t.data.enable_upload;r&&(U(this,_,new Tt({token:this.token,productId:this.productIdPC,options:{...(u=this.options)==null?void 0:u.designerOptions,designerUrl:c(this,te)}})),v(this,ye,mt).call(this),i&&i instanceof HTMLButtonElement&&(i.disabled=!1)),o&&(U(this,L,new At({token:this.token,productId:this.productIdPC})),v(this,ge,vt).call(this),i&&i instanceof HTMLButtonElement&&(i.disabled=!1));const s=()=>{c(this,_)&&!c(this,L)&&c(this,_).render(),!c(this,_)&&c(this,L)&&c(this,L).open(),c(this,_)&&c(this,L)&&v(this,pe,dt).call(this)};i&&i instanceof HTMLButtonElement&&(i.onclick=s)})},ue=new WeakSet,lt=function(){const i=` | ||
<button aria-label="Close" id="pc-select_close-btn"><span data-modal-x></span></button> | ||
@@ -48,2 +48,2 @@ <div class="pc-select-wrap" id="pc-content-overlay"> | ||
</div> | ||
`,r=document.createElement("div");r.id="pc-select_wrap",r.setAttribute("role","dialog"),r.setAttribute("aria-modal","true"),r.setAttribute("tabIndex","-1"),r.innerHTML=i,document.body.appendChild(r);const o=()=>{a(this,_)&&(v(this,T,z).call(this),a(this,_).render())},s=()=>{a(this,L)&&(v(this,T,z).call(this),a(this,L).open())},c=document.getElementById("pc-select_btn_upload"),u=document.getElementById("pc-select_btn_design");c&&(c==null||c.addEventListener("click",s)),u&&(u==null||u.addEventListener("click",o))},pe=new WeakSet,dt=function(){const e=document.getElementById("pc-select_wrap");e&&(e.style.display="flex",document.body.classList.toggle("pc-overflow"));const t=e==null?void 0:e.querySelector("#pc-select_close-btn");t&&t instanceof HTMLButtonElement&&t.focus()},T=new WeakSet,z=function(){const e=document.getElementById("pc-select_wrap");e&&(e.style.display="none",document.body.classList.toggle("pc-overflow"))},fe=new WeakSet,ut=function(){const e=document.getElementById("pc-select_close-btn"),t=document.getElementById("pc-content-overlay"),i=r=>{r.key==="Escape"&&v(this,T,z).call(this)};window.addEventListener("keydown",i),e==null||e.addEventListener("click",()=>v(this,T,z).call(this)),t==null||t.addEventListener("click",()=>v(this,T,z).call(this))},he=new WeakSet,pt=function(){const e=document.getElementById("pc-select_wrap"),t=e==null?void 0:e.querySelectorAll("button"),i=t&&t[0],r=t&&t[t.length-1],o=s=>{s.key==="Tab"&&(s.shiftKey?r&&document.activeElement===i&&(r.focus(),s.preventDefault()):i&&document.activeElement===r&&(i.focus(),s.preventDefault()))};window.addEventListener("keydown",o)},ve=new WeakSet,ft=function(e){var c,u;const t=e.map(g=>g.data.id);let i=document.querySelector('input[name="properties[_pcDesignIds]"]');i?i.value+=`,${t.join()}`:(i=document.createElement("input"),i.type="hidden",i.name="properties[_pcDesignIds]",i.className="pc-designer_input",i.value=t.join(),(c=a(this,x))==null||c.appendChild(i));const r=document.querySelector(".pc-preview-wrap")||document.createElement("div");r.className="pc-preview-wrap",localStorage.getItem("pc-design-ids")&&localStorage.removeItem("pc-design-ids"),localStorage.setItem("pc-design-ids",JSON.stringify(t)),e.forEach(g=>{var K;if(!g.data.design_image.url)return;const y=document.createElement("div");y.className="pc-preview",y.setAttribute("data-pc-design-id",g.data.id);const b=document.createElement("button");b.className="pc-btn pc-danger-btn",b.innerHTML=(K=this.options)!=null&&K.removeUploaderBtnText?this.options.removeUploaderBtnText:"Remove",b.onclick=()=>{const V=i.value.split(",").filter(Ce=>Ce!==g.data.id);i.value=V.join(),y.remove()};const k=document.createElement("img");k.src=g.data.design_image.url,k.className="pc-uploader-image";const S=document.createElement("div");S.className="pc-preview-overlay",S.appendChild(b),y.appendChild(S),y.appendChild(k),r.appendChild(y)});const o=document.querySelector("div#pc-designer_wrap");if(!document.querySelector(".princart-preview-heading")){const g=document.createElement("h5");g.className="princart-preview-heading",g.innerHTML="Your artworks",o==null||o.appendChild(g)}o==null||o.appendChild(r);const s=(u=this.options)==null?void 0:u.onUploadSuccess;s&&s(e,a(this,L))},me=new WeakSet,ht=function(e){var u,g;const t=this,i=e.map(y=>y.id);let r=document.querySelector('input[name="properties[_pcDesignIds]"]');r?r.value+=`,${i.join()}`:(r=document.createElement("input"),r.type="hidden",r.name="properties[_pcDesignIds]",r.className="pc-designer_input",r.value=i.join(),(u=a(this,x))==null||u.appendChild(r));const o=document.querySelector(".pc-preview-wrap")||document.createElement("div");o.className="pc-preview-wrap",localStorage.getItem("pc-design-ids")&&localStorage.removeItem("pc-design-ids"),localStorage.setItem("pc-design-ids",JSON.stringify(i)),e.forEach(y=>{var Ce;if(!y.design_image.url)return;const b=document.createElement("div");b.className="pc-preview",b.setAttribute("data-pc-design-id",y.id);const k=document.createElement("button");k.className="pc-btn pc-primary-btn",k.style.borderRadius="5px",k.innerHTML="Edit",k.onclick=()=>{a(t,_).editDesign(y.id)};const S=document.createElement("button");S.className="pc-btn pc-danger-btn",S.style.borderRadius="5px",S.innerHTML="Remove",S.onclick=()=>{const Bt=r.value.split(",").filter(jt=>jt!==y.id);r.value=Bt.join(),b.remove()};const K=document.createElement("img");K.src=((Ce=y.preview_image)==null?void 0:Ce.url)||y.design_image.url,K.className="pc-uploader-image";const V=document.createElement("div");V.className="pc-preview-overlay",V.appendChild(k),V.appendChild(S),b.appendChild(V),b.appendChild(K),o.appendChild(b)});const s=document.querySelector("div#pc-designer_wrap");s==null||s.appendChild(o);const c=(g=this.options)==null?void 0:g.onDesignCreateSuccess;c&&c(e,a(this,_))},ge=new WeakSet,vt=function(){a(this,L)&&a(this,L).on("upload-success",e=>{v(this,ve,ft).call(this,e),a(this,L).close()})},ye=new WeakSet,mt=function(){a(this,_)&&(a(this,_).on("upload-success",e=>{v(this,me,ht).call(this,e),a(this,_).close()}),a(this,_).on("edit-success",e=>{var r;if(!e.design_image.url)return;const t=document.querySelector(`[data-pc-design-id="${e.id}"] img`);if(!t||!(t instanceof HTMLImageElement))throw new Error("Can't find image element");t.src=e.design_image.url;const i=(r=this.options)==null?void 0:r.onDesignEditSuccess;a(this,_).close(),i&&i(e,a(this,_))}))},_e=new WeakSet,gt=function(){const e=v(this,we,yt).call(this),t=new URL(e);return new URLSearchParams(t.search).get("shopT")},we=new WeakSet,yt=function(){return document.querySelector("[id='pc-wix-integration-sdk']").src},Le=new WeakSet,_t=function(){const e={}.VITE_SDK_URL?{}.VITE_SDK_URL:"https://unpkg.com/@printcart/wix-integration/dist",t=document.createElement("link");t.rel="stylesheet",t.href=`${e}/style.css`,document.head.appendChild(t)},Ee=new WeakSet,wt=async function(e){try{const t=`${a(this,q)}/integration/wix/products/${e}`,i=this.token;if(!i)throw new Error("Missing Printcart Unauth Token");return await(await fetch(t,{headers:{"X-PrintCart-Unauth-Token":i}})).json()}catch(t){console.error("There has been a problem with your fetch operation:",t);return}},be=new WeakSet,Lt=function(){var r,o,s;const e=a(this,x);if(!(e!=null&&e.parentNode)){console.log("Can not find cart form");return}if(document.getElementById("pc-designer_wrap")!==null)return;const t=document.createElement("div");t.id="pc-designer_wrap";const i=document.createElement("button");i.id="pc-btn",i.className=(r=this.options)!=null&&r.designClassName?(o=this.options)==null?void 0:o.designClassName:"",i.innerHTML=(s=this.options)!=null&&s.designBtnText?this.options.designBtnText:"Start Design",i.disabled=!0,t.appendChild(i),e.appendChild(t)},Ie=new WeakSet,Et=async function(e,t,i){try{const r=`${a(this,q)}/projects`,o=this.token;if(!o)throw new Error("Missing Printcart Unauth Token");const s={name:`${e}`,status:"processing",design_ids:i,order_detail:{id:t}};await fetch(r,{method:"POST",headers:{"Content-Type":"application/json","X-PrintCart-Unauth-Token":o},body:JSON.stringify(s)})}catch(r){console.error("There has been a problem with your fetch operation:",r);return}},(async()=>{})().then(()=>new Dt)}); | ||
`,r=document.createElement("div");r.id="pc-select_wrap",r.setAttribute("role","dialog"),r.setAttribute("aria-modal","true"),r.setAttribute("tabIndex","-1"),r.innerHTML=i,document.body.appendChild(r);const o=()=>{c(this,_)&&(v(this,T,z).call(this),c(this,_).render())},s=()=>{c(this,L)&&(v(this,T,z).call(this),c(this,L).open())},a=document.getElementById("pc-select_btn_upload"),u=document.getElementById("pc-select_btn_design");a&&(a==null||a.addEventListener("click",s)),u&&(u==null||u.addEventListener("click",o))},pe=new WeakSet,dt=function(){const e=document.getElementById("pc-select_wrap");e&&(e.style.display="flex",document.body.classList.toggle("pc-overflow"));const t=e==null?void 0:e.querySelector("#pc-select_close-btn");t&&t instanceof HTMLButtonElement&&t.focus()},T=new WeakSet,z=function(){const e=document.getElementById("pc-select_wrap");e&&(e.style.display="none",document.body.classList.toggle("pc-overflow"))},fe=new WeakSet,ut=function(){const e=document.getElementById("pc-select_close-btn"),t=document.getElementById("pc-content-overlay"),i=r=>{r.key==="Escape"&&v(this,T,z).call(this)};window.addEventListener("keydown",i),e==null||e.addEventListener("click",()=>v(this,T,z).call(this)),t==null||t.addEventListener("click",()=>v(this,T,z).call(this))},he=new WeakSet,pt=function(){const e=document.getElementById("pc-select_wrap"),t=e==null?void 0:e.querySelectorAll("button"),i=t&&t[0],r=t&&t[t.length-1],o=s=>{s.key==="Tab"&&(s.shiftKey?r&&document.activeElement===i&&(r.focus(),s.preventDefault()):i&&document.activeElement===r&&(i.focus(),s.preventDefault()))};window.addEventListener("keydown",o)},ve=new WeakSet,ft=function(e){var a,u;const t=e.map(g=>g.data.id);let i=document.querySelector('input[name="properties[_pcDesignIds]"]');i?i.value+=`,${t.join()}`:(i=document.createElement("input"),i.type="hidden",i.name="properties[_pcDesignIds]",i.className="pc-designer_input",i.value=t.join(),(a=c(this,x))==null||a.appendChild(i));const r=document.querySelector(".pc-preview-wrap")||document.createElement("div");r.className="pc-preview-wrap",localStorage.getItem("pc-design-ids")&&localStorage.removeItem("pc-design-ids"),localStorage.setItem("pc-design-ids",JSON.stringify(t)),e.forEach(g=>{var K;if(!g.data.design_image.url)return;const y=document.createElement("div");y.className="pc-preview",y.setAttribute("data-pc-design-id",g.data.id);const b=document.createElement("button");b.className="pc-btn pc-danger-btn",b.innerHTML=(K=this.options)!=null&&K.removeUploaderBtnText?this.options.removeUploaderBtnText:"Remove",b.onclick=()=>{const V=i.value.split(",").filter(Ce=>Ce!==g.data.id);i.value=V.join(),y.remove()};const k=document.createElement("img");k.src=g.data.design_image.url,k.className="pc-uploader-image";const S=document.createElement("div");S.className="pc-preview-overlay",S.appendChild(b),y.appendChild(S),y.appendChild(k),r.appendChild(y)});const o=document.querySelector("div#pc-designer_wrap");if(!document.querySelector(".princart-preview-heading")){const g=document.createElement("h5");g.className="princart-preview-heading",g.innerHTML="Your artworks",o==null||o.appendChild(g)}o==null||o.appendChild(r);const s=(u=this.options)==null?void 0:u.onUploadSuccess;s&&s(e,c(this,L))},me=new WeakSet,ht=function(e){var u,g;const t=this,i=e.map(y=>y.id);let r=document.querySelector('input[name="properties[_pcDesignIds]"]');r?r.value+=`,${i.join()}`:(r=document.createElement("input"),r.type="hidden",r.name="properties[_pcDesignIds]",r.className="pc-designer_input",r.value=i.join(),(u=c(this,x))==null||u.appendChild(r));const o=document.querySelector(".pc-preview-wrap")||document.createElement("div");o.className="pc-preview-wrap",localStorage.getItem("pc-design-ids")&&localStorage.removeItem("pc-design-ids"),localStorage.setItem("pc-design-ids",JSON.stringify(i)),e.forEach(y=>{var Ce;if(!y.design_image.url)return;const b=document.createElement("div");b.className="pc-preview",b.setAttribute("data-pc-design-id",y.id);const k=document.createElement("button");k.className="pc-btn pc-primary-btn",k.style.borderRadius="5px",k.innerHTML="Edit",k.onclick=()=>{c(t,_).editDesign(y.id)};const S=document.createElement("button");S.className="pc-btn pc-danger-btn",S.style.borderRadius="5px",S.innerHTML="Remove",S.onclick=()=>{const Bt=r.value.split(",").filter(jt=>jt!==y.id);r.value=Bt.join(),b.remove()};const K=document.createElement("img");K.src=((Ce=y.preview_image)==null?void 0:Ce.url)||y.design_image.url,K.className="pc-uploader-image";const V=document.createElement("div");V.className="pc-preview-overlay",V.appendChild(k),V.appendChild(S),b.appendChild(V),b.appendChild(K),o.appendChild(b)});const s=document.querySelector("div#pc-designer_wrap");s==null||s.appendChild(o);const a=(g=this.options)==null?void 0:g.onDesignCreateSuccess;a&&a(e,c(this,_))},ge=new WeakSet,vt=function(){c(this,L)&&c(this,L).on("upload-success",e=>{v(this,ve,ft).call(this,e),c(this,L).close()})},ye=new WeakSet,mt=function(){c(this,_)&&(c(this,_).on("upload-success",e=>{v(this,me,ht).call(this,e),c(this,_).close()}),c(this,_).on("edit-success",e=>{var r;if(!e.design_image.url)return;const t=document.querySelector(`[data-pc-design-id="${e.id}"] img`);if(!t||!(t instanceof HTMLImageElement))throw new Error("Can't find image element");t.src=e.design_image.url;const i=(r=this.options)==null?void 0:r.onDesignEditSuccess;c(this,_).close(),i&&i(e,c(this,_))}))},_e=new WeakSet,gt=function(){const e=v(this,we,yt).call(this),t=new URL(e);return new URLSearchParams(t.search).get("shopT")},we=new WeakSet,yt=function(){return document.querySelector("[id='pc-wix-integration-sdk']").src},Le=new WeakSet,_t=function(){const e={}.VITE_SDK_URL?{}.VITE_SDK_URL:"https://unpkg.com/@printcart/wix-integration/dist",t=document.createElement("link");t.rel="stylesheet",t.href=`${e}/style.css`,document.head.appendChild(t)},Ee=new WeakSet,wt=async function(e){try{const t=`${c(this,q)}/integration/wix/products/${e}`,i=this.token;if(!i)throw new Error("Missing Printcart Unauth Token");return await(await fetch(t,{headers:{"X-PrintCart-Unauth-Token":i}})).json()}catch(t){console.error("There has been a problem with your fetch operation:",t);return}},be=new WeakSet,Lt=function(){var r,o,s;const e=c(this,x);if(!(e!=null&&e.parentNode)){console.log("Can not find cart form");return}if(document.getElementById("pc-designer_wrap")!==null)return;const t=document.createElement("div");t.id="pc-designer_wrap";const i=document.createElement("button");i.id="pc-btn",i.className=(r=this.options)!=null&&r.designClassName?(o=this.options)==null?void 0:o.designClassName:"",i.innerHTML=(s=this.options)!=null&&s.designBtnText?this.options.designBtnText:"Start Design",i.disabled=!0,t.appendChild(i),e.appendChild(t)},Ie=new WeakSet,Et=async function(e,t,i){try{const r=`${c(this,q)}/projects`,o=this.token;if(!o)throw new Error("Missing Printcart Unauth Token");const s={name:`${e}`,status:"processing",design_ids:i,order_detail:{id:t}};await fetch(r,{method:"POST",headers:{"Content-Type":"application/json","X-PrintCart-Unauth-Token":o},body:JSON.stringify(s)})}catch(r){console.error("There has been a problem with your fetch operation:",r);return}},(async()=>{})().then(()=>new Dt)}); |
@@ -7,3 +7,3 @@ { | ||
], | ||
"version": "1.1.2", | ||
"version": "1.1.3", | ||
"scripts": { | ||
@@ -10,0 +10,0 @@ "dev": "vite --port 3102", |
@@ -9,3 +9,3 @@ Add [Printcart Designer](https://printcart.com) to your Wix Store. | ||
<link | ||
href="https://unpkg.com/@printcart/shopify-integration/dist/style.css" | ||
href="https://unpkg.com/@printcart/wix-integration/dist/style.css" | ||
rel="stylesheet" | ||
@@ -12,0 +12,0 @@ /> |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
108304
2060