"use strict";(globalThis.webpackChunkhelpgent=globalThis.webpackChunkhelpgent||[]).push([[498],{13498:(e,t,a)=>{a.r(t),a.d(t,{default:()=>N});var l=a(51609),n=a(86087),r=a(56427),i=a(63064),s=a(73424),o=a(64197);const c=(0,n.createContext)(),p=({children:e})=>{const[t,a]=(0,n.useState)({isImportingAttachment:!1,isCreatePopupOpen:!1,selectedTemplate:null,templateElements:null,createFormStage:"initial"});return(0,l.createElement)(c.Provider,{value:{preMadeTemplatePreviewState:t,setPreMadeTemplatePreviewState:a}},e)};var g=a(65604);const m=a(38267).Ay.div`
    .helpgent-preMade-preview__header{
        display: flex;
        justify-content: space-between;
        align-items: center;
        padding: 30px;
        background-color: var(--helpgent-color-white);
        @media only screen and (max-width: 767px){
            flex-wrap: wrap;
            gap: 15px;
        }
    }
    .helpgent-preMade-preview__header-left{
        line-height: 1;
        a{
            font-size: 14px;
            font-weight: 500;
            text-decoration: none;
            color: var(--helpgent-color-light-gray);
            &:hover{
                color: var(--helpgent-color-primary);
                svg path{
                    fill: var(--helpgent-color-primary);
                }
            }
        }
        svg{
            margin-right: 6px;
            path{
                fill: var(--helpgent-color-light-gray);
            }
        }
    }
    .helpgent-preMade-preview__header-right{
        .helpgent-btn{
            svg{
                path{
                    fill: var(--helpgent-color-white);
                }
            }
            &:hover{
                svg{
                path{
                    fill: var(--helpgent-color-primary);
                }
            }
            }
        }
    }
    .helpgent-preMade-preview__header-middle{
        text-align: center;
        @media only screen and (max-width: 691px){
            order: 2;
        }
    }
    .helpgent-preMade-preview__title{
        font-size: 22px;
        font-weight: 600;
        margin: 0;
        color: var(--helpgent-color-dark);
    }

    .helpgent-preview-style{
        text-align: left;
        height: calc(100vh - 180px);
        .helpgent-element-element{
            padding-left: 30px;
            padding-right: 30px;
        }
    }

    .helpgent-preMade-preview__content{
        max-width: 1240px;
        padding: 40px 15px 0;
        margin: 0 auto;
    }
    .helpgent-preMade-preview__iframe{
        padding: 30px;
        background: #fff;
        border-radius: 12px;
        margin-bottom: 30px;
        min-height: 500px;
        position: relative;
        &.helpgent-iframe-loader{
            &:after{
                position: absolute;
                left: 0;
                top: 0;
                width: 100%;
                height: 100%;
                content: '';
                background-color: var(--helpgent-color-white);
                opacity: .5;
                z-index: 1;
            }
        }
        .components-spinner{
            position: absolute;
            left: 50%;
            top: 50%;
            z-index: 10;
        }
        iframe{
            width: 100%;
        }
    }

    iframe{
        color: white;
        body{
            background-color: transparent;
        }
        .helpgent-preview-container{
            @media only screen and (max-width: 1399px){
                scale: 1;
            }
        }
    }

`;var M=a(47643),u=a(22057),d=a(6945),h=a(38745),w=a(52619),y=a(16622),_=a(27723);const L=e=>{const{baseApiRoute:t,baseLinkRoute:a}=e,[i,o]=(0,n.useState)(!1),{routeLink:p,paramsHook:L}=(0,d.Xd)("helpgent_router_references",null),N=(0,h.L)(),{preMadeTemplatePreviewState:z,setPreMadeTemplatePreviewState:v}=(0,n.useContext)(c),{selectedTemplate:b}=z,{id:x}=L(),j=(0,w.applyFilters)("helpgent_before_template_iframe");return(0,n.useEffect)(()=>{fetch(y._V+"/"+x).then(async e=>{const t=await e.json();v({...z,selectedTemplate:t})})},[]),(0,l.createElement)(m,{className:"helpgent-preMade-preview"},(0,l.createElement)("div",{className:"helpgent-preMade-preview__header"},(0,l.createElement)("div",{className:"helpgent-preMade-preview__header-left"},(0,l.createElement)(p,{to:`${a.preMadeTemplates}`},(0,l.createElement)(g.A,{src:u.A})," ",(0,_.__)("Back to template gallery","helpgent"))),(0,l.createElement)("div",{className:"helpgent-preMade-preview__header-middle"},(0,l.createElement)("h4",{className:"helpgent-preMade-preview__title"},b?.title)),(0,l.createElement)("div",{className:"helpgent-preMade-preview__header-right"},(0,l.createElement)("button",{className:"helpgent-btn helpgent-btn-md helpgent-btn-primary "+((0,w.applyFilters)("helpgent_disable_template_use_button",!N&&b?.is_pro)?"helpgent-btn-disabled":""),onClick:function(){b.json_path&&(v({...z,isCreatePopupOpen:!0,createFormStage:"prepared-elements"}),fetch(b.json_path).then(e=>{if(!e.ok)throw new Error((0,_.__)("Network response was not ok","helpgent"));return e.json()}).then(e=>{v({...z,isCreatePopupOpen:!0,createFormStage:"scratch",templateElements:e})}).catch(e=>{console.error((0,_.__)("There was a problem with the fetch operation:","helpgent"),e)}))}},(0,l.createElement)(g.A,{src:M.A})," ",(0,_.__)("Use this template","helpgent")))),(0,l.createElement)("div",{className:"helpgent-preMade-preview__content"},b&&(0,l.createElement)("div",{className:"helpgent-preMade-preview__iframe "+(i?"":"helpgent-iframe-loader")},!i&&(0,l.createElement)(r.Spinner,null),j,(0,l.createElement)("iframe",{src:b?.preview_url,width:"1000",height:"600",style:{border:"0"},onLoad:()=>{o(!0)}}))),(0,l.createElement)(s.A,{moduleState:z,setModuleState:v,baseApiRoute:t,baseLinkRoute:a}))};function N(e){return(0,l.createElement)(i.Ht,{client:o.A},(0,l.createElement)(p,null,(0,l.createElement)(L,{...e})))}},26944:(e,t,a)=>{a.d(t,{A:()=>r});var l=a(51609),n=a(4286);function r(e){const{type:t,currentValue:a,contentFlow:r}=e;return(0,l.createElement)(n.F2,{className:`helpgent-progress-bar helpgent-progress-bar-${t} helpgent-progress-bar-${r}`},(0,l.createElement)("div",{className:"helpgent-progress-bar__status",style:{["vertical"===r?"height":"width"]:`${a}%`}}))}},41620:(e,t,a)=>{function l(e,t){return isNaN(e)||isNaN(t)||0===t?0:(e/t*100).toFixed(2).replace(/\.00$/,"")}a.d(t,{A:()=>l})},47643:(e,t,a)=>{a.d(t,{A:()=>l}),a(51609);const l="data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIxNCIgaGVpZ2h0PSIxNCIgdmlld0JveD0iMCAwIDE0IDE0Ij4KICA8cGF0aCBpZD0iY29weSIgZD0iTTcuODc1LDExLjA4M0gzLjIwOEEzLjIxMiwzLjIxMiwwLDAsMSwwLDcuODc1VjMuMjA4QTMuMjEyLDMuMjEyLDAsMCwxLDMuMjA4LDBINy44NzVhMy4yMTIsMy4yMTIsMCwwLDEsMy4yMDgsMy4yMDhWNy44NzVBMy4yMTIsMy4yMTIsMCwwLDEsNy44NzUsMTEuMDgzWk0zLjIwOCwxLjc1QTEuNDU4LDEuNDU4LDAsMCwwLDEuNzUsMy4yMDhWNy44NzVBMS40NTgsMS40NTgsMCwwLDAsMy4yMDgsOS4zMzNINy44NzVBMS40NTgsMS40NTgsMCwwLDAsOS4zMzMsNy44NzVWMy4yMDhBMS40NTgsMS40NTgsMCwwLDAsNy44NzUsMS43NVpNMTQsMTAuNzkyVjQuMDgzYS44NzUuODc1LDAsMSwwLTEuNzUsMHY2LjcwOGExLjQ1OCwxLjQ1OCwwLDAsMS0xLjQ1OCwxLjQ1OEg0LjA4M2EuODc1Ljg3NSwwLDEsMCwwLDEuNzVoNi43MDhBMy4yMTIsMy4yMTIsMCwwLDAsMTQsMTAuNzkyWiIvPgo8L3N2Zz4K"},64197:(e,t,a)=>{a.d(t,{A:()=>l});const l=new(a(5054).E)},73424:(e,t,a)=>{a.d(t,{A:()=>Y});var l=a(51609),n=a(86087),r=a(56427),i=a(65604),s=a(5556),o=a.n(s),c=a(27723);function p(e){const{title:t,subtitle:a}=e;return(0,l.createElement)("div",{className:"helpgent-createPopup__header"},t&&(0,l.createElement)("h4",null,t),a&&(0,l.createElement)("p",null,a))}p.propTypes={title:o().string,subtitle:o().string};var g=a(6945);function m(e){const{routeLink:t}=(0,g.Xd)("helpgent_router_references",null),{icon:a,text:n,step:r,url:s,moduleState:o,setModuleState:c}=e;function p(e,t){e.preventDefault(),"scratch"===t?c({...o,addBackBtn:!0,createFormStage:"scratch"}):"template"===t&&c({...o,createFormStage:"template"})}return s?(0,l.createElement)(t,{to:s||"#",className:"helpgent-createPopup__action",onClick:e=>r?p(e,r):null},(0,l.createElement)("div",{className:"helpgent-createPopup__action-icon"},(0,l.createElement)(i.A,{src:a})),n&&(0,l.createElement)("span",{className:"helpgent-createPopup__action-text"},n)):(0,l.createElement)("span",{className:"helpgent-createPopup__action",onClick:e=>r?p(e,r):null},(0,l.createElement)("div",{className:"helpgent-createPopup__action-icon"},(0,l.createElement)(i.A,{src:a})),n&&(0,l.createElement)("span",{className:"helpgent-createPopup__action-text"},n))}function M(e){const{moduleState:t,setModuleState:a}=e;return(0,l.createElement)("div",{className:"helpgent-createPopup"},(0,l.createElement)(p,{title:(0,c.__)("Create a New Form","helpgent"),subtitle:(0,c.__)("You can select a template to assist you, or start from scratch.","helpgent")}),(0,l.createElement)("div",{className:"helpgent-createPopup__body"},(0,l.createElement)("div",{className:"helpgent-createPopup__actions"},[{icon:"data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIzMCIgaGVpZ2h0PSIzMCIgdmlld0JveD0iMCAwIDMwIDMwIj4KICA8ZyBpZD0iR3JvdXBfMjYxOCIgZGF0YS1uYW1lPSJHcm91cCAyNjE4IiB0cmFuc2Zvcm09InRyYW5zbGF0ZSgtNzk5Ljc0NyAtMzAzLjIyOSkiPgogICAgPHBhdGggaWQ9IlBhdGhfMTQ3OCIgZGF0YS1uYW1lPSJQYXRoIDE0NzgiIGQ9Ik0zNC4yMTIsMTguMzM3bC0uOTM3LjkzN2ExMC43ODEsMTAuNzgxLDAsMCwwLTMuNzEyLS42NUExMC45NTIsMTAuOTUyLDAsMCwwLDE4LjYyNiwyOS41NWExMC43NTYsMTAuNzU2LDAsMCwwLC42NTEsMy43MDlMMTcuNzUsMzQuNzg0bC0zLjMxMy0zLjMxTDExLjIsMjguMjM5bC4xLS4xTDI2Ljk1OSwxMi41bC42ODgtLjY4NywzLjE2MywzLjE0N0wzNC4yLDE4LjMyMmwuMDEzLjAxNVpNMTAuNjc4LDI5LjQ4NSw4LjA1MSwzNi43MjFhLjk2Ljk2LDAsMCwwLC4yMjUuOTg3Ljk3Ni45NzYsMCwwLDAsLjk4Ni4yMjVsNy4yNDMtMi42MjQtNS44MjctNS44MjRaTTM2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I5LjY2N0EzLjMzMywzLjMzMywwLDAsMCwzMywxM1Y2LjMzM0EzLjMzMywzLjMzMywwLDAsMCwyOS42NjcsM1pNNi4zMzMsMTNWNi4zMzNIMjkuNjY3VjEzWm0xMCw1aC0xMEEzLjMzMywzLjMzMywwLDAsMCwzLDIxLjMzM3Y4LjMzM0EzLjMzMywzLjMzMywwLDAsMCw2LjMzMywzM2gxMGEzLjMzMywzLjMzMywwLDAsMCwzLjMzMy0zLjMzM1YyMS4zMzNBMy4zMzMsMy4zMzMsMCwwLDAsMTYuMzMzLDE4Wm0tMTAsMTEuNjY3VjIxLjMzM2gxMHY4LjMzM1pNMjkuNjY3LDE4aC01YTMuMzMzLDMuMzMzLDAsMCwwLTMuMzMzLDMuMzMzdjguMzMzQTMuMzMzLDMuMzMzLDAsMCwwLDI0LjY2NywzM2g1QTMuMzMzLDMuMzMzLDAsMCwwLDMzLDI5LjY2N1YyMS4zMzNBMy4zMzMsMy4zMzMsMCwwLDAsMjkuNjY3LDE4Wm0tNSwxMS42NjdWMjEuMzMzaDV2OC4zMzNaIiB0cmFuc2Zvcm09InRyYW5zbGF0ZSgtMyAtMykiLz4KPC9zdmc+Cg==",text:"Start From A Template",url:"pre-made-templates"}].map((e,n)=>(0,l.createElement)(m,{icon:e.icon,text:e.text,step:e.step,url:e.url,moduleState:t,setModuleState:a,key:n})))))}m.propTypes={icon:o().string,text:o().string,step:o().string,url:o().string},M.propTypes={};var u=a(49876),d=a(88869),h=a(63064),w=a(49785),y=a(52619),_=a(29898);async function L(e,t,a,l,n,r,i){const s=(0,_.vf)().filter(e=>"welcome"===e.element_type||"end"===e.element_type||"user_validation"===e.element_type);let o=null,p={};const g={color_style:{icon:{value:"#3C3C3C"},title:{value:"#000000"},description:{value:"#3C3C3C"},chat_title_color:{value:"#000000"},button:{value:"#6551F2"},button_text:{value:"#ffffff"},footer_text_color:{value:"#6E6E6E"},options_color:{value:"#3c3c3c"}},corner:"round",element_size:"md",specialElement_size:"md",background_image:null,background_color:"#ffffff",background_style:{background_overlay:{isActive:"1"},overlay_color:{value:"#000000"},overlay_opacity:{value:"50"}},font_family:{family:"Inter",category:"sans-serif"},font_weight_variations:[400,500,600]};if(r){const e=Object.assign({},JSON.parse(r).global),t=JSON.parse(r).elements;p={...e,...g},o=JSON.stringify({elements:t,global:p})}else{p={...g,action_btn:{isActive:"1"},go_to_next_text:{value:"OK"},submission_text:{value:"Submit"},helpgent_branding:{isActive:"1"},save_incomplete_data:{isActive:"0"},anonymous_submission:{isActive:"0"},progress_count:{isActive:"1"},bubble:{background_type:{type:"",screen:"",color:"",upload:{}},overlay_text:"",shape:"circle",border:{has_border:"1",color:"#6551F2"},position:"left",offset_x:"30",offset_y:"30",size:"medium"},media:{max_video_duration:{value:"2"},max_voice_duration:{value:"2"},max_upload_size:{value:"300",unit:"mb"}},email_notification:{admin_notification:{notify_on_new_response:{isActive:"1"},new_response_subject:{value:"New Form Submission Alert"},new_response_body:{value:"<p>Hello {{TO_NAME}},</p><p>You have received a new submission for the {{FROM_NAME}}. Here are the details:</p><ul><li>User Name: {{FROM_EMAIL}}</li><li>IP Address: {{IP_ADDRESS}}</li><li>Submission Date and Time: {{NOW}}</li></ul><p>To access the complete submission details, kindly navigate to the admin panel by clicking on the link below: {{DASHBOARD_LINK}}</p><p>Best regards,</p><p>{{SITE_NAME}}</p>"},notify_on_user_message:{isActive:"1"},user_message_subject:{value:"New Message Received Alert"},user_message_body:{value:"<p>Hello {{TO_NAME}},</p><p>You have received a new message for the {{FROM_NAME}}. Here are the details: </p><ul><li>User Name: {{FROM_EMAIL}}</li><li>Submission Date and Time: {{NOW}}</li></ul><p>To continue the conversation, kindly visit the admin panel by clicking on this link: {{DASHBOARD_LINK}}</p><p>Best regards, </p><p>{{SITE_NAME}}</p>"}},user_notification:{notify_on_new_response:{isActive:"1"},new_response_subject:{value:"New Submission"},new_response_body:{value:"<p>Hello {{TO_NAME}},</p><p>Greetings and welcome to our platform!</p><p>We're delighted to inform you that your submission was successful, and we've received your message. </p><p>You can view your submission and continue the conversation through your dashboard by clicking on the following link: {{DASHBOARD_LINK}}</p><p>Thanks,</p><p>The Administrator of {{SITE_NAME}} </p>"},notify_on_admin_message:{isActive:"1"},admin_message_subject:{value:"New message form {{SITE_NAME}}"},admin_message_body:{value:"<p>Hello {{TO_NAME}},</p><p>You have received a new response from the admin. Here are the details:</p><ul><li>Message: {{MESSAGE}}</li><li>Submission Date and Time: {{NOW}}</li></ul><p>You can view the response and continue the conversation through your dashboard by clicking on the following link: {{DASHBOARD_LINK}}</p><p>Thanks, </p><p>The Administrator of {{SITE_NAME}} </p>"}}}};const e=s.filter(e=>"end"===e.element_type)[0];s[0].controls.elementLogic.default_target=e?.id,o=JSON.stringify({elements:s,global:p})}const m={status:"draft",content:o},M=e.available_pages?e.available_pages:"";m.title=e.title,m.available_pages=M||[],m.is_chat_bubble=e.displayChatBubble||"0";try{const e=await t(m);e&&l(`/${i.forms}/${e.form_id}/edit`),n.invalidateQueries("helpgent-single-form"),n.invalidateQueries("helpgent-form"),(0,y.doAction)("helpgent-toast",{message:e.message})}catch(e){let t={};e.message?t.internal=e.message:t.internal=(0,c.__)("Server Error","helpgent"),a(t)}}var N=a(92300),z=a(26374),v=a(7012);var b=a(38267);const x=b.Ay.div`
    width: fit-content;
    margin: 0 auto;
    @media only screen and (max-width: 575px){
        width: 100%;
    }
    .helpgent-createPopup{
        text-align: center;
        margin: 50px 0;
        .helpgent-toggle-inline{
            display: flex;
            align-items: center;
            justify-content: space-between;
            width: 100%;
            .helpgent-toggle__label{
                display: flex;
                align-items: center;
                font-size: 15px;
                font-weight: 500;
                color: var(--helpgent-color-dark);
                cursor: pointer;
            }
        }
    }

    .helpgent-select__option{
        display: flex;
        .helpgent-checkbox{
            margin-right: 10px;
        }
    }

    .helpgent-createPopup__header{
        h4{
            font-size: 30px;
            font-weight: 600;
            margin: 0 0 15px;
            line-height: 1.27;
            color: var(--helpgent-color-dark);
        }
        p{
            font-size: 16px;
            font-weight: 400;
            margin: 0;
        }
    }

    .helpgent-createPopup__actions{
        display: flex;
        align-items: center;
        margin-top: 32px;
        @media only screen and (max-width: 400px){
            flex-wrap: wrap;
        }
    }

    .helpgent-createPopup__action{
        display: flex;
        flex-direction: column;
        align-items: center;
        margin: 15px;
        border-radius: 20px;
        padding: 40px 52px;
        text-decoration: none;
        cursor: pointer;
        background-color: var(--helpgent-color-bg-light);
        transition: var(--helpgent-transition);
        &:hover{
            background-color: var(--helpgent-color-bg-deep);
        }
        @media only screen and (max-width: 480px){
            width: 50%;
            padding: 20px 0;
        }
        @media only screen and (max-width: 400px){
            width: 100%;
        }
    }

    .helpgent-createPopup__action-icon{
        display: flex;
        align-items: center;
        justify-content: center;
        width: 80px;
        height: 80px;
        border-radius: 20px;
        background-color: var(--helpgent-color-white);
        svg{
            fill: var(--helpgent-color-primary);
        }
    }

    .helpgent-createPopup__action-text{
        display: block;
        font-size: 16px;
        font-weight: 500;
        max-width: 96px;
        margin-top: 20px;
        line-height: 1.38;
        color: var(--helpgent-color-dark);
    }

    .helpgent-validate-danger{
        display: block;
    }

    .helpgent-form-group{
        flex-direction: column;
        &__element{
            font-size: 16px;
            min-height: 50px;
            padding-inline-start: 20px;
            padding-inline-end: 20px;
            border-radius: 12px;
        }
    }

    .helpgent-btn {
        min-height: 50px;
    }
`,j=b.Ay.div`
    width: 100%;
    min-width: 320px;
    .helpgent-import-attachment__title{
        font-size: 18px;
        color: var(--helpgent-color-dark);
    }
    .helpgent-import-attachment__progress{
        display: flex;
        align-items: center;
    }
    .helpgent-import-attachment__percentage{
        margin-left: 15px;
    }
`,E=b.Ay.div`
    text-align: start;
    margin-top: 50px;
    .helpgent-form-group{
        width: 450px;
        @media only screen and (max-width: 575px){
            width: 100%;
        }
    }
    .helpgent-btn-block{
        margin-top: 30px;
    }
    .helpgent-tooltip-toggle{
        position: relative;
        top: 1px;
        display: inline-block;
        margin-inline-start: 10px;
        line-height: .85;
        cursor: pointer;
    }
    .helpgent-form__element,
    .helpgent-form__element-inline{
        border-radius: 12px;
        background-color: var(--helpgent-color-bg-light);
    }
    .helpgent-form__element{
        &::placeholder{
            color: #3C3C3C;
        }
    }
    .helpgent-form__element-inline{
        display: flex;
        justify-content: space-between;
        padding: 15px 20px;
    }
    .helpgent-form__label{
        display: flex;
        align-items: center;
        font-size: 15px;
        font-weight: 600;
        color: var(--helpgent-color-dark);
    }
    .helpgent-select {
        margin-top: 12px;
        &__control{
            background-color: var(--helpgent-color-bg-light);
        }
    }
`;var f=a(28050),D=a(41620),A=a(26944),S=a(16622);function C(e){const{formData:t,createFormMutation:a,setServerErrors:r,navigate:i,queryClient:s,moduleState:o,setModuleState:p,baseLinkRoute:g}=e,[m,M]=(0,n.useState)(0),[u,d]=(0,n.useState)(0),[h,w]=(0,n.useState)(0),[y,_]=(0,n.useState)(0),{templateElements:N,selectedTemplate:z}=o,{mutateAsync:v,isLoading:b}=(0,f.A)("/helpgent/form/media");return(0,n.useEffect)(()=>{if(N?.elements?.length>0){p({...o,isImportingAttachment:!0}),fetch(S._V+"/import/"+z.id);const e=N?.elements;let t=0,a=0;e.map(async(l,n)=>{if(l?.media?.url){const r={url:l.media.url};try{const l=await v(r);201===l?.data?.status?(e[n].media.url=l.url,a+=1,M(a)):(e[n].media.url=null,t+=1,d(t))}catch(a){e[n].media.url=null,t+=1,d(t)}}else t+=1,d(t);"picture_select"===l?.element_type&&l?.controls?.general?.options?.length>0&&(_(l?.controls?.general?.options?.length),l?.controls?.general?.options.map(async(e,n)=>{if(e?.url){const r={url:e?.url};try{const e=await v(r);201===e?.data?.status?(l.controls.general.options[n].url=e?.url,a+=1,M(a)):(l.controls.general.options[n].url=null,t+=1,d(t))}catch(e){l.controls.general.options[n].url=null,t+=1,d(t)}}else t+=1,d(t)}))})}},[N?.elements]),(0,n.useEffect)(()=>{const e=(0,D.A)(m+u,N?.elements?.length+y),l=JSON.stringify({elements:N.elements,global:N.global});100===parseInt(e)&&L(t,a,r,i,s,l,g),w(e)},[m,u]),(0,l.createElement)(j,null,(0,l.createElement)("h4",{className:"helpgent-import-attachment__title"},(0,c.__)("Import attachment progress","helpgent")),(0,l.createElement)("div",{className:"helpgent-import-attachment__progress"},(0,l.createElement)(A.A,{type:"success",currentValue:h,contentFlow:"horizontal"}),(0,l.createElement)("span",{className:"helpgent-import-attachment__percentage"},Math.floor(h),"%")))}var I=a(88589);function T(e){const{control:t,baseApiRoute:a}=e;return(0,l.createElement)("div",{className:"helpgent-form-group"},(0,l.createElement)("label",{htmlFor:"helpgent-page-select",className:"helpgent-form__label"},a.availablePages.text,(0,l.createElement)(r.Tooltip,{text:(0,c.__)("Control where your form bubble appears by specifying the pages it's displayed on.","helpgent"),delay:"0"},(0,l.createElement)("span",{className:"helpgent-tooltip-toggle"},(0,l.createElement)(i.A,{src:I.A})))),(0,l.createElement)(d.SelectField,{name:"available_pages",control:t,isMulti:!0,optionsAPI:a.availablePages.api,placeholder:(0,c.__)("Select...","helpgent")}))}function k(e){const{navigationHook:t}=(0,g.Xd)("helpgent_router_references",null),{moduleState:a,setModuleState:r,baseApiRoute:i,baseLinkRoute:s}=e,{selectedTemplate:o}=a,m=t(),M=(0,h.jE)(),[y,_]=(0,n.useState)({}),[b,x]=(0,n.useState)(null),[j,f]=(0,n.useState)(!1),[D,A]=(0,n.useState)("0"),[S,I]=(0,n.useState)("form"),{register:k,handleSubmit:O,setValue:Y,formState:{errors:P},control:F}=(0,w.mN)({mode:"all"}),{mutateAsync:B,isLoading:R}=(W=`${i?.forms}`,(0,z.n)(e=>(0,v.A)(W,e)));var W;return(0,n.useEffect)(()=>{o&&Y("title",o?.title||null)},[o]),(0,l.createElement)(l.Fragment,null,"form"===S&&(0,l.createElement)("div",{className:"helpgent-createPopup"},(0,l.createElement)(p,{title:(0,c.__)("Let’s get started","helpgent")}),(0,l.createElement)(E,null,(0,l.createElement)("form",{onSubmit:O(e=>function(e){r({...a,addBackBtn:!1}),o?(I("attachmentImport"),x(e)):L(e,B,_,m,M,null,s)}(e))},(0,l.createElement)("div",{className:"helpgent-form-group"},(0,l.createElement)("input",{type:"text",className:"helpgent-form-group__element",name:"title",placeholder:(0,c.__)("Form Name","helpgent"),...k("title",{required:{value:!0,message:(0,c.__)("The title field is required","helpgent")},validate:{isOnlySpace:e=>0!==e.trim().length||(0,c.__)("Only spaces not allowed","helpgent"),minLength:e=>e.trim().length>=5||(0,c.__)("The title field must be at least 5 characters.","helpgent")}})}),"required"===P.title?.type?(0,N.A)(P.title.message):y.title?(0,N.A)(y.title):null,"isOnlySpace"===P.title?.type?(0,N.A)(P.title.message):y.title?(0,N.A)(y.title):null,"minLength"===P.title?.type?(0,N.A)(P.title.message):y.title?(0,N.A)(y.title):null),(0,l.createElement)("div",{className:"helpgent-form-group"},(0,l.createElement)("div",{className:"helpgent-form__element-inline"},(0,l.createElement)(d.Switch,{handleToggle:()=>function(e,t,a,l,n){e(!a),t("displayChatBubble",!a),l("0"===n?"1":"0")}(f,Y,j,A,D),label:(0,c.__)("Enable Form Bubble?","helpgent"),isActive:D,tooltip:!0,tooltipText:(0,c.__)("Enable the Form Bubble to add a floating icon to your website. When activated, users can easily access and expand the form with a single click.","helpgent")}))),j&&(0,l.createElement)(l.Fragment,null,(0,l.createElement)(T,{control:F,baseApiRoute:i}),(0,u.$)("helpgent_form_create_modal_bubble_controls",{},{control:F})),(0,u.$)("helpgent_form_modal_before_submit",{},{control:F,displayChatBubble:j}),(0,l.createElement)("button",{type:"submit",className:"helpgent-btn helpgent-btn-md helpgent-btn-primary helpgent-btn-block "+(0!==Object.keys(P).length||0!==Object.keys(y).length||R?"helpgent-btn-disabled":""),disabled:!(0===Object.keys(P).length&&0===Object.keys(y).length&&!R)},R?(0,c.__)("Creating","helpgent"):(0,c.__)("Create Form","helpgent")),y.internal&&(0,N.A)(y.internal)))),"attachmentImport"===S&&(0,l.createElement)(C,{formData:b,createFormMutation:B,setServerErrors:_,navigate:m,queryClient:M,moduleState:a,setModuleState:r,baseLinkRoute:s}))}var O=a(22057);const Y=function(e){const{moduleState:t,setModuleState:a,baseApiRoute:s,baseLinkRoute:o}=e,{isImportingAttachment:p,isCreatePopupOpen:g,createFormStage:m,addBackBtn:u}=t;return g&&(0,l.createElement)(n.Fragment,null,(0,l.createElement)(r.Modal,{overlayClassName:"helpgent-modal helpgent-create-modal-wrap "+(p?"helpgent-attachment-importing":""),shouldCloseOnClickOutside:!p,onRequestClose:()=>p?{}:void a({...t,createFormStage:"initial",addBackBtn:!1,isCreatePopupOpen:!1}),isDismissible:!p},"scratch"===m&&u&&(0,l.createElement)("span",{className:"helpgent-btn-back",onClick:function(){a({...t,createFormStage:"initial",addBackBtn:!1})}},(0,l.createElement)(i.A,{src:O.A})," ",(0,c.__)("Back","helpgent")),(0,l.createElement)(x,{className:"helpgent-create-form-modal "+("prepared-elements"===m?"helpgent-create-loader-active":"")},"prepared-elements"===m&&(0,l.createElement)(r.Spinner,null),"initial"===m?(0,l.createElement)(M,{moduleState:t,setModuleState:a}):"scratch"===m?(0,l.createElement)(k,{moduleState:t,setModuleState:a,baseApiRoute:s,baseLinkRoute:o}):void 0)))}},88589:(e,t,a)=>{a.d(t,{A:()=>l}),a(51609);const l="data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIxNiIgaGVpZ2h0PSIxNiIgdmlld0JveD0iMCAwIDE2IDE2Ij4KICA8cGF0aCBpZD0iSWNvbl9hd2Vzb21lLXF1ZXN0aW9uLWNpcmNsZSIgZGF0YS1uYW1lPSJJY29uIGF3ZXNvbWUtcXVlc3Rpb24tY2lyY2xlIiBkPSJNMTYuNTYzLDguNTYzYTgsOCwwLDEsMS04LThBOCw4LDAsMCwxLDE2LjU2Myw4LjU2M1pNOC43NzcsMy4yMDhhNC4xNzgsNC4xNzgsMCwwLDAtMy43NiwyLjA1Ny4zODguMzg4LDAsMCwwLC4wODguNTI0bDEuMTE5Ljg0OWEuMzg3LjM4NywwLDAsMCwuNTM4LS4wNjhjLjU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