import{B as v,b as _,c as w,a as x}from"./game-ui-CVdoDJpA.js";const f=window,c={get board(){return f.board},set board(e){f.board=e}};function h(e,...t){var a;return(a=f[e])==null?void 0:a.call(f,...t)}v.prototype.create_div_open_save=function(){const e=c.board.div_endgame_movelist;e.style.width="50%";const t=document.createElement("div");var a="width:100%;";a+="position: relative;",a+="float: left;",t.setAttribute("style",a);const o=document.createElement("input");o.id="myfile",o.type="file",o.accept=".txt",o.onchange=()=>h("Open"),o.style.cssText="float: left;";const s=document.createElement("input");s.id="filename",s.type="text",s.style.cssText="float: left;",s.onclick=_,s.onblur=w;const i=document.createElement("input");i.id="submit",i.value="匯出指令",i.type="button",i.style.top="400px",i.onclick=g,i.style.cssText="float: left;";const l=document.createElement("input");l.id="submit_log",l.value="匯出BoardLog",l.type="button",l.style.top="400px",l.onclick=L,l.style.cssText="float: left;";const r=document.createElement("input");r.id="submit_init_log",r.value="匯出初始盤面",r.type="button",r.style.top="400px",r.onclick=C,r.style.cssText="float: left;",c.board.mode==x.History&&t.appendChild(o),t.appendChild(s),t.appendChild(i),t.appendChild(l),t.appendChild(r),e.appendChild(t),e.insertBefore(t,e.childNodes[0])};function B(){c.board.create_div_open_save();const e=c.board.div_endgame_movelist,t=document.createElement("textarea");t.id="user_info";var a="";a+="float: left;",a+="font-family: Courier New;",a+="position: relative;",t.setAttribute("style",a),t.style.width="100%",t.style.maxWidth="100%",t.style.resize="none",t.style.overflowX="scroll",t.style.overflowY="scroll",t.style.whiteSpace="nowrap",t.rows=20;const o=document.createElement("textarea");o.id="info_error",a="",a+="float: left;",a+="font-family: Courier New;",a+="position: relative;",o.setAttribute("style",a),o.style.width="100%",o.style.maxWidth="100%",o.style.resize="none",o.style.overflowX="scroll",o.style.overflowY="scroll",o.style.whiteSpace="nowrap",o.rows=20,e.appendChild(t),e.appendChild(o)}function g(){const e=c.board;if(e.his_openf=="")return;var t="",a=e.board_data.split("* ");/\n/.test(a[0])==!1;for(var o=1;o<5;o++)t+="* "+a[o]+e.os_type;for(var s=1,i=17,l=0;l<4;l++){t+="/start MJ "+((e.dealer+l&3)+1)+" AI"+e.os_type,t+="/initGame East East 1 "+(e.dealer+1)+" 0"+e.os_type,t+="/initCard ";for(var r=e.initalBoardData.split(" "),o=s;o<=i;o++)t+=r[o]+" ";l==0?s+=17:s+=16,i+=16,t+=e.os_type;for(var o=0;o<=e.his_step;o++){for(var n=e.actlist[o].split(" "),d=1;d<n.length-3;d++)if(!(n[1]=="/mo"&&n[2]!=(e.dealer+l&3)+1))if(n[1]=="/mo"){t+=n[1]+" "+n[3];break}else t+=n[d]+" ";n[1]=="/mo"&&n[2]!=(e.dealer+l&3)+1||(t+=e.os_type)}t+=e.os_type}t+="# #"+e.os_type,t+="# #"+e.os_type,t+="###"+e.os_type;var b=new Blob([t],{type:"text/plain;charset=utf-8"}),m=document.getElementById("filename").value,y;m!=""?y=m+".txt":y="board.txt";const u=window.URL.createObjectURL(b),p=document.createElement("a");p.style.display="none",p.href=u,p.download=y,document.body.appendChild(p),p.click(),window.URL.revokeObjectURL(u)}function L(){const e=c.board;if(e.his_openf=="")return;var t="",a=e.board_data.split("* ");console.log(e.board_data),/\n/.test(a[0])==!1;for(var o=1;o<=e.his_step+7;o++)t+="* "+a[o]+e.os_type;t+="* Comment 0 0",t+=e.os_type,e.acttime[0]=e.acttime[0].replace(/\r?\n/g,""),t+="0. "+e.acttime[0].split(e.split_str)[0].split(" ")[1]+e.os_type;for(var s=1,o=1;o<e.his_step+2;o++)e.acttime[o]=e.acttime[o].replace(/\r?\n/g,""),t+=s+". "+e.acttime[o].split(e.split_str)[0].split(" ")[1]+e.os_type,s++;t+="# #"+e.os_type,t+="# #"+e.os_type,t+="###"+e.os_type;var i=new Blob([t],{type:"text/plain;charset=utf-8"}),l=document.getElementById("filename").value,r;l!=""?r=l+".txt":r="board_Log.txt";const n=window.URL.createObjectURL(i),d=document.createElement("a");d.style.display="none",d.href=n,d.download=r,document.body.appendChild(d),d.click(),window.URL.revokeObjectURL(n)}function C(){const e=c.board;if(e.his_openf=="")return;var t="",a=e.board_data.split("* ");console.log(e.board_data),/\n/.test(a[0])==!1;for(var o=1;o<7;o++)t+="* "+a[o]+e.os_type;t+="* Comment 0 0",t+=e.os_type,e.acttime[0]=e.acttime[0].replace(/\r?\n/g,""),t+="0. "+e.acttime[0].split(e.split_str)[0].split(" ")[1]+e.os_type;var s=new Blob([t],{type:"text/plain;charset=utf-8"}),i=document.getElementById("filename").value,l;i!=""?l=i+".txt":l="InitBoard_Log.txt";const r=window.URL.createObjectURL(s),n=document.createElement("a");n.style.display="none",n.href=r,n.download=l,document.body.appendChild(n),n.click(),window.URL.revokeObjectURL(r)}export{B as a};
