@shopkit/builder 0.1.4 → 0.1.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,2 +1,2 @@
1
1
  "use client";
2
- 'use strict';const _0x558574=_0x44a6;(function(_0x3b71ad,_0x39d90f){const _0x2f0fb3=_0x44a6,_0x4955e4=_0x3b71ad();while(!![]){try{const _0x55cc3c=parseInt(_0x2f0fb3(0x17c))/0x1+-parseInt(_0x2f0fb3(0x189))/0x2+parseInt(_0x2f0fb3(0x195))/0x3+-parseInt(_0x2f0fb3(0x1a6))/0x4+-parseInt(_0x2f0fb3(0x17b))/0x5*(parseInt(_0x2f0fb3(0x18e))/0x6)+-parseInt(_0x2f0fb3(0x1a5))/0x7+-parseInt(_0x2f0fb3(0x17e))/0x8*(-parseInt(_0x2f0fb3(0x199))/0x9);if(_0x55cc3c===_0x39d90f)break;else _0x4955e4['push'](_0x4955e4['shift']());}catch(_0x43d062){_0x4955e4['push'](_0x4955e4['shift']());}}}(_0x39ca,0xe583a));var react=require(_0x558574(0x1b3)),a={'mobile':{'max':0x2ff},'tablet':{'min':0x300,'max':0x3ff},'desktop':{'min':0x400,'max':0x780},'wide':{'min':0x781}},o=class{constructor(_0x177379=a){const _0xbe4620=_0x558574,_0x337d4f={'cPKFa':_0xbe4620(0x1b6),'AjLtQ':function(_0x397f68,_0x282e7f){return _0x397f68<_0x282e7f;}};this['mediaQueryListeners']=new Map(),this[_0xbe4620(0x1a3)]=_0x337d4f[_0xbe4620(0x1b4)],this[_0xbe4620(0x1ac)]=new Set(),this['boundHandler']=null,(this[_0xbe4620(0x1a2)]=_0x177379,_0x337d4f['AjLtQ'](typeof window,'u')&&(this[_0xbe4620(0x19a)](),this[_0xbe4620(0x1ba)]()));}[_0x558574(0x1b8)](){const _0xe5a962=_0x558574;return this[_0xe5a962(0x1a3)];}[_0x558574(0x18d)](){const _0x4f8f83=_0x558574;return this[_0x4f8f83(0x1a2)];}[_0x558574(0x188)](_0x1916ff){const _0x10aebf=_0x558574,_0x5bb617={'rfPam':function(_0x9b1df8,_0x514f6f){return _0x9b1df8!==_0x514f6f;},'EIyFf':function(_0x2c187c,_0x58048b){return _0x2c187c!==_0x58048b;}};let _0x4f5910=this[_0x10aebf(0x191)](_0x1916ff);if(!_0x4f5910)return'';let _0x51b084=[];return _0x5bb617['rfPam'](_0x4f5910[_0x10aebf(0x197)],void 0x0)&&_0x51b084['push']('(min-width:\x20'+_0x4f5910[_0x10aebf(0x197)]+_0x10aebf(0x1af)),_0x5bb617[_0x10aebf(0x1a0)](_0x4f5910['max'],void 0x0)&&_0x51b084['push'](_0x10aebf(0x18f)+_0x4f5910[_0x10aebf(0x196)]+'px)'),_0x51b084[_0x10aebf(0x19c)](_0x10aebf(0x1b7));}[_0x558574(0x191)](_0x393c98){const _0x4f278c=_0x558574,_0x5fa569={'LdfOE':function(_0x6ddad6,_0x1a7ccf){return _0x6ddad6 in _0x1a7ccf;},'CyqXU':function(_0x39a8a4,_0x83c44f){return _0x39a8a4 in _0x83c44f;}};return _0x5fa569[_0x4f278c(0x198)](_0x393c98,this[_0x4f278c(0x1a2)])?this['breakpoints'][_0x393c98]:this[_0x4f278c(0x1a2)][_0x4f278c(0x18b)]&&_0x5fa569[_0x4f278c(0x1b2)](_0x393c98,this[_0x4f278c(0x1a2)][_0x4f278c(0x18b)])?this[_0x4f278c(0x1a2)][_0x4f278c(0x18b)][_0x393c98]:null;}['setupMediaQueryListeners'](){const _0x2cc8cf=_0x558574,_0x376f21={'qrRVn':function(_0x3c7f7d,_0x52c197){return _0x3c7f7d===_0x52c197;},'koCIk':_0x2cc8cf(0x18b)};this[_0x2cc8cf(0x186)]=()=>this[_0x2cc8cf(0x1ba)](),Object['keys'](this['breakpoints'])['forEach'](_0x5ddd6f=>{const _0x3b1529=_0x2cc8cf;if(_0x376f21[_0x3b1529(0x193)](_0x5ddd6f,_0x376f21['koCIk']))return;let _0x385399=this[_0x3b1529(0x188)](_0x5ddd6f);if(_0x385399){let _0x3dae1c=window[_0x3b1529(0x1a4)](_0x385399);this[_0x3b1529(0x1b9)][_0x3b1529(0x1b5)](_0x5ddd6f,_0x3dae1c),_0x3dae1c[_0x3b1529(0x17d)](_0x3b1529(0x18c),this[_0x3b1529(0x186)]);}}),this['breakpoints'][_0x2cc8cf(0x18b)]&&Object[_0x2cc8cf(0x1a7)](this[_0x2cc8cf(0x1a2)]['custom'])[_0x2cc8cf(0x19b)](_0x3f72fb=>{const _0x380cae=_0x2cc8cf;let _0x427838=this[_0x380cae(0x188)](_0x3f72fb);if(_0x427838){let _0x3f67d2=window[_0x380cae(0x1a4)](_0x427838);this['mediaQueryListeners']['set'](_0x3f72fb,_0x3f67d2),_0x3f67d2[_0x380cae(0x17d)](_0x380cae(0x18c),this[_0x380cae(0x186)]);}});}[_0x558574(0x1ba)](){const _0x2a8e51=_0x558574,_0x434310={'vcKeX':_0x2a8e51(0x1b6),'fHtor':_0x2a8e51(0x18a),'TYHPb':function(_0x1ee6a4,_0x2f02fe){return _0x1ee6a4<=_0x2f02fe;},'ACQIb':'tablet','nKkqE':function(_0x5aa0fd,_0x566b0c){return _0x5aa0fd<=_0x566b0c;},'RnEgg':_0x2a8e51(0x183),'ehVNl':function(_0xe26418,_0x5978c1){return _0xe26418===_0x5978c1;},'QGEDN':function(_0x994689,_0x5cdfff){return _0x994689>=_0x5cdfff;}};let _0x3583ac=window[_0x2a8e51(0x181)],_0x456db3=_0x434310['vcKeX'];if(_0x3583ac<=this[_0x2a8e51(0x1a2)]['mobile'][_0x2a8e51(0x196)]?_0x456db3=_0x434310[_0x2a8e51(0x184)]:_0x3583ac>=this[_0x2a8e51(0x1a2)][_0x2a8e51(0x1a1)][_0x2a8e51(0x197)]&&_0x434310[_0x2a8e51(0x187)](_0x3583ac,this[_0x2a8e51(0x1a2)]['tablet'][_0x2a8e51(0x196)])?_0x456db3=_0x434310[_0x2a8e51(0x194)]:_0x3583ac>=this[_0x2a8e51(0x1a2)][_0x2a8e51(0x1b6)]['min']&&_0x434310[_0x2a8e51(0x180)](_0x3583ac,this[_0x2a8e51(0x1a2)][_0x2a8e51(0x1b6)]['max'])?_0x456db3=_0x434310[_0x2a8e51(0x17f)]:_0x3583ac>=this[_0x2a8e51(0x1a2)][_0x2a8e51(0x183)]['min']&&(_0x456db3=_0x434310[_0x2a8e51(0x1a9)]),this[_0x2a8e51(0x1a2)][_0x2a8e51(0x18b)]){for(let [_0x111b8c,_0x4ceae9]of Object[_0x2a8e51(0x1a8)](this[_0x2a8e51(0x1a2)][_0x2a8e51(0x18b)]))if((_0x434310[_0x2a8e51(0x19e)](_0x4ceae9[_0x2a8e51(0x197)],void 0x0)||_0x434310[_0x2a8e51(0x19d)](_0x3583ac,_0x4ceae9[_0x2a8e51(0x197)]))&&(_0x4ceae9['max']===void 0x0||_0x3583ac<=_0x4ceae9[_0x2a8e51(0x196)])){_0x456db3=_0x111b8c;break;}}_0x456db3!==this[_0x2a8e51(0x1a3)]&&(this[_0x2a8e51(0x1a3)]=_0x456db3,this['notifyListeners']());}[_0x558574(0x19f)](_0xcc2614){const _0x5bc8cb=_0x558574;return this[_0x5bc8cb(0x1ac)][_0x5bc8cb(0x185)](_0xcc2614),()=>this[_0x5bc8cb(0x1ac)][_0x5bc8cb(0x1ad)](_0xcc2614);}[_0x558574(0x182)](){const _0x303999=_0x558574;this['listeners'][_0x303999(0x19b)](_0x1f5bd5=>_0x1f5bd5(this['currentBreakpoint']));}['matches'](_0x4ad9fe){const _0x13cf53=_0x558574;let _0xcb870=this[_0x13cf53(0x1b9)][_0x13cf53(0x192)](_0x4ad9fe);return _0xcb870?_0xcb870[_0x13cf53(0x1ae)]:![];}[_0x558574(0x1aa)](){const _0x17ec1c=_0x558574,_0x18f458={'qNlwg':_0x17ec1c(0x18c)};this[_0x17ec1c(0x186)]&&(this[_0x17ec1c(0x1b9)][_0x17ec1c(0x19b)](_0x4db540=>{const _0x53b25c=_0x17ec1c;_0x4db540[_0x53b25c(0x1bb)](_0x18f458['qNlwg'],this['boundHandler']);}),this[_0x17ec1c(0x186)]=null),this['mediaQueryListeners'][_0x17ec1c(0x1ab)](),this[_0x17ec1c(0x1ac)][_0x17ec1c(0x1ab)]();}},s=null;function _0x39ca(){const _0x1e51c2=['qunrswi','mtCYmdu5nM9St0LsBa','Bwf4','BwLU','tgrMt0u','otGXodCZA0TyvLjf','C2v0DxbnzwrPyvf1zxj5tgLZDgvUzxjZ','zM9YrwfJAa','AM9PBG','uuDfre4','zwHwtMW','C3vIC2nYAwjL','ruL5rMy','DgfIBgv0','yNjLywTWB2LUDhm','y3vYCMvUDejYzwfRCg9PBNq','Bwf0y2HnzwrPyq','mti3odqZodb0q1PitNm','nZG5oti0vwP6s1rn','A2v5CW','zw50CMLLCW','uM5fz2C','zgvZDhjVEq','y2XLyxi','BgLZDgvUzxjZ','zgvSzxrL','Bwf0y2HLCW','ChGP','sxbTvuy','DxnLqNjLywTWB2LUDhm','q3LXwfu','CMvHy3q','y1blrMe','C2v0','zgvZA3rVCa','igfUzca','z2v0q3vYCMvUDejYzwfRCg9PBNq','BwvKAwfrDwvYEuXPC3rLBMvYCW','zgv0zwn0q3vYCMvUDejYzwfRCg9PBNq','CMvTB3zLrxzLBNrmAxn0zw5LCG','mZa4ndK4nvPHs2L2vG','mteXmta5nLrqtvHxDa','ywrKrxzLBNrmAxn0zw5LCG','mZq0yuT0v01r','DMnlzvG','BKTRCuu','Aw5UzxjxAwr0Aa','BM90Awz5tgLZDgvUzxjZ','D2LKzq','zKH0B3i','ywrK','yM91BMriyw5KBgvY','vfLiugi','z2v0twvKAwfrDwvYEq','mZeYmtC5nfvKt0HPEa','Bw9IAwXL','y3vZDg9T','y2HHBMDL','z2v0qNjLywTWB2LUDhm','mtH6swfZugO','kg1HEc13Awr0AdOG','DejXzwS','z2v0qNjLywTWB2LUDenVBMzPzW','z2v0','CxjsvM4'];_0x39ca=function(){return _0x1e51c2;};return _0x39ca();}function _0x44a6(_0x35e532,_0x3f051b){_0x35e532=_0x35e532-0x17b;const _0x39ca31=_0x39ca();let _0x44a632=_0x39ca31[_0x35e532];if(_0x44a6['CwVfsy']===undefined){var _0x591b82=function(_0x2a9c17){const _0x3b8e74='abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789+/=';let _0x378cc7='',_0x4dfca6='';for(let _0x323cba=0x0,_0x2caf2e,_0x4e8a0f,_0x34e6e4=0x0;_0x4e8a0f=_0x2a9c17['charAt'](_0x34e6e4++);~_0x4e8a0f&&(_0x2caf2e=_0x323cba%0x4?_0x2caf2e*0x40+_0x4e8a0f:_0x4e8a0f,_0x323cba++%0x4)?_0x378cc7+=String['fromCharCode'](0xff&_0x2caf2e>>(-0x2*_0x323cba&0x6)):0x0){_0x4e8a0f=_0x3b8e74['indexOf'](_0x4e8a0f);}for(let _0x3f42ba=0x0,_0x5930f8=_0x378cc7['length'];_0x3f42ba<_0x5930f8;_0x3f42ba++){_0x4dfca6+='%'+('00'+_0x378cc7['charCodeAt'](_0x3f42ba)['toString'](0x10))['slice'](-0x2);}return decodeURIComponent(_0x4dfca6);};_0x44a6['xNDxrg']=_0x591b82,_0x44a6['lerVTB']={},_0x44a6['CwVfsy']=!![];}const _0x228d3d=_0x39ca31[0x0],_0x46e391=_0x35e532+_0x228d3d,_0x1f7937=_0x44a6['lerVTB'][_0x46e391];return!_0x1f7937?(_0x44a632=_0x44a6['xNDxrg'](_0x44a632),_0x44a6['lerVTB'][_0x46e391]=_0x44a632):_0x44a632=_0x1f7937,_0x44a632;}function p(_0x1af968){return s||(s=new o(_0x1af968)),s;}function b(_0x60f5bf){const _0xee8cc2=_0x558574,_0x10d46d={'gtURM':'desktop','tBqek':_0xee8cc2(0x1a1),'IpmUF':function(_0x1a95b8,_0x14a040){return _0x1a95b8===_0x14a040;}};let [_0x415531,_0x54d94e]=react['useState'](_0x10d46d['gtURM']),_0x3ad42a=p(_0x60f5bf);return react['useEffect'](()=>(_0x54d94e(_0x3ad42a['getCurrentBreakpoint']()),_0x3ad42a[_0xee8cc2(0x19f)](_0xabe401=>{_0x54d94e(_0xabe401);})),[_0x60f5bf]),{'currentBreakpoint':_0x415531,'isMobile':_0x415531===_0xee8cc2(0x18a),'isTablet':_0x415531===_0x10d46d[_0xee8cc2(0x190)],'isDesktop':_0x415531===_0x10d46d['gtURM'],'isWide':_0x10d46d[_0xee8cc2(0x1b0)](_0x415531,'wide'),'matches':_0x51e104=>_0x3ad42a[_0xee8cc2(0x1ae)](_0x51e104)};}exports[_0x558574(0x1b1)]=b;
2
+ 'use strict';const _0x1c596f=_0x49fb;function _0x5003(){const _0x240df2=['y3vYCMvUDejYzwfRCg9PBNq','z2v0qNjLywTWB2LUDenVBMzPzW','C3vIC2nYAwjL','DxnLqNjLywTWB2LUDhm','AM9PBG','mtK4otqYowTssK50DG','mZqZnZm0meztBerfsa','wMDkEgS','zgvSzxrL','CMvHy3q','ywrKrxzLBNrmAxn0zw5LCG','zM9YrwfJAa','ywrK','ndmYmtG4ne5Zufrgsq','DwTyq0S','Bwf0y2HLCW','q1HXENi','BwLU','EKrIyMq','ChGP','y3vZDg9T','BwvKAwfrDwvYEuXPC3rLBMvYCW','BgLZDgvUzxjZ','mta2ndu3mw5PsuTAsW','s2zWCva','igfUzca','C2v0','zw50CMLLCW','Ahnsr0q','kg1HEc13Awr0AdOG','ngvctvj3CG','y2XLyxi','DgfIBgv0','z2v0q3vYCMvUDejYzwfRCg9PBNq','Bwf0y2HnzwrPyq','zgv0zwn0q3vYCMvUDejYzwfRCg9PBNq','BM90Awz5tgLZDgvUzxjZ','Bwf4','rgzQB3C','zgvZA3rVCa','yNjLywTWB2LUDhm','DxnLu3rHDgu','A2v5CW','zhLyANm','nJaZmZi4Dw5puw5T','zgvZDhjVEq','C2v0DxbnzwrPyvf1zxj5tgLZDgvUzxjZ','Bw9IAwXL','y2HHBMDL','ugHZueC','Bw5guw0','D2LKzq','mJG0nti0mg9KwM5hqG','z2v0twvKAwfrDwvYEq','ChvZAa','ntK3odq1CvzSBuHZ','Aw5UzxjxAwr0Aa','yM91BMriyw5KBgvY','uvDNs2W'];_0x5003=function(){return _0x240df2;};return _0x5003();}function _0x49fb(_0x1e0ab8,_0xa33f32){_0x1e0ab8=_0x1e0ab8-0x98;const _0x5003cb=_0x5003();let _0x49fb53=_0x5003cb[_0x1e0ab8];if(_0x49fb['bXfiph']===undefined){var _0x220e81=function(_0x4bef2a){const _0x3d9e8f='abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789+/=';let _0x598831='',_0x546c04='';for(let _0x599283=0x0,_0x35a03a,_0x2c7984,_0x1c3aa8=0x0;_0x2c7984=_0x4bef2a['charAt'](_0x1c3aa8++);~_0x2c7984&&(_0x35a03a=_0x599283%0x4?_0x35a03a*0x40+_0x2c7984:_0x2c7984,_0x599283++%0x4)?_0x598831+=String['fromCharCode'](0xff&_0x35a03a>>(-0x2*_0x599283&0x6)):0x0){_0x2c7984=_0x3d9e8f['indexOf'](_0x2c7984);}for(let _0x34a017=0x0,_0x315152=_0x598831['length'];_0x34a017<_0x315152;_0x34a017++){_0x546c04+='%'+('00'+_0x598831['charCodeAt'](_0x34a017)['toString'](0x10))['slice'](-0x2);}return decodeURIComponent(_0x546c04);};_0x49fb['plLpxD']=_0x220e81,_0x49fb['GphjwJ']={},_0x49fb['bXfiph']=!![];}const _0x2d2202=_0x5003cb[0x0],_0x117112=_0x1e0ab8+_0x2d2202,_0x4dd57f=_0x49fb['GphjwJ'][_0x117112];return!_0x4dd57f?(_0x49fb53=_0x49fb['plLpxD'](_0x49fb53),_0x49fb['GphjwJ'][_0x117112]=_0x49fb53):_0x49fb53=_0x4dd57f,_0x49fb53;}(function(_0x36b028,_0x491cee){const _0x5b8ca8=_0x49fb,_0x58d0d6=_0x36b028();while(!![]){try{const _0xdb2e95=-parseInt(_0x5b8ca8(0xc6))/0x1+parseInt(_0x5b8ca8(0xa0))/0x2+parseInt(_0x5b8ca8(0xb4))/0x3+-parseInt(_0x5b8ca8(0xcd))/0x4*(-parseInt(_0x5b8ca8(0xab))/0x5)+parseInt(_0x5b8ca8(0xb5))/0x6+parseInt(_0x5b8ca8(0xbc))/0x7+-parseInt(_0x5b8ca8(0xa8))/0x8;if(_0xdb2e95===_0x491cee)break;else _0x58d0d6['push'](_0x58d0d6['shift']());}catch(_0x28ea74){_0x58d0d6['push'](_0x58d0d6['shift']());}}}(_0x5003,0xd09b4));var react=require(_0x1c596f(0xb8)),a={'mobile':{'max':0x2ff},'tablet':{'min':0x300,'max':0x3ff},'desktop':{'min':0x400,'max':0x780},'wide':{'min':0x781}},o=class{constructor(_0x3f3622=a){const _0x4dd75d=_0x1c596f;this[_0x4dd75d(0xc4)]=new Map(),this['currentBreakpoint']=_0x4dd75d(0x9b),this['listeners']=new Set(),this['boundHandler']=null,(this[_0x4dd75d(0x9c)]=_0x3f3622,typeof window<'u'&&(this[_0x4dd75d(0xa2)](),this['detectCurrentBreakpoint']()));}[_0x1c596f(0xd0)](){const _0xbe9ef3=_0x1c596f;return this[_0xbe9ef3(0xaf)];}['getBreakpoints'](){return this['breakpoints'];}[_0x1c596f(0xa9)](_0x17e181){const _0x5db536=_0x1c596f,_0x21b51b={'KfpqP':function(_0x2a347b,_0x3b0f61){return _0x2a347b!==_0x3b0f61;},'ukXCK':_0x5db536(0xc8)};let _0x1c314b=this[_0x5db536(0xb0)](_0x17e181);if(!_0x1c314b)return'';let _0x197b5c=[];return _0x21b51b[_0x5db536(0xc7)](_0x1c314b[_0x5db536(0xc0)],void 0x0)&&_0x197b5c[_0x5db536(0xaa)]('(min-width:\x20'+_0x1c314b[_0x5db536(0xc0)]+_0x5db536(0xc2)),_0x21b51b[_0x5db536(0xc7)](_0x1c314b[_0x5db536(0x99)],void 0x0)&&_0x197b5c[_0x5db536(0xaa)](_0x5db536(0xcc)+_0x1c314b[_0x5db536(0x99)]+'px)'),_0x197b5c[_0x5db536(0xb3)](_0x21b51b[_0x5db536(0xbd)]);}[_0x1c596f(0xb0)](_0x345c95){const _0x3d1179=_0x1c596f;return _0x345c95 in this[_0x3d1179(0x9c)]?this[_0x3d1179(0x9c)][_0x345c95]:this[_0x3d1179(0x9c)]['custom']&&_0x345c95 in this[_0x3d1179(0x9c)][_0x3d1179(0xc3)]?this[_0x3d1179(0x9c)][_0x3d1179(0xc3)][_0x345c95]:null;}[_0x1c596f(0xa2)](){const _0x484225=_0x1c596f,_0x572aef={'mnFQm':function(_0x3d6914,_0x28c615){return _0x3d6914===_0x28c615;},'ZgJxk':'change'};this[_0x484225(0xad)]=()=>this[_0x484225(0xd2)](),Object[_0x484225(0x9e)](this['breakpoints'])[_0x484225(0xba)](_0x261bc3=>{const _0x80cf55=_0x484225;if(_0x572aef[_0x80cf55(0xa6)](_0x261bc3,'custom'))return;let _0x170bc6=this[_0x80cf55(0xa9)](_0x261bc3);if(_0x170bc6){let _0x56b3ee=window[_0x80cf55(0xd1)](_0x170bc6);this['mediaQueryListeners'][_0x80cf55(0xc9)](_0x261bc3,_0x56b3ee),_0x56b3ee[_0x80cf55(0xb9)](_0x572aef[_0x80cf55(0xb6)],this[_0x80cf55(0xad)]);}}),this[_0x484225(0x9c)][_0x484225(0xc3)]&&Object[_0x484225(0x9e)](this[_0x484225(0x9c)][_0x484225(0xc3)])[_0x484225(0xba)](_0x2ae464=>{const _0x4ee383=_0x484225;let _0x4e2812=this[_0x4ee383(0xa9)](_0x2ae464);if(_0x4e2812){let _0x4052ec=window[_0x4ee383(0xd1)](_0x4e2812);this['mediaQueryListeners'][_0x4ee383(0xc9)](_0x2ae464,_0x4052ec),_0x4052ec[_0x4ee383(0xb9)](_0x572aef[_0x4ee383(0xb6)],this[_0x4ee383(0xad)]);}});}[_0x1c596f(0xd2)](){const _0x460fa6=_0x1c596f,_0x13dffe={'CXqzr':function(_0x22688b,_0x2f684a){return _0x22688b>=_0x2f684a;},'Dfjow':function(_0x1c69f7,_0x5313b5){return _0x1c69f7<=_0x5313b5;},'zDbbd':_0x460fa6(0xcf),'PhsPG':_0x460fa6(0x9b),'QWgKl':function(_0x54bdfd,_0x51ad67){return _0x54bdfd>=_0x51ad67;},'XnuGP':_0x460fa6(0xa7),'dyXjs':function(_0x32afa8,_0x5c3566){return _0x32afa8===_0x5c3566;}};let _0x1b7755=window[_0x460fa6(0xac)],_0x5e12e1='desktop';if(_0x1b7755<=this['breakpoints'][_0x460fa6(0xa3)]['max']?_0x5e12e1=_0x460fa6(0xa3):_0x13dffe['CXqzr'](_0x1b7755,this[_0x460fa6(0x9c)][_0x460fa6(0xcf)][_0x460fa6(0xc0)])&&_0x13dffe[_0x460fa6(0x9a)](_0x1b7755,this[_0x460fa6(0x9c)][_0x460fa6(0xcf)][_0x460fa6(0x99)])?_0x5e12e1=_0x13dffe[_0x460fa6(0xc1)]:_0x13dffe[_0x460fa6(0xbf)](_0x1b7755,this[_0x460fa6(0x9c)][_0x460fa6(0x9b)][_0x460fa6(0xc0)])&&_0x1b7755<=this[_0x460fa6(0x9c)][_0x460fa6(0x9b)][_0x460fa6(0x99)]?_0x5e12e1=_0x13dffe[_0x460fa6(0xa5)]:_0x13dffe[_0x460fa6(0xae)](_0x1b7755,this[_0x460fa6(0x9c)][_0x460fa6(0xa7)][_0x460fa6(0xc0)])&&(_0x5e12e1=_0x13dffe['XnuGP']),this[_0x460fa6(0x9c)][_0x460fa6(0xc3)]){for(let [_0x38fa61,_0xb1785f]of Object[_0x460fa6(0xca)](this[_0x460fa6(0x9c)][_0x460fa6(0xc3)]))if((_0x13dffe[_0x460fa6(0x9f)](_0xb1785f[_0x460fa6(0xc0)],void 0x0)||_0x1b7755>=_0xb1785f[_0x460fa6(0xc0)])&&(_0xb1785f[_0x460fa6(0x99)]===void 0x0||_0x1b7755<=_0xb1785f[_0x460fa6(0x99)])){_0x5e12e1=_0x38fa61;break;}}_0x5e12e1!==this['currentBreakpoint']&&(this[_0x460fa6(0xaf)]=_0x5e12e1,this[_0x460fa6(0x98)]());}[_0x1c596f(0xb1)](_0x2ec1d0){const _0x37a4e3=_0x1c596f;return this[_0x37a4e3(0xc5)][_0x37a4e3(0xbb)](_0x2ec1d0),()=>this[_0x37a4e3(0xc5)][_0x37a4e3(0xb7)](_0x2ec1d0);}[_0x1c596f(0x98)](){const _0x1b0fd5=_0x1c596f;this[_0x1b0fd5(0xc5)]['forEach'](_0xc468d4=>_0xc468d4(this[_0x1b0fd5(0xaf)]));}[_0x1c596f(0xbe)](_0x2e3ab5){const _0x410ec7=_0x1c596f;let _0x557803=this[_0x410ec7(0xc4)]['get'](_0x2e3ab5);return _0x557803?_0x557803['matches']:![];}[_0x1c596f(0xa1)](){const _0xab17a3=_0x1c596f;this['boundHandler']&&(this[_0xab17a3(0xc4)][_0xab17a3(0xba)](_0x12541b=>{const _0x136174=_0xab17a3;_0x12541b['removeEventListener'](_0x136174(0xa4),this[_0x136174(0xad)]);}),this[_0xab17a3(0xad)]=null),this[_0xab17a3(0xc4)][_0xab17a3(0xce)](),this[_0xab17a3(0xc5)]['clear']();}},s=null;function p(_0x5a2789){return s||(s=new o(_0x5a2789)),s;}function b(_0x204d33){const _0x507731=_0x1c596f,_0x3186d9={'bQEvw':_0x507731(0x9b),'hsRGD':function(_0x2c7f8e,_0x13841e){return _0x2c7f8e===_0x13841e;},'pheAW':_0x507731(0xa7)};let [_0x577b10,_0x9833bc]=react[_0x507731(0x9d)](_0x3186d9['bQEvw']),_0x11798d=p(_0x204d33);return react['useEffect'](()=>(_0x9833bc(_0x11798d[_0x507731(0xd0)]()),_0x11798d['subscribe'](_0xb46db2=>{_0x9833bc(_0xb46db2);})),[_0x204d33]),{'currentBreakpoint':_0x577b10,'isMobile':_0x577b10===_0x507731(0xa3),'isTablet':_0x3186d9[_0x507731(0xcb)](_0x577b10,_0x507731(0xcf)),'isDesktop':_0x3186d9['hsRGD'](_0x577b10,_0x3186d9['bQEvw']),'isWide':_0x577b10===_0x3186d9['pheAW'],'matches':_0x460207=>_0x11798d['matches'](_0x460207)};}exports[_0x1c596f(0xb2)]=b;
@@ -1,2 +1,2 @@
1
1
  "use client";
2
- function _0x2825(){const _0x48a07e=['z2v0qNjLywTWB2LUDhm','DgfIBgv0','ywrKrxzLBNrmAxn0zw5LCG','yNjLywTWB2LUDhm','y3vYCMvUDejYzwfRCg9PBNq','BM90Awz5tgLZDgvUzxjZ','Bwf4','txP0tuS','BwLU','zgv0zwn0q3vYCMvUDejYzwfRCg9PBNq','mJyZmtbnDu9Lwha','zgvZA3rVCa','yM91BMriyw5KBgvY','z2v0twvKAwfrDwvYEq','uxvkEMm','AM9PBG','BgLZDgvUzxjZ','z2v0qNjLywTWB2LUDenVBMzPzW','mtDuvKHjz1u','C2v0DxbnzwrPyvf1zxj5tgLZDgvUzxjZ','nxjMv21pAG','igfUzca','y2XLyxi','BwvKAwfrDwvYEuXPC3rLBMvYCW','mtmZmJu5nhDPEejIsG','nJG4nJi2quXhrNjf','y3vZDg9T','AMPZrfm','u0TgAgi','z2v0','zgvZDhjVEq','C2v0','z2v0q3vYCMvUDejYzwfRCg9PBNq','zM9YrwfJAa','ndq1oda2zNHIt1fj','C3vIC2nYAwjL','ChvZAa','mtKZmZmYm0PPALj4qW','kg1HEc13Awr0AdOG','y2HHBMDL','Avbfuw8','otC0ody4qxvHChjX','uvvHquG','zgvSzxrL','Bwf0y2HLCW','Aw5UzxjxAwr0Aa','BwTRAhq','kg1PBI13Awr0AdOG','twLYr1y','ntu0nJK3mg5RDuLMra','vfHjz1i','EgrhzKu','Bw9IAwXL','ywrK','mtzwzfj5zxa','BfvzANu','Bwf0y2HnzwrPyq','ChGP','q1nTzgW','A2v5CW'];_0x2825=function(){return _0x48a07e;};return _0x2825();}const _0x5dc072=_0x1f00;(function(_0x4ce0cd,_0x428949){const _0x406f1e=_0x1f00,_0x3be5f4=_0x4ce0cd();while(!![]){try{const _0x488344=parseInt(_0x406f1e(0x17d))/0x1*(parseInt(_0x406f1e(0x175))/0x2)+parseInt(_0x406f1e(0x18d))/0x3+-parseInt(_0x406f1e(0x194))/0x4*(-parseInt(_0x406f1e(0x17f))/0x5)+parseInt(_0x406f1e(0x184))/0x6+parseInt(_0x406f1e(0x190))/0x7+parseInt(_0x406f1e(0x165))/0x8*(-parseInt(_0x406f1e(0x183))/0x9)+-parseInt(_0x406f1e(0x160))/0xa;if(_0x488344===_0x428949)break;else _0x3be5f4['push'](_0x3be5f4['shift']());}catch(_0x5a286b){_0x3be5f4['push'](_0x3be5f4['shift']());}}}(_0x2825,0x261b5));import{useState,useEffect}from'react';var a={'mobile':{'max':0x2ff},'tablet':{'min':0x300,'max':0x3ff},'desktop':{'min':0x400,'max':0x780},'wide':{'min':0x781}},o=class{constructor(_0xae4213=a){const _0x60454c=_0x1f00;this['mediaQueryListeners']=new Map(),this[_0x60454c(0x16f)]=_0x60454c(0x176),this['listeners']=new Set(),this['boundHandler']=null,(this[_0x60454c(0x16e)]=_0xae4213,typeof window<'u'&&(this[_0x60454c(0x17e)](),this[_0x60454c(0x174)]()));}[_0x5dc072(0x18b)](){const _0x38074c=_0x5dc072;return this[_0x38074c(0x16f)];}[_0x5dc072(0x16b)](){const _0x1762e4=_0x5dc072;return this[_0x1762e4(0x16e)];}['getMediaQuery'](_0x13282f){const _0x55a66b=_0x5dc072,_0x580f3b={'tREki':function(_0x474e8d,_0x50d41b){return _0x474e8d!==_0x50d41b;}};let _0xf5d025=this[_0x55a66b(0x17c)](_0x13282f);if(!_0xf5d025)return'';let _0x11fe1d=[];return _0x580f3b['tREki'](_0xf5d025['min'],void 0x0)&&_0x11fe1d[_0x55a66b(0x18f)](_0x55a66b(0x15e)+_0xf5d025[_0x55a66b(0x173)]+_0x55a66b(0x168)),_0xf5d025[_0x55a66b(0x171)]!==void 0x0&&_0x11fe1d[_0x55a66b(0x18f)](_0x55a66b(0x191)+_0xf5d025[_0x55a66b(0x171)]+_0x55a66b(0x168)),_0x11fe1d[_0x55a66b(0x17a)](_0x55a66b(0x180));}[_0x5dc072(0x17c)](_0x564016){const _0x37c5a0=_0x5dc072,_0x528dd0={'QUaAH':function(_0x3d0cad,_0x173796){return _0x3d0cad in _0x173796;}};return _0x564016 in this[_0x37c5a0(0x16e)]?this[_0x37c5a0(0x16e)][_0x564016]:this[_0x37c5a0(0x16e)][_0x37c5a0(0x185)]&&_0x528dd0[_0x37c5a0(0x195)](_0x564016,this[_0x37c5a0(0x16e)]['custom'])?this['breakpoints'][_0x37c5a0(0x185)][_0x564016]:null;}[_0x5dc072(0x17e)](){const _0x54389e=_0x5dc072,_0x30e92f={'oYrtl':function(_0x18a1a2,_0x3ae58e){return _0x18a1a2===_0x3ae58e;},'NkwYA':'custom'};this[_0x54389e(0x177)]=()=>this[_0x54389e(0x174)](),Object[_0x54389e(0x16a)](this['breakpoints'])[_0x54389e(0x18c)](_0x15b348=>{const _0x3402b2=_0x54389e;if(_0x30e92f['oYrtl'](_0x15b348,_0x30e92f['NkwYA']))return;let _0x1e390a=this[_0x3402b2(0x178)](_0x15b348);if(_0x1e390a){let _0x563ad8=window[_0x3402b2(0x167)](_0x1e390a);this[_0x3402b2(0x182)][_0x3402b2(0x18a)](_0x15b348,_0x563ad8),_0x563ad8[_0x3402b2(0x16d)](_0x3402b2(0x192),this[_0x3402b2(0x177)]);}}),this['breakpoints']['custom']&&Object[_0x54389e(0x16a)](this[_0x54389e(0x16e)][_0x54389e(0x185)])['forEach'](_0x23a1e8=>{const _0xb76879=_0x54389e;let _0x39081e=this['getMediaQuery'](_0x23a1e8);if(_0x39081e){let _0x834d5f=window['matchMedia'](_0x39081e);this[_0xb76879(0x182)][_0xb76879(0x18a)](_0x23a1e8,_0x834d5f),_0x834d5f[_0xb76879(0x16d)](_0xb76879(0x192),this[_0xb76879(0x177)]);}});}[_0x5dc072(0x174)](){const _0x107b52=_0x5dc072,_0x3bf866={'TXIgR':_0x107b52(0x176),'iPEQo':_0x107b52(0x163),'FgwdX':function(_0x3f05a5,_0x31067b){return _0x3f05a5<=_0x31067b;},'lUYju':'tablet','kDCKt':function(_0x4873df,_0x29a2d8){return _0x4873df>=_0x29a2d8;},'pCCqi':'wide','SKFhb':function(_0x48d3c7,_0x58c4e8){return _0x48d3c7>=_0x58c4e8;},'jjsDS':function(_0x53b8ad,_0xbb935c){return _0x53b8ad===_0xbb935c;}};let _0x457869=window[_0x107b52(0x198)],_0x3d23a5=_0x3bf866[_0x107b52(0x161)];if(_0x457869<=this['breakpoints'][_0x107b52(0x163)]['max']?_0x3d23a5=_0x3bf866[_0x107b52(0x193)]:_0x457869>=this['breakpoints'][_0x107b52(0x16c)][_0x107b52(0x173)]&&_0x3bf866['FgwdX'](_0x457869,this[_0x107b52(0x16e)][_0x107b52(0x16c)][_0x107b52(0x171)])?_0x3d23a5=_0x3bf866[_0x107b52(0x166)]:_0x457869>=this[_0x107b52(0x16e)][_0x107b52(0x176)][_0x107b52(0x173)]&&_0x457869<=this['breakpoints'][_0x107b52(0x176)][_0x107b52(0x171)]?_0x3d23a5='desktop':_0x3bf866['kDCKt'](_0x457869,this[_0x107b52(0x16e)]['wide'][_0x107b52(0x173)])&&(_0x3d23a5=_0x3bf866['pCCqi']),this[_0x107b52(0x16e)][_0x107b52(0x185)]){for(let [_0x36de42,_0x11fdec]of Object['entries'](this[_0x107b52(0x16e)][_0x107b52(0x185)]))if((_0x11fdec[_0x107b52(0x173)]===void 0x0||_0x3bf866[_0x107b52(0x187)](_0x457869,_0x11fdec[_0x107b52(0x173)]))&&(_0x3bf866[_0x107b52(0x186)](_0x11fdec['max'],void 0x0)||_0x457869<=_0x11fdec['max'])){_0x3d23a5=_0x36de42;break;}}_0x3d23a5!==this[_0x107b52(0x16f)]&&(this[_0x107b52(0x16f)]=_0x3d23a5,this[_0x107b52(0x170)]());}[_0x5dc072(0x18e)](_0x522969){const _0x417253=_0x5dc072;return this[_0x417253(0x17b)][_0x417253(0x164)](_0x522969),()=>this['listeners'][_0x417253(0x196)](_0x522969);}[_0x5dc072(0x170)](){const _0x561b06=_0x5dc072;this[_0x561b06(0x17b)][_0x561b06(0x18c)](_0x208eb2=>_0x208eb2(this[_0x561b06(0x16f)]));}[_0x5dc072(0x197)](_0x3334ec){const _0x16cb0e=_0x5dc072;let _0x2c14d1=this['mediaQueryListeners'][_0x16cb0e(0x188)](_0x3334ec);return _0x2c14d1?_0x2c14d1[_0x16cb0e(0x197)]:![];}[_0x5dc072(0x189)](){const _0xbfb40f=_0x5dc072;this[_0xbfb40f(0x177)]&&(this[_0xbfb40f(0x182)][_0xbfb40f(0x18c)](_0x51ce78=>{const _0x431f87=_0xbfb40f;_0x51ce78['removeEventListener'](_0x431f87(0x192),this[_0x431f87(0x177)]);}),this['boundHandler']=null),this[_0xbfb40f(0x182)][_0xbfb40f(0x181)](),this[_0xbfb40f(0x17b)][_0xbfb40f(0x181)]();}},s=null;function p(_0x29cb62){return s||(s=new o(_0x29cb62)),s;}function _0x1f00(_0x615923,_0x4a6c7a){_0x615923=_0x615923-0x15d;const _0x282504=_0x2825();let _0x1f001d=_0x282504[_0x615923];if(_0x1f00['dMBYZG']===undefined){var _0x3b7215=function(_0x4bc719){const _0x3c298d='abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789+/=';let _0x4e56f1='',_0x5cd9f4='';for(let _0x5cc939=0x0,_0x5a006e,_0x2258c6,_0x3c7183=0x0;_0x2258c6=_0x4bc719['charAt'](_0x3c7183++);~_0x2258c6&&(_0x5a006e=_0x5cc939%0x4?_0x5a006e*0x40+_0x2258c6:_0x2258c6,_0x5cc939++%0x4)?_0x4e56f1+=String['fromCharCode'](0xff&_0x5a006e>>(-0x2*_0x5cc939&0x6)):0x0){_0x2258c6=_0x3c298d['indexOf'](_0x2258c6);}for(let _0x1784bf=0x0,_0x3f9eee=_0x4e56f1['length'];_0x1784bf<_0x3f9eee;_0x1784bf++){_0x5cd9f4+='%'+('00'+_0x4e56f1['charCodeAt'](_0x1784bf)['toString'](0x10))['slice'](-0x2);}return decodeURIComponent(_0x5cd9f4);};_0x1f00['ckqiMo']=_0x3b7215,_0x1f00['dnVhRM']={},_0x1f00['dMBYZG']=!![];}const _0x5266af=_0x282504[0x0],_0x208071=_0x615923+_0x5266af,_0xafa9c3=_0x1f00['dnVhRM'][_0x208071];return!_0xafa9c3?(_0x1f001d=_0x1f00['ckqiMo'](_0x1f001d),_0x1f00['dnVhRM'][_0x208071]=_0x1f001d):_0x1f001d=_0xafa9c3,_0x1f001d;}function b(_0x45dc03){const _0x2fac6d=_0x5dc072,_0x1db01e={'mkkht':function(_0x4dc63a,_0x4de630){return _0x4dc63a(_0x4de630);},'pzdlf':function(_0x5c5150,_0x2615b9){return _0x5c5150(_0x2615b9);},'QuJzc':_0x2fac6d(0x176),'MztMK':function(_0x119a05,_0x3f4ca6){return _0x119a05(_0x3f4ca6);},'CSmdl':function(_0x542c9e,_0x2ce40b,_0x467581){return _0x542c9e(_0x2ce40b,_0x467581);},'MirGV':_0x2fac6d(0x16c),'xdGfE':function(_0x2bfc04,_0x5f4f19){return _0x2bfc04===_0x5f4f19;},'JEJRU':function(_0xa29c38,_0x18305e){return _0xa29c38===_0x18305e;}};let [_0x35ce10,_0xf7f0ef]=_0x1db01e['pzdlf'](useState,_0x1db01e[_0x2fac6d(0x179)]),_0x190ebe=_0x1db01e[_0x2fac6d(0x172)](p,_0x45dc03);return _0x1db01e[_0x2fac6d(0x169)](useEffect,()=>(_0xf7f0ef(_0x190ebe[_0x2fac6d(0x18b)]()),_0x190ebe['subscribe'](_0x38b420=>{const _0x4ded30=_0x2fac6d;_0x1db01e[_0x4ded30(0x15d)](_0xf7f0ef,_0x38b420);})),[_0x45dc03]),{'currentBreakpoint':_0x35ce10,'isMobile':_0x35ce10===_0x2fac6d(0x163),'isTablet':_0x35ce10===_0x1db01e[_0x2fac6d(0x15f)],'isDesktop':_0x1db01e[_0x2fac6d(0x162)](_0x35ce10,_0x2fac6d(0x176)),'isWide':_0x1db01e['JEJRU'](_0x35ce10,'wide'),'matches':_0x24b5c3=>_0x190ebe['matches'](_0x24b5c3)};}export{b as useBreakpoints};
2
+ const _0x35e2c0=_0x384a;(function(_0x21316d,_0xb1c7d7){const _0x4d4789=_0x384a,_0x67da43=_0x21316d();while(!![]){try{const _0x5da577=-parseInt(_0x4d4789(0xe7))/0x1*(-parseInt(_0x4d4789(0xd5))/0x2)+-parseInt(_0x4d4789(0xdc))/0x3*(parseInt(_0x4d4789(0xdd))/0x4)+parseInt(_0x4d4789(0xb7))/0x5+-parseInt(_0x4d4789(0xe5))/0x6*(-parseInt(_0x4d4789(0xbd))/0x7)+parseInt(_0x4d4789(0xc5))/0x8*(-parseInt(_0x4d4789(0xc7))/0x9)+-parseInt(_0x4d4789(0xd1))/0xa*(parseInt(_0x4d4789(0xaf))/0xb)+-parseInt(_0x4d4789(0xe0))/0xc*(-parseInt(_0x4d4789(0xb0))/0xd);if(_0x5da577===_0xb1c7d7)break;else _0x67da43['push'](_0x67da43['shift']());}catch(_0x4e5280){_0x67da43['push'](_0x67da43['shift']());}}}(_0x57d3,0xba882));import{useState,useEffect}from'react';function _0x57d3(){const _0x197e4b=['uejAvvG','z2v0q3vYCMvUDejYzwfRCg9PBNq','mJC1nJyYnxbkz0HvBa','z2v0qNjLywTWB2LUDhm','zgvZDhjVEq','z2v0','Aw5UzxjxAwr0Aa','BKzzBw8','mtu0qMfzDNbm','yLrTsge','zgvSzxrL','reTLuwy','Bw9IAwXL','y3vZDg9T','ywrK','zgv0zwn0q3vYCMvUDejYzwfRCg9PBNq','mtzgrvbosu4','yNjLywTWB2LUDhm','nJqWotK3mwPiv2LOuW','sgHeu2O','BwHMtwq','y2XLyxi','kg1PBI13Awr0AdOG','B3jIy0e','DgfIBgv0','zgvZA3rVCa','ChGP','BM90Awz5tgLZDgvUzxjZ','mti0nZG2mfzZtxPZsa','C3vIC2nYAwjL','y3vYCMvUDejYzwfRCg9PBNq','C2v0','mZGXmJznv2LrEM4','z2v0qNjLywTWB2LUDenVBMzPzW','yNbyAue','BwvKAwfrDwvYEuXPC3rLBMvYCW','BgLZDgvUzxjZ','Bwf4','zM9YrwfJAa','m1f3zuz0wG','nJa1odKXmKjdsw9JyW','uLb1Cu0','z2v0twvKAwfrDwvYEq','mZeWmtG4AgDys1Pn','ChvZAa','AM9PBG','BwLU','y2HHBMDL','mteZnZG0r05Auu5m','wMnhuxO','ndrcB21YBvO','igfUzca','D2LKzq','A2v5CW','C2v0DxbnzwrPyvf1zxj5tgLZDgvUzxjZ','kg1HEc13Awr0AdOG','wK9gv1G','CvvUCKm','mJjIBufjthi','mta3ovvcwgzfAa','CuveB1e','Bwf0y2HnzwrPyq','yM91BMriyw5KBgvY','ywrKrxzLBNrmAxn0zw5LCG'];_0x57d3=function(){return _0x197e4b;};return _0x57d3();}function _0x384a(_0x4684db,_0x12678d){_0x4684db=_0x4684db-0xaf;const _0x57d310=_0x57d3();let _0x384a05=_0x57d310[_0x4684db];if(_0x384a['NyhAVU']===undefined){var _0x3c5a58=function(_0x428dc9){const _0x5ad685='abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789+/=';let _0x44dee2='',_0x429f45='';for(let _0x10e486=0x0,_0x56f3ea,_0x378ce5,_0x33992b=0x0;_0x378ce5=_0x428dc9['charAt'](_0x33992b++);~_0x378ce5&&(_0x56f3ea=_0x10e486%0x4?_0x56f3ea*0x40+_0x378ce5:_0x378ce5,_0x10e486++%0x4)?_0x44dee2+=String['fromCharCode'](0xff&_0x56f3ea>>(-0x2*_0x10e486&0x6)):0x0){_0x378ce5=_0x5ad685['indexOf'](_0x378ce5);}for(let _0x4b5348=0x0,_0x2be14c=_0x44dee2['length'];_0x4b5348<_0x2be14c;_0x4b5348++){_0x429f45+='%'+('00'+_0x44dee2['charCodeAt'](_0x4b5348)['toString'](0x10))['slice'](-0x2);}return decodeURIComponent(_0x429f45);};_0x384a['gwzYJf']=_0x3c5a58,_0x384a['CqDbOC']={},_0x384a['NyhAVU']=!![];}const _0x2adf46=_0x57d310[0x0],_0x152e83=_0x4684db+_0x2adf46,_0x29d88d=_0x384a['CqDbOC'][_0x152e83];return!_0x29d88d?(_0x384a05=_0x384a['gwzYJf'](_0x384a05),_0x384a['CqDbOC'][_0x152e83]=_0x384a05):_0x384a05=_0x29d88d,_0x384a05;}var a={'mobile':{'max':0x2ff},'tablet':{'min':0x300,'max':0x3ff},'desktop':{'min':0x400,'max':0x780},'wide':{'min':0x781}},o=class{constructor(_0x53f6aa=a){const _0x3a2a16=_0x384a,_0x204e27={'orbcA':_0x3a2a16(0xce),'bpXiA':function(_0x486419,_0xcee48f){return _0x486419<_0xcee48f;}};this[_0x3a2a16(0xd8)]=new Map(),this[_0x3a2a16(0xd3)]=_0x204e27[_0x3a2a16(0xcc)],this[_0x3a2a16(0xd9)]=new Set(),this[_0x3a2a16(0xb3)]=null,(this['breakpoints']=_0x53f6aa,_0x204e27[_0x3a2a16(0xd7)](typeof window,'u')&&(this[_0x3a2a16(0xeb)](),this[_0x3a2a16(0xc4)]()));}['getCurrentBreakpoint'](){const _0x171a94=_0x384a;return this[_0x171a94(0xd3)];}[_0x35e2c0(0xb8)](){const _0x3ce893=_0x35e2c0;return this[_0x3ce893(0xc6)];}[_0x35e2c0(0xdf)](_0xca6901){const _0x463a55=_0x35e2c0,_0x15c901={'bTmHa':function(_0x315738,_0x4e2ab7){return _0x315738!==_0x4e2ab7;},'ZcGQz':_0x463a55(0xe8)};let _0x38749e=this[_0x463a55(0xd6)](_0xca6901);if(!_0x38749e)return'';let _0x420c2d=[];return _0x15c901[_0x463a55(0xbe)](_0x38749e[_0x463a55(0xe3)],void 0x0)&&_0x420c2d[_0x463a55(0xe1)](_0x463a55(0xcb)+_0x38749e[_0x463a55(0xe3)]+_0x463a55(0xcf)),_0x38749e[_0x463a55(0xda)]!==void 0x0&&_0x420c2d[_0x463a55(0xe1)](_0x463a55(0xec)+_0x38749e[_0x463a55(0xda)]+'px)'),_0x420c2d[_0x463a55(0xe2)](_0x15c901[_0x463a55(0xe6)]);}['getBreakpointConfig'](_0x1b7d43){const _0x215c65=_0x35e2c0;return _0x1b7d43 in this['breakpoints']?this[_0x215c65(0xc6)][_0x1b7d43]:this['breakpoints'][_0x215c65(0xc2)]&&_0x1b7d43 in this[_0x215c65(0xc6)][_0x215c65(0xc2)]?this[_0x215c65(0xc6)][_0x215c65(0xc2)][_0x1b7d43]:null;}['setupMediaQueryListeners'](){const _0x250654=_0x35e2c0,_0x3310e3={'hlWyg':_0x250654(0xe4)};this[_0x250654(0xb3)]=()=>this['detectCurrentBreakpoint'](),Object['keys'](this[_0x250654(0xc6)])['forEach'](_0x1c1b4f=>{const _0x4d38a7=_0x250654;if(_0x1c1b4f===_0x4d38a7(0xc2))return;let _0x514062=this[_0x4d38a7(0xdf)](_0x1c1b4f);if(_0x514062){let _0x1a133=window[_0x4d38a7(0xb2)](_0x514062);this[_0x4d38a7(0xd8)]['set'](_0x1c1b4f,_0x1a133),_0x1a133[_0x4d38a7(0xb4)](_0x4d38a7(0xe4),this[_0x4d38a7(0xb3)]);}}),this['breakpoints']['custom']&&Object[_0x250654(0xea)](this[_0x250654(0xc6)][_0x250654(0xc2)])[_0x250654(0xdb)](_0x5a832e=>{const _0x477884=_0x250654;let _0x3d4d5e=this[_0x477884(0xdf)](_0x5a832e);if(_0x3d4d5e){let _0x412dab=window[_0x477884(0xb2)](_0x3d4d5e);this[_0x477884(0xd8)][_0x477884(0xd4)](_0x5a832e,_0x412dab),_0x412dab[_0x477884(0xb4)](_0x3310e3['hlWyg'],this[_0x477884(0xb3)]);}});}[_0x35e2c0(0xc4)](){const _0x300e5c=_0x35e2c0,_0x38d34a={'DKeQf':_0x300e5c(0xce),'ZOFWX':_0x300e5c(0xc1),'qEDoQ':function(_0x4725d3,_0x4fe5f5){return _0x4725d3>=_0x4fe5f5;},'HhDSj':function(_0x1c240b,_0x2612fd){return _0x1c240b<=_0x2612fd;},'KlMLo':_0x300e5c(0xcd),'wmZaN':_0x300e5c(0xe9),'RPuqM':function(_0x3ef5ef,_0x546eb8){return _0x3ef5ef===_0x546eb8;},'EJygj':function(_0x2a7893,_0x44d757){return _0x2a7893!==_0x44d757;}};let _0x413db1=window[_0x300e5c(0xbb)],_0x1601f7=_0x38d34a[_0x300e5c(0xc0)];if(_0x413db1<=this[_0x300e5c(0xc6)][_0x300e5c(0xc1)][_0x300e5c(0xda)]?_0x1601f7=_0x38d34a[_0x300e5c(0xed)]:_0x38d34a[_0x300e5c(0xb1)](_0x413db1,this[_0x300e5c(0xc6)][_0x300e5c(0xcd)][_0x300e5c(0xe3)])&&_0x38d34a[_0x300e5c(0xc8)](_0x413db1,this[_0x300e5c(0xc6)]['tablet'][_0x300e5c(0xda)])?_0x1601f7=_0x38d34a['KlMLo']:_0x38d34a['qEDoQ'](_0x413db1,this[_0x300e5c(0xc6)]['desktop']['min'])&&_0x413db1<=this[_0x300e5c(0xc6)]['desktop'][_0x300e5c(0xda)]?_0x1601f7=_0x300e5c(0xce):_0x413db1>=this[_0x300e5c(0xc6)]['wide']['min']&&(_0x1601f7=_0x38d34a['wmZaN']),this['breakpoints'][_0x300e5c(0xc2)]){for(let [_0x157d1e,_0x2e4dea]of Object['entries'](this[_0x300e5c(0xc6)][_0x300e5c(0xc2)]))if((_0x2e4dea[_0x300e5c(0xe3)]===void 0x0||_0x413db1>=_0x2e4dea[_0x300e5c(0xe3)])&&(_0x38d34a[_0x300e5c(0xde)](_0x2e4dea['max'],void 0x0)||_0x38d34a[_0x300e5c(0xc8)](_0x413db1,_0x2e4dea[_0x300e5c(0xda)]))){_0x1601f7=_0x157d1e;break;}}_0x38d34a['EJygj'](_0x1601f7,this[_0x300e5c(0xd3)])&&(this[_0x300e5c(0xd3)]=_0x1601f7,this[_0x300e5c(0xd0)]());}[_0x35e2c0(0xd2)](_0x4472a5){const _0x2f407e=_0x35e2c0;return this['listeners'][_0x2f407e(0xc3)](_0x4472a5),()=>this[_0x2f407e(0xd9)][_0x2f407e(0xbf)](_0x4472a5);}[_0x35e2c0(0xd0)](){const _0x130cae=_0x35e2c0;this[_0x130cae(0xd9)][_0x130cae(0xdb)](_0x238e85=>_0x238e85(this[_0x130cae(0xd3)]));}['matches'](_0x538d0e){const _0x267a99=_0x35e2c0;let _0x2be7cf=this[_0x267a99(0xd8)][_0x267a99(0xba)](_0x538d0e);return _0x2be7cf?_0x2be7cf['matches']:![];}[_0x35e2c0(0xb9)](){const _0x47811c=_0x35e2c0;this[_0x47811c(0xb3)]&&(this[_0x47811c(0xd8)][_0x47811c(0xdb)](_0x351194=>{const _0x44814d=_0x47811c;_0x351194['removeEventListener'](_0x44814d(0xe4),this['boundHandler']);}),this[_0x47811c(0xb3)]=null),this['mediaQueryListeners'][_0x47811c(0xca)](),this['listeners'][_0x47811c(0xca)]();}},s=null;function p(_0x31fea1){return s||(s=new o(_0x31fea1)),s;}function b(_0x154c49){const _0x5b27b1=_0x35e2c0,_0x10fd48={'YDVpP':function(_0x5c8dd9,_0x1385cc){return _0x5c8dd9(_0x1385cc);},'PBZUX':function(_0x430118,_0x1c841b){return _0x430118(_0x1c841b);},'nFYmo':_0x5b27b1(0xce),'mhfMd':function(_0xd22f5a,_0x7326f7){return _0xd22f5a(_0x7326f7);},'qUnrC':_0x5b27b1(0xc1),'XxCZo':function(_0x24550c,_0x43a94b){return _0x24550c===_0x43a94b;}};let [_0x1ef90c,_0x481fe8]=_0x10fd48[_0x5b27b1(0xb5)](useState,_0x10fd48[_0x5b27b1(0xbc)]),_0x2231ea=_0x10fd48[_0x5b27b1(0xc9)](p,_0x154c49);return useEffect(()=>(_0x481fe8(_0x2231ea[_0x5b27b1(0xb6)]()),_0x2231ea[_0x5b27b1(0xd2)](_0x54d5ac=>{_0x10fd48['YDVpP'](_0x481fe8,_0x54d5ac);})),[_0x154c49]),{'currentBreakpoint':_0x1ef90c,'isMobile':_0x1ef90c===_0x10fd48[_0x5b27b1(0xee)],'isTablet':_0x1ef90c===_0x5b27b1(0xcd),'isDesktop':_0x1ef90c===_0x10fd48[_0x5b27b1(0xbc)],'isWide':_0x10fd48['XxCZo'](_0x1ef90c,'wide'),'matches':_0x57423a=>_0x2231ea['matches'](_0x57423a)};}export{b as useBreakpoints};
package/dist/index.d.mts CHANGED
@@ -776,6 +776,55 @@ interface RenderPageParams {
776
776
  */
777
777
  pageConfig?: PageConfig;
778
778
  }
779
+ /**
780
+ * Parameters for rendering layout chrome (header + footer).
781
+ */
782
+ interface RenderChromeParams {
783
+ /**
784
+ * Merchant identifier (theme folder name in this pipeline) - REQUIRED.
785
+ */
786
+ merchantName: string;
787
+ /**
788
+ * Locale for this render.
789
+ */
790
+ locale?: Locale;
791
+ /**
792
+ * Translation messages for i18n.
793
+ */
794
+ messages?: Record<string, any>;
795
+ /**
796
+ * Pre-loaded header config. When provided, it is used directly (skips
797
+ * resolution). REQUIRED in the visual editor, whose template loader is a
798
+ * stub that throws. Omit in production to resolve by template name.
799
+ */
800
+ headerConfig?: PageConfig;
801
+ /**
802
+ * Pre-loaded footer config. Same rules as headerConfig.
803
+ */
804
+ footerConfig?: PageConfig;
805
+ /**
806
+ * Template name for the header chrome. Default: "header".
807
+ */
808
+ headerTemplateName?: string;
809
+ /**
810
+ * Template name for the footer chrome. Default: "footer".
811
+ */
812
+ footerTemplateName?: string;
813
+ }
814
+ /**
815
+ * Rendered layout chrome. Either field is null if its template is absent or
816
+ * errored - a missing footer must never crash the page (graceful degradation).
817
+ */
818
+ interface ChromeResult {
819
+ header: React.ReactNode | null;
820
+ footer: React.ReactNode | null;
821
+ /**
822
+ * Distinct nav-menu handles referenced by the chrome widgets' `menuHandle`
823
+ * setting (derive-from-JSON). The layout passes these to `getNavMenus` so a
824
+ * handle the editor assigns is fetched automatically — no per-app handle list.
825
+ */
826
+ menuHandles: string[];
827
+ }
779
828
 
780
829
  /**
781
830
  * Page Builder Factory Function
@@ -836,6 +885,11 @@ interface PageBuilder {
836
885
  * Render a page to React nodes
837
886
  */
838
887
  renderPage(params: RenderPageParams): Promise<React.ReactNode>;
888
+ /**
889
+ * Render layout chrome (header + footer) so callers can place page content
890
+ * between them. Used by both production layout and the visual editor.
891
+ */
892
+ renderChrome(params: RenderChromeParams): Promise<ChromeResult>;
839
893
  /**
840
894
  * Clear internal caches
841
895
  */
@@ -1201,4 +1255,4 @@ declare function createSectionRendererFromComponent(Component: React.ComponentTy
1201
1255
  children: React.ReactNode[];
1202
1256
  }>): SectionRenderer;
1203
1257
 
1204
- export { ASPECT_RATIO_OPTIONS, type AspectRatioOption, type Breakpoint, type BreakpointConfig, CARD_STYLE_OPTIONS, type CardStyleOption, DATA_SOURCE_TYPES, DEFAULT_BREAKPOINTS, DEFAULT_LOCALE, type DataSourceConfig, type DataSourceType, DefaultSectionWrapper, type FileSystemPresetOptions, type ITemplateLoader, type IThemeLoader, type IWidgetRegistry, type Locale, type PageBuilder, type PageBuilderOptions, type PageConfig, PageConfigHelpers, type RenderPageParams, type ResponsiveSpacing, type RouteContext, SECTION_ALIGNMENT_OPTIONS, SECTION_LAYOUT_OPTIONS, SECTION_TYPES, type SectionAlignmentOption, type SectionConfig, type SectionLayoutOption, type SectionRegistry, type SectionRenderContext, type SectionRenderer, type SectionSchema, type SectionSettings, type SectionType, type Spacing, TEXT_ALIGNMENT_OPTIONS, type Template, type TemplateVariantRegistry, type TextAlignmentOption, type Theme, type ThemeConfig, type ThemeRole, type ValidationResult, type VariantRegistryResult, type WidgetConfig, type WidgetEntry, type WidgetProps, WidgetRegistry, type WidgetResponsiveConfig, type WidgetSchema, type WidgetSchemaRegistry, createDefaultSectionRenderer, createFileSystemPageBuilder, createPageBuilder, createSectionRendererFromComponent, getPageBuilder, resetPageBuilder };
1258
+ export { ASPECT_RATIO_OPTIONS, type AspectRatioOption, type Breakpoint, type BreakpointConfig, CARD_STYLE_OPTIONS, type CardStyleOption, type ChromeResult, DATA_SOURCE_TYPES, DEFAULT_BREAKPOINTS, DEFAULT_LOCALE, type DataSourceConfig, type DataSourceType, DefaultSectionWrapper, type FileSystemPresetOptions, type ITemplateLoader, type IThemeLoader, type IWidgetRegistry, type Locale, type PageBuilder, type PageBuilderOptions, type PageConfig, PageConfigHelpers, type RenderChromeParams, type RenderPageParams, type ResponsiveSpacing, type RouteContext, SECTION_ALIGNMENT_OPTIONS, SECTION_LAYOUT_OPTIONS, SECTION_TYPES, type SectionAlignmentOption, type SectionConfig, type SectionLayoutOption, type SectionRegistry, type SectionRenderContext, type SectionRenderer, type SectionSchema, type SectionSettings, type SectionType, type Spacing, TEXT_ALIGNMENT_OPTIONS, type Template, type TemplateVariantRegistry, type TextAlignmentOption, type Theme, type ThemeConfig, type ThemeRole, type ValidationResult, type VariantRegistryResult, type WidgetConfig, type WidgetEntry, type WidgetProps, WidgetRegistry, type WidgetResponsiveConfig, type WidgetSchema, type WidgetSchemaRegistry, createDefaultSectionRenderer, createFileSystemPageBuilder, createPageBuilder, createSectionRendererFromComponent, getPageBuilder, resetPageBuilder };
package/dist/index.d.ts CHANGED
@@ -776,6 +776,55 @@ interface RenderPageParams {
776
776
  */
777
777
  pageConfig?: PageConfig;
778
778
  }
779
+ /**
780
+ * Parameters for rendering layout chrome (header + footer).
781
+ */
782
+ interface RenderChromeParams {
783
+ /**
784
+ * Merchant identifier (theme folder name in this pipeline) - REQUIRED.
785
+ */
786
+ merchantName: string;
787
+ /**
788
+ * Locale for this render.
789
+ */
790
+ locale?: Locale;
791
+ /**
792
+ * Translation messages for i18n.
793
+ */
794
+ messages?: Record<string, any>;
795
+ /**
796
+ * Pre-loaded header config. When provided, it is used directly (skips
797
+ * resolution). REQUIRED in the visual editor, whose template loader is a
798
+ * stub that throws. Omit in production to resolve by template name.
799
+ */
800
+ headerConfig?: PageConfig;
801
+ /**
802
+ * Pre-loaded footer config. Same rules as headerConfig.
803
+ */
804
+ footerConfig?: PageConfig;
805
+ /**
806
+ * Template name for the header chrome. Default: "header".
807
+ */
808
+ headerTemplateName?: string;
809
+ /**
810
+ * Template name for the footer chrome. Default: "footer".
811
+ */
812
+ footerTemplateName?: string;
813
+ }
814
+ /**
815
+ * Rendered layout chrome. Either field is null if its template is absent or
816
+ * errored - a missing footer must never crash the page (graceful degradation).
817
+ */
818
+ interface ChromeResult {
819
+ header: React.ReactNode | null;
820
+ footer: React.ReactNode | null;
821
+ /**
822
+ * Distinct nav-menu handles referenced by the chrome widgets' `menuHandle`
823
+ * setting (derive-from-JSON). The layout passes these to `getNavMenus` so a
824
+ * handle the editor assigns is fetched automatically — no per-app handle list.
825
+ */
826
+ menuHandles: string[];
827
+ }
779
828
 
780
829
  /**
781
830
  * Page Builder Factory Function
@@ -836,6 +885,11 @@ interface PageBuilder {
836
885
  * Render a page to React nodes
837
886
  */
838
887
  renderPage(params: RenderPageParams): Promise<React.ReactNode>;
888
+ /**
889
+ * Render layout chrome (header + footer) so callers can place page content
890
+ * between them. Used by both production layout and the visual editor.
891
+ */
892
+ renderChrome(params: RenderChromeParams): Promise<ChromeResult>;
839
893
  /**
840
894
  * Clear internal caches
841
895
  */
@@ -1201,4 +1255,4 @@ declare function createSectionRendererFromComponent(Component: React.ComponentTy
1201
1255
  children: React.ReactNode[];
1202
1256
  }>): SectionRenderer;
1203
1257
 
1204
- export { ASPECT_RATIO_OPTIONS, type AspectRatioOption, type Breakpoint, type BreakpointConfig, CARD_STYLE_OPTIONS, type CardStyleOption, DATA_SOURCE_TYPES, DEFAULT_BREAKPOINTS, DEFAULT_LOCALE, type DataSourceConfig, type DataSourceType, DefaultSectionWrapper, type FileSystemPresetOptions, type ITemplateLoader, type IThemeLoader, type IWidgetRegistry, type Locale, type PageBuilder, type PageBuilderOptions, type PageConfig, PageConfigHelpers, type RenderPageParams, type ResponsiveSpacing, type RouteContext, SECTION_ALIGNMENT_OPTIONS, SECTION_LAYOUT_OPTIONS, SECTION_TYPES, type SectionAlignmentOption, type SectionConfig, type SectionLayoutOption, type SectionRegistry, type SectionRenderContext, type SectionRenderer, type SectionSchema, type SectionSettings, type SectionType, type Spacing, TEXT_ALIGNMENT_OPTIONS, type Template, type TemplateVariantRegistry, type TextAlignmentOption, type Theme, type ThemeConfig, type ThemeRole, type ValidationResult, type VariantRegistryResult, type WidgetConfig, type WidgetEntry, type WidgetProps, WidgetRegistry, type WidgetResponsiveConfig, type WidgetSchema, type WidgetSchemaRegistry, createDefaultSectionRenderer, createFileSystemPageBuilder, createPageBuilder, createSectionRendererFromComponent, getPageBuilder, resetPageBuilder };
1258
+ export { ASPECT_RATIO_OPTIONS, type AspectRatioOption, type Breakpoint, type BreakpointConfig, CARD_STYLE_OPTIONS, type CardStyleOption, type ChromeResult, DATA_SOURCE_TYPES, DEFAULT_BREAKPOINTS, DEFAULT_LOCALE, type DataSourceConfig, type DataSourceType, DefaultSectionWrapper, type FileSystemPresetOptions, type ITemplateLoader, type IThemeLoader, type IWidgetRegistry, type Locale, type PageBuilder, type PageBuilderOptions, type PageConfig, PageConfigHelpers, type RenderChromeParams, type RenderPageParams, type ResponsiveSpacing, type RouteContext, SECTION_ALIGNMENT_OPTIONS, SECTION_LAYOUT_OPTIONS, SECTION_TYPES, type SectionAlignmentOption, type SectionConfig, type SectionLayoutOption, type SectionRegistry, type SectionRenderContext, type SectionRenderer, type SectionSchema, type SectionSettings, type SectionType, type Spacing, TEXT_ALIGNMENT_OPTIONS, type Template, type TemplateVariantRegistry, type TextAlignmentOption, type Theme, type ThemeConfig, type ThemeRole, type ValidationResult, type VariantRegistryResult, type WidgetConfig, type WidgetEntry, type WidgetProps, WidgetRegistry, type WidgetResponsiveConfig, type WidgetSchema, type WidgetSchemaRegistry, createDefaultSectionRenderer, createFileSystemPageBuilder, createPageBuilder, createSectionRendererFromComponent, getPageBuilder, resetPageBuilder };
package/dist/index.js CHANGED
@@ -1,4 +1,4 @@
1
- 'use strict';var D=require('react'),jsxRuntime=require('react/jsx-runtime');function _interopDefault(e){return e&&e.__esModule?e:{default:e}}var D__default=/*#__PURE__*/_interopDefault(D);var v="en";var y=class{constructor(e="en",t={}){this.locale=e,this.messages=t;}getLocale(){return this.locale}getMessages(){return this.messages}translate(e,t){if(typeof e!="string")return String(e);if(!e.startsWith("t:"))return e;let r=e.slice(2),n=this.getNestedValue(this.messages,r);return n==null?r:typeof n!="string"?n:t?this.interpolate(n,t):n}translateRaw(e){if(typeof e!="string"||!e.startsWith("t:"))return e;let t=e.slice(2),r=this.getNestedValue(this.messages,t);return r!==void 0?r:e}translateObject(e,t){if(e==null)return e;if(typeof e=="string"){if(e.startsWith("t:")){let r=this.translateRaw(e);return typeof r!="string"?r:t?this.interpolate(r,t):r}return e}if(Array.isArray(e))return e.map(r=>this.translateObject(r,t));if(typeof e=="object"){let r={};for(let[n,i]of Object.entries(e))r[n]=this.translateObject(i,t);return r}return e}getNestedValue(e,t){if(!t||!e)return;let r=t.split("."),n=e;for(let i of r){if(n==null)return;n=n[i];}return n}interpolate(e,t){return e.replace(/\{(\w+)\}/g,(r,n)=>{let i=t[n];return i!==void 0?String(i):r})}};var g={PRODUCT:"PRODUCT",PRODUCTS:"PRODUCTS",PRODUCTS_BY_HANDLES:"PRODUCTS_BY_HANDLES",COLLECTION:"COLLECTION",COLLECTIONS:"COLLECTIONS",COLLECTION_BY_HANDLES:"COLLECTION_BY_HANDLES",COLLECTION_FILTERS:"COLLECTION_FILTERS",STATIC:"STATIC",FETCH_REQUEST:"FETCH_REQUEST",GRAPHQL_REQUEST:"GRAPHQL_REQUEST"};var R=class{constructor(e){this.commerceClient=e;}async fetchPageData(e){let{merchantName:t,pageConfig:r,routeContext:n}=e,i={merchantName:t},a=this.collectRequirements(r,n),s=await this.fetchAllData(a);return {...i,...s}}collectRequirements(e,t){let r=[];if(e.dataSources)for(let[n,i]of Object.entries(e.dataSources))r.push({type:i.type,params:{...i.params,...t.params},required:i.required||false,sourceId:n,options:i.options});return r}async fetchAllData(e){let t={};return await Promise.all(e.map(async r=>{try{let n=await this.fetchSingleRequirement(r);t[r.sourceId]=n;}catch(n){if(console.error(`Error fetching data for ${r.sourceId}:`,n),r.required)throw n;t[r.sourceId]=null;}})),t}async fetchSingleRequirement(e){let{type:t,params:r,options:n}=e;switch(t){case g.STATIC:return r;case g.PRODUCT:return this.commerceClient.getProduct(r,n);case g.PRODUCTS:return this.commerceClient.getProducts(r,n);case g.PRODUCTS_BY_HANDLES:return this.commerceClient.getProductsByHandles(r,n);case g.COLLECTION:return this.commerceClient.getCollection(r,n);case g.COLLECTIONS:return this.commerceClient.getCollections(r,n);case g.COLLECTION_BY_HANDLES:return this.commerceClient.getCollectionsByHandles(r,n);case g.COLLECTION_FILTERS:return this.commerceClient.getCollectionFilters(r,n);case g.FETCH_REQUEST:return this.commerceClient.fetchRequest(r);case g.GRAPHQL_REQUEST:return this.commerceClient.graphqlRequest(r);default:return console.warn(`Unknown data source type: ${t}`),null}}};var S=class{constructor(e){this.widgetRegistry=e;}createWidgets({pageConfig:e,pageData:t,routeContext:r,translationService:n}){let i={};for(let a of e.sections){if(!a.widgets?.length){console.warn(`Section ${a.id} has no widgets.`);continue}for(let s of a.widgets){let c=this.createSingleWidget(s,e,t,r,n);c&&(i[s.id]=c);}}return i}createSingleWidget(e,t,r,n,i){try{let a=this.widgetRegistry.get(e.type);if(!a)return console.error(`Widget type not found: ${e.type}`),console.error("Available widgets:",this.widgetRegistry.getRegisteredTypes()),null;let s=this.prepareWidgetData(e,t,r);if(s===null)return null;let c={key:e.id,id:e.id,data:s,settings:e.settings,routeContext:n};return i&&(c.locale=i.getLocale()),D__default.default.createElement(a,c)}catch(a){return console.error(`Error creating widget: ${e.id}`,a),null}}prepareWidgetData(e,t,r){if(!e.dataSourceKey)return {};let n=e.dataSourceKey,i=r[n];return (t.dataSources?.[n]?.required||false)&&!i?(console.error(`Required data not available for widget: ${e.id} (dataSourceKey: ${n})`),null):i||{}}};var C=class{constructor(e){this.renderSectionWrapper=e;}renderLayout({pageConfig:e,widgets:t,styles:r,routeContext:n,isEditing:i=false,onSelectSection:a,onSelectWidget:s}){return jsxRuntime.jsx("div",{className:"page-container",children:e.sections.map(c=>this.renderSection(c,t,r,i,a,s))})}renderSection(e,t,r,n=false,i,a){let s=e.widgets.map(d=>{let u=t[d.id];if(!u)return null;let f=D__default.default.cloneElement(u,{key:d.id,...d.responsive&&{responsive:d.responsive}});return n?jsxRuntime.jsxs("div",{className:"relative",style:{overflow:"visible"},children:[jsxRuntime.jsx("div",{className:"absolute inset-0 pointer-events-auto rounded cursor-pointer","data-widget-id":d.id,style:{zIndex:1e4,border:"2px solid transparent",transition:"border-color 0.2s",borderRadius:"0.375rem"},onClick:p=>{p.preventDefault(),p.stopPropagation(),a&&a(e.id,d.id);},onMouseEnter:p=>{p.currentTarget.style.borderColor="#EF4444";},onMouseLeave:p=>{p.currentTarget.style.borderColor="transparent";}}),f]},d.id):f}).filter(Boolean),c=this.renderSectionWrapper(e,s,r);return n?jsxRuntime.jsxs("div",{className:"relative",style:{overflow:"visible"},children:[jsxRuntime.jsx("div",{className:"absolute inset-0 pointer-events-auto rounded-md cursor-pointer","data-section-id":e.id}),c]},e.id):c}};var h=class{constructor(e){this.themeLoader=e;}async processStyles({merchantName:e,pageConfig:t}){try{return {...(await this.themeLoader.loadTheme(e)).config,...t.theme}}catch(r){throw console.error(`Error processing styles for merchant ${e}:`,r),new Error(`Failed to process styles for merchant ${e}: ${r instanceof Error?r.message:"Unknown error"}`)}}};var T=new Map,P=class{constructor(e){this.templateLoader=e;}async resolveTemplate({merchantName:e,routeContext:t,variant:r}){if(!e)throw new Error("Merchant name is required");let{templateName:n,apiData:i}=t||{};if(!n)throw new Error("Template name is required in the route context");let a=r||(i?await this.determineVariant(e,n,i):"default"),s=`${e}-${n}-${a}`;if(T.has(s))return T.get(s);let c;try{c=await this.loadMerchantTemplate(e,n,a),this.validateTemplate(c)&&T.set(s,c);}catch(d){throw console.error(`Error loading merchant template for ${e}/${n}:`,d),new Error(`Unable to load template for ${e}/${n}. Make sure the template exists.`)}if(!this.validateTemplate(c))throw new Error(`Invalid template configuration for ${e}/${n}`);return c}async loadMerchantTemplate(e,t,r="default"){try{let n=await this.templateLoader.loadTemplate(e,t,r);if(!n)throw new Error(`Template not returned for ${e}/${t}/${r}`);return n}catch(n){if(r!=="default")return console.warn(`Template variant "${r}" not found for ${e}/${t}, falling back to default`),this.loadMerchantTemplate(e,t,"default");throw console.error(`Error loading template ${e}/${t}/${r}:`,n),n}}validateTemplate(e){if(!e.id||!e.sections)return console.error("Template validation failed: Missing required fields (id, or sections)"),false;if(!Array.isArray(e.sections)||e.sections.length===0)return console.error("Template validation failed: Sections must be a non-empty array"),false;for(let t of e.sections){if(!t.id||!t.widgets||!Array.isArray(t.widgets))return console.error("Template validation failed: Each section must have id and widgets array"),console.error("Section structure:",{id:t.id,hasWidgets:!!t.widgets,isArray:Array.isArray(t.widgets)}),false;if(!t.name||!t.type)return console.error("Template validation failed: Each section must have name and type"),console.error("Section:",{id:t.id,name:t.name,type:t.type}),false;if(!t.settings)return console.error("Template validation failed: Each section must have settings"),console.error("Section:",{id:t.id,hasSettings:!!t.settings}),false;for(let r of t.widgets){if(!r.id||!r.type||!r.name)return console.error("Template validation failed: Each widget must have id, type, and name"),console.error("Widget:",{id:r.id,type:r.type,name:r.name}),false;if(!r.settings)return console.error("Template validation failed: Each widget must have settings"),console.error("Widget:",{id:r.id,hasSettings:!!r.settings}),false}}return true}clearCache(){T.clear();}async determineVariant(e,t,r){try{if(!this.templateLoader.loadVariantRegistry)return "default";let n=await this.templateLoader.loadVariantRegistry(e);if(!n||!n.variantRegistry)return "default";let i=n.variantRegistry[t];if(!i)return "default";let{apiField:a,variantMap:s,defaultVariant:c}=i,d=this.getNestedValue(r,a);return d&&s&&s[d]?s[d]:c||"default"}catch(n){return console.warn(`Failed to load variant registry for template type ${t}:`,n),"default"}}getNestedValue(e,t){return t.split(".").reduce((r,n)=>r&&r[n]!==void 0?r[n]:void 0,e)}};function B(o,e="desktop"){let n=o.settings.responsive?.[e]||{padding:o.settings.padding||{top:0,right:0,bottom:0,left:0},margin:o.settings.margin},i=n.padding?`${n.padding.top}px ${n.padding.right}px ${n.padding.bottom}px ${n.padding.left}px`:"0",a=n.margin?`${n.margin.top}px ${n.margin.right}px ${n.margin.bottom}px ${n.margin.left}px`:void 0;return {padding:i,margin:a}}function l(o,e,t){let{styles:r,breakpoint:n="desktop"}=t,{layout:i}=o.settings,a=B(o,n),s={width:"100%",padding:a.padding,...a.margin&&{margin:a.margin},...i==="page"&&{maxWidth:r?.spacing?.container||"1280px",marginLeft:"auto",marginRight:"auto"}};return D__default.default.createElement("section",{key:o.id,"data-section-id":o.id,"data-section-type":o.type,"data-breakpoint":n,style:s},e)}function F(){return l}var I=class{constructor(e){let{commerceClient:t,themeLoader:r,templateLoader:n,widgetRegistry:i,sectionRenderer:a,defaultLocale:s="en"}=e;this.templateResolver=new P(n),this.dataFetcher=new R(t),this.widgetFactory=new S(i),this.styleProcessor=new h(r),this.sectionRenderer=a||l,this.defaultLocale=s;}createLayoutRenderer(e){let t=this.sectionRenderer,r=(n,i,a)=>t(n,i,{styles:a,routeContext:e,breakpoint:"desktop"});return new C(r)}async renderPage({merchantName:e,pageConfig:t,routeContext:r,locale:n,messages:i}){let a=n||this.defaultLocale,s=new y(a,i||{}),c=t||await this.templateResolver.resolveTemplate({merchantName:e,routeContext:r}),d=this.translatePageConfig(c,s),u=await this.dataFetcher.fetchPageData({merchantName:e,pageConfig:d,routeContext:r}),f=await this.styleProcessor.processStyles({merchantName:e,pageConfig:d}),p=this.widgetFactory.createWidgets({pageConfig:d,pageData:u,routeContext:r,translationService:s});return this.createLayoutRenderer(r).renderLayout({pageConfig:d,widgets:p,styles:f,routeContext:r})}clearCache(){this.templateResolver.clearCache();}validateConfig(e){let t=[];return e.id||t.push("Page config must have an id"),(!e.sections||!Array.isArray(e.sections))&&t.push("Page config must have a sections array"),(!e.dataSources||typeof e.dataSources!="object")&&t.push("Page config must have a dataSources object"),e.sections?.forEach((r,n)=>{r.id||t.push(`Section at index ${n} must have an id`),(!r.widgets||!Array.isArray(r.widgets))&&t.push(`Section "${r.id}" must have a widgets array`),r.widgets?.forEach((i,a)=>{i.id||t.push(`Widget at section "${r.id}" index ${a} must have an id`),i.type||t.push(`Widget "${i.id}" must have a type`);});}),{valid:t.length===0,errors:t}}translatePageConfig(e,t){return {...e,sections:e.sections.map(r=>({...r,widgets:r.widgets.map(n=>({...n,settings:t.translateObject(n.settings||{})}))}))}}};function x(o){if(!o.commerceClient)throw new Error("commerceClient is required");if(!o.themeLoader)throw new Error("themeLoader is required");if(!o.templateLoader)throw new Error("templateLoader is required");if(!o.widgetRegistry)throw new Error("widgetRegistry is required");let e=new I({commerceClient:o.commerceClient,themeLoader:o.themeLoader,templateLoader:o.templateLoader,widgetRegistry:o.widgetRegistry,sectionRenderer:o.sectionRenderer,defaultLocale:o.defaultLocale});return {renderPage:t=>e.renderPage(t),clearCache:()=>e.clearCache(),validateConfig:t=>e.validateConfig(t)}}var m=class{constructor(){this.widgets=new Map;}register(e,t){if(!e){console.warn("WidgetRegistry: Cannot register widget with empty type");return}this.widgets.set(e,t);}registerAll(e){for(let{type:t,component:r}of e)this.register(t,r);}get(e){return this.widgets.get(e)}has(e){return this.widgets.has(e)}getRegisteredTypes(){return Array.from(this.widgets.keys())}clear(){this.widgets.clear();}get size(){return this.widgets.size}};var O=class{static getUsedDataSources(e){let t=new Set;for(let r of e.sections)for(let n of r.widgets)n.dataSourceKey&&t.add(n.dataSourceKey);return Array.from(t)}static findWidget(e,t){for(let r of e.sections){let n=r.widgets.find(i=>i.id===t);if(n)return n}return null}static findSection(e,t){return e.sections.find(r=>r.id===t)||null}static generateId(e){return `${e}-${Date.now()}-${Math.random().toString(36).substr(2,9)}`}static validate(e){let t=[];return e.id||t.push("Page config must have an id"),(!e.sections||!Array.isArray(e.sections))&&t.push("Page config must have a sections array"),(!e.dataSources||typeof e.dataSources!="object")&&t.push("Page config must have a dataSources object"),e.sections?.forEach((r,n)=>{r.id||t.push(`Section at index ${n} must have an id`),(!r.widgets||!Array.isArray(r.widgets))&&t.push(`Section "${r.id}" must have a widgets array`),r.widgets?.forEach((i,a)=>{i.id||t.push(`Widget at section "${r.id}" index ${a} must have an id`),i.type||t.push(`Widget "${i.id}" must have a type`);});}),{valid:t.length===0,errors:t}}};var $={HEADER_SECTION:"HEADER_SECTION",GRID_SECTION:"GRID_SECTION",HERO_SECTION:"HERO_SECTION",CONTENT_SECTION:"CONTENT_SECTION",FOOTER_SECTION:"FOOTER_SECTION"},k={PAGE:"page",FULL:"full"},M={LEFT:"left",CENTER:"center",RIGHT:"right"},U={SQUARE:"1:1",STANDARD:"4:3",CLASSIC:"3:2",WIDE:"16:9"},H={LEFT:"left",CENTER:"center",RIGHT:"right"},Y={STANDARD:"standard",COMPACT:"compact",MINIMAL:"minimal"};var V={mobile:{max:767},tablet:{min:768,max:1023},desktop:{min:1024,max:1920},wide:{min:1921}};var E=null;function Q(o){let e=[];if((!o.widgets||!Array.isArray(o.widgets))&&e.push("widgets (array of { type, component })"),o.commerceClient||e.push("commerceClient (ICommerceClient)"),o.themeLoader||e.push("themeLoader (IThemeLoader)"),o.templateLoader||e.push("templateLoader (ITemplateLoader)"),e.length>0)throw new Error(`[PageBuilder] Missing required options:
1
+ 'use strict';var b=require('react'),jsxRuntime=require('react/jsx-runtime');function _interopDefault(e){return e&&e.__esModule?e:{default:e}}var b__default=/*#__PURE__*/_interopDefault(b);var x="en";var R=class{constructor(e="en",t={}){this.locale=e,this.messages=t;}getLocale(){return this.locale}getMessages(){return this.messages}translate(e,t){if(typeof e!="string")return String(e);if(!e.startsWith("t:"))return e;let r=e.slice(2),n=this.getNestedValue(this.messages,r);return n==null?r:typeof n!="string"?n:t?this.interpolate(n,t):n}translateRaw(e){if(typeof e!="string"||!e.startsWith("t:"))return e;let t=e.slice(2),r=this.getNestedValue(this.messages,t);return r!==void 0?r:e}translateObject(e,t){if(e==null)return e;if(typeof e=="string"){if(e.startsWith("t:")){let r=this.translateRaw(e);return typeof r!="string"?r:t?this.interpolate(r,t):r}return e}if(Array.isArray(e))return e.map(r=>this.translateObject(r,t));if(typeof e=="object"){let r={};for(let[n,o]of Object.entries(e))r[n]=this.translateObject(o,t);return r}return e}getNestedValue(e,t){if(!t||!e)return;let r=t.split("."),n=e;for(let o of r){if(n==null)return;n=n[o];}return n}interpolate(e,t){return e.replace(/\{(\w+)\}/g,(r,n)=>{let o=t[n];return o!==void 0?String(o):r})}};var g={PRODUCT:"PRODUCT",PRODUCTS:"PRODUCTS",PRODUCTS_BY_HANDLES:"PRODUCTS_BY_HANDLES",COLLECTION:"COLLECTION",COLLECTIONS:"COLLECTIONS",COLLECTION_BY_HANDLES:"COLLECTION_BY_HANDLES",COLLECTION_FILTERS:"COLLECTION_FILTERS",STATIC:"STATIC",FETCH_REQUEST:"FETCH_REQUEST",GRAPHQL_REQUEST:"GRAPHQL_REQUEST"};var C=class{constructor(e){this.commerceClient=e;}async fetchPageData(e){let{merchantName:t,pageConfig:r,routeContext:n}=e,o={merchantName:t},a=this.collectRequirements(r,n),s=await this.fetchAllData(a);return {...o,...s}}collectRequirements(e,t){let r=[];if(e.dataSources)for(let[n,o]of Object.entries(e.dataSources))r.push({type:o.type,params:{...o.params,...t.params},required:o.required||false,sourceId:n,options:o.options});return r}async fetchAllData(e){let t={};return await Promise.all(e.map(async r=>{try{let n=await this.fetchSingleRequirement(r);t[r.sourceId]=n;}catch(n){if(console.error(`Error fetching data for ${r.sourceId}:`,n),r.required)throw n;t[r.sourceId]=null;}})),t}async fetchSingleRequirement(e){let{type:t,params:r,options:n}=e;switch(t){case g.STATIC:return r;case g.PRODUCT:return this.commerceClient.getProduct(r,n);case g.PRODUCTS:return this.commerceClient.getProducts(r,n);case g.PRODUCTS_BY_HANDLES:return this.commerceClient.getProductsByHandles(r,n);case g.COLLECTION:return this.commerceClient.getCollection(r,n);case g.COLLECTIONS:return this.commerceClient.getCollections(r,n);case g.COLLECTION_BY_HANDLES:return this.commerceClient.getCollectionsByHandles(r,n);case g.COLLECTION_FILTERS:return this.commerceClient.getCollectionFilters(r,n);case g.FETCH_REQUEST:return this.commerceClient.fetchRequest(r);case g.GRAPHQL_REQUEST:return this.commerceClient.graphqlRequest(r);default:return console.warn(`Unknown data source type: ${t}`),null}}};var h=class{constructor(e){this.widgetRegistry=e;}createWidgets({pageConfig:e,pageData:t,routeContext:r,translationService:n}){let o={};for(let a of e.sections){if(!a.widgets?.length){console.warn(`Section ${a.id} has no widgets.`);continue}for(let s of a.widgets){let c=this.createSingleWidget(s,e,t,r,n);c&&(o[s.id]=c);}}return o}createSingleWidget(e,t,r,n,o){try{let a=this.widgetRegistry.get(e.type);if(!a)return console.error(`Widget type not found: ${e.type}`),console.error("Available widgets:",this.widgetRegistry.getRegisteredTypes()),null;let s=this.prepareWidgetData(e,t,r);if(s===null)return null;let c={key:e.id,id:e.id,data:s,settings:e.settings,routeContext:n};return o&&(c.locale=o.getLocale()),b__default.default.createElement(a,c)}catch(a){return console.error(`Error creating widget: ${e.id}`,a),null}}prepareWidgetData(e,t,r){if(!e.dataSourceKey)return {};let n=e.dataSourceKey,o=r[n];return (t.dataSources?.[n]?.required||false)&&!o?(console.error(`Required data not available for widget: ${e.id} (dataSourceKey: ${n})`),null):o||{}}};var T=class{constructor(e){this.renderSectionWrapper=e;}renderLayout({pageConfig:e,widgets:t,styles:r,routeContext:n,isEditing:o=false,onSelectSection:a,onSelectWidget:s}){return jsxRuntime.jsx("div",{className:"page-container",children:e.sections.map(c=>jsxRuntime.jsx(b__default.default.Fragment,{children:this.renderSection(c,t,r,o,a,s)},c.id))})}renderSection(e,t,r,n=false,o,a){let s=e.widgets.map(d=>{let p=t[d.id];if(!p)return null;let m=b__default.default.cloneElement(p,{key:d.id,...d.responsive&&{responsive:d.responsive}});return n?jsxRuntime.jsxs("div",{className:"relative",style:{overflow:"visible"},children:[jsxRuntime.jsx("div",{className:"absolute inset-0 pointer-events-auto rounded cursor-pointer","data-widget-id":d.id,style:{zIndex:1e4,border:"2px solid transparent",transition:"border-color 0.2s",borderRadius:"0.375rem"},onClick:l=>{l.preventDefault(),l.stopPropagation(),a&&a(e.id,d.id);},onMouseEnter:l=>{l.currentTarget.style.borderColor="#EF4444";},onMouseLeave:l=>{l.currentTarget.style.borderColor="transparent";}}),m]},d.id):m}).filter(Boolean),c=this.renderSectionWrapper(e,s,r);return n?jsxRuntime.jsxs("div",{className:"relative",style:{overflow:"visible"},children:[jsxRuntime.jsx("div",{className:"absolute inset-0 pointer-events-auto rounded-md cursor-pointer","data-section-id":e.id}),c]},e.id):c}};var P=class{constructor(e){this.themeLoader=e;}async processStyles({merchantName:e,pageConfig:t}){try{return {...(await this.themeLoader.loadTheme(e)).config,...t.theme}}catch(r){throw console.error(`Error processing styles for merchant ${e}:`,r),new Error(`Failed to process styles for merchant ${e}: ${r instanceof Error?r.message:"Unknown error"}`)}}};var I=new Map,v=class{constructor(e){this.templateLoader=e;}async resolveTemplate({merchantName:e,routeContext:t,variant:r}){if(!e)throw new Error("Merchant name is required");let{templateName:n,apiData:o}=t||{};if(!n)throw new Error("Template name is required in the route context");let a=r||(o?await this.determineVariant(e,n,o):"default"),s=`${e}-${n}-${a}`;if(I.has(s))return I.get(s);let c;try{c=await this.loadMerchantTemplate(e,n,a),this.validateTemplate(c)&&I.set(s,c);}catch(d){throw console.error(`Error loading merchant template for ${e}/${n}:`,d),new Error(`Unable to load template for ${e}/${n}. Make sure the template exists.`)}if(!this.validateTemplate(c))throw new Error(`Invalid template configuration for ${e}/${n}`);return c}async loadMerchantTemplate(e,t,r="default"){try{let n=await this.templateLoader.loadTemplate(e,t,r);if(!n)throw new Error(`Template not returned for ${e}/${t}/${r}`);return n}catch(n){if(r!=="default")return console.warn(`Template variant "${r}" not found for ${e}/${t}, falling back to default`),this.loadMerchantTemplate(e,t,"default");throw console.error(`Error loading template ${e}/${t}/${r}:`,n),n}}validateTemplate(e){if(!e.id||!e.sections)return console.error("Template validation failed: Missing required fields (id, or sections)"),false;if(!Array.isArray(e.sections)||e.sections.length===0)return console.error("Template validation failed: Sections must be a non-empty array"),false;for(let t of e.sections){if(!t.id||!t.widgets||!Array.isArray(t.widgets))return console.error("Template validation failed: Each section must have id and widgets array"),console.error("Section structure:",{id:t.id,hasWidgets:!!t.widgets,isArray:Array.isArray(t.widgets)}),false;if(!t.name||!t.type)return console.error("Template validation failed: Each section must have name and type"),console.error("Section:",{id:t.id,name:t.name,type:t.type}),false;if(!t.settings)return console.error("Template validation failed: Each section must have settings"),console.error("Section:",{id:t.id,hasSettings:!!t.settings}),false;for(let r of t.widgets){if(!r.id||!r.type||!r.name)return console.error("Template validation failed: Each widget must have id, type, and name"),console.error("Widget:",{id:r.id,type:r.type,name:r.name}),false;if(!r.settings)return console.error("Template validation failed: Each widget must have settings"),console.error("Widget:",{id:r.id,hasSettings:!!r.settings}),false}}return true}clearCache(){I.clear();}async determineVariant(e,t,r){try{if(!this.templateLoader.loadVariantRegistry)return "default";let n=await this.templateLoader.loadVariantRegistry(e);if(!n||!n.variantRegistry)return "default";let o=n.variantRegistry[t];if(!o)return "default";let{apiField:a,variantMap:s,defaultVariant:c}=o,d=this.getNestedValue(r,a);return d&&s&&s[d]?s[d]:c||"default"}catch(n){return console.warn(`Failed to load variant registry for template type ${t}:`,n),"default"}}getNestedValue(e,t){return t.split(".").reduce((r,n)=>r&&r[n]!==void 0?r[n]:void 0,e)}};function k(i,e="desktop"){let n=i.settings.responsive?.[e]||{padding:i.settings.padding||{top:0,right:0,bottom:0,left:0},margin:i.settings.margin},o=n.padding?`${n.padding.top}px ${n.padding.right}px ${n.padding.bottom}px ${n.padding.left}px`:"0",a=n.margin?`${n.margin.top}px ${n.margin.right}px ${n.margin.bottom}px ${n.margin.left}px`:void 0;return {padding:o,margin:a}}function f(i,e,t){let{styles:r,breakpoint:n="desktop"}=t,{layout:o}=i.settings,a=k(i,n),s={width:"100%",padding:a.padding,...a.margin&&{margin:a.margin},...o==="page"&&{maxWidth:r?.spacing?.container||"1280px",marginLeft:"auto",marginRight:"auto"}};return b__default.default.createElement("section",{key:i.id,"data-section-id":i.id,"data-section-type":i.type,"data-breakpoint":n,style:s},e)}function M(){return f}function U(i,e){if(i)for(let t of i.sections??[])for(let r of t.widgets??[]){let n=r.settings?.menuHandle;typeof n=="string"&&n.length>0&&e.add(n);}}var E=class{constructor(e){let{commerceClient:t,themeLoader:r,templateLoader:n,widgetRegistry:o,sectionRenderer:a,defaultLocale:s="en"}=e;this.templateResolver=new v(n),this.dataFetcher=new C(t),this.widgetFactory=new h(o),this.styleProcessor=new P(r),this.sectionRenderer=a||f,this.defaultLocale=s;}createLayoutRenderer(e){let t=this.sectionRenderer,r=(n,o,a)=>t(n,o,{styles:a,routeContext:e,breakpoint:"desktop"});return new T(r)}async renderPage({merchantName:e,pageConfig:t,routeContext:r,locale:n,messages:o}){let a=n||this.defaultLocale,s=new R(a,o||{}),c=t||await this.templateResolver.resolveTemplate({merchantName:e,routeContext:r}),d=this.translatePageConfig(c,s),p=await this.dataFetcher.fetchPageData({merchantName:e,pageConfig:d,routeContext:r}),m=await this.styleProcessor.processStyles({merchantName:e,pageConfig:d}),l=this.widgetFactory.createWidgets({pageConfig:d,pageData:p,routeContext:r,translationService:s});return this.createLayoutRenderer(r).renderLayout({pageConfig:d,widgets:l,styles:m,routeContext:r})}async renderChrome({merchantName:e,locale:t,messages:r,headerConfig:n,footerConfig:o,headerTemplateName:a="header",footerTemplateName:s="footer"}){let c=new Set,d=async(l,A)=>{try{let u={templateName:l,path:"/",params:{},query:{},fetchAPITemplate:!0},_=A??await this.templateResolver.resolveTemplate({merchantName:e,routeContext:u});return U(_,c),await this.renderPage({merchantName:e,pageConfig:_,routeContext:u,locale:t,messages:r})}catch(u){return console.error(JSON.stringify({level:"error",service:"builder",message:"renderChrome slot failed",slot:l,merchantName:e,error:u instanceof Error?u.message:String(u)})),null}},[p,m]=await Promise.all([d(a,n),d(s,o)]);return {header:p,footer:m,menuHandles:[...c]}}clearCache(){this.templateResolver.clearCache();}validateConfig(e){let t=[];return e.id||t.push("Page config must have an id"),(!e.sections||!Array.isArray(e.sections))&&t.push("Page config must have a sections array"),(!e.dataSources||typeof e.dataSources!="object")&&t.push("Page config must have a dataSources object"),e.sections?.forEach((r,n)=>{r.id||t.push(`Section at index ${n} must have an id`),(!r.widgets||!Array.isArray(r.widgets))&&t.push(`Section "${r.id}" must have a widgets array`),r.widgets?.forEach((o,a)=>{o.id||t.push(`Widget at section "${r.id}" index ${a} must have an id`),o.type||t.push(`Widget "${o.id}" must have a type`);});}),{valid:t.length===0,errors:t}}translatePageConfig(e,t){return {...e,sections:e.sections.map(r=>({...r,widgets:r.widgets.map(n=>({...n,settings:t.translateObject(n.settings||{})}))}))}}};function O(i){if(!i.commerceClient)throw new Error("commerceClient is required");if(!i.themeLoader)throw new Error("themeLoader is required");if(!i.templateLoader)throw new Error("templateLoader is required");if(!i.widgetRegistry)throw new Error("widgetRegistry is required");let e=new E({commerceClient:i.commerceClient,themeLoader:i.themeLoader,templateLoader:i.templateLoader,widgetRegistry:i.widgetRegistry,sectionRenderer:i.sectionRenderer,defaultLocale:i.defaultLocale});return {renderPage:t=>e.renderPage(t),renderChrome:t=>e.renderChrome(t),clearCache:()=>e.clearCache(),validateConfig:t=>e.validateConfig(t)}}var y=class{constructor(){this.widgets=new Map;}register(e,t){if(!e){console.warn("WidgetRegistry: Cannot register widget with empty type");return}this.widgets.set(e,t);}registerAll(e){for(let{type:t,component:r}of e)this.register(t,r);}get(e){return this.widgets.get(e)}has(e){return this.widgets.has(e)}getRegisteredTypes(){return Array.from(this.widgets.keys())}clear(){this.widgets.clear();}get size(){return this.widgets.size}};var w=class{static getUsedDataSources(e){let t=new Set;for(let r of e.sections)for(let n of r.widgets)n.dataSourceKey&&t.add(n.dataSourceKey);return Array.from(t)}static findWidget(e,t){for(let r of e.sections){let n=r.widgets.find(o=>o.id===t);if(n)return n}return null}static findSection(e,t){return e.sections.find(r=>r.id===t)||null}static generateId(e){return `${e}-${Date.now()}-${Math.random().toString(36).substr(2,9)}`}static validate(e){let t=[];return e.id||t.push("Page config must have an id"),(!e.sections||!Array.isArray(e.sections))&&t.push("Page config must have a sections array"),(!e.dataSources||typeof e.dataSources!="object")&&t.push("Page config must have a dataSources object"),e.sections?.forEach((r,n)=>{r.id||t.push(`Section at index ${n} must have an id`),(!r.widgets||!Array.isArray(r.widgets))&&t.push(`Section "${r.id}" must have a widgets array`),r.widgets?.forEach((o,a)=>{o.id||t.push(`Widget at section "${r.id}" index ${a} must have an id`),o.type||t.push(`Widget "${o.id}" must have a type`);});}),{valid:t.length===0,errors:t}}};var H={HEADER_SECTION:"HEADER_SECTION",GRID_SECTION:"GRID_SECTION",HERO_SECTION:"HERO_SECTION",CONTENT_SECTION:"CONTENT_SECTION",FOOTER_SECTION:"FOOTER_SECTION"},Y={PAGE:"page",FULL:"full"},V={LEFT:"left",CENTER:"center",RIGHT:"right"},G={SQUARE:"1:1",STANDARD:"4:3",CLASSIC:"3:2",WIDE:"16:9"},Q={LEFT:"left",CENTER:"center",RIGHT:"right"},K={STANDARD:"standard",COMPACT:"compact",MINIMAL:"minimal"};var j={mobile:{max:767},tablet:{min:768,max:1023},desktop:{min:1024,max:1920},wide:{min:1921}};var L=null;function z(i){let e=[];if((!i.widgets||!Array.isArray(i.widgets))&&e.push("widgets (array of { type, component })"),i.commerceClient||e.push("commerceClient (ICommerceClient)"),i.themeLoader||e.push("themeLoader (IThemeLoader)"),i.templateLoader||e.push("templateLoader (ITemplateLoader)"),e.length>0)throw new Error(`[PageBuilder] Missing required options:
2
2
  `+e.map(t=>` - ${t}`).join(`
3
3
  `)+`
4
4
 
@@ -11,5 +11,5 @@ Example usage:
11
11
  commerceClient: getCommerceClient(),
12
12
  themeLoader: { loadTheme: async (merchant) => ... },
13
13
  templateLoader: { loadTemplate: async (...) => ... },
14
- });`)}function w(o){Q(o);let e=new m;e.registerAll(o.widgets);let t=o.sectionRenderer||l;return x({commerceClient:o.commerceClient,themeLoader:o.themeLoader,templateLoader:o.templateLoader,widgetRegistry:e,sectionRenderer:t,defaultLocale:o.defaultLocale||"en"})}function N(o){if(!E){if(!o)throw new Error(`[PageBuilder] getPageBuilder() requires options on first call.
15
- Provide widgets, commerceClient, themeLoader, and templateLoader.`);E=w(o);}return E}function _(){E=null;}function b(o){return (e,t,r)=>D__default.default.createElement(o,{section:e,styles:r.styles,children:t})}exports.ASPECT_RATIO_OPTIONS=U;exports.CARD_STYLE_OPTIONS=Y;exports.DATA_SOURCE_TYPES=g;exports.DEFAULT_BREAKPOINTS=V;exports.DEFAULT_LOCALE=v;exports.DefaultSectionWrapper=l;exports.PageConfigHelpers=O;exports.SECTION_ALIGNMENT_OPTIONS=M;exports.SECTION_LAYOUT_OPTIONS=k;exports.SECTION_TYPES=$;exports.TEXT_ALIGNMENT_OPTIONS=H;exports.WidgetRegistry=m;exports.createDefaultSectionRenderer=F;exports.createFileSystemPageBuilder=w;exports.createPageBuilder=x;exports.createSectionRendererFromComponent=b;exports.getPageBuilder=N;exports.resetPageBuilder=_;
14
+ });`)}function N(i){z(i);let e=new y;e.registerAll(i.widgets);let t=i.sectionRenderer||f;return O({commerceClient:i.commerceClient,themeLoader:i.themeLoader,templateLoader:i.templateLoader,widgetRegistry:e,sectionRenderer:t,defaultLocale:i.defaultLocale||"en"})}function W(i){if(!L){if(!i)throw new Error(`[PageBuilder] getPageBuilder() requires options on first call.
15
+ Provide widgets, commerceClient, themeLoader, and templateLoader.`);L=N(i);}return L}function q(){L=null;}function F(i){return (e,t,r)=>b__default.default.createElement(i,{section:e,styles:r.styles,children:t})}exports.ASPECT_RATIO_OPTIONS=G;exports.CARD_STYLE_OPTIONS=K;exports.DATA_SOURCE_TYPES=g;exports.DEFAULT_BREAKPOINTS=j;exports.DEFAULT_LOCALE=x;exports.DefaultSectionWrapper=f;exports.PageConfigHelpers=w;exports.SECTION_ALIGNMENT_OPTIONS=V;exports.SECTION_LAYOUT_OPTIONS=Y;exports.SECTION_TYPES=H;exports.TEXT_ALIGNMENT_OPTIONS=Q;exports.WidgetRegistry=y;exports.createDefaultSectionRenderer=M;exports.createFileSystemPageBuilder=N;exports.createPageBuilder=O;exports.createSectionRendererFromComponent=F;exports.getPageBuilder=W;exports.resetPageBuilder=q;
package/dist/index.mjs CHANGED
@@ -1,4 +1,4 @@
1
- import D from'react';import {jsx,jsxs}from'react/jsx-runtime';var v="en";var y=class{constructor(e="en",t={}){this.locale=e,this.messages=t;}getLocale(){return this.locale}getMessages(){return this.messages}translate(e,t){if(typeof e!="string")return String(e);if(!e.startsWith("t:"))return e;let r=e.slice(2),n=this.getNestedValue(this.messages,r);return n==null?r:typeof n!="string"?n:t?this.interpolate(n,t):n}translateRaw(e){if(typeof e!="string"||!e.startsWith("t:"))return e;let t=e.slice(2),r=this.getNestedValue(this.messages,t);return r!==void 0?r:e}translateObject(e,t){if(e==null)return e;if(typeof e=="string"){if(e.startsWith("t:")){let r=this.translateRaw(e);return typeof r!="string"?r:t?this.interpolate(r,t):r}return e}if(Array.isArray(e))return e.map(r=>this.translateObject(r,t));if(typeof e=="object"){let r={};for(let[n,i]of Object.entries(e))r[n]=this.translateObject(i,t);return r}return e}getNestedValue(e,t){if(!t||!e)return;let r=t.split("."),n=e;for(let i of r){if(n==null)return;n=n[i];}return n}interpolate(e,t){return e.replace(/\{(\w+)\}/g,(r,n)=>{let i=t[n];return i!==void 0?String(i):r})}};var g={PRODUCT:"PRODUCT",PRODUCTS:"PRODUCTS",PRODUCTS_BY_HANDLES:"PRODUCTS_BY_HANDLES",COLLECTION:"COLLECTION",COLLECTIONS:"COLLECTIONS",COLLECTION_BY_HANDLES:"COLLECTION_BY_HANDLES",COLLECTION_FILTERS:"COLLECTION_FILTERS",STATIC:"STATIC",FETCH_REQUEST:"FETCH_REQUEST",GRAPHQL_REQUEST:"GRAPHQL_REQUEST"};var R=class{constructor(e){this.commerceClient=e;}async fetchPageData(e){let{merchantName:t,pageConfig:r,routeContext:n}=e,i={merchantName:t},a=this.collectRequirements(r,n),s=await this.fetchAllData(a);return {...i,...s}}collectRequirements(e,t){let r=[];if(e.dataSources)for(let[n,i]of Object.entries(e.dataSources))r.push({type:i.type,params:{...i.params,...t.params},required:i.required||false,sourceId:n,options:i.options});return r}async fetchAllData(e){let t={};return await Promise.all(e.map(async r=>{try{let n=await this.fetchSingleRequirement(r);t[r.sourceId]=n;}catch(n){if(console.error(`Error fetching data for ${r.sourceId}:`,n),r.required)throw n;t[r.sourceId]=null;}})),t}async fetchSingleRequirement(e){let{type:t,params:r,options:n}=e;switch(t){case g.STATIC:return r;case g.PRODUCT:return this.commerceClient.getProduct(r,n);case g.PRODUCTS:return this.commerceClient.getProducts(r,n);case g.PRODUCTS_BY_HANDLES:return this.commerceClient.getProductsByHandles(r,n);case g.COLLECTION:return this.commerceClient.getCollection(r,n);case g.COLLECTIONS:return this.commerceClient.getCollections(r,n);case g.COLLECTION_BY_HANDLES:return this.commerceClient.getCollectionsByHandles(r,n);case g.COLLECTION_FILTERS:return this.commerceClient.getCollectionFilters(r,n);case g.FETCH_REQUEST:return this.commerceClient.fetchRequest(r);case g.GRAPHQL_REQUEST:return this.commerceClient.graphqlRequest(r);default:return console.warn(`Unknown data source type: ${t}`),null}}};var S=class{constructor(e){this.widgetRegistry=e;}createWidgets({pageConfig:e,pageData:t,routeContext:r,translationService:n}){let i={};for(let a of e.sections){if(!a.widgets?.length){console.warn(`Section ${a.id} has no widgets.`);continue}for(let s of a.widgets){let c=this.createSingleWidget(s,e,t,r,n);c&&(i[s.id]=c);}}return i}createSingleWidget(e,t,r,n,i){try{let a=this.widgetRegistry.get(e.type);if(!a)return console.error(`Widget type not found: ${e.type}`),console.error("Available widgets:",this.widgetRegistry.getRegisteredTypes()),null;let s=this.prepareWidgetData(e,t,r);if(s===null)return null;let c={key:e.id,id:e.id,data:s,settings:e.settings,routeContext:n};return i&&(c.locale=i.getLocale()),D.createElement(a,c)}catch(a){return console.error(`Error creating widget: ${e.id}`,a),null}}prepareWidgetData(e,t,r){if(!e.dataSourceKey)return {};let n=e.dataSourceKey,i=r[n];return (t.dataSources?.[n]?.required||false)&&!i?(console.error(`Required data not available for widget: ${e.id} (dataSourceKey: ${n})`),null):i||{}}};var C=class{constructor(e){this.renderSectionWrapper=e;}renderLayout({pageConfig:e,widgets:t,styles:r,routeContext:n,isEditing:i=false,onSelectSection:a,onSelectWidget:s}){return jsx("div",{className:"page-container",children:e.sections.map(c=>this.renderSection(c,t,r,i,a,s))})}renderSection(e,t,r,n=false,i,a){let s=e.widgets.map(d=>{let u=t[d.id];if(!u)return null;let f=D.cloneElement(u,{key:d.id,...d.responsive&&{responsive:d.responsive}});return n?jsxs("div",{className:"relative",style:{overflow:"visible"},children:[jsx("div",{className:"absolute inset-0 pointer-events-auto rounded cursor-pointer","data-widget-id":d.id,style:{zIndex:1e4,border:"2px solid transparent",transition:"border-color 0.2s",borderRadius:"0.375rem"},onClick:p=>{p.preventDefault(),p.stopPropagation(),a&&a(e.id,d.id);},onMouseEnter:p=>{p.currentTarget.style.borderColor="#EF4444";},onMouseLeave:p=>{p.currentTarget.style.borderColor="transparent";}}),f]},d.id):f}).filter(Boolean),c=this.renderSectionWrapper(e,s,r);return n?jsxs("div",{className:"relative",style:{overflow:"visible"},children:[jsx("div",{className:"absolute inset-0 pointer-events-auto rounded-md cursor-pointer","data-section-id":e.id}),c]},e.id):c}};var h=class{constructor(e){this.themeLoader=e;}async processStyles({merchantName:e,pageConfig:t}){try{return {...(await this.themeLoader.loadTheme(e)).config,...t.theme}}catch(r){throw console.error(`Error processing styles for merchant ${e}:`,r),new Error(`Failed to process styles for merchant ${e}: ${r instanceof Error?r.message:"Unknown error"}`)}}};var T=new Map,P=class{constructor(e){this.templateLoader=e;}async resolveTemplate({merchantName:e,routeContext:t,variant:r}){if(!e)throw new Error("Merchant name is required");let{templateName:n,apiData:i}=t||{};if(!n)throw new Error("Template name is required in the route context");let a=r||(i?await this.determineVariant(e,n,i):"default"),s=`${e}-${n}-${a}`;if(T.has(s))return T.get(s);let c;try{c=await this.loadMerchantTemplate(e,n,a),this.validateTemplate(c)&&T.set(s,c);}catch(d){throw console.error(`Error loading merchant template for ${e}/${n}:`,d),new Error(`Unable to load template for ${e}/${n}. Make sure the template exists.`)}if(!this.validateTemplate(c))throw new Error(`Invalid template configuration for ${e}/${n}`);return c}async loadMerchantTemplate(e,t,r="default"){try{let n=await this.templateLoader.loadTemplate(e,t,r);if(!n)throw new Error(`Template not returned for ${e}/${t}/${r}`);return n}catch(n){if(r!=="default")return console.warn(`Template variant "${r}" not found for ${e}/${t}, falling back to default`),this.loadMerchantTemplate(e,t,"default");throw console.error(`Error loading template ${e}/${t}/${r}:`,n),n}}validateTemplate(e){if(!e.id||!e.sections)return console.error("Template validation failed: Missing required fields (id, or sections)"),false;if(!Array.isArray(e.sections)||e.sections.length===0)return console.error("Template validation failed: Sections must be a non-empty array"),false;for(let t of e.sections){if(!t.id||!t.widgets||!Array.isArray(t.widgets))return console.error("Template validation failed: Each section must have id and widgets array"),console.error("Section structure:",{id:t.id,hasWidgets:!!t.widgets,isArray:Array.isArray(t.widgets)}),false;if(!t.name||!t.type)return console.error("Template validation failed: Each section must have name and type"),console.error("Section:",{id:t.id,name:t.name,type:t.type}),false;if(!t.settings)return console.error("Template validation failed: Each section must have settings"),console.error("Section:",{id:t.id,hasSettings:!!t.settings}),false;for(let r of t.widgets){if(!r.id||!r.type||!r.name)return console.error("Template validation failed: Each widget must have id, type, and name"),console.error("Widget:",{id:r.id,type:r.type,name:r.name}),false;if(!r.settings)return console.error("Template validation failed: Each widget must have settings"),console.error("Widget:",{id:r.id,hasSettings:!!r.settings}),false}}return true}clearCache(){T.clear();}async determineVariant(e,t,r){try{if(!this.templateLoader.loadVariantRegistry)return "default";let n=await this.templateLoader.loadVariantRegistry(e);if(!n||!n.variantRegistry)return "default";let i=n.variantRegistry[t];if(!i)return "default";let{apiField:a,variantMap:s,defaultVariant:c}=i,d=this.getNestedValue(r,a);return d&&s&&s[d]?s[d]:c||"default"}catch(n){return console.warn(`Failed to load variant registry for template type ${t}:`,n),"default"}}getNestedValue(e,t){return t.split(".").reduce((r,n)=>r&&r[n]!==void 0?r[n]:void 0,e)}};function B(o,e="desktop"){let n=o.settings.responsive?.[e]||{padding:o.settings.padding||{top:0,right:0,bottom:0,left:0},margin:o.settings.margin},i=n.padding?`${n.padding.top}px ${n.padding.right}px ${n.padding.bottom}px ${n.padding.left}px`:"0",a=n.margin?`${n.margin.top}px ${n.margin.right}px ${n.margin.bottom}px ${n.margin.left}px`:void 0;return {padding:i,margin:a}}function l(o,e,t){let{styles:r,breakpoint:n="desktop"}=t,{layout:i}=o.settings,a=B(o,n),s={width:"100%",padding:a.padding,...a.margin&&{margin:a.margin},...i==="page"&&{maxWidth:r?.spacing?.container||"1280px",marginLeft:"auto",marginRight:"auto"}};return D.createElement("section",{key:o.id,"data-section-id":o.id,"data-section-type":o.type,"data-breakpoint":n,style:s},e)}function F(){return l}var I=class{constructor(e){let{commerceClient:t,themeLoader:r,templateLoader:n,widgetRegistry:i,sectionRenderer:a,defaultLocale:s="en"}=e;this.templateResolver=new P(n),this.dataFetcher=new R(t),this.widgetFactory=new S(i),this.styleProcessor=new h(r),this.sectionRenderer=a||l,this.defaultLocale=s;}createLayoutRenderer(e){let t=this.sectionRenderer,r=(n,i,a)=>t(n,i,{styles:a,routeContext:e,breakpoint:"desktop"});return new C(r)}async renderPage({merchantName:e,pageConfig:t,routeContext:r,locale:n,messages:i}){let a=n||this.defaultLocale,s=new y(a,i||{}),c=t||await this.templateResolver.resolveTemplate({merchantName:e,routeContext:r}),d=this.translatePageConfig(c,s),u=await this.dataFetcher.fetchPageData({merchantName:e,pageConfig:d,routeContext:r}),f=await this.styleProcessor.processStyles({merchantName:e,pageConfig:d}),p=this.widgetFactory.createWidgets({pageConfig:d,pageData:u,routeContext:r,translationService:s});return this.createLayoutRenderer(r).renderLayout({pageConfig:d,widgets:p,styles:f,routeContext:r})}clearCache(){this.templateResolver.clearCache();}validateConfig(e){let t=[];return e.id||t.push("Page config must have an id"),(!e.sections||!Array.isArray(e.sections))&&t.push("Page config must have a sections array"),(!e.dataSources||typeof e.dataSources!="object")&&t.push("Page config must have a dataSources object"),e.sections?.forEach((r,n)=>{r.id||t.push(`Section at index ${n} must have an id`),(!r.widgets||!Array.isArray(r.widgets))&&t.push(`Section "${r.id}" must have a widgets array`),r.widgets?.forEach((i,a)=>{i.id||t.push(`Widget at section "${r.id}" index ${a} must have an id`),i.type||t.push(`Widget "${i.id}" must have a type`);});}),{valid:t.length===0,errors:t}}translatePageConfig(e,t){return {...e,sections:e.sections.map(r=>({...r,widgets:r.widgets.map(n=>({...n,settings:t.translateObject(n.settings||{})}))}))}}};function x(o){if(!o.commerceClient)throw new Error("commerceClient is required");if(!o.themeLoader)throw new Error("themeLoader is required");if(!o.templateLoader)throw new Error("templateLoader is required");if(!o.widgetRegistry)throw new Error("widgetRegistry is required");let e=new I({commerceClient:o.commerceClient,themeLoader:o.themeLoader,templateLoader:o.templateLoader,widgetRegistry:o.widgetRegistry,sectionRenderer:o.sectionRenderer,defaultLocale:o.defaultLocale});return {renderPage:t=>e.renderPage(t),clearCache:()=>e.clearCache(),validateConfig:t=>e.validateConfig(t)}}var m=class{constructor(){this.widgets=new Map;}register(e,t){if(!e){console.warn("WidgetRegistry: Cannot register widget with empty type");return}this.widgets.set(e,t);}registerAll(e){for(let{type:t,component:r}of e)this.register(t,r);}get(e){return this.widgets.get(e)}has(e){return this.widgets.has(e)}getRegisteredTypes(){return Array.from(this.widgets.keys())}clear(){this.widgets.clear();}get size(){return this.widgets.size}};var O=class{static getUsedDataSources(e){let t=new Set;for(let r of e.sections)for(let n of r.widgets)n.dataSourceKey&&t.add(n.dataSourceKey);return Array.from(t)}static findWidget(e,t){for(let r of e.sections){let n=r.widgets.find(i=>i.id===t);if(n)return n}return null}static findSection(e,t){return e.sections.find(r=>r.id===t)||null}static generateId(e){return `${e}-${Date.now()}-${Math.random().toString(36).substr(2,9)}`}static validate(e){let t=[];return e.id||t.push("Page config must have an id"),(!e.sections||!Array.isArray(e.sections))&&t.push("Page config must have a sections array"),(!e.dataSources||typeof e.dataSources!="object")&&t.push("Page config must have a dataSources object"),e.sections?.forEach((r,n)=>{r.id||t.push(`Section at index ${n} must have an id`),(!r.widgets||!Array.isArray(r.widgets))&&t.push(`Section "${r.id}" must have a widgets array`),r.widgets?.forEach((i,a)=>{i.id||t.push(`Widget at section "${r.id}" index ${a} must have an id`),i.type||t.push(`Widget "${i.id}" must have a type`);});}),{valid:t.length===0,errors:t}}};var $={HEADER_SECTION:"HEADER_SECTION",GRID_SECTION:"GRID_SECTION",HERO_SECTION:"HERO_SECTION",CONTENT_SECTION:"CONTENT_SECTION",FOOTER_SECTION:"FOOTER_SECTION"},k={PAGE:"page",FULL:"full"},M={LEFT:"left",CENTER:"center",RIGHT:"right"},U={SQUARE:"1:1",STANDARD:"4:3",CLASSIC:"3:2",WIDE:"16:9"},H={LEFT:"left",CENTER:"center",RIGHT:"right"},Y={STANDARD:"standard",COMPACT:"compact",MINIMAL:"minimal"};var V={mobile:{max:767},tablet:{min:768,max:1023},desktop:{min:1024,max:1920},wide:{min:1921}};var E=null;function Q(o){let e=[];if((!o.widgets||!Array.isArray(o.widgets))&&e.push("widgets (array of { type, component })"),o.commerceClient||e.push("commerceClient (ICommerceClient)"),o.themeLoader||e.push("themeLoader (IThemeLoader)"),o.templateLoader||e.push("templateLoader (ITemplateLoader)"),e.length>0)throw new Error(`[PageBuilder] Missing required options:
1
+ import b from'react';import {jsx,jsxs}from'react/jsx-runtime';var x="en";var R=class{constructor(e="en",t={}){this.locale=e,this.messages=t;}getLocale(){return this.locale}getMessages(){return this.messages}translate(e,t){if(typeof e!="string")return String(e);if(!e.startsWith("t:"))return e;let r=e.slice(2),n=this.getNestedValue(this.messages,r);return n==null?r:typeof n!="string"?n:t?this.interpolate(n,t):n}translateRaw(e){if(typeof e!="string"||!e.startsWith("t:"))return e;let t=e.slice(2),r=this.getNestedValue(this.messages,t);return r!==void 0?r:e}translateObject(e,t){if(e==null)return e;if(typeof e=="string"){if(e.startsWith("t:")){let r=this.translateRaw(e);return typeof r!="string"?r:t?this.interpolate(r,t):r}return e}if(Array.isArray(e))return e.map(r=>this.translateObject(r,t));if(typeof e=="object"){let r={};for(let[n,o]of Object.entries(e))r[n]=this.translateObject(o,t);return r}return e}getNestedValue(e,t){if(!t||!e)return;let r=t.split("."),n=e;for(let o of r){if(n==null)return;n=n[o];}return n}interpolate(e,t){return e.replace(/\{(\w+)\}/g,(r,n)=>{let o=t[n];return o!==void 0?String(o):r})}};var g={PRODUCT:"PRODUCT",PRODUCTS:"PRODUCTS",PRODUCTS_BY_HANDLES:"PRODUCTS_BY_HANDLES",COLLECTION:"COLLECTION",COLLECTIONS:"COLLECTIONS",COLLECTION_BY_HANDLES:"COLLECTION_BY_HANDLES",COLLECTION_FILTERS:"COLLECTION_FILTERS",STATIC:"STATIC",FETCH_REQUEST:"FETCH_REQUEST",GRAPHQL_REQUEST:"GRAPHQL_REQUEST"};var C=class{constructor(e){this.commerceClient=e;}async fetchPageData(e){let{merchantName:t,pageConfig:r,routeContext:n}=e,o={merchantName:t},a=this.collectRequirements(r,n),s=await this.fetchAllData(a);return {...o,...s}}collectRequirements(e,t){let r=[];if(e.dataSources)for(let[n,o]of Object.entries(e.dataSources))r.push({type:o.type,params:{...o.params,...t.params},required:o.required||false,sourceId:n,options:o.options});return r}async fetchAllData(e){let t={};return await Promise.all(e.map(async r=>{try{let n=await this.fetchSingleRequirement(r);t[r.sourceId]=n;}catch(n){if(console.error(`Error fetching data for ${r.sourceId}:`,n),r.required)throw n;t[r.sourceId]=null;}})),t}async fetchSingleRequirement(e){let{type:t,params:r,options:n}=e;switch(t){case g.STATIC:return r;case g.PRODUCT:return this.commerceClient.getProduct(r,n);case g.PRODUCTS:return this.commerceClient.getProducts(r,n);case g.PRODUCTS_BY_HANDLES:return this.commerceClient.getProductsByHandles(r,n);case g.COLLECTION:return this.commerceClient.getCollection(r,n);case g.COLLECTIONS:return this.commerceClient.getCollections(r,n);case g.COLLECTION_BY_HANDLES:return this.commerceClient.getCollectionsByHandles(r,n);case g.COLLECTION_FILTERS:return this.commerceClient.getCollectionFilters(r,n);case g.FETCH_REQUEST:return this.commerceClient.fetchRequest(r);case g.GRAPHQL_REQUEST:return this.commerceClient.graphqlRequest(r);default:return console.warn(`Unknown data source type: ${t}`),null}}};var h=class{constructor(e){this.widgetRegistry=e;}createWidgets({pageConfig:e,pageData:t,routeContext:r,translationService:n}){let o={};for(let a of e.sections){if(!a.widgets?.length){console.warn(`Section ${a.id} has no widgets.`);continue}for(let s of a.widgets){let c=this.createSingleWidget(s,e,t,r,n);c&&(o[s.id]=c);}}return o}createSingleWidget(e,t,r,n,o){try{let a=this.widgetRegistry.get(e.type);if(!a)return console.error(`Widget type not found: ${e.type}`),console.error("Available widgets:",this.widgetRegistry.getRegisteredTypes()),null;let s=this.prepareWidgetData(e,t,r);if(s===null)return null;let c={key:e.id,id:e.id,data:s,settings:e.settings,routeContext:n};return o&&(c.locale=o.getLocale()),b.createElement(a,c)}catch(a){return console.error(`Error creating widget: ${e.id}`,a),null}}prepareWidgetData(e,t,r){if(!e.dataSourceKey)return {};let n=e.dataSourceKey,o=r[n];return (t.dataSources?.[n]?.required||false)&&!o?(console.error(`Required data not available for widget: ${e.id} (dataSourceKey: ${n})`),null):o||{}}};var T=class{constructor(e){this.renderSectionWrapper=e;}renderLayout({pageConfig:e,widgets:t,styles:r,routeContext:n,isEditing:o=false,onSelectSection:a,onSelectWidget:s}){return jsx("div",{className:"page-container",children:e.sections.map(c=>jsx(b.Fragment,{children:this.renderSection(c,t,r,o,a,s)},c.id))})}renderSection(e,t,r,n=false,o,a){let s=e.widgets.map(d=>{let p=t[d.id];if(!p)return null;let m=b.cloneElement(p,{key:d.id,...d.responsive&&{responsive:d.responsive}});return n?jsxs("div",{className:"relative",style:{overflow:"visible"},children:[jsx("div",{className:"absolute inset-0 pointer-events-auto rounded cursor-pointer","data-widget-id":d.id,style:{zIndex:1e4,border:"2px solid transparent",transition:"border-color 0.2s",borderRadius:"0.375rem"},onClick:l=>{l.preventDefault(),l.stopPropagation(),a&&a(e.id,d.id);},onMouseEnter:l=>{l.currentTarget.style.borderColor="#EF4444";},onMouseLeave:l=>{l.currentTarget.style.borderColor="transparent";}}),m]},d.id):m}).filter(Boolean),c=this.renderSectionWrapper(e,s,r);return n?jsxs("div",{className:"relative",style:{overflow:"visible"},children:[jsx("div",{className:"absolute inset-0 pointer-events-auto rounded-md cursor-pointer","data-section-id":e.id}),c]},e.id):c}};var P=class{constructor(e){this.themeLoader=e;}async processStyles({merchantName:e,pageConfig:t}){try{return {...(await this.themeLoader.loadTheme(e)).config,...t.theme}}catch(r){throw console.error(`Error processing styles for merchant ${e}:`,r),new Error(`Failed to process styles for merchant ${e}: ${r instanceof Error?r.message:"Unknown error"}`)}}};var I=new Map,v=class{constructor(e){this.templateLoader=e;}async resolveTemplate({merchantName:e,routeContext:t,variant:r}){if(!e)throw new Error("Merchant name is required");let{templateName:n,apiData:o}=t||{};if(!n)throw new Error("Template name is required in the route context");let a=r||(o?await this.determineVariant(e,n,o):"default"),s=`${e}-${n}-${a}`;if(I.has(s))return I.get(s);let c;try{c=await this.loadMerchantTemplate(e,n,a),this.validateTemplate(c)&&I.set(s,c);}catch(d){throw console.error(`Error loading merchant template for ${e}/${n}:`,d),new Error(`Unable to load template for ${e}/${n}. Make sure the template exists.`)}if(!this.validateTemplate(c))throw new Error(`Invalid template configuration for ${e}/${n}`);return c}async loadMerchantTemplate(e,t,r="default"){try{let n=await this.templateLoader.loadTemplate(e,t,r);if(!n)throw new Error(`Template not returned for ${e}/${t}/${r}`);return n}catch(n){if(r!=="default")return console.warn(`Template variant "${r}" not found for ${e}/${t}, falling back to default`),this.loadMerchantTemplate(e,t,"default");throw console.error(`Error loading template ${e}/${t}/${r}:`,n),n}}validateTemplate(e){if(!e.id||!e.sections)return console.error("Template validation failed: Missing required fields (id, or sections)"),false;if(!Array.isArray(e.sections)||e.sections.length===0)return console.error("Template validation failed: Sections must be a non-empty array"),false;for(let t of e.sections){if(!t.id||!t.widgets||!Array.isArray(t.widgets))return console.error("Template validation failed: Each section must have id and widgets array"),console.error("Section structure:",{id:t.id,hasWidgets:!!t.widgets,isArray:Array.isArray(t.widgets)}),false;if(!t.name||!t.type)return console.error("Template validation failed: Each section must have name and type"),console.error("Section:",{id:t.id,name:t.name,type:t.type}),false;if(!t.settings)return console.error("Template validation failed: Each section must have settings"),console.error("Section:",{id:t.id,hasSettings:!!t.settings}),false;for(let r of t.widgets){if(!r.id||!r.type||!r.name)return console.error("Template validation failed: Each widget must have id, type, and name"),console.error("Widget:",{id:r.id,type:r.type,name:r.name}),false;if(!r.settings)return console.error("Template validation failed: Each widget must have settings"),console.error("Widget:",{id:r.id,hasSettings:!!r.settings}),false}}return true}clearCache(){I.clear();}async determineVariant(e,t,r){try{if(!this.templateLoader.loadVariantRegistry)return "default";let n=await this.templateLoader.loadVariantRegistry(e);if(!n||!n.variantRegistry)return "default";let o=n.variantRegistry[t];if(!o)return "default";let{apiField:a,variantMap:s,defaultVariant:c}=o,d=this.getNestedValue(r,a);return d&&s&&s[d]?s[d]:c||"default"}catch(n){return console.warn(`Failed to load variant registry for template type ${t}:`,n),"default"}}getNestedValue(e,t){return t.split(".").reduce((r,n)=>r&&r[n]!==void 0?r[n]:void 0,e)}};function k(i,e="desktop"){let n=i.settings.responsive?.[e]||{padding:i.settings.padding||{top:0,right:0,bottom:0,left:0},margin:i.settings.margin},o=n.padding?`${n.padding.top}px ${n.padding.right}px ${n.padding.bottom}px ${n.padding.left}px`:"0",a=n.margin?`${n.margin.top}px ${n.margin.right}px ${n.margin.bottom}px ${n.margin.left}px`:void 0;return {padding:o,margin:a}}function f(i,e,t){let{styles:r,breakpoint:n="desktop"}=t,{layout:o}=i.settings,a=k(i,n),s={width:"100%",padding:a.padding,...a.margin&&{margin:a.margin},...o==="page"&&{maxWidth:r?.spacing?.container||"1280px",marginLeft:"auto",marginRight:"auto"}};return b.createElement("section",{key:i.id,"data-section-id":i.id,"data-section-type":i.type,"data-breakpoint":n,style:s},e)}function M(){return f}function U(i,e){if(i)for(let t of i.sections??[])for(let r of t.widgets??[]){let n=r.settings?.menuHandle;typeof n=="string"&&n.length>0&&e.add(n);}}var E=class{constructor(e){let{commerceClient:t,themeLoader:r,templateLoader:n,widgetRegistry:o,sectionRenderer:a,defaultLocale:s="en"}=e;this.templateResolver=new v(n),this.dataFetcher=new C(t),this.widgetFactory=new h(o),this.styleProcessor=new P(r),this.sectionRenderer=a||f,this.defaultLocale=s;}createLayoutRenderer(e){let t=this.sectionRenderer,r=(n,o,a)=>t(n,o,{styles:a,routeContext:e,breakpoint:"desktop"});return new T(r)}async renderPage({merchantName:e,pageConfig:t,routeContext:r,locale:n,messages:o}){let a=n||this.defaultLocale,s=new R(a,o||{}),c=t||await this.templateResolver.resolveTemplate({merchantName:e,routeContext:r}),d=this.translatePageConfig(c,s),p=await this.dataFetcher.fetchPageData({merchantName:e,pageConfig:d,routeContext:r}),m=await this.styleProcessor.processStyles({merchantName:e,pageConfig:d}),l=this.widgetFactory.createWidgets({pageConfig:d,pageData:p,routeContext:r,translationService:s});return this.createLayoutRenderer(r).renderLayout({pageConfig:d,widgets:l,styles:m,routeContext:r})}async renderChrome({merchantName:e,locale:t,messages:r,headerConfig:n,footerConfig:o,headerTemplateName:a="header",footerTemplateName:s="footer"}){let c=new Set,d=async(l,A)=>{try{let u={templateName:l,path:"/",params:{},query:{},fetchAPITemplate:!0},_=A??await this.templateResolver.resolveTemplate({merchantName:e,routeContext:u});return U(_,c),await this.renderPage({merchantName:e,pageConfig:_,routeContext:u,locale:t,messages:r})}catch(u){return console.error(JSON.stringify({level:"error",service:"builder",message:"renderChrome slot failed",slot:l,merchantName:e,error:u instanceof Error?u.message:String(u)})),null}},[p,m]=await Promise.all([d(a,n),d(s,o)]);return {header:p,footer:m,menuHandles:[...c]}}clearCache(){this.templateResolver.clearCache();}validateConfig(e){let t=[];return e.id||t.push("Page config must have an id"),(!e.sections||!Array.isArray(e.sections))&&t.push("Page config must have a sections array"),(!e.dataSources||typeof e.dataSources!="object")&&t.push("Page config must have a dataSources object"),e.sections?.forEach((r,n)=>{r.id||t.push(`Section at index ${n} must have an id`),(!r.widgets||!Array.isArray(r.widgets))&&t.push(`Section "${r.id}" must have a widgets array`),r.widgets?.forEach((o,a)=>{o.id||t.push(`Widget at section "${r.id}" index ${a} must have an id`),o.type||t.push(`Widget "${o.id}" must have a type`);});}),{valid:t.length===0,errors:t}}translatePageConfig(e,t){return {...e,sections:e.sections.map(r=>({...r,widgets:r.widgets.map(n=>({...n,settings:t.translateObject(n.settings||{})}))}))}}};function O(i){if(!i.commerceClient)throw new Error("commerceClient is required");if(!i.themeLoader)throw new Error("themeLoader is required");if(!i.templateLoader)throw new Error("templateLoader is required");if(!i.widgetRegistry)throw new Error("widgetRegistry is required");let e=new E({commerceClient:i.commerceClient,themeLoader:i.themeLoader,templateLoader:i.templateLoader,widgetRegistry:i.widgetRegistry,sectionRenderer:i.sectionRenderer,defaultLocale:i.defaultLocale});return {renderPage:t=>e.renderPage(t),renderChrome:t=>e.renderChrome(t),clearCache:()=>e.clearCache(),validateConfig:t=>e.validateConfig(t)}}var y=class{constructor(){this.widgets=new Map;}register(e,t){if(!e){console.warn("WidgetRegistry: Cannot register widget with empty type");return}this.widgets.set(e,t);}registerAll(e){for(let{type:t,component:r}of e)this.register(t,r);}get(e){return this.widgets.get(e)}has(e){return this.widgets.has(e)}getRegisteredTypes(){return Array.from(this.widgets.keys())}clear(){this.widgets.clear();}get size(){return this.widgets.size}};var w=class{static getUsedDataSources(e){let t=new Set;for(let r of e.sections)for(let n of r.widgets)n.dataSourceKey&&t.add(n.dataSourceKey);return Array.from(t)}static findWidget(e,t){for(let r of e.sections){let n=r.widgets.find(o=>o.id===t);if(n)return n}return null}static findSection(e,t){return e.sections.find(r=>r.id===t)||null}static generateId(e){return `${e}-${Date.now()}-${Math.random().toString(36).substr(2,9)}`}static validate(e){let t=[];return e.id||t.push("Page config must have an id"),(!e.sections||!Array.isArray(e.sections))&&t.push("Page config must have a sections array"),(!e.dataSources||typeof e.dataSources!="object")&&t.push("Page config must have a dataSources object"),e.sections?.forEach((r,n)=>{r.id||t.push(`Section at index ${n} must have an id`),(!r.widgets||!Array.isArray(r.widgets))&&t.push(`Section "${r.id}" must have a widgets array`),r.widgets?.forEach((o,a)=>{o.id||t.push(`Widget at section "${r.id}" index ${a} must have an id`),o.type||t.push(`Widget "${o.id}" must have a type`);});}),{valid:t.length===0,errors:t}}};var H={HEADER_SECTION:"HEADER_SECTION",GRID_SECTION:"GRID_SECTION",HERO_SECTION:"HERO_SECTION",CONTENT_SECTION:"CONTENT_SECTION",FOOTER_SECTION:"FOOTER_SECTION"},Y={PAGE:"page",FULL:"full"},V={LEFT:"left",CENTER:"center",RIGHT:"right"},G={SQUARE:"1:1",STANDARD:"4:3",CLASSIC:"3:2",WIDE:"16:9"},Q={LEFT:"left",CENTER:"center",RIGHT:"right"},K={STANDARD:"standard",COMPACT:"compact",MINIMAL:"minimal"};var j={mobile:{max:767},tablet:{min:768,max:1023},desktop:{min:1024,max:1920},wide:{min:1921}};var L=null;function z(i){let e=[];if((!i.widgets||!Array.isArray(i.widgets))&&e.push("widgets (array of { type, component })"),i.commerceClient||e.push("commerceClient (ICommerceClient)"),i.themeLoader||e.push("themeLoader (IThemeLoader)"),i.templateLoader||e.push("templateLoader (ITemplateLoader)"),e.length>0)throw new Error(`[PageBuilder] Missing required options:
2
2
  `+e.map(t=>` - ${t}`).join(`
3
3
  `)+`
4
4
 
@@ -11,5 +11,5 @@ Example usage:
11
11
  commerceClient: getCommerceClient(),
12
12
  themeLoader: { loadTheme: async (merchant) => ... },
13
13
  templateLoader: { loadTemplate: async (...) => ... },
14
- });`)}function w(o){Q(o);let e=new m;e.registerAll(o.widgets);let t=o.sectionRenderer||l;return x({commerceClient:o.commerceClient,themeLoader:o.themeLoader,templateLoader:o.templateLoader,widgetRegistry:e,sectionRenderer:t,defaultLocale:o.defaultLocale||"en"})}function N(o){if(!E){if(!o)throw new Error(`[PageBuilder] getPageBuilder() requires options on first call.
15
- Provide widgets, commerceClient, themeLoader, and templateLoader.`);E=w(o);}return E}function _(){E=null;}function b(o){return (e,t,r)=>D.createElement(o,{section:e,styles:r.styles,children:t})}export{U as ASPECT_RATIO_OPTIONS,Y as CARD_STYLE_OPTIONS,g as DATA_SOURCE_TYPES,V as DEFAULT_BREAKPOINTS,v as DEFAULT_LOCALE,l as DefaultSectionWrapper,O as PageConfigHelpers,M as SECTION_ALIGNMENT_OPTIONS,k as SECTION_LAYOUT_OPTIONS,$ as SECTION_TYPES,H as TEXT_ALIGNMENT_OPTIONS,m as WidgetRegistry,F as createDefaultSectionRenderer,w as createFileSystemPageBuilder,x as createPageBuilder,b as createSectionRendererFromComponent,N as getPageBuilder,_ as resetPageBuilder};
14
+ });`)}function N(i){z(i);let e=new y;e.registerAll(i.widgets);let t=i.sectionRenderer||f;return O({commerceClient:i.commerceClient,themeLoader:i.themeLoader,templateLoader:i.templateLoader,widgetRegistry:e,sectionRenderer:t,defaultLocale:i.defaultLocale||"en"})}function W(i){if(!L){if(!i)throw new Error(`[PageBuilder] getPageBuilder() requires options on first call.
15
+ Provide widgets, commerceClient, themeLoader, and templateLoader.`);L=N(i);}return L}function q(){L=null;}function F(i){return (e,t,r)=>b.createElement(i,{section:e,styles:r.styles,children:t})}export{G as ASPECT_RATIO_OPTIONS,K as CARD_STYLE_OPTIONS,g as DATA_SOURCE_TYPES,j as DEFAULT_BREAKPOINTS,x as DEFAULT_LOCALE,f as DefaultSectionWrapper,w as PageConfigHelpers,V as SECTION_ALIGNMENT_OPTIONS,Y as SECTION_LAYOUT_OPTIONS,H as SECTION_TYPES,Q as TEXT_ALIGNMENT_OPTIONS,y as WidgetRegistry,M as createDefaultSectionRenderer,N as createFileSystemPageBuilder,O as createPageBuilder,F as createSectionRendererFromComponent,W as getPageBuilder,q as resetPageBuilder};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@shopkit/builder",
3
- "version": "0.1.4",
3
+ "version": "0.1.5",
4
4
  "description": "Page builder for creating dynamic storefronts with configurable widgets and layouts",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.mjs",
@@ -45,6 +45,7 @@
45
45
  "javascript-obfuscator": "^5.3.0",
46
46
  "tsup": "^8.0.0",
47
47
  "typescript": "^5.3.0",
48
+ "vitest": "^1.0.0",
48
49
  "@shopkit/test-utils": "workspace:*"
49
50
  },
50
51
  "keywords": [