인터뷰에서 방향만 정하고 남겨 뒀던 후속 5건을 구현하고, 커밋 전 종합 점검에서 발견한 결함 2건을 함께 고쳤다. 기능 도입: - 업로드 이미지 축소 — `upload.image_max_width` / `image_max_height` / `image_quality` 는 저장·검증만 되고 리사이즈 코드가 0건이었다. 비율 유지, 상한 이내면 재인코딩하지 않음(불필요한 화질 손실 방지), 한계 미설정이면 무동작(기존 사이트 이미지 보호). PNG·GIF·WebP 투명도 보존. 실패해도 업로드는 계속되고 원본이 저장된다. - 로그인 2단계 인증 — `security.two_factor_auth` 는 설정 항목만 있고 구현도 화면 컨트롤도 없었다. 코어 IDV 인프라를 재사용해 purpose `login` 을 추가하고, 비밀번호 확인 통과 후 challenge 만 발행한다(토큰 미발급 + logout). `POST /api/auth/login/two-factor` 가 코드를 확인해야 토큰이 나가며, 로그인과 같은 요청 제한을 적용한다. challenge 의 purpose 를 대조해 다른 흐름의 challenge 로 로그인하는 것을 막는다. 코드 발송이 실패하면 실패로 알린다 — 2단계를 건너뛰고 로그인시키면 통제가 조용히 열린다. 결함 수정: - 게시글 수정 시 사용자 경로가 `attachment_ids` 를 Service 로 넘기지 않아, 검증과 권한은 통과하고 200 을 받는데 첨부만 조용히 연결되지 않았다. 관리자 경로는 넘기고 있어 같은 요청이 화면에 따라 다르게 동작했다. - 설정 화면 라디오가 `pointer-events-none` + Label click 으로만 상태를 바꿔, 키보드 방향키(change) 조작 시 화면 표시와 저장될 값이 어긋났다. 동일 패턴 4개 레이아웃 12개 라디오에 change 액션을 부여하고 params 를 click 과 동일하게 고정한다. - 주문완료 화면이 결제수단 확인보다 영수증 조회를 앞세워, PG 를 거치지 않는 주문에서도 매번 404 요청이 나갔다. - 개별 게시판 폼의 숫자 항목에 경계값 바인딩이 없어 환경설정 화면과 안내가 달랐다. 커밋 전 점검에서 발견: - 2단계 인증이 반쪽으로 들어가 있었다. enum 에 case 만 추가하고 코어 purpose 레지스트리와 ko/en 라벨을 빠뜨려, 목적 목록 API 에서 통째로 빠지고 `hasPurpose` 가 false 였으며 라벨 대신 i18n 키 원문이 반환됐다. 관리자가 이 목적의 메시지 템플릿·정책을 만들 수 없는 상태였다. 세 곳을 enum 기준으로 전수 대조하는 회귀 테스트를 함께 둔다. - 업로드 이미지 축소가 적용되지 않은 8번째 서비스(레이아웃 편집기 첨부)가 있었다. 열거형 커버리지 테스트는 내 조사 결과를 green 으로 고정할 뿐 전수를 증명하지 못한다 — 같은 규약을 조건으로 표현한 audit 룰이 첫 실행에서 검출했다. 재발 방지: - audit 룰 `upload-service-image-resize` (신규 업로드 서비스의 축소 누락 검출) - 트러블슈팅 사례 20 (코어 설정이 일부 경로에만 적용되는 증상의 진단 절차) - `sirsoft-ckeditor5` 의 코어 최소 요구 버전을 7.0.6 으로 상향 (신설 클래스 의존) 공개 이슈: gnuboard/g7
92 lines
41 KiB
JavaScript
92 lines
41 KiB
JavaScript
(function(){"use strict";const x="kginicis_pay_form_",R="__sirsoftKginicisReloadStandardPaySdk",w="__sirsoftKginicisMobilePaymentReturnPending";function oe(){if(typeof document>"u")return 0;const e=document.querySelectorAll(`form[id^="${x}"]`);return e.forEach(t=>t.remove()),e.length}function qe(){typeof window>"u"||(window[R]=!0)}function We(){if(typeof window>"u")return!1;const e=window,t=e[R]===!0;return delete e[R],t}function Ve(e){typeof window>"u"||typeof document>"u"||(window.INIStdPay=void 0,document.querySelectorAll(`script[src="${e}"], script[src*="/INIStdPay_third-party.js"]`).forEach(t=>t.remove()))}function ze(e=Date.now()){if(!(typeof window>"u"))try{window.sessionStorage.setItem(w,String(e))}catch{window[w]=e}}function M(){if(!(typeof window>"u")){try{window.sessionStorage.removeItem(w)}catch{}delete window[w]}}function ie(e=Date.now()){if(typeof window>"u")return!1;let t=null;try{const n=window.sessionStorage.getItem(w);t=n?Number(n):null}catch{t=null}if(!Number.isFinite(t)){const n=window[w];t=typeof n=="number"?n:Number(n)}return!Number.isFinite(t)||e-t>18e5?(M(),!1):!0}const N="sirsoft-pay_kginicis",Xe=N,Ze="payment-window-closed",ae="__sirsoftKginicisPaymentCloseListenerInstalled",L="__sirsoftKginicisActiveStandardPaymentCloseContext",se=20,Qe=100,O={info:(...e)=>console.info(`[${N}]`,...e),warn:(...e)=>console.warn(`[${N}]`,...e)};function et(e){if(!e||typeof e!="object")return!1;const t=e;return t.source===Xe&&t.type===Ze}function $(){return/\/shop\/checkout\/?$/.test(window.location.pathname)}function P(){return window}function tt(){const e=P()[L];return!e||typeof e!="object"?null:e}function nt(e){return/^https?:\/\//i.test(e)||e.startsWith("/api/")?e:e.startsWith("/plugins/")?`/api${e}`:e.startsWith("plugins/")?`/api/${e}`:e}function rt(e){e.closeReportUrl&&(P()[L]={...e,reported:!1})}function ce(){delete P()[L]}function de(){ce()}async function ot(e="payment-window-closed"){const t=tt();if(!t||t.reported||!$())return;t.reported=!0;const n={oid:t.oid,price:t.price,buyer_email:t.buyer_email??"",buyer_phone:t.buyer_phone??"",payment_method:t.payment_method??"",reason:e};try{const r=window.G7Core?.api;typeof r?.post=="function"?await r.post(t.closeReportUrl,n):await fetch(nt(t.closeReportUrl),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(n),keepalive:!0})}catch(r){O.warn("failed to report KG payment window close",{reason:e,error:r})}finally{ce()}}function le(e="payment-window-closed",t=!0){if(!$())return!1;const r=window.G7Core?.state?.setLocal;return typeof r!="function"?(t&&O.warn("G7Core.state.setLocal not available while resetting payment submit state"),!1):(oe(),qe(),r({isSubmittingOrder:!1}),O.info("checkout submit state reset after KG payment close",{reason:e}),!0)}function it(e,t=!1){let n=0;const r=()=>{if(n++,!(t&&!ie())){if(le(e,n>=se)){t&&M();return}!$()||n>=se||window.setTimeout(r,Qe)}};r()}function I(e){ie()&&it(e,!0)}function at(){if(typeof window>"u")return;const e=P();e[ae]||(window.addEventListener("message",t=>{t.origin===window.location.origin&&et(t.data)&&(ot(t.data.reason),le(t.data.reason))}),window.addEventListener("pagehide",()=>{de()}),window.addEventListener("beforeunload",()=>{de()}),window.addEventListener("pageshow",t=>{I(t.persisted?"mobile-payment-bfcache-return":"mobile-payment-page-show")}),window.addEventListener("focus",()=>{I("mobile-payment-window-focus")}),document.addEventListener("visibilitychange",()=>{document.visibilityState==="visible"&&I("mobile-payment-visibility-return")}),e[ae]=!0,I("mobile-payment-listener-installed"))}function ue(){if(typeof navigator>"u")return!1;const e=navigator;if(e.userAgentData?.mobile!==void 0)return e.userAgentData.mobile;const t=(e.userAgent||"").toLowerCase(),n=((e.userAgentData?.platform??e.platform)||"").toLowerCase();if(/android|iphone|ipad|ipod|windows phone|iemobile|blackberry|opera mini|mobile safari/.test(t)||/iphone|ipad|ipod|ios/.test(n))return!0;const r=e.maxTouchPoints??0;return/macintosh|mac os x/.test(t)&&r>1}function st(e){return new Promise((t,n)=>{if(document.querySelector(`script[src="${e}"]`)){t();return}const r=document.createElement("script");r.src=e,r.async=!0,r.onload=()=>t(),r.onerror=()=>n(new Error(`Failed to load script: ${e}`)),document.head.appendChild(r)})}function me(e,t){if(!t.startsWith("kginicis_"))return e;const n=new URL(e,window.location.origin);return n.searchParams.set("selectedPaymentMethod",t),n.toString()}function ct(e){const t=(e??"").trim().toUpperCase();return t===""||t==="WON"?"KRW":t}function fe(e,t,n="utf-8",r){const o=document.createElement("form");r&&(o.id=r),o.method="POST",o.action=e,o.acceptCharset=n,o.style.display="none";for(const[i,s]of Object.entries(t)){const a=document.createElement("input");a.type="hidden",a.name=i,a.value=s,o.appendChild(a)}document.body.appendChild(o),o.submit()}const dt={card:"Card",vbank:"VBank",bank:"DirectBank",phone:"HPP",kginicis_samsung_pay:"onlyssp",kginicis_naverpay:"onlynaverpay",kginicis_lpay:"onlylpay",kginicis_kakaopay:"onlykakaopay"},lt={card:"CARD",vbank:"VBANK",bank:"BANK",phone:"MOBILE"},ut={kginicis_samsung_pay:"d_samsungpay=Y",kginicis_naverpay:"d_npay=Y",kginicis_lpay:"d_lpay=Y",kginicis_kakaopay:"d_kakaopay=Y"},mt=["CARD","CVS","PAYpay"],pe={card:["CARD"],kginicis_japan_paypay:["PAYpay"],kginicis_japan_cvs:["CVS"]},ft=new Set(Object.keys(pe)),pt=new Set(["kginicis_samsung_pay","kginicis_naverpay","kginicis_lpay","kginicis_kakaopay"]);async function yt(e,t,n,r){const o=String(Math.floor(Date.now())),i=await e.api.post(t.callback_urls.mobile_signature,{oid:n.order_number,price:n.amount,timestamp:o,buyer_email:n.customer_email??"",buyer_phone:n.customer_phone??""}),{chkfake:s,mobile_payment_url:a}=i.data,c=me(window.location.origin+t.callback_urls.mobile_callback+"?orderId="+encodeURIComponent(n.order_number),r),u=ut[r],d=u!==void 0,l=d?a.replace(/\/smart\/[^/]+\/?$/,"/smart/wcard/"):a,m=lt[r]??"CARD",f=t.use_escrow?"below1000=Y&vbank_receipt=Y&useescrow=Y¢erCd=Y&amt_hash=Y":"below1000=Y&vbank_receipt=Y¢erCd=Y&amt_hash=Y",p=d?f.replace("&useescrow=Y","")+"&"+u:f,y={P_MID:t.mid,P_OID:n.order_number,P_AMT:String(n.amount),P_GOODS:n.order_name,P_UNAME:n.customer_name??"",P_MOBILE:n.customer_phone??"",P_EMAIL:n.customer_email??"",P_NEXT_URL:c,P_CHARSET:"utf8",P_TIMESTAMP:o,P_CHKFAKE:s,P_RESERVED:p};d?y.P_SKIP_TERMS="Y":y.P_INI_PAYMENT=m,m==="MOBILE"&&!d&&(y.P_HPP_METHOD="2"),m==="VBANK"&&!d&&(y.P_NOTI_URL=window.location.origin+t.callback_urls.mobile_vbank_notify),ze(),fe(l,y,"euc-kr",x+"mobile_"+Date.now())}async function _t(e,t,n,r){const o=String(Math.floor(Date.now())),i=await e.api.post(t.callback_urls.signature,{oid:n.order_number,price:n.amount,timestamp:o,buyer_email:n.customer_email??"",buyer_phone:n.customer_phone??""}),{signature:s,verification:a,mKey:c}=i.data;if(We()&&Ve(t.sdk_url),window.INIStdPay||await st(t.sdk_url),window.INIStdPay||await new Promise(p=>setTimeout(p,100)),!window.INIStdPay)throw new Error("INIStdPay SDK not available");const u=me(window.location.origin+t.callback_urls.callback,r),d=window.location.origin+t.callback_urls.close;oe();const l=x+Date.now(),m=document.createElement("form");m.id=l,m.method="POST",m.acceptCharset="euc-kr";const f={version:"1.0",mid:t.mid,oid:n.order_number,goodname:n.order_name,price:String(n.amount),currency:"WON",buyername:n.customer_name??"",buyeremail:n.customer_email??"",buyertel:n.customer_phone??"",timestamp:o,signature:s,verification:a,mKey:c,returnUrl:u,closeUrl:d,gopaymethod:dt[r]??"Card",acceptmethod:(()=>{const p=t.use_escrow?"useescrow:":"",y=t.use_credit_point?"CREDITCARD(Y):":"",h=r==="phone"?`HPP(1):${p}${y}centerCd(Y)`:`${p}${y}centerCd(Y)`;return r==="kginicis_samsung_pay"||r==="kginicis_naverpay"||r==="kginicis_lpay"||r==="kginicis_kakaopay"?h?`${h}:cardonly`:"cardonly":h})(),payViewType:"overlay",use_chkfake:"Y",charset:"UTF-8"};for(const[p,y]of Object.entries(f)){const h=document.createElement("input");h.type="hidden",h.name=p,h.value=y,m.appendChild(h)}document.body.appendChild(m),t.callback_urls.close_report&&rt({closeReportUrl:t.callback_urls.close_report,oid:n.order_number,price:Number(n.amount),buyer_email:n.customer_email??"",buyer_phone:n.customer_phone??"",payment_method:r}),window.INIStdPay.pay(l)}function ht(e=new Date){const t=n=>String(n).padStart(2,"0");return e.getFullYear().toString()+t(e.getMonth()+1)+t(e.getDate())+t(e.getHours())+t(e.getMinutes())+t(e.getSeconds())}function gt(e,t){const n=e.cbt_extra_data??{},o=(t?pe[t]:void 0)??n.payment?.paymethod??mt,i=window.location.origin+e.callback_urls.cbt_cvs_notify;return{...n,paymentUI:{language:"JP",...n.paymentUI??{}},payment:{...n.payment??{},paymethod:o,isMobile:ue()?"true":"false",cvs:{...n.payment?.cvs??{},notiUrl:i}}}}async function wt(e,t,n,r){const o=t.japan_mid,i=ht(),s=n.customer_email??"",a=n.customer_phone??"",c=await e.api.post(t.callback_urls.cbt_checkout_token,{oid:n.order_number,price:n.amount,buyer_email:s,buyer_phone:a}),{checkout_token:u}=c.data,d=await e.api.post(t.callback_urls.cbt_hash_data,{oid:n.order_number,price:n.amount,timestamp:i,buyer_email:s,buyer_phone:a,checkout_token:u}),{hash_data:l}=d.data,m=window.location.origin+t.callback_urls.cbt_callback+`?oid=${encodeURIComponent(n.order_number)}&selectedPaymentMethod=${encodeURIComponent(r??"card")}`;fe(t.callback_urls.cbt_auth_url,{cbtType:"JPPG",mid:o,timestamp:i,returnUrl:m,buyerName:n.customer_name??"",buyerTel:n.customer_phone??"",buyerEmail:n.customer_email??"",goodName:n.order_name,amount:String(n.amount),orderId:n.order_number,hashData:l,extraData:JSON.stringify(gt(t,r))})}async function bt(e,t){const{pgPaymentData:n,paymentMethod:r}=e.params||{};if(!n)return;const o=window.__templateApp?.globalState?._local,i=r??n.payment_method??o?.paymentMethod??"card",s=window.G7Core;try{const a=await s.api.get("/modules/sirsoft-ecommerce/payments/client-config/kginicis");if(!a.data)throw new Error("Failed to fetch KG Inicis client config");const c=a.data,u=ct(n.currency),d=u==="JPY",l=u==="KRW",m=i.startsWith("kginicis_japan_"),f=pt.has(i),p=c.japan_enabled&&!!c.japan_mid&&c.japan_configured!==!1,y=c.japan_restrict_jpy_payment_methods===!0;if(m&&!d)throw new Error("KG Inicis Japan payment methods require a JPY order.");if(f&&Array.isArray(c.easy_pay_enabled_methods)&&!c.easy_pay_enabled_methods.includes(i))throw new Error("Selected KG Inicis easy pay method is disabled.");if(!d&&!l)throw new Error("KG Inicis supports only KRW standard payments or JPY Japan CBT payments.");if(d&&!p)throw new Error("KG Inicis Japan CBT payment is not configured.");if(d&&y&&!ft.has(i))throw new Error("JPY orders can only use KG Inicis Japan CBT payment methods.");const h=ue();if(l&&c.standard_configured===!1)throw new Error("KG Inicis live standard payment is not configured.");if(l&&h&&c.mobile_configured===!1)throw new Error("KG Inicis live mobile payment is not configured.");d?await wt(s,c,n,i):h?await yt(s,c,n,i):await _t(s,c,n,i)}catch(a){const c=a instanceof Error?a.message:"Unknown error";s?.state?.setLocal?.({paymentErrorMessage:c,isSubmittingOrder:!1,paymentMethod:i}),s?.modal?.open?.("kginicis_payment_error_modal")}}const ye={requestPayment:bt},kt="sirsoft-pay_kginicis",Ct={info:(...e)=>console.info(`[${kt}]`,...e)};function Et(){Ct.info("order interceptor is a no-op — payment entry is dispatched via pg_payment_handler")}const St="sirsoft-pay_kginicis";function Pt(){return localStorage.getItem("auth_token")}function It(){try{const t=sessionStorage.getItem("g7_guest_order_token");if(t)return t}catch{}const e=window.G7Core?.state?.get?.("_global")?.guestOrderToken;return typeof e=="string"&&e!==""?e:null}async function _e(e,t){try{const n=await fetch(`/api/plugins/${St}/user/orders/${e}/receipt`,{headers:t,credentials:"same-origin"});return n.ok?{status:n.status,data:await n.json()}:{status:n.status,data:null}}catch{return{status:0,data:null}}}async function he(e){const t=Pt(),n=It(),r={Accept:"application/json"};t?r.Authorization=`Bearer ${t}`:n&&(r["X-Guest-Order-Token"]=n);const o=await _e(e,r);if(o.data||o.status!==401||!t)return{status:o.status,info:o.data};const i={Accept:"application/json"};n&&(i["X-Guest-Order-Token"]=n);const s=await _e(e,i);return{status:s.status,info:s.data}}async function v(e){return(await he(e)).info}function C(e){return e?e.receipt_url?!0:e.receipt_type==="cbt_confirmation"&&Array.isArray(e.receipt_fields)&&e.receipt_fields.length>0:!1}function A(e){return e?.receipt_view_label||"영수증 조회"}function vt(e){return e?.receipt_label||"영수증"}function ge(e){if(e.receipt_url){window.open(e.receipt_url,"kginicis_receipt","width=800,height=600,scrollbars=yes,resizable=yes");return}e.receipt_type==="cbt_confirmation"&&At(e)}function At(e){const t=window.open("","kginicis_receipt","width=800,height=700,scrollbars=yes,resizable=yes");if(!t)return;const n=e.receipt_title||"KG 이니시스 CBT 결제확인서",r=e.receipt_notice||"",o=(e.receipt_fields??[]).map(i=>`
|
|
<div class="row">
|
|
<dt>${E(i.label)}</dt>
|
|
<dd>${E(i.value)}</dd>
|
|
</div>
|
|
`).join("");t.document.open(),t.document.write(`<!doctype html>
|
|
<html lang="ko">
|
|
<head>
|
|
<meta charset="utf-8">
|
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
|
<title>${E(n)}</title>
|
|
<style>
|
|
body {
|
|
margin: 0;
|
|
padding: 32px;
|
|
background: #f8fafc;
|
|
color: #111827;
|
|
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
|
|
}
|
|
main {
|
|
max-width: 720px;
|
|
margin: 0 auto;
|
|
background: #fff;
|
|
border: 1px solid #e5e7eb;
|
|
border-radius: 8px;
|
|
padding: 28px;
|
|
box-shadow: 0 10px 30px rgba(15, 23, 42, .08);
|
|
}
|
|
h1 {
|
|
margin: 0 0 8px;
|
|
font-size: 22px;
|
|
line-height: 1.35;
|
|
}
|
|
.notice {
|
|
margin: 0 0 24px;
|
|
color: #4b5563;
|
|
font-size: 14px;
|
|
line-height: 1.6;
|
|
}
|
|
dl {
|
|
margin: 0;
|
|
border-top: 1px solid #e5e7eb;
|
|
}
|
|
.row {
|
|
display: grid;
|
|
grid-template-columns: 160px minmax(0, 1fr);
|
|
gap: 16px;
|
|
padding: 14px 0;
|
|
border-bottom: 1px solid #e5e7eb;
|
|
}
|
|
dt {
|
|
color: #6b7280;
|
|
font-size: 14px;
|
|
}
|
|
dd {
|
|
margin: 0;
|
|
color: #111827;
|
|
font-size: 14px;
|
|
font-weight: 600;
|
|
overflow-wrap: anywhere;
|
|
}
|
|
.actions {
|
|
margin-top: 24px;
|
|
text-align: right;
|
|
}
|
|
button {
|
|
border: 0;
|
|
border-radius: 6px;
|
|
background: #2563eb;
|
|
color: #fff;
|
|
padding: 10px 14px;
|
|
font-size: 14px;
|
|
cursor: pointer;
|
|
}
|
|
@media (max-width: 520px) {
|
|
body { padding: 16px; }
|
|
main { padding: 20px; }
|
|
.row { grid-template-columns: 1fr; gap: 6px; }
|
|
}
|
|
</style>
|
|
</head>
|
|
<body>
|
|
<main>
|
|
<h1>${E(n)}</h1>
|
|
${r?`<p class="notice">${E(r)}</p>`:""}
|
|
<dl>${o}</dl>
|
|
<div class="actions"><button type="button" onclick="window.print()">인쇄</button></div>
|
|
</main>
|
|
</body>
|
|
</html>`),t.document.close()}function E(e){return e.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}const D="sirsoft-pay_kginicis",we="__kginicisOrderShowInjectorInstalled",K="kginicis-mp-receipt-row",be=/^(?:\/mypage\/orders\/([^/]+)|\/shop\/guest\/orders\/([^/]+))$/,G=new Map;function Tt(e){try{const n=window.G7Core?.getState,i=n?.()?.currentDataContext?.order?.data;return i&&(i.order_number===e||i.id!==void 0&&String(i.id)===e)?i:null}catch{return null}}function xt(){const e=document.getElementById("order_payment_info_panel");if(e)return Array.from(e.children).find(r=>r.className?.includes("space-y"))??e;const t=Array.from(document.querySelectorAll("h3")).find(r=>{const o=r.textContent?.trim()??"";return o.includes("결제 정보")||/^Payment Information$/i.test(o)});if(!t)return null;const n=t.parentElement?.parentElement;return n?Array.from(n.children).find(r=>r.className?.includes("space-y"))??n:null}function Rt(e,t){if(!t)return!1;const n=Array.from(e.querySelectorAll("div"));for(const r of n){const o=Array.from(r.children).filter(a=>a instanceof HTMLElement&&a.tagName==="SPAN");if(o.length<2)continue;const i=o[0].textContent?.trim();if(i!=="결제 방법"&&i!=="결제수단"&&i!=="Payment Method")continue;const s=o[o.length-1];return s.textContent?.trim()===t?(r.dataset.kginicisPaymentMethodRow="true",!0):(s.textContent=t,s.dataset.kginicisPaymentMethodPatched="true",r.dataset.kginicisPaymentMethodRow="true",!0)}return!1}function Mt(e,t){const n=document.createElement("div");n.id=K,n.className="flex items-center justify-between",n.dataset.kginicisReceiptRow="mypage-order";const r=document.createElement("span");r.className="text-gray-500 dark:text-gray-400 text-sm",r.textContent=vt(t);const o=document.createElement("button");return o.type="button",o.dataset.kginicisReceiptButton="mypage-order",o.className="inline-flex items-center gap-1 text-sm text-blue-600 dark:text-blue-400 hover:underline disabled:opacity-50",o.textContent=A(t),o.addEventListener("click",async()=>{o.disabled=!0,o.textContent="로딩 중...";const i=await v(e);o.disabled=!1,o.textContent=A(i??t),C(i)&&ge(i)}),n.appendChild(r),n.appendChild(o),n}async function Nt(e,t){const n=Tt(e),r=n?.payment;if(r&&(r.pg_provider!=="kginicis"||!r.transaction_id))return!0;const o=n?.order_number??(t?e:null);if(!o)return!1;if(!t&&n&&!r)return!0;const i=xt();if(!i)return!1;const{status:s,info:a}=await he(o);if(!t&&s===404)return!0;const c=r?.payment_status==="paid",u=a?.receipt_type==="cbt_confirmation";if(r&&!c&&!u)return!0;if(!r&&!C(a))return!1;const d=Rt(i,a?.payment_method_display_label);return!document.getElementById(K)&&C(a)&&(i.appendChild(Mt(o,a)),console.info(`[${D}] receipt button injected on mypage order show`)),d&&console.info(`[${D}] payment method display patched on mypage order show`),!!(document.getElementById(K)||d)}function Lt(e,t){if(G.has(e))return;let n=0;const r=window.setInterval(()=>{n++,Nt(e,t).then(o=>{(o||n>=30)&&(window.clearInterval(r),G.delete(e))})},400);G.set(e,r)}function Ot(){const e=location.pathname.match(be);if(e){const t=e[1],n=e[2],r=t??n;r&&Lt(r,n!==void 0)}}function $t(){if(typeof window>"u")return;const e=window;if(e[we])return;e[we]=!0,console.info(`[${D}] mypage order show injector installed`);let t=null;const n=(a=1500)=>{t!==null&&window.clearTimeout(t),t=window.setTimeout(()=>{t=null,Ot()},a)};document.readyState==="loading"?document.addEventListener("DOMContentLoaded",()=>n()):n();const r=history.pushState.bind(history);history.pushState=(...a)=>{r(...a),n(600)};const o=history.replaceState.bind(history);history.replaceState=(...a)=>{o(...a),n(600)},window.addEventListener("popstate",()=>n(500));const i=document.getElementById("app")??document.body;new MutationObserver(()=>{be.test(location.pathname)&&n(250)}).observe(i,{childList:!0,subtree:!0})}const j="sirsoft-pay_kginicis",ke="__kginicisAdminPaymentDisplayInjectorInstalled",Dt=/^\/admin\/ecommerce\/orders\/([^/]+)$/;function Kt(){return localStorage.getItem("auth_token")}async function Gt(e){const t=Kt();if(!t)return null;try{const n=await fetch(`/api/plugins/${j}/admin/orders/${e}/transaction-status`,{headers:{Authorization:`Bearer ${t}`,Accept:"application/json"}});if(!n.ok)return null;const r=await n.json();return("data"in r?r.data:r)??null}catch{return null}}function jt(e){return Array.from(e.children).filter(t=>t instanceof HTMLElement)}function Yt(e,t){let n=!1;const r=Array.from(e.querySelectorAll("div"));for(const o of r){const i=jt(o),s=i.findIndex(l=>l.textContent?.trim()==="결제수단");if(s<0)continue;const a=i.slice(s+1).find(l=>l.textContent?.trim()&&l.textContent.trim()!=="결제수단");if(!a)continue;const c=i.slice(s+2).find(l=>/^\(.+\)$/.test(l.textContent?.trim()??"")),u=c?.textContent?.trim().replace(/^\(|\)$/g,"")??"",d=u&&t.endsWith(")")?t.replace(/\)$/,`, ${u})`):t;a.textContent?.trim()!==d&&(a.textContent=d,a.dataset.kginicisPaymentMethodPatched="true"),o.dataset.kginicisPaymentMethodRow="admin-order",c&&u&&(c.textContent="",c.style.display="none",c.dataset.kginicisPaymentInstallmentHidden="true"),n=!0}return n}function Bt(e,t,n){const o=Array.from(e.querySelectorAll("span")).filter(i=>i.textContent?.trim()===t).find(i=>{const s=typeof i.className=="string"?i.className:"";return s.includes("rounded-full")||s.includes("font-medium")});return o?(o.textContent=n,o.dataset.kginicisPaymentMethodPatched="true",o.dataset.kginicisPaymentMethodBadge="admin-order",!0):!1}function Ut(e,t){const n=t?._pay_method_label,r=t?._embedded_pg_provider_label,o=t?._base_pay_method_label;if(!n||!r)return!1;const i=Yt(e,n),s=o?Bt(e,o,r):!1;return i||s}async function Ht(e){const t=document.getElementById("section_payment_info")??document.getElementById("payment_info_card");if(!t)return!1;const n=await Gt(e);return n&&Ut(t,n)&&console.info(`[${j}] payment method display patched on admin order detail`),!0}function Jt(e){let t=0;const n=setInterval(()=>{t++,Ht(e).then(r=>{(r||t>=30)&&clearInterval(n)})},400)}function Ft(){const e=location.pathname.match(Dt);e&&Jt(e[1])}function qt(){if(typeof window>"u")return;const e=window;if(e[ke])return;e[ke]=!0,console.info(`[${j}] admin order payment display injector installed`);const t=(r=1500)=>setTimeout(Ft,r);document.readyState==="loading"?document.addEventListener("DOMContentLoaded",()=>t()):t();const n=history.pushState.bind(history);history.pushState=(...r)=>{n(...r),t(600)},window.addEventListener("popstate",()=>t(500))}const Ce="sirsoft-pay_kginicis",Ee="__kginicisOcReceiptInjectorInstalled",Se="kginicis-oc-receipt-btn",Wt=/^\/shop\/orders\/([^/]+)\/complete$/;function Vt(){return localStorage.getItem("auth_token")}function zt(){try{const t=sessionStorage.getItem("g7_guest_order_token");if(t)return t}catch{}const e=window.G7Core?.state?.get?.("_global")?.guestOrderToken;return typeof e=="string"&&e!==""?e:null}async function Xt(e){const t=Vt(),n=zt();if(!t&&!n)return null;const r={Accept:"application/json"};t?r.Authorization=`Bearer ${t}`:n&&(r["X-Guest-Order-Token"]=n);try{const o=await fetch(`/api/modules/sirsoft-ecommerce/user/orders/${e}`,{headers:r});return o.ok?(await o.json())?.data?.payment??null:null}catch{return null}}function Zt(e){if(!e)return!1;const t=Array.from(document.querySelectorAll("div"));for(const n of t){const r=Array.from(n.children).filter(s=>s instanceof HTMLElement&&s.tagName==="SPAN");if(r.length<2)continue;const o=r[0].textContent?.trim();if(o!=="결제 방법"&&o!=="결제수단"&&o!=="결제 방식")continue;const i=r[r.length-1];return i.textContent?.trim()===e?(n.dataset.kginicisPaymentMethodRow="true",!0):(i.textContent=e,i.dataset.kginicisPaymentMethodPatched="true",n.dataset.kginicisPaymentMethodRow="true",!0)}return!1}async function Qt(e){if(document.getElementById(Se))return;const t=await Xt(e);if(t&&(t.pg_provider!=="kginicis"||!t.transaction_id))return;const n=await v(e);if(!C(n))return;if(t){const a=t.payment_status==="paid",c=n.receipt_type==="cbt_confirmation";if(!a&&!c)return}Zt(n.payment_method_display_label);const r=Array.from(document.querySelectorAll('button[type="button"]')).find(a=>a.className.includes("bg-blue-600"));if(!r?.parentElement)return;const o=r.parentElement;o.dataset.kginicisReceiptContainer="order-complete";const i=document.createElement("button");i.id=Se,i.type="button",i.dataset.kginicisReceiptButton="order-complete",i.className=r.className.replace(/bg-blue-\d+/g,"bg-green-600").replace(/hover:bg-blue-\d+/g,"hover:bg-green-700"),i.textContent=A(n),i.addEventListener("click",async()=>{i.disabled=!0,i.textContent="로딩 중...";const a=await v(e);i.disabled=!1,i.textContent=A(a??n),C(a)&&ge(a)});const s=o.lastElementChild;o.insertBefore(i,s),console.info(`[${Ce}] receipt button injected on order complete page`)}function en(){const e=location.pathname.match(Wt);e&&Qt(e[1])}function tn(){if(typeof window>"u")return;const e=window;if(e[Ee])return;e[Ee]=!0,console.info(`[${Ce}] order complete receipt injector installed`);const t=(r=1200)=>setTimeout(en,r);document.readyState==="loading"?document.addEventListener("DOMContentLoaded",()=>t()):t();const n=history.pushState.bind(history);history.pushState=(...r)=>{n(...r),t()},window.addEventListener("popstate",()=>t(500))}const Pe="sirsoft-pay_kginicis",Ie="__kginicisVbankInfoInjectorInstalled",Y="kginicis-mp-vbank-info",nn=/^\/shop\/orders\/([^/]+)\/complete$/,rn=/^\/mypage\/orders\/([^/]+)$/,on=/\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}[+\-]\d{2}:\d{2}/,an={"03":"기업은행","04":"국민은행","05":"외환은행","07":"수협중앙회",11:"농협중앙회",20:"우리은행",23:"SC 제일은행",31:"대구은행",32:"부산은행",34:"광주은행",37:"전북은행",39:"경남은행",53:"한국씨티은행",71:"우체국",81:"하나은행",88:"신한은행",89:"케이뱅크",90:"카카오뱅크",92:"토스뱅크",D1:"동양종합금융증권",D2:"현대증권",D3:"미래에셋증권",D4:"한국투자증권",D5:"우리투자증권",D6:"하이투자증권",D7:"HMC 투자증권",D8:"SK 증권",D9:"대신증권",DA:"하나대투증권",DB:"굿모닝신한증권",DC:"동부증권",DD:"유진투자증권",DE:"메리츠증권",DF:"신영증권"};function sn(e){if(e.vbank_code)return String(e.vbank_code);const t=(e.vbank_name??"").trim();if(!t)return null;for(const[n,r]of Object.entries(an))if(r===t)return n;return null}function cn(){try{const t=window.G7Core?.getState;return t?.()?.currentDataContext?._global?.currentUser?.is_admin===!0}catch{return!1}}function ve(e){try{return new Date(e).toLocaleString("ko-KR",{year:"numeric",month:"long",day:"numeric",hour:"2-digit",minute:"2-digit",timeZone:"Asia/Seoul"})}catch{return e}}function dn(){const e=document.createTreeWalker(document.body,NodeFilter.SHOW_TEXT),t=[];let n=e.nextNode();for(;n;){const r=n.textContent??"",o=r.match(on);o&&t.push({node:n,formatted:r.replace(o[0],ve(o[0]))}),n=e.nextNode()}for(const{node:r,formatted:o}of t)r.textContent=o}function ln(e){try{const n=window.G7Core?.getState,i=n?.()?.currentDataContext?.order?.data;return!i||i.order_number!==e?null:i}catch{return null}}function un(){const e=document.getElementById("order_payment_info_panel");if(e)return Array.from(e.children).find(r=>r.className?.includes("space-y"))??e;const t=Array.from(document.querySelectorAll("h3")).find(r=>r.textContent?.includes("결제 정보"));if(!t)return null;const n=t.parentElement?.parentElement;return n?Array.from(n.children).find(r=>r.className?.includes("space-y"))??n:null}function _(e,t,n=!1){const r=document.createElement("div");r.className="flex items-center justify-between";const o=document.createElement("span");o.className="text-gray-500 dark:text-gray-400 text-sm",o.textContent=e;const i=document.createElement("span");return i.className=n?"text-sm font-medium text-blue-600 dark:text-blue-400":"text-sm text-gray-900 dark:text-gray-100",i.textContent=t,r.appendChild(o),r.appendChild(i),r}function mn(e,t){const n=document.createElement("div");n.id=Y,n.className="mt-3 pt-3 border-t border-gray-200 dark:border-gray-700 space-y-2";const r=document.createElement("p");if(r.className="text-sm font-semibold text-gray-700 dark:text-gray-300",r.textContent="가상계좌 입금 안내",n.appendChild(r),e.vbank_name&&n.appendChild(_("은행",e.vbank_name)),cn()){const o=sn(e);o&&n.appendChild(_("은행코드",o))}return e.vbank_number&&n.appendChild(_("계좌번호",e.vbank_number)),e.vbank_holder&&n.appendChild(_("예금주",e.vbank_holder)),t&&n.appendChild(_("입금 기한",t,!0)),n}function g(e,t){return e?.receipt_fields?.find(n=>n.label===t)?.value??""}function fn(e,t){if(t?.receipt_type!=="cbt_confirmation")return!1;if(g(t,"결제수단").includes("편의점"))return!0;const r=String(e.transaction_id??"");return String(e.currency??"").toUpperCase()==="JPY"&&(String(e.vbank_name??"").toUpperCase()==="CVS"||r.startsWith("INIJPGCVS"))}function pn(e,t,n){const r=document.createElement("div");r.id=Y,r.className="mt-3 pt-3 border-t border-gray-200 dark:border-gray-700 space-y-2";const o=document.createElement("p");o.className="text-sm font-semibold text-gray-700 dark:text-gray-300",o.textContent="일본 편의점 입금 안내",r.appendChild(o);const i=g(t,"입금 상태"),s=g(t,"입금예정금액")||g(t,"결제금액"),a=g(t,"편의점 코드"),c=g(t,"편의점 확인번호")||String(e.vbank_number??""),u=g(t,"편의점 접수번호"),d=g(t,"입금 마감일시")||n;return i&&r.appendChild(_("상태",i)),s&&r.appendChild(_("입금예정금액",s,!0)),a&&r.appendChild(_("편의점 코드",a)),c&&r.appendChild(_("편의점 확인번호",c)),u&&r.appendChild(_("편의점 접수번호",u)),d&&r.appendChild(_("입금 마감일시",d,!0)),r}async function yn(e){const t=ln(e);if(!t)return!1;const{payment:n}=t;if(!n||n.pg_provider!=="kginicis"||n.payment_status!=="waiting_deposit"||!n.vbank_number||document.getElementById(Y))return!0;const r=un();if(!r)return!1;const o=await v(e),i=n.vbank_due_at?ve(n.vbank_due_at):"";return r.appendChild(fn(n,o)?pn(n,o,i):mn(n,i)),console.info(`[${Pe}] vbank info injected on mypage`),!0}function _n(e){let t=0;const n=setInterval(()=>{t++,yn(e).then(r=>{(r||t>=30)&&clearInterval(n)})},400)}function hn(){if(location.pathname.match(nn)){setTimeout(dn,500);return}const t=location.pathname.match(rn);t&&_n(t[1])}function gn(){if(typeof window>"u")return;const e=window;if(e[Ie])return;e[Ie]=!0,console.info(`[${Pe}] vbank info injector installed`);const t=(r=800)=>setTimeout(hn,r);document.readyState==="loading"?document.addEventListener("DOMContentLoaded",()=>t()):t();const n=history.pushState.bind(history);history.pushState=(...r)=>{n(...r),t(600)},window.addEventListener("popstate",()=>t(500))}const Ae="sirsoft-pay_kginicis",Te="__sirsoftKginicisCheckoutJpyPaymentMethodRestrictorInstalled",B=/^\/shop\/checkout\/?$/,wn="/api/modules/sirsoft-ecommerce/checkout",bn="/api/modules/sirsoft-ecommerce/settings/payment",kn="/api/modules/sirsoft-ecommerce/payments/client-config/kginicis",xe="__sirsoftKginicisCheckoutCurrency",U=new Set(["card","kginicis_japan_paypay","kginicis_japan_cvs"]),H=new Set(["kginicis_japan_paypay","kginicis_japan_cvs"]),Re=new Set(["card","vbank","dbank","bank","phone","kginicis_samsung_pay","kginicis_naverpay","kginicis_lpay","kginicis_kakaopay","kginicis_japan_paypay","kginicis_japan_cvs"]),Cn=[{id:"card",labels:["신용카드","Credit Card","クレジットカード"]},{id:"vbank",labels:["가상계좌","Virtual Account","バーチャル口座"]},{id:"dbank",labels:["무통장입금","Bank Transfer","銀行振込"]},{id:"bank",labels:["계좌이체","Account Transfer","口座振替"]},{id:"phone",labels:["휴대폰결제","Mobile Payment","携帯電話決済"]},{id:"kginicis_naverpay",labels:["네이버페이 (KG이니시스)","Naver Pay (KG Inicis)"]},{id:"kginicis_samsung_pay",labels:["삼성페이 (KG이니시스)","Samsung Pay (KG Inicis)"]},{id:"kginicis_lpay",labels:["L.pay (KG이니시스)","L.pay (KG Inicis)"]},{id:"kginicis_kakaopay",labels:["카카오페이 (KG이니시스)","Kakao Pay (KG Inicis)"]},{id:"kginicis_japan_paypay",labels:["PayPay (일본 KG이니시스)","PayPay (KG Inicis Japan)"]},{id:"kginicis_japan_cvs",labels:["일본 편의점결제 (KG이니시스)","Japan Convenience Store (KG Inicis)"]}],J={info:(...e)=>console.info(`[${Ae}]`,...e),warn:(...e)=>console.warn(`[${Ae}]`,...e)};let S=null,F=null,b=null;function q(){return window}function En(e){return typeof e=="string"?e:e instanceof URL?e.toString():typeof Request<"u"&&e instanceof Request?e.url:String(e)}function Sn(e,t){return t?.method?t.method.toUpperCase():typeof Request<"u"&&e instanceof Request?e.method.toUpperCase():"GET"}function Pn(e){try{return new URL(e,window.location.origin).pathname}catch{return e.split("?")[0].split("#")[0]}}function Me(e){if(typeof e!="string")return null;const t=e.trim().toUpperCase();return/^[A-Z]{3}$/.test(t)?t:null}function W(e,t){return t.split(".").reduce((n,r)=>{if(!(n===null||typeof n!="object"))return n[r]},e)}function In(e,t){for(const n of t){const r=Me(W(e,n));if(r)return r}return null}function vn(e){return In(e,["data.calculation.summary.selected_payment_currency","data.calculation.metadata.payment_currency","data.calculation.metadata.currency","data.currency","data.currency_code"])}function An(e){const t=vn(e);t&&(q()[xe]=t)}function Ne(){const e=q(),n=e.__templateApp?.globalState,r=[e[xe],n?.preferredCurrency];try{r.push(window.localStorage?.getItem("g7_preferred_currency"))}catch{}r.push(W(n,"modules.sirsoft-ecommerce.language_currency.default_currency"),W(n,"modules.sirsoft-ecommerce.language_currency.currencies.0.code"));for(const o of r){const i=Me(o);if(i)return i}return null}function V(){return B.test(window.location.pathname)&&Ne()==="JPY"}function z(){if(!B.test(window.location.pathname))return!1;const e=Ne();return e!==null&&e!=="JPY"}async function Le(e){return S!==null||(S=(async()=>{try{const t=await e(kn,{headers:{Accept:"application/json"}});return t.ok?(await t.json()).data?.japan_restrict_jpy_payment_methods===!0:!1}catch{return!1}})()),S}function Tn(e){const t=e.data?.order_settings?.payment_methods;return Array.isArray(t)?{...e,data:{...e.data,order_settings:{...e.data?.order_settings,payment_methods:t.map(n=>{const r=typeof n.id=="string"?n.id:"";return!Re.has(r)||U.has(r)?n:{...n,is_active:!1,_kginicis_restricted_for_jpy:!0}})}}}:e}function xn(e){const t=e.data?.order_settings?.payment_methods;return Array.isArray(t)?{...e,data:{...e.data,order_settings:{...e.data?.order_settings,payment_methods:t.map(n=>{const r=typeof n.id=="string"?n.id:"";return H.has(r)?{...n,is_active:!1,_kginicis_restricted_for_non_jpy:!0}:n})}}}:e}function Rn(e,t){const n=new Headers(e.headers);return n.set("Content-Type","application/json"),new Response(JSON.stringify(t),{status:e.status,statusText:e.statusText,headers:n})}function Mn(){const e=Array.from(document.querySelectorAll("h2")).find(n=>{const r=n.textContent??"";return r.includes("결제 수단")||r.includes("결제 방법")||r.includes("Payment Method")});if(!e)return null;let t=e.parentElement;for(;t&&t!==document.body;){if(t.tagName==="DIV"&&String(t.className).includes("rounded-lg"))return t;t=t.parentElement}return null}function Nn(e){const t=e.querySelector("p")?.textContent?.trim()??e.textContent?.trim()??"";for(const n of Cn)if(n.labels.some(r=>t.includes(r)))return n.id;return null}function X(){const e=V(),t=z();if(!e&&!t)return!1;const n=Mn();if(!n)return!1;let r=!1;if(n.querySelectorAll('button[type="button"]').forEach(o=>{const i=Nn(o);if(!i||!Re.has(i))return;if(e?U.has(i):!H.has(i)){o.style.removeProperty("display"),o.disabled=!1,o.removeAttribute("aria-hidden");return}o.style.display="none",o.disabled=!0,o.setAttribute("aria-hidden","true"),e?o.dataset.kginicisRestrictedForJpy="true":o.dataset.kginicisRestrictedForNonJpy="true",r=!0}),r)try{const i=window.G7Core?.state?.getLocal?.()?.paymentMethod;typeof i=="string"&&(e&&!U.has(i)||t&&H.has(i))&&window.G7Core?.state?.setLocal?.({paymentMethod:"card"})}catch{}return r}async function Oe(e){if(!B.test(window.location.pathname))return;const t=V(),n=z();if(!t&&!n||t&&!await Le(e))return;X(),F===null&&(F=new MutationObserver(()=>{X()}),F.observe(document.body,{childList:!0,subtree:!0})),b!==null&&clearInterval(b);let r=0;b=setInterval(()=>{r++,X(),r>=50&&b!==null&&(clearInterval(b),b=null)},200)}function $e(e){S=null,Oe(e)}function Ln(){if(typeof window>"u"||typeof window.fetch!="function")return;const e=q();if(e[Te])return;e[Te]=!0;const t=window.fetch.bind(window);window.fetch=async function(i,s){const a=En(i),c=Sn(i,s),u=Pn(a),d=await t(i,s);if(c==="GET"&&u.endsWith(wn)){try{const f=await d.clone().json();An(f)}catch{}return d}if(c!=="GET"||!u.endsWith(bn))return d;const l=V(),m=z();if(!l&&!m||l&&!await Le(t))return d;try{const f=await d.clone().json(),p=l?Tn(f):xn(f);return J.info(l?"restricted checkout payment methods for JPY order":"hid Japan-only payment methods for non-JPY order"),Rn(d,p)}catch(f){return J.warn("failed to restrict checkout payment methods",f),d}},J.info("checkout JPY payment method restrictor installed");const n=()=>{Oe(t)};document.readyState==="loading"?document.addEventListener("DOMContentLoaded",n):n();const r=history.pushState.bind(history);history.pushState=(...o)=>{r(...o),setTimeout(()=>$e(t),200)},window.addEventListener("popstate",()=>setTimeout(()=>$e(t),200))}const On="sirsoft-pay_kginicis",De="__kginicisAdminPaymentMethodBrandInjectorInstalled",Ke="__kginicisAdminPaymentMethodBrandSyncListenerAttached",$n=/^\/admin\/ecommerce\/settings\/?$/,Ge='[data-kginicis-admin-payment-brand-mark="true"]',Dn=200,Kn=120,Gn=[{id:"kginicis_naverpay",labels:["네이버페이 (KG이니시스)","Naver Pay (KG Inicis)"],shortLabels:[],markLines:["N","Pay"],markClassName:"bg-green-500 text-white"},{id:"kginicis_samsung_pay",labels:["삼성페이 (KG이니시스)","Samsung Pay (KG Inicis)"],shortLabels:[],markLines:["S","Pay"],markClassName:"bg-blue-700 text-white"},{id:"kginicis_lpay",labels:["L.pay (KG이니시스)","L.pay (KG Inicis)"],shortLabels:[],markLines:["L","pay"],markClassName:"bg-red-600 text-white"},{id:"kginicis_kakaopay",labels:["카카오페이 (KG이니시스)","Kakao Pay (KG Inicis)"],shortLabels:[],markLines:["Kakao","Pay"],markClassName:"bg-yellow-400 text-gray-950"},{id:"kginicis_japan_paypay",labels:["PayPay (일본 KG이니시스)","PayPay (KG Inicis Japan)"],shortLabels:[],markLines:["Pay","Pay"],markClassName:"bg-red-600 text-white"},{id:"kginicis_japan_cvs",labels:["일본 편의점결제 (KG이니시스)","Japan Convenience Store (KG Inicis)"],shortLabels:[],markLines:["CVS","JP"],markClassName:"bg-blue-600 text-white"}];let je=null,T=null,Z=!1;function jn(){return window}function Q(){if(!$n.test(window.location.pathname))return!1;const e=new URLSearchParams(window.location.search).get("tab");return e===null||e===""||e==="order_settings"}function Yn(e){return e instanceof HTMLElement?e.className:""}function Ye(e){return(e??"").replace(/\u200B/g,"").replace(/\s+/g," ").trim()}function Bn(e){const t=Yn(e);return t.includes("excel-card")||t.includes("flex-center")&&t.includes("border")&&t.includes("gap-4")}function Be(e){return e.querySelector(".font-medium")}function Un(e){const t=Ye(Be(e)?.textContent),n=Ye(e.textContent);return Gn.find(r=>r.shortLabels.some(o=>t===o)||r.labels.some(o=>n.includes(o)))??null}function Hn(e){return Array.from(e.querySelectorAll("div")).filter(Bn)}function Jn(e){return Array.from(e.querySelectorAll("svg, [data-icon], i")).find(n=>!n.closest("[data-drag-handle]")&&!n.closest(Ge)&&!n.closest('.row-stack, .excel-card-body, button, select, [role="switch"]'))??null}function Ue(e,t){e.dataset.kginicisAdminPaymentBrandMark="true",e.dataset.kginicisAdminPaymentMethod=t.id,e.setAttribute("aria-hidden","true"),e.className=`inline-flex items-center justify-center rounded-lg font-bold ${t.markClassName}`,e.style.width="32px",e.style.height="32px",e.style.flex="0 0 32px",e.style.flexDirection="column",e.style.lineHeight="1",e.style.fontSize="9px";const n=t.markLines.join("");e.textContent!==n&&(e.replaceChildren(),t.markLines.forEach(r=>{const o=document.createElement("span");o.style.lineHeight="1",o.textContent=r,e.appendChild(o)}))}function Fn(e){const t=document.createElement("span");return Ue(t,e),t}function qn(e,t){const n=e.querySelector(Ge);if(n instanceof HTMLSpanElement)return e.dataset.kginicisAdminPaymentMethod=t.id,Ue(n,t),!0;const r=Fn(t),o=Jn(e);if(o&&o.parentElement)return e.dataset.kginicisAdminPaymentMethod=t.id,o.replaceWith(r),!0;const i=Be(e);return i&&i.parentElement?(e.dataset.kginicisAdminPaymentMethod=t.id,i.parentElement.insertBefore(r,i),!0):!1}function ee(e=document){if(typeof window>"u"||typeof document>"u"||!Q())return!1;let t=!1;return Hn(e).forEach(n=>{const r=Un(n);r&&qn(n,r)&&(t=!0)}),t}function Wn(){Z||(Z=!0,window.setTimeout(()=>{Z=!1,ee()},0))}function te(){T!==null&&(window.clearInterval(T),T=null)}function ne(){if(!Q())return;te(),ee();let e=0;T=window.setInterval(()=>{e+=1,ee(),e>=Kn&&te()},Dn);const t=document.body;t[Ke]||(t[Ke]=!0,je=new MutationObserver(()=>Wn()),je.observe(document.body,{childList:!0,subtree:!0,characterData:!0}))}function He(){if(Q()){ne();return}te()}function Vn(){if(typeof window>"u"||typeof document>"u")return;const e=jn();if(e[De])return;e[De]=!0,console.info(`[${On}] admin payment method brand sync installed`),document.readyState==="loading"?document.addEventListener("DOMContentLoaded",()=>ne()):ne();const t=history.pushState.bind(history);history.pushState=(...n)=>{t(...n),window.setTimeout(()=>He(),200)},window.addEventListener("popstate",()=>window.setTimeout(()=>He(),200))}const k="sirsoft-pay_kginicis",re={info:(...e)=>console.info(`[${k}]`,...e),warn:(...e)=>console.warn(`[${k}]`,...e),error:(...e)=>console.error(`[${k}]`,...e)};function Je(){const e=window.G7Core;if(!e)return 0;const t=e.getActionDispatcher;if(typeof t!="function")return 0;const n=t();if(!n||typeof n.registerHandler!="function")return 0;let r=0;for(const[o,i]of Object.entries(ye)){const s=`${k}.${o}`;n.registerHandler(s,i,{category:"plugin",source:k}),r++}return r}function Fe(){const e=()=>{const t=Je();if(t>0){re.info(`${t} handler(s) registered`);return}let n=0;const r=50,o=setInterval(()=>{n++;const i=Je();if(i>0){clearInterval(o),re.info(`${i} handler(s) registered (after ${n} retries)`);return}n>=r&&(clearInterval(o),re.warn("ActionDispatcher not available after timeout"))},100)};document.readyState==="loading"?document.addEventListener("DOMContentLoaded",e):e()}Et(),Ln(),$t(),qt(),Vn(),tn(),gn(),at(),Fe(),window.__SirsoftKginicis={identifier:k,handlers:Object.keys(ye),initPlugin:Fe}})();
|
|
//# sourceMappingURL=plugin.iife.js.map
|