1"use strict";(self.webpackChunkchefworks_theme=self.webpackChunkchefworks_theme||[]).push([[91],{89529(e,t,r){r.r(t),r.d(t,{connectNotification:()=>n});var n=(0,r(71354).connect)({using:["notification"],mapDispatchToProps:function(e){return function(t){return{enqueueNotification:function(){for(var r,n=[],i=0;i<arguments.length;i++)n[i]=arguments[i];return t((r=e.actions).enqueue.apply(r,n))}}}}})},65633(e,t,r){r.r(t),r.d(t,{SacConfigurator:()=>Bt});var n=r(14041),i=r(46343),o=r.n(i),a=r(71354),s=r(27711),l=r(89529),c=r(77733),u=r(76398),d=r(73855),p=r(67843),h=r(76478),f=r(68203);var v=r(18001),S=function(e,t,r,n){return new(r||(r=Promise))(function(i,o){function a(e){try{l(n.next(e))}catch(e){o(e)}}function s(e){try{l(n.throw(e))}catch(e){o(e)}}function l(e){var t;e.done?i(e.value):(t=e.value,t instanceof r?t:new r(function(e){e(t)})).then(a,s)}l((n=n.apply(e,t||[])).next())})},g=function(e,t){var r,n,i,o={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]},a=Object.create(("function"==typeof Iterator?Iterator:Object).prototype);return a.next=s(0),a.throw=s(1),a.return=s(2),"function"==typeof Symbol&&(a[Symbol.iterator]=function(){return this}),a;function s(s){return function(l){return function(s){if(r)throw new TypeError("Generator is already executing.");for(;a&&(a=0,s[0]&&(o=0)),o;)try{if(r=1,n&&(i=2&s[0]?n.return:s[0]?n.throw||((i=n.return)&&i.call(n),0):n.next)&&!(i=i.call(n,s[1])).done)return i;switch(n=0,i&&(s=[2&s[0],i.value]),s[0]){case 0:case 1:i=s;break;case 4:return o.label++,{value:s[1],done:!1};case 5:o.label++,n=s[1],s=[0];continue;case 7:s=o.ops.pop(),o.trys.pop();continue;default:if(!(i=o.trys,(i=i.length>0&&i[i.length-1])||6!==s[0]&&2!==s[0])){o=0;continue}if(3===s[0]&&(!i||s[1]>i[0]&&s[1]<i[3])){o.label=s[1];break}if(6===s[0]&&o.label<i[1]){o.label=i[1],i=s;break}if(i&&o.label<i[2]){o.label=i[2],o.ops.push(s);break}i[2]&&o.ops.pop(),o.trys.pop();continue}s=t.call(e,o)}catch(e){s=[6,e],n=0}finally{r=i=0}if(5&s[0])throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}([s,l])}}},m="_artworkListId",y=function(e,t){return S(void 0,void 0,void 0,function(){var r,n,i,o,a,s,l,c,u;return g(this,function(d){switch(d.label){case 0:r=null!==(o=null===(i=e.getUserArtworkImages)||void 0===i?void 0:i.call(e))&&void 0!==o?o:[],(n=r.map(function(e){return{img:e,visible:e.visible,opacity:e.opacity,evented:e.evented,selectable:e.selectable}})).forEach(function(e){var t,r=e.img;null===(t=r.set)||void 0===t||t.call(r,{visible:!0,opacity:1,evented:!0,selectable:!0})}),null===(s=null===(a=e.canvas)||void 0===a?void 0:a.requestRenderAll)||void 0===s||s.call(a),d.label=1;case 1:return d.trys.push([1,,3,4]),[4,t()];case 2:return[2,d.sent()];case 3:return n.forEach(function(e){var t,r=e.img,n=e.visible,i=e.opacity,o=e.evented,a=e.selectable,s=r;null===(t=s.set)||void 0===t||t.call(s,{visible:n,opacity:i,evented:o,selectable:a})}),null===(l=e.updateSideVisibility)||void 0===l||l.call(e),null===(u=null===(c=e.canvas)||void 0===c?void 0:c.requestRenderAll)||void 0===u||u.call(c),[7];case 4:return[2]}})})};function b(e,t){return S(this,void 0,void 0,function(){var r,n,i,o,a,s=this;return g(this,function(l){if(!(r=e.getContext()))throw new Error("Designer does not support edited artwork export.");if(n=r.getUserArtworkImages,i=r.renderArtworkExportBitmap,!n||!i)throw new Error("Designer does not support edited artwork export.");return o=n(),a=o.filter(function(e){return function(e){if(null==e?void 0:e._uploadedOriginalSrc)return!0;var t=null==e?void 0:e._replaceRules;return Boolean(t&&"object"==typeof t&&Object.keys(t).length>0)}(e)}).map(function(e){return{img:e,listId:null!=e[m]?String(e[m]):""}}).filter(function(e){var r=e.listId;return r&&(!t||0===t.size||t.has(r))}),[2,y(r,function(){return S(s,void 0,void 0,function(){var e=this;return g(this,function(t){switch(t.label){case 0:return[4,a.reduce(function(t,n){return S(e,[t,n],void 0,function(e,t){var n,o,a,s=t.img,l=t.listId;return g(this,function(t){switch(t.label){case 0:return[4,e];case 1:n=t.sent(),t.label=2;case 2:return t.trys.push([2,4,,5]),[4,i(s)];case 3:return(null==(o=t.sent())?void 0:o.dataUrl)&&(a=r.resolveEditedArtworkUploadSourceForCart?r.resolveEditedArtworkUploadSourceForCart(s,o):o.dataUrl)?(n.push({listId:l,dataUrl:(0,v.resolveEditedArtworkFileUploadSource)(a,o.dataUrl)}),[3,5]):[2,n];case 4:return t.sent(),[3,5];case 5:return[2,n]}})})},Promise.resolve([]))];case 1:return[2,t.sent()]}})})})]})})}function w(e,t,r,n){return S(this,void 0,void 0,function(){var i,o,a=this;return g(this,function(s){switch(s.label){case 0:return[4,b(e,n)];case 1:if(!(i=s.sent()).length)return[2,new Map];if(!r)throw new Error("Artworks virtual product is not configured for this item.");return o=new Map,[4,Promise.allSettled(i.map(function(e){return S(a,[e],void 0,function(e){var n,i=e.listId,a=e.dataUrl;return g(this,function(e){switch(e.label){case 0:return[4,t.uploadEditedArtworkFile(r,a)];case 1:return n=e.sent(),o.set(i,function(e){if(!(e.url&&e.quote_path&&e.order_path&&e.secret_key&&e.title))throw new Error("Edited artwork upload did not return complete file metadata.");var t={url:e.url,quote_path:e.quote_path,order_path:e.order_path,secret_key:e.secret_key,title:e.title};return e.thumb_quote_path&&(t.thumb_quote_path=e.thumb_quote_path),e.thumb_order_path&&(t.thumb_order_path=e.thumb_order_path),t}(n)),[2]}})})}))];case 2:return s.sent(),[2,o]}})})}function C(e,t){return(0,p.mergeEditedArtworkUploadsIntoSavePayload)(e,t)}var A=function(e,t,r,n){return new(r||(r=Promise))(function(i,o){function a(e){try{l(n.next(e))}catch(e){o(e)}}function s(e){try{l(n.throw(e))}catch(e){o(e)}}function l(e){var t;e.done?i(e.value):(t=e.value,t instanceof r?t:new r(function(e){e(t)})).then(a,s)}l((n=n.apply(e,t||[])).next())})},P=function(e,t){var r,n,i,o={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]},a=Object.create(("function"==typeof Iterator?Iterator:Object).prototype);return a.next=s(0),a.throw=s(1),a.return=s(2),"function"==typeof Symbol&&(a[Symbol.iterator]=function(){return this}),a;function s(s){return function(l){return function(s){if(r)throw new TypeError("Generator is already executing.");for(;a&&(a=0,s[0]&&(o=0)),o;)try{if(r=1,n&&(i=2&s[0]?n.return:s[0]?n.throw||((i=n.return)&&i.call(n),0):n.next)&&!(i=i.call(n,s[1])).done)return i;switch(n=0,i&&(s=[2&s[0],i.value]),s[0]){case 0:case 1:i=s;break;case 4:return o.label++,{value:s[1],done:!1};case 5:o.label++,n=s[1],s=[0];continue;case 7:s=o.ops.pop(),o.trys.pop();continue;default:if(!(i=o.trys,(i=i.length>0&&i[i.length-1])||6!==s[0]&&2!==s[0])){o=0;continue}if(3===s[0]&&(!i||s[1]>i[0]&&s[1]<i[3])){o.label=s[1];break}if(6===s[0]&&o.label<i[1]){o.label=i[1],i=s;break}if(i&&o.label<i[2]){o.label=i[2],o.ops.push(s);break}i[2]&&o.ops.pop(),o.trys.pop();continue}s=t.call(e,o)}catch(e){s=[6,e],n=0}finally{r=i=0}if(5&s[0])throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}([s,l])}}};function k(e){if(!(e.url&&e.quote_path&&e.order_path&&e.secret_key&&e.title))throw new Error("Artwork preview upload did not return complete file metadata.");return{url:e.url,quote_path:e.quote_path,order_path:e.order_path,secret_key:e.secret_key,title:e.title}}function _(e,t,r){return A(this,void 0,void 0,function(){var n,i,o=this;return P(this,function(a){switch(a.label){case 0:return[4,(0,p.exportArtworkPreviewBitmaps)(e,{skipViewRestore:!0})];case 1:if(!(n=a.sent()).length)return[2,new Map];if(!r)throw new Error("Artworks virtual product is not configured for this item.");return i=new Map,[4,Promise.all(n.map(function(e){return A(o,[e],void 0,function(e){var n,o,a,s=e.side,l=e.dataUrlRegular,c=e.dataUrlLarge;return P(this,function(e){switch(e.label){case 0:return[4,Promise.all([t.uploadArtworkPreviewFile(r,l),t.uploadArtworkPreviewFile(r,c)])];case 1:return n=e.sent(),o=n[0],a=n[1],i.set(s,{regular:k(o),large:k(a)}),[2]}})})}))];case 2:return a.sent(),[2,i]}})})}function I(e,t){return(0,p.mergeArtworkPreviewUploadsIntoSavePayload)(e,t)}var E=r(48882),D=r(86999),F=function(){return F=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++)for(var i in t=arguments[r])Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e},F.apply(this,arguments)},R="_artworkListId",x="_onFileColorAndGeneralEdits",O="shareReplaceRules",L=["side","placement","rotation","printPositionX","printPositionY","printWidth","printHeight"],N=function(e){if(!e)return"";if("string"==typeof e)return e.trim();if("object"==typeof e)try{return JSON.stringify(e)}catch(e){return""}return""},U=function(e){return Boolean(e&&Object.keys((0,D.buildReplaceRulesFromSacColorEdits)(e)).length)},j=function(e){return Boolean(e&&"object"==typeof e&&Object.keys(e).length)},M=function(e){var t,r=e._replaceRules;if(r&&"object"==typeof r){var n=r;if(Object.keys(n).length)return n}return t=N(e[x]),(0,D.buildReplaceRulesFromSacColorEdits)(t)},q=function(e){var t=new Map;return function(e){var t=e.designState,r=null==t?void 0:t.artwork;return Array.isArray(r)?r.filter(function(e){return e&&"object"==typeof e}):[]}(e).forEach(function(e){var r=null!=e.listId?String(e.listId):"";r&&t.set(r,e)}),t},T=function(e){var t=new Map,r=e.getContext();return(null==r?void 0:r.getUserArtworkImages)?(r.getUserArtworkImages().forEac
1h(function(e){var r=null!=e[R]?String(e[R]):"";r&&t.set(r,e)}),t):t},V=function(e,t){if(!t)return e;var r={};return L.forEach(function(e){var n=t[e];null!=n&&""!==n&&(r[e]=n)}),F(F({},e),r)},G=function(e,t){return JSON.stringify(e)===JSON.stringify(t)},B=function(e){return e?(0,D.resolveShareArtworkReplaceRules)({artworkColorAndGeneralEdits:e.artworkColorAndGeneralEdits,onFileColorAndGeneralEdits:e.onFileColorAndGeneralEdits,shareReplaceRules:e[O]}):{}},W=["uploadApiUrl","uploadThumbQuotePath","uploadThumbOrderPath","onFileArtworkPath","onFileArtworkNumber","onFileArtworkTitle"],Q=["artworkColorAndGeneralEdits","onFileColorAndGeneralEdits","artworkPixelEdited"],z=function(e,t){if(void 0===t&&(t={}),!e)return t;var r=F({},t);return W.forEach(function(t){var n=r[t],i=e[t];null!=n&&""!==n||null==i||""===i||(r[t]=i)}),!r.editedUpload&&e.editedUpload&&(r.editedUpload=e.editedUpload),Q.forEach(function(t){var n=r[t],i=e[t],o="artworkPixelEdited"!==t&&U(N(n)),a="artworkPixelEdited"!==t&&U(N(i));!o&&a&&(r[t]=i)}),!j(r[O])&&j(e[O])&&(r[O]=e[O]),r},H=function(e){try{return JSON.parse(JSON.stringify(e))}catch(t){return F({},e)}},J=function(e,t){var r,n,i,o,a,s,l,c,u=(null==t?void 0:t.fabricImg)?M(t.fabricImg):{};if(Object.keys(u).length)return F(F({},e),((r={})[O]=u,r));var d=B(null==t?void 0:t.exportItem);if(Object.keys(d).length){var p=null!==(a=null===(o=null==t?void 0:t.exportItem)||void 0===o?void 0:o.artworkColorAndGeneralEdits)&&void 0!==a?a:null===(s=null==t?void 0:t.exportItem)||void 0===s?void 0:s.onFileColorAndGeneralEdits,h=F(F({},e),((n={})[O]=d,n));return p&&!U(N(null!==(l=e.artworkColorAndGeneralEdits)&&void 0!==l?l:e.onFileColorAndGeneralEdits))&&(h.artworkColorAndGeneralEdits=p,h.onFileColorAndGeneralEdits=p),h}if(j(e[O]))return e;var f=(0,D.buildReplaceRulesFromSacColorEdits)(N(null!==(c=e.artworkColorAndGeneralEdits)&&void 0!==c?c:e.onFileColorAndGeneralEdits));return Object.keys(f).length?F(F({},e),((i={})[O]=f,i)):e},K=function(e,t){var r,n,i,o;if(j(e[O]))return e;var a=N(null!==(r=null==t?void 0:t.artworkColorAndGeneralEdits)&&void 0!==r?r:null==t?void 0:t.onFileColorAndGeneralEdits);if(!U(a))return e;var s=N(null!==(n=e.artworkColorAndGeneralEdits)&&void 0!==n?n:e.onFileColorAndGeneralEdits);return U(s)?e:F(F({},e),{artworkColorAndGeneralEdits:null!==(i=null==t?void 0:t.artworkColorAndGeneralEdits)&&void 0!==i?i:a,onFileColorAndGeneralEdits:null!==(o=null==t?void 0:t.onFileColorAndGeneralEdits)&&void 0!==o?o:a})},X=function(e,t,r){return z(e,J(K(V(H(e),t),t),{fabricImg:r,exportItem:t}))},Y=function(e,t,r){var n=q(t),i=q(r),o=T(e),a=new Set,s=new Set(Array.from(n.keys()).concat(Array.from(i.keys()))),l=Array.from(s).sort(function(e,t){return Number(e)-Number(t)}).map(function(e){var t,r,s=n.get(e),l=i.get(e),c=o.get(e);if(!(s||l))return null;var u=N(null!==(t=null==s?void 0:s.artworkColorAndGeneralEdits)&&void 0!==t?t:null==s?void 0:s.onFileColorAndGeneralEdits),d=N(null!==(r=null==l?void 0:l.artworkColorAndGeneralEdits)&&void 0!==r?r:null==l?void 0:l.onFileColorAndGeneralEdits),p=B(s),h=B(l),f=c?M(c):{},v=c?N(c[x]):"",S=function(e,t,r,n,i){var o=Object.keys(e).length,a=Object.keys(t).length,s=Object.keys(n).length;if(0===o)return!(a>0&&s>0&&G(t,n))&&(a>0||s>0);if(0===a)return!1;var l=!G(t,e);return!(l&&i&&!U(r)&&G(n,e))&&l}(p,f,v,h,Boolean(null==s?void 0:s.editedUpload));if(!S){if(s)return X(s,l,c);if(l)return J(K(F({},l),l),{fabricImg:c,exportItem:l})}a.add(e);var g=function(e,t,r){return U(r)?r:U(t)?t:U(e)?e:r||t||e}(u,v,d);return J(function(e,t,r){var n,i=e?V(H(e),t):F({},t||{}),o=N(null!==(n=null==t?void 0:t.artworkColorAndGeneralEdits)&&void 0!==n?n:null==t?void 0:t.onFileColorAndGeneralEdits),a=U(o)?o:r||"";return a&&(i.artworkColorAndGeneralEdits=a,i.onFileColorAndGeneralEdits=a,i.artworkPixelEdited=!0),z(e,J(K(i,t),{exportItem:t}))}(s,l,g),{fabricImg:c,exportItem:l})}).filter(function(e){return Boolean(e)}),c=t.designState||{},u=r.designState||{};return{sessionState:F(F(F({},t),r),{designState:F(F(F({},c),u),{artwork:l})}),changedListIds:a}};var Z=function(){return Z=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++)for(var i in t=arguments[r])Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e},Z.apply(this,arguments)};var $=r(76504),ee=r(43356),te=r(19127),re=function(){return re=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++)for(var i in t=arguments[r])Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e},re.apply(this,arguments)};function ne(e){var t,r;return String(null!==(r=null!==(t=e.backend_value)&&void 0!==t?t:e.value)&&void 0!==r?r:"")}function ie(e){return e.trim().toLowerCase()}function oe(e,t){if(null==e?void 0:e.length){var r=ie(t);return e.find(function(e){return String(e.backend_value||"").trim().toLowerCase()===r})}}function ae(e){if(null!=e&&""!==String(e).trim()){var t=parseInt(String(e),10);if(Number.isFinite(t))return t;var r=String(e).match(/\d+/);return r?parseInt(r[0],10):void 0}}function se(e,t,r){var n,i,o,a,s=(0,ee.getDirectToFilmHiddenProductAttributeCode)(),l=null===(n=null==t?void 0:t.options)||void 0===n?void 0:n.find(function(e){return e.code===s});if(null===(i=null==l?void 0:l.options)||void 0===i?void 0:i.length){var c=null!==(o=e[l.id])&&void 0!==o?o:e[String(l.id)];if(null!=c){var u=l.options.find(function(e){return e.id===Number(c)});if(u)return function(e){for(var t=[e.backend_value,e.value,e.label],r=0;r<t.length;r+=1){var n=ae(t[r]);if(void 0!==n)return n}}(u)}}var d=null==r?void 0:r.find(function(e){return e.code===s}),p=null===(a=null==d?void 0:d.options)||void 0===a?void 0:a.find(function(e){return e.selected});if(p)return ae(ne(p))}function le(e,t){var r,n,i=(0,ee.getDirectToFilmHiddenProductAttributeCode)(),o=null===(r=t.options)||void 0===r?void 0:r.find(function(e){return e.code===i});if(null===(n=null==o?void 0:o.options)||void 0===n?void 0:n.length){var a=Math.max(1,e),s=o.options.find(function(e){return[e.backend_value,e.value,e.label].filter(function(e){return null!=e&&""!==String(e).trim()}).some(function(e){var t=String(e).match(/\d+/);return!!t&&parseInt(t[0],10)===a})});return null==s?void 0:s.id}}function ce(e,t,r,n,i){var o,a,s=Math.max(1,e),l=(0,ee.getDirectToFilmHiddenProductAttributeCode)(),c=null==t?void 0:t.find(function(e){return e.code===l});if(r&&i&&n){var u=null===(o=r.options)||void 0===o?void 0:o.find(function(e){return e.code===l}),d=le(s,r);if(u&&null!=d){var p=null!==(a=n[u.id])&&void 0!==a?a:n[String(u.id)];return Number(p)!==d&&i(String(u.id),String(d),"1"),!0}}if(c){var h=function(e,t){if(null==e?void 0:e.length){var r=String(t);return e.find(function(e){return ne(e)===r})}}(c.options,s);if(h)return h.selected||h.disabled||h.handleClick(),!0}return function(e){var t=(0,ee.getDirectToFilmHiddenProductAttributeCode)(),r=(0,ee.getAttributeOptionId)(t,e),n=document.getElementById(r);return!!n&&(n.click(),!0)}(s)}var ue=r(50780),de=r(96904);function pe(e,t){var r=Number(t);if(Number.isFinite(r)&&!(r<=0))return null==e?void 0:e.find(function(e){return Number(e.item_id)===r||Number(e.id)===r})}function he(e,t){var r,n=Number(null!==(r=null==t?void 0:t.item_id)&&void 0!==r?r:null==t?void 0:t.id);if(Number.isFinite(n)&&n>0)return n;var i=Number(e);return Number.isFinite(i)&&i>0?i:0}var fe,ve=(fe=function(e,t){return fe=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r])},fe(e,t)},function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function r(){this.constructor=e}fe(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)}),Se=function(){return Se=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++)for(var i in t=arguments[r])Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e},Se.apply(this,arguments)},ge=function(e,t,r,n){return new(r||(r=Promise))(function(i,o){function a(e){try{l(n.next(e))}catch(e){o(e)}}function s(e){try{l(n.throw(e))}catch(e){o(e)}}function l(e){var t;e.done?i(e.value):(t=e.value,t instanceof r?t:new r(function(e){e(t)})).then(a,s)}l((n=n.apply(e,t||[])).next())})},me=function(e,t){var r,n,i,o={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]},a=Object.create(("function"==typeof Iterator?Iterator:Object).prototype);return a.next=s(0),a.throw=s(1),a.return=s(2),"function"==typeof Symbol&&(a[Symbol.iterator]=function(){return this}),a;function s(s){return function(l){return function(s){if(r)throw new TypeError("Generator is already executing.");for(;a&&(a=0,s[0]&&(o=0)),o;)try{if(r=1,n&&(i=2&s[0]?n.return:s[0]?n.throw||((i=n.return)&&i.call(n),0):n.next)&&!(i=i.call(n,s[1])).done)return i;switch(n=0,i&&(s=[2&s[0],i.value]),s[0]){case 0:case 1:i=s;break;case 4:return o.label++,{value:s[1],done:!1};case 5:o.label++,n=s[1],s=[0];continue;case 7:s=o.ops.pop(),o.trys.pop();continue;default:if(!(i=o.trys,(i=i.length>0&&i[i.length-1])||6!==s[0]&&2!==s[0])){o=0;continue}if(3===s[0]&&(!i||s[1]>i[0]&&s[1]<i[3])){o.label=s[1];break}if(6===s[0]&&o.label<i[1]){o.label=i[1],i=s;break}if(i&&o.label<i[2]){o.label=i[2],o.ops.push(s);break}i[2]&&o.ops.pop(),o.trys.pop();continue}s=t.call(e,o)}catch(e){s=[6,e],n=0}finally{r=i=0}if(5&s[0])throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}([s,l])}}},ye=new WeakSet,be=function(){var e;return(null===(e=(0,d.getConfigIdFromQuery)())||void 0===e?void 0:e.trim())||""};function we(e){var t;if(!e)return 0;var r=e.getContext();if("function"==typeof(null==r?void 0:r.countUserArtworkImages))return r.countUserArtworkImages();var n=null===(t=e.getDesignState())||void 0===t?void 0:t.artwork;return Array.isArray(n)?n.length:0}function Ce(e,t,r,n){var i,o,a;return JSON.stringify({configId:(null==n?void 0:n.trim())||"",side:(null==t?void 0:t.side)||(null===(i=(0,d.extractSacSharePlacement)(e))||void 0===i?void 0:i.side)||"",placement:(null==t?void 0:t.placement)||(null===(o=(0,d.extractSacSharePlacement)(e))||void 0===o?void 0:o.placement)||"",instructions:r||(0,d.extractSacSpecialInstructions)(e)||"",artwork:Array.isArray(null===(a=e.designState)||void 0===a?void 0:a.artwork)?e.designState.artwork.length:0})}function Ae(e,t,r){var n,i,o,a,s,l,c,u,p,h,f,v,S,g,m;if(e){var y=(null===(n=null==r?void 0:r.customOptions)||void 0===n?void 0:n.sacPlacement)||(0,d.extractSacSharePlacement)(t),b=null!==(o=null===(i=null==r?void 0:r.customOptions)||void 0===i?void 0:i.sacSpecialInstructions)&&void 0!==o?o:(0,d.extractSacSpecialInstructions)(t);"function"==typeof e.loadDesignState&&"string"==typeof b&&e.loadDesignState({specialInstructions:b});var w="function"==typeof e.getContext?e.getContext():null;w&&(null==y?void 0:y.placement)&&(w.currentPlacement=y.placement),w&&(null==y?void 0:y.side)?(null===(s=null===(a=w.canvas)||void 0===a?void 0:a.discardActiveObject)||void 0===s||s.call(a),w.currentSide=y.side,null===(l=w.setPrintableAreaFromCurrentPlacement)||void 0===l||l.call(w),null===(c=w.renderPlacementButtons)||void 0===c||c.call(w),null===(u=w.updatePlacementUi)||void 0===u||u.call(w),null===(p=w.updateSideVisibility)||void 0===p||p.call(w),null===(h=w.updateDesignAreaBorder)||void 0===h||h.
1call(w),null===(f=w.syncPrintableAreaBorderVisibility)||void 0===f||f.call(w),null===(v=w.stackShirtPreviewLayers)||void 0===v||v.call(w)):w&&(null==y?void 0:y.placement)&&(null===(S=w.renderPlacementButtons)||void 0===S||S.call(w),null===(g=w.updatePlacementUi)||void 0===g||g.call(w),null===(m=w.setPrintableAreaFromCurrentPlacement)||void 0===m||m.call(w))}}var Pe=r(93285),ke=r(7459),_e=r(30004),Ie=r(18077),Ee=r(40003),De=r(20856),Fe=r(57576);const Re="ktyHxBg5EivzxYpYcmId",xe="QQJaAQpzxuknRPH3x17Y",Oe="TJJ49_yrPgrcNEeTOdc0",Le="uVaEsaEUXlgNm5eLW90D",Ne="CZeT85VgbPJhfuCabKz8",Ue="it9nbOg6vWmKBuKzRJAP",je="bZsakMiiY_kom0VUklfw",Me="N9W0GeNnCUPRle0OOWtr";var qe=function(e){var t=e.context,r=(0,_e.usePhraseTranslater)(),i=t.quantityState,o=t.product;return n.createElement(n.Fragment,null,n.createElement("div",{className:(0,ke.classes)(xe)},n.createElement("div",{className:Re},r("Quantity:")),n.createElement("div",{className:Oe},n.createElement("div",{className:Le},n.createElement("button",{onClick:function(){return i.decrement()},"data-test":"btn-qty-decr",type:"button"},"-"),n.createElement("input",{type:"text",value:i.current,onChange:function(e){return i.set(Number(e.target.value))},onClick:function(e){return e.target.select()},"data-test":"qty-input","aria-label":"Quantity"}),n.createElement("button",{onClick:function(){return i.increment()},"data-test":"btn-qty-incr",type:"button"},"+")),n.createElement("div",{className:je},n.createElement(De.StockStatus,{product:o,parentClass:Me,type:"footer"})))),n.createElement("div",{className:(0,ke.classes)(Ne)},n.createElement(Fe.QuantityMessage,{className:Ue,quantity:i.current,product:o})))},Te=r(50654),Ve=r(23853);const Ge="oAlKHr19yG5EP_mWdQHD",Be="u9qJCMQwfXqYxiWukp6A",We="ckh88uijr_CjeC9EogJu",Qe="sVnDeKJdFaoi1bMz5nf7";var ze=function(e){var t,r=e.text,i=e.price,o=e.dataTest,s=e.isPersonalizationPrice,l=void 0===s?void 0:s,c=(0,a.useContainerHook)("usePriceFormatter");return n.createElement("div",{className:(0,ke.classes)(Ge,"price-line-content")},n.createElement("div",{className:Be},r),n.createElement("div",{"data-test":o,className:(0,ke.classes)(We,"weglot-exclude","price-content",(t={},t[Qe]=l,t))},c(i)))};const He="JIybar6KUY3RujrQ4d6A",Je="iHB6lo29alPr2AFlBlcS",Ke="_k2l8qxwg0BKZAuWFJks",Xe="qCJZaYupJkQmqFqQRdA_",Ye="ycGxUA5I6IEsjaIEPPXl";var Ze=function(e){var t,r,i=e.context,o=(0,_e.usePhraseTranslater)(),a=(0,Te.useReactiveVar)(Ve.totalProductsPriceVar);return n.createElement("div",{className:He},n.createElement("div",{className:Je},n.createElement("div",{className:(0,ke.classes)(Ke,"price-line-content")},n.createElement("div",{className:Xe},(t=i.bundleItemPriceData.labels.join(" + "),r=i.isOrderMultiple?o("Products"):"",t||r||o("Product"))),n.createElement("div",{id:"sac-add-to-cart-products-price-content","data-test":"product-cost-summary",className:Ye},a&&a)),i.isDisplayConfigPrice&&n.createElement(ze,{text:o("Personalized"),price:i.personalizationPrice,dataTest:"custom-sac-summary",isPersonalizationPrice:!0})))},$e=r(98485),et=r(78087);const tt="aETuyNU71odHa9EgSr8c",rt="Oz0HC9BdB8KhQU6SzGTw",nt="y6IocODjVKBGF83PeVZi",it="fNAtv4jjyWWlrWq9pktT",ot="xmNiuxjmwZoW5s51Y9kX",at="DufYqij2EAKOlAuCSPBr",st="FQoFUeG15LT_RLuiuokD",lt="ljXRalP9LFGuyB2SzUcy",ct="JP_JBar6Hxq6uEhFEO1t",ut="VNvY4PvHkURtSz_Rq26L",dt="W7IRKQPtJbfJ7FiioAsr",pt="ykHwLAgMCcFjjzGv_Uef";var ht=r(30334),ft=r(33670);const vt="dH0irqONSK6QleiDD1sV",St="OW3vuzQ6_10VfJ_u6bdR";var gt=(0,ht.connectWishlist)(function(e){var t,r=e.wishlistHasProduct,i=e.toggleWishlist,o=e.productId;return(0,ft.isPunchoutStoreMode)()?null:n.createElement("div",null,n.createElement("button",{className:(0,ke.classes)(vt,(t={},t[St]=r(o),t)),onClick:function(){return i(o)},"data-test":"btn-add-to-wishlist",type:"button","aria-label":"Add To Wishlist"}))}),mt=r(8997);const yt={BaseFontFamily:"Montserrat, arial, sans-serif",itemList:"ycuhQAX0ywZ3hXYQd6Ue",item:"LyateHMCbozkVuI7pLGz",productImage:"whIHqdgj8n7JwZDRwIeS",productDetailWrapper:"jXWQQY9DYMAW_6K0tZzr",productDetail:"MJCv6fClt5PnxVPebTeD",title:"bTiE1Zo4qCHcohEItUqg"};var bt=function(e){var t,r=e.item,i=(0,_e.usePhraseTranslater)();if(!(null===(t=null==r?void 0:r.simpleProduct)||void 0===t?void 0:t.id)||Number(r.simpleProduct.id)<=0)return null;if(!r.simpleProduct.options)return null;return n.createElement("div",{className:yt.item},n.createElement("div",{className:yt.productImage},n.createElement("img",{src:function(){if(r.simpleProduct.images&&r.simpleProduct.images.length){var e=(0,mt.sortImages)(r.simpleProduct.images)[0];return e.thumb||e.image}return""}(),alt:r.simpleProduct.name})),n.createElement("div",{className:yt.productDetailWrapper},n.createElement("div",{className:yt.productDetail},n.createElement("div",{className:yt.title},n.createElement("span",null,r.simpleProduct.name),n.createElement("span",null,Object.keys(r.selections||{}).map(function(e){return(0,c.getOptionValue)(function(t){return t.id===Number(e)}
1)(r.selections,r.simpleProduct)}).join(" - "))),n.createElement("div",{className:yt.quantity},n.createElement("span",null,i("Qty: %1",r.qty))))))},wt=function(e){var t,r=e.className,i=void 0===r?"":r,o=e.context;return o.isOrderMultiple&&(null===(t=o.multiSelections)||void 0===t?void 0:t.length)?n.createElement("div",{className:i?"".concat(yt.itemList," ").concat(i):yt.itemList},o.multiSelections.map(function(e){return n.createElement(bt,{key:Object.entries(e.selections).toString(),item:e})})):null};const Ct="WSdconJPM8epf_U4CJTQ",At="x_Vy_7XeLglKdmqp3J2j",Pt="dcH_sxdmg3vN_lb3P2oL",kt="SeUxCDgGfMALIQPXqNEx";var _t=function(e,t,r,n){return new(r||(r=Promise))(function(i,o){function a(e){try{l(n.next(e))}catch(e){o(e)}}function s(e){try{l(n.throw(e))}catch(e){o(e)}}function l(e){var t;e.done?i(e.value):(t=e.value,t instanceof r?t:new r(function(e){e(t)})).then(a,s)}l((n=n.apply(e,t||[])).next())})},It=function(e,t){var r,n,i,o={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]},a=Object.create(("function"==typeof Iterator?Iterator:Object).prototype);return a.next=s(0),a.throw=s(1),a.return=s(2),"function"==typeof Symbol&&(a[Symbol.iterator]=function(){return this}),a;function s(s){return function(l){return function(s){if(r)throw new TypeError("Generator is already executing.");for(;a&&(a=0,s[0]&&(o=0)),o;)try{if(r=1,n&&(i=2&s[0]?n.return:s[0]?n.throw||((i=n.return)&&i.call(n),0):n.next)&&!(i=i.call(n,s[1])).done)return i;switch(n=0,i&&(s=[2&s[0],i.value]),s[0]){case 0:case 1:i=s;break;case 4:return o.label++,{value:s[1],done:!1};case 5:o.label++,n=s[1],s=[0];continue;case 7:s=o.ops.pop(),o.trys.pop();continue;default:if(!(i=o.trys,(i=i.length>0&&i[i.length-1])||6!==s[0]&&2!==s[0])){o=0;continue}if(3===s[0]&&(!i||s[1]>i[0]&&s[1]<i[3])){o.label=s[1];break}if(6===s[0]&&o.label<i[1]){o.label=i[1],i=s;break}if(i&&o.label<i[2]){o.label=i[2],o.ops.push(s);break}i[2]&&o.ops.pop(),o.trys.pop();continue}s=t.call(e,o)}catch(e){s=[6,e],n=0}finally{r=i=0}if(5&s[0])throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}([s,l])}}},Et=function(e){var t,r,i,o=e.context,s=(0,a.useContainerHook)("useEnqueueNotification"),l=(0,n.useState)(!1),c=l[0],u=l[1],d=(0,_e.usePhraseTranslater)(),p=o.cannotSave,h=p||o.isSaving,f=(null!==(i=null===(r=o.multiSelections)||void 0===r?void 0:r.length)&&void 0!==i?i:0)<=0,v=function(){var e=(0,n.useState)(null),t=e[0],r=e[1],i=function(){r(null)},o=function(){t&&(t.resolve(!0),i())},a=function(){t&&(t.resolve(!1),i())},s=function(){};return{ConfirmationDialog:function(e){var r=e.title,l=e.notice,c=e.confirmActionTitle,u=void 0===c?void 0:c,d=e.cancelActionTitle,p=void 0===d?void 0:d,h=e.children,f=void 0===h?void 0:h,v=(0,_e.usePhraseTranslater)();return n.createElement(et.Overlay,{active:null!==t,close:i,className:tt},n.createElement("div",{className:(0,ke.classes)(rt,nt)},n.createElement("div",{className:(0,ke.classes)(it,ot)},f),n.createElement("div",{className:(0,ke.classes)(it,at)},n.createElement("div",{className:st},n.createElement("div",{className:lt},r),n.createElement("div",{className:ct},l&&n.createElement(n.Fragment,null,n.createElement("p",null,n.createElement("sup",null,"*"),l),n.createElement($e.AccessibleButton,{tag:"button",action:s,className:ut,isLocked:!0},n.createElement("i",{className:"fa-solid fa-xmark"})))),n.createElement($e.AccessibleButton,{tag:"div",action:o,className:dt},null!=u?u:v("confirm"))),n.createElement("div",{className:pt},n.createElement($e.AccessibleButton,{tag:"a",action:a},null!=p?p:v("close"))))))},confirm:function(){return new Promise(function(e,t){r({resolve:e,reject:t})})}}}(),S=v.ConfirmationDialog;v.confirm;return(0,n.useEffect)(function(){if(p){var e=setTimeout(function(){u(!1)},5e3);return function(){return clearTimeout(e)}}},[c,p]),n.createElement(n.Fragment,null,n.createElement("div",null,p&&c&&n.createElement("div",{className:kt},n.createElement("span",null,d("Required data missing from personalized."))),n.createElement("div",{className:Ct},n.createElement($e.AccessibleButton,{tag:"div","data-test":"submit-sac",action:function(){return _t(void 0,void 0,void 0,function(){return It(this,function(e){switch(e.label){case 0:return p&&u(!0),o.isOrderMultiple?f||p||o.isSaving?[3,7]:[3,4]:[3,9];case 1:return e.sent()?[4,o.save()]:[3,3];case 2:e.sent(),e.label=3;case 3:return[3,6];case 4:return[4,o.save()];case 5:e.sent(),e.label=6;case 6:return[3,8];case 7:(p||f)&&(s({type:"primary",message:d("Not all required options were selected"),time:5e3}),f&&o.configValidation&&(o.configValidation.set({validation:!0}
1),(0,$.scrollToValidationArea)())),e.label=8;case 8:return[3,11];case 9:return p||o.isSaving?[3,11]:[4,o.save()];case 10:e.sent(),e.label=11;case 11:return[2]}})})},className:(0,ke.classes)(At,(t={},t[Pt]=h,t))},o.isQuickView?d("update item"):d("add to cart")),n.createElement(gt,{productId:o.product.id}))),n.createElement(S,{title:d("Personalized"),notice:d("I agree, Personalized options will be applied to all items."),confirmActionTitle:d("Add To Cart")},n.createElement(wt,{context:o})))};const Dt="fLj75eK3Vi6NEHFzhnsM";function Ft(e){var t=e.text,r=void 0===t?"":t,i=(0,_e.usePhraseTranslater)(),o=r.trim();return o?n.createElement("span",{className:Dt},i(o)):null}const Rt="xmsia8jijwyf12JuG9FQ",xt="x35WO1RX5HybX_j6eQwZ",Ot="ESnwRw9d64AlgZbws5kg",Lt="yIAtXlkxRgS2LmEgkH4_",Nt="zgGFEUa5WwrDiFbG6gmw";var Ut=function(e){var t=e.context,r=!t.isQuickView&&Boolean(t.productConfig);return n.createElement("div",{className:Rt},n.createElement("div",{className:xt},n.createElement("div",{className:Ee.default.showOnDesktop},n.createElement(Ft,{text:t.previewDisclaimer}))),n.createElement("div",{className:Ot},n.createElement("div",null,!t.isOrderMultiple&&n.createElement(qe,{context:t})),n.createElement("div",null,n.createElement(Ze,{context:t})),n.createElement("div",{className:(0,ke.classes)(Ee.default.showOnMobile,Nt)},n.createElement(Ft,{text:t.previewDisclaimer}))),n.createElement("div",{className:Lt},n.createElement("div",null,n.createElement(Et,{context:t}),r&&t.productConfig&&n.createElement(d.ShareCopyLinkRegistrar,{config:t.productConfig,cartItems:t.cartItems||[],mode:"sac",enabled:!t.cannotSave&&!t.isSaving,skipFormValidation:!0,prepareShareDraft:t.prepareShareDraft}))))};const jt="F69AXcRuqlij8GEDV1k1",Mt="wi1NQLOxpS0EQmEepFZN",qt="rx0VGbBUbFl6UwrTz1uD";var Tt=function(){return Tt=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++)for(var i in t=arguments[r])Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e},Tt.apply(this,arguments)};var Vt,Gt,Bt=(Vt=function(e){var t=e.sac,r=(0,_e.usePhraseTranslater)(),i="loading"===t.loadState&&!t.sacConfig,o="error"===t.loadState,a="saving"===t.loadState;return n.createElement("div",{className:(0,ke.classes)(jt)},n.createElement(Pe.Helmet,null,n.createElement("link",{rel:"stylesheet",href:"https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.5.1/css/all.min.css",crossOrigin:"anonymous",referrerPolicy:"no-referrer"})),i&&n.createElement(Ie.ShowLoader,{message:r("Loading designer...")}),o&&n.createElement("p",{className:Mt},r("Could not load the designer. Reload the page and try again.")),t.sacConfig&&n.createElement(p.SacDesignerHost,{config:Tt(Tt({},t.sacConfig),{onShirtSwatchChange:t.onShirtSwatchChange,onArtworkCountChange:t.onArtworkCountChange}),configKey:String(t.sacConfigRevision),onReady:t.setDesigner}),t.sacConfig&&!o&&n.createElement(Ut,{context:t.addToCartContext}),a&&n.createElement("div",{className:qt,"data-test":"sac-saving-overlay"},n.createElement(Ie.ShowLoader,{message:r("Submitting personalized product...")})))},Gt=function(e){function t(t){var r=e.call(this,t)||this;return r._pendingSessionState=null,r._sessionRestoreId=0,r._sacConfigRevision=0,r._shareRestorePreviewContext=null,r._suppressShirtSwatchProductSync=!1,r._suppressArtworkLocationProductSync=!1,r._deferArtworkLocationProductSync=!1,r._lastSyncedArtworkLocation=0,r._cartSelectionsSnapshot=null,r._closingAfterSave=!1,r._cartRestoreSucceededForItemId=0,r._cartRestoreInFlight=!1,r._sharedSessionAppliedKey="",r._activeShareConfigId="",r._sharedSessionApplyInFlight=!1,r._unsubSharedRestore=null,r._unsubSharedOpenPending=null,r.state={designer:null,loadState:"loading",sacConfig:null,apiConfig:null,sourceMappings:null},r.setDesigner=r.setDesigner.bind(r),r.save=r.save.bind(r),r.close=r.close.bind(r),r.performUpdates=r.performUpdates.bind(r),r.loadSacConfigFromApi=r.loadSacConfigFromApi.bind(r),r.handleSacShirtSwatchChange=r.handleSacShirtSwatchChange.bind(r),r.handleSacArtworkCountChange=r.handleSacArtworkCountChange.bind(r),r.finishDesignerReady=r.finishDesignerReady.bind(r),r.syncArtworkLocationFromDesigner=r.syncArtworkLocationFromDesigner.bind(r),r.publishOpe
1ned=r.publishOpened.bind(r),r.publishSaved=r.publishSaved.bind(r),r.persistShareDraftFromDesigner=r.persistShareDraftFromDesigner.bind(r),r.prepareShareDraftWithUploads=r.prepareShareDraftWithUploads.bind(r),r.tryApplySharedSessionWhenAvailable=r.tryApplySharedSessionWhenAvailable.bind(r),r.handleSharedRestoreVarChange=r.handleSharedRestoreVarChange.bind(r),r.attachSharedRestoreListeners=r.attachSharedRestoreListeners.bind(r),r}return ve(t,e),t.prototype.componentDidMount=function(){this.syncShareConfigIdSession(),this.attachSharedRestoreListeners(),this.handleSharedRestoreVarChange(),this.performUpdates(),this.syncSacPrepareShareDraftBridge()},t.prototype.componentDidUpdate=function(){this.syncShareConfigIdSession(),this.performUpdates(),this.tryRestoreCartDesignWhenReady().catch(function(){}),this.tryApplySharedSessionWhenAvailable().catch(function(){}),this.syncSacPrepareShareDraftBridge()},t.prototype.componentWillUnmount=function(){var e,t;null===(e=this._unsubSharedRestore)||void 0===e||e.call(this),this._unsubSharedRestore=null,null===(t=this._unsubSharedOpenPending)||void 0===t||t.call(this),this._unsubSharedOpenPending=null,(0,d.setSacPrepareShareDraft)(null),this.isSacShareUrlSessionActive()&&(0,d.clearSacShareDefaultConfigReady)()},t.prototype.handleSharedRestoreVarChange=function(){this.isSacShareUrlSessionActive()&&(this.consumeSharedSacRestoreSession(),this.tryApplySharedSessionWhenAvailable().catch(function(){}))},t.prototype.handleSacShirtSwatchChange=function(e){if(!this._suppressShirtSwatchProductSync&&!this._closingAfterSave&&"ready"===this.state.loadState){var t=this.props,r=t.productAttributes,n=t.simpleProduct,i=t.configurableProduct;!function(e,t,r,n,i,o){var a,s,l,c=ie(e);if(!c)return!1;var u=null==t?void 0:t.find(function(e){var t;return e.code===$.COLOR_ATTRIBUTE_CODE||"color"===(null===(t=e.label)||void 0===t?void 0:t.toLowerCase())});if(u){var d=u.options.find(function(e){return ne(e).trim().toLowerCase()===c});if(d)return d.selected||d.disabled||d.handleClick(),!0}var p=(0,te.findColorOptionOnProduct)(o),h=oe(null==p?void 0:p.options,e);if(p&&h&&i){var f=null!==(a=n[p.id])&&void 0!==a?a:n[String(p.id)];return Number(f)!==h.id&&i(String(p.id),String(h.id),"1"),!0}var v=null===(s=null==r?void 0:r.options)||void 0===s?void 0:s.find(function(e){var t,r;return"color"===(null===(t=e.code)||void 0===t?void 0:t.toLowerCase())||"color"===(null===(r=e.label)||void 0===r?void 0:r.toLowerCase())}),S=oe(null==v?void 0:v.options,e);v&&S&&i&&(f=null!==(l=n[v.id])&&void 0!==l?l:n[String(v.id)],Number(f)!==S.id&&i(String(v.id),String(S.id),"1"))}(e,r,n,t.selections,t.setSelections,i)}},t.prototype.handleSacArtworkCountChange=function(e,t){if(!this._closingAfterSave&&(!this._deferArtworkLocationProductSync||(null==t?void 0:t.bypassDefer))&&(!this._suppressArtworkLocationProductSync||(null==t?void 0:t.bypassDefer))){var r=this.state,n=r.loadState,i=r.designer;if("saving"!==n&&((null==t?void 0:t.bypassDefer)||"ready"===n)){var o=we(null!=i?i:null),a=Math.max(1,o>0?o:e);if(a!==this._lastSyncedArtworkLocation){var s=this.props,l=s.productAttributes,c=s.configurableProduct,u=s.selections,d=s.setSelections;this.refreshCartSelectionsSnapshot(i,a),ce(a,l,c,u,d)&&(this._lastSyncedArtworkLocation=a),this.persistShareDraftFromDesigner(i)}}}},t.prototype.setSelectedItem=function(e){var t=this.props.configItemId;this._restoredItem=pe(e,t)},t.prototype.getSelectionsAndQuantityForSave=function(){var e,t,r,n,i=this.props,o=i.quantity,a=i.isOrderMultiple,s=i.multiSelections,l=i.configurableProduct,c=i.quantityState,d=i.selections,p=null!==(e=null==c?void 0:c.current)&&void 0!==e?e:o,h=null!==(t=this._cartSelectionsSnapshot)&&void 0!==t?t:d;if(a&&(null==s?void 0:s.length)&&(null==l?void 0:l.type)===(0,u.getProductTypeConfigurable)()){var f=s[0];return{selections:null!==(r=this._cartSelectionsSnapshot)&&void 0!==r?r:f.selections,quantity:null!==(n=f.qty)&&void 0!==n?n:p}}return{selections:h,quantity:p}},t.prototype.setDesigner=function(e){var t,r=this,n=this._pendingSessionState,i=this.isSacShareUrlSessionActive();if(i&&n&&!(0,d.isShareableSacSession)(n)&&(null===(t=(0,d.getConfigIdFromQuery)())||void 0===t?void 0:t.trim())&&(n=null,this._pendingSessionState=null),n&&"function"==typeof e.importSessionState){this._sessionRestoreId+=1;var o=this._sessionRestoreId;this._pendingSessionState=null,this._suppressShirtSwatchProductSync=!0,i&&(this._shareRestorePreviewContext={session:n,placement:(0,d.extractSacSharePlacement)(n),specialInstructions:(0,d.extractSacSpecialInstructions)(n)},this._sharedSessionAppliedKey=Ce(n,void 0,void 0,be()),this._sharedSessionApplyInFlight=!0),e.importSessionState(i?(0,D.prepareSacSessionForShareRestore)(n):n,{deferShirtColorToHost:!0}
1).catch(function(){}).then(function(){return ge(r,void 0,void 0,function(){return me(this,function(t){switch(t.label){case 0:return i?(Ae(e,n),[4,(0,D.restoreSacDesignFromShareSession)(e,n)]):[3,2];case 1:t.sent(),this._deferArtworkLocationProductSync&&(this._deferArtworkLocationProductSync=!1),t.label=2;case 2:return[2,this.syncConfiguratorColorFromPdp(e,!0)]}})})}).finally(function(){if(i&&(r._sharedSessionApplyInFlight=!1),o===r._sessionRestoreId)return r.finishDesignerInitialization(e,!0)})}else this.finishDesignerInitialization(e).catch(function(){})},t.prototype.isSacShareUrlSessionActive=function(){return!this.props.configItemId&&Boolean(be())},t.prototype.syncShareConfigIdSession=function(){var e=be();e!==this._activeShareConfigId&&(this._activeShareConfigId=e,this._sharedSessionAppliedKey="",this._pendingSessionState=null,this._shareRestorePreviewContext=null,e||(0,d.clearSacShareDefaultConfigReady)())},t.prototype.attachSharedRestoreListeners=function(){this.reattachSharedRestoreListener(),this.reattachSharedOpenPendingListener()},t.prototype.reattachSharedRestoreListener=function(){var e,t=this;null===(e=this._unsubSharedRestore)||void 0===e||e.call(this),this._unsubSharedRestore=d.sharedConfigurationRestoreVar.onNextChange(function(){t.handleSharedRestoreVarChange(),t.reattachSharedRestoreListener()})},t.prototype.reattachSharedOpenPendingListener=function(){var e,t=this;null===(e=this._unsubSharedOpenPending)||void 0===e||e.call(this),this._unsubSharedOpenPending=d.sharedConfiguratorOpenPendingVar.onNextChange(function(){t.handleSharedRestoreVarChange(),t.reattachSharedOpenPendingListener()})},t.prototype.installShareSafeSwitchSide=function(e){if(this.isSacShareUrlSessionActive()){var t=e.getContext();if(t&&!ye.has(e)){ye.add(e);var r="function"==typeof t.switchSide?t.switchSide.bind(t):void 0;t.switchSide=function(e){var n,i;null===(i=null===(n=t.canvas)||void 0===n?void 0:n.discardActiveObject)||void 0===i||i.call(n),null==r||r(e)}}}},t.prototype.refreshShareUrlDesignerPreview=function(e,t){return ge(this,void 0,void 0,function(){var r;return me(this,function(n){switch(n.label){case 0:return this.isSacShareUrlSessionActive()&&(null==(r=(null==t?void 0:t.session)?t:this._shareRestorePreviewContext)?void 0:r.session)?[4,(0,D.refreshSacDesignerPreview)(e,r.session,{placement:r.placement,specialInstructions:r.specialInstructions})]:[2];case 1:return n.sent(),[2]}})})},t.prototype.tryApplySharedSessionWhenAvailable=function(){return ge(this,void 0,void 0,function(){var e,t,r,n,i,o,a,s,l,c,u,p,h,f,v,S,g,m,y,b,w,C,A;return me(this,function(P){switch(P.label){case 0:if(this._sharedSessionApplyInFlight||this._closingAfterSave)return[2];if(!this.isSacShareUrlSessionActive())return[2];if(e=this.state,t=e.designer,r=e.loadState,!t||"ready"!==r)return[2];if(n=(0,d.sharedConfigurationRestoreVar)(),i=null===(y=null==n?void 0:n.customOptions)||void 0===y?void 0:y.sacSession,o=this.props,a=o.configurableProduct,s=o.productC
1onfig,l=(null===(b=null==s?void 0:s.product)||void 0===b?void 0:b.sku)||(null==a?void 0:a.sku),c=(null===(w=null==s?void 0:s.product)||void 0===w?void 0:w.id)||(null==a?void 0:a.id),u=null,p=null===(C=null==n?void 0:n.customOptions)||void 0===C?void 0:C.sacPlacement,h=null===(A=null==n?void 0:n.customOptions)||void 0===A?void 0:A.sacSpecialInstructions,i&&"object"==typeof i?u=(0,d.ensureSacShareMetaInSession)(i,{placement:p,specialInstructions:h}):this._pendingSessionState?(u=(0,d.ensureSacShareMetaInSession)(this._pendingSessionState,{placement:p,specialInstructions:h}),p=p||(0,d.extractSacSharePlacement)(this._pendingSessionState),h=h||(0,d.extractSacSpecialInstructions)(this._pendingSessionState)):this._sharedSessionAppliedKey||be()||(null==(f=(0,d.getSacDraftForProduct)(l,c))?void 0:f.sessionState)&&(v=f.placement,S=f.specialInstructions,g=f.sessionState,u=(0,d.ensureSacShareMetaInSession)(g,{placement:v,specialInstructions:S}),p=v,h=S),!u)return this.isSacShareUrlSessionActive()&&this._sharedSessionAppliedKey&&(0,d.sacShareRestoreReadyVar)(!0),[2];if(m=Ce(u,p,h,be()),this._sharedSessionAppliedKey===m)return[2];this._sharedSessionApplyInFlight=!0,P.label=1;case 1:if(P.trys.push([1,,9,10]),this._pendingSessionState=null,"function"!=typeof t.importSessionState)return[3,5];P.label=2;case 2:return P.trys.push([2,4,,5]),[4,t.importSessionState((0,D.prepareSacSessionForShareRestore)(u),{deferShirtColorToHost:!0})];case 3:case 4:return P.sent(),[3,5];case 5:return Ae(t,u,n),[4,(0,D.restoreSacDesignFromShareSession)(t,u,{placement:p,specialInstructions:h})];case 6:return P.sent(),[4,this.syncConfiguratorColorFromPdp(t,!0)];case 7:return P.sent(),[4,this.refreshShareUrlDesignerPreview(t,{session:u,placement:p,specialInstructions:h})];case 8:return P.sent(),this.persistShareDraftFromDesigner(t),this._sharedSessionAppliedKey=m,(0,d.sacShareRestoreReadyVar)(!0),i&&(0,d.clearSharedConfigurationRestore)(),this._deferArtworkLocationProductSync&&(this._deferArtworkLocationProductSync=!1,this.syncArtworkLocationFromDesigner(t,!0)),[3,10];case 9:return this._sharedSessionApplyInFlight=!1,[7];case 10:return[2]}})})},t.prototype.finishDesignerInitialization=function(e){return ge(this,arguments,void 0,function(e,t){return void 0===t&&(t=!1),me(this,function(r){switch(r.label){case 0:return[4,this.syncConfiguratorColorFromPdp(e,t)];case 1:return r.sent(),this._shareRestorePreviewContext?[4,this.refreshShareUrlDesignerPreview(e,this._shareRestorePreviewContext)]:[3,3];case 2:r.sent(),this._shareRestorePreviewContext=null,r.label=3;case 3:return[4,this.restoreCartDesignIfEditing(e)];case 4:return r.sent(),this.finishDesignerReady(e),[2]}})})},t.prototype.restoreCartDesignIfEditing=function(e){return ge(this,void 0,void 0,function(){var t,r,n,i,o,a;return me(this,function(s){switch(s.label){case 0:if(this.isSacShareUrlSessionActive())return[2];if(t=this.props,r=t.cartItems,n=t.configItemId,!(i=pe(r,n)))return[2];if(this._restoredItem=i,!(o=he(n,i)))return[2];if(this._cartRestoreSucceededForItemId===o||this._cartRestoreInFlight)return[2];this._cartRestoreInFlight=!0,this._suppressArtworkLocationProductSync=!0,a=this.state.apiConfig,s.label=1;case 1:return s.trys.push([1,3,4,5]),[4,(0,de.restoreSacDesignFromCart)(e,i,a)];case 2:return s.sent()&&(this._cartRestoreSucceededForItemId=o,this.persistShareDraftFromDesigner(e)),[3,5];case 3:return s.sent(),[3,5];case 4:return this._cartRestoreInFlight=!1,this._suppressArtworkLocationProductSync=!1,this.syncArtworkLocationAfterCartRestore(e),[7];case 5:return[2]}})})},t.prototype.countExpectedCartArtworks=function(e){var t,r,n=this.state.apiConfig;return e&&n&&null!==(r=null===(t=(0,de.buildSacDesignStateFromCartItem)(e,n))||void 0===t?void 0:t.artwork.length)&&void 0!==r?r:0},t.prototype.tryRestoreCartDesignWhenReady=function(e){return ge(this,void 0,void 0,function(){var t,r,n,i,o,a,s,l,c,u,d;return me(this,function(p){switch(p.label){case 0:return this.isSacShareUrlSessionActive()?[2]:(t=this.state,r=t.designer,n=t.loadState,i=t.apiConfig,o=null!=e?e:r,a=this.props,s=a.cartItems,l=a.configItemId,o&&"ready"===n&&i&&l?(c=pe(s,l),(u=he(l,c))&&c?this._cartRestoreSucceededForItemId===u?[2]:(d=this.countExpectedCartArtworks(c))<=0?(this.clearDeferredArtworkLocationSyncFromSelections(),[2]):we(o)>=d?(this._cartRestoreSucceededForItemId=u,this.syncArtworkLocationAfterCartRestore(o),[2]):[4,this.restoreCartDesignIfEditing(o)]:[2]):[2]);case 1:return p.sent(),[2]}})})},t.prototype.clearDeferredArtworkLocationSyncFromSelections=function(){if(this._deferArtworkLocationProductSync){this._deferArtworkLocationProductSync=!1;var e=this.props,t=se(e.selections,e.configurableProduct,e.productAttributes);null!=t&&(this._lastSyncedArtworkLocation=t)}},t.prototype.syncArtworkLocationAfterCartRestore=function(e){this._deferArtworkLocationProductSync=!1;var t=we(e),r=this.props,n=r.selections,i=r.configurableProduct,o=r.productAttributes,a=r.setSelections,s=r.cartItems,l=r.configItemId,c=se(n,i,o),u=pe(s,l),d=this.countExpectedCartArtworks(u),p=Math.max(1,t>0?t:0,null!=c?c:0,d>0?d:0);p===this._lastSyncedArtworkLocation&&t===p||(this._lastSyncedArtworkLocation=0,this.refreshCartSelectionsSnapshot(e,p),ce(p,o,i,n,a)&&(this._lastSyncedArtworkLocation=p))},t.prototype.shouldDeferArtworkLocationSyncUntilShareRestore=function(e){var t;if(!this.isSacShareUrlSessionActive())return!1;
1var r=(0,d.sharedConfigurationRestoreVar)(),n=(this._pendingSessionState&&"object"==typeof this._pendingSessionState?this._pendingSessionState:null)||(null===(t=null==r?void 0:r.customOptions)||void 0===t?void 0:t.sacSession);if(!n||"object"!=typeof n)return!1;var i=function(e){var t;if(!e||"object"!=typeof e)return 0;var r=e.designState;if(Array.isArray(null==r?void 0:r.artwork))return r.artwork.length;var n=e.canvasSnapshot,i=null===(t=null==n?void 0:n.json)||void 0===t?void 0:t.objects;return Array.isArray(i)?i.filter(function(e){return e&&"image"===e.type&&!e._designerRole&&null!=e._artworkListId}).length:0}(n);return!(i<=0)&&we(e)<i},t.prototype.shouldDeferArtworkLocationSyncUntilCartRestore=function(e){var t=this.props,r=t.cartItems,n=t.configItemId;if(!n)return!1;var i=pe(r,n),o=he(n,i);if(!o||!i)return!1;if(this._cartRestoreSucceededForItemId===o)return!1;var a=this.countExpectedCartArtworks(i);return!(a<=0)&&we(e)<a},t.prototype.finishDesignerReady=function(e){var t=this;this._suppressShirtSwatchProductSync=!1,this.installShareSafeSwitchSide(e),this.shouldDeferArtworkLocationSyncUntilCartRestore(e)||this.shouldDeferArtworkLocationSyncUntilShareRestore(e)||this._deferArtworkLocationProductSync||this.syncArtworkLocationFromDesigner(e,!0),this.setState({designer:e,loadState:"ready"},function(){t.persistShareDraftFromDesigner(e),t.bindShareDraftPersistence(e),t.tryRestoreCartDesignWhenReady(e).catch(function(){}),t.tryApplySharedSessionWhenAvailable().catch(function(){})})}
1,t.prototype.publishOpened=function(){var e=this.props,t=e.appEventBus,r=e.configurableProduct;t.publish("chefworks.sac.opened",r)},t.prototype.syncSacPrepareShareDraftBridge=function(){var e=this,t=this.state,r=t.designer,n=t.loadState;r&&"ready"===n?(0,d.setSacPrepareShareDraft)(function(){return e.prepareShareDraftWithUploads()}):this.isSacShareUrlSessionActive()||(0,d.setSacPrepareShareDraft)(null)},t.prototype.refreshShareSacSessionCache=function(e,t,r){var n,i,o=be();if(o){var a=(0,d.sanitizeSacSessionForShare)(e,{placement:t,specialInstructions:r});if(a){var s=this.props,l=s.configurableProduct,c=s.productConfig,u=(null===(n=null==c?void 0:c.product)||void 0===n?void 0:n.sku)||(null==l?void 0:l.sku),p=(null===(i=null==c?void 0:c.product)||void 0===i?void 0:i.id)||(null==l?void 0:l.id);(0,d.setSharedSacSessionCache)({configId:o,productSku:u,productId:p,sessionState:a,placement:t,specialInstructions:r})}}},t.prototype.bindShareDraftPersistence=function(e){var t=this;if("undefined"!=typeof document){var r=function(){return t.persistShareDraftFromDesigner(e)},n=document.getElementById("specialInstructionsInput");n&&!n.dataset.sacShareDraftBound&&(n.dataset.sacShareDraftBound="1",n.addEventListener("input",r),n.addEventListener("change",r));var i=document.getElementById("placementButtons")||document.querySelector(".sac-placement-buttons");i instanceof HTMLElement&&!i.dataset.sacShareDraftBound&&(i.dataset.sacShareDraftBound="1",i.addEventListener("click",r))}},t.prototype.persistShareDraftFromDesigner=function(e,t){var r,n,i=this.state.designer,o=null!=e?e:i;if(o&&"function"==typeof o.exportSessionState){var a=this.props,s=a.configurableProduct,l=a.productConfig,c=(null===(r=null==l?void 0:l.product)||void 0===r?void 0:r.sku)||(null==s?void 0:s.sku),u=(null===(n=null==l?void 0:l.product)||void 0===n?void 0:n.id)||(null==s?void 0:s.id);if(c)try{var p=t||o.exportSessionState();(0,d.persistSacDraft)(c,p,u)}catch(e){}}},t.prototype.prepareShareDraftWithUploads=function(){return ge(this,void 0,void 0,function(){var e,t,r,n,i,o,a,s,l,c,u,p,h,f,v,S,g,m,y,b,C,A,P;return me(this,function(k){switch(k.label){case 0:if(e=this.state,t=e.designer,r=e.sourceMappings,n=this.props.sacRepository,!t||"function"!=typeof t.exportSessionState)return this.persistShareDraftFromDesigner(),[2];i=null===(C=null==r?void 0:r.artworks)||void 0===C?void 0:C.virtualProductId,o=this.props,a=o.configurableProduct,s=o.productC
1onfig,l=(null===(A=null==s?void 0:s.product)||void 0===A?void 0:A.sku)||(null==a?void 0:a.sku),c=(null===(P=null==s?void 0:s.product)||void 0===P?void 0:P.id)||(null==a?void 0:a.id),u=t.exportSessionState(),p=function(e,t){var r,n=null===(r=(0,d.getConfigIdFromQuery)())||void 0===r?void 0:r.trim();if(n){var i=(0,d.getSharedSacSessionCache)(n,e,t);if((null==i?void 0:i.sessionState)&&(0,d.isShareableSacSession)(i.sessionState))return i.sessionState}var o=(0,d.getSacDraftForProduct)(e,t);return(null==o?void 0:o.sessionState)&&(0,d.isShareableSacSession)(o.sessionState)?o.sessionState:null}(l,c)||u,h=Y(t,p,u),f=h.sessionState,v=h.changedListIds,S=f,g=new Map,k.label=1;case 1:return k.trys.push([1,4,,5]),i&&n?[4,Promise.all([w(t,n,i,v),_(t,n,i)])]:[3,3];case 2:m=k.sent(),y=m[0],b=m[1],S=function(e,t,r){var n=Z({},e.designState||{});Array.isArray(n.artwork)&&t.size&&(n.artwork=n.artwork.map(function(e){if(!e||"object"!=typeof e)return e;var r=e,n=null!=r.listId?String(r.listId):"",i=n?t.get(n):void 0;return i?Z(Z(Z(Z({},r),{editedUpload:i,uploadApiUrl:i.url,artworkPixelEdited:!0}),i.thumb_quote_path?{uploadThumbQuotePath:i.thumb_quote_path}:{}),i.thumb_order_path?{uploadThumbOrderPath:i.thumb_order_path}:{}):e}));var i=Z(Z({},e),{designState:n});return r.size&&(i.viewPreviews=Array.from(r.entries()).map(function(e){var t=e[0],r=e[1];return{side:t,previewUploadRegular:r.regular,previewUploadLarge:r.large}})),i}(S,g=y,b),k.label=3;case 3:return[3,5];case 4:return k.sent(),[3,5];case 5:return S=function(e,t,r,n){if(!r.size)return e;var i=q(t),o=F({},e.designState||{}),a=o.artwork;return Array.isArray(a)?(o.artwork=a.map(function(e){if(!e||"object"!=typeof e)return e;var t=e,o=null!=t.listId?String(t.listId):"";if(!o||!r.has(o)||n.has(o))return e;var a=i.get(o);return a?V(H(a),t):e}),F(F({},e),{designState:o})):e}(S,p,v,g),S=function(e,t,r){var n=F({},e.designState||{}),i=n.artwork;return Array.isArray(i)?(n.artwork=i.map(function(e){if(!e||"object"!=typeof e)return e;var n=e,i=null!=n.listId?String(n.listId):"";return i&&r.has(i)&&t.has(i),e}),F(F({},e),{designState:n})):e}(S,g,v),S=function(e,t,r,n,i,o){void 0===i&&(i=new Set),void 0===o&&(o=new Map);var a=q(r),s=n?q(n):new Map,l=T(e),c=F({},t.designState||{}),u=c.artwork;return Array.isArray(u)?(c.artwork=u.map(function(e){if(!e||"object"!=typeof e)return e;var t=e,r=null!=t.listId?String(t.listId):"";if(!r)return e;var n=!i.has(r),c=i.has(r)&&o.has(r);if(!n&&!c)return e;var u=s.get(r),d=a.get(r),p=l.get(r);if(n&&u)return X(u,d,p);var h=J(t,{fabricImg:p,exportItem:d});return u?z(u,h):h}),F(F({},t),{designState:c})):t}(t,S,u,p,v,g),this.persistShareDraftFromDesigner(t,S),this.refreshShareSacSessionCache(S,(0,d.extractSacSharePlacement)(S),(0,d.extractSacSpecialInstructions)(S)),[2]}})})},t.prototype.consumeSharedSacRestoreSession=function(){var e,t,r,n,i,o;if(this.isSacShareUrlSessionActive()){var a=this.props,s=a.configurableProduct,l=a.productConfig,c=(null===(e=null==l?void 0:l.product)||void 0===e?void 0:e.sku)||(null==s?void 0:s.sku),u=(null===(t=null==l?void 0:l.product)||void 0===t?void 0:t.id)||(null==s?void 0:s.id),p=(0,d.sharedConfigurationRestoreVar)(),h=null===(r=null==p?void 0:p.customOptions)||void 0===r?void 0:r.sacSession;if(h&&"object"==typeof h){var f=(0,d.ensureSacShareMetaInSession)(h,{placement:null===(n=null==p?void 0:p.customOptions)||void 0===n?void 0:n.sacPlacement,specialInstructions:null===(i=null==p?void 0:p.customOptions)||void 0===i?void 0:i.sacSpecialInstructions});return this._pendingSessionState=f,void(0,d.clearSharedConfigurationRestore)()}if(!this._pendingSessionState){if(null===(o=(0,d.getConfigIdFromQuery)())||void 0===o?void 0:o.trim())return;var v=(0,d.getSacDraftForProduct)(c,u);(null==v?void 0:v.sessionState)&&(this._pendingSessionState=(0,d.ensureSacShareMetaInSession)(v.sessionState,{placement:v.placement,specialInstructions:v.specialInstructions}))}}},t.prototype.resolveSessionStateForReload=function(){var e,t,r=this.state,n=r.designer,i=r.loadState,o=this.props,a=o.configurableProduct,s=o.productC
1onfig,l=(null===(e=null==s?void 0:s.product)||void 0===e?void 0:e.sku)||(null==a?void 0:a.sku),c=(null===(t=null==s?void 0:s.product)||void 0===t?void 0:t.id)||(null==a?void 0:a.id),u=this.isSacShareUrlSessionActive(),p=this._pendingSessionState;if(!n||"ready"!==i&&"saving"!==i)return p;if("function"!=typeof n.exportSessionState)return p;try{var h=n.exportSessionState();if((0,d.isShareableSacSession)(h))return l&&(0,d.persistSacDraft)(l,h,c),h}catch(e){}return u?(0,d.isShareableSacSession)(p)?p:null:p},t.prototype.publishSaved=function(){var e=this,t=this.props,r=t.appEventBus,n=t.configurableProduct,i=t.quantity;r.publish("chefworks.sac.saved",n);var o=0===i?"removed":e._restoredItem?"updated":"added";r.publish("chefworks.sac.".concat(o),n)},t.prototype.syncConfiguratorColorFromPdp=function(e){return ge(this,arguments,void 0,function(e,t){var r,n,i,o,a,s,l,c;return void 0===t&&(t=!1),me(this,function(u){switch(u.label){case 0:return r=this.props,n=r.selections,i=r.simpleProduct,o=r.configurableProduct,a=this.state.sacConfig,"string"==typeof(s=null!==(c=(0,te.resolveShirtSwatchIdFromPdpSelections)(n,i,o))&&void 0!==c?c:"string"==typeof(null==a?void 0:a.shirtSwatchId)?a.shirtSwatchId:void 0)&&s.trim()?(l=s.trim().toLowerCase(),a&&a.shirtSwatchId!==l&&this.setState({sacConfig:Se(Se({},a),{shirtSwatchId:l})}),[4,this.applyProductShirtColorFromConfig(e,l,t)]):[2];case 1:return u.sent(),[2]}})})},t.prototype.applyProductShirtColorFromConfig=function(e,t,r){var n,i=this;void 0===r&&(r=!1);var o=this.props,a=o.selections,s=o.simpleProduct,l=o.configurableProduct,c=this.state.sacConfig,u=null!==(n=null!=t?t:(0,te.resolveShirtSwatchIdFromPdpSelections)(a,s,l))&&void 0!==n?n:"string"==typeof(null==c?void 0:c.shirtSwatchId)?c.shirtSwatchId:void 0;if("string"!=typeof u||!u.trim())return Promise.resolve();var d=e.getContext(),p=u.trim().toLowerCase();return String((null==d?void 0:d.currentShirtSwatchId)||"").trim().toLowerCase()===p||"function"!=typeof(null==d?void 0:d.applyShirtSwatch)?Promise.resolve():(this._suppressShirtSwatchProductSync=!0,new Promise(function(e){d.applyShirtSwatch(p,function(){r||(i._suppressShirtSwatchProductSync=!1),e()})}))},t.prototype.syncArtworkLocationFromDesigner=function(e,t){void 0===t&&(t=!1);var r=e.getContext(),n="function"==typeof(null==r?void 0:r.countUserArtworkImages)?r.countUserArtworkImages():0;t&&(this._lastSyncedArtworkLocation=0),this.handleSacArtworkCountChange(n,{bypassDefer:!0})},t.prototype.resolveArtworkCountForSelections=function(e,t){if(null!=t)return Math.max(1,t);var r=we(null!=e?e:null);if(r>0)return r;var n=this.props,i=se(n.selections,n.configurableProduct,n.productAttributes);return Math.max(1,null!=i?i:1)},t.prototype.refreshCartSelectionsSnapshot=function(e,t){var r=this.state.designer,n=null!=e?e:r,i=this.resolveArtworkCountForSelections(n,t),o=this.props,a=o.selections,s=o.configurableProduct,l=o.productAttributes,c=o.isOrderMultiple,d=o.multiSelections,p=c&&(null==d?void 0:d.length)&&(null==s?void 0:s.type)===(0,u.getProductTypeConfigurable)()?d[0].selections:a;this._cartSelectionsSnapshot=function(e,t,r,n){var i,o,a=re({},e);null===(i=t.options)||void 0===i||i.forEach(function(e){var t;if(null==a[e.id]&&null==a[String(e.id)]){var n=null==r?void 0:r.find(function(t){return t.code===e.code||t.id===e.id}),i=null===(t=null==n?void 0:n.options)||void 0===t?void 0:t.find(function(e){return e.selected});i&&(a[e.id]=i.id)}});var s=le(n,t),l=null===(o=t.options)||void 0===o?void 0:o.find(function(e){return e.code===(0,ee.getDirectToFilmHiddenProductAttributeCode)()});return l&&null!=s&&(a[l.id]=s),a}(p,s,l,i)},t.prototype.close=function(){this._pendingSessionState=null,this._lastSyncedArtworkLocation=0,this._deferArtworkLocationProductSync=!1,(0,d.clearSacShareDefaultConfigReady)(),this._cartSelectionsSnapshot=null,this._closingAfterSave=!1,this._cartRestoreSucceededForItemId=0,this._cartRestoreInFlight=!1,this._restoredItem=void 0,this._sessionRestoreId+=1,(0,this.props.closeSac)()},t.prototype.save=function(){return ge(this,void 0,void 0,function(){var e,t,r,n,i,o,a,s,l,c,d,v,S,g,m,y,b,A,P,k,D,F,R,x,O,L,N,U,j,M,q,T,V,G,B,W;return me(this,function(Q){switch(Q.label){case 0:if(e=this.state,t=e.designer,r=e.sourceMappings,n=e.apiConfig,i=e.loadState,o=this.props,a=o.sacRepository,s=o.getCartList,l=o.enqueueNotification,c=o.afterSave,d=o.simpleProduct,v=o.configurableProduct,S=o.configItemId,g=o.cartItems,m=o.isOrderMultiple,y=o.multiSelections,b=o.productAttributes,!t)return l({type:"primary",message:"Designer is still loading. Please wait.",time:5e3}),[2];if("saving"===i)return[2];if(!t.isDesignValid())return l({type:"primary",message:"Add artwork on at least one placement before saving.",time:5e3}),[2];this.setState({loadState:"saving"}),Q.label=1;case 1:return Q.trys.push([1,11,,12]),A=this.getSelectionsAndQuantityForSave(),P=A.selections,k=A.quantity,D={productId:d.id,configItemId:S,quantity:k,selections:P},[4,w(t,a,null===(B=null==r?void 0:r.artworks)||void 0===B?void 0:B.virtualProductId)];case 2:return F=Q.sent(),[4,_(t,a,null===(W=null==r?void 0:r.artworks)||void 0===W?void 0:W.virtualProductId)];case 3:return R=Q.sent(),O=C,L=I,[4,(0,p.serializeDesignForApi)(t,D)];case 4:if(x=O.apply(void 0,[L.apply(void 0,[Q.sent(),R]),F]),!n||!r)throw new Error("Designer configuration is not loaded.");return N=(0,h.buildSacLoadProductInfo)(d,v,P),U=pe(g,S),j=he(S,null!=U?U:this._restoredItem),M=(0,ue.checkIsSacLockdown)({attributes:null!=b?b:[]}),Boolean(m&&(null==y?void 0:y.length)&&(null==v?void 0:v.type)===(0,u.getProductTypeConfigurable)())&&y?(q=(0,f.buildSacMultipleDirectToFilmC
1artPayloads)(d,v,y,x,r,n,U,M),[4,a.saveMultiple(q,j)]):[3,6];case 5:return Q.sent(),[3,8];case 6:return[4,a.save(N,x,r,n,null!=U?U:this._restoredItem,j,M)];case 7:Q.sent(),Q.label=8;case 8:return[4,s()];case 9:return Q.sent(),document.dispatchEvent(new CustomEvent("chefworks.sac.saved",{detail:x})),this.publishSaved(),this._closingAfterSave=!0,[4,(0,p.waitForFabricRenderDrain)()];case 10:return Q.sent(),function(e){(0,p.silenceFabricCanvasRenders)(e.getCanvas())}(t),t.destroy(),c(),[3,12];case 11:throw T=Q.sent(),this.setState({loadState:"ready"}),V=(0,E.resolveUserFacingApiErrorMessage)(T,"Could not save your design. Please try again."),"function"==typeof(null==(G=t.getContext())?void 0:G.showPreviewStatus)&&G.showPreviewStatus("failed",V),l({type:"primary",message:V,time:5e3}),T;case 12:return[2]}})})},t.prototype.isDifferentProductSelections=function(){var e=this.props,t=e.selections,r=e.configurableProduct;if(!this._lastProduct||!this._lastSelections)return!0;if(t===this._lastSelections)return!1;var n=(0,c.getSelectionsWithoutArtworkOption)(this._lastSelections,r),i=(0,c.getSelectionsWithoutArtworkOption)(t,r);return!o()(i,n)},t.prototype.isColorOnlySelectionChange=function(){var e,t,r=this.props,n=r.selections,i=r.configurableProduct,a=r.simpleProduct;if(!this._lastSelections)return!1;var s=(0,te.findColorOptionOnProduct)(i)||(0,te.findColorOptionOnProduct)(a);if(!s)return!1;var l=(0,c.getSelectionsWithoutArtworkOption)(this._lastSelections,i),u=(0,c.getSelectionsWithoutArtworkOption)(n,i),d=function(e){var t=Se({},e);return delete t[s.id],delete t[String(s.id)],t};return(null!==(e=l[s.id])&&void 0!==e?e:l[String(s.id)])!==(null!==(t=u[s.id])&&void 0!==t?t:u[String(s.id)])&&o()(d(l),d(u))},t.prototype.performUpdates=function(){if(!this._closingAfterSave){var e=this.props,t=e.simpleProduct,r=e.selections,n=e.configurableProduct,i=this.state,a=i.designer,s=i.loadState,l=i.sacConfig,c=!o()(r,this._lastSelections);if((null==t?void 0:t.id)!==this._lastProduct||(null==n?void 0:n.id)!==this._lastConfigProduct||c){var u=this.isDifferentProductSelections();if(u&&this.isColorOnlySelectionChange()&&a&&("ready"===s||"saving"===s))return this.syncConfiguratorColorFromPdp(a).finally(function(){}),this._lastProduct=null==t?void 0:t.id,this._lastConfigProduct=null==n?void 0:n.id,this._lastSelections=r,void this.refreshCartSelectionsSnapshot(a);if(u&&"saving"!==s){if(this.isSacShareUrlSessionActive()&&l)return this._lastProduct=null==t?void 0:t.id,this._lastConfigProduct=null==n?void 0:n.id,this._lastSelections=r,this.refreshCartSelectionsSnapshot(a),this.consumeSharedSacRestoreSession(),void this.tryApplySharedSessionWhenAvailable().catch(function(){});this.captureSessionStateBeforeReload(),this.loadSacConfigFromApi(),this.publishOpened()}this._lastProduct=null==t?void 0:t.id,this._lastConfigProduct=null==n?void 0:n.id,this._lastSelections=r,this.refreshCartSelectionsSnapshot()}}},t.prototype.captureSessionStateBeforeReload=function(){this.isColorOnlySelectionChange()?this.isSacShareUrlSessionActive()||(this._pendingSessionState=null):this._pendingSessionState=this.resolveSessionStateForReload()},t.prototype.loadSacConfigFromApi=function(){return ge(this,void 0,void 0,function(){var e,t,r,n,i,o,a,s,l,c,u,p,f,v,S,g,m,y;return me(this,function(b){switch(b.label){case 0:e=this.props,t=e.sacRepository,r=e.cartItems,n=e.configItemId,i=e.simpleProduct,o=e.configurableProduct,a=e.selections,s=e.productAttributes,l=e.enqueueNotification,this.setSelectedItem(null!=r?r:[]),c=this.isSacShareUrlSessionActive(),u=c&&(0,d.isShareableSacSession)(this._pendingSessionState)?this._pendingSessionState:null,this.consumeSharedSacRestoreSession(),u&&!this._pendingSessionState&&(this._pendingSessionState=u),u||(this._sharedSessionAppliedKey=""),this._sharedSessionApplyInFlight=!1,this._cartRestoreSucceededForItemId=0,this._cartRestoreInFlight=!1,this._deferArtworkLocationProductSync=Boolean(n)||c,c&&(0,d.sacShareDefaultConfigReadyVar)(!1),n?null!=(p=se(a,o,s))&&(this._lastSyncedArtworkLocation=p):this._lastSyncedArtworkLocation=0,this.setState({loadState:"loading",designer:null,sacConfig:null,apiConfig:null,sourceMappings:null}),f=pe(r,n),v=(0,h.buildSacLoadProductInfo)(i,o,a),b.label=1;case 1:return b.trys.push([1,3,,4]),[4,t.loadSacConfig(v,f,i,a,o)];case 2:return S=b.sent(),g=S.apiConfig,m=S.sacConfig,y=S.sourceMappings,this.setState({apiConfig:g,sacConfig:m,sourceMappings:y,loadState:"loading"}),this._sacConfigRevision+=1,c&&(0,d.sacShareDefaultConfigReadyVar)(!0),[3,4];case 3:return b.sent(),l({type:"primary",message:"Could not load the designer configuration. Please try again.",time:5e3}),this.setState({loadState:"error"}),[3,4];case 4:return[2]}})})}
1,t.prototype.render=function(){var e=this,t=this.state,r=t.designer,i=t.loadState,o=t.apiConfig,a=t.sacConfig,s=t.sourceMappings,l=this.props,c=l.simpleProduct,u=l.configurableProduct,d=l.quantityState,p=l.isOrderMultiple,h=l.multiSelections,f=l.bundleItemPriceData,v=l.configValidation,S=l.isQuickView,g=l.productConfig,m=l.cartItems,y="saving"===i,b=function(e){var t,r;return{product:e.simpleProduct,quantityState:e.quantityState,isOrderMultiple:e.isOrderMultiple,multiSelections:e.multiSelections,bundleItemPriceData:e.bundleItemPriceData,isDisplayConfigPrice:!!(null===(t=e.apiConfig)||void 0===t?void 0:t.is_display_config_price),previewDisclaimer:String((null===(r=e.apiConfig)||void 0===r?void 0:r.preview_disclaimer)||"").trim(),personalizationPrice:0,cannotSave:e.cannotSave,isSaving:e.isSaving,isQuickView:e.isQuickView,save:e.save,configValidation:e.configValidation,productConfig:e.productConfig,cartItems:e.cartItems,prepareShareDraft:e.prepareShareDraft}}({simpleProduct:c,configurableProduct:u,quantityState:d,isOrderMultiple:p,multiSelections:h,bundleItemPriceData:f,configValidation:v,apiConfig:o,isQuickView:S,cannotSave:!("ready"===i&&r&&(null==r?void 0:r.isDesignValid())),isSaving:y,save:this.save,productConfig:g,cartItems:m,prepareShareDraft:function(){return e.prepareShareDraftWithUploads()}}),w={designer:r,sacConfig:a,sacConfigRevision:this._sacConfigRevision,apiConfig:o,sourceMappings:s,loadState:i,setDesigner:this.setDesigner,save:this.save,close:this.close,onShirtSwatchChange:this.handleSacShirtSwatchChange,onArtworkCountChange:this.handleSacArtworkCountChange,addToCartContext:b};return n.createElement(Vt,Se({},this.props,{sac:w}))},t}(n.Component),Gt.defaultProps={isOrderMultiple:!1,multiSelections:void 0,productAttributes:void 0,setSelections:void 0,productConfig:void 0},(0,a.injectProps)("sacRepository","appEventBus")((0,l.connectNotification)((0,s.connectCart)(Gt))))}}]); 2//# sourceMappingURL=91.bundle.660124f690fdf965e77e.js.map
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.