(function appEasyProtect($){let App=function App(){this.sessionId='a2e5d81f70d0a1d043bc50ca84ddc43f';this.sessionToken='042b35c94c464be712ce6f864a4607abc8a627282b56921e42ceb3dc3b13ab8d';this.listType='none';this.shopId=168;this.translations={"add_text":{"__default":"Dodaj","pl_PL":"Dodaj"},"no_option_text":{"__default":"brak","pl_PL":"brak"},"protectionAddText":{"__default":"Dodaj","pl_PL":"Dodaj"},"noOptionText":{"__default":"brak","pl_PL":"brak"},"infoPageText":{"__default":"dowiedz si\u0119 wi\u0119cej","pl_PL":"dowiedz si\u0119 wi\u0119cej"},"checkboxEnableEasyProtectText":{"__default":"jestem zainteresowany gwarancj\u0105 EP","pl_PL":"jestem zainteresowany gwarancj\u0105 EP"},"productIndexText2":{"__default":"Zyskaj nawet 3 lata dodatkowej ochrony dla swojego sprz\u0119tu","pl_PL":"Zyskaj nawet 3 lata dodatkowej ochrony dla swojego sprz\u0119tu"},"productIndexOptionText":{"__default":"Gwarancja","pl_PL":"Gwarancja"},"productIndexNoOptionText":{"__default":"podstawowa","pl_PL":"podstatowa"}};this.productId=33788;this.optionPriceRangeId=12;this.optionTimePeriodId=13;this.optionToProductId=14;this.optionDataId=15;this.infoPageId=27;this.checkboxEnableFieldId=5;this.noOption=1;this.checkboxEnableEasyProtect=0;this.addEasyProtectToProductIndex=0;this.productIds=[33769,33770,33771,33772,33773,33774,33775,33776,33804,33805,33806,33807,33808,33904,33908,33910,33911,33912,34543,34544,34545,34547,34548,34549,34550,34551,34552,34553,34554,34555,34556,34616,34627,34629,34632,34633,34635,34636,34752,34753,34754,34755,34756,34757,34758,34759,34760,34761,34762,34763,33672,33673,33674,33675,33676,33677,33678,33679,33680,33681,33682,33683,33684,33685,33686,33687,33688,33689,33690,33691,33692,33693,33694,33695,33696,33697,33698,33699,33700,33701,33702,33703,33704,33705,33741,33742,33743,33744,33745,33746,33747,33748,33749,33750,33751,33752,33753,33754,33755,33756,33594,33595,33596,33597,33599,33600,33601,33603,33604,33605,33619,33620,33621,33622,33623,33624,33625,33626,33627,33628,33629,33630,33631,33632,33646,33647,33648,33649,33650,33651,33652,33653,33654,33655,33656,33657,33658,33659,33660,33661,33662,33663,33664,33665,33666,33667,33668,33669,33670,33671,33533,33534,33535,33536,33537,33538,33539,33540,33541,33542,33543,33544,33555,33556,33557,33558,33559,33560,33561,33562,33563,33564,33565,33566,33567,33568,33569,33570,33571,33572,33573,33574,33575,33576,33577,33578,33579,33580,33581,33583,33584,33585,33586,33587,33588,33589,33590,33591,33592,33593,33483,33484,33485,33486,33487,33488,33489,33490,33491,33492,33493,33494,33495,33496,33497,33498,33499,33500,33501,33502,33503,33504,33505,33506,33507,33508,33509,33510,33511,33512,33513,33514,33515,33516,33517,33518,33519,33520,33521,33522,33523,33524,33525,33526,33527,33528,33529,33530,33531,33532,33147,33148,33186,33235,33280,33281,33282,33283,33284,33285,33286,33298,33344,33345,33346,33407,33408,33409,33451,33452,33453,33454,33455,33456,33457,33458,33459,33460,33461,33462,33463,33464,33465,33466,33467,33468,33469,33470,33471,33472,33473,33474,33475,33476,33477,33478,33479,33480,33481,33482,31605,31606,31607,31608,31609,31610,31611,31612,31613,31614,31615,31616,31617,31618,31619,31620,31621,31622,31623,31624,31625,31626,31627,31634,31649,31650,31803,31813,31814,31815,31816,31817,31818,31819,31820,31821,31822,31823,32746,32747,32748,32749,32750,32751,32752,33087,33118,33119,33145,33146,30577,30584,30585,30586,30587,30588,30589,30590,30591,30592,30593,30594,30595,30596,30597,31528,31529,31530,31531,31568,31574,31575,31576,31577,31578,31579,31580,31582,31583,31584,31585,31586,31587,31588,31589,31590,31591,31592,31593,31594,31595,31596,31597,31598,31599,31600,31601,31602,31603,31604,30172,30173,30174,30175,30176,30177,30178,30179,30180,30181,30182,30183,30199,30200,30201,30211,30212,30217,30218,30219,30220,30296,30297,30298,30299,30300,30301,30302,30303,30304,30305,30306,30307,30308,30309,30310,30311,30312,30313,30314,30315,30316,30317,30318,30319,30320,30321,30574,30575,30576,30119,30120,30121,30122,30123,30124,30125,30126,30127,30128,30129,30130,30131,30132,30133,30134,30135,30136,30137,30138,30139,30140,30141,30142,30143,30144,30145,30146,30147,30148,30149,30150,30151,30152,30153,30154,30155,30156,30157,30158,30159,30160,30164,30165,30166,30167,30168,30169,30170,30171,29925,29926,29927,29936,29968,30001,30003,30005,30006,30007,30008,30009,30010,30011,30012,30013,30014,30015,30016,30018,30024,30025,30026,30027,30028,30029,30059,30060,30061,30062,30063,30082,30084,30085,30086,30087,30088,30093,30094,30095,30096,30097,30103,30106,30107,30108,30112,30113,30114,30118,29234,29235,29236,29237,29578,29592,29593,29594,29597,29603,29605,29606,29607,29608,29609,29610,29616,29620,29621,29622,29623,29894,29895,29896,29897,29898,29899,29900,29901,29902,29903,29904,29905,29906,29907,29908,29909,29910,29911,29912,29913,29914,29915,29916,29917,29918,29919,29921,29922,29924,29153,29155,29157,29162,29164,29166,29168,29169,29170,29182,29185,29186,29187,29188,29189,29190,29191,29192,29193,29194,29195,29196,29197,29198,29199,29200,29201,29202,29203,29204,29208,29209,29210,29211,29212,29213,29214,29215,29216,29217,29218,29219,29220,29225,29228,29229,29230,29231,29232,29233,23279,27763,29127,29131,29135,29140,29144,29148,29150,29152,30203,30207,30208,30209,30210,33188,33706,33707,33708,33709,33710,33711,33712,33713,33714,33715,33716,33717,33718,33719,33720,33721,33722,33723,33724,33725,33726,33727,33728,33729,33730,33731,33732,33733,29712,29713,29714,29715,29717,29718,29719,29720,29721,29722,29723,29724,29725,33842,33877,33878,33879,31861,31862,31863,31864,31865,31866,31873,31874,31875,31876,31877,31878,31879,31880,31881,31882,31883,31884,31885,31886,31887,31888,31889,31890,31892,32093,32094,32095,32096,32097,32098,32099,32124,32125,32126,32127,32128,32129,32130,32157,32158,32159,32160,32161,32162,32163,33001,33002,33003,33085,31506,31507,31508,31509,31510,31511,31512,31513,31514,31515,31516,31517,31518,31519,31520,31521,31522,31523,31524,31525,31526,31527,31665,31668,31669,31670,31671,31672,31673,31674,31675,31676,31678,31679,31693,31694,31695,31696,31697,31698,31699,31700,31701,31730,31731,31732,31733,31734,31735,31736,31065,31066,31067,31068,31128,31129,31130,31131,31132,31251,31252,31253,31254,31255,31256,31257,31258,31259,31260,31261,31262,31263,31264,31265,31266,31267,31268,31269,31270,31271,31272,31273,31274,31275,31276,31277,31278,31279,31280,31281,31282,31497,31498,31499,31500,31501,31502,31503,31504,31505,30333,30334,30335,30336,30337,30338,30339,30340,30341,30342,30343,30347,30348,30349,30350,30861,30917,30918,30939,30940,30941,30942,30943,30944,30945,30946,30947,30948,30949,30950,30951,30952,30953,30954,30955,30956,30957,30958,30959,30960,30961,30963,30964,30965,30966,30967,30968,30969,31063,31064,29294,29342,29534,29655,30322,30323,30324,30325,30329,30332,33828,33829,33830,33831,33832,33833,33834,33835,33836,33837,33838,33843,33844,33845,33846,33847,33848,33849,33850,33851,33852,33853,33854,33855,33856,33857,33858,33859,33860,33862,33863,33864,33865,33866,33867,33868,33869,33870,33871,33872,33873,33874,33875,33876,34120,34126,34317,34322,34691,34740,33393,33394,33395,33396,33397,33398,33399,33400,33401,33402,33403,33404,33405,33410,33411,33412,33413,33414,33415,33416,33417,33418,33419,33420,33421,33422,33423,33424,33425,33426,33427,33428,33429,33430,33431,33432,33433,33434,33435,33438,33439,33440,33551,33612,33613,33787,33826,33827,33333,33334,33335,33336,33337,33338,33349,33350,33351,33352,33353,33354,33355,33356,33357,33358,33359,33360,33361,33362,33363,33364,33365,33366,33367,33368,33369,33370,33371,33372,33373,33374,33375,33376,33377,33378,33379,33380,33381,33382,33383,33384,33385,33386,33387,33388,33389,33390,33391,33392,33168,33169,33170,33171,33172,33173,33174,33175,33176,33177,33178,33179,33180,33181,33182,33183,33184,33185,33187,33189,33190,33191,33192,33206,33208,33209,33232,33233,33234,33238,33239,33240,33243,33271,33272,33273,33274,33322,33323,33324,33325,33326,33327,33328,33329,33330,33331,33332,33112,33113,33114,33115,33116,33117,33120,33121,33122,33123,33124,33125,33126,33127,33131,33132,33133,33134,33135,33136,33137,33138,33139,33140,33141,33142,33149,33150,33151,33152,33153,33154,33155,33156,33157,33158,33160,33161,33162,33163,33164,33165,33166,33167,32981,32982,32983,32984,32985,32986,32987,32988,32989,32990,32991,32992,32993,32994,32995,32996,32997,32998,32999,33000,33005,33006,33007,33008,33009,33010,33011,33012,33013,33014,33015,33016,33017,33018,33019,33020,33021,33022,33023,33066,33068,33070,33071,33073,33074,33086,33095,33109,33110,33111,32922,32923,32924,32925,32926,32927,32928,32929,32930,32931,32932,32933,32934,32935,32936,32937,32938,32939,32940,32941,32951,32952,32953,32954,32955,32956,32957,32958,32959,32960,32961,32962,32963,32964,32965,32966,32967,32968,32969,32970,32971,32972,32973,32974,32975,32976,32977,32978,32979,32980,32872,32873,32874,32875,32876,32877,32878,32879,32880,32881,32882,32883,32884,32885,32886,32887,32888,32889,32890,32891,32892,32893,32894,32895,32896,32897,32898,32899,32900,32901,32902,32903,32904,32905,32906,32907,32908,32909,32910,32911,32912,32913,32914,32915,32916,32917,32918,32919,32920,32921,32017,32018,32020,32025,32026,32053,32062,32063,32064,32065,32066,32071,32074,32075,32079,32080,32081,32083,32085,32087,32388,32489,32490,32491,32546,32547,32548,32549,32550,32551,32635,32636,32637,32638,32639,32640,32641,32642,32643,32644,32645,32651,32652,32656,32657,32721,32868,32869,32870,32871,30810,30811,30812,30813,30814,30815,30816,30817,30819,30820,30821,30822,30823,30824,30825,30826,30827,30828,30829,30830,30831,30832,30833,30834,30835,30836,30837,30838,30855,30857,30858,30860,30919,31030,31179,31180,31181,31203,31225,31227,31228,31229,31283,31305,31306,31307,31416,31532,31860,32015,29364,29394,29396,29398,29399,29400,29401,29402,29403,29405,29406,29407,29408,29409,29410,29411,29412,29413,29415,29418,29970,29972,30079,30080,30089,30090,30091,30092,30098,30099,30100,30101,30236,30249,30328,30523,30533,30540,30764,30768,30776,30777,30778,30779,30780,30781,30790,30791,30794,30809,28833,28837,28838,28839,28865,28866,28878,28879,28880,28881,28882,28883,28884,28885,28886,28887,28889,28890,28891,28892,28893,28895,28896,28897,28899,28900,28901,29151,29159,29161,29180,29181,29183,29184,29336,29337,29338,29339,29340,29341,29344,29346,29347,29348,29349,29351,29353,29355,29360,29361,27971,27972,27983,27984,28342,28345,28347,28349,28423,28424,28425,28426,28427,28428,28465,28466,28467,28468,28469,28470,28517,28524,28525,28526,28527,28528,28529,28530,28531,28532,28533,28534,28639,28640,28642,28690,28691,28693,28694,28710,28721,28793,28805,28823,28824,28825,28827,28830,28831,28832,20793,20794,20795,20796,20797,20798,20799,20800,20801,20802,20803,20804,20805,20806,21420,21421,21422,21952,21953,21954,21955,21956,21957,21958,21959,21960,21961,22080,22670,22671,22695,22863,24679,24681,24684,24686,25894,26843,26844,26845,26846,27778,27779,27822,27823,27824,27825,27826,27827,27897,20654,20702,20703,20704,20705,20706,20731,20732,20733,20734,20735,20749,20750,20754,20755,20756,20757,20758,20759,20760,20761,20762,20763,20764,20765,20766,20767,20768,20769,20770,20771,20772,20773,20774,20775,20776,20777,20778,20779,20780,20781,20782,20783,20784,20785,20786,20787,20790,20791,20792,17670,17671,17672,17676,17677,17679,17690,17693,17696,17706,17785,17793,17806,17812,20145,20176,20177,20178,20179,20284,20653,30474,30475,30476,30495,30496,30497,30498,30499,30500,30501,30502,30503,30504,30505,30506,30507,30508,30509,30510,30569,30570,30571,30572,30573,32164,32217,32218,32219,32220,32221,32222,32223,32224,32278,32279,32280,33618,33633,33634,33635,33636,33637,33638,33639,33640,33641,33642,33643,33644,33645,30421,30422,30423,30424,30425,30426,30427,30428,30432,30433,30434,30435,30436,30437,30438,30439,30440,30441,30442,30443,30444,30445,30446,30447,30448,30449,30450,30451,30452,30453,30454,30455,30456,30457,30458,30459,30460,30461,30462,30463,30464,30465,30466,30467,30468,30469,30470,30471,30472,30473,30371,30372,30373,30374,30375,30376,30377,30378,30379,30380,30381,30382,30383,30384,30385,30386,30387,30388,30389,30390,30391,30392,30393,30394,30395,30396,30397,30398,30399,30400,30401,30402,30403,30404,30405,30406,30407,30408,30409,30410,30411,30412,30413,30414,30415,30416,30417,30418,30419,30420,30351,30356,30357,30358,30359,30360,30361,30362,30365,30366,30367,30368,30369,30370,32668,32669,32714,32717,32718,32719,32720,33024,33069,33077,33078,33080,33103,33104,33105,33106,33107,33339,33340,33341,33342,33343,33347,33348,33582,33598,33602,33606,33607,33608,33609,33611,33614,33615,33616,33617,33764,33765,33766,33768,33777,33778,33779,33780,33781,31827,31828,31832,31837,31842,31844,31846,31847,31987,31994,31996,31997,31998,32028,32078,32138,32139,32140,32270,32281,32282,32283,32284,32285,32292,32293,32294,32462,32463,32464,32465,32621,32622,32623,32624,32666,32667,33900,33902,33971,33972,34132,34133,34134,34135,34153,34154,34157,34178,34179,34180,34181,34210,34234,34235,34236,34237,34255,34265,34266,34267,34268,34269,34270,34271,34316,34318,34319,34320,34321,34723,34724,34725,34726,34727,34728,34729,34730,34748,34749,34750,34751,33782,33783,33784,33785,33786,33839,33840,33841,33861,30242,30243,30244,30273,30290,30291,30292,30293,30294,30295,30330,30331,30363,30818,30859,30863,31308,31352,31354,31356,31358,31360,31383,31385,31408,31410,31412,31414,31433,31461,31486,31487,31489,31492,31493,31495,31564,31565,31566,31567,31708,31716,31717,31718,31719,31720,31729,31825,30021,30040,30042,30043,30044,30046,30052,30053,30054,30076,30077,30078,30161,30162,30163,30184,30185,30186,30187,30188,30189,30190,30191,30192,30193,30194,30195,30196,30197,30198,30213,30214,30215,30221,30234,30237,30238,30239,30240,29434,29435,29438,29439,29440,29475,29478,29491,29496,29741,29745,29747,29967,29978,29983,29984,29985,29986,29987,29988,29989,29990,29991,29992,29993,29994,29995,29996,30017,30019,30020,28996,28997,29002,29003,29049,29050,29068,29085,29086,29087,29091,29092,29093,29094,29095,29096,29098,29102,29103,29104,29105,29106,29146,29149,29178,29179,28876,28877,28911,28912,28915,28916,28919,28921,28925,28926,28958,28959,28960,28961,28968,28983,28984,28985,28986,28987,28992,28993,28994,28995,28495,28496,28497,28498,28499,28500,28501,28502,28503,28504,28505,28506,28507,28508,28514,28540,28544,28613,28614,28619,28620,28633,28637,28645,28646,28649,28650,28651,28652,28654,28655,28656,28657,27991,27992,27993,27994,27995,27996,27997,27998,28436,28437,28438,28439,28440,28441,28442,28443,28444,28445,28446,28447,28448,28449,28450,28451,28452,28453,28454,28455,28456,28457,28458,28459,28460,28461,28462,28463,28464,27767,27768,27769,27770,27771,27772,27773,27774,27775,27776,27777,27780,27781,27782,27783,27784,27785,27786,27787,27788,27789,27790,27791,27877,27913,27920,27942,27943,27944,27945,27962,27963,27964,27965,27966,27967,27968,27969,27970,27985,27986,27987,27988,27989,27990,27192,27193,27194,27217,27218,27259,27260,27261,27262,27263,27264,27361,27408,27409,27410,27411,27414,27415,27416,27417,27423,27424,27491,27492,27505,27510,27511,27696,27697,27698,27699,27722,27723,27724,27725,27726,27727,27728,27729,27740,27741,27742,27743,27744,27745,27746,27747,27766,26024,26176,26177,26178,26179,26180,26181,26211,26240,26264,26266,26269,26270,26652,26663,26667,26670,26706,26707,26710,26793,26798,26799,26800,26801,26802,26805,26806,26807,26808,26809,26810,26811,26812,26813,26814,26815,26816,26817,26819,26822,26824,26825,26826,26827,26828,26829,26830,23581,23582,23583,23584,23585,23586,23587,23588,23589,23590,23591,23602,23603,23645,23650,23651,23819,23820,24068,24076,24078,24080,24377,24378,25910,25911,25912,25913,25914,25915,25916,25917,25918,25926,25928,25930,25966,25979,25997,26002,26004,26005,26021,26022,26023,22374,22375,22472,22473,22474,22677,22678,22871,22899,22900,22901,22902,22903,23015,23016,23017,23018,23019,23020,23021,23022,23528,23529,23533,23543,23551,23553,23554,23555,23556,23557,23558,23559,23560,23561,23562,23566,23568,23569,23570,23571,23572,23573,23574,23575,23576,23577,23578,23579,23580,17415,17416,17417,17418,17419,17420,17439,17440,17441,17442,17443,17444,17445,17446,17447,17555,17556,17557,17558,20097,20105,20106,20107,20108,20109,20110,20111,20113,20114,20115,20116,20117,20118,20131,20132,22359,22362,22364,22365,22366,22367,22368,22369,22370,22371,22372,22373,4280,4282,4283,4285,4286,4287,4292,4294,4295,4296,4297,4299,4300,10406,13585,13984,13985,13986,13987,13988,15362,15383,15384,16364,16972,16990,16991,16992,16993,16995,16996,16997,16998,17402,17403,17404,17405,17406,17407,17408,17409,17411,17412,17413,17414,33025,33027,33028,33030,33031,33032,33033,33034,33036,33037,33038,33039,33042,33043,33044,33045,33046,33047,33048,33049,33050,33051,33052,33053,33054,33055,33056,33057,33058,33059,33060,33061,33062,33063,33064,33065,33143,33144,33159,33228,33231,33250,33251,33252,33253,33254,33255,33256,33257,33258,33267,33268,33269,33270,34546,34231,33276,33277,33278,29404,30000,30102,30104,30105,30109,30110,30111,30115,30116,30117,28902,29335,26542,26461,26462,26463,26464,26465,26466,26467,26539,26540,26541,32193,32194,32195,32196,32197,32198,32199,34772,34773,34774,34775];this.categoriesIds={"0":"Wszystkie kategorie"};this.producersIds={"0":"Wszyscy producenci"};this.lang=Shop.lang.name?Shop.lang.name:"pl_PL";this.$style=$('').appendTo('head');this.insertStyle();if(Shop.pageType.split(' ').includes('shop_basket')){if(typeof GlobalSoolutionSoobasket!='undefined'&&typeof forceStandardEasyProtect=='undefined'){this.basketSoobasket();} else{this.basketIndex();} return true;} if(Shop.pageType.split(' ').includes('shop_basket_address')){this.basketAddress();return true;} if(Shop.pageType.split(' ').includes('shop_basket_step3')){this.basketStep3();return true;} if(this.addEasyProtectToProductIndex&&Shop.pageType.split(' ').includes('shop_product')){this.productIndex();return true;} if(Shop.pageType.split(' ').includes('shop_infopage')&&Shop.pageId==this.infoPageId){this.insertInfoPageStyle();} let protectionFromProductIndex=[];if(localStorage.appEasyProtectProtectionFromProductIndex){protectionFromProductIndex=JSON.parse(localStorage.appEasyProtectProtectionFromProductIndex);} if(protectionFromProductIndex.length>0){this.loadCurrency().then(()=>Promise.all([this.loadBasketInfo(),this.loadCurrencyRate(),])).then(()=>this.addProtectionFromProductIndex(true)).catch((reason)=>this.errorHandler(reason));} return true;};App.prototype.basketIndex=function basketIndex(){this.preloadAddedProtection().then(()=>this.loadCurrency()).then(()=>Promise.all([this.loadProtection(),this.loadBasketInfo(),this.loadInfoPage(),this.loadCurrencyRate(),])).then(()=>this.addProtectionFromProductIndex()).then(()=>this.checkExceedingProtection()).then(()=>this.loadProductOptions()).then(()=>this.addProtectionToBasket()).catch((reason)=>this.errorHandler(reason));};App.prototype.basketAddress=function basketAddress(){this.loadCurrency().then(()=>Promise.all([this.loadProtection(),this.loadBasketInfo(),this.loadInfoPage(),this.loadCurrencyRate(),])).then(()=>this.addProtectionFromProductIndex()).then(()=>this.checkExceedingProtection()).then(()=>{let protectionData=[];if(localStorage.appEasyProtectProtectionData){protectionData=JSON.parse(localStorage.appEasyProtectProtectionData);} $(`#additional_${this.checkboxEnableFieldId}`).val(protectionData.length==0&&localStorage.appEasyProtectEnableEasyProtect==='true'?"Tak":"");}).catch((reason)=>this.errorHandler(reason));};App.prototype.basketStep3=function basketStep3(){this.loadCurrency().then(()=>Promise.all([this.loadProtection(),this.loadBasketInfo(),this.loadInfoPage(),this.loadCurrencyRate(),])).then(()=>this.addProtectionFromProductIndex()).then(()=>this.checkExceedingProtection()).catch((reason)=>this.errorHandler(reason));};App.prototype.productIndex=function productIndex(){this.loadCurrency().then(()=>Promise.all([this.loadProtection(),this.loadBasketInfo(),this.loadInfoPage(),this.loadCurrencyRate(),])).then(()=>this.addProtectionFromProductIndex()).then(()=>this.addProtectionToProductIndex()).catch((reason)=>this.errorHandler(reason));};App.prototype.basketSoobasket=function basketSoobasket(){this.loadCurrency().then(()=>Promise.all([this.loadProtection(),this.loadBasketInfo(),this.loadInfoPage(),this.loadCurrencyRate(),])).then(()=>this.addProtectionFromProductIndex()).then(()=>this.checkExceedingProtection()).then(()=>this.loadProductOptions()).then(()=>this.waitForSoobasket()).then((response)=>{if(response==='fallback'){return this.preloadAddedProtection().then(()=>this.addProtectionToBasket());} return this.addProtectionToSoobasket();}).catch((reason)=>this.errorHandler(reason));};App.prototype.preloadAddedProtection=function preloadAddedProtection(){return new Promise((resolve,reject)=>{let protectionRows=[];let productsTable=$(`#box_basketlist .productlist > tbody > tr[data-product-id]`);productsTable.each((index,tableRow)=>{tableRow=$(tableRow);if(tableRow.data('basket-product-id')==undefined){if(tableRow.find('.prodremove').length==0||tableRow.find('.prodremove').attr('href')=='')return true;let productBasketId=tableRow.find('.prodremove').attr('href').split("/").pop();tableRow.attr('data-basket-product-id',productBasketId);} if(tableRow.data('product-id')==this.productId){protectionRows.push(tableRow);}});if(protectionRows.length>0){let protectionData=[];if(localStorage.appEasyProtectProtectionData){protectionData=JSON.parse(localStorage.appEasyProtectProtectionData);} for(let key in protectionRows){let protectionRow=protectionRows[key];let mxInfoPageUrl=protectionRow.find(`td.name > a`);mxInfoPageUrl.attr('href',`/${this.lang}/i/easy-protect/${this.infoPageId}`);mxInfoPageUrl.attr('title',this.getTranslation('infoPageText'));mxInfoPageUrl.attr('target','_blank').attr('rel','noreferrer');let variants=protectionRow.find(`td.name .variant`).html().split('; ');protectionRow.find(`td.name .variant`).html(`${variants[1]}; ${variants[2]}`);let input=protectionRow.find(`td.quantity input`);input.attr('max',input.val());let basketProductId=0;let basketProtectionId=protectionRow.data('basket-product-id');for(let key2 in protectionData){let data=protectionData[key2];if(data.basketProtectionId!=basketProtectionId)continue;basketProductId=data.basketProductId;break;} if(basketProductId!=0){protectionRow.attr('data-for-basket-product-id',basketProductId);let parentRow=$(`#box_basketlist .productlist > tbody > tr[data-basket-product-id=${basketProductId}]`);while(parentRow.next().data('product-id')==this.productId){parentRow=parentRow.next();} protectionRow.insertAfter(parentRow);}}} return resolve(true);});};App.prototype.loadProtection=function loadProtection(){return new Promise((resolve,reject)=>{this.waitFor(()=>{return typeof window.frontAPI==='object'&&typeof window.frontAPI.getProduct==='function';},()=>{frontAPI.getProduct((protection)=>{if('error_description'in protection)return reject(new Error('Protection not found'));if(!('options_configuration'in protection))return reject(new Error('Protection missing options'));if(protection.options_configuration.length!=4)return reject(new Error('Protection missing options'));this.protection=protection;return resolve(protection);},{id:this.productId,lang:this.lang,currency:this.currency});});});};App.prototype.loadBasketInfo=function loadBasketInfo(){return new Promise((resolve,reject)=>{this.waitFor(()=>{return typeof window.frontAPI==='object'&&typeof window.frontAPI.getBasketInfo==='function';},()=>{frontAPI.getBasketInfo((basket)=>{this.basketInfo=basket;return resolve(basket);},{lang:this.lang,currency:this.currency});});});};App.prototype.loadInfoPage=function loadInfoPage(){return new Promise((resolve,reject)=>{this.waitFor(()=>{return typeof window.frontAPI==='object'&&typeof window.frontAPI.getPage==='function';},()=>{frontAPI.getPage((page)=>{if('error_description'in page)return reject(new Error('Infopage not found'));this.infoPageUrl=page.url;return resolve(page.url);},{id:this.infoPageId,lang:this.lang});});});};App.prototype.loadCurrencyRate=function loadCurrencyRate(){return new Promise((resolve,reject)=>{let link="https://mxapp2.maxserver.pl/appEasyProtect/getCurrencyRate.php";let postData={sessionId:this.sessionId,sessionToken:this.sessionToken,shopId:this.shopId,currency:this.currency};$.post(link,postData).done((response)=>{response=JSON.parse(response);if('error'in response)return reject(new Error(response.error));this.currencyRate=response.rate;return resolve(response.rate);}).fail((response)=>{return reject(new Error(response));});});};App.prototype.checkExceedingProtection=function checkExceedingProtection(){return new Promise((resolve,reject)=>{let promises=[];let protectionData=[];if(localStorage.appEasyProtectProtectionData){protectionData=JSON.parse(localStorage.appEasyProtectProtectionData);} let noProtectionProductsQuantity={};for(let key in this.basketInfo.products){let basketProduct=this.basketInfo.products[key];if(basketProduct.product_id==this.productId)continue;let categoryId='category'in basketProduct?basketProduct.category.category_id:-1;let producerId='producer'in basketProduct?basketProduct.producer.producer_id:-1;if(!this.checkAllowProtection(basketProduct.product_id,categoryId,producerId))continue;if(basketProduct.id in noProtectionProductsQuantity){noProtectionProductsQuantity[basketProduct.id]+=basketProduct.quantity;}else{noProtectionProductsQuantity[basketProduct.id]=basketProduct.quantity;}} loopLabel:for(let key in protectionData){let data=protectionData[key];if(data.basketProductId in noProtectionProductsQuantity){for(let key2 in this.basketInfo.products){let basketProduct=this.basketInfo.products[key2];if(basketProduct.id!=data.basketProtectionId)continue;if(noProtectionProductsQuantity[data.basketProductId]-basketProduct.quantity>=0){noProtectionProductsQuantity[data.basketProductId]-=basketProduct.quantity;break loopLabel;} if(noProtectionProductsQuantity[data.basketProductId]>0){let newQuantity=noProtectionProductsQuantity[data.basketProductId];noProtectionProductsQuantity[data.basketProductId]=0;promises.push(new Promise((resolve,reject)=>{frontAPI.editBasketProductQuantity(()=>{basketProduct.quantity=newQuantity;return resolve(true);},{id:data.basketProtectionId,data:{quantity:newQuantity}});}));break loopLabel;} promises.push(new Promise((resolve,reject)=>{frontAPI.removeFromBasket(()=>{protectionData.splice(key,1);return resolve(true);},{id:data.basketProtectionId});}));break loopLabel;} protectionData.splice(key,1);localStorage.appEasyProtectProtectionData=JSON.stringify(protectionData);} else{promises.push(new Promise((resolve,reject)=>{frontAPI.removeFromBasket(()=>{protectionData.splice(key,1);return resolve(true);},{id:data.basketProtectionId});}));}} loopLabel:for(let key in this.basketInfo.products){let basketProduct=this.basketInfo.products[key];if(basketProduct.product_id!=this.productId)continue;for(let key2 in protectionData){let data=protectionData[key2];if(basketProduct.id!=data.basketProtectionId)continue;continue loopLabel;} promises.push(new Promise((resolve,reject)=>{frontAPI.removeFromBasket(()=>{return resolve(true);},{id:basketProduct.id});}));} if(promises.length>0){Promise.allSettled(promises).then(()=>{localStorage.appEasyProtectProtectionData=JSON.stringify(protectionData);location.replace(location.href);});return false;} else{return resolve(true);}});};App.prototype.loadProductOptions=function loadProductOptions(prices=false){if(typeof this.protectionVariants!='object')this.protectionVariants=[];let currentPrices=[];if(prices===false){for(let key in this.basketInfo.products){let basketProduct=this.basketInfo.products[key];if(basketProduct.product_id==this.productId)continue;if(!currentPrices.includes(basketProduct.price_float))currentPrices.push(basketProduct.price_float);}} else{switch(typeof prices){case'string':currentPrices.push(parseFloat(prices));break;case'number':currentPrices.push(prices);break;case'object':if(!Array.isArray(prices))return Promise.reject(new Error('Wrong prices type in loadProductOptions'));currentPrices=prices;break;default:return Promise.reject(new Error('Wrong prices type in loadProductOptions'));}} let optionPriceRangeValues=[];let optionPriceRangeBrakets={};let optionTimePeriodValues=[];let optionTimePeriodNames={};for(let key in this.protection.options_configuration){let option=this.protection.options_configuration[key];if(option.id==this.optionPriceRangeId){for(let key2 in option.values){let optionValue=option.values[key2];let priceBraketsArray=optionValue.name.split(',').join('.').split('-');let priceBrakets={priceMin:parseFloat(priceBraketsArray[0])*this.currencyRate,priceMax:parseFloat(priceBraketsArray[1])*this.currencyRate,};let priceInBrakets=false;for(let key3 in currentPrices){let price=currentPrices[key3];if(priceBrakets.priceMin<=price&&price<=priceBrakets.priceMax){priceInBrakets=true;break;}} if(priceInBrakets){optionPriceRangeValues.push(optionValue.id);optionPriceRangeBrakets[optionValue.id]=priceBrakets;}}} if(option.id==this.optionTimePeriodId){for(let key2 in option.values){let optionValue=option.values[key2];optionTimePeriodValues.push(optionValue.id);optionTimePeriodNames[optionValue.id]=optionValue.name;}}} let dataOptions=[];for(let key in optionPriceRangeValues){let optionPriceRangeValue=optionPriceRangeValues[key];for(let key2 in optionTimePeriodValues){let optionTimePeriodValue=optionTimePeriodValues[key2];let options={};options[this.optionPriceRangeId]=optionPriceRangeValue;options[this.optionTimePeriodId]=optionTimePeriodValue;dataOptions.push(options);}} let promises=[];loopLabel:for(let key in dataOptions){let options=dataOptions[key];for(let key2 in this.protectionVariants){if(this.protectionVariants[key2].options[this.optionPriceRangeId]!=options[this.optionPriceRangeId])continue;if(this.protectionVariants[key2].options[this.optionTimePeriodId]!=options[this.optionTimePeriodId])continue;continue loopLabel;} promises.push(new Promise((resolve,reject)=>{frontAPI.getProductOption((stock)=>{if('error_description'in stock)return resolve(stock);let priceBrakets=optionPriceRangeBrakets[options[this.optionPriceRangeId]];let protectionWariant={stockId:stock.id,options:options,price:stock.price.gross.final_float,priceMin:priceBrakets.priceMin,priceMax:priceBrakets.priceMax,timePeriod:optionTimePeriodNames[options[this.optionTimePeriodId]],};this.protectionVariants.push(protectionWariant);return resolve(protectionWariant);},{id:this.productId,data:{options:options},lang:this.lang,currency:this.currency});}));} return Promise.all(promises);};App.prototype.addProtectionToBasket=function addProtectionToBasket(){return new Promise((resolve,reject)=>{let protectionExists=false;let protectionForms={};let productsTable=$(`#box_basketlist .productlist > tbody > tr[data-product-id]`);productsTable.each((index,tableRow)=>{tableRow=$(tableRow);if(tableRow.data('basket-product-id')==undefined){if(tableRow.find('.prodremove').length==0||tableRow.find('.prodremove').attr('href')=='')return true;let productBasketId=tableRow.find('.prodremove').attr('href').split("/").pop();tableRow.attr('data-basket-product-id',productBasketId);} let basketProductId=tableRow.data('basket-product-id');let basketProduct=this.basketInfo.products.find((basketProduct)=>basketProduct.id==basketProductId);let productId=basketProduct.product_id;if(productId!=this.productId){let categoryId='category'in basketProduct?basketProduct.category.category_id:-1;let producerId='producer'in basketProduct?basketProduct.producer.producer_id:-1;if(!this.checkAllowProtection(productId,categoryId,producerId))return true;let protectionForm=this.createProtectionForm(tableRow);if(protectionForm!=false){protectionForms[basketProductId]=protectionForm;tableRow.find('.quantity input').on('change.maxProtection',(e)=>{this.changeMaxProtectionEvent(basketProductId);});this.changeMaxProtectionEvent(basketProductId);}} else{protectionExists=true;tableRow.find(`td.name > a`).attr('href',this.infoPageUrl);tableRow.find('.quantity input').on('change.maxProtection',(e)=>{if(tableRow.data('basket-product-id')==undefined)return false;this.changeMaxProtectionEvent(tableRow.data('for-basket-product-id'));});}});if(!protectionExists&&this.checkboxEnableEasyProtect){localStorage.appEasyProtectEnableEasyProtect='false';if(Object.keys(protectionForms).length>0){let mxEnableEasyProtect=$(`
`).prependTo('#box_basketlist .summary-container');let checkbox=$(``).appendTo(mxEnableEasyProtect);checkbox.attr('id','mxEnableEasyProtect');checkbox.wrap(``);$(``).insertAfter(checkbox);let label=$(``).appendTo(mxEnableEasyProtect);label.html(this.getTranslation('checkboxEnableEasyProtectText'));checkbox.on('change.enableEasyProtect',(e)=>{if(checkbox.is(':checked')){localStorage.appEasyProtectEnableEasyProtect='true';productsTable.each((index,tableRow)=>{tableRow=$(tableRow);let basketProductId=tableRow.data('basket-product-id');let basketProduct=this.basketInfo.products.find((basketProduct)=>basketProduct.id==basketProductId);let productId=basketProduct.product_id;if(productId!=this.productId){if(basketProductId in protectionForms){let parentRow=tableRow;while(parentRow.next().data('product-id')==this.productId){parentRow=parentRow.next();} protectionForms[basketProductId].insertAfter(parentRow);}}});} else{localStorage.appEasyProtectEnableEasyProtect='false';productsTable.each((index,tableRow)=>{tableRow=$(tableRow);let basketProductId=tableRow.data('basket-product-id');let basketProduct=this.basketInfo.products.find((basketProduct)=>basketProduct.id==basketProductId);let productId=basketProduct.product_id;if(productId!=this.productId){if(basketProductId in protectionForms){protectionForms[basketProductId].detach();}}});}});}} else{productsTable.each((index,tableRow)=>{tableRow=$(tableRow);let basketProductId=tableRow.data('basket-product-id');let basketProduct=this.basketInfo.products.find((basketProduct)=>basketProduct.id==basketProductId);let productId=basketProduct.product_id;if(productId!=this.productId){if(basketProductId in protectionForms){let parentRow=tableRow;while(parentRow.next().data('product-id')==this.productId){parentRow=parentRow.next();} protectionForms[basketProductId].insertAfter(parentRow);}}});} return resolve(true);});};App.prototype.checkAllowProtection=function checkAllowProtection(productId,categoryId,producerId){let blockCategory=false;let blockProducer=false;if(0 in this.categoriesIds){if(categoryId in this.categoriesIds){blockCategory=true;}} else{if(!(categoryId in this.categoriesIds)){blockCategory=true;}} if(0 in this.producersIds){if(producerId in this.producersIds){blockProducer=true;}} else{if(!(producerId in this.producersIds)){blockProducer=true;}} if(this.listType=='whitelist'){if(this.productIds.includes(productId))return true;} else if(this.listType=='blacklist'){if(this.productIds.includes(productId))return false;} if(blockCategory)return false;if(blockProducer)return false;return true;};App.prototype.createProtectionForm=function createProtectionForm(tableRow){let basketProductId=tableRow.data('basket-product-id');let basketProduct=this.basketInfo.products.find((basketProduct)=>basketProduct.id==basketProductId);let productId=basketProduct.product_id;let chossenProtectionVariants=this.protectionVariants.filter((variant)=>variant.priceMin<=basketProduct.price_float&&basketProduct.price_float<=variant.priceMax);if(chossenProtectionVariants.length==0)return false;chossenProtectionVariants.sort((a,b)=>a.price-b.price);let noProtectionQuantity=basketProduct.quantity;let protectionData=[];if(localStorage.appEasyProtectProtectionData){protectionData=JSON.parse(localStorage.appEasyProtectProtectionData);} for(let key in protectionData){let data=protectionData[key];if(data.basketProductId!=basketProductId)continue;for(let key2 in this.basketInfo.products){let basketProtection=this.basketInfo.products[key2];if(basketProtection.id!=data.basketProtectionId)continue;noProtectionQuantity-=basketProtection.quantity;}} if(noProtectionQuantity<=0)return false;let form=$(`
`);let mxWrapper=form.find('.mxWrapper');let mxLeftCol=$(`
`).appendTo(mxWrapper);let bigPurpleArrow=$(``).appendTo(mxWrapper);bigPurpleArrow.attr('src','https://mxapp2.maxserver.pl/appEasyProtect/gfx/bigPurpleArrow.png');bigPurpleArrow.wrap(`
`);let mxRightCol=$(`
`).appendTo(mxWrapper);let name=this.escapeHtml(this.protection.name);let tradeMark='';if(name.charCodeAt(name.length-1)==174){tradeMark=`${name.substr(-1, 1)}`;name=name.substr(0,name.length-1);} if(name.charCodeAt(name.length-1)==8482){tradeMark=`${name.substr(-1, 1)}`;name=name.substr(0,name.length-1);} let mxImage=$(``).appendTo(mxLeftCol);mxImage.wrap(`
`);let mxNameContainer=$(`
`).appendTo(mxLeftCol);let mxName=$(`
${name}${tradeMark}
`).appendTo(mxNameContainer);let mxInfoPageUrl=$(`${this.getTranslation('infoPageText')}`).appendTo(mxNameContainer);mxInfoPageUrl.attr('href',this.infoPageUrl);mxInfoPageUrl.attr('target','_blank').attr('rel','noreferrer');mxInfoPageUrl.wrap(`
`);let smallPurpleArrow=$(``).insertBefore(mxInfoPageUrl);smallPurpleArrow.attr('src','https://mxapp2.maxserver.pl/appEasyProtect/gfx/smallPurpleArrow.png');smallPurpleArrow.wrap(`
`);let mxQuantityWrap=$(`
`).appendTo(mxRightCol);let mxQuantity=$(``).appendTo(mxQuantityWrap);for(let i=1;i<=noProtectionQuantity;i++){mxQuantity.append(``);} let mxOptions=$(`
`).appendTo(mxRightCol);if(this.noOption==1){let mxOption=$(``).appendTo(mxOptions);mxOption.attr('name',`radio_${basketProductId}`);mxOption.attr('id',`radio_${basketProductId}_no_option`);mxOption.attr('value',`0`);mxOption.wrap(`
`);let label=$(``).insertAfter(mxOption);label.attr('for',`radio_${basketProductId}_no_option`);label.append(this.getTranslation('noOptionText'));} for(let key in chossenProtectionVariants){let chossenVariant=chossenProtectionVariants[key];let mxOption=$(``).appendTo(mxOptions);mxOption.attr('name',`radio_${basketProductId}`);mxOption.attr('id',`radio_${basketProductId}_${chossenVariant.stockId}`);mxOption.attr('value',chossenVariant.stockId);mxOption.wrap(`
`);let label=$(``).insertAfter(mxOption);label.attr('for',`radio_${basketProductId}_${chossenVariant.stockId}`);label.append(`${chossenVariant.timePeriod} `);label.append(`${this.priceFormat(chossenVariant.price)}`);} let mxSum=$(`
`).appendTo(mxRightCol);let mxAction=$(`
`).appendTo(mxRightCol);let mxButtonAdd=$(`
${this.getTranslation('protectionAddText')}
`).appendTo(mxAction);mxQuantity.on('change',(e)=>{let quantity=parseFloat($(e.target).val());let stockId=parseFloat(mxOptions.find('input:checked').val());if(stockId==0){mxButtonAdd.stop().animate({'opacity':0.3});mxSum.text(this.priceFormat(0));} else{mxButtonAdd.stop().animate({'opacity':1});let price=0;for(let key in chossenProtectionVariants){let chossenVariant=chossenProtectionVariants[key];if(stockId==chossenVariant.stockId){price=chossenVariant.price;break;}} let quantity=mxQuantity.val();mxSum.text(this.priceFormat(price*quantity));} for(let key in this.$style.get(0).sheet.cssRules){let rule=this.$style.get(0).sheet.cssRules[key];if(rule.selectorText!='.protectionForm .mxRightCol .mxSum')continue;let width=mxSum.get(0).getBoundingClientRect().width;if(parseFloat(rule.style.minWidth){let quantity=parseFloat(mxQuantity.val());let stockId=parseFloat($(e.target).val());if(stockId==0){mxAction.addClass('mxHidden');mxButtonAdd.stop().animate({'opacity':0.3});mxSum.text(this.priceFormat(0));} else{mxAction.removeClass('mxHidden');mxButtonAdd.stop().animate({'opacity':1});let price=0;for(let key in chossenProtectionVariants){let chossenVariant=chossenProtectionVariants[key];if(stockId==chossenVariant.stockId){price=chossenVariant.price;break;}} mxSum.text(this.priceFormat(price*quantity));} for(let key in this.$style.get(0).sheet.cssRules){let rule=this.$style.get(0).sheet.cssRules[key];if(rule.selectorText!='.protectionForm .mxRightCol .mxSum')continue;let width=mxSum.get(0).getBoundingClientRect().width;if(parseFloat(rule.style.minWidth){let quantity=parseFloat(mxQuantity.val());let stockId=parseFloat(mxOptions.find('input:checked').val());if(stockId==0)return false;let options={};for(let key in chossenProtectionVariants){let chossenVariant=chossenProtectionVariants[key];if(stockId==chossenVariant.stockId){options=chossenVariant.options;break;}} let query={data:{stock_id:stockId,quantity:quantity,options:options,}};query.data.options[this.optionToProductId]=`${basketProduct.name}`;let hasVariant=0;if(basketProduct.variant!=''){hasVariant=1;query.data.options[this.optionToProductId]+=` (${basketProduct.variant})`;} query.data.options[this.optionDataId]=`${basketProduct.stock_id}, ${hasVariant}`;let wait=$('').appendTo('head');frontAPI.addToBasket((response)=>{if(response.added.length>0){let protectionData=[];if(localStorage.appEasyProtectProtectionData){protectionData=JSON.parse(localStorage.appEasyProtectProtectionData);} let protectionExisted=false;for(let key in protectionData){let data=protectionData[key];if(data.basketProductId!=basketProduct.id)continue;if(data.basketProtectionId!=response.added[0].id)continue;protectionExisted=true;break;} if(!protectionExisted){protectionData.push({basketProductId:basketProduct.id,basketProtectionId:response.added[0].id,});localStorage.appEasyProtectProtectionData=JSON.stringify(protectionData);} location.replace(location.href);} else{if(response._flash_messenger.error.length>0)shoper.alert(response._flash_messenger.error[0],'');if(response._flash_messenger.warning.length>0)shoper.alert(response._flash_messenger.warning[0],'');if(response._flash_messenger.info.length>0)shoper.alert(response._flash_messenger.info[0],'');} wait.remove();},query);});return form;};App.prototype.changeMaxProtectionEvent=function changeMaxProtectionEvent(basketProductId){let maxProtection=$(`#box_basketlist .productlist > tbody > tr[data-basket-product-id=${basketProductId}] .quantity input`).val();let noProtectionQuantity=maxProtection;let basketProtectionIds=[];let protectionData=[];if(localStorage.appEasyProtectProtectionData){protectionData=JSON.parse(localStorage.appEasyProtectProtectionData);} for(let key in protectionData){let data=protectionData[key];if(data.basketProductId!=basketProductId)continue;basketProtectionIds.push(data.basketProtectionId);} if(basketProtectionIds.length==0)return false;let protectionsTable=$(`#box_basketlist .productlist > tbody > tr[data-product-id=${this.productId}]`);protectionsTable.each((index2,tableRow)=>{tableRow=$(tableRow);if(!basketProtectionIds.includes(tableRow.data('basket-product-id')))return true;noProtectionQuantity-=tableRow.find('.quantity input').val();});if(noProtectionQuantity<0){noProtectionQuantity=maxProtection;protectionsTable.each((index2,tableRow)=>{tableRow=$(tableRow);if(!basketProtectionIds.includes(tableRow.data('basket-product-id')))return true;let input=tableRow.find('.quantity input');if(noProtectionQuantity-input.val()>0){noProtectionQuantity-=input.val();input.attr('max',input.val());return true;} if(noProtectionQuantity>0){input.attr('max',noProtectionQuantity);noProtectionQuantity=0;return true;} input.attr('max',0);});$('#box_basketlist .innerbox > form').get(0).reportValidity();} else{protectionsTable.each((index2,tableRow)=>{tableRow=$(tableRow);if(!basketProtectionIds.includes(tableRow.data('basket-product-id')))return true;let input=tableRow.find('.quantity input');input.attr('max',input.val()*1+noProtectionQuantity);});}};App.prototype.addProtectionToProductIndex=function addProtectionToProductIndex(){return new Promise((resolve,reject)=>{frontAPI.getProduct((product)=>{if('error_description'in product)return reject(new Error('Product not found'));let categoryId='category'in product?product.category.id:-1;let producerId='producer'in product?product.producer.id:-1;if(!this.checkAllowProtection(product.id,categoryId,producerId))return resolve(true);let mxEasyProtectContainer=$(`
`).insertBefore('.productdetails-more-details');mxEasyProtectContainer.hide();let name=this.escapeHtml(this.protection.name);let tradeMark='';if(name.charCodeAt(name.length-1)==174){tradeMark=`${name.substr(-1, 1)}`;name=name.substr(0,name.length-1);} if(name.charCodeAt(name.length-1)==8482){tradeMark=`${name.substr(-1, 1)}`;name=name.substr(0,name.length-1);} let mxImage=$(``).appendTo(mxEasyProtectContainer);mxImage.wrap(`
`);let mxName=$(`
${name}${tradeMark}
`).appendTo(mxEasyProtectContainer);let mxText=$(`
${this.getTranslation('productIndexText2')}
`).appendTo(mxEasyProtectContainer);let mxInfoPageUrl=$(`${this.getTranslation('infoPageText')}`).appendTo(mxEasyProtectContainer);mxInfoPageUrl.attr('href',this.infoPageUrl);mxInfoPageUrl.attr('target','_blank').attr('rel','noreferrer');mxInfoPageUrl.wrap(`
`);let mxSmallPurpleArrow=$(``).insertBefore(mxInfoPageUrl);mxSmallPurpleArrow.attr('src','https://mxapp2.maxserver.pl/appEasyProtect/gfx/smallPurpleArrow.png');mxSmallPurpleArrow.wrap(`
`);let mxOptions=$(`
`).appendTo(mxEasyProtectContainer);let price=parseFloat($('#box_productfull .price .main-price').eq(0).text().replaceAll(/[^\d,.-]/g,'').replaceAll(',','.'));this.changeProductStockEvent(mxEasyProtectContainer,mxOptions,price).catch((reason)=>this.errorHandler(reason));let prevPrice=price;let observer=new MutationObserver(()=>{let price=parseFloat($('#box_productfull .price .main-price').eq(0).text().replaceAll(/[^\d,.-]/g,'').replaceAll(',','.'));if(price==prevPrice)return false;prevPrice=price;this.changeProductStockEvent(mxEasyProtectContainer,mxOptions,price).catch((reason)=>this.errorHandler(reason));});observer.observe($('#box_productfull .price .main-price').get(0),{childList:true});$('#box_productfull .addtobasket').on('click',(e)=>{let option=mxOptions.find('input:checked');if(option.length==1&&option.val()!=0){let protectionFromProductIndex=[];if(localStorage.appEasyProtectProtectionFromProductIndex){protectionFromProductIndex=JSON.parse(localStorage.appEasyProtectProtectionFromProductIndex);} let object={protection:{},product:{},otherProductQuantities:{}};object.protection.stockId=parseFloat(option.val());object.product.stockId=parseFloat($('#box_productfull .addtobasket-container [name="stock_id"]').val());object.product.quantity=parseFloat($('#box_productfull .addtobasket-container [name="quantity"]').val());for(let key in this.protectionVariants){let variant=this.protectionVariants[key];if(variant.stockId==option.val()){object.protection.options=variant.options;break;}} for(let key in this.basketInfo.products){let basketProduct=this.basketInfo.products[key];object.otherProductQuantities[basketProduct.id]=basketProduct.quantity;} protectionFromProductIndex.push(object);localStorage.appEasyProtectProtectionFromProductIndex=JSON.stringify(protectionFromProductIndex);}});return resolve(true);},{id:Shop.pageId});});};App.prototype.changeProductStockEvent=function changeProductStockEvent(mxEasyProtectContainer,mxOptions,price){return this.loadProductOptions(price).then(()=>{let chossenProtectionVariants=this.protectionVariants.filter((variant)=>variant.priceMin<=price&&price<=variant.priceMax);mxOptions.empty();if(chossenProtectionVariants.length==0){mxEasyProtectContainer.hide();} else{chossenProtectionVariants.sort((a,b)=>a.price-b.price);mxEasyProtectContainer.show();{let mxOption=$(``).appendTo(mxOptions);mxOption.attr('for',`mx_easy_protect_radio_no_option`);let mxBranches=$(`
`).appendTo(mxOption);$(`
`).appendTo(mxBranches);$(`
`).appendTo(mxBranches);let mxOptionInput=$(``).appendTo(mxOption);mxOptionInput.attr('name',`mx_easy_protect_radio`);mxOptionInput.attr('id',`mx_easy_protect_radio_no_option`);mxOptionInput.attr('value',`0`);mxOptionInput.attr('checked',`checked`);let mxOptionLabel=$(`
`).appendTo(mxOption);let mxOptionText=$(`
${this.getTranslation('productIndexOptionText')}
`).appendTo(mxOption);let mxOptionName=$(`
${this.getTranslation('productIndexNoOptionText')}
`).appendTo(mxOption);let mxOptionPrice=$(`
${this.priceFormat(0)}
`).appendTo(mxOption);} for(let key in chossenProtectionVariants){let chossenVariant=chossenProtectionVariants[key];let mxOption=$(``).appendTo(mxOptions);mxOption.attr('for',`mx_easy_protect_radio_${chossenVariant.stockId}`);let mxBranches=$(`
`).appendTo(mxOption);$(`
`).appendTo(mxBranches);$(`
`).appendTo(mxBranches);let mxOptionInput=$(``).appendTo(mxOption);mxOptionInput.attr('name',`mx_easy_protect_radio`);mxOptionInput.attr('id',`mx_easy_protect_radio_${chossenVariant.stockId}`);mxOptionInput.attr('value',chossenVariant.stockId);let mxOptionLabel=$(`
`).appendTo(mxOption);let mxOptionText=$(`
${this.getTranslation('productIndexOptionText')}
`).appendTo(mxOption);let mxOptionName=$(`
${chossenVariant.timePeriod}
`).appendTo(mxOption);let mxOptionPrice=$(`
${this.priceFormat(chossenVariant.price)}
`).appendTo(mxOption);} let mxRwdTree=$(``).appendTo(mxOptions);$(`
`).appendTo(mxRwdTree);$(`
`).appendTo(mxRwdTree);$(``).appendTo(mxOptions);}});};App.prototype.addProtectionFromProductIndex=function addProtectionFromProductIndex(skipRefresh=false){return new Promise((resolve,reject)=>{let protectionFromProductIndexes=[];if(localStorage.appEasyProtectProtectionFromProductIndex){protectionFromProductIndexes=JSON.parse(localStorage.appEasyProtectProtectionFromProductIndex);} if(protectionFromProductIndexes.length>0){let promises=[];for(let key in protectionFromProductIndexes){let protectionFromProductIndex=protectionFromProductIndexes[key];let correctBasketProduct=null;for(let key2 in this.basketInfo.products){let basketProduct=this.basketInfo.products[key2];if(basketProduct.stock_id!=protectionFromProductIndex.product.stockId)continue;if(basketProduct.quantity==protectionFromProductIndex.otherProductQuantities[basketProduct.id])continue;protectionFromProductIndex.otherProductQuantities[basketProduct.id]+=protectionFromProductIndex.product.quantity;correctBasketProduct=basketProduct;break;} if(correctBasketProduct==null)continue;promises.push(new Promise((resolve,reject)=>{let query={data:{stock_id:protectionFromProductIndex.protection.stockId,quantity:protectionFromProductIndex.product.quantity,options:protectionFromProductIndex.protection.options,}};query.data.options[this.optionToProductId]=`${correctBasketProduct.name}`;let hasVariant=0;if(correctBasketProduct.variant!=''){hasVariant=1;query.data.options[this.optionToProductId]+=` (${correctBasketProduct.variant})`;} query.data.options[this.optionDataId]=`${correctBasketProduct.stock_id}, ${hasVariant}`;let wait=$('').appendTo('head');frontAPI.addToBasket((response)=>{if(response.added.length>0){protectionFromProductIndexes.splice(key,1);localStorage.appEasyProtectProtectionFromProductIndex=JSON.stringify(protectionFromProductIndexes);let protectionData=[];if(localStorage.appEasyProtectProtectionData){protectionData=JSON.parse(localStorage.appEasyProtectProtectionData);} let protectionExisted=false;for(let key in protectionData){let data=protectionData[key];if(data.basketProductId!=correctBasketProduct.id)continue;if(data.basketProtectionId!=response.added[0].id)continue;protectionExisted=true;break;} if(!protectionExisted){protectionData.push({basketProductId:correctBasketProduct.id,basketProtectionId:response.added[0].id,});localStorage.appEasyProtectProtectionData=JSON.stringify(protectionData);} return resolve(true);} else{if(response._flash_messenger.error.length>0)shoper.alert(response._flash_messenger.error[0],'');if(response._flash_messenger.warning.length>0)shoper.alert(response._flash_messenger.warning[0],'');if(response._flash_messenger.info.length>0)shoper.alert(response._flash_messenger.info[0],'');} wait.remove();},query);}));} Promise.all(promises).then(()=>{if(skipRefresh){return resolve(true);} else{location.replace(location.href);}});return true;} else{return resolve(true);}});};App.prototype.waitForSoobasket=function waitForSoobasket(){return new Promise((resolve,reject)=>{let waitingFunction=()=>{if($('#box_basketlist').is(':visible')){return resolve('fallback');} else if($('.el-table .el-table__row').length==0){setTimeout(waitingFunction,100);} else{let protectionRows=[];let productsTable=$('.el-table .el-table__row');productsTable.each((index,tableRow)=>{tableRow=$(tableRow);for(let className of tableRow.get(0).classList){let types={'data-basket-product-id':'basket_product_id_','data-product-id':'product_id_',};for(let type in types){if(className.indexOf(types[type])!=-1){tableRow.attr(type,className.slice(types[type].length));}}} if(tableRow.data('product-id')==this.productId){protectionRows.push(tableRow);}});if(protectionRows.length>0){let protectionData=[];if(localStorage.appEasyProtectProtectionData){protectionData=JSON.parse(localStorage.appEasyProtectProtectionData);} for(let key in protectionRows){let protectionRow=protectionRows[key];let mxInfoPageUrl=protectionRow.find(`.cell > .name > a`);mxInfoPageUrl.attr('href',`/${this.lang}/i/easy-protect/${this.infoPageId}`);mxInfoPageUrl.attr('title',this.getTranslation('infoPageText'));mxInfoPageUrl.attr('target','_blank').attr('rel','noreferrer');let variants=protectionRow.find(`.cell > .name .variant`).html().split('; ');protectionRow.find(`.cell > .name .variant`).html(`${variants[1]}; ${variants[2]}`);let basketProductId=0;let basketProtectionId=protectionRow.data('basket-product-id');for(let key2 in protectionData){let data=protectionData[key2];if(data.basketProtectionId!=basketProtectionId)continue;basketProductId=data.basketProductId;break;} if(basketProductId!=0){protectionRow.attr('data-for-basket-product-id',basketProductId);let parentRow=$(`.el-table .el-table__row.basket_product_id_${basketProductId}`);while(parentRow.next().data('product-id')==this.productId){parentRow=parentRow.next();} protectionRow.insertAfter(parentRow);}}} return resolve('loaded');}};waitingFunction();});};App.prototype.addProtectionToSoobasket=function addProtectionToSoobasket(){return new Promise((resolve,reject)=>{let protectionExists=false;let protectionForms={};let protectionInputs={};let productsTable=$(`.el-table .el-table__row`);productsTable.each((index,tableRow)=>{tableRow=$(tableRow);let basketProductId=tableRow.data('basket-product-id');let basketProduct=this.basketInfo.products.find((basketProduct)=>basketProduct.id==basketProductId);let productId=basketProduct.product_id;if(productId!=this.productId){let categoryId='category'in basketProduct?basketProduct.category.category_id:-1;let producerId='producer'in basketProduct?basketProduct.producer.producer_id:-1;if(!this.checkAllowProtection(productId,categoryId,producerId))return true;let protectionForm=this.createProtectionFormSoobasket(tableRow);if(protectionForm!=false){protectionForms[basketProductId]=protectionForm;protectionInputs[basketProductId]={product:tableRow.find('.quantity-input input').eq(0),protection:[],};}} else{protectionExists=true;tableRow.find(`.cell > .name > a`).attr('href',this.infoPageUrl);protectionInputs[tableRow.data('for-basket-product-id')].protection.push(tableRow.find('.quantity-input input').eq(0));tableRow.find('.quantity-input').each((index2,item)=>{item=$(item);let orgInput=item.find('input');let mxQuantity=item.clone().addClass('quantity-input-ep').insertAfter(item);item.addClass('quantity-input-org').hide();});}});productsTable.each((index,tableRow)=>{tableRow=$(tableRow);let basketProductId=tableRow.data('basket-product-id');let basketProduct=this.basketInfo.products.find((basketProduct)=>basketProduct.id==basketProductId);let productId=basketProduct.product_id;if(productId==this.productId){let protectionInput=protectionInputs[tableRow.data('for-basket-product-id')];let noProtectionQuantity=protectionInput.product.val();for(let key in protectionInput.protection){noProtectionQuantity-=protectionInput.protection[key].val();} tableRow.find('.quantity-input-ep input').val(basketProduct.quantity).attr('data-max',basketProduct.quantity+noProtectionQuantity);if(basketProduct.quantity<=1){tableRow.find('.quantity-input-ep .el-input-number__decrease').addClass('is-disabled');}else{tableRow.find('.quantity-input-ep .el-input-number__decrease').removeClass('is-disabled');} if(noProtectionQuantity<=0){tableRow.find('.quantity-input-ep .el-input-number__increase').addClass('is-disabled');}else{tableRow.find('.quantity-input-ep .el-input-number__increase').removeClass('is-disabled');} tableRow.find('.quantity-input-ep input').on('change',(e)=>{let value=Math.min(Math.max(1,$(e.currentTarget).val()),$(e.currentTarget).data('max'));let input=tableRow.find('.quantity-input-org input').eq(0);if(value==input.val())return false;input.val(value);input.get(0).dispatchEvent(new Event('change'));});tableRow.find('.quantity-input-ep .el-input-number__decrease').on('click',(e)=>{if($(e.currentTarget).is('.is-disabled'))return false;let input=tableRow.find('.quantity-input-org input').eq(0);input.val(input.val()-1);input.get(0).dispatchEvent(new Event('change'));});tableRow.find('.quantity-input-ep .el-input-number__increase').on('click',(e)=>{if($(e.currentTarget).is('.is-disabled'))return false;let input=tableRow.find('.quantity-input-org input').eq(0);input.val(parseInt(input.val())+1);input.get(0).dispatchEvent(new Event('change'));});}});if(this.checkboxEnableEasyProtect){if(Object.keys(protectionForms).length>0){let mxEnableEasyProtect=$(`
`).prependTo('.el-form > .el-row + .el-row + .first-part-info > .el-col:last-of-type');mxEnableEasyProtect.wrap(`
`);let checkbox=$(``).appendTo(mxEnableEasyProtect);checkbox.attr('id','mxEnableEasyProtect');checkbox.wrap(``);$(``).insertAfter(checkbox);let label=$(``).appendTo(mxEnableEasyProtect);label.html(this.getTranslation('checkboxEnableEasyProtectText'));checkbox.on('change.enableEasyProtect',(e)=>{if(checkbox.is(':checked')){productsTable.each((index,tableRow)=>{tableRow=$(tableRow);let basketProductId=tableRow.data('basket-product-id');let basketProduct=this.basketInfo.products.find((basketProduct)=>basketProduct.id==basketProductId);let productId=basketProduct.product_id;if(productId!=this.productId){if(basketProductId in protectionForms){let noProtectionQuantity=basketProduct.quantity;let protectionData=[];if(localStorage.appEasyProtectProtectionData){protectionData=JSON.parse(localStorage.appEasyProtectProtectionData);} for(let key in protectionData){let data=protectionData[key];if(data.basketProductId!=basketProductId)continue;for(let key2 in this.basketInfo.products){let basketProtection=this.basketInfo.products[key2];if(basketProtection.id!=data.basketProtectionId)continue;noProtectionQuantity-=basketProtection.quantity;}} if(noProtectionQuantity>0){let parentRow=tableRow;while(parentRow.next().data('product-id')==this.productId){parentRow=parentRow.next();} protectionForms[basketProductId].insertAfter(parentRow);}}}});} else{productsTable.each((index,tableRow)=>{tableRow=$(tableRow);let basketProductId=tableRow.data('basket-product-id');let basketProduct=this.basketInfo.products.find((basketProduct)=>basketProduct.id==basketProductId);let productId=basketProduct.product_id;if(productId!=this.productId){if(basketProductId in protectionForms){protectionForms[basketProductId].detach();}}});}});if(protectionExists)checkbox.prop('checked',true).change();}} else{productsTable.each((index,tableRow)=>{tableRow=$(tableRow);let basketProductId=tableRow.data('basket-product-id');let basketProduct=this.basketInfo.products.find((basketProduct)=>basketProduct.id==basketProductId);let productId=basketProduct.product_id;if(productId!=this.productId){if(basketProductId in protectionForms){let noProtectionQuantity=basketProduct.quantity;let protectionData=[];if(localStorage.appEasyProtectProtectionData){protectionData=JSON.parse(localStorage.appEasyProtectProtectionData);} for(let key in protectionData){let data=protectionData[key];if(data.basketProductId!=basketProductId)continue;for(let key2 in this.basketInfo.products){let basketProtection=this.basketInfo.products[key2];if(basketProtection.id!=data.basketProtectionId)continue;noProtectionQuantity-=basketProtection.quantity;}} if(noProtectionQuantity>0){let parentRow=tableRow;while(parentRow.next().data('product-id')==this.productId){parentRow=parentRow.next();} protectionForms[basketProductId].insertAfter(parentRow);}}}});} shoper.addEvent("soobasket:refresh",(e,basket)=>{this.basketInfo=basket;this.checkExceedingProtection().then(()=>{productsTable.each((index,tableRow)=>{tableRow=$(tableRow);let basketProductId=tableRow.data('basket-product-id');let basketProduct=this.basketInfo.products.find((basketProduct)=>basketProduct.id==basketProductId);if(basketProduct===undefined){if(basketProductId in protectionForms){protectionForms[basketProductId].remove();delete protectionForms[basketProductId];} productsTable=productsTable.filter(i=>i!=index);return true;} let productId=basketProduct.product_id;if(productId!=this.productId){if(basketProductId in protectionForms){let protectionInput=protectionInputs[basketProductId];let noProtectionQuantity=protectionInput.product.val();for(let key in protectionInput.protection){noProtectionQuantity-=protectionInput.protection[key].val();} if(noProtectionQuantity>0){let mxQuantity=protectionForms[basketProductId].find('.mxQuantity').empty();for(let i=1;i<=noProtectionQuantity;i++){mxQuantity.append(``);}} if(!this.checkboxEnableEasyProtect||$('#mxEnableEasyProtect').is(':checked')){if(noProtectionQuantity>0){let parentRow=tableRow;while(parentRow.next().data('product-id')==this.productId){parentRow=parentRow.next();} protectionForms[basketProductId].insertAfter(parentRow);} else{protectionForms[basketProductId].detach();}}}} else{let protectionInput=protectionInputs[tableRow.data('for-basket-product-id')];let noProtectionQuantity=protectionInput.product.val();for(let key in protectionInput.protection){noProtectionQuantity-=protectionInput.protection[key].val();} tableRow.find('.quantity-input-ep input').val(basketProduct.quantity).attr('data-max',basketProduct.quantity+noProtectionQuantity);if(basketProduct.quantity<=1){tableRow.find('.quantity-input-ep .el-input-number__decrease').addClass('is-disabled');}else{tableRow.find('.quantity-input-ep .el-input-number__decrease').removeClass('is-disabled');} if(noProtectionQuantity<=0){tableRow.find('.quantity-input-ep .el-input-number__increase').addClass('is-disabled');}else{tableRow.find('.quantity-input-ep .el-input-number__increase').removeClass('is-disabled');}}});}).catch((reason)=>this.errorHandler(reason));});shoper.addEvent("soobasket:beforeorder",(e,basket)=>{let protectionData=[];if(localStorage.appEasyProtectProtectionData){protectionData=JSON.parse(localStorage.appEasyProtectProtectionData);} if(protectionData.length==0&&$('#mxEnableEasyProtect').is(':checked')){basket.additional_fields[this.checkboxEnableFieldId]='Tak';}else{delete basket.additional_fields[this.checkboxEnableFieldId];}});return resolve(true);});};App.prototype.createProtectionFormSoobasket=function createProtectionFormSoobasket(tableRow){let basketProductId=tableRow.data('basket-product-id');let basketProduct=this.basketInfo.products.find((basketProduct)=>basketProduct.id==basketProductId);let productId=basketProduct.product_id;let chossenProtectionVariants=this.protectionVariants.filter((variant)=>variant.priceMin<=basketProduct.price_float&&basketProduct.price_float<=variant.priceMax);if(chossenProtectionVariants.length==0)return false;chossenProtectionVariants.sort((a,b)=>a.price-b.price);let noProtectionQuantity=basketProduct.quantity;let protectionData=[];if(localStorage.appEasyProtectProtectionData){protectionData=JSON.parse(localStorage.appEasyProtectProtectionData);} for(let key in protectionData){let data=protectionData[key];if(data.basketProductId!=basketProductId)continue;for(let key2 in this.basketInfo.products){let basketProtection=this.basketInfo.products[key2];if(basketProtection.id!=data.basketProtectionId)continue;noProtectionQuantity-=basketProtection.quantity;}} let form=$(`
`);let mxWrapper=form.find('.mxWrapper');let mxLeftCol=$(`
`).appendTo(mxWrapper);let bigPurpleArrow=$(``).appendTo(mxWrapper);bigPurpleArrow.attr('src','https://mxapp2.maxserver.pl/appEasyProtect/gfx/bigPurpleArrow.png');bigPurpleArrow.wrap(`
`);let mxRightCol=$(`
`).appendTo(mxWrapper);let name=this.escapeHtml(this.protection.name);let tradeMark='';if(name.charCodeAt(name.length-1)==174){tradeMark=`${name.substr(-1, 1)}`;name=name.substr(0,name.length-1);} if(name.charCodeAt(name.length-1)==8482){tradeMark=`${name.substr(-1, 1)}`;name=name.substr(0,name.length-1);} let mxImage=$(``).appendTo(mxLeftCol);mxImage.wrap(`
`);let mxNameContainer=$(`
`).appendTo(mxLeftCol);let mxName=$(`
${name}${tradeMark}
`).appendTo(mxNameContainer);let mxInfoPageUrl=$(`${this.getTranslation('infoPageText')}`).appendTo(mxNameContainer);mxInfoPageUrl.attr('href',this.infoPageUrl);mxInfoPageUrl.attr('target','_blank').attr('rel','noreferrer');mxInfoPageUrl.wrap(`
`);let smallPurpleArrow=$(``).insertBefore(mxInfoPageUrl);smallPurpleArrow.attr('src','https://mxapp2.maxserver.pl/appEasyProtect/gfx/smallPurpleArrow.png');smallPurpleArrow.wrap(`
`);let mxQuantityWrap=$(`
`).appendTo(mxRightCol);let mxQuantity=$(``).appendTo(mxQuantityWrap);for(let i=1;i<=noProtectionQuantity;i++){mxQuantity.append(``);} let mxOptions=$(`
`).appendTo(mxRightCol);if(this.noOption==1){let mxOption=$(``).appendTo(mxOptions);mxOption.attr('name',`radio_${basketProductId}`);mxOption.attr('id',`radio_${basketProductId}_no_option`);mxOption.attr('value',`0`);mxOption.wrap(`
`);let label=$(``).insertAfter(mxOption);label.attr('for',`radio_${basketProductId}_no_option`);label.append(this.getTranslation('noOptionText'));} for(let key in chossenProtectionVariants){let chossenVariant=chossenProtectionVariants[key];let mxOption=$(``).appendTo(mxOptions);mxOption.attr('name',`radio_${basketProductId}`);mxOption.attr('id',`radio_${basketProductId}_${chossenVariant.stockId}`);mxOption.attr('value',chossenVariant.stockId);mxOption.wrap(`
`);let label=$(``).insertAfter(mxOption);label.attr('for',`radio_${basketProductId}_${chossenVariant.stockId}`);label.append(`${chossenVariant.timePeriod} `);label.append(`${this.priceFormat(chossenVariant.price)}`);} let mxSum=$(`
`).appendTo(mxRightCol);let mxAction=$(`
`).appendTo(mxRightCol);let mxButtonAdd=$(`
${this.getTranslation('protectionAddText')}
`).appendTo(mxAction);mxQuantity.on('change',(e)=>{let quantity=parseFloat($(e.target).val());let stockId=parseFloat(mxOptions.find('input:checked').val());if(stockId==0){mxButtonAdd.stop().animate({'opacity':0.3});mxSum.text(this.priceFormat(0));} else{mxButtonAdd.stop().animate({'opacity':1});let price=0;for(let key in chossenProtectionVariants){let chossenVariant=chossenProtectionVariants[key];if(stockId==chossenVariant.stockId){price=chossenVariant.price;break;}} let quantity=mxQuantity.val();mxSum.text(this.priceFormat(price*quantity));} for(let key in this.$style.get(0).sheet.cssRules){let rule=this.$style.get(0).sheet.cssRules[key];if(rule.selectorText!='.protectionForm .mxRightCol .mxSum')continue;let width=mxSum.get(0).getBoundingClientRect().width;if(parseFloat(rule.style.minWidth){let quantity=parseFloat(mxQuantity.val());let stockId=parseFloat($(e.target).val());if(stockId==0){mxAction.addClass('mxHidden');mxButtonAdd.stop().animate({'opacity':0.3});mxSum.text(this.priceFormat(0));} else{mxAction.removeClass('mxHidden');mxButtonAdd.stop().animate({'opacity':1});let price=0;for(let key in chossenProtectionVariants){let chossenVariant=chossenProtectionVariants[key];if(stockId==chossenVariant.stockId){price=chossenVariant.price;break;}} mxSum.text(this.priceFormat(price*quantity));} for(let key in this.$style.get(0).sheet.cssRules){let rule=this.$style.get(0).sheet.cssRules[key];if(rule.selectorText!='.protectionForm .mxRightCol .mxSum')continue;let width=mxSum.get(0).getBoundingClientRect().width;if(parseFloat(rule.style.minWidth){let quantity=parseFloat(mxQuantity.val());let stockId=parseFloat(mxOptions.find('input:checked').val());if(stockId==0)return false;let options={};for(let key in chossenProtectionVariants){let chossenVariant=chossenProtectionVariants[key];if(stockId==chossenVariant.stockId){options=chossenVariant.options;break;}} let query={data:{stock_id:stockId,quantity:quantity,options:options,}};query.data.options[this.optionToProductId]=`${basketProduct.name}`;let hasVariant=0;if(basketProduct.variant!=''){hasVariant=1;query.data.options[this.optionToProductId]+=` (${basketProduct.variant})`;} query.data.options[this.optionDataId]=`${basketProduct.stock_id}, ${hasVariant}`;let wait=$('').appendTo('head');frontAPI.addToBasket((response)=>{if(response.added.length>0){let protectionData=[];if(localStorage.appEasyProtectProtectionData){protectionData=JSON.parse(localStorage.appEasyProtectProtectionData);} let protectionExisted=false;for(let key in protectionData){let data=protectionData[key];if(data.basketProductId!=basketProduct.id)continue;if(data.basketProtectionId!=response.added[0].id)continue;protectionExisted=true;break;} if(!protectionExisted){protectionData.push({basketProductId:basketProduct.id,basketProtectionId:response.added[0].id,});localStorage.appEasyProtectProtectionData=JSON.stringify(protectionData);} location.replace(location.href);} else{if(response._flash_messenger.error.length>0)shoper.alert(response._flash_messenger.error[0],'');if(response._flash_messenger.warning.length>0)shoper.alert(response._flash_messenger.warning[0],'');if(response._flash_messenger.info.length>0)shoper.alert(response._flash_messenger.info[0],'');} wait.remove();},query);});return form;};App.prototype.errorHandler=function errorHandler(reason){switch(reason){case'ExceedingProtection':console.log(reason);break;default:console.error(reason);break;}};App.prototype.insertStyle=function insertStyle(){this.$style.append(` .protectionForm .protectionFormTd { padding: 0; } .protectionForm .mxWrapper { padding: 10px 30px; display: flex; align-items: center; justify-content: space-between; gap: 20px; } .protectionForm .mxLeftCol { display: grid; grid: auto / 85px auto; gap: 5px; } .protectionForm .mxLeftCol .mxImage { align-self: center; justify-self: center; } .protectionForm .mxLeftCol .mxNameContainer { display: grid; align-content: center; gap: 10px; } .protectionForm .mxLeftCol .mxNameContainer .mxName { display: block; max-width: 350px; line-height: 24px; color: #666; font-size: 21px; font-weight: bold; text-align: center; } .protectionForm .mxLeftCol .mxNameContainer .mxName .mxTradeMark { margin-left: 3px; font-size: 15px; font-weight: normal; vertical-align: text-top; } .protectionForm .mxLeftCol .mxNameContainer .mxInfoPageUrl { text-align: center; } .protectionForm .mxLeftCol .mxNameContainer .mxInfoPageUrl a { text-decoration: none; font-size: 14px; font-weight: bold; } .protectionForm .mxLeftCol .mxNameContainer .mxInfoPageUrl .mxSmallPurpleArrow img { width: 19px; } .protectionForm .mxBigPurpleArrow { width: 30px; } .protectionForm .mxRightCol { position: relative; display: flex; align-items: center; gap: 20px; } .protectionForm .mxRightCol .mxQuantityWrap { position: relative; display: flex; align-items: center; } .protectionForm .mxRightCol .mxQuantityWrap::after { content: ""; position: absolute; display: block; right: 10px; width: 4px; height: 4px; margin-top: -2px; transform: rotate(-45deg); border-color: #392074; border-style: solid; border-width: 0 0 1px 1px; pointer-events: none; } .protectionForm .mxRightCol .mxQuantity { height: 30px; line-height: 30px; min-height: unset; min-width: 45px; padding: 0 18px 0 6px; background: #dcdddf !important; border: 1px solid #cac6d8; border-radius: 5px; color: #392074; font-size: 15px; font-weight: bold; cursor: pointer; } .protectionForm .mxRightCol .mxQuantity:hover, .protectionForm .mxRightCol .mxQuantity:focus { border-color: #a49cba; } .protectionForm .mxRightCol .mxOptions { display: grid; gap: 5px; } .protectionForm .mxRightCol .mxOptions .mxOption { } .protectionForm .mxRightCol .mxOptions .mxOption input { display: none !important; } .protectionForm .mxRightCol .mxOptions .mxOption label { display: block; line-height: 18px; min-width: max-content; padding: 6px 25px; background: #dcdddf; border: 1px solid #cac6d8; border-radius: 6px; font-size: 15px; font-weight: bold; text-align: center; cursor: pointer; } .protectionForm .mxRightCol .mxOptions .mxOption label:hover { border-color: #a49cba; } .protectionForm .mxRightCol .mxOptions .mxOption input:checked + label { border-color: #a49cba; } .protectionForm .mxRightCol .mxOptions .mxOption .mxColor { color: #392074; } .protectionForm .mxRightCol .mxSum { min-width: 68px; font-size: 16px; font-weight: bold; color: #392074; text-align: center; } .protectionForm .mxRightCol .mxAction .mxButtonAdd { line-height: 18px; padding: 6px 15px; border-radius: 6px; background: #dcdddf; border: 1px solid #cac6d8; color: #392074; font-size: 15px; font-weight: bold; text-align: center; cursor: pointer; } .protectionForm .mxRightCol .mxAction:not(.mxHidden) .mxButtonAdd:hover { border-color: #a49cba; } .protectionForm .mxRightCol .mxAction.mxHidden .mxButtonAdd { cursor: default; } .wce_celltitles .protectionForm { justify-content: center; padding: 15px; } .wce_celltitles .protectionForm .mxWrapper { flex-direction: column; padding: 0; } .wce_celltitles .protectionForm .mxBigPurpleArrow { display: none; } .el-table .protectionForm .protectionFormTd { border-bottom: 1px solid #ebeef5; } .el-table .protectionForm .mxWrapper { padding: 10px 20px 10px 10px; } .el-table .protectionForm .mxLeftCol { grid: auto / 100px auto; gap: 10px; } .el-table .protectionForm .mxLeftCol .mxImage img { margin: 0 !important; } .el-table .protectionForm .mxLeftCol .mxNameContainer .mxInfoPageUrl .mxSmallPurpleArrow img { margin: 0 !important; } .el-table .protectionForm .mxBigPurpleArrow img { margin: 0 !important; } .mxEasyProtectContainer { clear: both; margin-top: 30px; text-align: center; } .mxEasyProtectContainer .mxImage { height: 90px; } .mxEasyProtectContainer .mxImage img { max-height: 100%; } .mxEasyProtectContainer .mxName { margin-bottom: 15px; line-height: 30px; color: #392074; font-size: 30px; font-weight: bold; } .mxEasyProtectContainer .mxName .mxTradeMark { margin-left: 3px; font-size: 18px; font-weight: normal; vertical-align: text-top; } .mxEasyProtectContainer .mxText { max-width: 85%; margin: 0 auto; margin-bottom: 20px; line-height: 24px; font-size: 21px; font-weight: bold; } .mxEasyProtectContainer .mxSmallPurpleArrow { margin-bottom: 5px; } .mxEasyProtectContainer .mxInfoPageUrl { margin-bottom: 20px; font-size: 13px; font-weight: bold; } .mxEasyProtectContainer .mxOptions { display: flex; width: 100%; } .mxEasyProtectContainer .mxOptions .mxRwdTree { display: none; } .mxEasyProtectContainer .mxOptions .mxRwdTreeStamp { display: none; } .mxEasyProtectContainer .mxOptions .mxOption { flex: 1 1 100px; margin: 0 -1px; } .mxEasyProtectContainer .mxOptions .mxOption .mxBranches { display: grid; grid: 24px / 1fr 1fr; } .mxEasyProtectContainer .mxOptions .mxOption .mxLeftBranch { margin-right: -1.5px; border: 0px solid #4C3495; border-width: 3px 3px 0px 0px; } .mxEasyProtectContainer .mxOptions .mxOption .mxRightBranch { margin-left: -1.5px; border: 0px solid #4C3495; border-width: 3px 0px 0px 3px; } .mxEasyProtectContainer .mxOptions .mxOption:first-of-type .mxLeftBranch { border-width: 0; } .mxEasyProtectContainer .mxOptions .mxOption:first-of-type .mxRightBranch { border-top-left-radius: 22px; } .mxEasyProtectContainer .mxOptions .mxOption:last-of-type .mxLeftBranch { border-top-right-radius: 22px; } .mxEasyProtectContainer .mxOptions .mxOption:last-of-type .mxRightBranch { border-width: 0; } .mxEasyProtectContainer .mxOptions .mxOption .mxOptionInput { display: none; } .mxEasyProtectContainer .mxOptions .mxOption .mxOptionLabel { position: relative; display: block; width: 30px; height: 30px; margin: 0 auto; margin-bottom: 5px; border: 3px solid #4C3495; border-radius: 15px; box-sizing: border-box; } .mxEasyProtectContainer .mxOptions .mxOption .mxOptionLabel::before { content: ''; position: absolute; top: 4px; left: 4px; right: 4px; bottom: 4px; border-radius: 8px; } .mxEasyProtectContainer .mxOptions .mxOption .mxOptionInput:checked + .mxOptionLabel::before { background: #4C3495; } .mxEasyProtectContainer .mxOptions .mxOption .mxOptionText { display: block; font-size: 15px; font-weight: bold; color: #737477; } .mxEasyProtectContainer .mxOptions .mxOption .mxOptionName { display: block; margin-bottom: 20px; font-size: 16px; font-weight: bold; } .mxEasyProtectContainer .mxOptions .mxOption .mxOptionPrice { display: block; font-size: 20px; font-weight: bold; color: #392074; } @media screen and (max-width: 1200px) { } @media screen and (min-width: 980px) and (max-width: 1200px) { .protectionForm .mxLeftCol .mxNameContainer .mxName { max-width: 260px; } .protectionForm .mxRightCol .mxOptions .mxOption label { padding: 6px 20px; } .wce_celltitles .protectionForm .mxLeftCol .mxNameContainer .mxName { max-width: 350px; } .wce_celltitles .protectionForm .mxRightCol .mxOptions .mxOption label { padding: 6px 25px; } } @media screen and (max-width: 979px) { .protectionForm .mxWrapper { flex-direction: column; padding: 10px 8px; } .protectionForm .mxBigPurpleArrow { display: none; } .el-table .protectionForm .mxWrapper { flex-direction: row; padding: 10px 20px 10px 10px; } .el-table .protectionForm .mxBigPurpleArrow { display: block; } } @media screen and (min-width: 768px) and (max-width: 979px) { /*.protectionForm .mxRightCol .mxAction.mxHidden { display: none; }*/ .el-table .protectionForm .mxLeftCol .mxNameContainer .mxName { max-width: 260px; } /*.el-table .protectionForm .mxRightCol .mxAction.mxHidden { display: block; }*/ .el-table .protectionForm .mxRightCol .mxOptions .mxOption label { padding: 6px 20px; } .mxEasyProtectContainer .mxOptions { display: grid; grid-template: auto auto / 1fr 40px 1fr; row-gap: 30px; } .mxEasyProtectContainer .mxOptions .mxOption { position: relative; } .mxEasyProtectContainer .mxOptions .mxOption .mxBranches { position: absolute; width: 100%; top: 13.5px; } .mxEasyProtectContainer .mxOptions .mxRwdTree { grid-area: 1 / 2 / 2 / 3; display: grid; grid-template: 100% / auto auto; margin: 0 -1px; margin-top: 13.5px; margin-bottom: -46px; } .mxEasyProtectContainer .mxOptions .mxRwdTreeStamp { grid-area: 2 / 2 / 3 / 3; display: block; } .mxEasyProtectContainer .mxOptions .mxRwdTree .mxLeftBranch { margin-right: -1.5px; border: 0px solid #4C3495; border-width: 3px 3px 3px 0px; border-radius: 0px 22px 22px 0px; } .mxEasyProtectContainer .mxOptions .mxRwdTree .mxRightBranch { margin-left: -1.5px; border: 0px solid #4C3495; border-width: 3px 0px 3px 3px; border-radius: 22px 0px 0px 22px; } .mxEasyProtectContainer .mxOptions .mxOption:nth-of-type(odd) .mxLeftBranch { border-width: 0; } .mxEasyProtectContainer .mxOptions .mxOption:nth-of-type(odd) .mxRightBranch { border-top-left-radius: 0; border-width: 3px 0px 0px 0px; margin-left: 13.5px; } .mxEasyProtectContainer .mxOptions .mxOption:nth-of-type(even) .mxLeftBranch { border-top-right-radius: 0px; border-width: 3px 0px 0px 0px; margin-right: 13.5px; } .mxEasyProtectContainer .mxOptions .mxOption:nth-of-type(even) .mxRightBranch { border-width: 0; } .mxEasyProtectContainer .mxOptions .mxOption:nth-of-type(3) + .mxRwdTree .mxRightBranch { border-width: 3px 0px 0px 3px; border-radius: 22px 0px 0px 0px; margin-bottom: 22px; } .mxEasyProtectContainer .mxOptions .mxOption:nth-of-type(2) + .mxRwdTree .mxLeftBranch { border-width: 3px 0px 0px 0px; border-radius: 0; } .mxEasyProtectContainer .mxOptions .mxOption:nth-of-type(2) + .mxRwdTree .mxRightBranch { border-width: 3px 0px 0px 0px; border-radius: 0; } } @media screen and (max-width: 767px) { .protectionForm .mxRightCol .mxOptions .mxOption label { padding: 6px 20px; } .el-table .protectionForm { display: flex; width: 100%; } .el-table .protectionForm .protectionFormTd { width: 100%; } .el-table .protectionForm .mxWrapper { flex-direction: column; padding: 10px 0; } .el-table .protectionForm .mxBigPurpleArrow { display: none; } } @media screen and (min-width: 481px) and (max-width: 767px) { /*.protectionForm .mxRightCol .mxAction.mxHidden { display: none; }*/ } @media screen and (max-width: 480px) { .protectionForm .mxRightCol { display: grid; grid: auto 1fr auto / repeat(2, auto); grid-template-areas: "mxOptions mxQuantityWrap" "mxOptions mxSum" "mxOptions mxAction"; justify-items: center; gap: 10px 20px; } .protectionForm .mxRightCol .mxQuantityWrap { grid-area: mxQuantityWrap; } .protectionForm .mxRightCol .mxOptions { grid-area: mxOptions; height: 100%; align-content: space-between; } .protectionForm .mxRightCol .mxSum { grid-area: mxSum; } .protectionForm .mxRightCol .mxAction { grid-area: mxAction; } .el-table .protectionForm .mxLeftCol { grid: auto / 85px auto; } .mxEasyProtectContainer .mxOptions { display: grid; grid-template: auto auto / 1fr 40px 1fr; row-gap: 30px; } .mxEasyProtectContainer .mxOptions .mxOption { position: relative; } .mxEasyProtectContainer .mxOptions .mxOption .mxBranches { position: absolute; width: 100%; top: 13.5px; } .mxEasyProtectContainer .mxOptions .mxRwdTree { grid-area: 1 / 2 / 2 / 3; display: grid; grid-template: 100% / auto auto; margin: 0 -1px; margin-top: 13.5px; margin-bottom: -46px; } .mxEasyProtectContainer .mxOptions .mxRwdTreeStamp { grid-area: 2 / 2 / 3 / 3; display: block; } .mxEasyProtectContainer .mxOptions .mxRwdTree .mxLeftBranch { margin-right: -1.5px; border: 0px solid #4C3495; border-width: 3px 3px 3px 0px; border-radius: 0px 22px 22px 0px; } .mxEasyProtectContainer .mxOptions .mxRwdTree .mxRightBranch { margin-left: -1.5px; border: 0px solid #4C3495; border-width: 3px 0px 3px 3px; border-radius: 22px 0px 0px 22px; } .mxEasyProtectContainer .mxOptions .mxOption:nth-of-type(odd) .mxLeftBranch { border-width: 0; } .mxEasyProtectContainer .mxOptions .mxOption:nth-of-type(odd) .mxRightBranch { border-top-left-radius: 0; border-width: 3px 0px 0px 0px; margin-left: 13.5px; } .mxEasyProtectContainer .mxOptions .mxOption:nth-of-type(even) .mxLeftBranch { border-top-right-radius: 0px; border-width: 3px 0px 0px 0px; margin-right: 13.5px; } .mxEasyProtectContainer .mxOptions .mxOption:nth-of-type(even) .mxRightBranch { border-width: 0; } .mxEasyProtectContainer .mxOptions .mxOption:nth-of-type(3) + .mxRwdTree .mxRightBranch { border-width: 3px 0px 0px 3px; border-radius: 22px 0px 0px 0px; margin-bottom: 22px; } .mxEasyProtectContainer .mxOptions .mxOption:nth-of-type(2) + .mxRwdTree .mxLeftBranch { border-width: 3px 0px 0px 0px; border-radius: 0; } .mxEasyProtectContainer .mxOptions .mxOption:nth-of-type(2) + .mxRwdTree .mxRightBranch { border-width: 3px 0px 0px 0px; border-radius: 0; } } @media screen and (min-width: 980px) { /*.wce_celltitles .protectionForm .mxRightCol .mxAction.mxHidden { display: none; }*/ } `);};App.prototype.insertInfoPageStyle=function insertInfoPageStyle(){this.$style.append(` .mxArticle .mxMainBanner img { max-height: 100%; } .mxArticle .mxMainTitle { color: #392074; font-size: 4em; text-align: center; margin-bottom: 30px; margin-top: 20px; line-height: 1.3em; font-weight: bold; } .mxArticle .mx_arrow_down { text-align: center; } .mxArticle .mx_under_header_txt { font-size: 1.4em; line-height: 1.5em; font-weight: 600; text-align: center; max-width: 640px; margin: 0 auto; margin-top: 10px; } .mxArticle .mxTitle { font-size: 1.7rem; font-weight: 600; line-height: 1.5em; text-align: center; margin: 30px 0 10px 0; color: #392074; display: block; /*shoper konvertuje na span*/ } .mxArticle .mxToolsRepairCost { max-width: 880px; margin: 20px auto; text-align: center; } .mxArticle .mx_arrow_up { text-align: center; transform: rotate(180deg); } .mxArticle .mx_margin { margin-bottom: 30px; } .mxArticle .mxAttributesHoneycomb { max-width: 880px; margin: 0 auto; text-align: center; } .mxArticle .mxAttributesHoneycombBackground { background-color: rgb(230, 231, 233); padding: 50px 0; } .mxArticle .mxServiceSteps { max-width: 880px; margin: 50px auto; text-align: center; } .mxArticle .mxInNumbers { background-color: rgb(230, 231, 233); padding: 20px 0; } .mxArticle .mxInNumbers .logo_img { text-align: center; } .mxArticle .mxInNumbers .mxInNumbersHeader { font-size: 1.7rem; text-align: center; color: rgb(96, 100, 108); margin-bottom: 10px; line-height: 1.3em; font-weight: bold; } .mxArticle .mxInNumbers .mxInNumbersHeader .mxColor { color: #392074; } .mxArticle .mxInNumbers .mx_inner_box { display: grid; justify-content: center; grid-template-areas: "first second third fourth" ". bottom_first bottom_second ."; } .mxArticle .mxInNumbers .mx_tile { text-align: center; background-color: white; padding: 10px; height: 150px; width: 150px; border-radius: 30px; margin: 25px; } .mxArticle .mxInNumbers .inside_box_tile { text-align: center; padding: 5px; } .mxArticle .mxInNumbers .mx_smaller_text { display: block; width: 80%; margin: auto; } .mxArticle .mxInNumbers .mx_bolder_upper_text { font-weight: 600; font-size: 1rem; color: #60646c; } .mxArticle .mxInNumbers .bolder_small_text { font-weight: 600; color: #60646c; } .mxArticle .mxInNumbers .over_ten_year.mx_tile { grid-area: first; } .mxArticle .mxInNumbers .over_likes.mx_tile { grid-area: second; } .mxArticle .mxInNumbers .every_five_minutes.mx_tile { grid-area: third; } .mxArticle .mxInNumbers .service_points.mx_tile { grid-area: fourth; } .mxArticle .mxInNumbers .mx_partenrs_tile.mx_tile { grid-area: bottom_first; } .mxArticle .mxInNumbers .active_traders.mx_tile { grid-area: bottom_second; } @media screen and (max-width: 1200px) { } @media screen and (min-width: 980px) and (max-width: 1200px) { } @media screen and (max-width: 979px) { } @media screen and (min-width: 768px) and (max-width: 979px) { .mxArticle .mxInNumbers .mx_inner_box { grid-template-areas: "first second third" "fourth bottom_first bottom_second"; } } @media screen and (max-width: 767px) { } @media screen and (min-width: 481px) and (max-width: 767px) { .mxArticle .mxInNumbers .mx_inner_box { grid-template-areas: "first second" "third fourth" "bottom_first bottom_second"; } } @media screen and (max-width: 480px) { .mxArticle .mxInNumbers .mx_inner_box { grid-template-areas: "first" "second" "third" "fourth" "bottom_first" "bottom_second"; } } `);};App.prototype.getTranslation=function getTranslation(varName,escape=true,lang=this.lang){let translation='';if(lang in this.translations[varName]){translation=this.translations[varName][lang];}else{translation=this.translations[varName]['__default'];} if(!escape)return translation;return this.escapeHtml(translation);};App.prototype.escapeHtml=function escapeHtml(unsafe){return unsafe.replace(/&/g,"&").replace(//g,">").replace(/"/g,""").replace(/'/g,"'");};App.prototype.priceFormat=function priceFormat(price,currency=this.currency,lang=this.lang){if(currency==undefined){throw new Error('Undefined currency');} if(typeof this._priceFormater==='undefined'||this._priceFormaterLang!=lang||this._priceFormaterCurrency!=currency){this._priceFormaterLang=lang;this._priceFormaterCurrency=currency;this._priceFormater=new Intl.NumberFormat(lang.split('_').join('-'),{style:'currency',currency:currency});} return this._priceFormater.format(price);};App.prototype.loadCurrency=function loadCurrency(){if('currency'in this)return Promise.resolve(this.currency);return new Promise((resolve,reject)=>{this.waitFor(()=>{return typeof Shop.values==='object'&&typeof Shop.values.currency==='string';},()=>{this.currency=Shop.values.currency;return resolve(this.currency);});});};App.prototype.waitFor=function waitFor(expr,callback,interval=0){if(!expr()){setTimeout(this.waitFor.bind(this,expr,callback,interval),interval);} else{callback();}};setTimeout(()=>App.prototype.waitFor(()=>typeof Shop.pageType==='string',()=>new App()),0);})(jQuery);