@bikdotai/bik-component-library 0.0.728 → 0.0.729-beta.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (37) hide show
  1. package/dist/cjs/components/QueryBuilder/Triggers/EVENTS/components/EventsTrigger.d.ts +1 -1
  2. package/dist/cjs/components/QueryBuilder/Triggers/EVENTS/selectors/useIGTriggerNameCacheSelector.d.ts +1 -1
  3. package/dist/cjs/components/QueryBuilder/Triggers/IG/components/IGTrigger.d.ts +1 -1
  4. package/dist/cjs/components/QueryBuilder/Triggers/IG/selectors/useIGTriggerNameCacheSelector.d.ts +1 -1
  5. package/dist/cjs/components/QueryBuilder/Triggers/components/BaseTriggerQueryBuilderNode.d.ts +2 -2
  6. package/dist/cjs/components/bik-layout/MockMenus.d.ts +1 -0
  7. package/dist/cjs/components/custom-date-time/CustomDateTime.js +1 -1
  8. package/dist/cjs/components/data-source-panel/DataSourcePanel.js +1 -1
  9. package/dist/cjs/components/discount-modal/CouponExpiration/CouponExpiration.d.ts +1 -0
  10. package/dist/cjs/components/discount-modal/CouponExpiration/CouponExpiration.js +1 -1
  11. package/dist/cjs/components/discount-modal/DiscountModal.d.ts +1 -0
  12. package/dist/cjs/components/discount-modal/DiscountModal.js +1 -1
  13. package/dist/cjs/components/discount-modal/DiscountUtils.d.ts +1 -1
  14. package/dist/cjs/components/discount-modal/DiscountUtils.js +1 -1
  15. package/dist/cjs/components/discount-modal/DynamicCoupon/DynamicCoupon.d.ts +2 -0
  16. package/dist/cjs/components/discount-modal/DynamicCoupon/DynamicCoupon.js +1 -1
  17. package/dist/cjs/components/discount-modal/StaticCoupon/StaticCoupon.d.ts +51 -1
  18. package/dist/cjs/components/discount-modal/StaticCoupon/StaticCoupon.js +1 -1
  19. package/dist/esm/components/QueryBuilder/Triggers/EVENTS/components/EventsTrigger.d.ts +1 -1
  20. package/dist/esm/components/QueryBuilder/Triggers/EVENTS/selectors/useIGTriggerNameCacheSelector.d.ts +1 -1
  21. package/dist/esm/components/QueryBuilder/Triggers/IG/components/IGTrigger.d.ts +1 -1
  22. package/dist/esm/components/QueryBuilder/Triggers/IG/selectors/useIGTriggerNameCacheSelector.d.ts +1 -1
  23. package/dist/esm/components/QueryBuilder/Triggers/components/BaseTriggerQueryBuilderNode.d.ts +2 -2
  24. package/dist/esm/components/bik-layout/MockMenus.d.ts +1 -0
  25. package/dist/esm/components/custom-date-time/CustomDateTime.js +1 -1
  26. package/dist/esm/components/data-source-panel/DataSourcePanel.js +1 -1
  27. package/dist/esm/components/discount-modal/CouponExpiration/CouponExpiration.d.ts +1 -0
  28. package/dist/esm/components/discount-modal/CouponExpiration/CouponExpiration.js +1 -1
  29. package/dist/esm/components/discount-modal/DiscountModal.d.ts +1 -0
  30. package/dist/esm/components/discount-modal/DiscountModal.js +1 -1
  31. package/dist/esm/components/discount-modal/DiscountUtils.d.ts +1 -1
  32. package/dist/esm/components/discount-modal/DiscountUtils.js +1 -1
  33. package/dist/esm/components/discount-modal/DynamicCoupon/DynamicCoupon.d.ts +2 -0
  34. package/dist/esm/components/discount-modal/DynamicCoupon/DynamicCoupon.js +1 -1
  35. package/dist/esm/components/discount-modal/StaticCoupon/StaticCoupon.d.ts +51 -1
  36. package/dist/esm/components/discount-modal/StaticCoupon/StaticCoupon.js +1 -1
  37. package/package.json +1 -1
@@ -1,4 +1,4 @@
1
1
  import React from 'react';
2
- import { QueryBuilderNodeProps } from "../../../types/QueryBuilderNodeProps.type";
2
+ import { QueryBuilderNodeProps } from "../../../Types/QueryBuilderNodeProps.type";
3
3
  declare const EventsTrigger: React.FC<QueryBuilderNodeProps>;
4
4
  export default EventsTrigger;
@@ -1,2 +1,2 @@
1
- import { QueryBuilderAPIData } from "../../../types/QueryBuilderAPI.type";
1
+ import { QueryBuilderAPIData } from "../../../Types/QueryBuilderAPI.type";
2
2
  export declare const useIGTriggerNameCacheSelector: () => QueryBuilderAPIData[];
@@ -1,4 +1,4 @@
1
1
  import React from 'react';
2
- import { QueryBuilderNodeProps } from "../../../types/QueryBuilderNodeProps.type";
2
+ import { QueryBuilderNodeProps } from "../../../Types/QueryBuilderNodeProps.type";
3
3
  declare const IGTrigger: React.FC<QueryBuilderNodeProps>;
4
4
  export default IGTrigger;
@@ -1,2 +1,2 @@
1
- import { QueryBuilderAPIData } from "../../../types/QueryBuilderAPI.type";
1
+ import { QueryBuilderAPIData } from "../../../Types/QueryBuilderAPI.type";
2
2
  export declare const useIGTriggerNameCacheSelector: () => QueryBuilderAPIData[];
@@ -1,7 +1,7 @@
1
1
  import React from 'react';
2
2
  import { DropdownOption } from "../../../dropdown/type";
3
- import { QueryBuilderProperty } from "../../types/QueryBuilder.type";
4
- import { QueryBuilderNodeProps } from "../../types/QueryBuilderNodeProps.type";
3
+ import { QueryBuilderProperty } from "../../Types/QueryBuilder.type";
4
+ import { QueryBuilderNodeProps } from "../../Types/QueryBuilderNodeProps.type";
5
5
  declare const BaseTriggerQueryBuilderNode: React.FC<QueryBuilderNodeProps & {
6
6
  cacheKey: string;
7
7
  propertyAddBtnText: string;
@@ -1,3 +1,4 @@
1
+ /// <reference types="react" />
1
2
  export declare const Menus: ({
2
3
  displayName: string;
3
4
  key: number;
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../../node_modules/react/jsx-runtime.js"),t=require("date-fns"),r=require("react"),o=require("./DateSelector/DateSelector.js"),s=require("../dropdown/DropdownPopover/index.js");require("../dropdown/Dropdown.js"),require("../dropdown/ChipDropdown.js"),require("../zeroState/ZeroState.js");var n=require("../TypographyStyle.js");require("../../constants/Theme.js"),require("../dropdown/OpenedDropdown/components/description/Description.styled.js"),require("../checkBox/CheckBox.styled.js"),require("../list-item/ListItem.js"),require("../dropdown/OpenedDropdown/components/menu/FreeFormMenu.styled.js"),require("../dropdown/OpenedDropdown/components/menu/MenuItem.js"),require("../dropdown/OpenedDropdown/components/menu/MenuList.styled.js"),require("../button/Button.js"),require("../dropdown/OpenedDropdown/components/multiSelect/MultiSelectDropdownBottomBar.styled.js"),require("../dropdown/OpenedDropdown/components/OpennedDropdown.styled.js"),require("../icon-button/IconButton.js");var i=require("../input/Input.js");require("../dropdown/MenuItem/MenuItem.js");var u=require("../../utils/DateUtils.js"),d=require("../../assets/icons/chevronDown.svg.js"),l=require("../../assets/icons/clock.svg.js"),a=require("./CustomDateTime.styled.js");const p=e=>{const t=[];for(let r=0;r<2;r++)for(let o=0;o<12;o++){let s;s=0===o?"12":o<10?`0${o}`:`${o}`;const n=`${s}:00 ${0===r?"AM":"PM"}`,i=`${s}:30 ${0===r?"AM":"PM"}`;t.push({label:n,value:n,selected:n===e},{label:i,value:i,selected:i===e})}return t};exports.CustomDateTime=c=>{const[m,j]=r.useState(c.time),[x,D]=r.useState(c.date);r.useEffect((()=>{c.setError(void 0);const e=u.default.convert12HourTimeTo24Hour(m),r=t.format(new Date,"HH:mm:ss");if(t.isToday(x)&&e<r)return void c.setError("Selected time should be later than current time");c.setError(void 0);const[o,s]=e.split(":"),n=new Date(x.getTime());n.setHours(+o,+s),c.onChange(n)}),[x,m]);return e.jsxRuntimeExports.jsxs(a.CustomDateTimeStyle,{children:[e.jsxRuntimeExports.jsxs("div",Object.assign({style:{display:"flex",gap:16}},{children:[e.jsxRuntimeExports.jsx("div",Object.assign({style:{flex:1}},{children:e.jsxRuntimeExports.jsx(o.default,{customDate:x,setCustomDate:D,placement:c.placement,minDate:c.minDate})})),e.jsxRuntimeExports.jsx("div",Object.assign({style:{flex:1}},{children:e.jsxRuntimeExports.jsx(s.DropdownPopover,Object.assign({options:p(m),onSelect:e=>{j(e.value)}},{children:e.jsxRuntimeExports.jsx(i.Input,{value:m,leftIcon:{icon:l.default},rightIcon:{icon:d.default},onChangeText:e=>(e=>{if(u.default.timeFormatValidation(e)){const r=u.default.convert12HourTimeTo24Hour(e),o=t.format(new Date,"HH:mm:ss");if(t.isToday(x)&&r<o)return void c.setError("Selected time should be later than current time");c.setError(void 0),j(e)}else c.setError('Format of time should be "HH:MM AM" or "HH:MM PM"')})(e)})}))}))]})),c.error&&e.jsxRuntimeExports.jsx(n.BodySecondary,Object.assign({style:{paddingTop:8}},{children:c.error}))]})};
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../../node_modules/react/jsx-runtime.js"),t=require("date-fns"),r=require("react"),o=require("./DateSelector/DateSelector.js"),s=require("../dropdown/DropdownPopover/index.js");require("../dropdown/Dropdown.js"),require("../dropdown/ChipDropdown.js"),require("../zeroState/ZeroState.js");var n=require("../TypographyStyle.js");require("../../constants/Theme.js"),require("../dropdown/OpenedDropdown/components/description/Description.styled.js"),require("../checkBox/CheckBox.styled.js"),require("../list-item/ListItem.js"),require("../dropdown/OpenedDropdown/components/menu/FreeFormMenu.styled.js"),require("../dropdown/OpenedDropdown/components/menu/MenuItem.js"),require("../dropdown/OpenedDropdown/components/menu/MenuList.styled.js"),require("../button/Button.js"),require("../dropdown/OpenedDropdown/components/multiSelect/MultiSelectDropdownBottomBar.styled.js"),require("../dropdown/OpenedDropdown/components/OpennedDropdown.styled.js"),require("../icon-button/IconButton.js");var i=require("../input/Input.js");require("../dropdown/MenuItem/MenuItem.js");var u=require("../../utils/DateUtils.js"),d=require("../../assets/icons/chevronDown.svg.js"),l=require("../../assets/icons/clock.svg.js"),a=require("./CustomDateTime.styled.js");const p=e=>{const t=[];for(let r=0;r<2;r++)for(let o=0;o<12;o++){let s;s=0===o?"12":o<10?`0${o}`:`${o}`;const n=`${s}:00 ${0===r?"AM":"PM"}`,i=`${s}:30 ${0===r?"AM":"PM"}`;t.push({label:n,value:n,selected:n===e},{label:i,value:i,selected:i===e})}return t};exports.CustomDateTime=c=>{const[m,j]=r.useState(c.time),[x,D]=r.useState(c.date);r.useEffect((()=>{c.setError(void 0);const e=u.default.convert12HourTimeTo24Hour(m),r=t.format(new Date,"HH:mm:ss");if(t.isToday(x)&&e<r)return void c.setError("Selected time should be later than current time");c.setError(void 0);const[o,s]=e.split(":"),n=new Date(x);n.setHours(+o,+s),c.onChange(n)}),[x,m]);return e.jsxRuntimeExports.jsxs(a.CustomDateTimeStyle,{children:[e.jsxRuntimeExports.jsxs("div",Object.assign({style:{display:"flex",gap:16}},{children:[e.jsxRuntimeExports.jsx("div",Object.assign({style:{flex:1}},{children:e.jsxRuntimeExports.jsx(o.default,{customDate:x,setCustomDate:D,placement:c.placement,minDate:c.minDate})})),e.jsxRuntimeExports.jsx("div",Object.assign({style:{flex:1}},{children:e.jsxRuntimeExports.jsx(s.DropdownPopover,Object.assign({options:p(m),onSelect:e=>{j(e.value)}},{children:e.jsxRuntimeExports.jsx(i.Input,{value:m,leftIcon:{icon:l.default},rightIcon:{icon:d.default},onChangeText:e=>(e=>{if(u.default.timeFormatValidation(e)){const r=u.default.convert12HourTimeTo24Hour(e),o=t.format(new Date,"HH:mm:ss");if(t.isToday(x)&&r<o)return void c.setError("Selected time should be later than current time");c.setError(void 0),j(e)}else c.setError('Format of time should be "HH:MM AM" or "HH:MM PM"')})(e)})}))}))]})),c.error&&e.jsxRuntimeExports.jsx(n.BodySecondary,Object.assign({style:{paddingTop:8}},{children:c.error}))]})};
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../../node_modules/react/jsx-runtime.js"),t=require("@bikdotai/bik-models/growth/models/bik-store"),s=require("../../assets/icons/box_search.svg.js"),i=require("../../assets/icons/boxV2.svg.js"),o=require("../../assets/icons/chevronDownOutline.svg.js"),n=require("../../assets/icons/chevronUpOutline.svg.js"),r=require("../../assets/icons/cross.svg.js"),l=require("../../assets/icons/edit.svg.js"),a=require("../../assets/icons/filePdf.svg.js"),d=require("../../assets/icons/help.svg.js"),c=require("../../assets/icons/info.svg.js"),u=require("../../assets/icons/openai.svg.js"),x=require("../../assets/icons/plus.svg.js"),p=require("../../assets/icons/redirect.svg.js"),j=require("../../assets/icons/text_t9.svg.js"),m=require("../../assets/icons/website.svg.js"),g=require("react"),h=require("../../constants/Theme.js"),y=require("../button/Button.js"),E=require("../icon-button/IconButton.js"),C=require("../shimmer/ShimmerComponent/BikShimmer.js"),R=require("../side-modal/SideModal.js"),O=require("../tag/Tag.js"),f=require("../tooltips/Tooltip.js"),v=require("../TypographyStyle.js"),S=require("./DataSourceInfoFooter.js"),T=require("./DataSourcePanel.style.js"),I=require("./IntentConfig.js"),b=require("./Modals/DescriptionModal.js"),L=require("./model.js");exports.DataSourcePanel=w=>{var D,N;const{appType:A,storeId:k,messageSource:_,setMessageSourcePanel:F,hideCloseButton:B,isSourceInfoFetched:q,allSourceInfoDetail:P,ChecklistType:M,title:U,zeroStateButton:K,editableSources:W,preFillTrainingSourceCount:$,redirect:H,footerButtonOption:Q,fetchTrainingSourceCount:G,fetchProductFAQCount:Y,productSourceData:z,reasonForAiGeneratedResponse:X,showAiResponseReason:V,aiResponseLoading:J,productSearchRule:Z,onEditProductSearchRule:ee}=w,{sources:te}=_,se=["blog","article","page","policy"],[ie,oe]=g.useState(!1),[ne,re]=g.useState(!1),[le,ae]=g.useState(!1),[de,ce]=g.useState(0),[ue,xe]=g.useState(),[pe,je]=g.useState(null!=$?$:{}),[me,ge]=g.useState(!1),[he,ye]=g.useState(!1),Ee={};I.intentConfig.forEach((t=>{let{key:s,type:i,tagText:o}=t;M[s]&&(Ee[M[s]]=e.jsxRuntimeExports.jsx(O.Tag,{theme:"light",type:i,tagText:o,cursor:"pointer"}))}));const Ce=te.filter((e=>"PRODUCTS"==e.type||"Products"==e.subTitle||e.productId)),Re=te.filter((e=>"PRODUCTS"!=e.type&&"Products"!=e.subTitle&&!e.productId)),Oe=g.useMemo((()=>{const e={};return["STORE_INFORMATION","CONTACT_INFO","STORE_LOCATION","SHIPPING_POLICY","RETURN_AND_REFUND","SALES_AND_OFFERS","SALES_AND_OFFERS_ISSUES","PRODUCT_CUSTOMISATION","PAYMENT_METHODS","CHECKOUT_ENQUIRY","ORDER_ENQUIRY"].forEach((t=>{M[t]&&(e[M[t]]=M[t])})),["COLLABORATION","SUBSCRIPTION_ENQUIRY"].forEach((t=>{e[t]=t})),e}),[M]);g.useEffect((()=>{var e,t,s,i;if(!(null==_?void 0:_.messageId))return;oe(!0),re(!0),ae(!1!==(null===(t=null===(e=_.sources)||void 0===e?void 0:e[0])||void 0===t?void 0:t.isTrainable)||!!(null===(i=null===(s=_.sources)||void 0===s?void 0:s[0])||void 0===i?void 0:i.insights));const o=_.sources.filter((e=>!!e.productId)).map((e=>e.productId)),n=Array.from(new Set(o)).filter((e=>!!e));Y(k,n).then((e=>ce(e))).then((()=>{$?(je($),setTimeout((()=>{oe(!1),re(!1)}),100)):(setTimeout((()=>oe(!1)),100),G(k).then((e=>je(e))).then((()=>setTimeout((()=>{re(!1)}),100))))}))}),[Y,G,null==_?void 0:_.messageId,_.sources,$,k]);const fe=e=>!!(e&&0===e.length||(null==_?void 0:_.isUnsatisfactoryAnswer)),ve=function(e){let t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];var s;return"custom"==e?e=L.CustomDataType.FILES:se.includes(e)?e=L.CustomDataType.FETCHED_LINKS:"url"==e?e=L.CustomDataType.WEBSITE_LINKS:"text"===e?e=L.CustomDataType.TEXTS:"faq"===e&&(e=L.CustomDataType.FAQ),t?e:null===(s=null==e?void 0:e.toLowerCase())||void 0===s?void 0:s.replace(/_/g," ")},Se=e=>e?"faq"==e.toLocaleLowerCase()?"FAQ":"openai"==e.toLocaleLowerCase()?"OPENAI":"files"==e.toLocaleLowerCase()?"PDF":"texts"==e.toLocaleLowerCase()?"Custom text":((e=(e=e.charAt(0).toUpperCase()+e.slice(1).toLowerCase()).replace("_"," ")).endsWith("s")&&(e=e.slice(0,-1)),e.replace("Website","Manual")):"",Te=t=>"products"==t||"product"==t?e.jsxRuntimeExports.jsx(i.default,{height:16,width:16,color:h.COLORS.content.secondary}):"files"==t?e.jsxRuntimeExports.jsx(a.default,{height:16,width:16,color:h.COLORS.content.secondary}):"website links"==t||"fetched links"==t?e.jsxRuntimeExports.jsx(m.default,{height:16,width:16,color:h.COLORS.content.secondary}):"faq"==t?e.jsxRuntimeExports.jsx(d.default,{height:16,width:16,color:h.COLORS.content.secondary}):"texts"==t?e.jsxRuntimeExports.jsx(j.default,{height:16,width:16,color:h.COLORS.content.secondary}):e.jsxRuntimeExports.jsx(u.default,{height:16,width:16,color:h.COLORS.content.secondary}),Ie=e=>{const t=e.replace(/(<([^>]+)>)/gi,""),s=document.createElement("textarea");return s.innerHTML=t,s.value};if(ie||!q)return e.jsxRuntimeExports.jsx(T.SourceInfoDetailsStyle,{children:e.jsxRuntimeExports.jsx(C.BikShimmer,{boxes:[{width:"100px",height:"16px"},{width:"0",height:"4px"},{width:"100%",height:"32px"},{width:"100%",height:"32px"},{width:"100%",height:"32px"},{width:"100%",height:"32px"},{width:"0",height:"4px"},{width:"100%",height:"16px"}]})});const be=s=>{const{title:i,count:r,isExpanded:l,onToggle:a,children:d}=s;return e.jsxRuntimeExports.jsxs("div",{children:[e.jsxRuntimeExports.jsxs("div",Object.assign({style:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:"8px 12px",cursor:"pointer"},onClick:a},{children:[e.jsxRuntimeExports.jsxs("div",Object.assign({style:{display:"flex",alignItems:"center",gap:"8px"}},{children:[e.jsxRuntimeExports.jsx(v.BodySecondary,{children:i}),A===t.ApplicationType.MANIFEST?e.jsxRuntimeExports.jsx("div",Object.assign({style:{backgroundColor:h.COLORS.surface.subdued,color:h.COLORS.content.secondary,padding:"2px 8px",borderRadius:"12px",fontSize:"12px",fontWeight:"500",border:`1px solid ${h.COLORS.stroke.primary}`}},{children:r})):e.jsxRuntimeExports.jsx(e.jsxRuntimeExports.Fragment,{})]})),e.jsxRuntimeExports.jsx(e.jsxRuntimeExports.Fragment,{children:A===t.ApplicationType.BIK?e.jsxRuntimeExports.jsx(e.jsxRuntimeExports.Fragment,{}):l?e.jsxRuntimeExports.jsx(n.default,{width:20,height:20,color:h.COLORS.content.primary}):e.jsxRuntimeExports.jsx(o.default,{width:20,height:20,color:h.COLORS.content.primary})})]})),l&&d]})};return e.jsxRuntimeExports.jsxs(e.jsxRuntimeExports.Fragment,{children:[e.jsxRuntimeExports.jsx(T.SourceInfoDetailsStyle,{children:e.jsxRuntimeExports.jsxs(e.jsxRuntimeExports.Fragment,{children:[e.jsxRuntimeExports.jsxs("div",Object.assign({className:"pop-up-header",style:{display:"flex",flexDirection:"column",padding:0,paddingBottom:"12px"}},{children:[!!U&&e.jsxRuntimeExports.jsx(v.TitleSmall,{children:U}),e.jsxRuntimeExports.jsxs("div",Object.assign({style:{display:"flex",flexDirection:"row",gap:"12px",alignItems:"center"}},{children:[e.jsxRuntimeExports.jsx(v.BodyCaption,Object.assign({color:h.COLORS.content.secondary},{children:"Intent"})),null!==(D=Ee[_.intent])&&void 0!==D?D:Ee.GENERIC,!B&&e.jsxRuntimeExports.jsx("div",Object.assign({style:{display:"flex",marginLeft:"auto",cursor:"pointer"},onClick:()=>F(void 0)},{children:e.jsxRuntimeExports.jsx(r.default,{height:20,width:20,color:h.COLORS.content.secondary})}))]})),Z&&e.jsxRuntimeExports.jsxs("div",Object.assign({style:{display:"flex",flexDirection:"column",gap:"12px",marginTop:"6px"}},{children:[e.jsxRuntimeExports.jsxs("div",Object.assign({style:{display:"flex",alignItems:"center",justifyContent:"space-between"}},{children:[e.jsxRuntimeExports.jsx(v.BodySecondary,Object.assign({color:h.COLORS.content.primary},{children:Z.rule_name})),ee&&Z.rule_id&&e.jsxRuntimeExports.jsxs("div",Object.assign({style:{display:"flex",alignItems:"center",gap:"6px"}},{children:[e.jsxRuntimeExports.jsx(s.default,{width:14,color:h.COLORS.content.secondary}),e.jsxRuntimeExports.jsx(v.BodyCaption,Object.assign({color:h.COLORS.content.secondary},{children:"Edit search rule"})),e.jsxRuntimeExports.jsx(E.IconButton,{Icon:l.default,height:16,width:16,bordered:!0,iconColor:h.COLORS.content.primary,onClick:()=>ee(null==Z?void 0:Z.rule_id)})]}))]})),Z.keywords&&Z.keywords.length>0&&e.jsxRuntimeExports.jsx("div",Object.assign({style:{display:"flex",flexWrap:"wrap",gap:"6px",padding:"8px",backgroundColor:h.COLORS.surface.subdued,borderRadius:"8px",border:`1px dashed ${h.COLORS.stroke.primary}`}},{children:Z.keywords.map(((t,s)=>e.jsxRuntimeExports.jsx(O.Tag,{tagText:t,theme:"light"},`keyword-${s}`)))}))]})),fe(te)?e.jsxRuntimeExports.jsx("div",Object.assign({style:{display:"flex",margin:"auto",justifyContent:"center",alignItems:"center",height:"calc(100vh - 300px)"}},{children:(()=>{var t,s;return e.jsxRuntimeExports.jsxs("div",Object.assign({style:{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",margin:"0px 30px",gap:"8px"}},{children:[e.jsxRuntimeExports.jsx("div",Object.assign({style:{display:"flex",alignItems:"center",justifyContent:"center",padding:"12px",backgroundColor:`${h.COLORS.background.negative.light}`,borderRadius:"100px"}},{children:e.jsxRuntimeExports.jsx(c.default,{width:24,height:24,color:h.COLORS.stroke.negative.vibrant})})),e.jsxRuntimeExports.jsx("div",Object.assign({style:{justifyContent:"center",alignItems:"center",marginBottom:"-4px"}},{children:e.jsxRuntimeExports.jsx(v.TitleSmall,{children:"Insufficient data"})})),e.jsxRuntimeExports.jsx(v.BodySecondary,Object.assign({color:h.COLORS.content.secondary,style:{display:"flex",justifyContent:"center",textAlign:"center"}},{children:"No data available to answer this query. Add an FAQ to address it in the future"})),K&&e.jsxRuntimeExports.jsx("div",Object.assign({style:{display:"flex",width:"100%"}},{children:e.jsxRuntimeExports.jsx(y.Button,{LeadingIcon:null!==(t=K.leadingIcon)&&void 0!==t?t:x.default,buttonText:null!==(s=K.title)&&void 0!==s?s:"Add FAQ",buttonType:"secondary",size:"small",matchParentWidth:!0,onClick:()=>{K.onClick()}})}))]}))})()})):!Z&&e.jsxRuntimeExports.jsx(O.Tag,{LeadingIcon:c.default,version:"2.0",type:"grey",theme:"light",alignIcon:"start",contentPadding:12,tagText:_.isEditable?`If any of the information is incorrect, update the original data source and sync it again. Alternatively, you can make local corrections directly in ${A===t.ApplicationType.BIK?"BIK":"Manifest"}.`:"Edit the original source and save again to update the response"})]})),le&&!fe(te)&&e.jsxRuntimeExports.jsx("div",Object.assign({className:"footer"},{children:e.jsxRuntimeExports.jsx(S.default,{appType:A,storeId:k,messageSource:_,sourceIntent:null!==(N=_.intent)&&void 0!==N?N:M.GENERIC,faqCount:de,trainingSourceCount:pe,ShowTrainingDataSource:Oe,ChecklistType:M,footerButtonOption:Q,isFooterLoading:ne,reasonForAiGeneratedResponse:X,showAiResponseReason:V,aiResponseLoading:J})})),!fe(te)&&e.jsxRuntimeExports.jsxs("div",Object.assign({className:"info-container"},{children:[e.jsxRuntimeExports.jsx(e.jsxRuntimeExports.Fragment,{children:Ce.length>0&&e.jsxRuntimeExports.jsx("div",Object.assign({className:"info-product-source"},{children:e.jsxRuntimeExports.jsx(be,Object.assign({title:"Product Sources",count:Ce.length,isExpanded:A!==t.ApplicationType.MANIFEST||me,onToggle:()=>ge(!me)},{children:e.jsxRuntimeExports.jsx("div",Object.assign({className:"source",style:{padding:"0 12px",maxWidth:"100%"}},{children:Ce.map(((t,s)=>{var i,o,n,r;const a=ve(t.type||t.subTitle||"OpenAI"),d=ve(t.type||t.subTitle||"OpenAI",!0),c=Se(a),u=null==W?void 0:W.includes(d),x=P[null!==(i=t.productId)&&void 0!==i?i:"Products"],j=t.title,m=t.productId&&(null==z?void 0:z[t.productId]),g=m&&m.metafield.join(", ");return e.jsxRuntimeExports.jsxs("div",Object.assign({style:{display:"flex",flexDirection:"column",gap:"8px",padding:"16px 0px",borderBottom:s+1<(null==Ce?void 0:Ce.length)?`1px solid ${h.COLORS.stroke.primary}`:"none"}},{children:[e.jsxRuntimeExports.jsxs("div",Object.assign({style:{display:"flex",flexDirection:"row",gap:"12px",justifyContent:"space-between",alignItems:"center"}},{children:[e.jsxRuntimeExports.jsxs("div",Object.assign({style:{display:"flex",flex:1,gap:"8px",flexDirection:"row",alignItems:"center",justifyContent:"flex-start"}},{children:[Te(a),e.jsxRuntimeExports.jsx(f.Tooltip,Object.assign({body:j,placement:"top"},{children:e.jsxRuntimeExports.jsx(v.BodySecondary,Object.assign({style:d==L.CustomDataType.FETCHED_LINKS||d==L.CustomDataType.WEBSITE_LINKS?{cursor:"pointer",textDecoration:"underline"}:{},color:h.COLORS.content.primary,className:"clamp-title",onClick:()=>d==L.CustomDataType.FETCHED_LINKS||d==L.CustomDataType.WEBSITE_LINKS?H(t):{}},{children:j}))}))]})),e.jsxRuntimeExports.jsxs("div",Object.assign({style:{display:"flex",flexDirection:"row",justifyContent:"flex-end",alignItems:"center",gap:"4px",flex:"none"}},{children:[t.intent!==M.EMAIL_COLLECTION&&e.jsxRuntimeExports.jsx(e.jsxRuntimeExports.Fragment,{children:e.jsxRuntimeExports.jsx(v.BodyCaption,Object.assign({color:h.COLORS.content.secondary},{children:c}))}),(t.link||t.docId)&&e.jsxRuntimeExports.jsx("div",Object.assign({style:{cursor:"pointer",marginLeft:"0px"}},{children:u?e.jsxRuntimeExports.jsx(E.IconButton,{Icon:l.default,height:16,width:16,iconColor:h.COLORS.content.secondary,onClick:()=>null==x?void 0:x.onEditClick(x.data,x.type),disabled:!x,disabledTooltip:"This source is deleted"}):e.jsxRuntimeExports.jsx(E.IconButton,{Icon:p.default,height:16,width:16,iconColor:h.COLORS.content.secondary,disabled:"custom"===t.type&&!x,disabledTooltip:"This source is deleted",onClick:()=>H(t)})}))]}))]})),m&&e.jsxRuntimeExports.jsxs(v.BodyCaption,{children:[e.jsxRuntimeExports.jsx("span",Object.assign({className:"product-data-text1",onClick:()=>{var e;xe({title:j,description:Ie(m.description),imageUrl:null!==(e=t.imageUrl)&&void 0!==e?e:"",onClose:()=>xe(void 0)})}},{children:`${null===(o=m.description)||void 0===o?void 0:o.length} characters description,`})),e.jsxRuntimeExports.jsx("span",Object.assign({className:"product-data-text1",onClick:()=>m.onEditFaqClick(m.faqs)},{children:`${null===(n=m.faqs)||void 0===n?void 0:n.length} FAQs, `})),e.jsxRuntimeExports.jsx("span",Object.assign({className:"product-data-text2"},{children:"and"})),e.jsxRuntimeExports.jsx(f.Tooltip,Object.assign({body:g,placement:"top"},{children:e.jsxRuntimeExports.jsx("span",Object.assign({className:"product-data-text1"},{children:`${null===(r=m.metafield)||void 0===r?void 0:r.length} metafields`}))}))]})]}),`info-${s}`)}))}))}))}))}),e.jsxRuntimeExports.jsx(e.jsxRuntimeExports.Fragment,{children:Re.length>0&&e.jsxRuntimeExports.jsx("div",Object.assign({className:"info-content-source"},{children:e.jsxRuntimeExports.jsx(be,Object.assign({title:"Content Sources",count:Re.length,isExpanded:A!==t.ApplicationType.MANIFEST||he,onToggle:()=>ye(!he)},{children:e.jsxRuntimeExports.jsx("div",Object.assign({className:"source",style:{padding:"0 12px",maxWidth:"100%"}},{children:Re.map(((t,s)=>{var i,o,n,r,a,d,c,u,x,j,m,g,y,C,R,O,S;const T=ve(t.type||t.subTitle||"OpenAI"),I=ve(t.type||t.subTitle||"OpenAI",!0),b=Se(T),w=null==W?void 0:W.includes(I),D="Products"===t.subTitle?P[null!==(i=t.productId)&&void 0!==i?i:"Products"]:P[null!==(o=t.docId)&&void 0!==o?o:""],N=I.toLowerCase()===(null===(n=L.CustomDataType.FAQ)||void 0===n?void 0:n.toLowerCase())?"faq"===(null===(r=t.title)||void 0===r?void 0:r.toLowerCase())?t.subTitle:t.title:I.toLowerCase()===(null===(a=L.CustomDataType.FILES)||void 0===a?void 0:a.toLowerCase())||I.toLowerCase()===(null===(d=L.CustomDataType.FETCHED_LINKS)||void 0===d?void 0:d.toLowerCase())||I.toLowerCase()===(null===(c=L.CustomDataType.TEXTS)||void 0===c?void 0:c.toLowerCase())?t.title:I.toLowerCase()===(null===(u=L.CustomDataType.WEBSITE_LINKS)||void 0===u?void 0:u.toLowerCase())?t.title.split("/")[t.title.split("/").length-1].replace(/[^\w\s]/gi," ").replace(/^(.)(.*)$/,((e,t,s)=>t.toUpperCase()+s)):t.intent===M.EMAIL_COLLECTION?b:t.title,A="faq"===I.toLowerCase()?null!==(m=null!==(x=null==D?void 0:D.content)&&void 0!==x?x:null===(j=null==D?void 0:D.data)||void 0===j?void 0:j.answer)&&void 0!==m?m:"":I.toLowerCase()===(null===(g=L.CustomDataType.FETCHED_LINKS)||void 0===g?void 0:g.toLowerCase())||I.toLowerCase()===(null===(y=L.CustomDataType.WEBSITE_LINKS)||void 0===y?void 0:y.toLowerCase())||I.toLowerCase()===(null===(C=L.CustomDataType.TEXTS)||void 0===C?void 0:C.toLowerCase())?null!==(S=null!==(R=null==D?void 0:D.content)&&void 0!==R?R:null===(O=null==D?void 0:D.data)||void 0===O?void 0:O.fileContentText)&&void 0!==S?S:"":t.intent===M.EMAIL_COLLECTION?"Collect leads before replying to messages":"";return e.jsxRuntimeExports.jsxs("div",Object.assign({style:{display:"flex",flexDirection:"column",gap:"8px",padding:"16px 0px",borderBottom:s+1<(null==Re?void 0:Re.length)?`1px solid ${h.COLORS.stroke.primary}`:"none"}},{children:[e.jsxRuntimeExports.jsxs("div",Object.assign({style:{display:"flex",flexDirection:"row",gap:"12px",justifyContent:"space-between",alignItems:"center"}},{children:[e.jsxRuntimeExports.jsxs("div",Object.assign({style:{display:"flex",flex:1,gap:"8px",flexDirection:"row",alignItems:"center",justifyContent:"flex-start"}},{children:[Te(T),e.jsxRuntimeExports.jsx(f.Tooltip,Object.assign({body:N,placement:"top"},{children:e.jsxRuntimeExports.jsx(v.BodySecondary,Object.assign({style:I==L.CustomDataType.FETCHED_LINKS||I==L.CustomDataType.WEBSITE_LINKS?{cursor:"pointer",textDecoration:"underline"}:{},color:h.COLORS.content.primary,className:"clamp-title",onClick:()=>I==L.CustomDataType.FETCHED_LINKS||I==L.CustomDataType.WEBSITE_LINKS?H(t):{}},{children:N}))}))]})),e.jsxRuntimeExports.jsxs("div",Object.assign({style:{display:"flex",flexDirection:"row",justifyContent:"flex-end",alignItems:"center",gap:"4px",flex:"none"}},{children:[t.intent!==M.EMAIL_COLLECTION&&e.jsxRuntimeExports.jsx(e.jsxRuntimeExports.Fragment,{children:e.jsxRuntimeExports.jsx(v.BodyCaption,Object.assign({color:h.COLORS.content.secondary},{children:b}))}),(t.link||t.docId)&&e.jsxRuntimeExports.jsx("div",Object.assign({style:{cursor:"pointer",marginLeft:"0px"}},{children:w?e.jsxRuntimeExports.jsx(E.IconButton,{Icon:l.default,height:16,width:16,iconColor:h.COLORS.content.secondary,onClick:()=>null==D?void 0:D.onEditClick(D.data,D.type),disabled:!D,disabledTooltip:"This source is deleted"}):e.jsxRuntimeExports.jsx(E.IconButton,{Icon:p.default,height:16,width:16,iconColor:h.COLORS.content.secondary,disabled:"custom"===t.type&&!D,disabledTooltip:"This source is deleted",onClick:()=>H(t)})}))]}))]})),(null!=A?A:"").trim()&&e.jsxRuntimeExports.jsx("div",Object.assign({style:{padding:"4px 8px",border:`1px dashed ${h.COLORS.stroke.primary}`,borderRadius:"4px",backgroundColor:h.COLORS.surface.subdued}},{children:e.jsxRuntimeExports.jsx(v.BodyCaption,Object.assign({color:h.COLORS.content.primary,className:"clamp-description"},{children:Ie(null!=A?A:"").trim()}))}))]}),`info-${s}`)}))}))}))}))})]})),null==w?void 0:w.children]})}),ue&&e.jsxRuntimeExports.jsx(R.SideModal,Object.assign({header:"Product description",onClose:()=>xe(void 0),width:"30%"},{children:e.jsxRuntimeExports.jsx(b.DescriptionModal,{title:ue.title,description:ue.description,imageUrl:ue.imageUrl,onClose:ue.onClose})}))]})};
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../../node_modules/react/jsx-runtime.js"),t=require("@bikdotai/bik-models/growth/models/bik-store"),s=require("../../assets/icons/box_search.svg.js"),i=require("../../assets/icons/boxV2.svg.js"),o=require("../../assets/icons/chevronDownOutline.svg.js"),n=require("../../assets/icons/chevronUpOutline.svg.js"),r=require("../../assets/icons/cross.svg.js"),l=require("../../assets/icons/edit.svg.js"),a=require("../../assets/icons/filePdf.svg.js"),d=require("../../assets/icons/help.svg.js"),c=require("../../assets/icons/info.svg.js"),u=require("../../assets/icons/openai.svg.js"),x=require("../../assets/icons/plus.svg.js"),p=require("../../assets/icons/redirect.svg.js"),j=require("../../assets/icons/text_t9.svg.js"),m=require("../../assets/icons/website.svg.js"),g=require("react"),h=require("../../constants/Theme.js"),y=require("../button/Button.js"),E=require("../icon-button/IconButton.js"),C=require("../shimmer/ShimmerComponent/BikShimmer.js"),R=require("../side-modal/SideModal.js"),O=require("../tag/Tag.js"),f=require("../tooltips/Tooltip.js"),v=require("../TypographyStyle.js"),S=require("./DataSourceInfoFooter.js"),T=require("./DataSourcePanel.style.js"),I=require("./IntentConfig.js"),b=require("./Modals/DescriptionModal.js"),L=require("./model.js");exports.DataSourcePanel=w=>{var D,N;const{appType:A,storeId:k,messageSource:_,setMessageSourcePanel:F,hideCloseButton:B,isSourceInfoFetched:q,allSourceInfoDetail:P,ChecklistType:M,title:U,zeroStateButton:K,editableSources:W,preFillTrainingSourceCount:$,redirect:H,footerButtonOption:Q,fetchTrainingSourceCount:G,fetchProductFAQCount:Y,productSourceData:z,reasonForAiGeneratedResponse:X,showAiResponseReason:V,aiResponseLoading:J,productSearchRule:Z,onEditProductSearchRule:ee}=w,{sources:te}=_,se=["blog","article","page","policy"],[ie,oe]=g.useState(!1),[ne,re]=g.useState(!1),[le,ae]=g.useState(!1),[de,ce]=g.useState(0),[ue,xe]=g.useState(),[pe,je]=g.useState(null!=$?$:{}),[me,ge]=g.useState(!1),[he,ye]=g.useState(!1),Ee={};I.intentConfig.forEach((t=>{let{key:s,type:i,tagText:o}=t;M[s]&&(Ee[M[s]]=e.jsxRuntimeExports.jsx(O.Tag,{theme:"light",type:i,tagText:o,cursor:"pointer"}))}));const Ce=te.filter((e=>"PRODUCTS"==e.type||"Products"==e.subTitle||e.productId)),Re=te.filter((e=>"PRODUCTS"!=e.type&&"Products"!=e.subTitle&&!e.productId)),Oe=g.useMemo((()=>{const e={};return["STORE_INFORMATION","CONTACT_INFO","STORE_LOCATION","SHIPPING_POLICY","RETURN_AND_REFUND","SALES_AND_OFFERS","SALES_AND_OFFERS_ISSUES","PRODUCT_CUSTOMISATION","PAYMENT_METHODS","CHECKOUT_ENQUIRY","ORDER_ENQUIRY"].forEach((t=>{M[t]&&(e[M[t]]=M[t])})),["COLLABORATION","SUBSCRIPTION_ENQUIRY"].forEach((t=>{e[t]=t})),e}),[M]);g.useEffect((()=>{var e,t,s,i;if(!(null==_?void 0:_.messageId))return;oe(!0),re(!0),ae(!1!==(null===(t=null===(e=_.sources)||void 0===e?void 0:e[0])||void 0===t?void 0:t.isTrainable)||!!(null===(i=null===(s=_.sources)||void 0===s?void 0:s[0])||void 0===i?void 0:i.insights));const o=_.sources.filter((e=>!!e.productId)).map((e=>e.productId)),n=Array.from(new Set(o)).filter((e=>!!e));Y(k,n).then((e=>ce(e))).then((()=>{$?(je($),setTimeout((()=>{oe(!1),re(!1)}),100)):(setTimeout((()=>oe(!1)),100),G(k).then((e=>je(e))).then((()=>setTimeout((()=>{re(!1)}),100))))}))}),[Y,G,null==_?void 0:_.messageId,_.sources,$,k]);const fe=e=>!!(e&&0===e.length||(null==_?void 0:_.isUnsatisfactoryAnswer)),ve=function(e){let t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];var s;return"custom"==e?e=L.CustomDataType.FILES:se.includes(e)?e=L.CustomDataType.FETCHED_LINKS:"url"==e?e=L.CustomDataType.WEBSITE_LINKS:"text"===e?e=L.CustomDataType.TEXTS:"faq"===e&&(e=L.CustomDataType.FAQ),t?e:null===(s=null==e?void 0:e.toLowerCase())||void 0===s?void 0:s.replace(/_/g," ")},Se=e=>e?"faq"==e.toLocaleLowerCase()?"FAQ":"openai"==e.toLocaleLowerCase()?"OPENAI":"files"==e.toLocaleLowerCase()?"PDF":"texts"==e.toLocaleLowerCase()?"Custom text":((e=(e=e.charAt(0).toUpperCase()+e.slice(1).toLowerCase()).replace("_"," ")).endsWith("s")&&(e=e.slice(0,-1)),e.replace("Website","Manual")):"",Te=g.useCallback((t=>"products"==t||"product"==t?e.jsxRuntimeExports.jsx(i.default,{height:16,width:16,color:h.COLORS.content.secondary}):"files"==t?e.jsxRuntimeExports.jsx(a.default,{height:16,width:16,color:h.COLORS.content.secondary}):"website links"==t||"fetched links"==t?e.jsxRuntimeExports.jsx(m.default,{height:16,width:16,color:h.COLORS.content.secondary}):"faq"==t?e.jsxRuntimeExports.jsx(d.default,{height:16,width:16,color:h.COLORS.content.secondary}):"texts"==t?e.jsxRuntimeExports.jsx(j.default,{height:16,width:16,color:h.COLORS.content.secondary}):e.jsxRuntimeExports.jsx(u.default,{height:16,width:16,color:h.COLORS.content.secondary})),[]),Ie=e=>{const t=e.replace(/(<([^>]+)>)/gi,""),s=document.createElement("textarea");return s.innerHTML=t,s.value};if(ie||!q)return e.jsxRuntimeExports.jsx(T.SourceInfoDetailsStyle,{children:e.jsxRuntimeExports.jsx(C.BikShimmer,{boxes:[{width:"100px",height:"16px"},{width:"0",height:"4px"},{width:"100%",height:"32px"},{width:"100%",height:"32px"},{width:"100%",height:"32px"},{width:"100%",height:"32px"},{width:"0",height:"4px"},{width:"100%",height:"16px"}]})});const be=s=>{const{title:i,count:r,isExpanded:l,onToggle:a,children:d}=s;return e.jsxRuntimeExports.jsxs("div",{children:[e.jsxRuntimeExports.jsxs("div",Object.assign({style:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:"8px 12px",cursor:"pointer"},onClick:a},{children:[e.jsxRuntimeExports.jsxs("div",Object.assign({style:{display:"flex",alignItems:"center",gap:"8px"}},{children:[e.jsxRuntimeExports.jsx(v.BodySecondary,{children:i}),A===t.ApplicationType.MANIFEST?e.jsxRuntimeExports.jsx("div",Object.assign({style:{backgroundColor:h.COLORS.surface.subdued,color:h.COLORS.content.secondary,padding:"2px 8px",borderRadius:"12px",fontSize:"12px",fontWeight:"500",border:`1px solid ${h.COLORS.stroke.primary}`}},{children:r})):e.jsxRuntimeExports.jsx(e.jsxRuntimeExports.Fragment,{})]})),e.jsxRuntimeExports.jsx(e.jsxRuntimeExports.Fragment,{children:A===t.ApplicationType.BIK?e.jsxRuntimeExports.jsx(e.jsxRuntimeExports.Fragment,{}):l?e.jsxRuntimeExports.jsx(n.default,{width:20,height:20,color:h.COLORS.content.primary}):e.jsxRuntimeExports.jsx(o.default,{width:20,height:20,color:h.COLORS.content.primary})})]})),l&&d]})};return e.jsxRuntimeExports.jsxs(e.jsxRuntimeExports.Fragment,{children:[e.jsxRuntimeExports.jsx(T.SourceInfoDetailsStyle,{children:e.jsxRuntimeExports.jsxs(e.jsxRuntimeExports.Fragment,{children:[e.jsxRuntimeExports.jsxs("div",Object.assign({className:"pop-up-header",style:{display:"flex",flexDirection:"column",padding:0,paddingBottom:"12px"}},{children:[!!U&&e.jsxRuntimeExports.jsx(v.TitleSmall,{children:U}),e.jsxRuntimeExports.jsxs("div",Object.assign({style:{display:"flex",flexDirection:"row",gap:"12px",alignItems:"center"}},{children:[e.jsxRuntimeExports.jsx(v.BodyCaption,Object.assign({color:h.COLORS.content.secondary},{children:"Intent"})),null!==(D=Ee[_.intent])&&void 0!==D?D:Ee.GENERIC,!B&&e.jsxRuntimeExports.jsx("div",Object.assign({style:{display:"flex",marginLeft:"auto",cursor:"pointer"},onClick:()=>F(void 0)},{children:e.jsxRuntimeExports.jsx(r.default,{height:20,width:20,color:h.COLORS.content.secondary})}))]})),Z&&e.jsxRuntimeExports.jsxs("div",Object.assign({style:{display:"flex",flexDirection:"column",gap:"12px",marginTop:"6px"}},{children:[e.jsxRuntimeExports.jsxs("div",Object.assign({style:{display:"flex",alignItems:"center",justifyContent:"space-between"}},{children:[e.jsxRuntimeExports.jsx(v.BodySecondary,Object.assign({color:h.COLORS.content.primary},{children:Z.rule_name})),ee&&Z.rule_id&&e.jsxRuntimeExports.jsxs("div",Object.assign({style:{display:"flex",alignItems:"center",gap:"6px"}},{children:[e.jsxRuntimeExports.jsx(s.default,{width:14,color:h.COLORS.content.secondary}),e.jsxRuntimeExports.jsx(v.BodyCaption,Object.assign({color:h.COLORS.content.secondary},{children:"Edit search rule"})),e.jsxRuntimeExports.jsx(E.IconButton,{Icon:l.default,height:16,width:16,bordered:!0,iconColor:h.COLORS.content.primary,onClick:()=>ee(null==Z?void 0:Z.rule_id)})]}))]})),Z.keywords&&Z.keywords.length>0&&e.jsxRuntimeExports.jsx("div",Object.assign({style:{display:"flex",flexWrap:"wrap",gap:"6px",padding:"8px",backgroundColor:h.COLORS.surface.subdued,borderRadius:"8px",border:`1px dashed ${h.COLORS.stroke.primary}`}},{children:Z.keywords.map(((t,s)=>e.jsxRuntimeExports.jsx(O.Tag,{tagText:t,theme:"light"},`keyword-${s}`)))}))]})),fe(te)?e.jsxRuntimeExports.jsx("div",Object.assign({style:{display:"flex",margin:"auto",justifyContent:"center",alignItems:"center",height:"calc(100vh - 300px)"}},{children:(()=>{var t,s;return e.jsxRuntimeExports.jsxs("div",Object.assign({style:{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",margin:"0px 30px",gap:"8px"}},{children:[e.jsxRuntimeExports.jsx("div",Object.assign({style:{display:"flex",alignItems:"center",justifyContent:"center",padding:"12px",backgroundColor:`${h.COLORS.background.negative.light}`,borderRadius:"100px"}},{children:e.jsxRuntimeExports.jsx(c.default,{width:24,height:24,color:h.COLORS.stroke.negative.vibrant})})),e.jsxRuntimeExports.jsx("div",Object.assign({style:{justifyContent:"center",alignItems:"center",marginBottom:"-4px"}},{children:e.jsxRuntimeExports.jsx(v.TitleSmall,{children:"Insufficient data"})})),e.jsxRuntimeExports.jsx(v.BodySecondary,Object.assign({color:h.COLORS.content.secondary,style:{display:"flex",justifyContent:"center",textAlign:"center"}},{children:"No data available to answer this query. Add an FAQ to address it in the future"})),K&&e.jsxRuntimeExports.jsx("div",Object.assign({style:{display:"flex",width:"100%"}},{children:e.jsxRuntimeExports.jsx(y.Button,{LeadingIcon:null!==(t=K.leadingIcon)&&void 0!==t?t:x.default,buttonText:null!==(s=K.title)&&void 0!==s?s:"Add FAQ",buttonType:"secondary",size:"small",matchParentWidth:!0,onClick:()=>{K.onClick()}})}))]}))})()})):!Z&&e.jsxRuntimeExports.jsx(O.Tag,{LeadingIcon:c.default,version:"2.0",type:"grey",theme:"light",alignIcon:"start",contentPadding:12,tagText:_.isEditable?`If any of the information is incorrect, update the original data source and sync it again. Alternatively, you can make local corrections directly in ${A===t.ApplicationType.BIK?"BIK":"Manifest"}.`:"Edit the original source and save again to update the response"})]})),le&&!fe(te)&&e.jsxRuntimeExports.jsx("div",Object.assign({className:"footer"},{children:e.jsxRuntimeExports.jsx(S.default,{appType:A,storeId:k,messageSource:_,sourceIntent:null!==(N=_.intent)&&void 0!==N?N:M.GENERIC,faqCount:de,trainingSourceCount:pe,ShowTrainingDataSource:Oe,ChecklistType:M,footerButtonOption:Q,isFooterLoading:ne,reasonForAiGeneratedResponse:X,showAiResponseReason:V,aiResponseLoading:J})})),!fe(te)&&e.jsxRuntimeExports.jsxs("div",Object.assign({className:"info-container"},{children:[e.jsxRuntimeExports.jsx(e.jsxRuntimeExports.Fragment,{children:Ce.length>0&&e.jsxRuntimeExports.jsx("div",Object.assign({className:"info-product-source"},{children:e.jsxRuntimeExports.jsx(be,Object.assign({title:"Product Sources",count:Ce.length,isExpanded:A!==t.ApplicationType.MANIFEST||me,onToggle:()=>ge(!me)},{children:e.jsxRuntimeExports.jsx("div",Object.assign({className:"source",style:{padding:"0 12px",maxWidth:"100%"}},{children:Ce.map(((t,s)=>{var i,o,n,r;const a=ve(t.type||t.subTitle||"OpenAI"),d=ve(t.type||t.subTitle||"OpenAI",!0),c=Se(a),u=null==W?void 0:W.includes(d),x=P[null!==(i=t.productId)&&void 0!==i?i:"Products"],j=t.title,m=t.productId&&(null==z?void 0:z[t.productId]),g=m&&m.metafield.join(", ");return e.jsxRuntimeExports.jsxs("div",Object.assign({style:{display:"flex",flexDirection:"column",gap:"8px",padding:"16px 0px",borderBottom:s+1<(null==Ce?void 0:Ce.length)?`1px solid ${h.COLORS.stroke.primary}`:"none"}},{children:[e.jsxRuntimeExports.jsxs("div",Object.assign({style:{display:"flex",flexDirection:"row",gap:"12px",justifyContent:"space-between",alignItems:"center"}},{children:[e.jsxRuntimeExports.jsxs("div",Object.assign({style:{display:"flex",flex:1,gap:"8px",flexDirection:"row",alignItems:"center",justifyContent:"flex-start"}},{children:[Te(a),e.jsxRuntimeExports.jsx(f.Tooltip,Object.assign({body:j,placement:"top"},{children:e.jsxRuntimeExports.jsx(v.BodySecondary,Object.assign({style:d==L.CustomDataType.FETCHED_LINKS||d==L.CustomDataType.WEBSITE_LINKS?{cursor:"pointer",textDecoration:"underline"}:{},color:h.COLORS.content.primary,className:"clamp-title",onClick:()=>d==L.CustomDataType.FETCHED_LINKS||d==L.CustomDataType.WEBSITE_LINKS?H(t):{}},{children:j}))}))]})),e.jsxRuntimeExports.jsxs("div",Object.assign({style:{display:"flex",flexDirection:"row",justifyContent:"flex-end",alignItems:"center",gap:"4px",flex:"none"}},{children:[t.intent!==M.EMAIL_COLLECTION&&e.jsxRuntimeExports.jsx(e.jsxRuntimeExports.Fragment,{children:e.jsxRuntimeExports.jsx(v.BodyCaption,Object.assign({color:h.COLORS.content.secondary},{children:c}))}),(t.link||t.docId)&&e.jsxRuntimeExports.jsx("div",Object.assign({style:{cursor:"pointer",marginLeft:"0px"}},{children:u?e.jsxRuntimeExports.jsx(E.IconButton,{Icon:l.default,height:16,width:16,iconColor:h.COLORS.content.secondary,onClick:()=>null==x?void 0:x.onEditClick(x.data,x.type),disabled:!x,disabledTooltip:"This source is deleted"}):e.jsxRuntimeExports.jsx(E.IconButton,{Icon:p.default,height:16,width:16,iconColor:h.COLORS.content.secondary,disabled:"custom"===t.type&&!x,disabledTooltip:"This source is deleted",onClick:()=>H(t)})}))]}))]})),m&&e.jsxRuntimeExports.jsxs(v.BodyCaption,{children:[e.jsxRuntimeExports.jsx("span",Object.assign({className:"product-data-text1",onClick:()=>{var e;xe({title:j,description:Ie(m.description),imageUrl:null!==(e=t.imageUrl)&&void 0!==e?e:"",onClose:()=>xe(void 0)})}},{children:`${null===(o=m.description)||void 0===o?void 0:o.length} characters description,`})),e.jsxRuntimeExports.jsx("span",Object.assign({className:"product-data-text1",onClick:()=>m.onEditFaqClick(m.faqs)},{children:`${null===(n=m.faqs)||void 0===n?void 0:n.length} FAQs, `})),e.jsxRuntimeExports.jsx("span",Object.assign({className:"product-data-text2"},{children:"and"})),e.jsxRuntimeExports.jsx(f.Tooltip,Object.assign({body:g,placement:"top"},{children:e.jsxRuntimeExports.jsx("span",Object.assign({className:"product-data-text1"},{children:`${null===(r=m.metafield)||void 0===r?void 0:r.length} metafields`}))}))]})]}),`info-${s}`)}))}))}))}))}),e.jsxRuntimeExports.jsx(e.jsxRuntimeExports.Fragment,{children:Re.length>0&&e.jsxRuntimeExports.jsx("div",Object.assign({className:"info-content-source"},{children:e.jsxRuntimeExports.jsx(be,Object.assign({title:"Content Sources",count:Re.length,isExpanded:A!==t.ApplicationType.MANIFEST||he,onToggle:()=>ye(!he)},{children:e.jsxRuntimeExports.jsx("div",Object.assign({className:"source",style:{padding:"0 12px",maxWidth:"100%"}},{children:Re.map(((t,s)=>{var i,o,n,r,a,d,c,u,x,j,m,g,y,C,R,O,S;const T=ve(t.type||t.subTitle||"OpenAI"),I=ve(t.type||t.subTitle||"OpenAI",!0),b=Se(T),w=null==W?void 0:W.includes(I),D="Products"===t.subTitle?P[null!==(i=t.productId)&&void 0!==i?i:"Products"]:P[null!==(o=t.docId)&&void 0!==o?o:""],N=I.toLowerCase()===(null===(n=L.CustomDataType.FAQ)||void 0===n?void 0:n.toLowerCase())?"faq"===(null===(r=t.title)||void 0===r?void 0:r.toLowerCase())?t.subTitle:t.title:I.toLowerCase()===(null===(a=L.CustomDataType.FILES)||void 0===a?void 0:a.toLowerCase())||I.toLowerCase()===(null===(d=L.CustomDataType.FETCHED_LINKS)||void 0===d?void 0:d.toLowerCase())||I.toLowerCase()===(null===(c=L.CustomDataType.TEXTS)||void 0===c?void 0:c.toLowerCase())?t.title:I.toLowerCase()===(null===(u=L.CustomDataType.WEBSITE_LINKS)||void 0===u?void 0:u.toLowerCase())?t.title.split("/")[t.title.split("/").length-1].replace(/[^\w\s]/gi," ").replace(/^(.)(.*)$/,((e,t,s)=>t.toUpperCase()+s)):t.intent===M.EMAIL_COLLECTION?b:t.title,A="faq"===I.toLowerCase()?null!==(m=null!==(x=null==D?void 0:D.content)&&void 0!==x?x:null===(j=null==D?void 0:D.data)||void 0===j?void 0:j.answer)&&void 0!==m?m:"":I.toLowerCase()===(null===(g=L.CustomDataType.FETCHED_LINKS)||void 0===g?void 0:g.toLowerCase())||I.toLowerCase()===(null===(y=L.CustomDataType.WEBSITE_LINKS)||void 0===y?void 0:y.toLowerCase())||I.toLowerCase()===(null===(C=L.CustomDataType.TEXTS)||void 0===C?void 0:C.toLowerCase())?null!==(S=null!==(R=null==D?void 0:D.content)&&void 0!==R?R:null===(O=null==D?void 0:D.data)||void 0===O?void 0:O.fileContentText)&&void 0!==S?S:"":t.intent===M.EMAIL_COLLECTION?"Collect leads before replying to messages":"";return e.jsxRuntimeExports.jsxs("div",Object.assign({style:{display:"flex",flexDirection:"column",gap:"8px",padding:"16px 0px",borderBottom:s+1<(null==Re?void 0:Re.length)?`1px solid ${h.COLORS.stroke.primary}`:"none"}},{children:[e.jsxRuntimeExports.jsxs("div",Object.assign({style:{display:"flex",flexDirection:"row",gap:"12px",justifyContent:"space-between",alignItems:"center"}},{children:[e.jsxRuntimeExports.jsxs("div",Object.assign({style:{display:"flex",flex:1,gap:"8px",flexDirection:"row",alignItems:"center",justifyContent:"flex-start"}},{children:[Te(T),e.jsxRuntimeExports.jsx(f.Tooltip,Object.assign({body:N,placement:"top"},{children:e.jsxRuntimeExports.jsx(v.BodySecondary,Object.assign({style:I==L.CustomDataType.FETCHED_LINKS||I==L.CustomDataType.WEBSITE_LINKS?{cursor:"pointer",textDecoration:"underline"}:{},color:h.COLORS.content.primary,className:"clamp-title",onClick:()=>I==L.CustomDataType.FETCHED_LINKS||I==L.CustomDataType.WEBSITE_LINKS?H(t):{}},{children:N}))}))]})),e.jsxRuntimeExports.jsxs("div",Object.assign({style:{display:"flex",flexDirection:"row",justifyContent:"flex-end",alignItems:"center",gap:"4px",flex:"none"}},{children:[t.intent!==M.EMAIL_COLLECTION&&e.jsxRuntimeExports.jsx(e.jsxRuntimeExports.Fragment,{children:e.jsxRuntimeExports.jsx(v.BodyCaption,Object.assign({color:h.COLORS.content.secondary},{children:b}))}),(t.link||t.docId)&&e.jsxRuntimeExports.jsx("div",Object.assign({style:{cursor:"pointer",marginLeft:"0px"}},{children:w?e.jsxRuntimeExports.jsx(E.IconButton,{Icon:l.default,height:16,width:16,iconColor:h.COLORS.content.secondary,onClick:()=>null==D?void 0:D.onEditClick(D.data,D.type),disabled:!D,disabledTooltip:"This source is deleted"}):e.jsxRuntimeExports.jsx(E.IconButton,{Icon:p.default,height:16,width:16,iconColor:h.COLORS.content.secondary,disabled:"custom"===t.type&&!D,disabledTooltip:"This source is deleted",onClick:()=>H(t)})}))]}))]})),(null!=A?A:"").trim()&&e.jsxRuntimeExports.jsx("div",Object.assign({style:{padding:"4px 8px",border:`1px dashed ${h.COLORS.stroke.primary}`,borderRadius:"4px",backgroundColor:h.COLORS.surface.subdued}},{children:e.jsxRuntimeExports.jsx(v.BodyCaption,Object.assign({color:h.COLORS.content.primary,className:"clamp-description"},{children:Ie(null!=A?A:"").trim()}))}))]}),`info-${s}`)}))}))}))}))})]})),null==w?void 0:w.children]})}),ue&&e.jsxRuntimeExports.jsx(R.SideModal,Object.assign({header:"Product description",onClose:()=>xe(void 0),width:"30%"},{children:e.jsxRuntimeExports.jsx(b.DescriptionModal,{title:ue.title,description:ue.description,imageUrl:ue.imageUrl,onClose:ue.onClose})}))]})};
@@ -7,6 +7,7 @@ interface CouponExpirationI {
7
7
  inValidCouponExpiry: boolean;
8
8
  setSelectedExpiration: React.Dispatch<React.SetStateAction<COUPON_EXPIRATION | undefined>>;
9
9
  selectedExpiration: COUPON_EXPIRATION | undefined;
10
+ hideExpirationOptions?: boolean;
10
11
  }
11
12
  export declare const CouponExpiration: React.FC<CouponExpirationI>;
12
13
  export {};
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../../../node_modules/react/jsx-runtime.js"),t=require("date-fns"),r=require("react"),o=require("../../custom-date-time/CustomDateTime.js"),i=require("../type.js");require("../../dropdown/DropdownPopover/index.js");var n=require("../../dropdown/Dropdown.js");require("../../dropdown/ChipDropdown.js"),require("../../zeroState/ZeroState.js");var s=require("../../TypographyStyle.js");require("../../../constants/Theme.js"),require("../../dropdown/OpenedDropdown/components/description/Description.styled.js"),require("../../checkBox/CheckBox.styled.js"),require("../../list-item/ListItem.js"),require("../../dropdown/OpenedDropdown/components/menu/FreeFormMenu.styled.js"),require("../../dropdown/OpenedDropdown/components/menu/MenuItem.js"),require("../../dropdown/OpenedDropdown/components/menu/MenuList.styled.js"),require("../../button/Button.js"),require("../../dropdown/OpenedDropdown/components/multiSelect/MultiSelectDropdownBottomBar.styled.js"),require("../../dropdown/OpenedDropdown/components/OpennedDropdown.styled.js"),require("../../icon-button/IconButton.js");var a=require("../../input/Input.js");require("../../dropdown/MenuItem/MenuItem.js");exports.CouponExpiration=d=>{var p;const[u,x]=r.useState(),[c,l]=r.useState(),m=(new Date).setDate((new Date).getDate()+1),j=[{selected:d.selectedExpiration===i.COUPON_EXPIRATION.DYNAMIC_EXPIRATION,label:"After a certain no. of days",value:i.COUPON_EXPIRATION.DYNAMIC_EXPIRATION},{selected:d.selectedExpiration===i.COUPON_EXPIRATION.FIXED_EXPIRATION,label:"Fixed expiry date",value:i.COUPON_EXPIRATION.FIXED_EXPIRATION}];r.useEffect((()=>{(void 0===d.selectedExpiration||null===d.selectedExpiration||u||c)&&d.setDiscountData(Object.assign(Object.assign({},d.discountData),{expireAfter:void 0,expireAt:void 0})),d.selectedExpiration&&(u||c)&&(d.selectedExpiration===i.COUPON_EXPIRATION.FIXED_EXPIRATION?l(void 0):x(void 0))}),[d.selectedExpiration,u,c]);return e.jsxRuntimeExports.jsxs("div",Object.assign({style:{display:"flex",flexDirection:"column",gap:13,margin:"16px 0 0 28px"}},{children:[e.jsxRuntimeExports.jsxs("div",{children:[e.jsxRuntimeExports.jsx(s.BodySecondary,Object.assign({style:{marginBottom:8}},{children:"Expiration"})),e.jsxRuntimeExports.jsx("div",Object.assign({style:{display:"flex",flexGrow:0,flexShrink:0,flexBasis:"auto"}},{children:e.jsxRuntimeExports.jsx(n.Dropdown,{width:"268px",options:j,placement:"bottom-start",onSelect:e=>{const t=e.value;d.setSelectedExpiration(t),d.setDiscountData(Object.assign(Object.assign({},d.discountData),{expireAt:void 0,expireAfter:void 0}))},truncatedText:!1})}))]}),d.selectedExpiration===i.COUPON_EXPIRATION.DYNAMIC_EXPIRATION&&e.jsxRuntimeExports.jsx(a.Input,{value:null===(p=d.discountData.expireAfter)||void 0===p?void 0:p.toString(),placeholder:"Eg. 5",labelText:"No. of days before coupon expires",width:"268px",type:"number",onChangeText:e=>{(e=>{l(void 0);const t=Number.parseInt(e);t>0?d.setDiscountData(Object.assign(Object.assign({},d.discountData),{expireAfter:t,expireAt:void 0})):l("Please enter valid input")})(e)},isRequired:!0,errorMessage:d.inValidCouponExpiry?"Required Field":c,state:d.inValidCouponExpiry?"invalid":"none"}),d.selectedExpiration===i.COUPON_EXPIRATION.FIXED_EXPIRATION&&e.jsxRuntimeExports.jsxs(e.jsxRuntimeExports.Fragment,{children:[e.jsxRuntimeExports.jsx(s.BodySecondary,{children:"Expiring on"}),e.jsxRuntimeExports.jsx(o.CustomDateTime,{placement:"bottom-start",time:d.discountData.expireAt?t.format(new Date(d.discountData.expireAt),"hh:mm a"):t.format(new Date(m),"hh:mm a"),date:d.discountData.expireAt?new Date(d.discountData.expireAt):new Date(m),error:u,setError:x,onChange:e=>{d.setDiscountData(Object.assign(Object.assign({},d.discountData),{expireAt:e,expireAfter:void 0}))},minDate:new Date(m)})]})]}))};
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../../../node_modules/react/jsx-runtime.js"),t=require("date-fns"),r=require("react"),o=require("../../custom-date-time/CustomDateTime.js"),n=require("../type.js");require("../../dropdown/DropdownPopover/index.js");var s=require("../../dropdown/Dropdown.js");require("../../dropdown/ChipDropdown.js"),require("../../zeroState/ZeroState.js");var i=require("../../TypographyStyle.js");require("../../../constants/Theme.js"),require("../../dropdown/OpenedDropdown/components/description/Description.styled.js"),require("../../checkBox/CheckBox.styled.js"),require("../../list-item/ListItem.js"),require("../../dropdown/OpenedDropdown/components/menu/FreeFormMenu.styled.js"),require("../../dropdown/OpenedDropdown/components/menu/MenuItem.js"),require("../../dropdown/OpenedDropdown/components/menu/MenuList.styled.js"),require("../../button/Button.js"),require("../../dropdown/OpenedDropdown/components/multiSelect/MultiSelectDropdownBottomBar.styled.js"),require("../../dropdown/OpenedDropdown/components/OpennedDropdown.styled.js"),require("../../icon-button/IconButton.js");var a=require("../../input/Input.js");require("../../dropdown/MenuItem/MenuItem.js");exports.CouponExpiration=d=>{var p;const[u,c]=r.useState(),[x,l]=r.useState(),m=(new Date).setDate((new Date).getDate()+1),j=()=>{try{const e=d.discountData.expireAt;if(!e)return m;let t;return"object"==typeof e&&"seconds"in e?t=new Date(1e3*e.seconds):e instanceof Date?t=e:"number"==typeof e||"string"==typeof e?t=new Date(e):(console.warn("safeToDate: unknown type",e),t=m),isNaN(t.getTime())?(console.warn("safeToDate: Invalid date for value:",e),m):t}catch(e){return console.error("safeToDate error:",e),m}},D=[{selected:d.selectedExpiration===n.COUPON_EXPIRATION.DYNAMIC_EXPIRATION,label:"After a certain no. of days",value:n.COUPON_EXPIRATION.DYNAMIC_EXPIRATION},{selected:d.selectedExpiration===n.COUPON_EXPIRATION.FIXED_EXPIRATION,label:"Fixed expiry date",value:n.COUPON_EXPIRATION.FIXED_EXPIRATION}];r.useEffect((()=>{(void 0===d.selectedExpiration||null===d.selectedExpiration||u||x)&&d.setDiscountData(Object.assign(Object.assign({},d.discountData),{expireAfter:void 0,expireAt:void 0})),d.selectedExpiration&&(u||x)&&(d.selectedExpiration===n.COUPON_EXPIRATION.FIXED_EXPIRATION?l(void 0):c(void 0))}),[d.selectedExpiration,u,x]);return e.jsxRuntimeExports.jsxs("div",Object.assign({style:{display:"flex",flexDirection:"column",gap:13,margin:"16px 0 0 28px"}},{children:[e.jsxRuntimeExports.jsx("div",{children:!d.hideExpirationOptions&&e.jsxRuntimeExports.jsxs(e.jsxRuntimeExports.Fragment,{children:[e.jsxRuntimeExports.jsx(i.BodySecondary,Object.assign({style:{marginBottom:8}},{children:"Expiration"})),e.jsxRuntimeExports.jsx("div",Object.assign({style:{display:"flex",flexGrow:0,flexShrink:0,flexBasis:"auto"}},{children:e.jsxRuntimeExports.jsx(s.Dropdown,{width:"268px",options:D,placement:"bottom-start",onSelect:e=>{const t=e.value;d.setSelectedExpiration(t),d.setDiscountData(Object.assign(Object.assign({},d.discountData),{expireAt:void 0,expireAfter:void 0}))},truncatedText:!1})}))]})}),d.selectedExpiration===n.COUPON_EXPIRATION.DYNAMIC_EXPIRATION&&e.jsxRuntimeExports.jsx(a.Input,{value:null===(p=d.discountData.expireAfter)||void 0===p?void 0:p.toString(),placeholder:"Eg. 5",labelText:"No. of days before coupon expires",width:"268px",type:"number",onChangeText:e=>{(e=>{l(void 0);const t=Number.parseInt(e);t>0?d.setDiscountData(Object.assign(Object.assign({},d.discountData),{expireAfter:t,expireAt:void 0})):l("Please enter valid input")})(e)},isRequired:!0,errorMessage:d.inValidCouponExpiry?"Required Field":x,state:d.inValidCouponExpiry?"invalid":"none"}),d.selectedExpiration===n.COUPON_EXPIRATION.FIXED_EXPIRATION&&e.jsxRuntimeExports.jsxs(e.jsxRuntimeExports.Fragment,{children:[e.jsxRuntimeExports.jsx(i.BodySecondary,{children:"Expiring on"}),e.jsxRuntimeExports.jsx(o.CustomDateTime,{placement:"bottom-start",time:(()=>{try{return t.format(j(),"hh:mm a")}catch(e){return console.error("formatTime error:",e),""}})(),date:j(),error:u,setError:c,onChange:e=>{d.setDiscountData(Object.assign(Object.assign({},d.discountData),{expireAt:e,expireAfter:void 0}))},minDate:new Date(m)})]})]}))};
@@ -35,5 +35,6 @@ export interface DiscountDialogueI {
35
35
  isProductVariableSupported?: boolean;
36
36
  productVariableList?: VariableListInterfaceV3[];
37
37
  makeExpiryMandatory?: boolean;
38
+ getDetailedDescription?: boolean;
38
39
  }
39
40
  export declare const DiscountModal: React.FC<DiscountDialogueI>;
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../../node_modules/react/jsx-runtime.js"),t=require("@bikdotai/bik-models/growth/models/bik-store"),i=require("react"),o=require("./type.js");require("../dropdown/DropdownPopover/index.js");var n=require("../dropdown/Dropdown.js");require("../dropdown/ChipDropdown.js"),require("../zeroState/ZeroState.js");var l=require("../TypographyStyle.js"),r=require("../../constants/Theme.js");require("../dropdown/OpenedDropdown/components/description/Description.styled.js"),require("../checkBox/CheckBox.styled.js"),require("../list-item/ListItem.js"),require("../dropdown/OpenedDropdown/components/menu/FreeFormMenu.styled.js"),require("../dropdown/OpenedDropdown/components/menu/MenuItem.js"),require("../dropdown/OpenedDropdown/components/menu/MenuList.styled.js"),require("../button/Button.js"),require("../dropdown/OpenedDropdown/components/multiSelect/MultiSelectDropdownBottomBar.styled.js"),require("../dropdown/OpenedDropdown/components/OpennedDropdown.styled.js"),require("../icon-button/IconButton.js"),require("../input/Input.js"),require("../dropdown/MenuItem/MenuItem.js");var s=require("../modals/styledModal.js"),a=require("../product-picker/ProductPickerModal.js"),d=require("../tag/Tag.js"),u=require("../tooltips/Tooltip.js"),c=require("../../assets/icons/gift_icon.svg.js"),p=require("../../assets/icons/percentage_icon.svg.js"),C=require("../../assets/icons/shipping_icon.svg.js"),E=require("../../assets/icons/triangle_error.svg.js"),T=require("../../assets/icons/warning.svg.js"),S=require("../product-picker-v2/modal.js");require("../product-picker-v2/type.js");var P=require("../variable-picker-v3/model.js"),I=require("../variable-picker-v3/VariablePicker.js"),O=require("./DiscountModal.styled.js"),v=require("./DiscountUtils.js"),_=require("./DynamicCoupon/DynamicCoupon.js"),b=require("./StaticCoupon/StaticCoupon.js");exports.DiscountModal=y=>{var m,x,D,N,h,j,R,f,U,A,g;const V=[{id:"0",label:"Amount",value:"amount",icon:t=>e.jsxRuntimeExports.jsx("span",Object.assign({style:{fontSize:20,color:t,lineHeight:.9}},{children:y.currency||""}))},{id:"1",label:"Percentage",value:"percentage",icon:t=>e.jsxRuntimeExports.jsx(p.default,{width:24,height:24,color:t})},{id:"2",label:"Buy X get Y",value:o.DISCOUNT_TYPES.BUY_X_GET_Y,icon:t=>e.jsxRuntimeExports.jsx(c.default,{width:24,height:24,color:t})},{id:"3",label:"Free Shipping",value:o.DISCOUNT_TYPES.FREE_SHIPPING,icon:t=>e.jsxRuntimeExports.jsx(C.default,{width:24,height:24,color:t})}],[F,k]=i.useState(),[q,L]=i.useState(),[M,Y]=i.useState(),[w,G]=i.useState(null!==(m=y.data)&&void 0!==m?m:"string"==typeof y.hideOption?{isStaticCoupon:"dynamic"===y.hideOption}:{isStaticCoupon:!0}),[B,X]=i.useState(!0),[Q,H]=i.useState(),[z,K]=i.useState((null===(x=y.data)||void 0===x?void 0:x.minAmount)?o.MIN_PURCHASE_REQUIREMENT.AMOUNT:(null===(D=y.data)||void 0===D?void 0:D.minQuantity)?o.MIN_PURCHASE_REQUIREMENT.QUANTITY:o.MIN_PURCHASE_REQUIREMENT.NA),[$,Z]=i.useState(o.DISCOUNT_APPLIES_TO.ENTIRE_ORDER),[J,W]=i.useState(o.OFFER_APPLIES_TO.SPECIFIC_PRODUCTS),[ee,te]=i.useState(o.OFFER_APPLIES_TO.SPECIFIC_PRODUCTS),[ie,oe]=i.useState(void 0),[ne,le]=i.useState(void 0),[re,se]=i.useState(void 0),[ae,de]=i.useState(void 0),[ue,ce]=i.useState(void 0),[pe,Ce]=i.useState(void 0),[Ee,Te]=i.useState(0),[Se,Pe]=i.useState(""),[Ie,Oe]=i.useState(V[0]),[ve,_e]=i.useState(!1),[be,ye]=i.useState(o.initialStaticCouponErrorState),[me,xe]=i.useState(o.initialDynamicCouponErrorState),[De,Ne]=i.useState(o.COUPON_EXPIRATION.DYNAMIC_EXPIRATION),he=[{value:o.DISCOUNT_TYPES.AMOUNT_OFF_ORDER,label:"Amount off on order",selected:Q===o.DISCOUNT_TYPES.AMOUNT_OFF_ORDER},{value:o.DISCOUNT_TYPES.AMOUNT_OFF_PRODUCTS,label:"Amount off on products",selected:Q===o.DISCOUNT_TYPES.AMOUNT_OFF_PRODUCTS},{value:o.DISCOUNT_TYPES.BUY_X_GET_Y,label:"Buy X Get Y FREE",selected:Q===o.DISCOUNT_TYPES.BUY_X_GET_Y},{value:o.DISCOUNT_TYPES.FREE_SHIPPING,label:"Free shipping",selected:Q===o.DISCOUNT_TYPES.FREE_SHIPPING}];i.useEffect((()=>{y.makeExpiryMandatory&&_e(!0)}),[y.makeExpiryMandatory]),i.useEffect((()=>{var e,t,i,n,l,r,s,a;let d;const{tempCouponData:u,discountType:c}=je();H(c);const p=(e,t)=>{Oe(u.valueType===o.DISCOUNT_VALUE_TYPES.FIXED_AMOUNT?V[e]:V[t])},C=(e,t)=>{Object.keys(e||{}).length&&t(e)};switch(((null==u?void 0:u.expireAfter)||(null==u?void 0:u.expireAt))&&(_e(!0),(null==u?void 0:u.expireAt)&&Ne(o.COUPON_EXPIRATION.FIXED_EXPIRATION),(null==u?void 0:u.expireAfter)&&Ne(o.COUPON_EXPIRATION.DYNAMIC_EXPIRATION)),c){case o.DISCOUNT_TYPES.AMOUNT_OFF_ORDER:p(0,1),Z(o.DISCOUNT_APPLIES_TO.ENTIRE_ORDER);break;case o.DISCOUNT_TYPES.AMOUNT_OFF_PRODUCTS:p(0,1),(null===(e=u.entitledCollectionIds)||void 0===e?void 0:e.length)?Z(o.DISCOUNT_APPLIES_TO.SPECIFIC_COLLECTIONS):(null===(t=u.entitledProductIds)||void 0===t?void 0:t.length)||(null===(i=u.productVariableConf)||void 0===i?void 0:i.entitledProductVariable)?(Z(o.DISCOUNT_APPLIES_TO.SPECIFIC_PRODUCTS),C(null===(n=u.productVariableConf)||void 0===n?void 0:n.entitledProductVariable,de)):Z(o.DISCOUNT_APPLIES_TO.ENTIRE_ORDER);break;case o.DISCOUNT_TYPES.BUY_X_GET_Y:Oe(V[2]),(null===(l=u.entitledCollectionIds)||void 0===l?void 0:l.length)?te(o.OFFER_APPLIES_TO.SPECIFIC_COLLECTIONS):(te(o.OFFER_APPLIES_TO.SPECIFIC_PRODUCTS),C(null===(r=u.productVariableConf)||void 0===r?void 0:r.entitledProductVariable,de)),(null===(s=u.prerequisiteCollectionIds)||void 0===s?void 0:s.length)?W(o.OFFER_APPLIES_TO.SPECIFIC_COLLECTIONS):(W(o.OFFER_APPLIES_TO.SPECIFIC_PRODUCTS),C(null===(a=u.productVariableConf)||void 0===a?void 0:a.prerequisiteProductVariable,ce));break;case o.DISCOUNT_TYPES.FREE_SHIPPING:Oe(V[3])}G(Object.assign({},u)),y.hideProbability||(d=Ue()),X(v.validateDiscountData(u,z,c,y.hideProbability||!1,d,!!u.isStaticCoupon)),y.hideProbability||Ue()}),[]),i.useEffect((()=>{let e;y.hideProbability||(e=Ue()),X(v.validateDiscountData(w,z,Q,y.hideProbability||!1,e,!!w.isStaticCoupon))}),[w,Ee,Q,z]),i.useEffect((()=>{var e,t,i,o,n,l,r;if(!y.newPickerConf&&((null===(e=y.products)||void 0===e?void 0:e.length)||(null===(t=y.collection)||void 0===t?void 0:t.length))){if(y.products&&(null===(i=y.products)||void 0===i?void 0:i.length)){if(null===(o=y.data)||void 0===o?void 0:o.entitledProductIds){const e=y.products.filter((e=>{var t,i;return null===(i=null===(t=y.data)||void 0===t?void 0:t.entitledProductIds)||void 0===i?void 0:i.includes(parseInt(e.id))}));le(e)}if(null===(n=y.data)||void 0===n?void 0:n.prerequisiteProductIds){const e=y.products.filter((e=>{var t,i;return null===(i=null===(t=y.data)||void 0===t?void 0:t.prerequisiteProductIds)||void 0===i?void 0:i.includes(parseInt(e.id))}));oe(e)}}if(y.collection&&y.collection.length){if(null===(l=y.data)||void 0===l?void 0:l.entitledCollectionIds){const e=y.collection.filter((e=>{var t,i;return null===(i=null===(t=y.data)||void 0===t?void 0:t.entitledCollectionIds)||void 0===i?void 0:i.includes(parseInt(e.id))}));Ce(e)}if(null===(r=y.data)||void 0===r?void 0:r.prerequisiteCollectionIds){const e=y.collection.filter((e=>{var t,i;return null===(i=null===(t=y.data)||void 0===t?void 0:t.prerequisiteCollectionIds)||void 0===i?void 0:i.includes(parseInt(e.id))}));se(e)}}}}),[y.products,y.collection]),i.useEffect((()=>{var e,t,i,o,n,l,r,s;(null===(t=null===(e=y.data)||void 0===e?void 0:e.productsConf)||void 0===t?void 0:t.entitledProducts)&&le(y.data.productsConf.entitledProducts),(null===(o=null===(i=y.data)||void 0===i?void 0:i.productsConf)||void 0===o?void 0:o.prerequisiteProducts)&&oe(y.data.productsConf.prerequisiteProducts),(null===(l=null===(n=y.data)||void 0===n?void 0:n.collectionsConf)||void 0===l?void 0:l.entitledCollections)&&Ce(y.data.collectionsConf.entitledCollections),(null===(s=null===(r=y.data)||void 0===r?void 0:r.collectionsConf)||void 0===s?void 0:s.prerequisiteCollections)&&se(y.data.collectionsConf.prerequisiteCollections)}),[null===(N=y.data)||void 0===N?void 0:N.productsConf,null===(h=y.data)||void 0===h?void 0:h.collectionsConf]),i.useEffect((()=>{if(!ne)return;if(y.newPickerConf){const e=[];return Object.values(ne).forEach((t=>{t.products&&Object.keys(t.products).forEach((t=>{e.push(parseInt(t))}))})),void G(Object.assign(Object.assign({},w),{entitledProductIds:e}))}const e=ne.map((e=>parseInt(e.id)));G(Object.assign(Object.assign({},w),{entitledProductIds:e}))}),[ne]),i.useEffect((()=>{if(!ie)return;if(y.newPickerConf){const e=[];return Object.values(ie).forEach((t=>{t.products&&Object.keys(t.products).forEach((t=>{e.push(parseInt(t))}))})),void G(Object.assign(Object.assign({},w),{prerequisiteProductIds:e}))}const e=ie.map((e=>parseInt(e.id)));G(Object.assign(Object.assign({},w),{prerequisiteProductIds:e}))}),[ie]),i.useEffect((()=>{if(!pe)return;if(y.newPickerConf){(null==pe?void 0:pe.isCustom)&&delete pe.isCustom;const e=Object.keys(pe).map((e=>parseInt(e)));return void G(Object.assign(Object.assign({},w),{entitledCollectionIds:e}))}const e=pe.map((e=>parseInt(e.id)));G(Object.assign(Object.assign({},w),{entitledCollectionIds:e}))}),[pe]),i.useEffect((()=>{if(!re)return;if(y.newPickerConf){(null==re?void 0:re.isCustom)&&delete re.isCustom;const e=Object.keys(re).map((e=>parseInt(e)));return void G(Object.assign(Object.assign({},w),{prerequisiteCollectionIds:e}))}const e=re.map((e=>parseInt(e.id)));G(Object.assign(Object.assign({},w),{prerequisiteCollectionIds:e}))}),[re]);const je=()=>{var e,t;let i,n=w;return w.isStaticCoupon||(w.targetType===o.DISCOUNT_TARGET_TYPES.SHIPPING_LINE?i=o.DISCOUNT_TYPES.FREE_SHIPPING:w.targetType===o.DISCOUNT_TARGET_TYPES.LINE_ITEM?i=w.targetSelection===o.DISCOUNT_TARGET_SELECTION.ENTITLED?(null===(e=w.prerequisiteProductIds)||void 0===e?void 0:e.length)||(null===(t=w.prerequisiteCollectionIds)||void 0===t?void 0:t.length)||w.prerequisiteQuantity||w.entitledQuantity?o.DISCOUNT_TYPES.BUY_X_GET_Y:o.DISCOUNT_TYPES.AMOUNT_OFF_PRODUCTS:o.DISCOUNT_TYPES.AMOUNT_OFF_ORDER:(n=Object.assign(Object.assign({},n),{targetType:o.DISCOUNT_TARGET_TYPES.LINE_ITEM,targetSelection:o.DISCOUNT_TARGET_SELECTION.ALL,valueType:o.DISCOUNT_VALUE_TYPES.FIXED_AMOUNT}),i=o.DISCOUNT_TYPES.AMOUNT_OFF_ORDER)),{discountType:i,tempCouponData:n}},Re=()=>{ye(o.initialStaticCouponErrorState),xe(o.initialDynamicCouponErrorState)},fe=e=>{var t;const i={invalidDiscountCode:"Please add Discount Code",invalidCouponTitle:"Please add Discount Coupon Title",invalidCouponDescription:"Please add Coupon Description",inValidProbability:e.inValidProbability&&(null!==(t=w.probability)&&void 0!==t?t:-1)>1?"Probability should not exceed 1":w.isStaticCoupon?"Please add Probability":"Probability should be greater than 0",inValidDiscountAmount:"Please add Discount Amount",inValidMinimumAmount:"Specify minimum amount required",inValidMinimumQuantity:"Specify minimum items required",inValidCouponExpiry:"Please add Coupon Expiry",inValidProductSelection:"Please specify the products",inValidProductVariableSelection:"Please specify the product variables",inValidCollectionSelection:"Please specify the collections",inValidBuyXValue:"Please specify buy product quantity",inValidGetYValue:"Please specify get product quantity",inValidBuyXProductSelection:"Please specify the products",inValidBuyXCollectionSelection:"Please specify the collections",inValidGetYProductSelection:"Please specify the products",inValidGetYCollectionSelection:"Please specify the collections",inValidBuyXProductVariableSelection:"Please specify the product variables",inValidGetYProductVariableSelection:"Please specify the product variables"};let o="";Object.keys(e).forEach((t=>{e[t]&&(o=i[t])}));const n=Object.values(e).filter(Boolean).length;return n>0&&(Pe(n>1?"Please add discount details":o),!0)},Ue=()=>{if(!y.quadrant||!y.probability)return;const e=[...y.probability];let t=[];e.length>=y.quadrant&&e.splice(y.quadrant-1,1),t=e;const i=t.reduce(((e,t)=>e+t),0)+(w.probability||0);return Te(parseFloat(i.toFixed(4))),parseFloat(i.toFixed(4))},Ae=e=>{var t,i,n,l,r,s,a,d,u,c,p,C,E,T,S,P;const I=e.value;H(I),oe([]),le([]),se([]),Ce([]),I===o.DISCOUNT_TYPES.FREE_SHIPPING?G({value:100,targetSelection:o.DISCOUNT_TARGET_SELECTION.ALL,targetType:o.DISCOUNT_TARGET_TYPES.SHIPPING_LINE,valueType:o.DISCOUNT_VALUE_TYPES.PERCENTAGE,quadrant:w.quadrant,isStaticCoupon:!1,title:w.title,expireAt:null!==(t=w.expireAt)&&void 0!==t?t:void 0,expireAfter:null!==(i=w.expireAfter)&&void 0!==i?i:void 0,probability:w.probability,minQuantity:null!==(n=w.minQuantity)&&void 0!==n?n:void 0,minAmount:null!==(l=w.minAmount)&&void 0!==l?l:void 0}):I===o.DISCOUNT_TYPES.BUY_X_GET_Y?G({value:100,targetSelection:o.DISCOUNT_TARGET_SELECTION.ENTITLED,targetType:o.DISCOUNT_TARGET_TYPES.LINE_ITEM,valueType:o.DISCOUNT_VALUE_TYPES.PERCENTAGE,quadrant:w.quadrant,isStaticCoupon:!1,title:w.title,expireAt:null!==(r=w.expireAt)&&void 0!==r?r:void 0,expireAfter:null!==(s=w.expireAfter)&&void 0!==s?s:void 0,probability:w.probability,minQuantity:void 0,minAmount:void 0}):I===o.DISCOUNT_TYPES.AMOUNT_OFF_ORDER?G({targetSelection:o.DISCOUNT_TARGET_SELECTION.ALL,targetType:o.DISCOUNT_TARGET_TYPES.LINE_ITEM,valueType:null!==(a=w.valueType)&&void 0!==a?a:o.DISCOUNT_VALUE_TYPES.FIXED_AMOUNT,quadrant:w.quadrant,isStaticCoupon:!1,title:w.title,expireAt:null!==(d=w.expireAt)&&void 0!==d?d:void 0,expireAfter:null!==(u=w.expireAfter)&&void 0!==u?u:void 0,probability:w.probability,value:w.value,minQuantity:null!==(c=w.minQuantity)&&void 0!==c?c:void 0,minAmount:null!==(p=w.minAmount)&&void 0!==p?p:void 0}):I===o.DISCOUNT_TYPES.AMOUNT_OFF_PRODUCTS&&G({targetSelection:o.DISCOUNT_TARGET_SELECTION.ENTITLED,targetType:o.DISCOUNT_TARGET_TYPES.LINE_ITEM,valueType:null!==(C=w.valueType)&&void 0!==C?C:o.DISCOUNT_VALUE_TYPES.FIXED_AMOUNT,quadrant:w.quadrant,isStaticCoupon:!1,title:w.title,expireAt:null!==(E=w.expireAt)&&void 0!==E?E:void 0,expireAfter:null!==(T=w.expireAfter)&&void 0!==T?T:void 0,probability:w.probability,value:w.value,minQuantity:null!==(S=w.minQuantity)&&void 0!==S?S:void 0,minAmount:null!==(P=w.minAmount)&&void 0!==P?P:void 0})},ge=t=>t&&e.jsxRuntimeExports.jsx(d.Tag,{theme:"light",tagText:t,type:"negative",LeadingIcon:T.default});return e.jsxRuntimeExports.jsxs(s.StyledModal,Object.assign({width:(M||F)&&y.newPickerConf?"25px":"640px",open:y.isOpen,hideCrossButton:!!q,headingTitle:F?"Select Products":y.title,headingSubtitle:F?void 0:y.subTitle,footerLeftCustomElement:Se?ge(Se):y.errorMsg?ge(y.errorMsg):!y.quadrant||y.hideProbability?e.jsxRuntimeExports.jsx(e.jsxRuntimeExports.Fragment,{}):Ee<=1?e.jsxRuntimeExports.jsx(d.Tag,{theme:"light",tagText:`Current probability sum: ${Ee}`,type:"white"}):e.jsxRuntimeExports.jsx(u.Tooltip,Object.assign({body:"Probability sum should not exceed 1",placement:"top"},{children:e.jsxRuntimeExports.jsx("div",{children:e.jsxRuntimeExports.jsx(d.Tag,{style:{cursor:"pointer"},theme:"light",tagText:`Current probability sum: ${Ee}`,type:"negative",LeadingIcon:E.default})})})),headerRightCustomElement:y.allowStaticCoupon||F?void 0:e.jsxRuntimeExports.jsx(n.Dropdown,{options:he,width:"200px",placement:"bottom-start",size:"small",onSelect:e=>{Ae(e)}}),onClose:y.onClose,footerContainerStyle:{borderTop:`1px solid ${r.DEFAULT_THEME.colorsV2.stroke.primary}`},primaryButton:F?{buttonType:"primary",onClick:()=>{k(void 0)},buttonText:"Add"}:M?{buttonType:"primary",onClick:()=>{Y(void 0)},buttonText:"Add"}:{buttonType:"primary",buttonText:"Create discount code",isLoading:null!==(j=y.loading)&&void 0!==j&&j,onClick:()=>{var e,t,i,n,l;if(Re(),w.isStaticCoupon){const{isStaticCoupon:e,couponCode:t,title:i,description:o,quadrant:n,probability:l}=w,r={invalidDiscountCode:!t,invalidCouponTitle:!i,invalidCouponDescription:!o,inValidProbability:!y.hideProbability&&(null!=l?l:-1)<0||(null!=l?l:0)>1||Number.isNaN(null!=l?l:0)};if(fe(r))return void ye(r);if(B||Ee>1)return void Pe(!y.hideProbability&&Ee>1?"Probability sum should not exceed 1":"Invalid coupon details");y.onSaveClicked({quadrant:n,couponCode:t,description:o,isStaticCoupon:e,probability:l,title:w.title})}else{const r={invalidCouponTitle:!w.title,inValidProbability:!y.hideProbability&&(null!==(e=w.probability)&&void 0!==e?e:-1)<=0||(null!==(t=w.probability)&&void 0!==t?t:-1)>1||Number.isNaN(null!==(i=w.probability)&&void 0!==i?i:-1),inValidDiscountAmount:!w.value,inValidMinimumQuantity:!1,inValidMinimumAmount:!1,inValidCouponExpiry:!1,inValidProductSelection:!1,inValidProductVariableSelection:!1,inValidCollectionSelection:!1,inValidBuyXValue:!1,inValidGetYValue:!1,inValidBuyXProductSelection:!1,inValidGetYProductSelection:!1,inValidBuyXCollectionSelection:!1,inValidGetYCollectionSelection:!1,inValidBuyXProductVariableSelection:!1,inValidGetYProductVariableSelection:!1};if(Q!==o.DISCOUNT_TYPES.BUY_X_GET_Y&&z!==o.MIN_PURCHASE_REQUIREMENT.NA){const{minAmount:e,minQuantity:t}=w;r.inValidMinimumAmount=z===o.MIN_PURCHASE_REQUIREMENT.AMOUNT&&!e,r.inValidMinimumQuantity=z===o.MIN_PURCHASE_REQUIREMENT.QUANTITY&&!t}if(ve&&(r.inValidCouponExpiry=!w.expireAt&&!w.expireAfter),Q!==o.DISCOUNT_TYPES.AMOUNT_OFF_ORDER&&Q!==o.DISCOUNT_TYPES.AMOUNT_OFF_PRODUCTS||($!==o.DISCOUNT_APPLIES_TO.SPECIFIC_PRODUCTS||!ne||Object.keys(ne).length||ae||(r.inValidProductSelection=!0,r.inValidProductVariableSelection=!0),$===o.DISCOUNT_APPLIES_TO.SPECIFIC_COLLECTIONS&&pe&&!Object.keys(pe).length&&(r.inValidCollectionSelection=!0)),Q===o.DISCOUNT_TYPES.BUY_X_GET_Y&&(w.prerequisiteQuantity||(r.inValidBuyXValue=!0),w.entitledQuantity||(r.inValidGetYValue=!0),J!==o.OFFER_APPLIES_TO.SPECIFIC_PRODUCTS||!ie||Object.keys(ie).length||ue||(r.inValidBuyXProductSelection=!0,r.inValidBuyXProductVariableSelection=!0),J===o.OFFER_APPLIES_TO.SPECIFIC_COLLECTIONS&&re&&!Object.keys(re).length&&(r.inValidBuyXCollectionSelection=!0),ee!==o.OFFER_APPLIES_TO.SPECIFIC_PRODUCTS||!ne||Object.keys(ne).length||ae||(r.inValidGetYProductSelection=!0,r.inValidGetYProductVariableSelection=!0),ee===o.OFFER_APPLIES_TO.SPECIFIC_COLLECTIONS&&pe&&!Object.keys(pe).length&&(r.inValidGetYCollectionSelection=!0)),fe(r))return void xe(r);if(B||Ee>1)return void Pe(!y.hideProbability&&Ee>1?"Probability sum should not exceed 1":"Invalid coupon details");y.onSaveClicked(Object.assign(Object.assign({},w),{description:v.descriptionBuilder(w,y.currency,null!==(n=y.products)&&void 0!==n?n:[],null!==(l=y.collection)&&void 0!==l?l:[]),productsConf:{entitledProducts:null!=ne?ne:[],prerequisiteProducts:null!=ie?ie:[]},collectionsConf:{entitledCollections:null!=pe?pe:[],prerequisiteCollections:null!=re?re:[]},productVariableConf:{entitledProductVariable:null!=ae?ae:{},prerequisiteProductVariable:null!=ue?ue:{}}}))}}},secondaryButton:F?{buttonType:"tertiaryGray",onClick:()=>{k(void 0)},buttonText:"Back"}:M?{buttonType:"tertiaryGray",onClick:()=>{Y(void 0)},buttonText:"Back"}:{buttonType:"tertiaryGray",onClick:y.onClose,buttonText:"Cancel"}},{children:[!F&&!M&&e.jsxRuntimeExports.jsxs(O.StyledDiscountDialogueContainer,{children:[y.allowStaticCoupon&&!F&&e.jsxRuntimeExports.jsxs(O.CouponTypeContainerStyled,Object.assign({selectedDiv:w.isStaticCoupon?1:2},{children:["static"===y.hideOption?e.jsxRuntimeExports.jsx(e.jsxRuntimeExports.Fragment,{}):e.jsxRuntimeExports.jsxs("div",Object.assign({className:"coupon-type__container",onClick:()=>{w.isStaticCoupon||(G({isStaticCoupon:!0,quadrant:w.quadrant}),Pe(""),Re())}},{children:[e.jsxRuntimeExports.jsx(l.TitleSmall,Object.assign({style:{marginBottom:"4px",color:w.isStaticCoupon?r.DEFAULT_THEME.colorsV2.content.brand:void 0}},{children:"Static Code"})),e.jsxRuntimeExports.jsx(l.BodyCaption,Object.assign({style:w.isStaticCoupon?{color:r.DEFAULT_THEME.colorsV2.content.brand}:{}},{children:"A uniform code provided manually, used for providing the same discount to all customers."}))]})),"dynamic"===y.hideOption?e.jsxRuntimeExports.jsx(e.jsxRuntimeExports.Fragment,{}):e.jsxRuntimeExports.jsxs("div",Object.assign({className:"coupon-type__container",onClick:()=>{var t;w.isStaticCoupon&&(H(o.DISCOUNT_TYPES.AMOUNT_OFF_ORDER),G({isStaticCoupon:!1,quadrant:w.quadrant,targetType:o.DISCOUNT_TARGET_TYPES.LINE_ITEM,targetSelection:o.DISCOUNT_TARGET_SELECTION.ALL,valueType:o.DISCOUNT_VALUE_TYPES.FIXED_AMOUNT}),Pe(""),Re(),Oe({id:"0",label:"Amount",value:"amount",icon:t=>e.jsxRuntimeExports.jsx("span",Object.assign({style:{fontSize:20,color:t}},{children:y.currency||""}))}),_e(null!==(t=y.makeExpiryMandatory)&&void 0!==t&&t),K(o.MIN_PURCHASE_REQUIREMENT.NA))}},{children:[e.jsxRuntimeExports.jsx(l.TitleSmall,Object.assign({style:{marginBottom:"4px",color:w.isStaticCoupon?void 0:r.DEFAULT_THEME.colorsV2.content.brand}},{children:"Dynamic Code"})),e.jsxRuntimeExports.jsx(l.BodyCaption,Object.assign({style:w.isStaticCoupon?{}:{color:r.DEFAULT_THEME.colorsV2.content.brand}},{children:"Code will be unique for all customers, with the first 5 letters of the customer's name, followed by 10 random characters."}))]}))]})),e.jsxRuntimeExports.jsx(l.TitleRegular,Object.assign({style:{marginTop:"24px"}},{children:"Coupon Details"})),w.isStaticCoupon&&!F&&e.jsxRuntimeExports.jsx(b.default,{discountData:w,setDiscountData:G,hideProbability:y.hideProbability||!1,discountAdminUrl:y.discountAdminUrl,staticDiscountValidationError:be,currency:y.currency}),!w.isStaticCoupon&&!F&&!M&&e.jsxRuntimeExports.jsx(_.default,{currency:y.currency,entitledProducts:null!=ne?ne:[],prerequisiteProducts:null!=ie?ie:[],setEntitledProducts:le,setPrerequisiteProducts:oe,discountData:w,productPickerOpen:F,productVariablePickerOpen:q,setIsProductPickerOpen:k,setIsProductVariablePickerOpen:L,setDiscountData:G,selectedCouponType:Q,setSelectedCouponType:H,selectedMinimumRequirement:z,setSelectedMinimumRequirement:K,discountCouponAppliesTo:$,offerAppliesToBuy:J,offerAppliesToGet:ee,setDiscountCouponAppliesTo:Z,setOfferAppliesToBuy:W,setOfferAppliesToGet:te,hideProbability:y.hideProbability||!1,hideExpiration:y.hideExpiration||!1,allowStaticCoupon:y.allowStaticCoupon,onChangeCouponType:Ae,collectionPickerOpen:M,entitledCollections:null!=pe?pe:[],prerequisiteCollections:null!=re?re:[],setIsCollectionPickerOpen:Y,setEntitledCollections:Ce,setPrerequisiteCollections:se,useNewPicker:!!y.newPickerConf,setSelectedDiscountDetails:Oe,selectedDiscountDetails:Ie,isProductVariableSupported:y.isProductVariableSupported,entitledProductVariable:ae,setEntitledProductVariable:de,preRequisiteProductVariable:ue,setPreRequisiteProductVariable:ce,productVariableList:y.productVariableList,isAddExpirationChecked:ve,setIsAddExpirationChecked:_e,dynamicDiscountValidationError:me,setDynamicDiscountValidationError:xe,setValidationErrorMessage:Pe,resetValidationErrors:Re,discountDetailsOptions:V,selectedExpiration:De,setSelectedExpiration:Ne,makeExpiryMandatory:!!y.makeExpiryMandatory})]}),!!F&&e.jsxRuntimeExports.jsxs(e.jsxRuntimeExports.Fragment,{children:[!y.newPickerConf&&e.jsxRuntimeExports.jsx("div",Object.assign({style:{padding:"12px 0"}},{children:e.jsxRuntimeExports.jsx(a.ProductPickerContent,{show:!0,onSave:()=>{},products:null!==(R=y.products)&&void 0!==R?R:[],title:"Select Products",onClose:()=>{k(void 0)},selectedProducts:null!==(f=F===_.DISCOUNT_PRODUCTS.ENTITLED?ne:ie)&&void 0!==f?f:[],setSelectedProducts:F===_.DISCOUNT_PRODUCTS.ENTITLED?le:oe,onSearchKeyChange:y.onProductSearch})})),y.newPickerConf&&e.jsxRuntimeExports.jsx(S.ProductPickerModal,{visible:!0,onClose:()=>k(void 0),collectionFetcher:(e,t,i)=>{var o;return(null===(o=y.newPickerConf)||void 0===o?void 0:o.fetchCollections)?y.newPickerConf.fetchCollections(e,t,!1,i):null},productFetcher:(e,t,i,o,n)=>{var l;return(null===(l=y.newPickerConf)||void 0===l?void 0:l.fetchProducts)?y.newPickerConf.fetchProducts(e,t,o,n,!1,i):null},selectedItems:F===_.DISCOUNT_PRODUCTS.ENTITLED?ne:ie,onAdd:e=>{F===_.DISCOUNT_PRODUCTS.ENTITLED?le(e):oe(e),k(void 0)},zIndex:200,storeId:y.newPickerConf.storeId,appType:y.newPickerConf.appType||t.ApplicationType.BIK,searchInCollectionFetcher:(e,t,i,o)=>{var n;return(null===(n=y.newPickerConf)||void 0===n?void 0:n.searchInCollection)?y.newPickerConf.searchInCollection(e,t,i,!1,o):null},customCollectionRestriction:!1,searchFetcher:(e,t,i)=>{var o;return(null===(o=y.newPickerConf)||void 0===o?void 0:o.searchProducts)?y.newPickerConf.searchProducts(e,t,!1,i):null},hideCollectionCheckbox:!0,hideVariantCheckbox:!0,selectProductsFromCustomCollection:!0,hideSelectionCount:!0})]}),!!M&&e.jsxRuntimeExports.jsx("div",Object.assign({style:{padding:"12px 0"}},{children:e.jsxRuntimeExports.jsxs(e.jsxRuntimeExports.Fragment,{children:[y.newPickerConf&&e.jsxRuntimeExports.jsx(S.ProductPickerModal,{visible:!0,onClose:()=>Y(void 0),collectionFetcher:y.newPickerConf.fetchCollections,productFetcher:y.newPickerConf.fetchProducts,selectedItems:M===_.DISCOUNT_PRODUCTS.ENTITLED?pe:re,onAdd:e=>{Object.values(e).forEach((e=>{e.products&&delete e.products})),M===_.DISCOUNT_PRODUCTS.ENTITLED?Ce(e):se(e),Y(void 0)},customCollectionRestriction:!1,zIndex:200,storeId:y.newPickerConf.storeId,appType:y.newPickerConf.appType||t.ApplicationType.BIK,searchInCollectionFetcher:y.newPickerConf.searchInCollection,searchFetcher:y.newPickerConf.searchProducts,hideProductCheckbox:!0,hideVariantCheckbox:!0,title:"Select Collections",hideGlobalSearch:!0,hideSelectionCount:!0}),!y.newPickerConf&&e.jsxRuntimeExports.jsx(a.ProductPickerContent,{show:!0,onSave:()=>{},products:null!==(U=y.collection)&&void 0!==U?U:[],title:"Select Products",onClose:()=>{Y(void 0)},selectedProducts:null!==(A=M===_.DISCOUNT_PRODUCTS.ENTITLED?pe:re)&&void 0!==A?A:[],setSelectedProducts:M===_.DISCOUNT_PRODUCTS.ENTITLED?Ce:se,onSearchKeyChange:y.onCollectionSearch,searchPlaceholder:"Search collections..."})]})})),q&&e.jsxRuntimeExports.jsx(O.VariablePickerContainer,{children:e.jsxRuntimeExports.jsx("div",Object.assign({style:{width:"50%",height:"100%",marginLeft:"50%"}},{children:e.jsxRuntimeExports.jsx(I.VariablePicker,{type:P.PickerType.EMBEDDED,data:null!==(g=y.productVariableList)&&void 0!==g?g:[],showHeader:!0,onSelect:e=>{if(q===_.DISCOUNT_PRODUCTS.ENTITLED){const{displayName:t,actualValue:i,isAvailable:o}=e;de({displayName:t,actualValue:i,isAvailable:o}),L(void 0)}if(q===_.DISCOUNT_PRODUCTS.PREREQUISITE){const{displayName:t,actualValue:i,isAvailable:o}=e;ce({displayName:t,actualValue:i,isAvailable:o}),L(void 0)}},onClose:()=>{L(void 0)}})}))})]}))};
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../../node_modules/react/jsx-runtime.js"),i=require("@bikdotai/bik-models/growth/models/bik-store"),t=require("react"),o=require("./type.js");require("../dropdown/DropdownPopover/index.js");var n=require("../dropdown/Dropdown.js");require("../dropdown/ChipDropdown.js"),require("../zeroState/ZeroState.js");var l=require("../TypographyStyle.js"),r=require("../../constants/Theme.js");require("../dropdown/OpenedDropdown/components/description/Description.styled.js"),require("../checkBox/CheckBox.styled.js"),require("../list-item/ListItem.js"),require("../dropdown/OpenedDropdown/components/menu/FreeFormMenu.styled.js"),require("../dropdown/OpenedDropdown/components/menu/MenuItem.js"),require("../dropdown/OpenedDropdown/components/menu/MenuList.styled.js"),require("../button/Button.js"),require("../dropdown/OpenedDropdown/components/multiSelect/MultiSelectDropdownBottomBar.styled.js"),require("../dropdown/OpenedDropdown/components/OpennedDropdown.styled.js"),require("../icon-button/IconButton.js"),require("../input/Input.js"),require("../dropdown/MenuItem/MenuItem.js");var a=require("../modals/styledModal.js"),s=require("../product-picker/ProductPickerModal.js"),d=require("../tag/Tag.js"),u=require("../tooltips/Tooltip.js"),c=require("../../assets/icons/gift_icon.svg.js"),p=require("../../assets/icons/percentage_icon.svg.js"),C=require("../../assets/icons/shipping_icon.svg.js"),E=require("../../assets/icons/triangle_error.svg.js"),T=require("../../assets/icons/warning.svg.js"),S=require("../product-picker-v2/modal.js");require("../product-picker-v2/type.js");var P=require("../variable-picker-v3/model.js"),O=require("../variable-picker-v3/VariablePicker.js"),I=require("./DiscountModal.styled.js"),_=require("./DiscountUtils.js"),v=require("./DynamicCoupon/DynamicCoupon.js"),b=require("./StaticCoupon/StaticCoupon.js");exports.DiscountModal=y=>{var D,m,N,x,R,U,A,h,j,f,g;const V=[{id:"0",label:"Amount",value:"amount",icon:i=>e.jsxRuntimeExports.jsx("span",Object.assign({style:{fontSize:20,color:i,lineHeight:.9}},{children:y.currency||""}))},{id:"1",label:"Percentage",value:"percentage",icon:i=>e.jsxRuntimeExports.jsx(p.default,{width:24,height:24,color:i})},{id:"2",label:"Buy X get Y",value:o.DISCOUNT_TYPES.BUY_X_GET_Y,icon:i=>e.jsxRuntimeExports.jsx(c.default,{width:24,height:24,color:i})},{id:"3",label:"Free Shipping",value:o.DISCOUNT_TYPES.FREE_SHIPPING,icon:i=>e.jsxRuntimeExports.jsx(C.default,{width:24,height:24,color:i})}],[F,k]=t.useState(),[L,q]=t.useState(),[Y,M]=t.useState(),[w,G]=t.useState(null!==(D=y.data)&&void 0!==D?D:"string"==typeof y.hideOption?{isStaticCoupon:"dynamic"===y.hideOption}:{isStaticCoupon:!0}),[B,X]=t.useState(!0),[Q,H]=t.useState(),[z,K]=t.useState((null===(m=y.data)||void 0===m?void 0:m.minAmount)?o.MIN_PURCHASE_REQUIREMENT.AMOUNT:(null===(N=y.data)||void 0===N?void 0:N.minQuantity)?o.MIN_PURCHASE_REQUIREMENT.QUANTITY:o.MIN_PURCHASE_REQUIREMENT.NA),[$,Z]=t.useState(o.DISCOUNT_APPLIES_TO.ENTIRE_ORDER),[J,W]=t.useState(o.OFFER_APPLIES_TO.SPECIFIC_PRODUCTS),[ee,ie]=t.useState(o.OFFER_APPLIES_TO.SPECIFIC_PRODUCTS),[te,oe]=t.useState(void 0),[ne,le]=t.useState(void 0),[re,ae]=t.useState(void 0),[se,de]=t.useState(void 0),[ue,ce]=t.useState(void 0),[pe,Ce]=t.useState(void 0),[Ee,Te]=t.useState(0),[Se,Pe]=t.useState(""),[Oe,Ie]=t.useState(V[0]),[_e,ve]=t.useState(!1),[be,ye]=t.useState(o.initialStaticCouponErrorState),[De,me]=t.useState(o.initialDynamicCouponErrorState),[Ne,xe]=t.useState(y.getDetailedDescription?o.COUPON_EXPIRATION.FIXED_EXPIRATION:o.COUPON_EXPIRATION.DYNAMIC_EXPIRATION),Re=[{value:o.DISCOUNT_TYPES.AMOUNT_OFF_ORDER,label:"Amount off on order",selected:Q===o.DISCOUNT_TYPES.AMOUNT_OFF_ORDER},{value:o.DISCOUNT_TYPES.AMOUNT_OFF_PRODUCTS,label:"Amount off on products",selected:Q===o.DISCOUNT_TYPES.AMOUNT_OFF_PRODUCTS},{value:o.DISCOUNT_TYPES.BUY_X_GET_Y,label:"Buy X Get Y FREE",selected:Q===o.DISCOUNT_TYPES.BUY_X_GET_Y},{value:o.DISCOUNT_TYPES.FREE_SHIPPING,label:"Free shipping",selected:Q===o.DISCOUNT_TYPES.FREE_SHIPPING}];t.useEffect((()=>{y.makeExpiryMandatory&&ve(!0)}),[y.makeExpiryMandatory]),t.useEffect((()=>{var e,i,t,n,l,r,a,s;let d;const{tempCouponData:u,discountType:c}=Ue();H(c);const p=(e,i)=>{Ie(u.valueType===o.DISCOUNT_VALUE_TYPES.FIXED_AMOUNT?V[e]:V[i])},C=(e,i)=>{Object.keys(e||{}).length&&i(e)};switch(((null==u?void 0:u.expireAfter)||(null==u?void 0:u.expireAt))&&(ve(!0),(null==u?void 0:u.expireAt)&&xe(o.COUPON_EXPIRATION.FIXED_EXPIRATION),(null==u?void 0:u.expireAfter)&&xe(o.COUPON_EXPIRATION.DYNAMIC_EXPIRATION)),c){case o.DISCOUNT_TYPES.AMOUNT_OFF_ORDER:p(0,1),Z(o.DISCOUNT_APPLIES_TO.ENTIRE_ORDER);break;case o.DISCOUNT_TYPES.AMOUNT_OFF_PRODUCTS:p(0,1),(null===(e=u.entitledCollectionIds)||void 0===e?void 0:e.length)?Z(o.DISCOUNT_APPLIES_TO.SPECIFIC_COLLECTIONS):(null===(i=u.entitledProductIds)||void 0===i?void 0:i.length)||(null===(t=u.productVariableConf)||void 0===t?void 0:t.entitledProductVariable)?(Z(o.DISCOUNT_APPLIES_TO.SPECIFIC_PRODUCTS),C(null===(n=u.productVariableConf)||void 0===n?void 0:n.entitledProductVariable,de)):Z(o.DISCOUNT_APPLIES_TO.ENTIRE_ORDER);break;case o.DISCOUNT_TYPES.BUY_X_GET_Y:Ie(V[2]),(null===(l=u.entitledCollectionIds)||void 0===l?void 0:l.length)?ie(o.OFFER_APPLIES_TO.SPECIFIC_COLLECTIONS):(ie(o.OFFER_APPLIES_TO.SPECIFIC_PRODUCTS),C(null===(r=u.productVariableConf)||void 0===r?void 0:r.entitledProductVariable,de)),(null===(a=u.prerequisiteCollectionIds)||void 0===a?void 0:a.length)?W(o.OFFER_APPLIES_TO.SPECIFIC_COLLECTIONS):(W(o.OFFER_APPLIES_TO.SPECIFIC_PRODUCTS),C(null===(s=u.productVariableConf)||void 0===s?void 0:s.prerequisiteProductVariable,ce));break;case o.DISCOUNT_TYPES.FREE_SHIPPING:Ie(V[3])}G(Object.assign({},u)),y.hideProbability||(d=je()),X(_.validateDiscountData(u,z,c,y.hideProbability||!1,d,!!u.isStaticCoupon,y.getDetailedDescription||!1)),y.hideProbability||je()}),[]),t.useEffect((()=>{let e;y.hideProbability||(e=je()),X(_.validateDiscountData(w,z,Q,y.hideProbability||!1,e,!!w.isStaticCoupon,y.getDetailedDescription||!1))}),[w,Ee,Q,z]),t.useEffect((()=>{var e,i,t,o,n,l,r;if(!y.newPickerConf&&((null===(e=y.products)||void 0===e?void 0:e.length)||(null===(i=y.collection)||void 0===i?void 0:i.length))){if(y.products&&(null===(t=y.products)||void 0===t?void 0:t.length)){if(null===(o=y.data)||void 0===o?void 0:o.entitledProductIds){const e=y.products.filter((e=>{var i,t;return null===(t=null===(i=y.data)||void 0===i?void 0:i.entitledProductIds)||void 0===t?void 0:t.includes(parseInt(e.id))}));le(e)}if(null===(n=y.data)||void 0===n?void 0:n.prerequisiteProductIds){const e=y.products.filter((e=>{var i,t;return null===(t=null===(i=y.data)||void 0===i?void 0:i.prerequisiteProductIds)||void 0===t?void 0:t.includes(parseInt(e.id))}));oe(e)}}if(y.collection&&y.collection.length){if(null===(l=y.data)||void 0===l?void 0:l.entitledCollectionIds){const e=y.collection.filter((e=>{var i,t;return null===(t=null===(i=y.data)||void 0===i?void 0:i.entitledCollectionIds)||void 0===t?void 0:t.includes(parseInt(e.id))}));Ce(e)}if(null===(r=y.data)||void 0===r?void 0:r.prerequisiteCollectionIds){const e=y.collection.filter((e=>{var i,t;return null===(t=null===(i=y.data)||void 0===i?void 0:i.prerequisiteCollectionIds)||void 0===t?void 0:t.includes(parseInt(e.id))}));ae(e)}}}}),[y.products,y.collection]),t.useEffect((()=>{var e,i,t,o,n,l,r,a;(null===(i=null===(e=y.data)||void 0===e?void 0:e.productsConf)||void 0===i?void 0:i.entitledProducts)&&le(y.data.productsConf.entitledProducts),(null===(o=null===(t=y.data)||void 0===t?void 0:t.productsConf)||void 0===o?void 0:o.prerequisiteProducts)&&oe(y.data.productsConf.prerequisiteProducts),(null===(l=null===(n=y.data)||void 0===n?void 0:n.collectionsConf)||void 0===l?void 0:l.entitledCollections)&&Ce(y.data.collectionsConf.entitledCollections),(null===(a=null===(r=y.data)||void 0===r?void 0:r.collectionsConf)||void 0===a?void 0:a.prerequisiteCollections)&&ae(y.data.collectionsConf.prerequisiteCollections)}),[null===(x=y.data)||void 0===x?void 0:x.productsConf,null===(R=y.data)||void 0===R?void 0:R.collectionsConf]),t.useEffect((()=>{if(!ne)return;if(y.newPickerConf){const e=[];return Object.values(ne).forEach((i=>{i.products&&Object.keys(i.products).forEach((i=>{e.push(parseInt(i))}))})),void G(Object.assign(Object.assign({},w),{entitledProductIds:e}))}const e=ne.map((e=>parseInt(e.id)));G(Object.assign(Object.assign({},w),{entitledProductIds:e}))}),[ne]),t.useEffect((()=>{if(!te)return;if(y.newPickerConf){const e=[];return Object.values(te).forEach((i=>{i.products&&Object.keys(i.products).forEach((i=>{e.push(parseInt(i))}))})),void G(Object.assign(Object.assign({},w),{prerequisiteProductIds:e}))}const e=te.map((e=>parseInt(e.id)));G(Object.assign(Object.assign({},w),{prerequisiteProductIds:e}))}),[te]),t.useEffect((()=>{if(!pe)return;if(y.newPickerConf){(null==pe?void 0:pe.isCustom)&&delete pe.isCustom;const e=Object.keys(pe).map((e=>parseInt(e)));return void G(Object.assign(Object.assign({},w),{entitledCollectionIds:e}))}const e=pe.map((e=>parseInt(e.id)));G(Object.assign(Object.assign({},w),{entitledCollectionIds:e}))}),[pe]),t.useEffect((()=>{if(!re)return;if(y.newPickerConf){(null==re?void 0:re.isCustom)&&delete re.isCustom;const e=Object.keys(re).map((e=>parseInt(e)));return void G(Object.assign(Object.assign({},w),{prerequisiteCollectionIds:e}))}const e=re.map((e=>parseInt(e.id)));G(Object.assign(Object.assign({},w),{prerequisiteCollectionIds:e}))}),[re]);const Ue=()=>{var e,i,t,n;let l,r=w;return w.isStaticCoupon?w.isStaticCoupon&&y.getDetailedDescription&&(w.targetType===o.DISCOUNT_TARGET_TYPES.SHIPPING_LINE?l=o.DISCOUNT_TYPES.FREE_SHIPPING:w.targetType===o.DISCOUNT_TARGET_TYPES.LINE_ITEM?l=w.targetSelection===o.DISCOUNT_TARGET_SELECTION.ENTITLED?(null===(t=w.prerequisiteProductIds)||void 0===t?void 0:t.length)||(null===(n=w.prerequisiteCollectionIds)||void 0===n?void 0:n.length)||w.prerequisiteQuantity||w.entitledQuantity?o.DISCOUNT_TYPES.BUY_X_GET_Y:o.DISCOUNT_TYPES.AMOUNT_OFF_PRODUCTS:o.DISCOUNT_TYPES.AMOUNT_OFF_ORDER:(r=Object.assign(Object.assign({},r),{targetType:o.DISCOUNT_TARGET_TYPES.LINE_ITEM,targetSelection:o.DISCOUNT_TARGET_SELECTION.ALL,valueType:o.DISCOUNT_VALUE_TYPES.FIXED_AMOUNT}),l=o.DISCOUNT_TYPES.AMOUNT_OFF_ORDER)):w.targetType===o.DISCOUNT_TARGET_TYPES.SHIPPING_LINE?l=o.DISCOUNT_TYPES.FREE_SHIPPING:w.targetType===o.DISCOUNT_TARGET_TYPES.LINE_ITEM?l=w.targetSelection===o.DISCOUNT_TARGET_SELECTION.ENTITLED?(null===(e=w.prerequisiteProductIds)||void 0===e?void 0:e.length)||(null===(i=w.prerequisiteCollectionIds)||void 0===i?void 0:i.length)||w.prerequisiteQuantity||w.entitledQuantity?o.DISCOUNT_TYPES.BUY_X_GET_Y:o.DISCOUNT_TYPES.AMOUNT_OFF_PRODUCTS:o.DISCOUNT_TYPES.AMOUNT_OFF_ORDER:(r=Object.assign(Object.assign({},r),{targetType:o.DISCOUNT_TARGET_TYPES.LINE_ITEM,targetSelection:o.DISCOUNT_TARGET_SELECTION.ALL,valueType:o.DISCOUNT_VALUE_TYPES.FIXED_AMOUNT}),l=o.DISCOUNT_TYPES.AMOUNT_OFF_ORDER),{discountType:l,tempCouponData:r}},Ae=()=>{ye(o.initialStaticCouponErrorState),me(o.initialDynamicCouponErrorState)},he=e=>{var i;const t={invalidDiscountCode:"Please add Discount Code",invalidCouponTitle:"Please add Discount Coupon Title",invalidCouponDescription:"Please add Coupon Description",inValidProbability:e.inValidProbability&&(null!==(i=w.probability)&&void 0!==i?i:-1)>1?"Probability should not exceed 1":w.isStaticCoupon?"Please add Probability":"Probability should be greater than 0",inValidDiscountAmount:"Please add Discount Amount",inValidMinimumAmount:"Specify minimum amount required",inValidMinimumQuantity:"Specify minimum items required",inValidCouponExpiry:"Please add Coupon Expiry",inValidProductSelection:"Please specify the products",inValidProductVariableSelection:"Please specify the product variables",inValidCollectionSelection:"Please specify the collections",inValidBuyXValue:"Please specify buy product quantity",inValidGetYValue:"Please specify get product quantity",inValidBuyXProductSelection:"Please specify the products",inValidBuyXCollectionSelection:"Please specify the collections",inValidGetYProductSelection:"Please specify the products",inValidGetYCollectionSelection:"Please specify the collections",inValidBuyXProductVariableSelection:"Please specify the product variables",inValidGetYProductVariableSelection:"Please specify the product variables"};let o="";Object.keys(e).forEach((i=>{e[i]&&(o=t[i])}));const n=Object.values(e).filter(Boolean).length;return n>0&&(Pe(n>1?"Please add discount details":o),!0)},je=()=>{if(!y.quadrant||!y.probability)return;const e=[...y.probability];let i=[];e.length>=y.quadrant&&e.splice(y.quadrant-1,1),i=e;const t=i.reduce(((e,i)=>e+i),0)+(w.probability||0);return Te(parseFloat(t.toFixed(4))),parseFloat(t.toFixed(4))},fe=e=>{var i,t,n,l,r,a,s,d,u,c,p,C,E,T,S,P;const O=e.value;H(O),oe([]),le([]),ae([]),Ce([]),O===o.DISCOUNT_TYPES.FREE_SHIPPING?G({value:100,targetSelection:o.DISCOUNT_TARGET_SELECTION.ALL,targetType:o.DISCOUNT_TARGET_TYPES.SHIPPING_LINE,valueType:o.DISCOUNT_VALUE_TYPES.PERCENTAGE,quadrant:w.quadrant,isStaticCoupon:!!y.getDetailedDescription,title:w.title,couponCode:y.getDetailedDescription?w.couponCode:void 0,expireAt:null!==(i=w.expireAt)&&void 0!==i?i:void 0,expireAfter:null!==(t=w.expireAfter)&&void 0!==t?t:void 0,probability:w.probability,minQuantity:null!==(n=w.minQuantity)&&void 0!==n?n:void 0,minAmount:null!==(l=w.minAmount)&&void 0!==l?l:void 0}):O===o.DISCOUNT_TYPES.BUY_X_GET_Y?G({value:100,targetSelection:o.DISCOUNT_TARGET_SELECTION.ENTITLED,targetType:o.DISCOUNT_TARGET_TYPES.LINE_ITEM,valueType:o.DISCOUNT_VALUE_TYPES.PERCENTAGE,quadrant:w.quadrant,isStaticCoupon:!!y.getDetailedDescription,title:w.title,couponCode:y.getDetailedDescription?w.couponCode:void 0,expireAt:null!==(r=w.expireAt)&&void 0!==r?r:void 0,expireAfter:null!==(a=w.expireAfter)&&void 0!==a?a:void 0,probability:w.probability,minQuantity:void 0,minAmount:void 0}):O===o.DISCOUNT_TYPES.AMOUNT_OFF_ORDER?G({targetSelection:o.DISCOUNT_TARGET_SELECTION.ALL,targetType:o.DISCOUNT_TARGET_TYPES.LINE_ITEM,valueType:null!==(s=w.valueType)&&void 0!==s?s:o.DISCOUNT_VALUE_TYPES.FIXED_AMOUNT,quadrant:w.quadrant,isStaticCoupon:!!y.getDetailedDescription,title:w.title,couponCode:y.getDetailedDescription?w.couponCode:void 0,expireAt:null!==(d=w.expireAt)&&void 0!==d?d:void 0,expireAfter:null!==(u=w.expireAfter)&&void 0!==u?u:void 0,probability:w.probability,value:w.value,minQuantity:null!==(c=w.minQuantity)&&void 0!==c?c:void 0,minAmount:null!==(p=w.minAmount)&&void 0!==p?p:void 0}):O===o.DISCOUNT_TYPES.AMOUNT_OFF_PRODUCTS&&G({targetSelection:o.DISCOUNT_TARGET_SELECTION.ENTITLED,targetType:o.DISCOUNT_TARGET_TYPES.LINE_ITEM,valueType:null!==(C=w.valueType)&&void 0!==C?C:o.DISCOUNT_VALUE_TYPES.FIXED_AMOUNT,quadrant:w.quadrant,isStaticCoupon:!!y.getDetailedDescription,title:w.title,couponCode:y.getDetailedDescription?w.couponCode:void 0,expireAt:null!==(E=w.expireAt)&&void 0!==E?E:void 0,expireAfter:null!==(T=w.expireAfter)&&void 0!==T?T:void 0,probability:w.probability,value:w.value,minQuantity:null!==(S=w.minQuantity)&&void 0!==S?S:void 0,minAmount:null!==(P=w.minAmount)&&void 0!==P?P:void 0})},ge=i=>i&&e.jsxRuntimeExports.jsx(d.Tag,{theme:"light",tagText:i,type:"negative",LeadingIcon:T.default});return e.jsxRuntimeExports.jsxs(a.StyledModal,Object.assign({width:(Y||F)&&y.newPickerConf?"25px":"640px",open:y.isOpen,hideCrossButton:!!L,headingTitle:F?"Select Products":y.title,headingSubtitle:F?void 0:y.subTitle,footerLeftCustomElement:Se?ge(Se):y.errorMsg?ge(y.errorMsg):!y.quadrant||y.hideProbability?e.jsxRuntimeExports.jsx(e.jsxRuntimeExports.Fragment,{}):Ee<=1?e.jsxRuntimeExports.jsx(d.Tag,{theme:"light",tagText:`Current probability sum: ${Ee}`,type:"white"}):e.jsxRuntimeExports.jsx(u.Tooltip,Object.assign({body:"Probability sum should not exceed 1",placement:"top"},{children:e.jsxRuntimeExports.jsx("div",{children:e.jsxRuntimeExports.jsx(d.Tag,{style:{cursor:"pointer"},theme:"light",tagText:`Current probability sum: ${Ee}`,type:"negative",LeadingIcon:E.default})})})),headerRightCustomElement:y.allowStaticCoupon||F?void 0:e.jsxRuntimeExports.jsx(n.Dropdown,{options:Re,width:"200px",placement:"bottom-start",size:"small",onSelect:e=>{fe(e)}}),onClose:y.onClose,footerContainerStyle:{borderTop:`1px solid ${r.DEFAULT_THEME.colorsV2.stroke.primary}`},primaryButton:F?{buttonType:"primary",onClick:()=>{k(void 0)},buttonText:"Add"}:Y?{buttonType:"primary",onClick:()=>{M(void 0)},buttonText:"Add"}:{buttonType:"primary",buttonText:"Create discount code",isLoading:null!==(U=y.loading)&&void 0!==U&&U,onClick:()=>{var e,i,t,n,l,r,a,s,d,u;if(Ae(),w.isStaticCoupon&&!y.getDetailedDescription){const{isStaticCoupon:e,couponCode:i,title:t,description:o,quadrant:n,probability:l}=w,r={invalidDiscountCode:!i,invalidCouponTitle:!t,invalidCouponDescription:!o,inValidProbability:!y.hideProbability&&(null!=l?l:-1)<0||(null!=l?l:0)>1||Number.isNaN(null!=l?l:0)};if(he(r))return void ye(r);if(B||Ee>1)return void Pe(!y.hideProbability&&Ee>1?"Probability sum should not exceed 1":"Invalid coupon details");y.onSaveClicked({quadrant:n,couponCode:i,description:o,isStaticCoupon:e,probability:l,title:w.title})}else if(w.isStaticCoupon&&y.getDetailedDescription){const{isStaticCoupon:r,couponCode:a,title:s,quadrant:d,probability:u}=w,c={invalidDiscountCode:!a,invalidCouponTitle:!s,invalidCouponDescription:!1,inValidProbability:!y.hideProbability&&(null!=u?u:-1)<0||(null!=u?u:0)>1||Number.isNaN(null!=u?u:0)};if(he(c))return void ye(c);const p={invalidCouponTitle:!w.title,inValidProbability:!y.hideProbability&&(null!==(e=w.probability)&&void 0!==e?e:-1)<=0||(null!==(i=w.probability)&&void 0!==i?i:-1)>1||Number.isNaN(null!==(t=w.probability)&&void 0!==t?t:-1),inValidDiscountAmount:!w.value,inValidMinimumQuantity:!1,inValidMinimumAmount:!1,inValidCouponExpiry:!1,inValidProductSelection:!1,inValidProductVariableSelection:!1,inValidCollectionSelection:!1,inValidBuyXValue:!1,inValidGetYValue:!1,inValidBuyXProductSelection:!1,inValidGetYProductSelection:!1,inValidBuyXCollectionSelection:!1,inValidGetYCollectionSelection:!1,inValidBuyXProductVariableSelection:!1,inValidGetYProductVariableSelection:!1};if(Q!==o.DISCOUNT_TYPES.BUY_X_GET_Y&&z!==o.MIN_PURCHASE_REQUIREMENT.NA){const{minAmount:e,minQuantity:i}=w;p.inValidMinimumAmount=z===o.MIN_PURCHASE_REQUIREMENT.AMOUNT&&!e,p.inValidMinimumQuantity=z===o.MIN_PURCHASE_REQUIREMENT.QUANTITY&&!i}if(_e&&(p.inValidCouponExpiry=!w.expireAt&&!w.expireAfter),Q!==o.DISCOUNT_TYPES.AMOUNT_OFF_ORDER&&Q!==o.DISCOUNT_TYPES.AMOUNT_OFF_PRODUCTS||($!==o.DISCOUNT_APPLIES_TO.SPECIFIC_PRODUCTS||!ne||Object.keys(ne).length||se||(p.inValidProductSelection=!0,p.inValidProductVariableSelection=!0),$===o.DISCOUNT_APPLIES_TO.SPECIFIC_COLLECTIONS&&pe&&!Object.keys(pe).length&&(p.inValidCollectionSelection=!0)),Q===o.DISCOUNT_TYPES.BUY_X_GET_Y&&(w.prerequisiteQuantity||(p.inValidBuyXValue=!0),w.entitledQuantity||(p.inValidGetYValue=!0),J!==o.OFFER_APPLIES_TO.SPECIFIC_PRODUCTS||!te||Object.keys(te).length||ue||(p.inValidBuyXProductSelection=!0,p.inValidBuyXProductVariableSelection=!0),J===o.OFFER_APPLIES_TO.SPECIFIC_COLLECTIONS&&re&&!Object.keys(re).length&&(p.inValidBuyXCollectionSelection=!0),ee!==o.OFFER_APPLIES_TO.SPECIFIC_PRODUCTS||!ne||Object.keys(ne).length||se||(p.inValidGetYProductSelection=!0,p.inValidGetYProductVariableSelection=!0),ee===o.OFFER_APPLIES_TO.SPECIFIC_COLLECTIONS&&pe&&!Object.keys(pe).length&&(p.inValidGetYCollectionSelection=!0)),he(p))return void me(p);if(B||Ee>1)return void Pe(!y.hideProbability&&Ee>1?"Probability sum should not exceed 1":"Invalid coupon details");y.onSaveClicked(Object.assign(Object.assign({},w),{couponCode:a,isStaticCoupon:r,quadrant:d,description:_.descriptionBuilder(w,y.currency,null!==(n=y.products)&&void 0!==n?n:[],null!==(l=y.collection)&&void 0!==l?l:[]),productsConf:{entitledProducts:null!=ne?ne:[],prerequisiteProducts:null!=te?te:[]},collectionsConf:{entitledCollections:null!=pe?pe:[],prerequisiteCollections:null!=re?re:[]},productVariableConf:{entitledProductVariable:null!=se?se:{},prerequisiteProductVariable:null!=ue?ue:{}}}))}else{const e={invalidCouponTitle:!w.title,inValidProbability:!y.hideProbability&&(null!==(r=w.probability)&&void 0!==r?r:-1)<=0||(null!==(a=w.probability)&&void 0!==a?a:-1)>1||Number.isNaN(null!==(s=w.probability)&&void 0!==s?s:-1),inValidDiscountAmount:!w.value,inValidMinimumQuantity:!1,inValidMinimumAmount:!1,inValidCouponExpiry:!1,inValidProductSelection:!1,inValidProductVariableSelection:!1,inValidCollectionSelection:!1,inValidBuyXValue:!1,inValidGetYValue:!1,inValidBuyXProductSelection:!1,inValidGetYProductSelection:!1,inValidBuyXCollectionSelection:!1,inValidGetYCollectionSelection:!1,inValidBuyXProductVariableSelection:!1,inValidGetYProductVariableSelection:!1};if(Q!==o.DISCOUNT_TYPES.BUY_X_GET_Y&&z!==o.MIN_PURCHASE_REQUIREMENT.NA){const{minAmount:i,minQuantity:t}=w;e.inValidMinimumAmount=z===o.MIN_PURCHASE_REQUIREMENT.AMOUNT&&!i,e.inValidMinimumQuantity=z===o.MIN_PURCHASE_REQUIREMENT.QUANTITY&&!t}if(_e&&(e.inValidCouponExpiry=!w.expireAt&&!w.expireAfter),Q!==o.DISCOUNT_TYPES.AMOUNT_OFF_ORDER&&Q!==o.DISCOUNT_TYPES.AMOUNT_OFF_PRODUCTS||($!==o.DISCOUNT_APPLIES_TO.SPECIFIC_PRODUCTS||!ne||Object.keys(ne).length||se||(e.inValidProductSelection=!0,e.inValidProductVariableSelection=!0),$===o.DISCOUNT_APPLIES_TO.SPECIFIC_COLLECTIONS&&pe&&!Object.keys(pe).length&&(e.inValidCollectionSelection=!0)),Q===o.DISCOUNT_TYPES.BUY_X_GET_Y&&(w.prerequisiteQuantity||(e.inValidBuyXValue=!0),w.entitledQuantity||(e.inValidGetYValue=!0),J!==o.OFFER_APPLIES_TO.SPECIFIC_PRODUCTS||!te||Object.keys(te).length||ue||(e.inValidBuyXProductSelection=!0,e.inValidBuyXProductVariableSelection=!0),J===o.OFFER_APPLIES_TO.SPECIFIC_COLLECTIONS&&re&&!Object.keys(re).length&&(e.inValidBuyXCollectionSelection=!0),ee!==o.OFFER_APPLIES_TO.SPECIFIC_PRODUCTS||!ne||Object.keys(ne).length||se||(e.inValidGetYProductSelection=!0,e.inValidGetYProductVariableSelection=!0),ee===o.OFFER_APPLIES_TO.SPECIFIC_COLLECTIONS&&pe&&!Object.keys(pe).length&&(e.inValidGetYCollectionSelection=!0)),he(e))return void me(e);if(B||Ee>1)return void Pe(!y.hideProbability&&Ee>1?"Probability sum should not exceed 1":"Invalid coupon details");y.onSaveClicked(Object.assign(Object.assign({},w),{isStaticCoupon:w.isStaticCoupon,description:_.descriptionBuilder(w,y.currency,null!==(d=y.products)&&void 0!==d?d:[],null!==(u=y.collection)&&void 0!==u?u:[]),productsConf:{entitledProducts:null!=ne?ne:[],prerequisiteProducts:null!=te?te:[]},collectionsConf:{entitledCollections:null!=pe?pe:[],prerequisiteCollections:null!=re?re:[]},productVariableConf:{entitledProductVariable:null!=se?se:{},prerequisiteProductVariable:null!=ue?ue:{}}}))}}},secondaryButton:F?{buttonType:"tertiaryGray",onClick:()=>{k(void 0)},buttonText:"Back"}:Y?{buttonType:"tertiaryGray",onClick:()=>{M(void 0)},buttonText:"Back"}:{buttonType:"tertiaryGray",onClick:y.onClose,buttonText:"Cancel"}},{children:[!F&&!Y&&e.jsxRuntimeExports.jsxs(I.StyledDiscountDialogueContainer,{children:[y.allowStaticCoupon&&!F&&!y.hideOption&&e.jsxRuntimeExports.jsxs(I.CouponTypeContainerStyled,Object.assign({selectedDiv:w.isStaticCoupon?1:2},{children:["static"===y.hideOption?e.jsxRuntimeExports.jsx(e.jsxRuntimeExports.Fragment,{}):e.jsxRuntimeExports.jsxs("div",Object.assign({className:"coupon-type__container",onClick:()=>{w.isStaticCoupon||(G({isStaticCoupon:!0,quadrant:w.quadrant}),Pe(""),Ae())}},{children:[e.jsxRuntimeExports.jsx(l.TitleSmall,Object.assign({style:{marginBottom:"4px",color:w.isStaticCoupon?r.DEFAULT_THEME.colorsV2.content.brand:void 0}},{children:"Static Code"})),e.jsxRuntimeExports.jsx(l.BodyCaption,Object.assign({style:w.isStaticCoupon?{color:r.DEFAULT_THEME.colorsV2.content.brand}:{}},{children:"A uniform code provided manually, used for providing the same discount to all customers."}))]})),"dynamic"===y.hideOption?e.jsxRuntimeExports.jsx(e.jsxRuntimeExports.Fragment,{}):e.jsxRuntimeExports.jsxs("div",Object.assign({className:"coupon-type__container",onClick:()=>{var i;w.isStaticCoupon&&(H(o.DISCOUNT_TYPES.AMOUNT_OFF_ORDER),G({isStaticCoupon:!1,quadrant:w.quadrant,targetType:o.DISCOUNT_TARGET_TYPES.LINE_ITEM,targetSelection:o.DISCOUNT_TARGET_SELECTION.ALL,valueType:o.DISCOUNT_VALUE_TYPES.FIXED_AMOUNT}),Pe(""),Ae(),Ie({id:"0",label:"Amount",value:"amount",icon:i=>e.jsxRuntimeExports.jsx("span",Object.assign({style:{fontSize:20,color:i}},{children:y.currency||""}))}),ve(null!==(i=y.makeExpiryMandatory)&&void 0!==i&&i),K(o.MIN_PURCHASE_REQUIREMENT.NA))}},{children:[e.jsxRuntimeExports.jsx(l.TitleSmall,Object.assign({style:{marginBottom:"4px",color:w.isStaticCoupon?void 0:r.DEFAULT_THEME.colorsV2.content.brand}},{children:"Dynamic Code"})),e.jsxRuntimeExports.jsx(l.BodyCaption,Object.assign({style:w.isStaticCoupon?{}:{color:r.DEFAULT_THEME.colorsV2.content.brand}},{children:"Code will be unique for all customers, with the first 5 letters of the customer's name, followed by 10 random characters."}))]}))]})),!y.getDetailedDescription&&e.jsxRuntimeExports.jsx(l.TitleRegular,Object.assign({style:{marginTop:"24px"}},{children:"Coupon Details"}))," ",w.isStaticCoupon&&!F&&!y.getDetailedDescription&&e.jsxRuntimeExports.jsx(b.default,{discountData:w,setDiscountData:G,hideProbability:y.hideProbability||!1,discountAdminUrl:y.discountAdminUrl,staticDiscountValidationError:be,currency:y.currency}),w.isStaticCoupon&&!F&&y.getDetailedDescription&&e.jsxRuntimeExports.jsx(b.default,{discountData:w,setDiscountData:G,hideProbability:y.hideProbability||!1,discountAdminUrl:y.discountAdminUrl,staticDiscountValidationError:be,currency:y.currency,getDetailedDescription:!0,selectedCouponType:Q,setSelectedCouponType:H,selectedMinimumRequirement:z,setSelectedMinimumRequirement:K,discountCouponAppliesTo:$,offerAppliesToBuy:J,offerAppliesToGet:ee,setDiscountCouponAppliesTo:Z,setOfferAppliesToBuy:W,setOfferAppliesToGet:ie,hideExpiration:y.hideExpiration||!1,onChangeCouponType:fe,entitledProducts:null!=ne?ne:[],prerequisiteProducts:null!=te?te:[],setEntitledProducts:le,setPrerequisiteProducts:oe,entitledCollections:null!=pe?pe:[],prerequisiteCollections:null!=re?re:[],setEntitledCollections:Ce,setPrerequisiteCollections:ae,setIsProductPickerOpen:k,setIsProductVariablePickerOpen:q,setIsCollectionPickerOpen:M,productPickerOpen:F,productVariablePickerOpen:L,collectionPickerOpen:Y,useNewPicker:!!y.newPickerConf,selectedDiscountDetails:Oe,setSelectedDiscountDetails:Ie,isProductVariableSupported:y.isProductVariableSupported,entitledProductVariable:se,setEntitledProductVariable:de,preRequisiteProductVariable:ue,setPreRequisiteProductVariable:ce,productVariableList:y.productVariableList,isAddExpirationChecked:_e,setIsAddExpirationChecked:ve,dynamicDiscountValidationError:De,setDynamicDiscountValidationError:me,setValidationErrorMessage:Pe,resetValidationErrors:Ae,discountDetailsOptions:V,selectedExpiration:Ne,setSelectedExpiration:xe,makeExpiryMandatory:!!y.makeExpiryMandatory}),!w.isStaticCoupon&&!F&&!Y&&e.jsxRuntimeExports.jsx(v.default,{currency:y.currency,entitledProducts:null!=ne?ne:[],prerequisiteProducts:null!=te?te:[],setEntitledProducts:le,setPrerequisiteProducts:oe,discountData:w,productPickerOpen:F,productVariablePickerOpen:L,setIsProductPickerOpen:k,setIsProductVariablePickerOpen:q,setDiscountData:G,selectedCouponType:Q,setSelectedCouponType:H,selectedMinimumRequirement:z,setSelectedMinimumRequirement:K,discountCouponAppliesTo:$,offerAppliesToBuy:J,offerAppliesToGet:ee,setDiscountCouponAppliesTo:Z,setOfferAppliesToBuy:W,setOfferAppliesToGet:ie,hideProbability:y.hideProbability||!1,hideExpiration:y.hideExpiration||!1,allowStaticCoupon:y.allowStaticCoupon,onChangeCouponType:fe,collectionPickerOpen:Y,entitledCollections:null!=pe?pe:[],prerequisiteCollections:null!=re?re:[],setIsCollectionPickerOpen:M,setEntitledCollections:Ce,setPrerequisiteCollections:ae,useNewPicker:!!y.newPickerConf,setSelectedDiscountDetails:Ie,selectedDiscountDetails:Oe,isProductVariableSupported:y.isProductVariableSupported,entitledProductVariable:se,setEntitledProductVariable:de,preRequisiteProductVariable:ue,setPreRequisiteProductVariable:ce,productVariableList:y.productVariableList,isAddExpirationChecked:_e,setIsAddExpirationChecked:ve,dynamicDiscountValidationError:De,setDynamicDiscountValidationError:me,setValidationErrorMessage:Pe,resetValidationErrors:Ae,discountDetailsOptions:V,selectedExpiration:Ne,setSelectedExpiration:xe,makeExpiryMandatory:!!y.makeExpiryMandatory})]}),!!F&&e.jsxRuntimeExports.jsxs(e.jsxRuntimeExports.Fragment,{children:[!y.newPickerConf&&e.jsxRuntimeExports.jsx("div",Object.assign({style:{padding:"12px 0"}},{children:e.jsxRuntimeExports.jsx(s.ProductPickerContent,{show:!0,onSave:()=>{},products:null!==(A=y.products)&&void 0!==A?A:[],title:"Select Products",onClose:()=>{k(void 0)},selectedProducts:null!==(h=F===v.DISCOUNT_PRODUCTS.ENTITLED?ne:te)&&void 0!==h?h:[],setSelectedProducts:F===v.DISCOUNT_PRODUCTS.ENTITLED?le:oe,onSearchKeyChange:y.onProductSearch})})),y.newPickerConf&&e.jsxRuntimeExports.jsx(S.ProductPickerModal,{visible:!0,onClose:()=>k(void 0),collectionFetcher:(e,i,t)=>{var o;return(null===(o=y.newPickerConf)||void 0===o?void 0:o.fetchCollections)?y.newPickerConf.fetchCollections(e,i,!1,t):null},productFetcher:(e,i,t,o,n)=>{var l;return(null===(l=y.newPickerConf)||void 0===l?void 0:l.fetchProducts)?y.newPickerConf.fetchProducts(e,i,o,n,!1,t):null},selectedItems:F===v.DISCOUNT_PRODUCTS.ENTITLED?ne:te,onAdd:e=>{F===v.DISCOUNT_PRODUCTS.ENTITLED?le(e):oe(e),k(void 0)},zIndex:200,storeId:y.newPickerConf.storeId,appType:y.newPickerConf.appType||i.ApplicationType.BIK,searchInCollectionFetcher:(e,i,t,o)=>{var n;return(null===(n=y.newPickerConf)||void 0===n?void 0:n.searchInCollection)?y.newPickerConf.searchInCollection(e,i,t,!1,o):null},customCollectionRestriction:!1,searchFetcher:(e,i,t)=>{var o;return(null===(o=y.newPickerConf)||void 0===o?void 0:o.searchProducts)?y.newPickerConf.searchProducts(e,i,!1,t):null},hideCollectionCheckbox:!0,hideVariantCheckbox:!0,selectProductsFromCustomCollection:!0,hideSelectionCount:!0})]}),!!Y&&e.jsxRuntimeExports.jsx("div",Object.assign({style:{padding:"12px 0"}},{children:e.jsxRuntimeExports.jsxs(e.jsxRuntimeExports.Fragment,{children:[y.newPickerConf&&e.jsxRuntimeExports.jsx(S.ProductPickerModal,{visible:!0,onClose:()=>M(void 0),collectionFetcher:y.newPickerConf.fetchCollections,productFetcher:y.newPickerConf.fetchProducts,selectedItems:Y===v.DISCOUNT_PRODUCTS.ENTITLED?pe:re,onAdd:e=>{Object.values(e).forEach((e=>{e.products&&delete e.products})),Y===v.DISCOUNT_PRODUCTS.ENTITLED?Ce(e):ae(e),M(void 0)},customCollectionRestriction:!1,zIndex:200,storeId:y.newPickerConf.storeId,appType:y.newPickerConf.appType||i.ApplicationType.BIK,searchInCollectionFetcher:y.newPickerConf.searchInCollection,searchFetcher:y.newPickerConf.searchProducts,hideProductCheckbox:!0,hideVariantCheckbox:!0,title:"Select Collections",hideGlobalSearch:!0,hideSelectionCount:!0}),!y.newPickerConf&&e.jsxRuntimeExports.jsx(s.ProductPickerContent,{show:!0,onSave:()=>{},products:null!==(j=y.collection)&&void 0!==j?j:[],title:"Select Products",onClose:()=>{M(void 0)},selectedProducts:null!==(f=Y===v.DISCOUNT_PRODUCTS.ENTITLED?pe:re)&&void 0!==f?f:[],setSelectedProducts:Y===v.DISCOUNT_PRODUCTS.ENTITLED?Ce:ae,onSearchKeyChange:y.onCollectionSearch,searchPlaceholder:"Search collections..."})]})})),L&&e.jsxRuntimeExports.jsx(I.VariablePickerContainer,{children:e.jsxRuntimeExports.jsx("div",Object.assign({style:{width:"50%",height:"100%",marginLeft:"50%"}},{children:e.jsxRuntimeExports.jsx(O.VariablePicker,{type:P.PickerType.EMBEDDED,data:null!==(g=y.productVariableList)&&void 0!==g?g:[],showHeader:!0,onSelect:e=>{if(L===v.DISCOUNT_PRODUCTS.ENTITLED){const{displayName:i,actualValue:t,isAvailable:o}=e;de({displayName:i,actualValue:t,isAvailable:o}),q(void 0)}if(L===v.DISCOUNT_PRODUCTS.PREREQUISITE){const{displayName:i,actualValue:t,isAvailable:o}=e;ce({displayName:i,actualValue:t,isAvailable:o}),q(void 0)}},onClose:()=>{q(void 0)}})}))})]}))};
@@ -1,4 +1,4 @@
1
1
  import { DISCOUNT_TYPES, ICouponData, MIN_PURCHASE_REQUIREMENT } from "./type";
2
2
  import { Collection, Product } from '../product-picker/type';
3
- export declare const validateDiscountData: (couponData: ICouponData, selectedMinimumRequirement: MIN_PURCHASE_REQUIREMENT | undefined, selectedCouponType: DISCOUNT_TYPES | undefined, hideProbability: boolean, currentProbability: number, isStatic: boolean) => boolean;
3
+ export declare const validateDiscountData: (couponData: ICouponData, selectedMinimumRequirement: MIN_PURCHASE_REQUIREMENT | undefined, selectedCouponType: DISCOUNT_TYPES | undefined, hideProbability: boolean, currentProbability: number, isStatic: boolean, getDetailedDescription: boolean) => boolean;
4
4
  export declare const descriptionBuilder: (data: ICouponData, currencySymbol: string, products: Product[], collections: Collection[]) => string | undefined;
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("./type.js"),t=require("../../utils/DateUtils.js");function i(e,t){const i=[];return t.forEach((t=>{e.find((e=>e.toString()===t.id))&&i.push(t.name)})),i}exports.descriptionBuilder=(r,n,l,u)=>{var o,T,E;return(null==r?void 0:r.isStaticCoupon)&&(null==r?void 0:r.description)?r.description:r.targetType===e.DISCOUNT_TARGET_TYPES.LINE_ITEM&&r.targetSelection===e.DISCOUNT_TARGET_SELECTION.ALL?`${r.valueType===e.DISCOUNT_VALUE_TYPES.FIXED_AMOUNT?n:""}${(null!==(o=r.value)&&void 0!==o?o:0).toString()}${r.valueType===e.DISCOUNT_VALUE_TYPES.PERCENTAGE?"% off":" off"} on all products\n ${r.minAmount?`| Minimum purchase of ${n}${r.minAmount}`:""} ${r.minQuantity?`| Buy ${r.minQuantity} products`:""} | One use per customer${r.expireAfter?` | Expires in ${r.expireAfter} day(s)`:r.expireAt?` | Expires at ${t.default.getStringFromDate(r.expireAt,"dd MMM yyyy")}`:""}`.replace(/\s\s+/g," ").trim():r.targetType===e.DISCOUNT_TARGET_TYPES.SHIPPING_LINE?`\n Free shipping on your order ${r.minAmount?`| Minimum purchase of ${n}${r.minAmount}`:""} ${r.minQuantity?`| Buy ${r.minQuantity} products`:""} | One use per customer${r.expireAfter?` | Expires in ${r.expireAfter} day(s)`:r.expireAt?` | Expires at ${t.default.getStringFromDate(r.expireAt,"dd MMM yyyy")}`:""}`.replace(/\s\s+/g," ").trim():r.targetSelection===e.DISCOUNT_TARGET_SELECTION.ENTITLED?(null===(T=r.prerequisiteProductIds)||void 0===T?void 0:T.length)||(null===(E=r.prerequisiteCollectionIds)||void 0===E?void 0:E.length)||r.entitledQuantity||r.prerequisiteQuantity?`${function(e,t,r){var n,l,u,o,T,E,d,a;let s=`Buy ${e.prerequisiteQuantity} item`;if((null===(n=e.prerequisiteProductIds)||void 0===n?void 0:n.length)||(null===(l=e.prerequisiteCollectionIds)||void 0===l?void 0:l.length)){const n=i(null!==(u=e.prerequisiteProductIds)&&void 0!==u?u:[],t),l=i(null!==(o=e.prerequisiteCollectionIds)&&void 0!==o?o:[],r);s+=" from a selection of ",n.length>0&&(s+=`${n.join(", ")} or `),l.length>0&&(s+=`products in ${l.join(", ")} collection or `),s=s.slice(0,-4)}if(s+=` and get ${e.entitledQuantity} item`,(null===(T=e.entitledProductIds)||void 0===T?void 0:T.length)||(null===(E=e.entitledCollectionIds)||void 0===E?void 0:E.length)){const n=i(null!==(d=e.entitledProductIds)&&void 0!==d?d:[],t),l=i(null!==(a=e.entitledCollectionIds)&&void 0!==a?a:[],r);s+=" from ",n.length>0&&(s+=`${n.join(", ")} or `),l.length>0&&(s+=`products in ${l.join(", ")} collection or `),s=s.slice(0,-4)}return s}(r,l,u)} ${100===r.value?"for free":`at ${r.value}% off`} | One use per customer${r.expireAfter?` | Expires in ${r.expireAfter} day(s)`:r.expireAt?` | Expires at ${t.default.getStringFromDate(r.expireAt,"dd MMM yyyy")}`:""}`.replace(/\s\s+/g," ").trim():`${function(t,r,n,l){var u,o,T;let E=`Get ${t.valueType===e.DISCOUNT_VALUE_TYPES.FIXED_AMOUNT?l:""}${(null!==(u=t.value)&&void 0!==u?u:0).toString()}${t.valueType===e.DISCOUNT_VALUE_TYPES.PERCENTAGE?"% off":" off"} on `;const d=i(null!==(o=t.entitledProductIds)&&void 0!==o?o:[],r),a=i(null!==(T=t.entitledCollectionIds)&&void 0!==T?T:[],n);d.length>0&&(E+=`${d.join(", ")} or `);a.length>0&&(E+=`products in ${a.join(", ")} collection or `);return E.slice(0,-4)}(r,l,u,n)} | One use per customer${r.expireAfter?` | Expires in ${r.expireAfter} day(s)`:r.expireAt?` | Expires at ${t.default.getStringFromDate(r.expireAt,"dd MMM yyyy")}`:""}`.replace(/\s\s+/g," ").trim():void 0},exports.validateDiscountData=(t,i,r,n,l,u)=>{var o;if(!t.title||(null===(o=t.title)||void 0===o?void 0:o.length)>30)return!0;if(!n){if(isNaN(t.probability))return!0;if((t.probability||0)>1)return!0;if((t.probability||0)<0)return!0;if(l>1)return!0}if(u){if(!(null==t?void 0:t.couponCode))return!0;if(!t.description)return!0}else{if(r&&r===e.DISCOUNT_TYPES.AMOUNT_OFF_ORDER){if((null==t?void 0:t.valueType)===e.DISCOUNT_VALUE_TYPES.FIXED_AMOUNT){if(!(null==t?void 0:t.value)||(null==t?void 0:t.value)<=0)return!0}else if(!(null==t?void 0:t.value)||(null==t?void 0:t.value)<=0||(null==t?void 0:t.value)>100)return!0;if(i===e.MIN_PURCHASE_REQUIREMENT.AMOUNT&&(!t.minAmount||(null==t?void 0:t.minAmount)<=0))return!0;if(i===e.MIN_PURCHASE_REQUIREMENT.QUANTITY&&(!(null==t?void 0:t.minQuantity)||(null==t?void 0:t.minQuantity)<=0))return!0;if(t.targetType!==e.DISCOUNT_TARGET_TYPES.LINE_ITEM)return!0;if(t.targetSelection!==e.DISCOUNT_TARGET_SELECTION.ALL)return!0}else if(r&&r===e.DISCOUNT_TYPES.AMOUNT_OFF_PRODUCTS){if(!t.value)return!0;if((null==t?void 0:t.valueType)===e.DISCOUNT_VALUE_TYPES.FIXED_AMOUNT){if(!(null==t?void 0:t.value)||(null==t?void 0:t.value)<=0)return!0}else if(!(null==t?void 0:t.value)||(null==t?void 0:t.value)<=0||(null==t?void 0:t.value)>100)return!0;if(t.targetSelection!==e.DISCOUNT_TARGET_SELECTION.ENTITLED)return!0;if(t.targetType!==e.DISCOUNT_TARGET_TYPES.LINE_ITEM)return!0}else if(r&&r===e.DISCOUNT_TYPES.BUY_X_GET_Y){if(!t.entitledQuantity||t.entitledQuantity<0||!t.prerequisiteQuantity||t.prerequisiteQuantity<0)return!0;if(t.valueType!==e.DISCOUNT_VALUE_TYPES.PERCENTAGE)return!0;if(!t.value)return!0;if(t.value<=0||t.value>100)return!0;if(t.targetSelection!==e.DISCOUNT_TARGET_SELECTION.ENTITLED)return!0;if(t.targetType!==e.DISCOUNT_TARGET_TYPES.LINE_ITEM)return!0}else if(r&&e.DISCOUNT_TYPES.FREE_SHIPPING){if(t.valueType!==e.DISCOUNT_VALUE_TYPES.PERCENTAGE)return!0;if(t.targetType!==e.DISCOUNT_TARGET_TYPES.SHIPPING_LINE)return!0;if(100!==t.value)return!0;if(t.targetSelection!==e.DISCOUNT_TARGET_SELECTION.ALL)return!0;if(i===e.MIN_PURCHASE_REQUIREMENT.AMOUNT&&(!t.minAmount||(null==t?void 0:t.minAmount)<=0))return!0;if(i===e.MIN_PURCHASE_REQUIREMENT.QUANTITY&&(!(null==t?void 0:t.minQuantity)||(null==t?void 0:t.minQuantity)<=0))return!0}if(null!==t.expireAfter&&void 0!==t.expireAfter&&t.expireAfter<=0)return!0;if(t.expireAt&&t.expireAt<new Date)return!0}return!1};
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("./type.js"),t=require("../../utils/DateUtils.js");function i(e,t){const i=[];return t.forEach((t=>{e.find((e=>e.toString()===t.id))&&i.push(t.name)})),i}exports.descriptionBuilder=(r,n,u,l)=>{var o,T,E;return(null==r?void 0:r.isStaticCoupon)&&(null==r?void 0:r.description)?r.description:r.targetType===e.DISCOUNT_TARGET_TYPES.LINE_ITEM&&r.targetSelection===e.DISCOUNT_TARGET_SELECTION.ALL?`${r.valueType===e.DISCOUNT_VALUE_TYPES.FIXED_AMOUNT?n:""}${(null!==(o=r.value)&&void 0!==o?o:0).toString()}${r.valueType===e.DISCOUNT_VALUE_TYPES.PERCENTAGE?"% off":" off"} on all products\n ${r.minAmount?`| Minimum purchase of ${n}${r.minAmount}`:""} ${r.minQuantity?`| Buy ${r.minQuantity} products`:""} | One use per customer${r.expireAfter?` | Expires in ${r.expireAfter} day(s)`:r.expireAt?` | Expires at ${t.default.getStringFromDate(r.expireAt,"dd MMM yyyy")}`:""}`.replace(/\s\s+/g," ").trim():r.targetType===e.DISCOUNT_TARGET_TYPES.SHIPPING_LINE?`\n Free shipping on your order ${r.minAmount?`| Minimum purchase of ${n}${r.minAmount}`:""} ${r.minQuantity?`| Buy ${r.minQuantity} products`:""} | One use per customer${r.expireAfter?` | Expires in ${r.expireAfter} day(s)`:r.expireAt?` | Expires at ${t.default.getStringFromDate(r.expireAt,"dd MMM yyyy")}`:""}`.replace(/\s\s+/g," ").trim():r.targetSelection===e.DISCOUNT_TARGET_SELECTION.ENTITLED?(null===(T=r.prerequisiteProductIds)||void 0===T?void 0:T.length)||(null===(E=r.prerequisiteCollectionIds)||void 0===E?void 0:E.length)||r.entitledQuantity||r.prerequisiteQuantity?`${function(e,t,r){var n,u,l,o,T,E,d,a;let s=`Buy ${e.prerequisiteQuantity} item`;if((null===(n=e.prerequisiteProductIds)||void 0===n?void 0:n.length)||(null===(u=e.prerequisiteCollectionIds)||void 0===u?void 0:u.length)){const n=i(null!==(l=e.prerequisiteProductIds)&&void 0!==l?l:[],t),u=i(null!==(o=e.prerequisiteCollectionIds)&&void 0!==o?o:[],r);s+=" from a selection of ",n.length>0&&(s+=`${n.join(", ")} or `),u.length>0&&(s+=`products in ${u.join(", ")} collection or `),s=s.slice(0,-4)}if(s+=` and get ${e.entitledQuantity} item`,(null===(T=e.entitledProductIds)||void 0===T?void 0:T.length)||(null===(E=e.entitledCollectionIds)||void 0===E?void 0:E.length)){const n=i(null!==(d=e.entitledProductIds)&&void 0!==d?d:[],t),u=i(null!==(a=e.entitledCollectionIds)&&void 0!==a?a:[],r);s+=" from ",n.length>0&&(s+=`${n.join(", ")} or `),u.length>0&&(s+=`products in ${u.join(", ")} collection or `),s=s.slice(0,-4)}return s}(r,u,l)} ${100===r.value?"for free":`at ${r.value}% off`} | One use per customer${r.expireAfter?` | Expires in ${r.expireAfter} day(s)`:r.expireAt?` | Expires at ${t.default.getStringFromDate(r.expireAt,"dd MMM yyyy")}`:""}`.replace(/\s\s+/g," ").trim():`${function(t,r,n,u){var l,o,T;let E=`Get ${t.valueType===e.DISCOUNT_VALUE_TYPES.FIXED_AMOUNT?u:""}${(null!==(l=t.value)&&void 0!==l?l:0).toString()}${t.valueType===e.DISCOUNT_VALUE_TYPES.PERCENTAGE?"% off":" off"} on `;const d=i(null!==(o=t.entitledProductIds)&&void 0!==o?o:[],r),a=i(null!==(T=t.entitledCollectionIds)&&void 0!==T?T:[],n);d.length>0&&(E+=`${d.join(", ")} or `);a.length>0&&(E+=`products in ${a.join(", ")} collection or `);return E.slice(0,-4)}(r,u,l,n)} | One use per customer${r.expireAfter?` | Expires in ${r.expireAfter} day(s)`:r.expireAt?` | Expires at ${t.default.getStringFromDate(r.expireAt,"dd MMM yyyy")}`:""}`.replace(/\s\s+/g," ").trim():void 0},exports.validateDiscountData=(t,i,r,n,u,l,o)=>{var T;if(!t.title||(null===(T=t.title)||void 0===T?void 0:T.length)>30)return!0;if(!n){if(isNaN(t.probability))return!0;if((t.probability||0)>1)return!0;if((t.probability||0)<0)return!0;if(u>1)return!0}if(l&&!o){if(!(null==t?void 0:t.couponCode))return!0;if(!t.description)return!0}else{if(l&&o&&!(null==t?void 0:t.couponCode))return!0;if(r&&r===e.DISCOUNT_TYPES.AMOUNT_OFF_ORDER){if((null==t?void 0:t.valueType)===e.DISCOUNT_VALUE_TYPES.FIXED_AMOUNT){if(!(null==t?void 0:t.value)||(null==t?void 0:t.value)<=0)return!0}else if(!(null==t?void 0:t.value)||(null==t?void 0:t.value)<=0||(null==t?void 0:t.value)>100)return!0;if(i===e.MIN_PURCHASE_REQUIREMENT.AMOUNT&&(!t.minAmount||(null==t?void 0:t.minAmount)<=0))return!0;if(i===e.MIN_PURCHASE_REQUIREMENT.QUANTITY&&(!(null==t?void 0:t.minQuantity)||(null==t?void 0:t.minQuantity)<=0))return!0;if(t.targetType!==e.DISCOUNT_TARGET_TYPES.LINE_ITEM)return!0;if(t.targetSelection!==e.DISCOUNT_TARGET_SELECTION.ALL)return!0}else if(r&&r===e.DISCOUNT_TYPES.AMOUNT_OFF_PRODUCTS){if(!t.value)return!0;if((null==t?void 0:t.valueType)===e.DISCOUNT_VALUE_TYPES.FIXED_AMOUNT){if(!(null==t?void 0:t.value)||(null==t?void 0:t.value)<=0)return!0}else if(!(null==t?void 0:t.value)||(null==t?void 0:t.value)<=0||(null==t?void 0:t.value)>100)return!0;if(t.targetSelection!==e.DISCOUNT_TARGET_SELECTION.ENTITLED)return!0;if(t.targetType!==e.DISCOUNT_TARGET_TYPES.LINE_ITEM)return!0}else if(r&&r===e.DISCOUNT_TYPES.BUY_X_GET_Y){if(!t.entitledQuantity||t.entitledQuantity<0||!t.prerequisiteQuantity||t.prerequisiteQuantity<0)return!0;if(t.valueType!==e.DISCOUNT_VALUE_TYPES.PERCENTAGE)return!0;if(!t.value)return!0;if(t.value<=0||t.value>100)return!0;if(t.targetSelection!==e.DISCOUNT_TARGET_SELECTION.ENTITLED)return!0;if(t.targetType!==e.DISCOUNT_TARGET_TYPES.LINE_ITEM)return!0}else if(r&&e.DISCOUNT_TYPES.FREE_SHIPPING){if(t.valueType!==e.DISCOUNT_VALUE_TYPES.PERCENTAGE)return!0;if(t.targetType!==e.DISCOUNT_TARGET_TYPES.SHIPPING_LINE)return!0;if(100!==t.value)return!0;if(t.targetSelection!==e.DISCOUNT_TARGET_SELECTION.ALL)return!0;if(i===e.MIN_PURCHASE_REQUIREMENT.AMOUNT&&(!t.minAmount||(null==t?void 0:t.minAmount)<=0))return!0;if(i===e.MIN_PURCHASE_REQUIREMENT.QUANTITY&&(!(null==t?void 0:t.minQuantity)||(null==t?void 0:t.minQuantity)<=0))return!0}if(null!==t.expireAfter&&void 0!==t.expireAfter&&t.expireAfter<=0)return!0;if(t.expireAt&&t.expireAt<new Date)return!0}return!1};
@@ -46,6 +46,7 @@ interface DynamicCouponI {
46
46
  onChangeCouponType: (option: SingleOption) => void;
47
47
  hideExpiration?: boolean;
48
48
  hideProbability?: boolean;
49
+ noTopMargin?: boolean;
49
50
  allowStaticCoupon: boolean;
50
51
  currency?: string;
51
52
  useNewPicker?: boolean;
@@ -65,6 +66,7 @@ interface DynamicCouponI {
65
66
  discountDetailsOptions: DiscountDetailsProps[];
66
67
  setSelectedExpiration: React.Dispatch<React.SetStateAction<COUPON_EXPIRATION | undefined>>;
67
68
  selectedExpiration: COUPON_EXPIRATION | undefined;
69
+ isUsageFromStatic?: boolean;
68
70
  }
69
71
  declare const DynamicCoupon: React.FC<DynamicCouponI>;
70
72
  export default DynamicCoupon;
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../../../_virtual/_tslib.js"),t=require("../../../node_modules/react/jsx-runtime.js"),i=require("../../../assets/icons/info.svg.js"),o=require("../../alerts/Alert.js"),s=require("../../alerts/AlertHelper.js"),n=require("../../button/Button.js"),r=require("../../checkBox/CheckBox.js"),l=require("../type.js");require("../../dropdown/DropdownPopover/index.js");var a=require("../../dropdown/Dropdown.js");require("../../dropdown/ChipDropdown.js"),require("react"),require("../../zeroState/ZeroState.js");var d=require("../../TypographyStyle.js"),u=require("../../../constants/Theme.js");require("../../dropdown/OpenedDropdown/components/description/Description.styled.js"),require("../../list-item/ListItem.js"),require("../../dropdown/OpenedDropdown/components/menu/FreeFormMenu.styled.js"),require("../../dropdown/OpenedDropdown/components/menu/MenuItem.js"),require("../../dropdown/OpenedDropdown/components/menu/MenuList.styled.js"),require("../../dropdown/OpenedDropdown/components/multiSelect/MultiSelectDropdownBottomBar.styled.js"),require("../../dropdown/OpenedDropdown/components/OpennedDropdown.styled.js"),require("../../icon-button/IconButton.js");var c=require("../../input/Input.js"),p=require("../../../assets/icons/cross.svg.js");require("../../dropdown/MenuItem/MenuItem.js");var E,x=require("../../radioButton/RadioButton.js"),T=require("../../../assets/icons/cubeIcon.svg.js"),C=require("../../../assets/icons/delete.svg.js"),D=require("../../../assets/icons/edit.svg.js"),O=require("../../../assets/icons/plus.svg.js"),j=require("../CouponExpiration/CouponExpiration.js"),S=require("../DiscountModal.styled.js"),m=require("./DynamicCoupon.styled.js"),P=require("./MinimumRequirementComponent.js"),I=require("./ZeroState.js");exports.DISCOUNT_PRODUCTS=void 0,(E=exports.DISCOUNT_PRODUCTS||(exports.DISCOUNT_PRODUCTS={})).ENTITLED="entitled",E.PREREQUISITE="prerequisite";exports.default=E=>{var R,v,_,b,g,y,U,h;const N=[{selected:E.discountCouponAppliesTo===l.DISCOUNT_APPLIES_TO.ENTIRE_ORDER,label:"Entire Order",value:l.DISCOUNT_APPLIES_TO.ENTIRE_ORDER},{selected:E.discountCouponAppliesTo===l.DISCOUNT_APPLIES_TO.SPECIFIC_PRODUCTS,label:"Specific Product",value:l.DISCOUNT_APPLIES_TO.SPECIFIC_PRODUCTS},{selected:E.discountCouponAppliesTo===l.DISCOUNT_APPLIES_TO.SPECIFIC_COLLECTIONS,label:"Specific Collections",value:l.DISCOUNT_APPLIES_TO.SPECIFIC_COLLECTIONS}],V=[{selected:E.offerAppliesToBuy===l.OFFER_APPLIES_TO.SPECIFIC_PRODUCTS,label:"Specific Product",value:l.OFFER_APPLIES_TO.SPECIFIC_PRODUCTS},{selected:E.offerAppliesToBuy===l.OFFER_APPLIES_TO.SPECIFIC_COLLECTIONS,label:"Specific Collections",value:l.OFFER_APPLIES_TO.SPECIFIC_COLLECTIONS}],A=[{selected:E.offerAppliesToGet===l.OFFER_APPLIES_TO.SPECIFIC_PRODUCTS,label:"Specific Product",value:l.OFFER_APPLIES_TO.SPECIFIC_PRODUCTS},{selected:E.offerAppliesToGet===l.OFFER_APPLIES_TO.SPECIFIC_COLLECTIONS,label:"Specific Collections",value:l.OFFER_APPLIES_TO.SPECIFIC_COLLECTIONS}],L=(e,r,a)=>{var c,x,j,S,P,I,R,v,_,b,g,y;let U=[],h=[],N={},V={};E.useNewPicker?(N=r===exports.DISCOUNT_PRODUCTS.ENTITLED?E.entitledProducts:E.prerequisiteProducts,V=null!==(c=r===exports.DISCOUNT_PRODUCTS.ENTITLED?E.entitledCollections:E.prerequisiteCollections)&&void 0!==c?c:[],(null==N?void 0:N.isCustom)&&delete N.isCustom,(null==V?void 0:V.isCustom)&&delete V.isCustom,Object.values(N).forEach((e=>{Object.keys(e.products).forEach((t=>{U.push({id:t,name:e.products[t].name,image:e.products[t].image})}))})),Object.keys(V).forEach((e=>{"isCustom"!==e&&h.push({id:e,name:V[e].name,image:V[e].image})}))):(U=r===exports.DISCOUNT_PRODUCTS.ENTITLED?E.entitledProducts:E.prerequisiteProducts,h=null!==(x=r===exports.DISCOUNT_PRODUCTS.ENTITLED?E.entitledCollections:E.prerequisiteCollections)&&void 0!==x?x:[]);const A=[null===(j=E.dynamicDiscountValidationError)||void 0===j?void 0:j.inValidProductSelection,null===(S=E.dynamicDiscountValidationError)||void 0===S?void 0:S.inValidProductVariableSelection,null===(P=E.dynamicDiscountValidationError)||void 0===P?void 0:P.inValidCollectionSelection],L=[null===(I=E.dynamicDiscountValidationError)||void 0===I?void 0:I.inValidBuyXCollectionSelection,null===(R=E.dynamicDiscountValidationError)||void 0===R?void 0:R.inValidBuyXProductSelection,null===(v=E.dynamicDiscountValidationError)||void 0===v?void 0:v.inValidBuyXProductVariableSelection],f=[null===(_=E.dynamicDiscountValidationError)||void 0===_?void 0:_.inValidGetYCollectionSelection,null===(b=E.dynamicDiscountValidationError)||void 0===b?void 0:b.inValidGetYProductSelection,null===(g=E.dynamicDiscountValidationError)||void 0===g?void 0:g.inValidGetYProductVariableSelection];let F=!1;return"couponAppliesTo"===a&&(F=A.some(Boolean)),"buyX"===a&&(F=L.some(Boolean)),"getY"===a&&(F=f.some(Boolean)),t.jsxRuntimeExports.jsxs(t.jsxRuntimeExports.Fragment,{children:[t.jsxRuntimeExports.jsxs("div",Object.assign({style:{display:"flex",gap:18}},{children:[e===l.DISCOUNT_APPLIES_TO.SPECIFIC_PRODUCTS&&0===U.length&&(r===exports.DISCOUNT_PRODUCTS.ENTITLED&&!E.entitledProductVariable||r===exports.DISCOUNT_PRODUCTS.PREREQUISITE&&!E.preRequisiteProductVariable)&&!(null==h?void 0:h.length)&&t.jsxRuntimeExports.jsxs(m.AddProductButtonsContainer,{children:[t.jsxRuntimeExports.jsx("div",Object.assign({style:{width:E.isProductVariableSupported?"284px":"300px",display:"flex"}},{children:t.jsxRuntimeExports.jsx(n.Button,{buttonText:"Add Product(s)",buttonType:"dashRegular",LeadingIcon:O.default,matchParentWidth:!0,onClick:()=>{E.setIsProductPickerOpen(r)},error:F})})),E.isProductVariableSupported&&E.productVariableList&&t.jsxRuntimeExports.jsxs(t.jsxRuntimeExports.Fragment,{children:[t.jsxRuntimeExports.jsx(d.BodySecondary,Object.assign({color:u.DEFAULT_THEME.colorsV2.content.placeholder},{children:"OR"})),t.jsxRuntimeExports.jsx(n.Button,{buttonText:"Add Product(s) Variable",buttonType:"dashRegular",LeadingIcon:O.default,matchParentWidth:!0,onClick:()=>{E.setIsProductVariablePickerOpen(r)},error:F})]})]}),e===l.DISCOUNT_APPLIES_TO.SPECIFIC_COLLECTIONS&&0===h.length&&!(null==U?void 0:U.length)&&t.jsxRuntimeExports.jsx("div",Object.assign({style:{width:"300px",display:"flex"}},{children:t.jsxRuntimeExports.jsx(n.Button,{buttonText:"Add collection(s)",buttonType:"dashRegular",LeadingIcon:O.default,matchParentWidth:!0,onClick:()=>{E.setIsCollectionPickerOpen(r)},style:{marginTop:"16px"},error:F})}))]})),F&&t.jsxRuntimeExports.jsx("div",Object.assign({style:{margin:"8px 0 0"}},{children:t.jsxRuntimeExports.jsx(o.Alert,{type:s.ALERT_TYPES.NEGATIVE,text:"Required Field",contentPosition:s.CONTENT_POSITION.START,icon:()=>t.jsxRuntimeExports.jsx(i.default,{width:16,height:16,color:u.DEFAULT_THEME.colorsV2.content.negative})})})),U.length||h.length?t.jsxRuntimeExports.jsxs("div",{children:[t.jsxRuntimeExports.jsx(d.BodySecondary,Object.assign({style:{margin:"8px 0"}},{children:e===l.DISCOUNT_APPLIES_TO.SPECIFIC_COLLECTIONS?"Collection(s)":"Product(s)"})),t.jsxRuntimeExports.jsxs(m.ProductCollectionCard,{children:[t.jsxRuntimeExports.jsx(m.CubeIconContainer,{children:t.jsxRuntimeExports.jsx(T.default,{width:20,height:20,color:u.DEFAULT_THEME.colorsV2.content.secondary})}),t.jsxRuntimeExports.jsxs(d.TitleSmall,{children:[e===l.DISCOUNT_APPLIES_TO.SPECIFIC_PRODUCTS?U.length:h.length," ",e===l.DISCOUNT_APPLIES_TO.SPECIFIC_PRODUCTS?"Product(s)":"Collection(s)"," ","added"]}),t.jsxRuntimeExports.jsxs("div",Object.assign({style:{display:"flex",gap:4}},{children:[t.jsxRuntimeExports.jsx(m.IconContainer,Object.assign({onClick:()=>{e===l.DISCOUNT_APPLIES_TO.SPECIFIC_PRODUCTS?E.setIsProductPickerOpen(r):E.setIsCollectionPickerOpen(r)}},{children:t.jsxRuntimeExports.jsx(D.default,{width:24,height:24,color:u.DEFAULT_THEME.colorsV2.content.placeholder})})),t.jsxRuntimeExports.jsx(m.IconContainer,Object.assign({onClick:()=>{e===l.DISCOUNT_APPLIES_TO.SPECIFIC_PRODUCTS?r===exports.DISCOUNT_PRODUCTS.ENTITLED?E.setEntitledProducts([]):E.setPrerequisiteProducts([]):r===exports.DISCOUNT_PRODUCTS.ENTITLED?E.setEntitledCollections([]):E.setPrerequisiteCollections([])}},{children:t.jsxRuntimeExports.jsx(C.default,{width:24,height:24,color:u.DEFAULT_THEME.colorsV2.content.placeholder})}))]}))]})]}):r===exports.DISCOUNT_PRODUCTS.ENTITLED&&E.entitledProductVariable?t.jsxRuntimeExports.jsxs("div",{children:[t.jsxRuntimeExports.jsx(d.BodySecondary,Object.assign({style:{margin:"16px 0 8px"}},{children:"Product Variable"})),t.jsxRuntimeExports.jsxs(m.ProductVariableCard,{children:[t.jsxRuntimeExports.jsx(d.TitleSmall,{children:E.entitledProductVariable.displayName}),t.jsxRuntimeExports.jsx("div",Object.assign({style:{display:"flex",gap:4}},{children:t.jsxRuntimeExports.jsx(m.IconContainer,Object.assign({onClick:()=>{E.setEntitledProductVariable(void 0)}},{children:t.jsxRuntimeExports.jsx(p.default,{width:24,height:24,color:u.DEFAULT_THEME.colorsV2.content.primary})}))}))]})]}):r===exports.DISCOUNT_PRODUCTS.PREREQUISITE&&(null===(y=E.preRequisiteProductVariable)||void 0===y?void 0:y.displayName)?t.jsxRuntimeExports.jsxs("div",{children:[t.jsxRuntimeExports.jsx(d.BodySecondary,Object.assign({style:{margin:"16px 0 8px"}},{children:"Product Variable"})),t.jsxRuntimeExports.jsxs(m.ProductVariableCard,{children:[t.jsxRuntimeExports.jsx(d.TitleSmall,{children:E.preRequisiteProductVariable.displayName}),t.jsxRuntimeExports.jsx("div",Object.assign({style:{display:"flex",gap:4}},{children:t.jsxRuntimeExports.jsx(m.IconContainer,Object.assign({onClick:()=>{E.setPreRequisiteProductVariable(void 0)}},{children:t.jsxRuntimeExports.jsx(p.default,{width:24,height:24,color:u.DEFAULT_THEME.colorsV2.content.primary})}))}))]})]}):t.jsxRuntimeExports.jsx(t.jsxRuntimeExports.Fragment,{children:" "})]})},f=(e,i)=>{var o,s,n,r,u,p,x,T,C,D;let O=[],j=[],S={},m={};E.useNewPicker?(S=e===exports.DISCOUNT_PRODUCTS.ENTITLED?E.entitledProducts:E.prerequisiteProducts,m=null!==(o=e===exports.DISCOUNT_PRODUCTS.ENTITLED?E.entitledCollections:E.prerequisiteCollections)&&void 0!==o?o:[],(null==S?void 0:S.isCustom)&&delete S.isCustom,(null==m?void 0:m.isCustom)&&delete m.isCustom,Object.values(S).forEach((e=>{Object.keys(e.products).forEach((t=>{O.push({id:t,name:e.products[t].name,image:e.products[t].image})}))})),Object.keys(m).forEach((e=>{"isCustom"!==e&&j.push({id:e,name:m[e].name,image:m[e].image})}))):(O=e===exports.DISCOUNT_PRODUCTS.ENTITLED?E.entitledProducts:E.prerequisiteProducts,j=null!==(s=e===exports.DISCOUNT_PRODUCTS.ENTITLED?E.entitledCollections:E.prerequisiteCollections)&&void 0!==s?s:[]);const P=e===exports.DISCOUNT_PRODUCTS.PREREQUISITE?E.offerAppliesToBuy:E.offerAppliesToGet,I=e===exports.DISCOUNT_PRODUCTS.PREREQUISITE?exports.DISCOUNT_PRODUCTS.PREREQUISITE:exports.DISCOUNT_PRODUCTS.ENTITLED,R=P===l.OFFER_APPLIES_TO.SPECIFIC_PRODUCTS?l.DISCOUNT_APPLIES_TO.SPECIFIC_PRODUCTS:l.DISCOUNT_APPLIES_TO.SPECIFIC_COLLECTIONS;return t.jsxRuntimeExports.jsxs("div",{children:[t.jsxRuntimeExports.jsx(d.TitleSmall,Object.assign({style:{marginBottom:16}},{children:e===exports.DISCOUNT_PRODUCTS.PREREQUISITE?"Customer buys":"Customer gets"})),t.jsxRuntimeExports.jsxs("div",Object.assign({style:{display:"flex"}},{children:[!i&&t.jsxRuntimeExports.jsx("div",{children:t.jsxRuntimeExports.jsxs("div",Object.assign({className:"input__rows"},{children:[t.jsxRuntimeExports.jsx("div",Object.assign({className:"input__wrapper"},{children:t.jsxRuntimeExports.jsx(c.Input,{value:e===exports.DISCOUNT_PRODUCTS.ENTITLED?null!==(r=null===(n=E.discountData.entitledQuantity)||void 0===n?void 0:n.toString())&&void 0!==r?r:"":null!==(p=null===(u=E.discountData.prerequisiteQuantity)||void 0===u?void 0:u.toString())&&void 0!==p?p:"",type:"number",onChangeText:t=>{e===exports.DISCOUNT_PRODUCTS.ENTITLED?E.setDiscountData(Object.assign(Object.assign({},E.discountData),{entitledQuantity:parseInt(t)})):E.setDiscountData(Object.assign(Object.assign({},E.discountData),{prerequisiteQuantity:parseInt(t)}))},labelText:"Quantity of products",placeholder:"Eg. 2",width:"300px",errorMessage:e===exports.DISCOUNT_PRODUCTS.PREREQUISITE&&(null===(x=E.dynamicDiscountValidationError)||void 0===x?void 0:x.inValidBuyXValue)||e===exports.DISCOUNT_PRODUCTS.ENTITLED&&(null===(T=E.dynamicDiscountValidationError)||void 0===T?void 0:T.inValidGetYValue)?"Required Field":"",state:e===exports.DISCOUNT_PRODUCTS.PREREQUISITE&&(null===(C=E.dynamicDiscountValidationError)||void 0===C?void 0:C.inValidBuyXValue)||e===exports.DISCOUNT_PRODUCTS.ENTITLED&&(null===(D=E.dynamicDiscountValidationError)||void 0===D?void 0:D.inValidGetYValue)?"invalid":"none"})})),t.jsxRuntimeExports.jsx("div",{className:"input__wrapper"})]}))}),t.jsxRuntimeExports.jsxs("div",{children:[t.jsxRuntimeExports.jsx(d.BodySecondary,Object.assign({style:{marginBottom:8}},{children:"Any items from"})),e===exports.DISCOUNT_PRODUCTS.PREREQUISITE&&t.jsxRuntimeExports.jsx(a.Dropdown,{width:"244px",options:V,placement:"bottom-start",onSelect:e=>{var t,i,o;E.setOfferAppliesToBuy(e.value),E.setPrerequisiteProducts([]),E.setPrerequisiteCollections([]),E.setPreRequisiteProductVariable(void 0),E.setDynamicDiscountValidationError((e=>Object.assign(Object.assign({},e),{inValidBuyXCollectionSelection:!1,inValidBuyXProductSelection:!1,inValidBuyXProductVariableSelection:!1}))),E.setDiscountData(Object.assign(Object.assign({},E.discountData),{prerequisiteCollectionIds:[],prerequisiteProductIds:[],collectionsConf:{entitledCollections:null===(t=E.discountData.collectionsConf)||void 0===t?void 0:t.entitledCollections,prerequisiteCollections:{}},productsConf:{entitledProducts:null===(i=E.discountData.productsConf)||void 0===i?void 0:i.entitledProducts,prerequisiteProducts:{}},productVariableConf:{entitledProductVariable:null===(o=E.discountData.productVariableConf)||void 0===o?void 0:o.entitledProductVariable,prerequisiteProductVariable:{}}}))}}),e===exports.DISCOUNT_PRODUCTS.ENTITLED&&t.jsxRuntimeExports.jsx(a.Dropdown,{width:"244px",options:A,placement:"bottom-start",onSelect:e=>{var t,i,o;E.setOfferAppliesToGet(e.value),E.setEntitledProducts([]),E.setEntitledCollections([]),E.setEntitledProductVariable(void 0),E.setDynamicDiscountValidationError((e=>Object.assign(Object.assign({},e),{inValidGetYCollectionSelection:!1,inValidGetYProductSelection:!1,inValidGetYProductVariableSelection:!1}))),E.setDiscountData(Object.assign(Object.assign({},E.discountData),{entitledCollectionIds:[],entitledProductIds:[],collectionsConf:{entitledCollections:{},prerequisiteCollections:null===(t=E.discountData.collectionsConf)||void 0===t?void 0:t.prerequisiteCollections},productsConf:{entitledProducts:{},prerequisiteProducts:null===(i=E.discountData.productsConf)||void 0===i?void 0:i.prerequisiteProducts},productVariableConf:{entitledProductVariable:{},prerequisiteProductVariable:null===(o=E.discountData.productVariableConf)||void 0===o?void 0:o.prerequisiteProductVariable}}))}})]})]})),L(R,I,e===exports.DISCOUNT_PRODUCTS.PREREQUISITE?"buyX":"getY")]})};return t.jsxRuntimeExports.jsxs(S.DynamicCouponContainer,{children:[t.jsxRuntimeExports.jsxs("div",{children:[t.jsxRuntimeExports.jsxs("div",Object.assign({style:{display:"flex",gap:16}},{children:[t.jsxRuntimeExports.jsx("div",Object.assign({className:"input__wrapper"},{children:t.jsxRuntimeExports.jsx(c.Input,{value:null!==(R=E.discountData.title)&&void 0!==R?R:"",onChangeText:e=>{var t;E.setDiscountData(Object.assign(Object.assign({},E.discountData),{title:null!==(t=null==e?void 0:e.trim())&&void 0!==t?t:""}))},maxCharLimit:30,labelText:"Discount Coupon Title",placeholder:`Eg. “Flat ${null!==(v=E.currency)&&void 0!==v?v:""} 15 Off”`,hintText:"Will be same for everyone. Can’t be changed later",width:"300px",isRequired:!0,errorMessage:(null===(_=E.dynamicDiscountValidationError)||void 0===_?void 0:_.invalidCouponTitle)?"Required Field":"",state:(null===(b=E.dynamicDiscountValidationError)||void 0===b?void 0:b.invalidCouponTitle)?"invalid":"none"})})),!E.hideProbability&&t.jsxRuntimeExports.jsx(c.Input,{value:null!==(y=null===(g=E.discountData.probability)||void 0===g?void 0:g.toString())&&void 0!==y?y:"",type:"number",onChangeText:e=>{E.setDiscountData(Object.assign(Object.assign({},E.discountData),{probability:e.startsWith(".")?parseFloat(parseFloat(`0${e}`).toFixed(2)):parseFloat(parseFloat(e).toFixed(2))}))},labelText:"Probability of getting coupon ",hintText:"Enter a decimal value between 0-1",placeholder:"Eg. 0.5",maxCharLimit:4,width:"300px",isRequired:!0,errorMessage:(null===(U=E.dynamicDiscountValidationError)||void 0===U?void 0:U.inValidProbability)?"Required Field":"",state:(null===(h=E.dynamicDiscountValidationError)||void 0===h?void 0:h.inValidProbability)?"invalid":"none"})]})),t.jsxRuntimeExports.jsx("div",{style:{height:"1px",width:"100%",background:u.DEFAULT_THEME.colorsV2.stroke.primary,margin:"24px 0 8px"}})]}),E.allowStaticCoupon&&t.jsxRuntimeExports.jsx((()=>t.jsxRuntimeExports.jsxs("div",{children:[t.jsxRuntimeExports.jsx(d.TitleRegular,{children:"Discount Details"}),t.jsxRuntimeExports.jsx(m.DiscountOptionsContainer,{children:E.discountDetailsOptions.map((i=>{return t.jsxRuntimeExports.jsxs(m.DiscountDetailsOption,Object.assign({selected:E.selectedDiscountDetails.id===i.id,onClick:()=>(t=>{if(E.selectedDiscountDetails.id!==t.id)if(E.resetValidationErrors(),E.setValidationErrorMessage(""),E.setDiscountCouponAppliesTo(l.DISCOUNT_APPLIES_TO.ENTIRE_ORDER),E.setSelectedDiscountDetails(t),E.setDiscountData(Object.assign(Object.assign({},E.discountData),{value:void 0})),E.setPreRequisiteProductVariable(void 0),E.setEntitledProductVariable(void 0),["percentage","amount"].includes(t.value)){E.onChangeCouponType({label:"Amount off on order",selected:!0,value:l.DISCOUNT_TYPES.AMOUNT_OFF_ORDER});const i=Object.assign(Object.assign({},E.discountData),{valueType:"percentage"===t.value?l.DISCOUNT_VALUE_TYPES.PERCENTAGE:l.DISCOUNT_VALUE_TYPES.FIXED_AMOUNT,value:void 0,targetType:l.DISCOUNT_TARGET_TYPES.LINE_ITEM,targetSelection:l.DISCOUNT_TARGET_SELECTION.ALL,entitledCollectionIds:[],entitledProductIds:[],prerequisiteCollectionIds:[],prerequisiteProductIds:[],collectionsConf:{entitledCollections:{},prerequisiteCollections:{}},productsConf:{entitledProducts:{},prerequisiteProducts:{}},productVariableConf:{entitledProductVariable:{},prerequisiteProductVariable:{}}}),o=e.__rest(i,["entitledQuantity","prerequisiteQuantity"]);E.setDiscountData(o)}else E.onChangeCouponType({label:t.label,selected:!0,value:t.value})})(i)},{children:[i.icon((o=i.id,E.selectedDiscountDetails.id===o?u.DEFAULT_THEME.colorsV2.stroke.brand:u.DEFAULT_THEME.colorsV2.text.secondary)),i.label]}),i.id);var o}))})]})),{}),(E.selectedCouponType===l.DISCOUNT_TYPES.AMOUNT_OFF_ORDER||E.selectedCouponType===l.DISCOUNT_TYPES.AMOUNT_OFF_PRODUCTS)&&(()=>{var e,i,o,s,n,r;return t.jsxRuntimeExports.jsxs(t.jsxRuntimeExports.Fragment,{children:[t.jsxRuntimeExports.jsx("div",Object.assign({className:"input__rows"},{children:t.jsxRuntimeExports.jsx("div",Object.assign({className:"input__wrapper"},{children:t.jsxRuntimeExports.jsx(c.Input,{value:null!==(o=null===(i=null===(e=E.discountData)||void 0===e?void 0:e.value)||void 0===i?void 0:i.toString())&&void 0!==o?o:"",labelText:"Discount amount",type:"number",width:"300px",onChangeText:e=>{E.setDiscountData(Object.assign(Object.assign({},E.discountData),{value:parseInt(e)}))},placeholder:"15",prefixText:E.discountData.valueType===l.DISCOUNT_VALUE_TYPES.FIXED_AMOUNT?null!==(s=E.currency)&&void 0!==s?s:"":void 0,suffixText:E.discountData.valueType===l.DISCOUNT_VALUE_TYPES.PERCENTAGE?"%":void 0,errorMessage:(null===(n=E.dynamicDiscountValidationError)||void 0===n?void 0:n.inValidDiscountAmount)?"Required Field":"",state:(null===(r=E.dynamicDiscountValidationError)||void 0===r?void 0:r.inValidDiscountAmount)?"invalid":"none"})}))})),t.jsxRuntimeExports.jsx("div",Object.assign({style:{paddingTop:"24px",marginTop:16,borderTop:`1px solid ${u.DEFAULT_THEME.colorsV2.stroke.primary}`}},{children:t.jsxRuntimeExports.jsxs("div",Object.assign({className:"input__wrapper"},{children:[t.jsxRuntimeExports.jsx(d.TitleRegular,Object.assign({style:{marginBottom:10}},{children:"Applies to"})),t.jsxRuntimeExports.jsx("div",Object.assign({style:{display:"flex",flexGrow:0,flexShrink:0,flexBasis:"auto"}},{children:t.jsxRuntimeExports.jsx(a.Dropdown,{width:"300px",options:N,placement:"bottom-start",onSelect:e=>{const t="value"in e&&e.value===l.DISCOUNT_APPLIES_TO.ENTIRE_ORDER?{label:"Amount off on order",selected:!0,value:l.DISCOUNT_TYPES.AMOUNT_OFF_ORDER}:{label:"Amount off on products",selected:!0,value:l.DISCOUNT_TYPES.AMOUNT_OFF_PRODUCTS};E.onChangeCouponType(t),E.setDiscountCouponAppliesTo(e.value),E.setEntitledProductVariable(void 0),E.setDynamicDiscountValidationError((e=>Object.assign(Object.assign({},e),{inValidProductVariableSelection:!1,inValidProductSelection:!1,inValidCollectionSelection:!1})))}})})),(E.discountCouponAppliesTo===l.DISCOUNT_APPLIES_TO.SPECIFIC_PRODUCTS||E.discountCouponAppliesTo===l.DISCOUNT_APPLIES_TO.SPECIFIC_COLLECTIONS)&&L(E.discountCouponAppliesTo,exports.DISCOUNT_PRODUCTS.ENTITLED,"couponAppliesTo")]}))}))]})})(),E.selectedCouponType===l.DISCOUNT_TYPES.BUY_X_GET_Y&&(()=>{var e,i,o,s,n;return t.jsxRuntimeExports.jsxs(S.DynamicCouponContainer,Object.assign({style:{border:`1px solid ${u.DEFAULT_THEME.colorsV2.stroke.primary}`,padding:"16px",borderRadius:"4px",margin:0}},{children:[f(exports.DISCOUNT_PRODUCTS.PREREQUISITE),t.jsxRuntimeExports.jsx("div",{style:{width:"100%",height:"1px",backgroundColor:u.DEFAULT_THEME.colorsV2.stroke.primary,margin:"8px 0"}}),f(exports.DISCOUNT_PRODUCTS.ENTITLED),t.jsxRuntimeExports.jsx(d.BodySecondary,Object.assign({style:{marginTop:"8px"}},{children:"At a discounted value"})),t.jsxRuntimeExports.jsx("div",{children:t.jsxRuntimeExports.jsx(x.RadioButton,{label:"Free",isActive:100===E.discountData.value,onValueChange:e=>{e?E.setDiscountData(Object.assign(Object.assign({},E.discountData),{value:100})):E.setDiscountData(Object.assign(Object.assign({},E.discountData),{value:void 0}))}})}),t.jsxRuntimeExports.jsxs("div",Object.assign({style:{display:"flex",flexDirection:"column"}},{children:[t.jsxRuntimeExports.jsx(x.RadioButton,{label:"Percentage off",isActive:100!==E.discountData.value,onValueChange:()=>{E.setDiscountData(Object.assign(Object.assign({},E.discountData),{value:void 0}))}}),100!==E.discountData.value&&t.jsxRuntimeExports.jsx("div",Object.assign({style:{marginTop:8}},{children:t.jsxRuntimeExports.jsx(c.Input,{value:null!==(o=null===(i=null===(e=E.discountData)||void 0===e?void 0:e.value)||void 0===i?void 0:i.toString())&&void 0!==o?o:"",onChangeText:e=>{E.setDiscountData(Object.assign(Object.assign({},E.discountData),{value:parseInt(e)}))},type:"number",placeholder:"Eg. 50",suffixText:"%",width:"300px",errorMessage:(null===(s=E.dynamicDiscountValidationError)||void 0===s?void 0:s.inValidDiscountAmount)?"Required Field":"",state:(null===(n=E.dynamicDiscountValidationError)||void 0===n?void 0:n.inValidDiscountAmount)?"invalid":"none"})}))]}))]}))})(),!E.selectedCouponType&&t.jsxRuntimeExports.jsx(I.default,{}),E.allowStaticCoupon&&E.selectedCouponType!==l.DISCOUNT_TYPES.BUY_X_GET_Y&&t.jsxRuntimeExports.jsx("div",Object.assign({style:{padding:"24px 0 16px",marginTop:16,borderTop:`1px solid ${u.DEFAULT_THEME.colorsV2.stroke.primary}`}},{children:t.jsxRuntimeExports.jsx(P.default,{selectedMinimumRequirement:E.selectedMinimumRequirement,setSelectedMinimumRequirement:E.setSelectedMinimumRequirement,discountData:E.discountData,setDiscountData:E.setDiscountData,currency:E.currency,dynamicDiscountValidationError:E.dynamicDiscountValidationError})})),E.selectedCouponType&&!E.hideExpiration&&t.jsxRuntimeExports.jsxs("div",Object.assign({style:{padding:E.selectedCouponType!==l.DISCOUNT_TYPES.BUY_X_GET_Y?"24px 0 16px":"8px 0",borderTop:E.selectedCouponType!==l.DISCOUNT_TYPES.BUY_X_GET_Y?`1px solid ${u.DEFAULT_THEME.colorsV2.stroke.primary}`:"none"}},{children:[t.jsxRuntimeExports.jsx(r.CheckBox,{label:"Add expiration",isDisabled:!!E.makeExpiryMandatory,isChecked:E.isAddExpirationChecked,onValueChange:e=>{E.setIsAddExpirationChecked(e),E.setDiscountData(Object.assign(Object.assign({},E.discountData),{expireAfter:void 0,expireAt:void 0})),E.setSelectedExpiration(l.COUPON_EXPIRATION.DYNAMIC_EXPIRATION)},boldOnChecked:!0,labelSize:"DEFAULT"}),t.jsxRuntimeExports.jsx(d.BodySecondary,Object.assign({style:{color:u.DEFAULT_THEME.colorsV2.text.secondary,marginLeft:28}},{children:"Make coupon only valid till a certain time"})),E.isAddExpirationChecked&&t.jsxRuntimeExports.jsx(j.CouponExpiration,{discountData:E.discountData,setDiscountData:E.setDiscountData,isAddExpirationChecked:E.isAddExpirationChecked,inValidCouponExpiry:E.dynamicDiscountValidationError.inValidCouponExpiry,selectedExpiration:E.selectedExpiration,setSelectedExpiration:E.setSelectedExpiration})]}))]})};
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../../../_virtual/_tslib.js"),t=require("../../../node_modules/react/jsx-runtime.js"),i=require("../../../assets/icons/info.svg.js"),o=require("../../alerts/Alert.js"),s=require("../../alerts/AlertHelper.js"),n=require("../../button/Button.js"),r=require("../../checkBox/CheckBox.js"),l=require("../type.js");require("../../dropdown/DropdownPopover/index.js");var a=require("../../dropdown/Dropdown.js");require("../../dropdown/ChipDropdown.js"),require("react"),require("../../zeroState/ZeroState.js");var d=require("../../TypographyStyle.js"),u=require("../../../constants/Theme.js");require("../../dropdown/OpenedDropdown/components/description/Description.styled.js"),require("../../list-item/ListItem.js"),require("../../dropdown/OpenedDropdown/components/menu/FreeFormMenu.styled.js"),require("../../dropdown/OpenedDropdown/components/menu/MenuItem.js"),require("../../dropdown/OpenedDropdown/components/menu/MenuList.styled.js"),require("../../dropdown/OpenedDropdown/components/multiSelect/MultiSelectDropdownBottomBar.styled.js"),require("../../dropdown/OpenedDropdown/components/OpennedDropdown.styled.js"),require("../../icon-button/IconButton.js");var c=require("../../input/Input.js"),p=require("../../../assets/icons/cross.svg.js");require("../../dropdown/MenuItem/MenuItem.js");var E,x=require("../../radioButton/RadioButton.js"),T=require("../../../assets/icons/cubeIcon.svg.js"),C=require("../../../assets/icons/delete.svg.js"),D=require("../../../assets/icons/edit.svg.js"),O=require("../../../assets/icons/plus.svg.js"),j=require("../CouponExpiration/CouponExpiration.js"),S=require("../DiscountModal.styled.js"),m=require("./DynamicCoupon.styled.js"),P=require("./MinimumRequirementComponent.js"),I=require("./ZeroState.js");exports.DISCOUNT_PRODUCTS=void 0,(E=exports.DISCOUNT_PRODUCTS||(exports.DISCOUNT_PRODUCTS={})).ENTITLED="entitled",E.PREREQUISITE="prerequisite";exports.default=E=>{var R,v,_,b,g,y,U,h;const N=[{selected:E.discountCouponAppliesTo===l.DISCOUNT_APPLIES_TO.ENTIRE_ORDER,label:"Entire Order",value:l.DISCOUNT_APPLIES_TO.ENTIRE_ORDER},{selected:E.discountCouponAppliesTo===l.DISCOUNT_APPLIES_TO.SPECIFIC_PRODUCTS,label:"Specific Product",value:l.DISCOUNT_APPLIES_TO.SPECIFIC_PRODUCTS},{selected:E.discountCouponAppliesTo===l.DISCOUNT_APPLIES_TO.SPECIFIC_COLLECTIONS,label:"Specific Collections",value:l.DISCOUNT_APPLIES_TO.SPECIFIC_COLLECTIONS}],V=[{selected:E.offerAppliesToBuy===l.OFFER_APPLIES_TO.SPECIFIC_PRODUCTS,label:"Specific Product",value:l.OFFER_APPLIES_TO.SPECIFIC_PRODUCTS},{selected:E.offerAppliesToBuy===l.OFFER_APPLIES_TO.SPECIFIC_COLLECTIONS,label:"Specific Collections",value:l.OFFER_APPLIES_TO.SPECIFIC_COLLECTIONS}],A=[{selected:E.offerAppliesToGet===l.OFFER_APPLIES_TO.SPECIFIC_PRODUCTS,label:"Specific Product",value:l.OFFER_APPLIES_TO.SPECIFIC_PRODUCTS},{selected:E.offerAppliesToGet===l.OFFER_APPLIES_TO.SPECIFIC_COLLECTIONS,label:"Specific Collections",value:l.OFFER_APPLIES_TO.SPECIFIC_COLLECTIONS}],L=(e,r,a)=>{var c,x,j,S,P,I,R,v,_,b,g,y;let U=[],h=[],N={},V={};E.useNewPicker?(N=r===exports.DISCOUNT_PRODUCTS.ENTITLED?E.entitledProducts:E.prerequisiteProducts,V=null!==(c=r===exports.DISCOUNT_PRODUCTS.ENTITLED?E.entitledCollections:E.prerequisiteCollections)&&void 0!==c?c:[],(null==N?void 0:N.isCustom)&&delete N.isCustom,(null==V?void 0:V.isCustom)&&delete V.isCustom,Object.values(N).forEach((e=>{Object.keys(e.products).forEach((t=>{U.push({id:t,name:e.products[t].name,image:e.products[t].image})}))})),Object.keys(V).forEach((e=>{"isCustom"!==e&&h.push({id:e,name:V[e].name,image:V[e].image})}))):(U=r===exports.DISCOUNT_PRODUCTS.ENTITLED?E.entitledProducts:E.prerequisiteProducts,h=null!==(x=r===exports.DISCOUNT_PRODUCTS.ENTITLED?E.entitledCollections:E.prerequisiteCollections)&&void 0!==x?x:[]);const A=[null===(j=E.dynamicDiscountValidationError)||void 0===j?void 0:j.inValidProductSelection,null===(S=E.dynamicDiscountValidationError)||void 0===S?void 0:S.inValidProductVariableSelection,null===(P=E.dynamicDiscountValidationError)||void 0===P?void 0:P.inValidCollectionSelection],L=[null===(I=E.dynamicDiscountValidationError)||void 0===I?void 0:I.inValidBuyXCollectionSelection,null===(R=E.dynamicDiscountValidationError)||void 0===R?void 0:R.inValidBuyXProductSelection,null===(v=E.dynamicDiscountValidationError)||void 0===v?void 0:v.inValidBuyXProductVariableSelection],f=[null===(_=E.dynamicDiscountValidationError)||void 0===_?void 0:_.inValidGetYCollectionSelection,null===(b=E.dynamicDiscountValidationError)||void 0===b?void 0:b.inValidGetYProductSelection,null===(g=E.dynamicDiscountValidationError)||void 0===g?void 0:g.inValidGetYProductVariableSelection];let F=!1;return"couponAppliesTo"===a&&(F=A.some(Boolean)),"buyX"===a&&(F=L.some(Boolean)),"getY"===a&&(F=f.some(Boolean)),t.jsxRuntimeExports.jsxs(t.jsxRuntimeExports.Fragment,{children:[t.jsxRuntimeExports.jsxs("div",Object.assign({style:{display:"flex",gap:18}},{children:[e===l.DISCOUNT_APPLIES_TO.SPECIFIC_PRODUCTS&&0===U.length&&(r===exports.DISCOUNT_PRODUCTS.ENTITLED&&!E.entitledProductVariable||r===exports.DISCOUNT_PRODUCTS.PREREQUISITE&&!E.preRequisiteProductVariable)&&!(null==h?void 0:h.length)&&t.jsxRuntimeExports.jsxs(m.AddProductButtonsContainer,{children:[t.jsxRuntimeExports.jsx("div",Object.assign({style:{width:E.isProductVariableSupported?"284px":"300px",display:"flex"}},{children:t.jsxRuntimeExports.jsx(n.Button,{buttonText:"Add Product(s)",buttonType:"dashRegular",LeadingIcon:O.default,matchParentWidth:!0,onClick:()=>{E.setIsProductPickerOpen(r)},error:F})})),E.isProductVariableSupported&&E.productVariableList&&t.jsxRuntimeExports.jsxs(t.jsxRuntimeExports.Fragment,{children:[t.jsxRuntimeExports.jsx(d.BodySecondary,Object.assign({color:u.DEFAULT_THEME.colorsV2.content.placeholder},{children:"OR"})),t.jsxRuntimeExports.jsx(n.Button,{buttonText:"Add Product(s) Variable",buttonType:"dashRegular",LeadingIcon:O.default,matchParentWidth:!0,onClick:()=>{E.setIsProductVariablePickerOpen(r)},error:F})]})]}),e===l.DISCOUNT_APPLIES_TO.SPECIFIC_COLLECTIONS&&0===h.length&&!(null==U?void 0:U.length)&&t.jsxRuntimeExports.jsx("div",Object.assign({style:{width:"300px",display:"flex"}},{children:t.jsxRuntimeExports.jsx(n.Button,{buttonText:"Add collection(s)",buttonType:"dashRegular",LeadingIcon:O.default,matchParentWidth:!0,onClick:()=>{E.setIsCollectionPickerOpen(r)},style:{marginTop:"16px"},error:F})}))]})),F&&t.jsxRuntimeExports.jsx("div",Object.assign({style:{margin:"8px 0 0"}},{children:t.jsxRuntimeExports.jsx(o.Alert,{type:s.ALERT_TYPES.NEGATIVE,text:"Required Field",contentPosition:s.CONTENT_POSITION.START,icon:()=>t.jsxRuntimeExports.jsx(i.default,{width:16,height:16,color:u.DEFAULT_THEME.colorsV2.content.negative})})})),U.length||h.length?t.jsxRuntimeExports.jsxs("div",{children:[t.jsxRuntimeExports.jsx(d.BodySecondary,Object.assign({style:{margin:"8px 0"}},{children:e===l.DISCOUNT_APPLIES_TO.SPECIFIC_COLLECTIONS?"Collection(s)":"Product(s)"})),t.jsxRuntimeExports.jsxs(m.ProductCollectionCard,{children:[t.jsxRuntimeExports.jsx(m.CubeIconContainer,{children:t.jsxRuntimeExports.jsx(T.default,{width:20,height:20,color:u.DEFAULT_THEME.colorsV2.content.secondary})}),t.jsxRuntimeExports.jsxs(d.TitleSmall,{children:[e===l.DISCOUNT_APPLIES_TO.SPECIFIC_PRODUCTS?U.length:h.length," ",e===l.DISCOUNT_APPLIES_TO.SPECIFIC_PRODUCTS?"Product(s)":"Collection(s)"," ","added"]}),t.jsxRuntimeExports.jsxs("div",Object.assign({style:{display:"flex",gap:4}},{children:[t.jsxRuntimeExports.jsx(m.IconContainer,Object.assign({onClick:()=>{e===l.DISCOUNT_APPLIES_TO.SPECIFIC_PRODUCTS?E.setIsProductPickerOpen(r):E.setIsCollectionPickerOpen(r)}},{children:t.jsxRuntimeExports.jsx(D.default,{width:24,height:24,color:u.DEFAULT_THEME.colorsV2.content.placeholder})})),t.jsxRuntimeExports.jsx(m.IconContainer,Object.assign({onClick:()=>{e===l.DISCOUNT_APPLIES_TO.SPECIFIC_PRODUCTS?r===exports.DISCOUNT_PRODUCTS.ENTITLED?E.setEntitledProducts([]):E.setPrerequisiteProducts([]):r===exports.DISCOUNT_PRODUCTS.ENTITLED?E.setEntitledCollections([]):E.setPrerequisiteCollections([])}},{children:t.jsxRuntimeExports.jsx(C.default,{width:24,height:24,color:u.DEFAULT_THEME.colorsV2.content.placeholder})}))]}))]})]}):r===exports.DISCOUNT_PRODUCTS.ENTITLED&&E.entitledProductVariable?t.jsxRuntimeExports.jsxs("div",{children:[t.jsxRuntimeExports.jsx(d.BodySecondary,Object.assign({style:{margin:"16px 0 8px"}},{children:"Product Variable"})),t.jsxRuntimeExports.jsxs(m.ProductVariableCard,{children:[t.jsxRuntimeExports.jsx(d.TitleSmall,{children:E.entitledProductVariable.displayName}),t.jsxRuntimeExports.jsx("div",Object.assign({style:{display:"flex",gap:4}},{children:t.jsxRuntimeExports.jsx(m.IconContainer,Object.assign({onClick:()=>{E.setEntitledProductVariable(void 0)}},{children:t.jsxRuntimeExports.jsx(p.default,{width:24,height:24,color:u.DEFAULT_THEME.colorsV2.content.primary})}))}))]})]}):r===exports.DISCOUNT_PRODUCTS.PREREQUISITE&&(null===(y=E.preRequisiteProductVariable)||void 0===y?void 0:y.displayName)?t.jsxRuntimeExports.jsxs("div",{children:[t.jsxRuntimeExports.jsx(d.BodySecondary,Object.assign({style:{margin:"16px 0 8px"}},{children:"Product Variable"})),t.jsxRuntimeExports.jsxs(m.ProductVariableCard,{children:[t.jsxRuntimeExports.jsx(d.TitleSmall,{children:E.preRequisiteProductVariable.displayName}),t.jsxRuntimeExports.jsx("div",Object.assign({style:{display:"flex",gap:4}},{children:t.jsxRuntimeExports.jsx(m.IconContainer,Object.assign({onClick:()=>{E.setPreRequisiteProductVariable(void 0)}},{children:t.jsxRuntimeExports.jsx(p.default,{width:24,height:24,color:u.DEFAULT_THEME.colorsV2.content.primary})}))}))]})]}):t.jsxRuntimeExports.jsx(t.jsxRuntimeExports.Fragment,{children:" "})]})},f=(e,i)=>{var o,s,n,r,u,p,x,T,C,D;let O=[],j=[],S={},m={};E.useNewPicker?(S=e===exports.DISCOUNT_PRODUCTS.ENTITLED?E.entitledProducts:E.prerequisiteProducts,m=null!==(o=e===exports.DISCOUNT_PRODUCTS.ENTITLED?E.entitledCollections:E.prerequisiteCollections)&&void 0!==o?o:[],(null==S?void 0:S.isCustom)&&delete S.isCustom,(null==m?void 0:m.isCustom)&&delete m.isCustom,Object.values(S).forEach((e=>{Object.keys(e.products).forEach((t=>{O.push({id:t,name:e.products[t].name,image:e.products[t].image})}))})),Object.keys(m).forEach((e=>{"isCustom"!==e&&j.push({id:e,name:m[e].name,image:m[e].image})}))):(O=e===exports.DISCOUNT_PRODUCTS.ENTITLED?E.entitledProducts:E.prerequisiteProducts,j=null!==(s=e===exports.DISCOUNT_PRODUCTS.ENTITLED?E.entitledCollections:E.prerequisiteCollections)&&void 0!==s?s:[]);const P=e===exports.DISCOUNT_PRODUCTS.PREREQUISITE?E.offerAppliesToBuy:E.offerAppliesToGet,I=e===exports.DISCOUNT_PRODUCTS.PREREQUISITE?exports.DISCOUNT_PRODUCTS.PREREQUISITE:exports.DISCOUNT_PRODUCTS.ENTITLED,R=P===l.OFFER_APPLIES_TO.SPECIFIC_PRODUCTS?l.DISCOUNT_APPLIES_TO.SPECIFIC_PRODUCTS:l.DISCOUNT_APPLIES_TO.SPECIFIC_COLLECTIONS;return t.jsxRuntimeExports.jsxs("div",{children:[t.jsxRuntimeExports.jsx(d.TitleSmall,Object.assign({style:{marginBottom:16}},{children:e===exports.DISCOUNT_PRODUCTS.PREREQUISITE?"Customer buys":"Customer gets"})),t.jsxRuntimeExports.jsxs("div",Object.assign({style:{display:"flex"}},{children:[!i&&t.jsxRuntimeExports.jsx("div",{children:t.jsxRuntimeExports.jsxs("div",Object.assign({className:"input__rows"},{children:[t.jsxRuntimeExports.jsx("div",Object.assign({className:"input__wrapper"},{children:t.jsxRuntimeExports.jsx(c.Input,{value:e===exports.DISCOUNT_PRODUCTS.ENTITLED?null!==(r=null===(n=E.discountData.entitledQuantity)||void 0===n?void 0:n.toString())&&void 0!==r?r:"":null!==(p=null===(u=E.discountData.prerequisiteQuantity)||void 0===u?void 0:u.toString())&&void 0!==p?p:"",type:"number",onChangeText:t=>{e===exports.DISCOUNT_PRODUCTS.ENTITLED?E.setDiscountData(Object.assign(Object.assign({},E.discountData),{entitledQuantity:parseInt(t)})):E.setDiscountData(Object.assign(Object.assign({},E.discountData),{prerequisiteQuantity:parseInt(t)}))},labelText:"Quantity of products",placeholder:"Eg. 2",width:"300px",errorMessage:e===exports.DISCOUNT_PRODUCTS.PREREQUISITE&&(null===(x=E.dynamicDiscountValidationError)||void 0===x?void 0:x.inValidBuyXValue)||e===exports.DISCOUNT_PRODUCTS.ENTITLED&&(null===(T=E.dynamicDiscountValidationError)||void 0===T?void 0:T.inValidGetYValue)?"Required Field":"",state:e===exports.DISCOUNT_PRODUCTS.PREREQUISITE&&(null===(C=E.dynamicDiscountValidationError)||void 0===C?void 0:C.inValidBuyXValue)||e===exports.DISCOUNT_PRODUCTS.ENTITLED&&(null===(D=E.dynamicDiscountValidationError)||void 0===D?void 0:D.inValidGetYValue)?"invalid":"none"})})),t.jsxRuntimeExports.jsx("div",{className:"input__wrapper"})]}))}),t.jsxRuntimeExports.jsxs("div",{children:[t.jsxRuntimeExports.jsx(d.BodySecondary,Object.assign({style:{marginBottom:8}},{children:"Any items from"})),e===exports.DISCOUNT_PRODUCTS.PREREQUISITE&&t.jsxRuntimeExports.jsx(a.Dropdown,{width:"244px",options:V,placement:"bottom-start",onSelect:e=>{var t,i,o;E.setOfferAppliesToBuy(e.value),E.setPrerequisiteProducts([]),E.setPrerequisiteCollections([]),E.setPreRequisiteProductVariable(void 0),E.setDynamicDiscountValidationError((e=>Object.assign(Object.assign({},e),{inValidBuyXCollectionSelection:!1,inValidBuyXProductSelection:!1,inValidBuyXProductVariableSelection:!1}))),E.setDiscountData(Object.assign(Object.assign({},E.discountData),{prerequisiteCollectionIds:[],prerequisiteProductIds:[],collectionsConf:{entitledCollections:null===(t=E.discountData.collectionsConf)||void 0===t?void 0:t.entitledCollections,prerequisiteCollections:{}},productsConf:{entitledProducts:null===(i=E.discountData.productsConf)||void 0===i?void 0:i.entitledProducts,prerequisiteProducts:{}},productVariableConf:{entitledProductVariable:null===(o=E.discountData.productVariableConf)||void 0===o?void 0:o.entitledProductVariable,prerequisiteProductVariable:{}}}))}}),e===exports.DISCOUNT_PRODUCTS.ENTITLED&&t.jsxRuntimeExports.jsx(a.Dropdown,{width:"244px",options:A,placement:"bottom-start",onSelect:e=>{var t,i,o;E.setOfferAppliesToGet(e.value),E.setEntitledProducts([]),E.setEntitledCollections([]),E.setEntitledProductVariable(void 0),E.setDynamicDiscountValidationError((e=>Object.assign(Object.assign({},e),{inValidGetYCollectionSelection:!1,inValidGetYProductSelection:!1,inValidGetYProductVariableSelection:!1}))),E.setDiscountData(Object.assign(Object.assign({},E.discountData),{entitledCollectionIds:[],entitledProductIds:[],collectionsConf:{entitledCollections:{},prerequisiteCollections:null===(t=E.discountData.collectionsConf)||void 0===t?void 0:t.prerequisiteCollections},productsConf:{entitledProducts:{},prerequisiteProducts:null===(i=E.discountData.productsConf)||void 0===i?void 0:i.prerequisiteProducts},productVariableConf:{entitledProductVariable:{},prerequisiteProductVariable:null===(o=E.discountData.productVariableConf)||void 0===o?void 0:o.prerequisiteProductVariable}}))}})]})]})),L(R,I,e===exports.DISCOUNT_PRODUCTS.PREREQUISITE?"buyX":"getY")]})};return t.jsxRuntimeExports.jsxs(S.DynamicCouponContainer,Object.assign({style:E.noTopMargin?{marginTop:0}:{}},{children:[t.jsxRuntimeExports.jsxs("div",{children:[t.jsxRuntimeExports.jsxs("div",Object.assign({style:{display:"flex",gap:16}},{children:[t.jsxRuntimeExports.jsx("div",Object.assign({className:"input__wrapper"},{children:t.jsxRuntimeExports.jsx(c.Input,{value:null!==(R=E.discountData.title)&&void 0!==R?R:"",onChangeText:e=>{var t;E.setDiscountData(Object.assign(Object.assign({},E.discountData),{title:null!==(t=null==e?void 0:e.trim())&&void 0!==t?t:""}))},maxCharLimit:30,labelText:"Discount Coupon Title",placeholder:`Eg. “Flat ${null!==(v=E.currency)&&void 0!==v?v:""} 15 Off”`,hintText:"Will be same for everyone. Can’t be changed later",width:"300px",isRequired:!0,errorMessage:(null===(_=E.dynamicDiscountValidationError)||void 0===_?void 0:_.invalidCouponTitle)?"Required Field":"",state:(null===(b=E.dynamicDiscountValidationError)||void 0===b?void 0:b.invalidCouponTitle)?"invalid":"none"})})),!E.hideProbability&&t.jsxRuntimeExports.jsx(c.Input,{value:null!==(y=null===(g=E.discountData.probability)||void 0===g?void 0:g.toString())&&void 0!==y?y:"",type:"number",onChangeText:e=>{E.setDiscountData(Object.assign(Object.assign({},E.discountData),{probability:e.startsWith(".")?parseFloat(parseFloat(`0${e}`).toFixed(2)):parseFloat(parseFloat(e).toFixed(2))}))},labelText:"Probability of getting coupon ",hintText:"Enter a decimal value between 0-1",placeholder:"Eg. 0.5",maxCharLimit:4,width:"300px",isRequired:!0,errorMessage:(null===(U=E.dynamicDiscountValidationError)||void 0===U?void 0:U.inValidProbability)?"Required Field":"",state:(null===(h=E.dynamicDiscountValidationError)||void 0===h?void 0:h.inValidProbability)?"invalid":"none"})]})),t.jsxRuntimeExports.jsx("div",{style:{height:"1px",width:"100%",background:u.DEFAULT_THEME.colorsV2.stroke.primary,margin:"24px 0 8px"}})]}),E.allowStaticCoupon&&t.jsxRuntimeExports.jsx((()=>t.jsxRuntimeExports.jsxs("div",{children:[t.jsxRuntimeExports.jsx(d.TitleRegular,{children:"Discount Details"}),t.jsxRuntimeExports.jsx(m.DiscountOptionsContainer,{children:E.discountDetailsOptions.map((i=>{return t.jsxRuntimeExports.jsxs(m.DiscountDetailsOption,Object.assign({selected:E.selectedDiscountDetails.id===i.id,onClick:()=>(t=>{if(E.selectedDiscountDetails.id!==t.id)if(E.resetValidationErrors(),E.setValidationErrorMessage(""),E.setDiscountCouponAppliesTo(l.DISCOUNT_APPLIES_TO.ENTIRE_ORDER),E.setSelectedDiscountDetails(t),E.setDiscountData(Object.assign(Object.assign({},E.discountData),{value:void 0})),E.setPreRequisiteProductVariable(void 0),E.setEntitledProductVariable(void 0),["percentage","amount"].includes(t.value)){E.onChangeCouponType({label:"Amount off on order",selected:!0,value:l.DISCOUNT_TYPES.AMOUNT_OFF_ORDER});const i=Object.assign(Object.assign({},E.discountData),{valueType:"percentage"===t.value?l.DISCOUNT_VALUE_TYPES.PERCENTAGE:l.DISCOUNT_VALUE_TYPES.FIXED_AMOUNT,value:void 0,targetType:l.DISCOUNT_TARGET_TYPES.LINE_ITEM,targetSelection:l.DISCOUNT_TARGET_SELECTION.ALL,entitledCollectionIds:[],entitledProductIds:[],prerequisiteCollectionIds:[],prerequisiteProductIds:[],collectionsConf:{entitledCollections:{},prerequisiteCollections:{}},productsConf:{entitledProducts:{},prerequisiteProducts:{}},productVariableConf:{entitledProductVariable:{},prerequisiteProductVariable:{}}}),o=e.__rest(i,["entitledQuantity","prerequisiteQuantity"]);E.setDiscountData(o)}else E.onChangeCouponType({label:t.label,selected:!0,value:t.value})})(i)},{children:[i.icon((o=i.id,E.selectedDiscountDetails.id===o?u.DEFAULT_THEME.colorsV2.stroke.brand:u.DEFAULT_THEME.colorsV2.text.secondary)),i.label]}),i.id);var o}))})]})),{}),(E.selectedCouponType===l.DISCOUNT_TYPES.AMOUNT_OFF_ORDER||E.selectedCouponType===l.DISCOUNT_TYPES.AMOUNT_OFF_PRODUCTS)&&(()=>{var e,i,o,s,n,r;return t.jsxRuntimeExports.jsxs(t.jsxRuntimeExports.Fragment,{children:[t.jsxRuntimeExports.jsx("div",Object.assign({className:"input__rows"},{children:t.jsxRuntimeExports.jsx("div",Object.assign({className:"input__wrapper"},{children:t.jsxRuntimeExports.jsx(c.Input,{value:null!==(o=null===(i=null===(e=E.discountData)||void 0===e?void 0:e.value)||void 0===i?void 0:i.toString())&&void 0!==o?o:"",labelText:"Discount amount",type:"number",width:"300px",onChangeText:e=>{E.setDiscountData(Object.assign(Object.assign({},E.discountData),{value:parseInt(e)}))},placeholder:"15",prefixText:E.discountData.valueType===l.DISCOUNT_VALUE_TYPES.FIXED_AMOUNT?null!==(s=E.currency)&&void 0!==s?s:"":void 0,suffixText:E.discountData.valueType===l.DISCOUNT_VALUE_TYPES.PERCENTAGE?"%":void 0,errorMessage:(null===(n=E.dynamicDiscountValidationError)||void 0===n?void 0:n.inValidDiscountAmount)?"Required Field":"",state:(null===(r=E.dynamicDiscountValidationError)||void 0===r?void 0:r.inValidDiscountAmount)?"invalid":"none"})}))})),t.jsxRuntimeExports.jsx("div",Object.assign({style:{paddingTop:"24px",marginTop:16,borderTop:`1px solid ${u.DEFAULT_THEME.colorsV2.stroke.primary}`}},{children:t.jsxRuntimeExports.jsxs("div",Object.assign({className:"input__wrapper"},{children:[t.jsxRuntimeExports.jsx(d.TitleRegular,Object.assign({style:{marginBottom:10}},{children:"Applies to"})),t.jsxRuntimeExports.jsx("div",Object.assign({style:{display:"flex",flexGrow:0,flexShrink:0,flexBasis:"auto"}},{children:t.jsxRuntimeExports.jsx(a.Dropdown,{width:"300px",options:N,placement:"bottom-start",onSelect:e=>{const t="value"in e&&e.value===l.DISCOUNT_APPLIES_TO.ENTIRE_ORDER?{label:"Amount off on order",selected:!0,value:l.DISCOUNT_TYPES.AMOUNT_OFF_ORDER}:{label:"Amount off on products",selected:!0,value:l.DISCOUNT_TYPES.AMOUNT_OFF_PRODUCTS};E.onChangeCouponType(t),E.setDiscountCouponAppliesTo(e.value),E.setEntitledProductVariable(void 0),E.setDynamicDiscountValidationError((e=>Object.assign(Object.assign({},e),{inValidProductVariableSelection:!1,inValidProductSelection:!1,inValidCollectionSelection:!1})))}})})),(E.discountCouponAppliesTo===l.DISCOUNT_APPLIES_TO.SPECIFIC_PRODUCTS||E.discountCouponAppliesTo===l.DISCOUNT_APPLIES_TO.SPECIFIC_COLLECTIONS)&&L(E.discountCouponAppliesTo,exports.DISCOUNT_PRODUCTS.ENTITLED,"couponAppliesTo")]}))}))]})})(),E.selectedCouponType===l.DISCOUNT_TYPES.BUY_X_GET_Y&&(()=>{var e,i,o,s,n;return t.jsxRuntimeExports.jsxs(S.DynamicCouponContainer,Object.assign({style:{border:`1px solid ${u.DEFAULT_THEME.colorsV2.stroke.primary}`,padding:"16px",borderRadius:"4px",margin:0}},{children:[f(exports.DISCOUNT_PRODUCTS.PREREQUISITE),t.jsxRuntimeExports.jsx("div",{style:{width:"100%",height:"1px",backgroundColor:u.DEFAULT_THEME.colorsV2.stroke.primary,margin:"8px 0"}}),f(exports.DISCOUNT_PRODUCTS.ENTITLED),t.jsxRuntimeExports.jsx(d.BodySecondary,Object.assign({style:{marginTop:"8px"}},{children:"At a discounted value"})),t.jsxRuntimeExports.jsx("div",{children:t.jsxRuntimeExports.jsx(x.RadioButton,{label:"Free",isActive:100===E.discountData.value,onValueChange:e=>{e?E.setDiscountData(Object.assign(Object.assign({},E.discountData),{value:100})):E.setDiscountData(Object.assign(Object.assign({},E.discountData),{value:void 0}))}})}),t.jsxRuntimeExports.jsxs("div",Object.assign({style:{display:"flex",flexDirection:"column"}},{children:[t.jsxRuntimeExports.jsx(x.RadioButton,{label:"Percentage off",isActive:100!==E.discountData.value,onValueChange:()=>{E.setDiscountData(Object.assign(Object.assign({},E.discountData),{value:void 0}))}}),100!==E.discountData.value&&t.jsxRuntimeExports.jsx("div",Object.assign({style:{marginTop:8}},{children:t.jsxRuntimeExports.jsx(c.Input,{value:null!==(o=null===(i=null===(e=E.discountData)||void 0===e?void 0:e.value)||void 0===i?void 0:i.toString())&&void 0!==o?o:"",onChangeText:e=>{E.setDiscountData(Object.assign(Object.assign({},E.discountData),{value:parseInt(e)}))},type:"number",placeholder:"Eg. 50",suffixText:"%",width:"300px",errorMessage:(null===(s=E.dynamicDiscountValidationError)||void 0===s?void 0:s.inValidDiscountAmount)?"Required Field":"",state:(null===(n=E.dynamicDiscountValidationError)||void 0===n?void 0:n.inValidDiscountAmount)?"invalid":"none"})}))]}))]}))})(),!E.selectedCouponType&&t.jsxRuntimeExports.jsx(I.default,{}),E.allowStaticCoupon&&E.selectedCouponType!==l.DISCOUNT_TYPES.BUY_X_GET_Y&&t.jsxRuntimeExports.jsx("div",Object.assign({style:{padding:"24px 0 16px",marginTop:16,borderTop:`1px solid ${u.DEFAULT_THEME.colorsV2.stroke.primary}`}},{children:t.jsxRuntimeExports.jsx(P.default,{selectedMinimumRequirement:E.selectedMinimumRequirement,setSelectedMinimumRequirement:E.setSelectedMinimumRequirement,discountData:E.discountData,setDiscountData:E.setDiscountData,currency:E.currency,dynamicDiscountValidationError:E.dynamicDiscountValidationError})})),E.selectedCouponType&&!E.hideExpiration&&t.jsxRuntimeExports.jsxs("div",Object.assign({style:{padding:E.selectedCouponType!==l.DISCOUNT_TYPES.BUY_X_GET_Y?"24px 0 16px":"8px 0",borderTop:E.selectedCouponType!==l.DISCOUNT_TYPES.BUY_X_GET_Y?`1px solid ${u.DEFAULT_THEME.colorsV2.stroke.primary}`:"none"}},{children:[t.jsxRuntimeExports.jsx(r.CheckBox,{label:"Add expiration",isDisabled:!!E.makeExpiryMandatory,isChecked:E.isAddExpirationChecked,onValueChange:e=>{E.setIsAddExpirationChecked(e),E.setDiscountData(Object.assign(Object.assign({},E.discountData),{expireAfter:void 0,expireAt:void 0})),E.setSelectedExpiration(E.isUsageFromStatic?l.COUPON_EXPIRATION.FIXED_EXPIRATION:l.COUPON_EXPIRATION.DYNAMIC_EXPIRATION)},boldOnChecked:!0,labelSize:"DEFAULT"}),t.jsxRuntimeExports.jsx(d.BodySecondary,Object.assign({style:{color:u.DEFAULT_THEME.colorsV2.text.secondary,marginLeft:28}},{children:"Make coupon only valid till a certain time"})),E.isAddExpirationChecked&&t.jsxRuntimeExports.jsx(j.CouponExpiration,{discountData:E.discountData,setDiscountData:E.setDiscountData,isAddExpirationChecked:E.isAddExpirationChecked,inValidCouponExpiry:E.dynamicDiscountValidationError.inValidCouponExpiry,selectedExpiration:E.selectedExpiration,setSelectedExpiration:E.setSelectedExpiration,hideExpirationOptions:E.isUsageFromStatic})]}))]}))};