@bikdotai/bik-component-library 0.0.359-beta.30 → 0.0.359-beta.4

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 (55) hide show
  1. package/dist/cjs/components/bik-layout/MockMenus.d.ts +0 -1
  2. package/dist/cjs/components/input-with-vars/InputWithVariables.d.ts +5 -13
  3. package/dist/cjs/components/input-with-vars/InputWithVariables.js +2 -2
  4. package/dist/cjs/components/template-context-mapper/TemplateContextMapper.d.ts +1 -2
  5. package/dist/cjs/components/template-context-mapper/TemplateContextMapper.js +1 -1
  6. package/dist/cjs/components/template-context-mapper/modalElements/Body.d.ts +0 -1
  7. package/dist/cjs/components/template-context-mapper/modalElements/Body.js +2 -2
  8. package/dist/cjs/components/template-context-mapper/modalElements/EditMediaV2.d.ts +0 -3
  9. package/dist/cjs/components/template-context-mapper/modalElements/EditMediaV2.js +2 -2
  10. package/dist/cjs/components/template-context-mapper/modalElements/EditWhatsAppTemplateMediaV2.d.ts +0 -2
  11. package/dist/cjs/components/template-context-mapper/modalElements/EditWhatsAppTemplateMediaV2.js +1 -1
  12. package/dist/cjs/components/template-context-mapper/modalElements/EditWhatsAppTemplateV2.d.ts +1 -2
  13. package/dist/cjs/components/template-context-mapper/modalElements/EditWhatsAppTemplateV2.js +1 -1
  14. package/dist/cjs/components/template-context-mapper/modalElements/MobilePreview.js +3 -3
  15. package/dist/cjs/components/template-context-mapper/modalElements/TemplateSelectModalContent.d.ts +1 -2
  16. package/dist/cjs/components/template-context-mapper/modalElements/TemplateSelectModalContent.js +1 -1
  17. package/dist/cjs/components/template-context-mapper/modalElements/VariableConnector.d.ts +0 -1
  18. package/dist/cjs/components/template-context-mapper/modalElements/VariableConnector.js +3 -3
  19. package/dist/cjs/components/template-context-mapper/modalElements/VariableConnectorWhatsApp.d.ts +2 -1
  20. package/dist/cjs/components/template-context-mapper/modalElements/VariableConnectorWhatsApp.js +1 -1
  21. package/dist/cjs/components/template-context-mapper/modalElements/WhatsAppTemplateCardButtonV2.js +1 -1
  22. package/dist/cjs/components/template-preview/constants/regexPatterns.js +1 -1
  23. package/dist/cjs/components/template-preview/helpers/TemplateCreatorHelper.js +1 -1
  24. package/dist/cjs/components/template-preview/models/WhatsAppTemplate.d.ts +0 -1
  25. package/dist/cjs/components/template-preview/utils/TemplateHelperUtils.js +1 -1
  26. package/dist/esm/components/bik-layout/MockMenus.d.ts +0 -1
  27. package/dist/esm/components/input-with-vars/InputWithVariables.d.ts +5 -13
  28. package/dist/esm/components/input-with-vars/InputWithVariables.js +3 -3
  29. package/dist/esm/components/template-context-mapper/TemplateContextMapper.d.ts +1 -2
  30. package/dist/esm/components/template-context-mapper/TemplateContextMapper.js +1 -1
  31. package/dist/esm/components/template-context-mapper/modalElements/Body.d.ts +0 -1
  32. package/dist/esm/components/template-context-mapper/modalElements/Body.js +1 -1
  33. package/dist/esm/components/template-context-mapper/modalElements/EditMediaV2.d.ts +0 -3
  34. package/dist/esm/components/template-context-mapper/modalElements/EditMediaV2.js +2 -2
  35. package/dist/esm/components/template-context-mapper/modalElements/EditWhatsAppTemplateMediaV2.d.ts +0 -2
  36. package/dist/esm/components/template-context-mapper/modalElements/EditWhatsAppTemplateMediaV2.js +1 -1
  37. package/dist/esm/components/template-context-mapper/modalElements/EditWhatsAppTemplateV2.d.ts +1 -2
  38. package/dist/esm/components/template-context-mapper/modalElements/EditWhatsAppTemplateV2.js +1 -1
  39. package/dist/esm/components/template-context-mapper/modalElements/MobilePreview.js +3 -3
  40. package/dist/esm/components/template-context-mapper/modalElements/TemplateSelectModalContent.d.ts +1 -2
  41. package/dist/esm/components/template-context-mapper/modalElements/TemplateSelectModalContent.js +1 -1
  42. package/dist/esm/components/template-context-mapper/modalElements/VariableConnector.d.ts +0 -1
  43. package/dist/esm/components/template-context-mapper/modalElements/VariableConnector.js +2 -2
  44. package/dist/esm/components/template-context-mapper/modalElements/VariableConnectorWhatsApp.d.ts +2 -1
  45. package/dist/esm/components/template-context-mapper/modalElements/VariableConnectorWhatsApp.js +1 -1
  46. package/dist/esm/components/template-context-mapper/modalElements/WhatsAppTemplateCardButtonV2.js +1 -1
  47. package/dist/esm/components/template-preview/constants/regexPatterns.js +1 -1
  48. package/dist/esm/components/template-preview/helpers/TemplateCreatorHelper.js +1 -1
  49. package/dist/esm/components/template-preview/models/WhatsAppTemplate.d.ts +0 -1
  50. package/dist/esm/components/template-preview/utils/TemplateHelperUtils.js +1 -1
  51. package/package.json +1 -1
  52. package/dist/cjs/components/template-context-mapper/modalElements/EditMediaModal.d.ts +0 -11
  53. package/dist/cjs/components/template-context-mapper/modalElements/EditMediaModal.js +0 -1
  54. package/dist/esm/components/template-context-mapper/modalElements/EditMediaModal.d.ts +0 -11
  55. package/dist/esm/components/template-context-mapper/modalElements/EditMediaModal.js +0 -1
@@ -1,4 +1,3 @@
1
- /// <reference types="react" />
2
1
  export declare const Menus: ({
3
2
  displayName: string;
4
3
  key: number;
@@ -1,18 +1,10 @@
1
- /// <reference types="react" />
2
- import { Variable } from '../add-variableV2/AddVariableV2';
3
1
  import { SelectedVariable } from '../add-variableV2/types';
4
- interface InputWithVariablesProps {
2
+ export declare const InputWithVariables: (props: {
5
3
  variablesList: any;
6
- onChange: (val: SelectedVariable | Variable) => void;
7
- onBlur?: (e: Event, val?: SelectedVariable | Variable) => void;
4
+ onChange: (val: SelectedVariable) => void;
8
5
  addVarBoxRight: string;
9
6
  allowMix: boolean;
10
7
  prevVariable: SelectedVariable;
11
- showHelp?: boolean;
12
- onlyVariables?: boolean;
13
- showSideVariablePanel?: boolean;
14
- placeHolder?: string;
15
- showAddButton?: boolean;
16
- }
17
- export declare const InputWithVariables: React.FC<InputWithVariablesProps>;
18
- export {};
8
+ showHelp?: boolean | undefined;
9
+ onlyVariables?: boolean | undefined;
10
+ }) => import("react/jsx-runtime").JSX.Element;
@@ -1,6 +1,6 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),a=require("../../assets/icons/PlusIcon.js"),l=require("react"),r=require("styled-components"),i=require("uuid"),t=require("../../constants/Theme.js"),d=require("../add-variableV2/AddVariableV2SideModal.js"),s=require("../add-variableV2/AddVariableV2.js"),u=require("../add-variableV2/AddVariableBox.styled.js"),o=require("../input/Input.js"),n=require("../TypographyStyle.js");function c(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}const v=c(r).default.div`
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),a=require("../../assets/icons/PlusIcon.js"),l=require("react"),r=require("styled-components"),i=require("uuid"),t=require("../../constants/Theme.js"),s=require("../add-variableV2/AddVariableBox.styled.js"),d=require("../add-variableV2/AddVariableV2.js"),u=require("../input/Input.js"),o=require("../TypographyStyle.js");function n(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}const c=n(r).default.div`
2
2
  margin-bottom: 32px;
3
3
  input {
4
4
  color: ${e=>e.isVar?t.COLORS.stroke.brand:"black"};
5
5
  }
6
- `;exports.InputWithVariables=r=>{let{addVarBoxRight:t,allowMix:c,onChange:b,prevVariable:V,variablesList:h,onBlur:p,onlyVariables:g,placeHolder:j,showAddButton:x=!0,showHelp:T,showSideVariablePanel:y}=r;const f=l.useRef(null),[S,m]=l.useState(!1),[q]=l.useState(i.v4()),[w,A]=l.useState(),[C,O]=l.useState(V),[B,k]=l.useState(!1),[I,N]=l.useState(!1);return l.useEffect((()=>{w&&w.actualValue&&O(c?e=>({actualValue:e.actualValue+w.actualValue,variableType:"string"}):e=>({actualValue:w.actualValue,variableType:w.variableType,needsFetching:w.needsFetching}))}),[w]),l.useEffect((()=>{b(C)}),[C]),e.jsxs(e.Fragment,{children:[e.jsxs(v,Object.assign({isVar:/^{{.*}}$/.test(C.actualValue)},{children:[e.jsx(o.Input,{id:q,ref:f,skipFocus:!0,textControl:!0,isActive:S,value:C.actualValue,validate:e=>[!0,""],errorMessage:"",placeholder:j||"Add a value",onChangeText:function(e,a){if(g){const e=(null==a?void 0:a.keyCode)||(null==a?void 0:a.charCode);8!=e&&46!=e||O({actualValue:"",variableType:"string"})}else O(c?{actualValue:e,variableType:"string"}:{actualValue:e.replace(/{{.*}}/,""),variableType:"string"})},onReferenceInit:()=>{},onFocus:e=>{var a;m(!0),N(!0),"Search..."!==(null===(a=e.relatedTarget)||void 0===a?void 0:a.placeholder)||B||k(!0)},onBlur:e=>{var a,l,r,i,t,d,s;null==p||p(e,C),"addVar"===(null===(a=e.relatedTarget)||void 0===a?void 0:a.id)||"varList"===(null===(l=e.relatedTarget)||void 0===l?void 0:l.id)||(null===(i=null===(r=e.relatedTarget)||void 0===r?void 0:r.className)||void 0===i?void 0:i.includes("exlualr0"))||(null===(d=null===(t=e.relatedTarget)||void 0===t?void 0:t.className)||void 0===d?void 0:d.includes("sc-dZoequ "))?(f.current&&f.current.focus(),m(!0)):"Search..."===(null===(s=e.relatedTarget)||void 0===s?void 0:s.placeholder)?m(!0):(m(!1),k(!1),N(!1))}}),e.jsxs("div",Object.assign({style:{display:"flex",flexDirection:"row",justifyContent:"space-between"}},{children:[C.actualValue&&T?e.jsx("div",Object.assign({style:{marginTop:4}},{children:e.jsx(n.BodyCaption,{children:`This value is of type ${C.variableType}`})})):e.jsx("div",{}),x&&I&&e.jsx(u.AddVariableStyled,Object.assign({right:t,id:"addVar",onClick:()=>{k(!B)}},{children:e.jsxs("div",Object.assign({className:"add"},{children:[e.jsx(a.default,{color:"white"}),e.jsx("div",Object.assign({className:"variable"},{children:"Add variable"}))]}))}))]})),!y&&B&&e.jsx(s.AddVariableV2,{data:h,showVariable:!0,setShowVariable:()=>{k(!1)},variableValue:w,setVariableValue:A,placeholder:"",pickerSize:"large",enableVariable:!0,selectWithTypes:!0,onSearchBlur:e=>{var a,l,r,i,t,d;"varList"===(null===(a=e.relatedTarget)||void 0===a?void 0:a.id)||(null===(r=null===(l=e.relatedTarget)||void 0===l?void 0:l.className)||void 0===r?void 0:r.includes("exlualr0"))||(null===(t=null===(i=e.relatedTarget)||void 0===i?void 0:i.className)||void 0===t?void 0:t.includes("sc-dZoequ "))?f.current.focus():"Enter here"===(null===(d=e.relatedTarget)||void 0===d?void 0:d.placeholder)?e.relatedTarget.id!==q&&(k(!1),N(!1),m(!1)):(k(!1),N(!1),m(!1))}})]})),y&&B&&e.jsx(d.AddVariableV2SideModal,{zIndex:2e3,data:h,showVariable:B,setShowVariable:k,placeholder:"Add a variable",customTrigger:e=>{O(e)}})]})};
6
+ `;exports.InputWithVariables=r=>{const t=l.useRef(null),[n,v]=l.useState(!1),[b]=l.useState(i.v4()),[p,V]=l.useState(),[g,h]=l.useState(r.prevVariable),[j,x]=l.useState(!1),[y,T]=l.useState(!1);return l.useEffect((()=>{p&&p.actualValue&&(r.allowMix?h((e=>({actualValue:e.actualValue+p.actualValue,variableType:"string"}))):h((e=>({actualValue:p.actualValue,variableType:p.variableType,needsFetching:p.needsFetching}))))}),[p]),l.useEffect((()=>{r.onChange(g)}),[g]),e.jsxs(c,Object.assign({isVar:/^{{.*}}$/.test(g.actualValue)},{children:[e.jsx(u.Input,{id:b,ref:t,skipFocus:!0,textControl:!0,isActive:n,value:g.actualValue,validate:e=>[!0,""],errorMessage:"",placeholder:"Add a value",onChangeText:function(e,a){if(r.onlyVariables){const e=(null==a?void 0:a.keyCode)||(null==a?void 0:a.charCode);8!=e&&46!=e||h({actualValue:"",variableType:"string"})}else r.allowMix?h({actualValue:e,variableType:"string"}):h({actualValue:e.replace(/{{.*}}/,""),variableType:"string"})},onReferenceInit:()=>{},onFocus:e=>{var a;v(!0),T(!0),"Search..."!==(null===(a=e.relatedTarget)||void 0===a?void 0:a.placeholder)||j||x(!0)},onBlur:e=>{var a,l,r,i,s,d,u;"addVar"===(null===(a=e.relatedTarget)||void 0===a?void 0:a.id)||"varList"===(null===(l=e.relatedTarget)||void 0===l?void 0:l.id)||(null===(i=null===(r=e.relatedTarget)||void 0===r?void 0:r.className)||void 0===i?void 0:i.includes("exlualr0"))||(null===(d=null===(s=e.relatedTarget)||void 0===s?void 0:s.className)||void 0===d?void 0:d.includes("sc-dZoequ "))?(t.current&&t.current.focus(),v(!0)):"Search..."===(null===(u=e.relatedTarget)||void 0===u?void 0:u.placeholder)?v(!0):(v(!1),x(!1),T(!1))}}),e.jsxs("div",Object.assign({style:{display:"flex",flexDirection:"row",justifyContent:"space-between"}},{children:[g.actualValue&&r.showHelp?e.jsx("div",Object.assign({style:{marginTop:4}},{children:e.jsx(o.BodyCaption,{children:`This value is of type ${g.variableType}`})})):e.jsx("div",{}),y&&e.jsx(s.AddVariableStyled,Object.assign({right:r.addVarBoxRight,id:"addVar",onClick:()=>{x(!j)}},{children:e.jsxs("div",Object.assign({className:"add"},{children:[e.jsx(a.default,{color:"white"}),e.jsx("div",Object.assign({className:"variable"},{children:"Add variable"}))]}))}))]})),j&&e.jsx(d.AddVariableV2,{data:r.variablesList,showVariable:!0,setShowVariable:()=>{x(!1)},variableValue:p,setVariableValue:V,placeholder:"",pickerSize:"large",enableVariable:!0,selectWithTypes:!0,onSearchBlur:e=>{var a,l,r,i,s,d;"varList"===(null===(a=e.relatedTarget)||void 0===a?void 0:a.id)||(null===(r=null===(l=e.relatedTarget)||void 0===l?void 0:l.className)||void 0===r?void 0:r.includes("exlualr0"))||(null===(s=null===(i=e.relatedTarget)||void 0===i?void 0:i.className)||void 0===s?void 0:s.includes("sc-dZoequ "))?t.current.focus():"Enter here"===(null===(d=e.relatedTarget)||void 0===d?void 0:d.placeholder)?e.relatedTarget.id!==b&&(x(!1),T(!1),v(!1)):(x(!1),T(!1),v(!1))}})]}))};
@@ -20,10 +20,9 @@ export interface TemplateContextMapperProps {
20
20
  zIndex?: number;
21
21
  showVariableModal?: boolean;
22
22
  variableList?: VariableListInterfaceV2[];
23
- variableListForImage?: VariableListInterfaceV2[];
24
23
  onBackPress?: () => void;
25
24
  discountCode?: string;
26
25
  setDiscountCode?: (code: string) => void;
27
26
  enabledCustomText?: boolean;
28
27
  }
29
- export declare const TemplateContextMapper: ({ selectedTemplate, closeDialog, showVariableMapping, channel, htmlContent, templateVariables, onTemplateSelect, globalPlaceholders, showOnlyContent, whatsappSpecificPickerMeta, zIndex, showVariableModal, variableList, discountCode, setDiscountCode, onBackPress, enabledCustomText, variableListForImage, }: TemplateContextMapperProps) => import("react/jsx-runtime").JSX.Element;
28
+ export declare const TemplateContextMapper: ({ selectedTemplate, closeDialog, showVariableMapping, channel, htmlContent, templateVariables, onTemplateSelect, globalPlaceholders, showOnlyContent, whatsappSpecificPickerMeta, zIndex, showVariableModal, variableList, discountCode, setDiscountCode, onBackPress, enabledCustomText, }: TemplateContextMapperProps) => import("react/jsx-runtime").JSX.Element;
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),t=require("react"),l=require("../../utils/StringUtils.js"),a=require("../modals/styledModal.js"),s=require("../template-preview/models/Channels.js"),o=require("./context/templateModalContext.js"),i=require("./modalElements/Footer.js"),r=require("./modalElements/TemplateSelectModalContent.js"),n=require("./utils/convertPlaceholdersToBikDropdown.js");exports.TemplateContextMapper=d=>{let{selectedTemplate:c,closeDialog:u,showVariableMapping:p,channel:m,htmlContent:h,templateVariables:g,onTemplateSelect:b,globalPlaceholders:v,showOnlyContent:C,whatsappSpecificPickerMeta:S,zIndex:T,showVariableModal:j,variableList:x,discountCode:M,setDiscountCode:E,onBackPress:P,enabledCustomText:L,variableListForImage:f}=d;var w,q;t.useEffect((()=>{I(h)}),[h]);const[y,A]=t.useState(m===s.CHANNEL_TYPE.EMAIL?"desktop":"mobile"),[N,I]=t.useState(h),[k,D]=t.useState(!1),[V,_]=t.useState(c),[H,O]=t.useState(null!=g?g:[]),[F,B]=t.useState(!1);const Y=t.useMemo((()=>n.convertPlaceholdersToBikDropdown(v)),[v]);return e.jsx(o.TemplateModalContext.Provider,Object.assign({value:{template:V,setTemplate:_,device:y,setDevice:A,display_content:N,setDisplayContent:I,originalVariableList:H,setOriginalVariableList:O,isError:k,setIsError:D,channel:m,globalNormalizedPlaceholders:Y,templateSelectionTriggered:F,setTemplateSelectionTriggered:B,enabledCustomText:L}},{children:C?e.jsx(r.default,{channel:s.CHANNEL_TYPE.EMAIL,hideHeader:!0}):e.jsxs(a.StyledModal,Object.assign({zIndex:T,centralContainerStyles:{width:m===s.CHANNEL_TYPE.EMAIL&&p?1e3:650},open:!0,onClose:()=>{null==u||u()},headingTitle:null==V?void 0:V.label,headingSubtitle:m===s.CHANNEL_TYPE.WHATSAPP?`${l.default.capitaliseFirstLetterOfString(null!==(w=null==V?void 0:V.category)&&void 0!==w?w:"")} • ${null!==(q=null==V?void 0:V.templateCategory)&&void 0!==q?q:""}`:"",onBackPress:()=>{null==P||P()}},{children:[e.jsx(r.default,{showVariableMapping:p,channel:m,whatsappSpecificPickerMeta:S,showVariableModal:j,variableList:x,discountCode:M,setDiscountCode:E,variableListForImage:f&&(null==f?void 0:f.length)>0?f:x}),b?e.jsx(i.default,{onSelect:function(){const e=null==b?void 0:b(V,H,null!=N?N:"");e?D(!!e):B(!0)}}):e.jsx(e.Fragment,{})]}))}))};
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),t=require("react"),l=require("../../utils/StringUtils.js"),a=require("../modals/styledModal.js"),o=require("../template-preview/models/Channels.js"),s=require("./context/templateModalContext.js"),i=require("./modalElements/Footer.js"),r=require("./modalElements/TemplateSelectModalContent.js"),n=require("./utils/convertPlaceholdersToBikDropdown.js");exports.TemplateContextMapper=d=>{let{selectedTemplate:c,closeDialog:u,showVariableMapping:p,channel:m,htmlContent:h,templateVariables:g,onTemplateSelect:C,globalPlaceholders:b,showOnlyContent:S,whatsappSpecificPickerMeta:T,zIndex:v,showVariableModal:j,variableList:x,discountCode:M,setDiscountCode:P,onBackPress:E,enabledCustomText:L}=d;var f,w;t.useEffect((()=>{A(h)}),[h]);const[N,q]=t.useState(m===o.CHANNEL_TYPE.EMAIL?"desktop":"mobile"),[y,A]=t.useState(h),[k,D]=t.useState(!1),[V,_]=t.useState(c),[H,I]=t.useState(null!=g?g:[]),[O,z]=t.useState(!1);const B=t.useMemo((()=>n.convertPlaceholdersToBikDropdown(b)),[b]);return console.log("globalNormalizedPlaceholders",B),e.jsx(s.TemplateModalContext.Provider,Object.assign({value:{template:V,setTemplate:_,device:N,setDevice:q,display_content:y,setDisplayContent:A,originalVariableList:H,setOriginalVariableList:I,isError:k,setIsError:D,channel:m,globalNormalizedPlaceholders:B,templateSelectionTriggered:O,setTemplateSelectionTriggered:z,enabledCustomText:L}},{children:S?e.jsx(r.default,{channel:o.CHANNEL_TYPE.EMAIL,hideHeader:!0}):e.jsxs(a.StyledModal,Object.assign({zIndex:v,centralContainerStyles:{width:m===o.CHANNEL_TYPE.EMAIL&&p?1e3:650},open:!0,onClose:()=>{null==u||u()},headingTitle:null==V?void 0:V.label,headingSubtitle:m===o.CHANNEL_TYPE.WHATSAPP?`${l.default.capitaliseFirstLetterOfString(null!==(f=null==V?void 0:V.category)&&void 0!==f?f:"")} • ${null!==(w=null==V?void 0:V.templateCategory)&&void 0!==w?w:""}`:"",onBackPress:()=>{null==E||E()}},{children:[e.jsx(r.default,{showVariableMapping:p,channel:m,whatsappSpecificPickerMeta:T,showVariableModal:j,variableList:x,discountCode:M,setDiscountCode:P}),C?e.jsx(i.default,{onSelect:function(){const e=null==C?void 0:C(V,H,null!=y?y:"");e?D(!!e):z(!0)}}):e.jsx(e.Fragment,{})]}))}))};
@@ -6,7 +6,6 @@ export interface BodyProps {
6
6
  whatsappSpecificPickerMeta?: WhatsAppPickerMeta;
7
7
  showVariableModal?: boolean;
8
8
  variableList?: VariableListInterfaceV2[];
9
- variableListForImage?: VariableListInterfaceV2[];
10
9
  discountCode?: string;
11
10
  setDiscountCode?: (code: string) => void;
12
11
  }
@@ -9,9 +9,9 @@
9
9
  overflow-y: 'auto';
10
10
  padding-bottom: 24px;
11
11
  border-left: ${o.COLORS.stroke.primary} 1px solid;
12
- `,g=h.default.div`
12
+ `,x=h.default.div`
13
13
  padding: ${e=>e.showOnlyContent?"16px 14px":"16px 32px"};
14
14
  flex: 1;
15
15
  height: 475px;
16
16
  overflow-y: auto;
17
- `;exports.default=l=>{const{showVariableMapping:p,showOnlyContent:h,whatsappSpecificPickerMeta:x,showVariableModal:v,variableList:b,discountCode:j,setDiscountCode:w,variableListForImage:C}=l,E=t.useRef(),y=t.useRef(),{device:L,display_content:P,channel:T,template:M,setTemplate:_}=i.useTemplateModalContext();const A=e=>{let t=0;for(;e;)t+=e.offsetTop,e=e.offsetParent;return t};return e.jsxs(m,{children:[e.jsx(g,Object.assign({showOnlyContent:h,showVariableMapping:p},{children:"mobile"===L?e.jsx(u.default,{ref:y,display_content:null!=P?P:"",channel:T,template:M}):T!==n.CHANNEL_TYPE.MESSAGE?e.jsx(s.default,{ref:E,channel:T,display_content:null!=P?P:""}):e.jsx(e.Fragment,{})})),p&&e.jsx(f,Object.assign({channel:T},{children:T!==n.CHANNEL_TYPE.WHATSAPP?e.jsx(c.default,{onFocus:T===n.CHANNEL_TYPE.EMAIL?function(e){var t,l,i;const s=null===document||void 0===document?void 0:document.getElementById("mobile"===L?"template_html_mobile":"template_html_desktop"),d=a.getVariableNameForEmailByIndex(e+1),u=T===n.CHANNEL_TYPE.EMAIL?null===(t=null==s?void 0:s.contentWindow)||void 0===t?void 0:t.document.getElementById(d):document.getElementById(d),c=A(u),p=null==u?void 0:u.offsetLeft;"desktop"===L?c&&E.current&&(null===(l=null==s?void 0:s.contentWindow)||void 0===l||l.scrollTo(null!=p?p:0,c),r.highlightFor(d,o.COLORS.background.warning.light,2,T,L)):c&&y.current&&(null===(i=null==s?void 0:s.contentWindow)||void 0===i||i.scrollTo(null!=p?p:0,c),r.highlightFor(d,o.COLORS.background.warning.light,2,T,L))}:void 0,showVariableModal:v,variableList:b,discountCode:j,setDiscountCode:w}):e.jsx(d.default,{whatsappSpecificPickerMeta:x,template:M,onTemplateChange:e=>{null==_||_(e)},showVariableModal:v,variableList:b,variableListForImage:C})}))]})};
17
+ `;exports.default=l=>{const{showVariableMapping:p,showOnlyContent:h,whatsappSpecificPickerMeta:g,showVariableModal:v,variableList:b,discountCode:j,setDiscountCode:w}=l,C=t.useRef(),E=t.useRef(),{device:y,display_content:P,channel:T,template:L,setTemplate:M}=i.useTemplateModalContext();const _=e=>{let t=0;for(;e;)t+=e.offsetTop,e=e.offsetParent;return t};return e.jsxs(m,{children:[e.jsx(x,Object.assign({showOnlyContent:h,showVariableMapping:p},{children:"mobile"===y?e.jsx(u.default,{ref:E,display_content:null!=P?P:"",channel:T,template:L}):T!==n.CHANNEL_TYPE.MESSAGE?e.jsx(s.default,{ref:C,channel:T,display_content:null!=P?P:""}):e.jsx(e.Fragment,{})})),p&&e.jsx(f,Object.assign({channel:T},{children:T!==n.CHANNEL_TYPE.WHATSAPP?e.jsx(c.default,{onFocus:T===n.CHANNEL_TYPE.EMAIL?function(e){var t,l,i;const s=null===document||void 0===document?void 0:document.getElementById("mobile"===y?"template_html_mobile":"template_html_desktop"),d=a.getVariableNameForEmailByIndex(e+1),u=T===n.CHANNEL_TYPE.EMAIL?null===(t=null==s?void 0:s.contentWindow)||void 0===t?void 0:t.document.getElementById(d):document.getElementById(d),c=_(u),p=null==u?void 0:u.offsetLeft;"desktop"===y?c&&C.current&&(null===(l=null==s?void 0:s.contentWindow)||void 0===l||l.scrollTo(null!=p?p:0,c),r.highlightFor(d,o.COLORS.background.warning.light,2,T,y)):c&&E.current&&(null===(i=null==s?void 0:s.contentWindow)||void 0===i||i.scrollTo(null!=p?p:0,c),r.highlightFor(d,o.COLORS.background.warning.light,2,T,y))}:void 0,showVariableModal:v,variableList:b,discountCode:j,setDiscountCode:w}):e.jsx(d.default,{whatsappSpecificPickerMeta:g,template:L,onTemplateChange:e=>{null==M||M(e)},showVariableModal:v,variableList:b})}))]})};
@@ -1,14 +1,11 @@
1
- /// <reference types="react" />
2
1
  import { HEADER_TYPES } from "../../template-preview/models/TemplateMeta";
3
2
  export interface EditMediaV2Props {
4
3
  imageName: string[];
5
- selectedVariable?: string;
6
4
  errorSecondaryText?: string;
7
5
  error?: string;
8
6
  isLoading?: boolean;
9
7
  mediaType?: HEADER_TYPES;
10
8
  handleImageChange?: () => void;
11
- setOpenEditMedia?: React.Dispatch<React.SetStateAction<boolean>>;
12
9
  }
13
10
  declare const EditMediaV2: (props: EditMediaV2Props) => import("react/jsx-runtime").JSX.Element;
14
11
  export default EditMediaV2;
@@ -1,8 +1,8 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),t=require("../../../assets/icons/document_pdf.svg.js"),i=require("../../../assets/icons/edit.svg.js"),s=require("../../../assets/icons/refresh.svg.js"),r=require("../../../assets/icons/video_camcorder.svg.js"),n=require("styled-components"),o=require("../../spinner/Spinner.js"),l=require("../../template-preview/models/TemplateMeta.js"),d=require("../../TypographyStyle.js"),a=require("../../../utils/StringUtils.js"),c=require("../../../constants/Theme.js"),u=require("./EditMediaV2.style.js");function h(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}const g=h(n).default.div`
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),t=require("../../../assets/icons/document_pdf.svg.js"),i=require("../../../assets/icons/edit.svg.js"),s=require("../../../assets/icons/refresh.svg.js"),r=require("../../../assets/icons/video_camcorder.svg.js"),n=require("styled-components"),o=require("../../spinner/Spinner.js"),l=require("../../template-preview/models/TemplateMeta.js"),d=require("../../TypographyStyle.js"),a=require("../../../utils/StringUtils.js"),c=require("../../../constants/Theme.js"),h=require("./EditMediaV2.style.js");function g(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}const j=g(n).default.div`
2
2
  padding-left: 14px;
3
3
  padding-right: 6px;
4
4
  width: 44px;
5
5
  height: 24px;
6
6
  border-left: 1px solid ${c.COLORS.stroke.primary};
7
7
  cursor: pointer;
8
- `;exports.default=n=>{const{imageName:h,error:j,isLoading:p,mediaType:x,handleImageChange:O,selectedVariable:y,setOpenEditMedia:m}=n,f=null==h?void 0:h[0].split("/"),v=null==f?void 0:f[f.length-1];return e.jsxs(u.Container,{children:[e.jsx(u.ImageContainer,Object.assign({error:!!j,onClick:j?O:void 0},{children:j?e.jsx(s.default,{color:c.COLORS.content.brand,width:32,height:32}):p?e.jsx(o.Spinner,{size:"small"}):x===l.HEADER_TYPES.IMAGE?e.jsx("img",{alt:"",src:null==h?void 0:h[0],style:{width:"100%",height:"56px",borderRadius:8,objectFit:"cover"}}):x===l.HEADER_TYPES.VIDEO?e.jsx(r.default,{width:18,height:22,color:c.COLORS.content.placeholder}):e.jsx(t.default,{width:18,height:22,color:c.COLORS.content.placeholder})})),e.jsxs(u.RightComponent,{children:[e.jsx("div",Object.assign({style:{flex:1}},{children:h&&j?e.jsx(e.Fragment,{}):p?e.jsx(d.BodyCaption,Object.assign({style:{marginLeft:8}},{children:"Your media is getting loaded..."})):e.jsx(d.BodySecondary,Object.assign({style:{color:c.COLORS.content.primary,marginLeft:8}},{children:y||a.default.toCapitilize(null==x?void 0:x.toLowerCase())||v}))})),!!j&&e.jsxs("div",Object.assign({style:{display:"flex",flexDirection:"column",marginLeft:8}},{children:[e.jsxs(d.BodySecondary,Object.assign({style:{color:c.COLORS.content.negative}},{children:["Error loading this ",null==x?void 0:x.toLowerCase(),". Retry"]})),e.jsx(d.Caption,Object.assign({style:{color:c.COLORS.content.secondary}},{children:j}))]})),!j&&!p&&e.jsx(g,Object.assign({onClick:()=>null==m?void 0:m(!0),onKeyDown:()=>null==m?void 0:m(!0),role:"presentation"},{children:e.jsx(i.default,{width:24,height:24,color:c.COLORS.content.placeholder})}))]})]})};
8
+ `;exports.default=n=>{const{imageName:g,error:u,isLoading:p,mediaType:x,handleImageChange:y}=n,O=null==g?void 0:g[0].split("/"),m=null==O?void 0:O[O.length-1];return e.jsxs(h.Container,{children:[e.jsx(h.ImageContainer,Object.assign({error:!!u,onClick:u?y:void 0},{children:u?e.jsx(s.default,{color:c.COLORS.content.brand,width:32,height:32}):p?e.jsx(o.Spinner,{size:"small"}):x===l.HEADER_TYPES.IMAGE?e.jsx("img",{alt:"",src:null==g?void 0:g[0],style:{width:"100%",height:"56px",borderRadius:8,objectFit:"cover"}}):x===l.HEADER_TYPES.VIDEO?e.jsx(r.default,{width:18,height:22,color:c.COLORS.content.placeholder}):e.jsx(t.default,{width:18,height:22,color:c.COLORS.content.placeholder})})),e.jsxs(h.RightComponent,{children:[e.jsx("div",Object.assign({style:{flex:1}},{children:g&&u?e.jsx(e.Fragment,{}):p?e.jsx(d.BodyCaption,Object.assign({style:{marginLeft:8}},{children:"Your media is getting loaded..."})):e.jsx(d.BodySecondary,Object.assign({style:{color:c.COLORS.content.primary,marginLeft:8}},{children:a.default.toCapitilize(null==x?void 0:x.toLowerCase())||m}))})),!!u&&e.jsxs("div",Object.assign({style:{display:"flex",flexDirection:"column",marginLeft:8}},{children:[e.jsxs(d.BodySecondary,Object.assign({style:{color:c.COLORS.content.negative}},{children:["Error loading this ",null==x?void 0:x.toLowerCase(),". Retry"]})),e.jsx(d.Caption,Object.assign({style:{color:c.COLORS.content.secondary}},{children:u}))]})),!u&&!p&&e.jsx(j,Object.assign({onClick:y,onKeyDown:y,role:"presentation"},{children:e.jsx(i.default,{width:24,height:24,color:c.COLORS.content.placeholder})}))]})]})};
@@ -1,11 +1,9 @@
1
1
  import React from 'react';
2
- import { VariableListInterfaceV2 } from "../../add-variableV2";
3
2
  import { WhatsAppPickerMeta, WhatsAppTemplate } from "../../template-preview/models/WhatsAppTemplate";
4
3
  declare const EditMediaTemplateMediaV2: React.FC<{
5
4
  mediaComponent: WhatsAppTemplate['components'][0];
6
5
  template: WhatsAppTemplate;
7
6
  whatsappSpecificPickerMeta: WhatsAppPickerMeta;
8
7
  updateTemplateImageUrl(url: string, format: WhatsAppTemplate['components'][0]['format']): void;
9
- variableListForImage?: VariableListInterfaceV2[];
10
8
  }>;
11
9
  export default EditMediaTemplateMediaV2;
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../../../_virtual/_tslib.js"),t=require("react/jsx-runtime"),i=require("react"),a=require("../../helpers/FileUploaderHelper.js"),n=require("../../image-cropper/BikImageCropper.js");require("../../image-compress/ImageCompress.js"),require("../../states/StateComponent.js"),require("../../../constants/zindex.js"),require("../../modals/styledModal.js"),require("../../spinner/Spinner.js");var o=require("../../template-preview/models/TemplateMeta.js"),r=require("../context/templateModalContext.js"),l=require("./EditMediaModal.js"),s=require("./EditMediaV2.js");function d(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var c=d(i);exports.default=d=>{let{mediaComponent:p,template:u,updateTemplateImageUrl:m,whatsappSpecificPickerMeta:f,variableListForImage:v}=d;var E,g,j;const[h,M]=i.useState(void 0),[_,b]=i.useState(),[y,A]=i.useState(),[S,x]=i.useState(!1),C=c.default.createRef(),[I,T]=i.useState(!1),[q,R]=i.useState(""),{template:O,setTemplate:w}=r.useTemplateModalContext();let D;function H(){var e;(null===(e=null==C?void 0:C.current)||void 0===e?void 0:e.click)&&C.current.click()}function k(t){var i;return e.__awaiter(this,void 0,void 0,(function*(){const e=new a.FileUploaderHelper;if(t instanceof Blob){const a=e.validate(t);if(a)R(a),T(!1);else{const e=p.format===o.HEADER_TYPES.IMAGE,a=yield f.uploadMediaFiles({file:t,fileName:h,isImage:e});if(a.success){const[e]=t.type.split("/");m(null!==(i=a.url)&&void 0!==i?i:"","application"===e?o.HEADER_TYPES.DOCUMENT:o.HEADER_TYPES[e.toUpperCase()])}else R("An unknown technical error occured");T(!1)}}else R("An unknown technical error occured"),T(!1)}))}return D=p.format===o.HEADER_TYPES.IMAGE?"image/png, image/jpeg":p.format===o.HEADER_TYPES.VIDEO?"video/mp4":"application/pdf",t.jsxs(t.Fragment,{children:[t.jsx(l.default,{mediaComponentFormat:null!==(E=p.format)&&void 0!==E?E:o.HEADER_TYPES.IMAGE,uploadMedia:function(t){var i;return e.__awaiter(this,void 0,void 0,(function*(){if(R(""),A(""),x(!1),t)if(t.startsWith("https"))try{T(!0);const e=yield fetch(t),i=yield e.blob();yield k(i)}catch(e){R("An unknown technical error occurred")}else if(/^{{.*}}$/.test(t)){A(t);const e=Object.assign({},O);if(e.components){const t=null===(i=null==e?void 0:e.components)||void 0===i?void 0:i.findIndex((e=>{if("HEADER"===e.type&&"NONE"!==e.format&&"TEXT"!==e.format)return!0}));if(void 0!==t&&t>-1&&(null==e?void 0:e.components[t])){const i=Object.assign(Object.assign({},e.components[t]),{format:p.format,example:{header_handle:["https://jkfenner.com/wp-content/uploads/2019/11/default.jpg"]}}),a=[...e.components];a[t]=i,e.components=a}}e.mapping&&(e.mapping=Object.assign(Object.assign({},e.mapping),{header:[t]})),T(!1),null==w||w(Object.assign({},e))}else T(!1),R("Invalid URL or variable");else H()}))},variableListForImage:v||[],setOpenEditMedia:x,openEditMedia:S}),!!_&&t.jsx(n.BikImageCropper,{aspectRatio:15/8,src:_,onCropComplete:function(t){return e.__awaiter(this,void 0,void 0,(function*(){T(!1),R("");const e=yield fetch(t);k(yield e.blob()).then((()=>{b(void 0)}))}))},onCancel:()=>{console.log("cancel"),T(!1),b("")}}),t.jsx("input",{ref:C,style:{display:"none"},type:"file",onChange:function(e){var t;R(""),T(!0);const i=null===(t=e.target.files)||void 0===t?void 0:t[0];if(p.format===o.HEADER_TYPES.IMAGE){const e=new FileReader;b(""),M(""),e.onload=()=>{b(e.result),M(null==i?void 0:i.name)},i&&e.readAsDataURL(i)}else k(i)},accept:D}),t.jsx(s.default,{imageName:null!==(j=null===(g=null==p?void 0:p.example)||void 0===g?void 0:g.header_handle)&&void 0!==j?j:[],handleImageChange:H,mediaType:null==p?void 0:p.format,error:q,isLoading:I,setOpenEditMedia:x,selectedVariable:y})]})};
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../../../_virtual/_tslib.js"),t=require("react/jsx-runtime"),r=require("react"),i=require("../../helpers/FileUploaderHelper.js"),a=require("../../image-cropper/BikImageCropper.js");require("../../image-compress/ImageCompress.js"),require("../../states/StateComponent.js"),require("../../../constants/zindex.js"),require("../../modals/styledModal.js"),require("../../spinner/Spinner.js");var n=require("../../template-preview/models/TemplateMeta.js"),o=require("./EditMediaV2.js");function l(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var s=l(r);exports.default=l=>{let{mediaComponent:u,template:d,updateTemplateImageUrl:c,whatsappSpecificPickerMeta:p}=l;var m,f;const[v,E]=r.useState(void 0),[g,j]=r.useState(),_=s.default.createRef(),[h,S]=r.useState(!1),[q,A]=r.useState("");function C(t){var r;return e.__awaiter(this,void 0,void 0,(function*(){const e=new i.FileUploaderHelper;if(t instanceof Blob){const i=e.validate(t);if(i)A(i),S(!1);else{const e=u.format===n.HEADER_TYPES.IMAGE,i=yield p.uploadMediaFiles({file:t,fileName:v,isImage:e});if(i.success){const[e]=t.type.split("/");c(null!==(r=i.url)&&void 0!==r?r:"","application"===e?n.HEADER_TYPES.DOCUMENT:n.HEADER_TYPES[e.toUpperCase()])}else A("An unknown technical error occured");S(!1)}}else A("An unknown technical error occured"),S(!1)}))}let y;return y=u.format===n.HEADER_TYPES.IMAGE?"image/png, image/jpeg":u.format===n.HEADER_TYPES.VIDEO?"video/mp4":"application/pdf",t.jsxs(t.Fragment,{children:[!!g&&t.jsx(a.BikImageCropper,{aspectRatio:15/8,src:g,onCropComplete:function(t){return e.__awaiter(this,void 0,void 0,(function*(){S(!1),A("");const e=yield fetch(t);C(yield e.blob()).then((()=>{j(void 0)}))}))},onCancel:()=>{S(!1),j("")}}),t.jsx("input",{ref:_,style:{display:"none"},type:"file",onChange:function(e){var t;A(""),S(!0);const r=null===(t=e.target.files)||void 0===t?void 0:t[0];if(u.format===n.HEADER_TYPES.IMAGE){const e=new FileReader;j(""),E(""),e.onload=()=>{j(e.result),E(null==r?void 0:r.name)},r&&e.readAsDataURL(r)}else C(r)},accept:y}),t.jsx(o.default,{imageName:null!==(f=null===(m=null==u?void 0:u.example)||void 0===m?void 0:m.header_handle)&&void 0!==f?f:[],handleImageChange:function(){var e;(null===(e=null==_?void 0:_.current)||void 0===e?void 0:e.click)&&_.current.click()},mediaType:null==u?void 0:u.format,error:q,isLoading:h})]})};
@@ -8,7 +8,6 @@ export interface EditWhatsAppTemplateV2Props {
8
8
  onTemplateChange?: (template: WhatsAppTemplate | EmailTemplateType | SMSTemplateType) => void;
9
9
  showVariableModal?: boolean;
10
10
  variableList?: VariableListInterfaceV2[];
11
- variableListForImage?: VariableListInterfaceV2[];
12
11
  }
13
- declare const EditWhatsAppTemplateV2: ({ template, onTemplateChange, whatsappSpecificPickerMeta, showVariableModal, variableList, variableListForImage, }: EditWhatsAppTemplateV2Props) => import("react/jsx-runtime").JSX.Element;
12
+ declare const EditWhatsAppTemplateV2: ({ template, onTemplateChange, whatsappSpecificPickerMeta, showVariableModal, variableList, }: EditWhatsAppTemplateV2Props) => import("react/jsx-runtime").JSX.Element;
14
13
  export default EditWhatsAppTemplateV2;
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),t=require("../context/templateModalContext.js"),n=require("../utils/getDataFromTemplateComponent.js"),o=require("./EditMediaV2.style.js"),i=require("./EditWhatsAppTemplateMediaV2.js"),a=require("./VariableConnectorsPanel.js"),l=require("./VariableConnectorWhatsApp.js"),s=require("./VariableEditorHeader.js"),d=require("./WhatsAppTemplateCardButtonV2.js");exports.default=r=>{let{template:p,onTemplateChange:u,whatsappSpecificPickerMeta:c,showVariableModal:m,variableList:b,variableListForImage:v}=r;var g,h,f,j,x,T,O,y,C,E,V,w;const{originalVariableList:I}=t.useTemplateModalContext(),{descriptionComponents:L,urlBtns:B,qrbBtns:M,imageComponent:q,bodyVariables:R,headerVariables:A}=n.getAllDataFromTemplateComponent(p);function U(e,t){var n,o,i,a;const l=Object.assign({},p),s=null==l?void 0:l.components.findIndex((e=>"BUTTONS"===e.type));if(void 0!==s&&s>-1){const d=null===(n=null==l?void 0:l.components[s].buttons)||void 0===n?void 0:n.findIndex((e=>"URL"===e.type));if(void 0!==d&&d>-1){const n="custom"===t&&"string"==typeof e,r=[...null!==(a=null===(i=null===(o=l.components)||void 0===o?void 0:o[s])||void 0===i?void 0:i.buttons)&&void 0!==a?a:[]];r[d]=Object.assign(Object.assign({},r[d]),{url:"https://d.bik.ai/{{1}}",example:[n?e:"string"!=typeof e?e.defaultValue:""]});const p=Object.assign(Object.assign({},l.components[s]),{buttons:r}),u=Object.assign(Object.assign({},l.mapping),{buttons:n?["((customBtnPlaceholder))"]:"string"!=typeof e?[e.placeHolder]:void 0});l.mapping=u;const c=[...l.components];c[s]=p,l.components=c}}null==u||u(l)}function P(e,t,n){var o;const i=Object.assign({},p),a=null==i?void 0:i.components.findIndex((e=>"BUTTONS"===e.type));if(void 0!==a&&a>-1){const t=null===(o=null==i?void 0:i.components[a].buttons)||void 0===o?void 0:o.filter((e=>"QUICK_REPLY"===e.type));t&&(t[n]=Object.assign(Object.assign({},t[n]),{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==u||u(i)}return e.jsxs(a.Container,Object.assign({style:{flexDirection:"column",maxHeight:460}},{children:[!!q&&e.jsx(o.EditTemplateMediaContainer,{children:e.jsx(i.default,{whatsappSpecificPickerMeta:c,mediaComponent:q,updateTemplateImageUrl:function(e,t){var n;let o=Object.assign({},p);const i=null===(n=null==o?void 0:o.components)||void 0===n?void 0:n.findIndex((e=>{if("HEADER"===e.type&&"NONE"!==e.format&&"TEXT"!==e.format)return!0}));if(void 0!==i&&i>-1&&(null==o?void 0:o.components[i])){const n=Object.assign(Object.assign({},o.components[i]),{format:t,example:{header_handle:[e]}}),a=[...o.components];a[i]=n,o=Object.assign(Object.assign({},o),{components:a})}o.mapping&&(o.mapping=Object.assign(Object.assign({},o.mapping),{header:void 0})),null==u||u(Object.assign({},o))},template:p,variableListForImage:v})}),(R.length>0||A.length>0)&&e.jsx(s.default,{containerStyle:{paddingTop:q?24:8},headerText:"Edit variable values",subText:"Edit values for the variables used in template",toolTipInfo:"Variables are placeholder texts which can either be filled through data or custom texts. These can be edited through the dropdowns below"}),null==L?void 0:L.map(((t,n)=>e.jsx(l.default,{originalVariableList:I,type:t.type,descriptionComponent:t.component,variableMapping:"HEADER"===t.type?p.mapping.header:p.mapping.body,showVariableModal:m,variableList:b},n))),(null===(h=null===(g=B[0])||void 0===g?void 0:g.component)||void 0===h?void 0:h.buttons)&&(null===(x=null===(j=null===(f=B[0])||void 0===f?void 0:f.component)||void 0===j?void 0:j.buttons)||void 0===x?void 0:x.length)>0&&e.jsx(s.default,{headerText:"Edit buttons",subText:"Edit the link connected to the CTA button"}),null===(T=null==I?void 0:I.buttons)||void 0===T?void 0:T.map(((t,n)=>{if("URL"===t.type)return e.jsx(d.default,{CTAoptions:null==c?void 0:c.CTAoptions,button:t,originalVariableList:I,updateSelectedURLTemplateBtn:U},`${n}`)})),(null===(y=null===(O=M[0])||void 0===O?void 0:O.component)||void 0===y?void 0:y.buttons)&&(null===(V=null===(E=null===(C=M[0])||void 0===C?void 0:C.component)||void 0===E?void 0:E.buttons)||void 0===V?void 0:V.length)>0&&e.jsx(s.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"}),null===(w=null==I?void 0:I.buttons)||void 0===w?void 0:w.map(((t,n)=>{if("QUICK_REPLY"===t.type)return e.jsx(d.default,{QRBoptions:null==c?void 0:c.QRBoptions,button:t,originalVariableList:I,updateSelectedQRBTemplateBtn:P},`${n}`)}))]}))};
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),t=require("../context/templateModalContext.js"),o=require("../utils/getDataFromTemplateComponent.js"),n=require("./EditMediaV2.style.js"),i=require("./EditWhatsAppTemplateMediaV2.js"),l=require("./VariableConnectorsPanel.js"),a=require("./VariableConnectorWhatsApp.js"),s=require("./VariableEditorHeader.js"),d=require("./WhatsAppTemplateCardButtonV2.js");exports.default=r=>{let{template:p,onTemplateChange:u,whatsappSpecificPickerMeta:c,showVariableModal:m,variableList:b}=r;var v,g,h,f,j,x,T,O,y,C,E,V;const{originalVariableList:w}=t.useTemplateModalContext(),{descriptionComponents:B,urlBtns:I,qrbBtns:L,imageComponent:M,bodyVariables:q,headerVariables:R}=o.getAllDataFromTemplateComponent(p);function A(e,t){var o,n,i,l;const a=Object.assign({},p),s=null==a?void 0:a.components.findIndex((e=>"BUTTONS"===e.type));if(void 0!==s&&s>-1){const d=null===(o=null==a?void 0:a.components[s].buttons)||void 0===o?void 0:o.findIndex((e=>"URL"===e.type));if(void 0!==d&&d>-1){const o="custom"===t&&"string"==typeof e,r=[...null!==(l=null===(i=null===(n=a.components)||void 0===n?void 0:n[s])||void 0===i?void 0:i.buttons)&&void 0!==l?l:[]];r[d]=Object.assign(Object.assign({},r[d]),{url:"https://d.bik.ai/{{1}}",example:[o?e:"string"!=typeof e?e.defaultValue:""]});const p=Object.assign(Object.assign({},a.components[s]),{buttons:r}),u=Object.assign(Object.assign({},a.mapping),{buttons:o?["((customBtnPlaceholder))"]:"string"!=typeof e?[e.placeHolder]:void 0});a.mapping=u;const c=[...a.components];c[s]=p,a.components=c}}null==u||u(a)}function U(e,t,o){var n;const i=Object.assign({},p),l=null==i?void 0:i.components.findIndex((e=>"BUTTONS"===e.type));if(void 0!==l&&l>-1){const t=null===(n=null==i?void 0:i.components[l].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 a=Object.assign(Object.assign({},i.components[l]),{buttons:t}),s=[...i.components];s[l]=a,i.components=s}null==u||u(i)}return e.jsxs(l.Container,Object.assign({style:{flexDirection:"column",maxHeight:460}},{children:[!!M&&e.jsx(n.EditTemplateMediaContainer,{children:e.jsx(i.default,{whatsappSpecificPickerMeta:c,mediaComponent:M,updateTemplateImageUrl:function(e,t){var o;let n=Object.assign({},p);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]}}),l=[...n.components];l[i]=o,n=Object.assign(Object.assign({},n),{components:l})}null==u||u(n)},template:p})}),(q.length>0||R.length>0)&&e.jsx(s.default,{containerStyle:{paddingTop:M?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==B?void 0:B.map(((t,o)=>e.jsx(a.default,{originalVariableList:w,type:t.type,descriptionComponent:t.component,variableMapping:"HEADER"===t.type?p.mapping.header:p.mapping.body,showVariableModal:m,variableList:b},o))),(null===(g=null===(v=I[0])||void 0===v?void 0:v.component)||void 0===g?void 0:g.buttons)&&(null===(j=null===(f=null===(h=I[0])||void 0===h?void 0:h.component)||void 0===f?void 0:f.buttons)||void 0===j?void 0:j.length)>0&&e.jsx(s.default,{headerText:"Edit buttons",subText:"Edit the link connected to the CTA button"}),null===(x=null==w?void 0:w.buttons)||void 0===x?void 0:x.map(((t,o)=>{if("URL"===t.type)return e.jsx(d.default,{CTAoptions:null==c?void 0:c.CTAoptions,button:t,originalVariableList:w,updateSelectedURLTemplateBtn:A},`${o}`)})),(null===(O=null===(T=L[0])||void 0===T?void 0:T.component)||void 0===O?void 0:O.buttons)&&(null===(E=null===(C=null===(y=L[0])||void 0===y?void 0:y.component)||void 0===C?void 0:C.buttons)||void 0===E?void 0:E.length)>0&&e.jsx(s.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"}),null===(V=null==w?void 0:w.buttons)||void 0===V?void 0:V.map(((t,o)=>{if("QUICK_REPLY"===t.type)return e.jsx(d.default,{QRBoptions:null==c?void 0:c.QRBoptions,button:t,originalVariableList:w,updateSelectedQRBTemplateBtn:U},`${o}`)}))]}))};
@@ -1,4 +1,4 @@
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/Channels.js");function o(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var s=o(t),l=o(i);const p=l.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/Channels.js");function o(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var l=o(t),s=o(a);const p=s.default.div`
2
2
  position: relative;
3
3
  height: 100%;
4
4
  border-radius: 31px;
@@ -6,7 +6,7 @@
6
6
  background-color: white;
7
7
  margin: auto;
8
8
  overflow-y: auto;
9
- `,n=l.default.div`
9
+ `,n=s.default.div`
10
10
  position: absolute;
11
11
  flex: 1;
12
12
  background-color: white;
@@ -17,4 +17,4 @@
17
17
  height: calc(100% - 17px);
18
18
  border-radius: 16px;
19
19
  overflow-y: auto;
20
- `,c=s.default.forwardRef(((t,i)=>{let{display_content:o,channel:s,template:l}=t;return e.jsx("div",{children:e.jsxs(p,Object.assign({channel:s},{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===r.CHANNEL_TYPE.WHATSAPP?236:213,height:443}}),e.jsx(n,Object.assign({ref:i},{children:e.jsx(a.TemplatePreview,{template:l,channel:s,smsSpecificMeta:{smsDisplayContent:o},whatsAppSpecificMeta:{showWhatsAppHeader:!0,whatsAppExtras:!0,containerStyle:{border:"none",borderBottomRightRadius:0,borderBottomLeftRadius:0,minHeight:426}},size:"small",hideHeader:!0,emailSpecificMeta:{emailDisplayContent:o,hideViewButtonForEmail:!0,emailHtmlContainerId:"template_html_mobile",containerStyle:{height:"100%"},templateContainerStyles:{height:"100%"}}})}))]}))})}));c.displayName="MobilePreview",exports.default=c;
20
+ `,c=l.default.forwardRef(((t,a)=>{let{display_content:o,channel:l,template:s}=t;return console.log("template",s),console.log("channel",l),console.log("display_content",o),e.jsx("div",{children:e.jsxs(p,Object.assign({channel:l},{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:l===r.CHANNEL_TYPE.WHATSAPP?236:213,height:443}}),e.jsx(n,Object.assign({ref:a},{children:e.jsx(i.TemplatePreview,{template:s,channel:l,smsSpecificMeta:{smsDisplayContent:o},whatsAppSpecificMeta:{showWhatsAppHeader:!0,whatsAppExtras:!0,containerStyle:{border:"none",borderBottomRightRadius:0,borderBottomLeftRadius:0,minHeight:426}},size:"small",hideHeader:!0,emailSpecificMeta:{emailDisplayContent:o,hideViewButtonForEmail:!0,emailHtmlContainerId:"template_html_mobile",containerStyle:{height:"100%"},templateContainerStyles:{height:"100%"}}})}))]}))})}));c.displayName="MobilePreview",exports.default=c;
@@ -9,9 +9,8 @@ export interface TemplateSelectModalContentProps {
9
9
  whatsappSpecificPickerMeta?: WhatsAppPickerMeta;
10
10
  showVariableModal?: boolean;
11
11
  variableList?: VariableListInterfaceV2[];
12
- variableListForImage?: VariableListInterfaceV2[];
13
12
  discountCode?: string;
14
13
  setDiscountCode?: (code: string) => void;
15
14
  }
16
- declare const TemplateSelectModalContent: ({ channel, showVariableMapping, showOnlyContent, whatsappSpecificPickerMeta, showVariableModal, variableList, discountCode, setDiscountCode, variableListForImage, }: TemplateSelectModalContentProps) => import("react/jsx-runtime").JSX.Element;
15
+ declare const TemplateSelectModalContent: ({ channel, showVariableMapping, showOnlyContent, whatsappSpecificPickerMeta, showVariableModal, variableList, discountCode, setDiscountCode, }: TemplateSelectModalContentProps) => import("react/jsx-runtime").JSX.Element;
17
16
  export default TemplateSelectModalContent;
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),a=require("../../template-preview/models/Channels.js"),t=require("./Body.js"),i=require("./Header.js");exports.default=s=>{let{channel:r,showVariableMapping:o,showOnlyContent:l,whatsappSpecificPickerMeta:n,showVariableModal:d,variableList:c,discountCode:p,setDiscountCode:u,variableListForImage:h}=s;return e.jsx("div",Object.assign({style:{paddingBottom:0}},{children:e.jsxs("div",{children:[r===a.CHANNEL_TYPE.EMAIL&&e.jsx(i.default,{showOnlyContent:l}),e.jsx(t.default,{whatsappSpecificPickerMeta:n,showVariableMapping:!!o,showOnlyContent:l,showVariableModal:d,variableList:c,discountCode:p,setDiscountCode:u,variableListForImage:h})]})}))};
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),t=require("../../template-preview/models/Channels.js"),s=require("./Body.js"),a=require("./Header.js");exports.default=i=>{let{channel:r,showVariableMapping:o,showOnlyContent:n,whatsappSpecificPickerMeta:l,showVariableModal:d,variableList:c,discountCode:p,setDiscountCode:u}=i;return e.jsx("div",Object.assign({style:{paddingBottom:0}},{children:e.jsxs("div",{children:[r===t.CHANNEL_TYPE.EMAIL&&e.jsx(a.default,{showOnlyContent:n}),e.jsx(s.default,{whatsappSpecificPickerMeta:l,showVariableMapping:!!o,showOnlyContent:n,showVariableModal:d,variableList:c,discountCode:p,setDiscountCode:u})]})}))};
@@ -14,7 +14,6 @@ export interface VariableConnectorProps {
14
14
  showVariableModal?: boolean;
15
15
  variableList?: VariableListInterfaceV2[];
16
16
  setShowDiscountCheckBox?: any;
17
- componentType?: 'HEADER' | 'BODY' | 'BUTTONS' | 'FOOTER';
18
17
  }
19
18
  declare const VariableConnector: React.FC<VariableConnectorProps>;
20
19
  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"),l=require("../../../assets/icons/edit.svg.js"),t=require("react"),a=require("styled-components"),n=require("../../add-variableV2/AddVariableV2SideModal.js"),o=require("../../dropdown/Dropdown.js"),i=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"),v=require("../../../constants/Theme.js"),p=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`
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
- `,x={value:"custom_link",label:"Custom URL"},h={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(""),[k,V]=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:[x,h]}),H(x)):(t.push({label:"",options:[x,h]}),H(h));const e=null!=F?F:[];V([...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:[];V([{label:"",options:[h,x]},...e]),l=[{label:"",options:[h,x]},...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(x),L(E.updatedValue.split("https://")[1])):(H(h),L(E.updatedValue))}),[]),l.useEffect((()=>{B&&S&&C&&setTimeout((()=>{K("custom_link"===(null==S?void 0:S.value)?`https://${C}`:C,S.value)}),100)}),[B]),l.useEffect((()=>{!M&&S&&E.updatedValue&&setTimeout((()=>{K("custom_link"===(null==S?void 0:S.value)?`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:k,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)?`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"},h={value:"custom_text",label:"Custom text"};exports.Container=g,exports.default=a=>{let{onFocus:b,variable:E,index:_,showVariableModal:j,variableList:A,setShowDiscountCheckBox:y}=a;var f;const[T,P]=t.useState(!1),[N,C]=t.useState(""),[O,L]=t.useState([]),[k,S]=t.useState(),[V,H]=t.useState(!1),[w,M]=t.useState(!1),{device:q,channel:Y,isError:W,originalVariableList:I,template:B,templateSelectionTriggered:$,setTemplate:R,setDisplayContent:z,setOriginalVariableList:D,globalNormalizedPlaceholders:U,enabledCustomText:Z}=p.useTemplateModalContext();function F(e,l){var t,a,n;const o=e;C(""),S(o),Y===d.CHANNEL_TYPE.WHATSAPP?"custom_text"!==o.value&&"custom_link"!==o.value?(G(null!==(t=o.value)&&void 0!==t?t:"","string"),null==J||J(null!==(a=E.index)&&void 0!==a?a:0,`[[${o.value}]]`)):(null==J||J(null!==(n=E.index)&&void 0!==n?n:0,E.variableName),G("","url"===o.bikPlaceholderType?"link":"string")):"custom_text"!==o.value&&"custom_link"!==o.value?G(o.value,"url"===o.bikPlaceholderType?"link":"string"):(C(""),G("",o.value))}function G(e,l){var t,a;const n="custom_link"===l?"link":"custom_text"===l?"string":l;if(Y!==d.CHANNEL_TYPE.WHATSAPP){const a=m.getVariableNameForEmailByIndex(_+1),o=null===document||void 0===document?void 0:document.getElementById("mobile"===q?"template_html_mobile":"template_html_desktop"),i=Y===d.CHANNEL_TYPE.EMAIL?null===(t=null==o?void 0:o.contentWindow)||void 0===t?void 0:t.document.getElementById(a):document.getElementById(a);i&&(i.textContent="custom_text"!==l&&"custom_link"!==l||e?e:E.variableName);const u=I.map(((l,t)=>t===_?Object.assign(Object.assign({},l),{type:n,updatedValue:e}):l));null==D||D(u)}if(Y===d.CHANNEL_TYPE.WHATSAPP){const l=null===(a=I.body)||void 0===a?void 0:a.map(((l,t)=>t===_?Object.assign(Object.assign({},l),{type:n,updatedValue:e}):l));null==D||D((e=>Object.assign(Object.assign({},e),{body:l,buttons:I.buttons})))}}function J(e,l){var t;const a=Object.assign({},B),n=null===(t=null==a?void 0:a.components)||void 0===t?void 0:t.map((t=>{var a,n,o,i,u;const s=Object.assign({},t);if("BODY"===t.type&&(null===(n=null===(a=t.example)||void 0===a?void 0:a.body_text)||void 0===n?void 0:n[0])){const t=[...null!==(u=null===(i=null===(o=s.example)||void 0===o?void 0:o.body_text)||void 0===i?void 0:i[0])&&void 0!==u?u:[]];t[e]=l.replace("{{","").replace("}}","").replace("((","").replace("))","");const a=Object.assign(Object.assign({},s.example),{body_text:[t]});return Object.assign(Object.assign({},s),{example:a})}return t}));a.components=n,null==R||R(a)}return t.useEffect((()=>{T&&(null==b||b())}),[T]),t.useEffect((()=>{!function(){var e,l,t,a,n;const o="mobile"===q?"template_html_mobile":"template_html_desktop",i=document.getElementById(o),u=(null!==(a=null===(t=null===(l=null===(e=null==i?void 0:i.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===(n=null==i?void 0:i.contentWindow)||void 0===n?void 0:n.document.head.innerHTML);Y===d.CHANNEL_TYPE.EMAIL&&(null==z||z(u))}()}),[$]),t.useEffect((()=>{var e;const l=[];let t=[];if(Y!==d.CHANNEL_TYPE.MESSAGE||Z){"link"===(null==E?void 0:E.type)?(l.push({label:"",options:[x,h]}),S(x)):(l.push({label:"",options:[x,h]}),S(h));const e=null!=U?U:[];console.log("globalOptions",e),L([...l,...e.map((e=>{var l,t;return Object.assign(Object.assign({},e),{label:c.default.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!=U?U:[];console.log("globalOptions",e),L([{label:"",options:[h,x]},...e]),t=[{label:"",options:[h,x]},...e]}if((Y===d.CHANNEL_TYPE.WHATSAPP||Y===d.CHANNEL_TYPE.EMAIL||Y===d.CHANNEL_TYPE.MESSAGE)&&E.updatedValue)if(s.placeHolderNamePattern.test(E.updatedValue)&&Y===d.CHANNEL_TYPE.WHATSAPP||E.updatedValue.startsWith("{{")&&Y!==d.CHANNEL_TYPE.WHATSAPP){const e=function(e,l,t){var a;let n={label:"",value:""};const o=t===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:""}:l.map((e=>{e.options.map((e=>{var l;(null===(l=e.value)||void 0===l?void 0:l.replace("{{","").replace("}}","").trim())===o.trim()&&(n=e)}))}));return console.log("preSelectedOption",n),n}(E,t,Y);e.value&&S(e)}else(null===(e=E.updatedValue)||void 0===e?void 0:e.startsWith("https"))?(S(x),C(E.updatedValue.split("https://")[1])):(S(h),C(E.updatedValue))}),[]),t.useEffect((()=>{q&&k&&N&&setTimeout((()=>{G("custom_link"===(null==k?void 0:k.value)?`https://${N}`:N,k.value)}),100)}),[q]),t.useEffect((()=>{!w&&k&&E.updatedValue&&setTimeout((()=>{G("custom_link"===(null==k?void 0:k.value)?`https://${E.updatedValue}`:E.updatedValue,k.value),M(!0)}),100)}),[k]),e.jsxs(g,Object.assign({channel:Y,focused:T,onMouseEnter:()=>P(!0),onMouseLeave:()=>P(!1)},{children:[e.jsx("div",Object.assign({style:{marginBottom:8}},{children:e.jsx(r.BodySecondary,Object.assign({style:{color:W&&!k?v.COLORS.content.negative:v.COLORS.content.primary}},{children:"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==k?void 0:k.label)?"space-between":"flex-end"}},{children:[e.jsx(r.BodyPrimary,{children:u.truncate(null!==(f=null==k?void 0:k.label)&&void 0!==f?f:"",20,!0)}),e.jsx(l.default,{onClick:()=>{H(!V)},width:24,height:24,color:v.COLORS.content.primary})]})):e.jsx(o.Dropdown,{options:O,isSearchable:!1,onSelect:F,defaultOptions:k?[Object.assign(Object.assign({},k),{selected:!0})]:[]})})),("custom_text"===(null==k?void 0:k.value)||"custom_link"===(null==k?void 0:k.value))&&e.jsx(i.Input,{labelText:"custom_text"===(null==k?void 0:k.value)?"Custom text value":"custom_link"===(null==k?void 0:k.value)?"Custom URL value":"",id:`variable-value-${null==k?void 0:k.value}-${_}`,value:N,errorMessage:W?N&&0!==N.trim().length?"custom_link"!==k.value||/^https?:\/\/(?:www\.)?[-a-zA-Z0-9@:%._\+~#=]{1,256}\.[a-zA-Z0-9()]{1,6}\b(?:[-a-zA-Z0-9()@:%_\+.~#?&\/=]*)$/.test(`https://${N.trim()}`)&&0!==N.trim().length?"custom_link"!==k.value&&N.length>30?"Length cannot be more than 30":"":"Enter valid URL":"Required field":"",maxCharLimit:"custom_link"===(null==k?void 0:k.value)?void 0:30,prefixText:"custom_link"===(null==k?void 0:k.value)?"https://":"",placeholder:"link"===E.type||"custom_link"===k.value?"Enter custom URL here":"Enter custom text here",onChangeText:e=>{!function(e,l){var t;C(l);const a="custom_link"===(null==k?void 0:k.value)?`https://${l}`:l;G(a,e),Y===d.CHANNEL_TYPE.WHATSAPP&&(null==J||J(null!==(t=E.index)&&void 0!==t?t:0,a))}(k.value,e)}}),V&&e.jsx(n.AddVariableV2SideModal,{zIndex:2e3,data:null!=A?A:[],showVariable:V,setShowVariable:H,placeholder:"Add a variable",customTrigger:e=>{console.log("variable",e),null==y||y(!1),"{{custom.url}}"===e.actualValue?F({label:e.displayName,selected:!0,value:"custom_link"}):"{{custom.text}}"==e.actualValue?F({label:e.displayName,selected:!0,value:"custom_text"}):F({label:e.defaultValue||e.displayName,selected:!0,value:e.actualValue,bikPlaceholderType:"string"})}})]}))};
@@ -1,3 +1,4 @@
1
+ /// <reference types="react" />
1
2
  import { VariableListInterfaceV2 } from "../../add-variableV2/AddVariableV2";
2
3
  import { WhatsAppTemplate, WhatsAppTemplateVariables } from "../../template-preview/models/WhatsAppTemplate";
3
4
  export type ComponentType = WhatsAppTemplate['components'][0];
@@ -9,5 +10,5 @@ export interface VariableConnectorWhatsAppProps {
9
10
  showVariableModal?: boolean;
10
11
  variableList?: VariableListInterfaceV2[];
11
12
  }
12
- declare const VariableConnectorWhatsApp: ({ descriptionComponent, type, showVariableModal, variableList, }: VariableConnectorWhatsAppProps) => import("react/jsx-runtime").JSX.Element;
13
+ declare const VariableConnectorWhatsApp: React.FC<VariableConnectorWhatsAppProps>;
13
14
  export default VariableConnectorWhatsApp;
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),a=require("../../input/Input.js"),i=require("../../TypographyStyle.js"),r=require("../../../constants/Theme.js"),t=require("../context/templateModalContext.js"),l=require("./VariableConnector.js");exports.default=s=>{let{descriptionComponent:n,type:o,showVariableModal:d,variableList:p}=s;var c,x;const{originalVariableList:b}=t.useTemplateModalContext();return"BODY"===n.type?e.jsx("div",{children:null===(c=null==b?void 0:b.body)||void 0===c?void 0:c.map(((t,s)=>t.isEditableVariable?e.jsx(l.default,{index:s,variable:t,showVariableModal:d,variableList:p,componentType:n.type},`${s}-${t.index}`):e.jsxs("div",Object.assign({style:{margin:"16px 8px"}},{children:[e.jsxs(i.BodySecondary,Object.assign({style:{color:r.COLORS.content.primary}},{children:["HEADER"===o?"Header":""," Locked variable ",s+1]})),e.jsx(a.Input,{state:"disabled",placeholder:t.variableName,onChangeText:()=>{}})]}),s)))}):"HEADER"===n.type?e.jsx("div",{children:null===(x=null==b?void 0:b.header)||void 0===x?void 0:x.map(((t,s)=>t.isEditableVariable?e.jsx(l.default,{index:s,variable:t,showVariableModal:d,variableList:p,componentType:n.type},`${s}-${t.index}`):e.jsxs("div",Object.assign({style:{margin:"16px 8px"}},{children:[e.jsxs(i.BodySecondary,Object.assign({style:{color:r.COLORS.content.primary}},{children:["HEADER"===o?"Header":""," Locked variable ",s+1]})),e.jsx(a.Input,{state:"disabled",placeholder:t.variableName,onChangeText:()=>{}})]}),s)))}):e.jsx(e.Fragment,{})};
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),a=require("../../input/Input.js"),r=require("../../TypographyStyle.js"),t=require("../../../constants/Theme.js"),i=require("../context/templateModalContext.js"),s=require("./VariableConnector.js");exports.default=l=>{let{descriptionComponent:n,type:o,showVariableModal:d,variableList:p}=l;var u;const{originalVariableList:c}=i.useTemplateModalContext();return"BODY"===n.type?e.jsx("div",{children:null===(u=null==c?void 0:c.body)||void 0===u?void 0:u.map(((i,l)=>i.isEditableVariable?e.jsx(s.default,{index:l,variable:i,showVariableModal:d,variableList:p},`${l}-${i.index}`):e.jsxs("div",Object.assign({style:{margin:"16px 8px"}},{children:[e.jsxs(r.BodySecondary,Object.assign({style:{color:t.COLORS.content.primary}},{children:["HEADER"===o?"Header":""," Locked variable ",l+1]})),e.jsx(a.Input,{state:"disabled",placeholder:i.variableName,onChangeText:()=>{}})]}),l)))}):e.jsx(e.Fragment,{})};
@@ -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"),s=require("../../input/Input.js"),a=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"),u=require("../context/templateModalContext.js"),c=require("../utils/validateIsUrl.js"),d=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}=u.useTemplateModalContext();function L(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&&a.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(d.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,{options:"URL"===b.type?x:v,isSearchable:!1,onSelect:function(e,t){const l=e;h(l);const s=("URL"===b.type?x:v).find((e=>e.placeHolder===l.placeHolder));if(s)if("custom_link"!==s.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:s.value,placeHolder:s.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 L("")},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(s.Input,{errorMessage:U?y?c.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:L})}))]})};
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"),r=require("../../template-preview/models/WhatsAppTemplate.js"),o=require("../../TypographyStyle.js"),i=require("../../../constants/Theme.js"),u=require("../context/templateModalContext.js"),d=require("../utils/validateIsUrl.js"),p=require("./VariableConnector.js");exports.default=c=>{let{button:b,updateSelectedURLTemplateBtn:m,updateSelectedQRBTemplateBtn:j,originalVariableList:x,CTAoptions:v,QRBoptions:y}=c;const[f,g]=t.useState(""),[h,O]=t.useState(),{setOriginalVariableList:R,isError:U}=u.useTemplateModalContext();function L(e){g(e);const t=[Object.assign(Object.assign({},x.buttons[0]),{type:r.BUTTON_TYPE.URL,buttonVariable:"((customPlaceholderName))",example:[`https://${e}`]})];null==R||R({body:[...x.body],buttons:[...t]}),null==m||m(`https://${e}`,"custom")}return t.useEffect((()=>{var e;if(b.buttonVariable&&s.editableVarPattern.test(b.buttonVariable))O(n.CUSTOM_URL_NAME),g((null===(e=b.example)||void 0===e?void 0:e[0].split("https://")[1])||"");else{let e=-1;const t="URL"===b.type?v:y;e="URL"===b.type?t.findIndex((e=>e.placeHolder===b.buttonVariable)):t.findIndex((e=>e.label===b.flowName)),e>-1&&O(t[e])}}),[]),e.jsxs(p.Container,{children:[e.jsx("div",Object.assign({style:{marginBottom:8}},{children:e.jsxs(o.BodySecondary,Object.assign({style:{color:i.COLORS.content.primary}},{children:[b.text," button"]}))})),e.jsx("div",Object.assign({style:{marginBottom:12}},{children:e.jsx(l.Dropdown,{options:"URL"===b.type?v:y,isSearchable:!1,onSelect:function(e,t){const l=e;O(l);const a=("URL"===b.type?v:y).find((e=>e.placeHolder===l.placeHolder));if(a)if("custom_link"!==a.value){let e;"URL"===b.type?(e=[Object.assign(Object.assign({},x.buttons[0]),{type:"URL",buttonVariable:l.placeHolder,example:["https://bik.ai/"]})],null==m||m({defaultValue:a.value,placeHolder:a.placeHolder},"placeholder")):(e=x.buttons.map(((e,t)=>t===b.index?Object.assign(Object.assign({},e),{type:"QUICK_REPLY",flowName:l.label,flowId:l.value}):e)),null==j||j({flowName:l.label,flowId:l.value},"placeholder",b.index)),null==R||R({body:[...x.body],buttons:[...e]})}else L("")},defaultOptions:h?[Object.assign(Object.assign({},h),{selected:!0})]:[]})})),"custom_link"===(null==h?void 0:h.value)&&e.jsx("div",Object.assign({style:{marginBottom:20}},{children:e.jsx(a.Input,{errorMessage:U?f?d.validateIsUrl(f)?"":"Enter valid URL":"Required field":"",value:f,prefixText:"custom_link"===(null==h?void 0:h.value)?"https://":"",placeholder:"Enter custom URL here",onChangeText:L})}))]})};
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});const e=/\{\{[A-Za-z0-9 .]+\}\}/g,t=e;exports.editableBracketPattern=/[((|))]/,exports.editableVarPattern=/\((\(|\[)[A-Za-z0-9 ]+(\]|\))\)/,exports.globalHalfVariablePattern=/\{\{[a-zA-Z0-9]+(?=( |\}))(?!\}\})/g,exports.globalVariablePattern=e,exports.lockedVarPattern=/\[\[[A-Za-z0-9 .]+\]\]/,exports.placeHolderNamePattern=/(\[\[|\{\{|\(\()(.*?)(\)\)|\}\}|\]\])/,exports.previewLinkMDFormatPattern=/\[([^[]+)\](\(.*\))/,exports.specialCharPattern=/[!@#$%^&*()_+\-={};':"\\|,.<>?]+/,exports.templateVariablePattern=t,exports.variablePattern=/\{\{[A-Za-z0-9 ._]+\}\}/,exports.variablePatternGlobal=/\{\{[A-Za-z0-9 _]+\}\}/g;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});const e=/\{\{[A-Za-z0-9 .]+\}\}/g,t=e;exports.editableBracketPattern=/[((|))]/,exports.editableVarPattern=/\((\(|\[)[A-Za-z0-9 ]+(\]|\))\)/,exports.globalHalfVariablePattern=/\{\{[a-zA-Z0-9]+(?=( |\}))(?!\}\})/g,exports.globalVariablePattern=e,exports.lockedVarPattern=/\[\[[A-Za-z0-9 .]+\]\]/,exports.placeHolderNamePattern=/(\[\[|\{\{||\(\()(.*)(\)\)|\}\}|\]\])/,exports.previewLinkMDFormatPattern=/\[([^[]+)\](\(.*\))/,exports.specialCharPattern=/[!@#$%^&*()_+\-={};':"\\|,.<>?]+/,exports.templateVariablePattern=t,exports.variablePattern=/\{\{[A-Za-z0-9 ._]+\}\}/,exports.variablePatternGlobal=/\{\{[A-Za-z0-9 _]+\}\}/g;
@@ -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){var t,n,i,o,a,d,r,v,s,E;const u={headerType:l.HEADER_TYPES.NONE,headerVariables:[]},T=null===(t=e.components)||void 0===t?void 0:t.find((e=>"HEADER"===e.type));if(T){u.headerType=T.format,u.headerText=T.text,u.headerAssetLink=null===(i=null===(n=T.example)||void 0===n?void 0:n.header_handle)||void 0===i?void 0:i[0];const t=null===(a=null===(o=T.example)||void 0===o?void 0:o.header_text)||void 0===a?void 0:a[0],l=null===(r=null===(d=e.mapping)||void 0===d?void 0:d.header)||void 0===r?void 0:r[0];if(t&&l){const e=null==l?void 0:l.replace("[[","").replace("]]","").replace("{{","").replace("}}","").replace("((","").replace("))",""),n=/\(\(/.test(l),i={idx:0,variableVal:t,editable:n,editableDefaultValues:n?void 0:t,variableName:e};u.headerVariables=[i],(null===(s=null===(v=T.example)||void 0===v?void 0:v.header_text)||void 0===s?void 0:s.length)&&(u.headerText=null===(E=u.headerText)||void 0===E?void 0:E.replace("{{1}}",`{{${e}}}`))}}return u}validateState(e){var t,a,d,r,v,s,E,u,T,p,c,_,R,m,h,b,I,L,N,y,B;const A=/\p{Extended_Pictographic}/u;let C="valid";const D={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?(D.meta.name=i.NAME_LEN_ERROR,C="invalid"):n.specialCharPattern.test(e.meta.name.trim())&&(D.meta.name=i.NO_SPECIAL_CHAR,C="invalid"):(D.meta.name=i.REQUIRED_FIELD,C="invalid"),D.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)D.header=i.HEADER_LEN_ERROR,C="invalid";else{const e=O.getTemplateVariablesFromState(t);e&&e.length>1&&(D.header=i.ONE_VAR_ALLOWED,C="invalid")}else D.header=i.REQUIRED_FIELD,C="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||(D.header=i.HEADER_ASSET_LINK_ERROR,C="invalid"),D.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&&(D.body=i.BODY_LEN_ERROR,C="invalid"):(D.body=i.REQUIRED_FIELD,C="invalid"),D.body&&!x&&(P(i.CREATE_TEMPLATE_DOM_IDS.body),x=!0),e.footerText&&e.footerText.length>i.HEADER_TEXT_LEN_LIMIT&&(D.footer=i.HEADER_LEN_ERROR,C="invalid"),(null==D?void 0:D.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;D.ctaBtn&&!t?(D.ctaBtn.phoneNumber.btnText=i.REQUIRED_FIELD,C="invalid"):D.ctaBtn&&t&&t.length>i.QUICK_REPLY_BTN_TEXT_LIMIT?(D.ctaBtn.phoneNumber.btnText=i.QUICK_REPLY_LEN_ERROR,C="invalid"):D.ctaBtn&&t&&A.test(t)&&(D.ctaBtn.phoneNumber.btnText=i.BUTTON_EMOJI_ERROR,C="invalid"),D.ctaBtn&&!n?(D.ctaBtn.phoneNumber.link=i.REQUIRED_FIELD,C="invalid"):D.ctaBtn&&n&&n.length<10&&(D.ctaBtn.phoneNumber.link=i.VALID_PHONE_NUMBER,C="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();D.ctaBtn&&!t?(D.ctaBtn.websiteLink.btnText=i.REQUIRED_FIELD,C="invalid"):D.ctaBtn&&t&&t.length>i.QUICK_REPLY_BTN_TEXT_LIMIT?(D.ctaBtn.websiteLink.btnText=i.QUICK_REPLY_LEN_ERROR,C="invalid"):D.ctaBtn&&t&&A.test(t)&&(D.ctaBtn.websiteLink.btnText=i.BUTTON_EMOJI_ERROR,C="invalid"),!D.ctaBtn||n||l||(D.ctaBtn.websiteLink.link=i.REQUIRED_FIELD,C="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,C="invalid";else if(A.test(o))t[l]=i.BUTTON_EMOJI_ERROR,C="invalid";else{const n=[...e.quickReply];n.splice(l,1);n.find((e=>e.text===o))&&(t[l]=i.QUICK_REPLY_NAME_ERROR,C="invalid")}else t[l]=i.REQUIRED_FIELD,C="invalid"})),D.quickReply=t}if(e.actionsType===l.ACTIONS_TYPES.CTA_BTN||e.actionsType===l.ACTIONS_TYPES.QUICK_REPLY){const e=null===(R=D.quickReply)||void 0===R?void 0:R.reduce(((e,t)=>e||!!t),!1);((null===(h=null===(m=null==D?void 0:D.ctaBtn)||void 0===m?void 0:m.websiteLink)||void 0===h?void 0:h.link)||(null===(I=null===(b=D.ctaBtn)||void 0===b?void 0:b.websiteLink)||void 0===I?void 0:I.btnText)||(null===(N=null===(L=D.ctaBtn)||void 0===L?void 0:L.phoneNumber)||void 0===N?void 0:N.link)||(null===(B=null===(y=D.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:C,errors:D}}parseBodyComponent(e){let i=arguments.length>1&&void 0!==arguments[1]&&arguments[1];var l,o,a,d,r;const v=[];let s="";const E=null===(l=e.components)||void 0===l?void 0:l.find((e=>"BODY"===e.type));return E&&(null===(a=null===(o=E.example)||void 0===o?void 0:o.body_text)||void 0===a||a[0].forEach(((t,i)=>{var l,o;let a=null===(o=null===(l=e.mapping)||void 0===l?void 0:l.body)||void 0===o?void 0:o[i];const d=a&&/\(\(/.test(a),r=null==a?void 0:a.match(n.placeHolderNamePattern);(null==r?void 0:r[2])&&(a=null==r?void 0:r[2]),v.push({idx:i,variableVal:t,editable:!!d,editableDefaultValues:d?void 0:t,variableName:null!=a?a:""})})),s=e.htmlContentUrl?e.htmlContentUrl:(null===(d=E.text)||void 0===d?void 0:d.split(/\{\{[0-9]+\}\}/).length)?null===(r=E.text)||void 0===r?void 0:r.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:s}}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,n){let i=arguments.length>2&&void 0!==arguments[2]&&arguments[2];var l;return e.__awaiter(this,void 0,void 0,(function*(){const{headerType:e,headerAssetLink:o,headerAssetName:a,headerText:d,headerVariables:r}=yield this.parseDataFromHeaderComponent(t),{bodyText:v,bodyVariable:s}=yield this.parseBodyComponent(t,i),{actionsType:E,quickReply:u,ctaBtn:T}=yield this.parseButtonComponent(t),p={quickReply:u,ctaBtn:T,meta:{name:n?`${t.label} Copy`:t.label,category:null===(l=t.category)||void 0===l?void 0:l.toUpperCase(),subCategory:t.templateCategory,language:t.language,templateId:t.templateId},error:{header:void 0,body:void 0,footer:void 0,quickReply:void 0,meta:void 0,ctaBtn:void 0},actionsType:E,footerText:this.parseFooterComponent(t),bodyVariables:s,bodyText:v,headerType:e,headerAssetLink:o,headerAssetName:a,headerText:d,headerVariables:r,alreadyAsADraft:t.isDraft,mode:"edit",initialLoading:!1},{errors:c}=this.validateState(p);return p.error=c,p}))}};
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){var t,n,i,o,a,d,r,v,s,E;const u={headerType:l.HEADER_TYPES.NONE,headerVariables:[]},T=null===(t=e.components)||void 0===t?void 0:t.find((e=>"HEADER"===e.type));if(T){u.headerType=T.format,u.headerText=T.text,u.headerAssetLink=null===(i=null===(n=T.example)||void 0===n?void 0:n.header_handle)||void 0===i?void 0:i[0];const t=null===(a=null===(o=T.example)||void 0===o?void 0:o.header_text)||void 0===a?void 0:a[0],l=null===(r=null===(d=e.mapping)||void 0===d?void 0:d.header)||void 0===r?void 0:r[0];if(t&&l){const e=null==l?void 0:l.replace("[[","").replace("]]","").replace("{{","").replace("}}","").replace("((","").replace("))",""),n=/\(\(/.test(l),i={idx:0,variableVal:t,editable:n,editableDefaultValues:n?void 0:t,variableName:e};u.headerVariables=[i],(null===(s=null===(v=T.example)||void 0===v?void 0:v.header_text)||void 0===s?void 0:s.length)&&(u.headerText=null===(E=u.headerText)||void 0===E?void 0:E.replace("{{1}}",`{{${e}}}`))}}return u}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 C="valid";const D={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?(D.meta.name=i.NAME_LEN_ERROR,C="invalid"):n.specialCharPattern.test(e.meta.name.trim())&&(D.meta.name=i.NO_SPECIAL_CHAR,C="invalid"):(D.meta.name=i.REQUIRED_FIELD,C="invalid"),D.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)D.header=i.HEADER_LEN_ERROR,C="invalid";else{const e=O.getTemplateVariablesFromState(t);e&&e.length>1&&(D.header=i.ONE_VAR_ALLOWED,C="invalid")}else D.header=i.REQUIRED_FIELD,C="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||(D.header=i.HEADER_ASSET_LINK_ERROR,C="invalid"),D.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&&(D.body=i.BODY_LEN_ERROR,C="invalid"):(D.body=i.REQUIRED_FIELD,C="invalid"),D.body&&!x&&(P(i.CREATE_TEMPLATE_DOM_IDS.body),x=!0),e.footerText&&e.footerText.length>i.HEADER_TEXT_LEN_LIMIT&&(D.footer=i.HEADER_LEN_ERROR,C="invalid"),(null==D?void 0:D.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;D.ctaBtn&&!t?(D.ctaBtn.phoneNumber.btnText=i.REQUIRED_FIELD,C="invalid"):D.ctaBtn&&t&&t.length>i.QUICK_REPLY_BTN_TEXT_LIMIT?(D.ctaBtn.phoneNumber.btnText=i.QUICK_REPLY_LEN_ERROR,C="invalid"):D.ctaBtn&&t&&A.test(t)&&(D.ctaBtn.phoneNumber.btnText=i.BUTTON_EMOJI_ERROR,C="invalid"),D.ctaBtn&&!n?(D.ctaBtn.phoneNumber.link=i.REQUIRED_FIELD,C="invalid"):D.ctaBtn&&n&&n.length<10&&(D.ctaBtn.phoneNumber.link=i.VALID_PHONE_NUMBER,C="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();D.ctaBtn&&!t?(D.ctaBtn.websiteLink.btnText=i.REQUIRED_FIELD,C="invalid"):D.ctaBtn&&t&&t.length>i.QUICK_REPLY_BTN_TEXT_LIMIT?(D.ctaBtn.websiteLink.btnText=i.QUICK_REPLY_LEN_ERROR,C="invalid"):D.ctaBtn&&t&&A.test(t)&&(D.ctaBtn.websiteLink.btnText=i.BUTTON_EMOJI_ERROR,C="invalid"),!D.ctaBtn||n||l||(D.ctaBtn.websiteLink.link=i.REQUIRED_FIELD,C="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,C="invalid";else if(A.test(o))t[l]=i.BUTTON_EMOJI_ERROR,C="invalid";else{const n=[...e.quickReply];n.splice(l,1);n.find((e=>e.text===o))&&(t[l]=i.QUICK_REPLY_NAME_ERROR,C="invalid")}else t[l]=i.REQUIRED_FIELD,C="invalid"})),D.quickReply=t}if(e.actionsType===l.ACTIONS_TYPES.CTA_BTN||e.actionsType===l.ACTIONS_TYPES.QUICK_REPLY){const e=null===(m=D.quickReply)||void 0===m?void 0:m.reduce(((e,t)=>e||!!t),!1);((null===(h=null===(R=null==D?void 0:D.ctaBtn)||void 0===R?void 0:R.websiteLink)||void 0===h?void 0:h.link)||(null===(I=null===(b=D.ctaBtn)||void 0===b?void 0:b.websiteLink)||void 0===I?void 0:I.btnText)||(null===(N=null===(L=D.ctaBtn)||void 0===L?void 0:L.phoneNumber)||void 0===N?void 0:N.link)||(null===(B=null===(y=D.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:C,errors:D}}parseBodyComponent(e){let i=arguments.length>1&&void 0!==arguments[1]&&arguments[1];var l,o,a,d,r;const v=[];let s="";const E=null===(l=e.components)||void 0===l?void 0:l.find((e=>"BODY"===e.type));return E&&(null===(a=null===(o=E.example)||void 0===o?void 0:o.body_text)||void 0===a||a[0].forEach(((t,i)=>{var l,o;let a=null===(o=null===(l=e.mapping)||void 0===l?void 0:l.body)||void 0===o?void 0:o[i];const d=a&&/\(\(/.test(a),r=null==a?void 0:a.match(n.placeHolderNamePattern);console.log({matchedPlaceholderName:r}),(null==r?void 0:r[2])&&(a=null==r?void 0:r[2]),v.push({idx:i,variableVal:t,editable:!!d,editableDefaultValues:d?void 0:t,variableName:null!=a?a:""})})),s=e.htmlContentUrl?e.htmlContentUrl:(null===(d=E.text)||void 0===d?void 0:d.split(/\{\{[0-9]+\}\}/).length)?null===(r=E.text)||void 0===r?void 0:r.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:s}}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,n){let i=arguments.length>2&&void 0!==arguments[2]&&arguments[2];var l;return e.__awaiter(this,void 0,void 0,(function*(){const{headerType:e,headerAssetLink:o,headerAssetName:a,headerText:d,headerVariables:r}=yield this.parseDataFromHeaderComponent(t),{bodyText:v,bodyVariable:s}=yield this.parseBodyComponent(t,i),{actionsType:E,quickReply:u,ctaBtn:T}=yield this.parseButtonComponent(t),p={quickReply:u,ctaBtn:T,meta:{name:n?`${t.label} Copy`:t.label,category:null===(l=t.category)||void 0===l?void 0:l.toUpperCase(),subCategory:t.templateCategory,language:t.language,templateId:t.templateId},error:{header:void 0,body:void 0,footer:void 0,quickReply:void 0,meta:void 0,ctaBtn:void 0},actionsType:E,footerText:this.parseFooterComponent(t),bodyVariables:s,bodyText:v,headerType:e,headerAssetLink:o,headerAssetName:a,headerText:d,headerVariables:r,alreadyAsADraft:t.isDraft,mode:"edit",initialLoading:!1},{errors:c}=this.validateState(p);return p.error=c,p}))}};
@@ -198,7 +198,6 @@ export type WhatsAppMediaUploadRequest = {
198
198
  };
199
199
  export interface WhatsAppTemplateVariables {
200
200
  body: CUSTOM_VARIABLE[];
201
- header: CUSTOM_VARIABLE[];
202
201
  buttons: TEMPLATE_BUTTON[];
203
202
  }
204
203
  export type CTABtnValType = {
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../constants/regexPatterns.js");exports.TemplateHelperUtils=class{fillVariablesValInBodyText(l,a){let t=arguments.length>2&&void 0!==arguments[2]&&arguments[2];const r=l.match(e.templateVariablePattern),i=l.split(e.templateVariablePattern);if(l&&(null==r?void 0:r.length)){return i.map(((e,l)=>{var n,o,v,d,u;const p=null===(n=null==r?void 0:r[l])||void 0===n?void 0:n.replace("{{","").replace("}}","");return i.length-1===l?e:(null===(v=null===(o=null==a?void 0:a[l])||void 0===o?void 0:o.variableName)||void 0===v?void 0:v.trim())===p.trim()||(null===(u=null===(d=null==a?void 0:a[l])||void 0===d?void 0:d.variableVal)||void 0===u?void 0:u.trim())===p.trim()?a[l].editable?`${e}${t?"{{":""}${a[l].variableVal}${t?"}}":""}`:`${e}${t?"{{":""}${a[l].variableName}${t?"}}":""}`:e})).join("")}return l}getTemplateVariablesFromState(l){var a;return null===(a=l.match(e.globalVariablePattern))||void 0===a?void 0:a.map((e=>e.replace("{{","").replace("}}","")))}whatsappOnlyFillVariablesValueInBodyText(l,a){let t=arguments.length>2&&void 0!==arguments[2]&&arguments[2];const r=l.match(e.templateVariablePattern),i=l.split(e.templateVariablePattern);if(l&&(null==r?void 0:r.length)){return i.map(((e,l)=>{var n;const o=null===(n=null==r?void 0:r[l])||void 0===n?void 0:n.replace("{{","").replace("}}","");if(i.length-1===l)return e;const v=a.findIndex((e=>e.variableName===o));if(v>-1){let l=a[v].variableVal;return t||(l=!a[v].variableVal&&a[v].variableName.startsWith("editableVariable")?a[v].variableName:null==l?void 0:l.replace("[[","").replace("]]","")),a[v].editable?`${e}${t?"{{":""}${l}${t?"}}":""}`:`${e}${t?"{{":""}${o}${t?"}}":""}`}return e})).join("")}return l}};
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../constants/regexPatterns.js");exports.TemplateHelperUtils=class{fillVariablesValInBodyText(l,a){let t=arguments.length>2&&void 0!==arguments[2]&&arguments[2];const r=l.match(e.templateVariablePattern),i=l.split(e.templateVariablePattern);if(l&&(null==r?void 0:r.length)){return i.map(((e,l)=>{var n,o,v,d,s;const u=null===(n=null==r?void 0:r[l])||void 0===n?void 0:n.replace("{{","").replace("}}","");return i.length-1===l?e:(null===(v=null===(o=null==a?void 0:a[l])||void 0===o?void 0:o.variableName)||void 0===v?void 0:v.trim())===u.trim()||(null===(s=null===(d=null==a?void 0:a[l])||void 0===d?void 0:d.variableVal)||void 0===s?void 0:s.trim())===u.trim()?a[l].editable?`${e}${t?"{{":""}${a[l].variableVal}${t?"}}":""}`:`${e}${t?"{{":""}${a[l].variableName}${t?"}}":""}`:e})).join("")}return l}getTemplateVariablesFromState(l){var a;return null===(a=l.match(e.globalVariablePattern))||void 0===a?void 0:a.map((e=>e.replace("{{","").replace("}}","")))}whatsappOnlyFillVariablesValueInBodyText(l,a){let t=arguments.length>2&&void 0!==arguments[2]&&arguments[2];const r=l.match(e.templateVariablePattern);console.log("variableList",r);const i=l.split(e.templateVariablePattern);if(l&&(null==r?void 0:r.length)){return i.map(((e,l)=>{var n;const o=null===(n=null==r?void 0:r[l])||void 0===n?void 0:n.replace("{{","").replace("}}","");if(i.length-1===l)return e;const v=a.findIndex((e=>e.variableName===o));if(v>-1){let l=a[v].variableVal;return t||(l=!a[v].variableVal&&a[v].variableName.startsWith("editableVariable")?a[v].variableName:null==l?void 0:l.replace("[[","").replace("]]","")),a[v].editable?`${e}${t?"{{":""}${l}${t?"}}":""}`:`${e}${t?"{{":""}${o}${t?"}}":""}`}return e})).join("")}return l}};
@@ -1,4 +1,3 @@
1
- /// <reference types="react" />
2
1
  export declare const Menus: ({
3
2
  displayName: string;
4
3
  key: number;
@@ -1,18 +1,10 @@
1
- /// <reference types="react" />
2
- import { Variable } from '../add-variableV2/AddVariableV2';
3
1
  import { SelectedVariable } from '../add-variableV2/types';
4
- interface InputWithVariablesProps {
2
+ export declare const InputWithVariables: (props: {
5
3
  variablesList: any;
6
- onChange: (val: SelectedVariable | Variable) => void;
7
- onBlur?: (e: Event, val?: SelectedVariable | Variable) => void;
4
+ onChange: (val: SelectedVariable) => void;
8
5
  addVarBoxRight: string;
9
6
  allowMix: boolean;
10
7
  prevVariable: SelectedVariable;
11
- showHelp?: boolean;
12
- onlyVariables?: boolean;
13
- showSideVariablePanel?: boolean;
14
- placeHolder?: string;
15
- showAddButton?: boolean;
16
- }
17
- export declare const InputWithVariables: React.FC<InputWithVariablesProps>;
18
- export {};
8
+ showHelp?: boolean | undefined;
9
+ onlyVariables?: boolean | undefined;
10
+ }) => import("react/jsx-runtime").JSX.Element;
@@ -1,6 +1,6 @@
1
- import{jsxs as e,Fragment as a,jsx as l}from"react/jsx-runtime";import r from"../../assets/icons/PlusIcon.js";import{useRef as i,useState as d,useEffect as t}from"react";import o from"styled-components";import{v4 as s}from"uuid";import{COLORS as n}from"../../constants/Theme.js";import{AddVariableV2SideModal as c}from"../add-variableV2/AddVariableV2SideModal.js";import{AddVariableV2 as u}from"../add-variableV2/AddVariableV2.js";import{AddVariableStyled as v}from"../add-variableV2/AddVariableBox.styled.js";import{Input as p}from"../input/Input.js";import{BodyCaption as b}from"../TypographyStyle.js";const h=o=>{let{addVarBoxRight:n,allowMix:h,onChange:m,prevVariable:g,variablesList:T,onBlur:f,onlyVariables:y,placeHolder:j,showAddButton:x=!0,showHelp:w,showSideVariablePanel:S}=o;const A=i(null),[C,k]=d(!1),[B]=d(s()),[N,O]=d(),[F,I]=d(g),[L,M]=d(!1),[$,q]=d(!1);return t((()=>{N&&N.actualValue&&I(h?e=>({actualValue:e.actualValue+N.actualValue,variableType:"string"}):e=>({actualValue:N.actualValue,variableType:N.variableType,needsFetching:N.needsFetching}))}),[N]),t((()=>{m(F)}),[F]),e(a,{children:[e(V,Object.assign({isVar:/^{{.*}}$/.test(F.actualValue)},{children:[l(p,{id:B,ref:A,skipFocus:!0,textControl:!0,isActive:C,value:F.actualValue,validate:e=>[!0,""],errorMessage:"",placeholder:j||"Add a value",onChangeText:function(e,a){if(y){const e=(null==a?void 0:a.keyCode)||(null==a?void 0:a.charCode);8!=e&&46!=e||I({actualValue:"",variableType:"string"})}else I(h?{actualValue:e,variableType:"string"}:{actualValue:e.replace(/{{.*}}/,""),variableType:"string"})},onReferenceInit:()=>{},onFocus:e=>{var a;k(!0),q(!0),"Search..."!==(null===(a=e.relatedTarget)||void 0===a?void 0:a.placeholder)||L||M(!0)},onBlur:e=>{var a,l,r,i,d,t,o;null==f||f(e,F),"addVar"===(null===(a=e.relatedTarget)||void 0===a?void 0:a.id)||"varList"===(null===(l=e.relatedTarget)||void 0===l?void 0:l.id)||(null===(i=null===(r=e.relatedTarget)||void 0===r?void 0:r.className)||void 0===i?void 0:i.includes("exlualr0"))||(null===(t=null===(d=e.relatedTarget)||void 0===d?void 0:d.className)||void 0===t?void 0:t.includes("sc-dZoequ "))?(A.current&&A.current.focus(),k(!0)):"Search..."===(null===(o=e.relatedTarget)||void 0===o?void 0:o.placeholder)?k(!0):(k(!1),M(!1),q(!1))}}),e("div",Object.assign({style:{display:"flex",flexDirection:"row",justifyContent:"space-between"}},{children:[F.actualValue&&w?l("div",Object.assign({style:{marginTop:4}},{children:l(b,{children:`This value is of type ${F.variableType}`})})):l("div",{}),x&&$&&l(v,Object.assign({right:n,id:"addVar",onClick:()=>{M(!L)}},{children:e("div",Object.assign({className:"add"},{children:[l(r,{color:"white"}),l("div",Object.assign({className:"variable"},{children:"Add variable"}))]}))}))]})),!S&&L&&l(u,{data:T,showVariable:!0,setShowVariable:()=>{M(!1)},variableValue:N,setVariableValue:O,placeholder:"",pickerSize:"large",enableVariable:!0,selectWithTypes:!0,onSearchBlur:e=>{var a,l,r,i,d,t;"varList"===(null===(a=e.relatedTarget)||void 0===a?void 0:a.id)||(null===(r=null===(l=e.relatedTarget)||void 0===l?void 0:l.className)||void 0===r?void 0:r.includes("exlualr0"))||(null===(d=null===(i=e.relatedTarget)||void 0===i?void 0:i.className)||void 0===d?void 0:d.includes("sc-dZoequ "))?A.current.focus():"Enter here"===(null===(t=e.relatedTarget)||void 0===t?void 0:t.placeholder)?e.relatedTarget.id!==B&&(M(!1),q(!1),k(!1)):(M(!1),q(!1),k(!1))}})]})),S&&L&&l(c,{zIndex:2e3,data:T,showVariable:L,setShowVariable:M,placeholder:"Add a variable",customTrigger:e=>{I(e)}})]})},V=o.div`
1
+ import{jsxs as e,jsx as a}from"react/jsx-runtime";import l from"../../assets/icons/PlusIcon.js";import{useRef as r,useState as i,useEffect as t}from"react";import o from"styled-components";import{v4 as d}from"uuid";import{COLORS as s}from"../../constants/Theme.js";import{AddVariableStyled as n}from"../add-variableV2/AddVariableBox.styled.js";import{AddVariableV2 as c}from"../add-variableV2/AddVariableV2.js";import{Input as u}from"../input/Input.js";import{BodyCaption as v}from"../TypographyStyle.js";const p=o=>{const s=r(null),[p,g]=i(!1),[m]=i(d()),[h,V]=i(),[T,f]=i(o.prevVariable),[y,j]=i(!1),[x,w]=i(!1);return t((()=>{h&&h.actualValue&&(o.allowMix?f((e=>({actualValue:e.actualValue+h.actualValue,variableType:"string"}))):f((e=>({actualValue:h.actualValue,variableType:h.variableType,needsFetching:h.needsFetching}))))}),[h]),t((()=>{o.onChange(T)}),[T]),e(b,Object.assign({isVar:/^{{.*}}$/.test(T.actualValue)},{children:[a(u,{id:m,ref:s,skipFocus:!0,textControl:!0,isActive:p,value:T.actualValue,validate:e=>[!0,""],errorMessage:"",placeholder:"Add a value",onChangeText:function(e,a){if(o.onlyVariables){const e=(null==a?void 0:a.keyCode)||(null==a?void 0:a.charCode);8!=e&&46!=e||f({actualValue:"",variableType:"string"})}else o.allowMix?f({actualValue:e,variableType:"string"}):f({actualValue:e.replace(/{{.*}}/,""),variableType:"string"})},onReferenceInit:()=>{},onFocus:e=>{var a;g(!0),w(!0),"Search..."!==(null===(a=e.relatedTarget)||void 0===a?void 0:a.placeholder)||y||j(!0)},onBlur:e=>{var a,l,r,i,t,o,d;"addVar"===(null===(a=e.relatedTarget)||void 0===a?void 0:a.id)||"varList"===(null===(l=e.relatedTarget)||void 0===l?void 0:l.id)||(null===(i=null===(r=e.relatedTarget)||void 0===r?void 0:r.className)||void 0===i?void 0:i.includes("exlualr0"))||(null===(o=null===(t=e.relatedTarget)||void 0===t?void 0:t.className)||void 0===o?void 0:o.includes("sc-dZoequ "))?(s.current&&s.current.focus(),g(!0)):"Search..."===(null===(d=e.relatedTarget)||void 0===d?void 0:d.placeholder)?g(!0):(g(!1),j(!1),w(!1))}}),e("div",Object.assign({style:{display:"flex",flexDirection:"row",justifyContent:"space-between"}},{children:[T.actualValue&&o.showHelp?a("div",Object.assign({style:{marginTop:4}},{children:a(v,{children:`This value is of type ${T.variableType}`})})):a("div",{}),x&&a(n,Object.assign({right:o.addVarBoxRight,id:"addVar",onClick:()=>{j(!y)}},{children:e("div",Object.assign({className:"add"},{children:[a(l,{color:"white"}),a("div",Object.assign({className:"variable"},{children:"Add variable"}))]}))}))]})),y&&a(c,{data:o.variablesList,showVariable:!0,setShowVariable:()=>{j(!1)},variableValue:h,setVariableValue:V,placeholder:"",pickerSize:"large",enableVariable:!0,selectWithTypes:!0,onSearchBlur:e=>{var a,l,r,i,t,o;"varList"===(null===(a=e.relatedTarget)||void 0===a?void 0:a.id)||(null===(r=null===(l=e.relatedTarget)||void 0===l?void 0:l.className)||void 0===r?void 0:r.includes("exlualr0"))||(null===(t=null===(i=e.relatedTarget)||void 0===i?void 0:i.className)||void 0===t?void 0:t.includes("sc-dZoequ "))?s.current.focus():"Enter here"===(null===(o=e.relatedTarget)||void 0===o?void 0:o.placeholder)?e.relatedTarget.id!==m&&(j(!1),w(!1),g(!1)):(j(!1),w(!1),g(!1))}})]}))},b=o.div`
2
2
  margin-bottom: 32px;
3
3
  input {
4
- color: ${e=>e.isVar?n.stroke.brand:"black"};
4
+ color: ${e=>e.isVar?s.stroke.brand:"black"};
5
5
  }
6
- `;export{h as InputWithVariables};
6
+ `;export{p as InputWithVariables};
@@ -20,10 +20,9 @@ export interface TemplateContextMapperProps {
20
20
  zIndex?: number;
21
21
  showVariableModal?: boolean;
22
22
  variableList?: VariableListInterfaceV2[];
23
- variableListForImage?: VariableListInterfaceV2[];
24
23
  onBackPress?: () => void;
25
24
  discountCode?: string;
26
25
  setDiscountCode?: (code: string) => void;
27
26
  enabledCustomText?: boolean;
28
27
  }
29
- export declare const TemplateContextMapper: ({ selectedTemplate, closeDialog, showVariableMapping, channel, htmlContent, templateVariables, onTemplateSelect, globalPlaceholders, showOnlyContent, whatsappSpecificPickerMeta, zIndex, showVariableModal, variableList, discountCode, setDiscountCode, onBackPress, enabledCustomText, variableListForImage, }: TemplateContextMapperProps) => import("react/jsx-runtime").JSX.Element;
28
+ export declare const TemplateContextMapper: ({ selectedTemplate, closeDialog, showVariableMapping, channel, htmlContent, templateVariables, onTemplateSelect, globalPlaceholders, showOnlyContent, whatsappSpecificPickerMeta, zIndex, showVariableModal, variableList, discountCode, setDiscountCode, onBackPress, enabledCustomText, }: TemplateContextMapperProps) => import("react/jsx-runtime").JSX.Element;
@@ -1 +1 @@
1
- import{jsx as e,jsxs as t,Fragment as l}from"react/jsx-runtime";import{useEffect as o,useState as a,useMemo as i}from"react";import n from"../../utils/StringUtils.js";import{StyledModal as r}from"../modals/styledModal.js";import{CHANNEL_TYPE as s}from"../template-preview/models/Channels.js";import{TemplateModalContext as d}from"./context/templateModalContext.js";import c from"./modalElements/Footer.js";import m from"./modalElements/TemplateSelectModalContent.js";import{convertPlaceholdersToBikDropdown as p}from"./utils/convertPlaceholdersToBikDropdown.js";const u=u=>{let{selectedTemplate:h,closeDialog:g,showVariableMapping:b,channel:v,htmlContent:C,templateVariables:f,onTemplateSelect:M,globalPlaceholders:S,showOnlyContent:T,whatsappSpecificPickerMeta:j,zIndex:w,showVariableModal:L,variableList:P,discountCode:x,setDiscountCode:I,onBackPress:y,enabledCustomText:E,variableListForImage:V}=u;var k,D;o((()=>{z(C)}),[C]);const[A,O]=a(v===s.EMAIL?"desktop":"mobile"),[F,z]=a(C),[B,H]=a(!1),[$,N]=a(h),[U,W]=a(null!=f?f:[]),[_,q]=a(!1);const G=i((()=>p(S)),[S]);return e(d.Provider,Object.assign({value:{template:$,setTemplate:N,device:A,setDevice:O,display_content:F,setDisplayContent:z,originalVariableList:U,setOriginalVariableList:W,isError:B,setIsError:H,channel:v,globalNormalizedPlaceholders:G,templateSelectionTriggered:_,setTemplateSelectionTriggered:q,enabledCustomText:E}},{children:T?e(m,{channel:s.EMAIL,hideHeader:!0}):t(r,Object.assign({zIndex:w,centralContainerStyles:{width:v===s.EMAIL&&b?1e3:650},open:!0,onClose:()=>{null==g||g()},headingTitle:null==$?void 0:$.label,headingSubtitle:v===s.WHATSAPP?`${n.capitaliseFirstLetterOfString(null!==(k=null==$?void 0:$.category)&&void 0!==k?k:"")} • ${null!==(D=null==$?void 0:$.templateCategory)&&void 0!==D?D:""}`:"",onBackPress:()=>{null==y||y()}},{children:[e(m,{showVariableMapping:b,channel:v,whatsappSpecificPickerMeta:j,showVariableModal:L,variableList:P,discountCode:x,setDiscountCode:I,variableListForImage:V&&(null==V?void 0:V.length)>0?V:P}),M?e(c,{onSelect:function(){const e=null==M?void 0:M($,U,null!=F?F:"");e?H(!!e):q(!0)}}):e(l,{})]}))}))};export{u as TemplateContextMapper};
1
+ import{jsx as e,jsxs as t,Fragment as l}from"react/jsx-runtime";import{useEffect as o,useState as a,useMemo as i}from"react";import n from"../../utils/StringUtils.js";import{StyledModal as r}from"../modals/styledModal.js";import{CHANNEL_TYPE as s}from"../template-preview/models/Channels.js";import{TemplateModalContext as c}from"./context/templateModalContext.js";import d from"./modalElements/Footer.js";import m from"./modalElements/TemplateSelectModalContent.js";import{convertPlaceholdersToBikDropdown as p}from"./utils/convertPlaceholdersToBikDropdown.js";const h=h=>{let{selectedTemplate:u,closeDialog:g,showVariableMapping:b,channel:v,htmlContent:C,templateVariables:f,onTemplateSelect:M,globalPlaceholders:S,showOnlyContent:T,whatsappSpecificPickerMeta:P,zIndex:j,showVariableModal:w,variableList:x,discountCode:L,setDiscountCode:y,onBackPress:E,enabledCustomText:V}=h;var k,D;o((()=>{z(C)}),[C]);const[I,A]=a(v===s.EMAIL?"desktop":"mobile"),[O,z]=a(C),[B,F]=a(!1),[H,N]=a(u),[$,U]=a(null!=f?f:[]),[W,_]=a(!1);const q=i((()=>p(S)),[S]);return console.log("globalNormalizedPlaceholders",q),e(c.Provider,Object.assign({value:{template:H,setTemplate:N,device:I,setDevice:A,display_content:O,setDisplayContent:z,originalVariableList:$,setOriginalVariableList:U,isError:B,setIsError:F,channel:v,globalNormalizedPlaceholders:q,templateSelectionTriggered:W,setTemplateSelectionTriggered:_,enabledCustomText:V}},{children:T?e(m,{channel:s.EMAIL,hideHeader:!0}):t(r,Object.assign({zIndex:j,centralContainerStyles:{width:v===s.EMAIL&&b?1e3:650},open:!0,onClose:()=>{null==g||g()},headingTitle:null==H?void 0:H.label,headingSubtitle:v===s.WHATSAPP?`${n.capitaliseFirstLetterOfString(null!==(k=null==H?void 0:H.category)&&void 0!==k?k:"")} • ${null!==(D=null==H?void 0:H.templateCategory)&&void 0!==D?D:""}`:"",onBackPress:()=>{null==E||E()}},{children:[e(m,{showVariableMapping:b,channel:v,whatsappSpecificPickerMeta:P,showVariableModal:w,variableList:x,discountCode:L,setDiscountCode:y}),M?e(d,{onSelect:function(){const e=null==M?void 0:M(H,$,null!=O?O:"");e?F(!!e):_(!0)}}):e(l,{})]}))}))};export{h as TemplateContextMapper};
@@ -6,7 +6,6 @@ export interface BodyProps {
6
6
  whatsappSpecificPickerMeta?: WhatsAppPickerMeta;
7
7
  showVariableModal?: boolean;
8
8
  variableList?: VariableListInterfaceV2[];
9
- variableListForImage?: VariableListInterfaceV2[];
10
9
  discountCode?: string;
11
10
  setDiscountCode?: (code: string) => void;
12
11
  }
@@ -14,4 +14,4 @@ import{jsxs as e,jsx as t,Fragment as o}from"react/jsx-runtime";import{useRef as
14
14
  flex: 1;
15
15
  height: 475px;
16
16
  overflow-y: auto;
17
- `,g=l=>{const{showVariableMapping:g,showOnlyContent:b,whatsappSpecificPickerMeta:w,showVariableModal:x,variableList:y,discountCode:j,setDiscountCode:M,variableListForImage:C}=l,P=n(),E=n(),{device:T,display_content:k,channel:A,template:L,setTemplate:V}=r();const I=e=>{let t=0;for(;e;)t+=e.offsetTop,e=e.offsetParent;return t};return e(u,{children:[t(v,Object.assign({showOnlyContent:b,showVariableMapping:g},{children:"mobile"===T?t(c,{ref:E,display_content:null!=k?k:"",channel:A,template:L}):A!==i.MESSAGE?t(d,{ref:P,channel:A,display_content:null!=k?k:""}):t(o,{})})),g&&t(f,Object.assign({channel:A},{children:A!==i.WHATSAPP?t(h,{onFocus:A===i.EMAIL?function(e){var t,o,n;const l=null===document||void 0===document?void 0:document.getElementById("mobile"===T?"template_html_mobile":"template_html_desktop"),r=s(e+1),d=A===i.EMAIL?null===(t=null==l?void 0:l.contentWindow)||void 0===t?void 0:t.document.getElementById(r):document.getElementById(r),m=I(d),c=null==d?void 0:d.offsetLeft;"desktop"===T?m&&P.current&&(null===(o=null==l?void 0:l.contentWindow)||void 0===o||o.scrollTo(null!=c?c:0,m),p(r,a.background.warning.light,2,A,T)):m&&E.current&&(null===(n=null==l?void 0:l.contentWindow)||void 0===n||n.scrollTo(null!=c?c:0,m),p(r,a.background.warning.light,2,A,T))}:void 0,showVariableModal:x,variableList:y,discountCode:j,setDiscountCode:M}):t(m,{whatsappSpecificPickerMeta:w,template:L,onTemplateChange:e=>{null==V||V(e)},showVariableModal:x,variableList:y,variableListForImage:C})}))]})};export{g as default};
17
+ `,g=l=>{const{showVariableMapping:g,showOnlyContent:w,whatsappSpecificPickerMeta:b,showVariableModal:x,variableList:y,discountCode:j,setDiscountCode:M}=l,C=n(),P=n(),{device:E,display_content:T,channel:k,template:A,setTemplate:V}=r();const _=e=>{let t=0;for(;e;)t+=e.offsetTop,e=e.offsetParent;return t};return e(u,{children:[t(v,Object.assign({showOnlyContent:w,showVariableMapping:g},{children:"mobile"===E?t(c,{ref:P,display_content:null!=T?T:"",channel:k,template:A}):k!==i.MESSAGE?t(d,{ref:C,channel:k,display_content:null!=T?T:""}):t(o,{})})),g&&t(f,Object.assign({channel:k},{children:k!==i.WHATSAPP?t(h,{onFocus:k===i.EMAIL?function(e){var t,o,n;const l=null===document||void 0===document?void 0:document.getElementById("mobile"===E?"template_html_mobile":"template_html_desktop"),r=s(e+1),d=k===i.EMAIL?null===(t=null==l?void 0:l.contentWindow)||void 0===t?void 0:t.document.getElementById(r):document.getElementById(r),m=_(d),c=null==d?void 0:d.offsetLeft;"desktop"===E?m&&C.current&&(null===(o=null==l?void 0:l.contentWindow)||void 0===o||o.scrollTo(null!=c?c:0,m),p(r,a.background.warning.light,2,k,E)):m&&P.current&&(null===(n=null==l?void 0:l.contentWindow)||void 0===n||n.scrollTo(null!=c?c:0,m),p(r,a.background.warning.light,2,k,E))}:void 0,showVariableModal:x,variableList:y,discountCode:j,setDiscountCode:M}):t(m,{whatsappSpecificPickerMeta:b,template:A,onTemplateChange:e=>{null==V||V(e)},showVariableModal:x,variableList:y})}))]})};export{g as default};
@@ -1,14 +1,11 @@
1
- /// <reference types="react" />
2
1
  import { HEADER_TYPES } from "../../template-preview/models/TemplateMeta";
3
2
  export interface EditMediaV2Props {
4
3
  imageName: string[];
5
- selectedVariable?: string;
6
4
  errorSecondaryText?: string;
7
5
  error?: string;
8
6
  isLoading?: boolean;
9
7
  mediaType?: HEADER_TYPES;
10
8
  handleImageChange?: () => void;
11
- setOpenEditMedia?: React.Dispatch<React.SetStateAction<boolean>>;
12
9
  }
13
10
  declare const EditMediaV2: (props: EditMediaV2Props) => import("react/jsx-runtime").JSX.Element;
14
11
  export default EditMediaV2;
@@ -1,8 +1,8 @@
1
- import{jsxs as e,jsx as t,Fragment as i}from"react/jsx-runtime";import o from"../../../assets/icons/document_pdf.svg.js";import r from"../../../assets/icons/edit.svg.js";import s from"../../../assets/icons/refresh.svg.js";import n from"../../../assets/icons/video_camcorder.svg.js";import l from"styled-components";import{Spinner as d}from"../../spinner/Spinner.js";import{HEADER_TYPES as c}from"../../template-preview/models/TemplateMeta.js";import{BodyCaption as a,BodySecondary as m,Caption as p}from"../../TypographyStyle.js";import h from"../../../utils/StringUtils.js";import{COLORS as g}from"../../../constants/Theme.js";import{Container as f,ImageContainer as j,RightComponent as v}from"./EditMediaV2.style.js";const y=l.div`
1
+ import{jsxs as e,jsx as t,Fragment as i}from"react/jsx-runtime";import o from"../../../assets/icons/document_pdf.svg.js";import r from"../../../assets/icons/edit.svg.js";import s from"../../../assets/icons/refresh.svg.js";import n from"../../../assets/icons/video_camcorder.svg.js";import l from"styled-components";import{Spinner as c}from"../../spinner/Spinner.js";import{HEADER_TYPES as d}from"../../template-preview/models/TemplateMeta.js";import{BodyCaption as a,BodySecondary as m,Caption as p}from"../../TypographyStyle.js";import h from"../../../utils/StringUtils.js";import{COLORS as g}from"../../../constants/Theme.js";import{Container as f,ImageContainer as j,RightComponent as y}from"./EditMediaV2.style.js";const v=l.div`
2
2
  padding-left: 14px;
3
3
  padding-right: 6px;
4
4
  width: 44px;
5
5
  height: 24px;
6
6
  border-left: 1px solid ${g.stroke.primary};
7
7
  cursor: pointer;
8
- `,u=l=>{const{imageName:u,error:b,isLoading:x,mediaType:w,handleImageChange:O,selectedVariable:C,setOpenEditMedia:L}=l,E=null==u?void 0:u[0].split("/"),M=null==E?void 0:E[E.length-1];return e(f,{children:[t(j,Object.assign({error:!!b,onClick:b?O:void 0},{children:b?t(s,{color:g.content.brand,width:32,height:32}):x?t(d,{size:"small"}):w===c.IMAGE?t("img",{alt:"",src:null==u?void 0:u[0],style:{width:"100%",height:"56px",borderRadius:8,objectFit:"cover"}}):w===c.VIDEO?t(n,{width:18,height:22,color:g.content.placeholder}):t(o,{width:18,height:22,color:g.content.placeholder})})),e(v,{children:[t("div",Object.assign({style:{flex:1}},{children:u&&b?t(i,{}):x?t(a,Object.assign({style:{marginLeft:8}},{children:"Your media is getting loaded..."})):t(m,Object.assign({style:{color:g.content.primary,marginLeft:8}},{children:C||h.toCapitilize(null==w?void 0:w.toLowerCase())||M}))})),!!b&&e("div",Object.assign({style:{display:"flex",flexDirection:"column",marginLeft:8}},{children:[e(m,Object.assign({style:{color:g.content.negative}},{children:["Error loading this ",null==w?void 0:w.toLowerCase(),". Retry"]})),t(p,Object.assign({style:{color:g.content.secondary}},{children:b}))]})),!b&&!x&&t(y,Object.assign({onClick:()=>null==L?void 0:L(!0),onKeyDown:()=>null==L?void 0:L(!0),role:"presentation"},{children:t(r,{width:24,height:24,color:g.content.placeholder})}))]})]})};export{u as default};
8
+ `,u=l=>{const{imageName:u,error:b,isLoading:x,mediaType:w,handleImageChange:O}=l,C=null==u?void 0:u[0].split("/"),L=null==C?void 0:C[C.length-1];return e(f,{children:[t(j,Object.assign({error:!!b,onClick:b?O:void 0},{children:b?t(s,{color:g.content.brand,width:32,height:32}):x?t(c,{size:"small"}):w===d.IMAGE?t("img",{alt:"",src:null==u?void 0:u[0],style:{width:"100%",height:"56px",borderRadius:8,objectFit:"cover"}}):w===d.VIDEO?t(n,{width:18,height:22,color:g.content.placeholder}):t(o,{width:18,height:22,color:g.content.placeholder})})),e(y,{children:[t("div",Object.assign({style:{flex:1}},{children:u&&b?t(i,{}):x?t(a,Object.assign({style:{marginLeft:8}},{children:"Your media is getting loaded..."})):t(m,Object.assign({style:{color:g.content.primary,marginLeft:8}},{children:h.toCapitilize(null==w?void 0:w.toLowerCase())||L}))})),!!b&&e("div",Object.assign({style:{display:"flex",flexDirection:"column",marginLeft:8}},{children:[e(m,Object.assign({style:{color:g.content.negative}},{children:["Error loading this ",null==w?void 0:w.toLowerCase(),". Retry"]})),t(p,Object.assign({style:{color:g.content.secondary}},{children:b}))]})),!b&&!x&&t(v,Object.assign({onClick:O,onKeyDown:O,role:"presentation"},{children:t(r,{width:24,height:24,color:g.content.placeholder})}))]})]})};export{u as default};
@@ -1,11 +1,9 @@
1
1
  import React from 'react';
2
- import { VariableListInterfaceV2 } from "../../add-variableV2";
3
2
  import { WhatsAppPickerMeta, WhatsAppTemplate } from "../../template-preview/models/WhatsAppTemplate";
4
3
  declare const EditMediaTemplateMediaV2: React.FC<{
5
4
  mediaComponent: WhatsAppTemplate['components'][0];
6
5
  template: WhatsAppTemplate;
7
6
  whatsappSpecificPickerMeta: WhatsAppPickerMeta;
8
7
  updateTemplateImageUrl(url: string, format: WhatsAppTemplate['components'][0]['format']): void;
9
- variableListForImage?: VariableListInterfaceV2[];
10
8
  }>;
11
9
  export default EditMediaTemplateMediaV2;
@@ -1 +1 @@
1
- import{__awaiter as e}from"../../../_virtual/_tslib.js";import{jsxs as t,Fragment as o,jsx as i}from"react/jsx-runtime";import n,{useState as a}from"react";import{FileUploaderHelper as r}from"../../helpers/FileUploaderHelper.js";import{BikImageCropper as l}from"../../image-cropper/BikImageCropper.js";import"../../image-compress/ImageCompress.js";import"../../states/StateComponent.js";import"../../../constants/zindex.js";import"../../modals/styledModal.js";import"../../spinner/Spinner.js";import{HEADER_TYPES as s}from"../../template-preview/models/TemplateMeta.js";import{useTemplateModalContext as p}from"../context/templateModalContext.js";import d from"./EditMediaModal.js";import c from"./EditMediaV2.js";const m=m=>{let{mediaComponent:f,template:u,updateTemplateImageUrl:v,whatsappSpecificPickerMeta:g,variableListForImage:h}=m;var j,M,b;const[E,y]=a(void 0),[I,C]=a(),[O,A]=a(),[k,w]=a(!1),x=n.createRef(),[T,F]=a(!1),[R,U]=a(""),{template:L,setTemplate:N}=p();let D;function G(){var e;(null===(e=null==x?void 0:x.current)||void 0===e?void 0:e.click)&&x.current.click()}function _(t){var o;return e(this,void 0,void 0,(function*(){const e=new r;if(t instanceof Blob){const i=e.validate(t);if(i)U(i),F(!1);else{const e=f.format===s.IMAGE,i=yield g.uploadMediaFiles({file:t,fileName:E,isImage:e});if(i.success){const[e]=t.type.split("/");v(null!==(o=i.url)&&void 0!==o?o:"","application"===e?s.DOCUMENT:s[e.toUpperCase()])}else U("An unknown technical error occured");F(!1)}}else U("An unknown technical error occured"),F(!1)}))}return D=f.format===s.IMAGE?"image/png, image/jpeg":f.format===s.VIDEO?"video/mp4":"application/pdf",t(o,{children:[i(d,{mediaComponentFormat:null!==(j=f.format)&&void 0!==j?j:s.IMAGE,uploadMedia:function(t){var o;return e(this,void 0,void 0,(function*(){if(U(""),A(""),w(!1),t)if(t.startsWith("https"))try{F(!0);const e=yield fetch(t),o=yield e.blob();yield _(o)}catch(e){U("An unknown technical error occurred")}else if(/^{{.*}}$/.test(t)){A(t);const e=Object.assign({},L);if(e.components){const t=null===(o=null==e?void 0:e.components)||void 0===o?void 0:o.findIndex((e=>{if("HEADER"===e.type&&"NONE"!==e.format&&"TEXT"!==e.format)return!0}));if(void 0!==t&&t>-1&&(null==e?void 0:e.components[t])){const o=Object.assign(Object.assign({},e.components[t]),{format:f.format,example:{header_handle:["https://jkfenner.com/wp-content/uploads/2019/11/default.jpg"]}}),i=[...e.components];i[t]=o,e.components=i}}e.mapping&&(e.mapping=Object.assign(Object.assign({},e.mapping),{header:[t]})),F(!1),null==N||N(Object.assign({},e))}else F(!1),U("Invalid URL or variable");else G()}))},variableListForImage:h||[],setOpenEditMedia:w,openEditMedia:k}),!!I&&i(l,{aspectRatio:15/8,src:I,onCropComplete:function(t){return e(this,void 0,void 0,(function*(){F(!1),U("");const e=yield fetch(t);_(yield e.blob()).then((()=>{C(void 0)}))}))},onCancel:()=>{console.log("cancel"),F(!1),C("")}}),i("input",{ref:x,style:{display:"none"},type:"file",onChange:function(e){var t;U(""),F(!0);const o=null===(t=e.target.files)||void 0===t?void 0:t[0];if(f.format===s.IMAGE){const e=new FileReader;C(""),y(""),e.onload=()=>{C(e.result),y(null==o?void 0:o.name)},o&&e.readAsDataURL(o)}else _(o)},accept:D}),i(c,{imageName:null!==(b=null===(M=null==f?void 0:f.example)||void 0===M?void 0:M.header_handle)&&void 0!==b?b:[],handleImageChange:G,mediaType:null==f?void 0:f.format,error:R,isLoading:T,setOpenEditMedia:w,selectedVariable:O})]})};export{m as default};
1
+ import{__awaiter as e}from"../../../_virtual/_tslib.js";import{jsxs as o,Fragment as i,jsx as t}from"react/jsx-runtime";import n,{useState as r}from"react";import{FileUploaderHelper as a}from"../../helpers/FileUploaderHelper.js";import{BikImageCropper as l}from"../../image-cropper/BikImageCropper.js";import"../../image-compress/ImageCompress.js";import"../../states/StateComponent.js";import"../../../constants/zindex.js";import"../../modals/styledModal.js";import"../../spinner/Spinner.js";import{HEADER_TYPES as s}from"../../template-preview/models/TemplateMeta.js";import p from"./EditMediaV2.js";const m=m=>{let{mediaComponent:c,template:d,updateTemplateImageUrl:f,whatsappSpecificPickerMeta:u}=m;var v,g;const[h,j]=r(void 0),[C,y]=r(),I=n.createRef(),[M,k]=r(!1),[w,A]=r("");function E(o){var i;return e(this,void 0,void 0,(function*(){const e=new a;if(o instanceof Blob){const t=e.validate(o);if(t)A(t),k(!1);else{const e=c.format===s.IMAGE,t=yield u.uploadMediaFiles({file:o,fileName:h,isImage:e});if(t.success){const[e]=o.type.split("/");f(null!==(i=t.url)&&void 0!==i?i:"","application"===e?s.DOCUMENT:s[e.toUpperCase()])}else A("An unknown technical error occured");k(!1)}}else A("An unknown technical error occured"),k(!1)}))}let U;return U=c.format===s.IMAGE?"image/png, image/jpeg":c.format===s.VIDEO?"video/mp4":"application/pdf",o(i,{children:[!!C&&t(l,{aspectRatio:15/8,src:C,onCropComplete:function(o){return e(this,void 0,void 0,(function*(){k(!1),A("");const e=yield fetch(o);E(yield e.blob()).then((()=>{y(void 0)}))}))},onCancel:()=>{k(!1),y("")}}),t("input",{ref:I,style:{display:"none"},type:"file",onChange:function(e){var o;A(""),k(!0);const i=null===(o=e.target.files)||void 0===o?void 0:o[0];if(c.format===s.IMAGE){const e=new FileReader;y(""),j(""),e.onload=()=>{y(e.result),j(null==i?void 0:i.name)},i&&e.readAsDataURL(i)}else E(i)},accept:U}),t(p,{imageName:null!==(g=null===(v=null==c?void 0:c.example)||void 0===v?void 0:v.header_handle)&&void 0!==g?g:[],handleImageChange:function(){var e;(null===(e=null==I?void 0:I.current)||void 0===e?void 0:e.click)&&I.current.click()},mediaType:null==c?void 0:c.format,error:w,isLoading:M})]})};export{m as default};
@@ -8,7 +8,6 @@ export interface EditWhatsAppTemplateV2Props {
8
8
  onTemplateChange?: (template: WhatsAppTemplate | EmailTemplateType | SMSTemplateType) => void;
9
9
  showVariableModal?: boolean;
10
10
  variableList?: VariableListInterfaceV2[];
11
- variableListForImage?: VariableListInterfaceV2[];
12
11
  }
13
- declare const EditWhatsAppTemplateV2: ({ template, onTemplateChange, whatsappSpecificPickerMeta, showVariableModal, variableList, variableListForImage, }: EditWhatsAppTemplateV2Props) => import("react/jsx-runtime").JSX.Element;
12
+ declare const EditWhatsAppTemplateV2: ({ template, onTemplateChange, whatsappSpecificPickerMeta, showVariableModal, variableList, }: EditWhatsAppTemplateV2Props) => import("react/jsx-runtime").JSX.Element;
14
13
  export default EditWhatsAppTemplateV2;
@@ -1 +1 @@
1
- import{jsxs as t,jsx as e}from"react/jsx-runtime";import{useTemplateModalContext as o}from"../context/templateModalContext.js";import{getAllDataFromTemplateComponent as n}from"../utils/getDataFromTemplateComponent.js";import{EditTemplateMediaContainer as i}from"./EditMediaV2.style.js";import a from"./EditWhatsAppTemplateMediaV2.js";import{Container as l}from"./VariableConnectorsPanel.js";import s from"./VariableConnectorWhatsApp.js";import d from"./VariableEditorHeader.js";import p from"./WhatsAppTemplateCardButtonV2.js";const r=r=>{let{template:c,onTemplateChange:m,whatsappSpecificPickerMeta:u,showVariableModal:b,variableList:v,variableListForImage:g}=r;var h,f,j,T,O,x,y,E,V,C,w,I;const{originalVariableList:L}=o(),{descriptionComponents:B,urlBtns:R,qrbBtns:A,imageComponent:M,bodyVariables:U,headerVariables:S}=n(c);function k(t,e){var o,n,i,a;const l=Object.assign({},c),s=null==l?void 0:l.components.findIndex((t=>"BUTTONS"===t.type));if(void 0!==s&&s>-1){const d=null===(o=null==l?void 0:l.components[s].buttons)||void 0===o?void 0:o.findIndex((t=>"URL"===t.type));if(void 0!==d&&d>-1){const o="custom"===e&&"string"==typeof t,p=[...null!==(a=null===(i=null===(n=l.components)||void 0===n?void 0:n[s])||void 0===i?void 0:i.buttons)&&void 0!==a?a:[]];p[d]=Object.assign(Object.assign({},p[d]),{url:"https://d.bik.ai/{{1}}",example:[o?t:"string"!=typeof t?t.defaultValue:""]});const r=Object.assign(Object.assign({},l.components[s]),{buttons:p}),c=Object.assign(Object.assign({},l.mapping),{buttons:o?["((customBtnPlaceholder))"]:"string"!=typeof t?[t.placeHolder]:void 0});l.mapping=c;const m=[...l.components];m[s]=r,l.components=m}}null==m||m(l)}function N(t,e,o){var n;const i=Object.assign({},c),a=null==i?void 0:i.components.findIndex((t=>"BUTTONS"===t.type));if(void 0!==a&&a>-1){const e=null===(n=null==i?void 0:i.components[a].buttons)||void 0===n?void 0:n.filter((t=>"QUICK_REPLY"===t.type));e&&(e[o]=Object.assign(Object.assign({},e[o]),{flowId:t.flowId,flowName:t.flowName}));const l=Object.assign(Object.assign({},i.components[a]),{buttons:e}),s=[...i.components];s[a]=l,i.components=s}null==m||m(i)}return t(l,Object.assign({style:{flexDirection:"column",maxHeight:460}},{children:[!!M&&e(i,{children:e(a,{whatsappSpecificPickerMeta:u,mediaComponent:M,updateTemplateImageUrl:function(t,e){var o;let n=Object.assign({},c);const i=null===(o=null==n?void 0:n.components)||void 0===o?void 0:o.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 o=Object.assign(Object.assign({},n.components[i]),{format:e,example:{header_handle:[t]}}),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==m||m(Object.assign({},n))},template:c,variableListForImage:g})}),(U.length>0||S.length>0)&&e(d,{containerStyle:{paddingTop:M?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==B?void 0:B.map(((t,o)=>e(s,{originalVariableList:L,type:t.type,descriptionComponent:t.component,variableMapping:"HEADER"===t.type?c.mapping.header:c.mapping.body,showVariableModal:b,variableList:v},o))),(null===(f=null===(h=R[0])||void 0===h?void 0:h.component)||void 0===f?void 0:f.buttons)&&(null===(O=null===(T=null===(j=R[0])||void 0===j?void 0:j.component)||void 0===T?void 0:T.buttons)||void 0===O?void 0:O.length)>0&&e(d,{headerText:"Edit buttons",subText:"Edit the link connected to the CTA button"}),null===(x=null==L?void 0:L.buttons)||void 0===x?void 0:x.map(((t,o)=>{if("URL"===t.type)return e(p,{CTAoptions:null==u?void 0:u.CTAoptions,button:t,originalVariableList:L,updateSelectedURLTemplateBtn:k},`${o}`)})),(null===(E=null===(y=A[0])||void 0===y?void 0:y.component)||void 0===E?void 0:E.buttons)&&(null===(w=null===(C=null===(V=A[0])||void 0===V?void 0:V.component)||void 0===C?void 0:C.buttons)||void 0===w?void 0:w.length)>0&&e(d,{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"}),null===(I=null==L?void 0:L.buttons)||void 0===I?void 0:I.map(((t,o)=>{if("QUICK_REPLY"===t.type)return e(p,{QRBoptions:null==u?void 0:u.QRBoptions,button:t,originalVariableList:L,updateSelectedQRBTemplateBtn:N},`${o}`)}))]}))};export{r as default};
1
+ import{jsxs as t,jsx as o}from"react/jsx-runtime";import{useTemplateModalContext as e}from"../context/templateModalContext.js";import{getAllDataFromTemplateComponent as n}from"../utils/getDataFromTemplateComponent.js";import{EditTemplateMediaContainer as i}from"./EditMediaV2.style.js";import l from"./EditWhatsAppTemplateMediaV2.js";import{Container as a}from"./VariableConnectorsPanel.js";import s from"./VariableConnectorWhatsApp.js";import d from"./VariableEditorHeader.js";import p from"./WhatsAppTemplateCardButtonV2.js";const r=r=>{let{template:c,onTemplateChange:u,whatsappSpecificPickerMeta:m,showVariableModal:b,variableList:v}=r;var g,h,f,j,T,O,x,y,E,V,C,w;const{originalVariableList:B}=e(),{descriptionComponents:I,urlBtns:L,qrbBtns:R,imageComponent:A,bodyVariables:M,headerVariables:U}=n(c);function S(t,o){var e,n,i,l;const a=Object.assign({},c),s=null==a?void 0:a.components.findIndex((t=>"BUTTONS"===t.type));if(void 0!==s&&s>-1){const d=null===(e=null==a?void 0:a.components[s].buttons)||void 0===e?void 0:e.findIndex((t=>"URL"===t.type));if(void 0!==d&&d>-1){const e="custom"===o&&"string"==typeof t,p=[...null!==(l=null===(i=null===(n=a.components)||void 0===n?void 0:n[s])||void 0===i?void 0:i.buttons)&&void 0!==l?l:[]];p[d]=Object.assign(Object.assign({},p[d]),{url:"https://d.bik.ai/{{1}}",example:[e?t:"string"!=typeof t?t.defaultValue:""]});const r=Object.assign(Object.assign({},a.components[s]),{buttons:p}),c=Object.assign(Object.assign({},a.mapping),{buttons:e?["((customBtnPlaceholder))"]:"string"!=typeof t?[t.placeHolder]:void 0});a.mapping=c;const u=[...a.components];u[s]=r,a.components=u}}null==u||u(a)}function k(t,o,e){var n;const i=Object.assign({},c),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==u||u(i)}return t(a,Object.assign({style:{flexDirection:"column",maxHeight:460}},{children:[!!A&&o(i,{children:o(l,{whatsappSpecificPickerMeta:m,mediaComponent:A,updateTemplateImageUrl:function(t,o){var e;let n=Object.assign({},c);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})}null==u||u(n)},template:c})}),(M.length>0||U.length>0)&&o(d,{containerStyle:{paddingTop:A?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==I?void 0:I.map(((t,e)=>o(s,{originalVariableList:B,type:t.type,descriptionComponent:t.component,variableMapping:"HEADER"===t.type?c.mapping.header:c.mapping.body,showVariableModal:b,variableList:v},e))),(null===(h=null===(g=L[0])||void 0===g?void 0:g.component)||void 0===h?void 0:h.buttons)&&(null===(T=null===(j=null===(f=L[0])||void 0===f?void 0:f.component)||void 0===j?void 0:j.buttons)||void 0===T?void 0:T.length)>0&&o(d,{headerText:"Edit buttons",subText:"Edit the link connected to the CTA button"}),null===(O=null==B?void 0:B.buttons)||void 0===O?void 0:O.map(((t,e)=>{if("URL"===t.type)return o(p,{CTAoptions:null==m?void 0:m.CTAoptions,button:t,originalVariableList:B,updateSelectedURLTemplateBtn:S},`${e}`)})),(null===(y=null===(x=R[0])||void 0===x?void 0:x.component)||void 0===y?void 0:y.buttons)&&(null===(C=null===(V=null===(E=R[0])||void 0===E?void 0:E.component)||void 0===V?void 0:V.buttons)||void 0===C?void 0:C.length)>0&&o(d,{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"}),null===(w=null==B?void 0:B.buttons)||void 0===w?void 0:w.map(((t,e)=>{if("QUICK_REPLY"===t.type)return o(p,{QRBoptions:null==m?void 0:m.QRBoptions,button:t,originalVariableList:B,updateSelectedQRBTemplateBtn:k},`${e}`)}))]}))};export{r as default};
@@ -1,4 +1,4 @@
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{CHANNEL_TYPE as r}from"../../template-preview/models/Channels.js";const p=a.div`
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{CHANNEL_TYPE as r}from"../../template-preview/models/Channels.js";const p=o.div`
2
2
  position: relative;
3
3
  height: 100%;
4
4
  border-radius: 31px;
@@ -6,7 +6,7 @@ import{jsx as e,jsxs as t}from"react/jsx-runtime";import i from"react";import a
6
6
  background-color: white;
7
7
  margin: auto;
8
8
  overflow-y: auto;
9
- `,l=a.div`
9
+ `,l=o.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 a
17
17
  height: calc(100% - 17px);
18
18
  border-radius: 16px;
19
19
  overflow-y: auto;
20
- `,s=i.forwardRef(((i,a)=>{let{display_content:s,channel:m,template:n}=i;return e("div",{children:t(p,Object.assign({channel:m},{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:m===r.WHATSAPP?236:213,height:443}}),e(l,Object.assign({ref:a},{children:e(o,{template:n,channel:m,smsSpecificMeta:{smsDisplayContent:s},whatsAppSpecificMeta:{showWhatsAppHeader:!0,whatsAppExtras:!0,containerStyle:{border:"none",borderBottomRightRadius:0,borderBottomLeftRadius:0,minHeight:426}},size:"small",hideHeader:!0,emailSpecificMeta:{emailDisplayContent:s,hideViewButtonForEmail:!0,emailHtmlContainerId:"template_html_mobile",containerStyle:{height:"100%"},templateContainerStyles:{height:"100%"}}})}))]}))})}));s.displayName="MobilePreview";export{s as default};
20
+ `,s=i.forwardRef(((i,o)=>{let{display_content:s,channel:n,template:m}=i;return console.log("template",m),console.log("channel",n),console.log("display_content",s),e("div",{children:t(p,Object.assign({channel:n},{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:n===r.WHATSAPP?236:213,height:443}}),e(l,Object.assign({ref:o},{children:e(a,{template:m,channel:n,smsSpecificMeta:{smsDisplayContent:s},whatsAppSpecificMeta:{showWhatsAppHeader:!0,whatsAppExtras:!0,containerStyle:{border:"none",borderBottomRightRadius:0,borderBottomLeftRadius:0,minHeight:426}},size:"small",hideHeader:!0,emailSpecificMeta:{emailDisplayContent:s,hideViewButtonForEmail:!0,emailHtmlContainerId:"template_html_mobile",containerStyle:{height:"100%"},templateContainerStyles:{height:"100%"}}})}))]}))})}));s.displayName="MobilePreview";export{s as default};
@@ -9,9 +9,8 @@ export interface TemplateSelectModalContentProps {
9
9
  whatsappSpecificPickerMeta?: WhatsAppPickerMeta;
10
10
  showVariableModal?: boolean;
11
11
  variableList?: VariableListInterfaceV2[];
12
- variableListForImage?: VariableListInterfaceV2[];
13
12
  discountCode?: string;
14
13
  setDiscountCode?: (code: string) => void;
15
14
  }
16
- declare const TemplateSelectModalContent: ({ channel, showVariableMapping, showOnlyContent, whatsappSpecificPickerMeta, showVariableModal, variableList, discountCode, setDiscountCode, variableListForImage, }: TemplateSelectModalContentProps) => import("react/jsx-runtime").JSX.Element;
15
+ declare const TemplateSelectModalContent: ({ channel, showVariableMapping, showOnlyContent, whatsappSpecificPickerMeta, showVariableModal, variableList, discountCode, setDiscountCode, }: TemplateSelectModalContentProps) => import("react/jsx-runtime").JSX.Element;
17
16
  export default TemplateSelectModalContent;
@@ -1 +1 @@
1
- import{jsx as e,jsxs as a}from"react/jsx-runtime";import{CHANNEL_TYPE as t}from"../../template-preview/models/Channels.js";import i from"./Body.js";import o from"./Header.js";const s=s=>{let{channel:r,showVariableMapping:n,showOnlyContent:l,whatsappSpecificPickerMeta:d,showVariableModal:p,variableList:c,discountCode:m,setDiscountCode:h,variableListForImage:w}=s;return e("div",Object.assign({style:{paddingBottom:0}},{children:a("div",{children:[r===t.EMAIL&&e(o,{showOnlyContent:l}),e(i,{whatsappSpecificPickerMeta:d,showVariableMapping:!!n,showOnlyContent:l,showVariableModal:p,variableList:c,discountCode:m,setDiscountCode:h,variableListForImage:w})]})}))};export{s as default};
1
+ import{jsx as e,jsxs as t}from"react/jsx-runtime";import{CHANNEL_TYPE as o}from"../../template-preview/models/Channels.js";import i from"./Body.js";import a from"./Header.js";const s=s=>{let{channel:n,showVariableMapping:r,showOnlyContent:l,whatsappSpecificPickerMeta:d,showVariableModal:p,variableList:c,discountCode:h,setDiscountCode:m}=s;return e("div",Object.assign({style:{paddingBottom:0}},{children:t("div",{children:[n===o.EMAIL&&e(a,{showOnlyContent:l}),e(i,{whatsappSpecificPickerMeta:d,showVariableMapping:!!r,showOnlyContent:l,showVariableModal:p,variableList:c,discountCode:h,setDiscountCode:m})]})}))};export{s as default};
@@ -14,7 +14,6 @@ export interface VariableConnectorProps {
14
14
  showVariableModal?: boolean;
15
15
  variableList?: VariableListInterfaceV2[];
16
16
  setShowDiscountCheckBox?: any;
17
- componentType?: 'HEADER' | 'BODY' | 'BUTTONS' | 'FOOTER';
18
17
  }
19
18
  declare const VariableConnector: React.FC<VariableConnectorProps>;
20
19
  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 l}from"react/jsx-runtime";import t from"../../../assets/icons/edit.svg.js";import{useState as o,useEffect as a}from"react";import n from"styled-components";import{AddVariableV2SideModal as i}from"../../add-variableV2/AddVariableV2SideModal.js";import{Dropdown as u}from"../../dropdown/Dropdown.js";import{Input as s}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 m,BodyPrimary as p}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`
2
2
  /* surface/$color-background-warning-light */
3
3
 
4
4
  background: ${e=>e.focused&&e.channel===c.EMAIL?b.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)?`https://${L}`:L,W.value)}),100)}),[N]),i((()=>{!I&&W&&f.updatedValue&&setTimeout((()=>{ee("custom_link"===(null==W?void 0:W.value)?`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)?`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
+ `,f={value:"custom_link",label:"Custom URL"},_={value:"custom_text",label:"Custom text"},j=n=>{let{onFocus:j,variable:y,index:k,showVariableModal:V,variableList:A,setShowDiscountCheckBox:O}=n;var T;const[S,E]=o(!1),[P,w]=o(""),[L,C]=o([]),[M,W]=o(),[$,H]=o(!1),[I,B]=o(!1),{device:N,channel:z,isError:R,originalVariableList:U,template:D,templateSelectionTriggered:Z,setTemplate:G,setDisplayContent:q,setOriginalVariableList:F,globalNormalizedPlaceholders:Y,enabledCustomText:J}=g();function K(e,l){var t,o,a;const n=e;w(""),W(n),z===c.WHATSAPP?"custom_text"!==n.value&&"custom_link"!==n.value?(Q(null!==(t=n.value)&&void 0!==t?t:"","string"),null==X||X(null!==(o=y.index)&&void 0!==o?o:0,`[[${n.value}]]`)):(null==X||X(null!==(a=y.index)&&void 0!==a?a:0,y.variableName),Q("","url"===n.bikPlaceholderType?"link":"string")):"custom_text"!==n.value&&"custom_link"!==n.value?Q(n.value,"url"===n.bikPlaceholderType?"link":"string"):(w(""),Q("",n.value))}function Q(e,l){var t,o;const a="custom_link"===l?"link":"custom_text"===l?"string":l;if(z!==c.WHATSAPP){const o=h(k+1),n=null===document||void 0===document?void 0:document.getElementById("mobile"===N?"template_html_mobile":"template_html_desktop"),i=z===c.EMAIL?null===(t=null==n?void 0:n.contentWindow)||void 0===t?void 0:t.document.getElementById(o):document.getElementById(o);i&&(i.textContent="custom_text"!==l&&"custom_link"!==l||e?e:y.variableName);const u=U.map(((l,t)=>t===k?Object.assign(Object.assign({},l),{type:a,updatedValue:e}):l));null==F||F(u)}if(z===c.WHATSAPP){const l=null===(o=U.body)||void 0===o?void 0:o.map(((l,t)=>t===k?Object.assign(Object.assign({},l),{type:a,updatedValue:e}):l));null==F||F((e=>Object.assign(Object.assign({},e),{body:l,buttons:U.buttons})))}}function X(e,l){var t;const o=Object.assign({},D),a=null===(t=null==o?void 0:o.components)||void 0===t?void 0:t.map((t=>{var o,a,n,i,u;const s=Object.assign({},t);if("BODY"===t.type&&(null===(a=null===(o=t.example)||void 0===o?void 0:o.body_text)||void 0===a?void 0:a[0])){const t=[...null!==(u=null===(i=null===(n=s.example)||void 0===n?void 0:n.body_text)||void 0===i?void 0:i[0])&&void 0!==u?u:[]];t[e]=l.replace("{{","").replace("}}","").replace("((","").replace("))","");const o=Object.assign(Object.assign({},s.example),{body_text:[t]});return Object.assign(Object.assign({},s),{example:o})}return t}));o.components=a,null==G||G(o)}return a((()=>{S&&(null==j||j())}),[S]),a((()=>{!function(){var e,l,t,o,a;const n="mobile"===N?"template_html_mobile":"template_html_desktop",i=document.getElementById(n),u=(null!==(o=null===(t=null===(l=null===(e=null==i?void 0:i.contentWindow)||void 0===e?void 0:e.document)||void 0===l?void 0:l.body)||void 0===t?void 0:t.innerHTML)&&void 0!==o?o:"")+(null===(a=null==i?void 0:i.contentWindow)||void 0===a?void 0:a.document.head.innerHTML);z===c.EMAIL&&(null==q||q(u))}()}),[Z]),a((()=>{var e;const l=[];let t=[];if(z!==c.MESSAGE||J){"link"===(null==y?void 0:y.type)?(l.push({label:"",options:[f,_]}),W(f)):(l.push({label:"",options:[f,_]}),W(_));const e=null!=Y?Y:[];console.log("globalOptions",e),C([...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!=Y?Y:[];console.log("globalOptions",e),C([{label:"",options:[_,f]},...e]),t=[{label:"",options:[_,f]},...e]}if((z===c.WHATSAPP||z===c.EMAIL||z===c.MESSAGE)&&y.updatedValue)if(r.test(y.updatedValue)&&z===c.WHATSAPP||y.updatedValue.startsWith("{{")&&z!==c.WHATSAPP){const e=function(e,l,t){var o;let a={label:"",value:""};const n=t===c.WHATSAPP?e.updatedValue.replace("[[","").replace("]]",""):e.updatedValue.replace("{{","").replace("}}","");V?a={label:e.updatedValue?e.updatedValue.replace("{{","").replace("}}","").trim().replace("."," "):"",value:null!==(o=e.updatedValue)&&void 0!==o?o:""}:l.map((e=>{e.options.map((e=>{var l;(null===(l=e.value)||void 0===l?void 0:l.replace("{{","").replace("}}","").trim())===n.trim()&&(a=e)}))}));return console.log("preSelectedOption",a),a}(y,t,z);e.value&&W(e)}else(null===(e=y.updatedValue)||void 0===e?void 0:e.startsWith("https"))?(W(f),w(y.updatedValue.split("https://")[1])):(W(_),w(y.updatedValue))}),[]),a((()=>{N&&M&&P&&setTimeout((()=>{Q("custom_link"===(null==M?void 0:M.value)?`https://${P}`:P,M.value)}),100)}),[N]),a((()=>{!I&&M&&y.updatedValue&&setTimeout((()=>{Q("custom_link"===(null==M?void 0:M.value)?`https://${y.updatedValue}`:y.updatedValue,M.value),B(!0)}),100)}),[M]),e(x,Object.assign({channel:z,focused:S,onMouseEnter:()=>E(!0),onMouseLeave:()=>E(!1)},{children:[l("div",Object.assign({style:{marginBottom:8}},{children:l(m,Object.assign({style:{color:R&&!M?b.content.negative:b.content.primary}},{children:"link"===(null==y?void 0:y.type)?"link":"variable"}))})),l("div",Object.assign({style:{marginBottom:12}},{children:V?e("div",Object.assign({style:{display:"flex",border:"#E0E0E0 1px solid",borderRadius:4,padding:10,justifyContent:(null==M?void 0:M.label)?"space-between":"flex-end"}},{children:[l(p,{children:d(null!==(T=null==M?void 0:M.label)&&void 0!==T?T:"",20,!0)}),l(t,{onClick:()=>{H(!$)},width:24,height:24,color:b.content.primary})]})):l(u,{options:L,isSearchable:!1,onSelect:K,defaultOptions:M?[Object.assign(Object.assign({},M),{selected:!0})]:[]})})),("custom_text"===(null==M?void 0:M.value)||"custom_link"===(null==M?void 0:M.value))&&l(s,{labelText:"custom_text"===(null==M?void 0:M.value)?"Custom text value":"custom_link"===(null==M?void 0:M.value)?"Custom URL value":"",id:`variable-value-${null==M?void 0:M.value}-${k}`,value:P,errorMessage:R?P&&0!==P.trim().length?"custom_link"!==M.value||/^https?:\/\/(?:www\.)?[-a-zA-Z0-9@:%._\+~#=]{1,256}\.[a-zA-Z0-9()]{1,6}\b(?:[-a-zA-Z0-9()@:%_\+.~#?&\/=]*)$/.test(`https://${P.trim()}`)&&0!==P.trim().length?"custom_link"!==M.value&&P.length>30?"Length cannot be more than 30":"":"Enter valid URL":"Required field":"",maxCharLimit:"custom_link"===(null==M?void 0:M.value)?void 0:30,prefixText:"custom_link"===(null==M?void 0:M.value)?"https://":"",placeholder:"link"===y.type||"custom_link"===M.value?"Enter custom URL here":"Enter custom text here",onChangeText:e=>{!function(e,l){var t;w(l);const o="custom_link"===(null==M?void 0:M.value)?`https://${l}`:l;Q(o,e),z===c.WHATSAPP&&(null==X||X(null!==(t=y.index)&&void 0!==t?t:0,o))}(M.value,e)}}),$&&l(i,{zIndex:2e3,data:null!=A?A:[],showVariable:$,setShowVariable:H,placeholder:"Add a variable",customTrigger:e=>{console.log("variable",e),null==O||O(!1),"{{custom.url}}"===e.actualValue?K({label:e.displayName,selected:!0,value:"custom_link"}):"{{custom.text}}"==e.actualValue?K({label:e.displayName,selected:!0,value:"custom_text"}):K({label:e.defaultValue||e.displayName,selected:!0,value:e.actualValue,bikPlaceholderType:"string"})}})]}))};export{x as Container,j as default};
@@ -1,3 +1,4 @@
1
+ /// <reference types="react" />
1
2
  import { VariableListInterfaceV2 } from "../../add-variableV2/AddVariableV2";
2
3
  import { WhatsAppTemplate, WhatsAppTemplateVariables } from "../../template-preview/models/WhatsAppTemplate";
3
4
  export type ComponentType = WhatsAppTemplate['components'][0];
@@ -9,5 +10,5 @@ export interface VariableConnectorWhatsAppProps {
9
10
  showVariableModal?: boolean;
10
11
  variableList?: VariableListInterfaceV2[];
11
12
  }
12
- declare const VariableConnectorWhatsApp: ({ descriptionComponent, type, showVariableModal, variableList, }: VariableConnectorWhatsAppProps) => import("react/jsx-runtime").JSX.Element;
13
+ declare const VariableConnectorWhatsApp: React.FC<VariableConnectorWhatsAppProps>;
13
14
  export default VariableConnectorWhatsApp;
@@ -1 +1 @@
1
- import{jsx as e,jsxs as a,Fragment as i}from"react/jsx-runtime";import{Input as t}from"../../input/Input.js";import{BodySecondary as r}from"../../TypographyStyle.js";import{COLORS as o}from"../../../constants/Theme.js";import{useTemplateModalContext as l}from"../context/templateModalContext.js";import n from"./VariableConnector.js";const d=d=>{let{descriptionComponent:s,type:p,showVariableModal:c,variableList:m}=d;var b,v;const{originalVariableList:y}=l();return"BODY"===s.type?e("div",{children:null===(b=null==y?void 0:y.body)||void 0===b?void 0:b.map(((i,l)=>i.isEditableVariable?e(n,{index:l,variable:i,showVariableModal:c,variableList:m,componentType:s.type},`${l}-${i.index}`):a("div",Object.assign({style:{margin:"16px 8px"}},{children:[a(r,Object.assign({style:{color:o.content.primary}},{children:["HEADER"===p?"Header":""," Locked variable ",l+1]})),e(t,{state:"disabled",placeholder:i.variableName,onChangeText:()=>{}})]}),l)))}):"HEADER"===s.type?e("div",{children:null===(v=null==y?void 0:y.header)||void 0===v?void 0:v.map(((i,l)=>i.isEditableVariable?e(n,{index:l,variable:i,showVariableModal:c,variableList:m,componentType:s.type},`${l}-${i.index}`):a("div",Object.assign({style:{margin:"16px 8px"}},{children:[a(r,Object.assign({style:{color:o.content.primary}},{children:["HEADER"===p?"Header":""," Locked variable ",l+1]})),e(t,{state:"disabled",placeholder:i.variableName,onChangeText:()=>{}})]}),l)))}):e(i,{})};export{d as default};
1
+ import{jsx as e,jsxs as a,Fragment as t}from"react/jsx-runtime";import{Input as i}from"../../input/Input.js";import{BodySecondary as r}from"../../TypographyStyle.js";import{COLORS as o}from"../../../constants/Theme.js";import{useTemplateModalContext as l}from"../context/templateModalContext.js";import n from"./VariableConnector.js";const s=s=>{let{descriptionComponent:d,type:p,showVariableModal:m,variableList:c}=s;var b;const{originalVariableList:v}=l();return"BODY"===d.type?e("div",{children:null===(b=null==v?void 0:v.body)||void 0===b?void 0:b.map(((t,l)=>t.isEditableVariable?e(n,{index:l,variable:t,showVariableModal:m,variableList:c},`${l}-${t.index}`):a("div",Object.assign({style:{margin:"16px 8px"}},{children:[a(r,Object.assign({style:{color:o.content.primary}},{children:["HEADER"===p?"Header":""," Locked variable ",l+1]})),e(i,{state:"disabled",placeholder:t.variableName,onChangeText:()=>{}})]}),l)))}):e(t,{})};export{s as default};
@@ -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 n}from"../../template-preview/constants/regexPatterns.js";import{CUSTOM_URL_NAME as i}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 c}from"../../../constants/Theme.js";import{useTemplateModalContext as m}from"../context/templateModalContext.js";import{validateIsUrl as d}from"../utils/validateIsUrl.js";import{Container as u}from"./VariableConnector.js";const b=b=>{let{button:f,updateSelectedURLTemplateBtn:j,updateSelectedQRBTemplateBtn:g,originalVariableList:h,CTAoptions:v,QRBoptions:y}=b;const[O,x]=l(""),[R,L]=l(),{setOriginalVariableList:U,isError:w}=m();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&&n.test(f.buttonVariable))L(i),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(u,{children:[t("div",Object.assign({style:{marginBottom:8}},{children:e(p,Object.assign({style:{color:c.content.primary}},{children:[f.text," button"]}))})),t("div",Object.assign({style:{marginBottom:12}},{children:t(a,{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,{errorMessage:w?O?d(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{b as default};
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 n}from"../../input/Input.js";import{editableVarPattern as s}from"../../template-preview/constants/regexPatterns.js";import{CUSTOM_URL_NAME as i}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 m}from"../../../constants/Theme.js";import{useTemplateModalContext as c}from"../context/templateModalContext.js";import{validateIsUrl as d}from"../utils/validateIsUrl.js";import{Container as u}from"./VariableConnector.js";const b=b=>{let{button:f,updateSelectedURLTemplateBtn:j,updateSelectedQRBTemplateBtn:g,originalVariableList:h,CTAoptions:v,QRBoptions:y}=b;const[x,O]=l(""),[R,L]=l(),{setOriginalVariableList:U,isError:w}=c();function T(e){O(e);const t=[Object.assign(Object.assign({},h.buttons[0]),{type:r.URL,buttonVariable:"((customPlaceholderName))",example:[`https://${e}`]})];null==U||U({body:[...h.body],buttons:[...t]}),null==j||j(`https://${e}`,"custom")}return o((()=>{var e;if(f.buttonVariable&&s.test(f.buttonVariable))L(i),O((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(u,{children:[t("div",Object.assign({style:{marginBottom:8}},{children:e(p,Object.assign({style:{color:m.content.primary}},{children:[f.text," button"]}))})),t("div",Object.assign({style:{marginBottom:12}},{children:t(a,{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({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(n,{errorMessage:w?x?d(x)?"":"Enter valid URL":"Required field":"",value:x,prefixText:"custom_link"===(null==R?void 0:R.value)?"https://":"",placeholder:"Enter custom URL here",onChangeText:T})}))]})};export{b as default};
@@ -1 +1 @@
1
- const a=/\[\[[A-Za-z0-9 .]+\]\]/,z=/\((\(|\[)[A-Za-z0-9 ]+(\]|\))\)/,A=/(\[\[|\{\{|\(\()(.*?)(\)\)|\}\}|\]\])/,Z=/\{\{[A-Za-z0-9 .]+\}\}/g,g=/\{\{[a-zA-Z0-9]+(?=( |\}))(?!\}\})/g,_=/[!@#$%^&*()_+\-={};':"\\|,.<>?]+/,o=/\{\{[A-Za-z0-9 ._]+\}\}/,t=/\{\{[A-Za-z0-9 _]+\}\}/g,c=Z,e=/\[([^[]+)\](\(.*\))/,n=/[((|))]/;export{n as editableBracketPattern,z as editableVarPattern,g as globalHalfVariablePattern,Z as globalVariablePattern,a as lockedVarPattern,A as placeHolderNamePattern,e as previewLinkMDFormatPattern,_ as specialCharPattern,c as templateVariablePattern,o as variablePattern,t as variablePatternGlobal};
1
+ const a=/\[\[[A-Za-z0-9 .]+\]\]/,z=/\((\(|\[)[A-Za-z0-9 ]+(\]|\))\)/,A=/(\[\[|\{\{||\(\()(.*)(\)\)|\}\}|\]\])/,Z=/\{\{[A-Za-z0-9 .]+\}\}/g,g=/\{\{[a-zA-Z0-9]+(?=( |\}))(?!\}\})/g,_=/[!@#$%^&*()_+\-={};':"\\|,.<>?]+/,o=/\{\{[A-Za-z0-9 ._]+\}\}/,t=/\{\{[A-Za-z0-9 _]+\}\}/g,c=Z,e=/\[([^[]+)\](\(.*\))/,n=/[((|))]/;export{n as editableBracketPattern,z as editableVarPattern,g as globalHalfVariablePattern,Z as globalVariablePattern,a as lockedVarPattern,A as placeHolderNamePattern,e as previewLinkMDFormatPattern,_ as specialCharPattern,c as templateVariablePattern,o as variablePattern,t as variablePatternGlobal};
@@ -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){var t,n,i,o,l,a,d,r,v,s;const u={headerType:k.NONE,headerVariables:[]},p=null===(t=e.components)||void 0===t?void 0:t.find((e=>"HEADER"===e.type));if(p){u.headerType=p.format,u.headerText=p.text,u.headerAssetLink=null===(i=null===(n=p.example)||void 0===n?void 0:n.header_handle)||void 0===i?void 0:i[0];const t=null===(l=null===(o=p.example)||void 0===o?void 0:o.header_text)||void 0===l?void 0:l[0],c=null===(d=null===(a=e.mapping)||void 0===a?void 0:a.header)||void 0===d?void 0:d[0];if(t&&c){const e=null==c?void 0:c.replace("[[","").replace("]]","").replace("{{","").replace("}}","").replace("((","").replace("))",""),n=/\(\(/.test(c),i={idx:0,variableVal:t,editable:n,editableDefaultValues:n?void 0:t,variableName:e};u.headerVariables=[i],(null===(v=null===(r=p.example)||void 0===r?void 0:r.header_text)||void 0===v?void 0:v.length)&&(u.headerText=null===(s=u.headerText)||void 0===s?void 0:s.replace("{{1}}",`{{${e}}}`))}}return u}validateState(e){var t,i,o,C,L,E,R,_,w,A,V,I,D,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]},H=new g;let S=!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&&!S&&(G(x.name),S=!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=H.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&&!S&&(G(x.header),S=!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&&!S&&(G(x.body),S=!0),e.footerText&&e.footerText.length>v&&(Q.footer=s,M="invalid"),(null==Q?void 0:Q.footer)&&!S&&(G(x.footer),S=!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===(w=null===(_=e.ctaBtn)||void 0===_?void 0:_.websiteLinkBtn)||void 0===w?void 0:w.isChecked){const t=null===(A=e.ctaBtn.websiteLinkBtn.btnText)||void 0===A?void 0:A.trim(),n=null===(V=e.ctaBtn.websiteLinkBtn.linkOpens)||void 0===V?void 0:V.trim(),i=null===(I=e.ctaBtn.websiteLinkBtn.placeholder)||void 0===I?void 0:I.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===(D=Q.quickReply)||void 0===D?void 0:D.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)&&!S&&(G(x.actionButtons),S=!0)}return{status:M,errors:Q}}parseBodyComponent(e){let n=arguments.length>1&&void 0!==arguments[1]&&arguments[1];var o,l,a,d,r;const v=[];let s="";const u=null===(o=e.components)||void 0===o?void 0:o.find((e=>"BODY"===e.type));return u&&(null===(a=null===(l=u.example)||void 0===l?void 0:l.body_text)||void 0===a||a[0].forEach(((t,n)=>{var o,l;let a=null===(l=null===(o=e.mapping)||void 0===o?void 0:o.body)||void 0===l?void 0:l[n];const d=a&&/\(\(/.test(a),r=null==a?void 0:a.match(i);(null==r?void 0:r[2])&&(a=null==r?void 0:r[2]),v.push({idx:n,variableVal:t,editable:!!d,editableDefaultValues:d?void 0:t,variableName:null!=a?a:""})})),s=e.htmlContentUrl?e.htmlContentUrl:(null===(d=u.text)||void 0===d?void 0:d.split(/\{\{[0-9]+\}\}/).length)?null===(r=u.text)||void 0===r?void 0:r.split(/\{\{[0-9]+\}\}/).map(((e,i)=>{if(null==v?void 0:v[i]){const o=v[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:v,bodyText:s}}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,n){let i=arguments.length>2&&void 0!==arguments[2]&&arguments[2];var o;return e(this,void 0,void 0,(function*(){const{headerType:e,headerAssetLink:l,headerAssetName:a,headerText:d,headerVariables:r}=yield this.parseDataFromHeaderComponent(t),{bodyText:v,bodyVariable:s}=yield this.parseBodyComponent(t,i),{actionsType:u,quickReply:p,ctaBtn:c}=yield this.parseButtonComponent(t),m={quickReply:p,ctaBtn:c,meta:{name:n?`${t.label} Copy`:t.label,category:null===(o=t.category)||void 0===o?void 0:o.toUpperCase(),subCategory:t.templateCategory,language:t.language,templateId:t.templateId},error:{header:void 0,body:void 0,footer:void 0,quickReply:void 0,meta:void 0,ctaBtn:void 0},actionsType:u,footerText:this.parseFooterComponent(t),bodyVariables:s,bodyText:v,headerType:e,headerAssetLink:l,headerAssetName:a,headerText:d,headerVariables:r,alreadyAsADraft:t.isDraft,mode:"edit",initialLoading:!1},{errors:h}=this.validateState(m);return m.error=h,m}))}}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){var t,n,i,o,l,a,d,r,v,s;const u={headerType:k.NONE,headerVariables:[]},p=null===(t=e.components)||void 0===t?void 0:t.find((e=>"HEADER"===e.type));if(p){u.headerType=p.format,u.headerText=p.text,u.headerAssetLink=null===(i=null===(n=p.example)||void 0===n?void 0:n.header_handle)||void 0===i?void 0:i[0];const t=null===(l=null===(o=p.example)||void 0===o?void 0:o.header_text)||void 0===l?void 0:l[0],c=null===(d=null===(a=e.mapping)||void 0===a?void 0:a.header)||void 0===d?void 0:d[0];if(t&&c){const e=null==c?void 0:c.replace("[[","").replace("]]","").replace("{{","").replace("}}","").replace("((","").replace("))",""),n=/\(\(/.test(c),i={idx:0,variableVal:t,editable:n,editableDefaultValues:n?void 0:t,variableName:e};u.headerVariables=[i],(null===(v=null===(r=p.example)||void 0===r?void 0:r.header_text)||void 0===v?void 0:v.length)&&(u.headerText=null===(s=u.headerText)||void 0===s?void 0:s.replace("{{1}}",`{{${e}}}`))}}return u}validateState(e){var t,i,o,C,L,E,R,_,w,A,V,I,D,U,O,q,F,P,j,$,Y;const K=/\p{Extended_Pictographic}/u;let M="valid";const Q={meta:{},ctaBtn:{phoneNumber:{btnText:"",link:""},websiteLink:{btnText:"",link:""}},quickReply:[null,null,null]},H=new g;let S=!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&&!S&&(G(x.name),S=!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=H.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&&!S&&(G(x.header),S=!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&&!S&&(G(x.body),S=!0),e.footerText&&e.footerText.length>v&&(Q.footer=s,M="invalid"),(null==Q?void 0:Q.footer)&&!S&&(G(x.footer),S=!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===(w=null===(_=e.ctaBtn)||void 0===_?void 0:_.websiteLinkBtn)||void 0===w?void 0:w.isChecked){const t=null===(A=e.ctaBtn.websiteLinkBtn.btnText)||void 0===A?void 0:A.trim(),n=null===(V=e.ctaBtn.websiteLinkBtn.linkOpens)||void 0===V?void 0:V.trim(),i=null===(I=e.ctaBtn.websiteLinkBtn.placeholder)||void 0===I?void 0:I.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===(D=Q.quickReply)||void 0===D?void 0:D.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===(j=null===(P=Q.ctaBtn)||void 0===P?void 0:P.phoneNumber)||void 0===j?void 0:j.link)||(null===(Y=null===($=Q.ctaBtn)||void 0===$?void 0:$.phoneNumber)||void 0===Y?void 0:Y.btnText)||e)&&!S&&(G(x.actionButtons),S=!0)}return{status:M,errors:Q}}parseBodyComponent(e){let n=arguments.length>1&&void 0!==arguments[1]&&arguments[1];var o,l,a,d,r;const v=[];let s="";const u=null===(o=e.components)||void 0===o?void 0:o.find((e=>"BODY"===e.type));return u&&(null===(a=null===(l=u.example)||void 0===l?void 0:l.body_text)||void 0===a||a[0].forEach(((t,n)=>{var o,l;let a=null===(l=null===(o=e.mapping)||void 0===o?void 0:o.body)||void 0===l?void 0:l[n];const d=a&&/\(\(/.test(a),r=null==a?void 0:a.match(i);console.log({matchedPlaceholderName:r}),(null==r?void 0:r[2])&&(a=null==r?void 0:r[2]),v.push({idx:n,variableVal:t,editable:!!d,editableDefaultValues:d?void 0:t,variableName:null!=a?a:""})})),s=e.htmlContentUrl?e.htmlContentUrl:(null===(d=u.text)||void 0===d?void 0:d.split(/\{\{[0-9]+\}\}/).length)?null===(r=u.text)||void 0===r?void 0:r.split(/\{\{[0-9]+\}\}/).map(((e,i)=>{if(null==v?void 0:v[i]){const o=v[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:v,bodyText:s}}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,n){let i=arguments.length>2&&void 0!==arguments[2]&&arguments[2];var o;return e(this,void 0,void 0,(function*(){const{headerType:e,headerAssetLink:l,headerAssetName:a,headerText:d,headerVariables:r}=yield this.parseDataFromHeaderComponent(t),{bodyText:v,bodyVariable:s}=yield this.parseBodyComponent(t,i),{actionsType:u,quickReply:p,ctaBtn:c}=yield this.parseButtonComponent(t),m={quickReply:p,ctaBtn:c,meta:{name:n?`${t.label} Copy`:t.label,category:null===(o=t.category)||void 0===o?void 0:o.toUpperCase(),subCategory:t.templateCategory,language:t.language,templateId:t.templateId},error:{header:void 0,body:void 0,footer:void 0,quickReply:void 0,meta:void 0,ctaBtn:void 0},actionsType:u,footerText:this.parseFooterComponent(t),bodyVariables:s,bodyText:v,headerType:e,headerAssetLink:l,headerAssetName:a,headerText:d,headerVariables:r,alreadyAsADraft:t.isDraft,mode:"edit",initialLoading:!1},{errors:h}=this.validateState(m);return m.error=h,m}))}}export{C as TemplateCreatorHelper};
@@ -198,7 +198,6 @@ export type WhatsAppMediaUploadRequest = {
198
198
  };
199
199
  export interface WhatsAppTemplateVariables {
200
200
  body: CUSTOM_VARIABLE[];
201
- header: CUSTOM_VARIABLE[];
202
201
  buttons: TEMPLATE_BUTTON[];
203
202
  }
204
203
  export type CTABtnValType = {
@@ -1 +1 @@
1
- import{templateVariablePattern as l,globalVariablePattern as e}from"../constants/regexPatterns.js";class a{fillVariablesValInBodyText(e,a){let i=arguments.length>2&&void 0!==arguments[2]&&arguments[2];const r=e.match(l),t=e.split(l);if(e&&(null==r?void 0:r.length)){return t.map(((l,e)=>{var n,o,v,d,u;const m=null===(n=null==r?void 0:r[e])||void 0===n?void 0:n.replace("{{","").replace("}}","");return t.length-1===e?l:(null===(v=null===(o=null==a?void 0:a[e])||void 0===o?void 0:o.variableName)||void 0===v?void 0:v.trim())===m.trim()||(null===(u=null===(d=null==a?void 0:a[e])||void 0===d?void 0:d.variableVal)||void 0===u?void 0:u.trim())===m.trim()?a[e].editable?`${l}${i?"{{":""}${a[e].variableVal}${i?"}}":""}`:`${l}${i?"{{":""}${a[e].variableName}${i?"}}":""}`:l})).join("")}return e}getTemplateVariablesFromState(l){var a;return null===(a=l.match(e))||void 0===a?void 0:a.map((l=>l.replace("{{","").replace("}}","")))}whatsappOnlyFillVariablesValueInBodyText(e,a){let i=arguments.length>2&&void 0!==arguments[2]&&arguments[2];const r=e.match(l),t=e.split(l);if(e&&(null==r?void 0:r.length)){return t.map(((l,e)=>{var n;const o=null===(n=null==r?void 0:r[e])||void 0===n?void 0:n.replace("{{","").replace("}}","");if(t.length-1===e)return l;const v=a.findIndex((l=>l.variableName===o));if(v>-1){let e=a[v].variableVal;return i||(e=!a[v].variableVal&&a[v].variableName.startsWith("editableVariable")?a[v].variableName:null==e?void 0:e.replace("[[","").replace("]]","")),a[v].editable?`${l}${i?"{{":""}${e}${i?"}}":""}`:`${l}${i?"{{":""}${o}${i?"}}":""}`}return l})).join("")}return e}}export{a as TemplateHelperUtils};
1
+ import{templateVariablePattern as l,globalVariablePattern as e}from"../constants/regexPatterns.js";class a{fillVariablesValInBodyText(e,a){let i=arguments.length>2&&void 0!==arguments[2]&&arguments[2];const r=e.match(l),t=e.split(l);if(e&&(null==r?void 0:r.length)){return t.map(((l,e)=>{var n,o,v,d,u;const s=null===(n=null==r?void 0:r[e])||void 0===n?void 0:n.replace("{{","").replace("}}","");return t.length-1===e?l:(null===(v=null===(o=null==a?void 0:a[e])||void 0===o?void 0:o.variableName)||void 0===v?void 0:v.trim())===s.trim()||(null===(u=null===(d=null==a?void 0:a[e])||void 0===d?void 0:d.variableVal)||void 0===u?void 0:u.trim())===s.trim()?a[e].editable?`${l}${i?"{{":""}${a[e].variableVal}${i?"}}":""}`:`${l}${i?"{{":""}${a[e].variableName}${i?"}}":""}`:l})).join("")}return e}getTemplateVariablesFromState(l){var a;return null===(a=l.match(e))||void 0===a?void 0:a.map((l=>l.replace("{{","").replace("}}","")))}whatsappOnlyFillVariablesValueInBodyText(e,a){let i=arguments.length>2&&void 0!==arguments[2]&&arguments[2];const r=e.match(l);console.log("variableList",r);const t=e.split(l);if(e&&(null==r?void 0:r.length)){return t.map(((l,e)=>{var n;const o=null===(n=null==r?void 0:r[e])||void 0===n?void 0:n.replace("{{","").replace("}}","");if(t.length-1===e)return l;const v=a.findIndex((l=>l.variableName===o));if(v>-1){let e=a[v].variableVal;return i||(e=!a[v].variableVal&&a[v].variableName.startsWith("editableVariable")?a[v].variableName:null==e?void 0:e.replace("[[","").replace("]]","")),a[v].editable?`${l}${i?"{{":""}${e}${i?"}}":""}`:`${l}${i?"{{":""}${o}${i?"}}":""}`}return l})).join("")}return e}}export{a as TemplateHelperUtils};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bikdotai/bik-component-library",
3
- "version": "0.0.359-beta.30",
3
+ "version": "0.0.359-beta.4",
4
4
  "description": "Bik Component Library",
5
5
  "repository": {
6
6
  "type": "git",
@@ -1,11 +0,0 @@
1
- import React from 'react';
2
- import { VariableListInterfaceV2 } from "../../add-variableV2";
3
- import { HEADER_TYPES } from "../../template-preview";
4
- declare const EditMediaModal: React.FC<{
5
- setOpenEditMedia: React.Dispatch<React.SetStateAction<boolean>>;
6
- openEditMedia: boolean;
7
- mediaComponentFormat: HEADER_TYPES;
8
- variableListForImage: VariableListInterfaceV2[];
9
- uploadMedia: (urlOrVariable?: string) => void;
10
- }>;
11
- export default EditMediaModal;
@@ -1 +0,0 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),t=require("../../button/Button.js"),s=require("../../input-with-vars/InputWithVariables.js"),a=require("../../modals/styledModal.js");require("../../template-preview/TemplatePreview.js"),require("../../template-preview/WhatsApp/WhatsAppLikePreview.js"),require("../../template-preview/WhatsApp/WhatsAppLikePreviewV2.js");var i=require("../../../constants/Theme.js"),r=require("../../template-preview/models/TemplateMeta.js"),l=require("../../TypographyStyle.js"),d=require("../../../assets/icons/file.svg.js"),o=require("../../../assets/icons/filePdf.svg.js"),n=require("../../../assets/icons/image.svg.js"),c=require("../../../assets/icons/upload.svg.js");exports.default=u=>{let{setOpenEditMedia:p,mediaComponentFormat:h,variableListForImage:j,openEditMedia:g,uploadMedia:x}=u;return e.jsx(a.StyledModal,Object.assign({open:g,zIndex:2e3,onClose:()=>p(!1),width:"440px"},{children:e.jsxs("div",Object.assign({style:{padding:24,borderRadius:4}},{children:[e.jsx(l.TitleMedium,Object.assign({style:{marginBottom:16}},{children:"Update media"})),e.jsxs("div",Object.assign({style:{padding:24,border:`1px dashed ${i.DEFAULT_THEME.colorsV2.stroke.primary}`,backgroundColor:i.DEFAULT_THEME.colorsV2.surface.subdued}},{children:[e.jsxs("div",Object.assign({style:{marginBottom:24,display:"flex",justifyContent:"center",flexDirection:"column",alignItems:"center",gap:16}},{children:[e.jsx("div",Object.assign({style:{height:80,width:80,borderRadius:"100%",display:"flex",alignItems:"center",justifyContent:"center",backgroundColor:i.DEFAULT_THEME.colorsV2.background.base}},{children:h===r.HEADER_TYPES.IMAGE?e.jsx(n.default,{width:40,height:40}):h===r.HEADER_TYPES.VIDEO?e.jsx(d.default,{width:40,height:40}):e.jsx(o.default,{width:40,height:40})})),e.jsx(l.TitleMedium,{children:h===r.HEADER_TYPES.IMAGE?"Upload an image":h===r.HEADER_TYPES.VIDEO?"Upload a video":"Upload a document"}),e.jsx(l.BodySecondary,{children:h===r.HEADER_TYPES.IMAGE?"JPEG/ PNG format • Max 5MB":h===r.HEADER_TYPES.VIDEO?"Mp4 format video • Max 16":"Pdf format a document • Max 100MB"})]})),e.jsxs("div",Object.assign({style:{marginBottom:16}},{children:[e.jsx(l.BodyRegular,{children:"Media"}),e.jsx(s.InputWithVariables,{addVarBoxRight:"46px",allowMix:!1,onChange:()=>{},prevVariable:{actualValue:"",variableType:"string"},variablesList:j,showSideVariablePanel:!0,placeHolder:"Enter URL or add variable...",onBlur:(e,t)=>{t&&t.actualValue&&x(t.actualValue)},showAddButton:h===r.HEADER_TYPES.IMAGE})]})),e.jsxs("div",Object.assign({style:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:4}},{children:[e.jsx("hr",{style:{height:"2px",flex:.5,backgroundColor:"black"}}),e.jsx(l.BodyCaption,Object.assign({style:{flex:1}},{children:"Or upload media from device"})),e.jsx("hr",{style:{height:"2px",flex:.5,backgroundColor:"black"}})]})),e.jsx("div",Object.assign({style:{display:"flex",width:"100%"}},{children:e.jsx(t.Button,{matchParentWidth:!0,buttonText:"Upload",buttonType:"secondary",LeadingIcon:c.default,onClick:()=>x()})}))]}))]}))}))};
@@ -1,11 +0,0 @@
1
- import React from 'react';
2
- import { VariableListInterfaceV2 } from "../../add-variableV2";
3
- import { HEADER_TYPES } from "../../template-preview";
4
- declare const EditMediaModal: React.FC<{
5
- setOpenEditMedia: React.Dispatch<React.SetStateAction<boolean>>;
6
- openEditMedia: boolean;
7
- mediaComponentFormat: HEADER_TYPES;
8
- variableListForImage: VariableListInterfaceV2[];
9
- uploadMedia: (urlOrVariable?: string) => void;
10
- }>;
11
- export default EditMediaModal;
@@ -1 +0,0 @@
1
- import{jsx as e,jsxs as t}from"react/jsx-runtime";import{Button as i}from"../../button/Button.js";import{InputWithVariables as a}from"../../input-with-vars/InputWithVariables.js";import{StyledModal as o}from"../../modals/styledModal.js";import"../../template-preview/TemplatePreview.js";import"../../template-preview/WhatsApp/WhatsAppLikePreview.js";import"../../template-preview/WhatsApp/WhatsAppLikePreviewV2.js";import{DEFAULT_THEME as r}from"../../../constants/Theme.js";import{HEADER_TYPES as s}from"../../template-preview/models/TemplateMeta.js";import{TitleMedium as l,BodySecondary as d,BodyRegular as n,BodyCaption as p}from"../../TypographyStyle.js";import m from"../../../assets/icons/file.svg.js";import c from"../../../assets/icons/filePdf.svg.js";import h from"../../../assets/icons/image.svg.js";import g from"../../../assets/icons/upload.svg.js";const u=u=>{let{setOpenEditMedia:b,mediaComponentFormat:f,variableListForImage:j,openEditMedia:v,uploadMedia:y}=u;return e(o,Object.assign({open:v,zIndex:2e3,onClose:()=>b(!1),width:"440px"},{children:t("div",Object.assign({style:{padding:24,borderRadius:4}},{children:[e(l,Object.assign({style:{marginBottom:16}},{children:"Update media"})),t("div",Object.assign({style:{padding:24,border:`1px dashed ${r.colorsV2.stroke.primary}`,backgroundColor:r.colorsV2.surface.subdued}},{children:[t("div",Object.assign({style:{marginBottom:24,display:"flex",justifyContent:"center",flexDirection:"column",alignItems:"center",gap:16}},{children:[e("div",Object.assign({style:{height:80,width:80,borderRadius:"100%",display:"flex",alignItems:"center",justifyContent:"center",backgroundColor:r.colorsV2.background.base}},{children:f===s.IMAGE?e(h,{width:40,height:40}):f===s.VIDEO?e(m,{width:40,height:40}):e(c,{width:40,height:40})})),e(l,{children:f===s.IMAGE?"Upload an image":f===s.VIDEO?"Upload a video":"Upload a document"}),e(d,{children:f===s.IMAGE?"JPEG/ PNG format • Max 5MB":f===s.VIDEO?"Mp4 format video • Max 16":"Pdf format a document • Max 100MB"})]})),t("div",Object.assign({style:{marginBottom:16}},{children:[e(n,{children:"Media"}),e(a,{addVarBoxRight:"46px",allowMix:!1,onChange:()=>{},prevVariable:{actualValue:"",variableType:"string"},variablesList:j,showSideVariablePanel:!0,placeHolder:"Enter URL or add variable...",onBlur:(e,t)=>{t&&t.actualValue&&y(t.actualValue)},showAddButton:f===s.IMAGE})]})),t("div",Object.assign({style:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:4}},{children:[e("hr",{style:{height:"2px",flex:.5,backgroundColor:"black"}}),e(p,Object.assign({style:{flex:1}},{children:"Or upload media from device"})),e("hr",{style:{height:"2px",flex:.5,backgroundColor:"black"}})]})),e("div",Object.assign({style:{display:"flex",width:"100%"}},{children:e(i,{matchParentWidth:!0,buttonText:"Upload",buttonType:"secondary",LeadingIcon:g,onClick:()=>y()})}))]}))]}))}))};export{u as default};