@unchainedshop/admin-ui 4.4.1 → 4.4.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (79) hide show
  1. package/out/403/index.html +2 -2
  2. package/out/404/index.html +2 -2
  3. package/out/404.html +2 -2
  4. package/out/423/index.html +2 -2
  5. package/out/500/index.html +2 -2
  6. package/out/_next/static/{nvzSUihMt17oSeJB8vX-J → ZINZExBw48QXAnmZi6Rup}/_buildManifest.js +1 -1
  7. package/out/_next/static/chunks/{3282-e2a65c5faff55caf.js → 3282-94459d44b61b3901.js} +1 -1
  8. package/out/_next/static/chunks/{3908-35d5c06b8b80f4d0.js → 3908-6852b2e785d79ac3.js} +1 -1
  9. package/out/_next/static/chunks/824-fd8ea3573638c07d.js +1 -0
  10. package/out/_next/static/chunks/{8474-0e8b5ac04fd81ee1.js → 8474-cc16eb7b40a6b8f0.js} +1 -1
  11. package/out/_next/static/chunks/{8488-34b29297840c693b.js → 8488-7648939f32accbe2.js} +1 -1
  12. package/out/_next/static/chunks/{9771-7e1da9ea99c87f6f.js → 9771-7c85d5564dae1b5d.js} +1 -1
  13. package/out/_next/static/chunks/pages/filters/{new-d1a06d3881047bea.js → new-728984fbf1519419.js} +1 -1
  14. package/out/_next/static/chunks/pages/{index-74344897b7251523.js → index-cbe65d651f31437e.js} +1 -1
  15. package/out/_next/static/chunks/pages/products/new-04fe5222e2a1b6fd.js +1 -0
  16. package/out/_next/static/chunks/pages/products-423ebc7d61aebce3.js +1 -0
  17. package/out/_next/static/chunks/pages/users/{new-b8c176b57ebb587b.js → new-a878520f80c25473.js} +1 -1
  18. package/out/_next/static/chunks/pages/works/{management-345df1385f46b4d8.js → management-0c5b3c46b8513d59.js} +1 -1
  19. package/out/_offline/index.html +2 -2
  20. package/out/account/forgot-password/index.html +2 -2
  21. package/out/account/index.html +2 -2
  22. package/out/assortments/AssortmentDetailPage/index.html +2 -2
  23. package/out/assortments/index.html +2 -2
  24. package/out/assortments/new/index.html +2 -2
  25. package/out/copilot/index.html +2 -2
  26. package/out/country/CountryDetailPage/index.html +2 -2
  27. package/out/country/index.html +2 -2
  28. package/out/country/new/index.html +2 -2
  29. package/out/currency/CurrencyDetailPage/index.html +2 -2
  30. package/out/currency/index.html +2 -2
  31. package/out/currency/new/index.html +2 -2
  32. package/out/delivery-provider/DeliveryProviderDetailPage/index.html +2 -2
  33. package/out/delivery-provider/index.html +2 -2
  34. package/out/delivery-provider/new/index.html +2 -2
  35. package/out/enrollments/EnrollmentDetailPage/index.html +2 -2
  36. package/out/enrollments/index.html +2 -2
  37. package/out/events/EventDetailPage/index.html +2 -2
  38. package/out/events/index.html +2 -2
  39. package/out/external/index.html +2 -2
  40. package/out/filters/FilterDetailPage/index.html +2 -2
  41. package/out/filters/index.html +2 -2
  42. package/out/filters/new/index.html +2 -2
  43. package/out/index.html +2 -2
  44. package/out/install/index.html +2 -2
  45. package/out/language/LanguageDetailPage/index.html +2 -2
  46. package/out/language/index.html +2 -2
  47. package/out/language/new/index.html +2 -2
  48. package/out/log-in/index.html +2 -2
  49. package/out/orders/OrderDetailPage/index.html +2 -2
  50. package/out/orders/index.html +2 -2
  51. package/out/payment-provider/PaymentProviderDetailPage/index.html +2 -2
  52. package/out/payment-provider/index.html +2 -2
  53. package/out/payment-provider/new/index.html +2 -2
  54. package/out/products/ProductDetailPage/index.html +2 -2
  55. package/out/products/index.html +2 -2
  56. package/out/products/new/index.html +2 -2
  57. package/out/quotations/QuotationDetailPage/index.html +2 -2
  58. package/out/quotations/index.html +2 -2
  59. package/out/reset-password/index.html +2 -2
  60. package/out/sign-up/index.html +2 -2
  61. package/out/styleguide/index.html +2 -2
  62. package/out/tokens/TokenDetailPage/index.html +2 -2
  63. package/out/tokens/index.html +2 -2
  64. package/out/users/UserDetailPage/index.html +2 -2
  65. package/out/users/index.html +2 -2
  66. package/out/users/new/index.html +2 -2
  67. package/out/verify-email/index.html +2 -2
  68. package/out/warehousing-provider/WarehousingProviderDetailPage/index.html +2 -2
  69. package/out/warehousing-provider/index.html +2 -2
  70. package/out/warehousing-provider/new/index.html +2 -2
  71. package/out/works/WorkDetailPage/index.html +2 -2
  72. package/out/works/WorkQueueListView/index.html +2 -2
  73. package/out/works/index.html +2 -2
  74. package/out/works/management/index.html +2 -2
  75. package/package.json +1 -1
  76. package/out/_next/static/chunks/824-aa2cb0fb345ae696.js +0 -1
  77. package/out/_next/static/chunks/pages/products/new-84368a7cdb693b1d.js +0 -1
  78. package/out/_next/static/chunks/pages/products-a85cd9bac6151826.js +0 -1
  79. /package/out/_next/static/{nvzSUihMt17oSeJB8vX-J → ZINZExBw48QXAnmZi6Rup}/_ssgManifest.js +0 -0
@@ -1 +1 @@
1
- "use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[3282],{564:(e,t,a)=>{a.d(t,{A:()=>l});var n=a(9985);function s(){let e=(0,n._)(["\n fragment ProductDetailFragment on Product {\n _id\n sequence\n status\n created\n tags\n updated\n published\n\n media {\n _id\n tags\n file {\n _id\n url\n }\n }\n reviews {\n _id\n created\n author {\n _id\n username\n isGuest\n }\n rating\n title\n review\n voteCount\n ownVotes {\n type\n timestamp\n }\n }\n siblings {\n _id\n media {\n _id\n file {\n _id\n url\n }\n }\n }\n }\n"]);return s=function(){return e},e}let l=(0,a(15968).J1)(s())},815:(e,t,a)=>{a.d(t,{A:()=>l});var n=a(9985);function s(){let e=(0,n._)(["\n fragment ProductTextsFragment on ProductTexts {\n _id\n locale\n slug\n title\n subtitle\n description\n vendor\n brand\n labels\n }\n"]);return s=function(){return e},e}let l=(0,a(15968).J1)(s())},12238:(e,t,a)=>{a.d(t,{A:()=>n});let n=(e,t,a)=>Object.assign({},...(null==e?void 0:e.map(e=>({[e[a]]:e[t]})))||[])},15796:(e,t,a)=>{a.d(t,{R:()=>o,A:()=>u});var n=a(9985),s=a(15968),l=a(70486);function r(){let e=(0,n._)(["\n fragment ProductCatalogPriceFragment on ProductCatalogPrice {\n isTaxable\n isNetPrice\n country {\n _id\n isoCode\n name\n flagEmoji\n }\n currency {\n _id\n isoCode\n isActive\n }\n amount\n maxQuantity\n }\n"]);return r=function(){return e},e}let i=(0,s.J1)(r());function d(){let e=(0,n._)(["\n query ProductCatalogPrices($productId: ID!) {\n productCatalogPrices(productId: $productId) {\n ...ProductCatalogPriceFragment\n }\n }\n ","\n"]);return d=function(){return e},e}let o=(0,s.J1)(d(),i),u=e=>{let{productId:t}=e,{data:a,loading:n,error:s}=(0,l.I)(o,{skip:!t,variables:{productId:t}});return{catalogPrices:(null==a?void 0:a.productCatalogPrices)||[],loading:n,error:s}}},18237:(e,t,a)=>{a.d(t,{A:()=>l});var n=a(9985);function s(){let e=(0,n._)(["\n fragment CurrencyFragment on Currency {\n _id\n isoCode\n isActive\n contractAddress\n decimals\n }\n"]);return s=function(){return e},e}let l=(0,a(15968).J1)(s())},23282:(e,t,a)=>{a.r(t),a.d(t,{default:()=>a7});var n=a(26514),s=a(644),l=a(824),r=a(99650),i=a(7823),d=a(15829),o=a(27413),u=a(94617),c=a(91701),m=a(56585),p=a(16165),x=a(48029),g=a(38504),f=a(20915),v=a(54333),h=a(13039),b=a(55263),j=a(75151),y=a(70369),_=a(10702),w=a(75834),N=a(70267),A=a(70412),P=a(13226),k=a(12238),M=a(51869),I=a(35843),C=a(69001),$=a.n(C),S=a(2560);let T=e=>{let{disabled:t,labelClassName:a,containerClassName:s,inputClassName:l,...r}=e,i=(0,S.A)({...e,type:"checkbox"});return(0,n.jsxs)("div",{className:$()("",{"text-rose-600":!!i.error,checkbox:!0,disabled:i.disabled,required:i.required},s),children:[(0,n.jsx)("input",{checked:!!i.value,disabled:t,id:i.name,name:i.name,onChange:i.onChange,onBlur:i.onBlur,type:"checkbox",className:$()("h-4 w-4 rounded-xs border-slate-300 dark:border-slate-600 bg-white dark:!bg-slate-800 text-indigo-600 dark:text-slate-200 focus:ring-slate-800",l,e.className),...r}),(0,n.jsx)("label",{htmlFor:i.name,className:$()("text-sm text-slate-900 dark:text-slate-200",a,{"text-danger":!!i.error}),children:i.label})]})};var V=a(42043),D=a(62250),R=a(50899),q=a(65917),E=a(70728),F=a(25851),O=a(95002),U=a(24048),J=a(15796),L=a(9985),B=a(15968),Q=a(62206),z=a(564);function W(){let e=(0,L._)(["\n mutation UpdateProductCommerce(\n $productId: ID!\n $commerce: UpdateProductCommerceInput!\n ) {\n updateProductCommerce(productId: $productId, commerce: $commerce) {\n ...ProductDetailFragment\n }\n }\n ","\n"]);return W=function(){return e},e}let K=(0,B.J1)(W(),z.A),G=function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[],t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[];return t.length?e.map(e=>{let a=t.find(t=>{let{isoCode:a}=t;return a.toLowerCase()===e.currency.isoCode.toLowerCase()});return{countryCode:e.country.isoCode,currencyCode:e.currency.isoCode,isTaxable:!!e.isTaxable,isNetPrice:!!e.isNetPrice,amount:((e,t)=>{if(t<0)return"0";if(0===t)return e.toString();let a=e.toString();if("0"===a)return"0."+"0".repeat(t);let n=a.startsWith("-"),s=n?a.slice(1):a;if(s.length<=t){let e=s.padStart(t,"0");return"".concat(n?"-":"","0.").concat(e)}let l=s.length-t,r=s.slice(0,l),i=s.slice(l);return"".concat(n?"-":"").concat(r,".").concat(i)})(e.amount,null==a?void 0:a.decimals),maxQuantity:e.maxQuantity}}):[]},H=e=>{var t;let{productId:a,disabled:r=!1}=e,{formatMessage:i}=(0,s.A)(),{catalogPrices:d}=(0,J.A)({productId:a}),{hasRole:o}=(0,A.A)(),{updateProductCommerce:u}=(()=>{let[e]=(0,Q.n)(K),{currencies:t}=(0,I.A)();return{updateProductCommerce:async a=>{let{productId:n,commerce:{pricing:s}}=a;return e({variables:{productId:n,commerce:{pricing:s.map(e=>{let a=t.find(t=>{let{isoCode:a}=t;return a===e.currencyCode}),n=((e,t)=>{if(!e||t<0)return 0;let a=e.trim();if(!/^-?\d*\.?\d*$/.test(a))return 0;let n=a.indexOf(".");if(-1===n)return Number(a)*10**t;let s=a.slice(0,n)||"0";return Number(s+a.slice(n+1).slice(0,t).padEnd(t,"0"))})(e.amount.toString(),a.decimals);return{...e,amount:n}})}},refetchQueries:["Products"]})}}})(),{countries:c}=(0,M.A)(),{currencies:m}=(0,I.A)(),p=null==c?void 0:c.find(e=>{let{isBase:t}=e;return t}),x=null==p?void 0:p.isoCode,g=null==p||null==(t=p.defaultCurrency)?void 0:t.isoCode,f=async e=>{let{pricing:t}=e;return await u({productId:a,commerce:{pricing:t}}),{success:!0}},v=i({id:"saved",defaultMessage:"Saved"}),h=G(d,m),b=(0,O.A)({disabled:r,submit:f,successMessage:v,enableReinitialize:!0,initialValues:{pricing:[...(null==h?void 0:h.length)?h:[{maxQuantity:"",amount:null,isTaxable:!1,isNetPrice:!1,currencyCode:g,countryCode:x}]]}}),{values:j}=b.formik,{pricing:y}=j;return(0,n.jsx)("div",{children:(0,n.jsxs)("div",{className:"mt-5 md:col-span-3 lg:mt-0",children:[(0,n.jsx)(P.A,{children:(0,n.jsxs)(V.A,{className:"mt-3 rounded-md",form:b,disabled:!o(l._r.ManageProducts),children:[(0,n.jsxs)("div",{className:"relative max-w-full p-3 sm:px-5",children:[(0,n.jsx)("div",{className:"max-w-full justify-between align-baseline"}),(0,n.jsxs)("label",{className:"sr-only flex w-full font-sans text-sm text-slate-500 dark:text-slate-200 lg:not-sr-only",children:[(0,n.jsxs)("span",{className:"flex w-full",children:[(0,n.jsx)("span",{className:"w-full",children:i({id:"max_quantity",defaultMessage:"Max Quantity"})}),(0,n.jsx)("span",{className:"w-full lg:ml-5",children:i({id:"price",defaultMessage:"Price"})})]}),(0,n.jsxs)("span",{className:"flex w-full",children:[(0,n.jsx)("span",{className:"w-full lg:ml-8",children:i({id:"vat_suspect",defaultMessage:"Vat Suspect"})}),(0,n.jsx)("span",{className:"w-full lg:ml-12",children:i({id:"net_price",defaultMessage:"Net Price"})})]}),(0,n.jsxs)("span",{className:"mr-5 flex w-full",children:[(0,n.jsx)("span",{className:"ml-10 w-full",children:i({id:"country",defaultMessage:"Country"})}),(0,n.jsx)("span",{className:"w-full",children:i({id:"currency",defaultMessage:"Currency"})})]})]}),(0,n.jsx)(N.ED,{name:"pricing",children:e=>{let{push:t,remove:a}=e;return(0,n.jsxs)("div",{children:[j.pricing.map((e,t)=>(0,n.jsxs)("div",{className:"relative max-w-full border-b dark:border-slate-700 pt-1 pb-5 mb-3 align-baseline lg:flex",children:[(0,n.jsxs)("div",{className:"flex w-full gap-x-2",children:[(0,n.jsx)(E.A,{className:"w-full",disabled:!o(l._r.ManageProducts),validators:[(0,U.lw)(t,y),(0,U.IE)(y)],name:"pricing[".concat(t,"].maxQuantity"),id:"pricing[".concat(t,"].maxQuantity"),type:"number",min:0,hideLabel:!0,label:i({id:"max_quantity",defaultMessage:"Max Quantity"})}),(0,n.jsx)(E.A,{type:"number",className:"w-full",disabled:!o(l._r.ManageProducts),name:"pricing[".concat(t,"].amount"),id:"pricing[".concat(t,"].amount"),required:!0,hideLabel:!0,label:i({id:"price",defaultMessage:"Price "})})]}),(0,n.jsxs)("div",{className:"flex w-full gap-x-2 pt-3 pb-2",children:[(0,n.jsx)("div",{className:"w-full lg:ml-8 lg:items-center",children:(0,n.jsx)(T,{name:"pricing[".concat(t,"].isTaxable"),labelClassName:"lg:sr-only items-center ",disabled:!o(l._r.ManageProducts),label:i({id:"vat_suspect",defaultMessage:"Vat Suspect"}),className:"mr-2 h-4 w-4 rounded-sm border-slate-300 dark:border-slate-600 bg-white dark:!bg-slate-900 text-slate-950 focus:ring-slate-800 lg:items-center",type:"checkbox"})}),(0,n.jsx)("div",{className:"w-full lg:ml-8",children:(0,n.jsx)(T,{name:"pricing[".concat(t,"].isNetPrice"),labelClassName:"lg:sr-only items-center",disabled:!o(l._r.ManageProducts),label:i({id:"net_price",defaultMessage:"Net Price"}),hideLabel:!0,className:"mr-2 h-4 w-4 justify-between rounded-sm border-slate-300 dark:border-slate-600 bg-white dark:!bg-slate-900 text-slate-950 focus:ring-slate-800 lg:items-center",type:"checkbox"})})]}),(0,n.jsxs)("div",{className:"flex w-full gap-x-2 mt-1",children:[(0,n.jsx)(R.A,{defaultValue:x,className:"w-full lg:ml-4 lg:mr-4",label:i({id:"country",defaultMessage:"Country"}),name:"pricing[".concat(t,"].countryCode"),id:"pricing[".concat(t,"].countryCode"),disabled:!o(l._r.ManageProducts),required:!0,options:(0,k.A)(c,"isoCode","isoCode"),hideLabel:!0}),(0,n.jsx)(R.A,{defaultValue:g,className:"w-full lg:mr-8 ",label:i({id:"currency",defaultMessage:"Currency"}),disabled:!o(l._r.ManageProducts),name:"pricing[".concat(t,"].currencyCode"),id:"pricing[".concat(t,"].currencyCode"),required:!0,options:(0,k.A)(m,"isoCode","isoCode"),hideLabel:!0,placeholder:i({id:"country_currency",defaultMessage:"Currency"})})]}),o(l._r.ManageProducts)&&(0,n.jsx)("div",{className:"absolute -top-2 right-0 mt-0 mr-0 shrink-0 pb-1 md:mr-0 lg:mt-6 lg:py-0 lg:px-0 ",children:(0,n.jsx)("button",{className:"items-center rounded-full bg-white dark:bg-slate-900 px-1 py-1 text-sm text-rose-500 dark:text-rose-400 hover:bg-rose-50 focus:outline-hidden focus:ring-0 focus:ring-rose-500 focus:ring-offset-2",type:"button",onClick:()=>a(t),children:(0,n.jsxs)("svg",{className:"h-4 w-4",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,n.jsx)("polyline",{points:"3 6 5 6 21 6"}),(0,n.jsx)("path",{d:"M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6m3 0V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2"}),(0,n.jsx)("line",{x1:"10",y1:"11",x2:"10",y2:"17"}),(0,n.jsx)("line",{x1:"14",y1:"11",x2:"14",y2:"17"})]})})})]},t)),o(l._r.ManageProducts)&&(0,n.jsx)("div",{className:"mt-6",children:(0,n.jsx)(F.A,{variant:"tertiary",text:i({id:"add_price_row",defaultMessage:"Add Price Row"}),className:"w-full items-center justify-center",onClick:()=>t({maxQuantity:"",amount:null,isTaxable:!1,isNetPrice:!1,currencyCode:g,countryCode:x})})})]})}})]}),(0,n.jsx)(D.A,{displayFieldErrors:!0}),o(l._r.ManageProducts)&&(0,n.jsx)("div",{className:"-mx-6 p-6 bg-slate-50 dark:bg-slate-900 text-right",children:(0,n.jsx)(q.A,{className:"mx-6",label:i({id:"save",defaultMessage:"Save"})})})]})}),(0,n.jsx)("p",{className:"mt-6 mb-10 text-sm text-slate-500 dark:text-slate-400",children:i({id:"product_commerce_info",defaultMessage:"One price list should have a max quantity field empty and no price should have the same max quantity along with currency and country specified"})})]})})};var X=a(76087),Z=a(65459),Y=a(815);function ee(){let e=(0,L._)(["\n mutation UpdateProductTexts($productId: ID!, $texts: [ProductTextInput!]!) {\n updateProductTexts(productId: $productId, texts: $texts) {\n ...ProductTextsFragment\n }\n }\n ","\n"]);return ee=function(){return e},e}let et=(0,B.J1)(ee(),Y.A);var ea=a(70805),en=a(54640),es=a(71759),el=a(25191),er=a(74781),ei=a(17482);let ed=e=>{let{productId:t,disabled:a=!1}=e,{selectedLocale:r,setSelectedLocale:i,languageDialectList:d}=(0,er.A)(),{formatMessage:o}=(0,s.A)(),{hasRole:u}=(0,A.A)(),{defaultLocale:c,shopInfo:m,loading:p}=(0,ei.A)(),{translatedTexts:x}=(0,Z.A)({productId:t}),g=o({id:"saved",defaultMessage:"Saved"}),{updateProductTexts:f}=(()=>{let[e]=(0,Q.n)(et);return{updateProductTexts:async t=>{let{productId:a,texts:n}=t;return e({variables:{productId:a,texts:n},refetchQueries:["TranslatedProductTexts"]})}}})(),v=async e=>{let{slug:a,title:n,subtitle:s,vendor:l,description:i,brand:d,labels:o}=e;return await f({productId:t,texts:[{locale:r,slug:a,title:n,subtitle:s,vendor:l,description:i,brand:d,labels:o}]}),{success:!0}},h=(0,O.A)({disabled:a,submit:v,successMessage:g,initialValues:{slug:"",title:"",subtitle:"",vendor:"",description:"",brand:"",labels:[]}});return(0,w.useEffect)(()=>{let e=null==x?void 0:x.find(e=>e.locale===r);h.formik.setValues({slug:"",title:"",subtitle:"",vendor:"",description:"",brand:"",labels:[],...e||{}})},[x,r]),(0,w.useEffect)(()=>{if(m&&(null==x?void 0:x.length)&&(null==x||!x.find(e=>{let{locale:t}=e;return t===r})))if(c&&(null==x?void 0:x.find(e=>{let{locale:t}=e;return t===c})))i(c);else if(c&&(null==x?void 0:x.find(e=>{let{locale:t}=e;return t===c.split("-")[0]})))i(c.split("-")[0]);else{let e=null==x?void 0:x.find(e=>{let{locale:t}=e;return t&&(null==d?void 0:d.find(e=>{let{isoCode:a}=e;return a===t}))});i(null==e?void 0:e.locale)}},[p,x]),(0,n.jsx)(ea.A,{documentationLabel:o({id:"texts",defaultMessage:"Texts"}),className:"mt-2 lg:mt-5",documentation:(0,n.jsx)(X.A,{id:"product_text_form_description",defaultMessage:"<ul> <li><strong>Slug:</strong> The unique part of your product URL (e.g., 'my-awesome-product'). Keep it short and descriptive.</li> <li><strong>Localization:</strong> Switch languages using the dropdown at the top left to translate content for different markets.</li> <li><strong>Description:</strong> Supports Markdown and HTML formatting. Use double backslash (\\\\\\\\) for line breaks.</li> <li><strong>Labels:</strong> Eye-catching badges that appear on your product (e.g., 'New Arrival', '50% Off', 'Limited Edition'). Perfect for promotions and highlighting special features. Each language can have unique labels.</li> <li><strong>Key Difference:</strong> Labels are customer-facing promotional badges, while Tags are internal keywords for organization and filtering.</li> </ul>",values:{ul:e=>(0,n.jsxs)("ul",{className:"space-y-2",children:[e," "]}),li:e=>(0,n.jsxs)("li",{className:"text-sm",children:[e," "]},Math.random()),strong:e=>(0,n.jsx)("strong",{className:"font-semibold text-slate-800 dark:text-slate-200",children:e})}}),children:(0,n.jsx)(P.A,{children:(0,n.jsxs)(V.A,{form:h,disabled:!u(l._r.ManageProducts),children:[(0,n.jsxs)("div",{className:"relative text-slate-500 dark:text-slate-200 px-4 py-5 sm:p-6",children:[(0,n.jsxs)("div",{className:"grid grid-cols-6 gap-6",children:[(0,n.jsx)("div",{className:"col-span-6 sm:col-span-3",children:(0,n.jsx)(E.A,{name:"slug",disabled:!u(l._r.ManageProducts),required:!0,id:"slug",label:o({id:"slug",defaultMessage:"Slug"}),autoComplete:"on",className:"text-sm"})}),(0,n.jsx)("div",{className:"col-span-6 sm:col-span-3",children:(0,n.jsx)(E.A,{name:"title",disabled:!u(l._r.ManageProducts),required:!0,id:"title",label:o({id:"title",defaultMessage:"Title"}),autoComplete:"on",className:"text-sm"})}),(0,n.jsx)("div",{className:"col-span-6 sm:col-span-3",children:(0,n.jsx)(E.A,{name:"subtitle",disabled:!u(l._r.ManageProducts),id:"subtitle",label:o({id:"subtitle",defaultMessage:"Subtitle"}),autoComplete:"on",className:"text-sm"})}),(0,n.jsx)("div",{className:"col-span-6 sm:col-span-3",children:(0,n.jsx)(E.A,{name:"vendor",disabled:!u(l._r.ManageProducts),id:"vendor",label:o({id:"vendor",defaultMessage:"Vendor"}),autoComplete:"on",className:"text-sm"})}),(0,n.jsx)("div",{className:"col-span-6 sm:col-span-3",children:(0,n.jsx)(E.A,{name:"brand",disabled:!u(l._r.ManageProducts),id:"brand",label:o({id:"brand",defaultMessage:"Brand"}),autoComplete:"on",className:"text-sm"})}),(0,n.jsxs)("div",{className:"col-span-6 sm:col-span-3",children:[(0,n.jsx)(es.A,{name:"labels",id:"labels",disabled:!u(l._r.ManageProducts),label:o({id:"labels",defaultMessage:"Labels"}),placeholder:o({id:"label",defaultMessage:"Label"}),buttonText:o({id:"add",defaultMessage:"Add"}),autoComplete:"on",className:"text-sm"}),(0,n.jsx)(el.A,{messageKey:"product_labels_help",defaultMessage:"Add promotional badges like 'New Arrival', '50% Off', or 'Limited Edition' that customers will see on your product. Perfect for highlighting deals and special features.",className:"mt-3"})]})]}),(0,n.jsx)("div",{className:"col-span-6 mt-6 sm:col-span-3",children:(0,n.jsx)(en.A,{name:"description",id:"description",disabled:!u(l._r.ManageProducts),label:o({id:"description",defaultMessage:"Description"})})})]}),u(l._r.ManageProducts)&&(0,n.jsx)("div",{className:"border-t-slate-100 border-t dark:border-t-slate-700 bg-slate-50 dark:bg-slate-900 px-4 py-5 text-right sm:px-6",children:(0,n.jsx)(q.A,{label:o({id:"save",defaultMessage:"Save"})})})]})})})};var eo=a(32162),eu=a(81593),ec=a(85979),em=a(30059),ep=a(20367);function ex(){let e=(0,L._)(["\n mutation PrepareProductMediaUpload($mediaName: String!, $productId: ID!) {\n prepareProductMediaUpload(mediaName: $mediaName, productId: $productId) {\n _id\n putURL\n expires\n }\n }\n"]);return ex=function(){return e},e}let eg=(0,B.J1)(ex());var ef=a(70486),ev=a(13414);function eh(){let e=(0,L._)(["\n fragment ProductMediaFragment on ProductMedia {\n _id\n tags\n file {\n _id\n name\n type\n size\n url\n }\n sortKey\n texts {\n _id\n locale\n title\n subtitle\n }\n }\n"]);return eh=function(){return e},e}let eb=(0,B.J1)(eh());function ej(){let e=(0,L._)(["\n query ProductMedia($productId: ID, $slug: String) {\n product(productId: $productId, slug: $slug) {\n _id\n media {\n ...ProductMediaFragment\n }\n }\n }\n ","\n"]);return ej=function(){return e},e}let ey=(0,B.J1)(ej(),eb),e_=function(){var e;let{productId:t=null,slug:a=null}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},n=(0,ev.id)(a),{data:s,loading:l,error:r}=(0,ef.I)(ey,{skip:!t&&!n,variables:{productId:t||n}});return{productMedia:(null==s||null==(e=s.product)?void 0:e.media)||[],loading:l,error:r}};var ew=a(81090),eN=a(70556);function eA(){let e=(0,L._)(["\n fragment ProductMediaTextsFragment on ProductMediaTexts {\n _id\n locale\n title\n subtitle\n }\n"]);return eA=function(){return e},e}let eP=(0,B.J1)(eA());function ek(){let e=(0,L._)(["\n query TranslatedProductMediaTexts($productMediaId: ID!) {\n translatedProductMediaTexts(productMediaId: $productMediaId) {\n ...ProductMediaTextsFragment\n }\n }\n ","\n"]);return ek=function(){return e},e}let eM=(0,B.J1)(ek(),eP);function eI(){let e=(0,L._)(["\n mutation UpdateProductMediaTexts(\n $productMediaId: ID!\n $texts: [ProductMediaTextInput!]!\n ) {\n updateProductMediaTexts(productMediaId: $productMediaId, texts: $texts) {\n ...ProductMediaTextsFragment\n }\n }\n ","\n"]);return eI=function(){return e},e}let eC=(0,B.J1)(eI(),eP);var e$=a(62679);function eS(){let e=(0,L._)(["\n mutation RemoveProductMedia($productMediaId: ID!) {\n removeProductMedia(productMediaId: $productMediaId) {\n _id\n }\n }\n"]);return eS=function(){return e},e}let eT=(0,B.J1)(eS());var eV=a(16227);let eD=e=>{let{media:t,id:a}=e,{setModal:i}=(0,eV.A)(),{removeProductMedia:d}=(()=>{let[e]=(0,Q.n)(eT);return{removeProductMedia:async t=>{let{productMediaId:a}=t;return e({variables:{productMediaId:a},refetchQueries:["ProductMedia"]})}}})(),{formatMessage:o}=(0,s.A)(),{selectedLocale:u}=(0,er.A)(),{updateProductMediaTexts:c}=(()=>{let[e]=(0,Q.n)(eC);return{updateProductMediaTexts:async t=>{let{productMediaId:a,texts:n}=t;return e({variables:{productMediaId:a,texts:n},refetchQueries:["TranslatedProductMediaTexts"]})}}})(),[m,p]=(0,w.useState)(!1),{hasRole:x}=(0,A.A)(),{translatedMediaTexts:g}=(e=>{let{productMediaId:t}=e,{data:a,loading:n,error:s}=(0,ef.I)(eM,{skip:!t,variables:{productMediaId:t}});return{translatedMediaTexts:(null==a?void 0:a.translatedProductMediaTexts)||[],loading:n,error:s}})({productMediaId:t._id}),f=(null==g?void 0:g.find(e=>e.locale===u))||{},v=async e=>{await i((0,n.jsx)(e$.A,{onCancelClick:async()=>i(""),message:o({id:"delete_product_media_confirmation",defaultMessage:"This action might cause inconsistencies with other data that relates to it. Are you sure you want to delete this media? "}),onOkClick:async()=>{i(""),await d({productMediaId:e}),r.oR.success(o({id:"product_media_deleted",defaultMessage:"Media deleted successfully"}))},okText:o({id:"delete_product_media",defaultMessage:"Delete media"})}))},h=async e=>{let{title:a,subtitle:n}=e;return await c({productMediaId:t._id,texts:[{title:a,locale:u,subtitle:n}]}),p(!1),!0};return(0,n.jsx)(eN.A,{id:a,media:t,mediaText:f,isEdit:m,onDelete:x(l._r.ManageProducts)?v:void 0,onEdit:x(l._r.ManageProducts)?p:void 0,onUpdate:x(l._r.ManageProducts)?h:void 0})},eR=e=>{let{medias:t,items:a}=e,{formatMessage:l}=(0,s.A)();return(0,n.jsx)("div",{className:"rounded-md lg:col-span-6 px-6",children:(0,n.jsxs)("div",{className:"mx-auto overflow-hidden",children:[(0,n.jsx)("h2",{className:"sr-only",children:l({id:"product_media",defaultMessage:"Product Media"})}),(0,n.jsx)("div",{className:"flow-root",children:(0,n.jsx)(eu.gB,{items:a,strategy:eu._G,children:(0,n.jsx)("ul",{className:"flex flex-col gap-3 rounded-md transition-[background-color] ease-in-out delay-200 ",children:(null==t?void 0:t.length)?a.map(e=>{let a=Object.values(t).find(t=>t._id===e);return(0,n.jsx)(eD,{id:e,media:a},a._id)}):(0,n.jsx)(ew.A,{message:l({id:"media",defaultMessage:"Media"})})})})})]})})};function eq(){let e=(0,L._)(["\n mutation ReOrderProductMedia($sortKeys: [ReorderProductMediaInput!]!) {\n reorderProductMedia(sortKeys: $sortKeys) {\n _id\n }\n }\n"]);return eq=function(){return e},e}let eE=(0,B.J1)(eq()),eF=e=>{let{productId:t}=e,{productMedia:a}=e_({productId:t}),{formatMessage:i}=(0,s.A)(),{hasRole:d}=(0,A.A)(),{addProductMedia:o}=(()=>{let[e]=(0,Q.n)(eg),{confirmMediaUpload:t}=(0,ep.A)({refetchQueries:["Product"]});return{addProductMedia:async a=>{let{productId:n,media:s}=a,{data:l}=await e({variables:{productId:n,mediaName:s.name}}),{prepareProductMediaUpload:r}=l;return await (0,em.A)(s,r.putURL),t({mediaUploadTicketId:r._id,size:null==s?void 0:s.size,type:s.type})}}})(),{reOrderProductMedia:u}=(()=>{let[e]=(0,Q.n)(eE);return{reOrderProductMedia:async t=>{let{sortKeys:a}=t;return e({variables:{sortKeys:a},refetchQueries:["ProductMedia"]})}}})(),c=null==a?void 0:a.map(e=>e._id),m=async e=>{try{await o({productId:t,media:e}),r.oR.success(i({id:"product_media_upload",defaultMessage:"Media uploaded successfully"}))}catch(e){r.oR.error(i({id:"fail_upload",defaultMessage:"Media upload failed"}))}},p=async e=>{let{active:t,over:a}=e;if(t.id!==a.id){let e=c.indexOf(t.id),n=c.indexOf(a.id),s=(0,eu.be)(c,e,n).map((e,t)=>({productMediaId:e,sortKey:t}));try{await u({sortKeys:s}),r.oR.success(i({id:"link_reorder",defaultMessage:"Link reorder successfully"}))}catch(e){r.oR.error(i({id:"fail_reorder",defaultMessage:"Reordering failed, Try again!"}))}}else r.oR.info(i({id:"reorder_original",defaultMessage:"Reorder to original location"}))},x=(0,eo.FR)((0,eo.MS)(eo.AN,{activationConstraint:{distance:5}}),(0,eo.MS)(eo.uN,{coordinateGetter:eu.JR}));return(0,n.jsxs)("div",{className:"mx-auto mt-5 space-y-5 lg:space-y-0 max-w-full py-6 lg:grid lg:grid-cols-12 lg:gap-4",children:[d(l._r.ManageProducts)&&(0,n.jsx)("div",{className:"mx-auto w-full px-6 lg:col-span-6 lg:col-start-1",children:(0,n.jsx)(ec.A,{onlyDragAndDrop:!0,addMedia:m})}),(0,n.jsx)(eo.Mp,{sensors:x,collisionDetection:eo.fp,onDragEnd:p,children:(0,n.jsx)(eR,{medias:a,items:c})})]})};function eO(){let e=(0,L._)(["\n fragment ProductPlanConfigurationFragment on ProductPlanConfiguration {\n usageCalculationType\n billingInterval\n trialInterval\n trialIntervalCount\n billingIntervalCount\n }\n"]);return eO=function(){return e},e}let eU=(0,B.J1)(eO());function eJ(){let e=(0,L._)(["\n query ProductPlan($productId: ID, $slug: String) {\n product(productId: $productId, slug: $slug) {\n _id\n ... on PlanProduct {\n plan {\n ...ProductPlanConfigurationFragment\n }\n }\n }\n }\n ","\n"]);return eJ=function(){return e},e}let eL=(0,B.J1)(eJ(),eU),eB=function(){let{productId:e=null,slug:t=null}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},a=(0,ev.id)(t),{data:n,loading:s,error:l}=(0,ef.I)(eL,{skip:!e&&!a,variables:{productId:e||a}}),r=null==n?void 0:n.product;return{plan:null==r?void 0:r.plan,loading:s,error:l}};function eQ(){let e=(0,L._)(['\n query ProductPlanConfigurationOptions {\n usageCalculationTypes: __type(name: "ProductPlanUsageCalculationType") {\n options: enumValues {\n value: name\n label: description\n }\n }\n configurationIntervals: __type(name: "ProductPlanConfigurationInterval") {\n options: enumValues {\n value: name\n label: description\n }\n }\n }\n']);return eQ=function(){return e},e}let ez=(0,B.J1)(eQ());function eW(){let e=(0,L._)(["\n mutation UpdateProductPlan($productId: ID!, $plan: UpdateProductPlanInput!) {\n updateProductPlan(productId: $productId, plan: $plan) {\n _id\n }\n }\n"]);return eW=function(){return e},e}let eK=(0,B.J1)(eW()),eG=e=>{let{productId:t,disabled:a=!1}=e,{formatMessage:r}=(0,s.A)(),{configurationIntervals:i,usageCalculationTypes:d}=(()=>{var e,t;let{data:a,loading:n,error:s}=(0,ef.I)(ez),l=(null==a||null==(e=a.usageCalculationTypes)?void 0:e.options)||[];return{configurationIntervals:(null==a||null==(t=a.configurationIntervals)?void 0:t.options)||[],usageCalculationTypes:l,loading:n,error:s}})(),{plan:o,loading:u}=eB({productId:t}),{hasRole:c}=(0,A.A)(),{updateProductPlan:m}=(()=>{let[e]=(0,Q.n)(eK);return{updateProductPlan:async t=>{let{productId:a,plan:{usageCalculationType:n,billingInterval:s,billingIntervalCount:l=null,trialInterval:r=null,trialIntervalCount:i=null}}=t;return e({variables:{productId:a,plan:{usageCalculationType:n,billingInterval:s,billingIntervalCount:l,trialInterval:r,trialIntervalCount:i}},refetchQueries:["Products"]})}}})(),p=r({id:"enrollment_updated_successfully",defaultMessage:"Enrollment saved successfully"}),x=async e=>{let{trialInterval:a,trialIntervalCount:n,billingInterval:s,billingIntervalCount:l,usageCalculationType:r}=e;return await m({productId:t,plan:{billingInterval:s,usageCalculationType:r,billingIntervalCount:l,trialInterval:a,trialIntervalCount:n}}),{success:!0}},g=(0,O.A)({disabled:a,submit:x,successMessage:p,initialValues:{trialInterval:"",trialIntervalCount:"",billingInterval:"",billingIntervalCount:"",usageCalculationType:""},getSubmitErrorMessage:e=>{var t;return(null==e||null==(t=e.message)?void 0:t.includes("Status of the product does not allow this operation"))?r({id:"subscription_product_type_not_valid",defaultMessage:"Status of the product does not allow this operation"}):(null==e?void 0:e.message)||""}});return(0,w.useEffect)(()=>{o&&!u&&g.formik.setValues(o)},[o]),(0,n.jsx)(ea.A,{documentationLabel:r({id:"subscription",defaultMessage:"Subscription"}),className:"mt-2 lg:mt-5",documentation:(0,n.jsx)(X.A,{id:"product_subscription_form_description",defaultMessage:"<ul><li> Information that will be used to calculate price of a subscription based product </li> <li>The price specified in commerce section will be used when calculating fees on each interval. </li> <li>Price will not be included for the specified trial period </li> </ul>",values:{ul:e=>(0,n.jsxs)("ul",{className:"space-y-1",children:[e," "]}),li:e=>(0,n.jsx)("li",{children:e})}}),children:(0,n.jsx)(P.A,{children:(0,n.jsx)(V.A,{form:g,children:(0,n.jsxs)("div",{className:"relative max-w-full space-y-6 rounded-md sm:p-6",children:[(0,n.jsx)(R.A,{required:!0,className:"mt-2.5 w-full py-1.5 text-sm font-medium text-slate-500",label:r({id:"usage_calculation_type",defaultMessage:"Usage calculation type"}),placeholder:r({id:"usage_calculation_type",defaultMessage:"Usage calculation type"}),name:"usageCalculationType",options:(0,k.A)(d,"value","value")}),(0,n.jsxs)("div",{className:"w-full items-end justify-end sm:flex",children:[(0,n.jsx)(R.A,{className:"mt-2.5 w-full text-sm font-medium text-slate-500",required:!0,label:r({id:"billing_interval_unit",defaultMessage:"Billing interval unit"}),placeholder:r({id:"billing_interval_unit",defaultMessage:"Billing interval unit"}),name:"billingInterval",options:(0,k.A)(i,"value","value")}),(0,n.jsx)(E.A,{name:"billingIntervalCount",id:"billing_unit",type:"number",required:!0,label:r({id:"billing_unit",defaultMessage:"Billing Unit"}),placeholder:r({id:"billing_unit",defaultMessage:"Billing Unit"}),className:"mt-1 w-full text-sm font-medium text-slate-500 sm:ml-1"})]}),(0,n.jsxs)("div",{className:"max-w-full items-end justify-end sm:flex",children:[(0,n.jsx)(R.A,{className:"mt-2.5 w-full text-sm font-medium text-slate-500",label:r({id:"trial_interval_unit",defaultMessage:"Trial interval unit"}),placeholder:r({id:"trial_interval_unit",defaultMessage:"Trial interval unit"}),name:"trialInterval",options:(0,k.A)(i,"value","value")}),(0,n.jsx)(E.A,{type:"number",name:"trialIntervalCount",id:"trialIntervalCount ",label:r({id:"trial_unit",defaultMessage:"Trial Unit"}),placeholder:r({id:"trial_unit",defaultMessage:"Trial Unit"}),required:!0,className:"mt-1 w-full text-sm font-medium text-slate-500 sm:ml-1"})]}),c(l._r.CreateEnrollment)&&(0,n.jsx)("div",{className:"-mx-6 -mb-6 mt-6 border-t-slate-100 border-t space-y-6 bg-slate-50 dark:bg-slate-500 text-right sm:p-6",children:(0,n.jsx)(q.A,{label:r({id:"save",defaultMessage:"Save"})})})]})})})})};var eH=a(64115);function eX(){let e=(0,L._)(["\n query ProductSupply($productId: ID, $slug: String) {\n product(productId: $productId, slug: $slug) {\n _id\n ... on SimpleProduct {\n dimensions {\n ...ProductDimensionFragment\n }\n }\n }\n }\n ","\n"]);return eX=function(){return e},e}let eZ=(0,B.J1)(eX(),eH.A),eY=function(){let{productId:e=null,slug:t=null}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},a=(0,ev.id)(t),{data:n,loading:s,error:l}=(0,ef.I)(eZ,{skip:!e&&!t,variables:{productId:e||a}}),r=null==n?void 0:n.product;return{dimensions:(null==r?void 0:r.dimensions)||{},loading:s,error:l}};function e0(){let e=(0,L._)(["\n mutation UpdateProductSupply(\n $productId: ID!\n $supply: UpdateProductSupplyInput!\n ) {\n updateProductSupply(productId: $productId, supply: $supply) {\n _id\n ... on SimpleProduct {\n dimensions {\n ...ProductDimensionFragment\n }\n }\n }\n }\n ","\n"]);return e0=function(){return e},e}let e1=(0,B.J1)(e0(),eH.A),e5=e=>{let{productId:t,disabled:a=!1}=e,{formatMessage:r}=(0,s.A)(),i=r({id:"saved",defaultMessage:"Saved"}),{hasRole:d}=(0,A.A)(),{updateProductSupply:o}=(()=>{let[e]=(0,Q.n)(e1);return{updateProductSupply:async t=>{let{productId:a,supply:{weightInGram:n=null,heightInMillimeters:s=null,lengthInMillimeters:l=null,widthInMillimeters:r=null}}=t;return e({variables:{productId:a,supply:{weightInGram:n||null,heightInMillimeters:s||null,lengthInMillimeters:l||null,widthInMillimeters:r||null}},refetchQueries:["Products"]})}}})(),{dimensions:u}=eY({productId:t}),c=async e=>{let{weight:a,length:n,width:s,height:l}=e;return await o({productId:t,supply:{weightInGram:a,lengthInMillimeters:n,heightInMillimeters:l,widthInMillimeters:s}}),{success:!0}},m=(0,O.A)({disabled:a,submit:c,getSubmitErrorMessage:e=>(e.message.includes("supply.weightInGram")&&e.message.includes("Expected type Int")?m.formik.setFieldError("weight","Invalid value, only integer is accepted"):e.message.includes("supply.heightInMillimeters")&&e.message.includes("Expected type Int")?m.formik.setFieldError("height","Invalid value, only integer is accepted"):e.message.includes("supply.lengthInMillimeters")&&e.message.includes("Expected type Int")&&m.formik.setFieldError("length","Invalid value, only integer is accepted"),null),successMessage:i,initialValues:{weight:"",length:"",width:"",height:""}});return(0,w.useEffect)(()=>{Object.keys(u).length&&m.formik.setValues(u)},[u]),(0,n.jsx)("div",{className:"mt-5 md:col-span-2 md:mt-0",children:(0,n.jsx)(P.A,{children:(0,n.jsxs)(V.A,{form:m,disabled:!d(l._r.ManageProducts),children:[(0,n.jsx)("div",{className:"relative px-4 py-5 sm:p-6",children:(0,n.jsxs)("div",{className:"grid grid-cols-6 gap-6",children:[(0,n.jsx)("div",{className:"col-span-6 sm:col-span-3",children:(0,n.jsx)(E.A,{validators:[(0,U.L6)()],type:"number",name:"weight",disabled:!d(l._r.ManageProducts),id:"weight",label:r({id:"weight_gram",defaultMessage:"Weight (Gram)"}),className:"text-sm"})}),(0,n.jsx)("div",{className:"col-span-6 sm:col-span-3",children:(0,n.jsx)(E.A,{validators:[(0,U.L6)()],name:"length",disabled:!d(l._r.ManageProducts),id:"length",type:"number",label:r({id:"length_millimeter",defaultMessage:"Length (Millimeter)"}),className:"text-sm"})}),(0,n.jsx)("div",{className:"col-span-6 sm:col-span-3",children:(0,n.jsx)(E.A,{validators:[(0,U.L6)()],type:"number",name:"width",disabled:!d(l._r.ManageProducts),id:"width ",label:r({id:"width",defaultMessage:"Width (Millimeter)"}),className:"text-sm "})}),(0,n.jsx)("div",{className:"col-span-6 sm:col-span-3",children:(0,n.jsx)(E.A,{validators:[(0,U.L6)()],name:"height",disabled:!d(l._r.ManageProducts),type:"number",id:"height",label:r({id:"height",defaultMessage:"Height (Millimeter)"}),className:"text-sm "})})]})}),d(l._r.ManageProducts)&&(0,n.jsx)("div",{className:"border-t-slate-100 border-t dark:border-t-slate-700 space-y-6 bg-slate-50 dark:bg-slate-900 text-right sm:p-6",children:(0,n.jsx)(q.A,{label:r({id:"save",defaultMessage:"Save"}),full:!0})})]})})})};var e2=a(28248);function e6(){let e=(0,L._)(["\n mutation CreateProductVariation(\n $productId: ID!\n $variation: CreateProductVariationInput!\n $texts: [ProductVariationTextInput!]\n ) {\n createProductVariation(\n productId: $productId\n variation: $variation\n texts: $texts\n ) {\n _id\n }\n }\n"]);return e6=function(){return e},e}let e4=(0,B.J1)(e6());function e8(){let e=(0,L._)(["\n fragment ProductVariationFragment on ProductVariation {\n _id\n type\n key\n texts(forceLocale: $locale) {\n _id\n locale\n title\n subtitle\n }\n options {\n _id\n texts(forceLocale: $locale) {\n _id\n locale\n title\n subtitle\n }\n value\n }\n }\n"]);return e8=function(){return e},e}let e3=(0,B.J1)(e8());function e9(){let e=(0,L._)(["\n query ProductVariations($productId: ID, $slug: String, $locale: Locale) {\n product(productId: $productId, slug: $slug) {\n _id\n ... on ConfigurableProduct {\n variations {\n ...ProductVariationFragment\n }\n }\n }\n }\n ","\n"]);return e9=function(){return e},e}let e7=(0,B.J1)(e9(),e3),te=function(){let{productId:e=null,slug:t=null,locale:a=null}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},n=(0,ev.id)(t),{data:s,loading:l,error:r}=(0,ef.I)(e7,{skip:!e&&!n,variables:{productId:e||n,locale:a}}),i=null==s?void 0:s.product;return{variations:null==i?void 0:i.variations,loading:l,error:r}};function tt(){let e=(0,L._)(['\n query ProductVariationType {\n variationTypes: __type(name: "ProductVariationType") {\n options: enumValues {\n value: name\n label: description\n }\n }\n }\n']);return tt=function(){return e},e}let ta=(0,B.J1)(tt()),tn=e=>{let{helpKey:t,helpText:a,helpValues:s,...l}=e;return(0,n.jsxs)("div",{className:"space-y-1",children:[(0,n.jsx)(E.A,{...l}),(t||a)&&(0,n.jsx)(el.A,{messageKey:t||"".concat(l.name,"_help"),defaultMessage:a,values:s,className:"mt-1"})]})};var ts=a(40841);function tl(){let e=(0,L._)(["\n mutation RemoveProductVariation($productVariationId: ID!) {\n removeProductVariation(productVariationId: $productVariationId) {\n _id\n }\n }\n"]);return tl=function(){return e},e}let tr=(0,B.J1)(tl());var ti=a(65284);function td(){let e=(0,L._)(["\n mutation UpdateProductVariationTexts(\n $productVariationId: ID!\n $productVariationOptionValue: String\n $texts: [ProductVariationTextInput!]!\n ) {\n updateProductVariationTexts(\n productVariationId: $productVariationId\n productVariationOptionValue: $productVariationOptionValue\n texts: $texts\n ) {\n _id\n }\n }\n"]);return td=function(){return e},e}let to=(0,B.J1)(td()),tu=()=>{let[e]=(0,Q.n)(to);return{updateProductVariationTexts:async t=>{let{productVariationId:a,productVariationOptionValue:n,texts:s}=t;return e({variables:{productVariationId:a,productVariationOptionValue:n,texts:s},refetchQueries:["ProductVariations"]})}}},tc=e=>{var t,a,l,r,i;let{variation:d,onCancel:o,onSuccess:u}=e,{updateProductVariationTexts:c}=tu(),{formatMessage:m}=(0,s.A)(),{selectedLocale:p}=(0,er.A)(),x=async e=>{let{title:t,subtitle:a}=e;return await c({productVariationId:d._id,texts:[{title:t,subtitle:a,locale:p}]}),u(),{success:!0}},g=(0,O.A)({submit:x,initialValues:{title:null!=(r=null==d||null==(t=d.texts)?void 0:t.title)?r:"",subtitle:null!=(i=null==d||null==(a=d.texts)?void 0:a.subtitle)?i:""}});return(0,n.jsx)(V.A,{form:g,className:"variation-update-form bg-white dark:bg-slate-800 px-4 py-3 border-b border-slate-200 dark:border-slate-700 w-full overflow-x-hidden overflow-y-visible relative hover:outline hover:outline-2 hover:outline-slate-400 dark:hover:outline-slate-500 transition-all","data-variationid":d._id,children:(0,n.jsxs)("div",{className:"flex items-center justify-between w-full gap-4",tabIndex:-1,children:[(0,n.jsxs)("div",{className:"flex items-center gap-4 flex-1 min-w-0 overflow-hidden flex-wrap",children:[(0,n.jsx)("div",{className:"flex-shrink-0 min-w-[180px]",children:(0,n.jsx)(E.A,{className:"mt-0 py-1",name:"title",required:!0,label:m({id:"title",defaultMessage:"Title"})})}),(null==d?void 0:d.type)&&(0,n.jsx)(ti.A,{text:d.type,color:"slate",className:"rounded-md uppercase text-xs font-medium flex-shrink-0"}),(0,n.jsx)("div",{className:"text-sm text-slate-500 dark:text-slate-400 truncate min-w-[200px]",children:(0,n.jsx)(E.A,{className:"mt-0 py-1",name:"subtitle",label:m({id:"subtitle",defaultMessage:"Subtitle"})})}),(null==d||null==(l=d.options)?void 0:l.length)>0&&(0,n.jsx)("div",{className:"flex items-center gap-2 flex-wrap",children:d.options.map((e,t)=>{var a;return(0,n.jsx)("span",{className:"inline-flex text-nowrap items-center px-2 py-0.5 rounded-lg text-xs font-medium bg-slate-100 dark:bg-slate-900 text-slate-800 dark:text-slate-200 border border-slate-200 dark:border-slate-800",children:(null==e||null==(a=e.texts)?void 0:a.title)||e.value},e.value||t)})}),(0,n.jsxs)("div",{className:"text-sm text-slate-400 dark:text-slate-500 font-mono flex-shrink-0",children:["(",null==d?void 0:d.key,")"]})]}),(0,n.jsxs)("div",{className:"flex space-x-2 flex-shrink-0",children:[(0,n.jsx)(F.A,{onClick:o,type:"button",variant:"secondary",size:"sm",text:m({id:"cancel",defaultMessage:"Cancel"})}),(0,n.jsx)(F.A,{onClick:()=>g.formik.submitForm(),type:"submit",variant:"primary",size:"sm",text:m({id:"save",defaultMessage:"Save"})})]})]})})};var tm=a(87483),tp=a(17657),tx=a(64113),tg=a(69013);let tf=e=>{var t,a,l,r;let{type:i,variation:d,onEdit:o,onDelete:u}=e,[c,m]=(0,w.useState)(!1),{formatMessage:p}=(0,s.A)(),{buttonRef:x,menuRef:g,menuPosition:f}=((e,t)=>{let a=(0,w.useRef)(null),n=(0,w.useRef)(null),[s,l]=(0,w.useState)({top:0,left:0});return(0,w.useEffect)(()=>{let e=e=>{a.current&&!a.current.contains(e.target)&&t(!1)};return document.addEventListener("mousedown",e),()=>document.removeEventListener("mousedown",e)},[t]),(0,w.useEffect)(()=>{if(e&&n.current){let e=n.current.getBoundingClientRect(),t=e.bottom+4,a=e.right-192;a<8&&(a=8),t+80>window.innerHeight-8&&(t=e.top-80-4),l({top:t,left:a})}},[e]),{buttonRef:n,menuRef:a,menuPosition:s}})(c,m);return(0,n.jsx)("div",{className:"variation-display bg-white dark:bg-slate-800 px-4 py-3 border-b border-slate-200 dark:border-slate-700 w-full overflow-x-hidden overflow-y-visible relative hover:outline hover:outline-2 hover:outline-slate-400 dark:hover:outline-slate-500 transition-all",children:(0,n.jsxs)("div",{className:"flex items-center justify-between w-full gap-4",tabIndex:-1,children:[(0,n.jsxs)("div",{className:"flex items-center gap-4 flex-1 min-w-0 overflow-hidden",children:[(0,n.jsx)("div",{className:"flex-shrink-0 text-lg font-semibold text-slate-900 dark:text-slate-200 truncate",children:null==d||null==(t=d.texts)?void 0:t.title}),i&&(0,n.jsx)(ti.A,{text:i,color:"slate",className:"rounded-md uppercase text-xs font-medium flex-shrink-0"}),(null==d||null==(a=d.texts)?void 0:a.subtitle)&&(0,n.jsx)("div",{className:"text-sm text-slate-500 dark:text-slate-400 truncate",children:null==d||null==(l=d.texts)?void 0:l.subtitle}),(null==d||null==(r=d.options)?void 0:r.length)>0&&(0,n.jsx)("div",{className:"flex items-center gap-2 flex-wrap",children:d.options.map((e,t)=>{var a;return(0,n.jsx)("span",{className:"inline-flex text-nowrap items-center px-2 py-0.5 rounded-lg text-xs font-medium bg-slate-100 dark:bg-slate-900 text-slate-800 dark:text-slate-200 border border-slate-200 dark:border-slate-800",children:(null==e||null==(a=e.texts)?void 0:a.title)||e.value},e.value||t)})}),(0,n.jsxs)("div",{className:"text-sm text-slate-400 dark:text-slate-500 font-mono flex-shrink-0",children:["(",null==d?void 0:d.key,")"]})]}),(0,n.jsxs)("div",{className:"relative flex-shrink-0",children:[(0,n.jsx)("button",{ref:x,type:"button",onClick:e=>{e.stopPropagation(),e.preventDefault(),m(e=>!e)},className:"flex items-center justify-center w-8 h-8 rounded-md hover:bg-slate-100 dark:hover:bg-slate-700 transition-colors",children:(0,n.jsx)(tm.A,{className:"w-5 h-5 text-slate-500 dark:text-slate-400"})}),c&&(0,n.jsx)(tp.A,{children:(0,n.jsx)("div",{ref:g,className:"fixed w-48 bg-white dark:bg-slate-800 rounded-md shadow-xl border border-slate-200 dark:border-slate-700 z-[9999]",style:{top:f.top,left:f.left,boxShadow:"0 10px 25px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05)"},children:(0,n.jsxs)("div",{className:"py-1",children:[(0,n.jsxs)("button",{type:"button",onClick:e=>{e.stopPropagation(),e.preventDefault(),o(),m(!1)},className:"flex items-center w-full px-4 py-2 text-sm text-slate-700 dark:text-slate-200 hover:bg-slate-100 dark:hover:bg-slate-700 transition-colors",children:[(0,n.jsx)(tx.A,{className:"mr-3 h-5 w-5"}),p({id:"edit",defaultMessage:"Edit"})]}),(0,n.jsxs)("button",{type:"button",onClick:e=>{e.stopPropagation(),e.preventDefault(),u(d._id),m(!1)},className:"flex items-center w-full px-4 py-2 text-sm text-rose-600 dark:text-rose-400 hover:bg-rose-50 dark:hover:bg-rose-900/20 transition-colors",children:[(0,n.jsx)(tg.A,{className:"mr-3 h-5 w-5"}),p({id:"delete",defaultMessage:"Delete"})]})]})})})]})]})})},tv=e=>{let{type:t,variation:a,onDelete:s}=e,[l,r]=(0,w.useState)(!1);return l?(0,n.jsx)(tc,{variation:a,onCancel:()=>r(!1),onSuccess:()=>r(!1)}):(0,n.jsx)(tf,{type:t,variation:a,onEdit:()=>r(!0),onDelete:s})};function th(){let e=(0,L._)(["\n mutation CreateProductVariationOption(\n $productVariationId: ID!\n $option: String!\n $texts: [ProductVariationTextInput!]\n ) {\n createProductVariationOption(\n productVariationId: $productVariationId\n option: $option\n texts: $texts\n ) {\n _id\n }\n }\n"]);return th=function(){return e},e}let tb=(0,B.J1)(th());function tj(){let e=(0,L._)(["\n mutation RemoveProductVariationOption(\n $productVariationId: ID!\n $productVariationOptionValue: String!\n ) {\n removeProductVariationOption(\n productVariationId: $productVariationId\n productVariationOptionValue: $productVariationOptionValue\n ) {\n _id\n }\n }\n"]);return tj=function(){return e},e}let ty=(0,B.J1)(tj()),t_=e=>{let{onSubmit:t}=e,{formatMessage:a}=(0,s.A)(),{hasRole:r}=(0,A.A)(),i=a({id:"variation_option_added",defaultMessage:"Variation option added successfully!"}),d=(0,O.A)({submit:t,successMessage:i,initialValues:{value:"",title:""}});return(0,n.jsxs)(V.A,{form:d,className:"variation-option-form relative overflow-visible",children:[(0,n.jsx)("div",{className:"mb-4 px-2 sm:px-4 pt-2",children:(0,n.jsx)("div",{className:"p-3 bg-slate-50 dark:bg-slate-900/20 rounded-lg border border-slate-200 dark:border-slate-800",children:(0,n.jsx)("p",{className:"text-sm text-slate-800 dark:text-slate-200",children:a({id:"variation_options_explanation",defaultMessage:'Add individual choices for this variation (e.g., "Red", "Blue", "Green" for a Color variation)'})})})}),(0,n.jsxs)("div",{className:"grid lg:grid-cols-2 gap-3 px-2 sm:px-4 sm:pb-4",children:[(0,n.jsx)("div",{className:"col-span-1",children:(0,n.jsx)(tn,{className:"mt-2 pt-1",name:"title",label:a({id:"title",defaultMessage:"Title"}),helpText:a({id:"variation_option_title_help",defaultMessage:'Display name customers see (e.g., "Red", "Large", "Cotton")'}),required:!0})}),(0,n.jsx)("div",{className:"col-span-1",children:(0,n.jsx)(tn,{className:"mt-2 pt-1",name:"value",label:a({id:"value",defaultMessage:"Value"}),helpText:a({id:"variation_option_value_help",defaultMessage:'Internal identifier (e.g., "red", "large", "cotton")'}),required:!0})})]}),r(l._r.ManageProducts)&&(0,n.jsx)("div",{className:"text-right mt-2 px-6 pb-6",children:(0,n.jsx)(q.A,{className:"py-2.5",label:a({id:"add_variation_option",defaultMessage:"Add option"})})})]})};var tw=a(12067);let tN=e=>{var t,a,l,r;let{option:i,onDelete:d,variationId:o}=e,{formatMessage:u}=(0,s.A)(),{selectedLocale:c}=(0,er.A)(),[m,p]=(0,w.useState)(!1),x=u({id:"variation_option_updated",defaultMessage:"Variation option updated successfully!"}),{updateProductVariationTexts:g}=tu(),f=async e=>{let{title:t,subtitle:a}=e,n=await g({productVariationId:o,productVariationOptionValue:i.value,texts:[{title:t,subtitle:a,locale:c}]});return p(!1),{data:n,success:!0}},v=(0,O.A)({submit:f,successMessage:x,initialValues:{title:null==i||null==(t=i.texts)?void 0:t.title,subtitle:null==i||null==(a=i.texts)?void 0:a.subtitle}});return(0,n.jsx)(V.A,{form:v,className:"last:pb-2 variation-option-update-form relative overflow-visible",children:(0,n.jsx)("div",{className:"my-2 rounded-sm border dark:border-slate-700 mx-4 ",children:(0,n.jsx)("div",{className:"p-2 bg-white dark:bg-slate-900 dark:text-slate-200",children:(0,n.jsxs)("div",{className:"flex gap-2 w-full items-center justify-between",children:[(0,n.jsx)(ti.A,{text:null==i?void 0:i.value,color:"slate",className:"rounded-md"}),(0,n.jsxs)("div",{className:"flex items-center gap-4 w-full",children:[(0,n.jsx)("p",{className:"truncate text-sm font-medium text-slate-900 dark:text-slate-400",children:m?(0,n.jsx)(E.A,{className:"mt-0",name:"title",required:!0,label:u({id:"title",defaultMessage:"Title"})}):null==i||null==(l=i.texts)?void 0:l.title}),(0,n.jsx)("p",{className:"truncate text-sm text-slate-500",children:m?(0,n.jsx)(E.A,{className:"mt-0",name:"subtitle",label:u({id:"subtitle",defaultMessage:"Subtitle"})}):null==i||null==(r=i.texts)?void 0:r.subtitle})]}),(0,n.jsx)("div",{className:"flex items-center justify-end ml-auto",children:m?(0,n.jsxs)("div",{className:"flex space-x-2 py-2",children:[(0,n.jsx)("button",{onClick:()=>p(!m),"aria-label":u({id:"cancel",defaultMessage:"Cancel"}),type:"button",className:"inline-flex items-center justify-center font-medium shadow-sm focus:outline-hidden focus:ring-2 focus:ring-offset-2 transition-colors duration-200 disabled:cursor-not-allowed disabled:opacity-50 px-3 py-2 text-sm h-8 rounded-md border border-slate-300 dark:border-slate-600 bg-white dark:bg-slate-800 text-slate-700 dark:text-slate-200 hover:bg-slate-50 dark:hover:bg-slate-700 focus:ring-slate-500",children:u({id:"cancel",defaultMessage:"Cancel"})}),(0,n.jsx)("button",{type:"submit","aria-label":u({id:"save",defaultMessage:"Save"}),className:"inline-flex items-center justify-center font-medium shadow-sm focus:outline-hidden focus:ring-2 focus:ring-offset-2 transition-colors duration-200 disabled:cursor-not-allowed disabled:opacity-50 px-3 py-2 text-sm h-8 rounded-md border border-slate-800 dark:border-slate-600 bg-slate-800 dark:bg-slate-600 text-white hover:bg-slate-900 dark:hover:bg-slate-500 focus:ring-slate-800 dark:focus:ring-slate-400",children:u({id:"save",defaultMessage:"Save"})})]}):(0,n.jsx)(tw.A,{onEdit:()=>{p(!0)},onDelete:()=>{d(i.value)},showEdit:!0,showDelete:!0})})]})})})})},tA=e=>{let{variationId:t,options:a}=e,{createProductVariationOption:l}=(()=>{let[e]=(0,Q.n)(tb);return{createProductVariationOption:async t=>{let{productVariationId:a,option:n,texts:s}=t;return e({variables:{productVariationId:a,option:n,texts:s},refetchQueries:["ProductVariations","Product"]})}}})(),{formatMessage:i}=(0,s.A)(),{selectedLocale:d}=(0,er.A)(),{setModal:o}=(0,eV.A)(),{removeProductVariationOption:u}=(()=>{let[e]=(0,Q.n)(ty);return{removeProductVariationOption:async t=>{let{productVariationId:a,productVariationOptionValue:n}=t;return e({variables:{productVariationId:a,productVariationOptionValue:n},refetchQueries:["ProductVariations"]})}}})(),c=async e=>{await o((0,n.jsx)(e$.A,{message:i({id:"delete_variation_option_confirmation",defaultMessage:"This action might cause inconsistencies with other data that relates to it. Are you sure you want to delete this option? "}),onCancelClick:()=>o(""),onOkClick:async()=>{o(""),await u({productVariationId:t,productVariationOptionValue:e}),r.oR.success(i({id:"product_variation_option_deleted",defaultMessage:"Variation option deleted successfully"}))},okText:i({id:"delete_variation_option",defaultMessage:"Delete option"})}))},m=async e=>{let{value:a,title:n}=e;return await l({productVariationId:t,option:a,texts:[{title:n,locale:d}]}),{success:!0}};return(0,n.jsxs)("div",{className:"relative overflow-visible",children:[(0,n.jsx)(t_,{onSubmit:m}),a.length?a.map(e=>(0,n.jsx)(tN,{variationId:t,option:e,onDelete:c},e._id)):(0,n.jsx)(ew.A,{message:i({id:"option",defaultMessage:"Option"})})]})},tP=e=>{let{productVariationId:t,variation:a}=e,{formatMessage:l}=(0,s.A)(),{setModal:i}=(0,eV.A)(),{options:d}=a,{removeProductVariation:o}=(()=>{let[e]=(0,Q.n)(tr);return{removeProductVariation:async t=>{let{productVariationId:a}=t;return e({variables:{productVariationId:a},refetchQueries:["ProductVariations"]})}}})(),u=async()=>{await i((0,n.jsx)(e$.A,{onCancelClick:async()=>i(""),message:l({id:"delete_product_variation_confirmation",defaultMessage:"This action might cause inconsistencies with other data that relates to it. Are you sure you want to delete this variation? "}),onOkClick:async()=>{i(""),await o({productVariationId:t}),r.oR.success(l({id:"product_variation_deleted",defaultMessage:"Variation deleted successfully"}))},okText:l({id:"delete_product_variation",defaultMessage:"Delete variation"})}))},c=[{header:(0,n.jsx)(tv,{onDelete:u,variation:a,...a}),body:(0,n.jsx)(tA,{variationId:a._id,options:d},t)}];return(0,n.jsx)(ts.A,{"data-variationid":a._id,data:c,containerCSS:"w-full max-w-full !my-0 !border-0 !shadow-none relative",bodyCSS:"bg-slate-50 dark:bg-slate-950 !border-t-0 relative overflow-visible",itemContainerCSS:"!mt-0 !mb-0 !border-0",headerCSS:"w-full flex items-center justify-between !p-0 !bg-transparent !border-0",hideChevron:!0})},tk=e=>{let{onSubmit:t,disabled:a,formatMessage:s}=e,{variationTypes:r}=(()=>{var e;let{data:t,loading:a,error:n}=(0,ef.I)(ta);return{variationTypes:(null==t||null==(e=t.variationTypes)?void 0:e.options)||[],loading:a,error:n}})(),{hasRole:i}=(0,A.A)(),d=s({id:"product_variation_added",defaultMessage:"Product variation added successfully"}),o=(0,O.A)({disabled:a,submit:t,successMessage:d,initialValues:{title:"",key:"",type:""}});return(0,n.jsxs)("div",{children:[(0,n.jsxs)("div",{className:"mb-6",children:[(0,n.jsx)("h3",{className:"text-lg font-semibold text-slate-900 dark:text-slate-100 mb-2",children:s({id:"product_variations_explanation_title",defaultMessage:"About Product Variations"})}),(0,n.jsx)("p",{className:"text-sm text-slate-600 dark:text-slate-400",children:s({id:"product_variations_explanation",defaultMessage:"Variations allow customers to choose different options for your product (like color, size, material). Each variation can have multiple options that customers can select from."})})]}),(0,n.jsxs)(V.A,{form:o,children:[(0,n.jsxs)("div",{className:"space-y-6",children:[(0,n.jsx)(tn,{name:"title",id:"title",label:s({id:"title",defaultMessage:"Title"}),helpText:s({id:"product_variation_title_help",defaultMessage:'The display name customers will see (e.g., "Color", "Size", "Material")'}),required:!0,autoComplete:"on",className:"w-full"}),(0,n.jsx)(tn,{name:"key",id:"key",label:s({id:"key",defaultMessage:"Key"}),helpText:s({id:"product_variation_key_help",defaultMessage:'Unique identifier used internally (e.g., "color", "size"). Use lowercase without spaces.'}),required:!0,autoComplete:"on",className:"w-full"}),(0,n.jsxs)("div",{children:[(0,n.jsx)(R.A,{required:!0,className:"w-full",label:s({id:"type",defaultMessage:"Type"}),placeholder:s({id:"type",defaultMessage:"Type"}),name:"type",options:(0,k.A)(r,"value","value")}),(0,n.jsx)(el.A,{messageKey:"product_variation_type_help",defaultMessage:"COLOR: For predefined options like colors or sizes. TEXT: For free-form input like custom text or measurements.",className:"mt-1"})]})]}),i(l._r.ManageProducts)&&(0,n.jsx)("div",{className:"flex justify-end mt-6 py-6 -mb-6 bg-slate-100 -mx-6 pe-5 border-t border-slate-200 dark:border-slate-700 bg-slate-50 dark:bg-slate-900",children:(0,n.jsx)(q.A,{label:s({id:"add_variation",defaultMessage:"Add variation"})})})]})]})},tM=e=>{let{productId:t,disabled:a=!1}=e,{createProductVariation:l}=(()=>{let[e]=(0,Q.n)(e4);return{createProductVariation:async t=>{let{productId:a,variation:{key:n,type:s},texts:l}=t;return e({variables:{productId:a,variation:{key:n,type:s},texts:l},refetchQueries:["ProductVariations"]})}}})(),{selectedLocale:r}=(0,er.A)(),{formatMessage:i}=(0,s.A)(),{setModal:o}=(0,eV.A)(),{variations:u,loading:c}=te({productId:t,locale:r}),m=async e=>{let{title:a,key:n,type:s}=e;return await l({productId:t,variation:{key:n,type:s},texts:[{title:a,locale:r}]}),o(""),{success:!0}};return c?(0,n.jsx)(d.A,{}):(0,n.jsxs)("div",{className:"mt-6 overflow-hidden rounded-md w-full max-w-full",children:[(0,n.jsx)("div",{className:"mb-6 flex justify-end items-center",children:(0,n.jsx)(F.A,{className:"m-1",onClick:()=>{o((0,n.jsx)(tk,{onSubmit:m,disabled:a,formatMessage:i}))},disabled:a,variant:"secondary",icon:(0,n.jsx)(e2.A,{className:"w-5 h-5"}),text:i({id:"add_variation",defaultMessage:"Add variation"})})}),(0,n.jsx)("div",{className:"flex flex-col border border-slate-200 dark:border-slate-700 rounded-md overflow-x-hidden overflow-y-visible w-full relative",children:(null==u?void 0:u.length)?null==u?void 0:u.map(e=>(0,n.jsx)(tP,{productVariationId:e._id,variation:e},e._id)):(0,n.jsx)(ew.A,{message:i({id:"variations",defaultMessage:"Variations"})})})]})};function tI(){let e=(0,L._)(["\n query ProductWarehousing($productId: ID, $slug: String) {\n product(productId: $productId, slug: $slug) {\n _id\n ... on SimpleProduct {\n sku\n baseUnit\n }\n }\n }\n"]);return tI=function(){return e},e}let tC=(0,B.J1)(tI()),t$=function(){let{productId:e=null,slug:t=null}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},a=(0,ev.id)(t),{data:n,loading:s,error:l}=(0,ef.I)(tC,{skip:!e&&!a,variables:{productId:e||a}});return{product:(null==n?void 0:n.product)||{},loading:s,error:l}};function tS(){let e=(0,L._)(["\n mutation UpdateProductWarehousing(\n $productId: ID!\n $warehousing: UpdateProductWarehousingInput!\n ) {\n updateProductWarehousing(productId: $productId, warehousing: $warehousing) {\n _id\n ... on SimpleProduct {\n sku\n baseUnit\n }\n }\n }\n"]);return tS=function(){return e},e}let tT=(0,B.J1)(tS()),tV=e=>{let{productId:t,disabled:a=!1}=e,{formatMessage:r}=(0,s.A)(),{product:i}=t$({productId:t}),{hasRole:d}=(0,A.A)(),{updateProductWarehousing:o}=(()=>{let[e]=(0,Q.n)(tT);return{updateProductWarehousing:async t=>{let{productId:a,warehousing:{sku:n=null,baseUnit:s=null}}=t;return e({variables:{productId:a,warehousing:{sku:n,baseUnit:s}},refetchQueries:["Products"]})}}})(),u=r({id:"saved",defaultMessage:"Saved"}),c=async e=>{let{sku:a,baseUnit:n}=e;return{data:await o({productId:t,warehousing:{baseUnit:n,sku:a}}),success:!0}},m=(0,O.A)({disabled:a,submit:c,successMessage:u,initialValues:{sku:"",baseUnit:""}});return(0,w.useEffect)(()=>{Object.keys(i).length&&m.formik.setValues({...i})},[i]),(0,n.jsx)("div",{className:"mt-5 md:mt-0",children:(0,n.jsx)(P.A,{children:(0,n.jsxs)(V.A,{className:"rounded",form:m,disabled:!d(l._r.ManageProducts),children:[(0,n.jsx)("div",{className:"relative px-4 pb-5 sm:p-6",children:(0,n.jsxs)("div",{className:"w-full justify-between align-baseline lg:flex gap-6",children:[(0,n.jsx)(E.A,{name:"sku",disabled:!d(l._r.ManageProducts),id:"sku",label:r({id:"sku",defaultMessage:"SKU"}),className:"mb-4 text-sm"}),(0,n.jsx)(E.A,{name:"baseUnit",id:"baseUnit",disabled:!d(l._r.ManageProducts),label:r({id:"baseUnit",defaultMessage:"Base Unit"}),className:"text-sm"})]})}),d(l._r.ManageProducts)&&(0,n.jsx)("div",{className:"border-t-slate-100 border-t dark:border-t-slate-700 space-y-6 bg-slate-50 dark:bg-slate-900 text-right sm:p-6",children:(0,n.jsx)(q.A,{label:r({id:"save",defaultMessage:"Save"})})})]})})})};var tD=a(2060),tR=a(55873);function tq(){let e=(0,L._)(["\n query ProductReviewByProduct(\n $productId: ID\n $slug: String\n $limit: Int\n $offset: Int\n $sort: [SortOptionInput!]\n ) {\n product(productId: $productId, slug: $slug) {\n _id\n reviews(limit: $limit, offset: $offset, sort: $sort) {\n ...ProductReviewDetailFragment\n }\n reviewsCount\n }\n }\n ","\n"]);return tq=function(){return e},e}let tE=(0,B.J1)(tq(),tR.A),tF=function(){let{productId:e=null,slug:t=null,limit:a=10,offset:n=0,sort:s=[{key:"created",value:l.t4.Desc}]}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},{data:r,loading:i,error:d,fetchMore:o}=(0,ef.I)(tE,{skip:!e,variables:{productId:e,slug:t,limit:a,offset:n,sort:s}}),u=null==r?void 0:r.product,c=(null==u?void 0:u.reviews)||[];return{productReviews:c,loading:i,error:d,reviewsCount:(null==u?void 0:u.reviewsCount)||0,loadMore:()=>{o({variables:{offset:null==c?void 0:c.length}})}}};var tO=a(99380),tU=a(26512),tJ=a(94129),tL=a(43419);let tB=e=>{let{productReviews:t}=e,{formatMessage:a}=(0,s.A)(),l=t.reduce((e,t)=>e+t.upVote,0),r=t.reduce((e,t)=>e+t.downVote,0),i=l?l/(l+r)*100:0,d=i?100-i:0;return(0,n.jsxs)("div",{className:"lg:col-span-4",children:[(0,n.jsx)("h2",{className:"text-2xl",children:a({id:"customer_reviews",defaultMessage:"Customer Reviews"})}),(0,n.jsxs)("div",{className:"mt-3 flex items-center",children:[(0,n.jsx)("div",{children:(0,n.jsx)("div",{title:"".concat(i),className:"flex items-center",children:[0,1,2,3,4].map(e=>{let t=i>=20*e;return(0,n.jsx)(tL.A,{className:"\n ".concat(t?"text-amber-400":"text-slate-300 dark:text-slate-600","\n h-5 w-5 shrink-0\n "),"aria-hidden":"true"},e)})})}),(0,n.jsx)("div",{className:"ml-2 text-sm",children:(0,n.jsx)(X.A,{id:"review_summary",defaultMessage:"<div> Based on <cta> {total} </cta> reviews</div>",values:{div:e=>(0,n.jsx)("div",{children:e}),cta:e=>(0,n.jsx)("b",{className:"font-semibold",children:e}),total:t.length}})})]}),(0,n.jsxs)("div",{className:"mt-6",children:[(0,n.jsx)("h3",{className:"sr-only",children:a({id:"review_data",defaultMessage:"Review data"})}),(0,n.jsxs)("dl",{className:"space-y-3",children:[(0,n.jsxs)("div",{className:"flex items-center text-sm",children:[(0,n.jsxs)("dt",{className:"flex flex-1 items-center",children:[(0,n.jsx)("p",{className:"font-medium",children:l}),(0,n.jsxs)("div",{"aria-hidden":"true",className:"ml-2 flex flex-1 items-center",children:[(0,n.jsx)(tU.A,{className:"\n ".concat(l>0?"text-emerald-500":"text-slate-500","\n h-5 w-5 shrink-0"),"aria-hidden":"true"}),(0,n.jsxs)("div",{className:"relative ml-3 flex-1",children:[(0,n.jsx)("div",{className:"h-3 rounded-full border border-slate-300 dark:border-slate-800 bg-slate-50 dark:bg-slate-900"}),l>0?(0,n.jsx)("div",{className:"absolute inset-y-0 rounded-full border border-emerald-500 bg-emerald-500",style:{width:"calc(".concat(i,"%)")}}):null]})]})]}),(0,n.jsxs)("dd",{className:"ml-3 w-10 text-right text-sm tabular-nums",children:[Math.round(i),"%"]})]}),(0,n.jsxs)("div",{className:"flex items-center text-sm",children:[(0,n.jsxs)("dt",{className:"flex flex-1 items-center",children:[(0,n.jsxs)("p",{className:"font-medium",children:[r,(0,n.jsx)("span",{className:"sr-only",children:a({id:"star_reviews",defaultMessage:"Star reviews"})})]}),(0,n.jsxs)("div",{"aria-hidden":"true",className:"ml-2 flex flex-1 items-center",children:[(0,n.jsx)(tJ.A,{className:"\n ".concat(r>0?"text-rose-500":"text-slate-500","\n h-5 w-5 shrink-0\n "),"aria-hidden":"true"}),(0,n.jsxs)("div",{className:"relative ml-3 flex-1",children:[(0,n.jsx)("div",{className:"h-3 rounded-full border border-slate-300 dark:border-slate-800 bg-slate-50 dark:bg-slate-900"}),r>0?(0,n.jsx)("div",{className:"absolute inset-y-0 rounded-full border border-rose-500 bg-rose-500",style:{width:"calc(".concat(d,"%)")}}):null]})]})]}),(0,n.jsxs)("dd",{className:"ml-3 w-10 text-right text-sm tabular-nums",children:[Math.round(d),"%"]})]})]})]})]})};var tQ=a(90689);let tz=e=>{let{onSubmit:t,onSubmitSuccess:a=null,defaultValue:r={},isEdit:i=!1}=e,{formatMessage:d}=(0,s.A)(),{hasRole:o}=(0,A.A)(),u=d({id:"product_review_added",defaultMessage:"Review added successfully!"}),c=d({id:"product_review_updated",defaultMessage:"Review updated successfully!"}),m=(0,O.A)({submit:t,onSubmitSuccess:a,successMessage:i?c:u,initialValues:{title:"",review:"",rating:1,...r}});return(0,n.jsxs)("div",{className:"bg-white dark:bg-slate-800 rounded-md shadow-sm overflow-hidden p-6 mb-6",children:[(0,n.jsx)("h3",{className:"text-lg font-semibold text-slate-900 dark:text-slate-100 mb-4",children:d({id:"write_review",defaultMessage:"Write a Review"})}),(0,n.jsxs)(V.A,{form:m,children:[(0,n.jsxs)("div",{className:"space-y-4",children:[(0,n.jsx)(E.A,{name:"title",disabled:!o(l._r.ReviewProduct),id:"title",label:d({id:"title",defaultMessage:"Title"}),autoComplete:"off",required:!0}),(0,n.jsx)(tQ.A,{rows:4,name:"review",disabled:!o(l._r.ReviewProduct),id:"review",label:d({id:"review",defaultMessage:"Review"}),placeholder:d({id:"review_placeholder",defaultMessage:"Share your thoughts about this product..."})})]}),o(l._r.ReviewProduct)&&(0,n.jsx)("div",{className:"mt-6 flex justify-end",children:(0,n.jsx)(q.A,{label:d(i?{id:"update_review",defaultMessage:"Update Review"}:{id:"add_review",defaultMessage:"Add Review"}),className:"px-6 py-2"})})]})]})};function tW(){let e=(0,L._)(["\n mutation CreateProductReview(\n $productId: ID!\n $productReview: ProductReviewInput!\n ) {\n createProductReview(productId: $productId, productReview: $productReview) {\n ...ProductReviewDetailFragment\n }\n }\n ","\n"]);return tW=function(){return e},e}let tK=(0,B.J1)(tW(),tR.A),tG=e=>{let{productId:t}=e,{productReviews:a,loadMore:l,reviewsCount:r}=tF({productId:t}),{createProductReview:i}=(()=>{let[e]=(0,Q.n)(tK);return{createProductReview:async t=>{let{productId:a,productReview:{title:n,rating:s,review:l}}=t;return e({variables:{productId:a,productReview:{title:n,rating:s,review:l}},refetchQueries:["ProductReviewByProduct","ProductReviewByUser"]})}}})(),{formatMessage:d}=(0,s.A)();return(0,n.jsxs)("div",{className:"sm:max-w-full",children:[(0,n.jsx)("div",{className:"text-slate-900 dark:text-slate-200",children:(0,n.jsxs)("div",{className:"mx-auto p-2 lg:grid lg:max-w-7xl lg:grid-cols-12 lg:gap-x-8",children:[(0,n.jsx)(tB,{productReviews:a}),(0,n.jsxs)("div",{className:"mt-16 lg:col-span-7 lg:col-start-6 lg:mt-0",children:[t&&(0,n.jsx)(tz,{onSubmit:async e=>{let{title:a,review:n,rating:s}=e;return await i({productId:t,productReview:{title:a,review:n,rating:10}})}}),(0,n.jsx)("h3",{className:"sr-only",children:d({id:"recent_reviews",defaultMessage:"Recent reviews"})}),(0,n.jsx)("div",{className:"flow-root",children:(0,n.jsx)("div",{className:"-my-3",children:a.map(e=>(0,n.jsx)(tO.A,{review:e},e._id))})})]})]})}),r>(null==a?void 0:a.length)?(0,n.jsx)(F.A,{text:d({id:"load-more-reviews",defaultMessage:"Load reviews"}),onClick:l}):null]})};var tH=a(26274);function tX(){let e=(0,L._)(["\n mutation CreateProductBundleItem(\n $productId: ID!\n $item: CreateProductBundleItemInput!\n ) {\n createProductBundleItem(productId: $productId, item: $item) {\n _id\n }\n }\n"]);return tX=function(){return e},e}let tZ=(0,B.J1)(tX());var tY=a(52536),t0=a(73018),t1=a(24984),t5=a(51599);let t2=function(e){let{onSuccess:t}=e,{selectedLocale:a}=(0,er.A)(),{createProduct:n}=(0,t5.A)(),{formatMessage:l}=(0,s.A)();return async e=>{let{title:s,type:r,quantity:i=1}=e,d=[{title:s,slug:s.toLowerCase().replace(/\s+/g,"-"),locale:a}],{data:o}=await n({product:{type:r||t1.W.SimpleProduct},texts:d}),u=null==o?void 0:o.createProduct;if(!(null==u?void 0:u._id))throw Error(l({id:"product_creation_failed",defaultMessage:"Product creation failed"}));return null==t||t(u,i),{success:!0}}},t6=e=>{let{bundleProduct:t,onSuccess:a}=e,{formatMessage:r}=(0,s.A)(),{hasRole:i}=(0,A.A)(),d=t2({onSuccess:a}),o=(0,w.useMemo)(()=>{var e,a;let n=null!=(a=null==t||null==(e=t.texts)?void 0:e.title)?a:"";return"".concat(n," - New Bundle Item")},[t]),u=async e=>{let{title:t,type:a,quantity:n}=e;try{return await d({title:t,type:a,quantity:n}),{success:!0}}catch(e){return{success:!1,error:{message:null==e?void 0:e.message}}}},c=r({id:"bundle-item-scaffolded-success",defaultMessage:"New product scaffolded and added to bundle successfully"}),m=(0,O.A)({submit:u,successMessage:c,enableReinitialize:!0,initialValues:{title:o,type:t1.W.SimpleProduct,quantity:1}});return(0,n.jsxs)(V.A,{className:"mt-4 rounded-md border border-slate-200 dark:border-slate-700",form:m,children:[(0,n.jsxs)("div",{className:"p-5 flex flex-col gap-3",children:[(0,n.jsx)("h3",{className:"text-md font-semibold text-slate-800 dark:text-slate-100",children:r({id:"scaffold_bundle_item_title",defaultMessage:"Scaffold New Bundle Item"})}),(0,n.jsx)(E.A,{name:"title",id:"title",label:r({id:"name",defaultMessage:"Name"}),required:!0,className:"block w-full rounded-md border-slate-300 dark:border-slate-800 text-sm"}),(0,n.jsx)(R.A,{className:"mt-1 w-full",label:r({id:"type",defaultMessage:"Type"}),placeholder:r({id:"type",defaultMessage:"Type"}),required:!0,name:"type",options:Object.fromEntries(Object.entries(t1.W).filter(e=>{let[,t]=e;return t!==t1.W.ConfigurableProduct&&t!==t1.W.BundleProduct}))}),(0,n.jsx)(E.A,{name:"quantity",type:"number",required:!0,label:r({id:"quantity",defaultMessage:"Quantity"})})]}),i(l._r.ManageProducts)&&(0,n.jsx)("div",{className:"border-t border-slate-100 dark:border-slate-700 bg-slate-50 dark:bg-slate-900 p-5 text-right",children:(0,n.jsx)(q.A,{label:r({id:"scaffold_and_add",defaultMessage:"Scaffold & Add"})})})]})};var t4=a(23416);function t8(){let e=(0,L._)(["\n query Product($productId: ID, $slug: String) {\n product(productId: $productId, slug: $slug) {\n ...ProductDetailFragment\n ","\n texts {\n _id\n title\n subtitle\n description\n }\n ... on SimpleProduct {\n texts {\n _id\n title\n subtitle\n description\n }\n proxies {\n __typename\n }\n }\n ... on ConfigurableProduct {\n texts {\n _id\n title\n subtitle\n description\n }\n }\n ... on PlanProduct {\n texts {\n _id\n title\n subtitle\n description\n }\n proxies {\n __typename\n }\n }\n ... on BundleProduct {\n texts {\n _id\n title\n subtitle\n description\n }\n proxies {\n __typename\n }\n }\n }\n }\n ","\n"]);return t8=function(){return e},e}let t3=function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"";return(0,B.J1)(t8(),e,z.A)},t9=function(){let{productId:e=null,slug:t=null}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},a=(0,ev.id)(t),{customProperties:n,hydrateFragment:s}=(0,t4.A)(),{data:l,loading:r,error:i}=(0,ef.I)(t3(null==n?void 0:n.Product),{skip:!e&&!a,variables:{productId:e||a}}),d=s(null==n?void 0:n.Product,null==l?void 0:l.product);return{product:null==l?void 0:l.product,loading:r,error:i,extendedData:d}},t7=function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[];return e.map(e=>{var t,a;let{_id:n,status:s,texts:l,media:r}=e;return{id:n,tag:s,...l,image:(null==r?void 0:r.length)?null==(a=r[0])||null==(t=a.file)?void 0:t.url:null}})},ae=e=>{let{productId:t,disabled:a=!1}=e,{product:r}=t9({productId:t}),{setModal:i}=(0,eV.A)(),[d,o]=(0,w.useState)(""),{createProductBundleItem:u}=(()=>{let[e]=(0,Q.n)(tZ);return{createProductBundleItem:async t=>{let{productId:a,item:n}=t;return e({variables:{productId:a,item:n},refetchQueries:["ProductBundleItems"]})}}})(),{hasRole:c}=(0,A.A)(),{formatMessage:m}=(0,s.A)(),{products:p,loading:x}=(0,tY.A)({queryString:d,includeDrafts:!0,limit:50,sort:[{key:"created",value:l.t4.Desc}]}),g=async e=>{let{productId:a,quantity:n}=e;return await u({item:{productId:a,quantity:n},productId:t}),{success:!0}},f=m({id:"bundle_item_added",defaultMessage:"Bundle product added successfully"}),v=(0,O.A)({disabled:a,submit:g,successMessage:f,onSubmitSuccess:()=>(v.formik.resetForm(),null),initialValues:{productId:"",quantity:1}}),h=(0,w.useCallback)(async()=>{await i((0,n.jsx)(t6,{bundleProduct:r,onSuccess:async function(e){let a=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1;await u({item:{productId:e._id,quantity:a},productId:t}),i("")}}))},[r]);return(0,n.jsxs)(V.A,{form:v,children:[(0,n.jsxs)("div",{className:"flex items-end gap-2 w-full",children:[(0,n.jsx)("div",{className:"flex-1",children:(0,n.jsx)(tH.A,{name:"productId",onFilter:o,queryString:d,label:m({id:"product",defaultMessage:"Product"}),data:t7(p),isLoading:x,className:"w-full text-sm font-medium text-slate-500",required:!0})}),c(l._r.ManageProducts)&&(0,n.jsx)("div",{className:"pb-3",children:(0,n.jsx)(F.A,{className:"flex items-center justify-center p-2 rounded-md",onClick:h,children:(0,n.jsx)(t0.A,{className:"h-5 w-5"})})})]}),(0,n.jsx)(E.A,{name:"quantity",type:"number",required:!0,label:m({id:"quantity",defaultMessage:"Quantity"})}),c(l._r.ManageProducts)&&(0,n.jsx)(q.A,{label:m({id:"submit",defaultMessage:"Submit"}),className:"mt-2"})]})};var at=a(41623);function aa(){let e=(0,L._)(["\n query ProductBundleItems($productId: ID, $slug: String) {\n product(productId: $productId, slug: $slug) {\n _id\n ... on BundleProduct {\n bundleItems {\n product {\n ...ProductBriefFragment\n }\n quantity\n }\n }\n }\n }\n ","\n"]);return aa=function(){return e},e}let an=(0,B.J1)(aa(),at.A),as=function(){var e;let{productId:t=null,slug:a=null}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},n=(0,ev.id)(a),{data:s,loading:l,error:r}=(0,ef.I)(an,{skip:!t&&!n,variables:{productId:t||n}});return{bundleItems:(null==s||null==(e=s.product)?void 0:e.bundleItems)||[],loading:l,error:r}};function al(){let e=(0,L._)(["\n mutation RemoveBundleItem($productId: ID!, $index: Int!) {\n removeBundleItem(productId: $productId, index: $index) {\n _id\n }\n }\n"]);return al=function(){return e},e}let ar=(0,B.J1)(al());var ai=a(65990),ad=a(35429);let ao=e=>{var t,a,s,l,r,i,d;let{item:o,onDelete:u,index:c}=e,{product:m,quantity:p}=o;return(0,n.jsxs)("div",{className:"group flex w-full items-center justify-between border-b border-slate-200 dark:border-slate-700 hover:border-slate-300 dark:hover:border-slate-600 hover:bg-slate-50/80 dark:hover:bg-slate-700/50 transition-all duration-200 ease-in-out hover:shadow-sm last:border-none",children:[(0,n.jsxs)("div",{className:"flex w-full items-center space-x-6 py-4",children:[(null==(t=m.media)?void 0:t.length)?(0,n.jsx)("div",{className:"flex w-20 flex-col items-center",children:(0,n.jsx)("div",{className:"relative m-1 mr-2 mt-1 flex items-center justify-center rounded-full ",children:(0,n.jsx)(ai.A,{className:"mx-auto w-auto",src:null==(s=m.media[0])||null==(a=s.file)?void 0:a.url,width:160,height:100,alt:(null==m||null==(l=m.texts)?void 0:l.title)||(null==m||null==(r=m.texts)?void 0:r.subtitle)})})}):(0,n.jsx)(ad.A,{className:"h-10 w-10"}),(0,n.jsxs)("div",{className:"shrink grow basis-1/2",children:[(0,n.jsx)("h3",{className:"text-lg text-slate-800 dark:text-slate-200",children:null==m||null==(i=m.texts)?void 0:i.title}),(0,n.jsx)("p",{className:"text-xs text-slate-600 dark:text-slate-200",children:null==m||null==(d=m.texts)?void 0:d.subtitle})]}),(0,n.jsx)("div",{className:"ml-auto",children:(0,n.jsx)(ti.A,{text:p,color:"slate",square:!0})})]}),(0,n.jsx)(tw.A,{onDelete:()=>{u(c)},showDelete:!0})]})},au=e=>{let{productId:t}=e,{formatMessage:a}=(0,s.A)(),{setModal:l}=(0,eV.A)(),{bundleItems:i,loading:o}=as({productId:t}),{removeBundleItem:u}=(()=>{let[e]=(0,Q.n)(ar);return{removeBundleItem:async t=>{let{productId:a,index:n}=t;return e({variables:{productId:a,index:n},refetchQueries:["ProductBundleItems"]})}}})(),c=async e=>{await l((0,n.jsx)(e$.A,{onCancelClick:async()=>l(""),message:a({id:"delete_bundle_item_confirmation",defaultMessage:"This action might cause inconsistencies with other data that relates to it. Are you sure you want to delete this bundle item? "}),onOkClick:async()=>{l(""),await u({productId:t,index:e}),r.oR.success(a({id:"bundle_item_deleted",defaultMessage:"Bundle item deleted successfully"}))},okText:a({id:"delete_bundle_item",defaultMessage:"Delete item"})}))};return o?(0,n.jsx)(d.A,{}):i.length?(0,n.jsx)(n.Fragment,{children:i.map((e,t)=>(0,n.jsx)(ao,{index:t,item:e,onDelete:c},e.product._id))}):(0,n.jsx)(ew.A,{message:a({id:"bundle",defaultMessage:"Bundle product"})})},ac=e=>{let{productId:t,disabled:a=!1}=e;return(0,n.jsx)("div",{className:"mt-6 rounded-md",children:(0,n.jsxs)("div",{className:"lg:grid lg:grid-cols-9",children:[(0,n.jsx)("div",{className:"mb-5 lg:col-span-4 lg:pr-5",children:(0,n.jsx)(ae,{productId:t,disabled:a})}),(0,n.jsx)("div",{className:"col-span-5 ml-auto rounded-md bg-white dark:bg-slate-800 px-8 shadow-md dark:shadow-none lg:w-full",children:(0,n.jsx)("div",{className:"py-4",children:(0,n.jsx)(au,{productId:t})})})]})})};var am=a(19921),ap=a(76500),ax=a(57104);function ag(){let e=(0,L._)(["\n fragment ProductAssignmentFragment on ProductVariationAssignment {\n _id\n vectors {\n _id\n option {\n _id\n value\n texts {\n _id\n title\n subtitle\n }\n }\n variation {\n _id\n key\n texts {\n _id\n locale\n title\n }\n }\n }\n product {\n _id\n texts {\n _id\n title\n slug\n subtitle\n }\n }\n }\n"]);return ag=function(){return e},e}let af=(0,B.J1)(ag());function av(){let e=(0,L._)(["\n query ProductAssignments($productId: ID, $slug: String) {\n product(productId: $productId, slug: $slug) {\n _id\n ... on ConfigurableProduct {\n texts {\n _id\n subtitle\n slug\n title\n }\n variations {\n _id\n key\n texts {\n _id\n title\n }\n options {\n _id\n value\n texts {\n _id\n title\n }\n }\n }\n assignments(includeInactive: true) {\n ...ProductAssignmentFragment\n }\n }\n }\n }\n ","\n"]);return av=function(){return e},e}let ah=(0,B.J1)(av(),af),ab=function(){let{productId:e=null,slug:t=null}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},a=(0,ev.id)(t),{data:n,loading:s,error:l}=(0,ef.I)(ah,{skip:!e&&!a,variables:{productId:e||a}});return{product:null==n?void 0:n.product,loading:s,error:l}};var aj=a(33023);let ay=(e,t,a)=>{let n=e[a],s=[];return(null==n||n.values.filter(e=>e.length).forEach(e=>{let a={};a[n.key]=e,t.length>0?t.forEach(e=>{s.push({...e,...a})}):s.push(a)}),e.length>a+1)?ay(e,s,a+1):Array.from(new Set(s.map(e=>JSON.stringify(e)))).map(e=>JSON.parse(e))},a_=e=>{let{_id:t,texts:a}=e;return{value:t,label:null==a?void 0:a.title}};var aw=a(62942),aN=a(9518),aA=a(56975);function aP(){let e=(0,L._)(["\n mutation AddProductAssignment(\n $proxyId: ID!\n $productId: ID!\n $vectors: [ProductAssignmentVectorInput!]!\n ) {\n addProductAssignment(\n proxyId: $proxyId\n productId: $productId\n vectors: $vectors\n ) {\n _id\n }\n }\n"]);return aP=function(){return e},e}let ak=(0,B.J1)(aP()),aM=()=>{let[e]=(0,Q.n)(ak);return{addProductAssignment:async t=>{let{productId:a,proxyId:n,vectors:s}=t;return e({variables:{productId:a,proxyId:n,vectors:s},refetchQueries:["ProductAssignments"]})}}};function aI(){let e=(0,L._)(["\n mutation RemoveProductAssignment(\n $proxyId: ID!\n $vectors: [ProductAssignmentVectorInput!]!\n ) {\n removeProductAssignment(proxyId: $proxyId, vectors: $vectors) {\n _id\n }\n }\n"]);return aI=function(){return e},e}let aC=(0,B.J1)(aI());var a$=a(96456),aS=a.n(a$),aT=a(10363);let aV=function(e){let{proxyProduct:t,vectors:a,onSuccess:n}=e,{selectedLocale:l}=(0,er.A)(),{createProduct:r}=(0,t5.A)(),{addProductAssignment:i}=aM(),{formatMessage:d}=(0,s.A)();return async e=>{let{title:s,type:o}=e,u=[{title:s,slug:s.toLowerCase().replace(/\s+/g,"-"),locale:l}],{data:c}=await r({product:{type:o||t1.W.SimpleProduct},texts:u}),m=null==c?void 0:c.createProduct,p=null==m?void 0:m._id;if(!p)throw Error(d({id:"product_creation_failed",defaultMessage:"Product creation failed"}));return await i({productId:p,proxyId:null==t?void 0:t._id,vectors:a}),null==n||n(m),{success:!0}}},aD=e=>{let{proxyProduct:t,vectors:a,onSuccess:r}=e,{formatMessage:i}=(0,s.A)(),d=aV({onSuccess:r,proxyProduct:t,vectors:a}),{hasRole:o}=(0,A.A)(),u=(0,w.useMemo)(()=>a.map(e=>{let{value:t}=e;return t}),[a]),c=(0,w.useMemo)(()=>{var e,a;let n=null!=(a=null==t||null==(e=t.texts)?void 0:e.title)?a:"";return"".concat(u.join("-")," ").concat(n).trim()},[u,t]),m=async e=>{let{title:t,type:a}=e;try{return await d({title:t,type:a}),{success:!0}}catch(e){return{success:!1,error:{message:null==e?void 0:e.message}}}},p=i({id:"product-scaffolded-success",defaultMessage:"Product scaffolded successfully"}),x=(0,O.A)({submit:m,successMessage:p,enableReinitialize:!0,initialValues:{title:c,type:t1.W.SimpleProduct}});return(0,n.jsxs)(V.A,{className:"mt-3 rounded-md",form:x,children:[(0,n.jsxs)("div",{className:"p-5 pb-7 sm:max-w-full flex flex-col gap-3",children:[(0,n.jsx)(E.A,{name:"title",id:"title",label:i({id:"name",defaultMessage:"Name"}),required:!0,className:"block w-full max-w-full rounded-md border-slate-300 dark:border-slate-800 text-sm focus:ring-slate-800 sm:text-sm"}),(0,n.jsx)(R.A,{className:"mt-1 w-full",label:i({id:"type",defaultMessage:"Type"}),placeholder:i({id:"type",defaultMessage:"Type"}),required:!0,name:"type",options:Object.fromEntries(Object.entries(t1.W).filter(e=>{let[,t]=e;return t!==t1.W.ConfigurableProduct}))})]}),o(l._r.ManageProducts)&&(0,n.jsx)("div",{className:"border-t border-t-slate-100 dark:border-t-slate-700 bg-slate-50 dark:bg-slate-900 p-5 text-right",children:(0,n.jsx)(q.A,{label:i({id:"scaffold_product",defaultMessage:"Scaffold"})})})]})},aR=e=>{var t,a;let{columns:r,variationProduct:i,product:d,loading:o,disabled:u,proxyId:c,columnKeys:m}=e,{formatMessage:p}=(0,s.A)(),[x,g]=(0,w.useState)(""),{addProductAssignment:f}=aM(),{removeProductAssignment:v}=(()=>{let[e]=(0,Q.n)(aC);return{removeProductAssignment:async t=>{let{proxyId:a,vectors:n}=t;return e({variables:{proxyId:a,vectors:n},refetchQueries:["ProductAssignments"]})}}})(),{hasRole:h}=(0,A.A)(),{setModal:b}=(0,eV.A)(),{products:j}=(0,tY.A)({queryString:x,limit:50,sort:[{key:"created",value:l.t4.Desc}]}),y=(0,w.useMemo)(()=>r.map((e,t)=>({key:m[t],value:e})).filter(e=>{let{value:t}=e;return t}),[r,m]),_=(0,w.useCallback)(async e=>{let{value:t}=e;await f({proxyId:c,productId:t,vectors:y})},[y,f,c]),N=(0,w.useCallback)(async()=>{await b((0,n.jsx)(e$.A,{onCancelClick:async()=>b(""),message:p({id:"delete_product_assignment",defaultMessage:"This action might cause inconsistencies with other data that relates to it. Are you sure you want to delete this assignment? "}),onOkClick:async()=>{b(""),await v({proxyId:c,vectors:y})},okText:p({id:"delete_variation_assignment",defaultMessage:"Delete assignment"})}))},[c,y,p,b,v]),P=(0,w.useMemo)(()=>(0,aA.A)(200)(g),[]),k=!i&&(null==d||null==(t=d.variations)?void 0:t.length)!==(null==r?void 0:r.length),M=(0,w.useMemo)(()=>(null==j?void 0:j.map(a_).filter(e=>{let{value:t}=e;return t!==c}))||[],[j,c]),I=async()=>{await b((0,n.jsx)(aD,{proxyProduct:d,vectors:y,onSuccess:()=>{b(null)}}))};return(0,n.jsxs)(aj.A.Row,{children:[r.map((e,t)=>(0,n.jsx)(aj.A.Cell,{className:"font-medium",children:e},"".concat(e))),(0,n.jsx)(aj.A.Cell,{children:i?(0,n.jsx)("div",{className:"flex items-center",children:(0,n.jsx)(aS(),{href:"/products?slug=".concat((0,ev.Ay)(i)),children:(0,n.jsx)("span",{className:"text-green-700 dark:text-green-300 font-medium",children:null==i||null==(a=i.texts)?void 0:a.title})})}):k?(0,n.jsx)("div",{className:"mt-1 text-sm text-rose-600 italic",children:p({id:"assign_product_needs_variations",defaultMessage:"Please configure all variation options before assigning a product."})}):(0,n.jsx)("div",{className:"relative w-full",children:(0,n.jsxs)("div",{className:"flex items-center gap-2",children:[(0,n.jsx)("div",{className:"flex-1",children:(0,n.jsx)(aN.A,{name:"productId",placeholder:p({id:"search_product",defaultMessage:"Search product"}),isLoading:o,isDisabled:u,onChange:_,onInputChange:P,options:M,className:"mt-1 w-full py-2 text-sm font-medium text-slate-500"})}),h(l._r.ManageProducts)&&(0,n.jsx)(F.A,{onClick:I,children:(0,n.jsx)(aT.A,{className:"h-5 w-5"})})]})})}),(0,n.jsx)(aj.A.Cell,{children:i&&i._id&&(0,n.jsx)(aw.A,{onClick:N})})]})};var aq=a(67032);let aE=e=>{let{proxyId:t,disabled:a=!1}=e,{formatMessage:l}=(0,s.A)(),{product:r,loading:i}=ab({productId:t}),d=r&&(null==r?void 0:r.variations)||[],o=r&&r.assignments||[],u=(0,w.useMemo)(()=>d.filter(e=>{let{options:t}=e;return t.length}).map(e=>{let{key:t}=e;return t}),[d]),c=(0,w.useMemo)(()=>d.map(e=>{let{key:t,options:a}=e;return{values:null==a?void 0:a.map(e=>e.value),key:t}}),[d]),m=(0,w.useMemo)(()=>{let e=c.filter(e=>{let{values:t}=e;return null==t?void 0:t.length});return e.length>0?ay(e,[],0):[]},[c]),p=(0,w.useMemo)(()=>o.map(e=>{let t={};return u.forEach(a=>{var n,s;let l=e.vectors.find(e=>{var t;return(null==(t=e.variation)?void 0:t.key)===a});t[a]=null!=(s=null==l||null==(n=l.option)?void 0:n.value)?s:""}),t}),[o,u]),x=(0,w.useMemo)(()=>{let e=[...m,...p],t=new Set;return e.filter(e=>{let a=Object.values(e).join("::");return!t.has(a)&&(t.add(a),!0)})},[m,p]),g=(0,w.useMemo)(()=>o.map(e=>{let t={};return e.vectors.forEach(e=>{var a,n;(null==e||null==(a=e.variation)?void 0:a.key)&&(null==e||null==(n=e.option)?void 0:n.value)&&(t[e.variation.key]=e.option.value)}),{keys:t,product:e.product}}),[o]),f=(0,w.useMemo)(()=>x.map(e=>{let t=g.find(t=>{let{keys:a}=t;return Object.entries(a).every(t=>{let[a,n]=t;return e[a]===n})});return{_id:Object.values(e).join("::"),product:null==t?void 0:t.product,columns:Object.values(e),columnsText:Object.values(e)}}),[x,g]),v=(0,w.useMemo)(()=>d.length>0,[d]),h=(0,w.useMemo)(()=>d.some(e=>e.options&&e.options.length>0),[d]);return(0,n.jsxs)(P.A,{children:[(0,n.jsx)(aq.A,{title:l({id:"product_assignments_explanation_title",defaultMessage:"About Product Assignments"}),description:l({id:"product_assignments_explanation_text",defaultMessage:"Product assignments allow you to link specific products to each unique combination of variation options. For example, if you have a t-shirt with 'Size' and 'Color' variations, you can assign different product SKUs to each combination like 'Large + Red' or 'Small + Blue'. This is useful for managing inventory, pricing, and product details for each specific variant."})}),!v&&(0,n.jsxs)("div",{className:"text-center py-8",children:[(0,n.jsx)("div",{className:"inline-flex items-center justify-center w-16 h-16 rounded-full bg-gray-100 dark:bg-gray-800 mb-4",children:(0,n.jsx)(ax.A,{className:"w-8 h-8 text-gray-400"})}),(0,n.jsx)("h3",{className:"text-lg font-medium text-gray-900 dark:text-gray-100 mb-2",children:l({id:"no_variations_configured",defaultMessage:"No variations configured yet. Please add variations and their options in the Variations tab first."})})]}),v&&h&&(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)("div",{className:"mb-4",children:(0,n.jsx)(el.A,{messageKey:"assignment_matrix_help",defaultMessage:"Each row represents a unique combination of your product variations. Assign a specific product to each combination to create a complete product catalog."})}),(0,n.jsxs)(aj.A,{children:[(0,n.jsxs)(aj.A.Row,{children:[u.map(e=>{var t,a;return(0,n.jsx)(aj.A.Cell,{className:"font-semibold bg-gray-50 dark:bg-gray-800",children:(null==(a=d.find(t=>t.key===e))||null==(t=a.texts)?void 0:t.title)||e},e)}),(0,n.jsx)(aj.A.Cell,{className:"font-semibold bg-gray-50 dark:bg-gray-800",children:l({id:"assigned_product_column_header",defaultMessage:"Assigned Product"})}),(0,n.jsx)(aj.A.Cell,{className:"font-semibold bg-gray-50 dark:bg-gray-800",children:l({id:"actions_column_header",defaultMessage:"Actions"})})]}),f.length>0&&f.map(e=>{let{_id:s,columns:l,product:d}=e;return(0,n.jsx)(aR,{columns:l,disabled:a,loading:i,product:r,variationProduct:d,columnKeys:u,proxyId:t},s)})]})]}),v&&!h&&(0,n.jsxs)("div",{className:"text-center py-8",children:[(0,n.jsx)("div",{className:"inline-flex items-center justify-center w-16 h-16 rounded-full bg-yellow-100 dark:bg-yellow-900/30 mb-4",children:(0,n.jsx)(ax.A,{className:"w-8 h-8 text-yellow-600 dark:text-yellow-400"})}),(0,n.jsx)("h3",{className:"text-lg font-medium text-gray-900 dark:text-gray-100 mb-2",children:l({id:"assign_product_needs_variations",defaultMessage:"Please configure all variation options before assigning a product."})}),(0,n.jsx)("p",{className:"text-sm text-gray-600 dark:text-gray-400",children:l({id:"assignment_matrix_help",defaultMessage:"Each row represents a unique combination of your product variations. Assign a specific product to each combination to create a complete product catalog."})})]})]})};function aF(){let e=(0,L._)(["\n query ProductTokenization($productId: ID, $slug: String) {\n product(productId: $productId, slug: $slug) {\n _id\n ... on TokenizedProduct {\n contractConfiguration {\n tokenId\n supply\n }\n contractStandard\n contractAddress\n }\n }\n }\n"]);return aF=function(){return e},e}let aO=(0,B.J1)(aF()),aU=function(){let{productId:e=null,slug:t=null}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},a=(0,ev.id)(t),{data:n,loading:s,error:l}=(0,ef.I)(aO,{skip:!e&&!t,variables:{productId:e||a}});return{product:null==n?void 0:n.product,loading:s,error:l}};function aJ(){let e=(0,L._)(['\n query SmartContractStandards {\n smartContractStandards: __type(name: "SmartContractStandard") {\n options: enumValues {\n value: name\n label: name\n }\n }\n }\n']);return aJ=function(){return e},e}let aL=(0,B.J1)(aJ());function aB(){let e=(0,L._)(["\n mutation UpdateProductTokenization(\n $productId: ID!\n $tokenization: UpdateProductTokenizationInput!\n ) {\n updateProductTokenization(\n productId: $productId\n tokenization: $tokenization\n ) {\n _id\n }\n }\n"]);return aB=function(){return e},e}let aQ=(0,B.J1)(aB()),az=e=>{let{productId:t,disabled:a=!1}=e,{formatMessage:r}=(0,s.A)(),{hasRole:i}=(0,A.A)(),{smartContractStandards:d}=(()=>{var e;let{data:t,loading:a,error:n}=(0,ef.I)(aL);return{smartContractStandards:(null==t||null==(e=t.smartContractStandards)?void 0:e.options)||[],loading:a,error:n}})(),{updateProductTokenization:o}=(()=>{let[e]=(0,Q.n)(aQ);return{updateProductTokenization:async t=>{let{productId:a,tokenization:{contractAddress:n,contractStandard:s,tokenId:l,supply:r}}=t;return e({variables:{productId:a,tokenization:{contractAddress:n,contractStandard:s,tokenId:l,supply:parseInt(r,10)}},refetchQueries:["Product","Products"]})}}})(),{product:u,loading:c}=aU({productId:t}),m=async e=>{let{contractAddress:a,contractStandard:n,tokenId:s,supply:l}=e;return await o({productId:t,tokenization:{contractAddress:a,contractStandard:n,tokenId:s||"",supply:l}}),{success:!0}},p=r({id:"token_updated",defaultMessage:"Token update successfully!"}),x=(0,O.A)({disabled:a,submit:m,successMessage:p,initialValues:{contractAddress:"",contractStandard:"",tokenId:"",supply:""}});return(0,w.useEffect)(()=>{var e,t;c||x.formik.setValues({contractAddress:(null==u?void 0:u.contractAddress)||"",contractStandard:(null==u?void 0:u.contractStandard)||"",tokenId:(null==u||null==(e=u.contractConfiguration)?void 0:e.tokenId)||"",supply:(null==u||null==(t=u.contractConfiguration)?void 0:t.supply)||""})},[c]),(0,n.jsx)(ea.A,{documentationLabel:r({id:"texts",defaultMessage:"Texts"}),className:"mt-2 lg:mt-5",documentation:(0,n.jsx)(X.A,{id:"tokenized_product_text_form_description",defaultMessage:"<b>Contract standards </b> <ol> <dt><b> ERC721 </b></dt> <dd> Buying multiple Products leads to multiple Tokens (make sure to set the tokenId to 0 to make it auto generate new id's) </dd> <dt> <b> ERC1155 </b></dt> <dd> Buying multiple Products leads to a new token with balance 3 of token with tokenId assigned </dd> <dt> <b> Contract address </b></dt> <dd> Address of a token on a given network </dd> </ol>",values:{ol:e=>(0,n.jsxs)("ol",{children:[e," "]}),dt:e=>(0,n.jsxs)("dt",{className:"bold",children:[e," "]}),dd:e=>(0,n.jsxs)("dd",{children:[e," "]}),b:e=>(0,n.jsxs)("b",{children:[e," "]})}}),children:(0,n.jsx)(P.A,{children:(0,n.jsxs)(V.A,{form:x,children:[(0,n.jsxs)("div",{className:"p-5 pb-7 sm:max-w-full flex flex-col gap-y-5",children:[(0,n.jsx)(R.A,{className:"w-full",label:r({id:"contract-standard",defaultMessage:"Contract standard"}),placeholder:r({id:"contract-standard",defaultMessage:"Contract standard"}),required:!0,name:"contractStandard",options:(0,k.A)(d,"label","value")}),(0,n.jsx)(E.A,{name:"contractAddress",id:"contractAddress",label:r({id:"contract-address-label",defaultMessage:"Contract Address"}),placeholder:r({id:"contract-address-label",defaultMessage:"Contract Address"}),required:!0,className:"block w-full max-w-full rounded-md border-slate-300 dark:border-slate-800 text-sm focus:ring-slate-800 sm:text-sm"}),(0,n.jsx)(E.A,{name:"supply",id:"supply",type:"number",label:r({id:"token-supply",defaultMessage:"Supply"}),placeholder:r({id:"token-supply",defaultMessage:"Supply"}),required:!0,className:"block w-full max-w-full rounded-md border-slate-300 dark:border-slate-800 text-sm focus:ring-slate-800 sm:text-sm"}),(0,n.jsx)(E.A,{name:"tokenId",id:"tokenId",label:r({id:"token-id-label",defaultMessage:"Token Serial Number"}),placeholder:r({id:"token-id-label",defaultMessage:"Token Serial Number"}),className:"block w-full max-w-full rounded-md border-slate-300 dark:border-slate-800 text-sm focus:ring-slate-800 sm:text-sm"})]}),i(l._r.ManageProducts)&&(0,n.jsx)("div",{className:"space-y-6 border-t border-t-slate-100 dark:border-t-slate-700 bg-slate-50 dark:bg-slate-900 p-5 text-right",children:(0,n.jsx)(q.A,{label:r({id:"update_token",defaultMessage:"Update token"})})})]})})})};var aW=a(14303),aK=a(42149);let aG=e=>{let{id:t,selectedView:a="",disableAll:s=!1,...l}=e;return"texts"===a?(0,n.jsx)(_.A,{children:(0,n.jsx)(ed,{productId:t,disabled:s})}):"media"===a?(0,n.jsx)(aK.A,{children:(0,n.jsx)(_.A,{children:(0,n.jsx)(eF,{productId:t})})}):"commerce"===a?(0,n.jsx)(H,{productId:t,disabled:s}):"supply"===a?(0,n.jsx)(e5,{productId:t,disabled:s}):"warehousing"===a?(0,n.jsx)(tV,{productId:t,disabled:s}):"variations"===a?(0,n.jsx)(_.A,{children:(0,n.jsx)(tM,{productId:t,disabled:s})}):"bundled_products"===a?(0,n.jsx)(ac,{productId:t,disabled:s}):"subscriptions"===a?(0,n.jsx)(eG,{productId:t,disabled:s}):"reviews"===a?(0,n.jsx)(tG,{productId:t}):"assignments"===a?(0,n.jsx)(_.A,{children:(0,n.jsx)(aE,{proxyId:t,disabled:s})}):"token"===a?(0,n.jsx)(az,{productId:t,disabled:s}):"extended"===a?(0,n.jsx)(aW.A,{data:l}):(0,n.jsx)(_.A,{children:(0,n.jsx)(ed,{productId:t})})},aH=e=>{var t;let{product:a,extendedData:r={}}=e,{formatMessage:i}=(0,s.A)(),{hasRole:d}=(0,A.A)(),{updateProduct:o}=(0,ap.A)(),{shopInfo:u}=(0,er.A)(),{__typename:_}=a||{},w=[{id:"texts",title:i({id:"general_text",defaultMessage:"Text"}),Icon:(0,n.jsx)(c.A,{className:"h-5 w-5"})},{id:"media",title:i({id:"media",defaultMessage:"Media"}),Icon:(0,n.jsx)(m.A,{className:"h-5 w-5"})},"ConfigurableProduct"!==_&&{id:"commerce",title:i({id:"commerce",defaultMessage:"Commerce"}),Icon:(0,n.jsx)(p.A,{className:"h-5 w-5"})},"SimpleProduct"===_&&{id:"supply",title:i({id:"supply",defaultMessage:"Supply"}),Icon:(0,n.jsx)(x.A,{className:"h-5 w-5"})},"SimpleProduct"===_&&{id:"warehousing",title:i({id:"warehousing",defaultMessage:"Warehousing"}),Icon:(0,n.jsx)(g.A,{className:"h-5 w-5"})},"ConfigurableProduct"===_&&{id:"variations",title:i({id:"variations",defaultMessage:"Variations"}),Icon:(0,n.jsx)(f.A,{className:"h-5 w-5"})},"BundleProduct"===_&&{id:"bundled_products",title:i({id:"bundled_items",defaultMessage:"Bundled items"}),Icon:(0,n.jsx)(v.A,{className:"h-5 w-5"})},"PlanProduct"===_&&{id:"subscriptions",title:i({id:"subscriptions",defaultMessage:"Subscriptions"}),Icon:(0,n.jsx)(h.A,{className:"h-5 w-5"})},"ConfigurableProduct"===_&&{id:"assignments",title:i({id:"assignments",defaultMessage:"Assignments"}),Icon:(0,n.jsx)(b.A,{className:"h-5 w-5"})},"TokenizedProduct"===_&&{id:"token",title:i({id:"token",defaultMessage:"Token"}),Icon:(0,n.jsx)(b.A,{className:"h-5 w-5"})},{id:"reviews",title:i({id:"reviews",defaultMessage:"Reviews"}),Icon:(0,n.jsx)(j.A,{className:"h-5 w-5"})},null!==r&&{id:"extended",title:i({id:"extended-fields",defaultMessage:"Extended"}),Icon:(0,n.jsx)(y.A,{className:"h-5 w-5"})}].filter(e=>e),N=async e=>{let{tags:t}=e;return await o({productId:null==a?void 0:a._id,product:{tags:t}}),!0};return(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)("div",{className:"mt-5 flex flex-wrap items-center justify-between gap-10",children:(0,n.jsx)(am.A,{defaultValue:null==a?void 0:a.tags,onSubmit:N,enableEdit:d(l._r.ManageProducts),availableTagOptions:null==u||null==(t=u.adminUiConfig)?void 0:t.productTags.filter(e=>{var t;return!(null==(t=(null==a?void 0:a.tags)||[])?void 0:t.includes(e))}).map(e=>({value:e,label:e}))})}),(0,n.jsx)(tD.A,{tabItems:w,defaultTab:"texts",children:(0,n.jsx)(aG,{disableAll:(null==a?void 0:a.status)===l.t_.Deleted,id:null==a?void 0:a._id,...r})})]})},aX=e=>{let{media:t=[],onEditMedia:a}=e;return(0,n.jsx)("div",{className:"my-5",children:(0,n.jsx)("div",{className:"flex gap-3 overflow-x-auto",children:t.map(e=>{var t,s,l,r;return(0,n.jsx)("div",{className:"relative flex-shrink-0 group",children:(0,n.jsx)("div",{className:"w-16 h-16 bg-slate-100 dark:bg-slate-800 rounded-lg overflow-hidden cursor-pointer border border-slate-200 dark:border-slate-700",onClick:()=>{var t;return t=e._id,void(a&&a(t))},children:(0,n.jsx)(ai.A,{src:null==e||null==(t=e.file)?void 0:t.url,alt:(null==(l=e.texts)||null==(s=l[0])?void 0:s.title)||(null==e||null==(r=e.file)?void 0:r.url),width:128,height:128,className:"w-full h-full object-cover"})})},e._id)})})})};var aZ=a(6743);function aY(){let e=(0,L._)(["\n mutation PublishProduct($productId: ID!) {\n publishProduct(productId: $productId) {\n ...ProductDetailFragment\n }\n }\n ","\n"]);return aY=function(){return e},e}let a0=(0,B.J1)(aY(),z.A);function a1(){let e=(0,L._)(["\n mutation UnpublishProduct($productId: ID!) {\n unpublishProduct(productId: $productId) {\n ...ProductDetailFragment\n }\n }\n ","\n"]);return a1=function(){return e},e}let a5=(0,B.J1)(a1(),z.A);var a2=a(28569),a6=a(57267),a4=a(83293),a8=a(46225),a3=a(96487),a9=a(41824);let a7=e=>{var t,a,c;let{slug:m}=e,{formatMessage:p}=(0,s.A)(),{formatDateTime:x}=(0,u.A)(),{hasRole:g}=(0,A.A)(),{publishProduct:f}=(()=>{let[e]=(0,Q.n)(a0);return{publishProduct:async t=>{let{productId:a}=t;return e({variables:{productId:a},refetchQueries:["Product","ShopStatus"],awaitRefetchQueries:!0})}}})(),{unPublishProduct:v}=(()=>{let[e]=(0,Q.n)(a5);return{unPublishProduct:async t=>{let{productId:a}=t;return e({variables:{productId:a},refetchQueries:["Product","ShopStatus"],awaitRefetchQueries:!0})}}})(),{removeProduct:h}=(0,a6.A)(),{updateProduct:b}=(0,ap.A)(),{setModal:j}=(0,eV.A)(),y=(0,a8.useRouter)(),{push:_}=(0,a8.useRouter)(),{product:N,loading:P,error:k,extendedData:M}=t9({slug:m}),I=(null==N?void 0:N.status)||"DRAFT",C=(0,w.useMemo)(()=>[{id:"published",title:p({id:"published",defaultMessage:"Published"}),description:p({id:"publish_product_description",defaultMessage:"Product will be searchable and is available for orders"}),current:"ACTIVE"===I,selectedTitle:p({id:"published",defaultMessage:"Published"}),onClick:async()=>{try{await f({productId:null==N?void 0:N._id}),r.oR.success(p({id:"product_published",defaultMessage:"Published successfully "}))}catch(t){console.error("Failed to publish product:",t);let e=(null==t?void 0:t.message)||"Unknown error";r.oR.error("".concat(p({id:"product_publish_error",defaultMessage:"Failed to publish product"}),": ").concat(e))}},bgColor:"green",disable:!g(l._r.ManageProducts)},{id:"draft",title:p({id:"draft",defaultMessage:"Draft"}),description:p({id:"draft_product_description",defaultMessage:"Product will not be discoverable and can not be orderose"}),current:"DRAFT"===I,selectedTitle:p({id:"not_published",defaultMessage:"Not published"}),bgColor:"amber",disable:"ACTIVE"===I&&!g(l._r.ManageProducts),onClick:async()=>{if(g(l._r.ManageProducts))try{await v({productId:null==N?void 0:N._id}),r.oR.success(p({id:"product_drafted",defaultMessage:"Drafted successfully "}))}catch(t){console.error("Failed to unpublish product:",t);let e=(null==t?void 0:t.message)||"Unknown error";r.oR.error("".concat(p({id:"product_unpublish_error",defaultMessage:"Failed to unpublish product"}),": ").concat(e))}}}],[N]);if(k)return console.error("Error loading product:",k),(0,n.jsx)("div",{className:"mt-5 max-w-full",children:(0,n.jsx)("div",{className:"text-center py-8",children:(0,n.jsx)("p",{className:"text-rose-600 dark:text-rose-400",children:p({id:"product_load_error",defaultMessage:"Failed to load product"})})})});let $=async e=>{e.target.value&&await b({productId:null==N?void 0:N._id,product:{sequence:parseInt(e.target.value,10)}})},S=async()=>{var e;if("proxies"in N&&(null==(e=N.proxies)?void 0:e.length))return void await j((0,n.jsx)(a9.A,{headerText:p({id:"product_delete_blocked_header",defaultMessage:"Remove links before deleting"}),message:(0,n.jsxs)("div",{className:"space-y-2",children:[(0,n.jsx)("p",{children:p({id:"product_delete_blocked_intro",defaultMessage:"This product is linked to the following product types:"})}),(0,n.jsx)("ul",{className:"list-disc list-inside text-sm text-slate-700 dark:text-slate-300",children:"proxies"in N&&N.proxies.map((e,t)=>{let{__typename:a}=e;return(0,n.jsx)("li",{children:a.replace("Product","")},t)})}),(0,n.jsx)("p",{children:p({id:"product_delete_blocked_action",defaultMessage:"Please unlink it before trying to delete it."})})]}),buttonText:p({id:"ok",defaultMessage:"Ok"}),onOkClick:()=>j(null)}));await j((0,n.jsx)(e$.A,{onCancelClick:()=>j(""),message:p({id:"delete_product_confirmation",defaultMessage:"This action might cause inconsistencies with other data that relates to it and it is nonreversible. Are you sure you want to delete this product?"}),onOkClick:async()=>{j("");try{await h({productId:null==N?void 0:N._id}),r.oR.success(p({id:"product_deleted_success",defaultMessage:"Deleted successfully"})),y.push("/products")}catch(e){await j((0,n.jsx)(e$.A,{onCancelClick:()=>j(""),headerText:p({id:"error",defaultMessage:"Error"}),message:e instanceof a4.A?e.message:e,icon:(0,n.jsx)("div",{className:"mx-auto flex h-12 w-12 shrink-0 items-center justify-center rounded-full bg-rose-100 dark:bg-rose-900/30 sm:mx-0 sm:h-10 sm:w-10",children:(0,n.jsx)(a3.A,{className:"h-6 w-6 text-rose-600 dark:text-rose-400",xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2"})}),okText:p({id:"ok",defaultMessage:"Ok"}),onOkClick:async()=>{j("")}}))}}}))};return N||P?P?(0,n.jsx)(d.A,{}):(0,n.jsxs)("div",{className:"mt-5 max-w-full",children:[(0,n.jsx)(i.A,{routeName:m,depth:3,currentPageTitle:null==N||null==(t=N.texts)?void 0:t.title}),"DELETED"===I&&(0,n.jsx)("div",{className:"mb-4 rounded-md border border-rose-300 bg-rose-50 p-4 text-sm text-rose-800 dark:border-rose-700 dark:bg-rose-900/30 dark:text-rose-300",children:p({id:"product_deleted_notice",defaultMessage:"This product has been deleted and is no longer active. Some actions may be restricted."})}),(0,n.jsxs)("div",{children:[(0,n.jsxs)("div",{className:"items-center flex-wrap flex gap-5 min-w-full justify-between",children:[(0,n.jsx)(o.A,{headerText:(0,n.jsxs)(n.Fragment,{children:[(null==N||null==(a=N.texts)?void 0:a.title)||"Untitled Product","DELETED"===I&&(0,n.jsx)("span",{className:"ml-3 rounded bg-rose-100 px-2 py-1 text-xs font-semibold text-rose-800 dark:bg-rose-900/40 dark:text-rose-300",children:p({id:"deleted_status",defaultMessage:"Deleted"})})]}),title:"".concat((null==N||null==(c=N.texts)?void 0:c.title)||"Product"," (").concat(null==N?void 0:N._id,")")}),(0,n.jsxs)("div",{className:"publish-and-order flex flex-wrap gap-3",children:[I&&"DELETED"!==I&&(0,n.jsx)(aZ.A,{options:C,type:p({id:"product",defaultMessage:"Product"})}),(0,n.jsxs)("div",{className:"inline-flex items-center gap-2 rounded-md dark:border-slate-600 px-4 py-2 text-sm font-medium leading-5 shadow-xs bg-white dark:bg-slate-800 h-[38px]",children:[(0,n.jsx)("label",{htmlFor:"sequence-input",className:"text-slate-700 dark:text-slate-200 font-medium cursor-pointer",children:p({id:"sequence",defaultMessage:"Display Order"})}),(0,n.jsx)("input",{type:"number",id:"sequence-input",disabled:!g(l._r.ManageProducts),className:"text-center w-12 bg-transparent border border-slate-300 dark:border-slate-600 rounded focus:ring-2 focus:ring-slate-800 dark:focus:ring-slate-400 focus:border-transparent focus:outline-none text-sm font-semibold text-slate-900 dark:text-slate-300 px-2 py-1 transition-all",defaultValue:null==N?void 0:N.sequence,onBlur:$})]}),"DRAFT"===I&&g(l._r.ManageProducts)&&(0,n.jsx)(a2.A,{onClick:S})]})]}),(0,n.jsxs)("div",{className:"mt-8 flex flex-wrap gap-3 gap-x-10 text-slate-600 dark:text-slate-400",children:[(0,n.jsxs)("div",{className:"flex flex-col items-baseline gap-0",children:[(0,n.jsx)("span",{className:"mr-2 text-xs text-slate-500 dark:text-slate-500",children:"ID:"}),(0,n.jsx)("span",{className:"text-sm font-mono",children:null==N?void 0:N._id})]}),(0,n.jsxs)("div",{className:"flex flex-col items-baseline gap-0",children:[(0,n.jsx)("span",{className:"text-xs text-slate-500 dark:text-slate-500",children:"Type:"}),(0,n.jsx)("p",{className:"text-sm font-mono",children:null==N?void 0:N.__typename})]}),(null==N?void 0:N.created)&&(0,n.jsxs)("div",{className:"flex flex-col items-baseline gap-0",children:[(0,n.jsxs)("span",{className:"text-xs text-slate-500 dark:text-slate-500",children:[p({id:"created",defaultMessage:"Created"}),":"]}),(0,n.jsx)("span",{className:"text-sm font-mono",children:x(N.created,{dateStyle:"medium",timeStyle:"short"})})]}),(null==N?void 0:N.updated)&&(0,n.jsxs)("div",{className:"flex flex-col items-baseline gap-0",children:[(0,n.jsxs)("span",{className:"text-xs text-slate-500 dark:text-slate-500",children:[p({id:"updated",defaultMessage:"Updated"}),":"]}),(0,n.jsx)("span",{className:"text-sm font-mono",children:x(N.updated,{dateStyle:"medium",timeStyle:"short"})})]}),(null==N?void 0:N.published)&&(0,n.jsxs)("div",{className:"flex flex-col items-baseline gap-0",children:[(0,n.jsxs)("span",{className:"text-xs text-slate-500 dark:text-slate-500",children:[p({id:"published",defaultMessage:"Published"}),":"]}),(0,n.jsx)("span",{className:"text-sm font-mono",children:x(N.published,{dateStyle:"medium",timeStyle:"short"})})]})]})]}),(0,n.jsx)(aX,{productId:null==N?void 0:N._id,media:(null==N?void 0:N.media)||[],onEditMedia:e=>{y.push({pathname:y.pathname,query:{...y.query,tab:"media"}},void 0,{shallow:!0})},canEdit:g(l._r.ManageProducts)}),(0,n.jsx)(aH,{product:N,extendedData:M})]}):(_("/404"),null)}},24984:(e,t,a)=>{a.d(t,{W:()=>n});let n={SimpleProduct:"SIMPLE_PRODUCT",BundleProduct:"BUNDLE_PRODUCT",PlanProduct:"PLAN_PRODUCT",ConfigurableProduct:"CONFIGURABLE_PRODUCT",TokenizedProduct:"TOKENIZED_PRODUCT"}},25191:(e,t,a)=>{a.d(t,{A:()=>r});var n=a(26514);a(75834);var s=a(36857),l=a(644);let r=e=>{let{messageKey:t,defaultMessage:a,values:r,className:i="",showIcon:d=!0}=e,{formatMessage:o}=(0,l.A)(),u=o({id:t,defaultMessage:a},r);return u?(0,n.jsxs)("div",{className:"flex items-start space-x-1 text-sm text-slate-600 dark:text-slate-400 ".concat(i),children:[d&&(0,n.jsx)(s.A,{className:"h-4 w-4 mt-0.5 flex-shrink-0"}),(0,n.jsx)("span",{children:u})]}):null}},35843:(e,t,a)=>{a.d(t,{A:()=>o});var n=a(9985),s=a(15968),l=a(70486),r=a(18237);function i(){let e=(0,n._)(["\n query Currencies(\n $queryString: String\n $limit: Int\n $offset: Int\n $includeInactive: Boolean\n $sort: [SortOptionInput!]\n ) {\n currencies(\n queryString: $queryString\n limit: $limit\n offset: $offset\n includeInactive: $includeInactive\n sort: $sort\n ) {\n ...CurrencyFragment\n }\n currenciesCount(\n includeInactive: $includeInactive\n queryString: $queryString\n )\n }\n ","\n"]);return i=function(){return e},e}let d=(0,s.J1)(i(),r.A),o=function(){let{queryString:e="",limit:t=20,offset:a=0,includeInactive:n=!0,sort:s=[]}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},{data:r,loading:i,error:o,fetchMore:u}=(0,l.I)(d,{variables:{queryString:e,limit:t,offset:a,includeInactive:n,sort:s}}),c=(null==r?void 0:r.currencies)||[],m=null==r?void 0:r.currenciesCount,p=(null==c?void 0:c.length)<m;return{currencies:c,currenciesCount:m,hasMore:p,loading:i,error:o,loadMore:()=>{u({variables:{offset:null==c?void 0:c.length}})}}}},40841:(e,t,a)=>{a.d(t,{A:()=>u});var n=a(26514),s=a(69001),l=a.n(s),r=a(46193),i=a(34044),d=a(75834);let o=e=>{let{header:t,body:a,headerCSS:s="",bodyCSS:o="",itemContainerCSS:u="",itemindex:c=1,hideChevron:m=!1}=e,[p,x]=(0,d.useState)(!1);return(0,n.jsxs)("div",{className:l()("mt-3",u),"data-itemindex":c,children:[(0,n.jsxs)("button",{type:"button",onClick:()=>x(!p),className:l()("relative cursor-pointer border dark:border-slate-800 bg-white dark:bg-slate-900 text-slate-500 dark:text-slate-200 hover:bg-slate-50 dark:hover:bg-slate-700 w-full max-w-full overflow-hidden",s),children:[(0,n.jsx)("div",{className:"w-full",children:t}),!m&&(0,n.jsx)("span",{className:"px-2",children:p?(0,n.jsx)(r.A,{className:"h-5 w-5"}):(0,n.jsx)(i.A,{className:"h-5 w-5"})})]}),p?(0,n.jsx)("div",{className:l()("rounded-lg sm:p-4 xl:p-10 relative overflow-visible",o),children:a}):""]})},u=e=>{let{data:t,containerCSS:a="",headerCSS:s="",bodyCSS:r="",itemContainerCSS:i="",hideChevron:d=!1,...u}=e;return(0,n.jsx)("div",{className:l()("my-3",a),...u,children:t.map((e,t)=>{let{header:a,body:l}=e;return(0,n.jsx)(o,{itemindex:t,header:a,body:l,headerCSS:s,bodyCSS:r,itemContainerCSS:i,hideChevron:d},t)})})}},51599:(e,t,a)=>{a.d(t,{A:()=>u});var n=a(9985),s=a(15968),l=a(62206),r=a(564),i=a(815);function d(){let e=(0,n._)(["\n mutation CreateProduct(\n $product: CreateProductInput!\n $texts: [ProductTextInput!]\n ) {\n createProduct(product: $product, texts: $texts) {\n ...ProductDetailFragment\n ... on SimpleProduct {\n texts {\n ...ProductTextsFragment\n }\n }\n ... on ConfigurableProduct {\n texts {\n ...ProductTextsFragment\n }\n }\n ... on BundleProduct {\n texts {\n ...ProductTextsFragment\n }\n }\n ... on TokenizedProduct {\n texts {\n ...ProductTextsFragment\n }\n }\n ... on PlanProduct {\n texts {\n ...ProductTextsFragment\n }\n }\n }\n }\n ","\n ","\n"]);return d=function(){return e},e}let o=(0,s.J1)(d(),r.A,i.A),u=()=>{let[e,{data:t,error:a,loading:n}]=(0,l.n)(o);return{createProduct:async t=>{let{product:{type:a,tags:n},texts:s}=t;return e({variables:{product:{type:a,tags:n},texts:s},refetchQueries:["Products","ShopStatus","ShopInfo"]})},newProduct:null==t?void 0:t.createProduct,error:a,loading:n}}},57267:(e,t,a)=>{a.d(t,{A:()=>d});var n=a(9985),s=a(15968),l=a(62206);function r(){let e=(0,n._)(["\n mutation RemoveProduct($productId: ID!) {\n removeProduct(productId: $productId) {\n _id\n }\n }\n"]);return r=function(){return e},e}let i=(0,s.J1)(r()),d=()=>{let[e]=(0,l.n)(i);return{removeProduct:async t=>{let{productId:a}=t;return e({variables:{productId:a},refetchQueries:["Products","ShopStatus","ShopInfo"]})}}}},65459:(e,t,a)=>{a.d(t,{A:()=>u,g:()=>o});var n=a(9985),s=a(15968),l=a(70486),r=a(23416),i=a(815);function d(){let e=(0,n._)(["\n query TranslatedProductTexts($productId: ID!) {\n translatedProductTexts(productId: $productId) {\n ...ProductTextsFragment\n ","\n }\n }\n ","\n"]);return d=function(){return e},e}let o=function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"";return(0,s.J1)(d(),e,i.A)},u=e=>{let{productId:t}=e,{customProperties:a}=(0,r.A)(),{data:n,loading:s,error:i}=(0,l.I)(o(null==a?void 0:a.ProductTexts),{skip:!t,variables:{productId:t}});return{translatedTexts:(null==n?void 0:n.translatedProductTexts)||[],loading:s,error:i}}},67032:(e,t,a)=>{a.d(t,{A:()=>l});var n=a(26514),s=a(57104);let l=e=>{let{title:t=null,description:a}=e;return(0,n.jsx)("div",{className:"mb-6 p-4 bg-blue-50 dark:bg-blue-900/20 border border-blue-200 dark:border-blue-800 rounded-lg",children:(0,n.jsxs)("div",{className:"flex items-start gap-3",children:[(0,n.jsx)(s.A,{className:"w-5 h-5 text-blue-600 dark:text-blue-400 mt-0.5 flex-shrink-0"}),(0,n.jsxs)("div",{children:[t&&(0,n.jsx)("h3",{className:"text-sm font-semibold text-blue-900 dark:text-blue-100 mb-2",children:t}),(0,n.jsx)("p",{className:"text-sm text-blue-800 dark:text-blue-200 leading-relaxed",children:a})]})]})})}},76500:(e,t,a)=>{a.d(t,{A:()=>o});var n=a(9985),s=a(15968),l=a(62206),r=a(564);function i(){let e=(0,n._)(["\n mutation UpdateProduct($productId: ID!, $product: UpdateProductInput!) {\n updateProduct(productId: $productId, product: $product) {\n ...ProductDetailFragment\n }\n }\n ","\n"]);return i=function(){return e},e}let d=(0,s.J1)(i(),r.A),o=()=>{let[e]=(0,l.n)(d);return{updateProduct:async t=>{let{productId:a,product:{tags:n,sequence:s,meta:l}}=t;return e({variables:{productId:a,product:{tags:n,sequence:s,meta:l}},refetchQueries:["Products","ShopStatus","ShopInfo"]})}}}}}]);
1
+ "use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[3282],{564:(e,t,a)=>{a.d(t,{A:()=>l});var n=a(9985);function s(){let e=(0,n._)(["\n fragment ProductDetailFragment on Product {\n _id\n sequence\n status\n created\n tags\n updated\n published\n\n media {\n _id\n tags\n file {\n _id\n url\n }\n }\n reviews {\n _id\n created\n author {\n _id\n username\n isGuest\n }\n rating\n title\n review\n voteCount\n ownVotes {\n type\n timestamp\n }\n }\n siblings {\n _id\n media {\n _id\n file {\n _id\n url\n }\n }\n }\n }\n"]);return s=function(){return e},e}let l=(0,a(15968).J1)(s())},815:(e,t,a)=>{a.d(t,{A:()=>l});var n=a(9985);function s(){let e=(0,n._)(["\n fragment ProductTextsFragment on ProductTexts {\n _id\n locale\n slug\n title\n subtitle\n description\n vendor\n brand\n labels\n }\n"]);return s=function(){return e},e}let l=(0,a(15968).J1)(s())},12238:(e,t,a)=>{a.d(t,{A:()=>n});let n=(e,t,a)=>Object.assign({},...(null==e?void 0:e.map(e=>({[e[a]]:e[t]})))||[])},15796:(e,t,a)=>{a.d(t,{R:()=>o,A:()=>u});var n=a(9985),s=a(15968),l=a(70486);function r(){let e=(0,n._)(["\n fragment ProductCatalogPriceFragment on ProductCatalogPrice {\n isTaxable\n isNetPrice\n country {\n _id\n isoCode\n name\n flagEmoji\n }\n currency {\n _id\n isoCode\n isActive\n }\n amount\n maxQuantity\n }\n"]);return r=function(){return e},e}let i=(0,s.J1)(r());function d(){let e=(0,n._)(["\n query ProductCatalogPrices($productId: ID!) {\n productCatalogPrices(productId: $productId) {\n ...ProductCatalogPriceFragment\n }\n }\n ","\n"]);return d=function(){return e},e}let o=(0,s.J1)(d(),i),u=e=>{let{productId:t}=e,{data:a,loading:n,error:s}=(0,l.I)(o,{skip:!t,variables:{productId:t}});return{catalogPrices:(null==a?void 0:a.productCatalogPrices)||[],loading:n,error:s}}},18237:(e,t,a)=>{a.d(t,{A:()=>l});var n=a(9985);function s(){let e=(0,n._)(["\n fragment CurrencyFragment on Currency {\n _id\n isoCode\n isActive\n contractAddress\n decimals\n }\n"]);return s=function(){return e},e}let l=(0,a(15968).J1)(s())},23282:(e,t,a)=>{a.r(t),a.d(t,{default:()=>a9});var n=a(26514),s=a(644),l=a(824),r=a(99650),i=a(7823),d=a(15829),o=a(27413),u=a(94617),c=a(91701),m=a(56585),p=a(16165),x=a(48029),g=a(38504),f=a(20915),v=a(54333),h=a(13039),b=a(55263),j=a(75151),y=a(70369),_=a(10702),w=a(75834),A=a(70267),N=a(70412),k=a(13226),M=a(12238),I=a(51869),P=a(35843),C=a(69001),$=a.n(C),S=a(2560);let T=e=>{let{disabled:t,labelClassName:a,containerClassName:s,inputClassName:l,...r}=e,i=(0,S.A)({...e,type:"checkbox"});return(0,n.jsxs)("div",{className:$()("",{"text-rose-600":!!i.error,checkbox:!0,disabled:i.disabled,required:i.required},s),children:[(0,n.jsx)("input",{checked:!!i.value,disabled:t,id:i.name,name:i.name,onChange:i.onChange,onBlur:i.onBlur,type:"checkbox",className:$()("h-4 w-4 rounded-xs border-slate-300 dark:border-slate-600 bg-white dark:!bg-slate-800 text-indigo-600 dark:text-slate-200 focus:ring-slate-800",l,e.className),...r}),(0,n.jsx)("label",{htmlFor:i.name,className:$()("text-sm text-slate-900 dark:text-slate-200",a,{"text-danger":!!i.error}),children:i.label})]})};var V=a(42043),D=a(62250),R=a(50899),q=a(65917),E=a(70728),F=a(25851),J=a(95002),O=a(24048),U=a(15796),L=a(9985),B=a(15968),Q=a(62206),z=a(564);function K(){let e=(0,L._)(["\n mutation UpdateProductCommerce(\n $productId: ID!\n $commerce: UpdateProductCommerceInput!\n ) {\n updateProductCommerce(productId: $productId, commerce: $commerce) {\n ...ProductDetailFragment\n }\n }\n ","\n"]);return K=function(){return e},e}let W=(0,B.J1)(K(),z.A),G=function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[],t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[];return t.length?e.map(e=>{let a=t.find(t=>{let{isoCode:a}=t;return a.toLowerCase()===e.currency.isoCode.toLowerCase()});return{countryCode:e.country.isoCode,currencyCode:e.currency.isoCode,isTaxable:!!e.isTaxable,isNetPrice:!!e.isNetPrice,amount:((e,t)=>{if(t<0)return"0";if(0===t)return e.toString();let a=e.toString();if("0"===a)return"0."+"0".repeat(t);let n=a.startsWith("-"),s=n?a.slice(1):a;if(s.length<=t){let e=s.padStart(t,"0");return"".concat(n?"-":"","0.").concat(e)}let l=s.length-t,r=s.slice(0,l),i=s.slice(l);return"".concat(n?"-":"").concat(r,".").concat(i)})(e.amount,null==a?void 0:a.decimals),maxQuantity:e.maxQuantity}}):[]},H=e=>{var t;let{productId:a,disabled:r=!1}=e,{formatMessage:i}=(0,s.A)(),{catalogPrices:d}=(0,U.A)({productId:a}),{hasRole:o}=(0,N.A)(),{updateProductCommerce:u}=(()=>{let[e]=(0,Q.n)(W),{currencies:t}=(0,P.A)();return{updateProductCommerce:async a=>{let{productId:n,commerce:{pricing:s}}=a;return e({variables:{productId:n,commerce:{pricing:s.map(e=>{let a=t.find(t=>{let{isoCode:a}=t;return a===e.currencyCode}),n=((e,t)=>{if(!e||t<0)return 0;let a=e.trim();if(!/^-?\d*\.?\d*$/.test(a))return 0;let n=a.indexOf(".");if(-1===n)return Number(a)*10**t;let s=a.slice(0,n)||"0";return Number(s+a.slice(n+1).slice(0,t).padEnd(t,"0"))})(e.amount.toString(),a.decimals);return{...e,amount:n}})}},refetchQueries:["Products"]})}}})(),{countries:c}=(0,I.A)(),{currencies:m}=(0,P.A)(),p=null==c?void 0:c.find(e=>{let{isBase:t}=e;return t}),x=null==p?void 0:p.isoCode,g=null==p||null==(t=p.defaultCurrency)?void 0:t.isoCode,f=async e=>{let{pricing:t}=e;return await u({productId:a,commerce:{pricing:t}}),{success:!0}},v=i({id:"saved",defaultMessage:"Saved"}),h=G(d,m),b=(0,J.A)({disabled:r,submit:f,successMessage:v,enableReinitialize:!0,initialValues:{pricing:[...(null==h?void 0:h.length)?h:[{maxQuantity:"",amount:null,isTaxable:!1,isNetPrice:!1,currencyCode:g,countryCode:x}]]}}),{values:j}=b.formik,{pricing:y}=j;return(0,n.jsx)("div",{children:(0,n.jsxs)("div",{className:"mt-5 md:col-span-3 lg:mt-0",children:[(0,n.jsx)(k.A,{children:(0,n.jsxs)(V.A,{className:"mt-3 rounded-md",form:b,disabled:!o(l._r.ManageProducts),children:[(0,n.jsxs)("div",{className:"relative max-w-full p-3 sm:px-5",children:[(0,n.jsx)("div",{className:"max-w-full justify-between align-baseline"}),(0,n.jsxs)("label",{className:"sr-only flex w-full font-sans text-sm text-slate-500 dark:text-slate-200 lg:not-sr-only",children:[(0,n.jsxs)("span",{className:"flex w-full",children:[(0,n.jsx)("span",{className:"w-full",children:i({id:"max_quantity",defaultMessage:"Max Quantity"})}),(0,n.jsx)("span",{className:"w-full lg:ml-5",children:i({id:"price",defaultMessage:"Price"})})]}),(0,n.jsxs)("span",{className:"flex w-full",children:[(0,n.jsx)("span",{className:"w-full lg:ml-8",children:i({id:"vat_suspect",defaultMessage:"Vat Suspect"})}),(0,n.jsx)("span",{className:"w-full lg:ml-12",children:i({id:"net_price",defaultMessage:"Net Price"})})]}),(0,n.jsxs)("span",{className:"mr-5 flex w-full",children:[(0,n.jsx)("span",{className:"ml-10 w-full",children:i({id:"country",defaultMessage:"Country"})}),(0,n.jsx)("span",{className:"w-full",children:i({id:"currency",defaultMessage:"Currency"})})]})]}),(0,n.jsx)(A.ED,{name:"pricing",children:e=>{let{push:t,remove:a}=e;return(0,n.jsxs)("div",{children:[j.pricing.map((e,t)=>(0,n.jsxs)("div",{className:"relative max-w-full border-b dark:border-slate-700 pt-1 pb-5 mb-3 align-baseline lg:flex",children:[(0,n.jsxs)("div",{className:"flex w-full gap-x-2",children:[(0,n.jsx)(E.A,{className:"w-full",disabled:!o(l._r.ManageProducts),validators:[(0,O.lw)(t,y),(0,O.IE)(y)],name:"pricing[".concat(t,"].maxQuantity"),id:"pricing[".concat(t,"].maxQuantity"),type:"number",min:0,hideLabel:!0,label:i({id:"max_quantity",defaultMessage:"Max Quantity"})}),(0,n.jsx)(E.A,{type:"number",className:"w-full",disabled:!o(l._r.ManageProducts),name:"pricing[".concat(t,"].amount"),id:"pricing[".concat(t,"].amount"),required:!0,hideLabel:!0,label:i({id:"price",defaultMessage:"Price "})})]}),(0,n.jsxs)("div",{className:"flex w-full gap-x-2 pt-3 pb-2",children:[(0,n.jsx)("div",{className:"w-full lg:ml-8 lg:items-center",children:(0,n.jsx)(T,{name:"pricing[".concat(t,"].isTaxable"),labelClassName:"lg:sr-only items-center ",disabled:!o(l._r.ManageProducts),label:i({id:"vat_suspect",defaultMessage:"Vat Suspect"}),className:"mr-2 h-4 w-4 rounded-sm border-slate-300 dark:border-slate-600 bg-white dark:!bg-slate-900 text-slate-950 focus:ring-slate-800 lg:items-center",type:"checkbox"})}),(0,n.jsx)("div",{className:"w-full lg:ml-8",children:(0,n.jsx)(T,{name:"pricing[".concat(t,"].isNetPrice"),labelClassName:"lg:sr-only items-center",disabled:!o(l._r.ManageProducts),label:i({id:"net_price",defaultMessage:"Net Price"}),hideLabel:!0,className:"mr-2 h-4 w-4 justify-between rounded-sm border-slate-300 dark:border-slate-600 bg-white dark:!bg-slate-900 text-slate-950 focus:ring-slate-800 lg:items-center",type:"checkbox"})})]}),(0,n.jsxs)("div",{className:"flex w-full gap-x-2 mt-1",children:[(0,n.jsx)(R.A,{defaultValue:x,className:"w-full lg:ml-4 lg:mr-4",label:i({id:"country",defaultMessage:"Country"}),name:"pricing[".concat(t,"].countryCode"),id:"pricing[".concat(t,"].countryCode"),disabled:!o(l._r.ManageProducts),required:!0,options:(0,M.A)(c,"isoCode","isoCode"),hideLabel:!0}),(0,n.jsx)(R.A,{defaultValue:g,className:"w-full lg:mr-8 ",label:i({id:"currency",defaultMessage:"Currency"}),disabled:!o(l._r.ManageProducts),name:"pricing[".concat(t,"].currencyCode"),id:"pricing[".concat(t,"].currencyCode"),required:!0,options:(0,M.A)(m,"isoCode","isoCode"),hideLabel:!0,placeholder:i({id:"country_currency",defaultMessage:"Currency"})})]}),o(l._r.ManageProducts)&&(0,n.jsx)("div",{className:"absolute -top-2 right-0 mt-0 mr-0 shrink-0 pb-1 md:mr-0 lg:mt-6 lg:py-0 lg:px-0 ",children:(0,n.jsx)("button",{className:"items-center rounded-full bg-white dark:bg-slate-900 px-1 py-1 text-sm text-rose-500 dark:text-rose-400 hover:bg-rose-50 focus:outline-hidden focus:ring-0 focus:ring-rose-500 focus:ring-offset-2",type:"button",onClick:()=>a(t),children:(0,n.jsxs)("svg",{className:"h-4 w-4",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,n.jsx)("polyline",{points:"3 6 5 6 21 6"}),(0,n.jsx)("path",{d:"M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6m3 0V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2"}),(0,n.jsx)("line",{x1:"10",y1:"11",x2:"10",y2:"17"}),(0,n.jsx)("line",{x1:"14",y1:"11",x2:"14",y2:"17"})]})})})]},t)),o(l._r.ManageProducts)&&(0,n.jsx)("div",{className:"mt-6",children:(0,n.jsx)(F.A,{variant:"tertiary",text:i({id:"add_price_row",defaultMessage:"Add Price Row"}),className:"w-full items-center justify-center",onClick:()=>t({maxQuantity:"",amount:null,isTaxable:!1,isNetPrice:!1,currencyCode:g,countryCode:x})})})]})}})]}),(0,n.jsx)(D.A,{displayFieldErrors:!0}),o(l._r.ManageProducts)&&(0,n.jsx)("div",{className:"-mx-6 p-6 bg-slate-50 dark:bg-slate-900 text-right",children:(0,n.jsx)(q.A,{className:"mx-6",label:i({id:"save",defaultMessage:"Save"})})})]})}),(0,n.jsx)("p",{className:"mt-6 mb-10 text-sm text-slate-500 dark:text-slate-400",children:i({id:"product_commerce_info",defaultMessage:"One price list should have a max quantity field empty and no price should have the same max quantity along with currency and country specified"})})]})})};var X=a(76087),Y=a(65459),Z=a(815);function ee(){let e=(0,L._)(["\n mutation UpdateProductTexts($productId: ID!, $texts: [ProductTextInput!]!) {\n updateProductTexts(productId: $productId, texts: $texts) {\n ...ProductTextsFragment\n }\n }\n ","\n"]);return ee=function(){return e},e}let et=(0,B.J1)(ee(),Z.A);var ea=a(70805),en=a(54640),es=a(71759),el=a(25191),er=a(74781),ei=a(17482);let ed=e=>{let{productId:t,disabled:a=!1}=e,{selectedLocale:r,setSelectedLocale:i,languageDialectList:d}=(0,er.A)(),{formatMessage:o}=(0,s.A)(),{hasRole:u}=(0,N.A)(),{defaultLocale:c,shopInfo:m,loading:p}=(0,ei.A)(),{translatedTexts:x}=(0,Y.A)({productId:t}),g=o({id:"saved",defaultMessage:"Saved"}),{updateProductTexts:f}=(()=>{let[e]=(0,Q.n)(et);return{updateProductTexts:async t=>{let{productId:a,texts:n}=t;return e({variables:{productId:a,texts:n},refetchQueries:["TranslatedProductTexts"]})}}})(),v=async e=>{let{slug:a,title:n,subtitle:s,vendor:l,description:i,brand:d,labels:o}=e;return await f({productId:t,texts:[{locale:r,slug:a,title:n,subtitle:s,vendor:l,description:i,brand:d,labels:o}]}),{success:!0}},h=(0,J.A)({disabled:a,submit:v,successMessage:g,initialValues:{slug:"",title:"",subtitle:"",vendor:"",description:"",brand:"",labels:[]}});return(0,w.useEffect)(()=>{let e=null==x?void 0:x.find(e=>e.locale===r);h.formik.setValues({slug:"",title:"",subtitle:"",vendor:"",description:"",brand:"",labels:[],...e||{}})},[x,r]),(0,w.useEffect)(()=>{if(m&&(null==x?void 0:x.length)&&(null==x||!x.find(e=>{let{locale:t}=e;return t===r})))if(c&&(null==x?void 0:x.find(e=>{let{locale:t}=e;return t===c})))i(c);else if(c&&(null==x?void 0:x.find(e=>{let{locale:t}=e;return t===c.split("-")[0]})))i(c.split("-")[0]);else{let e=null==x?void 0:x.find(e=>{let{locale:t}=e;return t&&(null==d?void 0:d.find(e=>{let{isoCode:a}=e;return a===t}))});i(null==e?void 0:e.locale)}},[p,x]),(0,n.jsx)(ea.A,{documentationLabel:o({id:"texts",defaultMessage:"Texts"}),className:"mt-2 lg:mt-5",documentation:(0,n.jsx)(X.A,{id:"product_text_form_description",defaultMessage:"<ul> <li><strong>Slug:</strong> The unique part of your product URL (e.g., 'my-awesome-product'). Keep it short and descriptive.</li> <li><strong>Localization:</strong> Switch languages using the dropdown at the top left to translate content for different markets.</li> <li><strong>Description:</strong> Supports Markdown and HTML formatting. Use double backslash (\\\\\\\\) for line breaks.</li> <li><strong>Labels:</strong> Eye-catching badges that appear on your product (e.g., 'New Arrival', '50% Off', 'Limited Edition'). Perfect for promotions and highlighting special features. Each language can have unique labels.</li> <li><strong>Key Difference:</strong> Labels are customer-facing promotional badges, while Tags are internal keywords for organization and filtering.</li> </ul>",values:{ul:e=>(0,n.jsxs)("ul",{className:"space-y-2",children:[e," "]}),li:e=>(0,n.jsxs)("li",{className:"text-sm",children:[e," "]},Math.random()),strong:e=>(0,n.jsx)("strong",{className:"font-semibold text-slate-800 dark:text-slate-200",children:e})}}),children:(0,n.jsx)(k.A,{children:(0,n.jsxs)(V.A,{form:h,disabled:!u(l._r.ManageProducts),children:[(0,n.jsxs)("div",{className:"relative text-slate-500 dark:text-slate-200 px-4 py-5 sm:p-6",children:[(0,n.jsxs)("div",{className:"grid grid-cols-6 gap-6",children:[(0,n.jsx)("div",{className:"col-span-6 sm:col-span-3",children:(0,n.jsx)(E.A,{name:"slug",disabled:!u(l._r.ManageProducts),required:!0,id:"slug",label:o({id:"slug",defaultMessage:"Slug"}),autoComplete:"on",className:"text-sm"})}),(0,n.jsx)("div",{className:"col-span-6 sm:col-span-3",children:(0,n.jsx)(E.A,{name:"title",disabled:!u(l._r.ManageProducts),required:!0,id:"title",label:o({id:"title",defaultMessage:"Title"}),autoComplete:"on",className:"text-sm"})}),(0,n.jsx)("div",{className:"col-span-6 sm:col-span-3",children:(0,n.jsx)(E.A,{name:"subtitle",disabled:!u(l._r.ManageProducts),id:"subtitle",label:o({id:"subtitle",defaultMessage:"Subtitle"}),autoComplete:"on",className:"text-sm"})}),(0,n.jsx)("div",{className:"col-span-6 sm:col-span-3",children:(0,n.jsx)(E.A,{name:"vendor",disabled:!u(l._r.ManageProducts),id:"vendor",label:o({id:"vendor",defaultMessage:"Vendor"}),autoComplete:"on",className:"text-sm"})}),(0,n.jsx)("div",{className:"col-span-6 sm:col-span-3",children:(0,n.jsx)(E.A,{name:"brand",disabled:!u(l._r.ManageProducts),id:"brand",label:o({id:"brand",defaultMessage:"Brand"}),autoComplete:"on",className:"text-sm"})}),(0,n.jsxs)("div",{className:"col-span-6 sm:col-span-3",children:[(0,n.jsx)(es.A,{name:"labels",id:"labels",disabled:!u(l._r.ManageProducts),label:o({id:"labels",defaultMessage:"Labels"}),placeholder:o({id:"label",defaultMessage:"Label"}),buttonText:o({id:"add",defaultMessage:"Add"}),autoComplete:"on",className:"text-sm"}),(0,n.jsx)(el.A,{messageKey:"product_labels_help",defaultMessage:"Add promotional badges like 'New Arrival', '50% Off', or 'Limited Edition' that customers will see on your product. Perfect for highlighting deals and special features.",className:"mt-3"})]})]}),(0,n.jsx)("div",{className:"col-span-6 mt-6 sm:col-span-3",children:(0,n.jsx)(en.A,{name:"description",id:"description",disabled:!u(l._r.ManageProducts),label:o({id:"description",defaultMessage:"Description"})})})]}),u(l._r.ManageProducts)&&(0,n.jsx)("div",{className:"border-t-slate-100 border-t dark:border-t-slate-700 bg-slate-50 dark:bg-slate-900 px-4 py-5 text-right sm:px-6",children:(0,n.jsx)(q.A,{label:o({id:"save",defaultMessage:"Save"})})})]})})})};var eo=a(32162),eu=a(81593),ec=a(85979),em=a(30059),ep=a(20367);function ex(){let e=(0,L._)(["\n mutation PrepareProductMediaUpload($mediaName: String!, $productId: ID!) {\n prepareProductMediaUpload(mediaName: $mediaName, productId: $productId) {\n _id\n putURL\n expires\n }\n }\n"]);return ex=function(){return e},e}let eg=(0,B.J1)(ex());var ef=a(70486),ev=a(13414);function eh(){let e=(0,L._)(["\n fragment ProductMediaFragment on ProductMedia {\n _id\n tags\n file {\n _id\n name\n type\n size\n url\n }\n sortKey\n texts {\n _id\n locale\n title\n subtitle\n }\n }\n"]);return eh=function(){return e},e}let eb=(0,B.J1)(eh());function ej(){let e=(0,L._)(["\n query ProductMedia($productId: ID, $slug: String) {\n product(productId: $productId, slug: $slug) {\n _id\n media {\n ...ProductMediaFragment\n }\n }\n }\n ","\n"]);return ej=function(){return e},e}let ey=(0,B.J1)(ej(),eb),e_=function(){var e;let{productId:t=null,slug:a=null}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},n=(0,ev.id)(a),{data:s,loading:l,error:r}=(0,ef.I)(ey,{skip:!t&&!n,variables:{productId:t||n}});return{productMedia:(null==s||null==(e=s.product)?void 0:e.media)||[],loading:l,error:r}};var ew=a(81090),eA=a(70556);function eN(){let e=(0,L._)(["\n fragment ProductMediaTextsFragment on ProductMediaTexts {\n _id\n locale\n title\n subtitle\n }\n"]);return eN=function(){return e},e}let ek=(0,B.J1)(eN());function eM(){let e=(0,L._)(["\n query TranslatedProductMediaTexts($productMediaId: ID!) {\n translatedProductMediaTexts(productMediaId: $productMediaId) {\n ...ProductMediaTextsFragment\n }\n }\n ","\n"]);return eM=function(){return e},e}let eI=(0,B.J1)(eM(),ek);function eP(){let e=(0,L._)(["\n mutation UpdateProductMediaTexts(\n $productMediaId: ID!\n $texts: [ProductMediaTextInput!]!\n ) {\n updateProductMediaTexts(productMediaId: $productMediaId, texts: $texts) {\n ...ProductMediaTextsFragment\n }\n }\n ","\n"]);return eP=function(){return e},e}let eC=(0,B.J1)(eP(),ek);var e$=a(62679);function eS(){let e=(0,L._)(["\n mutation RemoveProductMedia($productMediaId: ID!) {\n removeProductMedia(productMediaId: $productMediaId) {\n _id\n }\n }\n"]);return eS=function(){return e},e}let eT=(0,B.J1)(eS());var eV=a(16227);let eD=e=>{let{media:t,id:a}=e,{setModal:i}=(0,eV.A)(),{removeProductMedia:d}=(()=>{let[e]=(0,Q.n)(eT);return{removeProductMedia:async t=>{let{productMediaId:a}=t;return e({variables:{productMediaId:a},refetchQueries:["ProductMedia"]})}}})(),{formatMessage:o}=(0,s.A)(),{selectedLocale:u}=(0,er.A)(),{updateProductMediaTexts:c}=(()=>{let[e]=(0,Q.n)(eC);return{updateProductMediaTexts:async t=>{let{productMediaId:a,texts:n}=t;return e({variables:{productMediaId:a,texts:n},refetchQueries:["TranslatedProductMediaTexts"]})}}})(),[m,p]=(0,w.useState)(!1),{hasRole:x}=(0,N.A)(),{translatedMediaTexts:g}=(e=>{let{productMediaId:t}=e,{data:a,loading:n,error:s}=(0,ef.I)(eI,{skip:!t,variables:{productMediaId:t}});return{translatedMediaTexts:(null==a?void 0:a.translatedProductMediaTexts)||[],loading:n,error:s}})({productMediaId:t._id}),f=(null==g?void 0:g.find(e=>e.locale===u))||{},v=async e=>{await i((0,n.jsx)(e$.A,{onCancelClick:async()=>i(""),message:o({id:"delete_product_media_confirmation",defaultMessage:"This action might cause inconsistencies with other data that relates to it. Are you sure you want to delete this media? "}),onOkClick:async()=>{i(""),await d({productMediaId:e}),r.oR.success(o({id:"product_media_deleted",defaultMessage:"Media deleted successfully"}))},okText:o({id:"delete_product_media",defaultMessage:"Delete media"})}))},h=async e=>{let{title:a,subtitle:n}=e;return await c({productMediaId:t._id,texts:[{title:a,locale:u,subtitle:n}]}),p(!1),!0};return(0,n.jsx)(eA.A,{id:a,media:t,mediaText:f,isEdit:m,onDelete:x(l._r.ManageProducts)?v:void 0,onEdit:x(l._r.ManageProducts)?p:void 0,onUpdate:x(l._r.ManageProducts)?h:void 0})},eR=e=>{let{medias:t,items:a}=e,{formatMessage:l}=(0,s.A)();return(0,n.jsx)("div",{className:"rounded-md lg:col-span-6 px-6",children:(0,n.jsxs)("div",{className:"mx-auto overflow-hidden",children:[(0,n.jsx)("h2",{className:"sr-only",children:l({id:"product_media",defaultMessage:"Product Media"})}),(0,n.jsx)("div",{className:"flow-root",children:(0,n.jsx)(eu.gB,{items:a,strategy:eu._G,children:(0,n.jsx)("ul",{className:"flex flex-col gap-3 rounded-md transition-[background-color] ease-in-out delay-200 ",children:(null==t?void 0:t.length)?a.map(e=>{let a=Object.values(t).find(t=>t._id===e);return(0,n.jsx)(eD,{id:e,media:a},a._id)}):(0,n.jsx)(ew.A,{message:l({id:"media",defaultMessage:"Media"})})})})})]})})};function eq(){let e=(0,L._)(["\n mutation ReOrderProductMedia($sortKeys: [ReorderProductMediaInput!]!) {\n reorderProductMedia(sortKeys: $sortKeys) {\n _id\n }\n }\n"]);return eq=function(){return e},e}let eE=(0,B.J1)(eq()),eF=e=>{let{productId:t}=e,{productMedia:a}=e_({productId:t}),{formatMessage:i}=(0,s.A)(),{hasRole:d}=(0,N.A)(),{addProductMedia:o}=(()=>{let[e]=(0,Q.n)(eg),{confirmMediaUpload:t}=(0,ep.A)({refetchQueries:["Product"]});return{addProductMedia:async a=>{let{productId:n,media:s}=a,{data:l}=await e({variables:{productId:n,mediaName:s.name}}),{prepareProductMediaUpload:r}=l;return await (0,em.A)(s,r.putURL),t({mediaUploadTicketId:r._id,size:null==s?void 0:s.size,type:s.type})}}})(),{reOrderProductMedia:u}=(()=>{let[e]=(0,Q.n)(eE);return{reOrderProductMedia:async t=>{let{sortKeys:a}=t;return e({variables:{sortKeys:a},refetchQueries:["ProductMedia"]})}}})(),c=null==a?void 0:a.map(e=>e._id),m=async e=>{try{await o({productId:t,media:e}),r.oR.success(i({id:"product_media_upload",defaultMessage:"Media uploaded successfully"}))}catch(e){r.oR.error(i({id:"fail_upload",defaultMessage:"Media upload failed"}))}},p=async e=>{let{active:t,over:a}=e;if(t.id!==a.id){let e=c.indexOf(t.id),n=c.indexOf(a.id),s=(0,eu.be)(c,e,n).map((e,t)=>({productMediaId:e,sortKey:t}));try{await u({sortKeys:s}),r.oR.success(i({id:"link_reorder",defaultMessage:"Link reorder successfully"}))}catch(e){r.oR.error(i({id:"fail_reorder",defaultMessage:"Reordering failed, Try again!"}))}}else r.oR.info(i({id:"reorder_original",defaultMessage:"Reorder to original location"}))},x=(0,eo.FR)((0,eo.MS)(eo.AN,{activationConstraint:{distance:5}}),(0,eo.MS)(eo.uN,{coordinateGetter:eu.JR}));return(0,n.jsxs)("div",{className:"mx-auto mt-5 space-y-5 lg:space-y-0 max-w-full py-6 lg:grid lg:grid-cols-12 lg:gap-4",children:[d(l._r.ManageProducts)&&(0,n.jsx)("div",{className:"mx-auto w-full px-6 lg:col-span-6 lg:col-start-1",children:(0,n.jsx)(ec.A,{onlyDragAndDrop:!0,addMedia:m})}),(0,n.jsx)(eo.Mp,{sensors:x,collisionDetection:eo.fp,onDragEnd:p,children:(0,n.jsx)(eR,{medias:a,items:c})})]})};function eJ(){let e=(0,L._)(["\n fragment ProductPlanConfigurationFragment on ProductPlanConfiguration {\n usageCalculationType\n billingInterval\n trialInterval\n trialIntervalCount\n billingIntervalCount\n }\n"]);return eJ=function(){return e},e}let eO=(0,B.J1)(eJ());function eU(){let e=(0,L._)(["\n query ProductPlan($productId: ID, $slug: String) {\n product(productId: $productId, slug: $slug) {\n _id\n ... on PlanProduct {\n plan {\n ...ProductPlanConfigurationFragment\n }\n }\n }\n }\n ","\n"]);return eU=function(){return e},e}let eL=(0,B.J1)(eU(),eO),eB=function(){let{productId:e=null,slug:t=null}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},a=(0,ev.id)(t),{data:n,loading:s,error:l}=(0,ef.I)(eL,{skip:!e&&!a,variables:{productId:e||a}}),r=null==n?void 0:n.product;return{plan:null==r?void 0:r.plan,loading:s,error:l}};function eQ(){let e=(0,L._)(['\n query ProductPlanConfigurationOptions {\n usageCalculationTypes: __type(name: "ProductPlanUsageCalculationType") {\n options: enumValues {\n value: name\n label: description\n }\n }\n configurationIntervals: __type(name: "ProductPlanConfigurationInterval") {\n options: enumValues {\n value: name\n label: description\n }\n }\n }\n']);return eQ=function(){return e},e}let ez=(0,B.J1)(eQ());function eK(){let e=(0,L._)(["\n mutation UpdateProductPlan($productId: ID!, $plan: UpdateProductPlanInput!) {\n updateProductPlan(productId: $productId, plan: $plan) {\n _id\n }\n }\n"]);return eK=function(){return e},e}let eW=(0,B.J1)(eK()),eG=e=>{let{productId:t,disabled:a=!1}=e,{formatMessage:r}=(0,s.A)(),{configurationIntervals:i,usageCalculationTypes:d}=(()=>{var e,t;let{data:a,loading:n,error:s}=(0,ef.I)(ez),l=(null==a||null==(e=a.usageCalculationTypes)?void 0:e.options)||[];return{configurationIntervals:(null==a||null==(t=a.configurationIntervals)?void 0:t.options)||[],usageCalculationTypes:l,loading:n,error:s}})(),{plan:o,loading:u}=eB({productId:t}),{hasRole:c}=(0,N.A)(),{updateProductPlan:m}=(()=>{let[e]=(0,Q.n)(eW);return{updateProductPlan:async t=>{let{productId:a,plan:{usageCalculationType:n,billingInterval:s,billingIntervalCount:l=null,trialInterval:r=null,trialIntervalCount:i=null}}=t;return e({variables:{productId:a,plan:{usageCalculationType:n,billingInterval:s,billingIntervalCount:l,trialInterval:r,trialIntervalCount:i}},refetchQueries:["Products"]})}}})(),p=r({id:"enrollment_updated_successfully",defaultMessage:"Enrollment saved successfully"}),x=async e=>{let{trialInterval:a,trialIntervalCount:n,billingInterval:s,billingIntervalCount:l,usageCalculationType:r}=e;return await m({productId:t,plan:{billingInterval:s,usageCalculationType:r,billingIntervalCount:l,trialInterval:a,trialIntervalCount:n}}),{success:!0}},g=(0,J.A)({disabled:a,submit:x,successMessage:p,initialValues:{trialInterval:"",trialIntervalCount:"",billingInterval:"",billingIntervalCount:"",usageCalculationType:""},getSubmitErrorMessage:e=>{var t;return(null==e||null==(t=e.message)?void 0:t.includes("Status of the product does not allow this operation"))?r({id:"subscription_product_type_not_valid",defaultMessage:"Status of the product does not allow this operation"}):(null==e?void 0:e.message)||""}});return(0,w.useEffect)(()=>{o&&!u&&g.formik.setValues(o)},[o]),(0,n.jsx)(ea.A,{documentationLabel:r({id:"subscription",defaultMessage:"Subscription"}),className:"mt-2 lg:mt-5",documentation:(0,n.jsx)(X.A,{id:"product_subscription_form_description",defaultMessage:"<ul><li> Information that will be used to calculate price of a subscription based product </li> <li>The price specified in commerce section will be used when calculating fees on each interval. </li> <li>Price will not be included for the specified trial period </li> </ul>",values:{ul:e=>(0,n.jsxs)("ul",{className:"space-y-1",children:[e," "]}),li:e=>(0,n.jsx)("li",{children:e})}}),children:(0,n.jsx)(k.A,{children:(0,n.jsx)(V.A,{form:g,children:(0,n.jsxs)("div",{className:"relative max-w-full space-y-6 rounded-md sm:p-6",children:[(0,n.jsx)(R.A,{required:!0,className:"mt-2.5 w-full py-1.5 text-sm font-medium text-slate-500",label:r({id:"usage_calculation_type",defaultMessage:"Usage calculation type"}),placeholder:r({id:"usage_calculation_type",defaultMessage:"Usage calculation type"}),name:"usageCalculationType",options:(0,M.A)(d,"value","value")}),(0,n.jsxs)("div",{className:"w-full items-end justify-end sm:flex",children:[(0,n.jsx)(R.A,{className:"mt-2.5 w-full text-sm font-medium text-slate-500",required:!0,label:r({id:"billing_interval_unit",defaultMessage:"Billing interval unit"}),placeholder:r({id:"billing_interval_unit",defaultMessage:"Billing interval unit"}),name:"billingInterval",options:(0,M.A)(i,"value","value")}),(0,n.jsx)(E.A,{name:"billingIntervalCount",id:"billing_unit",type:"number",required:!0,label:r({id:"billing_unit",defaultMessage:"Billing Unit"}),placeholder:r({id:"billing_unit",defaultMessage:"Billing Unit"}),className:"mt-1 w-full text-sm font-medium text-slate-500 sm:ml-1"})]}),(0,n.jsxs)("div",{className:"max-w-full items-end justify-end sm:flex",children:[(0,n.jsx)(R.A,{className:"mt-2.5 w-full text-sm font-medium text-slate-500",label:r({id:"trial_interval_unit",defaultMessage:"Trial interval unit"}),placeholder:r({id:"trial_interval_unit",defaultMessage:"Trial interval unit"}),name:"trialInterval",options:(0,M.A)(i,"value","value")}),(0,n.jsx)(E.A,{type:"number",name:"trialIntervalCount",id:"trialIntervalCount ",label:r({id:"trial_unit",defaultMessage:"Trial Unit"}),placeholder:r({id:"trial_unit",defaultMessage:"Trial Unit"}),required:!0,className:"mt-1 w-full text-sm font-medium text-slate-500 sm:ml-1"})]}),c(l._r.CreateEnrollment)&&(0,n.jsx)("div",{className:"-mx-6 -mb-6 mt-6 border-t-slate-100 border-t space-y-6 bg-slate-50 dark:bg-slate-500 text-right sm:p-6",children:(0,n.jsx)(q.A,{label:r({id:"save",defaultMessage:"Save"})})})]})})})})};var eH=a(64115);function eX(){let e=(0,L._)(["\n query ProductSupply($productId: ID, $slug: String) {\n product(productId: $productId, slug: $slug) {\n _id\n ... on SimpleProduct {\n dimensions {\n ...ProductDimensionFragment\n }\n }\n }\n }\n ","\n"]);return eX=function(){return e},e}let eY=(0,B.J1)(eX(),eH.A),eZ=function(){let{productId:e=null,slug:t=null}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},a=(0,ev.id)(t),{data:n,loading:s,error:l}=(0,ef.I)(eY,{skip:!e&&!t,variables:{productId:e||a}}),r=null==n?void 0:n.product;return{dimensions:(null==r?void 0:r.dimensions)||{},loading:s,error:l}};function e0(){let e=(0,L._)(["\n mutation UpdateProductSupply(\n $productId: ID!\n $supply: UpdateProductSupplyInput!\n ) {\n updateProductSupply(productId: $productId, supply: $supply) {\n _id\n ... on SimpleProduct {\n dimensions {\n ...ProductDimensionFragment\n }\n }\n }\n }\n ","\n"]);return e0=function(){return e},e}let e1=(0,B.J1)(e0(),eH.A),e5=e=>{let{productId:t,disabled:a=!1}=e,{formatMessage:r}=(0,s.A)(),i=r({id:"saved",defaultMessage:"Saved"}),{hasRole:d}=(0,N.A)(),{updateProductSupply:o}=(()=>{let[e]=(0,Q.n)(e1);return{updateProductSupply:async t=>{let{productId:a,supply:{weightInGram:n=null,heightInMillimeters:s=null,lengthInMillimeters:l=null,widthInMillimeters:r=null}}=t;return e({variables:{productId:a,supply:{weightInGram:n||null,heightInMillimeters:s||null,lengthInMillimeters:l||null,widthInMillimeters:r||null}},refetchQueries:["Products"]})}}})(),{dimensions:u}=eZ({productId:t}),c=async e=>{let{weight:a,length:n,width:s,height:l}=e;return await o({productId:t,supply:{weightInGram:a,lengthInMillimeters:n,heightInMillimeters:l,widthInMillimeters:s}}),{success:!0}},m=(0,J.A)({disabled:a,submit:c,getSubmitErrorMessage:e=>(e.message.includes("supply.weightInGram")&&e.message.includes("Expected type Int")?m.formik.setFieldError("weight","Invalid value, only integer is accepted"):e.message.includes("supply.heightInMillimeters")&&e.message.includes("Expected type Int")?m.formik.setFieldError("height","Invalid value, only integer is accepted"):e.message.includes("supply.lengthInMillimeters")&&e.message.includes("Expected type Int")&&m.formik.setFieldError("length","Invalid value, only integer is accepted"),null),successMessage:i,initialValues:{weight:"",length:"",width:"",height:""}});return(0,w.useEffect)(()=>{Object.keys(u).length&&m.formik.setValues(u)},[u]),(0,n.jsx)("div",{className:"mt-5 md:col-span-2 md:mt-0",children:(0,n.jsx)(k.A,{children:(0,n.jsxs)(V.A,{form:m,disabled:!d(l._r.ManageProducts),children:[(0,n.jsx)("div",{className:"relative px-4 py-5 sm:p-6",children:(0,n.jsxs)("div",{className:"grid grid-cols-6 gap-6",children:[(0,n.jsx)("div",{className:"col-span-6 sm:col-span-3",children:(0,n.jsx)(E.A,{validators:[(0,O.L6)()],type:"number",name:"weight",disabled:!d(l._r.ManageProducts),id:"weight",label:r({id:"weight_gram",defaultMessage:"Weight (Gram)"}),className:"text-sm"})}),(0,n.jsx)("div",{className:"col-span-6 sm:col-span-3",children:(0,n.jsx)(E.A,{validators:[(0,O.L6)()],name:"length",disabled:!d(l._r.ManageProducts),id:"length",type:"number",label:r({id:"length_millimeter",defaultMessage:"Length (Millimeter)"}),className:"text-sm"})}),(0,n.jsx)("div",{className:"col-span-6 sm:col-span-3",children:(0,n.jsx)(E.A,{validators:[(0,O.L6)()],type:"number",name:"width",disabled:!d(l._r.ManageProducts),id:"width ",label:r({id:"width",defaultMessage:"Width (Millimeter)"}),className:"text-sm "})}),(0,n.jsx)("div",{className:"col-span-6 sm:col-span-3",children:(0,n.jsx)(E.A,{validators:[(0,O.L6)()],name:"height",disabled:!d(l._r.ManageProducts),type:"number",id:"height",label:r({id:"height",defaultMessage:"Height (Millimeter)"}),className:"text-sm "})})]})}),d(l._r.ManageProducts)&&(0,n.jsx)("div",{className:"border-t-slate-100 border-t dark:border-t-slate-700 space-y-6 bg-slate-50 dark:bg-slate-900 text-right sm:p-6",children:(0,n.jsx)(q.A,{label:r({id:"save",defaultMessage:"Save"}),full:!0})})]})})})};var e2=a(28248);function e6(){let e=(0,L._)(["\n mutation CreateProductVariation(\n $productId: ID!\n $variation: CreateProductVariationInput!\n $texts: [ProductVariationTextInput!]\n ) {\n createProductVariation(\n productId: $productId\n variation: $variation\n texts: $texts\n ) {\n _id\n }\n }\n"]);return e6=function(){return e},e}let e4=(0,B.J1)(e6());function e8(){let e=(0,L._)(["\n fragment ProductVariationFragment on ProductVariation {\n _id\n type\n key\n texts(forceLocale: $locale) {\n _id\n locale\n title\n subtitle\n }\n options {\n _id\n texts(forceLocale: $locale) {\n _id\n locale\n title\n subtitle\n }\n value\n }\n }\n"]);return e8=function(){return e},e}let e3=(0,B.J1)(e8());function e9(){let e=(0,L._)(["\n query ProductVariations($productId: ID, $slug: String, $locale: Locale) {\n product(productId: $productId, slug: $slug) {\n _id\n ... on ConfigurableProduct {\n variations {\n ...ProductVariationFragment\n }\n }\n }\n }\n ","\n"]);return e9=function(){return e},e}let e7=(0,B.J1)(e9(),e3),te=function(){let{productId:e=null,slug:t=null,locale:a=null}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},n=(0,ev.id)(t),{data:s,loading:l,error:r}=(0,ef.I)(e7,{skip:!e&&!n,variables:{productId:e||n,locale:a}}),i=null==s?void 0:s.product;return{variations:null==i?void 0:i.variations,loading:l,error:r}};function tt(){let e=(0,L._)(['\n query ProductVariationType {\n variationTypes: __type(name: "ProductVariationType") {\n options: enumValues {\n value: name\n label: description\n }\n }\n }\n']);return tt=function(){return e},e}let ta=(0,B.J1)(tt()),tn=e=>{let{helpKey:t,helpText:a,helpValues:s,...l}=e;return(0,n.jsxs)("div",{className:"space-y-1",children:[(0,n.jsx)(E.A,{...l}),(t||a)&&(0,n.jsx)(el.A,{messageKey:t||"".concat(l.name,"_help"),defaultMessage:a,values:s,className:"mt-1"})]})};var ts=a(40841);function tl(){let e=(0,L._)(["\n mutation RemoveProductVariation($productVariationId: ID!) {\n removeProductVariation(productVariationId: $productVariationId) {\n _id\n }\n }\n"]);return tl=function(){return e},e}let tr=(0,B.J1)(tl());var ti=a(65284);function td(){let e=(0,L._)(["\n mutation UpdateProductVariationTexts(\n $productVariationId: ID!\n $productVariationOptionValue: String\n $texts: [ProductVariationTextInput!]!\n ) {\n updateProductVariationTexts(\n productVariationId: $productVariationId\n productVariationOptionValue: $productVariationOptionValue\n texts: $texts\n ) {\n _id\n }\n }\n"]);return td=function(){return e},e}let to=(0,B.J1)(td()),tu=()=>{let[e]=(0,Q.n)(to);return{updateProductVariationTexts:async t=>{let{productVariationId:a,productVariationOptionValue:n,texts:s}=t;return e({variables:{productVariationId:a,productVariationOptionValue:n,texts:s},refetchQueries:["ProductVariations"]})}}},tc=e=>{var t,a,l,r,i;let{variation:d,onCancel:o,onSuccess:u}=e,{updateProductVariationTexts:c}=tu(),{formatMessage:m}=(0,s.A)(),{selectedLocale:p}=(0,er.A)(),x=async e=>{let{title:t,subtitle:a}=e;return await c({productVariationId:d._id,texts:[{title:t,subtitle:a,locale:p}]}),u(),{success:!0}},g=(0,J.A)({submit:x,initialValues:{title:null!=(r=null==d||null==(t=d.texts)?void 0:t.title)?r:"",subtitle:null!=(i=null==d||null==(a=d.texts)?void 0:a.subtitle)?i:""}});return(0,n.jsx)(V.A,{form:g,className:"variation-update-form bg-white dark:bg-slate-800 px-4 py-3 border-b border-slate-200 dark:border-slate-700 w-full overflow-x-hidden overflow-y-visible relative hover:outline hover:outline-2 hover:outline-slate-400 dark:hover:outline-slate-500 transition-all","data-variationid":d._id,children:(0,n.jsxs)("div",{className:"flex items-center justify-between w-full gap-4",tabIndex:-1,children:[(0,n.jsxs)("div",{className:"flex items-center gap-4 flex-1 min-w-0 overflow-hidden flex-wrap",children:[(0,n.jsx)("div",{className:"flex-shrink-0 min-w-[180px]",children:(0,n.jsx)(E.A,{className:"mt-0 py-1",name:"title",required:!0,label:m({id:"title",defaultMessage:"Title"})})}),(null==d?void 0:d.type)&&(0,n.jsx)(ti.A,{text:d.type,color:"slate",className:"rounded-md uppercase text-xs font-medium flex-shrink-0"}),(0,n.jsx)("div",{className:"text-sm text-slate-500 dark:text-slate-400 truncate min-w-[200px]",children:(0,n.jsx)(E.A,{className:"mt-0 py-1",name:"subtitle",label:m({id:"subtitle",defaultMessage:"Subtitle"})})}),(null==d||null==(l=d.options)?void 0:l.length)>0&&(0,n.jsx)("div",{className:"flex items-center gap-2 flex-wrap",children:d.options.map((e,t)=>{var a;return(0,n.jsx)("span",{className:"inline-flex text-nowrap items-center px-2 py-0.5 rounded-lg text-xs font-medium bg-slate-100 dark:bg-slate-900 text-slate-800 dark:text-slate-200 border border-slate-200 dark:border-slate-800",children:(null==e||null==(a=e.texts)?void 0:a.title)||e.value},e.value||t)})}),(0,n.jsxs)("div",{className:"text-sm text-slate-400 dark:text-slate-500 font-mono flex-shrink-0",children:["(",null==d?void 0:d.key,")"]})]}),(0,n.jsxs)("div",{className:"flex space-x-2 flex-shrink-0",children:[(0,n.jsx)(F.A,{onClick:o,type:"button",variant:"secondary",size:"sm",text:m({id:"cancel",defaultMessage:"Cancel"})}),(0,n.jsx)(F.A,{onClick:()=>g.formik.submitForm(),type:"submit",variant:"primary",size:"sm",text:m({id:"save",defaultMessage:"Save"})})]})]})})};var tm=a(87483),tp=a(17657),tx=a(64113),tg=a(69013);let tf=e=>{var t,a,l,r;let{type:i,variation:d,onEdit:o,onDelete:u}=e,[c,m]=(0,w.useState)(!1),{formatMessage:p}=(0,s.A)(),{buttonRef:x,menuRef:g,menuPosition:f}=((e,t)=>{let a=(0,w.useRef)(null),n=(0,w.useRef)(null),[s,l]=(0,w.useState)({top:0,left:0});return(0,w.useEffect)(()=>{let e=e=>{a.current&&!a.current.contains(e.target)&&t(!1)};return document.addEventListener("mousedown",e),()=>document.removeEventListener("mousedown",e)},[t]),(0,w.useEffect)(()=>{if(e&&n.current){let e=n.current.getBoundingClientRect(),t=e.bottom+4,a=e.right-192;a<8&&(a=8),t+80>window.innerHeight-8&&(t=e.top-80-4),l({top:t,left:a})}},[e]),{buttonRef:n,menuRef:a,menuPosition:s}})(c,m);return(0,n.jsx)("div",{className:"variation-display bg-white dark:bg-slate-800 px-4 py-3 border-b border-slate-200 dark:border-slate-700 w-full overflow-x-hidden overflow-y-visible relative hover:outline hover:outline-2 hover:outline-slate-400 dark:hover:outline-slate-500 transition-all",children:(0,n.jsxs)("div",{className:"flex items-center justify-between w-full gap-4",tabIndex:-1,children:[(0,n.jsxs)("div",{className:"flex items-center gap-4 flex-1 min-w-0 overflow-hidden",children:[(0,n.jsx)("div",{className:"flex-shrink-0 text-lg font-semibold text-slate-900 dark:text-slate-200 truncate",children:null==d||null==(t=d.texts)?void 0:t.title}),i&&(0,n.jsx)(ti.A,{text:i,color:"slate",className:"rounded-md uppercase text-xs font-medium flex-shrink-0"}),(null==d||null==(a=d.texts)?void 0:a.subtitle)&&(0,n.jsx)("div",{className:"text-sm text-slate-500 dark:text-slate-400 truncate",children:null==d||null==(l=d.texts)?void 0:l.subtitle}),(null==d||null==(r=d.options)?void 0:r.length)>0&&(0,n.jsx)("div",{className:"flex items-center gap-2 flex-wrap",children:d.options.map((e,t)=>{var a;return(0,n.jsx)("span",{className:"inline-flex text-nowrap items-center px-2 py-0.5 rounded-lg text-xs font-medium bg-slate-100 dark:bg-slate-900 text-slate-800 dark:text-slate-200 border border-slate-200 dark:border-slate-800",children:(null==e||null==(a=e.texts)?void 0:a.title)||e.value},e.value||t)})}),(0,n.jsxs)("div",{className:"text-sm text-slate-400 dark:text-slate-500 font-mono flex-shrink-0",children:["(",null==d?void 0:d.key,")"]})]}),(0,n.jsxs)("div",{className:"relative flex-shrink-0",children:[(0,n.jsx)("button",{ref:x,type:"button",onClick:e=>{e.stopPropagation(),e.preventDefault(),m(e=>!e)},className:"flex items-center justify-center w-8 h-8 rounded-md hover:bg-slate-100 dark:hover:bg-slate-700 transition-colors",children:(0,n.jsx)(tm.A,{className:"w-5 h-5 text-slate-500 dark:text-slate-400"})}),c&&(0,n.jsx)(tp.A,{children:(0,n.jsx)("div",{ref:g,className:"fixed w-48 bg-white dark:bg-slate-800 rounded-md shadow-xl border border-slate-200 dark:border-slate-700 z-[9999]",style:{top:f.top,left:f.left,boxShadow:"0 10px 25px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05)"},children:(0,n.jsxs)("div",{className:"py-1",children:[(0,n.jsxs)("button",{type:"button",onClick:e=>{e.stopPropagation(),e.preventDefault(),o(),m(!1)},className:"flex items-center w-full px-4 py-2 text-sm text-slate-700 dark:text-slate-200 hover:bg-slate-100 dark:hover:bg-slate-700 transition-colors",children:[(0,n.jsx)(tx.A,{className:"mr-3 h-5 w-5"}),p({id:"edit",defaultMessage:"Edit"})]}),(0,n.jsxs)("button",{type:"button",onClick:e=>{e.stopPropagation(),e.preventDefault(),u(d._id),m(!1)},className:"flex items-center w-full px-4 py-2 text-sm text-rose-600 dark:text-rose-400 hover:bg-rose-50 dark:hover:bg-rose-900/20 transition-colors",children:[(0,n.jsx)(tg.A,{className:"mr-3 h-5 w-5"}),p({id:"delete",defaultMessage:"Delete"})]})]})})})]})]})})},tv=e=>{let{type:t,variation:a,onDelete:s}=e,[l,r]=(0,w.useState)(!1);return l?(0,n.jsx)(tc,{variation:a,onCancel:()=>r(!1),onSuccess:()=>r(!1)}):(0,n.jsx)(tf,{type:t,variation:a,onEdit:()=>r(!0),onDelete:s})};function th(){let e=(0,L._)(["\n mutation CreateProductVariationOption(\n $productVariationId: ID!\n $option: String!\n $texts: [ProductVariationTextInput!]\n ) {\n createProductVariationOption(\n productVariationId: $productVariationId\n option: $option\n texts: $texts\n ) {\n _id\n }\n }\n"]);return th=function(){return e},e}let tb=(0,B.J1)(th());function tj(){let e=(0,L._)(["\n mutation RemoveProductVariationOption(\n $productVariationId: ID!\n $productVariationOptionValue: String!\n ) {\n removeProductVariationOption(\n productVariationId: $productVariationId\n productVariationOptionValue: $productVariationOptionValue\n ) {\n _id\n }\n }\n"]);return tj=function(){return e},e}let ty=(0,B.J1)(tj()),t_=e=>{let{onSubmit:t}=e,{formatMessage:a}=(0,s.A)(),{hasRole:r}=(0,N.A)(),i=a({id:"variation_option_added",defaultMessage:"Variation option added successfully!"}),d=(0,J.A)({submit:t,successMessage:i,initialValues:{value:"",title:""}});return(0,n.jsxs)(V.A,{form:d,className:"variation-option-form relative overflow-visible",children:[(0,n.jsx)("div",{className:"mb-4 px-2 sm:px-4 pt-2",children:(0,n.jsx)("div",{className:"p-3 bg-slate-50 dark:bg-slate-900/20 rounded-lg border border-slate-200 dark:border-slate-800",children:(0,n.jsx)("p",{className:"text-sm text-slate-800 dark:text-slate-200",children:a({id:"variation_options_explanation",defaultMessage:'Add individual choices for this variation (e.g., "Red", "Blue", "Green" for a Color variation)'})})})}),(0,n.jsxs)("div",{className:"grid lg:grid-cols-2 gap-3 px-2 sm:px-4 sm:pb-4",children:[(0,n.jsx)("div",{className:"col-span-1",children:(0,n.jsx)(tn,{className:"mt-2 pt-1",name:"title",label:a({id:"title",defaultMessage:"Title"}),helpText:a({id:"variation_option_title_help",defaultMessage:'Display name customers see (e.g., "Red", "Large", "Cotton")'}),required:!0})}),(0,n.jsx)("div",{className:"col-span-1",children:(0,n.jsx)(tn,{className:"mt-2 pt-1",name:"value",label:a({id:"value",defaultMessage:"Value"}),helpText:a({id:"variation_option_value_help",defaultMessage:'Internal identifier (e.g., "red", "large", "cotton")'}),required:!0})})]}),r(l._r.ManageProducts)&&(0,n.jsx)("div",{className:"text-right mt-2 px-6 pb-6",children:(0,n.jsx)(q.A,{className:"py-2.5",label:a({id:"add_variation_option",defaultMessage:"Add option"})})})]})};var tw=a(12067);let tA=e=>{var t,a,l,r;let{option:i,onDelete:d,variationId:o}=e,{formatMessage:u}=(0,s.A)(),{selectedLocale:c}=(0,er.A)(),[m,p]=(0,w.useState)(!1),x=u({id:"variation_option_updated",defaultMessage:"Variation option updated successfully!"}),{updateProductVariationTexts:g}=tu(),f=async e=>{let{title:t,subtitle:a}=e,n=await g({productVariationId:o,productVariationOptionValue:i.value,texts:[{title:t,subtitle:a,locale:c}]});return p(!1),{data:n,success:!0}},v=(0,J.A)({submit:f,successMessage:x,initialValues:{title:null==i||null==(t=i.texts)?void 0:t.title,subtitle:null==i||null==(a=i.texts)?void 0:a.subtitle}});return(0,n.jsx)(V.A,{form:v,className:"last:pb-2 variation-option-update-form relative overflow-visible",children:(0,n.jsx)("div",{className:"my-2 rounded-sm border dark:border-slate-700 mx-4 ",children:(0,n.jsx)("div",{className:"p-2 bg-white dark:bg-slate-900 dark:text-slate-200",children:(0,n.jsxs)("div",{className:"flex gap-2 w-full items-center justify-between",children:[(0,n.jsx)(ti.A,{text:null==i?void 0:i.value,color:"slate",className:"rounded-md"}),(0,n.jsxs)("div",{className:"flex items-center gap-4 w-full",children:[(0,n.jsx)("p",{className:"truncate text-sm font-medium text-slate-900 dark:text-slate-400",children:m?(0,n.jsx)(E.A,{className:"mt-0",name:"title",required:!0,label:u({id:"title",defaultMessage:"Title"})}):null==i||null==(l=i.texts)?void 0:l.title}),(0,n.jsx)("p",{className:"truncate text-sm text-slate-500",children:m?(0,n.jsx)(E.A,{className:"mt-0",name:"subtitle",label:u({id:"subtitle",defaultMessage:"Subtitle"})}):null==i||null==(r=i.texts)?void 0:r.subtitle})]}),(0,n.jsx)("div",{className:"flex items-center justify-end ml-auto",children:m?(0,n.jsxs)("div",{className:"flex space-x-2 py-2",children:[(0,n.jsx)("button",{onClick:()=>p(!m),"aria-label":u({id:"cancel",defaultMessage:"Cancel"}),type:"button",className:"inline-flex items-center justify-center font-medium shadow-sm focus:outline-hidden focus:ring-2 focus:ring-offset-2 transition-colors duration-200 disabled:cursor-not-allowed disabled:opacity-50 px-3 py-2 text-sm h-8 rounded-md border border-slate-300 dark:border-slate-600 bg-white dark:bg-slate-800 text-slate-700 dark:text-slate-200 hover:bg-slate-50 dark:hover:bg-slate-700 focus:ring-slate-500",children:u({id:"cancel",defaultMessage:"Cancel"})}),(0,n.jsx)("button",{type:"submit","aria-label":u({id:"save",defaultMessage:"Save"}),className:"inline-flex items-center justify-center font-medium shadow-sm focus:outline-hidden focus:ring-2 focus:ring-offset-2 transition-colors duration-200 disabled:cursor-not-allowed disabled:opacity-50 px-3 py-2 text-sm h-8 rounded-md border border-slate-800 dark:border-slate-600 bg-slate-800 dark:bg-slate-600 text-white hover:bg-slate-900 dark:hover:bg-slate-500 focus:ring-slate-800 dark:focus:ring-slate-400",children:u({id:"save",defaultMessage:"Save"})})]}):(0,n.jsx)(tw.A,{onEdit:()=>{p(!0)},onDelete:()=>{d(i.value)},showEdit:!0,showDelete:!0})})]})})})})},tN=e=>{let{variationId:t,options:a}=e,{createProductVariationOption:l}=(()=>{let[e]=(0,Q.n)(tb);return{createProductVariationOption:async t=>{let{productVariationId:a,option:n,texts:s}=t;return e({variables:{productVariationId:a,option:n,texts:s},refetchQueries:["ProductVariations","Product"]})}}})(),{formatMessage:i}=(0,s.A)(),{selectedLocale:d}=(0,er.A)(),{setModal:o}=(0,eV.A)(),{removeProductVariationOption:u}=(()=>{let[e]=(0,Q.n)(ty);return{removeProductVariationOption:async t=>{let{productVariationId:a,productVariationOptionValue:n}=t;return e({variables:{productVariationId:a,productVariationOptionValue:n},refetchQueries:["ProductVariations"]})}}})(),c=async e=>{await o((0,n.jsx)(e$.A,{message:i({id:"delete_variation_option_confirmation",defaultMessage:"This action might cause inconsistencies with other data that relates to it. Are you sure you want to delete this option? "}),onCancelClick:()=>o(""),onOkClick:async()=>{o(""),await u({productVariationId:t,productVariationOptionValue:e}),r.oR.success(i({id:"product_variation_option_deleted",defaultMessage:"Variation option deleted successfully"}))},okText:i({id:"delete_variation_option",defaultMessage:"Delete option"})}))},m=async e=>{let{value:a,title:n}=e;return await l({productVariationId:t,option:a,texts:[{title:n,locale:d}]}),{success:!0}};return(0,n.jsxs)("div",{className:"relative overflow-visible",children:[(0,n.jsx)(t_,{onSubmit:m}),a.length?a.map(e=>(0,n.jsx)(tA,{variationId:t,option:e,onDelete:c},e._id)):(0,n.jsx)(ew.A,{message:i({id:"option",defaultMessage:"Option"})})]})},tk=e=>{let{productVariationId:t,variation:a}=e,{formatMessage:l}=(0,s.A)(),{setModal:i}=(0,eV.A)(),{options:d}=a,{removeProductVariation:o}=(()=>{let[e]=(0,Q.n)(tr);return{removeProductVariation:async t=>{let{productVariationId:a}=t;return e({variables:{productVariationId:a},refetchQueries:["ProductVariations"]})}}})(),u=async()=>{await i((0,n.jsx)(e$.A,{onCancelClick:async()=>i(""),message:l({id:"delete_product_variation_confirmation",defaultMessage:"This action might cause inconsistencies with other data that relates to it. Are you sure you want to delete this variation? "}),onOkClick:async()=>{i(""),await o({productVariationId:t}),r.oR.success(l({id:"product_variation_deleted",defaultMessage:"Variation deleted successfully"}))},okText:l({id:"delete_product_variation",defaultMessage:"Delete variation"})}))},c=[{header:(0,n.jsx)(tv,{onDelete:u,variation:a,...a}),body:(0,n.jsx)(tN,{variationId:a._id,options:d},t)}];return(0,n.jsx)(ts.A,{"data-variationid":a._id,data:c,containerCSS:"w-full max-w-full !my-0 !border-0 !shadow-none relative",bodyCSS:"bg-slate-50 dark:bg-slate-950 !border-t-0 relative overflow-visible",itemContainerCSS:"!mt-0 !mb-0 !border-0",headerCSS:"w-full flex items-center justify-between !p-0 !bg-transparent !border-0",hideChevron:!0})},tM=e=>{let{onSubmit:t,disabled:a,formatMessage:s}=e,{variationTypes:r}=(()=>{var e;let{data:t,loading:a,error:n}=(0,ef.I)(ta);return{variationTypes:(null==t||null==(e=t.variationTypes)?void 0:e.options)||[],loading:a,error:n}})(),{hasRole:i}=(0,N.A)(),d=s({id:"product_variation_added",defaultMessage:"Product variation added successfully"}),o=(0,J.A)({disabled:a,submit:t,successMessage:d,initialValues:{title:"",key:"",type:""}});return(0,n.jsxs)("div",{children:[(0,n.jsxs)("div",{className:"mb-6",children:[(0,n.jsx)("h3",{className:"text-lg font-semibold text-slate-900 dark:text-slate-100 mb-2",children:s({id:"product_variations_explanation_title",defaultMessage:"About Product Variations"})}),(0,n.jsx)("p",{className:"text-sm text-slate-600 dark:text-slate-400",children:s({id:"product_variations_explanation",defaultMessage:"Variations allow customers to choose different options for your product (like color, size, material). Each variation can have multiple options that customers can select from."})})]}),(0,n.jsxs)(V.A,{form:o,children:[(0,n.jsxs)("div",{className:"space-y-6",children:[(0,n.jsx)(tn,{name:"title",id:"title",label:s({id:"title",defaultMessage:"Title"}),helpText:s({id:"product_variation_title_help",defaultMessage:'The display name customers will see (e.g., "Color", "Size", "Material")'}),required:!0,autoComplete:"on",className:"w-full"}),(0,n.jsx)(tn,{name:"key",id:"key",label:s({id:"key",defaultMessage:"Key"}),helpText:s({id:"product_variation_key_help",defaultMessage:'Unique identifier used internally (e.g., "color", "size"). Use lowercase without spaces.'}),required:!0,autoComplete:"on",className:"w-full"}),(0,n.jsxs)("div",{children:[(0,n.jsx)(R.A,{required:!0,className:"w-full",label:s({id:"type",defaultMessage:"Type"}),placeholder:s({id:"type",defaultMessage:"Type"}),name:"type",options:(0,M.A)(r,"value","value")}),(0,n.jsx)(el.A,{messageKey:"product_variation_type_help",defaultMessage:"COLOR: For predefined options like colors or sizes. TEXT: For free-form input like custom text or measurements.",className:"mt-1"})]})]}),i(l._r.ManageProducts)&&(0,n.jsx)("div",{className:"flex justify-end mt-6 py-6 -mb-6 bg-slate-100 -mx-6 pe-5 border-t border-slate-200 dark:border-slate-700 bg-slate-50 dark:bg-slate-900",children:(0,n.jsx)(q.A,{label:s({id:"add_variation",defaultMessage:"Add variation"})})})]})]})},tI=e=>{let{productId:t,disabled:a=!1}=e,{createProductVariation:l}=(()=>{let[e]=(0,Q.n)(e4);return{createProductVariation:async t=>{let{productId:a,variation:{key:n,type:s},texts:l}=t;return e({variables:{productId:a,variation:{key:n,type:s},texts:l},refetchQueries:["ProductVariations"]})}}})(),{selectedLocale:r}=(0,er.A)(),{formatMessage:i}=(0,s.A)(),{setModal:o}=(0,eV.A)(),{variations:u,loading:c}=te({productId:t,locale:r}),m=async e=>{let{title:a,key:n,type:s}=e;return await l({productId:t,variation:{key:n,type:s},texts:[{title:a,locale:r}]}),o(""),{success:!0}};return c?(0,n.jsx)(d.A,{}):(0,n.jsxs)("div",{className:"mt-6 overflow-hidden rounded-md w-full max-w-full",children:[(0,n.jsx)("div",{className:"mb-6 flex justify-end items-center",children:(0,n.jsx)(F.A,{className:"m-1",onClick:()=>{o((0,n.jsx)(tM,{onSubmit:m,disabled:a,formatMessage:i}))},disabled:a,variant:"secondary",icon:(0,n.jsx)(e2.A,{className:"w-5 h-5"}),text:i({id:"add_variation",defaultMessage:"Add variation"})})}),(0,n.jsx)("div",{className:"flex flex-col border border-slate-200 dark:border-slate-700 rounded-md overflow-x-hidden overflow-y-visible w-full relative",children:(null==u?void 0:u.length)?null==u?void 0:u.map(e=>(0,n.jsx)(tk,{productVariationId:e._id,variation:e},e._id)):(0,n.jsx)(ew.A,{message:i({id:"variations",defaultMessage:"Variations"})})})]})};function tP(){let e=(0,L._)(["\n query ProductWarehousing($productId: ID, $slug: String) {\n product(productId: $productId, slug: $slug) {\n _id\n ... on SimpleProduct {\n sku\n baseUnit\n }\n }\n }\n"]);return tP=function(){return e},e}let tC=(0,B.J1)(tP()),t$=function(){let{productId:e=null,slug:t=null}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},a=(0,ev.id)(t),{data:n,loading:s,error:l}=(0,ef.I)(tC,{skip:!e&&!a,variables:{productId:e||a}});return{product:(null==n?void 0:n.product)||{},loading:s,error:l}};function tS(){let e=(0,L._)(["\n mutation UpdateProductWarehousing(\n $productId: ID!\n $warehousing: UpdateProductWarehousingInput!\n ) {\n updateProductWarehousing(productId: $productId, warehousing: $warehousing) {\n _id\n ... on SimpleProduct {\n sku\n baseUnit\n }\n }\n }\n"]);return tS=function(){return e},e}let tT=(0,B.J1)(tS()),tV=e=>{let{productId:t,disabled:a=!1}=e,{formatMessage:r}=(0,s.A)(),{product:i}=t$({productId:t}),{hasRole:d}=(0,N.A)(),{updateProductWarehousing:o}=(()=>{let[e]=(0,Q.n)(tT);return{updateProductWarehousing:async t=>{let{productId:a,warehousing:{sku:n=null,baseUnit:s=null}}=t;return e({variables:{productId:a,warehousing:{sku:n,baseUnit:s}},refetchQueries:["Products"]})}}})(),u=r({id:"saved",defaultMessage:"Saved"}),c=async e=>{let{sku:a,baseUnit:n}=e;return{data:await o({productId:t,warehousing:{baseUnit:n,sku:a}}),success:!0}},m=(0,J.A)({disabled:a,submit:c,successMessage:u,initialValues:{sku:"",baseUnit:""}});return(0,w.useEffect)(()=>{Object.keys(i).length&&m.formik.setValues({...i})},[i]),(0,n.jsx)("div",{className:"mt-5 md:mt-0",children:(0,n.jsx)(k.A,{children:(0,n.jsxs)(V.A,{className:"rounded",form:m,disabled:!d(l._r.ManageProducts),children:[(0,n.jsx)("div",{className:"relative px-4 pb-5 sm:p-6",children:(0,n.jsxs)("div",{className:"w-full justify-between align-baseline lg:flex gap-6",children:[(0,n.jsx)(E.A,{name:"sku",disabled:!d(l._r.ManageProducts),id:"sku",label:r({id:"sku",defaultMessage:"SKU"}),className:"mb-4 text-sm"}),(0,n.jsx)(E.A,{name:"baseUnit",id:"baseUnit",disabled:!d(l._r.ManageProducts),label:r({id:"baseUnit",defaultMessage:"Base Unit"}),className:"text-sm"})]})}),d(l._r.ManageProducts)&&(0,n.jsx)("div",{className:"border-t-slate-100 border-t dark:border-t-slate-700 space-y-6 bg-slate-50 dark:bg-slate-900 text-right sm:p-6",children:(0,n.jsx)(q.A,{label:r({id:"save",defaultMessage:"Save"})})})]})})})};var tD=a(2060),tR=a(55873);function tq(){let e=(0,L._)(["\n query ProductReviewByProduct(\n $productId: ID\n $slug: String\n $limit: Int\n $offset: Int\n $sort: [SortOptionInput!]\n ) {\n product(productId: $productId, slug: $slug) {\n _id\n reviews(limit: $limit, offset: $offset, sort: $sort) {\n ...ProductReviewDetailFragment\n }\n reviewsCount\n }\n }\n ","\n"]);return tq=function(){return e},e}let tE=(0,B.J1)(tq(),tR.A),tF=function(){let{productId:e=null,slug:t=null,limit:a=10,offset:n=0,sort:s=[{key:"created",value:l.t4.Desc}]}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},{data:r,loading:i,error:d,fetchMore:o}=(0,ef.I)(tE,{skip:!e,variables:{productId:e,slug:t,limit:a,offset:n,sort:s}}),u=null==r?void 0:r.product,c=(null==u?void 0:u.reviews)||[];return{productReviews:c,loading:i,error:d,reviewsCount:(null==u?void 0:u.reviewsCount)||0,loadMore:()=>{o({variables:{offset:null==c?void 0:c.length}})}}};var tJ=a(99380),tO=a(26512),tU=a(94129),tL=a(43419);let tB=e=>{let{productReviews:t}=e,{formatMessage:a}=(0,s.A)(),l=t.reduce((e,t)=>e+t.upVote,0),r=t.reduce((e,t)=>e+t.downVote,0),i=l?l/(l+r)*100:0,d=i?100-i:0;return(0,n.jsxs)("div",{className:"lg:col-span-4",children:[(0,n.jsx)("h2",{className:"text-2xl",children:a({id:"customer_reviews",defaultMessage:"Customer Reviews"})}),(0,n.jsxs)("div",{className:"mt-3 flex items-center",children:[(0,n.jsx)("div",{children:(0,n.jsx)("div",{title:"".concat(i),className:"flex items-center",children:[0,1,2,3,4].map(e=>{let t=i>=20*e;return(0,n.jsx)(tL.A,{className:"\n ".concat(t?"text-amber-400":"text-slate-300 dark:text-slate-600","\n h-5 w-5 shrink-0\n "),"aria-hidden":"true"},e)})})}),(0,n.jsx)("div",{className:"ml-2 text-sm",children:(0,n.jsx)(X.A,{id:"review_summary",defaultMessage:"<div> Based on <cta> {total} </cta> reviews</div>",values:{div:e=>(0,n.jsx)("div",{children:e}),cta:e=>(0,n.jsx)("b",{className:"font-semibold",children:e}),total:t.length}})})]}),(0,n.jsxs)("div",{className:"mt-6",children:[(0,n.jsx)("h3",{className:"sr-only",children:a({id:"review_data",defaultMessage:"Review data"})}),(0,n.jsxs)("dl",{className:"space-y-3",children:[(0,n.jsxs)("div",{className:"flex items-center text-sm",children:[(0,n.jsxs)("dt",{className:"flex flex-1 items-center",children:[(0,n.jsx)("p",{className:"font-medium",children:l}),(0,n.jsxs)("div",{"aria-hidden":"true",className:"ml-2 flex flex-1 items-center",children:[(0,n.jsx)(tO.A,{className:"\n ".concat(l>0?"text-emerald-500":"text-slate-500","\n h-5 w-5 shrink-0"),"aria-hidden":"true"}),(0,n.jsxs)("div",{className:"relative ml-3 flex-1",children:[(0,n.jsx)("div",{className:"h-3 rounded-full border border-slate-300 dark:border-slate-800 bg-slate-50 dark:bg-slate-900"}),l>0?(0,n.jsx)("div",{className:"absolute inset-y-0 rounded-full border border-emerald-500 bg-emerald-500",style:{width:"calc(".concat(i,"%)")}}):null]})]})]}),(0,n.jsxs)("dd",{className:"ml-3 w-10 text-right text-sm tabular-nums",children:[Math.round(i),"%"]})]}),(0,n.jsxs)("div",{className:"flex items-center text-sm",children:[(0,n.jsxs)("dt",{className:"flex flex-1 items-center",children:[(0,n.jsxs)("p",{className:"font-medium",children:[r,(0,n.jsx)("span",{className:"sr-only",children:a({id:"star_reviews",defaultMessage:"Star reviews"})})]}),(0,n.jsxs)("div",{"aria-hidden":"true",className:"ml-2 flex flex-1 items-center",children:[(0,n.jsx)(tU.A,{className:"\n ".concat(r>0?"text-rose-500":"text-slate-500","\n h-5 w-5 shrink-0\n "),"aria-hidden":"true"}),(0,n.jsxs)("div",{className:"relative ml-3 flex-1",children:[(0,n.jsx)("div",{className:"h-3 rounded-full border border-slate-300 dark:border-slate-800 bg-slate-50 dark:bg-slate-900"}),r>0?(0,n.jsx)("div",{className:"absolute inset-y-0 rounded-full border border-rose-500 bg-rose-500",style:{width:"calc(".concat(d,"%)")}}):null]})]})]}),(0,n.jsxs)("dd",{className:"ml-3 w-10 text-right text-sm tabular-nums",children:[Math.round(d),"%"]})]})]})]})]})};var tQ=a(90689);let tz=e=>{let{onSubmit:t,onSubmitSuccess:a=null,defaultValue:r={},isEdit:i=!1}=e,{formatMessage:d}=(0,s.A)(),{hasRole:o}=(0,N.A)(),u=d({id:"product_review_added",defaultMessage:"Review added successfully!"}),c=d({id:"product_review_updated",defaultMessage:"Review updated successfully!"}),m=(0,J.A)({submit:t,onSubmitSuccess:a,successMessage:i?c:u,initialValues:{title:"",review:"",rating:1,...r}});return(0,n.jsxs)("div",{className:"bg-white dark:bg-slate-800 rounded-md shadow-sm overflow-hidden p-6 mb-6",children:[(0,n.jsx)("h3",{className:"text-lg font-semibold text-slate-900 dark:text-slate-100 mb-4",children:d({id:"write_review",defaultMessage:"Write a Review"})}),(0,n.jsxs)(V.A,{form:m,children:[(0,n.jsxs)("div",{className:"space-y-4",children:[(0,n.jsx)(E.A,{name:"title",disabled:!o(l._r.ReviewProduct),id:"title",label:d({id:"title",defaultMessage:"Title"}),autoComplete:"off",required:!0}),(0,n.jsx)(tQ.A,{rows:4,name:"review",disabled:!o(l._r.ReviewProduct),id:"review",label:d({id:"review",defaultMessage:"Review"}),placeholder:d({id:"review_placeholder",defaultMessage:"Share your thoughts about this product..."})})]}),o(l._r.ReviewProduct)&&(0,n.jsx)("div",{className:"mt-6 flex justify-end",children:(0,n.jsx)(q.A,{label:d(i?{id:"update_review",defaultMessage:"Update Review"}:{id:"add_review",defaultMessage:"Add Review"}),className:"px-6 py-2"})})]})]})};function tK(){let e=(0,L._)(["\n mutation CreateProductReview(\n $productId: ID!\n $productReview: ProductReviewInput!\n ) {\n createProductReview(productId: $productId, productReview: $productReview) {\n ...ProductReviewDetailFragment\n }\n }\n ","\n"]);return tK=function(){return e},e}let tW=(0,B.J1)(tK(),tR.A),tG=e=>{let{productId:t}=e,{productReviews:a,loadMore:l,reviewsCount:r}=tF({productId:t}),{createProductReview:i}=(()=>{let[e]=(0,Q.n)(tW);return{createProductReview:async t=>{let{productId:a,productReview:{title:n,rating:s,review:l}}=t;return e({variables:{productId:a,productReview:{title:n,rating:s,review:l}},refetchQueries:["ProductReviewByProduct","ProductReviewByUser"]})}}})(),{formatMessage:d}=(0,s.A)();return(0,n.jsxs)("div",{className:"sm:max-w-full",children:[(0,n.jsx)("div",{className:"text-slate-900 dark:text-slate-200",children:(0,n.jsxs)("div",{className:"mx-auto p-2 lg:grid lg:max-w-7xl lg:grid-cols-12 lg:gap-x-8",children:[(0,n.jsx)(tB,{productReviews:a}),(0,n.jsxs)("div",{className:"mt-16 lg:col-span-7 lg:col-start-6 lg:mt-0",children:[t&&(0,n.jsx)(tz,{onSubmit:async e=>{let{title:a,review:n,rating:s}=e;return await i({productId:t,productReview:{title:a,review:n,rating:10}})}}),(0,n.jsx)("h3",{className:"sr-only",children:d({id:"recent_reviews",defaultMessage:"Recent reviews"})}),(0,n.jsx)("div",{className:"flow-root",children:(0,n.jsx)("div",{className:"-my-3",children:a.map(e=>(0,n.jsx)(tJ.A,{review:e},e._id))})})]})]})}),r>(null==a?void 0:a.length)?(0,n.jsx)(F.A,{text:d({id:"load-more-reviews",defaultMessage:"Load reviews"}),onClick:l}):null]})};var tH=a(26274);function tX(){let e=(0,L._)(["\n mutation CreateProductBundleItem(\n $productId: ID!\n $item: CreateProductBundleItemInput!\n ) {\n createProductBundleItem(productId: $productId, item: $item) {\n _id\n }\n }\n"]);return tX=function(){return e},e}let tY=(0,B.J1)(tX());var tZ=a(52536),t0=a(73018),t1=a(51599);let t5=function(e){let{onSuccess:t}=e,{selectedLocale:a}=(0,er.A)(),{createProduct:n}=(0,t1.A)(),{formatMessage:r}=(0,s.A)();return async e=>{let{title:s,type:i,quantity:d=1}=e,o=[{title:s,slug:s.toLowerCase().replace(/\s+/g,"-"),locale:a}],{data:u}=await n({product:{type:i||l.ln.SimpleProduct},texts:o}),c=null==u?void 0:u.createProduct;if(!(null==c?void 0:c._id))throw Error(r({id:"product_creation_failed",defaultMessage:"Product creation failed"}));return null==t||t(c,d),{success:!0}}},t2=e=>{let{bundleProduct:t,onSuccess:a}=e,{formatMessage:r}=(0,s.A)(),{hasRole:i}=(0,N.A)(),d=t5({onSuccess:a}),o=(0,w.useMemo)(()=>{var e,a;let n=null!=(a=null==t||null==(e=t.texts)?void 0:e.title)?a:"";return"".concat(n," - New Bundle Item")},[t]),u=async e=>{let{title:t,type:a,quantity:n}=e;try{return await d({title:t,type:a,quantity:n}),{success:!0}}catch(e){return{success:!1,error:{message:null==e?void 0:e.message}}}},c=r({id:"bundle-item-scaffolded-success",defaultMessage:"New product scaffolded and added to bundle successfully"}),m=(0,J.A)({submit:u,successMessage:c,enableReinitialize:!0,initialValues:{title:o,type:l.ln.SimpleProduct,quantity:1}});return(0,n.jsxs)(V.A,{className:"mt-4 rounded-md border border-slate-200 dark:border-slate-700",form:m,children:[(0,n.jsxs)("div",{className:"p-5 flex flex-col gap-3",children:[(0,n.jsx)("h3",{className:"text-md font-semibold text-slate-800 dark:text-slate-100",children:r({id:"scaffold_bundle_item_title",defaultMessage:"Scaffold New Bundle Item"})}),(0,n.jsx)(E.A,{name:"title",id:"title",label:r({id:"name",defaultMessage:"Name"}),required:!0,className:"block w-full rounded-md border-slate-300 dark:border-slate-800 text-sm"}),(0,n.jsx)(R.A,{className:"mt-1 w-full",label:r({id:"type",defaultMessage:"Type"}),placeholder:r({id:"type",defaultMessage:"Type"}),required:!0,name:"type",options:Object.fromEntries(Object.entries(l.ln).filter(e=>{let[t,a]=e;return a!==l.ln.ConfigurableProduct&&a!==l.ln.BundleProduct}))}),(0,n.jsx)(E.A,{name:"quantity",type:"number",required:!0,label:r({id:"quantity",defaultMessage:"Quantity"})})]}),i(l._r.ManageProducts)&&(0,n.jsx)("div",{className:"border-t border-slate-100 dark:border-slate-700 bg-slate-50 dark:bg-slate-900 p-5 text-right",children:(0,n.jsx)(q.A,{label:r({id:"scaffold_and_add",defaultMessage:"Scaffold & Add"})})})]})};var t6=a(23416);function t4(){let e=(0,L._)(["\n query Product($productId: ID, $slug: String) {\n product(productId: $productId, slug: $slug) {\n ...ProductDetailFragment\n ","\n texts {\n _id\n title\n subtitle\n description\n }\n ... on SimpleProduct {\n texts {\n _id\n title\n subtitle\n description\n }\n proxies {\n __typename\n }\n }\n ... on ConfigurableProduct {\n texts {\n _id\n title\n subtitle\n description\n }\n }\n ... on PlanProduct {\n texts {\n _id\n title\n subtitle\n description\n }\n proxies {\n __typename\n }\n }\n ... on BundleProduct {\n texts {\n _id\n title\n subtitle\n description\n }\n proxies {\n __typename\n }\n }\n }\n }\n ","\n"]);return t4=function(){return e},e}let t8=function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"";return(0,B.J1)(t4(),e,z.A)},t3=function(){let{productId:e=null,slug:t=null}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},a=(0,ev.id)(t),{customProperties:n,hydrateFragment:s}=(0,t6.A)(),{data:l,loading:r,error:i}=(0,ef.I)(t8(null==n?void 0:n.Product),{skip:!e&&!a,variables:{productId:e||a}}),d=s(null==n?void 0:n.Product,null==l?void 0:l.product);return{product:null==l?void 0:l.product,loading:r,error:i,extendedData:d}},t9=function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[];return e.map(e=>{var t,a;let{_id:n,status:s,texts:l,media:r}=e;return{id:n,tag:s,...l,image:(null==r?void 0:r.length)?null==(a=r[0])||null==(t=a.file)?void 0:t.url:null}})},t7=e=>{let{productId:t,disabled:a=!1}=e,{product:r}=t3({productId:t}),{setModal:i}=(0,eV.A)(),[d,o]=(0,w.useState)(""),{createProductBundleItem:u}=(()=>{let[e]=(0,Q.n)(tY);return{createProductBundleItem:async t=>{let{productId:a,item:n}=t;return e({variables:{productId:a,item:n},refetchQueries:["ProductBundleItems"]})}}})(),{hasRole:c}=(0,N.A)(),{formatMessage:m}=(0,s.A)(),{products:p,loading:x}=(0,tZ.A)({queryString:d,includeDrafts:!0,limit:50,sort:[{key:"created",value:l.t4.Desc}]}),g=async e=>{let{productId:a,quantity:n}=e;return await u({item:{productId:a,quantity:n},productId:t}),{success:!0}},f=m({id:"bundle_item_added",defaultMessage:"Bundle product added successfully"}),v=(0,J.A)({disabled:a,submit:g,successMessage:f,onSubmitSuccess:()=>(v.formik.resetForm(),null),initialValues:{productId:"",quantity:1}}),h=(0,w.useCallback)(async()=>{await i((0,n.jsx)(t2,{bundleProduct:r,onSuccess:async function(e){let a=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1;await u({item:{productId:e._id,quantity:a},productId:t}),i("")}}))},[r]);return(0,n.jsxs)(V.A,{form:v,children:[(0,n.jsxs)("div",{className:"flex items-end gap-2 w-full",children:[(0,n.jsx)("div",{className:"flex-1",children:(0,n.jsx)(tH.A,{name:"productId",onFilter:o,queryString:d,label:m({id:"product",defaultMessage:"Product"}),data:t9(p),isLoading:x,className:"w-full text-sm font-medium text-slate-500",required:!0})}),c(l._r.ManageProducts)&&(0,n.jsx)("div",{className:"pb-3",children:(0,n.jsx)(F.A,{className:"flex items-center justify-center p-2 rounded-md",onClick:h,children:(0,n.jsx)(t0.A,{className:"h-5 w-5"})})})]}),(0,n.jsx)(E.A,{name:"quantity",type:"number",required:!0,label:m({id:"quantity",defaultMessage:"Quantity"})}),c(l._r.ManageProducts)&&(0,n.jsx)(q.A,{label:m({id:"submit",defaultMessage:"Submit"}),className:"mt-2"})]})};var ae=a(41623);function at(){let e=(0,L._)(["\n query ProductBundleItems($productId: ID, $slug: String) {\n product(productId: $productId, slug: $slug) {\n _id\n ... on BundleProduct {\n bundleItems {\n product {\n ...ProductBriefFragment\n }\n quantity\n }\n }\n }\n }\n ","\n"]);return at=function(){return e},e}let aa=(0,B.J1)(at(),ae.A),an=function(){var e;let{productId:t=null,slug:a=null}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},n=(0,ev.id)(a),{data:s,loading:l,error:r}=(0,ef.I)(aa,{skip:!t&&!n,variables:{productId:t||n}});return{bundleItems:(null==s||null==(e=s.product)?void 0:e.bundleItems)||[],loading:l,error:r}};function as(){let e=(0,L._)(["\n mutation RemoveBundleItem($productId: ID!, $index: Int!) {\n removeBundleItem(productId: $productId, index: $index) {\n _id\n }\n }\n"]);return as=function(){return e},e}let al=(0,B.J1)(as());var ar=a(65990),ai=a(35429);let ad=e=>{var t,a,s,l,r,i,d;let{item:o,onDelete:u,index:c}=e,{product:m,quantity:p}=o;return(0,n.jsxs)("div",{className:"group flex w-full items-center justify-between border-b border-slate-200 dark:border-slate-700 hover:border-slate-300 dark:hover:border-slate-600 hover:bg-slate-50/80 dark:hover:bg-slate-700/50 transition-all duration-200 ease-in-out hover:shadow-sm last:border-none",children:[(0,n.jsxs)("div",{className:"flex w-full items-center space-x-6 py-4",children:[(null==(t=m.media)?void 0:t.length)?(0,n.jsx)("div",{className:"flex w-20 flex-col items-center",children:(0,n.jsx)("div",{className:"relative m-1 mr-2 mt-1 flex items-center justify-center rounded-full ",children:(0,n.jsx)(ar.A,{className:"mx-auto w-auto",src:null==(s=m.media[0])||null==(a=s.file)?void 0:a.url,width:160,height:100,alt:(null==m||null==(l=m.texts)?void 0:l.title)||(null==m||null==(r=m.texts)?void 0:r.subtitle)})})}):(0,n.jsx)(ai.A,{className:"h-10 w-10"}),(0,n.jsxs)("div",{className:"shrink grow basis-1/2",children:[(0,n.jsx)("h3",{className:"text-lg text-slate-800 dark:text-slate-200",children:null==m||null==(i=m.texts)?void 0:i.title}),(0,n.jsx)("p",{className:"text-xs text-slate-600 dark:text-slate-200",children:null==m||null==(d=m.texts)?void 0:d.subtitle})]}),(0,n.jsx)("div",{className:"ml-auto",children:(0,n.jsx)(ti.A,{text:p,color:"slate",square:!0})})]}),(0,n.jsx)(tw.A,{onDelete:()=>{u(c)},showDelete:!0})]})},ao=e=>{let{productId:t}=e,{formatMessage:a}=(0,s.A)(),{setModal:l}=(0,eV.A)(),{bundleItems:i,loading:o}=an({productId:t}),{removeBundleItem:u}=(()=>{let[e]=(0,Q.n)(al);return{removeBundleItem:async t=>{let{productId:a,index:n}=t;return e({variables:{productId:a,index:n},refetchQueries:["ProductBundleItems"]})}}})(),c=async e=>{await l((0,n.jsx)(e$.A,{onCancelClick:async()=>l(""),message:a({id:"delete_bundle_item_confirmation",defaultMessage:"This action might cause inconsistencies with other data that relates to it. Are you sure you want to delete this bundle item? "}),onOkClick:async()=>{l(""),await u({productId:t,index:e}),r.oR.success(a({id:"bundle_item_deleted",defaultMessage:"Bundle item deleted successfully"}))},okText:a({id:"delete_bundle_item",defaultMessage:"Delete item"})}))};return o?(0,n.jsx)(d.A,{}):i.length?(0,n.jsx)(n.Fragment,{children:i.map((e,t)=>(0,n.jsx)(ad,{index:t,item:e,onDelete:c},e.product._id))}):(0,n.jsx)(ew.A,{message:a({id:"bundle",defaultMessage:"Bundle product"})})},au=e=>{let{productId:t,disabled:a=!1}=e;return(0,n.jsx)("div",{className:"mt-6 rounded-md",children:(0,n.jsxs)("div",{className:"lg:grid lg:grid-cols-9",children:[(0,n.jsx)("div",{className:"mb-5 lg:col-span-4 lg:pr-5",children:(0,n.jsx)(t7,{productId:t,disabled:a})}),(0,n.jsx)("div",{className:"col-span-5 ml-auto rounded-md bg-white dark:bg-slate-800 px-8 shadow-md dark:shadow-none lg:w-full",children:(0,n.jsx)("div",{className:"py-4",children:(0,n.jsx)(ao,{productId:t})})})]})})};var ac=a(19921),am=a(76500),ap=a(57104);function ax(){let e=(0,L._)(["\n fragment ProductAssignmentFragment on ProductVariationAssignment {\n _id\n vectors {\n _id\n option {\n _id\n value\n texts {\n _id\n title\n subtitle\n }\n }\n variation {\n _id\n key\n texts {\n _id\n locale\n title\n }\n }\n }\n product {\n _id\n texts {\n _id\n title\n slug\n subtitle\n }\n }\n }\n"]);return ax=function(){return e},e}let ag=(0,B.J1)(ax());function af(){let e=(0,L._)(["\n query ProductAssignments($productId: ID, $slug: String) {\n product(productId: $productId, slug: $slug) {\n _id\n ... on ConfigurableProduct {\n texts {\n _id\n subtitle\n slug\n title\n }\n variations {\n _id\n key\n texts {\n _id\n title\n }\n options {\n _id\n value\n texts {\n _id\n title\n }\n }\n }\n assignments(includeInactive: true) {\n ...ProductAssignmentFragment\n }\n }\n }\n }\n ","\n"]);return af=function(){return e},e}let av=(0,B.J1)(af(),ag),ah=function(){let{productId:e=null,slug:t=null}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},a=(0,ev.id)(t),{data:n,loading:s,error:l}=(0,ef.I)(av,{skip:!e&&!a,variables:{productId:e||a}});return{product:null==n?void 0:n.product,loading:s,error:l}};var ab=a(33023);let aj=(e,t,a)=>{let n=e[a],s=[];return(null==n||n.values.filter(e=>e.length).forEach(e=>{let a={};a[n.key]=e,t.length>0?t.forEach(e=>{s.push({...e,...a})}):s.push(a)}),e.length>a+1)?aj(e,s,a+1):Array.from(new Set(s.map(e=>JSON.stringify(e)))).map(e=>JSON.parse(e))},ay=e=>{let{_id:t,texts:a}=e;return{value:t,label:null==a?void 0:a.title}};var a_=a(62942),aw=a(9518),aA=a(56975);function aN(){let e=(0,L._)(["\n mutation AddProductAssignment(\n $proxyId: ID!\n $productId: ID!\n $vectors: [ProductAssignmentVectorInput!]!\n ) {\n addProductAssignment(\n proxyId: $proxyId\n productId: $productId\n vectors: $vectors\n ) {\n _id\n }\n }\n"]);return aN=function(){return e},e}let ak=(0,B.J1)(aN()),aM=()=>{let[e]=(0,Q.n)(ak);return{addProductAssignment:async t=>{let{productId:a,proxyId:n,vectors:s}=t;return e({variables:{productId:a,proxyId:n,vectors:s},refetchQueries:["ProductAssignments"]})}}};function aI(){let e=(0,L._)(["\n mutation RemoveProductAssignment(\n $proxyId: ID!\n $vectors: [ProductAssignmentVectorInput!]!\n ) {\n removeProductAssignment(proxyId: $proxyId, vectors: $vectors) {\n _id\n }\n }\n"]);return aI=function(){return e},e}let aP=(0,B.J1)(aI());var aC=a(96456),a$=a.n(aC),aS=a(10363);let aT=function(e){let{proxyProduct:t,vectors:a,onSuccess:n}=e,{selectedLocale:r}=(0,er.A)(),{createProduct:i}=(0,t1.A)(),{addProductAssignment:d}=aM(),{formatMessage:o}=(0,s.A)();return async e=>{let{title:s,type:u}=e,c=[{title:s,slug:s.toLowerCase().replace(/\s+/g,"-"),locale:r}],{data:m}=await i({product:{type:u||l.ln.SimpleProduct},texts:c}),p=null==m?void 0:m.createProduct,x=null==p?void 0:p._id;if(!x)throw Error(o({id:"product_creation_failed",defaultMessage:"Product creation failed"}));return await d({productId:x,proxyId:null==t?void 0:t._id,vectors:a}),null==n||n(p),{success:!0}}},aV=e=>{let{proxyProduct:t,vectors:a,onSuccess:r}=e,{formatMessage:i}=(0,s.A)(),d=aT({onSuccess:r,proxyProduct:t,vectors:a}),{hasRole:o}=(0,N.A)(),u=(0,w.useMemo)(()=>a.map(e=>{let{value:t}=e;return t}),[a]),c=(0,w.useMemo)(()=>{var e,a;let n=null!=(a=null==t||null==(e=t.texts)?void 0:e.title)?a:"";return"".concat(u.join("-")," ").concat(n).trim()},[u,t]),m=async e=>{let{title:t,type:a}=e;try{return await d({title:t,type:a}),{success:!0}}catch(e){return{success:!1,error:{message:null==e?void 0:e.message}}}},p=i({id:"product-scaffolded-success",defaultMessage:"Product scaffolded successfully"}),x=(0,J.A)({submit:m,successMessage:p,enableReinitialize:!0,initialValues:{title:c,type:l.ln.SimpleProduct}});return(0,n.jsxs)(V.A,{className:"mt-3 rounded-md",form:x,children:[(0,n.jsxs)("div",{className:"p-5 pb-7 sm:max-w-full flex flex-col gap-3",children:[(0,n.jsx)(E.A,{name:"title",id:"title",label:i({id:"name",defaultMessage:"Name"}),required:!0,className:"block w-full max-w-full rounded-md border-slate-300 dark:border-slate-800 text-sm focus:ring-slate-800 sm:text-sm"}),(0,n.jsx)(R.A,{className:"mt-1 w-full",label:i({id:"type",defaultMessage:"Type"}),placeholder:i({id:"type",defaultMessage:"Type"}),required:!0,name:"type",options:Object.fromEntries(Object.entries(l.ln).map(e=>{let[t,a]=e;return[a,t]}))})]}),o(l._r.ManageProducts)&&(0,n.jsx)("div",{className:"border-t border-t-slate-100 dark:border-t-slate-700 bg-slate-50 dark:bg-slate-900 p-5 text-right",children:(0,n.jsx)(q.A,{label:i({id:"scaffold_product",defaultMessage:"Scaffold"})})})]})},aD=e=>{var t,a;let{columns:r,variationProduct:i,product:d,loading:o,disabled:u,proxyId:c,columnKeys:m}=e,{formatMessage:p}=(0,s.A)(),[x,g]=(0,w.useState)(""),{addProductAssignment:f}=aM(),{removeProductAssignment:v}=(()=>{let[e]=(0,Q.n)(aP);return{removeProductAssignment:async t=>{let{proxyId:a,vectors:n}=t;return e({variables:{proxyId:a,vectors:n},refetchQueries:["ProductAssignments"]})}}})(),{hasRole:h}=(0,N.A)(),{setModal:b}=(0,eV.A)(),{products:j}=(0,tZ.A)({queryString:x,limit:50,sort:[{key:"created",value:l.t4.Desc}]}),y=(0,w.useMemo)(()=>r.map((e,t)=>({key:m[t],value:e})).filter(e=>{let{value:t}=e;return t}),[r,m]),_=(0,w.useCallback)(async e=>{let{value:t}=e;await f({proxyId:c,productId:t,vectors:y})},[y,f,c]),A=(0,w.useCallback)(async()=>{await b((0,n.jsx)(e$.A,{onCancelClick:async()=>b(""),message:p({id:"delete_product_assignment",defaultMessage:"This action might cause inconsistencies with other data that relates to it. Are you sure you want to delete this assignment? "}),onOkClick:async()=>{b(""),await v({proxyId:c,vectors:y})},okText:p({id:"delete_variation_assignment",defaultMessage:"Delete assignment"})}))},[c,y,p,b,v]),k=(0,w.useMemo)(()=>(0,aA.A)(200)(g),[]),M=!i&&(null==d||null==(t=d.variations)?void 0:t.length)!==(null==r?void 0:r.length),I=(0,w.useMemo)(()=>(null==j?void 0:j.map(ay).filter(e=>{let{value:t}=e;return t!==c}))||[],[j,c]),P=async()=>{await b((0,n.jsx)(aV,{proxyProduct:d,vectors:y,onSuccess:()=>{b(null)}}))};return(0,n.jsxs)(ab.A.Row,{children:[r.map((e,t)=>(0,n.jsx)(ab.A.Cell,{className:"font-medium",children:e},"".concat(e))),(0,n.jsx)(ab.A.Cell,{children:i?(0,n.jsx)("div",{className:"flex items-center",children:(0,n.jsx)(a$(),{href:"/products?slug=".concat((0,ev.Ay)(i)),children:(0,n.jsx)("span",{className:"text-green-700 dark:text-green-300 font-medium",children:null==i||null==(a=i.texts)?void 0:a.title})})}):M?(0,n.jsx)("div",{className:"mt-1 text-sm text-rose-600 italic",children:p({id:"assign_product_needs_variations",defaultMessage:"Please configure all variation options before assigning a product."})}):(0,n.jsx)("div",{className:"relative w-full",children:(0,n.jsxs)("div",{className:"flex items-center gap-2",children:[(0,n.jsx)("div",{className:"flex-1",children:(0,n.jsx)(aw.A,{name:"productId",placeholder:p({id:"search_product",defaultMessage:"Search product"}),isLoading:o,isDisabled:u,onChange:_,onInputChange:k,options:I,className:"mt-1 w-full py-2 text-sm font-medium text-slate-500"})}),h(l._r.ManageProducts)&&(0,n.jsx)(F.A,{onClick:P,children:(0,n.jsx)(aS.A,{className:"h-5 w-5"})})]})})}),(0,n.jsx)(ab.A.Cell,{children:i&&i._id&&(0,n.jsx)(a_.A,{onClick:A})})]})};var aR=a(67032);let aq=e=>{let{proxyId:t,disabled:a=!1}=e,{formatMessage:l}=(0,s.A)(),{product:r,loading:i}=ah({productId:t}),d=r&&(null==r?void 0:r.variations)||[],o=r&&r.assignments||[],u=(0,w.useMemo)(()=>d.filter(e=>{let{options:t}=e;return t.length}).map(e=>{let{key:t}=e;return t}),[d]),c=(0,w.useMemo)(()=>d.map(e=>{let{key:t,options:a}=e;return{values:null==a?void 0:a.map(e=>e.value),key:t}}),[d]),m=(0,w.useMemo)(()=>{let e=c.filter(e=>{let{values:t}=e;return null==t?void 0:t.length});return e.length>0?aj(e,[],0):[]},[c]),p=(0,w.useMemo)(()=>o.map(e=>{let t={};return u.forEach(a=>{var n,s;let l=e.vectors.find(e=>{var t;return(null==(t=e.variation)?void 0:t.key)===a});t[a]=null!=(s=null==l||null==(n=l.option)?void 0:n.value)?s:""}),t}),[o,u]),x=(0,w.useMemo)(()=>{let e=[...m,...p],t=new Set;return e.filter(e=>{let a=Object.values(e).join("::");return!t.has(a)&&(t.add(a),!0)})},[m,p]),g=(0,w.useMemo)(()=>o.map(e=>{let t={};return e.vectors.forEach(e=>{var a,n;(null==e||null==(a=e.variation)?void 0:a.key)&&(null==e||null==(n=e.option)?void 0:n.value)&&(t[e.variation.key]=e.option.value)}),{keys:t,product:e.product}}),[o]),f=(0,w.useMemo)(()=>x.map(e=>{let t=g.find(t=>{let{keys:a}=t;return Object.entries(a).every(t=>{let[a,n]=t;return e[a]===n})});return{_id:Object.values(e).join("::"),product:null==t?void 0:t.product,columns:Object.values(e),columnsText:Object.values(e)}}),[x,g]),v=(0,w.useMemo)(()=>d.length>0,[d]),h=(0,w.useMemo)(()=>d.some(e=>e.options&&e.options.length>0),[d]);return(0,n.jsxs)(k.A,{children:[(0,n.jsx)(aR.A,{title:l({id:"product_assignments_explanation_title",defaultMessage:"About Product Assignments"}),description:l({id:"product_assignments_explanation_text",defaultMessage:"Product assignments allow you to link specific products to each unique combination of variation options. For example, if you have a t-shirt with 'Size' and 'Color' variations, you can assign different product SKUs to each combination like 'Large + Red' or 'Small + Blue'. This is useful for managing inventory, pricing, and product details for each specific variant."})}),!v&&(0,n.jsxs)("div",{className:"text-center py-8",children:[(0,n.jsx)("div",{className:"inline-flex items-center justify-center w-16 h-16 rounded-full bg-gray-100 dark:bg-gray-800 mb-4",children:(0,n.jsx)(ap.A,{className:"w-8 h-8 text-gray-400"})}),(0,n.jsx)("h3",{className:"text-lg font-medium text-gray-900 dark:text-gray-100 mb-2",children:l({id:"no_variations_configured",defaultMessage:"No variations configured yet. Please add variations and their options in the Variations tab first."})})]}),v&&h&&(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)("div",{className:"mb-4",children:(0,n.jsx)(el.A,{messageKey:"assignment_matrix_help",defaultMessage:"Each row represents a unique combination of your product variations. Assign a specific product to each combination to create a complete product catalog."})}),(0,n.jsxs)(ab.A,{children:[(0,n.jsxs)(ab.A.Row,{children:[u.map(e=>{var t,a;return(0,n.jsx)(ab.A.Cell,{className:"font-semibold bg-gray-50 dark:bg-gray-800",children:(null==(a=d.find(t=>t.key===e))||null==(t=a.texts)?void 0:t.title)||e},e)}),(0,n.jsx)(ab.A.Cell,{className:"font-semibold bg-gray-50 dark:bg-gray-800",children:l({id:"assigned_product_column_header",defaultMessage:"Assigned Product"})}),(0,n.jsx)(ab.A.Cell,{className:"font-semibold bg-gray-50 dark:bg-gray-800",children:l({id:"actions_column_header",defaultMessage:"Actions"})})]}),f.length>0&&f.map(e=>{let{_id:s,columns:l,product:d}=e;return(0,n.jsx)(aD,{columns:l,disabled:a,loading:i,product:r,variationProduct:d,columnKeys:u,proxyId:t},s)})]})]}),v&&!h&&(0,n.jsxs)("div",{className:"text-center py-8",children:[(0,n.jsx)("div",{className:"inline-flex items-center justify-center w-16 h-16 rounded-full bg-yellow-100 dark:bg-yellow-900/30 mb-4",children:(0,n.jsx)(ap.A,{className:"w-8 h-8 text-yellow-600 dark:text-yellow-400"})}),(0,n.jsx)("h3",{className:"text-lg font-medium text-gray-900 dark:text-gray-100 mb-2",children:l({id:"assign_product_needs_variations",defaultMessage:"Please configure all variation options before assigning a product."})}),(0,n.jsx)("p",{className:"text-sm text-gray-600 dark:text-gray-400",children:l({id:"assignment_matrix_help",defaultMessage:"Each row represents a unique combination of your product variations. Assign a specific product to each combination to create a complete product catalog."})})]})]})};function aE(){let e=(0,L._)(["\n query ProductTokenization($productId: ID, $slug: String) {\n product(productId: $productId, slug: $slug) {\n _id\n ... on TokenizedProduct {\n contractConfiguration {\n tokenId\n supply\n }\n contractStandard\n contractAddress\n }\n }\n }\n"]);return aE=function(){return e},e}let aF=(0,B.J1)(aE()),aJ=function(){let{productId:e=null,slug:t=null}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},a=(0,ev.id)(t),{data:n,loading:s,error:l}=(0,ef.I)(aF,{skip:!e&&!t,variables:{productId:e||a}});return{product:null==n?void 0:n.product,loading:s,error:l}};function aO(){let e=(0,L._)(['\n query SmartContractStandards {\n smartContractStandards: __type(name: "SmartContractStandard") {\n options: enumValues {\n value: name\n label: name\n }\n }\n }\n']);return aO=function(){return e},e}let aU=(0,B.J1)(aO());function aL(){let e=(0,L._)(["\n mutation UpdateProductTokenization(\n $productId: ID!\n $tokenization: UpdateProductTokenizationInput!\n ) {\n updateProductTokenization(\n productId: $productId\n tokenization: $tokenization\n ) {\n _id\n }\n }\n"]);return aL=function(){return e},e}let aB=(0,B.J1)(aL()),aQ=e=>{let{productId:t,disabled:a=!1}=e,{formatMessage:r}=(0,s.A)(),{hasRole:i}=(0,N.A)(),{smartContractStandards:d}=(()=>{var e;let{data:t,loading:a,error:n}=(0,ef.I)(aU);return{smartContractStandards:(null==t||null==(e=t.smartContractStandards)?void 0:e.options)||[],loading:a,error:n}})(),{updateProductTokenization:o}=(()=>{let[e]=(0,Q.n)(aB);return{updateProductTokenization:async t=>{let{productId:a,tokenization:{contractAddress:n,contractStandard:s,tokenId:l,supply:r}}=t;return e({variables:{productId:a,tokenization:{contractAddress:n,contractStandard:s,tokenId:l,supply:parseInt(r,10)}},refetchQueries:["Product","Products"]})}}})(),{product:u,loading:c}=aJ({productId:t}),m=async e=>{let{contractAddress:a,contractStandard:n,tokenId:s,supply:l}=e;return await o({productId:t,tokenization:{contractAddress:a,contractStandard:n,tokenId:s||"",supply:l}}),{success:!0}},p=r({id:"token_updated",defaultMessage:"Token update successfully!"}),x=(0,J.A)({disabled:a,submit:m,successMessage:p,initialValues:{contractAddress:"",contractStandard:"",tokenId:"",supply:""}});return(0,w.useEffect)(()=>{var e,t;c||x.formik.setValues({contractAddress:(null==u?void 0:u.contractAddress)||"",contractStandard:(null==u?void 0:u.contractStandard)||"",tokenId:(null==u||null==(e=u.contractConfiguration)?void 0:e.tokenId)||"",supply:(null==u||null==(t=u.contractConfiguration)?void 0:t.supply)||""})},[c]),(0,n.jsx)(ea.A,{documentationLabel:r({id:"texts",defaultMessage:"Texts"}),className:"mt-2 lg:mt-5",documentation:(0,n.jsx)(X.A,{id:"tokenized_product_text_form_description",defaultMessage:"<b>Contract standards </b> <ol> <dt><b> ERC721 </b></dt> <dd> Buying multiple Products leads to multiple Tokens (make sure to set the tokenId to 0 to make it auto generate new id's) </dd> <dt> <b> ERC1155 </b></dt> <dd> Buying multiple Products leads to a new token with balance 3 of token with tokenId assigned </dd> <dt> <b> Contract address </b></dt> <dd> Address of a token on a given network </dd> </ol>",values:{ol:e=>(0,n.jsxs)("ol",{children:[e," "]}),dt:e=>(0,n.jsxs)("dt",{className:"bold",children:[e," "]}),dd:e=>(0,n.jsxs)("dd",{children:[e," "]}),b:e=>(0,n.jsxs)("b",{children:[e," "]})}}),children:(0,n.jsx)(k.A,{children:(0,n.jsxs)(V.A,{form:x,children:[(0,n.jsxs)("div",{className:"p-5 pb-7 sm:max-w-full flex flex-col gap-y-5",children:[(0,n.jsx)(R.A,{className:"w-full",label:r({id:"contract-standard",defaultMessage:"Contract standard"}),placeholder:r({id:"contract-standard",defaultMessage:"Contract standard"}),required:!0,name:"contractStandard",options:(0,M.A)(d,"label","value")}),(0,n.jsx)(E.A,{name:"contractAddress",id:"contractAddress",label:r({id:"contract-address-label",defaultMessage:"Contract Address"}),placeholder:r({id:"contract-address-label",defaultMessage:"Contract Address"}),required:!0,className:"block w-full max-w-full rounded-md border-slate-300 dark:border-slate-800 text-sm focus:ring-slate-800 sm:text-sm"}),(0,n.jsx)(E.A,{name:"supply",id:"supply",type:"number",label:r({id:"token-supply",defaultMessage:"Supply"}),placeholder:r({id:"token-supply",defaultMessage:"Supply"}),required:!0,className:"block w-full max-w-full rounded-md border-slate-300 dark:border-slate-800 text-sm focus:ring-slate-800 sm:text-sm"}),(0,n.jsx)(E.A,{name:"tokenId",id:"tokenId",label:r({id:"token-id-label",defaultMessage:"Token Serial Number"}),placeholder:r({id:"token-id-label",defaultMessage:"Token Serial Number"}),className:"block w-full max-w-full rounded-md border-slate-300 dark:border-slate-800 text-sm focus:ring-slate-800 sm:text-sm"})]}),i(l._r.ManageProducts)&&(0,n.jsx)("div",{className:"space-y-6 border-t border-t-slate-100 dark:border-t-slate-700 bg-slate-50 dark:bg-slate-900 p-5 text-right",children:(0,n.jsx)(q.A,{label:r({id:"update_token",defaultMessage:"Update token"})})})]})})})};var az=a(14303),aK=a(42149);let aW=e=>{let{id:t,selectedView:a="",disableAll:s=!1,...l}=e;return"texts"===a?(0,n.jsx)(_.A,{children:(0,n.jsx)(ed,{productId:t,disabled:s})}):"media"===a?(0,n.jsx)(aK.A,{children:(0,n.jsx)(_.A,{children:(0,n.jsx)(eF,{productId:t})})}):"commerce"===a?(0,n.jsx)(H,{productId:t,disabled:s}):"supply"===a?(0,n.jsx)(e5,{productId:t,disabled:s}):"warehousing"===a?(0,n.jsx)(tV,{productId:t,disabled:s}):"variations"===a?(0,n.jsx)(_.A,{children:(0,n.jsx)(tI,{productId:t,disabled:s})}):"bundled_products"===a?(0,n.jsx)(au,{productId:t,disabled:s}):"subscriptions"===a?(0,n.jsx)(eG,{productId:t,disabled:s}):"reviews"===a?(0,n.jsx)(tG,{productId:t}):"assignments"===a?(0,n.jsx)(_.A,{children:(0,n.jsx)(aq,{proxyId:t,disabled:s})}):"token"===a?(0,n.jsx)(aQ,{productId:t,disabled:s}):"extended"===a?(0,n.jsx)(az.A,{data:l}):(0,n.jsx)(_.A,{children:(0,n.jsx)(ed,{productId:t})})},aG=e=>{var t;let{product:a,extendedData:r={}}=e,{formatMessage:i}=(0,s.A)(),{hasRole:d}=(0,N.A)(),{updateProduct:o}=(0,am.A)(),{shopInfo:u}=(0,er.A)(),{__typename:_}=a||{},w=[{id:"texts",title:i({id:"general_text",defaultMessage:"Text"}),Icon:(0,n.jsx)(c.A,{className:"h-5 w-5"})},{id:"media",title:i({id:"media",defaultMessage:"Media"}),Icon:(0,n.jsx)(m.A,{className:"h-5 w-5"})},"ConfigurableProduct"!==_&&{id:"commerce",title:i({id:"commerce",defaultMessage:"Commerce"}),Icon:(0,n.jsx)(p.A,{className:"h-5 w-5"})},"SimpleProduct"===_&&{id:"supply",title:i({id:"supply",defaultMessage:"Supply"}),Icon:(0,n.jsx)(x.A,{className:"h-5 w-5"})},"SimpleProduct"===_&&{id:"warehousing",title:i({id:"warehousing",defaultMessage:"Warehousing"}),Icon:(0,n.jsx)(g.A,{className:"h-5 w-5"})},"ConfigurableProduct"===_&&{id:"variations",title:i({id:"variations",defaultMessage:"Variations"}),Icon:(0,n.jsx)(f.A,{className:"h-5 w-5"})},"BundleProduct"===_&&{id:"bundled_products",title:i({id:"bundled_items",defaultMessage:"Bundled items"}),Icon:(0,n.jsx)(v.A,{className:"h-5 w-5"})},"PlanProduct"===_&&{id:"subscriptions",title:i({id:"subscriptions",defaultMessage:"Subscriptions"}),Icon:(0,n.jsx)(h.A,{className:"h-5 w-5"})},"ConfigurableProduct"===_&&{id:"assignments",title:i({id:"assignments",defaultMessage:"Assignments"}),Icon:(0,n.jsx)(b.A,{className:"h-5 w-5"})},"TokenizedProduct"===_&&{id:"token",title:i({id:"token",defaultMessage:"Token"}),Icon:(0,n.jsx)(b.A,{className:"h-5 w-5"})},{id:"reviews",title:i({id:"reviews",defaultMessage:"Reviews"}),Icon:(0,n.jsx)(j.A,{className:"h-5 w-5"})},null!==r&&{id:"extended",title:i({id:"extended-fields",defaultMessage:"Extended"}),Icon:(0,n.jsx)(y.A,{className:"h-5 w-5"})}].filter(e=>e),A=async e=>{let{tags:t}=e;return await o({productId:null==a?void 0:a._id,product:{tags:t}}),!0};return(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)("div",{className:"mt-5 flex flex-wrap items-center justify-between gap-10",children:(0,n.jsx)(ac.A,{defaultValue:null==a?void 0:a.tags,onSubmit:A,enableEdit:d(l._r.ManageProducts),availableTagOptions:null==u||null==(t=u.adminUiConfig)?void 0:t.productTags.filter(e=>{var t;return!(null==(t=(null==a?void 0:a.tags)||[])?void 0:t.includes(e))}).map(e=>({value:e,label:e}))})}),(0,n.jsx)(tD.A,{tabItems:w,defaultTab:"texts",children:(0,n.jsx)(aW,{disableAll:(null==a?void 0:a.status)===l.t_.Deleted,id:null==a?void 0:a._id,...r})})]})},aH=e=>{let{media:t=[],onEditMedia:a}=e;return(0,n.jsx)("div",{className:"my-5",children:(0,n.jsx)("div",{className:"flex gap-3 overflow-x-auto",children:t.map(e=>{var t,s,l,r;return(0,n.jsx)("div",{className:"relative flex-shrink-0 group",children:(0,n.jsx)("div",{className:"w-16 h-16 bg-slate-100 dark:bg-slate-800 rounded-lg overflow-hidden cursor-pointer border border-slate-200 dark:border-slate-700",onClick:()=>{var t;return t=e._id,void(a&&a(t))},children:(0,n.jsx)(ar.A,{src:null==e||null==(t=e.file)?void 0:t.url,alt:(null==(l=e.texts)||null==(s=l[0])?void 0:s.title)||(null==e||null==(r=e.file)?void 0:r.url),width:128,height:128,className:"w-full h-full object-cover"})})},e._id)})})})};var aX=a(6743);function aY(){let e=(0,L._)(["\n mutation PublishProduct($productId: ID!) {\n publishProduct(productId: $productId) {\n ...ProductDetailFragment\n }\n }\n ","\n"]);return aY=function(){return e},e}let aZ=(0,B.J1)(aY(),z.A);function a0(){let e=(0,L._)(["\n mutation UnpublishProduct($productId: ID!) {\n unpublishProduct(productId: $productId) {\n ...ProductDetailFragment\n }\n }\n ","\n"]);return a0=function(){return e},e}let a1=(0,B.J1)(a0(),z.A);var a5=a(28569),a2=a(57267),a6=a(83293),a4=a(46225),a8=a(96487),a3=a(41824);let a9=e=>{var t,a,c;let{slug:m}=e,{formatMessage:p}=(0,s.A)(),{formatDateTime:x}=(0,u.A)(),{hasRole:g}=(0,N.A)(),{publishProduct:f}=(()=>{let[e]=(0,Q.n)(aZ);return{publishProduct:async t=>{let{productId:a}=t;return e({variables:{productId:a},refetchQueries:["Product","ShopStatus"],awaitRefetchQueries:!0})}}})(),{unPublishProduct:v}=(()=>{let[e]=(0,Q.n)(a1);return{unPublishProduct:async t=>{let{productId:a}=t;return e({variables:{productId:a},refetchQueries:["Product","ShopStatus"],awaitRefetchQueries:!0})}}})(),{removeProduct:h}=(0,a2.A)(),{updateProduct:b}=(0,am.A)(),{setModal:j}=(0,eV.A)(),y=(0,a4.useRouter)(),{push:_}=(0,a4.useRouter)(),{product:A,loading:k,error:M,extendedData:I}=t3({slug:m}),P=(null==A?void 0:A.status)||"DRAFT",C=(0,w.useMemo)(()=>[{id:"published",title:p({id:"published",defaultMessage:"Published"}),description:p({id:"publish_product_description",defaultMessage:"Product will be searchable and is available for orders"}),current:"ACTIVE"===P,selectedTitle:p({id:"published",defaultMessage:"Published"}),onClick:async()=>{try{await f({productId:null==A?void 0:A._id}),r.oR.success(p({id:"product_published",defaultMessage:"Published successfully "}))}catch(t){console.error("Failed to publish product:",t);let e=(null==t?void 0:t.message)||"Unknown error";r.oR.error("".concat(p({id:"product_publish_error",defaultMessage:"Failed to publish product"}),": ").concat(e))}},bgColor:"green",disable:!g(l._r.ManageProducts)},{id:"draft",title:p({id:"draft",defaultMessage:"Draft"}),description:p({id:"draft_product_description",defaultMessage:"Product will not be discoverable and can not be orderose"}),current:"DRAFT"===P,selectedTitle:p({id:"not_published",defaultMessage:"Not published"}),bgColor:"amber",disable:"ACTIVE"===P&&!g(l._r.ManageProducts),onClick:async()=>{if(g(l._r.ManageProducts))try{await v({productId:null==A?void 0:A._id}),r.oR.success(p({id:"product_drafted",defaultMessage:"Drafted successfully "}))}catch(t){console.error("Failed to unpublish product:",t);let e=(null==t?void 0:t.message)||"Unknown error";r.oR.error("".concat(p({id:"product_unpublish_error",defaultMessage:"Failed to unpublish product"}),": ").concat(e))}}}],[A]);if(M)return console.error("Error loading product:",M),(0,n.jsx)("div",{className:"mt-5 max-w-full",children:(0,n.jsx)("div",{className:"text-center py-8",children:(0,n.jsx)("p",{className:"text-rose-600 dark:text-rose-400",children:p({id:"product_load_error",defaultMessage:"Failed to load product"})})})});let $=async e=>{e.target.value&&await b({productId:null==A?void 0:A._id,product:{sequence:parseInt(e.target.value,10)}})},S=async()=>{var e;if("proxies"in A&&(null==(e=A.proxies)?void 0:e.length))return void await j((0,n.jsx)(a3.A,{headerText:p({id:"product_delete_blocked_header",defaultMessage:"Remove links before deleting"}),message:(0,n.jsxs)("div",{className:"space-y-2",children:[(0,n.jsx)("p",{children:p({id:"product_delete_blocked_intro",defaultMessage:"This product is linked to the following product types:"})}),(0,n.jsx)("ul",{className:"list-disc list-inside text-sm text-slate-700 dark:text-slate-300",children:"proxies"in A&&A.proxies.map((e,t)=>{let{__typename:a}=e;return(0,n.jsx)("li",{children:a.replace("Product","")},t)})}),(0,n.jsx)("p",{children:p({id:"product_delete_blocked_action",defaultMessage:"Please unlink it before trying to delete it."})})]}),buttonText:p({id:"ok",defaultMessage:"Ok"}),onOkClick:()=>j(null)}));await j((0,n.jsx)(e$.A,{onCancelClick:()=>j(""),message:p({id:"delete_product_confirmation",defaultMessage:"This action might cause inconsistencies with other data that relates to it and it is nonreversible. Are you sure you want to delete this product?"}),onOkClick:async()=>{j("");try{await h({productId:null==A?void 0:A._id}),r.oR.success(p({id:"product_deleted_success",defaultMessage:"Deleted successfully"})),y.push("/products")}catch(e){await j((0,n.jsx)(e$.A,{onCancelClick:()=>j(""),headerText:p({id:"error",defaultMessage:"Error"}),message:e instanceof a6.A?e.message:e,icon:(0,n.jsx)("div",{className:"mx-auto flex h-12 w-12 shrink-0 items-center justify-center rounded-full bg-rose-100 dark:bg-rose-900/30 sm:mx-0 sm:h-10 sm:w-10",children:(0,n.jsx)(a8.A,{className:"h-6 w-6 text-rose-600 dark:text-rose-400",xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2"})}),okText:p({id:"ok",defaultMessage:"Ok"}),onOkClick:async()=>{j("")}}))}}}))};return A||k?k?(0,n.jsx)(d.A,{}):(0,n.jsxs)("div",{className:"mt-5 max-w-full",children:[(0,n.jsx)(i.A,{routeName:m,depth:3,currentPageTitle:null==A||null==(t=A.texts)?void 0:t.title}),"DELETED"===P&&(0,n.jsx)("div",{className:"mb-4 rounded-md border border-rose-300 bg-rose-50 p-4 text-sm text-rose-800 dark:border-rose-700 dark:bg-rose-900/30 dark:text-rose-300",children:p({id:"product_deleted_notice",defaultMessage:"This product has been deleted and is no longer active. Some actions may be restricted."})}),(0,n.jsxs)("div",{children:[(0,n.jsxs)("div",{className:"items-center flex-wrap flex gap-5 min-w-full justify-between",children:[(0,n.jsx)(o.A,{headerText:(0,n.jsxs)(n.Fragment,{children:[(null==A||null==(a=A.texts)?void 0:a.title)||"Untitled Product","DELETED"===P&&(0,n.jsx)("span",{className:"ml-3 rounded bg-rose-100 px-2 py-1 text-xs font-semibold text-rose-800 dark:bg-rose-900/40 dark:text-rose-300",children:p({id:"deleted_status",defaultMessage:"Deleted"})})]}),title:"".concat((null==A||null==(c=A.texts)?void 0:c.title)||"Product"," (").concat(null==A?void 0:A._id,")")}),(0,n.jsxs)("div",{className:"publish-and-order flex flex-wrap gap-3",children:[P&&"DELETED"!==P&&(0,n.jsx)(aX.A,{options:C,type:p({id:"product",defaultMessage:"Product"})}),(0,n.jsxs)("div",{className:"inline-flex items-center gap-2 rounded-md dark:border-slate-600 px-4 py-2 text-sm font-medium leading-5 shadow-xs bg-white dark:bg-slate-800 h-[38px]",children:[(0,n.jsx)("label",{htmlFor:"sequence-input",className:"text-slate-700 dark:text-slate-200 font-medium cursor-pointer",children:p({id:"sequence",defaultMessage:"Display Order"})}),(0,n.jsx)("input",{type:"number",id:"sequence-input",disabled:!g(l._r.ManageProducts),className:"text-center w-12 bg-transparent border border-slate-300 dark:border-slate-600 rounded focus:ring-2 focus:ring-slate-800 dark:focus:ring-slate-400 focus:border-transparent focus:outline-none text-sm font-semibold text-slate-900 dark:text-slate-300 px-2 py-1 transition-all",defaultValue:null==A?void 0:A.sequence,onBlur:$})]}),"DRAFT"===P&&g(l._r.ManageProducts)&&(0,n.jsx)(a5.A,{onClick:S})]})]}),(0,n.jsxs)("div",{className:"mt-8 flex flex-wrap gap-3 gap-x-10 text-slate-600 dark:text-slate-400",children:[(0,n.jsxs)("div",{className:"flex flex-col items-baseline gap-0",children:[(0,n.jsx)("span",{className:"mr-2 text-xs text-slate-500 dark:text-slate-500",children:"ID:"}),(0,n.jsx)("span",{className:"text-sm font-mono",children:null==A?void 0:A._id})]}),(0,n.jsxs)("div",{className:"flex flex-col items-baseline gap-0",children:[(0,n.jsx)("span",{className:"text-xs text-slate-500 dark:text-slate-500",children:"Type:"}),(0,n.jsx)("p",{className:"text-sm font-mono",children:null==A?void 0:A.__typename})]}),(null==A?void 0:A.created)&&(0,n.jsxs)("div",{className:"flex flex-col items-baseline gap-0",children:[(0,n.jsxs)("span",{className:"text-xs text-slate-500 dark:text-slate-500",children:[p({id:"created",defaultMessage:"Created"}),":"]}),(0,n.jsx)("span",{className:"text-sm font-mono",children:x(A.created,{dateStyle:"medium",timeStyle:"short"})})]}),(null==A?void 0:A.updated)&&(0,n.jsxs)("div",{className:"flex flex-col items-baseline gap-0",children:[(0,n.jsxs)("span",{className:"text-xs text-slate-500 dark:text-slate-500",children:[p({id:"updated",defaultMessage:"Updated"}),":"]}),(0,n.jsx)("span",{className:"text-sm font-mono",children:x(A.updated,{dateStyle:"medium",timeStyle:"short"})})]}),(null==A?void 0:A.published)&&(0,n.jsxs)("div",{className:"flex flex-col items-baseline gap-0",children:[(0,n.jsxs)("span",{className:"text-xs text-slate-500 dark:text-slate-500",children:[p({id:"published",defaultMessage:"Published"}),":"]}),(0,n.jsx)("span",{className:"text-sm font-mono",children:x(A.published,{dateStyle:"medium",timeStyle:"short"})})]})]})]}),(0,n.jsx)(aH,{productId:null==A?void 0:A._id,media:(null==A?void 0:A.media)||[],onEditMedia:e=>{y.push({pathname:y.pathname,query:{...y.query,tab:"media"}},void 0,{shallow:!0})},canEdit:g(l._r.ManageProducts)}),(0,n.jsx)(aG,{product:A,extendedData:I})]}):(_("/404"),null)}},25191:(e,t,a)=>{a.d(t,{A:()=>r});var n=a(26514);a(75834);var s=a(36857),l=a(644);let r=e=>{let{messageKey:t,defaultMessage:a,values:r,className:i="",showIcon:d=!0}=e,{formatMessage:o}=(0,l.A)(),u=o({id:t,defaultMessage:a},r);return u?(0,n.jsxs)("div",{className:"flex items-start space-x-1 text-sm text-slate-600 dark:text-slate-400 ".concat(i),children:[d&&(0,n.jsx)(s.A,{className:"h-4 w-4 mt-0.5 flex-shrink-0"}),(0,n.jsx)("span",{children:u})]}):null}},35843:(e,t,a)=>{a.d(t,{A:()=>o});var n=a(9985),s=a(15968),l=a(70486),r=a(18237);function i(){let e=(0,n._)(["\n query Currencies(\n $queryString: String\n $limit: Int\n $offset: Int\n $includeInactive: Boolean\n $sort: [SortOptionInput!]\n ) {\n currencies(\n queryString: $queryString\n limit: $limit\n offset: $offset\n includeInactive: $includeInactive\n sort: $sort\n ) {\n ...CurrencyFragment\n }\n currenciesCount(\n includeInactive: $includeInactive\n queryString: $queryString\n )\n }\n ","\n"]);return i=function(){return e},e}let d=(0,s.J1)(i(),r.A),o=function(){let{queryString:e="",limit:t=20,offset:a=0,includeInactive:n=!0,sort:s=[]}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},{data:r,loading:i,error:o,fetchMore:u}=(0,l.I)(d,{variables:{queryString:e,limit:t,offset:a,includeInactive:n,sort:s}}),c=(null==r?void 0:r.currencies)||[],m=null==r?void 0:r.currenciesCount,p=(null==c?void 0:c.length)<m;return{currencies:c,currenciesCount:m,hasMore:p,loading:i,error:o,loadMore:()=>{u({variables:{offset:null==c?void 0:c.length}})}}}},40841:(e,t,a)=>{a.d(t,{A:()=>u});var n=a(26514),s=a(69001),l=a.n(s),r=a(46193),i=a(34044),d=a(75834);let o=e=>{let{header:t,body:a,headerCSS:s="",bodyCSS:o="",itemContainerCSS:u="",itemindex:c=1,hideChevron:m=!1}=e,[p,x]=(0,d.useState)(!1);return(0,n.jsxs)("div",{className:l()("mt-3",u),"data-itemindex":c,children:[(0,n.jsxs)("button",{type:"button",onClick:()=>x(!p),className:l()("relative cursor-pointer border dark:border-slate-800 bg-white dark:bg-slate-900 text-slate-500 dark:text-slate-200 hover:bg-slate-50 dark:hover:bg-slate-700 w-full max-w-full overflow-hidden",s),children:[(0,n.jsx)("div",{className:"w-full",children:t}),!m&&(0,n.jsx)("span",{className:"px-2",children:p?(0,n.jsx)(r.A,{className:"h-5 w-5"}):(0,n.jsx)(i.A,{className:"h-5 w-5"})})]}),p?(0,n.jsx)("div",{className:l()("rounded-lg sm:p-4 xl:p-10 relative overflow-visible",o),children:a}):""]})},u=e=>{let{data:t,containerCSS:a="",headerCSS:s="",bodyCSS:r="",itemContainerCSS:i="",hideChevron:d=!1,...u}=e;return(0,n.jsx)("div",{className:l()("my-3",a),...u,children:t.map((e,t)=>{let{header:a,body:l}=e;return(0,n.jsx)(o,{itemindex:t,header:a,body:l,headerCSS:s,bodyCSS:r,itemContainerCSS:i,hideChevron:d},t)})})}},51599:(e,t,a)=>{a.d(t,{A:()=>u});var n=a(9985),s=a(15968),l=a(62206),r=a(564),i=a(815);function d(){let e=(0,n._)(["\n mutation CreateProduct(\n $product: CreateProductInput!\n $texts: [ProductTextInput!]\n ) {\n createProduct(product: $product, texts: $texts) {\n ...ProductDetailFragment\n ... on SimpleProduct {\n texts {\n ...ProductTextsFragment\n }\n }\n ... on ConfigurableProduct {\n texts {\n ...ProductTextsFragment\n }\n }\n ... on BundleProduct {\n texts {\n ...ProductTextsFragment\n }\n }\n ... on TokenizedProduct {\n texts {\n ...ProductTextsFragment\n }\n }\n ... on PlanProduct {\n texts {\n ...ProductTextsFragment\n }\n }\n }\n }\n ","\n ","\n"]);return d=function(){return e},e}let o=(0,s.J1)(d(),r.A,i.A),u=()=>{let[e,{data:t,error:a,loading:n}]=(0,l.n)(o);return{createProduct:async t=>{let{product:{type:a,tags:n},texts:s}=t;return e({variables:{product:{type:a,tags:n},texts:s},refetchQueries:["Products","ShopStatus","ShopInfo"]})},newProduct:null==t?void 0:t.createProduct,error:a,loading:n}}},57267:(e,t,a)=>{a.d(t,{A:()=>d});var n=a(9985),s=a(15968),l=a(62206);function r(){let e=(0,n._)(["\n mutation RemoveProduct($productId: ID!) {\n removeProduct(productId: $productId) {\n _id\n }\n }\n"]);return r=function(){return e},e}let i=(0,s.J1)(r()),d=()=>{let[e]=(0,l.n)(i);return{removeProduct:async t=>{let{productId:a}=t;return e({variables:{productId:a},refetchQueries:["Products","ShopStatus","ShopInfo"]})}}}},65459:(e,t,a)=>{a.d(t,{A:()=>u,g:()=>o});var n=a(9985),s=a(15968),l=a(70486),r=a(23416),i=a(815);function d(){let e=(0,n._)(["\n query TranslatedProductTexts($productId: ID!) {\n translatedProductTexts(productId: $productId) {\n ...ProductTextsFragment\n ","\n }\n }\n ","\n"]);return d=function(){return e},e}let o=function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"";return(0,s.J1)(d(),e,i.A)},u=e=>{let{productId:t}=e,{customProperties:a}=(0,r.A)(),{data:n,loading:s,error:i}=(0,l.I)(o(null==a?void 0:a.ProductTexts),{skip:!t,variables:{productId:t}});return{translatedTexts:(null==n?void 0:n.translatedProductTexts)||[],loading:s,error:i}}},67032:(e,t,a)=>{a.d(t,{A:()=>l});var n=a(26514),s=a(57104);let l=e=>{let{title:t=null,description:a}=e;return(0,n.jsx)("div",{className:"mb-6 p-4 bg-blue-50 dark:bg-blue-900/20 border border-blue-200 dark:border-blue-800 rounded-lg",children:(0,n.jsxs)("div",{className:"flex items-start gap-3",children:[(0,n.jsx)(s.A,{className:"w-5 h-5 text-blue-600 dark:text-blue-400 mt-0.5 flex-shrink-0"}),(0,n.jsxs)("div",{children:[t&&(0,n.jsx)("h3",{className:"text-sm font-semibold text-blue-900 dark:text-blue-100 mb-2",children:t}),(0,n.jsx)("p",{className:"text-sm text-blue-800 dark:text-blue-200 leading-relaxed",children:a})]})]})})}},76500:(e,t,a)=>{a.d(t,{A:()=>o});var n=a(9985),s=a(15968),l=a(62206),r=a(564);function i(){let e=(0,n._)(["\n mutation UpdateProduct($productId: ID!, $product: UpdateProductInput!) {\n updateProduct(productId: $productId, product: $product) {\n ...ProductDetailFragment\n }\n }\n ","\n"]);return i=function(){return e},e}let d=(0,s.J1)(i(),r.A),o=()=>{let[e]=(0,l.n)(d);return{updateProduct:async t=>{let{productId:a,product:{tags:n,sequence:s,meta:l}}=t;return e({variables:{productId:a,product:{tags:n,sequence:s,meta:l}},refetchQueries:["Products","ShopStatus","ShopInfo"]})}}}}}]);