@bikdotai/bik-component-library 0.0.693-beta.0 → 0.0.693-beta.1

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 (31) hide show
  1. package/dist/cjs/components/bik-layout/MockMenus.d.ts +1 -0
  2. package/dist/cjs/components/data-source-panel/DataSourceInfoFooter.js +1 -1
  3. package/dist/cjs/components/data-source-panel/DataSourcePanel.js +1 -1
  4. package/dist/cjs/components/discount-modal/DiscountModal.js +1 -1
  5. package/dist/cjs/components/product-picker-v2/modal.js +1 -1
  6. package/dist/cjs/components/template-context-mapper/modalElements/EditWhatsAppCarouselTemplateV2.js +1 -1
  7. package/dist/cjs/components/unsatisfactory-response-list/UnsatisfactoryResponseList.js +1 -1
  8. package/dist/esm/components/bik-layout/MockMenus.d.ts +1 -0
  9. package/dist/esm/components/data-source-panel/DataSourceInfoFooter.js +1 -1
  10. package/dist/esm/components/data-source-panel/DataSourcePanel.js +1 -1
  11. package/dist/esm/components/discount-modal/DiscountModal.js +1 -1
  12. package/dist/esm/components/product-picker-v2/modal.js +1 -1
  13. package/dist/esm/components/template-context-mapper/modalElements/EditWhatsAppCarouselTemplateV2.js +1 -1
  14. package/dist/esm/components/unsatisfactory-response-list/UnsatisfactoryResponseList.js +1 -1
  15. package/package.json +1 -1
  16. package/dist/cjs/_virtual/bik-store.js +0 -1
  17. package/dist/cjs/_virtual/billing.js +0 -1
  18. package/dist/cjs/_virtual/index.js +0 -1
  19. package/dist/cjs/_virtual/store.js +0 -1
  20. package/dist/cjs/node_modules/@bikdotai/bik-models/growth/index.js +0 -1
  21. package/dist/cjs/node_modules/@bikdotai/bik-models/growth/models/bik-store.js +0 -1
  22. package/dist/cjs/node_modules/@bikdotai/bik-models/growth/models/billing.js +0 -1
  23. package/dist/cjs/node_modules/@bikdotai/bik-models/growth/models/store.js +0 -1
  24. package/dist/esm/_virtual/bik-store.js +0 -1
  25. package/dist/esm/_virtual/billing.js +0 -1
  26. package/dist/esm/_virtual/index.js +0 -1
  27. package/dist/esm/_virtual/store.js +0 -1
  28. package/dist/esm/node_modules/@bikdotai/bik-models/growth/index.js +0 -1
  29. package/dist/esm/node_modules/@bikdotai/bik-models/growth/models/bik-store.js +0 -1
  30. package/dist/esm/node_modules/@bikdotai/bik-models/growth/models/billing.js +0 -1
  31. package/dist/esm/node_modules/@bikdotai/bik-models/growth/models/store.js +0 -1
@@ -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");require("../../node_modules/@bikdotai/bik-models/growth/index.js");var t=require("../../assets/icons/alert_triangle.svg.js"),s=require("../../assets/icons/plus.svg.js"),o=require("react"),n=require("../../constants/Theme.js"),i=require("../button/Button.js"),r=require("../shimmer/ShimmerComponent/BikShimmer.js"),a=require("../TypographyStyle.js"),d=require("./DataSourcePanel.style.js"),l=require("../../_virtual/index.js");const u=o.memo((u=>{const{appType:x,sourceIntent:m,hideHeading:j,messageSource:h,trainingSourceCount:g={},ShowTrainingDataSource:v={},faqCount:R,ChecklistType:E,footerButtonOption:y,isFooterLoading:T,reasonForAiGeneratedResponse:b,showAiResponseReason:A}=u,_=v,[O,C]=o.useState(!0),[S,f]=o.useState(!0),I="/bik-ai/training",[F,w]=o.useState({buttonTitle:"",redirectUrl:"",addFaqProps:{}}),[N,k]=o.useState({title:"",subTitle:""}),q=o.useMemo((()=>{const e=(null==g?void 0:g[m])||0;return e<=1?"There is "+e+"data source added to the identified intent":`There are ${e} data sources added to the identified intent`}),[g,m]),D=()=>{var e;(null==F?void 0:F.redirectUrl)?window.open(`${window.location.origin}${null==F?void 0:F.redirectUrl}`,"_self"):Object.keys(null!==(e=null==F?void 0:F.addFaqProps)&&void 0!==e?e:{}).length>0?null==y||y.onClick(F):(null==y?void 0:y.navigate)&&(null==y||y.navigate("Training",x==l.__exports.ApplicationType.MANIFEST?{tab:"/custom_data"}:{},{},!0))};return o.useEffect((()=>{var e,t,s,o;if(m){if(null===(e=null==h?void 0:h.sources)||void 0===e?void 0:e.length){const e=h.sources[0];if(_[m])m===E.ORDER_ENQUIRY&&f(!1);else{let n=null==e?void 0:e.insights,i="";switch(m){case E.PRODUCT_DETAILS:"Product reviews"!==(null==e?void 0:e.title)&&(n=`${R||"No"} FAQs added for this product`,i="Add product-specific information via FAQs to improve responses",w({buttonTitle:"Add FAQ",addFaqProps:{faqProducts:[{id:null==e?void 0:e.productId,variantId:null==e?void 0:e.variantId,name:null==e?void 0:e.title,imageUrl:null==e?void 0:e.imageUrl}]},redirectUrl:""}));break;case E.ORDER_MODIFICATION:n=(null==g?void 0:g[m])?void 0:"Customers who are looking to modify their orders would be redirected to your live agents via the agent handover flow.",n&&w({buttonTitle:x==l.__exports.ApplicationType.MANIFEST?"Manage agent handover":"Add relevant data",redirectUrl:x==l.__exports.ApplicationType.MANIFEST?"/customise?tab=AgentHandover":I,addFaqProps:{}});break;case E.ORDER_CANCELLATION:n=(null==g?void 0:g[m])?void 0:"Customers who are looking to cancel their orders would be redirected to your live agents via the agent handover flow.",w({buttonTitle:x==l.__exports.ApplicationType.MANIFEST?"Manage agent handover":"Add relevant data",redirectUrl:x==l.__exports.ApplicationType.MANIFEST?"/customise?tab=AgentHandover":I,addFaqProps:{}});break;case E.ORDER_TRACKING:if("ORDER_NOT_FOUND"===(null==e?void 0:e.subIntent))break;w({buttonTitle:x==l.__exports.ApplicationType.MANIFEST?"Add order tracking link":"Add relevant data",redirectUrl:x==l.__exports.ApplicationType.MANIFEST?"/training/order-management":I,addFaqProps:{}});break;case E.PRODUCT_SEARCH:if("QUIZ"===(null==e?void 0:e.type))break;if(-1!==(null===(o=null===(s=null===(t=null==h?void 0:h.sources)||void 0===t?void 0:t[0])||void 0===s?void 0:s.title)||void 0===o?void 0:o.toLowerCase().indexOf("collection"))){n="Collections are recommended by matching queries with collection names and descriptions. Add relevant keywords to your collection description to improve results.";break}n="Products are recommended by matching queries with product names, descriptions, tags, and collections. Add relevant keywords and tags to your products to improve results."}k({title:null!=n?n:"",subTitle:i})}}(_[m]||[E.PRODUCT_DETAILS,E.ORDER_MODIFICATION,E.ORDER_CANCELLATION,E.ORDER_TRACKING].includes(m))&&C(!1)}}),[null==h?void 0:h.messageId,g,m,null==h?void 0:h.sources,_,E,R,x,h]),e.jsxRuntimeExports.jsx(d.SourceInfoFooterStyle,{children:T?e.jsxRuntimeExports.jsx(e.jsxRuntimeExports.Fragment,{children:e.jsxRuntimeExports.jsx(r.BikShimmer,{gap:"8px",direction:"column",boxes:[{height:"20px",width:"300px"},{height:"80px",width:"300px"}]})}):e.jsxRuntimeExports.jsx(e.jsxRuntimeExports.Fragment,{children:!(null==N?void 0:N.title)&&g&&m in g?e.jsxRuntimeExports.jsxs(e.jsxRuntimeExports.Fragment,{children:[e.jsxRuntimeExports.jsx(c,{hideHeading:null!=j&&j}),e.jsxRuntimeExports.jsx(p,{reason:b||"",showAiResponseReason:null!=A&&A}),e.jsxRuntimeExports.jsxs("div",Object.assign({className:"source_info_details "+(g[m]>0?"":"no_data_source")},{children:[g[m]>0&&S?e.jsxRuntimeExports.jsxs(e.jsxRuntimeExports.Fragment,{children:[e.jsxRuntimeExports.jsx(a.BodyCaption,{children:q}),e.jsxRuntimeExports.jsx(a.BodyCaption,Object.assign({color:n.COLORS.content.secondary},{children:"Improve responses by adding more data sources for the identified intent"}))]}):S&&e.jsxRuntimeExports.jsxs("div",Object.assign({className:"no_data_source_title"},{children:[e.jsxRuntimeExports.jsx(t.default,{width:15,height:15,color:n.COLORS.content.negative,style:{marginTop:2}}),e.jsxRuntimeExports.jsx(a.BodyCaption,{children:"No data sources added to the identified link"})]})),!y||y.hideAddDataButton||O?e.jsxRuntimeExports.jsx(e.jsxRuntimeExports.Fragment,{}):e.jsxRuntimeExports.jsx(i.Button,{size:"small",buttonType:"tertiary",LeadingIcon:s.default,buttonText:(null==F?void 0:F.buttonTitle.length)>0?null==F?void 0:F.buttonTitle:"Add relevant data",matchParentWidth:!0,onClick:()=>D(),style:{backgroundColor:"unset"}})]}))]}):e.jsxRuntimeExports.jsxs(e.jsxRuntimeExports.Fragment,{children:[e.jsxRuntimeExports.jsx(c,{hideHeading:null!=j&&j}),e.jsxRuntimeExports.jsx(p,{reason:b||"",showAiResponseReason:null!=A&&A}),e.jsxRuntimeExports.jsxs("div",Object.assign({className:"source_info_details"},{children:[S&&e.jsxRuntimeExports.jsxs(e.jsxRuntimeExports.Fragment,{children:[e.jsxRuntimeExports.jsx(a.BodyCaption,{children:null==N?void 0:N.title}),e.jsxRuntimeExports.jsx(a.BodyCaption,Object.assign({color:n.COLORS.content.secondary},{children:null==N?void 0:N.subTitle}))]}),!y||y.hideAddDataButton||O?e.jsxRuntimeExports.jsx(e.jsxRuntimeExports.Fragment,{}):e.jsxRuntimeExports.jsx(i.Button,{size:"small",buttonType:"tertiary",LeadingIcon:s.default,buttonText:(null==F?void 0:F.buttonTitle.length)>0?null==F?void 0:F.buttonTitle:"Add relevant data",matchParentWidth:!0,onClick:()=>D(),style:{backgroundColor:"unset"}})]}))]})})})})),c=o.memo((t=>t.hideHeading?null:e.jsxRuntimeExports.jsx(a.BodyCaption,Object.assign({color:n.COLORS.content.secondary},{children:"Training insights"})))),p=o.memo((t=>{const[s,i]=o.useState(!1),r=t.reason&&t.reason.length>50,d=r&&!s?t.reason.substring(0,50)+"...":t.reason;return t.showAiResponseReason?e.jsxRuntimeExports.jsxs("div",Object.assign({className:"source_info_details"},{children:[e.jsxRuntimeExports.jsx(a.BodyCaption,Object.assign({color:n.COLORS.content.primary,className:"why_ai_gave_this_response"},{children:"Here’s why your AI gave this response"})),e.jsxRuntimeExports.jsxs(a.BodyCaption,Object.assign({color:n.COLORS.content.secondary,className:"clamp-text"},{children:[d||"No reason provided for this response.",r&&e.jsxRuntimeExports.jsx(a.BodyCaption,Object.assign({color:n.COLORS.content.brand,style:{cursor:"pointer",textDecoration:"underline",marginTop:"4px"},onClick:()=>i(!s)},{children:s?"Show less":"Show more"}))]}))]})):e.jsxRuntimeExports.jsx(e.jsxRuntimeExports.Fragment,{})}));p.displayName="WhyAiGaveThisResponse",c.displayName="TrainingInsightsHeading",u.displayName="SourceInfoFooter",exports.default=u;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../../node_modules/react/jsx-runtime.js"),t=require("@bikdotai/bik-models/growth"),s=require("../../assets/icons/alert_triangle.svg.js"),o=require("../../assets/icons/plus.svg.js"),n=require("react"),i=require("../../constants/Theme.js"),r=require("../button/Button.js"),a=require("../shimmer/ShimmerComponent/BikShimmer.js"),d=require("../TypographyStyle.js"),l=require("./DataSourcePanel.style.js");const u=n.memo((u=>{const{appType:x,sourceIntent:m,hideHeading:j,messageSource:h,trainingSourceCount:g={},ShowTrainingDataSource:R={},faqCount:v,ChecklistType:E,footerButtonOption:y,isFooterLoading:T,reasonForAiGeneratedResponse:b,showAiResponseReason:A}=u,O=R,[C,S]=n.useState(!0),[f,I]=n.useState(!0),_="/bik-ai/training",[F,w]=n.useState({buttonTitle:"",redirectUrl:"",addFaqProps:{}}),[N,k]=n.useState({title:"",subTitle:""}),D=n.useMemo((()=>{const e=(null==g?void 0:g[m])||0;return e<=1?"There is "+e+"data source added to the identified intent":`There are ${e} data sources added to the identified intent`}),[g,m]),q=()=>{var e;(null==F?void 0:F.redirectUrl)?window.open(`${window.location.origin}${null==F?void 0:F.redirectUrl}`,"_self"):Object.keys(null!==(e=null==F?void 0:F.addFaqProps)&&void 0!==e?e:{}).length>0?null==y||y.onClick(F):(null==y?void 0:y.navigate)&&(null==y||y.navigate("Training",x==t.ApplicationType.MANIFEST?{tab:"/custom_data"}:{},{},!0))};return n.useEffect((()=>{var e,s,o,n;if(m){if(null===(e=null==h?void 0:h.sources)||void 0===e?void 0:e.length){const e=h.sources[0];if(O[m])m===E.ORDER_ENQUIRY&&I(!1);else{let i=null==e?void 0:e.insights,r="";switch(m){case E.PRODUCT_DETAILS:"Product reviews"!==(null==e?void 0:e.title)&&(i=`${v||"No"} FAQs added for this product`,r="Add product-specific information via FAQs to improve responses",w({buttonTitle:"Add FAQ",addFaqProps:{faqProducts:[{id:null==e?void 0:e.productId,variantId:null==e?void 0:e.variantId,name:null==e?void 0:e.title,imageUrl:null==e?void 0:e.imageUrl}]},redirectUrl:""}));break;case E.ORDER_MODIFICATION:i=(null==g?void 0:g[m])?void 0:"Customers who are looking to modify their orders would be redirected to your live agents via the agent handover flow.",i&&w({buttonTitle:x==t.ApplicationType.MANIFEST?"Manage agent handover":"Add relevant data",redirectUrl:x==t.ApplicationType.MANIFEST?"/customise?tab=AgentHandover":_,addFaqProps:{}});break;case E.ORDER_CANCELLATION:i=(null==g?void 0:g[m])?void 0:"Customers who are looking to cancel their orders would be redirected to your live agents via the agent handover flow.",w({buttonTitle:x==t.ApplicationType.MANIFEST?"Manage agent handover":"Add relevant data",redirectUrl:x==t.ApplicationType.MANIFEST?"/customise?tab=AgentHandover":_,addFaqProps:{}});break;case E.ORDER_TRACKING:if("ORDER_NOT_FOUND"===(null==e?void 0:e.subIntent))break;w({buttonTitle:x==t.ApplicationType.MANIFEST?"Add order tracking link":"Add relevant data",redirectUrl:x==t.ApplicationType.MANIFEST?"/training/order-management":_,addFaqProps:{}});break;case E.PRODUCT_SEARCH:if("QUIZ"===(null==e?void 0:e.type))break;if(-1!==(null===(n=null===(o=null===(s=null==h?void 0:h.sources)||void 0===s?void 0:s[0])||void 0===o?void 0:o.title)||void 0===n?void 0:n.toLowerCase().indexOf("collection"))){i="Collections are recommended by matching queries with collection names and descriptions. Add relevant keywords to your collection description to improve results.";break}i="Products are recommended by matching queries with product names, descriptions, tags, and collections. Add relevant keywords and tags to your products to improve results."}k({title:null!=i?i:"",subTitle:r})}}(O[m]||[E.PRODUCT_DETAILS,E.ORDER_MODIFICATION,E.ORDER_CANCELLATION,E.ORDER_TRACKING].includes(m))&&S(!1)}}),[null==h?void 0:h.messageId,g,m,null==h?void 0:h.sources,O,E,v,x,h]),e.jsxRuntimeExports.jsx(l.SourceInfoFooterStyle,{children:T?e.jsxRuntimeExports.jsx(e.jsxRuntimeExports.Fragment,{children:e.jsxRuntimeExports.jsx(a.BikShimmer,{gap:"8px",direction:"column",boxes:[{height:"20px",width:"300px"},{height:"80px",width:"300px"}]})}):e.jsxRuntimeExports.jsx(e.jsxRuntimeExports.Fragment,{children:!(null==N?void 0:N.title)&&g&&m in g?e.jsxRuntimeExports.jsxs(e.jsxRuntimeExports.Fragment,{children:[e.jsxRuntimeExports.jsx(c,{hideHeading:null!=j&&j}),e.jsxRuntimeExports.jsx(p,{reason:b||"",showAiResponseReason:null!=A&&A}),e.jsxRuntimeExports.jsxs("div",Object.assign({className:"source_info_details "+(g[m]>0?"":"no_data_source")},{children:[g[m]>0&&f?e.jsxRuntimeExports.jsxs(e.jsxRuntimeExports.Fragment,{children:[e.jsxRuntimeExports.jsx(d.BodyCaption,{children:D}),e.jsxRuntimeExports.jsx(d.BodyCaption,Object.assign({color:i.COLORS.content.secondary},{children:"Improve responses by adding more data sources for the identified intent"}))]}):f&&e.jsxRuntimeExports.jsxs("div",Object.assign({className:"no_data_source_title"},{children:[e.jsxRuntimeExports.jsx(s.default,{width:15,height:15,color:i.COLORS.content.negative,style:{marginTop:2}}),e.jsxRuntimeExports.jsx(d.BodyCaption,{children:"No data sources added to the identified link"})]})),!y||y.hideAddDataButton||C?e.jsxRuntimeExports.jsx(e.jsxRuntimeExports.Fragment,{}):e.jsxRuntimeExports.jsx(r.Button,{size:"small",buttonType:"tertiary",LeadingIcon:o.default,buttonText:(null==F?void 0:F.buttonTitle.length)>0?null==F?void 0:F.buttonTitle:"Add relevant data",matchParentWidth:!0,onClick:()=>q(),style:{backgroundColor:"unset"}})]}))]}):e.jsxRuntimeExports.jsxs(e.jsxRuntimeExports.Fragment,{children:[e.jsxRuntimeExports.jsx(c,{hideHeading:null!=j&&j}),e.jsxRuntimeExports.jsx(p,{reason:b||"",showAiResponseReason:null!=A&&A}),e.jsxRuntimeExports.jsxs("div",Object.assign({className:"source_info_details"},{children:[f&&e.jsxRuntimeExports.jsxs(e.jsxRuntimeExports.Fragment,{children:[e.jsxRuntimeExports.jsx(d.BodyCaption,{children:null==N?void 0:N.title}),e.jsxRuntimeExports.jsx(d.BodyCaption,Object.assign({color:i.COLORS.content.secondary},{children:null==N?void 0:N.subTitle}))]}),!y||y.hideAddDataButton||C?e.jsxRuntimeExports.jsx(e.jsxRuntimeExports.Fragment,{}):e.jsxRuntimeExports.jsx(r.Button,{size:"small",buttonType:"tertiary",LeadingIcon:o.default,buttonText:(null==F?void 0:F.buttonTitle.length)>0?null==F?void 0:F.buttonTitle:"Add relevant data",matchParentWidth:!0,onClick:()=>q(),style:{backgroundColor:"unset"}})]}))]})})})})),c=n.memo((t=>t.hideHeading?null:e.jsxRuntimeExports.jsx(d.BodyCaption,Object.assign({color:i.COLORS.content.secondary},{children:"Training insights"})))),p=n.memo((t=>{const[s,o]=n.useState(!1),r=t.reason&&t.reason.length>50,a=r&&!s?t.reason.substring(0,50)+"...":t.reason;return t.showAiResponseReason?e.jsxRuntimeExports.jsxs("div",Object.assign({className:"source_info_details"},{children:[e.jsxRuntimeExports.jsx(d.BodyCaption,Object.assign({color:i.COLORS.content.primary,className:"why_ai_gave_this_response"},{children:"Here’s why your AI gave this response"})),e.jsxRuntimeExports.jsxs(d.BodyCaption,Object.assign({color:i.COLORS.content.secondary,className:"clamp-text"},{children:[a||"No reason provided for this response.",r&&e.jsxRuntimeExports.jsx(d.BodyCaption,Object.assign({color:i.COLORS.content.brand,style:{cursor:"pointer",textDecoration:"underline",marginTop:"4px"},onClick:()=>o(!s)},{children:s?"Show less":"Show more"}))]}))]})):e.jsxRuntimeExports.jsx(e.jsxRuntimeExports.Fragment,{})}));p.displayName="WhyAiGaveThisResponse",c.displayName="TrainingInsightsHeading",u.displayName="SourceInfoFooter",exports.default=u;
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../../node_modules/react/jsx-runtime.js");require("../../node_modules/@bikdotai/bik-models/growth/index.js");var t=require("../../assets/icons/boxV2.svg.js"),s=require("../../assets/icons/chevronDownOutline.svg.js"),i=require("../../assets/icons/chevronUpOutline.svg.js"),o=require("../../assets/icons/cross.svg.js"),n=require("../../assets/icons/edit.svg.js"),r=require("../../assets/icons/filePdf.svg.js"),l=require("../../assets/icons/help.svg.js"),a=require("../../assets/icons/info.svg.js"),d=require("../../assets/icons/openai.svg.js"),c=require("../../assets/icons/plus.svg.js"),u=require("../../assets/icons/redirect.svg.js"),x=require("../../assets/icons/text_t9.svg.js"),p=require("../../assets/icons/website.svg.js"),j=require("react"),m=require("../../constants/Theme.js"),g=require("../button/Button.js"),h=require("../icon-button/IconButton.js"),E=require("../shimmer/ShimmerComponent/BikShimmer.js"),C=require("../side-modal/SideModal.js"),y=require("../tag/Tag.js"),R=require("../tooltips/Tooltip.js"),O=require("../TypographyStyle.js"),v=require("./DataSourceInfoFooter.js"),f=require("./DataSourcePanel.style.js"),S=require("./IntentConfig.js"),T=require("./Modals/DescriptionModal.js"),I=require("./model.js"),b=require("../../_virtual/index.js");exports.DataSourcePanel=L=>{var w,D;const{appType:N,storeId:_,messageSource:A,setMessageSourcePanel:F,hideCloseButton:q,isSourceInfoFetched:B,allSourceInfoDetail:k,ChecklistType:P,title:M,zeroStateButton:U,editableSources:K,preFillTrainingSourceCount:W,redirect:H,footerButtonOption:$,fetchTrainingSourceCount:Q,fetchProductFAQCount:G,productSourceData:Y,reasonForAiGeneratedResponse:z,showAiResponseReason:X}=L,{sources:V}=A,J=["blog","article","page","policy"],[Z,ee]=j.useState(!1),[te,se]=j.useState(!1),[ie,oe]=j.useState(!1),[ne,re]=j.useState(0),[le,ae]=j.useState(),[de,ce]=j.useState(null!=W?W:{}),[ue,xe]=j.useState(!1),[pe,je]=j.useState(!1),me={};S.intentConfig.forEach((t=>{let{key:s,type:i,tagText:o}=t;P[s]&&(me[P[s]]=e.jsxRuntimeExports.jsx(y.Tag,{theme:"light",type:i,tagText:o,cursor:"pointer"}))}));const ge=V.filter((e=>"PRODUCTS"==e.type||"Products"==e.subTitle||e.productId)),he=V.filter((e=>"PRODUCTS"!=e.type&&"Products"!=e.subTitle&&!e.productId)),Ee=j.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=>{P[t]&&(e[P[t]]=P[t])})),["COLLABORATION","SUBSCRIPTION_ENQUIRY"].forEach((t=>{e[t]=t})),e}),[P]);j.useEffect((()=>{var e,t,s,i;if(!(null==A?void 0:A.messageId))return;ee(!0),se(!0),oe(!1!==(null===(t=null===(e=A.sources)||void 0===e?void 0:e[0])||void 0===t?void 0:t.isTrainable)||!!(null===(i=null===(s=A.sources)||void 0===s?void 0:s[0])||void 0===i?void 0:i.insights));const o=A.sources.filter((e=>!!e.productId)).map((e=>e.productId)),n=Array.from(new Set(o)).filter((e=>!!e));G(_,n).then((e=>re(e))).then((()=>{W?(ce(W),setTimeout((()=>{ee(!1),se(!1)}),100)):(setTimeout((()=>ee(!1)),100),Q(_).then((e=>ce(e))).then((()=>setTimeout((()=>{se(!1)}),100))))}))}),[G,Q,null==A?void 0:A.messageId,A.sources,W,_]);const Ce=e=>!!(e&&0===e.length||(null==A?void 0:A.isUnsatisfactoryAnswer)),ye=function(e){let t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];var s;return"custom"==e?e=I.CustomDataType.FILES:J.includes(e)?e=I.CustomDataType.FETCHED_LINKS:"url"==e?e=I.CustomDataType.WEBSITE_LINKS:"text"===e?e=I.CustomDataType.TEXTS:"faq"===e&&(e=I.CustomDataType.FAQ),t?e:null===(s=null==e?void 0:e.toLowerCase())||void 0===s?void 0:s.replace(/_/g," ")},Re=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")):"",Oe=s=>"products"==s||"product"==s?e.jsxRuntimeExports.jsx(t.default,{height:16,width:16,color:m.COLORS.content.secondary}):"files"==s?e.jsxRuntimeExports.jsx(r.default,{height:16,width:16,color:m.COLORS.content.secondary}):"website links"==s||"fetched links"==s?e.jsxRuntimeExports.jsx(p.default,{height:16,width:16,color:m.COLORS.content.secondary}):"faq"==s?e.jsxRuntimeExports.jsx(l.default,{height:16,width:16,color:m.COLORS.content.secondary}):"texts"==s?e.jsxRuntimeExports.jsx(x.default,{height:16,width:16,color:m.COLORS.content.secondary}):e.jsxRuntimeExports.jsx(d.default,{height:16,width:16,color:m.COLORS.content.secondary}),ve=e=>{const t=e.replace(/(<([^>]+)>)/gi,""),s=document.createElement("textarea");return s.innerHTML=t,s.value};if(Z||!B)return e.jsxRuntimeExports.jsx(f.SourceInfoDetailsStyle,{children:e.jsxRuntimeExports.jsx(E.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 fe=t=>{const{title:o,count:n,isExpanded:r,onToggle:l,children:a}=t;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:l},{children:[e.jsxRuntimeExports.jsxs("div",Object.assign({style:{display:"flex",alignItems:"center",gap:"8px"}},{children:[e.jsxRuntimeExports.jsx(O.BodyCaption,Object.assign({style:{fontWeight:"600"}},{children:o})),N===b.__exports.ApplicationType.MANIFEST?e.jsxRuntimeExports.jsx("div",Object.assign({style:{backgroundColor:m.COLORS.surface.subdued,color:m.COLORS.content.secondary,padding:"2px 8px",borderRadius:"12px",fontSize:"12px",fontWeight:"500"}},{children:n})):e.jsxRuntimeExports.jsx(e.jsxRuntimeExports.Fragment,{})]})),e.jsxRuntimeExports.jsx(e.jsxRuntimeExports.Fragment,{children:N===b.__exports.ApplicationType.BIK?e.jsxRuntimeExports.jsx(e.jsxRuntimeExports.Fragment,{}):r?e.jsxRuntimeExports.jsx(s.default,{width:20,height:20,color:m.COLORS.content.primary}):e.jsxRuntimeExports.jsx(i.default,{width:20,height:20,color:m.COLORS.content.primary})})]})),r&&a]})};return e.jsxRuntimeExports.jsxs(e.jsxRuntimeExports.Fragment,{children:[e.jsxRuntimeExports.jsx(f.SourceInfoDetailsStyle,{children:e.jsxRuntimeExports.jsxs(e.jsxRuntimeExports.Fragment,{children:[e.jsxRuntimeExports.jsxs("div",Object.assign({className:"pop-up-header",style:{display:"flex",flexDirection:"column",paddingBottom:"12px"}},{children:[!!M&&e.jsxRuntimeExports.jsx(O.TitleSmall,{children:M}),e.jsxRuntimeExports.jsxs("div",Object.assign({style:{display:"flex",flexDirection:"row",gap:"12px",alignItems:"center"}},{children:[e.jsxRuntimeExports.jsx(O.BodyCaption,Object.assign({color:m.COLORS.content.secondary},{children:"Intent"})),null!==(w=me[A.intent])&&void 0!==w?w:me.GENERIC,!q&&e.jsxRuntimeExports.jsx("div",Object.assign({style:{display:"flex",marginLeft:"auto",cursor:"pointer"},onClick:()=>F(void 0)},{children:e.jsxRuntimeExports.jsx(o.default,{height:20,width:20,color:m.COLORS.content.secondary})}))]})),Ce(V)?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:`${m.COLORS.background.negative.light}`,borderRadius:"100px"}},{children:e.jsxRuntimeExports.jsx(a.default,{width:24,height:24,color:m.COLORS.stroke.negative.vibrant})})),e.jsxRuntimeExports.jsx("div",Object.assign({style:{justifyContent:"center",alignItems:"center",marginBottom:"-4px"}},{children:e.jsxRuntimeExports.jsx(O.TitleSmall,{children:"Insufficient data"})})),e.jsxRuntimeExports.jsx(O.BodySecondary,Object.assign({color:m.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"})),U&&e.jsxRuntimeExports.jsx("div",Object.assign({style:{display:"flex",width:"100%"}},{children:e.jsxRuntimeExports.jsx(g.Button,{LeadingIcon:null!==(t=U.leadingIcon)&&void 0!==t?t:c.default,buttonText:null!==(s=U.title)&&void 0!==s?s:"Add FAQ",buttonType:"secondary",size:"small",matchParentWidth:!0,onClick:()=>{U.onClick()}})}))]}))})()})):e.jsxRuntimeExports.jsx(y.Tag,{LeadingIcon:a.default,version:"2.0",type:"grey",theme:"light",alignIcon:"start",contentPadding:12,tagText:A.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 ${N===b.__exports.ApplicationType.BIK?"BIK":"Manifest"}.`:"Edit the original source and save again to update the response"})]})),!Ce(V)&&e.jsxRuntimeExports.jsxs("div",Object.assign({className:"info-container"},{children:[e.jsxRuntimeExports.jsx(e.jsxRuntimeExports.Fragment,{children:ge.length>0&&e.jsxRuntimeExports.jsx("div",Object.assign({className:"info-product-source"},{children:e.jsxRuntimeExports.jsx(fe,Object.assign({title:"Product Sources",count:ge.length,isExpanded:N!==b.__exports.ApplicationType.MANIFEST||ue,onToggle:()=>xe(!ue)},{children:e.jsxRuntimeExports.jsx("div",Object.assign({className:"source",style:{padding:"0 12px",maxWidth:"100%"}},{children:ge.map(((t,s)=>{var i,o,r,l;const a=ye(t.type||t.subTitle||"OpenAI"),d=ye(t.type||t.subTitle||"OpenAI",!0),c=Re(a),x=null==K?void 0:K.includes(d),p=k[null!==(i=t.productId)&&void 0!==i?i:"Products"],j=t.title,g=t.productId&&(null==Y?void 0:Y[t.productId]),E=g&&g.metafield.join(", ");return e.jsxRuntimeExports.jsxs("div",Object.assign({style:{display:"flex",flexDirection:"column",gap:"8px",padding:"16px 0px",borderBottom:s+1<(null==ge?void 0:ge.length)?`1px solid ${m.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:[Oe(a),e.jsxRuntimeExports.jsx(R.Tooltip,Object.assign({body:j,placement:"top"},{children:e.jsxRuntimeExports.jsx(O.BodySecondary,Object.assign({style:d==I.CustomDataType.FETCHED_LINKS||d==I.CustomDataType.WEBSITE_LINKS?{cursor:"pointer",textDecoration:"underline"}:{},color:m.COLORS.content.primary,className:"clamp-title",onClick:()=>d==I.CustomDataType.FETCHED_LINKS||d==I.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!==P.EMAIL_COLLECTION&&e.jsxRuntimeExports.jsx(e.jsxRuntimeExports.Fragment,{children:e.jsxRuntimeExports.jsx(O.BodyCaption,Object.assign({color:m.COLORS.content.secondary},{children:c}))}),(t.link||t.docId)&&e.jsxRuntimeExports.jsx("div",Object.assign({style:{cursor:"pointer",marginLeft:"0px"}},{children:x?e.jsxRuntimeExports.jsx(h.IconButton,{Icon:n.default,height:16,width:16,iconColor:m.COLORS.content.secondary,onClick:()=>null==p?void 0:p.onEditClick(p.data,p.type),disabled:!p,disabledTooltip:"This source is deleted"}):e.jsxRuntimeExports.jsx(h.IconButton,{Icon:u.default,height:16,width:16,iconColor:m.COLORS.content.secondary,disabled:"custom"===t.type&&!p,disabledTooltip:"This source is deleted",onClick:()=>H(t)})}))]}))]})),g&&e.jsxRuntimeExports.jsxs(O.BodyCaption,{children:[e.jsxRuntimeExports.jsx("span",Object.assign({className:"product-data-text1",onClick:()=>{var e;ae({title:j,description:ve(g.description),imageUrl:null!==(e=t.imageUrl)&&void 0!==e?e:"",onClose:()=>ae(void 0)})}},{children:`${null===(o=g.description)||void 0===o?void 0:o.length} characters description,`})),e.jsxRuntimeExports.jsx("span",Object.assign({className:"product-data-text1",onClick:()=>g.onEditFaqClick(g.faqs)},{children:`${null===(r=g.faqs)||void 0===r?void 0:r.length} FAQs, `})),e.jsxRuntimeExports.jsx("span",Object.assign({className:"product-data-text2"},{children:"and"})),e.jsxRuntimeExports.jsx(R.Tooltip,Object.assign({body:E,placement:"top"},{children:e.jsxRuntimeExports.jsx("span",Object.assign({className:"product-data-text1"},{children:`${null===(l=g.metafield)||void 0===l?void 0:l.length} metafields`}))}))]})]}),`info-${s}`)}))}))}))}))}),e.jsxRuntimeExports.jsx(e.jsxRuntimeExports.Fragment,{children:he.length>0&&e.jsxRuntimeExports.jsx("div",Object.assign({className:"info-content-source"},{children:e.jsxRuntimeExports.jsx(fe,Object.assign({title:"Content Sources",count:he.length,isExpanded:N!==b.__exports.ApplicationType.MANIFEST||pe,onToggle:()=>je(!pe)},{children:e.jsxRuntimeExports.jsx("div",Object.assign({className:"source",style:{padding:"0 12px",maxWidth:"100%"}},{children:he.map(((t,s)=>{var i,o,r,l,a,d,c,x,p,j,g,E,C,y,v,f,S;const T=ye(t.type||t.subTitle||"OpenAI"),b=ye(t.type||t.subTitle||"OpenAI",!0),L=Re(T),w=null==K?void 0:K.includes(b),D="Products"===t.subTitle?k[null!==(i=t.productId)&&void 0!==i?i:"Products"]:k[null!==(o=t.docId)&&void 0!==o?o:""],N=b.toLowerCase()===(null===(r=I.CustomDataType.FAQ)||void 0===r?void 0:r.toLowerCase())?"faq"===(null===(l=t.title)||void 0===l?void 0:l.toLowerCase())?t.subTitle:t.title:b.toLowerCase()===(null===(a=I.CustomDataType.FILES)||void 0===a?void 0:a.toLowerCase())||b.toLowerCase()===(null===(d=I.CustomDataType.FETCHED_LINKS)||void 0===d?void 0:d.toLowerCase())||b.toLowerCase()===(null===(c=I.CustomDataType.TEXTS)||void 0===c?void 0:c.toLowerCase())?t.title:b.toLowerCase()===(null===(x=I.CustomDataType.WEBSITE_LINKS)||void 0===x?void 0:x.toLowerCase())?t.title.split("/")[t.title.split("/").length-1].replace(/[^\w\s]/gi," ").replace(/^(.)(.*)$/,((e,t,s)=>t.toUpperCase()+s)):t.intent===P.EMAIL_COLLECTION?L:t.title,_="faq"===b.toLowerCase()?null!==(g=null!==(p=null==D?void 0:D.content)&&void 0!==p?p:null===(j=null==D?void 0:D.data)||void 0===j?void 0:j.answer)&&void 0!==g?g:"":b.toLowerCase()===(null===(E=I.CustomDataType.FETCHED_LINKS)||void 0===E?void 0:E.toLowerCase())||b.toLowerCase()===(null===(C=I.CustomDataType.WEBSITE_LINKS)||void 0===C?void 0:C.toLowerCase())||b.toLowerCase()===(null===(y=I.CustomDataType.TEXTS)||void 0===y?void 0:y.toLowerCase())?null!==(S=null!==(v=null==D?void 0:D.content)&&void 0!==v?v:null===(f=null==D?void 0:D.data)||void 0===f?void 0:f.fileContentText)&&void 0!==S?S:"":t.intent===P.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==he?void 0:he.length)?`1px solid ${m.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:[Oe(T),e.jsxRuntimeExports.jsx(R.Tooltip,Object.assign({body:N,placement:"top"},{children:e.jsxRuntimeExports.jsx(O.BodySecondary,Object.assign({style:b==I.CustomDataType.FETCHED_LINKS||b==I.CustomDataType.WEBSITE_LINKS?{cursor:"pointer",textDecoration:"underline"}:{},color:m.COLORS.content.primary,className:"clamp-title",onClick:()=>b==I.CustomDataType.FETCHED_LINKS||b==I.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!==P.EMAIL_COLLECTION&&e.jsxRuntimeExports.jsx(e.jsxRuntimeExports.Fragment,{children:e.jsxRuntimeExports.jsx(O.BodyCaption,Object.assign({color:m.COLORS.content.secondary},{children:L}))}),(t.link||t.docId)&&e.jsxRuntimeExports.jsx("div",Object.assign({style:{cursor:"pointer",marginLeft:"0px"}},{children:w?e.jsxRuntimeExports.jsx(h.IconButton,{Icon:n.default,height:16,width:16,iconColor:m.COLORS.content.secondary,onClick:()=>null==D?void 0:D.onEditClick(D.data,D.type),disabled:!D,disabledTooltip:"This source is deleted"}):e.jsxRuntimeExports.jsx(h.IconButton,{Icon:u.default,height:16,width:16,iconColor:m.COLORS.content.secondary,disabled:"custom"===t.type&&!D,disabledTooltip:"This source is deleted",onClick:()=>H(t)})}))]}))]})),(null!=_?_:"").trim()&&e.jsxRuntimeExports.jsx("div",Object.assign({style:{padding:"4px 8px",border:`1px dashed ${m.COLORS.stroke.primary}`,borderRadius:"4px",backgroundColor:m.COLORS.surface.subdued}},{children:e.jsxRuntimeExports.jsx(O.BodyCaption,Object.assign({color:m.COLORS.content.primary,className:"clamp-description"},{children:ve(null!=_?_:"").trim()}))}))]}),`info-${s}`)}))}))}))}))})]})),ie&&!Ce(V)&&e.jsxRuntimeExports.jsx("div",Object.assign({className:"footer"},{children:e.jsxRuntimeExports.jsx(v.default,{appType:N,storeId:_,messageSource:A,sourceIntent:null!==(D=A.intent)&&void 0!==D?D:P.GENERIC,faqCount:ne,trainingSourceCount:de,ShowTrainingDataSource:Ee,ChecklistType:P,footerButtonOption:$,isFooterLoading:te,reasonForAiGeneratedResponse:z,showAiResponseReason:X})}))]})}),le&&e.jsxRuntimeExports.jsx(C.SideModal,Object.assign({header:"Product description",onClose:()=>ae(void 0),width:"30%"},{children:e.jsxRuntimeExports.jsx(T.DescriptionModal,{title:le.title,description:le.description,imageUrl:le.imageUrl,onClose:le.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"),s=require("../../assets/icons/boxV2.svg.js"),i=require("../../assets/icons/chevronDownOutline.svg.js"),o=require("../../assets/icons/chevronUpOutline.svg.js"),n=require("../../assets/icons/cross.svg.js"),r=require("../../assets/icons/edit.svg.js"),l=require("../../assets/icons/filePdf.svg.js"),a=require("../../assets/icons/help.svg.js"),d=require("../../assets/icons/info.svg.js"),c=require("../../assets/icons/openai.svg.js"),u=require("../../assets/icons/plus.svg.js"),x=require("../../assets/icons/redirect.svg.js"),p=require("../../assets/icons/text_t9.svg.js"),j=require("../../assets/icons/website.svg.js"),m=require("react"),g=require("../../constants/Theme.js"),h=require("../button/Button.js"),E=require("../icon-button/IconButton.js"),C=require("../shimmer/ShimmerComponent/BikShimmer.js"),y=require("../side-modal/SideModal.js"),R=require("../tag/Tag.js"),O=require("../tooltips/Tooltip.js"),f=require("../TypographyStyle.js"),v=require("./DataSourceInfoFooter.js"),S=require("./DataSourcePanel.style.js"),T=require("./IntentConfig.js"),I=require("./Modals/DescriptionModal.js"),b=require("./model.js");exports.DataSourcePanel=L=>{var w,D;const{appType:N,storeId:A,messageSource:F,setMessageSourcePanel:_,hideCloseButton:q,isSourceInfoFetched:B,allSourceInfoDetail:k,ChecklistType:P,title:M,zeroStateButton:U,editableSources:K,preFillTrainingSourceCount:W,redirect:H,footerButtonOption:$,fetchTrainingSourceCount:Q,fetchProductFAQCount:G,productSourceData:Y,reasonForAiGeneratedResponse:z,showAiResponseReason:X}=L,{sources:V}=F,J=["blog","article","page","policy"],[Z,ee]=m.useState(!1),[te,se]=m.useState(!1),[ie,oe]=m.useState(!1),[ne,re]=m.useState(0),[le,ae]=m.useState(),[de,ce]=m.useState(null!=W?W:{}),[ue,xe]=m.useState(!1),[pe,je]=m.useState(!1),me={};T.intentConfig.forEach((t=>{let{key:s,type:i,tagText:o}=t;P[s]&&(me[P[s]]=e.jsxRuntimeExports.jsx(R.Tag,{theme:"light",type:i,tagText:o,cursor:"pointer"}))}));const ge=V.filter((e=>"PRODUCTS"==e.type||"Products"==e.subTitle||e.productId)),he=V.filter((e=>"PRODUCTS"!=e.type&&"Products"!=e.subTitle&&!e.productId)),Ee=m.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=>{P[t]&&(e[P[t]]=P[t])})),["COLLABORATION","SUBSCRIPTION_ENQUIRY"].forEach((t=>{e[t]=t})),e}),[P]);m.useEffect((()=>{var e,t,s,i;if(!(null==F?void 0:F.messageId))return;ee(!0),se(!0),oe(!1!==(null===(t=null===(e=F.sources)||void 0===e?void 0:e[0])||void 0===t?void 0:t.isTrainable)||!!(null===(i=null===(s=F.sources)||void 0===s?void 0:s[0])||void 0===i?void 0:i.insights));const o=F.sources.filter((e=>!!e.productId)).map((e=>e.productId)),n=Array.from(new Set(o)).filter((e=>!!e));G(A,n).then((e=>re(e))).then((()=>{W?(ce(W),setTimeout((()=>{ee(!1),se(!1)}),100)):(setTimeout((()=>ee(!1)),100),Q(A).then((e=>ce(e))).then((()=>setTimeout((()=>{se(!1)}),100))))}))}),[G,Q,null==F?void 0:F.messageId,F.sources,W,A]);const Ce=e=>!!(e&&0===e.length||(null==F?void 0:F.isUnsatisfactoryAnswer)),ye=function(e){let t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];var s;return"custom"==e?e=b.CustomDataType.FILES:J.includes(e)?e=b.CustomDataType.FETCHED_LINKS:"url"==e?e=b.CustomDataType.WEBSITE_LINKS:"text"===e?e=b.CustomDataType.TEXTS:"faq"===e&&(e=b.CustomDataType.FAQ),t?e:null===(s=null==e?void 0:e.toLowerCase())||void 0===s?void 0:s.replace(/_/g," ")},Re=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")):"",Oe=t=>"products"==t||"product"==t?e.jsxRuntimeExports.jsx(s.default,{height:16,width:16,color:g.COLORS.content.secondary}):"files"==t?e.jsxRuntimeExports.jsx(l.default,{height:16,width:16,color:g.COLORS.content.secondary}):"website links"==t||"fetched links"==t?e.jsxRuntimeExports.jsx(j.default,{height:16,width:16,color:g.COLORS.content.secondary}):"faq"==t?e.jsxRuntimeExports.jsx(a.default,{height:16,width:16,color:g.COLORS.content.secondary}):"texts"==t?e.jsxRuntimeExports.jsx(p.default,{height:16,width:16,color:g.COLORS.content.secondary}):e.jsxRuntimeExports.jsx(c.default,{height:16,width:16,color:g.COLORS.content.secondary}),fe=e=>{const t=e.replace(/(<([^>]+)>)/gi,""),s=document.createElement("textarea");return s.innerHTML=t,s.value};if(Z||!B)return e.jsxRuntimeExports.jsx(S.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 ve=s=>{const{title:n,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(f.BodyCaption,Object.assign({style:{fontWeight:"600"}},{children:n})),N===t.ApplicationType.MANIFEST?e.jsxRuntimeExports.jsx("div",Object.assign({style:{backgroundColor:g.COLORS.surface.subdued,color:g.COLORS.content.secondary,padding:"2px 8px",borderRadius:"12px",fontSize:"12px",fontWeight:"500"}},{children:r})):e.jsxRuntimeExports.jsx(e.jsxRuntimeExports.Fragment,{})]})),e.jsxRuntimeExports.jsx(e.jsxRuntimeExports.Fragment,{children:N===t.ApplicationType.BIK?e.jsxRuntimeExports.jsx(e.jsxRuntimeExports.Fragment,{}):l?e.jsxRuntimeExports.jsx(i.default,{width:20,height:20,color:g.COLORS.content.primary}):e.jsxRuntimeExports.jsx(o.default,{width:20,height:20,color:g.COLORS.content.primary})})]})),l&&d]})};return e.jsxRuntimeExports.jsxs(e.jsxRuntimeExports.Fragment,{children:[e.jsxRuntimeExports.jsx(S.SourceInfoDetailsStyle,{children:e.jsxRuntimeExports.jsxs(e.jsxRuntimeExports.Fragment,{children:[e.jsxRuntimeExports.jsxs("div",Object.assign({className:"pop-up-header",style:{display:"flex",flexDirection:"column",paddingBottom:"12px"}},{children:[!!M&&e.jsxRuntimeExports.jsx(f.TitleSmall,{children:M}),e.jsxRuntimeExports.jsxs("div",Object.assign({style:{display:"flex",flexDirection:"row",gap:"12px",alignItems:"center"}},{children:[e.jsxRuntimeExports.jsx(f.BodyCaption,Object.assign({color:g.COLORS.content.secondary},{children:"Intent"})),null!==(w=me[F.intent])&&void 0!==w?w:me.GENERIC,!q&&e.jsxRuntimeExports.jsx("div",Object.assign({style:{display:"flex",marginLeft:"auto",cursor:"pointer"},onClick:()=>_(void 0)},{children:e.jsxRuntimeExports.jsx(n.default,{height:20,width:20,color:g.COLORS.content.secondary})}))]})),Ce(V)?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:`${g.COLORS.background.negative.light}`,borderRadius:"100px"}},{children:e.jsxRuntimeExports.jsx(d.default,{width:24,height:24,color:g.COLORS.stroke.negative.vibrant})})),e.jsxRuntimeExports.jsx("div",Object.assign({style:{justifyContent:"center",alignItems:"center",marginBottom:"-4px"}},{children:e.jsxRuntimeExports.jsx(f.TitleSmall,{children:"Insufficient data"})})),e.jsxRuntimeExports.jsx(f.BodySecondary,Object.assign({color:g.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"})),U&&e.jsxRuntimeExports.jsx("div",Object.assign({style:{display:"flex",width:"100%"}},{children:e.jsxRuntimeExports.jsx(h.Button,{LeadingIcon:null!==(t=U.leadingIcon)&&void 0!==t?t:u.default,buttonText:null!==(s=U.title)&&void 0!==s?s:"Add FAQ",buttonType:"secondary",size:"small",matchParentWidth:!0,onClick:()=>{U.onClick()}})}))]}))})()})):e.jsxRuntimeExports.jsx(R.Tag,{LeadingIcon:d.default,version:"2.0",type:"grey",theme:"light",alignIcon:"start",contentPadding:12,tagText:F.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 ${N===t.ApplicationType.BIK?"BIK":"Manifest"}.`:"Edit the original source and save again to update the response"})]})),!Ce(V)&&e.jsxRuntimeExports.jsxs("div",Object.assign({className:"info-container"},{children:[e.jsxRuntimeExports.jsx(e.jsxRuntimeExports.Fragment,{children:ge.length>0&&e.jsxRuntimeExports.jsx("div",Object.assign({className:"info-product-source"},{children:e.jsxRuntimeExports.jsx(ve,Object.assign({title:"Product Sources",count:ge.length,isExpanded:N!==t.ApplicationType.MANIFEST||ue,onToggle:()=>xe(!ue)},{children:e.jsxRuntimeExports.jsx("div",Object.assign({className:"source",style:{padding:"0 12px",maxWidth:"100%"}},{children:ge.map(((t,s)=>{var i,o,n,l;const a=ye(t.type||t.subTitle||"OpenAI"),d=ye(t.type||t.subTitle||"OpenAI",!0),c=Re(a),u=null==K?void 0:K.includes(d),p=k[null!==(i=t.productId)&&void 0!==i?i:"Products"],j=t.title,m=t.productId&&(null==Y?void 0:Y[t.productId]),h=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==ge?void 0:ge.length)?`1px solid ${g.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:[Oe(a),e.jsxRuntimeExports.jsx(O.Tooltip,Object.assign({body:j,placement:"top"},{children:e.jsxRuntimeExports.jsx(f.BodySecondary,Object.assign({style:d==b.CustomDataType.FETCHED_LINKS||d==b.CustomDataType.WEBSITE_LINKS?{cursor:"pointer",textDecoration:"underline"}:{},color:g.COLORS.content.primary,className:"clamp-title",onClick:()=>d==b.CustomDataType.FETCHED_LINKS||d==b.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!==P.EMAIL_COLLECTION&&e.jsxRuntimeExports.jsx(e.jsxRuntimeExports.Fragment,{children:e.jsxRuntimeExports.jsx(f.BodyCaption,Object.assign({color:g.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:r.default,height:16,width:16,iconColor:g.COLORS.content.secondary,onClick:()=>null==p?void 0:p.onEditClick(p.data,p.type),disabled:!p,disabledTooltip:"This source is deleted"}):e.jsxRuntimeExports.jsx(E.IconButton,{Icon:x.default,height:16,width:16,iconColor:g.COLORS.content.secondary,disabled:"custom"===t.type&&!p,disabledTooltip:"This source is deleted",onClick:()=>H(t)})}))]}))]})),m&&e.jsxRuntimeExports.jsxs(f.BodyCaption,{children:[e.jsxRuntimeExports.jsx("span",Object.assign({className:"product-data-text1",onClick:()=>{var e;ae({title:j,description:fe(m.description),imageUrl:null!==(e=t.imageUrl)&&void 0!==e?e:"",onClose:()=>ae(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(O.Tooltip,Object.assign({body:h,placement:"top"},{children:e.jsxRuntimeExports.jsx("span",Object.assign({className:"product-data-text1"},{children:`${null===(l=m.metafield)||void 0===l?void 0:l.length} metafields`}))}))]})]}),`info-${s}`)}))}))}))}))}),e.jsxRuntimeExports.jsx(e.jsxRuntimeExports.Fragment,{children:he.length>0&&e.jsxRuntimeExports.jsx("div",Object.assign({className:"info-content-source"},{children:e.jsxRuntimeExports.jsx(ve,Object.assign({title:"Content Sources",count:he.length,isExpanded:N!==t.ApplicationType.MANIFEST||pe,onToggle:()=>je(!pe)},{children:e.jsxRuntimeExports.jsx("div",Object.assign({className:"source",style:{padding:"0 12px",maxWidth:"100%"}},{children:he.map(((t,s)=>{var i,o,n,l,a,d,c,u,p,j,m,h,C,y,R,v,S;const T=ye(t.type||t.subTitle||"OpenAI"),I=ye(t.type||t.subTitle||"OpenAI",!0),L=Re(T),w=null==K?void 0:K.includes(I),D="Products"===t.subTitle?k[null!==(i=t.productId)&&void 0!==i?i:"Products"]:k[null!==(o=t.docId)&&void 0!==o?o:""],N=I.toLowerCase()===(null===(n=b.CustomDataType.FAQ)||void 0===n?void 0:n.toLowerCase())?"faq"===(null===(l=t.title)||void 0===l?void 0:l.toLowerCase())?t.subTitle:t.title:I.toLowerCase()===(null===(a=b.CustomDataType.FILES)||void 0===a?void 0:a.toLowerCase())||I.toLowerCase()===(null===(d=b.CustomDataType.FETCHED_LINKS)||void 0===d?void 0:d.toLowerCase())||I.toLowerCase()===(null===(c=b.CustomDataType.TEXTS)||void 0===c?void 0:c.toLowerCase())?t.title:I.toLowerCase()===(null===(u=b.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===P.EMAIL_COLLECTION?L:t.title,A="faq"===I.toLowerCase()?null!==(m=null!==(p=null==D?void 0:D.content)&&void 0!==p?p:null===(j=null==D?void 0:D.data)||void 0===j?void 0:j.answer)&&void 0!==m?m:"":I.toLowerCase()===(null===(h=b.CustomDataType.FETCHED_LINKS)||void 0===h?void 0:h.toLowerCase())||I.toLowerCase()===(null===(C=b.CustomDataType.WEBSITE_LINKS)||void 0===C?void 0:C.toLowerCase())||I.toLowerCase()===(null===(y=b.CustomDataType.TEXTS)||void 0===y?void 0:y.toLowerCase())?null!==(S=null!==(R=null==D?void 0:D.content)&&void 0!==R?R:null===(v=null==D?void 0:D.data)||void 0===v?void 0:v.fileContentText)&&void 0!==S?S:"":t.intent===P.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==he?void 0:he.length)?`1px solid ${g.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:[Oe(T),e.jsxRuntimeExports.jsx(O.Tooltip,Object.assign({body:N,placement:"top"},{children:e.jsxRuntimeExports.jsx(f.BodySecondary,Object.assign({style:I==b.CustomDataType.FETCHED_LINKS||I==b.CustomDataType.WEBSITE_LINKS?{cursor:"pointer",textDecoration:"underline"}:{},color:g.COLORS.content.primary,className:"clamp-title",onClick:()=>I==b.CustomDataType.FETCHED_LINKS||I==b.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!==P.EMAIL_COLLECTION&&e.jsxRuntimeExports.jsx(e.jsxRuntimeExports.Fragment,{children:e.jsxRuntimeExports.jsx(f.BodyCaption,Object.assign({color:g.COLORS.content.secondary},{children:L}))}),(t.link||t.docId)&&e.jsxRuntimeExports.jsx("div",Object.assign({style:{cursor:"pointer",marginLeft:"0px"}},{children:w?e.jsxRuntimeExports.jsx(E.IconButton,{Icon:r.default,height:16,width:16,iconColor:g.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:x.default,height:16,width:16,iconColor:g.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 ${g.COLORS.stroke.primary}`,borderRadius:"4px",backgroundColor:g.COLORS.surface.subdued}},{children:e.jsxRuntimeExports.jsx(f.BodyCaption,Object.assign({color:g.COLORS.content.primary,className:"clamp-description"},{children:fe(null!=A?A:"").trim()}))}))]}),`info-${s}`)}))}))}))}))})]})),ie&&!Ce(V)&&e.jsxRuntimeExports.jsx("div",Object.assign({className:"footer"},{children:e.jsxRuntimeExports.jsx(v.default,{appType:N,storeId:A,messageSource:F,sourceIntent:null!==(D=F.intent)&&void 0!==D?D:P.GENERIC,faqCount:ne,trainingSourceCount:de,ShowTrainingDataSource:Ee,ChecklistType:P,footerButtonOption:$,isFooterLoading:te,reasonForAiGeneratedResponse:z,showAiResponseReason:X})}))]})}),le&&e.jsxRuntimeExports.jsx(y.SideModal,Object.assign({header:"Product description",onClose:()=>ae(void 0),width:"30%"},{children:e.jsxRuntimeExports.jsx(I.DescriptionModal,{title:le.title,description:le.description,imageUrl:le.imageUrl,onClose:le.onClose})}))]})};
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../../node_modules/react/jsx-runtime.js");require("../../node_modules/@bikdotai/bik-models/growth/index.js");var t=require("react"),i=require("./type.js");require("../dropdown/DropdownPopover/index.js");var o=require("../dropdown/Dropdown.js");require("../dropdown/ChipDropdown.js"),require("../zeroState/ZeroState.js");var n=require("../TypographyStyle.js"),l=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 r=require("../modals/styledModal.js"),s=require("../product-picker/ProductPickerModal.js"),a=require("../tag/Tag.js"),d=require("../tooltips/Tooltip.js"),u=require("../../assets/icons/gift_icon.svg.js"),c=require("../../assets/icons/percentage_icon.svg.js"),p=require("../../assets/icons/shipping_icon.svg.js"),C=require("../../assets/icons/triangle_error.svg.js"),E=require("../../assets/icons/warning.svg.js"),T=require("../product-picker-v2/modal.js");require("../product-picker-v2/type.js");var S=require("../variable-picker-v3/model.js"),P=require("../variable-picker-v3/VariablePicker.js"),I=require("./DiscountModal.styled.js"),O=require("./DiscountUtils.js"),v=require("./DynamicCoupon/DynamicCoupon.js"),_=require("./StaticCoupon/StaticCoupon.js"),b=require("../../_virtual/index.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(c.default,{width:24,height:24,color:t})},{id:"2",label:"Buy X get Y",value:i.DISCOUNT_TYPES.BUY_X_GET_Y,icon:t=>e.jsxRuntimeExports.jsx(u.default,{width:24,height:24,color:t})},{id:"3",label:"Free Shipping",value:i.DISCOUNT_TYPES.FREE_SHIPPING,icon:t=>e.jsxRuntimeExports.jsx(p.default,{width:24,height:24,color:t})}],[F,q]=t.useState(),[k,L]=t.useState(),[M,Y]=t.useState(),[w,G]=t.useState(null!==(m=y.data)&&void 0!==m?m:"string"==typeof y.hideOption?{isStaticCoupon:"dynamic"===y.hideOption}:{isStaticCoupon:!0}),[B,X]=t.useState(!0),[Q,H]=t.useState(),[z,K]=t.useState((null===(x=y.data)||void 0===x?void 0:x.minAmount)?i.MIN_PURCHASE_REQUIREMENT.AMOUNT:(null===(D=y.data)||void 0===D?void 0:D.minQuantity)?i.MIN_PURCHASE_REQUIREMENT.QUANTITY:i.MIN_PURCHASE_REQUIREMENT.NA),[$,Z]=t.useState(i.DISCOUNT_APPLIES_TO.ENTIRE_ORDER),[J,W]=t.useState(i.OFFER_APPLIES_TO.SPECIFIC_PRODUCTS),[ee,te]=t.useState(i.OFFER_APPLIES_TO.SPECIFIC_PRODUCTS),[ie,oe]=t.useState(void 0),[ne,le]=t.useState(void 0),[re,se]=t.useState(void 0),[ae,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(""),[Ie,Oe]=t.useState(V[0]),[ve,_e]=t.useState(!1),[be,ye]=t.useState(i.initialStaticCouponErrorState),[me,xe]=t.useState(i.initialDynamicCouponErrorState),[De,Ne]=t.useState(i.COUPON_EXPIRATION.DYNAMIC_EXPIRATION),he=[{value:i.DISCOUNT_TYPES.AMOUNT_OFF_ORDER,label:"Amount off on order",selected:Q===i.DISCOUNT_TYPES.AMOUNT_OFF_ORDER},{value:i.DISCOUNT_TYPES.AMOUNT_OFF_PRODUCTS,label:"Amount off on products",selected:Q===i.DISCOUNT_TYPES.AMOUNT_OFF_PRODUCTS},{value:i.DISCOUNT_TYPES.BUY_X_GET_Y,label:"Buy X Get Y FREE",selected:Q===i.DISCOUNT_TYPES.BUY_X_GET_Y},{value:i.DISCOUNT_TYPES.FREE_SHIPPING,label:"Free shipping",selected:Q===i.DISCOUNT_TYPES.FREE_SHIPPING}];t.useEffect((()=>{y.makeExpiryMandatory&&_e(!0)}),[y.makeExpiryMandatory]),t.useEffect((()=>{var e,t,o,n,l,r,s,a;let d;const{tempCouponData:u,discountType:c}=je();H(c);const p=(e,t)=>{Oe(u.valueType===i.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(i.COUPON_EXPIRATION.FIXED_EXPIRATION),(null==u?void 0:u.expireAfter)&&Ne(i.COUPON_EXPIRATION.DYNAMIC_EXPIRATION)),c){case i.DISCOUNT_TYPES.AMOUNT_OFF_ORDER:p(0,1),Z(i.DISCOUNT_APPLIES_TO.ENTIRE_ORDER);break;case i.DISCOUNT_TYPES.AMOUNT_OFF_PRODUCTS:p(0,1),(null===(e=u.entitledCollectionIds)||void 0===e?void 0:e.length)?Z(i.DISCOUNT_APPLIES_TO.SPECIFIC_COLLECTIONS):(null===(t=u.entitledProductIds)||void 0===t?void 0:t.length)||(null===(o=u.productVariableConf)||void 0===o?void 0:o.entitledProductVariable)?(Z(i.DISCOUNT_APPLIES_TO.SPECIFIC_PRODUCTS),C(null===(n=u.productVariableConf)||void 0===n?void 0:n.entitledProductVariable,de)):Z(i.DISCOUNT_APPLIES_TO.ENTIRE_ORDER);break;case i.DISCOUNT_TYPES.BUY_X_GET_Y:Oe(V[2]),(null===(l=u.entitledCollectionIds)||void 0===l?void 0:l.length)?te(i.OFFER_APPLIES_TO.SPECIFIC_COLLECTIONS):(te(i.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(i.OFFER_APPLIES_TO.SPECIFIC_COLLECTIONS):(W(i.OFFER_APPLIES_TO.SPECIFIC_PRODUCTS),C(null===(a=u.productVariableConf)||void 0===a?void 0:a.prerequisiteProductVariable,ce));break;case i.DISCOUNT_TYPES.FREE_SHIPPING:Oe(V[3])}G(Object.assign({},u)),y.hideProbability||(d=Ue()),X(O.validateDiscountData(u,z,c,y.hideProbability||!1,d,!!u.isStaticCoupon)),y.hideProbability||Ue()}),[]),t.useEffect((()=>{let e;y.hideProbability||(e=Ue()),X(O.validateDiscountData(w,z,Q,y.hideProbability||!1,e,!!w.isStaticCoupon))}),[w,Ee,Q,z]),t.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]),t.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]),t.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]),t.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]),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 je=()=>{var e,t;let o,n=w;return w.isStaticCoupon||(w.targetType===i.DISCOUNT_TARGET_TYPES.SHIPPING_LINE?o=i.DISCOUNT_TYPES.FREE_SHIPPING:w.targetType===i.DISCOUNT_TARGET_TYPES.LINE_ITEM?o=w.targetSelection===i.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?i.DISCOUNT_TYPES.BUY_X_GET_Y:i.DISCOUNT_TYPES.AMOUNT_OFF_PRODUCTS:i.DISCOUNT_TYPES.AMOUNT_OFF_ORDER:(n=Object.assign(Object.assign({},n),{targetType:i.DISCOUNT_TARGET_TYPES.LINE_ITEM,targetSelection:i.DISCOUNT_TARGET_SELECTION.ALL,valueType:i.DISCOUNT_VALUE_TYPES.FIXED_AMOUNT}),o=i.DISCOUNT_TYPES.AMOUNT_OFF_ORDER)),{discountType:o,tempCouponData:n}},Re=()=>{ye(i.initialStaticCouponErrorState),xe(i.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,o,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===i.DISCOUNT_TYPES.FREE_SHIPPING?G({value:100,targetSelection:i.DISCOUNT_TARGET_SELECTION.ALL,targetType:i.DISCOUNT_TARGET_TYPES.SHIPPING_LINE,valueType:i.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!==(o=w.expireAfter)&&void 0!==o?o: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===i.DISCOUNT_TYPES.BUY_X_GET_Y?G({value:100,targetSelection:i.DISCOUNT_TARGET_SELECTION.ENTITLED,targetType:i.DISCOUNT_TARGET_TYPES.LINE_ITEM,valueType:i.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===i.DISCOUNT_TYPES.AMOUNT_OFF_ORDER?G({targetSelection:i.DISCOUNT_TARGET_SELECTION.ALL,targetType:i.DISCOUNT_TARGET_TYPES.LINE_ITEM,valueType:null!==(a=w.valueType)&&void 0!==a?a:i.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===i.DISCOUNT_TYPES.AMOUNT_OFF_PRODUCTS&&G({targetSelection:i.DISCOUNT_TARGET_SELECTION.ENTITLED,targetType:i.DISCOUNT_TARGET_TYPES.LINE_ITEM,valueType:null!==(C=w.valueType)&&void 0!==C?C:i.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(a.Tag,{theme:"light",tagText:t,type:"negative",LeadingIcon:E.default});return e.jsxRuntimeExports.jsxs(r.StyledModal,Object.assign({width:(M||F)&&y.newPickerConf?"25px":"640px",open:y.isOpen,hideCrossButton:!!k,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(a.Tag,{theme:"light",tagText:`Current probability sum: ${Ee}`,type:"white"}):e.jsxRuntimeExports.jsx(d.Tooltip,Object.assign({body:"Probability sum should not exceed 1",placement:"top"},{children:e.jsxRuntimeExports.jsx("div",{children:e.jsxRuntimeExports.jsx(a.Tag,{style:{cursor:"pointer"},theme:"light",tagText:`Current probability sum: ${Ee}`,type:"negative",LeadingIcon:C.default})})})),headerRightCustomElement:y.allowStaticCoupon||F?void 0:e.jsxRuntimeExports.jsx(o.Dropdown,{options:he,width:"200px",placement:"bottom-start",size:"small",onSelect:e=>{Ae(e)}}),onClose:y.onClose,footerContainerStyle:{borderTop:`1px solid ${l.DEFAULT_THEME.colorsV2.stroke.primary}`},primaryButton:F?{buttonType:"primary",onClick:()=>{q(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,o,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!==(o=w.probability)&&void 0!==o?o:-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!==i.DISCOUNT_TYPES.BUY_X_GET_Y&&z!==i.MIN_PURCHASE_REQUIREMENT.NA){const{minAmount:e,minQuantity:t}=w;r.inValidMinimumAmount=z===i.MIN_PURCHASE_REQUIREMENT.AMOUNT&&!e,r.inValidMinimumQuantity=z===i.MIN_PURCHASE_REQUIREMENT.QUANTITY&&!t}if(ve&&(r.inValidCouponExpiry=!w.expireAt&&!w.expireAfter),Q!==i.DISCOUNT_TYPES.AMOUNT_OFF_ORDER&&Q!==i.DISCOUNT_TYPES.AMOUNT_OFF_PRODUCTS||($!==i.DISCOUNT_APPLIES_TO.SPECIFIC_PRODUCTS||!ne||Object.keys(ne).length||ae||(r.inValidProductSelection=!0,r.inValidProductVariableSelection=!0),$===i.DISCOUNT_APPLIES_TO.SPECIFIC_COLLECTIONS&&pe&&!Object.keys(pe).length&&(r.inValidCollectionSelection=!0)),Q===i.DISCOUNT_TYPES.BUY_X_GET_Y&&(w.prerequisiteQuantity||(r.inValidBuyXValue=!0),w.entitledQuantity||(r.inValidGetYValue=!0),J!==i.OFFER_APPLIES_TO.SPECIFIC_PRODUCTS||!ie||Object.keys(ie).length||ue||(r.inValidBuyXProductSelection=!0,r.inValidBuyXProductVariableSelection=!0),J===i.OFFER_APPLIES_TO.SPECIFIC_COLLECTIONS&&re&&!Object.keys(re).length&&(r.inValidBuyXCollectionSelection=!0),ee!==i.OFFER_APPLIES_TO.SPECIFIC_PRODUCTS||!ne||Object.keys(ne).length||ae||(r.inValidGetYProductSelection=!0,r.inValidGetYProductVariableSelection=!0),ee===i.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:O.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:()=>{q(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(I.StyledDiscountDialogueContainer,{children:[y.allowStaticCoupon&&!F&&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(""),Re())}},{children:[e.jsxRuntimeExports.jsx(n.TitleSmall,Object.assign({style:{marginBottom:"4px",color:w.isStaticCoupon?l.DEFAULT_THEME.colorsV2.content.brand:void 0}},{children:"Static Code"})),e.jsxRuntimeExports.jsx(n.BodyCaption,Object.assign({style:w.isStaticCoupon?{color:l.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(i.DISCOUNT_TYPES.AMOUNT_OFF_ORDER),G({isStaticCoupon:!1,quadrant:w.quadrant,targetType:i.DISCOUNT_TARGET_TYPES.LINE_ITEM,targetSelection:i.DISCOUNT_TARGET_SELECTION.ALL,valueType:i.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(i.MIN_PURCHASE_REQUIREMENT.NA))}},{children:[e.jsxRuntimeExports.jsx(n.TitleSmall,Object.assign({style:{marginBottom:"4px",color:w.isStaticCoupon?void 0:l.DEFAULT_THEME.colorsV2.content.brand}},{children:"Dynamic Code"})),e.jsxRuntimeExports.jsx(n.BodyCaption,Object.assign({style:w.isStaticCoupon?{}:{color:l.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(n.TitleRegular,Object.assign({style:{marginTop:"24px"}},{children:"Coupon Details"})),w.isStaticCoupon&&!F&&e.jsxRuntimeExports.jsx(_.default,{discountData:w,setDiscountData:G,hideProbability:y.hideProbability||!1,discountAdminUrl:y.discountAdminUrl,staticDiscountValidationError:be,currency:y.currency}),!w.isStaticCoupon&&!F&&!M&&e.jsxRuntimeExports.jsx(v.default,{currency:y.currency,entitledProducts:null!=ne?ne:[],prerequisiteProducts:null!=ie?ie:[],setEntitledProducts:le,setPrerequisiteProducts:oe,discountData:w,productPickerOpen:F,productVariablePickerOpen:k,setIsProductPickerOpen:q,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(s.ProductPickerContent,{show:!0,onSave:()=>{},products:null!==(R=y.products)&&void 0!==R?R:[],title:"Select Products",onClose:()=>{q(void 0)},selectedProducts:null!==(f=F===v.DISCOUNT_PRODUCTS.ENTITLED?ne:ie)&&void 0!==f?f:[],setSelectedProducts:F===v.DISCOUNT_PRODUCTS.ENTITLED?le:oe,onSearchKeyChange:y.onProductSearch})})),y.newPickerConf&&e.jsxRuntimeExports.jsx(T.ProductPickerModal,{visible:!0,onClose:()=>q(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===v.DISCOUNT_PRODUCTS.ENTITLED?ne:ie,onAdd:e=>{F===v.DISCOUNT_PRODUCTS.ENTITLED?le(e):oe(e),q(void 0)},zIndex:200,storeId:y.newPickerConf.storeId,appType:y.newPickerConf.appType||b.__exports.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(T.ProductPickerModal,{visible:!0,onClose:()=>Y(void 0),collectionFetcher:y.newPickerConf.fetchCollections,productFetcher:y.newPickerConf.fetchProducts,selectedItems:M===v.DISCOUNT_PRODUCTS.ENTITLED?pe:re,onAdd:e=>{Object.values(e).forEach((e=>{e.products&&delete e.products})),M===v.DISCOUNT_PRODUCTS.ENTITLED?Ce(e):se(e),Y(void 0)},customCollectionRestriction:!1,zIndex:200,storeId:y.newPickerConf.storeId,appType:y.newPickerConf.appType||b.__exports.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!==(U=y.collection)&&void 0!==U?U:[],title:"Select Products",onClose:()=>{Y(void 0)},selectedProducts:null!==(A=M===v.DISCOUNT_PRODUCTS.ENTITLED?pe:re)&&void 0!==A?A:[],setSelectedProducts:M===v.DISCOUNT_PRODUCTS.ENTITLED?Ce:se,onSearchKeyChange:y.onCollectionSearch,searchPlaceholder:"Search collections..."})]})})),k&&e.jsxRuntimeExports.jsx(I.VariablePickerContainer,{children:e.jsxRuntimeExports.jsx("div",Object.assign({style:{width:"50%",height:"100%",marginLeft:"50%"}},{children:e.jsxRuntimeExports.jsx(P.VariablePicker,{type:S.PickerType.EMBEDDED,data:null!==(g=y.productVariableList)&&void 0!==g?g:[],showHeader:!0,onSelect:e=>{if(k===v.DISCOUNT_PRODUCTS.ENTITLED){const{displayName:t,actualValue:i,isAvailable:o}=e;de({displayName:t,actualValue:i,isAvailable:o}),L(void 0)}if(k===v.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"),t=require("@bikdotai/bik-models/growth"),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 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../../node_modules/react/jsx-runtime.js");require("../../node_modules/@bikdotai/bik-models/growth/index.js");var t=require("../../assets/icons/search.svg.js"),o=require("react"),s=require("../../constants/Theme.js"),r=require("../../assets/icons/cross.svg.js"),c=require("../button/Button.js"),n=require("../input/Input.js"),i=require("../modals/styledModal.js"),l=require("../spinner/Spinner.js"),a=require("../tag/Tag.js"),d=require("./collectionScreen.js"),u=require("./productInfoOverlay.js"),p=require("./productScreen.js"),x=require("./rearrangeScreen.js"),h=require("./reducers.js"),j=require("./searchScreen.js"),m=require("./selectedScreen.js"),S=require("./style.js"),C=require("./type.js"),g=require("./utility.js"),y=require("../../_virtual/index.js");exports.ProductPickerModal=R=>{const{storeId:b,selectedItems:f,onClose:E,visible:v,zIndex:k,exactLimit:I,limit:O,hideCollectionCheckbox:F,hideProductCheckbox:P,outOfStockAction:T=C.OUT_OF_STOCK_ACTION.BLUR,hideVariantCheckbox:D,selectProductsFromCustomCollection:q,hideSelectionCount:N,title:A,width:B,left:w,renderWithoutModal:L,onClickSave:M,pickerType:_,hideProductVariants:V=!1,startupScreen:z=C.ScreenName.Collections,rearrangeEnabled:$,selectSingleItem:H=!1,showProductDetails:K,containerStyle:W,crossButtonInsideHeader:G=!1,footerForNonModal:U={},primaryButton:Y,secondaryButton:J,subtitle:Q}=R,X=R.appType||y.__exports.ApplicationType.BIK,[Z,ee]=o.useReducer(h.collectionsReducer,{}),[te,oe]=o.useState([C.ScreenName.Collections,C.ScreenName.RearrangeProducts].includes(z)?z:C.ScreenName.Collections),[se,re]=o.useState("grid"),[ce,ne]=o.useState(""),[ie,le]=o.useState(""),[ae,de]=o.useState(0),[ue,pe]=o.useState(!1),[xe,he]=o.useState(0),[je,me]=o.useState(""),[Se,Ce]=o.useState(!1),[ge,ye]=o.useState(!1),[Re,be]=o.useReducer(h.searchReducer,{collections:{},products:{}}),[fe,Ee]=o.useReducer(h.selectedColectionsReducer,Object.keys(f).length>0?f:{}),ve=o.useRef(null),[ke,Ie]=o.useState(!1),[Oe,Fe]=o.useState();o.useEffect((()=>{pe(!0),ye(!0),R.collectionFetcher(ae,b,X).then((e=>{ee({type:"fetched",data:(null==e?void 0:e.collections)||{}}),pe(!1),de((e=>e+1)),ye(!1)})).catch()}),[]),o.useEffect((()=>{let e=0;V?Object.keys(fe||[]).forEach((t=>{var o;Object.keys((null===(o=fe[t])||void 0===o?void 0:o.products)||[]).forEach((o=>{var s;"-1"!==t&&fe[-1]&&(null===(s=fe[-1].products)||void 0===s?void 0:s[o])||(e+=1)}))})):Object.keys(fe||[]).forEach((t=>{var o;Object.keys((null===(o=fe[t])||void 0===o?void 0:o.products)||[]).forEach((o=>{var s,r;Object.keys((null===(r=null===(s=fe[t].products)||void 0===s?void 0:s[o])||void 0===r?void 0:r.variants)||[]).forEach((()=>{e+=1}))}))})),he(e)}),[Z,fe,V]),o.useEffect((()=>{ie&&(pe(!0),R.productFetcher(ie,b,X).then((e=>{Object.keys(e).length&&ee({type:"productsFetched",data:{collectionId:ie,products:e}}),pe(!1)})).catch())}),[ie]),o.useEffect((()=>{const e=setTimeout((()=>{"rearrange"!==te&&(je.length||"collections"!==te)&&(je.length?(Ce(!0),R.searchFetcher(b,je,X).then((e=>{"collections"in e&&"products"in e?(be({type:"set",data:e}),ee({type:"searched",data:e.collections}),ee({type:"searched",data:e.products})):(be({type:"set",data:{collections:{},products:e}}),ee({type:"searched",data:e})),oe("searchProducts"),pe(!1),Ce(!1)}))):oe("collections"))}),800);return()=>clearTimeout(e)}),[je]),o.useEffect((()=>{M&&(R.onAdd(fe,xe),Pe())}),[M]),o.useEffect((()=>{H&&Object.keys(fe||{}).length&&xe&&(R.onAdd(fe,xe),Pe())}),[H,fe,xe]);const Pe=()=>{Ee({type:"reset",data:{}})},Te=()=>I&&xe>I?e.jsxRuntimeExports.jsx(a.Tag,{tagText:`You can only select ${I} products`,type:"negative"}):O&&xe>O?e.jsxRuntimeExports.jsx(a.Tag,{tagText:`You can only select ${O} products`,type:"negative"}):xe>0?e.jsxRuntimeExports.jsx(c.Button,{onClick:()=>{oe($?C.ScreenName.RearrangeProducts:C.ScreenName.SelectedProducts)},buttonText:I?`${xe}/${I} products selected`:`${xe} products selected`,buttonType:["rearrange","view"].includes(te)?"tertiaryGray":"tertiary",disabled:["rearrange","view"].includes(te)}):e.jsxRuntimeExports.jsx(c.Button,{disabled:!0,buttonText:I?`${xe}/${I} products selected`:`${xe} products selected`,buttonType:"tertiaryGray"}),De=e=>ue?"Loading...":te===C.ScreenName.RearrangeProducts?null!=e?e:"Done":null!=e?e:"Add",qe=e.jsxRuntimeExports.jsxs(S.ContainerStyle,Object.assign({style:null!=W?W:{}},{children:[R.postHeader&&e.jsxRuntimeExports.jsx("div",Object.assign({style:{padding:"0 24px"}},{children:R.postHeader})),!R.hideGlobalSearch&&e.jsxRuntimeExports.jsx(e.jsxRuntimeExports.Fragment,{children:("collections"===te||"searchProducts"===te)&&e.jsxRuntimeExports.jsx("div",Object.assign({style:{padding:L?"8px 16px":"12px 24px",borderBottom:"1px solid #E0E0E0"}},{children:e.jsxRuntimeExports.jsx(n.Input,{placeholder:"Search using ID, Name or SKU ID",noKeyDownChange:!0,noErrorHint:!0,rightIcon:{icon:()=>Se?e.jsxRuntimeExports.jsx(l.Spinner,{size:"small",color:s.COLORS.content.primary}):e.jsxRuntimeExports.jsx(t.default,{})},id:"listInput",height:"24px",type:"text",value:je,onChangeText:e=>{e.length&&e.trim().length?me(e):me("")}})}))}),e.jsxRuntimeExports.jsxs(S.ScrollContainerStyle,Object.assign({ref:ve,screenName:te},{children:["collections"===te&&e.jsxRuntimeExports.jsx(d.CollectionsScreen,{customCollectionRestriction:R.customCollectionRestriction,dataLoading:ge,collections:Z,selectedCollectionsDispatch:Ee,setCollectionId:ne,setSelectedCollectionId:le,setScreen:oe,selectedCollections:fe,collectionFetcher:R.collectionFetcher,storeId:b,appType:X,collectionsDispatch:ee,setSaveDisabled:pe,pagingControls:{curPage:ae,setCurPage:de},hideCollectionCheckbox:F,renderWithoutModal:L,pickerType:_,scrollContainerRef:ve}),"products"===te&&ce&&e.jsxRuntimeExports.jsx(h.CollectionIdContext.Provider,Object.assign({value:ce},{children:e.jsxRuntimeExports.jsx(p.ProductsScreen,{hideInCollectionSearch:R.hideInCollectionSearch,customCollectionRestriction:R.customCollectionRestriction,productFetcher:R.productFetcher,setScreen:oe,storeId:b,appType:X,data:Z[ce],collectionsDispatch:ee,selectedCollectionsDispatch:Ee,selectedData:fe,setSaveDisabled:pe,searchInCollectionFetcher:R.searchInCollectionFetcher,hideProductCheckbox:P,outOfStockAction:T,hideVariantCheckbox:D,selectProductsFromCustomCollection:q,renderWithoutModal:L,pickerType:_,hideProductVariants:V,fbStatusFetcher:R.fbStatusFetcher,onProductDetailClick:e=>{Ie(!0),Fe(e)},showProductDetailInfoIcon:K,scrollContainerRef:ve})})),"view"===te&&e.jsxRuntimeExports.jsx(m.SelectedScreen,{selectedCollections:fe||{},selectedCollectionsDispatch:Ee,setScreen:oe,collections:Z,hideProductVariants:V,outOfStockAction:T,storeId:b,appType:X,fbStatusFetcher:R.fbStatusFetcher}),"rearrange"===te&&e.jsxRuntimeExports.jsx(x.RearrangeScreen,{selectedCollections:fe||{},selectedCollectionsDispatch:Ee,setScreen:oe,outOfStockAction:T,rearrangeViewType:"grid"===se?"list":"grid",scrollContainerRef:ve,storeId:b,appType:X,fbStatusFetcher:R.fbStatusFetcher}),"searchProducts"===te&&e.jsxRuntimeExports.jsx(j.SearchScreen,{customCollectionRestriction:R.customCollectionRestriction,selectedCollections:fe||{},searchedCollections:Re||{},searchedCollectionsDispatch:be,selectedCollectionsDispatch:Ee,setScreen:oe,collections:Z,onBackPress:()=>{me(""),be({type:"set",data:{collections:{},products:{}}})},pickerType:_,hideProductCheckbox:P,hideProductVariants:V,hideVariantCheckbox:D,storeId:b,appType:X,fbStatusFetcher:R.fbStatusFetcher,setCollectionId:ne,setSelectedCollectionId:le,renderWithoutModal:L,hideCollectionCheckbox:F,outOfStockAction:T})]}))]}));return e.jsxRuntimeExports.jsx(e.jsxRuntimeExports.Fragment,{children:L?e.jsxRuntimeExports.jsxs(e.jsxRuntimeExports.Fragment,{children:[qe,U.renderFooter?e.jsxRuntimeExports.jsxs(S.StyledFooterForNonModal,{children:[Te(),e.jsxRuntimeExports.jsx(c.Button,{buttonText:De(U.primaryButtonText),disabled:!U.isLoading&&(ue||xe<1||I&&xe<I||!I&&O&&xe>O)||U.primaryButtonDisabled,isLoading:U.isLoading,onClick:()=>{R.onAdd(fe,xe),Pe(),oe([C.ScreenName.Collections,C.ScreenName.RearrangeProducts].includes(z)?z:C.ScreenName.Collections)}})]}):e.jsxRuntimeExports.jsx(e.jsxRuntimeExports.Fragment,{}),ke&&Oe?e.jsxRuntimeExports.jsx(u.ProductInfoOverlay,{productData:Oe,outOfStockAction:T,useDynamicInfoImageSize:R.useDynamicInfoImageSize,onClose:()=>{Ie(!1)}}):e.jsxRuntimeExports.jsx(e.jsxRuntimeExports.Fragment,{})]}):e.jsxRuntimeExports.jsxs(i.StyledModal,Object.assign({zIndex:k,open:v,onClose:()=>{null==E||E(),Pe()},headingTitle:A||("collections"===te||"products"===te?"Select Products":"view"===te?"Selected Products":"searchProducts"===te?"Searched Results":"rearrange"===te?"Rearrange Products":void 0),headingSubtitle:Q,footerShadow:!0,centralContainerStyles:{width:B||"600px",left:w||"auto"},headerRightCustomElement:G?e.jsxRuntimeExports.jsx("div",Object.assign({style:{cursor:"pointer",display:"flex"},onClick:E},{children:e.jsxRuntimeExports.jsx(r.default,{width:20,height:20,color:s.COLORS.content.secondary})})):e.jsxRuntimeExports.jsx(e.jsxRuntimeExports.Fragment,{}),footerContainerStyle:R.stickyFooter?{position:"absolute",bottom:0,left:0,width:"100%",zIndex:9,background:s.COLORS.surface.standard}:void 0,primaryButton:Y?(e=>Object.assign(Object.assign({},e),{disabled:!e.isLoading&&(ue||xe<1||I&&xe<I||!I&&O&&xe>O)||e.disabled,onClick:()=>{R.onAdd(fe,xe),Pe(),oe([C.ScreenName.Collections,C.ScreenName.RearrangeProducts].includes(z)?z:C.ScreenName.Collections)}}))(Y):{buttonText:De(),disabled:ue||xe<1||I&&xe<I||!I&&O&&xe>O||!1,onClick:()=>{R.onAdd(fe,xe),Pe()}},secondaryButton:J?(e=>Object.assign(Object.assign({},e),{disabled:ue||xe<1||I&&xe<I||!I&&O&&xe>O||!1,onClick:()=>{const e=g.updateAllVariantsForSelectedProducts(fe,Z,Re);R.onAdd(e,xe,!0)}}))(J):void 0,wrapperStyle:R.stickyFooter?{height:"calc(100vh - 168px)"}:void 0,footerLeftCustomElement:N?e.jsxRuntimeExports.jsx(e.jsxRuntimeExports.Fragment,{}):Te(),hideCrossButton:ke||G},{children:[qe,ke&&Oe?e.jsxRuntimeExports.jsx(u.ProductInfoOverlay,{productData:Oe,useDynamicInfoImageSize:R.useDynamicInfoImageSize,outOfStockAction:T,onClose:()=>{Ie(!1)}}):e.jsxRuntimeExports.jsx(e.jsxRuntimeExports.Fragment,{})]}))})};
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../../node_modules/react/jsx-runtime.js"),t=require("@bikdotai/bik-models/growth"),o=require("../../assets/icons/search.svg.js"),s=require("react"),r=require("../../constants/Theme.js"),c=require("../../assets/icons/cross.svg.js"),n=require("../button/Button.js"),i=require("../input/Input.js"),l=require("../modals/styledModal.js"),a=require("../spinner/Spinner.js"),d=require("../tag/Tag.js"),u=require("./collectionScreen.js"),p=require("./productInfoOverlay.js"),x=require("./productScreen.js"),h=require("./rearrangeScreen.js"),j=require("./reducers.js"),m=require("./searchScreen.js"),S=require("./selectedScreen.js"),C=require("./style.js"),g=require("./type.js"),y=require("./utility.js");exports.ProductPickerModal=R=>{const{storeId:b,selectedItems:f,onClose:E,visible:v,zIndex:k,exactLimit:I,limit:O,hideCollectionCheckbox:F,hideProductCheckbox:P,outOfStockAction:T=g.OUT_OF_STOCK_ACTION.BLUR,hideVariantCheckbox:D,selectProductsFromCustomCollection:q,hideSelectionCount:N,title:A,width:B,left:w,renderWithoutModal:L,onClickSave:M,pickerType:V,hideProductVariants:z=!1,startupScreen:$=g.ScreenName.Collections,rearrangeEnabled:_,selectSingleItem:H=!1,showProductDetails:K,containerStyle:W,crossButtonInsideHeader:G=!1,footerForNonModal:U={},primaryButton:Y,secondaryButton:J,subtitle:Q}=R,X=R.appType||t.ApplicationType.BIK,[Z,ee]=s.useReducer(j.collectionsReducer,{}),[te,oe]=s.useState([g.ScreenName.Collections,g.ScreenName.RearrangeProducts].includes($)?$:g.ScreenName.Collections),[se,re]=s.useState("grid"),[ce,ne]=s.useState(""),[ie,le]=s.useState(""),[ae,de]=s.useState(0),[ue,pe]=s.useState(!1),[xe,he]=s.useState(0),[je,me]=s.useState(""),[Se,Ce]=s.useState(!1),[ge,ye]=s.useState(!1),[Re,be]=s.useReducer(j.searchReducer,{collections:{},products:{}}),[fe,Ee]=s.useReducer(j.selectedColectionsReducer,Object.keys(f).length>0?f:{}),ve=s.useRef(null),[ke,Ie]=s.useState(!1),[Oe,Fe]=s.useState();s.useEffect((()=>{pe(!0),ye(!0),R.collectionFetcher(ae,b,X).then((e=>{ee({type:"fetched",data:(null==e?void 0:e.collections)||{}}),pe(!1),de((e=>e+1)),ye(!1)})).catch()}),[]),s.useEffect((()=>{let e=0;z?Object.keys(fe||[]).forEach((t=>{var o;Object.keys((null===(o=fe[t])||void 0===o?void 0:o.products)||[]).forEach((o=>{var s;"-1"!==t&&fe[-1]&&(null===(s=fe[-1].products)||void 0===s?void 0:s[o])||(e+=1)}))})):Object.keys(fe||[]).forEach((t=>{var o;Object.keys((null===(o=fe[t])||void 0===o?void 0:o.products)||[]).forEach((o=>{var s,r;Object.keys((null===(r=null===(s=fe[t].products)||void 0===s?void 0:s[o])||void 0===r?void 0:r.variants)||[]).forEach((()=>{e+=1}))}))})),he(e)}),[Z,fe,z]),s.useEffect((()=>{ie&&(pe(!0),R.productFetcher(ie,b,X).then((e=>{Object.keys(e).length&&ee({type:"productsFetched",data:{collectionId:ie,products:e}}),pe(!1)})).catch())}),[ie]),s.useEffect((()=>{const e=setTimeout((()=>{"rearrange"!==te&&(je.length||"collections"!==te)&&(je.length?(Ce(!0),R.searchFetcher(b,je,X).then((e=>{"collections"in e&&"products"in e?(be({type:"set",data:e}),ee({type:"searched",data:e.collections}),ee({type:"searched",data:e.products})):(be({type:"set",data:{collections:{},products:e}}),ee({type:"searched",data:e})),oe("searchProducts"),pe(!1),Ce(!1)}))):oe("collections"))}),800);return()=>clearTimeout(e)}),[je]),s.useEffect((()=>{M&&(R.onAdd(fe,xe),Pe())}),[M]),s.useEffect((()=>{H&&Object.keys(fe||{}).length&&xe&&(R.onAdd(fe,xe),Pe())}),[H,fe,xe]);const Pe=()=>{Ee({type:"reset",data:{}})},Te=()=>I&&xe>I?e.jsxRuntimeExports.jsx(d.Tag,{tagText:`You can only select ${I} products`,type:"negative"}):O&&xe>O?e.jsxRuntimeExports.jsx(d.Tag,{tagText:`You can only select ${O} products`,type:"negative"}):xe>0?e.jsxRuntimeExports.jsx(n.Button,{onClick:()=>{oe(_?g.ScreenName.RearrangeProducts:g.ScreenName.SelectedProducts)},buttonText:I?`${xe}/${I} products selected`:`${xe} products selected`,buttonType:["rearrange","view"].includes(te)?"tertiaryGray":"tertiary",disabled:["rearrange","view"].includes(te)}):e.jsxRuntimeExports.jsx(n.Button,{disabled:!0,buttonText:I?`${xe}/${I} products selected`:`${xe} products selected`,buttonType:"tertiaryGray"}),De=e=>ue?"Loading...":te===g.ScreenName.RearrangeProducts?null!=e?e:"Done":null!=e?e:"Add",qe=e.jsxRuntimeExports.jsxs(C.ContainerStyle,Object.assign({style:null!=W?W:{}},{children:[R.postHeader&&e.jsxRuntimeExports.jsx("div",Object.assign({style:{padding:"0 24px"}},{children:R.postHeader})),!R.hideGlobalSearch&&e.jsxRuntimeExports.jsx(e.jsxRuntimeExports.Fragment,{children:("collections"===te||"searchProducts"===te)&&e.jsxRuntimeExports.jsx("div",Object.assign({style:{padding:L?"8px 16px":"12px 24px",borderBottom:"1px solid #E0E0E0"}},{children:e.jsxRuntimeExports.jsx(i.Input,{placeholder:"Search using ID, Name or SKU ID",noKeyDownChange:!0,noErrorHint:!0,rightIcon:{icon:()=>Se?e.jsxRuntimeExports.jsx(a.Spinner,{size:"small",color:r.COLORS.content.primary}):e.jsxRuntimeExports.jsx(o.default,{})},id:"listInput",height:"24px",type:"text",value:je,onChangeText:e=>{e.length&&e.trim().length?me(e):me("")}})}))}),e.jsxRuntimeExports.jsxs(C.ScrollContainerStyle,Object.assign({ref:ve,screenName:te},{children:["collections"===te&&e.jsxRuntimeExports.jsx(u.CollectionsScreen,{customCollectionRestriction:R.customCollectionRestriction,dataLoading:ge,collections:Z,selectedCollectionsDispatch:Ee,setCollectionId:ne,setSelectedCollectionId:le,setScreen:oe,selectedCollections:fe,collectionFetcher:R.collectionFetcher,storeId:b,appType:X,collectionsDispatch:ee,setSaveDisabled:pe,pagingControls:{curPage:ae,setCurPage:de},hideCollectionCheckbox:F,renderWithoutModal:L,pickerType:V,scrollContainerRef:ve}),"products"===te&&ce&&e.jsxRuntimeExports.jsx(j.CollectionIdContext.Provider,Object.assign({value:ce},{children:e.jsxRuntimeExports.jsx(x.ProductsScreen,{hideInCollectionSearch:R.hideInCollectionSearch,customCollectionRestriction:R.customCollectionRestriction,productFetcher:R.productFetcher,setScreen:oe,storeId:b,appType:X,data:Z[ce],collectionsDispatch:ee,selectedCollectionsDispatch:Ee,selectedData:fe,setSaveDisabled:pe,searchInCollectionFetcher:R.searchInCollectionFetcher,hideProductCheckbox:P,outOfStockAction:T,hideVariantCheckbox:D,selectProductsFromCustomCollection:q,renderWithoutModal:L,pickerType:V,hideProductVariants:z,fbStatusFetcher:R.fbStatusFetcher,onProductDetailClick:e=>{Ie(!0),Fe(e)},showProductDetailInfoIcon:K,scrollContainerRef:ve})})),"view"===te&&e.jsxRuntimeExports.jsx(S.SelectedScreen,{selectedCollections:fe||{},selectedCollectionsDispatch:Ee,setScreen:oe,collections:Z,hideProductVariants:z,outOfStockAction:T,storeId:b,appType:X,fbStatusFetcher:R.fbStatusFetcher}),"rearrange"===te&&e.jsxRuntimeExports.jsx(h.RearrangeScreen,{selectedCollections:fe||{},selectedCollectionsDispatch:Ee,setScreen:oe,outOfStockAction:T,rearrangeViewType:"grid"===se?"list":"grid",scrollContainerRef:ve,storeId:b,appType:X,fbStatusFetcher:R.fbStatusFetcher}),"searchProducts"===te&&e.jsxRuntimeExports.jsx(m.SearchScreen,{customCollectionRestriction:R.customCollectionRestriction,selectedCollections:fe||{},searchedCollections:Re||{},searchedCollectionsDispatch:be,selectedCollectionsDispatch:Ee,setScreen:oe,collections:Z,onBackPress:()=>{me(""),be({type:"set",data:{collections:{},products:{}}})},pickerType:V,hideProductCheckbox:P,hideProductVariants:z,hideVariantCheckbox:D,storeId:b,appType:X,fbStatusFetcher:R.fbStatusFetcher,setCollectionId:ne,setSelectedCollectionId:le,renderWithoutModal:L,hideCollectionCheckbox:F,outOfStockAction:T})]}))]}));return e.jsxRuntimeExports.jsx(e.jsxRuntimeExports.Fragment,{children:L?e.jsxRuntimeExports.jsxs(e.jsxRuntimeExports.Fragment,{children:[qe,U.renderFooter?e.jsxRuntimeExports.jsxs(C.StyledFooterForNonModal,{children:[Te(),e.jsxRuntimeExports.jsx(n.Button,{buttonText:De(U.primaryButtonText),disabled:!U.isLoading&&(ue||xe<1||I&&xe<I||!I&&O&&xe>O)||U.primaryButtonDisabled,isLoading:U.isLoading,onClick:()=>{R.onAdd(fe,xe),Pe(),oe([g.ScreenName.Collections,g.ScreenName.RearrangeProducts].includes($)?$:g.ScreenName.Collections)}})]}):e.jsxRuntimeExports.jsx(e.jsxRuntimeExports.Fragment,{}),ke&&Oe?e.jsxRuntimeExports.jsx(p.ProductInfoOverlay,{productData:Oe,outOfStockAction:T,useDynamicInfoImageSize:R.useDynamicInfoImageSize,onClose:()=>{Ie(!1)}}):e.jsxRuntimeExports.jsx(e.jsxRuntimeExports.Fragment,{})]}):e.jsxRuntimeExports.jsxs(l.StyledModal,Object.assign({zIndex:k,open:v,onClose:()=>{null==E||E(),Pe()},headingTitle:A||("collections"===te||"products"===te?"Select Products":"view"===te?"Selected Products":"searchProducts"===te?"Searched Results":"rearrange"===te?"Rearrange Products":void 0),headingSubtitle:Q,footerShadow:!0,centralContainerStyles:{width:B||"600px",left:w||"auto"},headerRightCustomElement:G?e.jsxRuntimeExports.jsx("div",Object.assign({style:{cursor:"pointer",display:"flex"},onClick:E},{children:e.jsxRuntimeExports.jsx(c.default,{width:20,height:20,color:r.COLORS.content.secondary})})):e.jsxRuntimeExports.jsx(e.jsxRuntimeExports.Fragment,{}),footerContainerStyle:R.stickyFooter?{position:"absolute",bottom:0,left:0,width:"100%",zIndex:9,background:r.COLORS.surface.standard}:void 0,primaryButton:Y?(e=>Object.assign(Object.assign({},e),{disabled:!e.isLoading&&(ue||xe<1||I&&xe<I||!I&&O&&xe>O)||e.disabled,onClick:()=>{R.onAdd(fe,xe),Pe(),oe([g.ScreenName.Collections,g.ScreenName.RearrangeProducts].includes($)?$:g.ScreenName.Collections)}}))(Y):{buttonText:De(),disabled:ue||xe<1||I&&xe<I||!I&&O&&xe>O||!1,onClick:()=>{R.onAdd(fe,xe),Pe()}},secondaryButton:J?(e=>Object.assign(Object.assign({},e),{disabled:ue||xe<1||I&&xe<I||!I&&O&&xe>O||!1,onClick:()=>{const e=y.updateAllVariantsForSelectedProducts(fe,Z,Re);R.onAdd(e,xe,!0)}}))(J):void 0,wrapperStyle:R.stickyFooter?{height:"calc(100vh - 168px)"}:void 0,footerLeftCustomElement:N?e.jsxRuntimeExports.jsx(e.jsxRuntimeExports.Fragment,{}):Te(),hideCrossButton:ke||G},{children:[qe,ke&&Oe?e.jsxRuntimeExports.jsx(p.ProductInfoOverlay,{productData:Oe,useDynamicInfoImageSize:R.useDynamicInfoImageSize,outOfStockAction:T,onClose:()=>{Ie(!1)}}):e.jsxRuntimeExports.jsx(e.jsxRuntimeExports.Fragment,{})]}))})};
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../../../node_modules/react/jsx-runtime.js");require("../../../node_modules/@bikdotai/bik-models/growth/index.js");var t=require("../../../assets/icons/arrow_back.svg.js"),l=require("../../../assets/icons/chevronLeft.svg.js"),n=require("../../../assets/icons/chevronRight.svg.js"),i=require("../../../assets/icons/PlusIcon.js"),s=require("lodash"),o=require("react"),r=require("../../button/Button.js"),a=require("../../icon-button/IconButton.js"),d=require("../../product-picker-v2/modal.js"),u=require("../../product-picker-v2/type.js"),c=require("../Badge/index.js"),p=require("../context/templateModalContext.js"),m=require("./EditWhatsAppTemplateV2.js"),x=require("./ProductBox.js");require("../../template-preview/TemplatePreview.js"),require("../../template-preview/WhatsApp/WhatsAppLikePreview.js"),require("../../template-preview/WhatsApp/WhatsAppLikePreviewV2.js");var v=require("../../../constants/Theme.js");require("../../curtain/CurtainHelper.js"),require("../../variable-picker-v3/model.js"),require("../../template-preview/models/TemplateMeta.js");var h=require("../../template-preview/models/WhatsAppTemplate.js");require("../../template-preview/models/Channels.js");var g=require("../../template-preview/helpers/templateMiscHelper.js"),j=require("../../TypographyStyle.js"),y=require("../../../_virtual/index.js");exports.default=f=>{let{template:b,whatsappSpecificPickerMeta:C,showVariableModal:R,variableListForImage:E,discountCode:O,setDiscountCode:I}=f;var S,q,k,w,P,T,B,L;const{selectedCarouselIndex:M,setTemplate:A,pickerConf:D,isProductCarouselType:_,pod:F,cardCount:V,carouselProducts:W,setCarouselProducts:N,isError:$,cardImages:z,disableEditVariable:G,onDeleteSelectedProducts:H,setSelectedCarouselIndex:K,setVariableCallback:J,setShowVariablePicker:Q,sliderRef:U}=p.useTemplateModalContext(),[X,Y]=o.useState(g.isRCSChannel(null==b?void 0:b.channel)?"Carousel Cards":-1==M?"First Message (Step 1/2)":_?"Product Carousel "+((null===(q=null===(S=null==b?void 0:b.mapping)||void 0===S?void 0:S.body)||void 0===q?void 0:q.length)?"(Step 2/2)":""):"Carousel Cards "+((null===(w=null===(k=null==b?void 0:b.mapping)||void 0===k?void 0:k.body)||void 0===w?void 0:w.length)?"(Step 2/2)":"")),[Z,ee]=o.useState(!1),[te,le]=o.useState(!1),ne=M===(null!=V?V:-1)-1,ie=(null!=M?M:-1)<1;o.useEffect((()=>{var e,t,l,n;Y(g.isRCSChannel(null==b?void 0:b.channel)?"Carousel Cards":-1==M?"First Message (Step 1/2)":_?"Product Carousel "+((null===(t=null===(e=null==b?void 0:b.mapping)||void 0===e?void 0:e.body)||void 0===t?void 0:t.length)?"(Step 2/2)":""):"Carousel Cards "+((null===(n=null===(l=null==b?void 0:b.mapping)||void 0===l?void 0:l.body)||void 0===n?void 0:n.length)?"(Step 2/2)":""))}),[M]);const se=e=>{null==N||N([{name:"variable",productName:e.actualValue}])};return o.useEffect((()=>{-1===M&&g.isRCSChannel(null==b?void 0:b.channel)&&(null==K||K(0))}),[M,null==b?void 0:b.channel]),e.jsxRuntimeExports.jsxs("div",Object.assign({style:{display:"flex",flexDirection:"column",gap:"16px"}},{children:[e.jsxRuntimeExports.jsxs("div",Object.assign({style:{display:"flex",flexDirection:"row",alignItems:"center"}},{children:[!g.isRCSChannel(null==b?void 0:b.channel)&&null!=M&&M>=0&&!!(null===(T=null===(P=null==b?void 0:b.mapping)||void 0===P?void 0:P.body)||void 0===T?void 0:T.length)&&e.jsxRuntimeExports.jsx(a.IconButton,{Icon:t.default,onClick:()=>{null==K||K(-1)}}),e.jsxRuntimeExports.jsx(j.TitleMedium,Object.assign({style:{marginLeft:10}},{children:X}))]})),_&&(null!==(B=null==W?void 0:W.length)&&void 0!==B?B:0)>0&&null!=M&&M>=0&&e.jsxRuntimeExports.jsxs("div",Object.assign({style:{display:"flex",rowGap:8,marginBottom:16,marginLeft:10,marginRight:10,flexDirection:"column"}},{children:[e.jsxRuntimeExports.jsx(x.ProductBox,{editItem:()=>{1===(null==W?void 0:W.length)&&"variable"===W[0].name?(J((()=>se)),Q(!0)):ee(!Z)},cardBody:1===(null==W?void 0:W.length)&&"variable"===W[0].name?`${W[0].productName}`:`${null==W?void 0:W.length} Products Selected`,hideIcon:1===(null==W?void 0:W.length)&&"variable"===W[0].name,deleteItem:()=>{var e;if(1===(null==W?void 0:W.length)&&"variable"===W[0].name)return void(null==N||N([]));const t=s.cloneDeep(Object.assign({},b));t&&(z&&z.length>0?null==z||z.forEach(((e,l)=>{var n;t.components[1].cards[l].components[0].example.header_handle=[null!==(n=z[l])&&void 0!==n?n:"https://res.cloudinary.com/drqhot9ot/image/upload/v1708753454/fake-product.png"]})):null===(e=null==t?void 0:t.components[1].cards)||void 0===e||e.forEach(((e,l)=>{t.components[1].cards[l].components[0].example.header_handle=["https://res.cloudinary.com/drqhot9ot/image/upload/v1708753454/fake-product.png"]})),null==A||A(t)),null==N||N([]),null==H||H()}}),W&&(null==W?void 0:W.length)>0&&"variable"!=W[0].name&&e.jsxRuntimeExports.jsx(r.Button,{disabled:(null!==(L=null==W?void 0:W.length)&&void 0!==L?L:0)<=1,style:{alignSelf:"flex-end"},onClick:()=>{le(!0),ee(!0)},buttonText:"Rearrange Products",buttonType:"tertiary"})]})),!G&&_&&0===(null==W?void 0:W.length)&&null!=M&&M>=0&&e.jsxRuntimeExports.jsxs(e.jsxRuntimeExports.Fragment,{children:[e.jsxRuntimeExports.jsxs("div",Object.assign({style:{marginLeft:12}},{children:[e.jsxRuntimeExports.jsx(j.TitleRegular,{children:"Product(s)"}),e.jsxRuntimeExports.jsx(j.BodySecondary,{children:`Select ${null!=V?V:1} products`})]})),e.jsxRuntimeExports.jsxs("div",Object.assign({style:{marginTop:16,marginBottom:16,marginLeft:$?16:12,marginRight:$?16:12,flexDirection:"column",display:"flex",alignItems:"center"}},{children:[e.jsxRuntimeExports.jsx(r.Button,{matchParentWidth:!0,style:{flex:1,display:"flex",width:"100%",marginBottom:12,border:$?`2px dashed ${v.COLORS.content.negative}`:void 0},size:"medium",buttonText:"Add Product(s)",buttonType:$?"tertiaryGray":"dashBold",LeadingIcon:()=>e.jsxRuntimeExports.jsx("div",Object.assign({style:{display:"flex",width:18,height:18}},{children:e.jsxRuntimeExports.jsx(i.default,{width:18,height:18,color:v.COLORS.content.secondary})})),onClick:e=>{ee(!0)}}),F===h.POD.CHATBOT&&e.jsxRuntimeExports.jsxs(e.jsxRuntimeExports.Fragment,{children:[e.jsxRuntimeExports.jsxs("div",Object.assign({style:{display:"flex",flex:1,alignItems:"center",justifyContent:"space-between",flexDirection:"row",width:"100%"}},{children:[e.jsxRuntimeExports.jsx("div",{style:{width:"100%",height:1,backgroundColor:"#E0E0E0",marginRight:8}}),e.jsxRuntimeExports.jsx(j.BodyCaption,Object.assign({style:{color:"#616161",overflow:"unset"}},{children:"OR"})),e.jsxRuntimeExports.jsx("div",{style:{width:"100%",height:1,backgroundColor:"#E0E0E0",marginLeft:8}})]})),e.jsxRuntimeExports.jsx(r.Button,{matchParentWidth:!0,style:{flex:1,display:"flex",marginTop:12,width:"100%",border:$?`2px dashed ${v.COLORS.content.negative}`:void 0},size:"medium",buttonText:"Add Product(s) Variable",buttonType:$?"tertiaryGray":"dashBold",LeadingIcon:()=>e.jsxRuntimeExports.jsx("div",Object.assign({style:{display:"flex"}},{children:e.jsxRuntimeExports.jsx(i.default,{width:18,height:18,color:v.COLORS.content.secondary})})),onClick:e=>{J((()=>se)),Q(!0)}})]})]})),$&&e.jsxRuntimeExports.jsx("div",Object.assign({style:{marginLeft:10,marginBottom:16}},{children:e.jsxRuntimeExports.jsx(c.Badge,{padding:"8px",errorText:"Please add products"})}))]}),!_&&(null!=M?M:-1)>-1&&e.jsxRuntimeExports.jsxs("div",Object.assign({style:{display:"flex",background:v.COLORS.surface.hovered,alignItems:"center"}},{children:[e.jsxRuntimeExports.jsx(a.IconButton,{Icon:l.default,disabled:ie,width:8,height:14,svgStyle:ie?{}:{color:v.COLORS.content.secondary},onClick:()=>{var e;null===(e=null==U?void 0:U.current)||void 0===e||e.slickPrev(),(null!=M?M:-1)<1||null==K||K((e=>e-1))}}),e.jsxRuntimeExports.jsx(j.TitleRegular,Object.assign({style:{flex:1,display:"flex",justifyContent:"center"},color:v.COLORS.content.secondary},{children:`Card ${(null!=M?M:0)+1}/${V}`})),e.jsxRuntimeExports.jsx(a.IconButton,{Icon:n.default,width:8,height:14,disabled:ne,svgStyle:ne?{}:{color:v.COLORS.content.secondary},onClick:()=>{var e;null===(e=null==U?void 0:U.current)||void 0===e||e.slickNext(),(null!=M?M:-1)>=(null!=V?V:-1)-1||null==K||K((e=>e+1))}})]})),e.jsxRuntimeExports.jsx(m.default,{whatsappSpecificPickerMeta:C,template:b,onTemplateChange:e=>{null==A||A(e)},showVariableModal:R,variableListForImage:E,discountCode:O,setDiscountCode:I}),Z&&D&&e.jsxRuntimeExports.jsx(d.ProductPickerModal,{zIndex:200,startupScreen:te?u.ScreenName.RearrangeProducts:u.ScreenName.Collections,rearrangeEnabled:!0,storeId:D.storeId,selectedItems:(e=>{if(e.length>0){const t={};for(const l of e){const e=null==l?void 0:l.collectionId,n=l.productId,i=l.variantId;e in t||(t[e]={products:{},name:"",image:"",isSmartCollection:!1}),n in t[e].products||(t[e].products[n]={variants:{},name:(null==l?void 0:l.productName)||"",image:(null==l?void 0:l.productImage)||""}),t[e].products[n].variants[i]={name:(null==l?void 0:l.name)||"",price:"",image:(null==l?void 0:l.image)||"",quantity:l.quantity||0,displayOrder:l.displayOrder}}return t}return{}})(null!=W?W:[]),collectionFetcher:D.fetchCollections,productFetcher:D.fetchProducts,onAdd:(e,t)=>{var l,n,i,o,r,a;le(!1);const d=[];delete e.isCustom;for(const t of Object.keys(e)){const s=e[t].products;if(void 0!==s&&Object.keys(s).length)for(const e of Object.keys(s)){const u=s[e].variants;if(void 0!==u&&Object.keys(u).length)for(const c of Object.keys(u)){const{name:p,image:m,quantity:x,displayOrder:v}=u[c],h={name:p,image:null!==(n=null!=m?m:null===(l=s[e])||void 0===l?void 0:l.image)&&void 0!==n?n:"",quantity:x,variantId:c,productId:e,displayOrder:v,collectionId:t,productName:null!==(o=null===(i=s[e])||void 0===i?void 0:i.name)&&void 0!==o?o:"",productImage:null!==(a=null===(r=s[e])||void 0===r?void 0:r.image)&&void 0!==a?a:""};d.push(h)}}}const u=d.sort(((e,t)=>e.displayOrder-t.displayOrder)),c=d.map((e=>e.image)),p=s.cloneDeep(Object.assign({},b));p&&(c.forEach(((e,t)=>{var l;p.components[1].cards[t].components[0].example.header_handle=e?[e]:[null!==(l=null==z?void 0:z[t])&&void 0!==l?l:""]})),null==A||A(p)),null==N||N(u),ee(!1)},searchInCollectionFetcher:D.searchInCollection,searchFetcher:D.searchProducts,visible:Z,onClose:()=>{ee(!1)},exactLimit:null!=V?V:1,appType:D.appType||y.__exports.ApplicationType.BIK})]}))};
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../../../node_modules/react/jsx-runtime.js"),t=require("@bikdotai/bik-models/growth"),l=require("../../../assets/icons/arrow_back.svg.js"),n=require("../../../assets/icons/chevronLeft.svg.js"),i=require("../../../assets/icons/chevronRight.svg.js"),s=require("../../../assets/icons/PlusIcon.js"),o=require("lodash"),r=require("react"),a=require("../../button/Button.js"),d=require("../../icon-button/IconButton.js"),u=require("../../product-picker-v2/modal.js"),c=require("../../product-picker-v2/type.js"),p=require("../Badge/index.js"),m=require("../context/templateModalContext.js"),x=require("./EditWhatsAppTemplateV2.js"),v=require("./ProductBox.js");require("../../template-preview/TemplatePreview.js"),require("../../template-preview/WhatsApp/WhatsAppLikePreview.js"),require("../../template-preview/WhatsApp/WhatsAppLikePreviewV2.js");var h=require("../../../constants/Theme.js");require("../../curtain/CurtainHelper.js"),require("../../variable-picker-v3/model.js"),require("../../template-preview/models/TemplateMeta.js");var g=require("../../template-preview/models/WhatsAppTemplate.js");require("../../template-preview/models/Channels.js");var j=require("../../template-preview/helpers/templateMiscHelper.js"),y=require("../../TypographyStyle.js");exports.default=f=>{let{template:b,whatsappSpecificPickerMeta:C,showVariableModal:R,variableListForImage:E,discountCode:O,setDiscountCode:I}=f;var S,q,k,w,P,T,B,L;const{selectedCarouselIndex:M,setTemplate:A,pickerConf:D,isProductCarouselType:F,pod:V,cardCount:W,carouselProducts:N,setCarouselProducts:$,isError:_,cardImages:z,disableEditVariable:G,onDeleteSelectedProducts:H,setSelectedCarouselIndex:K,setVariableCallback:J,setShowVariablePicker:Q,sliderRef:U}=m.useTemplateModalContext(),[X,Y]=r.useState(j.isRCSChannel(null==b?void 0:b.channel)?"Carousel Cards":-1==M?"First Message (Step 1/2)":F?"Product Carousel "+((null===(q=null===(S=null==b?void 0:b.mapping)||void 0===S?void 0:S.body)||void 0===q?void 0:q.length)?"(Step 2/2)":""):"Carousel Cards "+((null===(w=null===(k=null==b?void 0:b.mapping)||void 0===k?void 0:k.body)||void 0===w?void 0:w.length)?"(Step 2/2)":"")),[Z,ee]=r.useState(!1),[te,le]=r.useState(!1),ne=M===(null!=W?W:-1)-1,ie=(null!=M?M:-1)<1;r.useEffect((()=>{var e,t,l,n;Y(j.isRCSChannel(null==b?void 0:b.channel)?"Carousel Cards":-1==M?"First Message (Step 1/2)":F?"Product Carousel "+((null===(t=null===(e=null==b?void 0:b.mapping)||void 0===e?void 0:e.body)||void 0===t?void 0:t.length)?"(Step 2/2)":""):"Carousel Cards "+((null===(n=null===(l=null==b?void 0:b.mapping)||void 0===l?void 0:l.body)||void 0===n?void 0:n.length)?"(Step 2/2)":""))}),[M]);const se=e=>{null==$||$([{name:"variable",productName:e.actualValue}])};return r.useEffect((()=>{-1===M&&j.isRCSChannel(null==b?void 0:b.channel)&&(null==K||K(0))}),[M,null==b?void 0:b.channel]),e.jsxRuntimeExports.jsxs("div",Object.assign({style:{display:"flex",flexDirection:"column",gap:"16px"}},{children:[e.jsxRuntimeExports.jsxs("div",Object.assign({style:{display:"flex",flexDirection:"row",alignItems:"center"}},{children:[!j.isRCSChannel(null==b?void 0:b.channel)&&null!=M&&M>=0&&!!(null===(T=null===(P=null==b?void 0:b.mapping)||void 0===P?void 0:P.body)||void 0===T?void 0:T.length)&&e.jsxRuntimeExports.jsx(d.IconButton,{Icon:l.default,onClick:()=>{null==K||K(-1)}}),e.jsxRuntimeExports.jsx(y.TitleMedium,Object.assign({style:{marginLeft:10}},{children:X}))]})),F&&(null!==(B=null==N?void 0:N.length)&&void 0!==B?B:0)>0&&null!=M&&M>=0&&e.jsxRuntimeExports.jsxs("div",Object.assign({style:{display:"flex",rowGap:8,marginBottom:16,marginLeft:10,marginRight:10,flexDirection:"column"}},{children:[e.jsxRuntimeExports.jsx(v.ProductBox,{editItem:()=>{1===(null==N?void 0:N.length)&&"variable"===N[0].name?(J((()=>se)),Q(!0)):ee(!Z)},cardBody:1===(null==N?void 0:N.length)&&"variable"===N[0].name?`${N[0].productName}`:`${null==N?void 0:N.length} Products Selected`,hideIcon:1===(null==N?void 0:N.length)&&"variable"===N[0].name,deleteItem:()=>{var e;if(1===(null==N?void 0:N.length)&&"variable"===N[0].name)return void(null==$||$([]));const t=o.cloneDeep(Object.assign({},b));t&&(z&&z.length>0?null==z||z.forEach(((e,l)=>{var n;t.components[1].cards[l].components[0].example.header_handle=[null!==(n=z[l])&&void 0!==n?n:"https://res.cloudinary.com/drqhot9ot/image/upload/v1708753454/fake-product.png"]})):null===(e=null==t?void 0:t.components[1].cards)||void 0===e||e.forEach(((e,l)=>{t.components[1].cards[l].components[0].example.header_handle=["https://res.cloudinary.com/drqhot9ot/image/upload/v1708753454/fake-product.png"]})),null==A||A(t)),null==$||$([]),null==H||H()}}),N&&(null==N?void 0:N.length)>0&&"variable"!=N[0].name&&e.jsxRuntimeExports.jsx(a.Button,{disabled:(null!==(L=null==N?void 0:N.length)&&void 0!==L?L:0)<=1,style:{alignSelf:"flex-end"},onClick:()=>{le(!0),ee(!0)},buttonText:"Rearrange Products",buttonType:"tertiary"})]})),!G&&F&&0===(null==N?void 0:N.length)&&null!=M&&M>=0&&e.jsxRuntimeExports.jsxs(e.jsxRuntimeExports.Fragment,{children:[e.jsxRuntimeExports.jsxs("div",Object.assign({style:{marginLeft:12}},{children:[e.jsxRuntimeExports.jsx(y.TitleRegular,{children:"Product(s)"}),e.jsxRuntimeExports.jsx(y.BodySecondary,{children:`Select ${null!=W?W:1} products`})]})),e.jsxRuntimeExports.jsxs("div",Object.assign({style:{marginTop:16,marginBottom:16,marginLeft:_?16:12,marginRight:_?16:12,flexDirection:"column",display:"flex",alignItems:"center"}},{children:[e.jsxRuntimeExports.jsx(a.Button,{matchParentWidth:!0,style:{flex:1,display:"flex",width:"100%",marginBottom:12,border:_?`2px dashed ${h.COLORS.content.negative}`:void 0},size:"medium",buttonText:"Add Product(s)",buttonType:_?"tertiaryGray":"dashBold",LeadingIcon:()=>e.jsxRuntimeExports.jsx("div",Object.assign({style:{display:"flex",width:18,height:18}},{children:e.jsxRuntimeExports.jsx(s.default,{width:18,height:18,color:h.COLORS.content.secondary})})),onClick:e=>{ee(!0)}}),V===g.POD.CHATBOT&&e.jsxRuntimeExports.jsxs(e.jsxRuntimeExports.Fragment,{children:[e.jsxRuntimeExports.jsxs("div",Object.assign({style:{display:"flex",flex:1,alignItems:"center",justifyContent:"space-between",flexDirection:"row",width:"100%"}},{children:[e.jsxRuntimeExports.jsx("div",{style:{width:"100%",height:1,backgroundColor:"#E0E0E0",marginRight:8}}),e.jsxRuntimeExports.jsx(y.BodyCaption,Object.assign({style:{color:"#616161",overflow:"unset"}},{children:"OR"})),e.jsxRuntimeExports.jsx("div",{style:{width:"100%",height:1,backgroundColor:"#E0E0E0",marginLeft:8}})]})),e.jsxRuntimeExports.jsx(a.Button,{matchParentWidth:!0,style:{flex:1,display:"flex",marginTop:12,width:"100%",border:_?`2px dashed ${h.COLORS.content.negative}`:void 0},size:"medium",buttonText:"Add Product(s) Variable",buttonType:_?"tertiaryGray":"dashBold",LeadingIcon:()=>e.jsxRuntimeExports.jsx("div",Object.assign({style:{display:"flex"}},{children:e.jsxRuntimeExports.jsx(s.default,{width:18,height:18,color:h.COLORS.content.secondary})})),onClick:e=>{J((()=>se)),Q(!0)}})]})]})),_&&e.jsxRuntimeExports.jsx("div",Object.assign({style:{marginLeft:10,marginBottom:16}},{children:e.jsxRuntimeExports.jsx(p.Badge,{padding:"8px",errorText:"Please add products"})}))]}),!F&&(null!=M?M:-1)>-1&&e.jsxRuntimeExports.jsxs("div",Object.assign({style:{display:"flex",background:h.COLORS.surface.hovered,alignItems:"center"}},{children:[e.jsxRuntimeExports.jsx(d.IconButton,{Icon:n.default,disabled:ie,width:8,height:14,svgStyle:ie?{}:{color:h.COLORS.content.secondary},onClick:()=>{var e;null===(e=null==U?void 0:U.current)||void 0===e||e.slickPrev(),(null!=M?M:-1)<1||null==K||K((e=>e-1))}}),e.jsxRuntimeExports.jsx(y.TitleRegular,Object.assign({style:{flex:1,display:"flex",justifyContent:"center"},color:h.COLORS.content.secondary},{children:`Card ${(null!=M?M:0)+1}/${W}`})),e.jsxRuntimeExports.jsx(d.IconButton,{Icon:i.default,width:8,height:14,disabled:ne,svgStyle:ne?{}:{color:h.COLORS.content.secondary},onClick:()=>{var e;null===(e=null==U?void 0:U.current)||void 0===e||e.slickNext(),(null!=M?M:-1)>=(null!=W?W:-1)-1||null==K||K((e=>e+1))}})]})),e.jsxRuntimeExports.jsx(x.default,{whatsappSpecificPickerMeta:C,template:b,onTemplateChange:e=>{null==A||A(e)},showVariableModal:R,variableListForImage:E,discountCode:O,setDiscountCode:I}),Z&&D&&e.jsxRuntimeExports.jsx(u.ProductPickerModal,{zIndex:200,startupScreen:te?c.ScreenName.RearrangeProducts:c.ScreenName.Collections,rearrangeEnabled:!0,storeId:D.storeId,selectedItems:(e=>{if(e.length>0){const t={};for(const l of e){const e=null==l?void 0:l.collectionId,n=l.productId,i=l.variantId;e in t||(t[e]={products:{},name:"",image:"",isSmartCollection:!1}),n in t[e].products||(t[e].products[n]={variants:{},name:(null==l?void 0:l.productName)||"",image:(null==l?void 0:l.productImage)||""}),t[e].products[n].variants[i]={name:(null==l?void 0:l.name)||"",price:"",image:(null==l?void 0:l.image)||"",quantity:l.quantity||0,displayOrder:l.displayOrder}}return t}return{}})(null!=N?N:[]),collectionFetcher:D.fetchCollections,productFetcher:D.fetchProducts,onAdd:(e,t)=>{var l,n,i,s,r,a;le(!1);const d=[];delete e.isCustom;for(const t of Object.keys(e)){const o=e[t].products;if(void 0!==o&&Object.keys(o).length)for(const e of Object.keys(o)){const u=o[e].variants;if(void 0!==u&&Object.keys(u).length)for(const c of Object.keys(u)){const{name:p,image:m,quantity:x,displayOrder:v}=u[c],h={name:p,image:null!==(n=null!=m?m:null===(l=o[e])||void 0===l?void 0:l.image)&&void 0!==n?n:"",quantity:x,variantId:c,productId:e,displayOrder:v,collectionId:t,productName:null!==(s=null===(i=o[e])||void 0===i?void 0:i.name)&&void 0!==s?s:"",productImage:null!==(a=null===(r=o[e])||void 0===r?void 0:r.image)&&void 0!==a?a:""};d.push(h)}}}const u=d.sort(((e,t)=>e.displayOrder-t.displayOrder)),c=d.map((e=>e.image)),p=o.cloneDeep(Object.assign({},b));p&&(c.forEach(((e,t)=>{var l;p.components[1].cards[t].components[0].example.header_handle=e?[e]:[null!==(l=null==z?void 0:z[t])&&void 0!==l?l:""]})),null==A||A(p)),null==$||$(u),ee(!1)},searchInCollectionFetcher:D.searchInCollection,searchFetcher:D.searchProducts,visible:Z,onClose:()=>{ee(!1)},exactLimit:null!=W?W:1,appType:D.appType||t.ApplicationType.BIK})]}))};
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../../node_modules/react/jsx-runtime.js");require("../../node_modules/@bikdotai/bik-models/growth/index.js");var s=require("../../assets/icons/cross.svg.js"),t=require("../../assets/icons/info.svg.js"),n=require("date-fns"),r=require("react"),i=require("../../constants/Theme.js"),o=require("../avatar/Avatar.js"),a=require("../avatar/AvatarHelper.js"),l=require("../button/Button.js"),c=require("../states/StateComponent.js");require("../../_virtual/_tslib.js");var d=require("../TypographyStyle.js"),u=require("./UnsatisfactoryCountIntentWiseModal.js"),p=require("./UnsatisfactoryResponseList.style.js"),x=require("../../_virtual/index.js");exports.UnsatisfactoryResponseList=j=>{const{storeId:y,appType:h,incorrectMessages:m,onIncorrectMessageBubbleClick:R,setShowIncorrectReplies:f,ChecklistType:g,IntentWiseUnsatisfactoryResponse:v,IntentHeaderTitle:E,redirectToUnsatisfactoryResponse:b,fetchUnsatisfactoryResponseCountIntentWise:I,fetchUnsatisfactoryResponseCount:C}=j,[O,S]=r.useState(""),[T,w]=r.useState((null==m?void 0:m.length)>0),[A,q]=r.useState(!1);return r.useEffect((()=>{!T&&C&&C().then((e=>{e>0&&w(!0),0===e&&f(!1)}))}),[]),e.jsxRuntimeExports.jsx("div",Object.assign({style:{overflow:"scroll",height:"100%"}},{children:e.jsxRuntimeExports.jsxs(p.IncorrectRepliesStyle,{children:[h==x.__exports.ApplicationType.MANIFEST&&e.jsxRuntimeExports.jsxs("div",Object.assign({style:{display:"flex",flexDirection:"column",gap:"8px"}},{children:[e.jsxRuntimeExports.jsxs("div",Object.assign({style:{display:"flex",justifyContent:"space-between",alignItems:"center"}},{children:[e.jsxRuntimeExports.jsx(d.TitleRegular,{children:"Unsatisfactory responses"}),e.jsxRuntimeExports.jsx("div",Object.assign({style:{cursor:"pointer"},onClick:()=>f(!1)},{children:e.jsxRuntimeExports.jsx(s.default,{height:16,width:16,color:i.COLORS.content.primary})}))]})),e.jsxRuntimeExports.jsx(d.BodySecondary,Object.assign({style:{color:i.COLORS.content.secondary}},{children:"Spot unsatisfactory replies, dive deeper, and enhance with relevant data for improved responses."}))]})),!(null==m?void 0:m.length)&&e.jsxRuntimeExports.jsx("div",Object.assign({style:{display:"flex",justifyContent:"center",alignItems:"center",height:"100%"}},{children:e.jsxRuntimeExports.jsx(c.StateComponent,{states:c.StateInterface.WARNING,heading:"No unsatisfactory responses",subline:"As of now, all responses are correct",isButtonEnabled:!1,width:0,size:a.SIZE.SMALL,icon:e.jsxRuntimeExports.jsx(o.Avatar,{type:a.AVATAR_TYPES.ICON,size:a.SIZE.MEDIUM,background:a.AVATAR_BACKGROUND.LIGHT,icon:()=>e.jsxRuntimeExports.jsx(t.default,{width:16,height:16,color:i.COLORS.content.warning})})})})),!!(null==m?void 0:m.length)&&e.jsxRuntimeExports.jsxs(e.jsxRuntimeExports.Fragment,{children:[h==x.__exports.ApplicationType.MANIFEST&&e.jsxRuntimeExports.jsx("div",Object.assign({style:{display:"flex",width:"100%",justifyContent:(null==m?void 0:m.length)?"flex-start":"center"}},{children:e.jsxRuntimeExports.jsx(l.Button,{buttonText:"Fix all unsatisfactory responses",buttonType:"tertiary",size:"small",onClick:()=>{q(!0)},disabled:!T})})),e.jsxRuntimeExports.jsx(u.UnsatisfactoryCountIntentWiseModal,{storeId:y,setShowUnsatisfactoryResponseModal:q,showUnsatisfactoryResponseModal:A,ChecklistType:g,UnsatisfactoryResponseIntentList:v,IntentHeaderTitle:E,fetchUnsatisfactoryResponseCountIntentWise:I,viewIntentWiseUnsatisfactoryResponse:b}),m&&(null==m?void 0:m.length)>0&&e.jsxRuntimeExports.jsx("div",Object.assign({className:"wrapper"},{children:m.map(((s,t)=>e.jsxRuntimeExports.jsxs("div",Object.assign({className:"bubble",onClick:()=>{R(s.messageId),S(s.messageId)},style:O===s.messageId?{backgroundColor:i.COLORS.surface.hovered}:{}},{children:[e.jsxRuntimeExports.jsx(d.BodySecondary,Object.assign({style:{color:i.COLORS.content.primary}},{children:s.message})),e.jsxRuntimeExports.jsx("div",{children:e.jsxRuntimeExports.jsxs(d.Caption,Object.assign({style:{color:i.COLORS.content.secondary}},{children:[n.format(new Date(null==s?void 0:s.date),"hh:mm a")," |"," ",n.format(new Date(null==s?void 0:s.date),"dd/MM/yyyy")]}))})]}),s.messageId)))}))]})]})}))};
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../../node_modules/react/jsx-runtime.js"),s=require("@bikdotai/bik-models/growth"),t=require("../../assets/icons/cross.svg.js"),n=require("../../assets/icons/info.svg.js"),i=require("date-fns"),r=require("react"),o=require("../../constants/Theme.js"),a=require("../avatar/Avatar.js"),l=require("../avatar/AvatarHelper.js"),c=require("../button/Button.js"),d=require("../states/StateComponent.js");require("../../_virtual/_tslib.js");var u=require("../TypographyStyle.js"),p=require("./UnsatisfactoryCountIntentWiseModal.js"),x=require("./UnsatisfactoryResponseList.style.js");exports.UnsatisfactoryResponseList=j=>{const{storeId:y,appType:h,incorrectMessages:m,onIncorrectMessageBubbleClick:R,setShowIncorrectReplies:f,ChecklistType:g,IntentWiseUnsatisfactoryResponse:v,IntentHeaderTitle:E,redirectToUnsatisfactoryResponse:b,fetchUnsatisfactoryResponseCountIntentWise:I,fetchUnsatisfactoryResponseCount:C}=j,[O,S]=r.useState(""),[T,w]=r.useState((null==m?void 0:m.length)>0),[A,U]=r.useState(!1);return r.useEffect((()=>{!T&&C&&C().then((e=>{e>0&&w(!0),0===e&&f(!1)}))}),[]),e.jsxRuntimeExports.jsx("div",Object.assign({style:{overflow:"scroll",height:"100%"}},{children:e.jsxRuntimeExports.jsxs(x.IncorrectRepliesStyle,{children:[h==s.ApplicationType.MANIFEST&&e.jsxRuntimeExports.jsxs("div",Object.assign({style:{display:"flex",flexDirection:"column",gap:"8px"}},{children:[e.jsxRuntimeExports.jsxs("div",Object.assign({style:{display:"flex",justifyContent:"space-between",alignItems:"center"}},{children:[e.jsxRuntimeExports.jsx(u.TitleRegular,{children:"Unsatisfactory responses"}),e.jsxRuntimeExports.jsx("div",Object.assign({style:{cursor:"pointer"},onClick:()=>f(!1)},{children:e.jsxRuntimeExports.jsx(t.default,{height:16,width:16,color:o.COLORS.content.primary})}))]})),e.jsxRuntimeExports.jsx(u.BodySecondary,Object.assign({style:{color:o.COLORS.content.secondary}},{children:"Spot unsatisfactory replies, dive deeper, and enhance with relevant data for improved responses."}))]})),!(null==m?void 0:m.length)&&e.jsxRuntimeExports.jsx("div",Object.assign({style:{display:"flex",justifyContent:"center",alignItems:"center",height:"100%"}},{children:e.jsxRuntimeExports.jsx(d.StateComponent,{states:d.StateInterface.WARNING,heading:"No unsatisfactory responses",subline:"As of now, all responses are correct",isButtonEnabled:!1,width:0,size:l.SIZE.SMALL,icon:e.jsxRuntimeExports.jsx(a.Avatar,{type:l.AVATAR_TYPES.ICON,size:l.SIZE.MEDIUM,background:l.AVATAR_BACKGROUND.LIGHT,icon:()=>e.jsxRuntimeExports.jsx(n.default,{width:16,height:16,color:o.COLORS.content.warning})})})})),!!(null==m?void 0:m.length)&&e.jsxRuntimeExports.jsxs(e.jsxRuntimeExports.Fragment,{children:[h==s.ApplicationType.MANIFEST&&e.jsxRuntimeExports.jsx("div",Object.assign({style:{display:"flex",width:"100%",justifyContent:(null==m?void 0:m.length)?"flex-start":"center"}},{children:e.jsxRuntimeExports.jsx(c.Button,{buttonText:"Fix all unsatisfactory responses",buttonType:"tertiary",size:"small",onClick:()=>{U(!0)},disabled:!T})})),e.jsxRuntimeExports.jsx(p.UnsatisfactoryCountIntentWiseModal,{storeId:y,setShowUnsatisfactoryResponseModal:U,showUnsatisfactoryResponseModal:A,ChecklistType:g,UnsatisfactoryResponseIntentList:v,IntentHeaderTitle:E,fetchUnsatisfactoryResponseCountIntentWise:I,viewIntentWiseUnsatisfactoryResponse:b}),m&&(null==m?void 0:m.length)>0&&e.jsxRuntimeExports.jsx("div",Object.assign({className:"wrapper"},{children:m.map(((s,t)=>e.jsxRuntimeExports.jsxs("div",Object.assign({className:"bubble",onClick:()=>{R(s.messageId),S(s.messageId)},style:O===s.messageId?{backgroundColor:o.COLORS.surface.hovered}:{}},{children:[e.jsxRuntimeExports.jsx(u.BodySecondary,Object.assign({style:{color:o.COLORS.content.primary}},{children:s.message})),e.jsxRuntimeExports.jsx("div",{children:e.jsxRuntimeExports.jsxs(u.Caption,Object.assign({style:{color:o.COLORS.content.secondary}},{children:[i.format(new Date(null==s?void 0:s.date),"hh:mm a")," |"," ",i.format(new Date(null==s?void 0:s.date),"dd/MM/yyyy")]}))})]}),s.messageId)))}))]})]})}))};
@@ -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
- import{j as e}from"../../node_modules/react/jsx-runtime.js";import"../../node_modules/@bikdotai/bik-models/growth/index.js";import t from"../../assets/icons/alert_triangle.svg.js";import o from"../../assets/icons/plus.svg.js";import{memo as n,useState as i,useMemo as s,useEffect as r}from"react";import{COLORS as a}from"../../constants/Theme.js";import{Button as d}from"../button/Button.js";import{BikShimmer as l}from"../shimmer/ShimmerComponent/BikShimmer.js";import{BodyCaption as c}from"../TypographyStyle.js";import{SourceInfoFooterStyle as u}from"./DataSourcePanel.style.js";import{__exports as p}from"../../_virtual/index.js";const h=n((n=>{const{appType:h,sourceIntent:v,hideHeading:T,messageSource:j,trainingSourceCount:b={},ShowTrainingDataSource:A={},faqCount:x,ChecklistType:y,footerButtonOption:f,isFooterLoading:_,reasonForAiGeneratedResponse:I,showAiResponseReason:R}=n,O=A,[F,w]=i(!0),[N,k]=i(!0),C="/bik-ai/training",[D,E]=i({buttonTitle:"",redirectUrl:"",addFaqProps:{}}),[S,P]=i({title:"",subTitle:""}),U=s((()=>{const e=(null==b?void 0:b[v])||0;return e<=1?"There is "+e+"data source added to the identified intent":`There are ${e} data sources added to the identified intent`}),[b,v]),M=()=>{var e;(null==D?void 0:D.redirectUrl)?window.open(`${window.location.origin}${null==D?void 0:D.redirectUrl}`,"_self"):Object.keys(null!==(e=null==D?void 0:D.addFaqProps)&&void 0!==e?e:{}).length>0?null==f||f.onClick(D):(null==f?void 0:f.navigate)&&(null==f||f.navigate("Training",h==p.ApplicationType.MANIFEST?{tab:"/custom_data"}:{},{},!0))};return r((()=>{var e,t,o,n;if(v){if(null===(e=null==j?void 0:j.sources)||void 0===e?void 0:e.length){const e=j.sources[0];if(O[v])v===y.ORDER_ENQUIRY&&k(!1);else{let i=null==e?void 0:e.insights,s="";switch(v){case y.PRODUCT_DETAILS:"Product reviews"!==(null==e?void 0:e.title)&&(i=`${x||"No"} FAQs added for this product`,s="Add product-specific information via FAQs to improve responses",E({buttonTitle:"Add FAQ",addFaqProps:{faqProducts:[{id:null==e?void 0:e.productId,variantId:null==e?void 0:e.variantId,name:null==e?void 0:e.title,imageUrl:null==e?void 0:e.imageUrl}]},redirectUrl:""}));break;case y.ORDER_MODIFICATION:i=(null==b?void 0:b[v])?void 0:"Customers who are looking to modify their orders would be redirected to your live agents via the agent handover flow.",i&&E({buttonTitle:h==p.ApplicationType.MANIFEST?"Manage agent handover":"Add relevant data",redirectUrl:h==p.ApplicationType.MANIFEST?"/customise?tab=AgentHandover":C,addFaqProps:{}});break;case y.ORDER_CANCELLATION:i=(null==b?void 0:b[v])?void 0:"Customers who are looking to cancel their orders would be redirected to your live agents via the agent handover flow.",E({buttonTitle:h==p.ApplicationType.MANIFEST?"Manage agent handover":"Add relevant data",redirectUrl:h==p.ApplicationType.MANIFEST?"/customise?tab=AgentHandover":C,addFaqProps:{}});break;case y.ORDER_TRACKING:if("ORDER_NOT_FOUND"===(null==e?void 0:e.subIntent))break;E({buttonTitle:h==p.ApplicationType.MANIFEST?"Add order tracking link":"Add relevant data",redirectUrl:h==p.ApplicationType.MANIFEST?"/training/order-management":C,addFaqProps:{}});break;case y.PRODUCT_SEARCH:if("QUIZ"===(null==e?void 0:e.type))break;if(-1!==(null===(n=null===(o=null===(t=null==j?void 0:j.sources)||void 0===t?void 0:t[0])||void 0===o?void 0:o.title)||void 0===n?void 0:n.toLowerCase().indexOf("collection"))){i="Collections are recommended by matching queries with collection names and descriptions. Add relevant keywords to your collection description to improve results.";break}i="Products are recommended by matching queries with product names, descriptions, tags, and collections. Add relevant keywords and tags to your products to improve results."}P({title:null!=i?i:"",subTitle:s})}}(O[v]||[y.PRODUCT_DETAILS,y.ORDER_MODIFICATION,y.ORDER_CANCELLATION,y.ORDER_TRACKING].includes(v))&&w(!1)}}),[null==j?void 0:j.messageId,b,v,null==j?void 0:j.sources,O,y,x,h,j]),e.jsx(u,{children:_?e.jsx(e.Fragment,{children:e.jsx(l,{gap:"8px",direction:"column",boxes:[{height:"20px",width:"300px"},{height:"80px",width:"300px"}]})}):e.jsx(e.Fragment,{children:!(null==S?void 0:S.title)&&b&&v in b?e.jsxs(e.Fragment,{children:[e.jsx(m,{hideHeading:null!=T&&T}),e.jsx(g,{reason:I||"",showAiResponseReason:null!=R&&R}),e.jsxs("div",Object.assign({className:"source_info_details "+(b[v]>0?"":"no_data_source")},{children:[b[v]>0&&N?e.jsxs(e.Fragment,{children:[e.jsx(c,{children:U}),e.jsx(c,Object.assign({color:a.content.secondary},{children:"Improve responses by adding more data sources for the identified intent"}))]}):N&&e.jsxs("div",Object.assign({className:"no_data_source_title"},{children:[e.jsx(t,{width:15,height:15,color:a.content.negative,style:{marginTop:2}}),e.jsx(c,{children:"No data sources added to the identified link"})]})),!f||f.hideAddDataButton||F?e.jsx(e.Fragment,{}):e.jsx(d,{size:"small",buttonType:"tertiary",LeadingIcon:o,buttonText:(null==D?void 0:D.buttonTitle.length)>0?null==D?void 0:D.buttonTitle:"Add relevant data",matchParentWidth:!0,onClick:()=>M(),style:{backgroundColor:"unset"}})]}))]}):e.jsxs(e.Fragment,{children:[e.jsx(m,{hideHeading:null!=T&&T}),e.jsx(g,{reason:I||"",showAiResponseReason:null!=R&&R}),e.jsxs("div",Object.assign({className:"source_info_details"},{children:[N&&e.jsxs(e.Fragment,{children:[e.jsx(c,{children:null==S?void 0:S.title}),e.jsx(c,Object.assign({color:a.content.secondary},{children:null==S?void 0:S.subTitle}))]}),!f||f.hideAddDataButton||F?e.jsx(e.Fragment,{}):e.jsx(d,{size:"small",buttonType:"tertiary",LeadingIcon:o,buttonText:(null==D?void 0:D.buttonTitle.length)>0?null==D?void 0:D.buttonTitle:"Add relevant data",matchParentWidth:!0,onClick:()=>M(),style:{backgroundColor:"unset"}})]}))]})})})})),m=n((t=>t.hideHeading?null:e.jsx(c,Object.assign({color:a.content.secondary},{children:"Training insights"})))),g=n((t=>{const[o,n]=i(!1),s=t.reason&&t.reason.length>50,r=s&&!o?t.reason.substring(0,50)+"...":t.reason;return t.showAiResponseReason?e.jsxs("div",Object.assign({className:"source_info_details"},{children:[e.jsx(c,Object.assign({color:a.content.primary,className:"why_ai_gave_this_response"},{children:"Here’s why your AI gave this response"})),e.jsxs(c,Object.assign({color:a.content.secondary,className:"clamp-text"},{children:[r||"No reason provided for this response.",s&&e.jsx(c,Object.assign({color:a.content.brand,style:{cursor:"pointer",textDecoration:"underline",marginTop:"4px"},onClick:()=>n(!o)},{children:o?"Show less":"Show more"}))]}))]})):e.jsx(e.Fragment,{})}));g.displayName="WhyAiGaveThisResponse",m.displayName="TrainingInsightsHeading",h.displayName="SourceInfoFooter";export{h as default};
1
+ import{j as e}from"../../node_modules/react/jsx-runtime.js";import{ApplicationType as t}from"@bikdotai/bik-models/growth";import o from"../../assets/icons/alert_triangle.svg.js";import n from"../../assets/icons/plus.svg.js";import{memo as i,useState as s,useMemo as r,useEffect as a}from"react";import{COLORS as d}from"../../constants/Theme.js";import{Button as l}from"../button/Button.js";import{BikShimmer as c}from"../shimmer/ShimmerComponent/BikShimmer.js";import{BodyCaption as u}from"../TypographyStyle.js";import{SourceInfoFooterStyle as h}from"./DataSourcePanel.style.js";const m=i((i=>{const{appType:m,sourceIntent:p,hideHeading:b,messageSource:j,trainingSourceCount:T={},ShowTrainingDataSource:x={},faqCount:A,ChecklistType:f,footerButtonOption:y,isFooterLoading:I,reasonForAiGeneratedResponse:R,showAiResponseReason:O}=i,F=x,[_,w]=s(!0),[N,k]=s(!0),C="/bik-ai/training",[D,E]=s({buttonTitle:"",redirectUrl:"",addFaqProps:{}}),[S,P]=s({title:"",subTitle:""}),U=r((()=>{const e=(null==T?void 0:T[p])||0;return e<=1?"There is "+e+"data source added to the identified intent":`There are ${e} data sources added to the identified intent`}),[T,p]),M=()=>{var e;(null==D?void 0:D.redirectUrl)?window.open(`${window.location.origin}${null==D?void 0:D.redirectUrl}`,"_self"):Object.keys(null!==(e=null==D?void 0:D.addFaqProps)&&void 0!==e?e:{}).length>0?null==y||y.onClick(D):(null==y?void 0:y.navigate)&&(null==y||y.navigate("Training",m==t.MANIFEST?{tab:"/custom_data"}:{},{},!0))};return a((()=>{var e,o,n,i;if(p){if(null===(e=null==j?void 0:j.sources)||void 0===e?void 0:e.length){const e=j.sources[0];if(F[p])p===f.ORDER_ENQUIRY&&k(!1);else{let s=null==e?void 0:e.insights,r="";switch(p){case f.PRODUCT_DETAILS:"Product reviews"!==(null==e?void 0:e.title)&&(s=`${A||"No"} FAQs added for this product`,r="Add product-specific information via FAQs to improve responses",E({buttonTitle:"Add FAQ",addFaqProps:{faqProducts:[{id:null==e?void 0:e.productId,variantId:null==e?void 0:e.variantId,name:null==e?void 0:e.title,imageUrl:null==e?void 0:e.imageUrl}]},redirectUrl:""}));break;case f.ORDER_MODIFICATION:s=(null==T?void 0:T[p])?void 0:"Customers who are looking to modify their orders would be redirected to your live agents via the agent handover flow.",s&&E({buttonTitle:m==t.MANIFEST?"Manage agent handover":"Add relevant data",redirectUrl:m==t.MANIFEST?"/customise?tab=AgentHandover":C,addFaqProps:{}});break;case f.ORDER_CANCELLATION:s=(null==T?void 0:T[p])?void 0:"Customers who are looking to cancel their orders would be redirected to your live agents via the agent handover flow.",E({buttonTitle:m==t.MANIFEST?"Manage agent handover":"Add relevant data",redirectUrl:m==t.MANIFEST?"/customise?tab=AgentHandover":C,addFaqProps:{}});break;case f.ORDER_TRACKING:if("ORDER_NOT_FOUND"===(null==e?void 0:e.subIntent))break;E({buttonTitle:m==t.MANIFEST?"Add order tracking link":"Add relevant data",redirectUrl:m==t.MANIFEST?"/training/order-management":C,addFaqProps:{}});break;case f.PRODUCT_SEARCH:if("QUIZ"===(null==e?void 0:e.type))break;if(-1!==(null===(i=null===(n=null===(o=null==j?void 0:j.sources)||void 0===o?void 0:o[0])||void 0===n?void 0:n.title)||void 0===i?void 0:i.toLowerCase().indexOf("collection"))){s="Collections are recommended by matching queries with collection names and descriptions. Add relevant keywords to your collection description to improve results.";break}s="Products are recommended by matching queries with product names, descriptions, tags, and collections. Add relevant keywords and tags to your products to improve results."}P({title:null!=s?s:"",subTitle:r})}}(F[p]||[f.PRODUCT_DETAILS,f.ORDER_MODIFICATION,f.ORDER_CANCELLATION,f.ORDER_TRACKING].includes(p))&&w(!1)}}),[null==j?void 0:j.messageId,T,p,null==j?void 0:j.sources,F,f,A,m,j]),e.jsx(h,{children:I?e.jsx(e.Fragment,{children:e.jsx(c,{gap:"8px",direction:"column",boxes:[{height:"20px",width:"300px"},{height:"80px",width:"300px"}]})}):e.jsx(e.Fragment,{children:!(null==S?void 0:S.title)&&T&&p in T?e.jsxs(e.Fragment,{children:[e.jsx(g,{hideHeading:null!=b&&b}),e.jsx(v,{reason:R||"",showAiResponseReason:null!=O&&O}),e.jsxs("div",Object.assign({className:"source_info_details "+(T[p]>0?"":"no_data_source")},{children:[T[p]>0&&N?e.jsxs(e.Fragment,{children:[e.jsx(u,{children:U}),e.jsx(u,Object.assign({color:d.content.secondary},{children:"Improve responses by adding more data sources for the identified intent"}))]}):N&&e.jsxs("div",Object.assign({className:"no_data_source_title"},{children:[e.jsx(o,{width:15,height:15,color:d.content.negative,style:{marginTop:2}}),e.jsx(u,{children:"No data sources added to the identified link"})]})),!y||y.hideAddDataButton||_?e.jsx(e.Fragment,{}):e.jsx(l,{size:"small",buttonType:"tertiary",LeadingIcon:n,buttonText:(null==D?void 0:D.buttonTitle.length)>0?null==D?void 0:D.buttonTitle:"Add relevant data",matchParentWidth:!0,onClick:()=>M(),style:{backgroundColor:"unset"}})]}))]}):e.jsxs(e.Fragment,{children:[e.jsx(g,{hideHeading:null!=b&&b}),e.jsx(v,{reason:R||"",showAiResponseReason:null!=O&&O}),e.jsxs("div",Object.assign({className:"source_info_details"},{children:[N&&e.jsxs(e.Fragment,{children:[e.jsx(u,{children:null==S?void 0:S.title}),e.jsx(u,Object.assign({color:d.content.secondary},{children:null==S?void 0:S.subTitle}))]}),!y||y.hideAddDataButton||_?e.jsx(e.Fragment,{}):e.jsx(l,{size:"small",buttonType:"tertiary",LeadingIcon:n,buttonText:(null==D?void 0:D.buttonTitle.length)>0?null==D?void 0:D.buttonTitle:"Add relevant data",matchParentWidth:!0,onClick:()=>M(),style:{backgroundColor:"unset"}})]}))]})})})})),g=i((t=>t.hideHeading?null:e.jsx(u,Object.assign({color:d.content.secondary},{children:"Training insights"})))),v=i((t=>{const[o,n]=s(!1),i=t.reason&&t.reason.length>50,r=i&&!o?t.reason.substring(0,50)+"...":t.reason;return t.showAiResponseReason?e.jsxs("div",Object.assign({className:"source_info_details"},{children:[e.jsx(u,Object.assign({color:d.content.primary,className:"why_ai_gave_this_response"},{children:"Here’s why your AI gave this response"})),e.jsxs(u,Object.assign({color:d.content.secondary,className:"clamp-text"},{children:[r||"No reason provided for this response.",i&&e.jsx(u,Object.assign({color:d.content.brand,style:{cursor:"pointer",textDecoration:"underline",marginTop:"4px"},onClick:()=>n(!o)},{children:o?"Show less":"Show more"}))]}))]})):e.jsx(e.Fragment,{})}));v.displayName="WhyAiGaveThisResponse",g.displayName="TrainingInsightsHeading",m.displayName="SourceInfoFooter";export{m as default};
@@ -1 +1 @@
1
- import{j as e}from"../../node_modules/react/jsx-runtime.js";import"../../node_modules/@bikdotai/bik-models/growth/index.js";import t from"../../assets/icons/boxV2.svg.js";import i from"../../assets/icons/chevronDownOutline.svg.js";import s from"../../assets/icons/chevronUpOutline.svg.js";import o from"../../assets/icons/cross.svg.js";import n from"../../assets/icons/edit.svg.js";import r from"../../assets/icons/filePdf.svg.js";import l from"../../assets/icons/help.svg.js";import a from"../../assets/icons/info.svg.js";import c from"../../assets/icons/openai.svg.js";import d from"../../assets/icons/plus.svg.js";import p from"../../assets/icons/redirect.svg.js";import u from"../../assets/icons/text_t9.svg.js";import g from"../../assets/icons/website.svg.js";import{useState as h,useMemo as x,useEffect as m}from"react";import{COLORS as j}from"../../constants/Theme.js";import{Button as f}from"../button/Button.js";import{IconButton as v}from"../icon-button/IconButton.js";import{BikShimmer as y}from"../shimmer/ShimmerComponent/BikShimmer.js";import{SideModal as C}from"../side-modal/SideModal.js";import{Tag as I}from"../tag/Tag.js";import{Tooltip as b}from"../tooltips/Tooltip.js";import{TitleSmall as T,BodyCaption as O,BodySecondary as E}from"../TypographyStyle.js";import S from"./DataSourceInfoFooter.js";import{SourceInfoDetailsStyle as w}from"./DataSourcePanel.style.js";import{intentConfig as L}from"./IntentConfig.js";import{DescriptionModal as N}from"./Modals/DescriptionModal.js";import{CustomDataType as A}from"./model.js";import{__exports as F}from"../../_virtual/index.js";const _=_=>{var D,k;const{appType:R,storeId:B,messageSource:P,setMessageSourcePanel:U,hideCloseButton:K,isSourceInfoFetched:M,allSourceInfoDetail:W,ChecklistType:H,title:$,zeroStateButton:q,editableSources:Q,preFillTrainingSourceCount:G,redirect:Y,footerButtonOption:z,fetchTrainingSourceCount:X,fetchProductFAQCount:V,productSourceData:J,reasonForAiGeneratedResponse:Z,showAiResponseReason:ee}=_,{sources:te}=P,ie=["blog","article","page","policy"],[se,oe]=h(!1),[ne,re]=h(!1),[le,ae]=h(!1),[ce,de]=h(0),[pe,ue]=h(),[ge,he]=h(null!=G?G:{}),[xe,me]=h(!1),[je,fe]=h(!1),ve={};L.forEach((t=>{let{key:i,type:s,tagText:o}=t;H[i]&&(ve[H[i]]=e.jsx(I,{theme:"light",type:s,tagText:o,cursor:"pointer"}))}));const ye=te.filter((e=>"PRODUCTS"==e.type||"Products"==e.subTitle||e.productId)),Ce=te.filter((e=>"PRODUCTS"!=e.type&&"Products"!=e.subTitle&&!e.productId)),Ie=x((()=>{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=>{H[t]&&(e[H[t]]=H[t])})),["COLLABORATION","SUBSCRIPTION_ENQUIRY"].forEach((t=>{e[t]=t})),e}),[H]);m((()=>{var e,t,i,s;if(!(null==P?void 0:P.messageId))return;oe(!0),re(!0),ae(!1!==(null===(t=null===(e=P.sources)||void 0===e?void 0:e[0])||void 0===t?void 0:t.isTrainable)||!!(null===(s=null===(i=P.sources)||void 0===i?void 0:i[0])||void 0===s?void 0:s.insights));const o=P.sources.filter((e=>!!e.productId)).map((e=>e.productId)),n=Array.from(new Set(o)).filter((e=>!!e));V(B,n).then((e=>de(e))).then((()=>{G?(he(G),setTimeout((()=>{oe(!1),re(!1)}),100)):(setTimeout((()=>oe(!1)),100),X(B).then((e=>he(e))).then((()=>setTimeout((()=>{re(!1)}),100))))}))}),[V,X,null==P?void 0:P.messageId,P.sources,G,B]);const be=e=>!!(e&&0===e.length||(null==P?void 0:P.isUnsatisfactoryAnswer)),Te=function(e){let t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];var i;return"custom"==e?e=A.FILES:ie.includes(e)?e=A.FETCHED_LINKS:"url"==e?e=A.WEBSITE_LINKS:"text"===e?e=A.TEXTS:"faq"===e&&(e=A.FAQ),t?e:null===(i=null==e?void 0:e.toLowerCase())||void 0===i?void 0:i.replace(/_/g," ")},Oe=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")):"",Ee=i=>"products"==i||"product"==i?e.jsx(t,{height:16,width:16,color:j.content.secondary}):"files"==i?e.jsx(r,{height:16,width:16,color:j.content.secondary}):"website links"==i||"fetched links"==i?e.jsx(g,{height:16,width:16,color:j.content.secondary}):"faq"==i?e.jsx(l,{height:16,width:16,color:j.content.secondary}):"texts"==i?e.jsx(u,{height:16,width:16,color:j.content.secondary}):e.jsx(c,{height:16,width:16,color:j.content.secondary}),Se=e=>{const t=e.replace(/(<([^>]+)>)/gi,""),i=document.createElement("textarea");return i.innerHTML=t,i.value};if(se||!M)return e.jsx(w,{children:e.jsx(y,{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 we=t=>{const{title:o,count:n,isExpanded:r,onToggle:l,children:a}=t;return e.jsxs("div",{children:[e.jsxs("div",Object.assign({style:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:"8px 12px",cursor:"pointer"},onClick:l},{children:[e.jsxs("div",Object.assign({style:{display:"flex",alignItems:"center",gap:"8px"}},{children:[e.jsx(O,Object.assign({style:{fontWeight:"600"}},{children:o})),R===F.ApplicationType.MANIFEST?e.jsx("div",Object.assign({style:{backgroundColor:j.surface.subdued,color:j.content.secondary,padding:"2px 8px",borderRadius:"12px",fontSize:"12px",fontWeight:"500"}},{children:n})):e.jsx(e.Fragment,{})]})),e.jsx(e.Fragment,{children:R===F.ApplicationType.BIK?e.jsx(e.Fragment,{}):r?e.jsx(i,{width:20,height:20,color:j.content.primary}):e.jsx(s,{width:20,height:20,color:j.content.primary})})]})),r&&a]})};return e.jsxs(e.Fragment,{children:[e.jsx(w,{children:e.jsxs(e.Fragment,{children:[e.jsxs("div",Object.assign({className:"pop-up-header",style:{display:"flex",flexDirection:"column",paddingBottom:"12px"}},{children:[!!$&&e.jsx(T,{children:$}),e.jsxs("div",Object.assign({style:{display:"flex",flexDirection:"row",gap:"12px",alignItems:"center"}},{children:[e.jsx(O,Object.assign({color:j.content.secondary},{children:"Intent"})),null!==(D=ve[P.intent])&&void 0!==D?D:ve.GENERIC,!K&&e.jsx("div",Object.assign({style:{display:"flex",marginLeft:"auto",cursor:"pointer"},onClick:()=>U(void 0)},{children:e.jsx(o,{height:20,width:20,color:j.content.secondary})}))]})),be(te)?e.jsx("div",Object.assign({style:{display:"flex",margin:"auto",justifyContent:"center",alignItems:"center",height:"calc(100vh - 300px)"}},{children:(()=>{var t,i;return e.jsxs("div",Object.assign({style:{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",margin:"0px 30px",gap:"8px"}},{children:[e.jsx("div",Object.assign({style:{display:"flex",alignItems:"center",justifyContent:"center",padding:"12px",backgroundColor:`${j.background.negative.light}`,borderRadius:"100px"}},{children:e.jsx(a,{width:24,height:24,color:j.stroke.negative.vibrant})})),e.jsx("div",Object.assign({style:{justifyContent:"center",alignItems:"center",marginBottom:"-4px"}},{children:e.jsx(T,{children:"Insufficient data"})})),e.jsx(E,Object.assign({color:j.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"})),q&&e.jsx("div",Object.assign({style:{display:"flex",width:"100%"}},{children:e.jsx(f,{LeadingIcon:null!==(t=q.leadingIcon)&&void 0!==t?t:d,buttonText:null!==(i=q.title)&&void 0!==i?i:"Add FAQ",buttonType:"secondary",size:"small",matchParentWidth:!0,onClick:()=>{q.onClick()}})}))]}))})()})):e.jsx(I,{LeadingIcon:a,version:"2.0",type:"grey",theme:"light",alignIcon:"start",contentPadding:12,tagText:P.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 ${R===F.ApplicationType.BIK?"BIK":"Manifest"}.`:"Edit the original source and save again to update the response"})]})),!be(te)&&e.jsxs("div",Object.assign({className:"info-container"},{children:[e.jsx(e.Fragment,{children:ye.length>0&&e.jsx("div",Object.assign({className:"info-product-source"},{children:e.jsx(we,Object.assign({title:"Product Sources",count:ye.length,isExpanded:R!==F.ApplicationType.MANIFEST||xe,onToggle:()=>me(!xe)},{children:e.jsx("div",Object.assign({className:"source",style:{padding:"0 12px",maxWidth:"100%"}},{children:ye.map(((t,i)=>{var s,o,r,l;const a=Te(t.type||t.subTitle||"OpenAI"),c=Te(t.type||t.subTitle||"OpenAI",!0),d=Oe(a),u=null==Q?void 0:Q.includes(c),g=W[null!==(s=t.productId)&&void 0!==s?s:"Products"],h=t.title,x=t.productId&&(null==J?void 0:J[t.productId]),m=x&&x.metafield.join(", ");return e.jsxs("div",Object.assign({style:{display:"flex",flexDirection:"column",gap:"8px",padding:"16px 0px",borderBottom:i+1<(null==ye?void 0:ye.length)?`1px solid ${j.stroke.primary}`:"none"}},{children:[e.jsxs("div",Object.assign({style:{display:"flex",flexDirection:"row",gap:"12px",justifyContent:"space-between",alignItems:"center"}},{children:[e.jsxs("div",Object.assign({style:{display:"flex",flex:1,gap:"8px",flexDirection:"row",alignItems:"center",justifyContent:"flex-start"}},{children:[Ee(a),e.jsx(b,Object.assign({body:h,placement:"top"},{children:e.jsx(E,Object.assign({style:c==A.FETCHED_LINKS||c==A.WEBSITE_LINKS?{cursor:"pointer",textDecoration:"underline"}:{},color:j.content.primary,className:"clamp-title",onClick:()=>c==A.FETCHED_LINKS||c==A.WEBSITE_LINKS?Y(t):{}},{children:h}))}))]})),e.jsxs("div",Object.assign({style:{display:"flex",flexDirection:"row",justifyContent:"flex-end",alignItems:"center",gap:"4px",flex:"none"}},{children:[t.intent!==H.EMAIL_COLLECTION&&e.jsx(e.Fragment,{children:e.jsx(O,Object.assign({color:j.content.secondary},{children:d}))}),(t.link||t.docId)&&e.jsx("div",Object.assign({style:{cursor:"pointer",marginLeft:"0px"}},{children:u?e.jsx(v,{Icon:n,height:16,width:16,iconColor:j.content.secondary,onClick:()=>null==g?void 0:g.onEditClick(g.data,g.type),disabled:!g,disabledTooltip:"This source is deleted"}):e.jsx(v,{Icon:p,height:16,width:16,iconColor:j.content.secondary,disabled:"custom"===t.type&&!g,disabledTooltip:"This source is deleted",onClick:()=>Y(t)})}))]}))]})),x&&e.jsxs(O,{children:[e.jsx("span",Object.assign({className:"product-data-text1",onClick:()=>{var e;ue({title:h,description:Se(x.description),imageUrl:null!==(e=t.imageUrl)&&void 0!==e?e:"",onClose:()=>ue(void 0)})}},{children:`${null===(o=x.description)||void 0===o?void 0:o.length} characters description,`})),e.jsx("span",Object.assign({className:"product-data-text1",onClick:()=>x.onEditFaqClick(x.faqs)},{children:`${null===(r=x.faqs)||void 0===r?void 0:r.length} FAQs, `})),e.jsx("span",Object.assign({className:"product-data-text2"},{children:"and"})),e.jsx(b,Object.assign({body:m,placement:"top"},{children:e.jsx("span",Object.assign({className:"product-data-text1"},{children:`${null===(l=x.metafield)||void 0===l?void 0:l.length} metafields`}))}))]})]}),`info-${i}`)}))}))}))}))}),e.jsx(e.Fragment,{children:Ce.length>0&&e.jsx("div",Object.assign({className:"info-content-source"},{children:e.jsx(we,Object.assign({title:"Content Sources",count:Ce.length,isExpanded:R!==F.ApplicationType.MANIFEST||je,onToggle:()=>fe(!je)},{children:e.jsx("div",Object.assign({className:"source",style:{padding:"0 12px",maxWidth:"100%"}},{children:Ce.map(((t,i)=>{var s,o,r,l,a,c,d,u,g,h,x,m,f,y,C,I,T;const S=Te(t.type||t.subTitle||"OpenAI"),w=Te(t.type||t.subTitle||"OpenAI",!0),L=Oe(S),N=null==Q?void 0:Q.includes(w),F="Products"===t.subTitle?W[null!==(s=t.productId)&&void 0!==s?s:"Products"]:W[null!==(o=t.docId)&&void 0!==o?o:""],_=w.toLowerCase()===(null===(r=A.FAQ)||void 0===r?void 0:r.toLowerCase())?"faq"===(null===(l=t.title)||void 0===l?void 0:l.toLowerCase())?t.subTitle:t.title:w.toLowerCase()===(null===(a=A.FILES)||void 0===a?void 0:a.toLowerCase())||w.toLowerCase()===(null===(c=A.FETCHED_LINKS)||void 0===c?void 0:c.toLowerCase())||w.toLowerCase()===(null===(d=A.TEXTS)||void 0===d?void 0:d.toLowerCase())?t.title:w.toLowerCase()===(null===(u=A.WEBSITE_LINKS)||void 0===u?void 0:u.toLowerCase())?t.title.split("/")[t.title.split("/").length-1].replace(/[^\w\s]/gi," ").replace(/^(.)(.*)$/,((e,t,i)=>t.toUpperCase()+i)):t.intent===H.EMAIL_COLLECTION?L:t.title,D="faq"===w.toLowerCase()?null!==(x=null!==(g=null==F?void 0:F.content)&&void 0!==g?g:null===(h=null==F?void 0:F.data)||void 0===h?void 0:h.answer)&&void 0!==x?x:"":w.toLowerCase()===(null===(m=A.FETCHED_LINKS)||void 0===m?void 0:m.toLowerCase())||w.toLowerCase()===(null===(f=A.WEBSITE_LINKS)||void 0===f?void 0:f.toLowerCase())||w.toLowerCase()===(null===(y=A.TEXTS)||void 0===y?void 0:y.toLowerCase())?null!==(T=null!==(C=null==F?void 0:F.content)&&void 0!==C?C:null===(I=null==F?void 0:F.data)||void 0===I?void 0:I.fileContentText)&&void 0!==T?T:"":t.intent===H.EMAIL_COLLECTION?"Collect leads before replying to messages":"";return e.jsxs("div",Object.assign({style:{display:"flex",flexDirection:"column",gap:"8px",padding:"16px 0px",borderBottom:i+1<(null==Ce?void 0:Ce.length)?`1px solid ${j.stroke.primary}`:"none"}},{children:[e.jsxs("div",Object.assign({style:{display:"flex",flexDirection:"row",gap:"12px",justifyContent:"space-between",alignItems:"center"}},{children:[e.jsxs("div",Object.assign({style:{display:"flex",flex:1,gap:"8px",flexDirection:"row",alignItems:"center",justifyContent:"flex-start"}},{children:[Ee(S),e.jsx(b,Object.assign({body:_,placement:"top"},{children:e.jsx(E,Object.assign({style:w==A.FETCHED_LINKS||w==A.WEBSITE_LINKS?{cursor:"pointer",textDecoration:"underline"}:{},color:j.content.primary,className:"clamp-title",onClick:()=>w==A.FETCHED_LINKS||w==A.WEBSITE_LINKS?Y(t):{}},{children:_}))}))]})),e.jsxs("div",Object.assign({style:{display:"flex",flexDirection:"row",justifyContent:"flex-end",alignItems:"center",gap:"4px",flex:"none"}},{children:[t.intent!==H.EMAIL_COLLECTION&&e.jsx(e.Fragment,{children:e.jsx(O,Object.assign({color:j.content.secondary},{children:L}))}),(t.link||t.docId)&&e.jsx("div",Object.assign({style:{cursor:"pointer",marginLeft:"0px"}},{children:N?e.jsx(v,{Icon:n,height:16,width:16,iconColor:j.content.secondary,onClick:()=>null==F?void 0:F.onEditClick(F.data,F.type),disabled:!F,disabledTooltip:"This source is deleted"}):e.jsx(v,{Icon:p,height:16,width:16,iconColor:j.content.secondary,disabled:"custom"===t.type&&!F,disabledTooltip:"This source is deleted",onClick:()=>Y(t)})}))]}))]})),(null!=D?D:"").trim()&&e.jsx("div",Object.assign({style:{padding:"4px 8px",border:`1px dashed ${j.stroke.primary}`,borderRadius:"4px",backgroundColor:j.surface.subdued}},{children:e.jsx(O,Object.assign({color:j.content.primary,className:"clamp-description"},{children:Se(null!=D?D:"").trim()}))}))]}),`info-${i}`)}))}))}))}))})]})),le&&!be(te)&&e.jsx("div",Object.assign({className:"footer"},{children:e.jsx(S,{appType:R,storeId:B,messageSource:P,sourceIntent:null!==(k=P.intent)&&void 0!==k?k:H.GENERIC,faqCount:ce,trainingSourceCount:ge,ShowTrainingDataSource:Ie,ChecklistType:H,footerButtonOption:z,isFooterLoading:ne,reasonForAiGeneratedResponse:Z,showAiResponseReason:ee})}))]})}),pe&&e.jsx(C,Object.assign({header:"Product description",onClose:()=>ue(void 0),width:"30%"},{children:e.jsx(N,{title:pe.title,description:pe.description,imageUrl:pe.imageUrl,onClose:pe.onClose})}))]})};export{_ as DataSourcePanel};
1
+ import{j as e}from"../../node_modules/react/jsx-runtime.js";import{ApplicationType as t}from"@bikdotai/bik-models/growth";import s from"../../assets/icons/boxV2.svg.js";import i from"../../assets/icons/chevronDownOutline.svg.js";import o from"../../assets/icons/chevronUpOutline.svg.js";import n from"../../assets/icons/cross.svg.js";import r from"../../assets/icons/edit.svg.js";import l from"../../assets/icons/filePdf.svg.js";import c from"../../assets/icons/help.svg.js";import a from"../../assets/icons/info.svg.js";import d from"../../assets/icons/openai.svg.js";import p from"../../assets/icons/plus.svg.js";import u from"../../assets/icons/redirect.svg.js";import g from"../../assets/icons/text_t9.svg.js";import h from"../../assets/icons/website.svg.js";import{useState as x,useMemo as m,useEffect as j}from"react";import{COLORS as f}from"../../constants/Theme.js";import{Button as v}from"../button/Button.js";import{IconButton as y}from"../icon-button/IconButton.js";import{BikShimmer as C}from"../shimmer/ShimmerComponent/BikShimmer.js";import{SideModal as I}from"../side-modal/SideModal.js";import{Tag as b}from"../tag/Tag.js";import{Tooltip as O}from"../tooltips/Tooltip.js";import{TitleSmall as T,BodyCaption as E,BodySecondary as S}from"../TypographyStyle.js";import w from"./DataSourceInfoFooter.js";import{SourceInfoDetailsStyle as L}from"./DataSourcePanel.style.js";import{intentConfig as N}from"./IntentConfig.js";import{DescriptionModal as F}from"./Modals/DescriptionModal.js";import{CustomDataType as A}from"./model.js";const _=_=>{var D,k;const{appType:R,storeId:B,messageSource:P,setMessageSourcePanel:U,hideCloseButton:K,isSourceInfoFetched:M,allSourceInfoDetail:W,ChecklistType:H,title:$,zeroStateButton:q,editableSources:Q,preFillTrainingSourceCount:G,redirect:Y,footerButtonOption:z,fetchTrainingSourceCount:X,fetchProductFAQCount:V,productSourceData:J,reasonForAiGeneratedResponse:Z,showAiResponseReason:ee}=_,{sources:te}=P,se=["blog","article","page","policy"],[ie,oe]=x(!1),[ne,re]=x(!1),[le,ce]=x(!1),[ae,de]=x(0),[pe,ue]=x(),[ge,he]=x(null!=G?G:{}),[xe,me]=x(!1),[je,fe]=x(!1),ve={};N.forEach((t=>{let{key:s,type:i,tagText:o}=t;H[s]&&(ve[H[s]]=e.jsx(b,{theme:"light",type:i,tagText:o,cursor:"pointer"}))}));const ye=te.filter((e=>"PRODUCTS"==e.type||"Products"==e.subTitle||e.productId)),Ce=te.filter((e=>"PRODUCTS"!=e.type&&"Products"!=e.subTitle&&!e.productId)),Ie=m((()=>{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=>{H[t]&&(e[H[t]]=H[t])})),["COLLABORATION","SUBSCRIPTION_ENQUIRY"].forEach((t=>{e[t]=t})),e}),[H]);j((()=>{var e,t,s,i;if(!(null==P?void 0:P.messageId))return;oe(!0),re(!0),ce(!1!==(null===(t=null===(e=P.sources)||void 0===e?void 0:e[0])||void 0===t?void 0:t.isTrainable)||!!(null===(i=null===(s=P.sources)||void 0===s?void 0:s[0])||void 0===i?void 0:i.insights));const o=P.sources.filter((e=>!!e.productId)).map((e=>e.productId)),n=Array.from(new Set(o)).filter((e=>!!e));V(B,n).then((e=>de(e))).then((()=>{G?(he(G),setTimeout((()=>{oe(!1),re(!1)}),100)):(setTimeout((()=>oe(!1)),100),X(B).then((e=>he(e))).then((()=>setTimeout((()=>{re(!1)}),100))))}))}),[V,X,null==P?void 0:P.messageId,P.sources,G,B]);const be=e=>!!(e&&0===e.length||(null==P?void 0:P.isUnsatisfactoryAnswer)),Oe=function(e){let t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];var s;return"custom"==e?e=A.FILES:se.includes(e)?e=A.FETCHED_LINKS:"url"==e?e=A.WEBSITE_LINKS:"text"===e?e=A.TEXTS:"faq"===e&&(e=A.FAQ),t?e:null===(s=null==e?void 0:e.toLowerCase())||void 0===s?void 0:s.replace(/_/g," ")},Te=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")):"",Ee=t=>"products"==t||"product"==t?e.jsx(s,{height:16,width:16,color:f.content.secondary}):"files"==t?e.jsx(l,{height:16,width:16,color:f.content.secondary}):"website links"==t||"fetched links"==t?e.jsx(h,{height:16,width:16,color:f.content.secondary}):"faq"==t?e.jsx(c,{height:16,width:16,color:f.content.secondary}):"texts"==t?e.jsx(g,{height:16,width:16,color:f.content.secondary}):e.jsx(d,{height:16,width:16,color:f.content.secondary}),Se=e=>{const t=e.replace(/(<([^>]+)>)/gi,""),s=document.createElement("textarea");return s.innerHTML=t,s.value};if(ie||!M)return e.jsx(L,{children:e.jsx(C,{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 we=s=>{const{title:n,count:r,isExpanded:l,onToggle:c,children:a}=s;return e.jsxs("div",{children:[e.jsxs("div",Object.assign({style:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:"8px 12px",cursor:"pointer"},onClick:c},{children:[e.jsxs("div",Object.assign({style:{display:"flex",alignItems:"center",gap:"8px"}},{children:[e.jsx(E,Object.assign({style:{fontWeight:"600"}},{children:n})),R===t.MANIFEST?e.jsx("div",Object.assign({style:{backgroundColor:f.surface.subdued,color:f.content.secondary,padding:"2px 8px",borderRadius:"12px",fontSize:"12px",fontWeight:"500"}},{children:r})):e.jsx(e.Fragment,{})]})),e.jsx(e.Fragment,{children:R===t.BIK?e.jsx(e.Fragment,{}):l?e.jsx(i,{width:20,height:20,color:f.content.primary}):e.jsx(o,{width:20,height:20,color:f.content.primary})})]})),l&&a]})};return e.jsxs(e.Fragment,{children:[e.jsx(L,{children:e.jsxs(e.Fragment,{children:[e.jsxs("div",Object.assign({className:"pop-up-header",style:{display:"flex",flexDirection:"column",paddingBottom:"12px"}},{children:[!!$&&e.jsx(T,{children:$}),e.jsxs("div",Object.assign({style:{display:"flex",flexDirection:"row",gap:"12px",alignItems:"center"}},{children:[e.jsx(E,Object.assign({color:f.content.secondary},{children:"Intent"})),null!==(D=ve[P.intent])&&void 0!==D?D:ve.GENERIC,!K&&e.jsx("div",Object.assign({style:{display:"flex",marginLeft:"auto",cursor:"pointer"},onClick:()=>U(void 0)},{children:e.jsx(n,{height:20,width:20,color:f.content.secondary})}))]})),be(te)?e.jsx("div",Object.assign({style:{display:"flex",margin:"auto",justifyContent:"center",alignItems:"center",height:"calc(100vh - 300px)"}},{children:(()=>{var t,s;return e.jsxs("div",Object.assign({style:{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",margin:"0px 30px",gap:"8px"}},{children:[e.jsx("div",Object.assign({style:{display:"flex",alignItems:"center",justifyContent:"center",padding:"12px",backgroundColor:`${f.background.negative.light}`,borderRadius:"100px"}},{children:e.jsx(a,{width:24,height:24,color:f.stroke.negative.vibrant})})),e.jsx("div",Object.assign({style:{justifyContent:"center",alignItems:"center",marginBottom:"-4px"}},{children:e.jsx(T,{children:"Insufficient data"})})),e.jsx(S,Object.assign({color:f.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"})),q&&e.jsx("div",Object.assign({style:{display:"flex",width:"100%"}},{children:e.jsx(v,{LeadingIcon:null!==(t=q.leadingIcon)&&void 0!==t?t:p,buttonText:null!==(s=q.title)&&void 0!==s?s:"Add FAQ",buttonType:"secondary",size:"small",matchParentWidth:!0,onClick:()=>{q.onClick()}})}))]}))})()})):e.jsx(b,{LeadingIcon:a,version:"2.0",type:"grey",theme:"light",alignIcon:"start",contentPadding:12,tagText:P.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 ${R===t.BIK?"BIK":"Manifest"}.`:"Edit the original source and save again to update the response"})]})),!be(te)&&e.jsxs("div",Object.assign({className:"info-container"},{children:[e.jsx(e.Fragment,{children:ye.length>0&&e.jsx("div",Object.assign({className:"info-product-source"},{children:e.jsx(we,Object.assign({title:"Product Sources",count:ye.length,isExpanded:R!==t.MANIFEST||xe,onToggle:()=>me(!xe)},{children:e.jsx("div",Object.assign({className:"source",style:{padding:"0 12px",maxWidth:"100%"}},{children:ye.map(((t,s)=>{var i,o,n,l;const c=Oe(t.type||t.subTitle||"OpenAI"),a=Oe(t.type||t.subTitle||"OpenAI",!0),d=Te(c),p=null==Q?void 0:Q.includes(a),g=W[null!==(i=t.productId)&&void 0!==i?i:"Products"],h=t.title,x=t.productId&&(null==J?void 0:J[t.productId]),m=x&&x.metafield.join(", ");return e.jsxs("div",Object.assign({style:{display:"flex",flexDirection:"column",gap:"8px",padding:"16px 0px",borderBottom:s+1<(null==ye?void 0:ye.length)?`1px solid ${f.stroke.primary}`:"none"}},{children:[e.jsxs("div",Object.assign({style:{display:"flex",flexDirection:"row",gap:"12px",justifyContent:"space-between",alignItems:"center"}},{children:[e.jsxs("div",Object.assign({style:{display:"flex",flex:1,gap:"8px",flexDirection:"row",alignItems:"center",justifyContent:"flex-start"}},{children:[Ee(c),e.jsx(O,Object.assign({body:h,placement:"top"},{children:e.jsx(S,Object.assign({style:a==A.FETCHED_LINKS||a==A.WEBSITE_LINKS?{cursor:"pointer",textDecoration:"underline"}:{},color:f.content.primary,className:"clamp-title",onClick:()=>a==A.FETCHED_LINKS||a==A.WEBSITE_LINKS?Y(t):{}},{children:h}))}))]})),e.jsxs("div",Object.assign({style:{display:"flex",flexDirection:"row",justifyContent:"flex-end",alignItems:"center",gap:"4px",flex:"none"}},{children:[t.intent!==H.EMAIL_COLLECTION&&e.jsx(e.Fragment,{children:e.jsx(E,Object.assign({color:f.content.secondary},{children:d}))}),(t.link||t.docId)&&e.jsx("div",Object.assign({style:{cursor:"pointer",marginLeft:"0px"}},{children:p?e.jsx(y,{Icon:r,height:16,width:16,iconColor:f.content.secondary,onClick:()=>null==g?void 0:g.onEditClick(g.data,g.type),disabled:!g,disabledTooltip:"This source is deleted"}):e.jsx(y,{Icon:u,height:16,width:16,iconColor:f.content.secondary,disabled:"custom"===t.type&&!g,disabledTooltip:"This source is deleted",onClick:()=>Y(t)})}))]}))]})),x&&e.jsxs(E,{children:[e.jsx("span",Object.assign({className:"product-data-text1",onClick:()=>{var e;ue({title:h,description:Se(x.description),imageUrl:null!==(e=t.imageUrl)&&void 0!==e?e:"",onClose:()=>ue(void 0)})}},{children:`${null===(o=x.description)||void 0===o?void 0:o.length} characters description,`})),e.jsx("span",Object.assign({className:"product-data-text1",onClick:()=>x.onEditFaqClick(x.faqs)},{children:`${null===(n=x.faqs)||void 0===n?void 0:n.length} FAQs, `})),e.jsx("span",Object.assign({className:"product-data-text2"},{children:"and"})),e.jsx(O,Object.assign({body:m,placement:"top"},{children:e.jsx("span",Object.assign({className:"product-data-text1"},{children:`${null===(l=x.metafield)||void 0===l?void 0:l.length} metafields`}))}))]})]}),`info-${s}`)}))}))}))}))}),e.jsx(e.Fragment,{children:Ce.length>0&&e.jsx("div",Object.assign({className:"info-content-source"},{children:e.jsx(we,Object.assign({title:"Content Sources",count:Ce.length,isExpanded:R!==t.MANIFEST||je,onToggle:()=>fe(!je)},{children:e.jsx("div",Object.assign({className:"source",style:{padding:"0 12px",maxWidth:"100%"}},{children:Ce.map(((t,s)=>{var i,o,n,l,c,a,d,p,g,h,x,m,j,v,C,I,b;const T=Oe(t.type||t.subTitle||"OpenAI"),w=Oe(t.type||t.subTitle||"OpenAI",!0),L=Te(T),N=null==Q?void 0:Q.includes(w),F="Products"===t.subTitle?W[null!==(i=t.productId)&&void 0!==i?i:"Products"]:W[null!==(o=t.docId)&&void 0!==o?o:""],_=w.toLowerCase()===(null===(n=A.FAQ)||void 0===n?void 0:n.toLowerCase())?"faq"===(null===(l=t.title)||void 0===l?void 0:l.toLowerCase())?t.subTitle:t.title:w.toLowerCase()===(null===(c=A.FILES)||void 0===c?void 0:c.toLowerCase())||w.toLowerCase()===(null===(a=A.FETCHED_LINKS)||void 0===a?void 0:a.toLowerCase())||w.toLowerCase()===(null===(d=A.TEXTS)||void 0===d?void 0:d.toLowerCase())?t.title:w.toLowerCase()===(null===(p=A.WEBSITE_LINKS)||void 0===p?void 0:p.toLowerCase())?t.title.split("/")[t.title.split("/").length-1].replace(/[^\w\s]/gi," ").replace(/^(.)(.*)$/,((e,t,s)=>t.toUpperCase()+s)):t.intent===H.EMAIL_COLLECTION?L:t.title,D="faq"===w.toLowerCase()?null!==(x=null!==(g=null==F?void 0:F.content)&&void 0!==g?g:null===(h=null==F?void 0:F.data)||void 0===h?void 0:h.answer)&&void 0!==x?x:"":w.toLowerCase()===(null===(m=A.FETCHED_LINKS)||void 0===m?void 0:m.toLowerCase())||w.toLowerCase()===(null===(j=A.WEBSITE_LINKS)||void 0===j?void 0:j.toLowerCase())||w.toLowerCase()===(null===(v=A.TEXTS)||void 0===v?void 0:v.toLowerCase())?null!==(b=null!==(C=null==F?void 0:F.content)&&void 0!==C?C:null===(I=null==F?void 0:F.data)||void 0===I?void 0:I.fileContentText)&&void 0!==b?b:"":t.intent===H.EMAIL_COLLECTION?"Collect leads before replying to messages":"";return e.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 ${f.stroke.primary}`:"none"}},{children:[e.jsxs("div",Object.assign({style:{display:"flex",flexDirection:"row",gap:"12px",justifyContent:"space-between",alignItems:"center"}},{children:[e.jsxs("div",Object.assign({style:{display:"flex",flex:1,gap:"8px",flexDirection:"row",alignItems:"center",justifyContent:"flex-start"}},{children:[Ee(T),e.jsx(O,Object.assign({body:_,placement:"top"},{children:e.jsx(S,Object.assign({style:w==A.FETCHED_LINKS||w==A.WEBSITE_LINKS?{cursor:"pointer",textDecoration:"underline"}:{},color:f.content.primary,className:"clamp-title",onClick:()=>w==A.FETCHED_LINKS||w==A.WEBSITE_LINKS?Y(t):{}},{children:_}))}))]})),e.jsxs("div",Object.assign({style:{display:"flex",flexDirection:"row",justifyContent:"flex-end",alignItems:"center",gap:"4px",flex:"none"}},{children:[t.intent!==H.EMAIL_COLLECTION&&e.jsx(e.Fragment,{children:e.jsx(E,Object.assign({color:f.content.secondary},{children:L}))}),(t.link||t.docId)&&e.jsx("div",Object.assign({style:{cursor:"pointer",marginLeft:"0px"}},{children:N?e.jsx(y,{Icon:r,height:16,width:16,iconColor:f.content.secondary,onClick:()=>null==F?void 0:F.onEditClick(F.data,F.type),disabled:!F,disabledTooltip:"This source is deleted"}):e.jsx(y,{Icon:u,height:16,width:16,iconColor:f.content.secondary,disabled:"custom"===t.type&&!F,disabledTooltip:"This source is deleted",onClick:()=>Y(t)})}))]}))]})),(null!=D?D:"").trim()&&e.jsx("div",Object.assign({style:{padding:"4px 8px",border:`1px dashed ${f.stroke.primary}`,borderRadius:"4px",backgroundColor:f.surface.subdued}},{children:e.jsx(E,Object.assign({color:f.content.primary,className:"clamp-description"},{children:Se(null!=D?D:"").trim()}))}))]}),`info-${s}`)}))}))}))}))})]})),le&&!be(te)&&e.jsx("div",Object.assign({className:"footer"},{children:e.jsx(w,{appType:R,storeId:B,messageSource:P,sourceIntent:null!==(k=P.intent)&&void 0!==k?k:H.GENERIC,faqCount:ae,trainingSourceCount:ge,ShowTrainingDataSource:Ie,ChecklistType:H,footerButtonOption:z,isFooterLoading:ne,reasonForAiGeneratedResponse:Z,showAiResponseReason:ee})}))]})}),pe&&e.jsx(I,Object.assign({header:"Product description",onClose:()=>ue(void 0),width:"30%"},{children:e.jsx(F,{title:pe.title,description:pe.description,imageUrl:pe.imageUrl,onClose:pe.onClose})}))]})};export{_ as DataSourcePanel};
@@ -1 +1 @@
1
- import{j as e}from"../../node_modules/react/jsx-runtime.js";import"../../node_modules/@bikdotai/bik-models/growth/index.js";import{useState as i,useEffect as t}from"react";import{DISCOUNT_TYPES as o,MIN_PURCHASE_REQUIREMENT as n,DISCOUNT_APPLIES_TO as l,OFFER_APPLIES_TO as r,initialStaticCouponErrorState as d,initialDynamicCouponErrorState as a,COUPON_EXPIRATION as s,DISCOUNT_TARGET_TYPES as c,DISCOUNT_TARGET_SELECTION as u,DISCOUNT_VALUE_TYPES as p}from"./type.js";import"../dropdown/DropdownPopover/index.js";import{Dropdown as v}from"../dropdown/Dropdown.js";import"../dropdown/ChipDropdown.js";import"../zeroState/ZeroState.js";import{TitleSmall as C,BodyCaption as m,TitleRegular as b}from"../TypographyStyle.js";import{DEFAULT_THEME as y}from"../../constants/Theme.js";import"../dropdown/OpenedDropdown/components/description/Description.styled.js";import"../checkBox/CheckBox.styled.js";import"../list-item/ListItem.js";import"../dropdown/OpenedDropdown/components/menu/FreeFormMenu.styled.js";import"../dropdown/OpenedDropdown/components/menu/MenuItem.js";import"../dropdown/OpenedDropdown/components/menu/MenuList.styled.js";import"../button/Button.js";import"../dropdown/OpenedDropdown/components/multiSelect/MultiSelectDropdownBottomBar.styled.js";import"../dropdown/OpenedDropdown/components/OpennedDropdown.styled.js";import"../icon-button/IconButton.js";import"../input/Input.js";import"../dropdown/MenuItem/MenuItem.js";import{StyledModal as P}from"../modals/styledModal.js";import{ProductPickerContent as h}from"../product-picker/ProductPickerModal.js";import{Tag as I}from"../tag/Tag.js";import{Tooltip as f}from"../tooltips/Tooltip.js";import T from"../../assets/icons/gift_icon.svg.js";import E from"../../assets/icons/percentage_icon.svg.js";import O from"../../assets/icons/shipping_icon.svg.js";import S from"../../assets/icons/triangle_error.svg.js";import g from"../../assets/icons/warning.svg.js";import{ProductPickerModal as j}from"../product-picker-v2/modal.js";import"../product-picker-v2/type.js";import{PickerType as x}from"../variable-picker-v3/model.js";import{VariablePicker as _}from"../variable-picker-v3/VariablePicker.js";import{StyledDiscountDialogueContainer as V,CouponTypeContainerStyled as A,VariablePickerContainer as D}from"./DiscountModal.styled.js";import{validateDiscountData as k,descriptionBuilder as N}from"./DiscountUtils.js";import F,{DISCOUNT_PRODUCTS as w}from"./DynamicCoupon/DynamicCoupon.js";import R from"./StaticCoupon/StaticCoupon.js";import{__exports as M}from"../../_virtual/index.js";const q=q=>{var L,U,B,G,Y,X,Q,H,z,K,$;const Z=[{id:"0",label:"Amount",value:"amount",icon:i=>e.jsx("span",Object.assign({style:{fontSize:20,color:i,lineHeight:.9}},{children:q.currency||""}))},{id:"1",label:"Percentage",value:"percentage",icon:i=>e.jsx(E,{width:24,height:24,color:i})},{id:"2",label:"Buy X get Y",value:o.BUY_X_GET_Y,icon:i=>e.jsx(T,{width:24,height:24,color:i})},{id:"3",label:"Free Shipping",value:o.FREE_SHIPPING,icon:i=>e.jsx(O,{width:24,height:24,color:i})}],[J,W]=i(),[ee,ie]=i(),[te,oe]=i(),[ne,le]=i(null!==(L=q.data)&&void 0!==L?L:"string"==typeof q.hideOption?{isStaticCoupon:"dynamic"===q.hideOption}:{isStaticCoupon:!0}),[re,de]=i(!0),[ae,se]=i(),[ce,ue]=i((null===(U=q.data)||void 0===U?void 0:U.minAmount)?n.AMOUNT:(null===(B=q.data)||void 0===B?void 0:B.minQuantity)?n.QUANTITY:n.NA),[pe,ve]=i(l.ENTIRE_ORDER),[Ce,me]=i(r.SPECIFIC_PRODUCTS),[be,ye]=i(r.SPECIFIC_PRODUCTS),[Pe,he]=i(void 0),[Ie,fe]=i(void 0),[Te,Ee]=i(void 0),[Oe,Se]=i(void 0),[ge,je]=i(void 0),[xe,_e]=i(void 0),[Ve,Ae]=i(0),[De,ke]=i(""),[Ne,Fe]=i(Z[0]),[we,Re]=i(!1),[Me,qe]=i(d),[Le,Ue]=i(a),[Be,Ge]=i(s.DYNAMIC_EXPIRATION),Ye=[{value:o.AMOUNT_OFF_ORDER,label:"Amount off on order",selected:ae===o.AMOUNT_OFF_ORDER},{value:o.AMOUNT_OFF_PRODUCTS,label:"Amount off on products",selected:ae===o.AMOUNT_OFF_PRODUCTS},{value:o.BUY_X_GET_Y,label:"Buy X Get Y FREE",selected:ae===o.BUY_X_GET_Y},{value:o.FREE_SHIPPING,label:"Free shipping",selected:ae===o.FREE_SHIPPING}];t((()=>{q.makeExpiryMandatory&&Re(!0)}),[q.makeExpiryMandatory]),t((()=>{var e,i,t,n,d,a,c,u;let v;const{tempCouponData:C,discountType:m}=Xe();se(m);const b=(e,i)=>{Fe(C.valueType===p.FIXED_AMOUNT?Z[e]:Z[i])},y=(e,i)=>{Object.keys(e||{}).length&&i(e)};switch(((null==C?void 0:C.expireAfter)||(null==C?void 0:C.expireAt))&&(Re(!0),(null==C?void 0:C.expireAt)&&Ge(s.FIXED_EXPIRATION),(null==C?void 0:C.expireAfter)&&Ge(s.DYNAMIC_EXPIRATION)),m){case o.AMOUNT_OFF_ORDER:b(0,1),ve(l.ENTIRE_ORDER);break;case o.AMOUNT_OFF_PRODUCTS:b(0,1),(null===(e=C.entitledCollectionIds)||void 0===e?void 0:e.length)?ve(l.SPECIFIC_COLLECTIONS):(null===(i=C.entitledProductIds)||void 0===i?void 0:i.length)||(null===(t=C.productVariableConf)||void 0===t?void 0:t.entitledProductVariable)?(ve(l.SPECIFIC_PRODUCTS),y(null===(n=C.productVariableConf)||void 0===n?void 0:n.entitledProductVariable,Se)):ve(l.ENTIRE_ORDER);break;case o.BUY_X_GET_Y:Fe(Z[2]),(null===(d=C.entitledCollectionIds)||void 0===d?void 0:d.length)?ye(r.SPECIFIC_COLLECTIONS):(ye(r.SPECIFIC_PRODUCTS),y(null===(a=C.productVariableConf)||void 0===a?void 0:a.entitledProductVariable,Se)),(null===(c=C.prerequisiteCollectionIds)||void 0===c?void 0:c.length)?me(r.SPECIFIC_COLLECTIONS):(me(r.SPECIFIC_PRODUCTS),y(null===(u=C.productVariableConf)||void 0===u?void 0:u.prerequisiteProductVariable,je));break;case o.FREE_SHIPPING:Fe(Z[3])}le(Object.assign({},C)),q.hideProbability||(v=ze()),de(k(C,ce,m,q.hideProbability||!1,v,!!C.isStaticCoupon)),q.hideProbability||ze()}),[]),t((()=>{let e;q.hideProbability||(e=ze()),de(k(ne,ce,ae,q.hideProbability||!1,e,!!ne.isStaticCoupon))}),[ne,Ve,ae,ce]),t((()=>{var e,i,t,o,n,l,r;if(!q.newPickerConf&&((null===(e=q.products)||void 0===e?void 0:e.length)||(null===(i=q.collection)||void 0===i?void 0:i.length))){if(q.products&&(null===(t=q.products)||void 0===t?void 0:t.length)){if(null===(o=q.data)||void 0===o?void 0:o.entitledProductIds){const e=q.products.filter((e=>{var i,t;return null===(t=null===(i=q.data)||void 0===i?void 0:i.entitledProductIds)||void 0===t?void 0:t.includes(parseInt(e.id))}));fe(e)}if(null===(n=q.data)||void 0===n?void 0:n.prerequisiteProductIds){const e=q.products.filter((e=>{var i,t;return null===(t=null===(i=q.data)||void 0===i?void 0:i.prerequisiteProductIds)||void 0===t?void 0:t.includes(parseInt(e.id))}));he(e)}}if(q.collection&&q.collection.length){if(null===(l=q.data)||void 0===l?void 0:l.entitledCollectionIds){const e=q.collection.filter((e=>{var i,t;return null===(t=null===(i=q.data)||void 0===i?void 0:i.entitledCollectionIds)||void 0===t?void 0:t.includes(parseInt(e.id))}));_e(e)}if(null===(r=q.data)||void 0===r?void 0:r.prerequisiteCollectionIds){const e=q.collection.filter((e=>{var i,t;return null===(t=null===(i=q.data)||void 0===i?void 0:i.prerequisiteCollectionIds)||void 0===t?void 0:t.includes(parseInt(e.id))}));Ee(e)}}}}),[q.products,q.collection]),t((()=>{var e,i,t,o,n,l,r,d;(null===(i=null===(e=q.data)||void 0===e?void 0:e.productsConf)||void 0===i?void 0:i.entitledProducts)&&fe(q.data.productsConf.entitledProducts),(null===(o=null===(t=q.data)||void 0===t?void 0:t.productsConf)||void 0===o?void 0:o.prerequisiteProducts)&&he(q.data.productsConf.prerequisiteProducts),(null===(l=null===(n=q.data)||void 0===n?void 0:n.collectionsConf)||void 0===l?void 0:l.entitledCollections)&&_e(q.data.collectionsConf.entitledCollections),(null===(d=null===(r=q.data)||void 0===r?void 0:r.collectionsConf)||void 0===d?void 0:d.prerequisiteCollections)&&Ee(q.data.collectionsConf.prerequisiteCollections)}),[null===(G=q.data)||void 0===G?void 0:G.productsConf,null===(Y=q.data)||void 0===Y?void 0:Y.collectionsConf]),t((()=>{if(!Ie)return;if(q.newPickerConf){const e=[];return Object.values(Ie).forEach((i=>{i.products&&Object.keys(i.products).forEach((i=>{e.push(parseInt(i))}))})),void le(Object.assign(Object.assign({},ne),{entitledProductIds:e}))}const e=Ie.map((e=>parseInt(e.id)));le(Object.assign(Object.assign({},ne),{entitledProductIds:e}))}),[Ie]),t((()=>{if(!Pe)return;if(q.newPickerConf){const e=[];return Object.values(Pe).forEach((i=>{i.products&&Object.keys(i.products).forEach((i=>{e.push(parseInt(i))}))})),void le(Object.assign(Object.assign({},ne),{prerequisiteProductIds:e}))}const e=Pe.map((e=>parseInt(e.id)));le(Object.assign(Object.assign({},ne),{prerequisiteProductIds:e}))}),[Pe]),t((()=>{if(!xe)return;if(q.newPickerConf){(null==xe?void 0:xe.isCustom)&&delete xe.isCustom;const e=Object.keys(xe).map((e=>parseInt(e)));return void le(Object.assign(Object.assign({},ne),{entitledCollectionIds:e}))}const e=xe.map((e=>parseInt(e.id)));le(Object.assign(Object.assign({},ne),{entitledCollectionIds:e}))}),[xe]),t((()=>{if(!Te)return;if(q.newPickerConf){(null==Te?void 0:Te.isCustom)&&delete Te.isCustom;const e=Object.keys(Te).map((e=>parseInt(e)));return void le(Object.assign(Object.assign({},ne),{prerequisiteCollectionIds:e}))}const e=Te.map((e=>parseInt(e.id)));le(Object.assign(Object.assign({},ne),{prerequisiteCollectionIds:e}))}),[Te]);const Xe=()=>{var e,i;let t,n=ne;return ne.isStaticCoupon||(ne.targetType===c.SHIPPING_LINE?t=o.FREE_SHIPPING:ne.targetType===c.LINE_ITEM?t=ne.targetSelection===u.ENTITLED?(null===(e=ne.prerequisiteProductIds)||void 0===e?void 0:e.length)||(null===(i=ne.prerequisiteCollectionIds)||void 0===i?void 0:i.length)||ne.prerequisiteQuantity||ne.entitledQuantity?o.BUY_X_GET_Y:o.AMOUNT_OFF_PRODUCTS:o.AMOUNT_OFF_ORDER:(n=Object.assign(Object.assign({},n),{targetType:c.LINE_ITEM,targetSelection:u.ALL,valueType:p.FIXED_AMOUNT}),t=o.AMOUNT_OFF_ORDER)),{discountType:t,tempCouponData:n}},Qe=()=>{qe(d),Ue(a)},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=ne.probability)&&void 0!==i?i:-1)>1?"Probability should not exceed 1":ne.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&&(ke(n>1?"Please add discount details":o),!0)},ze=()=>{if(!q.quadrant||!q.probability)return;const e=[...q.probability];let i=[];e.length>=q.quadrant&&e.splice(q.quadrant-1,1),i=e;const t=i.reduce(((e,i)=>e+i),0)+(ne.probability||0);return Ae(parseFloat(t.toFixed(4))),parseFloat(t.toFixed(4))},Ke=e=>{var i,t,n,l,r,d,a,s,v,C,m,b,y,P,h,I;const f=e.value;se(f),he([]),fe([]),Ee([]),_e([]),f===o.FREE_SHIPPING?le({value:100,targetSelection:u.ALL,targetType:c.SHIPPING_LINE,valueType:p.PERCENTAGE,quadrant:ne.quadrant,isStaticCoupon:!1,title:ne.title,expireAt:null!==(i=ne.expireAt)&&void 0!==i?i:void 0,expireAfter:null!==(t=ne.expireAfter)&&void 0!==t?t:void 0,probability:ne.probability,minQuantity:null!==(n=ne.minQuantity)&&void 0!==n?n:void 0,minAmount:null!==(l=ne.minAmount)&&void 0!==l?l:void 0}):f===o.BUY_X_GET_Y?le({value:100,targetSelection:u.ENTITLED,targetType:c.LINE_ITEM,valueType:p.PERCENTAGE,quadrant:ne.quadrant,isStaticCoupon:!1,title:ne.title,expireAt:null!==(r=ne.expireAt)&&void 0!==r?r:void 0,expireAfter:null!==(d=ne.expireAfter)&&void 0!==d?d:void 0,probability:ne.probability,minQuantity:void 0,minAmount:void 0}):f===o.AMOUNT_OFF_ORDER?le({targetSelection:u.ALL,targetType:c.LINE_ITEM,valueType:null!==(a=ne.valueType)&&void 0!==a?a:p.FIXED_AMOUNT,quadrant:ne.quadrant,isStaticCoupon:!1,title:ne.title,expireAt:null!==(s=ne.expireAt)&&void 0!==s?s:void 0,expireAfter:null!==(v=ne.expireAfter)&&void 0!==v?v:void 0,probability:ne.probability,value:ne.value,minQuantity:null!==(C=ne.minQuantity)&&void 0!==C?C:void 0,minAmount:null!==(m=ne.minAmount)&&void 0!==m?m:void 0}):f===o.AMOUNT_OFF_PRODUCTS&&le({targetSelection:u.ENTITLED,targetType:c.LINE_ITEM,valueType:null!==(b=ne.valueType)&&void 0!==b?b:p.FIXED_AMOUNT,quadrant:ne.quadrant,isStaticCoupon:!1,title:ne.title,expireAt:null!==(y=ne.expireAt)&&void 0!==y?y:void 0,expireAfter:null!==(P=ne.expireAfter)&&void 0!==P?P:void 0,probability:ne.probability,value:ne.value,minQuantity:null!==(h=ne.minQuantity)&&void 0!==h?h:void 0,minAmount:null!==(I=ne.minAmount)&&void 0!==I?I:void 0})},$e=i=>i&&e.jsx(I,{theme:"light",tagText:i,type:"negative",LeadingIcon:g});return e.jsxs(P,Object.assign({width:(te||J)&&q.newPickerConf?"25px":"640px",open:q.isOpen,hideCrossButton:!!ee,headingTitle:J?"Select Products":q.title,headingSubtitle:J?void 0:q.subTitle,footerLeftCustomElement:De?$e(De):q.errorMsg?$e(q.errorMsg):!q.quadrant||q.hideProbability?e.jsx(e.Fragment,{}):Ve<=1?e.jsx(I,{theme:"light",tagText:`Current probability sum: ${Ve}`,type:"white"}):e.jsx(f,Object.assign({body:"Probability sum should not exceed 1",placement:"top"},{children:e.jsx("div",{children:e.jsx(I,{style:{cursor:"pointer"},theme:"light",tagText:`Current probability sum: ${Ve}`,type:"negative",LeadingIcon:S})})})),headerRightCustomElement:q.allowStaticCoupon||J?void 0:e.jsx(v,{options:Ye,width:"200px",placement:"bottom-start",size:"small",onSelect:e=>{Ke(e)}}),onClose:q.onClose,footerContainerStyle:{borderTop:`1px solid ${y.colorsV2.stroke.primary}`},primaryButton:J?{buttonType:"primary",onClick:()=>{W(void 0)},buttonText:"Add"}:te?{buttonType:"primary",onClick:()=>{oe(void 0)},buttonText:"Add"}:{buttonType:"primary",buttonText:"Create discount code",isLoading:null!==(X=q.loading)&&void 0!==X&&X,onClick:()=>{var e,i,t,d,a;if(Qe(),ne.isStaticCoupon){const{isStaticCoupon:e,couponCode:i,title:t,description:o,quadrant:n,probability:l}=ne,r={invalidDiscountCode:!i,invalidCouponTitle:!t,invalidCouponDescription:!o,inValidProbability:!q.hideProbability&&(null!=l?l:-1)<0||(null!=l?l:0)>1||Number.isNaN(null!=l?l:0)};if(He(r))return void qe(r);if(re||Ve>1)return void ke(!q.hideProbability&&Ve>1?"Probability sum should not exceed 1":"Invalid coupon details");q.onSaveClicked({quadrant:n,couponCode:i,description:o,isStaticCoupon:e,probability:l,title:ne.title})}else{const s={invalidCouponTitle:!ne.title,inValidProbability:!q.hideProbability&&(null!==(e=ne.probability)&&void 0!==e?e:-1)<=0||(null!==(i=ne.probability)&&void 0!==i?i:-1)>1||Number.isNaN(null!==(t=ne.probability)&&void 0!==t?t:-1),inValidDiscountAmount:!ne.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(ae!==o.BUY_X_GET_Y&&ce!==n.NA){const{minAmount:e,minQuantity:i}=ne;s.inValidMinimumAmount=ce===n.AMOUNT&&!e,s.inValidMinimumQuantity=ce===n.QUANTITY&&!i}if(we&&(s.inValidCouponExpiry=!ne.expireAt&&!ne.expireAfter),ae!==o.AMOUNT_OFF_ORDER&&ae!==o.AMOUNT_OFF_PRODUCTS||(pe!==l.SPECIFIC_PRODUCTS||!Ie||Object.keys(Ie).length||Oe||(s.inValidProductSelection=!0,s.inValidProductVariableSelection=!0),pe===l.SPECIFIC_COLLECTIONS&&xe&&!Object.keys(xe).length&&(s.inValidCollectionSelection=!0)),ae===o.BUY_X_GET_Y&&(ne.prerequisiteQuantity||(s.inValidBuyXValue=!0),ne.entitledQuantity||(s.inValidGetYValue=!0),Ce!==r.SPECIFIC_PRODUCTS||!Pe||Object.keys(Pe).length||ge||(s.inValidBuyXProductSelection=!0,s.inValidBuyXProductVariableSelection=!0),Ce===r.SPECIFIC_COLLECTIONS&&Te&&!Object.keys(Te).length&&(s.inValidBuyXCollectionSelection=!0),be!==r.SPECIFIC_PRODUCTS||!Ie||Object.keys(Ie).length||Oe||(s.inValidGetYProductSelection=!0,s.inValidGetYProductVariableSelection=!0),be===r.SPECIFIC_COLLECTIONS&&xe&&!Object.keys(xe).length&&(s.inValidGetYCollectionSelection=!0)),He(s))return void Ue(s);if(re||Ve>1)return void ke(!q.hideProbability&&Ve>1?"Probability sum should not exceed 1":"Invalid coupon details");q.onSaveClicked(Object.assign(Object.assign({},ne),{description:N(ne,q.currency,null!==(d=q.products)&&void 0!==d?d:[],null!==(a=q.collection)&&void 0!==a?a:[]),productsConf:{entitledProducts:null!=Ie?Ie:[],prerequisiteProducts:null!=Pe?Pe:[]},collectionsConf:{entitledCollections:null!=xe?xe:[],prerequisiteCollections:null!=Te?Te:[]},productVariableConf:{entitledProductVariable:null!=Oe?Oe:{},prerequisiteProductVariable:null!=ge?ge:{}}}))}}},secondaryButton:J?{buttonType:"tertiaryGray",onClick:()=>{W(void 0)},buttonText:"Back"}:te?{buttonType:"tertiaryGray",onClick:()=>{oe(void 0)},buttonText:"Back"}:{buttonType:"tertiaryGray",onClick:q.onClose,buttonText:"Cancel"}},{children:[!J&&!te&&e.jsxs(V,{children:[q.allowStaticCoupon&&!J&&e.jsxs(A,Object.assign({selectedDiv:ne.isStaticCoupon?1:2},{children:["static"===q.hideOption?e.jsx(e.Fragment,{}):e.jsxs("div",Object.assign({className:"coupon-type__container",onClick:()=>{ne.isStaticCoupon||(le({isStaticCoupon:!0,quadrant:ne.quadrant}),ke(""),Qe())}},{children:[e.jsx(C,Object.assign({style:{marginBottom:"4px",color:ne.isStaticCoupon?y.colorsV2.content.brand:void 0}},{children:"Static Code"})),e.jsx(m,Object.assign({style:ne.isStaticCoupon?{color:y.colorsV2.content.brand}:{}},{children:"A uniform code provided manually, used for providing the same discount to all customers."}))]})),"dynamic"===q.hideOption?e.jsx(e.Fragment,{}):e.jsxs("div",Object.assign({className:"coupon-type__container",onClick:()=>{var i;ne.isStaticCoupon&&(se(o.AMOUNT_OFF_ORDER),le({isStaticCoupon:!1,quadrant:ne.quadrant,targetType:c.LINE_ITEM,targetSelection:u.ALL,valueType:p.FIXED_AMOUNT}),ke(""),Qe(),Fe({id:"0",label:"Amount",value:"amount",icon:i=>e.jsx("span",Object.assign({style:{fontSize:20,color:i}},{children:q.currency||""}))}),Re(null!==(i=q.makeExpiryMandatory)&&void 0!==i&&i),ue(n.NA))}},{children:[e.jsx(C,Object.assign({style:{marginBottom:"4px",color:ne.isStaticCoupon?void 0:y.colorsV2.content.brand}},{children:"Dynamic Code"})),e.jsx(m,Object.assign({style:ne.isStaticCoupon?{}:{color:y.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.jsx(b,Object.assign({style:{marginTop:"24px"}},{children:"Coupon Details"})),ne.isStaticCoupon&&!J&&e.jsx(R,{discountData:ne,setDiscountData:le,hideProbability:q.hideProbability||!1,discountAdminUrl:q.discountAdminUrl,staticDiscountValidationError:Me,currency:q.currency}),!ne.isStaticCoupon&&!J&&!te&&e.jsx(F,{currency:q.currency,entitledProducts:null!=Ie?Ie:[],prerequisiteProducts:null!=Pe?Pe:[],setEntitledProducts:fe,setPrerequisiteProducts:he,discountData:ne,productPickerOpen:J,productVariablePickerOpen:ee,setIsProductPickerOpen:W,setIsProductVariablePickerOpen:ie,setDiscountData:le,selectedCouponType:ae,setSelectedCouponType:se,selectedMinimumRequirement:ce,setSelectedMinimumRequirement:ue,discountCouponAppliesTo:pe,offerAppliesToBuy:Ce,offerAppliesToGet:be,setDiscountCouponAppliesTo:ve,setOfferAppliesToBuy:me,setOfferAppliesToGet:ye,hideProbability:q.hideProbability||!1,hideExpiration:q.hideExpiration||!1,allowStaticCoupon:q.allowStaticCoupon,onChangeCouponType:Ke,collectionPickerOpen:te,entitledCollections:null!=xe?xe:[],prerequisiteCollections:null!=Te?Te:[],setIsCollectionPickerOpen:oe,setEntitledCollections:_e,setPrerequisiteCollections:Ee,useNewPicker:!!q.newPickerConf,setSelectedDiscountDetails:Fe,selectedDiscountDetails:Ne,isProductVariableSupported:q.isProductVariableSupported,entitledProductVariable:Oe,setEntitledProductVariable:Se,preRequisiteProductVariable:ge,setPreRequisiteProductVariable:je,productVariableList:q.productVariableList,isAddExpirationChecked:we,setIsAddExpirationChecked:Re,dynamicDiscountValidationError:Le,setDynamicDiscountValidationError:Ue,setValidationErrorMessage:ke,resetValidationErrors:Qe,discountDetailsOptions:Z,selectedExpiration:Be,setSelectedExpiration:Ge,makeExpiryMandatory:!!q.makeExpiryMandatory})]}),!!J&&e.jsxs(e.Fragment,{children:[!q.newPickerConf&&e.jsx("div",Object.assign({style:{padding:"12px 0"}},{children:e.jsx(h,{show:!0,onSave:()=>{},products:null!==(Q=q.products)&&void 0!==Q?Q:[],title:"Select Products",onClose:()=>{W(void 0)},selectedProducts:null!==(H=J===w.ENTITLED?Ie:Pe)&&void 0!==H?H:[],setSelectedProducts:J===w.ENTITLED?fe:he,onSearchKeyChange:q.onProductSearch})})),q.newPickerConf&&e.jsx(j,{visible:!0,onClose:()=>W(void 0),collectionFetcher:(e,i,t)=>{var o;return(null===(o=q.newPickerConf)||void 0===o?void 0:o.fetchCollections)?q.newPickerConf.fetchCollections(e,i,!1,t):null},productFetcher:(e,i,t,o,n)=>{var l;return(null===(l=q.newPickerConf)||void 0===l?void 0:l.fetchProducts)?q.newPickerConf.fetchProducts(e,i,o,n,!1,t):null},selectedItems:J===w.ENTITLED?Ie:Pe,onAdd:e=>{J===w.ENTITLED?fe(e):he(e),W(void 0)},zIndex:200,storeId:q.newPickerConf.storeId,appType:q.newPickerConf.appType||M.ApplicationType.BIK,searchInCollectionFetcher:(e,i,t,o)=>{var n;return(null===(n=q.newPickerConf)||void 0===n?void 0:n.searchInCollection)?q.newPickerConf.searchInCollection(e,i,t,!1,o):null},customCollectionRestriction:!1,searchFetcher:(e,i,t)=>{var o;return(null===(o=q.newPickerConf)||void 0===o?void 0:o.searchProducts)?q.newPickerConf.searchProducts(e,i,!1,t):null},hideCollectionCheckbox:!0,hideVariantCheckbox:!0,selectProductsFromCustomCollection:!0,hideSelectionCount:!0})]}),!!te&&e.jsx("div",Object.assign({style:{padding:"12px 0"}},{children:e.jsxs(e.Fragment,{children:[q.newPickerConf&&e.jsx(j,{visible:!0,onClose:()=>oe(void 0),collectionFetcher:q.newPickerConf.fetchCollections,productFetcher:q.newPickerConf.fetchProducts,selectedItems:te===w.ENTITLED?xe:Te,onAdd:e=>{Object.values(e).forEach((e=>{e.products&&delete e.products})),te===w.ENTITLED?_e(e):Ee(e),oe(void 0)},customCollectionRestriction:!1,zIndex:200,storeId:q.newPickerConf.storeId,appType:q.newPickerConf.appType||M.ApplicationType.BIK,searchInCollectionFetcher:q.newPickerConf.searchInCollection,searchFetcher:q.newPickerConf.searchProducts,hideProductCheckbox:!0,hideVariantCheckbox:!0,title:"Select Collections",hideGlobalSearch:!0,hideSelectionCount:!0}),!q.newPickerConf&&e.jsx(h,{show:!0,onSave:()=>{},products:null!==(z=q.collection)&&void 0!==z?z:[],title:"Select Products",onClose:()=>{oe(void 0)},selectedProducts:null!==(K=te===w.ENTITLED?xe:Te)&&void 0!==K?K:[],setSelectedProducts:te===w.ENTITLED?_e:Ee,onSearchKeyChange:q.onCollectionSearch,searchPlaceholder:"Search collections..."})]})})),ee&&e.jsx(D,{children:e.jsx("div",Object.assign({style:{width:"50%",height:"100%",marginLeft:"50%"}},{children:e.jsx(_,{type:x.EMBEDDED,data:null!==($=q.productVariableList)&&void 0!==$?$:[],showHeader:!0,onSelect:e=>{if(ee===w.ENTITLED){const{displayName:i,actualValue:t,isAvailable:o}=e;Se({displayName:i,actualValue:t,isAvailable:o}),ie(void 0)}if(ee===w.PREREQUISITE){const{displayName:i,actualValue:t,isAvailable:o}=e;je({displayName:i,actualValue:t,isAvailable:o}),ie(void 0)}},onClose:()=>{ie(void 0)}})}))})]}))};export{q as DiscountModal};
1
+ import{j as e}from"../../node_modules/react/jsx-runtime.js";import{ApplicationType as i}from"@bikdotai/bik-models/growth";import{useState as t,useEffect as o}from"react";import{DISCOUNT_TYPES as n,MIN_PURCHASE_REQUIREMENT as l,DISCOUNT_APPLIES_TO as r,OFFER_APPLIES_TO as d,initialStaticCouponErrorState as a,initialDynamicCouponErrorState as s,COUPON_EXPIRATION as c,DISCOUNT_TARGET_TYPES as u,DISCOUNT_TARGET_SELECTION as p,DISCOUNT_VALUE_TYPES as v}from"./type.js";import"../dropdown/DropdownPopover/index.js";import{Dropdown as C}from"../dropdown/Dropdown.js";import"../dropdown/ChipDropdown.js";import"../zeroState/ZeroState.js";import{TitleSmall as m,BodyCaption as b,TitleRegular as y}from"../TypographyStyle.js";import{DEFAULT_THEME as P}from"../../constants/Theme.js";import"../dropdown/OpenedDropdown/components/description/Description.styled.js";import"../checkBox/CheckBox.styled.js";import"../list-item/ListItem.js";import"../dropdown/OpenedDropdown/components/menu/FreeFormMenu.styled.js";import"../dropdown/OpenedDropdown/components/menu/MenuItem.js";import"../dropdown/OpenedDropdown/components/menu/MenuList.styled.js";import"../button/Button.js";import"../dropdown/OpenedDropdown/components/multiSelect/MultiSelectDropdownBottomBar.styled.js";import"../dropdown/OpenedDropdown/components/OpennedDropdown.styled.js";import"../icon-button/IconButton.js";import"../input/Input.js";import"../dropdown/MenuItem/MenuItem.js";import{StyledModal as h}from"../modals/styledModal.js";import{ProductPickerContent as I}from"../product-picker/ProductPickerModal.js";import{Tag as f}from"../tag/Tag.js";import{Tooltip as T}from"../tooltips/Tooltip.js";import E from"../../assets/icons/gift_icon.svg.js";import O from"../../assets/icons/percentage_icon.svg.js";import S from"../../assets/icons/shipping_icon.svg.js";import g from"../../assets/icons/triangle_error.svg.js";import j from"../../assets/icons/warning.svg.js";import{ProductPickerModal as x}from"../product-picker-v2/modal.js";import"../product-picker-v2/type.js";import{PickerType as V}from"../variable-picker-v3/model.js";import{VariablePicker as _}from"../variable-picker-v3/VariablePicker.js";import{StyledDiscountDialogueContainer as A,CouponTypeContainerStyled as D,VariablePickerContainer as k}from"./DiscountModal.styled.js";import{validateDiscountData as N,descriptionBuilder as F}from"./DiscountUtils.js";import w,{DISCOUNT_PRODUCTS as R}from"./DynamicCoupon/DynamicCoupon.js";import M from"./StaticCoupon/StaticCoupon.js";const q=q=>{var L,U,B,G,Y,X,Q,H,z,K,$;const Z=[{id:"0",label:"Amount",value:"amount",icon:i=>e.jsx("span",Object.assign({style:{fontSize:20,color:i,lineHeight:.9}},{children:q.currency||""}))},{id:"1",label:"Percentage",value:"percentage",icon:i=>e.jsx(O,{width:24,height:24,color:i})},{id:"2",label:"Buy X get Y",value:n.BUY_X_GET_Y,icon:i=>e.jsx(E,{width:24,height:24,color:i})},{id:"3",label:"Free Shipping",value:n.FREE_SHIPPING,icon:i=>e.jsx(S,{width:24,height:24,color:i})}],[J,W]=t(),[ee,ie]=t(),[te,oe]=t(),[ne,le]=t(null!==(L=q.data)&&void 0!==L?L:"string"==typeof q.hideOption?{isStaticCoupon:"dynamic"===q.hideOption}:{isStaticCoupon:!0}),[re,de]=t(!0),[ae,se]=t(),[ce,ue]=t((null===(U=q.data)||void 0===U?void 0:U.minAmount)?l.AMOUNT:(null===(B=q.data)||void 0===B?void 0:B.minQuantity)?l.QUANTITY:l.NA),[pe,ve]=t(r.ENTIRE_ORDER),[Ce,me]=t(d.SPECIFIC_PRODUCTS),[be,ye]=t(d.SPECIFIC_PRODUCTS),[Pe,he]=t(void 0),[Ie,fe]=t(void 0),[Te,Ee]=t(void 0),[Oe,Se]=t(void 0),[ge,je]=t(void 0),[xe,Ve]=t(void 0),[_e,Ae]=t(0),[De,ke]=t(""),[Ne,Fe]=t(Z[0]),[we,Re]=t(!1),[Me,qe]=t(a),[Le,Ue]=t(s),[Be,Ge]=t(c.DYNAMIC_EXPIRATION),Ye=[{value:n.AMOUNT_OFF_ORDER,label:"Amount off on order",selected:ae===n.AMOUNT_OFF_ORDER},{value:n.AMOUNT_OFF_PRODUCTS,label:"Amount off on products",selected:ae===n.AMOUNT_OFF_PRODUCTS},{value:n.BUY_X_GET_Y,label:"Buy X Get Y FREE",selected:ae===n.BUY_X_GET_Y},{value:n.FREE_SHIPPING,label:"Free shipping",selected:ae===n.FREE_SHIPPING}];o((()=>{q.makeExpiryMandatory&&Re(!0)}),[q.makeExpiryMandatory]),o((()=>{var e,i,t,o,l,a,s,u;let p;const{tempCouponData:C,discountType:m}=Xe();se(m);const b=(e,i)=>{Fe(C.valueType===v.FIXED_AMOUNT?Z[e]:Z[i])},y=(e,i)=>{Object.keys(e||{}).length&&i(e)};switch(((null==C?void 0:C.expireAfter)||(null==C?void 0:C.expireAt))&&(Re(!0),(null==C?void 0:C.expireAt)&&Ge(c.FIXED_EXPIRATION),(null==C?void 0:C.expireAfter)&&Ge(c.DYNAMIC_EXPIRATION)),m){case n.AMOUNT_OFF_ORDER:b(0,1),ve(r.ENTIRE_ORDER);break;case n.AMOUNT_OFF_PRODUCTS:b(0,1),(null===(e=C.entitledCollectionIds)||void 0===e?void 0:e.length)?ve(r.SPECIFIC_COLLECTIONS):(null===(i=C.entitledProductIds)||void 0===i?void 0:i.length)||(null===(t=C.productVariableConf)||void 0===t?void 0:t.entitledProductVariable)?(ve(r.SPECIFIC_PRODUCTS),y(null===(o=C.productVariableConf)||void 0===o?void 0:o.entitledProductVariable,Se)):ve(r.ENTIRE_ORDER);break;case n.BUY_X_GET_Y:Fe(Z[2]),(null===(l=C.entitledCollectionIds)||void 0===l?void 0:l.length)?ye(d.SPECIFIC_COLLECTIONS):(ye(d.SPECIFIC_PRODUCTS),y(null===(a=C.productVariableConf)||void 0===a?void 0:a.entitledProductVariable,Se)),(null===(s=C.prerequisiteCollectionIds)||void 0===s?void 0:s.length)?me(d.SPECIFIC_COLLECTIONS):(me(d.SPECIFIC_PRODUCTS),y(null===(u=C.productVariableConf)||void 0===u?void 0:u.prerequisiteProductVariable,je));break;case n.FREE_SHIPPING:Fe(Z[3])}le(Object.assign({},C)),q.hideProbability||(p=ze()),de(N(C,ce,m,q.hideProbability||!1,p,!!C.isStaticCoupon)),q.hideProbability||ze()}),[]),o((()=>{let e;q.hideProbability||(e=ze()),de(N(ne,ce,ae,q.hideProbability||!1,e,!!ne.isStaticCoupon))}),[ne,_e,ae,ce]),o((()=>{var e,i,t,o,n,l,r;if(!q.newPickerConf&&((null===(e=q.products)||void 0===e?void 0:e.length)||(null===(i=q.collection)||void 0===i?void 0:i.length))){if(q.products&&(null===(t=q.products)||void 0===t?void 0:t.length)){if(null===(o=q.data)||void 0===o?void 0:o.entitledProductIds){const e=q.products.filter((e=>{var i,t;return null===(t=null===(i=q.data)||void 0===i?void 0:i.entitledProductIds)||void 0===t?void 0:t.includes(parseInt(e.id))}));fe(e)}if(null===(n=q.data)||void 0===n?void 0:n.prerequisiteProductIds){const e=q.products.filter((e=>{var i,t;return null===(t=null===(i=q.data)||void 0===i?void 0:i.prerequisiteProductIds)||void 0===t?void 0:t.includes(parseInt(e.id))}));he(e)}}if(q.collection&&q.collection.length){if(null===(l=q.data)||void 0===l?void 0:l.entitledCollectionIds){const e=q.collection.filter((e=>{var i,t;return null===(t=null===(i=q.data)||void 0===i?void 0:i.entitledCollectionIds)||void 0===t?void 0:t.includes(parseInt(e.id))}));Ve(e)}if(null===(r=q.data)||void 0===r?void 0:r.prerequisiteCollectionIds){const e=q.collection.filter((e=>{var i,t;return null===(t=null===(i=q.data)||void 0===i?void 0:i.prerequisiteCollectionIds)||void 0===t?void 0:t.includes(parseInt(e.id))}));Ee(e)}}}}),[q.products,q.collection]),o((()=>{var e,i,t,o,n,l,r,d;(null===(i=null===(e=q.data)||void 0===e?void 0:e.productsConf)||void 0===i?void 0:i.entitledProducts)&&fe(q.data.productsConf.entitledProducts),(null===(o=null===(t=q.data)||void 0===t?void 0:t.productsConf)||void 0===o?void 0:o.prerequisiteProducts)&&he(q.data.productsConf.prerequisiteProducts),(null===(l=null===(n=q.data)||void 0===n?void 0:n.collectionsConf)||void 0===l?void 0:l.entitledCollections)&&Ve(q.data.collectionsConf.entitledCollections),(null===(d=null===(r=q.data)||void 0===r?void 0:r.collectionsConf)||void 0===d?void 0:d.prerequisiteCollections)&&Ee(q.data.collectionsConf.prerequisiteCollections)}),[null===(G=q.data)||void 0===G?void 0:G.productsConf,null===(Y=q.data)||void 0===Y?void 0:Y.collectionsConf]),o((()=>{if(!Ie)return;if(q.newPickerConf){const e=[];return Object.values(Ie).forEach((i=>{i.products&&Object.keys(i.products).forEach((i=>{e.push(parseInt(i))}))})),void le(Object.assign(Object.assign({},ne),{entitledProductIds:e}))}const e=Ie.map((e=>parseInt(e.id)));le(Object.assign(Object.assign({},ne),{entitledProductIds:e}))}),[Ie]),o((()=>{if(!Pe)return;if(q.newPickerConf){const e=[];return Object.values(Pe).forEach((i=>{i.products&&Object.keys(i.products).forEach((i=>{e.push(parseInt(i))}))})),void le(Object.assign(Object.assign({},ne),{prerequisiteProductIds:e}))}const e=Pe.map((e=>parseInt(e.id)));le(Object.assign(Object.assign({},ne),{prerequisiteProductIds:e}))}),[Pe]),o((()=>{if(!xe)return;if(q.newPickerConf){(null==xe?void 0:xe.isCustom)&&delete xe.isCustom;const e=Object.keys(xe).map((e=>parseInt(e)));return void le(Object.assign(Object.assign({},ne),{entitledCollectionIds:e}))}const e=xe.map((e=>parseInt(e.id)));le(Object.assign(Object.assign({},ne),{entitledCollectionIds:e}))}),[xe]),o((()=>{if(!Te)return;if(q.newPickerConf){(null==Te?void 0:Te.isCustom)&&delete Te.isCustom;const e=Object.keys(Te).map((e=>parseInt(e)));return void le(Object.assign(Object.assign({},ne),{prerequisiteCollectionIds:e}))}const e=Te.map((e=>parseInt(e.id)));le(Object.assign(Object.assign({},ne),{prerequisiteCollectionIds:e}))}),[Te]);const Xe=()=>{var e,i;let t,o=ne;return ne.isStaticCoupon||(ne.targetType===u.SHIPPING_LINE?t=n.FREE_SHIPPING:ne.targetType===u.LINE_ITEM?t=ne.targetSelection===p.ENTITLED?(null===(e=ne.prerequisiteProductIds)||void 0===e?void 0:e.length)||(null===(i=ne.prerequisiteCollectionIds)||void 0===i?void 0:i.length)||ne.prerequisiteQuantity||ne.entitledQuantity?n.BUY_X_GET_Y:n.AMOUNT_OFF_PRODUCTS:n.AMOUNT_OFF_ORDER:(o=Object.assign(Object.assign({},o),{targetType:u.LINE_ITEM,targetSelection:p.ALL,valueType:v.FIXED_AMOUNT}),t=n.AMOUNT_OFF_ORDER)),{discountType:t,tempCouponData:o}},Qe=()=>{qe(a),Ue(s)},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=ne.probability)&&void 0!==i?i:-1)>1?"Probability should not exceed 1":ne.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&&(ke(n>1?"Please add discount details":o),!0)},ze=()=>{if(!q.quadrant||!q.probability)return;const e=[...q.probability];let i=[];e.length>=q.quadrant&&e.splice(q.quadrant-1,1),i=e;const t=i.reduce(((e,i)=>e+i),0)+(ne.probability||0);return Ae(parseFloat(t.toFixed(4))),parseFloat(t.toFixed(4))},Ke=e=>{var i,t,o,l,r,d,a,s,c,C,m,b,y,P,h,I;const f=e.value;se(f),he([]),fe([]),Ee([]),Ve([]),f===n.FREE_SHIPPING?le({value:100,targetSelection:p.ALL,targetType:u.SHIPPING_LINE,valueType:v.PERCENTAGE,quadrant:ne.quadrant,isStaticCoupon:!1,title:ne.title,expireAt:null!==(i=ne.expireAt)&&void 0!==i?i:void 0,expireAfter:null!==(t=ne.expireAfter)&&void 0!==t?t:void 0,probability:ne.probability,minQuantity:null!==(o=ne.minQuantity)&&void 0!==o?o:void 0,minAmount:null!==(l=ne.minAmount)&&void 0!==l?l:void 0}):f===n.BUY_X_GET_Y?le({value:100,targetSelection:p.ENTITLED,targetType:u.LINE_ITEM,valueType:v.PERCENTAGE,quadrant:ne.quadrant,isStaticCoupon:!1,title:ne.title,expireAt:null!==(r=ne.expireAt)&&void 0!==r?r:void 0,expireAfter:null!==(d=ne.expireAfter)&&void 0!==d?d:void 0,probability:ne.probability,minQuantity:void 0,minAmount:void 0}):f===n.AMOUNT_OFF_ORDER?le({targetSelection:p.ALL,targetType:u.LINE_ITEM,valueType:null!==(a=ne.valueType)&&void 0!==a?a:v.FIXED_AMOUNT,quadrant:ne.quadrant,isStaticCoupon:!1,title:ne.title,expireAt:null!==(s=ne.expireAt)&&void 0!==s?s:void 0,expireAfter:null!==(c=ne.expireAfter)&&void 0!==c?c:void 0,probability:ne.probability,value:ne.value,minQuantity:null!==(C=ne.minQuantity)&&void 0!==C?C:void 0,minAmount:null!==(m=ne.minAmount)&&void 0!==m?m:void 0}):f===n.AMOUNT_OFF_PRODUCTS&&le({targetSelection:p.ENTITLED,targetType:u.LINE_ITEM,valueType:null!==(b=ne.valueType)&&void 0!==b?b:v.FIXED_AMOUNT,quadrant:ne.quadrant,isStaticCoupon:!1,title:ne.title,expireAt:null!==(y=ne.expireAt)&&void 0!==y?y:void 0,expireAfter:null!==(P=ne.expireAfter)&&void 0!==P?P:void 0,probability:ne.probability,value:ne.value,minQuantity:null!==(h=ne.minQuantity)&&void 0!==h?h:void 0,minAmount:null!==(I=ne.minAmount)&&void 0!==I?I:void 0})},$e=i=>i&&e.jsx(f,{theme:"light",tagText:i,type:"negative",LeadingIcon:j});return e.jsxs(h,Object.assign({width:(te||J)&&q.newPickerConf?"25px":"640px",open:q.isOpen,hideCrossButton:!!ee,headingTitle:J?"Select Products":q.title,headingSubtitle:J?void 0:q.subTitle,footerLeftCustomElement:De?$e(De):q.errorMsg?$e(q.errorMsg):!q.quadrant||q.hideProbability?e.jsx(e.Fragment,{}):_e<=1?e.jsx(f,{theme:"light",tagText:`Current probability sum: ${_e}`,type:"white"}):e.jsx(T,Object.assign({body:"Probability sum should not exceed 1",placement:"top"},{children:e.jsx("div",{children:e.jsx(f,{style:{cursor:"pointer"},theme:"light",tagText:`Current probability sum: ${_e}`,type:"negative",LeadingIcon:g})})})),headerRightCustomElement:q.allowStaticCoupon||J?void 0:e.jsx(C,{options:Ye,width:"200px",placement:"bottom-start",size:"small",onSelect:e=>{Ke(e)}}),onClose:q.onClose,footerContainerStyle:{borderTop:`1px solid ${P.colorsV2.stroke.primary}`},primaryButton:J?{buttonType:"primary",onClick:()=>{W(void 0)},buttonText:"Add"}:te?{buttonType:"primary",onClick:()=>{oe(void 0)},buttonText:"Add"}:{buttonType:"primary",buttonText:"Create discount code",isLoading:null!==(X=q.loading)&&void 0!==X&&X,onClick:()=>{var e,i,t,o,a;if(Qe(),ne.isStaticCoupon){const{isStaticCoupon:e,couponCode:i,title:t,description:o,quadrant:n,probability:l}=ne,r={invalidDiscountCode:!i,invalidCouponTitle:!t,invalidCouponDescription:!o,inValidProbability:!q.hideProbability&&(null!=l?l:-1)<0||(null!=l?l:0)>1||Number.isNaN(null!=l?l:0)};if(He(r))return void qe(r);if(re||_e>1)return void ke(!q.hideProbability&&_e>1?"Probability sum should not exceed 1":"Invalid coupon details");q.onSaveClicked({quadrant:n,couponCode:i,description:o,isStaticCoupon:e,probability:l,title:ne.title})}else{const s={invalidCouponTitle:!ne.title,inValidProbability:!q.hideProbability&&(null!==(e=ne.probability)&&void 0!==e?e:-1)<=0||(null!==(i=ne.probability)&&void 0!==i?i:-1)>1||Number.isNaN(null!==(t=ne.probability)&&void 0!==t?t:-1),inValidDiscountAmount:!ne.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(ae!==n.BUY_X_GET_Y&&ce!==l.NA){const{minAmount:e,minQuantity:i}=ne;s.inValidMinimumAmount=ce===l.AMOUNT&&!e,s.inValidMinimumQuantity=ce===l.QUANTITY&&!i}if(we&&(s.inValidCouponExpiry=!ne.expireAt&&!ne.expireAfter),ae!==n.AMOUNT_OFF_ORDER&&ae!==n.AMOUNT_OFF_PRODUCTS||(pe!==r.SPECIFIC_PRODUCTS||!Ie||Object.keys(Ie).length||Oe||(s.inValidProductSelection=!0,s.inValidProductVariableSelection=!0),pe===r.SPECIFIC_COLLECTIONS&&xe&&!Object.keys(xe).length&&(s.inValidCollectionSelection=!0)),ae===n.BUY_X_GET_Y&&(ne.prerequisiteQuantity||(s.inValidBuyXValue=!0),ne.entitledQuantity||(s.inValidGetYValue=!0),Ce!==d.SPECIFIC_PRODUCTS||!Pe||Object.keys(Pe).length||ge||(s.inValidBuyXProductSelection=!0,s.inValidBuyXProductVariableSelection=!0),Ce===d.SPECIFIC_COLLECTIONS&&Te&&!Object.keys(Te).length&&(s.inValidBuyXCollectionSelection=!0),be!==d.SPECIFIC_PRODUCTS||!Ie||Object.keys(Ie).length||Oe||(s.inValidGetYProductSelection=!0,s.inValidGetYProductVariableSelection=!0),be===d.SPECIFIC_COLLECTIONS&&xe&&!Object.keys(xe).length&&(s.inValidGetYCollectionSelection=!0)),He(s))return void Ue(s);if(re||_e>1)return void ke(!q.hideProbability&&_e>1?"Probability sum should not exceed 1":"Invalid coupon details");q.onSaveClicked(Object.assign(Object.assign({},ne),{description:F(ne,q.currency,null!==(o=q.products)&&void 0!==o?o:[],null!==(a=q.collection)&&void 0!==a?a:[]),productsConf:{entitledProducts:null!=Ie?Ie:[],prerequisiteProducts:null!=Pe?Pe:[]},collectionsConf:{entitledCollections:null!=xe?xe:[],prerequisiteCollections:null!=Te?Te:[]},productVariableConf:{entitledProductVariable:null!=Oe?Oe:{},prerequisiteProductVariable:null!=ge?ge:{}}}))}}},secondaryButton:J?{buttonType:"tertiaryGray",onClick:()=>{W(void 0)},buttonText:"Back"}:te?{buttonType:"tertiaryGray",onClick:()=>{oe(void 0)},buttonText:"Back"}:{buttonType:"tertiaryGray",onClick:q.onClose,buttonText:"Cancel"}},{children:[!J&&!te&&e.jsxs(A,{children:[q.allowStaticCoupon&&!J&&e.jsxs(D,Object.assign({selectedDiv:ne.isStaticCoupon?1:2},{children:["static"===q.hideOption?e.jsx(e.Fragment,{}):e.jsxs("div",Object.assign({className:"coupon-type__container",onClick:()=>{ne.isStaticCoupon||(le({isStaticCoupon:!0,quadrant:ne.quadrant}),ke(""),Qe())}},{children:[e.jsx(m,Object.assign({style:{marginBottom:"4px",color:ne.isStaticCoupon?P.colorsV2.content.brand:void 0}},{children:"Static Code"})),e.jsx(b,Object.assign({style:ne.isStaticCoupon?{color:P.colorsV2.content.brand}:{}},{children:"A uniform code provided manually, used for providing the same discount to all customers."}))]})),"dynamic"===q.hideOption?e.jsx(e.Fragment,{}):e.jsxs("div",Object.assign({className:"coupon-type__container",onClick:()=>{var i;ne.isStaticCoupon&&(se(n.AMOUNT_OFF_ORDER),le({isStaticCoupon:!1,quadrant:ne.quadrant,targetType:u.LINE_ITEM,targetSelection:p.ALL,valueType:v.FIXED_AMOUNT}),ke(""),Qe(),Fe({id:"0",label:"Amount",value:"amount",icon:i=>e.jsx("span",Object.assign({style:{fontSize:20,color:i}},{children:q.currency||""}))}),Re(null!==(i=q.makeExpiryMandatory)&&void 0!==i&&i),ue(l.NA))}},{children:[e.jsx(m,Object.assign({style:{marginBottom:"4px",color:ne.isStaticCoupon?void 0:P.colorsV2.content.brand}},{children:"Dynamic Code"})),e.jsx(b,Object.assign({style:ne.isStaticCoupon?{}:{color:P.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.jsx(y,Object.assign({style:{marginTop:"24px"}},{children:"Coupon Details"})),ne.isStaticCoupon&&!J&&e.jsx(M,{discountData:ne,setDiscountData:le,hideProbability:q.hideProbability||!1,discountAdminUrl:q.discountAdminUrl,staticDiscountValidationError:Me,currency:q.currency}),!ne.isStaticCoupon&&!J&&!te&&e.jsx(w,{currency:q.currency,entitledProducts:null!=Ie?Ie:[],prerequisiteProducts:null!=Pe?Pe:[],setEntitledProducts:fe,setPrerequisiteProducts:he,discountData:ne,productPickerOpen:J,productVariablePickerOpen:ee,setIsProductPickerOpen:W,setIsProductVariablePickerOpen:ie,setDiscountData:le,selectedCouponType:ae,setSelectedCouponType:se,selectedMinimumRequirement:ce,setSelectedMinimumRequirement:ue,discountCouponAppliesTo:pe,offerAppliesToBuy:Ce,offerAppliesToGet:be,setDiscountCouponAppliesTo:ve,setOfferAppliesToBuy:me,setOfferAppliesToGet:ye,hideProbability:q.hideProbability||!1,hideExpiration:q.hideExpiration||!1,allowStaticCoupon:q.allowStaticCoupon,onChangeCouponType:Ke,collectionPickerOpen:te,entitledCollections:null!=xe?xe:[],prerequisiteCollections:null!=Te?Te:[],setIsCollectionPickerOpen:oe,setEntitledCollections:Ve,setPrerequisiteCollections:Ee,useNewPicker:!!q.newPickerConf,setSelectedDiscountDetails:Fe,selectedDiscountDetails:Ne,isProductVariableSupported:q.isProductVariableSupported,entitledProductVariable:Oe,setEntitledProductVariable:Se,preRequisiteProductVariable:ge,setPreRequisiteProductVariable:je,productVariableList:q.productVariableList,isAddExpirationChecked:we,setIsAddExpirationChecked:Re,dynamicDiscountValidationError:Le,setDynamicDiscountValidationError:Ue,setValidationErrorMessage:ke,resetValidationErrors:Qe,discountDetailsOptions:Z,selectedExpiration:Be,setSelectedExpiration:Ge,makeExpiryMandatory:!!q.makeExpiryMandatory})]}),!!J&&e.jsxs(e.Fragment,{children:[!q.newPickerConf&&e.jsx("div",Object.assign({style:{padding:"12px 0"}},{children:e.jsx(I,{show:!0,onSave:()=>{},products:null!==(Q=q.products)&&void 0!==Q?Q:[],title:"Select Products",onClose:()=>{W(void 0)},selectedProducts:null!==(H=J===R.ENTITLED?Ie:Pe)&&void 0!==H?H:[],setSelectedProducts:J===R.ENTITLED?fe:he,onSearchKeyChange:q.onProductSearch})})),q.newPickerConf&&e.jsx(x,{visible:!0,onClose:()=>W(void 0),collectionFetcher:(e,i,t)=>{var o;return(null===(o=q.newPickerConf)||void 0===o?void 0:o.fetchCollections)?q.newPickerConf.fetchCollections(e,i,!1,t):null},productFetcher:(e,i,t,o,n)=>{var l;return(null===(l=q.newPickerConf)||void 0===l?void 0:l.fetchProducts)?q.newPickerConf.fetchProducts(e,i,o,n,!1,t):null},selectedItems:J===R.ENTITLED?Ie:Pe,onAdd:e=>{J===R.ENTITLED?fe(e):he(e),W(void 0)},zIndex:200,storeId:q.newPickerConf.storeId,appType:q.newPickerConf.appType||i.BIK,searchInCollectionFetcher:(e,i,t,o)=>{var n;return(null===(n=q.newPickerConf)||void 0===n?void 0:n.searchInCollection)?q.newPickerConf.searchInCollection(e,i,t,!1,o):null},customCollectionRestriction:!1,searchFetcher:(e,i,t)=>{var o;return(null===(o=q.newPickerConf)||void 0===o?void 0:o.searchProducts)?q.newPickerConf.searchProducts(e,i,!1,t):null},hideCollectionCheckbox:!0,hideVariantCheckbox:!0,selectProductsFromCustomCollection:!0,hideSelectionCount:!0})]}),!!te&&e.jsx("div",Object.assign({style:{padding:"12px 0"}},{children:e.jsxs(e.Fragment,{children:[q.newPickerConf&&e.jsx(x,{visible:!0,onClose:()=>oe(void 0),collectionFetcher:q.newPickerConf.fetchCollections,productFetcher:q.newPickerConf.fetchProducts,selectedItems:te===R.ENTITLED?xe:Te,onAdd:e=>{Object.values(e).forEach((e=>{e.products&&delete e.products})),te===R.ENTITLED?Ve(e):Ee(e),oe(void 0)},customCollectionRestriction:!1,zIndex:200,storeId:q.newPickerConf.storeId,appType:q.newPickerConf.appType||i.BIK,searchInCollectionFetcher:q.newPickerConf.searchInCollection,searchFetcher:q.newPickerConf.searchProducts,hideProductCheckbox:!0,hideVariantCheckbox:!0,title:"Select Collections",hideGlobalSearch:!0,hideSelectionCount:!0}),!q.newPickerConf&&e.jsx(I,{show:!0,onSave:()=>{},products:null!==(z=q.collection)&&void 0!==z?z:[],title:"Select Products",onClose:()=>{oe(void 0)},selectedProducts:null!==(K=te===R.ENTITLED?xe:Te)&&void 0!==K?K:[],setSelectedProducts:te===R.ENTITLED?Ve:Ee,onSearchKeyChange:q.onCollectionSearch,searchPlaceholder:"Search collections..."})]})})),ee&&e.jsx(k,{children:e.jsx("div",Object.assign({style:{width:"50%",height:"100%",marginLeft:"50%"}},{children:e.jsx(_,{type:V.EMBEDDED,data:null!==($=q.productVariableList)&&void 0!==$?$:[],showHeader:!0,onSelect:e=>{if(ee===R.ENTITLED){const{displayName:i,actualValue:t,isAvailable:o}=e;Se({displayName:i,actualValue:t,isAvailable:o}),ie(void 0)}if(ee===R.PREREQUISITE){const{displayName:i,actualValue:t,isAvailable:o}=e;je({displayName:i,actualValue:t,isAvailable:o}),ie(void 0)}},onClose:()=>{ie(void 0)}})}))})]}))};export{q as DiscountModal};
@@ -1 +1 @@
1
- import{j as e}from"../../node_modules/react/jsx-runtime.js";import"../../node_modules/@bikdotai/bik-models/growth/index.js";import t from"../../assets/icons/search.svg.js";import{useReducer as o,useState as s,useRef as c,useEffect as r}from"react";import{COLORS as i}from"../../constants/Theme.js";import n from"../../assets/icons/cross.svg.js";import{Button as l}from"../button/Button.js";import{Input as a}from"../input/Input.js";import{StyledModal as d}from"../modals/styledModal.js";import{Spinner as u}from"../spinner/Spinner.js";import{Tag as p}from"../tag/Tag.js";import{CollectionsScreen as h}from"./collectionScreen.js";import{ProductInfoOverlay as m}from"./productInfoOverlay.js";import{ProductsScreen as g}from"./productScreen.js";import{RearrangeScreen as j}from"./rearrangeScreen.js";import{collectionsReducer as C,searchReducer as y,selectedColectionsReducer as x,CollectionIdContext as b}from"./reducers.js";import{SearchScreen as f}from"./searchScreen.js";import{SelectedScreen as S}from"./selectedScreen.js";import{ContainerStyle as k,ScrollContainerStyle as v,StyledFooterForNonModal as I}from"./style.js";import{OUT_OF_STOCK_ACTION as F,ScreenName as P}from"./type.js";import{updateAllVariantsForSelectedProducts as O}from"./utility.js";import{__exports as T}from"../../_virtual/index.js";const D=D=>{const{storeId:R,selectedItems:w,onClose:A,visible:B,zIndex:E,exactLimit:L,limit:z,hideCollectionCheckbox:V,hideProductCheckbox:$,outOfStockAction:M=F.BLUR,hideVariantCheckbox:_,selectProductsFromCustomCollection:H,hideSelectionCount:W,title:G,width:K,left:N,renderWithoutModal:U,onClickSave:Y,pickerType:q,hideProductVariants:J=!1,startupScreen:Q=P.Collections,rearrangeEnabled:X,selectSingleItem:Z=!1,showProductDetails:ee,containerStyle:te,crossButtonInsideHeader:oe=!1,footerForNonModal:se={},primaryButton:ce,secondaryButton:re,subtitle:ie}=D,ne=D.appType||T.ApplicationType.BIK,[le,ae]=o(C,{}),[de,ue]=s([P.Collections,P.RearrangeProducts].includes(Q)?Q:P.Collections),[pe,he]=s("grid"),[me,ge]=s(""),[je,Ce]=s(""),[ye,xe]=s(0),[be,fe]=s(!1),[Se,ke]=s(0),[ve,Ie]=s(""),[Fe,Pe]=s(!1),[Oe,Te]=s(!1),[De,Re]=o(y,{collections:{},products:{}}),[we,Ae]=o(x,Object.keys(w).length>0?w:{}),Be=c(null),[Ee,Le]=s(!1),[ze,Ve]=s();r((()=>{fe(!0),Te(!0),D.collectionFetcher(ye,R,ne).then((e=>{ae({type:"fetched",data:(null==e?void 0:e.collections)||{}}),fe(!1),xe((e=>e+1)),Te(!1)})).catch()}),[]),r((()=>{let e=0;J?Object.keys(we||[]).forEach((t=>{var o;Object.keys((null===(o=we[t])||void 0===o?void 0:o.products)||[]).forEach((o=>{var s;"-1"!==t&&we[-1]&&(null===(s=we[-1].products)||void 0===s?void 0:s[o])||(e+=1)}))})):Object.keys(we||[]).forEach((t=>{var o;Object.keys((null===(o=we[t])||void 0===o?void 0:o.products)||[]).forEach((o=>{var s,c;Object.keys((null===(c=null===(s=we[t].products)||void 0===s?void 0:s[o])||void 0===c?void 0:c.variants)||[]).forEach((()=>{e+=1}))}))})),ke(e)}),[le,we,J]),r((()=>{je&&(fe(!0),D.productFetcher(je,R,ne).then((e=>{Object.keys(e).length&&ae({type:"productsFetched",data:{collectionId:je,products:e}}),fe(!1)})).catch())}),[je]),r((()=>{const e=setTimeout((()=>{"rearrange"!==de&&(ve.length||"collections"!==de)&&(ve.length?(Pe(!0),D.searchFetcher(R,ve,ne).then((e=>{"collections"in e&&"products"in e?(Re({type:"set",data:e}),ae({type:"searched",data:e.collections}),ae({type:"searched",data:e.products})):(Re({type:"set",data:{collections:{},products:e}}),ae({type:"searched",data:e})),ue("searchProducts"),fe(!1),Pe(!1)}))):ue("collections"))}),800);return()=>clearTimeout(e)}),[ve]),r((()=>{Y&&(D.onAdd(we,Se),$e())}),[Y]),r((()=>{Z&&Object.keys(we||{}).length&&Se&&(D.onAdd(we,Se),$e())}),[Z,we,Se]);const $e=()=>{Ae({type:"reset",data:{}})},Me=()=>L&&Se>L?e.jsx(p,{tagText:`You can only select ${L} products`,type:"negative"}):z&&Se>z?e.jsx(p,{tagText:`You can only select ${z} products`,type:"negative"}):Se>0?e.jsx(l,{onClick:()=>{ue(X?P.RearrangeProducts:P.SelectedProducts)},buttonText:L?`${Se}/${L} products selected`:`${Se} products selected`,buttonType:["rearrange","view"].includes(de)?"tertiaryGray":"tertiary",disabled:["rearrange","view"].includes(de)}):e.jsx(l,{disabled:!0,buttonText:L?`${Se}/${L} products selected`:`${Se} products selected`,buttonType:"tertiaryGray"}),_e=e=>be?"Loading...":de===P.RearrangeProducts?null!=e?e:"Done":null!=e?e:"Add",He=e.jsxs(k,Object.assign({style:null!=te?te:{}},{children:[D.postHeader&&e.jsx("div",Object.assign({style:{padding:"0 24px"}},{children:D.postHeader})),!D.hideGlobalSearch&&e.jsx(e.Fragment,{children:("collections"===de||"searchProducts"===de)&&e.jsx("div",Object.assign({style:{padding:U?"8px 16px":"12px 24px",borderBottom:"1px solid #E0E0E0"}},{children:e.jsx(a,{placeholder:"Search using ID, Name or SKU ID",noKeyDownChange:!0,noErrorHint:!0,rightIcon:{icon:()=>Fe?e.jsx(u,{size:"small",color:i.content.primary}):e.jsx(t,{})},id:"listInput",height:"24px",type:"text",value:ve,onChangeText:e=>{e.length&&e.trim().length?Ie(e):Ie("")}})}))}),e.jsxs(v,Object.assign({ref:Be,screenName:de},{children:["collections"===de&&e.jsx(h,{customCollectionRestriction:D.customCollectionRestriction,dataLoading:Oe,collections:le,selectedCollectionsDispatch:Ae,setCollectionId:ge,setSelectedCollectionId:Ce,setScreen:ue,selectedCollections:we,collectionFetcher:D.collectionFetcher,storeId:R,appType:ne,collectionsDispatch:ae,setSaveDisabled:fe,pagingControls:{curPage:ye,setCurPage:xe},hideCollectionCheckbox:V,renderWithoutModal:U,pickerType:q,scrollContainerRef:Be}),"products"===de&&me&&e.jsx(b.Provider,Object.assign({value:me},{children:e.jsx(g,{hideInCollectionSearch:D.hideInCollectionSearch,customCollectionRestriction:D.customCollectionRestriction,productFetcher:D.productFetcher,setScreen:ue,storeId:R,appType:ne,data:le[me],collectionsDispatch:ae,selectedCollectionsDispatch:Ae,selectedData:we,setSaveDisabled:fe,searchInCollectionFetcher:D.searchInCollectionFetcher,hideProductCheckbox:$,outOfStockAction:M,hideVariantCheckbox:_,selectProductsFromCustomCollection:H,renderWithoutModal:U,pickerType:q,hideProductVariants:J,fbStatusFetcher:D.fbStatusFetcher,onProductDetailClick:e=>{Le(!0),Ve(e)},showProductDetailInfoIcon:ee,scrollContainerRef:Be})})),"view"===de&&e.jsx(S,{selectedCollections:we||{},selectedCollectionsDispatch:Ae,setScreen:ue,collections:le,hideProductVariants:J,outOfStockAction:M,storeId:R,appType:ne,fbStatusFetcher:D.fbStatusFetcher}),"rearrange"===de&&e.jsx(j,{selectedCollections:we||{},selectedCollectionsDispatch:Ae,setScreen:ue,outOfStockAction:M,rearrangeViewType:"grid"===pe?"list":"grid",scrollContainerRef:Be,storeId:R,appType:ne,fbStatusFetcher:D.fbStatusFetcher}),"searchProducts"===de&&e.jsx(f,{customCollectionRestriction:D.customCollectionRestriction,selectedCollections:we||{},searchedCollections:De||{},searchedCollectionsDispatch:Re,selectedCollectionsDispatch:Ae,setScreen:ue,collections:le,onBackPress:()=>{Ie(""),Re({type:"set",data:{collections:{},products:{}}})},pickerType:q,hideProductCheckbox:$,hideProductVariants:J,hideVariantCheckbox:_,storeId:R,appType:ne,fbStatusFetcher:D.fbStatusFetcher,setCollectionId:ge,setSelectedCollectionId:Ce,renderWithoutModal:U,hideCollectionCheckbox:V,outOfStockAction:M})]}))]}));return e.jsx(e.Fragment,{children:U?e.jsxs(e.Fragment,{children:[He,se.renderFooter?e.jsxs(I,{children:[Me(),e.jsx(l,{buttonText:_e(se.primaryButtonText),disabled:!se.isLoading&&(be||Se<1||L&&Se<L||!L&&z&&Se>z)||se.primaryButtonDisabled,isLoading:se.isLoading,onClick:()=>{D.onAdd(we,Se),$e(),ue([P.Collections,P.RearrangeProducts].includes(Q)?Q:P.Collections)}})]}):e.jsx(e.Fragment,{}),Ee&&ze?e.jsx(m,{productData:ze,outOfStockAction:M,useDynamicInfoImageSize:D.useDynamicInfoImageSize,onClose:()=>{Le(!1)}}):e.jsx(e.Fragment,{})]}):e.jsxs(d,Object.assign({zIndex:E,open:B,onClose:()=>{null==A||A(),$e()},headingTitle:G||("collections"===de||"products"===de?"Select Products":"view"===de?"Selected Products":"searchProducts"===de?"Searched Results":"rearrange"===de?"Rearrange Products":void 0),headingSubtitle:ie,footerShadow:!0,centralContainerStyles:{width:K||"600px",left:N||"auto"},headerRightCustomElement:oe?e.jsx("div",Object.assign({style:{cursor:"pointer",display:"flex"},onClick:A},{children:e.jsx(n,{width:20,height:20,color:i.content.secondary})})):e.jsx(e.Fragment,{}),footerContainerStyle:D.stickyFooter?{position:"absolute",bottom:0,left:0,width:"100%",zIndex:9,background:i.surface.standard}:void 0,primaryButton:ce?(e=>Object.assign(Object.assign({},e),{disabled:!e.isLoading&&(be||Se<1||L&&Se<L||!L&&z&&Se>z)||e.disabled,onClick:()=>{D.onAdd(we,Se),$e(),ue([P.Collections,P.RearrangeProducts].includes(Q)?Q:P.Collections)}}))(ce):{buttonText:_e(),disabled:be||Se<1||L&&Se<L||!L&&z&&Se>z||!1,onClick:()=>{D.onAdd(we,Se),$e()}},secondaryButton:re?(e=>Object.assign(Object.assign({},e),{disabled:be||Se<1||L&&Se<L||!L&&z&&Se>z||!1,onClick:()=>{const e=O(we,le,De);D.onAdd(e,Se,!0)}}))(re):void 0,wrapperStyle:D.stickyFooter?{height:"calc(100vh - 168px)"}:void 0,footerLeftCustomElement:W?e.jsx(e.Fragment,{}):Me(),hideCrossButton:Ee||oe},{children:[He,Ee&&ze?e.jsx(m,{productData:ze,useDynamicInfoImageSize:D.useDynamicInfoImageSize,outOfStockAction:M,onClose:()=>{Le(!1)}}):e.jsx(e.Fragment,{})]}))})};export{D as ProductPickerModal};
1
+ import{j as e}from"../../node_modules/react/jsx-runtime.js";import{ApplicationType as t}from"@bikdotai/bik-models/growth";import o from"../../assets/icons/search.svg.js";import{useReducer as c,useState as s,useRef as r,useEffect as i}from"react";import{COLORS as n}from"../../constants/Theme.js";import l from"../../assets/icons/cross.svg.js";import{Button as a}from"../button/Button.js";import{Input as d}from"../input/Input.js";import{StyledModal as u}from"../modals/styledModal.js";import{Spinner as p}from"../spinner/Spinner.js";import{Tag as h}from"../tag/Tag.js";import{CollectionsScreen as m}from"./collectionScreen.js";import{ProductInfoOverlay as g}from"./productInfoOverlay.js";import{ProductsScreen as C}from"./productScreen.js";import{RearrangeScreen as j}from"./rearrangeScreen.js";import{collectionsReducer as y,searchReducer as x,selectedColectionsReducer as b,CollectionIdContext as f}from"./reducers.js";import{SearchScreen as S}from"./searchScreen.js";import{SelectedScreen as k}from"./selectedScreen.js";import{ContainerStyle as v,ScrollContainerStyle as I,StyledFooterForNonModal as F}from"./style.js";import{OUT_OF_STOCK_ACTION as P,ScreenName as O}from"./type.js";import{updateAllVariantsForSelectedProducts as T}from"./utility.js";const D=D=>{const{storeId:R,selectedItems:w,onClose:A,visible:B,zIndex:E,exactLimit:L,limit:z,hideCollectionCheckbox:V,hideProductCheckbox:$,outOfStockAction:M=P.BLUR,hideVariantCheckbox:H,selectProductsFromCustomCollection:W,hideSelectionCount:G,title:K,width:N,left:U,renderWithoutModal:Y,onClickSave:_,pickerType:q,hideProductVariants:J=!1,startupScreen:Q=O.Collections,rearrangeEnabled:X,selectSingleItem:Z=!1,showProductDetails:ee,containerStyle:te,crossButtonInsideHeader:oe=!1,footerForNonModal:ce={},primaryButton:se,secondaryButton:re,subtitle:ie}=D,ne=D.appType||t.BIK,[le,ae]=c(y,{}),[de,ue]=s([O.Collections,O.RearrangeProducts].includes(Q)?Q:O.Collections),[pe,he]=s("grid"),[me,ge]=s(""),[Ce,je]=s(""),[ye,xe]=s(0),[be,fe]=s(!1),[Se,ke]=s(0),[ve,Ie]=s(""),[Fe,Pe]=s(!1),[Oe,Te]=s(!1),[De,Re]=c(x,{collections:{},products:{}}),[we,Ae]=c(b,Object.keys(w).length>0?w:{}),Be=r(null),[Ee,Le]=s(!1),[ze,Ve]=s();i((()=>{fe(!0),Te(!0),D.collectionFetcher(ye,R,ne).then((e=>{ae({type:"fetched",data:(null==e?void 0:e.collections)||{}}),fe(!1),xe((e=>e+1)),Te(!1)})).catch()}),[]),i((()=>{let e=0;J?Object.keys(we||[]).forEach((t=>{var o;Object.keys((null===(o=we[t])||void 0===o?void 0:o.products)||[]).forEach((o=>{var c;"-1"!==t&&we[-1]&&(null===(c=we[-1].products)||void 0===c?void 0:c[o])||(e+=1)}))})):Object.keys(we||[]).forEach((t=>{var o;Object.keys((null===(o=we[t])||void 0===o?void 0:o.products)||[]).forEach((o=>{var c,s;Object.keys((null===(s=null===(c=we[t].products)||void 0===c?void 0:c[o])||void 0===s?void 0:s.variants)||[]).forEach((()=>{e+=1}))}))})),ke(e)}),[le,we,J]),i((()=>{Ce&&(fe(!0),D.productFetcher(Ce,R,ne).then((e=>{Object.keys(e).length&&ae({type:"productsFetched",data:{collectionId:Ce,products:e}}),fe(!1)})).catch())}),[Ce]),i((()=>{const e=setTimeout((()=>{"rearrange"!==de&&(ve.length||"collections"!==de)&&(ve.length?(Pe(!0),D.searchFetcher(R,ve,ne).then((e=>{"collections"in e&&"products"in e?(Re({type:"set",data:e}),ae({type:"searched",data:e.collections}),ae({type:"searched",data:e.products})):(Re({type:"set",data:{collections:{},products:e}}),ae({type:"searched",data:e})),ue("searchProducts"),fe(!1),Pe(!1)}))):ue("collections"))}),800);return()=>clearTimeout(e)}),[ve]),i((()=>{_&&(D.onAdd(we,Se),$e())}),[_]),i((()=>{Z&&Object.keys(we||{}).length&&Se&&(D.onAdd(we,Se),$e())}),[Z,we,Se]);const $e=()=>{Ae({type:"reset",data:{}})},Me=()=>L&&Se>L?e.jsx(h,{tagText:`You can only select ${L} products`,type:"negative"}):z&&Se>z?e.jsx(h,{tagText:`You can only select ${z} products`,type:"negative"}):Se>0?e.jsx(a,{onClick:()=>{ue(X?O.RearrangeProducts:O.SelectedProducts)},buttonText:L?`${Se}/${L} products selected`:`${Se} products selected`,buttonType:["rearrange","view"].includes(de)?"tertiaryGray":"tertiary",disabled:["rearrange","view"].includes(de)}):e.jsx(a,{disabled:!0,buttonText:L?`${Se}/${L} products selected`:`${Se} products selected`,buttonType:"tertiaryGray"}),He=e=>be?"Loading...":de===O.RearrangeProducts?null!=e?e:"Done":null!=e?e:"Add",We=e.jsxs(v,Object.assign({style:null!=te?te:{}},{children:[D.postHeader&&e.jsx("div",Object.assign({style:{padding:"0 24px"}},{children:D.postHeader})),!D.hideGlobalSearch&&e.jsx(e.Fragment,{children:("collections"===de||"searchProducts"===de)&&e.jsx("div",Object.assign({style:{padding:Y?"8px 16px":"12px 24px",borderBottom:"1px solid #E0E0E0"}},{children:e.jsx(d,{placeholder:"Search using ID, Name or SKU ID",noKeyDownChange:!0,noErrorHint:!0,rightIcon:{icon:()=>Fe?e.jsx(p,{size:"small",color:n.content.primary}):e.jsx(o,{})},id:"listInput",height:"24px",type:"text",value:ve,onChangeText:e=>{e.length&&e.trim().length?Ie(e):Ie("")}})}))}),e.jsxs(I,Object.assign({ref:Be,screenName:de},{children:["collections"===de&&e.jsx(m,{customCollectionRestriction:D.customCollectionRestriction,dataLoading:Oe,collections:le,selectedCollectionsDispatch:Ae,setCollectionId:ge,setSelectedCollectionId:je,setScreen:ue,selectedCollections:we,collectionFetcher:D.collectionFetcher,storeId:R,appType:ne,collectionsDispatch:ae,setSaveDisabled:fe,pagingControls:{curPage:ye,setCurPage:xe},hideCollectionCheckbox:V,renderWithoutModal:Y,pickerType:q,scrollContainerRef:Be}),"products"===de&&me&&e.jsx(f.Provider,Object.assign({value:me},{children:e.jsx(C,{hideInCollectionSearch:D.hideInCollectionSearch,customCollectionRestriction:D.customCollectionRestriction,productFetcher:D.productFetcher,setScreen:ue,storeId:R,appType:ne,data:le[me],collectionsDispatch:ae,selectedCollectionsDispatch:Ae,selectedData:we,setSaveDisabled:fe,searchInCollectionFetcher:D.searchInCollectionFetcher,hideProductCheckbox:$,outOfStockAction:M,hideVariantCheckbox:H,selectProductsFromCustomCollection:W,renderWithoutModal:Y,pickerType:q,hideProductVariants:J,fbStatusFetcher:D.fbStatusFetcher,onProductDetailClick:e=>{Le(!0),Ve(e)},showProductDetailInfoIcon:ee,scrollContainerRef:Be})})),"view"===de&&e.jsx(k,{selectedCollections:we||{},selectedCollectionsDispatch:Ae,setScreen:ue,collections:le,hideProductVariants:J,outOfStockAction:M,storeId:R,appType:ne,fbStatusFetcher:D.fbStatusFetcher}),"rearrange"===de&&e.jsx(j,{selectedCollections:we||{},selectedCollectionsDispatch:Ae,setScreen:ue,outOfStockAction:M,rearrangeViewType:"grid"===pe?"list":"grid",scrollContainerRef:Be,storeId:R,appType:ne,fbStatusFetcher:D.fbStatusFetcher}),"searchProducts"===de&&e.jsx(S,{customCollectionRestriction:D.customCollectionRestriction,selectedCollections:we||{},searchedCollections:De||{},searchedCollectionsDispatch:Re,selectedCollectionsDispatch:Ae,setScreen:ue,collections:le,onBackPress:()=>{Ie(""),Re({type:"set",data:{collections:{},products:{}}})},pickerType:q,hideProductCheckbox:$,hideProductVariants:J,hideVariantCheckbox:H,storeId:R,appType:ne,fbStatusFetcher:D.fbStatusFetcher,setCollectionId:ge,setSelectedCollectionId:je,renderWithoutModal:Y,hideCollectionCheckbox:V,outOfStockAction:M})]}))]}));return e.jsx(e.Fragment,{children:Y?e.jsxs(e.Fragment,{children:[We,ce.renderFooter?e.jsxs(F,{children:[Me(),e.jsx(a,{buttonText:He(ce.primaryButtonText),disabled:!ce.isLoading&&(be||Se<1||L&&Se<L||!L&&z&&Se>z)||ce.primaryButtonDisabled,isLoading:ce.isLoading,onClick:()=>{D.onAdd(we,Se),$e(),ue([O.Collections,O.RearrangeProducts].includes(Q)?Q:O.Collections)}})]}):e.jsx(e.Fragment,{}),Ee&&ze?e.jsx(g,{productData:ze,outOfStockAction:M,useDynamicInfoImageSize:D.useDynamicInfoImageSize,onClose:()=>{Le(!1)}}):e.jsx(e.Fragment,{})]}):e.jsxs(u,Object.assign({zIndex:E,open:B,onClose:()=>{null==A||A(),$e()},headingTitle:K||("collections"===de||"products"===de?"Select Products":"view"===de?"Selected Products":"searchProducts"===de?"Searched Results":"rearrange"===de?"Rearrange Products":void 0),headingSubtitle:ie,footerShadow:!0,centralContainerStyles:{width:N||"600px",left:U||"auto"},headerRightCustomElement:oe?e.jsx("div",Object.assign({style:{cursor:"pointer",display:"flex"},onClick:A},{children:e.jsx(l,{width:20,height:20,color:n.content.secondary})})):e.jsx(e.Fragment,{}),footerContainerStyle:D.stickyFooter?{position:"absolute",bottom:0,left:0,width:"100%",zIndex:9,background:n.surface.standard}:void 0,primaryButton:se?(e=>Object.assign(Object.assign({},e),{disabled:!e.isLoading&&(be||Se<1||L&&Se<L||!L&&z&&Se>z)||e.disabled,onClick:()=>{D.onAdd(we,Se),$e(),ue([O.Collections,O.RearrangeProducts].includes(Q)?Q:O.Collections)}}))(se):{buttonText:He(),disabled:be||Se<1||L&&Se<L||!L&&z&&Se>z||!1,onClick:()=>{D.onAdd(we,Se),$e()}},secondaryButton:re?(e=>Object.assign(Object.assign({},e),{disabled:be||Se<1||L&&Se<L||!L&&z&&Se>z||!1,onClick:()=>{const e=T(we,le,De);D.onAdd(e,Se,!0)}}))(re):void 0,wrapperStyle:D.stickyFooter?{height:"calc(100vh - 168px)"}:void 0,footerLeftCustomElement:G?e.jsx(e.Fragment,{}):Me(),hideCrossButton:Ee||oe},{children:[We,Ee&&ze?e.jsx(g,{productData:ze,useDynamicInfoImageSize:D.useDynamicInfoImageSize,outOfStockAction:M,onClose:()=>{Le(!1)}}):e.jsx(e.Fragment,{})]}))})};export{D as ProductPickerModal};
@@ -1 +1 @@
1
- import{j as e}from"../../../node_modules/react/jsx-runtime.js";import"../../../node_modules/@bikdotai/bik-models/growth/index.js";import t from"../../../assets/icons/arrow_back.svg.js";import l from"../../../assets/icons/chevronLeft.svg.js";import o from"../../../assets/icons/chevronRight.svg.js";import i from"../../../assets/icons/PlusIcon.js";import{cloneDeep as n}from"lodash";import{useState as r,useEffect as s}from"react";import{Button as a}from"../../button/Button.js";import{IconButton as d}from"../../icon-button/IconButton.js";import{ProductPickerModal as c}from"../../product-picker-v2/modal.js";import{ScreenName as p}from"../../product-picker-v2/type.js";import{Badge as u}from"../Badge/index.js";import{useTemplateModalContext as m}from"../context/templateModalContext.js";import v from"./EditWhatsAppTemplateV2.js";import{ProductBox as h}from"./ProductBox.js";import"../../template-preview/TemplatePreview.js";import"../../template-preview/WhatsApp/WhatsAppLikePreview.js";import"../../template-preview/WhatsApp/WhatsAppLikePreviewV2.js";import{COLORS as g}from"../../../constants/Theme.js";import"../../curtain/CurtainHelper.js";import"../../variable-picker-v3/model.js";import"../../template-preview/models/TemplateMeta.js";import{POD as j}from"../../template-preview/models/WhatsAppTemplate.js";import"../../template-preview/models/Channels.js";import{isRCSChannel as f}from"../../template-preview/helpers/templateMiscHelper.js";import{TitleMedium as x,TitleRegular as y,BodySecondary as b,BodyCaption as C}from"../../TypographyStyle.js";import{__exports as I}from"../../../_virtual/index.js";const w=w=>{let{template:k,whatsappSpecificPickerMeta:O,showVariableModal:P,variableListForImage:T,discountCode:S,setDiscountCode:L}=w;var B,E,A,F,M,V,_,D;const{selectedCarouselIndex:R,setTemplate:W,pickerConf:$,isProductCarouselType:q,pod:N,cardCount:z,carouselProducts:G,setCarouselProducts:H,isError:K,cardImages:J,disableEditVariable:Q,onDeleteSelectedProducts:U,setSelectedCarouselIndex:X,setVariableCallback:Y,setShowVariablePicker:Z,sliderRef:ee}=m(),[te,le]=r(f(null==k?void 0:k.channel)?"Carousel Cards":-1==R?"First Message (Step 1/2)":q?"Product Carousel "+((null===(E=null===(B=null==k?void 0:k.mapping)||void 0===B?void 0:B.body)||void 0===E?void 0:E.length)?"(Step 2/2)":""):"Carousel Cards "+((null===(F=null===(A=null==k?void 0:k.mapping)||void 0===A?void 0:A.body)||void 0===F?void 0:F.length)?"(Step 2/2)":"")),[oe,ie]=r(!1),[ne,re]=r(!1),se=R===(null!=z?z:-1)-1,ae=(null!=R?R:-1)<1;s((()=>{var e,t,l,o;le(f(null==k?void 0:k.channel)?"Carousel Cards":-1==R?"First Message (Step 1/2)":q?"Product Carousel "+((null===(t=null===(e=null==k?void 0:k.mapping)||void 0===e?void 0:e.body)||void 0===t?void 0:t.length)?"(Step 2/2)":""):"Carousel Cards "+((null===(o=null===(l=null==k?void 0:k.mapping)||void 0===l?void 0:l.body)||void 0===o?void 0:o.length)?"(Step 2/2)":""))}),[R]);const de=e=>{null==H||H([{name:"variable",productName:e.actualValue}])};return s((()=>{-1===R&&f(null==k?void 0:k.channel)&&(null==X||X(0))}),[R,null==k?void 0:k.channel]),e.jsxs("div",Object.assign({style:{display:"flex",flexDirection:"column",gap:"16px"}},{children:[e.jsxs("div",Object.assign({style:{display:"flex",flexDirection:"row",alignItems:"center"}},{children:[!f(null==k?void 0:k.channel)&&null!=R&&R>=0&&!!(null===(V=null===(M=null==k?void 0:k.mapping)||void 0===M?void 0:M.body)||void 0===V?void 0:V.length)&&e.jsx(d,{Icon:t,onClick:()=>{null==X||X(-1)}}),e.jsx(x,Object.assign({style:{marginLeft:10}},{children:te}))]})),q&&(null!==(_=null==G?void 0:G.length)&&void 0!==_?_:0)>0&&null!=R&&R>=0&&e.jsxs("div",Object.assign({style:{display:"flex",rowGap:8,marginBottom:16,marginLeft:10,marginRight:10,flexDirection:"column"}},{children:[e.jsx(h,{editItem:()=>{1===(null==G?void 0:G.length)&&"variable"===G[0].name?(Y((()=>de)),Z(!0)):ie(!oe)},cardBody:1===(null==G?void 0:G.length)&&"variable"===G[0].name?`${G[0].productName}`:`${null==G?void 0:G.length} Products Selected`,hideIcon:1===(null==G?void 0:G.length)&&"variable"===G[0].name,deleteItem:()=>{var e;if(1===(null==G?void 0:G.length)&&"variable"===G[0].name)return void(null==H||H([]));const t=n(Object.assign({},k));t&&(J&&J.length>0?null==J||J.forEach(((e,l)=>{var o;t.components[1].cards[l].components[0].example.header_handle=[null!==(o=J[l])&&void 0!==o?o:"https://res.cloudinary.com/drqhot9ot/image/upload/v1708753454/fake-product.png"]})):null===(e=null==t?void 0:t.components[1].cards)||void 0===e||e.forEach(((e,l)=>{t.components[1].cards[l].components[0].example.header_handle=["https://res.cloudinary.com/drqhot9ot/image/upload/v1708753454/fake-product.png"]})),null==W||W(t)),null==H||H([]),null==U||U()}}),G&&(null==G?void 0:G.length)>0&&"variable"!=G[0].name&&e.jsx(a,{disabled:(null!==(D=null==G?void 0:G.length)&&void 0!==D?D:0)<=1,style:{alignSelf:"flex-end"},onClick:()=>{re(!0),ie(!0)},buttonText:"Rearrange Products",buttonType:"tertiary"})]})),!Q&&q&&0===(null==G?void 0:G.length)&&null!=R&&R>=0&&e.jsxs(e.Fragment,{children:[e.jsxs("div",Object.assign({style:{marginLeft:12}},{children:[e.jsx(y,{children:"Product(s)"}),e.jsx(b,{children:`Select ${null!=z?z:1} products`})]})),e.jsxs("div",Object.assign({style:{marginTop:16,marginBottom:16,marginLeft:K?16:12,marginRight:K?16:12,flexDirection:"column",display:"flex",alignItems:"center"}},{children:[e.jsx(a,{matchParentWidth:!0,style:{flex:1,display:"flex",width:"100%",marginBottom:12,border:K?`2px dashed ${g.content.negative}`:void 0},size:"medium",buttonText:"Add Product(s)",buttonType:K?"tertiaryGray":"dashBold",LeadingIcon:()=>e.jsx("div",Object.assign({style:{display:"flex",width:18,height:18}},{children:e.jsx(i,{width:18,height:18,color:g.content.secondary})})),onClick:e=>{ie(!0)}}),N===j.CHATBOT&&e.jsxs(e.Fragment,{children:[e.jsxs("div",Object.assign({style:{display:"flex",flex:1,alignItems:"center",justifyContent:"space-between",flexDirection:"row",width:"100%"}},{children:[e.jsx("div",{style:{width:"100%",height:1,backgroundColor:"#E0E0E0",marginRight:8}}),e.jsx(C,Object.assign({style:{color:"#616161",overflow:"unset"}},{children:"OR"})),e.jsx("div",{style:{width:"100%",height:1,backgroundColor:"#E0E0E0",marginLeft:8}})]})),e.jsx(a,{matchParentWidth:!0,style:{flex:1,display:"flex",marginTop:12,width:"100%",border:K?`2px dashed ${g.content.negative}`:void 0},size:"medium",buttonText:"Add Product(s) Variable",buttonType:K?"tertiaryGray":"dashBold",LeadingIcon:()=>e.jsx("div",Object.assign({style:{display:"flex"}},{children:e.jsx(i,{width:18,height:18,color:g.content.secondary})})),onClick:e=>{Y((()=>de)),Z(!0)}})]})]})),K&&e.jsx("div",Object.assign({style:{marginLeft:10,marginBottom:16}},{children:e.jsx(u,{padding:"8px",errorText:"Please add products"})}))]}),!q&&(null!=R?R:-1)>-1&&e.jsxs("div",Object.assign({style:{display:"flex",background:g.surface.hovered,alignItems:"center"}},{children:[e.jsx(d,{Icon:l,disabled:ae,width:8,height:14,svgStyle:ae?{}:{color:g.content.secondary},onClick:()=>{var e;null===(e=null==ee?void 0:ee.current)||void 0===e||e.slickPrev(),(null!=R?R:-1)<1||null==X||X((e=>e-1))}}),e.jsx(y,Object.assign({style:{flex:1,display:"flex",justifyContent:"center"},color:g.content.secondary},{children:`Card ${(null!=R?R:0)+1}/${z}`})),e.jsx(d,{Icon:o,width:8,height:14,disabled:se,svgStyle:se?{}:{color:g.content.secondary},onClick:()=>{var e;null===(e=null==ee?void 0:ee.current)||void 0===e||e.slickNext(),(null!=R?R:-1)>=(null!=z?z:-1)-1||null==X||X((e=>e+1))}})]})),e.jsx(v,{whatsappSpecificPickerMeta:O,template:k,onTemplateChange:e=>{null==W||W(e)},showVariableModal:P,variableListForImage:T,discountCode:S,setDiscountCode:L}),oe&&$&&e.jsx(c,{zIndex:200,startupScreen:ne?p.RearrangeProducts:p.Collections,rearrangeEnabled:!0,storeId:$.storeId,selectedItems:(e=>{if(e.length>0){const t={};for(const l of e){const e=null==l?void 0:l.collectionId,o=l.productId,i=l.variantId;e in t||(t[e]={products:{},name:"",image:"",isSmartCollection:!1}),o in t[e].products||(t[e].products[o]={variants:{},name:(null==l?void 0:l.productName)||"",image:(null==l?void 0:l.productImage)||""}),t[e].products[o].variants[i]={name:(null==l?void 0:l.name)||"",price:"",image:(null==l?void 0:l.image)||"",quantity:l.quantity||0,displayOrder:l.displayOrder}}return t}return{}})(null!=G?G:[]),collectionFetcher:$.fetchCollections,productFetcher:$.fetchProducts,onAdd:(e,t)=>{var l,o,i,r,s,a;re(!1);const d=[];delete e.isCustom;for(const t of Object.keys(e)){const n=e[t].products;if(void 0!==n&&Object.keys(n).length)for(const e of Object.keys(n)){const c=n[e].variants;if(void 0!==c&&Object.keys(c).length)for(const p of Object.keys(c)){const{name:u,image:m,quantity:v,displayOrder:h}=c[p],g={name:u,image:null!==(o=null!=m?m:null===(l=n[e])||void 0===l?void 0:l.image)&&void 0!==o?o:"",quantity:v,variantId:p,productId:e,displayOrder:h,collectionId:t,productName:null!==(r=null===(i=n[e])||void 0===i?void 0:i.name)&&void 0!==r?r:"",productImage:null!==(a=null===(s=n[e])||void 0===s?void 0:s.image)&&void 0!==a?a:""};d.push(g)}}}const c=d.sort(((e,t)=>e.displayOrder-t.displayOrder)),p=d.map((e=>e.image)),u=n(Object.assign({},k));u&&(p.forEach(((e,t)=>{var l;u.components[1].cards[t].components[0].example.header_handle=e?[e]:[null!==(l=null==J?void 0:J[t])&&void 0!==l?l:""]})),null==W||W(u)),null==H||H(c),ie(!1)},searchInCollectionFetcher:$.searchInCollection,searchFetcher:$.searchProducts,visible:oe,onClose:()=>{ie(!1)},exactLimit:null!=z?z:1,appType:$.appType||I.ApplicationType.BIK})]}))};export{w as default};
1
+ import{j as e}from"../../../node_modules/react/jsx-runtime.js";import{ApplicationType as t}from"@bikdotai/bik-models/growth";import l from"../../../assets/icons/arrow_back.svg.js";import o from"../../../assets/icons/chevronLeft.svg.js";import n from"../../../assets/icons/chevronRight.svg.js";import i from"../../../assets/icons/PlusIcon.js";import{cloneDeep as r}from"lodash";import{useState as s,useEffect as a}from"react";import{Button as d}from"../../button/Button.js";import{IconButton as c}from"../../icon-button/IconButton.js";import{ProductPickerModal as u}from"../../product-picker-v2/modal.js";import{ScreenName as p}from"../../product-picker-v2/type.js";import{Badge as m}from"../Badge/index.js";import{useTemplateModalContext as v}from"../context/templateModalContext.js";import h from"./EditWhatsAppTemplateV2.js";import{ProductBox as g}from"./ProductBox.js";import"../../template-preview/TemplatePreview.js";import"../../template-preview/WhatsApp/WhatsAppLikePreview.js";import"../../template-preview/WhatsApp/WhatsAppLikePreviewV2.js";import{COLORS as j}from"../../../constants/Theme.js";import"../../curtain/CurtainHelper.js";import"../../variable-picker-v3/model.js";import"../../template-preview/models/TemplateMeta.js";import{POD as f}from"../../template-preview/models/WhatsAppTemplate.js";import"../../template-preview/models/Channels.js";import{isRCSChannel as y}from"../../template-preview/helpers/templateMiscHelper.js";import{TitleMedium as x,TitleRegular as b,BodySecondary as C,BodyCaption as I}from"../../TypographyStyle.js";const w=w=>{let{template:k,whatsappSpecificPickerMeta:O,showVariableModal:P,variableListForImage:T,discountCode:S,setDiscountCode:L}=w;var B,E,A,F,M,V,D,R;const{selectedCarouselIndex:W,setTemplate:$,pickerConf:q,isProductCarouselType:N,pod:_,cardCount:z,carouselProducts:G,setCarouselProducts:H,isError:K,cardImages:J,disableEditVariable:Q,onDeleteSelectedProducts:U,setSelectedCarouselIndex:X,setVariableCallback:Y,setShowVariablePicker:Z,sliderRef:ee}=v(),[te,le]=s(y(null==k?void 0:k.channel)?"Carousel Cards":-1==W?"First Message (Step 1/2)":N?"Product Carousel "+((null===(E=null===(B=null==k?void 0:k.mapping)||void 0===B?void 0:B.body)||void 0===E?void 0:E.length)?"(Step 2/2)":""):"Carousel Cards "+((null===(F=null===(A=null==k?void 0:k.mapping)||void 0===A?void 0:A.body)||void 0===F?void 0:F.length)?"(Step 2/2)":"")),[oe,ne]=s(!1),[ie,re]=s(!1),se=W===(null!=z?z:-1)-1,ae=(null!=W?W:-1)<1;a((()=>{var e,t,l,o;le(y(null==k?void 0:k.channel)?"Carousel Cards":-1==W?"First Message (Step 1/2)":N?"Product Carousel "+((null===(t=null===(e=null==k?void 0:k.mapping)||void 0===e?void 0:e.body)||void 0===t?void 0:t.length)?"(Step 2/2)":""):"Carousel Cards "+((null===(o=null===(l=null==k?void 0:k.mapping)||void 0===l?void 0:l.body)||void 0===o?void 0:o.length)?"(Step 2/2)":""))}),[W]);const de=e=>{null==H||H([{name:"variable",productName:e.actualValue}])};return a((()=>{-1===W&&y(null==k?void 0:k.channel)&&(null==X||X(0))}),[W,null==k?void 0:k.channel]),e.jsxs("div",Object.assign({style:{display:"flex",flexDirection:"column",gap:"16px"}},{children:[e.jsxs("div",Object.assign({style:{display:"flex",flexDirection:"row",alignItems:"center"}},{children:[!y(null==k?void 0:k.channel)&&null!=W&&W>=0&&!!(null===(V=null===(M=null==k?void 0:k.mapping)||void 0===M?void 0:M.body)||void 0===V?void 0:V.length)&&e.jsx(c,{Icon:l,onClick:()=>{null==X||X(-1)}}),e.jsx(x,Object.assign({style:{marginLeft:10}},{children:te}))]})),N&&(null!==(D=null==G?void 0:G.length)&&void 0!==D?D:0)>0&&null!=W&&W>=0&&e.jsxs("div",Object.assign({style:{display:"flex",rowGap:8,marginBottom:16,marginLeft:10,marginRight:10,flexDirection:"column"}},{children:[e.jsx(g,{editItem:()=>{1===(null==G?void 0:G.length)&&"variable"===G[0].name?(Y((()=>de)),Z(!0)):ne(!oe)},cardBody:1===(null==G?void 0:G.length)&&"variable"===G[0].name?`${G[0].productName}`:`${null==G?void 0:G.length} Products Selected`,hideIcon:1===(null==G?void 0:G.length)&&"variable"===G[0].name,deleteItem:()=>{var e;if(1===(null==G?void 0:G.length)&&"variable"===G[0].name)return void(null==H||H([]));const t=r(Object.assign({},k));t&&(J&&J.length>0?null==J||J.forEach(((e,l)=>{var o;t.components[1].cards[l].components[0].example.header_handle=[null!==(o=J[l])&&void 0!==o?o:"https://res.cloudinary.com/drqhot9ot/image/upload/v1708753454/fake-product.png"]})):null===(e=null==t?void 0:t.components[1].cards)||void 0===e||e.forEach(((e,l)=>{t.components[1].cards[l].components[0].example.header_handle=["https://res.cloudinary.com/drqhot9ot/image/upload/v1708753454/fake-product.png"]})),null==$||$(t)),null==H||H([]),null==U||U()}}),G&&(null==G?void 0:G.length)>0&&"variable"!=G[0].name&&e.jsx(d,{disabled:(null!==(R=null==G?void 0:G.length)&&void 0!==R?R:0)<=1,style:{alignSelf:"flex-end"},onClick:()=>{re(!0),ne(!0)},buttonText:"Rearrange Products",buttonType:"tertiary"})]})),!Q&&N&&0===(null==G?void 0:G.length)&&null!=W&&W>=0&&e.jsxs(e.Fragment,{children:[e.jsxs("div",Object.assign({style:{marginLeft:12}},{children:[e.jsx(b,{children:"Product(s)"}),e.jsx(C,{children:`Select ${null!=z?z:1} products`})]})),e.jsxs("div",Object.assign({style:{marginTop:16,marginBottom:16,marginLeft:K?16:12,marginRight:K?16:12,flexDirection:"column",display:"flex",alignItems:"center"}},{children:[e.jsx(d,{matchParentWidth:!0,style:{flex:1,display:"flex",width:"100%",marginBottom:12,border:K?`2px dashed ${j.content.negative}`:void 0},size:"medium",buttonText:"Add Product(s)",buttonType:K?"tertiaryGray":"dashBold",LeadingIcon:()=>e.jsx("div",Object.assign({style:{display:"flex",width:18,height:18}},{children:e.jsx(i,{width:18,height:18,color:j.content.secondary})})),onClick:e=>{ne(!0)}}),_===f.CHATBOT&&e.jsxs(e.Fragment,{children:[e.jsxs("div",Object.assign({style:{display:"flex",flex:1,alignItems:"center",justifyContent:"space-between",flexDirection:"row",width:"100%"}},{children:[e.jsx("div",{style:{width:"100%",height:1,backgroundColor:"#E0E0E0",marginRight:8}}),e.jsx(I,Object.assign({style:{color:"#616161",overflow:"unset"}},{children:"OR"})),e.jsx("div",{style:{width:"100%",height:1,backgroundColor:"#E0E0E0",marginLeft:8}})]})),e.jsx(d,{matchParentWidth:!0,style:{flex:1,display:"flex",marginTop:12,width:"100%",border:K?`2px dashed ${j.content.negative}`:void 0},size:"medium",buttonText:"Add Product(s) Variable",buttonType:K?"tertiaryGray":"dashBold",LeadingIcon:()=>e.jsx("div",Object.assign({style:{display:"flex"}},{children:e.jsx(i,{width:18,height:18,color:j.content.secondary})})),onClick:e=>{Y((()=>de)),Z(!0)}})]})]})),K&&e.jsx("div",Object.assign({style:{marginLeft:10,marginBottom:16}},{children:e.jsx(m,{padding:"8px",errorText:"Please add products"})}))]}),!N&&(null!=W?W:-1)>-1&&e.jsxs("div",Object.assign({style:{display:"flex",background:j.surface.hovered,alignItems:"center"}},{children:[e.jsx(c,{Icon:o,disabled:ae,width:8,height:14,svgStyle:ae?{}:{color:j.content.secondary},onClick:()=>{var e;null===(e=null==ee?void 0:ee.current)||void 0===e||e.slickPrev(),(null!=W?W:-1)<1||null==X||X((e=>e-1))}}),e.jsx(b,Object.assign({style:{flex:1,display:"flex",justifyContent:"center"},color:j.content.secondary},{children:`Card ${(null!=W?W:0)+1}/${z}`})),e.jsx(c,{Icon:n,width:8,height:14,disabled:se,svgStyle:se?{}:{color:j.content.secondary},onClick:()=>{var e;null===(e=null==ee?void 0:ee.current)||void 0===e||e.slickNext(),(null!=W?W:-1)>=(null!=z?z:-1)-1||null==X||X((e=>e+1))}})]})),e.jsx(h,{whatsappSpecificPickerMeta:O,template:k,onTemplateChange:e=>{null==$||$(e)},showVariableModal:P,variableListForImage:T,discountCode:S,setDiscountCode:L}),oe&&q&&e.jsx(u,{zIndex:200,startupScreen:ie?p.RearrangeProducts:p.Collections,rearrangeEnabled:!0,storeId:q.storeId,selectedItems:(e=>{if(e.length>0){const t={};for(const l of e){const e=null==l?void 0:l.collectionId,o=l.productId,n=l.variantId;e in t||(t[e]={products:{},name:"",image:"",isSmartCollection:!1}),o in t[e].products||(t[e].products[o]={variants:{},name:(null==l?void 0:l.productName)||"",image:(null==l?void 0:l.productImage)||""}),t[e].products[o].variants[n]={name:(null==l?void 0:l.name)||"",price:"",image:(null==l?void 0:l.image)||"",quantity:l.quantity||0,displayOrder:l.displayOrder}}return t}return{}})(null!=G?G:[]),collectionFetcher:q.fetchCollections,productFetcher:q.fetchProducts,onAdd:(e,t)=>{var l,o,n,i,s,a;re(!1);const d=[];delete e.isCustom;for(const t of Object.keys(e)){const r=e[t].products;if(void 0!==r&&Object.keys(r).length)for(const e of Object.keys(r)){const c=r[e].variants;if(void 0!==c&&Object.keys(c).length)for(const u of Object.keys(c)){const{name:p,image:m,quantity:v,displayOrder:h}=c[u],g={name:p,image:null!==(o=null!=m?m:null===(l=r[e])||void 0===l?void 0:l.image)&&void 0!==o?o:"",quantity:v,variantId:u,productId:e,displayOrder:h,collectionId:t,productName:null!==(i=null===(n=r[e])||void 0===n?void 0:n.name)&&void 0!==i?i:"",productImage:null!==(a=null===(s=r[e])||void 0===s?void 0:s.image)&&void 0!==a?a:""};d.push(g)}}}const c=d.sort(((e,t)=>e.displayOrder-t.displayOrder)),u=d.map((e=>e.image)),p=r(Object.assign({},k));p&&(u.forEach(((e,t)=>{var l;p.components[1].cards[t].components[0].example.header_handle=e?[e]:[null!==(l=null==J?void 0:J[t])&&void 0!==l?l:""]})),null==$||$(p)),null==H||H(c),ne(!1)},searchInCollectionFetcher:q.searchInCollection,searchFetcher:q.searchProducts,visible:oe,onClose:()=>{ne(!1)},exactLimit:null!=z?z:1,appType:q.appType||t.BIK})]}))};export{w as default};
@@ -1 +1 @@
1
- import{j as e}from"../../node_modules/react/jsx-runtime.js";import"../../node_modules/@bikdotai/bik-models/growth/index.js";import s from"../../assets/icons/cross.svg.js";import t from"../../assets/icons/info.svg.js";import{format as n}from"date-fns";import{useState as o,useEffect as i}from"react";import{COLORS as r}from"../../constants/Theme.js";import{Avatar as a}from"../avatar/Avatar.js";import{SIZE as l,AVATAR_TYPES as c,AVATAR_BACKGROUND as d}from"../avatar/AvatarHelper.js";import{Button as p}from"../button/Button.js";import{StateComponent as m,StateInterface as y}from"../states/StateComponent.js";import"../../_virtual/_tslib.js";import{TitleRegular as j,BodySecondary as h,Caption as f}from"../TypographyStyle.js";import{UnsatisfactoryCountIntentWiseModal as g}from"./UnsatisfactoryCountIntentWiseModal.js";import{IncorrectRepliesStyle as u}from"./UnsatisfactoryResponseList.style.js";import{__exports as x}from"../../_virtual/index.js";const v=v=>{const{storeId:b,appType:I,incorrectMessages:w,onIncorrectMessageBubbleClick:C,setShowIncorrectReplies:T,ChecklistType:U,IntentWiseUnsatisfactoryResponse:M,IntentHeaderTitle:O,redirectToUnsatisfactoryResponse:R,fetchUnsatisfactoryResponseCountIntentWise:k,fetchUnsatisfactoryResponseCount:A}=v,[N,S]=o(""),[_,W]=o((null==w?void 0:w.length)>0),[L,D]=o(!1);return i((()=>{!_&&A&&A().then((e=>{e>0&&W(!0),0===e&&T(!1)}))}),[]),e.jsx("div",Object.assign({style:{overflow:"scroll",height:"100%"}},{children:e.jsxs(u,{children:[I==x.ApplicationType.MANIFEST&&e.jsxs("div",Object.assign({style:{display:"flex",flexDirection:"column",gap:"8px"}},{children:[e.jsxs("div",Object.assign({style:{display:"flex",justifyContent:"space-between",alignItems:"center"}},{children:[e.jsx(j,{children:"Unsatisfactory responses"}),e.jsx("div",Object.assign({style:{cursor:"pointer"},onClick:()=>T(!1)},{children:e.jsx(s,{height:16,width:16,color:r.content.primary})}))]})),e.jsx(h,Object.assign({style:{color:r.content.secondary}},{children:"Spot unsatisfactory replies, dive deeper, and enhance with relevant data for improved responses."}))]})),!(null==w?void 0:w.length)&&e.jsx("div",Object.assign({style:{display:"flex",justifyContent:"center",alignItems:"center",height:"100%"}},{children:e.jsx(m,{states:y.WARNING,heading:"No unsatisfactory responses",subline:"As of now, all responses are correct",isButtonEnabled:!1,width:0,size:l.SMALL,icon:e.jsx(a,{type:c.ICON,size:l.MEDIUM,background:d.LIGHT,icon:()=>e.jsx(t,{width:16,height:16,color:r.content.warning})})})})),!!(null==w?void 0:w.length)&&e.jsxs(e.Fragment,{children:[I==x.ApplicationType.MANIFEST&&e.jsx("div",Object.assign({style:{display:"flex",width:"100%",justifyContent:(null==w?void 0:w.length)?"flex-start":"center"}},{children:e.jsx(p,{buttonText:"Fix all unsatisfactory responses",buttonType:"tertiary",size:"small",onClick:()=>{D(!0)},disabled:!_})})),e.jsx(g,{storeId:b,setShowUnsatisfactoryResponseModal:D,showUnsatisfactoryResponseModal:L,ChecklistType:U,UnsatisfactoryResponseIntentList:M,IntentHeaderTitle:O,fetchUnsatisfactoryResponseCountIntentWise:k,viewIntentWiseUnsatisfactoryResponse:R}),w&&(null==w?void 0:w.length)>0&&e.jsx("div",Object.assign({className:"wrapper"},{children:w.map(((s,t)=>e.jsxs("div",Object.assign({className:"bubble",onClick:()=>{C(s.messageId),S(s.messageId)},style:N===s.messageId?{backgroundColor:r.surface.hovered}:{}},{children:[e.jsx(h,Object.assign({style:{color:r.content.primary}},{children:s.message})),e.jsx("div",{children:e.jsxs(f,Object.assign({style:{color:r.content.secondary}},{children:[n(new Date(null==s?void 0:s.date),"hh:mm a")," |"," ",n(new Date(null==s?void 0:s.date),"dd/MM/yyyy")]}))})]}),s.messageId)))}))]})]})}))};export{v as UnsatisfactoryResponseList};
1
+ import{j as e}from"../../node_modules/react/jsx-runtime.js";import{ApplicationType as s}from"@bikdotai/bik-models/growth";import t from"../../assets/icons/cross.svg.js";import n from"../../assets/icons/info.svg.js";import{format as o}from"date-fns";import{useState as i,useEffect as r}from"react";import{COLORS as a}from"../../constants/Theme.js";import{Avatar as l}from"../avatar/Avatar.js";import{SIZE as c,AVATAR_TYPES as d,AVATAR_BACKGROUND as p}from"../avatar/AvatarHelper.js";import{Button as m}from"../button/Button.js";import{StateComponent as h,StateInterface as y}from"../states/StateComponent.js";import"../../_virtual/_tslib.js";import{TitleRegular as j,BodySecondary as f,Caption as g}from"../TypographyStyle.js";import{UnsatisfactoryCountIntentWiseModal as u}from"./UnsatisfactoryCountIntentWiseModal.js";import{IncorrectRepliesStyle as x}from"./UnsatisfactoryResponseList.style.js";const v=v=>{const{storeId:b,appType:I,incorrectMessages:w,onIncorrectMessageBubbleClick:C,setShowIncorrectReplies:T,ChecklistType:U,IntentWiseUnsatisfactoryResponse:M,IntentHeaderTitle:O,redirectToUnsatisfactoryResponse:R,fetchUnsatisfactoryResponseCountIntentWise:k,fetchUnsatisfactoryResponseCount:N}=v,[S,A]=i(""),[W,L]=i((null==w?void 0:w.length)>0),[D,E]=i(!1);return r((()=>{!W&&N&&N().then((e=>{e>0&&L(!0),0===e&&T(!1)}))}),[]),e.jsx("div",Object.assign({style:{overflow:"scroll",height:"100%"}},{children:e.jsxs(x,{children:[I==s.MANIFEST&&e.jsxs("div",Object.assign({style:{display:"flex",flexDirection:"column",gap:"8px"}},{children:[e.jsxs("div",Object.assign({style:{display:"flex",justifyContent:"space-between",alignItems:"center"}},{children:[e.jsx(j,{children:"Unsatisfactory responses"}),e.jsx("div",Object.assign({style:{cursor:"pointer"},onClick:()=>T(!1)},{children:e.jsx(t,{height:16,width:16,color:a.content.primary})}))]})),e.jsx(f,Object.assign({style:{color:a.content.secondary}},{children:"Spot unsatisfactory replies, dive deeper, and enhance with relevant data for improved responses."}))]})),!(null==w?void 0:w.length)&&e.jsx("div",Object.assign({style:{display:"flex",justifyContent:"center",alignItems:"center",height:"100%"}},{children:e.jsx(h,{states:y.WARNING,heading:"No unsatisfactory responses",subline:"As of now, all responses are correct",isButtonEnabled:!1,width:0,size:c.SMALL,icon:e.jsx(l,{type:d.ICON,size:c.MEDIUM,background:p.LIGHT,icon:()=>e.jsx(n,{width:16,height:16,color:a.content.warning})})})})),!!(null==w?void 0:w.length)&&e.jsxs(e.Fragment,{children:[I==s.MANIFEST&&e.jsx("div",Object.assign({style:{display:"flex",width:"100%",justifyContent:(null==w?void 0:w.length)?"flex-start":"center"}},{children:e.jsx(m,{buttonText:"Fix all unsatisfactory responses",buttonType:"tertiary",size:"small",onClick:()=>{E(!0)},disabled:!W})})),e.jsx(u,{storeId:b,setShowUnsatisfactoryResponseModal:E,showUnsatisfactoryResponseModal:D,ChecklistType:U,UnsatisfactoryResponseIntentList:M,IntentHeaderTitle:O,fetchUnsatisfactoryResponseCountIntentWise:k,viewIntentWiseUnsatisfactoryResponse:R}),w&&(null==w?void 0:w.length)>0&&e.jsx("div",Object.assign({className:"wrapper"},{children:w.map(((s,t)=>e.jsxs("div",Object.assign({className:"bubble",onClick:()=>{C(s.messageId),A(s.messageId)},style:S===s.messageId?{backgroundColor:a.surface.hovered}:{}},{children:[e.jsx(f,Object.assign({style:{color:a.content.primary}},{children:s.message})),e.jsx("div",{children:e.jsxs(g,Object.assign({style:{color:a.content.secondary}},{children:[o(new Date(null==s?void 0:s.date),"hh:mm a")," |"," ",o(new Date(null==s?void 0:s.date),"dd/MM/yyyy")]}))})]}),s.messageId)))}))]})]})}))};export{v as UnsatisfactoryResponseList};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bikdotai/bik-component-library",
3
- "version": "0.0.693-beta.0",
3
+ "version": "0.0.693-beta.1",
4
4
  "description": "Bik Component Library",
5
5
  "repository": {
6
6
  "type": "git",
@@ -1 +0,0 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});exports.__exports={};
@@ -1 +0,0 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});exports.__exports={};
@@ -1 +0,0 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});exports.__exports={};
@@ -1 +0,0 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});exports.__exports={};
@@ -1 +0,0 @@
1
- "use strict";var e=require("../../../../_virtual/_commonjsHelpers.js"),r=require("../../../../_virtual/index.js");require("./models/store.js"),require("./models/billing.js"),require("./models/bik-store.js");var o,t,i,s=require("../../../../_virtual/store.js"),l=require("../../../../_virtual/billing.js"),n=require("../../../../_virtual/bik-store.js");o=r.__exports,t=e.commonjsGlobal&&e.commonjsGlobal.__createBinding||(Object.create?function(e,r,o,t){void 0===t&&(t=o);var i=Object.getOwnPropertyDescriptor(r,o);i&&!("get"in i?!r.__esModule:i.writable||i.configurable)||(i={enumerable:!0,get:function(){return r[o]}}),Object.defineProperty(e,t,i)}:function(e,r,o,t){void 0===t&&(t=o),e[t]=r[o]}),i=e.commonjsGlobal&&e.commonjsGlobal.__exportStar||function(e,r){for(var o in e)"default"===o||Object.prototype.hasOwnProperty.call(r,o)||t(r,e,o)},Object.defineProperty(o,"__esModule",{value:!0}),i(s.__exports,o),i(l.__exports,o),i(n.__exports,o);
@@ -1 +0,0 @@
1
- "use strict";var e,i,p=require("../../../../../_virtual/bik-store.js");e=p.__exports,Object.defineProperty(e,"__esModule",{value:!0}),e.ApplicationType=void 0,(i=e.ApplicationType||(e.ApplicationType={})).BIK="BIK",i.MANIFEST="MANIFEST",i.BSP="BSP";
@@ -1 +0,0 @@
1
- "use strict";!function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.ExchangeRateMap=e.PACKAGES=e.TIER=e.PACKAGENAMES=e.MANIFEST_PACKAGENAMES=void 0;const _=14;var a,r,i;(a=e.MANIFEST_PACKAGENAMES||(e.MANIFEST_PACKAGENAMES={})).FREE="FREE",a.GLOBAL_STARTER_1_MONTH="GLOBAL_STARTER_1_MONTH",a.GLOBAL_BOOST_1_MONTH="GLOBAL_BOOST_1_MONTH",a.GLOBAL_GROWTH_1_MONTH="GLOBAL_GROWTH_1_MONTH",a.GLOBAL_SCALE_1_MONTH="GLOBAL_SCALE_1_MONTH",a.GLOBAL_STARTER_12_MONTH="GLOBAL_STARTER_12_MONTH",a.GLOBAL_BOOST_12_MONTH="GLOBAL_BOOST_12_MONTH",a.GLOBAL_GROWTH_12_MONTH="GLOBAL_GROWTH_12_MONTH",a.GLOBAL_SCALE_12_MONTH="GLOBAL_SCALE_12_MONTH",a.GLOBAL_BASIC_1_MONTH="GLOBAL_BASIC_1_MONTH",a.GLOBAL_PREMIUM_1_MONTH="GLOBAL_PREMIUM_1_MONTH",a.GLOBAL_VIP_1_MONTH="GLOBAL_VIP_1_MONTH",a.GLOBAL_ENTERPRISE_1_MONTH="GLOBAL_ENTERPRISE_1_MONTH",a.GLOBAL_BASIC_12_MONTH="GLOBAL_BASIC_12_MONTH",a.GLOBAL_PREMIUM_12_MONTH="GLOBAL_PREMIUM_12_MONTH",a.GLOBAL_VIP_12_MONTH="GLOBAL_VIP_12_MONTH",a.GLOBAL_ENTERPRISE_12_MONTH="GLOBAL_ENTERPRISE_12_MONTH",function(e){e.BIK_INSTAGRAM_PLAN="BIK_INSTAGRAM_PLAN",e.BIK_GROWTH_PLAN="BIK_GROWTH_PLAN",e.BIK_BUSINESS_PLAN="BIK_BUSINESS_PLAN",e.BIK_CUSTOM_PLAN="BIK_CUSTOM_PLAN",e.BIK_FREE_PLAN="BIK_FREE_PLAN",e.BIK_PLG_GROWTH_PLAN="BIK_PLG_GROWTH_PLAN",e.BIK_PLG_BUSINESS_PLAN="BIK_PLG_BUSINESS_PLAN",e.BIK_PLG_STARTER_PLAN="BIK_PLG_STARTER_PLAN",e.BIK_SALES_STARTER_PLAN="BIK_SALES_STARTER_PLAN",e.BIK_SALES_GROWTH_PLAN="BIK_SALES_GROWTH_PLAN",e.BIK_SALES_BUSINESS_PLAN="BIK_SALES_BUSINESS_PLAN"}(r=e.PACKAGENAMES||(e.PACKAGENAMES={})),function(e){e.TIER_0="TIER_0",e.TIER_1="TIER_1",e.TIER_2="TIER_2",e.TIER_3="TIER_3",e.TIER_4="TIER_4",e.TIER_5="TIER_5",e.TIER_6="TIER_6"}(i=e.TIER||(e.TIER={})),e.PACKAGES={FREE:{packageName:"FREE",quota:100,duration:30,description:"Free plan",price:0,freeTrialDays:0,overagePrice:0,overageAllowed:0},GLOBAL_STARTER_1_MONTH:{packageName:"GLOBAL_STARTER_1_MONTH",quota:1e3,duration:30,description:"Bik Starter Monthly Package",price:39,freeTrialDays:_,overagePrice:.04,overageAllowed:4975},GLOBAL_BOOST_1_MONTH:{packageName:"GLOBAL_BOOST_1_MONTH",quota:3e3,duration:30,description:"Bik Boost Monthly Package",price:99,freeTrialDays:_,overagePrice:.04,overageAllowed:4975},GLOBAL_GROWTH_1_MONTH:{packageName:"GLOBAL_GROWTH_1_MONTH",quota:7500,duration:30,description:"Bik Growth Monthly Package",price:249,freeTrialDays:_,overagePrice:.035,overageAllowed:14229},GLOBAL_SCALE_1_MONTH:{packageName:"GLOBAL_SCALE_1_MONTH",quota:3e4,duration:30,description:"Bik Scale Monthly Package",price:799,freeTrialDays:_,overagePrice:.025,overageAllowed:63920},GLOBAL_STARTER_12_MONTH:{packageName:"GLOBAL_STARTER_12_MONTH",quota:12e3,duration:365,description:"Bik Starter Annual Package",price:399,freeTrialDays:_},GLOBAL_BOOST_12_MONTH:{packageName:"GLOBAL_BOOST_12_MONTH",quota:36e3,duration:365,description:"Bik Boost Annual Package",price:999,freeTrialDays:_},GLOBAL_GROWTH_12_MONTH:{packageName:"GLOBAL_GROWTH_12_MONTH",quota:9e4,duration:365,description:"Bik Growth Annual Package",price:2499,freeTrialDays:_},GLOBAL_SCALE_12_MONTH:{packageName:"GLOBAL_SCALE_12_MONTH",quota:36e4,duration:365,description:"Bik Scale Annual Package",price:7999,freeTrialDays:_},GLOBAL_BASIC_1_MONTH:{packageName:"GLOBAL_BASIC_1_MONTH",quota:600,duration:30,description:"Bik Basic Monthly Package",price:99,freeTrialDays:7,overagePrice:.2,overageAllowed:1500},GLOBAL_PREMIUM_1_MONTH:{packageName:"GLOBAL_PREMIUM_1_MONTH",quota:2500,duration:30,description:"Bik Premium Monthly Package",price:249,freeTrialDays:7,overagePrice:.15,overageAllowed:5e3},GLOBAL_VIP_1_MONTH:{packageName:"GLOBAL_VIP_1_MONTH",quota:7e3,duration:30,description:"Bik VIP Monthly Package",price:499,freeTrialDays:7,overagePrice:.1,overageAllowed:15e3},GLOBAL_ENTERPRISE_1_MONTH:{packageName:"GLOBAL_ENTERPRISE_1_MONTH",quota:7e3,duration:30,description:"Manifest Enterprise Monthly Package",price:499,overagePrice:.1,overageAllowed:15e3,freeTrialDays:7},GLOBAL_BASIC_12_MONTH:{packageName:"GLOBAL_BASIC_12_MONTH",quota:7200,duration:365,description:"Bik Basic Annual Package",price:999,freeTrialDays:7},GLOBAL_PREMIUM_12_MONTH:{packageName:"GLOBAL_PREMIUM_12_MONTH",quota:3e4,duration:365,description:"Bik Premium Annual Package",price:2499,freeTrialDays:7},GLOBAL_VIP_12_MONTH:{packageName:"GLOBAL_VIP_12_MONTH",quota:84e3,duration:365,description:"Bik VIP Annual Package",price:4999,freeTrialDays:7},GLOBAL_ENTERPRISE_12_MONTH:{packageName:"GLOBAL_ENTERPRISE_12_MONTH",quota:84e3,duration:365,description:"Manifest Enterprise Annual Package",price:4999,freeTrialDays:7},[r.BIK_INSTAGRAM_PLAN]:{packageName:r.BIK_INSTAGRAM_PLAN,quota:2990,duration:30,description:"Instagram Plan",price:299,freeTrialDays:14,overageAllowed:598,waFreeCredits:1.1,emailFreeCredits:5.95,freeContacts:1e4,emailUnitCost:37e-5},[r.BIK_GROWTH_PLAN]:{packageName:r.BIK_GROWTH_PLAN,quota:5990,duration:30,description:"Growth Plan",price:599,freeTrialDays:14,overageAllowed:1198,waFreeCredits:4.95,emailFreeCredits:35.71,freeContacts:1e5,emailUnitCost:37e-5,tierMapping:{[i.TIER_1]:{price:199},[i.TIER_2]:{price:269},[i.TIER_3]:{price:469},[i.TIER_4]:{price:669},[i.TIER_5]:{price:819}}},[r.BIK_BUSINESS_PLAN]:{packageName:r.BIK_BUSINESS_PLAN,quota:7990,duration:30,description:"Business Plan",price:799,freeTrialDays:14,overageAllowed:1598,waFreeCredits:49.5,emailFreeCredits:35.71,emailUnitCost:37e-5,freeContacts:2e6,tierMapping:{[i.TIER_1]:{price:250},[i.TIER_2]:{price:339},[i.TIER_3]:{price:589},[i.TIER_4]:{price:829},[i.TIER_5]:{price:999}}},[r.BIK_CUSTOM_PLAN]:{packageName:r.BIK_CUSTOM_PLAN,quota:5e3,duration:30,description:"Custom Plan",price:0,freeTrialDays:0,overageAllowed:79900,waFreeCredits:12.5,emailFreeCredits:12.5,emailUnitCost:37e-5},[r.BIK_FREE_PLAN]:{packageName:r.BIK_FREE_PLAN,quota:10,duration:30,description:"Free Plan",price:0,freeTrialDays:0,overageAllowed:10,waFreeCredits:.55,emailFreeCredits:.6,freeContacts:500,emailUnitCost:37e-5},[r.BIK_PLG_STARTER_PLAN]:{packageName:r.BIK_PLG_STARTER_PLAN,quota:990,duration:30,description:"BIK Starter Plan",price:99,freeTrialDays:14,overageAllowed:198,waFreeCredits:1.1,emailFreeCredits:5.95,freeContacts:1e4,emailUnitCost:37e-5,tierMapping:{[i.TIER_1]:{price:99},[i.TIER_2]:{price:169},[i.TIER_3]:{price:179},[i.TIER_4]:{price:329},[i.TIER_5]:{price:529}}},[r.BIK_PLG_GROWTH_PLAN]:{packageName:r.BIK_PLG_GROWTH_PLAN,quota:3990,duration:30,description:"BIK Growth Plan",price:399,freeTrialDays:14,overageAllowed:798,waFreeCredits:4.95,emailFreeCredits:35.71,freeContacts:1e5,emailUnitCost:37e-5,tierMapping:{[i.TIER_1]:{price:199},[i.TIER_2]:{price:269},[i.TIER_3]:{price:469},[i.TIER_4]:{price:669},[i.TIER_5]:{price:819}}},[r.BIK_PLG_BUSINESS_PLAN]:{packageName:r.BIK_PLG_BUSINESS_PLAN,quota:7990,duration:30,description:"BIK Business Plan",price:799,freeTrialDays:14,overageAllowed:1598,waFreeCredits:49.5,emailFreeCredits:35.71,freeContacts:2e6,emailUnitCost:37e-5,tierMapping:{[i.TIER_1]:{price:250},[i.TIER_2]:{price:339},[i.TIER_3]:{price:589},[i.TIER_4]:{price:829},[i.TIER_5]:{price:999}}},[r.BIK_SALES_STARTER_PLAN]:{packageName:r.BIK_SALES_STARTER_PLAN,quota:990,duration:30,description:"BIK Sales Starter Plan",price:99,freeTrialDays:14,overageAllowed:198,waFreeCredits:0,emailFreeCredits:0,freeContacts:0,emailUnitCost:37e-5,tierMapping:{[i.TIER_1]:{price:99},[i.TIER_2]:{price:169},[i.TIER_3]:{price:179},[i.TIER_4]:{price:329},[i.TIER_5]:{price:529}}},[r.BIK_SALES_GROWTH_PLAN]:{packageName:r.BIK_SALES_GROWTH_PLAN,quota:3990,duration:30,description:"BIK Sales Growth Plan",price:399,freeTrialDays:14,overageAllowed:798,waFreeCredits:0,emailFreeCredits:0,freeContacts:0,emailUnitCost:37e-5,tierMapping:{[i.TIER_1]:{price:199},[i.TIER_2]:{price:269},[i.TIER_3]:{price:469},[i.TIER_4]:{price:669},[i.TIER_5]:{price:819}}},[r.BIK_SALES_BUSINESS_PLAN]:{packageName:r.BIK_SALES_BUSINESS_PLAN,quota:7990,duration:30,description:"BIK Sales Business Plan",price:799,freeTrialDays:14,overageAllowed:1598,waFreeCredits:0,emailFreeCredits:0,freeContacts:0,emailUnitCost:37e-5,tierMapping:{[i.TIER_1]:{price:250},[i.TIER_2]:{price:339},[i.TIER_3]:{price:589},[i.TIER_4]:{price:829},[i.TIER_5]:{price:999}}}},e.ExchangeRateMap={"USD-INR":83.235758,"INR-USD":.0120141,"GBP-INR":101.020305081,"INR-GBP":.00990747,"AUD-INR":52.606042,"INR-AUD":.0190078,"JPY-INR":.55805653,"INR-JPY":1.79193,"INR-PKR":3.41966,"PKR-INR":.2924269,"CAD-INR":60.719681,"INR-CAD":.0164691,"INR-RUB":1.19476,"RUB-INR":.83698689,"INR-AED":.0441093,"AED-INR":22.670942,"INR-EUR":.011435464,"EUR-INR":87.447258,"INR-BRL":.061935861,"BRL-INR":16.1457,"USD-GBP":.811721,"USD-EUR":.940639,"USD-CAD":1.36082,"USD-SGD":1.36185,"USD-USD":1,"USD-SAR":3.75,"SAR-USD":.26666667,"KWD-USD":3.23494,"USD-KWD":.309125,"QAR-USD":.27472527,"USD-QAR":3.64,"AED-USD":.27229408,"USD-AED":3.6725,"ZAR-USD":.053130272,"USD-ZAR":18.8202,"PKR-USD":.0035818064,"USD-PKR":279.189,"LKR-USD":.0030839229,"USD-LKR":324.262,"TRY-USD":.03604935,"USD-TRY":27.7395,"CNY-USD":.13756281,"USD-CNY":7.26941,"CNH-USD":.13701883,"USD-CNH":7.29853,"BRL-USD":.19798628,"USD-BRL":5.05086,"KRW-USD":.0007471076,"USD-KRW":1338.5,"AUD-USD":.6409892,"USD-AUD":1.56009,"JPY-USD":.0067046544,"USD-JPY":149.15,"CAD-USD":.7348507,"GBP-USD":1.2319473,"EUR-USD":1.0631068,"SGD-USD":.73429505}}(require("../../../../../_virtual/billing.js").__exports);
@@ -1 +0,0 @@
1
- "use strict";var T,S,e,A,_,P,O=require("../../../../../_virtual/store.js");T=O.__exports,Object.defineProperty(T,"__esModule",{value:!0}),T.ATTRIBUTION_TYPE=T.Statuses=T.PartnerSyncStatusType=T.AppType=T.BillingType=void 0,(S=T.BillingType||(T.BillingType={})).COMPLETELY_ON_SHOPIFY="COMPLETELY_ON_SHOPIFY",S.PARTIALLY_ON_SHOPIFY="PARTIALLY_ON_SHOPIFY",S.OUTSIDE_SHOPIFY="OUTSIDE_SHOPIFY",(e=T.AppType||(T.AppType={})).GLOBAL="GLOBAL",e.WHATSAPP="WHATSAPP",e.BSP="BSP",e.WHATSAPP_CUSTOM="WHATSAPP_CUSTOM",e.WHATSAPP_LISTING="WHATSAPP_LISTING",e.GLOBAL_LISTING="GLOBAL_LISTING",e.GLOBAL_CUSTOM="GLOBAL_CUSTOM",(A=T.PartnerSyncStatusType||(T.PartnerSyncStatusType={})).NOT_STARTED="NOT_STARTED",A.IN_PROGRESS="IN_PROGRESS",A.COMPLETED="COMPLETED",A.FAILED="FAILED",(_=T.Statuses||(T.Statuses={})).Active="Active",_.Inactive="Inactive",_.Blocked="Blocked",_.Closed="Closed",_.Churned_deleted="Churned_deleted",(P=T.ATTRIBUTION_TYPE||(T.ATTRIBUTION_TYPE={})).CLICK_BASED="CLICK_BASED",P.OPEN_BASED="OPEN_BASED",P.DELIVERY_BASED="DELIVERY_BASED";
@@ -1 +0,0 @@
1
- var r={};export{r as __exports};
@@ -1 +0,0 @@
1
- var r={};export{r as __exports};
@@ -1 +0,0 @@
1
- var r={};export{r as __exports};
@@ -1 +0,0 @@
1
- var r={};export{r as __exports};
@@ -1 +0,0 @@
1
- import{commonjsGlobal as r}from"../../../../_virtual/_commonjsHelpers.js";import{__exports as e}from"../../../../_virtual/index.js";import"./models/store.js";import"./models/billing.js";import"./models/bik-store.js";import{__exports as t}from"../../../../_virtual/store.js";import{__exports as o}from"../../../../_virtual/billing.js";import{__exports as i}from"../../../../_virtual/bik-store.js";var s,n,a;s=e,n=r&&r.__createBinding||(Object.create?function(r,e,t,o){void 0===o&&(o=t);var i=Object.getOwnPropertyDescriptor(e,t);i&&!("get"in i?!e.__esModule:i.writable||i.configurable)||(i={enumerable:!0,get:function(){return e[t]}}),Object.defineProperty(r,o,i)}:function(r,e,t,o){void 0===o&&(o=t),r[o]=e[t]}),a=r&&r.__exportStar||function(r,e){for(var t in r)"default"===t||Object.prototype.hasOwnProperty.call(e,t)||n(e,r,t)},Object.defineProperty(s,"__esModule",{value:!0}),a(t,s),a(o,s),a(i,s);
@@ -1 +0,0 @@
1
- import{__exports as e}from"../../../../../_virtual/bik-store.js";var p,i;p=e,Object.defineProperty(p,"__esModule",{value:!0}),p.ApplicationType=void 0,(i=p.ApplicationType||(p.ApplicationType={})).BIK="BIK",i.MANIFEST="MANIFEST",i.BSP="BSP";
@@ -1 +0,0 @@
1
- import{__exports as e}from"../../../../../_virtual/billing.js";!function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.ExchangeRateMap=e.PACKAGES=e.TIER=e.PACKAGENAMES=e.MANIFEST_PACKAGENAMES=void 0;const _=14;var a,r,i;(a=e.MANIFEST_PACKAGENAMES||(e.MANIFEST_PACKAGENAMES={})).FREE="FREE",a.GLOBAL_STARTER_1_MONTH="GLOBAL_STARTER_1_MONTH",a.GLOBAL_BOOST_1_MONTH="GLOBAL_BOOST_1_MONTH",a.GLOBAL_GROWTH_1_MONTH="GLOBAL_GROWTH_1_MONTH",a.GLOBAL_SCALE_1_MONTH="GLOBAL_SCALE_1_MONTH",a.GLOBAL_STARTER_12_MONTH="GLOBAL_STARTER_12_MONTH",a.GLOBAL_BOOST_12_MONTH="GLOBAL_BOOST_12_MONTH",a.GLOBAL_GROWTH_12_MONTH="GLOBAL_GROWTH_12_MONTH",a.GLOBAL_SCALE_12_MONTH="GLOBAL_SCALE_12_MONTH",a.GLOBAL_BASIC_1_MONTH="GLOBAL_BASIC_1_MONTH",a.GLOBAL_PREMIUM_1_MONTH="GLOBAL_PREMIUM_1_MONTH",a.GLOBAL_VIP_1_MONTH="GLOBAL_VIP_1_MONTH",a.GLOBAL_ENTERPRISE_1_MONTH="GLOBAL_ENTERPRISE_1_MONTH",a.GLOBAL_BASIC_12_MONTH="GLOBAL_BASIC_12_MONTH",a.GLOBAL_PREMIUM_12_MONTH="GLOBAL_PREMIUM_12_MONTH",a.GLOBAL_VIP_12_MONTH="GLOBAL_VIP_12_MONTH",a.GLOBAL_ENTERPRISE_12_MONTH="GLOBAL_ENTERPRISE_12_MONTH",function(e){e.BIK_INSTAGRAM_PLAN="BIK_INSTAGRAM_PLAN",e.BIK_GROWTH_PLAN="BIK_GROWTH_PLAN",e.BIK_BUSINESS_PLAN="BIK_BUSINESS_PLAN",e.BIK_CUSTOM_PLAN="BIK_CUSTOM_PLAN",e.BIK_FREE_PLAN="BIK_FREE_PLAN",e.BIK_PLG_GROWTH_PLAN="BIK_PLG_GROWTH_PLAN",e.BIK_PLG_BUSINESS_PLAN="BIK_PLG_BUSINESS_PLAN",e.BIK_PLG_STARTER_PLAN="BIK_PLG_STARTER_PLAN",e.BIK_SALES_STARTER_PLAN="BIK_SALES_STARTER_PLAN",e.BIK_SALES_GROWTH_PLAN="BIK_SALES_GROWTH_PLAN",e.BIK_SALES_BUSINESS_PLAN="BIK_SALES_BUSINESS_PLAN"}(r=e.PACKAGENAMES||(e.PACKAGENAMES={})),function(e){e.TIER_0="TIER_0",e.TIER_1="TIER_1",e.TIER_2="TIER_2",e.TIER_3="TIER_3",e.TIER_4="TIER_4",e.TIER_5="TIER_5",e.TIER_6="TIER_6"}(i=e.TIER||(e.TIER={})),e.PACKAGES={FREE:{packageName:"FREE",quota:100,duration:30,description:"Free plan",price:0,freeTrialDays:0,overagePrice:0,overageAllowed:0},GLOBAL_STARTER_1_MONTH:{packageName:"GLOBAL_STARTER_1_MONTH",quota:1e3,duration:30,description:"Bik Starter Monthly Package",price:39,freeTrialDays:_,overagePrice:.04,overageAllowed:4975},GLOBAL_BOOST_1_MONTH:{packageName:"GLOBAL_BOOST_1_MONTH",quota:3e3,duration:30,description:"Bik Boost Monthly Package",price:99,freeTrialDays:_,overagePrice:.04,overageAllowed:4975},GLOBAL_GROWTH_1_MONTH:{packageName:"GLOBAL_GROWTH_1_MONTH",quota:7500,duration:30,description:"Bik Growth Monthly Package",price:249,freeTrialDays:_,overagePrice:.035,overageAllowed:14229},GLOBAL_SCALE_1_MONTH:{packageName:"GLOBAL_SCALE_1_MONTH",quota:3e4,duration:30,description:"Bik Scale Monthly Package",price:799,freeTrialDays:_,overagePrice:.025,overageAllowed:63920},GLOBAL_STARTER_12_MONTH:{packageName:"GLOBAL_STARTER_12_MONTH",quota:12e3,duration:365,description:"Bik Starter Annual Package",price:399,freeTrialDays:_},GLOBAL_BOOST_12_MONTH:{packageName:"GLOBAL_BOOST_12_MONTH",quota:36e3,duration:365,description:"Bik Boost Annual Package",price:999,freeTrialDays:_},GLOBAL_GROWTH_12_MONTH:{packageName:"GLOBAL_GROWTH_12_MONTH",quota:9e4,duration:365,description:"Bik Growth Annual Package",price:2499,freeTrialDays:_},GLOBAL_SCALE_12_MONTH:{packageName:"GLOBAL_SCALE_12_MONTH",quota:36e4,duration:365,description:"Bik Scale Annual Package",price:7999,freeTrialDays:_},GLOBAL_BASIC_1_MONTH:{packageName:"GLOBAL_BASIC_1_MONTH",quota:600,duration:30,description:"Bik Basic Monthly Package",price:99,freeTrialDays:7,overagePrice:.2,overageAllowed:1500},GLOBAL_PREMIUM_1_MONTH:{packageName:"GLOBAL_PREMIUM_1_MONTH",quota:2500,duration:30,description:"Bik Premium Monthly Package",price:249,freeTrialDays:7,overagePrice:.15,overageAllowed:5e3},GLOBAL_VIP_1_MONTH:{packageName:"GLOBAL_VIP_1_MONTH",quota:7e3,duration:30,description:"Bik VIP Monthly Package",price:499,freeTrialDays:7,overagePrice:.1,overageAllowed:15e3},GLOBAL_ENTERPRISE_1_MONTH:{packageName:"GLOBAL_ENTERPRISE_1_MONTH",quota:7e3,duration:30,description:"Manifest Enterprise Monthly Package",price:499,overagePrice:.1,overageAllowed:15e3,freeTrialDays:7},GLOBAL_BASIC_12_MONTH:{packageName:"GLOBAL_BASIC_12_MONTH",quota:7200,duration:365,description:"Bik Basic Annual Package",price:999,freeTrialDays:7},GLOBAL_PREMIUM_12_MONTH:{packageName:"GLOBAL_PREMIUM_12_MONTH",quota:3e4,duration:365,description:"Bik Premium Annual Package",price:2499,freeTrialDays:7},GLOBAL_VIP_12_MONTH:{packageName:"GLOBAL_VIP_12_MONTH",quota:84e3,duration:365,description:"Bik VIP Annual Package",price:4999,freeTrialDays:7},GLOBAL_ENTERPRISE_12_MONTH:{packageName:"GLOBAL_ENTERPRISE_12_MONTH",quota:84e3,duration:365,description:"Manifest Enterprise Annual Package",price:4999,freeTrialDays:7},[r.BIK_INSTAGRAM_PLAN]:{packageName:r.BIK_INSTAGRAM_PLAN,quota:2990,duration:30,description:"Instagram Plan",price:299,freeTrialDays:14,overageAllowed:598,waFreeCredits:1.1,emailFreeCredits:5.95,freeContacts:1e4,emailUnitCost:37e-5},[r.BIK_GROWTH_PLAN]:{packageName:r.BIK_GROWTH_PLAN,quota:5990,duration:30,description:"Growth Plan",price:599,freeTrialDays:14,overageAllowed:1198,waFreeCredits:4.95,emailFreeCredits:35.71,freeContacts:1e5,emailUnitCost:37e-5,tierMapping:{[i.TIER_1]:{price:199},[i.TIER_2]:{price:269},[i.TIER_3]:{price:469},[i.TIER_4]:{price:669},[i.TIER_5]:{price:819}}},[r.BIK_BUSINESS_PLAN]:{packageName:r.BIK_BUSINESS_PLAN,quota:7990,duration:30,description:"Business Plan",price:799,freeTrialDays:14,overageAllowed:1598,waFreeCredits:49.5,emailFreeCredits:35.71,emailUnitCost:37e-5,freeContacts:2e6,tierMapping:{[i.TIER_1]:{price:250},[i.TIER_2]:{price:339},[i.TIER_3]:{price:589},[i.TIER_4]:{price:829},[i.TIER_5]:{price:999}}},[r.BIK_CUSTOM_PLAN]:{packageName:r.BIK_CUSTOM_PLAN,quota:5e3,duration:30,description:"Custom Plan",price:0,freeTrialDays:0,overageAllowed:79900,waFreeCredits:12.5,emailFreeCredits:12.5,emailUnitCost:37e-5},[r.BIK_FREE_PLAN]:{packageName:r.BIK_FREE_PLAN,quota:10,duration:30,description:"Free Plan",price:0,freeTrialDays:0,overageAllowed:10,waFreeCredits:.55,emailFreeCredits:.6,freeContacts:500,emailUnitCost:37e-5},[r.BIK_PLG_STARTER_PLAN]:{packageName:r.BIK_PLG_STARTER_PLAN,quota:990,duration:30,description:"BIK Starter Plan",price:99,freeTrialDays:14,overageAllowed:198,waFreeCredits:1.1,emailFreeCredits:5.95,freeContacts:1e4,emailUnitCost:37e-5,tierMapping:{[i.TIER_1]:{price:99},[i.TIER_2]:{price:169},[i.TIER_3]:{price:179},[i.TIER_4]:{price:329},[i.TIER_5]:{price:529}}},[r.BIK_PLG_GROWTH_PLAN]:{packageName:r.BIK_PLG_GROWTH_PLAN,quota:3990,duration:30,description:"BIK Growth Plan",price:399,freeTrialDays:14,overageAllowed:798,waFreeCredits:4.95,emailFreeCredits:35.71,freeContacts:1e5,emailUnitCost:37e-5,tierMapping:{[i.TIER_1]:{price:199},[i.TIER_2]:{price:269},[i.TIER_3]:{price:469},[i.TIER_4]:{price:669},[i.TIER_5]:{price:819}}},[r.BIK_PLG_BUSINESS_PLAN]:{packageName:r.BIK_PLG_BUSINESS_PLAN,quota:7990,duration:30,description:"BIK Business Plan",price:799,freeTrialDays:14,overageAllowed:1598,waFreeCredits:49.5,emailFreeCredits:35.71,freeContacts:2e6,emailUnitCost:37e-5,tierMapping:{[i.TIER_1]:{price:250},[i.TIER_2]:{price:339},[i.TIER_3]:{price:589},[i.TIER_4]:{price:829},[i.TIER_5]:{price:999}}},[r.BIK_SALES_STARTER_PLAN]:{packageName:r.BIK_SALES_STARTER_PLAN,quota:990,duration:30,description:"BIK Sales Starter Plan",price:99,freeTrialDays:14,overageAllowed:198,waFreeCredits:0,emailFreeCredits:0,freeContacts:0,emailUnitCost:37e-5,tierMapping:{[i.TIER_1]:{price:99},[i.TIER_2]:{price:169},[i.TIER_3]:{price:179},[i.TIER_4]:{price:329},[i.TIER_5]:{price:529}}},[r.BIK_SALES_GROWTH_PLAN]:{packageName:r.BIK_SALES_GROWTH_PLAN,quota:3990,duration:30,description:"BIK Sales Growth Plan",price:399,freeTrialDays:14,overageAllowed:798,waFreeCredits:0,emailFreeCredits:0,freeContacts:0,emailUnitCost:37e-5,tierMapping:{[i.TIER_1]:{price:199},[i.TIER_2]:{price:269},[i.TIER_3]:{price:469},[i.TIER_4]:{price:669},[i.TIER_5]:{price:819}}},[r.BIK_SALES_BUSINESS_PLAN]:{packageName:r.BIK_SALES_BUSINESS_PLAN,quota:7990,duration:30,description:"BIK Sales Business Plan",price:799,freeTrialDays:14,overageAllowed:1598,waFreeCredits:0,emailFreeCredits:0,freeContacts:0,emailUnitCost:37e-5,tierMapping:{[i.TIER_1]:{price:250},[i.TIER_2]:{price:339},[i.TIER_3]:{price:589},[i.TIER_4]:{price:829},[i.TIER_5]:{price:999}}}},e.ExchangeRateMap={"USD-INR":83.235758,"INR-USD":.0120141,"GBP-INR":101.020305081,"INR-GBP":.00990747,"AUD-INR":52.606042,"INR-AUD":.0190078,"JPY-INR":.55805653,"INR-JPY":1.79193,"INR-PKR":3.41966,"PKR-INR":.2924269,"CAD-INR":60.719681,"INR-CAD":.0164691,"INR-RUB":1.19476,"RUB-INR":.83698689,"INR-AED":.0441093,"AED-INR":22.670942,"INR-EUR":.011435464,"EUR-INR":87.447258,"INR-BRL":.061935861,"BRL-INR":16.1457,"USD-GBP":.811721,"USD-EUR":.940639,"USD-CAD":1.36082,"USD-SGD":1.36185,"USD-USD":1,"USD-SAR":3.75,"SAR-USD":.26666667,"KWD-USD":3.23494,"USD-KWD":.309125,"QAR-USD":.27472527,"USD-QAR":3.64,"AED-USD":.27229408,"USD-AED":3.6725,"ZAR-USD":.053130272,"USD-ZAR":18.8202,"PKR-USD":.0035818064,"USD-PKR":279.189,"LKR-USD":.0030839229,"USD-LKR":324.262,"TRY-USD":.03604935,"USD-TRY":27.7395,"CNY-USD":.13756281,"USD-CNY":7.26941,"CNH-USD":.13701883,"USD-CNH":7.29853,"BRL-USD":.19798628,"USD-BRL":5.05086,"KRW-USD":.0007471076,"USD-KRW":1338.5,"AUD-USD":.6409892,"USD-AUD":1.56009,"JPY-USD":.0067046544,"USD-JPY":149.15,"CAD-USD":.7348507,"GBP-USD":1.2319473,"EUR-USD":1.0631068,"SGD-USD":.73429505}}(e);
@@ -1 +0,0 @@
1
- import{__exports as T}from"../../../../../_virtual/store.js";var S,e,A,_,P,O;S=T,Object.defineProperty(S,"__esModule",{value:!0}),S.ATTRIBUTION_TYPE=S.Statuses=S.PartnerSyncStatusType=S.AppType=S.BillingType=void 0,(e=S.BillingType||(S.BillingType={})).COMPLETELY_ON_SHOPIFY="COMPLETELY_ON_SHOPIFY",e.PARTIALLY_ON_SHOPIFY="PARTIALLY_ON_SHOPIFY",e.OUTSIDE_SHOPIFY="OUTSIDE_SHOPIFY",(A=S.AppType||(S.AppType={})).GLOBAL="GLOBAL",A.WHATSAPP="WHATSAPP",A.BSP="BSP",A.WHATSAPP_CUSTOM="WHATSAPP_CUSTOM",A.WHATSAPP_LISTING="WHATSAPP_LISTING",A.GLOBAL_LISTING="GLOBAL_LISTING",A.GLOBAL_CUSTOM="GLOBAL_CUSTOM",(_=S.PartnerSyncStatusType||(S.PartnerSyncStatusType={})).NOT_STARTED="NOT_STARTED",_.IN_PROGRESS="IN_PROGRESS",_.COMPLETED="COMPLETED",_.FAILED="FAILED",(P=S.Statuses||(S.Statuses={})).Active="Active",P.Inactive="Inactive",P.Blocked="Blocked",P.Closed="Closed",P.Churned_deleted="Churned_deleted",(O=S.ATTRIBUTION_TYPE||(S.ATTRIBUTION_TYPE={})).CLICK_BASED="CLICK_BASED",O.OPEN_BASED="OPEN_BASED",O.DELIVERY_BASED="DELIVERY_BASED";