import{x as oe,_ as le}from"./index-fNs72j9w.js";import{p as ne,f as se}from"./embed-B0Gwp2fv.js";import{B as ie,a as j,b as y,o as de,l as pe,_ as ce,D as V,G as i,U as m,u as l,H as a,P as s,Z as me,Y as ue,I as u,X as fe,C as x,V as b,ah as g,ag as D}from"./vue-DweYBrEc.js";const be={class:"default-main partnership-page"},ge={class:"setting-grid"},he={class:"panel setting-panel"},ye={class:"panel-title"},_e={class:"panel-body setting-form"},ve={class:"form-row"},Ce={class:"form-row textarea-row"},we={class:"form-row template-row"},Ve={class:"form-row textarea-row"},xe={class:"form-row template-row"},Ie={class:"color-grid"},ke={class:"panel embed-panel"},Se={class:"panel-title"},Oe={class:"panel-body"},Ue={class:"panel data-panel"},Ne={class:"panel-title"},Pe={class:"table-wrap"},Te=["href"],Ee={key:1},Ae={class:"bottom-actions"},Be={class:"dialog-grid"},P=`{
    "infoText": "We specialise in curating Asia's top licensed gaming and entertainment platforms, delivering the safest, most transparent, and most rewarding experience for every member.",
    "label": {
        "highlight": ["PAGCOR Licensed", "SSL Encrypted"],
        "normal": ["10+ Top Platforms", "Instant Payouts", "24/7 Support"]
    },
    "sections": [
        {
            "title": "Partner Advantages",
            "items": [
                "Exclusive negotiated deals you won't find anywhere else",
                "New member welcome bonus up to 200% on first deposit",
                "Unlimited daily cashback, the more you play, the more you earn"
            ]
        },
        {
            "title": "Security Guarantee",
            "items": [
                "Platform-wide 256-bit SSL encryption end-to-end",
                "RNG independently certified by third-party auditors",
                "Segregated player funds"
            ]
        },
        {
            "title": "Withdrawal Promise",
            "items": [
                "As fast as 3 minutes",
                "24-hour withdrawal channel",
                "Zero transaction fees"
            ]
        }
    ]
}`,J=`{
    "hideSection": [
        "partnerCard",
        "partnerWithdrawal",
        "payoutRates",
        "partnerReviews",
        "footer"
    ]
}`,Re=ie({name:"embed/partnership",__name:"partnership",setup(je){const{t}=oe.useI18n(),n=j({headerImage:"",footerConfig:P,customConfig:"",baseColor1:"#151921",baseColor2:"#1c2130",borderColor:"#2a3147",highlightColor:"#f0b429",titleColor:"#e2e8f0",textColor:"#718096"}),L=[{key:"baseColor1",label:"embed.partnership.baseColor1"},{key:"highlightColor",label:"embed.partnership.highlightColor"},{key:"baseColor2",label:"embed.partnership.baseColor2"},{key:"titleColor",label:"embed.partnership.titleColor"},{key:"borderColor",label:"embed.partnership.borderColor"},{key:"textColor",label:"embed.partnership.textColor"}],I=y(`<div style="position: relative;max-width: 1000px;margin: 0 auto;overflow: hidden;border: none;">
    <iframe id="partnershipIframe" src="https://1xaud.em7bd7.co/embed/partnership/partnership.asp" style="width: 100%;overflow: hidden;border: none;"></iframe>
    <script>
        (() => {
            const merchantId = (typeof _ !== "undefined" && typeof _.getVar === "function") ? (_.getVar("merchantId") ?? "") : "";
            if (!merchantId) {
                console.log("merchantId not found");
                return;
            }
            function init(iframe) {
                iframe.addEventListener('load', function() {
                    iframe.contentWindow.postMessage({ type: 'setIframeData', clientMerchant: merchantId }, '*');
                });
                window.addEventListener("message", function(event) {
                    if (event.data && event.data.type === "setPartnershipIframeHeight") {
                        iframe.style.height = event.data.height + "px";
                    }
                }, false);
            }
            var el = document.getElementById('partnershipIframe');
            if (el) { init(el); return; }
            var attempts = 0;
            var timer = setInterval(function() {
                attempts++;
                var el = document.getElementById('partnershipIframe');
                if (el) {
                    clearInterval(timer);
                    init(el);
                } else if (attempts >= 5) {
                    clearInterval(timer);
                    alert("iframe not found");
                }
            }, 1000);
        })();
    <\/script>
</div>`),f=y([]),k=y(!1),C=o=>o?typeof o=="string"?o:JSON.stringify(o,null,2):"",M=o=>{o&&(n.headerImage=o.header_image_url??"",n.footerConfig=C(o.footer_config),n.customConfig=C(o.custom_config),n.baseColor1=o.base_color_1??"",n.baseColor2=o.base_color_2??"",n.borderColor=o.border_color??"",n.highlightColor=o.highlight_color??"",n.titleColor=o.title_color??"",n.textColor=o.text_color??"")},$=o=>Array.isArray(o)?o.map((e,d)=>({id:Number(e.id)||d+1,displayOrder:Number(e.display_order??e.displayOrder??e.weigh)||d+1,name:String(e.partner_name??e.name??""),currency:String(e.currency??""),logoImage:String(e.logo_image??e.logoImage??""),option:C(e.option),config:C(e.config),status:Number(e.status)===1?1:2})):[],T=async()=>{k.value=!0;try{const o=await ne(),e=o.data??o;M(e==null?void 0:e.partnership_setting),f.value=$(e==null?void 0:e.partner_data)}finally{k.value=!1}},E=o=>{if(!o.trim())return{};const e=JSON.parse(o);if(!e||Array.isArray(e)||typeof e!="object")throw new Error;return e},S=y(!1),z=async()=>{let o,e;try{o=E(n.footerConfig),e=E(n.customConfig)}catch{g.error(t("embed.partnership.invalidConfig"));return}S.value=!0;try{await se({header_image_url:n.headerImage,footer_config:o,custom_config:e,base_color_1:n.baseColor1,base_color_2:n.baseColor2,border_color:n.borderColor,highlight_color:n.highlightColor,title_color:n.titleColor,text_color:n.textColor}),await T()}finally{S.value=!1}},q=async()=>{try{await navigator.clipboard.writeText(I.value),g.success(t("embed.partnership.copied"))}catch{g.error(t("embed.partnership.copyFailed"))}};de(T);const v=y(!1),O=y("create"),U=y(),A=y(),c=j({displayOrder:0,name:"",currency:"AUD",logoImage:"",option:"",config:"",status:1}),F=pe(()=>({name:[{required:!0,message:t("embed.partnership.nameRequired"),trigger:"blur"}],currency:[{required:!0,message:t("embed.partnership.currencyRequired"),trigger:"blur"}]})),B=(o,e)=>{O.value=o,U.value=e==null?void 0:e.id,Object.assign(c,e??{displayOrder:f.value.length+1,name:"",currency:"AUD",logoImage:"",option:"",config:"",status:1}),v.value=!0},G=async()=>{var o;if(await((o=A.value)==null?void 0:o.validate().catch(()=>!1))){try{c.option&&JSON.parse(c.option),c.config&&JSON.parse(c.config)}catch{g.error(t("embed.partnership.invalidPartnerConfig"));return}if(O.value==="create"){const e=Math.max(0,...f.value.map(d=>d.id))+1;f.value.push({id:e,...c})}else{const e=f.value.findIndex(d=>d.id===U.value);e>=0&&(f.value[e]={id:U.value,...c})}f.value.sort((e,d)=>e.displayOrder-d.displayOrder),v.value=!1,g.success(t("embed.partnership.operationSuccess"))}},W=async o=>{try{await D.confirm(t("embed.partnership.deleteConfirm",{name:o.name}),t("embed.partnership.warning"),{type:"warning",confirmButtonText:t("embed.partnership.confirm"),cancelButtonText:t("embed.partnership.cancel")}),f.value=f.value.filter(e=>e.id!==o.id),g.success(t("embed.partnership.deleted"))}catch{return}},H=()=>{const o=new Blob([JSON.stringify(f.value,null,2)],{type:"application/json"}),e=URL.createObjectURL(o),d=document.createElement("a");d.href=e,d.download="partner-data.json",d.click(),URL.revokeObjectURL(e),g.success(t("embed.partnership.exported"))},Z=async o=>{if(o.raw)try{const e=JSON.parse(await o.raw.text());if(!Array.isArray(e))throw new Error("Invalid partner data");const d=e.map((p,w)=>({id:Number(p.id)||w+1,displayOrder:Number(p.displayOrder)||w+1,name:String(p.name??""),currency:String(p.currency??""),logoImage:String(p.logoImage??""),option:typeof p.option=="string"?p.option:JSON.stringify(p.option??{}),config:typeof p.config=="string"?p.config:JSON.stringify(p.config??{}),status:Number(p.status)===2?2:1}));await D.confirm(t("embed.partnership.importConfirm",{total:d.length}),t("embed.partnership.warning"),{type:"warning",confirmButtonText:t("embed.partnership.confirm"),cancelButtonText:t("embed.partnership.cancel")}),f.value=d,g.success(t("embed.partnership.imported"))}catch(e){if(e==="cancel"||e==="close")return;g.error(t("embed.partnership.importFailed"))}};return(o,e)=>{const d=u("el-input"),p=u("el-button"),w=u("el-color-picker"),h=u("el-table-column"),X=u("el-tag"),Y=u("el-table"),K=u("el-upload"),Q=u("el-input-number"),_=u("el-form-item"),R=u("el-option"),ee=u("el-select"),te=u("el-form"),ae=u("el-dialog"),re=fe("loading");return ce((x(),V("div",be,[i("section",ge,[i("div",he,[i("div",ye,m(l(t)("embed.partnership.settingTitle")),1),i("div",_e,[i("div",ve,[i("label",null,m(l(t)("embed.partnership.headerImage"))+":",1),a(d,{modelValue:n.headerImage,"onUpdate:modelValue":e[0]||(e[0]=r=>n.headerImage=r),placeholder:"e.g. https://image.png"},null,8,["modelValue"])]),i("div",Ce,[i("label",null,m(l(t)("embed.partnership.footerConfig"))+":",1),a(d,{modelValue:n.footerConfig,"onUpdate:modelValue":e[1]||(e[1]=r=>n.footerConfig=r),type:"textarea",rows:8,placeholder:P,resize:"vertical"},null,8,["modelValue"])]),i("div",we,[e[16]||(e[16]=i("label",null,null,-1)),a(p,{size:"small",onClick:e[2]||(e[2]=r=>n.footerConfig=P)},{default:s(()=>[b(m(l(t)("embed.partnership.loadTemplate")),1)]),_:1})]),i("div",Ve,[i("label",null,m(l(t)("embed.partnership.customConfig"))+":",1),a(d,{modelValue:n.customConfig,"onUpdate:modelValue":e[3]||(e[3]=r=>n.customConfig=r),type:"textarea",rows:7,placeholder:J,resize:"vertical"},null,8,["modelValue"])]),i("div",xe,[e[17]||(e[17]=i("label",null,null,-1)),a(p,{size:"small",onClick:e[4]||(e[4]=r=>n.customConfig=J)},{default:s(()=>[b(m(l(t)("embed.partnership.loadTemplate")),1)]),_:1})]),i("div",Ie,[(x(),V(me,null,ue(L,r=>i("div",{key:r.key,class:"color-item"},[i("label",null,m(l(t)(r.label))+":",1),a(w,{modelValue:n[r.key],"onUpdate:modelValue":N=>n[r.key]=N},null,8,["modelValue","onUpdate:modelValue"]),i("span",null,m(n[r.key]),1)])),64))]),a(p,{type:"success",class:"save-button",loading:S.value,onClick:z},{default:s(()=>[b(m(l(t)("embed.partnership.save")),1)]),_:1},8,["loading"])])]),i("div",ke,[i("div",Se,m(l(t)("embed.partnership.embedCode")),1),i("div",Oe,[a(d,{modelValue:I.value,"onUpdate:modelValue":e[5]||(e[5]=r=>I.value=r),type:"textarea",rows:19,readonly:"",resize:"none"},null,8,["modelValue"]),a(p,{class:"copy-button",onClick:q},{default:s(()=>[b(m(l(t)("embed.partnership.copyCode")),1)]),_:1})])])]),i("section",Ue,[i("div",Ne,m(l(t)("embed.partnership.dataTitle")),1),i("div",Pe,[a(Y,{data:f.value,border:"","empty-text":l(t)("embed.partnership.empty")},{default:s(()=>[a(h,{prop:"displayOrder",label:l(t)("embed.partnership.displayOrder"),width:"140"},null,8,["label"]),a(h,{prop:"name",label:l(t)("embed.partnership.partnerName"),"min-width":"180"},null,8,["label"]),a(h,{prop:"currency",label:l(t)("embed.partnership.currency"),width:"130"},null,8,["label"]),a(h,{label:l(t)("embed.partnership.logoImage"),"min-width":"240"},{default:s(({row:r})=>[r.logoImage?(x(),V("a",{key:0,class:"image-link",href:r.logoImage,target:"_blank",rel:"noopener noreferrer"},m(r.logoImage),9,Te)):(x(),V("span",Ee,"-"))]),_:1},8,["label"]),a(h,{prop:"option",label:l(t)("embed.partnership.option"),"min-width":"180","show-overflow-tooltip":""},null,8,["label"]),a(h,{prop:"config",label:l(t)("embed.partnership.config"),"min-width":"220","show-overflow-tooltip":""},null,8,["label"]),a(h,{label:l(t)("embed.partnership.status"),width:"110",align:"center"},{default:s(({row:r})=>[a(X,{type:r.status===1?"success":"info",effect:"plain"},{default:s(()=>[b(m(r.status===1?l(t)("embed.partnership.active"):l(t)("embed.partnership.inactive")),1)]),_:2},1032,["type"])]),_:1},8,["label"]),a(h,{label:l(t)("embed.partnership.action"),width:"150",fixed:"right"},{default:s(({row:r})=>[a(p,{link:"",type:"primary",onClick:N=>B("edit",r)},{default:s(()=>[b(m(l(t)("embed.partnership.edit")),1)]),_:2},1032,["onClick"]),a(p,{link:"",type:"danger",onClick:N=>W(r)},{default:s(()=>[b(m(l(t)("embed.partnership.delete")),1)]),_:2},1032,["onClick"])]),_:1},8,["label"])]),_:1},8,["data","empty-text"])])]),i("div",Ae,[a(p,{type:"success",class:"create-button",onClick:e[6]||(e[6]=r=>B("create"))},{default:s(()=>[b(m(l(t)("embed.partnership.create")),1)]),_:1}),a(p,{type:"primary",onClick:H},{default:s(()=>[b(m(l(t)("embed.partnership.export")),1)]),_:1}),a(K,{accept:".json,application/json","auto-upload":!1,"show-file-list":!1,"on-change":Z},{default:s(()=>[a(p,{type:"warning"},{default:s(()=>[b(m(l(t)("embed.partnership.import")),1)]),_:1})]),_:1})]),a(ae,{modelValue:v.value,"onUpdate:modelValue":e[15]||(e[15]=r=>v.value=r),title:O.value==="create"?l(t)("embed.partnership.createTitle"):l(t)("embed.partnership.editTitle"),width:"600px","destroy-on-close":""},{footer:s(()=>[a(p,{onClick:e[14]||(e[14]=r=>v.value=!1)},{default:s(()=>[b(m(l(t)("embed.partnership.cancel")),1)]),_:1}),a(p,{type:"primary",onClick:G},{default:s(()=>[b(m(l(t)("embed.partnership.confirm")),1)]),_:1})]),default:s(()=>[a(te,{ref_key:"formRef",ref:A,model:c,rules:F.value,"label-position":"top"},{default:s(()=>[i("div",Be,[a(_,{label:l(t)("embed.partnership.displayOrder"),prop:"displayOrder"},{default:s(()=>[a(Q,{modelValue:c.displayOrder,"onUpdate:modelValue":e[7]||(e[7]=r=>c.displayOrder=r),min:0},null,8,["modelValue"])]),_:1},8,["label"]),a(_,{label:l(t)("embed.partnership.currency"),prop:"currency"},{default:s(()=>[a(d,{modelValue:c.currency,"onUpdate:modelValue":e[8]||(e[8]=r=>c.currency=r),placeholder:"AUD"},null,8,["modelValue"])]),_:1},8,["label"])]),a(_,{label:l(t)("embed.partnership.partnerName"),prop:"name"},{default:s(()=>[a(d,{modelValue:c.name,"onUpdate:modelValue":e[9]||(e[9]=r=>c.name=r)},null,8,["modelValue"])]),_:1},8,["label"]),a(_,{label:l(t)("embed.partnership.logoImage"),prop:"logoImage"},{default:s(()=>[a(d,{modelValue:c.logoImage,"onUpdate:modelValue":e[10]||(e[10]=r=>c.logoImage=r),placeholder:"https://image.png"},null,8,["modelValue"])]),_:1},8,["label"]),a(_,{label:l(t)("embed.partnership.option")},{default:s(()=>[a(d,{modelValue:c.option,"onUpdate:modelValue":e[11]||(e[11]=r=>c.option=r),type:"textarea",rows:3,placeholder:"{}"},null,8,["modelValue"])]),_:1},8,["label"]),a(_,{label:l(t)("embed.partnership.config")},{default:s(()=>[a(d,{modelValue:c.config,"onUpdate:modelValue":e[12]||(e[12]=r=>c.config=r),type:"textarea",rows:3,placeholder:"{}"},null,8,["modelValue"])]),_:1},8,["label"]),a(_,{label:l(t)("embed.partnership.status")},{default:s(()=>[a(ee,{modelValue:c.status,"onUpdate:modelValue":e[13]||(e[13]=r=>c.status=r)},{default:s(()=>[a(R,{label:l(t)("embed.partnership.active"),value:1},null,8,["label"]),a(R,{label:l(t)("embed.partnership.inactive"),value:2},null,8,["label"])]),_:1},8,["modelValue"])]),_:1},8,["label"])]),_:1},8,["model","rules"])]),_:1},8,["modelValue","title"])])),[[re,k.value]])}}}),Me=le(Re,[["__scopeId","data-v-1ad219de"]]);export{Me as default};
