PageSourceSearch

https://wedraw.kr/assets/WoodManagement.BWCLPcfy.js

js wedraw.kr collected 2026-10-04 07:43:45 UTC 115,507 bytes, 23 lines download raw bytes

1import{j as e}from"./vendor-ui.BwPBmVwt.js";import{r as g}from"./vendor-react.kR8tqwKZ.js";import{d as L}from"./vendor-utils.D2q0l15H.js";import{A as E}from"./AdminWriteGuard.xT1R3h4-.js";import{c as Ie,d as Se,e as De,u as ge,f as Fe,h as te,i as Re,j as Oe,k as Ee,l as We,m as Te,t as Ue,s as Be,n as he,o as re,p as Ge,q as Ve}from"./woodService.DVhONkSW.js";import{T as qe,a as Ke,b as ae,c as ne}from"./tabs.B_vF9hjw.js";import{P as ee}from"./plus.VSSFQhJP.js";import{P as Je}from"./package-check.CT9mT73v.js";import{P as ze}from"./package-x.DCQefjMU.js";import{P as Pe}from"./pen.DRMoMQWT.js";import{T as Me}from"./trash-2.DYInpbaD.js";import{s as Q,X as de,E as Xe,k as Ye}from"./index.86ltQqcV.js";import{W as Qe}from"./woodBrand.CS97CnMe.js";import{U as Ze}from"./upload.C9RE_zBD.js";import{C as U,a as B,c as G,b as V}from"./card.o7dQ1Cmv.js";import{B as J}from"./badge.FoetXalN.js";import{A as He}from"./arrow-up-right.DVkiG2vy.js";import{A as e0}from"./arrow-down-right.COTeQkiZ.js";import{M as s0}from"./minus.-470SVQC.js";import{D as t0,f as r0,c as pe}from"./lnWoods.CNKkeAwn.js";import{T as $e}from"./triangle-alert.DiFS_pz6.js";import{S as me}from"./save.DyDnqxYS.js";import{C as xe}from"./chevron-up.B4ORgOxs.js";import{C as ue}from"./chevron-down.8Oyg22r0.js";import{R as Le}from"./rotate-ccw.DzhI_qNN.js";import{H as Ae}from"./history.Bbo3PYMK.js";import{S as a0}from"./search.CoLV_vkF.js";import"./vendor-three.C5-HLXBy.js";function n0({categories:s,selectedCategoryId:n,onSelectCategory:c,onAddCategory:u}){return e.jsxs("div",{className:"bg-white rounded-lg shadow-sm border border-gray-200",children:[e.jsxs("div",{className:"flex items-center justify-between px-6 py-4 border-b border-gray-200",children:[e.jsx("h2",{className:"text-lg font-semibold text-gray-900",children:"카테고리"}),e.jsx(E,{children:e.jsxs("button",{onClick:u,className:"flex items-center gap-1.5 px-3 py-2 text-sm text-white bg-blue-600 hover:bg-blue-700 rounded-lg transition-colors",children:[e.jsx(ee,{className:"w-4 h-4"}),"카테고리 추가"]})})]}),e.jsxs("div",{className:"flex items-center gap-2 px-4 py-3 overflow-x-auto",children:[e.jsx("button",{onClick:()=>c(null),className:`
2            flex-shrink-0 px-4 py-2 rounded-lg text-sm font-medium transition-colors
3            ${n===null?"bg-blue-600 text-white":"bg-gray-100 text-gray-700 hover:bg-gray-200"}
4          `,children:"전체 보기"}),s.filter(d=>d.is_active).map(d=>{const t=n===d.id;return e.jsx("button",{onClick:()=>c(d.id),className:`
5                flex-shrink-0 px-4 py-2 rounded-lg text-sm font-medium transition-colors
6                ${t?"bg-blue-600 text-white":"bg-gray-100 text-gray-700 hover:bg-gray-200"}
7              `,children:d.name},d.id)})]})]})}function l0({item:s,category:n,onEdit:c,onDelete:u,onToggleSoldOut:d,onToggleThicknessSoldOut:t}){const l=s.texture_img||s.real_img||"/placeholder-wood.png",x=!!s.is_sold_out,h=s.thickness_type==="simple"?(s.thickness_simple??[]).map(j=>`${j}mm`):(s.thickness_detailed??[]).map(j=>j.label),b=new Set(s.sold_out_thicknesses??[]);return e.jsxs("div",{className:"bg-white border border-gray-200 rounded-lg overflow-hidden hover:shadow-md transition-shadow",children:[e.jsxs("div",{className:"aspect-video bg-gray-100 relative",children:[e.jsx("img",{src:l,alt:s.name,className:`w-full h-full object-cover ${x?"grayscale opacity-60":""}`,onError:j=>{j.currentTarget.src="/placeholder-wood.png"}}),n&&e.jsx("span",{className:"absolute top-2 left-2 px-2 py-1 bg-blue-600 text-white text-xs font-medium rounded",children:n.name}),x&&e.jsx("span",{className:"absolute top-2 right-2 px-2 py-1 bg-red-600 text-white text-xs font-bold rounded shadow",children:"품절"})]}),e.jsxs("div",{className:"p-4",children:[e.jsx("h3",{className:"font-semibold text-gray-900 mb-1",children:s.name}),e.jsxs("div",{className:"text-xs text-gray-500 mb-3",children:[s.wood_category," / ",s.wood_type]}),e.jsxs("div",{className:"space-y-1.5 text-sm text-gray-600 mb-3",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"text-gray-500",children:"두께:"}),e.jsx("span",{className:"font-medium",children:s.thickness_type==="simple"?(s.thickness_simple?.length??0)>0?s.thickness_simple.join(", ")+"mm":"-":(s.thickness_detailed?.length??0)>0?`${s.thickness_detailed.length}개 규격`:"-"})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"text-gray-500",children:"폭:"}),e.jsxs("span",{className:"font-medium",children:[s.width_min," ~ ",s.width_max,"mm"]})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"text-gray-500",children:"길이:"}),e.jsxs("span",{className:"font-medium",children:[s.length_min," ~ ",s.length_max,"mm"]})]}),s.pricing_formula&&e.jsxs("div",{className:"flex items-center justify-between pt-1.5 border-t border-gray-100",children:[e.jsx("span",{className:"text-gray-500",children:"가격:"}),e.jsx("span",{className:"font-medium text-blue-600",children:s.pricing_formula.type==="fixed"?`${s.pricing_formula.fixed_price?.toLocaleStr
7ing()}원 (고정)`:s.pricing_formula.type==="detailed"?"규격별 단가":`기본 ${s.pricing_formula.base_price?.toLocaleString()}원 + ${s.pricing_formula.unit_price}원/mm²`})]})]}),e.jsx(E,{children:e.jsxs("div",{className:"pt-3 border-t border-gray-100 space-y-2",children:[e.jsxs("div",{className:"flex items-stretch gap-2",children:[e.jsxs("div",{className:"flex flex-col flex-shrink-0",children:[e.jsx("span",{className:"text-[11px] font-medium text-gray-400 mb-1",children:"전체"}),e.jsx("button",{onClick:()=>d(s),className:`inline-flex items-center justify-center gap-1 px-2.5 py-1.5 text-xs rounded-md border transition-colors ${x?"text-green-700 bg-green-50 border-green-200 hover:bg-green-100":"text-red-600 bg-red-50 border-red-200 hover:bg-red-100"}`,title:"목재 전체 품절 여부 토글 (노출은 유지, 모든 두께 선택 차단)",children:x?e.jsxs(e.Fragment,{children:[e.jsx(Je,{className:"w-3.5 h-3.5"}),"전체 판매재개"]}):e.jsxs(e.Fragment,{children:[e.jsx(ze,{className:"w-3.5 h-3.5"}),"전체 품절처리"]})})]}),h.length>0&&e.jsx("div",{className:"w-px self-stretch bg-gray-200"}),h.length>0&&e.jsxs("div",{className:"flex flex-col flex-1 min-w-0",children:[e.jsx("span",{className:"text-[11px] font-medium text-gray-400 mb-1",children:"두께별"}),e.jsx("div",{className:"flex flex-wrap gap-1.5",children:h.map(j=>{const I=b.has(j);return e.jsx("button",{type:"button",onClick:()=>t(s,j),title:I?`${j} 판매 재개`:`${j} 품절 처리`,className:`px-2 py-1 text-xs rounded-md border transition-colors ${I?"bg-red-50 text-red-600 border-red-200 line-through":"bg-gray-50 text-gray-600 border-gray-200 hover:bg-gray-100"}`,children:j},j)})})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("button",{onClick:()=>c(s),className:"flex-1 flex items-center justify-center gap-1.5 px-3 py-2 text-sm text-gray-700 bg-gray-100 hover:bg-gray-200 rounded-lg transition-colors",children:[e.jsx(Pe,{className:"w-4 h-4"}),"수정"]}),e.jsxs("button",{onClick:()=>u(s.id),className:"flex-1 flex items-center justify-center gap-1.5 px-3 py-2 text-sm text-red-600 bg-red-50 hover:bg-red-100 rounded-lg transition-colors",children:[e.jsx(Me,{className:"w-4 h-4"}),"삭제"]})]})]})})]})]})}const Z="wedraw",i0="woods",c0=10*1024*1024,o0=["image/jpeg","image/png","image/webp","image/gif"];async function d0(s,n,c){try{if(s.size>c0)return{success:!1,error:"파일 크기는 10MB 이하여야 합니다."};if(!o0.includes(s.type))return{success:!1,error:"지원하지 않는 이미지 형식입니다. (JPG, PNG, WebP, GIF)"};const u=s.name.split(".").pop()||"png",d=Date.now(),t=`${i0}/${n}/${c}_${d}.${u}`,{error:l}=await Q.storage.from(Z).upload(t,s,{cacheControl:"3600",upsert:!1});if(l)return console.error("Wood image upload error:",l),{success:!1,error:l.message};const{data:x}=Q.storage.from(Z).getPublicUrl(t);return{success:!0,url:x.publicUrl}}catch(u){return console.error("Wood image upload exception:",u),{success:!1,error:"이미지 업로드 중 오류가 발생했습니다."}}}async function m0(s){try{if(!s.includes(Z))return{success:!0};const n=s.match(/\/storage\/v1\/object\/public\/wedraw\/(.+)$/),c=n?n[1]:null;if(!c)return{success:!1,error:"잘못된 이미지 URL입니다."};const{error:u}=await Q.storage.from(Z).remove([c]);return u?(console.error("Wood image delete error:",u),{success:!1,error:u.message}):{success:!0}}catch(n){return console.error("Wood image delete exception:",n),{success:!1,error:"이미지 삭제 중 오류가 발생했습니다."}}}function le(s){return s?s.includes("supabase.co/storage")&&s.includes(Z):!1}function x0({item:s,categories:n,processOptions:c,onSave:u,onClose:d}){const[t,l]=g.useState({category_id:s?.category_id||"",wood_category:s?.wood_category||"",wood_type:s?.wood_type||"",name:s?.name||"",description:s?.description||"",brand:s?.brand??"",supplier_name:s?.supplier_name??"",thickness_type:s?.thickness_type||"simple",thickness_simple:s?.thickness_simple||[],thickness_detailed:s?.thickness_detailed||[],width_min:s?.width_min||100,width_max:s?.width_max||2440,length_min:s?.length_min||100,length_max:s?.length_max||1220,pricing_formula:s?.pricing_formula||{type:"area",base_price:0,unit_price:0}}),x=r=>({file:null,preview:r||null,dbUrl:r||null}),[h,b]=g.useState(x(s?.texture_img)),[j,I]=g.useState(x(s?.real_img)),[P,F]=g.useState(x(s?.info_img)),O=g.useRef(null),M=g.useRef(null),N=g.useRef(null),[v,$]=g.useState(""),[A,S]=g.useState([]),[C,R]=g.useState({label:"",thickness:"",width:"",description:""});g.useEffect(()=>{s?.id&&y(s.id)},[s?.id]);const y=async r=>{try{const _=await Ie(r);S(_.map(D=>D.id))}catch(_){console.error("가공 옵션 로드 실패:",_)}},m=(r,_)=>{if(!_)return;if(!["image/jpeg","image/png","image/webp","image/gif"].includes(_.type)){L.error("JPG, PNG, WebP, GIF 형식만 지원합니다.");return}if(_.size>10*1024*1024){L.error("파일 크기는 10MB 이하여야 합니다.");return}r(q=>({...q,file:_,preview:URL.createObjectURL(_)}))},i=r=>{r({file:null,preview:null,dbUrl:null})},f=r=>{r.preventDefault();const _=[];h.file&&_.push({type:"texture",file:h.file,oldUrl:le(h.dbUrl)?h.dbUrl:null}),j.file&&_.push({type:"real",file:j.file,oldUrl:le(j.dbUrl)?j.dbUrl:null}),P.file&&_.push({type:"info",file:P.file,oldUrl:le(P.dbUrl)?P.dbUrl:null});const D={category_id:t.category_id,wood_category:t.wood_category,wood_type:t.wood_type,name:t.name,description:t.description,brand:t.brand||null,supplier_name:t.supplier_name.trim()||null,thickness_type:t.thickness_type,thickness_simple:t.thickness_simple,thickness_detailed:t.thickness_detailed.length>0?t.thickness_detailed:null,width_min:t.width_min,width_max:t.width_max,length_min:t.length_min,length_max:t.length_max,texture_img:h.file||h.preview?h.dbUrl:null,real_img:j.file||j.preview?j.dbUrl:null,info_img:P.file||P.preview?P.dbUrl:null,pricing_formula:t.pricing_formula};u(D,A,_)},o=()=>{const r=parseInt(v);r&&!t.thickness_simple.includes(r)&&(l({...t,thickness_simple:[...t.thickness_simple,r].sort((_,D)=>_-D)}),$(""))},a=r=>{l({...t,thickness_simple:t.thickness_simple.filter(_=>_!==r)})},p=()=>
7{if(!C.label||!C.thickness){L.warning("규격명과 두께는 필수입니다.");return}const r={id:String(Date.now()),label:C.label,thickness:parseInt(C.thickness),width:C.width?parseInt(C.width):void 0,description:C.description||void 0};l({...t,thickness_detailed:[...t.thickness_detailed,r]}),R({label:"",thickness:"",width:"",description:""})},w=r=>{l({...t,thickness_detailed:t.thickness_detailed.filter(_=>_.id!==r)})},k=r=>{S(_=>_.includes(r)?_.filter(D=>D!==r):[..._,r])};return e.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4",children:e.jsxs("div",{className:"bg-white rounded-lg shadow-xl max-w-4xl w-full max-h-[90vh] flex flex-col overflow-hidden",children:[e.jsxs("div",{className:"flex items-center justify-between p-6 border-b border-gray-200 flex-shrink-0",children:[e.jsx("h2",{className:"text-xl font-bold text-gray-900",children:s?"목재 수정":"목재 추가"}),e.jsx("button",{type:"button",onClick:d,className:"p-2 text-gray-400 hover:text-gray-600 hover:bg-gray-100 rounded-lg transition-colors",children:e.jsx(de,{className:"w-5 h-5"})})]}),e.jsxs("form",{onSubmit:f,className:"flex flex-col flex-1 overflow-hidden",children:[e.jsxs("div",{className:"p-6 space-y-6 overflow-y-auto flex-1",children:[e.jsxs("div",{className:"space-y-4",children:[e.jsx("h3",{className:"text-lg font-semibold text-gray-900",children:"기본 정보"}),e.jsxs("div",{children:[e.jsxs("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:["카테고리 ",e.jsx("span",{className:"text-red-500",children:"*"})]}),e.jsxs("select",{value:t.category_id,onChange:r=>l({...t,category_id:r.target.value}),className:"w-full px-3 py-2 border border-gray-300 rounded-lg focus:outline-none focus:ring-2 focus:ring-blue-500",required:!0,children:[e.jsx("option",{value:"",children:"카테고리 선택"}),n.map(r=>e.jsx("option",{value:r.id,children:r.name},r.id))]})]}),e.jsxs("div",{children:[e.jsxs("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:["목재명 (대분류) ",e.jsx("span",{className:"text-red-500",children:"*"})]}),e.jsx("input",{type:"text",value:t.wood_category,onChange:r=>l({...t,wood_category:r.target.value}),placeholder:"예: 오크, 자작나무, 대크재",className:"w-full px-3 py-2 border border-gray-300 rounded-lg focus:outline-none focus:ring-2 focus:ring-blue-500",required:!0})]}),e.jsxs("div",{children:[e.jsxs("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:["구분 (중분류) ",e.jsx("span",{className:"text-red-500",children:"*"})]}),e.jsx("input",{type:"text",value:t.wood_type,onChange:r=>l({...t,wood_type:r.target.value}),placeholder:"예: 무광, 유광, 단면 엠보",className:"w-full px-3 py-2 border border-gray-300 rounded-lg focus:outline-none focus:ring-2 focus:ring-blue-500",required:!0})]}),e.jsxs("div",{children:[e.jsxs("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:["최종 표시명 ",e.jsx("span",{className:"text-red-500",children:"*"})]}),e.jsx("input",{type:"text",value:t.name,onChange:r=>l({...t,name:r.target.value}),placeholder:"예: 오크 무광 - 21mm",className:"w-full px-3 py-2 border border-gray-300 rounded-lg focus:outline-none focus:ring-2 focus:ring-blue-500",required:!0}),e.jsxs("p",{className:"mt-1 text-xs text-gray-500",children:["고객에게 표시될 이름입니다. 자동 생성: ",t.wood_category&&t.wood_type?`${t.wood_category} ${t.wood_type}`:"(대분류와 중분류를 입력하세요)"]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:"목재 설명"}),e.jsx("textarea",{value:t.description,onChange:r=>l({...t,description:r.target.value}),placeholder:"목재에 대한 상세 설명을 입력하세요",rows:3,className:"w-full px-3 py-2 border border-gray-300 rounded-lg focus:outline-none focus:ring-2 focus:ring-blue-500 resize-none"})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:"브랜드 뱃지"}),e.jsxs("select",{value:t.brand,onChange:r=>l({...t,brand:r.target.value}),className:"w-full px-3 py-2 border border-gray-300 rounded-lg focus:outline-none focus:ring-2 focus:ring-blue-500",children:[e.jsx("option",{value:"",children:"미설정 (자동 판정)"}),Qe.map(r=>e.jsx("option",{value:r.value,children:r.label},r.value))]}),e.jsxs("p",{className:"mt-1 text-xs text-gray-500",children:["견적계산기·주방리폼·싱크대도어 카드 우측 상단에 표시됩니다.",e.jsx("br",{}),"'미설정'은 카테고리/이름 기준 기존 규칙으로 자동 판정합니다."]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:"발주서 표기명"}),e.jsx("input",{type:"text",value:t.supplier_name,onChange:r=>l({...t,supplier_name:r.target.value}),placeholder:t.name||"예: 매트 블랙",className:"w-full px-3 py-2 border border-gray-300 rounded-lg focus:outline-none focus:ring-2 focus:ring-blue-500"}),e.jsxs("p",{className:"mt-1 text-xs text-gray-500",children:["목림 발주서 엑셀의 목재종류 칸에 찍히는 이름입니다.",e.jsx("br",{}),"비워두면 최종 표시명을 그대로 사용합니다."]})]})]})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsx("h3",{className:"text-lg font-semibold text-gray-900",children:"이미지"}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsx(ie,{label:"텍스처 이미지",state:h,inputRef:O,onFileSelect:r=>m(b,r),onRemove:()=>i(b)}),e.jsx(ie,{label:"실제 사진",state:j,inputRef:M,onFileSelect:r=>m(I,r),onRemove:()=>i(I)})]}),e.jsx(ie,{label:"견적계산기 상세보기 이미지",description:"견적계산기에서 '상세정보' 버튼 클릭 시 표시되는 이미지입니다.",state:P,inputRef:N,onFileSelect:r=>m(F,r),onRemove:()=>i(F),objectFit:"contain"})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("h3",{className:"text-lg font-semibold text-gray-900",children:"두께 설정"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx("button",{type:"button",onClick:()=>l({...t,thickness_type:"simple"}),className:`px-3 py-1.5 text-sm rounded-lg transition-colors ${t.thickness_type==="simple"?"bg-blue-600 text-white":"bg-gray-100 text-gray-700 hover:bg-gray-200"}`,children:"단순 입력"}),e.jsx("button",{type:"button",onClick:()=>l({...t,thickness_type:"detailed"}),className:`px-3 py-1.5 text-sm rounded-lg transition-colors ${t.thickness_type==="detailed"?"bg-blue-600 text-white":"bg-gray-100 text-gray-700 hover:bg-gray-200"}`,children:"상세 규격"})]})]}),t.thickness_type==="simple"?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex gap-2",children:[e.jsx("input",{type:"number",value:v,onCh
7ange:r=>$(r.target.value),placeholder:"두께 (mm)",className:"no-spinner flex-1 px-3 py-2 border border-gray-300 rounded-lg focus:outline-none focus:ring-2 focus:ring-blue-500",onKeyDown:r=>{r.key==="Enter"&&(r.preventDefault(),o())}}),e.jsxs("button",{type:"button",onClick:o,className:"px-4 py-2 bg-blue-600 text-white rounded-lg hover:bg-blue-700 transition-colors flex items-center gap-2",children:[e.jsx(ee,{className:"w-4 h-4"}),"추가"]})]}),t.thickness_simple.length>0&&e.jsx("div",{className:"flex flex-wrap gap-2",children:t.thickness_simple.map(r=>e.jsxs("span",{className:"inline-flex items-center gap-1 px-3 py-1.5 bg-blue-50 text-blue-700 rounded-lg",children:[r,"mm",e.jsx("button",{type:"button",onClick:()=>a(r),className:"ml-1 text-blue-600 hover:text-blue-800",children:e.jsx(de,{className:"w-3.5 h-3.5"})})]},r))})]}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"border border-gray-300 rounded-lg p-4 space-y-3 bg-gray-50",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{children:[e.jsxs("label",{className:"block text-xs font-medium text-gray-700 mb-1",children:["규격명 ",e.jsx("span",{className:"text-red-500",children:"*"})]}),e.jsx("input",{type:"text",value:C.label,onChange:r=>R({...C,label:r.target.value}),placeholder:"예: 대크재 (단면 엠보) - 21mm",className:"w-full px-3 py-2 text-sm border border-gray-300 rounded-lg focus:outline-none focus:ring-2 focus:ring-blue-500"})]}),e.jsxs("div",{children:[e.jsxs("label",{className:"block text-xs font-medium text-gray-700 mb-1",children:["두께 (mm) ",e.jsx("span",{className:"text-red-500",children:"*"})]}),e.jsx("input",{type:"number",value:C.thickness,onChange:r=>R({...C,thickness:r.target.value}),placeholder:"21",className:"no-spinner w-full px-3 py-2 text-sm border border-gray-300 rounded-lg focus:outline-none focus:ring-2 focus:ring-blue-500"})]})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{children:[e.jsxs("label",{className:"block text-xs font-medium text-gray-700 mb-1",children:["폭 (mm) ",e.jsx("span",{className:"text-gray-400",children:"선택사항"})]}),e.jsx("input",{type:"number",value:C.width,onChange:r=>R({...C,width:r.target.value}),placeholder:"120",className:"no-spinner w-full px-3 py-2 text-sm border border-gray-300 rounded-lg focus:outline-none focus:ring-2 focus:ring-blue-500"})]}),e.jsxs("div",{children:[e.jsxs("label",{className:"block text-xs font-medium text-gray-700 mb-1",children:["설명 ",e.jsx("span",{className:"text-gray-400",children:"선택사항"})]}),e.jsx("input",{type:"text",value:C.description,onChange:r=>R({...C,description:r.target.value}),placeholder:"폭 120mm",className:"w-full px-3 py-2 text-sm border border-gray-300 rounded-lg focus:outline-none focus:ring-2 focus:ring-blue-500"})]})]}),e.jsxs("button",{type:"button",onClick:p,className:"w-full px-4 py-2 bg-blue-600 text-white text-sm rounded-lg hover:bg-blue-700 transition-colors flex items-center justify-center gap-2",children:[e.jsx(ee,{className:"w-4 h-4"}),"규격 추가"]})]}),t.thickness_detailed.length>0&&e.jsx("div",{className:"space-y-2 max-h-60 overflow-y-auto",children:t.thickness_detailed.map(r=>e.jsxs("div",{className:"flex items-center justify-between p-3 bg-white border border-gray-200 rounded-lg",children:[e.jsxs("div",{className:"flex-1",children:[e.jsx("div",{className:"font-medium text-gray-900",children:r.label}),e.jsxs("div",{className:"text-sm text-gray-600 mt-0.5",children:["두께: ",r.thickness,"mm",r.width&&` / 폭: ${r.width}mm`,r.description&&` / ${r.description}`]})]}),e.jsx("button",{type:"button",onClick:()=>w(r.id),className:"ml-3 p-1.5 text-red-600 hover:bg-red-50 rounded-lg transition-colors",children:e.jsx(Me,{className:"w-4 h-4"})})]},r.id))})]})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsx("h3",{className:"text-lg font-semibold text-gray-900",children:"크기 범위"}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:"최소 폭 (mm)"}),e.jsx("input",{type:"number",value:t.width_min,onChange:r=>l({...t,width_min:parseInt(r.target.value)||0}),className:"no-spinner w-full px-3 py-2 border border-gray-300 rounded-lg focus:outline-none focus:ring-2 focus:ring-blue-500",required:!0})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:"최대 폭 (mm)"}),e.jsx("input",{type:"number",value:t.width_max,onChange:r=>l({...t,width_max:parseInt(r.target.value)||0}),className:"no-spinner w-full px-3 py-2 border border-gray-300 rounded-lg focus:outline-none focus:ring-2 focus:ring-blue-500",required:!0})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:"최소 길이 (mm)"}),e.jsx("input",{type:"number",value:t.length_min,onChange:r=>l({...t,length_min:parseInt(r.target.value)||0}),className:"no-spinner w-full px-3 py-2 border border-gray-300 rounded-lg focus:outline-none focus:ring-2 focus:ring-blue-500",required:!0})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:"최대 길이 (mm)"}),e.jsx("input",{type:"number",value:t.length_max,onChange:r=>l({...t,length_max:parseInt(r.target.value)||0}),className:"no-spinner w-full px-3 py-2 border border-gray-300 rounded-lg focus:outline-none focus:ring-2 focus:ring-blue-500",required:!0})]})]})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsx("h3",{className:"text-lg font-semibold text-gray-900",children:"가격 산출 로직"}),e.jsxs("div",{children:[e.jsxs("label",{className:"block text-sm font-medium text-gray-700 mb-2",children:["가격 계산 방식 ",e.jsx("span",{className:"text-red-500",children:"*"})]}),t.pricing_formula.type==="detailed"?e.jsxs("div",{className:"px-4 py-3 bg-gray-50 border border-gray-200 rounded-lg text-sm text-gray-700",children:[e.jsx("span",{className:"font-medium",children:"규격별 단가"})," — 이 목재의 가격은 두께 규격마다 저장되어 있어 여기서 계산 방식을 바꾸지 않습니다."]}):e.jsxs("div",{className:"flex gap-2",children:[e.jsx("button",{type:"button",onClick:()=>l({...t,pricing_formula:{type:"fixed",fixed_price:0}}),className:`px-4 py-2 rounded-lg font-medium transition-colors ${t.pricing_formula.type==="fixed"?"bg-blue-600 text-white":"bg-gray-100 text-gray-700 hover:bg-gray-200"}`,children:"고정가"}),e.jsx("button",{type:"button",onClick:()=>l({...t,pricing_formula:{type:"area",base_price:0,unit_price:0}}),className:`px-4 py-2 rounded-lg font-medium transition-colors ${t.pricing_formula.type==="area"?"bg-blue-600 text-white":"bg-gray-100 text-gray-700 hover:bg-gray-200"}`,children:"면적 기반"})]})]}),t.pricing_formula.type==="fixed"&&e.jsxs("div",{children:[e.jsxs("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:["고정 가격 (원) ",e.jsx("span",{className:"text-red-500",children:"*"})]}),e.jsx("input",{type:"number",value:t.pricing_formula.fixed_price||0,onChange:r=>l({...t,pricing_formula:{...t.pricing_formula,fixed_price:parseInt(r.target.value)||0}}),placeholder:"예: 50000",className:"no-spinner w-full px-3 py-2 border border-gray-300 rounded-lg focus:outline-none focus:ring-2 focus:ring-blue-500",required:!0}),e.jsx("p",{className:"text-xs text-gray-500 mt-1",children:"크기와 무관하게 ê
7³ ì •된 가격이 적용됩니다."})]}),t.pricing_formula.type==="area"&&e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{children:[e.jsxs("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:["기본 가격 (원) ",e.jsx("span",{className:"text-red-500",children:"*"})]}),e.jsx("input",{type:"number",value:t.pricing_formula.base_price||0,onChange:r=>l({...t,pricing_formula:{...t.pricing_formula,base_price:parseInt(r.target.value)||0}}),placeholder:"예: 10000",className:"no-spinner w-full px-3 py-2 border border-gray-300 rounded-lg focus:outline-none focus:ring-2 focus:ring-blue-500",required:!0}),e.jsx("p",{className:"text-xs text-gray-500 mt-1",children:"기본 베이스 가격 (재단비, 인건비 등)"})]}),e.jsxs("div",{children:[e.jsxs("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:["단가 (원/mm²) ",e.jsx("span",{className:"text-red-500",children:"*"})]}),e.jsx("input",{type:"number",step:"0.01",value:t.pricing_formula.unit_price||0,onChange:r=>l({...t,pricing_formula:{...t.pricing_formula,unit_price:parseFloat(r.target.value)||0}}),placeholder:"예: 0.5",className:"no-spinner w-full px-3 py-2 border border-gray-300 rounded-lg focus:outline-none focus:ring-2 focus:ring-blue-500",required:!0}),e.jsx("p",{className:"text-xs text-gray-500 mt-1",children:"mm² 당 단가 (가격 = 기본가격 + 폭 × 길이 × 단가)"})]}),t.pricing_formula.base_price>0&&t.pricing_formula.unit_price>0&&e.jsxs("div",{className:"p-3 bg-blue-50 border border-blue-200 rounded-lg",children:[e.jsx("p",{className:"text-sm font-medium text-blue-900 mb-2",children:"💡 가격 계산 예시"}),e.jsxs("div",{className:"text-xs text-blue-800 space-y-1",children:[e.jsx("p",{children:"• 폭 500mm × 길이 1000mm 기준:"}),e.jsxs("p",{className:"ml-4",children:["= ",t.pricing_formula.base_price.toLocaleString(),"원 + (500 × 1000 × ",t.pricing_formula.unit_price,") = ",(t.pricing_formula.base_price+500*1e3*t.pricing_formula.unit_price).toLocaleString(),"원"]})]})]})]})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsx("h3",{className:"text-lg font-semibold text-gray-900",children:"가공 옵션"}),e.jsx("p",{className:"text-sm text-gray-600",children:"적용 가능한 가공 옵션을 선택하세요."}),e.jsx("div",{className:"grid grid-cols-2 md:grid-cols-3 gap-2 max-h-60 overflow-y-auto p-2 border border-gray-200 rounded-lg",children:c.map(r=>e.jsxs("label",{className:"flex items-center gap-2 p-2 rounded hover:bg-gray-50 cursor-pointer",children:[e.jsx("input",{type:"checkbox",checked:A.includes(r.id),onChange:()=>k(r.id),className:"w-4 h-4 text-blue-600 border-gray-300 rounded focus:ring-blue-500"}),e.jsx("span",{className:"text-sm text-gray-700",children:r.name})]},r.id))}),A.length>0&&e.jsxs("div",{className:"text-sm text-gray-600",children:["선택된 옵션: ",A.length,"개"]})]})]}),e.jsxs("div",{className:"flex items-center gap-3 p-6 border-t border-gray-200 bg-white flex-shrink-0",children:[e.jsx("button",{type:"button",onClick:d,className:"flex-1 px-4 py-2.5 text-gray-700 bg-gray-100 hover:bg-gray-200 rounded-lg transition-colors",children:"취소"}),e.jsx("button",{type:"submit",className:"flex-1 px-4 py-2.5 text-white bg-blue-600 hover:bg-blue-700 rounded-lg transition-colors",children:s?"수정 완료":"추가하기"})]})]})]})})}function ie({label:s,description:n,state:c,inputRef:u,onFileSelect:d,onRemove:t,objectFit:l="cover"}){const x=h=>{h.preventDefault();const b=h.dataTransfer.files[0];b&&d(b)};return e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:s}),n&&e.jsx("p",{className:"text-xs text-gray-500 mb-2",children:n}),e.jsx("input",{ref:u,type:"file",accept:"image/jpeg,image/png,image/webp,image/gif",className:"hidden",onChange:h=>{const b=h.target.files?.[0];b&&d(b),h.target.value=""}}),c.preview?e.jsxs("div",{className:"relative group",children:[e.jsx("div",{className:"aspect-video bg-gray-100 rounded-lg overflow-hidden border border-gray-200",children:e.jsx("img",{src:c.preview,alt:s,className:`w-full h-full ${l==="contain"?"object-contain":"object-cover"}`,onError:h=>{h.currentTarget.style.display="none"}})}),c.file&&e.jsx("span",{className:"absolute top-2 left-2 px-1.5 py-0.5 bg-blue-600 text-white text-[10px] rounded font-medium",children:"새 파일"}),e.jsxs("div",{className:"absolute inset-0 bg-black/40 opacity-0 group-hover:opacity-100 transition-opacity rounded-lg flex items-center justify-center gap-2",children:[e.jsx("button",{type:"button",onClick:()=>u.current?.click(),className:"px-3 py-1.5 bg-white text-gray-800 text-xs rounded-lg font-medium hover:bg-gray-100",children:"변경"}),e.jsx("button",{type:"button",onClick:t,className:"px-3 py-1.5 bg-red-500 text-white text-xs rounded-lg font-medium hover:bg-red-600",children:"삭제"})]})]}):e.jsxs("div",{onClick:()=>u.current?.click(),onDragOver:h=>h.preventDefault(),onDrop:x,className:"border-2 border-dashed border-gray-300 rounded-lg p-6 text-center hover:border-blue-500 hover:bg-blue-50/50 transition-colors cursor-pointer",children:[e.jsx(Ze,{className:"w-8 h-8 mx-auto text-gray-400 mb-2"}),e.jsx("p",{className:"text-sm text-gray-600",children:"클릭 또는 드래그하여 업로드"}),e.jsx("p",{className:"text-xs text-gray-400 mt-1",children:"JPG, PNG, WebP, GIF (최대 
710MB)"})]})]})}const fe=["솔리드 무광","솔리드 유광","우드","세라믹"],X={minPrice:7e3,baseAreaPrice:34e3,coefficient:5e3,lFormula:"linear",lCoeff:null,lOffset:null,wCoeff:.00432,wOffset:.102,correction:.929,slopeRatio:.65,priceMultiplier:1},ce=2e4,be=32e4,ye=800,je=400;function Ne(s,n,c){const u=c*n,{minPrice:d,baseAreaPrice:t,coefficient:l,lFormula:x,lCoeff:h,lOffset:b,wCoeff:j,wOffset:I,correction:P,slopeRatio:F,priceMultiplier:O}=s,M=$=>x==="coefficients"&&h!==null&&b!==null?h*$+b:$/200,N=($,A)=>l*M(A)*(j*$+I)*P;let v;if(u<=ce)v=d;else if(u<be){const $=N(je,ye),A=(u-ce)/(be-ce);v=d+($-d)*(1-Math.exp(-2*A))}else{const $=N(n,c),A=N(je,ye);v=t+($-A)*F}return v=v*O,Math.ceil(v/1e3)*1e3}const u0=[{label:"소 (200x200)",width:200,length:200},{label:"중 (400x800)",width:400,length:800},{label:"대 (1000x2000)",width:1e3,length:2e3}];function we(s){const n=[];return s.minPrice<=0&&n.push({field:"minPrice",message:"최소가는 0보다 커야 합니다"}),s.baseAreaPrice<=0&&n.push({field:"baseAreaPrice",message:"기준단가는 0보다 커야 합니다"}),s.coefficient<=0&&n.push({field:"coefficient",message:"기본 계수는 0보다 커야 합니다"}),s.wCoeff===0&&n.push({field:"wCoeff",message:"W 계수는 0이 될 수 없습니다"}),s.correction<=0&&n.push({field:"correction",message:"보정 계수는 0보다 커야 합니다"}),(s.slopeRatio<=0||s.slopeRatio>1)&&n.push({field:"slopeRatio",message:"기울기 비율은 0~1 사이여야 합니다"}),s.priceMultiplier<=0&&n.push({field:"priceMultiplier",message:"조정률은 0보다 커야 합니다"}),s.lFormula==="coefficients"&&((s.lCoeff===null||s.lCoeff===0)&&n.push({field:"lCoeff",message:"L 계수는 0이 될 수 없습니다"}),s.lOffset===null&&n.push({field:"lOffset",message:"L 오프셋을 입력해주세요"})),n}function g0(){const[s,n]=g.useState([]),[c,u]=g.useState(!0),[d,t]=g.useState(null),[l,x]=g.useState({}),[h,b]=g.useState(400),[j,I]=g.useState(800),[P,F]=g.useState([]),[O,M]=g.useState(!1),N=g.useCallback(async()=>{try{u(!0);const o=await Se();n(o);const a={};for(const p of o)if(fe.includes(p.name)){const w=p.pricing_params;w&&"minPrice"in w?a[p.id]={...w}:a[p.id]={...X}}x(a)}catch(o){console.error("카테고리 로드 실패:",o),L.error("카테고리 데이터를 불러오는데 실패했습니다.")}finally{u(!1)}},[]),v=g.useCallback(async()=>{try{M(!0);const o=await De(void 0,20);F(o)}catch{}finally{M(!1)}},[]);g.useEffect(()=>{N(),v()},[N,v]);const $=g.useMemo(()=>s.filter(o=>fe.includes(o.name)),[s]),A=g.useMemo(()=>$.map(o=>{const a=l[o.id]||X,p=o.pricing_params&&"minPrice"in o.pricing_params?o.pricing_params:X,w=JSON.stringify(a)!==JSON.stringify(p);return{category:o,params:a,originalParams:p,isDirty:w}}),[$,l]),S=g.useCallback((o,a,p)=>{x(w=>{const k=w[o]||X;return{...w,[o]:{...k,[a]:p}}})},[]),C=g.useCallback((o,a)=>{x(p=>({...p,[o]:a}))},[]),R=g.useCallback(async o=>{const a=l[o];if(!a)return;const p=we(a);if(p.length>0){L.error(p.map(w=>w.message).join(`
8`));return}try{t(o),await ge(o,a),await N(),await v(),L.success("가격 파라미터가 저장되었습니다.")}catch(w){console.error("파라미터 저장 실패:",w),L.error("파라미터 저장에 실패했습니다.")}finally{t(null)}},[l,N]),y=g.useCallback(o=>{const a=s.find(w=>w.id===o);if(!a)return;const p=a.pricing_params&&"minPrice"in a.pricing_params?a.pricing_params:X;x(w=>({...w,[o]:{...p}}))},[s]),m=g.useCallback(o=>{if(o<=0){L.error("조정률은 0보다 커야 합니다.");return}x(a=>{const p={...a};for(const w of $)p[w.id]&&(p[w.id]={...p[w.id],priceMultiplier:o});return p})},[$]),i=g.useCallback(async()=>{const o=A.filter(a=>a.isDirty);if(o.length===0){L.info("변경된 항목이 없습니다.");return}for(const a of o){const p=we(a.params);if(p.length>0){L.error(`${a.category.name}: ${p[0].message}`);return}}try{t("all"),await Promise.all(o.map(a=>ge(a.category.id,a.params))),await N(),await v(),L.success(`${o.length}개 카테고리가 저장되었습니다.`)}catch(a){console.error("전체 저장 실패:",a),L.error("전체 저장에 실패했습니다.")}finally{t(null)}},[A,N]),f=g.useMemo(()=>A.map(({category:o,params:a,originalParams:p})=>{const w=Ne(a,h,j),k=Ne(p,h,j),r=k>0?(w-k)/k*100:0;return{categoryName:o.name,categoryId:o.id,currentPrice:w,originalPrice
8:k,diffPercent:r}}),[A,h,j]);return{loading:c,saving:d,pricingDataList:A,updateParam:S,setParams:C,saveParams:R,resetParams:y,saveAll:i,applyBulkMultiplier:m,simWidth:h,simLength:j,setSimWidth:b,setSimLength:I,simulationResults:f,changeLog:P,changeLogLoading:O,hasDirtyItems:A.some(o=>o.isDirty)}}function h0({simWidth:s,simLength:n,setSimWidth:c,setSimLength:u,simulationResults:d}){const t=s*n;return e.jsxs(U,{children:[e.jsx(B,{children:e.jsx(G,{className:"text-lg",children:"가격 시뮬레이터"})}),e.jsxs(V,{className:"space-y-4",children:[e.jsxs("div",{className:"flex flex-wrap items-end gap-4",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs font-medium text-gray-500 mb-1",children:"폭 W (mm)"}),e.jsx("input",{type:"number",min:1,value:s,onChange:l=>c(Math.max(1,parseInt(l.target.value)||1)),className:"no-spinner w-28 text-sm border border-gray-300 rounded-lg px-3 py-2 focus:outline-none focus:ring-1 focus:ring-blue-500"})]}),e.jsx("span",{className:"text-gray-400 pb-2 text-lg font-light",children:"x"}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs font-medium text-gray-500 mb-1",children:"길이 L (mm)"}),e.jsx("input",{type:"number",min:1,value:n,onChange:l=>u(Math.max(1,parseInt(l.target.value)||1)),className:"no-spinner w-28 text-sm border border-gray-300 rounded-lg px-3 py-2 focus:outline-none focus:ring-1 focus:ring-blue-500"})]}),e.jsxs("div",{className:"pb-2 text-sm text-gray-500",children:["= ",t.toLocaleString("ko-KR")," mm²"]}),e.jsx("div",{className:"flex items-center gap-2 pb-1",children:u0.map(l=>e.jsx("button",{onClick:()=>{c(l.width),u(l.length)},className:`
9                  px-3 py-1.5 text-xs rounded-lg border transition-colors
10                  ${s===l.width&&n===l.length?"bg-blue-50 border-blue-300 text-blue-700":"bg-white border-gray-200 text-gray-600 hover:bg-gray-50"}
11                `,children:l.label},l.label))})]}),e.jsx("div",{className:"overflow-x-auto",children:e.jsxs("table",{className:"w-full text-sm",children:[e.jsx("thead",{children:e.jsxs("tr",{className:"border-b border-gray-200",children:[e.jsx("th",{className:"text-left py-2.5 px-3 text-xs font-medium text-gray-500 uppercase tracking-wider",children:"카테고리"}),e.jsx("th",{className:"text-right py-2.5 px-3 text-xs font-medium text-gray-500 uppercase tracking-wider",children:"현재 가격"}),e.jsx("th",{className:"text-right py-2.5 px-3 text-xs font-medium text-gray-500 uppercase tracking-wider",children:"변경 후"}),e.jsx("th",{className:"text-right py-2.5 px-3 text-xs font-medium text-gray-500 uppercase tracking-wider",children:"변경률"})]})}),e.jsx("tbody",{children:d.map(l=>{const x=Math.abs(l.diffPercent)>=.1,h=l.diffPercent>0,b=Math.abs(l.diffPercent)>=20;return e.jsxs("tr",{className:"border-b border-gray-100 last:border-b-0",children:[e.jsx("td",{className:"py-3 px-3 font-medium text-gray-900",children:l.categoryName}),e.jsxs("td",{className:"py-3 px-3 text-right text-gray-600",children:[l.originalPrice.toLocaleString("ko-KR"),"원"]}),e.jsxs("td",{className:`py-3 px-3 text-right font-semibold ${x?h?"text-blue-700":"text-green-700":"text-gray-900"}`,children:[l.currentPrice.toLocaleString("ko-KR"),"원"]}),e.jsx("td",{className:"py-3 px-3 text-right",children:x?e.jsxs("span",{className:`
12                          inline-flex items-center gap-1 px-2 py-0.5 rounded-full text-xs font-medium
13                          ${b?"bg-red-100 text-red-700":h?"bg-blue-50 text-blue-700":"bg-green-50 text-green-700"}
14                        `,children:[h?e.jsx(He,{className:"w-3 h-3"}):e.jsx(e0,{className:"w-3 h-3"}),l.diffPercent>0?"+":"",l.diffPercent.toFixed(1),"%"]}):e.jsxs("span",{className:"inline-flex items-center gap-1 text-xs text-gray-400",children:[e.jsx(s0,{className:"w-3 h-3"}),"변동 없음"]})})]},l.categoryId)})})]})})]})]})}const Y=[{code:"023",w:100,h:645,min:100,max:645},{code:"078",w:100,h:800,min:100,max:800},{code:"072",w:115,h:1210,min:115,max:1210},{code:"086",w:115,h:1600,min:115,max:1600},{code:"088",w:165,h:1210,min:165,max:1210},{code:"025",w:165,h:1600,min:165,max:1600},{code:"071",w:195,h:1210,min:195,max:1210},{code:"094",w:195,h:1600,min:195,max:1600},{code:"087",w:200,h:800,min:200,max:800},{code:"019",w:300,h:218,min:218,max:300},{code:"024",w:300,h:500,min:300,max:500},{code:"014",w:300,h:600,min:300,max:600},{code:"001",w:300,h:645,min:300,max:645}
14,{code:"005",w:300,h:800,min:300,max:800},{code:"036",w:300,h:900,min:300,max:900},{code:"045",w:300,h:1e3,min:300,max:1e3},{code:"052",w:300,h:1210,min:300,max:1210},{code:"058",w:300,h:1600,min:300,max:1600},{code:"067",w:300,h:1800,min:300,max:1800},{code:"026",w:300,h:2440,min:300,max:2440},{code:"020",w:400,h:218,min:218,max:400},{code:"015",w:400,h:600,min:400,max:600},{code:"002",w:400,h:645,min:400,max:645},{code:"006",w:400,h:800,min:400,max:800},{code:"037",w:400,h:900,min:400,max:900},{code:"046",w:400,h:1e3,min:400,max:1e3},{code:"053",w:400,h:1210,min:400,max:1210},{code:"059",w:400,h:1600,min:400,max:1600},{code:"068",w:400,h:1800,min:400,max:1800},{code:"027",w:400,h:2440,min:400,max:2440},{code:"021",w:450,h:218,min:218,max:450},{code:"016",w:450,h:600,min:450,max:600},{code:"003",w:450,h:645,min:450,max:645},{code:"007",w:450,h:800,min:450,max:800},{code:"038",w:450,h:900,min:450,max:900},{code:"047",w:450,h:1e3,min:450,max:1e3},{code:"054",w:450,h:1210,min:450,max:1210},{code:"060",w:450,h:1600,min:450,max:1600},{code:"069",w:450,h:1800,min:450,max:1800},{code:"028",w:450,h:2440,min:450,max:2440},{code:"096",w:500,h:2440,min:500,max:2440},{code:"022",w:600,h:218,min:218,max:600},{code:"018",w:600,h:500,min:500,max:600},{code:"017",w:600,h:600,min:600,max:600},{code:"004",w:600,h:645,min:600,max:645},{code:"008",w:600,h:800,min:600,max:800},{code:"039",w:600,h:900,min:600,max:900},{code:"048",w:600,h:1e3,min:600,max:1e3},{code:"055",w:600,h:1210,min:600,max:1210},{code:"061",w:600,h:1600,min:600,max:1600},{code:"070",w:600,h:1800,min:600,max:1800},{code:"029",w:600,h:2440,min:600,max:2440},{code:"085",w:700,h:700,min:700,max:700},{code:"009",w:700,h:800,min:700,max:800},{code:"040",w:700,h:900,min:700,max:900},{code:"049",w:700,h:1e3,min:700,max:1e3},{code:"056",w:700,h:1210,min:700,max:1210},{code:"062",w:700,h:1600,min:700,max:1600},{code:"073",w:700,h:1800,min:700,max:1800},{code:"030",w:700,h:2440,min:700,max:2440},{code:"010",w:800,h:800,min:800,max:800},{code:"041",w:800,h:900,min:800,max:900},{code:"063",w:800,h:1600,min:800,max:1600},{code:"074",w:800,h:1800,min:800,max:1800},{code:"031",w:800,h:2440,min:800,max:2440},{code:"042",w:900,h:900,min:900,max:900},{code:"064",w:900,h:1600,min:900,max:1600},{code:"075",w:900,h:1800,min:900,max:1800},{code:"032",w:900,h:2440,min:900,max:2440},{code:"011",w:1e3,h:800,min:800,max:1e3},{code:"043",w:1e3,h:900,min:900,max:1e3},{code:"065",w:1e3,h:1600,min:1e3,max:1600},{code:"076",w:1e3,h:1800,min:1e3,max:1800},{code:"033",w:1e3,h:2440,min:1e3,max:2440},{code:"012",w:1100,h:800,min:800,max:1100},{code:"050",w:1100,h:1e3,min:1e3,max:1100},{code:"034",w:1100,h:2440,min:1100,max:2440},{code:"013",w:1210,h:800,min:800,max:1210},{code:"044",w:1210,h:900,min:900,max:1210},{code:"051",w:1210,h:1e3,min:1e3,max:1210},{code:"057",w:1210,h:1210,min:1210,max:1210},{code:"066",w:1210,h:1600,min:1210,max:1600},{code:"077",w:1210,h:1800,min:1210,max:1800},{code:"035",w:1210,h:2440,min:1210,max:2440}],p0=[{code:"091",w:65},{code:"092",w:75},{code:"093",w:85},{code:"081",w:95},{code:"082",w:115},{code:"083",w:165},{code:"084",w:195}],f0={136031:171e3,546008:43e3,534059:55e3,534078:9e3,536036:25e3,542022:15e3,513043:97e3,538053:42e3,547014:19e3,547037:34e3,542083:42e3,513008:55e3,140040:55e3,607093:25e3,513049:79e3,513068:82e3,601032:157e3,"084018":32e3,544073:109e3,136025:34e3,538022:13e3,513094:43e3,541028:92e3,601093:25e3,542042:72e3,"084092":3e4,536072:16e3,536051:99e3,543023:8e3,532060:64e3,513055:8e4,513076:186e3,543080:39e3,533039:46e3,547049:62e3,535085:42e3,543082:29e3,534009:49e3,535024:14e3,539060:61e3,512048:67e3,512069:9e4,538058:42e3,538096:101e3,512046:48e3,533078:9e3,533059:55e3,"084043":8e4,536064:118e3,536045:27e3,512010:72e3,539008:41e3,547052:34e3,547071:25e3,543053:42e3,601088:2e4,512053:56e3,601046:33e3,538067:47e3,603022:12e3,533063:106e3,533046:35e3,533088:2e4,513020:15e3,535016:25e3,607057:111e3,546021:11e3,536056:71e3,542050:95e3,543047:39e3,543064:118e3,536038:36e3,601059:51e3,601078:1e4,"084023":14e3,512030:178e3,541070:89e3,546065:134e3,607067:47e3,607044:85e3,607086:21e3,601019:8e3,601038:34e3,543085:42e3,546044
14:92e3,546067:5e4,139060:63e3,538039:46e3,607018:27e3,543058:42e3,512094:43e3,548078:1e4,548059:57e3,542039:49e3,536030:138e3,139013:79e3,136002:29e3,542008:44e3,543038:36e3,538059:55e3,603063:92e3,533022:13e3,546038:37e3,535091:2e4,538088:2e4,548063:109e3,541009:49e3,"084028":103e3,538042:69e3,534040:55e3,601050:83e3,548037:34e3,"084057":124e3,548047:41e3,541071:23e3,543026:64e3,603064:103e3,603045:24e3,533034:213e3,533015:22e3,140014:21e3,539027:82e3,535063:106e3,538072:16e3,513029:156e3,537034:213e3,537015:22e3,136010:62e3,546057:121e3,"084017":37e3,512049:79e3,"084082":37e3,512017:43e3,541084:44e3,541065:131e3,541046:35e3,140096:105e3,607040:52e3,537063:106e3,533001:19e3,535094:3e4,543092:22e3,136088:27e3,535077:175e3,512006:39e3,139045:31e3,139064:117e3,140071:28e3,537060:61e3,532034:218e3,532017:34e3,547002:25e3,544062:97e3,544041:65e3,534041:62e3,534062:93e3,542017:34e3,538008:41e3,512028:123e3,536057:118e3,139093:28e3,513018:37e3,139059:57e3,136087:22e3,541037:32e3,539062:93e3,603032:152e3,603011:59e3,534094:3e4,512050:121e3,541092:22e3,538050:92e3,607002:24e3,542023:9e3,533060:61e3,512093:34e3,136060:71e3,542080:39e3,546049:62e3,532069:72e3,546087:17e3,548021:11e3,532084:48e3,136018:33e3,139042:69e3,139061:79e3,541023:8e3,539078:9e3,539091:2e4,136024:2e4,"084006":34e3,139023:12e3,601023:9e3,537066:156e3,537045:27e3,536007:32e3,513047:52e3,544021:12e3,532051:103e3,546037:34e3,512025:38e3,534024:14e3,513030:178e3,513054:62e3,513075:17e4,539044:9e4,539067:47e3,547048:53e3,547069:71e3,547086:22e3,140026:68e3,603010:48e3,537078:9e3,537059:55e3,"084036":31e3,544035:237e3,544016:27e3,136078:16e3,542047:42e3,542062:97e3,136055:69e3,537018:27e3,535022:13e3,546056:73e3,547053:44e3,547076:15e4,547082:32e3,"084001":24e3,139024:18e3,541041:62e3,140024:18e3,532062:97e3,539015:22e3,539036:25e3,536078:9e3,542078:11e3,607056:68e3,548003:28e3,513091:3e4,532031:162e3,544067:51e3,544084:48e3,601094:3e4,536039:46e3,536018:27e3,601079:29e3,512008:55e3,541050:92e3,542014:19e3,607066:145e3,139096:105e3,607085:41e3,139075:129e3,601039:43e3,140079:23e3,535040:55e3,532025:29e3,512072:25e3,538036:25e3,534057:118e3,534072:16e3,607012:71e3,536025:26e3,547012:76e3,547031:16e4,512011:88e3,548022:14e3,533007:32e3,535001:19e3,543039:46e3,513006:39e3,601025:26e3,140009:5e4,136086:28e3,136023:13e3,512038:48e3,512060:81e3,544081:29e3,542011:71e3,542032:181e3,541006:29e3,"084029":128e3,548004:35e3,547025:28e3,513048:67e3,"084094":38e3,"084075":137e3,"084056":76e3,140070:93e3,536091:2e4,543025:26e3,601022:13e3,533037:32e3,533014:17e3,136034:225e3,546005:24e3,538033:194e3,541020:9e3,534007:32e3,548075:135e3,"084035":227e3,"084016":3e4,"084039":51e3,"084083":45e3,548065:134e3,536062:93e3,543032:176e3,136069:78e3,139087:2e4,603078:8e3,533028:92e3,547058:45e3,547096:104e3,543093:23e3,535055:61e3,535076:147e3,512059:73e3,512078:17e3,538048:51e3,603038:31e3,538086:2e4,548081:28e3,533069:68e3,533048:51e3,546027:85e3,"084051":107e3,536075:133e3,536054:47e3,548002:25e3,538085:42e3,607016:24e3,607025:27e3,546082:32e3,547050:94e3,537004:34e3,601063:96e3,538076:147e3,603033:168e3,544088:22e3,533075:133e3,533056:71e3,536069:68e3,542045:3e4,548066:159e3,136040:61e3,539005:22e3,546069:71e3,543056:71e3,543075:133e3,601085:39e3,539021:1e4,541022:13e3,601068:57e3,547001:2e4,536079:33e3,512012:96e3,535013:81e3,542006:31e3,536004:34e3,546054:48e3,546075:135e3,548009:51e3,543048:51e3,543069:68e3,532010:58e3,548069:71e3,548048:53e3,544070:93e3,533093:23e3,537096:101e3,537058:42e3,543028:92e3,534079:33e3,603072:14e3,603051:86e3,533032:176e3,546062:96e3,546074:121e3,513057:152e3,139003:29e3,"084038":41e3,"084019":12e3,513007:43e3,"084084":5e4,546019:8e3,"084046":4e4,548033:198e3,543014:17e3,541063:106e3,548056:73e3,139088:25e3,603075:115e3,603054:41e3,533025:26e3,140027:84e3,546091:22e3,539014:17e3,539035:231e3,535071:23e3,537025:26e3,139015:26e3,532032:181e3,532011:71e3,548086:22e3,534081:25e3,544085:45e3,541074:119e3,541057:118e3,512001:27e3,607070:85e3,603069:6e4,539058:42e3,140013:79e3,538084:44e3,513060:81e3,532080:39e3,546083:41e3,139057:116e3,537031:157e3,537012:74e3,538003:26e3,532024:16e3,546034:2
1416e3,544072:18e3,544057:122e3,534073:105e3,542025:29e3,139074:117e3,548067:5e4,607068:59e3,539013:81e3,533006:29e3,139082:33e3,139048:52e3,535062:93e3,541029:119e3,539051:99e3,539072:16e3,546039:48e3,136022:18e3,534084:44e3,534067:47e3,538080:39e3,536001:19e3,547024:15e3,512029:156e3,532078:11e3,546078:1e4,603060:53e3,139052:36e3,541032:176e3,541011:68e3,539069:68e3,136035:242e3,136014:23e3,139031:151e3,537076:147e3,537053:42e3,140021:14e3,603005:2e4,547018:28e3,535010:55e3,544033:2e5,532047:42e3,534016:25e3,543003:26e3,532023:9e3,513045:38e3,513064:153e3,539054:47e3,539075:133e3,547059:57e3,547078:1e4,136029:134e3,607023:9e3,537086:2e4,537069:68e3,537048:51e3,542003:28e3,535021:1e4,140033:182e3,140074:117e3,544024:16e3,537040:55e3,136068:71e3,136049:68e3,512045:38e3,536076:147e3,536055:61e3,541048:51e3,513051:13e4,"084010":6e4,547021:11e3,547045:29e3,547066:159e3,139017:34e3,139034:198e3,607024:15e3,607026:62e3,601041:57e3,601062:85e3,538054:47e3,538077:175e3,533038:36e3,543030:138e3,140058:45e3,542084:48e3,536087:16e3,543008:41e3,536049:6e4,512064:153e3,538004:34e3,546022:14e3,544079:33e3,544094:33e3,601084:42e3,601067:45e3,541081:25e3,533042:69e3,546025:28e3,533009:49e3,607077:162e3,535012:74e3,535037:32e3,607094:3e4,139063:106e3,136061:89e3,140003:29e3,534018:27e3,538026:64e3,543068:61e3,536034:213e3,536017:32e3,547013:83e3,548084:46e3,533092:22e3,537009:49e3,607051:94e3,607043:72e3,136063:119e3,601015:21e3,601034:19e4,136032:189e3,535081:25e3,512057:152e3,603029:104e3,139002:27e3,534050:92e3,548030:142e3,140062:96e3,"084085":46e3,"084064":124e3,"084047":44e3,543015:22e3,543034:213e3,140080:27e3,536019:7e3,601033:174e3,603055:53e3,533026:64e3,536063:106e3,538021:1e4,535053:42e3,548068:64e3,548042:71e3,"084024":2e4,538063:106e3,532016:27e3,"084091":29e3,546052:34e3,512044:119e3,536073:105e3,543022:13e3,546060:63e3,532040:57e3,603087:14e3,603068:54e3,603049:53e3,535020:9e3,533019:7e3,535086:2e4,535044:9e4,535067:47e3,544068:65e3,539080:39e3,512068:82e3,542034:218e3,538078:9e3,603028:8e4,136096:117e3,537070:89e3,"084061":85e3,548039:48e3,536067:47e3,536044:9e4,534033:194e3,536058:42e3,607017:31e3,512031:199e3,607091:22e3,601072:16e3,538045:27e3,538066:156e3,603016:22e3,533064:118e3,533047:39e3,537082:29e3,535019:7e3,136070:103e3,539020:9e3,548023:9e3,542070:93e3,543088:2e4,536082:29e3,543046:35e3,543063:106e3,548088:21e3,541033:194e3,541016:25e3,548085:44e3,533053:42e3,537071:23e3,537052:32e3,607042:65e3,603091:18e3,546015:23e3,546045:29e3,532065:135e3,532046:38e3,532088:22e3,534017:32e3,543078:9e3,140049:61e3,548096:104e3,139009:5e4,548058:45e3,539057:118e3,"084013":85e3,512003:36e3,547074:121e3,512026:86e3,543050:92e3,533082:29e3,537087:16e3,537049:6e4,513072:25e3,603062:81e3,534054:47e3,533023:8e3,546051:102e3,546072:17e3,544020:11e3,139007:34e3,139008:42e3,534060:61e3,601070:82e3,139016:28e3,546055:63e3,547081:28e3,541072:16e3,541051:99e3,512015:32e3,603067:42e3,603044:78e3,140042:69e3,544039:49e3,140015:26e3,136074:132e3,532083:42e3,537061:8e4,542066:16e4,537037:32e3,537014:17e3,548053:44e3,513004:46e3,547020:1e4,532022:15e3,535074:119e3,544078:11e3,544059:58e3,140056:71e3,607049:58e3,541064:118e3,541045:27e3,539016:25e3,140059:57e3,136073:118e3,539019:7e3,533008:41e3,543002:24e3,139046:37e3,139065:127e3,542013:84e3,532035:237e3,532014:19e3,547003:28e3,544063:11e4,544046:38e3,536016:25e3,534061:8e4,542016:27e3,513032:221e3,512004:46e3,603037:28e3,136092:29e3,139092:27e3,139058:45e3,139079:23e3,541038:36e3,513013:103e3,539063:106e3,532029:124e3,136033:207e3,512070:119e3,534076:147e3,538070:89e3,536021:1e4,513010:72e3,533040:55e3,547016:26e3,547035:235e3,548010:57e3,536080:39e3,532068:65e3,532049:63e3,533003:26e3,535005:22e3,139043:75e3,139047:41e3,601011:62e3,136027:93e3,"084005":28e3,512027:108e3,537088:2e4,537067:47e3,537042:69e3,512066:196e3,546028:95e3,548008:43e3,547029:123e3,512036:35e3,532073:109e3,532056:74e3,548070:92e3,542091:23e3,136082:36e3,546080:39e3,538010:55e3,539045:27e3,539064:118e3,543040:55e3,547068:64e3,546001:2e4,607032:164e3,607011:65e3,601081:26e3,603008:36e3,538079:33e3,536010:55e3,544034:218e3,544015:24e3,140073:106e3,136058:5e4,534011:68e3,542063:11e4,543037:32e3,513063:138e3,547054:48e3,547077:178e3,139025:32e3,607035:215e3,607014:18e3,136046:41e3,541069:68e3,601073:95e3,538044:9e4,538065:131e3,512091:3e4,533065:131e3,533044:9e4,533086:2e4,542094:33e3,536096:101e3,535018:27e3,542077:179e3,542012:77e3,548073:107e3,547063:109e3,607029:113e3,543041:62e3,543062:93e3,537008:41e3,601076:132e3,139010:56e3,533071:23e3,533052:32e3,546058:45e3,139054:49e3,607069:66e3,535026:64e3,607084:44e3,534008:41e3,535060:61e3,538014:17e3,538037:32e3,512058:57e3,543079:33e3,536024:14e3,543094:3e4,544060:64e3,"084031":161e3,"084012":79e3,533083:38e3,542081:29e3,607062:88e3,601024:14e3,140006:31e3,547055:63e3,535093:23e3,513038:48e3,546010:57e3,548082:32e3,536012:74e3,541007:32e3,512065:167e3,546029:123e3,512037:43e3,140088:25e3,"084074":125e3,"084055":67e3,544053:45e3,546088:21e3,543024:14e3,537043:76e3,533058:42e3,603066:135e3,533036:25e3,533013:81e3,546081:28e3,538011:68e3,532006:31e3,535042:69e3,535061:8e4,601001:18e3,"084026":74e3,548071:25e3,548052:34e3,"084034":21e4,"084015":28e3,601080:34e3,136051:112e3,512019:13e3,543033:194e3,532070:93e3,603096:88e3,603079:29e3,603058:37e3,539001:19e3,542031:162e3,535096:101e3,535054:47e3,535075:133e3,601004:32e3,537021:1e4,512079:34e3,139037:34e3,603039:4e4,538081:25e3,537080:39e3,547004:35e3,533049:6e4,"084073":113e3,548028:95e3,513001:27e3,541078:9e3,513087:24e3,512054:62e3,544052:35e3,513031:199e3,601020:1e4,512009:64e3,547019:8e3,547070:92e3,541039:46e3,541018:27e3,513012:96e3,603001:17e3,603025:23e3,513074:153e3,533074:119e3,533055:61e3,548017:33e3,537092:22e3,136017:38e3,513067:64e3,539004:34e3,542040:57e3,536060:61e3,532048:54e3,543057:118e3,543072:16e3,541025:26e3,539093:23e3,"084004":39e3,"084030":145e3,544007:34e3,542082:33e3,542001:2e4,536005:22e3,513062:124e3,139004:36e3,542029:124e3,534021:1e4,532074:123e3,532057:122e3,140066:148e3,548087:17e3,546076:15e4,548049:62e3,538030:138e3,544050:95e3,539084:44e3,512034:264e3,541091:2e4,537057:118e3,601044:82e3,603009:43e3,603073:91e3,140082:33e3,544037:34e3,532043:79e3,139086:26e3,"084053":47e3,534012:74e3,534031:157e3,548093:26e3,512018:37e3,548029:123e3,548032:179e3,513015:32e3,136056:8e4,541062:93e3,607036:25e3,140053:44e3,544028:96e3,548046:37e3,532092:25e3,539034:213e3,607006:28e3,542055:64e3,542076:151e3,537026:64e3,512041:81e3,513093:34e3,532033:2e5,547041:64e3,547062:96e3,547009:51e3,544069:72e3,544048:54e3,534092:22e3,541075:133e3,541054:47e3,548024:15e3,512035:286e3,140085:43e3,136059:63e3,140047:41e3,140031:151e3,136052:39e3,533030:138e3,140038:38e3,537011:68e3,532027:87e3,140076:141e3,544075:137e3,544056:74e3,547008:43e3,536027:82e3,513014:26e3,539012:74e3,533005:22e3,535003:26e3,139049:61e3,139068:64e3,140007:34e3,532038:38e3,537064:118e3,512032:221e3,534087:16e3,534045:27e3,534066:156e3,534093:23e3,536013:81e3,548020:1e4,547023:9e3,532079:33e3,532058:46e3,603040:48e3,140061:79e3,140030:136e3,542030:143e3,538009:49e3,539081:25e3,136036:31e3,538012:74e3,538031:157e3,512016:35e3,544093:27e3,536066:156e3,139070:93e3,512002:33e3,538073:105e3,547038:37e3,544032:181e3,536083:38e3,607083:39e3,513046:48e3,513065:167e3,513084:58e3,535041:62e3,139021:14e3,547079:33e3,136028:107e3,548080:39e3,607022:14e3,512061:103e3,603080:34e3,544025:29e3,"084072":23e3,136048:58e3,536077:175e3,536052:32e3,607045:27e3,513071:34e3,547044:92e3,547065:134e3,535048:51e3,607027:79e3,537002:24e3,601061:73e3,538055:61e3,538074:119e3,603093:21e3,533077:175e3,533054:47e3,533096:101e3,536086:2e4,535028:92e3,536048:51e3,139005:26e3,53900
147:32e3,547072:17e3,607038:35e3,543073:105e3,546073:107e3,601087:16e3,601045:26e3,601066:139e3,603021:9e3,533043:76e3,544006:31e3,535015:22e3,535036:25e3,136008:47e3,513056:92e3,136094:38e3,543084:44e3,543067:47e3,536035:231e3,536014:17e3,541001:19e3,533091:2e4,607073:99e3,607047:38e3,601016:24e3,601035:206e3,546041:64e3,512062:124e3,535082:29e3,532008:44e3,538064:118e3,548092:24e3,140052:36e3,534070:89e3,542010:58e3,"084065":135e3,"084044":98e3,543016:25e3,543035:231e3,548045:29e3,539074:119e3,603077:151e3,603043:66e3,533027:82e3,140029:12e4,546093:26e3,541030:138e3,535052:32e3,136016:3e4,537027:82e3,548043:78e3,"084025":35e3,538041:62e3,538062:93e3,"084079":25e3,541076:147e3,541055:61e3,136067:56e3,603086:18e3,140084:45e3,603048:45e3,140046:37e3,533018:27e3,140011:68e3,535087:16e3,539028:92e3,535045:27e3,535064:118e3,546036:26e3,537033:194e3,543007:32e3,546026:67e3,546023:9e3,"084062":102e3,"084041":67e3,548038:37e3,548019:8e3,541087:16e3,541068:61e3,541049:6e4,136047:45e3,513041:81e3,601010:51e3,535059:55e3,139084:45e3,139069:7e4,512055:8e4,512074:153e3,539053:42e3,532039:49e3,532018:29e3,546007:33e3,140092:27e3,534086:2e4,544042:72e3,534044:9e4,534065:131e3,537083:38e3,"084070":99e3,140043:75e3,512007:43e3,136050:104e3,136009:56e3,513059:73e3,532059:58e3,607080:35e3,541034:213e3,541017:32e3,539082:29e3,603012:65e3,136005:28e3,139012:74e3,544092:25e3,537051:99e3,535039:46e3,546046:37e3,532064:122e3,532045:3e4,532087:17e3,535009:49e3,139062:96e3,140072:21e3,513085:55e3,539056:71e3,512085:55e3,539094:3e4,"084009":54e3,537084:44e3,139081:3e4,537046:35e3,536008:41e3,136038:42e3,536071:23e3,140093:28e3,548027:85e3,544026:68e3,532052:35e3,535008:41e3,607008:4e4,542053:45e3,534027:82e3,513053:56e3,607020:1e4,512084:58e3,547047:41e3,547064:121e3,547085:44e3,139019:11e3,140064:117e3,541073:105e3,547080:39e3,136066:168e3,140041:63e3,544038:38e3,544019:9e3,136075:145e3,539025:26e3,542044:93e3,542067:51e3,537036:25e3,513082:4e4,548077:178e3,533029:119e3,547073:107e3,534091:2e4,544058:46e3,513035:286e3,541067:47e3,541044:9e4,607072:17e3,140094:35e3,546011:7e4,536068:61e3,140023:12e3,539018:27e3,539039:46e3,607079:3e4,601029:109e3,543081:25e3,140001:22e3,532036:27e3,532015:24e3,546006:3e4,544064:122e3,544047:42e3,534043:76e3,512040:71e3,542019:9e3,536015:22e3,546033:198e3,513058:57e3,512039:61e3,607065:123e3,607046:35e3,607088:21e3,139078:15e3,601017:3e4,136004:4e4,539041:62e3,512024:22e3,532028:96e3,538018:27e3,538025:26e3,534077:175e3,513092:32e3,542021:12e3,547017:33e3,535038:36e3,603070:78e3,533002:24e3,535004:34e3,543017:32e3,601012:68e3,601031:141e3,537044:9e4,544044:93e3,541010:55e3,544082:33e3,603002:21e3,139036:28e3,538061:8e4,607031:147e3,544023:9e3,"084078":16e3,"084059":61e3,536092:22e3,548025:28e3,607092:24e3,532001:2e4,533017:32e3,543060:61e3,535088:2e4,532002:26e3,535046:35e3,534004:34e3,136006:35e3,538091:2e4,140018:3e4,"084063":113e3,536088:2e4,536061:8e4,536042:69e3,548076:15e4,534035:231e3,534020:9e3,136064:131e3,513050:121e3,535058:42e3,535079:33e3,539050:92e3,513034:264e3,601051:9e4,512075:17e4,546068:64e3,538047:39e3,603035:2e5,603014:16e3,533066:156e3,533045:27e3,533087:16e3,544008:44e3,512052:45e3,536059:55e3,601043:69e3,548036:26e3,601036:24e3,535014:17e3,607028:88e3,543061:8e4,601096:93e3,537007:32e3,601077:156e3,139030:136e3,603013:7e4,607001:19e3,547028:95e3,533051:99e3,542061:83e3,601060:57e3,535027:82e3,513069:9e4,546047:41e3,546085:44e3,538015:22e3,538034:213e3,543076:147e3,548094:32e3,541021:1e4,607058:42e3,544040:57e3,"084011":73e3,546071:25e3,541080:39e3,544003:28e3,535033:194e3,536009:49e3,603083:34e3,546053:44e3,547015:23e3,139050:93e3,535092:22e3,607009:47e3,548083:41e3,139083:41e3,541004:34e3,136044:103e3,"084077":175e3,"084054":52e3,607015:22e3,548026:67e3,603088:18e3,603052:29e3,140063:106e3,533031:157e3,533012:74e3,539068:61e3,532007:34e3,535043:76e3,534001:19e3,548007:33e3,601002:23e3,136007:38e3,537039:46e3,548051:102e3,"084037":37e3,"084014":23e3,544009:52e3,"084081":33e3,"084068":69e3,136043:84e3,548013:83e3,543011:68e3,541066:156e3,541043:76e3,532050:95e3,603059:48e3,140057:116e3,140022:17e3,539038:36e3,535057:118e3,542007:34e3,601005:22e3,537022:13e3,136020:14e3,532037:34e3,532012:77e3,140035:213e3,547005:24e3,544065:135e3,539024:14e3,534042:69e3,544086:23e3,541096:101e3,541079:33e3,541058:42e3,512056:92e3,538024:14e3,139094:35e3,136081:32e3,139077:164e3,541019:7e3,539042:69e3,539061:8e4,603024:13e3,544071:25e3,534055:61e3,534074:119e3,548016:26e3,537091:2e4,544061:83e3,542026:68e3,513026:86e3,533080:39e3,136080:32e3,542060:64e3,536040:55e3,539033:194e3,535007:32e3,542051:103e3,541024:14e3,607059:53e3,539092:22e3,136021:15e3,534049:6e4,544083:42e3,534032:176e3,536002:24e3,603003:23e3,547027:85e3,532075:137e3,532054:49e3,546094:32e3,532096:106e3,542093:27e3,534029:119e3,544036:27e3,139072:21e3,544074:123e3,541012:74e3,539047:39e3,538005:22e3,539085:42e3,136026:75e3,136019:12e3,513022:2e4,139022:17e3,537094:3e4,537075:133e3,537056:71e3,603006:25e3,140081:3e4,532061:83e3,532042:72e3,140048:52e3,534013:81e3,534036:25e3,547034:216e3,546050:94e3,513042:89e3,513061:103e3,513088:3e4,547056:73e3,547075:135e3,547094:32e3,607037:31e3,603020:8e3,543054:47e3,548001:2e4,544029:124e3,532093:27e3,542096:106e3,536094:3e4,542054:49e3,542075:137e3,535066:156e3,547061:82e3,140036:28e3,534083:38e3,544049:63e3,543036:25e3,537006:29e3,601074:107e3,512020:15e3,136053:49e3,607048:49e3,512067:64e3,533010:55e3,532026:68e3,547091:22e3,538016:25e3,538035:231e3,534052:32e3,534071:23e3,536026:64e3,601049:55e3,541060:61e3,533081:25e3,533004:34e3,601069:63e3,535002:24e3,533050:92e3,140020:13e3,532072:18e3,140004:36e3,537065:131e3,607033:181e3,538029:119e3,140086:26e3,536031:157e3,542037:34e3,541005:22e3,547022:14e3,513078:1
147e3,"084076":15e4,607052:32e3,140010:56e3,512021:16e3,513025:38e3,533011:68e3,136037:38e3,538013:81e3,532004:36e3,534002:24e3,601054:43e3,136012:83e3,139001:22e3,538051:99e3,547039:48e3,512043:97e3,"084086":29e3,"084069":75e3,"084048":56e3,603018:24e3,542069:72e3,543012:74e3,543031:157e3,607082:31e3,603094:27e3,603056:62e3,539003:26e3,136062:107e3,548060:63e3,535056:71e3,535073:105e3,546031:16e4,601091:22e3,538083:38e3,543004:34e3,513021:16e3,140065:127e3,536053:42e3,535035:231e3,534010:55e3,140037:34e3,535049:6e4,535068:61e3,140019:11e3,537001:19e3,538056:71e3,538075:133e3,603027:72e3,601055:56e3,533076:147e3,548034:216e3,548015:23e3,536085:42e3,535029:119e3,536047:39e3,544030:143e3,536081:25e3,539006:29e3,607039:45e3,543051:99e3,601086:21e3,512051:13e4,541027:82e3,601065:118e3,537093:23e3,533061:8e4,544005:24e3,537062:93e3,537041:62e3,536003:26e3,512080:4e4,544014:19e3,546059:57e3,537030:138e3,543087:16e3,543045:27e3,543066:156e3,512042:89e3,603034:184e3,548064:121e3,541013:81e3,"084021":15e3,140077:164e3,548050:94e3,513039:61e3,537074:119e3,537055:61e3,603092:19e3,546042:71e3,546061:82e3,532041:65e3,535083:38e3,532009:52e3,534014:17e3,534037:32e3,532020:11e3,548091:22e3,607030:13e4,539077:175e3,"084066":158e3,"084045":33e3,532082:33e3,603019:7e3,541083:38e3,512033:243e3,603061:69e3,603042:6e4,140051:1e5,140028:96e3,546092:24e3,136065:143e3,607004:33e3,534023:8e3,607034:198e3,537028:92e3,548061:82e3,534080:39e3,534082:29e3,543005:22e3,533068:61e3,541077:175e3,541052:32e3,603085:37e3,603047:34e3,140045:31e3,546064:121e3,140016:28e3,136071:3e4,539029:119e3,546014:19e3,542048:54e3,537032:176e3,537017:32e3,548031:16e4,513003:36e3,532021:12e3,601056:65e3,544077:179e3,544054:49e3,544096:106e3,544091:23e3,541086:2e4,542028:96e3,537010:55e3,542072:18e3,139028:96e3,534022:13e3,601030:125e3,139085:43e3,601008:39e3,139066:148e3,539052:32e3,535050:92e3,532019:9e3,544043:79e3,534047:39e3,534064:118e3,512083:51e3,548041:64e3,542015:24e3,542036:27e3,"084050":99e3,547030:142e3,546030:142e3,544013:84e3,536070:89e3,543018:27e3,539022:13e3,139091:25e3,512063:138e3,535065:131e3,541035:231e3,541014:17e3,539083:38e3,136013:89e3,"084020":14e3,534058:42e3,534053:42e3,537073:105e3,607078:1e4,532067:51e3,532044:93e3,532086:23e3,140060:63e3,534019:7e3,534038:36e3,607081:27e3,136076:159e3,513086:31e3,539059:55e3,543077:175e3,544022:15e3,543070:89e3,"084008":46e3,548040:56e3,532081:29e3,537085:42e3,601092:23e3,537047:39e3,136003:32e3,544027:87e3,532053:45e3,547032:179e3,542052:35e3,534026:64e3,513052:45e3,513077:218e3,513096:135e3,539088:2e4,547046:37e3,536043:76e3,139018:3e4,139039:48e3,543006:29e3,603050:8e4,513033:243e3,601042:63e3,538057:118e3,513037:43e3,544018:29e3,538020:9e3,542087:17e3,536084:44e3,542064:122e3,536046:35e3,513083:51e3,547051:102e3,601057:106e3,139026:68e3,607019:8e3,546004:35e3,601047:37e3,601064:107e3,513016:35e3,542071:25e3,533062:93e3,533041:62e3,136041:7e4,535017:32e3,535034:213e3,533020:9e3,512082:4e4,547083:41e3,543086:2e4,140055:62e3,543044:9e4,543065:131e3,542027:87e3,536037:32e3,601058:4e4,"084022":18e3,543019:7e3,607064:111e3,535023:8e3,607087:16e3,601018:26e3,535080:39e3,513080:4e4,513081:36e3,139040:55e3,538019:7e3,538038:36e3,546020:1e4,536023:8e3,512073:137e3,547033:198e3,"084088":27e3,"084067":55e3,607061:76e3,542009:52e3,139051:1e5,601013:74e3,601027:76e3,603041:54e3,533021:1e4,139056:71e3,539065:131e3,548062:96e3,541008:41e3,"084027":9e4,538043:76e3,548006:3e4,"084096":112e3,"084058":49e3,536093:23e3,139080:27e3,543027:82e3,603084:39e3,603065:113e3,603046:31e3,533035:231e3,533016:25e3,546003:28e3,532003:28e3,535047:39e3,534005:22e3,601083:38e3,136030:153e3,513002:33e3,538092:22e3,513036:35e3,140032:167e3,546016:26e3,536041:62e3,512023:14e3,136054:54e3,607060:59e3,513027:108e3,541093:23e3,543091:2e4,513070:119e3,535078:9e3,539070:89e3,601052:31e3,601071:23e3,538046:35e3,603036:22e3,544087:17e3,533067:47e3,"084003":31e3,533084:44e3,537081:25e3,541059:55e3,607003:26e3,603017:28e3,536050:92e3,543043:76e3,542024:16e3,541036:25e3,541015:22e3,603031:136e3,533073:105e3,136085:48e3,537072:16e3,539010:55e3,548035:235e3,546048:53e3,532066:16e4,546086:22e3,543096:101e3,538069:68e3,"084080":29e3,534039:46e3,139041:63e3,548074:121e3,548055:63e3,"084033":194e3,539079:33e3,539096:101e3,"084007":37e3,547084:46e3,544002:26e3,535011:68e3,535032:176e3,536006:29e3,"084052":39e3,603082:26e3,140091:25e3,532071:25e3,546077:178e3,534025:26e3,548057:121e3,513024:22e3,539066:156e3,136001:24e3,536020:9e3,139038:38e3,603030:12e4,537079:33e3,546040:56e3,542085:45e3,603053:37e3,543059:55e3,140039:48e3,544017:34e3,136077:186e3,542088:22e3,542046:38e3,542065:135e3,601003:25e3,537038:36e3,537019:7e3,512086:31e3,513009:64e3,542005:24e3,601040:5e4,"084002":29e3,139027:84e3,537050:92e3,548012:76e3,547010:57e3,541088:2e4,541061:8e4,541042:69e3,140075:129e3,140054:49e3,140025:32e3,543020:9e3,136045:34e3,539037:32e3,542058:46e3,542079:33e3,601006:27e3,537023:8e3,546013:83e3,532013:84e3,512005:32e3,547006:3e4,544066:16e4,544045:3e4,544055:64e3,512076:186e3,535030:138e3,542038:38e3,136011:76e3,140069:7e4,513011:88e3,136091:27e3,538068:61e3,139055:62e3,139076:141e3,539043:76e3,538001:19e3,542057:122e3,544051:103e3,534075:133e3,536022:13e3,547011:7e4,139073:106e3,539011:68e3,539032:176e3,535006:29e3,60704
141:59e3,546035:235e3,546063:109e3,601026:6e4,140008:42e3,512071:34e3,547087:17e3,534048:51e3,534069:68e3,538040:55e3,513019:13e3,542033:2e5,533070:89e3,548005:24e3,547026:67e3,140050:93e3,532076:151e3,532055:64e3,542092:25e3,534028:92e3,136084:5e4,139071:28e3,603015:2e4,513079:34e3,539048:51e3,538006:29e3,539086:2e4,546002:25e3,538032:176e3,139033:182e3,607050:86e3,601082:3e4,603076:127e3,603007:28e3,542086:23e3,538093:23e3,512022:2e4,544031:162e3,544012:77e3,542043:79e3,543001:19e3,543009:49e3,546070:92e3,513066:196e3,542004:36e3,547060:63e3,607021:11e3,140034:198e3,601053:39e3,512096:135e3,538049:6e4,538087:16e3,534056:71e3,140083:41e3,"084071":3e4,533085:42e3,536074:119e3,542074:123e3,547043:78e3,512014:26e3,543042:69e3,537005:22e3,601075:119e3,512088:3e4,533072:16e3,533057:118e3,535025:26e3,539030:138e3,547092:24e3,538017:32e3,136079:28e3,543055:61e3,543074:119e3,536029:119e3,601048:47e3,534096:101e3,"084032":178e3,544080:39e3,541040:55e3,544001:2e4,607054:45e3,535031:157e3,607096:97e3,603081:23e3,536065:131e3,140005:26e3,546018:28e3,607074:112e3,538028:92e3,543049:6e4,532030:143e3,536032:176e3,536011:68e3,541002:24e3,546017:33e3,543021:1e4,512013:103e3,542020:11e3,512092:32e3,607053:41e3,543029:119e3,603071:2e4,533033:194e3,537003:26e3,546009:51e3,532005:24e3,534003:26e3,547036:26e3,548072:17e3,546032:179e3,538052:32e3,538071:23e3,"084087":22e3,136093:3e4,"084049":66e3,548011:7e4,543013:81e3,542018:29e3,607063:1e5,603074:103e3,603057:103e3,533024:14e3,538023:8e3,535051:99e3,535072:16e3,601007:3e4,537024:14e3,512077:218e3,546012:76e3,538082:29e3,547007:33e3,"084093":32e3,547057:121e3,541094:3e4,541056:71e3,136015:28e3,140087:2e4,140068:64e3,539017:32e3,534030:138e3,140012:74e3,535084:44e3,513040:71e3,543083:38e3,535069:68e3,539040:55e3,537013:81e3,512087:24e3,538002:24e3,603026:56e3,533079:33e3,"084042":73e3,533094:3e4,548014:19e3,"084040":59e3,513017:43e3,544010:58e3,539009:49e3,539031:157e3,543052:32e3,543071:23e3,601021:11e3,547040:56e3,513005:32e3,541026:64e3,548018:28e3,139020:13e3,539073:105e3,603023:7e3,537020:9e3,534085:42e3,136083:45e3,534068:61e3,544004:36e3,538060:61e3,542002:26e3,513023:14e3,532077:179e3,546079:33e3,546096:104e3,532094:33e3,607075:124e3,513028:123e3,139053:44e3,541031:157e3,548044:92e3,539049:6e4,538007:32e3,539087:16e3,534006:29e3,139011:68e3,139032:167e3,532085:45e3,537077:175e3,537054:47e3,139006:31e3,603004:3e4,546043:78e3,532063:11e4,544011:71e3,534015:22e3,534034:213e3,607007:31e3,513044:119e3,548079:33e3,607010:53e3,539055:61e3,539076:147e3,136039:53e3,139029:12e4,537068:61e3,541082:29e3,542059:58e3,542041:65e3,548054:48e3,532091:23e3,607005:23e3,542056:74e3,542073:109e3,546066:159e3,537029:119e3,513073:137e3,547042:71e3,547067:5e4,547088:21e3,139014:21e3,139035:213e3,546024:15e3,541053:42e3,538094:3e4,539071:23e3,512047:52e3,140067:51e3,140044:92e3,543010:55e3,140017:34e3,136072:23e3,539026:64e3,542049:63e3,542068:65e3,136057:131e3,537035:231e3,537016:25e3,607013:76e3,547093:26e3,512081:36e3,544076:151e3,541085:42e3,536028:92e3,541047:39e3,"084060":68e3,140078:15e3,539002:24e3,607076:137e3,607055:58e3,539046:35e3,139044:92e3,139067:51e3,546084:46e3,601028:84e3,140002:27e3,535070:89e3,534088:2e4,538027:82e3,534046:35e3,534063:106e3,536033:194e3,542035:237e3,541003:26e3,601009:45e3,534051:99e3,539023:8e3,607071:24e3,601014:17e3,601037:3e4,136042:77e3},ve=[{disc:.466,grain:0,code:601,name:"클린화이트 무광",cat:"무광"},{disc:.466,grain:0,code:532,name:"웜화이트 무광",cat:"무광"},{disc:.466,grain:0,code:603,name:"퓨어그레이 무광",cat:"무광"},{disc:.466,grain:0,code:537,name:"마이티그레이 무광",cat:"무광"},{disc:.466,grain:0,code:533,name:"미스티그레이 무광",cat:"무광"},{disc:.466,grain:0,code:534,name:"실키그레이 무광",cat:"무광"},{disc:.466,grain:0,code:535,name:"카키그레이 무광",cat:"무광"},{disc:.466,grain:0,code:536,name:"코코아그레이 무광",cat:"무광"},{disc:.466,grain:0,code:541,name:"라떼베이지 무광",cat:"무광"},{disc:.466,grain:0,code:538,name:"딥블루 무광",cat:"무광"},{disc:.466,grain:0,code:542,name:"스모키스카이블루 무광",cat:"무광"},{disc:.466,grain:0,code:543,name:"허브티그린 무광",cat:"무광"},{disc:.466,grain:0,code:539,name:"헤이지그린 무광",cat:"무광"}
14,{disc:.466,grain:0,code:84,name:"핑크 무광",cat:"무광"},{disc:.464,grain:0,code:544,name:"웜화이트 유광",cat:"유광"},{disc:.464,grain:0,code:607,name:"클린화이트 유광",cat:"유광"},{disc:.464,grain:0,code:546,name:"라이트그레이지 유광",cat:"유광"},{disc:.464,grain:0,code:548,name:"마이티그레이 유광",cat:"유광"},{disc:.464,grain:0,code:547,name:"모카그레이 유광",cat:"유광"},{disc:.439,grain:1,code:140,name:"오크내츄럴",cat:"우드"},{disc:.439,grain:1,code:139,name:"오크워시",cat:"우드"},{disc:.439,grain:1,code:136,name:"월넛(MFB)",cat:"우드"},{disc:.459,grain:0,code:513,name:"세라믹그레이",cat:"세라믹"},{disc:.459,grain:0,code:512,name:"세라믹프로스트",cat:"세라믹"}],b0={무광:"솔리드 무광",유광:"솔리드 유광",우드:"우드",세라믹:"세라믹"};function _e(s){const n=String(s);return n.length>=3?n:"0".repeat(3-n.length)+n}function K(s,n){const c=f0[_e(s)+_e(n)];return c??null}function y0(s,n,c){const u=Math.min(s,n),d=Math.max(s,n);let t=null;for(const l of Y)if(u<=l.min&&d<=l.max){const x=K(c,l.code);x!=null&&(t==null||x<t.price)&&(t={spec:l,price:x})}return t}function j0(s,n,c){const u=Math.min(s,n),d=Math.max(s,n),t=[];if(d>600&&d<=1210){let l=null;for(const b of Y)if(s<=b.w&&n<=b.h){const j=K(c,b.code);j!=null&&(l==null||j<l.price)&&(l={spec:b,price:j})}l&&t.push(l);let x=null;for(const b of Y)if(u<=b.min&&d<=b.max){const j=K(c,b.code);if(j!=null){const I=Math.round(j*1.3);(x==null||I<x.price)&&(x={spec:b,price:I})}}x&&t.push(x);let h=null;for(const b of Y)if(u<=b.min&&1210<=b.max){const j=K(c,b.code);j!=null&&(h==null||j<h.price)&&(h={spec:b,price:j})}h&&t.push(h)}else{let l=null;for(const x of Y)if(u<=x.min&&d<=x.max){const h=K(c,x.code);h!=null&&(l==null||h<l.price)&&(l={spec:x,price:h})}l&&t.push(l)}return t.length===0?null:(t.sort((l,x)=>l.price-x.price),t[0])}function N0(s){for(const n of p0)if(s<=n.w)return n.code;return null}function w0(s,n,c){if(!(n>0)||!(c>0))return null;let u=null,d="";if(n<=195&&c>1600&&c<2440){const l=N0(n<100?100:n);l!=null&&(u=K(s.code,l),d=`좁은자재 → 몰딩 ${l}`)}else{const l=s.grain===0?y0(n,c,s.code):j0(n,c,s.code);l&&(u=l.price,d=`규격 ${l.spec.w}×${l.spec.h} (${l.spec.code})`)}return u==null?null:{moklimPrice:Math.ceil(u/1e3)*1e3,label:d}}async function v0(s){if(!(s.moklimPrice>0)||!(s.invoicePrice>0))throw new Error("목림가와 거래명세서 단가가 모두 0보다 커야 합니다.");const n=Number((s.invoicePrice/s.moklimPrice).toFixed(4)),{error:c}=await Q.from("tp_moklim_cost_samples").insert({color_code:s.colorCode,color_name:s.colorName,category:s.category,width:s.width,length:s.length,moklim_price:s.moklimPrice,invoice_price:s.invoicePrice,ratio:n});if(c)throw c}function Ce(s){if(s.length===0)return 0;const n=[...s].sort((u,d)=>u-d),c=Math.floor(n.length/2);return n.length%2===0?(n[c-1]+n[c])/2:n[c]}function _0(s){const n=new Map,c=new Map;for(const t of s){const l=Number(t.ratio);l>0&&(n.has(t.color_code)||n.set(t.color_code,[]),n.get(t.color_code).push(l),c.has(t.category)||c.set(t.category,[]),c.get(t.category).push(l))}const u={};n.forEach((t,l)=>{u[l]={discount:Number(Ce(t).toFixed(4)),n:t.length}});const d={};return c.forEach((t,l)=>{d[l]={discount:Number(Ce(t).toFixed(4)),n:t.length}}),{byColor:u,byCategory:d}}async function C0(s=12){const n=new Date;n.setMonth(n.getMonth()-s);const{data:c,error:u}=await Q.from("tp_moklim_cost_samples").select("color_code, category, ratio").gte("created_at",n.toISOString());if(u)throw u;return _0(c??[])}function k0(){const[s,n]=g.useState({byColor:{},byCategory:{}}),[c,u]=g.useState(!0),d=g.useCallback(async()=>{u(!0);try{n(await C0())}catch(t){console.error("[moklim] 학습 할인율 로드 실패:",t)}finally{u(!1)}},[]);return g.useEffect(()=>{d()},[d]),{learned:s,loading:c,reload:d}}const S0={무광:"솔리드 무광",유광:"솔리드 유광",우드:"우드",세라믹:"세라믹"},P0=["무광","유광","우드","세라믹"],oe=5,M0=.04;function $0({sellParamsByCategory:s}){const[n,c]=g.useState(0),[u,d]=g.useState(600),[t,l]=g.useState(800),[x,h]=g.useState(""),[b,j]=g.useState(!1),[I,P]=g.useState(""),{learned:F,reload:O}=k0(),M=ve[n],N=g.useMemo(()=>{const S=w0(M,u,t);if(!S)return null;const C=F.byColor[M.code],R=F.byCategory[M.cat];let y=M.disc,m="기본값";C&&C.n>=oe?(y=C.discount,m=`학습 ${C.n}건(색상)`):R&&R.n>=oe&&(y=R.discount,m=`학습 ${R.n}건(카테고리)`);const i=Math.round(S.moklimPrice*y),f=b0[M.cat],o=s?.[f]??t0[f];let a=null;o&&(a=r0({category:{name:f}},u,t,18,o));const p=a!=null&&a>0?(a-i)/a:null;
14return{moklimPrice:S.moklimPrice,label:S.label,cost:i,sellPrice:a,margin:p,discount:y,discSource:m}},[M,u,t,s,F]),v=g.useMemo(()=>{const S=F.byCategory[M.cat];if(!S||S.n<oe)return null;const C=(S.discount-M.disc)/M.disc;return Math.abs(C)<M0?null:{learned:S.discount,base:M.disc,up:C>0,pct:Math.abs(C*100),n:S.n}},[F,M]),$=g.useMemo(()=>{if(!N)return null;const S=parseInt(x,10);if(!(S>0))return null;const C=S-N.cost,R=C/N.cost*100,y=Math.abs(R),m=C>=0?"+":"−";let i="text-green-600",f="정상 범위";return y>=8?(i="text-red-600",f=C>0?"과청구 의심":"저청구(이득)"):y>=3&&(i="text-amber-600",f="약간 차이"),{text:`${m}${Math.abs(C).toLocaleString()}원 (${m}${y.toFixed(1)}%) · ${f}`,color:i}},[N,x]),A=g.useCallback(async()=>{if(!N)return;const S=parseInt(x,10);if(S>0){j(!0),P("");try{await v0({colorCode:M.code,colorName:M.name,category:M.cat,width:u,length:t,moklimPrice:N.moklimPrice,invoicePrice:S}),P("저장됨 · 학습 반영"),await O()}catch(C){console.error("[moklim] 샘플 저장 실패:",C),P("저장 실패")}finally{j(!1)}}},[N,x,M,u,t,O]);return e.jsxs(U,{children:[e.jsx(B,{className:"pb-3",children:e.jsxs(G,{className:"text-lg flex flex-wrap items-center gap-x-2 gap-y-1",children:["매입원가 계산기",e.jsx("span",{className:"text-xs font-normal text-gray-400",children:"목림 단가 로직 기반 · 거래명세서로 학습"})]})}),e.jsxs(V,{className:"space-y-4",children:[v&&e.jsxs("div",{className:"flex items-start gap-2 rounded-md border border-amber-200 bg-amber-50 px-3 py-2 text-xs text-amber-700",children:[e.jsx($e,{className:"w-4 h-4 mt-0.5 shrink-0"}),e.jsxs("span",{children:["목림 단가 변동 의심 — ",M.cat," 실측 할인율 ",v.learned.toFixed(3)," (기준 ",v.base.toFixed(3),", ",v.up?"+":"−",v.pct.toFixed(1),"%, 표본 ",v.n,"건). ",v.up?"목림이 단가를 올린 것으로 보입니다 — 단가표 재추출을 권장합니다.":"실측 할인이 기준보다 큽니다 — 데이터 확인을 권장합니다."]})]}),e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-3 gap-3",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs font-medium text-gray-500 mb-1",children:"색상"}),e.jsx("select",{value:n,onChange:S=>c(Number(S.target.value)),className:"w-full text-sm border border-gray-300 rounded-lg px-3 py-2 focus:outline-none focus:ring-1 focus:ring-blue-500",children:P0.map(S=>e.jsx("optgroup",{label:S0[S],children:ve.map((C,R)=>C.cat===S?e.jsx("option",{value:R,children:C.name},R):null)},S))})]}),e.jsx(ke,{label:"가로 (mm)",value:u,onChange:d}),e.jsx(ke,{label:"세로 (mm)",value:t,onChange:l})]}),N?e.jsxs("div",{className:"grid grid-cols-2 sm:grid-cols-4 gap-3",children:[e.jsx(H,{label:"목림가",value:`${N.moklimPrice.toLocaleString()}원`,sub:N.label}),e.jsx(H,{label:"매입원가",value:`${N.cost.toLocaleString()}원`,sub:`× ${N.discount.toFixed(3)} · ${N.discSource}`,highlight:!0}),e.jsx(H,{label:"우리 판매가",value:N.sellPrice!=null?`${N.sellPrice.toLocaleString()}원`:"-"}),e.jsx(H,{label:"마진율",value:N.margin!=null?`${Math.round(N.margin*100)}%`:"-",sub:"판매가 기준"})]}):e.jsx("p",{className:"text-sm text-gray-400",children:"규격 범위를 벗어났습니다 (가로 50~1210mm, 세로 50~2440mm)."}),N&&e.jsxs("div",{className:"border-t border-gray-100 pt-3 space-y-2",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx("label",{className:"text-xs font-medium text-gray-500",children:"거래명세서 단가"}),e.jsx("input",{type:"number",value:x,onChange:S=>{h(S.target.value),P("")},placeholder:"실제 매입가",className:"no-spinner w-32 text-sm border border-gray-300 rounded-lg px-3 py-1.5 focus:outline-none focus:ring-1 focus:ring-blue-500"}),e.jsx("span",{className:"text-xs text-gray-400",children:"vs 예상 매입원가"}),$?e.jsx("span",{className:`text-sm font-semibold ${$.color}`,children:$.text}):e.jsx("span",{className:"text-sm text-gray-400",children:"-"})]}),e.jsx(E,{children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("button",{onClick:A,disabled:b||!(parseInt(x,10)>0),className:"text-sm px-3 py-1.5 bg-blue-600 text-white rounded-lg hover:bg-blue-700 disabled:opacity-50 disabled:cursor-not-allowed transition-colors",children:b?"저장 중...":"학습에 저장"}),I&&e.jsx("span",{className:"text-xs text-gray-500",children:I})]})})]}),e.jsx("p",{className:"text-xs text-gray-400 leading-relaxed",children:"* 목림가는 목림 단가표 기준 ±0, 매입원가는 ±2~3%(목림 라인별 청구 변동). 거래명세서를 저장할수록 색상별 할인율이 자동 보정되고, 목림 단가 인상도 감지됩니다. 용도 구분 없이 사이즈 기준(좁고 긴 조각은 자동 몰딩 단가)."})]})]})}function ke({label:s,value:n,onChange:c}){return e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs font-medium text-gray-500 mb-1",children:s}),e.jsx("input",{type:"number",value:n,onChange:u=>c(parseInt(u.target.value,10)||0),className:"no-spinner w-full text-sm border border-gray-300 rounded-lg px-3 py-2 focus:outline-none focus:ring-1 focus:ring-blue-500"})]})}function H({label:s,value:n,sub:c,highlight:u}){return e.jsxs("div",{className:`rounded-md p-3 ${u?"bg-blue-50":"bg-gray-50"}`,children:[e.jsx("div",{className:"text-xs text-gray-500",children:s}),e.jsx("div",{className:`text-lg font-semibold ${u?"text-blue-700":"text-gray-900"}`,children:n}),c&&e.jsx("div",{className:"text-[11px] text-gray-400 mt-0.5 truncate",title:c,children:c})]})}const T={coefficient:"기본 계수",lFormula:"L 계수 방식",lCoeff:"L 선형 계수",lOffset:"L 오프셋",wCoeff:"W 선형 계수",wOffset:"W 오프셋",correction:"보정 계수",slopeRatio:"대면적 기울기 비율"};function L0(s){const n=(s-1)*100;return n===0?"변동 없음":`${n>0?"+":""}${n.toFixed(1)}%`}function A0(s){const n=Math.abs((s-1)*100);return n===0?"text-gray-600":n>=20?"text-red-600":n>=10?"text-orange-500":s>1?"text-blue-600":"text-green-600"}function I0(s){const n=Math.abs((s-1)*100);return n>=20?"destructive":n===0?"secondary":"outline"}function D0({pricingDataList:s,loading:n,saving:c,hasDirtyItems:u,updateParam:d,saveParams:t,resetParams:l,saveAll:x,applyBulkMultiplier:h,simWidth:b,simLength:j,setSimWidth:I,setSimLength:P,simulationResults:F,changeLog:O,changeLogLoading:M}){const[N,v]=g.useState(new Set),[$,A]=g.useState(!1),[S,C]=g.useState("0"),R=g.useMemo(()=>Object.fromEntries(s.map(i=>[i.category.name,i.params])),[s]),y=i=>{v(f=>{const o=new Set(f);return o.has(i)?o.delete(i):o.add(i),o})},m=()=>{const i=parseFloat(S);if(isNaN(i))return;const f=1+i/100;f<=0||h(f)};return n?e.jsx("div",{className:"flex items-center justify-center py-20",children:e.jsxs("div",{className:"text-center",children:[e.jsx("div",{className:"animate-spin rounded-full h-10 w-10 border-b-2 border-blue-600 mx-auto mb-3"}),e.jsx("p",{className:"text-gray-500 text-sm",children:"단가 데이터 로딩 중..."})]})}):s.length===0?e.jsxs("div",{className:"text-center py-20 text-gray-500",children:[e.jsx("p",{children:"코팅합판 카테고리가 없습니다."}),e.jsx("p",{className:"text-sm mt-1",children:"목재 관리 탭에서 카테고리를 먼저 등록해주세요."})]}):e.jsxs("div",{className:"space-y-6",children:[e.jsx($0,{sellParamsByCategory:R}),e.jsxs("div",{className:"flex flex-col sm:flex-row items-start sm:items-center justify-between gap-4",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"text-xl font-bold text-gray-900",children:"코팅합판 단가 관리"}),e.jsx("p",{className:"text-sm text-gray-500 mt-1",children:"4개 카테고리의 가격 공식 파라미터를 관리합니다."})]}),e.jsx(E,{children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsxs("div",{className:"flex items-center gap-2 bg-gray-50 rounded-lg px-3 py-2 border border-gray-200",children:[e.jsx("span",{className:"text-sm text-gray-600 whitespace-nowrap",children:"일괄 조정"}),e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx("input",{type:"number",step:"1",value:S,onChange:i=>C(i.target.value),placeholder:"0",className:"no-spinner w-16 text-sm text-right border border-gray-300 rounded px-2 py-1 focus:outline-none focus:ring-1 focus:ring-blue-500"}),e.jsx("span",{className:"text-sm text-gray-500",children:"%"})]}),e.jsx("button",{onClick:m,className:"text-sm px-3 py-1 bg-gray-200 hover:bg-gray-300 rounded transition-colors whitespace-nowrap",children:"전체 적용"})]}),e.jsxs("button",{onClick:x,disabled:!u||c==="all",className:"flex items-center gap-2 px-4 py-2 bg-blue-600 text-white rounded-lg hover:bg-blue-700 disabled:opacity-50 disabled:cursor-not-allowed transition-colors",children:[e.jsx(me,{className:"w-4 h-4"}),c==="all"?"저장 중...":"전체 저장"]})]})})]}),e.jsx("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-4",children:s.map(({category:i,params:f,isDirty:o})=>{const a=N.has(i.id),p=c===i.id,k=Math.abs((f.priceMultiplier-1)*100)>=20;return e.jsxs(U,{className:`relative ${o?"ring-2 ring-blue-300":""}`,children:[o&&e.jsx("div",{className:"absolute top-2 right-2",children:e.jsx(J,{variant:"outline",className:"bg-blue-50 text-blue-700 border-blue-200 text-xs",children:"수정됨"})}),e.jsx(B,{className:"pb-3",children:e.jsxs(G,{className:"text-lg flex items-center gap-3",children:[i.name,e.jsx(J,{variant:I0(f.priceMultiplier),children:e.jsx("span",{className:A0(f.priceMultiplier),children:L0(f.priceMultiplier)})}),k&&e.jsx($e,{className:"w-4 h-4 text-red-500"})]})}),e.jsxs(V,{className:"space-y-4",children:[e.jsxs("div",{className:"grid grid-cols-3 gap-3",children:[e.jsx(W,{label:"최소가",value:f.minPrice,onChange:r=>d(i.id,"minPrice",r),suffix:"원"}),e.jsx(W,{label:"기준단가",value:f.baseAreaPrice,onChange:r=>d(i.id,"baseAreaPrice",r),suffix:"원"}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs font-medium text-gray-500 mb-1",children:"조정률"}),e.jsxs("div",{className:`flex items-center gap-1 rounded-md border px-2 py-1.5 ${k?"border-red-300 bg-red-50":"border-gray-300 bg-white"}`,children:[e.jsx("input",{type:"number",step:"1",value:Math.round((f.priceMultiplier-1)*100),onChange:r=>{const _=parseFloat(r.target.value);isNaN(_)||d(i.id,"priceMultiplier",1+_/100)},className:"no-spinner w-full text-sm bg-transparent focus:outline-none text-right"}),e.jsx("span",{className:"text-xs text-gray-500 whitespace-nowrap",children:"%"})]})]})]}),e.jsxs("button",{onClick:()=>y(i.id),className:"flex items-center gap-1.5 text-sm text-gray-500 hover:text-gray-700 transition-colors",children:[a?e.jsx(xe,{className:"w-4 h-4"}):e.jsx(ue,{className:"w-4 h-4"}),"상세 계수 설정"]}),a&&e.jsxs("div",{className:"border-t border-gray-100 pt-4 space-y-4",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs font-medium text-gray-500 mb-1",children:T.lFormula}),e.jsxs("select",{value:f.lFormula,onChange:r=>d(i.id,"lFormula",r.target.value),className:"w-full text-sm border border-gray-300 rounded-lg px-3 py-2 focus:outline-none focus:ring-1 focus:ring-blue-500",children:[e.jsx("option",{value:"linear",children:"linear (L / 200)"}),e.jsx("option",{value:"coefficients",children:"coefficients (lCoeff * L + lOffset)"})]})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsx(W,{label:T.coefficient,value:f.coefficient,onChange:r=>d(i.id,"coefficient",r)}),e.jsx(W,{label:T.correction,value:f.correction,onChange:r=>
14d(i.id,"correction",r),step:.001})]}),f.lFormula==="coefficients"&&e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsx(W,{label:T.lCoeff,value:f.lCoeff??0,onChange:r=>d(i.id,"lCoeff",r),step:1e-5}),e.jsx(W,{label:T.lOffset,value:f.lOffset??0,onChange:r=>d(i.id,"lOffset",r),step:.001})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsx(W,{label:T.wCoeff,value:f.wCoeff,onChange:r=>d(i.id,"wCoeff",r),step:1e-5}),e.jsx(W,{label:T.wOffset,value:f.wOffset,onChange:r=>d(i.id,"wOffset",r),step:.001})]}),e.jsx(W,{label:T.slopeRatio,value:f.slopeRatio,onChange:r=>d(i.id,"slopeRatio",r),step:.01})]}),e.jsx(E,{children:e.jsxs("div",{className:"flex items-center gap-2 pt-2 border-t border-gray-100",children:[e.jsxs("button",{onClick:()=>t(i.id),disabled:!o||p,className:"flex-1 flex items-center justify-center gap-1.5 px-3 py-2 text-sm text-white bg-blue-600 hover:bg-blue-700 disabled:opacity-50 disabled:cursor-not-allowed rounded-lg transition-colors",children:[e.jsx(me,{className:"w-4 h-4"}),p?"저장 중...":"저장"]}),e.jsxs("button",{onClick:()=>l(i.id),disabled:!o,className:"flex items-center justify-center gap-1.5 px-3 py-2 text-sm text-gray-600 bg-gray-100 hover:bg-gray-200 disabled:opacity-50 disabled:cursor-not-allowed rounded-lg transition-colors",children:[e.jsx(Le,{className:"w-4 h-4"}),"되돌리기"]})]})})]})]},i.id)})}),e.jsx(h0,{simWidth:b,simLength:j,setSimWidth:I,setSimLength:P,simulationResults:F}),e.jsxs(U,{children:[e.jsx(B,{className:"pb-3",children:e.jsxs("button",{onClick:()=>A(!$),className:"flex items-center gap-2 text-left",children:[e.jsx(Ae,{className:"w-4 h-4 text-gray-500"}),e.jsx(G,{className:"text-base",children:"변경 이력"}),e.jsxs(J,{variant:"secondary",className:"ml-auto",children:[O.length,"건"]}),$?e.jsx(xe,{className:"w-4 h-4"}):e.jsx(ue,{className:"w-4 h-4"})]})}),$&&e.jsx(V,{children:M?e.jsx("p",{className:"text-sm text-gray-500 text-center py-4",children:"로딩 중..."}):O.length===0?e.jsx("p",{className:"text-sm text-gray-500 text-center py-4",children:"변경 이력이 없습니다."}):e.jsx("div",{className:"space-y-3",children:O.map(i=>{const f=i.old_params,o=i.new_params,a=[],p=f?.priceMultiplier??1,w=o?.priceMultiplier??1;return p!==w&&a.push({label:"조정률",oldVal:`${Math.round((p-1)*100)}%`,newVal:`${Math.round((w-1)*100)}%`}),(f?.minPrice??0)!==(o?.minPrice??0)&&a.push({label:"최소가",oldVal:`${(f?.minPrice??0).toLocaleString()}원`,newVal:`${(o?.minPrice??0).toLocaleString()}원`}),(f?.baseAreaPrice??0)!==(o?.baseAreaPrice??0)&&a.push({label:"기준단가",oldVal:`${(f?.baseAreaPrice??0).toLocaleString()}원`,newVal:`${(o?.baseAreaPrice??0).toLocaleString()}원`}),(f?.coefficient??0)!==(o?.coefficient??0)&&a.push({label:"계수",oldVal:`${f?.coefficient}`,newVal:`${o?.coefficient}`}),(f?.correction??0)!==(o?.correction??0)&&a.push({label:"보정계수",oldVal:`${f?.correction}`,newVal:`${o?.correction}`}),(f?.slopeRatio??0)!==(o?.slopeRatio??0)&&a.push({label:"감쇠율",oldVal:`${f?.slopeRatio}`,newVal:`${o?.slopeRatio}`}),e.jsxs("div",{className:"border border-gray-100 rounded-lg p-3 text-sm",children:[e.jsxs("div",{className:"flex items-center justify-between mb-1",children:[e.jsx("span",{className:"font-medium text-gray-900",children:i.category_name}),e.jsx("span",{className:"text-xs text-gray-400",children:new Date(i.changed_at).toLocaleString("ko-KR")})]}),a.length>0?e.jsx("div",{className:"flex flex-wrap gap-x-4 gap-y-0.5 mt-1 text-xs text-gray-600",children:a.map(k=>e.jsxs("span",{children:[k.label,": ",e.jsx("span",{className:"text-gray-400",children:k.oldVal})," → ",e.jsx("span",{className:"text-gray-900",children:k.newVal})]},k.label))}):e.jsx("p",{className:"text-xs text-gray-400 mt-1",children:"변경된 값 없음 (저장만 실행)"})]},i.id)})})})]})]})}function W({label:s,value:n,onChange:c,step:u=1,suffix:d,highlight:t,warning:l}){return e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs font-medium text-gray-500 mb-1",children:s}),e.jsxs("div",{className:"relative",children:[e.jsx("input",{type:"number",step:u,value:n,onChange:x=>c(parseFloat(x.target.value)||0),className:`
15            no-spinner w-full text-sm border rounded-lg px-3 py-2 focus:outline-none focus:ring-1 transition-colors
16            ${t?"font-bold text-lg":""}
17            ${l?"border-red-300 bg-red-50 focus:ring-red-500 text-red-700":"border-gray-300 focus:ring-blue-500"}
18          `}),d&&e.jsx("span",{className:"absolute right-3 top-1/2 -translate-y-1/2 text-xs text-gray-400",children:d})]})]})}function F0({prices:s,loading:n,saving:c,categories:u,filterCategory:d,setFilterCategory:t,updateField:l,saveAll:x,applyBulkPercent:h,resetAll:b,hasDirtyItems:j,simWidth:I,simLength:P,setSimWidth:F,setSimLength:O,changeLog:M,changeLogLoading:N}){const[v,$]=g.useState({}),A=m=>v[m]??"0",S=(m,i)=>$(f=>({...f,[m]:i})),C=async m=>{const i=parseFloat(A(m));isNaN(i)||i===0||confirm(`${m} 가격을 ${i>0?"+":""}${i}% 조정합니다. 계속하시겠습니까?`)&&(await h(i,m),S(m,"0"))},R=async()=>{const m=Object.entries(v).filter(([,f])=>{const o=parseFloat(f);return!isNaN(o)&&o!==0});if(m.length===0)return;const i=m.map(([f,o])=>`${f}: ${parseFloat(o)>0?"+":""}${o}%`).join(`
19`);if(confirm(`다음 카테고리별 조정을 적용합니다:
20
21${i}
22
23계속하시겠습니까?`)){for(const[f,o]of m)await h(parseFloat(o),f);$({})}};if(n)return e.jsx("div",{className:"flex items-center justify-center py-20",children:e.jsxs("div",{className:"text-center",children:[e.jsx("div",{className:"animate-spin rounded-full h-10 w-10 border-b-2 border-blue-600 mx-auto mb-3"}),e.jsx("p",{className:"text-gray-500 text-sm",children:"가격 데이터 로딩 중..."})]})});const y={};for(const m of s){const i=m.wood_name||m.wood_id;y[i]||(y[i]=[]),y[i].push(m)}return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex flex-col sm:flex-row items-start sm:items-center justify-between gap-4",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"text-xl font-bold text-gray-900",children:"일반목재 단가 관리"}),e.jsx("p",{className:"text-sm text-gray-500 mt-1",children:"집성목, 합판/보드의 두께별 단가를 관리합니다."})]}),e.jsx(E,{children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("button",{onClick:b,disabled:!j,className:"flex items-center gap-1.5 px-3 py-2 text-sm text-gray-600 bg-gray-100 hover:bg-gray-200 disabled:opacity-50 rounded-lg transition-colors",children:e.jsx(Le,{className:"w-4 h-4"})}),e.jsxs("button",{onClick:x,disabled:!j||c,className:"flex items-center gap-2 px-4 py-2 bg-blue-600 text-white rounded-lg hover:bg-blue-700 disabled:opacity-50 disabled:cursor-not-allowed transition-colors",children:[e.jsx(me,{className:"w-4 h-4"}),c?"저장 중...":"전체 저장"]})]})})]}),e.jsx(E,{children:e.jsxs(U,{children:[e.jsx(B,{className:"pb-3",children:e.jsx(G,{className:"text-base",children:"카테고리별 일괄 조정"})}),e.jsxs(V,{children:[e.jsx("div",{className:"grid grid-cols-2 sm:grid-cols-3 lg:grid-cols-4 gap-3",children:u.map(m=>e.jsxs("div",{className:"flex items-center gap-2 bg-gray-50 rounded-lg px-3 py-2 border border-gray-200",children:[e.jsx("span",{className:"text-sm text-gray-700 font-medium min-w-0 truncate flex-1",children:m}),e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx("input",{type:"number",step:"1",value:A(m),onChange:i=>S(m,i.target.value),className:"no-spinner w-14 text-sm text-right border border-gray-300 rounded px-1.5 py-1 focus:outline-none focus:ring-1 focus:ring-blue-500"}),e.jsx("span",{className:"text-xs text-gray-500",children:"%"})]}),e.jsx("button",{onClick:()=>C(m),disabled:c||parseFloat(A(m))===0,className:"text-xs px-2 py-1 bg-gray-200 hover:bg-gray-300 disabled:opacity-50 rounded transition-colors whitespace-nowrap",children:"적용"})]},m))}),u.length>1&&e.jsx("div",{className:"mt-3 flex justify-end",children:e.jsx("button",{onClick:R,disabled:c||Object.values(v).every(m=>parseFloat(m)===0||isNaN(parseFloat(m))),className:"text-sm px-4 py-1.5 bg-blue-600 text-white hover:bg-blue-700 disabled:opacity-50 rounded-lg transition-colors",children:"입력된 조정률 일괄 적용"})})]})]})}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx("button",{onClick:()=>t("all"),className:`px-3 py-1.5 text-sm rounded-full transition-colors ${d==="all"?"bg-blue-600 text-white":"bg-gray-100 text-gray-700 hover:bg-gray-200"}`,children:"전체"}),u.map(m=>e.jsx("button",{onClick:()=>t(m),className:`px-3 py-1.5 text-sm rounded-full transition-colors ${d===m?"bg-blue-600 text-white":"bg-gray-100 text-gray-700 hover:bg-gray-200"}`,children:m},m))]}),e.jsx("div",{className:"space-y-4",children:Object.entries(y).map(([m,i])=>{const f=i.some(o=>o.isDirty);return e.jsxs(U,{className:f?"ring-2 ring-blue-200":"",children:[e.jsx(B,{className:"pb-3",children:e.jsxs(G,{className:"text-base flex items-center gap-2",children:[m,e.jsx(J,{variant:"secondary",className:"text-xs",children:i[0]?.category_name}),f&&e.jsx(J,{variant:"outline",className:"text-xs text-blue-600",children:"수정됨"})]})}),e.jsx(V,{children:e.jsxs("table",{className:"w-full text-sm table-fixed",children:[e.jsxs("colgroup",{children:[e.jsx("col",{className:"w-[20%]"}),e.jsx("col",{className:"w-[18%]"}),e.jsx("col",{className:"w-[20%]"}),e.jsx("col",{className:"w-[18%]"}),e.jsx("col",{className:"w-[24%]"})]}),e.jsx("thead",{children:e.jsxs("tr",{className:"border-b border-gray-100",children:[e.jsx("th",{className:"text-left py-2 text-gray-500 font-medium",children:"규격"}),e.jsx("th",{className:"text-right py-2 text-gray-500 font-medium",children:"기준 단가"}),e.jsx("th",{className:"text-right py-2 text-gray-500 font-medium",children:"기준 최소금액"}),e.jsx("th",{className:"text-right py-2 text-gray-500 font-medium",children:"조정률"}),e.jsx("th",{className:"text-right py-2 text-gray-500 font-medium",children:"적용 단가"})]})}),e.jsx("tbody",{children:i.map(o=>{const a=o.edited_multiplier,p=Math.round((a-1)*100),w=Math.ceil(o.unit_price*a),k=Math.ceil(o.area_price*a),r=a!==o.price_multiplier;return e.jsxs("tr",{className:`border-b border-gray-50 ${o.isDirty?"bg-blue-50/50":""}`,children:[e.jsx("td",{className:"py-2 text-gray-900",children:o.spec_label||`${o.thickness}mm`}),e.jsx("td",{className:"py-2 text-right text-gray-500",children:o.unit_price.toLocaleStr
23ing()}),e.jsx("td",{className:"py-2 text-right text-gray-500",children:o.area_price.toLocaleString()}),e.jsx("td",{className:"py-2 text-right",children:e.jsxs("div",{className:"inline-flex items-center gap-1",children:[e.jsx("input",{type:"number",step:"1",value:p,onChange:_=>{const D=parseInt(_.target.value);isNaN(D)||l(o.id,"multiplier",1+D/100)},className:`no-spinner w-16 text-right text-sm border rounded px-2 py-1 focus:outline-none focus:ring-1 focus:ring-blue-500 ${r?"border-blue-400 bg-blue-50":"border-gray-300"}`}),e.jsx("span",{className:"text-xs text-gray-500",children:"%"})]})}),e.jsxs("td",{className:"py-2 text-right",children:[e.jsx("span",{className:r?"text-blue-600 font-medium":"text-gray-700",children:w.toLocaleString()}),e.jsx("span",{className:"text-gray-400 mx-1",children:"/"}),e.jsx("span",{className:r?"text-blue-600":"text-gray-500",children:k.toLocaleString()})]})]},o.id)})})]})})]},m)})}),s.length===0&&e.jsx("div",{className:"text-center py-20 text-gray-500",children:e.jsx("p",{children:"일반목재 가격 데이터가 없습니다."})}),e.jsx(R0,{prices:s,simWidth:I,simLength:P,setSimWidth:F,setSimLength:O}),e.jsx(O0,{changeLog:M,loading:N})]})}function R0({prices:s,simWidth:n,simLength:c,setSimWidth:u,setSimLength:d}){const t=[{label:"소",w:200,l:200},{label:"중",w:400,l:800},{label:"대",w:600,l:1200}],l=g.useMemo(()=>{const x=new Map;for(const h of s){const b=h.wood_name||"";(!x.has(b)||h.thickness>(x.get(b)?.thickness??0))&&x.set(b,h)}return Array.from(x.entries()).map(([h,b])=>{const j=b.low_width*b.low_length,I=b.edited_multiplier??1,P=b.price_multiplier??1,F=pe(n,c,Math.ceil(b.unit_price*I),Math.ceil(b.area_price*I),j),O=pe(n,c,Math.ceil(b.unit_price*P),Math.ceil(b.area_price*P),j),M=O>0?(F-O)/O*100:0;return{name:h,thickness:b.thickness,category:b.category_name||"",currentPrice:F,originalPrice:O,diff:M}})},[s,n,c]);return e.jsxs(U,{children:[e.jsx(B,{className:"pb-3",children:e.jsx(G,{className:"text-base",children:"가격 시뮬레이션"})}),e.jsxs(V,{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx("div",{className:"flex items-center gap-2",children:t.map(x=>e.jsx("button",{onClick:()=>{u(x.w),d(x.l)},className:`px-3 py-1 text-sm rounded-full transition-colors ${n===x.w&&c===x.l?"bg-blue-600 text-white":"bg-gray-100 text-gray-700 hover:bg-gray-200"}`,children:x.label},x.label))}),e.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[e.jsx("input",{type:"number",value:n,onChange:x=>u(parseInt(x.target.value)||0),className:"no-spinner w-20 text-right border border-gray-300 rounded px-2 py-1 focus:outline-none focus:ring-1 focus:ring-blue-500"}),e.jsx("span",{className:"text-gray-500",children:"x"}),e.jsx("input",{type:"number",value:c,onChange:x=>d(parseInt(x.target.value)||0),className:"no-spinner w-20 text-right border border-gray-300 rounded px-2 py-1 focus:outline-none focus:ring-1 focus:ring-blue-500"}),e.jsx("span",{className:"text-gray-500",children:"mm"}),e.jsxs("span",{className:"text-xs text-gray-400 ml-2",children:["(",(n*c).toLocaleString()," mm²)"]})]})]}),l.length>0&&e.jsxs("table",{className:"w-full text-sm",children:[e.jsx("thead",{children:e.jsxs("tr",{className:"border-b border-gray-100",children:[e.jsx("th",{className:"text-left py-2 text-gray-500 font-medium",children:"목재"}),e.jsx("th",{className:"text-right py-2 text-gray-500 font-medium",children:"현행가"}),e.jsx("th",{className:"text-right py-2 text-gray-500 font-medium",children:"변경 후"}),e.jsx("th",{className:"text-right py-2 text-gray-500 font-medium",children:"변동"})]})}),e.jsx("tbody",{children:l.map(x=>e.jsxs("tr",{className:"border-b border-gray-50",children:[e.jsxs("td",{className:"py-2",children:[e.jsx("span",{className:"text-gray-900",children:x.name}),e.jsxs("span",{className:"text-xs text-gray-400 ml-1",children:["(",x.thickness,"mm)"]})]}),e.jsxs("td",{className:"py-2 text-right text-gray-600",children:[x.originalPrice.toLocaleString(),"원"]}),e.jsxs("td",{className:"py-2 text-right text-gray-900 font-medium",children:[x.currentPrice.toLocaleStr
23ing(),"원"]}),e.jsx("td",{className:`py-2 text-right text-xs ${x.diff===0?"text-gray-400":x.diff>0?"text-blue-600":"text-green-600"}`,children:x.diff===0?"-":`${x.diff>0?"+":""}${x.diff.toFixed(1)}%`})]},x.name))})]})]})]})}function O0({changeLog:s,loading:n}){const[c,u]=g.useState(!1);return e.jsxs(U,{children:[e.jsx(B,{className:"pb-3",children:e.jsxs("button",{onClick:()=>u(!c),className:"flex items-center gap-2 text-left w-full",children:[e.jsx(Ae,{className:"w-4 h-4 text-gray-500"}),e.jsx(G,{className:"text-base",children:"변경 이력"}),e.jsxs(J,{variant:"secondary",className:"ml-auto",children:[s.length,"건"]}),c?e.jsx(xe,{className:"w-4 h-4"}):e.jsx(ue,{className:"w-4 h-4"})]})}),c&&e.jsx(V,{children:n?e.jsx("p",{className:"text-sm text-gray-500 text-center py-4",children:"로딩 중..."}):s.length===0?e.jsx("p",{className:"text-sm text-gray-500 text-center py-4",children:"변경 이력이 없습니다."}):e.jsx("div",{className:"space-y-2",children:s.map(d=>{const t=d.old_multiplier!==d.new_multiplier,l=d.old_unit_price!==d.new_unit_price,x=d.old_area_price!==d.new_area_price,h=t||l||x;return e.jsxs("div",{className:"border border-gray-100 rounded-lg p-3 text-sm",children:[e.jsxs("div",{className:"flex items-center justify-between mb-1",children:[e.jsxs("span",{className:"font-medium text-gray-900",children:[d.wood_name," ",d.thickness,"mm"]}),e.jsx("span",{className:"text-xs text-gray-400",children:new Date(d.changed_at).toLocaleString("ko-KR")})]}),e.jsxs("div",{className:"flex flex-wrap gap-x-4 gap-y-0.5 text-xs text-gray-600",children:[t&&e.jsxs("span",{children:["조정률: ",e.jsxs("span",{className:"text-gray-400",children:[Math.round((d.old_multiplier-1)*100),"%"]})," → ",e.jsxs("span",{className:"text-gray-900",children:[Math.round((d.new_multiplier-1)*100),"%"]})]}),l&&e.jsxs("span",{children:["unit_price: ",e.jsx("span",{className:"text-gray-400",children:d.old_unit_price})," → ",e.jsx("span",{className:"text-gray-900",children:d.new_unit_price})]}),x&&e.jsxs("span",{children:["area_price: ",e.jsx("span",{className:"text-gray-400",children:d.old_area_price})," → ",e.jsx("span",{className:"text-gray-900",children:d.new_area_price})]}),!h&&e.jsx("span",{className:"text-gray-400",children:"변경된 값 없음"})]})]},d.id)})})})]})}function E0(){const[s,n]=g.useState([]),[c,u]=g.useState(!0),[d,t]=g.useState(!1),[l,x]=g.useState("all"),h=g.useCallback(async()=>{try{u(!0);const y=await Fe();n(y.map(m=>({...m,edited_unit_price:m.unit_price,edited_area_price:m.area_price,edited_multiplier:m.price_multiplier,isDirty:!1})))}catch(y){console.error("일반목재 가격 로드 실패:",y),L.error("가격 데이터를 불러오는데 실패했습니다.")}finally{u(!1)}},[]);g.useEffect(()=>{h()},[h]);const b=g.useMemo(()=>{const y=new Set;for(const m of s)m.wood_name==="MDF"?y.add("MDF"):m.category_name&&y.add(m.category_name);return Array.from(y).sort()},[s]),j=g.useMemo(()=>l==="all"?s:l==="MDF"?s.filter(y=>y.wood_name==="MDF"):s.filter(y=>y.category_name===l&&y.wood_name!=="MDF"),[s,l]),I=g.useCallback((y,m,i)=>{n(f=>f.map(o=>{if(o.id!==y)return o;let a;return m==="multiplier"?a={...o,edited_multiplier:i}:a={...o,[m==="unit_price"?"edited_unit_price":"edited_area_price"]:i},a.isDirty=a.edited_unit_price!==o.unit_price||a.edited_area_price!==o.area_price||a.edited_multiplier!==o.price_multiplier,a}))},[]),P=g.useCallback(async y=>{const m=s.find(i=>i.id===y);if(!(!m||!m.isDirty))try{t(!0),await te(y,{unit_price:m.edited_unit_price,area_price:m.edited_area_price}),await h(),L.success(`${m.wood_name} ${m.thickness}mm 가격이 저장되었습니다.`)}catch(i){console.error("가격 저장 실패:",i),L.error("가격 저장에 실패했습니다.")}finally{t(!1)}},[s,h]);g.useCallback(async()=>{const y=s.filter(m=>m.isDirty);if(y.length===0){L.info("변경된 항목이 없습니다.");return}try{t(!0),await Promise.all(y.map(m=>te(m.id,{unit_price:m.edited_unit_price,area_price:m.edited_area_price}))),await h(),L.success(`${y.length}개 항목이 저장되었습니다.`)}catch(m){console.error("전체 저장 실패:",m),L.error("전체 저장에 실패했습니다.")}finally{t(!1)}},[s,h]);const F=g.useCallback(async(y,m)=>{if(y!==0)try{t(!0);const i=await Re(y,m);await h();const f=m||"전체";L.success(`${f} ${i}개 항목에 ${y>0?"+":""}${y}% 조정이 적용되었습니다.`)}catch(i){console.error("일괄 조정 실패:",i),L.error("일괄 조정에 실패했습니다.")}finally{t(!1)}}
23,[h]),O=g.useCallback(()=>{n(y=>y.map(m=>({...m,edited_unit_price:m.unit_price,edited_area_price:m.area_price,edited_multiplier:m.price_multiplier,isDirty:!1})))},[]),[M,N]=g.useState(400),[v,$]=g.useState(800),[A,S]=g.useState([]),C=g.useCallback(async()=>{const y=s.filter(i=>i.isDirty);if(y.length===0){L.info("변경된 항목이 없습니다.");return}const m=y.map((i,f)=>({id:Date.now()+f,wood_name:i.wood_name||"",thickness:i.thickness,old_unit_price:i.unit_price,old_area_price:i.area_price,new_unit_price:i.edited_unit_price,new_area_price:i.edited_area_price,old_multiplier:i.price_multiplier,new_multiplier:i.edited_multiplier,changed_at:new Date().toISOString()}));try{t(!0),await Promise.all(y.map(i=>te(i.id,{unit_price:i.edited_unit_price,area_price:i.edited_area_price,price_multiplier:i.edited_multiplier}))),await h(),S(i=>[...m,...i].slice(0,50)),L.success(`${y.length}개 항목이 저장되었습니다.`)}catch(i){console.error("전체 저장 실패:",i),L.error("전체 저장에 실패했습니다.")}finally{t(!1)}},[s,h]),R=s.some(y=>y.isDirty);return{prices:j,allPrices:s,loading:c,saving:d,categories:b,filterCategory:l,setFilterCategory:x,updateField:I,saveRow:P,saveAll:C,applyBulkPercent:F,resetAll:O,hasDirtyItems:R,simWidth:M,simLength:v,setSimWidth:N,setSimLength:$,changeLog:A,changeLogLoading:!1}}function u3(){const[s,n]=g.useState([]),[c,u]=g.useState(null),[d,t]=g.useState([]),[l,x]=g.useState([]),[h,b]=g.useState(""),[j,I]=g.useState(!1),[P,F]=g.useState(null),[O,M]=g.useState(!0),N=g0(),v=E0();g.useEffect(()=>{$()},[]);const $=async()=>{try{M(!0);const[a,p,w]=await Promise.all([Se(),Oe(),Ee()]);n(a),t(p),x(w)}catch(a){console.error("데이터 로드 실패:",a),L.error("데이터를 불러오는데 실패했습니다.")}finally{M(!1)}},A=d.filter(a=>!(c&&a.category_id!==c||h&&!a.name.toLowerCase().includes(h.toLowerCase()))),S=()=>{const a=prompt("카테고리 이름을 입력하세요:","새 카테고리");!a||!a.trim()||L.info("카테고리 추가 기능은 추후 구현 예정")},C=async(a,p)=>{try{await We(a,p),await $()}catch(w){console.error("카테고리 수정 실패:",w),L.error("카테고리 수정에 실패했습니다.")}},R=()=>{F(null),I(!0)},y=a=>{F(a),I(!0)},m=async a=>{if(confirm("이 목재를 삭제하시겠습니까?"))try{await Te(a),await $()}catch(p){console.error("목재 삭제 실패:",p),L.error("목재 삭제에 실패했습니다.")}},i=async a=>{const p=!a.is_sold_out;t(w=>w.map(k=>k.id===a.id?{...k,is_sold_out:p}:k));try{await Ue(a.id,p),L.success(p?`"${a.name}" 품절 처리되었습니다.`:`"${a.name}" 판매가 재개되었습니다.`)}catch(w){console.error("품절 상태 변경 실패:",w),L.error("품절 상태 변경에 실패했습니다."),t(k=>k.map(r=>r.id===a.id?{...r,is_sold_out:a.is_sold_out}:r))}},f=async(a,p)=>{const w=a.sold_out_thicknesses??[],k=w.includes(p),r=k?w.filter(_=>_!==p):[...w,p];t(_=>_.map(D=>D.id===a.id?{...D,sold_out_thicknesses:r}:D));try{await Be(a.id,r),L.success(k?`"${a.name}" ${p} 판매가 재개되었습니다.`:`"${a.name}" ${p} 품절 처리되었습니다.`)}catch(_){console.error("두께별 품절 상태 변경 실패:",_),L.error("두께별 품절 상태 변경에 실패했습니다."),t(D=>D.map(q=>q.id===a.id?{...q,sold_out_thicknesses:w}:q))}},o=async(a,p,w)=>{try{let k;if(P){const{texture_img:r,real_img:_,info_img:D,...q}=a,se={...q};if(w.some(z=>z.type==="texture")||(se.texture_img=r),w.some(z=>z.type==="real")||(se.real_img=_),await he(P.id,se),k=P.id,!w.some(z=>z.type==="info")&&D!==void 0)try{await re(k,D)}catch{}}else{const{info_img:r,..._}=a;if(k=(await Ge(_)).id,r)try{await re(k,r)}catch{}}if(w.length>0){const r={};for(const _ of w){_.oldUrl&&await m0(_.oldUrl);const D=await d0(_.file,k,_.type);if(!D.success){L.error(`${_.type} 이미지 업로드 실패: ${D.error}`);continue}if(_.type==="texture")r.texture_img=D.url;else if(_.type==="real")r.real_img=D.url;else if(_.type==="info")try{await re(k,D.url)}catch{}}Object.keys(r).length>0&&await he(k,r)}await Ve(k,p),await $(),I(!1),F(null),L.success(P?"목재가 수정되었습니다.":"목재가 추가되었습니다.")}catch(k){console.error("목재 저장 실패:",k);const r=k?.message||k?.code||"알 수 없는 오류";L.error(`목재 저장 실패: ${r}`)}};return O?e.jsx("div",{className:"p-6 flex items-center justify-center min-h-screen",children:e.jsxs("div",{className:"text-center",children:[e.jsx("div",{className:"animate-spin rounded-full h-12 w-12 border-b-2 border-blue-600 mx-auto mb-4"}),e.jsx("p",{className:"text-gray-600",children:"데이터 로딩 중..."})]})}):e.jsxs("div",{className:"p-6 space-y-6",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-2xl font-bold text-gray-900",children:"목재·코팅합판 관리"}),e.jsx("p",{className:"text-sm text-gray-500 mt-1",children:"목재 카테고리, 목재 정보, 가공 옵션 및 단가를 관리합니다."})]}),e.jsxs(qe,{defaultValue:"wood",className:"w-full",children:[e.jsxs(Ke,{children:[e.jsx(ae,{value:"wood",children:"목록"}),e.jsx(ae,{value:"wood-price",children:"일반목재 단가"}),e.jsx(ae,{value:"pricing",children:"코팅합판 단가"})]}),e.jsxs(ne,{value:"wood",className:"space-y-6 mt-4",children:[e.jsx(n0,{categories:s,selectedCategoryId:c,onSelectCategory:u,onAddCategory:S,onUpdateCategory:C}),e.jsxs("div",{className:"bg-white rounded-lg shadow-sm border border-gray-200 p-6",children:[e.jsxs("div",{className:"flex items-center justify-between mb-6",children:[e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx("h2",{className:"text-xl font-bold text-gray-900",children:c?s.find(a=>a.id===c)?.name:"전체 목재"}),e.jsxs("span",{className:"px-3 py-1 bg-blue-100 text-blue-700 text-sm font-medium rounded-full",children:[A.length,"개"]}),c&&e.jsx(E,{children:e.jsxs("div",{className:"flex items-center gap-2 ml-4 pl-4 border-l border-gray-300",children:[e.jsx("button",{onClick:()=>{const a=s.find(p=>p.id===c);a&&C(c,{is_active:!a.is_active})},className:`flex items-center gap-1.5 px-3 py-1.5 text-sm rounded-lg transition-colors ${s.find(a=>a.id===c)?.is_active?"bg-green-50 text-green-700 hover:bg-green-100":"bg-gray-100 text-gray-600 hover:bg-gray-200"}`,title:"노출 여부 토글",children:s.find(a=>a.id===c)?.is_active?e.jsxs(e.Fragment,{children:[e.jsx(Xe,{className:"w-4 h-4"}),"노출 중"]}):e.jsxs(e.Fragment,{children:[e.jsx(Ye,{className:"w-4 h-4"}),"숨김"]})}),e.jsxs("button",{onClick:()=>{const a=s.find(p=>p.id===c);if(a){const p=prompt("카테고리 이름 변경",a.name);p&&p.trim()&&C(c,{name:p.trim()})}},className:"flex items-center gap-1.5 px-3 py-1.5 text-sm bg-gray-100 text-gray-700 hover:bg-gray-200 rounded-lg transition-colors",title:"카테고리 수정",children:[e.jsx(Pe,{className:"w-4 h-4"}),"수정"]})]})})]}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsxs("div",{className:"relative w-64",children:[e.jsx(a0,{className:"absolute left-3 top-1/2 transform -translate-y-1/2 w-4 h-4 text-gray-400"}),e.jsx("input",{type:"text",value:h,onChange:a=>b(a.target.value),placeholder:"목재명 검색...",className:"w-full pl-9 pr-9 py-2 text-sm border border-gray-300 rounded-lg focus:outline-none focus:ring-2 focus:ring-blue-500"}),h&&e.jsx("button",{type:"button",onClick:()=>b(""),className:"absolute right-3 top-1/2 -translate-y-1/2 p-0.5 rounded hover:bg-gray-100 text-gray-400 hover:text-gray-600",title:"검색어 지우기",children:e.jsx(de,{className:"w-4 h-4"})})]}),e.jsx(E,{children:e.jsxs("button",{onClick:R,className:"flex items-center gap-1.5 px-3 py-2 text-sm text-white bg-blue-600 hover:bg-blue-700 rounded-lg transition-colors",children:[e.jsx(ee,{className:"w-4 h-4"}),"목재 추가"]})})]})]}),A.length===0?e.jsxs("div",{className:"text-center py-12 text-gray-500",children:[e.jsx("p",{children:"등록된 목재가 없습니다."}),e.jsx(E,{children:e.jsx("button",{onClick:R,className:"mt-4 text-blue-600 hover:text-blue-700 font-medium",children:"+ 목재 추가하기"})})]}):e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4 gap-4",children:A.map(a=>e.jsx(l0,{item:a,category:s.find(p=>p.id===a.category_id),onEdit:y,onDelete:m,onToggleSoldOut:i,onToggleThicknessSoldOut:f},a.id))})]})]}),e.jsx(ne,{value:"pricing",className:"mt-4",children:e.jsx(D0,{pricingDataList:N.pricingDataList,loading:N.loading,saving:N.saving,hasDirtyItems:N.hasDirtyItems,updateParam:N.updateParam,saveParams:N.saveParams,resetParams:N.resetParams,saveAll:N.saveAll,applyBulkMultiplier:N.applyBulkMultiplier,simWidth:N.simWidth,simLength:N.simLength,setSimWidth:N.setSimWidth,setSimLength:N.setSimLength,simulationResults:N.simulationResults,changeLog:N.changeLog,changeLogLoading:N.changeLogLoading})}),e.jsx(ne,{value:"wood-price",className:"mt-4",children:e.jsx(F0,{prices:v.prices,loading:v.loading,saving:v.s
23aving,categories:v.categories,filterCategory:v.filterCategory,setFilterCategory:v.setFilterCategory,updateField:v.updateField,saveRow:v.saveRow,saveAll:v.saveAll,applyBulkPercent:v.applyBulkPercent,resetAll:v.resetAll,hasDirtyItems:v.hasDirtyItems,simWidth:v.simWidth,simLength:v.simLength,setSimWidth:v.setSimWidth,setSimLength:v.setSimLength,changeLog:v.changeLog,changeLogLoading:v.changeLogLoading})})]}),j&&e.jsx(x0,{item:P,categories:s.filter(a=>a.is_active||P&&a.id===P.category_id),processOptions:l,onSave:o,onClose:()=>{I(!1),F(null)}})]})}export{u3 as default};

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.