@bikdotai/bik-component-library 0.0.406-beta.2 → 0.0.407-beta.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (33) hide show
  1. package/dist/cjs/components/template-context-mapper/modalElements/EditWhatsAppTemplateV2.js +1 -1
  2. package/dist/cjs/components/template-context-mapper/modalElements/MobilePreview.js +3 -3
  3. package/dist/cjs/components/template-context-mapper/modalElements/VariableConnector.d.ts +2 -1
  4. package/dist/cjs/components/template-context-mapper/modalElements/VariableConnector.js +3 -3
  5. package/dist/cjs/components/template-context-mapper/modalElements/WhatsAppTemplateCardButtonV2.d.ts +4 -1
  6. package/dist/cjs/components/template-context-mapper/modalElements/WhatsAppTemplateCardButtonV2.js +1 -1
  7. package/dist/cjs/components/template-context-mapper/utils/getDataFromTemplateComponent.js +1 -1
  8. package/dist/cjs/components/template-preview/WhatsApp/ChatUiV2.js +5 -5
  9. package/dist/cjs/components/template-preview/WhatsApp/MediaCard.js +1 -1
  10. package/dist/cjs/components/template-preview/WhatsAppTemplatePreview.js +1 -1
  11. package/dist/cjs/components/template-preview/helpers/TemplateCreatorHelper.js +1 -1
  12. package/dist/cjs/components/template-preview/models/TemplateMeta.d.ts +1 -1
  13. package/dist/cjs/components/template-preview/models/WhatsAppTemplate.d.ts +13 -2
  14. package/dist/cjs/components/template-preview/models/WhatsAppTemplate.js +1 -1
  15. package/dist/esm/components/template-context-mapper/modalElements/EditWhatsAppTemplateV2.js +1 -1
  16. package/dist/esm/components/template-context-mapper/modalElements/MobilePreview.js +4 -4
  17. package/dist/esm/components/template-context-mapper/modalElements/VariableConnector.d.ts +2 -1
  18. package/dist/esm/components/template-context-mapper/modalElements/VariableConnector.js +3 -3
  19. package/dist/esm/components/template-context-mapper/modalElements/WhatsAppTemplateCardButtonV2.d.ts +4 -1
  20. package/dist/esm/components/template-context-mapper/modalElements/WhatsAppTemplateCardButtonV2.js +1 -1
  21. package/dist/esm/components/template-context-mapper/utils/getDataFromTemplateComponent.js +1 -1
  22. package/dist/esm/components/template-preview/WhatsApp/ChatUiV2.js +4 -4
  23. package/dist/esm/components/template-preview/WhatsApp/MediaCard.js +1 -1
  24. package/dist/esm/components/template-preview/WhatsAppTemplatePreview.js +1 -1
  25. package/dist/esm/components/template-preview/helpers/TemplateCreatorHelper.js +1 -1
  26. package/dist/esm/components/template-preview/models/TemplateMeta.d.ts +1 -1
  27. package/dist/esm/components/template-preview/models/WhatsAppTemplate.d.ts +13 -2
  28. package/dist/esm/components/template-preview/models/WhatsAppTemplate.js +1 -1
  29. package/package.json +1 -1
  30. package/dist/cjs/components/template-context-mapper/utils/getPreviewDimension.d.ts +0 -2
  31. package/dist/cjs/components/template-context-mapper/utils/getPreviewDimension.js +0 -1
  32. package/dist/esm/components/template-context-mapper/utils/getPreviewDimension.d.ts +0 -2
  33. package/dist/esm/components/template-context-mapper/utils/getPreviewDimension.js +0 -1
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),t=require("react"),o=require("../../template-preview/models/WhatsAppTemplate.js"),n=require("../context/templateModalContext.js"),i=require("../utils/getDataFromTemplateComponent.js"),a=require("./BackTrackComponent.js"),l=require("./DiscountCodeComponent.js"),s=require("./EditMediaV2.style.js"),d=require("./EditWhatsAppTemplateMediaV2.js"),r=require("./VariableConnectorsPanel.js"),u=require("./VariableConnectorWhatsApp.js"),c=require("./VariableEditorHeader.js"),p=require("./WhatsAppTemplateCardButtonV2.js");exports.default=v=>{let{template:m,onTemplateChange:b,whatsappSpecificPickerMeta:g,showVariableModal:h,variableList:f,variableListForImage:j,discountCode:T,setDiscountCode:x}=v;var C,O,E,k,y,B,V,w,q,L,I,M,A,D,R,U;const{originalVariableList:P,pod:H,extras:S}=n.useTemplateModalContext(),{descriptionComponents:N,urlBtns:Q,qrbBtns:_,imageComponent:F,bodyVariables:W,headerVariables:K}=i.getAllDataFromTemplateComponent(m),[Y,$]=t.useState(!1);function X(e,t){var o,n,i,a,l;const s=Object.assign({},m),d=null==s?void 0:s.components.findIndex((e=>"BUTTONS"===e.type));if(void 0!==d&&d>-1){const l=null===(o=null==s?void 0:s.components[d].buttons)||void 0===o?void 0:o.findIndex((e=>"URL"===e.type));if(void 0!==l&&l>-1){const o="custom"===t&&"string"==typeof e,r=[...null!==(a=null===(i=null===(n=s.components)||void 0===n?void 0:n[d])||void 0===i?void 0:i.buttons)&&void 0!==a?a:[]];r[l]=Object.assign(Object.assign({},r[l]),{url:"https://d.bik.ai/{{1}}",example:[o?e:"string"!=typeof e?e.defaultValue:""]});const u=Object.assign(Object.assign({},s.components[d]),{buttons:r}),c=Object.assign(Object.assign({},s.mapping),{buttons:o?["((customBtnPlaceholder))"]:"string"!=typeof e?[e.placeHolder]:void 0});s.mapping=c;const p=[...s.components];p[d]=u,s.components=p}}if("string"!=typeof e){"checkout.checkoutUrl"===(null===(l=e.placeHolder)||void 0===l?void 0:l.slice(2,-2))?$(!0):($(!1),null==x||x(""))}null==b||b(s)}function z(e,t,o){var n;const i=Object.assign({},m),a=null==i?void 0:i.components.findIndex((e=>"BUTTONS"===e.type));if(void 0!==a&&a>-1){const t=null===(n=null==i?void 0:i.components[a].buttons)||void 0===n?void 0:n.filter((e=>"QUICK_REPLY"===e.type));t&&(t[o]=Object.assign(Object.assign({},t[o]),{flowId:e.flowId,flowName:e.flowName}));const l=Object.assign(Object.assign({},i.components[a]),{buttons:t}),s=[...i.components];s[a]=l,i.components=s}null==b||b(i)}return t.useEffect((()=>{var e;const t=null===(e=m.mapping.buttons)||void 0===e?void 0:e[0];"checkout.checkoutUrl"===(null==t?void 0:t.slice(2,-2))?$(!0):($(!1),null==x||x(""))}),[m]),e.jsxs(r.Container,Object.assign({style:{flexDirection:"column",maxHeight:460}},{children:[!!F&&e.jsx(s.EditTemplateMediaContainer,{children:e.jsx(d.default,{whatsappSpecificPickerMeta:g,mediaComponent:F,updateTemplateImageUrl:function(e,t){var o;let n=Object.assign({},m);const i=null===(o=null==n?void 0:n.components)||void 0===o?void 0:o.findIndex((e=>{if("HEADER"===e.type&&"NONE"!==e.format&&"TEXT"!==e.format)return!0}));if(void 0!==i&&i>-1&&(null==n?void 0:n.components[i])){const o=Object.assign(Object.assign({},n.components[i]),{format:t,example:{header_handle:[e]}}),a=[...n.components];a[i]=o,n=Object.assign(Object.assign({},n),{components:a})}n.mapping&&(n.mapping=Object.assign(Object.assign({},n.mapping),{header:void 0})),null==b||b(Object.assign({},n))},template:m,variableListForImage:j})}),(W.length>0||K.length>0)&&e.jsx(c.default,{containerStyle:{paddingTop:F?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==N?void 0:N.map(((t,o)=>e.jsx(u.default,{originalVariableList:P,type:t.type,descriptionComponent:t.component,variableMapping:"HEADER"===t.type?m.mapping.header:m.mapping.body,showVariableModal:h,variableList:f},o))),(null===(O=null===(C=Q[0])||void 0===C?void 0:C.component)||void 0===O?void 0:O.buttons)&&(null===(y=null===(k=null===(E=Q[0])||void 0===E?void 0:E.component)||void 0===k?void 0:k.buttons)||void 0===y?void 0:y.length)>0&&e.jsx(c.default,{headerText:"Edit buttons",subText:"Edit the link connected to the CTA button"}),null===(B=null==P?void 0:P.buttons)||void 0===B?void 0:B.map(((t,o)=>{if("URL"===t.type)return e.jsx(p.default,{CTAoptions:null==g?void 0:g.CTAoptions,button:t,originalVariableList:P,updateSelectedURLTemplateBtn:X},`${o}`)})),(null===(w=null===(V=_[0])||void 0===V?void 0:V.component)||void 0===w?void 0:w.buttons)&&(null===(I=null===(L=null===(q=_[0])||void 0===q?void 0:q.component)||void 0===L?void 0:L.buttons)||void 0===I?void 0:I.length)>0&&(H!==o.POD.CHATBOT?e.jsx(c.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===(M=null==S?void 0:S.backTrackExtra)||void 0===M?void 0:M[0],setBackTrackMessage:null===(A=null==S?void 0:S.backTrackExtra)||void 0===A?void 0:A[1]})),null===(D=null==P?void 0:P.buttons)||void 0===D?void 0:D.map(((t,o)=>{if("QUICK_REPLY"===t.type)return e.jsx(p.default,{QRBoptions:null==g?void 0:g.QRBoptions,button:t,originalVariableList:P,updateSelectedQRBTemplateBtn:z},`${o}`)})),H===o.POD.CHATBOT&&Y&&e.jsx(l.DiscountCodeComponent,{discountCode:null===(R=null==S?void 0:S.discountCodeExtra)||void 0===R?void 0:R[0],setDiscountCode:null===(U=null==S?void 0:S.discountCodeExtra)||void 0===U?void 0:U[1],variableList:f})]}))};
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),t=require("react"),o=require("../../template-preview/models/WhatsAppTemplate.js"),n=require("../context/templateModalContext.js"),i=require("../utils/getDataFromTemplateComponent.js"),a=require("./BackTrackComponent.js"),l=require("./DiscountCodeComponent.js"),s=require("./EditMediaV2.style.js"),d=require("./EditWhatsAppTemplateMediaV2.js"),r=require("./VariableConnector.js"),u=require("./VariableConnectorsPanel.js"),c=require("./VariableConnectorWhatsApp.js"),p=require("./VariableEditorHeader.js"),v=require("./WhatsAppTemplateCardButtonV2.js");exports.default=b=>{let{template:m,onTemplateChange:g,whatsappSpecificPickerMeta:h,showVariableModal:f,variableList:x,variableListForImage:j,discountCode:T,setDiscountCode:C}=b;var O,y,E,k,V,I,L,B,w,q,M,A,D,U,N,P,R;const{originalVariableList:S,pod:H,extras:_}=n.useTemplateModalContext(),{descriptionComponents:Q,urlBtns:F,qrbBtns:W,imageComponent:Y,bodyVariables:K,headerVariables:$}=i.getAllDataFromTemplateComponent(m),[X,z]=t.useState(!1);function G(e,t){var o,n,i,a,l;const s=Object.assign({},m),d=null==s?void 0:s.components.findIndex((e=>"BUTTONS"===e.type));if(void 0!==d&&d>-1){const l=null===(o=null==s?void 0:s.components[d].buttons)||void 0===o?void 0:o.findIndex((e=>"URL"===e.type));if(void 0!==l&&l>-1){const o="custom"===t&&"string"==typeof e,r=[...null!==(a=null===(i=null===(n=s.components)||void 0===n?void 0:n[d])||void 0===i?void 0:i.buttons)&&void 0!==a?a:[]];r[l]=Object.assign(Object.assign({},r[l]),{url:"https://d.bik.ai/{{1}}",example:[o?e:"string"!=typeof e?e.defaultValue:""]});const u=Object.assign(Object.assign({},s.components[d]),{buttons:r}),c=Object.assign(Object.assign({},s.mapping),{buttons:o?["((customBtnPlaceholder))"]:"string"!=typeof e?[e.placeHolder]:void 0});s.mapping=c;const p=[...s.components];p[d]=u,s.components=p}}if("string"!=typeof e){"checkout.checkoutUrl"===(null===(l=e.placeHolder)||void 0===l?void 0:l.slice(2,-2))?z(!0):(z(!1),null==C||C(""))}null==g||g(s)}function J(e,t,o){var n;const i=Object.assign({},m),a=null==i?void 0:i.components.findIndex((e=>"BUTTONS"===e.type));if(void 0!==a&&a>-1){const t=null===(n=null==i?void 0:i.components[a].buttons)||void 0===n?void 0:n.filter((e=>"QUICK_REPLY"===e.type));t&&(t[o]=Object.assign(Object.assign({},t[o]),{flowId:e.flowId,flowName:e.flowName}));const l=Object.assign(Object.assign({},i.components[a]),{buttons:t}),s=[...i.components];s[a]=l,i.components=s}null==g||g(i)}t.useEffect((()=>{var e;const t=null===(e=m.mapping.buttons)||void 0===e?void 0:e[0];"checkout.checkoutUrl"===(null==t?void 0:t.slice(2,-2))?z(!0):(z(!1),null==C||C(""))}),[m]);const Z=t.useCallback((()=>x?[...x,{description:"",displayName:"Custom variables",orderId:1,variables:{"Custom text":{description:void 0,displayName:"Custom text",actualValue:"{{custom.text}}",variableType:"any",isAvailable:!0}}}].sort(((e,t)=>e.orderId-t.orderId)):x),[x]),ee=t.useMemo((()=>Z()),[Z]);return e.jsxs(u.Container,Object.assign({style:{flexDirection:"column",maxHeight:460}},{children:[!!Y&&e.jsx(s.EditTemplateMediaContainer,{children:e.jsx(d.default,{whatsappSpecificPickerMeta:h,mediaComponent:Y,updateTemplateImageUrl:function(e,t){var o;let n=Object.assign({},m);const i=null===(o=null==n?void 0:n.components)||void 0===o?void 0:o.findIndex((e=>{if("HEADER"===e.type&&"NONE"!==e.format&&"TEXT"!==e.format)return!0}));if(void 0!==i&&i>-1&&(null==n?void 0:n.components[i])){const o=Object.assign(Object.assign({},n.components[i]),{format:t,example:{header_handle:[e]}}),a=[...n.components];a[i]=o,n=Object.assign(Object.assign({},n),{components:a})}n.mapping&&(n.mapping=Object.assign(Object.assign({},n.mapping),{header:void 0})),null==g||g(Object.assign({},n))},template:m,variableListForImage:j})}),(K.length>0||$.length>0)&&e.jsx(p.default,{containerStyle:{paddingTop:Y?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==Q?void 0:Q.map(((t,o)=>e.jsx(c.default,{originalVariableList:S,type:t.type,descriptionComponent:t.component,variableMapping:"HEADER"===t.type?m.mapping.header:m.mapping.body,showVariableModal:f,variableList:x},o))),(null===(y=null===(O=F[0])||void 0===O?void 0:O.component)||void 0===y?void 0:y.buttons)&&(null===(V=null===(k=null===(E=F[0])||void 0===E?void 0:E.component)||void 0===k?void 0:k.buttons)||void 0===V?void 0:V.length)>0&&e.jsx(p.default,{headerText:"Edit buttons",subText:"Edit the link connected to the CTA button"}),null===(I=null==S?void 0:S.buttons)||void 0===I?void 0:I.map(((t,o)=>{if("URL"===t.type)return e.jsx(v.default,{variableListIndex:o,CTAoptions:null==h?void 0:h.CTAoptions,button:t,originalVariableList:S,updateSelectedURLTemplateBtn:G,variableList:x},`${o}`)})),(null===(B=null===(L=W[0])||void 0===L?void 0:L.component)||void 0===B?void 0:B.buttons)&&(null===(M=null===(q=null===(w=W[0])||void 0===w?void 0:w.component)||void 0===q?void 0:q.buttons)||void 0===M?void 0:M.length)>0&&(H!==o.POD.CHATBOT?e.jsx(p.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===(A=null==_?void 0:_.backTrackExtra)||void 0===A?void 0:A[0],setBackTrackMessage:null===(D=null==_?void 0:_.backTrackExtra)||void 0===D?void 0:D[1]})),null===(U=null==S?void 0:S.buttons)||void 0===U?void 0:U.map(((t,o)=>{if("QUICK_REPLY"===t.type)return e.jsx(v.default,{variableListIndex:o,QRBoptions:null==h?void 0:h.QRBoptions,button:t,originalVariableList:S,updateSelectedQRBTemplateBtn:J},`${o}`)})),H===o.POD.CHATBOT&&X&&e.jsx(l.DiscountCodeComponent,{discountCode:null===(N=null==_?void 0:_.discountCodeExtra)||void 0===N?void 0:N[0],setDiscountCode:null===(P=null==_?void 0:_.discountCodeExtra)||void 0===P?void 0:P[1],variableList:x}),null===(R=null==S?void 0:S.buttons)||void 0===R?void 0:R.map(((t,o)=>{var n,i,a;if("COPY_CODE"===t.type)return e.jsx(r.default,{index:o,variable:{variableName:null!==(n=t.text)&&void 0!==n?n:"",updatedValue:null!==(i=t.buttonVariable)&&void 0!==i?i:"",type:"string",isEditableVariable:!0,index:null!==(a=t.index)&&void 0!==a?a:0},showVariableModal:!0,variableList:ee,componentType:"BUTTONS"},o)}))]}))};
@@ -1,8 +1,8 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),t=require("react"),i=require("styled-components"),a=require("../../template-preview/TemplatePreview.js");require("../../template-preview/WhatsApp/WhatsAppLikePreview.js"),require("../../template-preview/WhatsApp/WhatsAppLikePreviewV2.js"),require("../../../constants/Theme.js"),require("../../template-preview/models/TemplateMeta.js");var r=require("../../template-preview/models/WhatsAppTemplate.js"),o=require("../context/templateModalContext.js"),s=require("../utils/getPreviewDimension.js");function l(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var p=l(t),n=l(i);const d=n.default.div`
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),t=require("react"),a=require("styled-components"),i=require("../../template-preview/TemplatePreview.js");require("../../template-preview/WhatsApp/WhatsAppLikePreview.js"),require("../../template-preview/WhatsApp/WhatsAppLikePreviewV2.js"),require("../../../constants/Theme.js"),require("../../template-preview/models/TemplateMeta.js");var r=require("../../template-preview/models/WhatsAppTemplate.js"),o=require("../../template-preview/models/Channels.js"),s=require("../context/templateModalContext.js");function l(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var p=l(t),n=l(a);const d=n.default.div`
2
2
  position: relative;
3
3
  height: 100%;
4
4
  border-radius: 31px;
5
- width: ${e=>s.getPreviewWidth(e.channel)}px;
5
+ width: ${e=>e.channel===o.CHANNEL_TYPE.WHATSAPP?"236px":"300px"};
6
6
  background-color: white;
7
7
  margin: auto;
8
8
  overflow-y: auto;
@@ -17,4 +17,4 @@
17
17
  height: calc(100% - 17px);
18
18
  border-radius: 16px;
19
19
  overflow-y: auto;
20
- `,h=p.default.forwardRef(((t,i)=>{let{display_content:l,channel:p,template:n,showSampleValues:h}=t;const{pod:m}=o.useTemplateModalContext();return e.jsx("div",{children:e.jsxs(d,Object.assign({channel:p},{children:[e.jsx("img",{alt:"",src:"https://firebasestorage.googleapis.com/v0/b/staging-bikayi.appspot.com/o/bik%2FkNwEVoGlLpVjOsXoO1M8WgvWicP2%2F6f07b850-8b4b-4d58-96cc-8ba6df7b4e4a-Device___Frame.jpg?alt=media&token=253f1bfe-8481-4f54-bdef-3c0a73697d6a",style:{width:s.getPreviewWidth(p),height:443}}),e.jsx(c,Object.assign({ref:i},{children:e.jsx(a.TemplatePreview,{showSampleValues:h,template:n,channel:p,smsSpecificMeta:{smsDisplayContent:l},whatsAppSpecificMeta:{showWhatsAppHeader:!0,whatsAppExtras:m!==r.POD.CHATBOT,containerStyle:{border:"none",borderBottomRightRadius:0,borderBottomLeftRadius:0,minHeight:426,width:236}},size:"small",hideHeader:!0,emailSpecificMeta:{emailDisplayContent:l,hideViewButtonForEmail:!0,emailHtmlContainerId:"template_html_mobile",containerStyle:{height:"100%",width:"100%"},templateContainerStyles:{height:"100%"}}})}))]}))})}));h.displayName="MobilePreview",exports.default=h;
20
+ `,h=p.default.forwardRef(((t,a)=>{let{display_content:l,channel:p,template:n,showSampleValues:h}=t;const{pod:m}=s.useTemplateModalContext();return e.jsx("div",{children:e.jsxs(d,Object.assign({channel:p},{children:[e.jsx("img",{alt:"",src:"https://firebasestorage.googleapis.com/v0/b/staging-bikayi.appspot.com/o/bik%2FkNwEVoGlLpVjOsXoO1M8WgvWicP2%2F6f07b850-8b4b-4d58-96cc-8ba6df7b4e4a-Device___Frame.jpg?alt=media&token=253f1bfe-8481-4f54-bdef-3c0a73697d6a",style:{width:p===o.CHANNEL_TYPE.WHATSAPP?236:300,height:443}}),e.jsx(c,Object.assign({ref:a},{children:e.jsx(i.TemplatePreview,{showSampleValues:h,template:n,channel:p,smsSpecificMeta:{smsDisplayContent:l},whatsAppSpecificMeta:{showWhatsAppHeader:!0,whatsAppExtras:m!==r.POD.CHATBOT,containerStyle:{border:"none",borderBottomRightRadius:0,borderBottomLeftRadius:0,minHeight:426,width:236}},size:"small",hideHeader:!0,emailSpecificMeta:{emailDisplayContent:l,hideViewButtonForEmail:!0,emailHtmlContainerId:"template_html_mobile",containerStyle:{height:"100%",width:"100%"},templateContainerStyles:{height:"100%"}}})}))]}))})}));h.displayName="MobilePreview",exports.default=h;
@@ -1,7 +1,7 @@
1
1
  /// <reference types="react" />
2
2
  import { VariableListInterfaceV2 } from "../../add-variableV2/AddVariableV2";
3
3
  import { CHANNEL_TYPE } from "../../template-preview/models/Channels";
4
- import { CUSTOM_VARIABLE } from "../../template-preview/models/TemplateMeta";
4
+ import { ButtonPlaceHolderOptions, CUSTOM_VARIABLE } from "../../template-preview/models/TemplateMeta";
5
5
  export declare const Container: import("styled-components").StyledComponent<"div", any, {
6
6
  focused?: boolean | undefined;
7
7
  channel?: CHANNEL_TYPE | undefined;
@@ -15,6 +15,7 @@ export interface VariableConnectorProps {
15
15
  variableList?: VariableListInterfaceV2[];
16
16
  setShowDiscountCheckBox?: any;
17
17
  componentType?: 'HEADER' | 'BODY' | 'BUTTONS' | 'FOOTER';
18
+ CTAoptions?: ButtonPlaceHolderOptions[];
18
19
  }
19
20
  declare const VariableConnector: React.FC<VariableConnectorProps>;
20
21
  export default VariableConnector;
@@ -1,7 +1,7 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),t=require("../../../assets/icons/edit.svg.js"),l=require("react"),a=require("styled-components"),n=require("../../add-variableV2/AddVariableV2SideModal.js"),i=require("../../dropdown/Dropdown.js"),o=require("../../input/Input.js"),u=require("../../product-picker-v2/collectionScreen.js"),s=require("../../template-preview/constants/regexPatterns.js"),d=require("../../template-preview/models/Channels.js"),r=require("../../TypographyStyle.js"),c=require("../../../utils/StringUtils.js"),p=require("../../../constants/Theme.js"),v=require("../context/templateModalContext.js"),m=require("../utils/getVariableNameEmail.js");function b(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}const g=b(a).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("react"),a=require("styled-components"),n=require("../../add-variableV2/AddVariableV2SideModal.js"),i=require("../../dropdown/Dropdown.js"),o=require("../../input/Input.js"),s=require("../../product-picker-v2/collectionScreen.js"),u=require("../../template-preview/constants/regexPatterns.js"),d=require("../../template-preview/models/Channels.js"),r=require("../../template-preview/models/WhatsAppTemplate.js"),c=require("../../TypographyStyle.js"),p=require("../../../utils/StringUtils.js"),v=require("../../../constants/Theme.js"),m=require("../context/templateModalContext.js"),b=require("../utils/getVariableNameEmail.js");function g(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}const h=g(a).default.div`
2
2
  /* surface/$color-background-warning-light */
3
3
 
4
- background: ${e=>e.focused&&e.channel===d.CHANNEL_TYPE.EMAIL?p.COLORS.background.warning.light:"transparent"};
4
+ background: ${e=>e.focused&&e.channel===d.CHANNEL_TYPE.EMAIL?v.COLORS.background.warning.light:"transparent"};
5
5
  border-radius: 4px;
6
6
  padding: 8px 10px;
7
- `,h={value:"custom_link",label:"Custom URL"},x={value:"custom_text",label:"Custom text"};exports.Container=g,exports.default=a=>{let{onFocus:b,variable:E,index:_,showVariableModal:j,variableList:y,setShowDiscountCheckBox:A,componentType:O}=a;var f,T;const[N,P]=l.useState(!1),[C,L]=l.useState(""),[V,k]=l.useState([]),[S,H]=l.useState(),[w,Y]=l.useState(!1),[M,q]=l.useState(!1),{device:B,channel:R,isError:W,originalVariableList:D,template:I,templateSelectionTriggered:$,setTemplate:z,setDisplayContent:U,setOriginalVariableList:Z,globalNormalizedPlaceholders:F,enabledCustomText:G}=v.useTemplateModalContext();function J(e,t){var l,a,n;const i=e;L(""),H(i),R===d.CHANNEL_TYPE.WHATSAPP?"custom_text"!==i.value&&"custom_link"!==i.value?(K(null!==(l=i.value)&&void 0!==l?l:"","string"),null==Q||Q(null!==(a=E.index)&&void 0!==a?a:0,i.value,!0)):(null==Q||Q(null!==(n=E.index)&&void 0!==n?n:0,E.variableName,!0,"custom_text"),K("","url"===i.bikPlaceholderType?"link":"string")):"custom_text"!==i.value&&"custom_link"!==i.value?K(i.value,"url"===i.bikPlaceholderType?"link":"string"):(L(""),K("",i.value))}function K(e,t){var l,a,n;const i="custom_link"===t?"link":"custom_text"===t?"string":t;if(R!==d.CHANNEL_TYPE.WHATSAPP){const a=m.getVariableNameForEmailByIndex(_+1),n=null===document||void 0===document?void 0:document.getElementById("mobile"===B?"template_html_mobile":"template_html_desktop"),o=R===d.CHANNEL_TYPE.EMAIL?null===(l=null==n?void 0:n.contentWindow)||void 0===l?void 0:l.document.getElementById(a):document.getElementById(a);o&&(o.textContent="custom_text"!==t&&"custom_link"!==t||e?e:E.variableName);const u=D.map(((t,l)=>l===_?Object.assign(Object.assign({},t),{type:i,updatedValue:e}):t));null==Z||Z(u)}if(R===d.CHANNEL_TYPE.WHATSAPP){const t=D;let l=t.body,o=t.header;"BODY"===O?l=null===(a=t.body)||void 0===a?void 0:a.map(((t,l)=>l===_?Object.assign(Object.assign({},t),{type:i,updatedValue:e}):t)):"HEADER"===O&&(o=null===(n=t.header)||void 0===n?void 0:n.map(((t,l)=>l===_?Object.assign(Object.assign({},t),{type:i,updatedValue:e}):t))),null==Z||Z((e=>Object.assign(Object.assign({},e),{header:o,body:l,buttons:t.buttons})))}}function Q(e,t,l,a){var n,i,o;const u=Object.assign({},I),s=null===(n=null==u?void 0:u.components)||void 0===n?void 0:n.map((l=>{var a,n,i,o,u,s,d,r;const c=Object.assign({},l);if("BODY"===l.type&&"BODY"===O){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!==(u=null===(o=null===(i=c.example)||void 0===i?void 0:i.body_text)||void 0===o?void 0:o[0])&&void 0!==u?u:[]];l[e]=t.replace("{{","").replace("}}","").replace("((","").replace("))","");const a=Object.assign(Object.assign({},c.example),{body_text:[l]});return Object.assign(Object.assign({},c),{example:a})}}else if("HEADER"===l.type&&"HEADER"===O&&(null===(s=l.example)||void 0===s?void 0:s.header_text)){const l=[...null!==(r=null===(d=c.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({},c.example),{header_text:l});return Object.assign(Object.assign({},c),{example:a})}return l}));u.components=s,l&&("BODY"===O&&(null===(i=null==u?void 0:u.mapping)||void 0===i?void 0:i.body)?u.mapping=Object.assign(Object.assign({},u.mapping),{body:u.mapping.body.map(((l,n)=>e===n?"custom_text"===a?`((editableVariable${n+10}))`:t:l))}):"HEADER"===O&&(null===(o=null==u?void 0:u.mapping)||void 0===o?void 0:o.header)&&(u.mapping=Object.assign(Object.assign({},u.mapping),{header:u.mapping.header.map(((l,n)=>e===n?"custom_text"===a?`((editableVariable${n+20}))`:t:l))}))),null==z||z(Object.assign({},u))}return l.useEffect((()=>{N&&(null==b||b())}),[N]),l.useEffect((()=>{!function(){var e,t,l,a,n;const i="mobile"===B?"template_html_mobile":"template_html_desktop",o=document.getElementById(i),u=(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===(n=null==o?void 0:o.contentWindow)||void 0===n?void 0:n.document.head.innerHTML);R===d.CHANNEL_TYPE.EMAIL&&(null==U||U(u))}()}),[$]),l.useEffect((()=>{var e;const t=[];let l=[];if(R!==d.CHANNEL_TYPE.MESSAGE||G){"link"===(null==E?void 0:E.type)?(t.push({label:"",options:[h,x]}),H(h)):(t.push({label:"",options:[h,x]}),H(x));const e=null!=F?F:[];k([...t,...e.map((e=>{var t,l;return Object.assign(Object.assign({},e),{label:c.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())})}))]),l=[...t,...e]}else{const e=null!=F?F:[];k([{label:"",options:[x,h]},...e]),l=[{label:"",options:[x,h]},...e]}if((R===d.CHANNEL_TYPE.WHATSAPP||R===d.CHANNEL_TYPE.EMAIL||R===d.CHANNEL_TYPE.MESSAGE)&&E.updatedValue)if(s.placeHolderNamePattern.test(E.updatedValue)&&R===d.CHANNEL_TYPE.WHATSAPP||E.updatedValue.startsWith("{{")&&R!==d.CHANNEL_TYPE.WHATSAPP){const e=function(e,t,l){var a;let n={label:"",value:""};const i=l===d.CHANNEL_TYPE.WHATSAPP?e.updatedValue.replace("[[","").replace("]]",""):e.updatedValue.replace("{{","").replace("}}","");j?n={label:e.updatedValue?e.updatedValue.replace("{{","").replace("}}","").trim().replace("."," "):"",value:null!==(a=e.updatedValue)&&void 0!==a?a:""}: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}(E,l,R);e.value&&H(e)}else(null===(e=E.updatedValue)||void 0===e?void 0:e.startsWith("https"))?(H(h),L(E.updatedValue.split("https://")[1])):(H(x),L(E.updatedValue))}),[]),l.useEffect((()=>{B&&S&&C&&setTimeout((()=>{K("custom_link"===(null==S?void 0:S.value)&&C?C.includes("https")?C:`https://${C}`:C,S.value)}),100)}),[B]),l.useEffect((()=>{!M&&S&&E.updatedValue&&setTimeout((()=>{K("custom_link"===(null==S?void 0:S.value)&&C?C.includes("https")?E.updatedValue:`https://${E.updatedValue}`:E.updatedValue,S.value),q(!0)}),100)}),[S]),e.jsxs(g,Object.assign({channel:R,focused:N,onMouseEnter:()=>P(!0),onMouseLeave:()=>P(!1)},{children:[e.jsx("div",Object.assign({style:{marginBottom:8}},{children:e.jsxs(r.BodySecondary,Object.assign({style:{color:W&&!S?p.COLORS.content.negative:p.COLORS.content.primary}},{children:[null===(f=E.variableName)||void 0===f?void 0:f.replace("{{","").replace("}}","")," ","link"===(null==E?void 0:E.type)?"link":"variable"]}))})),e.jsx("div",Object.assign({style:{marginBottom:12}},{children:j?e.jsxs("div",Object.assign({style:{display:"flex",border:"#E0E0E0 1px solid",borderRadius:4,padding:10,justifyContent:(null==S?void 0:S.label)?"space-between":"flex-end"}},{children:[e.jsx(r.BodyPrimary,{children:u.truncate(null!==(T=null==S?void 0:S.label)&&void 0!==T?T:"",20,!0)}),e.jsx(t.default,{onClick:()=>{Y(!w)},width:24,height:24,color:p.COLORS.content.primary})]})):e.jsx(i.Dropdown,{options:V,isSearchable:!1,onSelect:J,defaultOptions:S?[Object.assign(Object.assign({},S),{selected:!0})]:[]})})),("custom_text"===(null==S?void 0:S.value)||"custom_link"===(null==S?void 0:S.value))&&e.jsx(o.Input,{labelText:"custom_text"===(null==S?void 0:S.value)?"Custom text value":"custom_link"===(null==S?void 0:S.value)?"Custom URL value":"",id:`variable-value-${null==S?void 0:S.value}-${_}`,value:C,errorMessage:W?C&&0!==C.trim().length?"custom_link"!==S.value||/^https?:\/\/(?:www\.)?[-a-zA-Z0-9@:%._\+~#=]{1,256}\.[a-zA-Z0-9()]{1,6}\b(?:[-a-zA-Z0-9()@:%_\+.~#?&\/=]*)$/.test(`https://${C.trim()}`)&&0!==C.trim().length?"custom_link"!==S.value&&C.length>30?"Length cannot be more than 30":"":"Enter valid URL":"Required field":"",maxCharLimit:"custom_link"===(null==S?void 0:S.value)?void 0:30,prefixText:"custom_link"===(null==S?void 0:S.value)?"https://":"",placeholder:"link"===E.type||"custom_link"===S.value?"Enter custom URL here":"Enter custom text here",onChangeText:e=>{!function(e,t){var l;L(t);const a="custom_link"===(null==S?void 0:S.value)&&t?t.includes("https")?t:`https://${t}`:t;K(a,e),R===d.CHANNEL_TYPE.WHATSAPP&&(null==Q||Q(null!==(l=E.index)&&void 0!==l?l:0,a))}(S.value,e)}}),w&&e.jsx(n.AddVariableV2SideModal,{zIndex:2e3,data:null!=y?y:[],showVariable:w,setShowVariable:Y,placeholder:"Add a variable",customTrigger:e=>{null==A||A(!1),"{{custom.url}}"===e.actualValue?J({label:e.displayName,selected:!0,value:"custom_link"}):"{{custom.text}}"==e.actualValue?J({label:e.displayName,selected:!0,value:"custom_text"}):J({label:e.displayName.replace("{{","").replace("}}","").trim().replace("."," "),selected:!0,value:e.actualValue,bikPlaceholderType:"string"})}})]}))};
7
+ `,x={value:"custom_link",label:"Custom URL"},j={value:"custom_text",label:"Custom text"};exports.Container=h,exports.default=a=>{let{onFocus:g,variable:E,index:O,showVariableModal:_,variableList:T,setShowDiscountCheckBox:y,componentType:A,CTAoptions:f}=a;var N,P;const[C,S]=l.useState(!1),[V,k]=l.useState(""),[L,H]=l.useState([]),[w,B]=l.useState(),[Y,q]=l.useState(!1),[M,R]=l.useState(!1),{device:W,channel:D,isError:I,originalVariableList:$,template:U,templateSelectionTriggered:z,setTemplate:Z,setDisplayContent:F,setOriginalVariableList:G,globalNormalizedPlaceholders:J,enabledCustomText:K,pod:Q}=m.useTemplateModalContext();function X(e,t){var l,a,n;const i=e;k(""),B(i),D===d.CHANNEL_TYPE.WHATSAPP?"custom_text"!==i.value&&"custom_link"!==i.value?(ee(null!==(l=i.value)&&void 0!==l?l:"","string"),null==te||te(null!==(a=E.index)&&void 0!==a?a:0,i.value,!0)):(null==te||te(null!==(n=E.index)&&void 0!==n?n:0,E.variableName,!0,"custom_text"),ee("","url"===i.bikPlaceholderType?"link":"string")):"custom_text"!==i.value&&"custom_link"!==i.value?ee(i.value,"url"===i.bikPlaceholderType?"link":"string"):(k(""),ee("",i.value))}function ee(e,t){var l,a,n,i;const o="custom_link"===t?"link":"custom_text"===t?"string":t;if(D!==d.CHANNEL_TYPE.WHATSAPP){const a=b.getVariableNameForEmailByIndex(O+1),n=null===document||void 0===document?void 0:document.getElementById("mobile"===W?"template_html_mobile":"template_html_desktop"),i=D===d.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:E.variableName);const s=$.map(((t,l)=>l===O?Object.assign(Object.assign({},t),{type:o,updatedValue:e}):t));null==G||G(s)}if(D===d.CHANNEL_TYPE.WHATSAPP){const l=$;let s=l.body,u=l.header,d=l.buttons;"BODY"===A?s=null===(a=l.body)||void 0===a?void 0:a.map(((t,l)=>l===O?Object.assign(Object.assign({},t),{type:o,updatedValue:e}):t)):"HEADER"===A?u=null===(n=l.header)||void 0===n?void 0:n.map(((t,l)=>l===O?Object.assign(Object.assign({},t),{type:o,updatedValue:e}):t)):"BUTTONS"===A&&(d=null===(i=l.buttons)||void 0===i?void 0:i.map(((l,a)=>a===O?Object.assign(Object.assign({},l),{buttonVariable:"custom_link"===t?"((customPlaceholderName))":e,example:[e]}):l))),null==G||G((e=>Object.assign(Object.assign({},e),{header:u,body:s,buttons:d})))}}function te(e,t,l,a){var n,i,o,s;const u=Object.assign({},U),d=null===(n=null==u?void 0:u.components)||void 0===n?void 0:n.map((l=>{var a,n,i,o,s,u,d,r,c,p;const v=Object.assign({},l);if("BODY"===l.type&&"BODY"===A){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!==(s=null===(o=null===(i=v.example)||void 0===i?void 0:i.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({},v.example),{body_text:[l]});return Object.assign(Object.assign({},v),{example:a})}}else if("HEADER"===l.type&&"HEADER"===A){if(null===(u=l.example)||void 0===u?void 0:u.header_text){const l=[...null!==(r=null===(d=v.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({},v.example),{header_text:l});return Object.assign(Object.assign({},v),{example:a})}}else if("BUTTONS"===l.type&&"BUTTONS"===A&&(null===(p=null===(c=l.buttons)||void 0===c?void 0:c[e])||void 0===p?void 0:p.example)){const a=l.buttons.map(((l,a)=>a===e?Object.assign(Object.assign({},l),{example:[t]}):l));return Object.assign(Object.assign({},v),{buttons:a})}return l}));u.components=d,l&&("BODY"===A&&(null===(i=null==u?void 0:u.mapping)||void 0===i?void 0:i.body)?u.mapping=Object.assign(Object.assign({},u.mapping),{body:u.mapping.body.map(((l,n)=>e===n?"custom_text"===a?`((editableVariable${n+10}))`:t:l))}):"HEADER"===A&&(null===(o=null==u?void 0:u.mapping)||void 0===o?void 0:o.header)?u.mapping=Object.assign(Object.assign({},u.mapping),{header:u.mapping.header.map(((l,n)=>e===n?"custom_text"===a?`((editableVariable${n+20}))`:t:l))}):"BUTTONS"===A&&(null===(s=null==u?void 0:u.mapping)||void 0===s?void 0:s.buttons)&&(u.mapping=Object.assign(Object.assign({},u.mapping),{buttons:u.mapping.buttons.map(((l,n)=>n===e?"custom_link"===a?"((customPlaceholderName))":t:l))}))),null==Z||Z(Object.assign({},u))}return l.useEffect((()=>{C&&(null==g||g())}),[C]),l.useEffect((()=>{!function(){var e,t,l,a,n;const i="mobile"===W?"template_html_mobile":"template_html_desktop",o=document.getElementById(i),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===(n=null==o?void 0:o.contentWindow)||void 0===n?void 0:n.document.head.innerHTML);D===d.CHANNEL_TYPE.EMAIL&&(null==F||F(s))}()}),[z]),l.useEffect((()=>{var e;const t=[];let l=[];if(D!==d.CHANNEL_TYPE.MESSAGE||K){"link"===(null==E?void 0:E.type)?(t.push({label:"",options:[x,j]}),B(x)):(t.push({label:"",options:[x,j]}),B(j));const e=null!=J?J:[];H([...t,...e.map((e=>{var t,l;return Object.assign(Object.assign({},e),{label:p.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())})}))]),l=[...t,...e]}else{const e=null!=J?J:[];H([{label:"",options:[j,x]},...e]),l=[{label:"",options:[j,x]},...e]}if((D===d.CHANNEL_TYPE.WHATSAPP||D===d.CHANNEL_TYPE.EMAIL||D===d.CHANNEL_TYPE.MESSAGE)&&E.updatedValue)if(u.placeHolderNamePattern.test(E.updatedValue)&&D===d.CHANNEL_TYPE.WHATSAPP||E.updatedValue.startsWith("{{")&&D!==d.CHANNEL_TYPE.WHATSAPP){const e=function(e,t,l){var a;let n={label:"",value:""};const i=l===d.CHANNEL_TYPE.WHATSAPP?e.updatedValue.replace("[[","").replace("]]",""):e.updatedValue.replace("{{","").replace("}}","");if(_){let t=e.updatedValue;if(Q===r.POD.CHATBOT&&"BUTTONS"===A){const l=null==f?void 0:f.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}(E,l,D);e.value&&B(e)}else(null===(e=E.updatedValue)||void 0===e?void 0:e.startsWith("https"))?(B(x),k(E.updatedValue.split("https://")[1])):(B(j),k(E.updatedValue))}),[]),l.useEffect((()=>{W&&w&&V&&setTimeout((()=>{ee("custom_link"===(null==w?void 0:w.value)&&V?V.includes("https")?V:`https://${V}`:V,w.value)}),100)}),[W]),l.useEffect((()=>{!M&&w&&E.updatedValue&&setTimeout((()=>{ee("custom_link"===(null==w?void 0:w.value)&&E.updatedValue?E.updatedValue.includes("https")?E.updatedValue:`https://${E.updatedValue}`:E.updatedValue,w.value),R(!0)}),100)}),[w]),e.jsxs(h,Object.assign({channel:D,focused:C,onMouseEnter:()=>S(!0),onMouseLeave:()=>S(!1)},{children:[e.jsx("div",Object.assign({style:{marginBottom:8}},{children:e.jsxs(c.BodySecondary,Object.assign({style:{color:I&&!w?v.COLORS.content.negative:v.COLORS.content.primary}},{children:[null===(N=E.variableName)||void 0===N?void 0:N.replace("{{","").replace("}}","")," ","link"===(null==E?void 0:E.type)?"link":"variable"]}))})),e.jsx("div",Object.assign({style:{marginBottom:12}},{children:_?e.jsxs("div",Object.assign({style:{display:"flex",border:"#E0E0E0 1px solid",borderRadius:4,padding:10,justifyContent:(null==w?void 0:w.label)?"space-between":"flex-end"}},{children:[e.jsx(c.BodyPrimary,{children:s.truncate(null!==(P=null==w?void 0:w.label)&&void 0!==P?P:"",20,!0)}),e.jsx(t.default,{onClick:()=>{q(!Y)},width:24,height:24,color:v.COLORS.content.primary})]})):e.jsx(i.Dropdown,{options:L,isSearchable:!1,onSelect:X,defaultOptions:w?[Object.assign(Object.assign({},w),{selected:!0})]:[]})})),("custom_text"===(null==w?void 0:w.value)||"custom_link"===(null==w?void 0:w.value))&&e.jsx(o.Input,{labelText:"custom_text"===(null==w?void 0:w.value)?"Custom text value":"custom_link"===(null==w?void 0:w.value)?"Custom URL value":"",id:`variable-value-${null==w?void 0:w.value}-${O}`,value:V,errorMessage:I?V&&0!==V.trim().length?"custom_link"!==w.value||/^https?:\/\/(?:www\.)?[-a-zA-Z0-9@:%._\+~#=]{1,256}\.[a-zA-Z0-9()]{1,6}\b(?:[-a-zA-Z0-9()@:%_\+.~#?&\/=]*)$/.test(`https://${V.trim()}`)&&0!==V.trim().length?"custom_link"!==w.value&&V.length>30?"Length cannot be more than 30":"":"Enter valid URL":"Required field":"",maxCharLimit:"custom_link"===(null==w?void 0:w.value)?void 0:30,prefixText:"custom_link"===(null==w?void 0:w.value)?"https://":"",placeholder:"link"===E.type||"custom_link"===w.value?"Enter custom URL here":"Enter custom text here",onChangeText:e=>{!function(e,t){var l;k(t);const a="custom_link"===(null==w?void 0:w.value)&&t?t.includes("https")?t:`https://${t}`:t;ee(a,e),D===d.CHANNEL_TYPE.WHATSAPP&&(null==te||te(null!==(l=E.index)&&void 0!==l?l:0,a,"custom_link"===e,e))}(w.value,e)}}),Y&&e.jsx(n.AddVariableV2SideModal,{zIndex:2e3,data:null!=T?T:[],showVariable:Y,setShowVariable:q,placeholder:"Add a variable",customTrigger:e=>{null==y||y(!1),"{{custom.url}}"===e.actualValue?X({label:e.displayName,selected:!0,value:"custom_link"}):"{{custom.text}}"==e.actualValue?X({label:e.displayName,selected:!0,value:"custom_text"}):X({label:e.displayName.replace("{{","").replace("}}","").trim().replace("."," "),selected:!0,value:e.actualValue,bikPlaceholderType:"string"})}})]}))};
@@ -1,3 +1,4 @@
1
+ import { VariableListInterfaceV2 } from "../../add-variableV2/AddVariableV2";
1
2
  import { ButtonPlaceHolderOptions } from "../../template-preview/models/TemplateMeta";
2
3
  import { CTABtnValType, QRBBtnValType, TEMPLATE_BUTTON } from "../../template-preview/models/WhatsAppTemplate";
3
4
  import { WhatsAppTemplateVariables } from "../../template-preview/models/WhatsAppTemplate";
@@ -10,6 +11,8 @@ export interface WhatsAppTemplateCardButtonV2Props {
10
11
  button: TEMPLATE_BUTTON;
11
12
  CTAoptions?: ButtonPlaceHolderOptions[];
12
13
  QRBoptions?: ButtonPlaceHolderOptions[];
14
+ variableList?: VariableListInterfaceV2[];
15
+ variableListIndex: number;
13
16
  }
14
- declare const WhatsAppTemplateCardButtonV2: ({ button, updateSelectedURLTemplateBtn, updateSelectedQRBTemplateBtn, originalVariableList, CTAoptions, QRBoptions, }: WhatsAppTemplateCardButtonV2Props) => import("react/jsx-runtime").JSX.Element;
17
+ declare const WhatsAppTemplateCardButtonV2: ({ variableListIndex, button, updateSelectedURLTemplateBtn, updateSelectedQRBTemplateBtn, originalVariableList, CTAoptions, QRBoptions, variableList, }: WhatsAppTemplateCardButtonV2Props) => import("react/jsx-runtime").JSX.Element;
15
18
  export default WhatsAppTemplateCardButtonV2;
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),t=require("react"),l=require("../../dropdown/Dropdown.js"),a=require("../../input/Input.js"),s=require("../../template-preview/constants/regexPatterns.js"),n=require("../../template-preview/models/TemplateMeta.js"),i=require("../../template-preview/models/WhatsAppTemplate.js"),r=require("../../TypographyStyle.js"),o=require("../../../constants/Theme.js"),d=require("../context/templateModalContext.js"),u=require("../utils/validateIsUrl.js"),c=require("./VariableConnector.js");exports.default=p=>{let{button:b,updateSelectedURLTemplateBtn:j,updateSelectedQRBTemplateBtn:m,originalVariableList:g,CTAoptions:x,QRBoptions:v}=p;const[y,O]=t.useState(""),[f,h]=t.useState(),{setOriginalVariableList:R,isError:U,disableEditVariable:L}=d.useTemplateModalContext();function T(e){O(e);const t=[Object.assign(Object.assign({},g.buttons[0]),{type:i.BUTTON_TYPE.URL,buttonVariable:"((customPlaceholderName))",example:[`https://${e}`]})];null==R||R((e=>Object.assign(Object.assign({},e),{body:[...g.body],buttons:[...t]}))),null==j||j(`https://${e}`,"custom")}return t.useEffect((()=>{var e;if(b.buttonVariable&&s.editableVarPattern.test(b.buttonVariable))h(n.CUSTOM_URL_NAME),O((null===(e=b.example)||void 0===e?void 0:e[0].split("https://")[1])||"");else{let e=-1;const t="URL"===b.type?x:v;e="URL"===b.type?t.findIndex((e=>e.placeHolder===b.buttonVariable)):t.findIndex((e=>e.label===b.flowName)),e>-1&&h(t[e])}}),[]),e.jsxs(c.Container,{children:[e.jsx("div",Object.assign({style:{marginBottom:8}},{children:e.jsxs(r.BodySecondary,Object.assign({style:{color:o.COLORS.content.primary}},{children:[b.text," button"]}))})),e.jsx("div",Object.assign({style:{marginBottom:12}},{children:e.jsx(l.Dropdown,{disabled:L,options:"URL"===b.type?x:v,isSearchable:!1,onSelect:function(e,t){const l=e;h(l);const a=("URL"===b.type?x:v).find((e=>e.placeHolder===l.placeHolder));if(a)if("custom_link"!==a.value){let e;"URL"===b.type?(e=[Object.assign(Object.assign({},g.buttons[0]),{type:"URL",buttonVariable:l.placeHolder,example:["https://bik.ai/"]})],null==j||j({defaultValue:a.value,placeHolder:a.placeHolder},"placeholder")):(e=g.buttons.map(((e,t)=>t===b.index?Object.assign(Object.assign({},e),{type:"QUICK_REPLY",flowName:l.label,flowId:l.value}):e)),null==m||m({flowName:l.label,flowId:l.value},"placeholder",b.index)),null==R||R((t=>Object.assign(Object.assign({},t),{body:[...g.body],buttons:[...e]})))}else T("")},defaultOptions:f?[Object.assign(Object.assign({},f),{selected:!0})]:[]})})),"custom_link"===(null==f?void 0:f.value)&&e.jsx("div",Object.assign({style:{marginBottom:20}},{children:e.jsx(a.Input,{state:L?"disabled":"none",errorMessage:U?y?u.validateIsUrl(y)?"":"Enter valid URL":"Required field":"",value:y,prefixText:"custom_link"===(null==f?void 0:f.value)?"https://":"",placeholder:"Enter custom URL here",onChangeText:T})}))]})};
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),t=require("react"),a=require("../../dropdown/Dropdown.js"),l=require("../../input/Input.js"),s=require("../../template-preview/constants/regexPatterns.js"),i=require("../../template-preview/models/TemplateMeta.js"),o=require("../../template-preview/models/WhatsAppTemplate.js"),r=require("../../TypographyStyle.js"),n=require("../../../constants/Theme.js"),d=require("../context/templateModalContext.js"),u=require("../utils/validateIsUrl.js"),p=require("./VariableConnector.js");exports.default=c=>{let{variableListIndex:b,button:m,updateSelectedURLTemplateBtn:v,updateSelectedQRBTemplateBtn:j,originalVariableList:x,CTAoptions:y,QRBoptions:O,variableList:g}=c;var f,h,T,L;const[U,V]=t.useState(""),[R,C]=t.useState(),q=t.useCallback((()=>g?[...g,{description:"",displayName:"Custom variables",orderId:1,variables:{"Custom url":{description:void 0,displayName:"Custom url",actualValue:"{{custom.url}}",variableType:"any",isAvailable:!0}}}].sort(((e,t)=>e.orderId-t.orderId)):g),[g]),I=t.useMemo((()=>q()),[q]),{setOriginalVariableList:w,isError:B,disableEditVariable:N,pod:S}=d.useTemplateModalContext();function E(e){V(e);const t=[Object.assign(Object.assign({},x.buttons[0]),{type:o.BUTTON_TYPE.URL,buttonVariable:"((customPlaceholderName))",example:[`https://${e}`]})];null==w||w((e=>Object.assign(Object.assign({},e),{body:[...x.body],buttons:[...t]}))),null==v||v(`https://${e}`,"custom")}return t.useEffect((()=>{var e;if(m.buttonVariable&&s.editableVarPattern.test(m.buttonVariable))C(i.CUSTOM_URL_NAME),V((null===(e=m.example)||void 0===e?void 0:e[0].split("https://")[1])||"");else{let e=-1;const t="URL"===m.type?y:O;e="URL"===m.type?t.findIndex((e=>e.placeHolder===m.buttonVariable)):t.findIndex((e=>e.label===m.flowName)),e>-1&&C(t[e])}}),[]),S!==o.POD.CHATBOT?e.jsxs(p.Container,{children:[e.jsx("div",Object.assign({style:{marginBottom:8}},{children:e.jsxs(r.BodySecondary,Object.assign({style:{color:n.COLORS.content.primary}},{children:[m.text," button"]}))})),e.jsx("div",Object.assign({style:{marginBottom:12}},{children:e.jsx(a.Dropdown,{disabled:N,options:"URL"===m.type?y:O,isSearchable:!1,onSelect:function(e,t){const a=e;C(a);const l=("URL"===m.type?y:O).find((e=>e.placeHolder===a.placeHolder));if(l)if("custom_link"!==l.value){let e;"URL"===m.type?(e=[Object.assign(Object.assign({},x.buttons[0]),{type:"URL",buttonVariable:a.placeHolder,example:["https://bik.ai/"]})],null==v||v({defaultValue:l.value,placeHolder:l.placeHolder},"placeholder")):(e=x.buttons.map(((e,t)=>t===m.index?Object.assign(Object.assign({},e),{type:"QUICK_REPLY",flowName:a.label,flowId:a.value}):e)),null==j||j({flowName:a.label,flowId:a.value},"placeholder",m.index)),null==w||w((t=>Object.assign(Object.assign({},t),{body:[...x.body],buttons:[...e]})))}else E("")},defaultOptions:R?[Object.assign(Object.assign({},R),{selected:!0})]:[]})})),"custom_link"===(null==R?void 0:R.value)&&e.jsx("div",Object.assign({style:{marginBottom:20}},{children:e.jsx(l.Input,{state:N?"disabled":"none",errorMessage:B?U?u.validateIsUrl(U)?"":"Enter valid URL":"Required field":"",value:U,prefixText:"custom_link"===(null==R?void 0:R.value)?"https://":"",placeholder:"Enter custom URL here",onChangeText:E})}))]}):e.jsx(p.default,{index:b,variable:{variableName:null!==(f=m.text)&&void 0!==f?f:"",updatedValue:"((customPlaceholderName))"===m.buttonVariable?`${null===(h=m.example)||void 0===h?void 0:h[0]}`:null!==(T=m.buttonVariable)&&void 0!==T?T:"",type:"link",isEditableVariable:!0,index:null!==(L=m.index)&&void 0!==L?L:0},showVariableModal:!0,componentType:"BUTTONS",variableList:I,CTAoptions:y})};
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});exports.getAllDataFromTemplateComponent=t=>{var e,o;const n=[],p=[],i=[],l=[],s=[];let a=null;return t.components.forEach(((t,e)=>{var o,l,s,r,u,d;if("BODY"===t.type&&t.text&&n.push({component:t,i:e,type:"BODY"}),"HEADER"===t.type&&"NONE"!==t.format&&"TEXT"!==t.format&&(null===(l=null===(o=t.example)||void 0===o?void 0:o.header_handle)||void 0===l?void 0:l[0])&&(a=t),"HEADER"===t.type&&"TEXT"===t.format&&n.push({component:t,i:e,type:"HEADER"}),"BUTTONS"===t.type){const o=null===(r=null===(s=t.buttons)||void 0===s?void 0:s.filter)||void 0===r?void 0:r.call(s,(t=>"URL"===t.type));p.push({component:Object.assign(Object.assign({},t),{buttons:o}),i:e});const n=null===(d=null===(u=t.buttons)||void 0===u?void 0:u.filter)||void 0===d?void 0:d.call(u,(t=>"QUICK_REPLY"===t.type));i.push({component:Object.assign(Object.assign({},t),{buttons:n}),i:e}),i.push}})),t.mapping&&(null===(e=t.mapping.body)||void 0===e||e.forEach((t=>{l.push(t)}))),t.mapping&&(null===(o=t.mapping.header)||void 0===o||o.forEach((t=>{s.push(t)}))),{imageComponent:a,descriptionComponents:n,urlBtns:p,qrbBtns:i,bodyVariables:l,headerVariables:s}};
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});exports.getAllDataFromTemplateComponent=t=>{var e,o;const n=[],i=[],p=[],l=[],s=[];let a=null;return t.components.forEach(((t,e)=>{var o,l,s,r,u,d;if("BODY"===t.type&&t.text&&n.push({component:t,i:e,type:"BODY"}),"HEADER"===t.type&&"NONE"!==t.format&&"TEXT"!==t.format&&(null===(l=null===(o=t.example)||void 0===o?void 0:o.header_handle)||void 0===l?void 0:l[0])&&(a=t),"HEADER"===t.type&&"TEXT"===t.format&&n.push({component:t,i:e,type:"HEADER"}),"BUTTONS"===t.type){const o=null===(r=null===(s=t.buttons)||void 0===s?void 0:s.filter)||void 0===r?void 0:r.call(s,(t=>"URL"===t.type));i.push({component:Object.assign(Object.assign({},t),{buttons:o}),i:e});const n=null===(d=null===(u=t.buttons)||void 0===u?void 0:u.filter)||void 0===d?void 0:d.call(u,(t=>"QUICK_REPLY"===t.type));p.push({component:Object.assign(Object.assign({},t),{buttons:n}),i:e})}})),t.mapping&&(null===(e=t.mapping.body)||void 0===e||e.forEach((t=>{l.push(t)}))),t.mapping&&(null===(o=t.mapping.header)||void 0===o||o.forEach((t=>{s.push(t)}))),{imageComponent:a,descriptionComponents:n,urlBtns:i,qrbBtns:p,bodyVariables:l,headerVariables:s}};
@@ -1,19 +1,19 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),t=require("../../../assets/icons/halfRectangle.svg.js"),r=require("../../../assets/icons/phone.svg.js"),s=require("../../../assets/icons/RedirectToNew.svg.js"),a=require("styled-components"),i=require("../../tooltips/Tooltip.js"),o=require("../../TypographyStyle.js"),n=require("../../../constants/Theme.js"),l=require("../helpers/VariableEditorHelper.js"),d=require("../models/TemplateMeta.js"),p=require("./ChatBtn.js"),h=require("./ChatUI.style.js"),x=require("./MediaCard.js");function c(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var u=c(a);const j=u.default.div`
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),t=require("../../../assets/icons/halfRectangle.svg.js"),r=require("../../../assets/icons/phone.svg.js"),s=require("../../../assets/icons/RedirectToNew.svg.js"),a=require("styled-components"),i=require("../../tooltips/Tooltip.js"),n=require("../../TypographyStyle.js"),o=require("../../../constants/Theme.js"),l=require("../helpers/VariableEditorHelper.js"),d=require("../models/TemplateMeta.js"),p=require("./ChatBtn.js"),h=require("./ChatUI.style.js"),x=require("./MediaCard.js");function u(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var c=u(a);const j=c.default.div`
2
2
  position: absolute;
3
3
  width: 8px;
4
4
  height: 8px;
5
5
  left: -8px;
6
6
  top: -9px;
7
- `,m=u.default.div`
7
+ `,m=c.default.div`
8
8
  font-family: 'Inter';
9
9
  font-style: normal;
10
10
  font-weight: 400;
11
11
  font-size: 14px;
12
12
  line-height: 20px;
13
13
  padding: 8px 12px 0px;
14
- color: ${n.COLORS.content.primary};
14
+ color: ${o.COLORS.content.primary};
15
15
  word-wrap: break-word;
16
- `,T=u.default(m)`
16
+ `,y=c.default(m)`
17
17
  font-weight: 600;
18
18
  margin-bottom: 8px;
19
- `,y=new l.VariableEditorHelper;exports.ChatUIV2=a=>{const{bodyText:n,footerText:l,headerMediaType:c,headerText:u,headerAssetLink:f,headerAssetName:g,quickReplybtn:E,ctaBtn:b,actionTypes:S,extras:v,showHeader:C,imagePreviewStyles:q,size:w,bodyVariableList:_,headerVariableList:A}=a,I=y.format(n,_),N=y.format(u,A);return e.jsxs(h.Container,{children:[e.jsx(j,{children:e.jsx(t.default,{color:"white",height:8,width:8})}),c===d.HEADER_TYPES.TEXT?e.jsx(T,{dangerouslySetInnerHTML:{__html:N}}):c!==d.HEADER_TYPES.NONE?e.jsx(x.MediaCard,{headerAssetLink:f,headerAssetName:g,mediaType:c,imagePreviewStyles:c===d.HEADER_TYPES.IMAGE?q:{}}):e.jsx(e.Fragment,{}),!!n&&e.jsx(e.Fragment,{children:e.jsx(m,{dangerouslySetInnerHTML:{__html:I}})}),e.jsxs(h.FooterWrapper,{children:[e.jsx(i.Tooltip,Object.assign({body:null!=l?l:"",placement:"top"},{children:e.jsx(h.TimeStamp,Object.assign({style:{flex:1}},{children:l}))})),e.jsx(h.TimeStamp,{children:"16:48"})]}),S===d.ACTIONS_TYPES.QUICK_REPLY?e.jsx("div",{children:null==E?void 0:E.map(((t,r)=>e.jsx(p.ChatBtn,{text:t.text},r)))}):S===d.ACTIONS_TYPES.CTA_BTN?e.jsx("div",{children:null==b?void 0:b.map(((t,a)=>e.jsx(p.ChatBtn,{textTypography:C?o.Caption:o.BodySecondary,extraContent:v?t.extra:void 0,placeholder:t.placeholder,text:t.text,Icon:"phoneNumber"===t.type?r.default:s.default,size:w},a)))}):e.jsx(e.Fragment,{})]})};
19
+ `,T=new l.VariableEditorHelper;exports.ChatUIV2=a=>{const{bodyText:o,footerText:l,headerMediaType:u,headerText:c,headerAssetLink:f,headerAssetName:g,quickReplybtn:E,ctaBtn:C,actionTypes:b,extras:S,showHeader:_,imagePreviewStyles:v,size:q,bodyVariableList:w,headerVariableList:I,buttons:P}=a,A=T.format(o,w),N=T.format(c,I),O={COPY_CODE:r.default,PHONE_NUMBER:r.default,URL:s.default,QUICK_REPLY:()=>e.jsx(e.Fragment,{})};return e.jsxs(h.Container,{children:[e.jsx(j,{children:e.jsx(t.default,{color:"white",height:8,width:8})}),u===d.HEADER_TYPES.TEXT?e.jsx(y,{dangerouslySetInnerHTML:{__html:N}}):u!==d.HEADER_TYPES.NONE?e.jsx(x.MediaCard,{headerAssetLink:f,headerAssetName:g,mediaType:u,imagePreviewStyles:u===d.HEADER_TYPES.IMAGE?v:{}}):e.jsx(e.Fragment,{}),!!o&&e.jsx(e.Fragment,{children:e.jsx(m,{dangerouslySetInnerHTML:{__html:A}})}),e.jsxs(h.FooterWrapper,{children:[e.jsx(i.Tooltip,Object.assign({body:null!=l?l:"",placement:"top"},{children:e.jsx(h.TimeStamp,Object.assign({style:{flex:1}},{children:l}))})),e.jsx(h.TimeStamp,{children:"16:48"})]}),P&&P.length>0?P.map(((t,r)=>e.jsx(p.ChatBtn,{text:t.text,Icon:O[t.type],size:q},r))):b===d.ACTIONS_TYPES.QUICK_REPLY?e.jsx("div",{children:null==E?void 0:E.map(((t,r)=>e.jsx(p.ChatBtn,{text:t.text},r)))}):b===d.ACTIONS_TYPES.CTA_BTN?e.jsx("div",{children:null==C?void 0:C.map(((t,a)=>e.jsx(p.ChatBtn,{textTypography:_?n.Caption:n.BodySecondary,extraContent:S?t.extra:void 0,placeholder:t.placeholder,text:t.text,Icon:"phoneNumber"===t.type?r.default:s.default,size:q},a)))}):e.jsx(e.Fragment,{})]})};
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),s=require("../../../assets/icons/filePdf.svg.js"),r=require("../../../assets/icons/image.svg.js"),t=require("../../../assets/icons/videoRecorder.svg.js"),a=require("../../TypographyStyle.js"),i=require("../../../constants/Theme.js"),n=require("../models/TemplateMeta.js"),d=require("./ChatUI.style.js");const o=o=>{let{headerAssetName:c,mediaType:l}=o;const j=l===n.HEADER_TYPES.IMAGE?r.default:l===n.HEADER_TYPES.VIDEO?t.default:s.default;return e.jsxs(d.MediaContainer,{children:[e.jsx(j,{height:40,width:40,color:i.COLORS.icon.placeholder}),!!c&&e.jsx(a.BodySecondary,Object.assign({style:{color:i.COLORS.content.secondary,marginTop:8}},{children:c}))]})};exports.MediaCard=s=>{let{headerAssetLink:r,headerAssetName:t,mediaType:a,imagePreviewStyles:i}=s;if(!r||a===n.HEADER_TYPES.DOCUMENT)return e.jsx(o,Object.assign({},{headerAssetLink:r,headerAssetName:t,mediaType:a}));const c={width:"100%",minHeight:"156px",borderRadius:8};return e.jsx(d.MediaContainer,{children:a===n.HEADER_TYPES.IMAGE?e.jsx("img",{alt:"Header displays here",style:Object.assign(Object.assign({},c),i),src:r}):a===n.HEADER_TYPES.VIDEO?e.jsx("video",Object.assign({src:r,style:c,controls:!0},{children:e.jsx("track",{default:!0,kind:"captions",srcLang:"en",src:r})})):e.jsx(e.Fragment,{})})},exports.NoMediaCard=o;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),s=require("../../../assets/icons/filePdf.svg.js"),r=require("../../../assets/icons/image.svg.js"),i=require("../../../assets/icons/videoRecorder.svg.js"),t=require("../../TypographyStyle.js"),a=require("../../../constants/Theme.js"),d=require("../models/TemplateMeta.js"),n=require("./ChatUI.style.js"),o=require("../../shimmer-image/ShimmerImage.js");const c=o=>{let{headerAssetName:c,mediaType:l}=o;const m=l===d.HEADER_TYPES.IMAGE?r.default:l===d.HEADER_TYPES.VIDEO?i.default:s.default;return e.jsxs(n.MediaContainer,{children:[e.jsx(m,{height:40,width:40,color:a.COLORS.icon.placeholder}),!!c&&e.jsx(t.BodySecondary,Object.assign({style:{color:a.COLORS.content.secondary,marginTop:8}},{children:c}))]})};exports.MediaCard=s=>{let{headerAssetLink:r,headerAssetName:i,mediaType:t,imagePreviewStyles:a}=s;if(!r||t===d.HEADER_TYPES.DOCUMENT)return e.jsx(c,Object.assign({},{headerAssetLink:r,headerAssetName:i,mediaType:t}));return e.jsx(n.MediaContainer,{children:t===d.HEADER_TYPES.IMAGE?e.jsx(o.ShimmerImage,{imageUrl:r,alt:r,width:148,height:156,borderRadius:8}):t===d.HEADER_TYPES.VIDEO?e.jsx("video",Object.assign({src:r,style:{width:"100%",minHeight:"156px",borderRadius:8},controls:!0},{children:e.jsx("track",{default:!0,kind:"captions",srcLang:"en",src:r})})):e.jsx(e.Fragment,{})})},exports.NoMediaCard=c;
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),l=require("react"),t=require("./helpers/TemplateCreatorHelper.js"),a=require("./models/TemplateMeta.js"),i=require("./utils/TemplateHelperUtils.js"),r=require("./WhatsApp/WhatsAppLikePreview.js"),n=require("./WhatsApp/WhatsAppLikePreviewV2.js");exports.default=o=>{let{template:d,extras:s,containerStyle:u,usePlaceHolderName:p,showHeader:v,zeroStateComponent:h,size:x,showSampleValues:c}=o;var m,b,T,y,w,k,N,V,B,j,A,L,P,S,q,g,H,f,C,E,F,O;const[R,W]=l.useState(),U=new t.TemplateCreatorHelper,z=new i.TemplateHelperUtils,D=[];return(null===(b=null===(m=null==R?void 0:R.ctaBtn)||void 0===m?void 0:m.phoneNumber)||void 0===b?void 0:b.isChecked)&&D.push({type:"phoneNumber",text:null!==(T=R.ctaBtn.phoneNumber.btnText)&&void 0!==T?T:"",extra:null!==(y=R.ctaBtn.phoneNumber.phoneNumber)&&void 0!==y?y:""}),(null===(k=null===(w=null==R?void 0:R.ctaBtn)||void 0===w?void 0:w.websiteLinkBtn)||void 0===k?void 0:k.isChecked)&&D.push({type:"website",text:null!==(N=R.ctaBtn.websiteLinkBtn.btnText)&&void 0!==N?N:"",extra:null!==(B=null===(V=R.ctaBtn.websiteLinkBtn)||void 0===V?void 0:V.linkOpens)&&void 0!==B?B:"",placeholder:null!==(j=R.ctaBtn.websiteLinkBtn.placeholder)&&void 0!==j?j:""}),l.useEffect((()=>{d&&U.parseUITemplateFromDBFormat({dbFormattedTemplate:d,isDuplicate:!1,showSampleValues:c,isV2:!d.htmlContentUrl}).then((e=>{W(Object.assign({},e))}))}),[d,c]),d?d.htmlContentUrl?e.jsx(r.WhatsappLikePreview,{showHeader:v,containerPadding:"large"===x?"16px 56px 12px 16px":"12px 56px 12px 12px",containerStyle:u,textType:"html",bodyText:z.whatsappOnlyFillVariablesValueInBodyText(null!==(H=null==R?void 0:R.bodyText)&&void 0!==H?H:"",null!==(f=null==R?void 0:R.bodyVariables)&&void 0!==f?f:[],p),footerText:null==R?void 0:R.footerText,headerMediaType:(null==R?void 0:R.headerType)||a.HEADER_TYPES.NONE,headerText:z.fillVariablesValInBodyText(null!==(C=null==R?void 0:R.headerText)&&void 0!==C?C:"",null!==(E=null==R?void 0:R.headerVariables)&&void 0!==E?E:[],p),headerAssetLink:null!==(F=null==R?void 0:R.headerAssetLink)&&void 0!==F?F:"",headerAssetName:null!==(O=null==R?void 0:R.headerAssetName)&&void 0!==O?O:"",quickReplybtn:null==R?void 0:R.quickReply,ctaBtn:D,actionTypes:null==R?void 0:R.actionsType,extras:s,hidePreviewText:!0,imagePreviewStyles:{objectFit:"cover"},zeroStateComponent:null!=h?h:e.jsx(e.Fragment,{children:" "})}):e.jsx(n.WhatsappLikePreviewV2,{showHeader:v,containerPadding:"large"===x?"16px 56px 12px 16px":"12px 56px 12px 12px",containerStyle:u,textType:"html",bodyText:null==R?void 0:R.bodyText,footerText:null==R?void 0:R.footerText,headerMediaType:(null==R?void 0:R.headerType)||a.HEADER_TYPES.NONE,headerText:null==R?void 0:R.headerText,headerAssetLink:null!==(A=null==R?void 0:R.headerAssetLink)&&void 0!==A?A:"",headerAssetName:null!==(L=null==R?void 0:R.headerAssetName)&&void 0!==L?L:"",quickReplybtn:null==R?void 0:R.quickReply,ctaBtn:D,actionTypes:null==R?void 0:R.actionsType,extras:s,hidePreviewText:!0,imagePreviewStyles:{objectFit:"cover"},zeroStateComponent:null!=h?h:e.jsx(e.Fragment,{children:" "}),bodyVariableList:null!==(S=null===(P=null==R?void 0:R.bodyVariables)||void 0===P?void 0:P.map((e=>{var l;return{placeholder:e.variableName,value:null!==(l=e.variableVal)&&void 0!==l?l:e.variableName}})))&&void 0!==S?S:[],headerVariableList:null!==(g=null===(q=null==R?void 0:R.headerVariables)||void 0===q?void 0:q.map((e=>{var l;return{placeholder:e.variableName,value:null!==(l=e.variableVal)&&void 0!==l?l:e.variableName}})))&&void 0!==g?g:[]}):e.jsx(e.Fragment,{children:h})};
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),l=require("react"),t=require("./helpers/TemplateCreatorHelper.js"),a=require("./models/TemplateMeta.js"),i=require("./utils/TemplateHelperUtils.js"),n=require("./WhatsApp/WhatsAppLikePreview.js"),r=require("./WhatsApp/WhatsAppLikePreviewV2.js");exports.default=o=>{let{template:d,extras:s,containerStyle:u,usePlaceHolderName:p,showHeader:v,zeroStateComponent:h,size:x,showSampleValues:c}=o;var m,b,T,y,w,k,N,B,V,j,A,L,P,S,q,g,H,f,C,E,F,O;const[R,W]=l.useState(),U=new t.TemplateCreatorHelper,z=new i.TemplateHelperUtils,D=[];return(null===(b=null===(m=null==R?void 0:R.ctaBtn)||void 0===m?void 0:m.phoneNumber)||void 0===b?void 0:b.isChecked)&&D.push({type:"phoneNumber",text:null!==(T=R.ctaBtn.phoneNumber.btnText)&&void 0!==T?T:"",extra:null!==(y=R.ctaBtn.phoneNumber.phoneNumber)&&void 0!==y?y:""}),(null===(k=null===(w=null==R?void 0:R.ctaBtn)||void 0===w?void 0:w.websiteLinkBtn)||void 0===k?void 0:k.isChecked)&&D.push({type:"website",text:null!==(N=R.ctaBtn.websiteLinkBtn.btnText)&&void 0!==N?N:"",extra:null!==(V=null===(B=R.ctaBtn.websiteLinkBtn)||void 0===B?void 0:B.linkOpens)&&void 0!==V?V:"",placeholder:null!==(j=R.ctaBtn.websiteLinkBtn.placeholder)&&void 0!==j?j:""}),l.useEffect((()=>{d&&U.parseUITemplateFromDBFormat({dbFormattedTemplate:d,isDuplicate:!1,showSampleValues:c,isV2:!d.htmlContentUrl}).then((e=>{W(Object.assign({},e))}))}),[d,c]),d?d.htmlContentUrl?e.jsx(n.WhatsappLikePreview,{showHeader:v,containerPadding:"large"===x?"16px 56px 12px 16px":"12px 56px 12px 12px",containerStyle:u,textType:"html",bodyText:z.whatsappOnlyFillVariablesValueInBodyText(null!==(H=null==R?void 0:R.bodyText)&&void 0!==H?H:"",null!==(f=null==R?void 0:R.bodyVariables)&&void 0!==f?f:[],p),footerText:null==R?void 0:R.footerText,headerMediaType:(null==R?void 0:R.headerType)||a.HEADER_TYPES.NONE,headerText:z.fillVariablesValInBodyText(null!==(C=null==R?void 0:R.headerText)&&void 0!==C?C:"",null!==(E=null==R?void 0:R.headerVariables)&&void 0!==E?E:[],p),headerAssetLink:null!==(F=null==R?void 0:R.headerAssetLink)&&void 0!==F?F:"",headerAssetName:null!==(O=null==R?void 0:R.headerAssetName)&&void 0!==O?O:"",quickReplybtn:null==R?void 0:R.quickReply,ctaBtn:D,actionTypes:null==R?void 0:R.actionsType,extras:s,hidePreviewText:!0,imagePreviewStyles:{objectFit:"cover"},zeroStateComponent:null!=h?h:e.jsx(e.Fragment,{children:" "})}):e.jsx(r.WhatsappLikePreviewV2,{showHeader:v,containerPadding:"large"===x?"16px 56px 12px 16px":"12px 56px 12px 12px",containerStyle:u,textType:"html",bodyText:null==R?void 0:R.bodyText,footerText:null==R?void 0:R.footerText,headerMediaType:(null==R?void 0:R.headerType)||a.HEADER_TYPES.NONE,headerText:null==R?void 0:R.headerText,headerAssetLink:null!==(A=null==R?void 0:R.headerAssetLink)&&void 0!==A?A:"",headerAssetName:null!==(L=null==R?void 0:R.headerAssetName)&&void 0!==L?L:"",quickReplybtn:null==R?void 0:R.quickReply,ctaBtn:D,actionTypes:null==R?void 0:R.actionsType,extras:s,hidePreviewText:!0,imagePreviewStyles:{objectFit:"cover"},zeroStateComponent:null!=h?h:e.jsx(e.Fragment,{children:" "}),bodyVariableList:null!==(S=null===(P=null==R?void 0:R.bodyVariables)||void 0===P?void 0:P.map((e=>{var l;return{placeholder:e.variableName,value:null!==(l=e.variableVal)&&void 0!==l?l:e.variableName}})))&&void 0!==S?S:[],headerVariableList:null!==(g=null===(q=null==R?void 0:R.headerVariables)||void 0===q?void 0:q.map((e=>{var l;return{placeholder:e.variableName,value:null!==(l=e.variableVal)&&void 0!==l?l:e.variableName}})))&&void 0!==g?g:[],buttons:null==R?void 0:R.allButtons}):e.jsx(e.Fragment,{children:h})};
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../../../_virtual/_tslib.js"),t=require("../../../constants/Theme.js"),n=require("../constants/regexPatterns.js"),i=require("../constants/TemplateConstants.js"),l=require("../models/TemplateMeta.js"),o=require("../utils/TemplateHelperUtils.js");exports.TemplateCreatorHelper=class{parseDataFromHeaderComponent(e,t){var n,i,o,a,d,r,v,s,E,u;const T={headerType:l.HEADER_TYPES.NONE,headerVariables:[]},p=null===(n=e.components)||void 0===n?void 0:n.find((e=>"HEADER"===e.type));if(p){T.headerType=p.format,T.headerText=p.text,T.headerAssetLink=null===(o=null===(i=p.example)||void 0===i?void 0:i.header_handle)||void 0===o?void 0:o[0];const n=null===(d=null===(a=p.example)||void 0===a?void 0:a.header_text)||void 0===d?void 0:d[0],l=null===(v=null===(r=e.mapping)||void 0===r?void 0:r.header)||void 0===v?void 0:v[0],c=l;if(n&&l){const e=null==l?void 0:l.replace("[[","").replace("]]","").replace("{{","").replace("}}","").replace("((","").replace("))",""),i=/\(\(/.test(l),o={idx:0,variableVal:t?n:c,editable:i,editableDefaultValues:i?void 0:n,variableName:e};T.headerVariables=[o],(null===(E=null===(s=p.example)||void 0===s?void 0:s.header_text)||void 0===E?void 0:E.length)&&(T.headerText=null===(u=T.headerText)||void 0===u?void 0:u.replace("{{1}}",`{{${e}}}`))}}return T}validateState(e){var t,a,d,r,v,s,E,u,T,p,c,_,m,R,h,b,I,L,N,y,B;const A=/\p{Extended_Pictographic}/u;let D="valid";const C={meta:{},ctaBtn:{phoneNumber:{btnText:"",link:""},websiteLink:{btnText:"",link:""}},quickReply:[null,null,null]},O=new o.TemplateHelperUtils;let x=!1;const P=e=>{var t;null===(t=document.getElementById(e))||void 0===t||t.scrollIntoView({behavior:"smooth",block:"nearest"})};if((null===(t=e.meta)||void 0===t?void 0:t.name)?e.meta.name.trim().length>i.NAME_LEN_LIMIT?(C.meta.name=i.NAME_LEN_ERROR,D="invalid"):n.specialCharPattern.test(e.meta.name.trim())&&(C.meta.name=i.NO_SPECIAL_CHAR,D="invalid"):(C.meta.name=i.REQUIRED_FIELD,D="invalid"),C.meta.name&&!x&&(P(i.CREATE_TEMPLATE_DOM_IDS.name),x=!0),e.headerType===l.HEADER_TYPES.TEXT){const t=null!==(d=null===(a=e.headerText)||void 0===a?void 0:a.trim())&&void 0!==d?d:"";if(t)if(t.length>i.HEADER_TEXT_LEN_LIMIT)C.header=i.HEADER_LEN_ERROR,D="invalid";else{const e=O.getTemplateVariablesFromState(t);e&&e.length>1&&(C.header=i.ONE_VAR_ALLOWED,D="invalid")}else C.header=i.REQUIRED_FIELD,D="invalid"}else e.headerType===l.HEADER_TYPES.DOCUMENT||e.headerType===l.HEADER_TYPES.IMAGE||(e.headerType,l.HEADER_TYPES.VIDEO);if(e.headerType!==l.HEADER_TYPES.DOCUMENT&&e.headerType!==l.HEADER_TYPES.IMAGE&&e.headerType!==l.HEADER_TYPES.VIDEO||e.headerAssetLink||(C.header=i.HEADER_ASSET_LINK_ERROR,D="invalid"),C.header&&!x&&(P(i.CREATE_TEMPLATE_DOM_IDS.header),x=!0),e.bodyText?e.bodyTextRaw&&(null===(r=e.bodyTextRaw)||void 0===r?void 0:r.trim().length)>i.BODY_TEXT_LEN_LIMIT&&(C.body=i.BODY_LEN_ERROR,D="invalid"):(C.body=i.REQUIRED_FIELD,D="invalid"),C.body&&!x&&(P(i.CREATE_TEMPLATE_DOM_IDS.body),x=!0),e.footerText&&e.footerText.length>i.HEADER_TEXT_LEN_LIMIT&&(C.footer=i.HEADER_LEN_ERROR,D="invalid"),(null==C?void 0:C.footer)&&!x&&(P(i.CREATE_TEMPLATE_DOM_IDS.footer),x=!0),e.actionsType===l.ACTIONS_TYPES.CTA_BTN){if(null===(s=null===(v=e.ctaBtn)||void 0===v?void 0:v.phoneNumber)||void 0===s?void 0:s.isChecked){const t=null===(E=e.ctaBtn.phoneNumber.btnText)||void 0===E?void 0:E.trim(),n=e.ctaBtn.phoneNumber.phoneNumber;C.ctaBtn&&!t?(C.ctaBtn.phoneNumber.btnText=i.REQUIRED_FIELD,D="invalid"):C.ctaBtn&&t&&t.length>i.QUICK_REPLY_BTN_TEXT_LIMIT?(C.ctaBtn.phoneNumber.btnText=i.QUICK_REPLY_LEN_ERROR,D="invalid"):C.ctaBtn&&t&&A.test(t)&&(C.ctaBtn.phoneNumber.btnText=i.BUTTON_EMOJI_ERROR,D="invalid"),C.ctaBtn&&!n?(C.ctaBtn.phoneNumber.link=i.REQUIRED_FIELD,D="invalid"):C.ctaBtn&&n&&n.length<10&&(C.ctaBtn.phoneNumber.link=i.VALID_PHONE_NUMBER,D="invalid")}if(null===(T=null===(u=e.ctaBtn)||void 0===u?void 0:u.websiteLinkBtn)||void 0===T?void 0:T.isChecked){const t=null===(p=e.ctaBtn.websiteLinkBtn.btnText)||void 0===p?void 0:p.trim(),n=null===(c=e.ctaBtn.websiteLinkBtn.linkOpens)||void 0===c?void 0:c.trim(),l=null===(_=e.ctaBtn.websiteLinkBtn.placeholder)||void 0===_?void 0:_.trim();C.ctaBtn&&!t?(C.ctaBtn.websiteLink.btnText=i.REQUIRED_FIELD,D="invalid"):C.ctaBtn&&t&&t.length>i.QUICK_REPLY_BTN_TEXT_LIMIT?(C.ctaBtn.websiteLink.btnText=i.QUICK_REPLY_LEN_ERROR,D="invalid"):C.ctaBtn&&t&&A.test(t)&&(C.ctaBtn.websiteLink.btnText=i.BUTTON_EMOJI_ERROR,D="invalid"),!C.ctaBtn||n||l||(C.ctaBtn.websiteLink.link=i.REQUIRED_FIELD,D="invalid")}}else if(e.actionsType===l.ACTIONS_TYPES.QUICK_REPLY){const t=["","",""];e.quickReply.forEach(((n,l)=>{const o=n.text.trim();if(o)if(o.length>i.QUICK_REPLY_NAME_LEN_LIMIT)t[l]=i.QUICK_REPLY_LEN_ERROR,D="invalid";else if(A.test(o))t[l]=i.BUTTON_EMOJI_ERROR,D="invalid";else{const n=[...e.quickReply];n.splice(l,1);n.find((e=>e.text===o))&&(t[l]=i.QUICK_REPLY_NAME_ERROR,D="invalid")}else t[l]=i.REQUIRED_FIELD,D="invalid"})),C.quickReply=t}if(e.actionsType===l.ACTIONS_TYPES.CTA_BTN||e.actionsType===l.ACTIONS_TYPES.QUICK_REPLY){const e=null===(m=C.quickReply)||void 0===m?void 0:m.reduce(((e,t)=>e||!!t),!1);((null===(h=null===(R=null==C?void 0:C.ctaBtn)||void 0===R?void 0:R.websiteLink)||void 0===h?void 0:h.link)||(null===(I=null===(b=C.ctaBtn)||void 0===b?void 0:b.websiteLink)||void 0===I?void 0:I.btnText)||(null===(N=null===(L=C.ctaBtn)||void 0===L?void 0:L.phoneNumber)||void 0===N?void 0:N.link)||(null===(B=null===(y=C.ctaBtn)||void 0===y?void 0:y.phoneNumber)||void 0===B?void 0:B.btnText)||e)&&!x&&(P(i.CREATE_TEMPLATE_DOM_IDS.actionButtons),x=!0)}return{status:D,errors:C}}parseBodyComponent(e){let i=arguments.length>1&&void 0!==arguments[1]&&arguments[1],l=arguments.length>2?arguments[2]:void 0;var o,a,d,r,v;const s=[];let E="";const u=null===(o=e.components)||void 0===o?void 0:o.find((e=>"BODY"===e.type));return u&&(null===(d=null===(a=u.example)||void 0===a?void 0:a.body_text)||void 0===d||d[0].forEach(((t,i)=>{var o,a;let d=null===(a=null===(o=e.mapping)||void 0===o?void 0:o.body)||void 0===a?void 0:a[i];const r=d,v=d&&/\(\(/.test(d),E=null==d?void 0:d.match(n.placeHolderNamePattern);(null==E?void 0:E[2])&&(d=null==E?void 0:E[2]),s.push({idx:i,variableVal:l?t:r,editable:!!v,editableDefaultValues:v?void 0:t,variableName:null!=d?d:""})})),E=e.htmlContentUrl?e.htmlContentUrl:(null===(r=u.text)||void 0===r?void 0:r.split(/\{\{[0-9]+\}\}/).length)?null===(v=u.text)||void 0===v?void 0:v.split(/\{\{[0-9]+\}\}/).map(((e,n)=>{if(null==s?void 0:s[n]){const l=s[n].variableName;return i?`${e}{{${l}}}`:`${e} <span> </span><span style="color: ${t.COLORS.content.brand}; text-decoration: underline;">{{${l}}}</span><span> </span>`}return e})).join(""):""),{bodyVariable:s,bodyText:E}}parseFooterComponent(e){var t;const n=null===(t=e.components)||void 0===t?void 0:t.find((e=>"FOOTER"===e.type));return null==n?void 0:n.text}parseButtonComponent(e){var t,i,o,a,d,r;const v={actionsType:l.ACTIONS_TYPES.NONE,quickReply:[],ctaBtn:{phoneNumber:void 0,websiteLinkBtn:void 0}},s=null===(t=e.components)||void 0===t?void 0:t.find((e=>"BUTTONS"===e.type));if(s&&(null===(i=null==s?void 0:s.buttons)||void 0===i?void 0:i.length)){const t="QUICK_REPLY"===(null===(o=null==s?void 0:s.buttons)||void 0===o?void 0:o[0].type)?l.ACTIONS_TYPES.QUICK_REPLY:l.ACTIONS_TYPES.CTA_BTN;if(v.actionsType=t,t===l.ACTIONS_TYPES.QUICK_REPLY){const e=null!==(d=null===(a=null==s?void 0:s.buttons)||void 0===a?void 0:a.map((e=>e)))&&void 0!==d?d:[];return v.quickReply=e,v}t===l.ACTIONS_TYPES.CTA_BTN&&(null===(r=null==s?void 0:s.buttons)||void 0===r||r.forEach((t=>{var i,l,o,a;if(t.phone_number&&(v.ctaBtn.phoneNumber={isChecked:!0,btnText:t.text,phoneNumber:t.phone_number}),t.url){const d=null!==(o=null===(l=null===(i=null==e?void 0:e.mapping)||void 0===i?void 0:i.buttons)||void 0===l?void 0:l[0])&&void 0!==o?o:void 0;let r=!1;d&&n.editableVarPattern.test(d)&&(r=!0),v.ctaBtn.websiteLinkBtn={isChecked:!0,btnText:t.text,linkOpens:r?null===(a=t.example)||void 0===a?void 0:a[0]:t.url,placeholder:r?void 0:d}}})))}return v}parseUITemplateFromDBFormat(t){var n;return e.__awaiter(this,void 0,void 0,(function*(){const{dbFormattedTemplate:e,isDuplicate:i,isV2:l=!1,showSampleValues:o}=t,{headerType:a,headerAssetLink:d,headerAssetName:r,headerText:v,headerVariables:s}=yield this.parseDataFromHeaderComponent(e),{bodyText:E,bodyVariable:u}=yield this.parseBodyComponent(e,l,o),{actionsType:T,quickReply:p,ctaBtn:c}=yield this.parseButtonComponent(e),_={quickReply:p,ctaBtn:c,meta:{name:i?`${e.label} Copy`:e.label,category:null===(n=e.category)||void 0===n?void 0:n.toUpperCase(),subCategory:e.templateCategory,language:e.language,templateId:e.templateId},error:{header:void 0,body:void 0,footer:void 0,quickReply:void 0,meta:void 0,ctaBtn:void 0},actionsType:T,footerText:this.parseFooterComponent(e),bodyVariables:u,bodyText:E,headerType:a,headerAssetLink:d,headerAssetName:r,headerText:v,headerVariables:s,alreadyAsADraft:e.isDraft,mode:"edit",initialLoading:!1},{errors:m}=this.validateState(_);return _.error=m,_}))}};
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../../../_virtual/_tslib.js"),t=require("../../../constants/Theme.js"),n=require("../constants/regexPatterns.js"),i=require("../constants/TemplateConstants.js"),l=require("../models/TemplateMeta.js"),o=require("../utils/TemplateHelperUtils.js");exports.TemplateCreatorHelper=class{parseDataFromHeaderComponent(e,t){var n,i,o,a,d,r,s,v,E,u;const T={headerType:l.HEADER_TYPES.NONE,headerVariables:[]},p=null===(n=e.components)||void 0===n?void 0:n.find((e=>"HEADER"===e.type));if(p){T.headerType=p.format,T.headerText=p.text,T.headerAssetLink=null===(o=null===(i=p.example)||void 0===i?void 0:i.header_handle)||void 0===o?void 0:o[0];const n=null===(d=null===(a=p.example)||void 0===a?void 0:a.header_text)||void 0===d?void 0:d[0],l=null===(s=null===(r=e.mapping)||void 0===r?void 0:r.header)||void 0===s?void 0:s[0],c=l;if(n&&l){const e=null==l?void 0:l.replace("[[","").replace("]]","").replace("{{","").replace("}}","").replace("((","").replace("))",""),i=/\(\(/.test(l),o={idx:0,variableVal:t?n:c,editable:i,editableDefaultValues:i?void 0:n,variableName:e};T.headerVariables=[o],(null===(E=null===(v=p.example)||void 0===v?void 0:v.header_text)||void 0===E?void 0:E.length)&&(T.headerText=null===(u=T.headerText)||void 0===u?void 0:u.replace("{{1}}",`{{${e}}}`))}}return T}validateState(e){var t,a,d,r,s,v,E,u,T,p,c,_,m,R,h,b,I,L,B,N,y;const A=/\p{Extended_Pictographic}/u;let D="valid";const C={meta:{},ctaBtn:{phoneNumber:{btnText:"",link:""},websiteLink:{btnText:"",link:""}},quickReply:[null,null,null]},O=new o.TemplateHelperUtils;let x=!1;const P=e=>{var t;null===(t=document.getElementById(e))||void 0===t||t.scrollIntoView({behavior:"smooth",block:"nearest"})};if((null===(t=e.meta)||void 0===t?void 0:t.name)?e.meta.name.trim().length>i.NAME_LEN_LIMIT?(C.meta.name=i.NAME_LEN_ERROR,D="invalid"):n.specialCharPattern.test(e.meta.name.trim())&&(C.meta.name=i.NO_SPECIAL_CHAR,D="invalid"):(C.meta.name=i.REQUIRED_FIELD,D="invalid"),C.meta.name&&!x&&(P(i.CREATE_TEMPLATE_DOM_IDS.name),x=!0),e.headerType===l.HEADER_TYPES.TEXT){const t=null!==(d=null===(a=e.headerText)||void 0===a?void 0:a.trim())&&void 0!==d?d:"";if(t)if(t.length>i.HEADER_TEXT_LEN_LIMIT)C.header=i.HEADER_LEN_ERROR,D="invalid";else{const e=O.getTemplateVariablesFromState(t);e&&e.length>1&&(C.header=i.ONE_VAR_ALLOWED,D="invalid")}else C.header=i.REQUIRED_FIELD,D="invalid"}else e.headerType===l.HEADER_TYPES.DOCUMENT||e.headerType===l.HEADER_TYPES.IMAGE||(e.headerType,l.HEADER_TYPES.VIDEO);if(e.headerType!==l.HEADER_TYPES.DOCUMENT&&e.headerType!==l.HEADER_TYPES.IMAGE&&e.headerType!==l.HEADER_TYPES.VIDEO||e.headerAssetLink||(C.header=i.HEADER_ASSET_LINK_ERROR,D="invalid"),C.header&&!x&&(P(i.CREATE_TEMPLATE_DOM_IDS.header),x=!0),e.bodyText?e.bodyTextRaw&&(null===(r=e.bodyTextRaw)||void 0===r?void 0:r.trim().length)>i.BODY_TEXT_LEN_LIMIT&&(C.body=i.BODY_LEN_ERROR,D="invalid"):(C.body=i.REQUIRED_FIELD,D="invalid"),C.body&&!x&&(P(i.CREATE_TEMPLATE_DOM_IDS.body),x=!0),e.footerText&&e.footerText.length>i.HEADER_TEXT_LEN_LIMIT&&(C.footer=i.HEADER_LEN_ERROR,D="invalid"),(null==C?void 0:C.footer)&&!x&&(P(i.CREATE_TEMPLATE_DOM_IDS.footer),x=!0),e.actionsType===l.ACTIONS_TYPES.CTA_BTN){if(null===(v=null===(s=e.ctaBtn)||void 0===s?void 0:s.phoneNumber)||void 0===v?void 0:v.isChecked){const t=null===(E=e.ctaBtn.phoneNumber.btnText)||void 0===E?void 0:E.trim(),n=e.ctaBtn.phoneNumber.phoneNumber;C.ctaBtn&&!t?(C.ctaBtn.phoneNumber.btnText=i.REQUIRED_FIELD,D="invalid"):C.ctaBtn&&t&&t.length>i.QUICK_REPLY_BTN_TEXT_LIMIT?(C.ctaBtn.phoneNumber.btnText=i.QUICK_REPLY_LEN_ERROR,D="invalid"):C.ctaBtn&&t&&A.test(t)&&(C.ctaBtn.phoneNumber.btnText=i.BUTTON_EMOJI_ERROR,D="invalid"),C.ctaBtn&&!n?(C.ctaBtn.phoneNumber.link=i.REQUIRED_FIELD,D="invalid"):C.ctaBtn&&n&&n.length<10&&(C.ctaBtn.phoneNumber.link=i.VALID_PHONE_NUMBER,D="invalid")}if(null===(T=null===(u=e.ctaBtn)||void 0===u?void 0:u.websiteLinkBtn)||void 0===T?void 0:T.isChecked){const t=null===(p=e.ctaBtn.websiteLinkBtn.btnText)||void 0===p?void 0:p.trim(),n=null===(c=e.ctaBtn.websiteLinkBtn.linkOpens)||void 0===c?void 0:c.trim(),l=null===(_=e.ctaBtn.websiteLinkBtn.placeholder)||void 0===_?void 0:_.trim();C.ctaBtn&&!t?(C.ctaBtn.websiteLink.btnText=i.REQUIRED_FIELD,D="invalid"):C.ctaBtn&&t&&t.length>i.QUICK_REPLY_BTN_TEXT_LIMIT?(C.ctaBtn.websiteLink.btnText=i.QUICK_REPLY_LEN_ERROR,D="invalid"):C.ctaBtn&&t&&A.test(t)&&(C.ctaBtn.websiteLink.btnText=i.BUTTON_EMOJI_ERROR,D="invalid"),!C.ctaBtn||n||l||(C.ctaBtn.websiteLink.link=i.REQUIRED_FIELD,D="invalid")}}else if(e.actionsType===l.ACTIONS_TYPES.QUICK_REPLY){const t=["","",""];e.quickReply.forEach(((n,l)=>{const o=n.text.trim();if(o)if(o.length>i.QUICK_REPLY_NAME_LEN_LIMIT)t[l]=i.QUICK_REPLY_LEN_ERROR,D="invalid";else if(A.test(o))t[l]=i.BUTTON_EMOJI_ERROR,D="invalid";else{const n=[...e.quickReply];n.splice(l,1);n.find((e=>e.text===o))&&(t[l]=i.QUICK_REPLY_NAME_ERROR,D="invalid")}else t[l]=i.REQUIRED_FIELD,D="invalid"})),C.quickReply=t}if(e.actionsType===l.ACTIONS_TYPES.CTA_BTN||e.actionsType===l.ACTIONS_TYPES.QUICK_REPLY){const e=null===(m=C.quickReply)||void 0===m?void 0:m.reduce(((e,t)=>e||!!t),!1);((null===(h=null===(R=null==C?void 0:C.ctaBtn)||void 0===R?void 0:R.websiteLink)||void 0===h?void 0:h.link)||(null===(I=null===(b=C.ctaBtn)||void 0===b?void 0:b.websiteLink)||void 0===I?void 0:I.btnText)||(null===(B=null===(L=C.ctaBtn)||void 0===L?void 0:L.phoneNumber)||void 0===B?void 0:B.link)||(null===(y=null===(N=C.ctaBtn)||void 0===N?void 0:N.phoneNumber)||void 0===y?void 0:y.btnText)||e)&&!x&&(P(i.CREATE_TEMPLATE_DOM_IDS.actionButtons),x=!0)}return{status:D,errors:C}}parseBodyComponent(e){let i=arguments.length>1&&void 0!==arguments[1]&&arguments[1],l=arguments.length>2?arguments[2]:void 0;var o,a,d,r,s;const v=[];let E="";const u=null===(o=e.components)||void 0===o?void 0:o.find((e=>"BODY"===e.type));return u&&(null===(d=null===(a=u.example)||void 0===a?void 0:a.body_text)||void 0===d||d[0].forEach(((t,i)=>{var o,a;let d=null===(a=null===(o=e.mapping)||void 0===o?void 0:o.body)||void 0===a?void 0:a[i];const r=d,s=d&&/\(\(/.test(d),E=null==d?void 0:d.match(n.placeHolderNamePattern);(null==E?void 0:E[2])&&(d=null==E?void 0:E[2]),v.push({idx:i,variableVal:l?t:r,editable:!!s,editableDefaultValues:s?void 0:t,variableName:null!=d?d:""})})),E=e.htmlContentUrl?e.htmlContentUrl:(null===(r=u.text)||void 0===r?void 0:r.split(/\{\{[0-9]+\}\}/).length)?null===(s=u.text)||void 0===s?void 0:s.split(/\{\{[0-9]+\}\}/).map(((e,n)=>{if(null==v?void 0:v[n]){const l=v[n].variableName;return i?`${e}{{${l}}}`:`${e} <span> </span><span style="color: ${t.COLORS.content.brand}; text-decoration: underline;">{{${l}}}</span><span> </span>`}return e})).join(""):""),{bodyVariable:v,bodyText:E}}parseFooterComponent(e){var t;const n=null===(t=e.components)||void 0===t?void 0:t.find((e=>"FOOTER"===e.type));return null==n?void 0:n.text}parseButtonComponent(e){var t,i,o,a,d,r;const s={actionsType:l.ACTIONS_TYPES.NONE,quickReply:[],ctaBtn:{phoneNumber:void 0,websiteLinkBtn:void 0},allButtons:[]},v=null===(t=e.components)||void 0===t?void 0:t.find((e=>"BUTTONS"===e.type));if(v&&(null===(i=null==v?void 0:v.buttons)||void 0===i?void 0:i.length)){const t="QUICK_REPLY"===(null===(o=null==v?void 0:v.buttons)||void 0===o?void 0:o[0].type)?l.ACTIONS_TYPES.QUICK_REPLY:l.ACTIONS_TYPES.CTA_BTN;if(s.actionsType=t,t===l.ACTIONS_TYPES.QUICK_REPLY){const e=null!==(d=null===(a=null==v?void 0:v.buttons)||void 0===a?void 0:a.map((e=>e)))&&void 0!==d?d:[];return s.quickReply=e,s}t===l.ACTIONS_TYPES.CTA_BTN&&(null===(r=null==v?void 0:v.buttons)||void 0===r||r.forEach((t=>{var i,l,o,a;if(t.phone_number&&(s.ctaBtn.phoneNumber={isChecked:!0,btnText:t.text,phoneNumber:t.phone_number}),t.url){const d=null!==(o=null===(l=null===(i=null==e?void 0:e.mapping)||void 0===i?void 0:i.buttons)||void 0===l?void 0:l[0])&&void 0!==o?o:void 0;let r=!1;d&&n.editableVarPattern.test(d)&&(r=!0),s.ctaBtn.websiteLinkBtn={isChecked:!0,btnText:t.text,linkOpens:r?null===(a=t.example)||void 0===a?void 0:a[0]:t.url,placeholder:r?void 0:d}}}))),s.allButtons=v.buttons}return s}parseUITemplateFromDBFormat(t){var n;return e.__awaiter(this,void 0,void 0,(function*(){const{dbFormattedTemplate:e,isDuplicate:i,isV2:l=!1,showSampleValues:o}=t,{headerType:a,headerAssetLink:d,headerAssetName:r,headerText:s,headerVariables:v}=yield this.parseDataFromHeaderComponent(e),{bodyText:E,bodyVariable:u}=yield this.parseBodyComponent(e,l,o),{actionsType:T,quickReply:p,ctaBtn:c,allButtons:_}=yield this.parseButtonComponent(e),m={quickReply:p,ctaBtn:c,allButtons:_,meta:{name:i?`${e.label} Copy`:e.label,category:null===(n=e.category)||void 0===n?void 0:n.toUpperCase(),subCategory:e.templateCategory,language:e.language,templateId:e.templateId},error:{header:void 0,body:void 0,footer:void 0,quickReply:void 0,meta:void 0,ctaBtn:void 0},actionsType:T,footerText:this.parseFooterComponent(e),bodyVariables:u,bodyText:E,headerType:a,headerAssetLink:d,headerAssetName:r,headerText:s,headerVariables:v,alreadyAsADraft:e.isDraft,mode:"edit",initialLoading:!1},{errors:R}=this.validateState(m);return m.error=R,m}))}};
@@ -1,7 +1,7 @@
1
1
  import { SingleOption } from "../../dropdown/type";
2
2
  export type CUSTOM_VARIABLE = {
3
3
  variableName: string;
4
- type: 'string' | 'link' | 'image';
4
+ type: 'string' | 'link' | 'image' | 'button';
5
5
  isEditableVariable: boolean;
6
6
  updatedValue: string;
7
7
  index?: number;
@@ -15,7 +15,7 @@ export type WhatsAppTemplate = {
15
15
  format?: HEADER_TYPES;
16
16
  text?: string;
17
17
  buttons?: {
18
- type: 'QUICK_REPLY' | 'URL' | 'PHONE_NUMBER';
18
+ type: 'QUICK_REPLY' | 'URL' | 'PHONE_NUMBER' | 'COPY_CODE';
19
19
  text?: string;
20
20
  url?: string;
21
21
  example?: string[];
@@ -46,6 +46,7 @@ export type WhatsAppTemplate = {
46
46
  updatedAt: number;
47
47
  isDraft?: boolean;
48
48
  };
49
+ export type WhatsappTemplateButtonTypes = 'QUICK_REPLY' | 'URL' | 'PHONE_NUMBER' | 'COPY_CODE';
49
50
  export type CreateTemplateType = {
50
51
  /** Data */
51
52
  headerType: HEADER_TYPES;
@@ -72,6 +73,7 @@ export type CreateTemplateType = {
72
73
  placeholder?: string;
73
74
  };
74
75
  };
76
+ allButtons: WhatsappPreviewButtonType[];
75
77
  meta: {
76
78
  name: string;
77
79
  category?: string;
@@ -172,6 +174,14 @@ export type WhatsappLikePreviewTypes = {
172
174
  children?: React.ReactNode;
173
175
  bodyVariableList?: variableType[];
174
176
  headerVariableList?: variableType[];
177
+ buttons?: WhatsappPreviewButtonType[];
178
+ };
179
+ export type WhatsappPreviewButtonType = {
180
+ type: WhatsappTemplateButtonTypes;
181
+ text: string;
182
+ placeholder?: string;
183
+ flowId: string;
184
+ flowName: string;
175
185
  };
176
186
  export type WhatsappMeta = {
177
187
  containerStyle?: React.CSSProperties | undefined;
@@ -224,7 +234,8 @@ export type TEMPLATE_BUTTON = {
224
234
  export declare enum BUTTON_TYPE {
225
235
  QUICK_REPLY = "QUICK_REPLY",
226
236
  URL = "URL",
227
- PHONE_NUMBER = "PHONE_NUMBER"
237
+ PHONE_NUMBER = "PHONE_NUMBER",
238
+ COPY_CODE = "COPY_CODE"
228
239
  }
229
240
  export declare enum POD {
230
241
  CHATBOT = "CHATBOT",
@@ -1 +1 @@
1
- "use strict";var T,N;Object.defineProperty(exports,"__esModule",{value:!0}),exports.BUTTON_TYPE=void 0,(T=exports.BUTTON_TYPE||(exports.BUTTON_TYPE={})).QUICK_REPLY="QUICK_REPLY",T.URL="URL",T.PHONE_NUMBER="PHONE_NUMBER",exports.POD=void 0,(N=exports.POD||(exports.POD={})).CHATBOT="CHATBOT",N.GROWTH="GROWTH",N.CAMPAIGN="CAMPAIGN",N.CRM="CRM",N.INTEGRATIONS="INTEGRATIONS",N.OPENAI="OPENAI",N.DM="DM",N.FRONTEND="FRONTEND";
1
+ "use strict";var O,T;Object.defineProperty(exports,"__esModule",{value:!0}),exports.BUTTON_TYPE=void 0,(O=exports.BUTTON_TYPE||(exports.BUTTON_TYPE={})).QUICK_REPLY="QUICK_REPLY",O.URL="URL",O.PHONE_NUMBER="PHONE_NUMBER",O.COPY_CODE="COPY_CODE",exports.POD=void 0,(T=exports.POD||(exports.POD={})).CHATBOT="CHATBOT",T.GROWTH="GROWTH",T.CAMPAIGN="CAMPAIGN",T.CRM="CRM",T.INTEGRATIONS="INTEGRATIONS",T.OPENAI="OPENAI",T.DM="DM",T.FRONTEND="FRONTEND";
@@ -1 +1 @@
1
- import{jsxs as t,jsx as o}from"react/jsx-runtime";import{useState as e,useEffect as n}from"react";import{POD as i}from"../../template-preview/models/WhatsAppTemplate.js";import{useTemplateModalContext as l}from"../context/templateModalContext.js";import{getAllDataFromTemplateComponent as a}from"../utils/getDataFromTemplateComponent.js";import{BackTrackComponent as s}from"./BackTrackComponent.js";import{DiscountCodeComponent as d}from"./DiscountCodeComponent.js";import{EditTemplateMediaContainer as r}from"./EditMediaV2.style.js";import p from"./EditWhatsAppTemplateMediaV2.js";import{Container as c}from"./VariableConnectorsPanel.js";import u from"./VariableConnectorWhatsApp.js";import m from"./VariableEditorHeader.js";import v from"./WhatsAppTemplateCardButtonV2.js";const b=b=>{let{template:g,onTemplateChange:h,whatsappSpecificPickerMeta:f,showVariableModal:T,variableList:j,variableListForImage:C,discountCode:O,setDiscountCode:x}=b;var E,k,y,V,w,B,L,I,A,M,R,U,H,D,S,N;const{originalVariableList:P,pod:Q,extras:W}=l(),{descriptionComponents:F,urlBtns:_,qrbBtns:K,imageComponent:Y,bodyVariables:$,headerVariables:q}=a(g),[X,z]=e(!1);function G(t,o){var e,n,i,l,a;const s=Object.assign({},g),d=null==s?void 0:s.components.findIndex((t=>"BUTTONS"===t.type));if(void 0!==d&&d>-1){const a=null===(e=null==s?void 0:s.components[d].buttons)||void 0===e?void 0:e.findIndex((t=>"URL"===t.type));if(void 0!==a&&a>-1){const e="custom"===o&&"string"==typeof t,r=[...null!==(l=null===(i=null===(n=s.components)||void 0===n?void 0:n[d])||void 0===i?void 0:i.buttons)&&void 0!==l?l:[]];r[a]=Object.assign(Object.assign({},r[a]),{url:"https://d.bik.ai/{{1}}",example:[e?t:"string"!=typeof t?t.defaultValue:""]});const p=Object.assign(Object.assign({},s.components[d]),{buttons:r}),c=Object.assign(Object.assign({},s.mapping),{buttons:e?["((customBtnPlaceholder))"]:"string"!=typeof t?[t.placeHolder]:void 0});s.mapping=c;const u=[...s.components];u[d]=p,s.components=u}}if("string"!=typeof t){"checkout.checkoutUrl"===(null===(a=t.placeHolder)||void 0===a?void 0:a.slice(2,-2))?z(!0):(z(!1),null==x||x(""))}null==h||h(s)}function J(t,o,e){var n;const i=Object.assign({},g),l=null==i?void 0:i.components.findIndex((t=>"BUTTONS"===t.type));if(void 0!==l&&l>-1){const o=null===(n=null==i?void 0:i.components[l].buttons)||void 0===n?void 0:n.filter((t=>"QUICK_REPLY"===t.type));o&&(o[e]=Object.assign(Object.assign({},o[e]),{flowId:t.flowId,flowName:t.flowName}));const a=Object.assign(Object.assign({},i.components[l]),{buttons:o}),s=[...i.components];s[l]=a,i.components=s}null==h||h(i)}return n((()=>{var t;const o=null===(t=g.mapping.buttons)||void 0===t?void 0:t[0];"checkout.checkoutUrl"===(null==o?void 0:o.slice(2,-2))?z(!0):(z(!1),null==x||x(""))}),[g]),t(c,Object.assign({style:{flexDirection:"column",maxHeight:460}},{children:[!!Y&&o(r,{children:o(p,{whatsappSpecificPickerMeta:f,mediaComponent:Y,updateTemplateImageUrl:function(t,o){var e;let n=Object.assign({},g);const i=null===(e=null==n?void 0:n.components)||void 0===e?void 0:e.findIndex((t=>{if("HEADER"===t.type&&"NONE"!==t.format&&"TEXT"!==t.format)return!0}));if(void 0!==i&&i>-1&&(null==n?void 0:n.components[i])){const e=Object.assign(Object.assign({},n.components[i]),{format:o,example:{header_handle:[t]}}),l=[...n.components];l[i]=e,n=Object.assign(Object.assign({},n),{components:l})}n.mapping&&(n.mapping=Object.assign(Object.assign({},n.mapping),{header:void 0})),null==h||h(Object.assign({},n))},template:g,variableListForImage:C})}),($.length>0||q.length>0)&&o(m,{containerStyle:{paddingTop:Y?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==F?void 0:F.map(((t,e)=>o(u,{originalVariableList:P,type:t.type,descriptionComponent:t.component,variableMapping:"HEADER"===t.type?g.mapping.header:g.mapping.body,showVariableModal:T,variableList:j},e))),(null===(k=null===(E=_[0])||void 0===E?void 0:E.component)||void 0===k?void 0:k.buttons)&&(null===(w=null===(V=null===(y=_[0])||void 0===y?void 0:y.component)||void 0===V?void 0:V.buttons)||void 0===w?void 0:w.length)>0&&o(m,{headerText:"Edit buttons",subText:"Edit the link connected to the CTA button"}),null===(B=null==P?void 0:P.buttons)||void 0===B?void 0:B.map(((t,e)=>{if("URL"===t.type)return o(v,{CTAoptions:null==f?void 0:f.CTAoptions,button:t,originalVariableList:P,updateSelectedURLTemplateBtn:G},`${e}`)})),(null===(I=null===(L=K[0])||void 0===L?void 0:L.component)||void 0===I?void 0:I.buttons)&&(null===(R=null===(M=null===(A=K[0])||void 0===A?void 0:A.component)||void 0===M?void 0:M.buttons)||void 0===R?void 0:R.length)>0&&(Q!==i.CHATBOT?o(m,{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(s,{backTrackMessage:null===(U=null==W?void 0:W.backTrackExtra)||void 0===U?void 0:U[0],setBackTrackMessage:null===(H=null==W?void 0:W.backTrackExtra)||void 0===H?void 0:H[1]})),null===(D=null==P?void 0:P.buttons)||void 0===D?void 0:D.map(((t,e)=>{if("QUICK_REPLY"===t.type)return o(v,{QRBoptions:null==f?void 0:f.QRBoptions,button:t,originalVariableList:P,updateSelectedQRBTemplateBtn:J},`${e}`)})),Q===i.CHATBOT&&X&&o(d,{discountCode:null===(S=null==W?void 0:W.discountCodeExtra)||void 0===S?void 0:S[0],setDiscountCode:null===(N=null==W?void 0:W.discountCodeExtra)||void 0===N?void 0:N[1],variableList:j})]}))};export{b as default};
1
+ import{jsxs as t,jsx as o}from"react/jsx-runtime";import{useState as e,useEffect as i,useCallback as n,useMemo as a}from"react";import{POD as l}from"../../template-preview/models/WhatsAppTemplate.js";import{useTemplateModalContext as s}from"../context/templateModalContext.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 h from"./WhatsAppTemplateCardButtonV2.js";const f=f=>{let{template:T,onTemplateChange:j,whatsappSpecificPickerMeta:x,showVariableModal:C,variableList:O,variableListForImage:y,discountCode:E,setDiscountCode:V}=f;var k,I,L,w,B,A,M,U,N,R,D,H,S,P,Q,W,_;const{originalVariableList:F,pod:Y,extras:K}=s(),{descriptionComponents:$,urlBtns:q,qrbBtns:X,imageComponent:z,bodyVariables:G,headerVariables:J}=d(T),[Z,tt]=e(!1);function ot(t,o){var e,i,n,a,l;const s=Object.assign({},T),d=null==s?void 0:s.components.findIndex((t=>"BUTTONS"===t.type));if(void 0!==d&&d>-1){const l=null===(e=null==s?void 0:s.components[d].buttons)||void 0===e?void 0:e.findIndex((t=>"URL"===t.type));if(void 0!==l&&l>-1){const e="custom"===o&&"string"==typeof t,r=[...null!==(a=null===(n=null===(i=s.components)||void 0===i?void 0:i[d])||void 0===n?void 0:n.buttons)&&void 0!==a?a:[]];r[l]=Object.assign(Object.assign({},r[l]),{url:"https://d.bik.ai/{{1}}",example:[e?t:"string"!=typeof t?t.defaultValue:""]});const p=Object.assign(Object.assign({},s.components[d]),{buttons:r}),c=Object.assign(Object.assign({},s.mapping),{buttons:e?["((customBtnPlaceholder))"]:"string"!=typeof t?[t.placeHolder]:void 0});s.mapping=c;const u=[...s.components];u[d]=p,s.components=u}}if("string"!=typeof t){"checkout.checkoutUrl"===(null===(l=t.placeHolder)||void 0===l?void 0:l.slice(2,-2))?tt(!0):(tt(!1),null==V||V(""))}null==j||j(s)}function et(t,o,e){var i;const n=Object.assign({},T),a=null==n?void 0:n.components.findIndex((t=>"BUTTONS"===t.type));if(void 0!==a&&a>-1){const o=null===(i=null==n?void 0:n.components[a].buttons)||void 0===i?void 0:i.filter((t=>"QUICK_REPLY"===t.type));o&&(o[e]=Object.assign(Object.assign({},o[e]),{flowId:t.flowId,flowName:t.flowName}));const l=Object.assign(Object.assign({},n.components[a]),{buttons:o}),s=[...n.components];s[a]=l,n.components=s}null==j||j(n)}i((()=>{var t;const o=null===(t=T.mapping.buttons)||void 0===t?void 0:t[0];"checkout.checkoutUrl"===(null==o?void 0:o.slice(2,-2))?tt(!0):(tt(!1),null==V||V(""))}),[T]);const it=n((()=>O?[...O,{description:"",displayName:"Custom variables",orderId:1,variables:{"Custom text":{description:void 0,displayName:"Custom text",actualValue:"{{custom.text}}",variableType:"any",isAvailable:!0}}}].sort(((t,o)=>t.orderId-o.orderId)):O),[O]),nt=a((()=>it()),[it]);return t(v,Object.assign({style:{flexDirection:"column",maxHeight:460}},{children:[!!z&&o(c,{children:o(u,{whatsappSpecificPickerMeta:x,mediaComponent:z,updateTemplateImageUrl:function(t,o){var e;let i=Object.assign({},T);const n=null===(e=null==i?void 0:i.components)||void 0===e?void 0:e.findIndex((t=>{if("HEADER"===t.type&&"NONE"!==t.format&&"TEXT"!==t.format)return!0}));if(void 0!==n&&n>-1&&(null==i?void 0:i.components[n])){const e=Object.assign(Object.assign({},i.components[n]),{format:o,example:{header_handle:[t]}}),a=[...i.components];a[n]=e,i=Object.assign(Object.assign({},i),{components:a})}i.mapping&&(i.mapping=Object.assign(Object.assign({},i.mapping),{header:void 0})),null==j||j(Object.assign({},i))},template:T,variableListForImage:y})}),(G.length>0||J.length>0)&&o(g,{containerStyle:{paddingTop:z?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==$?void 0:$.map(((t,e)=>o(b,{originalVariableList:F,type:t.type,descriptionComponent:t.component,variableMapping:"HEADER"===t.type?T.mapping.header:T.mapping.body,showVariableModal:C,variableList:O},e))),(null===(I=null===(k=q[0])||void 0===k?void 0:k.component)||void 0===I?void 0:I.buttons)&&(null===(B=null===(w=null===(L=q[0])||void 0===L?void 0:L.component)||void 0===w?void 0:w.buttons)||void 0===B?void 0:B.length)>0&&o(g,{headerText:"Edit buttons",subText:"Edit the link connected to the CTA button"}),null===(A=null==F?void 0:F.buttons)||void 0===A?void 0:A.map(((t,e)=>{if("URL"===t.type)return o(h,{variableListIndex:e,CTAoptions:null==x?void 0:x.CTAoptions,button:t,originalVariableList:F,updateSelectedURLTemplateBtn:ot,variableList:O},`${e}`)})),(null===(U=null===(M=X[0])||void 0===M?void 0:M.component)||void 0===U?void 0:U.buttons)&&(null===(D=null===(R=null===(N=X[0])||void 0===N?void 0:N.component)||void 0===R?void 0:R.buttons)||void 0===D?void 0:D.length)>0&&(Y!==l.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===(H=null==K?void 0:K.backTrackExtra)||void 0===H?void 0:H[0],setBackTrackMessage:null===(S=null==K?void 0:K.backTrackExtra)||void 0===S?void 0:S[1]})),null===(P=null==F?void 0:F.buttons)||void 0===P?void 0:P.map(((t,e)=>{if("QUICK_REPLY"===t.type)return o(h,{variableListIndex:e,QRBoptions:null==x?void 0:x.QRBoptions,button:t,originalVariableList:F,updateSelectedQRBTemplateBtn:et},`${e}`)})),Y===l.CHATBOT&&Z&&o(p,{discountCode:null===(Q=null==K?void 0:K.discountCodeExtra)||void 0===Q?void 0:Q[0],setDiscountCode:null===(W=null==K?void 0:K.discountCodeExtra)||void 0===W?void 0:W[1],variableList:O}),null===(_=null==F?void 0:F.buttons)||void 0===_?void 0:_.map(((t,e)=>{var i,n,a;if("COPY_CODE"===t.type)return o(m,{index:e,variable:{variableName:null!==(i=t.text)&&void 0!==i?i:"",updatedValue:null!==(n=t.buttonVariable)&&void 0!==n?n:"",type:"string",isEditableVariable:!0,index:null!==(a=t.index)&&void 0!==a?a:0},showVariableModal:!0,variableList:nt,componentType:"BUTTONS"},e)}))]}))};export{f as default};
@@ -1,12 +1,12 @@
1
- import{jsx as e,jsxs as t}from"react/jsx-runtime";import i from"react";import o from"styled-components";import{TemplatePreview as a}from"../../template-preview/TemplatePreview.js";import"../../template-preview/WhatsApp/WhatsAppLikePreview.js";import"../../template-preview/WhatsApp/WhatsAppLikePreviewV2.js";import"../../../constants/Theme.js";import"../../template-preview/models/TemplateMeta.js";import{POD as p}from"../../template-preview/models/WhatsAppTemplate.js";import{useTemplateModalContext as r}from"../context/templateModalContext.js";import{getPreviewWidth as s}from"../utils/getPreviewDimension.js";const l=o.div`
1
+ import{jsx as e,jsxs as t}from"react/jsx-runtime";import i from"react";import a from"styled-components";import{TemplatePreview as o}from"../../template-preview/TemplatePreview.js";import"../../template-preview/WhatsApp/WhatsAppLikePreview.js";import"../../template-preview/WhatsApp/WhatsAppLikePreviewV2.js";import"../../../constants/Theme.js";import"../../template-preview/models/TemplateMeta.js";import{POD as p}from"../../template-preview/models/WhatsAppTemplate.js";import{CHANNEL_TYPE as r}from"../../template-preview/models/Channels.js";import{useTemplateModalContext as l}from"../context/templateModalContext.js";const s=a.div`
2
2
  position: relative;
3
3
  height: 100%;
4
4
  border-radius: 31px;
5
- width: ${e=>s(e.channel)}px;
5
+ width: ${e=>e.channel===r.WHATSAPP?"236px":"300px"};
6
6
  background-color: white;
7
7
  margin: auto;
8
8
  overflow-y: auto;
9
- `,m=o.div`
9
+ `,m=a.div`
10
10
  position: absolute;
11
11
  flex: 1;
12
12
  background-color: white;
@@ -17,4 +17,4 @@ import{jsx as e,jsxs as t}from"react/jsx-runtime";import i from"react";import o
17
17
  height: calc(100% - 17px);
18
18
  border-radius: 16px;
19
19
  overflow-y: auto;
20
- `,n=i.forwardRef(((i,o)=>{let{display_content:n,channel:h,template:c,showSampleValues:d}=i;const{pod:w}=r();return e("div",{children:t(l,Object.assign({channel:h},{children:[e("img",{alt:"",src:"https://firebasestorage.googleapis.com/v0/b/staging-bikayi.appspot.com/o/bik%2FkNwEVoGlLpVjOsXoO1M8WgvWicP2%2F6f07b850-8b4b-4d58-96cc-8ba6df7b4e4a-Device___Frame.jpg?alt=media&token=253f1bfe-8481-4f54-bdef-3c0a73697d6a",style:{width:s(h),height:443}}),e(m,Object.assign({ref:o},{children:e(a,{showSampleValues:d,template:c,channel:h,smsSpecificMeta:{smsDisplayContent:n},whatsAppSpecificMeta:{showWhatsAppHeader:!0,whatsAppExtras:w!==p.CHATBOT,containerStyle:{border:"none",borderBottomRightRadius:0,borderBottomLeftRadius:0,minHeight:426,width:236}},size:"small",hideHeader:!0,emailSpecificMeta:{emailDisplayContent:n,hideViewButtonForEmail:!0,emailHtmlContainerId:"template_html_mobile",containerStyle:{height:"100%",width:"100%"},templateContainerStyles:{height:"100%"}}})}))]}))})}));n.displayName="MobilePreview";export{n as default};
20
+ `,n=i.forwardRef(((i,a)=>{let{display_content:n,channel:h,template:c,showSampleValues:d}=i;const{pod:w}=l();return e("div",{children:t(s,Object.assign({channel:h},{children:[e("img",{alt:"",src:"https://firebasestorage.googleapis.com/v0/b/staging-bikayi.appspot.com/o/bik%2FkNwEVoGlLpVjOsXoO1M8WgvWicP2%2F6f07b850-8b4b-4d58-96cc-8ba6df7b4e4a-Device___Frame.jpg?alt=media&token=253f1bfe-8481-4f54-bdef-3c0a73697d6a",style:{width:h===r.WHATSAPP?236:300,height:443}}),e(m,Object.assign({ref:a},{children:e(o,{showSampleValues:d,template:c,channel:h,smsSpecificMeta:{smsDisplayContent:n},whatsAppSpecificMeta:{showWhatsAppHeader:!0,whatsAppExtras:w!==p.CHATBOT,containerStyle:{border:"none",borderBottomRightRadius:0,borderBottomLeftRadius:0,minHeight:426,width:236}},size:"small",hideHeader:!0,emailSpecificMeta:{emailDisplayContent:n,hideViewButtonForEmail:!0,emailHtmlContainerId:"template_html_mobile",containerStyle:{height:"100%",width:"100%"},templateContainerStyles:{height:"100%"}}})}))]}))})}));n.displayName="MobilePreview";export{n as default};
@@ -1,7 +1,7 @@
1
1
  /// <reference types="react" />
2
2
  import { VariableListInterfaceV2 } from "../../add-variableV2/AddVariableV2";
3
3
  import { CHANNEL_TYPE } from "../../template-preview/models/Channels";
4
- import { CUSTOM_VARIABLE } from "../../template-preview/models/TemplateMeta";
4
+ import { ButtonPlaceHolderOptions, CUSTOM_VARIABLE } from "../../template-preview/models/TemplateMeta";
5
5
  export declare const Container: import("styled-components").StyledComponent<"div", any, {
6
6
  focused?: boolean | undefined;
7
7
  channel?: CHANNEL_TYPE | undefined;
@@ -15,6 +15,7 @@ export interface VariableConnectorProps {
15
15
  variableList?: VariableListInterfaceV2[];
16
16
  setShowDiscountCheckBox?: any;
17
17
  componentType?: 'HEADER' | 'BODY' | 'BUTTONS' | 'FOOTER';
18
+ CTAoptions?: ButtonPlaceHolderOptions[];
18
19
  }
19
20
  declare const VariableConnector: React.FC<VariableConnectorProps>;
20
21
  export default VariableConnector;
@@ -1,7 +1,7 @@
1
- import{jsxs as e,jsx as l}from"react/jsx-runtime";import t from"../../../assets/icons/edit.svg.js";import{useState as a,useEffect as i}from"react";import n from"styled-components";import{AddVariableV2SideModal as o}from"../../add-variableV2/AddVariableV2SideModal.js";import{Dropdown as s}from"../../dropdown/Dropdown.js";import{Input as u}from"../../input/Input.js";import{truncate as d}from"../../product-picker-v2/collectionScreen.js";import{placeHolderNamePattern as r}from"../../template-preview/constants/regexPatterns.js";import{CHANNEL_TYPE as c}from"../../template-preview/models/Channels.js";import{BodySecondary as p,BodyPrimary as m}from"../../TypographyStyle.js";import v from"../../../utils/StringUtils.js";import{COLORS as b}from"../../../constants/Theme.js";import{useTemplateModalContext as g}from"../context/templateModalContext.js";import{getVariableNameForEmailByIndex as h}from"../utils/getVariableNameEmail.js";const x=n.div`
1
+ import{jsxs as e,jsx as t}from"react/jsx-runtime";import l from"../../../assets/icons/edit.svg.js";import{useState as a,useEffect as i}from"react";import n from"styled-components";import{AddVariableV2SideModal as o}from"../../add-variableV2/AddVariableV2SideModal.js";import{Dropdown as s}from"../../dropdown/Dropdown.js";import{Input as u}from"../../input/Input.js";import{truncate as d}from"../../product-picker-v2/collectionScreen.js";import{placeHolderNamePattern as r}from"../../template-preview/constants/regexPatterns.js";import{CHANNEL_TYPE as c}from"../../template-preview/models/Channels.js";import{POD as p}from"../../template-preview/models/WhatsAppTemplate.js";import{BodySecondary as m,BodyPrimary as v}from"../../TypographyStyle.js";import b from"../../../utils/StringUtils.js";import{COLORS as g}from"../../../constants/Theme.js";import{useTemplateModalContext as h}from"../context/templateModalContext.js";import{getVariableNameForEmailByIndex as x}from"../utils/getVariableNameEmail.js";const j=n.div`
2
2
  /* surface/$color-background-warning-light */
3
3
 
4
- background: ${e=>e.focused&&e.channel===c.EMAIL?b.background.warning.light:"transparent"};
4
+ background: ${e=>e.focused&&e.channel===c.EMAIL?g.background.warning.light:"transparent"};
5
5
  border-radius: 4px;
6
6
  padding: 8px 10px;
7
- `,j={value:"custom_link",label:"Custom URL"},_={value:"custom_text",label:"Custom text"},y=n=>{let{onFocus:y,variable:f,index:O,showVariableModal:k,variableList:A,setShowDiscountCheckBox:V,componentType:E}=n;var T,P;const[S,w]=a(!1),[L,C]=a(""),[H,M]=a([]),[W,$]=a(),[B,D]=a(!1),[I,R]=a(!1),{device:N,channel:z,isError:U,originalVariableList:Y,template:Z,templateSelectionTriggered:G,setTemplate:q,setDisplayContent:F,setOriginalVariableList:J,globalNormalizedPlaceholders:K,enabledCustomText:Q}=g();function X(e,l){var t,a,i;const n=e;C(""),$(n),z===c.WHATSAPP?"custom_text"!==n.value&&"custom_link"!==n.value?(ee(null!==(t=n.value)&&void 0!==t?t:"","string"),null==le||le(null!==(a=f.index)&&void 0!==a?a:0,n.value,!0)):(null==le||le(null!==(i=f.index)&&void 0!==i?i:0,f.variableName,!0,"custom_text"),ee("","url"===n.bikPlaceholderType?"link":"string")):"custom_text"!==n.value&&"custom_link"!==n.value?ee(n.value,"url"===n.bikPlaceholderType?"link":"string"):(C(""),ee("",n.value))}function ee(e,l){var t,a,i;const n="custom_link"===l?"link":"custom_text"===l?"string":l;if(z!==c.WHATSAPP){const a=h(O+1),i=null===document||void 0===document?void 0:document.getElementById("mobile"===N?"template_html_mobile":"template_html_desktop"),o=z===c.EMAIL?null===(t=null==i?void 0:i.contentWindow)||void 0===t?void 0:t.document.getElementById(a):document.getElementById(a);o&&(o.textContent="custom_text"!==l&&"custom_link"!==l||e?e:f.variableName);const s=Y.map(((l,t)=>t===O?Object.assign(Object.assign({},l),{type:n,updatedValue:e}):l));null==J||J(s)}if(z===c.WHATSAPP){const l=Y;let t=l.body,o=l.header;"BODY"===E?t=null===(a=l.body)||void 0===a?void 0:a.map(((l,t)=>t===O?Object.assign(Object.assign({},l),{type:n,updatedValue:e}):l)):"HEADER"===E&&(o=null===(i=l.header)||void 0===i?void 0:i.map(((l,t)=>t===O?Object.assign(Object.assign({},l),{type:n,updatedValue:e}):l))),null==J||J((e=>Object.assign(Object.assign({},e),{header:o,body:t,buttons:l.buttons})))}}function le(e,l,t,a){var i,n,o;const s=Object.assign({},Z),u=null===(i=null==s?void 0:s.components)||void 0===i?void 0:i.map((t=>{var a,i,n,o,s,u,d,r;const c=Object.assign({},t);if("BODY"===t.type&&"BODY"===E){if(null===(i=null===(a=t.example)||void 0===a?void 0:a.body_text)||void 0===i?void 0:i[0]){const t=[...null!==(s=null===(o=null===(n=c.example)||void 0===n?void 0:n.body_text)||void 0===o?void 0:o[0])&&void 0!==s?s:[]];t[e]=l.replace("{{","").replace("}}","").replace("((","").replace("))","");const a=Object.assign(Object.assign({},c.example),{body_text:[t]});return Object.assign(Object.assign({},c),{example:a})}}else if("HEADER"===t.type&&"HEADER"===E&&(null===(u=t.example)||void 0===u?void 0:u.header_text)){const t=[...null!==(r=null===(d=c.example)||void 0===d?void 0:d.header_text)&&void 0!==r?r:[]];t[e]=l.replace("{{","").replace("}}","").replace("((","").replace("))","");const a=Object.assign(Object.assign({},c.example),{header_text:t});return Object.assign(Object.assign({},c),{example:a})}return t}));s.components=u,t&&("BODY"===E&&(null===(n=null==s?void 0:s.mapping)||void 0===n?void 0:n.body)?s.mapping=Object.assign(Object.assign({},s.mapping),{body:s.mapping.body.map(((t,i)=>e===i?"custom_text"===a?`((editableVariable${i+10}))`:l:t))}):"HEADER"===E&&(null===(o=null==s?void 0:s.mapping)||void 0===o?void 0:o.header)&&(s.mapping=Object.assign(Object.assign({},s.mapping),{header:s.mapping.header.map(((t,i)=>e===i?"custom_text"===a?`((editableVariable${i+20}))`:l:t))}))),null==q||q(Object.assign({},s))}return i((()=>{S&&(null==y||y())}),[S]),i((()=>{!function(){var e,l,t,a,i;const n="mobile"===N?"template_html_mobile":"template_html_desktop",o=document.getElementById(n),s=(null!==(a=null===(t=null===(l=null===(e=null==o?void 0:o.contentWindow)||void 0===e?void 0:e.document)||void 0===l?void 0:l.body)||void 0===t?void 0:t.innerHTML)&&void 0!==a?a:"")+(null===(i=null==o?void 0:o.contentWindow)||void 0===i?void 0:i.document.head.innerHTML);z===c.EMAIL&&(null==F||F(s))}()}),[G]),i((()=>{var e;const l=[];let t=[];if(z!==c.MESSAGE||Q){"link"===(null==f?void 0:f.type)?(l.push({label:"",options:[j,_]}),$(j)):(l.push({label:"",options:[j,_]}),$(_));const e=null!=K?K:[];M([...l,...e.map((e=>{var l,t;return Object.assign(Object.assign({},e),{label:v.toCapitilize(null===(t=null===(l=e.label)||void 0===l?void 0:l.replace(/([A-Z])/g," $1"))||void 0===t?void 0:t.toLowerCase())})}))]),t=[...l,...e]}else{const e=null!=K?K:[];M([{label:"",options:[_,j]},...e]),t=[{label:"",options:[_,j]},...e]}if((z===c.WHATSAPP||z===c.EMAIL||z===c.MESSAGE)&&f.updatedValue)if(r.test(f.updatedValue)&&z===c.WHATSAPP||f.updatedValue.startsWith("{{")&&z!==c.WHATSAPP){const e=function(e,l,t){var a;let i={label:"",value:""};const n=t===c.WHATSAPP?e.updatedValue.replace("[[","").replace("]]",""):e.updatedValue.replace("{{","").replace("}}","");k?i={label:e.updatedValue?e.updatedValue.replace("{{","").replace("}}","").trim().replace("."," "):"",value:null!==(a=e.updatedValue)&&void 0!==a?a:""}:l.map((e=>{e.options.map((e=>{var l;(null===(l=e.value)||void 0===l?void 0:l.replace("{{","").replace("}}","").trim())===n.trim()&&(i=e)}))}));return i}(f,t,z);e.value&&$(e)}else(null===(e=f.updatedValue)||void 0===e?void 0:e.startsWith("https"))?($(j),C(f.updatedValue.split("https://")[1])):($(_),C(f.updatedValue))}),[]),i((()=>{N&&W&&L&&setTimeout((()=>{ee("custom_link"===(null==W?void 0:W.value)&&L?L.includes("https")?L:`https://${L}`:L,W.value)}),100)}),[N]),i((()=>{!I&&W&&f.updatedValue&&setTimeout((()=>{ee("custom_link"===(null==W?void 0:W.value)&&L?L.includes("https")?f.updatedValue:`https://${f.updatedValue}`:f.updatedValue,W.value),R(!0)}),100)}),[W]),e(x,Object.assign({channel:z,focused:S,onMouseEnter:()=>w(!0),onMouseLeave:()=>w(!1)},{children:[l("div",Object.assign({style:{marginBottom:8}},{children:e(p,Object.assign({style:{color:U&&!W?b.content.negative:b.content.primary}},{children:[null===(T=f.variableName)||void 0===T?void 0:T.replace("{{","").replace("}}","")," ","link"===(null==f?void 0:f.type)?"link":"variable"]}))})),l("div",Object.assign({style:{marginBottom:12}},{children:k?e("div",Object.assign({style:{display:"flex",border:"#E0E0E0 1px solid",borderRadius:4,padding:10,justifyContent:(null==W?void 0:W.label)?"space-between":"flex-end"}},{children:[l(m,{children:d(null!==(P=null==W?void 0:W.label)&&void 0!==P?P:"",20,!0)}),l(t,{onClick:()=>{D(!B)},width:24,height:24,color:b.content.primary})]})):l(s,{options:H,isSearchable:!1,onSelect:X,defaultOptions:W?[Object.assign(Object.assign({},W),{selected:!0})]:[]})})),("custom_text"===(null==W?void 0:W.value)||"custom_link"===(null==W?void 0:W.value))&&l(u,{labelText:"custom_text"===(null==W?void 0:W.value)?"Custom text value":"custom_link"===(null==W?void 0:W.value)?"Custom URL value":"",id:`variable-value-${null==W?void 0:W.value}-${O}`,value:L,errorMessage:U?L&&0!==L.trim().length?"custom_link"!==W.value||/^https?:\/\/(?:www\.)?[-a-zA-Z0-9@:%._\+~#=]{1,256}\.[a-zA-Z0-9()]{1,6}\b(?:[-a-zA-Z0-9()@:%_\+.~#?&\/=]*)$/.test(`https://${L.trim()}`)&&0!==L.trim().length?"custom_link"!==W.value&&L.length>30?"Length cannot be more than 30":"":"Enter valid URL":"Required field":"",maxCharLimit:"custom_link"===(null==W?void 0:W.value)?void 0:30,prefixText:"custom_link"===(null==W?void 0:W.value)?"https://":"",placeholder:"link"===f.type||"custom_link"===W.value?"Enter custom URL here":"Enter custom text here",onChangeText:e=>{!function(e,l){var t;C(l);const a="custom_link"===(null==W?void 0:W.value)&&l?l.includes("https")?l:`https://${l}`:l;ee(a,e),z===c.WHATSAPP&&(null==le||le(null!==(t=f.index)&&void 0!==t?t:0,a))}(W.value,e)}}),B&&l(o,{zIndex:2e3,data:null!=A?A:[],showVariable:B,setShowVariable:D,placeholder:"Add a variable",customTrigger:e=>{null==V||V(!1),"{{custom.url}}"===e.actualValue?X({label:e.displayName,selected:!0,value:"custom_link"}):"{{custom.text}}"==e.actualValue?X({label:e.displayName,selected:!0,value:"custom_text"}):X({label:e.displayName.replace("{{","").replace("}}","").trim().replace("."," "),selected:!0,value:e.actualValue,bikPlaceholderType:"string"})}})]}))};export{x as Container,y as default};
7
+ `,O={value:"custom_link",label:"Custom URL"},_={value:"custom_text",label:"Custom text"},f=n=>{let{onFocus:f,variable:y,index:T,showVariableModal:k,variableList:A,setShowDiscountCheckBox:V,componentType:E,CTAoptions:S}=n;var P,w;const[C,B]=a(!1),[L,H]=a(""),[N,M]=a([]),[W,$]=a(),[D,I]=a(!1),[R,U]=a(!1),{device:z,channel:Y,isError:Z,originalVariableList:G,template:q,templateSelectionTriggered:F,setTemplate:J,setDisplayContent:K,setOriginalVariableList:Q,globalNormalizedPlaceholders:X,enabledCustomText:ee,pod:te}=h();function le(e,t){var l,a,i;const n=e;H(""),$(n),Y===c.WHATSAPP?"custom_text"!==n.value&&"custom_link"!==n.value?(ae(null!==(l=n.value)&&void 0!==l?l:"","string"),null==ie||ie(null!==(a=y.index)&&void 0!==a?a:0,n.value,!0)):(null==ie||ie(null!==(i=y.index)&&void 0!==i?i:0,y.variableName,!0,"custom_text"),ae("","url"===n.bikPlaceholderType?"link":"string")):"custom_text"!==n.value&&"custom_link"!==n.value?ae(n.value,"url"===n.bikPlaceholderType?"link":"string"):(H(""),ae("",n.value))}function ae(e,t){var l,a,i,n;const o="custom_link"===t?"link":"custom_text"===t?"string":t;if(Y!==c.WHATSAPP){const a=x(T+1),i=null===document||void 0===document?void 0:document.getElementById("mobile"===z?"template_html_mobile":"template_html_desktop"),n=Y===c.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:y.variableName);const s=G.map(((t,l)=>l===T?Object.assign(Object.assign({},t),{type:o,updatedValue:e}):t));null==Q||Q(s)}if(Y===c.WHATSAPP){const l=G;let s=l.body,u=l.header,d=l.buttons;"BODY"===E?s=null===(a=l.body)||void 0===a?void 0:a.map(((t,l)=>l===T?Object.assign(Object.assign({},t),{type:o,updatedValue:e}):t)):"HEADER"===E?u=null===(i=l.header)||void 0===i?void 0:i.map(((t,l)=>l===T?Object.assign(Object.assign({},t),{type:o,updatedValue:e}):t)):"BUTTONS"===E&&(d=null===(n=l.buttons)||void 0===n?void 0:n.map(((l,a)=>a===T?Object.assign(Object.assign({},l),{buttonVariable:"custom_link"===t?"((customPlaceholderName))":e,example:[e]}):l))),null==Q||Q((e=>Object.assign(Object.assign({},e),{header:u,body:s,buttons:d})))}}function ie(e,t,l,a){var i,n,o,s;const u=Object.assign({},q),d=null===(i=null==u?void 0:u.components)||void 0===i?void 0:i.map((l=>{var a,i,n,o,s,u,d,r,c,p;const m=Object.assign({},l);if("BODY"===l.type&&"BODY"===E){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=m.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({},m.example),{body_text:[l]});return Object.assign(Object.assign({},m),{example:a})}}else if("HEADER"===l.type&&"HEADER"===E){if(null===(u=l.example)||void 0===u?void 0:u.header_text){const l=[...null!==(r=null===(d=m.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({},m.example),{header_text:l});return Object.assign(Object.assign({},m),{example:a})}}else if("BUTTONS"===l.type&&"BUTTONS"===E&&(null===(p=null===(c=l.buttons)||void 0===c?void 0:c[e])||void 0===p?void 0:p.example)){const a=l.buttons.map(((l,a)=>a===e?Object.assign(Object.assign({},l),{example:[t]}):l));return Object.assign(Object.assign({},m),{buttons:a})}return l}));u.components=d,l&&("BODY"===E&&(null===(n=null==u?void 0:u.mapping)||void 0===n?void 0:n.body)?u.mapping=Object.assign(Object.assign({},u.mapping),{body:u.mapping.body.map(((l,i)=>e===i?"custom_text"===a?`((editableVariable${i+10}))`:t:l))}):"HEADER"===E&&(null===(o=null==u?void 0:u.mapping)||void 0===o?void 0:o.header)?u.mapping=Object.assign(Object.assign({},u.mapping),{header:u.mapping.header.map(((l,i)=>e===i?"custom_text"===a?`((editableVariable${i+20}))`:t:l))}):"BUTTONS"===E&&(null===(s=null==u?void 0:u.mapping)||void 0===s?void 0:s.buttons)&&(u.mapping=Object.assign(Object.assign({},u.mapping),{buttons:u.mapping.buttons.map(((l,i)=>i===e?"custom_link"===a?"((customPlaceholderName))":t:l))}))),null==J||J(Object.assign({},u))}return i((()=>{C&&(null==f||f())}),[C]),i((()=>{!function(){var e,t,l,a,i;const n="mobile"===z?"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);Y===c.EMAIL&&(null==K||K(s))}()}),[F]),i((()=>{var e;const t=[];let l=[];if(Y!==c.MESSAGE||ee){"link"===(null==y?void 0:y.type)?(t.push({label:"",options:[O,_]}),$(O)):(t.push({label:"",options:[O,_]}),$(_));const e=null!=X?X:[];M([...t,...e.map((e=>{var t,l;return Object.assign(Object.assign({},e),{label:b.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())})}))]),l=[...t,...e]}else{const e=null!=X?X:[];M([{label:"",options:[_,O]},...e]),l=[{label:"",options:[_,O]},...e]}if((Y===c.WHATSAPP||Y===c.EMAIL||Y===c.MESSAGE)&&y.updatedValue)if(r.test(y.updatedValue)&&Y===c.WHATSAPP||y.updatedValue.startsWith("{{")&&Y!==c.WHATSAPP){const e=function(e,t,l){var a;let i={label:"",value:""};const n=l===c.WHATSAPP?e.updatedValue.replace("[[","").replace("]]",""):e.updatedValue.replace("{{","").replace("}}","");if(k){let t=e.updatedValue;if(te===p.CHATBOT&&"BUTTONS"===E){const l=null==S?void 0:S.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}(y,l,Y);e.value&&$(e)}else(null===(e=y.updatedValue)||void 0===e?void 0:e.startsWith("https"))?($(O),H(y.updatedValue.split("https://")[1])):($(_),H(y.updatedValue))}),[]),i((()=>{z&&W&&L&&setTimeout((()=>{ae("custom_link"===(null==W?void 0:W.value)&&L?L.includes("https")?L:`https://${L}`:L,W.value)}),100)}),[z]),i((()=>{!R&&W&&y.updatedValue&&setTimeout((()=>{ae("custom_link"===(null==W?void 0:W.value)&&y.updatedValue?y.updatedValue.includes("https")?y.updatedValue:`https://${y.updatedValue}`:y.updatedValue,W.value),U(!0)}),100)}),[W]),e(j,Object.assign({channel:Y,focused:C,onMouseEnter:()=>B(!0),onMouseLeave:()=>B(!1)},{children:[t("div",Object.assign({style:{marginBottom:8}},{children:e(m,Object.assign({style:{color:Z&&!W?g.content.negative:g.content.primary}},{children:[null===(P=y.variableName)||void 0===P?void 0:P.replace("{{","").replace("}}","")," ","link"===(null==y?void 0:y.type)?"link":"variable"]}))})),t("div",Object.assign({style:{marginBottom:12}},{children:k?e("div",Object.assign({style:{display:"flex",border:"#E0E0E0 1px solid",borderRadius:4,padding:10,justifyContent:(null==W?void 0:W.label)?"space-between":"flex-end"}},{children:[t(v,{children:d(null!==(w=null==W?void 0:W.label)&&void 0!==w?w:"",20,!0)}),t(l,{onClick:()=>{I(!D)},width:24,height:24,color:g.content.primary})]})):t(s,{options:N,isSearchable:!1,onSelect:le,defaultOptions:W?[Object.assign(Object.assign({},W),{selected:!0})]:[]})})),("custom_text"===(null==W?void 0:W.value)||"custom_link"===(null==W?void 0:W.value))&&t(u,{labelText:"custom_text"===(null==W?void 0:W.value)?"Custom text value":"custom_link"===(null==W?void 0:W.value)?"Custom URL value":"",id:`variable-value-${null==W?void 0:W.value}-${T}`,value:L,errorMessage:Z?L&&0!==L.trim().length?"custom_link"!==W.value||/^https?:\/\/(?:www\.)?[-a-zA-Z0-9@:%._\+~#=]{1,256}\.[a-zA-Z0-9()]{1,6}\b(?:[-a-zA-Z0-9()@:%_\+.~#?&\/=]*)$/.test(`https://${L.trim()}`)&&0!==L.trim().length?"custom_link"!==W.value&&L.length>30?"Length cannot be more than 30":"":"Enter valid URL":"Required field":"",maxCharLimit:"custom_link"===(null==W?void 0:W.value)?void 0:30,prefixText:"custom_link"===(null==W?void 0:W.value)?"https://":"",placeholder:"link"===y.type||"custom_link"===W.value?"Enter custom URL here":"Enter custom text here",onChangeText:e=>{!function(e,t){var l;H(t);const a="custom_link"===(null==W?void 0:W.value)&&t?t.includes("https")?t:`https://${t}`:t;ae(a,e),Y===c.WHATSAPP&&(null==ie||ie(null!==(l=y.index)&&void 0!==l?l:0,a,"custom_link"===e,e))}(W.value,e)}}),D&&t(o,{zIndex:2e3,data:null!=A?A:[],showVariable:D,setShowVariable:I,placeholder:"Add a variable",customTrigger:e=>{null==V||V(!1),"{{custom.url}}"===e.actualValue?le({label:e.displayName,selected:!0,value:"custom_link"}):"{{custom.text}}"==e.actualValue?le({label:e.displayName,selected:!0,value:"custom_text"}):le({label:e.displayName.replace("{{","").replace("}}","").trim().replace("."," "),selected:!0,value:e.actualValue,bikPlaceholderType:"string"})}})]}))};export{j as Container,f as default};
@@ -1,3 +1,4 @@
1
+ import { VariableListInterfaceV2 } from "../../add-variableV2/AddVariableV2";
1
2
  import { ButtonPlaceHolderOptions } from "../../template-preview/models/TemplateMeta";
2
3
  import { CTABtnValType, QRBBtnValType, TEMPLATE_BUTTON } from "../../template-preview/models/WhatsAppTemplate";
3
4
  import { WhatsAppTemplateVariables } from "../../template-preview/models/WhatsAppTemplate";
@@ -10,6 +11,8 @@ export interface WhatsAppTemplateCardButtonV2Props {
10
11
  button: TEMPLATE_BUTTON;
11
12
  CTAoptions?: ButtonPlaceHolderOptions[];
12
13
  QRBoptions?: ButtonPlaceHolderOptions[];
14
+ variableList?: VariableListInterfaceV2[];
15
+ variableListIndex: number;
13
16
  }
14
- declare const WhatsAppTemplateCardButtonV2: ({ button, updateSelectedURLTemplateBtn, updateSelectedQRBTemplateBtn, originalVariableList, CTAoptions, QRBoptions, }: WhatsAppTemplateCardButtonV2Props) => import("react/jsx-runtime").JSX.Element;
17
+ declare const WhatsAppTemplateCardButtonV2: ({ variableListIndex, button, updateSelectedURLTemplateBtn, updateSelectedQRBTemplateBtn, originalVariableList, CTAoptions, QRBoptions, variableList, }: WhatsAppTemplateCardButtonV2Props) => import("react/jsx-runtime").JSX.Element;
15
18
  export default WhatsAppTemplateCardButtonV2;
@@ -1 +1 @@
1
- import{jsxs as e,jsx as t}from"react/jsx-runtime";import{useState as l,useEffect as o}from"react";import{Dropdown as a}from"../../dropdown/Dropdown.js";import{Input as s}from"../../input/Input.js";import{editableVarPattern as i}from"../../template-preview/constants/regexPatterns.js";import{CUSTOM_URL_NAME as n}from"../../template-preview/models/TemplateMeta.js";import{BUTTON_TYPE as r}from"../../template-preview/models/WhatsAppTemplate.js";import{BodySecondary as p}from"../../TypographyStyle.js";import{COLORS as d}from"../../../constants/Theme.js";import{useTemplateModalContext as c}from"../context/templateModalContext.js";import{validateIsUrl as m}from"../utils/validateIsUrl.js";import{Container as b}from"./VariableConnector.js";const u=u=>{let{button:f,updateSelectedURLTemplateBtn:j,updateSelectedQRBTemplateBtn:g,originalVariableList:h,CTAoptions:v,QRBoptions:y}=u;const[O,x]=l(""),[R,L]=l(),{setOriginalVariableList:U,isError:w,disableEditVariable:V}=c();function T(e){x(e);const t=[Object.assign(Object.assign({},h.buttons[0]),{type:r.URL,buttonVariable:"((customPlaceholderName))",example:[`https://${e}`]})];null==U||U((e=>Object.assign(Object.assign({},e),{body:[...h.body],buttons:[...t]}))),null==j||j(`https://${e}`,"custom")}return o((()=>{var e;if(f.buttonVariable&&i.test(f.buttonVariable))L(n),x((null===(e=f.example)||void 0===e?void 0:e[0].split("https://")[1])||"");else{let e=-1;const t="URL"===f.type?v:y;e="URL"===f.type?t.findIndex((e=>e.placeHolder===f.buttonVariable)):t.findIndex((e=>e.label===f.flowName)),e>-1&&L(t[e])}}),[]),e(b,{children:[t("div",Object.assign({style:{marginBottom:8}},{children:e(p,Object.assign({style:{color:d.content.primary}},{children:[f.text," button"]}))})),t("div",Object.assign({style:{marginBottom:12}},{children:t(a,{disabled:V,options:"URL"===f.type?v:y,isSearchable:!1,onSelect:function(e,t){const l=e;L(l);const o=("URL"===f.type?v:y).find((e=>e.placeHolder===l.placeHolder));if(o)if("custom_link"!==o.value){let e;"URL"===f.type?(e=[Object.assign(Object.assign({},h.buttons[0]),{type:"URL",buttonVariable:l.placeHolder,example:["https://bik.ai/"]})],null==j||j({defaultValue:o.value,placeHolder:o.placeHolder},"placeholder")):(e=h.buttons.map(((e,t)=>t===f.index?Object.assign(Object.assign({},e),{type:"QUICK_REPLY",flowName:l.label,flowId:l.value}):e)),null==g||g({flowName:l.label,flowId:l.value},"placeholder",f.index)),null==U||U((t=>Object.assign(Object.assign({},t),{body:[...h.body],buttons:[...e]})))}else T("")},defaultOptions:R?[Object.assign(Object.assign({},R),{selected:!0})]:[]})})),"custom_link"===(null==R?void 0:R.value)&&t("div",Object.assign({style:{marginBottom:20}},{children:t(s,{state:V?"disabled":"none",errorMessage:w?O?m(O)?"":"Enter valid URL":"Required field":"",value:O,prefixText:"custom_link"===(null==R?void 0:R.value)?"https://":"",placeholder:"Enter custom URL here",onChangeText:T})}))]})};export{u as default};
1
+ import{jsxs as e,jsx as t}from"react/jsx-runtime";import{useState as l,useCallback as a,useMemo as o,useEffect as i}from"react";import{Dropdown as s}from"../../dropdown/Dropdown.js";import{Input as n}from"../../input/Input.js";import{editableVarPattern as r}from"../../template-preview/constants/regexPatterns.js";import{CUSTOM_URL_NAME as d}from"../../template-preview/models/TemplateMeta.js";import{POD as p,BUTTON_TYPE as m}from"../../template-preview/models/WhatsAppTemplate.js";import{BodySecondary as b}from"../../TypographyStyle.js";import{COLORS as c}from"../../../constants/Theme.js";import{useTemplateModalContext as u}from"../context/templateModalContext.js";import{validateIsUrl as v}from"../utils/validateIsUrl.js";import f,{Container as j}from"./VariableConnector.js";const y=y=>{let{variableListIndex:g,button:h,updateSelectedURLTemplateBtn:x,updateSelectedQRBTemplateBtn:O,originalVariableList:L,CTAoptions:T,QRBoptions:V,variableList:R}=y;var U,w,I,C;const[B,N]=l(""),[H,E]=l(),S=a((()=>R?[...R,{description:"",displayName:"Custom variables",orderId:1,variables:{"Custom url":{description:void 0,displayName:"Custom url",actualValue:"{{custom.url}}",variableType:"any",isAvailable:!0}}}].sort(((e,t)=>e.orderId-t.orderId)):R),[R]),k=o((()=>S()),[S]),{setOriginalVariableList:A,isError:M,disableEditVariable:P,pod:_}=u();function Q(e){N(e);const t=[Object.assign(Object.assign({},L.buttons[0]),{type:m.URL,buttonVariable:"((customPlaceholderName))",example:[`https://${e}`]})];null==A||A((e=>Object.assign(Object.assign({},e),{body:[...L.body],buttons:[...t]}))),null==x||x(`https://${e}`,"custom")}return i((()=>{var e;if(h.buttonVariable&&r.test(h.buttonVariable))E(d),N((null===(e=h.example)||void 0===e?void 0:e[0].split("https://")[1])||"");else{let e=-1;const t="URL"===h.type?T:V;e="URL"===h.type?t.findIndex((e=>e.placeHolder===h.buttonVariable)):t.findIndex((e=>e.label===h.flowName)),e>-1&&E(t[e])}}),[]),_!==p.CHATBOT?e(j,{children:[t("div",Object.assign({style:{marginBottom:8}},{children:e(b,Object.assign({style:{color:c.content.primary}},{children:[h.text," button"]}))})),t("div",Object.assign({style:{marginBottom:12}},{children:t(s,{disabled:P,options:"URL"===h.type?T:V,isSearchable:!1,onSelect:function(e,t){const l=e;E(l);const a=("URL"===h.type?T:V).find((e=>e.placeHolder===l.placeHolder));if(a)if("custom_link"!==a.value){let e;"URL"===h.type?(e=[Object.assign(Object.assign({},L.buttons[0]),{type:"URL",buttonVariable:l.placeHolder,example:["https://bik.ai/"]})],null==x||x({defaultValue:a.value,placeHolder:a.placeHolder},"placeholder")):(e=L.buttons.map(((e,t)=>t===h.index?Object.assign(Object.assign({},e),{type:"QUICK_REPLY",flowName:l.label,flowId:l.value}):e)),null==O||O({flowName:l.label,flowId:l.value},"placeholder",h.index)),null==A||A((t=>Object.assign(Object.assign({},t),{body:[...L.body],buttons:[...e]})))}else Q("")},defaultOptions:H?[Object.assign(Object.assign({},H),{selected:!0})]:[]})})),"custom_link"===(null==H?void 0:H.value)&&t("div",Object.assign({style:{marginBottom:20}},{children:t(n,{state:P?"disabled":"none",errorMessage:M?B?v(B)?"":"Enter valid URL":"Required field":"",value:B,prefixText:"custom_link"===(null==H?void 0:H.value)?"https://":"",placeholder:"Enter custom URL here",onChangeText:Q})}))]}):t(f,{index:g,variable:{variableName:null!==(U=h.text)&&void 0!==U?U:"",updatedValue:"((customPlaceholderName))"===h.buttonVariable?`${null===(w=h.example)||void 0===w?void 0:w[0]}`:null!==(I=h.buttonVariable)&&void 0!==I?I:"",type:"link",isEditableVariable:!0,index:null!==(C=h.index)&&void 0!==C?C:0},showVariableModal:!0,componentType:"BUTTONS",variableList:k,CTAoptions:T})};export{y as default};
@@ -1 +1 @@
1
- const o=o=>{var n,t;const e=[],i=[],p=[],l=[],s=[];let a=null;return o.components.forEach(((o,n)=>{var t,l,s,u,d,r;if("BODY"===o.type&&o.text&&e.push({component:o,i:n,type:"BODY"}),"HEADER"===o.type&&"NONE"!==o.format&&"TEXT"!==o.format&&(null===(l=null===(t=o.example)||void 0===t?void 0:t.header_handle)||void 0===l?void 0:l[0])&&(a=o),"HEADER"===o.type&&"TEXT"===o.format&&e.push({component:o,i:n,type:"HEADER"}),"BUTTONS"===o.type){const t=null===(u=null===(s=o.buttons)||void 0===s?void 0:s.filter)||void 0===u?void 0:u.call(s,(o=>"URL"===o.type));i.push({component:Object.assign(Object.assign({},o),{buttons:t}),i:n});const e=null===(r=null===(d=o.buttons)||void 0===d?void 0:d.filter)||void 0===r?void 0:r.call(d,(o=>"QUICK_REPLY"===o.type));p.push({component:Object.assign(Object.assign({},o),{buttons:e}),i:n}),p.push}})),o.mapping&&(null===(n=o.mapping.body)||void 0===n||n.forEach((o=>{l.push(o)}))),o.mapping&&(null===(t=o.mapping.header)||void 0===t||t.forEach((o=>{s.push(o)}))),{imageComponent:a,descriptionComponents:e,urlBtns:i,qrbBtns:p,bodyVariables:l,headerVariables:s}};export{o as getAllDataFromTemplateComponent};
1
+ const o=o=>{var n,t;const e=[],i=[],p=[],l=[],s=[];let a=null;return o.components.forEach(((o,n)=>{var t,l,s,d,r,u;if("BODY"===o.type&&o.text&&e.push({component:o,i:n,type:"BODY"}),"HEADER"===o.type&&"NONE"!==o.format&&"TEXT"!==o.format&&(null===(l=null===(t=o.example)||void 0===t?void 0:t.header_handle)||void 0===l?void 0:l[0])&&(a=o),"HEADER"===o.type&&"TEXT"===o.format&&e.push({component:o,i:n,type:"HEADER"}),"BUTTONS"===o.type){const t=null===(d=null===(s=o.buttons)||void 0===s?void 0:s.filter)||void 0===d?void 0:d.call(s,(o=>"URL"===o.type));i.push({component:Object.assign(Object.assign({},o),{buttons:t}),i:n});const e=null===(u=null===(r=o.buttons)||void 0===r?void 0:r.filter)||void 0===u?void 0:u.call(r,(o=>"QUICK_REPLY"===o.type));p.push({component:Object.assign(Object.assign({},o),{buttons:e}),i:n})}})),o.mapping&&(null===(n=o.mapping.body)||void 0===n||n.forEach((o=>{l.push(o)}))),o.mapping&&(null===(t=o.mapping.header)||void 0===t||t.forEach((o=>{s.push(o)}))),{imageComponent:a,descriptionComponents:e,urlBtns:i,qrbBtns:p,bodyVariables:l,headerVariables:s}};export{o as getAllDataFromTemplateComponent};
@@ -1,10 +1,10 @@
1
- import{jsxs as e,jsx as t,Fragment as o}from"react/jsx-runtime";import r from"../../../assets/icons/halfRectangle.svg.js";import i from"../../../assets/icons/phone.svg.js";import s from"../../../assets/icons/RedirectToNew.svg.js";import a from"styled-components";import{Tooltip as n}from"../../tooltips/Tooltip.js";import{Caption as p,BodySecondary as l}from"../../TypographyStyle.js";import{COLORS as m}from"../../../constants/Theme.js";import{VariableEditorHelper as d}from"../helpers/VariableEditorHelper.js";import{HEADER_TYPES as h,ACTIONS_TYPES as c}from"../models/TemplateMeta.js";import{ChatBtn as f}from"./ChatBtn.js";import{Container as x,FooterWrapper as y,TimeStamp as g}from"./ChatUI.style.js";import{MediaCard as T}from"./MediaCard.js";const j=a.div`
1
+ import{jsxs as e,jsx as t,Fragment as o}from"react/jsx-runtime";import r from"../../../assets/icons/halfRectangle.svg.js";import i from"../../../assets/icons/phone.svg.js";import s from"../../../assets/icons/RedirectToNew.svg.js";import n from"styled-components";import{Tooltip as a}from"../../tooltips/Tooltip.js";import{Caption as p,BodySecondary as l}from"../../TypographyStyle.js";import{COLORS as m}from"../../../constants/Theme.js";import{VariableEditorHelper as d}from"../helpers/VariableEditorHelper.js";import{HEADER_TYPES as h,ACTIONS_TYPES as c}from"../models/TemplateMeta.js";import{ChatBtn as x}from"./ChatBtn.js";import{Container as f,FooterWrapper as y,TimeStamp as g}from"./ChatUI.style.js";import{MediaCard as T}from"./MediaCard.js";const b=n.div`
2
2
  position: absolute;
3
3
  width: 8px;
4
4
  height: 8px;
5
5
  left: -8px;
6
6
  top: -9px;
7
- `,b=a.div`
7
+ `,j=n.div`
8
8
  font-family: 'Inter';
9
9
  font-style: normal;
10
10
  font-weight: 400;
@@ -13,7 +13,7 @@ import{jsxs as e,jsx as t,Fragment as o}from"react/jsx-runtime";import r from"..
13
13
  padding: 8px 12px 0px;
14
14
  color: ${m.content.primary};
15
15
  word-wrap: break-word;
16
- `,w=a(b)`
16
+ `,w=n(j)`
17
17
  font-weight: 600;
18
18
  margin-bottom: 8px;
19
- `,v=new d,u=a=>{const{bodyText:m,footerText:d,headerMediaType:u,headerText:I,headerAssetLink:L,headerAssetName:N,quickReplybtn:A,ctaBtn:C,actionTypes:M,extras:_,showHeader:E,imagePreviewStyles:S,size:k,bodyVariableList:H,headerVariableList:R}=a,z=v.format(m,H),B=v.format(I,R);return e(x,{children:[t(j,{children:t(r,{color:"white",height:8,width:8})}),u===h.TEXT?t(w,{dangerouslySetInnerHTML:{__html:B}}):u!==h.NONE?t(T,{headerAssetLink:L,headerAssetName:N,mediaType:u,imagePreviewStyles:u===h.IMAGE?S:{}}):t(o,{}),!!m&&t(o,{children:t(b,{dangerouslySetInnerHTML:{__html:z}})}),e(y,{children:[t(n,Object.assign({body:null!=d?d:"",placement:"top"},{children:t(g,Object.assign({style:{flex:1}},{children:d}))})),t(g,{children:"16:48"})]}),M===c.QUICK_REPLY?t("div",{children:null==A?void 0:A.map(((e,o)=>t(f,{text:e.text},o)))}):M===c.CTA_BTN?t("div",{children:null==C?void 0:C.map(((e,o)=>t(f,{textTypography:E?p:l,extraContent:_?e.extra:void 0,placeholder:e.placeholder,text:e.text,Icon:"phoneNumber"===e.type?i:s,size:k},o)))}):t(o,{})]})};export{u as ChatUIV2};
19
+ `,v=new d,u=n=>{const{bodyText:m,footerText:d,headerMediaType:u,headerText:C,headerAssetLink:E,headerAssetName:I,quickReplybtn:L,ctaBtn:N,actionTypes:_,extras:M,showHeader:R,imagePreviewStyles:A,size:O,bodyVariableList:P,headerVariableList:H,buttons:S}=n,U=v.format(m,P),k=v.format(C,H),z={COPY_CODE:i,PHONE_NUMBER:i,URL:s,QUICK_REPLY:()=>t(o,{})};return e(f,{children:[t(b,{children:t(r,{color:"white",height:8,width:8})}),u===h.TEXT?t(w,{dangerouslySetInnerHTML:{__html:k}}):u!==h.NONE?t(T,{headerAssetLink:E,headerAssetName:I,mediaType:u,imagePreviewStyles:u===h.IMAGE?A:{}}):t(o,{}),!!m&&t(o,{children:t(j,{dangerouslySetInnerHTML:{__html:U}})}),e(y,{children:[t(a,Object.assign({body:null!=d?d:"",placement:"top"},{children:t(g,Object.assign({style:{flex:1}},{children:d}))})),t(g,{children:"16:48"})]}),S&&S.length>0?S.map(((e,o)=>t(x,{text:e.text,Icon:z[e.type],size:O},o))):_===c.QUICK_REPLY?t("div",{children:null==L?void 0:L.map(((e,o)=>t(x,{text:e.text},o)))}):_===c.CTA_BTN?t("div",{children:null==N?void 0:N.map(((e,o)=>t(x,{textTypography:R?p:l,extraContent:M?e.extra:void 0,placeholder:e.placeholder,text:e.text,Icon:"phoneNumber"===e.type?i:s,size:O},o)))}):t(o,{})]})};export{u as ChatUIV2};
@@ -1 +1 @@
1
- import{jsx as e,Fragment as s,jsxs as t}from"react/jsx-runtime";import r from"../../../assets/icons/filePdf.svg.js";import i from"../../../assets/icons/image.svg.js";import o from"../../../assets/icons/videoRecorder.svg.js";import{BodySecondary as a}from"../../TypographyStyle.js";import{COLORS as n}from"../../../constants/Theme.js";import{HEADER_TYPES as c}from"../models/TemplateMeta.js";import{MediaContainer as m}from"./ChatUI.style.js";const d=s=>{let{headerAssetName:d,mediaType:l}=s;const p=l===c.IMAGE?i:l===c.VIDEO?o:r;return t(m,{children:[e(p,{height:40,width:40,color:n.icon.placeholder}),!!d&&e(a,Object.assign({style:{color:n.content.secondary,marginTop:8}},{children:d}))]})},l=t=>{let{headerAssetLink:r,headerAssetName:i,mediaType:o,imagePreviewStyles:a}=t;if(!r||o===c.DOCUMENT)return e(d,Object.assign({},{headerAssetLink:r,headerAssetName:i,mediaType:o}));const n={width:"100%",minHeight:"156px",borderRadius:8};return e(m,{children:o===c.IMAGE?e("img",{alt:"Header displays here",style:Object.assign(Object.assign({},n),a),src:r}):o===c.VIDEO?e("video",Object.assign({src:r,style:n,controls:!0},{children:e("track",{default:!0,kind:"captions",srcLang:"en",src:r})})):e(s,{})})};export{l as MediaCard,d as NoMediaCard};
1
+ import{jsx as e,Fragment as s,jsxs as r}from"react/jsx-runtime";import t from"../../../assets/icons/filePdf.svg.js";import i from"../../../assets/icons/image.svg.js";import o from"../../../assets/icons/videoRecorder.svg.js";import{BodySecondary as m}from"../../TypographyStyle.js";import{COLORS as a}from"../../../constants/Theme.js";import{HEADER_TYPES as n}from"../models/TemplateMeta.js";import{MediaContainer as d}from"./ChatUI.style.js";import{ShimmerImage as c}from"../../shimmer-image/ShimmerImage.js";const h=s=>{let{headerAssetName:c,mediaType:h}=s;const l=h===n.IMAGE?i:h===n.VIDEO?o:t;return r(d,{children:[e(l,{height:40,width:40,color:a.icon.placeholder}),!!c&&e(m,Object.assign({style:{color:a.content.secondary,marginTop:8}},{children:c}))]})},l=r=>{let{headerAssetLink:t,headerAssetName:i,mediaType:o,imagePreviewStyles:m}=r;if(!t||o===n.DOCUMENT)return e(h,Object.assign({},{headerAssetLink:t,headerAssetName:i,mediaType:o}));return e(d,{children:o===n.IMAGE?e(c,{imageUrl:t,alt:t,width:148,height:156,borderRadius:8}):o===n.VIDEO?e("video",Object.assign({src:t,style:{width:"100%",minHeight:"156px",borderRadius:8},controls:!0},{children:e("track",{default:!0,kind:"captions",srcLang:"en",src:t})})):e(s,{})})};export{l as MediaCard,h as NoMediaCard};
@@ -1 +1 @@
1
- import{jsx as e,Fragment as l}from"react/jsx-runtime";import{useState as t,useEffect as a}from"react";import{TemplateCreatorHelper as i}from"./helpers/TemplateCreatorHelper.js";import{HEADER_TYPES as o}from"./models/TemplateMeta.js";import{TemplateHelperUtils as n}from"./utils/TemplateHelperUtils.js";import{WhatsappLikePreview as r}from"./WhatsApp/WhatsAppLikePreview.js";import{WhatsappLikePreviewV2 as d}from"./WhatsApp/WhatsAppLikePreviewV2.js";const p=p=>{let{template:s,extras:u,containerStyle:v,usePlaceHolderName:h,showHeader:m,zeroStateComponent:x,size:c,showSampleValues:b}=p;var T,y,w,N,k,B,V,f,A,L,S,j,P,C,g,F,H,O,q,z,R,U;const[W,I]=t(),M=new i,D=new n,E=[];return(null===(y=null===(T=null==W?void 0:W.ctaBtn)||void 0===T?void 0:T.phoneNumber)||void 0===y?void 0:y.isChecked)&&E.push({type:"phoneNumber",text:null!==(w=W.ctaBtn.phoneNumber.btnText)&&void 0!==w?w:"",extra:null!==(N=W.ctaBtn.phoneNumber.phoneNumber)&&void 0!==N?N:""}),(null===(B=null===(k=null==W?void 0:W.ctaBtn)||void 0===k?void 0:k.websiteLinkBtn)||void 0===B?void 0:B.isChecked)&&E.push({type:"website",text:null!==(V=W.ctaBtn.websiteLinkBtn.btnText)&&void 0!==V?V:"",extra:null!==(A=null===(f=W.ctaBtn.websiteLinkBtn)||void 0===f?void 0:f.linkOpens)&&void 0!==A?A:"",placeholder:null!==(L=W.ctaBtn.websiteLinkBtn.placeholder)&&void 0!==L?L:""}),a((()=>{s&&M.parseUITemplateFromDBFormat({dbFormattedTemplate:s,isDuplicate:!1,showSampleValues:b,isV2:!s.htmlContentUrl}).then((e=>{I(Object.assign({},e))}))}),[s,b]),s?s.htmlContentUrl?e(r,{showHeader:m,containerPadding:"large"===c?"16px 56px 12px 16px":"12px 56px 12px 12px",containerStyle:v,textType:"html",bodyText:D.whatsappOnlyFillVariablesValueInBodyText(null!==(H=null==W?void 0:W.bodyText)&&void 0!==H?H:"",null!==(O=null==W?void 0:W.bodyVariables)&&void 0!==O?O:[],h),footerText:null==W?void 0:W.footerText,headerMediaType:(null==W?void 0:W.headerType)||o.NONE,headerText:D.fillVariablesValInBodyText(null!==(q=null==W?void 0:W.headerText)&&void 0!==q?q:"",null!==(z=null==W?void 0:W.headerVariables)&&void 0!==z?z:[],h),headerAssetLink:null!==(R=null==W?void 0:W.headerAssetLink)&&void 0!==R?R:"",headerAssetName:null!==(U=null==W?void 0:W.headerAssetName)&&void 0!==U?U:"",quickReplybtn:null==W?void 0:W.quickReply,ctaBtn:E,actionTypes:null==W?void 0:W.actionsType,extras:u,hidePreviewText:!0,imagePreviewStyles:{objectFit:"cover"},zeroStateComponent:null!=x?x:e(l,{children:" "})}):e(d,{showHeader:m,containerPadding:"large"===c?"16px 56px 12px 16px":"12px 56px 12px 12px",containerStyle:v,textType:"html",bodyText:null==W?void 0:W.bodyText,footerText:null==W?void 0:W.footerText,headerMediaType:(null==W?void 0:W.headerType)||o.NONE,headerText:null==W?void 0:W.headerText,headerAssetLink:null!==(S=null==W?void 0:W.headerAssetLink)&&void 0!==S?S:"",headerAssetName:null!==(j=null==W?void 0:W.headerAssetName)&&void 0!==j?j:"",quickReplybtn:null==W?void 0:W.quickReply,ctaBtn:E,actionTypes:null==W?void 0:W.actionsType,extras:u,hidePreviewText:!0,imagePreviewStyles:{objectFit:"cover"},zeroStateComponent:null!=x?x:e(l,{children:" "}),bodyVariableList:null!==(C=null===(P=null==W?void 0:W.bodyVariables)||void 0===P?void 0:P.map((e=>{var l;return{placeholder:e.variableName,value:null!==(l=e.variableVal)&&void 0!==l?l:e.variableName}})))&&void 0!==C?C:[],headerVariableList:null!==(F=null===(g=null==W?void 0:W.headerVariables)||void 0===g?void 0:g.map((e=>{var l;return{placeholder:e.variableName,value:null!==(l=e.variableVal)&&void 0!==l?l:e.variableName}})))&&void 0!==F?F:[]}):e(l,{children:x})};export{p as default};
1
+ import{jsx as e,Fragment as l}from"react/jsx-runtime";import{useState as t,useEffect as a}from"react";import{TemplateCreatorHelper as i}from"./helpers/TemplateCreatorHelper.js";import{HEADER_TYPES as o}from"./models/TemplateMeta.js";import{TemplateHelperUtils as n}from"./utils/TemplateHelperUtils.js";import{WhatsappLikePreview as r}from"./WhatsApp/WhatsAppLikePreview.js";import{WhatsappLikePreviewV2 as d}from"./WhatsApp/WhatsAppLikePreviewV2.js";const p=p=>{let{template:s,extras:u,containerStyle:v,usePlaceHolderName:h,showHeader:m,zeroStateComponent:x,size:c,showSampleValues:b}=p;var T,y,w,N,k,B,V,f,A,L,S,j,P,C,g,F,H,O,q,z,R,U;const[W,I]=t(),M=new i,D=new n,E=[];return(null===(y=null===(T=null==W?void 0:W.ctaBtn)||void 0===T?void 0:T.phoneNumber)||void 0===y?void 0:y.isChecked)&&E.push({type:"phoneNumber",text:null!==(w=W.ctaBtn.phoneNumber.btnText)&&void 0!==w?w:"",extra:null!==(N=W.ctaBtn.phoneNumber.phoneNumber)&&void 0!==N?N:""}),(null===(B=null===(k=null==W?void 0:W.ctaBtn)||void 0===k?void 0:k.websiteLinkBtn)||void 0===B?void 0:B.isChecked)&&E.push({type:"website",text:null!==(V=W.ctaBtn.websiteLinkBtn.btnText)&&void 0!==V?V:"",extra:null!==(A=null===(f=W.ctaBtn.websiteLinkBtn)||void 0===f?void 0:f.linkOpens)&&void 0!==A?A:"",placeholder:null!==(L=W.ctaBtn.websiteLinkBtn.placeholder)&&void 0!==L?L:""}),a((()=>{s&&M.parseUITemplateFromDBFormat({dbFormattedTemplate:s,isDuplicate:!1,showSampleValues:b,isV2:!s.htmlContentUrl}).then((e=>{I(Object.assign({},e))}))}),[s,b]),s?s.htmlContentUrl?e(r,{showHeader:m,containerPadding:"large"===c?"16px 56px 12px 16px":"12px 56px 12px 12px",containerStyle:v,textType:"html",bodyText:D.whatsappOnlyFillVariablesValueInBodyText(null!==(H=null==W?void 0:W.bodyText)&&void 0!==H?H:"",null!==(O=null==W?void 0:W.bodyVariables)&&void 0!==O?O:[],h),footerText:null==W?void 0:W.footerText,headerMediaType:(null==W?void 0:W.headerType)||o.NONE,headerText:D.fillVariablesValInBodyText(null!==(q=null==W?void 0:W.headerText)&&void 0!==q?q:"",null!==(z=null==W?void 0:W.headerVariables)&&void 0!==z?z:[],h),headerAssetLink:null!==(R=null==W?void 0:W.headerAssetLink)&&void 0!==R?R:"",headerAssetName:null!==(U=null==W?void 0:W.headerAssetName)&&void 0!==U?U:"",quickReplybtn:null==W?void 0:W.quickReply,ctaBtn:E,actionTypes:null==W?void 0:W.actionsType,extras:u,hidePreviewText:!0,imagePreviewStyles:{objectFit:"cover"},zeroStateComponent:null!=x?x:e(l,{children:" "})}):e(d,{showHeader:m,containerPadding:"large"===c?"16px 56px 12px 16px":"12px 56px 12px 12px",containerStyle:v,textType:"html",bodyText:null==W?void 0:W.bodyText,footerText:null==W?void 0:W.footerText,headerMediaType:(null==W?void 0:W.headerType)||o.NONE,headerText:null==W?void 0:W.headerText,headerAssetLink:null!==(S=null==W?void 0:W.headerAssetLink)&&void 0!==S?S:"",headerAssetName:null!==(j=null==W?void 0:W.headerAssetName)&&void 0!==j?j:"",quickReplybtn:null==W?void 0:W.quickReply,ctaBtn:E,actionTypes:null==W?void 0:W.actionsType,extras:u,hidePreviewText:!0,imagePreviewStyles:{objectFit:"cover"},zeroStateComponent:null!=x?x:e(l,{children:" "}),bodyVariableList:null!==(C=null===(P=null==W?void 0:W.bodyVariables)||void 0===P?void 0:P.map((e=>{var l;return{placeholder:e.variableName,value:null!==(l=e.variableVal)&&void 0!==l?l:e.variableName}})))&&void 0!==C?C:[],headerVariableList:null!==(F=null===(g=null==W?void 0:W.headerVariables)||void 0===g?void 0:g.map((e=>{var l;return{placeholder:e.variableName,value:null!==(l=e.variableVal)&&void 0!==l?l:e.variableName}})))&&void 0!==F?F:[],buttons:null==W?void 0:W.allButtons}):e(l,{children:x})};export{p as default};
@@ -1 +1 @@
1
- import{__awaiter as e}from"../../../_virtual/_tslib.js";import{COLORS as t}from"../../../constants/Theme.js";import{specialCharPattern as n,placeHolderNamePattern as i,editableVarPattern as o}from"../constants/regexPatterns.js";import{REQUIRED_FIELD as l,NAME_LEN_LIMIT as a,NAME_LEN_ERROR as d,NO_SPECIAL_CHAR as r,HEADER_TEXT_LEN_LIMIT as v,HEADER_LEN_ERROR as s,ONE_VAR_ALLOWED as u,HEADER_ASSET_LINK_ERROR as p,BODY_TEXT_LEN_LIMIT as c,BODY_LEN_ERROR as m,QUICK_REPLY_BTN_TEXT_LIMIT as h,QUICK_REPLY_LEN_ERROR as b,BUTTON_EMOJI_ERROR as T,VALID_PHONE_NUMBER as y,QUICK_REPLY_NAME_LEN_LIMIT as B,CREATE_TEMPLATE_DOM_IDS as x,QUICK_REPLY_NAME_ERROR as f}from"../constants/TemplateConstants.js";import{HEADER_TYPES as k,ACTIONS_TYPES as N}from"../models/TemplateMeta.js";import{TemplateHelperUtils as g}from"../utils/TemplateHelperUtils.js";class C{parseDataFromHeaderComponent(e,t){var n,i,o,l,a,d,r,v,s,u;const p={headerType:k.NONE,headerVariables:[]},c=null===(n=e.components)||void 0===n?void 0:n.find((e=>"HEADER"===e.type));if(c){p.headerType=c.format,p.headerText=c.text,p.headerAssetLink=null===(o=null===(i=c.example)||void 0===i?void 0:i.header_handle)||void 0===o?void 0:o[0];const n=null===(a=null===(l=c.example)||void 0===l?void 0:l.header_text)||void 0===a?void 0:a[0],m=null===(r=null===(d=e.mapping)||void 0===d?void 0:d.header)||void 0===r?void 0:r[0],h=m;if(n&&m){const e=null==m?void 0:m.replace("[[","").replace("]]","").replace("{{","").replace("}}","").replace("((","").replace("))",""),i=/\(\(/.test(m),o={idx:0,variableVal:t?n:h,editable:i,editableDefaultValues:i?void 0:n,variableName:e};p.headerVariables=[o],(null===(s=null===(v=c.example)||void 0===v?void 0:v.header_text)||void 0===s?void 0:s.length)&&(p.headerText=null===(u=p.headerText)||void 0===u?void 0:u.replace("{{1}}",`{{${e}}}`))}}return p}validateState(e){var t,i,o,C,L,E,R,w,_,V,A,D,I,U,O,q,F,j,P,$,Y;const K=/\p{Extended_Pictographic}/u;let M="valid";const Q={meta:{},ctaBtn:{phoneNumber:{btnText:"",link:""},websiteLink:{btnText:"",link:""}},quickReply:[null,null,null]},S=new g;let H=!1;const G=e=>{var t;null===(t=document.getElementById(e))||void 0===t||t.scrollIntoView({behavior:"smooth",block:"nearest"})};if((null===(t=e.meta)||void 0===t?void 0:t.name)?e.meta.name.trim().length>a?(Q.meta.name=d,M="invalid"):n.test(e.meta.name.trim())&&(Q.meta.name=r,M="invalid"):(Q.meta.name=l,M="invalid"),Q.meta.name&&!H&&(G(x.name),H=!0),e.headerType===k.TEXT){const t=null!==(o=null===(i=e.headerText)||void 0===i?void 0:i.trim())&&void 0!==o?o:"";if(t)if(t.length>v)Q.header=s,M="invalid";else{const e=S.getTemplateVariablesFromState(t);e&&e.length>1&&(Q.header=u,M="invalid")}else Q.header=l,M="invalid"}else e.headerType===k.DOCUMENT||e.headerType===k.IMAGE||(e.headerType,k.VIDEO);if(e.headerType!==k.DOCUMENT&&e.headerType!==k.IMAGE&&e.headerType!==k.VIDEO||e.headerAssetLink||(Q.header=p,M="invalid"),Q.header&&!H&&(G(x.header),H=!0),e.bodyText?e.bodyTextRaw&&(null===(C=e.bodyTextRaw)||void 0===C?void 0:C.trim().length)>c&&(Q.body=m,M="invalid"):(Q.body=l,M="invalid"),Q.body&&!H&&(G(x.body),H=!0),e.footerText&&e.footerText.length>v&&(Q.footer=s,M="invalid"),(null==Q?void 0:Q.footer)&&!H&&(G(x.footer),H=!0),e.actionsType===N.CTA_BTN){if(null===(E=null===(L=e.ctaBtn)||void 0===L?void 0:L.phoneNumber)||void 0===E?void 0:E.isChecked){const t=null===(R=e.ctaBtn.phoneNumber.btnText)||void 0===R?void 0:R.trim(),n=e.ctaBtn.phoneNumber.phoneNumber;Q.ctaBtn&&!t?(Q.ctaBtn.phoneNumber.btnText=l,M="invalid"):Q.ctaBtn&&t&&t.length>h?(Q.ctaBtn.phoneNumber.btnText=b,M="invalid"):Q.ctaBtn&&t&&K.test(t)&&(Q.ctaBtn.phoneNumber.btnText=T,M="invalid"),Q.ctaBtn&&!n?(Q.ctaBtn.phoneNumber.link=l,M="invalid"):Q.ctaBtn&&n&&n.length<10&&(Q.ctaBtn.phoneNumber.link=y,M="invalid")}if(null===(_=null===(w=e.ctaBtn)||void 0===w?void 0:w.websiteLinkBtn)||void 0===_?void 0:_.isChecked){const t=null===(V=e.ctaBtn.websiteLinkBtn.btnText)||void 0===V?void 0:V.trim(),n=null===(A=e.ctaBtn.websiteLinkBtn.linkOpens)||void 0===A?void 0:A.trim(),i=null===(D=e.ctaBtn.websiteLinkBtn.placeholder)||void 0===D?void 0:D.trim();Q.ctaBtn&&!t?(Q.ctaBtn.websiteLink.btnText=l,M="invalid"):Q.ctaBtn&&t&&t.length>h?(Q.ctaBtn.websiteLink.btnText=b,M="invalid"):Q.ctaBtn&&t&&K.test(t)&&(Q.ctaBtn.websiteLink.btnText=T,M="invalid"),!Q.ctaBtn||n||i||(Q.ctaBtn.websiteLink.link=l,M="invalid")}}else if(e.actionsType===N.QUICK_REPLY){const t=["","",""];e.quickReply.forEach(((n,i)=>{const o=n.text.trim();if(o)if(o.length>B)t[i]=b,M="invalid";else if(K.test(o))t[i]=T,M="invalid";else{const n=[...e.quickReply];n.splice(i,1);n.find((e=>e.text===o))&&(t[i]=f,M="invalid")}else t[i]=l,M="invalid"})),Q.quickReply=t}if(e.actionsType===N.CTA_BTN||e.actionsType===N.QUICK_REPLY){const e=null===(I=Q.quickReply)||void 0===I?void 0:I.reduce(((e,t)=>e||!!t),!1);((null===(O=null===(U=null==Q?void 0:Q.ctaBtn)||void 0===U?void 0:U.websiteLink)||void 0===O?void 0:O.link)||(null===(F=null===(q=Q.ctaBtn)||void 0===q?void 0:q.websiteLink)||void 0===F?void 0:F.btnText)||(null===(P=null===(j=Q.ctaBtn)||void 0===j?void 0:j.phoneNumber)||void 0===P?void 0:P.link)||(null===(Y=null===($=Q.ctaBtn)||void 0===$?void 0:$.phoneNumber)||void 0===Y?void 0:Y.btnText)||e)&&!H&&(G(x.actionButtons),H=!0)}return{status:M,errors:Q}}parseBodyComponent(e){let n=arguments.length>1&&void 0!==arguments[1]&&arguments[1],o=arguments.length>2?arguments[2]:void 0;var l,a,d,r,v;const s=[];let u="";const p=null===(l=e.components)||void 0===l?void 0:l.find((e=>"BODY"===e.type));return p&&(null===(d=null===(a=p.example)||void 0===a?void 0:a.body_text)||void 0===d||d[0].forEach(((t,n)=>{var l,a;let d=null===(a=null===(l=e.mapping)||void 0===l?void 0:l.body)||void 0===a?void 0:a[n];const r=d,v=d&&/\(\(/.test(d),u=null==d?void 0:d.match(i);(null==u?void 0:u[2])&&(d=null==u?void 0:u[2]),s.push({idx:n,variableVal:o?t:r,editable:!!v,editableDefaultValues:v?void 0:t,variableName:null!=d?d:""})})),u=e.htmlContentUrl?e.htmlContentUrl:(null===(r=p.text)||void 0===r?void 0:r.split(/\{\{[0-9]+\}\}/).length)?null===(v=p.text)||void 0===v?void 0:v.split(/\{\{[0-9]+\}\}/).map(((e,i)=>{if(null==s?void 0:s[i]){const o=s[i].variableName;return n?`${e}{{${o}}}`:`${e} <span> </span><span style="color: ${t.content.brand}; text-decoration: underline;">{{${o}}}</span><span> </span>`}return e})).join(""):""),{bodyVariable:s,bodyText:u}}parseFooterComponent(e){var t;const n=null===(t=e.components)||void 0===t?void 0:t.find((e=>"FOOTER"===e.type));return null==n?void 0:n.text}parseButtonComponent(e){var t,n,i,l,a,d;const r={actionsType:N.NONE,quickReply:[],ctaBtn:{phoneNumber:void 0,websiteLinkBtn:void 0}},v=null===(t=e.components)||void 0===t?void 0:t.find((e=>"BUTTONS"===e.type));if(v&&(null===(n=null==v?void 0:v.buttons)||void 0===n?void 0:n.length)){const t="QUICK_REPLY"===(null===(i=null==v?void 0:v.buttons)||void 0===i?void 0:i[0].type)?N.QUICK_REPLY:N.CTA_BTN;if(r.actionsType=t,t===N.QUICK_REPLY){const e=null!==(a=null===(l=null==v?void 0:v.buttons)||void 0===l?void 0:l.map((e=>e)))&&void 0!==a?a:[];return r.quickReply=e,r}t===N.CTA_BTN&&(null===(d=null==v?void 0:v.buttons)||void 0===d||d.forEach((t=>{var n,i,l,a;if(t.phone_number&&(r.ctaBtn.phoneNumber={isChecked:!0,btnText:t.text,phoneNumber:t.phone_number}),t.url){const d=null!==(l=null===(i=null===(n=null==e?void 0:e.mapping)||void 0===n?void 0:n.buttons)||void 0===i?void 0:i[0])&&void 0!==l?l:void 0;let v=!1;d&&o.test(d)&&(v=!0),r.ctaBtn.websiteLinkBtn={isChecked:!0,btnText:t.text,linkOpens:v?null===(a=t.example)||void 0===a?void 0:a[0]:t.url,placeholder:v?void 0:d}}})))}return r}parseUITemplateFromDBFormat(t){var n;return e(this,void 0,void 0,(function*(){const{dbFormattedTemplate:e,isDuplicate:i,isV2:o=!1,showSampleValues:l}=t,{headerType:a,headerAssetLink:d,headerAssetName:r,headerText:v,headerVariables:s}=yield this.parseDataFromHeaderComponent(e),{bodyText:u,bodyVariable:p}=yield this.parseBodyComponent(e,o,l),{actionsType:c,quickReply:m,ctaBtn:h}=yield this.parseButtonComponent(e),b={quickReply:m,ctaBtn:h,meta:{name:i?`${e.label} Copy`:e.label,category:null===(n=e.category)||void 0===n?void 0:n.toUpperCase(),subCategory:e.templateCategory,language:e.language,templateId:e.templateId},error:{header:void 0,body:void 0,footer:void 0,quickReply:void 0,meta:void 0,ctaBtn:void 0},actionsType:c,footerText:this.parseFooterComponent(e),bodyVariables:p,bodyText:u,headerType:a,headerAssetLink:d,headerAssetName:r,headerText:v,headerVariables:s,alreadyAsADraft:e.isDraft,mode:"edit",initialLoading:!1},{errors:T}=this.validateState(b);return b.error=T,b}))}}export{C as TemplateCreatorHelper};
1
+ import{__awaiter as e}from"../../../_virtual/_tslib.js";import{COLORS as t}from"../../../constants/Theme.js";import{specialCharPattern as n,placeHolderNamePattern as i,editableVarPattern as o}from"../constants/regexPatterns.js";import{REQUIRED_FIELD as l,NAME_LEN_LIMIT as a,NAME_LEN_ERROR as d,NO_SPECIAL_CHAR as r,HEADER_TEXT_LEN_LIMIT as v,HEADER_LEN_ERROR as s,ONE_VAR_ALLOWED as u,HEADER_ASSET_LINK_ERROR as p,BODY_TEXT_LEN_LIMIT as c,BODY_LEN_ERROR as m,QUICK_REPLY_BTN_TEXT_LIMIT as h,QUICK_REPLY_LEN_ERROR as b,BUTTON_EMOJI_ERROR as T,VALID_PHONE_NUMBER as y,QUICK_REPLY_NAME_LEN_LIMIT as B,CREATE_TEMPLATE_DOM_IDS as x,QUICK_REPLY_NAME_ERROR as f}from"../constants/TemplateConstants.js";import{HEADER_TYPES as k,ACTIONS_TYPES as N}from"../models/TemplateMeta.js";import{TemplateHelperUtils as g}from"../utils/TemplateHelperUtils.js";class C{parseDataFromHeaderComponent(e,t){var n,i,o,l,a,d,r,v,s,u;const p={headerType:k.NONE,headerVariables:[]},c=null===(n=e.components)||void 0===n?void 0:n.find((e=>"HEADER"===e.type));if(c){p.headerType=c.format,p.headerText=c.text,p.headerAssetLink=null===(o=null===(i=c.example)||void 0===i?void 0:i.header_handle)||void 0===o?void 0:o[0];const n=null===(a=null===(l=c.example)||void 0===l?void 0:l.header_text)||void 0===a?void 0:a[0],m=null===(r=null===(d=e.mapping)||void 0===d?void 0:d.header)||void 0===r?void 0:r[0],h=m;if(n&&m){const e=null==m?void 0:m.replace("[[","").replace("]]","").replace("{{","").replace("}}","").replace("((","").replace("))",""),i=/\(\(/.test(m),o={idx:0,variableVal:t?n:h,editable:i,editableDefaultValues:i?void 0:n,variableName:e};p.headerVariables=[o],(null===(s=null===(v=c.example)||void 0===v?void 0:v.header_text)||void 0===s?void 0:s.length)&&(p.headerText=null===(u=p.headerText)||void 0===u?void 0:u.replace("{{1}}",`{{${e}}}`))}}return p}validateState(e){var t,i,o,C,L,E,R,w,_,V,A,D,I,U,O,q,F,j,P,$,Y;const K=/\p{Extended_Pictographic}/u;let M="valid";const Q={meta:{},ctaBtn:{phoneNumber:{btnText:"",link:""},websiteLink:{btnText:"",link:""}},quickReply:[null,null,null]},S=new g;let H=!1;const G=e=>{var t;null===(t=document.getElementById(e))||void 0===t||t.scrollIntoView({behavior:"smooth",block:"nearest"})};if((null===(t=e.meta)||void 0===t?void 0:t.name)?e.meta.name.trim().length>a?(Q.meta.name=d,M="invalid"):n.test(e.meta.name.trim())&&(Q.meta.name=r,M="invalid"):(Q.meta.name=l,M="invalid"),Q.meta.name&&!H&&(G(x.name),H=!0),e.headerType===k.TEXT){const t=null!==(o=null===(i=e.headerText)||void 0===i?void 0:i.trim())&&void 0!==o?o:"";if(t)if(t.length>v)Q.header=s,M="invalid";else{const e=S.getTemplateVariablesFromState(t);e&&e.length>1&&(Q.header=u,M="invalid")}else Q.header=l,M="invalid"}else e.headerType===k.DOCUMENT||e.headerType===k.IMAGE||(e.headerType,k.VIDEO);if(e.headerType!==k.DOCUMENT&&e.headerType!==k.IMAGE&&e.headerType!==k.VIDEO||e.headerAssetLink||(Q.header=p,M="invalid"),Q.header&&!H&&(G(x.header),H=!0),e.bodyText?e.bodyTextRaw&&(null===(C=e.bodyTextRaw)||void 0===C?void 0:C.trim().length)>c&&(Q.body=m,M="invalid"):(Q.body=l,M="invalid"),Q.body&&!H&&(G(x.body),H=!0),e.footerText&&e.footerText.length>v&&(Q.footer=s,M="invalid"),(null==Q?void 0:Q.footer)&&!H&&(G(x.footer),H=!0),e.actionsType===N.CTA_BTN){if(null===(E=null===(L=e.ctaBtn)||void 0===L?void 0:L.phoneNumber)||void 0===E?void 0:E.isChecked){const t=null===(R=e.ctaBtn.phoneNumber.btnText)||void 0===R?void 0:R.trim(),n=e.ctaBtn.phoneNumber.phoneNumber;Q.ctaBtn&&!t?(Q.ctaBtn.phoneNumber.btnText=l,M="invalid"):Q.ctaBtn&&t&&t.length>h?(Q.ctaBtn.phoneNumber.btnText=b,M="invalid"):Q.ctaBtn&&t&&K.test(t)&&(Q.ctaBtn.phoneNumber.btnText=T,M="invalid"),Q.ctaBtn&&!n?(Q.ctaBtn.phoneNumber.link=l,M="invalid"):Q.ctaBtn&&n&&n.length<10&&(Q.ctaBtn.phoneNumber.link=y,M="invalid")}if(null===(_=null===(w=e.ctaBtn)||void 0===w?void 0:w.websiteLinkBtn)||void 0===_?void 0:_.isChecked){const t=null===(V=e.ctaBtn.websiteLinkBtn.btnText)||void 0===V?void 0:V.trim(),n=null===(A=e.ctaBtn.websiteLinkBtn.linkOpens)||void 0===A?void 0:A.trim(),i=null===(D=e.ctaBtn.websiteLinkBtn.placeholder)||void 0===D?void 0:D.trim();Q.ctaBtn&&!t?(Q.ctaBtn.websiteLink.btnText=l,M="invalid"):Q.ctaBtn&&t&&t.length>h?(Q.ctaBtn.websiteLink.btnText=b,M="invalid"):Q.ctaBtn&&t&&K.test(t)&&(Q.ctaBtn.websiteLink.btnText=T,M="invalid"),!Q.ctaBtn||n||i||(Q.ctaBtn.websiteLink.link=l,M="invalid")}}else if(e.actionsType===N.QUICK_REPLY){const t=["","",""];e.quickReply.forEach(((n,i)=>{const o=n.text.trim();if(o)if(o.length>B)t[i]=b,M="invalid";else if(K.test(o))t[i]=T,M="invalid";else{const n=[...e.quickReply];n.splice(i,1);n.find((e=>e.text===o))&&(t[i]=f,M="invalid")}else t[i]=l,M="invalid"})),Q.quickReply=t}if(e.actionsType===N.CTA_BTN||e.actionsType===N.QUICK_REPLY){const e=null===(I=Q.quickReply)||void 0===I?void 0:I.reduce(((e,t)=>e||!!t),!1);((null===(O=null===(U=null==Q?void 0:Q.ctaBtn)||void 0===U?void 0:U.websiteLink)||void 0===O?void 0:O.link)||(null===(F=null===(q=Q.ctaBtn)||void 0===q?void 0:q.websiteLink)||void 0===F?void 0:F.btnText)||(null===(P=null===(j=Q.ctaBtn)||void 0===j?void 0:j.phoneNumber)||void 0===P?void 0:P.link)||(null===(Y=null===($=Q.ctaBtn)||void 0===$?void 0:$.phoneNumber)||void 0===Y?void 0:Y.btnText)||e)&&!H&&(G(x.actionButtons),H=!0)}return{status:M,errors:Q}}parseBodyComponent(e){let n=arguments.length>1&&void 0!==arguments[1]&&arguments[1],o=arguments.length>2?arguments[2]:void 0;var l,a,d,r,v;const s=[];let u="";const p=null===(l=e.components)||void 0===l?void 0:l.find((e=>"BODY"===e.type));return p&&(null===(d=null===(a=p.example)||void 0===a?void 0:a.body_text)||void 0===d||d[0].forEach(((t,n)=>{var l,a;let d=null===(a=null===(l=e.mapping)||void 0===l?void 0:l.body)||void 0===a?void 0:a[n];const r=d,v=d&&/\(\(/.test(d),u=null==d?void 0:d.match(i);(null==u?void 0:u[2])&&(d=null==u?void 0:u[2]),s.push({idx:n,variableVal:o?t:r,editable:!!v,editableDefaultValues:v?void 0:t,variableName:null!=d?d:""})})),u=e.htmlContentUrl?e.htmlContentUrl:(null===(r=p.text)||void 0===r?void 0:r.split(/\{\{[0-9]+\}\}/).length)?null===(v=p.text)||void 0===v?void 0:v.split(/\{\{[0-9]+\}\}/).map(((e,i)=>{if(null==s?void 0:s[i]){const o=s[i].variableName;return n?`${e}{{${o}}}`:`${e} <span> </span><span style="color: ${t.content.brand}; text-decoration: underline;">{{${o}}}</span><span> </span>`}return e})).join(""):""),{bodyVariable:s,bodyText:u}}parseFooterComponent(e){var t;const n=null===(t=e.components)||void 0===t?void 0:t.find((e=>"FOOTER"===e.type));return null==n?void 0:n.text}parseButtonComponent(e){var t,n,i,l,a,d;const r={actionsType:N.NONE,quickReply:[],ctaBtn:{phoneNumber:void 0,websiteLinkBtn:void 0},allButtons:[]},v=null===(t=e.components)||void 0===t?void 0:t.find((e=>"BUTTONS"===e.type));if(v&&(null===(n=null==v?void 0:v.buttons)||void 0===n?void 0:n.length)){const t="QUICK_REPLY"===(null===(i=null==v?void 0:v.buttons)||void 0===i?void 0:i[0].type)?N.QUICK_REPLY:N.CTA_BTN;if(r.actionsType=t,t===N.QUICK_REPLY){const e=null!==(a=null===(l=null==v?void 0:v.buttons)||void 0===l?void 0:l.map((e=>e)))&&void 0!==a?a:[];return r.quickReply=e,r}t===N.CTA_BTN&&(null===(d=null==v?void 0:v.buttons)||void 0===d||d.forEach((t=>{var n,i,l,a;if(t.phone_number&&(r.ctaBtn.phoneNumber={isChecked:!0,btnText:t.text,phoneNumber:t.phone_number}),t.url){const d=null!==(l=null===(i=null===(n=null==e?void 0:e.mapping)||void 0===n?void 0:n.buttons)||void 0===i?void 0:i[0])&&void 0!==l?l:void 0;let v=!1;d&&o.test(d)&&(v=!0),r.ctaBtn.websiteLinkBtn={isChecked:!0,btnText:t.text,linkOpens:v?null===(a=t.example)||void 0===a?void 0:a[0]:t.url,placeholder:v?void 0:d}}}))),r.allButtons=v.buttons}return r}parseUITemplateFromDBFormat(t){var n;return e(this,void 0,void 0,(function*(){const{dbFormattedTemplate:e,isDuplicate:i,isV2:o=!1,showSampleValues:l}=t,{headerType:a,headerAssetLink:d,headerAssetName:r,headerText:v,headerVariables:s}=yield this.parseDataFromHeaderComponent(e),{bodyText:u,bodyVariable:p}=yield this.parseBodyComponent(e,o,l),{actionsType:c,quickReply:m,ctaBtn:h,allButtons:b}=yield this.parseButtonComponent(e),T={quickReply:m,ctaBtn:h,allButtons:b,meta:{name:i?`${e.label} Copy`:e.label,category:null===(n=e.category)||void 0===n?void 0:n.toUpperCase(),subCategory:e.templateCategory,language:e.language,templateId:e.templateId},error:{header:void 0,body:void 0,footer:void 0,quickReply:void 0,meta:void 0,ctaBtn:void 0},actionsType:c,footerText:this.parseFooterComponent(e),bodyVariables:p,bodyText:u,headerType:a,headerAssetLink:d,headerAssetName:r,headerText:v,headerVariables:s,alreadyAsADraft:e.isDraft,mode:"edit",initialLoading:!1},{errors:y}=this.validateState(T);return T.error=y,T}))}}export{C as TemplateCreatorHelper};
@@ -1,7 +1,7 @@
1
1
  import { SingleOption } from "../../dropdown/type";
2
2
  export type CUSTOM_VARIABLE = {
3
3
  variableName: string;
4
- type: 'string' | 'link' | 'image';
4
+ type: 'string' | 'link' | 'image' | 'button';
5
5
  isEditableVariable: boolean;
6
6
  updatedValue: string;
7
7
  index?: number;
@@ -15,7 +15,7 @@ export type WhatsAppTemplate = {
15
15
  format?: HEADER_TYPES;
16
16
  text?: string;
17
17
  buttons?: {
18
- type: 'QUICK_REPLY' | 'URL' | 'PHONE_NUMBER';
18
+ type: 'QUICK_REPLY' | 'URL' | 'PHONE_NUMBER' | 'COPY_CODE';
19
19
  text?: string;
20
20
  url?: string;
21
21
  example?: string[];
@@ -46,6 +46,7 @@ export type WhatsAppTemplate = {
46
46
  updatedAt: number;
47
47
  isDraft?: boolean;
48
48
  };
49
+ export type WhatsappTemplateButtonTypes = 'QUICK_REPLY' | 'URL' | 'PHONE_NUMBER' | 'COPY_CODE';
49
50
  export type CreateTemplateType = {
50
51
  /** Data */
51
52
  headerType: HEADER_TYPES;
@@ -72,6 +73,7 @@ export type CreateTemplateType = {
72
73
  placeholder?: string;
73
74
  };
74
75
  };
76
+ allButtons: WhatsappPreviewButtonType[];
75
77
  meta: {
76
78
  name: string;
77
79
  category?: string;
@@ -172,6 +174,14 @@ export type WhatsappLikePreviewTypes = {
172
174
  children?: React.ReactNode;
173
175
  bodyVariableList?: variableType[];
174
176
  headerVariableList?: variableType[];
177
+ buttons?: WhatsappPreviewButtonType[];
178
+ };
179
+ export type WhatsappPreviewButtonType = {
180
+ type: WhatsappTemplateButtonTypes;
181
+ text: string;
182
+ placeholder?: string;
183
+ flowId: string;
184
+ flowName: string;
175
185
  };
176
186
  export type WhatsappMeta = {
177
187
  containerStyle?: React.CSSProperties | undefined;
@@ -224,7 +234,8 @@ export type TEMPLATE_BUTTON = {
224
234
  export declare enum BUTTON_TYPE {
225
235
  QUICK_REPLY = "QUICK_REPLY",
226
236
  URL = "URL",
227
- PHONE_NUMBER = "PHONE_NUMBER"
237
+ PHONE_NUMBER = "PHONE_NUMBER",
238
+ COPY_CODE = "COPY_CODE"
228
239
  }
229
240
  export declare enum POD {
230
241
  CHATBOT = "CHATBOT",
@@ -1 +1 @@
1
- var N,R;!function(N){N.QUICK_REPLY="QUICK_REPLY",N.URL="URL",N.PHONE_NUMBER="PHONE_NUMBER"}(N||(N={})),function(N){N.CHATBOT="CHATBOT",N.GROWTH="GROWTH",N.CAMPAIGN="CAMPAIGN",N.CRM="CRM",N.INTEGRATIONS="INTEGRATIONS",N.OPENAI="OPENAI",N.DM="DM",N.FRONTEND="FRONTEND"}(R||(R={}));export{N as BUTTON_TYPE,R as POD};
1
+ var N,O;!function(N){N.QUICK_REPLY="QUICK_REPLY",N.URL="URL",N.PHONE_NUMBER="PHONE_NUMBER",N.COPY_CODE="COPY_CODE"}(N||(N={})),function(N){N.CHATBOT="CHATBOT",N.GROWTH="GROWTH",N.CAMPAIGN="CAMPAIGN",N.CRM="CRM",N.INTEGRATIONS="INTEGRATIONS",N.OPENAI="OPENAI",N.DM="DM",N.FRONTEND="FRONTEND"}(O||(O={}));export{N as BUTTON_TYPE,O as POD};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bikdotai/bik-component-library",
3
- "version": "0.0.406-beta.2",
3
+ "version": "0.0.407-beta.1",
4
4
  "description": "Bik Component Library",
5
5
  "repository": {
6
6
  "type": "git",
@@ -1,2 +0,0 @@
1
- import { CHANNEL_TYPE } from "../../template-preview/models/Channels";
2
- export declare const getPreviewWidth: (channel: CHANNEL_TYPE) => 236 | 300 | 360;
@@ -1 +0,0 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../../template-preview/models/Channels.js");exports.getPreviewWidth=r=>{switch(r){case e.CHANNEL_TYPE.WHATSAPP:return 236;case e.CHANNEL_TYPE.SMS:return 300;case e.CHANNEL_TYPE.EMAIL:return 360;default:return 300}};
@@ -1,2 +0,0 @@
1
- import { CHANNEL_TYPE } from "../../template-preview/models/Channels";
2
- export declare const getPreviewWidth: (channel: CHANNEL_TYPE) => 236 | 300 | 360;
@@ -1 +0,0 @@
1
- import{CHANNEL_TYPE as e}from"../../template-preview/models/Channels.js";const r=r=>{switch(r){case e.WHATSAPP:return 236;case e.SMS:return 300;case e.EMAIL:return 360;default:return 300}};export{r as getPreviewWidth};