1"use strict";(self.webpackChunksaas_frontend=self.webpackChunksaas_frontend||[]).push([[754],{265:(e,a,t)=>{t.d(a,{A:()=>y});var s=t(43),c=t(475),i=t(184),n=t(935),l=t(921),r=t(955),o=t(579);const d="cat.assistant.conversation",u=e=>{try{e?localStorage.setItem(d,e):localStorage.removeItem(d)}catch(a){}},p=(e,a)=>a>0?[{icon:(0,o.jsx)(i.kcq,{}),text:e("catalogue.assistant.sPrice","Analyse les prix de ces produits et propose une strat\xe9gie pour chacun.")},{icon:(0,o.jsx)(i.onj,{}),text:e("catalogue.assistant.sComplete","Compl\xe8te les donn\xe9es manquantes de ces produits.")},{icon:(0,o.jsx)(i.Tvt,{}),text:e("catalogue.assistant.sMarketplaces","V\xe9rifie la pr\xe9sence de ces produits sur les places de march\xe9 et signale les fiches erron\xe9es.")},{icon:(0,o.jsx)(i.t69,{}),text:e("catalogue.assistant.sListings","R\xe9dige les fiches marketplace de ces produits.")},{icon:(0,o.jsx)(i.t69,{}),text:e("catalogue.assistant.sSeo","R\xe9dige le SEO de la fiche produit de ces produits dans toutes les langues du site.")},{icon:(0,o.jsx)(i.HiP,{}),text:e("catalogue.assistant.sAd","Cr\xe9e une publicit\xe9 Instagram : une image 1:1 puis une vid\xe9o 9:16 de 5 s.")}]:[{icon:(0,o.jsx)(i.kcq,{}),text:e("catalogue.assistant.sBadPrices","Quels produits sont mal positionn\xe9s en prix ? Propose une strat\xe9gie pour les 5 plus expos\xe9s.")},{icon:(0,o.jsx)(i.onj,{}),text:e("catalogue.assistant.sIncomplete","Compl\xe8te les produits incomplets du catalogue.")},{icon:(0,o.jsx)(i.t69,{}),text:e("catalogue.assistant.sNoListing","R\xe9dige les fiches des produits qui n\u2019en ont pas encore.")}],g=e=>{let{card:a,t:t}=e;return(0,o.jsxs)("div",{className:"cat-mini-card",children:[(0,o.jsxs)("div",{className:"cat-mini-card-head",children:[(0,o.jsx)(i.onj,{})," ",(0,o.jsx)("strong",{children:t("catalogue.assistant.cardCompletion","Compl\xe9tion web")})]}),(0,o.jsx)(c.N_,{className:"cat-link",to:"/catalogue/products/".concat(a.product_id,"?tab=data"),children:a.title}),(0,o.jsxs)("div",{className:"cat-chips",children:[(0,o.jsx)("span",{className:"cat-pill cat-pill--ok",children:t("catalogue.assistant.applied","{{n}} appliqu\xe9e(s)",{n:(a.applied||[]).length})}),(a.proposed||[]).length>0&&(0,o.jsx)("span",{className:"cat-pill cat-pill--warn",children:t("catalogue.assistant.toConfirm","{{n}} \xe0 confirmer",{n:a.proposed.length})}),a.readiness&&(0,o.jsx)("span",{className:"cat-pill cat-pill--".concat("ready"===a.readiness?"ok":"warn"),children:"ready"===a.readiness?t("catalogue.states.ready","Pr\xeat"):t("catalogue.states.incomplete","Incomplet")})]})]})},m={amazon:"Amazon",fnac_darty:"Fnac Darty",backmarket:"Back Market",cdiscount:"Cdiscount"},h=e=>{let{card:a,t:t}=e;return(0,o.jsxs)("div",{className:"cat-mini-card",children:[(0,o.jsxs)("div",{className:"cat-mini-card-head",children:[(0,o.jsx)(i.t69,{})," ",(0,o.jsx)("strong",{children:t("catalogue.assistant.cardListings","Fiches r\xe9dig\xe9es \u2014 \xe0 valider")})]}),(0,o.jsx)(c.N_,{className:"cat-link",to:"/catalogue/products/".concat(a.product_id,"?tab=listings"),children:a.title}),(0,o.jsxs)("div",{className:"cat-chips",children:[(a.listings||[]).map((e=>(0,o.jsxs)("span",{className:"cat-pill cat-pill--".concat(e.ok?"ai":"warn"),children:[m[e.marketplace]||e.marketplace,e.ok?"":" \u26a0"]},e.marketplace))),(a.existing_pages||[]).map((e=>(0,o.jsxs)("span",{className:"cat-pill cat-pill--ok",title:t("catalogue.marketplaces.joinNote","Vous vous rattachez \xe0 cette page comme vendeur : pas de fiche \xe0 r\xe9diger, seulement l\u2019offre."),children:[m[e]||e," \xb7 ",t("catalogue.marketplaces.pageShort","page existante")]},e)))]})]})},x=e=>{var a,t,s,n,l,r;let{card:d,t:u}=e;return(0,o.jsxs)("div",{className:"cat-mini-card",children:[(0,o.jsxs)("div",{className:"cat-mini-card-head",children:[(0,o.jsx)(i.t69,{})," ",(0,o.jsx)("strong",{children:u("catalogue.assistant.cardSeo","SEO de la fiche ({{lang}}) \u2014 \xe0 relire",{lang:(d.language||"").toUpperCase()})})]}),(0,o.jsx)(c.N_,{className:"cat-link",to:"/catalogue/products/".concat(d.product_id,"?tab=listings"),children:d.title}),(0,o.jsxs)("div",{className:"cat-chips",children:[(0,o.jsx)("span",{className:"cat-pill ".concat(d.ok?"cat-pill--ok":"cat-pill--warn"),children:u("catalogue.seo.words","{{n}} mots",{n:null!==(a=null===(t=d.stats)||void 0===t?void 0:t.words)&&void 0!==a?a:"?"})}),(0,o.jsx)("span",{className:"cat-pill",children:u("catalogue.seo.faqCount","{{n}} questions",{n:null!==(s=null===(n=d.stats)||void 0===n?void 0:n.faq)&&void 0!==s?s:0})}),(0,o.jsx)("span",{className:"cat-pill",children:u("catalogue.seo.linksCount","{{n}} liens internes",{n:null!==(l=null===(r=d.stats)||void 0===r?void 0:r.internal_links)&&void 0!==l?l:0})})]})]})},j={listed:"ok",listed_unconfirmed:"warn",ean_conflict:"bad",not_listed:"",unknown:""},f=e=>{let{card:a,t:t}=e;return(0,o.jsxs)("div",{className:"cat-mini-card",children:[(0,o.jsxs)("div",{className:"cat-mini-card-head",children:[(0,o.jsx)(i.Tvt,{})," ",(0,o.jsx)("strong",{children:t("catalogue.assistant.cardMarketplaces","Pr\xe9sence sur les places de march\xe9")})]}),(0,o.jsx)(c.N_,{className:"cat-link",to:"/catalogue/products/".concat(a.product_id,"?tab=listings"),children:a.title}),(0,o.jsxs)("div",{className:"cat-chips",children:[Object.entries(a.statuses||{}).map((e=>{let[a,s]=e;return(0,o.jsxs)("span",{className:"cat-pill ".concat(j[s]?"cat-pill--".concat(j[s]):""),children:[m[a]||a," \xb7 ",{listed:t("catalogue.marketplaces.pageShort","page existante"),listed_unconfirmed:t("catalogue.marketplaces.toConfirm","\xe0 confirmer"),ean_conflict:t("catalogue.marketplaces.eanShort","EAN erron\xe9"),not_listed:t("catalogue.marketplaces.absent","absente")}[s]||t("catalogue.marketplaces.unknown","Non v\xe9rifi\xe9")]},a)})),a.issues>0&&(0,o.jsx)("span",{className:"cat-pill cat-pill--bad",children:t("catalogue.marketplaces.issuesCount","{{n}} anomalie(s)",{n:a.issues})})]})]})},v=e=>{let{card:a,t:t}=e;return(0,o.jsxs)("div",{className:"cat-mini-card",children:[(0,o.jsxs)("div",{className:"cat-mini-card-head",children:[(0,o.jsx)(i.A7C,{})," ",(0,o.jsx)("strong",{children:t("catalogue.assistant.cardUpdate","Produit mis \xe0 jour")})]}),(0,o.jsx)(c.N_,{className:"cat-link",to:"/catalogue/products/".concat(a.product_id,"?tab=data"),children:a.title}),(0,o.jsx)("span",{className:"cat-faint",children:(a.fields||[]).join(", ")})]})},b=e=>{let{cards:a,conv:t,t:c,lang:i,onChanged:n,onError:d}=e;const u=(0,s.useMemo)((()=>Object.fromEntries(((null===t||void 0===t?void 0:t.proposals)||[]).map((e=>[e.id,e])))),[t]),p=(0,s.useMemo)((()=>Object.fromEntries(((null===t||void 0===t?void 0:t.assets)||[]).map((e=>[e.id,e])))),[t]);return(a||[]).map(((e,a)=>{if("price_proposal"===e.type){const t=u[e.proposal_id];return t?(0,o.jsx)(r.rN,{proposal:t,t:c,lang:i,compact:!0,showProduct:!0,onChanged:n,onError:d},a):null}return"asset"===e.type?p[e.asset_id]?(0,o.jsx)(l.hq,{asset:p[e.asset_id],t:c}
1,a):null:"completion"===e.type?(0,o.jsx)(g,{card:e,t:c},a):"listings"===e.type?(0,o.jsx)(h,{card:e,t:c},a):"marketplaces"===e.type?(0,o.jsx)(f,{card:e,t:c},a):"seo"===e.type?(0,o.jsx)(x,{card:e,t:c},a):"product_update"===e.type?(0,o.jsx)(v,{card:e,t:c},a):null}))},y=e=>{var a,t,c,r,g,m,h,x;let{open:j,onClose:f,context:v,onRemoveContext:y,onClearContext:N,onChanged:k,t:_,lang:C}=e;const[w,E]=(0,s.useState)([]),[S,A]=(0,s.useState)((()=>{try{return localStorage.getItem(d)}catch(e){return null}})()),[P,q]=(0,s.useState)(null),[R,M]=(0,s.useState)(""),[T,z]=(0,s.useState)(!1),[I,L]=(0,s.useState)(null),[O,U]=(0,s.useState)(null),[B,D]=(0,s.useState)(!1),[V,J]=(0,s.useState)({}),[F,H]=(0,s.useState)(null),[K,Q]=(0,s.useState)(null),W=(0,s.useRef)(null),G=(0,s.useRef)(!1),$=(0,s.useRef)(null);(0,s.useEffect)((()=>{if(j)return document.body.classList.add("cat-assistant-open"),()=>document.body.classList.remove("cat-assistant-open")}),[j]);const Y=(0,s.useCallback)((async()=>{try{const e=await(0,n.Jt)("/assistant/conversations");E(e.data.conversations||[])}catch(e){L((0,n.fJ)(e,_("catalogue.assistant.loadError","Impossible de charger les conversations.")))}}),[_]),Z=(0,s.useCallback)((async e=>{if(e)try{const a=await(0,n.Jt)("/assistant/conversations/".concat(e));q(a.data)}catch(t){var a;if(404===(null===t||void 0===t||null===(a=t.response)||void 0===a?void 0:a.status))return A(null),u(null),void q(null);L((0,n.fJ)(t,_("catalogue.assistant.loadError","Impossible de charger les conversations.")))}else q(null)}),[_]);(0,s.useEffect)((()=>{j&&(Y(),Z(S))}),[j]);const X="running"===(null===P||void 0===P||null===(a=P.turn)||void 0===a?void 0:a.status);(0,s.useEffect)((()=>{if(!j||!P||!X)return;const e=setTimeout((()=>Z(P.id)),2e3);return()=>clearTimeout(e)}),[j,P,X,Z]);const ee=((null===P||void 0===P?void 0:P.assets)||[]).some((e=>"queued"===e.status||"running"===e.status));(0,s.useEffect)((()=>{if(!j||!P||X||!ee)return;const e=setTimeout((()=>Z(P.id)),1e4);return()=>clearTimeout(e)}),[j,P,X,ee,Z]),(0,s.useEffect)((()=>{G.current&&!X&&P&&(k&&k(),Y()),G.current=X}),[X,P,k,Y]),(0,s.useEffect)((()=>{const e=W.current;e&&(e.scrollTop=e.scrollHeight)}),[null===P||void 0===P||null===(t=P.messages)||void 0===t?void 0:t.length,X,null===P||void 0===P||null===(c=P.turn)||void 0===c||null===(r=c.events)||void 0===r?void 0:r.length]),(0,s.useEffect)((()=>{j&&$.current&&$.current.focus()}),[j,v.length]);const ae=()=>{A(null),u(null),q(null),D(!1),L(null)},te=async e=>{const a=(null!==e&&void 0!==e?e:R).trim();if(a&&!X){z(!0),L(null),U(null);try{let e=S;if(!e){e=(await(0,n.bE)("/assistant/conversations",{})).data.id,A(e),u(e)}await(0,n.bE)("/assistant/conversations/".concat(e,"/messages"),{text:a,product_ids:v.map((e=>e.id))}),M(""),await Z(e),Y()}catch(t){L((0,n.fJ)(t,_("catalogue.assistant.sendError","Message non envoy\xe9.")))}finally{z(!1)}}},se=(e,a)=>{a&&U(a),P&&Z(P.id),k&&k()},ce=async function(e){let a=arguments.length>1&&void 0!==arguments[1]&&arguments[1];H(e.join(","));try{const t=await(0,n.bE)("/pricing/proposals/apply",{proposal_ids:e,confirm:a}),s=(t.data.errors||[]).filter((e=>"large_drop"===e.code));if(s.length&&!a)return void Q({ids:e,count:s.length});Q(null),U(_("catalogue.assistant.batchDone","{{n}} prix appliqu\xe9(s).",{n:(t.data.applied||[]).length})+((t.data.errors||[]).length?" ".concat(_("catalogue.assistant.batchErrors","{{n}} non appliqu\xe9(s).",{n:t.data.errors.length})):"")),se()}catch(t){"large_drop"!==(0,n.CA)(t)&&L((0,n.fJ)(t,_("catalogue.pricing.applyError","Le prix n\u2019a pas pu \xeatre appliqu\xe9.")))}finally{H(null)}};if(!j)return null;const ie=(null===P||void 0===P?void 0:P.messages)||[],ne=Object.fromEntries(((null===P||void 0===P?void 0:P.proposals)||[]).map((e=>[e.id,e]))),le=v.slice(0,4),re=((null===(g=[...ie].reverse().find((e=>"user"===e.role)))||void 0===g||null===(m=g.context)||void 0===m?void 0:m.product_ids)||[]).slice().sort().join(","),oe=v.length>0&&v.map((e=>e.id)).sort().join(",")!==re;return(0,o.jsxs)("aside",{className:"cat-assistant","aria-label":_("catalogue.assistant.title","Assistant marketing"),children:[(0,o.jsxs)("header",{className:"cat-assistant-head",children:[(0,o.jsxs)("div",{className:"cat-assistant-title",children:[(0,o.jsx)(i.y8Q,{})," ",(0,o.jsx)("span",{children:_("catalogue.assistant.title","Assistant marketing")})]}),(0,o.jsxs)("div",{className:"cat-assistant-actions",children:[(0,o.jsx)("button",{type:"button",className:"cat-icon-btn",onClick:()=>{D(!B),B||Y()},title:_("catalogue.assistant.history","Conversations"),"aria-expanded":B,children:(0,o.jsx)(i.OKX,{})}),(0,o.jsx)("button",{type:"button",className:"cat-icon-btn",onClick:ae,title:_("catalogue.assistant.new","N
1ouvelle conversation"),children:(0,o.jsx)(i.OiG,{})}),(0,o.jsx)("button",{type:"button",className:"cat-icon-btn",onClick:f,title:_("catalogue.common.close","Fermer"),children:(0,o.jsx)(i.QCr,{})})]}),B&&(0,o.jsxs)("div",{className:"cat-assistant-history",role:"menu",children:[0===w.length&&(0,o.jsx)("p",{className:"cat-muted",children:_("catalogue.assistant.noConversation","Aucune conversation.")}),w.map((e=>(0,o.jsxs)("div",{className:"cat-history-item ".concat(e.id===S?"is-active":""),children:[(0,o.jsxs)("button",{type:"button",onClick:()=>{return a=e.id,A(a),u(a),D(!1),L(null),void Z(a);var a},title:e.title,children:[(0,o.jsx)("strong",{children:e.title}),(0,o.jsxs)("span",{className:"cat-faint",children:[(0,n.qw)(e.updated_at)," \xb7 ",e.message_count," ",_("catalogue.assistant.messages","messages")]})]}),(0,o.jsx)("button",{type:"button",className:"cat-icon-btn cat-danger",onClick:()=>(async e=>{try{await(0,n.yH)("/assistant/conversations/".concat(e)),e===S&&ae(),Y()}catch(a){L((0,n.fJ)(a,_("catalogue.assistant.deleteError","Suppression impossible.")))}})(e.id),title:_("catalogue.common.delete","Supprimer"),children:(0,o.jsx)(i.qbC,{})})]},e.id)))]})]}),(0,o.jsx)("div",{className:"cat-assistant-context",children:0===v.length?(0,o.jsx)("span",{className:"cat-faint",children:_("catalogue.assistant.scopeAll","Tout le catalogue \u2014 cochez des produits pour cibler la demande.")}):(0,o.jsxs)(o.Fragment,{children:[(0,o.jsx)("span",{className:"cat-label",children:_("catalogue.assistant.scope","Sur {{n}} produit(s)",{n:v.length})}),(0,o.jsxs)("div",{className:"cat-context-chips",children:[le.map((e=>(0,o.jsxs)("span",{className:"cat-context-chip",title:e.title,children:[e.image?(0,o.jsx)("img",{src:e.image,alt:""}):(0,o.jsx)(i.rrY,{}),(0,o.jsx)("span",{children:e.title}),y&&(0,o.jsx)("button",{type:"button",onClick:()=>y(e.id),"aria-label":_("catalogue.common.remove","Retirer"),children:(0,o.jsx)(i.QCr,{})})]},e.id))),v.length>le.length&&(0,o.jsxs)("span",{className:"cat-context-chip is-more",children:["+",v.length-le.length]}),N&&(0,o.jsx)("button",{type:"button",className:"cat-link",onClick:N,children:_("catalogue.assistant.clearScope","Vider")})]})]})}),(0,o.jsxs)("div",{className:"cat-assistant-body",ref:W,children:[I&&(0,o.jsxs)("div",{className:"cat-alert cat-alert-error",children:[(0,o.jsx)(i._Hm,{})," ",I," ",(0,o.jsx)("button",{type:"button",className:"cat-link",onClick:()=>L(null),children:"\xd7"})]}),O&&(0,o.jsxs)("div",{className:"cat-alert cat-alert-ok",children:[(0,o.jsx)(i.A7C,{})," ",O," ",(0,o.jsx)("button",{type:"button",className:"cat-link",onClick:()=>U(null),children:"\xd7"})]}),0===ie.length&&!X&&(0,o.jsxs)("div",{className:"cat-assistant-welcome",children:[(0,o.jsx)(i.T_n,{}),(0,o.jsx)("strong",{children:v.length?_("catalogue.assistant.welcomeScoped","Que faire sur ces {{n}} produit(s) ?",{n:v.length}):_("catalogue.assistant.emptyTitle","Que voulez-vous faire sur votre catalogue ?")}),(0,o.jsx)("span",{className:"cat-muted",children:_("catalogue.assistant.welcomeText","Prix et strat\xe9gie, donn\xe9es manquantes, fiches marketplace, publicit\xe9s : l\u2019assistant agit, vous validez.")})]}),ie.map(((e,a)=>{if("user"===e.role){var t;const s=(null===(t=e.context)||void 0===t?void 0:t.products)||[];return(0,o.jsxs)("div",{className:"cat-amsg cat-amsg-user",children:[(0,o.jsx)("p",{children:e.content}),s.length>0&&(0,o.jsx)("span",{className:"cat-amsg-scope",children:_("catalogue.assistant.onProducts","sur {{n}} produit(s) : {{names}}",{n:s.length,names:s.slice(0,3).map((e=>e.title)).join(", ")+(s.length>3?"\u2026":"")})})]},a)}const s=(e.proposal_ids||[]).filter((e=>ne[e]&&"pending"===ne[e].status));return(0,o.jsxs)("div",{className:"cat-amsg cat-amsg-assistant ".concat(e.error?"is-error":""),children:[e.error?(0,o.jsxs)("p",{className:"cat-danger",children:[(0,o.jsx)(i.BS8,{})," ",e.content]}):(0,o.jsx)(l.oz,{text:e.content}),(0,o.jsx)(b,{cards:e.cards,conv:P,t:_,lang:C,onChanged:se,onError:L}),s.length>1&&(K&&K.ids.join(",")===s.join(",")?(0,o.jsxs)("div",{className:"cat-confirm",role:"alert",children:[(0,o.jsx)(i.BS8,{}),(0,o.jsx)("span",{children:_("catalogue.assistant.batchConfirm","{{n}} baisse(s) d\xe9passent 25 % : les appliquer quand m\xeame ?",{n:K.count})}),(0,o.jsx)("button",{type:"button",className:"u-btn u-btn--primary",onClick:()=>ce(s,!0),disabled:!!F,children:_("catalogue.pricing.confirm","Confirmer")}),(0,o.jsx)("button",{type:"button",className:"cat-link",onClick:()=>Q(null),children:_("catalogue.common.cancel","Annuler")})]}):(0,o.jsxs)("button",{type:"button",className:"u-btn u-btn--secondary cat-batch-apply",onClick:()=>ce(s),disabled:!!F,children:[F?(0,o.jsx)("span",{className:"cat-spinner"}):(0,o.jsx)(i.A7C,{}
1)," ",_("catalogue.assistant.applyAll","Appliquer les {{n}} propositions",{n:s.length})]})),(e.tool_events||[]).length>0&&(0,o.jsxs)("div",{className:"cat-steps",children:[(0,o.jsxs)("button",{type:"button",className:"cat-link",onClick:()=>J({...V,[a]:!V[a]}),children:[(0,o.jsx)(i.Vr3,{})," ",_("catalogue.assistant.actions","{{n}} action(s) r\xe9alis\xe9e(s)",{n:e.tool_events.length})]}),V[a]&&(0,o.jsx)("ul",{children:e.tool_events.map(((e,a)=>(0,o.jsx)("li",{className:e.ok?"":"cat-danger",children:e.summary},a)))})]}),(0,o.jsx)("span",{className:"cat-faint",children:(0,n.qw)(e.at)})]},a)})),X&&(0,o.jsxs)("div",{className:"cat-amsg cat-amsg-assistant cat-amsg-working","aria-live":"polite",children:[(0,o.jsxs)("span",{children:[(0,o.jsx)("span",{className:"cat-spinner"})," ",_("catalogue.assistant.working","L\u2019assistant travaille\u2026")]}),((null===(h=P.turn)||void 0===h?void 0:h.events)||[]).length>0&&(0,o.jsx)("ul",{children:P.turn.events.map(((e,a)=>(0,o.jsx)("li",{className:e.ok?"":"cat-danger",children:e.summary},a)))}),(0,o.jsx)(b,{cards:null===(x=P.turn)||void 0===x?void 0:x.cards,conv:P,t:_,lang:C,onChanged:se,onError:L})]})]}),(0,o.jsxs)("footer",{className:"cat-assistant-foot",children:[!X&&(0===ie.length||oe)&&(0,o.jsx)("div",{className:"cat-suggestions",children:p(_,v.length).map(((e,a)=>(0,o.jsxs)("button",{type:"button",className:"cat-suggestion",onClick:()=>te(e.text),disabled:T,children:[e.icon," ",(0,o.jsx)("span",{children:e.text})]},a)))}),(0,o.jsxs)("div",{className:"cat-assistant-input",children:[(0,o.jsx)("textarea",{ref:$,className:"cat-textarea",rows:2,value:R,disabled:X||T,onChange:e=>M(e.target.value),onKeyDown:e=>{"Enter"!==e.key||e.shiftKey||(e.preventDefault(),te())},placeholder:v.length?_("catalogue.assistant.placeholderScoped","Demandez quelque chose sur les {{n}} produit(s) s\xe9lectionn\xe9(s)\u2026",{n:v.length}):_("catalogue.assistant.placeholder","Ex. : \xab Quels produits sont trop chers par rapport au march\xe9 ? \xbb")}),(0,o.jsx)("button",{type:"button",className:"u-btn u-btn--primary",onClick:()=>te(),disabled:X||T||!R.trim(),"aria-label":_("catalogue.assistant.send","Envoyer"),"data-tour":"cat-assistant-send",children:(0,o.jsx)(i.Cer,{})})]}),(0,o.jsx)("span",{className:"cat-faint",children:_("catalogue.assistant.footer","Entr\xe9e pour envoyer \xb7 les prix ne changent que si vous cliquez \xab Appliquer \xbb.")})]})]})}},921:(e,a,t)=>{t.d(a,{hq:()=>r,iH:()=>l,lr:()=>o,oz:()=>u});var s=t(43),c=t(184),i=t(935),n=t(579);const l=e=>{let{product:a,t:t,onChanged:l,onError:r}=e;const[o,d]=(0,s.useState)(null),u=Object.entries(a.enrichment||{}),p=a.enrichment_meta,g={gtin:"EAN / GTIN",brand:t("catalogue.products.colBrand","Marque"),description_html:t("catalogue.fields.description","Description"),short_description:t("catalogue.seo.shortDescription","Description courte"),category_path:t("catalogue.fields.category","Cat\xe9gorie"),product_type:t("catalogue.source.productType","Type"),attributes:t("catalogue.fields.attributes","Attributs")},m={applied:["ok",t("catalogue.enrich.applied","appliqu\xe9e")],proposed:["warn",t("catalogue.enrich.proposed","\xe0 confirmer")],rejected:["",t("catalogue.enrich.rejected","rejet\xe9e")]},h=async(e,s)=>{d(e);try{await(0,i.bE)("/products/".concat(a.id,"/enrichment/").concat(e,"/").concat(s)),l("apply"===s?t("catalogue.enrich.appliedNotice","Valeur appliqu\xe9e au produit."):t("catalogue.enrich.rejectedNotice","Valeur retir\xe9e."))}catch(c){r((0,i.fJ)(c,t("catalogue.enrich.resolveError","Action impossible.")))}finally{d(null)}};if(!u.length)return null;const x=(e,a)=>"attributes"===e?Object.entries(a||{}).map((e=>{let[a,t]=e;return"".concat(a," : ").concat(t)})).join(" \xb7 "):"description_html"===e?String(a||"").replace(/<[^>]+>/g," ").replace(/\s+/g," ").trim().slice(0,220)+"\u2026":String(a||"");return(0,n.jsxs)("div",{className:"cat-card",children:[(0,n.jsxs)("h2",{children:[(0,n.jsx)(c.T_n,{})," ",t("catalogue.enrich.title","Compl\xe9tions web")]}),p&&p.identity&&(0,n.jsxs)("p",{className:"cat-muted",children:[p.identity.found?t("catalogue.enrich.identified","Produit identifi\xe9 sur le web ({{on}}).",{on:p.identity.matched_on||"\u2014"}):t("catalogue.enrich.unidentified","Produit non identifi\xe9 avec certitude : les valeurs restent des propositions."),p.identity.official_page&&(0,n.jsxs)(n.Fragment,{children:[" ",(0,n.jsxs)("a",{className:"cat-link",href:(0,i.Uf)(p.identity.official_page),target:"_blank",rel:"noopener noreferrer",children:[(0,n.jsx)(c.EQc,{})," ",t("catalogue.enrich.officialPage","page officielle")]})]}),p.notes&&"rien"!==p.notes&&(0,n.jsxs)(n.Fragment,{children:[" \xb7 ",p.notes]})]}),(0,n.jsx)("div",{className:"cat-table-scroll",children:(0,n.jsxs)("table",{className:"cat-table",style:{minWidth:760},children:[(0,n.jsxs)("colgroup",{children:[(0,n.jsx)("col",{style:{width:140}}),(0,n.jsx)("col",{}),(0,n.jsx)("col",{style:{width:90}}),(0,n.jsx)("col",{style:{width:110}}),(0,n.jsx)("col",{style:{width:210}})]}),(0,n.jsx)("thead",{children:(0,n.jsxs)("tr",{children:[(0,n.jsx)("th",{children:t("catalogue.connections.field","Champ")}),(0,n.jsx)("th",{children:t("catalogue.enrich.value","Valeur trouv\xe9e")}),(0,n.jsx)("th",{children:t("catalogue.enrich.confidence","Confiance")}),(0,n.jsx)("th",{children:t("catalogue.runs.status","\xc9tat")}),(0,n.jsx)("th",{children:t("catalogue.enrich.actions","Actions")})]})}),(0,n.jsx)("tbody",{children:u.map((e=>{let[a,s]=e;const[l,r]=m[s.status]||["",s.status];return(0,n.jsxs)("tr",{style:{cursor:"default"},children:[(0,n.jsx)("td",{children:g[a]||a}
1),(0,n.jsx)("td",{title:x(a,s.value),children:(0,n.jsxs)("div",{className:"cat-product-cell",children:[(0,n.jsx)("span",{children:x(a,s.value)}),(0,n.jsxs)("span",{className:"cat-faint",children:[s.reason,(s.sources||[]).slice(0,2).map(((e,a)=>(0,n.jsxs)("a",{className:"cat-link",href:(0,i.Uf)(e.url),target:"_blank",rel:"noopener noreferrer",children:[" ",(0,n.jsx)(c.EQc,{})," ",(e.url||"").replace(/^https?:\/\/(www\.)?/,"").split("/")[0]]},a)))]})]})}),(0,n.jsx)("td",{children:null!=s.confidence?"".concat(Math.round(100*s.confidence)," %"):"\u2014"}),(0,n.jsx)("td",{children:(0,n.jsx)("span",{className:"cat-pill ".concat(l?"cat-pill--".concat(l):""),children:r})}),(0,n.jsxs)("td",{onClick:e=>e.stopPropagation(),children:["applied"!==s.status&&(0,n.jsxs)("button",{type:"button",className:"cat-link",disabled:o===a,onClick:()=>h(a,"apply"),children:[(0,n.jsx)(c.A7C,{})," ",t("catalogue.enrich.apply","Appliquer")]}),"rejected"!==s.status&&(0,n.jsxs)("button",{type:"button",className:"cat-link cat-danger",disabled:o===a,onClick:()=>h(a,"reject"),children:[(0,n.jsx)(c._Hm,{})," ","applied"===s.status?t("catalogue.enrich.revert","Retirer"):t("catalogue.enrich.reject","Rejeter")]})]})]},a)}))})]})})]})},r=e=>{var a;let{asset:t,t:s,onAnimate:i}=e;const l="queued"===t.status||"running"===t.status,r={done:"ok",failed:"bad",queued:"info",running:"info"}[t.status]||"",o={done:s("catalogue.media.done","pr\xeat"),failed:s("catalogue.media.failed","\xe9chec"),queued:s("catalogue.media.queued","en file"),running:s("catalogue.media.running","en cours")}[t.status]||t.status;return(0,n.jsxs)("div",{className:"cat-asset",children:[(0,n.jsxs)("div",{className:"cat-asset-media",children:["done"===t.status&&t.url&&"image"===t.kind&&(0,n.jsx)("a",{href:t.url,target:"_blank",rel:"noopener noreferrer",children:(0,n.jsx)("img",{src:t.url,alt:"",loading:"lazy"})}),"done"===t.status&&t.url&&"video"===t.kind&&(0,n.jsx)("video",{src:t.url,controls:!0,muted:!0,playsInline:!0,preload:"metadata"}),l&&(0,n.jsxs)("div",{className:"cat-asset-placeholder",children:[(0,n.jsx)("span",{className:"cat-spinner"})," ",o]}),"failed"===t.status&&(0,n.jsxs)("div",{className:"cat-asset-placeholder cat-danger",children:[(0,n.jsx)(c._Hm,{})," ",t.error||o]})]}),(0,n.jsxs)("div",{className:"cat-asset-body",children:[(0,n.jsxs)("div",{className:"cat-status-strip",style:{marginBottom:4},children:[(0,n.jsxs)("span",{className:"cat-pill ".concat(r?"cat-pill--".concat(r):""),children:["video"===t.kind?(0,n.jsx)(c.HiP,{}):(0,n.jsx)(c.dkL,{})," ",o]}),(0,n.jsxs)("span",{className:"cat-faint",children:[t.model_label||t.model,null!==(a=t.params)&&void 0!==a&&a.aspect_ratio?" \xb7 ".concat(t.params.aspect_ratio):""]})]}),(0,n.jsx)("div",{className:"cat-faint",title:t.prompt,children:(t.prompt||"").slice(0,140)}),(0,n.jsxs)("div",{className:"cat-card-actions",style:{marginTop:6},children:["done"===t.status&&t.url&&(0,n.jsxs)("a",{className:"cat-link",href:t.url,target:"_blank",rel:"noopener noreferrer",children:[(0,n.jsx)(c.EQc,{})," ",s("catalogue.media.open","Ouvrir")]}),"done"===t.status&&"image"===t.kind&&i&&(0,n.jsxs)("button",{type:"button",className:"cat-link",onClick:()=>i(t),children:[(0,n.jsx)(c.HiP,{})," ",s("catalogue.media.animate","Cr\xe9er une vid\xe9o \xe0 partir de cette image")]})]})]})]})},o=e=>{let{product:a,t:t,onError:l,onNotice:o}=e;const[d,u]=(0,s.useState)(null),[p,g]=(0,s.useState)({kind:"image",prompt:"",model:"",aspect_ratio:"1:1",use_product_image:!0,source_asset_id:"",negative_prompt:"extra hands, text, watermark, logo change, warped edges, duplicated product, flicker, blur, color shift, morphing",duration:5}),[m,h]=(0,s.useState)(!1),x=(0,s.useCallback)((async()=>{try{const e=await(0,i.Jt)("/assets",{product_id:a.id,limit:60});u(e.data)}catch(e){l((0,i.fJ)(e,t("catalogue.media.loadError","M\xe9dias inaccessibles.")))}}),[a.id,t,l]);(0,s.useEffect)((()=>{x()}),[x]),(0,s.useEffect)((()=>{if(!d||!(d.assets||[]).some((e=>"queued"===e.status||"running"===e.status)))return;const e=setTimeout(x,6e3);return()=>clearTimeout(e)}),[d,x]);const j=Object.entries((null===d||void 0===d?void 0:d.models)||{}).filter((e=>{let[,a]=e;return a.kind===p.kind})),f=((null===d||void 0===d?void 0:d.assets)||[]).filter((e=>"image"===e.kind&&"done"===e.status));return(0,n.jsxs)("div",{children:[d&&!1===d.configured&&(0,n.jsxs)("div",{className:"cat-alert cat-alert-info",children:[(0,n.jsx)(c.BS8,{})," ",t("catalogue.media.notConfigured","G\xe9n\xe9ration de m\xe9dias non configur\xe9e (cl\xe9 Higgsfield absente sur le serveur).")]}),(0,n.jsxs)("div",{className:"cat-generate-box",children:[(0,n.jsxs)("div",{className:"cat-row",children:[(0,n.jsxs)("label",{className:"cat-field",style:{marginBottom:0,flex:"0 0 140px"},children:[(0,n.jsx)("span",{className:"cat-label",children:t("catalogue.media.kind","Type")}),(0,n.jsxs)("select",{className:"cat-select",value:p.kind,onChange:e=>g({...p,kind:e.target.value,model:"",aspect_ratio:"video"===e.target.value?"9:16":"1:1"}),children:[(0,n.jsx)("option",{value:"image",children:t("catalogue.media.image","Image")}),(0,n.jsx)("option",{value:"video",children:t("catalogue.media.video","Vid\xe9o")})]})]}),(0,n.jsxs)("label",{className:"cat-field",style:{marginBottom:0,flex:"0 0 180px"},children:[(0,n.jsx)("span",{className:"cat-label",children:t("catalogue.media.model","Mod\xe8le")}),(0,n.jsxs)("select",{className:"cat-select",value:p.model,onChange:e=>g({...p,model:e.target.value}),children:[(0,n.jsx)("option",{value:"",children:t("catalogue.media.defaultModel","Par d\xe9faut")}),j.map((e=>{let[a,t]=e;return(0,n.jsxs)("option",{value:a,children:[t.label," (~",t.usd," $/","second"===t.unit?"s":"img",")"]},a)}))]})]}),(0,n.jsxs)("label",{className:"cat-field",style:{marginBottom:0,flex:"0 0 120px"},children:[(0,n.jsx)("span",{className:"cat-label",children:t("catalogue.media.format","Format")}),(0,n.jsxs)("select",{className:"cat-select",value:p.aspect_ratio,onChange:e=>g({...p,aspect_ratio:e.target.value}),children:[(0,n.jsx)("option",{children:"1:1"}),(0,n.jsx)("option",{children:"9:16"}),(0,n.jsx)("option",{children:"16:9"}),(0,n.jsx)("option",{children:"4:5"})]})]}),"video"===p.kind&&(0,n.jsxs)("label",{className:"cat-field",style:{marginBottom:0},children:[(0,n.jsx)("span",{className:"cat-label",children:t("catalogue.media.sourceImage","Image de d\xe9part")}),(0,n.jsxs)("select",{className:"cat-select",value:p.source_asset_id,onChange:e=>g({...p,source_asset_id:e.target.value}),children:[(0,n.jsx)("option",{value:"",children:"\u2014"}),f.map((e=>(0,n.jsx)("option",{value:e.id,children:(e.prompt||e.id).slice(0,50)},e.id)))]})]}),"video"===p.kind&&(0,n.jsxs)("label",{className:"cat-field",style:{marginBottom:0,flex:"0 0 110px"},children:[(0,n.jsx)("span",{className:"cat-label",children:t("catalogue.media.duration","Dur\xe9e (s)")}),(0,n.jsxs)("select",{className:"cat-select",value:p.duration,onChange:e=>g({...p,duration:e.target.value}),children:[(0,n.jsx)("option",{children:"5"}),(0,n.jsx)("option",{children:"10"})]})]})]}),(0,n.jsxs)("label",{className:"cat-field",style:{marginBottom:0},children:[(0,n.jsx)("span",{className:"cat-label",children:t("catalogue.media.prompt","Prompt (en anglais, fid\xe8le au produit)")}),(0,n.jsx)("textarea",{className:"cat-textarea",rows:3,value:p.prompt,onChange:e=>g({...p,prompt:e.target.value}),placeholder:"image"===p.kind?"Clean commercial product photo of the exact charger on a dark reflective surface, single rim light, 85mm macro, shallow depth of field, no text":"Slow dolly in on the product, subtle light sweep, premium calm mood, product shape and colour unchanged, no text"})]}),"video"===p.kind&&(0,n.jsxs)("label",{className:"cat-field",style:{marginBottom:0},children:[(0,n.jsx)("span",{className:"cat-label",children:t("catalogue.media.negativePrompt","\xc0 \xe9viter (negative prompt)")}),(0,n.jsx)("input",{className:"cat-input",value:p.negative_prompt,onChange:e=>g({...p,negative_prompt:e.target.value})})]}),(0,n.jsxs)("div",{className:"cat-row",style:{alignItems:"center"},children:["image"===p.kind&&(0,n.jsxs)("label",{className:"cat-check",children:[(0,n.jsx)("input",{type:"checkbox",checked:p.use_product_image,onChange:e=>g({...p,use_product_image:e.target.checked})})," ",t("catalogue.media.useProductImage","Utiliser la photo du produit comme r\xe9f\xe9rence")]}),(0,n.jsx)("div",{style:{flex:"0 0 auto",marginLeft:"auto"},children:(0,n.jsxs)("button",{type:"button",className:"u-btn u-btn--primary",onClick:async()=>{h(!0);try{const e={kind:p.kind,prompt:p.prompt,model:p.model||null,product_ids:[a.id],use_product_image:p.use_product_image,params:"image"===p.kind?{aspect_ratio:p.aspect_ratio}:{aspect_ratio:p.aspect_ratio,duration:Number(p.duration)||5,...p.negative_prompt?{negative_prompt:p.negative_prompt}:{}},source_asset_id:"video"===p.kind&&p.source_asset_id||null};await(0,i.bE)("/assets",e),o(t("catalogue.media.requested","G\xe9n\xe9ration lanc\xe9e : le m\xe9dia appara\xeetra ici d\xe8s qu\u2019il est pr\xeat.")),g((e=>({...e,prompt:""}))),x()}catch(e){l((0,i.fJ)(e,t("catalogue.media.createError","La g\xe9n\xe9ration n\u2019a pas pu d\xe9marrer.")))}finally{h(!1)}},disabled:m||!p.prompt.trim()||"video"===p.kind&&!p.source_asset_id||!1===(null===d||void 0===d?void 0:d.configured),children:[m?(0,n.jsx)("span",{className:"cat-spinner"}):(0,n.jsx)(c.T_n,{})," ",t("catalogue.media.generate","G\xe9n\xe9rer")]})})]}),(0,n.jsx)("span",{className:"cat-help",children:t("catalogue.media.help","Une image d\u2019abord (r\xe9f\xe9rence = photo du catalogue), puis une vid\xe9o \xe0 partir de cette image : un mouvement de cam\xe9ra par clip, 5 s pour un hook, 8 \xe0 10 s pour une r\xe9v\xe9lation. L\u2019assistant marketing peut encha\xeener tout cela pour vous.")})]}),(0,n.jsx)("div",{className:"cat-card-actions",children:(0,n.jsxs)("button",{type:"button",className:"cat-link",onClick:x,children:[(0,n.jsx)(c.KP4,{})," ",t("catalogue.common.refresh","Actualiser")]})}),(0,n.jsxs)("div",{className:"cat-assets",children:[((null===d||void 0===d?void 0:d.assets)||[]).map((e=>(0,n.jsx)(r,{asset:e,t:t,onAnimate:e=>g((a=>{var t;return{...a,kind:"video",aspect_ratio:(null===(t=e.params)||void 0===t?void 0:t.as
1pect_ratio)||"9:16",source_asset_id:e.id,model:""}}))},e.id))),d&&0===(d.assets||[]).length&&(0,n.jsx)("p",{className:"cat-muted",children:t("catalogue.media.empty","Aucun m\xe9dia pour ce produit.")})]})]})},d=e=>{const a=[],t=/\*\*([^*]+)\*\*|\[([^\]]+)\]\((https?:\/\/[^)\s]+)\)|(https?:\/\/[^\s)]+)/g;let s,c=0;for(;null!==(s=t.exec(e));)s.index>c&&a.push(e.slice(c,s.index)),s[1]?a.push((0,n.jsx)("strong",{children:s[1]},a.length)):s[2]?a.push((0,n.jsx)("a",{className:"cat-link",href:s[3],target:"_blank",rel:"noopener noreferrer",children:s[2]},a.length)):a.push((0,n.jsx)("a",{className:"cat-link",href:s[4],target:"_blank",rel:"noopener noreferrer",children:s[4].replace(/^https?:\/\//,"").slice(0,60)},a.length)),c=t.lastIndex;return c<e.length&&a.push(e.slice(c)),a},u=e=>{let{text:a}=e;const t=String(a||"").split("\n"),s=[];let c=0;for(;c<t.length;){const e=t[c];if(/^\s*\|/.test(e)){const e=[];for(;c<t.length&&/^\s*\|/.test(t[c]);)e.push(t[c]),c+=1;const a=e.filter((e=>!/^\s*\|\s*:?-+/.test(e))).map((e=>e.trim().replace(/^\||\|$/g,"").split("|").map((e=>e.trim()))));s.push((0,n.jsx)("div",{className:"cat-table-scroll",children:(0,n.jsxs)("table",{className:"cat-table cat-md-table",children:[(0,n.jsx)("thead",{children:(0,n.jsx)("tr",{children:(a[0]||[]).map(((e,a)=>(0,n.jsx)("th",{children:d(e)},a)))})}),(0,n.jsx)("tbody",{children:a.slice(1).map(((e,a)=>(0,n.jsx)("tr",{style:{cursor:"default"},children:e.map(((e,a)=>(0,n.jsx)("td",{title:e,children:d(e)},a)))},a)))})]})},s.length));continue}if(/^\s*([-*\u2022]|\d+[.)])\s+/.test(e)){const e=[];for(;c<t.length&&/^\s*([-*\u2022]|\d+[.)])\s+/.test(t[c]);)e.push(t[c].replace(/^\s*([-*\u2022]|\d+[.)])\s+/,"")),c+=1;s.push((0,n.jsx)("ul",{children:e.map(((e,a)=>(0,n.jsx)("li",{children:d(e)},a)))},s.length));continue}if(/^\s*#{1,4}\s+/.test(e)){s.push((0,n.jsx)("h3",{children:d(e.replace(/^\s*#+\s+/,""))},s.length)),c+=1;continue}if(""===e.trim()){c+=1;continue}const a=[];for(;c<t.length&&""!==t[c].trim()&&!/^\s*(\||[-*\u2022]\s|\d+[.)]\s|#{1,4}\s)/.test(t[c]);)a.push(t[c]),c+=1;s.push((0,n.jsx)("p",{children:d(a.join(" "))},s.length))}return(0,n.jsx)("div",{className:"cat-md",children:s})}},754:(e,a,t)=>{t.r(a),t.d(a,{StatePill:()=>g,default:()=>h});var s=t(43),c=t(117),i=t(216),n=t(475),l=t(184),r=t(935),o=t(265),d=t(955),u=(t(887),t(579));const p="cat.assistant.open",g=e=>{let{state:a,t:t}=e;const s={ready:["ok",t("catalogue.states.ready","Pr\xeat")],incomplete:["warn",t("catalogue.states.incomplete","Incomplet")],draft:["ai",t("catalogue.states.draft","Brouillon IA")],approved:["ok",t("catalogue.states.approved","Valid\xe9e")],none:["","\u2014"]},[c,i]=s[a]||["",a];return(0,u.jsx)("span",{className:"cat-pill ".concat(c?"cat-pill--".concat(c):""),children:i})},m=e=>{let{states:a,presence:t,t:s}=e;return(0,u.jsx)("span",{className:"cat-dots",children:r.nL.map((e=>{var c;const i=null===a||void 0===a?void 0:a[e.key],n=null===t||void 0===t||null===(c=t.statuses)||void 0===c?void 0:c[e.key],l="listed"===n?"page":"ean_conflict"===n?"bad":"approved"===i?"ok":"draft"===i?"ai":"none",r="listed"===n?s("catalogue.marketplaces.listed","Page existante"):"ean_conflict"===n?s("catalogue.marketplaces.eanConflict","Notre EAN m\xe8ne \xe0 un autre produit"):"approved"===i?s("catalogue.states.approved","Valid\xe9e"):"draft"===i?s("catalogue.states.draft","Brouillon IA"):s("catalogue.products.noListing","pas de fiche");return(0,u.jsx)("span",{className:"cat-dot cat-dot--".concat(l),title:"".concat(e.label," : ").concat(r),children:e.label[0]},e.key)}))})},h=()=>{var e,a,t,h;const{t:x,i18n:j}=(0,c.Bd)(),f=(0,i.Zp)(),[v,b]=(0,n.ok)(),[y,N]=(0,s.useState)(null),[k,_]=(0,s.useState)(null),[C,w]=(0,s.useState)(null),[E,S]=(0,s.useState)({}
1),[A,P]=(0,s.useState)(null),[q,R]=(0,s.useState)(null),[M,T]=(0,s.useState)(null),[z,I]=(0,s.useState)(!1),[L,O]=(0,s.useState)((()=>"1"===v.get("assistant")||(()=>{try{return"1"===localStorage.getItem(p)}catch(e){return!1}})())),U=v.get("q")||"",B=v.get("source")||"",D=v.get("readiness")||"",V=v.get("pricing")||"",J=v.get("marketplace")||"",F=Number(v.get("page")||1),H=j.language||"fr",K=(e,a)=>{const t=new URLSearchParams(v);a?t.set(e,a):t.delete(e),"page"!==e&&t.delete("page"),t.delete("assistant"),b(t,{replace:!0})},Q=e=>{const a=void 0===e?!L:e;O(a);try{localStorage.setItem(p,a?"1":"0")}catch(t){}};(0,s.useEffect)((()=>{if("1"!==v.get("assistant"))return;O(!0);try{localStorage.setItem(p,"1")}catch(a){}const e=new URLSearchParams(v);e.delete("assistant"),b(e,{replace:!0})}),[v,b]);const W=(0,s.useCallback)((async()=>{P(null);try{const[e,a,t]=await Promise.all([(0,r.Jt)("/products/stats"),(0,r.Jt)("/products",{q:U||void 0,source:B||void 0,readiness:D||void 0,pricing:V||void 0,marketplace:J||void 0,page:F,limit:50}),(0,r.Jt)("/sources")]);N(e.data),w(a.data),_(t.data.sources||[])}catch(e){P((0,r.fJ)(e,x("catalogue.products.loadError","Impossible de charger le catalogue.")))}}),[U,B,D,V,J,F,x]);(0,s.useEffect)((()=>{W()}),[W]);const G=(0,r.Xt)(M,(e=>{var a,t;R(x("catalogue.products.bulkDone","Termin\xe9 : {{done}} produit(s) trait\xe9(s), {{failed}} \xe9chec(s).",{done:(null===(a=e.counters)||void 0===a?void 0:a.done)||0,failed:(null===(t=e.counters)||void 0===t?void 0:t.failed)||0})),W()})),$=(null===C||void 0===C?void 0:C.items)||[],Y=Object.keys(E),Z=(0,s.useMemo)((()=>Object.values(E)),[E]),X=$.length>0&&$.every((e=>E[e.id])),ee=Y.length>0&&!X,ae=e=>{var a,t;return{id:e.id,title:e.title,sku:e.sku,image:(null===(a=e.images)||void 0===a||null===(t=a[0])||void 0===t?void 0:t.url)||null}},te=async(e,a,t)=>{if(Y.length){I(!0),P(null);try{const t=await(0,r.bE)(e,a);T(t.data.run_id)}catch(s){P((0,r.fJ)(s,t))}finally{I(!1)}}},se=y&&y.products?Math.round(y.ready/y.products*100):0,ce=C?Math.max(1,Math.ceil(C.total/50)):1,ie=(0,s.useMemo)((()=>Object.fromEntries((k||[]).map((e=>[e.key,e.name])))),[k]),ne=G&&({complete:x("catalogue.products.completing","Compl\xe9tion web en cours\u2026"),competitors:x("catalogue.products.comparing","Analyse des prix en cours\u2026"),marketplaces:x("catalogue.products.checkingMarketplaces","V\xe9rification des places de march\xe9 en cours\u2026"),price_check:x("catalogue.products.rereadingPrices","Lecture des prix sur les pages des offres en cours\u2026")}[G.kind]||x("catalogue.products.generating","R\xe9daction des fiches en cours\u2026"));return(0,u.jsxs)("div",{className:"cat-page ".concat(L?"cat-has-assistant":""),children:[(0,u.jsxs)("div",{className:"cat-head",children:[(0,u.jsxs)("div",{children:[(0,u.jsxs)("h1",{children:[(0,u.jsx)(l.rrY,{})," ",x("catalogue.products.title","Catalogue produits")]}),(0,u.jsx)("p",{className:"cat-muted",children:x("catalogue.products.intro2","Vos produits synchronis\xe9s depuis votre back office, avec leur position prix et leurs fiches marketplace. Cochez des produits puis demandez \xe0 l\u2019assistant.")})]}),(0,u.jsxs)("div",{className:"cat-head-actions",children:[(0,u.jsxs)("button",{type:"button",className:"u-btn ".concat(L?"u-btn--secondary":"u-btn--primary"),onClick:()=>Q(),"data-tour":"cat-assistant-toggle",children:[(0,u.jsx)(l.y8Q,{})," ",L?x("catalogue.assistant.close","Fermer l\u2019assistant"):x("catalogue.nav.assistant","Assistant marketing")]}),(0,u.jsxs)(n.N_,{to:"/catalogue/connections",className:"u-btn u-btn--secondary",children:[(0,u.jsx)(l.O2x,{})," ",x("catalogue.nav.connections","Connexions")]}),(0,u.jsx)("button",{type:"button",className:"u-btn u-btn--secondary",onClick:W,title:x("catalogue.common.refresh","Actualiser"),"aria-label":x("catalogue.common.refresh","Actualiser"),children:(0,u.jsx)(l.KP4,{})})]})]}),A&&(0,u.jsxs)("div",{className:"cat-alert cat-alert-error",children:[(0,u.jsx)(l._Hm,{})," ",A]}),q&&(0,u.jsxs)("div",{className:"cat-alert cat-alert-ok",children:[(0,u.jsx)(l.A7C,{})," ",q," ",(0,u.jsx)("button",{type:"button",className:"cat-link",onClick:()=>R(null),children:"\xd7"})]}),y&&(0,u.jsxs)("div",{className:"cat-tiles",children:[(0,u.jsxs)("div",{className:"cat-tile",children:[(0,u.jsx)("span",{className:"cat-tile-label",children:x("catalogue.products.tileProducts","Produits")}),(0,u.jsx)("span",{className:"cat-tile-value",children:y.products}),(0,u.jsx)("span",{className:"cat-tile-scope",children:x("catalogue.products.tileReadyShort","{{n}} pr\xeats pour une fiche",{n:y.ready})}),(0,u.jsx)("div",{className:"cat-meter",children:(0,u.jsx)("span",{style:{width:"".concat(se,"%")}})})]}),void 0!==y.priced&&(0,u.jsxs)("button",{type:"button",className:"cat-tile cat-tile-btn ".concat("above_median"===V?"is-active":""),onClick:()=>K("pricing","above_median"===V?"":"above_median"),children:[(0,u.jsx)("span",{className:"cat-tile-label",children:x("catalogue.products.tilePriced","Prix anal
1ys\xe9s")}),(0,u.jsxs)("span",{className:"cat-tile-value",children:[y.priced,(0,u.jsxs)("span",{className:"cat-tile-scope",children:[" / ",y.products]})]}),(0,u.jsx)("span",{className:"cat-tile-scope ".concat(y.above_median?"cat-warn-text":""),children:x("catalogue.products.tileAbove","{{n}} au-dessus de la m\xe9diane",{n:y.above_median})})]}),void 0!==y.price_proposals&&(0,u.jsxs)("button",{type:"button",className:"cat-tile cat-tile-btn cat-tile-ai ".concat("pending"===V?"is-active":""),onClick:()=>K("pricing","pending"===V?"":"pending"),children:[(0,u.jsx)("span",{className:"cat-tile-label",children:x("catalogue.products.tileProposals","Propositions de prix")}),(0,u.jsx)("span",{className:"cat-tile-value",children:y.price_proposals}),(0,u.jsx)("span",{className:"cat-tile-scope",children:x("catalogue.products.tileProposalsScope","en attente de votre d\xe9cision")})]}),y.prices_to_verify>0&&(0,u.jsxs)("button",{type:"button",className:"cat-tile cat-tile-btn cat-tile-warn ".concat("to_verify"===V?"is-active":""),onClick:()=>K("pricing","to_verify"===V?"":"to_verify"),children:[(0,u.jsx)("span",{className:"cat-tile-label",children:x("catalogue.products.tileToVerify","Offres \xe0 v\xe9rifier")}),(0,u.jsx)("span",{className:"cat-tile-value",children:y.prices_to_verify}),(0,u.jsx)("span",{className:"cat-tile-scope",children:x("catalogue.products.tileToVerifyScope","produits dont des prix concurrents attendent votre validation")})]}),y.marketplace_checked>0&&(0,u.jsxs)("button",{type:"button",className:"cat-tile cat-tile-btn ".concat(y.marketplace_issues?"cat-tile-bad":""," ").concat("issues"===J?"is-active":""),onClick:()=>K("marketplace","issues"===J?"":"issues"),children:[(0,u.jsx)("span",{className:"cat-tile-label",children:x("catalogue.products.tileIssues","Anomalies marketplace")}),(0,u.jsx)("span",{className:"cat-tile-value",children:y.marketplace_issues}),(0,u.jsx)("span",{className:"cat-tile-scope",children:x("catalogue.products.tileIssuesScope","produits avec une fiche marketplace \xe0 faire corriger ({{n}} v\xe9rifi\xe9s)",{n:y.marketplace_checked})})]}),(0,u.jsxs)("div",{className:"cat-tile",children:[(0,u.jsx)("span",{className:"cat-tile-label",children:x("catalogue.products.tileApproved","Fiches valid\xe9es")}),(0,u.jsxs)("span",{className:"cat-tile-value",children:[y.approved,(0,u.jsxs)("span",{className:"cat-tile-scope",children:[" / ",y.listings]})]}),(0,u.jsx)("span",{className:"cat-tile-scope",children:x("catalogue.products.tileGeneratedScope2","{{n}} produits avec fiches",{n:y.with_listing})})]}),y.backoffice_pending>0&&(0,u.jsxs)("div",{className:"cat-tile cat-tile-warn",children:[(0,u.jsx)("span",{className:"cat-tile-label",children:x("catalogue.products.tileBackoffice","Prix \xe0 reporter")}),(0,u.jsx)("span",{className:"cat-tile-value",children:y.backoffice_pending}),(0,u.jsxs)("button",{type:"button",className:"cat-link",onClick:()=>(0,r.RG)("/pricing/backoffice.csv"),children:[(0,u.jsx)(l.WCW,{})," ",x("catalogue.pricing.exportChanges","Prix \xe0 reporter (CSV)")]})]})]}),G&&"running"===G.status&&(0,u.jsxs)("div",{className:"cat-jobbar","aria-live":"polite",children:[(0,u.jsx)("span",{className:"cat-spinner"}),(0,u.jsxs)("span",{children:[ne," ",((null===(e=G.counters)||void 0===e?void 0:e.done)||0)+((null===(a=G.counters)||void 0===a?void 0:a.failed)||0)," / ",(null===(t=G.counters)||void 0===t?void 0:t.total)||Y.length]}),(0,u.jsx)("div",{className:"cat-meter",children:(0,u.jsx)("span",{style:{width:"".concat(null!==(h=G.counters)&&void 0!==h&&h.total?Math.round((G.counters.done+G.counters.failed)/G.counters.total*100):5,"%")}})})]}),(0,u.jsxs)("div",{className:"cat-toolbar",children:[(0,u.jsxs)("div",{className:"cat-search",children:[(0,u.jsx)(l.KSO,{}),(0,u.jsx)("input",{className:"cat-input",value:U,placeholder:x("catalogue.products.searchPlaceholder","Rechercher un SKU, un EAN, un titre, une marque"),onChange:e=>K("q",e.target.value)})]}),(0,u.jsxs)("select",{className:"cat-select",value:V,onChange:e=>K("pricing",e.target.value),"aria-label":x("catalogue.products.pricingFilter","Prix"),children:[(0,u.jsx)("option",{value:"",children:x("catalogue.products.allPricing","Prix : tous")}),(0,u.jsx)("option",{value:"pending",children:x("catalogue.products.fPending","Proposition en attente")}),(0,u.jsx)("option",{value:"above_median",children:x("catalogue.products.fAbove","Plus cher que la m\xe9diane")}),(0,u.jsx)("option",{value:"not_analyzed",children:x("catalogue.products.fNotAnalyzed","Jamais analys\xe9")}),(0,u.jsx)("option",{value:"backoffice",children:x("catalogue.products.fBackoffice","\xc0 reporter dans le back office")}),(0,u.jsx)("option",{value:"to_verify",children:x("catalogue.products.fToVerify","Offres \xe0 v\xe9rifier")})]}),(0,u.jsxs)("select",{className:"cat-select",value:J,onChange:e=>K("marketplace",e.target.value),"aria-label":x("catalogue.products.marketplaceFilter","Places de march\xe9"),children:[(0,u.jsx)("option",{value:"",children:x("catalogue.products.allMarketplaces","Places de march\xe9 : toutes")}),(0,u.jsx)("option",{value:"issues",children:x("catalogue.products.fIssues","Anomalies \xe0 signaler")}),(0,u.jsx)("option",{value:"listed",children:x("catalogue.products.fListed","Page existante")}),(0,u.jsx)("option",{value:"unchecked",children:x("catalogue.products.fUnchecked","Jamais v\xe9rifi\xe9")})]}),(0,u.jsxs)("select",{className:"cat-select",value:D,onChange:e=>K("readiness",e.target.value),"aria-label":x("catalogue.products.colReadiness","Donn\xe9es"),children:[(0,u.jsx)("option",{value:"",children:x("catalogue.products.allReadiness","Donn\xe9es : toutes")}),(0,u.jsx)("option",{value:"ready",children:x("catalogue.states.ready","Pr\xeat")}),(0,u.jsx)("option",{value:"incomplete",children:x("catalogue.states.incomplete","Incomplet")})]}),(k||[]).length>1&&(0,u.jsxs)("select",{className:"cat-select",value:B,onChange:e=>K("source",e.target.value),children:[(0,u.jsx)("option",{value:"",children:x("catalogue.products.allSources","Toutes les sources")}),(k||[]).map((e=>(0,u.jsx)("option",{value:e.key,children:e.name},e.key)))]})]}),Y.length>0&&(0,u.jsxs)("div",{className:"cat-selection",children:[(0,u.jsx)("strong",{children:x("catalogue.products.selected","{{n}} s\xe9lectionn\xe9(s)",{n:Y.length})}),(0,u.jsxs)("button",{type:"button",className:"u-btn u-btn--primary",onClick:()=>Q(!0),"data-tour":"cat-ask-selection",children:[(0,u.jsx)(l.y8Q,{})," ",x("catalogue.products.askAssistant","Demander \xe0 l\u2019assistant")]}),(0,u.jsxs)("button",{type:"button",className:"u-btn u-btn--secondary",onClick:()=>
1te("/products/competitors",{product_ids:Y},x("catalogue.pricing.analyzeError","L\u2019analyse des prix a \xe9chou\xe9. R\xe9essayez dans un instant.")),disabled:z||"running"===(null===G||void 0===G?void 0:G.status),children:[(0,u.jsx)(l.kcq,{})," ",x("catalogue.products.analyzePrices","Analyser les prix")]}),(0,u.jsxs)("button",{type:"button",className:"u-btn u-btn--secondary",onClick:()=>te("/products/competitors/verify",{product_ids:Y},x("catalogue.pricing.rereadError","Les pages n\u2019ont pas pu \xeatre relues. R\xe9essayez dans un instant.")),disabled:z||"running"===(null===G||void 0===G?void 0:G.status),title:x("catalogue.pricing.rereadHint","Relit les pages des offres \xe0 v\xe9rifier et des prix lus il y a plus d\u2019une semaine, sans nouvelle recherche"),children:[(0,u.jsx)(l.KP4,{})," ",x("catalogue.pricing.rereadPrices","Relire les prix")]}),(0,u.jsxs)("button",{type:"button",className:"u-btn u-btn--secondary",onClick:()=>te("/products/complete",{product_ids:Y},x("catalogue.enrich.error","La compl\xe9tion a \xe9chou\xe9. R\xe9essayez dans un instant.")),disabled:z||"running"===(null===G||void 0===G?void 0:G.status),children:[(0,u.jsx)(l.onj,{})," ",x("catalogue.products.completeSelected","Compl\xe9ter (web)")]}),(0,u.jsxs)("button",{type:"button",className:"u-btn u-btn--secondary",onClick:()=>te("/products/marketplaces/check",{product_ids:Y},x("catalogue.marketplaces.checkError","La v\xe9rification a \xe9chou\xe9. R\xe9essayez dans un instant.")),disabled:z||"running"===(null===G||void 0===G?void 0:G.status),children:[(0,u.jsx)(l.Tvt,{})," ",x("catalogue.products.checkMarketplaces","V\xe9rifier les places de march\xe9")]}),(0,u.jsxs)("button",{type:"button",className:"u-btn u-btn--secondary",onClick:()=>te("/products/generate",{product_ids:Y,language:"fr"},x("catalogue.products.generateError","La g\xe9n\xe9ration n\u2019a pas pu d\xe9marrer.")),disabled:z||"running"===(null===G||void 0===G?void 0:G.status),"data-tour":"cat-generate",children:[(0,u.jsx)(l.t69,{})," ",x("catalogue.products.generateSelected2","R\xe9diger les fiches")]}),(0,u.jsx)("button",{type:"button",className:"cat-link",onClick:()=>S({}),children:x("catalogue.common.clearSelection","Tout d\xe9s\xe9lectionner")})]}),k&&0===k.length&&(0,u.jsxs)("div",{className:"cat-card cat-empty",children:[(0,u.jsx)(l.O2x,{}),(0,u.jsx)("strong",{children:x("catalogue.products.emptyTitle","Aucune source de produits connect\xe9e")}),(0,u.jsx)("span",{className:"cat-muted",children:x("catalogue.products.emptyText","Connectez Shopify, PrestaShop, l\u2019API de votre ERP ou importez un fichier pour voir vos produits ici.")}),(0,u.jsxs)(n.N_,{to:"/catalogue/connections",className:"u-btn u-btn--primary","data-tour":"cat-add-source",children:[(0,u.jsx)(l.O2x,{})," ",x("catalogue.products.connectSource","Connecter une source")]})]}),(!k||k.length>0)&&(0,u.jsx)("div",{className:"cat-table-scroll",children:(0,u.jsxs)("table",{className:"cat-table cat-products-table","data-tour":"cat-products",children:[(0,u.jsxs)("colgroup",{children:[(0,u.jsx)("col",{style:{width:36}}),(0,u.jsx)("col",{style:{width:52}}),(0,u.jsx)("col",{className:"cat-col-product"}),(0,u.jsx)("col",{style:{width:104}}),(0,u.jsx)("col",{style:{width:176}}),(0,u.jsx)("col",{className:"cat-col-optional",style:{width:70}}),(0,u.jsx)("col",{style:{width:96}}),(0,u.jsx)("col",{style:{width:104}}),(0,u.jsx)("col",{className:"cat-col-optional",style:{width:104}}),(0,u.jsx)("col",{style:{width:44}})]}),(0,u.jsx)("thead",{children:(0,u.jsxs)("tr",{children:[(0,u.jsx)("th",{className:"cat-check",children:(0,u.jsx)("input",{type:"checkbox",checked:X,ref:e=>{e&&(e.indeterminate=ee&&$.some((e=>E[e.id])))},onChange:()=>S((e=>{const a={...e};return X?$.forEach((e=>delete a[e.id])):$.forEach((e=>{a[e.id]=ae(e)})),a})),"aria-label":x("catalogue.products.selectAll","Tout s\xe9lectionner")})}),(0,u.jsx)("th",{}),(0,u.jsx)("th",{children:x("catalogue.products.colProduct","Produit")}),(0,u.jsx)("th",{children:x("catalogue.products.colPrice","Prix")}),(0,u.jsx)("th",{children:x("catalogue.products.colPosition","Position prix")}),(0,u.jsx)("th",{className:"cat-col-optional",children:x("catalogue.products.colStock","Stock")}),(0,u.jsx)("th",{children:x("catalogue.products.colData","Donn\xe9es")}),(0,u.jsx)("th",{children:x("catalogue.products.colListings","Fiches")}),(0,u.jsx)("th",{className:"cat-col-optional",children:x("catalogue.products.colUpdated","Mis \xe0 jour")}),(0,u.jsx)("th",{})]})}),(0,u.jsxs)("tbody",{children:[!C&&[0,1,2,3,4].map((e=>(0,u.jsx)("tr",{"aria-hidden":"true",children:(0,u.jsx)("td",{colSpan:10,children:(0,u.jsx)("div",{className:"cat-skeleton-row"})})},e))),C&&0===$.length&&(0,u.jsx)("tr",{children:(0,u.jsx)("td",{colSpan:10,className:"cat-muted",children:x("catalogue.products.noResult","Aucun produit ne correspond.")})}),$.map((e=>{var a,t,s,c,i,n;const o=e.images&&e.images[0],p=(null===(a=e.readiness)||void 0===a?void 0:a.gaps)||[],h=e.pricing_summary;return(0,u.jsxs)("tr",{className:E[e.id]?"selected":"",onClick:()=>f("/catalogue/products/".concat(e.id)),children:[(0,u.jsx)("td",{className:"cat-check",onClick:e=>e.stopPropagation(),children:(0,u.jsx)("input",{type:"checkbox",checked:!!E[e.id],onChange:()=>(e=>S((a=>{const t={...a};
1return t[e.id]?delete t[e.id]:t[e.id]=ae(e),t})))(e),"aria-label":e.title})}),(0,u.jsx)("td",{children:o?(0,u.jsx)("img",{className:"cat-thumb",src:o.url,alt:"",loading:"lazy"}):(0,u.jsx)("div",{className:"cat-thumb-empty",children:(0,u.jsx)(l.rrY,{})})}),(0,u.jsx)("td",{title:e.title,children:(0,u.jsxs)("div",{className:"cat-product-cell",children:[(0,u.jsx)("strong",{children:e.title}),(0,u.jsx)("span",{className:"cat-faint cat-mono",children:[e.sku,e.gtin?"EAN ".concat(e.gtin):x("catalogue.products.noGtin","EAN manquant"),(k||[]).length>1?ie[e.source_key]:null].filter(Boolean).join(" \xb7 ")})]})}),(0,u.jsx)("td",{children:(0,u.jsx)("span",{className:"cat-price-cell",children:(0,r.up)(null===(t=e.price)||void 0===t?void 0:t.amount,null===(s=e.price)||void 0===s?void 0:s.currency,H)})}),(0,u.jsx)("td",{onClick:a=>{h&&(a.stopPropagation(),f("/catalogue/products/".concat(e.id,"?tab=pricing")))},children:(0,u.jsx)(d.z$,{summary:h,t:x,lang:H})}),(0,u.jsx)("td",{className:"cat-col-optional",children:null!==(c=e.stock)&&void 0!==c?c:(0,u.jsx)("span",{className:"cat-faint",children:"\u2014"})}),(0,u.jsxs)("td",{title:p.map((e=>e.reason)).join(" \xb7 "),children:[(0,u.jsx)(g,{state:(null===(i=e.readiness)||void 0===i?void 0:i.status)||"incomplete",t:x}),p.length>0&&(0,u.jsxs)("span",{className:"cat-faint",children:[" ",p.length]})]}),(0,u.jsxs)("td",{children:[(0,u.jsx)(m,{states:e.listing_states,presence:e.presence,t:x}),(null===(n=e.presence)||void 0===n?void 0:n.open_issues)>0&&(0,u.jsx)("span",{className:"cat-pill cat-pill--bad cat-issue-chip",title:x("catalogue.marketplaces.issuesCount","{{n}} anomalie(s)",{n:e.presence.open_issues}),children:"!"})]}),(0,u.jsx)("td",{className:"cat-col-optional cat-faint",children:(0,r.KW)(e.synced_at||e.updated_at,x)}),(0,u.jsx)("td",{className:"cat-row-actions",onClick:e=>e.stopPropagation(),children:(0,u.jsx)("button",{type:"button",className:"cat-icon-btn cat-row-action",onClick:()=>(e=>{S({[e.id]:ae(e)}),Q(!0)})(e),title:x("catalogue.products.askAbout","Demander \xe0 l\u2019assistant sur ce produit"),"aria-label":x("catalogue.products.askAbout","Demander \xe0 l\u2019assistant sur ce produit"),children:(0,u.jsx)(l.y8Q,{})})})]},e.id)}))]})]})}),C&&C.total>0&&(0,u.jsxs)("div",{className:"cat-pager",children:[(0,u.jsx)("span",{children:x("catalogue.products.pager","{{from}}\u2013{{to}} sur {{total}}",{from:50*(F-1)+1,to:Math.min(50*F,C.total),total:C.total})}),(0,u.jsxs)("div",{className:"cat-pager-buttons",children:[(0,u.jsx)("button",{type:"button",className:"u-btn u-btn--secondary",disabled:F<=1,onClick:()=>K("page",String(F-1)),children:"\u2039"}),(0,u.jsxs)("span",{className:"cat-muted",style:{alignSelf:"center"},children:[F," / ",ce]}),(0,u.jsx)("button",{type:"button",className:"u-btn u-btn--secondary",disabled:F>=ce,onClick:()=>K("page",String(F+1)),children:"\u203a"})]})]}),(0,u.jsx)(o.A,{open:L,onClose:()=>Q(!1),context:Z,onRemoveContext:e=>S((a=>{const t={...a};return delete t[e],t})),onClearContext:()=>S({}),onChanged:W,t:x,lang:H})]})}},955:(e,a,t)=>{t.d(a,{rN:()=>p,vJ:()=>f,z$:()=>d});var s=t(43),c=t(475),i=t(184),n=t(935),l=t(579);const r=e=>({ai:e("catalogue.pricing.sourceAi","IA"),rules:e("catalogue.pricing.sourceRules","R\xe8gles"),agent:e("catalogue.pricing.sourceAgent","Assistant"),operator:e("catalogue.pricing.sourceOperator","Op\xe9rateur")}),o=e=>{let{summary:a,t:t,lang:s}=e;return(0,l.jsx)("span",{className:"cat-pill cat-pill--warn",title:a.to_verify_min?t("catalogue.pricing.verifyChipHint","Prix relev\xe9s par l\u2019IA \xe0 valider ; le moins cher annonc\xe9 : {{price}}",{price:(0,n.up)(a.to_verify_min,"EUR",s)}):"",children:t("catalogue.pricing.verifyChip","{{n}} \xe0 v\xe9rifier",{n:a.to_verify})})},d=e=>{let{summary:a,t:t,lang:s,withPending:c=!0}=e;if(!a||!a.rank)return(null===a||void 0===a?void 0:a.to_verify)>0?(0,l.jsx)("span",{className:"cat-pos",children:(0,l.jsx)(o,{summary:a,t:t,lang:s})}):null!==a&&void 0!==a&&a.pending?(0,l.jsx)(u,{summary:a,t:t,lang:s}):(0,l.jsx)("span",{className:"cat-faint",children:t("catalogue.pricing.notAnalyzed","non analys\xe9")});const[i,r]=(e=>({cheapest:["ok",e("catalogue.pricing.posCheapest","le moins cher")],below_median:["ok",e("catalogue.pricing.posBelow","sous la m\xe9diane")],above_median:["warn",e("catalogue.pricing.posAbove","au-dessus de la m\xe9diane")],most_expensive:["bad",e("catalogue.pricing.posTop","le plus cher")]}))(t)[a.position]||["",""];return(0,l.jsxs)("span",{className:"cat-pos",title:"".concat(r," \xb7 ").concat(t("catalogue.pricing.cheapestIs","le moins cher : {{price}} ({{seller}})",{price:(0,n.up)(a.min,"EUR",s),seller:a.cheapest_seller||"\u2014"})),children:[(0,l.jsxs)("span",{className:"cat-pill cat-pill--".concat(i||"info"),
1children:[(0,n._k)(a.rank),(0,l.jsxs)("span",{className:"cat-pos-size",children:["/",a.market_size]})]}),c&&a.pending&&(0,l.jsx)(u,{summary:a,t:t,lang:s}),a.to_verify>0&&(0,l.jsx)(o,{summary:a,t:t,lang:s}),a.backoffice_pending&&(0,l.jsx)("span",{className:"cat-pill cat-pill--warn",title:t("catalogue.pricing.backofficeHint","Prix appliqu\xe9 dans Unanimity, \xe0 reporter dans le back office"),children:t("catalogue.pricing.toReport","\xe0 reporter")})]})},u=e=>{var a,t;let{summary:s,t:c,lang:r}=e;return(0,l.jsxs)("span",{className:"cat-pill cat-pill--ai",title:null===(a=s.pending)||void 0===a?void 0:a.label,children:[(0,l.jsx)(i.Z0P,{})," ",(0,n.up)(null===(t=s.pending)||void 0===t?void 0:t.price,"EUR",r)]})},p=e=>{let{proposal:a,t:t,lang:o,onChanged:d,onError:u,onVerify:p,compact:g=!1,showProduct:m=!1}=e;const[h,x]=(0,s.useState)(null),[j,f]=(0,s.useState)(""),[v,b]=(0,s.useState)(!1),[y,N]=(0,s.useState)(!1),[k,_]=(0,s.useState)(!1),[C,w]=(0,s.useState)(!g);if((0,s.useEffect)((()=>{x(null),N(!1),b(!1)}),[null===a||void 0===a?void 0:a.id,null===a||void 0===a?void 0:a.status]),!a)return null;const E=a.currency||"EUR",S=["applied","dismissed","superseded"].includes(a.status),A=h||{price:a.proposed_price,label:a.label,expected_rank:a.rank_after,margin_pct:a.margin_after,delta_abs:a.delta_abs,delta_pct:a.delta_pct,large_drop:a.large_drop,choice:a.choice},P="hold"===A.choice||Math.abs((A.price||0)-(a.current_price||0))<.005,[q,R]=(e=>({high:["ok",e("catalogue.pricing.confHigh","confiance \xe9lev\xe9e")],medium:["info",e("catalogue.pricing.confMedium","confiance moyenne")],low:["warn",e("catalogue.pricing.confLow","confiance faible")]}))(t)[a.confidence]||["",""],M=a.analysis||{},T=async function(){let e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];if(e||!A.large_drop){_(!0);try{var s;const c={confirm:e,price:h?h.price:null},i=await(0,n.bE)("/pricing/proposals/".concat(a.id,"/apply"),c);N(!1),d&&d(i.data,t("catalogue.pricing.appliedNotice","Prix appliqu\xe9 : {{price}}.",{price:(0,n.up)(null===(s=i.data.result)||void 0===s?void 0:s.price,E,o)}))}catch(c){"large_drop"===(0,n.CA)(c)?N(!0):u&&u((0,n.fJ)(c,t("catalogue.pricing.applyError","Le prix n\u2019a pas pu \xeatre appliqu\xe9.")))}finally{_(!1)}}else N(!0)},z=async e=>{_(!0);try{await(0,n.bE)("/pricing/proposals/".concat(a.id,"/dismiss")),d&&d(null,e||t("catalogue.pricing.dismissedNotice","Proposition ignor\xe9e."))}catch(s){u&&u((0,n.fJ)(s,t("catalogue.pricing.applyError","Le prix n\u2019a pas pu \xeatre appliqu\xe9.")))}finally{_(!1)}},I=()=>{const e=parseFloat(String(j).replace(",","."));if(!e||e<=0)return;const s=a.current_price||e;x({price:Math.round(100*e)/100,label:t("catalogue.pricing.customPrice","Prix personnalis\xe9"),choice:"custom",delta_abs:Math.round(100*(e-s))/100,delta_pct:Math.round((e-s)/s*1e3)/10,large_drop:e<s&&(s-e)/s*100>25,expected_rank:null,margin_pct:null}),b(!1)},L=(a.alternatives||[]).filter((e=>void 0!==e.price)),O=a.write_back||{};return(0,l.jsxs)("div",{className:"cat-proposal ".concat(S?"is-decided":""," ").concat(g?"is-compact":""),children:[(0,l.jsxs)("div",{className:"cat-proposal-head",children:[(0,l.jsxs)("span",{className:"cat-proposal-kicker",children:[(0,l.jsx)(i.T_n,{})," ",t("catalogue.pricing.proposal","Strat\xe9gie de prix")]}),(0,l.jsx)("span",{className:"cat-pill cat-pill--".concat("ai"===a.source?"ai":"info"),children:r(t)[a.source]||a.source}),R&&(0,l.jsx)("span",{className:"cat-pill cat-pill--".concat(q),children:R}),S&&(0,l.jsx)("span",{className:"cat-pill ".concat("applied"===a.status?"cat-pill--ok":""),children:{applied:t("catalogue.pricing.statusApplied","appliqu\xe9e"),dismissed:t("catalogue.pricing.statusDismissed","ignor\xe9e"),superseded:t("catalogue.pricing.statusSuperseded","remplac\xe9e")}[a.status]})]}),m&&a.product&&(0,l.jsxs)(c.N_,{className:"cat-proposal-product",to:"/catalogue/products/".concat(a.product_id,"?tab=pricing"),children:[a.product.image?(0,l.jsx)("img",{src:a.product.image,alt:""}):(0,l.jsx)("span",{className:"cat-thumb-empty",children:(0,l.jsx)(i.rrY,{})}),(0,l.jsxs)("span",{children:[(0,l.jsx)("strong",{children:a.product.title}),(0,l.jsx)("span",{className:"cat-faint",children:a.product.sku})]})]}),a.headline&&(0,l.jsx)("div",{className:"cat-proposal-headline",children:a.headline}),(0,l.jsxs)("div",{className:"cat-proposal-prices",children:[(0,l.jsxs)("div",{className:"cat-price-block",children:[(0,l.jsx)("span",{className:"cat-label",children:t("catalogue.pricing.current","Prix actuel")}),(0,l.jsx)("span",{className:"cat-price ".concat(P?"":"is-old"),children:(0,n.up)(a.current_price,E,o)})]}),!P&&(0,l.jsx)(i.Z0P,{className:"cat-price-arrow"}),!P&&(0,l.jsxs)("div",{className:"cat-price-block",children:[(0,l.jsx)("span",{className:"cat-label",children:"applied"===a.status?t("catalogue.pricing.applied","Appliqu\xe9"):A.label}),(0,l.jsx)("span",{className:"cat-price cat-price-new ".concat("applied"===a.status?"is-applied":""),children:(0,n.up)("applied"===a.status?a.applied_price:A.price,E,o)})]}),!P&&null!==A.delta_abs&&void 0!==A.delta_abs&&(0,l.jsxs)("span",{className:"cat-delta",children:[A.delta_abs>0?"+":"",(0,n.up)(A.delta_abs,E,o)," \xb7 ",(0,n.pT)(A.delta_pct,o)]})]}),(0,l.jsxs)("div",{className:"cat-proposal-facts",children:[a.rank_now&&(0,l.jsxs)("span",{className:"cat-fact",children:[(0,l.jsx)("span",{className:"cat-label",children:t("catalogue.pricing.rank","Position")}),(0,l.jsxs)("strong",{children:[(0,n._k)(a.rank_now),!P&&A.expected_rank?" \u2192 ".concat((0,n._k)(A.expected_rank)):""]}),(0,l.jsxs)("span",{className:"cat-faint",children:[" / ",a.market_size]})]}),null!==a.margin_now&&void 0!==a.margin_now&&(0,l.jsxs)("span",{className:"cat-fact",children:[(0,l.jsx)("span",{className:"cat-label",children:t("catalogue.pricing.margin","Marge")}),(0,l.jsxs)("strong",{children:[(0,n.pT)(a.margin_now,o).replace("+",""),P||null===A.margin_pct||void 0===A.margin_pct?"":" \u2192 ".concat((0,n.pT)(A.margin_pct,o).replace("+",""))]})]}),M.min&&(0,l.jsxs)("span",{className:"cat-fact",children:[(0,l.jsx)("span",{className:"cat-label",children:t("catalogue.pricing.cheapest","Le moins cher")}),(0,l.jsx)("strong",{children:(0,n.up)(M.min,E,o)})," ",(0,l.jsxs)("span",{className:"cat-faint",children:[M.cheapest_seller,M.cheapest_verified?" \u2713":""]})]}),M.median&&(0,l.jsxs)("span",{className:"cat-fact",children:[(0,l.jsx)("span",{className:"cat-label",children:t("catalogue.pricing.median","M\xe9diane")}),(0,l.jsx)("strong",{children:(0,n.up)(M.median,E,o)})]})]}),(a.position_summary||a.rationale)&&(0,l.jsxs)("div",{className:"cat-proposal-why",children:[g&&(0,l.jsx)("button",{type:"button",className:"cat-link",onClick:()=>w(!C),children:C?t("catalogue.pricing.hideWhy","Masquer l\u2019explication"):t("catalogue.pricing.why","Pourquoi ?")}),C&&(0,l.jsxs)(l.Fragment,{children:[a.position_summary&&(0,l.jsx)("p",{children:a.position_summary}),a.rationale&&(0,l.jsx)("p",{children:a.rationale}),a.expected_effect&&(0,l.jsx)("p",{className:"cat-muted",children:a.expected_effect}),(a.risks||[]).length>0&&(0,l.jsx)("ul",{className:"cat-risks",children:a.risks.map(((e,a)=>(0,l.jsxs)("li",{children:[(0,l.jsx)(i.BS8,{})," ",e]},a)))}),(0,l.jsxs)("span",{className:"cat-faint",children:[t("catalogue.pricing.basis2","Bas\xe9 sur {{n}} offres fiables {{basis}} ({{v}} prix lus sur la page, {{o}} valid\xe9s par vous)",{n:M.market_offers||0,v:M.verified_count||0,o:M.validated_count||0,basis:"identical"===M.basis?t("catalogue.pricing.basisIdentical","identiques"):t("catalogue.pricing.basisComparable","comparables (identiques et \xe9quivalentes)")}),M.to_verify?" \xb7 ".concat(t("catalogue.pricing.pendingCount","{{n}} \xe0 v\xe9rifier",{n:M.to_verify})):""]})]})]}),!S&&(0,l.jsxs)(l.Fragment,{children:[(0,l.jsxs)("div",{className:"cat-alts",role:"radiogroup","aria-label":t("catalogue.pricing.options","Options"),children:[(0,l.jsxs)("button",{type:"button",role:"radio","aria-checked":!h,className:"cat-alt ".concat(h?"":"is-selected"),onClick:()=>x(null),children:[a.label," \xb7 ",(0,n.up)(a.proposed_price,E,o)]}),L.map((e=>(0,l.jsxs)("button",{type:"button",role:"radio","aria-checked":(null===h||void 0===h?void 0:h.choice)===e.choice,title:e.why||"",className:"cat-alt ".concat((null===h||void 0===h?void 0:h.choice)===e.choice?"is-selected":""),onClick:()=>x({...e,margin_pct:e.margin_pct}),children:[e.label," \xb7 ",(0,n.up)(e.price,E,o),e.expected_rank?" \xb7 ".concat((0,n._k)(e.expected_rank)):""]},e.choice))),!v&&(0,l.jsx)("button",{type:"button",className:"cat-alt cat-alt-custom",onClick:()=>b(!0),children:t("catalogue.pricing.otherPrice","Autre prix\u2026")}),v&&(0,l.jsxs)("span",{className:"cat-alt-input",children:[(0,l.jsx)("input",{className:"cat-input",inputMode:"decimal",value:j,onChange:e=>f(e.target.value),placeholder:"29,90",onKeyDown:e=>{"Enter"===e.key&&I()},autoFocus:!0}),(0,l.jsx)("button",{type:"button",className:"u-btn u-btn--secondary",onClick:I,children:"OK"})]})]}),y?(0,l.jsxs)("div",{className:"cat-confirm",role:"alert",children:[(0,l.jsx)(i.BS8,{}),(0,l.jsx)("span",{children:t("catalogue.pricing.confirmDrop","Baisse de {{pct}} : confirmez-vous le passage \xe0 {{price}} ?",{pct:(0,n.pT)(Math.abs(A.delta_pct||0),o).replace("+",""),price:(0,n.up)(A.price,E,o)})}),(0,l.jsx)("button",{type:"button",className:"u-btn u-btn--primary",onClick:()=>T(!0),disabled:k,children:t("catalogue.pricing.confirm","Confirmer")}),(0,l.jsx)("button",{type:"button",className:"cat-link",onClick:()=>N(!1),children:t("catalogue.common.cancel","Annuler")})]}):(0,l.jsxs)("div",{className:"cat-proposal-actions",children:[!M.market_offers&&M.to_verify>0&&(p?(0,l.jsxs)("button",{type:"button",className:"u-btn u-btn--primary",onClick:p,children:[(0,l.jsx)(i.A7C,{})," ",t("catalogue.pricing.verifyOffers","V\xe9rifier les {{n}} offres",{n:M.to_verify})]}):(0,l.jsxs)(c.N_,{className:"u-btn u-btn--primary",to:"/catalogue/products/".concat(a.product_id,"?tab=pricing"),children:[(0,l.jsx)(i.A7C,{})," ",t("catalogue.pricing.verifyOffers","V\xe9rifier les {{n}} offres",{n:M.to_verify})]})),P?(0,l.jsxs)("button",{type:"button",className:"u-btn u-btn--secondary",onClick:()=>z(t("catalogue.pricing.keptNotice","Prix conserv\xe9.")),disabled:k,title:t("catalogue.pricing.holdHint","La recommandation est de garder le prix ; choisissez une autre option pour le modifier."),children:[k?(0,l.jsx)("span",{className:"cat-spinner"}):(0,l.jsx)(i.A7C,{})," ",t("catalogue.pricing.keep","Garder le prix")]}):(0,l.jsxs)(l.Fragment,{children:[(0,l.jsxs)("button",{type:"button",className:"u-btn u-btn--primary",onClick:()=>T(!1),disabled:k,"data-tour":"cat-apply-price",children:[k?(0,l.jsx)("span",{className:"cat-spinner"}):(0,l.jsx)(i.A7C,{})," ",t("catalogue.pricing.apply","Appliquer {{price}}",{price:(0,n.up)(A.price,E,o)})]}),(0,l.jsx)("button",{type:"button",className:"cat-link",onClick:()=>z(),disabled:k,children:t("catalogue.pricing.dismiss","Ignorer")})]})]})]}),"applied"===a.status&&(0,l.jsxs)("div",{className:"cat-writeback cat-writeback--".concat(O.status||"manual"),children:["done"===O.status?(0,l.jsx)(i.A7C,{}):"failed"===O.status?(0,l.jsx)(i._Hm,{}):(0,l.jsx)(i.BS8,{}),(0,l.jsxs)("span",{children:[t("catalogue.pricing.appliedOn","Appliqu\xe9 le {{date}}.",{date:(0,n.qw)(a.decided_at)})," ",O.message]}
1),"done"!==O.status&&(0,l.jsxs)("button",{type:"button",className:"cat-link",onClick:()=>(0,n.RG)("/pricing/backoffice.csv"),children:[(0,l.jsx)(i.WCW,{})," ",t("catalogue.pricing.exportChanges","Prix \xe0 reporter (CSV)")]})]})]})},g=e=>{let{offers:a,ourPrice:t,proposedPrice:s,median:c,t:i,lang:r}=e;const o=(a||[]).filter((e=>e.price>0)),d=[...o.map((e=>e.price)),t,s].filter((e=>e>0));if(0===o.length||!t)return null;const u=Math.min(...d),p=Math.max(...d),g=p-u||p||1,m=e=>4+(e-u)/g*92,h=e=>"".concat(m(e),"%"),x=e=>m(e)<15?"is-start":m(e)>85?"is-end":"",j=s&&Math.abs(s-t)>.004;return(0,l.jsxs)("div",{className:"cat-card cat-ladder-card",children:[(0,l.jsx)("h3",{style:{marginTop:0},children:i("catalogue.pricing.ladder","Positionnement prix")}),(0,l.jsxs)("div",{className:"cat-ladder",role:"img","aria-label":i("catalogue.pricing.ladderAria","Votre prix {{you}} parmi {{n}} offres de {{lo}} \xe0 {{hi}}",{you:(0,n.up)(t,"EUR",r),n:o.length,lo:(0,n.up)(u,"EUR",r),hi:(0,n.up)(p,"EUR",r)}),children:[(0,l.jsx)("div",{className:"cat-ladder-track"}),c&&(0,l.jsx)("span",{className:"cat-ladder-median",style:{left:h(c)},title:"".concat(i("catalogue.pricing.median","M\xe9diane")," ").concat((0,n.up)(c,"EUR",r))}),o.map(((e,a)=>(0,l.jsx)("span",{className:"cat-ladder-dot ".concat(e.verified?"is-verified":""," ").concat("identical"===e.match?"is-identical":""),style:{left:h(e.price)},title:"".concat(e.seller," \u2014 ").concat((0,n.up)(e.price,e.currency,r)," \xb7 ").concat("identical"===e.match?i("catalogue.pricing.identical","identique"):i("catalogue.pricing.equivalent","\xe9quivalent")).concat(e.verified?" \xb7 ".concat(i("catalogue.pricing.verifiedShort","v\xe9rifi\xe9")):"")},a))),(0,l.jsx)("span",{className:"cat-ladder-marker cat-ladder-you ".concat(x(t)),style:{left:h(t)},children:(0,l.jsxs)("span",{className:"cat-ladder-label",children:[i("catalogue.pricing.you","Vous")," ",(0,n.up)(t,"EUR",r)]})}),j&&(0,l.jsx)("span",{className:"cat-ladder-marker cat-ladder-proposed ".concat(x(s)),style:{left:h(s)},children:(0,l.jsxs)("span",{className:"cat-ladder-label",children:[i("catalogue.pricing.proposedShort","Propos\xe9")," ",(0,n.up)(s,"EUR",r)]})}),(0,l.jsx)("span",{className:"cat-ladder-axis cat-ladder-axis-lo",children:(0,n.up)(u,"EUR",r)}),(0,l.jsx)("span",{className:"cat-ladder-axis cat-ladder-axis-hi",children:(0,n.up)(p,"EUR",r)})]}),(0,l.jsxs)("div",{className:"cat-ladder-legend",children:[(0,l.jsxs)("span",{children:[(0,l.jsx)("i",{className:"cat-legend-dot is-identical"})," ",i("catalogue.pricing.identical","identique")]}),(0,l.jsxs)("span",{children:[(0,l.jsx)("i",{className:"cat-legend-dot"})," ",i("catalogue.pricing.equivalent","\xe9quivalent")]}),(0,l.jsxs)("span",{children:[(0,l.jsx)("i",{className:"cat-legend-dot is-verified"})," ",i("catalogue.pricing.onPage","lu sur la page")]}),c&&(0,l.jsxs)("span",{children:[(0,l.jsx)("i",{className:"cat-legend-median"})," ",i("catalogue.pricing.median","M\xe9diane")," ",(0,n.up)(c,"EUR",r)]})]})]})},m=e=>({ban:e("catalogue.pricing.readBan","page non lue (le site a refus\xe9), nouvel essai automatique"),capacity:e("catalogue.pricing.readCapacity","page non lue (lecteur satur\xe9), nouvel essai automatique"),error:e("catalogue.pricing.readError","page non lue, nouvel essai automatique"),budget:e("catalogue.pricing.readBudget","lecture report\xe9e (plafond du jour atteint)"),not_product:e("catalogue.pricing.readNotProduct","la page n\u2019est pas une fiche produit"),currency:e("catalogue.pricing.readCurrency","prix de la page dans une autre devise"),auth:e("catalogue.pricing.readAuth","lecture automatique indisponible")}),h=e=>{let{offer:a,t:t,lang:s}=e;const c=a.page_read;return"page"===a.price_source&&a.verified_at?(0,l.jsx)("span",{className:"cat-faint",children:t("catalogue.pricing.readOn","lu le {{date}}",{date:(0,n.qw)(a.verified_at)})}):a.to_verify?c?c.shared&&c.price?(0,l.jsx)("span",{className:"cat-faint",children:t("catalogue.pricing.readShared","page partag\xe9e : seul le prix mis en avant ({{price}}) s\u2019y lit",{price:(0,n.up)(c.price,c.currency||"EUR",s)})}):c.error?(0,l.jsx)("span",{className:"cat-faint",children:m(t)[c.error]||m(t).error}):"page"===a.price_source?(0,l.jsx)("span",{className:"cat-faint",children:t("catalogue.pricing.readNoId","prix lu, mais la page ne montre ni EAN ni r\xe9f\xe9rence")}):(0,l.jsx)("span",{className:"cat-faint",children:t("catalogue.pricing.readNoPrice","aucun prix lisible sur la page")}):(0,l.jsx)("span",{className:"cat-faint",children:t("catalogue.pricing.readNever","page pas encore lue")}):null},x=e=>{var a,t;let{offer:c,productId:r,t:o,lang:d,onDecided:u,onError:p}=e;
1const[g,m]=(0,s.useState)(!1),[h,x]=(0,s.useState)(""),[j,f]=(0,s.useState)(!1),v=async(e,a)=>{f(!0);try{const t=await(0,n.bE)("/products/".concat(r,"/competitors/offers/").concat(c.key,"/decision"),{decision:e,price:null!==a&&void 0!==a?a:null});m(!1),u(t.data,{confirm:o("catalogue.pricing.confirmedNotice","Offre valid\xe9e : elle compte d\xe9sormais dans la strat\xe9gie."),correct:o("catalogue.pricing.correctedNotice","Prix corrig\xe9 et valid\xe9."),reject:o("catalogue.pricing.rejectedNotice","Offre \xe9cart\xe9e : elle ne sera plus propos\xe9e."),reset:o("catalogue.pricing.resetNotice","Validation annul\xe9e.")}[e])}catch(t){p((0,n.fJ)(t,o("catalogue.pricing.decisionError","Action impossible sur cette offre.")))}finally{f(!1)}},b=()=>{const e=parseFloat(String(h).replace(",","."));e>0&&v("correct",Math.round(100*e)/100)},y=null===(a=c.validation)||void 0===a?void 0:a.status;return g?(0,l.jsxs)("span",{className:"cat-offer-edit",children:[(0,l.jsx)("input",{className:"cat-input",inputMode:"decimal",autoFocus:!0,value:h,placeholder:String(c.price).replace(".",","),onChange:e=>x(e.target.value),onKeyDown:e=>{"Enter"===e.key&&b(),"Escape"===e.key&&m(!1)},"aria-label":o("catalogue.pricing.pagePrice","Prix affich\xe9 sur la page")}),(0,l.jsx)("button",{type:"button",className:"u-btn u-btn--secondary",onClick:b,disabled:j,children:"OK"})]}):!y||"rejected"===y||null!==(t=c.validation)&&void 0!==t&&t.remembered?(0,l.jsxs)("span",{className:"cat-offer-actions",children:[c.to_verify&&(0,l.jsx)("button",{type:"button",className:"cat-icon-btn cat-ok",onClick:()=>v("confirm"),disabled:j,title:o("catalogue.pricing.confirmHint","M\xeame produit et prix exact sur la page : valider"),"aria-label":o("catalogue.pricing.confirmOffer","Valider"),children:(0,l.jsx)(i.CMH,{})}),(0,l.jsx)("button",{type:"button",className:"cat-icon-btn",onClick:()=>{x(""),m(!0)},disabled:j,title:o("catalogue.pricing.correctHint","M\xeame produit, mais la page affiche un autre prix : corriger"),"aria-label":o("catalogue.pricing.correctOffer","Corriger le prix"),children:(0,l.jsx)(i.F7,{})}),(0,l.jsx)("button",{type:"button",className:"cat-icon-btn cat-danger",onClick:()=>v("reject"),disabled:j,title:o("catalogue.pricing.rejectHint","Autre produit ou offre non pertinente : \xe9carter"),"aria-label":o("catalogue.pricing.rejectOffer","\xc9carter"),children:(0,l.jsx)(i.Rqy,{})})]}):(0,l.jsx)("button",{type:"button",className:"cat-link",onClick:()=>v("reset"),disabled:j,children:o("catalogue.pricing.undo","Annuler")})},j=e=>{let{offers:a,ourPrice:t,productId:c,t:r,lang:o,onDecided:d,onError:u,onReread:p,rereading:g}=e;const[m,j]=(0,s.useState)("all"),[f,v]=(0,s.useState)(!1),b=(0,s.useMemo)((()=>a||[]),[a]),y=b.filter((e=>{var a;return"rejected"===(null===(a=e.validation)||void 0===a?void 0:a.status)})),N=b.filter((e=>e.is_self)),k=b.filter((e=>e.to_verify)),_=(0,s.useMemo)((()=>{const e=b.filter((e=>{var a;return!e.is_self&&"rejected"!==(null===(a=e.validation)||void 0===a?void 0:a.status)})).filter((e=>"all"===m||("pending"===m?e.to_verify:e.trusted))).map((e=>({...e,kind:"offer"})));return t&&"pending"!==m&&e.push({kind:"self",price:t}),e.sort(((e,a)=>e.price-a.price))}),[b,t,m]);if(!b.length)return null;const C=(e=>({page:["ok",e("catalogue.pricing.srcPage","lu sur la page")],operator:["ok",e("catalogue.pricing.srcOperator","valid\xe9 par vous")],api:["ok",e("catalogue.pricing.srcApi","flux marchand")],ai:["warn",e("catalogue.pricing.srcAi","non v\xe9rifi\xe9")]}))(r),w=(e=>({gtin:["ok",e("catalogue.pricing.idGtin","EAN identique")],mpn:["ok",e("catalogue.pricing.idMpn","r\xe9f. fabricant identique")],asin:["ok",e("catalogue.pricing.idAsin","m\xeame ASIN")],operator:["ok",e("catalogue.pricing.idOperator","valid\xe9 par vous")],reference:["warn",e("catalogue.pricing.idReference","mod\xe8le vu sur la page")]}))(r);return(0,l.jsxs)("div",{className:"cat-card cat-offers-card",children:[(0,l.jsxs)("div",{className:"cat-offers-head",children:[(0,l.jsx)("h3",{style:{margin:0},children:r("catalogue.pricing.offersTitle","Offres relev\xe9es")}),(0,l.jsx)("div",{className:"cat-segmented",role:"tablist",children:[["all",r("catalogue.pricing.fAll","Toutes")],["trusted",r("catalogue.pricing.fTrusted","Fiables")],["pending","".concat(r("catalogue.pricing.fPending","\xc0 v\xe9rifier")," (").concat(k.length,")")]].map((e=>{let[a,t]=e;return(0,l.jsx)("button",{type:"button",role:"tab","aria-selected":m===a,className:m===a?"active":"",onClick:()=>j(a),children:t},a)}))})]}),k.length>0&&(0,l.jsxs)("p",{className:"cat-help cat-verify-help",children:[(0,l.jsx)(i.BS8,{}
1)," ",r("catalogue.pricing.verifyHelp2","{{n}} offre(s) \xe0 v\xe9rifier : leur page n\u2019a pas pu \xeatre lue, ou plusieurs vendeurs la partagent. Les pages sont relues automatiquement chaque jour ; vous pouvez aussi les relire maintenant, ou ouvrir la page puis valider \u2713, corriger le prix \u270e ou \xe9carter \u2717. Seules les offres fiables comptent dans la strat\xe9gie.",{n:k.length}),p&&(0,l.jsxs)("button",{type:"button",className:"cat-link",onClick:p,disabled:g,children:[g?(0,l.jsx)("span",{className:"cat-spinner"}):(0,l.jsx)(i.KP4,{})," ",r("catalogue.pricing.reread","Relire les pages")]})]}),(0,l.jsx)("div",{className:"cat-table-scroll",children:(0,l.jsxs)("table",{className:"cat-table cat-offers",style:{minWidth:980},children:[(0,l.jsxs)("colgroup",{children:[(0,l.jsx)("col",{style:{width:40}}),(0,l.jsx)("col",{style:{width:190}}),(0,l.jsx)("col",{style:{width:150}}),(0,l.jsx)("col",{style:{width:84}}),(0,l.jsx)("col",{style:{width:92}}),(0,l.jsx)("col",{style:{width:150}}),(0,l.jsx)("col",{}),(0,l.jsx)("col",{style:{width:132}})]}),(0,l.jsx)("thead",{children:(0,l.jsxs)("tr",{children:[(0,l.jsx)("th",{children:"#"}),(0,l.jsx)("th",{children:r("catalogue.pricing.seller","Vendeur")}),(0,l.jsx)("th",{children:r("catalogue.products.colPrice","Prix")}),(0,l.jsx)("th",{children:r("catalogue.pricing.vsYou","vs vous")}),(0,l.jsx)("th",{children:r("catalogue.pricing.shipping","Livraison")}),(0,l.jsx)("th",{children:r("catalogue.pricing.match","Produit")}),(0,l.jsx)("th",{children:r("catalogue.pricing.offer","Offre")}),(0,l.jsx)("th",{children:r("catalogue.pricing.check","V\xe9rification")})]})}),(0,l.jsxs)("tbody",{children:[_.map(((e,a)=>{if("self"===e.kind)return(0,l.jsxs)("tr",{className:"cat-offer-self",children:[(0,l.jsx)("td",{children:a+1}),(0,l.jsx)("td",{children:(0,l.jsx)("strong",{children:r("catalogue.pricing.youRow","Vous (votre prix)")})}),(0,l.jsx)("td",{children:(0,l.jsx)("span",{className:"cat-offer-price",children:(0,n.up)(e.price,"EUR",o)})}),(0,l.jsx)("td",{children:"\u2014"}),(0,l.jsx)("td",{children:"\u2014"}),(0,l.jsx)("td",{children:"\u2014"}),(0,l.jsx)("td",{}),(0,l.jsx)("td",{})]},"self");const s=t?(e.price-t)/t*100:null,[p,g]=C[e.price_source]||C.ai,m="identical"!==e.match?["info",r("catalogue.pricing.equivalent","\xe9quivalent")]:w[e.identity]||["warn",r("catalogue.pricing.idClaimed","m\xeame mod\xe8le (IA)")],j=e.identity_conflict&&!e.trusted&&!e.to_verify,f="page"===e.stock_source&&!1===e.in_stock;return(0,l.jsxs)("tr",{className:j?"cat-offer-excluded":e.to_verify?"cat-offer-pending":"",style:{cursor:"default"},children:[(0,l.jsx)("td",{className:"cat-faint",children:a+1}),(0,l.jsx)("td",{title:e.seller,children:(0,l.jsxs)("div",{className:"cat-product-cell",children:[(0,l.jsx)("strong",{children:e.seller}),(0,l.jsx)("span",{className:"cat-faint",children:e.marketplace!==e.seller?e.marketplace:e.domain})]})}),(0,l.jsx)("td",{children:(0,l.jsxs)("div",{className:"cat-product-cell",children:[(0,l.jsx)("span",{className:"cat-offer-price",children:(0,n.up)(e.price,e.currency,o)}),(0,l.jsxs)("span",{className:"cat-src cat-src--".concat(p),children:["ok"===p?(0,l.jsx)(i.A7C,{}):(0,l.jsx)(i.BS8,{})," ",g]}),e.reported_price&&Math.abs(e.reported_price-e.price)>.005&&(0,l.jsx)("span",{className:"cat-faint",children:r("catalogue.pricing.reported","annonc\xe9 {{price}}",{price:(0,n.up)(e.reported_price,e.currency,o)})}),e.price_changed_since_validation&&(0,l.jsx)("span",{className:"cat-faint",children:r("catalogue.pricing.changedSince","vous aviez valid\xe9 {{price}}",{price:(0,n.up)(e.price_changed_since_validation,e.currency,o)})}),(0,l.jsx)(h,{offer:e,t:r,lang:o})]})}),(0,l.jsx)("td",{children:(0,l.jsx)("span",{className:"cat-diff ".concat(s<0?"is-cheaper":"is-dearer"),children:(0,n.pT)(null===s?null:Math.round(10*s)/10,o)})}),(0,l.jsx)("td",{title:null===e.shipping_price||void 0===e.shipping_price?"":(0,n.up)(e.shipping_price,"EUR",o),children:0===e.shipping_price?r("catalogue.pricing.free","offerte"):e.shipping_price?(0,n.up)(e.shipping_price,"EUR",o):(0,l.jsx)("span",{className:"cat-faint",children:r("catalogue.pricing.unknown","inconnue")})}),(0,l.jsxs)("td",{title:e.identity_conflict||e.match_evidence||"",children:[j?(0,l.jsx)("span",{className:"cat-pill cat-pill--bad",children:r("catalogue.pricing.otherEan","autre EAN sur la page")}):(0,l.jsx)("span",{className:"cat-pill cat-pill--".concat(m[0]),children:m[1]}),f&&(0,l.jsx)("span",{className:"cat-pill cat-pill--warn",title:r("catalogue.pricing.soldOutHint","\xc9puis\xe9 sur la page : non compt\xe9 dans le march\xe9"),children:r("catalogue.pricing.soldOut","\xe9puis\xe9")})]}),(0,l.jsx)("td",{title:e.title,children:(0,l.jsxs)("a",{className:"cat-link",href:(0,n.Uf)(e.url),target:"_blank",rel:"noopener noreferrer",children:[(0,l.jsx)(i.EQc,{})," ",e.title||e.domain]})}),(0,l.jsx)("td",{children:c&&e.key?(0,l.jsx)(x,{offer:e,productId:c,t:r,lang:o,onDecided:d,onError:u}):null})]},e.key||a)})),0===_.length&&(0,l.jsx)("tr",{children:(0,l.jsx)("td",{colSpan:8,className:"cat-muted",children:r("catalogue.pricing.noneInFilter","Aucune offre dans ce filtre.")})})]})]})}),(N.length>0||y.length>0)&&(0,l.jsxs)("div",{className:"cat-offers-foot",children:[N.length>0&&(0,l.jsx)("span",{className:"cat-faint",children:r("catalogue.pricing.selfOffers","Vos propres offres, jamais compar\xe9es : {{list}}",{list:N.map((e=>"".concat(e.marketplace||e.domain," ").concat((0,n.up)(e.price,e.currency,o)))).join(" \xb7 ")})}),y.length>0&&(0,l.jsx)("button",{type:"button",className:"cat-link",onClick:()=>v(!f),children:r("catalogue.pricing.rejectedCount","{{n}} offre(s) \xe9cart\xe9e(s)",{n:y.length})}),f&&(0,l.jsx)("ul",{className:"cat-rejected",children:y.map((e=>(0,l.jsxs)("li",{children:[(0,l.jsxs)("span",{children:[e.seller," \xb7 ",(0,n.up)(e.price,e.currency,o)]}),(0,l.jsx)(x,{offer:e,productId:c,t:r,lang:o,onDecided:d,onError:u})]},e.key)))})]})]})},f=e=>{var a,t,c,r,o;let{product:d,t:u,lang:m,onChanged:h,onError:x,onAskAssistant:f}=e;
1const[v,b]=(0,s.useState)(!1),[y,N]=(0,s.useState)(null),k=d.competitors,_=d.proposals||[],C=_.find((e=>"pending"===e.status||"info"===e.status))||_[0]||null,w=(null===k||void 0===k?void 0:k.stats)||{},E=((null===k||void 0===k?void 0:k.offers)||[]).filter((e=>e.trusted)),S=null===(a=d.pricing_summary)||void 0===a?void 0:a.market_changed,[A,P]=(0,s.useState)(!1),[q,R]=(0,s.useState)(!1),M=async()=>{R(!0);try{var e,a,t;const s=await(0,n.bE)("/products/".concat(d.id,"/competitors/verify")),c=(null===(e=s.data.competitors)||void 0===e?void 0:e.page_reads)||{},i=(null===(a=s.data.competitors)||void 0===a||null===(t=a.stats)||void 0===t?void 0:t.to_verify)||0;h(c.pages?"day"===c.refused?u("catalogue.pricing.rereadCapped","Plafond de lectures du jour atteint : les pages restantes seront lues demain."):u("catalogue.pricing.rereadDone","{{pages}} page(s) relue(s) ; {{left}} offre(s) encore \xe0 v\xe9rifier.",{pages:c.pages,left:i}):u("catalogue.pricing.rereadNone","Aucune page \xe0 relire : les prix ont \xe9t\xe9 lus r\xe9cemment."))}catch(s){x((0,n.fJ)(s,u("catalogue.pricing.rereadError","Les pages n\u2019ont pas pu \xeatre relues. R\xe9essayez dans un instant.")))}finally{R(!1)}};(0,s.useEffect)((()=>{let e=!1;return(0,n.Jt)("/products/".concat(d.id,"/competitors/history")).then((a=>{e||N(a.data.history||[])})).catch((()=>{e||N([])})),()=>{e=!0}}),[d.id,null===k||void 0===k?void 0:k.fetched_at]);const T=async()=>{b(!0);try{await(0,n.bE)("/products/".concat(d.id,"/competitors")),h(u("catalogue.pricing.analyzed","Analyse termin\xe9e : une strat\xe9gie de prix est propos\xe9e."))}catch(e){x((0,n.fJ)(e,u("catalogue.pricing.analyzeError","L\u2019analyse des prix a \xe9chou\xe9. R\xe9essayez dans un instant.")))}finally{b(!1)}};return k||v?(0,l.jsxs)("div",{className:"cat-pricing",children:[(0,l.jsxs)("div",{className:"cat-status-strip",children:[(0,l.jsxs)("button",{type:"button",className:"u-btn u-btn--secondary",onClick:T,disabled:v,children:[v?(0,l.jsx)("span",{className:"cat-spinner"}):(0,l.jsx)(i.KP4,{})," ",u("catalogue.pricing.refresh","Actualiser l\u2019analyse")]}),f&&(0,l.jsxs)("button",{type:"button",className:"u-btn u-btn--secondary",onClick:f,children:[(0,l.jsx)(i.y8Q,{})," ",u("catalogue.pricing.ask","Demander \xe0 l\u2019assistant")]}),k&&(0,l.jsxs)("button",{type:"button",className:"u-btn u-btn--secondary",onClick:M,disabled:q,title:u("catalogue.pricing.rereadHint","Relit les pages des offres \xe0 v\xe9rifier et des prix lus il y a plus d\u2019une semaine, sans nouvelle recherche"),children:[q?(0,l.jsx)("span",{className:"cat-spinner"}):(0,l.jsx)(i.kcq,{})," ",u("catalogue.pricing.rereadPrices","Relire les prix")]}),k&&(0,l.jsxs)("span",{className:"cat-faint",children:[u("catalogue.pricing.analyzedOn","Analyse du {{date}}",{date:(0,n.qw)(k.fetched_at)}),k.duration_s?" \xb7 ".concat(Math.round(k.duration_s)," s"):"",!1===k.web_search_used?" \xb7 ".concat(u("catalogue.pricing.noWeb","sans recherche web")):"",k.pages_checked_at?" \xb7 ".concat(u("catalogue.pricing.pagesCheckedOn","pages lues le {{date}}",{date:(0,n.qw)(k.pages_checked_at)})):""]})]}),v&&(0,l.jsxs)("div",{className:"cat-jobbar","aria-live":"polite",children:[(0,l.jsx)("span",{className:"cat-spinner"})," ",u("catalogue.pricing.working","Recherche web des offres (EAN, r\xe9f\xe9rence, \xe9quivalents), lecture des prix sur chaque page, puis strat\xe9gie : 30 \xe0 90 secondes.")]}),S&&(0,l.jsxs)("div",{className:"cat-alert cat-alert-ai",children:[(0,l.jsx)(i.T_n,{})," ",(0,l.jsx)("span",{children:u("catalogue.pricing.marketChanged2","Le march\xe9 a chang\xe9 depuis la strat\xe9gie (offres valid\xe9es ou \xe9cart\xe9es, prix relus sur les pages) : recalculez-la sur les offres fiables.")}),(0,l.jsxs)("button",{type:"button",className:"u-btn u-btn--primary",onClick:async()=>{P(!0);try{await(0,n.bE)("/products/".concat(d.id,"/pricing/recommend")),h(u("catalogue.pricing.recomputed","Strat\xe9gie recalcul\xe9e sur les offres fiables."))}catch(e){x((0,n.fJ)(e,u("catalogue.pricing.analyzeError","L\u2019analyse des prix a \xe9chou\xe9. R\xe9essayez dans un instant.")))}finally{P(!1)}},disabled:A,children:[A?(0,l.jsx)("span",{className:"cat-spinner"}):(0,l.jsx)(i.KP4,{})," ",u("catalogue.pricing.recompute","Recalculer la strat\xe9gie")]})]}),(0,l.jsxs)("div",{className:"cat-pricing-grid",children:[(0,l.jsx)("div",{className:"cat-pricing-main",children:C?(0,l.jsx)(p,{proposal:C,t:u,lang:m,onChanged:(e,a)=>h(a),onError:x,onVerify:()=>{var e;return null===(e=document.getElementById("cat-offers"))||void 0===e?void 0:e.scrollIntoView({behavior:"smooth",block:"start"})}}):(0,l.jsx)("div",{className:"cat-card cat-muted",children:u("catalogue.pricing.noProposal","Aucune proposition : actualisez l\u2019anal
1yse.")})}),(0,l.jsx)("div",{className:"cat-pricing-side",children:(0,l.jsxs)("div",{className:"cat-card",style:{marginTop:0},children:[(0,l.jsx)("h3",{style:{marginTop:0},children:u("catalogue.pricing.market","March\xe9")}),(0,l.jsxs)("div",{className:"cat-market-facts",children:[(0,l.jsxs)("div",{children:[(0,l.jsx)("span",{className:"cat-label",children:u("catalogue.pricing.yourPosition","Votre position")}),(0,l.jsxs)("strong",{children:[(0,n._k)(w.rank)," ",(0,l.jsxs)("span",{className:"cat-faint",children:["/ ",w.market_size||"\u2014"]})]})]}),(0,l.jsxs)("div",{children:[(0,l.jsx)("span",{className:"cat-label",children:u("catalogue.pricing.cheapest","Le moins cher")}),(0,l.jsx)("strong",{children:(0,n.up)(w.min,"EUR",m)}),(0,l.jsx)("span",{className:"cat-faint",children:w.cheapest_seller})]}),(0,l.jsxs)("div",{children:[(0,l.jsx)("span",{className:"cat-label",children:u("catalogue.pricing.median","M\xe9diane")}),(0,l.jsx)("strong",{children:(0,n.up)(w.median,"EUR",m)})]}),(0,l.jsxs)("div",{children:[(0,l.jsx)("span",{className:"cat-label",children:u("catalogue.pricing.gap","\xc9cart au moins cher")}),(0,l.jsx)("strong",{className:w.delta_vs_min_pct>0?"cat-danger":"",children:(0,n.pT)(w.delta_vs_min_pct,m)})]})]}),(0,l.jsx)("p",{className:"cat-faint",children:u("catalogue.pricing.marketCount2","{{n}} offres fiables : {{v}} prix lus sur la page, {{o}} valid\xe9s par vous",{n:w.market_offers||0,v:w.verified_count||0,o:w.validated_count||0})}),w.to_verify>0&&(0,l.jsxs)("p",{className:"cat-to-verify",children:[(0,l.jsx)(i.BS8,{})," ",u("catalogue.pricing.toVerifyLine","{{n}} \xe0 v\xe9rifier \u2014 la moins ch\xe8re annonc\xe9e : {{price}} ({{seller}})",{n:w.to_verify,price:(0,n.up)(w.to_verify_min,"EUR",m),seller:w.to_verify_min_seller})]}),(w.excluded>0||w.out_of_stock>0)&&(0,l.jsx)("p",{className:"cat-faint",children:[w.excluded>0?u("catalogue.pricing.excludedLine","{{n}} exclue(s) : la page montre un autre EAN",{n:w.excluded}):null,w.out_of_stock>0?u("catalogue.pricing.soldOutLine","{{n}} \xe9puis\xe9e(s), non compt\xe9e(s)",{n:w.out_of_stock}):null].filter(Boolean).join(" \xb7 ")}),(null===k||void 0===k?void 0:k.market_summary)&&(0,l.jsx)("p",{className:"cat-muted",children:k.market_summary})]})})]}),(0,l.jsx)(g,{offers:E,ourPrice:null===(t=d.price)||void 0===t?void 0:t.amount,proposedPrice:C&&"applied"!==C.status&&"hold"!==C.choice?C.proposed_price:null,median:w.median,t:u,lang:m}),(0,l.jsx)("div",{id:"cat-offers",children:(0,l.jsx)(j,{offers:null===k||void 0===k?void 0:k.offers,ourPrice:null===(c=d.price)||void 0===c?void 0:c.amount,productId:d.id,t:u,lang:m,onDecided:(e,a)=>h(a),onError:x,onReread:M,rereading:q})}),(y&&y.length>1||((null===(r=d.pricing)||void 0===r?void 0:r.history)||[]).length>0)&&(0,l.jsxs)("details",{className:"cat-card cat-history",children:[(0,l.jsxs)("summary",{className:"cat-link",children:[(0,l.jsx)(i.OKX,{})," ",u("catalogue.pricing.historyTitle","Historique des prix et des analyses")]}),((null===(o=d.pricing)||void 0===o?void 0:o.history)||[]).length>0&&(0,l.jsxs)("table",{className:"cat-runs",children:[(0,l.jsx)("thead",{children:(0,l.jsxs)("tr",{children:[(0,l.jsx)("th",{children:u("catalogue.runs.date","Date")}),(0,l.jsx)("th",{children:u("catalogue.pricing.from","De")}),(0,l.jsx)("th",{children:u("catalogue.pricing.to","\xc0")}),(0,l.jsx)("th",{children:u("catalogue.pricing.reason","Motif")}),(0,l.jsx)("th",{children:u("catalogue.pricing.backoffice","Back office")})]})}),(0,l.jsx)("tbody",{children:[...d.pricing.history].reverse().map(((e,a)=>(0,l.jsxs)("tr",{children:[(0,l.jsx)("td",{children:(0,n.qw)(e.at)}),(0,l.jsx)("td",{children:(0,n.up)(e.from,"EUR",m)}),(0,l.jsx)("td",{children:(0,n.up)(e.to,"EUR",m)}),(0,l.jsx)("td",{children:e.reason}),(0,l.jsx)("td",{children:e.write_back||("sync"===e.by?u("catalogue.pricing.sync","synchro"):"\u2014")})]},a)))})]}),y&&y.length>1&&(0,l.jsxs)("table",{className:"cat-runs",children:[(0,l.jsx)("thead",{children:(0,l.jsxs)("tr",{children:[(0,l.jsx)("th",{children:u("catalogue.pricing.analysis","Analyse")}),(0,l.jsx)("th",{children:u("catalogue.pricing.cheapest","Le moins cher")}),(0,l.jsx)("th",{children:u("catalogue.pricing.median","M\xe9diane")}),(0,l.jsx)("th",{children:u("catalogue.pricing.rank","Position")})]})}),(0,l.jsx)("tbody",{children:y.map(((e,a)=>{var t,s,c,i;return(0,l.jsxs)("tr",{children:[(0,l.jsx)("td",{children:(0,n.qw)(e.fetched_at)}),(0,l.jsx)("td",{children:(0,n.up)(null===(t=e.stats)||void 0===t?void 0:t.min,"EUR",m)}),(0,l.jsx)("td",{children:(0,n.up)(null===(s=e.stats)||void 0===s?void 0:s.median,"EUR",m)}),(0,l.jsxs)("td",{children:[(0,n._k)(null===(c=e.stats)||void 0===c?void 0:c.rank)," / ",(null===(i=e.stats)||void 0===i?void 0:i.market_size)||"\u2014"]})]},a)}))})]})]})]}):(0,l.jsxs)("div",{className:"cat-card cat-empty",children:[(0,l.jsx)(i.kcq,{}),(0,l.jsx)("strong",{children:u("catalogue.pricing.emptyTitle","Prix jamais analys\xe9")}),(0,l.jsx)("span",{className:"cat-muted",children:u("catalogue.pricing.emptyText","L\u2019IA rel\xe8ve sur le web les offres du m\xeame produit et de ses \xe9quivalents, lit les prix sur les pages, puis propose une strat\xe9gie chiffr\xe9e que vous appliquez d\u2019un clic.")}
1),(0,l.jsxs)("button",{type:"button",className:"u-btn u-btn--primary",onClick:T,children:[(0,l.jsx)(i.kcq,{})," ",u("catalogue.pricing.analyze","Analyser les prix")]})]})}},935:(e,a,t)=>{t.d(a,{CA:()=>o,Jt:()=>d,KW:()=>v,RG:()=>N,Uf:()=>y,Xt:()=>k,_k:()=>f,bE:()=>u,dy:()=>b,fJ:()=>r,nL:()=>m,pT:()=>j,pn:()=>C,qw:()=>x,sQ:()=>w,up:()=>h,yH:()=>g,yJ:()=>p});var s=t(43),c=t(154),i=t(87);const n="/api/catalog",l=()=>({headers:{Authorization:"Bearer ".concat(localStorage.getItem("access_token"))}}),r=(e,a)=>{var t,s,c;const i=null===e||void 0===e||null===(t=e.response)||void 0===t||null===(s=t.data)||void 0===s?void 0:s.detail;return"string"===typeof i?i:i&&"object"===typeof i&&i.message?i.message:Array.isArray(i)&&null!==(c=i[0])&&void 0!==c&&c.msg?i[0].msg:a},o=e=>{var a,t;const s=null===e||void 0===e||null===(a=e.response)||void 0===a||null===(t=a.data)||void 0===t?void 0:t.detail;return s&&"object"===typeof s&&!Array.isArray(s)&&s.code||null},d=(e,a)=>c.A.get("".concat(n).concat(e),{...l(),params:a}),u=function(e,a){let t=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return c.A.post("".concat(n).concat(e),a,{...t,headers:{...l().headers,...t.headers||{}}})},p=(e,a)=>c.A.put("".concat(n).concat(e),a,l()),g=e=>c.A.delete("".concat(n).concat(e),l()),m=[{key:"amazon",label:"Amazon"},{key:"fnac_darty",label:"Fnac Darty"},{key:"backmarket",label:"Back Market"},{key:"cdiscount",label:"Cdiscount"}],h=function(e){let a=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"EUR",t=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"fr";if(null===e||void 0===e||""===e)return"\u2014";try{return new Intl.NumberFormat(t,{style:"currency",currency:a||"EUR"}).format(Number(e))}catch(s){return"".concat(e," ").concat(a||"")}},x=e=>(0,i.r6)(e),j=function(e){let a=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"fr";return null===e||void 0===e?"\u2014":"".concat(e>0?"+":"").concat(new Intl.NumberFormat(a,{maximumFractionDigits:1}).format(e)," %")},f=e=>e?1===e?"1er":"".concat(e,"e"):"\u2014",v=(e,a)=>{const t=(0,i.y5)(e);if(!t)return a("catalogue.time.never","jamais");const s=Math.round((Date.now()-t.getTime())/6e4);if(s<1)return a("catalogue.time.now","\xe0 l'instant");if(s<60)return a("catalogue.time.minutes","il y a {{n}} min",{n:s});const c=Math.round(s/60);return c<24?a("catalogue.time.hours","il y a {{n}} h",{n:c}):a("catalogue.time.days","il y a {{n}} j",{n:Math.round(c/24)})},b=e=>(new TextEncoder).encode(e||"").length,y=e=>"string"===typeof e&&/^https?:\/\//i.test(e.trim())?e.trim():void 0,N=async(e,a)=>{const t=await c.A.get("".concat(n).concat(e),{...l(),params:a,responseType:"blob"}),s=t.headers["content-disposition"]||"",i=/filename="?([^";]+)"?/.exec(s),r=window.URL.createObjectURL(new Blob([t.data])),o=document.createElement("a");o.href=r,o.download=i?i[1]:"export",document.body.appendChild(o),o.click(),o.remove(),window.URL.revokeObjectURL(r)},k=(e,a)=>{const[t,c]=(0,s.useState)(null),i=(0,s.useRef)(!1);return(0,s.useEffect)((()=>{if(!e)return c(null),void(i.current=!1);let t=!1,s=null;const n=async()=>{try{const l=await d("/runs/".concat(e));if(t)return;c(l.data),"running"===l.data.status?s=setTimeout(n,2500):i.current||(i.current=!0,a&&a(l.data))}catch(l){t||(s=setTimeout(n,5e3))}};return n(),()=>{t=!0,s&&clearTimeout(s)}}),[e]),t},_=new Set(["p","br","ul","ol","li","strong","b","em","i","h2","h3","h4"]),C=e=>String(e||"").replace(/<\/?([a-zA-Z0-9]+)[^>]*>/g,((e,a)=>{const t=a.toLowerCase();return _.has(t)?e.startsWith("</")?"</".concat(t,">"):"<".concat(t,">"):""})).replace(/<\/?(script|style|iframe)[^>]*>/gi,""),w=function(e){const a=e=>String(e||"").trim().replace(/#.*$/,"").replace(/\/$/,"").toLowerCase(),t=new Set((arguments.length>1&&void 0!==arguments[1]?arguments[1]:[]).map(a));return String(e||"").replace(/<\/?([a-zA-Z0-9]+)([^>]*)>/g,((e,s,c)=>{const i=s.toLowerCase();if("a"===i){if(e.startsWith("</"))return"</a>";const s=/href=["']([^"']+)["']/i.exec(c||""),i=s&&y(s[1]);return i&&t.has(a(i))?'<a href="'.concat(i.replace(/"/g,"""),'" target="_blank" rel="noopener noreferrer">'):"<a>"}return _.has(i)?e.startsWith("</")?"</".concat(i,">"):"<".concat(i,">"):""})).replace(/<\/?(script|style|iframe)[^>]*>/gi,"")}},887:()=>{}}]); 2//# sourceMappingURL=754.c1daa9c6.chunk.js.map
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.