@bikdotai/bik-component-library 0.0.458 → 0.0.460-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.
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e,t=require("react/jsx-runtime"),o=require("../../assets/icons/search.svg.js"),c=require("react"),r=require("../../constants/Theme.js"),s=require("../button/Button.js"),n=require("../input/Input.js"),l=require("../modals/styledModal.js"),i=require("../spinner/Spinner.js"),a=require("../tag/Tag.js"),d=require("./collectionScreen.js"),u=require("./productInfoOverlay.js"),h=require("./productScreen.js"),p=require("./rearrangeScreen.js"),S=require("./reducers.js"),C=require("./searchScreen.js"),x=require("./selectedScreen.js"),g=require("./style.js"),j=require("./type.js");exports.ScreenName=void 0,(e=exports.ScreenName||(exports.ScreenName={})).Collections="collections",e.RearrangeProducts="rearrange",e.SelectedProducts="view",e.SearchProducts="searchProducts",e.Products="products";exports.ProductPickerModal=e=>{const{storeId:y,selectedItems:b,onClose:m,visible:f,zIndex:P,exactLimit:v,limit:k,hideCollectionCheckbox:I,hideProductCheckbox:F,outOfStockAction:O=j.OUT_OF_STOCK_ACTION.BLUR,hideVariantCheckbox:R,selectProductsFromCustomCollection:T,hideSelectionCount:q,title:D,width:E,renderWithoutModal:w,onClickSave:N,pickerType:A,hideProductVariants:B=!1,startupScreen:M=exports.ScreenName.Collections,rearrangeEnabled:$,selectSingleItem:L=!1,showProductDetails:V}=e,[_,z]=c.useReducer(S.collectionsReducer,{}),[W,G]=c.useState([exports.ScreenName.Collections,exports.ScreenName.RearrangeProducts].includes(M)?M:exports.ScreenName.Collections),[H,K]=c.useState("grid"),[U,Y]=c.useState(""),[J,Q]=c.useState(""),[X,Z]=c.useState(0),[ee,te]=c.useState(!1),[oe,ce]=c.useState(0),[re,se]=c.useState(""),[ne,le]=c.useState(!1),[ie,ae]=c.useState(!1),[de,ue]=c.useReducer(S.searchReducer,{collections:{},products:{}}),[he,pe]=c.useReducer(S.selectedColectionsReducer,Object.keys(b).length>0?b:{}),Se=c.useRef(null),[Ce,xe]=c.useState(!1),[ge,je]=c.useState();c.useEffect((()=>{te(!0),ae(!0),e.collectionFetcher(X,y).then((e=>{z({type:"fetched",data:(null==e?void 0:e.collections)||{}}),te(!1),Z((e=>e+1)),ae(!1)})).catch()}),[]),c.useEffect((()=>{let e=0;Object.keys(he||[]).forEach((t=>{var o;Object.keys((null===(o=he[t])||void 0===o?void 0:o.products)||[]).forEach((o=>{var c,r;Object.keys((null===(r=null===(c=he[t].products)||void 0===c?void 0:c[o])||void 0===r?void 0:r.variants)||[]).forEach((()=>{e+=1}))}))})),ce(e)})),c.useEffect((()=>{J&&(te(!0),e.productFetcher(J,y).then((e=>{Object.keys(e).length&&z({type:"productsFetched",data:{collectionId:J,products:e}}),te(!1)})).catch())}),[J]),c.useEffect((()=>{const t=setTimeout((()=>{"rearrange"!==W&&(re.length?(le(!0),e.searchFetcher(y,re).then((e=>{"collections"in e&&"products"in e?(ue({type:"set",data:e}),z({type:"searched",data:e.collections})):(ue({type:"set",data:{collections:{},products:e}}),z({type:"searched",data:e})),G("searchProducts"),te(!1),le(!1)}))):G("collections"))}),800);return()=>clearTimeout(t)}),[re]),c.useEffect((()=>{N&&(e.onAdd(he,oe),ye())}),[N]),c.useEffect((()=>{L&&Object.keys(he||{}).length&&oe&&(e.onAdd(he,oe),ye())}),[L,he,oe]);const ye=()=>{pe({type:"reset",data:{}})},be=t.jsxs(g.ContainerStyle,{children:[e.postHeader&&t.jsx("div",Object.assign({style:{padding:"0 24px"}},{children:e.postHeader})),!e.hideGlobalSearch&&t.jsx(t.Fragment,{children:("collections"===W||"searchProducts"===W)&&t.jsx("div",Object.assign({style:{padding:w?"8px 16px":"12px 24px",borderBottom:"1px solid #E0E0E0"}},{children:t.jsx(n.Input,{noKeyDownChange:!0,noErrorHint:!0,rightIcon:{icon:()=>ne?t.jsx(i.Spinner,{size:"small",color:r.COLORS.content.primary}):t.jsx(o.default,{})},id:"listInput",height:"24px",type:"text",value:re,onChangeText:e=>{e.length&&e.trim().length?se(e):se("")}})}))}),t.jsxs(g.ScrollContainerStyle,Object.assign({ref:Se},{children:["collections"===W&&t.jsx(d.CollectionsScreen,{customCollectionRestriction:e.customCollectionRestriction,dataLoading:ie,collections:_,selectedCollectionsDispatch:pe,setCollectionId:Y,setSelectedCollectionId:Q,setScreen:G,selectedCollections:he,collectionFetcher:e.collectionFetcher,storeId:y,collectionsDispatch:z,setSaveDisabled:te,pagingControls:{curPage:X,setCurPage:Z},hideCollectionCheckbox:I,renderWithoutModal:w,pickerType:A}),"products"===W&&U&&t.jsx(S.CollectionIdContext.Provider,Object.assign({value:U},{children:t.jsx(h.ProductsScreen,{hideInCollectionSearch:e.hideInCollectionSearch,customCollectionRestriction:e.customCollectionRestriction,productFetcher:e.productFetcher,setScreen:G,storeId:y,data:_[U],collectionsDispatch:z,selectedCollectionsDispatch:pe,selectedData:he,setSaveDisabled:te,searchInCollectionFetcher:e.searchInCollectionFetcher,hideProductCheckbox:F,outOfStockAction:O,hideVariantCheckbox:R,selectProductsFromCustomCollection:T,renderWithoutModal:w,pickerType:A,hideProductVariants:B,fbStatusFetcher:e.fbStatusFetcher,onProductDetailClick:e=>{xe(!0),je(e)},showProductDetailInfoIcon:V})})),"view"===W&&t.jsx(x.SelectedScreen,{selectedCollections:he||{},selectedCollectionsDispatch:pe,setScreen:G,collections:_,outOfStockAction:O,storeId:y,fbStatusFetcher:e.fbStatusFetcher}),"rearrange"===W&&t.jsx(p.RearrangeScreen,{selectedCollections:he||{},selectedCollectionsDispatch:pe,setScreen:G,outOfStockAction:O,rearrangeViewType:"grid"===H?"list":"grid",scrollContainerRef:Se,storeId:y,fbStatusFetcher:e.fbStatusFetcher}),"searchProducts"===W&&t.jsx(C.SearchScreen,{customCollectionRestriction:e.customCollectionRestriction,selectedCollections:he||{},searchedCollections:de||{},searchedCollectionsDispatch:ue,selectedCollectionsDispatch:pe,setScreen:G,collections:_,onBackPress:()=>{se(""),ue({type:"set",data:{collections:{},products:{}}})},pickerType:A,hideProductCheckbox:F,hideProductVariants:B,hideVariantCheckbox:R,storeId:y,fbStatusFetcher:e.fbStatusFetcher,setCollectionId:Y,setSelectedCollectionId:Q,renderWithoutModal:w,hideCollectionCheckbox:I})]}))]});return t.jsx(t.Fragment,{children:w?be:t.jsxs(l.StyledModal,Object.assign({zIndex:P,open:f,onClose:()=>{null==m||m(),ye()},headingTitle:D||("collections"===W||"products"===W?"Select Products":"view"===W?"Selected Products":"searchProducts"===W?"Searched Products":"rearrange"===W?"Rearrange Products":void 0),footerShadow:!0,centralContainerStyles:{width:E||"600px"},headerRightCustomElement:"rearrange"===W?(console.log("ignore:",K),t.jsx(t.Fragment,{})):t.jsx(t.Fragment,{}),footerContainerStyle:e.stickyFooter?{position:"absolute",bottom:0,left:0,width:"100%",zIndex:9,background:r.COLORS.surface.standard}:void 0,primaryButton:{buttonText:ee?"Loading...":W===exports.ScreenName.RearrangeProducts?"Done":"Add",disabled:ee||oe<1||v&&oe<v||!v&&k&&oe>k||!1,onClick:()=>{e.onAdd(he,oe),ye()}},wrapperStyle:e.stickyFooter?{height:"calc(100vh - 168px)"}:void 0,footerLeftCustomElement:q?t.jsx(t.Fragment,{}):v&&oe>v?t.jsx(a.Tag,{tagText:`You can only select ${v} products`,type:"negative"}):k&&oe>k?t.jsx(a.Tag,{tagText:`You can only select ${k} products`,type:"negative"}):oe>0?t.jsx(s.Button,{onClick:()=>{G($?exports.ScreenName.RearrangeProducts:exports.ScreenName.SelectedProducts)},buttonText:v?`${oe}/${v} products selected`:`${oe} products selected`,buttonType:["rearrange","view"].includes(W)?"tertiaryGray":"tertiary",disabled:["rearrange","view"].includes(W)}):t.jsx(s.Button,{disabled:!0,buttonText:v?`${oe}/${v} products selected`:`${oe} products selected`,buttonType:"tertiaryGray"}),hideCrossButton:Ce},{children:[be,Ce&&ge?t.jsx(u.ProductInfoOverlay,{productData:ge,outOfStockAction:O,onClose:()=>{xe(!1)}}):t.jsx(t.Fragment,{})]}))})};
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e,t=require("react/jsx-runtime"),o=require("../../assets/icons/search.svg.js"),c=require("react"),r=require("../../constants/Theme.js"),s=require("../button/Button.js"),n=require("../input/Input.js"),l=require("../modals/styledModal.js"),i=require("../spinner/Spinner.js"),a=require("../tag/Tag.js"),d=require("./collectionScreen.js"),u=require("./productInfoOverlay.js"),h=require("./productScreen.js"),p=require("./rearrangeScreen.js"),S=require("./reducers.js"),C=require("./searchScreen.js"),x=require("./selectedScreen.js"),g=require("./style.js"),j=require("./type.js");exports.ScreenName=void 0,(e=exports.ScreenName||(exports.ScreenName={})).Collections="collections",e.RearrangeProducts="rearrange",e.SelectedProducts="view",e.SearchProducts="searchProducts",e.Products="products";exports.ProductPickerModal=e=>{const{storeId:y,selectedItems:b,onClose:m,visible:f,zIndex:P,exactLimit:v,limit:k,hideCollectionCheckbox:I,hideProductCheckbox:F,outOfStockAction:O=j.OUT_OF_STOCK_ACTION.BLUR,hideVariantCheckbox:R,selectProductsFromCustomCollection:T,hideSelectionCount:q,title:D,width:E,renderWithoutModal:w,onClickSave:N,pickerType:A,hideProductVariants:B=!1,startupScreen:M=exports.ScreenName.Collections,rearrangeEnabled:$,selectSingleItem:L=!1,showProductDetails:V}=e,[_,z]=c.useReducer(S.collectionsReducer,{}),[W,G]=c.useState([exports.ScreenName.Collections,exports.ScreenName.RearrangeProducts].includes(M)?M:exports.ScreenName.Collections),[H,K]=c.useState("grid"),[U,Y]=c.useState(""),[J,Q]=c.useState(""),[X,Z]=c.useState(0),[ee,te]=c.useState(!1),[oe,ce]=c.useState(0),[re,se]=c.useState(""),[ne,le]=c.useState(!1),[ie,ae]=c.useState(!1),[de,ue]=c.useReducer(S.searchReducer,{collections:{},products:{}}),[he,pe]=c.useReducer(S.selectedColectionsReducer,Object.keys(b).length>0?b:{}),Se=c.useRef(null),[Ce,xe]=c.useState(!1),[ge,je]=c.useState();c.useEffect((()=>{te(!0),ae(!0),e.collectionFetcher(X,y).then((e=>{z({type:"fetched",data:(null==e?void 0:e.collections)||{}}),te(!1),Z((e=>e+1)),ae(!1)})).catch()}),[]),c.useEffect((()=>{let e=0;Object.keys(he||[]).forEach((t=>{var o;Object.keys((null===(o=he[t])||void 0===o?void 0:o.products)||[]).forEach((o=>{var c,r;Object.keys((null===(r=null===(c=he[t].products)||void 0===c?void 0:c[o])||void 0===r?void 0:r.variants)||[]).forEach((()=>{e+=1}))}))})),ce(e)})),c.useEffect((()=>{J&&(te(!0),e.productFetcher(J,y).then((e=>{Object.keys(e).length&&z({type:"productsFetched",data:{collectionId:J,products:e}}),te(!1)})).catch())}),[J]),c.useEffect((()=>{const t=setTimeout((()=>{"rearrange"!==W&&(re.length?(le(!0),e.searchFetcher(y,re).then((e=>{"collections"in e&&"products"in e?(ue({type:"set",data:e}),z({type:"searched",data:e.collections})):(ue({type:"set",data:{collections:{},products:e}}),z({type:"searched",data:e})),G("searchProducts"),te(!1),le(!1)}))):G("collections"))}),800);return()=>clearTimeout(t)}),[re]),c.useEffect((()=>{N&&(e.onAdd(he,oe),ye())}),[N]),c.useEffect((()=>{L&&Object.keys(he||{}).length&&oe&&(e.onAdd(he,oe),ye())}),[L,he,oe]);const ye=()=>{pe({type:"reset",data:{}})},be=t.jsxs(g.ContainerStyle,{children:[e.postHeader&&t.jsx("div",Object.assign({style:{padding:"0 24px"}},{children:e.postHeader})),!e.hideGlobalSearch&&t.jsx(t.Fragment,{children:("collections"===W||"searchProducts"===W)&&t.jsx("div",Object.assign({style:{padding:w?"8px 16px":"12px 24px",borderBottom:"1px solid #E0E0E0"}},{children:t.jsx(n.Input,{noKeyDownChange:!0,noErrorHint:!0,rightIcon:{icon:()=>ne?t.jsx(i.Spinner,{size:"small",color:r.COLORS.content.primary}):t.jsx(o.default,{})},id:"listInput",height:"24px",type:"text",value:re,onChangeText:e=>{e.length&&e.trim().length?se(e):se("")}})}))}),t.jsxs(g.ScrollContainerStyle,Object.assign({ref:Se,screenName:W},{children:["collections"===W&&t.jsx(d.CollectionsScreen,{customCollectionRestriction:e.customCollectionRestriction,dataLoading:ie,collections:_,selectedCollectionsDispatch:pe,setCollectionId:Y,setSelectedCollectionId:Q,setScreen:G,selectedCollections:he,collectionFetcher:e.collectionFetcher,storeId:y,collectionsDispatch:z,setSaveDisabled:te,pagingControls:{curPage:X,setCurPage:Z},hideCollectionCheckbox:I,renderWithoutModal:w,pickerType:A}),"products"===W&&U&&t.jsx(S.CollectionIdContext.Provider,Object.assign({value:U},{children:t.jsx(h.ProductsScreen,{hideInCollectionSearch:e.hideInCollectionSearch,customCollectionRestriction:e.customCollectionRestriction,productFetcher:e.productFetcher,setScreen:G,storeId:y,data:_[U],collectionsDispatch:z,selectedCollectionsDispatch:pe,selectedData:he,setSaveDisabled:te,searchInCollectionFetcher:e.searchInCollectionFetcher,hideProductCheckbox:F,outOfStockAction:O,hideVariantCheckbox:R,selectProductsFromCustomCollection:T,renderWithoutModal:w,pickerType:A,hideProductVariants:B,fbStatusFetcher:e.fbStatusFetcher,onProductDetailClick:e=>{xe(!0),je(e)},showProductDetailInfoIcon:V})})),"view"===W&&t.jsx(x.SelectedScreen,{selectedCollections:he||{},selectedCollectionsDispatch:pe,setScreen:G,collections:_,outOfStockAction:O,storeId:y,fbStatusFetcher:e.fbStatusFetcher}),"rearrange"===W&&t.jsx(p.RearrangeScreen,{selectedCollections:he||{},selectedCollectionsDispatch:pe,setScreen:G,outOfStockAction:O,rearrangeViewType:"grid"===H?"list":"grid",scrollContainerRef:Se,storeId:y,fbStatusFetcher:e.fbStatusFetcher}),"searchProducts"===W&&t.jsx(C.SearchScreen,{customCollectionRestriction:e.customCollectionRestriction,selectedCollections:he||{},searchedCollections:de||{},searchedCollectionsDispatch:ue,selectedCollectionsDispatch:pe,setScreen:G,collections:_,onBackPress:()=>{se(""),ue({type:"set",data:{collections:{},products:{}}})},pickerType:A,hideProductCheckbox:F,hideProductVariants:B,hideVariantCheckbox:R,storeId:y,fbStatusFetcher:e.fbStatusFetcher,setCollectionId:Y,setSelectedCollectionId:Q,renderWithoutModal:w,hideCollectionCheckbox:I})]}))]});return t.jsx(t.Fragment,{children:w?be:t.jsxs(l.StyledModal,Object.assign({zIndex:P,open:f,onClose:()=>{null==m||m(),ye()},headingTitle:D||("collections"===W||"products"===W?"Select Products":"view"===W?"Selected Products":"searchProducts"===W?"Searched Products":"rearrange"===W?"Rearrange Products":void 0),footerShadow:!0,centralContainerStyles:{width:E||"600px"},headerRightCustomElement:"rearrange"===W?(console.log("ignore:",K),t.jsx(t.Fragment,{})):t.jsx(t.Fragment,{}),footerContainerStyle:e.stickyFooter?{position:"absolute",bottom:0,left:0,width:"100%",zIndex:9,background:r.COLORS.surface.standard}:void 0,primaryButton:{buttonText:ee?"Loading...":W===exports.ScreenName.RearrangeProducts?"Done":"Add",disabled:ee||oe<1||v&&oe<v||!v&&k&&oe>k||!1,onClick:()=>{e.onAdd(he,oe),ye()}},wrapperStyle:e.stickyFooter?{height:"calc(100vh - 168px)"}:void 0,footerLeftCustomElement:q?t.jsx(t.Fragment,{}):v&&oe>v?t.jsx(a.Tag,{tagText:`You can only select ${v} products`,type:"negative"}):k&&oe>k?t.jsx(a.Tag,{tagText:`You can only select ${k} products`,type:"negative"}):oe>0?t.jsx(s.Button,{onClick:()=>{G($?exports.ScreenName.RearrangeProducts:exports.ScreenName.SelectedProducts)},buttonText:v?`${oe}/${v} products selected`:`${oe} products selected`,buttonType:["rearrange","view"].includes(W)?"tertiaryGray":"tertiary",disabled:["rearrange","view"].includes(W)}):t.jsx(s.Button,{disabled:!0,buttonText:v?`${oe}/${v} products selected`:`${oe} products selected`,buttonType:"tertiaryGray"}),hideCrossButton:Ce},{children:[be,Ce&&ge?t.jsx(u.ProductInfoOverlay,{productData:ge,outOfStockAction:O,onClose:()=>{xe(!1)}}):t.jsx(t.Fragment,{})]}))})};
@@ -1,4 +1,4 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),t=require("styled-components"),o=require("../../constants/Theme.js"),r=require("../../assets/icons/cross.svg.js"),i=require("../icon-button/IconButton.js"),a=require("../shimmer-image/ShimmerImage.js"),s=require("../TypographyStyle.js"),d=require("./ProductPickerTag.js");function n(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var l=n(t);const c=t=>{var o;const r=void 0===t.productData.variants;return e.jsxs(f,{children:[e.jsx(g,{children:e.jsx(a.ShimmerImage,{imageUrl:t.productData.image,width:"200px",height:200,borderRadius:4})}),e.jsxs(h,{children:[e.jsx(s.TitleSmall,Object.assign({style:{display:"flex"}},{children:t.productData.name})),e.jsx(s.BodyCaption,{style:{display:"flex",flexDirection:"column"},dangerouslySetInnerHTML:{__html:null!==(o=t.productData.description)&&void 0!==o?o:""}}),e.jsx(d.ProductPickerTag,{isVariant:r,data:t.productData,outOfStockAction:t.outOfStockAction})]})]})},u=l.default.div`
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),t=require("styled-components"),o=require("../../constants/Theme.js"),r=require("../../assets/icons/cross.svg.js"),i=require("../icon-button/IconButton.js"),a=require("../shimmer-image/ShimmerImage.js"),s=require("../TypographyStyle.js"),d=require("./ProductPickerTag.js");function n(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var l=n(t);const c=t=>{var o;const r=void 0===t.productData.variants;return e.jsxs(f,{children:[e.jsx(g,{children:e.jsx(a.ShimmerImage,{imageUrl:t.productData.image,width:"200px",height:200,borderRadius:4})}),e.jsxs(h,{children:[e.jsx(s.TitleSmall,Object.assign({style:{display:"flex"}},{children:t.productData.name})),e.jsx(s.BodyCaption,{className:"overlay-description",dangerouslySetInnerHTML:{__html:null!==(o=t.productData.description)&&void 0!==o?o:""}}),e.jsx(d.ProductPickerTag,{isVariant:r,data:t.productData,outOfStockAction:t.outOfStockAction})]})]})},u=l.default.div`
2
2
  display: flex;
3
3
  flex: 1;
4
4
  background: rgba(0, 0, 0, 0.5);
@@ -8,6 +8,14 @@
8
8
  position: absolute;
9
9
  bottom: 0;
10
10
  z-index: 10;
11
+
12
+ .overlay-description {
13
+ display: flex;
14
+ flex-direction: column;
15
+ max-height: 300px;
16
+ overflow-y: auto;
17
+ word-break: break-word;
18
+ }
11
19
  `,p=l.default.div`
12
20
  display: flex;
13
21
  flex: 1;
@@ -1,5 +1,7 @@
1
1
  export declare const ContainerStyle: import("styled-components").StyledComponent<"div", any, {}, never>;
2
- export declare const ScrollContainerStyle: import("styled-components").StyledComponent<"div", any, {}, never>;
2
+ export declare const ScrollContainerStyle: import("styled-components").StyledComponent<"div", any, {
3
+ screenName: string;
4
+ }, never>;
3
5
  export declare const CollectionCardStyle: import("styled-components").StyledComponent<"div", any, {
4
6
  isDisabled: boolean;
5
7
  isActive: boolean;
@@ -1,9 +1,9 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("styled-components"),t=require("../../constants/Theme.js");function i(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var o=i(e);const r=o.default.div`
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("styled-components"),t=require("../../constants/Theme.js"),i=require("./modal.js");function o(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var r=o(e);const l=r.default.div`
2
2
  display: flex;
3
3
  background-color: white;
4
4
  height: 600px;
5
5
  flex-direction: column;
6
- `,l=o.default.div`
6
+ `,n=r.default.div`
7
7
  overflow-y: scroll;
8
8
  overflow-x: hidden;
9
9
 
@@ -13,10 +13,10 @@
13
13
  }
14
14
 
15
15
  ::-webkit-scrollbar-thumb {
16
- background-color: #888;
16
+ background-color: ${e=>e.screenName!==i.ScreenName.RearrangeProducts?"#888":"#fff"};
17
17
  border-radius: 8px;
18
18
  }
19
- `,n=o.default.div`
19
+ `,d=r.default.div`
20
20
  height: 64px;
21
21
  background-color: ${e=>e.isDisabled?"#F0F0F0":e.isActive?t.COLORS.background.positive.light:"white"};
22
22
  border-bottom: 1px solid #e0e0e0;
@@ -30,17 +30,17 @@
30
30
  cursor: pointer;
31
31
  background-color: ${t.COLORS.surface.hovered};
32
32
  }
33
- `,d=o.default.div`
33
+ `,a=r.default.div`
34
34
  display: flex;
35
35
  flex-direction: row;
36
36
  justify-content: center;
37
37
  align-items: center;
38
38
  column-gap: 18px;
39
- `,a=o.default.div`
39
+ `,c=r.default.div`
40
40
  display: flex;
41
41
  flex-direction: column;
42
42
  justify-content: center;
43
- `,p=o.default.div`
43
+ `,p=r.default.div`
44
44
  display: flex;
45
45
  flex-direction: row;
46
46
  max-height: 32px;
@@ -53,14 +53,14 @@
53
53
  position: sticky;
54
54
  top: 0;
55
55
  z-index: 10;
56
- `,c=o.default.div`
56
+ `,s=r.default.div`
57
57
  display: flex;
58
58
  flex-direction: row;
59
59
  column-gap: 16px;
60
60
  padding: 12px 16px;
61
61
  border-bottom: 1px solid #e0e0e0;
62
62
  align-items: center;
63
- `,x=o.default.div`
63
+ `,x=r.default.div`
64
64
  min-height: 64px;
65
65
  background-color: ${e=>e.isActive?t.COLORS.background.positive.light:"white"};
66
66
  border-bottom: 1px solid #e0e0e0;
@@ -75,7 +75,7 @@
75
75
  cursor: pointer;
76
76
  background-color: ${t.COLORS.surface.hovered};
77
77
  }
78
- `,s=o.default.div`
78
+ `,f=r.default.div`
79
79
  display: flex;
80
80
  flex-direction: row;
81
81
  max-height: 32px;
@@ -87,10 +87,10 @@
87
87
  position: sticky;
88
88
  top: 0;
89
89
  z-index: 10;
90
- `,u=o.default.div`
90
+ `,u=r.default.div`
91
91
  display: flex;
92
92
  flex-direction: column;
93
- `,f=o.default.div`
93
+ `,g=r.default.div`
94
94
  min-height: 72px;
95
95
  background: white;
96
96
  padding: 12px 16px;
@@ -111,14 +111,14 @@
111
111
  flex-direction: column;
112
112
  gap: 2px;
113
113
  }
114
- `,g=o.default.div`
114
+ `,y=r.default.div`
115
115
  height: 72px;
116
116
  width: 72px;
117
117
  display: flex;
118
118
  align-items: center;
119
119
  justify-content: center;
120
120
  margin: 16px;
121
- `;o.default.div`
121
+ `;r.default.div`
122
122
  display: flex;
123
123
  width: 32px;
124
124
  height: 32px;
@@ -127,4 +127,4 @@
127
127
  align-items: center;
128
128
  border: 1px solid ${t.COLORS.stroke.primary};
129
129
  border-radius: 4px;
130
- `,exports.CollectionCardDetailStyle=a,exports.CollectionCardInfoStyle=d,exports.CollectionCardStyle=n,exports.CollectionNameHolder=u,exports.ContainerStyle=r,exports.ProductCardStyle=x,exports.ProductScreenCollectionCardStyle=c,exports.ProductScreenHeader=p,exports.ScrollContainerStyle=l,exports.SelectedScreenHeader=s,exports.VariantCardGridStyle=g,exports.VariantCardListStyle=f;
130
+ `,exports.CollectionCardDetailStyle=c,exports.CollectionCardInfoStyle=a,exports.CollectionCardStyle=d,exports.CollectionNameHolder=u,exports.ContainerStyle=l,exports.ProductCardStyle=x,exports.ProductScreenCollectionCardStyle=s,exports.ProductScreenHeader=p,exports.ScrollContainerStyle=n,exports.SelectedScreenHeader=f,exports.VariantCardGridStyle=y,exports.VariantCardListStyle=g;
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),r=require("react"),a=require("react-beautiful-dnd"),s=require("../../constants/Theme.js"),t=require("./variant.js");exports.VariantsGrid=r=>{let{selectedVariants:s}=r;return e.jsx(a.Droppable,Object.assign({droppableId:"droppable-horizontal"},{children:r=>e.jsxs("div",Object.assign({},r.droppableProps,{ref:r.innerRef,style:Object.assign(Object.assign({},r.droppableProps.style),{display:"flex"})},{children:[e.jsx(a.Droppable,Object.assign({droppableId:"droppable-vertical",direction:"horizontal"},{children:r=>e.jsxs("div",Object.assign({},r.droppableProps,{ref:r.innerRef,style:Object.assign(Object.assign({},r.droppableProps.style),{display:"flex",flexWrap:"wrap",flexDirection:"row"})},{children:[s.map(((r,s)=>e.jsx(a.Draggable,Object.assign({draggableId:`${r.productId}-${r.variantId}`,index:s},{children:(a,s)=>e.jsxs("div",Object.assign({ref:a.innerRef},a.draggableProps,a.dragHandleProps,{children:[e.jsx(t.VariantCardGridView,{data:r}),a.placeholder]}))}),`${r.productId}-${r.variantId}`))),r.placeholder]}))})),r.placeholder]}))}))},exports.VariantsList=i=>{let{selectedVariants:n,setSelectedVariants:d,selectedCollectionsDispatch:l,outOfStockAction:o}=i;const[p,c]=r.useState(-1);function b(e){if(null==e?void 0:e.transform){const r=`translate(0px, ${e.transform.split(",").pop()}`;return Object.assign(Object.assign({},e),{transform:r})}return e}return e.jsx(a.Droppable,Object.assign({droppableId:"droppable-list"},{children:(r,i)=>e.jsxs("div",Object.assign({},r.droppableProps,{ref:r.innerRef,style:Object.assign({backgroundColor:s.COLORS.surface.subdued,padding:"0.05px",height:n.length<8?"550px":"100%"},r.droppableProps.style)},{children:[n.map(((r,i)=>e.jsx("div",Object.assign({style:{background:s.COLORS.surface.hovered,margin:"5px",boxShadow:i===p?"0px 4px 12px rgba(0, 0, 0, 0.12)":""},onMouseEnter:()=>c(i),onMouseLeave:()=>c(-1)},{children:e.jsx(a.Draggable,Object.assign({draggableId:`${r.productId}-${r.variantId}`,index:i},{children:(a,s)=>e.jsx("div",Object.assign({ref:a.innerRef},a.draggableProps,a.dragHandleProps,{style:b(Object.assign(Object.assign({},a.draggableProps.style),a.draggableSnapshot))},{children:e.jsx(t.VariantCardListView,{data:r,selectedCollectionsDispatch:l,onDelete:()=>{const e=n.slice();e[i].displayOrder=null,e.splice(i,1),d(e)},outOfStockAction:o},`${r.productId}-${r.variantId}`)}))}),`${r.productId}-${r.variantId}`)}),`${r.productId}-${r.variantId}`))),r.placeholder&&i.isDraggingOver?e.jsx("div",Object.assign({style:{background:s.COLORS.surface.hovered,margin:"5px"}},{children:r.placeholder})):null]}))}))};
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),r=require("react"),a=require("react-beautiful-dnd"),s=require("../../constants/Theme.js"),t=require("./variant.js");exports.VariantsGrid=r=>{let{selectedVariants:s}=r;return e.jsx(a.Droppable,Object.assign({droppableId:"droppable-horizontal"},{children:r=>e.jsxs("div",Object.assign({},r.droppableProps,{ref:r.innerRef,style:Object.assign(Object.assign({},r.droppableProps.style),{display:"flex"})},{children:[e.jsx(a.Droppable,Object.assign({droppableId:"droppable-vertical",direction:"horizontal"},{children:r=>e.jsxs("div",Object.assign({},r.droppableProps,{ref:r.innerRef,style:Object.assign(Object.assign({},r.droppableProps.style),{display:"flex",flexWrap:"wrap",flexDirection:"row"})},{children:[s.map(((r,s)=>e.jsx(a.Draggable,Object.assign({draggableId:`${r.productId}-${r.variantId}`,index:s},{children:(a,s)=>e.jsxs("div",Object.assign({ref:a.innerRef},a.draggableProps,a.dragHandleProps,{children:[e.jsx(t.VariantCardGridView,{data:r}),a.placeholder]}))}),`${r.productId}-${r.variantId}`))),r.placeholder]}))})),r.placeholder]}))}))},exports.VariantsList=i=>{let{selectedVariants:n,setSelectedVariants:d,selectedCollectionsDispatch:l,outOfStockAction:o}=i;const[p,c]=r.useState(-1);function b(e){if(null==e?void 0:e.transform){const r=`translate(0px, ${e.transform.split(",").pop()}`;return Object.assign(Object.assign({},e),{transform:r})}return e}return e.jsx(a.Droppable,Object.assign({droppableId:"droppable-list"},{children:(r,i)=>e.jsxs("div",Object.assign({},r.droppableProps,{ref:r.innerRef,style:Object.assign({backgroundColor:s.COLORS.surface.subdued,padding:"0.05px",height:n.length<8?"550px":"100%",overflow:"auto"},r.droppableProps.style)},{children:[n.map(((r,i)=>e.jsx("div",Object.assign({style:{background:s.COLORS.surface.hovered,margin:"5px",boxShadow:i===p?"0px 4px 12px rgba(0, 0, 0, 0.12)":""},onMouseEnter:()=>c(i),onMouseLeave:()=>c(-1)},{children:e.jsx(a.Draggable,Object.assign({draggableId:`${r.productId}-${r.variantId}`,index:i},{children:(a,s)=>e.jsx("div",Object.assign({ref:a.innerRef},a.draggableProps,a.dragHandleProps,{style:b(Object.assign(Object.assign({},a.draggableProps.style),a.draggableSnapshot))},{children:e.jsx(t.VariantCardListView,{data:r,selectedCollectionsDispatch:l,onDelete:()=>{const e=n.slice();e[i].displayOrder=null,e.splice(i,1),d(e)},outOfStockAction:o},`${r.productId}-${r.variantId}`)}))}),`${r.productId}-${r.variantId}`)}),`${r.productId}-${r.variantId}`))),r.placeholder&&i.isDraggingOver?e.jsx("div",Object.assign({style:{background:s.COLORS.surface.hovered,margin:"5px"}},{children:r.placeholder})):null]}))}))};
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),t=require("lodash"),n=require("react"),o=require("../../template-preview/models/WhatsAppTemplate.js"),i=require("../context/templateModalContext.js"),s=require("../custom-hooks/useAdditionalVariables.js"),l=require("../utils/getDataFromTemplateComponent.js"),a=require("./BackTrackComponent.js"),d=require("./DiscountCodeComponent.js"),r=require("./EditMediaV2.style.js"),u=require("./EditWhatsAppTemplateMediaV2.js"),c=require("./VariableConnector.js"),p=require("./VariableConnectorsPanel.js"),m=require("./VariableConnectorWhatsApp.js"),v=require("./VariableEditorHeader.js"),b=require("./WhatsAppTemplateCardButtonV2.js");exports.default=g=>{let{template:j,onTemplateChange:f,whatsappSpecificPickerMeta:C,showVariableModal:O,variableList:h,variableListForImage:x,discountCode:T,setDiscountCode:y}=g;var V,B,E,L,U,k,q,D,I,w,R,A,P,S;const N=j.isCarouselType,{originalVariableList:M,pod:_,extras:Q,selectedCarouselIndex:H,isProductCarouselType:Y}=i.useTemplateModalContext(),{descriptionComponents:F,urlBtns:K,qrbBtns:W,imageComponent:$,bodyVariables:X,headerVariables:z}=l.getAllDataFromTemplateComponent(j),[G,J]=n.useState(!1),[Z,ee]=n.useState(-1===H?{descriptionComponents:F,urlBtns:K,qrbBtns:W,imageComponent:$,bodyVariables:X,headerVariables:z}:{}),[te,ne]=n.useState(!1);function oe(e,n,o){var i,s,l,a,d,r,u,c,p,m;const v=null!=H&&H>-1?{components:null===(i=Object.assign({},j).components[1].cards)||void 0===i?void 0:i[H].components,mapping:null===(s=Object.assign({},j).mapping.cards)||void 0===s?void 0:s[H]}:Object.assign({},j),b=t.cloneDeep(v),g="custom"===n&&"string"==typeof e,C=g?e:"string"!=typeof e?e.defaultValue:"";if(null!=H&&H>-1&&Y){const n=Object.assign({},j).components.map((e=>{var t;return"CAROUSEL"===e.type?Object.assign(Object.assign({},e),{cards:null===(t=e.cards)||void 0===t?void 0:t.map((e=>Object.assign(Object.assign({},e),{components:e.components.map((e=>{var t,n,i;if("BUTTONS"===e.type){const s=null===(t=e.buttons)||void 0===t?void 0:t.filter((e=>"URL"===e.type));let l=null!==(n=null==s?void 0:s[o])&&void 0!==n?n:{};l=Object.assign(Object.assign({},l),{url:"https://d.bik.ai/{{1}}",example:[C]});const a=null===(i=e.buttons)||void 0===i?void 0:i.map((e=>"URL"===e.type&&(null==e?void 0:e.text)===(null==l?void 0:l.text)?l:e));return Object.assign(Object.assign({},e),{buttons:a})}return e}))})))}):e})),i=null===(a=null===(l=Object.assign({},j).mapping)||void 0===l?void 0:l.cards)||void 0===a?void 0:a.map((t=>{var n;return Object.assign(Object.assign({},t),{buttons:null===(n=null==t?void 0:t.buttons)||void 0===n?void 0:n.map((t=>g?"((customBtnPlaceholder))":"string"!=typeof e?e.placeHolder:""))})})),s=t.cloneDeep(j);return s.components=n,s.mapping.cards=i,void(null==f||f(Object.assign({},s)))}const O=null==b?void 0:b.components.findIndex((e=>"BUTTONS"===e.type));if(void 0!==O&&O>-1){const t=null===(d=null==b?void 0:b.components[O].buttons)||void 0===d?void 0:d.filter((e=>"URL"===e.type));if((null==t?void 0:t.length)>0){const i="custom"===n&&"string"==typeof e,s=i?e:"string"!=typeof e?e.defaultValue:"";let l=t[o];l=Object.assign(Object.assign({},l),{url:"https://d.bik.ai/{{1}}",example:[s]});const a=[...null!==(c=null===(u=null===(r=b.components)||void 0===r?void 0:r[O])||void 0===u?void 0:u.buttons)&&void 0!==c?c:[]].map((e=>"URL"===e.type&&(null==e?void 0:e.text)===(null==l?void 0:l.text)?l:e)),d=Object.assign(Object.assign({},b.components[O]),{buttons:a}),m=null===(p=b.mapping)||void 0===p?void 0:p.buttons;m&&m.length>0&&(m[o]=i?"((customBtnPlaceholder))":"string"!=typeof e?e.placeHolder:"");const v=Object.assign(Object.assign({},b.mapping),{buttons:m});b.mapping=v;const g=[...b.components];g[O]=d,b.components=g}}if("string"!=typeof e){"checkout.checkoutUrl"===(null===(m=e.placeHolder)||void 0===m?void 0:m.slice(2,-2))?J(!0):(J(!1),null==y||y(""))}if(null!=H&&H>-1){const e=t.cloneDeep(j);e.components[1].cards[H].components=b.components,e.mapping.cards[H]=b.mapping,null==f||f(Object.assign({},e))}else null==f||f(b)}function ie(e,n,o){var i,s,l,a,d,r;const u=null!=H&&H>-1?{components:null===(i=Object.assign({},j).components[1].cards)||void 0===i?void 0:i[H].components,mapping:null===(s=Object.assign({},j).mapping.cards)||void 0===s?void 0:s[H]}:Object.assign({},j);if(null!=H&&H>-1&&Y){const n=Object.assign({},j).components.map((t=>{var n;return"CAROUSEL"===t.type?Object.assign(Object.assign({},t),{cards:null===(n=t.cards)||void 0===n?void 0:n.map((t=>Object.assign(Object.assign({},t),{components:t.components.map((t=>{var n,i,s;if("BUTTONS"===t.type){const l=null===(n=t.buttons)||void 0===n?void 0:n.filter((e=>"QUICK_REPLY"===e.type));let a=null!==(i=null==l?void 0:l[o])&&void 0!==i?i:{};a=Object.assign(Object.assign({},a),{flowId:e.flowId,flowName:e.flowName});const d=null===(s=t.buttons)||void 0===s?void 0:s.map((e=>"QUICK_REPLY"===e.type&&(null==e?void 0:e.text)===(null==a?void 0:a.text)?a:e));return Object.assign(Object.assign({},t),{buttons:d})}return t}))})))}):t})),i=t.cloneDeep(j);return i.components=n,void(null==f||f(Object.assign({},i)))}const c=null==u?void 0:u.components.findIndex((e=>"BUTTONS"===e.type));if(void 0!==c&&c>-1){const t=null===(l=null==u?void 0:u.components[c].buttons)||void 0===l?void 0:l.filter((e=>"QUICK_REPLY"===e.type));if(t){let n=t[o];n=Object.assign(Object.assign({},n),{flowId:e.flowId,flowName:e.flowName});const i=[...null!==(r=null===(d=null===(a=u.components)||void 0===a?void 0:a[c])||void 0===d?void 0:d.buttons)&&void 0!==r?r:[]].map((e=>"QUICK_REPLY"===e.type&&(null==e?void 0:e.text)===(null==n?void 0:n.text)?n:e)),s=Object.assign(Object.assign({},u.components[c]),{buttons:i}),l=[...u.components];l[c]=s,u.components=l}}if(null!=H&&H>-1){const e=t.cloneDeep(j);e.components[1].cards[H].components=u.components,null==f||f(Object.assign({},e))}else null==f||f(u)}n.useEffect((()=>{var e,t;if(null===(e=j.mapping.buttons)||void 0===e?void 0:e.find((e=>"checkout.checkoutUrl"===e.slice(2,-2))))J(!0);else{J(!1);const e=null===(t=null==Q?void 0:Q.discountCodeExtra)||void 0===t?void 0:t[1];null==e||e("")}}),[j]),n.useEffect((()=>{var e,t,n,o;if(null!=H&&H>-1){const i={components:null===(t=null===(e=j.components[1])||void 0===e?void 0:e.cards)||void 0===t?void 0:t[H].components,mapping:null===(o=null===(n=null==j?void 0:j.mapping)||void 0===n?void 0:n.cards)||void 0===o?void 0:o[H]},{descriptionComponents:s,urlBtns:a,qrbBtns:d,imageComponent:r,bodyVariables:u,headerVariables:c}=l.getAllDataFromTemplateComponent(i);ee({descriptionComponents:s,urlBtns:a,qrbBtns:d,imageComponent:r,bodyVariables:u,headerVariables:c})}else if(null!=H&&-1===H){const{descriptionComponents:e,urlBtns:t,qrbBtns:n,imageComponent:o,bodyVariables:i,headerVariables:s}=l.getAllDataFromTemplateComponent(j);ee({descriptionComponents:e,urlBtns:t,qrbBtns:n,imageComponent:o,bodyVariables:i,headerVariables:s})}}),[H]),n.useEffect((()=>{var e,t,n,o;if(null!=H&&H>-1&&te){const i={components:null===(t=null===(e=j.components[1])||void 0===e?void 0:e.cards)||void 0===t?void 0:t[H].components,mapping:null===(o=null===(n=null==j?void 0:j.mapping)||void 0===n?void 0:n.cards)||void 0===o?void 0:o[H]},{descriptionComponents:s,urlBtns:a,qrbBtns:d,imageComponent:r,bodyVariables:u,headerVariables:c}=l.getAllDataFromTemplateComponent(i);ee({descriptionComponents:s,urlBtns:a,qrbBtns:d,imageComponent:r,bodyVariables:u,headerVariables:c}),ne(!1)}}),[te]);const se=s.useAdditionalVariables({variableList:h,categoryDisplayName:"Custom Variables",variableDisplayName:"Custom Text",variableValue:"{{custom.text}}"});return e.jsxs(p.Container,Object.assign({style:{flexDirection:"column",width:400,maxHeight:460}},{children:[!!Z.imageComponent&&!Y&&e.jsx(r.EditTemplateMediaContainer,{children:e.jsx(u.default,{whatsappSpecificPickerMeta:C,mediaComponent:N?Z.imageComponent:$,updateTemplateImageUrl:function(e,n){var o,i,s,l,a;let d;d=null!=H&&H>-1?{components:null===(i=null===(o=j.components[1])||void 0===o?void 0:o.cards)||void 0===i?void 0:i[H].components,mapping:null===(l=null===(s=null==j?void 0:j.mapping)||void 0===s?void 0:s.cards)||void 0===l?void 0:l[H]}:Object.assign({},j);const r=null===(a=null==d?void 0:d.components)||void 0===a?void 0:a.findIndex((e=>{if("HEADER"===e.type&&"NONE"!==e.format&&"TEXT"!==e.format)return!0}));if(void 0!==r&&r>-1&&(null==d?void 0:d.components[r])){const t=Object.assign(Object.assign({},d.components[r]),{format:n,example:{header_handle:[e]}}),o=[...d.components];o[r]=t,d=Object.assign(Object.assign({},d),{components:o})}if(d.mapping&&(d.mapping=Object.assign(Object.assign({},d.mapping),{header:void 0})),null!=H&&H>-1){const e=t.cloneDeep(j);e.components[1].cards[H].components=d.components,e.mapping.cards[H]=d.mapping,null==f||f(Object.assign({},e)),ne(!0)}else null==f||f(Object.assign({},d))},template:j,variableListForImage:x})}),(Z.bodyVariables.length>0||Z.headerVariables.length>0)&&e.jsx(v.default,{containerStyle:{paddingTop:Z.mediaComponent?24:8},headerText:"Edit variable values",subText:"Edit values for the variables used in template",toolTipInfo:"Variables are placeholder texts which can either be filled through data or custom texts. These can be edited through the dropdowns below"}),null===(V=Z.descriptionComponents)||void 0===V?void 0:V.map(((t,n)=>e.jsx(m.default,{originalVariableList:null!=H&&H>-1?M.cards[H]:M,type:t.type,descriptionComponent:t.component,showVariableModal:O,variableList:h},n))),(null===(E=null===(B=null!=H&&H>-1?M.cards[H].buttons:null==M?void 0:M.buttons)||void 0===B?void 0:B.filter((e=>"URL"===e.type)))||void 0===E?void 0:E.length)>0&&e.jsx(v.default,{headerText:"Edit buttons",subText:"Edit the link connected to the CTA button"}),null===(U=null===(L=null!=H&&H>-1?M.cards[H].buttons:null==M?void 0:M.buttons)||void 0===L?void 0:L.filter((e=>_===o.POD.CHATBOT||"URL"===e.type)))||void 0===U?void 0:U.map(((t,n)=>{if("URL"===t.type)return e.jsx(b.default,{variableListIndex:n,CTAoptions:null==C?void 0:C.CTAoptions,button:t,currentVariableList:null!=H&&H>-1?Object.assign({},M.cards[H]):Object.assign({},M),updateSelectedURLTemplateBtn:oe,variableList:h},`${n}_${H}`)})),(null===(q=null===(k=null!=H&&H>-1?M.cards[H].buttons:null==M?void 0:M.buttons)||void 0===k?void 0:k.filter((e=>"QUICK_REPLY"===e.type)))||void 0===q?void 0:q.length)>0&&(_!==o.POD.CHATBOT?e.jsx(v.default,{headerText:"Edit buttons",subText:"Edit the chatflows triggered on clicking the buttons",toolTipInfo:"There is an option to trigger chatflows through the buttons which can keep the user engaged"}):e.jsx(a.BackTrackComponent,{backTrackMessage:null===(D=null==Q?void 0:Q.backTrackExtra)||void 0===D?void 0:D[0],setBackTrackMessage:null===(I=null==Q?void 0:Q.backTrackExtra)||void 0===I?void 0:I[1]})),null===(R=null===(w=null!=H&&H>-1?M.cards[H].buttons:null==M?void 0:M.buttons)||void 0===w?void 0:w.filter((e=>"QUICK_REPLY"===e.type)))||void 0===R?void 0:R.map(((t,n)=>{if("QUICK_REPLY"===t.type)return e.jsx(b.default,{variableListIndex:n,QRBoptions:null==C?void 0:C.QRBoptions,button:t,currentVariableList:null!=H&&H>-1?Object.assign({},M.cards[H]):Object.assign({},M),updateSelectedQRBTemplateBtn:ie},`${n}_${H}`)})),_===o.POD.CHATBOT&&G&&e.jsx(d.DiscountCodeComponent,{discountCode:null===(A=null==Q?void 0:Q.discountCodeExtra)||void 0===A?void 0:A[0],setDiscountCode:null===(P=null==Q?void 0:Q.discountCodeExtra)||void 0===P?void 0:P[1],variableList:h}),null===(S=null!=H&&H>-1?M.cards[H].buttons:null==M?void 0:M.buttons)||void 0===S?void 0:S.map(((t,n)=>{var o,i,s;if("COPY_CODE"===t.type)return e.jsx(c.default,{index:n,variable:{variableName:null!==(o=t.text)&&void 0!==o?o:"Copy Code",updatedValue:null!==(i=t.buttonVariable)&&void 0!==i?i:"",type:"string",isEditableVariable:!0,index:null!==(s=t.index)&&void 0!==s?s:0},showVariableModal:!0,variableList:se,componentType:"BUTTONS"},n)}))]}))};
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),t=require("lodash"),n=require("react"),o=require("../../template-preview/models/WhatsAppTemplate.js"),i=require("../context/templateModalContext.js"),s=require("../custom-hooks/useAdditionalVariables.js"),l=require("../utils/getDataFromTemplateComponent.js"),a=require("./BackTrackComponent.js"),d=require("./DiscountCodeComponent.js"),r=require("./EditMediaV2.style.js"),u=require("./EditWhatsAppTemplateMediaV2.js"),c=require("./VariableConnector.js"),p=require("./VariableConnectorsPanel.js"),m=require("./VariableConnectorWhatsApp.js"),v=require("./VariableEditorHeader.js"),b=require("./WhatsAppTemplateCardButtonV2.js");exports.default=g=>{let{template:j,onTemplateChange:f,whatsappSpecificPickerMeta:C,showVariableModal:O,variableList:h,variableListForImage:T,discountCode:x,setDiscountCode:y}=g;var V,B,E,L,U,k,q,D,I,w,R,A,P,S;const N=j.isCarouselType,{originalVariableList:M,pod:_,extras:H,selectedCarouselIndex:Q,isProductCarouselType:Y}=i.useTemplateModalContext(),{descriptionComponents:F,urlBtns:K,qrbBtns:W,imageComponent:$,bodyVariables:X,headerVariables:z}=l.getAllDataFromTemplateComponent(j),[G,J]=n.useState(!1),[Z,ee]=n.useState(-1===Q?{descriptionComponents:F,urlBtns:K,qrbBtns:W,imageComponent:$,bodyVariables:X,headerVariables:z}:{}),[te,ne]=n.useState(!1);function oe(e,n,o){var i,s,l,a,d,r,u,c,p,m;const v=null!=Q&&Q>-1?{components:null===(i=Object.assign({},j).components[1].cards)||void 0===i?void 0:i[Q].components,mapping:null===(s=Object.assign({},j).mapping.cards)||void 0===s?void 0:s[Q]}:Object.assign({},j),b=t.cloneDeep(v),g="custom"===n&&"string"==typeof e,C=g?e:"string"!=typeof e?e.defaultValue:"";if(null!=Q&&Q>-1&&Y){const n=Object.assign({},j).components.map((e=>{var t;return"CAROUSEL"===e.type?Object.assign(Object.assign({},e),{cards:null===(t=e.cards)||void 0===t?void 0:t.map((e=>Object.assign(Object.assign({},e),{components:e.components.map((e=>{var t,n,i;if("BUTTONS"===e.type){const s=null===(t=e.buttons)||void 0===t?void 0:t.filter((e=>"URL"===e.type));let l=null!==(n=null==s?void 0:s[o])&&void 0!==n?n:{};l=Object.assign(Object.assign({},l),{url:"https://d.bik.ai/{{1}}",example:[C]});const a=null===(i=e.buttons)||void 0===i?void 0:i.map((e=>"URL"===e.type&&(null==e?void 0:e.text)===(null==l?void 0:l.text)?l:e));return Object.assign(Object.assign({},e),{buttons:a})}return e}))})))}):e})),i=null===(a=null===(l=Object.assign({},j).mapping)||void 0===l?void 0:l.cards)||void 0===a?void 0:a.map((t=>{var n;return Object.assign(Object.assign({},t),{buttons:null===(n=null==t?void 0:t.buttons)||void 0===n?void 0:n.map((t=>g?"((customBtnPlaceholder))":"string"!=typeof e?e.placeHolder:""))})})),s=t.cloneDeep(j);return s.components=n,s.mapping.cards=i,void(null==f||f(Object.assign({},s)))}const O=null==b?void 0:b.components.findIndex((e=>"BUTTONS"===e.type));if(void 0!==O&&O>-1){const t=null===(d=null==b?void 0:b.components[O].buttons)||void 0===d?void 0:d.filter((e=>"URL"===e.type));if((null==t?void 0:t.length)>0){const i="custom"===n&&"string"==typeof e,s=i?e:"string"!=typeof e?e.defaultValue:"";let l=t[o];l=Object.assign(Object.assign({},l),{url:"https://d.bik.ai/{{1}}",example:[s]});const a=[...null!==(c=null===(u=null===(r=b.components)||void 0===r?void 0:r[O])||void 0===u?void 0:u.buttons)&&void 0!==c?c:[]].map((e=>"URL"===e.type&&(null==e?void 0:e.text)===(null==l?void 0:l.text)?l:e)),d=Object.assign(Object.assign({},b.components[O]),{buttons:a}),m=null===(p=b.mapping)||void 0===p?void 0:p.buttons;m&&m.length>0&&(m[o]=i?"((customBtnPlaceholder))":"string"!=typeof e?e.placeHolder:"");const v=Object.assign(Object.assign({},b.mapping),{buttons:m});b.mapping=v;const g=[...b.components];g[O]=d,b.components=g}}if("string"!=typeof e){"checkout.checkoutUrl"===(null===(m=e.placeHolder)||void 0===m?void 0:m.slice(2,-2))?J(!0):(J(!1),null==y||y(""))}if(null!=Q&&Q>-1){const e=t.cloneDeep(j);e.components[1].cards[Q].components=b.components,e.mapping.cards[Q]=b.mapping,null==f||f(Object.assign({},e))}else null==f||f(b)}function ie(e,n,o){var i,s,l,a,d,r;const u=null!=Q&&Q>-1?{components:null===(i=Object.assign({},j).components[1].cards)||void 0===i?void 0:i[Q].components,mapping:null===(s=Object.assign({},j).mapping.cards)||void 0===s?void 0:s[Q]}:Object.assign({},j);if(null!=Q&&Q>-1&&Y){const n=Object.assign({},j).components.map((t=>{var n;return"CAROUSEL"===t.type?Object.assign(Object.assign({},t),{cards:null===(n=t.cards)||void 0===n?void 0:n.map((t=>Object.assign(Object.assign({},t),{components:t.components.map((t=>{var n,i,s;if("BUTTONS"===t.type){const l=null===(n=t.buttons)||void 0===n?void 0:n.filter((e=>"QUICK_REPLY"===e.type));let a=null!==(i=null==l?void 0:l[o])&&void 0!==i?i:{};a=Object.assign(Object.assign({},a),{flowId:e.flowId,flowName:e.flowName});const d=null===(s=t.buttons)||void 0===s?void 0:s.map((e=>"QUICK_REPLY"===e.type&&(null==e?void 0:e.text)===(null==a?void 0:a.text)?a:e));return Object.assign(Object.assign({},t),{buttons:d})}return t}))})))}):t})),i=t.cloneDeep(j);return i.components=n,void(null==f||f(Object.assign({},i)))}const c=null==u?void 0:u.components.findIndex((e=>"BUTTONS"===e.type));if(void 0!==c&&c>-1){const t=null===(l=null==u?void 0:u.components[c].buttons)||void 0===l?void 0:l.filter((e=>"QUICK_REPLY"===e.type));if(t){let n=t[o];n=Object.assign(Object.assign({},n),{flowId:e.flowId,flowName:e.flowName});const i=[...null!==(r=null===(d=null===(a=u.components)||void 0===a?void 0:a[c])||void 0===d?void 0:d.buttons)&&void 0!==r?r:[]].map((e=>"QUICK_REPLY"===e.type&&(null==e?void 0:e.text)===(null==n?void 0:n.text)?n:e)),s=Object.assign(Object.assign({},u.components[c]),{buttons:i}),l=[...u.components];l[c]=s,u.components=l}}if(null!=Q&&Q>-1){const e=t.cloneDeep(j);e.components[1].cards[Q].components=u.components,null==f||f(Object.assign({},e))}else null==f||f(u)}n.useEffect((()=>{var e,t;if(null===(e=j.mapping.buttons)||void 0===e?void 0:e.find((e=>"checkout.checkoutUrl"===e.slice(2,-2))))J(!0);else{J(!1);const e=null===(t=null==H?void 0:H.discountCodeExtra)||void 0===t?void 0:t[1];null==e||e("")}}),[j]),n.useEffect((()=>{var e,t,n,o;if(null!=Q&&Q>-1){const i={components:null===(t=null===(e=j.components[1])||void 0===e?void 0:e.cards)||void 0===t?void 0:t[Q].components,mapping:null===(o=null===(n=null==j?void 0:j.mapping)||void 0===n?void 0:n.cards)||void 0===o?void 0:o[Q]},{descriptionComponents:s,urlBtns:a,qrbBtns:d,imageComponent:r,bodyVariables:u,headerVariables:c}=l.getAllDataFromTemplateComponent(i);ee({descriptionComponents:s,urlBtns:a,qrbBtns:d,imageComponent:r,bodyVariables:u,headerVariables:c})}else if(null!=Q&&-1===Q){const{descriptionComponents:e,urlBtns:t,qrbBtns:n,imageComponent:o,bodyVariables:i,headerVariables:s}=l.getAllDataFromTemplateComponent(j);ee({descriptionComponents:e,urlBtns:t,qrbBtns:n,imageComponent:o,bodyVariables:i,headerVariables:s})}}),[Q]),n.useEffect((()=>{var e,t,n,o;if(null!=Q&&Q>-1&&te){const i={components:null===(t=null===(e=j.components[1])||void 0===e?void 0:e.cards)||void 0===t?void 0:t[Q].components,mapping:null===(o=null===(n=null==j?void 0:j.mapping)||void 0===n?void 0:n.cards)||void 0===o?void 0:o[Q]},{descriptionComponents:s,urlBtns:a,qrbBtns:d,imageComponent:r,bodyVariables:u,headerVariables:c}=l.getAllDataFromTemplateComponent(i);ee({descriptionComponents:s,urlBtns:a,qrbBtns:d,imageComponent:r,bodyVariables:u,headerVariables:c}),ne(!1)}}),[te]);const se=s.useAdditionalVariables({variableList:h,categoryDisplayName:"Custom Variables",variableDisplayName:"Custom Text",variableValue:"{{custom.text}}"});return e.jsxs(p.Container,Object.assign({style:{flexDirection:"column",width:400,maxHeight:460}},{children:[!!Z.imageComponent&&!Y&&e.jsx(r.EditTemplateMediaContainer,{children:e.jsx(u.default,{whatsappSpecificPickerMeta:C,mediaComponent:N?Z.imageComponent:$,updateTemplateImageUrl:function(e,n){var o,i,s,l,a;let d;d=null!=Q&&Q>-1?{components:null===(i=null===(o=j.components[1])||void 0===o?void 0:o.cards)||void 0===i?void 0:i[Q].components,mapping:null===(l=null===(s=null==j?void 0:j.mapping)||void 0===s?void 0:s.cards)||void 0===l?void 0:l[Q]}:Object.assign({},j);const r=null===(a=null==d?void 0:d.components)||void 0===a?void 0:a.findIndex((e=>{if("HEADER"===e.type&&"NONE"!==e.format&&"TEXT"!==e.format)return!0}));if(void 0!==r&&r>-1&&(null==d?void 0:d.components[r])){const t=Object.assign(Object.assign({},d.components[r]),{format:n,example:{header_handle:[e]}}),o=[...d.components];o[r]=t,d=Object.assign(Object.assign({},d),{components:o})}if(d.mapping&&(d.mapping=Object.assign(Object.assign({},d.mapping),{header:void 0})),null!=Q&&Q>-1){const e=t.cloneDeep(j);e.components[1].cards[Q].components=d.components,e.mapping.cards[Q]=d.mapping,null==f||f(Object.assign({},e)),ne(!0)}else null==f||f(Object.assign({},d))},template:j,variableListForImage:T})}),(Z.bodyVariables.length>0||Z.headerVariables.length>0)&&e.jsx(v.default,{containerStyle:{paddingTop:Z.mediaComponent?24:8},headerText:"Edit variable values",subText:"Edit values for the variables used in template",toolTipInfo:"Variables are placeholder texts which can either be filled through data or custom texts. These can be edited through the dropdowns below"}),null===(V=Z.descriptionComponents)||void 0===V?void 0:V.map(((t,n)=>e.jsx(m.default,{originalVariableList:null!=Q&&Q>-1?M.cards[Q]:M,type:t.type,descriptionComponent:t.component,showVariableModal:O,variableList:h},n))),(null===(E=null===(B=null!=Q&&Q>-1?M.cards[Q].buttons:null==M?void 0:M.buttons)||void 0===B?void 0:B.filter((e=>"URL"===e.type)))||void 0===E?void 0:E.length)>0&&e.jsx(v.default,{headerText:"Edit buttons",subText:"Edit the link connected to the CTA button"}),null===(U=null===(L=null!=Q&&Q>-1?M.cards[Q].buttons:null==M?void 0:M.buttons)||void 0===L?void 0:L.filter((e=>_===o.POD.CHATBOT||"URL"===e.type)))||void 0===U?void 0:U.map(((t,n)=>{if("URL"===t.type)return e.jsx(b.default,{variableListIndex:n,CTAoptions:null==C?void 0:C.CTAoptions,button:t,currentVariableList:null!=Q&&Q>-1?Object.assign({},M.cards[Q]):Object.assign({},M),updateSelectedURLTemplateBtn:oe,variableList:h},`${n}_${Q}`)})),(null===(q=null===(k=null!=Q&&Q>-1?M.cards[Q].buttons:null==M?void 0:M.buttons)||void 0===k?void 0:k.filter((e=>"QUICK_REPLY"===e.type)))||void 0===q?void 0:q.length)>0&&(_!==o.POD.CHATBOT?e.jsx(v.default,{headerText:"Edit buttons",subText:"Edit the chatflows triggered on clicking the buttons",toolTipInfo:"There is an option to trigger chatflows through the buttons which can keep the user engaged"}):e.jsx(a.BackTrackComponent,{backTrackMessage:null===(D=null==H?void 0:H.backTrackExtra)||void 0===D?void 0:D[0],setBackTrackMessage:null===(I=null==H?void 0:H.backTrackExtra)||void 0===I?void 0:I[1]})),null===(R=null===(w=null!=Q&&Q>-1?M.cards[Q].buttons:null==M?void 0:M.buttons)||void 0===w?void 0:w.filter((e=>"QUICK_REPLY"===e.type)))||void 0===R?void 0:R.map(((t,n)=>{if("QUICK_REPLY"===t.type&&_!==o.POD.CHATBOT)return e.jsx(b.default,{variableListIndex:n,QRBoptions:null==C?void 0:C.QRBoptions,button:t,currentVariableList:null!=Q&&Q>-1?Object.assign({},M.cards[Q]):Object.assign({},M),updateSelectedQRBTemplateBtn:ie},`${n}_${Q}`)})),_===o.POD.CHATBOT&&G&&e.jsx(d.DiscountCodeComponent,{discountCode:null===(A=null==H?void 0:H.discountCodeExtra)||void 0===A?void 0:A[0],setDiscountCode:null===(P=null==H?void 0:H.discountCodeExtra)||void 0===P?void 0:P[1],variableList:h}),null===(S=null!=Q&&Q>-1?M.cards[Q].buttons:null==M?void 0:M.buttons)||void 0===S?void 0:S.map(((t,n)=>{var o,i,s;if("COPY_CODE"===t.type)return e.jsx(c.default,{index:n,variable:{variableName:null!==(o=t.text)&&void 0!==o?o:"Copy Code",updatedValue:null!==(i=t.buttonVariable)&&void 0!==i?i:"",type:"string",isEditableVariable:!0,index:null!==(s=t.index)&&void 0!==s?s:0},showVariableModal:!0,variableList:se,componentType:"BUTTONS"},n)}))]}))};
@@ -1,10 +1,10 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),t=require("../../../assets/icons/edit.svg.js"),l=require("date-fns"),a=require("lodash"),i=require("react"),n=require("styled-components"),s=require("../../add-variableV2/AddVariableV2SideModal.js"),o=require("../../custom-date-time/CustomDateTime.js"),u=require("../../dropdown/Dropdown.js"),d=require("../../input/Input.js"),r=require("../../product-picker-v2/collectionScreen.js"),c=require("../../template-preview/constants/regexPatterns.js"),p=require("../../template-preview/models/Channels.js"),m=require("../../template-preview/models/WhatsAppTemplate.js"),v=require("../../TypographyStyle.js"),b=require("../../../utils/StringUtils.js"),g=require("../../../constants/Theme.js"),O=require("../context/templateModalContext.js"),j=require("../utils/getVariableNameEmail.js");function x(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var h=x(n);const _=h.default.div`
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),t=require("../../../assets/icons/edit.svg.js"),l=require("date-fns"),a=require("lodash"),n=require("react"),i=require("styled-components"),s=require("../../add-variableV2/AddVariableV2SideModal.js"),o=require("../../custom-date-time/CustomDateTime.js"),u=require("../../dropdown/Dropdown.js"),d=require("../../input/Input.js"),c=require("../../product-picker-v2/collectionScreen.js"),r=require("../../template-preview/constants/regexPatterns.js"),p=require("../../template-preview/models/Channels.js"),m=require("../../template-preview/models/WhatsAppTemplate.js"),v=require("../../TypographyStyle.js"),b=require("../../../utils/StringUtils.js"),g=require("../../../constants/Theme.js"),O=require("../context/templateModalContext.js"),j=require("../utils/getVariableNameEmail.js");function x(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var h=x(i);const y=h.default.div`
2
2
  /* surface/$color-background-warning-light */
3
3
 
4
4
  background: ${e=>e.focused&&e.channel===p.CHANNEL_TYPE.EMAIL?g.COLORS.background.warning.light:"transparent"};
5
5
  border-radius: 4px;
6
6
  padding: 8px 10px;
7
- `,y=h.default.div`
7
+ `,_=h.default.div`
8
8
  position: absolute;
9
9
  top: 0;
10
10
  left: 0;
@@ -13,4 +13,4 @@
13
13
  background-color: rgba(0, 0, 0, 0.1);
14
14
  z-index: 1000;
15
15
  cursor: not-allowed;
16
- `,f={value:"custom_link",label:"Custom URL"},E={value:"custom_text",label:"Custom text"},T={value:"static_expiry",label:"Static Expiry"};exports.Container=_,exports.default=n=>{let{onFocus:x,variable:h,index:A,showVariableModal:C,variableList:N,setShowDiscountCheckBox:P,componentType:S,CTAoptions:V}=n;var k,L,H;const[D,w]=i.useState(!1),[B,Y]=i.useState(""),[q,M]=i.useState([]),[R,U]=i.useState(),[I,W]=i.useState(!1),[$,z]=i.useState(!1),{device:Z,channel:F,isError:G,originalVariableList:K,template:J,templateSelectionTriggered:Q,setTemplate:X,setDisplayContent:ee,setOriginalVariableList:te,globalNormalizedPlaceholders:le,enabledCustomText:ae,pod:ie,selectedCarouselIndex:ne,isProductCarouselType:se,disableEditVariable:oe,disableEditExpiry:ue}=O.useTemplateModalContext();function de(){var e,t;const l=[];let a=[];if(F!==p.CHANNEL_TYPE.MESSAGE||ae){"link"===(null==h?void 0:h.type)?(l.push({label:"",options:[f,E]}),U(f)):"date_time"===(null==h?void 0:h.type)?(l.push({label:"",options:[f,E]}),U(T)):(l.push({label:"",options:[f,E,T]}),U(E));const e=null!=le?le:[];M([...l,...e.map((e=>{var t,l;return Object.assign(Object.assign({},e),{label:b.default.toCapitilize(null===(l=null===(t=e.label)||void 0===t?void 0:t.replace(/([A-Z])/g," $1"))||void 0===l?void 0:l.toLowerCase())})}))]),a=[...l,...e]}else{const e=null!=le?le:[];M([{label:"",options:[E,f]},...e]),a=[{label:"",options:[E,f]},...e]}if((F===p.CHANNEL_TYPE.WHATSAPP||F===p.CHANNEL_TYPE.EMAIL||F===p.CHANNEL_TYPE.MESSAGE)&&h.updatedValue)if(c.placeHolderNamePattern.test(h.updatedValue)&&F===p.CHANNEL_TYPE.WHATSAPP||h.updatedValue.startsWith("{{")&&F!==p.CHANNEL_TYPE.WHATSAPP){const e=function(e,t,l){var a;let i={label:"",value:""};const n=l===p.CHANNEL_TYPE.WHATSAPP?e.updatedValue.replace("[[","").replace("]]",""):e.updatedValue.replace("{{","").replace("}}","");if(C){let t=e.updatedValue;if(ie===m.POD.CHATBOT&&"BUTTONS"===S){const l=null==V?void 0:V.filter((t=>t.placeHolder===e.updatedValue));l&&l.length>0&&(t=l[0].label)}i={label:t?t.replace("{{","").replace("}}","").trim().replace("."," "):"",value:null!==(a=e.updatedValue)&&void 0!==a?a:""}}else t.map((e=>{e.options.map((e=>{var t;(null===(t=e.value)||void 0===t?void 0:t.replace("{{","").replace("}}","").trim())===n.trim()&&(i=e)}))}));return i}(h,a,F);e.value&&U(e)}else"date_time"===h.type?(U(T),Y(h.updatedValue),me(null!==(e=h.index)&&void 0!==e?e:0,h.updatedValue)):(null===(t=h.updatedValue)||void 0===t?void 0:t.startsWith("https"))?(U(f),Y(h.updatedValue.split("https://")[1])):(U(E),Y(h.updatedValue))}function re(e,t){var l,a,i;const n=e;Y(""),U(n),F===p.CHANNEL_TYPE.WHATSAPP?"custom_text"!==n.value&&"custom_link"!==n.value&&"static_expiry"!==n.value?(pe(null!==(l=n.value)&&void 0!==l?l:"","string"),null==me||me(null!==(a=h.index)&&void 0!==a?a:0,n.value,!0)):(null==me||me(null!==(i=h.index)&&void 0!==i?i:0,B,!0,n.value),pe("","url"===n.bikPlaceholderType?"link":"string")):"custom_text"!==n.value&&"custom_link"!==n.value?pe(n.value,"url"===n.bikPlaceholderType?"link":"string"):(Y(""),pe("",n.value))}function ce(e,t){var l;Y(t);const a="custom_link"===(null==R?void 0:R.value)&&t?t.includes("https")?t:`https://${t}`:t;pe(a,"static_expiry"===e?"string":e),F===p.CHANNEL_TYPE.WHATSAPP&&(null==me||me(null!==(l=h.index)&&void 0!==l?l:0,a,"custom_link"===e,e))}function pe(e,t){var l,i,n,s;const o="custom_link"===t?"link":"custom_text"===t?"string":t;if(F!==p.CHANNEL_TYPE.WHATSAPP){const a=j.getVariableNameForEmailByIndex(A+1),i=null===document||void 0===document?void 0:document.getElementById("mobile"===Z?"template_html_mobile":"template_html_desktop"),n=F===p.CHANNEL_TYPE.EMAIL?null===(l=null==i?void 0:i.contentWindow)||void 0===l?void 0:l.document.getElementById(a):document.getElementById(a);n&&(n.textContent="custom_text"!==t&&"custom_link"!==t||e?e:h.variableName);const s=K.map(((t,l)=>l===A?Object.assign(Object.assign({},t),{type:o,updatedValue:e}):t));null==te||te(s)}if(F===p.CHANNEL_TYPE.WHATSAPP){if(null!=ne&&ne>-1&&se){const t=Object.assign({},K).cards.map(((t,l)=>{var a;return Object.assign(Object.assign({},t),{body:null===(a=t.body)||void 0===a?void 0:a.map(((t,l)=>A===l?Object.assign(Object.assign({},t),{type:o,updatedValue:e}):t))})}));return void(null==te||te((e=>Object.assign(Object.assign({},e),{cards:t}))))}const l=null!=ne&&ne>-1?K.cards[ne]:K;let u=l.body,d=l.header,r=l.buttons;if("BODY"===S?u=null===(i=l.body)||void 0===i?void 0:i.map(((t,l)=>l===A?Object.assign(Object.assign({},t),{type:o,updatedValue:e}):t)):"HEADER"===S?d=null===(n=l.header)||void 0===n?void 0:n.map(((t,l)=>l===A?Object.assign(Object.assign({},t),{type:o,updatedValue:e}):t)):"BUTTONS"===S&&(r=null===(s=l.buttons)||void 0===s?void 0:s.map(((l,a)=>a===A?Object.assign(Object.assign({},l),{buttonVariable:"custom_link"===t?"((customPlaceholderName))":e,example:"COPY_CODE"===l.type?e:[e]}):l))),null!=ne&&ne>-1){const e=a.cloneDeep(K.cards);e[ne]={header:d,body:u,buttons:r},null==te||te((t=>Object.assign(Object.assign({},t),{cards:e})))}else null==te||te((e=>Object.assign(Object.assign({},e),{header:d,body:u,buttons:r})))}}function me(e,t,l,i){var n,s,o,u,d,r,c;if(null!=ne&&ne>-1&&se){const s=Object.assign({},J).components.map((l=>{var a;return"CAROUSEL"===l.type?Object.assign(Object.assign({},l),{cards:null===(a=l.cards)||void 0===a?void 0:a.map((l=>Object.assign(Object.assign({},l),{components:l.components.map((l=>{var a,i,n,s,o;if("BODY"!==l.type)return l;if(null===(i=null===(a=l.example)||void 0===a?void 0:a.body_text)||void 0===i?void 0:i[0]){const a=[...null!==(o=null===(s=null===(n=l.example)||void 0===n?void 0:n.body_text)||void 0===s?void 0:s[0])&&void 0!==o?o:[]];a[e]=t.replace("{{","").replace("}}","").replace("((","").replace("))","");const i=Object.assign(Object.assign({},l.example),{body_text:[a]});return Object.assign(Object.assign({},l),{example:i})}}))})))}):l})),o=a.cloneDeep(J);if(l){const l=null===(n=Object.assign({},J).mapping.cards)||void 0===n?void 0:n.map((l=>{var a;return Object.assign(Object.assign({},l),{body:null===(a=l.body)||void 0===a?void 0:a.map(((l,a)=>e===a?"custom_text"===i?`((editableVariable${a+10}))`:t:l))})}));o.mapping.cards=l}return o.components=s,void(null==X||X(o))}const p=null!=ne&&ne>-1?{components:null===(s=Object.assign({},J).components[1].cards)||void 0===s?void 0:s[ne].components,mapping:null===(o=Object.assign({},J).mapping.cards)||void 0===o?void 0:o[ne]}:Object.assign({},J),m=null===(u=null==p?void 0:p.components)||void 0===u?void 0:u.map((l=>{var a,i,n,s,o,u,d,r,c;const p=Object.assign({},l);if("BODY"===l.type&&"BODY"===S){if(null===(i=null===(a=l.example)||void 0===a?void 0:a.body_text)||void 0===i?void 0:i[0]){const l=[...null!==(o=null===(s=null===(n=p.example)||void 0===n?void 0:n.body_text)||void 0===s?void 0:s[0])&&void 0!==o?o:[]];l[e]=t.replace("{{","").replace("}}","").replace("((","").replace("))","");const a=Object.assign(Object.assign({},p.example),{body_text:[l]});return Object.assign(Object.assign({},p),{example:a})}}else if("HEADER"===l.type&&"HEADER"===S){if(null===(u=l.example)||void 0===u?void 0:u.header_text){const l=[...null!==(r=null===(d=p.example)||void 0===d?void 0:d.header_text)&&void 0!==r?r:[]];l[e]=t.replace("{{","").replace("}}","").replace("((","").replace("))","");const a=Object.assign(Object.assign({},p.example),{header_text:l});return Object.assign(Object.assign({},p),{example:a})}}else{if("BUTTONS"===l.type&&"BUTTONS"===S){const a=null===(c=l.buttons)||void 0===c?void 0:c.map(((l,a)=>a===e?Object.assign(Object.assign({},l),{example:"COPY_CODE"===l.type?t:[t]}):l));return a?Object.assign(Object.assign({},p),{buttons:a}):p}if("limited_time_offer"===l.type&&"limited_time_offer"===S)return Object.assign(Object.assign({},p),{example:Object.assign(Object.assign({},p.example),{limited_time_offer:t})})}return l}));if(p.components=m,l)if("BODY"===S&&(null===(d=null==p?void 0:p.mapping)||void 0===d?void 0:d.body))p.mapping=Object.assign(Object.assign({},p.mapping),{body:p.mapping.body.map(((l,a)=>e===a?"custom_text"===i?`((editableVariable${a+10}))`:t:l))});else if("HEADER"===S&&(null===(r=null==p?void 0:p.mapping)||void 0===r?void 0:r.header))p.mapping=Object.assign(Object.assign({},p.mapping),{header:p.mapping.header.map(((l,a)=>e===a?"custom_text"===i?`((editableVariable${a+20}))`:t:l))});else if("BUTTONS"===S&&(null===(c=null==p?void 0:p.mapping)||void 0===c?void 0:c.buttons)){let l=-1,a=-1;m.forEach((t=>{var i;"BUTTONS"===t.type&&(null===(i=t.buttons)||void 0===i||i.forEach(((t,i)=>{"URL"===t.type&&(l++,i===e&&"URL"==t.type&&(a=l))})))})),p.mapping=Object.assign(Object.assign({},p.mapping),{buttons:p.mapping.buttons.map(((e,l)=>l===a?"custom_link"===i?"((customPlaceholderName))":t:e))})}if(null!=ne&&ne>-1&&J){const e=a.cloneDeep(J);e.components[1].cards[ne].components=p.components,e.mapping.cards[ne]=p.mapping,null==X||X(e)}else null==X||X(Object.assign({},p))}return i.useEffect((()=>{D&&(null==x||x())}),[D]),i.useEffect((()=>{!function(){var e,t,l,a,i;const n="mobile"===Z?"template_html_mobile":"template_html_desktop",s=document.getElementById(n),o=(null!==(a=null===(l=null===(t=null===(e=null==s?void 0:s.contentWindow)||void 0===e?void 0:e.document)||void 0===t?void 0:t.body)||void 0===l?void 0:l.innerHTML)&&void 0!==a?a:"")+(null===(i=null==s?void 0:s.contentWindow)||void 0===i?void 0:i.document.head.innerHTML);F===p.CHANNEL_TYPE.EMAIL&&(null==ee||ee(o))}()}),[Q]),i.useEffect((()=>{de()}),[]),i.useEffect((()=>{de()}),[ne]),i.useEffect((()=>{Z&&R&&B&&setTimeout((()=>{pe("custom_link"===(null==R?void 0:R.value)&&B?B.includes("https")?B:`https://${B}`:B,R.value)}),100)}),[Z]),i.useEffect((()=>{!$&&R&&h.updatedValue&&setTimeout((()=>{pe("custom_link"===(null==R?void 0:R.value)&&h.updatedValue?h.updatedValue.includes("https")?h.updatedValue:`https://${h.updatedValue}`:h.updatedValue,R.value),z(!0)}),100)}),[R]),e.jsxs(_,Object.assign({channel:F,focused:D,onMouseEnter:()=>w(!0),onMouseLeave:()=>w(!1)},{children:[e.jsx("div",Object.assign({style:{marginBottom:8}},{children:e.jsxs(v.BodySecondary,Object.assign({style:{color:G&&!R?g.COLORS.content.negative:g.COLORS.content.primary}},{children:[null===(k=h.variableName)||void 0===k?void 0:k.replace("{{","").replace("}}","")," ","link"===(null==h?void 0:h.type)?"link":"variable"]}))})),e.jsx("div",Object.assign({style:{marginBottom:12}},{children:C?e.jsxs("div",Object.assign({style:{display:"flex",border:"#E0E0E0 1px solid",borderRadius:4,padding:10,justifyContent:(null==R?void 0:R.label)?"space-between":"flex-end"}},{children:[e.jsx(v.BodyPrimary,Object.assign({numberOfLines:1},{children:ie===m.POD.CHATBOT?["static_expiry","custom_text"].includes(null!==(L=null==R?void 0:R.value)&&void 0!==L?L:"")?null==R?void 0:R.label:null==R?void 0:R.value:r.truncate(null!==(H=null==R?void 0:R.label)&&void 0!==H?H:"",20,!0)})),oe||"date_time"===(null==h?void 0:h.type)&&ue?e.jsx(e.Fragment,{}):e.jsx(t.default,{onClick:()=>{W(!I)},width:24,height:24,color:g.COLORS.content.primary})]})):e.jsx(u.Dropdown,{disabled:oe,options:q,isSearchable:!1,onSelect:re,defaultOptions:R?[Object.assign(Object.assign({},R),{selected:!0})]:[]})})),("custom_text"===(null==R?void 0:R.value)||"custom_link"===(null==R?void 0:R.value))&&e.jsx(d.Input,{state:oe?"disabled":"none",labelText:"custom_text"===(null==R?void 0:R.value)?"Custom text value":"custom_link"===(null==R?void 0:R.value)?"Custom URL value":"",id:`variable-value-${null==R?void 0:R.value}-${A}`,value:B,errorMessage:G?B&&0!==B.trim().length?"custom_link"!==R.value||/^https?:\/\/(?:www\.)?[-a-zA-Z0-9@:%._\+~#=]{1,256}\.[a-zA-Z0-9()]{1,6}\b(?:[-a-zA-Z0-9()@:%_\+.~#?&\/=]*)$/.test(`https://${B.trim()}`)&&0!==B.trim().length?"custom_link"!==R.value&&B.length>30?"Length cannot be more than 30":"BUTTONS"===S&&"custom_link"!==R.value?"Enter valid alpha numeric code":"":"Enter valid URL":"Required field":"",maxCharLimit:"custom_link"===(null==R?void 0:R.value)?2e3:"BUTTONS"===S?15:30,noKeyDownChange:!0,prefixText:"custom_link"===(null==R?void 0:R.value)?"https://":"",placeholder:"link"===h.type||"custom_link"===R.value?"Enter custom URL here":"Enter custom text here",onChangeText:e=>{ce(R.value,e)}}),"static_expiry"===(null==R?void 0:R.value)&&e.jsxs("div",Object.assign({style:{position:"relative"}},{children:[oe&&e.jsx(y,{onClick:e=>e.preventDefault()}),e.jsx(o.CustomDateTime,{placement:"auto",time:B?l.format(new Date(B),"hh:mm a"):l.format(new Date,"hh:mm a"),date:B?new Date(B):new Date,minDate:new Date,error:"",setError:()=>{},onChange:e=>{ce("static_expiry",e.toISOString())}})]})),I&&e.jsx(s.AddVariableV2SideModal,{zIndex:2e3,data:null!=N?N:[],showVariable:I,setShowVariable:W,placeholder:"Add a variable",customTrigger:e=>{null==P||P(!1),"{{custom.url}}"===e.actualValue?re({label:e.displayName,selected:!0,value:"custom_link"}):"{{custom.text}}"==e.actualValue?re({label:e.displayName,selected:!0,value:"custom_text"}):"{{static.expiry}}"==e.actualValue?re({label:e.displayName,selected:!0,value:"static_expiry"}):re({label:e.displayName.replace("{{","").replace("}}","").trim().replace("."," "),selected:!0,value:e.actualValue,bikPlaceholderType:"string"})}})]}))};
16
+ `,f={value:"custom_link",label:"Custom URL"},E={value:"custom_text",label:"Custom text"},T={value:"static_expiry",label:"Static Expiry"};exports.Container=y,exports.default=i=>{let{onFocus:x,variable:h,index:N,showVariableModal:C,variableList:A,setShowDiscountCheckBox:S,componentType:P,CTAoptions:V}=i;var k,L,D;const[B,H]=n.useState(!1),[w,Y]=n.useState(""),[U,q]=n.useState([]),[R,M]=n.useState(),[I,W]=n.useState(!1),[$,z]=n.useState(!1),{device:Z,channel:F,isError:G,originalVariableList:K,template:J,templateSelectionTriggered:Q,setTemplate:X,setDisplayContent:ee,setOriginalVariableList:te,globalNormalizedPlaceholders:le,enabledCustomText:ae,pod:ne,selectedCarouselIndex:ie,isProductCarouselType:se,disableEditVariable:oe,disableEditExpiry:ue}=O.useTemplateModalContext();function de(){var e,t;const l=[];let a=[];if(F!==p.CHANNEL_TYPE.MESSAGE||ae){"link"===(null==h?void 0:h.type)?(l.push({label:"",options:[f,E]}),M(f)):"date_time"===(null==h?void 0:h.type)?(l.push({label:"",options:[f,E]}),M(T)):(l.push({label:"",options:[f,E,T]}),M(E));const e=null!=le?le:[];q([...l,...e.map((e=>{var t,l;return Object.assign(Object.assign({},e),{label:b.default.toCapitilize(null===(l=null===(t=e.label)||void 0===t?void 0:t.replace(/([A-Z])/g," $1"))||void 0===l?void 0:l.toLowerCase())})}))]),a=[...l,...e]}else{const e=null!=le?le:[];q([{label:"",options:[E,f]},...e]),a=[{label:"",options:[E,f]},...e]}if((F===p.CHANNEL_TYPE.WHATSAPP||F===p.CHANNEL_TYPE.EMAIL||F===p.CHANNEL_TYPE.MESSAGE)&&h.updatedValue)if(r.placeHolderNamePattern.test(h.updatedValue)&&F===p.CHANNEL_TYPE.WHATSAPP||h.updatedValue.startsWith("{{")&&F!==p.CHANNEL_TYPE.WHATSAPP){const e=function(e,t,l){var a;let n={label:"",value:""};const i=l===p.CHANNEL_TYPE.WHATSAPP?e.updatedValue.replace("[[","").replace("]]",""):e.updatedValue.replace("{{","").replace("}}","");if(C){let t=e.updatedValue;if(ne===m.POD.CHATBOT&&"BUTTONS"===P){const l=null==V?void 0:V.filter((t=>t.placeHolder===e.updatedValue));l&&l.length>0&&(t=l[0].label)}n={label:t?t.replace("{{","").replace("}}","").trim().replace("."," "):"",value:null!==(a=e.updatedValue)&&void 0!==a?a:""}}else t.map((e=>{e.options.map((e=>{var t;(null===(t=e.value)||void 0===t?void 0:t.replace("{{","").replace("}}","").trim())===i.trim()&&(n=e)}))}));return n}(h,a,F);e.value&&M(e)}else"date_time"===h.type?(M(T),Y(h.updatedValue),me(null!==(e=h.index)&&void 0!==e?e:0,h.updatedValue)):(null===(t=h.updatedValue)||void 0===t?void 0:t.startsWith("https"))?(M(f),Y(h.updatedValue.split("https://")[1])):(M(E),Y(h.updatedValue))}function ce(e,t){var l,a,n;const i=e;Y(""),M(i),F===p.CHANNEL_TYPE.WHATSAPP?"custom_text"!==i.value&&"custom_link"!==i.value&&"static_expiry"!==i.value?(pe(null!==(l=i.value)&&void 0!==l?l:"","string"),null==me||me(null!==(a=h.index)&&void 0!==a?a:0,i.value,!0)):(null==me||me(null!==(n=h.index)&&void 0!==n?n:0,w,!0,i.value),pe("","url"===i.bikPlaceholderType?"link":"string")):"custom_text"!==i.value&&"custom_link"!==i.value?pe(i.value,"url"===i.bikPlaceholderType?"link":"string"):(Y(""),pe("",i.value))}function re(e,t){var l;Y(t);const a="custom_link"===(null==R?void 0:R.value)&&t?t.includes("https")?t:`https://${t}`:t;pe(a,"static_expiry"===e?"string":e),F===p.CHANNEL_TYPE.WHATSAPP&&(null==me||me(null!==(l=h.index)&&void 0!==l?l:0,a,"custom_link"===e,e))}function pe(e,t){var l,n,i,s;const o="custom_link"===t?"link":"custom_text"===t?"string":t;if(F!==p.CHANNEL_TYPE.WHATSAPP){const a=j.getVariableNameForEmailByIndex(N+1),n=null===document||void 0===document?void 0:document.getElementById("mobile"===Z?"template_html_mobile":"template_html_desktop"),i=F===p.CHANNEL_TYPE.EMAIL?null===(l=null==n?void 0:n.contentWindow)||void 0===l?void 0:l.document.getElementById(a):document.getElementById(a);i&&(i.textContent="custom_text"!==t&&"custom_link"!==t||e?e:h.variableName);const s=K.map(((t,l)=>l===N?Object.assign(Object.assign({},t),{type:o,updatedValue:e}):t));null==te||te(s)}if(F===p.CHANNEL_TYPE.WHATSAPP){if(null!=ie&&ie>-1&&se){const l=Object.assign({},K).cards.map(((l,a)=>{var n,i;return"BODY"===P?Object.assign(Object.assign({},l),{body:null===(n=l.body)||void 0===n?void 0:n.map(((t,l)=>N===l?Object.assign(Object.assign({},t),{type:o,updatedValue:e}):t))}):"BUTTONS"===P?Object.assign(Object.assign({},l),{buttons:null===(i=l.buttons)||void 0===i?void 0:i.map(((l,a)=>a===N?Object.assign(Object.assign({},l),{buttonVariable:"custom_link"===t?"((customPlaceholderName))":e,example:"COPY_CODE"===l.type?e:[e]}):l))}):l}));return void(null==te||te((e=>Object.assign(Object.assign({},e),{cards:l}))))}const l=null!=ie&&ie>-1?K.cards[ie]:K;let u=l.body,d=l.header,c=l.buttons;if("BODY"===P?u=null===(n=l.body)||void 0===n?void 0:n.map(((t,l)=>l===N?Object.assign(Object.assign({},t),{type:o,updatedValue:e}):t)):"HEADER"===P?d=null===(i=l.header)||void 0===i?void 0:i.map(((t,l)=>l===N?Object.assign(Object.assign({},t),{type:o,updatedValue:e}):t)):"BUTTONS"===P&&(c=null===(s=l.buttons)||void 0===s?void 0:s.map(((l,a)=>a===N?Object.assign(Object.assign({},l),{buttonVariable:"custom_link"===t?"((customPlaceholderName))":e,example:"COPY_CODE"===l.type?e:[e]}):l))),null!=ie&&ie>-1){const e=a.cloneDeep(K.cards);e[ie]={header:d,body:u,buttons:c},null==te||te((t=>Object.assign(Object.assign({},t),{cards:e})))}else null==te||te((e=>Object.assign(Object.assign({},e),{header:d,body:u,buttons:c})))}}function me(e,t,l,n){var i,s,o,u,d,c,r;if(null!=ie&&ie>-1&&se){const s=Object.assign({},J).components.map((l=>{var a;return"CAROUSEL"===l.type?Object.assign(Object.assign({},l),{cards:null===(a=l.cards)||void 0===a?void 0:a.map((l=>Object.assign(Object.assign({},l),{components:l.components.map((l=>{var a,n,i,s,o,u;if("BODY"===l.type&&"BODY"===P){if(null===(n=null===(a=l.example)||void 0===a?void 0:a.body_text)||void 0===n?void 0:n[0]){const a=[...null!==(o=null===(s=null===(i=l.example)||void 0===i?void 0:i.body_text)||void 0===s?void 0:s[0])&&void 0!==o?o:[]];a[e]=t.replace("{{","").replace("}}","").replace("((","").replace("))","");const n=Object.assign(Object.assign({},l.example),{body_text:[a]});return Object.assign(Object.assign({},l),{example:n})}return l}if("BUTTONS"===l.type&&"BUTTONS"===P){const a=null===(u=l.buttons)||void 0===u?void 0:u.map(((l,a)=>a===e?Object.assign(Object.assign({},l),{example:[t]}):l));return a?Object.assign(Object.assign({},l),{buttons:a}):l}return l}))})))}):l})),o=a.cloneDeep(J);if(l){const l=null===(i=Object.assign({},J).mapping.cards)||void 0===i?void 0:i.map(((l,a)=>{var i,s,o;if("BODY"===P)return Object.assign(Object.assign({},l),{body:null===(i=l.body)||void 0===i?void 0:i.map(((l,a)=>e===a?"custom_text"===n?`((editableVariable${a+10}))`:t:l))});if("BUTTONS"===P&&(null==l?void 0:l.buttons)){let i=-1,u=-1;return null===(s=J.components[1].cards)||void 0===s||s[a].components.forEach((t=>{var l;"BUTTONS"===t.type&&(null===(l=t.buttons)||void 0===l||l.forEach(((t,l)=>{"URL"===t.type&&(i++,l===e&&"URL"==t.type&&(u=i))})))})),Object.assign(Object.assign({},l),{buttons:null===(o=l.buttons)||void 0===o?void 0:o.map(((e,l)=>l===u?"custom_link"===n?"((customPlaceholderName))":t:e))})}return l}));o.mapping.cards=l}return o.components=s,void(null==X||X(o))}const p=null!=ie&&ie>-1?{components:null===(s=Object.assign({},J).components[1].cards)||void 0===s?void 0:s[ie].components,mapping:null===(o=Object.assign({},J).mapping.cards)||void 0===o?void 0:o[ie]}:Object.assign({},J),m=null===(u=null==p?void 0:p.components)||void 0===u?void 0:u.map((l=>{var a,n,i,s,o,u,d,c,r;const p=Object.assign({},l);if("BODY"===l.type&&"BODY"===P){if(null===(n=null===(a=l.example)||void 0===a?void 0:a.body_text)||void 0===n?void 0:n[0]){const l=[...null!==(o=null===(s=null===(i=p.example)||void 0===i?void 0:i.body_text)||void 0===s?void 0:s[0])&&void 0!==o?o:[]];l[e]=t.replace("{{","").replace("}}","").replace("((","").replace("))","");const a=Object.assign(Object.assign({},p.example),{body_text:[l]});return Object.assign(Object.assign({},p),{example:a})}}else if("HEADER"===l.type&&"HEADER"===P){if(null===(u=l.example)||void 0===u?void 0:u.header_text){const l=[...null!==(c=null===(d=p.example)||void 0===d?void 0:d.header_text)&&void 0!==c?c:[]];l[e]=t.replace("{{","").replace("}}","").replace("((","").replace("))","");const a=Object.assign(Object.assign({},p.example),{header_text:l});return Object.assign(Object.assign({},p),{example:a})}}else{if("BUTTONS"===l.type&&"BUTTONS"===P){const a=null===(r=l.buttons)||void 0===r?void 0:r.map(((l,a)=>a===e?Object.assign(Object.assign({},l),{example:"COPY_CODE"===l.type?t:[t]}):l));return a?Object.assign(Object.assign({},p),{buttons:a}):p}if("limited_time_offer"===l.type&&"limited_time_offer"===P)return Object.assign(Object.assign({},p),{example:Object.assign(Object.assign({},p.example),{limited_time_offer:t})})}return l}));if(p.components=m,l)if("BODY"===P&&(null===(d=null==p?void 0:p.mapping)||void 0===d?void 0:d.body))p.mapping=Object.assign(Object.assign({},p.mapping),{body:p.mapping.body.map(((l,a)=>e===a?"custom_text"===n?`((editableVariable${a+10}))`:t:l))});else if("HEADER"===P&&(null===(c=null==p?void 0:p.mapping)||void 0===c?void 0:c.header))p.mapping=Object.assign(Object.assign({},p.mapping),{header:p.mapping.header.map(((l,a)=>e===a?"custom_text"===n?`((editableVariable${a+20}))`:t:l))});else if("BUTTONS"===P&&(null===(r=null==p?void 0:p.mapping)||void 0===r?void 0:r.buttons)){let l=-1,a=-1;m.forEach((t=>{var n;"BUTTONS"===t.type&&(null===(n=t.buttons)||void 0===n||n.forEach(((t,n)=>{"URL"===t.type&&(l++,n===e&&"URL"==t.type&&(a=l))})))})),p.mapping=Object.assign(Object.assign({},p.mapping),{buttons:p.mapping.buttons.map(((e,l)=>l===a?"custom_link"===n?"((customPlaceholderName))":t:e))})}if(null!=ie&&ie>-1&&J){const e=a.cloneDeep(J);e.components[1].cards[ie].components=p.components,e.mapping.cards[ie]=p.mapping,null==X||X(e)}else null==X||X(Object.assign({},p))}return n.useEffect((()=>{B&&(null==x||x())}),[B]),n.useEffect((()=>{!function(){var e,t,l,a,n;const i="mobile"===Z?"template_html_mobile":"template_html_desktop",s=document.getElementById(i),o=(null!==(a=null===(l=null===(t=null===(e=null==s?void 0:s.contentWindow)||void 0===e?void 0:e.document)||void 0===t?void 0:t.body)||void 0===l?void 0:l.innerHTML)&&void 0!==a?a:"")+(null===(n=null==s?void 0:s.contentWindow)||void 0===n?void 0:n.document.head.innerHTML);F===p.CHANNEL_TYPE.EMAIL&&(null==ee||ee(o))}()}),[Q]),n.useEffect((()=>{de()}),[]),n.useEffect((()=>{de()}),[ie]),n.useEffect((()=>{Z&&R&&w&&setTimeout((()=>{pe("custom_link"===(null==R?void 0:R.value)&&w?w.includes("https")?w:`https://${w}`:w,R.value)}),100)}),[Z]),n.useEffect((()=>{!$&&R&&h.updatedValue&&setTimeout((()=>{pe("custom_link"===(null==R?void 0:R.value)&&h.updatedValue?h.updatedValue.includes("https")?h.updatedValue:`https://${h.updatedValue}`:h.updatedValue,R.value),z(!0)}),100)}),[R]),e.jsxs(y,Object.assign({channel:F,focused:B,onMouseEnter:()=>H(!0),onMouseLeave:()=>H(!1)},{children:[e.jsx("div",Object.assign({style:{marginBottom:8}},{children:e.jsxs(v.BodySecondary,Object.assign({style:{color:G&&!R?g.COLORS.content.negative:g.COLORS.content.primary}},{children:[null===(k=h.variableName)||void 0===k?void 0:k.replace("{{","").replace("}}","")," ","link"===(null==h?void 0:h.type)?"link":"variable"]}))})),e.jsx("div",Object.assign({style:{marginBottom:12}},{children:C?e.jsxs("div",Object.assign({style:{display:"flex",border:"#E0E0E0 1px solid",borderRadius:4,padding:10,justifyContent:(null==R?void 0:R.label)?"space-between":"flex-end"}},{children:[e.jsx(v.BodyPrimary,Object.assign({numberOfLines:1},{children:ne===m.POD.CHATBOT?["static_expiry","custom_text","custom_link"].includes(null!==(L=null==R?void 0:R.value)&&void 0!==L?L:"")?null==R?void 0:R.label:null==R?void 0:R.value:c.truncate(null!==(D=null==R?void 0:R.label)&&void 0!==D?D:"",20,!0)})),oe||"date_time"===(null==h?void 0:h.type)&&ue?e.jsx(e.Fragment,{}):e.jsx(t.default,{onClick:()=>{W(!I)},width:24,height:24,color:g.COLORS.content.primary})]})):e.jsx(u.Dropdown,{disabled:oe,options:U,isSearchable:!1,onSelect:ce,defaultOptions:R?[Object.assign(Object.assign({},R),{selected:!0})]:[]})})),("custom_text"===(null==R?void 0:R.value)||"custom_link"===(null==R?void 0:R.value))&&e.jsx(d.Input,{state:oe?"disabled":"none",labelText:"custom_text"===(null==R?void 0:R.value)?"Custom text value":"custom_link"===(null==R?void 0:R.value)?"Custom URL value":"",id:`variable-value-${null==R?void 0:R.value}-${N}`,value:w,errorMessage:G?w&&0!==w.trim().length?"custom_link"!==R.value||/^https?:\/\/(?:www\.)?[-a-zA-Z0-9@:%._\+~#=]{1,256}\.[a-zA-Z0-9()]{1,6}\b(?:[-a-zA-Z0-9()@:%_\+.~#?&\/=]*)$/.test(`https://${w.trim()}`)&&0!==w.trim().length?"custom_link"!==R.value&&w.length>30?"Length cannot be more than 30":"BUTTONS"===P&&"custom_link"!==R.value?"Enter valid alpha numeric code":"":"Enter valid URL":"Required field":"",maxCharLimit:"custom_link"===(null==R?void 0:R.value)?2e3:"BUTTONS"===P?15:30,noKeyDownChange:!0,prefixText:"custom_link"===(null==R?void 0:R.value)?"https://":"",placeholder:"link"===h.type||"custom_link"===R.value?"Enter custom URL here":"Enter custom text here",onChangeText:e=>{re(R.value,e)}}),"static_expiry"===(null==R?void 0:R.value)&&e.jsxs("div",Object.assign({style:{position:"relative"}},{children:[oe&&e.jsx(_,{onClick:e=>e.preventDefault()}),e.jsx(o.CustomDateTime,{placement:"auto",time:w?l.format(new Date(w),"hh:mm a"):l.format(new Date,"hh:mm a"),date:w?new Date(w):new Date,minDate:new Date,error:"",setError:()=>{},onChange:e=>{re("static_expiry",e.toISOString())}})]})),I&&e.jsx(s.AddVariableV2SideModal,{zIndex:2e3,data:null!=A?A:[],showVariable:I,setShowVariable:W,placeholder:"Add a variable",customTrigger:e=>{null==S||S(!1),"{{custom.url}}"===e.actualValue?ce({label:e.displayName,selected:!0,value:"custom_link"}):"{{custom.text}}"==e.actualValue?ce({label:e.displayName,selected:!0,value:"custom_text"}):"{{static.expiry}}"==e.actualValue?ce({label:e.displayName,selected:!0,value:"static_expiry"}):(console.log("variable: ",e),ce({label:e.displayName.replace("{{","").replace("}}","").trim().replace("."," "),selected:!0,value:e.actualValue,bikPlaceholderType:"string"}))}})]}))};
@@ -1 +1 @@
1
- import{jsxs as e,jsx as t,Fragment as o}from"react/jsx-runtime";import c from"../../assets/icons/search.svg.js";import{useReducer as r,useState as s,useRef as i,useEffect as n}from"react";import{COLORS as l}from"../../constants/Theme.js";import{Button as d}from"../button/Button.js";import{Input as a}from"../input/Input.js";import{StyledModal as u}from"../modals/styledModal.js";import{Spinner as h}from"../spinner/Spinner.js";import{Tag as p}from"../tag/Tag.js";import{CollectionsScreen as m}from"./collectionScreen.js";import{ProductInfoOverlay as C}from"./productInfoOverlay.js";import{ProductsScreen as g}from"./productScreen.js";import{RearrangeScreen as b}from"./rearrangeScreen.js";import{collectionsReducer as f,searchReducer as y,selectedColectionsReducer as S,CollectionIdContext as v}from"./reducers.js";import{SearchScreen as k}from"./searchScreen.js";import{SelectedScreen as P}from"./selectedScreen.js";import{ContainerStyle as x,ScrollContainerStyle as j}from"./style.js";import{OUT_OF_STOCK_ACTION as I}from"./type.js";var F;!function(e){e.Collections="collections",e.RearrangeProducts="rearrange",e.SelectedProducts="view",e.SearchProducts="searchProducts",e.Products="products"}(F||(F={}));const T=T=>{const{storeId:D,selectedItems:O,onClose:w,visible:R,zIndex:E,exactLimit:A,limit:$,hideCollectionCheckbox:V,hideProductCheckbox:B,outOfStockAction:L=I.BLUR,hideVariantCheckbox:M,selectProductsFromCustomCollection:z,hideSelectionCount:W,title:G,width:H,renderWithoutModal:Y,onClickSave:K,pickerType:U,hideProductVariants:q=!1,startupScreen:J=F.Collections,rearrangeEnabled:N,selectSingleItem:Q=!1,showProductDetails:X}=T,[Z,_]=r(f,{}),[ee,te]=s([F.Collections,F.RearrangeProducts].includes(J)?J:F.Collections),[oe,ce]=s("grid"),[re,se]=s(""),[ie,ne]=s(""),[le,de]=s(0),[ae,ue]=s(!1),[he,pe]=s(0),[me,Ce]=s(""),[ge,be]=s(!1),[fe,ye]=s(!1),[Se,ve]=r(y,{collections:{},products:{}}),[ke,Pe]=r(S,Object.keys(O).length>0?O:{}),xe=i(null),[je,Ie]=s(!1),[Fe,Te]=s();n((()=>{ue(!0),ye(!0),T.collectionFetcher(le,D).then((e=>{_({type:"fetched",data:(null==e?void 0:e.collections)||{}}),ue(!1),de((e=>e+1)),ye(!1)})).catch()}),[]),n((()=>{let e=0;Object.keys(ke||[]).forEach((t=>{var o;Object.keys((null===(o=ke[t])||void 0===o?void 0:o.products)||[]).forEach((o=>{var c,r;Object.keys((null===(r=null===(c=ke[t].products)||void 0===c?void 0:c[o])||void 0===r?void 0:r.variants)||[]).forEach((()=>{e+=1}))}))})),pe(e)})),n((()=>{ie&&(ue(!0),T.productFetcher(ie,D).then((e=>{Object.keys(e).length&&_({type:"productsFetched",data:{collectionId:ie,products:e}}),ue(!1)})).catch())}),[ie]),n((()=>{const e=setTimeout((()=>{"rearrange"!==ee&&(me.length?(be(!0),T.searchFetcher(D,me).then((e=>{"collections"in e&&"products"in e?(ve({type:"set",data:e}),_({type:"searched",data:e.collections})):(ve({type:"set",data:{collections:{},products:e}}),_({type:"searched",data:e})),te("searchProducts"),ue(!1),be(!1)}))):te("collections"))}),800);return()=>clearTimeout(e)}),[me]),n((()=>{K&&(T.onAdd(ke,he),De())}),[K]),n((()=>{Q&&Object.keys(ke||{}).length&&he&&(T.onAdd(ke,he),De())}),[Q,ke,he]);const De=()=>{Pe({type:"reset",data:{}})},Oe=e(x,{children:[T.postHeader&&t("div",Object.assign({style:{padding:"0 24px"}},{children:T.postHeader})),!T.hideGlobalSearch&&t(o,{children:("collections"===ee||"searchProducts"===ee)&&t("div",Object.assign({style:{padding:Y?"8px 16px":"12px 24px",borderBottom:"1px solid #E0E0E0"}},{children:t(a,{noKeyDownChange:!0,noErrorHint:!0,rightIcon:{icon:()=>ge?t(h,{size:"small",color:l.content.primary}):t(c,{})},id:"listInput",height:"24px",type:"text",value:me,onChangeText:e=>{e.length&&e.trim().length?Ce(e):Ce("")}})}))}),e(j,Object.assign({ref:xe},{children:["collections"===ee&&t(m,{customCollectionRestriction:T.customCollectionRestriction,dataLoading:fe,collections:Z,selectedCollectionsDispatch:Pe,setCollectionId:se,setSelectedCollectionId:ne,setScreen:te,selectedCollections:ke,collectionFetcher:T.collectionFetcher,storeId:D,collectionsDispatch:_,setSaveDisabled:ue,pagingControls:{curPage:le,setCurPage:de},hideCollectionCheckbox:V,renderWithoutModal:Y,pickerType:U}),"products"===ee&&re&&t(v.Provider,Object.assign({value:re},{children:t(g,{hideInCollectionSearch:T.hideInCollectionSearch,customCollectionRestriction:T.customCollectionRestriction,productFetcher:T.productFetcher,setScreen:te,storeId:D,data:Z[re],collectionsDispatch:_,selectedCollectionsDispatch:Pe,selectedData:ke,setSaveDisabled:ue,searchInCollectionFetcher:T.searchInCollectionFetcher,hideProductCheckbox:B,outOfStockAction:L,hideVariantCheckbox:M,selectProductsFromCustomCollection:z,renderWithoutModal:Y,pickerType:U,hideProductVariants:q,fbStatusFetcher:T.fbStatusFetcher,onProductDetailClick:e=>{Ie(!0),Te(e)},showProductDetailInfoIcon:X})})),"view"===ee&&t(P,{selectedCollections:ke||{},selectedCollectionsDispatch:Pe,setScreen:te,collections:Z,outOfStockAction:L,storeId:D,fbStatusFetcher:T.fbStatusFetcher}),"rearrange"===ee&&t(b,{selectedCollections:ke||{},selectedCollectionsDispatch:Pe,setScreen:te,outOfStockAction:L,rearrangeViewType:"grid"===oe?"list":"grid",scrollContainerRef:xe,storeId:D,fbStatusFetcher:T.fbStatusFetcher}),"searchProducts"===ee&&t(k,{customCollectionRestriction:T.customCollectionRestriction,selectedCollections:ke||{},searchedCollections:Se||{},searchedCollectionsDispatch:ve,selectedCollectionsDispatch:Pe,setScreen:te,collections:Z,onBackPress:()=>{Ce(""),ve({type:"set",data:{collections:{},products:{}}})},pickerType:U,hideProductCheckbox:B,hideProductVariants:q,hideVariantCheckbox:M,storeId:D,fbStatusFetcher:T.fbStatusFetcher,setCollectionId:se,setSelectedCollectionId:ne,renderWithoutModal:Y,hideCollectionCheckbox:V})]}))]});return t(o,{children:Y?Oe:e(u,Object.assign({zIndex:E,open:R,onClose:()=>{null==w||w(),De()},headingTitle:G||("collections"===ee||"products"===ee?"Select Products":"view"===ee?"Selected Products":"searchProducts"===ee?"Searched Products":"rearrange"===ee?"Rearrange Products":void 0),footerShadow:!0,centralContainerStyles:{width:H||"600px"},headerRightCustomElement:"rearrange"===ee?(console.log("ignore:",ce),t(o,{})):t(o,{}),footerContainerStyle:T.stickyFooter?{position:"absolute",bottom:0,left:0,width:"100%",zIndex:9,background:l.surface.standard}:void 0,primaryButton:{buttonText:ae?"Loading...":ee===F.RearrangeProducts?"Done":"Add",disabled:ae||he<1||A&&he<A||!A&&$&&he>$||!1,onClick:()=>{T.onAdd(ke,he),De()}},wrapperStyle:T.stickyFooter?{height:"calc(100vh - 168px)"}:void 0,footerLeftCustomElement:W?t(o,{}):A&&he>A?t(p,{tagText:`You can only select ${A} products`,type:"negative"}):$&&he>$?t(p,{tagText:`You can only select ${$} products`,type:"negative"}):t(d,he>0?{onClick:()=>{te(N?F.RearrangeProducts:F.SelectedProducts)},buttonText:A?`${he}/${A} products selected`:`${he} products selected`,buttonType:["rearrange","view"].includes(ee)?"tertiaryGray":"tertiary",disabled:["rearrange","view"].includes(ee)}:{disabled:!0,buttonText:A?`${he}/${A} products selected`:`${he} products selected`,buttonType:"tertiaryGray"}),hideCrossButton:je},{children:[Oe,je&&Fe?t(C,{productData:Fe,outOfStockAction:L,onClose:()=>{Ie(!1)}}):t(o,{})]}))})};export{T as ProductPickerModal,F as ScreenName};
1
+ import{jsxs as e,jsx as t,Fragment as o}from"react/jsx-runtime";import c from"../../assets/icons/search.svg.js";import{useReducer as r,useState as s,useRef as i,useEffect as n}from"react";import{COLORS as l}from"../../constants/Theme.js";import{Button as d}from"../button/Button.js";import{Input as a}from"../input/Input.js";import{StyledModal as u}from"../modals/styledModal.js";import{Spinner as h}from"../spinner/Spinner.js";import{Tag as p}from"../tag/Tag.js";import{CollectionsScreen as m}from"./collectionScreen.js";import{ProductInfoOverlay as C}from"./productInfoOverlay.js";import{ProductsScreen as g}from"./productScreen.js";import{RearrangeScreen as b}from"./rearrangeScreen.js";import{collectionsReducer as f,searchReducer as y,selectedColectionsReducer as S,CollectionIdContext as v}from"./reducers.js";import{SearchScreen as k}from"./searchScreen.js";import{SelectedScreen as P}from"./selectedScreen.js";import{ContainerStyle as x,ScrollContainerStyle as j}from"./style.js";import{OUT_OF_STOCK_ACTION as I}from"./type.js";var F;!function(e){e.Collections="collections",e.RearrangeProducts="rearrange",e.SelectedProducts="view",e.SearchProducts="searchProducts",e.Products="products"}(F||(F={}));const T=T=>{const{storeId:D,selectedItems:O,onClose:w,visible:R,zIndex:E,exactLimit:A,limit:$,hideCollectionCheckbox:V,hideProductCheckbox:B,outOfStockAction:L=I.BLUR,hideVariantCheckbox:M,selectProductsFromCustomCollection:z,hideSelectionCount:W,title:G,width:H,renderWithoutModal:Y,onClickSave:K,pickerType:N,hideProductVariants:U=!1,startupScreen:q=F.Collections,rearrangeEnabled:J,selectSingleItem:Q=!1,showProductDetails:X}=T,[Z,_]=r(f,{}),[ee,te]=s([F.Collections,F.RearrangeProducts].includes(q)?q:F.Collections),[oe,ce]=s("grid"),[re,se]=s(""),[ie,ne]=s(""),[le,de]=s(0),[ae,ue]=s(!1),[he,pe]=s(0),[me,Ce]=s(""),[ge,be]=s(!1),[fe,ye]=s(!1),[Se,ve]=r(y,{collections:{},products:{}}),[ke,Pe]=r(S,Object.keys(O).length>0?O:{}),xe=i(null),[je,Ie]=s(!1),[Fe,Te]=s();n((()=>{ue(!0),ye(!0),T.collectionFetcher(le,D).then((e=>{_({type:"fetched",data:(null==e?void 0:e.collections)||{}}),ue(!1),de((e=>e+1)),ye(!1)})).catch()}),[]),n((()=>{let e=0;Object.keys(ke||[]).forEach((t=>{var o;Object.keys((null===(o=ke[t])||void 0===o?void 0:o.products)||[]).forEach((o=>{var c,r;Object.keys((null===(r=null===(c=ke[t].products)||void 0===c?void 0:c[o])||void 0===r?void 0:r.variants)||[]).forEach((()=>{e+=1}))}))})),pe(e)})),n((()=>{ie&&(ue(!0),T.productFetcher(ie,D).then((e=>{Object.keys(e).length&&_({type:"productsFetched",data:{collectionId:ie,products:e}}),ue(!1)})).catch())}),[ie]),n((()=>{const e=setTimeout((()=>{"rearrange"!==ee&&(me.length?(be(!0),T.searchFetcher(D,me).then((e=>{"collections"in e&&"products"in e?(ve({type:"set",data:e}),_({type:"searched",data:e.collections})):(ve({type:"set",data:{collections:{},products:e}}),_({type:"searched",data:e})),te("searchProducts"),ue(!1),be(!1)}))):te("collections"))}),800);return()=>clearTimeout(e)}),[me]),n((()=>{K&&(T.onAdd(ke,he),De())}),[K]),n((()=>{Q&&Object.keys(ke||{}).length&&he&&(T.onAdd(ke,he),De())}),[Q,ke,he]);const De=()=>{Pe({type:"reset",data:{}})},Oe=e(x,{children:[T.postHeader&&t("div",Object.assign({style:{padding:"0 24px"}},{children:T.postHeader})),!T.hideGlobalSearch&&t(o,{children:("collections"===ee||"searchProducts"===ee)&&t("div",Object.assign({style:{padding:Y?"8px 16px":"12px 24px",borderBottom:"1px solid #E0E0E0"}},{children:t(a,{noKeyDownChange:!0,noErrorHint:!0,rightIcon:{icon:()=>ge?t(h,{size:"small",color:l.content.primary}):t(c,{})},id:"listInput",height:"24px",type:"text",value:me,onChangeText:e=>{e.length&&e.trim().length?Ce(e):Ce("")}})}))}),e(j,Object.assign({ref:xe,screenName:ee},{children:["collections"===ee&&t(m,{customCollectionRestriction:T.customCollectionRestriction,dataLoading:fe,collections:Z,selectedCollectionsDispatch:Pe,setCollectionId:se,setSelectedCollectionId:ne,setScreen:te,selectedCollections:ke,collectionFetcher:T.collectionFetcher,storeId:D,collectionsDispatch:_,setSaveDisabled:ue,pagingControls:{curPage:le,setCurPage:de},hideCollectionCheckbox:V,renderWithoutModal:Y,pickerType:N}),"products"===ee&&re&&t(v.Provider,Object.assign({value:re},{children:t(g,{hideInCollectionSearch:T.hideInCollectionSearch,customCollectionRestriction:T.customCollectionRestriction,productFetcher:T.productFetcher,setScreen:te,storeId:D,data:Z[re],collectionsDispatch:_,selectedCollectionsDispatch:Pe,selectedData:ke,setSaveDisabled:ue,searchInCollectionFetcher:T.searchInCollectionFetcher,hideProductCheckbox:B,outOfStockAction:L,hideVariantCheckbox:M,selectProductsFromCustomCollection:z,renderWithoutModal:Y,pickerType:N,hideProductVariants:U,fbStatusFetcher:T.fbStatusFetcher,onProductDetailClick:e=>{Ie(!0),Te(e)},showProductDetailInfoIcon:X})})),"view"===ee&&t(P,{selectedCollections:ke||{},selectedCollectionsDispatch:Pe,setScreen:te,collections:Z,outOfStockAction:L,storeId:D,fbStatusFetcher:T.fbStatusFetcher}),"rearrange"===ee&&t(b,{selectedCollections:ke||{},selectedCollectionsDispatch:Pe,setScreen:te,outOfStockAction:L,rearrangeViewType:"grid"===oe?"list":"grid",scrollContainerRef:xe,storeId:D,fbStatusFetcher:T.fbStatusFetcher}),"searchProducts"===ee&&t(k,{customCollectionRestriction:T.customCollectionRestriction,selectedCollections:ke||{},searchedCollections:Se||{},searchedCollectionsDispatch:ve,selectedCollectionsDispatch:Pe,setScreen:te,collections:Z,onBackPress:()=>{Ce(""),ve({type:"set",data:{collections:{},products:{}}})},pickerType:N,hideProductCheckbox:B,hideProductVariants:U,hideVariantCheckbox:M,storeId:D,fbStatusFetcher:T.fbStatusFetcher,setCollectionId:se,setSelectedCollectionId:ne,renderWithoutModal:Y,hideCollectionCheckbox:V})]}))]});return t(o,{children:Y?Oe:e(u,Object.assign({zIndex:E,open:R,onClose:()=>{null==w||w(),De()},headingTitle:G||("collections"===ee||"products"===ee?"Select Products":"view"===ee?"Selected Products":"searchProducts"===ee?"Searched Products":"rearrange"===ee?"Rearrange Products":void 0),footerShadow:!0,centralContainerStyles:{width:H||"600px"},headerRightCustomElement:"rearrange"===ee?(console.log("ignore:",ce),t(o,{})):t(o,{}),footerContainerStyle:T.stickyFooter?{position:"absolute",bottom:0,left:0,width:"100%",zIndex:9,background:l.surface.standard}:void 0,primaryButton:{buttonText:ae?"Loading...":ee===F.RearrangeProducts?"Done":"Add",disabled:ae||he<1||A&&he<A||!A&&$&&he>$||!1,onClick:()=>{T.onAdd(ke,he),De()}},wrapperStyle:T.stickyFooter?{height:"calc(100vh - 168px)"}:void 0,footerLeftCustomElement:W?t(o,{}):A&&he>A?t(p,{tagText:`You can only select ${A} products`,type:"negative"}):$&&he>$?t(p,{tagText:`You can only select ${$} products`,type:"negative"}):t(d,he>0?{onClick:()=>{te(J?F.RearrangeProducts:F.SelectedProducts)},buttonText:A?`${he}/${A} products selected`:`${he} products selected`,buttonType:["rearrange","view"].includes(ee)?"tertiaryGray":"tertiary",disabled:["rearrange","view"].includes(ee)}:{disabled:!0,buttonText:A?`${he}/${A} products selected`:`${he} products selected`,buttonType:"tertiaryGray"}),hideCrossButton:je},{children:[Oe,je&&Fe?t(C,{productData:Fe,outOfStockAction:L,onClose:()=>{Ie(!1)}}):t(o,{})]}))})};export{T as ProductPickerModal,F as ScreenName};
@@ -1,4 +1,4 @@
1
- import{jsxs as o,jsx as t}from"react/jsx-runtime";import i from"styled-components";import{COLORS as r}from"../../constants/Theme.js";import e from"../../assets/icons/cross.svg.js";import{IconButton as a}from"../icon-button/IconButton.js";import{ShimmerImage as n}from"../shimmer-image/ShimmerImage.js";import{TitleSmall as d,BodyCaption as s}from"../TypographyStyle.js";import{ProductPickerTag as c}from"./ProductPickerTag.js";const l=i=>o(m,{children:[t(u,{}),t(x,{children:t(a,{className:"close-button",onClick:i.onClose,Icon:e,width:20,height:20})}),t(p,{productData:i.productData,outOfStockAction:i.outOfStockAction})]}),p=i=>{var r;const e=void 0===i.productData.variants;return o(f,{children:[t(g,{children:t(n,{imageUrl:i.productData.image,width:"200px",height:200,borderRadius:4})}),o(h,{children:[t(d,Object.assign({style:{display:"flex"}},{children:i.productData.name})),t(s,{style:{display:"flex",flexDirection:"column"},dangerouslySetInnerHTML:{__html:null!==(r=i.productData.description)&&void 0!==r?r:""}}),t(c,{isVariant:e,data:i.productData,outOfStockAction:i.outOfStockAction})]})]})},m=i.div`
1
+ import{jsxs as o,jsx as t}from"react/jsx-runtime";import i from"styled-components";import{COLORS as r}from"../../constants/Theme.js";import e from"../../assets/icons/cross.svg.js";import{IconButton as a}from"../icon-button/IconButton.js";import{ShimmerImage as d}from"../shimmer-image/ShimmerImage.js";import{TitleSmall as n,BodyCaption as s}from"../TypographyStyle.js";import{ProductPickerTag as c}from"./ProductPickerTag.js";const l=i=>o(m,{children:[t(u,{}),t(x,{children:t(a,{className:"close-button",onClick:i.onClose,Icon:e,width:20,height:20})}),t(p,{productData:i.productData,outOfStockAction:i.outOfStockAction})]}),p=i=>{var r;const e=void 0===i.productData.variants;return o(f,{children:[t(g,{children:t(d,{imageUrl:i.productData.image,width:"200px",height:200,borderRadius:4})}),o(h,{children:[t(n,Object.assign({style:{display:"flex"}},{children:i.productData.name})),t(s,{className:"overlay-description",dangerouslySetInnerHTML:{__html:null!==(r=i.productData.description)&&void 0!==r?r:""}}),t(c,{isVariant:e,data:i.productData,outOfStockAction:i.outOfStockAction})]})]})},m=i.div`
2
2
  display: flex;
3
3
  flex: 1;
4
4
  background: rgba(0, 0, 0, 0.5);
@@ -8,6 +8,14 @@ import{jsxs as o,jsx as t}from"react/jsx-runtime";import i from"styled-component
8
8
  position: absolute;
9
9
  bottom: 0;
10
10
  z-index: 10;
11
+
12
+ .overlay-description {
13
+ display: flex;
14
+ flex-direction: column;
15
+ max-height: 300px;
16
+ overflow-y: auto;
17
+ word-break: break-word;
18
+ }
11
19
  `,u=i.div`
12
20
  display: flex;
13
21
  flex: 1;
@@ -1,5 +1,7 @@
1
1
  export declare const ContainerStyle: import("styled-components").StyledComponent<"div", any, {}, never>;
2
- export declare const ScrollContainerStyle: import("styled-components").StyledComponent<"div", any, {}, never>;
2
+ export declare const ScrollContainerStyle: import("styled-components").StyledComponent<"div", any, {
3
+ screenName: string;
4
+ }, never>;
3
5
  export declare const CollectionCardStyle: import("styled-components").StyledComponent<"div", any, {
4
6
  isDisabled: boolean;
5
7
  isActive: boolean;
@@ -1,9 +1,9 @@
1
- import e from"styled-components";import{COLORS as i}from"../../constants/Theme.js";const t=e.div`
1
+ import e from"styled-components";import{COLORS as i}from"../../constants/Theme.js";import{ScreenName as t}from"./modal.js";const o=e.div`
2
2
  display: flex;
3
3
  background-color: white;
4
4
  height: 600px;
5
5
  flex-direction: column;
6
- `,o=e.div`
6
+ `,n=e.div`
7
7
  overflow-y: scroll;
8
8
  overflow-x: hidden;
9
9
 
@@ -13,10 +13,10 @@ import e from"styled-components";import{COLORS as i}from"../../constants/Theme.j
13
13
  }
14
14
 
15
15
  ::-webkit-scrollbar-thumb {
16
- background-color: #888;
16
+ background-color: ${e=>e.screenName!==t.RearrangeProducts?"#888":"#fff"};
17
17
  border-radius: 8px;
18
18
  }
19
- `,n=e.div`
19
+ `,r=e.div`
20
20
  height: 64px;
21
21
  background-color: ${e=>e.isDisabled?"#F0F0F0":e.isActive?i.background.positive.light:"white"};
22
22
  border-bottom: 1px solid #e0e0e0;
@@ -30,17 +30,17 @@ import e from"styled-components";import{COLORS as i}from"../../constants/Theme.j
30
30
  cursor: pointer;
31
31
  background-color: ${i.surface.hovered};
32
32
  }
33
- `,r=e.div`
33
+ `,d=e.div`
34
34
  display: flex;
35
35
  flex-direction: row;
36
36
  justify-content: center;
37
37
  align-items: center;
38
38
  column-gap: 18px;
39
- `,d=e.div`
39
+ `,p=e.div`
40
40
  display: flex;
41
41
  flex-direction: column;
42
42
  justify-content: center;
43
- `,p=e.div`
43
+ `,l=e.div`
44
44
  display: flex;
45
45
  flex-direction: row;
46
46
  max-height: 32px;
@@ -53,14 +53,14 @@ import e from"styled-components";import{COLORS as i}from"../../constants/Theme.j
53
53
  position: sticky;
54
54
  top: 0;
55
55
  z-index: 10;
56
- `,l=e.div`
56
+ `,c=e.div`
57
57
  display: flex;
58
58
  flex-direction: row;
59
59
  column-gap: 16px;
60
60
  padding: 12px 16px;
61
61
  border-bottom: 1px solid #e0e0e0;
62
62
  align-items: center;
63
- `,c=e.div`
63
+ `,a=e.div`
64
64
  min-height: 64px;
65
65
  background-color: ${e=>e.isActive?i.background.positive.light:"white"};
66
66
  border-bottom: 1px solid #e0e0e0;
@@ -87,10 +87,10 @@ import e from"styled-components";import{COLORS as i}from"../../constants/Theme.j
87
87
  position: sticky;
88
88
  top: 0;
89
89
  z-index: 10;
90
- `,a=e.div`
90
+ `,s=e.div`
91
91
  display: flex;
92
92
  flex-direction: column;
93
- `,s=e.div`
93
+ `,g=e.div`
94
94
  min-height: 72px;
95
95
  background: white;
96
96
  padding: 12px 16px;
@@ -111,7 +111,7 @@ import e from"styled-components";import{COLORS as i}from"../../constants/Theme.j
111
111
  flex-direction: column;
112
112
  gap: 2px;
113
113
  }
114
- `,g=e.div`
114
+ `,f=e.div`
115
115
  height: 72px;
116
116
  width: 72px;
117
117
  display: flex;
@@ -127,4 +127,4 @@ import e from"styled-components";import{COLORS as i}from"../../constants/Theme.j
127
127
  align-items: center;
128
128
  border: 1px solid ${i.stroke.primary};
129
129
  border-radius: 4px;
130
- `;export{d as CollectionCardDetailStyle,r as CollectionCardInfoStyle,n as CollectionCardStyle,a as CollectionNameHolder,t as ContainerStyle,c as ProductCardStyle,l as ProductScreenCollectionCardStyle,p as ProductScreenHeader,o as ScrollContainerStyle,x as SelectedScreenHeader,g as VariantCardGridStyle,s as VariantCardListStyle};
130
+ `;export{p as CollectionCardDetailStyle,d as CollectionCardInfoStyle,r as CollectionCardStyle,s as CollectionNameHolder,o as ContainerStyle,a as ProductCardStyle,c as ProductScreenCollectionCardStyle,l as ProductScreenHeader,n as ScrollContainerStyle,x as SelectedScreenHeader,f as VariantCardGridStyle,g as VariantCardListStyle};
@@ -1 +1 @@
1
- import{jsx as e,jsxs as r}from"react/jsx-runtime";import{useState as a}from"react";import{Droppable as t,Draggable as s}from"react-beautiful-dnd";import{COLORS as n}from"../../constants/Theme.js";import{VariantCardListView as d,VariantCardGridView as i}from"./variant.js";const l=i=>{let{selectedVariants:l,setSelectedVariants:o,selectedCollectionsDispatch:c,outOfStockAction:p}=i;const[g,b]=a(-1);function f(e){if(null==e?void 0:e.transform){const r=`translate(0px, ${e.transform.split(",").pop()}`;return Object.assign(Object.assign({},e),{transform:r})}return e}return e(t,Object.assign({droppableId:"droppable-list"},{children:(a,t)=>r("div",Object.assign({},a.droppableProps,{ref:a.innerRef,style:Object.assign({backgroundColor:n.surface.subdued,padding:"0.05px",height:l.length<8?"550px":"100%"},a.droppableProps.style)},{children:[l.map(((r,a)=>e("div",Object.assign({style:{background:n.surface.hovered,margin:"5px",boxShadow:a===g?"0px 4px 12px rgba(0, 0, 0, 0.12)":""},onMouseEnter:()=>b(a),onMouseLeave:()=>b(-1)},{children:e(s,Object.assign({draggableId:`${r.productId}-${r.variantId}`,index:a},{children:(t,s)=>e("div",Object.assign({ref:t.innerRef},t.draggableProps,t.dragHandleProps,{style:f(Object.assign(Object.assign({},t.draggableProps.style),t.draggableSnapshot))},{children:e(d,{data:r,selectedCollectionsDispatch:c,onDelete:()=>{const e=l.slice();e[a].displayOrder=null,e.splice(a,1),o(e)},outOfStockAction:p},`${r.productId}-${r.variantId}`)}))}),`${r.productId}-${r.variantId}`)}),`${r.productId}-${r.variantId}`))),a.placeholder&&t.isDraggingOver?e("div",Object.assign({style:{background:n.surface.hovered,margin:"5px"}},{children:a.placeholder})):null]}))}))},o=a=>{let{selectedVariants:n}=a;return e(t,Object.assign({droppableId:"droppable-horizontal"},{children:a=>r("div",Object.assign({},a.droppableProps,{ref:a.innerRef,style:Object.assign(Object.assign({},a.droppableProps.style),{display:"flex"})},{children:[e(t,Object.assign({droppableId:"droppable-vertical",direction:"horizontal"},{children:a=>r("div",Object.assign({},a.droppableProps,{ref:a.innerRef,style:Object.assign(Object.assign({},a.droppableProps.style),{display:"flex",flexWrap:"wrap",flexDirection:"row"})},{children:[n.map(((a,t)=>e(s,Object.assign({draggableId:`${a.productId}-${a.variantId}`,index:t},{children:(t,s)=>r("div",Object.assign({ref:t.innerRef},t.draggableProps,t.dragHandleProps,{children:[e(i,{data:a}),t.placeholder]}))}),`${a.productId}-${a.variantId}`))),a.placeholder]}))})),a.placeholder]}))}))};export{o as VariantsGrid,l as VariantsList};
1
+ import{jsx as e,jsxs as r}from"react/jsx-runtime";import{useState as a}from"react";import{Droppable as t,Draggable as s}from"react-beautiful-dnd";import{COLORS as n}from"../../constants/Theme.js";import{VariantCardListView as d,VariantCardGridView as i}from"./variant.js";const o=i=>{let{selectedVariants:o,setSelectedVariants:l,selectedCollectionsDispatch:c,outOfStockAction:p}=i;const[g,b]=a(-1);function f(e){if(null==e?void 0:e.transform){const r=`translate(0px, ${e.transform.split(",").pop()}`;return Object.assign(Object.assign({},e),{transform:r})}return e}return e(t,Object.assign({droppableId:"droppable-list"},{children:(a,t)=>r("div",Object.assign({},a.droppableProps,{ref:a.innerRef,style:Object.assign({backgroundColor:n.surface.subdued,padding:"0.05px",height:o.length<8?"550px":"100%",overflow:"auto"},a.droppableProps.style)},{children:[o.map(((r,a)=>e("div",Object.assign({style:{background:n.surface.hovered,margin:"5px",boxShadow:a===g?"0px 4px 12px rgba(0, 0, 0, 0.12)":""},onMouseEnter:()=>b(a),onMouseLeave:()=>b(-1)},{children:e(s,Object.assign({draggableId:`${r.productId}-${r.variantId}`,index:a},{children:(t,s)=>e("div",Object.assign({ref:t.innerRef},t.draggableProps,t.dragHandleProps,{style:f(Object.assign(Object.assign({},t.draggableProps.style),t.draggableSnapshot))},{children:e(d,{data:r,selectedCollectionsDispatch:c,onDelete:()=>{const e=o.slice();e[a].displayOrder=null,e.splice(a,1),l(e)},outOfStockAction:p},`${r.productId}-${r.variantId}`)}))}),`${r.productId}-${r.variantId}`)}),`${r.productId}-${r.variantId}`))),a.placeholder&&t.isDraggingOver?e("div",Object.assign({style:{background:n.surface.hovered,margin:"5px"}},{children:a.placeholder})):null]}))}))},l=a=>{let{selectedVariants:n}=a;return e(t,Object.assign({droppableId:"droppable-horizontal"},{children:a=>r("div",Object.assign({},a.droppableProps,{ref:a.innerRef,style:Object.assign(Object.assign({},a.droppableProps.style),{display:"flex"})},{children:[e(t,Object.assign({droppableId:"droppable-vertical",direction:"horizontal"},{children:a=>r("div",Object.assign({},a.droppableProps,{ref:a.innerRef,style:Object.assign(Object.assign({},a.droppableProps.style),{display:"flex",flexWrap:"wrap",flexDirection:"row"})},{children:[n.map(((a,t)=>e(s,Object.assign({draggableId:`${a.productId}-${a.variantId}`,index:t},{children:(t,s)=>r("div",Object.assign({ref:t.innerRef},t.draggableProps,t.dragHandleProps,{children:[e(i,{data:a}),t.placeholder]}))}),`${a.productId}-${a.variantId}`))),a.placeholder]}))})),a.placeholder]}))}))};export{l as VariantsGrid,o as VariantsList};
@@ -1 +1 @@
1
- import{jsxs as n,jsx as o}from"react/jsx-runtime";import{cloneDeep as t}from"lodash";import{useState as e,useEffect as i}from"react";import{POD as s}from"../../template-preview/models/WhatsAppTemplate.js";import{useTemplateModalContext as l}from"../context/templateModalContext.js";import{useAdditionalVariables as a}from"../custom-hooks/useAdditionalVariables.js";import{getAllDataFromTemplateComponent as d}from"../utils/getDataFromTemplateComponent.js";import{BackTrackComponent as r}from"./BackTrackComponent.js";import{DiscountCodeComponent as p}from"./DiscountCodeComponent.js";import{EditTemplateMediaContainer as c}from"./EditMediaV2.style.js";import u from"./EditWhatsAppTemplateMediaV2.js";import m from"./VariableConnector.js";import{Container as v}from"./VariableConnectorsPanel.js";import b from"./VariableConnectorWhatsApp.js";import g from"./VariableEditorHeader.js";import f from"./WhatsAppTemplateCardButtonV2.js";const h=h=>{let{template:j,onTemplateChange:O,whatsappSpecificPickerMeta:C,showVariableModal:y,variableList:T,variableListForImage:x,discountCode:V,setDiscountCode:B}=h;var L,E,U,k,I,w,R,A,N,P,S,_,M,Q;const D=j.isCarouselType,{originalVariableList:H,pod:q,extras:Y,selectedCarouselIndex:K,isProductCarouselType:W}=l(),{descriptionComponents:$,urlBtns:F,qrbBtns:X,imageComponent:z,bodyVariables:G,headerVariables:J}=d(j),[Z,nn]=e(!1),[on,tn]=e(-1===K?{descriptionComponents:$,urlBtns:F,qrbBtns:X,imageComponent:z,bodyVariables:G,headerVariables:J}:{}),[en,sn]=e(!1);function ln(n,o,e){var i,s,l,a,d,r,p,c,u,m;const v=null!=K&&K>-1?{components:null===(i=Object.assign({},j).components[1].cards)||void 0===i?void 0:i[K].components,mapping:null===(s=Object.assign({},j).mapping.cards)||void 0===s?void 0:s[K]}:Object.assign({},j),b=t(v),g="custom"===o&&"string"==typeof n,f=g?n:"string"!=typeof n?n.defaultValue:"";if(null!=K&&K>-1&&W){const o=Object.assign({},j).components.map((n=>{var o;return"CAROUSEL"===n.type?Object.assign(Object.assign({},n),{cards:null===(o=n.cards)||void 0===o?void 0:o.map((n=>Object.assign(Object.assign({},n),{components:n.components.map((n=>{var o,t,i;if("BUTTONS"===n.type){const s=null===(o=n.buttons)||void 0===o?void 0:o.filter((n=>"URL"===n.type));let l=null!==(t=null==s?void 0:s[e])&&void 0!==t?t:{};l=Object.assign(Object.assign({},l),{url:"https://d.bik.ai/{{1}}",example:[f]});const a=null===(i=n.buttons)||void 0===i?void 0:i.map((n=>"URL"===n.type&&(null==n?void 0:n.text)===(null==l?void 0:l.text)?l:n));return Object.assign(Object.assign({},n),{buttons:a})}return n}))})))}):n})),i=null===(a=null===(l=Object.assign({},j).mapping)||void 0===l?void 0:l.cards)||void 0===a?void 0:a.map((o=>{var t;return Object.assign(Object.assign({},o),{buttons:null===(t=null==o?void 0:o.buttons)||void 0===t?void 0:t.map((o=>g?"((customBtnPlaceholder))":"string"!=typeof n?n.placeHolder:""))})})),s=t(j);return s.components=o,s.mapping.cards=i,void(null==O||O(Object.assign({},s)))}const h=null==b?void 0:b.components.findIndex((n=>"BUTTONS"===n.type));if(void 0!==h&&h>-1){const t=null===(d=null==b?void 0:b.components[h].buttons)||void 0===d?void 0:d.filter((n=>"URL"===n.type));if((null==t?void 0:t.length)>0){const i="custom"===o&&"string"==typeof n,s=i?n:"string"!=typeof n?n.defaultValue:"";let l=t[e];l=Object.assign(Object.assign({},l),{url:"https://d.bik.ai/{{1}}",example:[s]});const a=[...null!==(c=null===(p=null===(r=b.components)||void 0===r?void 0:r[h])||void 0===p?void 0:p.buttons)&&void 0!==c?c:[]].map((n=>"URL"===n.type&&(null==n?void 0:n.text)===(null==l?void 0:l.text)?l:n)),d=Object.assign(Object.assign({},b.components[h]),{buttons:a}),m=null===(u=b.mapping)||void 0===u?void 0:u.buttons;m&&m.length>0&&(m[e]=i?"((customBtnPlaceholder))":"string"!=typeof n?n.placeHolder:"");const v=Object.assign(Object.assign({},b.mapping),{buttons:m});b.mapping=v;const g=[...b.components];g[h]=d,b.components=g}}if("string"!=typeof n){"checkout.checkoutUrl"===(null===(m=n.placeHolder)||void 0===m?void 0:m.slice(2,-2))?nn(!0):(nn(!1),null==B||B(""))}if(null!=K&&K>-1){const n=t(j);n.components[1].cards[K].components=b.components,n.mapping.cards[K]=b.mapping,null==O||O(Object.assign({},n))}else null==O||O(b)}function an(n,o,e){var i,s,l,a,d,r;const p=null!=K&&K>-1?{components:null===(i=Object.assign({},j).components[1].cards)||void 0===i?void 0:i[K].components,mapping:null===(s=Object.assign({},j).mapping.cards)||void 0===s?void 0:s[K]}:Object.assign({},j);if(null!=K&&K>-1&&W){const o=Object.assign({},j).components.map((o=>{var t;return"CAROUSEL"===o.type?Object.assign(Object.assign({},o),{cards:null===(t=o.cards)||void 0===t?void 0:t.map((o=>Object.assign(Object.assign({},o),{components:o.components.map((o=>{var t,i,s;if("BUTTONS"===o.type){const l=null===(t=o.buttons)||void 0===t?void 0:t.filter((n=>"QUICK_REPLY"===n.type));let a=null!==(i=null==l?void 0:l[e])&&void 0!==i?i:{};a=Object.assign(Object.assign({},a),{flowId:n.flowId,flowName:n.flowName});const d=null===(s=o.buttons)||void 0===s?void 0:s.map((n=>"QUICK_REPLY"===n.type&&(null==n?void 0:n.text)===(null==a?void 0:a.text)?a:n));return Object.assign(Object.assign({},o),{buttons:d})}return o}))})))}):o})),i=t(j);return i.components=o,void(null==O||O(Object.assign({},i)))}const c=null==p?void 0:p.components.findIndex((n=>"BUTTONS"===n.type));if(void 0!==c&&c>-1){const o=null===(l=null==p?void 0:p.components[c].buttons)||void 0===l?void 0:l.filter((n=>"QUICK_REPLY"===n.type));if(o){let t=o[e];t=Object.assign(Object.assign({},t),{flowId:n.flowId,flowName:n.flowName});const i=[...null!==(r=null===(d=null===(a=p.components)||void 0===a?void 0:a[c])||void 0===d?void 0:d.buttons)&&void 0!==r?r:[]].map((n=>"QUICK_REPLY"===n.type&&(null==n?void 0:n.text)===(null==t?void 0:t.text)?t:n)),s=Object.assign(Object.assign({},p.components[c]),{buttons:i}),l=[...p.components];l[c]=s,p.components=l}}if(null!=K&&K>-1){const n=t(j);n.components[1].cards[K].components=p.components,null==O||O(Object.assign({},n))}else null==O||O(p)}i((()=>{var n,o;if(null===(n=j.mapping.buttons)||void 0===n?void 0:n.find((n=>"checkout.checkoutUrl"===n.slice(2,-2))))nn(!0);else{nn(!1);const n=null===(o=null==Y?void 0:Y.discountCodeExtra)||void 0===o?void 0:o[1];null==n||n("")}}),[j]),i((()=>{var n,o,t,e;if(null!=K&&K>-1){const i={components:null===(o=null===(n=j.components[1])||void 0===n?void 0:n.cards)||void 0===o?void 0:o[K].components,mapping:null===(e=null===(t=null==j?void 0:j.mapping)||void 0===t?void 0:t.cards)||void 0===e?void 0:e[K]},{descriptionComponents:s,urlBtns:l,qrbBtns:a,imageComponent:r,bodyVariables:p,headerVariables:c}=d(i);tn({descriptionComponents:s,urlBtns:l,qrbBtns:a,imageComponent:r,bodyVariables:p,headerVariables:c})}else if(null!=K&&-1===K){const{descriptionComponents:n,urlBtns:o,qrbBtns:t,imageComponent:e,bodyVariables:i,headerVariables:s}=d(j);tn({descriptionComponents:n,urlBtns:o,qrbBtns:t,imageComponent:e,bodyVariables:i,headerVariables:s})}}),[K]),i((()=>{var n,o,t,e;if(null!=K&&K>-1&&en){const i={components:null===(o=null===(n=j.components[1])||void 0===n?void 0:n.cards)||void 0===o?void 0:o[K].components,mapping:null===(e=null===(t=null==j?void 0:j.mapping)||void 0===t?void 0:t.cards)||void 0===e?void 0:e[K]},{descriptionComponents:s,urlBtns:l,qrbBtns:a,imageComponent:r,bodyVariables:p,headerVariables:c}=d(i);tn({descriptionComponents:s,urlBtns:l,qrbBtns:a,imageComponent:r,bodyVariables:p,headerVariables:c}),sn(!1)}}),[en]);const dn=a({variableList:T,categoryDisplayName:"Custom Variables",variableDisplayName:"Custom Text",variableValue:"{{custom.text}}"});return n(v,Object.assign({style:{flexDirection:"column",width:400,maxHeight:460}},{children:[!!on.imageComponent&&!W&&o(c,{children:o(u,{whatsappSpecificPickerMeta:C,mediaComponent:D?on.imageComponent:z,updateTemplateImageUrl:function(n,o){var e,i,s,l,a;let d;d=null!=K&&K>-1?{components:null===(i=null===(e=j.components[1])||void 0===e?void 0:e.cards)||void 0===i?void 0:i[K].components,mapping:null===(l=null===(s=null==j?void 0:j.mapping)||void 0===s?void 0:s.cards)||void 0===l?void 0:l[K]}:Object.assign({},j);const r=null===(a=null==d?void 0:d.components)||void 0===a?void 0:a.findIndex((n=>{if("HEADER"===n.type&&"NONE"!==n.format&&"TEXT"!==n.format)return!0}));if(void 0!==r&&r>-1&&(null==d?void 0:d.components[r])){const t=Object.assign(Object.assign({},d.components[r]),{format:o,example:{header_handle:[n]}}),e=[...d.components];e[r]=t,d=Object.assign(Object.assign({},d),{components:e})}if(d.mapping&&(d.mapping=Object.assign(Object.assign({},d.mapping),{header:void 0})),null!=K&&K>-1){const n=t(j);n.components[1].cards[K].components=d.components,n.mapping.cards[K]=d.mapping,null==O||O(Object.assign({},n)),sn(!0)}else null==O||O(Object.assign({},d))},template:j,variableListForImage:x})}),(on.bodyVariables.length>0||on.headerVariables.length>0)&&o(g,{containerStyle:{paddingTop:on.mediaComponent?24:8},headerText:"Edit variable values",subText:"Edit values for the variables used in template",toolTipInfo:"Variables are placeholder texts which can either be filled through data or custom texts. These can be edited through the dropdowns below"}),null===(L=on.descriptionComponents)||void 0===L?void 0:L.map(((n,t)=>o(b,{originalVariableList:null!=K&&K>-1?H.cards[K]:H,type:n.type,descriptionComponent:n.component,showVariableModal:y,variableList:T},t))),(null===(U=null===(E=null!=K&&K>-1?H.cards[K].buttons:null==H?void 0:H.buttons)||void 0===E?void 0:E.filter((n=>"URL"===n.type)))||void 0===U?void 0:U.length)>0&&o(g,{headerText:"Edit buttons",subText:"Edit the link connected to the CTA button"}),null===(I=null===(k=null!=K&&K>-1?H.cards[K].buttons:null==H?void 0:H.buttons)||void 0===k?void 0:k.filter((n=>q===s.CHATBOT||"URL"===n.type)))||void 0===I?void 0:I.map(((n,t)=>{if("URL"===n.type)return o(f,{variableListIndex:t,CTAoptions:null==C?void 0:C.CTAoptions,button:n,currentVariableList:null!=K&&K>-1?Object.assign({},H.cards[K]):Object.assign({},H),updateSelectedURLTemplateBtn:ln,variableList:T},`${t}_${K}`)})),(null===(R=null===(w=null!=K&&K>-1?H.cards[K].buttons:null==H?void 0:H.buttons)||void 0===w?void 0:w.filter((n=>"QUICK_REPLY"===n.type)))||void 0===R?void 0:R.length)>0&&(q!==s.CHATBOT?o(g,{headerText:"Edit buttons",subText:"Edit the chatflows triggered on clicking the buttons",toolTipInfo:"There is an option to trigger chatflows through the buttons which can keep the user engaged"}):o(r,{backTrackMessage:null===(A=null==Y?void 0:Y.backTrackExtra)||void 0===A?void 0:A[0],setBackTrackMessage:null===(N=null==Y?void 0:Y.backTrackExtra)||void 0===N?void 0:N[1]})),null===(S=null===(P=null!=K&&K>-1?H.cards[K].buttons:null==H?void 0:H.buttons)||void 0===P?void 0:P.filter((n=>"QUICK_REPLY"===n.type)))||void 0===S?void 0:S.map(((n,t)=>{if("QUICK_REPLY"===n.type)return o(f,{variableListIndex:t,QRBoptions:null==C?void 0:C.QRBoptions,button:n,currentVariableList:null!=K&&K>-1?Object.assign({},H.cards[K]):Object.assign({},H),updateSelectedQRBTemplateBtn:an},`${t}_${K}`)})),q===s.CHATBOT&&Z&&o(p,{discountCode:null===(_=null==Y?void 0:Y.discountCodeExtra)||void 0===_?void 0:_[0],setDiscountCode:null===(M=null==Y?void 0:Y.discountCodeExtra)||void 0===M?void 0:M[1],variableList:T}),null===(Q=null!=K&&K>-1?H.cards[K].buttons:null==H?void 0:H.buttons)||void 0===Q?void 0:Q.map(((n,t)=>{var e,i,s;if("COPY_CODE"===n.type)return o(m,{index:t,variable:{variableName:null!==(e=n.text)&&void 0!==e?e:"Copy Code",updatedValue:null!==(i=n.buttonVariable)&&void 0!==i?i:"",type:"string",isEditableVariable:!0,index:null!==(s=n.index)&&void 0!==s?s:0},showVariableModal:!0,variableList:dn,componentType:"BUTTONS"},t)}))]}))};export{h as default};
1
+ import{jsxs as n,jsx as o}from"react/jsx-runtime";import{cloneDeep as t}from"lodash";import{useState as e,useEffect as i}from"react";import{POD as s}from"../../template-preview/models/WhatsAppTemplate.js";import{useTemplateModalContext as l}from"../context/templateModalContext.js";import{useAdditionalVariables as a}from"../custom-hooks/useAdditionalVariables.js";import{getAllDataFromTemplateComponent as d}from"../utils/getDataFromTemplateComponent.js";import{BackTrackComponent as r}from"./BackTrackComponent.js";import{DiscountCodeComponent as p}from"./DiscountCodeComponent.js";import{EditTemplateMediaContainer as c}from"./EditMediaV2.style.js";import u from"./EditWhatsAppTemplateMediaV2.js";import m from"./VariableConnector.js";import{Container as v}from"./VariableConnectorsPanel.js";import b from"./VariableConnectorWhatsApp.js";import g from"./VariableEditorHeader.js";import f from"./WhatsAppTemplateCardButtonV2.js";const h=h=>{let{template:j,onTemplateChange:O,whatsappSpecificPickerMeta:C,showVariableModal:y,variableList:T,variableListForImage:x,discountCode:V,setDiscountCode:B}=h;var L,E,U,k,I,w,R,A,N,P,S,_,H,M;const Q=j.isCarouselType,{originalVariableList:D,pod:q,extras:Y,selectedCarouselIndex:K,isProductCarouselType:W}=l(),{descriptionComponents:$,urlBtns:F,qrbBtns:X,imageComponent:z,bodyVariables:G,headerVariables:J}=d(j),[Z,nn]=e(!1),[on,tn]=e(-1===K?{descriptionComponents:$,urlBtns:F,qrbBtns:X,imageComponent:z,bodyVariables:G,headerVariables:J}:{}),[en,sn]=e(!1);function ln(n,o,e){var i,s,l,a,d,r,p,c,u,m;const v=null!=K&&K>-1?{components:null===(i=Object.assign({},j).components[1].cards)||void 0===i?void 0:i[K].components,mapping:null===(s=Object.assign({},j).mapping.cards)||void 0===s?void 0:s[K]}:Object.assign({},j),b=t(v),g="custom"===o&&"string"==typeof n,f=g?n:"string"!=typeof n?n.defaultValue:"";if(null!=K&&K>-1&&W){const o=Object.assign({},j).components.map((n=>{var o;return"CAROUSEL"===n.type?Object.assign(Object.assign({},n),{cards:null===(o=n.cards)||void 0===o?void 0:o.map((n=>Object.assign(Object.assign({},n),{components:n.components.map((n=>{var o,t,i;if("BUTTONS"===n.type){const s=null===(o=n.buttons)||void 0===o?void 0:o.filter((n=>"URL"===n.type));let l=null!==(t=null==s?void 0:s[e])&&void 0!==t?t:{};l=Object.assign(Object.assign({},l),{url:"https://d.bik.ai/{{1}}",example:[f]});const a=null===(i=n.buttons)||void 0===i?void 0:i.map((n=>"URL"===n.type&&(null==n?void 0:n.text)===(null==l?void 0:l.text)?l:n));return Object.assign(Object.assign({},n),{buttons:a})}return n}))})))}):n})),i=null===(a=null===(l=Object.assign({},j).mapping)||void 0===l?void 0:l.cards)||void 0===a?void 0:a.map((o=>{var t;return Object.assign(Object.assign({},o),{buttons:null===(t=null==o?void 0:o.buttons)||void 0===t?void 0:t.map((o=>g?"((customBtnPlaceholder))":"string"!=typeof n?n.placeHolder:""))})})),s=t(j);return s.components=o,s.mapping.cards=i,void(null==O||O(Object.assign({},s)))}const h=null==b?void 0:b.components.findIndex((n=>"BUTTONS"===n.type));if(void 0!==h&&h>-1){const t=null===(d=null==b?void 0:b.components[h].buttons)||void 0===d?void 0:d.filter((n=>"URL"===n.type));if((null==t?void 0:t.length)>0){const i="custom"===o&&"string"==typeof n,s=i?n:"string"!=typeof n?n.defaultValue:"";let l=t[e];l=Object.assign(Object.assign({},l),{url:"https://d.bik.ai/{{1}}",example:[s]});const a=[...null!==(c=null===(p=null===(r=b.components)||void 0===r?void 0:r[h])||void 0===p?void 0:p.buttons)&&void 0!==c?c:[]].map((n=>"URL"===n.type&&(null==n?void 0:n.text)===(null==l?void 0:l.text)?l:n)),d=Object.assign(Object.assign({},b.components[h]),{buttons:a}),m=null===(u=b.mapping)||void 0===u?void 0:u.buttons;m&&m.length>0&&(m[e]=i?"((customBtnPlaceholder))":"string"!=typeof n?n.placeHolder:"");const v=Object.assign(Object.assign({},b.mapping),{buttons:m});b.mapping=v;const g=[...b.components];g[h]=d,b.components=g}}if("string"!=typeof n){"checkout.checkoutUrl"===(null===(m=n.placeHolder)||void 0===m?void 0:m.slice(2,-2))?nn(!0):(nn(!1),null==B||B(""))}if(null!=K&&K>-1){const n=t(j);n.components[1].cards[K].components=b.components,n.mapping.cards[K]=b.mapping,null==O||O(Object.assign({},n))}else null==O||O(b)}function an(n,o,e){var i,s,l,a,d,r;const p=null!=K&&K>-1?{components:null===(i=Object.assign({},j).components[1].cards)||void 0===i?void 0:i[K].components,mapping:null===(s=Object.assign({},j).mapping.cards)||void 0===s?void 0:s[K]}:Object.assign({},j);if(null!=K&&K>-1&&W){const o=Object.assign({},j).components.map((o=>{var t;return"CAROUSEL"===o.type?Object.assign(Object.assign({},o),{cards:null===(t=o.cards)||void 0===t?void 0:t.map((o=>Object.assign(Object.assign({},o),{components:o.components.map((o=>{var t,i,s;if("BUTTONS"===o.type){const l=null===(t=o.buttons)||void 0===t?void 0:t.filter((n=>"QUICK_REPLY"===n.type));let a=null!==(i=null==l?void 0:l[e])&&void 0!==i?i:{};a=Object.assign(Object.assign({},a),{flowId:n.flowId,flowName:n.flowName});const d=null===(s=o.buttons)||void 0===s?void 0:s.map((n=>"QUICK_REPLY"===n.type&&(null==n?void 0:n.text)===(null==a?void 0:a.text)?a:n));return Object.assign(Object.assign({},o),{buttons:d})}return o}))})))}):o})),i=t(j);return i.components=o,void(null==O||O(Object.assign({},i)))}const c=null==p?void 0:p.components.findIndex((n=>"BUTTONS"===n.type));if(void 0!==c&&c>-1){const o=null===(l=null==p?void 0:p.components[c].buttons)||void 0===l?void 0:l.filter((n=>"QUICK_REPLY"===n.type));if(o){let t=o[e];t=Object.assign(Object.assign({},t),{flowId:n.flowId,flowName:n.flowName});const i=[...null!==(r=null===(d=null===(a=p.components)||void 0===a?void 0:a[c])||void 0===d?void 0:d.buttons)&&void 0!==r?r:[]].map((n=>"QUICK_REPLY"===n.type&&(null==n?void 0:n.text)===(null==t?void 0:t.text)?t:n)),s=Object.assign(Object.assign({},p.components[c]),{buttons:i}),l=[...p.components];l[c]=s,p.components=l}}if(null!=K&&K>-1){const n=t(j);n.components[1].cards[K].components=p.components,null==O||O(Object.assign({},n))}else null==O||O(p)}i((()=>{var n,o;if(null===(n=j.mapping.buttons)||void 0===n?void 0:n.find((n=>"checkout.checkoutUrl"===n.slice(2,-2))))nn(!0);else{nn(!1);const n=null===(o=null==Y?void 0:Y.discountCodeExtra)||void 0===o?void 0:o[1];null==n||n("")}}),[j]),i((()=>{var n,o,t,e;if(null!=K&&K>-1){const i={components:null===(o=null===(n=j.components[1])||void 0===n?void 0:n.cards)||void 0===o?void 0:o[K].components,mapping:null===(e=null===(t=null==j?void 0:j.mapping)||void 0===t?void 0:t.cards)||void 0===e?void 0:e[K]},{descriptionComponents:s,urlBtns:l,qrbBtns:a,imageComponent:r,bodyVariables:p,headerVariables:c}=d(i);tn({descriptionComponents:s,urlBtns:l,qrbBtns:a,imageComponent:r,bodyVariables:p,headerVariables:c})}else if(null!=K&&-1===K){const{descriptionComponents:n,urlBtns:o,qrbBtns:t,imageComponent:e,bodyVariables:i,headerVariables:s}=d(j);tn({descriptionComponents:n,urlBtns:o,qrbBtns:t,imageComponent:e,bodyVariables:i,headerVariables:s})}}),[K]),i((()=>{var n,o,t,e;if(null!=K&&K>-1&&en){const i={components:null===(o=null===(n=j.components[1])||void 0===n?void 0:n.cards)||void 0===o?void 0:o[K].components,mapping:null===(e=null===(t=null==j?void 0:j.mapping)||void 0===t?void 0:t.cards)||void 0===e?void 0:e[K]},{descriptionComponents:s,urlBtns:l,qrbBtns:a,imageComponent:r,bodyVariables:p,headerVariables:c}=d(i);tn({descriptionComponents:s,urlBtns:l,qrbBtns:a,imageComponent:r,bodyVariables:p,headerVariables:c}),sn(!1)}}),[en]);const dn=a({variableList:T,categoryDisplayName:"Custom Variables",variableDisplayName:"Custom Text",variableValue:"{{custom.text}}"});return n(v,Object.assign({style:{flexDirection:"column",width:400,maxHeight:460}},{children:[!!on.imageComponent&&!W&&o(c,{children:o(u,{whatsappSpecificPickerMeta:C,mediaComponent:Q?on.imageComponent:z,updateTemplateImageUrl:function(n,o){var e,i,s,l,a;let d;d=null!=K&&K>-1?{components:null===(i=null===(e=j.components[1])||void 0===e?void 0:e.cards)||void 0===i?void 0:i[K].components,mapping:null===(l=null===(s=null==j?void 0:j.mapping)||void 0===s?void 0:s.cards)||void 0===l?void 0:l[K]}:Object.assign({},j);const r=null===(a=null==d?void 0:d.components)||void 0===a?void 0:a.findIndex((n=>{if("HEADER"===n.type&&"NONE"!==n.format&&"TEXT"!==n.format)return!0}));if(void 0!==r&&r>-1&&(null==d?void 0:d.components[r])){const t=Object.assign(Object.assign({},d.components[r]),{format:o,example:{header_handle:[n]}}),e=[...d.components];e[r]=t,d=Object.assign(Object.assign({},d),{components:e})}if(d.mapping&&(d.mapping=Object.assign(Object.assign({},d.mapping),{header:void 0})),null!=K&&K>-1){const n=t(j);n.components[1].cards[K].components=d.components,n.mapping.cards[K]=d.mapping,null==O||O(Object.assign({},n)),sn(!0)}else null==O||O(Object.assign({},d))},template:j,variableListForImage:x})}),(on.bodyVariables.length>0||on.headerVariables.length>0)&&o(g,{containerStyle:{paddingTop:on.mediaComponent?24:8},headerText:"Edit variable values",subText:"Edit values for the variables used in template",toolTipInfo:"Variables are placeholder texts which can either be filled through data or custom texts. These can be edited through the dropdowns below"}),null===(L=on.descriptionComponents)||void 0===L?void 0:L.map(((n,t)=>o(b,{originalVariableList:null!=K&&K>-1?D.cards[K]:D,type:n.type,descriptionComponent:n.component,showVariableModal:y,variableList:T},t))),(null===(U=null===(E=null!=K&&K>-1?D.cards[K].buttons:null==D?void 0:D.buttons)||void 0===E?void 0:E.filter((n=>"URL"===n.type)))||void 0===U?void 0:U.length)>0&&o(g,{headerText:"Edit buttons",subText:"Edit the link connected to the CTA button"}),null===(I=null===(k=null!=K&&K>-1?D.cards[K].buttons:null==D?void 0:D.buttons)||void 0===k?void 0:k.filter((n=>q===s.CHATBOT||"URL"===n.type)))||void 0===I?void 0:I.map(((n,t)=>{if("URL"===n.type)return o(f,{variableListIndex:t,CTAoptions:null==C?void 0:C.CTAoptions,button:n,currentVariableList:null!=K&&K>-1?Object.assign({},D.cards[K]):Object.assign({},D),updateSelectedURLTemplateBtn:ln,variableList:T},`${t}_${K}`)})),(null===(R=null===(w=null!=K&&K>-1?D.cards[K].buttons:null==D?void 0:D.buttons)||void 0===w?void 0:w.filter((n=>"QUICK_REPLY"===n.type)))||void 0===R?void 0:R.length)>0&&(q!==s.CHATBOT?o(g,{headerText:"Edit buttons",subText:"Edit the chatflows triggered on clicking the buttons",toolTipInfo:"There is an option to trigger chatflows through the buttons which can keep the user engaged"}):o(r,{backTrackMessage:null===(A=null==Y?void 0:Y.backTrackExtra)||void 0===A?void 0:A[0],setBackTrackMessage:null===(N=null==Y?void 0:Y.backTrackExtra)||void 0===N?void 0:N[1]})),null===(S=null===(P=null!=K&&K>-1?D.cards[K].buttons:null==D?void 0:D.buttons)||void 0===P?void 0:P.filter((n=>"QUICK_REPLY"===n.type)))||void 0===S?void 0:S.map(((n,t)=>{if("QUICK_REPLY"===n.type&&q!==s.CHATBOT)return o(f,{variableListIndex:t,QRBoptions:null==C?void 0:C.QRBoptions,button:n,currentVariableList:null!=K&&K>-1?Object.assign({},D.cards[K]):Object.assign({},D),updateSelectedQRBTemplateBtn:an},`${t}_${K}`)})),q===s.CHATBOT&&Z&&o(p,{discountCode:null===(_=null==Y?void 0:Y.discountCodeExtra)||void 0===_?void 0:_[0],setDiscountCode:null===(H=null==Y?void 0:Y.discountCodeExtra)||void 0===H?void 0:H[1],variableList:T}),null===(M=null!=K&&K>-1?D.cards[K].buttons:null==D?void 0:D.buttons)||void 0===M?void 0:M.map(((n,t)=>{var e,i,s;if("COPY_CODE"===n.type)return o(m,{index:t,variable:{variableName:null!==(e=n.text)&&void 0!==e?e:"Copy Code",updatedValue:null!==(i=n.buttonVariable)&&void 0!==i?i:"",type:"string",isEditableVariable:!0,index:null!==(s=n.index)&&void 0!==s?s:0},showVariableModal:!0,variableList:dn,componentType:"BUTTONS"},t)}))]}))};export{h as default};
@@ -1,10 +1,10 @@
1
- import{jsxs as e,jsx as t,Fragment as l}from"react/jsx-runtime";import a from"../../../assets/icons/edit.svg.js";import{format as i}from"date-fns";import{cloneDeep as n}from"lodash";import{useState as o,useEffect as s}from"react";import d from"styled-components";import{AddVariableV2SideModal as u}from"../../add-variableV2/AddVariableV2SideModal.js";import{CustomDateTime as c}from"../../custom-date-time/CustomDateTime.js";import{Dropdown as r}from"../../dropdown/Dropdown.js";import{Input as p}from"../../input/Input.js";import{truncate as m}from"../../product-picker-v2/collectionScreen.js";import{placeHolderNamePattern as v}from"../../template-preview/constants/regexPatterns.js";import{CHANNEL_TYPE as b}from"../../template-preview/models/Channels.js";import{POD as g}from"../../template-preview/models/WhatsAppTemplate.js";import{BodySecondary as O,BodyPrimary as h}from"../../TypographyStyle.js";import j from"../../../utils/StringUtils.js";import{COLORS as x}from"../../../constants/Theme.js";import{useTemplateModalContext as y}from"../context/templateModalContext.js";import{getVariableNameForEmailByIndex as f}from"../utils/getVariableNameEmail.js";const _=d.div`
1
+ import{jsxs as e,jsx as t,Fragment as l}from"react/jsx-runtime";import a from"../../../assets/icons/edit.svg.js";import{format as i}from"date-fns";import{cloneDeep as n}from"lodash";import{useState as o,useEffect as s}from"react";import u from"styled-components";import{AddVariableV2SideModal as d}from"../../add-variableV2/AddVariableV2SideModal.js";import{CustomDateTime as c}from"../../custom-date-time/CustomDateTime.js";import{Dropdown as r}from"../../dropdown/Dropdown.js";import{Input as p}from"../../input/Input.js";import{truncate as m}from"../../product-picker-v2/collectionScreen.js";import{placeHolderNamePattern as v}from"../../template-preview/constants/regexPatterns.js";import{CHANNEL_TYPE as b}from"../../template-preview/models/Channels.js";import{POD as g}from"../../template-preview/models/WhatsAppTemplate.js";import{BodySecondary as O,BodyPrimary as j}from"../../TypographyStyle.js";import h from"../../../utils/StringUtils.js";import{COLORS as y}from"../../../constants/Theme.js";import{useTemplateModalContext as x}from"../context/templateModalContext.js";import{getVariableNameForEmailByIndex as f}from"../utils/getVariableNameEmail.js";const _=u.div`
2
2
  /* surface/$color-background-warning-light */
3
3
 
4
- background: ${e=>e.focused&&e.channel===b.EMAIL?x.background.warning.light:"transparent"};
4
+ background: ${e=>e.focused&&e.channel===b.EMAIL?y.background.warning.light:"transparent"};
5
5
  border-radius: 4px;
6
6
  padding: 8px 10px;
7
- `,T=d.div`
7
+ `,T=u.div`
8
8
  position: absolute;
9
9
  top: 0;
10
10
  left: 0;
@@ -13,4 +13,4 @@ import{jsxs as e,jsx as t,Fragment as l}from"react/jsx-runtime";import a from"..
13
13
  background-color: rgba(0, 0, 0, 0.1);
14
14
  z-index: 1000;
15
15
  cursor: not-allowed;
16
- `,V={value:"custom_link",label:"Custom URL"},k={value:"custom_text",label:"Custom text"},E={value:"static_expiry",label:"Static Expiry"},A=d=>{let{onFocus:A,variable:S,index:C,showVariableModal:w,variableList:P,setShowDiscountCheckBox:D,componentType:B,CTAoptions:L}=d;var N,H,U;const[M,W]=o(!1),[R,$]=o(""),[I,z]=o([]),[Y,Z]=o(),[G,q]=o(!1),[F,K]=o(!1),{device:J,channel:Q,isError:X,originalVariableList:ee,template:te,templateSelectionTriggered:le,setTemplate:ae,setDisplayContent:ie,setOriginalVariableList:ne,globalNormalizedPlaceholders:oe,enabledCustomText:se,pod:de,selectedCarouselIndex:ue,isProductCarouselType:ce,disableEditVariable:re,disableEditExpiry:pe}=y();function me(){var e,t;const l=[];let a=[];if(Q!==b.MESSAGE||se){"link"===(null==S?void 0:S.type)?(l.push({label:"",options:[V,k]}),Z(V)):"date_time"===(null==S?void 0:S.type)?(l.push({label:"",options:[V,k]}),Z(E)):(l.push({label:"",options:[V,k,E]}),Z(k));const e=null!=oe?oe:[];z([...l,...e.map((e=>{var t,l;return Object.assign(Object.assign({},e),{label:j.toCapitilize(null===(l=null===(t=e.label)||void 0===t?void 0:t.replace(/([A-Z])/g," $1"))||void 0===l?void 0:l.toLowerCase())})}))]),a=[...l,...e]}else{const e=null!=oe?oe:[];z([{label:"",options:[k,V]},...e]),a=[{label:"",options:[k,V]},...e]}if((Q===b.WHATSAPP||Q===b.EMAIL||Q===b.MESSAGE)&&S.updatedValue)if(v.test(S.updatedValue)&&Q===b.WHATSAPP||S.updatedValue.startsWith("{{")&&Q!==b.WHATSAPP){const e=function(e,t,l){var a;let i={label:"",value:""};const n=l===b.WHATSAPP?e.updatedValue.replace("[[","").replace("]]",""):e.updatedValue.replace("{{","").replace("}}","");if(w){let t=e.updatedValue;if(de===g.CHATBOT&&"BUTTONS"===B){const l=null==L?void 0:L.filter((t=>t.placeHolder===e.updatedValue));l&&l.length>0&&(t=l[0].label)}i={label:t?t.replace("{{","").replace("}}","").trim().replace("."," "):"",value:null!==(a=e.updatedValue)&&void 0!==a?a:""}}else t.map((e=>{e.options.map((e=>{var t;(null===(t=e.value)||void 0===t?void 0:t.replace("{{","").replace("}}","").trim())===n.trim()&&(i=e)}))}));return i}(S,a,Q);e.value&&Z(e)}else"date_time"===S.type?(Z(E),$(S.updatedValue),Oe(null!==(e=S.index)&&void 0!==e?e:0,S.updatedValue)):(null===(t=S.updatedValue)||void 0===t?void 0:t.startsWith("https"))?(Z(V),$(S.updatedValue.split("https://")[1])):(Z(k),$(S.updatedValue))}function ve(e,t){var l,a,i;const n=e;$(""),Z(n),Q===b.WHATSAPP?"custom_text"!==n.value&&"custom_link"!==n.value&&"static_expiry"!==n.value?(ge(null!==(l=n.value)&&void 0!==l?l:"","string"),null==Oe||Oe(null!==(a=S.index)&&void 0!==a?a:0,n.value,!0)):(null==Oe||Oe(null!==(i=S.index)&&void 0!==i?i:0,R,!0,n.value),ge("","url"===n.bikPlaceholderType?"link":"string")):"custom_text"!==n.value&&"custom_link"!==n.value?ge(n.value,"url"===n.bikPlaceholderType?"link":"string"):($(""),ge("",n.value))}function be(e,t){var l;$(t);const a="custom_link"===(null==Y?void 0:Y.value)&&t?t.includes("https")?t:`https://${t}`:t;ge(a,"static_expiry"===e?"string":e),Q===b.WHATSAPP&&(null==Oe||Oe(null!==(l=S.index)&&void 0!==l?l:0,a,"custom_link"===e,e))}function ge(e,t){var l,a,i,o;const s="custom_link"===t?"link":"custom_text"===t?"string":t;if(Q!==b.WHATSAPP){const a=f(C+1),i=null===document||void 0===document?void 0:document.getElementById("mobile"===J?"template_html_mobile":"template_html_desktop"),n=Q===b.EMAIL?null===(l=null==i?void 0:i.contentWindow)||void 0===l?void 0:l.document.getElementById(a):document.getElementById(a);n&&(n.textContent="custom_text"!==t&&"custom_link"!==t||e?e:S.variableName);const o=ee.map(((t,l)=>l===C?Object.assign(Object.assign({},t),{type:s,updatedValue:e}):t));null==ne||ne(o)}if(Q===b.WHATSAPP){if(null!=ue&&ue>-1&&ce){const t=Object.assign({},ee).cards.map(((t,l)=>{var a;return Object.assign(Object.assign({},t),{body:null===(a=t.body)||void 0===a?void 0:a.map(((t,l)=>C===l?Object.assign(Object.assign({},t),{type:s,updatedValue:e}):t))})}));return void(null==ne||ne((e=>Object.assign(Object.assign({},e),{cards:t}))))}const l=null!=ue&&ue>-1?ee.cards[ue]:ee;let d=l.body,u=l.header,c=l.buttons;if("BODY"===B?d=null===(a=l.body)||void 0===a?void 0:a.map(((t,l)=>l===C?Object.assign(Object.assign({},t),{type:s,updatedValue:e}):t)):"HEADER"===B?u=null===(i=l.header)||void 0===i?void 0:i.map(((t,l)=>l===C?Object.assign(Object.assign({},t),{type:s,updatedValue:e}):t)):"BUTTONS"===B&&(c=null===(o=l.buttons)||void 0===o?void 0:o.map(((l,a)=>a===C?Object.assign(Object.assign({},l),{buttonVariable:"custom_link"===t?"((customPlaceholderName))":e,example:"COPY_CODE"===l.type?e:[e]}):l))),null!=ue&&ue>-1){const e=n(ee.cards);e[ue]={header:u,body:d,buttons:c},null==ne||ne((t=>Object.assign(Object.assign({},t),{cards:e})))}else null==ne||ne((e=>Object.assign(Object.assign({},e),{header:u,body:d,buttons:c})))}}function Oe(e,t,l,a){var i,o,s,d,u,c,r;if(null!=ue&&ue>-1&&ce){const o=Object.assign({},te).components.map((l=>{var a;return"CAROUSEL"===l.type?Object.assign(Object.assign({},l),{cards:null===(a=l.cards)||void 0===a?void 0:a.map((l=>Object.assign(Object.assign({},l),{components:l.components.map((l=>{var a,i,n,o,s;if("BODY"!==l.type)return l;if(null===(i=null===(a=l.example)||void 0===a?void 0:a.body_text)||void 0===i?void 0:i[0]){const a=[...null!==(s=null===(o=null===(n=l.example)||void 0===n?void 0:n.body_text)||void 0===o?void 0:o[0])&&void 0!==s?s:[]];a[e]=t.replace("{{","").replace("}}","").replace("((","").replace("))","");const i=Object.assign(Object.assign({},l.example),{body_text:[a]});return Object.assign(Object.assign({},l),{example:i})}}))})))}):l})),s=n(te);if(l){const l=null===(i=Object.assign({},te).mapping.cards)||void 0===i?void 0:i.map((l=>{var i;return Object.assign(Object.assign({},l),{body:null===(i=l.body)||void 0===i?void 0:i.map(((l,i)=>e===i?"custom_text"===a?`((editableVariable${i+10}))`:t:l))})}));s.mapping.cards=l}return s.components=o,void(null==ae||ae(s))}const p=null!=ue&&ue>-1?{components:null===(o=Object.assign({},te).components[1].cards)||void 0===o?void 0:o[ue].components,mapping:null===(s=Object.assign({},te).mapping.cards)||void 0===s?void 0:s[ue]}:Object.assign({},te),m=null===(d=null==p?void 0:p.components)||void 0===d?void 0:d.map((l=>{var a,i,n,o,s,d,u,c,r;const p=Object.assign({},l);if("BODY"===l.type&&"BODY"===B){if(null===(i=null===(a=l.example)||void 0===a?void 0:a.body_text)||void 0===i?void 0:i[0]){const l=[...null!==(s=null===(o=null===(n=p.example)||void 0===n?void 0:n.body_text)||void 0===o?void 0:o[0])&&void 0!==s?s:[]];l[e]=t.replace("{{","").replace("}}","").replace("((","").replace("))","");const a=Object.assign(Object.assign({},p.example),{body_text:[l]});return Object.assign(Object.assign({},p),{example:a})}}else if("HEADER"===l.type&&"HEADER"===B){if(null===(d=l.example)||void 0===d?void 0:d.header_text){const l=[...null!==(c=null===(u=p.example)||void 0===u?void 0:u.header_text)&&void 0!==c?c:[]];l[e]=t.replace("{{","").replace("}}","").replace("((","").replace("))","");const a=Object.assign(Object.assign({},p.example),{header_text:l});return Object.assign(Object.assign({},p),{example:a})}}else{if("BUTTONS"===l.type&&"BUTTONS"===B){const a=null===(r=l.buttons)||void 0===r?void 0:r.map(((l,a)=>a===e?Object.assign(Object.assign({},l),{example:"COPY_CODE"===l.type?t:[t]}):l));return a?Object.assign(Object.assign({},p),{buttons:a}):p}if("limited_time_offer"===l.type&&"limited_time_offer"===B)return Object.assign(Object.assign({},p),{example:Object.assign(Object.assign({},p.example),{limited_time_offer:t})})}return l}));if(p.components=m,l)if("BODY"===B&&(null===(u=null==p?void 0:p.mapping)||void 0===u?void 0:u.body))p.mapping=Object.assign(Object.assign({},p.mapping),{body:p.mapping.body.map(((l,i)=>e===i?"custom_text"===a?`((editableVariable${i+10}))`:t:l))});else if("HEADER"===B&&(null===(c=null==p?void 0:p.mapping)||void 0===c?void 0:c.header))p.mapping=Object.assign(Object.assign({},p.mapping),{header:p.mapping.header.map(((l,i)=>e===i?"custom_text"===a?`((editableVariable${i+20}))`:t:l))});else if("BUTTONS"===B&&(null===(r=null==p?void 0:p.mapping)||void 0===r?void 0:r.buttons)){let l=-1,i=-1;m.forEach((t=>{var a;"BUTTONS"===t.type&&(null===(a=t.buttons)||void 0===a||a.forEach(((t,a)=>{"URL"===t.type&&(l++,a===e&&"URL"==t.type&&(i=l))})))})),p.mapping=Object.assign(Object.assign({},p.mapping),{buttons:p.mapping.buttons.map(((e,l)=>l===i?"custom_link"===a?"((customPlaceholderName))":t:e))})}if(null!=ue&&ue>-1&&te){const e=n(te);e.components[1].cards[ue].components=p.components,e.mapping.cards[ue]=p.mapping,null==ae||ae(e)}else null==ae||ae(Object.assign({},p))}return s((()=>{M&&(null==A||A())}),[M]),s((()=>{!function(){var e,t,l,a,i;const n="mobile"===J?"template_html_mobile":"template_html_desktop",o=document.getElementById(n),s=(null!==(a=null===(l=null===(t=null===(e=null==o?void 0:o.contentWindow)||void 0===e?void 0:e.document)||void 0===t?void 0:t.body)||void 0===l?void 0:l.innerHTML)&&void 0!==a?a:"")+(null===(i=null==o?void 0:o.contentWindow)||void 0===i?void 0:i.document.head.innerHTML);Q===b.EMAIL&&(null==ie||ie(s))}()}),[le]),s((()=>{me()}),[]),s((()=>{me()}),[ue]),s((()=>{J&&Y&&R&&setTimeout((()=>{ge("custom_link"===(null==Y?void 0:Y.value)&&R?R.includes("https")?R:`https://${R}`:R,Y.value)}),100)}),[J]),s((()=>{!F&&Y&&S.updatedValue&&setTimeout((()=>{ge("custom_link"===(null==Y?void 0:Y.value)&&S.updatedValue?S.updatedValue.includes("https")?S.updatedValue:`https://${S.updatedValue}`:S.updatedValue,Y.value),K(!0)}),100)}),[Y]),e(_,Object.assign({channel:Q,focused:M,onMouseEnter:()=>W(!0),onMouseLeave:()=>W(!1)},{children:[t("div",Object.assign({style:{marginBottom:8}},{children:e(O,Object.assign({style:{color:X&&!Y?x.content.negative:x.content.primary}},{children:[null===(N=S.variableName)||void 0===N?void 0:N.replace("{{","").replace("}}","")," ","link"===(null==S?void 0:S.type)?"link":"variable"]}))})),t("div",Object.assign({style:{marginBottom:12}},{children:w?e("div",Object.assign({style:{display:"flex",border:"#E0E0E0 1px solid",borderRadius:4,padding:10,justifyContent:(null==Y?void 0:Y.label)?"space-between":"flex-end"}},{children:[t(h,Object.assign({numberOfLines:1},{children:de===g.CHATBOT?["static_expiry","custom_text"].includes(null!==(H=null==Y?void 0:Y.value)&&void 0!==H?H:"")?null==Y?void 0:Y.label:null==Y?void 0:Y.value:m(null!==(U=null==Y?void 0:Y.label)&&void 0!==U?U:"",20,!0)})),re||"date_time"===(null==S?void 0:S.type)&&pe?t(l,{}):t(a,{onClick:()=>{q(!G)},width:24,height:24,color:x.content.primary})]})):t(r,{disabled:re,options:I,isSearchable:!1,onSelect:ve,defaultOptions:Y?[Object.assign(Object.assign({},Y),{selected:!0})]:[]})})),("custom_text"===(null==Y?void 0:Y.value)||"custom_link"===(null==Y?void 0:Y.value))&&t(p,{state:re?"disabled":"none",labelText:"custom_text"===(null==Y?void 0:Y.value)?"Custom text value":"custom_link"===(null==Y?void 0:Y.value)?"Custom URL value":"",id:`variable-value-${null==Y?void 0:Y.value}-${C}`,value:R,errorMessage:X?R&&0!==R.trim().length?"custom_link"!==Y.value||/^https?:\/\/(?:www\.)?[-a-zA-Z0-9@:%._\+~#=]{1,256}\.[a-zA-Z0-9()]{1,6}\b(?:[-a-zA-Z0-9()@:%_\+.~#?&\/=]*)$/.test(`https://${R.trim()}`)&&0!==R.trim().length?"custom_link"!==Y.value&&R.length>30?"Length cannot be more than 30":"BUTTONS"===B&&"custom_link"!==Y.value?"Enter valid alpha numeric code":"":"Enter valid URL":"Required field":"",maxCharLimit:"custom_link"===(null==Y?void 0:Y.value)?2e3:"BUTTONS"===B?15:30,noKeyDownChange:!0,prefixText:"custom_link"===(null==Y?void 0:Y.value)?"https://":"",placeholder:"link"===S.type||"custom_link"===Y.value?"Enter custom URL here":"Enter custom text here",onChangeText:e=>{be(Y.value,e)}}),"static_expiry"===(null==Y?void 0:Y.value)&&e("div",Object.assign({style:{position:"relative"}},{children:[re&&t(T,{onClick:e=>e.preventDefault()}),t(c,{placement:"auto",time:i(R?new Date(R):new Date,"hh:mm a"),date:R?new Date(R):new Date,minDate:new Date,error:"",setError:()=>{},onChange:e=>{be("static_expiry",e.toISOString())}})]})),G&&t(u,{zIndex:2e3,data:null!=P?P:[],showVariable:G,setShowVariable:q,placeholder:"Add a variable",customTrigger:e=>{null==D||D(!1),"{{custom.url}}"===e.actualValue?ve({label:e.displayName,selected:!0,value:"custom_link"}):"{{custom.text}}"==e.actualValue?ve({label:e.displayName,selected:!0,value:"custom_text"}):"{{static.expiry}}"==e.actualValue?ve({label:e.displayName,selected:!0,value:"static_expiry"}):ve({label:e.displayName.replace("{{","").replace("}}","").trim().replace("."," "),selected:!0,value:e.actualValue,bikPlaceholderType:"string"})}})]}))};export{_ as Container,A as default};
16
+ `,k={value:"custom_link",label:"Custom URL"},E={value:"custom_text",label:"Custom text"},V={value:"static_expiry",label:"Static Expiry"},S=u=>{let{onFocus:S,variable:A,index:C,showVariableModal:B,variableList:P,setShowDiscountCheckBox:w,componentType:D,CTAoptions:N}=u;var L,U,H;const[R,M]=o(!1),[W,$]=o(""),[I,Y]=o([]),[z,Z]=o(),[G,q]=o(!1),[F,K]=o(!1),{device:J,channel:Q,isError:X,originalVariableList:ee,template:te,templateSelectionTriggered:le,setTemplate:ae,setDisplayContent:ie,setOriginalVariableList:ne,globalNormalizedPlaceholders:oe,enabledCustomText:se,pod:ue,selectedCarouselIndex:de,isProductCarouselType:ce,disableEditVariable:re,disableEditExpiry:pe}=x();function me(){var e,t;const l=[];let a=[];if(Q!==b.MESSAGE||se){"link"===(null==A?void 0:A.type)?(l.push({label:"",options:[k,E]}),Z(k)):"date_time"===(null==A?void 0:A.type)?(l.push({label:"",options:[k,E]}),Z(V)):(l.push({label:"",options:[k,E,V]}),Z(E));const e=null!=oe?oe:[];Y([...l,...e.map((e=>{var t,l;return Object.assign(Object.assign({},e),{label:h.toCapitilize(null===(l=null===(t=e.label)||void 0===t?void 0:t.replace(/([A-Z])/g," $1"))||void 0===l?void 0:l.toLowerCase())})}))]),a=[...l,...e]}else{const e=null!=oe?oe:[];Y([{label:"",options:[E,k]},...e]),a=[{label:"",options:[E,k]},...e]}if((Q===b.WHATSAPP||Q===b.EMAIL||Q===b.MESSAGE)&&A.updatedValue)if(v.test(A.updatedValue)&&Q===b.WHATSAPP||A.updatedValue.startsWith("{{")&&Q!==b.WHATSAPP){const e=function(e,t,l){var a;let i={label:"",value:""};const n=l===b.WHATSAPP?e.updatedValue.replace("[[","").replace("]]",""):e.updatedValue.replace("{{","").replace("}}","");if(B){let t=e.updatedValue;if(ue===g.CHATBOT&&"BUTTONS"===D){const l=null==N?void 0:N.filter((t=>t.placeHolder===e.updatedValue));l&&l.length>0&&(t=l[0].label)}i={label:t?t.replace("{{","").replace("}}","").trim().replace("."," "):"",value:null!==(a=e.updatedValue)&&void 0!==a?a:""}}else t.map((e=>{e.options.map((e=>{var t;(null===(t=e.value)||void 0===t?void 0:t.replace("{{","").replace("}}","").trim())===n.trim()&&(i=e)}))}));return i}(A,a,Q);e.value&&Z(e)}else"date_time"===A.type?(Z(V),$(A.updatedValue),Oe(null!==(e=A.index)&&void 0!==e?e:0,A.updatedValue)):(null===(t=A.updatedValue)||void 0===t?void 0:t.startsWith("https"))?(Z(k),$(A.updatedValue.split("https://")[1])):(Z(E),$(A.updatedValue))}function ve(e,t){var l,a,i;const n=e;$(""),Z(n),Q===b.WHATSAPP?"custom_text"!==n.value&&"custom_link"!==n.value&&"static_expiry"!==n.value?(ge(null!==(l=n.value)&&void 0!==l?l:"","string"),null==Oe||Oe(null!==(a=A.index)&&void 0!==a?a:0,n.value,!0)):(null==Oe||Oe(null!==(i=A.index)&&void 0!==i?i:0,W,!0,n.value),ge("","url"===n.bikPlaceholderType?"link":"string")):"custom_text"!==n.value&&"custom_link"!==n.value?ge(n.value,"url"===n.bikPlaceholderType?"link":"string"):($(""),ge("",n.value))}function be(e,t){var l;$(t);const a="custom_link"===(null==z?void 0:z.value)&&t?t.includes("https")?t:`https://${t}`:t;ge(a,"static_expiry"===e?"string":e),Q===b.WHATSAPP&&(null==Oe||Oe(null!==(l=A.index)&&void 0!==l?l:0,a,"custom_link"===e,e))}function ge(e,t){var l,a,i,o;const s="custom_link"===t?"link":"custom_text"===t?"string":t;if(Q!==b.WHATSAPP){const a=f(C+1),i=null===document||void 0===document?void 0:document.getElementById("mobile"===J?"template_html_mobile":"template_html_desktop"),n=Q===b.EMAIL?null===(l=null==i?void 0:i.contentWindow)||void 0===l?void 0:l.document.getElementById(a):document.getElementById(a);n&&(n.textContent="custom_text"!==t&&"custom_link"!==t||e?e:A.variableName);const o=ee.map(((t,l)=>l===C?Object.assign(Object.assign({},t),{type:s,updatedValue:e}):t));null==ne||ne(o)}if(Q===b.WHATSAPP){if(null!=de&&de>-1&&ce){const l=Object.assign({},ee).cards.map(((l,a)=>{var i,n;return"BODY"===D?Object.assign(Object.assign({},l),{body:null===(i=l.body)||void 0===i?void 0:i.map(((t,l)=>C===l?Object.assign(Object.assign({},t),{type:s,updatedValue:e}):t))}):"BUTTONS"===D?Object.assign(Object.assign({},l),{buttons:null===(n=l.buttons)||void 0===n?void 0:n.map(((l,a)=>a===C?Object.assign(Object.assign({},l),{buttonVariable:"custom_link"===t?"((customPlaceholderName))":e,example:"COPY_CODE"===l.type?e:[e]}):l))}):l}));return void(null==ne||ne((e=>Object.assign(Object.assign({},e),{cards:l}))))}const l=null!=de&&de>-1?ee.cards[de]:ee;let u=l.body,d=l.header,c=l.buttons;if("BODY"===D?u=null===(a=l.body)||void 0===a?void 0:a.map(((t,l)=>l===C?Object.assign(Object.assign({},t),{type:s,updatedValue:e}):t)):"HEADER"===D?d=null===(i=l.header)||void 0===i?void 0:i.map(((t,l)=>l===C?Object.assign(Object.assign({},t),{type:s,updatedValue:e}):t)):"BUTTONS"===D&&(c=null===(o=l.buttons)||void 0===o?void 0:o.map(((l,a)=>a===C?Object.assign(Object.assign({},l),{buttonVariable:"custom_link"===t?"((customPlaceholderName))":e,example:"COPY_CODE"===l.type?e:[e]}):l))),null!=de&&de>-1){const e=n(ee.cards);e[de]={header:d,body:u,buttons:c},null==ne||ne((t=>Object.assign(Object.assign({},t),{cards:e})))}else null==ne||ne((e=>Object.assign(Object.assign({},e),{header:d,body:u,buttons:c})))}}function Oe(e,t,l,a){var i,o,s,u,d,c,r;if(null!=de&&de>-1&&ce){const o=Object.assign({},te).components.map((l=>{var a;return"CAROUSEL"===l.type?Object.assign(Object.assign({},l),{cards:null===(a=l.cards)||void 0===a?void 0:a.map((l=>Object.assign(Object.assign({},l),{components:l.components.map((l=>{var a,i,n,o,s,u;if("BODY"===l.type&&"BODY"===D){if(null===(i=null===(a=l.example)||void 0===a?void 0:a.body_text)||void 0===i?void 0:i[0]){const a=[...null!==(s=null===(o=null===(n=l.example)||void 0===n?void 0:n.body_text)||void 0===o?void 0:o[0])&&void 0!==s?s:[]];a[e]=t.replace("{{","").replace("}}","").replace("((","").replace("))","");const i=Object.assign(Object.assign({},l.example),{body_text:[a]});return Object.assign(Object.assign({},l),{example:i})}return l}if("BUTTONS"===l.type&&"BUTTONS"===D){const a=null===(u=l.buttons)||void 0===u?void 0:u.map(((l,a)=>a===e?Object.assign(Object.assign({},l),{example:[t]}):l));return a?Object.assign(Object.assign({},l),{buttons:a}):l}return l}))})))}):l})),s=n(te);if(l){const l=null===(i=Object.assign({},te).mapping.cards)||void 0===i?void 0:i.map(((l,i)=>{var n,o,s;if("BODY"===D)return Object.assign(Object.assign({},l),{body:null===(n=l.body)||void 0===n?void 0:n.map(((l,i)=>e===i?"custom_text"===a?`((editableVariable${i+10}))`:t:l))});if("BUTTONS"===D&&(null==l?void 0:l.buttons)){let n=-1,u=-1;return null===(o=te.components[1].cards)||void 0===o||o[i].components.forEach((t=>{var l;"BUTTONS"===t.type&&(null===(l=t.buttons)||void 0===l||l.forEach(((t,l)=>{"URL"===t.type&&(n++,l===e&&"URL"==t.type&&(u=n))})))})),Object.assign(Object.assign({},l),{buttons:null===(s=l.buttons)||void 0===s?void 0:s.map(((e,l)=>l===u?"custom_link"===a?"((customPlaceholderName))":t:e))})}return l}));s.mapping.cards=l}return s.components=o,void(null==ae||ae(s))}const p=null!=de&&de>-1?{components:null===(o=Object.assign({},te).components[1].cards)||void 0===o?void 0:o[de].components,mapping:null===(s=Object.assign({},te).mapping.cards)||void 0===s?void 0:s[de]}:Object.assign({},te),m=null===(u=null==p?void 0:p.components)||void 0===u?void 0:u.map((l=>{var a,i,n,o,s,u,d,c,r;const p=Object.assign({},l);if("BODY"===l.type&&"BODY"===D){if(null===(i=null===(a=l.example)||void 0===a?void 0:a.body_text)||void 0===i?void 0:i[0]){const l=[...null!==(s=null===(o=null===(n=p.example)||void 0===n?void 0:n.body_text)||void 0===o?void 0:o[0])&&void 0!==s?s:[]];l[e]=t.replace("{{","").replace("}}","").replace("((","").replace("))","");const a=Object.assign(Object.assign({},p.example),{body_text:[l]});return Object.assign(Object.assign({},p),{example:a})}}else if("HEADER"===l.type&&"HEADER"===D){if(null===(u=l.example)||void 0===u?void 0:u.header_text){const l=[...null!==(c=null===(d=p.example)||void 0===d?void 0:d.header_text)&&void 0!==c?c:[]];l[e]=t.replace("{{","").replace("}}","").replace("((","").replace("))","");const a=Object.assign(Object.assign({},p.example),{header_text:l});return Object.assign(Object.assign({},p),{example:a})}}else{if("BUTTONS"===l.type&&"BUTTONS"===D){const a=null===(r=l.buttons)||void 0===r?void 0:r.map(((l,a)=>a===e?Object.assign(Object.assign({},l),{example:"COPY_CODE"===l.type?t:[t]}):l));return a?Object.assign(Object.assign({},p),{buttons:a}):p}if("limited_time_offer"===l.type&&"limited_time_offer"===D)return Object.assign(Object.assign({},p),{example:Object.assign(Object.assign({},p.example),{limited_time_offer:t})})}return l}));if(p.components=m,l)if("BODY"===D&&(null===(d=null==p?void 0:p.mapping)||void 0===d?void 0:d.body))p.mapping=Object.assign(Object.assign({},p.mapping),{body:p.mapping.body.map(((l,i)=>e===i?"custom_text"===a?`((editableVariable${i+10}))`:t:l))});else if("HEADER"===D&&(null===(c=null==p?void 0:p.mapping)||void 0===c?void 0:c.header))p.mapping=Object.assign(Object.assign({},p.mapping),{header:p.mapping.header.map(((l,i)=>e===i?"custom_text"===a?`((editableVariable${i+20}))`:t:l))});else if("BUTTONS"===D&&(null===(r=null==p?void 0:p.mapping)||void 0===r?void 0:r.buttons)){let l=-1,i=-1;m.forEach((t=>{var a;"BUTTONS"===t.type&&(null===(a=t.buttons)||void 0===a||a.forEach(((t,a)=>{"URL"===t.type&&(l++,a===e&&"URL"==t.type&&(i=l))})))})),p.mapping=Object.assign(Object.assign({},p.mapping),{buttons:p.mapping.buttons.map(((e,l)=>l===i?"custom_link"===a?"((customPlaceholderName))":t:e))})}if(null!=de&&de>-1&&te){const e=n(te);e.components[1].cards[de].components=p.components,e.mapping.cards[de]=p.mapping,null==ae||ae(e)}else null==ae||ae(Object.assign({},p))}return s((()=>{R&&(null==S||S())}),[R]),s((()=>{!function(){var e,t,l,a,i;const n="mobile"===J?"template_html_mobile":"template_html_desktop",o=document.getElementById(n),s=(null!==(a=null===(l=null===(t=null===(e=null==o?void 0:o.contentWindow)||void 0===e?void 0:e.document)||void 0===t?void 0:t.body)||void 0===l?void 0:l.innerHTML)&&void 0!==a?a:"")+(null===(i=null==o?void 0:o.contentWindow)||void 0===i?void 0:i.document.head.innerHTML);Q===b.EMAIL&&(null==ie||ie(s))}()}),[le]),s((()=>{me()}),[]),s((()=>{me()}),[de]),s((()=>{J&&z&&W&&setTimeout((()=>{ge("custom_link"===(null==z?void 0:z.value)&&W?W.includes("https")?W:`https://${W}`:W,z.value)}),100)}),[J]),s((()=>{!F&&z&&A.updatedValue&&setTimeout((()=>{ge("custom_link"===(null==z?void 0:z.value)&&A.updatedValue?A.updatedValue.includes("https")?A.updatedValue:`https://${A.updatedValue}`:A.updatedValue,z.value),K(!0)}),100)}),[z]),e(_,Object.assign({channel:Q,focused:R,onMouseEnter:()=>M(!0),onMouseLeave:()=>M(!1)},{children:[t("div",Object.assign({style:{marginBottom:8}},{children:e(O,Object.assign({style:{color:X&&!z?y.content.negative:y.content.primary}},{children:[null===(L=A.variableName)||void 0===L?void 0:L.replace("{{","").replace("}}","")," ","link"===(null==A?void 0:A.type)?"link":"variable"]}))})),t("div",Object.assign({style:{marginBottom:12}},{children:B?e("div",Object.assign({style:{display:"flex",border:"#E0E0E0 1px solid",borderRadius:4,padding:10,justifyContent:(null==z?void 0:z.label)?"space-between":"flex-end"}},{children:[t(j,Object.assign({numberOfLines:1},{children:ue===g.CHATBOT?["static_expiry","custom_text","custom_link"].includes(null!==(U=null==z?void 0:z.value)&&void 0!==U?U:"")?null==z?void 0:z.label:null==z?void 0:z.value:m(null!==(H=null==z?void 0:z.label)&&void 0!==H?H:"",20,!0)})),re||"date_time"===(null==A?void 0:A.type)&&pe?t(l,{}):t(a,{onClick:()=>{q(!G)},width:24,height:24,color:y.content.primary})]})):t(r,{disabled:re,options:I,isSearchable:!1,onSelect:ve,defaultOptions:z?[Object.assign(Object.assign({},z),{selected:!0})]:[]})})),("custom_text"===(null==z?void 0:z.value)||"custom_link"===(null==z?void 0:z.value))&&t(p,{state:re?"disabled":"none",labelText:"custom_text"===(null==z?void 0:z.value)?"Custom text value":"custom_link"===(null==z?void 0:z.value)?"Custom URL value":"",id:`variable-value-${null==z?void 0:z.value}-${C}`,value:W,errorMessage:X?W&&0!==W.trim().length?"custom_link"!==z.value||/^https?:\/\/(?:www\.)?[-a-zA-Z0-9@:%._\+~#=]{1,256}\.[a-zA-Z0-9()]{1,6}\b(?:[-a-zA-Z0-9()@:%_\+.~#?&\/=]*)$/.test(`https://${W.trim()}`)&&0!==W.trim().length?"custom_link"!==z.value&&W.length>30?"Length cannot be more than 30":"BUTTONS"===D&&"custom_link"!==z.value?"Enter valid alpha numeric code":"":"Enter valid URL":"Required field":"",maxCharLimit:"custom_link"===(null==z?void 0:z.value)?2e3:"BUTTONS"===D?15:30,noKeyDownChange:!0,prefixText:"custom_link"===(null==z?void 0:z.value)?"https://":"",placeholder:"link"===A.type||"custom_link"===z.value?"Enter custom URL here":"Enter custom text here",onChangeText:e=>{be(z.value,e)}}),"static_expiry"===(null==z?void 0:z.value)&&e("div",Object.assign({style:{position:"relative"}},{children:[re&&t(T,{onClick:e=>e.preventDefault()}),t(c,{placement:"auto",time:i(W?new Date(W):new Date,"hh:mm a"),date:W?new Date(W):new Date,minDate:new Date,error:"",setError:()=>{},onChange:e=>{be("static_expiry",e.toISOString())}})]})),G&&t(d,{zIndex:2e3,data:null!=P?P:[],showVariable:G,setShowVariable:q,placeholder:"Add a variable",customTrigger:e=>{null==w||w(!1),"{{custom.url}}"===e.actualValue?ve({label:e.displayName,selected:!0,value:"custom_link"}):"{{custom.text}}"==e.actualValue?ve({label:e.displayName,selected:!0,value:"custom_text"}):"{{static.expiry}}"==e.actualValue?ve({label:e.displayName,selected:!0,value:"static_expiry"}):(console.log("variable: ",e),ve({label:e.displayName.replace("{{","").replace("}}","").trim().replace("."," "),selected:!0,value:e.actualValue,bikPlaceholderType:"string"}))}})]}))};export{_ as Container,S as default};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bikdotai/bik-component-library",
3
- "version": "0.0.458",
3
+ "version": "0.0.460-beta.1",
4
4
  "description": "Bik Component Library",
5
5
  "repository": {
6
6
  "type": "git",