(window.webpackJsonpalfagresalfa_components_10_3_24=window.webpackJsonpalfagresalfa_components_10_3_24||[]).push([[5],{35:function(e,n){var i={kind:"Document",definitions:[{kind:"OperationDefinition",operation:"query",name:{kind:"Name",value:"getRewardValue"},variableDefinitions:[{kind:"VariableDefinition",variable:{kind:"Variable",name:{kind:"Name",value:"value"}},type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"ID"}}},directives:[]}],directives:[{kind:"Directive",name:{kind:"Name",value:"context"},arguments:[{kind:"Argument",name:{kind:"Name",value:"sender"},value:{kind:"StringValue",value:"alfagresalfa.components@10.3.24",block:!1}}]}],selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"product"},arguments:[{kind:"Argument",name:{kind:"Name",value:"identifier"},value:{kind:"ObjectValue",fields:[{kind:"ObjectField",name:{kind:"Name",value:"field"},value:{kind:"EnumValue",value:"sku"}},{kind:"ObjectField",name:{kind:"Name",value:"value"},value:{kind:"Variable",name:{kind:"Name",value:"value"}}}]}}],directives:[{kind:"Directive",name:{kind:"Name",value:"context"},arguments:[{kind:"Argument",name:{kind:"Name",value:"provider"},value:{kind:"StringValue",value:"vtex.search-graphql",block:!1}}]},{kind:"Directive",name:{kind:"Name",value:"runtimeMeta"},arguments:[{kind:"Argument",name:{kind:"Name",value:"hash"},value:{kind:"StringValue",value:"f2775381c4e97caeec110c6a32855cb03bc03d613a17c346bec033fcfab8cc26",block:!1}}]}],selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"productId"},arguments:[],directives:[]},{kind:"Field",name:{kind:"Name",value:"properties"},arguments:[],directives:[],selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"name"},arguments:[],directives:[]},{kind:"Field",name:{kind:"Name",value:"values"},arguments:[],directives:[]},{kind:"Field",name:{kind:"Name",value:"__typename"},arguments:[],directives:[]}]}},{kind:"Field",name:{kind:"Name",value:"items"},arguments:[],directives:[],selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"itemId"},arguments:[],directives:[]},{kind:"Field",name:{kind:"Name",value:"measurementUnit"},arguments:[],directives:[]},{kind:"Field",name:{kind:"Name",value:"variations"},arguments:[],directives:[],selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"name"},arguments:[],directives:[]},{kind:"Field",name:{kind:"Name",value:"values"},arguments:[],directives:[]},{kind:"Field",name:{kind:"Name",value:"__typename"},arguments:[],directives:[]}]}},{kind:"Field",name:{kind:"Name",value:"sellers"},arguments:[],directives:[],selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"sellerDefault"},arguments:[],directives:[]},{kind:"Field",name:{kind:"Name",value:"commertialOffer"},arguments:[],directives:[],selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"Price"},arguments:[],directives:[]},{kind:"Field",name:{kind:"Name",value:"ListPrice"},arguments:[],directives:[]},{kind:"Field",name:{kind:"Name",value:"RewardValue"},arguments:[],directives:[]},{kind:"Field",name:{kind:"Name",value:"AvailableQuantity"},arguments:[],directives:[]},{kind:"Field",name:{kind:"Name",value:"__typename"},arguments:[],directives:[]}]}},{kind:"Field",name:{kind:"Name",value:"__typename"},arguments:[],directives:[]}]}},{kind:"Field",name:{kind:"Name",value:"__typename"},arguments:[],directives:[]}]}},{kind:"Field",name:{kind:"Name",value:"__typename"},arguments:[],directives:[]}]}}]}}],loc:{start:0,end:721}};i.loc.source={body:'query getRewardValue($value: ID!) @context(sender: "alfagresalfa.components@10.3.24") {\n product(identifier: {field: sku, value: $value}) @context(provider: "vtex.search-graphql") @runtimeMeta(hash: "f2775381c4e97caeec110c6a32855cb03bc03d613a17c346bec033fcfab8cc26") {\n productId\n properties {\n name\n values\n __typename\n }\n items {\n itemId\n measurementUnit\n variations {\n name\n values\n __typename\n }\n sellers {\n sellerDefault\n commertialOffer {\n Price\n ListPrice\n RewardValue\n AvailableQuantity\n __typename\n }\n __typename\n }\n __typename\n }\n __typename\n }\n}\n',name:"GraphQL request",locationOffset:{line:1,column:1}};var a={};function t(e,n){for(var i=0;i0;){var u=d;d=new Set,u.forEach((function(e){l.has(e)||(l.add(e),(a[e]||new Set).forEach((function(e){d.add(e)})))}))}return l.forEach((function(n){var a=t(e,n);a&&i.definitions.push(a)})),i}(i,"getRewardValue")},73:function(e,n,i){"use strict";i.r(n),i.d(n,"findBestSku",(function(){return v}));var a=i(0),t=i.n(a),r=i(6),l=i.n(r),d=i(44),u=i.n(d),s=i(29),c=i(35),m=i.n(c),o=i(74),f=i.n(o).a.useProductSummaryDispatch;function v(e){var n=e.product.items,i=n.filter((function(e){return e.sellers.find((function(e){return e.sellerDefault})).commertialOffer.AvailableQuantity>0}));return i.length>0?i.reduce((function(e,n){return(n.sellers.find((function(e){return e.sellerDefault})).commertialOffer.ListPrice-n.sellers.find((function(e){return e.sellerDefault})).commertialOffer.Price)/n.sellers.find((function(e){return e.sellerDefault})).commertialOffer.ListPrice>(e.sellers.find((function(e){return e.sellerDefault})).commertialOffer.ListPrice-e.sellers.find((function(e){return e.sellerDefault})).commertialOffer.Price)/e.sellers.find((function(e){return e.sellerDefault})).commertialOffer.ListPrice?n:e})):n.reduce((function(e,n){return(n.sellers.find((function(e){return e.sellerDefault})).commertialOffer.ListPrice-n.sellers.find((function(e){return e.sellerDefault})).commertialOffer.Price)/n.sellers.find((function(e){return e.sellerDefault})).commertialOffer.ListPrice>(e.sellers.find((function(e){return e.sellerDefault})).commertialOffer.ListPrice-e.sellers.find((function(e){return e.sellerDefault})).commertialOffer.Price)/e.sellers.find((function(e){return e.sellerDefault})).commertialOffer.ListPrice?n:e}))}n.default=function(){var e,n=l()(),i=u()(),r=f(),d=Object(s.useQuery)(m.a,{variables:{value:(null===(e=null==n?void 0:n.selectedItem)||void 0===e?void 0:e.itemId)||""}}),c=d.data,o=d.loading;return Object(a.useEffect)((function(){var e,a,t,l;if(c&&i){!(null===(e=null==n?void 0:n.product)||void 0===e?void 0:e.properties)&&c.product.properties.length&&i({type:"SET_PRODUCT",args:{product:Object.assign(Object.assign({},null==n?void 0:n.product),{properties:c.product.properties})}});var d=v(c);if(d&&(null===(a=null==n?void 0:n.selectedItem)||void 0===a?void 0:a.itemId)!=d.itemId){var u=null===(t=null==n?void 0:n.product)||void 0===t?void 0:t.items.find((function(e){return e.itemId==d.itemId}));u&&i({type:"SET_SELECTED_ITEM",args:{item:u}})}}r({type:"SET_PRODUCT_QUERY",args:{query:"skuId=".concat(null===(l=null==n?void 0:n.selectedItem)||void 0===l?void 0:l.itemId)}})}),[c,n]),o?null:t.a.createElement(t.a.Fragment,null)}}}]);