@bikdotai/bik-component-library 0.0.628-beta.20 → 0.0.629-beta.20

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,3 +1,4 @@
1
+ /// <reference types="react" />
1
2
  export declare const Menus: ({
2
3
  displayName: string;
3
4
  key: number;
@@ -4,4 +4,4 @@
4
4
  padding-right: 10px;
5
5
  margin-bottom: 8px;
6
6
  line-height: normal;
7
- `;exports.default=i=>{let{template:y,onTemplateChange:B,whatsappSpecificPickerMeta:M,showVariableModal:k,variableListForImage:D,setDiscountCode:I,fileName:q,setFileName:R}=i;var P,L,A,U,w,N,_,H,S,F,Q,Y,W,K,$,G,X,z,J,Z,ee,ne,te,oe,ie,le,ae,se,de,re,ue,pe,ce,ve,me,be,ge,he,fe;const je=y.isCarouselType,{originalVariableList:Ce,pod:Te,extras:xe,selectedCarouselIndex:Oe,isProductCarouselType:Ee,disableCopyCode:ye,isError:Ve}=r.useTemplateModalContext(),{descriptionComponents:Be,urlBtns:Me,qrbBtns:ke,imageComponent:De,bodyVariables:Ie,headerVariables:qe}=p.getAllDataFromTemplateComponent(y),Re=o.useRef(null),[Pe,Le]=o.useState(!1),[Ae,Ue]=o.useState(-1===Oe?{descriptionComponents:Be,urlBtns:Me,qrbBtns:ke,imageComponent:De,bodyVariables:Ie,headerVariables:qe}:{}),{uploadMediaLink:we,uploadMediaFiles:Ne,validateMimeType:_e}=M,He=j.useEditWhatsappTemplateMedia({uploadMediaLink:we,uploadMediaFiles:Ne,updateTemplateImageUrl:function(e,n){var o,i,l,a,s,d,r,u;let p;p=null!=Oe&&Oe>-1?{components:null===(i=null===(o=y.components[1])||void 0===o?void 0:o.cards)||void 0===i?void 0:i[Oe].components,mapping:null===(a=null===(l=null==y?void 0:y.mapping)||void 0===l?void 0:l.cards)||void 0===a?void 0:a[Oe]}:Object.assign({},y);const c=null===(s=null==p?void 0:p.components)||void 0===s?void 0:s.findIndex((e=>{if("HEADER"===e.type&&"NONE"!==e.format&&"TEXT"!==e.format)return!0}));if(void 0!==c&&c>-1&&(null==p?void 0:p.components[c])){const t=Object.assign(Object.assign({},p.components[c]),{format:n,example:{header_handle:[e]}}),o=[...p.components];o[c]=t,p=Object.assign(Object.assign({},p),{components:o})}p.mapping&&(p.mapping=Object.assign(Object.assign({},p.mapping),{header:void 0}));if(null!=Oe&&Oe>-1){const e=t.cloneDeep(y);e.components[1].cards[Oe].components=p.components,(null===(d=null==e?void 0:e.mapping)||void 0===d?void 0:d.cards)&&(null===(r=null==e?void 0:e.mapping)||void 0===r?void 0:r.cards.length)>0&&(e.mapping.cards[Oe]=null!==(u=p.mapping)&&void 0!==u?u:{}),null==B||B(Object.assign({},e)),Fe(!0)}else null==B||B(Object.assign({},p))},validateMimeType:_e,mediaComponent:je?Ae.imageComponent:De,fileRef:Re}),[Se,Fe]=o.useState(!1),[Qe,Ye]=o.useState(q),[We,Ke]=o.useState();function $e(e,n,o){var i,l,a,s,d,r,u,p,c,v;const m=null!=Oe&&Oe>-1?{components:null===(i=Object.assign({},y).components[1].cards)||void 0===i?void 0:i[Oe].components,mapping:null===(l=Object.assign({},y).mapping.cards)||void 0===l?void 0:l[Oe]}:Object.assign({},y),b=t.cloneDeep(m),g="custom"===n&&"string"==typeof e,h=g?e:"string"!=typeof e?e.defaultValue?e.defaultValue:"https://d.bik.ai/":"https://d.bik.ai";if(null!=Oe&&Oe>-1&&Ee){const n=Object.assign({},y).components.map((e=>{var n;return"CAROUSEL"===e.type?Object.assign(Object.assign({},e),{cards:null===(n=e.cards)||void 0===n?void 0:n.map((e=>Object.assign(Object.assign({},e),{components:e.components.map((e=>{var n,t,i;if("BUTTONS"===e.type){const l=null===(n=e.buttons)||void 0===n?void 0:n.filter((e=>"URL"===e.type));let a=null!==(t=null==l?void 0:l[o])&&void 0!==t?t:{};a=Object.assign(Object.assign({},a),{url:"https://d.bik.ai/{{1}}",example:[h]});const s=null===(i=e.buttons)||void 0===i?void 0:i.map((e=>"URL"===e.type&&(null==e?void 0:e.text)===(null==a?void 0:a.text)?a:e));return Object.assign(Object.assign({},e),{buttons:s})}return e}))})))}):e})),i=null===(s=null===(a=Object.assign({},y).mapping)||void 0===a?void 0:a.cards)||void 0===s?void 0:s.map((n=>{var t;return Object.assign(Object.assign({},n),{buttons:null===(t=null==n?void 0:n.buttons)||void 0===t?void 0:t.map((n=>g?"((customBtnPlaceholder))":"string"!=typeof e?e.placeHolder:""))})})),l=t.cloneDeep(y);return l.components=n,l.mapping.cards=i,void(null==B||B(Object.assign({},l)))}const f=null==b?void 0:b.components.findIndex((e=>"BUTTONS"===e.type));if(void 0!==f&&f>-1){const t=null===(d=null==b?void 0:b.components[f].buttons)||void 0===d?void 0:d.filter((e=>"URL"===e.type));if((null==t?void 0:t.length)>0){const i="custom"===n&&"string"==typeof e,l=i?e:"string"!=typeof e&&e.defaultValue?e.defaultValue:"https://d.bik.ai/";let a=t[o];a=Object.assign(Object.assign({},a),{url:"https://d.bik.ai/{{1}}",example:[l]});const s=[...null!==(p=null===(u=null===(r=b.components)||void 0===r?void 0:r[f])||void 0===u?void 0:u.buttons)&&void 0!==p?p:[]].map((e=>"URL"===e.type&&(null==e?void 0:e.text)===(null==a?void 0:a.text)?a:e)),d=Object.assign(Object.assign({},b.components[f]),{buttons:s}),v=null===(c=b.mapping)||void 0===c?void 0:c.buttons;v&&v.length>0&&(v[o]=i?"((customBtnPlaceholder))":"string"!=typeof e?e.placeHolder:"");const m=Object.assign(Object.assign({},b.mapping),{buttons:v});b.mapping=m;const g=[...b.components];g[f]=d,b.components=g}}if("string"!=typeof e){"checkout.checkoutUrl"===(null===(v=e.placeHolder)||void 0===v?void 0:v.slice(2,-2))?Le(!0):(Le(!1),null==I||I(""))}if(null!=Oe&&Oe>-1){const e=t.cloneDeep(y);e.components[1].cards[Oe].components=b.components,e.mapping.cards[Oe]=b.mapping,null==B||B(Object.assign({},e))}else null==B||B(b)}function Ge(e,n,o){var i,l,a,s,d,r,u;const p=null!=Oe&&Oe>-1?{components:null===(i=Object.assign({},y).components[1].cards)||void 0===i?void 0:i[Oe].components,mapping:null===(l=Object.assign({},y).mapping.cards)||void 0===l?void 0:l[Oe]}:Object.assign({},y);if(null!=Oe&&Oe>-1&&Ee){const n=Object.assign({},y).components.map((n=>{var t;return"CAROUSEL"===n.type?Object.assign(Object.assign({},n),{cards:null===(t=n.cards)||void 0===t?void 0:t.map((n=>Object.assign(Object.assign({},n),{components:n.components.map((n=>{var t,i,l;if("BUTTONS"===n.type){const a=null===(t=null==n?void 0:n.buttons)||void 0===t?void 0:t.filter((e=>"QUICK_REPLY"===e.type));let s=null!==(i=null==a?void 0:a[o])&&void 0!==i?i:{};s=Object.assign(Object.assign({},s),{flowId:e.flowId,flowName:e.flowName});const d=null===(l=null==n?void 0:n.buttons)||void 0===l?void 0:l.map((e=>"QUICK_REPLY"===e.type&&(null==e?void 0:e.text)===(null==s?void 0:s.text)?s:e));return Object.assign(Object.assign({},n),{buttons:d})}return n}))})))}):n})),i=t.cloneDeep(y);return i.components=n,void(null==B||B(Object.assign({},i)))}const c=null==p?void 0:p.components.findIndex((e=>"BUTTONS"===e.type));if(void 0!==c&&c>-1){const n=null===(s=null===(a=null==p?void 0:p.components[c])||void 0===a?void 0:a.buttons)||void 0===s?void 0:s.filter((e=>"QUICK_REPLY"===e.type));if(n){let t=n[o];t=Object.assign(Object.assign({},t),{flowId:e.flowId,flowName:e.flowName});const i=[...null!==(u=null===(r=null===(d=p.components)||void 0===d?void 0:d[c])||void 0===r?void 0:r.buttons)&&void 0!==u?u:[]].map((e=>"QUICK_REPLY"===e.type&&(null==e?void 0:e.text)===(null==t?void 0:t.text)?t:e)),l=Object.assign(Object.assign({},p.components[c]),{buttons:i}),a=[...p.components];a[c]=l,p.components=a}}if(null!=Oe&&Oe>-1){const e=t.cloneDeep(y);e.components[1].cards[Oe].components=p.components,null==B||B(Object.assign({},e))}else null==B||B(p)}o.useEffect((()=>{var e,n;if(null===(e=y.mapping.buttons)||void 0===e?void 0:e.find((e=>"checkout.checkoutUrl"===e.slice(2,-2))))Le(!0);else{Le(!1);const e=null===(n=null==xe?void 0:xe.discountCodeExtra)||void 0===n?void 0:n[1];null==e||e("")}}),[y]),o.useEffect((()=>{var e,n,t,o;if(null!=Oe&&Oe>-1){const i={components:null===(n=null===(e=y.components[1])||void 0===e?void 0:e.cards)||void 0===n?void 0:n[Oe].components,mapping:null===(o=null===(t=null==y?void 0:y.mapping)||void 0===t?void 0:t.cards)||void 0===o?void 0:o[Oe]},{descriptionComponents:l,urlBtns:a,qrbBtns:s,imageComponent:d,bodyVariables:r,headerVariables:u}=p.getAllDataFromTemplateComponent(i);Ue({descriptionComponents:l,urlBtns:a,qrbBtns:s,imageComponent:d,bodyVariables:r,headerVariables:u})}else if(null!=Oe&&-1===Oe){const{descriptionComponents:e,urlBtns:n,qrbBtns:t,imageComponent:o,bodyVariables:i,headerVariables:l}=p.getAllDataFromTemplateComponent(y);Ue({descriptionComponents:e,urlBtns:n,qrbBtns:t,imageComponent:o,bodyVariables:i,headerVariables:l})}}),[Oe]),o.useEffect((()=>{var e,n,t,o;if(null!=Oe&&Oe>-1&&Se){const i={components:null===(n=null===(e=y.components[1])||void 0===e?void 0:e.cards)||void 0===n?void 0:n[Oe].components,mapping:null===(o=null===(t=null==y?void 0:y.mapping)||void 0===t?void 0:t.cards)||void 0===o?void 0:o[Oe]},{descriptionComponents:l,urlBtns:a,qrbBtns:s,imageComponent:d,bodyVariables:r,headerVariables:u}=p.getAllDataFromTemplateComponent(i);Ue({descriptionComponents:l,urlBtns:a,qrbBtns:s,imageComponent:d,bodyVariables:r,headerVariables:u}),Fe(!1)}}),[Se]);o.useEffect((()=>{Ve&&Te===d.POD.CHATBOT&&(()=>{if(!q)return void Ke("PDF name is Required");const e=v.validateInputNameChatbot(q);null==R||R(null!=q?q:""),Ke(e?"Please enter a valid PDF name":void 0)})()}),[Ve]);const Xe=je?Ae.imageComponent:De;return He.openEditMedia?e.jsx(T.Container,Object.assign({style:{flexDirection:"column",width:400,maxHeight:460}},{children:e.jsx(g.default,{mediaComponentFormat:null!==(P=Xe.format)&&void 0!==P?P:s.HEADER_TYPES.IMAGE,uploadMedia:He.uploadMedia,variableListForImage:D||[],useEditWhatsappTemplateMediaResponse:He,setOpenEditMedia:He.setOpenEditMedia,openEditMedia:He.openEditMedia,editIconRef:He.editIconRef,fileRef:Re})})):e.jsxs(T.Container,Object.assign({style:{flexDirection:"column",width:400,maxHeight:460,minWidth:Ee?"420px":"auto"}},{children:[!!Ae.imageComponent&&!Ee&&e.jsxs(f.EditTemplateMediaContainer,{children:[e.jsx(h.default,{imageName:null!==(A=null===(L=null==Xe?void 0:Xe.example)||void 0===L?void 0:L.header_handle)&&void 0!==A?A:[],handleImageChange:He.handleImageChange,mediaType:null==Xe?void 0:Xe.format,error:He.error,isLoading:He.loading,setOpenEditMedia:He.setOpenEditMedia,selectedVariable:c.isVariable(null!==(N=null===(w=null===(U=null==Xe?void 0:Xe.example)||void 0===U?void 0:U.header_handle)||void 0===w?void 0:w[0])&&void 0!==N?N:"")?null===(H=null===(_=null==Xe?void 0:Xe.example)||void 0===_?void 0:_.header_handle)||void 0===H?void 0:H[0]:(null===(F=null===(S=null==y?void 0:y.mapping)||void 0===S?void 0:S.header)||void 0===F?void 0:F[0])?null===(Y=null===(Q=null==y?void 0:y.mapping)||void 0===Q?void 0:Q.header)||void 0===Y?void 0:Y[0]:He.selectedVariable}),(null==De?void 0:De.format)==s.HEADER_TYPES.DOCUMENT?e.jsx(V,{children:Te===d.POD.CHATBOT?e.jsx(a.InputWithVariables,{labelText:"PDF Name",placeHolder:"Enter the name",errorMessage:We||void 0,onChange:e=>{var n;Ke(""),null==R||R(null!==(n=null==e?void 0:e.actualValue)&&void 0!==n?n:"")},pickerType:n.PickerType.EMBEDDED,noMaxCharCheck:!0,allowMix:!0,showVarHeader:!0,varHeaderText:"Select variable",prevVariable:{actualValue:null!=q?q:"",variableType:"string"},variablesList:D,showAddButton:!0}):e.jsx(l.Input,{labelText:"PDF Name",placeholder:"Enter the name",value:Qe,errorMessage:We||void 0,onBlur:()=>{if(!Qe)return null==R||R(""),void Ke("PDF name is Required");const e=v.validateInputName(Qe);null==R||R(Qe),Ke(e?"Please enter a valid PDF name":void 0)},onChangeText:e=>{Ke(""),Ye(e)}})}):e.jsx(e.Fragment,{})]}),(null===(W=Ae.bodyVariables)||void 0===W?void 0:W.length)>0&&e.jsx(O.default,{containerStyle:{paddingTop:Ae.mediaComponent?24:8},headerText:"Edit variable values",subText:"Edit values for the variables used in template",toolTipInfo:"Variables are placeholder texts which can either be filled through data or custom texts. These can be edited through the dropdowns below"}),null===(K=Ae.descriptionComponents)||void 0===K?void 0:K.map(((n,t)=>e.jsx(x.default,{originalVariableList:null!=Oe&&Oe>-1?Ce.cards[Oe]:Ce,type:n.type,descriptionComponent:n.component,showVariableModal:k},t))),(null===(X=null===(G=null!=Oe&&Oe>-1?null===($=Ce.cards[Oe])||void 0===$?void 0:$.buttons:null==Ce?void 0:Ce.buttons)||void 0===G?void 0:G.filter((e=>"URL"===e.type)))||void 0===X?void 0:X.length)>0&&e.jsx(O.default,{headerText:"Edit buttons",subText:"Edit the link connected to the CTA button"}),null===(Z=null===(J=null!=Oe&&Oe>-1?null===(z=Ce.cards[Oe])||void 0===z?void 0:z.buttons:null==Ce?void 0:Ce.buttons)||void 0===J?void 0:J.filter((e=>Te===d.POD.CHATBOT||"URL"===e.type)))||void 0===Z?void 0:Z.map(((n,t)=>{const o=n.buttonVariable===u.STATIC_URL_VARIABLE_NAME;if("URL"===n.type)return e.jsx(E.default,{variableListIndex:t,disableEdit:o,CTAoptions:null==M?void 0:M.CTAoptions,button:n,currentVariableList:null!=Oe&&Oe>-1?Object.assign({},Ce.cards[Oe]):Object.assign({},Ce),updateSelectedURLTemplateBtn:$e},`${t}_${Oe}`)})),Te===d.POD.CHATBOT&&(null===(ne=null===(ee=ke[0])||void 0===ee?void 0:ee.component)||void 0===ne?void 0:ne.buttons)&&(null===(ie=null===(oe=null===(te=ke[0])||void 0===te?void 0:te.component)||void 0===oe?void 0:oe.buttons)||void 0===ie?void 0:ie.length)>0&&e.jsx(m.BackTrackComponent,{backTrackMessage:null===(le=null==xe?void 0:xe.backTrackExtra)||void 0===le?void 0:le[0],setBackTrackMessage:null===(ae=null==xe?void 0:xe.backTrackExtra)||void 0===ae?void 0:ae[1]}),(null===(re=null===(de=null!=Oe&&Oe>-1?null===(se=Ce.cards[Oe])||void 0===se?void 0:se.buttons:null==Ce?void 0:Ce.buttons)||void 0===de?void 0:de.filter((e=>"QUICK_REPLY"===e.type)))||void 0===re?void 0:re.length)>0&&(Te!==d.POD.CHATBOT?e.jsx(O.default,{headerText:"Edit buttons",subText:"Edit the chatflows triggered on clicking the buttons",toolTipInfo:"There is an option to trigger chatflows through the buttons which can keep the user engaged"}):e.jsx(m.BackTrackComponent,{backTrackMessage:null===(ue=null==xe?void 0:xe.backTrackExtra)||void 0===ue?void 0:ue[0],setBackTrackMessage:null===(pe=null==xe?void 0:xe.backTrackExtra)||void 0===pe?void 0:pe[1]})),null===(me=null===(ve=null!=Oe&&Oe>-1?null===(ce=Ce.cards[Oe])||void 0===ce?void 0:ce.buttons:null==Ce?void 0:Ce.buttons)||void 0===ve?void 0:ve.filter((e=>"QUICK_REPLY"===e.type)))||void 0===me?void 0:me.map(((n,t)=>{if("QUICK_REPLY"===n.type&&Te!==d.POD.CHATBOT)return e.jsx(E.default,{variableListIndex:t,QRBoptions:null==M?void 0:M.QRBoptions,button:n,currentVariableList:null!=Oe&&Oe>-1?Object.assign({},Ce.cards[Oe]):Object.assign({},Ce),updateSelectedQRBTemplateBtn:Ge},`${t}_${Oe}`)})),Te===d.POD.CHATBOT&&Pe&&e.jsx(b.DiscountCodeComponent,{discountCode:null===(be=null==xe?void 0:xe.discountCodeExtra)||void 0===be?void 0:be[0],setDiscountCode:null===(ge=null==xe?void 0:xe.discountCodeExtra)||void 0===ge?void 0:ge[1]}),null===(fe=null!=Oe&&Oe>-1?null===(he=Ce.cards[Oe])||void 0===he?void 0:he.buttons:null==Ce?void 0:Ce.buttons)||void 0===fe?void 0:fe.map(((n,t)=>{var o,i,a,s,d;if("COPY_CODE"===n.type)return e.jsx(e.Fragment,{children:ye?e.jsx("div",Object.assign({style:{marginBottom:20,borderRadius:4,padding:"8px 10px"}},{children:e.jsx(l.Input,{state:"disabled",labelText:null!==(o=n.text)&&void 0!==o?o:"Copy Code",value:null!==(i=n.buttonVariable)&&void 0!==i?i:"",onChangeText:()=>{}})})):e.jsx(C.default,{index:t,variable:{variableName:null!==(a=n.text)&&void 0!==a?a:"Copy Code",updatedValue:null!==(s=n.buttonVariable)&&void 0!==s?s:"",type:"string",isEditableVariable:!0,index:null!==(d=n.index)&&void 0!==d?d:0},showVariableModal:!0,componentType:"BUTTONS",buttonType:n.type},t)})}))]}))};
7
+ `;exports.default=i=>{let{template:y,onTemplateChange:B,whatsappSpecificPickerMeta:M,showVariableModal:k,variableListForImage:D,setDiscountCode:I,fileName:q,setFileName:R}=i;var P,L,A,U,w,N,_,H,S,F,Q,Y,W,K,$,G,X,z,J,Z,ee,ne,te,oe,ie,le,ae,se,de,re,ue,pe,ce,ve,me,be,ge,he,fe;const je=y.isCarouselType,{originalVariableList:Ce,pod:Te,extras:xe,selectedCarouselIndex:Oe,isProductCarouselType:Ee,disableCopyCode:ye,isError:Ve}=r.useTemplateModalContext(),{descriptionComponents:Be,urlBtns:Me,qrbBtns:ke,imageComponent:De,bodyVariables:Ie,headerVariables:qe}=p.getAllDataFromTemplateComponent(y),Re=o.useRef(null),[Pe,Le]=o.useState(!1),[Ae,Ue]=o.useState(-1===Oe?{descriptionComponents:Be,urlBtns:Me,qrbBtns:ke,imageComponent:De,bodyVariables:Ie,headerVariables:qe}:{}),{uploadMediaLink:we,uploadMediaFiles:Ne,validateMimeType:_e}=M,He=j.useEditWhatsappTemplateMedia({uploadMediaLink:we,uploadMediaFiles:Ne,updateTemplateImageUrl:function(e,n){var o,i,l,a,s,d,r,u;let p;p=null!=Oe&&Oe>-1?{components:null===(i=null===(o=y.components[1])||void 0===o?void 0:o.cards)||void 0===i?void 0:i[Oe].components,mapping:null===(a=null===(l=null==y?void 0:y.mapping)||void 0===l?void 0:l.cards)||void 0===a?void 0:a[Oe]}:Object.assign({},y);const c=null===(s=null==p?void 0:p.components)||void 0===s?void 0:s.findIndex((e=>{if("HEADER"===e.type&&"NONE"!==e.format&&"TEXT"!==e.format)return!0}));if(void 0!==c&&c>-1&&(null==p?void 0:p.components[c])){const t=Object.assign(Object.assign({},p.components[c]),{format:n,example:{header_handle:[e]}}),o=[...p.components];o[c]=t,p=Object.assign(Object.assign({},p),{components:o})}p.mapping&&(p.mapping=Object.assign(Object.assign({},p.mapping),{header:void 0}));if(null!=Oe&&Oe>-1){const e=t.cloneDeep(y);e.components[1].cards[Oe].components=p.components,(null===(d=null==e?void 0:e.mapping)||void 0===d?void 0:d.cards)&&(null===(r=null==e?void 0:e.mapping)||void 0===r?void 0:r.cards.length)>0&&(e.mapping.cards[Oe]=null!==(u=p.mapping)&&void 0!==u?u:{}),null==B||B(Object.assign({},e)),Fe(!0)}else null==B||B(Object.assign({},p))},validateMimeType:_e,mediaComponent:je?Ae.imageComponent:De,fileRef:Re}),[Se,Fe]=o.useState(!1),[Qe,Ye]=o.useState(q),[We,Ke]=o.useState();function $e(e,n,o){var i,l,a,s,d,r,u,p,c,v;const m=null!=Oe&&Oe>-1?{components:null===(i=Object.assign({},y).components[1].cards)||void 0===i?void 0:i[Oe].components,mapping:null===(l=Object.assign({},y).mapping.cards)||void 0===l?void 0:l[Oe]}:Object.assign({},y),b=t.cloneDeep(m),g="custom"===n&&"string"==typeof e,h=g?e:"string"!=typeof e?e.defaultValue?e.defaultValue:"https://d.bik.ai/":"https://d.bik.ai";if(null!=Oe&&Oe>-1&&Ee){const n=Object.assign({},y).components.map((e=>{var n;return"CAROUSEL"===e.type?Object.assign(Object.assign({},e),{cards:null===(n=e.cards)||void 0===n?void 0:n.map((e=>Object.assign(Object.assign({},e),{components:e.components.map((e=>{var n,t,i;if("BUTTONS"===e.type){const l=null===(n=e.buttons)||void 0===n?void 0:n.filter((e=>"URL"===e.type));let a=null!==(t=null==l?void 0:l[o])&&void 0!==t?t:{};a=Object.assign(Object.assign({},a),{url:"https://d.bik.ai/{{1}}",example:[h]});const s=null===(i=e.buttons)||void 0===i?void 0:i.map((e=>"URL"===e.type&&(null==e?void 0:e.text)===(null==a?void 0:a.text)?a:e));return Object.assign(Object.assign({},e),{buttons:s})}return e}))})))}):e})),i=null===(s=null===(a=Object.assign({},y).mapping)||void 0===a?void 0:a.cards)||void 0===s?void 0:s.map((n=>{var t;return Object.assign(Object.assign({},n),{buttons:null===(t=null==n?void 0:n.buttons)||void 0===t?void 0:t.map(((n,t)=>t===o?g?"((customBtnPlaceholder))":"string"!=typeof e?e.placeHolder:"":n))})})),l=t.cloneDeep(y);return l.components=n,l.mapping.cards=i,void(null==B||B(Object.assign({},l)))}const f=null==b?void 0:b.components.findIndex((e=>"BUTTONS"===e.type));if(void 0!==f&&f>-1){const t=null===(d=null==b?void 0:b.components[f].buttons)||void 0===d?void 0:d.filter((e=>"URL"===e.type));if((null==t?void 0:t.length)>0){const i="custom"===n&&"string"==typeof e,l=i?e:"string"!=typeof e&&e.defaultValue?e.defaultValue:"https://d.bik.ai/";let a=t[o];a=Object.assign(Object.assign({},a),{url:"https://d.bik.ai/{{1}}",example:[l]});const s=[...null!==(p=null===(u=null===(r=b.components)||void 0===r?void 0:r[f])||void 0===u?void 0:u.buttons)&&void 0!==p?p:[]].map((e=>"URL"===e.type&&(null==e?void 0:e.text)===(null==a?void 0:a.text)?a:e)),d=Object.assign(Object.assign({},b.components[f]),{buttons:s}),v=null===(c=b.mapping)||void 0===c?void 0:c.buttons;v&&v.length>0&&(v[o]=i?"((customBtnPlaceholder))":"string"!=typeof e?e.placeHolder:"");const m=Object.assign(Object.assign({},b.mapping),{buttons:v});b.mapping=m;const g=[...b.components];g[f]=d,b.components=g}}if("string"!=typeof e){"checkout.checkoutUrl"===(null===(v=e.placeHolder)||void 0===v?void 0:v.slice(2,-2))?Le(!0):(Le(!1),null==I||I(""))}if(null!=Oe&&Oe>-1){const e=t.cloneDeep(y);e.components[1].cards[Oe].components=b.components,e.mapping.cards[Oe]=b.mapping,null==B||B(Object.assign({},e))}else null==B||B(b)}function Ge(e,n,o){var i,l,a,s,d,r,u;const p=null!=Oe&&Oe>-1?{components:null===(i=Object.assign({},y).components[1].cards)||void 0===i?void 0:i[Oe].components,mapping:null===(l=Object.assign({},y).mapping.cards)||void 0===l?void 0:l[Oe]}:Object.assign({},y);if(null!=Oe&&Oe>-1&&Ee){const n=Object.assign({},y).components.map((n=>{var t;return"CAROUSEL"===n.type?Object.assign(Object.assign({},n),{cards:null===(t=n.cards)||void 0===t?void 0:t.map((n=>Object.assign(Object.assign({},n),{components:n.components.map((n=>{var t,i,l;if("BUTTONS"===n.type){const a=null===(t=null==n?void 0:n.buttons)||void 0===t?void 0:t.filter((e=>"QUICK_REPLY"===e.type));let s=null!==(i=null==a?void 0:a[o])&&void 0!==i?i:{};s=Object.assign(Object.assign({},s),{flowId:e.flowId,flowName:e.flowName});const d=null===(l=null==n?void 0:n.buttons)||void 0===l?void 0:l.map((e=>"QUICK_REPLY"===e.type&&(null==e?void 0:e.text)===(null==s?void 0:s.text)?s:e));return Object.assign(Object.assign({},n),{buttons:d})}return n}))})))}):n})),i=t.cloneDeep(y);return i.components=n,void(null==B||B(Object.assign({},i)))}const c=null==p?void 0:p.components.findIndex((e=>"BUTTONS"===e.type));if(void 0!==c&&c>-1){const n=null===(s=null===(a=null==p?void 0:p.components[c])||void 0===a?void 0:a.buttons)||void 0===s?void 0:s.filter((e=>"QUICK_REPLY"===e.type));if(n){let t=n[o];t=Object.assign(Object.assign({},t),{flowId:e.flowId,flowName:e.flowName});const i=[...null!==(u=null===(r=null===(d=p.components)||void 0===d?void 0:d[c])||void 0===r?void 0:r.buttons)&&void 0!==u?u:[]].map((e=>"QUICK_REPLY"===e.type&&(null==e?void 0:e.text)===(null==t?void 0:t.text)?t:e)),l=Object.assign(Object.assign({},p.components[c]),{buttons:i}),a=[...p.components];a[c]=l,p.components=a}}if(null!=Oe&&Oe>-1){const e=t.cloneDeep(y);e.components[1].cards[Oe].components=p.components,null==B||B(Object.assign({},e))}else null==B||B(p)}o.useEffect((()=>{var e,n;if(null===(e=y.mapping.buttons)||void 0===e?void 0:e.find((e=>"checkout.checkoutUrl"===e.slice(2,-2))))Le(!0);else{Le(!1);const e=null===(n=null==xe?void 0:xe.discountCodeExtra)||void 0===n?void 0:n[1];null==e||e("")}}),[y]),o.useEffect((()=>{var e,n,t,o;if(null!=Oe&&Oe>-1){const i={components:null===(n=null===(e=y.components[1])||void 0===e?void 0:e.cards)||void 0===n?void 0:n[Oe].components,mapping:null===(o=null===(t=null==y?void 0:y.mapping)||void 0===t?void 0:t.cards)||void 0===o?void 0:o[Oe]},{descriptionComponents:l,urlBtns:a,qrbBtns:s,imageComponent:d,bodyVariables:r,headerVariables:u}=p.getAllDataFromTemplateComponent(i);Ue({descriptionComponents:l,urlBtns:a,qrbBtns:s,imageComponent:d,bodyVariables:r,headerVariables:u})}else if(null!=Oe&&-1===Oe){const{descriptionComponents:e,urlBtns:n,qrbBtns:t,imageComponent:o,bodyVariables:i,headerVariables:l}=p.getAllDataFromTemplateComponent(y);Ue({descriptionComponents:e,urlBtns:n,qrbBtns:t,imageComponent:o,bodyVariables:i,headerVariables:l})}}),[Oe]),o.useEffect((()=>{var e,n,t,o;if(null!=Oe&&Oe>-1&&Se){const i={components:null===(n=null===(e=y.components[1])||void 0===e?void 0:e.cards)||void 0===n?void 0:n[Oe].components,mapping:null===(o=null===(t=null==y?void 0:y.mapping)||void 0===t?void 0:t.cards)||void 0===o?void 0:o[Oe]},{descriptionComponents:l,urlBtns:a,qrbBtns:s,imageComponent:d,bodyVariables:r,headerVariables:u}=p.getAllDataFromTemplateComponent(i);Ue({descriptionComponents:l,urlBtns:a,qrbBtns:s,imageComponent:d,bodyVariables:r,headerVariables:u}),Fe(!1)}}),[Se]);o.useEffect((()=>{Ve&&Te===d.POD.CHATBOT&&(()=>{if(!q)return void Ke("PDF name is Required");const e=v.validateInputNameChatbot(q);null==R||R(null!=q?q:""),Ke(e?"Please enter a valid PDF name":void 0)})()}),[Ve]);const Xe=je?Ae.imageComponent:De;return He.openEditMedia?e.jsx(T.Container,Object.assign({style:{flexDirection:"column",width:400,maxHeight:460}},{children:e.jsx(g.default,{mediaComponentFormat:null!==(P=Xe.format)&&void 0!==P?P:s.HEADER_TYPES.IMAGE,uploadMedia:He.uploadMedia,variableListForImage:D||[],useEditWhatsappTemplateMediaResponse:He,setOpenEditMedia:He.setOpenEditMedia,openEditMedia:He.openEditMedia,editIconRef:He.editIconRef,fileRef:Re})})):e.jsxs(T.Container,Object.assign({style:{flexDirection:"column",width:400,maxHeight:460,minWidth:Ee?"420px":"auto"}},{children:[!!Ae.imageComponent&&!Ee&&e.jsxs(f.EditTemplateMediaContainer,{children:[e.jsx(h.default,{imageName:null!==(A=null===(L=null==Xe?void 0:Xe.example)||void 0===L?void 0:L.header_handle)&&void 0!==A?A:[],handleImageChange:He.handleImageChange,mediaType:null==Xe?void 0:Xe.format,error:He.error,isLoading:He.loading,setOpenEditMedia:He.setOpenEditMedia,selectedVariable:c.isVariable(null!==(N=null===(w=null===(U=null==Xe?void 0:Xe.example)||void 0===U?void 0:U.header_handle)||void 0===w?void 0:w[0])&&void 0!==N?N:"")?null===(H=null===(_=null==Xe?void 0:Xe.example)||void 0===_?void 0:_.header_handle)||void 0===H?void 0:H[0]:(null===(F=null===(S=null==y?void 0:y.mapping)||void 0===S?void 0:S.header)||void 0===F?void 0:F[0])?null===(Y=null===(Q=null==y?void 0:y.mapping)||void 0===Q?void 0:Q.header)||void 0===Y?void 0:Y[0]:He.selectedVariable}),(null==De?void 0:De.format)==s.HEADER_TYPES.DOCUMENT?e.jsx(V,{children:Te===d.POD.CHATBOT?e.jsx(a.InputWithVariables,{labelText:"PDF Name",placeHolder:"Enter the name",errorMessage:We||void 0,onChange:e=>{var n;Ke(""),null==R||R(null!==(n=null==e?void 0:e.actualValue)&&void 0!==n?n:"")},pickerType:n.PickerType.EMBEDDED,noMaxCharCheck:!0,allowMix:!0,showVarHeader:!0,varHeaderText:"Select variable",prevVariable:{actualValue:null!=q?q:"",variableType:"string"},variablesList:D,showAddButton:!0}):e.jsx(l.Input,{labelText:"PDF Name",placeholder:"Enter the name",value:Qe,errorMessage:We||void 0,onBlur:()=>{if(!Qe)return null==R||R(""),void Ke("PDF name is Required");const e=v.validateInputName(Qe);null==R||R(Qe),Ke(e?"Please enter a valid PDF name":void 0)},onChangeText:e=>{Ke(""),Ye(e)}})}):e.jsx(e.Fragment,{})]}),(null===(W=Ae.bodyVariables)||void 0===W?void 0:W.length)>0&&e.jsx(O.default,{containerStyle:{paddingTop:Ae.mediaComponent?24:8},headerText:"Edit variable values",subText:"Edit values for the variables used in template",toolTipInfo:"Variables are placeholder texts which can either be filled through data or custom texts. These can be edited through the dropdowns below"}),null===(K=Ae.descriptionComponents)||void 0===K?void 0:K.map(((n,t)=>e.jsx(x.default,{originalVariableList:null!=Oe&&Oe>-1?Ce.cards[Oe]:Ce,type:n.type,descriptionComponent:n.component,showVariableModal:k},t))),(null===(X=null===(G=null!=Oe&&Oe>-1?null===($=Ce.cards[Oe])||void 0===$?void 0:$.buttons:null==Ce?void 0:Ce.buttons)||void 0===G?void 0:G.filter((e=>"URL"===e.type)))||void 0===X?void 0:X.length)>0&&e.jsx(O.default,{headerText:"Edit buttons",subText:"Edit the link connected to the CTA button"}),null===(Z=null===(J=null!=Oe&&Oe>-1?null===(z=Ce.cards[Oe])||void 0===z?void 0:z.buttons:null==Ce?void 0:Ce.buttons)||void 0===J?void 0:J.filter((e=>Te===d.POD.CHATBOT||"URL"===e.type)))||void 0===Z?void 0:Z.map(((n,t)=>{const o=n.buttonVariable===u.STATIC_URL_VARIABLE_NAME;if("URL"===n.type)return e.jsx(E.default,{variableListIndex:t,disableEdit:o,CTAoptions:null==M?void 0:M.CTAoptions,button:n,currentVariableList:null!=Oe&&Oe>-1?Object.assign({},Ce.cards[Oe]):Object.assign({},Ce),updateSelectedURLTemplateBtn:$e},`${t}_${Oe}`)})),Te===d.POD.CHATBOT&&(null===(ne=null===(ee=ke[0])||void 0===ee?void 0:ee.component)||void 0===ne?void 0:ne.buttons)&&(null===(ie=null===(oe=null===(te=ke[0])||void 0===te?void 0:te.component)||void 0===oe?void 0:oe.buttons)||void 0===ie?void 0:ie.length)>0&&e.jsx(m.BackTrackComponent,{backTrackMessage:null===(le=null==xe?void 0:xe.backTrackExtra)||void 0===le?void 0:le[0],setBackTrackMessage:null===(ae=null==xe?void 0:xe.backTrackExtra)||void 0===ae?void 0:ae[1]}),(null===(re=null===(de=null!=Oe&&Oe>-1?null===(se=Ce.cards[Oe])||void 0===se?void 0:se.buttons:null==Ce?void 0:Ce.buttons)||void 0===de?void 0:de.filter((e=>"QUICK_REPLY"===e.type)))||void 0===re?void 0:re.length)>0&&(Te!==d.POD.CHATBOT?e.jsx(O.default,{headerText:"Edit buttons",subText:"Edit the chatflows triggered on clicking the buttons",toolTipInfo:"There is an option to trigger chatflows through the buttons which can keep the user engaged"}):e.jsx(m.BackTrackComponent,{backTrackMessage:null===(ue=null==xe?void 0:xe.backTrackExtra)||void 0===ue?void 0:ue[0],setBackTrackMessage:null===(pe=null==xe?void 0:xe.backTrackExtra)||void 0===pe?void 0:pe[1]})),null===(me=null===(ve=null!=Oe&&Oe>-1?null===(ce=Ce.cards[Oe])||void 0===ce?void 0:ce.buttons:null==Ce?void 0:Ce.buttons)||void 0===ve?void 0:ve.filter((e=>"QUICK_REPLY"===e.type)))||void 0===me?void 0:me.map(((n,t)=>{if("QUICK_REPLY"===n.type&&Te!==d.POD.CHATBOT)return e.jsx(E.default,{variableListIndex:t,QRBoptions:null==M?void 0:M.QRBoptions,button:n,currentVariableList:null!=Oe&&Oe>-1?Object.assign({},Ce.cards[Oe]):Object.assign({},Ce),updateSelectedQRBTemplateBtn:Ge},`${t}_${Oe}`)})),Te===d.POD.CHATBOT&&Pe&&e.jsx(b.DiscountCodeComponent,{discountCode:null===(be=null==xe?void 0:xe.discountCodeExtra)||void 0===be?void 0:be[0],setDiscountCode:null===(ge=null==xe?void 0:xe.discountCodeExtra)||void 0===ge?void 0:ge[1]}),null===(fe=null!=Oe&&Oe>-1?null===(he=Ce.cards[Oe])||void 0===he?void 0:he.buttons:null==Ce?void 0:Ce.buttons)||void 0===fe?void 0:fe.map(((n,t)=>{var o,i,a,s,d;if("COPY_CODE"===n.type)return e.jsx(e.Fragment,{children:ye?e.jsx("div",Object.assign({style:{marginBottom:20,borderRadius:4,padding:"8px 10px"}},{children:e.jsx(l.Input,{state:"disabled",labelText:null!==(o=n.text)&&void 0!==o?o:"Copy Code",value:null!==(i=n.buttonVariable)&&void 0!==i?i:"",onChangeText:()=>{}})})):e.jsx(C.default,{index:t,variable:{variableName:null!==(a=n.text)&&void 0!==a?a:"Copy Code",updatedValue:null!==(s=n.buttonVariable)&&void 0!==s?s:"",type:"string",isEditableVariable:!0,index:null!==(d=n.index)&&void 0!==d?d:0},showVariableModal:!0,componentType:"BUTTONS",buttonType:n.type},t)})}))]}))};
@@ -1,3 +1,4 @@
1
+ /// <reference types="react" />
1
2
  export declare const Menus: ({
2
3
  displayName: string;
3
4
  key: number;
@@ -1,4 +1,4 @@
1
- import{jsx as e,jsxs as o,Fragment as n}from"react/jsx-runtime";import"../../curtain/CurtainHelper.js";import{PickerType as t}from"../../variable-picker-v3/model.js";import{cloneDeep as i}from"lodash";import{useRef as l,useState as a,useEffect as s}from"react";import d from"styled-components";import{Input as r}from"../../input/Input.js";import{InputWithVariables as p}from"../../input-with-vars/InputWithVariables.js";import{HEADER_TYPES as u}from"../../template-preview/models/TemplateMeta.js";import{POD as c}from"../../template-preview/models/WhatsAppTemplate.js";import{useTemplateModalContext as v}from"../context/templateModalContext.js";import{STATIC_URL_VARIABLE_NAME as m}from"../utils/constants.js";import{getAllDataFromTemplateComponent as b}from"../utils/getDataFromTemplateComponent.js";import{isVariable as g}from"../utils/validateIsUrl.js";import{validateInputName as f,validateInputNameChatbot as h}from"../utils/validateName.js";import{BackTrackComponent as j}from"./BackTrackComponent.js";import{DiscountCodeComponent as C}from"./DiscountCodeComponent.js";import O from"./EditMediaModal.js";import T from"./EditMediaV2.js";import{EditTemplateMediaContainer as x}from"./EditMediaV2.style.js";import{useEditWhatsappTemplateMedia as y}from"./useEditWhtasappTemplateMedia.js";import E from"./VariableConnector.js";import{Container as V}from"./VariableConnectorsPanel.js";import B from"./VariableConnectorWhatsApp.js";import M from"./VariableEditorHeader.js";import k from"./WhatsAppTemplateCardButtonV2.js";const I=d=>{let{template:I,onTemplateChange:R,whatsappSpecificPickerMeta:U,showVariableModal:w,variableListForImage:P,setDiscountCode:N,fileName:A,setFileName:D}=d;var H,_,F,S,q,Q,Y,K,W,$,G,X,z,J,Z,ee,oe,ne,te,ie,le,ae,se,de,re,pe,ue,ce,ve,me,be,ge,fe,he,je,Ce,Oe,Te,xe;const ye=I.isCarouselType,{originalVariableList:Ee,pod:Ve,extras:Be,selectedCarouselIndex:Me,isProductCarouselType:ke,disableCopyCode:Ie,isError:Le}=v(),{descriptionComponents:Re,urlBtns:Ue,qrbBtns:we,imageComponent:Pe,bodyVariables:Ne,headerVariables:Ae}=b(I),De=l(null),[He,_e]=a(!1),[Fe,Se]=a(-1===Me?{descriptionComponents:Re,urlBtns:Ue,qrbBtns:we,imageComponent:Pe,bodyVariables:Ne,headerVariables:Ae}:{}),{uploadMediaLink:qe,uploadMediaFiles:Qe,validateMimeType:Ye}=U,Ke=y({uploadMediaLink:qe,uploadMediaFiles:Qe,updateTemplateImageUrl:function(e,o){var n,t,l,a,s,d,r,p;let u;u=null!=Me&&Me>-1?{components:null===(t=null===(n=I.components[1])||void 0===n?void 0:n.cards)||void 0===t?void 0:t[Me].components,mapping:null===(a=null===(l=null==I?void 0:I.mapping)||void 0===l?void 0:l.cards)||void 0===a?void 0:a[Me]}:Object.assign({},I);const c=null===(s=null==u?void 0:u.components)||void 0===s?void 0:s.findIndex((e=>{if("HEADER"===e.type&&"NONE"!==e.format&&"TEXT"!==e.format)return!0}));if(void 0!==c&&c>-1&&(null==u?void 0:u.components[c])){const n=Object.assign(Object.assign({},u.components[c]),{format:o,example:{header_handle:[e]}}),t=[...u.components];t[c]=n,u=Object.assign(Object.assign({},u),{components:t})}u.mapping&&(u.mapping=Object.assign(Object.assign({},u.mapping),{header:void 0}));if(null!=Me&&Me>-1){const e=i(I);e.components[1].cards[Me].components=u.components,(null===(d=null==e?void 0:e.mapping)||void 0===d?void 0:d.cards)&&(null===(r=null==e?void 0:e.mapping)||void 0===r?void 0:r.cards.length)>0&&(e.mapping.cards[Me]=null!==(p=u.mapping)&&void 0!==p?p:{}),null==R||R(Object.assign({},e)),$e(!0)}else null==R||R(Object.assign({},u))},validateMimeType:Ye,mediaComponent:ye?Fe.imageComponent:Pe,fileRef:De}),[We,$e]=a(!1),[Ge,Xe]=a(A),[ze,Je]=a();function Ze(e,o,n){var t,l,a,s,d,r,p,u,c,v;const m=null!=Me&&Me>-1?{components:null===(t=Object.assign({},I).components[1].cards)||void 0===t?void 0:t[Me].components,mapping:null===(l=Object.assign({},I).mapping.cards)||void 0===l?void 0:l[Me]}:Object.assign({},I),b=i(m),g="custom"===o&&"string"==typeof e,f=g?e:"string"!=typeof e?e.defaultValue?e.defaultValue:"https://d.bik.ai/":"https://d.bik.ai";if(null!=Me&&Me>-1&&ke){const o=Object.assign({},I).components.map((e=>{var o;return"CAROUSEL"===e.type?Object.assign(Object.assign({},e),{cards:null===(o=e.cards)||void 0===o?void 0:o.map((e=>Object.assign(Object.assign({},e),{components:e.components.map((e=>{var o,t,i;if("BUTTONS"===e.type){const l=null===(o=e.buttons)||void 0===o?void 0:o.filter((e=>"URL"===e.type));let a=null!==(t=null==l?void 0:l[n])&&void 0!==t?t:{};a=Object.assign(Object.assign({},a),{url:"https://d.bik.ai/{{1}}",example:[f]});const s=null===(i=e.buttons)||void 0===i?void 0:i.map((e=>"URL"===e.type&&(null==e?void 0:e.text)===(null==a?void 0:a.text)?a:e));return Object.assign(Object.assign({},e),{buttons:s})}return e}))})))}):e})),t=null===(s=null===(a=Object.assign({},I).mapping)||void 0===a?void 0:a.cards)||void 0===s?void 0:s.map((o=>{var n;return Object.assign(Object.assign({},o),{buttons:null===(n=null==o?void 0:o.buttons)||void 0===n?void 0:n.map((o=>g?"((customBtnPlaceholder))":"string"!=typeof e?e.placeHolder:""))})})),l=i(I);return l.components=o,l.mapping.cards=t,void(null==R||R(Object.assign({},l)))}const h=null==b?void 0:b.components.findIndex((e=>"BUTTONS"===e.type));if(void 0!==h&&h>-1){const t=null===(d=null==b?void 0:b.components[h].buttons)||void 0===d?void 0:d.filter((e=>"URL"===e.type));if((null==t?void 0:t.length)>0){const i="custom"===o&&"string"==typeof e,l=i?e:"string"!=typeof e&&e.defaultValue?e.defaultValue:"https://d.bik.ai/";let a=t[n];a=Object.assign(Object.assign({},a),{url:"https://d.bik.ai/{{1}}",example:[l]});const s=[...null!==(u=null===(p=null===(r=b.components)||void 0===r?void 0:r[h])||void 0===p?void 0:p.buttons)&&void 0!==u?u:[]].map((e=>"URL"===e.type&&(null==e?void 0:e.text)===(null==a?void 0:a.text)?a:e)),d=Object.assign(Object.assign({},b.components[h]),{buttons:s}),v=null===(c=b.mapping)||void 0===c?void 0:c.buttons;v&&v.length>0&&(v[n]=i?"((customBtnPlaceholder))":"string"!=typeof e?e.placeHolder:"");const m=Object.assign(Object.assign({},b.mapping),{buttons:v});b.mapping=m;const g=[...b.components];g[h]=d,b.components=g}}if("string"!=typeof e){"checkout.checkoutUrl"===(null===(v=e.placeHolder)||void 0===v?void 0:v.slice(2,-2))?_e(!0):(_e(!1),null==N||N(""))}if(null!=Me&&Me>-1){const e=i(I);e.components[1].cards[Me].components=b.components,e.mapping.cards[Me]=b.mapping,null==R||R(Object.assign({},e))}else null==R||R(b)}function eo(e,o,n){var t,l,a,s,d,r,p;const u=null!=Me&&Me>-1?{components:null===(t=Object.assign({},I).components[1].cards)||void 0===t?void 0:t[Me].components,mapping:null===(l=Object.assign({},I).mapping.cards)||void 0===l?void 0:l[Me]}:Object.assign({},I);if(null!=Me&&Me>-1&&ke){const o=Object.assign({},I).components.map((o=>{var t;return"CAROUSEL"===o.type?Object.assign(Object.assign({},o),{cards:null===(t=o.cards)||void 0===t?void 0:t.map((o=>Object.assign(Object.assign({},o),{components:o.components.map((o=>{var t,i,l;if("BUTTONS"===o.type){const a=null===(t=null==o?void 0:o.buttons)||void 0===t?void 0:t.filter((e=>"QUICK_REPLY"===e.type));let s=null!==(i=null==a?void 0:a[n])&&void 0!==i?i:{};s=Object.assign(Object.assign({},s),{flowId:e.flowId,flowName:e.flowName});const d=null===(l=null==o?void 0:o.buttons)||void 0===l?void 0:l.map((e=>"QUICK_REPLY"===e.type&&(null==e?void 0:e.text)===(null==s?void 0:s.text)?s:e));return Object.assign(Object.assign({},o),{buttons:d})}return o}))})))}):o})),t=i(I);return t.components=o,void(null==R||R(Object.assign({},t)))}const c=null==u?void 0:u.components.findIndex((e=>"BUTTONS"===e.type));if(void 0!==c&&c>-1){const o=null===(s=null===(a=null==u?void 0:u.components[c])||void 0===a?void 0:a.buttons)||void 0===s?void 0:s.filter((e=>"QUICK_REPLY"===e.type));if(o){let t=o[n];t=Object.assign(Object.assign({},t),{flowId:e.flowId,flowName:e.flowName});const i=[...null!==(p=null===(r=null===(d=u.components)||void 0===d?void 0:d[c])||void 0===r?void 0:r.buttons)&&void 0!==p?p:[]].map((e=>"QUICK_REPLY"===e.type&&(null==e?void 0:e.text)===(null==t?void 0:t.text)?t:e)),l=Object.assign(Object.assign({},u.components[c]),{buttons:i}),a=[...u.components];a[c]=l,u.components=a}}if(null!=Me&&Me>-1){const e=i(I);e.components[1].cards[Me].components=u.components,null==R||R(Object.assign({},e))}else null==R||R(u)}s((()=>{var e,o;if(null===(e=I.mapping.buttons)||void 0===e?void 0:e.find((e=>"checkout.checkoutUrl"===e.slice(2,-2))))_e(!0);else{_e(!1);const e=null===(o=null==Be?void 0:Be.discountCodeExtra)||void 0===o?void 0:o[1];null==e||e("")}}),[I]),s((()=>{var e,o,n,t;if(null!=Me&&Me>-1){const i={components:null===(o=null===(e=I.components[1])||void 0===e?void 0:e.cards)||void 0===o?void 0:o[Me].components,mapping:null===(t=null===(n=null==I?void 0:I.mapping)||void 0===n?void 0:n.cards)||void 0===t?void 0:t[Me]},{descriptionComponents:l,urlBtns:a,qrbBtns:s,imageComponent:d,bodyVariables:r,headerVariables:p}=b(i);Se({descriptionComponents:l,urlBtns:a,qrbBtns:s,imageComponent:d,bodyVariables:r,headerVariables:p})}else if(null!=Me&&-1===Me){const{descriptionComponents:e,urlBtns:o,qrbBtns:n,imageComponent:t,bodyVariables:i,headerVariables:l}=b(I);Se({descriptionComponents:e,urlBtns:o,qrbBtns:n,imageComponent:t,bodyVariables:i,headerVariables:l})}}),[Me]),s((()=>{var e,o,n,t;if(null!=Me&&Me>-1&&We){const i={components:null===(o=null===(e=I.components[1])||void 0===e?void 0:e.cards)||void 0===o?void 0:o[Me].components,mapping:null===(t=null===(n=null==I?void 0:I.mapping)||void 0===n?void 0:n.cards)||void 0===t?void 0:t[Me]},{descriptionComponents:l,urlBtns:a,qrbBtns:s,imageComponent:d,bodyVariables:r,headerVariables:p}=b(i);Se({descriptionComponents:l,urlBtns:a,qrbBtns:s,imageComponent:d,bodyVariables:r,headerVariables:p}),$e(!1)}}),[We]);s((()=>{Le&&Ve===c.CHATBOT&&(()=>{if(!A)return void Je("PDF name is Required");const e=h(A);null==D||D(null!=A?A:""),Je(e?"Please enter a valid PDF name":void 0)})()}),[Le]);const oo=ye?Fe.imageComponent:Pe;return Ke.openEditMedia?e(V,Object.assign({style:{flexDirection:"column",width:400,maxHeight:460}},{children:e(O,{mediaComponentFormat:null!==(H=oo.format)&&void 0!==H?H:u.IMAGE,uploadMedia:Ke.uploadMedia,variableListForImage:P||[],useEditWhatsappTemplateMediaResponse:Ke,setOpenEditMedia:Ke.setOpenEditMedia,openEditMedia:Ke.openEditMedia,editIconRef:Ke.editIconRef,fileRef:De})})):o(V,Object.assign({style:{flexDirection:"column",width:400,maxHeight:460,minWidth:ke?"420px":"auto"}},{children:[!!Fe.imageComponent&&!ke&&o(x,{children:[e(T,{imageName:null!==(F=null===(_=null==oo?void 0:oo.example)||void 0===_?void 0:_.header_handle)&&void 0!==F?F:[],handleImageChange:Ke.handleImageChange,mediaType:null==oo?void 0:oo.format,error:Ke.error,isLoading:Ke.loading,setOpenEditMedia:Ke.setOpenEditMedia,selectedVariable:g(null!==(Q=null===(q=null===(S=null==oo?void 0:oo.example)||void 0===S?void 0:S.header_handle)||void 0===q?void 0:q[0])&&void 0!==Q?Q:"")?null===(K=null===(Y=null==oo?void 0:oo.example)||void 0===Y?void 0:Y.header_handle)||void 0===K?void 0:K[0]:(null===($=null===(W=null==I?void 0:I.mapping)||void 0===W?void 0:W.header)||void 0===$?void 0:$[0])?null===(X=null===(G=null==I?void 0:I.mapping)||void 0===G?void 0:G.header)||void 0===X?void 0:X[0]:Ke.selectedVariable}),(null==Pe?void 0:Pe.format)==u.DOCUMENT?e(L,{children:Ve===c.CHATBOT?e(p,{labelText:"PDF Name",placeHolder:"Enter the name",errorMessage:ze||void 0,onChange:e=>{var o;Je(""),null==D||D(null!==(o=null==e?void 0:e.actualValue)&&void 0!==o?o:"")},pickerType:t.EMBEDDED,noMaxCharCheck:!0,allowMix:!0,showVarHeader:!0,varHeaderText:"Select variable",prevVariable:{actualValue:null!=A?A:"",variableType:"string"},variablesList:P,showAddButton:!0}):e(r,{labelText:"PDF Name",placeholder:"Enter the name",value:Ge,errorMessage:ze||void 0,onBlur:()=>{if(!Ge)return null==D||D(""),void Je("PDF name is Required");const e=f(Ge);null==D||D(Ge),Je(e?"Please enter a valid PDF name":void 0)},onChangeText:e=>{Je(""),Xe(e)}})}):e(n,{})]}),(null===(z=Fe.bodyVariables)||void 0===z?void 0:z.length)>0&&e(M,{containerStyle:{paddingTop:Fe.mediaComponent?24:8},headerText:"Edit variable values",subText:"Edit values for the variables used in template",toolTipInfo:"Variables are placeholder texts which can either be filled through data or custom texts. These can be edited through the dropdowns below"}),null===(J=Fe.descriptionComponents)||void 0===J?void 0:J.map(((o,n)=>e(B,{originalVariableList:null!=Me&&Me>-1?Ee.cards[Me]:Ee,type:o.type,descriptionComponent:o.component,showVariableModal:w},n))),(null===(oe=null===(ee=null!=Me&&Me>-1?null===(Z=Ee.cards[Me])||void 0===Z?void 0:Z.buttons:null==Ee?void 0:Ee.buttons)||void 0===ee?void 0:ee.filter((e=>"URL"===e.type)))||void 0===oe?void 0:oe.length)>0&&e(M,{headerText:"Edit buttons",subText:"Edit the link connected to the CTA button"}),null===(ie=null===(te=null!=Me&&Me>-1?null===(ne=Ee.cards[Me])||void 0===ne?void 0:ne.buttons:null==Ee?void 0:Ee.buttons)||void 0===te?void 0:te.filter((e=>Ve===c.CHATBOT||"URL"===e.type)))||void 0===ie?void 0:ie.map(((o,n)=>{const t=o.buttonVariable===m;if("URL"===o.type)return e(k,{variableListIndex:n,disableEdit:t,CTAoptions:null==U?void 0:U.CTAoptions,button:o,currentVariableList:null!=Me&&Me>-1?Object.assign({},Ee.cards[Me]):Object.assign({},Ee),updateSelectedURLTemplateBtn:Ze},`${n}_${Me}`)})),Ve===c.CHATBOT&&(null===(ae=null===(le=we[0])||void 0===le?void 0:le.component)||void 0===ae?void 0:ae.buttons)&&(null===(re=null===(de=null===(se=we[0])||void 0===se?void 0:se.component)||void 0===de?void 0:de.buttons)||void 0===re?void 0:re.length)>0&&e(j,{backTrackMessage:null===(pe=null==Be?void 0:Be.backTrackExtra)||void 0===pe?void 0:pe[0],setBackTrackMessage:null===(ue=null==Be?void 0:Be.backTrackExtra)||void 0===ue?void 0:ue[1]}),(null===(me=null===(ve=null!=Me&&Me>-1?null===(ce=Ee.cards[Me])||void 0===ce?void 0:ce.buttons:null==Ee?void 0:Ee.buttons)||void 0===ve?void 0:ve.filter((e=>"QUICK_REPLY"===e.type)))||void 0===me?void 0:me.length)>0&&(Ve!==c.CHATBOT?e(M,{headerText:"Edit buttons",subText:"Edit the chatflows triggered on clicking the buttons",toolTipInfo:"There is an option to trigger chatflows through the buttons which can keep the user engaged"}):e(j,{backTrackMessage:null===(be=null==Be?void 0:Be.backTrackExtra)||void 0===be?void 0:be[0],setBackTrackMessage:null===(ge=null==Be?void 0:Be.backTrackExtra)||void 0===ge?void 0:ge[1]})),null===(je=null===(he=null!=Me&&Me>-1?null===(fe=Ee.cards[Me])||void 0===fe?void 0:fe.buttons:null==Ee?void 0:Ee.buttons)||void 0===he?void 0:he.filter((e=>"QUICK_REPLY"===e.type)))||void 0===je?void 0:je.map(((o,n)=>{if("QUICK_REPLY"===o.type&&Ve!==c.CHATBOT)return e(k,{variableListIndex:n,QRBoptions:null==U?void 0:U.QRBoptions,button:o,currentVariableList:null!=Me&&Me>-1?Object.assign({},Ee.cards[Me]):Object.assign({},Ee),updateSelectedQRBTemplateBtn:eo},`${n}_${Me}`)})),Ve===c.CHATBOT&&He&&e(C,{discountCode:null===(Ce=null==Be?void 0:Be.discountCodeExtra)||void 0===Ce?void 0:Ce[0],setDiscountCode:null===(Oe=null==Be?void 0:Be.discountCodeExtra)||void 0===Oe?void 0:Oe[1]}),null===(xe=null!=Me&&Me>-1?null===(Te=Ee.cards[Me])||void 0===Te?void 0:Te.buttons:null==Ee?void 0:Ee.buttons)||void 0===xe?void 0:xe.map(((o,t)=>{var i,l,a,s,d;if("COPY_CODE"===o.type)return e(n,{children:Ie?e("div",Object.assign({style:{marginBottom:20,borderRadius:4,padding:"8px 10px"}},{children:e(r,{state:"disabled",labelText:null!==(i=o.text)&&void 0!==i?i:"Copy Code",value:null!==(l=o.buttonVariable)&&void 0!==l?l:"",onChangeText:()=>{}})})):e(E,{index:t,variable:{variableName:null!==(a=o.text)&&void 0!==a?a:"Copy Code",updatedValue:null!==(s=o.buttonVariable)&&void 0!==s?s:"",type:"string",isEditableVariable:!0,index:null!==(d=o.index)&&void 0!==d?d:0},showVariableModal:!0,componentType:"BUTTONS",buttonType:o.type},t)})}))]}))},L=d.div`
1
+ import{jsx as e,jsxs as o,Fragment as n}from"react/jsx-runtime";import"../../curtain/CurtainHelper.js";import{PickerType as t}from"../../variable-picker-v3/model.js";import{cloneDeep as i}from"lodash";import{useRef as l,useState as a,useEffect as s}from"react";import d from"styled-components";import{Input as r}from"../../input/Input.js";import{InputWithVariables as p}from"../../input-with-vars/InputWithVariables.js";import{HEADER_TYPES as u}from"../../template-preview/models/TemplateMeta.js";import{POD as c}from"../../template-preview/models/WhatsAppTemplate.js";import{useTemplateModalContext as v}from"../context/templateModalContext.js";import{STATIC_URL_VARIABLE_NAME as m}from"../utils/constants.js";import{getAllDataFromTemplateComponent as b}from"../utils/getDataFromTemplateComponent.js";import{isVariable as g}from"../utils/validateIsUrl.js";import{validateInputName as f,validateInputNameChatbot as h}from"../utils/validateName.js";import{BackTrackComponent as j}from"./BackTrackComponent.js";import{DiscountCodeComponent as C}from"./DiscountCodeComponent.js";import O from"./EditMediaModal.js";import T from"./EditMediaV2.js";import{EditTemplateMediaContainer as x}from"./EditMediaV2.style.js";import{useEditWhatsappTemplateMedia as y}from"./useEditWhtasappTemplateMedia.js";import E from"./VariableConnector.js";import{Container as V}from"./VariableConnectorsPanel.js";import B from"./VariableConnectorWhatsApp.js";import M from"./VariableEditorHeader.js";import k from"./WhatsAppTemplateCardButtonV2.js";const I=d=>{let{template:I,onTemplateChange:R,whatsappSpecificPickerMeta:U,showVariableModal:w,variableListForImage:P,setDiscountCode:N,fileName:A,setFileName:D}=d;var H,_,F,S,q,Q,Y,K,W,$,G,X,z,J,Z,ee,oe,ne,te,ie,le,ae,se,de,re,pe,ue,ce,ve,me,be,ge,fe,he,je,Ce,Oe,Te,xe;const ye=I.isCarouselType,{originalVariableList:Ee,pod:Ve,extras:Be,selectedCarouselIndex:Me,isProductCarouselType:ke,disableCopyCode:Ie,isError:Le}=v(),{descriptionComponents:Re,urlBtns:Ue,qrbBtns:we,imageComponent:Pe,bodyVariables:Ne,headerVariables:Ae}=b(I),De=l(null),[He,_e]=a(!1),[Fe,Se]=a(-1===Me?{descriptionComponents:Re,urlBtns:Ue,qrbBtns:we,imageComponent:Pe,bodyVariables:Ne,headerVariables:Ae}:{}),{uploadMediaLink:qe,uploadMediaFiles:Qe,validateMimeType:Ye}=U,Ke=y({uploadMediaLink:qe,uploadMediaFiles:Qe,updateTemplateImageUrl:function(e,o){var n,t,l,a,s,d,r,p;let u;u=null!=Me&&Me>-1?{components:null===(t=null===(n=I.components[1])||void 0===n?void 0:n.cards)||void 0===t?void 0:t[Me].components,mapping:null===(a=null===(l=null==I?void 0:I.mapping)||void 0===l?void 0:l.cards)||void 0===a?void 0:a[Me]}:Object.assign({},I);const c=null===(s=null==u?void 0:u.components)||void 0===s?void 0:s.findIndex((e=>{if("HEADER"===e.type&&"NONE"!==e.format&&"TEXT"!==e.format)return!0}));if(void 0!==c&&c>-1&&(null==u?void 0:u.components[c])){const n=Object.assign(Object.assign({},u.components[c]),{format:o,example:{header_handle:[e]}}),t=[...u.components];t[c]=n,u=Object.assign(Object.assign({},u),{components:t})}u.mapping&&(u.mapping=Object.assign(Object.assign({},u.mapping),{header:void 0}));if(null!=Me&&Me>-1){const e=i(I);e.components[1].cards[Me].components=u.components,(null===(d=null==e?void 0:e.mapping)||void 0===d?void 0:d.cards)&&(null===(r=null==e?void 0:e.mapping)||void 0===r?void 0:r.cards.length)>0&&(e.mapping.cards[Me]=null!==(p=u.mapping)&&void 0!==p?p:{}),null==R||R(Object.assign({},e)),$e(!0)}else null==R||R(Object.assign({},u))},validateMimeType:Ye,mediaComponent:ye?Fe.imageComponent:Pe,fileRef:De}),[We,$e]=a(!1),[Ge,Xe]=a(A),[ze,Je]=a();function Ze(e,o,n){var t,l,a,s,d,r,p,u,c,v;const m=null!=Me&&Me>-1?{components:null===(t=Object.assign({},I).components[1].cards)||void 0===t?void 0:t[Me].components,mapping:null===(l=Object.assign({},I).mapping.cards)||void 0===l?void 0:l[Me]}:Object.assign({},I),b=i(m),g="custom"===o&&"string"==typeof e,f=g?e:"string"!=typeof e?e.defaultValue?e.defaultValue:"https://d.bik.ai/":"https://d.bik.ai";if(null!=Me&&Me>-1&&ke){const o=Object.assign({},I).components.map((e=>{var o;return"CAROUSEL"===e.type?Object.assign(Object.assign({},e),{cards:null===(o=e.cards)||void 0===o?void 0:o.map((e=>Object.assign(Object.assign({},e),{components:e.components.map((e=>{var o,t,i;if("BUTTONS"===e.type){const l=null===(o=e.buttons)||void 0===o?void 0:o.filter((e=>"URL"===e.type));let a=null!==(t=null==l?void 0:l[n])&&void 0!==t?t:{};a=Object.assign(Object.assign({},a),{url:"https://d.bik.ai/{{1}}",example:[f]});const s=null===(i=e.buttons)||void 0===i?void 0:i.map((e=>"URL"===e.type&&(null==e?void 0:e.text)===(null==a?void 0:a.text)?a:e));return Object.assign(Object.assign({},e),{buttons:s})}return e}))})))}):e})),t=null===(s=null===(a=Object.assign({},I).mapping)||void 0===a?void 0:a.cards)||void 0===s?void 0:s.map((o=>{var t;return Object.assign(Object.assign({},o),{buttons:null===(t=null==o?void 0:o.buttons)||void 0===t?void 0:t.map(((o,t)=>t===n?g?"((customBtnPlaceholder))":"string"!=typeof e?e.placeHolder:"":o))})})),l=i(I);return l.components=o,l.mapping.cards=t,void(null==R||R(Object.assign({},l)))}const h=null==b?void 0:b.components.findIndex((e=>"BUTTONS"===e.type));if(void 0!==h&&h>-1){const t=null===(d=null==b?void 0:b.components[h].buttons)||void 0===d?void 0:d.filter((e=>"URL"===e.type));if((null==t?void 0:t.length)>0){const i="custom"===o&&"string"==typeof e,l=i?e:"string"!=typeof e&&e.defaultValue?e.defaultValue:"https://d.bik.ai/";let a=t[n];a=Object.assign(Object.assign({},a),{url:"https://d.bik.ai/{{1}}",example:[l]});const s=[...null!==(u=null===(p=null===(r=b.components)||void 0===r?void 0:r[h])||void 0===p?void 0:p.buttons)&&void 0!==u?u:[]].map((e=>"URL"===e.type&&(null==e?void 0:e.text)===(null==a?void 0:a.text)?a:e)),d=Object.assign(Object.assign({},b.components[h]),{buttons:s}),v=null===(c=b.mapping)||void 0===c?void 0:c.buttons;v&&v.length>0&&(v[n]=i?"((customBtnPlaceholder))":"string"!=typeof e?e.placeHolder:"");const m=Object.assign(Object.assign({},b.mapping),{buttons:v});b.mapping=m;const g=[...b.components];g[h]=d,b.components=g}}if("string"!=typeof e){"checkout.checkoutUrl"===(null===(v=e.placeHolder)||void 0===v?void 0:v.slice(2,-2))?_e(!0):(_e(!1),null==N||N(""))}if(null!=Me&&Me>-1){const e=i(I);e.components[1].cards[Me].components=b.components,e.mapping.cards[Me]=b.mapping,null==R||R(Object.assign({},e))}else null==R||R(b)}function eo(e,o,n){var t,l,a,s,d,r,p;const u=null!=Me&&Me>-1?{components:null===(t=Object.assign({},I).components[1].cards)||void 0===t?void 0:t[Me].components,mapping:null===(l=Object.assign({},I).mapping.cards)||void 0===l?void 0:l[Me]}:Object.assign({},I);if(null!=Me&&Me>-1&&ke){const o=Object.assign({},I).components.map((o=>{var t;return"CAROUSEL"===o.type?Object.assign(Object.assign({},o),{cards:null===(t=o.cards)||void 0===t?void 0:t.map((o=>Object.assign(Object.assign({},o),{components:o.components.map((o=>{var t,i,l;if("BUTTONS"===o.type){const a=null===(t=null==o?void 0:o.buttons)||void 0===t?void 0:t.filter((e=>"QUICK_REPLY"===e.type));let s=null!==(i=null==a?void 0:a[n])&&void 0!==i?i:{};s=Object.assign(Object.assign({},s),{flowId:e.flowId,flowName:e.flowName});const d=null===(l=null==o?void 0:o.buttons)||void 0===l?void 0:l.map((e=>"QUICK_REPLY"===e.type&&(null==e?void 0:e.text)===(null==s?void 0:s.text)?s:e));return Object.assign(Object.assign({},o),{buttons:d})}return o}))})))}):o})),t=i(I);return t.components=o,void(null==R||R(Object.assign({},t)))}const c=null==u?void 0:u.components.findIndex((e=>"BUTTONS"===e.type));if(void 0!==c&&c>-1){const o=null===(s=null===(a=null==u?void 0:u.components[c])||void 0===a?void 0:a.buttons)||void 0===s?void 0:s.filter((e=>"QUICK_REPLY"===e.type));if(o){let t=o[n];t=Object.assign(Object.assign({},t),{flowId:e.flowId,flowName:e.flowName});const i=[...null!==(p=null===(r=null===(d=u.components)||void 0===d?void 0:d[c])||void 0===r?void 0:r.buttons)&&void 0!==p?p:[]].map((e=>"QUICK_REPLY"===e.type&&(null==e?void 0:e.text)===(null==t?void 0:t.text)?t:e)),l=Object.assign(Object.assign({},u.components[c]),{buttons:i}),a=[...u.components];a[c]=l,u.components=a}}if(null!=Me&&Me>-1){const e=i(I);e.components[1].cards[Me].components=u.components,null==R||R(Object.assign({},e))}else null==R||R(u)}s((()=>{var e,o;if(null===(e=I.mapping.buttons)||void 0===e?void 0:e.find((e=>"checkout.checkoutUrl"===e.slice(2,-2))))_e(!0);else{_e(!1);const e=null===(o=null==Be?void 0:Be.discountCodeExtra)||void 0===o?void 0:o[1];null==e||e("")}}),[I]),s((()=>{var e,o,n,t;if(null!=Me&&Me>-1){const i={components:null===(o=null===(e=I.components[1])||void 0===e?void 0:e.cards)||void 0===o?void 0:o[Me].components,mapping:null===(t=null===(n=null==I?void 0:I.mapping)||void 0===n?void 0:n.cards)||void 0===t?void 0:t[Me]},{descriptionComponents:l,urlBtns:a,qrbBtns:s,imageComponent:d,bodyVariables:r,headerVariables:p}=b(i);Se({descriptionComponents:l,urlBtns:a,qrbBtns:s,imageComponent:d,bodyVariables:r,headerVariables:p})}else if(null!=Me&&-1===Me){const{descriptionComponents:e,urlBtns:o,qrbBtns:n,imageComponent:t,bodyVariables:i,headerVariables:l}=b(I);Se({descriptionComponents:e,urlBtns:o,qrbBtns:n,imageComponent:t,bodyVariables:i,headerVariables:l})}}),[Me]),s((()=>{var e,o,n,t;if(null!=Me&&Me>-1&&We){const i={components:null===(o=null===(e=I.components[1])||void 0===e?void 0:e.cards)||void 0===o?void 0:o[Me].components,mapping:null===(t=null===(n=null==I?void 0:I.mapping)||void 0===n?void 0:n.cards)||void 0===t?void 0:t[Me]},{descriptionComponents:l,urlBtns:a,qrbBtns:s,imageComponent:d,bodyVariables:r,headerVariables:p}=b(i);Se({descriptionComponents:l,urlBtns:a,qrbBtns:s,imageComponent:d,bodyVariables:r,headerVariables:p}),$e(!1)}}),[We]);s((()=>{Le&&Ve===c.CHATBOT&&(()=>{if(!A)return void Je("PDF name is Required");const e=h(A);null==D||D(null!=A?A:""),Je(e?"Please enter a valid PDF name":void 0)})()}),[Le]);const oo=ye?Fe.imageComponent:Pe;return Ke.openEditMedia?e(V,Object.assign({style:{flexDirection:"column",width:400,maxHeight:460}},{children:e(O,{mediaComponentFormat:null!==(H=oo.format)&&void 0!==H?H:u.IMAGE,uploadMedia:Ke.uploadMedia,variableListForImage:P||[],useEditWhatsappTemplateMediaResponse:Ke,setOpenEditMedia:Ke.setOpenEditMedia,openEditMedia:Ke.openEditMedia,editIconRef:Ke.editIconRef,fileRef:De})})):o(V,Object.assign({style:{flexDirection:"column",width:400,maxHeight:460,minWidth:ke?"420px":"auto"}},{children:[!!Fe.imageComponent&&!ke&&o(x,{children:[e(T,{imageName:null!==(F=null===(_=null==oo?void 0:oo.example)||void 0===_?void 0:_.header_handle)&&void 0!==F?F:[],handleImageChange:Ke.handleImageChange,mediaType:null==oo?void 0:oo.format,error:Ke.error,isLoading:Ke.loading,setOpenEditMedia:Ke.setOpenEditMedia,selectedVariable:g(null!==(Q=null===(q=null===(S=null==oo?void 0:oo.example)||void 0===S?void 0:S.header_handle)||void 0===q?void 0:q[0])&&void 0!==Q?Q:"")?null===(K=null===(Y=null==oo?void 0:oo.example)||void 0===Y?void 0:Y.header_handle)||void 0===K?void 0:K[0]:(null===($=null===(W=null==I?void 0:I.mapping)||void 0===W?void 0:W.header)||void 0===$?void 0:$[0])?null===(X=null===(G=null==I?void 0:I.mapping)||void 0===G?void 0:G.header)||void 0===X?void 0:X[0]:Ke.selectedVariable}),(null==Pe?void 0:Pe.format)==u.DOCUMENT?e(L,{children:Ve===c.CHATBOT?e(p,{labelText:"PDF Name",placeHolder:"Enter the name",errorMessage:ze||void 0,onChange:e=>{var o;Je(""),null==D||D(null!==(o=null==e?void 0:e.actualValue)&&void 0!==o?o:"")},pickerType:t.EMBEDDED,noMaxCharCheck:!0,allowMix:!0,showVarHeader:!0,varHeaderText:"Select variable",prevVariable:{actualValue:null!=A?A:"",variableType:"string"},variablesList:P,showAddButton:!0}):e(r,{labelText:"PDF Name",placeholder:"Enter the name",value:Ge,errorMessage:ze||void 0,onBlur:()=>{if(!Ge)return null==D||D(""),void Je("PDF name is Required");const e=f(Ge);null==D||D(Ge),Je(e?"Please enter a valid PDF name":void 0)},onChangeText:e=>{Je(""),Xe(e)}})}):e(n,{})]}),(null===(z=Fe.bodyVariables)||void 0===z?void 0:z.length)>0&&e(M,{containerStyle:{paddingTop:Fe.mediaComponent?24:8},headerText:"Edit variable values",subText:"Edit values for the variables used in template",toolTipInfo:"Variables are placeholder texts which can either be filled through data or custom texts. These can be edited through the dropdowns below"}),null===(J=Fe.descriptionComponents)||void 0===J?void 0:J.map(((o,n)=>e(B,{originalVariableList:null!=Me&&Me>-1?Ee.cards[Me]:Ee,type:o.type,descriptionComponent:o.component,showVariableModal:w},n))),(null===(oe=null===(ee=null!=Me&&Me>-1?null===(Z=Ee.cards[Me])||void 0===Z?void 0:Z.buttons:null==Ee?void 0:Ee.buttons)||void 0===ee?void 0:ee.filter((e=>"URL"===e.type)))||void 0===oe?void 0:oe.length)>0&&e(M,{headerText:"Edit buttons",subText:"Edit the link connected to the CTA button"}),null===(ie=null===(te=null!=Me&&Me>-1?null===(ne=Ee.cards[Me])||void 0===ne?void 0:ne.buttons:null==Ee?void 0:Ee.buttons)||void 0===te?void 0:te.filter((e=>Ve===c.CHATBOT||"URL"===e.type)))||void 0===ie?void 0:ie.map(((o,n)=>{const t=o.buttonVariable===m;if("URL"===o.type)return e(k,{variableListIndex:n,disableEdit:t,CTAoptions:null==U?void 0:U.CTAoptions,button:o,currentVariableList:null!=Me&&Me>-1?Object.assign({},Ee.cards[Me]):Object.assign({},Ee),updateSelectedURLTemplateBtn:Ze},`${n}_${Me}`)})),Ve===c.CHATBOT&&(null===(ae=null===(le=we[0])||void 0===le?void 0:le.component)||void 0===ae?void 0:ae.buttons)&&(null===(re=null===(de=null===(se=we[0])||void 0===se?void 0:se.component)||void 0===de?void 0:de.buttons)||void 0===re?void 0:re.length)>0&&e(j,{backTrackMessage:null===(pe=null==Be?void 0:Be.backTrackExtra)||void 0===pe?void 0:pe[0],setBackTrackMessage:null===(ue=null==Be?void 0:Be.backTrackExtra)||void 0===ue?void 0:ue[1]}),(null===(me=null===(ve=null!=Me&&Me>-1?null===(ce=Ee.cards[Me])||void 0===ce?void 0:ce.buttons:null==Ee?void 0:Ee.buttons)||void 0===ve?void 0:ve.filter((e=>"QUICK_REPLY"===e.type)))||void 0===me?void 0:me.length)>0&&(Ve!==c.CHATBOT?e(M,{headerText:"Edit buttons",subText:"Edit the chatflows triggered on clicking the buttons",toolTipInfo:"There is an option to trigger chatflows through the buttons which can keep the user engaged"}):e(j,{backTrackMessage:null===(be=null==Be?void 0:Be.backTrackExtra)||void 0===be?void 0:be[0],setBackTrackMessage:null===(ge=null==Be?void 0:Be.backTrackExtra)||void 0===ge?void 0:ge[1]})),null===(je=null===(he=null!=Me&&Me>-1?null===(fe=Ee.cards[Me])||void 0===fe?void 0:fe.buttons:null==Ee?void 0:Ee.buttons)||void 0===he?void 0:he.filter((e=>"QUICK_REPLY"===e.type)))||void 0===je?void 0:je.map(((o,n)=>{if("QUICK_REPLY"===o.type&&Ve!==c.CHATBOT)return e(k,{variableListIndex:n,QRBoptions:null==U?void 0:U.QRBoptions,button:o,currentVariableList:null!=Me&&Me>-1?Object.assign({},Ee.cards[Me]):Object.assign({},Ee),updateSelectedQRBTemplateBtn:eo},`${n}_${Me}`)})),Ve===c.CHATBOT&&He&&e(C,{discountCode:null===(Ce=null==Be?void 0:Be.discountCodeExtra)||void 0===Ce?void 0:Ce[0],setDiscountCode:null===(Oe=null==Be?void 0:Be.discountCodeExtra)||void 0===Oe?void 0:Oe[1]}),null===(xe=null!=Me&&Me>-1?null===(Te=Ee.cards[Me])||void 0===Te?void 0:Te.buttons:null==Ee?void 0:Ee.buttons)||void 0===xe?void 0:xe.map(((o,t)=>{var i,l,a,s,d;if("COPY_CODE"===o.type)return e(n,{children:Ie?e("div",Object.assign({style:{marginBottom:20,borderRadius:4,padding:"8px 10px"}},{children:e(r,{state:"disabled",labelText:null!==(i=o.text)&&void 0!==i?i:"Copy Code",value:null!==(l=o.buttonVariable)&&void 0!==l?l:"",onChangeText:()=>{}})})):e(E,{index:t,variable:{variableName:null!==(a=o.text)&&void 0!==a?a:"Copy Code",updatedValue:null!==(s=o.buttonVariable)&&void 0!==s?s:"",type:"string",isEditableVariable:!0,index:null!==(d=o.index)&&void 0!==d?d:0},showVariableModal:!0,componentType:"BUTTONS",buttonType:o.type},t)})}))]}))},L=d.div`
2
2
  padding-top: 24px;
3
3
  padding-left: 10px;
4
4
  padding-right: 10px;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bikdotai/bik-component-library",
3
- "version": "0.0.628-beta.20",
3
+ "version": "0.0.629-beta.20",
4
4
  "description": "Bik Component Library",
5
5
  "repository": {
6
6
  "type": "git",