PageSourceSearch

https://sav-assistant-next.vercel.app/_next/static/chunks/app/page-df46211d11688d2f.js

js sav-assistant-next.vercel.app collected 2026-10-03 07:39:55 UTC 591,644 bytes, 1 lines download raw bytes

1(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[8974],{199:(e,t,n)=>{Promise.resolve().then(n.bind(n,9892))},1150:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),Object.defineProperty(t,"default",{enumerable:!0,get:function(){return a}});let i=n(5155),r=n(2115),l=n(4437);function o(e){return{default:e&&"default"in e?e.default:e}}n(6552);let s={loader:()=>Promise.resolve(o(()=>null)),loading:null,ssr:!0},a=function(e){let t={...s,...e},n=(0,r.lazy)(()=>t.loader().then(o)),a=t.loading;function d(e){let o=a?(0,i.jsx)(a,{isLoading:!0,pastDelay:!0,error:null}):null,s=!t.ssr||!!t.loading,d=s?r.Suspense:r.Fragment,c=t.ssr?(0,i.jsxs)(i.Fragment,{children:[null,(0,i.jsx)(n,{...e})]}):(0,i.jsx)(l.BailoutToCSR,{reason:"next/dynamic",children:(0,i.jsx)(n,{...e})});return(0,i.jsx)(d,{...s?{fallback:o}:{},children:c})}return d.displayName="LoadableComponent",d}},4054:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),!function(e,t){for(var n in t)Object.defineProperty(e,n,{enumerable:!0,get:t[n]})}(t,{bindSnapshot:function(){return o},createAsyncLocalStorage:function(){return l},createSnapshot:function(){return s}});let n=Object.defineProperty(Error("Invariant: AsyncLocalStorage accessed in runtime where it is not available"),"__NEXT_ERROR_CODE",{value:"E504",enumerable:!1,configurable:!0});class i{disable(){throw n}getStore(){}run(){throw n}exit(){throw n}enterWith(){throw n}static bind(e){return e}}let r="undefined"!=typeof globalThis&&globalThis.AsyncLocalStorage;function l(){return r?new r:new i}function o(e){return r?r.bind(e):i.bind(e)}function s(){return r?r.snapshot():function(e,...t){return e(...t)}}},4437:(e,t,n)=>{"use strict";function i(e){let{reason:t,children:n}=e;return n}Object.defineProperty(t,"__esModule",{value:!0}),Object.defineProperty(t,"BailoutToCSR",{enumerable:!0,get:function(){return i}}),n(4553)},6278:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),Object.defineProperty(t,"default",{enumerable:!0,get:function(){return r}});let i=n(8140)._(n(1150));function r(e,t){var n;let r={};"function"==typeof e&&(r.loader=e);let l={...r,...t};return(0,i.default)({...l,modules:null==(n=l.loadableGenerated)?void 0:n.modules})}("function"==typeof t.default||"object"==typeof t.default&&null!==t.default)&&void 0===t.default.__esModule&&(Object.defineProperty(t.default,"__esModule",{value:!0}),Object.assign(t.default,t),e.exports=t.default)},6552:(e,t,n)=>{"use strict";function i(e){let{moduleIds:t}=e;return null}Object.defineProperty(t,"__esModule",{value:!0}),Object.defineProperty(t,"PreloadChunks",{enumerable:!0,get:function(){return i}}),n(5155),n(7650),n(8567),n(7278)},7828:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),Object.defineProperty(t,"workAsyncStorageInstance",{enumerable:!0,get:function(){return i}});let i=(0,n(4054).createAsyncLocalStorage)()},8567:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),Object.defineProperty(t,"workAsyncStorage",{enumerable:!0,get:function(){return i.workAsyncStorageInstance}});let i=n(7828)},9892:(e,t,n)=>{"use strict";n.r(t),n.d(t,{default:()=>n_});var i=n(5155),r=n(2115);let l=async function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n="90bf72b266b57db5941529bb5241cfc5da01f7f651e1ffc3e760f2b8b189d823",i={"Content-Type":"application/json"};n&&(i.Authorization="Bearer ".concat(n));let r=await fetch("/api".concat(e),{headers:i,...t,body:t.body?JSON.stringify(t.body):void 0}),l=await r.text();if(!l){if(!r.ok)throw Error("Erreur serveur ".concat(r.status," (r\xe9ponse vide) — la requ\xeate a peut-\xeatre expir\xe9"));return{}}try{return JSON.parse(l)}catch(e){throw Error("R\xe9ponse inattendue du serveur (".concat(r.status,"): ").concat(l.slice(0,200)))}},o=function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return l("/tickets?".concat(new URLSearchParams(e)))},s=(e,t,n,i,r,o)=>l("/send",{method:"POST",body:{to:e,subject:t,body:n,threadId:i,ticketId:r,gmailId:o}}),a=(e,t,n,i)=>l("/feedback",{method:"POST",body:{ticketId:e,originalDraft:t,editedDraft:n,category:i}}),d=()=>
1l("/notifications/campaigns"),c=function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return l("/returns?".concat(new URLSearchParams(e)))},u=(e,t)=>l("/returns/".concat(encodeURIComponent(e)),{method:"PATCH",body:t}),p=(e,t)=>l("/returns/".concat(encodeURIComponent(e),"/process"),{method:"POST",body:t}),g=(e,t)=>l("/returns/".concat(encodeURIComponent(e),"/offer"),{method:"POST",body:t}),x=function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return l("/returns/".concat(encodeURIComponent(e),"/reship-label"),{method:"POST",body:t})},h=function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return"/api/returns/export?".concat(new URLSearchParams(e))},m=()=>l("/returns/carriers"),f=e=>l("/orders/preparation".concat(e?"?date=".concat(e):"")),y=(e,t)=>l("/expedition/".concat(encodeURIComponent(e),"/generate-label"),{method:"POST",body:t}),b=function(){let e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];return l("/expedition/debug-phones",{method:"POST",body:{apply:e}})},v=(e,t)=>l("/marketing/sequences?id=".concat(encodeURIComponent(e)),{method:"PUT",body:t}),j=()=>l("/marketing/templates"),S=function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return l("/marketing/history?".concat(new URLSearchParams(e)))},k=function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return l("/marketing/orders?".concat(new URLSearchParams(e)))},w=()=>l("/marketing/sync"),C=()=>l("/marketing/sync",{method:"POST"}),_=function(){let e=!(arguments.length>0)||void 0===arguments[0]||arguments[0];return l("/cron/marketing".concat(e?"?dry=1":""))},z=async e=>{try{var t,n;if(!e||!(null==(t=e.type)?void 0:t.startsWith("image/"))||e.size<=1572864)return e;let i=await createImageBitmap(e),r=Math.min(1,1600/Math.max(i.width,i.height)),l=Math.round(i.width*r),o=Math.round(i.height*r),s=document.createElement("canvas");s.width=l,s.height=o,s.getContext("2d").drawImage(i,0,0,l,o),null==(n=i.close)||n.call(i);let a=await new Promise(e=>
1s.toBlob(e,"image/jpeg",.85));if(!a||a.size>=e.size)return e;let d=(e.name||"image").replace(/\.[^.]+$/,"");return new File([a],"".concat(d,".jpg"),{type:"image/jpeg"})}catch(t){return e}},T=async(e,t)=>{let n,i="90bf72b266b57db5941529bb5241cfc5da01f7f651e1ffc3e760f2b8b189d823",r={};i&&(r.Authorization="Bearer ".concat(i));let l=await fetch("/api".concat(e),{method:"POST",headers:r,body:t}),o=await l.text();if(!o){if(!l.ok)throw Error("Erreur serveur ".concat(l.status));return{}}try{n=JSON.parse(o)}catch(e){throw Error("R\xe9ponse inattendue du serveur (".concat(l.status,")"))}if(!l.ok||!1===n.success)throw Error(n.error||"Erreur serveur ".concat(l.status));return n},D=async(e,t)=>{let n=new FormData;return n.append("file",await z(e)),t&&n.append("slot",t),T("/studio/upload",n)},R=async(e,t,n)=>{let i=new FormData;return i.append("file",await z(e)),i.append("kind",t||"mood"),n&&i.append("label",n),T("/studio/refs",i)},I=e=>l("/studio/generate",{method:"POST",body:e}),M=(e,t)=>l("/studio/retouch",{method:"POST",body:{generationId:e,instruction:t}}),W=function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:60,t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},i=new URLSearchParams({limit:String(e),offset:String(t)});return n.shotType&&"all"!==n.shotType&&i.set("shotType",n.shotType),n.kind&&"all"!==n.kind&&i.set("kind",n.kind),l("/studio/generations?".concat(i.toString()))},q=e=>l("/studio/settings",{method:"PUT",body:e}),L=e=>l("/studio/shopify/products?q=".concat(encodeURIComponent(e))),A=e=>l("/studio/catalog/process-product",{method:"POST",body:e}),F=function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return l("/prospection/prospects?".concat(new URLSearchParams(e)))},E=(e,t)=>l("/prospection/prospects?id=".concat(encodeURIComponent(e)),{method:"PUT",body:t}),B=e=>l("/prospection/events?id=".concat(encodeURIComponent(e))),P=function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return l("/prospection/enrich",{method:"POST",body:e})},O=(e,t,n)=>l("/prospection/sequence",{method:"POST",body:{action:e,id:t,step:n}}),U=function(){let e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];return l("/prospection/run".concat(e?"?dry=1":""),{method:"POST",body:{}})},N={brand:{name:"Sudist",tone:"Chaleureux, professionnel, proven\xe7al. Tutoiement interdit.",signature:"L'\xe9quipe Sudist\nMarque textile proven\xe7ale\nhttps://sudist.fr",contact:"[email protected]"},chat:{enabled:!0},shipping:{carriers:[{name:"DPD",trackingUrl:"http://www.dpd.fr/tracex_{tracking}",delayDays:"3-5 jours ouvr\xe9s"},{name:"Mondial Relay",trackingUrl:"https://www.mondialrelay.fr/suivi-de-colis?numeroExpedition={tracking}",delayDays:"4-7 jours ouvr\xe9s"}],freeShippingThreshold:"60€",shippingCost:"4.90€"},returns:{carrier:"colissimo",portalUrl:"https://sudist.fr/retours",delayDays:30,eligibilityDays:15,conditions:"Produit non port\xe9, non lav\xe9, avec \xe9tiquettes. Sous-v\xeatements et maillots exclus.",refundDelay:"5-7 jours ouvr\xe9s apr\xe8s r\xe9ception",exchangePolicy:"Via le portail retour uniquement : https://sudist.fr/retours",exchangeShippingTitle:"DPD Predict",creditBonusPercent:10,nonReturnableOrderTags:["non_returnable"],nonReturnableProductTags:["non_returnable"],overrideOrders:[],photoRequiredReasons:["defectueux","ne_correspond_pas"],maxPhotos:3,maxPhotoSizeMB:5,returnFeeEnabled:!1,returnFeeAmount:5,rejectDiscountDefaultPercent:30,offerExpiryDays:14},boutiques:{listUrl:"https://sudist.fr/pages/boutiques",stores:[{name:"Printemps Toulon",city:"Toulon",status:"ouvert"},{name:"Printemps La Valentine",city:"Marseille",status:"ouvert"},{name:"Sudist Salon de Provence",city:"Salon-de-Provence",status:"ouverture mai 2025"}]},defaultReturnCarrier:"colissimo",expedition:{carrier:"colissimo",dpdService:"predict",productCode:"DOM",defaultWeightKg:.25,fulfillOnGenerate:!0,notifyCustomerDefault:!0,includeSlipDefault:!0},marketing:{enabled:!1,dryRun:!0,frequencyCapDays:21,dailySendCap:40,syncPagesPerRun:4,aiCallsPerRun:250,attributionWindowDays:7,logoUrl:"",promoCode:"AIOLI"},prospection:{enabled:!1,mode:"draft",dailySendCap:15,stepDelays:[0,5,7],fromName:"L'\xe9quipe Sudist",logoUrl:"",heroImageUrl:"https://cdn.shopify.com/s/files/1/0034/3123/5651/files/t-shirt-atelier.jpg?v=1679765712",atelierImageUrl:"https://cdn.shopify.com/s/files/1/0034/3123/5651/files/atelier-sudist_12cdf60d-8b19-4de1-b9f8-c67c3c7bff6c.jpg?v=1679770024",customTeeImageUrl:"https://cdn.shopify.com/s/files/1/0034/3123/5651/files/21f470aa-fa42-40c5-afd1-02a275c06fdd_1782797221409_0c62246f-75e3-4290-b4bb-d1e4de6dbbd4.jpg?v=1785673540",bestSellers:[{title:"T-Shirt Cigale tricolore",tagline:"La cigale bleu-blanc-rouge brod\xe9e sur le cœur : l'esprit du Sud et la fiert\xe9 fran\xe7aise.",price:"39 €",imageUrl:"https://cdn.shopify.com/s/files/1/0034/3123/5651/files/DSC04459.jpg?v=1785673717",url:"https://sudist.fr/products/t-shirt-cigale-tr
1icolore"},{title:"T-Shirt Expressions Proven\xe7ales",tagline:"Les expressions du Sud imprim\xe9es dans le dos : la Provence a son propre vocabulaire.",price:"49 €",imageUrl:"https://cdn.shopify.com/s/files/1/0034/3123/5651/files/expHD.jpg?v=1785673606",url:"https://sudist.fr/products/t-shirt-expressions-provencales"},{title:"Casquette Cigale",tagline:"Cigale brod\xe9e, visi\xe8re incurv\xe9e, r\xe9glage snapback : l'arme anti-cagnard du Sud.",price:"45 €",imageUrl:"https://cdn.shopify.com/s/files/1/0034/3123/5651/files/DSC01444_copie.jpg?v=1785673360",url:"https://sudist.fr/products/casquette-cigale"},{title:"T-Shirt Iced Pastis Club",tagline:"Bienvenue au club, imprim\xe9 dans le dos. Pour les amateurs de jaune bien frais.",price:"49 €",imageUrl:"https://cdn.shopify.com/s/files/1/0034/3123/5651/files/DSC08200.jpg?v=1785674637",url:"https://sudist.fr/products/t-shirt-iced-pastis"},{title:"Basket Cigale",tagline:"Tige en cuir, semelle en caoutchouc naturel, cigale brod\xe9e : la basket con\xe7ue en Provence.",price:"159 €",imageUrl:"https://cdn.shopify.com/s/files/1/0034/3123/5651/files/afd86697-8f9a-4534-a3fe-25557f5138e6_1785404391431.webp?v=1785674450",url:"https://sudist.fr/products/basket-cigale"},{title:"T-Shirt South of France",tagline:"Le Sud \xe9crit en anglais, imprim\xe9 dans le dos. Celui que le monde entier appelle le South of France.",price:"49 €",imageUrl:"https://cdn.shopify.com/s/files/1/0034/3123/5651/files/aa31e190-db9c-4e32-adee-b9d25289fc6c_1788424869938.webp?v=1788453793",url:"https://sudist.fr/products/t-shirt-south-of-france"}],cities:["Toulon","Marseille","Aix-en-Provence","Cassis","Sanary-sur-Mer","Bandol","Saint-Tropez","Avignon","Nice"],placesQueries:["boutique souvenirs","concept store","boutique cadeaux cr\xe9ateurs"],blacklistBrands:["natif","le petit fran\xe7ais"],cityAssets:{toulon:{products:"notre t-shirt Pilou Pilou et nos Expressions Proven\xe7ales tournent tr\xe8s bien dans le Var",press:"\xab Sudist, une marque pour raconter Toulon \xbb (Var Matin)"},marseille:{products:"notre t-shirt Marseille et le mod\xe8le \xc0 jamais les premiers sont nos meilleures ventes sur la ville",press:"\xab La marque proven\xe7ale \xe9coresponsable qui produit ses cr\xe9ations \xe0 Saint-Cannat \xbb (La Provence)"},default:{products:"nos t-shirts Cigale et Expressions Proven\xe7ales sont nos meilleures ventes en boutique",press:"\xab Face au fast fashion, l'atelier Sudist mise sur la durabilit\xe9 \xbb (TF1, Journal de 13h)"}},segmentAssets:{deco:{products:"au-del\xe0 du textile, nos affiches du Sud, nos tote bags et nos accessoires Cigale (stickers, porte-cl\xe9s) trouvent naturellement leur place dans un univers de d\xe9coration",bestSellers:[{title:"Affiche Provence",tagline:"La Provence illustr\xe9e, tirage d'art sur papier \xe9pais. Une illustration originale Sudist, en 50 x 70 cm.",price:"29,90 €",imageUrl:"https://cdn.shopify.com/s/files/1/0034/3123/5651/files/affichescopie_d5f7301c-0be5-4f14-b25f-787b8aa21ba1.jpg?v=1785673695",url:"https://sudist.fr/products/affiche-provence"},{title:"Affiche Pastis",tagline:"L'ap\xe9ritif du Sud aux teintes Pantone, en 30 x 40 cm. Le petit format qui part vite en caisse.",price:"19,90 €",imageUrl:"https://cdn.shopify.com/s/files/1/0034/3123/5651/files/PASTIS.jpg?v=1785674035",url:"https://sudist.fr/products/affiche-pastis"},{title:"T-Shirt Cigale",tagline:"Notre embl\xe8me brod\xe9 sur le cœur : la pi\xe8ce signature de l'atelier, celle que l'on offre et que l'on garde.",price:"39 €",imageUrl:"https://cdn.shopify.com/s/files/1/0034/3123/5651/files/DSC05009copie.jpg?v=1785674366",url:"https://sudist.fr/products/t-shirt-cigale"}]},epicerie_fine:{products:"nos tote bags, nos accessoires Cigale et nos t-shirts {{ville}} accompagnent tr\xe8s bien un univers de produits du terroir"}}},warehouse:{companyName:"SUDIST",line2:"6 rue concert",city:"Salon-de-Provence",zipCode:"13300",countryCode:"FR"},product:{materials:"100% coton 220g (vs 150-180g pour les t-shirts bas de gamme). OEKO-TEX Standard 100.",manufacturing:"Grande partie produite dans notre atelier en France. Une partie sous-trait\xe9e dans notre atelier partenaire au Portugal, avec les m\xeames standards de qualit\xe9.",sizing:"Coupe unisexe, taille normalement. Guide des tailles disponible sur chaque page produit.",restock:"Pour \xeatre alert\xe9 d'un r\xe9assort : s\xe9lectionner le produit en rupture sur le site, une alerte stock est disponible sur la page produit."},responses:[{id:"r1",category:"livraison",trigger:"Colis en transit +7j DPD / +10j Mondial Relay",instruction:"Rassurer, fournir lien suivi. Si d\xe9pass\xe9: escalade vers [email protected]."},{id:"r2",category:"retour",trigger:"Demande de retour ou d'\xe9change",instruction:"Diriger vers https://sudist.fr/retours. D\xe9lai 30j. Produit non port\xe9, non lav\xe9, \xe9tiquettes. Sous-v\xeatements et maillots exclus."},{id:"r3",category:"retour",trigger:"Mauvais article re\xe7u ou article d\xe9fectueux",instruction:"Diriger vers le portail retour https://sudist.fr/retours pour initier la proc\xe9dure."},{id:"r4",category:"livraison",trigger:"Modification d'adresse",instruction:"Non exp\xe9di\xe9: contacter [email protected]. Exp\xe9di\xe9: redirection via transporteur, contacter [email protected]."},{id:"r5",category:"livraison",trigger:"Annulation de commande",instruction:"Non exp\xe9di\xe9e: contacter [email protected] rapidement. Exp\xe9di\xe9e: impossible, utiliser le portail retour apr\xe8s r\xe9ception."},{id:"r6",category:"livraison",trigger:"Colis perdu ou commande incompl\xe8te",instruction:"Escalade vers [email protected] uniquement."},{id:"r7",category:"pre_achat",trigger:"Questions tailles",instruction:"Coupe unisexe, taille normalement. Guide des tailles sur chaque page produit."},{id:"r8",category:"pre_achat",trigger:"Questions mati\xe8res ou fabrication",instruction:"100% coton 220g, OEKO-TEX Standard 100. Production en atelier France + atelier partenaire Portugal avec m\xeames standards."},{id:"r9",category:"pre_achat",trigger:"Rupture de stock",instruction:"S\xe9lectionner le produit sur le site, une alerte stock est disponible sur la page produit."},{id:"r10",category:"autre",trigger:"Tout autre sujet (paiement, facture, B2B, entretien, international, code promo, etc.)",instruction:"Rediriger vers [email protected]. Ne pas improviser de r\xe9ponse."},{id:"r11",category:"autre",trigger:"Questions boutiques physiques, points de vente, revendeurs",instruction:"Mentionner Printemps Toulon, Printemps La Valentine (Marseille), Sudist Salon-de-Provence (ouverture mai 2025). Liste compl\xe8te : https://sudist.fr/pages/boutiques"}]},H={livraison:{label:"Suivi livraison",color:"#2563eb",bg:"#eff6ff",icon:"\uD83D\uDCE6"},retour:{label:"Retour / \xc9change",color:"#d97706",bg:"#fffbeb",icon:"\uD83D\uDD04"},reclamation:{label:"R\xe9clamation",color:"#dc2626",bg:"#fef2f2",icon:"⚠️"},pre_achat:{label:"Pr\xe9-achat",color:"#059669",bg:"#ecfdf5",icon:"\uD83D\uDCAC"},autre:{label:"Autre",color:"#6b7280",bg:"#f9fafb",icon:"\uD83D\uDCCB"},spam:{label:"Spam",color:"#9ca3af",bg:"#f3f4f6",icon:"\uD83D\uDEAB"},hors_sujet:{label:"Hors sujet",color:"#9ca3af",bg:"#f3f4f6",icon:"\uD83D\uDCED"}};function V(e){var t,n;let i=e||N,r=i.shipping.carriers.map(e=>"- ".concat(e.name,": ").concat(e.delayDays,", suivi: ").concat(e.trackingUrl)).join("\n"),l=i.responses.map(e=>"- [".concat(e.category.toUpperCase(),'] "').concat(e.trigger,'" → ').concat(e.instruction)).join("\n"),o=((null==(t=i.boutiques)?void 0:t.stores)||[]).map(e=>"  - ".concat(e.name," (").concat(e.city,")").concat("ouvert"!==e.status?" — ".concat(e.status):"")).join("\n");return"Tu es l'assistant SAV de ".concat(i.brand.name,", marque textile proven\xe7ale.\nTONALIT\xc9: ").concat(i.brand.tone,"\nSIGNATURE:\n").concat(i.brand.signature,"\n══ LIVRAISON ══\n").concat(r,"\nGratuit d\xe8s ").concat(i.shipping.freeShippingThreshold,", sinon ").concat(i.shipping.shippingCost,".\n══ RETOURS & \xc9CHANGES ══\nPortail d\xe9di\xe9: ").concat(i.returns.portalUrl," | D\xe9lai: ").concat(i.returns.delayDays,"j | ").concat(i.returns.conditions,"\nRemboursement: ").concat(i.returns.refundDelay," | \xc9change: ").concat(i.returns.exchangePolicy,"\n══ BOUTIQUES PHYSIQUES ══\n").concat(o,"\nListe compl\xe8te: ").concat((null==(n=i.boutiques)?void 0:n.listUrl)||"https://sudist.fr/pages/boutiques","\n══ R\xc8GLES ══\n").concat(l,'\n══ FORMAT ══\nJSON valide uniquement: {"category":"livraison|retour|reclamation|pre_achat|autre|spam|hors_sujet","urgency":"low|medium|high","summary":"...","order_number":"SUD-XXXXX ou null","key_info":[...],"suggested_action":"...","draft_response":"..."}\nSi l\'email est une newsletter, publicit\xe9, notification automatique ou spam manifeste → category:"spam", draft_response vide.\nSi l\'email est hors p\xe9rim\xe8tre SAV (candidature, partenariat, presse, fournisseur, facture) → category:"hors_sujet", draft_response vide.')}let G="'Manrope', -apple-system, BlinkMacSystemFont, 'Segoe UI Variable', 'Segoe UI', system-ui, sans-serif",K="'Geist Mono', ui-monospace, 'JetBrains Mono', 'SF Mono', monospace",Y={bg:"#f6f7f9",surface:"#ffffff",surfaceAlt:"#f0f2f5",border:"#e2e4e8",borderLight:"#eef0f3",text:"#191b1f",textMuted:"#696d74",textDim:"#9a9ea6",accent:"#191b1f",accentMuted:"#3d4045",accentBg:"rgba(25,27,31,0.05)",gold:"#b08540",goldMuted:"#8a6a30",goldBg:"rgba(176,133,64,0.10)",green:"#1f9a5e",blue:"#2f80c0",red:"#d33e3a",orange:"#e08a3c",purple:"#7c5cf0",greenSoft:"#e3f5ea",blueSoft:"#e4f0fa",redSoft:"#fbe9e7",orangeSoft:"#fdeedd",nav:"#f1f2f5",navSoft:"#e8eaee",navLine:"#dcdfe4",navInk:"#3d4045",navInkStrong:"#141518",shadow:"rgba(20,21,24,0.14)",shadowLight:"rgba(20,21,24,0.06)"},J={bg:"#161718",surface:"#1f2022",surfaceAlt:"#26272a",border:"#303236",borderLight:"#26272a",text:"#f4f5f7",textMuted:"#878b93",textDim:"#61656d",accent:"#f4f5f7",accentMuted:"#c6c8cd",accentBg:"rgba(244,245,247,0.06)",gold:"#c8a46e",goldMuted:"#9a7a4e",goldBg:"rgba(200,164,110,0.10)",green:"#4fce86",blue:"#63a9e8",red:"#f0625b",orange:"#f0a45a",purple:"#a78bfa",greenSoft:"#1f3f2c",blueSoft:"#1f3a52",redSoft:"#4a2523",orangeSoft:"#4a3320",nav:"#121314",navSoft:"#1f2022",navLine:"#2b2d30",navInk:"#a9adb4",n
1avInkStrong:"#f8f9fb",shadow:"rgba(0,0,0,0.5)",shadowLight:"rgba(0,0,0,0.25)"},X="cubic-bezier(0.16, 1, 0.3, 1)",Q={xs:4,sm:8,md:12,lg:16,xl:20,xxl:24,xxxl:32},$={sm:6,md:10,lg:14,xl:18,pill:999},Z=function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:J;return{width:"100%",padding:"9px 12px",borderRadius:$.md,border:"1px solid ".concat(e.border),background:e.surface,color:e.text,fontSize:13,fontFamily:G,outline:"none",boxSizing:"border-box",transition:"border-color 160ms ".concat(X,", box-shadow 160ms ").concat(X)}},ee=function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:J;return{...Z(e),minHeight:64,resize:"vertical",lineHeight:1.55}},et=function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:J;return{fontSize:11,color:e.textMuted,textTransform:"uppercase",letterSpacing:"0.14em",fontWeight:500,marginBottom:6,display:"block"}},en=function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:J;return{fontFamily:K,fontSize:11,textTransform:"uppercase",letterSpacing:"0.12em",color:e.textMuted}},ei=function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:J;return{padding:"7px 14px",borderRadius:$.pill,border:e?"1px solid ".concat(t.text):"1px solid ".concat(t.border),background:e?t.text:t.surface,color:e?t.bg:t.text,fontSize:12.5,fontWeight:500,cursor:"pointer",fontFamily:G,transition:"background-color 160ms ".concat(X,", border-color 160ms ").concat(X,", color 160ms ").concat(X,", transform 120ms ").concat(X),display:"inline-flex",alignItems:"center",gap:6,letterSpacing:"0.005em",lineHeight:1.25}},er=function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:J;return{padding:Q.xl,borderRadius:$.xl,background:e.surface,border:"1px solid ".concat(e.border)}},el=function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:J;return{display:"flex",alignItems:"center",gap:12,padding:"10px 12px",borderRadius:$.lg,border:"none",background:e?t.navSoft||t.surfaceAlt:"transparent",color:e?t.navInkStrong||t.text:t.navInk||t.textMuted,fontSize:14,fontWeight:500,cursor:"pointer",transition:"background-color 160ms ".concat(X,", color 160ms ").concat(X),width:"100%",textAlign:"left",fontFamily:G}},eo=function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:J;return{padding:"6px 12px",borderRadius:$.pill,border:"1px solid ".concat(e?t.text:t.border),background:e?t.text:t.surface,color:e?t.bg:t.text,fontSize:12.5,fontWeight:500,cursor:"pointer",whiteSpace:"nowrap",transition:"background-color 160ms ".concat(X,", border-color 160ms ").concat(X,", color 160ms ").concat(X),fontFamily:G,lineHeight:1.25}},es=function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:J,n={neutral:{bg:t.borderLight,fg:t.text},ink:{bg:t.text,fg:t.bg},signal:{bg:t.redSoft||"".concat(t.red,"1f"),fg:t.red},warning:{bg:t.orangeSoft||"".concat(t.orange,"1f"),fg:t.orange},success:{bg:t.greenSoft||"".concat(t.green,"1f"),fg:t.green},info:{bg:t.blueSoft||"".concat(t.blue,"1f"),fg:t.blue},muted:{bg:t.borderLight,fg:t.textMuted},gold:{bg:t.goldBg,fg:t.gold}},i=n[e]||n.neutral;return{display:"inline-flex",alignItems:"center",gap:5,height:22,padding:"0 8px",borderRadius:$.sm,fontSize:11,fontWeight:500,textTransform:"uppercase",letterSpacing:"0.06em",whiteSpace:"nowrap",background:i.bg,color:i.fg,fontFamily:G,lineHeight:1}};function ea(e){let{status:t,t:n=J}=e,r={processing:{l:"En pr\xe9paration",tone:"info"},preparing:{l:"Pr\xe9paration (trait\xe9e)",tone:"info"},unfulfilled:{l:"Non trait\xe9",tone:"warning"},label_created:{l:"\xc9tiquette cr\xe9\xe9e",tone:"warning"},ready_for_pickup:{l:"Pr\xeat \xe0 retirer",tone:"info"},in_transit:{l:"En transit",tone:"info"},out_for_delivery:{l:"En livraison",tone:"info"},attempted_delivery:{l:"Tentative \xe9chou\xe9e",tone:"signal"},delivered:{l:"Livr\xe9",tone:"success"},fulfilled:{l:"Exp\xe9di\xe9",tone:"success"},failure:{l:"\xc9chec livraison",tone:"signal"}}[t]||{l:t||"Inconnu",tone:"muted"};return(0,i.jsx)("span",{style:es(r.tone,n),children:r.l})}function ed(e){let{level:t,t:n=J}=e,r={low:n.green,medium:n.orange,high:n.red}[t]||n.green;return(0,i.jsx)("span",{style:{display:"inline-block",width:7,height:7,borderRadius:"50%",background:r,marginRight:6}})}function ec(e){let{tier:t,t:n=J}
1=e,r={new:{l:"Nouveau",tone:"info"},standard:{l:"Standard",tone:"muted"},vip:{l:"VIP",tone:"gold"},whale:{l:"Top client",tone:"ink"}},l=r[t]||r.standard;return(0,i.jsx)("span",{style:es(l.tone,n),children:l.l})}function eu(e){let{label:t,value:n,sub:r,color:l,t:o=J}=e;return(0,i.jsxs)("div",{style:{padding:"".concat(Q.lg,"px ").concat(Q.xl,"px"),borderRadius:$.xl,background:o.surface,border:"1px solid ".concat(o.border),display:"flex",flexDirection:"column",gap:6},children:[(0,i.jsx)("div",{style:en(o),children:t}),(0,i.jsx)("div",{style:{fontSize:"clamp(22px, 4vw, 28px)",fontWeight:600,color:l||o.text,lineHeight:1.05,fontFamily:K,fontVariantNumeric:"tabular-nums",letterSpacing:"-0.02em"},children:n}),r&&(0,i.jsx)("div",{style:{fontSize:12,color:o.textMuted,lineHeight:1.4},children:r})]})}function ep(e){let{name:t,size:n=32,t:r=J}=e,l=(t||"?").split(/[\s@]+/).filter(Boolean).slice(0,2).map(e=>{var t;return null==(t=e[0])?void 0:t.toUpperCase()}).join("");return(0,i.jsx)("div",{style:{width:n,height:n,borderRadius:"50%",background:r.text,color:r.bg,display:"flex",alignItems:"center",justifyContent:"center",fontSize:Math.max(11,Math.round(.36*n)),fontWeight:500,flexShrink:0,fontFamily:G,userSelect:"none"},children:l})}function eg(e){let{icon:t,title:n,description:r,t:l=J}=e,o="string"!=typeof t;return(0,i.jsxs)("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",height:"100%",padding:48,textAlign:"center",gap:Q.sm},children:[t&&(0,i.jsx)("div",{style:{marginBottom:Q.sm,color:l.textMuted,opacity:.7},children:o?t:(0,i.jsx)("span",{style:{fontSize:32},children:t})}),n&&(0,i.jsx)("div",{style:{fontSize:17,fontWeight:600,color:l.text,letterSpacing:"-0.01em",fontFamily:G},children:n}),r&&(0,i.jsx)("div",{style:{fontSize:13,color:l.textMuted,lineHeight:1.55,maxWidth:320},children:r})]})}let ex={home:e=>{let{size:t=18,color:n}=e;return(0,i.jsxs)("svg",{width:t,height:t,viewBox:"0 0 24 24",fill:"none",stroke:n||"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,i.jsx)("path",{d:"M3 9l9-7 9 7v11a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2z"}),(0,i.jsx)("polyline",{points:"9 22 9 12 15 12 15 22"})]})},inbox:e=>{let{size:t=18,color:n}=e;return(0,i.jsxs)("svg",{width:t,height:t,viewBox:"0 0 24 24",fill:"none",stroke:n||"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,i.jsx)("polyline",{points:"22 12 16 12 14 15 10 15 8 12 2 12"}),(0,i.jsx)("path",{d:"M5.45 5.11L2 12v6a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2v-6l-3.45-6.89A2 2 0 0 0 16.76 4H7.24a2 2 0 0 0-1.79 1.11z"})]})},chat:e=>{let{size:t=18,color:n}=e;return(0,i.jsx)("svg",{width:t,height:t,viewBox:"0 0 24 24",fill:"none",stroke:n||"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round",children:(0,i.jsx)("path",{d:"M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z"})})},dashboard:e=>{let{size:t=18,color:n}=e;return(0,i.jsxs)("svg",{width:t,height:t,viewBox:"0 0 24 24",fill:"none",stroke:n||"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,i.jsx)("rect",{x:"3",y:"3",width:"7",height:"7",rx:"1"}),(0,i.jsx)("rect",{x:"14",y:"3",width:"7",height:"7",rx:"1"}),(0,i.jsx)("rect",{x:"3",y:"14",width:"7",height:"7",rx:"1"}),(0,i.jsx)("rect",{x:"14",y:"14",width:"7",height:"7",rx:"1"})]})},proactive:e=>{let{size:t=18,color:n}=e;return(0,i.jsxs)("svg",{width:t,height:t,viewBox:"0 0 24 24",fill:"none",stroke:n||"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,i.jsx)("path",{d:"M18 8A6 6 0 0 0 6 8c0 7-3 9-3 9h18s-3-2-3-9"}),(0,i.jsx)("path",{d:"M13.73 21a2 2 0 0 1-3.46 0"})]})},config:e=>{let{size:t=18,color:n}=e;return(0,i.jsxs)("svg",{width:t,height:t,viewBox:"0 0 24 24",fill:"none",stroke:n||"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,i.jsx)("circle",{cx:"12",cy:"12",r:"3"}),(0,i.jsx)("path",{d:"M19.4 15a1.65 1.65 0 0 0 .33 1.82l.06.06a2 2 0 0 1 0 2.83 2 2 0 0 1-2.83 0l-.06-.06a1.65 1.65 0 0 0-1.82-.33 1.65 1.65 0 0 0-1 1.51V21a2 2 0 0 1-2 2 2 2 0 0 1-2-2v-.09A1.65 1.65 0 0 0 9 19.4a1.65 1.65 0 0 0-1.82.33l-.06.06a2 2 0 0 1-2.83 0 2 2 
10 0 1 0-2.83l.06-.06A1.65 1.65 0 0 0 4.68 15a1.65 1.65 0 0 0-1.51-1H3a2 2 0 0 1-2-2 2 2 0 0 1 2-2h.09A1.65 1.65 0 0 0 4.6 9a1.65 1.65 0 0 0-.33-1.82l-.06-.06a2 2 0 0 1 0-2.83 2 2 0 0 1 2.83 0l.06.06A1.65 1.65 0 0 0 9 4.68a1.65 1.65 0 0 0 1-1.51V3a2 2 0 0 1 2-2 2 2 0 0 1 2 2v.09a1.65 1.65 0 0 0 1 1.51 1.65 1.65 0 0 0 1.82-.33l.06-.06a2 2 0 0 1 2.83 0 2 2 0 0 1 0 2.83l-.06.06a1.65 1.65 0 0 0-.33 1.82V9a1.65 1.65 0 0 0 1.51 1H21a2 2 0 0 1 2 2 2 2 0 0 1-2 2h-.09a1.65 1.65 0 0 0-1.51 1z"})]})},sun:e=>{let{size:t=18,color:n}=e;return(0,i.jsxs)("svg",{width:t,height:t,viewBox:"0 0 24 24",fill:"none",stroke:n||"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,i.jsx)("circle",{cx:"12",cy:"12",r:"5"}),(0,i.jsx)("line",{x1:"12",y1:"1",x2:"12",y2:"3"}),(0,i.jsx)("line",{x1:"12",y1:"21",x2:"12",y2:"23"}),(0,i.jsx)("line",{x1:"4.22",y1:"4.22",x2:"5.64",y2:"5.64"}),(0,i.jsx)("line",{x1:"18.36",y1:"18.36",x2:"19.78",y2:"19.78"}),(0,i.jsx)("line",{x1:"1",y1:"12",x2:"3",y2:"12"}),(0,i.jsx)("line",{x1:"21",y1:"12",x2:"23",y2:"12"}),(0,i.jsx)("line",{x1:"4.22",y1:"19.78",x2:"5.64",y2:"18.36"}),(0,i.jsx)("line",{x1:"18.36",y1:"5.64",x2:"19.78",y2:"4.22"})]})},moon:e=>{let{size:t=18,color:n}=e;return(0,i.jsx)("svg",{width:t,height:t,viewBox:"0 0 24 24",fill:"none",stroke:n||"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round",children:(0,i.jsx)("path",{d:"M21 12.79A9 9 0 1 1 11.21 3 7 7 0 0 0 21 12.79z"})})},refresh:e=>{let{size:t=18,color:n}=e;return(0,i.jsxs)("svg",{width:t,height:t,viewBox:"0 0 24 24",fill:"none",stroke:n||"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,i.jsx)("polyline",{points:"23 4 23 10 17 10"}),(0,i.jsx)("path",{d:"M20.49 15a9 9 0 1 1-2.12-9.36L23 10"})]})},download:e=>{let{size:t=18,color:n}=e;return(0,i.jsxs)("svg",{width:t,height:t,viewBox:"0 0 24 24",fill:"none",stroke:n||"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,i.jsx)("path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"}),(0,i.jsx)("polyline",{points:"7 10 12 15 17 10"}),(0,i.jsx)("line",{x1:"12",y1:"15",x2:"12",y2:"3"})]})},play:e=>{let{size:t=18,color:n}=e;return(0,i.jsx)("svg",{width:t,height:t,viewBox:"0 0 24 24",fill:"none",stroke:n||"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round",children:(0,i.jsx)("polygon",{points:"5 3 19 12 5 21 5 3"})})},search:e=>{let{size:t=18,color:n}=e;return(0,i.jsxs)("svg",{width:t,height:t,viewBox:"0 0 24 24",fill:"none",stroke:n||"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,i.jsx)("circle",{cx:"11",cy:"11",r:"8"}),(0,i.jsx)("line",{x1:"21",y1:"21",x2:"16.65",y2:"16.65"})]})},menu:e=>{let{size:t=18,color:n}=e;return(0,i.jsxs)("svg",{width:t,height:t,viewBox:"0 0 24 24",fill:"none",stroke:n||"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,i.jsx)("line",{x1:"3",y1:"12",x2:"21",y2:"12"}),(0,i.jsx)("line",{x1:"3",y1:"6",x2:"21",y2:"6"}),(0,i.jsx)("line",{x1:"3",y1:"18",x2:"21",y2:"18"})]})},chevronLeft:e=>{let{size:t=18,color:n}=e;return(0,i.jsx)("svg",{width:t,height:t,viewBox:"0 0 24 24",fill:"none",stroke:n||"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:(0,i.jsx)("polyline",{points:"15 18 9 12 15 6"})})},returns:e=>{let{size:t=18,color:n}=e;return(0,i.jsxs)("svg",{width:t,height:t,viewBox:"0 0 24 24",fill:"none",stroke:n||"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,i.jsx)("polyline",{points:"1 4 1 10 7 10"}),(0,i.jsx)("path",{d:"M3.51 15a9 9 0 1 0 2.13-9.36L1 10"})]})},préparation:e=>{let{size:t=18,color:n}=e;return(0,i.jsxs)("svg",{width:t,height:t,viewBox:"0 0 24 24",fill:"none",stroke:n||"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,i.jsx)("path",{d:"M16 4h2a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2V6a2 2 0 0 1 2-2h2"}),(0,i.jsx)("rect",{x:"8",y:"2",width:"8",height:"4",rx:"1",ry:"1"}),(0,i.jsx)("line",{x1:"9",y1:"12",x2:"11",y2:"14"}),(0,i.jsx)("line",{x1:"11",y1:"14",x2:"15",y2:"10"})]})},b2b:e=>{let{size:t=18,color:n}=e;return(0,i.jsxs)("svg",{width:t,height:t,viewBox:"0 0 24 24",fill:"none",stroke:n||"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,i.jsx)("path",{d:"M17 21v-2a4 4 0 0 0-4-4H5a4 4 0 0 0-4 4v2"}),(0,i.jsx)("circle",{cx:"9",cy:"7",r:"4"}),(0,i.jsx)("path",{d:"M23 21v-2a4 4 0 0 0-3-3.87"}),(0,i.jsx)("path",{d:"M16 3.13a4 4 0 0 1 0 7.75"})]})},expedition:e=>{let{size:t=18,color:n}=e;return(0,i.jsxs)("svg",{width:t,height:t,viewBox:"0 0 24 24",fill:"none",stroke:n||"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,i.jsx)("rect",{x:"1",y:"3",width:"15",height:"13",rx:"1"}),(0,i.jsx)("polygon",{points:"16 8 20 8 23 11 23 16 16 16 16 8"}),(0,i.jsx)("circle",{cx:"5.5",cy:"18.5",r:"2.5"}),(0,i.jsx)("circle",{cx:"18.5",cy:"18.5",r:"2.5"})]})},studio:e=>{let{size:t=18,color:n}=e;return(0,i.jsxs)("svg",{width:t,height:t,viewBox:"0 0 24 24",fill:"none",stroke:n||"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,i.jsx)("path",{d:"M23 19a2 2 0 0 1-2 2H3a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h4l2-3h6l2 3h4a2 2 0 0 1 2 2z"}),(0,i.jsx)("circle",{cx:"12",cy:"13",r:"4"})]})},marketing:e=>{let{size:t=18,color:n}=e;return(0,i.jsx)("svg",{width:t,height:t,viewBox:"0 0 24 24",fill:"none",stroke:n||"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round",children:(0,i.jsx)("path",{d:"M3 11l18-8-8 18-2-8-8-2z"})})},prospection:e=>{let{size:t=18,color:n}=e;return(0,i.jsxs)("svg",{width:t,height:t,viewBox:"0 0 24 24",fill:"none",stroke:n||"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,i.jsx)("circle",{cx:"12",cy:"12",r:"10"}),(0,i.jsx)("circle",{cx:"12",cy:"12",r:"6"}),(0,i.jsx)("circle",{cx:"12",cy:"12",r:"2"})]})}},eh={close:e=>{let{size:t=14,color:n}=e;return(0,i.jsxs)("svg",{width:t,height:t,viewBox:"0 0 24 24",fill:"none",stroke:n||"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,i.jsx)("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),(0,i.jsx)("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})},plus:e=>{let{size:t=14,color:n}=e;return(0,i.jsxs)("svg",{width:t,height:t,viewBox:"0 0 24 24",fill:"none",stroke:n||"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,i.jsx)("line",{x1:"12",y1:"5",x2:"12",y2:"19"}),(0,i.jsx)("line",{x1:"5",y1:"12",x2:"19",y2:"12"})]})},check:e=>{let{size:t=14,color:n}=e;return(0,i.jsx)("svg",{width:t,height:t,viewBox:"0 0 24 24",fill:"none",stroke:n||"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:(0,i.jsx)("polyline",{points:"20 6 9 17 4 12"})})}},em=[{id:"shipping",label:"Livraison"},{id:"brand",label:"Marque"},{id:"responses",label:"R\xe8gles IA"}];function ef(e){var t,n,l,o;let{policies:s,setPolicies:a,onClose:d,onSave:c,t:u=J,fullPage:p=!1}=e,[g,x]=(0,r.useState)("shipping"),[h,m]=(0,r.useState)(!1),[f,y]=(0,r.useState)(!1),[b,v]=(0,r.useState)(!1),[j,S]=(0,r.useState)("desktop");(0,r.useEffect)(()=>{let e=()=>{let e=window.innerWidth;S(e<768?"mobile":e<1024?"tablet":"desktop")};return e(),window.addEventListener("resize",e),()=>window.removeEventListener("resize",e)},[]);let k="mobile"===j,w=(e,t)=>a(n=>({...n,brand:{...n.brand,[e]:t}})),C=(e,t)=>a(n=>({...n,shipping:{...n.shipping,[e]:t}}
1)),_=(e,t,n)=>a(i=>{let r=[...i.shipping.carriers];return r[e]={...r[e],[t]:n},{...i,shipping:{...i.shipping,carriers:r}}}),z=(e,t,n)=>a(i=>{let r=[...i.responses];return r[e]={...r[e],[t]:n},{...i,responses:r}}),T=async()=>{m(!0),await (null==c?void 0:c(s)),m(!1),y(!0),setTimeout(()=>y(!1),2e3)};return(0,i.jsxs)("div",{style:{height:"100%",display:"flex",flexDirection:"column",background:u.bg,fontFamily:G,color:u.text},children:[(0,i.jsx)("div",{style:{flex:1,overflowY:"auto",overflowX:"hidden"},children:(0,i.jsxs)("div",{style:{maxWidth:720,margin:"0 auto",padding:k?"28px 20px 80px":"44px 48px 80px"},children:[(0,i.jsx)("header",{style:{marginBottom:32},children:(0,i.jsxs)("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"flex-start",gap:Q.lg,flexWrap:"wrap"},children:[(0,i.jsxs)("div",{style:{flex:1,minWidth:200},children:[(0,i.jsx)("div",{style:{fontSize:10,color:u.textDim,textTransform:"uppercase",letterSpacing:"0.18em",fontWeight:600,marginBottom:12},children:"Politiques \xb7 IA \xb7 Marque"}),(0,i.jsx)("h1",{style:{fontSize:"clamp(32px, 6vw, 46px)",fontFamily:G,fontWeight:600,color:u.text,letterSpacing:"-0.015em",lineHeight:1,margin:0},children:"Param\xe8tres."})]}),(0,i.jsxs)("div",{style:{display:"flex",gap:Q.sm,alignItems:"center",flexShrink:0},children:[(0,i.jsxs)("button",{onClick:T,disabled:h,"aria-label":"Enregistrer les param\xe8tres",style:{padding:"10px 18px",minHeight:40,borderRadius:$.md,border:"none",background:f?u.green:u.text,color:u.bg,fontSize:12,fontWeight:600,cursor:"pointer",fontFamily:G,display:"inline-flex",alignItems:"center",gap:6,opacity:h?.5:1,transition:"background 0.2s ease"},children:[f&&(0,i.jsx)(eh.check,{size:13,color:u.bg}),h?"Sauvegarde…":f?"Enregistr\xe9":"Enregistrer"]}),d&&!p&&(0,i.jsx)("button",{onClick:d,"aria-label":"Fermer",style:{width:38,height:38,borderRadius:$.md,border:"1px solid ".concat(u.border),background:"transparent",color:u.textMuted,cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center"},children:(0,i.jsx)(eh.close,{size:14,color:"currentColor"})})]})]})}),(0,i.jsx)("div",{className:"kb-tab-row",style:{display:"flex",gap:Q.xxl,marginBottom:28,paddingBottom:14,borderBottom:"1px solid ".concat(u.border),overflowX:"auto",overflowY:"hidden",WebkitOverflowScrolling:"touch",scrollbarWidth:"none"},children:em.map(e=>(0,i.jsxs)("button",{onClick:()=>x(e.id),"aria-pressed":g===e.id,style:{background:"transparent",border:"none",cursor:"pointer",padding:0,fontFamily:G,fontSize:11,fontWeight:700,textTransform:"uppercase",letterSpacing:"0.16em",color:g===e.id?u.text:u.textMuted,position:"relative",minHeight:32,whiteSpace:"nowrap",transition:"color 0.2s ease"},children:[e.label,g===e.id&&(0,i.jsx)("span",{style:{position:"absolute",bottom:-15,left:0,right:0,height:2,background:u.text}})]},e.id))}),"shipping"===g&&(0,i.jsxs)("div",{style:{display:"flex",flexDirection:"column",gap:36},children:[(0,i.jsx)(ey,{title:"Seuils",t:u,children:(0,i.jsxs)("div",{style:{display:"grid",gridTemplateColumns:k?"1fr":"1fr 1fr",gap:Q.md},children:[(0,i.jsx)(eb,{label:"Livraison gratuite d\xe8s",t:u,children:(0,i.jsx)("input",{value:s.shipping.freeShippingThreshold,onChange:e=>C("freeShippingThreshold",e.target.value),style:Z(u)})}),(0,i.jsx)(eb,{label:"Frais de port",t:u,children:(0,i.jsx)("input",{value:s.shipping.shippingCost,onChange:e=>C("shippingCost",e.target.value),style:Z(u)})})]})}),(0,i.jsx)(ey,{title:"Transporteurs",count:s.shipping.carriers.length,t:u,children:(0,i.jsxs)("div",{style:{display:"flex",flexDirection:"column",gap:Q.lg},children:[s.shipping.carriers.map((e,t)=>(0,i.jsxs)("div",{style:{padding:"".concat(Q.md,"px 0"),borderBottom:"1px solid ".concat(u.border),display:"flex",flexDirection:"column",gap:Q.md},children:[(0,i.jsxs)("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center"},children:[(0,i.jsx)("span",{style:{fontSize:13,fontWeight:600,color:u.text,letterSpacing:"-0.01em"},children:e.name||"Transporteur ".concat(t+1)}),(0,i.jsx)("button",{onClick:()=>a(e=>({...e,shipping:{...e.shipping,carriers:e.shipping.carriers.filter((e,n
1)=>n!==t)}})),"aria-label":"Supprimer ce transporteur",style:{width:32,height:32,padding:0,borderRadius:$.md,border:"none",background:"transparent",color:u.textMuted,cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center",transition:"color 0.15s ease, background 0.15s ease"},onMouseEnter:e=>{e.currentTarget.style.color=u.red,e.currentTarget.style.background="".concat(u.red,"10")},onMouseLeave:e=>{e.currentTarget.style.color=u.textMuted,e.currentTarget.style.background="transparent"},children:(0,i.jsx)(eh.close,{size:13,color:"currentColor"})})]}),(0,i.jsxs)("div",{style:{display:"flex",flexDirection:"column",gap:Q.sm},children:[(0,i.jsx)(eb,{label:"Nom",t:u,children:(0,i.jsx)("input",{value:e.name,onChange:e=>_(t,"name",e.target.value),style:Z(u)})}),(0,i.jsx)(eb,{label:"URL de suivi",hint:"Utilise {tracking} pour le num\xe9ro",t:u,children:(0,i.jsx)("input",{value:e.trackingUrl,onChange:e=>_(t,"trackingUrl",e.target.value),style:Z(u)})}),(0,i.jsx)(eb,{label:"D\xe9lai indicatif",t:u,children:(0,i.jsx)("input",{value:e.delayDays,onChange:e=>_(t,"delayDays",e.target.value),style:Z(u)})})]})]},t)),(0,i.jsxs)("button",{onClick:()=>a(e=>({...e,shipping:{...e.shipping,carriers:[...e.shipping.carriers,{name:"",trackingUrl:"",delayDays:""}]}})),style:{padding:"12px 16px",minHeight:44,borderRadius:$.md,border:"1px dashed ".concat(u.border),background:"transparent",color:u.textMuted,fontSize:12,fontWeight:600,cursor:"pointer",fontFamily:G,display:"inline-flex",alignItems:"center",justifyContent:"center",gap:6,transition:"border-color 0.18s ease, color 0.18s ease"},onMouseEnter:e=>{e.currentTarget.style.color=u.text,e.currentTarget.style.borderColor=u.textMuted},onMouseLeave:e=>{e.currentTarget.style.color=u.textMuted,e.currentTarget.style.borderColor=u.border},children:[(0,i.jsx)(eh.plus,{size:13,color:"currentColor"}),"Ajouter un transporteur"]})]})})]}),"brand"===g&&(0,i.jsxs)("div",{style:{display:"flex",flexDirection:"column",gap:36},children:[(0,i.jsx)(ey,{title:"Identit\xe9",t:u,children:(0,i.jsxs)("div",{style:{display:"flex",flexDirection:"column",gap:Q.md},children:[(0,i.jsx)(eb,{label:"Marque",t:u,children:(0,i.jsx)("input",{value:s.brand.name,onChange:e=>w("name",e.target.value),style:Z(u)})}),(0,i.jsx)(eb,{label:"Tonalit\xe9",hint:"Adjectifs ou phrase qui guident l'IA",t:u,children:(0,i.jsx)("textarea",{value:s.brand.tone,onChange:e=>w("tone",e.target.value),style:{...ee(u),minHeight:80}})}),(0,i.jsx)(eb,{label:"Signature email",hint:"Plac\xe9e \xe0 la fin de chaque brouillon IA",t:u,children:(0,i.jsx)("textarea",{value:s.brand.signature,onChange:e=>w("signature",e.target.value),style:{...ee(u),minHeight:100,fontFamily:K,fontSize:11}})})]})}),(0,i.jsx)(ey,{title:"Chat en direct",t:u,children:(0,i.jsxs)("label",{style:{display:"flex",alignItems:"center",gap:12,cursor:"pointer"},children:[(0,i.jsx)("button",{type:"button",role:"switch","aria-checked":(null==(t=s.chat)?void 0:t.enabled)!==!1,onClick:()=>{var e;let t;return t=(null==(e=s.chat)?void 0:e.enabled)===!1,a(e=>({...e,chat:{...e.chat||{},enabled:t}}))},style:{position:"relative",width:44,height:24,flexShrink:0,borderRadius:999,border:"none",cursor:"pointer",padding:0,background:(null==(n=s.chat)?void 0:n.enabled)!==!1?u.accent:u.border,transition:"background .15s ease"},children:(0,i.jsx)("span",{style:{position:"absolute",top:2,left:(null==(l=s.chat)?void 0:l.enabled)!==!1?22:2,width:20,height:20,borderRadius:"50%",background:"#fff",transition:"left .15s ease",boxShadow:"0 1px 2px rgba(0,0,0,.3)"}})}),(0,i.jsx)("span",{style:{fontSize:13},children:(null==(o=s.chat)?void 0:o.enabled)!==!1?"Le widget de chat est affich\xe9 sur le site":"Le widget de chat est masqu\xe9 (les clients sont redirig\xe9s par email)"})]})})]}),"responses"===g&&(0,i.jsxs)("div",{style:{display:"flex",flexDirection:"column",gap:24},children:[(0,i.jsx)("p",{style:{fontSize:12,color:u.textMuted,lineHeight:1.6,padding:14,borderRadius:$.md,background:u.surfaceAlt,border:"1px solid ".concat(u.border),margin:0},children:"L'IA combine ces r\xe8gles avec le feedback de tes corrections pass\xe9es pour ajuster ses brouillons."}),(0,i.jsx)(ey,{title:"R\xe8gles",count:s.responses.length,t:u,children:(0,i.jsxs)("div",{style:{display:"flex",flexDirection:"column",gap:Q.lg},children:[s.responses.map((e,t)=>{let n=H[e.category]||{label:"Autre",color:u.textMuted};return(0,i.jsxs)("div",{style:{padding:"".concat(Q.lg,"px 0"),borderBottom:"1px solid ".concat(u.border),display:"flex",flexDirection:"column",gap:Q.md},children:[(0,i.jsxs)("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",gap:Q.sm},children:[(0,i.jsxs)("span",{style:{display:"inline-flex",alignItems:"center",gap:6,fontSize:10,fontWeight:600,color:n.color,padding:"3px 10px",borderRadius:$.pill,background:"".concat(n.color,"12"),border:"1px solid ".concat(n.color,"25"),letterSpacing:"0.02em"},children:[(0,i.jsx)("span",{style:{width:5,height:5,borderRadius:"50%",background:n.color}}),n.label]}),(0,i.jsx)("button",{onClick:()=>a(e=>
1({...e,responses:e.responses.filter((e,n)=>n!==t)})),"aria-label":"Supprimer cette r\xe8gle",style:{width:32,height:32,padding:0,borderRadius:$.md,border:"none",background:"transparent",color:u.textMuted,cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center"},onMouseEnter:e=>{e.currentTarget.style.color=u.red,e.currentTarget.style.background="".concat(u.red,"10")},onMouseLeave:e=>{e.currentTarget.style.color=u.textMuted,e.currentTarget.style.background="transparent"},children:(0,i.jsx)(eh.close,{size:13,color:"currentColor"})})]}),(0,i.jsx)(eb,{label:"Cat\xe9gorie",t:u,children:(0,i.jsx)("select",{value:e.category,onChange:e=>z(t,"category",e.target.value),style:{...Z(u),cursor:"pointer"},children:Object.entries(H).map(e=>{let[t,n]=e;return(0,i.jsx)("option",{value:t,children:n.label},t)})})}),(0,i.jsx)(eb,{label:"Situation d\xe9clencheuse",t:u,children:(0,i.jsx)("input",{value:e.trigger,onChange:e=>z(t,"trigger",e.target.value),style:Z(u)})}),(0,i.jsx)(eb,{label:"Instruction pour l'IA",t:u,children:(0,i.jsx)("textarea",{value:e.instruction,onChange:e=>z(t,"instruction",e.target.value),style:ee(u)})})]},e.id)}),(0,i.jsxs)("button",{onClick:()=>a(e=>({...e,responses:[...e.responses,{id:"r".concat(Date.now()),category:"autre",trigger:"",instruction:""}]})),style:{padding:"12px 16px",minHeight:44,borderRadius:$.md,border:"1px dashed ".concat(u.border),background:"transparent",color:u.textMuted,fontSize:12,fontWeight:600,cursor:"pointer",fontFamily:G,display:"inline-flex",alignItems:"center",justifyContent:"center",gap:6,transition:"border-color 0.18s ease, color 0.18s ease"},onMouseEnter:e=>{e.currentTarget.style.color=u.text,e.currentTarget.style.borderColor=u.textMuted},onMouseLeave:e=>{e.currentTarget.style.color=u.textMuted,e.currentTarget.style.borderColor=u.border},children:[(0,i.jsx)(eh.plus,{size:13,color:"currentColor"}),"Ajouter une r\xe8gle"]})]})})]}),(0,i.jsxs)("div",{style:{marginTop:48,paddingTop:24,borderTop:"1px solid ".concat(u.border)},children:[(0,i.jsxs)("button",{onClick:()=>v(e=>!e),"aria-expanded":b,style:{background:"transparent",border:"none",cursor:"pointer",padding:0,color:u.textDim,fontFamily:G,fontSize:10,fontWeight:700,textTransform:"uppercase",letterSpacing:"0.16em",display:"inline-flex",alignItems:"center",gap:6},children:["Prompt syst\xe8me \xb7 ",b?"Replier":"Afficher"]}),b&&(0,i.jsx)("pre",{style:{marginTop:14,padding:Q.md,borderRadius:$.md,background:u.surfaceAlt,border:"1px solid ".concat(u.border),fontSize:10,lineHeight:1.5,color:u.textMuted,fontFamily:K,whiteSpace:"pre-wrap",maxHeight:280,overflowY:"auto"},children:V(s)})]})]})}),(0,i.jsx)("style",{children:".kb-tab-row::-webkit-scrollbar { display: none; }"})]})}function ey(e){let{title:t,hint:n,count:r,t:l,children:o}=e;return(0,i.jsxs)("section",{children:[(0,i.jsxs)("header",{style:{display:"flex",alignItems:"baseline",gap:12,paddingBottom:12,marginBottom:16,borderBottom:"1px solid ".concat(l.border)},children:[(0,i.jsx)("h2",{style:{fontSize:11,fontWeight:700,textTransform:"uppercase",letterSpacing:"0.16em",color:l.text,margin:0},children:t}),null!=r&&(0,i.jsx)("span",{style:{fontSize:12,color:l.textDim,fontFamily:K,letterSpacing:"-0.01em"},children:r})]}),n&&(0,i.jsx)("p",{style:{fontSize:12,color:l.textMuted,lineHeight:1.6,margin:"0 0 16px"},children:n}),o]})}function eb(e){let{label:t,hint:n,t:r,children:l}=e;return(0,i.jsxs)("div",{children:[(0,i.jsx)("label",{style:{...et(r),marginBottom:6},children:t}),l,n&&(0,i.jsx)("div",{style:{marginTop:6,fontSize:11,color:r.textDim,lineHeight:1.5},children:n})]})}let ev={user:e=>{let{size:t=14,color:n}=e;return(0,i.jsxs)("svg",{width:t,height:t,viewBox:"0 0 24 24",fill:"none",stroke:n||"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,i.jsx)("path",{d:"M20 21v-2a4 4 0 0 0-4-4H8a4 4 0 0 0-4 4v2"}),(0,i.jsx)("circle",{cx:"12",cy:"7",r:"4"})]})},bot:e=>{let{size:t=14,color:n}=e;return(0,i.jsxs)("svg",{width:t,height:t,viewBox:"0 0 24 24",fill:"none",stroke:n||"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,i.jsx)("rect",{x:"3",y:"11",width:"18",height:"10",rx:"2"}),(0,i.jsx)("circle",{cx:"12",cy:"5",r:"2"}),(0,i.jsx)("line",{x1:"12",y1:"7",x2:"12",y2:"11"}),(0,i.jsx)("circle",{cx:"8",cy:"16",r:"1",fill:n||"currentColor"}),(0,i.jsx)("circle",{cx:"16",cy:"16",r:"1",fill:n||"currentColor"})]})},search:e=>{let{size:t=14,color:n}=e;return(0,i.jsxs)("svg",{width:t,height:t,viewBox:"0 0 24 24",fill:"none",stroke:n||"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,i.jsx)("circle",{cx:"11",cy:"11",r:"8"}),(0,i.jsx)("line",{x1:"21",y1:"21",x2:"16.65",y2:"16.65"})]})},back:e=>{let{size:t=16,color:n}=e;return(0,i.jsx)("svg",{width:t,height:t,viewBox:"0 0 24 24",fill:"none",stroke:n||"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:(0,i.jsx)("polyline",{points:"15 18 9 12 15 6"})})},check:e=>{let{size:t=14,color:n}=e;return(0,i.jsx)("svg",{width:t,height:t,viewBox:"0 0 24 24",fill:"none",stroke:n||"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:(0,i.jsx)("polyline",{points:"20 6 9 17 4 12"})})},close:e=>{let{size:t=14,color:n}=e;return(0,i.jsxs)("svg",{width:t,height:t,viewBox:"0 0 24 24",fill:"none",stroke:n||"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,i.jsx)("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),(0,i.jsx)("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})},alert:e=>{let{size:t=14,color:n}=e;return(0,i.jsxs)("svg",{width:t,height:t,viewBox:"0 0 24 24",fill:"none",stroke:n||"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,i.jsx)("path",{d:"M10.29 3.86L1.82 18a2 2 0 0 0 1.71 3h16.94a2 2 0 0 0 1.71-3L13.71 3.86a2 2 0 0 0-3.42 0z"}),(0,i.jsx)("line",{x1:"12",y1:"9",x2:"12",y2:"13"}),(0,i.jsx)("line",{x1:"12",y1:"17",x2:"12.01",y2:"17"})]})},message:e=>{let{size:t=16,color:n}=e;return(0,i.jsx)("svg",{width:t,height:t,viewBox:"0 0 24 24",fill:"none",stroke:n||"currentColor",strokeWidth:"1.6",strokeLinecap:"round",strokeLinejoin:"round",children:(0,i.jsx)("path",{d:"M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z"})})}};function ej(e){if(!e)return"—";let t=Math.floor((Date.now()-new Date(e).getTime())/1e3);return t<60?"\xe0 l'instant":t<3600?"il y a ".concat(Math.floor(t/60),"min"):t<86400?"il y a ".concat(Math.floor(t/3600),"h"):"il y a ".concat(Math.floor(t/86400),"j")}function eS(e){if(e.customer_name&&!e.customer_name.startsWith("anon_chat_"))return e.customer_name;if(e.customer_email&&!e.customer_email.startsWith("anon_chat_"))return e.customer_email.split("@")[0];let t=new Date(e.created_at);if(isNaN(t))return"Session";let n=t.toLocaleDateString("fr-FR",{weekday:"short",day:"numeric",month:"short"}),i=t.toLocaleTimeString("fr-FR",{hour:"2-digit",minute:"2-digit"});return"".concat(n,", ").concat(i)}function ek(e){let{t,active:n}=e,o=t||J,[s,a]=(0,r.useState)([]),[d,c]=(0,r.useState)(null),[u,p]=(0,r.useState)([]),[g,x]=(0,r.useState)(null),[h,m]=(0,r.useState)(!0),[f,y]=(0,r.useState)(""),[b,v]=(0,r.useState)("desktop"),j=(0,r.useRef)(null),S={active:{label:"Actif",color:o.green},escalated:{label:"Escalad\xe9",color:o.red},resolved:{label:"R\xe9solu",color:o.textMuted},expired:{label:"Expir\xe9",color:o.textDim}};(0,r.useEffect)(()=>{let e=()=>{let e=window.innerWidth;v(e<768?"mobile":e<1024?"tablet":"desktop")};return e(),window.addEventListener("resize",e),()=>window.removeEventListener("resize",e)},[]);let k="mobile"===b,w="tablet"===b,C=(0,r.useCallback)(()=>{m(!0),l("/chat/sessions".concat(g?"?status=".concat(g):"")).then(e=>{e.success&&a(e.sessions||[]),m(!1)}).catch(()=>m(!1))},[g]);(0,r.useEffect)(()=>{C()},[C]),(0,r.useEffect)(()=>{n&&C()},[n]),(0,r.useEffect)(()=>
1{if(d){let e;(e=d.id,l("/chat/sessions/".concat(encodeURIComponent(e),"/messages"))).then(e=>{e.success&&p(e.messages||[])})}},[d]),(0,r.useEffect)(()=>{var e;null==(e=j.current)||e.scrollIntoView({behavior:"smooth"})},[u]);let _=async e=>{await l("/chat/sessions/".concat(encodeURIComponent(e),"/resolve"),{method:"POST"}),a(t=>t.map(t=>t.id===e?{...t,status:"resolved"}:t)),(null==d?void 0:d.id)===e&&c(e=>({...e,status:"resolved"}))},z=async e=>{await l("/chat/sessions/".concat(encodeURIComponent(e)),{method:"DELETE"}),a(t=>t.filter(t=>t.id!==e)),(null==d?void 0:d.id)===e&&(c(null),p([]))},T=(0,r.useMemo)(()=>{if(!f.trim())return u;let e=f.toLowerCase();return u.filter(t=>{var n;return null==(n=t.content)?void 0:n.toLowerCase().includes(e)})},[u,f]),D=(0,r.useMemo)(()=>{let e={all:s.length,active:0,escalated:0,resolved:0,expired:0};return s.forEach(t=>{null!=e[t.status]&&e[t.status]++}),e},[s]);function R(e,t){return t.trim()?e.split(RegExp("(".concat(t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),")"),"gi")).map((e,n)=>e.toLowerCase()===t.toLowerCase()?(0,i.jsx)("mark",{style:{background:"".concat(o.gold,"30"),borderRadius:2,padding:"0 2px",color:"inherit"},children:e},n):e):e}function I(e,t){let n;if(!e)return null;let r=/\[\[PRODUCT_CARD:(.*?)\]\]/g,l=[];for(;null!==(n=r.exec(e));)try{l.push(JSON.parse(n[1]))}catch(e){}let s=e.replace(r,"").replace(/\n{3,}/g,"\n\n").trim();return(0,i.jsxs)(i.Fragment,{children:[s&&(0,i.jsx)("div",{style:{whiteSpace:"pre-wrap"},children:s.split(/(\*\*[^*]+\*\*)/g).map((e,n)=>{if(e.startsWith("**")&&e.endsWith("**")){let r=e.slice(2,-2);return(0,i.jsx)("strong",{children:t?R(r,t):r},n)}return t?(0,i.jsx)("span",{children:R(e,t)},n):e})}),l.length>0&&(0,i.jsx)("div",{style:{display:"flex",gap:8,flexWrap:"wrap",marginTop:10*!!s},children:l.map((e,t)=>(0,i.jsxs)("a",{href:e.url,target:"_blank",rel:"noopener noreferrer",style:{display:"flex",gap:10,padding:10,borderRadius:$.md,border:"1px solid ".concat(o.border),background:o.surface,textDecoration:"none",color:o.text,maxWidth:280,transition:"border-color 0.18s ease"},onMouseOver:e=>{e.currentTarget.style.borderColor=o.textMuted},onMouseOut:e=>{e.currentTarget.style.borderColor=o.border},children:[e.image&&(0,i.jsx)("img",{src:e.image,alt:e.title,style:{width:52,height:52,borderRadius:6,objectFit:"cover",flexShrink:0}}),(0,i.jsxs)("div",{style:{minWidth:0,display:"flex",flexDirection:"column",justifyContent:"center",gap:3},children:[(0,i.jsx)("div",{style:{fontSize:12,fontWeight:600,lineHeight:1.35,overflow:"hidden",textOverflow:"ellipsis",display:"-webkit-box",WebkitLineClamp:2,WebkitBoxOrient:"vertical"},children:e.title}),(0,i.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:6},children:[(0,i.jsxs)("span",{style:{fontSize:12,fontWeight:700,color:o.text,fontFamily:K},children:[e.price,"€"]}),e.compare_at_price&&parseFloat(e.compare_at_price)>parseFloat(e.price)&&(0,i.jsxs)("span",{style:{fontSize:10,color:o.textDim,textDecoration:"line-through",fontFamily:K},children:[e.compare_at_price,"€"]})]}),(0,i.jsx)("span",{style:{fontSize:10,fontWeight:600,color:e.available?o.green:o.red,letterSpacing:"0.02em"},children:e.available?"En stock":"Rupture"})]})]},t))})]})}let M=k?"100%":d?w?320:380:"100%",W=!(k&&d),q=!!d;return(0,i.jsxs)("div",{style:{display:"flex",height:"100%",overflow:"hidden",fontFamily:G,color:o.text,background:o.bg},children:[(0,i.jsxs)("aside",{style:{width:M,minWidth:k?0:d?w?320:380:"100%",maxWidth:k?"100%":d?w?320:380:"100%",display:W?"flex":"none",flexDirection:"column",borderRight:q?"1px solid ".concat(o.border):"none",overflow:"hidden",transition:"width 0.22s ease"},children:[!d&&(0,i.jsxs)("div",{style:{padding:k?"24px 20px 0":"32px 32px 0",flexShrink:0},children:[(0,i.jsx)("div",{style:{fontSize:10,color:o.textDim,textTransform:"uppercase",letterSpacing:"0.18em",fontWeight:600,marginBottom:10},children:"Bo\xeete de r\xe9ception"}),(0,i.jsx)("h1",{style:{fontSize:"clamp(28px, 6vw, 40px)",fontFamily:G,fontWeight:600,color:o.text,letterSpacing:"-0.015em",lineHeight:1,margin:0},children:"Conversations."}),(0,i.jsxs)("div",{style:{marginTop:14,fontSize:13,color:o.textMuted,lineHeight:1.6},children:[(0,i.jsx)(ew,{first:!0,n:D.all,l:"au total",T:o}),D.active>0&&(0,i.jsx)(ew,{n:D.active,l:"actifs",T:o}),D.escalated>0&&(0,i.jsx)(ew,{n:D.escalated,l:"escalad\xe9s",T:o,accent:"red"})]})]}),(0,i.jsx)("div",{className:"ca-chip-row",style:{display:"flex",gap:Q.sm,padding:d?"".concat(Q.lg,"px ").concat(Q.lg,"px ").concat(Q.sm,"px"):"".concat(Q.lg,"px ").concat(k?20:32,"px ").concat(Q.sm,"px"),overflowX:"auto",overflowY:"hidden",flexShrink:0,WebkitOverflowScrolling:"touch",scrollbarWidth:"none"},children:[{id:null,label:"Tous",count:D.all},{id:"active",label:"Actifs",count:D.active},{id:"escalated",label:"Escalad\xe9s",count:D.escalated},{id:"resolved",label:"R\xe9solus",count:D.resolved},{id:"expired",label:"Expir\xe9s",count:D.expired}].map(e=>{let t=g===e.id;return(0,i.jsxs)("button",{onClick:()=>x(e.id),"aria-pressed":t,style:{display:"inline-flex",alignItems:"center",gap:6,padding:"8px 14px",minHeight:36,borderRadius:$.pill,border:"1px solid ".concat(t?o.text:o.border),background:t?"".concat(o.text,"08"):"transparent",color:t?o.text:o.textMuted,fontSize:12,fontWeight:t?600:500,fontFamily:G,cursor:"pointer",whiteSpace:"nowrap",flexShrink:0,transition:"border-color 0.18s ease, background 0.18s ease, color 0.18s ease"},children:[(0,i.jsx)("span",{children:e.label}),(0,i.jsx)("span",{style:{fontSize:11,fontFamily:K,color:t?o.text:o.textDim,letterSpacing:"-0.01em"},children:e.count})]},e.id||"all")})}),(0,i.jsx)("div",{style:{flex:1,overflowY:"auto"},children:h?(0,i.jsx)("div",{style:{display:"flex",alignItems:"center",justifyContent:"center",padding:60},children:(0,i.jsx)("span",{style:{fontFamily:G,fontSize:20,color:o.textMuted,letterSpacing:"-0.01em"},children:"Lecture des conversations…"})}):0===s.length?(0,i.jsx)("div",{style:{padding:"60px 32px",textAlign:"left",fontFamily:G,fontSize:22,color:o.textMuted,letterSpacing:"-0.01em"},children:g?"Aucune conversation pour ce filtre.":"Pas de conversation pour l'instant."}):(0,i.jsx)("div",{style:{padding:"0 ".concat(d?Q.sm:k?12:24,"px ").concat(Q.xl,"px")},children:s.map(e=>{let t=(null==d?void 0:d.id)===e.id,n=S[e.status]||{label:e.status||"—",color:o.textMuted},r="escalated"===e.status;return(0,i.jsxs)("button",{type:"button",onClick:()=>c(e),"aria-pressed":t,className:"ca-row",style:{display:"flex",flexDirection:"column",gap:4,width:"100%",padding:"14px 12px",background:t?"".concat(o.text,"08"):"transparent",border:"none",borderBottom:"1px solid ".concat(o.border),borderLeft:t?"2px solid ".concat(o.text):"2px solid transparent",curs
1or:"pointer",textAlign:"left",fontFamily:G,color:o.text,transition:"background 0.15s ease, border-color 0.15s ease",minHeight:60},children:[(0,i.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:8,width:"100%"},children:[(0,i.jsx)("span",{style:{fontSize:13,fontWeight:r?700:600,color:o.text,flex:1,whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis",minWidth:0},children:eS(e)}),e.customer_tier&&"standard"!==e.customer_tier&&(0,i.jsx)(ec,{tier:e.customer_tier,t:o}),(0,i.jsxs)("span",{style:{display:"inline-flex",alignItems:"center",gap:5,fontSize:10,color:n.color,fontWeight:600,flexShrink:0},children:[(0,i.jsx)("span",{style:{width:6,height:6,borderRadius:"50%",background:n.color}}),n.label]})]}),(0,i.jsx)("div",{style:{fontSize:11,color:o.textMuted,whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:e.customer_email||"—"}),(0,i.jsxs)("div",{style:{display:"flex",alignItems:"center",fontSize:10,color:o.textDim,gap:10},children:[(0,i.jsxs)("span",{children:[e.message_count||0," messages"]}),(0,i.jsx)("span",{"aria-hidden":"true",style:{opacity:.5},children:"\xb7"}),(0,i.jsx)("span",{style:{fontFamily:K,letterSpacing:"-0.01em"},children:ej(e.last_message_at||e.updated_at||e.created_at)}),(0,i.jsx)("span",{style:{flex:1}}),(0,i.jsx)("span",{role:"button",tabIndex:0,onClick:t=>{t.stopPropagation(),confirm("Supprimer cette conversation ?")&&z(e.id)},onKeyDown:t=>{("Enter"===t.key||" "===t.key)&&(t.stopPropagation(),t.preventDefault(),confirm("Supprimer cette conversation ?")&&z(e.id))},"aria-label":"Supprimer",className:"ca-row-delete",style:{padding:"4px 6px",borderRadius:4,color:o.textDim,cursor:"pointer",display:"inline-flex",alignItems:"center",transition:"color 0.15s ease, background 0.15s ease",opacity:0},children:(0,i.jsx)(ev.close,{size:11,color:"currentColor"})})]})]},e.id)})})}),(0,i.jsx)("style",{children:'\n          .ca-chip-row::-webkit-scrollbar { display: none; }\n          .ca-row:hover:not([aria-pressed="true"]) {\n            background: '.concat(o.surfaceAlt,' !important;\n          }\n          .ca-row:hover .ca-row-delete,\n          .ca-row:focus-visible .ca-row-delete,\n          .ca-row[aria-pressed="true"] .ca-row-delete {\n            opacity: 0.55;\n          }\n          .ca-row-delete:hover {\n            color: ').concat(o.red," !important;\n            background: ").concat(o.red,"15 !important;\n            opacity: 1 !important;\n          }\n        ")})]}),d?(0,i.jsxs)("section",{style:{flex:1,display:"flex",flexDirection:"column",minWidth:0,background:o.bg},children:[(0,i.jsxs)("div",{style:{padding:"".concat(Q.md,"px ").concat(Q.lg,"px"),borderBottom:"1px solid ".concat(o.border),background:o.surface,flexShrink:0,display:"flex",alignItems:"center",gap:Q.md},children:[k&&(0,i.jsx)("button",{type:"button",onClick:()=>c(null),"aria-label":"Retour \xe0 la liste",style:{width:36,height:36,borderRadius:$.md,background:"transparent",border:"none",cursor:"pointer",color:o.textMuted,display:"flex",alignItems:"center",justifyContent:"center",flexShrink:0,marginLeft:-8}
1,children:(0,i.jsx)(ev.back,{size:18,color:"currentColor"})}),(0,i.jsxs)("div",{style:{flex:1,minWidth:0},children:[(0,i.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:10,flexWrap:"wrap"},children:[(0,i.jsx)("span",{style:{fontSize:14,fontWeight:600,color:o.text,whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis",maxWidth:240},children:eS(d)}),d.customer_tier&&"standard"!==d.customer_tier&&(0,i.jsx)(ec,{tier:d.customer_tier,t:o}),(()=>{let e=S[d.status]||{label:d.status,color:o.textMuted};return(0,i.jsxs)("span",{style:{display:"inline-flex",alignItems:"center",gap:5,fontSize:10,color:e.color,fontWeight:600},children:[(0,i.jsx)("span",{style:{width:6,height:6,borderRadius:"50%",background:e.color}}),e.label]})})(),d.escalation_reason&&(0,i.jsxs)("span",{style:{display:"inline-flex",alignItems:"center",gap:4,fontSize:10,fontWeight:600,color:o.red,padding:"2px 8px",borderRadius:$.pill,background:"".concat(o.red,"10"),border:"1px solid ".concat(o.red,"25")},children:[(0,i.jsx)(ev.alert,{size:10,color:"currentColor"}),"Escalad\xe9"]})]}),(0,i.jsxs)("div",{style:{marginTop:2,fontSize:11,color:o.textMuted,display:"flex",gap:12,flexWrap:"wrap"},children:[(0,i.jsx)("span",{style:{whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis",maxWidth:220},children:d.customer_email}),(0,i.jsx)("span",{"aria-hidden":"true",style:{opacity:.5},children:"\xb7"}),(0,i.jsxs)("span",{children:[d.message_count||u.length," messages"]}),d.created_at&&(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)("span",{"aria-hidden":"true",style:{opacity:.5},children:"\xb7"}),(0,i.jsx)("span",{style:{fontFamily:K,letterSpacing:"-0.01em"},children:ej(d.last_message_at||d.updated_at||d.created_at)})]})]})]}),(0,i.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:Q.xs,flexShrink:0},children:["resolved"!==d.status&&"expired"!==d.status&&(0,i.jsxs)("button",{type:"button",onClick:()=>_(d.id),"aria-label":"Marquer comme r\xe9solu",style:{...ei(!1,o),padding:k?"8px":"8px 12px",color:o.green,borderColor:"".concat(o.green,"40")},children:[(0,i.jsx)(ev.check,{size:13,color:o.green}),!k&&(0,i.jsx)("span",{children:"R\xe9soudre"})]}),(0,i.jsx)("button",{type:"button",onClick:()=>{confirm("Supprimer cette conversation ?")&&z(d.id)},"aria-label":"Supprimer",style:{width:36,height:36,padding:0,flexShrink:0,borderRadius:$.md,border:"1px solid ".concat(o.border),background:"transparent",color:o.textMuted,cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center",transition:"color 0.15s ease, border-color 0.15s ease"},onMouseEnter:e=>{e.currentTarget.style.color=o.red,e.currentTarget.style.borderColor="".concat(o.red,"50")},onMouseLeave:e=>{e.currentTarget.style.color=o.textMuted,e.currentTarget.style.borderColor=o.border},children:(0,i.jsx)(ev.close,{size:13,color:"currentColor"})})]})]}),(0,i.jsxs)("div",{style:{padding:"".concat(Q.sm,"px ").concat(Q.lg,"px"),borderBottom:"1px solid ".concat(o.border),background:o.surface,flexShrink:0,display:"flex",alignItems:"center",gap:10},children:[(0,i.jsxs)("div",{style:{flex:1,position:"relative"},children:[(0,i.jsx)("span",{style:{position:"absolute",left:10,top:"50%",transform:"translateY(-50%)",display:"flex",pointerEvents:"none"},children:(0,i.jsx)(ev.search,{size:12,color:o.textDim})}),(0,i.jsx)("input",{type:"text",placeholder:"Rechercher dans les messages…",value:f,onChange:e=>y(e.target.value),style:{width:"100%",padding:"8px 12px 8px 30px",borderRadius:$.md,border:"1px solid ".concat(o.border),background:o.surfaceAlt,color:o.text,fontSize:12,fontFamily:G,outline:"none",minHeight:36,boxSizing:"border-box",transition:"border-color 0.15s ease"},onFocus:e=>e.target.style.borderColor=o.textMuted,onBlur:e=>e.target.style.borderColor=o.border})]}),f&&(0,i.jsxs)("span",{style:{fontSize:10,color:o.textDim,fontFamily:K,whiteSpace:"nowrap",flexShrink:0},children:[T.length," r\xe9sultat",1!==T.length?"s":""]})]}),(0,i.jsxs)("div",{style:{flex:1,overflowY:"auto",padding:"".concat(Q.lg,"px ").concat(Q.lg,"px ").concat(Q.md,"px"),display:"flex",flexDirection:"column",gap:10},children:[0===T.length&&u.length>0?(0,i.jsx)("div",{style:{padding:40,textAlign:"center",fontFamily:G,fontSize:18,color:o.textMuted},children:"Aucun message ne correspond."}):null,T.map((e,t)=>{if("system"===e.role)return(0,i.jsx)("div",{style:{display:"flex",justifyContent:"center",margin:"4px 0"},children:(0,i.jsxs)("div",{style:{maxWidth:"80%",padding:"8px 14px",borderRadius:$.md,background:o.surfaceAlt,fontSize:11,fontStyle:"italic",color:o.textMuted,lineHeight:1.5,textAlign:"center"},children:[I(e.content,f),(0,i.jsx)("div",{style:{marginTop:4,fontSize:9,color:o.textDim,fontFamily:K,letterSpacing:"-0.01em"},children:new Date(e.created_at).toLocaleTimeString("fr-FR",{hour:"2-digit",minute:"2-digit"})})]})},t);let n="user"===e.role;return(0,i.jsxs)("div",{style:{display:"flex",alignItems:"flex-start",ga
1p:8,justifyContent:n?"flex-end":"flex-start"},children:[!n&&(0,i.jsx)("div",{title:"Assistant",style:{width:28,height:28,borderRadius:"50%",flexShrink:0,display:"flex",alignItems:"center",justifyContent:"center",background:o.surface,border:"1px solid ".concat(o.border),color:o.textMuted},children:(0,i.jsx)(ev.bot,{size:13,color:"currentColor"})}),(0,i.jsxs)("div",{style:{maxWidth:k?"82%":"72%",display:"flex",flexDirection:"column",alignItems:n?"flex-end":"flex-start"},children:[(0,i.jsx)("div",{style:{padding:"10px 14px",borderRadius:n?"".concat($.lg,"px ").concat($.sm,"px ").concat($.sm,"px ").concat($.lg,"px"):"".concat($.sm,"px ").concat($.lg,"px ").concat($.lg,"px ").concat($.sm,"px"),background:n?o.text:o.surface,color:n?o.bg:o.text,border:n?"none":"1px solid ".concat(o.border),fontSize:13,lineHeight:1.6,wordBreak:"break-word"},children:I(e.content,f)}),(0,i.jsxs)("div",{style:{marginTop:4,fontSize:9,color:o.textDim,display:"flex",alignItems:"center",gap:6,letterSpacing:"0.04em"},children:[(0,i.jsx)("span",{style:{fontWeight:600,textTransform:"uppercase"},children:n?"Client":"Assistant"}),(0,i.jsx)("span",{style:{fontFamily:K,letterSpacing:"-0.01em"},children:new Date(e.created_at).toLocaleTimeString("fr-FR",{hour:"2-digit",minute:"2-digit"})})]})]}),n&&(0,i.jsx)("div",{title:"Client",style:{width:28,height:28,borderRadius:"50%",flexShrink:0,display:"flex",alignItems:"center",justifyContent:"center",background:o.surfaceAlt,border:"1px solid ".concat(o.border),color:o.textMuted},children:(0,i.jsx)(ev.user,{size:13,color:"currentColor"})})]},t)}),(0,i.jsx)("div",{ref:j})]})]}):!k&&(0,i.jsx)("div",{style:{flex:1,display:"flex",alignItems:"center",justifyContent:"center",padding:40,color:o.textDim},children:(0,i.jsxs)("div",{style:{textAlign:"center",maxWidth:320},children:[(0,i.jsx)(ev.message,{size:36,color:o.textDim}),(0,i.jsx)("div",{style:{marginTop:14,fontFamily:G,fontSize:22,color:o.textMuted,letterSpacing:"-0.01em"},children:"S\xe9lectionnez une conversation."}),(0,i.jsx)("div",{style:{marginTop:8,fontSize:12,color:o.textDim,lineHeight:1.5},children:"La discussion s'ouvrira ici, avec recherche et actions inline."})]})})]})}function ew(e){let{n:t,l:n,T:r,first:l,accent:o}=e,s="red"===o?r.red:"gold"===o?r.gold:r.text;return(0,i.jsxs)("span",{style:{display:"inline-flex",alignItems:"baseline",whiteSpace:"nowrap",marginRight:20},children:[!l&&(0,i.jsx)("span",{"aria-hidden":"true",style:{marginRight:20,opacity:.45,color:r.textMuted},children:"\xb7"}),(0,i.jsx)("span",{style:{fontFamily:K,fontWeight:600,color:s,fontSize:13,letterSpacing:"-0.01em"},children:t}),(0,i.jsx)("span",{style:{marginLeft:6,color:o?s:r.textMuted},children:n})]})}let eC=[{id:"colissimo",name:"Colissimo (La Poste)",deposit:"Bureau de poste / point relais La Poste"},{id:"dpd",name:"DPD France",deposit:"Point relais Pickup DPD"}],e_={close:e=>{let{size:t=14,color:n}=e;return(0,i.jsxs)("svg",{width:t,height:t,viewBox:"0 0 24 24",fill:"none",stroke:n||"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,i.jsx)("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),(0,i.jsx)("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})},plus:e=>{let{size:t=14,color:n}=e;return(0,i.jsxs)("svg",{width:t,height:t,viewBox:"0 0 24 24",fill:"none",stroke:n||"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,i.jsx)("line",{x1:"12",y1:"5",x2:"12",y2:"19"}),(0,i.jsx)("line",{x1:"5",y1:"12",x2:"19",y2:"12"})]})},check:e=>{let{size:t=14,color:n}=e;return(0,i.jsx)("svg",{width:t,height:t,viewBox:"0 0 24 24",fill:"none",stroke:n||"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:(0,i.jsx)("polyline",{points:"20 6 9 17 4 12"})})},back:e=>{let{size:t=16,color:n}=e;return(0,i.jsxs)("svg",{width:t,height:t,viewBox:"0 0 24 24",fill:"none",stroke:n||"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,i.jsx)("line",{x1:"19",y1:"12",x2:"5",y2:"12"}),(0,i.jsx)("polyline",{points:"12 19 5 12 12 5"})]})}};function ez(e){var t,n,l,o,s,a,d,c,u,p,g,x;let{t:h,policies:f,setPolicies:y,onSave:b,onClose:v,isMobile:j=!1}=e,[S,k]=(0,r.useState)(!1),[w,C]=(0,r.useState)(!1),[_,z]=(0,r.useState)(""),[T,D]=(0,r.useState)(""),[R,I]=(0,r.useState)(""),M=(null==f?void 0:f.returns)||{},W=(e,t)=>y(n=>({...n,returns:{...n.returns||{},[e]:t}})),[q,L]=(0,r.useState)(null);(0,r.useEffect)(()=>{m().then(e=>{e.success&&L((e.carriers||[]).map(e=>e.id))}).catch(()=>L([]))},[]);let A=M.carrier||"colissimo",F=eC.find(e=>e.id===A),E=null==q||q.includes(A),B=async()=>{k(!0);try{await (null==b?void 0:b(f)),C(!0),setTimeout(()=>C(!1),2e3)}finally{k(!1)}};return(0,i.jsx)("div",{style:{height:"100%",display:"flex",flexDirection:"column",background:h.bg,fontFamily:G,color:h.text},children:(0,i.jsx)("div",{style:{flex:1,overflowY:"auto",overflowX:"hidden"},children:(0,i.jsxs)("div",{style:{maxWidth:720,margin:"0 auto",padding:j?"28px 20px 80px":"44px 48px 80px"},children:[(0,i.jsx)("header",{style:{marginBottom:32},children:(0,i.jsxs)("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"flex-start",ga
1p:Q.lg,flexWrap:"wrap"},children:[(0,i.jsxs)("div",{style:{flex:1,minWidth:200},children:[v&&(0,i.jsxs)("button",{onClick:v,style:{display:"inline-flex",alignItems:"center",gap:6,background:"transparent",border:"none",cursor:"pointer",padding:0,marginBottom:14,color:h.textMuted,fontSize:11,fontWeight:600,fontFamily:G,textTransform:"uppercase",letterSpacing:"0.14em"},children:[(0,i.jsx)(e_.back,{size:13,color:"currentColor"})," Retour \xe0 la liste"]}),(0,i.jsx)("div",{style:{fontSize:10,color:h.textDim,textTransform:"uppercase",letterSpacing:"0.18em",fontWeight:600,marginBottom:12},children:"Retours & \xc9changes"}),(0,i.jsx)("h1",{style:{fontSize:"clamp(28px, 6vw, 42px)",fontFamily:"inherit",fontWeight:400,color:h.text,letterSpacing:"-0.015em",lineHeight:1,margin:0},children:"R\xe9glages retours."})]}),(0,i.jsxs)("button",{onClick:B,disabled:S,"aria-label":"Enregistrer les r\xe9glages retours",style:{padding:"10px 18px",minHeight:40,borderRadius:$.md,border:"none",background:w?h.green:h.text,color:h.bg,fontSize:12,fontWeight:600,cursor:"pointer",fontFamily:G,display:"inline-flex",alignItems:"center",gap:6,opacity:S?.5:1,transition:"background 0.2s ease",flexShrink:0},children:[w&&(0,i.jsx)(e_.check,{size:13,color:h.bg}),S?"Sauvegarde…":w?"Enregistr\xe9":"Enregistrer"]})]})}),(0,i.jsxs)("div",{style:{display:"flex",flexDirection:"column",gap:36},children:[(0,i.jsxs)(eT,{title:"Transporteur de retour",hint:"Transporteur impos\xe9 pour TOUTES les \xe9tiquettes retour — portail client comme g\xe9n\xe9ration admin. Personne ne choisit au cas par cas. Renseignez ses identifiants dans Exp\xe9dition › R\xe9glages › Identifiants transporteurs.",t:h,children:[(0,i.jsx)("div",{style:{display:"flex",gap:Q.sm,flexWrap:"wrap"},children:eC.map(e=>{let t=A===e.id,n=null==q||q.includes(e.id);return(0,i.jsxs)("button",{onClick:()=>W("carrier",e.id),style:{flex:"1 1 200px",textAlign:"left",cursor:"pointer",padding:"".concat(Q.md,"px ").concat(Q.lg,"px"),borderRadius:$.md,border:"1.5px solid ".concat(t?h.text:h.border),background:t?"".concat(h.text,"06"):"transparent",transition:"all 0.15s ease",fontFamily:G},children:[(0,i.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:8},children:[(0,i.jsx)("span",{style:{width:14,height:14,borderRadius:"50%",flexShrink:0,border:"1.5px solid ".concat(t?h.text:h.border),background:t?h.text:"transparent"}}),(0,i.jsx)("span",{style:{fontSize:13,fontWeight:600,color:h.text},children:e.name})]}),(0,i.jsxs)("div",{style:{fontSize:11,color:h.textMuted,marginTop:6,paddingLeft:22},children:["D\xe9p\xf4t : ",e.deposit]}),(0,i.jsx)("div",{style:{fontSize:10,marginTop:4,paddingLeft:22,color:n?h.green:h.orange},children:n?"● Identifiants configur\xe9s":"○ Identifiants manquants (Exp\xe9dition › R\xe9glages)"})]},e.id)})}),!E&&(0,i.jsxs)("div",{style:{marginTop:Q.md,fontSize:11,color:h.orange,lineHeight:1.5},children:["⚠ ",null==F?void 0:F.name," est impos\xe9 mais ses identifiants ne sont pas renseign\xe9s — la g\xe9n\xe9ration d'\xe9tiquette \xe9chouera tant qu'ils ne sont pas ajout\xe9s dans Exp\xe9dition › R\xe9glages › Identifiants transporteurs."]})]}),(0,i.jsx)(eT,{title:"P\xe9riode de retour",t:h,children:(0,i.jsxs)("div",{style:{display:"grid",gridTemplateColumns:j?"1fr":"1fr 1fr",gap:Q.md},children:[(0,i.jsx)(eD,{label:"Dur\xe9e (jours)",hint:"Depuis la livraison, ou la cr\xe9ation si non exp\xe9di\xe9.",t:h,children:(0,i.jsx)("input",{type:"number",min:"1",value:null!=(t=M.eligibilityDays)?t:15,onChange:e=>W("eligibilityDays",parseInt(e.target.value)||15),style:Z(h)})}),(0,i.jsx)(eD,{label:"D\xe9lai de remboursement",t:h,children:(0,i.jsx)("input",{value:null!=(n=M.refundDelay)?n:"",onChange:e=>W("refundDelay",e.target.value),style:Z(h)})})]})}),(0,i.jsx)(eT,{title:"Frais de retour",hint:"Retenus une seule fois par retour sur la part remboursement (jamais sur un \xe9change ni un avoir), uniquement pour les demandes du portail. Le montant est fig\xe9 \xe0 la demande : modifier le r\xe9glage ne touche pas les retours en cours. L'admin peut offrir les frais au moment de valider.",t:h,children:(0,i.jsxs)("div",{style:{display:"grid",gridTemplateColumns:j?"1fr":"1fr 1fr",gap:Q.md,alignItems:"end"},children:[(0,i.jsxs)("label",{style:{display:"flex",alignItems:"center",gap:10,cursor:"pointer",padding:"".concat(Q.md,"px ").concat(Q.lg,"px"),borderRadius:$.md,border:"1.5px solid ".concat(M.returnFeeEnabled?h.text:h.border),background:M.returnFeeEnabled?"".concat(h.text,"06"):"transparent",fontFamily:G},children:[(0,i.jsx)("input",{type:"checkbox",checked:!!M.returnFeeEnabled,onChange:e=>W("returnFeeEnabled",e.target.checked),style:{cursor:"pointer"}}),(0,i.jsx)("span",{style:{fontSize:13,fontWeight:600,color:h.text},children:"Facturer des frais de retour"})]}),(0,i.jsx)(eD,{label:"Montant (€)",hint:"D\xe9duit du remboursement, 5 â
1‚¬ par d\xe9faut.",t:h,children:(0,i.jsx)("input",{type:"number",min:"0",step:"0.5",value:null!=(l=M.returnFeeAmount)?l:5,onChange:e=>W("returnFeeAmount",Math.max(0,parseFloat(e.target.value)||0)),disabled:!M.returnFeeEnabled,style:{...Z(h),opacity:M.returnFeeEnabled?1:.5}})})]})}),(0,i.jsx)(eT,{title:"Refus avec options",hint:"Quand un retour re\xe7u est refus\xe9 (article sale, port\xe9...), l'admin peut proposer au client un remboursement avec d\xe9cote et / ou le renvoi de l'article par DPD, via un lien sign\xe9 dans l'email. Ces valeurs pr\xe9-remplissent le formulaire de refus.",t:h,children:(0,i.jsxs)("div",{style:{display:"grid",gridTemplateColumns:j?"1fr":"1fr 1fr",gap:Q.md},children:[(0,i.jsx)(eD,{label:"D\xe9cote propos\xe9e par d\xe9faut (%)",hint:"Ajustable \xe0 chaque refus, entre 1 et 90.",t:h,children:(0,i.jsx)("input",{type:"number",min:"1",max:"90",value:null!=(o=M.rejectDiscountDefaultPercent)?o:30,onChange:e=>W("rejectDiscountDefaultPercent",Math.min(90,Math.max(1,parseInt(e.target.value)||30))),style:Z(h)})}),(0,i.jsx)(eD,{label:"Validit\xe9 du lien (jours)",hint:"Pass\xe9 ce d\xe9lai, le client doit contacter l'atelier.",t:h,children:(0,i.jsx)("input",{type:"number",min:"1",value:null!=(s=M.offerExpiryDays)?s:14,onChange:e=>W("offerExpiryDays",Math.max(1,parseInt(e.target.value)||14)),style:Z(h)})})]})}),(0,i.jsxs)(eT,{title:"Exceptions hors d\xe9lai",hint:"Num\xe9ros de commande autoris\xe9s \xe0 d\xe9passer le d\xe9lai au cas par cas. Les tags non-retournables s'appliquent toujours.",t:h,children:[(0,i.jsx)(eR,{items:null!=(a=M.overrideOrders)?a:[],color:h.green,onRemove:e=>{var t;return W("overrideOrders",(null!=(t=M.overrideOrders)?t:[]).filter(t=>t!==e))}}),(0,i.jsx)(eI,{value:R,setValue:I,onAdd:()=>{var e;let t=R.trim();if(!t)return;let n=null!=(e=M.overrideOrders)?e:[];n.map(e=>e.toLowerCase()).includes(t.toLowerCase())||(W("overrideOrders",[...n,t]),I(""))},placeholder:"ex: SUD-1042",t:h})]}),(0,i.jsxs)(eT,{title:"Tags commandes non-retournables",hint:"Commandes Shopify avec ces tags : retour et \xe9change totalement bloqu\xe9s.",t:h,children:[(0,i.jsx)(eR,{items:null!=(d=M.nonReturnableOrderTags)?d:[],color:h.red,onRemove:e=>{var t;return W("nonReturnableOrderTags",(null!=(t=M.nonReturnableOrderTags)?t:[]).filter(t=>t!==e))}}),(0,i.jsx)(eI,{value:_,setValue:z,onAdd:()=>{var e;let t=_.trim();if(!t)return;let n=null!=(e=M.nonReturnableOrderTags)?e:[];n.includes(t)||(W("nonReturnableOrderTags",[...n,t]),z(""))},placeholder:"ex: non_returnable",t:h})]}),(0,i.jsxs)(eT,{title:"Tags produits non-retournables",hint:"Produits Shopify avec ces tags : article exclu des retours.",t:h,children:[(0,i.jsx)(eR,{items:null!=(c=M.nonReturnableProductTags)?c:[],color:h.orange,onRemove:e=>{var t;return W("nonReturnableProductTags",(null!=(t=M.nonReturnableProductTags)?t:[]).filter(t=>t!==e))}}),(0,i.jsx)(eI,{value:T,setValue:D,onAdd:()=>{var e;let t=T.trim();if(!t)return;let n=null!=(e=M.nonReturnableProductTags)?e:[];n.includes(t)||(W("nonReturnableProductTags",[...n,t]),D(""))},placeholder:"ex: final_sale",t:h})]}),(0,i.jsx)(eT,{title:"Portail et conditions",t:h,children:(0,i.jsxs)("div",{style:{display:"flex",flexDirection:"column",gap:Q.md},children:[(0,i.jsx)(eD,{label:"URL du portail retour",t:h,children:(0,i.jsx)("input",{value:null!=(u=M.portalUrl)?u:"",onChange:e=>W("portalUrl",e.target.value),style:Z(h)})}),(0,i.jsx)(eD,{label:"Conditions de retour",t:h,children:(0,i.jsx)("textarea",{value:null!=(p=M.conditions)?p:"",onChange:e=>W("conditions",e.target.value),style:ee(h)})}),(0,i.jsx)(eD,{label:"Politique d'\xe9change",t:h,children:(0,i.jsx)("textarea",{value:null!=(g=M.exchangePolicy)?g:"",onChange:e=>W("exchangePolicy",e.target.value),style:ee(h)})}),(0,i.jsxs)("div",{style:{display:"grid",gridTemplateColumns:j?"1fr":"2fr 1fr",gap:Q.md},children:[(0,i.jsx)(eD,{label:"Profil d'exp\xe9dition \xe9change",t:h,children:(0,i.jsx)("input",{value:M.exchangeShippingTitle||"",onChange:e=>W("exchangeShippingTitle",e.target.value),style:Z(h),placeholder:"DPD Predict"})}),(0,i.jsx)(eD,{label:"D\xe9lai communication retour",hint:"en jours",t:h,children:(0,i.jsx)("input",{type:"number",value:null!=(x=M.delayDays)?x:0,onChange:e=>W("delayDays",parseInt(e.target.value)||0),style:Z(h)})})]})]})})]})]})})})}function eT(e){let{title:t,hint:n,t:r,children:l}=e;return(0,i.jsxs)("section",{children:[(0,i.jsx)("header",{style:{display:"flex",alignItems:"baseline",gap:12,paddingBottom:12,marginBottom:16,borderBottom:"1px solid ".concat(r.border)},children:(0,i.jsx)("h2",{style:{fontSize:11,fontWeight:700,textTransform:"uppercase",letterSpacing:"0.16em",color:r.text,margin:0},children:t})}),n&&(0,i.jsx)("p",{style:{fontSize:12,color:r.textMuted,lineHeight:1.6,margin:"0 0 16px"},children:n}),l]})}function eD(e){let{label:t,hint:n,t:r,children:l}=e;return(0,i.jsxs)("div",{children:[(0,i.jsx)("label",{style:{...et(r),marginBottom:6},children:t}),l,n&&(0,i.jsx)("div",{style:{marginTop:6,fontSize:11,color:r.textDim,lineHeight:1.5},children:n})]})}function eR(e){let{items:t,color:n,onRemove:r}=e;return 0===t.length?null:(0,i.jsx)("div",{style:{display:"flex",flexWrap:"wrap",gap:6,marginBottom:12},children:t.map(e=>(0,i.jsxs)("span",{style:{display:"inline-flex",alignItems:"center",gap:5,padding:"4px 6px 4px 10px",borderRadius:$.pill,background:"".concat(n,"12"),color:n,fontSize:11,fontWeight:600,border:"1px solid ".concat(n,"25"),letterSpacing:"0.02em"},children:[e,(0,i.jsx)("button",{onClick:()=>r(e),"aria-label":"Retirer ".concat(e),style:{width:18,height:18,padding:0,borderRadius:"50%",border:"none",background:"transparent",color:n,cursor:"pointer",display:"inline-flex",alignItems:"center",justifyContent:"center",opacity:.6,transition:"opacity 0.15s ease, background 0.15s ease"},onMouseEnter:e=>{e.currentTarget.style.opacity=1,e.currentTarget.style.background="".concat(n,"25")},onMouseLeave:e=>{e.currentTarget.style.opacity=.6,e.currentTarget.style.background="transparent"}
1,children:(0,i.jsx)(e_.close,{size:10,color:"currentColor"})})]},e))})}function eI(e){let{value:t,setValue:n,onAdd:r,placeholder:l,t:o}=e;return(0,i.jsxs)("div",{style:{display:"flex",gap:Q.sm},children:[(0,i.jsx)("input",{value:t,onChange:e=>n(e.target.value),onKeyDown:e=>"Enter"===e.key&&r(),placeholder:l,style:{...Z(o),flex:1,minHeight:38}}),(0,i.jsxs)("button",{onClick:r,style:{padding:"8px 14px",minHeight:38,borderRadius:$.md,border:"1px solid ".concat(o.border),background:"transparent",color:o.textMuted,cursor:"pointer",fontSize:12,fontWeight:600,fontFamily:G,display:"inline-flex",alignItems:"center",gap:5,transition:"color 0.15s ease, border-color 0.15s ease",flexShrink:0},onMouseEnter:e=>{e.currentTarget.style.color=o.text,e.currentTarget.style.borderColor=o.textMuted},onMouseLeave:e=>{e.currentTarget.style.color=o.textMuted,e.currentTarget.style.borderColor=o.border},children:[(0,i.jsx)(e_.plus,{size:12,color:"currentColor"}),"Ajouter"]})]})}let eM=e=>Math.round(100*(Number(e)||0))/100;function eW(e){return(null==e?void 0:e.decision)&&"object"==typeof e.decision?e.decision:{status:"accepted"}}let eq=e=>!!eW(e).settled_at,eL=e=>{let t=eW(e);return"rejected"===t.status&&!!t.offer&&(!!t.offer.discount_percent||!!t.offer.reship)},eA=e=>eL(e)&&!eW(e).choice&&!eq(e);function eF(e){var t;let n=eW(e);return"rejected"!==n.status?{action:e.action,discountPercent:0}:"discounted_refund"===n.choice?{action:"refund",discountPercent:Number(null==(t=n.offer)?void 0:t.discount_percent)||0}:"reship"===n.choice?{action:"reship",discountPercent:0}:eL(e)?{action:"pending",discountPercent:0}:{action:"rejected",discountPercent:0}}let eE=e=>(parseFloat(e.price)||0)*(e.qty||1),eB={alertCircle:e=>{let{size:t=16,color:n}=e;return(0,i.jsxs)("svg",{width:t,height:t,viewBox:"0 0 24 24",fill:"none",stroke:n||"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,i.jsx)("circle",{cx:"12",cy:"12",r:"10"}),(0,i.jsx)("line",{x1:"12",y1:"8",x2:"12",y2:"12"}),(0,i.jsx)("line",{x1:"12",y1:"16",x2:"12.01",y2:"16"})]})},pkg:e=>{let{size:t=16,color:n}=e;return(0,i.jsxs)("svg",{width:t,height:t,viewBox:"0 0 24 24",fill:"none",stroke:n||"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,i.jsx)("line",{x1:"16.5",y1:"9.4",x2:"7.5",y2:"4.21"}),(0,i.jsx)("path",{d:"M21 16V8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73l7 4a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16z"}),(0,i.jsx)("polyline",{points:"3.27 6.96 12 12.01 20.73 6.96"}),(0,i.jsx)("line",{x1:"12",y1:"22.08",x2:"12",y2:"12"})]})},clock:e=>{let{size:t=16,color:n}=e;return(0,i.jsxs)("svg",{width:t,height:t,viewBox:"0 0 24 24",fill:"none",stroke:n||"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,i.jsx)("circle",{cx:"12",cy:"12",r:"10"}),(0,i.jsx)("polyline",{points:"12 6 12 12 16 14"})]})},arrowRight:e=>{let{size:t=16,color:n}=e;return(0,i.jsxs)("svg",{width:t,height:t,viewBox:"0 0 24 24",fill:"none",stroke:n||"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,i.jsx)("line",{x1:"5",y1:"12",x2:"19",y2:"12"}),(0,i.jsx)("polyline",{points:"12 5 19 12 12 19"})]})},plus:e=>{let{size:t=16,color:n}=e;return(0,i.jsxs)("svg",{width:t,height:t,viewBox:"0 0 24 24",fill:"none",stroke:n||"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,i.jsx)("line",{x1:"12",y1:"5",x2:"12",y2:"19"}),(0,i.jsx)("line",{x1:"5",y1:"12",x2:"19",y2:"12"})]})},check:e=>{let{size:t=16,color:n}=e;return(0,i.jsx)("svg",{width:t,height:t,viewBox:"0 0 24 24",fill:"none",stroke:n||"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:(0,i.jsx)("polyline",{points:"20 6 9 17 4 12"})})},x:e=>{let{size:t=16,color:n}=e;return(0,i.jsxs)("svg",{width:t,height:t,viewBox:"0 0 24 24",fill:"none",stroke:n||"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,i.jsx)("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),(0,i.jsx)("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})},dollarSign:e=>{let{size:t=16,color:n}=e;return(0,i.jsxs)("svg",{width:t,height:t,viewBox:"0 0 24 24",fill:"none",stroke:n||"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,i.jsx)("line",{x1:"12",y1:"1",x2:"12",y2:"23"}),(0,i.jsx)("path",{d:"M17 5H9.5a3.5 3.5 0 0 0 0 7h5a3.5 3.5 0 0 1 0 7H6"})]})},repeat:e=>{let{size:t=16,color:n}=e;return(0,i.jsxs)("svg",{width:t,height:t,viewBox:"0 0 24 24",fill:"none",stroke:n||"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,i.jsx)("polyline",{points:"17 1 21 5 17 9"}),(0,i.jsx)("path",{d:"M3 11V9a4 4 0 0 1 4-4h14"}),(0,i.jsx)("polyline",{points:"7 23 3 19 7 15"}),(0,i.jsx)("path",{d:"M21 13v2a4 4 0 0 1-4 4H3"})]})},tag:e=>{let{size:t=16,color:n}=e;return(0,i.jsxs)("svg",{width:t,height:t,viewBox:"0 0 24 24",fill:"none",stroke:n||"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,i.jsx)("path",{d:"M20.59 13.41l-7.17 7.17a2 2 0 0 1-2.83 0L2 12V2h10l8.59 8.59a2 2 0 0 1 0 2.82z"}),(0,i.jsx)("line",{x1:"7",y1:"7",x2:"7.01",y2:"7"})]})},layers:e=>{let{size:t=16,color:n}=e;return(0,i.jsxs)("svg",{width:t,height:t,viewBox:"0 0 24 24",fill:"none",stroke:n||"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,i.jsx)("polygon",{points:"12 2 2 7 12 12 22 7 12 2"}),(0,i.jsx)("polyline",{points:"2 17 12 22 22 17"}),(0,i.jsx)("polyline",{points:"2 12 12 17 22 12"})]})},mail:e=>{let{size:t=16,color:n}=e;return(0,i.jsxs)("svg",{width:t,height:t,viewBox:"0 0 24 24",fill:"none",stroke:n||"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,i.jsx)("path",{d:"M4 4h16c1.1 0 2 .9 2 2v12c0 1.1-.9 2-2 2H4c-1.1 0-2-.9-2-2V6c0-1.1.9-2 2-2z"}),(0,i.jsx)("polyline",{points:"22,6 12,13 2,6"})]})},copy:e=>{let{size:t=16,color:n}=e;return(0,i.jsxs)("svg",{width:t,height:t,viewBox:"0 0 24 24",fill:"none",stroke:n||"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,i.jsx)("rect",{x:"9",y:"9",width:"13",height:"13",rx:"2",ry:"2"}),(0,i.jsx)("path",{d:"M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1"})]})},save:e=>{let{size:t=16,color:n}=e;return(0,i.jsxs)("svg",{width:t,height:t,viewBox:"0 0 24 24",fill:"none",stroke:n||"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,i.jsx)("path",{d:"M19 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h11l5 5v11a2 2 0 0 1-2 2z"}),(0,i.jsx)("polyline",{points:"17 21 17 13 7 13 7 21"}),(0,i.jsx)("polyline",{points:"7 3 7 8 15 8"})]})},arrowLeft:e=>{let{size:t=16,color:n}=e;return(0,i.jsxs)("svg",{width:t,height:t,viewBox:"0 0 24 24",fill:"none",stroke:n||"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,i.jsx)("line",{x1:"19",y1:"12",x2:"5",y2:"12"}),(0,i.jsx)("polyline",{points:"12 19 5 12 12 5"})]})},externalLink:e=>{let{size:t=16,color:n}=e;return(0,i.jsxs)("svg",{width:t,height:t,viewBox:"0 0 24 24",fill:"none",stroke:n||"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,i.jsx)("path",{d:"M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6"}),(0,i.jsx)("polyline",{points:"15 3 21 3 21 9"}),(0,i.jsx)("line",{x1:"10",y1:"14",x2:"21",y2:"3"})]})},chevronDown:e=>{let{size:t=16,color:n}=e;return(0,i.jsx)("svg",{width:t,height:t,viewBox:"0 0 24 24",fill:"none",stroke:n||"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:(0,i.jsx)("polyline",{points:"6 9 12 15 18 9"})})},edit:e=>{let{size:t=16,color:n}=e;return(0,i.jsxs)("svg",{width:t,height:t,viewBox:"0 0 24 24",fill:"none",stroke:n||"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,i.jsx)("path",{d:"M11 4H4a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7"}),(0,i.jsx)("path",{d:"M18.5 2.5a2.121 2.121 0 0 1 3 3L12 15l-4 1 1-4 9.5-9.5z"})]})}},eP=e=>({refund:{label:"Remboursement",color:e.blue,icon:eB.dollarSign},exchange:{label:"\xc9change",color:e.purple,icon:eB.repeat},credit:{label:"Avoir",color:e.green,icon:eB.tag},mixed:{label:"Mixte",color:e.orange,icon:eB.layers}}),eO={taille_incorrecte:"Taille incorrecte",defectueux:"Article defectueux",ne_correspond_pas:"Ne correspond pas",autre:"Autre"};function eU(e){let{status:t,t:n}
1=e,r={pending:{label:"En attente",color:n.textMuted,icon:eB.clock},label_generated:{label:"A d\xe9poser",color:n.orange,icon:eB.tag},in_transit:{label:"En transit",color:n.blue,icon:eB.pkg},received:{label:"A traiter",color:n.red,icon:eB.alertCircle},processed:{label:"Trait\xe9",color:n.green,icon:eB.check},rejected:{label:"Refus\xe9",color:n.red,icon:eB.x},awaiting_customer:{label:"Choix client",color:n.orange,icon:eB.clock},to_reship:{label:"A renvoyer",color:n.purple,icon:eB.pkg},reshipped:{label:"Renvoy\xe9",color:n.green,icon:eB.check}},l=r[t]||r.pending;return(0,i.jsxs)("span",{style:{display:"inline-flex",alignItems:"center",gap:6,padding:"4px 10px",borderRadius:$.pill,fontSize:10,fontWeight:600,letterSpacing:"0.01em",color:l.color,background:"".concat(l.color,"10"),transition:"all 0.2s ease"},children:[(0,i.jsx)("span",{style:{width:6,height:6,borderRadius:"50%",background:l.color,flexShrink:0}}),l.label]})}function eN(e){let{type:t,t:n}=e,r=eP(n),l=r[t]||r.refund,o=l.icon;return(0,i.jsxs)("span",{style:{display:"inline-flex",alignItems:"center",gap:4,padding:"3px 8px",borderRadius:$.pill,fontSize:10,fontWeight:600,color:l.color,background:"".concat(l.color,"08")},children:[(0,i.jsx)(o,{size:11,color:l.color}),l.label]})}function eH(e){let{t,sectionCard:n,icon:r,iconBg:l,label:o,address:s,email:a}=e;if(!s)return null;let d=[s.first_name,s.last_name].filter(Boolean).join(" ")||s.name||"",c=[s.address1,s.address2,[s.zip,s.city].filter(Boolean).join(" "),[s.province,s.country].filter(Boolean).join(", ")].filter(Boolean),u=[d,...c,s.phone,a].filter(Boolean).join("\n");return(0,i.jsxs)("div",{style:{...n,padding:12,flex:"1 1 240px",minWidth:240,display:"flex",flexDirection:"column",gap:6},children:[(0,i.jsxs)("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:8},children:[(0,i.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:6},children:[(0,i.jsx)("div",{style:{width:20,height:20,borderRadius:4,background:l,display:"flex",alignItems:"center",justifyContent:"center"},children:r}),(0,i.jsx)("span",{style:{fontSize:9,color:t.textDim,textTransform:"uppercase",fontWeight:600,letterSpacing:"0.04em"},children:o})]}),(0,i.jsx)("button",{onClick:()=>navigator.clipboard.writeText(u),title:"Copier",style:{background:"transparent",border:"none",cursor:"pointer",padding:2,display:"flex",alignItems:"center",color:t.textMuted},children:(0,i.jsx)(eB.copy,{size:11})})]}),(0,i.jsxs)("div",{style:{fontSize:12,color:t.text,lineHeight:1.5},children:[d&&(0,i.jsx)("div",{style:{fontWeight:600},children:d}),c.map((e,t)=>(0,i.jsx)("div",{children:e},t)),s.phone&&(0,i.jsx)("div",{style:{color:t.textMuted,marginTop:2,fontSize:11},children:s.phone})]})]})}let eV=[{id:null,label:"Tout",iconKey:"stack"},{id:"received",label:"A traiter",iconKey:"alertCircle"},{id:"awaiting",label:"En attente colis",iconKey:"pkg"},{id:"late",label:"En retard",iconKey:"clock"}];function eG(e){if(!e)return"—";let t=new Date(e);if(isNaN(t.getTime()))return"—";let n=(Date.now()-t.getTime())/1e3;return n<60?"a l'instant":n<3600?"il y a ".concat(Math.floor(n/60),"min"):n<86400?"il y a ".concat(Math.floor(n/3600),"h"):n<604800?"il y a ".concat(Math.floor(n/86400),"j"):t.toLocaleDateString("fr-FR",{day:"numeric",month:"short"})}function eK(e){let{children:t,t:n}=e;return(0,i.jsx)("div",{style:{fontSize:10,color:n.textDim,textTransform:"uppercase",letterSpacing:"0.08em",fontWeight:600,marginBottom:Q.sm,fontFamily:G},children:t})}function eY(e){var t,n,o,s,a,d,f;let{t:y,active:b,policies:v,setPolicies:j,onSavePolicies:S}=e,[k,w]=(0,r.useState)([]),[C,_]=(0,r.useState)(!0),[z,T]=(0,r.useState)(!1),[D,R]=(0,r.useState)(null),[I,M]=(0,r.useState)(null),[W,q]=(0,r.useState)(""),[A,F]=(0,r.useState)(null),[E,B]=(0,r.useState)(!1),[P,O]=(0,r.useState)(!0),[U,N]=(0,r.useState)({}),[H,V]=(0,r.useState)(""),[Y,J]=(0,r.useState)(!1),[X,ee]=(0,r.useState)(!1),[et,en]=(0,r.useState)({}),[er,el]=(0,r.useState)({}),[eo,es]=(0,r.useState)({}),[ea,ed]=(0,r.useState)(""),[ec,eu]=(0,r.useState)(null),[ep,eg]=(0,r.useState)(!1),[eh,em]=(0,r.useState)(""),[ef,ey]=(0,r.useState)(""),[eb,ev]=(0,r.useState)(""),[ej,eS]=(0,r.useState)(null),[ek,ew]=(0,r.useState)(!1),[eC,e_]=(0,r.useState)(""),[eT,eD]=(0,r.useState)(""),[eR,eI]=(0,r.useState)(!1),[eL,eY]=(0,r.useState)(null),[eJ,e$]=(0,r.useState)({}),[eZ,e0]=(0,r.useState)(!1),[e1,e2]=(0,r.useState)(!1),[e6,e4]=(0,r.useState)(""),[e5,e3]=(0,r.useState)({}),[e8,e7]=(0,r.useState)("order"),[e9,te]=(0,r.useState)(""),[tt,tn]=(0,r.useState)([]),[ti,tr]=(0,r.useState)(!1),[tl,to]=(0,r.useState)(null),[ts,ta]=(0,r.useState)(!1),[td,tc]=(0,r.useState)({name:"",email:"",ph
1one:""}),[tu,tp]=(0,r.useState)([]),[tg,tx]=(0,r.useState)(""),[th,tm]=(0,r.useState)([]),[tf,ty]=(0,r.useState)(!1),[tb,tv]=(0,r.useState)(null),[tj,tS]=(0,r.useState)({date:"",location:"",payment_method:"especes",receipt_ref:""}),[tk,tw]=(0,r.useState)("in_store"),[tC,t_]=(0,r.useState)({first_name:"",last_name:"",address1:"",address2:"",zip:"",city:"",phone:""}),[tz,tT]=(0,r.useState)(!1),[tD,tR]=(0,r.useState)([]),[tI,tM]=(0,r.useState)("colissimo"),[tW,tq]=(0,r.useState)(!1),[tL,tA]=(0,r.useState)(!1),[tF,tE]=(0,r.useState)(!1),[tB,tP]=(0,r.useState)(!1),[tO,tU]=(0,r.useState)(!1),[tN,tH]=(0,r.useState)(!1),[tV,tG]=(0,r.useState)(!1),[tK,tY]=(0,r.useState)(null),[tJ,tX]=(0,r.useState)(!1),[tQ,t$]=(0,r.useState)({}),[tZ,t0]=(0,r.useState)(!1),[t1,t2]=(0,r.useState)(null),[t6,t4]=(0,r.useState)(!1),[t5,t3]=(0,r.useState)(!1),[t8,t7]=(0,r.useState)(!1),[t9,ne]=(0,r.useState)(!1);(0,r.useEffect)(()=>{let e=()=>{let e=window.innerWidth;t7(e<768),ne(e>=768&&e<1024)};return e(),window.addEventListener("resize",e),()=>window.removeEventListener("resize",e)},[]);let nt=(0,r.useCallback)(async()=>{_(!0);try{let e=await c();e.success&&w(e.returns||[])}catch(e){console.error("Fetch returns error:",e)}_(!1)},[]),nn=async()=>{tG(!0),tY(null);try{let n=await l("/cron/track-returns");if(n.success){var e,t;tY({ok:!0,message:"".concat(null!=(e=n.updated)?e:0," retour(s) mis \xe0 jour sur ").concat(null!=(t=n.tracked)?t:0," suivis")}),await nt()}else tY({ok:!1,message:n.error||"Erreur inconnue"})}catch(e){tY({ok:!1,message:e.message})}tG(!1),setTimeout(()=>tY(null),6e3)};(0,r.useEffect)(()=>{nt()},[nt]),(0,r.useEffect)(()=>{b&&nt()},[b]),(0,r.useEffect)(()=>{m().then(e=>{var t;e.success&&(null==(t=e.carriers)?void 0:t.length)&&(tR(e.carriers),tM(e.carriers[0].id))}).catch(()=>{})},[]);let ni=async()=>{if(ng&&!tL){tA(!0);try{let e="90bf72b266b57db5941529bb5241cfc5da01f7f651e1ffc3e760f2b8b189d823",t=await fetch("/api/returns/".concat(ng.id,"/download-label"),{headers:e?{Authorization:"Bearer ".concat(e)}:{}});if(!t.ok){let e=await t.json().catch(()=>({}));alert(e.error||"Erreur lors du t\xe9l\xe9chargement");return}let n=await t.blob(),i=URL.createObjectURL(n),r=document.createElement("a");r.href=i;let l="colissimo"===ng.carrier?"Colissimo":"dpd"===ng.carrier?"DPD":ng.carrier||"retour";r.download="etiquette-".concat(ng.order_name||ng.id,"-").concat(l,".pdf"),r.click(),URL.revokeObjectURL(i)}catch(e){alert("Erreur: "+e.message)}tA(!1)}},nr=async()=>{if(ng&&!tW){tq(!0);try{var e;let t,n,i=(null==v||null==(e=v.returns)?void 0:e.carrier)||tI,r=await (t=ng.id,n=tN||void 0,l("/returns/".concat(encodeURIComponent(t),"/generate-label"),{method:"POST",body:{carrier:i,force:n}}));r.success?(tT(!1),tH(!1),await nt()):alert(r.error||"Erreur lors de la g\xe9n\xe9ration")}catch(e){alert("Erreur: "+e.message)}tq(!1)}},nl=async()=>{if(ng&&!tO){tU(!0);try{let e,t=await (e=ng.id,l("/returns/".concat(encodeURIComponent(e),"/resend-label"),{method:"POST"}));t.success?alert("Email renvoy\xe9 avec succ\xe8s"):alert(t.error||"Erreur lors du renvoi")}catch(e){alert("Erreur: "+e.message)}tU(!1)}},no=async()=>{if(ng&&!tZ){t0(!0),t2(null);try{let e={shipping_address:JSON.stringify(tQ)};ny&&(e.exchange_shipping_address=JSON.stringify(tQ));let t=await u(ng.id,e);if(!t.success)throw Error(t.error||"Erreur lors de la sauvegarde");tX(!1),t2({ok:!0}),await nt()}catch(e){t2({ok:!1,message:e.message})}t0(!1)}},ns=async()=>{if(ng&&!tB){tP(!0);try{let e,t=await (e=ng.id,l("/returns/".concat(encodeURIComponent(e)),{method:"DELETE"}));t.success?(R(null),tE(!1),await nt()):alert(t.error||"Erreur lors de la suppression")}catch(e){alert("Erreur: "+e.message)}tP(!1)}},na={all:k.length,received:k.filter(e=>"received"===e.status).length,awaiting:k.filter(e=>["pending","label_generated","in_transit"].includes(e.status)).length,late:k.filter(e=>"in_transit"===e.status&&(Date.now()-new Date(e.created_at).getTime())/864e5>7).length},nd=k.filter(e=>{if("received"===I&&"received"!==e.status||"awaiting"===I&&!["pending","label_generated","in_transit"].includes(e.status)||"late"===I&&("in_transit"!==e.status||(Date.now()-new Date(e.created_at).getTime())/864e5<=7)||A&&e.type!==A)return!1;if(W){let t=W.toLowerCase();if(!((e.order_name||"").toLowerCase().includes(t)||(e.customer_email||"").toLowerCase().includes(t)||(e.customer_name||"").toLowerCase().includes(t)||(e.tracking_code||"").toLowerCase().includes(t)))return!1}return!0}),nc=["processed","rejected","reshipped"],nu=nd.filter(e=>!nc.includes(e.status)),np=nd.filter(e=>nc.includes(e.status)),ng=k.find(e=>e.id===D),nx=ng?"string"==typeof ng.items?JSON.parse(ng.items):ng.
1items:[],nh=e=>{if(!e)return null;if("string"==typeof e)try{return JSON.parse(e)}catch(e){return null}return e},nm=ng?nh(ng.shipping_address):null,nf=ng?nh(ng.exchange_shipping_address):null,ny=nx.some(e=>(null==e?void 0:e.action)==="exchange"),nb=async e=>{if(!e5[e])try{let t=await fetch("/api/returns/check-stock?productId=".concat(encodeURIComponent(e))),n=await t.json();n.success&&e3(t=>({...t,[e]:n.variants}))}catch(e){}},nv=null!=(f=null==v||null==(t=v.returns)?void 0:t.rejectDiscountDefaultPercent)?f:30,nj=(e,t)=>N(n=>({...n,[e]:{status:"accepted",reason:"",discountOn:!0,discount:nv,reship:!0,...n[e]||{},...t}})),nS=e=>U[e]||{status:"accepted",reason:"",discountOn:!0,discount:nv,reship:!0},nk=nx.map((e,t)=>eq(e)||eW(e).choice?null:t).filter(e=>null!==e),nw=nk.filter(e=>"rejected"===nS(e).status).length,nC=nk.length-nw,n_=nk.every(e=>{let t=nS(e);return"rejected"!==t.status||!!(t.reason||H).trim()&&(!t.discountOn||!!(Number(t.discount)>=1&&90>=Number(t.discount)))}),nz=async()=>{if(ng&&!E&&n_){B(!0);try{let e={restock:P,waive_fee:Y,common_reason:H.trim(),decisions:nk.map(e=>{let t=nS(e);return"rejected"===t.status?{index:e,status:"rejected",reason:(t.reason||H).trim(),discount_percent:t.discountOn?Number(t.discount):null,reship:!!t.reship}:{index:e,status:"accepted"}})},t=await p(ng.id,e);t.success?(await nt(),R(null)):(alert(t.error||"Erreur lors du traitement"),await nt())}catch(e){alert("Erreur: "+e.message)}B(!1)}},nT=async()=>{if(ng&&!E){B(!0);try{let e=await g(ng.id,{action:"resend"});e.success?(await nt(),alert("Email renvoy\xe9 au client")):alert(e.error||"Erreur")}catch(e){alert("Erreur: "+e.message)}B(!1)}},nD=Object.values(et).includes("reship"),nR=async()=>{if(ng&&!E){B(!0);try{let e=Object.entries(et).map(e=>{let[t,n]=e;return{index:Number(t),choice:n}}),t=await g(ng.id,{action:"choose",choices:e,address:nD?er:void 0});t.success?(ee(!1),await nt()):(es(t.errors||{}),alert(t.error||"Erreur"))}catch(e){alert("Erreur: "+e.message)}B(!1)}},nI=async function(){let e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];if(ng&&!E&&(!e||confirm("R\xe9g\xe9n\xe9rer cr\xe9e un NOUVEAU colis DPD. Continuer ?"))){B(!0),eu(null);try{let t=await x(ng.id,{force:e,weight:ea?parseFloat(ea):void 0});if(t.success){if(eu(t),t.label_pdf_b64){let e=Uint8Array.from(atob(t.label_pdf_b64),e=>e.charCodeAt(0)),n=URL.createObjectURL(new Blob([e],{type:"application/pdf"})),i=document.createElement("a");i.href=n,i.download="renvoi-sav-".concat(ng.order_name||ng.id,"-DPD.pdf"),i.click(),URL.revokeObjectURL(n)}await nt()}else alert(t.error||"Erreur lors de la g\xe9n\xe9ration")}catch(e){alert("Erreur: "+e.message)}B(!1)}},nM=async()=>{if(ng&&!ep){eg(!0);try{let e="90bf72b266b57db5941529bb5241cfc5da01f7f651e1ffc3e760f2b8b189d823",t=await fetch("/api/returns/".concat(ng.id,"/download-reship-label"),{headers:e?{Authorization:"Bearer ".concat(e)}:{}});if(!t.ok){let e=await t.json().catch(()=>({}));alert(e.error||"Erreur lors du t\xe9l\xe9chargement");return}let n=URL.createObjectURL(await t.blob()),i=document.createElement("a");i.href=n,i.download="renvoi-sav-".concat(ng.order_name||ng.id,"-DPD.pdf"),i.click(),URL.revokeObjectURL(n)}catch(e){alert("Erreur: "+e.message)}eg(!1)}},nW=async()=>{ng&&(await u(ng.id,{admin_notes:eh}),await nt())},nq=async e=>{if(ng&&!E){B(!0);try{let t={status:e};"received"===e&&(t.received_at=new Date().toISOString());let n=await u(ng.id,t);n.success?await nt():alert(n.error||"Erreur")}catch(e){alert("Erreur: "+e.message)}B(!1)}},nL=async()=>{if(!ng)return;let e={};ef!==(ng.label_url||"")&&(e.label_url=ef),eb!==(ng.tracking_code||"")&&(e.tracking_code=eb),Object.keys(e).length&&(await u(ng.id,e),await nt())},nA=async()=>
1{if(eC.trim()||eT.trim()){eI(!0),e4(""),eY(null),e$({});try{if(eC.trim()){let e=await fetch("/api/portal/order?num=".concat(encodeURIComponent(eC.trim()))),t=await e.json();t.success?eY(t.order):e4("Commande introuvable")}else{var e;let t=await fetch("/api/portal/orders-by-email?email=".concat(encodeURIComponent(eT.trim()))),n=await t.json();n.success&&(null==(e=n.orders)?void 0:e.length)?eY(n.orders[0]):e4("Aucune commande trouvee")}}catch(e){e4("Erreur de recherche")}eI(!1)}},nF=async()=>{if(eL&&Object.keys(eJ).length){eI(!0),e4("");try{var e;let t,n=Object.entries(eJ).map(e=>{let[t,n]=e,i=eL.items[parseInt(t)];return{title:i.title,variant:i.variant,qty:i.qty,price:i.price,product_id:i.product_id,image:i.image||null,variant_id:i.variant_id,line_item_id:i.line_item_id,reason:n.reason||"autre",action:n.action||"refund",exchange_variant_id:n.exchangeVariant||null,exchange_variant_title:n.exchangeVariantTitle||null}}),i=await (t={order_number:eL.name,email:null==(e=eL.customer)?void 0:e.email,items:n,override_eligibility:eZ||e1},l("/returns",{method:"POST",body:t}));i.success?(ew(!1),e_(""),eD(""),eY(null),e$({}),e0(!1),e2(!1),e3({}),await nt()):e4(i.message||i.error||"Erreur")}catch(e){e4(e.message)}eI(!1)}},nE=e=>{var t;return(null==(t=String(e||"").match(/\d+/g))?void 0:t.pop())||null};(0,r.useEffect)(()=>{if(!ek||"manual"!==e8)return;let e=e9.trim();if(e.length<2)return void tn([]);let t=setTimeout(async()=>{tr(!0);try{let t=await l("/customers/search?q=".concat(encodeURIComponent(e)));t.success&&tn(t.customers||[])}catch(e){}tr(!1)},350);return()=>clearTimeout(t)},[e9,ek,e8]),(0,r.useEffect)(()=>{if(!ek||"manual"!==e8)return;let e=tg.trim();if(e.length<2)return void tm([]);let t=setTimeout(async()=>{ty(!0);try{let t=await L(e);t.success&&tm(t.products||[])}catch(e){}ty(!1)},350);return()=>clearTimeout(t)},[tg,ek,e8]);let nB=(e,t)=>{tp(n=>n.map((n,i)=>i===e?{...n,...t}:n))},nP=async(e,t)=>{if(t&&!(t.trim().length<2))try{let n=await L(t.trim());n.success&&nB(e,{exchange_results:n.products||[]})}catch(e){}},nO=async()=>{e4("");let e=tl?{email:tl.email,name:tl.name||"",phone:tl.phone||null,shopify_customer_id:"sav"!==tl.source?tl.id:null}:{email:td.email.trim(),name:td.name.trim(),phone:td.phone||null};if(!e.email||!e.name)return void e4("Client requis : s\xe9lectionnez un client existant ou renseignez nom et email.");if(!tu.length)return void e4("Ajoutez au moins un article.");let t=tu.filter(e=>"exchange"===e.action&&!e.exchange_variant_id);if(t.length)return void e4("Variante d'\xe9change manquante pour : ".concat(t.map(e=>e.title).join(", ")));let n=tu.some(e=>"exchange"===e.action),i="shipping"===tk||n;if(i&&(!(tC.first_name.trim()||tC.last_name.trim())||!tC.address1.trim()||!tC.zip.trim()||!tC.city.trim()))return void e4("shipping"===tk?"Adresse compl\xe8te requise pour g\xe9n\xe9rer l'\xe9tiquette de retour.":"Adresse compl\xe8te requise pour livrer l'\xe9change.");eI(!0);try{let t,n=tu.map(e=>{let{exchange_results:t,exchange_search:n,...i}=e;return i}),r=await (t={customer:e,items:n,purchase:tj,drop_off:tk,shipping_address:i?tC:null},l("/returns/manual",{method:"POST",body:t}));r.success?(ew(!1),e7("order"),te(""),tn([]),to(null),ta(!1),tc({name:"",email:"",phone:""}),tp([]),tx(""),tm([]),tv(null),tS({date:"",location:"",payment_method:"especes",receipt_ref:""}),tw("in_store"),t_({first_name:"",last_name:"",address1:"",address2:"",zip:"",city:"",phone:""}),e3({}),await nt()):e4(r.error||"Erreur lors de la cr\xe9ation")}catch(e){e4(e.message)}eI(!1)};(0,r.useEffect)(()=>{ng&&(em(ng.admin_notes||""),N({}),V(""),J(!1),ee(!1),ed(""),eu(null),ey(ng.label_url||""),ev(ng.tracking_code||""),tX(!1),t2(null),t4(!1))},[D]),y.bg;let nU={padding:Q.lg,borderRadius:$.lg,background:y.surface,border:"1px solid ".concat(y.border)},nN=(e,t,n)=>({padding:"7px 14px",borderRadius:$.md,border:"none",background:e,color:t,fontSize:11,fontWeight:600,cursor:n?"default":"pointer",fontFamily:G,transition:"all 0.2s ease",opacity:n?.5:1,display:"inline-flex",alignItems:"center",gap:6});if(z&&v&&j)return(0,i.jsx)(ez,{t:y,policies:v,setPolicies:j,onSave:S,onClose:()=>T(!1),isMobile:t8});let nH=(null==v||null==(n=v.returns)?void 0:n.carrier)||"colissimo",nV=(null==(o=tD.find(e=>e.id===nH))?void 0:o.name)||("dpd"===nH?"DPD France":"Colissimo (La Poste)");return(0,i.jsxs)("div",{style:{display:"flex",height:"100%",overflow:"hidden",fontFamily:G},children:[(0,i.jsxs)("div",{style:{width:t8?"100%":ng?t9?320:440:"100%",minWidth:t8?0:ng?440*!t9:0,maxWidth:t8?"100%":ng?t9?320:440:"100%",display:t8&&ng?"none":"flex",borderRight:ng?"1px solid ".concat(y.border):"none",flexDirection:"column",overflow:"hidden",transition:"width 0.25s ease, max-width 0.25s ease"},children:[!ng&&(0,i.jsxs)("div",{style:{padding:t8?"24px 20px 0":"32px 32px 0",flexShrink:0},children:[(0,i.jsxs)("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"flex-start",ga
1p:Q.md},children:[(0,i.jsx)("div",{style:{fontSize:10,color:y.textDim,textTransform:"uppercase",letterSpacing:"0.18em",fontWeight:600,marginBottom:10},children:"Bo\xeete de r\xe9ception"}),v&&j&&(0,i.jsxs)("button",{onClick:()=>T(!0),"aria-label":"R\xe9glages retours et \xe9changes",style:{display:"inline-flex",alignItems:"center",gap:6,padding:"7px 12px",minHeight:32,flexShrink:0,borderRadius:$.md,border:"1px solid ".concat(y.border),background:"transparent",color:y.textMuted,fontSize:11,fontWeight:600,fontFamily:G,cursor:"pointer",transition:"color 0.15s ease, border-color 0.15s ease"},onMouseEnter:e=>{e.currentTarget.style.color=y.text,e.currentTarget.style.borderColor=y.textMuted},onMouseLeave:e=>{e.currentTarget.style.color=y.textMuted,e.currentTarget.style.borderColor=y.border},children:[(0,i.jsx)(ex.config,{size:13,color:"currentColor"})," R\xe9glages"]})]}),(0,i.jsx)("h1",{style:{fontSize:"clamp(28px, 6vw, 40px)",fontFamily:G,fontWeight:600,color:y.text,letterSpacing:"-0.015em",lineHeight:1,margin:0},children:"Retours."}),(0,i.jsxs)("div",{style:{marginTop:14,fontSize:13,color:y.textMuted,lineHeight:1.6,display:"flex",flexWrap:"wrap",rowGap:4,columnGap:0},children:[(0,i.jsxs)("span",{style:{whiteSpace:"nowrap"},children:[(0,i.jsx)("span",{style:{fontFamily:K,fontWeight:600,color:y.text,fontSize:13},children:na.all}),(0,i.jsx)("span",{style:{marginLeft:6},children:"au total"})]}),na.received>0&&(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)("span",{"aria-hidden":"true",style:{margin:"0 10px",opacity:.45},children:"\xb7"}),(0,i.jsxs)("span",{style:{whiteSpace:"nowrap"},children:[(0,i.jsx)("span",{style:{fontFamily:K,fontWeight:600,color:y.gold,fontSize:13},children:na.received}),(0,i.jsx)("span",{style:{marginLeft:6,color:y.gold},children:"\xe0 rembourser"})]})]}),na.late>0&&(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)("span",{"aria-hidden":"true",style:{margin:"0 10px",opacity:.45},children:"\xb7"}),(0,i.jsxs)("span",{style:{whiteSpace:"nowrap"},children:[(0,i.jsx)("span",{style:{fontFamily:K,fontWeight:600,color:y.red,fontSize:13},children:na.late}),(0,i.jsx)("span",{style:{marginLeft:6,color:y.red},children:"en retard"})]})]})]})]}),(0,i.jsx)("div",{style:{display:"flex",gap:Q.sm,padding:ng?"".concat(Q.lg,"px ").concat(Q.lg,"px ").concat(Q.sm,"px"):"".concat(Q.lg,"px ").concat(t8?20:32,"px ").concat(Q.sm,"px"),overflowX:"auto",overflowY:"hidden",flexShrink:0,WebkitOverflowScrolling:"touch",scrollbarWidth:"none"},className:"ra-chip-row",children:eV.map(e=>{let t=null===e.id?na.all:na[e.id]||0,n=I===e.id;return(0,i.jsxs)("button",{onClick:()=>M(e.id),"aria-pressed":n,style:{display:"inline-flex",alignItems:"center",gap:6,padding:"8px 14px",minHeight:36,borderRadius:$.pill,border:"1px solid ".concat(n?y.text:y.border),background:n?"".concat(y.text,"08"):"transparent",color:n?y.text:y.textMuted,fontSize:12,fontWeight:n?600:500,fontFamily:G,cursor:"pointer",whiteSpace:"nowrap",flexShrink:0,transition:"border-color 0.18s ease, background 0.18s ease, color 0.18s ease"},children:[(0,i.jsx)("span",{children:e.label}),(0,i.jsx)("span",{style:{fontSize:11,fontFamily:K,color:n?y.text:y.textDim,letterSpacing:"-0.01em"},children:t})]},e.id||"all")})}),(0,i.jsxs)("div",{style:{padding:ng?"".concat(Q.sm,"px ").concat(Q.lg,"px ").concat(Q.md,"px"):"".concat(Q.sm,"px ").concat(t8?20:32,"px ").concat(Q.md,"px"),display:"flex",gap:Q.sm,alignItems:"center",flexWrap:"wrap",borderBottom:"1px solid ".concat(y.border),flexShrink:0},children:[(0,i.jsxs)("div",{style:{flex:1,minWidth:180,position:"relative"},children:[(0,i.jsx)("div",{style:{position:"absolute",left:12,top:"50%",transform:"translateY(-50%)",display:"flex",alignItems:"center",pointerEvents:"none"},children:(0,i.jsx)(ex.search,{size:13,color:y.textDim})}),(0,i.jsx)("input",{value:W,onChange:e=>q(e.target.value),placeholder:"Rechercher commande, client, tracking…",style:{width:"100%",paddingLeft:32,paddingRight:12,paddingTop:9,paddingBottom:9,borderRadius:$.md,border:"1px solid ".concat(y.border),background:y.surfaceAlt,color:y.text,fontSize:12,fontFamily:G,outline:"none",minHeight:38,boxSizing:"border-box"}})]}),!t8&&(0,i.jsx)("div",{style:{display:"flex",gap:4},children:[null,"refund","exchange","credit"].map(e=>{let t=eP(y);return(0,i.jsx)("button",{onClick:()=>F(e),style:{padding:"6px 10px",minHeight:30,borderRadius:$.pill,border:"1px solid ".concat(A===e?y.text:y.border),background:A===e?"".concat(y.text,"08"):"transparent",color:A===e?y.text:y.textMuted,fontSize:10,fontWeight:600,cursor:"pointer",fontFamily:G,whiteSpace:"nowrap",transition:"border-color 0.18s ease, background 0.18s ease, color 0.18s ease"},children:e?t[e].label.slice(0,4):"Tous"},e||"all")})}),(0,i.jsxs)("button",{onClick:()=>ew(!0),"aria-label":"Cr\xe9er un retour",style:{padding:"9px 14px",minHeight:38,borderRadius:$.md,border:"none",background:y.text,color:y.bg,fontSize:12,fontWeight:600,cursor:"pointer",fontFamily:G,display:"inline-flex",alignItems:"center",gap:5,whiteSpace:"nowrap",transition:"background 0.2s ease"},children:[(0,i.jsx)(eB.plus,{size:13,color:y.bg}),!t8&&"Nouveau"]}),(0,i.jsx)("button",{onClick:()=>{let e={};"received"===I&&(e.status="received"),window.open(h(e),"_blank")},"aria-label":"Exporter CSV",title:"Exporter CSV",style:{width:38,height:38,padding:0,borderRadius:$.md,border:"1px solid ".concat(y.border),background:"transparent",color:y.textMuted,cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center",flexShrink:0,transition:"border-color 0.18s ease, color 0.18s ease"},children:(0,i.jsx)(ex.download,{size:14,color:"currentColor"})}),(0,i.jsx)("button",{onClick:nt,"aria-label":"Rafra\xeechir",title:"Rafra\xeechir",style:{width:38,height:38,padding:0,borderRadius:$.md,border:"1px solid ".concat(y.border),background:"transparent",color:y.textMuted,cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center",flexShrink:0,transition:"border-color 0.18s ease, color 0.18s ease"},children:(0,i.jsx)(ex.refresh,{size:14,color:"currentColor"})}),!t8&&(0,i.jsxs)("button",{onClick:nn,disabled:tV,title:"Mettre \xe0 j
1our le suivi colis (La Poste)",style:{padding:"9px 12px",minHeight:38,borderRadius:$.md,border:"1px solid ".concat(y.blue,"40"),background:"transparent",color:y.blue,fontSize:11,fontWeight:600,cursor:"pointer",fontFamily:G,display:"inline-flex",alignItems:"center",gap:5,opacity:tV?.5:1,transition:"border-color 0.18s ease, background 0.18s ease"},children:[(0,i.jsx)(ex.refresh,{size:12,color:"currentColor"}),tV?"Suivi…":"Suivi colis"]})]}),tK&&(0,i.jsxs)("div",{style:{margin:"6px 16px 0",padding:"8px 14px",borderRadius:6,fontSize:12,background:tK.ok?"#e8f5e9":"#fdf0ef",border:"1px solid ".concat(tK.ok?"#4caf50":"#c0392b"),color:tK.ok?"#2e7d32":"#c0392b"},children:[tK.ok?"✓ ":"✗ ",tK.message]}),(0,i.jsx)("div",{style:{flex:1,overflowY:"auto"},children:C?(0,i.jsx)("div",{style:{display:"flex",alignItems:"center",justifyContent:"center",padding:60},children:(0,i.jsx)("span",{style:{fontFamily:G,fontSize:20,color:y.textMuted,letterSpacing:"-0.01em"},children:"Lecture du registre…"})}):0===nd.length?(0,i.jsx)("div",{style:{padding:"60px 32px",textAlign:"left",fontFamily:G,fontSize:22,color:y.textMuted,letterSpacing:"-0.01em"},children:I||A||W?"Aucun retour pour ces filtres.":"Aucun retour \xe0 traiter aujourd'hui."}):(0,i.jsx)("div",{style:{padding:"0 ".concat(ng?Q.md:t8?12:24,"px ").concat(Q.xl,"px")},children:[...nu.map(e=>({r:e,archived:!1})),...np.length>0?[{divider:!0}]:[],...t5?np.map(e=>({r:e,archived:!0})):[]].map(e=>{if(e.divider)return(0,i.jsxs)("button",{onClick:()=>t3(e=>!e),style:{display:"flex",alignItems:"center",justifyContent:"space-between",width:"100%",marginTop:Q.lg,padding:"12px 8px",background:"transparent",border:"none",borderTop:"1px solid ".concat(y.border),color:y.textMuted,fontSize:10,fontWeight:700,letterSpacing:"0.10em",textTransform:"uppercase",fontFamily:G,cursor:"pointer",minHeight:40},children:[(0,i.jsxs)("span",{children:["Archiv\xe9s ",(0,i.jsx)("span",{style:{fontFamily:K,marginLeft:4},children:np.length})]}),(0,i.jsx)("span",{style:{display:"inline-flex",transform:t5?"rotate(180deg)":"rotate(0deg)",transition:"transform 0.2s ease"},children:(0,i.jsx)(eB.chevronDown,{size:12,color:"currentColor"})})]},"__archived_divider__");let{r:t,archived:n}=e,r=t.id===D,l={pending:{label:"En attente",color:y.orange},approved:{label:"Approuv\xe9",color:y.blue},label_generated:{label:"\xc9tiquette g\xe9n\xe9r\xe9e",color:y.blue},in_transit:{label:"En transit",color:y.blue},received:{label:"Re\xe7u",color:y.green},refunded:{label:"Rembours\xe9",color:y.green},exchanged:{label:"\xc9chang\xe9",color:y.purple},rejected:{label:"Rejet\xe9",color:y.red},awaiting_customer:{label:"Choix client",color:y.orange},to_reship:{label:"\xc0 renvoyer",color:y.purple},reshipped:{label:"Renvoy\xe9",color:y.green}}[t.status]||{label:t.status||"—",color:y.textMuted},o=eP(y)[t.type]||{label:t.type,color:y.textMuted},s="received"===t.status||"to_reship"===t.status;return(0,i.jsxs)("button",{onClick:()=>{R(t.id),tE(!1)},"aria-pressed":r,className:"ra-row",style:{display:"flex",alignItems:"center",gap:Q.md,width:"100%",padding:"14px 12px",background:r?"".concat(y.text,"08"):"transparent",border:"none",borderBottom:"1px solid ".concat(y.border),borderLeft:r?"2px solid ".concat(y.text):"2px solid transparent",cursor:"pointer",textAlign:"left",fontFamily:G,color:y.text,opacity:n?.55:1,transition:"background 0.15s ease, border-color 0.15s ease",minHeight:56},children:[(0,i.jsx)("span",{style:{fontFamily:K,fontSize:13,fontWeight:s&&!n?700:600,color:y.text,letterSpacing:"-0.01em",flexShrink:0,minWidth:t8?78:92},children:t.order_name||(t.order_id?"#".concat(t.order_id):"—")}),(0,i.jsx)("span",{style:{fontSize:9,fontWeight:600,color:o.color,textTransform:"uppercase",letterSpacing:"0.10em",flexShrink:0,display:t8?"none":"inline",minWidth:58},children:o.label.slice(0,t8?3:9)}),(0,i.jsxs)("span",{style:{display:"inline-flex",alignItems:"center",gap:6,fontSize:11,color:l.color,flexShrink:0,minWidth:124*!t8,whiteSpace:"nowrap"},children:[(0,i.jsx)("span",{style:{width:6,height:6,borderRadius:"50%",background:l.color}}),!t8&&l.label]}),(0,i.jsxs)("span",{style:{flex:1,fontSize:12,color:y.textMuted,whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis",lineHeight:1.45,minWidth:0},children:[t.customer_name||t.customer_email||"—",t.reason?" \xb7 ".concat(t.reason):""]}),"manual"===t.source&&(0,i.jsx)("span",{style:{fontSize:9,color:y.purple,fontWeight:700,padding:"2px 7px",borderRadius:$.sm,background:"".concat(y.purple,"10"),border:"1px solid ".concat(y.purple,"25"),textTransform:"uppercase",letterSpacing:"0.05em",flexShrink:0},children:"Boutique"}),t.override_eligibility&&(0,i.jsx)("span",{style:{fontSize:9,color:y.orange,fontWeight:700,padding:"2px 7px",borderRadius:$.sm,background:"".concat(y.orange,"10"),border:"1px solid ".concat(y.orange,"25"),textTransform:"uppercase",letterSpacing:"0.05em",flexShrink:0},children:"Hors d\xe9lai"}
1),(0,i.jsx)("span",{style:{fontSize:10,color:y.textDim,whiteSpace:"nowrap",flexShrink:0,minWidth:50,textAlign:"right"},children:eG(t.created_at)})]},t.id)})})}),(0,i.jsx)("style",{children:'\n          .ra-chip-row::-webkit-scrollbar { display: none; }\n          .ra-row:hover:not([aria-pressed="true"]) {\n            background: '.concat(y.surfaceAlt," !important;\n          }\n        ")})]}),ng&&(0,i.jsxs)("div",{style:{flex:1,overflowY:"auto",padding:t8?Q.lg:Q.xxl,display:"flex",flexDirection:"column",gap:Q.xl,background:y.bg},children:[t8&&(0,i.jsxs)("button",{onClick:()=>R(null),style:{...ei(!1,y),display:"flex",alignItems:"center",gap:6,fontSize:11},children:[(0,i.jsx)(eB.arrowLeft,{size:14,color:y.textMuted}),"Retour a la liste"]}),(0,i.jsxs)("div",{style:{paddingBottom:Q.lg,borderBottom:"1px solid ".concat(y.border)},children:[(0,i.jsxs)("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"flex-start",marginBottom:10},children:[(0,i.jsx)("span",{style:{fontSize:22,fontWeight:700,color:y.text,lineHeight:1,fontFamily:K,letterSpacing:"-0.025em"},children:ng.order_name}),!t8&&(0,i.jsx)("button",{onClick:()=>R(null),style:{width:26,height:26,borderRadius:$.md,border:"1px solid ".concat(y.border),background:"transparent",cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center",transition:"background 0.15s ease",flexShrink:0},onMouseEnter:e=>e.currentTarget.style.background=y.surfaceAlt,onMouseLeave:e=>e.currentTarget.style.background="transparent",children:(0,i.jsx)(eB.x,{size:13,color:y.textMuted})})]}),(0,i.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:8,flexWrap:"wrap",marginBottom:8},children:[(0,i.jsx)(eU,{status:ng.status,t:y}),(0,i.jsx)(eN,{type:ng.type,t:y}),"manual"===ng.source&&(0,i.jsx)("span",{style:{fontSize:9,color:y.purple,fontWeight:700,padding:"2px 7px",borderRadius:$.sm,background:"".concat(y.purple,"10"),border:"1px solid ".concat(y.purple,"25"),textTransform:"uppercase",letterSpacing:"0.05em"},children:"Achat boutique"}),(0,i.jsx)("span",{style:{fontSize:10,color:y.textDim,opacity:.5},children:"\xb7"}),(0,i.jsx)("span",{style:{fontSize:10,color:y.textDim},children:eG(ng.created_at)})]}),(0,i.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:6,flexWrap:"wrap"},children:[ng.customer_name&&(0,i.jsx)("span",{style:{fontSize:12,color:y.text,fontWeight:500},children:ng.customer_name}),ng.customer_name&&ng.customer_email&&(0,i.jsx)("span",{style:{fontSize:11,color:y.textDim,opacity:.4},children:"\xb7"}),ng.customer_email&&(0,i.jsx)("span",{style:{fontSize:11,color:y.textMuted},children:ng.customer_email})]})]}),"manual"===ng.source&&(0,i.jsxs)("div",{style:{...nU,padding:"10px ".concat(Q.lg,"px"),display:"flex",gap:Q.lg,alignItems:"center",flexWrap:"wrap",border:"1px solid ".concat(y.purple,"25"),background:"".concat(y.purple,"04")},children:[(0,i.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:6},children:[(0,i.jsx)(eB.tag,{size:12,color:y.purple}),(0,i.jsx)("span",{style:{fontSize:10,color:y.textDim,textTransform:"uppercase",fontWeight:600,letterSpacing:"0.05em"},children:"Achat"}),(0,i.jsx)("span",{style:{fontSize:12,color:y.text,fontWeight:600},children:ng.purchase_date?new Date(ng.purchase_date).toLocaleDateString("fr-FR",{day:"numeric",month:"short",year:"numeric"}):"Date inconnue"})]}),ng.purchase_location&&(0,i.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:6},children:[(0,i.jsx)("span",{style:{fontSize:10,color:y.textDim,textTransform:"uppercase",fontWeight:600,letterSpacing:"0.05em"},children:"Lieu"}),(0,i.jsx)("span",{style:{fontSize:12,color:y.text},children:ng.purchase_location})]}),(0,i.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:6},children:[(0,i.jsx)("span",{style:{fontSize:10,color:y.textDim,textTransform:"uppercase",fontWeight:600,letterSpacing:"0.05em"},children:"Paiement"}),(0,i.jsx)("span",{style:{fontSize:12,color:y.text},children:{especes:"Esp\xe8ces",cb:"CB",cheque:"Ch\xe8que"}[ng.payment_method]||ng.payment_method||"—"})]}),ng.receipt_ref&&(0,i.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:6}
1,children:[(0,i.jsx)("span",{style:{fontSize:10,color:y.textDim,textTransform:"uppercase",fontWeight:600,letterSpacing:"0.05em"},children:"Ticket"}),(0,i.jsx)("code",{style:{fontFamily:K,fontSize:11,color:y.text},children:ng.receipt_ref})]}),(0,i.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:6},children:[(0,i.jsx)("span",{style:{fontSize:10,color:y.textDim,textTransform:"uppercase",fontWeight:600,letterSpacing:"0.05em"},children:"Retour"}),(0,i.jsx)("span",{style:{fontSize:12,color:y.text},children:"in_store"===ng.drop_off?"D\xe9pos\xe9 en boutique":"Envoi postal"})]})]}),ng.tracking_code&&(0,i.jsxs)("div",{style:{...nU,display:"flex",alignItems:"center",gap:Q.md,padding:"".concat(Q.md,"px ").concat(Q.lg,"px")},children:[(0,i.jsx)("div",{style:{width:28,height:28,borderRadius:$.md,background:"".concat(y.blue,"10"),display:"flex",alignItems:"center",justifyContent:"center",flexShrink:0},children:(0,i.jsx)(eB.pkg,{size:14,color:y.blue})}),(0,i.jsxs)("div",{style:{flex:1},children:[(0,i.jsxs)("div",{style:{fontSize:9,color:y.textDim,fontWeight:600,textTransform:"uppercase",letterSpacing:"0.04em"},children:["Tracking ","colissimo"===ng.carrier?"Colissimo":"dpd"===ng.carrier?"DPD":""]}),(0,i.jsx)("code",{style:{fontFamily:K,fontSize:12,color:y.text,letterSpacing:"0.02em"},children:ng.tracking_code})]}),(0,i.jsxs)("div",{style:{display:"flex",gap:Q.xs},children:[(0,i.jsxs)("button",{onClick:()=>navigator.clipboard.writeText(ng.tracking_code),style:{...ei(!1,y),padding:"4px 8px",fontSize:10,display:"flex",alignItems:"center",gap:4},children:[(0,i.jsx)(eB.copy,{size:11,color:y.textMuted}),"Copier"]}),"colissimo"===ng.carrier&&(0,i.jsxs)("a",{href:"https://www.laposte.fr/outils/suivre-vos-envois?code=".concat(encodeURIComponent(ng.tracking_code)),target:"_blank",rel:"noopener noreferrer",style:{...ei(!1,y),padding:"4px 8px",fontSize:10,display:"flex",alignItems:"center",gap:4,textDecoration:"none"},children:[(0,i.jsx)(eB.externalLink,{size:11,color:y.blue}),(0,i.jsx)("span",{style:{color:y.blue},children:"Suivre"})]}),(0,i.jsxs)("button",{onClick:nl,disabled:tO,style:{...ei(!1,y),padding:"4px 8px",fontSize:10,display:"flex",alignItems:"center",gap:4,opacity:tO?.6:1,cursor:tO?"default":"pointer"},children:[(0,i.jsx)(eB.mail,{size:11,color:y.textMuted}),tO?"Envoi...":"Renvoyer"]})]})]}),(ng.refund_total>0||ng.credit_total>0)&&(0,i.jsxs)("div",{style:{...nU,padding:"10px ".concat(Q.lg,"px"),display:"flex",gap:Q.xl,alignItems:"center",flexWrap:"wrap"},children:[ng.refund_total>0&&(()=>{let e=function(e){let{waiveFee:t=!1,items:n=null}=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},i=t?0:Number((null==e?void 0:e.return_fee)||0),r=n||("string"==typeof(null==e?void 0:e.items)?(()=>{try{return JSON.parse(e.items)}catch(e){return[]}})():null==e?void 0:e.items)||[];return r.some(e=>"refund"===eF(e).action)?function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[],t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},{feeEnabled:n=!1,feeAmount:i=0,applyFee:r=!0,discountPercent:l=0,creditBonusPercent:o=10}=t,s=0,a=0,d=0;for(let t of e){let e=eE(t),n=eF(t);"refund"===n.action?(s+=e,a+=e*(n.discountPercent||Number(l)||0)/100):"credit"===n.action&&(d+=e*(1+(Number(o)||0)/100))}let c=eM(s),u=eM(a),p=eM(c-u),g=eM(Math.min(Math.max(0,Number(r&&n&&c>0?i:0)||0),p)),x=eM(p-g),h=c>0?eM(u/c*100):0;return{refundGross:c,discountPercent:h,discountAmount:u,returnFee:g,refundNet:x,creditTotal:eM(d)}}(r,{feeEnabled:i>0,feeAmount:i,discountPercent:(null==e?void 0:e.discount_percent)||0}):{...function(){let{gross:e=0,discountPercent:t=0,fee:n=0}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},i=eM(Math.max(0,e)),r=Math.min(100,Math.max(0,Number(t)||0)),l=eM(i*r/100),o=eM(i-l),s=eM(Math.min(Math.max(0,Number(n)||0),o)),a=eM(o-s);return{refundGross:i,discountPercent:r,discountAmount:l,returnFee:s,refundNet:a}}({gross:(null==e?void 0:e.refund_gross)!=null?Number(e.refund_gross):Number((null==e?void 0:e.refund_total)||0),discountPercent:(null==e?void 0:e.discount_percent)||0,fee:i}),creditTotal:Number((null==e?void 0:e.credit_total)||0)}}(ng,{waiveFee:Y&&"received"===ng.status,items:nx}),t=e.discountAmount>0||e.returnFee>0||Number(ng.return_fee)>0;return(0,i.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:8,flexWrap:"wrap"},children:[(0,i.jsx)(eB.dollarSign,{size:12,color:y.blue}
1),(0,i.jsx)("span",{style:{fontSize:10,color:y.textDim,textTransform:"uppercase",fontWeight:600,letterSpacing:"0.05em"},children:"Remboursement"}),(0,i.jsxs)("span",{style:{fontFamily:K,fontSize:14,fontWeight:700,color:y.blue},children:[e.refundNet.toFixed(2),"€"]}),t&&(0,i.jsxs)("span",{style:{fontSize:10,color:y.textMuted,fontFamily:K},children:["= ",e.refundGross.toFixed(2),"€",e.discountAmount>0&&(0,i.jsxs)(i.Fragment,{children:[" − d\xe9cote ",e.discountAmount.toFixed(2),"€"]}),e.returnFee>0&&(0,i.jsxs)(i.Fragment,{children:[" − frais ",e.returnFee.toFixed(2),"€"]}),0===e.returnFee&&Number(ng.return_fee)>0&&Y&&(0,i.jsxs)(i.Fragment,{children:[" (frais ",Number(ng.return_fee).toFixed(2),"€ offerts)"]})]}),ng.shopify_refund_id&&(0,i.jsx)("span",{style:{fontSize:9,color:y.textDim,fontFamily:K,opacity:.6},children:ng.shopify_refund_id})]})})(),ng.refund_total>0&&ng.credit_total>0&&(0,i.jsx)("div",{style:{width:1,height:16,background:y.border,flexShrink:0}}),ng.credit_total>0&&(0,i.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:8},children:[(0,i.jsx)(eB.tag,{size:12,color:y.green}),(0,i.jsx)("span",{style:{fontSize:10,color:y.textDim,textTransform:"uppercase",fontWeight:600,letterSpacing:"0.05em"},children:"Avoir"}),(0,i.jsxs)("span",{style:{fontFamily:K,fontSize:14,fontWeight:700,color:y.green},children:[ng.credit_total,"€"]}),ng.shopify_discount_code&&(0,i.jsx)("code",{style:{fontFamily:K,background:y.surfaceAlt,padding:"1px 6px",borderRadius:$.sm,fontSize:10,color:y.textMuted},children:ng.shopify_discount_code})]})]}),(0,i.jsxs)("div",{children:[(0,i.jsxs)(eK,{t:y,children:["Articles (",nx.length,")"]}),(0,i.jsx)("div",{style:{display:"flex",flexDirection:"column",gap:Q.sm},children:nx.map((e,t)=>{var n;return(0,i.jsxs)("div",{style:{...nU,padding:Q.md,display:"flex",gap:Q.md,alignItems:"flex-start"},children:[e.image&&(0,i.jsx)("div",{style:{width:44,height:44,borderRadius:$.md,overflow:"hidden",flexShrink:0,border:"1px solid ".concat(y.border)},children:(0,i.jsx)("img",{src:e.image,alt:"",style:{width:"100%",height:"100%",objectFit:"cover"}})}),(0,i.jsxs)("div",{style:{flex:1,minWidth:0},children:[(0,i.jsx)("div",{style:{fontWeight:600,fontSize:12,color:y.text,lineHeight:1.3},children:e.title}),e.variant&&(0,i.jsx)("div",{style:{fontSize:10,color:y.textMuted,marginTop:1},children:e.variant}),(0,i.jsxs)("div",{style:{display:"flex",gap:Q.sm,marginTop:6,flexWrap:"wrap",alignItems:"center"},children:[(0,i.jsxs)("span",{style:{fontSize:10,color:y.textDim},children:["Qt\xe9: ",e.qty||1]}),(0,i.jsx)("span",{style:{fontSize:8,color:y.border},children:"•"}),(0,i.jsxs)("span",{style:{fontSize:10,color:y.textDim,fontFamily:K},children:[e.price,"€"]}),e.reason&&(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)("span",{style:{fontSize:8,color:y.border},children:"•"}),(0,i.jsx)("span",{style:{fontSize:10,color:y.orange,fontWeight:600,padding:"1px 6px",borderRadius:$.sm,background:"".concat(y.orange,"08")},children:eO[e.reason]||e.reason})]})]}),e.action&&(0,i.jsxs)("div",{style:{marginTop:6,display:"flex",alignItems:"center",gap:6,flexWrap:"wrap"},children:[(0,i.jsx)(eN,{type:e.action,t:y}),"exchange"===e.action&&e.exchange_variant_title&&(0,i.jsxs)("span",{style:{fontSize:10,color:y.purple,display:"flex",alignItems:"center",gap:3},children:[(0,i.jsx)(eB.arrowRight,{size:10,color:y.purple}),e.exchange_variant_title]}),(0,i.jsx)(eQ,{item:e,t:y})]}),"received"===ng.status&&nk.includes(t)&&(()=>{let n=nS(t),r="rejected"===n.status,l=(e,t)=>({padding:"3px 10px",borderRadius:$.pill,fontSize:10,fontWeight:600,cursor:"pointer",fontFamily:G,border:"1px solid ".concat(e?t:y.border),background:e?t:"transparent",color:e?y.bg:y.textMuted});return(0,i.jsxs)("div",{style:{marginTop:8,display:"flex",flexDirection:"column",gap:6},children:[(0,i.jsxs)("div",{style:{display:"flex",gap:6},children:[(0,i.jsx)("button",{onClick:()=>nj(t,{status:"accepted"}),style:l(!r,y.green),children:"Accepter"}),(0,i.jsx)("button",{onClick:()=>nj(t,{status:"rejected"}),style:l(r,y.red),children:"Refuser"})]}),r&&(0,i.jsxs)("div",{style:{display:"flex",flexDirection:"column",gap:6,padding:Q.sm,borderRadius:$.sm,background:"".concat(y.red,"06"),border:"1px solid ".concat(y.red,"18")},children:[(0,i.jsx)("input",{value:n.reason,onChange:e=>nj(t,{reason:e.target.value}),placeholder:H?"Motif : ".concat(H," (commun)"):"Motif du refus pour cet article (obligatoire)",style:{...Z(y),fontSize:11,padding:"6px 8px"}}),(0,i.jsxs)("label",{style:{display:"flex",alignItems:"center",gap:6,fontSize:11,color:y.text,fontFamily:G,flexWrap:"wrap"},children:[(0,i.jsx)("input",{type:"checkbox",checked:n.discountOn,onChange:e=>nj(t,{discountOn:e.target.checked})}),"D\xe9cote",(0,i.jsx)("input",{type:"number",min:"1",max:"90",value:n.discount,disabled:!n.discountOn,onChange:e=>nj(t,{discount:e.target.value}),style:{...Z(y),width:56,fontSize:11,padding:"3px 6px"}}),"%",n.discountOn&&Number(n.discount)>0&&(0,i.jsxs)("span",{style:{color:y.textMuted,fontFamily:K,fontSize:10},children:["→ ",(eE(e)*(1-Number(n.discount)/100)).toFixed(2),"€"]})]}),(0,i.jsxs)("label",{style:{display:"flex",alignItems:"center",gap:6,fontSize:11,color:y.text,fontFamily:G},children:[(0,i.jsx)("input",{type:"checkbox",checked:n.reship,onChange:e=>nj(t,{reship:e.target.checked})}),"Proposer le renvoi (DPD)"]}),!n.discountOn&&!n.reship&&(0,i.jsx)("span",{style:{fontSize:10,
1color:y.textDim},children:"Aucune option : refus d\xe9finitif pour cet article."})]})]})})()]}),(null==(n=e.photos)?void 0:n.length)>0&&(0,i.jsx)("div",{style:{display:"flex",gap:4,flexShrink:0},children:e.photos.map((e,t)=>(0,i.jsx)("div",{onClick:()=>eS(e),style:{width:44,height:44,borderRadius:$.sm,overflow:"hidden",cursor:"pointer",border:"1px solid ".concat(y.border),transition:"border-color 0.15s ease"},onMouseEnter:e=>e.currentTarget.style.borderColor=y.textMuted,onMouseLeave:e=>e.currentTarget.style.borderColor=y.border,children:(0,i.jsx)("img",{src:e,alt:"",style:{width:"100%",height:"100%",objectFit:"cover"}})},t))})]},t)})})]}),(nm||nf)&&(0,i.jsxs)("div",{children:[(0,i.jsxs)("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",marginBottom:Q.sm},children:[(0,i.jsx)(eK,{t:y,style:{margin:0},children:"Adresses"}),nm&&!tJ&&(0,i.jsxs)("button",{onClick:()=>{t$({...nm}),t2(null),tX(!0)},style:{fontSize:11,color:y.blue,background:"".concat(y.blue,"10"),border:"1px solid ".concat(y.blue,"30"),borderRadius:$.sm,padding:"3px 10px",cursor:"pointer",display:"flex",alignItems:"center",gap:4},children:[(0,i.jsx)(eB.edit,{size:11,color:y.blue}),"Modifier l’adresse"]})]}),tJ?(0,i.jsxs)("div",{style:{...nU,padding:Q.lg,display:"flex",flexDirection:"column",gap:10},children:[(0,i.jsx)("div",{style:{fontSize:9,color:y.textDim,textTransform:"uppercase",fontWeight:600,letterSpacing:"0.05em",marginBottom:2},children:"Adresse d’exp\xe9dition du retour"}),(()=>{let e=(e,t)=>(0,i.jsxs)("div",{children:[(0,i.jsx)("div",{style:{fontSize:10,color:y.textMuted,marginBottom:3,fontWeight:600},children:t}),(0,i.jsx)("input",{value:tQ[e]||"",onChange:t=>t$(n=>({...n,[e]:t.target.value})),style:{width:"100%",padding:"7px 10px",fontSize:12,border:"1px solid ".concat(y.border),borderRadius:$.sm,background:y.surfaceAlt,color:y.text,boxSizing:"border-box",fontFamily:G,outline:"none",transition:"border-color 0.15s ease"},onFocus:e=>e.target.style.borderColor=y.gold,onBlur:e=>e.target.style.borderColor=y.border})]},e);return(0,i.jsxs)(i.Fragment,{children:[(0,i.jsxs)("div",{style:{display:"grid",gridTemplateColumns:t8?"1fr":"1fr 1fr",gap:10},children:[e("first_name","Pr\xe9nom"),e("last_name","Nom")]}),e("address1","Adresse"),e("address2","Compl\xe9ment"),(0,i.jsxs)("div",{style:{display:"grid",gridTemplateColumns:"1fr 2fr",gap:10},children:[e("zip","Code postal"),e("city","Ville")]}),e("phone","T\xe9l\xe9phone")]})})(),t1&&(0,i.jsx)("div",{style:{fontSize:11,padding:"8px 12px",borderRadius:$.sm,background:t1.ok?"".concat(y.green,"12"):"".concat(y.red,"12"),color:t1.ok?y.green:y.red},children:t1.ok?"Adresse mise \xe0 jour.":t1.message}),(0,i.jsxs)("div",{style:{display:"flex",gap:Q.sm,marginTop:2},children:[(0,i.jsx)("button",{onClick:no,disabled:tZ,style:{flex:1,padding:"8px 0",fontSize:12,fontWeight:600,background:y.text,color:y.bg,border:"none",borderRadius:$.sm,cursor:tZ?"default":"pointer",opacity:tZ?.6:1,fontFamily:G,transition:"opacity 0.15s ease"},children:tZ?"Enregistrement...":"Enregistrer"}),(0,i.jsx)("button",{onClick:()=>{tX(!1),t2(null)},disabled:tZ,style:{padding:"8px 14px",fontSize:12,fontFamily:G,background:"transparent",color:y.textMuted,border:"1px solid ".concat(y.border),borderRadius:$.sm,cursor:"pointer"},children:"Annuler"})]})]}):(0,i.jsxs)("div",{style:{display:"flex",gap:Q.md,flexWrap:"wrap"},children:[nm&&(0,i.jsx)(eH,{t:y,sectionCard:nU,icon:(0,i.jsx)(eB.pkg,{size:12,color:y.blue}),iconBg:"".concat(y.blue,"10"),label:ny?"Exp\xe9dition du retour":"Adresse du client",address:nm,email:ng.customer_email}),nf&&(0,i.jsx)(eH,{t:y,sectionCard:nU,icon:(0,i.jsx)(eB.arrowRight,{size:12,color:y.purple}),iconBg:"".concat(y.purple,"10"),label:"Livraison de l'\xe9change",address:nf,email:ng.customer_email})]})]}),(0,i.jsxs)("div",{children:[(0,i.jsx)(eK,{t:y,children:"Historique"}),(0,i.jsx)("div",{style:{...nU,padding:"".concat(Q.md,"px ").concat(Q.lg,"px")},children:(()=>{let e=!!ng.label_url||!!ng.tracking_code,t=["in_transit","received","processed"].includes(ng.status),n=["received","processed"].includes(ng.status),i=["processed","rejected","reshipped"].includes(ng.status),r=nh(ng.rejection_offer),l=!!r&&nx.some(e=>eW(e).offer),o=["to_reship","reshipped"].includes(ng.status),s="in_store"===ng.drop_off;return[{label:"manual"===ng.source?"Retour cr\xe9\xe9 (achat boutique)":"Demande cr\xe9\xe9e",date:ng.created_at,done:!0},...s?[]:[{label:"\xc9tiquette g\xe9n\xe9r\xe9e",date:e?ng.updated_at:null,done:e},...e?[{label:"Email envoy\xe9 : \xe9tiquette + suivi",date:e?ng.updated_at:null,done:e,isEmail
1:!0}]:[],{label:"Colis en transit",date:null,done:t}],{label:s?"Article d\xe9pos\xe9 en boutique":"Colis re\xe7u",date:ng.received_at,done:n},...n?[{label:"Email envoy\xe9 : colis re\xe7u",date:ng.received_at,done:n,isEmail:!0}]:[],...l?[{label:"Refus avec options propos\xe9es",date:r.offered_at,done:!0},{label:"Email envoy\xe9 : proposition".concat(r.sent_count>1?" (\xd7".concat(r.sent_count,")"):""),date:r.last_sent_at||r.offered_at,done:!0,isEmail:!0},{label:"reship"===ng.customer_choice?"Choix client : renvoi":"discounted_refund"===ng.customer_choice?"Choix client : remboursement d\xe9cot\xe9":"mixed"===ng.customer_choice?"Choix client : d\xe9cote + renvoi":"Choix du client",date:ng.customer_choice_at,done:!!ng.customer_choice}]:[],...o?[{label:"Article renvoy\xe9 (DPD)",date:ng.reshipped_at,done:"reshipped"===ng.status},..."reshipped"===ng.status?[{label:"Email envoy\xe9 : suivi du renvoi",date:ng.reshipped_at,done:!0,isEmail:!0}]:[]]:[{label:i&&"rejected"===ng.status?"Refus\xe9":"Trait\xe9",date:ng.processed_at,done:i},...i?[{label:"Email envoy\xe9 : ".concat("rejected"===ng.status?"retour refuse":"retour trait\xe9"),date:ng.processed_at,done:i,isEmail:!0}]:[]]]})().map((e,t,n)=>{var r,l;let o=t===n.length-1,s=e.isEmail,a=s?e.done?y.blue:y.border:e.done?"rejected"===ng.status&&o?y.red:y.green:y.border,d=e.done&&(null==(r=n[t+1])?void 0:r.done)?(null==(l=n[t+1])?void 0:l.isEmail)?y.blue:y.green:y.border;return(0,i.jsxs)("div",{style:{display:"flex",gap:Q.lg,alignItems:"flex-start",position:"relative"},children:[(0,i.jsxs)("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",width:16,flexShrink:0,paddingTop:2},children:[s&&e.done?(0,i.jsx)("div",{style:{width:14,height:14,display:"flex",alignItems:"center",justifyContent:"center",flexShrink:0},children:(0,i.jsx)(eB.mail,{size:12,color:y.blue})}):(0,i.jsx)("div",{style:{width:e.done?10:8,height:e.done?10:8,borderRadius:"50%",background:e.done?a:"transparent",border:e.done?"2px solid ".concat(a):"2px solid ".concat(y.border),flexShrink:0,boxShadow:e.done?"0 0 0 3px ".concat(a,"12"):"none",transition:"all 0.2s ease"}}),!o&&(0,i.jsx)("div",{style:{width:1.5,flex:1,minHeight:20,background:d,marginTop:3,transition:"background 0.2s ease"}})]}),(0,i.jsxs)("div",{style:{paddingBottom:o?0:Q.md,flex:1},children:[(0,i.jsx)("div",{style:{fontSize:s?11:12,fontWeight:e.done?s?500:600:400,color:e.done?s?y.blue:y.text:y.textDim,lineHeight:1.3,fontStyle:s?"italic":"normal"},children:e.label}),e.date&&(0,i.jsx)("div",{style:{fontSize:10,color:y.textMuted,marginTop:1},children:eG(e.date)})]})]},t)})})]}),nx.some(e=>"rejected"===eW(e).status)&&(()=>{let e=nh(ng.rejection_offer)||{},t=nh(ng.reship_address),n="rejected"===ng.status,r=n?y.red:y.orange,l=nx.some(eA);return(0,i.jsxs)("div",{style:{...nU,background:"".concat(r,"06"),border:"1px solid ".concat(r,"18"),padding:Q.lg,display:"flex",flexDirection:"column",gap:Q.md},children:[(0,i.jsxs)("div",{style:{fontSize:10,color:r,fontWeight:600,textTransform:"uppercase",display:"flex",alignItems:"center",gap:6},children:[(0,i.jsx)(eB.x,{size:12,color:r}),n?"Retour refus\xe9":"Articles refus\xe9s"]}),nx.map((e,t)=>{var n;let r=eW(e);return"rejected"!==r.status?null:(0,i.jsxs)("div",{style:{fontSize:11,color:y.text,lineHeight:1.6},children:[(0,i.jsxs)("strong",{children:[e.title,e.variant?" (".concat(e.variant,")"):""]})," : ",r.reason,r.offer&&!r.choice&&(0,i.jsxs)("div",{style:{color:y.textMuted},children:["Options : ",[r.offer.discount_percent?"d\xe9cote ".concat(r.offer.discount_percent," %"):null,r.offer.reship?"renvoi DPD":null].filter(Boolean).join(" ou "),"rejected"===r.settled_by?"":" \xb7 en attente du client"]}),!r.offer&&(0,i.jsx)("div",{style:{color:y.textMuted},children:"Refus d\xe9finitif"}),r.choice&&(0,i.jsxs)("div",{style:{color:y.green},children:["Choix ","admin"===r.chosen_by?"saisi par l'admin":"du client"," : ","reship"===r.choice?"renvoi de l'article":"remboursement d\xe9cot\xe9 ".concat(null==(n=r.offer)?void 0:n.discount_percent," %"),"refund"===r.settled_by||"manual"===r.settled_by?" \xb7 rembours\xe9":"reship"===r.settled_by?" \xb7 renvoy\xe9":""]})]},t)}
1),l&&e.expires_at&&(0,i.jsxs)("div",{style:{fontSize:10,color:new Date(e.expires_at)<Date.now()?y.red:y.textDim},children:["Lien ",new Date(e.expires_at)<Date.now()?"expir\xe9 depuis le":"valable jusqu'au"," ",new Date(e.expires_at).toLocaleDateString("fr-FR"),e.sent_count>1?" \xb7 envoy\xe9 ".concat(e.sent_count," fois"):""]}),t&&(0,i.jsxs)("div",{style:{fontSize:11,color:y.textMuted,lineHeight:1.5,padding:"".concat(Q.sm,"px ").concat(Q.md,"px"),background:"".concat(y.green,"10"),borderRadius:$.sm,border:"1px solid ".concat(y.green,"25")},children:[(0,i.jsx)("strong",{style:{color:y.text},children:"Adresse de renvoi"}),(0,i.jsx)("br",{}),"".concat(t.first_name||""," ").concat(t.last_name||"").trim(),(0,i.jsx)("br",{}),t.address1,t.address2?", ".concat(t.address2):"",(0,i.jsx)("br",{}),t.zip," ",t.city," (",t.country_code,")",(0,i.jsx)("br",{}),t.phone," \xb7 ",t.email]}),ng.reship_tracking&&(0,i.jsxs)("div",{style:{fontSize:11,color:y.textMuted},children:["Suivi DPD renvoi : ",(0,i.jsx)("a",{href:"https://trace.dpd.fr/fr/trace/".concat(encodeURIComponent(ng.reship_tracking)),target:"_blank",rel:"noreferrer",style:{color:y.text,fontFamily:K},children:ng.reship_tracking})]})]})})(),(0,i.jsxs)("div",{children:[(0,i.jsx)(eK,{t:y,children:"Notes internes"}),(0,i.jsx)("textarea",{value:eh,onChange:e=>em(e.target.value),placeholder:"Ajouter une note interne...",style:{...Z(y),minHeight:64,resize:"vertical",fontSize:11,lineHeight:1.6,fontFamily:G}}),(0,i.jsxs)("button",{onClick:nW,style:{...ei(!1,y),marginTop:Q.sm,fontSize:10,display:"flex",alignItems:"center",gap:5},children:[(0,i.jsx)(eB.save,{size:11,color:y.textMuted}),"Sauvegarder"]})]}),!["processed","rejected","reshipped"].includes(ng.status)&&(0,i.jsxs)("div",{style:{...nU,padding:Q.lg,display:"flex",flexDirection:"column",gap:Q.lg,border:"1px solid ".concat(y.text,"12"),background:"".concat(y.text,"03")},children:[(0,i.jsx)("div",{style:{fontSize:9,color:y.textDim,textTransform:"uppercase",fontWeight:600,letterSpacing:"0.07em"},children:"Actions"}),(0,i.jsxs)("div",{style:{display:"flex",gap:Q.sm,flexWrap:"wrap"},children:["pending"===ng.status&&!ng.tracking_code&&tD.length>0&&(0,i.jsxs)("button",{onClick:()=>tT(!0),style:nN(y.green,y.bg,!1),children:[(0,i.jsx)(ex.download,{size:13,color:y.bg}),"G\xe9n\xe9rer l'\xe9tiquette"]}),ng.tracking_code&&tD.length>0&&(0,i.jsxs)("button",{onClick:()=>{tT(!0),tH(!0)},style:nN(y.orange,y.bg,!1),children:[(0,i.jsx)(eB.repeat,{size:13,color:y.bg}),"R\xe9g\xe9n\xe9rer l'\xe9tiquette"]}),"pending"===ng.status&&(0,i.jsxs)("button",{onClick:()=>nq("label_generated"),disabled:E,style:nN(y.orange,y.bg,E),children:[(0,i.jsx)(eB.tag,{size:12,color:y.bg}),"\xc9tiquette g\xe9n\xe9r\xe9e"]}),["pending","label_generated"].includes(ng.status)&&(0,i.jsxs)("button",{onClick:()=>nq("in_transit"),disabled:E,style:nN(y.blue,y.bg,E),children:[(0,i.jsx)(eB.pkg,{size:12,color:y.bg}),"En transit"]}),["label_generated","in_transit"].includes(ng.status)&&(0,i.jsxs)("button",{onClick:()=>nq("received"),disabled:E,style:nN(y.orange,y.bg,E),children:[(0,i.jsx)(eB.alertCircle,{size:12,color:y.bg}),"Colis re\xe7u"]}),"received"===ng.status&&(0,i.jsxs)(i.Fragment,{children:[(0,i.jsxs)("button",{onClick:nz,disabled:E||!n_,style:nN(nw?y.orange:y.green,y.bg,E||!n_),children:[(0,i.jsx)(eB.check,{size:12,color:y.bg}),E?"Traitement...":nw?"Valider (".concat(nC," accept\xe9").concat(nC>1?"s":"",", ").concat(nw," refus\xe9").concat(nw>1?"s":"",")"):"Valider le retour"]}),nw<nk.length&&(0,i.jsxs)("button",{onClick:()=>{N(e=>{let t={...e};for(let e of nk)t[e]={...nS(e),status:"rejected"};return t})},disabled:E,style:{...nN("transparent",y.red,E),border:"1px solid ".concat(y.red,"30")},children:[(0,i.jsx)(eB.x,{size:12,color:y.red}),"Tout refuser"]})]}),"awaiting_customer"===ng.status&&(0,i.jsxs)(i.Fragment,{children:[(0,i.jsxs)("button",{onClick:nT,disabled:E,style:nN(y.orange,y.bg,E),children:[(0,i.jsx)(eB.mail,{size:12,color:y.bg}),"Renvoyer l'email"]}),(0,i.jsxs)("button",{onClick:()=>{let e=nm||{};el({first_name:e.first_name||"",last_name:e.last_name||"",address1:e.address1||"",address2:e.address2||"",zip:e.zip||"",city:e.city||"",country_code:(e.country_code||"FR").toUpperCase(),email:(null==ng?void 0:ng.customer_email)||"",phone:e.phone||""});let t={};
1nx.forEach((e,n)=>{if(!eA(e))return;let i=eW(e).offer||{};t[n]=i.discount_percent?"discounted_refund":"reship"}),en(t),es({}),ee(!0)},disabled:E,style:{...nN("transparent",y.text,E),border:"1px solid ".concat(y.border)},children:[(0,i.jsx)(eB.check,{size:12,color:y.text}),"Choisir pour le client"]})]}),"to_reship"===ng.status&&(0,i.jsxs)("button",{onClick:()=>nI(!1),disabled:E,style:nN(y.purple,y.bg,E),children:[(0,i.jsx)(ex.download,{size:13,color:y.bg}),E?"G\xe9n\xe9ration DPD...":"G\xe9n\xe9rer l'\xe9tiquette de renvoi DPD"]})]}),"to_reship"===ng.status&&(0,i.jsxs)("div",{style:{display:"flex",flexDirection:"column",gap:Q.sm},children:[(0,i.jsx)("div",{style:{fontSize:11,color:y.textMuted,lineHeight:1.5},children:"\xc9tiquette DPD sortante (entrep\xf4t → client) + bordereau \xab RETOUR SAV \xbb fusionn\xe9s. Aucune commande Shopify n'est cr\xe9\xe9e."}),(0,i.jsxs)("label",{style:{display:"flex",alignItems:"center",gap:Q.sm,fontSize:11,color:y.textMuted,fontFamily:G},children:["Poids (kg, optionnel)",(0,i.jsx)("input",{value:ea,onChange:e=>ed(e.target.value),placeholder:"auto",type:"number",min:"0.05",step:"0.05",style:{...Z(y),width:90,fontSize:11}})]}),(null==ec?void 0:ec.warning)&&(0,i.jsx)("div",{style:{fontSize:11,color:y.orange},children:ec.warning})]}),X&&"awaiting_customer"===ng.status&&(0,i.jsxs)("div",{style:{display:"flex",flexDirection:"column",gap:Q.md,borderTop:"1px solid ".concat(y.border),paddingTop:Q.lg},children:[(0,i.jsx)("div",{style:{fontSize:11,color:y.textMuted},children:"Saisir le choix pour le compte du client (apr\xe8s \xe9change par t\xe9l\xe9phone ou email), article par article."}),nx.map((e,t)=>{if(!eA(e))return null;let n=eW(e).offer||{},r=et[t],l=(e,n)=>(0,i.jsx)("button",{onClick:()=>en(n=>({...n,[t]:e})),style:{...nN(r===e?y.text:"transparent",r===e?y.bg:y.text,!1),border:"1px solid ".concat(y.border),fontSize:10},children:n},e);return(0,i.jsxs)("div",{style:{display:"flex",flexDirection:"column",gap:6},children:[(0,i.jsxs)("div",{style:{fontSize:11,fontWeight:600,color:y.text},children:[e.title,e.variant?" (".concat(e.variant,")"):""]}),(0,i.jsxs)("div",{style:{display:"flex",gap:Q.sm,flexWrap:"wrap"},children:[n.discount_percent&&l("discounted_refund","Remboursement d\xe9cot\xe9 ".concat(n.discount_percent," % (").concat((eE(e)*(1-n.discount_percent/100)).toFixed(2),"€)")),n.reship&&l("reship","Renvoi de l'article")]})]},t)}),nD&&(0,i.jsx)(eX,{t:y,address:er,setAddress:el,errors:eo}),(0,i.jsxs)("div",{style:{display:"flex",gap:Q.sm},children:[(0,i.jsx)("button",{onClick:nR,disabled:E,style:nN(y.text,y.bg,E),children:"Enregistrer le choix"}),(0,i.jsx)("button",{onClick:()=>ee(!1),style:nN("transparent",y.textMuted,!1),children:"Annuler"})]})]}),"received"===ng.status&&(0,i.jsxs)("div",{style:{display:"flex",gap:Q.lg,flexWrap:"wrap"},children:[(0,i.jsxs)("label",{style:{display:"inline-flex",alignItems:"center",gap:Q.xs,fontSize:12,color:y.text,cursor:"pointer",userSelect:"none",fontFamily:G},children:[(0,i.jsx)("input",{type:"checkbox",checked:P,onChange:e=>O(e.target.checked),disabled:E,style:{cursor:"pointer"}}),"Restocker les articles"]}),Number(ng.return_fee)>0&&(0,i.jsxs)("label",{style:{display:"inline-flex",alignItems:"center",gap:Q.xs,fontSize:12,color:y.text,cursor:"pointer",userSelect:"none",fontFamily:G},children:[(0,i.jsx)("input",{type:"checkbox",checked:Y,onChange:e=>J(e.target.checked),disabled:E,style:{cursor:"pointer"}}),"Offrir les frais de retour (",Number(ng.return_fee).toFixed(2),"€)"]})]}),"received"===ng.status&&nw>0&&(0,i.jsxs)("div",{style:{display:"flex",flexDirection:"column",gap:Q.sm,borderTop:"1px solid ".concat(y.border),paddingTop:Q.lg},children:[(0,i.jsx)("label",{style:{fontSize:10,color:y.textMuted,fontWeight:600,fontFamily:G},children:"Motif commun aux articles refus\xe9s (utilis\xe9 si un article n'a pas son propre motif)"}),(0,i.jsx)("textarea",{value:H,onChange:e=>V(e.target.value),placeholder:"Ex. : article port\xe9, traces d'utilisation...",style:{...Z(y),minHeight:48,resize:"vertical",fontSize:11,fontFamily:G,lineHeight:1.5}}
1),(0,i.jsx)("div",{style:{fontSize:10,color:y.textDim,lineHeight:1.5},children:"Les articles accept\xe9s sont trait\xe9s tout de suite (remboursement, \xe9change, avoir). Les articles refus\xe9s avec une option passent en \xab Choix client \xbb avec un lien sign\xe9 ; sans option, ils sont refus\xe9s d\xe9finitivement."}),!n_&&(0,i.jsx)("div",{style:{fontSize:10,color:y.red},children:"Motif requis pour chaque article refus\xe9 (d\xe9cote entre 1 et 90 %)."})]}),(0,i.jsxs)("div",{style:{borderTop:"1px solid ".concat(y.border),paddingTop:Q.md},children:[(0,i.jsxs)("button",{onClick:()=>t4(e=>!e),style:{background:"none",border:"none",cursor:"pointer",padding:0,display:"flex",alignItems:"center",gap:6,fontSize:10,color:y.textDim,fontFamily:G,fontWeight:600,letterSpacing:"0.04em",textTransform:"uppercase"},children:[(0,i.jsx)("span",{style:{display:"inline-flex",transform:t6?"rotate(180deg)":"rotate(0deg)",transition:"transform 0.2s ease"},children:(0,i.jsx)(eB.chevronDown,{size:12,color:y.textDim})}),"Saisie manuelle"]}),t6&&(0,i.jsxs)("div",{style:{display:"flex",flexDirection:"column",gap:Q.md,marginTop:Q.md},children:[(0,i.jsxs)("div",{children:[(0,i.jsx)("label",{style:{fontSize:10,color:y.textMuted,fontWeight:600,display:"block",marginBottom:4},children:"URL \xe9tiquette"}),(0,i.jsx)("input",{value:ef,onChange:e=>ey(e.target.value),placeholder:"https://...",style:{...Z(y),fontSize:11}})]}),(0,i.jsxs)("div",{children:[(0,i.jsx)("label",{style:{fontSize:10,color:y.textMuted,fontWeight:600,display:"block",marginBottom:4},children:"Code de suivi"}),(0,i.jsx)("input",{value:eb,onChange:e=>ev(e.target.value),placeholder:"DPD-...",style:{...Z(y),fontSize:11}})]}),(ef!==(ng.label_url||"")||eb!==(ng.tracking_code||""))&&(0,i.jsxs)("button",{onClick:nL,style:{...nN(y.text,y.bg,!1),alignSelf:"flex-start"},children:[(0,i.jsx)(eB.save,{size:12,color:y.bg}),"Sauvegarder"]})]})]})]}),(ng.carrier||ng.label_url)&&(0,i.jsxs)("button",{onClick:ni,disabled:tL,style:{...nU,textDecoration:"none",textAlign:"center",display:"flex",justifyContent:"center",alignItems:"center",gap:8,padding:"".concat(Q.md,"px ").concat(Q.lg,"px"),color:tL?y.textMuted:y.text,fontSize:12,fontWeight:600,transition:"all 0.2s ease",cursor:tL?"default":"pointer",width:"100%",border:"1.5px solid ".concat(y.border)},onMouseEnter:e=>{tL||(e.currentTarget.style.background=y.surfaceAlt,e.currentTarget.style.borderColor=y.textMuted)},onMouseLeave:e=>{e.currentTarget.style.background=y.surface,e.currentTarget.style.borderColor=y.border},children:[(0,i.jsx)(ex.download,{size:14,color:tL?y.textMuted:y.text}),tL?"T\xe9l\xe9chargement…":"T\xe9l\xe9charger l'\xe9tiquette".concat("colissimo"===ng.carrier?" Colissimo":"dpd"===ng.carrier?" DPD":"")]}),ng.reship_tracking&&(0,i.jsxs)("div",{style:{display:"flex",gap:Q.sm},children:[(0,i.jsxs)("button",{onClick:nM,disabled:ep,style:{...nU,flex:1,textAlign:"center",display:"flex",justifyContent:"center",alignItems:"center",gap:8,padding:"".concat(Q.md,"px ").concat(Q.lg,"px"),color:y.text,fontSize:12,fontWeight:600,cursor:ep?"default":"pointer",border:"1.5px solid ".concat(y.purple,"40")},children:[(0,i.jsx)(ex.download,{size:14,color:y.text}),ep?"T\xe9l\xe9chargement…":"\xc9tiquette de renvoi SAV (DPD + bordereau)"]}),(0,i.jsx)("button",{onClick:()=>nI(!0),disabled:E,title:"R\xe9g\xe9n\xe9rer (nouveau colis DPD)",style:{...nN("transparent",y.orange,E),border:"1px solid ".concat(y.orange,"30")},children:(0,i.jsx)(eB.repeat,{size:12,color:y.orange})})]}),tF?(0,i.jsxs)("div",{style:{background:"".concat(y.red,"10"),border:"1px solid ".concat(y.red,"30"),borderRadius:$.lg,padding:Q.md,display:"flex",flexDirection:"column",gap:Q.sm},children:[(0,i.jsx)("div",{style:{fontSize:11,color:y.red,fontWeight:600,fontFamily:G},children:"Supprimer d\xe9finitivement ce retour ?"}),(0,i.jsxs)("div",{style:{display:"flex",gap:Q.sm},children:[(0,i.jsx)("button",{onClick:ns,disabled:tB,style:{background:y.red,color:y.bg,border:"none",borderRadius:$.md,padding:"".concat(Q.xs,"px ").concat(Q.md,"px"),fontSize:11,fontWeight:600,fontFamily:G,cursor:tB?"default":"pointer",opacity:tB?.6:1},children:tB?"Suppression…":"Confirmer"}),(0,i.jsx)("button",{onClick:()=>tE(!1),style:{background:"transparent",color:y.textMuted,border:"none",borderRadius:$.md,padding:"".concat(Q.xs,"px ").concat(Q.md,"px"),fontSize:11,fontFamily:G,cursor:"pointer"},children:"Annuler"})]})]}):(0,i.jsxs)("button",{onClick:()=>tE(!0),style:{background:"transparent",border:"none",cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center",gap:6,color:y.textDim,fontSize:11,fontFamily:G,padding:"".concat(Q.sm,"px 0"),width:"100%",marginTop:Q.xs,transition:"color 0.15s ease"},onMouseEnter:e=>{e.currentTarget.style.color=y.red},onMouseLeave:e=>{e.currentTarget.style.color=y.textDim},children:[(0,i.jsx)(eB.x,{size:12}),"Supprimer ce retour"]})]}
1),ek&&(0,i.jsx)("div",{style:{position:"fixed",top:0,left:0,right:0,bottom:0,background:"rgba(0,0,0,0.5)",zIndex:9998,display:"flex",alignItems:"center",justifyContent:"center",padding:20,backdropFilter:"blur(4px)"},onClick:e=>e.target===e.currentTarget&&ew(!1),children:(0,i.jsxs)("div",{style:{background:y.surface,borderRadius:$.xl,padding:Q.xxl,width:"100%",maxWidth:520,maxHeight:"90vh",overflowY:"auto",boxShadow:"0 24px 48px ".concat(y.shadow,", 0 0 0 1px ").concat(y.border)},children:[(0,i.jsxs)("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:Q.xl,paddingBottom:Q.lg,borderBottom:"1px solid ".concat(y.border)},children:[(0,i.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:Q.md},children:[(0,i.jsx)("div",{style:{width:32,height:32,borderRadius:$.md,background:"".concat(y.text,"08"),display:"flex",alignItems:"center",justifyContent:"center"},children:(0,i.jsx)(eB.plus,{size:16,color:y.text})}),(0,i.jsx)("h3",{style:{fontSize:15,fontWeight:700,color:y.text,margin:0,fontFamily:G},children:"manual"===e8?"Retour manuel \xb7 Achat boutique":"Nouveau retour"})]}),(0,i.jsx)("button",{onClick:()=>ew(!1),style:{width:28,height:28,borderRadius:$.md,border:"1px solid ".concat(y.border),background:"transparent",cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center",transition:"all 0.15s ease"},onMouseEnter:e=>e.currentTarget.style.background=y.surfaceAlt,onMouseLeave:e=>e.currentTarget.style.background="transparent",children:(0,i.jsx)(eB.x,{size:14,color:y.textMuted})})]}),(0,i.jsx)("div",{style:{display:"flex",gap:6,marginBottom:Q.lg},children:[{id:"order",label:"Commande en ligne"},{id:"manual",label:"Achat boutique"}].map(e=>(0,i.jsx)("button",{onClick:()=>{e7(e.id),e4("")},style:{flex:1,padding:"8px 12px",minHeight:34,borderRadius:$.pill,border:"1.5px solid ".concat(e8===e.id?y.text:y.border),background:e8===e.id?"".concat(y.text,"08"):"transparent",color:e8===e.id?y.text:y.textMuted,fontSize:11,fontWeight:600,fontFamily:G,cursor:"pointer",transition:"border-color 0.18s ease, background 0.18s ease, color 0.18s ease"},children:e.label},e.id))}),"order"===e8&&(0,i.jsxs)("div",{style:{display:"flex",gap:Q.sm,marginBottom:Q.lg},children:[(0,i.jsx)("input",{value:eC,onChange:e=>e_(e.target.value),placeholder:"N. commande",style:{...Z(y),flex:1,fontSize:11},onKeyDown:e=>"Enter"===e.key&&nA()}),(0,i.jsx)("input",{value:eT,onChange:e=>eD(e.target.value),placeholder:"Email client",style:{...Z(y),flex:1,fontSize:11},onKeyDown:e=>"Enter"===e.key&&nA()}),(0,i.jsx)("button",{onClick:nA,disabled:eR,style:nN(y.text,y.bg,eR),children:eR?"...":"Chercher"})]}),e6&&(0,i.jsxs)("div",{style:{fontSize:11,color:y.red,marginBottom:Q.lg,padding:"".concat(Q.sm,"px ").concat(Q.md,"px"),background:"".concat(y.red,"06"),borderRadius:$.md,border:"1px solid ".concat(y.red,"15"),display:"flex",alignItems:"center",gap:6},children:[(0,i.jsx)(eB.alertCircle,{size:12,color:y.red}),e6]}),"order"===e8&&eL&&(0,i.jsxs)(i.Fragment,{children:[(0,i.jsxs)("div",{style:{fontSize:12,color:y.text,marginBottom:Q.lg,padding:"".concat(Q.sm,"px ").concat(Q.md,"px"),background:y.surfaceAlt,borderRadius:$.md,fontWeight:500},children:[eL.name," — ",null==(s=eL.customer)?void 0:s.name," (",null==(a=eL.customer)?void 0:a.email,")"]}),(0,i.jsx)("div",{style:{display:"flex",flexDirection:"column",gap:Q.sm,marginBottom:Q.lg},children:null==(d=eL.items)?void 0:d.map((e,t)=>{let n=!!eJ[t];return(0,i.jsxs)("div",{style:{...nU,padding:Q.md,cursor:"pointer",border:"1.5px solid ".concat(n?y.text:y.border),background:n?"".concat(y.text,"04"):y.surface,transition:"all 0.15s ease"},onClick:()=>{e$(e=>{let n={...e};return n[t]?delete n[t]:n[t]={reason:"autre",action:"refund"},n})},children:[(0,i.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:Q.sm},children:[n&&(0,i.jsx)("div",{style:{width:18,height:18,borderRadius:$.sm,background:y.text,display:"flex",alignItems:"center",justifyContent:"center",flexShrink:0},children:(0,i.jsx)(eB.check,{size:12,color:y.bg})}),(0,i.jsxs)("div",{style:{flex:1},children:[(0,i.jsx)("div",{style:{fontSize:12,fontWeight:600,color:y.text},children:e.title}
1),(0,i.jsxs)("div",{style:{fontSize:10,color:y.textMuted},children:[e.variant&&"".concat(e.variant," \xb7 "),"Qt\xe9: ",e.qty," \xb7 ",e.price,"€"]})]})]}),n&&(0,i.jsxs)("div",{style:{display:"flex",flexDirection:"column",gap:Q.sm,marginTop:Q.md},onClick:e=>e.stopPropagation(),children:[(0,i.jsxs)("div",{style:{display:"flex",gap:Q.sm},children:[(0,i.jsxs)("select",{value:eJ[t].action,onChange:n=>{n.stopPropagation();let i=n.target.value;e$(e=>({...e,[t]:{...e[t],action:i,exchangeVariant:null,exchangeVariantTitle:null}})),"exchange"===i&&e.product_id&&nb(e.product_id)},style:{...Z(y),fontSize:10,flex:1},children:[(0,i.jsx)("option",{value:"refund",children:"Remboursement"}),(0,i.jsx)("option",{value:"exchange",children:"\xc9change"}),(0,i.jsx)("option",{value:"credit",children:"Avoir"})]}),(0,i.jsxs)("select",{value:eJ[t].reason,onChange:e=>{e.stopPropagation(),e$(n=>({...n,[t]:{...n[t],reason:e.target.value}}))},style:{...Z(y),fontSize:10,flex:1},children:[(0,i.jsx)("option",{value:"taille_incorrecte",children:"Taille incorrecte"}),(0,i.jsx)("option",{value:"defectueux",children:"Defectueux"}),(0,i.jsx)("option",{value:"ne_correspond_pas",children:"Ne correspond pas"}),(0,i.jsx)("option",{value:"autre",children:"Autre"})]})]}),"exchange"===eJ[t].action&&e.product_id&&(e5[e.product_id]?(0,i.jsxs)("select",{value:eJ[t].exchangeVariant||"",onChange:n=>{let i=e5[e.product_id].find(e=>e.id===n.target.value);e$(e=>({...e,[t]:{...e[t],exchangeVariant:n.target.value,exchangeVariantTitle:(null==i?void 0:i.title)||"Standard"}}))},style:{...Z(y),fontSize:10},children:[(0,i.jsx)("option",{value:"",children:"Variante d'\xe9change..."}),e5[e.product_id].map(e=>(0,i.jsxs)("option",{value:e.id,disabled:!e.available,children:[e.title||"Standard",e.available?"":" (rupture)"," — ",e.price,"€"]},e.id))]}):(0,i.jsx)("button",{onClick:t=>{t.stopPropagation(),nb(e.product_id)},style:{...ei(!1,y),fontSize:9,alignSelf:"flex-start"},children:"Charger les variantes"}))]})]},t)})}),(0,i.jsxs)("div",{style:{display:"flex",flexDirection:"column",gap:Q.md,marginBottom:Q.xl},children:[(0,i.jsxs)("label",{style:{display:"flex",alignItems:"center",gap:Q.sm,fontSize:11,color:y.textMuted,cursor:"pointer"},children:[(0,i.jsx)("input",{type:"checkbox",checked:eZ,onChange:e=>e0(e.target.checked),style:{accentColor:y.text}}),"Ignorer le d\xe9lai d'\xe9ligibilit\xe9"]}),(0,i.jsxs)("label",{style:{display:"flex",alignItems:"center",gap:Q.sm,fontSize:11,color:y.textMuted,cursor:"pointer"},children:[(0,i.jsx)("input",{type:"checkbox",checked:e1,onChange:e=>e2(e.target.checked),style:{accentColor:y.text}}),"Ignorer les restrictions produit"]})]}),(0,i.jsxs)("button",{onClick:nF,disabled:!Object.keys(eJ).length||eR,style:{...nN(y.text,y.bg,!Object.keys(eJ).length||eR),width:"100%",justifyContent:"center",padding:"10px 16px",fontSize:12},children:[(0,i.jsx)(eB.check,{size:14,color:y.bg}),eR?"Cr\xe9ation...":"Cr\xe9er le retour"]})]}),"manual"===e8&&(()=>{let e={fontSize:9,color:y.textDim,textTransform:"uppercase",letterSpacing:"0.07em",fontWeight:700,marginBottom:Q.sm},t=tu.some(e=>"exchange"===e.action),n={...Z(y),fontSize:11};return(0,i.jsxs)("div",{style:{display:"flex",flexDirection:"column",gap:Q.xl},children:[(0,i.jsxs)("div",{children:[(0,i.jsx)("div",{style:e,children:"1 \xb7 Client"}),tl?(0,i.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:Q.md,padding:"".concat(Q.sm,"px ").concat(Q.md,"px"),borderRadius:$.md,background:y.surfaceAlt,border:"1px solid ".concat(y.border)},children:[(0,i.jsxs)("div",{style:{flex:1,minWidth:0},children:[(0,i.jsx)("div",{style:{fontSize:12,fontWeight:600,color:y.text},children:tl.name||"Sans nom"}),(0,i.jsxs)("div",{style:{fontSize:10,color:y.textMuted},children:[tl.email,tl.orders_count>0&&" \xb7 ".concat(tl.orders_count," commande(s)"),"sav"!==tl.source&&" \xb7 Shopify"]})]}),(0,i.jsx)("button",{onClick:()=>{to(null),te("")},style:{...ei(!1,y),fontSize:10},children:"Changer"})]}):ts?(0,i.jsxs)("div",{style:{display:"flex",flexDirection:"column",gap:Q.sm},children:[(0,i.jsxs)("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:Q.sm},children:[(0,i.jsx)("input",{value:td.name,onChange:e=>tc(t=>({...t,name:e.target.value})),placeholder:"Nom complet *",style:n}),(0,i.jsx)("input",{value:td.phone,onChange:e=>tc(t=>({...t,phone:e.target.value})),placeholder:"T\xe9l\xe9phone",style:n})]}),(0,i.jsx)("input",{value:td.email,onChange:e=>tc(t=>({...t,email:e.target.value})),placeholder:"Email * (avoir, \xe9change et notifications)",type:"email",style:n}),(0,i.jsx)("button",{onClick:()=>ta(!1),style:{background:"none",border:"none",cursor:"pointer",padding:0,alignSelf:"flex-start",fontSize:10,
1color:y.blue,fontFamily:G},children:"← Rechercher un client existant"})]}):(0,i.jsxs)("div",{style:{position:"relative",display:"flex",flexDirection:"column",gap:Q.sm},children:[(0,i.jsx)("input",{value:e9,onChange:e=>te(e.target.value),placeholder:"Rechercher par nom ou email…",style:n}),(tt.length>0||ti)&&e9.trim().length>=2&&(0,i.jsxs)("div",{style:{border:"1px solid ".concat(y.border),borderRadius:$.md,background:y.surface,overflow:"hidden"},children:[ti&&(0,i.jsx)("div",{style:{padding:"".concat(Q.sm,"px ").concat(Q.md,"px"),fontSize:11,color:y.textMuted},children:"Recherche…"}),tt.map(e=>(0,i.jsxs)("button",{onClick:()=>{to(e),ta(!1),tn([]),te(""),e.default_address&&t_({first_name:e.default_address.first_name||"",last_name:e.default_address.last_name||"",address1:e.default_address.address1||"",address2:e.default_address.address2||"",zip:e.default_address.zip||"",city:e.default_address.city||"",phone:e.default_address.phone||e.phone||""})},style:{display:"block",width:"100%",textAlign:"left",padding:"".concat(Q.sm,"px ").concat(Q.md,"px"),background:"transparent",border:"none",borderBottom:"1px solid ".concat(y.border),cursor:"pointer",fontFamily:G},onMouseEnter:e=>e.currentTarget.style.background=y.surfaceAlt,onMouseLeave:e=>e.currentTarget.style.background="transparent",children:[(0,i.jsx)("div",{style:{fontSize:12,fontWeight:600,color:y.text},children:e.name||"Sans nom"}),(0,i.jsxs)("div",{style:{fontSize:10,color:y.textMuted},children:[e.email,e.orders_count>0&&" \xb7 ".concat(e.orders_count," commande(s)"),"sav"!==e.source&&" \xb7 Shopify"]})]},"".concat(e.source,"-").concat(e.id)))]}),(0,i.jsxs)("button",{onClick:()=>ta(!0),style:{background:"none",border:"none",cursor:"pointer",padding:0,alignSelf:"flex-start",fontSize:10,color:y.blue,fontFamily:G,display:"flex",alignItems:"center",gap:4},children:[(0,i.jsx)(eB.plus,{size:10,color:y.blue}),"Nouveau client (achat en boutique sans compte)"]})]})]}),(0,i.jsxs)("div",{children:[(0,i.jsx)("div",{style:e,children:"2 \xb7 Articles rapport\xe9s"}),(0,i.jsxs)("div",{style:{display:"flex",flexDirection:"column",gap:Q.sm},children:[tu.map((e,t)=>{var r;return(0,i.jsxs)("div",{style:{...nU,padding:Q.md},children:[(0,i.jsxs)("div",{style:{display:"flex",gap:Q.sm,alignItems:"flex-start"},children:[e.image&&(0,i.jsx)("img",{src:e.image,alt:"",style:{width:36,height:36,borderRadius:$.sm,objectFit:"cover",border:"1px solid ".concat(y.border),flexShrink:0}}),(0,i.jsxs)("div",{style:{flex:1,minWidth:0},children:[(0,i.jsx)("div",{style:{fontSize:12,fontWeight:600,color:y.text},children:e.title}),e.variant&&(0,i.jsx)("div",{style:{fontSize:10,color:y.textMuted},children:e.variant})]}),(0,i.jsx)("button",{onClick:()=>tp(e=>e.filter((e,n)=>n!==t)),title:"Retirer",style:{background:"transparent",border:"none",cursor:"pointer",padding:2,color:y.textDim},children:(0,i.jsx)(eB.x,{size:13})})]}),(0,i.jsxs)("div",{style:{display:"grid",gridTemplateColumns:"70px 52px 1fr 1fr",gap:Q.sm,marginTop:Q.sm},children:[(0,i.jsx)("input",{value:e.price,onChange:e=>nB(t,{price:e.target.value}),placeholder:"Prix €",title:"Prix pay\xe9 en boutique (modifiable)",style:{...n,fontFamily:K}}),(0,i.jsx)("input",{type:"number",min:"1",value:e.qty,onChange:e=>nB(t,{qty:Math.max(1,parseInt(e.target.value)||1)}),title:"Quantit\xe9",style:{...n,fontFamily:K}}),(0,i.jsxs)("select",{value:e.action,onChange:n=>{let i=n.target.value,r={action:i,exchange_variant_id:null,exchange_variant_title:null};"exchange"!==i||e.exchange_product_id||(r.exchange_product_id=e.product_id,r.exchange_product_title=e.title,nb(e.product_id)),nB(t,r)},style:{...n,fontSize:10},children:[(0,i.jsx)("option",{value:"refund",children:"Remboursement"}),(0,i.jsx)("option",{value:"exchange",children:"\xc9change"}),(0,i.jsx)("option",{value:"credit",children:"Avoir"})]}),(0,i.jsxs)("select",{value:e.reason,onChange:e=>nB(t,{reason:e.target.value}),style:{...n,fontSize:10},children:[(0,i.jsx)("option",{value:"taille_incorrecte",children:"Taille incorrecte"}),(0,i.jsx)("option",{value:"defectueux",children:"Defectueux"}),(0,i.jsx)("option",{value:"ne_correspond_pas",children:"Ne correspond pas"}),(0,i.jsx)("option",{value:"autre",children:"Autre"})]})]}),"exchange"===e.action&&(0,i.jsxs)("div",{style:{marginTop:Q.sm,padding:Q.sm,borderRadius:$.sm,background:"".concat(y.purple,"06"),border:"1px solid ".concat(y.purple,"18"),display:"flex",flexDirection:"column",gap:Q.sm},children:[(0,i.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:6,fontSize:10,
1color:y.purple,fontWeight:600},children:[(0,i.jsx)(eB.repeat,{size:11,color:y.purple}),"\xc9changer vers : ",e.exchange_product_title||"…"]}),e.exchange_product_id&&(e5[e.exchange_product_id]?(0,i.jsxs)("select",{value:e.exchange_variant_id||"",onChange:n=>{let i=e5[e.exchange_product_id].find(e=>e.id===n.target.value);nB(t,{exchange_variant_id:n.target.value||null,exchange_variant_title:i?"".concat(e.exchange_product_title!==e.title?e.exchange_product_title+" — ":"").concat(i.title||"Standard"):null})},style:{...n,fontSize:10},children:[(0,i.jsx)("option",{value:"",children:"Variante d'\xe9change…"}),e5[e.exchange_product_id].map(e=>(0,i.jsxs)("option",{value:e.id,disabled:!e.available,children:[e.title||"Standard",e.available?"":" (rupture)"," — ",e.price,"€"]},e.id))]}):(0,i.jsx)("div",{style:{fontSize:10,color:y.textMuted},children:"Chargement des variantes…"})),(0,i.jsxs)("div",{style:{display:"flex",gap:Q.sm},children:[(0,i.jsx)("input",{value:e.exchange_search||"",onChange:e=>nB(t,{exchange_search:e.target.value}),onKeyDown:n=>"Enter"===n.key&&nP(t,e.exchange_search),placeholder:"Ou chercher un autre produit…",style:{...n,fontSize:10,flex:1}}),(0,i.jsx)("button",{onClick:()=>nP(t,e.exchange_search),style:{...ei(!1,y),fontSize:10},children:"Chercher"})]}),(null==(r=e.exchange_results)?void 0:r.length)>0&&(0,i.jsx)("div",{style:{display:"flex",flexDirection:"column",gap:2},children:e.exchange_results.slice(0,5).map(e=>(0,i.jsxs)("button",{onClick:()=>{var n;nB(t,{exchange_product_id:n=nE(e.id),exchange_product_title:e.title,exchange_variant_id:null,exchange_variant_title:null,exchange_results:null,exchange_search:""}),nb(n)},style:{display:"flex",alignItems:"center",gap:Q.sm,textAlign:"left",padding:"4px 8px",borderRadius:$.sm,background:"transparent",border:"1px solid ".concat(y.border),cursor:"pointer",fontFamily:G,fontSize:11,color:y.text},children:[e.image&&(0,i.jsx)("img",{src:e.image,alt:"",style:{width:20,height:20,borderRadius:3,objectFit:"cover"}}),e.title]},e.id))})]})]},t)}),tb?(0,i.jsxs)("div",{style:{...nU,padding:Q.md,border:"1.5px solid ".concat(y.text)},children:[(0,i.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:Q.sm,marginBottom:Q.sm},children:[tb.image&&(0,i.jsx)("img",{src:tb.image,alt:"",style:{width:30,height:30,borderRadius:$.sm,objectFit:"cover"}}),(0,i.jsx)("div",{style:{flex:1,fontSize:12,fontWeight:600,color:y.text},children:tb.title}),(0,i.jsx)("button",{onClick:()=>tv(null),style:{background:"transparent",border:"none",cursor:"pointer",padding:2,color:y.textDim},children:(0,i.jsx)(eB.x,{size:13})})]}),e5[tb.numericId]?(0,i.jsx)("div",{style:{display:"flex",flexWrap:"wrap",gap:6},children:e5[tb.numericId].map(e=>(0,i.jsxs)("button",{onClick:()=>{tb&&(tp(t=>[...t,{title:tb.title,variant:e.title||null,variant_id:e.id,product_id:tb.numericId,price:e.price||"0",qty:1,image:tb.image||null,reason:"autre",action:"refund",exchange_product_id:null,exchange_product_title:null,exchange_variant_id:null,exchange_variant_title:null}]),tv(null),tx(""),tm([]))},style:{padding:"5px 10px",borderRadius:$.pill,border:"1px solid ".concat(y.border),background:"transparent",color:y.text,fontSize:10,fontWeight:600,cursor:"pointer",fontFamily:G},children:[e.title||"Standard"," — ",e.price,"€"]},e.id))}):(0,i.jsx)("div",{style:{fontSize:10,color:y.textMuted},children:"Chargement des variantes…"})]}):(0,i.jsxs)("div",{style:{display:"flex",flexDirection:"column",gap:Q.sm},children:[(0,i.jsx)("input",{value:tg,onChange:e=>tx(e.target.value),placeholder:"+ Ajouter un article : chercher dans le catalogue…",style:n}),(th.length>0||tf)&&tg.trim().length>=2&&(0,i.jsxs)("div",{style:{border:"1px solid ".concat(y.border),borderRadius:$.md,background:y.surface,overflow:"hidden"},children:[tf&&(0,i.jsx)("div",{style:{padding:"".concat(Q.sm,"px ").concat(Q.md,"px"),fontSize:11,color:y.textMuted},children:"Recherche…"}),th.map(e=>(0,i.jsxs)("button",{onClick:()=>(e=>{let t=nE(e.id);t&&(tv({...e,numericId:t}),nb(t))})(e),style:{display:"flex",alignItems:"center",gap:Q.sm,width:"100%",textAlign:"left",padding:"".concat(Q.sm,"px ").concat(Q.md,"px"),background:"transparent",border:"none",borderBottom:"1px solid ".concat(y.border),cursor:"pointer",fontFamily:G},onMouseEnter:e=>e.currentTarget.style.background=y.surfaceAlt,onMouseLeave:e=>e.currentTarget.style.background="transparent",children:[e.image&&(0,i.jsx)("img",{src:e.image,alt:"",style:{width:26,height:26,borderRadius:$.sm,objectFit:"cover"}}),(0,i.jsx)("span",{style:{fontSize:12,color:y.text,fontWeight:500},children:e.title})]},e.id))]})]})]})]}),(0,i.jsxs)("div",{children:[(0,i.jsx)("div",{style:e,children:"3 \xb7 Achat d'origine"}),(0,i.jsxs)("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:Q.sm},children:[(0,i.jsxs)("div",{children:[(0,i.jsx)("div",{style:{fontSize:9,color:y.textMuted,marginBottom:3,fontWeight:600},children:"Date d'achat"}),(0,i.jsx)("input",{type:"date",value:tj.date,onChange:e=>tS(t=>({...t,date:e.target.value})),style:n})]}),(0,i.jsxs)("div",{children:[(0,i.jsx)("div",{style:{fontSize:9,color:y.textMuted,marginBottom:3,fontWeight:600},children:"Moyen de paiement"}),(0,i.jsxs)("select",{value:tj.payment_method,onChange:e=>tS(t=>({...t,payment_method:e.target.value})),style:{...n,fontSize:10},children:[(0,i.jsx)("option",{value:"especes",children:"Esp\xe8ces"}),(0,i.jsx)("option",{value:"cb",children:"Carte bancaire"}),(0,i.jsx)("option",{value:"cheque",children:"Ch\xe8que"}),(0,i.jsx)("option",{value:"autre",children:"Autre"})]})]}),(0,i.jsxs)("div",{children:[(0,i.jsx)("div",{style:{fontSize:9,color:y.textMuted,marginBottom:3,fontWeight:600},children:"Boutique / lieu"}),(0,i.jsx)("input",{value:tj.location,onChange:e=>tS(t=>({...t,location:e.target.value})),placeholder:"Ex : boutique Marseille",style:n})]}),(0,i.jsxs)("div",{children:[(0,i.jsx)("div",{style:{fontSize:9,color:y.textMuted,marginBottom:3,fontWeight:600},children:"N\xb0 ticket de caisse"}),(0,i.jsx)("input",{value:tj.receipt_ref,onChange:e=>tS(t=>({...t,receipt_ref:e.target.value})),placeholder:"Optionnel",style:n})]})]})]}),(0,i.jsxs)("div",{children:[(0,i.jsx)("div",{style:e,children:"4 \xb7 Retour du produit"}),(0,i.jsx)("div",{style:{display:"flex",gap:6},children:[{id:"in_store",label:"D\xe9pos\xe9 en boutique"},{id:"shipping",label:"Envoi postal (\xe9tiquette)"}].map(e=>(0,i.jsx)("button",{onClick:()=>tw(e.id),style:{flex:1,padding:"8px 10px",minHeight:34,borderRadius:$.md,border:"1.5px solid ".concat(tk===e.id?y.text:y.border),background:tk===e.id?"".concat(y.text,"06"):"transparent",color:tk===e.id?y.text:y.textMuted,fontSize:11,fontWeight:600,fontFamily:G,cursor:"pointer"},children:e.label},e.id))}
1),"in_store"===tk&&(0,i.jsx)("div",{style:{fontSize:10,color:y.textMuted,marginTop:Q.sm,lineHeight:1.5},children:"L'article est d\xe9j\xe0 en boutique : le retour sera cr\xe9\xe9 directement au statut \xab Re\xe7u \xbb, pr\xeat \xe0 traiter."}),("shipping"===tk||t)&&(0,i.jsxs)("div",{style:{display:"flex",flexDirection:"column",gap:Q.sm,marginTop:Q.md},children:[(0,i.jsx)("div",{style:{fontSize:9,color:y.textDim,textTransform:"uppercase",fontWeight:600,letterSpacing:"0.04em"},children:"shipping"===tk?"Adresse du client (\xe9tiquette retour + livraison \xe9change)":"Adresse de livraison de l'\xe9change"}),(0,i.jsxs)("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:Q.sm},children:[(0,i.jsx)("input",{value:tC.first_name,onChange:e=>t_(t=>({...t,first_name:e.target.value})),placeholder:"Pr\xe9nom",style:n}),(0,i.jsx)("input",{value:tC.last_name,onChange:e=>t_(t=>({...t,last_name:e.target.value})),placeholder:"Nom",style:n})]}),(0,i.jsx)("input",{value:tC.address1,onChange:e=>t_(t=>({...t,address1:e.target.value})),placeholder:"Adresse",style:n}),(0,i.jsx)("input",{value:tC.address2,onChange:e=>t_(t=>({...t,address2:e.target.value})),placeholder:"Compl\xe9ment (optionnel)",style:n}),(0,i.jsxs)("div",{style:{display:"grid",gridTemplateColumns:"1fr 2fr 1fr",gap:Q.sm},children:[(0,i.jsx)("input",{value:tC.zip,onChange:e=>t_(t=>({...t,zip:e.target.value})),placeholder:"CP",style:n}),(0,i.jsx)("input",{value:tC.city,onChange:e=>t_(t=>({...t,city:e.target.value})),placeholder:"Ville",style:n}),(0,i.jsx)("input",{value:tC.phone,onChange:e=>t_(t=>({...t,phone:e.target.value})),placeholder:"T\xe9l.",style:n})]})]})]}),(0,i.jsxs)("button",{onClick:nO,disabled:eR,style:{...nN(y.text,y.bg,eR),width:"100%",justifyContent:"center",padding:"10px 16px",fontSize:12},children:[(0,i.jsx)(eB.check,{size:14,color:y.bg}),eR?"Cr\xe9ation...":"Cr\xe9er le retour manuel"]})]})})()]})}),tz&&(0,i.jsx)("div",{style:{position:"fixed",top:0,left:0,right:0,bottom:0,background:"rgba(0,0,0,0.5)",zIndex:9998,display:"flex",alignItems:"center",justifyContent:"center",padding:20,backdropFilter:"blur(4px)"},onClick:e=>{e.target!==e.currentTarget||tW||(tT(!1),tH(!1))},children:(0,i.jsxs)("div",{style:{background:y.surface,borderRadius:$.xl,padding:Q.xxl,width:"100%",maxWidth:380,boxShadow:"0 24px 48px ".concat(y.shadow,", 0 0 0 1px ").concat(y.border)},children:[(0,i.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:Q.md,marginBottom:Q.xl,paddingBottom:Q.lg,borderBottom:"1px solid ".concat(y.border)},children:[(0,i.jsx)("div",{style:{width:32,height:32,borderRadius:$.md,background:"".concat(y.green,"10"),display:"flex",alignItems:"center",justifyContent:"center"},children:(0,i.jsx)(eB.pkg,{size:16,color:y.green})}),(0,i.jsx)("h3",{style:{fontSize:15,fontWeight:700,color:y.text,margin:0,fontFamily:G},children:"G\xe9n\xe9rer l'\xe9tiquette"})]}),(0,i.jsx)("div",{style:{fontSize:11,color:y.textMuted,marginBottom:Q.md},children:tN?"R\xe9g\xe9n\xe9rer l'\xe9tiquette de retour avec le transporteur impos\xe9 :":"L'\xe9tiquette sera g\xe9n\xe9r\xe9e avec le transporteur impos\xe9 :"}),(0,i.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:Q.md,marginBottom:Q.md,padding:"".concat(Q.md,"px ").concat(Q.lg,"px"),borderRadius:$.md,border:"1.5px solid ".concat(y.text),background:"".concat(y.text,"06")},children:[(0,i.jsx)("span",{style:{width:14,height:14,borderRadius:"50%",background:y.text,flexShrink:0}}),(0,i.jsx)("span",{style:{fontSize:13,fontWeight:600,color:y.text},children:nV})]}),(0,i.jsx)("div",{style:{fontSize:10,color:y.textDim,marginBottom:Q.xl,lineHeight:1.5},children:"Pour changer de transporteur, modifiez \xab Transporteur de retour \xbb dans R\xe9glages."}),(0,i.jsxs)("div",{style:{display:"flex",gap:Q.sm},children:[(0,i.jsx)("button",{onClick:nr,disabled:tW,style:{...nN(y.green,y.bg,tW),flex:1,justifyContent:"center",padding:"9px 16px"},children:tW?"G\xe9n\xe9ration en cours...":"G\xe9n\xe9rer"}),(0,i.jsx)("button",{onClick:()=>{tT(!1),tH(!1)},disabled:tW,style:nN("transparent",y.textMuted,tW),children:"Annuler"})]})]})}),ej&&(0,i.jsx)("div",{onClick:()=>eS(null),style:{position:"fixed",top:0,left:0,right:0,bottom:0,background:"rgba(0,0,0,0.85)",zIndex:9999,display:"flex",alignItems:"center",justifyContent:"center",cursor:"pointer",backdropFilter:"blur(8px)"},children:(0,i.jsx)("img",{src:ej,alt:"",style:{maxWidth:"90%",maxHeight:"90%",borderRadius:$.lg,boxShadow:"0 20px 60px rgba(0,0,0,0.5)"}})})]})}let eJ=[["FR","France"],["BE","Belgique"],["CH","Suisse"],["LU","Luxembourg"],["DE","Allemagne"],["ES","Espagne"],["IT","Italie"],["NL","Pays-Bas"],["PT","Portugal"],["GB","Royaume-Uni"]];function eX(e){let{t,address:n,setAddress:r,errors:l={}}=e,o=e=>t=>r(n=>({...n,[e]:t.target.value})),s=function(e,r){let s=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return(0,i.jsxs)("div",{style:{flex:s.flex||"1 1 140px"}
1,children:[(0,i.jsxs)("label",{style:{fontSize:10,color:l[e]?t.red:t.textMuted,fontWeight:600,display:"block",marginBottom:4},children:[r,l[e]?" — ".concat(l[e]):""]}),(0,i.jsx)("input",{value:n[e]||"",onChange:o(e),placeholder:s.placeholder||"",type:s.type||"text",style:{...Z(t),fontSize:11,borderColor:l[e]?t.red:void 0}})]})};return(0,i.jsxs)("div",{style:{display:"flex",flexWrap:"wrap",gap:Q.sm},children:[s("first_name","Pr\xe9nom"),s("last_name","Nom"),s("address1","Adresse",{flex:"1 1 100%"}),s("address2","Compl\xe9ment",{flex:"1 1 100%"}),s("zip","Code postal",{flex:"1 1 90px"}),s("city","Ville"),(0,i.jsxs)("div",{style:{flex:"1 1 120px"},children:[(0,i.jsx)("label",{style:{fontSize:10,color:l.country_code?t.red:t.textMuted,fontWeight:600,display:"block",marginBottom:4},children:"Pays"}),(0,i.jsx)("select",{value:n.country_code||"FR",onChange:o("country_code"),style:{...Z(t),fontSize:11},children:eJ.map(e=>{let[t,n]=e;return(0,i.jsx)("option",{value:t,children:n},t)})})]}),s("email","Email",{type:"email"}),s("phone","Portable (obligatoire, DPD Predict)",{type:"tel",placeholder:"06 12 34 56 78"})]})}function eQ(e){let{item:t,t:n}=e,r=eW(t),l=eF(t),o=null,s=n.textMuted;if("rejected"===r.status)if("reship"===r.settled_by)o="Renvoy\xe9",s=n.purple;else if("refund"===r.settled_by||"manual"===r.settled_by){var a;o="Rembours\xe9 (d\xe9cote ".concat(null==(a=r.offer)?void 0:a.discount_percent," %)"),s=n.green}else"rejected"===r.settled_by?(o="Refus\xe9",s=n.red):"reship"===l.action?(o="\xc0 renvoyer",s=n.purple):"refund"===l.action?(o="D\xe9cote ".concat(l.discountPercent," % accept\xe9e"),s=n.blue):(o="Refus\xe9 \xb7 choix client",s=n.orange);else r.settled_by&&(o=({refund:"Rembours\xe9",manual:"Rembours\xe9 (boutique)",exchange:"\xc9chang\xe9",credit:"Avoir \xe9mis"})[r.settled_by]||"Trait\xe9",s=n.green);return o?(0,i.jsx)("span",{style:{fontSize:9,fontWeight:600,color:s,padding:"1px 6px",borderRadius:4,background:"".concat(s,"12"),border:"1px solid ".concat(s,"30")},children:o}):null}let e$={chevronDown:e=>{let{size:t=16,color:n}=e;return(0,i.jsx)("svg",{width:t,height:t,viewBox:"0 0 24 24",fill:"none",stroke:n||"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:(0,i.jsx)("polyline",{points:"6 9 12 15 18 9"})})},printer:e=>{let{size:t=16,color:n}=e;return(0,i.jsxs)("svg",{width:t,height:t,viewBox:"0 0 24 24",fill:"none",stroke:n||"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,i.jsx)("polyline",{points:"6 9 6 2 18 2 18 9"}),(0,i.jsx)("path",{d:"M6 18H4a2 2 0 0 1-2-2v-5a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2v5a2 2 0 0 1-2 2h-2"}),(0,i.jsx)("rect",{x:"6",y:"14",width:"12",height:"8"})]})},refresh:e=>{let{size:t=16,color:n}=e;return(0,i.jsxs)("svg",{width:t,height:t,viewBox:"0 0 24 24",fill:"none",stroke:n||"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,i.jsx)("polyline",{points:"23 4 23 10 17 10"}),(0,i.jsx)("path",{d:"M20.49 15a9 9 0 1 1-2.12-9.36L23 10"})]})},check:e=>{let{size:t=16,color:n}=e;return(0,i.jsx)("svg",{width:t,height:t,viewBox:"0 0 24 24",fill:"none",stroke:n||"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:(0,i.jsx)("polyline",{points:"20 6 9 17 4 12"})})},close:e=>{let{size:t=14,color:n}=e;return(0,i.jsxs)("svg",{width:t,height:t,viewBox:"0 0 24 24",fill:"none",stroke:n||"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,i.jsx)("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),(0,i.jsx)("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})}};function eZ(e){let{checked:t,onChange:n,t:r,size:l=22}=e;return(0,i.jsx)("button",{type:"button",onClick:n,"aria-pressed":t,style:{width:l,height:l,borderRadius:5,border:"1.5px solid ".concat(t?r.green:r.border),background:t?r.green:"transparent",cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center",transition:"border-color 0.15s ease, background 0.15s ease",flexShrink:0,padding:0},children:t&&(0,i.jsx)(e$.check,{size:l-8,color:r.bg})})}function e0(e){let{done:t,total:n,t:r,width:l=60}=e,o=n>0?t/n*100:0;return(0,i.jsxs)("div",{style:{display:"inline-flex",alignItems:"center",gap:8},children:[(0,i.jsx)("div",{style:{width:l,height:3,borderRadius:2,background:r.border,overflow:"hidden"},children:(0,i.jsx)("div",{style:{height:"100%",width:"".concat(o,"%"),background:100===o?r.green:r.gold,borderRadius:2,transition:"width 0.3s ease"}})}),(0,i.jsxs)("span",{style:{fontSize:10,fontFamily:K,color:100===o?r.green:r.textMuted,letterSpacing:"-0.01em"},children:[t,"/",n]})]})}function e1(e){let{title:t,count:n,T:r}=e;return(0,i.jsxs)("header",{style:{display:"flex",alignItems:"baseline",gap:12,paddingBottom:14,marginBottom:4,borderBottom:"1px solid ".concat(r.border)},children:[(0,i.jsx)("h2",{style:{fontSize:11,fontWeight:700,textTransform:"uppercase",letterSpacing:"0.16em",color:r.text,margin:0,fontFamily:G},children:t}),null!=n&&(0,i.jsx)("span",{style:{fontSize:12,color:r.textDim,fontFamily:K,letterSpacing:"-0.01em"},children:n})]})}function e2(e){let{n:t,l:n,T:r,accent:l,first:o}=e;return(0,i.jsxs)("span",{style:{display:"inline-flex",alignItems:"baseline",whiteSpace:"nowrap",marginRight:20}
1,children:[!o&&(0,i.jsx)("span",{"aria-hidden":"true",style:{marginRight:20,opacity:.45,color:r.textMuted},children:"\xb7"}),(0,i.jsx)("span",{style:{fontFamily:K,fontWeight:600,color:l?r.gold:r.text,fontSize:14,letterSpacing:"-0.01em"},children:t}),(0,i.jsx)("span",{style:{marginLeft:6,color:r.textMuted},children:n})]})}function e6(e){let{t,active:n}=e,o=t||J,[s,a]=(0,r.useState)(null),[d,c]=(0,r.useState)(!0),[u,p]=(0,r.useState)(""),[g,x]=(0,r.useState)(""),[h,m]=(0,r.useState)("picking"),[y,b]=(0,r.useState)(new Set),[v,j]=(0,r.useState)(new Set),[S,k]=(0,r.useState)(null),[w,C]=(0,r.useState)(new Set),[_,z]=(0,r.useState)(new Set),[T,D]=(0,r.useState)(!1),[R,I]=(0,r.useState)("desktop");(0,r.useEffect)(()=>{let e=()=>{let e=window.innerWidth;I(e<768?"mobile":e<1024?"tablet":"desktop")};return e(),window.addEventListener("resize",e),()=>window.removeEventListener("resize",e)},[]);let M="mobile"===R,W=(0,r.useCallback)(async()=>{c(!0);let e=await f(u||null);e.success&&(a(e),C(new Set),z(new Set)),c(!1)},[u]);(0,r.useEffect)(()=>{W()},[W]),(0,r.useEffect)(()=>{n&&W()},[n]),(0,r.useEffect)(()=>{if(!n)return;let e=setInterval(()=>{W()},6e4);return()=>clearInterval(e)},[n,W]);let q=e=>!w.has(e),L=e=>!_.has(e),A=(e,t)=>
1"".concat(e.productId,"-").concat(t.variantId),F=(e,t)=>L(A(e,t))?t.orders.filter(e=>q(e.orderName)).reduce((e,t)=>e+t.qty,0):0,E=e=>{z(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},B=async e=>{j(t=>new Set(t).add(e));let t=await l("/orders/pickup-ready",{method:"POST",body:{order_name:e}});if(!t.success){k("".concat(e," — erreur Supabase : ").concat(t.error||"inconnu",". Commande NON masqu\xe9e.")),setTimeout(()=>k(null),1e4),j(t=>{let n=new Set(t);return n.delete(e),n});return}t.shopify_updated||(k("".concat(e," — sauvegard\xe9 localement, mais Shopify n'a pas pu notifier le client (").concat(t.shopify_error||"erreur inconnue",").")),setTimeout(()=>k(null),8e3)),a(t=>t?{...t,packingList:t.packingList.filter(t=>t.orderName!==e),products:t.products.map(t=>({...t,variants:t.variants.map(t=>({...t,orders:t.orders.filter(t=>t.orderName!==e),totalQty:t.orders.filter(t=>t.orderName!==e).reduce((e,t)=>e+t.qty,0)})).filter(e=>e.orders.length>0),totalQty:t.variants.flatMap(t=>t.orders.filter(t=>t.orderName!==e)).reduce((e,t)=>e+t.qty,0)})).filter(e=>e.variants.length>0)}:t),j(t=>{let n=new Set(t);return n.delete(e),n})},P=async()=>{let e=((null==s?void 0:s.packingList)||[]).filter(e=>!e.shippingAddress);0!==e.length&&(D(!0),await Promise.all(e.map(e=>B(e.orderName))),D(!1))},O=(null==s?void 0:s.products)||[],U=g?O.filter(e=>e.title.toLowerCase().includes(g.toLowerCase())||e.variants.some(e=>"".concat(e.variantTitle," ").concat(e.sku||"").toLowerCase().includes(g.toLowerCase()))):O,N=(null==s?void 0:s.packingList)||[],H=g?N.filter(e=>"".concat(e.orderName," ").concat(e.customerName).toLowerCase().includes(g.toLowerCase())):N,V=O.flatMap(e=>e.variants.map(t=>({k:A(e,t),qty:t.orders.filter(e=>q(e.orderName)).reduce((e,t)=>e+t.qty,0)}))),Y=V.reduce((e,t)=>e+t.qty,0),X=V.filter(e=>L(e.k)).reduce((e,t)=>e+t.qty,0);if(d)return(0,i.jsx)("div",{style:{display:"flex",alignItems:"center",justifyContent:"center",height:"100%",padding:40},children:(0,i.jsx)("span",{style:{fontFamily:G,fontSize:22,color:o.textMuted,letterSpacing:"-0.01em"},children:"Inventaire de l'atelier…"})});if(!s)return(0,i.jsxs)("div",{style:{display:"flex",alignItems:"center",justifyContent:"center",flexDirection:"column",height:"100%",padding:40,gap:Q.lg},children:[(0,i.jsx)("span",{style:{fontFamily:G,fontSize:22,color:o.textMuted,letterSpacing:"-0.01em"},children:"Impossible de charger les commandes."}),(0,i.jsx)("button",{onClick:W,style:ei(!0,o),children:"R\xe9essayer"})]});let Z=s.stats.totalOrders||0,ee=s.stats.totalItems||0,et=s.stats.totalProducts||0,en=((null==s?void 0:s.packingList)||[]).some(e=>!e.shippingAddress);return(0,i.jsxs)("div",{style:{padding:M?"28px 20px 80px":"40px 48px 80px",maxWidth:1e3,margin:"0 auto",fontFamily:G,color:o.text,height:"100%",overflowY:"auto",overflowX:"hidden"},children:[(0,i.jsxs)("header",{style:{marginBottom:36},children:[(0,i.jsxs)("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"flex-start",gap:Q.lg,flexWrap:"wrap"},children:[(0,i.jsxs)("div",{style:{flex:1,minWidth:200},children:[(0,i.jsx)("div",{style:{fontSize:10,color:o.textDim,textTransform:"uppercase",letterSpacing:"0.18em",fontWeight:600,marginBottom:12},children:u?new Date(u).toLocaleDateString("fr-FR",{weekday:"long",day:"numeric",month:"long",year:"numeric"}):"Aujourd'hui"}),(0,i.jsx)("h1",{style:{fontSize:"clamp(32px, 6vw, 46px)",fontFamily:G,fontWeight:600,color:o.text,letterSpacing:"-0.015em",lineHeight:1,margin:0},children:"Pr\xe9paration."})]}),(0,i.jsxs)("div",{style:{display:"flex",gap:Q.sm,alignItems:"center",flexShrink:0},children:[(0,i.jsx)("input",{type:"date",value:u,onChange:e=>p(e.target.value),"aria-label":"Filtrer par date",style:{padding:"8px 12px",borderRadius:$.md,border:"1px solid ".concat(o.border),background:o.surfaceAlt,color:o.text,fontSize:12,fontFamily:G,outline:"none",minHeight:38}}),(0,i.jsx)("button",{onClick:W,"aria-label":"Actualiser",style:{background:"transparent",border:"1px solid ".concat(o.border),width:38,height:38,borderRadius:"50%",cursor:"pointer",color:o.textMuted,display:"flex",alignItems:"center",justifyContent:"center",padding:0,flexShrink:0,transition:"border-color 0.2s ease, color 0.2s ease"},children:(0,i.jsx)(e$.refresh,{size:14,color:"currentColor"})}),(0,i.jsxs)("button",{onClick:()=>{let e=window.open("","_blank");if(!e)return;let t=u||new Date().toLocaleDateString("fr-FR"),n=H.filter(e=>q(e.orderName)),i=n.length,r=U.reduce((e,t)=>
1e+t.variants.reduce((e,n)=>e+F(t,n),0),0),l="";for(let e of(null==s?void 0:s.basesList)||[]){for(let t of(l+='<div class="base-group"><div class="base-title">'.concat(e.label,"</div>"),e.sizes))l+='<div class="base-size"><span>'.concat(t.size,'</span><span class="base-qty">').concat(t.qty,"</span></div>");l+="</div>"}let o="";for(let e of U){let t=e.variants.reduce((t,n)=>t+F(e,n),0);if(0!==t)for(let n of(o+='<tr class="prod-hdr"><td></td><td colspan="2">'.concat(e.title.toUpperCase(),' <span class="badge">').concat(t,"</span></td><td></td></tr>"),e.variants)){let t=F(e,n);L(A(e,n))&&0!==t&&(o+='<tr><td class="cb">☐</td><td style="padding-left:12px;">• '.concat(n.variantTitle,'</td><td style="color:#888;font-size:10px;">').concat(n.sku||"—",'</td><td style="text-align:right;font-weight:700;">').concat(t,"</td></tr>"))}}let a="";for(let e of n){let t=e.items.filter(e=>L(e.key));if(0!==t.length){if(a+='<div class="order"><div class="order-header">',a+='<div class="order-top"><strong>'.concat(e.orderName,"</strong> — ").concat(e.customerName||""),e.carrier&&(a+=' <span class="carrier">'.concat(e.carrier,"</span>")),e.shippingAddress||(a+=' <span class="carrier">Retrait</span>'),a+="</div>",e.shippingAddress){let t=e.shippingAddress,n=[t.name,t.address1,t.address2,[t.zip,t.city].filter(Boolean).join(" "),t.country].filter(Boolean).join(" \xb7 ");a+='<div class="shipping-addr">'.concat(n,"</div>")}for(let e of(a+='</div><table class="items">',t))a+='<tr><td class="cb">☐</td><td>'.concat(e.title," — ").concat(e.variant,'</td><td style="color:#888;font-size:10px;">').concat(e.sku||"",'</td><td style="text-align:right;">\xd7').concat(e.qty,"</td></tr>");a+="</table></div>"}}
1e.document.write('<!DOCTYPE html><html><head><meta charset="utf-8"/><title>Pr\xe9paration '.concat(t,'</title>\n<style>\n  * { margin:0; padding:0; box-sizing:border-box; }\n  body { font-family:Georgia, serif; font-size:12px; padding:24px; color:#2b2520; }\n  h1 { font-family:Georgia, serif; font-size:24px; font-weight:400; margin-bottom:4px; letter-spacing:-0.01em; }\n  h2 { font-size:11px; margin:24px 0 12px; padding-bottom:8px; border-bottom:1px solid #2b2520; text-transform:uppercase; letter-spacing:.16em; font-weight:700; }\n  .subtitle { color:#5a5550; font-size:11px; margin-bottom:16px; font-family:-apple-system,sans-serif; }\n  table { width:100%; border-collapse:collapse; margin-bottom:8px; font-family:-apple-system,sans-serif; }\n  td { padding:5px 8px; border-bottom:1px solid #e8e0d8; vertical-align:top; }\n  td.cb { width:20px; font-size:14px; color:#a09890; padding-right:4px; }\n  tr.prod-hdr td { background:#f7f4ee; font-weight:700; font-size:10px; text-transform:uppercase; letter-spacing:.08em; padding:8px; }\n  .badge { background:#2b2520; color:#ede8e3; padding:2px 8px; border-radius:10px; font-size:10px; margin-left:8px; font-weight:700; font-family:monospace; }\n  .order { margin-bottom:16px; page-break-inside:avoid; border:1px solid #e8e0d8; border-radius:6px; overflow:hidden; }\n  .order-header { padding:8px 12px; background:#f7f4ee; font-family:-apple-system,sans-serif; }\n  .order-top { display:flex; align-items:center; gap:8px; }\n  .shipping-addr { font-size:10px; color:#5a5550; margin-top:4px; }\n  .carrier { background:#e8e0d8; padding:2px 8px; border-radius:10px; font-size:10px; }\n  .bases-grid { display:flex; flex-wrap:wrap; gap:16px; margin-bottom:8px; font-family:-apple-system,sans-serif; }\n  .base-group { border:1px solid #e8e0d8; border-radius:6px; padding:12px 14px; min-width:140px; page-break-inside:avoid; }\n  .base-title { font-weight:700; font-size:11px; text-transform:uppercase; border-bottom:1px solid #e8e0d8; padding-bottom:6px; margin-bottom:6px; letter-spacing:.08em; }\n  .base-size { display:flex; justify-content:space-between; padding:3px 0; font-size:12px; }\n  .base-qty { font-weight:700; font-family:monospace; }\n  @media print {\n    body { padding:12px; }\n    h2 { margin-top:14px; }\n    .order { page-break-inside:avoid; }\n  }\n</style></head><body>\n<h1>Fiche de pr\xe9paration</h1>\n<div class="subtitle">').concat(t," — ").concat(i," commande").concat(i>1?"s":""," \xb7 ").concat(r," article").concat(r>1?"s":"",'</div>\n<h2>1. Bases \xe0 r\xe9cup\xe9rer</h2>\n<div class="bases-grid">').concat(l,"</div>\n<h2>2. Picking par produit</h2>\n<table>").concat(o,"</table>\n<h2>3. Colisage par commande</h2>\n").concat(a,"\n</body></html>")),e.document.close(),setTimeout(()=>e.print(),300)},style:{...ei(!0,o),padding:"8px 14px",minHeight:38},"aria-label":"Imprimer la fiche",children:[(0,i.jsx)(e$.printer,{size:13,color:o.bg}),!M&&(0,i.jsx)("span",{children:"Imprimer"})]})]})]}),(0,i.jsxs)("div",{style:{marginTop:24,fontSize:14,color:o.textMuted,fontFamily:G,lineHeight:1.7},children:[(0,i.jsx)(e2,{first:!0,n:Z,l:"commande".concat(1!==Z?"s":""),T:o}),(0,i.jsx)(e2,{n:ee,l:"article".concat(1!==ee?"s":""," \xe0 picker"),T:o}),(0,i.jsx)(e2,{n:et,l:"produit".concat(1!==et?"s":""," diff\xe9rent").concat(1!==et?"s":""),T:o}),Y>0&&(0,i.jsxs)("span",{style:{display:"inline-flex",alignItems:"center",whiteSpace:"nowrap"},children:[(0,i.jsx)("span",{"aria-hidden":"true",style:{marginRight:16,opacity:.45,color:o.textMuted},children:"\xb7"}),(0,i.jsx)(e0,{done:X,total:Y,t:o,width:M?60:100})]})]}),(0,i.jsxs)("div",{style:{marginTop:24,display:"flex",gap:Q.sm,alignItems:"center",flexWrap:"wrap"},children:[(0,i.jsx)("div",{style:{position:"relative",flex:1,minWidth:200,maxWidth:M?"100%":360},children:(0,i.jsx)("input",{type:"text",placeholder:"Rechercher commande ou produit…",value:g,onChange:e=>x(e.target.value),style:{width:"100%",padding:"10px 14px",borderRadius:$.md,border:"1px solid ".concat(o.border),background:o.surfaceAlt,color:o.text,fontSize:13,fontFamily:G,outline:"none",minHeight:40,boxSizing:"border-box"}})}),en&&(0,i.jsx)("button",{onClick:P,disabled:T,style:{...ei(!1,o),padding:"8px 14px",minHeight:40,color:o.purple,borderColor:o.purple,opacity:T?.5:1},title:"Marquer toutes les commandes retrait comme pr\xeates",children:T?"Marquage…":"✓ Retraits pr\xeats"})]})]}),S&&(0,i.jsxs)("div",{style:{marginBottom:Q.lg,padding:"10px 14px",background:"".concat(o.orange,"10"),border:"1px solid ".concat(o.orange,"40"),borderRadius:$.md,fontSize:12,color:o.orange,display:"flex",alignItems:"center",justifyContent:"space-between",gap:8},children:[(0,i.jsx)("span",{children:S}),(0,i.jsx)("button",{onClick:()=>k(null),"aria-label":"Fermer",style:{background:"none",border:"none",cursor:"pointer",color:o.orange,padding:4,lineHeight:1,display:"flex",alignItems:"center"},children:(0,i.jsx)(e$.close,{size:14,color:"currentColor"})})]}),(0,i.jsx)("div",{style:{display:"flex",gap:Q.xxl,marginBottom:28,paddingBottom:14,borderBottom:"1px solid ".concat(o.border)},children:[{id:"picking",label:"Picking"},{id:"packing",label:"Colisage"}].map(e=>(0,i.jsxs)("button",{onClick:()=>m(e.id),style:{background:"transparent",border:"none",cursor:"pointer",padding:0,fontFamily:G,fontSize:11,fontWeight:700,textTransform:"uppercase",letterSpacing:"0.16em",color:h===e.id?o.text:o.textMuted,position:"relative",minHeight:32,transition:"color 0.2s ease"},"aria-pressed":h===e.id,children:[e.label,h===e.id&&(0,i.jsx)("span",{style:{position:"absolute",bottom:-15,left
1:0,right:0,height:2,background:o.text}})]},e.id))}),"picking"===h?0===U.length?(0,i.jsx)(e4,{T:o,children:"Aucun article \xe0 picker."}):(0,i.jsxs)(i.Fragment,{children:[((null==s?void 0:s.basesList)||[]).length>0&&(0,i.jsxs)("section",{style:{marginBottom:48},children:[(0,i.jsx)(e1,{title:"Bases \xe0 r\xe9cup\xe9rer",T:o}),(0,i.jsx)("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fill, minmax(".concat(M?140:180,"px, 1fr))"),gap:Q.md,marginTop:Q.lg},children:s.basesList.map(e=>(0,i.jsxs)("div",{style:{padding:Q.md,borderTop:"1px solid ".concat(o.border)},children:[(0,i.jsxs)("div",{style:{fontSize:10,fontWeight:700,color:o.text,textTransform:"uppercase",letterSpacing:"0.1em",paddingBottom:6,marginBottom:8,display:"flex",justifyContent:"space-between"},children:[(0,i.jsx)("span",{children:e.label}),(0,i.jsx)("span",{style:{fontFamily:K,color:o.textMuted},children:e.totalQty})]}),e.sizes.map(e=>(0,i.jsxs)("div",{style:{display:"flex",justifyContent:"space-between",padding:"3px 0",fontSize:13,color:o.text},children:[(0,i.jsx)("span",{children:e.size}),(0,i.jsx)("span",{style:{fontWeight:700,fontFamily:K},children:e.qty})]},e.size))]},e.label))})]}),(0,i.jsxs)("section",{children:[(0,i.jsx)(e1,{title:"D\xe9tail par produit",count:U.length,T:o}),(0,i.jsx)("div",{style:{marginTop:8},children:U.map(e=>{let t=e.variants.reduce((e,t)=>e+t.orders.filter(e=>q(e.orderName)).reduce((e,t)=>e+t.qty,0),0);return(0,i.jsxs)("div",{style:{marginBottom:Q.xl},children:[(0,i.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:Q.md,padding:"12px 0",borderBottom:"1px solid ".concat(o.border)},children:[e.image&&(0,i.jsx)("img",{src:e.image,style:{width:36,height:36,borderRadius:6,objectFit:"cover",border:"1px solid ".concat(o.border),flexShrink:0},alt:e.title}),(0,i.jsx)("span",{style:{flex:1,fontSize:13,fontWeight:600,color:o.text,letterSpacing:"-0.01em"},children:e.title}),(0,i.jsx)("span",{style:{fontFamily:K,fontSize:14,fontWeight:700,color:o.text,letterSpacing:"-0.01em"},children:t})]}),e.variants.map(t=>{let n=A(e,t),r=F(e,t),l=L(n);return(0,i.jsxs)("label",{className:"op-row",style:{display:"flex",alignItems:"center",gap:Q.md,padding:"12px 0",borderBottom:"1px solid ".concat(o.border),opacity:l?1:.4,transition:"opacity 0.15s ease",cursor:"pointer"},children:[(0,i.jsx)(eZ,{checked:l,onChange:()=>E(n),t:o,size:22}),(0,i.jsx)("span",{style:{flex:1,fontSize:13,color:o.text,fontWeight:500},children:t.variantTitle}),(0,i.jsx)("span",{style:{fontSize:10,fontFamily:K,color:o.textDim,minWidth:80*!M,display:M?"none":"inline"},children:t.sku||"—"}),(0,i.jsx)("span",{style:{fontSize:14,fontWeight:700,fontFamily:K,color:r>0?o.text:o.textDim,minWidth:32,textAlign:"right",letterSpacing:"-0.01em"},children:r})]},n)})]},e.productId)})})]})]}):0===H.length?(0,i.jsx)(e4,{T:o,children:"Aucune commande \xe0 coliser."}):(0,i.jsxs)("section",{children:[(0,i.jsx)(e1,{title:"Commandes du jour",count:H.length,T:o}),(0,i.jsx)("div",{style:{marginTop:8},children:H.map(e=>{let t=!y.has(e.orderName),n=q(e.orderName),r=n?e.items.filter(e=>L(e.key)).length:0,l=v.has(e.orderName),s=!e.shippingAddress;return(0,i.jsxs)("div",{style:{borderBottom:"1px solid ".concat(o.border),opacity:n?1:.55,transition:"opacity 0.2s ease"},children:[(0,i.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:Q.md,padding:"14px 0"},children:[(0,i.jsx)("div",{onClick:e=>e.stopPropagation(),children:(0,i.jsx)(eZ,{checked:n,onChange:()=>{var t,n;return t=e.orderName,void(null==n||n.stopPropagation(),C(e=>{let n=new Set(e);return n.has(t)?n.delete(t):n.add(t),n}))},t:o,size:22})}),(0,i.jsxs)("button",{type:"button",onClick:()=>{var t;return t=e.orderName,void b(e=>{let n=new Set(e);return n.has(t)?n.delete(t):n.add(t),n})},"aria-expanded":t,style:{flex:1,display:"flex",alignItems:"center",gap:Q.md,background:"transparent",border:"none",cursor:"pointer",padding:0,textAlign:"left",color:o.text,minHeight:44},children:[(0,i.jsx)("span",{style:{display:"inline-flex",transition:"transform 0.2s ease",transform:t?"rotate(0deg)":"rotate(-90deg)",color:o.textMuted,flexShrink:0},children:(0,i.jsx)(e$.chevronDown,{size:14,color:"currentColor"})}),(0,i.jsx)("span",{style:{fontFamily:K,fontSize:13,fontWeight:600,color:o.text,letterSpacing:"-0.01em",flexShrink:0},children:e.orderName}),!M&&(0,i.jsx)("span",{style:{fontSize:13,color:o.text,fontWeight:500,flex:1,whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:e.customerName}),(0,i.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:8,marginLeft:"auto",flexShrink:0},children:[e.carrier&&(0,i.jsx)("span",{style:{fontSize:9,fontWeight:600,color:o.blue,textTransform:"uppercase",letterSpacing:"0.08em",padding:"2px 8px",borderRadius:$.pill,background:"".concat(o.blue,"10"),border:"1px solid ".concat(o.blue,"25"),whiteSpace:"nowrap"},children:e.carrier}),s&&(0,i.jsx)("span",{style:{fontSize:9,fontWeight:600,color:o.purple,textTransform:"uppercase",letterSpacing:"0.08em",padding:"2px 8px",borderRadius:$.pill,background:"".concat(o.purple,"10"),border:"1px solid ".concat(o.purple,"25"),whiteSpace:"nowrap"},children:"Retrait"}
1),!M&&(0,i.jsx)(e0,{done:r,total:e.items.length,t:o,width:50})]})]})]}),M&&(0,i.jsx)("div",{style:{padding:"0 0 10px 38px",fontSize:12,color:o.textMuted},children:e.customerName}),t&&(0,i.jsxs)("div",{style:{paddingBottom:14},children:[e.items.map((e,t)=>{let r=L(e.key)&&n;return(0,i.jsxs)("label",{className:"op-row",style:{display:"flex",alignItems:"center",gap:Q.md,padding:"10px 0 10px 38px",borderTop:0===t?"1px solid ".concat(o.border):"none",opacity:r?1:.4,transition:"opacity 0.15s ease",cursor:"pointer",fontSize:13},children:[(0,i.jsx)(eZ,{checked:L(e.key),onChange:()=>E(e.key),t:o,size:18}),e.image&&(0,i.jsx)("img",{src:e.image,alt:e.title,style:{width:28,height:28,borderRadius:4,objectFit:"cover",flexShrink:0}}),(0,i.jsx)("span",{style:{flex:1,color:o.text,fontWeight:500,whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:e.title}),!M&&(0,i.jsx)("span",{style:{color:o.textMuted,fontSize:12,minWidth:110},children:e.variant}),(0,i.jsxs)("span",{style:{fontWeight:700,fontFamily:K,color:o.text,minWidth:32,textAlign:"right",letterSpacing:"-0.01em"},children:["\xd7",e.qty]})]},t)}),s&&(0,i.jsx)("div",{style:{padding:"12px 0 0 38px"},children:(0,i.jsx)("button",{type:"button",onClick:()=>B(e.orderName),disabled:l,style:{...ei(!1,o),padding:"8px 14px",fontSize:11,color:o.purple,borderColor:o.purple,opacity:l?.5:1},children:l?"Marquage…":"✓ Marquer pr\xeate au retrait"})})]})]},e.orderName)})})]}),(0,i.jsx)("style",{children:"\n        @keyframes spin { from { transform: rotate(0deg); } to { transform: rotate(360deg); } }\n        .op-row:hover {\n          background: ".concat(o.surfaceAlt,";\n          margin: 0 -12px;\n          padding-left: 12px !important;\n          padding-right: 12px !important;\n        }\n      ")})]})}function e4(e){let{T:t,children:n}=e;return(0,i.jsx)("div",{style:{padding:"48px 0 24px",textAlign:"left",fontFamily:G,fontSize:24,color:t.textMuted,letterSpacing:"-0.01em",lineHeight:1.3},children:n})}let e5={chevronDown:e=>{let{size:t=16,color:n}=e;return(0,i.jsx)("svg",{width:t,height:t,viewBox:"0 0 24 24",fill:"none",stroke:n||"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:(0,i.jsx)("polyline",{points:"6 9 12 15 18 9"})})},refresh:e=>{let{size:t=16,color:n}=e;return(0,i.jsxs)("svg",{width:t,height:t,viewBox:"0 0 24 24",fill:"none",stroke:n||"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,i.jsx)("polyline",{points:"23 4 23 10 17 10"}),(0,i.jsx)("path",{d:"M20.49 15a9 9 0 1 1-2.12-9.36L23 10"})]})},truck:e=>{let{size:t=16,color:n}=e;return(0,i.jsxs)("svg",{width:t,height:t,viewBox:"0 0 24 24",fill:"none",stroke:n||"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,i.jsx)("rect",{x:"1",y:"3",width:"15",height:"13",rx:"1"}),(0,i.jsx)("polygon",{points:"16 8 20 8 23 11 23 16 16 16 16 8"}),(0,i.jsx)("circle",{cx:"5.5",cy:"18.5",r:"2.5"}),(0,i.jsx)("circle",{cx:"18.5",cy:"18.5",r:"2.5"})]})},download:e=>{let{size:t=16,color:n}=e;return(0,i.jsxs)("svg",{width:t,height:t,viewBox:"0 0 24 24",fill:"none",stroke:n||"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,i.jsx)("path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"}),(0,i.jsx)("polyline",{points:"7 10 12 15 17 10"}),(0,i.jsx)("line",{x1:"12",y1:"15",x2:"12",y2:"3"})]})},check:e=>{let{size:t=16,color:n}=e;return(0,i.jsx)("svg",{width:t,height:t,viewBox:"0 0 24 24",fill:"none",stroke:n||"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:(0,i.jsx)("polyline",{points:"20 6 9 17 4 12"})})},settings:e=>{let{size:t=16,color:n}=e;return(0,i.jsxs)("svg",{width:t,height:t,viewBox:"0 0 24 24",fill:"none",stroke:n||"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,i.jsx)("circle",{cx:"12",cy:"12",r:"3"}),(0,i.jsx)("path",{d:"M12 1v4M12 19v4M4.2 4.2l2.8 2.8M17 17l2.8 2.8M1 12h4M19 12h4M4.2 19.8L7 17M17 7l2.8-2.8"})]})},copy:e=>{let{size:t=13,color:n}=e;return(0,i.jsxs)("svg",{width:t,height:t,viewBox:"0 0 24 24",fill:"none",stroke:n||"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,i.jsx)("rect",{x:"9",y:"9",width:"13",height:"13",rx:"2"}),(0,i.jsx)("path",{d:"M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1"})]})}};function e3(e){let{checked:t,onChange:n,t:r,size:l=18,disabled:o}=e;return(0,i.jsx)("button",{type:"button",onClick:o?void 0:n,"aria-pressed":t,style:{width:l,height:l,borderRadius:5,border:"1.5px solid ".concat(t?r.green:r.border),background:t?r.green:"transparent",curs
1or:o?"default":"pointer",display:"flex",alignItems:"center",justifyContent:"center",transition:"border-color 0.15s ease, background 0.15s ease",flexShrink:0,padding:0,opacity:o?.4:1},children:t&&(0,i.jsx)(e5.check,{size:l-8,color:r.bg})})}function e8(e){let{label:t,hint:n,checked:r,onChange:l,t:o,disabled:s}=e;return(0,i.jsxs)("label",{style:{display:"flex",alignItems:"flex-start",gap:10,cursor:s?"default":"pointer"},onClick:s?void 0:l,children:[(0,i.jsx)(e3,{checked:r,onChange:l,t:o,disabled:s}),(0,i.jsxs)("span",{style:{fontSize:12,color:s?o.textDim:o.text,lineHeight:1.4},children:[t,n&&(0,i.jsx)("span",{style:{display:"block",fontSize:10,color:o.textDim},children:n})]})]})}let e7={colissimo:"Colissimo",dpd:"DPD"},e9=(e,t)=>{let n=URL.createObjectURL(e),i=document.createElement("a");i.href=n,i.download=t,i.click(),URL.revokeObjectURL(n)};function te(e){var t,o,s,a,d,c,u,p,g,x,h,m,f,v,j,S,k,w;let{t:C,active:_}=e,z=C||J,[T,D]=(0,r.useState)(null),[R,I]=(0,r.useState)(!0),[M,W]=(0,r.useState)(""),[q,L]=(0,r.useState)(null),[A,F]=(0,r.useState)({}),[E,B]=(0,r.useState)(null),[P,O]=(0,r.useState)(null),[U,N]=(0,r.useState)(null),[H,V]=(0,r.useState)(null),[Y,X]=(0,r.useState)(!1),[ee,en]=(0,r.useState)(null),[el,es]=(0,r.useState)(!1),[ed,ec]=(0,r.useState)(null),[ep,eg]=(0,r.useState)(!1),[ex,eh]=(0,r.useState)({}),[em,ef]=(0,r.useState)({}),[ey,eb]=(0,r.useState)(null),[ev,ej]=(0,r.useState)(null),[eS,ek]=(0,r.useState)(null);(0,r.useEffect)(()=>{let e=()=>eg(window.innerWidth<640);return e(),window.addEventListener("resize",e),()=>window.removeEventListener("resize",e)},[]);let ew=(0,r.useCallback)(async()=>{I(!0);try{let e=await l("/expedition/orders");e.success&&D(e)}catch(e){console.error("Expedition load error:",e)}I(!1)},[]);(0,r.useEffect)(()=>{_&&ew()},[_,ew]);let eC=(null==T?void 0:T.settings)||{},e_=(null==T?void 0:T.orders)||[],ez=(null==T?void 0:T.carriers)||[{id:"colissimo",name:"Colissimo (La Poste)",available:!0}],eT=e=>{var t;return(null==(t=ez.find(e=>"dpd"===e.id))?void 0:t.available)&&/dpd|predict/i.test(e.shipping_method||"")?"dpd":eC.carrier||"colissimo"},eD=e=>e.shipping_method||"Autre",eR=e=>/mondial/i.test(e.shipping_method||""),eI=[...new Set(e_.map(eD))].sort(),eM=e=>!1!==em[e],eW=e=>{var t,n;return null!=(n=ex[e.shopify_order_id])?n:!(null==(t=e.shipment)?void 0:t.tracking_code)&&!eR(e)},eq=e_.filter(e=>{var t,n;if(!eM(eD(e)))return!1;if(!M)return!0;let i=M.toLowerCase();return(e.name||"").toLowerCase().includes(i)||((null==(t=e.customer)?void 0:t.name)||"").toLowerCase().includes(i)||((null==(n=e.shipping_address)?void 0:n.city)||"").toLowerCase().includes(i)}),eL=eq.filter(eW),eA=eL.filter(e=>{var t;return!(null==(t=e.shipment)?void 0:t.tracking_code)}),eF=e=>eh(t=>{let n={...t};return eq.forEach(t=>{n[t.shopify_order_id]=e}),n}),eE=e=>{var t,n,i;let r=A[e.shopify_order_id]||{};return{weight:void 0!==r.weight?r.weight:e.weight_estimate_kg||eC.defaultWeightKg||.25,carrier:r.carrier||(null==(t=e.shipment)?void 0:t.carrier)||eT(e),productCode:r.productCode||(null==(n=e.shipment)?void 0:n.product_code)||eC.productCode||"DOM",includeSlip:void 0!==r.includeSlip?r.includeSlip:!!eC.includeSlipDefault,fulfill:void 0!==r.fulfill?r.fulfill:!1!==eC.fulfillOnGenerate,notifyCustomer:void 0!==r.notifyCustomer?r.notifyCustomer:(null==(i=e.shipment)||!i.tracking_code)&&!1!==eC.notifyCustomerDefault,address:r.address||null}},eB=(e,t)=>F(n=>({...n,[e]:{...n[e]||{},...t}})),eP=(e,t,n)=>F(i=>{var r;return{...i,[e]:{...i[e]||{},address:{...(null==(r=i[e])?void 0:r.address)||{},[t]:n}}}}),eO=(0,r.useRef)(null),eU=(e,t)=>{clearTimeout(eO.current),V({kind:e,msg:t}),eO.current=setTimeout(()=>V(null),"ok"===e?5e3:1e4)};(0,r.useEffect)(()=>()=>clearTimeout(eO.current),[]);let eN=async function(e){var t,n,i;let r=arguments.length>1&&void 0!==arguments[1]&&arguments[1],l=eE(e);if(!r||window.confirm("R\xe9g\xe9n\xe9rer l'\xe9tiquette de ".concat(e.name," ? Un nouveau n\xb0 de suivi remplacera ").concat((null==(t=e.shipment)?void 0:t.tracking_code)||"l'ancien","."))){B(e.shopify_order_id);try{let t=await y(e.shopify_order_id,{weight:parseFloat(l.weight)||void 0,carrier:l.carrier,productC
1ode:l.productCode,includeSlip:l.includeSlip,fulfill:l.fulfill,notifyCustomer:l.notifyCustomer,addressOverride:l.address||void 0,force:r});if(!t.success)throw Error(t.error||"Erreur inconnue");t.label_pdf_b64&&(n=t.label_pdf_b64,i="etiquette-".concat(e.name,".pdf"),e9(new Blob([Uint8Array.from(atob(n),e=>e.charCodeAt(0))],{type:"application/pdf"}),i)),eU(t.warning?"warn":"ok",t.warning||"\xc9tiquette ".concat(e.name," g\xe9n\xe9r\xe9e — suivi ").concat(t.tracking_code)),await ew()}catch(t){eU("err","\xc9chec g\xe9n\xe9ration ".concat(e.name," : ").concat(t.message))}B(null)}},eH=async()=>{if(!eA.length||!window.confirm("G\xe9n\xe9rer ".concat(eA.length," \xe9tiquette").concat(eA.length>1?"s":""," avec les r\xe9glages par d\xe9faut ?")))return;eb({done:0,total:eA.length});let e=[],t=[];for(let n of eA){try{var i,r;let l=await y(n.shopify_order_id,{carrier:(null==(i=A[n.shopify_order_id])?void 0:i.carrier)||eT(n),includeSlip:!!eC.includeSlipDefault,fulfill:!1!==eC.fulfillOnGenerate,notifyCustomer:!1!==eC.notifyCustomerDefault,addressOverride:(null==(r=A[n.shopify_order_id])?void 0:r.address)||void 0});if(!l.success)throw Error(l.error||"Erreur inconnue");l.warning&&t.push("".concat(n.name," : ").concat(l.warning)),l.label_pdf_b64&&e.push(l.label_pdf_b64)}catch(e){t.push("".concat(n.name," : ").concat(e.message))}eb(e=>e?{...e,done:e.done+1}:e)}try{if(e.length){let{PDFDocument:t}=await n.e(3394).then(n.bind(n,3394)),i=await t.create();for(let n of e){let e=await t.load(Uint8Array.from(atob(n),e=>e.charCodeAt(0)));(await i.copyPages(e,e.getPageIndices())).forEach(e=>i.addPage(e))}let r=await i.save();e9(new Blob([r],{type:"application/pdf"}),"etiquettes-".concat(new Date().toISOString().slice(0,10),".pdf"))}}catch(e){t.push("Fusion PDF : ".concat(e.message))}eb(null),eU(t.length?"warn":"ok","".concat(e.length,"/").concat(eA.length," \xe9tiquette").concat(e.length>1?"s":""," g\xe9n\xe9r\xe9e").concat(e.length>1?"s":"").concat(t.length?" — ".concat(t.join(" \xb7 ")):"")),await ew()},eV=async e=>{O(e.shopify_order_id);try{let t="90bf72b266b57db5941529bb5241cfc5da01f7f651e1ffc3e760f2b8b189d823",n=await fetch("/api/expedition/".concat(e.shopify_order_id,"/download-label"),{headers:t?{Authorization:"Bearer ".concat(t)}:{}});if(!n.ok)throw Error("Erreur ".concat(n.status));e9(await n.blob(),"etiquette-".concat(e.name,".pdf"))}catch(e){eU("err","T\xe9l\xe9chargement impossible : ".concat(e.message))}O(null)},eG=async e=>{let t=eE(e);N(e.shopify_order_id);try{let n,i,r=await (n=e.shopify_order_id,i=t.notifyCustomer,l("/expedition/".concat(encodeURIComponent(n),"/fulfill"),{method:"POST",body:{notifyCustomer:i}}));if(!r.success)throw Error(r.error||"Erreur inconnue");eU("ok","".concat(e.name," marqu\xe9e trait\xe9e dans Shopify")),await ew()}catch(t){eU("err","Fulfillment ".concat(e.name," : ").concat(t.message))}N(null)},eK=(e,t,n)=>en(i=>{var r;return{...i,credentials:{...i.credentials,[e]:{...(null==(r=i.credentials)?void 0:r[e])||{},[t]:n}}}}),eY=async()=>{es(!0);try{let e=await l("/expedition/config",{method:"PATCH",body:ee});if(!e.success)throw Error(e.error||"Erreur inconnue");D(t=>({...t,settings:e.settings,carriers:e.carriers||t.carriers})),X(!1),eU("ok","Param\xe8tres d'exp\xe9dition enregistr\xe9s")}catch(e){eU("err","Sauvegarde impossible : ".concat(e.message))}es(!1)};if(R&&!T)return(0,i.jsx)("div",{style:{display:"flex",alignItems:"center",justifyContent:"center",height:"100%",padding:40},children:(0,i.jsx)("span",{style:{fontFamily:G,fontSize:22,color:z.textMuted},children:"Chargement des commandes…"})});if(!T)return(0,i.jsxs)("div",{style:{display:"flex",alignItems:"center",justifyContent:"center",flexDirection:"column",height:"100%",padding:40,gap:Q.lg},children:[(0,i.jsx)("span",{style:{fontFamily:G,fontSize:22,color:z.textMuted},children:"Impossible de charger les commandes."}),(0,i.jsx)("button",{onClick:ew,style:ei(!0,z),children:"R\xe9essayer"})]});let eJ=e_.filter(e=>{var t;return!(null==(t=e.shipment)?void 0:t.tracking_code)}).length,eX=e_.filter(e=>{var t;return null==(t=e.shipment)?void 0:t.tracking_code}).length,eQ=async e=>{var t,n,i;let r=String(null!=(i=(A[e.shopify_order_id]||{}).mrPhone)?i:(null==(t=e.shipping_address)?void 0:t.phone)||(null==(n=e.customer)?void 0:n.phone)||"").trim()||"0600000000";ej(e.shopify_order_id);try{let t,n=await (t=e.shopify_order_id,l("/expedition/".concat(encodeURIComponent(t),"/prepare-mondial-relay"),{method:"POST",body:{phone:r}}));if(!n.success)throw Error(n.error||"Erreur");eU("ok","T\xe9l. ".concat(n.phone," enregistr\xe9 sur ").concat(e.name," — achetez l'\xe9tiquette Mondial Relay dans l'onglet Shopify ouvert")),window.open(n.admin_url,"_blank","noopener")}catch(e){eU("err",e.message)}ej(null)},e$=async()=>{ek({loading:!0});try{let e=await b(!1);if(!e.success)throw Error(e.error||"Erreur");ek({report:e})}catch(e){eU("err",e.message),ek(null)}},eZ=async()=>{ek(e=>({...e,applying:!0}));try{var e;let t=await b(!0);if(!t.success)throw Error(t.error||"Erreur");eU("ok","".concat(t.fixed," t\xe9l\xe9phone(s) corrig\xe9(s)").concat((null==(e=t.errors)?void 0:e.length)?" — ".concat(t.errors.length," \xe9chec(s)"):"")),ek(null),await ew()}catch(e){eU("err",e.message),ek(e=>({...e,applying:!1}))}},e0=e_.filter(eR).length;return(0,i.jsxs)("div",{style:{padding:ep?"28px 20px 80px":"40px 48px 80px",maxWidth:1e3,margin:"0 auto",fontFamily:G,color:z.text,height:"100%",overflowY:"auto",overflowX:"hidden"},children:[(0,i.jsxs)("header",{style:{marginBottom:28},children:[(0,i.jsxs)("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"flex-start",ga
1p:Q.lg,flexWrap:"wrap"},children:[(0,i.jsxs)("div",{style:{flex:1,minWidth:200},children:[(0,i.jsxs)("div",{style:{fontSize:10,color:z.textDim,textTransform:"uppercase",letterSpacing:"0.18em",fontWeight:600,marginBottom:12},children:[((null==(t=((null==T?void 0:T.carriers)||[]).find(e=>e.id===(eC.carrier||"colissimo")))?void 0:t.name)||"Colissimo").split(" (")[0]," — \xe9tiquettes sortantes"]}),(0,i.jsx)("h1",{style:{fontSize:"clamp(32px, 6vw, 46px)",fontFamily:G,fontWeight:600,color:z.text,letterSpacing:"-0.015em",lineHeight:1,margin:0},children:"Exp\xe9dition."})]}),(0,i.jsxs)("div",{style:{display:"flex",gap:Q.sm,alignItems:"center",flexShrink:0},children:[(0,i.jsx)("button",{onClick:ew,"aria-label":"Actualiser",style:{background:"transparent",border:"1px solid ".concat(z.border),width:38,height:38,borderRadius:"50%",cursor:"pointer",color:z.textMuted,display:"flex",alignItems:"center",justifyContent:"center",padding:0,flexShrink:0},children:(0,i.jsx)(e5.refresh,{size:14,color:"currentColor"})}),(0,i.jsx)("button",{onClick:e$,disabled:null==eS?void 0:eS.loading,style:{...ei(!1,z),padding:"8px 14px",minHeight:38},children:(null==eS?void 0:eS.loading)?"Scan…":"☎ D\xe9bug t\xe9l\xe9phones"}),(0,i.jsxs)("button",{onClick:Y?()=>X(!1):()=>{var e,t;en({...eC,credentials:{colissimo:{contractNumber:"",password:"",...(null==(e=eC.credentials)?void 0:e.colissimo)||{}},dpd:{userid:"",password:"",centerNumber:"",customerNumber:"",countryCode:"250",env:"prod",endpoint:"",...(null==(t=eC.credentials)?void 0:t.dpd)||{}}}}),X(!0)},style:{...ei(!1,z),padding:"8px 14px",minHeight:38},children:[(0,i.jsx)(e5.settings,{size:13,color:"currentColor"}),!ep&&(0,i.jsx)("span",{children:"R\xe9glages"})]})]})]}),(null==eS?void 0:eS.report)&&(0,i.jsx)("div",{style:{position:"fixed",inset:0,zIndex:1e3,background:"rgba(0,0,0,0.55)",display:"flex",alignItems:"center",justifyContent:"center",padding:Q.xl},onClick:()=>!eS.applying&&ek(null),children:(0,i.jsxs)("div",{style:{background:z.surface,borderRadius:$.lg,width:"min(560px, 96vw)",maxHeight:"85vh",overflowY:"auto",padding:Q.xl},onClick:e=>e.stopPropagation(),children:[(0,i.jsx)("div",{style:{fontWeight:600,fontSize:15,marginBottom:Q.sm},children:"D\xe9bug t\xe9l\xe9phones"}),(0,i.jsxs)("div",{style:{fontSize:12.5,color:z.textMuted,marginBottom:Q.lg,lineHeight:1.5},children:[eS.report.checked," commande(s) ouvertes analys\xe9es. Un portable de fallback au format du pays sera pos\xe9 quand le t\xe9l\xe9phone est absent ou n'est pas un mobile (fixe, mauvais format) — c'est ce qui bloque les \xe9tiquettes."]}),0===eS.report.to_fix.length?(0,i.jsx)("div",{style:{fontSize:13,color:z.green,marginBottom:Q.lg},children:"Aucune commande \xe0 corriger, tous les t\xe9l\xe9phones sont valides ✓"}):(0,i.jsx)("div",{style:{border:"1px solid ".concat(z.border),borderRadius:$.md,marginBottom:Q.lg,overflow:"hidden"},children:eS.report.to_fix.map((e,t)=>(0,i.jsxs)("div",{style:{display:"flex",gap:Q.md,alignItems:"center",padding:"".concat(Q.sm,"px ").concat(Q.md,"px"),borderTop:t?"1px solid ".concat(z.borderLight):"none",fontSize:12,flexWrap:"wrap"},children:[(0,i.jsx)("span",{style:{fontFamily:K,fontWeight:600,minWidth:90},children:e.name}),(0,i.jsx)("span",{style:{color:z.textDim,minWidth:24},children:e.country}),(0,i.jsxs)("span",{style:{color:z.orange,flex:1},children:[e.old," ",(0,i.jsxs)("span",{style:{color:z.textDim},children:["(",e.reason,")"]})]}),(0,i.jsxs)("span",{style:{fontFamily:K,color:z.green},children:["→ ",e.new]})]},e.order_id))}),(null==(o=eS.report.unsupported)?void 0:o.length)>0&&(0,i.jsxs)("div",{style:{fontSize:11.5,color:z.textMuted,marginBottom:Q.lg},children:["Pays sans r\xe8gle (non touch\xe9s) : ",eS.report.unsupported.map(e=>"".concat(e.name," (").concat(e.country,")")).join(", ")]}),(0,i.jsxs)("div",{style:{display:"flex",gap:Q.sm,justifyContent:"flex-end"},children:[(0,i.jsx)("button",{style:ei(!1,z),disabled:eS.applying,onClick:()=>ek(null),children:"Fermer"}),eS.report.to_fix.length>0&&(0,i.jsx)("button",{style:ei(!0,z),disabled:eS.applying,onClick:eZ,children:eS.applying?"Correction…":"Corriger ".concat(eS.report.to_fix.length," commande(s)")})]})]})}
1),(0,i.jsxs)("div",{style:{marginTop:24,display:"grid",gap:Q.md,gridTemplateColumns:ep?"1fr 1fr":"repeat(4, 1fr)"},children:[(0,i.jsx)(eu,{label:"\xc0 exp\xe9dier",value:eJ,color:z.gold,t:z}),(0,i.jsx)(eu,{label:"S\xe9lectionn\xe9es",value:eL.length,sub:eA.length!==eL.length?"dont ".concat(eA.length," sans \xe9tiquette"):void 0,t:z}),(0,i.jsx)(eu,{label:"\xc9tiquettes g\xe9n\xe9r\xe9es",value:eX,color:z.green,t:z}),(0,i.jsx)(eu,{label:"Mondial Relay",value:e0,sub:"g\xe9r\xe9 hors Colissimo",t:z})]}),eI.length>1&&(0,i.jsxs)("div",{style:{marginTop:16,display:"flex",gap:Q.sm,flexWrap:"wrap",alignItems:"center"},children:[(0,i.jsx)("span",{style:{fontSize:10,color:z.textDim,textTransform:"uppercase",letterSpacing:"0.08em",fontWeight:600},children:"Livraison"}),eI.map(e=>{let t=e_.filter(t=>eD(t)===e).length;return(0,i.jsxs)("button",{onClick:()=>ef(t=>({...t,[e]:!1===t[e]})),style:eo(eM(e),z),children:[e," \xb7 ",t]},e)})]}),(0,i.jsxs)("div",{style:{marginTop:16,display:"flex",gap:Q.sm,flexWrap:"wrap",alignItems:"center"},children:[(0,i.jsx)("input",{type:"search",placeholder:"Rechercher une commande, un client, une ville…",value:M,onChange:e=>W(e.target.value),style:{...Z(z),maxWidth:320,minHeight:38,flex:"1 1 200px"}}),(0,i.jsx)("button",{onClick:()=>eF(!0),style:ei(!1,z),children:"Tout s\xe9lectionner"}),(0,i.jsx)("button",{onClick:()=>eF(!1),style:ei(!1,z),children:"Tout d\xe9s\xe9lectionner"}),(0,i.jsxs)("button",{onClick:eH,disabled:!!ey||0===eA.length,style:{...ei(!0,z),padding:"9px 16px",minHeight:38,opacity:ey||0===eA.length?.55:1},children:[(0,i.jsx)(e5.truck,{size:13,color:z.bg}),ey?"G\xe9n\xe9ration ".concat(ey.done,"/").concat(ey.total,"…"):"G\xe9n\xe9rer ".concat(eA.length," \xe9tiquette").concat(eA.length>1?"s":"")]})]})]}),H&&(0,i.jsx)("div",{style:{marginBottom:20,padding:"10px 14px",borderRadius:$.md,fontSize:12,lineHeight:1.5,color:"err"===H.kind?z.red:"warn"===H.kind?z.orange:z.green,background:"".concat("err"===H.kind?z.red:"warn"===H.kind?z.orange:z.green,"12"),border:"1px solid ".concat("err"===H.kind?z.red:"warn"===H.kind?z.orange:z.green,"30")},children:H.msg}),Y&&ee&&(0,i.jsxs)("section",{style:{...er(z),marginBottom:28,display:"flex",flexDirection:"column",gap:Q.lg},children:[(0,i.jsx)("div",{style:{fontSize:11,fontWeight:700,textTransform:"uppercase",letterSpacing:"0.16em"},children:"Param\xe8tres d'exp\xe9dition"}),(0,i.jsxs)("div",{style:{display:"grid",gridTemplateColumns:ep?"1fr":"1fr 1fr",gap:Q.lg},children:[(0,i.jsxs)("div",{children:[(0,i.jsx)("label",{style:et(z),children:"Transporteur par d\xe9faut (hors Mondial Relay)"}),(0,i.jsx)("select",{value:ee.carrier||"colissimo",onChange:e=>en(t=>({...t,carrier:e.target.value})),style:{...Z(z),minHeight:36},children:ez.map(e=>(0,i.jsxs)("option",{value:e.id,disabled:!e.available,children:[e.name,e.available?"":" — non configur\xe9"]},e.id))}),ez.filter(e=>!e.available).map(e=>(0,i.jsxs)("div",{style:{fontSize:9,color:z.textDim,marginTop:3},children:[e.name," : ",e.reason]},e.id))]}),(0,i.jsxs)("div",{children:[(0,i.jsx)("label",{style:et(z),children:"Service DPD"}),(0,i.jsxs)("select",{value:ee.dpdService||"predict",onChange:e=>en(t=>({...t,dpdService:e.target.value})),style:{...Z(z),minHeight:36},children:[(0,i.jsx)("option",{value:"predict",children:"Predict (notification SMS/email)"}),(0,i.jsx)("option",{value:"classic",children:"Classic (sans notification)"})]}),(0,i.jsx)("div",{style:{fontSize:9,color:z.textDim,marginTop:3},children:"Predict n\xe9cessite un n\xb0 de portable (ou email) client"})]}),(0,i.jsxs)("div",{children:[(0,i.jsx)("label",{style:et(z),children:"Type de livraison Colissimo"}),(0,i.jsxs)("select",{value:ee.productCode,onChange:e=>en(t=>({...t,productCode:e.target.value})),style:{...Z(z),minHeight:36},children:[(0,i.jsx)("option",{value:"DOM",children:"Domicile sans signature (DOM)"}),(0,i.jsx)("option",{value:"DOS",children:"Domicile avec signature (DOS)"})]})]}),(0,i.jsxs)("div",{children:[(0,i.jsx)("label",{style:et(z),children:"Poids par d\xe9faut (kg)"}),(0,i.jsx)("input",{type:"number",step:"0.05",min:"0.01",max:"30",value:ee.defaultWeightKg,onChange:e=>en(t=>({...t,defaultWeightKg:e.target.value})),style:{...Z(z),minHeight:36}})]})]}),(0,i.jsxs)("div",{style:{borderTop:"1px solid ".concat(z.border),paddingTop:Q.lg,display:"flex",flexDirection:"column",gap:Q.lg},children:[(0,i.jsxs)("div",{children:[(0,i.jsx)("div",{style:{fontSize:11,fontWeight:700,textTransform:"uppercase",letterSpacing:"0.16em"},children:"Identifiants transporteurs"}
1),(0,i.jsx)("div",{style:{fontSize:10,color:z.textDim,marginTop:4,lineHeight:1.5},children:"Champ vide = la variable d'environnement Vercel correspondante est utilis\xe9e."})]}),(0,i.jsxs)("div",{style:{display:"grid",gridTemplateColumns:ep?"1fr":"1fr 1fr",gap:Q.lg},children:[(0,i.jsxs)("div",{children:[(0,i.jsx)("label",{style:et(z),children:"Colissimo — n\xb0 de contrat"}),(0,i.jsx)("input",{value:(null==(a=ee.credentials)||null==(s=a.colissimo)?void 0:s.contractNumber)||"",onChange:e=>eK("colissimo","contractNumber",e.target.value),placeholder:"COLISSIMO_CONTRACT_NUMBER",style:{...Z(z),minHeight:36,fontFamily:K}})]}),(0,i.jsxs)("div",{children:[(0,i.jsx)("label",{style:et(z),children:"Colissimo — mot de passe"}),(0,i.jsx)("input",{type:"password",value:(null==(c=ee.credentials)||null==(d=c.colissimo)?void 0:d.password)||"",onChange:e=>eK("colissimo","password",e.target.value),placeholder:"COLISSIMO_PASSWORD",style:{...Z(z),minHeight:36,fontFamily:K}})]})]}),(0,i.jsxs)("div",{style:{display:"grid",gridTemplateColumns:ep?"1fr":"1fr 1fr",gap:Q.lg},children:[(0,i.jsxs)("div",{children:[(0,i.jsx)("label",{style:et(z),children:"DPD — identifiant (userid)"}),(0,i.jsx)("input",{value:(null==(p=ee.credentials)||null==(u=p.dpd)?void 0:u.userid)||"",onChange:e=>eK("dpd","userid",e.target.value),placeholder:"DPD_USER_ID",style:{...Z(z),minHeight:36,fontFamily:K}})]}),(0,i.jsxs)("div",{children:[(0,i.jsx)("label",{style:et(z),children:"DPD — mot de passe"}),(0,i.jsx)("input",{type:"password",value:(null==(x=ee.credentials)||null==(g=x.dpd)?void 0:g.password)||"",onChange:e=>eK("dpd","password",e.target.value),placeholder:"DPD_PASSWORD",style:{...Z(z),minHeight:36,fontFamily:K}})]}),(0,i.jsxs)("div",{children:[(0,i.jsx)("label",{style:et(z),children:"DPD — code agence"}),(0,i.jsx)("input",{value:(null==(m=ee.credentials)||null==(h=m.dpd)?void 0:h.centerNumber)||"",onChange:e=>eK("dpd","centerNumber",e.target.value),placeholder:"ex : 077",style:{...Z(z),minHeight:36,fontFamily:K}})]}),(0,i.jsxs)("div",{children:[(0,i.jsx)("label",{style:et(z),children:"DPD — n\xb0 de compte"}),(0,i.jsx)("input",{value:(null==(v=ee.credentials)||null==(f=v.dpd)?void 0:f.customerNumber)||"",onChange:e=>eK("dpd","customerNumber",e.target.value),placeholder:"ex : 123456",style:{...Z(z),minHeight:36,fontFamily:K}})]}),(0,i.jsxs)("div",{children:[(0,i.jsx)("label",{style:et(z),children:"DPD — environnement"}),(0,i.jsxs)("select",{value:(null==(S=ee.credentials)||null==(j=S.dpd)?void 0:j.env)||"prod",onChange:e=>eK("dpd","env",e.target.value),style:{...Z(z),minHeight:36},children:[(0,i.jsx)("option",{value:"prod",children:"Production"}),(0,i.jsx)("option",{value:"test",children:"Test (e-station-testenv)"})]})]}),(0,i.jsxs)("div",{children:[(0,i.jsx)("label",{style:et(z),children:"DPD — endpoint / proxy (optionnel)"}),(0,i.jsx)("input",{value:(null==(w=ee.credentials)||null==(k=w.dpd)?void 0:k.endpoint)||"",onChange:e=>eK("dpd","endpoint",e.target.value),placeholder:"https://… (proxy IP fixe)",style:{...Z(z),minHeight:36,fontFamily:K}})]})]}),(0,i.jsx)("div",{style:{fontSize:10,color:z.orange,lineHeight:1.5},children:"DPD applique une whitelist IP : depuis Vercel (IP dynamiques), la g\xe9n\xe9ration \xe9chouera avec \xab IpPermissionDenied \xbb tant que le proxy \xe0 IP fixe n'est pas en place. Testable d\xe8s maintenant depuis une IP autoris\xe9e (dev local)."})]}),(0,i.jsxs)("div",{style:{display:"flex",flexDirection:"column",gap:Q.md},children:[(0,i.jsx)(e8,{t:z,checked:!1!==ee.fulfillOnGenerate,onChange:()=>en(e=>({...e,fulfillOnGenerate:!1===e.fulfillOnGenerate})),label:"Marquer la commande trait\xe9e dans Shopify \xe0 la g\xe9n\xe9ration",hint:"Cr\xe9e le fulfillment Shopify avec le n\xb0 de suivi Colissimo"}),(0,i.jsx)(e8,{t:z,checked:!1!==ee.notifyCustomerDefault,onChange:()=>en(e=>({...e,notifyCustomerDefault:!1===e.notifyCustomerDefault})),label:"Notifier le client par d\xe9faut",hint:"Shopify envoie l'email \xab commande exp\xe9di\xe9e \xbb avec le lien de suivi"}
1),(0,i.jsx)(e8,{t:z,checked:!!ee.includeSlipDefault,onChange:()=>en(e=>({...e,includeSlipDefault:!e.includeSlipDefault})),label:"Inclure le bordereau d'exp\xe9dition par d\xe9faut",hint:"Page A6 ajout\xe9e apr\xe8s l'\xe9tiquette dans le m\xeame PDF"})]}),T.warehouse&&(0,i.jsxs)("div",{style:{fontSize:11,color:z.textDim,borderTop:"1px solid ".concat(z.border),paddingTop:Q.md},children:["Exp\xe9diteur : ",T.warehouse.companyName,", ",T.warehouse.line2,", ",T.warehouse.zipCode," ",T.warehouse.city]}),(0,i.jsxs)("div",{style:{display:"flex",gap:Q.sm},children:[(0,i.jsx)("button",{onClick:eY,disabled:el,style:{...ei(!0,z),opacity:el?.6:1},children:el?"Enregistrement…":"Enregistrer"}),(0,i.jsx)("button",{onClick:()=>X(!1),style:ei(!1,z),children:"Annuler"})]})]}),0===eq.length?(0,i.jsx)("div",{style:{textAlign:"center",padding:60,color:z.textDim,fontFamily:G,fontSize:18},children:M?"Aucune commande ne correspond.":"Aucune commande \xe0 exp\xe9dier — tout est parti !"}):(0,i.jsx)("div",{style:{display:"flex",flexDirection:"column",gap:Q.md},children:eq.map(e=>{var t,n,r,l,o,s,a,d,c,u,p,g,x,h,m,f;let y,b=q===e.shopify_order_id,v=eE(e),j=e.shipment,S=!!(null==j?void 0:j.tracking_code),k=E===e.shopify_order_id,w=(e.items||[]).reduce((e,t)=>e+(t.qty||1),0),C=!((null==(t=e.shipping_address)?void 0:t.phone)||(null==(n=e.customer)?void 0:n.phone));return(0,i.jsxs)("div",{style:{...er(z),padding:0,overflow:"hidden"},children:[(0,i.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:Q.md,paddingLeft:Q.lg},children:[(0,i.jsx)(e3,{checked:eW(e),onChange:()=>eh(t=>({...t,[e.shopify_order_id]:!eW(e)})),t:z,size:20}),(0,i.jsxs)("button",{onClick:()=>L(b?null:e.shopify_order_id),style:{display:"flex",alignItems:"center",gap:Q.md,flex:1,minWidth:0,padding:Q.lg,paddingLeft:0,background:"transparent",border:"none",cursor:"pointer",color:z.text,fontFamily:G,textAlign:"left"},children:[(0,i.jsx)("span",{style:{fontFamily:K,fontWeight:700,fontSize:13,flexShrink:0},children:e.name}),(0,i.jsxs)("span",{style:{fontSize:12,color:z.textMuted,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",flex:1},children:[(null==(r=e.customer)?void 0:r.name)||"—",(null==(l=e.shipping_address)?void 0:l.city)?" \xb7 ".concat(e.shipping_address.city):"",!ep&&" \xb7 ".concat(w," article").concat(w>1?"s":"")]}),!ep&&e.shipping_method&&(0,i.jsx)("span",{style:{padding:"3px 10px",borderRadius:$.pill,fontSize:10,fontWeight:600,color:eR(e)?z.orange:z.textMuted,background:eR(e)?"".concat(z.orange,"12"):z.surfaceAlt,border:"1px solid ".concat(eR(e)?"".concat(z.orange,"30"):z.border),whiteSpace:"nowrap",flexShrink:0},children:e.shipping_method}),S&&(0,i.jsx)(ea,{status:"label_generated"===j.status?"label_created":j.status,t:z}),(null==j?void 0:j.fulfilled)&&!ep&&(0,i.jsx)("span",{style:{display:"inline-flex",alignItems:"center",gap:4,padding:"3px 10px",borderRadius:$.pill,fontSize:10,fontWeight:600,color:z.green,background:"".concat(z.green,"12"),border:"1px solid ".concat(z.green,"20")},children:"Trait\xe9e"}),(0,i.jsx)("span",{style:{transform:b?"rotate(180deg)":"none",transition:"transform 0.2s ease",color:z.textDim,display:"flex"},children:(0,i.jsx)(e5.chevronDown,{size:16})})]})]}),b&&(0,i.jsxs)("div",{style:{padding:Q.lg,paddingTop:0,display:"flex",flexDirection:"column",gap:Q.lg},children:[(0,i.jsxs)("div",{style:{display:"grid",gridTemplateColumns:ep?"1fr":"1fr 1fr",gap:Q.lg},children:[(0,i.jsxs)("div",{children:[(0,i.jsx)("div",{style:et(z),children:"Articles"}),(0,i.jsx)("div",{style:{display:"flex",flexDirection:"column",gap:Q.sm},children:(e.items||[]).map((e,t)=>(0,i.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:Q.sm,fontSize:12},children:[e.image&&(0,i.jsx)("img",{src:e.image,alt:"",style:{width:32,height:32,borderRadius:$.sm,objectFit:"cover",flexShrink:0}}),(0,i.jsxs)("span",{style:{flex:1,minWidth:0,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:[e.title,e.variant?(0,i.jsxs)("span",{style:{color:z.textMuted},children:[" — ",e.variant]}):null]}),(0,i.jsxs)("span",{style:{fontFamily:K,color:z.textMuted,flexShrink:0},children:["\xd7",e.qty]})]},t))})]}),(0,i.jsxs)("div",{children:[(0,i.jsxs)("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:Q.sm},children:[(0,i.jsx)("div",{style:et(z),children:"Livraison"}),(0,i.jsx)("button",{onClick:()=>{var t,n,i,r,l,o,s,a,d;return eB(e.shopify_order_id,{address:v.address?null:{first_name:(null==(t=e.shipping_address)?void 0:t.first_name)||"",last_name:(null==(n=e.shipping_address)?void 0:n.last_name)||"",address1:(null==(i=e.shipping_address)?void 0:i.address1)||"",address2:(null==(r=e.shipping_address)?void 0:r.address2)||"",zip:(null==(l=e.shipping_address)?void 0:l.zip)||"",city:(null==(o=e.shipping_address)?void 0:o.city)||"",phone:(null==(s=e.shipping_address)?void 0:s.phone)||(null==(a=e.customer)?void 0:a.phone)||"",email:(null==(d=e.customer)?void 0:d.email)||""}})},style:{background:"transparent",border:"none",cursor:"pointer",padding:"0 0 6px",fontSize:10,fontWeight:600,textTransform:"uppercase",letterSpacing:"0.08em",color:v.address?z.orange:z.gold,fontFamily:G},children:v.address?"Annuler la correction":"Modifier"})]}),v.address?(0,i.jsxs)("div",{style:{display:"flex",flexDirection:"column",gap:Q.sm},children:[(0,i.jsxs)("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:Q.sm},children:[(0,i.jsx)("input",{value:v.address.first_name,placeholder:"Pr\xe9nom",onChange:t=>eP(e.shopify_order_id,"first_name",t.target.value),style:{...Z(z),minHeight:32,fontSize:12}}),(0,i.jsx)("input",{value:v.address.last_name,placeholder:"Nom",onChange:t=>eP(e.shopify_order_id,"last_name",t.target.value),style:{...Z(z),minHeight:32,fontSize:12}})]}),(0,i.jsx)("input",{value:v.address.address1,placeholder:"Adresse",onChange:t=>eP(e.shopify_order_id,"address1",t.target.value),style:{...Z(z),minHeight:32,fontSize:12}}),(0,i.jsx)("input",{value:v.address.address2,placeholder:"Compl\xe9ment (b\xe2t., \xe9tage…)",onChange:t=>eP(e.shopify_order_id,"address2",t.target.value),style:{...Z(z),minHeight:32,fontSize:12}}),(0,i.jsxs)("div",{style:{display:"grid",gridTemplateColumns:"100px 1fr",gap:Q.sm},children:[(0,i.jsx)("input",{value:v.address.zip,placeholder:"CP",onChange:t=>eP(e.shopify_order_id,"zip",t.target.value),style:{...Z(z),minHeight:32,fontSize:12,fontFamily:K}}),(0,i.jsx)("input",{value:v.address.city,placeholder:"Ville",onCh
1ange:t=>eP(e.shopify_order_id,"city",t.target.value),style:{...Z(z),minHeight:32,fontSize:12}})]}),(0,i.jsxs)("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:Q.sm},children:[(0,i.jsx)("input",{type:"tel",value:v.address.phone,placeholder:"T\xe9l\xe9phone",onChange:t=>eP(e.shopify_order_id,"phone",t.target.value),style:{...Z(z),minHeight:32,fontSize:12,fontFamily:K}}),(0,i.jsx)("input",{type:"email",value:v.address.email,placeholder:"Email",onChange:t=>eP(e.shopify_order_id,"email",t.target.value),style:{...Z(z),minHeight:32,fontSize:12}})]}),(0,i.jsx)("div",{style:{fontSize:10,color:z.orange,lineHeight:1.4},children:"Correction utilis\xe9e pour l'\xe9tiquette et le bordereau — la commande Shopify n'est pas modifi\xe9e."})]}):(0,i.jsxs)("div",{style:{fontSize:12,lineHeight:1.6,color:z.textMuted},children:[(0,i.jsxs)("div",{style:{color:z.text,fontWeight:600},children:[null==(o=e.shipping_address)?void 0:o.first_name," ",null==(s=e.shipping_address)?void 0:s.last_name]}),(0,i.jsx)("div",{children:null==(a=e.shipping_address)?void 0:a.address1}),(null==(d=e.shipping_address)?void 0:d.address2)&&(0,i.jsx)("div",{children:e.shipping_address.address2}),(0,i.jsxs)("div",{children:[null==(c=e.shipping_address)?void 0:c.zip," ",null==(u=e.shipping_address)?void 0:u.city]}),(0,i.jsx)("div",{style:{marginTop:4},children:C?(0,i.jsx)("span",{style:{color:z.textDim},children:"06 00 00 00 00 (d\xe9faut — t\xe9l. absent)"}):(null==(p=e.shipping_address)?void 0:p.phone)||(null==(g=e.customer)?void 0:g.phone)}),(null==(x=e.customer)?void 0:x.email)&&(0,i.jsx)("div",{children:e.customer.email})]})]})]}),S&&(0,i.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:Q.md,flexWrap:"wrap",padding:Q.md,borderRadius:$.md,background:z.surfaceAlt,border:"1px solid ".concat(z.border)},children:[(0,i.jsxs)("span",{style:{fontSize:11,color:z.textMuted},children:["Suivi ",e7[j.carrier]||"Colissimo"]}),(0,i.jsx)("a",{href:(y=j.tracking_code,"dpd"===j.carrier?"https://trace.dpd.fr/fr/trace/".concat(encodeURIComponent(y)):"https://www.laposte.fr/outils/suivre-vos-envois?code=".concat(encodeURIComponent(y))),target:"_blank",rel:"noreferrer",style:{fontFamily:K,fontSize:12,color:z.gold,textDecoration:"none",fontWeight:600},children:j.tracking_code}),(0,i.jsx)("button",{onClick:()=>{var e,t;return e=j.tracking_code,void(null==(t=navigator.clipboard)||t.writeText(e),ec(e),setTimeout(()=>ec(null),1500))},"aria-label":"Copier le n\xb0 de suivi",style:{background:"transparent",border:"none",cursor:"pointer",color:ed===j.tracking_code?z.green:z.textDim,padding:2,display:"flex"},children:ed===j.tracking_code?(0,i.jsx)(e5.check,{size:13}):(0,i.jsx)(e5.copy,{size:13})}),(0,i.jsx)("span",{style:{flex:1}}),(0,i.jsxs)("button",{onClick:()=>eV(e),disabled:P===e.shopify_order_id,style:ei(!1,z),children:[(0,i.jsx)(e5.download,{size:12}),P===e.shopify_order_id?"…":"T\xe9l\xe9charger"]}),!j.fulfilled&&(0,i.jsx)("button",{onClick:()=>eG(e),disabled:U===e.shopify_order_id,style:ei(!1,z),children:U===e.shopify_order_id?"…":"Marquer trait\xe9e"})]}),eR(e)&&(0,i.jsxs)("div",{style:{display:"flex",flexWrap:"wrap",alignItems:"flex-end",gap:Q.md,padding:Q.md,borderRadius:$.md,background:"".concat(z.orange,"0d"),border:"1px solid ".concat(z.orange,"30")},children:[(0,i.jsxs)("div",{style:{flex:1,minWidth:220},children:[(0,i.jsx)("div",{style:{fontSize:11,fontWeight:700,textTransform:"uppercase",letterSpacing:"0.06em",color:z.orange,marginBottom:3},children:"Mondial Relay via Shopify"}),(0,i.jsx)("div",{style:{fontSize:11,color:z.textMuted,lineHeight:1.5},children:C?"T\xe9l\xe9phone absent : il sera enregistr\xe9 sur la commande (sans lui, Shopify bloque l'achat d'\xe9tiquette), puis la commande s'ouvre dans Shopify pour acheter l'\xe9tiquette.":"Le t\xe9l\xe9phone ci-contre sera confirm\xe9 sur la commande, puis la commande s'ouvre dans Shopify pour acheter l'\xe9tiquette."})]}),(0,i.jsxs)("div",{children:[(0,i.jsx)("label",{style:et(z),children:"T\xe9l\xe9phone"}),(0,i.jsx)("input",{value:null!=(f=v.mrPhone)?f:(null==(h=e.shipping_address)?void 0:h.phone)||(null==(m=e.customer)?void 0:m.ph
1one)||"0600000000",onChange:t=>eB(e.shopify_order_id,{mrPhone:t.target.value}),style:{...Z(z),minHeight:36,width:150,fontFamily:K}})]}),(0,i.jsx)("button",{onClick:()=>eQ(e),disabled:ev===e.shopify_order_id,style:ei(!0,z),children:ev===e.shopify_order_id?"…":"Corriger & ouvrir Shopify"})]}),(0,i.jsxs)("div",{style:{display:"grid",gridTemplateColumns:ep?"1fr 1fr":"140px 180px 220px",gap:Q.md},children:[(0,i.jsxs)("div",{children:[(0,i.jsx)("label",{style:et(z),children:"Poids (kg)"}),(0,i.jsx)("input",{type:"number",step:"0.05",min:"0.01",max:"30",value:v.weight,onChange:t=>eB(e.shopify_order_id,{weight:t.target.value}),style:{...Z(z),minHeight:36,fontFamily:K}}),null!=e.weight_estimate_kg&&(0,i.jsxs)("div",{style:{fontSize:9,color:z.textDim,marginTop:3},children:["Estim\xe9 Shopify : ",e.weight_estimate_kg," kg"]})]}),(0,i.jsxs)("div",{children:[(0,i.jsx)("label",{style:et(z),children:"Transporteur"}),(0,i.jsx)("select",{value:v.carrier,onChange:t=>eB(e.shopify_order_id,{carrier:t.target.value}),style:{...Z(z),minHeight:36},children:ez.map(e=>(0,i.jsxs)("option",{value:e.id,disabled:!e.available,children:[e7[e.id]||e.name,e.available?"":" (non configur\xe9)"]},e.id))}),"dpd"===v.carrier&&(0,i.jsxs)("div",{style:{fontSize:9,color:z.textDim,marginTop:3},children:["Service ","classic"===eC.dpdService?"Classic":"Predict","classic"!==eC.dpdService&&C?" — portable requis !":""]})]}),"colissimo"===v.carrier&&(0,i.jsxs)("div",{children:[(0,i.jsx)("label",{style:et(z),children:"Livraison"}),(0,i.jsxs)("select",{value:v.productCode,onChange:t=>eB(e.shopify_order_id,{productCode:t.target.value}),style:{...Z(z),minHeight:36},children:[(0,i.jsx)("option",{value:"DOM",children:"Sans signature (DOM)"}),(0,i.jsx)("option",{value:"DOS",children:"Avec signature (DOS)"})]})]})]}),(0,i.jsxs)("div",{style:{display:"flex",flexDirection:"column",gap:Q.sm},children:[(0,i.jsx)(e8,{t:z,checked:v.includeSlip,onChange:()=>eB(e.shopify_order_id,{includeSlip:!v.includeSlip}),label:"Inclure le bordereau d'exp\xe9dition dans le PDF"}),(0,i.jsx)(e8,{t:z,checked:v.fulfill,onChange:()=>eB(e.shopify_order_id,{fulfill:!v.fulfill}),label:"Marquer trait\xe9e dans Shopify",hint:S?"R\xe9g\xe9n\xe9ration : remplace le n\xb0 de suivi sur le fulfillment existant":void 0}),(0,i.jsx)(e8,{t:z,checked:v.notifyCustomer,disabled:!v.fulfill,onChange:()=>eB(e.shopify_order_id,{notifyCustomer:!v.notifyCustomer}),label:"Notifier le client (email Shopify)"})]}),(0,i.jsx)("div",{children:(0,i.jsxs)("button",{onClick:()=>eN(e,S),disabled:k,style:{...ei(!0,z),padding:"9px 18px",opacity:k?.6:1},children:[(0,i.jsx)(e5.truck,{size:13,color:z.bg}),k?"G\xe9n\xe9ration…":S?"R\xe9g\xe9n\xe9rer l'\xe9tiquette":"G\xe9n\xe9rer l'\xe9tiquette"]})})]})]},e.shopify_order_id)})})]})}let tt={arrowRight:e=>{let{size:t=12,color:n}=e;return(0,i.jsxs)("svg",{width:t,height:t,viewBox:"0 0 24 24",fill:"none",stroke:n||"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,i.jsx)("line",{x1:"5",y1:"12",x2:"19",y2:"12"}),(0,i.jsx)("polyline",{points:"12 5 19 12 12 19"})]})},refund:e=>{let{size:t=12,color:n}=e;return(0,i.jsxs)("svg",{width:t,height:t,viewBox:"0 0 24 24",fill:"none",stroke:n||"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,i.jsx)("line",{x1:"12",y1:"1",x2:"12",y2:"23"}),(0,i.jsx)("path",{d:"M17 5H9.5a3.5 3.5 0 0 0 0 7h5a3.5 3.5 0 0 1 0 7H6"})]})}},tn=["dimanche","lundi","mardi","mercredi","jeudi","vendredi","samedi"],ti=["janvier","f\xe9vrier","mars","avril","mai","juin","juillet","ao\xfbt","septembre","octobre","novembre","d\xe9cembre"];function tr(e){var t,n;let{t:o,onNavigate:s,active:a}=e,d=o||J,[u,g]=(0,r.useState)(!0),[x,h]=(0,r.useState)({stats:{},packingList:[]}),[m,y]=(0,r.useState)([]),[b,v]=(0,r.useState)({}),[j,S]=(0,r.useState)(!1),[k,w]=(0,r.useState)(null),[C,_]=(0,r.useState)(Date.now()),z=(0,r.useCallback)(async function(){let{silent:e=!1}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};e||g(!0);let[t,n]=await Promise.all([f().catch(()=>({stats:{},packingList:[]})),c().catch(()=>[])]);h({stats:(null==t?void 0:t.stats)||{},packingList:(null==t?void 0:t.packingList)||[]}),y((Array.isArray(n)?n:(null==n?void 0:n.returns)||(null==n?void 0:n.data)||[]).filter(e=>["pending","label_generated","in_transit","received"].includes(e.status))),w(Date.now()),e||g(!1)},[]);(0,r.useEffect)(()=>{z()},[z]),(0,r.useEffect)(()=>{a&&z()},[a,z]),(0,r.useEffect)(()=>
1{if(!a)return;let e=setInterval(()=>z({silent:!0}),12e4);return()=>clearInterval(e)},[a,z]),(0,r.useEffect)(()=>{let e=setInterval(()=>_(Date.now()),3e4);return()=>clearInterval(e)},[]);let T=async()=>{S(!0),await l("/cron/poll-emails",{method:"POST"}).catch(()=>{}),await z({silent:!0}),S(!1)},D=async e=>{v(t=>({...t,[e]:!0}));try{await p(e,{}),y(t=>t.filter(t=>t.id!==e))}catch(e){console.error("Process return failed:",e)}v(t=>({...t,[e]:!1}))},R=(null==(t=x.stats)?void 0:t.totalOrders)||0,I=(null==(n=x.stats)?void 0:n.totalItems)||0,M=m.length,W=m.filter(e=>"received"===e.status).length,q=x.packingList.slice(0,8),L=x.packingList.length-8;return u?(0,i.jsx)("div",{style:{display:"flex",alignItems:"center",justifyContent:"center",height:"100%",padding:40},children:(0,i.jsx)("span",{style:{fontFamily:G,fontSize:22,color:d.textMuted,letterSpacing:"-0.01em"},children:"Pr\xe9paration de l'atelier…"})}):(0,i.jsxs)("div",{style:{padding:"clamp(28px, 4vw, 44px) clamp(20px, 4vw, 48px) 96px",maxWidth:920,margin:"0 auto",fontFamily:G,color:d.text,minHeight:"100%"},children:[(0,i.jsxs)("header",{style:{marginBottom:56},children:[(0,i.jsxs)("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"flex-start",gap:Q.xl},children:[(0,i.jsxs)("div",{style:{flex:1,minWidth:0},children:[(0,i.jsx)("div",{style:{fontSize:10,color:d.textDim,textTransform:"uppercase",letterSpacing:"0.18em",fontWeight:600,marginBottom:14},children:function(){let e=new Date,t=tn[e.getDay()];return"".concat(t.charAt(0).toUpperCase()).concat(t.slice(1)," ").concat(e.getDate()," ").concat(ti[e.getMonth()]," ").concat(e.getFullYear())}()}),(0,i.jsxs)("h1",{style:{fontSize:"clamp(32px, 8vw, 46px)",fontFamily:G,fontWeight:600,color:d.text,letterSpacing:"-0.015em",lineHeight:1,margin:0},children:[function(){let e=new Date().getHours();return e<12?"Bonjour":e<18?"Bon apr\xe8s-midi":"Bonsoir"}(),"."]})]}),(0,i.jsxs)("div",{style:{display:"flex",flexDirection:"column",alignItems:"flex-end",gap:8,flexShrink:0},children:[(0,i.jsx)("button",{type:"button",onClick:T,disabled:j,"aria-label":"Actualiser le carnet",className:"todo-refresh",style:{background:"transparent",border:"1px solid ".concat(d.border),width:38,height:38,borderRadius:"50%",cursor:j?"wait":"pointer",display:"flex",alignItems:"center",justifyContent:"center",color:d.textMuted,padding:0,transition:"border-color 0.2s ease, color 0.2s ease"},children:(0,i.jsx)("span",{style:{display:"inline-flex",animation:j?"spin 1s linear infinite":"none"},children:(0,i.jsx)(ex.refresh,{size:14,color:"currentColor"})})}),(0,i.jsxs)("div",{style:{fontSize:10,color:d.textDim,fontFamily:G,letterSpacing:"0.04em"},children:["Sync ",function(e,t){if(!e)return"\xe0 l'instant";let n=Math.floor((t-e)/1e3);return n<60?"\xe0 l'instant":n<3600?"il y a ".concat(Math.floor(n/60)," min"):"il y a ".concat(Math.floor(n/3600)," h")}(k,C)]})]})]}),(0,i.jsxs)("div",{style:{marginTop:28,fontSize:14,color:d.textMuted,fontFamily:G,lineHeight:1.7},children:[(0,i.jsx)(tl,{first:!0,n:R,l:"commande".concat(1!==R?"s":""," \xe0 pr\xe9parer"),T:d}),I>0&&(0,i.jsx)(tl,{n:I,l:"article".concat(1!==I?"s":""),T:d,muted:!0}),(0,i.jsx)(tl,{n:M,l:"retour".concat(1!==M?"s":""," en cours"),T:d}),W>0&&(0,i.jsx)(tl,{n:W,l:"\xe0 rembourser",T:d,accent:!0})]})]}),(0,i.jsx)(to,{title:"Production du jour",count:R,linkLabel:"Voir la pr\xe9paration",onLink:()=>s("pr\xe9paration"),T:d,children:0===R?(0,i.jsx)(tc,{T:d,children:"L'atelier est \xe0 jour."}):(0,i.jsxs)(i.Fragment,{children:[q.map((e,t)=>(0,i.jsx)(ts,{order:e,T:d,onClick:()=>s("pr\xe9paration")},e.orderName||t)),L>0&&(0,i.jsxs)("button",{type:"button",onClick:()=>s("pr\xe9paration"),style:{display:"inline-flex",alignItems:"center",gap:6,marginTop:18,marginLeft:0,background:"transparent",border:"none",cursor:"pointer",fontSize:12,color:d.textMuted,fontFamily:G,padding:"4px 0",letterSpacing:"0.01em"},children:["et ",L," autre",L>1?"s":""," \xe0 voir dans Pr\xe9paration",(0,i.jsx)(tt.arrowRight,{size:11})]})]})}),(0,i.jsx)(to,{title:"Retours \xe0 traiter",count:M,linkLabel:"Tous les retours",onLink:()=>s("returns"),T:d,children:0===M?(0,i.jsx)(tc,{T:d,children:"Pas de retour \xe0 traiter aujourd'hui."}):m.map(e=>(0,i.jsx)(td,{ret:e,T:d,isProcessing:!!b[e.id],onProcess:()=>D(e.id),onClick:()=>s("returns")},e.id))}),(0,i.jsx)("style",{children:"\n        @keyframes spin { from { transform: rotate(0deg); } to { transform: rotate(360deg); } }\n        .todo-refresh:hover:not(:disabled) {\n          border-color: ".concat(d.textMuted," !important;\n          color: ").concat(d.text," !important;\n        }\n        .todo-row {\n          transition: background 0.18s ease;\n        }\n        .todo-row:hover, .todo-row:focus-visible {\n          background: ").concat(d.surfaceAlt,";\n        }\n        .todo-row .todo-row-action {\n          opacity: 0;\n          transform: translateX(-4px);\n          transition: opacity 0.18s ease, transform 0.18s ease;\n          pointer-events: none;\n        }\n        .todo-row:hover .todo-row-action,\n        .todo-row:focus-visible .todo-row-action,\n        .todo-row:focus-within .todo-row-action {\n          opacity: 1;\n          transform: translateX(0);\n          pointer-events: auto;\n        }\n        .todo-section-link:hover { color: ").concat(d.text," !important; }\n        @media (max-width: 720px) {\n          .todo-row-customer { display: none; }\n          .todo-return-type { display: none; }\n          .todo-row-items { font-size: 11px !important; }\n        }\n      ")})]})}function tl(e){let{n:t,l:n,T:r,muted:l,accent:o,first:s}=e;return(0,i.jsxs)("span",{style:{display:"inline-flex",alignItems:"baseline",whiteSpace:"nowrap",marginRight:20},children:[!s&&(0,i.jsx)("span",{"aria-hidden":"true",style:{marginRight:20,opacity:.45,color:r.textMuted},children:"\xb7"}),(0,i.jsx)("span",{style:{fontFamily:K,fontWeight:600,color:o?r.gold:l?r.textMuted:r.text,fontSize:14,letterSpacing:"-0.01em"},children:t}),(0,i.jsx)("span",{style:{marginLeft:6,color:o?r.gold:r.textMuted},children:n})]})}function to(e){let{title:t,count:n,linkLabel:r,onLink:l,T:o,children:s}=e;return(0,i.jsxs)("section",{style:{marginBottom:56},children:[(0,i.jsxs)("header",{style:{display:"flex",justifyContent:"space-between",alignItems:"baseline",paddingBottom:14,marginBottom:4,borderBottom:"1px solid ".concat(o.border)},children:[(0,i.jsxs)("div",{style:{display:"flex",alignItems:"baseline",gap:12},children:[(0,i.jsx)("h2",{style:{fontSize:11,fontWeight:700,textTransform:"uppercase",letterSpacing:"0.16em",color:o.text,margin:0,fontFamily:G},children:t}),null!=n&&(0,i.jsx)("span",{style:{fontSize:12,color:o.textDim,fontFamily:K,letterSpacing:"-0.01em"},children:n})]}),r&&l&&(0,i.jsxs)("button",{type:"button",onClick:l,className:"todo-section-link",style:{background:"transparent",border:"none",cursor:"pointer",fontSize:11,color:o.textMuted,fontFamily:G,fontWeight:500,display:"inline-flex",alignItems:"center",gap:5,padding:"4px 0",transition:"color 0.2s ease"},children:[r," ",(0,i.jsx)(tt.arrowRight,{size:11})]})]}),s]})}function ts(e){let{order:t,T:n,onClick:r}=e,l=t.items||[],o=l.length,s=l.map(e=>"".concat(e.title||e.name).concat(e.variant?" (".concat(e.variant,")"):""," \xd7").concat(e.qty||e.quantity||1)).join(", ");return(0,i.jsxs)("button",{type:"button",onClick:r,className:"todo-row",style:{display:"flex",alignItems:"center",gap:18,padding:"14px 16px",margin:"0 -16px",background:"transparent",border:"none",borderBottom:"1px solid ".concat(n.border),borderRadius:0,cursor:"pointer",width:"calc(100% + 32px)",textAlign:"left",fontFamily:G,color:n.text},children:[(0,i.jsx)("span",{style:{fontFamily:K,fontSize:13,fontWeight:600,color:n.text,letterSpacing:"-0.01em",flexShrink:0,minWidth:86},children:t.orderName}),(0,i.jsx)("span",{className:"todo-row-customer",style:{fontSize:13,color:n.text,fontWeight:500,flexShrink:0,minWidth:140,whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:t.customerName}),(0,i.jsxs)("span",{style:{fontSize:11,fontFamily:K,color:n.textDim,flexShrink:0,minWidth:32,textAlign:"right",letterSpacing:"-0.01em"},children:["\xd7",o]}),(0,i.jsx)("span",{className:"todo-row-items",style:{flex:1,fontSize:12,color:n.textMuted,whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis",lineHeight:1.5},children:s}),(0,i.jsxs)("span",{className:"todo-row-action",style:{fontSize:11,fontWeight:600,color:n.text,display:"inline-flex",alignItems:"center",gap:5,whiteSpace:"nowrap",flexShrink:0},children:["Pr\xe9parer ",(0,i.jsx)(tt.arrowRight,{size:11})]})]})}let ta={refund:"Rembourser",credit:"Cr\xe9er l'avoir",exchange:"Traiter l'\xe9change",mixed:"Traiter"};function td(e){let{ret:t,T:n,isProcessing:r,onProcess:l,onClick:o}=e,s={pending:{label:"En attente",color:n.orange},label_generated:{label:"\xc9tiquette g\xe9n\xe9r\xe9e",color:n.blue},in_transit:{label:"En transit",color:n.blue},received:{label:"Re\xe7u",color:n.green},refunded:{label:"Rembours\xe9",color:n.green},exchanged:{label:"\xc9chang\xe9",color:n.purple},rejected:{label:"Rejet\xe9",color:n.red}}[t.status]||{label:t.status||"—",color:n.textMuted},a="received"===t.status,d="exchange"===t.type,c=ta[t.type]||"Traiter";return(0,i.jsxs)("div",{className:"todo-row",style:{display:"flex",alignItems:"center",gap:18,padding:"14px 16px",margin:"0 -16px",borderBottom:"1px solid ".concat(n.border),borderRadius:0,cursor:"pointer",width:"calc(100% + 32px)",fontFamily:G,color:n.text},onClick:o,onKeyDown:e=>
1{e.target===e.currentTarget&&("Enter"===e.key||" "===e.key)&&(e.preventDefault(),o())},role:"button",tabIndex:0,children:[(0,i.jsx)("span",{style:{fontFamily:K,fontSize:13,fontWeight:a?700:600,color:n.text,letterSpacing:"-0.01em",flexShrink:0,minWidth:86},children:t.order_name}),(0,i.jsx)("span",{className:"todo-return-type",style:{fontSize:10,fontWeight:600,color:d?n.purple:n.textMuted,textTransform:"uppercase",letterSpacing:"0.10em",flexShrink:0,minWidth:54},children:d?"\xc9change":"Retour"}),(0,i.jsxs)("span",{style:{display:"inline-flex",alignItems:"center",gap:6,fontSize:11,color:s.color,flexShrink:0,minWidth:134},children:[(0,i.jsx)("span",{style:{width:6,height:6,borderRadius:"50%",background:s.color}}),s.label]}),(0,i.jsxs)("span",{className:"todo-row-items",style:{flex:1,fontSize:12,color:n.textMuted,whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:[t.customer_name||t.customer_email,t.reason?" \xb7 ".concat(t.reason):""]}),a?(0,i.jsxs)("button",{type:"button",onClick:e=>{e.stopPropagation(),l()},disabled:r,"aria-label":"".concat(c," ").concat(t.order_name),style:{...ei(!0,n),padding:"7px 14px",fontSize:11,opacity:r?.5:1,flexShrink:0},children:[(0,i.jsx)(tt.refund,{size:11,color:n.bg}),r?"...":c]}):(0,i.jsxs)("span",{className:"todo-row-action",style:{fontSize:11,fontWeight:600,color:n.text,display:"inline-flex",alignItems:"center",gap:5,whiteSpace:"nowrap",flexShrink:0},children:["Voir ",(0,i.jsx)(tt.arrowRight,{size:11})]})]})}function tc(e){let{T:t,children:n}=e;return(0,i.jsx)("div",{style:{padding:"36px 16px 12px",textAlign:"left",fontFamily:G,fontSize:24,color:t.textMuted,letterSpacing:"-0.01em",lineHeight:1.3},children:n})}let tu=async function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n="90bf72b266b57db5941529bb5241cfc5da01f7f651e1ffc3e760f2b8b189d823",i={"Content-Type":"application/json"};n&&(i.Authorization="Bearer ".concat(n));let r=await fetch("/api".concat(e),{headers:i,...t,body:t.body?JSON.stringify(t.body):void 0}),l=await r.text();if(!l)return{};try{return JSON.parse(l)}catch(e){return{}}},tp={all:"Tous les produits",product:"Produit sp\xe9cifique (ID Shopify)",product_tag:"Tag produit Shopify",product_type:"Type de produit"};function tg(e){var t,n,l,o,s,a,d,c,u,p,g,x,h,m,f,y,b,v,j,S;let{t:k=J,active:w}=e,[C,_]=(0,r.useState)("rules"),[z,T]=(0,r.useState)([]),[D,R]=(0,r.useState)(!1),[I,M]=(0,r.useState)({name:"",tag:"",scope:"all",product_id:"",product_tag:"",product_type:"",collection_handle:"",discount_type:"percentage",discount_value:"",tiers:[]}),[W,q]=(0,r.useState)(null),[L,A]=(0,r.useState)(!1),[F,E]=(0,r.useState)(null),[B,P]=(0,r.useState)(0),[O,U]=(0,r.useState)(!1),[N,H]=(0,r.useState)(!1),[V,Y]=(0,r.useState)(null),[X,ee]=(0,r.useState)(!1),[en,el]=(0,r.useState)(null),[es,ea]=(0,r.useState)(!1),[ed,ec]=(0,r.useState)(null),[eu,ep]=(0,r.useState)(!1),[eg,ex]=(0,r.useState)(null),[eh,em]=(0,r.useState)(!1),[ef,ey]=(0,r.useState)(null),[eb,ev]=(0,r.useState)(null),[ej,eS]=(0,r.useState)(""),[ek,ew]=(0,r.useState)(""),[eC,e_]=(0,r.useState)(!1),[ez,eT]=(0,r.useState)(null),[eD,eR]=(0,r.useState)([]),[eI,eM]=(0,r.useState)({tag:"",label:"",priority:"0"}),[eW,eq]=(0,r.useState)(null),[eL,eA]=(0,r.useState)(!1),[eF,eE]=(0,r.useState)(null),[eB,eP]=(0,r.useState)(null),[eO,eU]=(0,r.useState)(30),[eN,eH]=(0,r.useState)(!1),eV=(0,r.useCallback)(async()=>{R(!0);let e=await tu("/b2b/price-rules");T(Array.isArray(e)?e:[]),R(!1)},[]),eG=(0,r.useCallback)(async()=>{let e=await tu("/b2b/campaigns");eR(Array.isArray(e)?e:[])},[]),eK=(0,r.useCallback)(async()=>{var e;let t=await tu("/b2b/settings");P(null!=(e=null==t?void 0:t.min_order_qty)?e:0)},[]),eY=(0,r.useCallback)(async()=>{Y(await tu("/b2b/setup"))},[]);async function eJ(){ep(!0),ev(null);let e=await tu("/b2b/setup",{method:"POST"});ep(!1),ev(e),eY()}async function eX(){ea(!0),ec(null);let e=await tu("/b2b/sync-products",{method:"POST"});ea(!1),ec(e)}async function eQ(){ee(!0),el(null);let e=await tu("/b2b/sync-customers",{method:"POST"});if(ee(!1),e.error)return void el({error:e.error});
1el(e),eY()}let e$=(0,r.useCallback)(async()=>{ex(await tu("/b2b/register-webhooks"))},[]);async function eZ(){em(!0),ey(null);let e=await tu("/b2b/register-webhooks",{method:"POST"});em(!1),ey(e),e$()}async function e0(){if(!ej.trim())return;e_(!0),eT(null);let e="/b2b/test-function?email=".concat(encodeURIComponent(ej.trim()));ek.trim()&&(e+="&productHandle=".concat(encodeURIComponent(ek.trim())));let t=await tu(e);e_(!1),eT(t)}let e1=(0,r.useCallback)(async e=>{eH(!0),eP(await tu("/b2b/reporting?days=".concat(e))),eH(!1)},[]);function e2(){q(null),M({name:"",tag:"",scope:"all",product_id:"",product_tag:"",product_type:"",collection_handle:"",discount_type:"percentage",discount_value:"",tiers:[]}),E(null)}async function e6(){if(!I.name.trim()||!I.tag||!I.discount_value)return void E("Nom, campagne et valeur sont requis.");A(!0),E(null);let e={name:I.name.trim(),tag:I.tag.trim().toLowerCase(),scope:I.scope,product_id:"product"===I.scope?I.product_id.trim():null,product_tag:"product_tag"===I.scope?I.product_tag.trim():null,product_type:"product_type"===I.scope?I.product_type.trim():null,collection_handle:"collection"===I.scope?I.collection_handle.trim():null,discount_type:I.discount_type,discount_value:Number(I.discount_value),tiers:I.tiers.filter(e=>""!==String(e.min_qty).trim()&&""!==String(e.discount_value).trim()).map(e=>({min_qty:Number(e.min_qty),discount_value:Number(e.discount_value)}))},t=W?await tu("/b2b/price-rules?id=".concat(W),{method:"PUT",body:e}):await tu("/b2b/price-rules",{method:"POST",body:e});if(t.error){E(t.error),A(!1);return}e2(),await eV(),A(!1)}async function e4(e){window.confirm("Supprimer cette r\xe8gle ?")&&(await tu("/b2b/price-rules?id=".concat(e),{method:"DELETE"}),await eV())}function e5(){eq(null),eM({tag:"",label:"",priority:"0"}),eE(null)}async function e3(){if(!eI.label.trim())return void eE("Le label est requis.");eA(!0),eE(null);let e={tag:eI.tag.trim().toLowerCase(),label:eI.label.trim(),priority:Number(eI.priority)||0},t=eW?await tu("/b2b/campaigns?id=".concat(eW),{method:"PUT",body:e}):await tu("/b2b/campaigns",{method:"POST",body:e});if(t.error){eE(t.error),eA(!1);return}e5(),await eG(),eA(!1)}async function e8(e){if(!window.confirm("Supprimer cette campagne ? Ses r\xe8gles de prix doivent \xeatre supprim\xe9es au pr\xe9alable."))return;let t=await tu("/b2b/campaigns?id=".concat(e),{method:"DELETE"});if(t.error)return void alert(t.error);await eG()}async function e7(e){await tu("/b2b/campaigns?id=".concat(e.id),{method:"PUT",body:{active:!e.active}}),await eG()}async function e9(){U(!0),await tu("/b2b/settings",{method:"PUT",body:{min_order_qty:Number(B)}}),U(!1),H(!0),setTimeout(()=>H(!1),2e3)}(0,r.useEffect)(()=>{w&&(eV(),eG(),eK(),eY(),e$())},[w,eV,eG,eK,eY,e$]),(0,r.useEffect)(()=>{"reporting"!==C||eB||e1(eO)},[C,eB,eO,e1]);let te=e=>Number(e).toLocaleString("fr-FR",{style:"currency",currency:"EUR"}),tt=(e,t)=>(0,i.jsxs)("div",{style:{marginBottom:Q.md},children:[(0,i.jsx)("label",{style:et(k),children:e}),t]}),[tn,ti]=(0,r.useState)("desktop");(0,r.useEffect)(()=>{let e=()=>{let e=window.innerWidth;ti(e<768?"mobile":e<1024?"tablet":"desktop")};return e(),window.addEventListener("resize",e),()=>window.removeEventListener("resize",e)},[]);let tr="mobile"===tn;return(0,i.jsxs)("div",{style:{padding:tr?"28px 20px 80px":"40px 48px 80px",maxWidth:1100,margin:"0 auto",overflowY:"auto",height:"100%",fontFamily:G,color:k.text},children:[(0,i.jsxs)("header",{style:{marginBottom:36},children:[(0,i.jsx)("div",{style:{fontSize:10,color:k.textDim,textTransform:"uppercase",letterSpacing:"0.18em",fontWeight:600,marginBottom:12},children:"Tarification & revendeurs"}),(0,i.jsx)("h1",{style:{fontSize:"clamp(32px, 6vw, 46px)",fontFamily:G,fontWeight:600,color:k.text,letterSpacing:"-0.015em",lineHeight:1,margin:0},children:"B2B."}),(0,i.jsxs)("div",{style:{marginTop:14,fontSize:13,color:k.textMuted,lineHeight:1.6},children:[(0,i.jsxs)("span",{style:{whiteSpace:"nowrap",marginRight:20},children:[(0,i.jsx)("span",{style:{fontFamily:K,fontWeight:600,color:k.text,fontSize:13},children:eD.length}),(0,i.jsxs)("span",{style:{marginLeft:6},children:["campagne",1!==eD.length?"s":""]})]}),(0,i.jsxs)("span",{style:{whiteSpace:"nowrap",marginRight:20},children:[(0,i.jsx)("span",{"aria-hidden":"true",style:{marginRight:20,opacity:.45,color:k.textMuted},children:"\xb7"}),(0,i.jsx)("span",{style:{fontFamily:K,fontWeight:600,color:k.text,fontSize:13},children:z.length}),(0,i.jsxs)("span",{style:{marginLeft:6},children:["r\xe8gle",1!==z.length?"s":""," de prix"]})]})]})]}),(0,i.jsx)("div",{className:"b2b-tab-row",style:{display:"flex",gap:Q.xxl,marginBottom:28,paddingBottom:14,borderBottom:"1px solid ".concat(k.border),overflowX:"auto",overflowY:"hidden",WebkitOverflowScrolling:"touch",scrollbarWidth:"none"},children:[{id:"campaigns",label:"Campagnes"},{id:"rules",label:"R\xe8gles de prix"},{id:"settings",label:"Param\xe8tres"},{id:"reporting",label:"Reporting"}].map(e=>(0,i.jsxs)("button",{onClick:()=>_(e.id),"aria-pressed":C===e.id,style:{background:"transparent",border:"none",cursor:"pointer",padding:0,fontFamily:G,fontSize:11,fontWeight:700,textTransform:"uppercase",letterSpacing:"0.16em",color:C===e.id?k.text:k.textMuted,position:"relative",minHeight:32,whiteSpace:"nowrap",transition:"color 0.2s ease"},children:[e.label,C===e.id&&(0,i.jsx)("span",{style:{position:"absolute",bottom:-15,left
1:0,right:0,height:2,background:k.text}})]},e.id))}),(0,i.jsx)("style",{children:".b2b-tab-row::-webkit-scrollbar { display: none; }"}),"campaigns"===C&&(0,i.jsxs)("div",{style:{display:"grid",gridTemplateColumns:tr?"1fr":"1fr 320px",gap:Q.xl,alignItems:"start"},children:[(0,i.jsxs)("div",{children:[(0,i.jsxs)("p",{style:{fontSize:12,color:k.textMuted,margin:"0 0 ".concat(Q.lg,"px")},children:["Chaque campagne li\xe9 un ",(0,i.jsx)("strong",{children:"tag Shopify client"})," \xe0 un ",(0,i.jsx)("strong",{children:"label affich\xe9 en front"}),". En cas de tags multiples sur un client, la campagne avec la ",(0,i.jsx)("strong",{children:"priorit\xe9 la plus haute"})," s'applique. Une campagne sans tag (",(0,i.jsx)("code",{style:{fontFamily:K,fontSize:11},children:"*"}),") s'applique \xe0 ",(0,i.jsx)("strong",{children:"tous les clients connect\xe9s"}),"."]}),0===eD.length?(0,i.jsx)("div",{style:{...er(k),textAlign:"center",padding:Q.xxl},children:(0,i.jsx)("p",{style:{color:k.textMuted,fontSize:13,margin:0},children:"Aucune campagne. Cr\xe9ez-en une \xe0 droite."})}):(0,i.jsx)("div",{style:{display:"flex",flexDirection:"column",gap:Q.sm},children:eD.map(e=>{let t=z.filter(t=>t.tag===e.tag).length;return(0,i.jsxs)("div",{style:{...er(k),display:"flex",alignItems:"center",gap:Q.md,opacity:e.active?1:.5},children:[(0,i.jsx)("div",{style:{width:36,height:36,borderRadius:$.md,flexShrink:0,background:k.goldBg,display:"flex",alignItems:"center",justifyContent:"center",fontSize:13,fontWeight:700,color:k.gold,fontFamily:K},children:e.priority}),(0,i.jsxs)("div",{style:{flex:1,minWidth:0},children:[(0,i.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:Q.sm,marginBottom:3},children:[(0,i.jsx)("span",{style:{fontSize:11,padding:"2px 10px",borderRadius:$.pill,background:k.text,color:k.bg,fontWeight:700,letterSpacing:"0.05em"},children:e.label}),(0,i.jsx)("span",{style:{fontSize:10,padding:"1px 8px",borderRadius:$.pill,background:k.surfaceAlt,color:k.textMuted,fontFamily:K},children:"*"===e.tag?"tous les clients":"tag: ".concat(e.tag)}),!e.active&&(0,i.jsx)("span",{style:{fontSize:10,padding:"1px 8px",borderRadius:$.pill,background:"".concat(k.red,"15"),color:k.red,fontWeight:600},children:"inactif"})]}),(0,i.jsxs)("div",{style:{fontSize:11,color:k.textDim},children:[t," r\xe8gle",1!==t?"s":""," de prix"]})]}),(0,i.jsxs)("div",{style:{display:"flex",gap:Q.sm,flexShrink:0},children:[(0,i.jsx)("button",{style:{...ei(!1,k),fontSize:10},onClick:()=>e7(e),title:e.active?"D\xe9sactiver":"Activer",children:e.active?"D\xe9sactiver":"Activer"}),(0,i.jsx)("button",{style:{...ei(!1,k),fontSize:10},onClick:()=>{eq(e.id),eM({tag:e.tag,label:e.label,priority:String(e.priority)}),eE(null)},children:"Modifier"}),(0,i.jsx)("button",{style:{...ei(!1,k),fontSize:10,color:k.red,borderColor:"".concat(k.red,"30")},onClick:()=>e8(e.id),children:"Supprimer"})]})]},e.id)})})]}),(0,i.jsxs)("div",{style:{...er(k),position:"sticky",top:0},children:[(0,i.jsx)("h3",{style:{margin:"0 0 ".concat(Q.lg,"px"),fontSize:13,fontWeight:700,color:k.text},children:eW?"Modifier la campagne":"Nouvelle campagne"}),(0,i.jsxs)("div",{style:{marginBottom:Q.md},children:[(0,i.jsxs)("label",{style:et(k),children:["Tag Shopify client ",(0,i.jsx)("span",{style:{color:k.textDim,fontWeight:400},children:"(optionnel)"})]}),(0,i.jsx)("input",{style:Z(k),value:"*"===eI.tag?"":eI.tag,placeholder:"Ex: b2b, vp, grossiste — vide = tous les clients",onChange:e=>eM(t=>({...t,tag:e.target.value})),disabled:!!eW}),(0,i.jsxs)("p",{style:{fontSize:10,color:k.textDim,marginTop:3,marginBottom:0},children:["Tag exact sur le client Shopify (insensible \xe0 la casse). Laisser vide pour appliquer \xe0 ",(0,i.jsx)("strong",{children:"tous les clients connect\xe9s"}),".",eW&&" Non modifiable — supprimez et recr\xe9ez si besoin."]})]}),(0,i.jsxs)("div",{style:{marginBottom:Q.md},children:[(0,i.jsx)("label",{style:et(k),children:"Label affich\xe9 en front"}),(0,i.jsx)("input",{style:Z(k),value:eI.label,placeholder:"Ex: PRO, VPriv\xe9e, Grossiste",onChange:e=>eM(t=>({...t,label:e.target.value}))}
1),(0,i.jsx)("p",{style:{fontSize:10,color:k.textDim,marginTop:3,marginBottom:0},children:"Texte du badge visible \xe0 c\xf4t\xe9 du prix sur le site."})]}),(0,i.jsxs)("div",{style:{marginBottom:Q.md},children:[(0,i.jsx)("label",{style:et(k),children:"Priorit\xe9"}),(0,i.jsx)("input",{style:Z(k),type:"number",min:"0",step:"1",value:eI.priority,onChange:e=>eM(t=>({...t,priority:e.target.value}))}),(0,i.jsx)("p",{style:{fontSize:10,color:k.textDim,marginTop:3,marginBottom:0},children:"Plus \xe9lev\xe9 = appliqu\xe9 en premier si le client a plusieurs tags campagne."})]}),eF&&(0,i.jsx)("p",{style:{fontSize:11,color:k.red,margin:"0 0 ".concat(Q.sm,"px")},children:eF}),(0,i.jsxs)("div",{style:{display:"flex",gap:Q.sm},children:[(0,i.jsx)("button",{style:{...ei(!0,k),flex:1},onClick:e3,disabled:eL,children:eL?"Enregistrement…":eW?"Mettre \xe0 jour":"Cr\xe9er la campagne"}),eW&&(0,i.jsx)("button",{style:ei(!1,k),onClick:e5,children:"Annuler"})]})]})]}),"rules"===C&&(0,i.jsxs)("div",{style:{display:"grid",gridTemplateColumns:tr?"1fr":"1fr 340px",gap:Q.xl,alignItems:"start"},children:[(0,i.jsx)("div",{children:D?(0,i.jsx)("p",{style:{color:k.textMuted,fontSize:13},children:"Chargement…"}):0===z.length?(0,i.jsx)("div",{style:{...er(k),textAlign:"center",padding:Q.xxl},children:(0,i.jsx)("p",{style:{color:k.textMuted,fontSize:13,margin:0},children:"Aucune r\xe8gle B2B. Cr\xe9ez-en une \xe0 droite."})}):(0,i.jsx)("div",{style:{display:"flex",flexDirection:"column",gap:Q.sm},children:z.map(e=>(0,i.jsxs)("div",{style:{...er(k),display:"flex",alignItems:"center",justifyContent:"space-between",gap:Q.md},children:[(0,i.jsxs)("div",{style:{flex:1,minWidth:0},children:[(0,i.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:Q.sm,marginBottom:4},children:[(0,i.jsx)("span",{style:{fontWeight:600,fontSize:13,color:k.text},children:e.name}),(()=>{let t=eD.find(t=>t.tag===e.tag);return t?(0,i.jsx)("span",{style:{fontSize:10,padding:"2px 8px",borderRadius:$.pill,background:k.text,color:k.bg,fontWeight:700,letterSpacing:"0.04em"},children:t.label}):(0,i.jsxs)("span",{style:{fontSize:10,padding:"1px 8px",borderRadius:$.pill,background:k.goldBg,color:k.gold,fontWeight:600,fontFamily:K},children:["tag: ",e.tag]})})()]}),(0,i.jsxs)("div",{style:{fontSize:11,color:k.textMuted,display:"flex",gap:Q.md,flexWrap:"wrap"},children:[(0,i.jsx)("span",{children:tp[e.scope]}),"product"===e.scope&&e.product_id&&(0,i.jsxs)("span",{style:{fontFamily:K},children:["ID: ",e.product_id]}),"product_tag"===e.scope&&e.product_tag&&(0,i.jsxs)("span",{style:{fontFamily:K},children:["tag: ",e.product_tag]}),"product_type"===e.scope&&e.product_type&&(0,i.jsxs)("span",{style:{fontFamily:K},children:["type: ",e.product_type]}),(0,i.jsx)("span",{style:{color:k.green,fontWeight:600},children:"percentage"===e.discount_type?"−".concat(e.discount_value,"%"):"fixed_price"===e.discount_type?"→\xa0".concat(e.discount_value,"\xa0€"):"−".concat(e.discount_value,"\xa0€")}),(e.tiers||[]).map(t=>(0,i.jsx)("span",{style:{color:k.green},children:"percentage"===e.discount_type?"−".concat(t.discount_value,"% d\xe8s ").concat(t.min_qty," pcs"):"fixed_price"===e.discount_type?"→\xa0".concat(t.discount_value,"\xa0€ d\xe8s ").concat(t.min_qty," pcs"):"−".concat(t.discount_value,"\xa0€ d\xe8s ").concat(t.min_qty," pcs")},t.min_qty))]})]}),(0,i.jsxs)("div",{style:{display:"flex",gap:Q.sm,flexShrink:0},children:[(0,i.jsx)("button",{style:ei(!1,k),onClick:()=>{q(e.id),M({name:e.name,tag:e.tag,scope:e.scope,product_id:e.product_id||"",product_tag:e.product_tag||"",product_type:e.product_type||"",collection_handle:e.collection_handle||"",discount_type:e.discount_type,discount_value:String(e.discount_value),tiers:(e.tiers||[]).map(e=>({min_qty:String(e.min_qty),discount_value:String(e.discount_value)}))}),E(null)},children:"Modifier"}),(0,i.jsx)("button",{style:{...ei(!1,k),color:k.red,borderColor:"".concat(k.red,"30")},onClick:()=>e4(e.id),children:"Supprimer"})]})]},e.id))})}),(0,i.jsxs)("div",{style:{...er(k),position:"sticky",top:0},children:[(0,i.jsx)("h3",{style:{margin:"0 0 ".concat(Q.lg,"px"),fontSize:13,fontWeight:700,color:k.text},children:W?"Modifier la r\xe8gle":"Nouvelle r\xe8gle"}),tt("Nom de la r\xe8gle",(0,i.jsx)("input",{style:Z(k),value:I.name,placeholder:"Ex: Grossistes −20%",onChange:e=>M(t=>({...t,name:e.target.value}))})),tt("Campagne",(0,i.jsxs)(i.Fragment,{children:[(0,i.jsxs)("select",{style:Z(k),value:I.tag,onChange:e=>M(t=>({...t,tag:e.target.value})),children:[(0,i.jsx)("option",{value:"",children:"— Choisir une campagne —"}),eD.map(e=>(0,i.jsxs)("option",{value:e.tag,children:[e.label," ","*"===e.tag?"(tous les clients)":"(tag: ".concat(e.tag,")")]},e.tag))]}
1),0===eD.length&&(0,i.jsx)("p",{style:{fontSize:10,color:k.orange,marginTop:3,marginBottom:0},children:"Aucune campagne configur\xe9e. Cr\xe9ez-en une dans l'onglet \"Campagnes\" d'abord."})]})),tt("Port\xe9e",(0,i.jsxs)("select",{style:Z(k),value:I.scope,onChange:e=>M(t=>({...t,scope:e.target.value})),children:[(0,i.jsx)("option",{value:"all",children:"Tous les produits"}),(0,i.jsx)("option",{value:"product",children:"Produit sp\xe9cifique (ID Shopify)"}),(0,i.jsx)("option",{value:"product_tag",children:"Tag produit Shopify"}),(0,i.jsx)("option",{value:"product_type",children:"Type de produit"})]})),"product"===I.scope&&tt("ID Produit Shopify",(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)("input",{style:Z(k),value:I.product_id,placeholder:"Ex: 8234567890",onChange:e=>M(t=>({...t,product_id:e.target.value}))}),(0,i.jsx)("p",{style:{fontSize:10,color:k.textDim,marginTop:3,marginBottom:0},children:"Visible dans l'URL produit Shopify admin."})]})),"product_type"===I.scope&&tt("Type de produit",(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)("input",{style:Z(k),value:I.product_type,placeholder:"Ex: Linge de lit",onChange:e=>M(t=>({...t,product_type:e.target.value}))}),(0,i.jsx)("p",{style:{fontSize:10,color:k.textDim,marginTop:3,marginBottom:0},children:'Correspond au champ "Type" dans la fiche produit Shopify.'})]})),"product_tag"===I.scope&&tt("Tag produit Shopify",(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)("input",{style:Z(k),value:I.product_tag,placeholder:"Ex: linge-de-maison",onChange:e=>M(t=>({...t,product_tag:e.target.value}))}),(0,i.jsx)("p",{style:{fontSize:10,color:k.textDim,marginTop:3,marginBottom:0},children:"S'applique \xe0 tous les produits ayant ce tag dans Shopify."})]})),tt("Type de prix B2B",(0,i.jsxs)("select",{style:Z(k),value:I.discount_type,onChange:e=>M(t=>({...t,discount_type:e.target.value})),children:[(0,i.jsx)("option",{value:"percentage",children:"Pourcentage (%)"}),(0,i.jsx)("option",{value:"fixed",children:"Remise fixe (€)"}),(0,i.jsx)("option",{value:"fixed_price",children:"Prix fixe B2B (€)"})]})),tt("percentage"===I.discount_type?"Remise (%)":"fixed_price"===I.discount_type?"Prix B2B (€ TTC)":"Remise (€ TTC)",(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)("input",{style:Z(k),type:"number",min:"0",step:"0.01",value:I.discount_value,placeholder:"percentage"===I.discount_type?"Ex: 20":"fixed_price"===I.discount_type?"Ex: 22.00":"Ex: 5.00",onChange:e=>M(t=>({...t,discount_value:e.target.value}))}),"fixed_price"===I.discount_type&&(0,i.jsx)("p",{style:{fontSize:10,color:k.textDim,marginTop:3,marginBottom:0},children:"Le client B2B verra ce prix affich\xe9 quel que soit le prix original."})]})),tt("Tarifs d\xe9gressifs (optionnel)",(0,i.jsxs)(i.Fragment,{children:[I.tiers.map((e,t)=>(0,i.jsxs)("div",{style:{display:"flex",gap:Q.sm,alignItems:"center",marginBottom:Q.sm},children:[(0,i.jsx)("span",{style:{fontSize:11,color:k.textMuted,flexShrink:0},children:"d\xe8s"}),(0,i.jsx)("input",{style:{...Z(k),width:70},type:"number",min:"2",step:"1",value:e.min_qty,placeholder:"101",onChange:e=>M(n=>({...n,tiers:n.tiers.map((n,i)=>i===t?{...n,min_qty:e.target.value}:n)}))}),(0,i.jsx)("span",{style:{fontSize:11,color:k.textMuted,flexShrink:0},children:"pcs\xa0→"}),(0,i.jsx)("input",{style:{...Z(k),width:80},type:"number",min:"0",step:"0.01",value:e.discount_value,placeholder:"percentage"===I.discount_type?"%":"€",onChange:e=>M(n=>({...n,tiers:n.tiers.map((n,i)=>i===t?{...n,discount_value:e.target.value}:n)}))}),(0,i.jsx)("button",{style:{...ei(!1,k),color:k.red,borderColor:"".concat(k.red,"30"),padding:"4px 8px"},onClick:()=>M(e=>({...e,tiers:e.tiers.filter((e,n)=>n!==t)})),children:"\xd7"})]},t)),(0,i.jsx)("button",{style:ei(!1,k),onClick:()=>M(e=>({...e,tiers:[...e.tiers,{min_qty:"",discount_value:""}]})),children:"+ Ajouter un palier"}),(0,i.jsx)("p",{style:{fontSize:10,color:k.textDim,marginTop:3,marginBottom:0},children:"La quantit\xe9 cumule toutes les lignes du panier couvertes par cette r\xe8gle (ex. 101 t-shirts toutes tailles confondues)."})]})),F&&(0,i.jsx)("p",{style:{fontSize:11,color:k.red,margin:"0 0 ".concat(Q.sm,"px")},children:F}),(0,i.jsxs)("div",{style:{display:"flex",gap:Q.sm},children:[(0,i.jsx)("button",{style:{...ei(!0,k),flex:1},onClick:e6,disabled:L,children:L?"Enregistrement…":W?"Mettre \xe0 j
1our":"Cr\xe9er la r\xe8gle"}),W&&(0,i.jsx)("button",{style:ei(!1,k),onClick:e2,children:"Annuler"})]}),(0,i.jsx)("p",{style:{fontSize:10,color:k.textDim,marginTop:Q.sm,marginBottom:0},children:"Les modifications sont effectives dans les 5 minutes sur le site Shopify."})]})]}),"settings"===C&&(0,i.jsxs)("div",{style:{maxWidth:480},children:[(0,i.jsxs)("div",{style:er(k),children:[(0,i.jsx)("h3",{style:{margin:"0 0 ".concat(Q.lg,"px"),fontSize:13,fontWeight:700,color:k.text},children:"Param\xe8tres globaux B2B"}),(0,i.jsxs)("div",{style:{marginBottom:Q.lg},children:[(0,i.jsx)("label",{style:et(k),children:"Quantit\xe9 minimum de commande (total articles)"}),(0,i.jsx)("input",{style:Z(k),type:"number",min:"0",step:"1",value:B,onChange:e=>P(e.target.value)}),(0,i.jsx)("p",{style:{fontSize:11,color:k.textMuted,marginTop:4,marginBottom:0},children:"Mettre \xe0 0 pour d\xe9sactiver le minimum. S'applique au total d'articles dans le panier."})]}),(0,i.jsx)("button",{style:ei(!0,k),onClick:e9,disabled:O,children:O?"Enregistrement…":N?"✓ Enregistr\xe9":"Enregistrer"})]}),(0,i.jsxs)("div",{style:{...er(k),marginTop:Q.lg},children:[(0,i.jsx)("h3",{style:{margin:"0 0 ".concat(Q.sm,"px"),fontSize:13,fontWeight:700,color:k.text},children:"Statut Shopify Function"}),null===V?(0,i.jsx)("span",{style:{fontSize:11,color:k.textMuted},children:"V\xe9rification…"}):(0,i.jsxs)("div",{style:{fontSize:12,color:k.textMuted,display:"flex",flexDirection:"column",gap:Q.sm},children:[(0,i.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:Q.sm},children:[(0,i.jsx)("span",{style:{width:8,height:8,borderRadius:"50%",background:(null==(t=V.function)?void 0:t.found)?"#22c55e":"#ef4444",display:"inline-block"}}),(0,i.jsxs)("span",{style:{color:k.text},children:["Function : ",(null==(n=V.function)?void 0:n.found)?"d\xe9ploy\xe9e":"non trouv\xe9e"]})]}),(0,i.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:Q.sm},children:[(0,i.jsx)("span",{style:{width:8,height:8,borderRadius:"50%",background:(null==(l=V.discount)?void 0:l.activated)?"#22c55e":"#f59e0b",display:"inline-block"}}),(0,i.jsxs)("span",{style:{color:k.text},children:["Discount : ",(null==(o=V.discount)?void 0:o.activated)?"active (".concat(V.discount.status,")"):"non d\xe9tect\xe9e"]})]}),(0,i.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:Q.sm},children:[(0,i.jsx)("span",{style:{width:8,height:8,borderRadius:"50%",background:(null==(s=V.shopMetafield)?void 0:s.exists)?"#22c55e":"#ef4444",display:"inline-block"}}),(0,i.jsxs)("span",{style:{color:k.text},children:["R\xe8gles Shopify : ",(null==(a=V.shopMetafield)?void 0:a.exists)?"".concat(V.shopMetafield.rulesCount," r\xe8gle(s) synchronis\xe9e(s)"):"non synchronis\xe9es"]})]}),((null==(d=V.sampleCustomers)?void 0:d.length)?V.sampleCustomers:V.sampleCustomer?[V.sampleCustomer]:[]).map(e=>(0,i.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:Q.sm},children:[(0,i.jsx)("span",{style:{width:8,height:8,borderRadius:"50%",background:"MISSING"!==e.metafieldValue?"#22c55e":"#ef4444",display:"inline-block"}}),(0,i.jsxs)("span",{style:{color:k.text},children:["Client ",(0,i.jsx)("code",{style:{fontFamily:K,background:k.surfaceAlt,padding:"1px 4px",borderRadius:3},children:e.tag})," : ",e.email," — metafield ","MISSING"!==e.metafieldValue?(0,i.jsxs)("strong",{children:['"',e.metafieldValue,'"']}):(0,i.jsx)("span",{style:{color:"#ef4444"},children:'manquant → lancer "Synchro tags clients"'})]})]},e.tag)),!(null==(c=V.discount)?void 0:c.activated)&&(0,i.jsxs)("div",{style:{marginTop:Q.md},children:[(0,i.jsx)("button",{style:ei(!0,k),onClick:eJ,disabled:eu,children:eu?"Initialisation…":"Cr\xe9er le discount automatique"}),eb&&(()=>{let e=eb.discount,t=(null==e?void 0:e.status)==="created"||(null==e?void 0:e.status)==="created_with_fallback_title"||"already_exists"===e,n=(null==e?void 0:e.status)==="created"?"Discount cr\xe9\xe9 avec succ\xe8s.":(null==e?void 0:e.status)==="created_with_fallback_title"?'Discount "'.concat(e.title,'" cr\xe9\xe9. Supprime manuellement l\'ancien "Tarif B2B" dans Shopify Admin → Remises, puis relance le setup.'):"already_exists"===e?"Discount d\xe9j\xe0 existant.":"Erreur : ".concat((null==e?void 0:e.error)||JSON.stringify(e));return(0,i.jsx)("p",{style:{fontSize:11,color:t?k.green:k.red,marginTop:Q.sm,marginBottom:0},children:n})})()]})]})]}),(0,i.jsxs)("div",{style:{...er(k),marginTop:Q.lg},children:[(0,i.jsx)("h3",{style:{margin:"0 0 ".concat(Q.sm,"px"),fontSize:13,fontWeight:700,color:k.text},children:"Webhooks automatiques"}),(0,i.jsx)("p",{style:{fontSize:12,color:k.textMuted,marginTop:0,marginBottom:Q.md},children:"Enregistre des webhooks Shopify pour synchroniser automatiquement les metafields \xe0 chaque modification de client ou produit — sans synchro manuelle."}),(null==eg?void 0:eg.webhooks)&&(0,i.jsx)("div",{style:{display:"flex",flexDirection:"column",gap:4,marginBottom:Q.md},children:eg.webhooks.map(e=>(0,i.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:Q.sm,fontSize:12},children:[(0,i.jsx)("span",{style:{width:8,height:8,borderRadius:"50%",background:e.registered?"#22c55e":"#f59e0b",display:"inline-block",flexShrink:0}}),(0,i.jsxs)("span",{style:{color:k.text},children:[e.topic," → ",(0,i.jsx)("code",{style:{fontFamily:K,background:k.surfaceAlt,padding:"1px 4px",borderRadius:3},children:e.path})," ",e.registered?"✓":"non enregistr\xe9"]})]},e.topic))}),(0,i.jsx)("button",{style:ei(!0,k),onClick:eZ,disabled:eh,children:eh?"Enregistrement…":"Enregistrer les webhooks"}),ef&&(0,i.jsx)("p",{style:{fontSize:11,color:ef.error?k.red:k.green,marginTop:Q.sm,marginBottom:0},children:ef.error||(null==(u=ef.results)?void 0:u.map(e=>"".concat(e.topic,": ").concat(e.status)).join(" \xb7 "))})]}),(0,i.jsxs)("div",{style:{...er(k),marginTop:Q.lg},children:[(0,i.jsx)("h3",{style:{margin:"0 0 ".concat(Q.sm,"px"),fontSize:13,fontWeight:700,color:k.text},children:"Synchro tags clients"}),(0,i.jsxs)("p",{style:{fontSize:12,color:k.textMuted,marginTop:0,marginBottom:Q.md},children:["Pose le metafield ",(0,i.jsx)("code",{style:{fontFamily:K,background:k.surfaceAlt,padding:"1px 4px",borderRadius:3},children:"b2b_pricing.tag"})," sur tous les clients dont le tag Shopify correspond \xe0 une campagne active (B2B, VPriv\xe9e, Friends…). \xc0 relancer apr\xe8s avoir tagu\xe9 un nouveau client."]}),(0,i.jsx)("button",{style:ei(!0,k),onClick:eQ,disabled:X,children:X?"Synchronisation…":"Synchro tags clients"}),en&&!en.error&&(0,i.jsxs)("p",{style:{fontSize:11,color:k.green,marginTop:Q.sm,marginBottom:0},children:[en.found," client(s) trouv\xe9(s), ",en.synced," synchronis\xe9(s), ",en.alreadyOk," d\xe9j\xe0 OK.",(null==(p=en.errors)?void 0:p.length)>0&&(0,i.jsxs)("span",{style:{color:k.red},children:[" — ",en.errors.length," erreur(s) : ",en.errors.map(e=>e.error).join("; ")]})]}),(null==en?void 0:en.error)&&(0,i.jsx)("p",{style:{fontSize:11,color:k.red,marginTop:Q.sm,marginBottom:0},children:en.error})]}),(0,i.jsxs)("div",{style:{...er(k),marginTop:Q.lg},children:[(0,i.jsx)("h3",{style:{margin:"0 0 ".concat(Q.sm,"px"),fontSize:13,fontWeight:700,color:k.text},children:"Synchro tags produits"}),(0,i.jsxs)("p",{style:{fontSize:12,color:k.textMuted,marginTop:0,marginBottom:Q.md},children:["Pour les r\xe8gles de type ",(0,i.jsx)("code",{style:{fontFamily:K,background:k.surfaceAlt,padding:"1px 4px",borderRadius:3},children:"product_tag"}),", pose le metafield ",(0,i.jsx)("code",{style:{fontFamily:K,background:k.surfaceAlt,padding:"1px 4px",borderRadius:3},children:"b2b_pricing.product_tag"})," sur tous les produits Shopify ayant le tag correspondant. N\xe9cessaire pour que la remise s'applique au checkout."]}),(0,i.jsx)("button",{style:ei(!0,k),onClick:eX,disabled:es,children:es?"Synchronisation…":"Synchro tags produits"}),ed&&!ed.error&&(0,i.jsxs)("p",{style:{fontSize:11,color:(null==(g=ed.errors)?void 0:g.length)?k.red:k.green,marginTop:Q.sm,marginBottom:0},children:[ed.message||"Tags trait\xe9s : ".concat((ed.tags||[]).join(", ")," — ").concat(null!=(S=ed.found)?S:"?"," produit(s) trouv\xe9(s), ").concat(ed.synced," mis \xe0 jour, ").concat(ed.alreadyOk," d\xe9j\xe0 OK."),(null==(x=ed.errors)?void 0:x.length)>0&&(0,i.jsxs)("span",{children:[" Erreurs : ",ed.errors.map(e=>e.error).join("; ")]})]}),(null==ed?void 0:ed.error)&&(0,i.jsx)("p",{style:{fontSize:11,color:k.red,marginTop:Q.sm,marginBottom:0},children:ed.error})]}),(0,i.jsxs)("div",{style:{...er(k),marginTop:Q.lg},children:[(0,i.jsx)("h3",{style:{margin:"0 0 ".concat(Q.sm,"px"),fontSize:13,fontWeight:700,color:k.text},children:"Diagnostic checkout"}),(0,i.jsx)("p",{style:{fontSize:12,color:k.textMuted,marginTop:0,marginBottom:Q.md},children:"V\xe9rifie ce que la Shopify Function verrait pour un client donn\xe9 : metafield client, r\xe8gles applicables, metafields produits."}),(0,i.jsxs)("div",{style:{display:"flex",flexDirection:"column",gap:Q.sm,marginBottom:Q.md},children:[(0,i.jsxs)("div",{style:{display:"flex",gap:Q.sm,alignItems:"center"},children:[(0,i.jsx)("input",{value:ej,onChange:e=>eS(e.target.value),onKeyDown:e=>"Enter"===e.key&&e0(),placeholder:"email du client",style:{flex:1,padding:"6px 10px",fontSize:12,borderRadius:$.sm,border:"1px solid ".concat(k.border),background:k.surface,color:k.text,fontFamily:"inherit"}}),(0,i.jsx)("input",{value:ek,onChange:e=>ew(e.target.value),onKeyDown:e=>"Enter"===e.key&&e0(),placeholder:"handle produit (optionnel)",style:{flex:1,padding:"6px 10px",fontSize:12,borderRadius:$.sm,border:"1px solid ".concat(k.border),background:k.surface,color:k.text,fontFamily:"inherit"}}),(0,i.jsx)("button",{style:ei(!0,k),onClick:e0,disabled:eC||!ej.trim(),children:eC?"Test…":"Tester"})]}),(0,i.jsxs)("p",{style:{fontSize:11,color:k.textMuted,margin:0},children:["Le handle produit se trouve dans l'URL Shopify : ",(0,i.jsx)("code",{style:{fontFamily:K,background:k.surfaceAlt,padding:"1px 4px",borderRadius:3},children:"/products/[handle]"})]})]}),ez&&(0,i.jsxs)("div",{style:{fontSize:12,display:"flex",flexDirection:"column",gap:6},children:[(0,i.jsxs)("div",{style:{display:"flex",alignItems:"flex-start",ga
1p:Q.sm},children:[(0,i.jsx)("span",{style:{width:8,height:8,borderRadius:"50%",background:(null==(h=ez.customer)?void 0:h.b2bMetafield)&&"MISSING"!==ez.customer.b2bMetafield?"#22c55e":"#ef4444",display:"inline-block",marginTop:2,flexShrink:0}}),(0,i.jsxs)("span",{style:{color:k.text},children:["Client : ",(null==(m=ez.customer)?void 0:m.email)||(null==(f=ez.customer)?void 0:f.error)||"introuvable",(null==(y=ez.customer)?void 0:y.b2bMetafield)&&(0,i.jsxs)(i.Fragment,{children:[" — metafield ",(0,i.jsx)("strong",{children:"MISSING"===ez.customer.b2bMetafield?"❌ manquant":'"'.concat(ez.customer.b2bMetafield,'"')})]})]})]}),(0,i.jsxs)("div",{style:{display:"flex",alignItems:"flex-start",gap:Q.sm},children:[(0,i.jsx)("span",{style:{width:8,height:8,borderRadius:"50%",background:ez.matchingRule?"#22c55e":"#ef4444",display:"inline-block",marginTop:2,flexShrink:0}}),(0,i.jsxs)("span",{style:{color:k.text},children:["R\xe8gles shop : ",ez.rulesCount," au total",ez.matchingRule?(0,i.jsxs)(i.Fragment,{children:[" — r\xe8gle trouv\xe9e : ",(0,i.jsx)("strong",{children:ez.matchingRule.name})," (scope: ",ez.matchingRule.scope,", ",ez.matchingRule.discount_value,"percentage"===ez.matchingRule.discount_type?"%":"€",")"]}):ez.customerTag?(0,i.jsxs)("span",{style:{color:"#ef4444"},children:[' — aucune r\xe8gle pour le tag "',ez.customerTag,'"']}):(0,i.jsx)("span",{style:{color:"#ef4444"},children:" — pas de tag client"})]})]}),ez.product&&(0,i.jsxs)("div",{style:{display:"flex",alignItems:"flex-start",gap:Q.sm},children:[(0,i.jsx)("span",{style:{width:8,height:8,borderRadius:"50%",background:ez.product.b2bTagMetafield?"#22c55e":"#ef4444",display:"inline-block",marginTop:2,flexShrink:0}}),(0,i.jsxs)("span",{style:{color:k.text},children:["Produit ",(0,i.jsx)("strong",{children:ez.product.title})," —"," ",ez.product.b2bTagMetafield?(0,i.jsxs)(i.Fragment,{children:["metafield ",(0,i.jsxs)("strong",{children:['"',ez.product.b2bTagMetafield,'"']})," ✅"]}):(0,i.jsxs)("span",{style:{color:"#ef4444"},children:["metafield ",(0,i.jsx)("code",{style:{fontFamily:K,background:k.surfaceAlt,padding:"1px 4px",borderRadius:3},children:"b2b_pricing.product_tag"}),' manquant → lance "Synchro tags produits"']})," ",(0,i.jsxs)("span",{style:{color:k.textMuted},children:["(tags Shopify : ",(null==(b=ez.product.tags)?void 0:b.join(", "))||"aucun",")"]})]})]}),(0,i.jsx)("div",{style:{marginTop:4,padding:"6px 10px",borderRadius:$.sm,background:k.surfaceAlt,fontFamily:K,fontSize:11,color:ez.functionWouldApply?"#22c55e":(null==(v=ez.diagnosis)?void 0:v.startsWith("⚠️"))?"#f59e0b":"#ef4444"},children:ez.diagnosis}),!ez.matchingRule&&(null==(j=ez.rules)?void 0:j.length)>0&&(0,i.jsxs)("details",{style:{marginTop:4},children:[(0,i.jsxs)("summary",{style:{fontSize:11,color:k.textMuted,cursor:"pointer"},children:["Voir les ",ez.rules.length," r\xe8gle(s) en shop metafield"]}),(0,i.jsx)("pre",{style:{fontSize:10,color:k.textMuted,marginTop:4,overflowX:"auto"},children:JSON.stringify(ez.rules,null,2)})]})]})]}),(0,i.jsxs)("div",{style:{...er(k),marginTop:Q.lg},children:[(0,i.jsx)("h3",{style:{margin:"0 0 ".concat(Q.md,"px"),fontSize:13,fontWeight:700,color:k.text},children:"Int\xe9gration Shopify"}),(0,i.jsxs)("p",{style:{fontSize:12,color:k.textMuted,marginTop:0},children:["Ajoutez dans ",(0,i.jsx)("code",{style:{fontFamily:K,background:k.surfaceAlt,padding:"1px 4px",borderRadius:3},children:"theme.liquid"})," avant ",(0,i.jsx)("code",{style:{fontFamily:K,background:k.surfaceAlt,padding:"1px 4px",borderRadius:3},children:"</body>"})," :"]}),(0,i.jsx)("pre",{style:{fontFamily:K,fontSize:10,color:k.text,background:k.surfaceAlt,padding:Q.md,borderRadius:$.md,overflowX:"auto",whiteSpace:"pre-wrap",wordBreak:"break-all",margin:0},children:'<script>\n  window.b2bCustomer = {\n    loggedIn: {% if customer %}true{% else %}false{% endif %},\n    email: "{{ customer.email | escape }}"\n  };\n<\/script>\n<script src="https://sav-assistant-next.vercel.app/widget/b2b-pricing.js"\n  data-server="https://sav-assistant-next.vercel.app">\n<\/script>'})]})]}),"reporting"===C&&(0,i.jsxs)("div",{children:[(0,i.jsxs)("div",{style:{display:"flex",gap:Q.sm,marginBottom:Q.xl,alignItems:"center"},children:[(0,i.jsx)("span",{style:{fontSize:12,color:k.textMuted},children:"P\xe9riode :"}),[7,30,90].map(e=>(0,i.jsxs)("button",{style:eo(eO===e,k),onClick:()=>{eU(e),eP(null),e1(e)},children:[e,"j"]},e)),eN&&(0,i.jsx)("span",{style:{fontSize:11,color:k.textMuted},children:"Chargement…"})]}),eB&&(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(160px, 1fr))",gap:Q.md,marginBottom:Q.xl},children:[{label:"Commandes B2B",value:eB.summary.totalOrders,color:k.blue},{label:"Chiffre d'affaires",value:te(eB.summary.totalRevenue),color:k.gold}
1,{label:"Compl\xe9t\xe9es",value:eB.summary.completedOrders,color:k.green},{label:"En attente",value:eB.summary.pendingOrders,color:k.orange},{label:"Abandonn\xe9es",value:eB.summary.abandonedOrders,color:k.red}].map(e=>(0,i.jsxs)("div",{style:{...er(k),textAlign:"center",background:"".concat(e.color,"08"),border:"1px solid ".concat(e.color,"20")},children:[(0,i.jsx)("div",{style:{fontSize:20,fontWeight:700,color:e.color,fontFamily:K},children:e.value}),(0,i.jsx)("div",{style:{fontSize:10,color:k.textMuted,marginTop:2},children:e.label})]},e.label))}),(0,i.jsxs)("div",{style:{display:"grid",gridTemplateColumns:tr?"1fr":"1fr 1fr",gap:Q.xl,marginBottom:Q.xl},children:[eB.by_tag.length>0&&(0,i.jsxs)("div",{style:er(k),children:[(0,i.jsx)("h3",{style:{margin:"0 0 ".concat(Q.md,"px"),fontSize:13,fontWeight:700,color:k.text},children:"Par tag B2B"}),(0,i.jsxs)("table",{style:{width:"100%",borderCollapse:"collapse",fontSize:12},children:[(0,i.jsx)("thead",{children:(0,i.jsx)("tr",{children:["Tag","Commandes","CA","Clients"].map(e=>(0,i.jsx)("th",{style:{padding:"4px 8px",textAlign:"left",color:k.textDim,fontWeight:600,fontSize:10,textTransform:"uppercase",letterSpacing:"0.05em"},children:e},e))})}),(0,i.jsx)("tbody",{children:eB.by_tag.map(e=>(0,i.jsxs)("tr",{style:{borderTop:"1px solid ".concat(k.border)},children:[(0,i.jsx)("td",{style:{padding:"6px 8px",color:k.gold,fontWeight:600},children:e.tag}),(0,i.jsx)("td",{style:{padding:"6px 8px",color:k.text,fontFamily:K},children:e.orders}),(0,i.jsx)("td",{style:{padding:"6px 8px",color:k.text,fontFamily:K},children:te(e.revenue)}),(0,i.jsx)("td",{style:{padding:"6px 8px",color:k.textMuted,fontFamily:K},children:e.unique_customers})]},e.tag))})]})]}),eB.top_customers.length>0&&(0,i.jsxs)("div",{style:er(k),children:[(0,i.jsx)("h3",{style:{margin:"0 0 ".concat(Q.md,"px"),fontSize:13,fontWeight:700,color:k.text},children:"Top clients B2B"}),(0,i.jsxs)("table",{style:{width:"100%",borderCollapse:"collapse",fontSize:12},children:[(0,i.jsx)("thead",{children:(0,i.jsx)("tr",{children:["Email","Tag","Cmds","CA"].map(e=>(0,i.jsx)("th",{style:{padding:"4px 8px",textAlign:"left",color:k.textDim,fontWeight:600,fontSize:10,textTransform:"uppercase",letterSpacing:"0.05em"},children:e},e))})}),(0,i.jsx)("tbody",{children:eB.top_customers.map(e=>(0,i.jsxs)("tr",{style:{borderTop:"1px solid ".concat(k.border)},children:[(0,i.jsx)("td",{style:{padding:"6px 8px",color:k.text,maxWidth:160,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:e.email}),(0,i.jsx)("td",{style:{padding:"6px 8px",color:k.gold,fontWeight:600},children:e.tag}),(0,i.jsx)("td",{style:{padding:"6px 8px",color:k.text,fontFamily:K},children:e.orders}),(0,i.jsx)("td",{style:{padding:"6px 8px",color:k.text,fontFamily:K},children:te(e.revenue)})]},e.email))})]})]})]}),eB.recent_orders.length>0&&(0,i.jsxs)("div",{style:er(k),children:[(0,i.jsxs)("h3",{style:{margin:"0 0 ".concat(Q.md,"px"),fontSize:13,fontWeight:700,color:k.text},children:["Commandes r\xe9centes (",eB.recent_orders.length,")"]}),(0,i.jsx)("div",{style:{overflowX:"auto"},children:(0,i.jsxs)("table",{style:{width:"100%",borderCollapse:"collapse",fontSize:12,minWidth:600},children:[(0,i.jsx)("thead",{children:(0,i.jsx)("tr",{children:["Date","Client","Tag","Montant","Statut","Lien"].map(e=>(0,i.jsx)("th",{style:{padding:"4px 8px",textAlign:"left",color:k.textDim,fontWeight:600,fontSize:10,textTransform:"uppercase",letterSpacing:"0.05em"},children:e},e))})}),(0,i.jsx)("tbody",{children:eB.recent_orders.map(e=>(0,i.jsxs)("tr",{style:{borderTop:"1px solid ".concat(k.border)},children:[(0,i.jsx)("td",{style:{padding:"6px 8px",color:k.textMuted,fontFamily:K,whiteSpace:"nowrap"},children:new Date(e.created_at).toLocaleDateString("fr-FR")}),(0,i.jsx)("td",{style:{padding:"6px 8px",color:k.text,maxWidth:160,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:e.customer_email}),(0,i.jsx)("td",{style:{padding:"6px 8px",color:k.gold,fontWeight:600},children:e.customer_tag}),(0,i.jsx)("td",{style:{padding:"6px 8px",color:k.text,fontFamily:K},children:e.subtotal?te(e.subtotal):"—"}),(0,i.jsx)("td",{style:{padding:"6px 8px"},children:(0,i.jsx)("span",{style:{fontSize:10,padding:"2px 8px",borderRadius:$.pill,background:"completed"===e.status?"".concat(k.green,"15"):"abandoned"===e.status?"".concat(k.red,"15"):"".concat(k.orange,"15"),color:"completed"===e.status?k.green:"abandoned"===e.status?k.red:k.orange,fontWeight:600},children:"completed"===e.status?"Compl\xe9t\xe9e":"abandoned"===e.status?"Abandonn\xe9e":"En attente"})}),(0,i.jsx)("td",{style:{padding:"6px 8px"},children:e.shopify_invoice_url?(0,i.jsx)("a",{href:e.shopify_invoice_url,target:"_blank",rel:"noopener noreferrer",style:{color:k.blue,fontSize:11,textDecoration:"none"},children:"Voir ↗"}):"—"})]},e.id))})]})})]}),0===eB.recent_orders.length&&!eN&&(0,i.jsx)("div",{style:{...er(k),textAlign:"center",padding:Q.xxl},children:(0,i.jsx)("p",{style:{color:k.textMuted,fontSize:13,margin:0},children:"Aucune commande B2B sur cette p\xe9riode."})})]})]})]})}let tx=[{id:"select",label:"1. S\xe9lection"},{id:"compose",label:"2. Composition"},{id:"send",label:"3. Envoi"}],th=[{value:"unfulfilled",label:"\xc0 exp\xe9dier"},{value:"partial",label:"Partiellement"},{value:"label_created",label:"\xc9tiquette cr\xe9\xe9e (non scann\xe9e)"},{value:"in_transit",label:"En transit"},{value:"delivered",label:"Livr\xe9"},{value:"pickup_or_pos",label:"Retrait magasin / POS"}],tm=["unfulfilled","partial","label_created"],tf="Nous tenons \xe0 vous informer d'un l\xe9ger retard dans la pr\xe9paration de votre commande. Nos artisans mettent tout en œuvre pour vous l'exp\xe9dier dans les meilleurs d\xe9lais.\n\nNous vous remercions de votre patience et restons \xe0 votre disposition pour toute question.";function ty(e){var t;let{t:n,active:o}=e,[s,a]=(0,r.useState)("select"),[c,u]=(0,r.useState)("filters"),[p,g]=(0,r.useState)(""),[x,h]=(0,r.useState)(""),[m,f]=(0,r.useState)(""),[y,b]=(0,r.useState)(""),[v,j]=(0,r.useState)(""),[S,k]=(0,r.useState)(tm),[w,C]=(0,r.useState)(""),[_,z]=(0,r.useState)([]),[T,D]=(0,r.useState)(new Set),[R,I]=(0,r.useState)(!1),[M,W]=(0,r.useState)(""),[q,L]=(0,r.useState)("Suivi de votre commande Sudist"),[A,F]=(0,r.useState)(tf),[E,B]=(0,r.useState)(null),[P,O]=(0,r.useState)(!1),[U,N]=(0,r.useState)(""),[H,V]=(0,r.useState)(!1),[Y,J]=(0,r.useState)(null),[X,en]=(0,r.useState)(!1),[el,es]=(0,r.useState)([]),[ea,ed]=(0,r.useState)(!1);(0,r.useEffect)(()=>{o&&d().then(e=>{e.success&&es(e.campaigns||[])}).catch(()=>{})},[o]);let ec=(0,r.useMemo)(()=>_.filter(e=>T.has(e.id)),[_,T]),eu=(0,r.useMemo)(()=>{let e=new Set;for(let t of ec)e.add(t.customer.email);return e.size},[ec]),ep=async()=>{I(!0),W(""),z([]),D(new Set);try{let e,t="filters"===c?await (e={skuQuery:p,createdMin:x,createdMax:m,country:y,tag:v,statuses:S},l("/notifications/search",{method:"POST",body:e})):await l("/notifications/resolve",{method:"POST",body:{input:w}});t.success?(z(t.orders||[]),D(new Set((t.orders||[]).map(e=>e.id)))):W(t.error||"Erreur")}catch(e){W(e.message)}I(!1)}
1,eh=e=>{D(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},em=async()=>{ec.length&&(a("compose"),await ef())},ef=async()=>{O(!0);try{let e=await l("/notifications/preview",{method:"POST",body:{subject:q,body:A,orders:ec}});e.success?B(e):B({error:e.error})}catch(e){B({error:e.message})}O(!1)},ey=async()=>{if(U){V(!0);try{let e=await l("/notifications/send-test",{method:"POST",body:{to:U,subject:q,body:A,orders:ec}});e.success?alert("Email test envoy\xe9 \xe0 "+U):alert("Erreur: "+(e.error||"inconnue"))}catch(e){alert("Erreur: "+e.message)}V(!1)}},eb=async()=>{V(!0),J(null);try{let e="filters"===c?{skuQuery:p,createdMin:x,createdMax:m,country:y,tag:v,statuses:S}:{paste:!0},t=await l("/notifications/send",{method:"POST",body:{subject:q,body:A,orders:ec,filter_criteria:e}});J(t),t.success&&d().then(e=>e.success&&es(e.campaigns||[]))}catch(e){J({success:!1,error:e.message})}V(!1),en(!1)};return(0,i.jsxs)("div",{style:{flex:1,overflowY:"auto",padding:Q.xl,maxWidth:1100,margin:"0 auto",width:"100%",fontFamily:G,color:n.text},children:[(0,i.jsxs)("div",{style:{display:"flex",gap:Q.sm,marginBottom:Q.xl,alignItems:"center"},children:[tx.map((e,t)=>(0,i.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:Q.sm},children:[(0,i.jsx)("div",{style:{padding:"6px 14px",borderRadius:$.pill,fontSize:11,fontWeight:600,background:s===e.id?n.gold:"transparent",color:s===e.id?"#fff":n.textMuted,border:"1px solid ".concat(s===e.id?n.gold:n.border)},children:e.label}),t<tx.length-1&&(0,i.jsx)("span",{style:{color:n.textDim,fontSize:12},children:"→"})]},e.id)),(0,i.jsxs)("button",{onClick:()=>ed(e=>!e),style:{...ei(!1,n),marginLeft:"auto"},children:[(0,i.jsx)(ex.dashboard,{size:13,color:n.textMuted})," Historique"]})]}),ea&&(0,i.jsxs)("div",{style:{...er(n),marginBottom:Q.xl},children:[(0,i.jsx)("div",{style:{fontSize:13,fontWeight:600,marginBottom:Q.md},children:"Derni\xe8res campagnes"}),0===el.length?(0,i.jsx)("div",{style:{fontSize:12,color:n.textMuted},children:"Aucune campagne pour l'instant."}):(0,i.jsxs)("table",{style:{width:"100%",fontSize:12,borderCollapse:"collapse"},children:[(0,i.jsx)("thead",{children:(0,i.jsxs)("tr",{style:{color:n.textDim,textAlign:"left"},children:[(0,i.jsx)("th",{style:{padding:"6px 0",fontWeight:600},children:"Date"}),(0,i.jsx)("th",{style:{padding:"6px 0",fontWeight:600},children:"Sujet"}),(0,i.jsx)("th",{style:{padding:"6px 0",fontWeight:600},children:"Destinataires"}),(0,i.jsx)("th",{style:{padding:"6px 0",fontWeight:600},children:"Envoy\xe9s"}),(0,i.jsx)("th",{style:{padding:"6px 0",fontWeight:600},children:"\xc9checs"}),(0,i.jsx)("th",{style:{padding:"6px 0",fontWeight:600},children:"Statut"})]})}),(0,i.jsx)("tbody",{children:el.map(e=>(0,i.jsxs)("tr",{style:{borderTop:"1px solid ".concat(n.border)},children:[(0,i.jsx)("td",{style:{padding:"8px 0",color:n.textMuted,fontFamily:K,fontSize:11},children:new Date(e.created_at).toLocaleString("fr-FR")}),(0,i.jsx)("td",{style:{padding:"8px 0"},children:e.subject}),(0,i.jsx)("td",{style:{padding:"8px 0",fontFamily:K},children:e.recipient_count}),(0,i.jsx)("td",{style:{padding:"8px 0",fontFamily:K,color:n.green},children:e.sent_count}),(0,i.jsx)("td",{style:{padding:"8px 0",fontFamily:K,color:e.failed_count>0?n.red:n.textDim},children:e.failed_count}),(0,i.jsx)("td",{style:{padding:"8px 0",fontSize:10,color:"sent"===e.status?n.green:"partial_failed"===e.status?n.orange:n.textMuted},children:e.status})]},e.id))})]})]}),"select"===s&&(0,i.jsxs)("div",{children:[(0,i.jsxs)("div",{style:{display:"flex",gap:Q.sm,marginBottom:Q.md},children:[(0,i.jsx)("button",{onClick:()=>u("filters"),style:eo("filters"===c,n),children:"Filtres"}),(0,i.jsx)("button",{onClick:()=>u("paste"),style:eo("paste"===c,n),children:"Coller des num\xe9ros"})]}),"filters"===c?(0,i.jsxs)("div",{style:{...er(n),display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(200px, 1fr))",gap:Q.md,marginBottom:Q.md},children:[(0,i.jsxs)("div",{children:[(0,i.jsx)("label",{style:et(n),children:"SKU ou produit"}),(0,i.jsx)("input",{style:Z(n),value:p,onChange:e=>g(e.target.value),placeholder:"ex: nappe-lin"})]}),(0,i.jsxs)("div",{children:[(0,i.jsx)("label",{style:et(n),children:"Tag commande"}
1),(0,i.jsx)("input",{style:Z(n),value:v,onChange:e=>j(e.target.value),placeholder:"ex: vp"})]}),(0,i.jsxs)("div",{children:[(0,i.jsx)("label",{style:et(n),children:"Pays (ISO)"}),(0,i.jsx)("input",{style:Z(n),value:y,onChange:e=>b(e.target.value),placeholder:"FR",maxLength:2})]}),(0,i.jsxs)("div",{children:[(0,i.jsx)("label",{style:et(n),children:"Command\xe9e apr\xe8s"}),(0,i.jsx)("input",{type:"date",style:Z(n),value:x,onChange:e=>h(e.target.value)})]}),(0,i.jsxs)("div",{children:[(0,i.jsx)("label",{style:et(n),children:"Command\xe9e avant"}),(0,i.jsx)("input",{type:"date",style:Z(n),value:m,onChange:e=>f(e.target.value)})]}),(0,i.jsxs)("div",{style:{gridColumn:"1 / -1"},children:[(0,i.jsx)("label",{style:et(n),children:"Statut de livraison"}),(0,i.jsx)("div",{style:{display:"flex",flexWrap:"wrap",gap:6},children:th.map(e=>(0,i.jsx)("button",{type:"button",onClick:()=>{var t;return t=e.value,void k(e=>e.includes(t)?e.filter(e=>e!==t):[...e,t])},style:eo(S.includes(e.value),n),children:e.label},e.value))})]})]}):(0,i.jsxs)("div",{style:{...er(n),marginBottom:Q.md},children:[(0,i.jsx)("label",{style:et(n),children:"Num\xe9ros de commande (s\xe9par\xe9s par espaces, virgules ou retours ligne)"}),(0,i.jsx)("textarea",{style:{...ee(n),minHeight:120,fontFamily:K},value:w,onChange:e=>C(e.target.value),placeholder:"#1234 SUD-1235 1236, 1237"})]}),(0,i.jsxs)("div",{style:{display:"flex",gap:Q.sm,alignItems:"center",marginBottom:Q.md},children:[(0,i.jsx)("button",{onClick:ep,disabled:R,style:{...ei(!0,n),padding:"8px 18px"},children:R?"Recherche...":"Charger les commandes"}),M&&(0,i.jsx)("span",{style:{color:n.red,fontSize:12},children:M})]}),_.length>0&&(0,i.jsxs)("div",{style:er(n),children:[(0,i.jsxs)("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:Q.md},children:[(0,i.jsxs)("div",{style:{fontSize:12,color:n.textMuted},children:[(0,i.jsx)("strong",{style:{color:n.text},children:T.size})," / ",_.length," commandes \xb7 ",(0,i.jsx)("strong",{style:{color:n.text},children:eu})," destinataire(s) unique(s)"]}),(0,i.jsxs)("div",{style:{display:"flex",gap:Q.sm},children:[(0,i.jsx)("button",{onClick:()=>{T.size===_.length?D(new Set):D(new Set(_.map(e=>e.id)))},style:ei(!1,n),children:T.size===_.length?"Tout d\xe9s\xe9lectionner":"Tout s\xe9lectionner"}),(0,i.jsx)("button",{onClick:em,disabled:!T.size,style:{...ei(!0,n),opacity:T.size?1:.5},children:"Continuer →"})]})]}),(0,i.jsx)("div",{style:{maxHeight:500,overflowY:"auto",border:"1px solid ".concat(n.border),borderRadius:$.md},children:(0,i.jsxs)("table",{style:{width:"100%",fontSize:12,borderCollapse:"collapse"},children:[(0,i.jsx)("thead",{style:{position:"sticky",top:0,background:n.surface,zIndex:1},children:(0,i.jsxs)("tr",{style:{color:n.textDim,textAlign:"left"},children:[(0,i.jsx)("th",{style:{padding:10,width:36}}),(0,i.jsx)("th",{style:{padding:10,fontWeight:600},children:"Commande"}),(0,i.jsx)("th",{style:{padding:10,fontWeight:600},children:"Client"}),(0,i.jsx)("th",{style:{padding:10,fontWeight:600},children:"Articles"}),(0,i.jsx)("th",{style:{padding:10,fontWeight:600},children:"Statut"}),(0,i.jsx)("th",{style:{padding:10,fontWeight:600},children:"Date"})]})}),(0,i.jsx)("tbody",{children:_.map(e=>{var t;let r=T.has(e.id);return(0,i.jsxs)("tr",{onClick:()=>eh(e.id),style:{borderTop:"1px solid ".concat(n.border),background:r?n.goldBg:"transparent",cursor:"pointer"},children:[(0,i.jsx)("td",{style:{padding:10},children:(0,i.jsx)("input",{type:"checkbox",checked:r,onChange:()=>eh(e.id),onClick:e=>e.stopPropagation()})}),(0,i.jsxs)("td",{style:{padding:10,fontWeight:600},children:[e.name,e.recently_notified&&(0,i.jsx)("span",{title:"D\xe9j\xe0 notifi\xe9 dans les 14 derniers jours",style:{marginLeft:6,fontSize:9,padding:"2px 6px",borderRadius:$.pill,background:"".concat(n.orange,"20"),color:n.orange},children:"d\xe9j\xe0 notifi\xe9"})]}),(0,i.jsxs)("td",{style:{padding:10,color:n.textMuted},children:[(0,i.jsx)("div",{children:[e.customer.first_name,e.customer.last_name].filter(Boolean).join(" ")||"—"}),(0,i.jsx)("div",{style:{fontSize:10,fontFamily:K,color:n.textDim},children:e.customer.email})]}
1),(0,i.jsxs)("td",{style:{padding:10,color:n.textMuted,fontSize:11},children:[e.items.slice(0,2).map((e,t)=>(0,i.jsxs)("div",{children:[e.title,e.variant?" (".concat(e.variant,")"):""," \xd7 ",e.qty]},t)),e.items.length>2&&(0,i.jsxs)("div",{style:{color:n.textDim},children:["+ ",e.items.length-2]})]}),(0,i.jsx)("td",{style:{padding:10,fontSize:10},children:(0,i.jsx)("span",{style:{padding:"2px 6px",borderRadius:$.sm,background:n.surfaceAlt,color:n.textMuted},children:(null==(t=th.find(t=>t.value===e.delivery_status))?void 0:t.label)||e.delivery_status})}),(0,i.jsx)("td",{style:{padding:10,color:n.textDim,fontFamily:K,fontSize:10},children:new Date(e.created_at).toLocaleDateString("fr-FR")})]},e.id)})})]})})]}),!R&&0===_.length&&!M&&(0,i.jsx)(eg,{icon:(0,i.jsx)(ex.proactive,{size:36,color:n.textDim}),title:"Lance une recherche",description:"Filtre par SKU/date/tag/pays ou colle une liste de num\xe9ros de commande.",t:n})]}),"compose"===s&&(0,i.jsxs)("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:Q.lg},children:[(0,i.jsx)("div",{children:(0,i.jsxs)("div",{style:er(n),children:[(0,i.jsxs)("div",{style:{marginBottom:Q.md},children:[(0,i.jsx)("label",{style:et(n),children:"Sujet"}),(0,i.jsx)("input",{style:Z(n),value:q,onChange:e=>L(e.target.value)})]}),(0,i.jsxs)("div",{children:[(0,i.jsx)("label",{style:et(n),children:"Corps du message"}),(0,i.jsx)("textarea",{style:{...ee(n),minHeight:280},value:A,onChange:e=>F(e.target.value)}),(0,i.jsxs)("div",{style:{fontSize:10,color:n.textDim,marginTop:6,lineHeight:1.5},children:["Le bonjour personnalis\xe9 et la signature sont ajout\xe9s automatiquement.",(0,i.jsx)("br",{}),"La liste des commandes du client est ins\xe9r\xe9e automatiquement (ou placez ",(0,i.jsx)("code",{style:{fontFamily:K,background:n.surfaceAlt,padding:"0 4px",borderRadius:3},children:"{{order_list}}"})," \xe0 l'endroit voulu)."]})]}),(0,i.jsxs)("div",{style:{display:"flex",gap:Q.sm,marginTop:Q.md},children:[(0,i.jsx)("button",{onClick:()=>a("select"),style:ei(!1,n),children:"← Retour"}),(0,i.jsx)("button",{onClick:ef,style:ei(!1,n),children:"Rafra\xeechir l'aper\xe7u"}),(0,i.jsx)("button",{onClick:()=>a("send"),style:{...ei(!0,n),marginLeft:"auto"},children:"Continuer →"})]})]})}),(0,i.jsx)("div",{children:(0,i.jsxs)("div",{style:er(n),children:[(0,i.jsxs)("div",{style:{fontSize:11,color:n.textDim,marginBottom:Q.sm},children:["Aper\xe7u (1er destinataire",(null==E||null==(t=E.preview)?void 0:t.recipient)?" : ".concat(E.preview.recipient):"",")"]}),P?(0,i.jsx)("div",{style:{fontSize:12,color:n.textMuted},children:"Chargement..."}):(null==E?void 0:E.error)?(0,i.jsx)("div",{style:{color:n.red,fontSize:12},children:E.error}):(null==E?void 0:E.preview)?(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)("div",{style:{fontSize:12,fontWeight:600,marginBottom:Q.sm,padding:Q.sm,background:n.surfaceAlt,borderRadius:$.sm},children:E.preview.subject}),(0,i.jsx)("iframe",{srcDoc:E.preview.html,style:{width:"100%",height:520,border:"1px solid ".concat(n.border),borderRadius:$.md,background:"#fff"},title:"Aper\xe7u email"})]}):null]})})]}),"send"===s&&(0,i.jsxs)("div",{style:er(n),children:[(0,i.jsx)("div",{style:{fontSize:14,fontWeight:600,marginBottom:Q.md},children:"R\xe9capitulatif"}),(0,i.jsxs)("div",{style:{display:"grid",gridTemplateColumns:"repeat(3, 1fr)",gap:Q.md,marginBottom:Q.lg},children:[(0,i.jsx)(tb,{label:"Commandes",value:ec.length,T:n}),(0,i.jsx)(tb,{label:"Destinataires uniques",value:eu,T:n}),(0,i.jsx)(tb,{label:"Sujet",value:q,T:n,small:!0})]}),!Y&&(0,i.jsxs)(i.Fragment,{children:[(0,i.jsxs)("div",{style:{display:"flex",gap:Q.sm,alignItems:"center",marginBottom:Q.md,padding:Q.md,background:n.surfaceAlt,borderRadius:$.md},children:[(0,i.jsx)("label",{style:{fontSize:11,color:n.textMuted,whiteSpace:"nowrap"},children:"Envoi test \xe0 :"}),(0,i.jsx)("input",{style:{...Z(n),flex:1},value:U,onChange:e=>N(e.target.value),placeholder:"[email protected]"}),(0,i.jsx)("button",{onClick:ey,disabled:!U||H,style:ei(!1,n),children:H?"...":"Envoyer test"})]}),(0,i.jsxs)("div",{style:{display:"flex",gap:Q.sm},children:[(0,i.jsx)("button",{onClick:()=>a("compose"),style:ei(!1,n),children:"← Retour"}),(0,i.jsx)("button",{onClick:()=>en(!0),disabled:H||!ec.length,style:{...ei(!0,n),marginLeft:"auto",padding:"8px 20px"},children:H?"Envoi en cours...":"Envoyer \xe0 ".concat(eu," destinataire(s)")})]})]}),Y&&(0,i.jsxs)("div",{style:{padding:Q.lg,borderRadius:$.md,background:Y.success?"".concat(n.green,"10"):"".concat(n.red,"10"),border:"1px solid ".concat(Y.success?n.green:n.red,"30")},children:[(0,i.jsx)("div",{style:{fontSize:14,fontWeight:600,marginBottom:Q.sm,color:Y.success?n.green:n.red},children:Y.success?"Campagne envoy\xe9e":"Erreur"}),Y.success?(0,i.jsxs)("div",{style:{fontSize:12,color:n.textMuted,lineHeight:1.6},children:[Y.sent," envoy\xe9(s)",(0,i.jsx)("br",{}),Y.failed>0&&(0,i.jsxs)("span",{style:{color:n.red},children:[Y.failed," \xe9chec(s)"]})]}):(0,i.jsx)("div",{style:{fontSize:12,color:n.red},children:Y.error}),(0,i.jsx)("button",{onClick:()=>{a("select"),z([]),D(new Set),J(null),L("Suivi de votre commande Sudist"),F(tf),B(null)},style:{...ei(!0,n),marginTop:Q.md},children:"Nouvelle campagne"})]})]}),X&&(0,i.jsx)("div",{style:{position:"fixed",inset:0,background:"rgba(0,0,0,0.5)",display:"flex",alignItems:"center",justifyContent:"center",zIndex:100},onClick:()=>en(!1),children:(0,i.jsxs)("div",{onClick:e=>e.stopPropagation(),style:{...er(n),maxWidth:420,padding:Q.xl},children:[(0,i.jsx)("div",{style:{fontSize:15,fontWeight:600,marginBottom:Q.md},children:"Confirmer l'envoi"}),(0,i.jsxs)("div",{style:{fontSize:13,color:n.textMuted,lineHeight:1.6,marginBottom:Q.lg},children:["Vous allez envoyer un email \xe0 ",(0,i.jsxs)("strong",{style:{color:n.text},children:[eu," client(s)"]})," couvrant ",(0,i.jsxs)("strong",{style:{color:n.text},children:[ec.length," commande(s)"]}),". Cette action est irr\xe9versible."]}),(0,i.jsxs)("div",{style:{display:"flex",gap:Q.sm,justifyContent:"flex-end"},children:[(0,i.jsx)("button",{onClick:()=>en(!1),style:ei(!1,n),children:"Annuler"}),(0,i.jsx)("button",{onClick:eb,disabled:H,style:ei(!0,n),children:H?"Envoi...":"Confirmer l'envoi"})]})]})})]})}function tb(e){let{label:t,value:n,T:r,small:l}=e;return(0,i.jsxs)("div",{style:{padding:Q.md,background:r.surfaceAlt,borderRadius:$.md}
1,children:[(0,i.jsx)("div",{style:{fontSize:10,color:r.textDim,textTransform:"uppercase",letterSpacing:"0.06em",marginBottom:4},children:t}),(0,i.jsx)("div",{style:{fontSize:l?12:22,fontWeight:l?500:700,color:r.text,fontFamily:l?G:K,lineHeight:1.3,wordBreak:"break-word"},children:n||"—"})]})}var tv=n(6278),tj=n.n(tv);let tS=e=>Math.round(100*e)/100;function tk(e,t){return!t||t<=0?0:Math.round(Number(e)/Number(t)*100)}function tw(){return{enrolled:0,active:0,completed:0,cancelled:0,sent:0,dry_run:0,failed:0,skipped:0,opened:0,clicked:0,orders:0,revenue:0,steps:0,eligible:{total:null,pending:null,population:null,window:null,window_pending:null,matched:null,excluded:null,at:null},next_run:{due:0,new:0,total:0,paused:!1},emails:{sent:0,remaining:0,potential:0,failed:0,skipped:0,dry_run:0},customers:{enrolled:0,in_flow:0,reached:0,opened:0,clicked:0,converted:0,revenue:0},rates:{enrolled:0,reached:0,open:0,click:0,conversion:0},by_email:{}}}let tC={branded:"Gabarit",html:"HTML",design:"Builder"},t_=e=>Number(e||0).toLocaleString("fr-FR"),tz=function(e,t){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"".concat(t,"s");return Number(e)>1?n:t},tT={eligible:"Cible compl\xe8te du flux dans la base : clients qui remplissent les crit\xe8res du d\xe9clencheur sans tenir compte du calendrier (ex. cadence : tous les clients \xe0 2 commandes et plus), hors d\xe9sinscrits, plus les clients d\xe9j\xe0 inscrits. Snapshot pris par le cron quotidien.",next_run:"Emails qui partiront au prochain passage du cron : inscrits dont l'\xe9tape est due sous 24 h + nouveaux clients entr\xe9s dans la fen\xeatre du d\xe9clencheur si le premier email part sans d\xe9lai. Dans la limite du cap quotidien, tous flux confondus.",sent:"Total d'emails r\xe9ellement envoy\xe9s sur cette s\xe9quence (toutes \xe9tapes).",opened:"Emails ouverts (pixel : sous-estim\xe9, Apple Mail et les bloqueurs d'images ne remontent pas). % des emails re\xe7us.",clicked:"Emails dont un lien a \xe9t\xe9 cliqu\xe9 (redirection sign\xe9e). % des emails re\xe7us.",converted:"Commandes attribu\xe9es : commande dans la fen\xeatre d'attribution apr\xe8s un clic. % des emails cliqu\xe9s."};function tD(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return(null==e?void 0:e.paramFields)?e.paramFields.filter(e=>"boolean"!==e.type&&void 0!==t[e.key]&&""!==t[e.key]&&0!==t[e.key]&&null!==t[e.key]).map(e=>"".concat(e.label.replace(/\s*\(.*?\)\s*/g,"").toLowerCase()," : ").concat(t[e.key])).join(" \xb7 "):""}function tR(e){let{stats:t,t:n=J,compact:r=!1}=e,l=function(e){var t,n;let i=e||tw(),r=i.sent||0,l=i.opened||0,o=i.clicked||0,s=i.orders||0,a=i.next_run||{};return[{key:"eligible",label:"\xc9ligibles",unit:"clients",value:null!=(n=null==(t=i.eligible)?void 0:t.population)?n:null,ofPrev:null,pctOf:null},{key:"next_run",label:"Prochain cron",unit:"emails",value:a.paused?0:a.total||0,ofPrev:null,pctOf:null,paused:!!a.paused},{key:"sent",label:"Re\xe7u",unit:"emails",value:r,ofPrev:null,pctOf:null},{key:"opened",label:"Ouvert",unit:"emails",value:l,ofPrev:r?tk(l,r):null,pctOf:"re\xe7us"},{key:"clicked",label:"Cliqu\xe9",unit:"emails",value:o,ofPrev:r?tk(o,r):null,pctOf:"re\xe7us"},{key:"converted",label:"Converti",unit:"commandes",value:s,ofPrev:o?tk(s,o):null,pctOf:"cliqu\xe9s",revenue:i.revenue||0}]}(t),o=Math.max(0,...l.map(e=>e.value||0)),s=null===l[0].value;return(0,i.jsxs)("div",{style:{display:"flex",flexDirection:"column",gap:r?4:6},children:[l.map(e=>{var t;let l=(t=e.key,({eligible:n.textDim,next_run:n.gold,sent:n.green,opened:n.blue,clicked:n.purple,converted:n.text})[t]||n.textDim),s=null===e.value,a=s||!o?0:Math.max(1.5*(e.value>0),e.value/o*100),d="converted"===e.key||"next_run"===e.key;return(0,i.jsxs)("div",{title:tT[e.key],style:{display:"grid",gridTemplateColumns:"92px 1fr 56px 78px",alignItems:"center",gap:Q.sm,fontSize:12},children:[(0,i.jsx)("span",{style:{color:d?n.text:n.textMuted,fontWeight:d?600:500,whiteSpace:"nowrap"},children:e.label}),(0,i.jsx)("div",{style:{height:r?8:10,borderRadius:$.pill,background:n.surfaceAlt,overflow:"hidden",position:"relative"},children:s?(0,i.jsx)("div",{style:{position:"absolute",inset:0,backgroundImage:"repeating-linear-gradient(135deg, ".concat(n.border," 0 4px, transparent 4px 8px)")}}):(0,i.jsx)("div",{style:{width:"".concat(a,"%"),height:"100%",background:l,borderRadius:$.pill,transition:"width .4s cubic-bezier(0.16,1,0.3,1)"}})}),(0,i.jsx)("span",{style:{fontFamily:K,fontVariantNumeric:"tabular-nums",textAlign:"right",color:s?n.textDim:n.text,fontWeight:600},children:s?"—":t_(e.value)}),(0,i.jsx)("span",{style:{fontFamily:K,fontSize:11,color:n.textDim,textAlign:"right",whiteSpace:"nowrap"},children:e.paused?"en pause":"converted"===e.key&&e.value>0?"".concat(t_(e.revenue)," €"):null!==e.ofPrev?"".concat(e.ofPrev," %"):"clients"===e.unit?"clients":""})]},e.key)}),s&&(0,i.jsx)("div",{style:{fontSize:11,color:n.textDim,marginTop:2},children:"\xc9ligibles : calcul\xe9s au prochain passage du cron (ou \xab Recalculer \xbb)."})]})}function tI(e){let{stats:t,t:n=J}=e,r=(null==t?void 0:t.emails)||{},l=r.sent||0,o=r.remaining||0,s=r.failed||0,a=r.potential||0,d=l+o+s,c=d+a,u=e=>c?"".concat(e/c*100,"%"):"0%",p=d?Math.round(l/d*100):0;return(0,i.jsxs)("div",{children:[(0,i.jsxs)("div",{style:{display:"flex",alignItems:"baseline",gap:Q.sm,marginBottom:6},children:[(0,i.jsx)("span",{style:{fontFamily:K,fontSize:18,fontWeight:600,color:n.text,fontVariantNumeric:"tabular-nums"},children:t_(l)}),(0,i.jsxs)("span",{style:{fontSize:12,color:n.textMuted},children:[d?"sur ".concat(t_(d)," ").concat(tz(d,"email")," planifi\xe9").concat(d>1?"s":""):"email envoy\xe9",d>0&&(0,i.jsxs)("span",{style:{color:n.textDim},children:[" \xb7 ",p," %"]})]})]}),(0,i.jsxs)("div",{title:"".concat(t_(l)," envoy\xe9s \xb7 ").concat(t_(o)," \xe0 envoyer \xb7 ").concat(t_(s)," \xe9checs \xb7 ").concat(t_(
1a)," potentiels"),style:{display:"flex",height:10,borderRadius:$.pill,overflow:"hidden",background:n.surfaceAlt},children:[l>0&&(0,i.jsx)("div",{style:{width:u(l),background:n.green}}),s>0&&(0,i.jsx)("div",{style:{width:u(s),background:n.red}}),o>0&&(0,i.jsx)("div",{style:{width:u(o),background:"".concat(n.gold,"66")}}),a>0&&(0,i.jsx)("div",{style:{width:u(a),backgroundImage:"repeating-linear-gradient(135deg, ".concat(n.border," 0 4px, transparent 4px 8px)")}})]}),(0,i.jsxs)("div",{style:{display:"flex",flexWrap:"wrap",gap:"4px ".concat(Q.md,"px"),marginTop:6,fontSize:11,color:n.textMuted},children:[(0,i.jsxs)(tM,{color:n.green,t:n,children:[t_(l)," envoy\xe9",l>1?"s":""]}),(0,i.jsxs)(tM,{color:"".concat(n.gold,"66"),t:n,children:[t_(o)," \xe0 envoyer"]}),s>0&&(0,i.jsxs)(tM,{color:n.red,t:n,children:[t_(s)," \xe9chec",s>1?"s":""]}),a>0&&(0,i.jsxs)(tM,{hatched:!0,t:n,title:"Cible pas encore inscrite \xd7 nombre d'emails de la s\xe9quence",children:["≈ ",t_(a)," potentiels"]})]})]})}function tM(e){let{color:t,hatched:n,t:r,title:l,children:o}=e;return(0,i.jsxs)("span",{title:l,style:{display:"inline-flex",alignItems:"center",gap:5,whiteSpace:"nowrap"},children:[(0,i.jsx)("span",{style:{width:8,height:8,borderRadius:2,flexShrink:0,background:n?"transparent":t,border:n?"1px dashed ".concat(r.textDim):"none"}}),o]})}function tW(e){let{steps:t=[],stats:n,t:r=J,capDays:l=0}=e,o=0,s=t.filter(e=>!1!==e.active);return s.length?(0,i.jsx)("div",{style:{display:"flex",gap:Q.sm,overflowX:"auto",paddingBottom:2},children:s.map((e,t)=>{var s;let a=Number(e.delay_days)||0;o+=a;let d=(null==n||null==(s=n.by_email)?void 0:s[e.id])||{},c=t>0&&l>0&&a<l,u=d.sent?Math.round(d.opened/d.sent*100):null;return(0,i.jsxs)("div",{title:"".concat(e.subject||"(sans sujet)").concat(c?"\n⚠ D\xe9lai ".concat(a," j plus court que le cap de fr\xe9quence (").concat(l," j)"):""),style:{flex:"1 0 120px",minWidth:120,maxWidth:200,padding:"".concat(Q.sm,"px ").concat(Q.md,"px"),borderRadius:$.md,background:r.surfaceAlt,display:"flex",flexDirection:"column",gap:3},children:[(0,i.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:Q.sm},children:[(0,i.jsxs)("span",{style:{fontFamily:K,fontSize:10.5,fontWeight:700,color:r.gold,background:r.goldBg,padding:"1px 6px",borderRadius:$.pill},children:["J",o?"+".concat(o):"0"]}),(0,i.jsx)("span",{style:{fontSize:10.5,color:r.textDim},children:tC[e.format]||e.format}),c&&(0,i.jsx)("span",{style:{color:r.orange,fontSize:11},children:"⚠"})]}),(0,i.jsx)("div",{style:{fontSize:12,color:r.text,whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:e.subject||"(sans sujet)"}),(0,i.jsxs)("div",{style:{display:"flex",gap:Q.sm,fontSize:11,fontFamily:K,color:r.textMuted,flexWrap:"wrap"},children:[(0,i.jsxs)("span",{style:{color:d.sent?r.green:r.textDim},children:[t_(d.sent)," env."]}),null!==u&&(0,i.jsxs)("span",{style:{color:r.blue},children:[u," % ouv."]}),d.pending>0&&(0,i.jsxs)("span",{style:{color:r.gold},children:[t_(d.pending)," \xe0 venir"]}),d.failed>0&&(0,i.jsxs)("span",{style:{color:r.red},children:[d.failed," \xe9ch."]})]})]},e.id||t)})}):(0,i.jsx)("div",{style:{fontSize:12,color:r.textDim,fontStyle:"italic"},children:"Aucun email actif dans cette s\xe9quence."})}function tq(e){var t,n;let{seq:r,trig:l,t:o=J,busy:s,capDays:a=0,onOpen:d,onToggle:c,onDelete:u,onOrders:p,onHistory:g,onRefresh:x}=e,h=r.stats||{},m=r.marketing_emails||[],f=m.filter(e=>!1!==e.active).length,y=tD(l,r.trigger_params),b=r.active?f?{label:"Active",color:o.green,bg:o.greenSoft||"".concat(o.green,"1f")}:{label:"Sans email",color:o.orange,bg:o.orangeSoft||"".concat(o.orange,"1f")}:{label:"En pause",color:o.textMuted,bg:o.surfaceAlt},v=(null==(t=h.eligible)?void 0:t.at)?new Date(h.eligible.at):null,j=s==="toggle-".concat(r.id),S=s==="elig-".concat(r.id)||"elig"===s,k={fontSize:10.5,letterSpacing:"0.1em",textTransform:"uppercase",color:o.textDim,fontWeight:700,marginBottom:Q.sm};return(0,i.jsxs)("div",{style:{...er(o),padding:0,overflow:"hidden",opacity:r.active?1:.88},children:[(0,i.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:Q.md,padding:"".concat(Q.md,"px ").concat(Q.lg,"px"),borderBottom:"1px solid ".concat(o.borderLight),flexWrap:"wrap"},children:[(0,i.jsx)("button",{onClick:()=>c(r),disabled:j,title:r.active?"Mettre en pause":"Activer",style:{width:36,height:20,borderRadius:10,border:"none",cursor:j?"wait":"pointer",flexShrink:0,background:r.active?o.gold:o.border,position:"relative",transition:"background .15s"},children:(0,i.jsx)("span",{style:{position:"absolute",top:2,left:r.active?18:2,width:16,height:16,borderRadius:8,background:"#fff",transition:"left .15s"}})}),(0,i.jsxs)("div",{style:{flex:1,minWidth:200},children:[(0,i.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:Q.sm,flexWrap:"wrap"},children:[(0,i.jsx)("button",{onClick:()=>d(r),title:"Ouvrir dans l'\xe9diteur",style:{background:"none",border:"none",padding:0,cursor:"pointer",fontFamily:G,color:o.text,fontWeight:600,fontSize:15,textAlign:"left",lineHeight:1.25},children:r.name}),(0,i.jsx)("span",{style:{fontSize:11,fontWeight:600,color:b.color,background:b.bg,padding:"1px 8px",borderRadius:$.pill},children:b.label})]}),(0,i.jsxs)("div",{style:{fontSize:12,color:o.textMuted,marginTop:2,whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},title:y||void 0,children:[(null==l?void 0:l.label)||r.trigger_type," \xb7 ",f," ",tz(f,"email"),y&&(0,i.jsxs)("span",{style:{color:o.textDim},children:[" \xb7 ",y]}),(null==(n=r.trigger_params)?void 0:n.suggest_products)&&(0,i.jsx)("span",{style:{color:o.purple},children:" \xb7 ✦ suggestions IA"})]})]}),(0,i.jsxs)("div",{style:{display:"flex",gap:Q.sm,marginLeft:"auto",flexWrap:"wrap"},children:[h.orders>0&&(0,i.jsxs)("button",{onClick:()=>p(r),title:"Voir les commandes attribu\xe9es",style:{...ei(!1,o),color:o.gold,fontFamily:K,fontWeight:600,whiteSpace:"nowrap"},children:[t_(h.revenue)," € \xb7 ",h.orders," ",tz(h.orders,"vente")]}),(0,i.jsx)("button",{style:ei(!1,o),onClick:()=>g(r),title:"Historique des envois de cette s\xe9quence",children:"Historique"}),(0,i.jsx)("button",{style:ei(!1,o),onClick:()=>d(r),children:"\xc9diter"}),(0,i.jsx)("button",{style:{...ei(!1,o),color:o.red},disabled:s==="del-".concat(r.id),onClick:()=>u(r),children:"Suppr."})]})]}),(0,i.jsxs)("div",{style:{display:"flex",flexWrap:"wrap",gap:Q.xl,padding:"".concat(Q.lg,"px ").concat(Q.lg,"px")},children:[(0,i.jsxs)("div",{style:{flex:"1 1 320px",minWidth:260},children:[(0,i.jsxs)("div",{style:{display:"flex",alignItems:"baseline",justifyContent:"space-between",gap:Q.sm},children:[(0,i.jsx)("div",{style:k,children:"Cible et r\xe9sultats"}),(0,i.jsxs)("div",{style:{fontSize:11,color:o.textDim,whiteSpace:"nowrap"}
1,children:[v?"\xe9ligibilit\xe9 du ".concat(v.toLocaleString("fr-FR",{day:"2-digit",month:"2-digit",hour:"2-digit",minute:"2-digit"})):"",x&&(0,i.jsx)("button",{onClick:()=>x(r),disabled:S,style:{background:"none",border:"none",padding:"0 0 0 6px",cursor:S?"wait":"pointer",color:o.gold,fontFamily:G,fontSize:11,textDecoration:"underline dotted"},children:S?"calcul…":"recalculer"})]})]}),(0,i.jsx)(tR,{stats:h,t:o})]}),(0,i.jsxs)("div",{style:{flex:"1 1 260px",minWidth:240,display:"flex",flexDirection:"column",gap:Q.lg},children:[(0,i.jsxs)("div",{children:[(0,i.jsx)("div",{style:k,children:"Emails"}),(0,i.jsx)(tI,{stats:h,t:o})]}),(0,i.jsxs)("div",{children:[(0,i.jsx)("div",{style:k,children:"\xc9tapes"}),(0,i.jsx)(tW,{steps:m,stats:h,t:o,capDays:a})]})]})]})]})}function tL(e){let{sequences:t,t:n=J,dailyCap:r=0}=e,l=function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[],t={sequences:e.length,active:0,eligible:0,eligibleKnown:!1,enrolled:0,nextRun:0,remaining:0,potential:0,sent:0,reached:0,opened:0,clicked:0,converted:0,orders:0,revenue:0};for(let u of e){var n,i,r,l,o,s,a,d,c;let e=(null==u?void 0:u.stats)||tw();(null==u?void 0:u.active)&&t.active++;let p=null!=(c=null==(n=e.eligible)?void 0:n.population)?c:null==(i=e.eligible)?void 0:i.total;null!=p&&(t.eligible+=p,t.eligibleKnown=!0),t.enrolled+=(null==(r=e.customers)?void 0:r.enrolled)||0,t.nextRun+=(null==(l=e.next_run)?void 0:l.total)||0,t.remaining+=(null==(o=e.emails)?void 0:o.remaining)||0,t.potential+=(null==(s=e.emails)?void 0:s.potential)||0,t.sent+=e.sent||0,t.reached+=(null==(a=e.customers)?void 0:a.reached)||0,t.opened+=e.opened||0,t.clicked+=e.clicked||0,t.converted+=(null==(d=e.customers)?void 0:d.converted)||0,t.orders+=e.orders||0,t.revenue=tS(t.revenue+(e.revenue||0))}return t.openRate=tk(t.opened,t.sent),t.clickRate=tk(t.clicked,t.sent),t.conversionRate=tk(t.orders,t.clicked),t}(t),o=r>0&&l.nextRun>r;return(0,i.jsxs)("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(150px, 1fr))",gap:Q.md,marginBottom:Q.xl},children:[(0,i.jsx)(eu,{t:n,label:"Clients \xe9ligibles",value:l.eligibleKnown?t_(l.eligible):"—",sub:l.eligibleKnown?"".concat(t_(l.enrolled)," d\xe9j\xe0 inscrits \xb7 ").concat(l.active," ").concat(tz(l.active,"s\xe9quence")," active").concat(l.active>1?"s":""," sur ").concat(l.sequences):"calcul\xe9s au prochain cron"}),(0,i.jsx)(eu,{t:n,label:"Prochain cron",value:t_(o?r:l.nextRun),color:n.gold,sub:o?"".concat(t_(l.nextRun)," emails dus, cap quotidien ").concat(t_(r)," \xb7 ").concat(t_(l.remaining)," \xe0 envoyer au total"):"emails dus \xb7 ".concat(t_(l.remaining)," \xe0 envoyer au total")}),(0,i.jsx)(eu,{t:n,label:"Taux d'ouverture",value:l.sent?"".concat(l.openRate," %"):"—",color:n.blue,sub:l.sent?"".concat(t_(l.opened)," sur ").concat(t_(l.sent)," emails re\xe7us \xb7 ").concat(l.clickRate," % de clics"):"aucun email r\xe9el envoy\xe9"}),(0,i.jsx)(eu,{t:n,label:"CA attribu\xe9",value:"".concat(t_(l.revenue)," €"),color:n.green,sub:l.orders?"".concat(t_(l.orders)," ").concat(tz(l.orders,"commande")," \xb7 ").concat(l.conversionRate," % des emails cliqu\xe9s"):"aucune vente attribu\xe9e"})]})}let tA=tj()(()=>n.e(4193).then(n.bind(n,4193)),{loadableGenerated:{webpack:()=>[null]},ssr:!1}),tF=[{name:"derniere_commande_date",label:"Date derni\xe8re commande"},{name:"derniere_commande_produits",label:"Produits derni\xe8re commande"},{name:"intervalle_moyen",label:"Rythme de rachat"},{name:"cadeau_an_dernier",label:"Cadeau de l'an dernier"},{name:"produit_demande",label:"Produit demand\xe9 en chat"},{name:"produits_suggeres",label:"Produits sugg\xe9r\xe9s (IA)"},{name:"code_promo",label:"Code promo (r\xe9glages)"},{name:"lien_desinscription",label:"Lien de d\xe9sinscription"}],tE=Object.fromEntries(tF.map(e=>[e.name,{name:e.label,value:"{{".concat(e.name,"}}")}])),tB={branded:"Gabarit Sudist",html:"HTML libre",design:"Builder visuel"},tP={sent:{label:"Envoy\xe9",color:"#3fb27f"},dry_run:{label:"Simul\xe9",color:"#5b9bd5"},skipped:{label:"Bloqu\xe9",color:"#d5a021"},failed:{label:"\xc9chec",color:"#d9534f"}},tO={suppression:"d\xe9sinscrit (lien)",consent:"d\xe9sinscrit (Shopify)",frequency_cap:"cap de fr\xe9quence",open_ticket:"ticket SAV ouvert",daily_cap:"cap quotidien"},tU=()=>({subject:"",format:"branded",title:"",hero_image_url:"",bottom_image_url:"",cta_label:"",cta_url:"",body:"",html:"",design:null,delay_days:0,active:!0}),tN="sav-mkt-flowmap";function tH(e){let{sequences:t,triggers:n,t:l,onOpen:o,onToggle:s,busy:a,capDays:d=0}=e,[c,u]=(0,r.useState)(!0);(0,r.useEffect)(()=>{try{"open"===localStorage.getItem(tN)&&u(!1)}catch(e){}},[]);let p=er(l),g=t.filter(e=>e.active).length,x=t.reduce((e,t)=>
1e+(t.marketing_emails||[]).length,0),h=t.reduce((e,t)=>{var n;return e+((null==(n=t.stats)?void 0:n.active)||0)},0),m={borderRadius:$.md,padding:"".concat(Q.sm,"px ").concat(Q.md,"px"),fontSize:12,lineHeight:1.35,display:"flex",flexDirection:"column",gap:2,flexShrink:0},f=(e,t,n)=>(0,i.jsxs)("div",{title:n||void 0,style:{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",minWidth:56,flexShrink:0,alignSelf:"stretch"},children:[(0,i.jsxs)("span",{style:{fontFamily:K,fontSize:10.5,color:n?l.orange:t?l.textDim:l.gold,marginBottom:3,whiteSpace:"nowrap"},children:[e,n?" ⚠":""]}),(0,i.jsx)("div",{style:{position:"relative",width:"100%",height:1,background:t?l.border:l.goldMuted},children:(0,i.jsx)("span",{style:{position:"absolute",right:-1,top:-3,width:0,height:0,borderTop:"3.5px solid transparent",borderBottom:"3.5px solid transparent",borderLeft:"6px solid ".concat(t?l.border:l.goldMuted)}})})]});return(0,i.jsxs)("div",{style:{...p,padding:0,marginBottom:Q.xl,overflow:"hidden"},children:[(0,i.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:Q.md,padding:"".concat(Q.md,"px ").concat(Q.lg,"px"),borderBottom:c?"none":"1px solid ".concat(l.borderLight)},children:[(0,i.jsxs)("div",{children:[(0,i.jsx)("div",{style:{fontSize:13,fontWeight:700},children:"Carte des flux"}),(0,i.jsx)("div",{style:{fontSize:11.5,color:l.textMuted,marginTop:1},children:"Toutes les animations d'un coup d'œil : d\xe9clencheur, emails, d\xe9lais et parcours clients."})]}),(0,i.jsxs)("div",{style:{marginLeft:"auto",display:"flex",gap:Q.lg,fontSize:12,fontFamily:K,color:l.textMuted,flexWrap:"wrap",justifyContent:"flex-end"},children:[(0,i.jsxs)("span",{children:[(0,i.jsx)("b",{style:{color:l.text},children:g}),"/",t.length," actives"]}),(0,i.jsxs)("span",{children:[(0,i.jsx)("b",{style:{color:l.text},children:x})," emails"]}),(0,i.jsxs)("span",{title:"Clients actuellement dans un parcours",children:[(0,i.jsx)("b",{style:{color:l.gold},children:h})," en parcours"]})]}),(0,i.jsx)("button",{style:{...ei(!1,l),padding:"3px 9px"},onClick:()=>u(e=>{try{localStorage.setItem(tN,e?"open":"closed")}catch(e){}return!e}),children:c?"Afficher":"R\xe9duire"})]}),!c&&(0,i.jsxs)("div",{style:{display:"flex",flexDirection:"column"},children:[t.map((e,t)=>{var r;let c=n[e.trigger_type],u=e.marketing_emails||[],p=e.stats||{},g=!e.active,x=tD(c,e.trigger_params),h=0;return(0,i.jsxs)("div",{style:{display:"flex",alignItems:"stretch",borderTop:t?"1px solid ".concat(l.borderLight):"none",opacity:g?.62:1},children:[(0,i.jsxs)("div",{style:{width:190,flexShrink:0,padding:"".concat(Q.md,"px ").concat(Q.lg,"px"),borderRight:"1px solid ".concat(l.borderLight),display:"flex",flexDirection:"column",gap:Q.xs,justifyContent:"center",background:l.surfaceAlt},children:[(0,i.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:Q.sm},children:[(0,i.jsx)("span",{title:e.active?"Active":"Inactive",style:{width:8,height:8,borderRadius:4,flexShrink:0,background:e.active?l.green:l.textDim}}),(0,i.jsx)("button",{onClick:()=>o(e),title:"Ouvrir dans l'\xe9diteur",style:{background:"none",border:"none",padding:0,cursor:"pointer",fontFamily:G,color:l.text,fontWeight:600,fontSize:13,textAlign:"left",lineHeight:1.3},children:e.name})]}),(0,i.jsxs)("div",{style:{fontSize:11,color:l.textMuted,fontFamily:K},children:[p.enrolled||0," inscrit",(p.enrolled||0)>1?"s":"",p.active>0&&(0,i.jsxs)("span",{style:{color:l.gold},children:[" \xb7 ",p.active," en cours"]})]}),(0,i.jsx)("button",{onClick:()=>s(e),disabled:a==="toggle-".concat(e.id),style:{...ei(!1,l),padding:"2px 8px",fontSize:11,alignSelf:"flex-start",cursor:a==="toggle-".concat(e.id)?"wait":"pointer"},children:e.active?"Mettre en pause":"Activer"})]}),(0,i.jsxs)("div",{style:{flex:1,minWidth:0,overflowX:"auto",display:"flex",alignItems:"center",gap:0,padding:"".concat(Q.md,"px ").concat(Q.lg,"px")},children:[(0,i.jsxs)("div",{title:x||void 0,style:{...m,maxWidth:210,border:"1.5px solid ".concat(g?l.border:l.gold),background:l.goldBg},children:[(0,i.jsx)("div",{style:{fontSize:10,letterSpacing:"0.12em",textTransform:"uppercase",color:l.gold,fontWeight:700},children:"D\xe9clencheur"}),(0,i.jsx)("div",{style:{fontWeight:600,color:l.text,whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:(null==c?void 0:c.label)||e.trigger_type}),x&&(0,i.jsx)("div",{style:{fontSize:10.5,color:l.textMuted,whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:x}),(null==(r=e.trigger_params)?void 0:r.suggest_products)&&(0,i.jsx)("div",{style:{fontSize:10.5,color:l.purple},children:"✦ suggestions IA"})]}),0===u.length&&(0,i.jsxs)(i.Fragment,{children:[f("",!0),(0,i.jsx)("div",{style:{...m,border:"1px dashed ".concat(l.border),color:l.textMuted,fontStyle:"italic"},children:"Aucun email"})]}),u.map((e,t)=>{var n;h+=Number(e.delay_days)||0;let r=(null==(n=p.by_email)?void 0:n[e.id])||{},o=!1===e.active,s=Number(e.delay_days)||0,a=t>0&&d>0&&s<d;return(0,i.jsxs)("div",{style:{display:"flex",alignItems:"center"},children:[f(0===t?h?"+".concat(h," j"):"imm\xe9diat":"+".concat(s," j"),g||o,a?"D\xe9lai ".concat(s," j plus court que le cap de fr\xe9quence 
1(").concat(d," j) : l'email partira en r\xe9alit\xe9 ").concat(d," j apr\xe8s le pr\xe9c\xe9dent."):""),(0,i.jsxs)("div",{title:e.subject,style:{...m,width:200,background:l.surface,border:"1px ".concat(o?"dashed":"solid"," ").concat(o?l.border:l.borderLight),opacity:o?.6:1},children:[(0,i.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:Q.sm},children:[(0,i.jsxs)("span",{style:{fontFamily:K,fontSize:10.5,fontWeight:700,color:l.gold,background:l.goldBg,padding:"1px 6px",borderRadius:$.pill},children:["J",h?"+".concat(h):"0"]}),(0,i.jsxs)("span",{style:{fontSize:10.5,color:l.textDim},children:["Email ",t+1,o?" \xb7 inactif":""]})]}),(0,i.jsx)("div",{style:{color:l.text,whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:e.subject||"(sans sujet)"}),(0,i.jsxs)("div",{style:{display:"flex",gap:Q.sm,fontSize:10.5,color:l.textMuted,fontFamily:K},children:[(0,i.jsx)("span",{children:tB[e.format]||e.format}),r.pending>0&&(0,i.jsxs)("span",{style:{color:l.gold},children:[r.pending," \xe0 venir"]})]})]})]},e.id||t)}),f("",g),(0,i.jsxs)("div",{style:{...m,border:"1px solid ".concat(l.borderLight),background:l.surfaceAlt,minWidth:120},children:[(0,i.jsx)("div",{style:{fontSize:10,letterSpacing:"0.12em",textTransform:"uppercase",color:l.textMuted,fontWeight:700},children:"Sortie"}),(0,i.jsxs)("div",{style:{fontFamily:K,fontSize:11,color:l.textMuted},children:[p.completed||0," termin\xe9",(p.completed||0)>1?"s":""]}),p.orders>0?(0,i.jsxs)("div",{style:{fontFamily:K,fontSize:11,color:l.gold,fontWeight:600},children:[p.orders," vente",p.orders>1?"s":""," \xb7 ",p.revenue,"€"]}):(0,i.jsx)("div",{style:{fontFamily:K,fontSize:11,color:l.textDim},children:"0 vente"})]})]})]},e.id)}),(0,i.jsxs)("div",{style:{display:"flex",gap:Q.lg,flexWrap:"wrap",padding:"".concat(Q.sm,"px ").concat(Q.lg,"px"),borderTop:"1px solid ".concat(l.borderLight),fontSize:11,color:l.textDim},children:[(0,i.jsxs)("span",{children:[(0,i.jsx)("span",{style:{display:"inline-block",width:7,height:7,borderRadius:4,background:l.green,marginRight:5}}),"active"]}),(0,i.jsxs)("span",{children:[(0,i.jsx)("span",{style:{display:"inline-block",width:7,height:7,borderRadius:4,background:l.textDim,marginRight:5}}),"en pause (gris\xe9e)"]}),(0,i.jsx)("span",{children:"J+n = jours apr\xe8s l'entr\xe9e du client dans le flux"}),(0,i.jsx)("span",{children:"\xab \xe0 venir \xbb = clients inscrits qui attendent encore cet email"}),d>0&&(0,i.jsxs)("span",{style:{color:l.orange},children:["⚠ = d\xe9lai plus court que le cap de fr\xe9quence (",d," j), l'email partira \xe0 +",d," j"]})]})]})]})}function tV(e){var t,n,o,s,a,d,c,u,p,g;let{t:x,active:h}=e,m=x||J,[f,y]=(0,r.useState)("sequences"),[b,z]=(0,r.useState)(!1),[T,D]=(0,r.useState)([]),[R,I]=(0,r.useState)({}),[M,W]=(0,r.useState)([]),[q,L]=(0,r.useState)(null),[A,F]=(0,r.useState)(null),[E,B]=(0,r.useState)(null),[P,O]=(0,r.useState)(null),[U,N]=(0,r.useState)(null),[H,V]=(0,r.useState)(""),[Y,X]=(0,r.useState)(""),[en,el]=(0,r.useState)(""),[es,ea]=(0,r.useState)(!1),[ed,ec]=(0,r.useState)(null),eu=(0,r.useRef)(null),[ep,ex]=(0,r.useState)(null),[eh,em]=(0,r.useState)(!1),[ef,ey]=(0,r.useState)(null),[eb,ev]=(0,r.useState)(null),[ej,eS]=(0,r.useState)(null),[ek,ew]=(0,r.useState)(null),[eC,e_]=(0,r.useState)(""),[ez,eT]=(0,r.useState)(null),[eD,eR]=(0,r.useState)(null),[eI,eM]=(0,r.useState)([]),eW=(0,r.useRef)(null),eq=(0,r.useCallback)((e,t)=>{ec({kind:e,msg:t}),clearTimeout(eu.current),eu.current=setTimeout(()=>ec(null),5e3)},[]),eL=(0,r.useCallback)(async()=>{z(!0);try{let[e,t,n,i]=await Promise.all([l("/marketing/sequences"),l("/marketing/presets"),w(),l("/marketing/config")]);e.success&&(D(e.sequences),I(e.triggers||{})),t.success&&W(t.presets),n.success&&L(n),i.success&&(F(i.settings),B(i.settings))}catch(e){console.error("[Marketing] load:",e),eq("err",e.message)}z(!1)},[eq]);(0,r.useEffect)(()=>{h&&eL()},[h,eL]);let eA=(0,r.useCallback)(async function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"",t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"";try{let n={limit:150};e&&(n.status=e),t&&(n.sequence_id=t);let i=await S(n);i.success&&O(i)}catch(e){eq("err",e.message)}},[eq]);(0,r.useEffect)(()=>{h&&"history"===f&&eA(Y,en)},[h,f,Y,en,eA]);let eF=(0,r.useCallback)(async function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"";try{let t=await k(e?{sequence_id:e,limit:200}:{limit:200});t.success&&N(t)}catch(e){eq("err",e.message)}},[eq]);(0,r.useEffect)(()=>{h&&"orders"===f&&eF(H)},[h,f,H,eF]);let eE=async()=>{ey("sync"),ev({processed:0,profiles:0});try{for(let e=0;e<60;e++){let e=await C();if(!e.success)throw Error(e.error||"Erreur sync");if(ev(t=>({processed:((null==t?void 0:t.processed)||0)+(e.processed||0),profiles:e.profiles})),e.done)break}let e=await w();e.success&&L(e),eq("ok","Synchronisation des profils termin\xe9e")}catch(e){eq("err",e.message)}ev(null),ey(null)},eB=async()=>{ey("simulate");try{let e=await _(!0);if(!e.success)throw Error(e.error||"Erreur simulation");ea(!1),eS(e),await eL()}catch(e){eq("err",e.message)}ey(null)},eP=async()=>
1{if(confirm("Envoyer les emails dus MAINTENANT ?\n\nC'est un envoi r\xe9el (pas une simulation) : les clients recevront leurs emails, dans la limite du cap quotidien. Les garde-fous (d\xe9sinscrits, tickets ouverts, cap de fr\xe9quence) s'appliquent.")){ey("sendnow");try{var e;let t=await _(!1);if(!t.success)throw Error(t.error||"Erreur d'envoi");ea(!1),eS(t),await eL(),eq("ok","".concat(null!=(e=t.sent)?e:0," email(s) envoy\xe9(s)"))}catch(e){eq("err",e.message)}ey(null)}},eO=async function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null;ey(e?"elig-".concat(e.id):"elig");try{let t,n=await (t=null==e?void 0:e.id,l("/marketing/eligibility",{method:"POST",body:t?{sequence_id:t}:{}}));if(!n.success)throw Error(n.error||"Erreur de calcul");await eL(),eq("ok",e?"\xc9ligibilit\xe9 recalcul\xe9e pour \xab ".concat(e.name," \xbb"):"\xc9ligibilit\xe9 recalcul\xe9e (".concat(n.refreshed," s\xe9quence").concat(n.refreshed>1?"s":"",")"))}catch(e){eq("err",e.message)}ey(null)},eU=async e=>{ey("preset-".concat(e));try{let t=await l("/marketing/presets",{method:"POST",body:{key:e}});if(!t.success)throw Error(t.error);eq("ok","S\xe9quence cr\xe9\xe9e (inactive) — relisez les emails puis activez-la"),await eL()}catch(e){eq("err",e.message)}ey(null)},eN=async e=>{ey("toggle-".concat(e.id));try{let t=await v(e.id,{active:!e.active});if(!t.success)throw Error(t.error);await eL()}catch(e){eq("err",e.message)}ey(null)},eH=async e=>{if(confirm("Supprimer la s\xe9quence \xab ".concat(e.name," \xbb et tout son historique d'inscriptions ?"))){ey("del-".concat(e.id));try{let t,n=await (t=e.id,l("/marketing/sequences?id=".concat(encodeURIComponent(t)),{method:"DELETE"}));if(!n.success)throw Error(n.error);eq("ok","S\xe9quence supprim\xe9e"),await eL()}catch(e){eq("err",e.message)}ey(null)}},eV=e=>{if(e){var t;ex({id:e.id,name:e.name,trigger_type:e.trigger_type,trigger_params:{...(null==(t=R[e.trigger_type])?void 0:t.defaultParams)||{},...e.trigger_params||{}},active:e.active,emails:(e.marketing_emails||[]).map(e=>({subject:e.subject,format:e.format,body:e.body||"",html:e.html||"",title:e.title||"",hero_image_url:e.hero_image_url||"",bottom_image_url:e.bottom_image_url||"",cta_label:e.cta_label||"",cta_url:e.cta_url||"",design:e.design||null,delay_days:e.delay_days,active:e.active}))})}else ex({name:"",trigger_type:"",trigger_params:{},active:!1,emails:[tU()]});y("editor")},eG=async()=>{if(!ep.name.trim())return eq("err","Donnez un nom \xe0 la s\xe9quence");if(!ep.trigger_type)return eq("err","Choisissez un d\xe9clencheur");if(!ep.emails.length||ep.emails.some(e=>!e.subject.trim()))return eq("err","Chaque email doit avoir un sujet");em(!0);try{let e={name:ep.name,trigger_type:ep.trigger_type,trigger_params:ep.trigger_params,active:ep.active,emails:ep.emails},t=ep.id?await v(ep.id,e):await l("/marketing/sequences",{method:"POST",body:e});if(!t.success)throw Error(t.error);eq("ok","S\xe9quence enregistr\xe9e"),y("sequences"),ex(null),await eL()}catch(e){eq("err",e.message)}em(!1)},eK=(e,t)=>ex(n=>({...n,emails:n.emails.map((n,i)=>i===e?{...n,...t}:n)})),eY=async e=>{ey("preview");try{let t,n=await (t={subject:e.subject,format:e.format,body:e.body,html:e.html,title:e.title,hero_image_url:e.hero_image_url,bottom_image_url:e.bottom_image_url,cta_label:e.cta_label,cta_url:e.cta_url},l("/marketing/preview",{method:"POST",body:t}));if(!n.success)throw Error(n.error);ew({html:n.html,subject:n.subject,profile:n.profile})}catch(e){eq("err",e.message)}ey(null)},eJ=async e=>{if(!eC.trim()||!eC.includes("@"))return eq("err","Adresse de test invalide");ey("test");try{let t,n=await (t={to:eC.trim(),subject:e.subject,format:e.format,body:e.body,html:e.html,title:e.title,hero_image_url:e.hero_image_url,bottom_image_url:e.bottom_image_url,cta_label:e.cta_label,cta_url:e.cta_url},l("/marketing/test-send",{method:"POST",body:t}));if(!n.success)throw Error(n.error);eq("ok","Email de test envoy\xe9 \xe0 ".concat(eC.trim()))}catch(e){eq("err",e.message)}ey(null)},eX=async()=>{if(!ez)return;let e=ep.emails[ez.index];eT(e=>({...e,loading:!0}));try{let t,n=await (t={action:("branded"===e.format?e.body:e.html)?"improve":"generate",brief:ez.brief,currentSubject:e.subject,currentBody:"branded"===e.format?e.body:e.html,format:"branded"===e.format?"branded":"html"},l("/marketing/assist",{method:"POST",body:t}));if(!n.success)throw Error(n.error);"branded"===e.format?eK(ez.index,{subject:n.subject,body:n.body}):eK(ez.index,{subject:n.subject,html:n.body}
1),eT(null),eq("ok","Email r\xe9dig\xe9 par l'IA — relisez avant d'enregistrer")}catch(e){eq("err",e.message),eT(e=>e?{...e,loading:!1}:null)}};(0,r.useEffect)(()=>{null!==eD&&j().then(e=>{e.success&&eM(e.templates)}).catch(()=>{})},[eD]);let eQ=async()=>{ey("settings");try{let e=await l("/marketing/config",{method:"PATCH",body:E});if(!e.success)throw Error(e.error);F(e.settings),B(e.settings),eq("ok","R\xe9glages enregistr\xe9s")}catch(e){eq("err",e.message)}ey(null)},e$=er(m),eZ={fontFamily:G,fontSize:13,fontWeight:700,textTransform:"uppercase",letterSpacing:"0.08em",color:m.textMuted,margin:"".concat(Q.xxl,"px 0 ").concat(Q.md,"px")},e0=(e,t)=>({display:"inline-block",padding:"2px 8px",borderRadius:$.pill,fontSize:11,fontWeight:600,color:e,background:t||"".concat(e,"22")}),e1=e=>{let{on:t,onClick:n,disabled:r}=e;return(0,i.jsx)("button",{onClick:n,disabled:r,style:{width:40,height:22,borderRadius:11,border:"none",cursor:r?"wait":"pointer",background:t?m.gold:m.border,position:"relative",transition:"background .15s",flexShrink:0},children:(0,i.jsx)("span",{style:{position:"absolute",top:2,left:t?20:2,width:18,height:18,borderRadius:9,background:"#fff",transition:"left .15s"}})})};return h?(0,i.jsxs)("div",{style:{height:"100%",overflowY:"auto",fontFamily:G,color:m.text},children:[(0,i.jsxs)("div",{style:{maxWidth:980,margin:"0 auto",padding:"".concat(Q.xxxl,"px ").concat(Q.xl,"px 80px")},children:[(0,i.jsx)("div",{style:{fontSize:11,letterSpacing:"0.2em",textTransform:"uppercase",color:m.gold,marginBottom:Q.xs},children:"S\xe9quences automatiques"}),(0,i.jsx)("h1",{style:{fontFamily:G,fontSize:34,fontWeight:500,margin:"0 0 ".concat(Q.lg,"px")},children:"Marketing."}),ed&&(0,i.jsx)("div",{style:{padding:"".concat(Q.md,"px ").concat(Q.lg,"px"),borderRadius:$.md,marginBottom:Q.lg,fontSize:13,background:"ok"===ed.kind?"#3fb27f22":"#d9534f22",color:"ok"===ed.kind?"#3fb27f":"#d9534f",border:"1px solid ".concat("ok"===ed.kind?"#3fb27f55":"#d9534f55")},children:ed.msg}),A&&"editor"!==f&&(0,i.jsxs)("div",{style:{...e$,padding:"".concat(Q.md,"px ").concat(Q.lg,"px"),marginBottom:Q.xl,display:"flex",flexWrap:"wrap",alignItems:"center",gap:"".concat(Q.sm,"px ").concat(Q.xl,"px")},children:[(0,i.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:Q.sm,minWidth:160},children:[(0,i.jsx)("span",{style:{width:8,height:8,borderRadius:4,flexShrink:0,background:A.enabled?m.green:m.red}}),(0,i.jsx)("span",{style:{fontSize:13,fontWeight:600},children:A.enabled?"Syst\xe8me actif":"Syst\xe8me d\xe9sactiv\xe9"}),A.enabled&&A.dryRun&&(0,i.jsx)("span",{style:e0(m.blue),children:"simulation"})]}),(0,i.jsxs)("div",{style:{display:"flex",flexWrap:"wrap",gap:"2px ".concat(Q.lg,"px"),fontSize:12,color:m.textMuted,flex:1,minWidth:240},children:[(0,i.jsxs)("span",{title:(null==q||null==(t=q.state)?void 0:t.backfill_done)===!1?"Backfill des commandes incomplet : relancez la synchronisation":"Profils clients synchronis\xe9s depuis Shopify",children:[(0,i.jsx)("b",{style:{color:m.text,fontFamily:K},children:(null==q?void 0:q.profiles)?q.profiles.toLocaleString("fr-FR"):0})," profils",(null==q||null==(n=q.state)?void 0:n.backfill_done)===!1&&(0,i.jsx)("span",{style:{color:m.orange},children:" \xb7 backfill incomplet"}),(null==q||null==(o=q.state)?void 0:o.last_run_at)&&(0,i.jsxs)("span",{style:{color:m.textDim},children:[" \xb7 sync ",new Date(q.state.last_run_at).toLocaleDateString("fr-FR")]})]}),(0,i.jsxs)("span",{title:"Le cron Vercel passe une fois par jour, vers 9h UTC (heure non garantie sur le plan Hobby)",children:[(null==q||null==(s=q.last_send)?void 0:s.at)?(0,i.jsxs)(i.Fragment,{children:["dernier envoi ",(0,i.jsx)("b",{style:{color:m.text},children:new Date(q.last_send.at).toLocaleString("fr-FR",{dateStyle:"short",timeStyle:"short"})})," (",q.last_send.count," email",q.last_send.count>1?"s":"",")"]}):"aucun envoi r\xe9el pour l'instant",(0,i.jsxs)("span",{style:{color:m.textDim},children:[" \xb7 cron vers ",new Date(new Date().setUTCHours(9,0,0,0)).toLocaleTimeString("fr-FR",{hour:"2-digit",minute:"2-digit"})]})]})]}),(0,i.jsxs)("div",{style:{display:"flex",gap:Q.sm,flexWrap:"wrap",marginLeft:"auto"},children:[(0,i.jsx)("button",{style:ei(!1,m),disabled:"sync"===ef,onClick:eE,children:eb?"Sync… ".concat(eb.processed," commandes"):"Synchroniser"}),(0,i.jsx)("button",{style:ei(!1,m),disabled:"elig"===ef,onClick:()=>eO(null),title:"Recalcule les clients \xe9ligibles de chaque s\xe9quence 
1(le cron le fait chaque jour)",children:"elig"===ef?"Calcul…":"Recalculer l'\xe9ligibilit\xe9"}),(0,i.jsx)("button",{style:ei(!0,m),disabled:"simulate"===ef,onClick:eB,children:"simulate"===ef?"Simulation…":"Simuler le prochain run"}),A.enabled&&!A.dryRun&&(0,i.jsx)("button",{style:{...ei(!1,m),borderColor:m.red,color:m.red},disabled:"sendnow"===ef,onClick:eP,children:"sendnow"===ef?"Envoi en cours…":"Envoyer maintenant"})]})]}),"editor"!==f&&(0,i.jsx)("div",{style:{display:"flex",gap:Q.sm,marginBottom:Q.xl},children:[["sequences","S\xe9quences"],["history","Historique"],["orders","Commandes g\xe9n\xe9r\xe9es"],["settings","R\xe9glages"]].map(e=>{let[t,n]=e;return(0,i.jsx)("button",{style:eo(f===t,m),onClick:()=>y(t),children:n},t)})}),"sequences"===f&&(0,i.jsxs)(i.Fragment,{children:[T.length>0&&(0,i.jsx)(tL,{sequences:T,t:m,dailyCap:Number(null==A?void 0:A.dailySendCap)||0}),T.length>0&&(0,i.jsx)(tH,{sequences:T,triggers:R,t:m,busy:ef,capDays:Number(null==A?void 0:A.frequencyCapDays)||0,onOpen:eV,onToggle:eN}),(0,i.jsxs)("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",gap:Q.md},children:[(0,i.jsx)("div",{style:{...eZ,margin:"".concat(Q.sm,"px 0 ").concat(Q.md,"px")},children:"Mes s\xe9quences"}),(0,i.jsx)("button",{style:ei(!0,m),onClick:()=>eV(null),children:"+ Nouvelle s\xe9quence"})]}),b&&!T.length?(0,i.jsx)("div",{style:{color:m.textMuted,fontSize:13,padding:Q.xl},children:"Chargement…"}):T.length?(0,i.jsx)("div",{style:{display:"flex",flexDirection:"column",gap:Q.lg},children:[...T].sort((e,t)=>Number(t.active)-Number(e.active)||String(e.name).localeCompare(String(t.name),"fr")).map(e=>(0,i.jsx)(tq,{seq:e,trig:R[e.trigger_type],t:m,busy:ef,capDays:Number(null==A?void 0:A.frequencyCapDays)||0,onOpen:eV,onToggle:eN,onDelete:eH,onRefresh:eO,onOrders:e=>{V(e.id),y("orders")},onHistory:e=>{el(e.id),X(""),y("history")}},e.id))}):(0,i.jsx)(eg,{t:m,title:"Aucune s\xe9quence",description:"Installez un preset ci-dessous ou cr\xe9ez votre premi\xe8re s\xe9quence."}),M.some(e=>!e.installed)&&(0,i.jsxs)(i.Fragment,{children:[(0,i.jsxs)("div",{style:eZ,children:["Presets — ",M.filter(e=>!e.installed).length," use case",M.filter(e=>!e.installed).length>1?"s":""," pr\xeats \xe0 installer (cr\xe9\xe9s inactifs)"]}),(0,i.jsx)("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fill, minmax(280px, 1fr))",gap:Q.md},children:M.filter(e=>!e.installed).map(e=>(0,i.jsxs)("div",{style:{...e$,padding:Q.lg,display:"flex",flexDirection:"column",gap:Q.sm},children:[(0,i.jsx)("div",{style:{fontWeight:600,fontSize:13},children:e.name}),(0,i.jsx)("div",{style:{fontSize:12,color:m.textMuted,lineHeight:1.5,flex:1},children:e.description}),(0,i.jsx)("button",{style:{...ei(!1,m),alignSelf:"flex-start"},disabled:ef==="preset-".concat(e.key),onClick:()=>eU(e.key),children:ef==="preset-".concat(e.key)?"Installation…":"Installer"})]},e.key))})]})]}),"history"===f&&(0,i.jsxs)(i.Fragment,{children:[P&&(0,i.jsxs)("div",{style:{display:"flex",flexDirection:"column",gap:Q.sm,marginBottom:Q.lg},children:[(0,i.jsxs)("div",{style:{display:"flex",gap:Q.sm,flexWrap:"wrap",alignItems:"center"},children:[[["","Tout"],["sent","Envoy\xe9s (".concat(P.counts.sent,")")],["dry_run","Simul\xe9s (".concat(P.counts.dry_run,")")],["skipped","Bloqu\xe9s (".concat(P.counts.skipped,")")],["failed","\xc9checs (".concat(P.counts.failed,")")]].map(e=>{let[t,n]=e;return(0,i.jsx)("button",{style:eo(Y===t,m),onClick:()=>X(t),children:n},t)}),(0,i.jsxs)("span",{style:{marginLeft:"auto",fontSize:12,color:m.textMuted},children:[P.counts.suppressed," d\xe9sinscrit",P.counts.suppressed>1?"s":""]})]}),T.length>0&&(0,i.jsxs)("div",{style:{display:"flex",gap:Q.sm,flexWrap:"wrap",alignItems:"center"},children:[(0,i.jsx)("span",{style:{fontSize:11,color:m.textDim,textTransform:"uppercase",letterSpacing:"0.08em",marginRight:Q.xs},children:"S\xe9quence"}),(0,i.jsx)("button",{style:eo(""===en,m),onClick:()=>el(""),children:"Toutes"}),T.map(e=>(0,i.jsx)("button",{style:eo(en===e.id,m),onClick:()=>el(e.id),children:e.name},e.id))]})]}),P?P.sends.length?(0,i.jsxs)("div",{style:{...e$,overflow:"hidden"},children:[P.sends.map((e,t)=>{let n=tP[e.status]||{},r=new Date(e.sent_at).toDateString(),l=0===t||new Date(P.sends[t-1].sent_at).toDateString()!==r;return(0,i.jsxs)("div",{children:[l&&(0,i.jsx)("div",{style:{padding:"".concat(Q.sm,"px ").concat(Q.lg,"px"),background:m.surfaceAlt,borderTop:t?"1px solid ".concat(m.borderLight):"none",fontSize:11,fontWeight:700,letterSpacing:"0.08em",textTransform:"uppercase",color:m.textMuted},children:new Date(e.sent_at).toLocaleDateString("fr-FR",{weekday:"long",day:"numeric",month:"long"})}),(0,i.jsxs)("div",{style:{display:"flex",gap:Q.lg,alignItems:"center",padding:"".concat(Q.md,"px ").concat(Q.lg,"px"),borderTop:"1px solid ".concat(m.borderLight),fontSize:13,flexWrap:"wrap"},children:[(0,i.jsx)("span",{style:{...e0(n.color),minWidth:58,textAlign:"center"},children:n.label||e.status}),"sent"===e.status&&e.clicked_at&&(0,i.jsx)("span",{title:"Clic le ".concat(new Date(e.clicked_at).toLocaleStr
1ing("fr-FR")).concat(e.click_count>1?" (".concat(e.click_count," fois)"):"").concat(e.clicked_url?" → ".concat(e.clicked_url):""),style:e0(m.gold),children:"clic"}),"sent"===e.status&&e.opened_at&&(0,i.jsx)("span",{title:"Ouvert le ".concat(new Date(e.opened_at).toLocaleString("fr-FR")).concat(e.open_count>1?" (".concat(e.open_count," fois)"):""),style:e0(m.blue),children:"ouvert"}),(0,i.jsx)("span",{style:{fontFamily:K,fontSize:12,color:m.textMuted,minWidth:44},children:new Date(e.sent_at).toLocaleTimeString("fr-FR",{hour:"2-digit",minute:"2-digit"})}),(0,i.jsx)("span",{style:{minWidth:180,overflow:"hidden",textOverflow:"ellipsis"},children:e.customer_email}),(0,i.jsxs)("span",{style:{flex:1,color:m.textMuted,fontSize:12,overflow:"hidden",textOverflow:"ellipsis"},children:[e.sequence_name&&!en&&(0,i.jsxs)("span",{style:{color:m.gold},children:[e.sequence_name," \xb7 "]}),"skipped"===e.status?tO[e.skip_reason]||e.skip_reason:"failed"===e.status?e.error:e.subject]})]})]},e.id)}),P.total>P.sends.length&&(0,i.jsxs)("div",{style:{padding:"".concat(Q.md,"px ").concat(Q.lg,"px"),fontSize:12,color:m.textMuted,borderTop:"1px solid ".concat(m.borderLight)},children:[P.sends.length," envois affich\xe9s sur ",P.total,"."]})]}):(0,i.jsx)(eg,{t:m,title:"Aucun envoi",description:"Lancez une simulation pour voir qui recevrait quoi."}):(0,i.jsx)("div",{style:{color:m.textMuted,fontSize:13},children:"Chargement…"})]}),"orders"===f&&(0,i.jsxs)(i.Fragment,{children:[U&&(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(160px, 1fr))",gap:Q.md,marginBottom:Q.lg},children:[["Commandes g\xe9n\xe9r\xe9es",U.totals.orders],["Chiffre d'affaires","".concat(U.totals.revenue.toLocaleString("fr-FR")," €")],["Panier moyen",U.totals.orders?"".concat(Math.round(U.totals.revenue/U.totals.orders)," €"):"0 €"]].map(e=>{let[t,n]=e;return(0,i.jsxs)("div",{style:{...e$,padding:Q.lg},children:[(0,i.jsx)("div",{style:{fontSize:11,textTransform:"uppercase",letterSpacing:"0.08em",color:m.textMuted},children:t}),(0,i.jsx)("div",{style:{fontFamily:K,fontSize:22,fontWeight:600,marginTop:4,color:m.gold},children:n})]},t)})}),(0,i.jsxs)("div",{style:{display:"flex",gap:Q.sm,marginBottom:Q.lg,flexWrap:"wrap"},children:[(0,i.jsxs)("button",{style:eo(""===H,m),onClick:()=>V(""),children:["Toutes (",U.totals.orders,")"]}),U.totals.by_sequence.map(e=>(0,i.jsxs)("button",{style:eo(H===e.sequence_id,m),onClick:()=>V(e.sequence_id||""),children:[e.sequence_name," (",e.orders," \xb7 ",e.revenue,"€)"]},e.sequence_id||"none"))]}),(0,i.jsxs)("div",{style:{fontSize:12,color:m.textMuted,marginBottom:Q.md},children:["Attribution sur clic : commande pass\xe9e dans les ",null!=(d=null==A?void 0:A.attributionWindowDays)?d:7," jours suivant un clic dans un email marketing (dernier clic). Le lien ouvre la commande dans Shopify."]})]}),U?U.orders.length?(0,i.jsxs)("div",{style:{...e$,overflow:"hidden"},children:[U.orders.map((e,t)=>{let n=e.email_sent_at?Math.round((new Date(e.ordered_at)-new Date(e.email_sent_at))/36e5):null,r=null===n?"":n<48?"".concat(n," h apr\xe8s l'email"):"".concat(Math.round(n/24)," j apr\xe8s l'email");return(0,i.jsxs)("div",{style:{display:"flex",gap:Q.lg,alignItems:"center",padding:"".concat(Q.md,"px ").concat(Q.lg,"px"),borderTop:t?"1px solid ".concat(m.borderLight):"none",fontSize:13,flexWrap:"wrap"},children:[(0,i.jsx)("span",{style:{fontFamily:K,fontSize:12,color:m.textMuted,minWidth:92},children:new Date(e.ordered_at).toLocaleString("fr-FR",{day:"2-digit",month:"2-digit",hour:"2-digit",minute:"2-digit"})}),e.admin_url?(0,i.jsxs)("a",{href:e.admin_url,target:"_blank",rel:"noreferrer",style:{fontFamily:K,fontWeight:600,color:m.gold,minWidth:96,textDecoration:"none"},children:[e.order_name||e.order_id," ↗"]}):(0,i.jsx)("span",{style:{fontFamily:K,fontWeight:600,minWidth:96},children:e.order_name||e.order_id}),(0,i.jsxs)("span",{style:{fontFamily:K,minWidth:64,textAlign:"right"},children:[Number(e.order_total).toLocaleString("fr-FR")," €"]}),(0,i.jsx)("span",{style:{minWidth:180,overflow:"hidden",textOverflow:"ellipsis"},children:e.customer_email}),(0,i.jsxs)("span",{style:{flex:1,color:m.textMuted,fontSize:12,overflow:"hidden",textOverflow:"ellipsis"},children:[e.sequence_name&&(0,i.jsxs)("span",{style:{color:m.gold},children:[e.sequence_name," \xb7 "]}),e.email_subject?"\xab ".concat(e.email_subject," \xbb"):"",r&&(0,i.jsxs)("span",{children:[" \xb7 ",r]})]})]},e.id)}),U.total>U.orders.length&&(0,i.jsxs)("div",{style:{padding:"".concat(Q.md,"px ").concat(Q.lg,"px"),fontSize:12,color:m.textMuted,borderTop:"1px solid ".concat(m.borderLight)},children:[U.orders.length," commandes affich\xe9es sur ",U.total,"."]})]}):(0,i.jsx)(eg,{t:m,title:"Aucune commande attribu\xe9e",description:"Les ventes apparaissent ici d\xe8s qu'un client commande apr\xe8s avoir re\xe7u un email de s\xe9quence."}):(0,i.jsx)("div",{style:{color:m.textMuted,fontSize:13},children:"Chargement…"})]}),"settings"===f&&E&&(0,i.jsx)("div",{style:{...e$,padding:Q.xl,maxWidth:620},children:(0,i.jsxs)("div",{style:{display:"flex",flexDirection:"column",gap:Q.xl},children:[(0,i.jsxs)("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:Q.lg},children:[(0,i.jsxs)("div",{children:[(0,i.jsx)("div",{style:{fontWeight:600,fontSize:14},children:"Activer le syst\xe8me"}),(0,i.jsx)("div",{style:{fontSize:12,color:m.textMuted,marginTop:2},children:"Tant que c'est d\xe9sactiv\xe9, le cron ne fait que rafra\xeechir les profils : aucune inscription, aucun envoi."})]}),(0,i.jsx)(e1,{on:E.enabled,onClick:()=>B(e=>({...e,enabled:!e.enabled}))})]}),(0,i.jsxs)("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:Q.lg},children:[(0,i.jsxs)("div",{children:[(0,i.jsx)("div",{style:{fontWeight:600,fontSize:14},children:"Mode simulation (dry-run)"}),(0,i.jsx)("div",{style:{fontSize:12,color:m.textMuted,marginTop:2},children:"Le pipeline tourne enti\xe8rement et logge \xab qui aurait re\xe7u quoi \xbb dans l'historique, sans rien envoyer. Recommand\xe9 avant la mise en production."})]}),(0,i.jsx)(e1,{on:E.dryRun,onClick:()=>B(e=>({...e,dryRun:!e.dryRun}))})]}
1),[["frequencyCapDays","Cap de fr\xe9quence (jours)","Un client ne re\xe7oit jamais 2 emails marketing \xe0 moins de N jours d'\xe9cart."],["dailySendCap","Cap quotidien d'envois","Plafond d'emails r\xe9els par jour (quota Gmail : rester prudent)."],["aiCallsPerRun","Budget IA par run","Appels Claude max par run (cross-sell, analyse chat)."],["attributionWindowDays","Fen\xeatre d'attribution (jours)","Une commande pass\xe9e dans les N jours apr\xe8s un clic dans un email marketing est compt\xe9e comme vente de la s\xe9quence."]].map(e=>{let[t,n,r]=e;return(0,i.jsxs)("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:Q.lg},children:[(0,i.jsxs)("div",{children:[(0,i.jsx)("div",{style:{fontWeight:600,fontSize:14},children:n}),(0,i.jsx)("div",{style:{fontSize:12,color:m.textMuted,marginTop:2},children:r})]}),(0,i.jsx)("input",{type:"number",value:E[t],style:{...Z(m),width:90,textAlign:"center"},onChange:e=>B(n=>({...n,[t]:e.target.value}))})]},t)}),(0,i.jsxs)("div",{children:[(0,i.jsx)("div",{style:{fontWeight:600,fontSize:14},children:"Logo des emails (URL https)"}),(0,i.jsx)("div",{style:{fontSize:12,color:m.textMuted,margin:"2px 0 8px"},children:"Affich\xe9 en t\xeate des emails brand\xe9s. Vide = \xab SUDIST \xbb en texte."}),(0,i.jsx)("input",{value:E.logoUrl||"",placeholder:"https://cdn.shopify.com/…/logo.png",style:{...Z(m),width:"100%"},onChange:e=>B(t=>({...t,logoUrl:e.target.value}))})]}),(0,i.jsxs)("div",{children:[(0,i.jsx)("div",{style:{fontWeight:600,fontSize:14},children:"Code promo des emails"}),(0,i.jsxs)("div",{style:{fontSize:12,color:m.textMuted,margin:"2px 0 8px"},children:["Code de r\xe9duction cr\xe9\xe9 dans Shopify (une utilisation par client), ins\xe9r\xe9 dans les emails via la variable ","{{code_promo}}",". Vide = variable vide."]}),(0,i.jsx)("input",{value:E.promoCode||"",placeholder:"AIOLI",style:{...Z(m),width:200,fontFamily:K,textTransform:"uppercase"},onChange:e=>B(t=>({...t,promoCode:e.target.value.toUpperCase()}))})]}),(0,i.jsx)("div",{children:(0,i.jsx)("button",{style:ei(!0,m),disabled:"settings"===ef,onClick:eQ,children:"settings"===ef?"Enregistrement…":"Enregistrer les r\xe9glages"})}),(0,i.jsx)("div",{style:{fontSize:11,color:m.textDim,lineHeight:1.6,borderTop:"1px solid ".concat(m.borderLight),paddingTop:Q.lg},children:"Cadre l\xe9gal (soft opt-in) : chaque email contient un lien de d\xe9sinscription sign\xe9 ; les d\xe9sinscrits (lien ou Shopify) ne sont jamais recontact\xe9s ; seuls des clients existants sont cibl\xe9s, pour des produits similaires. Les clients avec un ticket SAV ouvert sont automatiquement exclus."})]})}),"editor"===f&&ep&&(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)("button",{style:{...ei(!1,m),marginBottom:Q.lg},onClick:()=>{y("sequences"),ex(null)},children:"← Retour"}),(0,i.jsxs)("div",{style:{...e$,padding:Q.xl,marginBottom:Q.xl},children:[(0,i.jsxs)("div",{style:{display:"flex",gap:Q.lg,flexWrap:"wrap",alignItems:"flex-end"},children:[(0,i.jsxs)("div",{style:{flex:2,minWidth:240},children:[(0,i.jsx)("label",{style:et(m),children:"Nom de la s\xe9quence"}),(0,i.jsx)("input",{style:{...Z(m),width:"100%"},value:ep.name,placeholder:"Ex : Anniversaire cadeau de No\xebl",onChange:e=>ex(t=>({...t,name:e.target.value}))})]}),(0,i.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:Q.sm,paddingBottom:6},children:[(0,i.jsx)(e1,{on:ep.active,onClick:()=>ex(e=>({...e,active:!e.active}))}),(0,i.jsx)("span",{style:{fontSize:13},children:ep.active?"Active":"Inactive"})]})]}),(0,i.jsx)("div",{style:eZ,children:"D\xe9clencheur"}),(0,i.jsx)("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fill, minmax(260px, 1fr))",gap:Q.md},children:Object.entries(R).map(e=>{let[t,n]=e;return(0,i.jsxs)("button",{onClick:()=>ex(e=>({...e,trigger_type:t,trigger_params:{...n.defaultParams,...e.trigger_type===t?e.trigger_params:{}}})),style:{...e$,padding:Q.md,textAlign:"left",cursor:"pointer",fontFamily:G,border:"1.5px solid ".concat(ep.trigger_type===t?m.gold:m.border),background:ep.trigger_type===t?m.goldBg:m.surface},children:[(0,i.jsx)("div",{style:{fontWeight:600,fontSize:13,color:m.text},children:n.label}),(0,i.jsx)("div",{style:{fontSize:11.5,color:m.textMuted,marginTop:4,lineHeight:1.45},children:n.description})]},t)})}),ep.trigger_type&&((null==(a=R[ep.trigger_type])?void 0:a.paramFields)||[]).length>0&&(0,i.jsx)("div",{style:{display:"flex",gap:Q.lg,flexWrap:"wrap",marginTop:Q.lg},children:R[ep.trigger_type].paramFields.map(e=>{var t;return(0,i.jsxs)("div",{style:{minWidth:160},children:[(0,i.jsx)("label",{style:et(m),children:e.label}),"boolean"===e.type?(0,i.jsx)("div",{style:{paddingTop:4},children:(0,i.jsx)(e1,{on:!!ep.trigger_params[e.key],onClick:()=>ex(t=>({...t,trigger_params:{...t.trigger_params,[e.key]:!t.trigger_params[e.key]}}))})}):(0,i.jsx)("input",{type:"number"===e.type?"number":"text",style:{...Z(m),width:"number"===e.type?110:180},value:null!=(t=ep.trigger_params[e.key])?t:"",onChange:t=>ex(n=>({...n,trigger_params:{...n.trigger_params,[e.key]:"number"===e.type?Number(t.target.value):t.target.value}}))})]},e.key)})}),ep.trigger_type&&(0,i.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:Q.md,marginTop:Q.lg,padding:Q.md,background:m.goldBg,borderRadius:$.md},children:[(0,i.jsx)(e1,{on:!0===ep.trigger_params.suggest_products,onClick:()=>ex(e=>({...e,trigger_params:{...e.trigger_params,suggest_products:!e.trigger_params.suggest_products}}))}),(0,i.jsxs)("div",{children:[(0,i.jsx)("div",{style:{fontSize:13,fontWeight:600},children:"Suggestions produits IA"}),(0,i.jsxs)("div",{style:{fontSize:12,color:m.textMuted},children:["Claude choisit 2-3 produits compl\xe9mentaires pour chaque client (selon ses achats pass\xe9s) — ins\xe9r\xe9s via ","{{produits_suggeres}}"," ou ajout\xe9s automatiquement en fin d'email."]})]})]})]}),(0,i.jsxs)("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center"},children:[(0,i.jsx)("div",{style:eZ,children:"Emails de la s\xe9quence"}),(0,i.jsx)("input",{style:{...Z(m),width:220},placeholder:"Adresse pour les tests",value:eC,onChange:e=>e_(e.target.value)})]}),(0,i.jsx)("div",{style:{display:"flex",flexDirection:"column",gap:Q.lg},children:ep.emails.map((e,t)=>(0,i.jsxs)("div",{style:{...e$,padding:Q.xl},children:[(0,i.jsxs)("div",{style:{display:"flex",gap:Q.lg,flexWrap:"wrap",alignItems:"flex-end",marginBottom:Q.lg},children:[(0,i.jsxs)("span",{style:{...e0(m.gold,m.goldBg),alignSelf:"center"},children:["Email ",t+1]}),(0,i.jsxs)("div",{children:[(0,i.jsx)("label",{style:et(m),children:0===t?"D\xe9lai apr\xe8s d\xe9clenchement (jours)":"D\xe9lai apr\xe8s l'email pr\xe9c\xe9dent (jours)"}),(0,i.jsx)("input",{type:"number",min:"0",style:{...Z(m),width:90},value:e.delay_days,onChange:e=>eK(t,{delay_days:e.target.value})})]}),(0,i.jsxs)("div",{children:[(0,i.jsx)("label",{style:et(m),children:"Format"}),(0,i.jsx)("div",{style:{display:"flex",gap:Q.xs},children:Object.entries(tB).map(n=>{let[r,l]=n;return(0,i.jsx)("button",{style:eo(e.format===r,m),onClick:()=>eK(t,{format:r}),children:l},r)})})]}),ep.emails.length>1&&(0,i.jsx)("button",{style:{...ei(!1,m),color:"#d9534f",marginLeft:"auto"},onClick:()=>ex(e=>
1({...e,emails:e.emails.filter((e,n)=>n!==t)})),children:"Retirer"})]}),(0,i.jsx)("label",{style:et(m),children:"Sujet"}),(0,i.jsx)("input",{style:{...Z(m),width:"100%",marginBottom:Q.md},value:e.subject,placeholder:"Ex : Il y a un an, vous cherchiez le cadeau parfait",onChange:e=>eK(t,{subject:e.target.value})}),"branded"===e.format&&(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)("label",{style:et(m),children:"Titre affich\xe9 dans l'email"}),(0,i.jsx)("input",{style:{...Z(m),width:"100%",marginBottom:Q.md},value:e.title,placeholder:"Ex : De belles nouveaut\xe9s pour la rentr\xe9e",onChange:e=>eK(t,{title:e.target.value})}),(0,i.jsxs)("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:Q.md,marginBottom:Q.md},children:[(0,i.jsxs)("div",{children:[(0,i.jsx)("label",{style:et(m),children:"Image d'en-t\xeate (URL, bords arrondis)"}),(0,i.jsx)("input",{style:{...Z(m),width:"100%"},value:e.hero_image_url,placeholder:"https://…",onChange:e=>eK(t,{hero_image_url:e.target.value})})]}),(0,i.jsxs)("div",{children:[(0,i.jsx)("label",{style:et(m),children:"Image de bas de mail (URL, optionnelle)"}),(0,i.jsx)("input",{style:{...Z(m),width:"100%"},value:e.bottom_image_url,placeholder:"https://…",onChange:e=>eK(t,{bottom_image_url:e.target.value})})]})]}),(0,i.jsx)("label",{style:et(m),children:"Corps du message (texte centr\xe9 — logo, titre, images et footer ajout\xe9s automatiquement)"}),(0,i.jsx)("textarea",{style:{...ee(m),width:"100%",minHeight:140},value:e.body,onChange:e=>eK(t,{body:e.target.value})}),(0,i.jsxs)("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:Q.md,marginTop:Q.md},children:[(0,i.jsxs)("div",{children:[(0,i.jsx)("label",{style:et(m),children:"Bouton — libell\xe9 (optionnel)"}),(0,i.jsx)("input",{style:{...Z(m),width:"100%"},value:e.cta_label,placeholder:"Ex : D\xc9COUVRIR LES NOUVEAUT\xc9S",onChange:e=>eK(t,{cta_label:e.target.value})})]}),(0,i.jsxs)("div",{children:[(0,i.jsx)("label",{style:et(m),children:"Bouton — lien"}),(0,i.jsx)("input",{style:{...Z(m),width:"100%"},value:e.cta_url,placeholder:"https://sudist.fr/...",onChange:e=>eK(t,{cta_url:e.target.value})})]})]})]}),"html"===e.format&&(0,i.jsxs)("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:Q.md},children:[(0,i.jsxs)("div",{children:[(0,i.jsx)("label",{style:et(m),children:"Code HTML"}),(0,i.jsx)("textarea",{style:{...ee(m),width:"100%",minHeight:260,fontFamily:K,fontSize:12},value:e.html,onChange:e=>eK(t,{html:e.target.value})})]}),(0,i.jsxs)("div",{children:[(0,i.jsx)("label",{style:et(m),children:"Aper\xe7u live"}),(0,i.jsx)("iframe",{title:"preview-".concat(t),srcDoc:e.html,sandbox:"",style:{width:"100%",height:260,border:"1px solid ".concat(m.border),borderRadius:$.md,background:"#fff"}})]})]}),"design"===e.format&&(0,i.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:Q.lg},children:[e.html?(0,i.jsx)("iframe",{title:"design-".concat(t),srcDoc:e.html,sandbox:"",style:{width:280,height:180,border:"1px solid ".concat(m.border),borderRadius:$.md,background:"#fff",pointerEvents:"none"}}):(0,i.jsx)("div",{style:{fontSize:13,color:m.textMuted},children:"Aucun design pour le moment."}),(0,i.jsx)("button",{style:ei(!0,m),onClick:()=>eR(t),children:e.design?"Modifier dans le builder":"Ouvrir le builder visuel"})]}),(0,i.jsxs)("div",{style:{display:"flex",flexWrap:"wrap",gap:Q.xs,marginTop:Q.md,alignItems:"center"},children:[(0,i.jsx)("span",{style:{fontSize:11,color:m.textDim,marginRight:Q.xs},children:"Variables :"}),tF.map(n=>(0,i.jsx)("button",{title:n.label,style:{...eo(!1,m),fontFamily:K,fontSize:11,padding:"3px 8px"},onClick:()=>{"branded"===e.format?eK(t,{body:"".concat(e.body||"","{{").concat(n.name,"}}")}):"html"===e.format&&eK(t,{html:"".concat(e.html||"","{{").concat(n.name,"}}")})},children:"{{".concat(n.name,"}}")},n.name))]}),(0,i.jsxs)("div",{style:{display:"flex",gap:Q.sm,marginTop:Q.lg},children:[(0,i.jsx)("button",{style:ei(!1,m),onClick:()=>eT({index:t,brief:"",loading:!1}),children:"✦ Assistant IA"}),(0,i.jsx)("button",{style:ei(!1,m),disabled:"preview"===ef,onClick:()=>eY(e),children:"Pr\xe9visualiser"}),(0,i.jsx)("button",{style:ei(!1,m),disabled:"test"===ef,onClick:()=>eJ(e),children:"Envoyer un test"})]})]},t))}),(0,i.jsxs)("div",{style:{display:"flex",gap:Q.md,marginTop:Q.xl},children:[(0,i.jsx)("button",{style:ei(!1,m),onClick:()=>ex(e=>({...e,emails:[...e.emails,{...tU(),delay_days:7}]})),children:"+ Ajouter un email"}),(0,i.jsx)("button",{style:{...ei(!0,m),marginLeft:"auto"},disabled:eh,onClick:eG,children:eh?"Enregistrement…":"Enregistrer la s\xe9quence"})]})]})]}),null!==eD&&ep&&(0,i.jsxs)("div",{style:{position:"fixed",inset:0,zIndex:1e3,background:m.bg,display:"flex",flexDirection:"column"},children:[(0,i.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:Q.md,padding:"".concat(Q.md,"px ").concat(Q.xl,"px"),borderBottom:"1px solid ".concat(m.border)},children:[(0,i.jsxs)("div",{style:{fontWeight:600,fontSize:14},children:["Builder — Email ",eD+1]}),eI.length>0&&(0,i.jsxs)("select",{style:{...Z(m),width:220},defaultValue:"",onChange:e=>{let t=eI.find(t=>
1t.id===e.target.value);t&&(e=>{var t;let n=null==(t=eW.current)?void 0:t.editor;n&&(null==e?void 0:e.design)&&n.loadDesign(e.design)})(t)},children:[(0,i.jsx)("option",{value:"",disabled:!0,children:"Charger un template…"}),eI.map(e=>(0,i.jsx)("option",{value:e.id,children:e.name},e.id))]}),(0,i.jsxs)("div",{style:{marginLeft:"auto",display:"flex",gap:Q.sm},children:[(0,i.jsx)("button",{style:ei(!1,m),onClick:()=>{var e;let t=null==(e=eW.current)?void 0:e.editor;if(!t)return;let n=prompt("Nom du template :");n&&t.exportHtml(async e=>{try{let t,i=await (t={name:n,design:e.design,html:e.html},l("/marketing/templates",{method:"POST",body:t}));if(!i.success)throw Error(i.error);let r=await j();r.success&&eM(r.templates),eq("ok","Template enregistr\xe9")}catch(e){eq("err",e.message)}})},children:"Enregistrer comme template"}),(0,i.jsx)("button",{style:ei(!1,m),onClick:()=>eR(null),children:"Annuler"}),(0,i.jsx)("button",{style:ei(!0,m),onClick:()=>{var e;let t=null==(e=eW.current)?void 0:e.editor;if(!t)return eq("err","\xc9diteur non pr\xeat");t.exportHtml(e=>{eK(eD,{design:e.design,html:e.html,format:"design"}),eR(null),eq("ok","Design enregistr\xe9 dans l'email")})},children:"Valider le design"})]})]}),(0,i.jsx)("div",{style:{flex:1,minHeight:0},children:(0,i.jsx)(tA,{ref:eW,minHeight:"100%",options:{locale:"fr-FR",mergeTags:tE,appearance:{theme:"modern_light"}},onReady:e=>{var t;let n=null==(t=ep.emails[eD])?void 0:t.design;n&&e.loadDesign(n)}})})]}),ek&&(0,i.jsx)("div",{style:{position:"fixed",inset:0,zIndex:1e3,background:"rgba(0,0,0,0.55)",display:"flex",alignItems:"center",justifyContent:"center",padding:Q.xl},onClick:()=>ew(null),children:(0,i.jsxs)("div",{style:{background:m.surface,borderRadius:$.lg,width:"min(680px, 96vw)",maxHeight:"90vh",display:"flex",flexDirection:"column",overflow:"hidden"},onClick:e=>e.stopPropagation(),children:[(0,i.jsxs)("div",{style:{padding:"".concat(Q.md,"px ").concat(Q.lg,"px"),borderBottom:"1px solid ".concat(m.border),fontSize:13},children:[(0,i.jsx)("div",{style:{fontWeight:600},children:ek.subject}),ek.profile&&(0,i.jsxs)("div",{style:{color:m.textMuted,fontSize:12,marginTop:2},children:["Aper\xe7u avec le profil r\xe9el : ",ek.profile.email]})]}),(0,i.jsx)("iframe",{title:"preview",srcDoc:ek.html,sandbox:"",style:{flex:1,minHeight:460,border:"none",background:"#fff"}}),(0,i.jsx)("div",{style:{padding:Q.md,textAlign:"right"},children:(0,i.jsx)("button",{style:ei(!1,m),onClick:()=>ew(null),children:"Fermer"})})]})}),ez&&(0,i.jsx)("div",{style:{position:"fixed",inset:0,zIndex:1e3,background:"rgba(0,0,0,0.55)",display:"flex",alignItems:"center",justifyContent:"center",padding:Q.xl},onClick:()=>!ez.loading&&eT(null),children:(0,i.jsxs)("div",{style:{background:m.surface,borderRadius:$.lg,width:"min(520px, 96vw)",padding:Q.xl},onClick:e=>e.stopPropagation(),children:[(0,i.jsx)("div",{style:{fontWeight:600,fontSize:15,marginBottom:Q.sm},children:"Assistant IA"}),(0,i.jsx)("div",{style:{fontSize:12.5,color:m.textMuted,marginBottom:Q.md,lineHeight:1.5},children:"D\xe9crivez l'email voulu (ou une consigne d'am\xe9lioration si l'email existe d\xe9j\xe0). L'IA \xe9crit dans le ton Sudist et conna\xeet les variables."}),(0,i.jsx)("textarea",{autoFocus:!0,style:{...ee(m),width:"100%",minHeight:90},value:ez.brief,placeholder:"Ex : email de relance pour un client qui offre un cadeau chaque No\xebl, mentionner {{cadeau_an_dernier}}",onChange:e=>eT(t=>({...t,brief:e.target.value}))}),(0,i.jsxs)("div",{style:{display:"flex",gap:Q.sm,marginTop:Q.md,justifyContent:"flex-end"},children:[(0,i.jsx)("button",{style:ei(!1,m),disabled:ez.loading,onClick:()=>eT(null),children:"Annuler"}),(0,i.jsx)("button",{style:ei(!0,m),disabled:ez.loading,onClick:eX,children:ez.loading?"R\xe9daction…":"R\xe9diger"})]})]})}),ej&&(0,i.jsx)("div",{style:{position:"fixed",inset:0,zIndex:1e3,background:"rgba(0,0,0,0.55)",display:"flex",alignItems:"center",justifyContent:"center",padding:Q.xl},onClick:()=>eS(null),children:(0,i.jsxs)("div",{style:{background:m.surface,borderRadius:$.lg,width:"min(640px, 96vw)",maxHeight:"85vh",overflowY:"auto",padding:Q.xl},onClick:e=>e.stopPropagation(),children:[(0,i.jsxs)("div",{style:{fontWeight:600,fontSize:15,marginBottom:Q.md},children:["R\xe9sultat du run ",ej.dry_run?"(simulation — rien n'a \xe9t\xe9 envoy\xe9)":""]}),(0,i.jsxs)("div",{style:{display:"flex",gap:Q.xl,fontSize:13,marginBottom:Q.lg,flexWrap:"wrap"},children:[(0,i.jsxs)("span",{children:[(0,i.jsx)("b",{children:null!=(c=ej.enrolled)?c:0})," nouvelles inscriptions"]}),(0,i.jsxs)("span",{style:{color:"#5b9bd5"},children:[(0,i.jsx)("b",{children:null!=(u=ej.sent)?u:0})," emails ",ej.dry_run?"simul\xe9s":"envoy\xe9s"]}),(0,i.jsxs)("span",{style:{color:"#d5a021"},children:[(0,i.jsx)("b",{children:null!=(p=ej.skipped)?p:0})," bloqu\xe9s"]}),ej.sync&&!ej.sync.error&&(0,i.jsxs)("span",{style:{color:m.textMuted},children:[null!=(g=ej.sync.processed)?g:0," commandes synchronis\xe9es"]})]}),(ej.by_sequence||[]).filter(e=>e.enrolled>0||e.waiting>0||e.error).map((e,t)=>(0,i.jsxs)("div",{style:{fontSize:12.5,padding:"".concat(Q.xs,"px 0"),color:e.error?"#d9534f":m.textMuted},children:[e.sequence," : ",e.error?"erreur — ".concat(e.error):"".concat(e.enrolled," inscription").concat(e.enrolled>1?"s":""),!e.error&&e.waiting>0&&(0,i.jsxs)("span",{style:{color:"#d5a021"},children:[" \xb7 ",e.waiting," en attente de budget IA"]})]},t)),(ej.details||[]).length>0&&(0,i.jsxs)("div",{style:{marginTop:Q.md,borderTop:"1px solid ".concat(m.borderLight),paddingTop:Q.md},children:[(0,i.jsx)("button",{onClick:()=>ea(e=>!e),style:{background:"none",border:"none",padding:0,cursor:"pointer",fontFamily:G,fontSize:12.5,color:m.gold,fontWeight:600},children:es?"▾ Masquer le d\xe9tail":"▸ Voir le d\xe9tail (".concat(ej.details.length," ligne").concat(ej.details.length>
11?"s":"",")")}),es&&ej.details.map((e,t)=>(0,i.jsxs)("div",{style:{fontSize:12,padding:"3px 0",color:m.textMuted,fontFamily:K},children:[e.email," — ",e.action,e.subject?" \xb7 ".concat(e.subject):"",e.reason?" \xb7 ".concat(e.reason):""]},t))]}),!ej.enrolled&&!(ej.details||[]).length&&(0,i.jsx)("div",{style:{fontSize:13,color:m.textMuted},children:"Aucune inscription ni envoi sur ce run. V\xe9rifiez qu'au moins une s\xe9quence est active et que les profils sont synchronis\xe9s."}),(0,i.jsx)("div",{style:{textAlign:"right",marginTop:Q.lg},children:(0,i.jsx)("button",{style:ei(!1,m),onClick:()=>eS(null),children:"Fermer"})})]})})]}):null}let tG={discovered:{label:"D\xe9couvert",color:"#8a8278"},to_verify:{label:"\xc0 v\xe9rifier",color:"#fbbf24"},qualified:{label:"Qualifi\xe9",color:"#60a5fa"},excluded:{label:"Exclu par l'IA",color:"#5a5550"},in_sequence:{label:"En s\xe9quence",color:"#c8a46e"},replied:{label:"A r\xe9pondu",color:"#34d399"},interested:{label:"Int\xe9ress\xe9",color:"#34d399"},refused:{label:"Non int\xe9ress\xe9",color:"#f87171"},unresponsive:{label:"Sans r\xe9ponse",color:"#8a8278"},customer:{label:"Client",color:"#a78bfa"},unsubscribed:{label:"D\xe9sinscrit",color:"#f87171"},bounced:{label:"Email invalide",color:"#f87171"}},tK={souvenirs:"Souvenirs / cadeaux",deco:"D\xe9co d'int\xe9rieur",mode:"Mode / textile",concept_store:"Concept store",epicerie_fine:"\xc9picerie fine",autre:"Autre"},tY={created:"Fiche cr\xe9\xe9e",enriched:"Site analys\xe9 (enrichissement IA)",qualified:"Qualifi\xe9",excluded:"Exclu",sequence_started:"S\xe9quence lanc\xe9e",sequence_stopped:"S\xe9quence stopp\xe9e",sequence_completed:"S\xe9quence termin\xe9e sans r\xe9ponse",email_draft:"Brouillon Gmail cr\xe9\xe9",email_sent:"Email envoy\xe9",opened:"Email ouvert",clicked:"Lien cliqu\xe9",replied:"A r\xe9pondu, s\xe9quence stopp\xe9e",bounced:"Adresse invalide (bounce)",unsubscribed:"D\xe9sinscrit",status_change:"Changement de statut",note:"Note"},tJ=[{key:"to_contact",label:"\xc0 contacter",color:"#60a5fa",drop:"qualified",statuses:["discovered","to_verify","qualified"],hint:"Collecte, IA et ajouts manuels",clearable:!0},{key:"in_sequence",label:"Email envoy\xe9",color:"#c8a46e",drop:"in_sequence",statuses:["in_sequence","unresponsive"],hint:"D\xe9poser ici envoie la pr\xe9sentation (lookbook), puis les relances suivent seules"},{key:"replied",label:"A r\xe9pondu",color:"#34d399",drop:"replied",statuses:["replied","interested","customer"],hint:"D\xe9tect\xe9 automatiquement dans Gmail"},{key:"refused",label:"Non int\xe9ress\xe9",color:"#f87171",drop:"refused",statuses:["refused"]}],tX=["excluded","unsubscribed","bounced"],tQ={discovered:{label:"\xe0 analyser",color:"#8a8278"},to_verify:{label:"\xe0 v\xe9rifier",color:"#fbbf24"},unresponsive:{label:"sans r\xe9ponse",color:"#8a8278"},interested:{label:"int\xe9ress\xe9",color:"#34d399"},customer:{label:"client",color:"#a78bfa"},unsubscribed:{label:"d\xe9sinscrit",color:"#f87171"},bounced:{label:"adresse invalide",color:"#f87171"}},t$=e=>e?new Date(e).toLocaleDateString("fr-FR",{day:"numeric",month:"short",hour:"2-digit",minute:"2-digit"}):"";function tZ(e){let{status:t,t:n}=e,r=tG[t]||{label:t,color:n.textMuted};return(0,i.jsx)("span",{style:{fontSize:11,fontWeight:600,color:r.color,background:"".concat(r.color,"18"),border:"1px solid ".concat(r.color,"40"),borderRadius:$.pill,padding:"3px 10px",whiteSpace:"nowrap"},children:r.label})}function t0(e){let{label:t,value:n,sub:r,t:l}=e;return(0,i.jsxs)("div",{style:{...er(l),padding:"".concat(Q.md,"px ").concat(Q.lg,"px"),minWidth:110,flex:"1 1 110px"},children:[(0,i.jsx)("div",{style:{fontSize:22,fontWeight:700,color:l.text,fontFamily:K},children:n}),(0,i.jsxs)("div",{style:{fontSize:11,color:l.textMuted,marginTop:2},children:[t,r?(0,i.jsxs)("span",{style:{color:l.textDim},children:[" \xb7 ",r]}):null]})]})}function t1(e){var t,n,o,s,a,d;let{t:c=J,active:u}=e,[p,g]=(0,r.useState)("pipeline"),[x,h]=(0,r.useState)("kanban"),[m,f]=(0,r.useState)(null),[y,b]=(0,r.useState)(null),[v,j]=(0,r.useState)([]),[S,k]=(0,r.useState)(null),[w,C]=(0,r.useState)(!1),[_,z]=(0,r.useState)(""),[T,D]=(0,r.useState)(""),[R,I]=(0,r.useState)(null),[M,W]=(0,r.useState)(null),[q,L]=(0,r.useState)(null),[A,N]=(0,r.useState)([]),[H,V]=(0,r.useState)({}),[Y,X]=(0,r.useState)(null),[en,el]=(0,r.useState)(!1),[eo,es]=(0,r.useState)({name:"",city:"",email:"",website:"",notes:""}),[ea,ed]=(0,r.useState)(!1),[ec,eu]=(0,r.useState)(""),[ep,ex]=(0,r.useState)(null),[eh,em]=(0,r.useState)(!1),[ef,ey]=(0,r.useState)(""),[eb,ev]=(0,r.useState)(null),[ej,eS]=(0,r.useState)(null),[ek,ew]=(0,r.useState)(!1),[eC,e_]=(0,r.useState)(!1),[ez,eT]=(0,r.useState)(null),eD=(e,t)=>{I({type:e,text:t}),setTimeout(()=>I(null),6e3)},eR=(0,r.useCallback)(async()=>{C(!0);try{let e={limit:500};_&&(e.status=_),T.trim()&&(e.q=T.trim());let t=await F(e);t.success&&(j(t.prospects),k(t.stats))}catch(e){eD("err",e.message)}C(!1)},[_,T]);(0,r.useEffect)(()=>{u&&eR()},[u,eR]),(0,r.useEffect)(()=>{try{let e=localStorage.getItem("sav-prospection-view");("list"===e||"kanban"===e)&&h(e)}catch(e){}},[]);let eI=e=>{h(e);try{localStorage.setItem("sav-prospection-view",e)}catch(e){}};(0,r.useEffect)(()=>{u&&l("/prospection/config").then(e=>{e.success&&(eS(e.settings),ew(e.places_configured))}).catch(()=>{})},[u]);let eM=async e=>{L(e),X(null),V({email:e.email||"",city:e.city||"",website:e.website||"",notes:e.notes||"",hook:e.hook||"",segment:e.segment||""});try{let t=await B(e.id);N(t.success?t.events:[])}catch(e){N([])}},eW=async e=>{let t=await F({q:""});if(t.success){j(t.prospects),k(t.stats);let n=t.prospects.find(t=>
1t.id===e);n&&(L(n),N((await B(e)).events||[]))}},eq=async function(e,t){let{reload:n=!0}=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};W(e);try{let e=await t();if(e&&!1===e.success)throw Error(e.error||"Erreur inconnue");return n&&await eR(),e}catch(e){return eD("err",e.message),null}finally{W(null)}},eL=async()=>{await eq("save",()=>E(q.id,H),{reload:!1})&&(eD("ok","Fiche enregistr\xe9e"),await eW(q.id))},eA=async e=>{if(await eq(e,()=>E(q.id,{status:e}),{reload:!1})){var t;eD("ok","Statut : ".concat((null==(t=tG[e])?void 0:t.label)||e)),await eW(q.id),await eR()}},eF=async function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0;await eq("start",()=>O("start",q.id,e),{reload:!1})&&(eD("ok","S\xe9quence lanc\xe9e : le prochain passage du moteur enverra l'\xe9tape 1 (ou cr\xe9era le brouillon)"),await eW(q.id),await eR())},eE=async e=>{let t=await eq("preview",()=>l("/prospection/preview",{method:"POST",body:{id:q.id,step:e}}),{reload:!1});t&&X({step:e,subject:t.subject,html:t.html,label:t.label})},eB=async e=>{let t=await eq(e?"dry":"run",()=>U(e));if(t){let n=t.replies&&!t.replies.error?" \xb7 r\xe9ponses d\xe9tect\xe9es : ".concat(t.replies.replied||0):"";eD("ok","".concat(e?"Simulation":"Traitement"," : ").concat(t.processed," email(s) ").concat("draft"===t.mode&&!e?"en brouillon":"trait\xe9s",", ").concat(t.skipped," pass\xe9s, ").concat(t.failed," \xe9checs").concat(n))}},eP=(e,t)=>j(n=>n.map(n=>n.id===e?{...n,...t}:n)),eO=async(e,t)=>{var n;if(e&&e.status!==t){if("in_sequence"===t){if(!e.email)return void eD("err","".concat(e.name," n'a pas d'email : ajoutez-le sur la tuile avant d'envoyer"));let n=(null==ej?void 0:ej.mode)!=="send",i="in_sequence"===e.status?e.sequence_step:0,r="l'email ".concat(Math.min(i,2)+1);if(!confirm(n?"Cr\xe9er le brouillon Gmail de ".concat(r," pour ").concat(e.name," maintenant ?\n(mode brouillon : vous relisez puis envoyez depuis Gmail)"):"Envoyer ".concat(r," \xe0 ").concat(e.name," maintenant ?")))return;eP(e.id,{status:t});let l=await eq("send_now",()=>O("send_now",e.id));return void(l?eD("ok","draft"===l.mode?"Brouillon cr\xe9\xe9 dans Gmail : \xab ".concat(l.subject," \xbb"):"Email envoy\xe9 \xe0 ".concat(e.name," : \xab ").concat(l.subject," \xbb")):await eR())}eP(e.id,{status:t}),await eq(t,()=>E(e.id,{status:t}))?eD("ok","".concat(e.name," → ").concat((null==(n=tG[t])?void 0:n.label)||t)):await eR()}},eU=async e=>{let t=prompt("Email de ".concat(e.name," :"),e.email||"");if(null===t)return;let n=t.trim().toLowerCase();n&&await eq("email",()=>E(e.id,{email:n}))&&eD("ok","Email enregistr\xe9 pour ".concat(e.name))},eN=async e=>{confirm("Supprimer ".concat(e.name," ? Cette boutique dispara\xeet du d\xe9marchage."))&&(j(t=>t.filter(t=>t.id!==e.id)),await eq("del",()=>{let t;return t=e.id,l("/prospection/prospects?id=".concat(encodeURIComponent(t)),{method:"DELETE"})})?(eD("ok","".concat(e.name," supprim\xe9e")),(null==q?void 0:q.id)===e.id&&L(null)):await eR())},eH=async e=>{let t=v.filter(t=>e.statuses.includes(t.status));if(!t.length)return void eD("ok","La colonne est d\xe9j\xe0 vide");if(!confirm("Supprimer les ".concat(t.length," boutique(s) de \xab ").concat(e.label," \xbb ?\nLes boutiques d\xe9j\xe0 contact\xe9es (Email envoy\xe9, A r\xe9pondu…) ne sont pas concern\xe9es. Cette action est d\xe9finitive.")))return;let n=await eq("clear",()=>{let t;return t=e.statuses,l("/prospection/prospects?statuses=".concat(encodeURIComponent(t.join(","))),{method:"DELETE"})});n&&eD("ok","".concat(n.deleted," boutique(s) supprim\xe9e(s), colonne \xab ").concat(e.label," \xbb vid\xe9e"))},eV=async e=>{let t=(null==ej?void 0:ej.mode)!=="send",n="in_sequence"===e.status?e.sequence_step:0,i="l'email ".concat(Math.min(n,2)+1);if(!confirm(t?"Cr\xe9er le brouillon Gmail de ".concat(i," pour ").concat(e.name," maintenant ?"):"Envoyer ".concat(i," \xe0 ").concat(e.name," maintenant ?")))return;let r=await eq("send_now",()=>O("send_now",e.id),{reload:!1});r&&(eD("ok","draft"===r.mode?"Brouillon cr\xe9\xe9 dans Gmail : \xab ".concat(r.subject," \xbb"):"Email envoy\xe9 : \xab ".concat(r.subject," \xbb")),await eW(e.id),await eR())},eG=async()=>{W("enrich");try{let t=0,n=0,i=1,r=1;for(;i>0&&r>0&&n<15;){var e;let l=await P({limit:10});if(!l||!1===l.success)throw Error((null==l?void 0:l.error)||"Erreur d'enrichissement");t+=l.enriched,i=null!=(e=l.remaining)?e:0,r=l.enriched,n++,I({type:"ok",text:"Analyse en cours : ".concat(t," bout
1ique(s) analys\xe9e(s), ").concat(i," restante(s)…")})}await eR(),eD("ok","Analyse termin\xe9e : ".concat(t," boutique(s) analys\xe9e(s)").concat(i>0?", ".concat(i," restante(s), recliquez pour continuer"):""))}catch(e){eD("err",e.message)}W(null)},eK={...Z(c),fontFamily:G},eY={...ei(c.gold,c),fontWeight:600},eJ={...ei(c.textMuted,c)},eX=e=>{let{children:t,onClose:n,wide:r}=e;return(0,i.jsx)("div",{onClick:n,style:{position:"fixed",inset:0,background:"rgba(0,0,0,.6)",zIndex:300,display:"flex",alignItems:"center",justifyContent:"center",padding:16},children:(0,i.jsx)("div",{onClick:e=>e.stopPropagation(),style:{background:c.surface,border:"1px solid ".concat(c.border),borderRadius:$.lg,padding:Q.xl,width:"100%",maxWidth:r?860:480,maxHeight:"90vh",overflowY:"auto"},children:t})})},eQ=async e=>{e_(!0);try{let t=await l("/prospection/config",{method:"PATCH",body:e});if(t.success)eS(t.settings),eD("ok","R\xe9glages enregistr\xe9s");else throw Error(t.error)}catch(e){eD("err",e.message)}e_(!1)},e$=(e,t)=>{let n=[...ez||ej.bestSellers||[]];null===t?n.splice(e,1):n[e]={...n[e],...t},eT(n)},eZ=e=>{let t=m===e.id;return(0,i.jsxs)("div",{draggable:!0,onDragStart:t=>{f(e.id),t.dataTransfer.effectAllowed="move";try{t.dataTransfer.setData("text/plain",e.id)}catch(e){}},onDragEnd:()=>{f(null),b(null)},onClick:()=>eM(e),style:{background:c.surface,border:"1px solid ".concat(c.border),borderRadius:$.md,padding:"10px 12px",cursor:"grab",opacity:t?.4:"unresponsive"===e.status?.6:1,boxShadow:"0 1px 2px rgba(0,0,0,.06)",position:"relative"},children:[(0,i.jsx)("button",{title:"Supprimer cette boutique",onClick:t=>{t.stopPropagation(),eN(e)},style:{position:"absolute",top:6,right:8,background:"transparent",border:0,color:c.textDim,fontSize:14,cursor:"pointer",lineHeight:1,padding:2},children:"\xd7"}),(0,i.jsx)("div",{style:{fontSize:13,fontWeight:600,color:c.text,paddingRight:16,lineHeight:1.3},children:e.name}),(0,i.jsxs)("div",{style:{fontSize:11,color:c.textMuted,marginTop:2},children:[e.city||"ville ?",e.segment?" \xb7 ".concat(tK[e.segment]||e.segment):""]}),e.email?(0,i.jsx)("div",{style:{fontSize:11,color:c.textMuted,fontFamily:K,marginTop:6,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},title:e.email,children:e.email}):(0,i.jsx)("button",{onClick:t=>{t.stopPropagation(),eU(e)},style:{...ei(c.orange,c),marginTop:6,padding:"2px 8px",fontSize:11},children:"+ ajouter un email"}),(0,i.jsxs)("div",{style:{display:"flex",gap:8,alignItems:"center",marginTop:8,fontSize:11,color:c.textDim,flexWrap:"wrap"},children:[tQ[e.status]&&(0,i.jsx)("span",{style:{fontSize:10,fontWeight:600,color:tQ[e.status].color,background:"".concat(tQ[e.status].color,"18"),border:"1px solid ".concat(tQ[e.status].color,"40"),borderRadius:$.pill,padding:"1px 7px"},children:tQ[e.status].label}),(e.sequence_step>0||"in_sequence"===e.status)&&(0,i.jsxs)("span",{title:"emails envoy\xe9s",style:{fontFamily:K},children:[Math.min(e.sequence_step,3),"/3"]}),e.open_count>0&&(0,i.jsxs)("span",{title:"ouvert",style:{color:c.blue},children:["\uD83D\uDC41 ",e.open_count]}),e.click_count>0&&(0,i.jsxs)("span",{title:"cliqu\xe9",style:{color:c.gold},children:["\uD83D\uDD17 ",e.click_count]}),e.replied_at&&(0,i.jsx)("span",{title:"a r\xe9pondu",style:{color:c.green},children:"✉︎"}),(0,i.jsx)("span",{style:{marginLeft:"auto",fontFamily:K},children:e.replied_at?"r\xe9pondu ".concat(t$(e.replied_at)):t$(e.last_open_at||e.updated_at)})]})]},e.id)};return(0,i.jsxs)("div",{style:{padding:Q.xl,fontFamily:G,height:"100%",overflowY:"auto",boxSizing:"border-box"},children:[(0,i.jsxs)("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",marginBottom:Q.lg,flexWrap:"wrap",gap:Q.md},children:[(0,i.jsxs)("div",{children:[(0,i.jsx)("h2",{style:{margin:0,fontSize:20,color:c.text},children:"Prospection B2B"}),(0,i.jsx)("div",{style:{fontSize:12,color:c.textMuted,marginTop:3},children:"D\xe9marchage de boutiques et revendeurs : collecte, qualification IA, s\xe9quence de 3 emails personnalis\xe9s"})]}),(0,i.jsxs)("div",{style:{display:"flex",gap:8},children:[(0,i.jsx)("button",{onClick:()=>g("pipeline"),style:"pipeline"===p?eY:eJ,children:"Pipeline"}),(0,i.jsx)("button",{onClick:()=>g("reglages"),style:"reglages"===p?eY:eJ,children:"R\xe9glages"})]})]}),R&&(0,i.jsx)("div",{style:{fontSize:13,padding:"10px 14px",borderRadius:$.md,marginBottom:Q.md,color:"ok"===R.type?c.green:c.red,background:"ok"===R.type?"".concat(c.green,"14"):"".concat(c.red,"14"),border:"1px solid ".concat("ok"===R.type?c.green:c.red,"30")},children:R.text}),"reglages"===p?ej&&(0,i.jsxs)("div",{style:{display:"flex",flexDirection:"column",gap:Q.lg,maxWidth:640},children:[(0,i.jsxs)("div",{style:er(c),children:[(0,i.jsx)("div",{style:{fontSize:14,fontWeight:700,color:c.text,marginBottom:Q.md},children:"Moteur d'envoi"}),(0,i.jsxs)("div",{style:{display:"flex",gap:Q.lg,flexWrap:"wrap",alignItems:"flex-end"},children:[(0,i.jsxs)("div",{children:[(0,i.jsx)("label",{style:et(c),children:"Activ\xe9 (cron quotidien 9h)"}),(0,i.jsx)("button",{onClick:()=>eQ({enabled:!ej.enabled}),style:{...ei(ej.enabled?c.green:c.textMuted,c),minWidth:90},children:ej.enabled?"Activ\xe9":"D\xe9sactiv\xe9"})]}),(0,i.jsxs)("div",{children:[(0,i.jsx)("label",{style:et(c),children:"Mode"}
1),(0,i.jsxs)("select",{value:ej.mode,onChange:e=>eQ({mode:e.target.value}),style:eK,children:[(0,i.jsx)("option",{value:"draft",children:"Brouillons Gmail \xe0 relire (recommand\xe9)"}),(0,i.jsx)("option",{value:"send",children:"Envoi automatique direct"})]})]}),(0,i.jsxs)("div",{children:[(0,i.jsx)("label",{style:et(c),children:"Plafond / jour"}),(0,i.jsx)("input",{type:"number",min:1,max:100,defaultValue:ej.dailySendCap,onBlur:e=>eQ({dailySendCap:Number(e.target.value)}),style:{...eK,width:80}})]})]}),(0,i.jsxs)("div",{style:{display:"flex",gap:Q.md,marginTop:Q.md,alignItems:"flex-end",flexWrap:"wrap"},children:[(0,i.jsxs)("div",{children:[(0,i.jsx)("label",{style:et(c),children:"D\xe9lais des 3 \xe9tapes (jours)"}),(0,i.jsx)("div",{style:{display:"flex",gap:6},children:[0,1,2].map(e=>{var t,n;return(0,i.jsx)("input",{type:"number",min:0,max:60,defaultValue:null!=(n=null==(t=ej.stepDelays)?void 0:t[e])?n:[0,5,7][e],onBlur:t=>{let n=[...ej.stepDelays||[0,5,7]];n[e]=Number(t.target.value),eQ({stepDelays:n})},style:{...eK,width:60}},e)})}),(0,i.jsx)("div",{style:{fontSize:11,color:c.textDim,marginTop:4},children:"J0, puis +5j, puis +7j = derni\xe8re relance \xe0 J+12"})]}),(0,i.jsxs)("div",{style:{flex:1,minWidth:180},children:[(0,i.jsx)("label",{style:et(c),children:"Signature (pr\xe9nom / \xe9quipe)"}),(0,i.jsx)("input",{defaultValue:ej.fromName,onBlur:e=>eQ({fromName:e.target.value}),style:{...eK,width:"100%"}})]})]})]}),(0,i.jsxs)("div",{style:er(c),children:[(0,i.jsx)("div",{style:{fontSize:14,fontWeight:700,color:c.text,marginBottom:Q.md},children:"Contenu des emails"}),(0,i.jsxs)("div",{style:{display:"flex",gap:Q.md,flexWrap:"wrap"},children:[(0,i.jsxs)("div",{style:{flex:1,minWidth:180},children:[(0,i.jsx)("label",{style:et(c),children:"Logo (emails brand\xe9s)"}),(0,i.jsx)("input",{defaultValue:ej.logoUrl,placeholder:"https://…/logo.png",onBlur:e=>eQ({logoUrl:e.target.value}),style:{...eK,width:"100%"}})]}),(0,i.jsxs)("div",{style:{flex:1,minWidth:180},children:[(0,i.jsx)("label",{style:et(c),children:"Photo d'en-t\xeate (lookbook, email 1)"}),(0,i.jsx)("input",{defaultValue:ej.heroImageUrl||"",placeholder:"https://…/atelier.jpg",onBlur:e=>eQ({heroImageUrl:e.target.value}),style:{...eK,width:"100%"}})]}),(0,i.jsxs)("div",{style:{flex:1,minWidth:180},children:[(0,i.jsx)("label",{style:et(c),children:"Photo de l'atelier (lookbook, email 1)"}),(0,i.jsx)("input",{defaultValue:ej.atelierImageUrl||"",placeholder:"https://…/atelier-sudist.jpg",onBlur:e=>eQ({atelierImageUrl:e.target.value}),style:{...eK,width:"100%"}})]}),(0,i.jsxs)("div",{style:{flex:1,minWidth:180},children:[(0,i.jsx)("label",{style:et(c),children:"Photo du bloc \xab t-shirt \xe0 votre ville \xbb (emails 1 et 2)"}),(0,i.jsx)("input",{defaultValue:ej.customTeeImageUrl||"",placeholder:"https://…/t-shirt-ville.jpg",onBlur:e=>eQ({customTeeImageUrl:e.target.value}),style:{...eK,width:"100%"}})]})]})]}),(0,i.jsxs)("div",{style:er(c),children:[(0,i.jsx)("div",{style:{fontSize:14,fontWeight:700,color:c.text,marginBottom:4},children:"Meilleures ventes du lookbook (email 1)"}),(0,i.jsx)("div",{style:{fontSize:12,color:c.textMuted,marginBottom:Q.md},children:"Jusqu'\xe0 8 produits en grille (3 colonnes quand le nombre est un multiple de 3, sinon 2 ; photos id\xe9alement 1200 \xd7 1500 px, fond clair). Le lien produit passe par le tracking de clic, et un bouton vers sudist.fr suit la grille. Les boutiques d\xe9co re\xe7oivent leur propre s\xe9lection (affiches). L'email 2 montre les trois premiers produits, l'email 3 les trois suivants."}),(ez||ej.bestSellers||[]).map((e,t,n)=>(0,i.jsxs)("div",{style:{border:"1px solid ".concat(c.border),borderRadius:$.md,padding:Q.md,marginBottom:Q.sm},children:[(0,i.jsxs)("div",{style:{display:"flex",gap:Q.sm,alignItems:"center",marginBottom:6},children:[(0,i.jsx)("span",{style:{fontFamily:K,fontSize:11,color:c.textDim,minWidth:22},children:String(t+1).padStart(2,"0")}),(0,i.jsx)("input",{value:e.title||"",placeholder:"Nom du produit",onChange:e=>e$(t,{title:e.target.value}),style:{...eK,flex:2}}),(0,i.jsx)("input",{value:e.price||"",placeholder:"Prix public (49 €)",onChange:e=>e$(t,{price:e.target.value}),style:{...eK,width:120}}),(0,i.jsx)("button",{onClick:()=>e$(t,null),title:"Retirer",style:ei(c.red||"#f87171",c),children:"\xd7"})]}),(0,i.jsx)("input",{value:e.tagline||"",placeholder:"Une phrase qui donne envie (facultatif)",onChange:e=>e$(t,{tagline:e.target.value}),style:{...eK,width:"100%",marginBottom:6}}),(0,i.jsxs)("div",{style:{display:"flex",gap:Q.sm,flexWrap:"wrap"},children:[(0,i.jsx)("input",{value:e.imageUrl||"",placeholder:"https://cdn.shopify.com/…/photo.jpg",onChange:e=>e$(t,{imageUrl:e.target.value}),style:{...eK,flex:1,minWidth:160}}),(0,i.jsx)("input",{value:e.url||"",placeholder:"https://sudist.fr/products/…",onChange:e=>e$(t,{url:e.target.value}),style:{...eK,flex:1,minWidth:160}})]}),e.imageUrl?(0,i.jsx)("img",{src:e.imageUrl,alt:"",style:{marginTop:8,height:72,width:"auto",borderRadius:8,display:"block",objectFit:"cover"},onError:e=>{e.currentTarget.style.display="none"}}):null]},t)),(0,i.jsxs)("div",{style:{display:"flex",gap:Q.sm,alignItems:"center",marginTop:Q.sm},children:[(ez||ej.bestSellers||[]).length<8&&(0,i.jsx)("button",{onClick:()=>eT([...ez||ej.bestSellers||[],{title:"",tagline:"",price:"",imageUrl:"",url:""}]),style:eJ,children:"+ Ajouter un produit"}),ez&&(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)("button",{disabled:eC,onClick:async()=>{await eQ({bestSellers:ez.filter(e=>(e.title||"").trim())}),eT(null)},style:eY,children:"Enregistrer les meilleures ventes"}),(0,i.jsx)("button",{onClick:()=>eT(null),style:eJ,children:"Annuler"})]})]})]}),(0,i.jsxs)("div",{style:er(c),children:[(0,i.jsx)("div",{style:{fontSize:14,fontWeight:700,color:c.text,marginBottom:4},children:"Filtre anti-concurrents"}),(0,i.jsx)("div",{style:{fontSize:12,color:c.textMuted,marginBottom:Q.md},children:"Une boutique dont le nom ou le site met une de ces marques en avant est exclue automatiquement. L'IA exclut aussi toute boutique monomarque d'une marque textile r\xe9gionale comparable, m\xeame absente de cette liste."}),(0,i.jsx)("label",{style:et(c),children:"Marques concurrentes (une par ligne)"}),(0,i.jsx)("textarea",{defaultValue:(ej.blacklistBrands||[]).join("\n"),onBlur:e=>eQ({blacklistBrands:e.target.value.split("\n").map(e=>
1e.trim()).filter(Boolean)}),style:{...ee(c),width:"100%",minHeight:70}})]}),(0,i.jsxs)("div",{style:er(c),children:[(0,i.jsx)("div",{style:{fontSize:14,fontWeight:700,color:c.text,marginBottom:4},children:"Collecte Google Places"}),(0,i.jsx)("div",{style:{fontSize:12,color:ek?c.green:c.orange,marginBottom:Q.md},children:ek?"API configur\xe9e":"GOOGLE_PLACES_API_KEY absente : la collecte automatique est d\xe9sactiv\xe9e (l'import CSV et l'ajout manuel fonctionnent)"}),(0,i.jsxs)("div",{style:{display:"flex",gap:Q.md},children:[(0,i.jsxs)("div",{style:{flex:1},children:[(0,i.jsx)("label",{style:et(c),children:"Villes cibles (une par ligne)"}),(0,i.jsx)("textarea",{defaultValue:(ej.cities||[]).join("\n"),onBlur:e=>eQ({cities:e.target.value.split("\n").map(e=>e.trim()).filter(Boolean)}),style:{...ee(c),width:"100%",minHeight:120}})]}),(0,i.jsxs)("div",{style:{flex:1},children:[(0,i.jsx)("label",{style:et(c),children:"Requ\xeates de recherche (une par ligne)"}),(0,i.jsx)("textarea",{defaultValue:(ej.placesQueries||[]).join("\n"),onBlur:e=>eQ({placesQueries:e.target.value.split("\n").map(e=>e.trim()).filter(Boolean)}),style:{...ee(c),width:"100%",minHeight:120}})]})]})]})]}):(0,i.jsxs)(i.Fragment,{children:[S&&(0,i.jsxs)("div",{style:{display:"flex",gap:Q.md,flexWrap:"wrap",marginBottom:Q.lg},children:[(0,i.jsx)(t0,{label:"Boutiques",value:S.total,t:c}),(0,i.jsx)(t0,{label:"Qualifi\xe9es",value:(null==(t=S.by_status)?void 0:t.qualified)||0,t:c}),(0,i.jsx)(t0,{label:"En s\xe9quence",value:(null==(n=S.by_status)?void 0:n.in_sequence)||0,t:c}),(0,i.jsx)(t0,{label:"R\xe9ponses",value:((null==(o=S.by_status)?void 0:o.replied)||0)+((null==(s=S.by_status)?void 0:s.interested)||0)+((null==(a=S.by_status)?void 0:a.customer)||0),sub:"".concat(S.reply_rate,"%"),t:c}),(0,i.jsx)(t0,{label:"Ouvertures",value:"".concat(S.open_rate,"%"),sub:"indicatif",t:c}),(0,i.jsx)(t0,{label:"Clics",value:"".concat(S.click_rate,"%"),t:c})]}),(0,i.jsxs)("div",{style:{display:"flex",gap:8,flexWrap:"wrap",marginBottom:Q.md,alignItems:"center"},children:[(0,i.jsxs)("div",{style:{display:"flex",gap:4},children:[(0,i.jsx)("button",{onClick:()=>eI("kanban"),style:"kanban"===x?eY:eJ,children:"Kanban"}),(0,i.jsx)("button",{onClick:()=>eI("list"),style:"list"===x?eY:eJ,children:"Liste"})]}),(0,i.jsx)("input",{placeholder:"Rechercher (nom, ville, email)…",value:T,onChange:e=>D(e.target.value),onKeyDown:e=>"Enter"===e.key&&eR(),style:{...eK,width:220}}),(0,i.jsxs)("select",{value:_,onChange:e=>z(e.target.value),style:{...eK,width:180},children:[(0,i.jsx)("option",{value:"",children:"Tous les statuts"}),Object.entries(tG).map(e=>{let[t,n]=e;return(0,i.jsx)("option",{value:t,children:n.label},t)})]}),(0,i.jsx)("div",{style:{flex:1}}),(0,i.jsx)("button",{onClick:()=>{el(!0),es({name:"",city:"",email:"",website:"",notes:""})},style:eY,children:"+ Ajouter une boutique"}),(0,i.jsx)("button",{onClick:()=>{ed(!0),ex(null)},style:eJ,children:"Importer CSV"}),(0,i.jsx)("button",{onClick:()=>{em(!0),ev(null)},style:eJ,children:"Collecter (Places)"}),(0,i.jsx)("button",{onClick:eG,disabled:!!M,style:eJ,children:"enrich"===M?"Analyse…":"Enrichir (IA)"}),(0,i.jsx)("button",{onClick:()=>eB(!0),disabled:!!M,style:eJ,children:"dry"===M?"…":"Simuler"}),(0,i.jsx)("button",{onClick:()=>eB(!1),disabled:!!M,style:eY,children:"run"===M?"…":"Traiter les envois"})]}),w?(0,i.jsx)("div",{style:{color:c.textMuted,fontSize:13,padding:30,textAlign:"center"},children:"Chargement…"}):0===v.length?(0,i.jsx)(eg,{icon:"\uD83C\uDFEA",title:"Aucune boutique",description:"Ajoutez une boutique \xe0 la main, importez un CSV ou lancez une collecte Google Places.",t:c}):"kanban"===x?(()=>{let e=v.filter(e=>tX.includes(e.status)).length;return(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)("div",{style:{display:"flex",gap:Q.sm,overflowX:"auto",paddingBottom:Q.md,alignItems:"flex-start"},children:tJ.map(e=>{let t=v.filter(t=>e.statuses.includes(t.status)),n=y===e.key,r={color:e.color};return(0,i.jsxs)("div",{onDragOver:t=>{t.preventDefault(),t.dataTransfer.dropEffect="move",y!==e.key&&b(e.key)},onDragLeave:e=>{e.currentTarget.contains(e.relatedTarget)||b(null)},onDrop:t=>{t.preventDefault();let n=m||t.dataTransfer.getData("text/plain"),i=v.find(e=>e.id===n);
1f(null),b(null),eO(i,e.drop)},style:{flex:"1 1 240px",minWidth:232,background:n?"".concat(r.color||c.gold,"14"):c.surfaceAlt,border:"1px ".concat(n?"dashed":"solid"," ").concat(n?r.color||c.gold:c.border),borderRadius:$.lg,padding:Q.sm,minHeight:320,transition:"background .12s"},children:[(0,i.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:6,padding:"4px 4px 8px"},children:[(0,i.jsx)("span",{style:{width:8,height:8,borderRadius:4,background:r.color||c.textMuted,flexShrink:0}}),(0,i.jsx)("span",{style:{fontSize:12,fontWeight:700,color:c.text,textTransform:"uppercase",letterSpacing:.6},children:e.label}),(0,i.jsx)("span",{style:{marginLeft:"auto",fontSize:11,fontFamily:K,color:c.textMuted},children:t.length}),e.clearable&&t.length>0&&(0,i.jsx)("button",{title:"Supprimer toutes les boutiques de cette colonne",disabled:!!M,onClick:()=>eH(e),style:{background:"transparent",border:"1px solid ".concat(c.border),borderRadius:$.pill,color:c.textMuted,fontSize:10,padding:"1px 7px",cursor:"pointer"},children:"clear"===M?"…":"Vider"})]}),e.hint&&(0,i.jsxs)("div",{style:{fontSize:10,color:c.textDim,padding:"0 4px 8px"},children:[e.hint,"in_sequence"===e.key&&(null==ej?void 0:ej.mode)!=="send"?" \xb7 mode brouillon : l'email attend dans Gmail":""]}),(0,i.jsxs)("div",{style:{display:"flex",flexDirection:"column",gap:6},children:[t.map(eZ),0===t.length&&(0,i.jsx)("div",{style:{fontSize:11,color:c.textDim,textAlign:"center",padding:"18px 6px",border:"1px dashed ".concat(c.border),borderRadius:$.md},children:"D\xe9poser ici"})]})]},e.key)})}),e>0&&(0,i.jsxs)("div",{style:{fontSize:11,color:c.textDim,marginTop:2}
1,children:[e," boutique(s) \xe9cart\xe9e(s) hors du tableau (exclues par l'IA, d\xe9sinscrites ou adresse invalide) :"," ",(0,i.jsx)("button",{onClick:()=>eI("list"),style:{background:"none",border:0,color:c.gold,cursor:"pointer",fontSize:11,padding:0,textDecoration:"underline"},children:"voir dans la liste"})]})]})})():(0,i.jsx)("div",{style:{...er(c),padding:0,overflow:"hidden"},children:(0,i.jsxs)("table",{style:{width:"100%",borderCollapse:"collapse",fontSize:13},children:[(0,i.jsx)("thead",{children:(0,i.jsx)("tr",{style:{background:c.surfaceAlt},children:["Boutique","Ville","Email","Statut","S\xe9quence","Activit\xe9"].map(e=>(0,i.jsx)("th",{style:{textAlign:"left",padding:"10px 14px",fontSize:11,textTransform:"uppercase",letterSpacing:1,color:c.textMuted,borderBottom:"1px solid ".concat(c.border)},children:e},e))})}),(0,i.jsx)("tbody",{children:v.map(e=>(0,i.jsxs)("tr",{onClick:()=>eM(e),style:{cursor:"pointer",borderBottom:"1px solid ".concat(c.border)},onMouseEnter:e=>e.currentTarget.style.background=c.surfaceAlt,onMouseLeave:e=>e.currentTarget.style.background="transparent",children:[(0,i.jsx)("td",{style:{padding:"10px 14px",color:c.text,fontWeight:600},children:e.name}),(0,i.jsxs)("td",{style:{padding:"10px 14px",color:c.textMuted},children:[e.city||"?",e.segment&&(0,i.jsxs)("span",{style:{color:c.textDim,fontSize:11},children:[" \xb7 ",tK[e.segment]||e.segment]})]}),(0,i.jsx)("td",{style:{padding:"10px 14px",color:e.email?c.text:c.orange,fontFamily:K,fontSize:12},children:e.email||"\xe0 trouver"}),(0,i.jsx)("td",{style:{padding:"10px 14px"},children:(0,i.jsx)(tZ,{status:e.status,t:c})}),(0,i.jsxs)("td",{style:{padding:"10px 14px",color:c.textMuted,fontSize:12},children:[e.sequence_step>0||"in_sequence"===e.status?"".concat(Math.min(e.sequence_step,3),"/3"):"\xb7",e.open_count>0&&(0,i.jsxs)("span",{title:"ouvert",style:{marginLeft:8,color:c.blue},children:["\uD83D\uDC41 ",e.open_count]}),e.click_count>0&&(0,i.jsxs)("span",{title:"cliqu\xe9",style:{marginLeft:6,color:c.gold},children:["\uD83D\uDD17 ",e.click_count]}),e.replied_at&&(0,i.jsx)("span",{title:"a r\xe9pondu",style:{marginLeft:6,color:c.green},children:"✉︎"})]}),(0,i.jsx)("td",{style:{padding:"10px 14px",color:c.textDim,fontSize:12,fontFamily:K},children:t$(e.last_open_at||e.updated_at)})]},e.id))})]})})]}),q&&(()=>{var e;let t=null==(e=q.enrichment)?void 0:e.classification,n=["qualified","to_verify","unresponsive","discovered"].includes(q.status)&&(H.email||q.email);return(0,i.jsxs)(eX,{onClose:()=>L(null),wide:!0,children:[(0,i.jsxs)("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"flex-start",marginBottom:Q.md},children:[(0,i.jsxs)("div",{children:[(0,i.jsx)("div",{style:{fontSize:18,fontWeight:700,color:c.text},children:q.name}),(0,i.jsxs)("div",{style:{fontSize:12,color:c.textMuted,marginTop:3},children:[[q.city,q.postal_code].filter(Boolean).join(" \xb7 "),q.website?(0,i.jsxs)(i.Fragment,{children:[" \xb7 ",(0,i.jsx)("a",{href:q.website,target:"_blank",rel:"noreferrer",style:{color:c.gold},children:"site web"})]}):null,q.google_place_id?" \xb7 via Google Places":"csv"===q.source?" \xb7 import CSV":" \xb7 saisie manuelle"]})]}),(0,i.jsxs)("div",{style:{display:"flex",gap:8,alignItems:"center"},children:[(0,i.jsx)(tZ,{status:q.status,t:c}),(0,i.jsx)("button",{onClick:()=>L(null),style:eJ,children:"Fermer"})]})]}),q.exclusion_reason&&(0,i.jsxs)("div",{style:{fontSize:12,color:c.red,background:"".concat(c.red,"14"),border:"1px solid ".concat(c.red,"30"),borderRadius:$.md,padding:"8px 12px",marginBottom:Q.md},children:["Motif d'exclusion : ",q.exclusion_reason]}),(0,i.jsxs)("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:Q.lg},children:[(0,i.jsxs)("div",{children:[(0,i.jsxs)("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:Q.sm},children:[(0,i.jsxs)("div",{children:[(0,i.jsx)("label",{style:et(c),children:"Email"}),(0,i.jsx)("input",{value:H.email,onChange:e=>V({...H,email:e.target.value}),style:{...eK,width:"100%"}})]}),(0,i.jsxs)("div",{children:[(0,i.jsx)("label",{style:et(c),children:"Ville"}),(0,i.jsx)("input",{value:H.city,onChange:e=>V({...H,city:e.target.value}),style:{...eK,width:"100%"}})]})]}),(0,i.jsxs)("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:Q.sm,marginTop:Q.sm},children:[(0,i.jsxs)("div",{children:[(0,i.jsx)("label",{style:et(c),children:"Site web"}),(0,i.jsx)("input",{value:H.website,onChange:e=>V({...H,website:e.target.value}),style:{...eK,width:"100%"}})]}),(0,i.jsxs)("div",{children:[(0,i.jsx)("label",{style:et(c),children:"Type de boutique (pilote les produits mis en avant)"}),(0,i.jsxs)("select",{value:H.segment,onChange:e=>V({...H,segment:e.target.value}),style:{...eK,width:"100%"},children:[(0,i.jsx)("option",{value:"",children:"Non d\xe9fini (s\xe9lection g\xe9n\xe9rale)"}),Object.entries(tK).map(e=>{let[t,n]=e;return(0,i.jsx)("option",{value:t,children:n},t)})]})]})]}),(0,i.jsx)("label",{style:{...et(c),marginTop:Q.sm},children:"Notes"}),(0,i.jsx)("textarea",{value:H.notes,onChange:e=>V({...H,notes:e.target.value}),style:{...ee(c),width:"100%",minHeight:50}}),(0,i.jsxs)("div",{style:{display:"flex",gap:8,marginTop:Q.sm,flexWrap:"wrap"},children:[(0,i.jsx)("button",{onClick:eL,disabled:"save"===M,style:eY,children:"save"===M?"…":"Enregistrer la fiche"}),(0,i.jsx)("button",{onClick:()=>eq("enrich1",()=>P({id:q.id}),{reload:!1}).then(e=>e&&eW(q.id)),disabled:!!M,style:eJ,children:"enrich1"===M?"Analyse…":"Analyser le site (IA)"})]}),t&&(0,i.jsxs)("div",{style:{...er(c),marginTop:Q.md,padding:Q.md,background:c.surfaceAlt},children:[(0,i.jsx)("div",{style:{fontSize:11,fontWeight:700,color:c.textMuted,textTransform:"uppercase",letterSpacing:1,marginBottom:6},children:"Profil IA"}),(0,i.jsxs)("div",{style:{fontSize:12,color:c.text,lineHeight:1.6},children:[t.summary,t.angle?(0,i.jsxs)("div",{style:{color:c.gold,marginTop:4},children:["Angle : ",t.angle]}):null,(0,i.jsxs)("div",{style:{color:c.textMuted,marginTop:4},children:["Type : ",t.shop_type,t.segment?" \xb7 Rayon : ".concat(tK[t.segment]||t.segment):""," \xb7 Concurrent : ",t.is_competitor?"oui":"non",t.competitor_brand?" (".concat(t.competitor_brand,")"):""," \xb7 Marques locales : ",t.sells_local_brands?"oui":"non"," \xb7 Confiance : ",Math.round(100*(t.confidence||0)),"%"]})]})]}),(0,i.jsxs)("div",{style:{marginTop:Q.md,display:"flex",gap:8,flexWrap:"wrap"},children:[["discovered","to_verify"].includes(q.status)&&(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)("button",{onClick:()=>eA("qualified"),disabled:!!M,style:ei(c.blue,c),children:"Qualifier"}),(0,i.jsx)("button",{onClick:()=>eA("excluded"),disabled:!!M,style:ei(c.textMuted,c),children:"Exclure"})]}),n&&"in_sequence"!==q.status&&(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)("button",{onClick:()=>eV(q),disabled:!!M,style:eY,children:(null==ej?void 0:ej.mode)==="send"?"Envoyer la pr\xe9sentation maintenant":"Cr\xe9er le brouillon de la pr\xe9sentation"}),(0,i.jsx)("button",{onClick:()=>
1eF(0),disabled:!!M,style:eJ,children:"Lancer la s\xe9quence (cron)"}),(0,i.jsx)("button",{onClick:()=>eF(1),disabled:!!M,style:eJ,children:"D\xe9marrer \xe0 la relance (email 2)"})]}),"in_sequence"===q.status&&(0,i.jsxs)(i.Fragment,{children:[q.sequence_step<3&&(0,i.jsx)("button",{onClick:()=>eV(q),disabled:!!M,style:eY,children:(null==ej?void 0:ej.mode)==="send"?"Envoyer l'email ".concat(q.sequence_step+1," maintenant"):"Cr\xe9er le brouillon de l'email ".concat(q.sequence_step+1)}),(0,i.jsx)("button",{onClick:()=>eq("stop",()=>O("stop",q.id),{reload:!1}).then(e=>{e&&(eW(q.id),eR())}),disabled:!!M,style:ei(c.orange,c),children:"Stopper la s\xe9quence"})]}),["replied","interested","in_sequence","unresponsive"].includes(q.status)&&(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)("button",{onClick:()=>eA("customer"),disabled:!!M,style:ei(c.purple,c),children:"Devenu client B2B"}),(0,i.jsx)("button",{onClick:()=>eA("refused"),disabled:!!M,style:ei(c.red,c),children:"Non int\xe9ress\xe9"})]}),"refused"===q.status&&(0,i.jsx)("button",{onClick:()=>eA("replied"),disabled:!!M,style:ei(c.green,c),children:"Remettre dans \xab A r\xe9pondu \xbb"}),(0,i.jsx)("button",{onClick:()=>eN(q),disabled:!!M,style:{...ei(c.red,c),marginLeft:"auto"},children:"Supprimer"})]}),(0,i.jsxs)("div",{style:{marginTop:Q.md},children:[(0,i.jsx)("div",{style:{fontSize:11,fontWeight:700,color:c.textMuted,textTransform:"uppercase",letterSpacing:1,marginBottom:6},children:"Aper\xe7u des emails"}),(0,i.jsx)("div",{style:{display:"flex",gap:6},children:[0,1,2].map(e=>(0,i.jsxs)("button",{onClick:()=>eE(e),disabled:!!M,style:(null==Y?void 0:Y.step)===e?eY:eJ,children:["Email ",e+1]},e))})]})]}),(0,i.jsx)("div",{children:Y?(0,i.jsxs)("div",{children:[(0,i.jsxs)("div",{style:{fontSize:12,color:c.textMuted,marginBottom:6},children:[Y.label," \xb7 Objet : ",(0,i.jsx)("span",{style:{color:c.text},children:Y.subject})]}),(0,i.jsx)("iframe",{title:"aper\xe7u",srcDoc:Y.html,sandbox:"",style:{width:"100%",height:420,border:"1px solid ".concat(c.border),borderRadius:$.md,background:"#fff"}})]}):(0,i.jsxs)("div",{children:[(0,i.jsx)("div",{style:{fontSize:11,fontWeight:700,color:c.textMuted,textTransform:"uppercase",letterSpacing:1,marginBottom:6},children:"Timeline"}),(0,i.jsxs)("div",{style:{maxHeight:460,overflowY:"auto",display:"flex",flexDirection:"column",gap:6},children:[0===A.length&&(0,i.jsx)("div",{style:{fontSize:12,color:c.textDim},children:"Aucun \xe9v\xe9nement pour l'instant."}),A.map(e=>{var t,n,r,l,o;return(0,i.jsxs)("div",{style:{fontSize:12,color:c.text,background:c.surfaceAlt,border:"1px solid ".concat(c.border),borderRadius:$.md,padding:"7px 10px"},children:[(0,i.jsx)("span",{style:{color:c.textMuted,fontFamily:K,fontSize:11},children:t$(e.created_at)})," \xb7 ",tY[e.type]||e.type,Number.isFinite(e.step)&&null!==e.step?" (email ".concat(e.step+1,")"):"",(null==(t=e.meta)?void 0:t.subject)?(0,i.jsx)("div",{style:{color:c.textMuted,marginTop:2},children:e.meta.subject}):null,(null==(n=e.meta)?void 0:n.excerpt)?(0,i.jsxs)("div",{style:{color:c.green,marginTop:2,fontStyle:"italic"},children:["\xab ",e.meta.excerpt.slice(0,140),"… \xbb"]}):null,(null==(r=e.meta)?void 0:r.exclusion_reason)?(0,i.jsx)("div",{style:{color:c.red,marginTop:2},children:e.meta.exclusion_reason}
1):null,"status_change"===e.type&&e.meta?(0,i.jsxs)("span",{style:{color:c.textMuted},children:[" : ",(null==(l=tG[e.meta.from])?void 0:l.label)||e.meta.from," → ",(null==(o=tG[e.meta.to])?void 0:o.label)||e.meta.to]}):null]},e.id)})]})]})})]})]})})(),en&&(0,i.jsxs)(eX,{onClose:()=>el(!1),children:[(0,i.jsx)("div",{style:{fontSize:16,fontWeight:700,color:c.text,marginBottom:Q.md},children:"Ajouter une boutique"}),[["name","Nom de la boutique *"],["city","Ville"],["email","Email"],["website","Site web"],["notes","Notes (salon, contact…)"]].map(e=>{let[t,n]=e;return(0,i.jsxs)("div",{style:{marginBottom:Q.sm},children:[(0,i.jsx)("label",{style:et(c),children:n}),(0,i.jsx)("input",{value:eo[t],onChange:e=>es({...eo,[t]:e.target.value}),style:{...eK,width:"100%"}})]},t)}),(0,i.jsx)("div",{style:{fontSize:11,color:c.textDim,marginBottom:Q.md},children:"Avec un email, la boutique est directement qualifi\xe9e (pr\xeate pour la s\xe9quence). Sans email, elle passe dans la file \xab \xe0 v\xe9rifier \xbb."}),(0,i.jsxs)("div",{style:{display:"flex",gap:8,justifyContent:"flex-end"},children:[(0,i.jsx)("button",{onClick:()=>el(!1),style:eJ,children:"Annuler"}),(0,i.jsx)("button",{disabled:!eo.name.trim()||!!M,onClick:()=>eq("add",()=>l("/prospection/prospects",{method:"POST",body:eo})).then(e=>{e&&(el(!1),eD("ok","Boutique ajout\xe9e"))}),style:eY,children:"add"===M?"…":"Ajouter"})]})]}),ea&&(0,i.jsxs)(eX,{onClose:()=>ed(!1),wide:!0,children:[(0,i.jsx)("div",{style:{fontSize:16,fontWeight:700,color:c.text,marginBottom:4},children:"Importer un CSV"}),(0,i.jsx)("div",{style:{fontSize:12,color:c.textMuted,marginBottom:Q.sm},children:"Fichier maison ou export Google Maps (Outscraper, PhantomBuster, Apify…) : les colonnes nom, ville, email, site, adresse, t\xe9l\xe9phone, cat\xe9gorie et identifiant Places sont reconnues en fran\xe7ais comme en anglais. Ville et code postal sont d\xe9duits de l'adresse. Sans en-t\xeate : nom, ville, email, site."}),(0,i.jsxs)("div",{style:{fontSize:12,color:c.textMuted,marginBottom:Q.md},children:["Pas d'email dans la liste ? C'est normal, Google Maps n'en fournit pas. Apr\xe8s l'import, \xab Enrichir (IA) \xbb retrouve le site via Places si besoin",ek?"":" (cl\xe9 GOOGLE_PLACES_API_KEY absente : seules les lignes avec un site seront enrichies)",", puis y cherche l'adresse email et qualifie la boutique."]}),(0,i.jsx)("input",{type:"file",accept:".csv,.tsv,.txt,text/csv",onChange:e=>{var t;let n=null==(t=e.target.files)?void 0:t[0];if(!n)return;let i=new FileReader;i.onload=()=>eu(String(i.result||"")),i.readAsText(n,"utf-8")},style:{fontSize:12,color:c.textMuted,marginBottom:Q.sm}}),(0,i.jsx)("textarea",{value:ec,onChange:e=>eu(e.target.value),placeholder:"nom;ville;email;site\nLa Boutique du Port;Toulon;[email protected];https://boutiqueduport.fr",style:{...ee(c),width:"100%",minHeight:180,fontFamily:K,fontSize:12}}),ep&&(0,i.jsxs)("div",{style:{fontSize:12,color:c.text,marginTop:Q.sm},children:[ep.total," ligne(s) lue(s) \xb7 ",ep.inserted," ajout\xe9e(s) \xb7 ",ep.duplicates," doublon(s) ignor\xe9(s)",ep.inserted>0?(0,i.jsx)("span",{style:{color:c.textMuted},children:" \xb7 lancez \xab Enrichir (IA) \xbb pour trouver sites et emails"}):null,(null==(d=ep.errors)?void 0:d.length)?(0,i.jsx)("div",{style:{color:c.orange,marginTop:4},children:ep.errors.slice(0,5).join(" \xb7 ")}):null]}),(0,i.jsxs)("div",{style:{display:"flex",gap:8,justifyContent:"flex-end",marginTop:Q.md},children:[(0,i.jsx)("button",{onClick:()=>ed(!1),style:eJ,children:"Fermer"}),(0,i.jsx)("button",{disabled:!ec.trim()||!!M,onClick:()=>eq("import",()=>l("/prospection/import",{method:"POST",body:{csv:ec}})).then(e=>{e&&ex(e)}),style:eY,children:"import"===M?"Import…":"Importer"})]})]}),eh&&(0,i.jsxs)(eX,{onClose:()=>em(!1),children:[(0,i.jsx)("div",{style:{fontSize:16,fontWeight:700,color:c.text,marginBottom:4},children:"Collecter des boutiques (Google Places)"}),!ek&&(0,i.jsx)("div",{style:{fontSize:12,color:c.orange,marginBottom:Q.md},children:"GOOGLE_PLACES_API_KEY absente des variables Vercel : ajoutez-la pour activer la collecte automatique."}),(0,i.jsx)("label",{style:et(c),children:"Ville"}),(0,i.jsx)("input",{list:"prospection-cities",value:ef,onChange:e=>ey(e.target.value),placeholder:"Toulon",style:{...eK,width:"100%"}}),(0,i.jsx)("datalist",{id:"prospection-cities",children:((null==ej?void 0:ej.cities)||[]).map(e=>(0,i.jsx)("option",{value:e},e))}),(0,i.jsxs)("div",{style:{fontSize:11,color:c.textDim,margin:"".concat(Q.sm,"px 0 ").concat(Q.md,"px")},children:["Recherches lanc\xe9es : ",((null==ej?void 0:ej.placesQueries)||[]).join(", ")||"boutique souvenirs, concept store",". Les boutiques d\xe9couvertes arrivent au statut \xab D\xe9couvert \xbb, puis \xab Enrichir (IA) \xbb les qualifie ou les exclut."]}),eb&&(0,i.jsxs)("div",{style:{fontSize:12,color:c.text,marginBottom:Q.md},children:[eb.found," trouv\xe9e(s) \xb7 ",eb.inserted," nouvelle(s) \xb7 ",eb.skipped," d\xe9j\xe0 connue(s)"]}),(0,i.jsxs)("div",{style:{display:"flex",gap:8,justifyContent:"flex-end"},children:[(0,i.jsx)("button",{onClick:()=>em(!1),style:eJ,children:"Fermer"}),(0,i.jsx)("button",{disabled:!ef.trim()||!ek||!!M,onClick:()=>eq("collect",()=>l("/prospection/collect",{method:"POST",body:{city:ef,query:void 0}})).then(e=>{e&&ev(e)}),style:eY,children:"collect"===M?"Collecte…":"Collecter"})]})]})]})}let t2=(()=>{let e=new Uint32Array(256);for(let t=0;t<256;t++){let n=t;for(let e=0;e<8;e++)n=1&n?0xedb88320^n>>>1:n>>>1;e[t]=n>>>0}return e})(),t6=[{id:"model",label:"Mod\xe8le",hint:"Vrai mod\xe8le humain, photo \xe9ditoriale r\xe9aliste",human:!0},{id:"ghost",label:"Ghost mannequin",hint:"Port\xe9 invisible, packshot premium"},{id:"flatlay",label:"Flat lay",hint:"\xc0 plat, motifs bien lisibles"},{id:"lifestyle",label:"Lifestyle",hint:"Mise en sc\xe8ne, mood de marque"}],t4=[{id:"tshirt",label:"T-shirt",hint:"Motifs cœur/dos, coupe, couleur",garment:!0},{id:"sweat",label:"Sweat",hint:"Motifs cœur/dos, coupe, couleur",garment:!0},{id:"hoodie",label:"Hoodie",hint:"Capuche, motifs cœur/dos, couleur",garment:!0},{id:"polo",label:"Polo",hint:"Col polo boutonn\xe9, motifs cœur/dos, couleur",garment:!0},{id:"vetement",label:"Autre v\xeatement",hint:"Coupe reproduite depuis votre photo de r\xe9f\xe9rence",garment:!0},{id:"bracelet",label:"Bracelet",hint:"Port\xe9 au poignet",worn:"port\xe9 au poignet du mod\xe8le, bien visible et net",closeup:!0},{id:"maillot",label:"Maillot de bain",hint:"Port\xe9, ambiance estivale",worn:"port\xe9 par le mod\xe8le dans une mise en sc\xe8ne estivale (plage, piscine, lumi\xe8re solaire chaude)",hasBack:!0},{id:"casquette",label:"Casquette",hint:"Port\xe9e sur la t\xeate",worn:"port\xe9e sur la t\xeate, bien ajust\xe9e, le visuel frontal lisible et non d\xe9form\xe9"},{id:"tote",label:"Tote bag",hint:"Port\xe9 \xe0 l'\xe9paule / main",worn:"port\xe9 \xe0 l'\xe9paule ou tenu \xe0 la main, le visuel imprim\xe9 bien lisible et non d\xe9form\xe9"},{id:"autre",label:"Autre produit",hint:"Photo + description libre",worn:"port\xe9 ou utilis\xe9 de fa\xe7on naturelle et r\xe9aliste par le mod\xe8le",free:!0}];function t5(e){let t=t4.find(t=>
1t.id===e);return!!(t&&t.garment)}let t3=[{id:"square",label:"Carr\xe9 1:1"},{id:"portrait",label:"Portrait"},{id:"landscape",label:"Paysage"}],t8=[{id:"print",label:"Imprim\xe9",noun:"imprim\xe9 DTF"},{id:"embroidery",label:"Broderie",noun:"broderie directe"},{id:"patch_brode",label:"Patch brod\xe9",noun:"\xe9cusson brod\xe9 cousu"},{id:"patch_silicone",label:"Patch silicone",noun:"patch silicone 3D"}],t7=[{id:"bust",label:"Buste"},{id:"waist",label:"Plan taille"},{id:"full",label:"Corps entier"},{id:"mix",label:"Mix"}],t9=[{id:"white",label:"Blanc",hex:"#f5f3ee",prompt:"blanc"},{id:"ecru",label:"\xc9cru",hex:"#e8dfce",prompt:"\xe9cru, blanc cass\xe9 naturel"},{id:"sand",label:"Sable",hex:"#cbb894",prompt:"sable beige clair"},{id:"black",label:"Noir",hex:"#1a1714",prompt:"noir profond"},{id:"navy",label:"Marine",hex:"#2b3a55",prompt:"bleu marine"},{id:"olive",label:"Olive",hex:"#6b6a45",prompt:"vert olive"},{id:"terracotta",label:"Terracotta",hex:"#b5654a",prompt:"terracotta, ocre rouge"},{id:"grey",label:"Gris chin\xe9",hex:"#9a958c",prompt:"gris chin\xe9"}],ne={humanRealism:"PHOTOGRAPHIE R\xc9ELLE, ce n'est PAS une image g\xe9n\xe9r\xe9e. V\xe9ritable mod\xe8le HUMAIN professionnel, r\xe9ellement photographi\xe9, attitude \xe9ditoriale VIVANTE et naturelle (surtout PAS de pose fig\xe9e droite face cam\xe9ra au garde-\xe0-vous). Peau hyper-r\xe9aliste : subsurface scattering, micro-relief et texture visible, pores, grain de peau, fin duvet, variations naturelles de teint et de rougeur, quelques grains de beaut\xe9 et imperfections, brillance localis\xe9e subtile, AUCUN lissage ni effet beaut\xe9. Cils individuels nets, sourcils naturels parfois irr\xe9guliers, reflets de lumi\xe8re r\xe9alistes dans les yeux (catchlights), iris d\xe9taill\xe9s. Cheveux d'aspect vraie photo : brins individuels visibles, m\xe8ches folles et quelques cheveux rebelles (baby hairs, frisottis), volume et retomb\xe9e naturels, reflets doux et irr\xe9guliers — jamais lisses-plastique ni casqu\xe9s. Le visage pr\xe9sente une asym\xe9trie naturelle. Rendu \xe9ditorial de mode, naturel et NON retouch\xe9.",antiSlop:"INTERDIT (signaux d'image IA \xe0 bannir) : peau plastique, cireuse ou \xab poreless \xbb, sur-lissage beaut\xe9, teint trop uniforme et lumineux, rendu 3D / CGI / type Pixar, sur-saturation, contraste HDR artificiel, halo ou contour trop net autour du sujet, bokeh trop parfait, yeux vitreux ou trop brillants, dents irr\xe9elles, sym\xe9trie parfaite du visage, cheveux lisses-plastique, vernis, \xab casqu\xe9s \xbb type perruque ou fondus en un bloc compact, pose raide et fig\xe9e, arri\xe8re-plan au flou artificiel, mains ou doigts d\xe9form\xe9s, accessoires fondus dans le corps, texte ou logo invent\xe9, filigrane. Si un d\xe9tail para\xeet \xab trop parfait \xbb, rends-le plus naturel et imparfait.",baseDirection:"Qualit\xe9 studio professionnelle, exposition ma\xeetris\xe9e, nettet\xe9 irr\xe9prochable, couleurs fid\xe8les. Aucun texte ni filigrane ajout\xe9s en dehors du motif fourni.",poses:["posture d\xe9contract\xe9e, l\xe9ger d\xe9hanch\xe9, poids sur une jambe, \xe9paules rel\xe2ch\xe9es, une main dans la poche, regard hors champ","capt\xe9 sur le vif en pleine marche vers l'objectif, foul\xe9e naturelle, bras qui balancent, cheveux et tissu en l\xe9ger mouvement","appuy\xe9 d'une \xe9paule contre un mur, jambes crois\xe9es \xe0 la cheville, une main dans la poche, expression calme et naturelle","en plein \xe9clat de rire, t\xeate l\xe9g\xe8rement rejet\xe9e en arri\xe8re, \xe9paules rel\xe2ch\xe9es, \xe9nergie spontan\xe9e et joyeuse","de trois-quarts, poids sur une jambe, hanche d\xe9hanch\xe9e, une main qui remonte dans les cheveux, regard de c\xf4t\xe9","accroupi avec aisance, un avant-bras pos\xe9 sur le genou, regard hors champ, attitude pos\xe9e et naturelle","capt\xe9 en train de se retourner comme surpris en plein mouvement, buste pivot\xe9, dynamique et vivant","les deux mains gliss\xe9es dans les poches arri\xe8re, \xe9paules basses, posture nonchalante et assur\xe9e","adoss\xe9 \xe0 un mur, une jambe repli\xe9e le pied contre le mur, visage tourn\xe9 vers la lumi\xe8re, expression sereine","en train d'ajuster d'un geste naturel l'ourlet ou la manche du t-shirt, regard baiss\xe9, attitude candide","assis sur une marche ou un muret, coudes pos\xe9s sur les genoux, dos d\xe9tendu, l\xe9ger sourire","assis \xe0 califourchon sur une chaise, bras crois\xe9s souplement sur le dossier, menton rel\xe2ch\xe9, regard direct","l\xe9ger pas de c\xf4t\xe9 dynamique comme en train de bouger doucement en musique, sourire en coin","une main en visi\xe8re au-dessus des yeux face \xe0 la lumi\xe8re, l'autre sur la hanche, posture vivante","pench\xe9 l\xe9g\xe8rement en avant comme en pleine conversation, mains rel\xe2ch\xe9es, rire naturel","debout d\xe9tendu, bras crois\xe9s tout en souplesse, poids sur une jambe, regard de c\xf4t\xe9, attitude cool","assis par terre adoss\xe9 \xe0 un mur, une jambe tendue l'autre repli\xe9e, mains rel\xe2ch\xe9es, ambiance lounge","t\xeate l\xe9g\xe8rement inclin\xe9e, une main effleurant la nuque, sourire discret et naturel, \xe9paules basses","appui dynamique sur une jambe avec l\xe9ger twist du buste, \xe9paules ouvertes, expression vivante","marchant de profil capt\xe9 sur le vif, une main tenant une veste jet\xe9e sur l'\xe9paule, allure libre"],poseBack:["de dos, t\xeate tourn\xe9e en trois-quarts par-dessus l'\xe9paule, regard vers l'objectif, \xe9paules rel\xe2ch\xe9es","de dos en pleine marche, foul\xe9e saisie sur le vif, bras qui balancent naturellement","de dos, une main dans la poche arri\xe8re, l'autre remontant vers la nuque, hanche l\xe9g\xe8rement d\xe9hanch\xe9e","de dos adoss\xe9 \xe0 un mur, une \xe9paule contre la paroi, visage de profil tourn\xe9 vers la lumi\xe8re","de dos en train de se retourner, buste pivot\xe9, mouvement dynamique et vivant","de dos assis sur une marche, dos souplement courb\xe9, t\xeate tourn\xe9e de c\xf4t\xe9, posture d\xe9tendue","de dos, les deux mains dans les poches, \xe9paules basses, attitude nonchalante, regard au loin","de dos en marchant tout en regardant par-dessus l'\xe9paule, cheveux en l\xe9ger mouvement","de dos avec un l\xe9ger twist du buste, un bras \xe0 demi crois\xe9 visible de c\xf4t\xe9, posture vivante","de dos, une main qui ajuste le col ou ram\xe8ne les cheveux, geste naturel et candide","de dos en pleine marche \xe9nergique, une veste tenue d'un doigt jet\xe9e sur l'\xe9paule, foul\xe9e capt\xe9e en plein mouvement","de dos, bras lev\xe9s en train de rassembler les cheveux \xe0 deux mains, coudes ouverts, posture vivante et naturelle","de dos en l\xe9ger pas saut\xe9 capt\xe9 sur le vif, cheveux et tissu en mouvement, \xe9nergie spontan\xe9e et joyeuse","de dos en train de s'\xe9tirer bras tendus vers le ciel, buste allong\xe9, attitude solaire et d\xe9tendue","de dos en train de danser doucement, poids sur une jambe, bras souples en mouvement, ambiance l\xe9g\xe8re","de dos, une main tendue vers l'avant comme pour montrer quelque chose hors champ, corps en l\xe9g\xe8re extension, vivant","de dos appuy\xe9 des deux avant-bras sur un muret, buste pench\xe9 vers l'avant, t\xeate tourn\xe9e de profil, posture d\xe9tendue","de dos marchant vers la lumi\xe8re, un bras lev\xe9 saluant quelqu'un hors champ, allure libre et spontan\xe9e"],shotFragments:{ghost:"Packshot e-commerce en ghost mannequin : le t-shirt prend une forme port\xe9e tridimensionnelle r\xe9aliste sans aucune personne ni buste visible, volume et tomb\xe9 du tissu nets, int\xe9rieur du col propre, fond studio neutre et homog\xe8ne.",flatlay:"Packshot \xe0 plat (flat lay) vu du dessus, t-shirt pos\xe9 bien \xe0 plat sur une surface neutre textur\xe9e, plis ma\xeetris\xe9s et naturels, lumi\xe8re douce rasante r\xe9v\xe9lant la mati\xe8re, motif parfaitement lisible et non d\xe9form\xe9.",lifestyle:"Mise en sc\xe8ne lifestyle \xe9ditoriale dans un d\xe9cor \xe9voquant le Sud de la France (lumi\xe8re chaude de fin de journ\xe9e, pierre claire, lin, mati\xe8res naturelles), t-shirt pr\xe9sent\xe9 sur cintre ou drap\xe9 avec soin, ambiance de marque haut de gamme."}},nt=[{key:"humanRealism",label:"R\xe9alisme & peau (mod\xe8le humain)",kind:"text"},{key:"antiSlop",label:"Interdits anti-IA",kind:"text"},{key:"poses",label:"Poses de face (une par ligne, tir\xe9es au hasard)",kind:"list"},{key:"poseBack",label:"Poses de dos (une par ligne, tir\xe9es au hasard)",kind:"list"},{key:"baseDirection",label:"Directive de base",kind:"text"},{key:"shotFragments.ghost",label:"Description — Ghost mannequin",kind:"text"},{key:"shotFragments.flatlay",label:"Description — Flat lay",kind:"text"},{key:"shotFragments.lifestyle",label:"Description — Lifestyle",kind:"text"}],nn=[{id:"clean",name:"Studio clean (e-com)",da_prompt:"Packshot e-commerce premium : fond seamless uni et clair (blanc cass\xe9 / gris tr\xe8s doux), parfaitement homog\xe8ne et sans texture parasite. Lumi\xe8re de studio douce et enveloppante (grande softbox en key l\xe9g\xe8rement de trois-quarts + fill pour des ombres tr\xe8s douces, ratio faible ~2:1), temp\xe9rature neutre l\xe9g\xe8rement chaude, restitution fid\xe8le des couleurs ; colorim\xe9trie neutre, contraste ma\xeetris\xe9, saturation mod\xe9r\xe9e. Nettet\xe9 irr\xe9prochable sur tout le sujet, profondeur de champ moyenne, pas de grain marqu\xe9, aucune dominante. Cadrage centr\xe9 qui laisse respirer le sujet. Pose : posture nette et soign\xe9e, attitude pos\xe9e et assur\xe9e, mains 
1naturelles, regard direct ou l\xe9g\xe8rement de c\xf4t\xe9. Ambiance \xe9pur\xe9e, propre, haut de gamme et intemporelle ; sujet bien d\xe9gag\xe9 du fond par la lumi\xe8re, sans halo ni contour artificiel."},{id:"lifestyle",name:"Lifestyle Sud",da_prompt:"Lifestyle \xe9ditorial dans le Sud de la France : lumi\xe8re naturelle chaude de fin d'apr\xe8s-midi (golden hour), directionnelle et douce, ombres longues et vivantes, l\xe9g\xe8re brume dor\xe9e. Colorim\xe9trie chaude et ensoleill\xe9e, palette m\xe9diterran\xe9enne — pierre claire, terre cuite, ocre, vert olive, bleu d\xe9lav\xe9, blanc lin. D\xe9cor ext\xe9rieur naturel (mur de pierre, ruelle proven\xe7ale, terrasse ombrag\xe9e, v\xe9g\xe9tation s\xe8che). Rendu argentique chaud type Kodak Portra 400, grain fin, faible profondeur de champ et bokeh doux, l\xe9g\xe8re halation dans les hautes lumi\xe8res. Cadrage lifestyle, sujet int\xe9gr\xe9 au d\xe9cor. Pose : attitude d\xe9contract\xe9e et candide, capt\xe9e sur le vif (en marche, en train de rire, l\xe9ger mouvement), gestuelle naturelle, regard souvent hors champ. Ambiance estivale, solaire, d\xe9contract\xe9e et authentique."},{id:"editorial",name:"\xc9ditorial",da_prompt:"\xc9ditorial mode contrast\xe9 : lumi\xe8re sculptante et plus dramatique (key dure ou semi-dure directionnelle, ombres nettes et marqu\xe9es, ratio \xe9lev\xe9), \xe9talonnage riche l\xe9g\xe8rement d\xe9satur\xe9 avec des noirs profonds et des teintes froides ou neutres. Fond minimal ou textur\xe9 (b\xe9ton, toile, mur brut) volontairement en retrait. Optique nette, rendu cin\xe9matographique, grain argentique pr\xe9sent et assum\xe9. Composition affirm\xe9e, cadrage serr\xe9 ou d\xe9centr\xe9, lignes graphiques. Pose : attitude forte et styl\xe9e, lignes du corps marqu\xe9es, regard intense, dynamisme ma\xeetris\xe9. \xc9nergie de magazine de mode."}];function ni(e){let{t:t,active:n}=e,[o,s]=(0,r.useState)(""),[a,d]=(0,r.useState)([]),[c,u]=(0,r.useState)(!1),[p,g]=(0,r.useState)(null),[x,h]=(0,r.useState)([]),[m,f]=(0,r.useState)("all"),[y,b]=(0,r.useState)("ai"),[v,j]=(0,r.useState)(!1),[S,k]=(0,r.useState)({}),[w,C]=(0,r.useState)(!1),[_,z]=(0,r.useState)(null),[T,D]=(0,r.useState)(!1),[R,I]=(0,r.useState)([]),[M,W]=(0,r.useState)(!1),[q,F]=(0,r.useState)(null),[E,B]=(0,r.useState)(null),P=function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"info";z({message:e,type:t}),setTimeout(()=>z(null),4e3)},O=async()=>{if(o.trim()){u(!0);try{let e=await L(o.trim());e.success&&d(e.products)}catch(e){P(e.message,"error")}finally{u(!1)}}},U=async e=>{g(e),h([]),k({}),j(!0);try{let t,n=await (t=e.id,l("/studio/catalog/images?productId=".concat(encodeURIComponent(t))));n.success?h(n.images||[]):P(n.error||"Lecture impossible","error")}catch(e){P(e.message,"error")}finally{j(!1)}},N=(0,r.useCallback)(e=>"all"===m||1===e.position,[m]),H=x.filter(e=>!e.isSquare&&null!=e.ratio&&N(e)),V=(0,r.useCallback)(async e=>{k(t=>({...t,[e.id]:{loading:!0}}));try{let t,n=await (t=e.src,l("/studio/catalog/squareify",{method:"POST",body:{imageUrl:t,mode:y}}));n.success?k(t=>({...t,[e.id]:{loading:!1,squareUrl:n.squareUrl,storagePath:n.storagePath,wasSquare:n.wasSquare,method:n.method}})):k(t=>({...t,[e.id]:{loading:!1,error:n.error||"\xc9chec"}}))}catch(t){k(n=>({...n,[e.id]:{loading:!1,error:t.message}}))}},[y]),Y=async()=>{for(let t of H){var e;(null==(e=S[t.id])?void 0:e.squareUrl)||await V(t)}},J=()=>H.filter(e=>{var t,n;return(null==(t=S[e.id])?void 0:t.squareUrl)&&!(null==(n=S[e.id])?void 0:n.wasSquare)}).map(e=>({imageId:e.id,originalUrl:e.src,alt:e.alt,position:e.position,variant_ids:e.variant_ids,squareUrl:S[e.id].squareUrl,storagePath:S[e.id].storagePath})),X=async()=>{let e=J();if(!e.length)return void P("G\xe9n\xe9rez d'abord au moins un aper\xe7u.","error");if(window.confirm("Remplacer ".concat(e.length," image(s) par leur version 1:1 sur \xab ").concat(p.title," \xbb ? Les originales sont sauvegard\xe9es (restaurables 30 j)."))){C(!0);try{let t,n=await (t={productId:p.id,productTitle:p.title,items:e},l("/studio/catalog/apply",{method:"POST",body:t}));n.success?(P("".concat(n.applied,"/").concat(n.total," image(s) remplac\xe9e(s)."),"success"),await U(p)):P(n.error||"Application impossible","error")}catch(e){P(e.message,"error")}finally{C(!1)}}},ee=(0,r.useCallback)(async()=>{W(!0);try{let e=await l("/studio/catalog/backups");e.success&&I(e.batches||[])}catch(e){P(e.message,"error")}finally{W(!1)}},[]);(0,r.useEffect)(()=>{n&&T&&ee()},[n,T,ee]);let et=async e=>{if(window.confirm("Restaurer les ".concat(e.counts.replaced," image(s) originale(s) de \xab ").concat(e.productTitle||e.productId," \xbb ? Les versions 1:1 seront retir\xe9es de Shopify."))){F(e.batchId);try{let t,n=await (t={batchId:e.batchId},l("/studio/catalog/restore",{method:"POST",body:t}));n.success?(P("".concat(n.restored," image(s) restaur\xe9e(s)."),"success"),await ee()):P(n.error||"Restauration impossible","error")}catch(e){P(e.message,"error")}finally{F(null)}}},en=async()=>{let e="main"===m?"l'image principale":"toutes les images 4:5";if(window.confirm("Convertir ".concat(e," en 1:1 sur TOUT le catalogue ?\n\nLe remplacement est direct (sans aper\xe7u) mais chaque originale est sauvegard\xe9e et restaurable 30 jours. Cette op\xe9ration peut \xeatre longue."))){B({running:!0,done:0,total:0,converted:0,failed:0,product:""});try{let e=(await l("/studio/catalog/products")).products||[];B(t=>({...t,total:e.length}));let t="undefined"!=typeof crypto&&crypto.randomUUID?crypto.randomUUID():String(Date.now()),n=0,i=0;for(let r of e){B(e=>({...e,product:r.title}));try{let e=await A({productId:r.id,productTitle:r.title,scope:m,batchId:t,mode:y});e.success?n+=e.converted||0:i+=1}catch(e){i+=1}B(e=>({...e,done:e.done+1,converted:n,failed:i}))}B(e=>({...e,running:!1})),P("Catalogue converti : ".concat(n," image(s) sur ").concat(e.length," produit(s)").concat(i?", ".concat(i," \xe9chec(s)"):"","."),i?"error":"success")}catch(e){B(null),P(e.message,"error")}}},er=(0,i.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:Q.sm,flexWrap:"wrap"},children:[(0,i.jsx)("span",{style:{fontSize:11,color:t.textMuted},children:"Port\xe9e :"}),[["main","Image principale"],["all","Toutes les 4:5"]].map(e=>{let[n,r]=e;return(0,i.jsx)("button",{onClick:()=>f(n),style:eo(m===n,t),children:r},n)})]}),el=(0,i.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:Q.sm,flexWrap:"wrap"},children:[(0,i.jsx)("span",{style:{fontSize:11,color:t.textMuted},children:"Extension :"}),[["ai","IA (Gemini)"],["flat","Bords nets (sans IA)"]].map(e=>{let[n,r]=e;return(0,i.jsx)("button",{onClick:()=>b(n),style:eo(y===n,t),title:"ai"===n?"Gemini prolonge r\xe9ellement la sc\xe8ne de la photo sur les c\xf4t\xe9s (pas de fond g\xe9n\xe9rique)":"Prolonge nettement le bord sans IA — d\xe9pannage sur fond parfaitement uni",children:r},n)})]});return(0,i.jsxs)("div",{style:{flex:1,overflowY:"auto",padding:Q.xxl,maxWidth:1100,margin:"0 auto",width:"100%",fontFamily:G},children:[(0,i.jsxs)("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"flex-end",gap:Q.lg,flexWrap:"wrap",marginBottom:Q.xl},children:[(0,i.jsxs)("div",{children:[(0,i.jsx)("div",{style:{fontSize:15,fontFamily:G},children:"Catalogue \xb7 Format carr\xe9 Meta Ads"}),(0,i.jsx)("div",{style:{fontSize:11,color:t.textMuted,marginTop:2,maxWidth:560,lineHeight:1.5},children:"Passe les visuels produit 4:5 en 1:1 : l'IA g\xe9n\xe8re les bords manquants (le produit reste intact au centre), pour des cr\xe9as catalogue sans bande blanche. L'originale est sauvegard\xe9e et restaurable 30 jours."})]}),(0,i.jsx)("button",{onClick:()=>D(e=>!e),style:{...ei(null,t),whiteSpace:"nowrap"},children:T?"← Conversion":"Sauvegardes / Restaurer"})]}),_&&(0,i.jsx)("div",{style:{marginBottom:Q.lg,padding:"".concat(Q.sm,"px ").concat(Q.md,"px"),borderRadius:$.md,fontSize:12,background:"error"===_.type?"".concat(t.red,"12"):"success"===_.type?"".concat(t.green,"12"):t.surfaceAlt,color:"error"===_.type?t.red:"success"===_.type?t.green:t.text,border:"1px solid ".concat(t.border)},children:_.message}),T?(0,i.jsx)("div",{style:{display:"flex",flexDirection:"column",gap:Q.md},children:M?(0,i.jsx)("div",{style:{fontSize:12,color:t.textDim},children:"Chargement…"}):0===R.length?(0,i.jsx)(eg,{t:t,icon:"⧉",title:"Aucune sauvegarde",description:"Les conversions appliqu\xe9es appara\xeetront ici, restaurables pendant 30 jours."}):R.map(e=>(0,i.jsxs)("div",{style:{border:"1px solid ".concat(t.border),borderRadius:$.md,padding:Q.md,background:t.surface,display:"flex",justifyContent:"space-between",alignItems:"center",gap:Q.md},children:[(0,i.jsxs)("div",{children:[(0,i.jsx)("div",{style:{fontSize:13,color:t.text,fontWeight:500},children:e.productTitle||e.productId}
1),(0,i.jsxs)("div",{style:{fontSize:10,color:t.textDim,marginTop:2,fontFamily:K},children:[new Date(e.createdAt).toLocaleString("fr-FR")," \xb7 ",e.counts.replaced," remplac\xe9e(s)",e.counts.restored?" \xb7 ".concat(e.counts.restored," restaur\xe9e(s)"):"",e.counts.failed?" \xb7 ".concat(e.counts.failed," \xe9chec(s)"):""]})]}),e.counts.replaced>0&&(0,i.jsx)("button",{onClick:()=>et(e),disabled:q===e.batchId,style:{...ei(t.gold,t),whiteSpace:"nowrap",opacity:q===e.batchId?.6:1},children:q===e.batchId?"Restauration…":"↺ Restaurer"})]},e.batchId))}):p?(0,i.jsxs)("div",{children:[(0,i.jsxs)("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",gap:Q.md,marginBottom:Q.lg,flexWrap:"wrap"},children:[(0,i.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:Q.md},children:[(0,i.jsx)("button",{onClick:()=>{g(null),h([]),k({})},style:{...ei(null,t),padding:"4px 10px"},children:"← Produits"}),(0,i.jsx)("span",{style:{fontSize:14,color:t.text,fontWeight:500},children:p.title})]}),(0,i.jsxs)("div",{style:{display:"flex",gap:Q.sm},children:[H.length>0&&(0,i.jsxs)("button",{onClick:Y,style:ei(null,t),children:["G\xe9n\xe9rer tous les aper\xe7us (",H.length,")"]}),J().length>0&&(0,i.jsx)("button",{onClick:X,disabled:w,style:{...ei(t.gold,t),background:t.gold,color:t.bg,opacity:w?.6:1},children:w?"Application…":"Appliquer sur Shopify (".concat(J().length,")")})]})]}),(0,i.jsxs)("div",{style:{display:"flex",flexDirection:"column",gap:Q.sm,marginBottom:Q.lg},children:[er,el]}),v?(0,i.jsx)("div",{style:{fontSize:12,color:t.textDim},children:"Chargement des images…"}):0===x.length?(0,i.jsx)(eg,{t:t,icon:"❏",title:"Aucune image",description:"Ce produit n'a pas d'image sur Shopify."}):(0,i.jsxs)(i.Fragment,{children:[0===H.length&&(0,i.jsx)("div",{style:{fontSize:12,color:t.green,marginBottom:Q.md},children:"main"===m?"✓ L'image principale est d\xe9j\xe0 en 1:1.":"✓ Toutes les images sont d\xe9j\xe0 en 1:1."}),(0,i.jsx)("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fill, minmax(220px, 1fr))",gap:Q.lg},children:x.map(e=>{let n,r=e.isSquare?{text:"1:1",color:"green"}:null==e.ratio?{text:"?",color:"dim"}:.03>Math.abs(e.ratio-.8)?{text:"4:5",color:"orange"}:{text:e.ratio.toFixed(2),color:"orange"},l=S[e.id];return(0,i.jsxs)("div",{style:{border:"1px solid ".concat(t.border),borderRadius:$.md,overflow:"hidden",background:t.surface},children:[(0,i.jsxs)("div",{style:{position:"relative",background:t.bg,display:"grid",gridTemplateColumns:(null==l?void 0:l.squareUrl)?"1fr 1fr":"1fr"},children:[(0,i.jsx)("img",{src:e.src,alt:"",style:{width:"100%",aspectRatio:"1/1",objectFit:"contain",background:t.surfaceAlt}}),(null==l?void 0:l.squareUrl)&&(0,i.jsx)("img",{src:l.squareUrl,alt:"aper\xe7u 1:1",style:{width:"100%",aspectRatio:"1/1",objectFit:"cover",borderLeft:"1px solid ".concat(t.border)}}),(0,i.jsx)("span",{style:{position:"absolute",top:6,left:6,fontSize:9,fontWeight:700,padding:"2px 6px",borderRadius:$.pill,background:t.bg,color:"green"===(n=r.color)?t.green:"orange"===n?t.gold:t.textDim,border:"1px solid ".concat(t.border)},children:r.text}),1===e.position&&(0,i.jsx)("span",{style:{position:"absolute",top:6,right:6,fontSize:9,fontWeight:700,padding:"2px 6px",borderRadius:$.pill,background:t.gold,color:t.bg},children:"Principale"})]}),(0,i.jsx)("div",{style:{padding:Q.sm},children:e.isSquare?(0,i.jsx)("span",{style:{fontSize:11,color:t.green},children:"D\xe9j\xe0 1:1"}):N(e)?(null==l?void 0:l.loading)?(0,i.jsx)("span",{style:{fontSize:11,color:t.textDim},children:"G\xe9n\xe9ration…"}):(null==l?void 0:l.error)?(0,i.jsx)("span",{style:{fontSize:11,color:t.red},children:l.error}):(null==l?void 0:l.squareUrl)?(0,i.jsxs)("span",{style:{fontSize:11,color:t.green},children:["✓ Aper\xe7u pr\xeat \xb7 ","extend"===l.method?"bords nets":"extension IA"]}):(0,i.jsx)("button",{onClick:()=>V(e),style:{...ei(null,t),width:"100%",justifyContent:"center"},children:"Passer en 1:1 (IA)"}):(0,i.jsx)("span",{style:{fontSize:11,color:t.textDim},children:"Hors p\xe9rim\xe8tre (principale seulement)"})})]},e.id)})})]})]}):(0,i.jsxs)("div",{style:{maxWidth:640},children:[(0,i.jsxs)("div",{style:{border:"1px solid ".concat(t.border),borderRadius:$.md,padding:Q.lg,background:t.surface,marginBottom:Q.xl},children:[(0,i.jsx)("div",{style:{fontSize:13,color:t.text,fontWeight:600,marginBottom:4}
1,children:"Tout le catalogue d'un coup"}),(0,i.jsx)("div",{style:{fontSize:11,color:t.textMuted,lineHeight:1.5,marginBottom:Q.md},children:"Convertit en 1:1 sur l'ensemble des produits, sans aper\xe7u (remplacement direct). Chaque originale est sauvegard\xe9e et restaurable 30 jours via \xab Sauvegardes / Restaurer \xbb."}),(0,i.jsxs)("div",{style:{display:"flex",flexDirection:"column",gap:Q.sm,marginBottom:Q.sm},children:[er,el]}),(0,i.jsx)("button",{onClick:en,disabled:null==E?void 0:E.running,style:{...ei(t.gold,t),background:t.gold,color:t.bg,opacity:(null==E?void 0:E.running)?.6:1,whiteSpace:"nowrap"},children:(null==E?void 0:E.running)?"Conversion en cours…":"Convertir tout le catalogue"}),E&&(0,i.jsxs)("div",{style:{marginTop:Q.md},children:[(0,i.jsx)("div",{style:{height:6,borderRadius:3,background:t.surfaceAlt,overflow:"hidden"},children:(0,i.jsx)("div",{style:{height:"100%",width:"".concat(E.total?Math.round(E.done/E.total*100):0,"%"),background:t.gold,transition:"width 0.3s ease"}})}),(0,i.jsxs)("div",{style:{fontSize:10,color:t.textDim,marginTop:6,fontFamily:K},children:[E.done,"/",E.total||"…"," produit(s) \xb7 ",E.converted," image(s) converties",E.failed?" \xb7 ".concat(E.failed," \xe9chec(s)"):"",E.running&&E.product?" \xb7 ".concat(E.product):""]})]})]}),(0,i.jsx)("div",{style:{fontSize:11,color:t.textMuted,marginBottom:Q.sm},children:"Ou convertir un produit pr\xe9cis (avec aper\xe7u) :"}),(0,i.jsxs)("div",{style:{display:"flex",gap:Q.sm,marginBottom:Q.lg},children:[(0,i.jsx)("input",{value:o,onChange:e=>s(e.target.value),onKeyDown:e=>"Enter"===e.key&&O(),placeholder:"Rechercher un produit…",style:{...Z(t),flex:1}}),(0,i.jsx)("button",{onClick:O,disabled:c,style:ei(t.gold,t),children:c?"…":"Chercher"})]}),(0,i.jsxs)("div",{style:{display:"flex",flexDirection:"column",gap:Q.xs},children:[a.map(e=>(0,i.jsxs)("button",{onClick:()=>U(e),style:{display:"flex",alignItems:"center",gap:Q.md,padding:Q.sm,borderRadius:$.md,border:"1px solid ".concat(t.border),background:t.surfaceAlt,cursor:"pointer",textAlign:"left",fontFamily:G},children:[e.image?(0,i.jsx)("img",{src:e.image,alt:"",style:{width:40,height:40,borderRadius:$.sm,objectFit:"cover"}}):(0,i.jsx)("div",{style:{width:40,height:40,borderRadius:$.sm,background:t.bg}}),(0,i.jsx)("span",{style:{flex:1,fontSize:12,color:t.text},children:e.title}),"ACTIVE"!==e.status&&(0,i.jsx)("span",{style:{fontSize:9,color:t.textDim,textTransform:"uppercase"},children:e.status})]},e.id)),!c&&o&&0===a.length&&(0,i.jsx)("span",{style:{fontSize:11,color:t.textDim},children:"Aucun produit trouv\xe9."})]})]})]})}let nr=["1K","2K","3K"],nl=[1,2,4],no=[2,4,6,8],ns=e=>"landscape"===e?"56.25%":"square"===e?"100%":"125%";async function na(e,t){let n=(e=>{let t=/\.([a-z0-9]{2,4})(?:[?#]|$)/i.exec((e||"").split("?")[0]);return(t?t[1]:"png").toLowerCase()})(e),i=(t||"sudist-studio-".concat(Date.now())).replace(/\.[a-z0-9]{2,4}$/i,""),r="".concat(i,".").concat(n);try{let t=await fetch(e),n=await t.blob(),i=URL.createObjectURL(n),l=document.createElement("a");l.href=i,l.download=r,document.body.appendChild(l),l.click(),l.remove(),URL.revokeObjectURL(i)}catch(t){window.open(e,"_blank")}}function nd(e){let{value:t,onChange:n,t:r}=e;return(0,i.jsx)("div",{style:{display:"flex",flexWrap:"wrap",gap:4,marginTop:4},children:t8.map(e=>{let l=t===e.id;return(0,i.jsx)("button",{onClick:()=>n(e.id),style:{fontSize:9,padding:"3px 7px",borderRadius:$.pill,border:"1px solid ".concat(l?r.gold:r.border),background:l?r.gold:"none",color:l?r.bg:r.textMuted,cursor:"pointer",fontFamily:G},children:e.label},e.id)})})}function nc(e){let{label:t,hint:n,value:l,uploading:o,onPick:s,onClear:a,t:d,compact:c}=e,u=(0,r.useRef)(null);return(0,i.jsxs)("div",{children:[(0,i.jsx)("span",{style:et(d),children:t}),(0,i.jsx)("div",{onClick:()=>{var e;return!o&&(null==(e=u.current)?void 0:e.click())},style:{position:"relative",aspectRatio:c?"1 / 1":"4 / 5",borderRadius:$.md,border:"1px dashed ".concat(l?d.border:d.borderLight),background:l?d.bg:d.surfaceAlt,cursor:o?"wait":"pointer",overflow:"hidden",display:"flex",alignItems:"center",justifyContent:"center",transition:"border-color 0.2s ease"},children:l?(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)("img",{src:l,alt:t,style:{width:"100%",height:"100%",objectFit:"contain"}}),(0,i.jsx)("button",{onClick:e=>{e.stopPropagation(),null==a||a()},title:"Retirer",style:{position:"absolute",top:6,right:6,width:22,height:22,borderRadius:$.pill,border:"none",cursor:"pointer",background:"rgba(13,11,9,0.7)",color:d.text,fontSize:13,lineHeight:1,display:"flex",alignItems:"center",justifyContent:"center"},children:"\xd7"})]}):(0,i.jsxs)("div",{style:{textAlign:"center",padding:Q.sm,color:d.textDim},children:[(0,i.jsx)("div",{style:{fontSize:20,fontWeight:300,marginBottom:2},children:o?"…":"+"}),(0,i.jsx)("div",{style:{fontSize:10,lineHeight:1.3},children:o?"Envoi…":n||"Ajouter"})]})}),(0,i.jsx)("input",{ref:u,type:"file",accept:"image/png,image/jpeg,image/webp",hidden:!0,onChange:e=>{var t;let n=null==(t=e.target.files)?void 0:t[0];n&&(null==s||s(n)),e.target.value=""}})]})}function nu(e){var t,n;let{t:o,active:s}=e,[a,d]=(0,r.useState)("studio"),[c,u]=(0,r.useState)(!1);(0,r.useEffect)(()=>{let e=()=>u(window.innerWidth<768);return e(),window.addEventListener("resize",e),()=>window.removeEventListener("resize",e)},[]);let[p,g]=(0,r.useState)("tshirt"),[x,h]=(0,r.useState)(null),[m,f]=(0,r.useState)(null),[y,b]=(0,r.useState)(null),[v,j]=(0,r.useState)(null),[S,k]=(0,r.useState)("print"),[w,C]=(0,r.useState)("print"),[_,z]=(0,r.useState)("auto"),[T,L]=(0,r.useState)(null),[A,F]=(0,r.useState)("print"),[E,B]=(0,r.useState)(null),[P,O]=(0,r.useState)(!1),U=(0,r.useRef)(null),N=(0,r.useRef)(null),[H,V]=(0,r.useState)(!1),[Y,J]=(0,r.useState)(null),X=(0,r.useRef)(null),[en,er]=(0,r.useState)(!1),el=(0,r.useRef)(null),[es,ea]=(0,r.useState)(!0),[ed,ec]=(0,r.useState)(!1),[eu,ep]=(0,r.useState)("auto"),[ex,eh]=(0,r.useState)(!0),[em,ef]=(0,r.useState)("webp"),[ey,eb]=(0,r.useState)(90),[ev,ej]=(0,r.useState)(""),[eS,ek]=(0,r.useState)("model"),[ew,eC]=(0,r.useState)("square"),[e_,ez]=(0,r.useState)("1K"),[eT,eD]=(0,r.useState)(2),[eR,eI]=(0,r.useState)("mix"),[eM,eW]=(0,r.useState)(""),[eq,eL]=(0,r.useState)(""),[eA,eF]=(0,r.useState)(null),[eE,eB]=(0,r.useState)(""),[eP,eO]=(0,r.useState)([]),eU=eP.some(e=>"pending"===e.status),eN=(0,r.useRef)(null),eH=(0,r.useRef)(!1);(0,r.useEffect)(()=>
1{if(eU&&!eH.current&&c){var e;null==(e=eN.current)||e.scrollIntoView({behavior:"smooth",block:"start"})}eH.current=eU},[eU,c]);let[eV,eG]=(0,r.useState)([]),[eK,eY]=(0,r.useState)([]),[eJ,eX]=(0,r.useState)(!1),[eQ,e$]=(0,r.useState)(!1),[eZ,e0]=(0,r.useState)("all"),[e1,e2]=(0,r.useState)("all"),e6=(0,r.useRef)("all"),e4=(0,r.useRef)("all"),e5=(0,r.useRef)(null),e3=(0,r.useRef)(null),[e8,e7]=(0,r.useState)(!1),[e9,te]=(0,r.useState)(""),[tt,tn]=(0,r.useState)(""),[ti,tr]=(0,r.useState)(!0),[tl,to]=(0,r.useState)(ne),[ts,ta]=(0,r.useState)(!0),[td,tc]=(0,r.useState)(!1),[tu,tp]=(0,r.useState)(null),[tg,tx]=(0,r.useState)(null),[th,tm]=(0,r.useState)(null),[tf,ty]=(0,r.useState)([]),[tb,tv]=(0,r.useState)(null),[tj,tS]=(0,r.useState)(null),[tk,tw]=(0,r.useState)(!1),[tC,t_]=(0,r.useState)(4),[tz,tT]=(0,r.useState)([]),[tD,tR]=(0,r.useState)(null),[tI,tM]=(0,r.useState)(!1),[tW,tq]=(0,r.useState)(!1),tL=eV.filter(e=>"mood"===e.kind),tA=eV.filter(e=>"garment"===e.kind),tF=eV.filter(e=>"mannequin"===e.kind),tE=eV.filter(e=>"lieu"===e.kind),tB=tb&&tF.some(e=>e.id===tb.id),tP=[...nn,...tz],tO=tP.find(e=>e.id===tD)||null,tU=t4.find(e=>e.id===p)||t4[0],tN="vetement"===p?"v\xeatement":tU.label.toLowerCase(),tH=!tU.garment,tV=!tH||!!tU.hasBack,tG=(0,r.useCallback)(async()=>{try{let e=await l("/studio/refs");e.success&&eG(e.refs)}catch(e){}},[]),tK=(0,r.useCallback)(async()=>{try{let e=await W(60,0,{shotType:e6.current,kind:e4.current});e.success&&(eY(e.generations),eX(!!e.hasMore))}catch(e){}},[]);e3.current=(0,r.useCallback)(async()=>{if(!eQ&&eJ){e$(!0);try{let e=await W(60,eK.length,{shotType:e6.current,kind:e4.current});e.success&&(eY(t=>{let n=new Set(t.map(e=>e.id));return[...t,...e.generations.filter(e=>!n.has(e.id))]}),eX(!!e.hasMore))}catch(e){}finally{e$(!1)}}},[eK.length,eJ,eQ]);let tY=(0,r.useCallback)((e,t)=>{"shot"===e?(e6.current=t,e0(t)):(e4.current=t,e2(t)),tK()},[tK]),tJ=(0,r.useCallback)(async()=>{try{let e=await l("/studio/models");e.success&&ty(e.models)}catch(e){}},[]),tX=(0,r.useCallback)(async()=>{try{let e=await l("/studio/styles");e.success&&tT(e.styles)}catch(e){}},[]),tQ=(0,r.useCallback)(async()=>{try{let s=await l("/studio/settings");if(s.success){var e,t,n,i,r,o;te((null==(e=s.settings)?void 0:e.model_profile)||""),tn((null==(t=s.settings)?void 0:t.model_profile_male)||""),eh((null==(n=s.settings)?void 0:n.motif_autocheck)!==!1),ef(["webp","png","jpeg"].includes(null==(i=s.settings)?void 0:i.output_format)?s.settings.output_format:"webp"),eb(Number(null==(r=s.settings)?void 0:r.output_quality)||90),tr(!0);let l=(null==(o=s.settings)?void 0:o.prompt_blocks)||{};to({...ne,...l,shotFragments:{...ne.shotFragments,...l.shotFragments||{}},poses:Array.isArray(l.poses)&&l.poses.length?l.poses:ne.poses,poseBack:Array.isArray(l.poseBack)&&l.poseBack.length?l.poseBack:"string"==typeof l.poseBack&&l.poseBack.trim()?[l.poseBack]:ne.poseBack}),ta(!0)}}catch(e){}},[]);(0,r.useEffect)(()=>{s&&(tG(),tK(),tQ(),tJ(),tX())},[s,tG,tK,tQ,tJ,tX]),(0,r.useEffect)(()=>{if("gallery"!==a)return;let e=e5.current;if(!e)return;let t=new IntersectionObserver(e=>{var t,n;(null==(t=e[0])?void 0:t.isIntersecting)&&(null==(n=e3.current)||n.call(e3))},{rootMargin:"400px"});return t.observe(e),()=>t.disconnect()},[a,eJ]),(0,r.useEffect)(()=>{if(!tg)return;let e=setTimeout(()=>tx(null),3200);return()=>clearTimeout(e)},[tg]);let t$=function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"info";return tx({message:e,type:t})},tZ=function(e){let{placeholder:t="",defaultValue:n="",multiline:i=!1}=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return new Promise(r=>tm({kind:"prompt",title:e,placeholder:t,value:n,multiline:i,resolve:r}))},t0=function(e){let{confirmLabel:t="Supprimer"}=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return new Promise(n=>tm({kind:"confirm",title:e,confirmLabel:t,danger:!0,resolve:n}))},t1=async()=>{try{await q({model_profile:e9,model_profile_male:tt}),tr(!0)}catch(e){t$("Enregistrement impossible : ".concat(e.message),"error")}},t8=e=>{let t=Math.min(100,Math.max(60,Math.round(Number(e)||90)));eb(t),q({output_quality:t}).catch(()=>{})},nu=async()=>{try{await q({prompt_blocks:tl}),ta(!0)}catch(e){t$("Enregistrement impossible : ".concat(e.message),"error")}},nm=(e,t)=>async n=>{e({url:null,uploading:!0});try{let i=await D(n,t);e({url:i.url,uploading:!1})}catch(t){e(null),t$("Upload impossible : ".concat(t.message),"error")}},nf=async e=>{O(!0);try{let t=await R(e,"garment");t.success&&(eG(e=>[t.ref,...e]),B({url:t.ref.url,id:t.ref.id,type:"ref"}),t$("Coupe enregistr\xe9e dans la biblioth\xe8que et s\xe9lectionn\xe9e","success"))}catch(e){t$("Upload impossible : ".concat(e.message),"error")}finally{O(!1)}},ny=function(e,t){var n,i,r;let l=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},o=l.refImageUrl?"couple"===l.refMode:ed,s={userPrompt:ev,shotType:eS,orientation:ew,imageSize:e_,batchId:t,couple:o,productType:p,productUrl:tH&&(null==x?void 0:x.url)||null,productDetailUrl:tH&&(null==m?void 0:m.url)||null,heartUrl:(null==y?void 0:y.url)||null,backUrl:(null==v?void 0:v.url)||null,heartFinis
1h:S,backFinish:w,placement:(null==y?void 0:y.url)?_:"auto",heartRightUrl:"double"===_&&(null==T?void 0:T.url)||null,heartRightFinish:A,garmentUrl:(null==E?void 0:E.url)||null,useMoodRefs:!l.refImageUrl&&es,decorUrl:l.refImageUrl?null:(null==Y?void 0:Y.url)||null,daPrompt:l.refImageUrl?null:(null==tO?void 0:tO.da_prompt)||null,daJson:l.refImageUrl?null:(null==tO?void 0:tO.da_json)||null,daImageUrls:l.refImageUrl?null:Array.isArray(null==tO?void 0:tO.source_image_urls)?tO.source_image_urls.slice(0,2):null,daCasting:l.refImageUrl?null:(null==tO||null==(n=tO.da_json)?void 0:n.casting)||null,daPoses:l.refImageUrl?null:(null==tO||null==(i=tO.da_json)?void 0:i.poses)||null,heartWidthCm:(null==y?void 0:y.url)&&eM?Number(eM):null,heartHeightCm:(null==y?void 0:y.url)&&eq?Number(eq):null,framing:eR,variationIndex:e,casting:eu,autocheck:ex,tshirtColor:"custom"===eA?eE.trim()||null:eA&&(null==(r=t9.find(e=>e.id===eA))?void 0:r.prompt)||null,...tb&&!o?{refImageUrl:tb.url,refMode:"model"}:{},...o&&!l.refImageUrl&&(tb||tj)?{duoRefUrls:[null==tb?void 0:tb.url,null==tj?void 0:tj.url].filter(
1Boolean)}:{},...l},a=e=>/expir|504|502|Failed to fetch|NetworkError|Load failed/i.test((null==e?void 0:e.message)||"");return I(s).catch(e=>{if(a(e))return I(s);throw e}).then(t=>{t.success?(eO(n=>n.map((n,i)=>i===e?{...n,status:"done",url:t.generation.image_url,thumb:t.generation.thumb_url||null,id:t.generation.id,view:t.view||(t.generation.has_back?"back":"front"),coupleShot:o,gen:t.generation}:n)),"doubtful"===t.motifCheck&&t$("Contr\xf4le motif : une image semble s'\xe9carter du fichier fourni malgr\xe9 un re-tirage — v\xe9rifiez-la, relancez ↻ ou retouchez ✎.","info")):eO(n=>n.map((n,i)=>i===e?{...n,status:"error",error:t.error||"\xc9chec"}:n))}).catch(t=>{let n=a(t)?"D\xe9lai d\xe9pass\xe9 (g\xe9n\xe9ration longue) — relancez avec ↻. Si \xe7a se r\xe9p\xe8te, v\xe9rifiez que Fluid Compute est activ\xe9 sur Vercel.":t.message;eO(t=>t.map((t,i)=>i===e?{...t,status:"error",error:n}:t))})},nb=async()=>{var e,t;if(eU)return;if((null==y?void 0:y.uploading)||(null==v?void 0:v.uploading)||P||(null==x?void 0:x.uploading)||(null==m?void 0:m.uploading))return void t$("Patientez la fin de l'upload des images.","error");if(tH&&!(null==x?void 0:x.url))return void t$("Ajoutez une photo du produit \xe0 reproduire.","error");if(ed&&!tH&&(!(null==y?void 0:y.url)||!(null==v?void 0:v.url)))return void t$("Pour une photo duo (face + dos), ajoutez un motif Avant ET un motif Dos.","error");if("double"===_&&!tH){if(null==T?void 0:T.uploading)return void t$("Patientez la fin de l'upload des images.","error");if((null==y?void 0:y.url)&&!(null==T?void 0:T.url))return void t$("Placement double : ajoutez le \xab Logo droit \xbb (ou changez de placement).","error");if(ed)return void t$("Le placement double (2 logos poitrine) n'est pas disponible en photo duo.","error")}let n=(null==(e=(t=crypto).randomUUID)?void 0:e.call(t))||"b".concat(Date.now());eO(Array.from({length:eT},()=>({status:"pending"}))),await Promise.allSettled(Array.from({length:eT},(e,t)=>ny(t,n))),tK()},nv=e=>{var t,n;let i=eP[e];if((null==i?void 0:i.status)==="pending")return;if(eO(t=>t.map((t,n)=>n===e?{...t,status:"pending"}:t)),null==i?void 0:i._retouch)return void nk(e,i._retouch.sourceId,i._retouch.instruction).then(tK);if(null==i?void 0:i._recipe)return void nH(i._recipe,e,i._ov||{}).then(tK);let r=(null==i?void 0:i._ov)||{};ny(e,(null==(t=(n=crypto).randomUUID)?void 0:t.call(n))||"b".concat(Date.now()),r).then(tK)},nj=function(e,t){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0,i="couple"===t;return{userPrompt:e.user_prompt||"",shotType:e.shot_type||"model",orientation:"reframe"===t?"portrait"===e.orientation?"landscape":"portrait":e.orientation||"square",imageSize:e.image_size||"1K",couple:i,productType:e.product_type||"tshirt",productUrl:e.product_url||null,productDetailUrl:e.product_detail_url||null,heartUrl:e.heart_url||null,backUrl:e.back_url||null,heartFinish:e.heart_finish||"print",backFinish:e.back_finish||"print",placement:e.placement||"auto",heartRightUrl:e.heart_right_url||null,heartRightFinish:e.heart_right_finish||"print",garmentUrl:e.garment_url||null,heartWidthCm:e.heart_w_cm||null,heartHeightCm:e.heart_h_cm||null,framing:e.framing||"mix",tshirtColor:e.tshirt_color||null,refImageUrl:e.image_url,forceView:i?null:"flip"===t?"back"===e.view?"front":"back":e.view||"front",refMode:i?"couple":t,variationIndex:n}},nS=(e,t)=>{var n,i;let r=eP[e];if(!r||"done"!==r.status)return;let l=r.gen?nj(r.gen,t,e):{refImageUrl:r.url,forceView:"flip"===t?"back"===r.view?"front":"back":r.view,refMode:t,variationIndex:e},o=eP.length;eO(e=>[...e,{status:"pending",_ov:l}]),ny(o,(null==(n=(i=crypto).randomUUID)?void 0:n.call(i))||"b".concat(Date.now()),l).then(tK)},nk=(e,t,n)=>M(t,n).then(t=>{t.success?eO(n=>n.map((n,i)=>i===e?{...n,status:"done",url:t.generation.image_url,thumb:t.generation.thumb_url||null,id:t.generation.id,view:t.view||t.generation.view||"front",gen:t.generation}:n)):eO(n=>n.map((n,i)=>i===e?{...n,status:"error",error:t.error||"\xc9chec"}:n))}).catch(t=>{eO(n=>n.map((n,i)=>i===e?{...n,status:"error",error:t.message}:n))}),nw=async e=>{let t=eP[e];
1if(!t||"done"!==t.status||!t.id)return;let n=await tZ("Que faut-il retoucher ?",{placeholder:"Ex : corrige la main droite (cinq doigts), enl\xe8ve l'objet au fond, lisse le faux-pli sur l'\xe9paule…",multiline:!0});if(!n)return;let i=eP.length;eO(e=>[...e,{status:"pending",orientation:t.orientation,coupleShot:t.coupleShot,_retouch:{sourceId:t.id,instruction:n}}]),nk(i,t.id,n).then(tK)},nC=async(e,t)=>{let n=Array.isArray(e)?e:[e];if(n.length){e7(!0);try{for(let e of n){let n=await R(e,t);n.success&&eG(e=>[n.ref,...e])}}catch(e){t$("Ajout impossible : ".concat(e.message),"error")}finally{e7(!1)}}},n_=async e=>{if(await t0("Retirer cette image de la biblioth\xe8que ?")){eG(t=>t.filter(t=>t.id!==e)),(null==E?void 0:E.id)===e&&B(null),(null==tb?void 0:tb.id)===e?(tv(tj||null),tS(null)):(null==tj?void 0:tj.id)===e&&tS(null),(null==Y?void 0:Y.id)===e&&J(null);try{await l("/studio/refs/".concat(encodeURIComponent(e)),{method:"DELETE"})}catch(e){tG()}}},nz=async e=>{if(await t0("Supprimer ce shooting ?")){eY(t=>t.filter(t=>t.id!==e));try{await l("/studio/generations?id=".concat(encodeURIComponent(e)),{method:"DELETE"})}catch(e){tK()}}},[nT,nD]=(0,r.useState)(null),nR=async(e,t)=>{if(!nT){nD(e.id);try{var n,i;await I({...nj(e,t,0),batchId:(null==(n=(i=crypto).randomUUID)?void 0:n.call(i))||"b".concat(Date.now()),useMoodRefs:!1,autocheck:ex}),await tK()}catch(e){t$("G\xe9n\xe9ration impossible : ".concat(e.message),"error")}finally{nD(null)}}},[nI,nM]=(0,r.useState)(null),nW=async()=>{if(!nI&&await t0("Flush : t\xe9l\xe9charger toute la galerie en zip, puis TOUT supprimer de l'app et du stockage ?",{confirmLabel:"T\xe9l\xe9charger & vider"})){nM("Inventaire…");try{let e=await W(1e3,0,{}),t=e.generations||[];for(;e.hasMore&&t.length<2e3;)e=await W(1e3,t.length,{}),t=[...t,...e.generations||[]];if(!t.length)return void t$("La galerie est d\xe9j\xe0 vide.","info");let n=[],i=[];for(let e=0;e<t.length;e++){nM("T\xe9l\xe9chargement ".concat(e+1,"/").concat(t.length,"…"));let r=t[e];try{let t=await fetch(r.image_url);if(!t.ok)throw Error(String(t.status));let l=new Uint8Array(await t.arrayBuffer()),o=(r.image_url.split(".").pop()||"png").split("?")[0].slice(0,4),s=(r.created_at||"").slice(0,10)||"sans-date";n.push({name:"sudist-".concat(s,"-").concat(String(e+1).padStart(3,"0"),"-").concat(r.view||"front",".").concat(o),data:l}),i.push(r.id)}catch(e){}}if(!n.length)return void t$("Aucune image t\xe9l\xe9chargeable — rien n'a \xe9t\xe9 supprim\xe9.","error");nM("Cr\xe9ation du zip…");let r=function(e){let t=new TextEncoder,{time:n,date:i}=function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:new Date;return{time:e.getHours()<<11|e.getMinutes()<<5|e.getSeconds()>>1,date:(e.getFullYear()-1980&127)<<9|e.getMonth()+1<<5|e.getDate()}}(),r=[],l=[],o=0;for(let s of e){let e=t.encode(s.name),a=s.data,d=function(e){let t=0xffffffff;for(let n=0;n<e.length;n++)t=t2[(t^e[n])&255]^t>>>8;return(0xffffffff^t)>>>0}(a),c=new DataView(new ArrayBuffer(30));c.setUint32(0,0x4034b50,!0),c.setUint16(4,20,!0),c.setUint16(6,2048,!0),c.setUint16(8,0,!0),c.setUint16(10,n,!0),c.setUint16(12,i,!0),c.setUint32(14,d,!0),c.setUint32(18,a.length,!0),c.setUint32(22,a.length,!0),c.setUint16(26,e.length,!0),c.setUint16(28,0,!0),r.push(new Uint8Array(c.buffer),e,a);let u=new DataView(new ArrayBuffer(46));u.setUint32(0,0x2014b50,!0),u.setUint16(4,20,!0),u.setUint16(6,20,!0),u.setUint16(8,2048,!0),u.setUint16(10,0,!0),u.setUint16(12,n,!0),u.setUint16(14,i,!0),u.setUint32(16,d,!0),u.setUint32(20,a.length,!0),u.setUint32(24,a.length,!0),u.setUint16(28,e.length,!0),u.setUint32(42,o,!0),l.push(new Uint8Array(u.buffer),e),o+=30+e.length+a.length}let s=0;for(let e of l)s+=e.length;let a=new DataView(new ArrayBuffer(22));return a.setUint32(0,0x6054b50,!0),a.setUint16(8,e.length,!0),a.setUint16(10,e.length,!0),a.setUint32(12,s,!0),a.setUint32(16,o,!0),new Blob([...r,...l,new Uint8Array(a.buffer)],{type:"application/zip"})}(n),o=URL.createObjectURL(r),s=document.createElement("a");s.href=o,s.download="sudist-studio-".concat(new Date().toISOString().slice(0,10),".zip"),document.body.appendChild(s),s.click(),s.remove(),URL.revokeObjectURL(o),nM("Suppression…"),await l("/studio/generations/flush",{method:"POST",body:{ids:i}}),await tK();let a=t.length-i.length;t$("".concat(n.length," image(s) t\xe9l\xe9charg\xe9es et supprim\xe9es").concat(a?" \xb7 ".concat(a," inaccessible(s) conserv\xe9e(s)"):"","."),"success")}catch(e){t$("Flush impossible : ".concat(e.message),"error")}finally{nM(null)}}},nq=async e=>{if(nT)return;let t=await tZ("Que faut-il retoucher ?",{placeholder:"Ex : corrige la main droite (cinq doigts), enl\xe8ve l'objet au fond, lisse le faux-pli sur l'\xe9paule…",multiline:!0});if(t){nD(e.id);try{await M(e.id,t),await tK(),t$("Retouche g\xe9n\xe9r\xe9e","success")}catch(e){t$("Retouche impossible : ".concat(e.message),"error")}finally{nD(null)}}},nL=()=>({productType:p,shotType:eS,orientation:ew,resolution:e_,framing:eR,count:eT,prompt:ev,heartW:eM,heartH:eq,colorId:eA,customColor:eE,useMood:es,couple:ed,styleId:tD,heartFinis
1h:S,backFinish:w,placement:_,heartRightFinish:A,heart:(null==y?void 0:y.url)?{url:y.url}:null,heartRight:(null==T?void 0:T.url)?{url:T.url}:null,back:(null==v?void 0:v.url)?{url:v.url}:null,cutSel:(null==E?void 0:E.url)?{url:E.url,id:E.id||null,type:E.type||"upload"}:null,productImg:(null==x?void 0:x.url)?{url:x.url}:null,productDetailImg:(null==m?void 0:m.url)?{url:m.url}:null,decorSel:(null==Y?void 0:Y.url)?{url:Y.url,id:Y.id||null}:null}),nA=e=>{let t=t9.find(t=>t.prompt===e.tshirt_color);return{productType:e.product_type||"tshirt",shotType:e.shot_type||"model",orientation:e.orientation||"portrait",resolution:e.image_size||"1K",framing:e.framing||"mix",count:2,prompt:e.user_prompt||"",heartW:e.heart_w_cm?String(e.heart_w_cm):"",heartH:e.heart_h_cm?String(e.heart_h_cm):"",colorId:e.tshirt_color?t?t.id:"custom":null,customColor:e.tshirt_color&&!t?e.tshirt_color:"",useMood:!0,couple:!!e.is_couple,heart:e.heart_url?{url:e.heart_url}:null,heartRight:e.heart_right_url?{url:e.heart_right_url}:null,back:e.back_url?{url:e.back_url}:null,heartFinish:e.heart_finish||"print",backFinish:e.back_finish||"print",placement:e.placement||"auto",heartRightFinish:e.heart_right_finish||"print",cutSel:e.garment_url?{url:e.garment_url,id:null,type:"upload"}:null,productImg:e.product_url?{url:e.product_url}:null,productDetailImg:e.product_detail_url?{url:e.product_detail_url}:null,decorSel:e.decor_url?{url:e.decor_url,id:null}:null}},nF=async function(e){let{name:t,refImageUrl:n=null,thumbUrl:i=null}=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=(t||await tZ("Nom du mod\xe8le ?",{placeholder:"Ex : T-shirt cigale \xe9t\xe9"})||"").trim();if(r)try{let t,o=await (t={name:r,config:e,ref_image_url:n,thumb_url:i},l("/studio/models",{method:"POST",body:t}));o.success&&(ty(e=>[o.model,...e]),t$("Mod\xe8le enregistr\xe9","success"))}catch(e){t$("Enregistrement impossible : ".concat(e.message),"error")}},nE=async e=>{if(await t0("Supprimer ce mod\xe8le ?")){ty(t=>t.filter(t=>t.id!==e));try{await l("/studio/models?id=".concat(encodeURIComponent(e)),{method:"DELETE"})}catch(e){tJ()}}},nB=async e=>{V(!0);try{let t=await R(e,"mannequin");if(t.success){eG(e=>[t.ref,...e]);let e={url:t.ref.url,view:"front",id:t.ref.id};ed&&tb?tS(e):tv(e),t$("Mannequin ajout\xe9 et s\xe9lectionn\xe9","success")}}catch(e){t$("Upload impossible : ".concat(e.message),"error")}finally{V(!1)}},nP=async e=>{try{let t,n=await l("/studio/refs",{method:"POST",body:{url:e,kind:"mannequin",label:t}});if(n.success){eG(e=>[n.ref,...e]);let e={url:n.ref.url,view:"front",id:n.ref.id};ed&&tb?tS(e):tv(e),d("studio"),t$("Visage ajout\xe9 aux mannequins et s\xe9lectionn\xe9","success")}}catch(e){t$("Enregistrement impossible : ".concat(e.message),"error")}},nO=async(e,t)=>{let n=(e||"").trim();if(!n)return void t$("Donnez un nom au style.","error");if(!(null==t?void 0:t.length))return void t$("Ajoutez au moins une image de r\xe9f\xe9rence.","error");tM(!0),t$("Analyse des r\xe9f\xe9rences en cours…");try{let e=[];for(let n of t.slice(0,6)){let t=await D(n,"style");e.push(t.url)}let i=await l("/studio/styles",{method:"POST",body:{name:n,imageUrls:e}});i.success?(tT(e=>[i.style,...e]),tR(i.style.id),t$("Style \xab ".concat(i.style.name," \xbb cr\xe9\xe9"),"success")):t$(i.error||"Analyse impossible","error")}catch(e){t$("Cr\xe9ation du style impossible : ".concat(e.message),"error")}finally{tM(!1)}},nU=async e=>{if(await t0("Supprimer ce style ?")){tT(t=>t.filter(t=>t.id!==e)),tD===e&&tR(null);try{await l("/studio/styles?id=".concat(encodeURIComponent(e)),{method:"DELETE"})}catch(e){tX()}}},nN=async e=>{er(!0);try{let t=await R(e,"lieu");t.success&&(eG(e=>[t.ref,...e]),J({url:t.ref.url,id:t.ref.id}),t$("Lieu ajout\xe9 et s\xe9lectionn\xe9","success"))}catch(e){t$("Upload impossible : ".concat(e.message),"error")}finally{er(!1)}},nH=(e,t,n)=>{var i,r,l,o,s,a,d,c,u,p;let g={userPrompt:e.prompt||"",shotType:"model",orientation:e.orientation||"portrait",imageSize:e.resolution||"1K",batchId:n.setId,setId:n.setId,couple:!!n.couple,productType:e.productType||"tshirt",productUrl:(null==(i=e.productImg)?void 0:i.url)||null,productDetailUrl:(null==(r=e.productDetailImg)?void 0:r.url)||null,heartUrl:(null==(l=e.heart)?void 0:l.url)||null,backUrl:(null==(o=e.back)?void 0:o.url)||null,heartFinis
1h:e.heartFinish||"print",backFinish:e.backFinish||"print",placement:e.placement||"auto",heartRightUrl:(null==(s=e.heartRight)?void 0:s.url)||null,heartRightFinish:e.heartRightFinish||"print",garmentUrl:(null==(a=e.cutSel)?void 0:a.url)||null,useMoodRefs:!1,heartWidthCm:(null==(d=e.heart)?void 0:d.url)&&e.heartW?Number(e.heartW):null,heartHeightCm:(null==(c=e.heart)?void 0:c.url)&&e.heartH?Number(e.heartH):null,framing:n.framing,variationIndex:t,tshirtColor:"custom"===e.colorId?(null==(u=e.customColor)?void 0:u.trim())||null:e.colorId&&(null==(p=t9.find(t=>t.id===e.colorId))?void 0:p.prompt)||null,refImageUrl:n.refImageUrl,forceView:n.forceView,refMode:n.refMode,autocheck:ex},x=e=>/expir|504|502|Failed to fetch|NetworkError|Load failed/i.test((null==e?void 0:e.message)||"");return I(g).catch(e=>{if(x(e))return I(g);throw e}).then(e=>{e.success?(eO(i=>i.map((i,r)=>r===t?{...i,status:"done",url:e.generation.image_url,thumb:e.generation.thumb_url||null,id:e.generation.id,view:e.view||"front",coupleShot:!!n.couple}:i)),"doubtful"===e.motifCheck&&t$("Contr\xf4le motif : une image du set semble s'\xe9carter du fichier fourni — v\xe9rifiez-la, relancez ↻ ou retouchez ✎.","info")):eO(n=>n.map((n,i)=>i===t?{...n,status:"error",error:e.error||"\xc9chec"}:n))}).catch(e=>{let n=x(e)?"D\xe9lai d\xe9pass\xe9 (g\xe9n\xe9ration longue) — relancez avec ↻.":e.message;eO(e=>e.map((e,i)=>i===t?{...e,status:"error",error:n}:e))})},nV=async(e,t,n)=>{var i,r,l,o;if(tk||eU)return;let s=e.couple?Array.from({length:tC},(e,t)=>({refMode:"couple",couple:!0,framing:t%2==0?"waist":"full"})):((e,t,n)=>{let i=["bust","waist","full"],r="back"===e?"front":"back",l=[];for(let o=0;o<n;o++){let n=i[o%i.length];t&&o%2==1?l.push({refMode:"flip",forceView:r,framing:n}):l.push({refMode:"repose",forceView:e,framing:n})}return l})(n||"front",t5(l=e.productType||"tshirt")||!!(null==(o=t4.find(e=>e.id===l))?void 0:o.hasBack),tC),a=(null==(i=(r=crypto).randomUUID)?void 0:i.call(r))||"s".concat(Date.now());tw(!0),d("studio"),eC(e.orientation||"portrait"),eO(s.map(n=>({status:"pending",orientation:e.orientation||"portrait",_recipe:e,_ov:{...n,refImageUrl:t,setId:a}}))),await Promise.allSettled(s.map((n,i)=>nH(e,i,{...n,refImageUrl:t,setId:a}))),tw(!1),tK()},nG=!eU&&!tk,nK={height:"100%",display:"flex",flexDirection:"column",background:o.bg,fontFamily:G,color:o.text};return(0,i.jsxs)("div",{style:nK,children:[(0,i.jsx)("style",{children:"@keyframes studioShimmer{0%{background-position:-200% 0}100%{background-position:200% 0}}"}),(0,i.jsxs)("div",{style:{padding:"".concat(Q.lg,"px ").concat(c?Q.lg:Q.xxl,"px"),borderBottom:"1px solid ".concat(o.border),display:"flex",alignItems:"center",justifyContent:"space-between",gap:Q.lg,flexWrap:"wrap",flexShrink:0},children:[(0,i.jsxs)("div",{children:[(0,i.jsx)("div",{style:{fontSize:19,fontFamily:G,letterSpacing:"0.01em"},children:"Studio photo"}),(0,i.jsx)("div",{style:{fontSize:11,color:o.textMuted,marginTop:2},children:"Shootings produit g\xe9n\xe9r\xe9s depuis vos motifs et le mood de la marque"})]}),(0,i.jsx)("div",{style:{display:"flex",gap:Q.xs},children:[["studio","Studio"],["gallery","Galerie"],["settings","R\xe9glages"]].map(e=>{let[t,n]=e;return(0,i.jsx)("button",{onClick:()=>d(t),style:{...eo(a===t,o),padding:"6px 14px",fontSize:11},children:n},t)})})]}),"catalog"===a&&(0,i.jsx)(ni,{t:o,active:s&&"catalog"===a}),"studio"===a&&(0,i.jsxs)("div",{style:{flex:1,display:"flex",flexDirection:c?"column":"row",overflow:c?void 0:"hidden",overflowY:c?"auto":void 0,WebkitOverflowScrolling:"touch"},children:[(0,i.jsxs)("div",{style:{width:c?"100%":340,minWidth:340*!c,borderRight:c?"none":"1px solid ".concat(o.border),borderBottom:c?"1px solid ".concat(o.border):"none",overflowY:c?"visible":"auto",flexShrink:0,padding:c?Q.lg:Q.xl,display:"flex",flexDirection:"column",gap:Q.xl},children:[(0,i.jsxs)("div",{children:[(0,i.jsx)("span",{style:et(o),children:"Type de produit"}),(0,i.jsx)("div",{style:{display:"flex",flexWrap:"wrap",gap:Q.xs},children:t4.map(e=>(0,i.jsx)("button",{title:e.hint,onClick:()=>{g(e.id),e.garment||ek("model")},style:eo(p===e.id,o),children:e.label},e.id))})]}),tf.length>0&&(0,i.jsxs)("div",{children:[(0,i.jsxs)("span",{style:et(o),children:["Recettes enregistr\xe9es ",(0,i.jsx)("span",{style:{textTransform:"none",color:o.textDim,fontWeight:400},children:"\xb7 r\xe9glages"})]}),tf.length>0&&(0,i.jsx)("div",{style:{display:"flex",gap:Q.sm,overflowX:"auto",paddingBottom:4},children:tf.map(e=>(0,i.jsxs)("div",{style:{flexShrink:0,width:60},children:[(0,i.jsxs)("div",{style:{position:"relative"},children:[(0,i.jsxs)("button",{onClick:()=>{var t,n,i,r,l,o,s,a,c,u,p,x,m,y,v,S,w,_,T,D,R,I,M,W,q,A,E;(n=e.config)&&(g(null!=(u=n.productType)?u:"tshirt"),ek(null!=(p=n.shotType)?p:"model"),eC(null!=(x=n.orientation)?x:"portrait"),ez(null!=(m=n.resolution)?m:"1K"),eI(null!=(y=n.framing)?y:"mix"),eD(null!=(v=n.count)?v:2),ej(null!=(S=n.prompt)?S:""),eW(null!=(w=n.heartW)?w:""),eL(null!=(_=n.heartH)?_:""),eF(null!=(T=n.colorId)?T:null),eB(null!=(D=n.customColor)?D:""),ea(null==(R=n.useMood)||R),ec(null!=(I=n.couple)&&I),tR(null!=(M=n.styleId)?M:null),b((null==(i=n.heart)?void 0:i.url)?{url:n.heart.url}:null),j((null==(r=n.back)?void 0:r.url)?{url:n.back.url}
1:null),k(null!=(W=n.heartFinish)?W:"print"),C(null!=(q=n.backFinish)?q:"print"),z(null!=(A=n.placement)?A:"auto"),L((null==(l=n.heartRight)?void 0:l.url)?{url:n.heartRight.url}:null),F(null!=(E=n.heartRightFinish)?E:"print"),B((null==(o=n.cutSel)?void 0:o.url)?n.cutSel:null),h((null==(s=n.productImg)?void 0:s.url)?{url:n.productImg.url}:null),f((null==(a=n.productDetailImg)?void 0:a.url)?{url:n.productDetailImg.url}:null),J((null==(c=n.decorSel)?void 0:c.url)?n.decorSel:null)),tv(e.ref_image_url?{url:e.ref_image_url,view:(null==(t=e.config)?void 0:t.view)||"front"}:null),d("studio")},title:"Charger \xab ".concat(e.name," \xbb").concat(e.ref_image_url?" \xb7 mannequin fig\xe9":""),style:{width:60,height:60,borderRadius:$.md,border:"1px solid ".concat(o.border),padding:0,overflow:"hidden",cursor:"pointer",background:o.surfaceAlt,position:"relative",display:"flex",alignItems:"center",justifyContent:"center"},children:[e.thumb_url?(0,i.jsx)("img",{src:e.thumb_url,alt:e.name,style:{width:"100%",height:"100%",objectFit:"cover"}}):(0,i.jsx)("span",{style:{fontSize:9,color:o.textDim,padding:2,textAlign:"center"},children:e.name.slice(0,10)}),e.ref_image_url&&(0,i.jsx)("span",{style:{position:"absolute",bottom:2,left:2,fontSize:7,background:"rgba(13,11,9,0.78)",color:o.gold,padding:"1px 3px",borderRadius:$.pill},children:"mannequin"})]}),(0,i.jsx)("button",{onClick:()=>nE(e.id),title:"Supprimer ce mod\xe8le",style:{position:"absolute",top:-5,right:-5,width:18,height:18,borderRadius:$.pill,border:"none",cursor:"pointer",background:"rgba(13,11,9,0.85)",color:o.text,fontSize:11,lineHeight:1,display:"flex",alignItems:"center",justifyContent:"center"},children:"\xd7"})]}),(0,i.jsx)("div",{style:{fontSize:8,color:o.textMuted,textAlign:"center",marginTop:2,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:e.name})]},e.id))})]}),(0,i.jsxs)("div",{children:[(0,i.jsxs)("span",{style:et(o),children:["Mannequin ",(0,i.jsx)("span",{style:{textTransform:"none",color:o.textDim,fontWeight:400},children:"\xb7 garder le m\xeame visage"})]}),(0,i.jsxs)("div",{style:{display:"flex",flexWrap:"wrap",gap:Q.sm},children:[(0,i.jsx)("button",{onClick:()=>{tv(null),tS(null)},style:{width:54,height:54,borderRadius:$.md,border:"".concat(!tb&&!tj?2:1,"px solid ").concat(tb||tj?o.border:o.gold),background:o.surfaceAlt,color:tb||tj?o.textMuted:o.gold,cursor:"pointer",fontSize:10,fontFamily:G,flexShrink:0},children:"Aucun"}),tF.map(e=>{let t=(null==tb?void 0:tb.id)===e.id,n=(null==tj?void 0:tj.id)===e.id,r=t||n;return(0,i.jsxs)("button",{onClick:()=>(e=>{let t={url:e.url,view:"front",id:e.id};if(!ed){tv(t),tS(null);return}if((null==tb?void 0:tb.id)===e.id){tv(tj),tS(null);return}return(null==tj?void 0:tj.id)===e.id?void tS(null):tb?void tS(t):void tv(t)})(e),title:ed?t?"Personne A (de face) — cliquer pour retirer":n?"Personne B (de dos) — cliquer pour retirer":"S\xe9lectionner pour le duo":e.label||"Mannequin enregistr\xe9",style:{width:54,height:54,borderRadius:$.md,border:"".concat(r?2:1,"px solid ").concat(r?o.gold:o.border),padding:0,overflow:"hidden",cursor:"pointer",flexShrink:0,background:o.bg,position:"relative"},children:[(0,i.jsx)("img",{src:e.url,alt:"mannequin",style:{width:"100%",height:"100%",objectFit:"cover"}}),ed&&r&&(0,i.jsx)("span",{style:{position:"absolute",bottom:2,right:2,width:16,height:16,borderRadius:$.pill,background:o.gold,color:o.bg,fontSize:9,fontWeight:700,display:"flex",alignItems:"center",justifyContent:"center"},children:t?"A":"B"})]},e.id)}),(0,i.jsx)("button",{onClick:()=>{var e;return!H&&(null==(e=N.current)?void 0:e.click())},title:"Importer un mannequin (photo d'une personne)",style:{width:54,height:54,borderRadius:$.md,border:"1px solid ".concat(o.borderLight),background:o.surfaceAlt,color:o.textDim,fontSize:18,cursor:H?"wait":"pointer",flexShrink:0,display:"flex",alignItems:"center",justifyContent:"center"},children:H?"…":"+"})]}),(0,i.jsx)("input",{ref:N,type:"file",accept:"image/png,image/jpeg,image/webp",hidden:!0,onChange:e=>{var t;let n=null==(t=e.target.files)?void 0:t[0];n&&nB(n),e.target.value=""}}
1),ed?(0,i.jsx)("div",{style:{fontSize:10,color:tb||tj?o.gold:o.textDim,marginTop:4},children:tb&&tj?(0,i.jsxs)(i.Fragment,{children:["Duo verrouill\xe9 : A = personne de face (motif avant), B = personne de dos (motif dos)."," ",(0,i.jsx)("button",{onClick:()=>{tv(tj),tS(tb)},style:{background:"none",border:"none",color:o.gold,cursor:"pointer",padding:0,fontSize:10,textDecoration:"underline",fontFamily:G},children:"⇄ Inverser A/B"})]}):tb?"Personne A (de face) verrouill\xe9e — s\xe9lectionnez un 2ᵉ mannequin pour imposer aussi la personne de dos, sinon elle sera g\xe9n\xe9r\xe9e.":"Duo : s\xe9lectionnez jusqu'\xe0 2 mannequins — le 1ᵉʳ devient la personne de FACE (A), le 2ᵉ la personne de DOS (B)."}):tb?(0,i.jsxs)("div",{style:{fontSize:10,color:o.gold,marginTop:4},children:["Mannequin verrouill\xe9 : m\xeame personne \xe0 chaque g\xe9n\xe9ration, le v\xeatement et le motif suivent vos r\xe9glages.",tB?"":" (r\xe9f. hors biblioth\xe8que)"]}):(0,i.jsxs)("div",{style:{fontSize:10,color:o.textDim,marginTop:4},children:["Importez ou choisissez un mannequin pour garder le m\xeame visage. G\xe9rez-les dans ",(0,i.jsx)("button",{onClick:()=>d("settings"),style:{background:"none",border:"none",color:o.gold,cursor:"pointer",padding:0,fontSize:10,textDecoration:"underline"},children:"R\xe9glages"}),"."]})]}),tH&&(0,i.jsxs)("div",{children:[(0,i.jsxs)("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:Q.sm},children:[(0,i.jsx)(nc,{t:o,label:"Photo du produit",hint:tU.hint||"Photo nette du produit",value:null==x?void 0:x.url,uploading:null==x?void 0:x.uploading,onPick:nm(h,"product"),onClear:()=>h(null),compact:!0}),(0,i.jsx)(nc,{t:o,label:"D\xe9tail \xb7 optionnel",hint:"Gros plan broderie / logo",value:null==m?void 0:m.url,uploading:null==m?void 0:m.uploading,onPick:nm(f,"product_detail"),onClear:()=>f(null),compact:!0})]}),(0,i.jsxs)("div",{style:{fontSize:10,color:o.textDim,marginTop:4},children:["Le produit sera reproduit fid\xe8lement et port\xe9 par le mod\xe8le",tU.hasBack?" (vue face/dos possible)":"",". Pour une broderie ou un logo fin, ajoutez un gros plan en \xab D\xe9tail \xbb : il sert de r\xe9f\xe9rence exacte."]})]}),!tH&&(0,i.jsxs)(i.Fragment,{children:[(0,i.jsxs)("div",{children:[(0,i.jsxs)("span",{style:{...et(o),marginBottom:Q.sm},children:["Motifs ",(0,i.jsx)("span",{style:{textTransform:"none",color:o.textDim,fontWeight:400},children:"\xb7 optionnels"})]}),(0,i.jsxs)("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:Q.sm},children:[(0,i.jsxs)("div",{children:[(0,i.jsx)(nc,{t:o,label:"Avant",hint:"Motif devant",value:null==y?void 0:y.url,uploading:null==y?void 0:y.uploading,onPick:nm(b,"heart"),onClear:()=>b(null),compact:!0}),(null==y?void 0:y.url)&&(0,i.jsx)(nd,{value:S,onChange:k,t:o})]}),(0,i.jsxs)("div",{children:[(0,i.jsx)(nc,{t:o,label:"Dos",hint:"Motif dos",value:null==v?void 0:v.url,uploading:null==v?void 0:v.uploading,onPick:nm(j,"back"),onClear:()=>j(null),compact:!0}),(null==v?void 0:v.url)&&(0,i.jsx)(nd,{value:w,onChange:C,t:o})]})]}),((null==y?void 0:y.url)||(null==v?void 0:v.url))&&("print"!==S||"print"!==w)&&(0,i.jsx)("div",{style:{fontSize:10,color:o.textDim,marginTop:4},children:"La finition pilote le rendu mati\xe8re : broderie = points de fil en relief \xb7 patch brod\xe9 = \xe9cusson \xe0 bord surfil\xe9 \xb7 patch silicone = relief 3D moul\xe9."}),(null==y?void 0:y.url)&&(0,i.jsxs)("div",{style:{marginTop:Q.sm},children:[(0,i.jsx)("span",{style:et(o),children:"Placement du motif devant"}),(0,i.jsx)("div",{style:{display:"flex",flexWrap:"wrap",gap:Q.xs},children:[{id:"auto",label:"Auto"},{id:"coeur",label:"Cœur"},{id:"centre",label:"Centr\xe9"},{id:"avant",label:"Avant \xb7 XL"},{id:"double",label:"Double \xb7 G + D"}].map(e=>(0,i.jsx)("button",{onClick:()=>z(e.id),style:eo(_===e.id,o),children:e.label},e.id))}),(0,i.jsxs)("div",{style:{fontSize:10,color:o.textDim,marginTop:4},children:["auto"===_&&"Choix automatique selon la taille : petit motif → c\xf4t\xe9 cœur, grand (≥ 16 cm) → centr\xe9 poitrine.","coeur"===_&&"Petit logo \xe0 gauche de la poitrine, \xe0 hauteur du cœur.","centre"===_&&"Motif centr\xe9 sur le devant, quelle que soit sa taille.","avant"===_&&"Grand imprim\xe9 pleine face (~28–32 cm de large), de la poitrine vers le ventre — comme le grand format du dos. Sans taille saisie, le grand format s'applique d'office.","double"===_&&(ed?"Indisponible en photo duo — repassez en solo pour deux logos poitrine.":"Deux logos poitrine : le motif Avant \xe0 GAUCHE + un second logo \xe0 DROITE (chargez-le ci-dessous).")]}),"double"===_&&!ed&&(0,i.jsx)("div",{style:{marginTop:Q.sm,display:"grid",gridTemplateColumns:"1fr 1fr",gap:Q.sm},children:(0,i.jsxs)("div",{children:[(0,i.jsx)(nc,{t:o,label:"Logo droit",hint:"Logo c\xf4t\xe9 droit",value:null==T?void 0:T.url,uploading:null==T?void 0:T.uploading,onPick:nm(L,"heart_right"),onClear:()=>L(null),compact:!0}),(null==T?void 0:T.url)&&(0,i.jsx)(nd,{value:A,onChange:F,t:o})]})})]}),(null==y?void 0:y.url)&&(0,i.jsxs)("div",{style:{marginTop:Q.sm},children:[(0,i.jsx)("span",{style:et(o),children:"double"===_?"Taille par logo (cm)":"Taille du motif avant (cm)"}),(0,i.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:Q.sm},children:[(0,i.jsx)("input",{type:"number",min:"1",max:"60",inputMode:"decimal",placeholder:"larg.",value:eM,onChange:e=>eW(e.target.value),style:{...Z(o),width:72}}),(0,i.jsx)("span",{style:{color:o.textDim,fontSize:12},children:"\xd7"}),(0,i.jsx)("input",{type:"number",min:"1",max:"60",inputMode:"decimal",placeholder:"haut.",value:eq,onChange:e=>eL(e.target.value),style:{...Z(o),width:72}}),(0,i.jsxs)("span",{style:{color:o.textDim,fontSize:11},children:["cm \xb7 taille r\xe9elle — une seule dimension suffit, l'autre suit le ratio du fic
1hier","print"!==S?" \xb7 pour un patch, indiquez sa taille r\xe9elle (ex : 3 de haut)":""]})]})]})]}),(0,i.jsxs)("div",{children:[(0,i.jsxs)("button",{onClick:()=>ec(e=>{let t=!e;return t&&"waist"!==eR&&"full"!==eR&&eI("waist"),t}),style:{display:"flex",alignItems:"center",gap:Q.sm,background:"none",border:"none",cursor:"pointer",padding:0,color:ed?o.text:o.textMuted,fontFamily:G},children:[(0,i.jsx)("span",{style:{width:32,height:18,borderRadius:$.pill,background:ed?o.gold:o.surfaceAlt,border:"1px solid ".concat(ed?o.gold:o.border),position:"relative",transition:"all 0.2s ease",flexShrink:0},children:(0,i.jsx)("span",{style:{position:"absolute",top:1,left:ed?15:1,width:14,height:14,borderRadius:"50%",background:ed?o.bg:o.textMuted,transition:"left 0.2s ease"}})}),(0,i.jsx)("span",{style:{fontSize:12},children:"Photo duo \xb7 face + dos"})]}),(0,i.jsx)("div",{style:{fontSize:10,color:o.textDim,marginTop:4},children:ed?"Deux mannequins dans une m\xeame photo : l'un de face (motif avant), l'autre de dos (motif dos). N\xe9cessite les deux motifs. Conseil fid\xe9lit\xe9 : g\xe9n\xe9rez d'abord un solo r\xe9ussi, puis \xab D\xe9cliner en duo \xbb depuis cette photo — les motifs y sont plus fiables qu'en duo direct.":"Active une sc\xe8ne \xe0 deux mannequins pour montrer le devant et le dos en une image."})]}),(0,i.jsxs)("div",{children:[(0,i.jsxs)("span",{style:et(o),children:["Coupe du ",tN]}),(0,i.jsxs)("div",{style:{display:"flex",flexWrap:"wrap",gap:Q.sm},children:[(0,i.jsx)("button",{onClick:()=>B(null),style:{width:54,height:54,borderRadius:$.md,border:"".concat(!E?2:1,"px solid ").concat(E?o.border:o.gold),background:o.surfaceAlt,color:E?o.textMuted:o.gold,cursor:"pointer",fontSize:10,fontFamily:G,flexShrink:0},children:"Aucune"}),tA.map(e=>{let t=(null==E?void 0:E.id)===e.id;return(0,i.jsx)("button",{onClick:()=>B({url:e.url,id:e.id,type:"ref"}),title:e.label||"Coupe enregistr\xe9e",style:{width:54,height:54,borderRadius:$.md,border:"".concat(t?2:1,"px solid ").concat(t?o.gold:o.border),padding:0,overflow:"hidden",cursor:"pointer",flexShrink:0,background:o.bg},children:(0,i.jsx)("img",{src:e.url,alt:"coupe",style:{width:"100%",height:"100%",objectFit:"cover"}})},e.id)}),(0,i.jsx)("button",{onClick:()=>{var e;return!P&&(null==(e=U.current)?void 0:e.click())},title:"Importer une coupe (enregistr\xe9e dans la biblioth\xe8que)",style:{width:54,height:54,borderRadius:$.md,border:"1px solid ".concat(o.borderLight),padding:0,overflow:"hidden",cursor:P?"wait":"pointer",flexShrink:0,background:o.surfaceAlt,color:o.textDim,fontSize:18,display:"flex",alignItems:"center",justifyContent:"center"},children:P?"…":"+"})]}),(0,i.jsx)("input",{ref:U,type:"file",accept:"image/png,image/jpeg,image/webp",hidden:!0,onChange:e=>{var t;let n=null==(t=e.target.files)?void 0:t[0];n&&nf(n),e.target.value=""}}),0===tA.length&&(0,i.jsx)("div",{style:{fontSize:10,color:o.textDim,marginTop:4},children:"Importez une photo du v\xeatement VIERGE (\xe0 plat, col bien lisible) : elle est enregistr\xe9e dans la biblioth\xe8que et r\xe9utilisable."}),"vetement"===p&&!E&&(0,i.jsx)("div",{style:{fontSize:10,color:o.gold,marginTop:4},children:"Pour \xab Autre v\xeatement \xbb, ajoutez une coupe de r\xe9f\xe9rence : c'est elle qui d\xe9finit le col, les fermetures et la forme. Sans elle, la coupe sera g\xe9n\xe9rique."}),(0,i.jsxs)("button",{onClick:()=>ea(e=>!e),style:{marginTop:Q.md,display:"flex",alignItems:"center",gap:Q.sm,background:"none",border:"none",cursor:"pointer",padding:0,color:es?o.text:o.textMuted,fontFamily:G},children:[(0,i.jsx)("span",{style:{width:32,height:18,borderRadius:$.pill,background:es?o.gold:o.surfaceAlt,border:"1px solid ".concat(es?o.gold:o.border),position:"relative",transition:"all 0.2s ease",flexShrink:0},children:(0,i.jsx)("span",{style:{position:"absolute",top:1,left:es?15:1,width:14,height:14,borderRadius:"50%",background:es?o.bg:o.textMuted,transition:"left 0.2s ease"}})}),(0,i.jsxs)("span",{style:{fontSize:12},children:["Mood de marque ",tL.length>0?"(".concat(tL.length,")"):"(aucune r\xe9f)"]})]}
1),es&&0===tL.length&&(0,i.jsxs)("div",{style:{fontSize:10,color:o.textDim,marginTop:4},children:["Ajoutez des images dans ",(0,i.jsx)("button",{onClick:()=>d("settings"),style:{background:"none",border:"none",color:o.gold,cursor:"pointer",padding:0,fontSize:10,textDecoration:"underline"},children:"R\xe9glages"}),"."]})]}),(0,i.jsxs)("div",{children:[(0,i.jsxs)("span",{style:et(o),children:["Couleur du ",tN]}),(0,i.jsxs)("div",{style:{display:"flex",flexWrap:"wrap",gap:Q.sm,alignItems:"center"},children:[(0,i.jsx)("button",{onClick:()=>eF(null),style:eo(!eA,o),children:"Origine"}),t9.map(e=>{let t=eA===e.id;return(0,i.jsx)("button",{onClick:()=>eF(e.id),title:e.label,style:{width:26,height:26,borderRadius:"50%",background:e.hex,cursor:"pointer",flexShrink:0,border:"2px solid ".concat(t?o.gold:o.border),boxShadow:t?"0 0 0 3px ".concat(o.goldBg):"none",padding:0}},e.id)}),(0,i.jsx)("button",{onClick:()=>eF("custom"),style:eo("custom"===eA,o),children:"Autre"})]}),"custom"===eA&&(0,i.jsx)("input",{value:eE,onChange:e=>eB(e.target.value),placeholder:"Ex : bleu lavande d\xe9lav\xe9",style:{...Z(o),marginTop:Q.sm}}),eA&&"custom"!==eA&&(0,i.jsx)("div",{style:{fontSize:10,color:o.textDim,marginTop:4},children:null==(t=t9.find(e=>e.id===eA))?void 0:t.label})]})]}),(0,i.jsxs)("div",{children:[(0,i.jsx)("span",{style:et(o),children:"Brief"}),(0,i.jsx)("textarea",{value:ev,onChange:e=>ej(e.target.value),rows:3,placeholder:"Ex : lumi\xe8re dor\xe9e de fin de journ\xe9e, fond pierre claire, ambiance estivale…",style:{...ee(o),minHeight:72}})]}),(0,i.jsxs)("div",{children:[(0,i.jsxs)("span",{style:et(o),children:["Style / direction artistique ",(0,i.jsx)("span",{style:{textTransform:"none",color:o.textDim,fontWeight:400},children:"\xb7 optionnel"})]}),(0,i.jsxs)("div",{style:{display:"flex",flexWrap:"wrap",gap:Q.xs},children:[(0,i.jsx)("button",{onClick:()=>tR(null),style:eo(!tD,o),children:"Aucun"}),tP.map(e=>(0,i.jsx)("button",{onClick:()=>tR(e.id),title:(e.da_prompt||"").slice(0,180),style:eo(tD===e.id,o),children:e.name},e.id))]}),(0,i.jsxs)("div",{style:{fontSize:10,color:o.textDim,marginTop:4},children:[tO?"Lumi\xe8re, colorim\xe9trie, optique, cadrage, poses et ambiance suivent ce style.":"Cr\xe9e des styles depuis tes images de r\xe9f\xe9rence dans ",!tO&&(0,i.jsx)("button",{onClick:()=>d("settings"),style:{background:"none",border:"none",color:o.gold,cursor:"pointer",padding:0,fontSize:10,textDecoration:"underline"},children:"R\xe9glages"}),!tO&&"."]}),tO&&es&&tL.length>0&&(0,i.jsx)("div",{style:{fontSize:10,color:o.textDim,marginTop:4,lineHeight:1.4},children:"Style + Mood actifs : le style dirige la mise en sc\xe8ne (lumi\xe8re, fond, cadrage, finition), le mood garde l'identit\xe9 de marque (palette, mati\xe8res, esprit — 2 images max)."})]}),(0,i.jsxs)("div",{children:[(0,i.jsxs)("span",{style:et(o),children:["Lieu ",(0,i.jsx)("span",{style:{textTransform:"none",color:o.textDim,fontWeight:400},children:"\xb7 d\xe9cor impos\xe9 \xb7 optionnel"})]}),(0,i.jsxs)("div",{style:{display:"flex",flexWrap:"wrap",gap:Q.sm},children:[(0,i.jsx)("button",{onClick:()=>J(null),style:{width:54,height:54,borderRadius:$.md,border:"".concat(!Y?2:1,"px solid ").concat(Y?o.border:o.gold),background:o.surfaceAlt,color:Y?o.textMuted:o.gold,cursor:"pointer",fontSize:10,fontFamily:G,flexShrink:0},children:"Aucun"}),tE.map(e=>{let t=(null==Y?void 0:Y.id)===e.id;return(0,i.jsx)("button",{onClick:()=>J({url:e.url,id:e.id}),title:e.label||"Lieu enregistr\xe9",style:{width:54,height:54,borderRadius:$.md,border:"".concat(t?2:1,"px solid ").concat(t?o.gold:o.border),padding:0,overflow:"hidden",cursor:"pointer",flexShrink:0,background:o.bg},children:(0,i.jsx)("img",{src:e.url,alt:"lieu",style:{width:"100%",height:"100%",objectFit:"cover"}})},e.id)}),(0,i.jsx)("button",{onClick:()=>{var e;return!en&&(null==(e=X.current)?void 0:e.click())},title:"Importer un lieu / d\xe9cor",style:{width:54,height:54,borderRadius:$.md,border:"1px solid ".concat(o.borderLight),background:o.surfaceAlt,color:o.textDim,fontSize:18,cursor:en?"wait":"pointer",flexShrink:0,display:"flex",alignItems:"center",justifyContent:"center"},children:en?"…":"+"})]}),(0,i.jsx)("input",{ref:X,type:"file",accept:"image/png,image/jpeg,image/webp",hidden:!0,onChange:e=>{var t;let n=null==(t=e.target.files)?void 0:t[0];n&&nN(n),e.target.value=""}}
1),(0,i.jsxs)("div",{style:{fontSize:10,color:o.textDim,marginTop:4},children:[Y?"La sc\xe8ne sera plac\xe9e dans ce lieu, reproduit fid\xe8lement.":"Imposez un d\xe9cor pr\xe9cis. G\xe9rez vos lieux dans ",!Y&&(0,i.jsx)("button",{onClick:()=>d("settings"),style:{background:"none",border:"none",color:o.gold,cursor:"pointer",padding:0,fontSize:10,textDecoration:"underline"},children:"R\xe9glages"}),!Y&&"."]})]}),!tH&&(0,i.jsxs)("div",{children:[(0,i.jsx)("span",{style:et(o),children:"Type de prise de vue"}),(0,i.jsx)("div",{style:{display:"flex",flexWrap:"wrap",gap:Q.xs},children:t6.map(e=>(0,i.jsx)("button",{title:e.hint,onClick:()=>ek(e.id),style:eo(eS===e.id,o),children:e.label},e.id))})]}),("model"===eS||tH)&&!ed&&(0,i.jsxs)("div",{children:[(0,i.jsx)("span",{style:et(o),children:"Casting"}),(0,i.jsx)("div",{style:{display:"flex",flexWrap:"wrap",gap:Q.xs},children:[["auto","Auto"],["femme","Femme"],["homme","Homme"],["enfant","Enfant"],["bebe","B\xe9b\xe9"]].map(e=>{let[t,n]=e;return(0,i.jsx)("button",{onClick:()=>ep(t),style:eo(eu===t,o),children:n},t)})}),(0,i.jsx)("div",{style:{fontSize:10,color:o.textDim,marginTop:4},children:tb?"Mannequin verrouill\xe9 : l'identit\xe9 vient de sa photo, le casting ne s'applique pas.":"homme"===eu?(0,i.jsxs)(i.Fragment,{children:["Mod\xe8le homme impos\xe9, avec un rendu masculin renforc\xe9 (barbe naissante, traits non liss\xe9s). Personnalisez le profil homme dans ",(0,i.jsx)("button",{onClick:()=>d("settings"),style:{background:"none",border:"none",color:o.gold,cursor:"pointer",padding:0,fontSize:10,textDecoration:"underline"},children:"R\xe9glages"}),"."]}):"femme"===eu?"Mod\xe8le femme impos\xe9 (profil mannequin des R\xe9glages).":"enfant"===eu?"Mod\xe8le enfant (~4-8 ans) : gestuelle spontan\xe9e, aucun maquillage, proportions d'enfant. Le profil mannequin adulte des R\xe9glages est ignor\xe9.":"bebe"===eu?"B\xe9b\xe9 / tout-petit (~12-24 mois) : assis ou debout stable, ambiance douce. Le profil mannequin adulte des R\xe9glages est ignor\xe9.":"Auto : suit le profil mannequin des R\xe9glages (ou le style s\xe9lectionn\xe9)."})]}),"model"===eS&&ed&&!tH&&(0,i.jsxs)("div",{children:[(0,i.jsx)("span",{style:et(o),children:"Cadrage du duo"}),(0,i.jsx)("div",{style:{display:"flex",flexWrap:"wrap",gap:Q.xs},children:[["waist","Plan taille"],["full","Corps entier"]].map(e=>{let[t,n]=e;return(0,i.jsx)("button",{onClick:()=>eI(t),style:eo(eR===t,o),children:n},t)})}),(0,i.jsx)("div",{style:{fontSize:10,color:o.textDim,marginTop:4},children:"Le plan taille rend les motifs nettement plus grands et plus fid\xe8les."})]}),"model"===eS&&!tU.closeup&&!ed&&(0,i.jsxs)("div",{children:[(0,i.jsx)("span",{style:et(o),children:"Cadrage"}),(0,i.jsx)("div",{style:{display:"flex",flexWrap:"wrap",gap:Q.xs},children:t7.map(e=>(0,i.jsx)("button",{onClick:()=>eI(e.id),style:eo(eR===e.id,o),children:e.label},e.id))}),"mix"===eR&&eT>1&&(0,i.jsx)("div",{style:{fontSize:10,color:o.textDim,marginTop:4},children:"Le cadrage varie d'une variation \xe0 l'autre."})]}),(0,i.jsxs)("div",{children:[(0,i.jsxs)("button",{onClick:()=>tq(e=>!e),style:{display:"flex",alignItems:"center",justifyContent:"space-between",width:"100%",background:"none",border:"none",cursor:"pointer",padding:0,fontFamily:G},children:[(0,i.jsx)("span",{style:et(o),children:"R\xe9glages de sortie"}),(0,i.jsxs)("span",{style:{fontSize:11,color:o.textDim,marginLeft:"auto"},children:[null==(n=t3.find(e=>e.id===ew))?void 0:n.label," \xb7 ",e_," \xb7 ",em.toUpperCase()," \xb7 ",eT," var. ",tW?"▾":"▸"]})]}),tW&&(0,i.jsxs)("div",{style:{display:"flex",flexDirection:"column",gap:Q.lg,marginTop:Q.md},children:[(0,i.jsxs)("div",{style:{display:"flex",gap:Q.xl},children:[(0,i.jsxs)("div",{children:[(0,i.jsx)("span",{style:et(o),children:"Format"}),(0,i.jsx)("div",{style:{display:"flex",gap:Q.xs},children:t3.map(e=>(0,i.jsx)("button",{onClick:()=>eC(e.id),style:eo(ew===e.id,o),children:e.label},e.id))})]}),(0,i.jsxs)("div",{children:[(0,i.jsx)("span",{style:et(o),children:"R\xe9solution"}),(0,i.jsx)("div",{style:{display:"flex",gap:Q.xs},children:nr.map(e=>(0,i.jsxs)("button",{onClick:()=>ez(e),title:"2K"===e?"Recommand\xe9 pour les visuels e-commerce finaux (motifs plus fid\xe8les)":void 0,style:eo(e_===e,o),children:[e,"2K"===e?" ★":""]},e))}
1),"1K"===e_&&(0,i.jsx)("div",{style:{fontSize:10,color:o.textDim,marginTop:4},children:"1K = brouillons rapides \xb7 passez en 2K pour les visuels boutique (d\xe9tails des motifs plus fid\xe8les)"})]})]}),(0,i.jsxs)("div",{children:[(0,i.jsx)("span",{style:et(o),children:"Variations"}),(0,i.jsx)("div",{style:{display:"flex",gap:Q.xs},children:nl.map(e=>(0,i.jsx)("button",{onClick:()=>eD(e),style:{...eo(eT===e,o),minWidth:36,justifyContent:"center"},children:e},e))})]}),(0,i.jsxs)("div",{children:[(0,i.jsxs)("button",{onClick:()=>{eh(e=>{let t=!e;return q({motif_autocheck:t}).catch(()=>{}),t})},style:{display:"flex",alignItems:"center",gap:Q.sm,background:"none",border:"none",cursor:"pointer",padding:0,color:ex?o.text:o.textMuted,fontFamily:G},children:[(0,i.jsx)("span",{style:{width:32,height:18,borderRadius:$.pill,background:ex?o.gold:o.surfaceAlt,border:"1px solid ".concat(ex?o.gold:o.border),position:"relative",transition:"all 0.2s ease",flexShrink:0},children:(0,i.jsx)("span",{style:{position:"absolute",top:1,left:ex?15:1,width:14,height:14,borderRadius:"50%",background:ex?o.bg:o.textMuted,transition:"left 0.2s ease"}})}),(0,i.jsx)("span",{style:{fontSize:12},children:"Autocontr\xf4le motif + re-tirage auto"})]}),(0,i.jsx)("div",{style:{fontSize:10,color:o.textDim,marginTop:4},children:ex?"Chaque rendu est v\xe9rifi\xe9 contre le fichier motif ; en cas d'\xe9cart franc, un re-tirage automatique. Co\xfbt : ~2 mini-analyses par image (n\xe9gligeable) + 1 image Gemini uniquement si re-tirage.":"D\xe9sactiv\xe9 : aucune v\xe9rification ni re-tirage — co\xfbt minimal, mais les motifs hallucin\xe9s ne seront plus rattrap\xe9s automatiquement."})]}),(0,i.jsxs)("div",{children:[(0,i.jsxs)("span",{style:et(o),children:["Taille du set ",(0,i.jsx)("span",{style:{textTransform:"none",color:o.textDim,fontWeight:400},children:"\xb7 d\xe9clinaison \xab m\xeame mannequin \xbb"})]}),(0,i.jsx)("div",{style:{display:"flex",gap:Q.xs},children:no.map(e=>(0,i.jsx)("button",{onClick:()=>t_(e),style:{...eo(tC===e,o),minWidth:36,justifyContent:"center"},children:e},e))}),(0,i.jsx)("div",{style:{fontSize:10,color:o.textDim,marginTop:4},children:tV?"Le set alterne dos/face et varie les poses.":"Le set varie les poses du m\xeame mannequin."})]})]})]}),(0,i.jsx)("button",{onClick:nb,disabled:!nG,style:{...ei(o.gold,o),background:o.gold,color:o.bg,padding:"11px 16px",fontSize:13,justifyContent:"center",opacity:nG?1:.5,cursor:nG?"pointer":"not-allowed",marginTop:"auto"},children:eU?"G\xe9n\xe9ration en cours…":"G\xe9n\xe9rer le shooting".concat(eT>1?" \xb7 ".concat(eT," images"):"")}),(0,i.jsx)("button",{onClick:()=>{nF(nL(),{thumbUrl:(null==y?void 0:y.url)||(null==v?void 0:v.url)||(null==E?void 0:E.url)||(null==x?void 0:x.url)||null})},title:"Enregistrer ce r\xe9glage pour le r\xe9utiliser plus tard",style:{...ei(null,o),justifyContent:"center"},children:"☆ Enregistrer comme recette"})]}),(0,i.jsx)("div",{ref:eN,style:{flex:c?"none":1,overflowY:c?"visible":"auto",padding:c?Q.lg:Q.xxl,minHeight:c?220:void 0},children:0===eP.length?(0,i.jsx)(eg,{t:o,icon:"◳",title:"La planche est vide",description:c?"R\xe9glez votre prise de vue ci-dessus, puis lancez la g\xe9n\xe9ration. Les images apparaissent ici au fil de leur arriv\xe9e.":"R\xe9glez votre prise de vue \xe0 gauche, puis lancez la g\xe9n\xe9ration. Les images apparaissent ici au fil de leur arriv\xe9e."}):(0,i.jsx)("div",{style:{display:"grid",gridTemplateColumns:1===eP.length?"minmax(0, 460px)":"repeat(auto-fill, minmax(260px, 1fr))",gap:Q.lg},children:eP.map((e,t)=>(0,i.jsxs)("div",{style:{position:"relative",borderRadius:$.lg,overflow:"hidden",background:o.surface,border:"1px solid ".concat(o.border)},children:[(0,i.jsxs)("div",{style:{position:"relative",width:"100%",paddingTop:ns(e.orientation||ew)},children:["pending"===e.status&&(0,i.jsx)("div",{style:{position:"absolute",inset:0,background:"linear-gradient(100deg, ".concat(o.surface," 30%, ").concat(o.surfaceAlt," 50%, ").concat(o.surface," 70%)"),backgroundSize:"200% 100%",animation:"studioShimmer 1.4s linear infinite",display:"flex",alignItems:"center",justifyContent:"center"}
1,children:(0,i.jsx)("span",{style:{fontSize:10,color:o.textDim,letterSpacing:"0.08em",textTransform:"uppercase"},children:"D\xe9veloppement…"})}),"done"===e.status&&(0,i.jsx)("img",{src:e.thumb||e.url,alt:"Shot ".concat(t+1),style:{position:"absolute",inset:0,width:"100%",height:"100%",objectFit:"cover"}}),"error"===e.status&&(0,i.jsxs)("div",{style:{position:"absolute",inset:0,display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",gap:Q.sm,padding:Q.lg,textAlign:"center"},children:[(0,i.jsx)("span",{style:{fontSize:11,color:o.red,lineHeight:1.4},children:e.error}),(0,i.jsx)("button",{onClick:()=>nv(t),style:ei(null,o),children:"R\xe9essayer"})]})]}),"done"===e.status&&(0,i.jsxs)("div",{style:{display:"flex",flexDirection:"column",gap:Q.xs,padding:Q.sm,borderTop:"1px solid ".concat(o.border)},children:[(0,i.jsxs)("div",{style:{display:"flex",gap:Q.xs},children:[(0,i.jsx)("button",{onClick:()=>na(e.url,"sudist-".concat(eS,"-").concat(t+1,".png")),style:{...ei(null,o),flex:1,justifyContent:"center"},children:"T\xe9l\xe9charger"}),(0,i.jsx)("button",{onClick:()=>nv(t),title:"R\xe9g\xe9n\xe9rer cette variation","aria-label":"R\xe9g\xe9n\xe9rer cette variation",style:ei(null,o),children:"↻"}),(0,i.jsx)("button",{onClick:()=>nw(t),disabled:eU,title:"Retoucher un d\xe9tail (m\xeame photo, correction locale)","aria-label":"Retoucher un d\xe9tail",style:{...ei(null,o),opacity:eU?.5:1,cursor:eU?"not-allowed":"pointer"},children:"✎"}),(0,i.jsx)("a",{href:e.url,target:"_blank",rel:"noreferrer",title:"Voir en grand","aria-label":"Voir en grand",style:{...ei(null,o),textDecoration:"none"},children:"⤢"})]}),"model"===eS&&!e.coupleShot&&(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)("button",{onClick:()=>nS(t,"repose"),disabled:eU,title:"Nouvelle pose avec exactement le m\xeame mannequin et le m\xeame d\xe9cor",style:{...ei(o.gold,o),justifyContent:"center",opacity:eU?.5:1,cursor:eU?"not-allowed":"pointer"},children:"⇄ Changer de pose (m\xeame mannequin)"}),tV&&(0,i.jsx)("button",{onClick:()=>nS(t,"flip"),disabled:eU,title:"G\xe9n\xe9rer la vue compl\xe9mentaire avec exactement le m\xeame mannequin",style:{...ei(null,o),justifyContent:"center",opacity:eU?.5:1,cursor:eU?"not-allowed":"pointer"},children:"back"===e.view?"G\xe9n\xe9rer la face (m\xeame mannequin)":"G\xe9n\xe9rer le dos (m\xeame mannequin)"}),(0,i.jsxs)("button",{onClick:()=>nV(nL(),e.url,e.view),disabled:eU||tk,title:"D\xe9cliner un set complet : plusieurs poses + face/dos, m\xeame mannequin",style:{...ei(null,o),justifyContent:"center",opacity:eU||tk?.5:1,cursor:eU||tk?"not-allowed":"pointer"},children:["⊞ G\xe9n\xe9rer un set \xb7 ",tC]}),(0,i.jsx)("button",{onClick:()=>nP(e.url),title:"Ajouter ce visage \xe0 la biblioth\xe8que de mannequins (r\xe9utilisable)",style:{...ei(null,o),justifyContent:"center"},children:"☆ Ajouter aux mannequins"})]}),e.coupleShot&&(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)("button",{onClick:()=>(e=>{var t,n;let i=eP[e];if(!i||"done"!==i.status)return;let r=i.gen?nj(i.gen,"couple",e):{refImageUrl:i.url,refMode:"couple",variationIndex:e},l=eP.length;eO(e=>[...e,{status:"pending",_ov:r,coupleShot:!0}]),ny(l,(null==(t=(n=crypto).randomUUID)?void 0:t.call(n))||"b".concat(Date.now()),r).then(tK)})(t),disabled:eU,title:"Nouvelle photo du m\xeame duo, poses diff\xe9rentes",style:{...ei(o.gold,o),background:o.gold,color:o.bg,justifyContent:"center",opacity:eU?.5:1,cursor:eU?"not-allowed":"pointer"},children:"⇄ Changer les poses (m\xeames mannequins)"}),(0,i.jsxs)("button",{onClick:()=>nV({...nL(),couple:!0},e.url,e.view),disabled:eU||tk,title:"D\xe9cliner un set du m\xeame duo (poses vari\xe9es)",style:{...ei(null,o),justifyContent:"center",opacity:eU||tk?.5:1,cursor:eU||tk?"not-allowed":"pointer"},children:["⊞ Set du duo \xb7 ",tC]})]}),(0,i.jsx)("button",{onClick:()=>tp(e.url),style:{...ei(null,o),justifyContent:"center"},children:"Assigner \xe0 un produit"})]})]},t))})})]}),"gallery"===a&&(0,i.jsxs)("div",{style:{flex:1,overflowY:"auto",padding:c?Q.lg:Q.xxl},children:[(0,i.jsxs)("div",{style:{display:"flex",flexWrap:"wrap",gap:Q.xs,alignItems:"center",marginBottom:Q.xl},children:[(0,i.jsx)("span",{style:{fontSize:11,color:o.textMuted,fontFamily:K,marginRight:Q.xs},children:"Type"}),(0,i.jsx)("button",{onClick:()=>tY("shot","all"),style:eo("all"===eZ,o),children:"Tous"}),t6.map(e=>(0,i.jsx)("button",{onClick:()=>tY("shot",e.id),style:eo(eZ===e.id,o),children:e.label},e.id)),(0,i.jsx)("span",{style:{width:1,height:18,background:o.border,margin:"0 ".concat(Q.sm,"px")}}),(0,i.jsx)("span",{style:{fontSize:11,color:o.textMuted,fontFamily:K,marginRight:Q.xs},children:"Cat\xe9gorie"}),[["all","Tous"],["solo","Solo"],["duo","Duo"],["set","Set"]].map(e=>{let[t,n]=e;return(0,i.jsx)("button",{onClick:()=>tY("kind",t),style:eo(e1===t,o),children:n},t)}),(0,i.jsx)("span",{style:{flex:1}}),(0,i.jsx)("button",{onClick:nW,disabled:!!nI,title:"T\xe9l\xe9charger TOUTE la galer
1ie (filtres ignor\xe9s) en un zip, puis tout supprimer de l'app et du stockage Supabase",style:{...ei(nI?null:o.gold,o),whiteSpace:"nowrap",opacity:nI?.7:1,cursor:nI?"wait":"pointer"},children:nI||"⬇ Flush \xb7 tout t\xe9l\xe9charger & vider"})]}),(()=>{let e=eK.filter(e=>e.motif_check||e.duration_ms);if(!e.length)return null;let t=e.filter(e=>["ok","retried","doubtful"].includes(e.motif_check)),n=t.filter(e=>"retried"===e.motif_check).length,r=t.filter(e=>"doubtful"===e.motif_check).length,l=e.filter(e=>e.duration_ms),s=l.length?Math.round(l.reduce((e,t)=>e+t.duration_ms,0)/l.length/1e3):null,a=e=>"".concat(Math.round(e/t.length*100),"%");return(0,i.jsxs)("div",{style:{fontSize:10,color:o.textDim,fontFamily:K,marginBottom:Q.lg},children:["Sant\xe9 (sur ",e.length," g\xe9n. charg\xe9es) : ",t.length?"motifs v\xe9rifi\xe9s ".concat(t.length," \xb7 re-tirage ").concat(a(n)," \xb7 douteux ").concat(a(r)):"aucun contr\xf4le motif",null!==s?" \xb7 dur\xe9e moy. ".concat(s,"s"):""]})})(),0===eK.length?(0,i.jsx)(eg,{t:o,icon:"❏",title:"all"!==eZ||"all"!==e1?"Aucun r\xe9sultat pour ce filtre":"Aucun shooting pour l'instant",description:"all"!==eZ||"all"!==e1?"Essayez un autre filtre ou r\xe9initialisez la s\xe9lection.":"Vos g\xe9n\xe9rations appara\xeetront ici, pr\xeates \xe0 \xeatre ret\xe9l\xe9charg\xe9es."}):(0,i.jsx)("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fill, minmax(220px, 1fr))",gap:Q.lg},children:eK.map(e=>{var t,n;return(0,i.jsxs)("div",{style:{borderRadius:$.lg,overflow:"hidden",background:o.surface,border:"1px solid ".concat(o.border)},children:[(0,i.jsx)("div",{style:{position:"relative",width:"100%",paddingTop:ns(e.orientation)},children:(0,i.jsx)("img",{src:e.thumb_url||e.image_url,alt:e.shot_type,style:{position:"absolute",inset:0,width:"100%",height:"100%",objectFit:"cover"}})}),(0,i.jsxs)("div",{style:{padding:Q.sm,display:"flex",flexDirection:"column",gap:Q.xs},children:[(0,i.jsxs)("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",gap:Q.xs},children:[(0,i.jsxs)("span",{style:{fontSize:10,color:o.textMuted,fontFamily:K},children:[(null==(t=t6.find(t=>t.id===e.shot_type))?void 0:t.label)||e.shot_type," \xb7 ",e.image_size,e.set_id&&(0,i.jsx)("span",{style:{color:o.gold},children:" \xb7 set"}),e.is_couple&&(0,i.jsx)("span",{style:{color:o.gold},children:" \xb7 duo"})]}),(0,i.jsxs)("div",{style:{display:"flex",gap:4},children:[(0,i.jsx)("button",{onClick:()=>nq(e),disabled:!!nT,title:"Retoucher un d\xe9tail (m\xeame photo, correction locale)",style:{...ei(null,o),padding:"4px 8px",opacity:nT?.5:1,cursor:nT?"not-allowed":"pointer"},children:"✎"}),(0,i.jsx)("button",{onClick:()=>na(e.image_url,"sudist-".concat(e.shot_type,".png")),title:"T\xe9l\xe9charger",style:{...ei(null,o),padding:"4px 8px"},children:"⬇"}),(0,i.jsx)("button",{onClick:()=>tp(e.image_url),title:"Assigner \xe0 un produit Shopify",style:{...ei(null,o),padding:"4px 8px"},children:"↗"}),(0,i.jsx)("button",{onClick:()=>nz(e.id),title:"Supprimer",style:{...ei(null,o),padding:"4px 8px",color:o.textDim},children:"\xd7"})]})]}),e.is_couple&&(0,i.jsxs)("div",{style:{display:"flex",gap:Q.xs},children:[(0,i.jsx)("button",{onClick:()=>nR(e,"couple"),disabled:!!nT,title:"M\xeames deux mannequins, nouvelles poses",style:{...ei(null,o),flex:1,justifyContent:"center",fontSize:10,opacity:nT?.5:1,cursor:nT?"not-allowed":"pointer"},children:nT===e.id?"G\xe9n\xe9ration…":"⇄ Poses"}),(0,i.jsxs)("button",{onClick:()=>nV(nA(e),e.image_url,e.view||"front"),disabled:tk||eU,title:"D\xe9cliner un set du m\xeame duo (poses vari\xe9es)",style:{...ei(null,o),flex:1,justifyContent:"center",fontSize:10,opacity:tk||eU?.5:1,cursor:tk||eU?"not-allowed":"pointer"},children:["⊞ Set \xb7 ",tC]})]}),"model"===e.shot_type&&!e.is_couple&&(0,i.jsxs)("div",{style:{display:"flex",gap:Q.xs},children:[(0,i.jsx)("button",{onClick:()=>nR(e,"repose"),disabled:!!nT,title:"Nouvelle pose, m\xeame mannequin",style:{...ei(null,o),flex:1,justifyContent:"center",fontSize:10,opacity:nT?.5:1,cursor:nT?"not-allowed":"pointer"},children:nT===e.id?"G\xe9n\xe9ration…":"⇄ Pose"}),(t5(e.product_type||"tshirt")||(null==(n=t4.find(t=>
1t.id===e.product_type))?void 0:n.hasBack))&&(0,i.jsx)("button",{onClick:()=>nR(e,"flip"),disabled:!!nT,title:"Vue compl\xe9mentaire (face/dos), m\xeame mannequin",style:{...ei(null,o),flex:1,justifyContent:"center",fontSize:10,opacity:nT?.5:1,cursor:nT?"not-allowed":"pointer"},children:"back"===e.view?"Voir la face":"Voir le dos"})]}),!e.is_couple&&(0,i.jsxs)("div",{style:{display:"flex",gap:Q.xs},children:[(0,i.jsx)("button",{onClick:()=>nR(e,"reframe"),disabled:!!nT,title:"M\xeame photo dans un autre format (m\xeame mannequin et d\xe9cor), d\xe9cor \xe9tendu par l'IA",style:{...ei(null,o),flex:1,justifyContent:"center",fontSize:10,opacity:nT?.5:1,cursor:nT?"not-allowed":"pointer"},children:nT===e.id?"G\xe9n\xe9ration…":"portrait"===e.orientation?"↔ Paysage":"↕ Portrait"}),"model"===e.shot_type&&(0,i.jsxs)("button",{onClick:()=>nV(nA(e),e.image_url,e.view||"front"),disabled:tk||eU,title:"D\xe9cliner un set complet : plusieurs poses + face/dos, m\xeame mannequin",style:{...ei(null,o),flex:1,justifyContent:"center",fontSize:10,opacity:tk||eU?.5:1,cursor:tk||eU?"not-allowed":"pointer"},children:["⊞ Set \xb7 ",tC]}),(0,i.jsx)("button",{onClick:()=>nP(e.image_url),title:"Ajouter ce visage \xe0 la biblioth\xe8que de mannequins (r\xe9utilisable)",style:{...ei(null,o),flex:1,justifyContent:"center",fontSize:10},children:"☆ Mannequin"})]})]})]},e.id)})}),eK.length>0&&eJ&&(0,i.jsx)("div",{ref:e5,style:{display:"flex",justifyContent:"center",alignItems:"center",minHeight:48,marginTop:Q.xl},children:eQ&&(0,i.jsx)("span",{style:{fontSize:12,color:o.textMuted,fontFamily:K},children:"Chargement…"})})]}),"settings"===a&&(0,i.jsxs)("div",{style:{flex:1,overflowY:"auto",padding:c?Q.lg:Q.xxl,maxWidth:920},children:[(0,i.jsxs)("div",{style:{marginBottom:Q.xxxl},children:[(0,i.jsx)("div",{style:{fontSize:15,fontFamily:G},children:"Profil mannequin"}),(0,i.jsx)("div",{style:{fontSize:11,color:o.textMuted,marginTop:2,maxWidth:460,lineHeight:1.5},children:"Le casting type pour les shoots \xab Mod\xe8le \xbb, r\xe9utilis\xe9 \xe0 chaque g\xe9n\xe9ration pour garder une coh\xe9rence sur une collection. D\xe9crivez la personne, pas la pose."}),(0,i.jsx)("textarea",{value:e9,onChange:e=>{te(e.target.value),tr(!1)},rows:3,placeholder:"Ex : femme, d\xe9but trentaine, peau mate naturelle, cheveux bruns longs, silhouette \xe9lanc\xe9e, allure m\xe9diterran\xe9enne d\xe9contract\xe9e, maquillage minimal.",style:{...ee(o),minHeight:72,marginTop:Q.md}}),(0,i.jsxs)("div",{style:{fontSize:11,color:o.textMuted,marginTop:Q.md,maxWidth:460,lineHeight:1.5},children:["Profil mannequin ",(0,i.jsx)("b",{children:"homme"})," — utilis\xe9 quand le casting \xab Homme \xbb est s\xe9lectionn\xe9 dans le studio."]}),(0,i.jsx)("textarea",{value:tt,onChange:e=>{tn(e.target.value),tr(!1)},rows:3,placeholder:"Ex : homme, trentaine, barbe courte naturelle, cheveux bruns textur\xe9s, carrure athl\xe9tique naturelle, allure m\xe9diterran\xe9enne d\xe9contract\xe9e.",style:{...ee(o),minHeight:72,marginTop:Q.sm}}),(0,i.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:Q.md,marginTop:Q.sm},children:[(0,i.jsx)("button",{onClick:t1,disabled:ti,style:{...ei(ti?null:o.gold,o),opacity:ti?.5:1,cursor:ti?"default":"pointer"},children:ti?"Enregistr\xe9":"Enregistrer"}),!ti&&(0,i.jsx)("span",{style:{fontSize:10,color:o.textDim},children:"Modifications non enregistr\xe9es"})]})]}),(0,i.jsxs)("div",{style:{marginBottom:Q.xxxl},children:[(0,i.jsx)("div",{style:{fontSize:15,fontFamily:G},children:"Format de fichier"}),(0,i.jsxs)("div",{style:{fontSize:11,color:o.textMuted,marginTop:2,maxWidth:520,lineHeight:1.5},children:["Format des images g\xe9n\xe9r\xe9es, appliqu\xe9 par d\xe9faut \xe0 chaque shooting et retouche. Le ",(0,i.jsx)("b",{children:"WebP"})," est recommand\xe9 pour l'e-commerce : un fichier ~10\xd7 plus l\xe9ger qu'un PNG pour un rendu visuellement identique, id\xe9al pour la vitesse d'une boutique en ligne. La r\xe9solution (1K / 2K / 3K) reste ind\xe9pendante — vous pouvez viser un fichier l\xe9ger ",(0,i.jsx)("i",{children:"et"})," une haute r\xe9solution."]}),(0,i.jsx)("div",{style:{display:"flex",gap:Q.xs,marginTop:Q.md},children:[["webp","WebP","L\xe9ger \xb7 recommand\xe9"],["png","PNG","Sans perte \xb7 lourd"],["jpeg","JPEG","Universel"]].map(e=>{let[t,n,r]=e;return(0,i.jsxs)("button",{onClick:()=>{ef(t),q({output_format:t}).catch(()=>{})},title:r,style:{...eo(em===t,o),flexDirection:"column",alignItems:"flex-start",ga
1p:1,padding:"6px 12px",height:"auto"},children:[(0,i.jsxs)("span",{style:{fontWeight:500},children:[n,"webp"===t?" ★":""]}),(0,i.jsx)("span",{style:{fontSize:9,color:em===t?o.bg:o.textDim,textTransform:"none",letterSpacing:0},children:r})]},t)})}),"png"!==em&&(0,i.jsxs)("div",{style:{marginTop:Q.md,maxWidth:360},children:[(0,i.jsxs)("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"baseline"},children:[(0,i.jsx)("span",{style:et(o),children:"Qualit\xe9"}),(0,i.jsx)("span",{style:{fontSize:12,color:o.text,fontFamily:K},children:ey})]}),(0,i.jsx)("input",{type:"range",min:60,max:100,step:1,value:ey,onChange:e=>eb(Number(e.target.value)),onMouseUp:e=>t8(e.target.value),onTouchEnd:e=>t8(e.target.value),onKeyUp:e=>t8(e.target.value),style:{width:"100%",accentColor:o.gold,marginTop:4}}),(0,i.jsx)("div",{style:{fontSize:10,color:o.textDim,marginTop:2},children:"90 = \xe9quilibre id\xe9al (quasi indiscernable, tr\xe8s l\xe9ger). Montez vers 100 pour un maximum de d\xe9tail, descendez pour all\xe9ger encore."})]})]}),(0,i.jsxs)("div",{style:{marginBottom:Q.xxxl},children:[(0,i.jsxs)("button",{onClick:()=>tc(e=>!e),style:{display:"flex",alignItems:"center",gap:Q.sm,background:"none",border:"none",cursor:"pointer",padding:0,fontFamily:G,fontSize:15,color:o.text},children:[(0,i.jsx)("span",{style:{fontSize:11},children:td?"▾":"▸"})," Instructions IA (prompt)"]}),(0,i.jsx)("div",{style:{fontSize:11,color:o.textMuted,marginTop:4,maxWidth:520,lineHeight:1.5},children:"Ajuste le ton du rendu (r\xe9alisme, poses, interdits, descriptions de prise de vue) sans d\xe9ploiement. Les r\xe8gles structurelles (anti-inversion cœur/dos, une vue par image, fid\xe9lit\xe9 du motif) restent fixes. Un champ vid\xe9 revient \xe0 la valeur par d\xe9faut."}),td&&(0,i.jsxs)("div",{style:{display:"flex",flexDirection:"column",gap:Q.md,marginTop:Q.lg},children:[nt.map(e=>{let t=e.key.split(".").reduce((e,t)=>null==e?void 0:e[t],tl),n="list"===e.kind?Array.isArray(t)?t.join("\n"):"":t||"";return(0,i.jsxs)("div",{children:[(0,i.jsx)("span",{style:et(o),children:e.label}),(0,i.jsx)("textarea",{value:n,rows:"list"===e.kind?5:3,onChange:t=>{var n,i;return n=e.key,i="list"===e.kind?t.target.value.split("\n"):t.target.value,void(ta(!1),to(e=>((e,t,n)=>{let i=t.split(".");if(1===i.length)return{...e,[i[0]]:n};let[r,l]=i;return{...e,[r]:{...e[r]||{},[l]:n}}})(e,n,i)))},style:{...ee(o),minHeight:56}})]},e.key)}),(0,i.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:Q.md},children:[(0,i.jsx)("button",{onClick:nu,disabled:ts,style:{...ei(ts?null:o.gold,o),opacity:ts?.5:1,cursor:ts?"default":"pointer"},children:ts?"Enregistr\xe9":"Enregistrer"}),(0,i.jsx)("button",{onClick:()=>{to(ne),ta(!1)},style:ei(null,o),children:"R\xe9initialiser"}),!ts&&(0,i.jsx)("span",{style:{fontSize:10,color:o.textDim},children:"Modifications non enregistr\xe9es"})]})]})]}),(0,i.jsx)(nh,{t:o,title:"Mood de marque",description:"Photos d'identit\xe9 de la marque, r\xe9inject\xe9es comme R\xc9F\xc9RENCES IMAGES \xe0 chaque g\xe9n\xe9ration. Sans style s\xe9lectionn\xe9, elles d\xe9finissent tout le look (lumi\xe8re, palette, atmosph\xe8re). Avec un style actif, elles ne portent plus que l'ADN de la marque (palette, mati\xe8res, esprit — 2 images max) et le style dirige la mise en sc\xe8ne. \xc0 distinguer du Lieu (d\xe9cor pr\xe9cis reproduit en fond).",items:tL,kind:"mood",onAdd:nC,onRemove:n_,loading:e8}),(0,i.jsx)("div",{style:{height:Q.xxxl}}),(0,i.jsx)(nh,{t:o,title:"Coupe de r\xe9f\xe9rence",description:"Une vue \xe0 plat ou de face de votre v\xeatement VIERGE (sans motif) — t-shirt, sweat, hoodie, polo ou autre pi\xe8ce (col, fermetures, fit, mati\xe8re). Id\xe9al : photo fournisseur du blank, col bien lisible, fond neutre. Sert de gabarit de coupe pour les shootings.",items:tA,kind:"garment",onAdd:nC,onRemove:n_,loading:e8}),(0,i.jsx)("div",{style:{height:Q.xxxl}}),(0,i.jsx)(nh,{t:o,title:"Mannequins",description:"Des photos de personnes \xe0 r\xe9utiliser comme mannequin. S\xe9lectionnez-en un dans le studio pour garder le m\xeame visage d'un shooting \xe0 l'autre — le v\xeatement, la coupe, la couleur et le motif restent ceux de vos r\xe9glages. Id\xe9alement un portrait net, cadrage buste ou plein-pied.",items:tF,kind:"mannequin",onAdd:nC,onRemove:n_,loading:e8}),(0,i.jsx)("div",{style:{height:Q.xxxl}}
1),(0,i.jsx)(nh,{t:o,title:"Lieux",description:"Des photos de d\xe9cors / lieux \xe0 imposer comme cadre de la sc\xe8ne (terrasse, plage, ruelle, atelier…). S\xe9lectionnez-en un dans le studio : le shooting sera plac\xe9 dans ce lieu, reproduit fid\xe8lement. Contrairement au mood, le lieu est r\xe9ellement utilis\xe9 comme d\xe9cor, pas comme simple inspiration.",items:tE,kind:"lieu",onAdd:nC,onRemove:n_,loading:e8}),(0,i.jsx)("div",{style:{height:Q.xxxl}}),(0,i.jsxs)("div",{children:[(0,i.jsxs)("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"flex-end",gap:Q.lg,marginBottom:Q.md},children:[(0,i.jsxs)("div",{children:[(0,i.jsx)("div",{style:{fontSize:15,fontFamily:G},children:"Styles \xb7 direction artistique"}),(0,i.jsx)("div",{style:{fontSize:11,color:o.textMuted,marginTop:2,maxWidth:520,lineHeight:1.5},children:"Uploadez des images de r\xe9f\xe9rence d'un shooting : l'outil en extrait une direction artistique d\xe9taill\xe9e (lumi\xe8re, colorim\xe9trie, optique/grain, fond, cadrage, registre de pose et attitude des mannequins, allure, ambiance, finition) et la sauvegarde comme style r\xe9utilisable, \xe0 s\xe9lectionner ensuite dans le studio. Plus pr\xe9cis que le Mood. Trois styles par d\xe9faut sont toujours disponibles."})]}),(0,i.jsx)("button",{onClick:()=>{var e;return null==(e=el.current)?void 0:e.click()},disabled:tI,style:{...ei(tI?null:o.gold,o),whiteSpace:"nowrap",opacity:tI?.6:1},children:tI?"Analyse…":"+ Cr\xe9er depuis des images"}),(0,i.jsx)("input",{ref:el,type:"file",accept:"image/png,image/jpeg,image/webp",hidden:!0,multiple:!0,onChange:async e=>{let t=Array.from(e.target.files||[]);if(e.target.value="",t.length){let e=await tZ("Nom du style ?",{placeholder:"Ex : Lookbook \xe9t\xe9 2025"});e&&nO(e,t)}}})]}),(0,i.jsxs)("div",{style:{fontSize:11,color:o.textDim},children:["Par d\xe9faut : ",nn.map(e=>e.name).join(" \xb7 ")]}),tz.length>0&&(0,i.jsx)("div",{style:{display:"flex",flexDirection:"column",gap:Q.md,marginTop:Q.md},children:tz.map(e=>(0,i.jsxs)("div",{style:{border:"1px solid ".concat(o.border),borderRadius:$.md,padding:Q.md,background:o.surface},children:[(0,i.jsxs)("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",gap:Q.md},children:[(0,i.jsx)("div",{style:{fontSize:13,color:o.text,fontWeight:500},children:e.name}),(0,i.jsx)("button",{onClick:()=>nU(e.id),style:{...ei(null,o),padding:"2px 8px",color:o.textDim},children:"Supprimer"})]}),Array.isArray(e.source_image_urls)&&e.source_image_urls.length>0&&(0,i.jsx)("div",{style:{display:"flex",gap:Q.xs,marginTop:Q.sm,flexWrap:"wrap"},children:e.source_image_urls.map((e,t)=>(0,i.jsx)("img",{src:e,alt:"r\xe9f",style:{width:44,height:44,borderRadius:$.sm,objectFit:"cover",border:"1px solid ".concat(o.border)}},t))}),(0,i.jsx)("div",{style:{fontSize:11,color:o.textMuted,marginTop:Q.sm,lineHeight:1.5},children:e.da_prompt})]},e.id))})]})]}),tu&&(0,i.jsx)(nx,{t:o,imageUrl:tu,onClose:()=>tp(null)}),th&&(0,i.jsx)(ng,{t:o,dialog:th,onClose:()=>tm(null)}),tg&&(0,i.jsx)(np,{t:o,toast:tg})]})}function np(e){let{t:t,toast:n}=e,r="error"===n.type?t.red:"success"===n.type?t.green:t.gold,l=72*(window.innerWidth<768);return(0,i.jsx)("div",{style:{position:"fixed",bottom:"max(".concat(Q.xl+l,"px, calc(env(safe-area-inset-bottom) + ").concat(l,"px))"),right:Q.xl,zIndex:1200,maxWidth:"min(360px, calc(100vw - ".concat(2*Q.xl,"px))"),background:t.surface,border:"1px solid ".concat(r,"40"),borderRadius:$.md,padding:"".concat(Q.md,"px ").concat(Q.lg,"px"),boxShadow:"0 8px 24px rgba(0,0,0,0.35)",fontFamily:G,fontSize:12,color:t.text,lineHeight:1.4},children:n.message})}function ng(e){let{t:t,dialog:n,onClose:l}=e,[o,s]=(0,r.useState)(n.value||""),a=(0,r.useRef)(null);(0,r.useEffect)(()=>{var e;"prompt"===n.kind&&(null==(e=a.current)||e.focus())},[n.kind]);let d=()=>{n.resolve("prompt"!==n.kind||o.trim()||null),l()},c=()=>{n.resolve("prompt"===n.kind&&null),l()};return(0,i.jsx)("div",{onClick:c,style:{position:"fixed",inset:0,background:"rgba(8,7,6,0.72)",display:"flex",alignItems:"center",justifyContent:"center",zIndex:1300,padding:Q.lg},children:(0,i.jsxs)("div",{onClick:e=>e.stopPropagation(),style:{width:380,maxWidth:"100%",background:t.surface,border:"1px solid ".concat(t.border),borderRadius:$.lg,padding:Q.xl,dis
1play:"flex",flexDirection:"column",gap:Q.lg,fontFamily:G},children:[(0,i.jsx)("div",{style:{fontSize:14,color:t.text},children:n.title}),"prompt"===n.kind&&(n.multiline?(0,i.jsx)("textarea",{ref:a,value:o,onChange:e=>s(e.target.value),onKeyDown:e=>{"Enter"===e.key&&(e.metaKey||e.ctrlKey)&&d(),"Escape"===e.key&&c()},rows:3,placeholder:n.placeholder||"",style:{...ee(t),minHeight:72}}):(0,i.jsx)("input",{ref:a,value:o,onChange:e=>s(e.target.value),onKeyDown:e=>{"Enter"===e.key&&d(),"Escape"===e.key&&c()},placeholder:n.placeholder||"",style:Z(t)})),(0,i.jsxs)("div",{style:{display:"flex",gap:Q.sm,justifyContent:"flex-end"},children:[(0,i.jsx)("button",{onClick:c,style:ei(null,t),children:"Annuler"}),(0,i.jsx)("button",{onClick:d,style:{...ei(n.danger?t.red:t.gold,t),background:n.danger?t.red:t.gold,color:n.danger?"#fff":t.bg},children:"prompt"===n.kind?"Valider":n.confirmLabel||"Confirmer"})]})]})})}function nx(e){let{t:t,imageUrl:n,onClose:o}=e,[s,a]=(0,r.useState)(""),[d,c]=(0,r.useState)([]),[u,p]=(0,r.useState)(!1),[g,x]=(0,r.useState)(null),[h,m]=(0,r.useState)(!1),[f,y]=(0,r.useState)(""),[b,v]=(0,r.useState)(!1),[j,S]=(0,r.useState)(!1),[k,w]=(0,r.useState)(""),C=async()=>{if(s.trim()){p(!0),w("");try{let e=await L(s.trim());e.success?c(e.products):w(e.error||"Recherche impossible")}catch(e){w(e.message)}finally{p(!1)}}},_=async()=>{if(g){v(!0),w("");try{let e,t=await (e={productId:g.id,imageUrl:n,asMain:h,variantId:f||null},l("/studio/shopify/assign",{method:"POST",body:e}));t.success?S(!0):w(t.error||"Assignation impossible")}catch(e){w(e.message)}finally{v(!1)}}};return(0,i.jsx)("div",{onClick:o,style:{position:"fixed",inset:0,background:"rgba(8,7,6,0.72)",display:"flex",alignItems:"center",justifyContent:"center",zIndex:1e3,padding:Q.lg},children:(0,i.jsxs)("div",{onClick:e=>e.stopPropagation(),style:{width:460,maxWidth:"100%",maxHeight:"86vh",overflowY:"auto",background:t.surface,border:"1px solid ".concat(t.border),borderRadius:$.lg,padding:Q.xl,dis
1play:"flex",flexDirection:"column",gap:Q.lg},children:[(0,i.jsxs)("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"flex-start",gap:Q.md},children:[(0,i.jsx)("div",{style:{fontSize:15,fontFamily:G},children:"Assigner \xe0 un produit"}),(0,i.jsx)("button",{onClick:o,style:{...ei(null,t),padding:"2px 8px"},children:"\xd7"})]}),(0,i.jsxs)("div",{style:{display:"flex",gap:Q.md,alignItems:"center"},children:[(0,i.jsx)("img",{src:n,alt:"maquette",style:{width:56,height:56,borderRadius:$.md,objectFit:"cover",border:"1px solid ".concat(t.border)}}),(0,i.jsx)("span",{style:{fontSize:11,color:t.textMuted},children:"Cette maquette sera ajout\xe9e au produit choisi."})]}),j?(0,i.jsxs)("div",{style:{display:"flex",flexDirection:"column",gap:Q.md},children:[(0,i.jsxs)("div",{style:{fontSize:13,color:t.green},children:["✓ Image ajout\xe9e \xe0 \xab ",null==g?void 0:g.title," \xbb."]}),(0,i.jsx)("button",{onClick:o,style:{...ei(t.gold,t),background:t.gold,color:t.bg,justifyContent:"center"},children:"Termin\xe9"})]}):g?(0,i.jsxs)("div",{style:{display:"flex",flexDirection:"column",gap:Q.md},children:[(0,i.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:Q.md},children:[g.image?(0,i.jsx)("img",{src:g.image,alt:"",style:{width:36,height:36,borderRadius:$.sm,objectFit:"cover"}}):null,(0,i.jsx)("span",{style:{flex:1,fontSize:13,color:t.text},children:g.title}),(0,i.jsx)("button",{onClick:()=>x(null),style:{...ei(null,t),padding:"2px 8px"},children:"Changer"})]}),(0,i.jsxs)("label",{style:{display:"flex",alignItems:"center",gap:Q.sm,cursor:"pointer",fontSize:12,color:t.text},children:[(0,i.jsx)("input",{type:"checkbox",checked:h,onChange:e=>m(e.target.checked)}),"D\xe9finir comme image principale"]}),g.variants.length>1&&(0,i.jsxs)("div",{children:[(0,i.jsx)("span",{style:et(t),children:"Assigner \xe0 une variante (optionnel)"}),(0,i.jsxs)("select",{value:f,onChange:e=>y(e.target.value),style:{...Z(t),cursor:"pointer"},children:[(0,i.jsx)("option",{value:"",children:"Toutes / aucune variante pr\xe9cise"}),g.variants.map(e=>(0,i.jsx)("option",{value:e.id,children:e.title},e.id))]})]}),(0,i.jsx)("button",{onClick:_,disabled:b,style:{...ei(t.gold,t),background:t.gold,color:t.bg,justifyContent:"center",opacity:b?.6:1},children:b?"Assignation…":"Assigner l'image"})]}):(0,i.jsxs)(i.Fragment,{children:[(0,i.jsxs)("div",{style:{display:"flex",gap:Q.sm},children:[(0,i.jsx)("input",{value:s,onChange:e=>a(e.target.value),onKeyDown:e=>"Enter"===e.key&&C(),placeholder:"Nom du produit…",autoFocus:!0,style:{...Z(t),flex:1}}),(0,i.jsx)("button",{onClick:C,disabled:u,style:ei(t.gold,t),children:u?"…":"Chercher"})]}),(0,i.jsxs)("div",{style:{display:"flex",flexDirection:"column",gap:Q.xs},children:[d.map(e=>(0,i.jsxs)("button",{onClick:()=>{x(e),y("")},style:{display:"flex",alignItems:"center",gap:Q.md,padding:Q.sm,borderRadius:$.md,border:"1px solid ".concat(t.border),background:t.surfaceAlt,cursor:"pointer",textAlign:"left",fontFamily:G},children:[e.image?(0,i.jsx)("img",{src:e.image,alt:"",style:{width:36,height:36,borderRadius:$.sm,objectFit:"cover"}}):(0,i.jsx)("div",{style:{width:36,height:36,borderRadius:$.sm,background:t.bg}}),(0,i.jsx)("span",{style:{flex:1,fontSize:12,color:t.text},children:e.title}),"ACTIVE"!==e.status&&(0,i.jsx)("span",{style:{fontSize:9,color:t.textDim,textTransform:"uppercase"},children:e.status})]},e.id)),!u&&s&&0===d.length&&(0,i.jsx)("span",{style:{fontSize:11,color:t.textDim},children:"Aucun produit trouv\xe9."})]})]}),k&&(0,i.jsx)("div",{style:{fontSize:11,color:t.red},children:k})]})})}function nh(e){let{t:t,title:n,description:l,items:o,kind:s,onAdd:a,onRemove:d,loading:c}=e,u=(0,r.useRef)(null);return(0,i.jsxs)("div",{children:[(0,i.jsxs)("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"flex-end",marginBottom:Q.md,gap:Q.lg},children:[(0,i.jsxs)("div",{children:[(0,i.jsx)("div",{style:{fontSize:15,fontFamily:G},children:n}),(0,i.jsx)("div",{style:{fontSize:11,color:t.textMuted,marginTop:2,maxWidth:460,lineHeight:1.5},children:l})]}),(0,i.jsx)("button",{onClick:()=>{var e;return null==(e=u.current)?void 0:e.click()},disabled:c,style:{...ei(null,t),whiteSpace:"nowrap"},children:c?"…":"+ Ajouter"}),(0,i.jsx)("input",{ref:u,type:"file",accept:"image/png,image/jpeg,image/webp",hidden:!0,multiple:!0,onChange:e=>{let t=Array.from(e.target.files||[]);t.length&&a(t,s),e.target.value=""}})]}),0===o.length?(0,i.jsx)("div",{style:{fontSize:12,color:t.textDim,padding:Q.lg,border:"1px dashed ".concat(t.border),borderRadius:$.md,textAlign:"center"},children:"Aucune image pour l'instant."}):(0,i.jsx)("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fill, minmax(130px, 1fr))",gap:Q.md},children:o.map(e=>(0,i.jsxs)("div",{style:{position:"relative",borderRadius:$.md,overflow:"hidden",border:"1px solid ".concat(t.border),aspectRatio:"1 / 1",background:t.bg},children:[(0,i.jsx)("img",{src:e.url,alt:e.label||s,style:{width:"100%",height:"100%",objectFit:"cover"}}),(0,i.jsx)("button",{onClick:()=>d(e.id),title:"Retirer",style:{position:"absolute",top:6,right:6,width:22,height:22,borderRadius:$.pill,border:"none",cursor:"pointer",background:"rgba(13,11,9,0.7)",color:t.text,fontSize:13,display:"flex",alignItems:"center",justifyContent:"center"},children:"\xd7"})]},e.id))})]})}function nm(e,t){return"ok"===e?t.green:"warn"===e?t.orange:t.red}function nf(e){return"ok"===e?"OK":"warn"===e?"Souci":"Cass\xe9"}function ny(e){let{checks:t,overall:n,T:l,compact:o=!1}=e,[s,a]=(0,r.useState)(!1),d=(0,r.useRef)(null);if((0,r.useEffect)(()=>
1{if(!s)return;let e=e=>{d.current&&!d.current.contains(e.target)&&a(!1)},t=e=>{"Escape"===e.key&&a(!1)};return document.addEventListener("mousedown",e),document.addEventListener("keydown",t),()=>{document.removeEventListener("mousedown",e),document.removeEventListener("keydown",t)}},[s]),!(null==t?void 0:t.length))return null;let c=t.reduce((e,t)=>(e[t.status]=(e[t.status]||0)+1,e),{});return(0,i.jsxs)("div",{ref:d,style:{position:"relative",display:"inline-flex"},children:[(0,i.jsx)("button",{type:"button",onClick:()=>a(e=>!e),"aria-label":"\xc9tat syst\xe8me — ".concat(nf(n||"ok")),"aria-expanded":s,title:o?"Syst\xe8me: ".concat(nf(n||"ok")):void 0,style:{display:"inline-flex",alignItems:"center",gap:3,background:"transparent",border:"none",padding:"2px 4px",margin:"-2px -4px",cursor:"pointer",borderRadius:4},children:o?(0,i.jsx)("span",{style:{width:7,height:7,borderRadius:"50%",background:nm(n||"ok",l),display:"inline-block"}}):t.map(e=>(0,i.jsx)("span",{title:"".concat(e.label,": ").concat(nf(e.status)).concat(e.message?" — ".concat(e.message):""),style:{width:6,height:6,borderRadius:"50%",background:nm(e.status,l),display:"inline-block"}},e.id))}),s&&(0,i.jsxs)("div",{role:"dialog","aria-label":"D\xe9tails de l'\xe9tat syst\xe8me",style:{position:"absolute",top:"calc(100% + 8px)",left:0,minWidth:240,maxWidth:320,background:l.surface,border:"1px solid ".concat(l.border),borderRadius:14,padding:12,boxShadow:"0 16px 40px ".concat(l.shadowLight||l.shadow),zIndex:50,fontSize:11.5,color:l.text},onClick:e=>e.stopPropagation(),children:[(0,i.jsxs)("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:8,paddingBottom:6,borderBottom:"1px solid ".concat(l.border)},children:[(0,i.jsx)("span",{style:{fontWeight:600,fontSize:12,color:l.text},children:"\xc9tat syst\xe8me"}),(0,i.jsxs)("span",{style:{fontSize:10.5,color:l.textMuted,fontVariantNumeric:"tabular-nums"},children:[c.ok||0," OK \xb7 ",c.warn||0," ⚠ \xb7 ",c.error||0," ✕"]})]}),(0,i.jsx)("div",{style:{display:"flex",flexDirection:"column",gap:5},children:t.map(e=>(0,i.jsxs)("div",{style:{display:"flex",alignItems:"flex-start",gap:8},children:[(0,i.jsx)("span",{style:{width:8,height:8,borderRadius:"50%",marginTop:4,background:nm(e.status,l),flexShrink:0}}),(0,i.jsxs)("div",{style:{flex:1,minWidth:0},children:[(0,i.jsx)("div",{style:{fontSize:11,color:l.text},children:e.label}),e.message&&(0,i.jsx)("div",{style:{fontSize:10,color:l.textMuted,wordBreak:"break-word"},children:e.message})]})]},e.id))})]})]})}let nb=[{label:"Accus\xe9 r\xe9ception",text:"Bonjour,\n\nNous avons bien re\xe7u votre message et nous vous r\xe9pondons dans les meilleurs d\xe9lais.\n\nBien cordialement,\nL'\xe9quipe Sudist"},{label:"Infos manquantes",text:"Bonjour,\n\nPourriez-vous nous communiquer votre num\xe9ro de commande pour que nous puissions traiter votre demande ?\n\nBien cordialement,\nL'\xe9quipe Sudist"},{label:"Escalader",text:"Bonjour,\n\nNous transf\xe9rons votre demande \xe0 notre \xe9quipe sp\xe9cialis\xe9e. Vous serez recontact\xe9(e) prochainement.\n\nBien cordialement,\nL'\xe9quipe Sudist"}],nv=[{value:null,label:"Tous"},{value:"livraison",label:"Livraison"},{value:"retour",label:"Retour"},{value:"reclamation",label:"R\xe9cla."},{value:"pre_achat",label:"Pr\xe9-achat"},{value:"autre",label:"Autre"}],nj=[{value:null,label:"Toutes"},{value:"high",label:"Haute"},{value:"medium",label:"Moy."},{value:"low",label:"Basse"}],nS=[{value:"recent",label:"R\xe9cents"},{value:"oldest",label:"Anciens"},{value:"urgent",label:"Urgents"},{value:"waiting",label:"En attente"}],nk={high:0,medium:1,low:2};function nw(e){let t=[],n={},i={},r={};for(let l of e){let e=l.email_id;if(!e)continue;let o=l.from_name?"".concat(l.from_name," <").concat(l.from_email,">"):l.from_email||"",s=l.last_inbound_at||l.received_at||new Date().toISOString();t.push({id:e,threadId:l.thread_id||null,from:o,subject:l.subject||"(sans objet)",body:l.body||"",date:s,lastInboundAt:s,status:l.status||(["sent","skipped"].includes(l.draft_status)?"closed":"open")}),(l.category||l.urgency||l.summary||l.draft_response||l.suggested_action)&&(n[e]={category:l.category||"autre",urgency:l.urgency||"low",summary:l.summary||"",draft_response:l.draft_response||"",order_number:l.order_number||null,key_info:l.key_info||[],suggested_action:l.suggested_action||"",duplicate_of:l.duplicate_of||null}),l.draft_status&&"pending"!==l.draft_status&&(i[e]=l.draft_status),l.order_data&&(r[e]=l.order_data)}return{emails:t,analysisMap:n,draftStatusMap:i,orderDataMap:r}}let nC=[{id:"home",label:"Accueil",icon:"home"},{id:"chat",label:"Chat",icon:"chat"},{id:"returns",label:"Retours",icon:"returns"},{id:"pr\xe9paration",label:"Preparation",icon:"pr\xe9paration"},{id:"expedition",label:"Exp\xe9dition",icon:"expedition"},{id:"b2b",label:"B2B",icon:"b2b"},{id:"notifications",label:"Notifications",icon:"proactive"},{id:"marketing",label:"Marketing",icon:"marketing"},{id:"prospection",label:"Prospection",icon:"prospection"},{id:"studio",label:"Studio Photo",icon:"studio"},{id:"config",label:"Param\xe8tres",icon:"config"}];function n_(){var e,t,n,d,c,u,p;let g,[x,h]=(0,r.useState)([]),[m,f]=(0,r.useState)(null),[y,b]=(0,r.useState)({}),[v,j]=(0,r.useState)({}),[S,k]=(0,r.useState)({}),[w,C]=(0,r.useState)({}),[_,z]=(0,r.useState)(null),[T,D]=(0,r.useState)(""),[R,I]=(0,r.useState)({}),[M,W]=(0,r.useState)(N),[q,L]=(0,r.useState)(null),[A,F]=(0,r.useState)("home"),[E,B]=(0,r.useState)({processed:0,drafts:0,pending:0}),[P,O]=(0,r.useState)(!1),[U,X]=(0,r.useState)("ouvert"),[ee,et]=(0,r.useState)(""),[en,es]=(0,r.useState)(null),[eu,eh]=(0,r.useState)(null),[em,ey]=(0,r.useState)(!1),[eb,ev]=(0,r.useState)(!1),[ej,eS]=(0,r.useState)(!1),ew=(0,r.useRef)(null),eC=(0,r.useRef)(null),e_=(0,r.useRef)(null),[ez,eT]=(0,r.useState)(null),[eD,eR]=(0,r.useState)([]),[eI,eM]=(0,r.useState)(!1),[eW,eq]=(0,r.useState)(""),[eL,eA]=(0,r.useState)(!1),[eF,eE]=(0,r.useState)(()=>{try{return new Set(JSON.parse(localStorage.getItem("sav-read-tickets")||"[]"))}catch(e){return new Set}}),[eB,eP]=(0,r.useState)(()=>{try{return JSON.parse(localStorage.getItem("sav-local-drafts")||"{}")}catch(e){return{}}}),[eO,eU]=(0,r.useState)(()=>{try{return JSON.parse(localStorage.getItem("sav-ticket-tags")||"{}")}catch(e){return{}}}),[eN,eH]=(0,r.useState)(""),[eV,eG]=(0,r.useState)(!1),[eK,eJ]=(0,r.useState)(!1),[eX,eQ]=(0,r.useState)(!1);(0,r.useEffect)(()=>{"dark"===localStorage.getItem("sav-theme")&&eQ(!0)},[]),(0,r.useEffect)(()=>{document.documentElement.dataset.theme=eX?"dark":"light"},[eX]);let e$=eX?J:Y,[eZ,e0]=(0,r.useState)("desktop");(0,r.useEffect)(()=>{let e=()=>{let e=window.innerWidth;e0(e<768?"mobile":e<1024?"tablet":"desktop")};return e(),window.addEventListener("resize",e),()=>window.removeEventListener("resize",e)},[]),(0,r.useEffect)(()=>{"tablet"===eZ?ey(!0):"desktop"===eZ&&ey(!1),"mobile"!==eZ&&ev(!1)},[eZ]),(0,r.useEffect)(()=>
1{if(!eb)return;let e=e=>{"Escape"===e.key&&ev(!1)};return window.addEventListener("keydown",e),()=>window.removeEventListener("keydown",e)},[eb]);let e1="mobile"===eZ,e2=!e1&&em;(0,r.useEffect)(()=>{localStorage.setItem("sav-read-tickets",JSON.stringify([...eF]))},[eF]),(0,r.useEffect)(()=>{localStorage.setItem("sav-local-drafts",JSON.stringify(eB))},[eB]),(0,r.useEffect)(()=>{localStorage.setItem("sav-ticket-tags",JSON.stringify(eO))},[eO]);let[e4,e5]=(0,r.useState)(null),[e3,e8]=(0,r.useState)("recent");(0,r.useEffect)(()=>{let e=()=>l("/health").then(L).catch(()=>{});e();let t=setInterval(e,6e4);return l("/knowledge-base").then(e=>{e.success&&e.policies&&W(e.policies)}).catch(()=>{}),o({limit:100}).then(e=>{var t;if(e.success&&(null==(t=e.tickets)?void 0:t.length)){let{emails:t,analysisMap:n,draftStatusMap:i,orderDataMap:r}=nw(e.tickets);h(t),b(n),C(i),j(r)}}).catch(()=>{}),()=>clearInterval(t)},[]),(0,r.useEffect)(()=>{if("inbox"!==A)return;let e=setInterval(()=>{o({limit:100}).then(e=>{var t;if(!e.success||!(null==(t=e.tickets)?void 0:t.length))return;let{emails:n,analysisMap:i,draftStatusMap:r,orderDataMap:l}=nw(e.tickets);h(e=>{let t=new Set(e.map(e=>e.id)),i=n.filter(e=>!t.has(e.id));return i.length?[...e,...i]:e}),f(e=>e&&n.find(t=>t.id===e.id)||e),b(e=>({...i,...e})),C(e=>({...r,...e})),j(e=>({...l,...e}))}).catch(()=>{})},18e4);return()=>clearInterval(e)},[A]),(0,r.useEffect)(()=>{let e=Object.keys(y).length;B({processed:e,drafts:x.filter(e=>"closed"===e.status).length,pending:x.length-e})},[y,w,x]);let e7=(0,r.useCallback)(async e=>{var t,n,i;let r;I(t=>({...t,[e.id]:!0}));let o=function(e){let t=e.match(/#(\d{4,})/);return t?"#".concat(t[1]):null}(e.subject+" "+e.body),s=null;if(o){let t=await l("/orders/".concat(o.replace("#","")));(s=t.success?t.order:null)&&j(t=>({...t,[e.id]:s}))}let a=(null==(n=e.from)||null==(t=n.match(/<([^>]+)>/))?void 0:t[1])||(null==(i=e.from)?void 0:i.split(" ").pop())||"",d=null,c=await l("/customer/".concat(encodeURIComponent(a)));(d=c.success?c.customer:null)&&k(t=>({...t,[e.id]:d}));let u=V(M),p=await (r=s,l("/analyze",{method:"POST",body:{email:e,orderData:r,customerData:d,systemPrompt:u}}));p.success&&p.analysis&&b(t=>({...t,[e.id]:p.analysis})),I(t=>({...t,[e.id]:!1}))},[M]);(0,r.useCallback)(async e=>{let t=y[e.id];if(!t)return;eh(null),C(t=>({...t,[e.id]:"sending"}));let n=_===e.id?T:t.draft_response;_===e.id&&T!==t.draft_response&&a("t_".concat(e.id),t.draft_response,T,t.category).catch(()=>{});let i=await s(e.from,e.subject,n,e.threadId,"t_".concat(e.id),e.id);i.success&&f(null),C(t=>({...t,[e.id]:i.success?"sent":"error"})),z(null)},[y,_,T]),(0,r.useCallback)(async e=>{let t,n,i=y[e.id];if(!i)return;let r=_===e.id?T:i.draft_response;C(t=>({...t,[e.id]:"creating"})),(await (t=e.from,n=e.subject,l("/draft",{method:"POST",body:{to:t,subject:n,body:r,threadId:e.threadId,ticketId:"t_".concat(e.id)}}))).success?(C(t=>({...t,[e.id]:"created"})),window.open("https://mail.google.com/mail/u/0/#drafts","_blank")):C(t=>({...t,[e.id]:"error"})),z(null)},[y,_,T]);let e9=(0,r.useCallback)((e,t)=>{let n,i="string"==typeof e?e:e.id,r="object"==typeof e?e.id:e;(n="t_".concat(i),l("/tickets?id=".concat(encodeURIComponent(n)),{method:"PATCH",body:{status:t}})).catch(()=>{}),"closed"===t&&(l("/emails/read",{method:"POST",body:{gmailId:r}}).catch(()=>{}),f(null)),h(e=>e.map(e=>e.id===i?{...e,status:t}:e)),C(e=>({...e,[i]:"closed"===t?"skipped":"pending"}))},[]),tt=(0,r.useCallback)(async()=>{for(let e of x)y[e.id]||await e7(e)},[x,y,e7]);(0,r.useEffect)(()=>{if(!m)return;eE(e=>{let t=new Set(e);return t.add(m),t}),eB[m]&&eq(eB[m]);let e=x.find(e=>e.id===m);!e||y[m]||R[m]||e7(e)},[m]),(0,r.useEffect)(()=>{if(!m||!eW)return;let e=y[m];(null==e||!e.draft_response||eW!==e.draft_response)&&eW.trim()&&eP(e=>({...e,[m]:eW}))},[eW,m]),(0,r.useEffect)(()=>{let e;if(!m){eR([]),eq("");return}let t=x.find(e=>e.id===m);if(!(null==t?void 0:t.threadId))return void eR([{id:null==t?void 0:t.id,from:null==t?void 0:t.from,date:null==t?void 0:t.date,body:null==t?void 0:t.body,direction:"inbound"}]);eM(!0),(e=t.threadId,l("/thread/".concat(encodeURIComponent(e)))).then(e=>{var n;e.success&&(null==(n=e.messages)?void 0:n.length)?eR(e.messages):eR([{id:t.id,from:t.from,date:t.date,body:t.body,direction:"inbound"}]),eM(!1)}).catch(()=>{eR([{id:t.id,from:t.from,date:t.date,body:t.body,direction:"inbound"}]),eM(!1)})},[m,x]),(0,r.useEffect)(()=>{eC.current&&eC.current.scrollIntoView({behavior:"smooth"})},[eD]),(0,r.useEffect)(()=>
1{if(!m)return void eq("");let e=x.find(e=>e.id===m);if((null==e?void 0:e.status)==="closed")return void eq("");if(eB[m])return void eq(eB[m]);let t=y[m];eq((null==t?void 0:t.draft_response)||"")},[m,y]),(0,r.useEffect)(()=>{let e=ew.current;e&&(e.style.height="auto",e.style.height=Math.max(140,e.scrollHeight)+"px")},[eW]);let tn=(0,r.useCallback)(e=>{var t;e.preventDefault();let n=e.clientY,i=(null==(t=e_.current)?void 0:t.offsetHeight)||260,r=e=>{let t=n-e.clientY;eT(Math.max(120,Math.min(.8*window.innerHeight,i+t)))},l=()=>{window.removeEventListener("mousemove",r),window.removeEventListener("mouseup",l)};window.addEventListener("mousemove",r),window.addEventListener("mouseup",l)},[]),ti=(0,r.useCallback)(async()=>{let e=x.find(e=>e.id===m);if(!eW.trim()||!e||eL)return;eA(!0);let t=y[e.id];(null==t?void 0:t.draft_response)&&eW!==t.draft_response&&a("t_".concat(e.id),t.draft_response,eW,null==t?void 0:t.category).catch(()=>{}),(await s(e.from,e.subject,eW,e.threadId,"t_".concat(e.id),e.id)).success&&(eR(e=>[...e,{id:"sent_".concat(Date.now()),from:"Moi",date:new Date().toISOString(),body:eW,direction:"outbound"}]),eq(""),h(t=>t.map(t=>t.id===e.id?{...t,status:"closed"}:t)),C(t=>({...t,[e.id]:"sent"})),eP(t=>{let n={...t};return delete n[e.id],n})),eA(!1)},[eW,m,x,eL,y]),tl=async e=>{await l("/knowledge-base",{method:"PUT",body:{policies:e}})},to=async()=>{O(!0);try{let e=await l("/emails/refresh",{method:"POST"});if(e.success){let t=e.tickets||[],{emails:n,analysisMap:i,draftStatusMap:r,orderDataMap:l}=nw(t);h(n),b(e=>({...e,...i})),C(e=>({...e,...r})),j(e=>({...e,...l}))}}catch(e){}O(!1)},ts=x.filter(e=>"closed"!==e.status),ta=x.filter(e=>"closed"===e.status),td="ouvert"===U?ts:ta,tc=x.find(e=>e.id===m),tu=m?y[m]:null,tp=m?v[m]:null,tx=m?S[m]:null,th=+!!en+ +!!e4+ +!!ee+ +("recent"!==e3),tm=(g=td.filter(e=>{var t,n,i;if(en&&(null==(t=y[e.id])?void 0:t.category)!==en||e4&&(null==(n=y[e.id])?void 0:n.urgency)!==e4)return!1;if(ee){let t=ee.toLowerCase(),n=(e.from||"").toLowerCase(),r=(e.subject||"").toLowerCase(),l=(e.body||"").toLowerCase(),o=((null==(i=y[e.id])?void 0:i.summary)||"").toLowerCase(),s=(eO[e.id]||[]).join(" ").toLowerCase();if(!n.includes(t)&&!r.includes(t)&&!l.includes(t)&&!o.includes(t)&&!s.includes(t))return!1}return!0}),"recent"===e3?g.sort((e,t)=>new Date(t.lastInboundAt||t.date)-new Date(e.lastInboundAt||e.date)):"oldest"===e3?g.sort((e,t)=>new Date(e.lastInboundAt||e.date)-new Date(t.lastInboundAt||t.date)):"urgent"===e3?g.sort((e,t)=>{var n,i,r,l;let o=null!=(r=nk[null==(n=y[e.id])?void 0:n.urgency])?r:3,s=null!=(l=nk[null==(i=y[t.id])?void 0:i.urgency])?l:3;return o!==s?o-s:new Date(t.date)-new Date(e.date)}):"waiting"===e3&&g.sort((e,t)=>{let n="closed"===e.status;return n!==("closed"===t.status)?n?1:-1:new Date(e.lastInboundAt||e.date)-new Date(t.lastInboundAt||t.date)}),g);(0,r.useEffect)(()=>{if("inbox"!==A)return;let e=e=>{var t,n;let i=null==(n=document.activeElement)||null==(t=n.tagName)?void 0:t.toLowerCase();if("input"===i||"textarea"===i)return;let r=tm.findIndex(e=>e.id===m);if("j"===e.key||"ArrowDown"===e.key){e.preventDefault();let t=tm[r+1];t&&f(t.id)}else if("k"===e.key||"ArrowUp"===e.key){e.preventDefault();let t=tm[r-1];t&&f(t.id)}else"a"===e.key?tc&&!y[tc.id]&&e7(tc):"r"===e.key?tc&&y[tc.id]&&(z(tc.id),D(y[tc.id].draft_response)):"e"===e.key?tc&&eW.trim()&&ti():"s"===e.key?tc&&e9(tc,"skipped"):"t"===e.key?tc&&e9(tc,"sent"):"Escape"===e.key?f(null):"?"===e.key&&eJ(e=>!e)};return window.addEventListener("keydown",e),()=>window.removeEventListener("keydown",e)},[A,tm,m,tc,y,e7,eW,ti,e9]);let tf=()=>{let e=!eX;eQ(e),localStorage.setItem("sav-theme",e?"dark":"light")},tb=e=>{if(!e)return"Inconnu";let t=e.match(/^([^<]+)</);return t?t[1].trim():e.split("@")[0]};return(0,i.jsxs)("div",{className:"app-shell",style:{fontFamily:G,background:e$.bg,color:e$.text,display:"flex",overflow:"hidden",position:"relative"},children:[!e1&&eb&&(0,i.jsx)("div",{onClick:()=>ev(!1),"aria-hidden":"true",style:{position:"fixed",inset:0,zIndex:24,background:"".concat(e$.text,"59"),animation:"overlay-in 180ms cubic-bezier(0.16, 1, 0.3, 1)"}}),!e1&&(0,i.jsxs)("aside",{style:{width:e2?60:244,minWidth:e2?60:244,transition:"width 220ms cubic-bezier(0.16, 1, 0.3, 1), min-width 220ms cubic-bezier(0.16, 1, 0.3, 1)",zIndex:"tablet"===eZ?25:20,..."tablet"===eZ?{position:"fixed",left:0,top:0,bottom:0,transform:eb?"translateX(0)":"translateX(-100%)",transition:"transform 240ms cubic-bezier(0.16, 1, 0.3, 1)",boxShadow:eb?"0 24px 48px ".concat(e$.shadow):"none"}:{},background:e$.nav,color:e$.navInk,borderRight:"1px solid ".concat(e$.border),display:"flex",flexDirection:"column",overflow:"hidden",flexShrink:0},children:[(0,i.jsxs)("div",{style:{padding:e2?"20px 0 12px":"20px 12px 12px",display:"flex",alignItems:"center",gap:10,justifyContent:e2?"center":"flex-start",minHeight:64,flexShrink:0},children:[(0,i.jsxs)("div",{style:{position:"relative",flexShrink:0},children:[(0,i.jsx)("span",{style:{width:32,height:32,borderRadius:"50%",background:e$.text,display:"grid",placeItems:"center"},children:(0,i.jsx)("img",{src:"/logo.png",alt:"Sudist",style:{width:18,height:18,objectFit:"contain",filter:eX?"none":"invert(1)",display:"block"}})}),e2&&(null==q?void 0:q.overall)&&(0,i.jsx)("span",{style:{position:"absolute",bottom:-1,right:-1,width:9,height:9,borderRadius:"50%",background:"ok"===q.overall?e$.green:"warn"===q.overall?e$.orange:e$.red,border:"2px s
1olid ".concat(e$.nav)},title:"Syst\xe8me: ".concat("ok"===q.overall?"OK":"warn"===q.overall?"Souci":"Cass\xe9")})]}),!e2&&(0,i.jsxs)("div",{style:{overflow:"hidden",minWidth:0},children:[(0,i.jsx)("div",{style:{fontSize:11.5,fontWeight:500,textTransform:"uppercase",letterSpacing:"0.08em",color:e$.navInkStrong,whiteSpace:"nowrap"},children:"Sudist"}),(0,i.jsxs)("div",{style:{fontSize:10.5,color:e$.navInk,display:"flex",gap:8,alignItems:"center",marginTop:2},children:[(0,i.jsx)("span",{children:"AIoli"}),(0,i.jsx)(ny,{checks:null==q?void 0:q.checks,overall:null==q?void 0:q.overall,T:e$})]})]})]}),(0,i.jsxs)("nav",{style:{padding:"".concat(Q.sm,"px ").concat(Q.sm,"px"),flex:1,display:"flex",flexDirection:"column",gap:2,overflowY:"auto"},children:[nC.map(e=>{let t=ex[e.icon],n=A===e.id,r="inbox"===e.id&&E.pending>0?E.pending:null;return(0,i.jsxs)("button",{onClick:()=>{F(e.id),ev(!1)},style:{...el(n,e$),padding:e2?"10px 0":"10px 12px",justifyContent:e2?"center":"flex-start",position:"relative"},className:"press",title:e2?e.label:void 0,"aria-current":n?"page":void 0,children:[(0,i.jsx)(t,{size:16,color:n?e$.navInkStrong:e$.navInk}),!e2&&(0,i.jsx)("span",{style:{flex:1},children:e.label}),r&&!e2&&(0,i.jsx)("span",{style:{display:"inline-flex",alignItems:"center",justifyContent:"center",height:18,minWidth:18,padding:"0 6px",fontSize:10,lineHeight:1,fontFamily:K,borderRadius:$.pill,background:e$.red,color:e$.bg},children:r}),r&&e2&&(0,i.jsx)("span",{style:{position:"absolute",top:4,right:6,width:7,height:7,borderRadius:"50%",background:e$.red}})]},e.id)}),(0,i.jsx)("div",{style:{flex:1}}),(0,i.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:10,justifyContent:e2?"center":"space-between",padding:e2?"10px 0":"10px 12px",borderTop:"1px solid ".concat(e$.border),marginTop:Q.sm},children:[!e2&&(0,i.jsx)("span",{style:{fontSize:11,textTransform:"uppercase",letterSpacing:"0.08em",color:e$.navInk},children:"Th\xe8me"}),(0,i.jsx)("button",{onClick:tf,role:"switch","aria-checked":eX,"aria-label":"Th\xe8me sombre",title:eX?"Passer en th\xe8me clair":"Passer en th\xe8me sombre",style:{position:"relative",width:44,height:26,borderRadius:13,flexShrink:0,border:"1px solid ".concat(e$.border),background:eX?e$.surfaceAlt:e$.surface,cursor:"pointer",padding:0,transition:"background-color 160ms cubic-bezier(0.16, 1, 0.3, 1)"},children:(0,i.jsx)("span",{style:{position:"absolute",top:2,left:eX?21:2,width:20,height:20,borderRadius:"50%",background:e$.text,color:e$.bg,display:"grid",placeItems:"center",transition:"left 160ms cubic-bezier(0.16, 1, 0.3, 1)"},children:eX?(0,i.jsx)(ex.moon,{size:10,color:e$.bg}):(0,i.jsx)(ex.sun,{size:10,color:e$.bg})})})]}),!e1&&(0,i.jsxs)("button",{onClick:()=>ey(e=>!e),"aria-label":e2?"D\xe9ployer la barre lat\xe9rale":"R\xe9duire la barre lat\xe9rale","aria-expanded":!e2,style:{...el(!1,e$),padding:e2?"10px 0":"10px 14px",justifyContent:e2?"center":"flex-start",padding:e2?"8px 0":"8px 12px",fontSize:12},children:[(0,i.jsx)("span",{style:{display:"inline-flex",transform:e2?"rotate(180deg)":"none",transition:"transform 200ms cubic-bezier(0.16, 1, 0.3, 1)"},children:(0,i.jsx)(ex.chevronLeft,{size:15,color:e$.navInk})}),!e2&&(0,i.jsx)("span",{style:{color:e$.navInk,fontSize:12},children:"R\xe9duire"})]})]})]})," ",(0,i.jsxs)("div",{style:{flex:1,display:"flex",flexDirection:"column",overflow:"hidden",minWidth:0,paddingBottom:e1?"calc(64px + env(safe-area-inset-bottom, 0px))":0},children:[(0,i.jsxs)("header",{style:{padding:"0 20px",height:56,minHeight:56,borderBottom:"1px solid ".concat(e$.border),display:"flex",alignItems:"center",justifyContent:"space-between",background:"".concat(e$.surface,"d9"),backdropFilter:"blur(10px)",WebkitBackdropFilter:"blur(10px)",flexShrink:0,position:"relative",zIndex:5},children:[(0,i.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:e1?4:16},children:[!e1&&"tablet"===eZ&&(0,i.jsx)("button",{onClick:()=>ev(e=>!e),"aria-label":"Ouvrir le menu","aria-expanded":eb,style:{background:"none",border:"none",color:e$.textMuted,cursor:"pointer",width:44,height:44,padding:0,display:"flex",alignItems:"center",justifyContent:"center",marginLeft:-10},children:(0,i.jsx)(ex.menu,{size:20,color:e$.textMuted})}),e1&&m&&"inbox"===A&&(0,i.jsx)("button",{onClick:()=>f(null),"aria-label":"Retour \xe0 la liste",style:{background:"none",border:"none",cursor:"pointer",width:40,height:44,padding:0,display:"flex",alignItems:"center",justifyContent:"center",marginLeft:-8,flexShrink:0},children:(0,i.jsx)(ex.chevronLeft,{size:20,color:e$.textMuted})}),(0,i.jsx)("h1",{style:{fontSize:e1?15:17,fontWeight:600,margin:0,letterSpacing:"-0.01em",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:e1&&m&&"inbox"===A?(null==(t=m.from)||null==(e=t.split("<")[0])?void 0:e.trim())||"Ticket":(null==(n=nC.find(e=>e.id===A))?void 0:n.label)||"AIoli"}),"inbox"===A&&!e1&&(0,i.jsx)("div",{style:{display:"flex",gap:16,alignItems:"center"},children:[{n:E.pending,l:"En attente",c:e$.orange},{n:E.processed,l:"Analys\xe9s",c:e$.blue},{n:E.drafts,l:"Envoy\xe9s",c:e$.green}].map(e=>(0,i.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:6},children:[(0,i.jsx)("span",{style:{fontSize:14,fontWeight:600,color:e.c,fontFamily:K,fontVariantNumeric:"tabular-nums"},children:e.n}),(0,i.jsx)("span",{style:{fontSize:11,color:e$.textMuted},children:e.l})]},e.l))})]}),(0,i.jsx)("div",{style:{display:"flex",alignItems:"center",gap:8},children:"inbox"===A&&(0,i.jsxs)(i.Fragment,{children:[(0,i.jsxs)("button",{onClick:()=>(function(e,t,n){let i=new Blob([["Date,De,Sujet,Cat\xe9gorie,Urgence,Commande,Statut,R\xe9sum\xe9",...e.map(e=>{let n=t[e.id];return[new Date(e.date).toLocaleDateString("fr-FR"),e.from,e.subject,(null==n?void 0:n.category)||"",(null==n?void 0:n.urgency)||"",(null==n?void 0:n.order_number)||"","closed"===e.status?"Trait\xe9":n?"Analys\xe9":"En attente",(null==n?void 0:n.summary)||""].map(e=>'"'.concat(String(e).replace(/"/g,'""'),'"')).join(",")})].join("\n")],{type:"text/csv;charset=utf-8;"}),r=URL.createObjectURL(i),l=document.createElement("a");l.href=r,l.download="sav-tickets-".concat(new Date().toISOString().slice(0,10),".csv"),l.click(),URL.revokeObjectURL(r)})(tm,y,0),"aria-label":"Exporter en CSV",style:{...ei(!1,e$),padding:"6px 12px"},title:"Exporter CSV",children:[(0,i.jsx)(ex.download,{size:14,color:e$.textMuted}),(0,i.jsx)("span",{className:"hide-mobile",children:"CSV"})]}),(0,i.jsxs)("button",{onClick:to,disabled:P,"aria-label":"Actualiser les emails",style:{...ei(!1,e$),padding:"6px 12px",opacity:P?.5:1,cursor:P?"wait":"pointer"},children:[(0,i.jsx)("span",{style:{display:"inline-flex",animation:P?"spin 1s linear infinite":"none"},children:(0,i.jsx)(ex.refresh,{size:14,color:e$.textMuted})}),(0,i.jsx)("span",{className:"hide-mobile",children:P?"Refresh...":"Refresh"})]}),(0,i.jsxs)("button",{onClick:tt,style:{...ei(!0,e$),padding:"6px 14px"},children:[(0,i.jsx)(ex.play,{size:13,color:e$.bg}),(0,i.jsx)("span",{className:"hide-mobile",children:"Analyser tout"})]}),(0,i.jsx)("button",{onClick:()=>eJ(!0),"aria-label":"Afficher les raccourcis clavier",title:"Raccourcis clavier",style:{...ei(!1,e$),padding:"6px 10px",fontSize:12,fontWeight:700},children:"?"})]})})]}),(0,i.jsx)("div",{style:{display:"flex",flex:1,overflow:"hidden"},children:"config"===A?(0,i.jsx)("div",{style:{flex:1,overflow:"hidden"},children:(0,i.jsx)(ef,{policies:M,setPolicies:W,onSave:tl,t:e$,fullPage:!0})}):"home"===A?(0,i.jsx)("div",{style:{flex:1,overflowY:"auto"},children:(0,i.jsx)(tr,{t:e$,onNavigate:F,active:"home"===A})}):"chat"===A?(0,i.jsx)("div",{style:{flex:1,overflow:"hidden"},children:(0,i.jsx)(ek,{t:e$,active:"chat"===A})}):"returns"===A?(0,i.jsx)("div",{style:{flex:1,overflow:"hidden"},children:(0,i.jsx)(eY,{t:e$,active:"returns"===A,policies:M,setPolicies:W,onSavePolicies:tl})}):"pr\xe9paration"===A?(0,i.jsx)("div",{style:{flex:1,overflow:"hidden"},children:(0,i.jsx)(e6,{t:e$,active:"pr\xe9paration"===A})}):"expedition"===A?(0,i.jsx)("div",{style:{flex:1,overflow:"hidden"},children:(0,i.jsx)(te,{t:e$,active:"expedition"===A})}
1):"b2b"===A?(0,i.jsx)("div",{style:{flex:1,overflowY:"auto"},children:(0,i.jsx)(tg,{t:e$,active:"b2b"===A})}):"notifications"===A?(0,i.jsx)("div",{style:{flex:1,overflow:"hidden"},children:(0,i.jsx)(ty,{t:e$,active:"notifications"===A})}):"marketing"===A?(0,i.jsx)("div",{style:{flex:1,overflow:"hidden"},children:(0,i.jsx)(tV,{t:e$,active:"marketing"===A})}):"prospection"===A?(0,i.jsx)("div",{style:{flex:1,overflow:"hidden"},children:(0,i.jsx)(t1,{t:e$,active:"prospection"===A})}):"studio"===A?(0,i.jsx)("div",{style:{flex:1,overflow:"hidden"},children:(0,i.jsx)(nu,{t:e$,active:"studio"===A})}):(0,i.jsxs)(i.Fragment,{children:[(0,i.jsxs)("div",{style:{width:e1?"100%":360,minWidth:360*!e1,maxWidth:e1?"100%":360,borderRight:e1?"none":"1px solid ".concat(e$.border),display:e1&&m?"none":"flex",flexDirection:"column",background:e$.bg,flexShrink:0,overflow:"hidden"},children:[(0,i.jsx)("div",{style:{padding:"".concat(Q.sm,"px ").concat(Q.md,"px"),borderBottom:"1px solid ".concat(e$.border),display:"flex",gap:4,background:e$.surface},children:[{v:"ouvert",l:"Ouvert",count:ts.length},{v:"archiv\xe9",l:"Archiv\xe9",count:ta.length}].map(e=>{let{v:t,l:n,count:r}=e;return(0,i.jsxs)("button",{onClick:()=>{X(t),f(null)},style:{flex:1,padding:"7px 0",borderRadius:$.md,border:"none",cursor:"pointer",background:U===t?e$.text:"transparent",color:U===t?e$.bg:e$.textMuted,fontSize:11,fontWeight:600,fontFamily:G,transition:"background 0.2s ease, color 0.2s ease",display:"flex",alignItems:"center",justifyContent:"center",gap:6},children:[n,(0,i.jsx)("span",{style:{fontSize:9,fontFamily:K,opacity:U===t?.7:1},children:r})]},t)})}),(0,i.jsxs)("div",{style:{padding:Q.md,borderBottom:"1px solid ".concat(e$.border),display:"flex",flexDirection:"column",gap:Q.sm,background:e$.surface},children:[(0,i.jsxs)("div",{style:{position:"relative"},children:[(0,i.jsx)("span",{style:{position:"absolute",left:10,top:"50%",transform:"translateY(-50%)",display:"flex",pointerEvents:"none"},children:(0,i.jsx)(ex.search,{size:14,color:e$.textDim})}),(0,i.jsx)("input",{type:"text",placeholder:"Rechercher un ticket...",value:ee,onChange:e=>et(e.target.value),style:{width:"100%",padding:"7px 10px 7px 32px",borderRadius:$.md,border:"1px solid ".concat(e$.border),background:e$.surfaceAlt,color:e$.text,fontSize:11,outline:"none",boxSizing:"border-box",fontFamily:G,transition:"border-color 0.2s ease"},onFocus:e=>{e.target.style.borderColor=e$.borderLight},onBlur:e=>{e.target.style.borderColor=e$.border}})]}),(0,i.jsx)("div",{style:{display:"flex",gap:4,...e1?{overflowX:"auto",flexWrap:"nowrap",scrollbarWidth:"none",WebkitOverflowScrolling:"touch",marginLeft:-Q.md,marginRight:-Q.md,paddingLeft:Q.md,paddingRight:Q.md}:{flexWrap:"wrap"}},children:nv.map(e=>(0,i.jsx)("button",{onClick:()=>es(e.value),style:{...eo(en===e.value,e$),flexShrink:0},children:e.label},String(e.value)))}),(0,i.jsxs)("div",{style:{display:"flex",gap:4,alignItems:"center",...e1?{overflowX:"auto",flexWrap:"nowrap",scrollbarWidth:"none",WebkitOverflowScrolling:"touch"}:{flexWrap:"wrap"}},children:[nj.map(e=>{let t,n=e.value?(t=e.value,({high:e$.red,medium:e$.orange,low:e$.green})[t]||e$.textDim):null;return(0,i.jsxs)("button",{onClick:()=>e5(e.value),style:{...eo(e4===e.value,e$),...e.value&&e4===e.value?{borderColor:"".concat(n,"40"),background:"".concat(n,"10")}:{}},children:[e.value&&(0,i.jsx)("span",{style:{display:"inline-block",width:6,height:6,borderRadius:"50%",background:n,marginRight:3}}),e.label]},String(e.value))}),(0,i.jsx)("select",{value:e3,onChange:e=>e8(e.target.value),style:{marginLeft:"auto",padding:"3px 6px",borderRadius:$.sm,border:"1px solid ".concat("recent"!==e3?e$.borderLight:e$.border),background:"recent"!==e3?e$.surfaceAlt:e$.surface,color:"recent"!==e3?e$.text:e$.textMuted,fontSize:10,fontWeight:600,cursor:"pointer",outline:"none",fontFamily:G},children:nS.map(e=>(0,i.jsx)("option",{value:e.value,children:e.label},e.value))})]}),th>0&&(0,i.jsxs)("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between"},children:[(0,i.jsxs)("span",{style:{fontSize:10,color:e$.text,fontWeight:600},children:[tm.length," r\xe9sultat",1!==tm.length?"s":""]}),(0,i.jsx)("button",{onClick:()=>{es(null),e5(null),et(""),e8("recent")}
1,style:{fontSize:10,color:e$.textDim,background:"none",border:"none",cursor:"pointer",textDecoration:"underline",fontFamily:G},children:"R\xe9initialiser"})]})]}),(0,i.jsxs)("div",{style:{flex:1,overflowY:"auto"},children:[0===tm.length&&(0,i.jsx)(eg,{icon:(0,i.jsx)(ex.inbox,{size:40,color:e$.textDim}),title:"ouvert"===U?"Aucun ticket en attente":"Aucun email archiv\xe9",description:"ouvert"===U?"Tous les tickets ont \xe9t\xe9 trait\xe9s":"Les tickets archiv\xe9s apparaitront ici",t:e$}),tm.map(e=>{let t=y[e.id],n=t?H[t.category]:null,r=m===e.id,o=R[e.id];w[e.id];let s="closed"===e.status,a=tb(e.from),d=null==t?void 0:t.urgency,c=!eF.has(e.id),u=eO[e.id]||[],p=!!eB[e.id];"high"===d?e$.red:"medium"===d&&e$.orange;let g="high"===d?"".concat(e$.red,"08"):"medium"===d?"".concat(e$.orange,"06"):"transparent",x=(null==t?void 0:t.summary)||e.subject||"(sans objet)";return(0,i.jsx)("div",{className:"ticket-row",onClick:()=>f(e.id),style:{padding:"14px 16px",borderBottom:"1px solid ".concat(e$.border),cursor:"pointer",background:r?e$.surfaceAlt:g,opacity:s?.55:1,transition:"background 0.15s ease"},onMouseOver:e=>{r||(e.currentTarget.style.background=r?e$.surfaceAlt:e$.accentBg)},onMouseOut:e=>{r||(e.currentTarget.style.background=r?e$.surfaceAlt:g)},children:(0,i.jsxs)("div",{style:{display:"flex",gap:12,alignItems:"flex-start"},children:[(0,i.jsx)(ep,{name:a,size:36,t:e$}),(0,i.jsxs)("div",{style:{flex:1,minWidth:0},children:[(0,i.jsxs)("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:3},children:[(0,i.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:6,minWidth:0},children:[c&&(0,i.jsx)("span",{style:{width:7,height:7,borderRadius:"50%",background:e$.blue,flexShrink:0}}),(0,i.jsx)("span",{style:{fontSize:13,fontWeight:c?700:500,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",color:c?e$.text:e$.textMuted},children:a}),"high"===d&&(0,i.jsx)("span",{style:{width:7,height:7,borderRadius:"50%",background:e$.red,flexShrink:0}}),"medium"===d&&(0,i.jsx)("span",{style:{width:6,height:6,borderRadius:"50%",background:e$.orange,flexShrink:0,opacity:.8}})]}),(0,i.jsx)("span",{style:{fontSize:10,color:e$.textDim,fontFamily:K,flexShrink:0,marginLeft:8},children:(e=>{if(!e)return"—";let t=new Date(e);if(isNaN(t.getTime()))return"—";let n=new Date-t;if(n<0)return t.toLocaleDateString("fr-FR",{day:"2-digit",month:"short"});let i=Math.floor(n/6e4),r=Math.floor(n/36e5),l=Math.floor(n/864e5);return i<1?"maintenant":i<60?"".concat(i,"min"):r<24?"".concat(r,"h"):l<7?"".concat(l,"j"):t.toLocaleDateString("fr-FR",{day:"2-digit",month:"short"})})(e.date)})]}),(0,i.jsx)("div",{style:{fontSize:12,lineHeight:1.4,color:e$.textMuted,marginBottom:5,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:x}),(0,i.jsxs)("div",{style:{display:"flex",gap:5,alignItems:"center",flexWrap:"wrap"},children:[o&&(0,i.jsx)("span",{style:{fontSize:10,color:e$.textMuted,fontFamily:K,animation:"pulse 1.5s infinite"},children:"Analyse..."}),n&&(0,i.jsx)("span",{style:{fontSize:10,padding:"2px 8px",borderRadius:$.pill,background:"".concat(n.color,"15"),color:n.color,fontWeight:600},children:n.label}),"high"===d&&(0,i.jsx)("span",{style:{fontSize:10,padding:"2px 8px",borderRadius:$.pill,background:"".concat(e$.red,"15"),color:e$.red,fontWeight:600},children:"Urgent"}),"closed"===e.status&&(0,i.jsxs)("span",{style:{fontSize:10,padding:"2px 8px",borderRadius:$.pill,background:"".concat(e$.green,"15"),color:e$.green,fontWeight:600,display:"flex",alignItems:"center",gap:4},children:[(0,i.jsx)("svg",{width:10,height:10,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"3",strokeLinecap:"round",strokeLinejoin:"round",children:(0,i.jsx)("polyline",{points:"20 6 9 17 4 12"})}),"Trait\xe9"]}),p&&"closed"!==e.status&&(0,i.jsx)("span",{style:{fontSize:10,padding:"2px 8px",borderRadius:$.pill,background:"".concat(e$.orange,"15"),color:e$.orange,fontWeight:600},children:"Brouillon local"}),(null==t?void 0:t.duplicate_of)&&(0,i.jsxs)("span",{title:"Doublon du ticket ".concat(t.duplicate_of),style:{fontSize:10,padding:"2px 8px",borderRadius:$.pill,background:"".concat(e$.purple,"15"),color:e$.purple,fontWeight:600,display:"flex",alignItems:"center",gap:3},children:[(0,i.jsxs)("svg",{width:9,height:9,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",children:[(0,i.jsx)("rect",{x:"9",y:"9",width:"13",height:"13",rx:"2"}),(0,i.jsx)("path",{d:"M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1"})]}),"Doublon"]}),u.map(e=>(0,i.jsx)("span",{style:{fontSize:9,padding:"2px 6px",borderRadius:$.pill,background:"".concat(e$.purple,"15"),color:e$.purple,fontWeight:600},children:e},e)),(0,i.jsx)("button",{onClick:t=>{var n;let i;t.stopPropagation(),confirm("Supprimer cet email ?")&&(n=e.id,(i="t_".concat(n),l("/tickets?id=".concat(encodeURIComponent(i)),{method:"DELETE"})).catch(()=>{}),h(e=>e.filter(e=>e.id!==n)),b(e=>{let t={...e};return delete t[n],t}),m===n&&f(null))},style:{marginLeft:"auto",background:"none",border:"none",cursor:"pointer",color:e$.textDim,padding:"2px 4px",borderRadius:$.sm,opacity:0,transition:"opacity 0.15s ease",display:"flex",alignItems:"center"},className:"ticket-delete-btn",onMouseOver:e=>{e.currentTarget.style.color=e$.red},onMouseOut:e=>{e.currentTarget.style.color=e$.textDim},children:(0,i.jsxs)("svg",{width:12,height:12,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",children:[(0,i.jsx)("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),(0,i.jsx)("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})]})]})]})},e.id)})]})]}),(0,i.jsx)("div",{style:{flex:1,display:e1&&!m?"none":"flex",flexDirection:"column",background:e$.bg,overflow:"hidden"},children:tc?(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)("div",{style:{padding:"".concat(Q.md,"px ").concat(Q.xl,"px"),borderBottom:"1px solid ".concat(e$.border),background:e$.surface,flexShrink:0},children:(0,i.jsxs)("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",gap:Q.md},children:[(0,i.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:Q.md,minWidth:0,flex:1},children:[e1&&(0,i.jsx)("button",{onClick:()=>f(null),"aria-label":"Retour \xe0 la liste",style:{background:"transparent",border:"none",width:36,height:36,borderRadius:$.md,cursor:"pointer",color:e$.textMuted,display:"flex",alignItems:"center",justifyContent:"center",flexShrink:0,marginLeft:-8}
1,children:(0,i.jsx)(ex.chevronLeft,{size:18,color:"currentColor"})}),(0,i.jsx)(ep,{name:tb(tc.from),size:32,t:e$}),(0,i.jsxs)("div",{style:{minWidth:0},children:[(0,i.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:8},children:[(0,i.jsx)("span",{style:{fontWeight:600,fontSize:14},children:tb(tc.from)}),tx&&(0,i.jsx)(ec,{tier:tx.tier,t:e$}),tu&&(0,i.jsx)("span",{style:{fontSize:9,padding:"2px 7px",borderRadius:$.sm,background:"".concat((null==(d=H[tu.category])?void 0:d.color)||e$.textMuted,"15"),color:(null==(c=H[tu.category])?void 0:c.color)||e$.textMuted,fontWeight:600},children:null==(u=H[tu.category])?void 0:u.label}),tu&&(0,i.jsx)(ed,{level:tu.urgency,t:e$})]}),(0,i.jsx)("div",{style:{fontSize:12,color:e$.textDim,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:tc.subject})]})]}),(0,i.jsx)("div",{style:{display:"flex",gap:4,flexShrink:0,alignItems:"center"},children:"closed"===tc.status?(0,i.jsxs)(i.Fragment,{children:[(0,i.jsxs)("span",{style:{fontSize:10,color:e$.green,fontWeight:600,display:"flex",alignItems:"center",gap:4,padding:"0 8px"},children:[(0,i.jsx)("span",{style:{width:6,height:6,borderRadius:"50%",background:e$.green}})," Trait\xe9"]}),(0,i.jsx)("button",{onClick:()=>e9(tc,"open"),style:{...ei(!1,e$),fontSize:10},children:"R\xe9ouvrir"})]}):(0,i.jsx)("button",{onClick:()=>e9(tc,"closed"),style:{...ei(!1,e$),fontSize:10},children:"Ignorer"})}),(0,i.jsxs)("div",{style:{display:"flex",gap:4,alignItems:"center",marginTop:Q.sm,flexWrap:"wrap"},children:[(eO[tc.id]||[]).map(e=>(0,i.jsxs)("span",{style:{fontSize:10,padding:"2px 8px",borderRadius:$.pill,background:"".concat(e$.purple,"15"),color:e$.purple,fontWeight:600,display:"flex",alignItems:"center",gap:4,cursor:"pointer"},onClick:()=>eU(t=>({...t,[tc.id]:(t[tc.id]||[]).filter(t=>t!==e)})),children:[e," ",(0,i.jsx)("span",{style:{fontSize:8},children:"x"})]},e)),eV?(0,i.jsx)("form",{onSubmit:e=>{e.preventDefault();let t=eN.trim();t&&!(eO[tc.id]||[]).includes(t)&&eU(e=>({...e,[tc.id]:[...e[tc.id]||[],t]})),eH(""),eG(!1)},style:{display:"flex",gap:4},children:(0,i.jsx)("input",{value:eN,onChange:e=>eH(e.target.value),autoFocus:!0,placeholder:"tag...",onBlur:()=>{eN.trim()||eG(!1)},style:{...Z(e$),fontSize:10,padding:"2px 8px",width:80,borderRadius:$.pill}})}):(0,i.jsx)("button",{onClick:()=>eG(!0),style:{fontSize:10,padding:"2px 8px",borderRadius:$.pill,background:"none",border:"1px dashed ".concat(e$.border),color:e$.textDim,cursor:"pointer",fontFamily:G},children:"+ tag"})]})]})}),(tu||tx||tp)&&(0,i.jsxs)("div",{style:{padding:"".concat(Q.sm,"px ").concat(Q.xl,"px"),borderBottom:"1px solid ".concat(e$.border),background:e$.surfaceAlt,flexShrink:0,display:"flex",gap:Q.lg,alignItems:"center",flexWrap:"wrap",fontSize:11,color:e$.textMuted},children:[(null==tu?void 0:tu.summary)&&(0,i.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:6,flex:1,minWidth:200},children:[(0,i.jsxs)("svg",{width:12,height:12,viewBox:"0 0 24 24",fill:"none",stroke:e$.blue,strokeWidth:"2",children:[(0,i.jsx)("circle",{cx:"12",cy:"12",r:"10"}),(0,i.jsx)("path",{d:"M12 16v-4M12 8h.01"})]}),(0,i.jsx)("span",{style:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:tu.summary})]}),tx&&(0,i.jsxs)("div",{style:{display:"flex",gap:Q.md,alignItems:"center",flexShrink:0},children:[(0,i.jsxs)("span",{children:[tx.total_orders," cmd"]}),(0,i.jsxs)("span",{children:[tx.total_spent,"€"]})]}),tp&&(0,i.jsxs)("div",{style:{display:"flex",gap:6,alignItems:"center",flexShrink:0},children:[(0,i.jsx)(ea,{status:tp.shipping_status,t:e$}),(0,i.jsx)("span",{style:{fontFamily:K},children:tp.name}),tp.tracking&&(0,i.jsx)("span",{style:{fontFamily:K,fontSize:10},children:tp.tracking})]}),(null==tu||null==(p=tu.key_info)?void 0:p.length)>0&&(0,i.jsx)("div",{style:{display:"flex",gap:4,flexWrap:"wrap"},children:tu.key_info.map((e,t)=>(0,i.jsx)("span",{style:{padding:"1px 6px",borderRadius:$.sm,background:e$.surface,border:"1px solid ".concat(e$.border),fontSize:9,fontFamily:K},children:e},t))})]}),(0,i.jsx)("div",{style:{flex:1,overflowY:"auto",padding:"".concat(Q.xl,"px ").concat(Q.xxl,"px")},children:eI?(0,i.jsx)("div",{style:{display:"flex",justifyContent:"center",padding:40,color:e$.textDim},children:(0,i.jsx)("span",{style:{fontFamily:K,animation:"pulse 1.5s infinite",fontSize:12},children:"Chargement de la conversation..."})}):(0,i.jsxs)("div",{style:{maxWidth:680,margin:"0 auto",display:"flex",flexDirection:"column",gap:Q.md},children:[eD.map((e,t)=>{var n,r;let l="outbound"===e.direction,o=new Date(e.date||0),s=!isNaN(o.getTime()),a=new Date((null==(n=eD[t-1])?void 0:n.date)||0),d=s&&(0===t||a.toDateString()!==o.toDateString());return(0,i.jsxs)("div",{children:[d&&(0,i.jsx)("div",{style:{textAlign:"center",margin:"".concat(Q.md,"px 0"),fontSize:10,
1color:e$.textDim},children:o.toLocaleDateString("fr-FR",{weekday:"long",day:"numeric",month:"long",year:"numeric"})}),(0,i.jsx)("div",{style:{display:"flex",justifyContent:l?"flex-end":"flex-start"},children:(0,i.jsxs)("div",{style:{maxWidth:"80%",padding:"".concat(Q.md,"px ").concat(Q.lg,"px"),borderRadius:l?"".concat($.lg,"px ").concat($.lg,"px ").concat($.sm,"px ").concat($.lg,"px"):"".concat($.lg,"px ").concat($.lg,"px ").concat($.lg,"px ").concat($.sm,"px"),background:l?eX?"#2a4a3a":"#e8f5e9":e$.surface,border:"1px solid ".concat(l?eX?"#3a6a4a":"#c8e6c9":e$.border)},children:[!l&&(0,i.jsx)("div",{style:{fontSize:10,color:e$.textMuted,marginBottom:4,fontWeight:600},children:e.from?tb(e.from):"Client"}),(0,i.jsx)("div",{style:{fontSize:13,lineHeight:1.6,whiteSpace:"pre-wrap",wordBreak:"break-word",overflowWrap:"anywhere",color:e$.text},children:(r=e.body)?r.split(/(\*\*[^*]+\*\*)/g).map((e,t)=>{let n=e.match(/^\*\*([^*]+)\*\*$/);return n?(0,i.jsx)("strong",{children:n[1]},t):e}):null}),(0,i.jsxs)("div",{style:{fontSize:9,color:e$.textDim,marginTop:4,textAlign:l?"right":"left"},children:[s?o.toLocaleTimeString("fr-FR",{hour:"2-digit",minute:"2-digit"}):"",l&&(0,i.jsx)("span",{style:{marginLeft:6,color:e$.green},children:"Envoy\xe9"})]})]})})]},e.id||t)}),(0,i.jsx)("div",{ref:eC})]})}),"closed"!==tc.status&&(0,i.jsxs)("div",{ref:e_,style:{borderTop:"1px solid ".concat(e$.border),background:e$.surface,padding:"".concat(Q.lg,"px ").concat(Q.xl,"px"),flexShrink:0,position:"relative",...ez?{height:ez,overflowY:"auto"}:{}},children:[(0,i.jsx)("div",{onMouseDown:tn,title:"Glisser pour redimensionner",style:{position:"absolute",left:0,right:0,marginTop:-18,height:16,cursor:"ns-resize",display:"flex",alignItems:"center",justifyContent:"center",userSelect:"none"},children:(0,i.jsx)("div",{style:{width:36,height:4,borderRadius:2,background:e$.border}})}),(0,i.jsxs)("div",{style:{maxWidth:680,margin:"0 auto"},children:[(0,i.jsxs)("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:Q.sm,flexWrap:"wrap",gap:6},children:[(0,i.jsxs)("div",{style:{display:"flex",gap:6,flexWrap:"wrap"},children:[nb.map(e=>(0,i.jsx)("button",{onClick:()=>eq(e.text),style:{...eo(!1,e$),fontSize:10,padding:"3px 10px"},children:e.label},e.label)),(null==tu?void 0:tu.draft_response)&&eW!==tu.draft_response&&(0,i.jsx)("button",{onClick:()=>eq(tu.draft_response),style:{...eo(!1,e$),fontSize:10,padding:"3px 10px",color:e$.blue,border:"1px solid ".concat(e$.blue,"30")},children:"R\xe9ponse IA"})]}),(0,i.jsx)("div",{style:{fontSize:10,color:e$.textDim},children:"Cmd+Enter pour envoyer"})]}),(0,i.jsxs)("div",{style:{border:"1px solid ".concat(e$.border),borderRadius:$.lg,background:e$.bg,overflow:"hidden",transition:"border-color 0.2s"},children:[(0,i.jsx)("textarea",{ref:ew,value:eW,onChange:e=>eq(e.target.value),onKeyDown:e=>{"Enter"===e.key&&(e.metaKey||e.ctrlKey)&&ti()},placeholder:"\xc9crire une r\xe9ponse...",rows:6,style:{width:"100%",border:"none",outline:"none",background:"transparent",color:e$.text,fontFamily:G,fontSize:13,lineHeight:1.6,minHeight:140,resize:"none",padding:"".concat(Q.lg,"px ").concat(Q.xl,"px"),boxSizing:"border-box"}}),(0,i.jsx)("div",{style:{display:"flex",justifyContent:"flex-end",alignItems:"center",padding:"".concat(Q.sm,"px ").concat(Q.md,"px"),gap:6,borderTop:"1px solid ".concat(e$.border)},children:(0,i.jsx)("button",{onClick:ti,disabled:eL||!eW.trim(),style:{...ei(!0,e$),padding:"8px 20px",opacity:eL||!eW.trim()?.5:1,cursor:eL||!eW.trim()?"not-allowed":"pointer",display:"flex",alignItems:"center",gap:6,fontSize:12},children:eL?"...":(0,i.jsxs)(i.Fragment,{children:[(0,i.jsxs)("svg",{width:14,height:14,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,i.jsx)("line",{x1:"22",y1:"2",x2:"11",y2:"13"}),(0,i.jsx)("polygon",{points:"22 2 15 22 11 13 2 9 22 2"})]}),"Envoyer"]})})})]})]})]})]}):(0,i.jsx)(eg,{icon:(0,i.jsx)(ex.inbox,{size:48,color:e$.textDim}),title:"S\xe9lectionnez un ticket",description:"Choisissez un email dans la liste pour voir la conversation",t:e$})})]})}),e1&&(()=>{let e=[{id:"home",label:"Accueil",icon:"home"},{id:"returns",label:"Retours",icon:"returns"},{id:"chat",label:"Chat",icon:"chat"},{id:"_more",label:"Plus",icon:"config"}],t=nC.filter(t=>!e.some(e=>e.id===t.id));return(0,i.jsxs)(i.Fragment,{children:[ej&&(0,i.jsx)("div",{onClick:()=>eS(!1),"aria-hidden":"true",style:{position:"fixed",inset:0,zIndex:39,background:"".concat(e$.text,"66")},className:"sheet-overlay"}),ej&&(0,i.jsxs)("div",{role:"dialog","aria-label":"Navigation — plus d'options",style:{position:"fixed",left:0,right:0,bottom:"calc(64px + env(safe-area-inset-bottom, 0px))",zIndex:40,background:e$.surface,borderTop:"1px solid ".concat(e$.border),borderRadius:"20px 20px 0 0",padding:"".concat(Q.md,"px ").concat(Q.md,"px ").concat(Q.lg,"px"),boxShadow:"0 -24px 48px ".concat(e$.shadow)},className:"sheet-panel",children:[(0,i.jsx)("div",{style:{width:36,height:3,borderRadius:2,background:e$.border,margin:"0 auto ".concat(Q.lg,"px")}}),(0,i.jsx)("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr 1fr",gap:Q.sm},children:t.map(e=>{let t=ex[e.icon],n=A===e.id;return(0,i.jsxs)("button",{onClick:()=>{F(e.id),eS(!1)},style:{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",gap:Q.xs,padding:"".concat(Q.md,"px ").concat(Q.sm,"px"),border:"none",cursor:"pointer",borderRadius:$.lg,minHeight:72,background:n?e$.text:e$.surfaceAlt,color:n?e$.bg:e$.text,transition:"background-color 160ms cubic-bezier(0.16, 1, 0.3, 1)"},className:"press",children:[(0,i.jsx)(t,{size:20,color:n?e$.bg:e$.textMuted}),(0,i.jsx)("span",{style:{fontSize:11,fontWeight:500,letterSpacing:"0.01em"},children:e.label})]},e.id)})}),(0,i.jsxs)("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",marginTop:Q.lg,paddingTop:Q.md,borderTop:"1px solid ".concat(e$.border)},children:[(0,i.jsx)(ny,{checks:null==q?void 0:q.checks,overall:null==q?void 0:q.overall,T:e$}),(0,i.jsxs)("button",{onClick:tf,"aria-label":eX?"Mode clair":"Mode sombre",style:{...ei(!1,e$),padding:"8px 14px"},children:[eX?(0,i.jsx)(ex.sun,{size:16,color:e$.textMuted}):(0,i.jsx)(ex.moon,{size:16,color:e$.textMuted}),(0,i.jsx)("span",{style:{fontSize:11},children:eX?"Mode clair":"Mode sombre"})]})]})]}),(0,i.jsx)("nav",{"aria-label":"Navigation principale",style:{position:"fixed",left:0,right:0,bottom:0,zIndex:38,background:"".concat(e$.surface,"f2"),backdropFilter:"blur(10px)",WebkitBackdropFilter:"blur(10px)",borderTop:"1px solid ".concat(e$.border),display:"flex",alignItems:"stretch",height:"calc(64px + env(safe-area-inset-bottom, 0px))",paddingBottom:"env(safe-area-inset-bottom, 0px)"},children:e.map(e=>
1{let t=ex[e.icon],n="_more"===e.id?ej:A===e.id,r="inbox"===e.id&&E.pending>0?E.pending:null;return(0,i.jsxs)("button",{onClick:()=>{"_more"===e.id?eS(e=>!e):(F(e.id),eS(!1))},"aria-label":e.label,"aria-current":n?"page":void 0,style:{flex:1,display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",gap:4,border:"none",background:"transparent",cursor:"pointer",position:"relative",color:n?e$.text:e$.textMuted,transition:"color 160ms cubic-bezier(0.16, 1, 0.3, 1)",minWidth:0},className:"press",children:[(0,i.jsxs)("span",{style:{position:"relative",display:"inline-flex"},children:[(0,i.jsx)(t,{size:22,color:n?e$.text:e$.textMuted}),n&&"_more"!==e.id&&(0,i.jsx)("span",{"aria-hidden":!0,className:"animate-rise",style:{position:"absolute",bottom:-7,left:"50%",marginLeft:-2,width:4,height:4,borderRadius:"50%",background:e$.red}}),r&&(0,i.jsx)("span",{style:{position:"absolute",top:-4,right:-8,fontSize:8,fontWeight:600,fontFamily:K,background:e$.red,color:e$.bg,borderRadius:$.pill,padding:"1px 4px",lineHeight:1.4,minWidth:14,textAlign:"center"},children:r>99?"99+":r})]}),(0,i.jsx)("span",{style:{fontSize:10.5,fontWeight:500,letterSpacing:"0.02em"},children:e.label})]},e.id)})})]})})()]}),(0,i.jsx)("style",{children:"\n        /* 100dvh suit la hauteur r\xe9ellement visible (barres du navigateur, webview\n           Shopify) l\xe0 o\xf9 100vh est fig\xe9 et d\xe9cale la tab bar. Fallback 100vh. */\n        .app-shell { height: 100vh; }\n        @supports (height: 100dvh) { .app-shell { height: 100dvh; } }\n        @keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.4; } }\n        @keyframes spin { from { transform: rotate(0deg); } to { transform: rotate(360deg); } }\n        * { box-sizing: border-box; margin: 0; }\n        ::-webkit-scrollbar { width: 5px; }\n        ::-webkit-scrollbar-track { background: transparent; }\n        ::-webkit-scrollbar-thumb { background: ".concat(e$.border,"; border-radius: 3px; }\n        select option { background: ").concat(e$.surface,"; color: ").concat(e$.text,"; }\n\n        /* Show delete button on ticket hover */\n        .ticket-delete-btn { opacity: 0 !important; }\n        div:hover > div > div > div > .ticket-delete-btn,\n        div:hover > div > .ticket-delete-btn { opacity: 1 !important; }\n\n        /* ── Mobile-first overrides ─────────────────────────────── */\n        @media (max-width: 767px) {\n          .hide-mobile { display: none !important; }\n          /* Suppress scrollbars on horizontal pill strips */\n          .pill-strip::-webkit-scrollbar { display: none; }\n          /* Ticket rows: larger touch target */\n          .ticket-row { min-height: 60px !important; }\n          /* Select dropdowns in filter bar: compact */\n          .filter-select { font-size: 11px; }\n        }\n\n        /* Responsive ticket list */\n        @media (max-width: 1024px) {\n          /* Allow ticket list to be narrower */\n        }\n      ")}),eK&&(0,i.jsx)("div",{onClick:()=>eJ(!1),style:{position:"fixed",inset:0,background:"rgba(0,0,0,0.5)",display:"flex",alignItems:"center",justifyContent:"center",zIndex:9999},children:(0,i.jsxs)("div",{onClick:e=>e.stopPropagation(),style:{...er(e$),padding:Q.xxl,maxWidth:360,width:"90%"},children:[(0,i.jsx)("div",{style:{fontSize:14,fontWeight:700,marginBottom:Q.lg},children:"Raccourcis clavier"}),[["j / k","Ticket suivant / pr\xe9c\xe9dent"],["a","Analyser le ticket"],["r","\xc9diter le brouillon"],["e","Envoyer la r\xe9ponse"],["s","Ignorer le ticket"],["t","Marquer comme trait\xe9"],["Esc","D\xe9s\xe9lectionner"],["?","Afficher cette aide"]].map(e=>{let[t,n]=e;return(0,i.jsxs)("div",{style:{display:"flex",justifyContent:"space-between",padding:"6px 0",borderBottom:"1px solid ".concat(e$.border),fontSize:12},children:[(0,i.jsx)("kbd",{style:{fontFamily:K,fontSize:11,padding:"2px 6px",borderRadius:$.sm,background:e$.surfaceAlt,border:"1px solid ".concat(e$.border)},children:t}),(0,i.jsx)("span",{style:{color:e$.textMuted},children:n})]},t)}),(0,i.jsx)("button",{onClick:()=>eJ(!1),style:{...ei(!1,e$),marginTop:Q.lg,width:"100%"},children:"Fermer"})]})})]})}}},e=>{e.O(0,[8441,1255,7358],()=>e(e.s=199)),_N_E=e.O()}]);

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.