1const widgetIcons = { 2 default: `<svg width="81" height="81" viewBox="0 0 81 81" fill="none" xmlns="http://www.w3.org/2000/svg"> 3 <path d="M45.8124 17.3399C45.8124 16.2298 45.8133 15.1406 45.8124 14.0523C45.8116 13.4553 45.7985 12.8583 45.8029 12.2612C45.8081 11.5549 46.2714 11.0689 46.9161 11.0759C47.5737 11.082 47.9781 11.513 47.9815 12.2385C47.9885 13.6074 47.9841 14.9763 47.9841 16.3452C47.9841 16.5908 47.9841 16.8373 47.9841 17.1415C49.3142 17.187 50.5255 17.5497 51.6048 18.388C52.0031 17.6363 52.3814 16.9195 52.7631 16.2036C53.5561 14.7167 54.3414 13.2254 55.1491 11.7464C55.5118 11.0829 56.1565 10.8792 56.71 11.207C57.2506 11.527 57.3842 12.1607 57.0406 12.8093C55.8233 15.1074 54.6086 17.4064 53.3774 19.6966C53.2117 20.0051 53.1857 20.2464 53.3332 20.5803C54.3284 22.8408 55.3227 25.1031 56.2606 27.3881C56.6918 28.4396 57.4423 29.2412 58.1069 30.1136C59.0561 31.361 60.0817 32.5533 60.9745 33.84C62.0027 35.3225 62.2621 36.9808 61.7849 38.7535C60.7116 42.7413 59.6635 46.7352 58.6024 50.7265C57.4406 55.0962 56.2675 59.4634 55.1179 63.8367C54.8437 64.8804 54.5886 65.9145 53.9492 66.8183C52.528 68.8244 50.1029 69.7746 47.7282 69.1688C45.573 68.619 43.4281 68.0255 41.2807 67.4459C36.8601 66.2545 32.4377 65.0692 28.0223 63.8603C27.1355 63.6172 26.215 63.3935 25.4124 62.9651C22.9639 61.6609 21.8342 59.0211 22.4841 56.3104C22.5648 55.973 22.4598 55.855 22.2047 55.7072C20.7393 54.8611 19.2391 54.0665 17.8327 53.1294C15.1716 51.3576 14.4254 47.9826 16.015 45.1906C18.099 41.5297 20.2031 37.8802 22.295 34.2246C24.5968 30.2027 26.9247 26.1966 29.1832 22.1503C30.351 20.0593 32.0568 18.9378 34.4073 18.6852C37.9125 18.3093 41.4126 17.881 44.9144 17.4728C45.1869 17.4413 45.4567 17.3924 45.8116 17.3391L45.8124 17.3399ZM45.7977 23.2263C45.5556 23.319 45.3673 23.388 45.1825 23.4632C43.7474 24.0401 42.3141 24.6214 40.8781 25.1957C38.5025 26.1459 36.1209 27.0786 33.7522 28.0445C32.6243 28.5043 31.9085 29.368 31.5735 30.5454C31.4425 31.007 31.3384 31.4755 31.2152 31.939
36C30.0187 36.4362 28.8196 40.9318 27.6232 45.4283C26.6176 49.209 25.605 52.9878 24.615 56.7728C24.0797 58.8218 25.2076 60.7851 27.2249 61.3795C27.5295 61.4695 27.8409 61.5351 28.1472 61.6181C32.5123 62.7964 36.8774 63.9756 41.2417 65.1548C43.5427 65.7764 45.8419 66.4049 48.1455 67.0185C50.1324 67.5482 52.207 66.3393 52.7258 64.376C53.8303 60.2012 54.9426 56.028 56.0506 51.8541C57.248 47.3418 58.4306 42.8261 59.647 38.319C60.0105 36.972 59.7702 35.7946 58.9199 34.7141C57.0883 32.3863 55.2602 30.055 53.4329 27.7246C52.5011 26.5366 51.5788 25.3408 50.6426 24.1564C49.9789 23.3164 49.1025 22.8775 47.9824 22.7761C47.9824 23.8513 47.9954 24.8837 47.9746 25.9143C47.9677 26.2473 48.0475 26.4169 48.3807 26.5515C50.5827 27.444 51.859 29.6853 51.5441 32.0498C51.2274 34.4239 49.3463 36.2998 47.0566 36.5245C44.5275 36.7718 42.3592 35.4099 41.5506 33.0655C40.7272 30.6809 41.6755 28.0742 43.8568 26.8575C44.452 26.5253 45.1253 26.3338 45.7977 26.0637V23.2263ZM23.1288 53.7212C23.2112 53.4485 23.2841 53.23 23.3439 53.0071C23.9218 50.8427 24.4988 48.6784 25.0732 46.5131C26.5195 41.0594 27.965 35.6049 29.4105 30.1512C29.9519 28.1101 31.1987 26.6966 33.1431 25.9125C35.0866 25.1284 37.0345 24.3548 38.9797 23.576C41.1402 22.7106 43.3015 21.8469 45.4593 20.9746C45.5877 20.923 45.7725 20.8067 45.7838 20.7045C45.8228 20.3373 45.7994 19.9632 45.7994 19.5882C45.704 19.5882 45.6606 19.5838 45.6181 19.5882C41.9002 20.0244 38.1832 20.4606 34.4654 20.8976C33.1804 21.0489 32.0828 21.5567 31.413 22.7184C28.6635 27.4886 25.9339 32.2709 23.1964 37.0489C21.456 40.0874 19.7189 43.1268 17.9715 46.1609C17.5455 46.9004 17.2956 47.6757 17.4032 48.5341C17.5646 49.827 18.1806 50.8287 19.3163 51.4887C20.5788 52.2221 21.8368 52.9616 23.1305 53.7186L23.1288 53.7212ZM45.8012 28.4274C44.3053 28.7534 43.3318 30.0891 43.4611 31.5821C43.5947 33.1328 44.7886 34.2989 46.2974 34.3505C47.8445 34.4038 49.1242 33.361 49.3663 31.8487C49.5693 30.5804 48.9203 29.1687 47.9833 28.8977C47.9833 29.1092 47.9911 29.312 47.9815 29.5148C47.9538 30.1634 47.4887 30.6319 46.8866 30.6258C46.2627 30.6197 45.8055 30.1276 45.802 29.4562C45.8003 29.1232 45.802 28.7902 45.802 28.4274H45.8012ZM51.4955 21.9081C50.9636 20.3347 49.4175 19.2473 48.0215 19.4072V20.5384C49.2821 20.666 50.4361 21.0349 51.4955 21.909V21.9081Z" fill="white"/> 4 <path d="M50.0751 54.1175C50.0786 56.2452 48.3875 57.9515 46.28 57.948C44.1925 57.9445 42.504 56.2478 42.4971 54.1455C42.4902 51.9952 44.1482 50.3072 46.2748 50.2993C48.4083 50.2915 50.0725 51.9637 50.076 54.1167L50.0751 54.1175ZM47.8904 54.1158C47.8964 53.2067 47.2171 52.5179 46.3043 52.5083C45.4098 52.4987 44.6966 53.1918 44.6801 54.087C44.6636 55.0013 45.3707 55.7417 46.2713 55.7522C47.1702 55.7627 47.8843 55.0406 47.8912 54.1158H47.8904Z" fill="white"/> 5 <path d="M40.7167 44.671C40.7488 46.6666 39.0517 48.4114 37.0448 48.4455C34.8809 48.4831 33.2194 46.8074 33.1795 44.5468C33.1448 42.5932 34.887 40.8685 36.9199 40.844C39.03 40.8187 40.682 42.4839 40.7175 44.6701L40.7167 44.671ZM36.952 43.0556C36.0791 43.0521 35.3763 43.726 35.3711 44.5722C35.3651 45.5101 36.0583 46.2453 36.9511 46.2462C37.824 46.247 38.545 45.5337 38.538 44.678C38.5302 43.7628 37.8422 43.0591 36.9528 43.0556H36.952Z" fill="white"/> 6 <path d="M36.1825 55.1552C35.5396 55.1587 35.1197 54.8641 34.9626 54.4296C34.7952 53.9655 34.9123 53.5345 35.3314 53.184C36.8645 51.8999 38.402 50.6202 39.9403 49.3422C42.092 47.5546 44.2395 45.7626 46.406 43.9943C46.6454 43.7985 46.9899 43.6569 47.2944 43.6376C47.7699 43.607 48.1447 43.9532 48.2835 44.4077C48.4276 44.8789 48.2905 45.274 47.9252 45.5826C47.1383 46.246 46.3444 46.8999 45.5513 47.5555C42.6595 49.9488 39.7685 52.344 36.8706 54.7295C36.6233 54.9331 36.3222 55.0695 36.1817 55.1552H36.1825Z" fill="white"/> 7 </svg> 8 `, 9 shipping: `<svg width="81" height="81" viewBox="0 0 81 81" fill="none" xmlns="http://www.w3.org/2000/svg"> 10 <path d="M5.22388 33.6172C5.6785 33.4711 6.13131 33.2099 6.58774 33.2008C8.86446 33.157 11.143 33.1789 13.4215 33.1825C14.2927 33.1844 14.7528 33.577 14.7419 34.282C14.7311 34.9596 14.2764 35.3633 13.456 35.3669C11.1104 35.3779 8.76485 35.3943 6.41929 35.3468C6.01901 35.3395 5.62235 35.0217 5.22569 34.8482C5.22569 34.4373 5.22569 34.0263 5.22569 33.6154L5.22388 33.6172Z" fill="white"/> 11 <path d="M57.3946 31.1769C59.9919 31.1769 62.477 31.2006 64.9602 31.1677C66.3476 31.1495 67.3148 31.7102 67.9849 32.9448C69.807 36.3036 71.6654 39.6441 73.5201 42.9864C74.1884 44.1882 74.5289 45.4594 74.5108 46.8438C74.4873 48.6921 74.509 50.5423 74.5036 52.3906C74.5 53.8115 73.7718 54.6279 72.3862 54.5403C71.2361 54.4672 70.613 54.6973 70.1584 55.9484C69.3271 58.2387 66.8783 59.6213 64.5454 59.4716C61.9988 59.3072 59.9213 57.689 59.1533 55.2708C59.0863 55.0571 59.0211 54.8416 58.936 54.5658C57.784 54.5658 56.6357 54.5658 55.4892 54.5658C50.338 54.5658 45.1851 54.5731 40.0339 54.5549C39.534 54.5531 39.3004 54.6553 39.1464 55.1886C38.402 57.7493 36.1108 59.457 33.4881 59.4807C30.9179 59.5044 28.567 57.7639 27.8099 55.2124C27.6577 54.701 27.4621 54.5476 26.9387 54.5531C24.1602 54.5823 21.38 54.5677 18.6015 54.5658C17.5003 54.5658 17.1507 54.2079 17.1489 53.0864C17.1471 50.8053 17.1489 48.5223 17.1489 46.1534C16.8827 46.1406 16.6454 46.1187 16.4099 46.1187C14.0155 46.1169 11.6192 46.1187 9.22475 46.1169C8.99835 46.1169 8.76832 46.1297 8.54916 46.0895C8.01485 45.989 7.7178 45.6329 7.67977 45.0996C7.64354 44.5918 7.88987 44.2046 8.36623 44.0384C8.6361 43.9453 8.9422 43.9325 9.232 43.9325C13.5029 43.927 17.772 43.9288 22.0429 43.9288C22.2005 43.9288 22.3599 43.9215 22.5174 43.9398C23.1785 44.0147 23.5933 44.4439 23.5897 45.0429C23.5861 45.6712 23.1459 46.1023 22.4359 46.1132C21.4253 46.1315 20.4128 46.1169 19.3604 46.1169V52.3468C19.518 52.3577 19.6466 52.3723 19.777 52.3723C22.2168 52.3723 24.6583 52.3668 27.098 52.3796C27.4675 52.3815 27.6378 52.2938 27.7537 51.8956C28.538 49.1816 30.8038 47.4502 33.5044 47.4556C36.1579 47.4593 38.411 49.1962 39.208 51.8755C39.3022 52.1952 39.3782 52.3833 39.7713 52.3833C44.8319 52.3668 49.8943 52.3705 54.9567 52.3668C55.0002 52.3668 55.0436 52.3449 55.1577 52.3157V23.7616H19.3623V27.1186C19.5959 27.1186 19.835 27.1186 20.0741 27.1186C21.8599 27.1186 23.644 27.1131 25.4299 27.1222C26.2975 27.1259 26.7829 27.5314 26.7811 28.2126C26.7811 28.8902 26.2884 29.3066 25.4263 29.3084C21.2025 29.3139 16.9769 29.3121 12.753 29.3103C12.6407 29.3103 12.5266 29.3103 12.4143 29.2938C11.7931 29.2135 11.3928 28.7952 11.3856 28.2236C11.3783 27.6263 11.8003 27.1533 12.4578 27.1369C13.7221 27.104 14.9881 27.1222 16.2542 27.1186C16.5222 27.1186 16.7885 27.1186 17.1489 27.1186C17.1489 26.0173 17.1489 24.9762 17.1489 23.937C17.1507 22.2348 17.8499 21.517 19.5271 21.517C31.3454 21.5152 43.1637 21.5152 54.9802 21.517C56.6882 21.517 57.391 22.2403 57.3928 23.9863C57.3946 26.1086 57.3928 28.2327 57.3928 30.355V31.175L57.3946 31.1769ZM72.3373 52.3376C72.3373 50.4765 72.3247 48.6556 72.3428 46.8347C72.3536 45.8484 72.1164 44.9443 71.6436 44.0896C69.7817 40.7253 67.9215 37.3611 66.0759 33.9877C65.8259 33.5293 65.509 33.3521 64.9946 33.3576C62.6671 33.3795 60.3397 33.3667 58.0123 33.3686C57.8366 33.3
11686 57.6627 33.3886 57.4725 33.4014V52.3522C58.3757 52.4009 58.9879 52.0217 59.3091 51.2144C60.2093 48.9496 62.3864 47.4611 64.8062 47.4538C67.2188 47.4465 69.4049 48.9295 70.316 51.1925C70.6493 52.0192 71.323 52.4009 72.3373 52.3376ZM29.7461 53.4389C29.7533 55.6087 31.3816 57.2835 33.4899 57.289C35.5674 57.2945 37.2319 55.5685 37.2247 53.4189C37.2174 51.3276 35.542 49.6473 33.4664 49.6491C31.3834 49.6491 29.737 51.3276 29.7443 53.4408L29.7461 53.4389ZM68.5537 53.4444C68.5482 51.3258 66.9127 49.6583 64.8316 49.6473C62.7269 49.6364 61.0696 51.3276 61.0751 53.4791C61.0805 55.616 62.7722 57.3146 64.8678 57.2872C66.9326 57.2598 68.5591 55.5649 68.5537 53.4444Z" fill="white"/> 12 <path d="M19.3172 38.9596C19.6233 38.9596 19.866 38.9596 20.1069 38.9596C24.4666 38.9596 28.8262 38.9468 33.1841 38.9815C33.5825 38.9851 34.0933 39.1806 34.3505 39.471C34.8721 40.0591 34.4338 40.9905 33.6351 41.1293C33.4141 41.1677 33.1841 41.1513 32.9595 41.1513C26.9063 41.1513 20.8531 41.1513 14.8 41.1513C14.6189 41.1513 14.4377 41.1604 14.2584 41.144C13.6082 41.0837 13.1989 40.6453 13.2079 40.0335C13.217 39.4217 13.6372 38.9833 14.2947 38.9669C15.2166 38.945 16.1385 38.9614 17.1474 38.9614V37.5679C17.1474 36.1524 17.1474 34.7387 17.1474 33.3233C17.1474 32.1361 17.4734 31.6065 18.2124 31.5973C18.9568 31.5864 19.3154 32.1398 19.3154 33.2977C19.3154 34.9415 19.3154 36.5834 19.3154 38.2272V38.9614L19.3172 38.9596Z" fill="white"/> 13 </svg> 14 `, 15 gift: `<svg width="81" height="81" viewBox="0 0 81 81" fill="none" xmlns="http://www.w3.org/2000/svg"> 16 <path d="M8.86011 32.7296C8.89571 32.6602 8.94749 32.5956 8.96367 32.5229C9.72261 29.0861 12.7842 26.9897 16.3168 27.4419C18.8072 27.7601 20.9788 28.8099 22.9999 30.2295C23.3381 30.4669 23.5906 30.5897 24.0129 30.3426C24.4482 30.089 24.6457 29.8516 24.602 29.3186C24.4126 27.0398 24.6165 24.8046 25.5146 22.6711C25.6473 22.3561 25.7994 22.046 25.9758 21.7537C26.2768 21.2547 26.7639 21.1109 27.2121 21.3564C27.6587 21.6019 27.772 22.0703 27.5665 22.6162C27.2348 23.4996 26.8205 24.3717 26.6441 25.2875C26.4176 26.46 26.3917 27.6713 26.28 28.8519C27.2348 28.6355 28.0439 28.4514 28.8028 28.2802C29.2931 27.1319 29.7705 25.9399 30.311 24.7787C30.5683 24.2248 31.1104 24.0762 31.5732 24.3168C32.0489 24.5639 32.1331 25.0872 31.8806 25.6831C31.4728 26.6441 31.1104 27.6244 30.7349 28.5999C30.5942 28.9649 30.6767 29.246 30.9388 29.5803C31.4081 30.1762 31.7706 30.8578 32.2739 31.654C32.7593 31.2276 33.3111 30.882 33.6785 30.3959C34.8209 28.8842 35.6591 27.2223 35.9423 25.3133C36.3808 22.3577 34.2982 19.8786 31.4453 20.0272C30.9534 20.0531 30.4631 20.2275 29.9841 20.3712C29.3659 20.557 28.8853 20.3777 28.696 19.848C28.5164 19.3457 28.7462 18.9274 29.3417 18.6673C32.9147 17.1104 37.0831 19.4426 37.6964 23.3252C37.9634 25.0161 37.656 26.615 37.0395 28.1784C36.944 28.4207 36.8356 28.6581 36.6899 28.9972C36.9019 28.9116 37.0395 28.8729 37.1624 28.805C38.6253 27.9927 40.0849 27.1722 41.5494 26.3631C43.1514 25.4764 44.6482 25.906 45.5496 27.5049C46.0642 28.4191 46.5723 29.3364 47.0804 30.2521C48.0594 32.0142 47.6565 33.4451 45.9088 34.4206C42.1578 36.5137 38.4068 38.6052 34.6558 40.6967C34.4843 40.792 34.3176 40.8954 34.1558 41.1295H34.829C41.7937 41.1295 48.7585 41.1295 55.7232 41.1295C55.9255 41.1295 56.1277 41.1215 56.3284 41.1376C57.5728 41.2361 58.4304 42.1002 58.4321 43.3567C58.445 49.8363 58.4515 56.3175 58.4256 62.7971C58.4191 64.5575 57.1618 65.814 55.3963 65.9642C55.1957 65.982 54.9934 65.9868 54.7911 65.9868C44.9605 65.9868 35.1284 65.9901 25.2978 65.982C24.8576 65.982 24.4013 65.9578 23.979 65.8463C22.5015 65.4571 21.6083 64.1909 21.6051 62.5226C21.5986 57.9196 21.6034 53.3167 21.6034 48.7138C21.6034 48.5006 21.6034 48.2891 21.6034 47.9693C20.0985 48.8059 18.6955 49.5876 17.2909 50.3676C16.7262 50.681 16.1695 51.0088 15.5918 51.2947C14.2746 51.9472 12.8182 51.5434 12.0641 50.282C11.3926 49.1564 10.7566 48.0097 10.1514 46.8468C9.45237 45.5063 9.9087 44.0205 11.2453 43.2533C12.7486 42.3909 14.273 41.5624 15.7876 40.7161C15.9543 40.6224 16.1145 40.5158 16.2682 40.4205C15.2229 40.1234 14.1743 39.9118 13.192 39.529C10.9185 38.6423 9.4103 37.0467 8.94587 34.5821C8.93454 34.5256 8.88924 34.4771 8.86011 34.4254C8.86011 33.8602 8.86011 33.2949 8.86011 32.7296ZM34.7837 42.9449C33.5231 42.9449 32.337 42.9255 31.1508 42.9578C30.8061 42.9675 30.4307 43.0628 30.1297 43.2259C28.0584 44.3532 26.0098 45.5209 23.9385 46.6498C23.5534 46.8597 23.4077 47.0891 23.4094 47.5365C23.4272 52.4608 23.4191 57.3835 23.4207 62.3078C23.4207 63.6806 23.9029 64.1667 25.2784 64.1683C28.2445 64.1715 31.2107 64.1699 34.1769 64.1683C34.3694 64.1683 34.562 64.1489 34.7837 64.1376C34.7837 63.729 34.7837 63.3866 34.7837 63.0458C34.7837 60.5231 34.7788 58.0004 34.7869 55.4793C34.7902 54.6508 35.4326 54.1711 36.0815 54.4925C36.5265 54.7121 36.6058 55.1062 36.6042 55.5601C36.5961 58.2039 36.5993 60.8477 36.6009 63.49C36.6009 63.7015 36.6187 63.9147 36.6284 64.1166H43.4297V42.9852H36.5993C36.5993 43.242 36.5993 43.4617 36.5993 43.6797C36.5993 45.9795 36.5993 48.281 36.5993 50.5808C36.5993 50.7617 36.6187 50.9491 36.5831 51.1235C36.486 51.5902 36.2028 51.8761 35.7061 51.8842C35.2093 51.8923 34.9148 51.6145 34.8063 51.1509C34.761 50.9588 34.7837 50.7488 34.7821 50.5485C34.7821 48.0468 34.7821 45.5467 34.7821 42.9465L34.7837 42.9449ZM45.336 42.9449V64.1425C45.5625 64.1538 45.7421 64.1683 45.9201 64.1683C48.8863 64.1683 51.8508 64.1731 54.817 64.1683C56.1569 64.1667 56.6229 63.6886 56.6229 62.332C56.6229 56.1592 56.6229 49.9865 56.6229 43.8138C56.6229 42.9755 56.5906 42.9449 55.72 42.9449C52.4722 42.9449 49.2245 42.9449 45.9768 42.9449C45.7794 42.9449 45.5803 42.9449 45.3376 42.9449H45.336ZM21.639 31.4683C21.1196 31.163 20.5629 30.8013 19.9771 30.496C18.4577 29.7062 16.8702 29.1491 15.1225 29.2266C12.5043 29.3429 10.5349 31.3601 10.6935 33.8392C10.8197 35.7999 11.9929 37.037 13.7131 37.8025C15.4575 38.5794 17.312 38.6601 19.1745 38.5131C19.7231 38.4695 20.2522 38.195 20.8316 38.0141C20.4448 37.2744 19.9982 36.7172 19.8623 36.0922C19.6843 35.2653 19.168 35.0537 18.4884 34.9358C17.5952 34.7824 16.6987 34.6467 15.8103 34.4723C15.2811 34.3689 14.9866 33.9458 15.0481 33.4742C15.1112 32.9945 15.4963 32.6828 16.0352 32.7022C16.3168 32.7119 16.6 32.7393 16.8767 32.791C17.8767 32.9767 18.8752 33.1754 19.7069 33.3353C20.3882 32.6779 20.9869 32.0981 21.6407 31.465L21.639 31.4683ZM24.3787 44.3273C23.4676 42.6961 22.5792 41.1085 21.686 39.508C18.4787 41.2959 15.3442 43.0385 12.2163 44.7925C11.6094 45.1316 11.5026 45.5419 11.836 46.1572C12.3651 47.1311 12.9105 48.0953 13.4526 49.0611C13.904 49.8637 14.2649 49.9703 15.0724 49.5214C17.7845 48.0129 20.4934 46.4996 23.2022 44.9879C23.5857 44.7731 23.9692 44.5567 24.377 44.3257L24.3787 44.3273ZM35.7546 37.9979C38.9845 36.1955 42.1514 34.4384 45.3052 32.6618C45.8311 32.3646 45.9201 31.9269 45.6159 31.3665C45.0706 30.3571 44.5091 29.3558 43.9427 28.3577C43.5543 27.6729 43.1385 27.5582 42.4394 27.9426C41.2581 28.5935 40.0833 29.2556 38.9052 29.913C36.9731 30.9902 35.0394 32.0658 33.0619 33.1673C33.9568 34.7743 34.8355 36.3506 35.753 37.9963L35.7546 37.9979ZM34.1655 38.8814C33.2545 37.2486 32.3726 35.669 31.4728 34.0572C28.7332 35.5834 26.0308 37.0887 23.2783 38.623C24.1828 40.2461 25.0696 41.8337 25.971 43.4488C28.7413 41.9048 31.4421 40.3979 34.1655 38.8814ZM22.3883 37.037C25.1473 35.4978 27.8594 33.9861 30.5893 32.4631C30.2705 31.9043 30.0229 31.4182 29.7252 30.9644C29.2527 30.2392 28.4144 29.9776 27.6604 30.3846C25.8156 31.3794 23.9838 32.4002 22.1682 33.4483C21.4432 33.8666 21.1973 34.7097 21.5339 35.451C21.7717 35.9791 22.0808 36.4749 22.3883 37.037Z" fill="white"/> 17 <path d="M60.1183 38.3158C60.1862 37.5535 60.2332 36.788 60.327 36.0273C60.3853 35.5541 60.2833 35.181 59.9516 34.8225C59.4467 34.275 58.9791 33.6919 58.5163 33.1057C57.8204 32.2254 58.0939 31.3775 59.1749 31.0804C59.9516 30.8672 60.7445 30.717 61.5164 30.4876C61.7559 30.4166 62.01 30.2244 62.1491 30.0144C62.5957 29.3442 62.9744 28.6303 63.4097 27.9536C64.0311 26.9878 64.9664 26.9846 65.5878 27.9456C66.0247 28.6223 66.405 29.3361 66.8516 30.0047C66.9908 30.2131 67.2416 30.4053 67.4795 30.4763C68.2303 30.7025 69.0038 30.851 69.7611 31.0594C70.936 31.3824 71.2046 32.1948 70.457 33.1412C70.0702 33.6322 69.6996 34.1458 69.253 34.5754C68.732 35.076 68.6106 35.6381 68.7028 36.318C68.7918 36.9769 68.8339 37.6423 68.8679 38.3061C68.9213 39.3672 68.2303 39.8937 67.227 39.5336C66.4519 39.2542 65.7059 38.8908 64.9292 38.6162C64.6751 38.5258 64.3353 38.5225 64.0813 38.6114C63.3045 38.8859 62.5601 39.2509 61.785 39.532C60.7995 39.8889 60.
170892 39.3511 60.1199 38.311L60.1183 38.3158ZM66.9099 37.5422C66.9099 36.5134 66.7124 35.588 66.9649 34.8063C67.2206 34.0117 67.9196 33.3608 68.5216 32.5081C66.473 32.5388 65.2091 31.5197 64.4939 29.6349C63.8191 31.5746 62.476 32.4952 60.4597 32.6195C62.0456 33.9358 62.5375 35.5169 62.0019 37.4986C63.6864 36.4343 65.303 36.4004 66.9099 37.5422Z" fill="white"/> 18 <path d="M42.4004 16.9939C42.4085 16.8324 42.3859 16.6628 42.4295 16.5126C42.8778 14.9767 42.313 13.7848 41.1965 12.7624C41.0055 12.5864 40.8502 12.3684 40.6932 12.16C40.0783 11.3428 40.3291 10.5159 41.3065 10.2284C42.0784 10.0007 42.8778 9.86664 43.6432 9.61954C43.949 9.5194 44.2614 9.27714 44.4507 9.01228C44.8488 8.45831 45.1627 7.84298 45.5219 7.25994C46.2728 6.03411 47.2049 6.04219 47.9589 7.28094C48.3376 7.8995 48.6823 8.54068 49.0884 9.13987C49.2276 9.34498 49.4881 9.52263 49.7293 9.59531C50.4995 9.82788 51.2908 9.98938 52.0659 10.2058C53.1469 10.5078 53.4107 11.3444 52.7084 12.2311C52.2326 12.8319 51.7601 13.4375 51.2374 13.9963C50.9267 14.329 50.8588 14.673 50.9041 15.0946C50.9834 15.8359 51.0481 16.5804 51.1015 17.3233C51.1856 18.47 50.4542 19.0369 49.383 18.638C48.6855 18.378 47.9962 18.0921 47.3198 17.7804C46.9249 17.5995 46.5819 17.5672 46.1773 17.7691C45.6384 18.0388 45.0478 18.2036 44.5089 18.4749C42.949 19.2598 42.0962 18.3424 42.3972 16.9955L42.4004 16.9939ZM49.1418 16.6499C49.1418 15.6469 48.9477 14.7247 49.1952 13.943C49.4477 13.1484 50.137 12.4911 50.6354 11.774C49.8085 11.5043 48.8668 11.4106 48.2146 10.9261C47.5657 10.4432 47.2097 9.56947 46.6288 8.72641C46.0495 10.7178 44.6837 11.6044 42.6982 11.7563C44.2921 13.0644 44.7468 14.6375 44.2419 16.5982C45.9216 15.571 47.5382 15.5129 49.1418 16.6499Z" fill="white"/> 19 <path d="M61.1019 14.1241C58.5823 14.0659 56.5822 11.9938 56.6486 9.50986C56.7165 6.98392 58.7684 5.00871 61.2702 5.06362C63.7897 5.11853 65.7817 7.18418 65.7218 9.67783C65.6603 12.1989 63.6004 14.1822 61.1019 14.1241ZM61.2054 12.3088C62.7201 12.2974 63.9289 11.0668 63.9062 9.55832C63.8836 8.04339 62.6505 6.84987 61.1358 6.87894C59.6439 6.9064 58.4626 8.10961 58.4658 9.59869C58.469 11.1104 59.6924 12.3201 61.207 12.3088H61.2054Z" fill="white"/> 20 <path d="M54.9206 24.6934C54.809 28.3434 54.5776 31.5267 53.296 34.5064C52.8639 35.511 52.2118 36.4284 51.592 37.3409C51.2619 37.8286 50.6518 37.8496 50.2651 37.5104C49.8718 37.1648 49.8168 36.6674 50.1987 36.2152C51.9609 34.1253 52.4788 31.5848 52.8202 28.9878C53.173 26.2955 53.1341 23.5935 52.9302 20.8915C52.8963 20.4522 52.9853 20.0291 53.427 19.8999C53.7118 19.8159 54.1455 19.845 54.3591 20.0162C54.5857 20.1954 54.7184 20.5976 54.7394 20.9125C54.8365 22.3209 54.8786 23.7324 54.9206 24.6934Z" fill="white"/> 21 <path d="M69.8697 13.3354C70.4312 13.3419 70.7532 13.5971 70.8487 14.0622C70.9458 14.5338 70.7354 14.9037 70.2775 15.07C69.7289 15.2687 69.1545 15.3979 68.6124 15.6094C64.706 17.1437 62.3758 20.109 61.0651 23.9835C60.7609 24.8831 60.4016 25.219 59.8174 25.0398C59.1977 24.8508 59.0261 24.3453 59.3368 23.4328C61.0457 18.4132 64.2351 14.8875 69.4652 13.4356C69.6189 13.392 69.7775 13.3597 69.8681 13.3387L69.8697 13.3354Z" fill="white"/> 22 </svg> 23 `, 24 birthday: `<svg width="81" height="81" viewBox="0 0 81 81" fill="none" xmlns="http://www.w3.org/2000/svg"> 25 <path d="M40.3803 12.1963C40.64 12.459 40.9562 12.6835 41.1516 12.9902C42.3995 14.9393 43.6 16.9103 44.3894 19.1231C45.0703 21.0328 44.1319 23.3823 42.4548 24.3626C40.5485 25.4771 38.2255 25.1334 36.8579 23.5269C35.5151 21.9494 35.3152 20.1694 36.2232 18.3489C37.1831 16.4242 38.2831 14.5724 39.3469 12.7021C39.47 12.4856 39.7467 12.363 39.9522 12.1963C40.0945 12.1963 40.2368 12.1963 40.3791 12.1963H40.3803ZM40.1521 14.7552C39.1448 16.4543 38.1577 18.0387 37.5863 19.8384C37.2611 20.865 37.6902 21.9992 38.5937 22.6774C39.479 23.3418 40.7947 23.3487 41.6982 22.6936C42.5971 22.0409 43.0522 20.8835 42.7315 19.8639C42.1612 18.0491 41.173 16.4496 40.1533 14.7564L40.1521 14.7552Z" fill="white"/> 26 <path d="M15.9372 66.3798C15.9372 66.1611 15.9372 66.0025 15.9372 65.8428C15.9372 62.8881 15.9304 59.9333 15.9462 56.9785C15.9485 56.5908 15.8412 56.3686 15.5205 56.1418C14.1314 55.1615 13.3228 53.7807 13.2856 52.0562C13.2223 49.1582 13.2167 46.2555 13.2743 43.3574C13.3273 40.6885 15.2822 38.846 17.9711 38.8113C19.07 38.7974 20.1699 38.809 21.332 38.809C21.332 38.5382 21.332 38.324 21.332 38.1088C21.332 35.4283 21.332 32.7467 21.332 30.0662C21.332 28.9702 21.5827 28.7167 22.6544 28.7167C24.1847 28.7167 25.7149 28.7156 27.2463 28.7167C28.2186 28.7167 28.5055 29.0165 28.5066 30.0326C28.5088 32.7316 28.5066 35.4318 28.5066 38.1308C28.5066 38.3287 28.5066 38.5277 28.5066 38.7673H36.5598C36.5598 38.574 36.5598 38.3657 36.5598 38.1562C36.5598 34.8554 36.5598 31.5534 36.5598 28.2526C36.5598 27.1439 36.8331 26.8684 37.9229 26.8672C39.4531 26.8672 40.9834 26.8649 42.5147 26.8672C43.4317 26.8696 43.7344 27.1705 43.7355 28.1114C43.74 31.4307 43.7378 34.7501 43.7378 38.0694C43.7378 38.2859 43.7378 38.5023 43.7378 38.7627H51.8091C51.8091 38.5648 51.8091 38.3703 51.8091 38.1759C51.8091 35.4584 51.8091 32.7409 51.8091 30.0234C51.8091 29.0049 52.0891 28.7167 53.0716 28.7156C54.6561 28.7144 56.2394 28.7121 57.8238 28.7156C58.6731 28.7179 58.9724 29.0269 58.9735 29.9076C58.9769 32.6437 58.9746 35.3797 58.9746 38.1146C58.9746 38.3136 58.9746 38.5115 58.9746 38.7731C59.1892 38.7847 59.3755 38.802 59.563 38.8055C60.6833 38.8252 61.8047 38.8101 62.9227 38.8669C65.0922 38.9768 67.0335 40.8228 67.0572 43.5172C67.0809 46.2347 67.0911 48.9522 67.0516 51.6697C67.0233 53.5955 66.2181 55.1406 64.6596 56.2575C64.5241 56.3547 64.3886 56.5665 64.3875 56.7262C64.3773 59.8997 64.3875 63.0721 64.3943 66.2456C64.3943 66.2618 64.4044
2666.2792 64.4383 66.3775C64.8471 66.3775 65.2842 66.3706 65.7212 66.381C65.9505 66.3868 66.1842 66.3984 66.4067 66.4528C66.8291 66.5546 67.0369 66.8856 67.0414 67.2942C67.047 67.7328 66.8087 68.0638 66.3762 68.1726C66.156 68.2282 65.9177 68.2212 65.6873 68.2212C48.656 68.2235 31.6247 68.2235 14.5944 68.2224C13.7124 68.2224 13.2743 67.9238 13.2652 67.3173C13.2551 66.6923 13.7079 66.3787 14.6215 66.3775C15.0304 66.3775 15.4392 66.3775 15.9395 66.3775L15.9372 66.3798ZM62.558 57.1764C62.1842 57.1764 61.8646 57.1799 61.5461 57.1764C58.9441 57.1475 56.6256 55.0573 56.3885 52.4278C56.2722 51.1431 56.323 49.8433 56.2891 48.5506C56.2812 48.2427 56.271 47.9267 56.2021 47.6293C56.0181 46.8342 55.3077 46.2208 54.5827 46.1918C53.7933 46.1606 53.0841 46.6178 52.8401 47.37C52.7419 47.6744 52.7204 48.0124 52.7069 48.3365C52.6798 49.0286 52.7114 49.7241 52.664 50.4139C52.4449 53.6719 48.9925 56.1012 45.9467 55.1545C43.4396 54.3756 41.9839 52.371 41.9546 49.6767C41.9478 49.0216 41.9568 48.3608 41.8676 47.7149C41.7637 46.9661 41.2702 46.465 40.5836 46.2509C39.9444 46.0518 39.3458 46.2439 38.8727 46.7428C38.4774 47.1582 38.3532 47.6779 38.3543 48.2473C38.3577 50.0887 38.3803 51.9312 38.343 53.7726C38.2877 56.5318 35.9195 58.9414 33.2272 59.0282C30.1012 59.1289 27.6427 56.6846 27.5975 53.4034C27.5749 51.7993 27.5952 50.194 27.5918 48.5899C27.5918 48.3168 27.5873 48.0413 27.5489 47.7717C27.4495 47.0749 26.8363 46.3666 26.1949 46.2347C25.4721 46.0854 24.8171 46.281 24.4071 46.9152C24.1858 47.2566 24.0593 47.7184 24.0424 48.1316C23.9938 49.2971 24.0401 50.4649 24.0209 51.6315C23.9746 54.4659 22.2196 56.5978 19.5014 57.0943C18.9367 57.1973 18.3506 57.173 17.7724 57.2077V66.337H62.558V57.1776V57.1764ZM40.1612 40.6538C32.8308 40.6538 25.5003 40.6527 18.171 40.6585C17.8006 40.6585 17.4189 40.6793 17.0609 40.7661C15.9767 41.03 15.1004 42.023 15.088 43.1364C15.0541 46.1074 15.0315 49.0806 15.0993 52.0516C15.1399 53.8073 16.6826 55.2506 18.3878 55.3235C20.5573 55.4161 22.1733 53.8675 22.2185 51.6245C22.2422 50.422 22.205 49.2172 22.2298 48.0147C22.2705 46.0622 23.6765 44.4951 25.4642 44.369C27.6551 44.2151 29.3649 45.8238 29.3852 48.0807C29.401 49.8491 29.3705 51.6188 29.3942 53.3861C29.4168 55.0075 30.1159 56.2482 31.5919 56.8883C32.9742 57.4878 34.2842 57.2366 35.4079 56.2019C36.2379 55.4381 36.5609 54.4462 36.5621 53.312C36.5643 51.3989 36.5214 49.4811 36.6366 47.5737C36.7507 45.6849 38.3633 44.3238 40.2425 44.3505C42.0393 44.3759 43.5774 45.8539 43.7028 47.708C43.7604 48.5621 43.7288 49.4221 43.7931 50.275C43.9264 52.0586 45.495 53.4914 47.3008 53.5203C49.075 53.5492 50.6876 52.121 50.8491 50.3271C50.9271 49.4579 50.9 48.5795 50.9496 47.7068C51.0343 46.215 52.1106 44.8805 53.5132 44.4894C55.8238 43.8459 58.0203 45.5229 58.087 48.0078C58.1197 49.2288 58.0904 50.451 58.0983 51.672C58.105 52.7692 58.4913 53.7124 59.3066 54.4242C60.436 55.4103 61.7437 55.6325 63.0967 55.0411C64.479 54.4358 65.222 53.2761 65.2458 51.7356C65.2864 49.1292 65.2593 46.5205 65.2593 43.9141C65.2593 41.7128 64.2328 40.6527 62.0983 40.6527C54.786 40.6527 47.4736 40.6527 40.1612 40.6527V40.6538ZM41.9241 28.763H38.3983V38.78H41.9241V28.763ZM26.6884 30.5998H23.1446V38.7708H26.6884V30.5998ZM57.1474 38.7812V30.6055H53.6442V38.7812H57.1474Z" fill="white"/> 27 <path d="M29.4259 22.3071C29.3514 24.6623 27.628 26.5928 25.3468 26.8382C23.1299 27.0766 21.0271 25.5037 20.5325 23.2596C20.2874 22.1508 20.5031 21.0918 20.9944 20.1381C21.9712 18.2447 23.0271 16.3917 24.0943 14.5492C24.4851 13.8745 25.2722 13.849 25.6878 14.4879C27.0758 16.6221 28.4603 18.7643 29.2203 21.2434C29.3254 21.586 29.3593 21.9517 29.4259 22.3071ZM24.9142 16.6058C24.6048 17.1162 24.301 17.541 24.074 18.0063C23.471 19.2412 22.8352 20.4657 22.3405 21.7457C21.9678 22.7087 22.4805 23.8799 23.3592 24.5199C24.2717 25.1843 25.5523 25.1854 26.4625 24.5246C27.3378 23.888 27.8076 22.7225 27.5026 21.7434C26.9312 19.9113 25.9419 18.2956 24.9154 16.6058H24.9142Z" fill="white"/> 28 <path d="M50.9248 22.2332C50.953 21.1603 51.4138 20.0805 51.9547 19.0632C52.7611 17.5458 53.6532 16.0737 54.5443 14.605C54.9746 13.8955 55.7493 13.8307 56.1694 14.4788C57.5076 16.5412 58.847 18.6071 59.6229 20.9855C60.2316 22.8501 59.5686 24.8627 57.9503 26.0432C56.4257 27.1555 54.2236 27.1242 52.7543 25.9703C51.5956 25.0606 50.9869 23.8593 50.9248 22.2332ZM55.4432 16.6778C55.3698 16.6616 55.2953 16.6442 55.2219 16.628C54.4291 18.2866 53.5787 19.9196 52.865 21.614C52.4279 22.651 52.9248 23.8547 53.8577 24.5317C54.7622 25.188 56.044 25.1822 56.9543 24.5178C57.8589 23.8581 58.3049 22.6811 57.9594 21.6371C57.3699 19.8536 56.4122 18.2611 55.4432 16.679V16.6778Z" fill="white"/> 29 </svg> 30 ` 31}; 32 33console.log("====VOUCHER WIDGET===="); 34// Function to create a voucher widget from a JSON object 35/** 36 * @typedef {{ 37 * discount: string, 38 * quantity: number, 39 * condition: string, 40 * badge: string, 41 * isShowQuantity: boolean, 42 * isHoverable: boolean, 43 * expiry: string, 44 * highlightExpiry: Object, 45 * icon: string, 46 * buttonText: string, 47 * isShowButton: boolean 48 * }} voucherData 49 */ 50function createVoucherWidget(voucherData) { 51 // predefine value 52 // check voucherData.isShowCounter has value or undefine 53 console.log("====VOUCHER WIDGET==== create voucher widget", voucherData); 54 var isShowQuantity = true; 55 isShowQuantity = 56 voucherData.isShowQuantity === undefined 57 ? true 58 : voucherData.isShowQuantity; 59 60 var isShowButton = true; 61 isShowButton = 62 voucherData.isShowButton === undefined ? true : voucherData.isShowButton; 63 64 if(voucherData.is_show_in_voucher_shop === false) { 65 isShowButton = false;
66 } 67 68 var highlightExpiry = { isHighlightExpiry: false, highlightType: "danger" }; 69 highlightExpiry = voucherData.highlightExpiry; 70 71 var isHoverable = false; 72 isHoverable = voucherData.isHoverable; 73 74 // Create the main voucher widget div 75 const voucherWidget = document.createElement("div"); 76 voucherWidget.classList.add("voucher-widget"); 77 78 if (isHoverable && isShowButton) { 79 voucherWidget.classList.add("hoverable"); 80 } 81 82 // Create mask div 83 const voucherMask = document.createElement("div"); 84 voucherMask.classList.add("voucher-widget-mask"); 85 86 // Create icon div and svg 87 const voucherIcon = document.createElement("div"); 88 voucherIcon.classList.add("voucher-widget-icon"); 89 voucherIcon.innerHTML = widgetIcons[voucherData.icon]; 90 91 voucherMask.appendChild(voucherIcon); 92 93 // Append mask to main voucher widget 94 voucherWidget.appendChild(voucherMask); 95 96 // Create voucher body frame 97 const voucherBodyFrame = document.createElement("div"); 98 voucherBodyFrame.classList.add("voucher-widget-body-frame"); 99 100 // Create voucher body 101 const voucherBody = document.createElement("div"); 102 voucherBody.classList.add("voucher-widget-body"); 103 104 // Create voucher header (discount) 105 const voucherHeader = document.createElement("div"); 106 voucherHeader.classList.add("voucher-widget-header"); 107 voucherHeader.textContent = voucherData.discount; 108 109 // Create voucher counter (quantity) 110 const voucherCounter = document.createElement("div"); 111 voucherCounter.classList.add("voucher-widget-counter"); 112 const voucherCounterSpan = document.createElement("span"); 113 voucherCounterSpan.textContent = "Ã" + voucherData.quantity; 114 voucherCounter.appendChild(voucherCounterSpan); 115 116 // Create a container for header and counter 117 const voucherHeaderCounterContainer = document.createElement("div"); 118 voucherHeaderCounterContainer.appendChild(voucherHeader); 119 if (isShowQuantity && voucherData.quantity > 0) { 120 voucherHeaderCounterContainer.appendChild(voucherCounter); 121 } 122 123 // Append header and counter container to body 124 voucherBody.appendChild(voucherHeaderCounterContainer); 125 126 // Create voucher text (condition) 127 const voucherTextMuted = document.createElement("div"); 128 voucherTextMuted.classList.add( 129 "voucher-widget-text-muted", 130 "voucher-widget-grow" 131 ); 132 voucherTextMuted.textContent = voucherData.condition; 133 134 // Append text to body 135 voucherBody.appendChild(voucherTextMuted); 136 137 // Create voucher badge div 138 const voucherBadge = document.createElement("div"); 139 voucherBadge.classList.add("voucher-widget-badge"); 140 voucherBadge.textContent = voucherData.badge; 141 142 // Create voucher badge container 143 const voucherBadgeContainer = document.createElement("div"); 144 voucherBadgeContainer.appendChild(voucherBadge); 145 146 // Append badge to body 147 voucherBody.appendChild(voucherBadgeContainer); 148 149 // Create voucher footer (expiry and button) 150 const voucherFooter = document.createElement("div"); 151 voucherFooter.classList.add("voucher-widget-body__footer"); 152 153 var voucherExpiry = document.createElement("div"); 154 if (highlightExpiry.isHighlightExpiry === true) { 155 switch (highlightExpiry.highlightType) { 156 case "danger": 157 voucherExpiry.classList.add("voucher-widget-text-danger"); 158 break; 159 case "warning": 160 voucherExpiry.classList.add("voucher-widget-text-warning"); 161 break; 162 default: 163 voucherExpiry.classList.add("voucher-widget-text-muted"); 164 } 165 } else { 166 voucherExpiry.classList.add("voucher-widget-text-muted"); 167 } 168 voucherExpiry.textContent = voucherData.expiry; 169 170 const voucherButton = document.createElement("div"); 171 voucherButton.classList.add("voucher-widget-button"); 172 voucherButton.textContent = voucherData.buttonText; 173 174 // Append expiry and button to footer 175 voucherFooter.appendChild(voucherExpiry); 176 if (isShowButton) { 177 voucherFooter.appendChild(voucherButton); 178 } 179 // Append footer to body 180 voucherBody.appendChild(voucherFooter); 181 182 // Append body to body frame 183 voucherBodyFrame.appendChild(voucherBody); 184 185 // Append body frame to main voucher widget 186 voucherWidget.appendChild(voucherBodyFrame); 187 188 return voucherWidget; 189} 190 191// =============================================== 192// ====== Formatting function ====== 193// =============================================== 194 195function _getEntitlement(data, shop, translationMap) { 196 var translationMap = { 197 free_shipping: translationMap?.free_shipping || "FREE SHIPPING", 198 free_of_charge: translationMap?.free_of_charge || "FREE" 199 }; 200 201 // check weather is shipping discount
202 let isShippingDiscount = 203 data.details.target_type == "shipping" || 204 data.details.target_type == "pickup" || 205 data.details.target_type == "shipping_or_pickup"; 206 207 switch (data.details.value_type) { 208 case "fixed_amount": 209 return ( 210 shop.money_prefix + 211 "" + 212 Number(data.details.value).toFixed(shop.format_decimals) + 213 " " + 214 _getTargetType(data.details.target_type, _getTargetTypeTranslation) 215 ); 216 217 case "percentage": 218 if (isShippingDiscount) { 219 // by default, shipping discount is 100% off 220 return translationMap.free_shipping; 221 } else if (Number(data.details.value) == "100") { 222 return translationMap.free_of_charge; 223 } else { 224 return ( 225 Number(data.details.value) + 226 "%" + 227 " " + 228 _getTargetType(data.details.target_type, _getTargetTypeTranslation) 229 ); 230 } 231 232 case "free_of_charge": 233 return translationMap.free_of_charge; 234 235 case "set_price": 236 return ( 237 shop.money_prefix + 238 "" + 239 Number(data.details.value).toFixed(shop.format_decimals) 240 ); 241 242 default: 243 return "-"; 244 } 245} 246 247function _getTargetType(targetType, translationMap) { 248 var translationMap = { 249 amount_credit: translationMap?.amount_credit || "credit", 250 amount_off: translationMap?.amount_off || "off" 251 }; 252 253 switch (targetType) { 254 case "credit": 255 return translationMap.amount_credit; 256 case "shipping": 257 case "pickup": 258 case "shipping_or_pickup": 259 case "line_item": 260 return translationMap.amount_off; 261 default: 262 return translationMap.amount_off; 263 } 264} 265 266function getVoucherCondition(data) { 267 let prerequisite = _getPrerequisite(data, shop, _getPrerequisiteTranslation); 268 let entitlement = _getEntitlement(data, shop, _getEntitlementTranslation); 269 270 return entitlement + " . " + prerequisite; 271} 272 273function _getPrerequisite(data, shop, translationMap) { 274 var prerequisite_subtotal_range = 275 data.details.prerequisite_subtotal_range || null; 276 var prerequisite_quantity_range = 277 data.details.prerequisite_quantity_range || null; 278 279 var translationMap = { 280 min_quantity: translationMap?.min_quantity || "Minimum quantity", 281 every_quantity: translationMap?.every_quantity || "Every quantity", 282 min_amount: translationMap?.min_amount || "Minimum amount", 283 every_amount: translationMap?.every_amount || "Every amount" 284 }; 285 286 // check for quantity purchase, then check for `greater_than_or_equal_to` or `every` 287 if (prerequisite_quantity_range != null) { 288 if ("greater_than_or_equal_to" in prerequisite_quantity_range) { 289 return translationMap.min_quantity.replace( 290 "formatValue", 291 Number( 292 data.details.prerequisite_quantity_range.greater_than_or_equal_to 293 ).toFixed(0) 294 ); 295 } else { 296 return translationMap.every_quantity.replace( 297 "formatValue", 298 Number(data.details.prerequisite_quantity_range.every).toFixed(0) 299 ); 300 } 301 } 302 // check for amount purchase, then check for `greater_than_or_equal_to` or `every` 303 else if (prerequisite_subtotal_range != null) { 304 if ("greater_than_or_equal_to" in prerequisite_subtotal_range) { 305 return translationMap.min_amount.replace( 306 "formatCurrency", 307 shop.money_prefix + 308 Number( 309 data.details.prerequisite_subtotal_range.greater_than_or_equal_to 310 ).toFixed(shop.format_decimals) 311 ); 312 } else { 313 return translationMap.every_amount.replace( 314 "formatCurrency", 315 shop.money_prefix + 316 Number(data.details.prerequisite_subtotal_range.every).toFixed( 317 shop.format_decimals 318 ) 319 ); 320 } 321 } else { 322 return ""; 323 } 324} 325 326// TODO: to be remove 327function _getPrerequisiteCondition(data, translationMap) { 328 var translationMap = { 329 selected_items: translationMap?.selected_items || "Selected items", 330 selected_collections: 331 translationMap?.selected_collections || "Selected collections", 332 storewide: translationMap?.storewide || "Storewide", 333 order_subtotal: translationMap?.order_subtotal || "Order subtotal" 334 }; 335 336 switch (data.details.prerequisite_conditions) { 337 case "selected_items": 338 return translationMap.selected_items; 339 case "selected_collections": 340 return translationMap.selected_collections; 341 case "storewide": 342 return translationMap.storewide; 343 case "order_subtotal": 344 return translationMap.order_subtotal; 345 default: 346 return translationMap.order_subtotal; 347 } 348} 349 350function getPrerequisiteCondition(data, translationMap) { 351 var translationMap = { 352 selected_items: translationMap?.selected_items || "Selected items", 353 selected_collections: 354 translationMap?.selected_collections || "Selected collections", 355 storewide: translationMap?.storewide || "Storewide", 356 order_subtotal: translationMap?.order_subtotal || "Order subtotal" 357 }; 358 359 switch (data.details.prerequisite_conditions) { 360 case "selected_items": 361 return translationMap.selected_items; 362 case "selected_collections": 363 return translationMap.selected_collections; 364 case "storewide": 365 return translationMap.storewide; 366 case "order_subtotal": 367 return translationMap.order_subtotal; 368 default: 369 return translationMap.order_subtotal; 370 } 371} 372 373function getVoucherIcon(data) { 374 if (data.redemption_setting?.event_type == "birthday") { 375 return "birthday"; 376 } else if (data.details.promotion_applies_to == "order_shipping_fee") { 377 return "shipping"; 378 } else if (data.details.value_type == "free_of_charge" || (data.details.value_type == "percentage" && Number(data.details.value) == "100")) { 379 return "gift"; 380 } else { 381 return "default"; 382 } 383} 384 385function getVoucherExpiry(data, translationMap) { 386 var translationMap = { 387 used: translationMap?.used || "Used", 388 expired: translationMap?.expired || "Expired", 389 valid_from: translationMap?.valid_from || "Valid from startDateTime", 390 days_left: translationMap?.days_left || "Ends in daysLeft days", 391 ends_today: translationMap?.ends_today || "Ends today", 392 ends_at: translationMap?.ends_at || "Ends at expiryDateTime" 393 }; 394 395 var expiryDateTime = formatISODate(data.ends_at); 396 var startDateTime = formatISODate(data.details.starts_at); 397 var endTime = formatISODate(data.ends_at, true); 398 var discountText = ""; 399 400 // get remaining days from expiryDateTime to current date 401 let daysLeft = expiryDateTime 402 ? Math.floor((new Date(data.ends_at) - new Date()) / (1000 * 60 * 60 * 24)) 403 : 0; 404 405 // check whether date is today and put in const isToday 406 const isToday = 407 expiryDateTime == formatISODate(new Date(), true) ? true : false;
408 409 const isLessThan8DaysLeft = daysLeft < 8 && daysLeft > 0; 410 411 // if (data.is_expired_in_a_week) { 412 // return `Ends at ${expiryDateTime}`; 413 // } else 414 415 if (data.datatype == "inactive") { 416 if (data.is_expired) { 417 return translationMap.expired; 418 } else if (data.is_used) { 419 return translationMap.used; 420 } 421 } else if (data.is_scheduled) { 422 discountText = translationMap.valid_from.replace( 423 "startDateTime", 424 startDateTime 425 ); 426 return discountText; 427 } else if (data.is_expired_in_a_week) { 428 if (isToday) { 429 // for today 430 discountText = translationMap.ends_today.replace("endTime", endTime); 431 return discountText; 432 } else if (isLessThan8DaysLeft) { 433 // for less than 8 days 434 discountText = translationMap.days_left.replace("daysLeft", daysLeft); 435 return discountText; 436 } else { 437 // fallback for 0 days but not today 438 discountText = translationMap.days_left.replace("daysLeft", 1); 439 return discountText; 440 } 441 } else if (expiryDateTime) { 442 discountText = translationMap.ends_at.replace( 443 "expiryDateTime", 444 expiryDateTime 445 ); 446 return discountText; 447 } else { 448 return " "; 449 } 450} 451 452function getVoucherButtonText(data, translationMap) { 453 var translationMap = { 454 more_details: translationMap?.more_details || "View details", 455 free_redeem: translationMap?.free_redeem || "Redeem" 456 }; 457 switch (data.datatype) { 458 case "active": 459 return translationMap.more_details; 460 case "redeemable": 461 return translationMap.free_redeem; 462 case "inactive": 463 return ""; 464 default: 465 return ""; 466 } 467} 468 469function getVoucherUnavailableText(data, translationMap) { 470 var map = { 471 condition_not_matched: translationMap?.condition_not_matched || "Voucher condition not matched", 472 available_on: translationMap?.available_on || "Available on channels", 473 available_on_only: translationMap?.available_on_only || "Available on channels only", 474 available_with_locations: translationMap?.available_with_locations || "Available on channels (locations only)", 475 pos_at_locations: translationMap?.pos_at_locations || "Retail Store at locations only", 476 channel_website: translationMap?.channel_website || "Website", 477 channel_mobile: translationMap?.channel_mobile || "Mobile Apps", 478 channel_pos: translationMap?.channel_pos || "Retail Store", 479 promotion_unavailable: translationMap?.promotion_unavailable || "This promotion is currently unavailable" 480 }; 481 482 var details = data && data.unavailable_details; 483 if (!details || !details.unavailable_reason) { 484 return map.condition_not_matched; 485 } 486 487 var channelOrder = ["website", "mobile", "pos"]; 488 var rawChannels = (details.available_channels || "") 489 .split(",") 490 .map(function (c) { return c.trim(); }) 491 .filter(Boolean); 492 493 if (rawChannels.length === 0) { 494 return map.promotion_unavailable; 495 } 496 497 var channels = channelOrder.filter(function (c) { return rawChannels.indexOf(c) !== -1; }); 498 var hasAllChannels = channelOrder.every(function (c) { return channels.indexOf(c) !== -1; }); 499 500 var locationNames = (details.available_locations || []) 501 .map(function (l) { return l && l.name; }) 502 .filter(Boolean); 503 var hasLocations = locationNames.length > 0; 504 505 var channelLabelMap = { 506 website: map.channel_website, 507 mobile: map.channel_mobile, 508 pos: map.channel_pos 509 }; 510 511 function formatChannelList(items) { 512 var names = items.map(function (c) { return channelLabelMap[c] || c; }); 513 if (names.length <= 1) return names.join(""); 514 return names.slice(0, -1).join(", ") + " & " + names[names.length - 1]; 515 } 516 517 var locationText = locationNames.join(", "); 518 var channelText = formatChannelList(channels); 519 520 var text = ""; 521 if (hasLocations) { 522 if (hasAllChannels) { 523 text = map.available_on.replace("channels", channelText) 524 + " (" + map.pos_at_locations.replace("locations", locationText) + ")"; 525 } else if (channels.length > 0) { 526 text = map.available_with_locations 527 .replace("channels", channelText) 528 .replace("locations", locationText); 529 } 530 } else if (!hasAllChannels && channels.length > 0) { 531 if (channels.length === 1) { 532 text = map.available_on_only.replace("channels", channelText); 533 } else { 534 text = map.available_on.replace("channels", channelText); 535 } 536 } 537 538 return text || map.condition_not_matched; 539} 540 541function setVoucherTheme(data) { 542 document.documentElement.style.setProperty( 543 "--voucher-widget-theme-color", 544 data.primary_color 545 ); 546} 547 548// =============================================== 549// ====== Utilities function ====== 550// =============================================== 551 552function formatISODate(isoDate, isReturnTimeOnly = false) { 553 if (!isoDate) { 554 return null; 555 } 556 557 // Create a new Date object from the ISO string 558 const date = new Date(isoDate); 559 560 // Get the date components 561 const day = String(date.getDate()).padStart(2, "0");
562 const month = String(date.getMonth() + 1).padStart(2, "0"); // getMonth() is zero-based 563 const year = date.getFullYear(); 564 565 // Get the time components 566 let hours = date.getHours(); 567 const minutes = String(date.getMinutes()).padStart(2, "0"); 568 569 // Determine AM/PM suffix and convert hours to 12-hour format 570 const ampm = hours >= 12 ? "PM" : "AM"; 571 hours = hours % 12 || 12; // Convert 0 (midnight) to 12 572 573 // Format the time as hh:mm AM/PM 574 const formattedTime = `${String(hours).padStart(2, "0")}:${minutes} ${ampm}`; 575 576 if (isReturnTimeOnly) { 577 return formattedTime; 578 } else { 579 // Combine to form the final formatted string 580 const formattedDate = `${day}-${month}-${year}, ${formattedTime}`; 581 582 return formattedDate; 583 } 584}
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.