@bikdotai/bik-component-library 0.0.612-beta-vsp.5 → 0.0.612-beta-vsp.7
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.
- package/dist/cjs/components/bik-layout/MockMenus.d.ts +1 -0
- package/dist/cjs/components/template-context-mapper/TemplateContextMapper.js +1 -1
- package/dist/cjs/components/template-context-mapper/modalElements/EditWhatsAppTemplateV2.js +2 -2
- package/dist/esm/components/bik-layout/MockMenus.d.ts +1 -0
- package/dist/esm/components/template-context-mapper/TemplateContextMapper.js +1 -1
- package/dist/esm/components/template-context-mapper/modalElements/EditWhatsAppTemplateV2.js +1 -1
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),t=require("lodash"),l=require("react"),o=require("../../utils/StringUtils.js"),a=require("../../constants/Theme.js"),i=require("../modals/styledModal.js"),r=require("../template-preview/models/Channels.js"),s=require("../template-preview/models/WhatsAppTemplate.js"),n=require("./context/templateModalContext.js"),d=require("./modalElements/Footer.js"),u=require("./modalElements/TemplateSelectModalContent.js"),c=require("./utils/convertPlaceholdersToBikDropdown.js");exports.TemplateContextMapper=
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),t=require("lodash"),l=require("react"),o=require("../../utils/StringUtils.js"),a=require("../../constants/Theme.js"),i=require("../modals/styledModal.js"),r=require("../template-preview/models/Channels.js"),s=require("../template-preview/models/WhatsAppTemplate.js"),n=require("./context/templateModalContext.js"),d=require("./modalElements/Footer.js"),u=require("./modalElements/TemplateSelectModalContent.js"),c=require("./utils/convertPlaceholdersToBikDropdown.js"),p=require("./utils/validateName.js");exports.TemplateContextMapper=v=>{var m,C,h,b,E,S,x,P;const{selectedTemplate:f,closeDialog:T,showVariableMapping:g,channel:y,htmlContent:D,templateVariables:I,onTemplateSelect:L,globalPlaceholders:j,showOnlyContent:N,whatsappSpecificPickerMeta:w,zIndex:k,showVariableModal:V,variableList:A,discountCode:H,setDiscountCode:M,onBackPress:O,enabledCustomText:q,variableListForImage:B,showSampleValues:F,disableEditVariable:_,pod:W,extras:Y,pickerConf:R,selectedCarouselProducts:U,disableEditExpiry:z,cardWidth:$,onDeleteSelectedProducts:G,fileName:J,setFileName:K,hideDeviceContainerInPreview:Q,maxCharLimit:X,onDefaultVariableSelect:Z,skipDefaultVariableContent:ee,disableDatePicker:te,disableCopyCode:le,initialExpiryDateTime:oe,showDiscountCodeExpiryInfo:ae}=v;l.useEffect((()=>{pe(D)}),[D]);const ie=y===r.CHANNEL_TYPE.WHATSAPP&&"CAROUSEL"===(null===(C=null===(m=null==f?void 0:f.components)||void 0===m?void 0:m[1])||void 0===C?void 0:C.type),re=null==f?void 0:f.isProductCarouselType,[se,ne]=l.useState(y===r.CHANNEL_TYPE.EMAIL||y==r.CHANNEL_TYPE.WEBPUSH||ie?"desktop":"mobile"),[de,ue]=l.useState(!1),[ce,pe]=l.useState(D),[ve,me]=l.useState(!1),[Ce,he]=l.useState([]),[be,Ee]=l.useState({}),[Se,xe]=l.useState(f),[Pe,fe]=l.useState([]),[Te,ge]=l.useState(null),[ye,De]=l.useState(!1),[Ie,Le]=l.useState(null!=I?I:[]),[je,Ne]=l.useState(!1),[we,ke]=l.useState(ie?(null===(b=null===(h=null==Se?void 0:Se.mapping)||void 0===h?void 0:h.body)||void 0===b?void 0:b.length)?-1:0:-1),[Ve,Ae]=l.useState([]),[He,Me]=l.useState(void 0),Oe=l.useRef(null),[qe,Be]=l.useState(!1),[Fe,_e]=l.useState(!1),[We,Ye]=l.useState(!1),[Re,Ue]=l.useState({});l.useEffect((()=>{U?Ae(U):re&&Ae([])}),[U]),l.useEffect((()=>{var e;if(!ye&&re&&(!U||0===Ae.length)){const t=null===(e=null==Se?void 0:Se.components)||void 0===e?void 0:e[1].cards,l=[];null==t||t.forEach((e=>{var t;null===(t=null==e?void 0:e.components)||void 0===t||t.forEach((e=>{var t,o,a;"HEADER"===e.type&&l.push(null!==(a=null===(o=null===(t=e.example)||void 0===t?void 0:t.header_handle)||void 0===o?void 0:o[0])&&void 0!==a?a:"")}))})),fe(l),De(!0)}}),[ye]);const ze=l.useMemo((()=>c.convertPlaceholdersToBikDropdown(j)),[j]);return l.useEffect((()=>{Me(t.cloneDeep(A))}),[A]),e.jsx(n.TemplateModalContext.Provider,Object.assign({value:{hideFooterButton:We,setHideFooterButton:Ye,hideCrossButton:Fe,setHideCrossButton:_e,variableList:He,setVariableList:Me,variableCallback:Te,setVariableCallback:ge,showVariablePicker:de,setShowVariablePicker:ue,template:Se,setTemplate:xe,device:se,setDevice:ne,display_content:ce,setDisplayContent:pe,originalVariableList:Ie,setOriginalVariableList:Le,isError:ve,setIsError:me,channel:y,globalNormalizedPlaceholders:ze,templateSelectionTriggered:je,setTemplateSelectionTriggered:Ne,enabledCustomText:q,disableEditVariable:_,pod:W,extras:Y,isWhatsappCarousel:ie,selectedCarouselIndex:we,setSelectedCarouselIndex:ke,isProductCarouselType:re,templateErrorIndexes:be,cardCount:ie?null===(S=null===(E=f.components)||void 0===E?void 0:E[1].cards)||void 0===S?void 0:S.length:void 0,errorIndexes:Ce,setErrorIndexes:he,pickerConf:R,carouselProducts:Ve,setCarouselProducts:Ae,disableEditExpiry:z,cardWidth:$,cardImages:Pe,onDeleteSelectedProducts:G,hideDeviceContainerInPreview:Q,sliderRef:Oe,isCarouselHovered:qe,setIsCarouselHovered:Be,maxCharLimit:X,ctaOptionsErrors:Re,setCtaOptionsErrors:Ue,onDefaultVariableSelect:Z,disableDatePicker:te,disableCopyCode:le,initialExpiryDateTime:oe,showDiscountCodeExpiryInfo:ae}},{children:N?e.jsx(u.default,{variableListFromProps:A,channel:r.CHANNEL_TYPE.EMAIL,hideHeader:!0}):e.jsxs(i.StyledModal,Object.assign({hideCrossButton:Fe,zIndex:k,centralContainerStyles:{width:ie?900:y===r.CHANNEL_TYPE.EMAIL&&g?1e3:800},open:!0,onClose:()=>{null==T||T()},headingTitle:null==Se?void 0:Se.label,headingSubtitle:y===r.CHANNEL_TYPE.WHATSAPP?`${o.default.capitaliseFirstLetterOfString(null!==(x=null==Se?void 0:Se.category)&&void 0!==x?x:"")} • ${null!==(P=null==Se?void 0:Se.templateCategory)&&void 0!==P?P:""}`:"",onBackPress:()=>{null==O||O()},modalHeaderStyles:{borderBottom:`1px solid ${a.COLORS.stroke.primary}`}},{children:[e.jsx(u.default,{variableListFromProps:A,showSampleValues:F,showVariableMapping:g,channel:y,whatsappSpecificPickerMeta:w,showVariableModal:V,discountCode:H,setDiscountCode:M,variableListForImage:B&&(null==B?void 0:B.length)>0?B:He,fileName:J,setFileName:e=>{null==K||K(e)},skipDefaultVariableContent:ee}),L?e.jsx(d.default,{isWhatsappCarousel:null!=ie&&ie,onSelect:function(){var e,t,l;if((null==Ve?void 0:Ve.length)<1&&re)return void me(!0);if(Object.keys(Re).length>0&&W!==s.POD.CHATBOT)return void me(!0);if(W===s.POD.CHATBOT){const l=null!==(t=null===(e=null==Se?void 0:Se.components)||void 0===e?void 0:e.some((e=>"DOCUMENT"===e.format)))&&void 0!==t&&t;if(console.log(J,p.validateInputName(null!=J?J:"",W)),l&&!p.validateInputName(null!=J?J:"",W))return void me(!0)}const o=null==L?void 0:L(Se,Ie,null!=ce?ce:"",Ve);Ee(null!==(l=null==o?void 0:o.templateErrorIndexes)&&void 0!==l?l:{body:[],buttons:[]}),(null==o?void 0:o.errorIndexes)||(null==o?void 0:o.error)?((null==o?void 0:o.errorIndexes)&&he(o.errorIndexes),(null==o?void 0:o.error)&&me(!!(null==o?void 0:o.error))):Ne(!0)}}):e.jsx(e.Fragment,{})]}))}))};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime");require("../../curtain/CurtainHelper.js");var n=require("../../variable-picker-v3/model.js"),t=require("lodash"),o=require("react"),i=require("styled-components"),l=require("../../input/Input.js"),a=require("../../input-with-vars/InputWithVariables.js"),s=require("../../template-preview/models/TemplateMeta.js"),d=require("../../template-preview/models/WhatsAppTemplate.js"),r=require("../context/templateModalContext.js"),u=require("../utils/constants.js"),p=require("../utils/getDataFromTemplateComponent.js"),c=require("../utils/validateIsUrl.js"),v=require("../utils/validateName.js"),m=require("./BackTrackComponent.js"),b=require("./DiscountCodeComponent.js"),g=require("./EditMediaModal.js"),h=require("./EditMediaV2.js"),j=require("./EditMediaV2.style.js"),f=require("./useEditWhtasappTemplateMedia.js"),C=require("./VariableConnector.js"),T=require("./VariableConnectorsPanel.js"),
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime");require("../../curtain/CurtainHelper.js");var n=require("../../variable-picker-v3/model.js"),t=require("lodash"),o=require("react"),i=require("styled-components"),l=require("../../input/Input.js"),a=require("../../input-with-vars/InputWithVariables.js"),s=require("../../template-preview/models/TemplateMeta.js"),d=require("../../template-preview/models/WhatsAppTemplate.js"),r=require("../context/templateModalContext.js"),u=require("../utils/constants.js"),p=require("../utils/getDataFromTemplateComponent.js"),c=require("../utils/validateIsUrl.js"),v=require("../utils/validateName.js"),m=require("./BackTrackComponent.js"),b=require("./DiscountCodeComponent.js"),g=require("./EditMediaModal.js"),h=require("./EditMediaV2.js"),j=require("./EditMediaV2.style.js"),f=require("./useEditWhtasappTemplateMedia.js"),C=require("./VariableConnector.js"),T=require("./VariableConnectorsPanel.js"),O=require("./VariableConnectorWhatsApp.js"),x=require("./VariableEditorHeader.js"),y=require("./WhatsAppTemplateCardButtonV2.js");function E(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}const V=E(i).default.div`
|
|
2
2
|
padding-top: 24px;
|
|
3
3
|
padding-left: 10px;
|
|
4
4
|
padding-right: 10px;
|
|
5
5
|
margin-bottom: 8px;
|
|
6
6
|
line-height: normal;
|
|
7
|
-
`;exports.default=i=>{let{template:E,onTemplateChange:B,whatsappSpecificPickerMeta:M,showVariableModal:k,variableListForImage:D,setDiscountCode:I,fileName:q,setFileName:R}=i;var L,P,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,je;const fe=E.isCarouselType,{originalVariableList:Ce,pod:Te,extras:xe,selectedCarouselIndex:Oe,isProductCarouselType:ye,disableCopyCode:Ee}=r.useTemplateModalContext(),{descriptionComponents:Ve,urlBtns:Be,qrbBtns:Me,imageComponent:ke,bodyVariables:De,headerVariables:Ie}=p.getAllDataFromTemplateComponent(E),qe=o.useRef(null),[Re,Le]=o.useState(!1),[Pe,Ae]=o.useState(-1===Oe?{descriptionComponents:Ve,urlBtns:Be,qrbBtns:Me,imageComponent:ke,bodyVariables:De,headerVariables:Ie}:{}),{uploadMediaLink:Ue,uploadMediaFiles:we,validateMimeType:Ne}=M,_e=f.useEditWhatsappTemplateMedia({uploadMediaLink:Ue,uploadMediaFiles:we,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=E.components[1])||void 0===o?void 0:o.cards)||void 0===i?void 0:i[Oe].components,mapping:null===(a=null===(l=null==E?void 0:E.mapping)||void 0===l?void 0:l.cards)||void 0===a?void 0:a[Oe]}:Object.assign({},E);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(E);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)),Se(!0)}else null==B||B(Object.assign({},p))},validateMimeType:Ne,mediaComponent:fe?Pe.imageComponent:ke,fileRef:qe}),[He,Se]=o.useState(!1),[Fe,Qe]=o.useState(q),[Ye,We]=o.useState();function Ke(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({},E).components[1].cards)||void 0===i?void 0:i[Oe].components,mapping:null===(l=Object.assign({},E).mapping.cards)||void 0===l?void 0:l[Oe]}:Object.assign({},E),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&&ye){const n=Object.assign({},E).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({},E).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(E);return l.components=n,l.mapping.cards=i,void(null==B||B(Object.assign({},l)))}const j=null==b?void 0:b.components.findIndex((e=>"BUTTONS"===e.type));if(void 0!==j&&j>-1){const t=null===(d=null==b?void 0:b.components[j].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[j])||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[j]),{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[j]=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(E);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 $e(e,n,o){var i,l,a,s,d,r,u;const p=null!=Oe&&Oe>-1?{components:null===(i=Object.assign({},E).components[1].cards)||void 0===i?void 0:i[Oe].components,mapping:null===(l=Object.assign({},E).mapping.cards)||void 0===l?void 0:l[Oe]}:Object.assign({},E);if(null!=Oe&&Oe>-1&&ye){const n=Object.assign({},E).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(E);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(E);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=E.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("")}}),[E]),o.useEffect((()=>{var e,n,t,o;if(null!=Oe&&Oe>-1){const i={components:null===(n=null===(e=E.components[1])||void 0===e?void 0:e.cards)||void 0===n?void 0:n[Oe].components,mapping:null===(o=null===(t=null==E?void 0:E.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);Ae({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(E);Ae({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&&He){const i={components:null===(n=null===(e=E.components[1])||void 0===e?void 0:e.cards)||void 0===n?void 0:n[Oe].components,mapping:null===(o=null===(t=null==E?void 0:E.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);Ae({descriptionComponents:l,urlBtns:a,qrbBtns:s,imageComponent:d,bodyVariables:r,headerVariables:u}),Se(!1)}}),[He]);const Ge=()=>{if(!Fe)return null==R||R(""),void We("PDF name is Required");const e=v.validateInputName(null!=Fe?Fe:"",Te);null==R||R(Fe),We(e?"Please enter a valid PDF name":void 0)},Xe=fe?Pe.imageComponent:ke;return _e.openEditMedia?e.jsx(T.Container,Object.assign({style:{flexDirection:"column",width:400,maxHeight:460}},{children:e.jsx(g.default,{mediaComponentFormat:null!==(L=Xe.format)&&void 0!==L?L:s.HEADER_TYPES.IMAGE,uploadMedia:_e.uploadMedia,variableListForImage:D||[],useEditWhatsappTemplateMediaResponse:_e,setOpenEditMedia:_e.setOpenEditMedia,openEditMedia:_e.openEditMedia,editIconRef:_e.editIconRef,fileRef:qe})})):e.jsxs(T.Container,Object.assign({style:{flexDirection:"column",width:400,maxHeight:460,minWidth:ye?"420px":"auto"}},{children:[!!Pe.imageComponent&&!ye&&e.jsxs(j.EditTemplateMediaContainer,{children:[e.jsx(h.default,{imageName:null!==(A=null===(P=null==Xe?void 0:Xe.example)||void 0===P?void 0:P.header_handle)&&void 0!==A?A:[],handleImageChange:_e.handleImageChange,mediaType:null==Xe?void 0:Xe.format,error:_e.error,isLoading:_e.loading,setOpenEditMedia:_e.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==E?void 0:E.mapping)||void 0===S?void 0:S.header)||void 0===F?void 0:F[0])?null===(Y=null===(Q=null==E?void 0:E.mapping)||void 0===Q?void 0:Q.header)||void 0===Y?void 0:Y[0]:_e.selectedVariable}),(null==ke?void 0:ke.format)==s.HEADER_TYPES.DOCUMENT?e.jsxs(V,{children:["(pod === POD.CHATBOT ?(",e.jsx(a.InputWithVariables,{labelText:"PDF Name",placeHolder:"Enter the name",errorMessage:Ye||void 0,onBlur:Ge,onChange:e=>{We(""),Qe(null==e?void 0:e.actualValue)},pickerType:n.PickerType.EMBEDDED,noMaxCharCheck:!0,allowMix:!0,showVarHeader:!0,varHeaderText:"Select variable",prevVariable:{actualValue:null!=Fe?Fe:"",variableType:"string"},variablesList:D,showAddButton:Te===d.POD.CHATBOT}),") : (",e.jsx(l.Input,{labelText:"PDF Name",placeholder:"Enter the name",value:Fe,errorMessage:Ye||void 0,onBlur:Ge,onChangeText:e=>{We(""),Qe(e)}}),")"]}):e.jsx(e.Fragment,{})]}),(null===(W=Pe.bodyVariables)||void 0===W?void 0:W.length)>0&&e.jsx(O.default,{containerStyle:{paddingTop:Pe.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=Pe.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(y.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:Ke},`${t}_${Oe}`)})),Te===d.POD.CHATBOT&&(null===(ne=null===(ee=Me[0])||void 0===ee?void 0:ee.component)||void 0===ne?void 0:ne.buttons)&&(null===(ie=null===(oe=null===(te=Me[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(y.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:$e},`${t}_${Oe}`)})),Te===d.POD.CHATBOT&&Re&&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===(je=null!=Oe&&Oe>-1?null===(he=Ce.cards[Oe])||void 0===he?void 0:he.buttons:null==Ce?void 0:Ce.buttons)||void 0===je?void 0:je.map(((n,t)=>{var o,i,a,s,d;if("COPY_CODE"===n.type)return e.jsx(e.Fragment,{children:Ee?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:E,onTemplateChange:B,whatsappSpecificPickerMeta:M,showVariableModal:k,variableListForImage:D,setDiscountCode:I,fileName:q,setFileName:R}=i;var L,P,A,U,w,H,N,_,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,je;const fe=E.isCarouselType,{originalVariableList:Ce,pod:Te,extras:Oe,selectedCarouselIndex:xe,isProductCarouselType:ye,disableCopyCode:Ee}=r.useTemplateModalContext(),{descriptionComponents:Ve,urlBtns:Be,qrbBtns:Me,imageComponent:ke,bodyVariables:De,headerVariables:Ie}=p.getAllDataFromTemplateComponent(E),qe=o.useRef(null),[Re,Le]=o.useState(!1),[Pe,Ae]=o.useState(-1===xe?{descriptionComponents:Ve,urlBtns:Be,qrbBtns:Me,imageComponent:ke,bodyVariables:De,headerVariables:Ie}:{}),{uploadMediaLink:Ue,uploadMediaFiles:we,validateMimeType:He}=M,Ne=f.useEditWhatsappTemplateMedia({uploadMediaLink:Ue,uploadMediaFiles:we,updateTemplateImageUrl:function(e,n){var o,i,l,a,s,d,r,u;let p;p=null!=xe&&xe>-1?{components:null===(i=null===(o=E.components[1])||void 0===o?void 0:o.cards)||void 0===i?void 0:i[xe].components,mapping:null===(a=null===(l=null==E?void 0:E.mapping)||void 0===l?void 0:l.cards)||void 0===a?void 0:a[xe]}:Object.assign({},E);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!=xe&&xe>-1){const e=t.cloneDeep(E);e.components[1].cards[xe].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[xe]=null!==(u=p.mapping)&&void 0!==u?u:{}),null==B||B(Object.assign({},e)),Se(!0)}else null==B||B(Object.assign({},p))},validateMimeType:He,mediaComponent:fe?Pe.imageComponent:ke,fileRef:qe}),[_e,Se]=o.useState(!1),[Fe,Qe]=o.useState(q),[Ye,We]=o.useState();function Ke(e,n,o){var i,l,a,s,d,r,u,p,c,v;const m=null!=xe&&xe>-1?{components:null===(i=Object.assign({},E).components[1].cards)||void 0===i?void 0:i[xe].components,mapping:null===(l=Object.assign({},E).mapping.cards)||void 0===l?void 0:l[xe]}:Object.assign({},E),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!=xe&&xe>-1&&ye){const n=Object.assign({},E).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({},E).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(E);return l.components=n,l.mapping.cards=i,void(null==B||B(Object.assign({},l)))}const j=null==b?void 0:b.components.findIndex((e=>"BUTTONS"===e.type));if(void 0!==j&&j>-1){const t=null===(d=null==b?void 0:b.components[j].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[j])||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[j]),{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[j]=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!=xe&&xe>-1){const e=t.cloneDeep(E);e.components[1].cards[xe].components=b.components,e.mapping.cards[xe]=b.mapping,null==B||B(Object.assign({},e))}else null==B||B(b)}function $e(e,n,o){var i,l,a,s,d,r,u;const p=null!=xe&&xe>-1?{components:null===(i=Object.assign({},E).components[1].cards)||void 0===i?void 0:i[xe].components,mapping:null===(l=Object.assign({},E).mapping.cards)||void 0===l?void 0:l[xe]}:Object.assign({},E);if(null!=xe&&xe>-1&&ye){const n=Object.assign({},E).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(E);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!=xe&&xe>-1){const e=t.cloneDeep(E);e.components[1].cards[xe].components=p.components,null==B||B(Object.assign({},e))}else null==B||B(p)}o.useEffect((()=>{var e,n;if(null===(e=E.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==Oe?void 0:Oe.discountCodeExtra)||void 0===n?void 0:n[1];null==e||e("")}}),[E]),o.useEffect((()=>{var e,n,t,o;if(null!=xe&&xe>-1){const i={components:null===(n=null===(e=E.components[1])||void 0===e?void 0:e.cards)||void 0===n?void 0:n[xe].components,mapping:null===(o=null===(t=null==E?void 0:E.mapping)||void 0===t?void 0:t.cards)||void 0===o?void 0:o[xe]},{descriptionComponents:l,urlBtns:a,qrbBtns:s,imageComponent:d,bodyVariables:r,headerVariables:u}=p.getAllDataFromTemplateComponent(i);Ae({descriptionComponents:l,urlBtns:a,qrbBtns:s,imageComponent:d,bodyVariables:r,headerVariables:u})}else if(null!=xe&&-1===xe){const{descriptionComponents:e,urlBtns:n,qrbBtns:t,imageComponent:o,bodyVariables:i,headerVariables:l}=p.getAllDataFromTemplateComponent(E);Ae({descriptionComponents:e,urlBtns:n,qrbBtns:t,imageComponent:o,bodyVariables:i,headerVariables:l})}}),[xe]),o.useEffect((()=>{var e,n,t,o;if(null!=xe&&xe>-1&&_e){const i={components:null===(n=null===(e=E.components[1])||void 0===e?void 0:e.cards)||void 0===n?void 0:n[xe].components,mapping:null===(o=null===(t=null==E?void 0:E.mapping)||void 0===t?void 0:t.cards)||void 0===o?void 0:o[xe]},{descriptionComponents:l,urlBtns:a,qrbBtns:s,imageComponent:d,bodyVariables:r,headerVariables:u}=p.getAllDataFromTemplateComponent(i);Ae({descriptionComponents:l,urlBtns:a,qrbBtns:s,imageComponent:d,bodyVariables:r,headerVariables:u}),Se(!1)}}),[_e]);const Ge=()=>{if(!Fe)return null==R||R(""),void We("PDF name is Required");const e=v.validateInputName(null!=Fe?Fe:"",Te);null==R||R(Fe),We(e?"Please enter a valid PDF name":void 0)},Xe=fe?Pe.imageComponent:ke;return Ne.openEditMedia?e.jsx(T.Container,Object.assign({style:{flexDirection:"column",width:400,maxHeight:460}},{children:e.jsx(g.default,{mediaComponentFormat:null!==(L=Xe.format)&&void 0!==L?L:s.HEADER_TYPES.IMAGE,uploadMedia:Ne.uploadMedia,variableListForImage:D||[],useEditWhatsappTemplateMediaResponse:Ne,setOpenEditMedia:Ne.setOpenEditMedia,openEditMedia:Ne.openEditMedia,editIconRef:Ne.editIconRef,fileRef:qe})})):e.jsxs(T.Container,Object.assign({style:{flexDirection:"column",width:400,maxHeight:460,minWidth:ye?"420px":"auto"}},{children:[!!Pe.imageComponent&&!ye&&e.jsxs(j.EditTemplateMediaContainer,{children:[e.jsx(h.default,{imageName:null!==(A=null===(P=null==Xe?void 0:Xe.example)||void 0===P?void 0:P.header_handle)&&void 0!==A?A:[],handleImageChange:Ne.handleImageChange,mediaType:null==Xe?void 0:Xe.format,error:Ne.error,isLoading:Ne.loading,setOpenEditMedia:Ne.setOpenEditMedia,selectedVariable:c.isVariable(null!==(H=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!==H?H:"")?null===(_=null===(N=null==Xe?void 0:Xe.example)||void 0===N?void 0:N.header_handle)||void 0===_?void 0:_[0]:(null===(F=null===(S=null==E?void 0:E.mapping)||void 0===S?void 0:S.header)||void 0===F?void 0:F[0])?null===(Y=null===(Q=null==E?void 0:E.mapping)||void 0===Q?void 0:Q.header)||void 0===Y?void 0:Y[0]:Ne.selectedVariable}),(null==ke?void 0:ke.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:Ye||void 0,onBlur:Te!==d.POD.CHATBOT?Ge:void 0,onChange:e=>{We(""),Qe(null==e?void 0:e.actualValue)},pickerType:n.PickerType.EMBEDDED,noMaxCharCheck:!0,allowMix:!0,showVarHeader:!0,varHeaderText:"Select variable",prevVariable:{actualValue:null!=Fe?Fe:"",variableType:"string"},variablesList:D,showAddButton:Te===d.POD.CHATBOT}):e.jsx(l.Input,{labelText:"PDF Name",placeholder:"Enter the name",value:Fe,errorMessage:Ye||void 0,onBlur:Ge,onChangeText:e=>{We(""),Qe(e)}})}):e.jsx(e.Fragment,{})]}),(null===(W=Pe.bodyVariables)||void 0===W?void 0:W.length)>0&&e.jsx(x.default,{containerStyle:{paddingTop:Pe.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=Pe.descriptionComponents)||void 0===K?void 0:K.map(((n,t)=>e.jsx(O.default,{originalVariableList:null!=xe&&xe>-1?Ce.cards[xe]:Ce,type:n.type,descriptionComponent:n.component,showVariableModal:k},t))),(null===(X=null===(G=null!=xe&&xe>-1?null===($=Ce.cards[xe])||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(x.default,{headerText:"Edit buttons",subText:"Edit the link connected to the CTA button"}),null===(Z=null===(J=null!=xe&&xe>-1?null===(z=Ce.cards[xe])||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(y.default,{variableListIndex:t,disableEdit:o,CTAoptions:null==M?void 0:M.CTAoptions,button:n,currentVariableList:null!=xe&&xe>-1?Object.assign({},Ce.cards[xe]):Object.assign({},Ce),updateSelectedURLTemplateBtn:Ke},`${t}_${xe}`)})),Te===d.POD.CHATBOT&&(null===(ne=null===(ee=Me[0])||void 0===ee?void 0:ee.component)||void 0===ne?void 0:ne.buttons)&&(null===(ie=null===(oe=null===(te=Me[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==Oe?void 0:Oe.backTrackExtra)||void 0===le?void 0:le[0],setBackTrackMessage:null===(ae=null==Oe?void 0:Oe.backTrackExtra)||void 0===ae?void 0:ae[1]}),(null===(re=null===(de=null!=xe&&xe>-1?null===(se=Ce.cards[xe])||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(x.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==Oe?void 0:Oe.backTrackExtra)||void 0===ue?void 0:ue[0],setBackTrackMessage:null===(pe=null==Oe?void 0:Oe.backTrackExtra)||void 0===pe?void 0:pe[1]})),null===(me=null===(ve=null!=xe&&xe>-1?null===(ce=Ce.cards[xe])||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(y.default,{variableListIndex:t,QRBoptions:null==M?void 0:M.QRBoptions,button:n,currentVariableList:null!=xe&&xe>-1?Object.assign({},Ce.cards[xe]):Object.assign({},Ce),updateSelectedQRBTemplateBtn:$e},`${t}_${xe}`)})),Te===d.POD.CHATBOT&&Re&&e.jsx(b.DiscountCodeComponent,{discountCode:null===(be=null==Oe?void 0:Oe.discountCodeExtra)||void 0===be?void 0:be[0],setDiscountCode:null===(ge=null==Oe?void 0:Oe.discountCodeExtra)||void 0===ge?void 0:ge[1]}),null===(je=null!=xe&&xe>-1?null===(he=Ce.cards[xe])||void 0===he?void 0:he.buttons:null==Ce?void 0:Ce.buttons)||void 0===je?void 0:je.map(((n,t)=>{var o,i,a,s,d;if("COPY_CODE"===n.type)return e.jsx(e.Fragment,{children:Ee?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 +1 @@
|
|
|
1
|
-
import{jsx as e,jsxs as o,Fragment as l}from"react/jsx-runtime";import{cloneDeep as t}from"lodash";import{useEffect as i,useState as r,useRef as a,useMemo as s}from"react";import n from"../../utils/StringUtils.js";import{COLORS as d}from"../../constants/Theme.js";import{StyledModal as
|
|
1
|
+
import{jsx as e,jsxs as o,Fragment as l}from"react/jsx-runtime";import{cloneDeep as t}from"lodash";import{useEffect as i,useState as r,useRef as a,useMemo as s}from"react";import n from"../../utils/StringUtils.js";import{COLORS as d}from"../../constants/Theme.js";import{StyledModal as u}from"../modals/styledModal.js";import{CHANNEL_TYPE as c}from"../template-preview/models/Channels.js";import{POD as p}from"../template-preview/models/WhatsAppTemplate.js";import{TemplateModalContext as m}from"./context/templateModalContext.js";import v from"./modalElements/Footer.js";import h from"./modalElements/TemplateSelectModalContent.js";import{convertPlaceholdersToBikDropdown as C}from"./utils/convertPlaceholdersToBikDropdown.js";import{validateInputName as b}from"./utils/validateName.js";const f=f=>{var g,x,E,P,y,S,T,I;const{selectedTemplate:D,closeDialog:w,showVariableMapping:V,channel:k,htmlContent:L,templateVariables:j,onTemplateSelect:M,globalPlaceholders:A,showOnlyContent:B,whatsappSpecificPickerMeta:H,zIndex:O,showVariableModal:F,variableList:W,discountCode:N,setDiscountCode:U,onBackPress:z,enabledCustomText:R,variableListForImage:$,showSampleValues:_,disableEditVariable:q,pod:G,extras:J,pickerConf:K,selectedCarouselProducts:Q,disableEditExpiry:X,cardWidth:Y,onDeleteSelectedProducts:Z,fileName:ee,setFileName:oe,hideDeviceContainerInPreview:le,maxCharLimit:te,onDefaultVariableSelect:ie,skipDefaultVariableContent:re,disableDatePicker:ae,disableCopyCode:se,initialExpiryDateTime:ne,showDiscountCodeExpiryInfo:de}=f;i((()=>{be(L)}),[L]);const ue=k===c.WHATSAPP&&"CAROUSEL"===(null===(x=null===(g=null==D?void 0:D.components)||void 0===g?void 0:g[1])||void 0===x?void 0:x.type),ce=null==D?void 0:D.isProductCarouselType,[pe,me]=r(k===c.EMAIL||k==c.WEBPUSH||ue?"desktop":"mobile"),[ve,he]=r(!1),[Ce,be]=r(L),[fe,ge]=r(!1),[xe,Ee]=r([]),[Pe,ye]=r({}),[Se,Te]=r(D),[Ie,De]=r([]),[we,Ve]=r(null),[ke,Le]=r(!1),[je,Me]=r(null!=j?j:[]),[Ae,Be]=r(!1),[He,Oe]=r(ue?(null===(P=null===(E=null==Se?void 0:Se.mapping)||void 0===E?void 0:E.body)||void 0===P?void 0:P.length)?-1:0:-1),[Fe,We]=r([]),[Ne,Ue]=r(void 0),ze=a(null),[Re,$e]=r(!1),[_e,qe]=r(!1),[Ge,Je]=r(!1),[Ke,Qe]=r({});i((()=>{Q?We(Q):ce&&We([])}),[Q]),i((()=>{var e;if(!ke&&ce&&(!Q||0===We.length)){const o=null===(e=null==Se?void 0:Se.components)||void 0===e?void 0:e[1].cards,l=[];null==o||o.forEach((e=>{var o;null===(o=null==e?void 0:e.components)||void 0===o||o.forEach((e=>{var o,t,i;"HEADER"===e.type&&l.push(null!==(i=null===(t=null===(o=e.example)||void 0===o?void 0:o.header_handle)||void 0===t?void 0:t[0])&&void 0!==i?i:"")}))})),De(l),Le(!0)}}),[ke]);const Xe=s((()=>C(A)),[A]);return i((()=>{Ue(t(W))}),[W]),e(m.Provider,Object.assign({value:{hideFooterButton:Ge,setHideFooterButton:Je,hideCrossButton:_e,setHideCrossButton:qe,variableList:Ne,setVariableList:Ue,variableCallback:we,setVariableCallback:Ve,showVariablePicker:ve,setShowVariablePicker:he,template:Se,setTemplate:Te,device:pe,setDevice:me,display_content:Ce,setDisplayContent:be,originalVariableList:je,setOriginalVariableList:Me,isError:fe,setIsError:ge,channel:k,globalNormalizedPlaceholders:Xe,templateSelectionTriggered:Ae,setTemplateSelectionTriggered:Be,enabledCustomText:R,disableEditVariable:q,pod:G,extras:J,isWhatsappCarousel:ue,selectedCarouselIndex:He,setSelectedCarouselIndex:Oe,isProductCarouselType:ce,templateErrorIndexes:Pe,cardCount:ue?null===(S=null===(y=D.components)||void 0===y?void 0:y[1].cards)||void 0===S?void 0:S.length:void 0,errorIndexes:xe,setErrorIndexes:Ee,pickerConf:K,carouselProducts:Fe,setCarouselProducts:We,disableEditExpiry:X,cardWidth:Y,cardImages:Ie,onDeleteSelectedProducts:Z,hideDeviceContainerInPreview:le,sliderRef:ze,isCarouselHovered:Re,setIsCarouselHovered:$e,maxCharLimit:te,ctaOptionsErrors:Ke,setCtaOptionsErrors:Qe,onDefaultVariableSelect:ie,disableDatePicker:ae,disableCopyCode:se,initialExpiryDateTime:ne,showDiscountCodeExpiryInfo:de}},{children:B?e(h,{variableListFromProps:W,channel:c.EMAIL,hideHeader:!0}):o(u,Object.assign({hideCrossButton:_e,zIndex:O,centralContainerStyles:{width:ue?900:k===c.EMAIL&&V?1e3:800},open:!0,onClose:()=>{null==w||w()},headingTitle:null==Se?void 0:Se.label,headingSubtitle:k===c.WHATSAPP?`${n.capitaliseFirstLetterOfString(null!==(T=null==Se?void 0:Se.category)&&void 0!==T?T:"")} • ${null!==(I=null==Se?void 0:Se.templateCategory)&&void 0!==I?I:""}`:"",onBackPress:()=>{null==z||z()},modalHeaderStyles:{borderBottom:`1px solid ${d.stroke.primary}`}},{children:[e(h,{variableListFromProps:W,showSampleValues:_,showVariableMapping:V,channel:k,whatsappSpecificPickerMeta:H,showVariableModal:F,discountCode:N,setDiscountCode:U,variableListForImage:$&&(null==$?void 0:$.length)>0?$:Ne,fileName:ee,setFileName:e=>{null==oe||oe(e)},skipDefaultVariableContent:re}),M?e(v,{isWhatsappCarousel:null!=ue&&ue,onSelect:function(){var e,o,l;if((null==Fe?void 0:Fe.length)<1&&ce)return void ge(!0);if(Object.keys(Ke).length>0&&G!==p.CHATBOT)return void ge(!0);if(G===p.CHATBOT){const l=null!==(o=null===(e=null==Se?void 0:Se.components)||void 0===e?void 0:e.some((e=>"DOCUMENT"===e.format)))&&void 0!==o&&o;if(console.log(ee,b(null!=ee?ee:"",G)),l&&!b(null!=ee?ee:"",G))return void ge(!0)}const t=null==M?void 0:M(Se,je,null!=Ce?Ce:"",Fe);ye(null!==(l=null==t?void 0:t.templateErrorIndexes)&&void 0!==l?l:{body:[],buttons:[]}),(null==t?void 0:t.errorIndexes)||(null==t?void 0:t.error)?((null==t?void 0:t.errorIndexes)&&Ee(t.errorIndexes),(null==t?void 0:t.error)&&ge(!!(null==t?void 0:t.error))):Be(!0)}}):e(l,{})]}))}))};export{f as TemplateContextMapper};
|
|
@@ -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}from"../utils/validateName.js";import{BackTrackComponent as h}from"./BackTrackComponent.js";import{DiscountCodeComponent as j}from"./DiscountCodeComponent.js";import O from"./EditMediaModal.js";import C from"./EditMediaV2.js";import{EditTemplateMediaContainer as T}from"./EditMediaV2.style.js";import{useEditWhatsappTemplateMedia as x}from"./useEditWhtasappTemplateMedia.js";import y from"./VariableConnector.js";import{Container as E}from"./VariableConnectorsPanel.js";import V from"./VariableConnectorWhatsApp.js";import B from"./VariableEditorHeader.js";import M from"./WhatsAppTemplateCardButtonV2.js";const k=d=>{let{template:k,onTemplateChange:L,whatsappSpecificPickerMeta:R,showVariableModal:U,variableListForImage:w,setDiscountCode:N,fileName:P,setFileName:A}=d;var H,D,_,S,F,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,Oe,Ce,Te;const xe=k.isCarouselType,{originalVariableList:ye,pod:Ee,extras:Ve,selectedCarouselIndex:Be,isProductCarouselType:Me,disableCopyCode:ke}=v(),{descriptionComponents:Ie,urlBtns:Le,qrbBtns:Re,imageComponent:Ue,bodyVariables:we,headerVariables:Ne}=b(k),Pe=l(null),[Ae,He]=a(!1),[De,_e]=a(-1===Be?{descriptionComponents:Ie,urlBtns:Le,qrbBtns:Re,imageComponent:Ue,bodyVariables:we,headerVariables:Ne}:{}),{uploadMediaLink:Se,uploadMediaFiles:Fe,validateMimeType:Qe}=R,qe=x({uploadMediaLink:Se,uploadMediaFiles:Fe,updateTemplateImageUrl:function(e,o){var n,t,l,a,s,d,r,p;let u;u=null!=Be&&Be>-1?{components:null===(t=null===(n=k.components[1])||void 0===n?void 0:n.cards)||void 0===t?void 0:t[Be].components,mapping:null===(a=null===(l=null==k?void 0:k.mapping)||void 0===l?void 0:l.cards)||void 0===a?void 0:a[Be]}:Object.assign({},k);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!=Be&&Be>-1){const e=i(k);e.components[1].cards[Be].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[Be]=null!==(p=u.mapping)&&void 0!==p?p:{}),null==L||L(Object.assign({},e)),Ke(!0)}else null==L||L(Object.assign({},u))},validateMimeType:Qe,mediaComponent:xe?De.imageComponent:Ue,fileRef:Pe}),[Ye,Ke]=a(!1),[We,$e]=a(P),[Ge,Xe]=a();function ze(e,o,n){var t,l,a,s,d,r,p,u,c,v;const m=null!=Be&&Be>-1?{components:null===(t=Object.assign({},k).components[1].cards)||void 0===t?void 0:t[Be].components,mapping:null===(l=Object.assign({},k).mapping.cards)||void 0===l?void 0:l[Be]}:Object.assign({},k),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!=Be&&Be>-1&&Me){const o=Object.assign({},k).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({},k).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(k);return l.components=o,l.mapping.cards=t,void(null==L||L(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))?He(!0):(He(!1),null==N||N(""))}if(null!=Be&&Be>-1){const e=i(k);e.components[1].cards[Be].components=b.components,e.mapping.cards[Be]=b.mapping,null==L||L(Object.assign({},e))}else null==L||L(b)}function Je(e,o,n){var t,l,a,s,d,r,p;const u=null!=Be&&Be>-1?{components:null===(t=Object.assign({},k).components[1].cards)||void 0===t?void 0:t[Be].components,mapping:null===(l=Object.assign({},k).mapping.cards)||void 0===l?void 0:l[Be]}:Object.assign({},k);if(null!=Be&&Be>-1&&Me){const o=Object.assign({},k).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(k);return t.components=o,void(null==L||L(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!=Be&&Be>-1){const e=i(k);e.components[1].cards[Be].components=u.components,null==L||L(Object.assign({},e))}else null==L||L(u)}s((()=>{var e,o;if(null===(e=k.mapping.buttons)||void 0===e?void 0:e.find((e=>"checkout.checkoutUrl"===e.slice(2,-2))))He(!0);else{He(!1);const e=null===(o=null==Ve?void 0:Ve.discountCodeExtra)||void 0===o?void 0:o[1];null==e||e("")}}),[k]),s((()=>{var e,o,n,t;if(null!=Be&&Be>-1){const i={components:null===(o=null===(e=k.components[1])||void 0===e?void 0:e.cards)||void 0===o?void 0:o[Be].components,mapping:null===(t=null===(n=null==k?void 0:k.mapping)||void 0===n?void 0:n.cards)||void 0===t?void 0:t[Be]},{descriptionComponents:l,urlBtns:a,qrbBtns:s,imageComponent:d,bodyVariables:r,headerVariables:p}=b(i);_e({descriptionComponents:l,urlBtns:a,qrbBtns:s,imageComponent:d,bodyVariables:r,headerVariables:p})}else if(null!=Be&&-1===Be){const{descriptionComponents:e,urlBtns:o,qrbBtns:n,imageComponent:t,bodyVariables:i,headerVariables:l}=b(k);_e({descriptionComponents:e,urlBtns:o,qrbBtns:n,imageComponent:t,bodyVariables:i,headerVariables:l})}}),[Be]),s((()=>{var e,o,n,t;if(null!=Be&&Be>-1&&Ye){const i={components:null===(o=null===(e=k.components[1])||void 0===e?void 0:e.cards)||void 0===o?void 0:o[Be].components,mapping:null===(t=null===(n=null==k?void 0:k.mapping)||void 0===n?void 0:n.cards)||void 0===t?void 0:t[Be]},{descriptionComponents:l,urlBtns:a,qrbBtns:s,imageComponent:d,bodyVariables:r,headerVariables:p}=b(i);_e({descriptionComponents:l,urlBtns:a,qrbBtns:s,imageComponent:d,bodyVariables:r,headerVariables:p}),Ke(!1)}}),[Ye]);const Ze=()=>{if(!We)return null==A||A(""),void Xe("PDF name is Required");const e=f(null!=We?We:"",Ee);null==A||A(We),Xe(e?"Please enter a valid PDF name":void 0)},eo=xe?De.imageComponent:Ue;return qe.openEditMedia?e(E,Object.assign({style:{flexDirection:"column",width:400,maxHeight:460}},{children:e(O,{mediaComponentFormat:null!==(H=eo.format)&&void 0!==H?H:u.IMAGE,uploadMedia:qe.uploadMedia,variableListForImage:w||[],useEditWhatsappTemplateMediaResponse:qe,setOpenEditMedia:qe.setOpenEditMedia,openEditMedia:qe.openEditMedia,editIconRef:qe.editIconRef,fileRef:Pe})})):o(E,Object.assign({style:{flexDirection:"column",width:400,maxHeight:460,minWidth:Me?"420px":"auto"}},{children:[!!De.imageComponent&&!Me&&o(T,{children:[e(C,{imageName:null!==(_=null===(D=null==eo?void 0:eo.example)||void 0===D?void 0:D.header_handle)&&void 0!==_?_:[],handleImageChange:qe.handleImageChange,mediaType:null==eo?void 0:eo.format,error:qe.error,isLoading:qe.loading,setOpenEditMedia:qe.setOpenEditMedia,selectedVariable:g(null!==(Q=null===(F=null===(S=null==eo?void 0:eo.example)||void 0===S?void 0:S.header_handle)||void 0===F?void 0:F[0])&&void 0!==Q?Q:"")?null===(Y=null===(q=null==eo?void 0:eo.example)||void 0===q?void 0:q.header_handle)||void 0===Y?void 0:Y[0]:(null===(W=null===(K=null==k?void 0:k.mapping)||void 0===K?void 0:K.header)||void 0===W?void 0:W[0])?null===(G=null===($=null==k?void 0:k.mapping)||void 0===$?void 0:$.header)||void 0===G?void 0:G[0]:qe.selectedVariable}),(null==Ue?void 0:Ue.format)==u.DOCUMENT?o(I,{children:["(pod === POD.CHATBOT ?(",e(p,{labelText:"PDF Name",placeHolder:"Enter the name",errorMessage:Ge||void 0,onBlur:Ze,onChange:e=>{Xe(""),$e(null==e?void 0:e.actualValue)},pickerType:t.EMBEDDED,noMaxCharCheck:!0,allowMix:!0,showVarHeader:!0,varHeaderText:"Select variable",prevVariable:{actualValue:null!=We?We:"",variableType:"string"},variablesList:w,showAddButton:Ee===c.CHATBOT}),") : (",e(r,{labelText:"PDF Name",placeholder:"Enter the name",value:We,errorMessage:Ge||void 0,onBlur:Ze,onChangeText:e=>{Xe(""),$e(e)}}),")"]}):e(n,{})]}),(null===(X=De.bodyVariables)||void 0===X?void 0:X.length)>0&&e(B,{containerStyle:{paddingTop:De.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===(z=De.descriptionComponents)||void 0===z?void 0:z.map(((o,n)=>e(V,{originalVariableList:null!=Be&&Be>-1?ye.cards[Be]:ye,type:o.type,descriptionComponent:o.component,showVariableModal:U},n))),(null===(ee=null===(Z=null!=Be&&Be>-1?null===(J=ye.cards[Be])||void 0===J?void 0:J.buttons:null==ye?void 0:ye.buttons)||void 0===Z?void 0:Z.filter((e=>"URL"===e.type)))||void 0===ee?void 0:ee.length)>0&&e(B,{headerText:"Edit buttons",subText:"Edit the link connected to the CTA button"}),null===(te=null===(ne=null!=Be&&Be>-1?null===(oe=ye.cards[Be])||void 0===oe?void 0:oe.buttons:null==ye?void 0:ye.buttons)||void 0===ne?void 0:ne.filter((e=>Ee===c.CHATBOT||"URL"===e.type)))||void 0===te?void 0:te.map(((o,n)=>{const t=o.buttonVariable===m;if("URL"===o.type)return e(M,{variableListIndex:n,disableEdit:t,CTAoptions:null==R?void 0:R.CTAoptions,button:o,currentVariableList:null!=Be&&Be>-1?Object.assign({},ye.cards[Be]):Object.assign({},ye),updateSelectedURLTemplateBtn:ze},`${n}_${Be}`)})),Ee===c.CHATBOT&&(null===(le=null===(ie=Re[0])||void 0===ie?void 0:ie.component)||void 0===le?void 0:le.buttons)&&(null===(de=null===(se=null===(ae=Re[0])||void 0===ae?void 0:ae.component)||void 0===se?void 0:se.buttons)||void 0===de?void 0:de.length)>0&&e(h,{backTrackMessage:null===(re=null==Ve?void 0:Ve.backTrackExtra)||void 0===re?void 0:re[0],setBackTrackMessage:null===(pe=null==Ve?void 0:Ve.backTrackExtra)||void 0===pe?void 0:pe[1]}),(null===(ve=null===(ce=null!=Be&&Be>-1?null===(ue=ye.cards[Be])||void 0===ue?void 0:ue.buttons:null==ye?void 0:ye.buttons)||void 0===ce?void 0:ce.filter((e=>"QUICK_REPLY"===e.type)))||void 0===ve?void 0:ve.length)>0&&(Ee!==c.CHATBOT?e(B,{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(h,{backTrackMessage:null===(me=null==Ve?void 0:Ve.backTrackExtra)||void 0===me?void 0:me[0],setBackTrackMessage:null===(be=null==Ve?void 0:Ve.backTrackExtra)||void 0===be?void 0:be[1]})),null===(he=null===(fe=null!=Be&&Be>-1?null===(ge=ye.cards[Be])||void 0===ge?void 0:ge.buttons:null==ye?void 0:ye.buttons)||void 0===fe?void 0:fe.filter((e=>"QUICK_REPLY"===e.type)))||void 0===he?void 0:he.map(((o,n)=>{if("QUICK_REPLY"===o.type&&Ee!==c.CHATBOT)return e(M,{variableListIndex:n,QRBoptions:null==R?void 0:R.QRBoptions,button:o,currentVariableList:null!=Be&&Be>-1?Object.assign({},ye.cards[Be]):Object.assign({},ye),updateSelectedQRBTemplateBtn:Je},`${n}_${Be}`)})),Ee===c.CHATBOT&&Ae&&e(j,{discountCode:null===(je=null==Ve?void 0:Ve.discountCodeExtra)||void 0===je?void 0:je[0],setDiscountCode:null===(Oe=null==Ve?void 0:Ve.discountCodeExtra)||void 0===Oe?void 0:Oe[1]}),null===(Te=null!=Be&&Be>-1?null===(Ce=ye.cards[Be])||void 0===Ce?void 0:Ce.buttons:null==ye?void 0:ye.buttons)||void 0===Te?void 0:Te.map(((o,t)=>{var i,l,a,s,d;if("COPY_CODE"===o.type)return e(n,{children:ke?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(y,{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)})}))]}))},I=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}from"../utils/validateName.js";import{BackTrackComponent as h}from"./BackTrackComponent.js";import{DiscountCodeComponent as j}from"./DiscountCodeComponent.js";import C from"./EditMediaModal.js";import O from"./EditMediaV2.js";import{EditTemplateMediaContainer as T}from"./EditMediaV2.style.js";import{useEditWhatsappTemplateMedia as x}from"./useEditWhtasappTemplateMedia.js";import y from"./VariableConnector.js";import{Container as E}from"./VariableConnectorsPanel.js";import V from"./VariableConnectorWhatsApp.js";import B from"./VariableEditorHeader.js";import M from"./WhatsAppTemplateCardButtonV2.js";const k=d=>{let{template:k,onTemplateChange:L,whatsappSpecificPickerMeta:R,showVariableModal:U,variableListForImage:w,setDiscountCode:A,fileName:H,setFileName:N}=d;var P,D,_,S,F,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;const xe=k.isCarouselType,{originalVariableList:ye,pod:Ee,extras:Ve,selectedCarouselIndex:Be,isProductCarouselType:Me,disableCopyCode:ke}=v(),{descriptionComponents:Ie,urlBtns:Le,qrbBtns:Re,imageComponent:Ue,bodyVariables:we,headerVariables:Ae}=b(k),He=l(null),[Ne,Pe]=a(!1),[De,_e]=a(-1===Be?{descriptionComponents:Ie,urlBtns:Le,qrbBtns:Re,imageComponent:Ue,bodyVariables:we,headerVariables:Ae}:{}),{uploadMediaLink:Se,uploadMediaFiles:Fe,validateMimeType:Qe}=R,qe=x({uploadMediaLink:Se,uploadMediaFiles:Fe,updateTemplateImageUrl:function(e,o){var n,t,l,a,s,d,r,p;let u;u=null!=Be&&Be>-1?{components:null===(t=null===(n=k.components[1])||void 0===n?void 0:n.cards)||void 0===t?void 0:t[Be].components,mapping:null===(a=null===(l=null==k?void 0:k.mapping)||void 0===l?void 0:l.cards)||void 0===a?void 0:a[Be]}:Object.assign({},k);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!=Be&&Be>-1){const e=i(k);e.components[1].cards[Be].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[Be]=null!==(p=u.mapping)&&void 0!==p?p:{}),null==L||L(Object.assign({},e)),Ke(!0)}else null==L||L(Object.assign({},u))},validateMimeType:Qe,mediaComponent:xe?De.imageComponent:Ue,fileRef:He}),[Ye,Ke]=a(!1),[We,$e]=a(H),[Ge,Xe]=a();function ze(e,o,n){var t,l,a,s,d,r,p,u,c,v;const m=null!=Be&&Be>-1?{components:null===(t=Object.assign({},k).components[1].cards)||void 0===t?void 0:t[Be].components,mapping:null===(l=Object.assign({},k).mapping.cards)||void 0===l?void 0:l[Be]}:Object.assign({},k),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!=Be&&Be>-1&&Me){const o=Object.assign({},k).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({},k).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(k);return l.components=o,l.mapping.cards=t,void(null==L||L(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))?Pe(!0):(Pe(!1),null==A||A(""))}if(null!=Be&&Be>-1){const e=i(k);e.components[1].cards[Be].components=b.components,e.mapping.cards[Be]=b.mapping,null==L||L(Object.assign({},e))}else null==L||L(b)}function Je(e,o,n){var t,l,a,s,d,r,p;const u=null!=Be&&Be>-1?{components:null===(t=Object.assign({},k).components[1].cards)||void 0===t?void 0:t[Be].components,mapping:null===(l=Object.assign({},k).mapping.cards)||void 0===l?void 0:l[Be]}:Object.assign({},k);if(null!=Be&&Be>-1&&Me){const o=Object.assign({},k).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(k);return t.components=o,void(null==L||L(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!=Be&&Be>-1){const e=i(k);e.components[1].cards[Be].components=u.components,null==L||L(Object.assign({},e))}else null==L||L(u)}s((()=>{var e,o;if(null===(e=k.mapping.buttons)||void 0===e?void 0:e.find((e=>"checkout.checkoutUrl"===e.slice(2,-2))))Pe(!0);else{Pe(!1);const e=null===(o=null==Ve?void 0:Ve.discountCodeExtra)||void 0===o?void 0:o[1];null==e||e("")}}),[k]),s((()=>{var e,o,n,t;if(null!=Be&&Be>-1){const i={components:null===(o=null===(e=k.components[1])||void 0===e?void 0:e.cards)||void 0===o?void 0:o[Be].components,mapping:null===(t=null===(n=null==k?void 0:k.mapping)||void 0===n?void 0:n.cards)||void 0===t?void 0:t[Be]},{descriptionComponents:l,urlBtns:a,qrbBtns:s,imageComponent:d,bodyVariables:r,headerVariables:p}=b(i);_e({descriptionComponents:l,urlBtns:a,qrbBtns:s,imageComponent:d,bodyVariables:r,headerVariables:p})}else if(null!=Be&&-1===Be){const{descriptionComponents:e,urlBtns:o,qrbBtns:n,imageComponent:t,bodyVariables:i,headerVariables:l}=b(k);_e({descriptionComponents:e,urlBtns:o,qrbBtns:n,imageComponent:t,bodyVariables:i,headerVariables:l})}}),[Be]),s((()=>{var e,o,n,t;if(null!=Be&&Be>-1&&Ye){const i={components:null===(o=null===(e=k.components[1])||void 0===e?void 0:e.cards)||void 0===o?void 0:o[Be].components,mapping:null===(t=null===(n=null==k?void 0:k.mapping)||void 0===n?void 0:n.cards)||void 0===t?void 0:t[Be]},{descriptionComponents:l,urlBtns:a,qrbBtns:s,imageComponent:d,bodyVariables:r,headerVariables:p}=b(i);_e({descriptionComponents:l,urlBtns:a,qrbBtns:s,imageComponent:d,bodyVariables:r,headerVariables:p}),Ke(!1)}}),[Ye]);const Ze=()=>{if(!We)return null==N||N(""),void Xe("PDF name is Required");const e=f(null!=We?We:"",Ee);null==N||N(We),Xe(e?"Please enter a valid PDF name":void 0)},eo=xe?De.imageComponent:Ue;return qe.openEditMedia?e(E,Object.assign({style:{flexDirection:"column",width:400,maxHeight:460}},{children:e(C,{mediaComponentFormat:null!==(P=eo.format)&&void 0!==P?P:u.IMAGE,uploadMedia:qe.uploadMedia,variableListForImage:w||[],useEditWhatsappTemplateMediaResponse:qe,setOpenEditMedia:qe.setOpenEditMedia,openEditMedia:qe.openEditMedia,editIconRef:qe.editIconRef,fileRef:He})})):o(E,Object.assign({style:{flexDirection:"column",width:400,maxHeight:460,minWidth:Me?"420px":"auto"}},{children:[!!De.imageComponent&&!Me&&o(T,{children:[e(O,{imageName:null!==(_=null===(D=null==eo?void 0:eo.example)||void 0===D?void 0:D.header_handle)&&void 0!==_?_:[],handleImageChange:qe.handleImageChange,mediaType:null==eo?void 0:eo.format,error:qe.error,isLoading:qe.loading,setOpenEditMedia:qe.setOpenEditMedia,selectedVariable:g(null!==(Q=null===(F=null===(S=null==eo?void 0:eo.example)||void 0===S?void 0:S.header_handle)||void 0===F?void 0:F[0])&&void 0!==Q?Q:"")?null===(Y=null===(q=null==eo?void 0:eo.example)||void 0===q?void 0:q.header_handle)||void 0===Y?void 0:Y[0]:(null===(W=null===(K=null==k?void 0:k.mapping)||void 0===K?void 0:K.header)||void 0===W?void 0:W[0])?null===(G=null===($=null==k?void 0:k.mapping)||void 0===$?void 0:$.header)||void 0===G?void 0:G[0]:qe.selectedVariable}),(null==Ue?void 0:Ue.format)==u.DOCUMENT?e(I,{children:Ee===c.CHATBOT?e(p,{labelText:"PDF Name",placeHolder:"Enter the name",errorMessage:Ge||void 0,onBlur:Ee!==c.CHATBOT?Ze:void 0,onChange:e=>{Xe(""),$e(null==e?void 0:e.actualValue)},pickerType:t.EMBEDDED,noMaxCharCheck:!0,allowMix:!0,showVarHeader:!0,varHeaderText:"Select variable",prevVariable:{actualValue:null!=We?We:"",variableType:"string"},variablesList:w,showAddButton:Ee===c.CHATBOT}):e(r,{labelText:"PDF Name",placeholder:"Enter the name",value:We,errorMessage:Ge||void 0,onBlur:Ze,onChangeText:e=>{Xe(""),$e(e)}})}):e(n,{})]}),(null===(X=De.bodyVariables)||void 0===X?void 0:X.length)>0&&e(B,{containerStyle:{paddingTop:De.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===(z=De.descriptionComponents)||void 0===z?void 0:z.map(((o,n)=>e(V,{originalVariableList:null!=Be&&Be>-1?ye.cards[Be]:ye,type:o.type,descriptionComponent:o.component,showVariableModal:U},n))),(null===(ee=null===(Z=null!=Be&&Be>-1?null===(J=ye.cards[Be])||void 0===J?void 0:J.buttons:null==ye?void 0:ye.buttons)||void 0===Z?void 0:Z.filter((e=>"URL"===e.type)))||void 0===ee?void 0:ee.length)>0&&e(B,{headerText:"Edit buttons",subText:"Edit the link connected to the CTA button"}),null===(te=null===(ne=null!=Be&&Be>-1?null===(oe=ye.cards[Be])||void 0===oe?void 0:oe.buttons:null==ye?void 0:ye.buttons)||void 0===ne?void 0:ne.filter((e=>Ee===c.CHATBOT||"URL"===e.type)))||void 0===te?void 0:te.map(((o,n)=>{const t=o.buttonVariable===m;if("URL"===o.type)return e(M,{variableListIndex:n,disableEdit:t,CTAoptions:null==R?void 0:R.CTAoptions,button:o,currentVariableList:null!=Be&&Be>-1?Object.assign({},ye.cards[Be]):Object.assign({},ye),updateSelectedURLTemplateBtn:ze},`${n}_${Be}`)})),Ee===c.CHATBOT&&(null===(le=null===(ie=Re[0])||void 0===ie?void 0:ie.component)||void 0===le?void 0:le.buttons)&&(null===(de=null===(se=null===(ae=Re[0])||void 0===ae?void 0:ae.component)||void 0===se?void 0:se.buttons)||void 0===de?void 0:de.length)>0&&e(h,{backTrackMessage:null===(re=null==Ve?void 0:Ve.backTrackExtra)||void 0===re?void 0:re[0],setBackTrackMessage:null===(pe=null==Ve?void 0:Ve.backTrackExtra)||void 0===pe?void 0:pe[1]}),(null===(ve=null===(ce=null!=Be&&Be>-1?null===(ue=ye.cards[Be])||void 0===ue?void 0:ue.buttons:null==ye?void 0:ye.buttons)||void 0===ce?void 0:ce.filter((e=>"QUICK_REPLY"===e.type)))||void 0===ve?void 0:ve.length)>0&&(Ee!==c.CHATBOT?e(B,{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(h,{backTrackMessage:null===(me=null==Ve?void 0:Ve.backTrackExtra)||void 0===me?void 0:me[0],setBackTrackMessage:null===(be=null==Ve?void 0:Ve.backTrackExtra)||void 0===be?void 0:be[1]})),null===(he=null===(fe=null!=Be&&Be>-1?null===(ge=ye.cards[Be])||void 0===ge?void 0:ge.buttons:null==ye?void 0:ye.buttons)||void 0===fe?void 0:fe.filter((e=>"QUICK_REPLY"===e.type)))||void 0===he?void 0:he.map(((o,n)=>{if("QUICK_REPLY"===o.type&&Ee!==c.CHATBOT)return e(M,{variableListIndex:n,QRBoptions:null==R?void 0:R.QRBoptions,button:o,currentVariableList:null!=Be&&Be>-1?Object.assign({},ye.cards[Be]):Object.assign({},ye),updateSelectedQRBTemplateBtn:Je},`${n}_${Be}`)})),Ee===c.CHATBOT&&Ne&&e(j,{discountCode:null===(je=null==Ve?void 0:Ve.discountCodeExtra)||void 0===je?void 0:je[0],setDiscountCode:null===(Ce=null==Ve?void 0:Ve.discountCodeExtra)||void 0===Ce?void 0:Ce[1]}),null===(Te=null!=Be&&Be>-1?null===(Oe=ye.cards[Be])||void 0===Oe?void 0:Oe.buttons:null==ye?void 0:ye.buttons)||void 0===Te?void 0:Te.map(((o,t)=>{var i,l,a,s,d;if("COPY_CODE"===o.type)return e(n,{children:ke?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(y,{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)})}))]}))},I=d.div`
|
|
2
2
|
padding-top: 24px;
|
|
3
3
|
padding-left: 10px;
|
|
4
4
|
padding-right: 10px;
|