import{r as t,h as s,g as e}from"./p-1a7a8b00.js";import{a3 as i,h as r,a4 as o,a5 as a,V as h,i as n,F as d,u as c}from"./p-a44cd541.js";import{T as l}from"./p-487241b6.js";import{s as k}from"./p-b4467cc2.js";const v=class{constructor(s){t(this,s),this.isLocked=void 0,this.isCloned=void 0,this.canTakeOver=void 0,this.isOwner=void 0,this.isFormLoaded=void 0,this.takeOverHandler=void 0,this.useExternal=!1}resetState(){}connectedCallback(){this.resetState()}componentWillLoad(){this.useExternal=!!customElements.get("bp-sdk-external-take-over"),customElements.whenDefined("bp-sdk-external-take-over").then((()=>{this.useExternal=!0}))}shouldRender(){return this.isFormLoaded&&this.canTakeOver&&!this.isOwner&&!this.isCloned&&!this.isLocked}render(){return[this.useExternal&&this.renderExternal(),!this.useExternal&&this.renderInternal()]}renderExternal(){return s("bp-sdk-external-take-over",{canTakeOver:this.canTakeOver,isCloned:this.isCloned,isLocked:this.isLocked,isOwner:this.isOwner,isFormLoaded:this.isFormLoaded,shouldRender:this.shouldRender(),takeOverHandler:this.takeOverHandler})}renderInternal(){return this.shouldRender()&&s("div",{class:"bp-sdk-take-over__container"},s("bp-sdk-take-over-button",{onClick:this.takeOverHandler}))}};v.style="";const p=class{constructor(s){t(this,s),this.handleSubscriptions=()=>{this.storeUnsubscribe&&this.storeUnsubscribe(),k.mapDispatchToProps(this,{cloneApplicationForm:i}),this.storeUnsubscribe=k.mapStateToProps(this,this.mapStateToProps)},this.mapStateToProps=t=>({appFormId:r(t),isLocked:o(t),isCloned:a(t),canTakeOver:h(t,{permission:l.TakeOver}),isOwner:n(t),isFormLoaded:d(t),config:c(t)}),this.takeOverHandler=()=>{this.cloneApplicationForm({appFormId:this.appFormId,config:this.config})},this.isLocked=void 0,this.isCloned=void 0,this.canTakeOver=void 0,this.isOwner=void 0,this.isFormLoaded=void 0,this.appFormId=void 0,this.config=void 0,this.useExternal=!1}resetState(){}connectedCallback(){this.resetState(),this.handleSubscriptions()}componentWillLoad(){this.useExternal=!!customElements.get("bp-sdk-external-take-over-container"),customElements.whenDefined("bp-sdk-external-take-over-container").then((()=>{this.useExternal=!0})),this.handleSubscriptions()}disconnectedCallback(){this.storeUnsubscribe&&this.storeUnsubscribe()}render(){return[this.useExternal&&this.renderExternal(),!this.useExternal&&this.renderInternal()]}renderExternal(){return s("bp-sdk-external-take-over-container",{appFormId:this.appFormId,canTakeOver:this.canTakeOver,config:this.config,isCloned:this.isCloned,isLocked:this.isLocked,isOwner:this.isOwner,isFormLoaded:this.isFormLoaded,takeOverHandler:this.takeOverHandler})}renderInternal(){return s("bp-sdk-take-over",{canTakeOver:this.canTakeOver,isCloned:this.isCloned,isLocked:this.isLocked,isOwner:this.isOwner,isFormLoaded:this.isFormLoaded,takeOverHandler:this.takeOverHandler})}get el(){return e(this)}};p.style="";export{v as bp_sdk_take_over,p as bp_sdk_take_over_container}