1import{g as fe,u as be,d$ as ve,e0 as ke,e1 as ye,Y as je,h as Ne,p as Ie,P as _,M as Se,q as G,j as r,e2 as Pe,bJ as Ce,m as $e,al as qe,am as we,ak as Te,aj as Ee,T as W,e3 as Ae,e4 as Le,e5 as Me,n as Ve,_ as ze,t as Re}from"./index-DUCsaRCi.js";import{r as o}from"./react-vendor-C7biPTGg.js";import{A as _e}from"./AppPageHeader-BRTHclYi.js";import{I as De,n as v,P as He,C as Oe,a as D}from"./referentiel-CmwTKanl.js";import{a as Fe}from"./FenetrePublier-B3e3c9HS.js";import{S as Ke}from"./SafeImg-BYkE8UD3.js";import{f as U}from"./format-5nHd35nN.js";import{P as Be}from"./platformStyle-UqMdLD38.js";import{r as Ge}from"./skuPhrase-MTf9n0_U.js";import"./PlanBadge-BBDhunXq.js";import"./AccountAvatar-Cpx5cYvF.js";const Z="klork_nouvelle_annonce_brouillon",se=20,A=100,We={fr:{title:"Nouvelle annonce",titleEdit:"Modifier lâannonce",subtitle:"Décris ton article comme tu le ferais sur Vinted. Elle rejoint ton dressing, et part sur tes plateformes comme les autres.",subtitleEdit:"Cette annonce est née dans Klork : tout se modifie ici, photos et catégorie comprises.",subtitleEditImport:e=>`Cette annonce vient de ${e} : tout se modifie ici, photos et catégorie comprises. Klork nâécrit jamais sur ${e} â tes changements partent aux prochaines publications.`,loading:"Chargement du référentiel Vintedâ¦",loadError:"Impossible de charger le référentiel Vinted. Réessaie dans un instant.",required:"obligatoire",advised:"conseillée",optional:"optionnel",photos:"Photos",photosCount:(e,t)=>`${e}/${t}`,photosHint:e=>`La première est la photo principale â glisse pour réordonner, ou colle une image (Ctrl+V). JPG, PNG, WebP.${e?` ${e}`:""}`,capsPhotos:e=>`${e.join(", ")}.`,capPhoto:(e,t)=>`${e} garde les ${t} premières`,titre:"Titre",titrePlaceholder:"Ex. Jean Leviâs 501 W30, bleu brut",titreCount:(e,t)=>`${e}/${A}${t?` · ${t.label} ${e>t.max?"coupera":"coupe"} à ${t.max}`:""}`,savePublish:"Publier",scheduleItem:"Programmerâ¦",scheduleTitle:"Programmer la publication",scheduleDate:"Date de publication",in1h:"Dans 1 heure",confirm:"Confirmer",close:"Fermer",pastTime:"Cette heure est déjà passée.",moreActions:"Plus dâactions",description:"Description",descriptionPlaceholder:"Ãtat, matière, défauts, mesures : tout ce que tu dirais à lâacheteur.",descriptionCount:e=>`${e} caractères`,skuHint:e=>`Ton SKU se lit là où tu lâas réglé â ${e} (Réglages â Mes annonces).`,skuWhere:{title_end:"fin du titre",title_start:"début du titre",description_start:"début de la description",description_end:"fin de la description",none:"nulle part (réglage « aucun »)"},categorie:"Catégorie",categorieCount:e=>`${e.toLocaleString("fr-FR")} catégories Vinted`,categorieHint:"Lâarbre de Vinted, avec ses ids : câest lui que lisent les tables de catégories des moteurs. En tête, tes catégories habituelles. La catégorie décide des champs qui suivent, exactement comme sur Vinted.",details:"Détails de lâarticle",marque:"Marque",marquePlaceholder:"Ex. Leviâs, Zara â ou « Sans marque »",marqueSearch:"Cherche une marqueâ¦",marqueHint:"Dâabord ce que tu vends déjà , puis les marques vues dans Klork. Rien qui colle ? Ton texte est gardé tel quel.",marqueOwn:"Dans ton dressing",marqueSeen:e=>`Marques vues dans Klork (${e.toLocaleString("fr-FR")})`,marqueOwnSub:e=>`${e} dans ton dressing`,marqueSeenSub:e=>`${e.toLocaleString("fr-FR")} annonces`,marqueNone:"Sans marque",marqueFree:e=>`Utiliser « ${e} » tel quel`,marqueEmpty:e=>`Rien pour « ${e} » â Entrée pour le garder tel quel.`,taille:"Taille",taillePlaceholder:"Choisis une taille",tailleSearch:"Tape pour filtrerâ¦",tailleEmpty:e=>`Aucune taille « ${e} » dans cette grille.`,tailleHintOne:(e,t)=>`Grille « ${e} » de Vinted pour cette catégorie (${t} entrées) â elle change avec la catégorie.`,tailleHintMany:e=>`${e.length} grilles pour cette catégorie : ${e.join(", ")}.`,etat:"Ãtat",etatHint:"Les 5 états Vinted â ceux que les 8 moteurs savent traduire.",couleurs:"Couleurs",couleursCount:e=>`${e} sur 2`,couleursPlaceholder:"Cherche une couleur â 2 max",couleursSearch:"Cherche une couleurâ¦",couleursEmpty:e=>`Aucune couleur « ${e} » dans la liste Vinted.`,matieres:"Matières",matieresCount:e=>`${e} sur 3 · optionnel`,matieresPlaceholder:"Cherche une matière â 3 max, optionnel",matieresSearch:"Cherche une matièreâ¦",matieresEmpty:e=>`Aucune matière « ${e} » dans la liste Vinted.`,remove:e=>`Retirer ${e}`,prix:"Prix",prixAchat:"Prix dâachat",prixAchatSub:"optionnel · pour tes marges dans Ventes",marge:e=>`Marge attendue : ${e} au prix affiché.`,margeVide:"Renseigne un prix dâachat pour voir ta marge dans Ventes.",colis:"Format de colis",colisDesc:{1:"Tient dans une enveloppe",2:"Tient dans une boîte à chaussures",3:"Tient dans un carton de déménagement"},colisHint:"Les 3 formats Vinted. Sur Leboncoin, Klork estime le poids dâaprès la catégorie, comme aujourdâhui â arrondi au palier supérieur, jamais en dessous.",inWardrobe:"Dans ton dressing",createdIn:"Créée dans Klork",noTitle:"Sans titre",whatGoes:"Ce qui partira",prismePhotosAll:"toutes les ph
1otos",prismePhotosMax:e=>`${e} photos max`,prismeTitreFull:"titre entier",prismeTitreCut:e=>`titre coupé à ${e}`,prismeTitreNone:"pas de champ titre",prismeEnchere:"prix de départ",prismeHint:e=>`${e===1?"Ta plateforme active":`Tes ${e} plateformes actives`}. Prix par plateforme : Réglages â Mes plateformes.`,prismeNone:"Aucune plateforme active : active-les dans Connexions.",save:"Enregistrer",saveEdit:"Enregistrer les modifications",saving:"Enregistrementâ¦",saveNote:"Klork nâécrit jamais sur Vinted. Cette annonce vit ici : tu la publies, la retires et la marques vendue depuis sa fiche, comme les autres.",draftKept:"Brouillon gardé dans ce navigateur",draftRestored:"Brouillon restauré â reprends où tu en étais.",saved:"Ajoutée à ton dressing",savedEdit:"Annonce modifiée",errPhotos:"Ajoute au moins une photo.",errTitle:"Donne un titre à lâannonce.",errCat:"Choisis une catégorie précise (une feuille de lâarbre).",errSize:"Vinted demande une taille pour cette catégorie.",errColor:"Vinted demande au moins une couleur pour cette catégorie.",errPrice:"Indique un prix.",errServer:"Impossible dâenregistrer lâannonce.",cancel:"Annuler"},en:{title:"New listing",titleEdit:"Edit listing",subtitle:"Describe your item like you would on Vinted. It joins your wardrobe and goe
1s out to your platforms like any other.",subtitleEdit:"This listing was born in Klork: everything is editable here, photos and category included.",subtitleEditImport:e=>`This listing comes from ${e}: everything is editable here, photos and category included. Klork never writes to ${e} â your changes go out with the next publications.`,loading:"Loading the Vinted reference dataâ¦",loadError:"Could not load the Vinted reference data. Try again in a moment.",required:"required",advised:"advised",optional:"optional",photos:"Photos",photosCount:(e,t)=>`${e}/${t}`,photosHint:e=>`The first one is the main photo â drag to reorder, or paste an image (Ctrl+V). JPG, PNG, WebP.${e?` ${e}`:""}`,capsPhotos:e=>`${e.join(", ")}.`,capPhoto:(e,t)=>`${e} keeps the first ${t}`,titre:"Title",titrePlaceholder:"E.g. Leviâs 501 jeans W30, raw blue",titreCount:(e,t)=>`${e}/${A}${t?` · ${t.label} ${e>t.max?"will cut":"cuts"} at ${t.max}`:""}`,savePublish:"Publish",scheduleItem:"Scheduleâ¦",scheduleTitle:"Schedule the publication",scheduleDate:"Publication date",in1h:"In 1 hour",confirm:"Confirm",close:"Close",pastTime:"That time has already passed.",moreActions:"More actions",description:"Description",descriptionPlaceholder:"Condition, material, flaws, measurements: everything you would tell the buyer.",descriptionCount:e=>`${e} characters`,skuHint:e=>`Your SKU is read where you set it â ${e} (Settings â My listings).`,skuWhere:{title_end:"end of the title",title_start:"start of the title",description_start:"start of the description",description_end:"end of the description",none:"nowhere (setting ânoneâ)"},categorie:"Category",categorieCount:e=>`${e.toLocaleString("en-GB")} Vinted categories`,categorieHint:"Vintedâs tree, with its ids: the one the enginesâ category tables read. Your usual categories come first. The category decides the next fields, exactly like on Vinted.",details:"Item details",marque:"Brand",marquePlaceholder:"E.g. Leviâs, Zara â or âNo brandâ",marqueSearch:"Search a brandâ¦",marqueHint:"What you already sell first, then brands seen in Klork. Nothing fits? Your text is kept as is.",marqueOwn:"In your wardrobe",marqueSeen:e=>`Brands seen in Klork (${e.toLocaleString("en-GB")})`,marqueOwnSub:e=>`${e} in your wardrobe`,marqueSeenSub:e=>`${e.toLocaleString("en-GB")} listings`,marqueNone:"No brand",marqueFree:e=>`Use â${e}â as is`,marqueEmpty:e=>`Nothing for â${e}â â Enter to keep it as is.`,taille:"Size",taillePlaceholder:"Pick a size",tailleSearch:"Type to filterâ¦",tailleEmpty:e=>`No size â${e}â in this grid.`,tailleHintOne:(e,t)=>`Vintedâs â${e}â grid for this category (${t} entries) â it changes with the category.`,tailleHintMany:e=>`${e.length} grids for this category: ${e.join(", ")}.`,etat:"Condition",etatHint:"The 5 Vinted conditions â the ones the 8 engines can translate.",couleurs:"Colours",couleursCount:e=>`${e} of 2`,couleursPlaceholder:"Search a colour â 2 max",couleursSearch:"Search a colourâ¦",couleursEmpty:e=>`No colour â${e}â in the Vinted list.`,matieres:"Materials",matieresCount:e=>`${e} of 3 · optional`,matieresPlaceholder:"Search a material â 3 max, optional",matieresSearch:"Search a materialâ¦",matieresEmpty:e=>`No material â${e}â in the Vinted list.`,remove:e=>`Remove ${e}`,prix:"Price",prixAchat:"Purchase price",prixAchatSub:"optional · for your margins in Sales",marge:e=>`Expected margin: ${e} at the displayed price.`,margeVide:"Add a purchase price to see your margin in Sales.",colis:"Parcel size",colisDesc:{1:"Fits in an envelope",2:"Fits in a shoebox",3:"Fits in a moving box"},colisHint:"Vintedâs 3 sizes. On Leboncoin, Klork estimates the weight from the category, as today â rounded up, never down.",inWardrobe:"In your wardrobe",createdIn:"Created in Klork",noTitle:"Untitled",whatGoes:"What will go out",prismePhotosAll:"all photos",prismePhotosMax:e=>`${e} photos max`,prismeTitreFull:"full title",prismeTitreCut:e=>`title cut at ${e}`,prismeTitreNone:"no title field",prismeEnchere:"starting price",prismeHint:e=>`${e===1?"Your active platform":`Your ${e} active platforms`}. Price per platform: Settings â My platforms.`,prismeNone:"No active platform: enable them in Connections.",save:"Save",saveEdit:"Save changes",saving:"Savingâ¦",s
1aveNote:"Klork never writes to Vinted. This listing lives here: you publish, delist and mark it sold from its card, like the others.",draftKept:"Draft kept in this browser",draftRestored:"Draft restored â pick up where you left off.",saved:"Added to your wardrobe",savedEdit:"Listing updated",errPhotos:"Add at least one photo.",errTitle:"Give the listing a title.",errCat:"Pick a precise category (a leaf of the tree).",errSize:"Vinted requires a size for this category.",errColor:"Vinted requires at least one colour for this category.",errPrice:"Set a price.",errServer:"Could not save the listing.",cancel:"Cancel"}},Q={photos:[],title:"",description:"",categoryId:null,brand:"",size:"",conditionId:2,colorIds:[],materialIds:[],price:"",cost:"",packageSizeId:2};function Ue(){try{const e=localStorage.getItem(Z);if(!e)return null;const t=JSON.parse(e);return{...Q,...t,photos:Array.isArray(t.photos)?t.photos:[]}}catch{return null}}function Y(e){const t=Number(String(e).replace(",",".").trim());return Number.isFinite(t)&&t>=0?t:null}function J(e,t){return e.length===t.length&&e.every((d,g)=>d===t[g])}function ot(){const{lang:e}=fe(),t=We[e],{user:d}=be(),u=ve().get("id"),[l,f]=o.useState(null),[y,H]=o.useState(null),[P,L]=o.useState("en-cours"),[q,w]=o.useState(null),[s,T]=o.useState(Q),[M,h]=o.useState(!1),[N,E]=o.useState(!1),[O,F]=o.useState(null),ee=o.useRef(!0),te=o.useRef(null),k=o.useCallback((a,i)=>T(n=>({...n,[a]:i})),[]);o.useEffect(()=>{let a=!0;return(async()=>{try{const[i,n]=await Promise.all([ke(),ye().catch(()=>null)]);if(!a)return;const c=new De(i);if(f(c),H(n),u){const p=await je(u);if(!a)return;if(!Ne(p)){const j=Ie(p);w(j?_[j]:"Vinted")}const b=Je(p,c);te.current=b,T(b)}else{const p=Ue();p&&(T(p),h(!0))}L("ok")}catch{a&&L("erreur")}})(),()=>{a=!1}},[u]),o.useEffect(()=>{if(u||P!=="ok")return;if(ee.current){ee.current=!1;return}const a=setTimeout(()=>{try{localStorage.setItem(Z,JSON.stringify(s))}catch{}},500);return()=>clearTimeout(a)},[s,u,P]);const x=l&&s.categoryId?l.noeud(s.categoryId):null,C=o.useMemo(()=>l&&s.categoryId?l.grillesDe(s.categoryId):[],[l,s.categoryId]);o.useEffect(()=>{!l||!s.categoryId||!s.size||l.tailleValide(s.categoryId,s.size)||k("size","")},[l,s.categoryId,s.size,k]);const S=o.useMemo(()=>Se(d?.features,d?.enabledPlatforms),[d?.features,d?.enabledPlatforms]),ne=o.useMemo(()=>{let a=null;for(const i of S){const n=G[i];!n||n.titreMax===null||n.titreLargement||(!a||n.titreMax<a.max)&&(a={label:_[i],max:n.titreMax})}return a},[S]),le=o.useMemo(()=>{const a=S.map(i=>({p:i,max:G[i]?.photosMax??null})).filter(i=>i.max!==null).sort((i,n)=>i.max-n.max).slice(0,3).map(i=>t.capPhoto(_[i.p],i.max));return a.length?t.capsPhotos(a):""},[S,t]),I=Y(s.price),K=Y(s.cost),oe=o.useCallback(a=>{const i=v(a),n=(y?.marques??[]).filter(m=>!i||v(m.marque).includes(i)).slice(0,12),c=new Set(n.map(m=>v(m.marque))),p=(y?.marquesVues??[]).filter(m=>!c.has(v(m.marque))&&(!i||v(m.marque).includes(i))).slice(0,i?40:12),b=[];n.length&&b.push({label:t.marqueOwn,items:n.map(m=>({key:`o-${m.marque}`,label:m.marque,sub:t.marqueOwnSub(m.annonces),selected:s.brand===m.marque,value:m.marque}))}),p.length&&b.push({label:t.marqueSeen(y?.marquesVues.length??0),items:p.map(m=>({key:`v-${m.marque}`,label:m.marque,sub:t.marqueSeenSub(m.annonces),selected:s.brand===m.marque,value:m.marque}))});const j=[];return(!i||v(t.marqueNone).includes(i))&&j.push({key:"none",label:t.marqueNone,selected:s.brand===t.marqueNone,value:t.marqueNone}),i&&!n.some(m=>v(m.marque)===i)&&!p.some(m=>v(m.marque)===i)&&j.push({key:"free",label:t.marqueFree(a),free:!0,value:a}),j.length&&b.push({items:j}),b},[y,s.brand,t]),ce=o.useCallback(a=>{const i=v(a);return C.map(n=>({label:C.length>1?n.libelle:void 0,items:n.tailles.filter(c=>!i||v(c.titre).includes(i)).map(c=>({key:`${n.id}-${c.id}`,label:c.titre,selected:s.size===c.titre,value:c.titre}))}))},[C,s.size]),de=o.useCallback(a=>{const i=v(a);return[{items:(l?.couleurs??[]).filter(n=>!i||v(n.titre).includes(i)).map(n=>({key:String(n.id),label:n.titre,swatch:n.hex,selected:s.colorIds.includes(n.id),disabled:!s.colorIds.includes(n.id
1)&&s.colorIds.length>=2,value:n.id}))}]},[l,s.colorIds]),ue=o.useCallback(a=>{const i=v(a);return[{items:(l?.matieres??[]).filter(n=>!i||v(n.titre).includes(i)).map(n=>({key:String(n.id),label:n.titre,selected:s.materialIds.includes(n.id),disabled:!s.materialIds.includes(n.id)&&s.materialIds.length>=3,value:n.id}))}]},[l,s.materialIds]);function V(a,i,n){T(c=>{const p=c[a];return p.includes(i)?{...c,[a]:p.filter(b=>b!==i)}:p.length>=n?c:{...c,[a]:[...p,i]}})}function me(){return s.photos.length?s.title.trim()?!l||!s.categoryId||!l.estFeuille(s.categoryId)||!x?t.errCat:x.champs.taille&&!s.size?t.errSize:x.champs.couleur&&!s.colorIds.length?t.errColor:I===null?t.errPrice:null:t.errTitle:t.errPhotos}function pe(){const a=te.current;if(!u||!a||I===null||I===Y(a.price))return!1;const i=s.size===a.size||!!(a.categoryId&&a.size)&&s.size===""&&!l?.tailleValide(a.categoryId,a.size);return J(s.photos,a.photos)&&s.description===a.description&&s.categoryId===a.categoryId&&s.brand===a.brand&&i&&s.conditionId===a.conditionId&&J(s.colorIds,a.colorIds)&&J(s.materialIds,a.materialIds)&&s.title===a.title&&s.cost===a.cost&&s.packageSizeId===a.packageSizeId}const[z,B]=o.useState(!1),[he,ae]=o.useState(!1),re=o.useRef(null);o.useEffect(()=>{if(!z)return;const a=i=>{i.target.closest("[data-menu-plus]")||B(!1)};return document.addEventListener("mousedown",a),()=>document.removeEventListener("mousedown",a)},[z]);async function R(a=null,i){const n=pe(),c=n?null:me();if(F(c),c){W.error(c);return}const p={title:s.title.trim(),description:s.description.trim(),priceAmount:I,costAmount:K,categoryId:s.categoryId,brand:x?.champs.marque?s.brand.trim():"",size:x?.champs.taille?s.size:"",conditionId:s.conditionId,colorIds:x?.champs.couleur?s.colorIds:[],materialIds:s.materialIds,photos:s.photos,packageSizeId:s.packageSizeId};E(!0);try{const b=u?n?await Ae(u,{priceAmount:I}):await Le(u,p):await Me(p);if(!u)try{localStorage.removeItem(Z)}catch{}W.success(u?t.savedEdit:t.saved);const j=a==="planifier"&&i?`&quand=${encodeURIComponent(i.toISOString())}`:"";Ve(`/dashboard?fiche=${encodeURIComponent(b.id)}${a?`&${a}=1`:""}${j}`)}catch(b){const j=b instanceof ze?b.message:t.errServer;F(j),W.error(j)}finally{E(!1)}}const xe=l&&s.colorIds.length?l.couleurs.find(a=>a.id===s.colorIds[0])?.titre:void 0,ge=l?.etats.find(a=>a.id===s.conditionId)?.titre;return r.jsxs("div",{className:"min-h-screen bg-[var(--bg)]",children:[r.jsx(_e,{}),r.jsxs("main",{className:"mx-auto max-w-screen-xl px-4 py-6 sm:px-6",children:[r.jsxs("div",{className:"mb-5",children:[r.jsx("h1",{className:"font-display text-2xl text-[var(--ink)]",children:u?t.titleEdit:t.title}),r.jsx("p",{className:"mt-1.5 max-w-2xl text-sm text-[var(--ink-muted)]",children:u?q?t.subtitleEditImport(q):t.subtitleEdit:t.subtitle})]}),P==="en-cours"&&r.jsx("p",{className:"text-sm text-[var(--ink-muted)]",children:t.loading}),P==="erreur"&&r.jsx("p",{className:"k-elev rounded-xl bg-[var(--surface)] px-4 py-3 text-sm text-[var(--danger)]",children:t.loadError}),P==="ok"&&l&&r.jsxs("div",{className:"grid gap-6 lg:grid-cols-[minmax(0,1fr)_340px] lg:items-start",children:[r.jsxs("form",{className:"flex flex-col gap-4",onSubmit:a=>{a.preventDefault(),R()},noValidate:!0,children:[r.jsxs("section",{className:"k-elev rounded-2xl bg-[var(--surface)] p-5",children:[r.jsx($,{titre:t.photos,tag:t.required,compteur:t.photosCount(s.photos.length,se)}),r.jsx(He,{photos:s.photos,onChange:a=>k("photos",a),max:se,upload:Pe,hint:t.photosHint(le)})]}),r.jsxs("section",{className:"k-elev rounded-2xl bg-[var(--surface)] p-5",children:[r.jsx($,{titre:t.titre,tag:t.required,compteur:t.titreCount(s.title.length,ne)}),r.jsx("input",{value:s.title,onChange:a=>k("title",a.target.value.slice(0,A)),placeholder:t.titrePlaceholder,"aria-label":t.titre,maxLength:A,className:"k-input","data-testid":"titre"})]}),r.jsxs("section",{className:"k-elev rounded-2xl bg-[var(--surface)] p-5",children:[r.jsx($,{titre:t.description,tag:t.advised,tagMuted:!0,compteur:t.descriptionCount(s.description.length)}),r.jsx("textarea",{value:s.description,onChange:a=>
1k("description",a.target.value),placeholder:t.descriptionPlaceholder,"aria-label":t.description,rows:5,maxLength:5e3,className:"k-input min-h-[120px] resize-y leading-relaxed","data-testid":"description"}),r.jsx("p",{className:"mt-2 text-xs text-[var(--ink-faint)]",children:t.skuHint(Ce(d?.skuLocation)?Ge(d?.skuLocation,e).replace(/^./,a=>a.toLowerCase()):t.skuWhere[d?.skuLocation??"title_end"]??t.skuWhere.title_end)})]}),r.jsxs("section",{className:"k-elev rounded-2xl bg-[var(--surface)] p-5",children:[r.jsx($,{titre:t.categorie,tag:t.required,compteur:t.categorieCount(l.nbCategories())}),r.jsx(Oe,{index:l,value:s.categoryId,onChange:a=>k("categoryId",a),habituelles:y?.categories??[]}),r.jsx("p",{className:"mt-2 text-xs text-[var(--ink-faint)]",children:t.categorieHint})]}),r.jsxs("section",{className:"k-elev rounded-2xl bg-[var(--surface)] p-5",children:[r.jsx($,{titre:t.details}),r.jsxs("div",{className:"mt-3 grid gap-4 md:grid-cols-2",children:[(!x||x.champs.marque)&&r.jsxs("div",{children:[r.jsx("label",{className:"k-label",children:t.marque}),r.jsx(D,{label:t.marque,placeholder:t.marquePlaceholder,searchPlaceholder:t.marqueSearch,display:s.brand,items:oe,onPick:a=>k("brand",a.value),onLibre:a=>k("brand",a),emptyText:t.marqueEmpty,testId:"marque"}),r.jsx("p",{className:"mt-2 text-xs text-[var(--ink-faint)]",children:t.marqueHint})]}),(!x||x.champs.taille)&&r.jsxs("div",{children:[r.jsxs("label",{className:"k-label",children:[t.taille," ",r.jsx("span",{className:"font-semibold text-[var(--accent-teal-text)]",children:t.required})]}),r.jsx(D,{label:t.taille,placeholder:t.taillePlaceholder,searchPlaceholder:t.tailleSearch,display:s.size,items:ce,onPick:a=>k("size",a.value),emptyText:t.tailleEmpty,disabled:!x,testId:"taille"}),r.jsx("p",{className:"mt-2 text-xs text-[var(--ink-faint)]",children:!x||C.length===0?"":C.length===1?t.tailleHintOne(C[0].libelle,C[0].tailles.length):t.tailleHintMany(C.map(a=>a.libelle))})]}),r.jsxs("div",{children:[r.jsxs("label",{className:"k-label",htmlFor:"etat",children:[t.etat," ",r.jsx("span",{className:"font-semibold text-[var(--accent-teal-text)]",children:t.required})]}),r.jsx("select",{id:"etat",value:s.conditionId,onChange:a=>k("conditionId",Number(a.target.value)),className:"k-input","data-testid":"etat",children:l.etats.map(a=>r.jsx("option",{value:a.id,children:a.titre},a.id))}),r.jsx("p",{className:"mt-2 text-xs text-[var(--ink-faint)]",children:t.etatHint})]}),(!x||x.champs.couleur)&&r.jsxs("div",{children:[r.jsxs("label",{className:"k-label",children:[t.couleurs," ",r.jsx("span",{className:"font-semibold text-[var(--accent-teal-text)]",children:t.required})," ",r.jsx("span",{className:"font-normal text-[var(--ink-faint)]",children:t.couleursCount(s.colorIds.length)})]}),r.jsx(ie,{items:s.colorIds.map(a=>l.couleurs.find(i=>i.id===a)).filter(a=>!!a).map(a=>({id:a.id,label:a.titre,swatch:a.hex})),onRemove:a=>V("colorIds",a,2),removeLabel:t.remove}),r.jsx(D,{label:t.couleurs,placeholder:t.couleursPlaceholder,searchPlaceholder:t.couleursSearch,display:"",items:de,onPick:a=>V("colorIds",a.value,2),multi:!0,emptyText:t.couleursEmpty,testId:"couleurs"})]}),r.jsxs("div",{className:"md:col-span-2",children:[r.jsxs("label",{className:"k-label",children:[t.matieres," ",r.jsx("span",{className:"font-normal text-[var(--ink-faint)]",children:t.matieresCount(s.materialIds.length)})]}),r.jsx(ie,{items:s.materialIds.map(a=>l.matieres.find(i=>i.id===a)).filter(a=>!!a).map(a=>({id:a.id,label:a.titre})),onRemove:a=>V("materialIds",a,3),removeLabel:t.remove}),r.jsx(D,{label:t.matieres,placeholder:t.matieresPlaceholder,searchPlaceholder:t.matieresSearch,display:"",items:ue,onPick:a=>V("materialIds",a.value,3),multi:!0,emptyText:t.matieresEmpty,testId:"matieres"})]})]})]}),r.jsxs("div",{className:"grid gap-4 md:grid-cols-2",children:[r.jsxs("section",{className:"k-elev rounded-2xl bg-[var(--surface)] p-5",children:[r.jsx($,{titre:t.prix,tag:t.required}),r.jsxs("div",{className:"relative mt-2",children:[r.jsx("input",{value:s.price,onChange:a=>k("price",a.target.value),inputMode:"decimal","aria-label":t.prix,className:"k-input font-display pr-9 text-xl","data-testid":"prix"}),r.jsx("span",{className:"pointer-events-none absolute right-3 top-1/2 -translate-y-1/2 text-[var(--ink-faint)]",children:"â¬"})]}),r.jsxs("label",{className:"k-label mt-3",children:[t.prixAchat," ",r.jsx("span",{className:"font-normal text-[var(--ink-faint)]",children:t.prixAchatSub})]}),r.jsxs("div",{className:"relative",children:[r.jsx("input",{value:s.cost,onChange:a=>k("cost",a.target.value),inputMode:"decimal","aria-label":t.prixAchat,className:"k-input pr-9","data-testid":"prix-achat"}),r.jsx("span",{className:"pointer-events-none absolute right-3 top-1/2 -translate-y-1/2 text-[var(--ink-faint)]",children:"â¬"})]}),r.jsx("p",{className:"mt-2 text-xs text-[var(--ink-faint)]",children:I!==null&&K!==null?t.marge(U(I-K,e)):t.margeVide})]}),r.jsxs("section",{className:"k-elev rounded-2xl bg-[var(--surface)] p-5",children:[r.jsx($,{titre:t.colis}),r.jsx("div",{className:"mt-2 flex flex-col gap-2",role:"radiogroup","aria-label":t.colis,children:l.colis.map(a=>{const i=s.packageSizeId===a.id;return r.jsxs("button",{type:"button",role:"radio","aria-checked":i,onClick:()=>
1k("packageSizeId",a.id),className:`flex items-start gap-3 rounded-xl border px-3 py-2.5 text-left ${i?"border-[rgba(45,212,191,0.32)] bg-[rgba(20,184,166,0.13)]":"border-transparent bg-[var(--surface-2)] hover:bg-[var(--surface-hover)]"}`,children:[r.jsx("span",{"aria-hidden":"true",className:`mt-0.5 h-4 w-4 shrink-0 rounded-full border-2 ${i?"border-[#14b8a6] bg-[#14b8a6] shadow-[inset_0_0_0_3px_var(--surface)]":"border-[var(--ink-faint)]"}`}),r.jsxs("span",{children:[r.jsx("span",{className:"block text-sm font-semibold text-[var(--ink)]",children:a.titre}),r.jsx("span",{className:"block text-xs text-[var(--ink-muted)]",children:t.colisDesc[a.id]})]})]},a.id)})}),r.jsx("p",{className:"mt-2 text-xs text-[var(--ink-faint)]",children:t.colisHint})]})]})]}),r.jsxs("aside",{className:"flex flex-col gap-4 lg:sticky lg:top-4",children:[r.jsxs("section",{className:"k-elev rounded-2xl bg-[var(--surface)] p-3.5",children:[r.jsx("div",{className:"mb-2.5 text-[10px] font-semibold uppercase tracking-[0.14em] text-[var(--ink-faint)]",children:t.inWardrobe}),r.jsxs("div",{className:"relative overflow-hidden rounded-xl bg-[var(--surface-2)]","data-testid":"apercu-carte",children:[!q&&r.jsxs("span",{className:"absolute right-2 top-2 z-10 inline-flex items-center gap-1.5 rounded-full border border-[rgba(45,212,191,0.32)] bg-[var(--scrim)] px-2 py-0.5 text-[11px] font-semibold text-[var(--accent-teal-text)] backdrop-blur",children:[r.jsx("span",{"aria-hidden":"true",className:"h-2 w-2 rounded-full bg-[#14b8a6]"}),t.createdIn]}),r.jsx("div",{className:"aspect-square bg-[var(--surface-2)]",children:s.photos[0]&&r.jsx(Ke,{src:s.photos[0],alt:"",className:"h-full w-full object-cover",eager:!0})}),r.jsxs("div",{className:"flex flex-col gap-1.5 p-3",children:[r.jsx("div",{className:"line-clamp-2 text-sm font-medium leading-snug text-[var(--ink)]",children:s.title||t.noTitle}),r.jsx("div",{className:"font-display text-[15px] font-bold text-[var(--ink)]",children:I!==null?U(I,e):"â"}),r.jsx("div",{className:"flex flex-wrap gap-1",children:[x?.champs.marque!==!1?s.brand:"",x?.champs.taille!==!1?s.size:"",ge,x?.champs.couleur!==!1?xe:""].filter(Boolean).map(a=>r.jsx("span",{className:"rounded-full bg-[var(--surface)] px-2 py-0.5 text-[11px] text-[var(--ink-muted)]",children:a},a))})]}),S.length>0&&r.jsx("div",{className:"flex gap-1 px-3 pb-3",children:S.map(a=>r.jsx("span",{className:"flex-1 rounded-md bg-[var(--surface)] py-0.5 text-center text-[10.5px] text-[var(--ink-faint)]",children:$e[a]},a))})]})]}),r.jsxs("section",{className:"k-elev rounded-2xl bg-[var(--surface)] px-4 py-3.5","data-testid":"prisme",children:[r.jsx("div",{className:"mb-1 text-[10px] font-semibold uppercase tracking-[0.14em] text-[var(--ink-faint)]",children:t.whatGoes}),S.length===0?r.jsx("p",{className:"text-xs text-[var(--ink-muted)]",children:t.prismeNone}):r.jsx("ul",{className:"flex flex-col",children:S.map(a=>{const i=G[a],n=qe(d?.margins,we(a,d?.leboncoinAccountType),d?.plateformeSource)??0,c=I!==null?Te(a,I,n,{arrondi:Ee(d?.arrondiPrix),...d?.whatnotSettings?{whatnot:{auction:d.whatnotSettings.auction!==!1,startPrice:Number(d.whatnotSettings.startPrice??1)}}:{}}):null,p=i?.photosMax==null?t.prismePhotosAll:t.prismePhotosMax(i.photosMax),b=i?.titreMax==null?t.prismeTitreNone:i.titreLargement?t.prismeTitreFull:t.prismeTitreCut(i.titreMax);return r.jsxs("li",{className:"grid grid-cols-[16px_74px_1fr] items-center gap-2 border-t border-[var(--line)] py-2 text-xs first:border-t-0",children:[r.jsx("span",{"aria-hidden":"true",className:"h-2 w-2 justify-self-center rounded-full",style:{background:Be[a]}}),r.jsx("span",{className:"font-semibold text-[var(--ink)]",children:_[a]}),r.jsxs("span",{className:"text-[var(--ink-muted)]",children:[r.jsx("b",{className:"font-semibold tabular-nums text-[var(--ink)]",children:c?`${c.devise==="USD"?`${c.montant.toLocaleString(e==="fr"?"fr-FR":"en-GB")} $`:U(c.montant,e)}`:"â"}),c?.regime==="enchere"&&` · ${t.prismeEnchere}`,c&&c.margeAppliquee&&n>0&&r.jsxs("span",{className:"text-[var(--accent-teal-text)]",children:[" +",n," %"]})," · ",p," · ",b]})]},a)})}),r.jsx("p",{className:"mt-2 text-xs text-[var(--ink-faint)]",children:S.length?t.prismeHint(S.length):""})]}),r.jsxs("section",{className:"k-elev rounded-2xl bg-[var(--surface)] p-4",children:[r.jsx("p",{className:"text-xs leading-relaxed text-[var(--ink-faint)]",children:t.saveNote}),!u&&r.jsxs("p",{className:"mt-2.5 flex items-center gap-1.5 text-[11px] text-[var(--ink-faint)]",children:[r.jsx("span",{"aria-hidden":"true",className:"h-1.5 w-1.5 rounded-full bg-[var(--accent-teal-text)]"}),M?t.draftRestored:t.draftKept]})]})]})]})]}),r.jsx("div",{className:"sticky bottom-[var(--barre-bas)] z-20 border-t border-[var(--line)] bg-[color-mix(in_srgb,var(--bg)_95%,transparent)] px-4 py-3 backdrop-blur","data-barre-flottante":!0,"data-testid":"barre-publier",children:r.jsxs("div",{className:"mx-auto flex max-w-5xl flex-wrap items-center justify-end gap-3",children:[O&&r.jsx("p",{role:"alert",className:"mr-auto text-xs text-[var(--danger)]",children:O}),r.jsx("button",{type:"button",onClick:()=>void R(),disabled:N,className:"k-btn","data-testid":"enregistrer",children:N?t.saving:u?t.saveEdit:t.save}),r.jsxs("div",{className:"relative flex","data-menu-plus":!0,children:[r.jsx("button",{type:"button",onClick:()=>void R("publier"),disabled:N,className:"k-btn k-btn-primary rounded-r-none","data-testid":"enregistrer-publier",children:t.savePublish}),r.jsx("button",{ref:re,type:"button",onClick:()=>B(a=>!a),disabled:N,"aria-label":t.moreActions,"aria-expanded":z,className:"k-btn k-btn-primary rounded-l-none border-l border-black/20 px-2.5","data-testid":"menu-programmer",children:"â¾"}),z&&r.jsx("div",{role:"menu",className:"absolute bottom-full right-0 mb-2 w-48 rounded-xl border border-[var(--line-strong)] bg-[var(--surface)] p-1.5 shadow-lg",children:r.jsx("button",{type:"button",role:"menuitem",onClick:()=>{re.current?.focus(),B(!1),F(null),ae(!0)},className:"w-full rounded-lg px-3 py-2 text-left text-sm text-[var(--ink)] hover:bg-[var(--surface-2)]","data-testid":"programmer",children:t.scheduleItem})})]})]})}),he&&r.jsx(Ye,{c:t,lang:e,saving:N,erreur:O,onClose:()=>ae(!1),onConfirm:a=>void R("planifier",a)})]})}function Ye({c:e,lang:t,saving:d,erreur:g,onClose:u,onConfirm:l}){const[f,y]=o.useState(""),[H,P]=o.useState(!1),L=Re(u),q=o.useMemo(()=>{const h=new Date,N=Fe(t,h);return[...N.filter(E=>E.cle==="30m"),{cle:"1h",label:e.in1h,date:new Date(h.getTime()+36e5)},...N.filter(E=>E.cle!=="30m")]},[t,e.in1h]),w=new Date(f),s=!Number.isNaN(w.getTime())&&w.getTime()>Date.now(),T=q.find(h=>f===X(h.date))?.cle,M=H?e.pastTime:g;return r.jsx("div",{className:"fixed inset-0 z-[70] flex items-center justify-center bg-black/60 p-4",onMouseDown:h=>h.target===h.currentTarget&&u(),role:"presentation",children:r.jsxs("div",{ref:L,tabIndex:-1,role:"dialog","aria-modal":"true","aria-labelledby":"fenetre-heure-titre",className:"w-full max-w-[420px] rounded-2xl bg-[var(--surface)] p-5 text-left shadow-[0_24px_70px_rgba(0,0,0,.6)]","data-testid":"fenetre-heure",children:[r.jsxs("div",{className:"flex items-start justify-between gap-3",children:[r.jsx("h3",{id:"fenetre-heure-titre",className:"text-base font-semibold text-[var(--ink)]",children:e.scheduleTitle}),r.jsx("button",{type:"button",onClick:u,"aria-label":e.close,className:"flex h-7 w-7 items-center justify-center rounded-lg text-base leading-none text-[var(--ink-muted)] hover:text-[var(--ink)]",children:"Ã"})]}),r.jsx("div",{className:"mt-3 flex flex-wrap gap-2",children:q.map(h=>{const N=h.cle===T;return r.jsx("button",{type:"button",onClick:()=>{y(X(h.date)),P(!1)},"aria-pressed":N,className:`rounded-full border px-3 py-1.5 text-xs ${N?"border-[rgba(45,212,191,0.32)] bg-[rgba(20,184,166,0.13)] text-[var(--accent-teal-text)]":"border-[var(--line)] text-[var(--ink-soft)] hover:border-[var(--ink-faint)]"}
1`,"data-testid":`heure-${h.cle}`,children:h.label},h.cle)})}),r.jsxs("label",{className:"mt-4 block text-xs font-medium text-[var(--ink-muted)]",children:[e.scheduleDate,r.jsx("input",{type:"datetime-local",value:f,min:X(new Date(Date.now()+6e4)),onChange:h=>{y(h.target.value),P(!1)},className:"k-input mt-1.5","data-testid":"heure-date"})]}),M&&r.jsx("p",{role:"alert",className:"mt-3 text-xs text-[var(--danger)]",children:M}),r.jsxs("div",{className:"mt-5 flex justify-end gap-2",children:[r.jsx("button",{type:"button",onClick:u,className:"k-btn",children:e.cancel}),r.jsx("button",{type:"button",onClick:()=>{w.getTime()>Date.now()?l(w):P(!0)},disabled:!s||d,className:"k-btn k-btn-primary","data-testid":"heure-confirmer",children:e.confirm})]})]})})}function Je(e,t){const d=(e.categoryIds?.length?e.categoryIds[e.categoryIds.length-1]:void 0)??(e.categoryPath?.length?t.parChemin(e.categoryPath)?.id:void 0)??null,g=t.etats.find(f=>f.titre===e.condition)?.id??Q.conditionId,u=[e.color,e.color2].map(f=>f?t.couleurs.find(y=>y.titre===f)?.id:void 0).filter(f=>typeof f=="number"),l=(e.materiaux??[]).map(f=>t.matieres.find(y=>y.titre===f)?.id).filter(f=>typeof f=="number");return{photos:e.photos??[],description:e.description??"",categoryId:d,brand:e.brand??"",size:e.size??"",conditionId:g,colorIds:u,materialIds:l,title:(e.title??"").slice(0,A),price:e.priceAmount!=null?String(e.priceAmount):"",cost:e.costAmount!=null?String(e.costAmount):"",packageSizeId:e.formatColis??2}}function X(e){return new Date(e.getTime()-e.getTimezoneOffset()*6e4).toISOString().slice(0,16)}function $({titre:e,tag:t,tagMuted:d=!1,compteur:g}){return r.jsxs("h2",{className:"mb-2 flex items-baseline gap-2 text-sm font-semibold text-[var(--ink)]",children:[e,t&&r.jsx("span",{className:`text-[11px] font-semibold ${d?"text-[var(--ink-faint)]":"text-[var(--accent-teal-text)]"}`,children:t}),g&&r.jsx("span",{className:"ml-auto text-[11px] font-normal tabular-nums text-[var(--ink-faint)]",children:g})]})}function ie({items:e,onRemove:t,removeLabel:d}){return e.length?r.jsx("div",{className:"mb-1.5 flex flex-wrap gap-1.5",children:e.map(g=>r.jsxs("span",{className:"inline-flex items-center gap-1.5 rounded-full border border-[rgba(45,212,191,0.32)] bg-[rgba(20,184,166,0.13)] py-1 pl-2.5 pr-1.5 text-xs font-semibold text-[var(--accent-teal-text)]",children:[g.swatch&&r.jsx("span",{"aria-hidden":"true",className:"h-2.5 w-2.5 rounded-full border border-black/25",style:{background:g.swatch}}),g.label,r.jsx("button",{type:"button",onClick:()=>t(g.id),"aria-label":d(g.label),className:"flex h-4 w-4 items-center justify-center rounded-full leading-none hover:bg-[rgba(20,184,166,0.2)]",children:"Ã"})]},g.id))}):null}export{ot 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.