';const results=el('div','br-search-results'),status=el('p','br-search-status');status.setAttribute('aria-live','polite');dialog.append(close,title,form,status,results);document.body.append(dialog);
const input=$('input[type=search]',form);const find=q=>{const terms=q.toLocaleLowerCase().trim().split(/\s+/).filter(Boolean);return D.products.filter(p=>terms.every(t=>(p.name+' '+p.english+' '+p.sku+' '+D.categories[p.category]+' '+p.tags.join(' ')).toLocaleLowerCase().includes(t)));};
const renderQuick=()=>{const q=input.value.trim(),p=q?find(q):D.products.filter(p=>['82','62','103','61'].includes(p.id));results.replaceChildren(...p.slice(0,6).map(card));status.textContent=q?(p.length?p.length+'개 제품 · Enter를 누르면 전체 결과를 볼 수 있습니다.':'검색 결과가 없습니다. 제품명이나 품번을 다시 입력해 주세요.'):'자주 찾는 워크웨어';};
searchButton.addEventListener('click',()=>{renderQuick();dialog.showModal();input.focus();});input.addEventListener('input',renderQuick);close.addEventListener('click',()=>dialog.close());dialog.addEventListener('click',e=>{if(e.target===dialog){const r=dialog.getBoundingClientRect();if(e.clientXr.right||e.clientYr.bottom)dialog.close();}});
$$('a[href="https://koreca.net/"]').filter(a=>/상담/.test(a.textContent)).forEach(a=>a.href='https://www.koreca.co.kr/board/write?id=bulkorder');
const typeGrid=$('.shop-by-type .type-grid');if(typeGrid&&!$('.br-type-all',typeGrid)){const all=el('a','br-type-all');all.href='/default/mall/mall1.php?mode=list';all.setAttribute('aria-label','비즐리 전체 제품 보기');all.innerHTML='FIND YOUR BISLEY나의 다음 워크웨어.전체 제품 보기 ↗';typeGrid.append(all);}
const params=new URLSearchParams(location.search),list=$('.pd_wrap');
if(list){const current=params.get('cate_code')||'',grid=$('.pd_grid',list),toolbar=el('form','br-product-filters');if(document.body.classList.contains('br-product-hub')){document.body.classList.remove('br-product-hub');const cats=$('.pd_categories',list);if(cats){cats.replaceChildren(...[['','전체 제품'],...Object.entries(D.categories)].map(([code,label])=>{const li=el('li'),a=el('a',code===current?'is_active':'',label);a.href='/default/mall/mall1.php?mode=list'+(code?'&cate_code='+code:'');if(code===current)a.setAttribute('aria-current','page');li.append(a);return li;}));}}toolbar.setAttribute('aria-label','제품 검색과 필터');toolbar.innerHTML='';
const q=$('input[type=search]',toolbar);q.value=params.get('q')||'';const count=$('.br-count',list)||el('p','br-count');count.setAttribute('aria-live','polite');count.id='br-live-results';count.tabIndex=-1;const note=el('p','br-filter-note','핏은 본사 표기 기준이며, 입는 날은 반팔·쇼츠·보온 소재에 따른 선택 가이드입니다.');toolbar.id='br-catalogue-filters';const resultsBar=el('div','br-results-bar'),refineLink=el('a','br-refine-link','검색 조건 바꾸기 ↑');refineLink.href='#br-catalogue-filters';resultsBar.append(count,refineLink);const advanced=el('details','br-filter-details'),advancedTitle=el('summary',null,'핏 · 입는 날 · 기능 필터');advanced.open=matchMedia('(min-width:701px)').matches;advanced.append(advancedTitle,$('.br-filter-selects',toolbar),note);toolbar.append(advanced);const bp=matchMedia('(min-width:701px)');bp.addEventListener('change',e=>advanced.open=e.matches);grid?.before(toolbar,resultsBar);$$('.pd_paging,.paging,.page_wrap',list).forEach(e=>e.hidden=true);$$('a[href*="page="]').filter(a=>new URL(a.href).pathname===location.pathname).forEach(a=>{const table=a.closest('table');if(table)table.hidden=true;});
const render=()=>{let found=find(q.value).filter(p=>!current||p.category===current);const fit=$('[name=fit]',toolbar).value,season=$('[name=season]',toolbar).value,feature=$('[name=feature]',toolbar).value;found=found.filter(p=>(!fit||p.fit===fit)&&(!season||p.season===season)&&(!feature||p.tags.includes(feature)));if(grid){grid.replaceChildren(...found.map(p=>{const li=el('li');li.append(card(p));return li;}));if(!found.length){const li=el('li','br-no-results','조건에 맞는 제품이 없습니다. 검색어나 필터를 바꿔보세요.');grid.append(li);}}count.textContent=q.value.trim()?'“'+q.value.trim()+'” 검색 결과 · '+found.length+'개':(D.categories[current]||'전체 제품')+' · '+found.length+'개';const used=[fit,season,feature].filter(Boolean).length;advancedTitle.textContent='핏 · 입는 날 · 기능 필터'+(used?' · '+used+'개 적용':'');const url=new URL(location.href);if(q.value.trim())url.searchParams.set('q',q.value.trim());else url.searchParams.delete('q');url.searchParams.delete('page');history.replaceState(null,'',url);};
const goResults=()=>requestAnimationFrame(()=>{const header=$('.header'),r=header?.getBoundingClientRect(),shortcuts=$('.product-shortcuts',header||document),extra=shortcuts?.getBoundingClientRect();const offset=(r?Math.max(r.height,extra?.height?extra.bottom-r.top:r.height):100)+18;window.scrollTo({top:Math.max(0,count.getBoundingClientRect().top+window.scrollY-offset),behavior:'instant'});count.focus({preventScroll:true});});
toolbar.addEventListener('submit',e=>{e.preventDefault();render();goResults();});q.addEventListener('input',render);toolbar.addEventListener('change',render);$('[data-catalogue-reset]',toolbar).addEventListener('click',e=>{e.preventDefault();q.value='';$$('select',toolbar).forEach(s=>s.value='');render();});render();if(q.value.trim()){goResults();if(document.readyState!=='complete')window.addEventListener('load',goResults,{once:true});}
}
const product=D.products.find(p=>p.id===params.get('idx'));
if(product&&$('.prd_page')){
const p=product,h=$('#br-product-title');if(p.stockColours){for(const row of $$('.br-spec-row')){if($('dt',row)?.textContent.trim()==='색상')$('dd',row).textContent=p.stockColours.join(', ');}const photo=$('.br-gallery-main img');if(photo)photo.alt=p.name+' '+p.primaryColor+' 제품 사진';}if(h){h.textContent=p.name;h.setAttribute('aria-label',p.name+' '+p.sku);}const lead=$('.br-product-lead');if(lead)lead.textContent=p.english+' / '+p.sku;
document.title=p.name+' '+p.sku+' | BISLEY KOREA';const b2b=$('.b2b_now');if(b2b){b2b.href=p.quote;b2b.removeAttribute('onclick');}
const actions=$('.br-purchase-actions'),copy=el('button','br-copy-product','제품 정보 복사');copy.type='button';const copied=el('span','br-copy-status');copied.setAttribute('aria-live','polite');const copyText=p.name+' ('+p.sku+')\n제품: '+canonical(p)+'\n색상: \n사이즈: \n수량: ';copy.addEventListener('click',async()=>{try{await navigator.clipboard.writeText(copyText);copied.textContent='복사했습니다. 견적 양식에 붙여넣어 주세요.';}catch{copied.textContent='문의할 품번: '+p.sku;}});const helper=el('div','br-quote-helper');helper.append(copy,copied);actions?.after(helper);
const sticky=el('nav','br-mobile-purchase');sticky.setAttribute('aria-label','제품 구매와 견적');const stickyName=el('span',null,p.sku),quote=el('a','br-sticky-quote','견적 문의 ↗'),buy=el('a','br-sticky-buy','구매하기 ↗');quote.href=p.quote;buy.href=p.purchase;quote.target=buy.target='_blank';quote.rel=buy.rel='noopener';sticky.append(stickyName,quote,buy);document.body.append(sticky);document.body.classList.add('br-has-purchase-bar');
const guide=el('details','br-size-guide');guide.id='br-size-guide';const summary=el('summary',null,'사이즈 · 핏 가이드'),content=el('div','br-size-content');guide.append(summary,content);
const sizes=p.spec['사이즈']||'',isEU=p.sku.startsWith('E'),women=p.category==='CA100015',bottom=['CA100005','CA100006','CA100007'].includes(p.category),shirt=/셔츠/.test(p.name),accessory=p.category==='CA100016';
if(sizes)content.append(el('p','br-available-size','국내 안내 사이즈: '+sizes));
const fitNames={Modern:'모던 핏',Traditional:'트래디셔널 핏',Active:'액티브 핏'};if(p.fit)content.append(el('p','br-fit-copy','핏: '+fitNames[p.fit]+'. '+({Modern:'트래디셔널 핏보다 셔츠는 반 사이즈 작으며, 팬츠는 허리가 낮고 다리가 조금 더 슬림합니다.',Traditional:'작업 중 움직임을 위해 여유를 둔 핏입니다.',Active:'셔츠 기준 트래디셔널 핏보다 한 사이즈 작은 핏입니다.'}[p.fit])));
function table(headers,rows){const wrap=el('div','br-size-table');wrap.tabIndex=0;wrap.setAttribute('role','region');wrap.setAttribute('aria-label','사이즈 표, 가로로 스크롤할 수 있습니다');const t=el('table'),caption=el('caption',null,'공식 신체 치수 가이드 · cm');t.append(caption);const tr=el('tr');headers.forEach(x=>tr.append(el('th',null,x)));const thead=el('thead');thead.append(tr);t.append(thead);const tbody=el('tbody');rows.forEach(r=>{const tr=el('tr');r.forEach((x,i)=>{const cell=el(i===0?'th':'td',null,String(x));if(i===0)cell.scope='row';tr.append(cell)});tbody.append(tr)});t.append(tbody);wrap.append(t);content.append(wrap);}
if(accessory){content.append(el('p',null,/삭스/.test(p.name)?'양말은 위 국내 안내 사이즈의 발 길이(mm)를 기준으로 선택해 주세요.':'프리 사이즈 제품입니다. 착용 방식과 조절 범위는 상세 설명을 확인해 주세요.'));}
else if(isEU){content.append(el('p',null,'유럽 라인은 호주 사이즈 표와 체계가 다릅니다. 아래 인치 환산은 단위 참고값이며 제품 실측이나 권장 신체 치수가 아닙니다.'));if(bottom||/오버롤/.test(p.name)){table(['표기(in)','32','34','36'],[['단위 환산(cm)','81.3','86.4','91.4']]);$('caption',content).textContent='인치 단위 환산 참고 · 실측 아님';}content.append(el('p',null,'국내 판매처의 옵션과 제품별 상세 사이즈를 확인하거나, 품번과 평소 사이즈를 알려주시면 선택을 도와드립니다.'));}
else if(women){table(['AU 표기','6','8','10','12','14','16'],[['가슴둘레',80,85,90,95,100,105],['자연 허리둘레',60,65,70,75,80,85],['낮은 허리둘레',67,72,77,82,87,92],['엉덩이둘레',87,92,97,102,107,112]]);}
else if(bottom){table(['허리 표기(in)','28','30','32','34','36','38','40'],[['공식 표기(cm)',72,77,82,87,92,97,102]]);}
else if(['CA100014'].includes(p.category)){table(['AU 표기','77R','82R','87R','92R','97R','102R'],[['가슴둘레',87,92,97,102,107,112],['허리둘레',77,82,87,92,97,102]]);content.append(el('p',null,'커버올의 국내 숫자 옵션은 판매처에 대응 사이즈를 확인해 주세요.'));}
else{table(['표기','XS','S','M','L','XL','2XL'],[['가슴둘레',...(shirt?[81,89,97,105,113,121]:[87,92,97,102,107,112])],...(shirt?[['목둘레','36','37–38','39–40','41–42','43–44','46']]:[])]);}
if(!accessory&&!isEU)content.append(el('p','br-size-note','비즐리 공식 신체 치수 기준입니다. 완성된 옷의 실측이 아니며, 핏과 스타일에 따라 여유가 다릅니다. 국내 구매 가능 옵션은 구매처에서 확인해 주세요.'));
content.append(el('p','br-measure-copy',bottom?'허리는 속옷 위 자연스러운 허리선을 따라 수평으로 재어주세요.':'가슴은 팔을 내린 상태에서 가장 넓은 부분을 수평으로 재어주세요.'));const help=el('a',null,'사이즈 상담 ↗');help.href=p.quote;help.target='_blank';help.rel='noopener';content.append(help);$('.br-quote-helper')?.after(guide);
const jump=el('a',null,'사이즈 가이드 ↓');jump.href='#br-size-guide';jump.addEventListener('click',()=>guide.open=true);$('.br-product-links')?.append(jump);
if(p.variants.length){const options=el('div','br-color-options'),label=el('p',null,'컬러 사진'),buttons=el('div','br-color-buttons');options.append(label,buttons);const target=$('.br-gallery-main img')||$('.br-gallery-trigger img');let active=-1;function select(i){active=i;const v=p.variants[i];if(target){target.src=D.base+'assets/colour-photos/'+v.file;target.alt=p.name+' '+v.color+' 제품 사진';target.style.setProperty('transform','none');}label.textContent='컬러 사진 / '+v.color;$$('button',buttons).forEach((b,j)=>b.setAttribute('aria-pressed',String(i===j)));}
p.variants.forEach((v,i)=>{const b=el('button',null,v.color);b.type='button';b.setAttribute('aria-pressed','false');b.addEventListener('click',()=>select(i));buttons.append(b)});$('.br-gallery-meta')?.after(options);const initial=p.variants.findIndex(v=>v.color===p.primaryColor);if(initial>=0)select(initial);
const zoom=$('.br-gallery-open');if(zoom)zoom.addEventListener('click',e=>{if(active<0)return;e.stopImmediatePropagation();const modal=el('dialog','br-image-dialog br-variant-dialog'),close=el('button','br-image-close','×'),photo=el('img');close.type='button';close.setAttribute('aria-label','컬러 사진 닫기');photo.src=target.src;photo.alt=target.alt;modal.append(close,photo);document.body.append(modal);close.addEventListener('click',()=>modal.close());modal.addEventListener('close',()=>modal.remove());modal.showModal();},true);
}
}
// Main cards use the same source and SKU identity as list/detail.
$$('.collection .product').forEach(card=>{const a=$('a[href*="idx="]',card);if(!a)return;const p=D.products.find(p=>p.id===new URL(a.href).searchParams.get('idx'));if(!p)return;const title=$('.product-title',card);if(title)title.textContent=p.name;const img=$('.product-image img',card);if(img){img.src=imgURL(p);img.alt=p.name+' '+p.sku;img.style.setProperty('--main-product-scale',p.scale);img.style.setProperty('--main-product-mobile-scale',p.mobileScale);}const dot=$('.color-dot',card);if(dot){const label=p.primaryColor||'';dot.setAttribute('aria-label',label);dot.style.background={차콜:'#51545a',네이비:'#192b3c',스톤:'#b2a68f',카키:'#a39572',블랙:'#17191c',그레이:'#a9adb3'}[label];}});
const patchTitles=()=>$$('.bs26blog-card').forEach(card=>{const a=$('.bs26blog-card-link',card);if(!a)return;const p=D.articles.find(x=>x.id===new URL(a.href).searchParams.get('com_board_idx'));if(p){const title=$('.bs26blog-card-title',card);if(title)title.textContent=p.title;const excerpt=$('.bs26blog-card-summary',card);if(excerpt&&p.summary)excerpt.textContent=p.summary;const img=$('img',card);if(img){if(img.getAttribute('src')!==p.image)img.src=p.image;img.alt=p.title;img.style.setProperty('--journal-position',p.coverPosition||'50% 40%');img.width=960;img.height=720;}a.setAttribute('aria-label',p.title);}});patchTitles();const blogGrid=$('#bs26blogGrid');if(blogGrid)new MutationObserver(patchTitles).observe(blogGrid,{childList:true});
const brandChapters=$('.story-chapters');if(brandChapters&&D.heritageFilm){const archive=el('section','br-heritage-film');archive.id='br-brand-archive';archive.setAttribute('aria-labelledby','br-archive-title');const copy=el('div');copy.append(el('p','eyebrow','THE BISLEY ARCHIVE'),el('p','br-archive-number','60 years'));const h=el('h2',null,'시간이 쌓인 이름, 비즐리.');h.id='br-archive-title';copy.append(h,el('p',null,'1950년대 호주에서 시작된 비즐리. 옷의 쓰임을 생각해 온 브랜드의 시간을 공식 60주년 기념 영상으로 만나보세요.'));const figure=el('figure'),video=el('video');video.controls=true;video.playsInline=true;video.preload='none';video.poster=D.base+'assets/heritage.jpg';video.setAttribute('aria-label','비즐리 공식 60주년 기념 영상, 원본 영문');const source=el('source');source.src=D.base+D.heritageFilm.file;source.type='video/mp4';video.append(source,document.createTextNode('브라우저에서 영상을 재생할 수 없습니다.'));figure.append(video,el('figcaption',null,'BISLEY WORKWEAR / Celebrating 60 years · 공식 기념 영상 · 원본 영문'));archive.append(copy,figure);brandChapters.before(archive);if(location.hash==='#br-brand-archive'){const showArchive=()=>requestAnimationFrame(()=>archive.scrollIntoView({block:'start',behavior:'instant'}));showArchive();if(document.readyState!=='complete')window.addEventListener('load',showArchive,{once:true});}}
const roots=$('.brand-section .brand-copy')||$('.brand-section h2')?.parentElement;if(roots){const archiveLink=el('a','br-archive-link','공식 기념 영상으로 만나는 비즐리의 시간 ↗');archiveLink.href='/default/?view=brand#br-brand-archive';roots.append(archiveLink);}
const article=$('.board-view-wrap');if(article){const a=D.articles.find(x=>x.id===params.get('com_board_idx'));let related=a?.related.map(s=>D.products.find(p=>p.sku===s)).filter(Boolean)||[];if(!related.length){const text=$('.board-view-header-title',article)?.textContent||'';const category=/여성/.test(text)?'CA100015':/셔츠/.test(text)?'CA100002':/아우터|재킷|자켓/.test(text)?'CA100001':/레인|방수/.test(text)?'CA100014':'CA100005';related=D.products.filter(p=>p.category===category).slice(0,3);}const section=el('section','br-related-products'),k=el('p','eyebrow','EXPLORE THE WORKWEAR'),h=el('h2',null,'함께 살펴볼 제품'),grid=el('div','br-related-grid');related.slice(0,4).forEach(p=>grid.append(card(p)));section.append(k,h,grid);$('.br-article-end',article)?.before(section);}
const links=$('.footer-links');if(links&&!$('a[href="/default/?view=explore"]',links)){const a=el('a',null,'전체 제품·저널 안내 ↗');a.href='/default/?view=explore';links.prepend(a);}
})();
};if(document.readyState==='complete')bisleyEnhancementsStart();else document.addEventListener('DOMContentLoaded',bisleyEnhancementsStart,{once:true});