@debales/ai 1.1.43 → 1.1.44

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.
package/dist/module/ai.js CHANGED
@@ -39965,11 +39965,23 @@ const bfe = oe.div`
39965
39965
  console.error("⛓️‍💥⛓️‍💥Error fetching product data:", V), S(!1);
39966
39966
  }
39967
39967
  }, G = async () => {
39968
+ console.log("handleTheCollectiveProductData");
39968
39969
  try {
39969
39970
  if (!(t != null && t.variants) || t.variants.length === 0) {
39970
39971
  console.warn("No variants available for The Collective product"), S(!1);
39971
39972
  return;
39972
39973
  }
39974
+ if (t.variants.length === 1) {
39975
+ const K = t.variants[0], ge = {
39976
+ id: K.id,
39977
+ title: K.title,
39978
+ options: K.selectedOptions.map((W) => W.value),
39979
+ available: K.inventoryQuantity > 0,
39980
+ price: K.price.toString()
39981
+ };
39982
+ o(ge), r(!1), S(!1);
39983
+ return;
39984
+ }
39973
39985
  const V = t.variants.filter(
39974
39986
  (K) => K.inventoryQuantity > 0
39975
39987
  );
@@ -39991,7 +40003,7 @@ const bfe = oe.div`
39991
40003
  )
39992
40004
  ).filter((W) => typeof W == "string");
39993
40005
  return { name: K, values: ge };
39994
- }).filter((K) => K.values.length > 1);
40006
+ });
39995
40007
  d(Y);
39996
40008
  const J = V.map((K) => ({
39997
40009
  id: K.id,
@@ -40000,14 +40012,11 @@ const bfe = oe.div`
40000
40012
  available: !0,
40001
40013
  price: K.price.toString()
40002
40014
  }));
40003
- if (p(J), V.length === 1) {
40004
- o(J[0]), r(!1), S(!1);
40005
- return;
40006
- }
40015
+ p(J), console.log("options", t), console.log("transformedVariants", J);
40007
40016
  const re = {};
40008
40017
  Y.forEach((K) => {
40009
40018
  re[K.name] = K.values[0];
40010
- }), m(re), S(!1);
40019
+ }), m(re), console.log("initialOptions", re), S(!1);
40011
40020
  } catch (V) {
40012
40021
  console.error("Error processing The Collective product data:", V), S(!1);
40013
40022
  }
@@ -40045,7 +40054,7 @@ const bfe = oe.div`
40045
40054
  A("");
40046
40055
  }, [y]), an(() => {
40047
40056
  n || T(null);
40048
- }, [n]), !n || l.length === 0 || l.every((q) => q.values.length === 1) || x ? null : /* @__PURE__ */ M.jsxs(M.Fragment, { children: [
40057
+ }, [n]), !n || l.length === 0 || x ? null : /* @__PURE__ */ M.jsxs(M.Fragment, { children: [
40049
40058
  /* @__PURE__ */ M.jsx(Ufe, {}),
40050
40059
  /* @__PURE__ */ M.jsxs(jfe, { $botId: a, children: [
40051
40060
  /* @__PURE__ */ M.jsx(Qfe, { onClick: () => r(!1), type: "button", children: "×" }),
@@ -1751,7 +1751,7 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
1751
1751
  font-weight: ${e=>ke(e.theme.botId)?"400":"700"};
1752
1752
  line-height: normal !important;
1753
1753
  word-wrap: break-word;
1754
- `,LA=({uidata:e,product:t,showModel:n,setShowModel:r,onVariantSelect:o,botId:a})=>{const[l,d]=ie.useState([]),[h,p]=ie.useState([]),[y,m]=ie.useState({}),[x,S]=ie.useState(!0),[w,T]=ie.useState(null),[k,A]=ie.useState(""),D=Vc.detect();ie.useEffect(()=>{const q=async()=>{try{const V=dp(e.shopifyShopDomain||"");if(!V.isValid)throw new Error("Invalid URL");let F;if(t!=null&&t.handle)F=await fetch(new URL(`/products/${t.handle}.js`,V.url));else{const pe=t==null?void 0:t.link.replace(/^https:\/\/https:\/\//,"https://"),Me=new URL((pe==null?void 0:pe.split("?")[0])+".js");Me.hostname=V.url.hostname,F=await fetch(Me)}const Y=await F.json(),J=Y.variants.filter(pe=>pe.available),oe={};Y.options.forEach(pe=>{oe[pe.name]=new Set}),J.forEach(pe=>{pe.options.forEach((Me,H)=>{oe[Y.options[H].name].add(Me)})});const K=Y.options.map(pe=>({name:pe.name,values:Array.from(oe[pe.name])})).filter(pe=>pe.values.length>0);d(K);const me=K.every(pe=>pe.values.length===1),W=J.map(pe=>({id:pe.id.toString(),title:Y.title,options:pe.options,available:pe.available,price:Number((pe.price/100).toFixed(2))}));p(W);const fe={};if(K.forEach(pe=>{fe[pe.name]=pe.values[0]}),m(fe),me){const pe=W.find(Me=>K.every((H,ne)=>Me.options[ne]===H.values[0]));pe&&(o(pe),r(!1))}S(!1)}catch(V){console.error("⛓️‍💥⛓️‍💥Error fetching product data:",V),S(!1)}},G=async()=>{try{if(!(t!=null&&t.variants)||t.variants.length===0){console.warn("No variants available for The Collective product"),S(!1);return}const V=t.variants.filter(K=>K.inventoryQuantity>0);if(V.length===0){console.warn("No in-stock variants for The Collective product"),S(!1);return}const Y=V[0].selectedOptions.map(K=>K.name).map(K=>{const me=Array.from(new Set(V.map(W=>{var fe;return(fe=W.selectedOptions.find(pe=>pe.name===K))==null?void 0:fe.value}).filter(Boolean))).filter(W=>typeof W=="string");return{name:K,values:me}}).filter(K=>K.values.length>1);d(Y);const J=V.map(K=>({id:K.id,title:K.title,options:K.selectedOptions.map(me=>me.value),available:!0,price:K.price.toString()}));if(p(J),V.length===1){o(J[0]),r(!1),S(!1);return}const oe={};Y.forEach(K=>{oe[K.name]=K.values[0]}),m(oe),S(!1)}catch(V){console.error("Error processing The Collective product data:",V),S(!1)}};n&&t&&D===vi.SHOPIFY?q():n&&t&&D===vi.THE_COLLECTIVE&&G()},[t,n,o,r,e.shopifyShopDomain,D]);const O=(q,G)=>{m(V=>({...V,[q]:G}))},I=()=>(console.log("Selected Options:",y),console.log("Available Variants:",h),h.find(G=>{const V=l.every((F,Y)=>G.options[Y]===y[F.name]);return console.log("Checking variant:",G,"Matches:",V),V})),N=()=>l.every(q=>y[q.name]&&y[q.name].trim()!==""),L=()=>{if(!N()){A("Please select all options to continue");return}const q=I();q?(A(""),o(q),r(!1)):A("This variant combination is not available")};return ie.useEffect(()=>{A("")},[y]),ie.useEffect(()=>{n||T(null)},[n]),!n||l.length===0||l.every(q=>q.values.length===1)||x?null:R.jsxs(R.Fragment,{children:[R.jsx(cce,{}),R.jsxs(fce,{$botId:a,children:[R.jsx(xce,{onClick:()=>r(!1),type:"button",children:"×"}),R.jsx(_ce,{children:"Please Select from Options"}),l.map(q=>R.jsxs(dce,{children:[R.jsx(hce,{children:q.name}),R.jsx(bce,{options:q.values,selectedOption:y[q.name],onSelect:G=>O(q.name,G),name:q.name,activeDropdown:w,setActiveDropdown:T,botId:a})]},q.name)),k&&R.jsx(yce,{children:k}),R.jsx("button",{onClick:L,type:"button",style:{backgroundColor:e.callToActionBackgroundColor||"#F48722",color:e.callToActionFontColor||"#fff",padding:"10px",border:"none",borderRadius:ke(a)?"0":"8px",width:"100%",cursor:"pointer",minHeight:"44px",fontSize:"16px",textTransform:ke(a)?"uppercase":"capitalize"},title:"Select Variant",children:"Continue"})]})]})},Sce=ee.form`
1754
+ `,LA=({uidata:e,product:t,showModel:n,setShowModel:r,onVariantSelect:o,botId:a})=>{const[l,d]=ie.useState([]),[h,p]=ie.useState([]),[y,m]=ie.useState({}),[x,S]=ie.useState(!0),[w,T]=ie.useState(null),[k,A]=ie.useState(""),D=Vc.detect();ie.useEffect(()=>{const q=async()=>{try{const V=dp(e.shopifyShopDomain||"");if(!V.isValid)throw new Error("Invalid URL");let F;if(t!=null&&t.handle)F=await fetch(new URL(`/products/${t.handle}.js`,V.url));else{const pe=t==null?void 0:t.link.replace(/^https:\/\/https:\/\//,"https://"),Me=new URL((pe==null?void 0:pe.split("?")[0])+".js");Me.hostname=V.url.hostname,F=await fetch(Me)}const Y=await F.json(),J=Y.variants.filter(pe=>pe.available),oe={};Y.options.forEach(pe=>{oe[pe.name]=new Set}),J.forEach(pe=>{pe.options.forEach((Me,H)=>{oe[Y.options[H].name].add(Me)})});const K=Y.options.map(pe=>({name:pe.name,values:Array.from(oe[pe.name])})).filter(pe=>pe.values.length>0);d(K);const me=K.every(pe=>pe.values.length===1),W=J.map(pe=>({id:pe.id.toString(),title:Y.title,options:pe.options,available:pe.available,price:Number((pe.price/100).toFixed(2))}));p(W);const fe={};if(K.forEach(pe=>{fe[pe.name]=pe.values[0]}),m(fe),me){const pe=W.find(Me=>K.every((H,ne)=>Me.options[ne]===H.values[0]));pe&&(o(pe),r(!1))}S(!1)}catch(V){console.error("⛓️‍💥⛓️‍💥Error fetching product data:",V),S(!1)}},G=async()=>{console.log("handleTheCollectiveProductData");try{if(!(t!=null&&t.variants)||t.variants.length===0){console.warn("No variants available for The Collective product"),S(!1);return}if(t.variants.length===1){const K=t.variants[0],me={id:K.id,title:K.title,options:K.selectedOptions.map(W=>W.value),available:K.inventoryQuantity>0,price:K.price.toString()};o(me),r(!1),S(!1);return}const V=t.variants.filter(K=>K.inventoryQuantity>0);if(V.length===0){console.warn("No in-stock variants for The Collective product"),S(!1);return}const Y=V[0].selectedOptions.map(K=>K.name).map(K=>{const me=Array.from(new Set(V.map(W=>{var fe;return(fe=W.selectedOptions.find(pe=>pe.name===K))==null?void 0:fe.value}).filter(Boolean))).filter(W=>typeof W=="string");return{name:K,values:me}});d(Y);const J=V.map(K=>({id:K.id,title:K.title,options:K.selectedOptions.map(me=>me.value),available:!0,price:K.price.toString()}));p(J),console.log("options",t),console.log("transformedVariants",J);const oe={};Y.forEach(K=>{oe[K.name]=K.values[0]}),m(oe),console.log("initialOptions",oe),S(!1)}catch(V){console.error("Error processing The Collective product data:",V),S(!1)}};n&&t&&D===vi.SHOPIFY?q():n&&t&&D===vi.THE_COLLECTIVE&&G()},[t,n,o,r,e.shopifyShopDomain,D]);const O=(q,G)=>{m(V=>({...V,[q]:G}))},I=()=>(console.log("Selected Options:",y),console.log("Available Variants:",h),h.find(G=>{const V=l.every((F,Y)=>G.options[Y]===y[F.name]);return console.log("Checking variant:",G,"Matches:",V),V})),N=()=>l.every(q=>y[q.name]&&y[q.name].trim()!==""),L=()=>{if(!N()){A("Please select all options to continue");return}const q=I();q?(A(""),o(q),r(!1)):A("This variant combination is not available")};return ie.useEffect(()=>{A("")},[y]),ie.useEffect(()=>{n||T(null)},[n]),!n||l.length===0||x?null:R.jsxs(R.Fragment,{children:[R.jsx(cce,{}),R.jsxs(fce,{$botId:a,children:[R.jsx(xce,{onClick:()=>r(!1),type:"button",children:"×"}),R.jsx(_ce,{children:"Please Select from Options"}),l.map(q=>R.jsxs(dce,{children:[R.jsx(hce,{children:q.name}),R.jsx(bce,{options:q.values,selectedOption:y[q.name],onSelect:G=>O(q.name,G),name:q.name,activeDropdown:w,setActiveDropdown:T,botId:a})]},q.name)),k&&R.jsx(yce,{children:k}),R.jsx("button",{onClick:L,type:"button",style:{backgroundColor:e.callToActionBackgroundColor||"#F48722",color:e.callToActionFontColor||"#fff",padding:"10px",border:"none",borderRadius:ke(a)?"0":"8px",width:"100%",cursor:"pointer",minHeight:"44px",fontSize:"16px",textTransform:ke(a)?"uppercase":"capitalize"},title:"Select Variant",children:"Continue"})]})]})},Sce=ee.form`
1755
1755
  padding: 2px;
1756
1756
  margin: 8px 12px;
1757
1757
  position: relative;
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@debales/ai",
3
3
  "private": false,
4
4
  "access": "public",
5
- "version": "1.1.43",
5
+ "version": "1.1.44",
6
6
  "type": "module",
7
7
  "main": "./dist/module/ai.js",
8
8
  "types": "./dist/module/index.d.ts",
@@ -53,9 +53,9 @@
53
53
  "typescript-eslint": "^8.24.1",
54
54
  "vite": "^6.2.0",
55
55
  "vite-plugin-dts": "^4.5.3",
56
+ "@debales/eslint-config": "0.0.0",
56
57
  "@debales/shared": "0.0.1",
57
- "@debales/typescript-config": "0.0.0",
58
- "@debales/eslint-config": "0.0.0"
58
+ "@debales/typescript-config": "0.0.0"
59
59
  },
60
60
  "peerDependencies": {
61
61
  "react": "^18.0.0 || ^19.0.0",