PageSourceSearch

https://woolyfeed.vercel.app/_next/static/chunks/pages/settings/datasources-26dec0f2e96c7a13.js

js woolyfeed.vercel.app collected 2026-10-03 08:04:42 UTC 26,483 bytes, 1 lines download raw bytes

1(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[5200],{13649:function(e,t,n){"use strict";n.d(t,{S:function(){return SvgCirclePlusMinor}});var a=n(67294),SvgCirclePlusMinor=function(e){return a.createElement("svg",Object.assign({viewBox:"0 0 20 20"},e),a.createElement("path",{d:"M6.25 10a.75.75 0 0 1 .75-.75h2.25v-2.25a.75.75 0 0 1 1.5 0v2.25h2.25a.75.75 0 0 1 0 1.5h-2.25v2.25a.75.75 0 0 1-1.5 0v-2.25h-2.25a.75.75 0 0 1-.75-.75Z"}),a.createElement("path",{fillRule:"evenodd",d:"M10 17a7 7 0 1 0 0-14 7 7 0 0 0 0 14Zm0-1.5a5.5 5.5 0 1 0 0-11 5.5 5.5 0 0 0 0 11Z"}))};SvgCirclePlusMinor.displayName="CirclePlusMinor"},55369:function(e,t,n){"use strict";n.d(t,{S:function(){return SvgDeleteMinor}});var a=n(67294),SvgDeleteMinor=function(e){return a.createElement("svg",Object.assign({viewBox:"0 0 20 20"},e),a.createElement("path",{d:"M11.5 8.25a.75.75 0 0 1 .75.75v4.25a.75.75 0 0 1-1.5 0v-4.25a.75.75 0 0 1 .75-.75Z"}),a.createElement("path",{d:"M9.25 9a.75.75 0 0 0-1.5 0v4.25a.75.75 0 0 0 1.5 0v-4.25Z"}),a.createElement("path",{fillRule:"evenodd",d:"M7.25 5.25a2.75 2.75 0 0 1 5.5 0h3a.75.75 0 0 1 0 1.5h-.75v5.45c0 1.68 0 2.52-.327 3.162a3 3 0 0 1-1.311 1.311c-.642.327-1.482.327-3.162.327h-.4c-1.68 0-2.52 0-3.162-.327a3 3 0 0 1-1.311-1.311c-.327-.642-.327-1.482-.327-3.162v-5.45h-.75a.75.75 0 0 1 0-1.5h3Zm1.5 0a1.25 1.25 0 1 1 2.5 0h-2.5Zm-2.25 1.5h7v5.45c0 .865-.001 1.423-.036 1.848-.033.408-.09.559-.128.633a1.5 1.5 0 0 1-.655.655c-.074.038-.225.095-.633.128-.425.035-.983.036-1.848.036h-.4c-.865 0-1.423-.001-1.848-.036-.408-.033-.559-.09-.633-.128a1.5 1.5 0 0 1-.656-.655c-.037-.074-.094-.225-.127-.633-.035-.425-.036-.983-.036-1.848v-5.45Z"}))};SvgDeleteMinor.displayName="DeleteMinor"},74209:function(e,t,n){"use strict";n.d(t,{S:function(){return SvgFileMinor}});var a=n(67294),SvgFileMinor=function(e){return a.createElement("svg",Object.assign({viewBox:"0 0 20 20"},e),a.createElement("path",{d:"M8 12.5a1 1 0 1 0 0 2h4a1 1 0 1 0 0-2h-4Z"}),a.createElement("path",{fillRule:"evenodd",d:"M6.75 2.5a2.75 2.75 0 0 0-2.75 2.75v9.5a2.75 2.75 0 0 0 2.75 2.75h6.5a2.75 2.75 0 0 0 2.75-2.75v-6a.75.75 0 0 0-.22-.53l-5.5-5.5a.75.75 0 0 0-.53-.22h-3Zm-1.25 2.75c0-.69.56-1.25 1.25-1.25h2.25v3.75c0 .966.784 1.75 1.75 1.75h3.75v5.25c0 .69-.56 1.25-1.25 1.25h-6.5c-.69 0-1.25-.56-1.25-1.25v-9.5Zm7.94 2.75-2.94-2.94v2.69c0 .138.112.25.25.25h2.69Z"}))};SvgFileMinor.displayName="FileMinor"},12115:function(e,t,n){"use strict";n.d(t,{i:function(){return Divider}});var a=n(67294);let Divider=({borderColor:e="border-secondary",borderWidth:t="025"})=>{let n="transparent"===e?e:`var(--p-color-${e})`;return a.createElement("hr",{className:"Polaris-Divider",style:{borderBlockStart:`var(--p-border-width-${t}) solid ${n}`}})}},71241:function(e,t,n){"use strict";n.d(t,{u:function(){return EmptyState}});var a=n(67294),r=n(68658),i={ImageContainer:"Polaris-EmptyState__ImageContainer",Image:"Polaris-EmptyState__Image",loaded:"Polaris-EmptyState--loaded",imageContained:"Polaris-EmptyState--imageContained",SkeletonImageContainer:"Polaris-EmptyState__SkeletonImageContainer",SkeletonImage:"Polaris-EmptyState__SkeletonImage"},l=n(61821),o=n(36731),s=n(89072),c=n(78369),u=n(53879),d=n(86147);function EmptyState({children:e,heading:t,image:n,largeImage:m,imageContained:h,fullWidth:p=!1,action:v,secondaryAction:g,footerContent:f}){let[y,S]=(0,a.useState)(!1),x=(0,a.useRef)(null);(0,a.useEffect)(()=>{x.current?.complete&&S(!0)},[]);let j=(0,r.AK)(i.Image,y&&i.loaded,h&&i.imageContained),E=m?a.createElement(c.E,{alt:"",role:"presentation",ref:x,source:m,className:j,sourceSet:[{source:n,descriptor:"568w"},{source:m,descriptor:"1136w"}],sizes:"(max-width: 568px) 60vw",onLoad:()=>S(!0)}):a.createElement(c.E,{alt:"",role:"presentation",ref:x,className:j,source:n,onLoad:()=>S(!0)}),C=(0,r.AK)(i.SkeletonImage,y&&i.loaded),b=(0,r.AK)(i.ImageContainer,!y&&i.SkeletonImageContainer),_=a.createElement("div",{className:b},E,a.createElement("div",{className:C})),w=g?(0,l.h)(g,{}):null,M=f?a.createElement(o.x,{paddingBlockStart:"400"},a.createElement(u.x,{as:"span",alignment:"center",variant:"bodySm"},f)):null,A=v?(0,l.h)(v,{variant:"primary",size:"medium"}):null,k=t?a.createElement(o.x,{paddingBlockEnd:"150"},a.createElement(u.x,{variant:"headingMd",as:"p",alignment:"center"},t)):null,L=e?a.createElement(u.x,{as:"span",alignment:"center",variant:"bodySm"},e):null,P=k||e?a.createElement(o.x,{paddingBlockEnd:"400"},k,L):null,D=A||w?a.createElement(d.g,{align:"center",gap:"200"},w,A):null,I=P||D||M?a.createElement(o.x,{maxWidth:p?"100%":"400px"}
1,a.createElement(s.E,{inlineAlign:"center"},P,D,M)):null;return a.createElement(o.x,{paddingInlineStart:"0",paddingInlineEnd:"0",paddingBlockStart:"500",paddingBlockEnd:"1600"},a.createElement(s.E,{inlineAlign:"center"},_,I))}},92818:function(e,t,n){"use strict";n.d(t,{A:function(){return Layout}});var a=n(67294),r={Layout:"Polaris-Layout",Section:"Polaris-Layout__Section","Section-fullWidth":"Polaris-Layout__Section--fullWidth","Section-oneHalf":"Polaris-Layout__Section--oneHalf","Section-oneThird":"Polaris-Layout__Section--oneThird",AnnotatedSection:"Polaris-Layout__AnnotatedSection",AnnotationWrapper:"Polaris-Layout__AnnotationWrapper",AnnotationContent:"Polaris-Layout__AnnotationContent",Annotation:"Polaris-Layout__Annotation"},i=n(44746),l=n(53879),o=n(36731),s=n(68658);function Section({children:e,variant:t}){let n=(0,s.AK)("Polaris-Layout__Section",r[`Section-${t}`]);return a.createElement("div",{className:n},e)}let Layout=function({sectioned:e,children:t}){let n=e?a.createElement(Section,null,t):t;return a.createElement("div",{className:"Polaris-Layout"},n)};Layout.AnnotatedSection=function({children:e,title:t,description:n,id:r}){let s="string"==typeof n?a.createElement(l.x,{as:"p",variant:"bodyMd"},n):n;return a.createElement("div",{className:"Polaris-Layout__AnnotatedSection"},a.createElement("div",{className:"Polaris-Layout__AnnotationWrapper"},a.createElement("div",{className:"Polaris-Layout__Annotation"},a.createElement(i.l,{spacing:"tight"},a.createElement(l.x,{id:r,variant:"headingMd",as:"h2"},t),s&&a.createElement(o.x,{color:"text-secondary"},s))),a.createElement("div",{className:"Polaris-Layout__AnnotationContent"},e)))},Layout.Section=Section},6075:function(e,t,n){"use strict";n.d(t,{i:function(){return useDynamicList}});var a=n(48043),r=n(37117);function useDynamicList(e,t,n=[]){let{fields:i,dispatch:l,reset:o,dirty:s,newDefaultValue:c,value:u,defaultValue:d}=(0,a.A)(e,n);return{fields:i,addItem:function(e){let n=t(e);Array.isArray(n)?l((0,r.Ht)(n)):l((0,r.Ht)([n]))},editItem:function(e,t){l((0,r.Fl)(e,t))},removeItem:function(e){l((0,r.X2)(e))},removeItems:function(e){l((0,r.kg)(e))},moveItem:function(e,t){l((0,r.aZ)(e,t))},reset:o,dirty:s,value:u,newDefaultValue:c,defaultValue:d}}},20640:function(e,t,n){"use strict";var a=n(11742),r={"text/plain":"Text","text/html":"Url",default:"Text"};e.exports=function(e,t){var n,i,l,o,s,c,u,d,m=!1;t||(t={}),l=t.debug||!1;try{if(s=a(),c=document.createRange(),u=document.getSelection(),(d=document.createElement("span")).textContent=e,d.ariaHidden="true",d.style.all="unset",d.style.position="fixed",d.style.top=0,d.style.clip="rect(0, 0, 0, 0)",d.style.whiteSpace="pre",d.style.webkitUserSelect="text",d.style.MozUserSelect="text",d.style.msUserSelect="text",d.style.userSelect="text",d.addEventListener("copy",function(n){if(n.stopPropagation(),t.format){if(n.preventDefault(),void 0===n.clipboardData){l&&console.warn("unable to use e.clipboardData"),l&&console.warn("trying IE specific stuff"),window.clipboardData.clearData();var a=r[t.format]||r.default;window.clipboardData.setData(a,e)}else n.clipboardData.clearData(),n.clipboardData.setData(t.format,e)}t.onCopy&&(n.preventDefault(),t.onCopy(n.clipboardData))}),document.body.appendChild(d),c.selectNodeContents(d),u.addRange(c),!document.execCommand("copy"))throw Error("copy command was unsuccessful");m=!0}catch(a){l&&console.error("unable to copy using execCommand: ",a),l&&console.warn("trying IE specific stuff");try{window.clipboardData.setData(t.format||"text",e),t.onCopy&&t.onCopy(window.clipboardData),m=!0}catch(a){l&&console.error("unable to copy using clipboardData: ",a),l&&console.error("falling back to prompt"),n="message"in t?t.message:"Copy to clipboard: #{key}, Enter",i=(/mac os x/i.test(navigator.userAgent)?"⌘":"Ctrl")+"+C",o=n.replace(/#{\s*key\s*}/g,i),window.prompt(o,e)}}finally{u&&("function"==typeof u.removeRange?u.removeRange(c):u.removeAllRanges()),d&&document.body.removeChild(d),s()}return m}},90821:function(e,t,n){(window.__NEXT_P=window.__NEXT_P||[]).push(["/settings/datasources",function(){return n(95463)}])},46415:function(e,t,n){"use strict";var a=n(85893),r=n(20640),i=n.n(r),l=n(67294),o=n(96241),s=n.n(o),c=n(78744),u=n(53879),d=n(12115),m=n(86849),h=n(51783),p=n(15253),v=n(41322),g=n(44706),f=n(18580),y=n(45697),S=n.n(y);function renderCell(e,t){try{if(["product_highlight","free_shipping_threshold","product_detail"].includes(t)||t.startsWith("shipping(")||t.startsWith("tax(")||t.startsWith("certification(")){let n=s()(e,"product_detail"==t&&{delimiter:":",recordDelimiter:",",quote:!0}),r="product_detail"==t&&n||n[0]||n;return(0,a.jsx)("ul",{style:{padding:0,listStylePosition:"inside"},children:"product_detail"==t?r.map((e,t)=>
1{let[n,r,i]=e;return(0,a.jsxs)("div",{children:[(0,a.jsxs)("p",{children:[(0,a.jsx)(u.x,{as:"span",fontWeight:"semibold",children:"Section"})," ",n]}),(0,a.jsxs)("p",{children:[(0,a.jsx)(u.x,{as:"span",fontWeight:"semibold",children:"Name"})," ",r]}),(0,a.jsxs)("p",{children:[(0,a.jsx)(u.x,{as:"span",fontWeight:"semibold",children:"Value"})," ",i]}),(0,a.jsx)(d.i,{})]},t)}):r.map((e,t)=>(0,a.jsx)("li",{children:Array.isArray(e)&&e.map(e=>(0,a.jsx)("div",{children:e},e))||e},t))})}}catch(e){}return e}n(40154);let CSVViewer=e=>{let{csv:t,preParsedData:n,delimiter:r,showToastMessage:o,previewMap:u={},showAll:d}=e,y=(0,l.useMemo)(()=>{if(n)return n[0]||[];try{let e=s()(t,{to_line:1,delimiter:r});return e?e[0]:[]}catch(e){return[]}},[t,r,n]),S=(0,l.useMemo)(()=>(null==y?void 0:y.map(()=>"text"))||[],[y]),x=(0,l.useMemo)(()=>n?n.slice(1):s()(t,{from_line:2,delimiter:r,relax:!0,relax_column_count:!0}),[t,r,n]),j=(0,l.useMemo)(()=>x.map(e=>e.map((e,t)=>{let n;if(e.startsWith("http"))return e.split(",http").map((e,t)=>{e.startsWith("http")||(e="http"+e);let n=/(jpg|gif|png|JPG|GIF|PNG|JPEG|jpeg)(\?.*)?$/.test(e),r=/(mp4)(\?.*)?$/.test(e);return(0,a.jsxs)("div",{style:{display:n||r?"flex":"",marginBottom:10},children:[(n||r)&&(0,a.jsx)("img",{width:"50",height:"100%",style:{marginRight:10},src:u[e]||e}),(0,a.jsxs)(m.D,{vertical:!0,spacing:"none",children:[(0,a.jsx)(h.z,{icon:r?v.S:g.S,plain:!0,url:e,external:!0,children:r?"Play":"Open"}),(0,a.jsx)(h.z,{icon:f.S,plain:!0,onClick:()=>{i()(e),o({content:"URL copied"})},children:"Copy"})]})]},t)});try{n=decodeURIComponent(e)}catch(t){n=e}return["title","description"].includes(y[t])?(0,a.jsxs)("div",{style:{minWidth:200},children:[" ",(0,a.jsx)(c.Z,{lines:4,more:"See more",less:"See less",className:"description",anchorClass:"my-anchor-css-class",expanded:!1,truncatedEndingComponent:"... ",children:renderCell(n,y[t])},t)]}):(0,a.jsx)("div",{style:["title","product_highlight","product_detail"].includes(y[t])?{minWidth:250,whiteSpace:"break-spaces"}:void 0,children:renderCell(n,y[t])},t)})),[x,y]),E=(0,l.useMemo)(()=>y.map((e,t)=>x.some(e=>e[t])),[y,x]),C=(0,l.useMemo)(()=>y.filter((e,t)=>d||E[t]),[d,y,E]),b=(0,l.useMemo)(()=>j.map(e=>e.filter((e,t)=>d||E[t])),[d,j,E]);return(0,a.jsx)("div",{className:"my-datatable",children:(0,a.jsx)(p.w,{rows:b,headings:C,columnContentTypes:S,increasedTableDensity:!0,stickyHeader:!0,hasZebraStripingOnData:!0,hoverable:!1})})};CSVViewer.propTypes={csv:S().string,delimiter:S().string,showToastMessage:S().func,previewMap:S().object},t.Z=(0,l.memo)(CSVViewer)},95463:function(e,t,n){"use strict";n.r(t),n.d(t,{default:function(){return B}});var a=n(85893),r=n(67294),i=n(86849),l=n(53879),o=n(87268),s=n(92818),c=n(68614),u=n(89072),d=n(28921),m=n(39601),h=n(72795),p=n(86147),v=n(66099),g=n(32222),f=n(12115),y=n(55587),S=n(51783),x=n(43835),j=n(71241),E=n(36731),C=n(67326),b=n(74209),SvgColumns3Minor=function(e){return r.createElement("svg",Object.assign({viewBox:"0 0 20 20"},e),r.createElement("path",{fillRule:"evenodd",d:"M6 3a3 3 0 0 0-3 3v8a3 3 0 0 0 3 3h8a3 3 0 0 0 3-3v-8a3 3 0 0 0-3-3h-8Zm5.25 1.5h-2.5v11h2.5v-11Zm1.5 0v11h1.25a1.5 1.5 0 0 0 1.5-1.5v-8a1.5 1.5 0 0 0-1.5-1.5h-1.25Zm-6.75 0h1.25v11h-1.25a1.5 1.5 0 0 1-1.5-1.5v-8a1.5 1.5 0 0 1 1.5-1.5Z"}))};SvgColumns3Minor.displayName="Columns3Minor";var SvgAnalyticsTableMinor=function(e){return r.createElement("svg",Object.assign({viewBox:"0 0 20 20"},e),r.createElement("path",{fillRule:"evenodd",d:"M5.5 16.5a2 2 0 0 1-2-2v-9a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v9a2 2 0 0 1-2 2h-9Zm3.25-11.5h2.5v2h-2.5v-2Zm-1.5 0h-1.75a.5.5 0 0 0-.5.5v1.5h2.25v-2Zm0 3.5h-2.25v6a.5.5 0 0 0 .5.5h1.75v-6.5Zm1.5 6.5v-6.5h2.5v6.5h-2.5Zm4-8v-2h1.75a.5.5 0 0 1 .5.5v1.5h-2.25Zm0 1.5v6.5h1.75a.5.5 0 0 0 .5-.5v-6h-2.25Z"}))};SvgAnalyticsTableMinor.displayName="AnalyticsTableMinor";var SvgPriceLookupMinor=function(e){return r.createElement("svg",Object.assign({viewBox:"0 0 20 20"},e),r.createElement("path",{d:"M5.5 4.5a1 1 0 1 1-2 0 1 1 0 0 1 2 0Z"}),r.createElement("path",{fillRule:"evenodd",d:"M13.189 14.25a4.001 4.001 0 0 1-5.648-2h-.791a.75.75 0 0 1 0-1.5h.5c0-.729.195-1.412.535-2h-1.035a.75.75 0 0 1 0-1.5h2.562a4 4 0 0 1 5.033 6.034l1.935 1.936
1a.75.75 0 1 1-1.06 1.06l-2.031-2.03Zm.561-3.5a2.5 2.5 0 1 1-5 0 2.5 2.5 0 0 1 5 0Z"}),r.createElement("path",{d:"M4.5 9a1 1 0 1 0 0-2 1 1 0 0 0 0 2Z"}),r.createElement("path",{d:"M5.5 11.5a1 1 0 1 1-2 0 1 1 0 0 1 2 0Z"}),r.createElement("path",{d:"M6.75 3.75a.75.75 0 0 0 0 1.5h6.5a.75.75 0 0 0 0-1.5h-6.5Z"}))};SvgPriceLookupMinor.displayName="PriceLookupMinor";var _=n(55369),w=n(13649),M=n(6075),A=n(5426),k=n(53416),L=n(44112),P=n(96241),D=n.n(P),I=n(46415),N=n(89554),T=n(32162),Z=n(96642),R=n(16493),U=n(9344),O=n(11662),W=n(39976),G=n(60163);let q=/^https:\/\/docs\.google\.com\/spreadsheets\/d\/([^/]+)\/edit\)?/i;function validatePositiveInt(e){let t=parseInt(String(e),10);if(!Number.isFinite(t)||t<1)return"Must be a positive number"}function dataSourceFactory(){return{name:"",type:"CSV",csvUrl:"",sheetUrl:"",sheetTitle:"",query:"",keyColumn:"1",valueColumn:"2"}}let DataSourcesPage=()=>{let{embedded:e,showToastMessage:t,globalState:n}=(0,r.useContext)(T.ZP),{host:P}=n,{freeDataSourceUnits:N}=(0,O.h)(),{shopOrigin:B}=n,V=(0,r.useRef)(null),{activate:F,awaitingBilling:H,billingAutoSaving:z}=(0,W.nK)({host:P,embedded:e,shopOrigin:B,featureKey:"datasources",returnPath:"settings/datasources",pendingStorageKey:"WF_PENDING_DATASOURCES_SAVE",attemptFn:async t=>{var n;let a=(null==t?void 0:t.dataSources)||(null===(n=V.current)||void 0===n?void 0:n.pendingList)||[];return(0,W.RI)({host:P,embedded:e,dataSources:a,returnPath:"settings/datasources"})()},resumeWithoutAttempt:!0,onSuccess:async e=>{var n,a;let r=(null==e?void 0:e.dataSources)||(null==e?void 0:null===(n=e.pending)||void 0===n?void 0:n.dataSources)||(null===(a=V.current)||void 0===a?void 0:a.pendingList);r&&Q({dataSources:r},!1),t({content:"Data sources saved"})},onBillingTimeout:()=>{t({content:"Billing confirmation timed out. Save again to apply changes.",error:!0})}}),{scopes:K,confirmEnableScope:$}=(0,G.lq)(),{data:J,mutate:Q,isLoading:Y}=(0,L.ZP)(["/api/shop/datasources",P,e],t=>{let[n,a]=t;return(0,U.Z)(e)(n).then(e=>e.json())},{fallbackData:{dataSources:[]}}),X=(0,r.useMemo)(()=>(J.dataSources||[]).map(e=>({id:e.id,name:e.name||"",type:e.type||"CSV",csvUrl:e.csvUrl||"",sheetUrl:e.sheetUrl||"",sheetTitle:e.sheetTitle||"",query:e.query||"",keyColumn:String(e.keyColumn||1),valueColumn:String(e.valueColumn||2)})),[J.dataSources]),ee=(0,M.i)({list:X,validates:{name:(e,t)=>{let{siblings:n}=t,a=String(e||"").trim();if(!a)return"Name is required";let r=a.toLowerCase();if(n.some(e=>{let{name:t}=e;return String(t.value||"").trim().toLowerCase()===r}))return"Name must be unique"},type:e=>!e&&"Required",csvUrl:(e,t)=>{let{listItem:n}=t;if("CSV"===n.type.value){if(!e)return"CSV URL is required";if(!function(e){try{let t=new URL(e);return"http:"===t.protocol||"https:"===t.protocol}catch(e){return!1}}(e))return"Invalid URL"}},sheetUrl:(e,t)=>
1{let{listItem:n}=t;if("GOOGLE_SHEET"===n.type.value){if(!e)return"Google sheet URL is required";if(!String(e).trim().match(q))return"URL must look like https://docs.google.com/spreadsheets/d/{sheetId}/edit"}},query:(e,t)=>{let{listItem:n}=t;if("QUERY"===n.type.value&&!String(e||"").trim())return"Query string is required"},keyColumn:validatePositiveInt,valueColumn:validatePositiveInt}},dataSourceFactory,[X]),et=(0,r.useCallback)(e=>(e.dataSources||[]).map(e=>{let t=String(e.name||"").trim(),n=String(e.type||"").trim(),a=e.id||(0,k.x0)(),r=parseInt(String(e.keyColumn||"1"),10)||1,i=parseInt(String(e.valueColumn||"2"),10)||2;if("CSV"===n)return{id:a,name:t,type:n,csvUrl:String(e.csvUrl||"").trim(),keyColumn:r,valueColumn:i};if("GOOGLE_SHEET"===n){let l=String(e.sheetTitle||"").trim();return{id:a,name:t,type:n,sheetUrl:String(e.sheetUrl||"").trim(),...l?{sheetTitle:l}:{},keyColumn:r,valueColumn:i}}return{id:a,name:t,type:n,query:String(e.query||"").trim(),keyColumn:r,valueColumn:i}}),[]),{submit:en,reset:ea,dirty:er,submitting:ei}=(0,A.c)({makeCleanAfterSubmit:!1,dynamicLists:{dataSources:ee},onSubmit:async n=>{let a=et(n);V.current={pendingList:a};let r=await F({dataSources:a,requiredMin:Math.max(0,a.length-(N||0))});if(null==r?void 0:r.redirected)return t({content:"Waiting for billing confirmation..."}),{status:"fail",errors:[]};if(!(null==r?void 0:r.ok))return(null==r?void 0:r.redirected)||t({content:(null==r?void 0:r.error)||"Failed to save data sources",error:!0}),{status:"fail",errors:[]};let i=await (0,U.Z)(e)("/api/shop/datasources").then(e=>e.json());return Q({dataSources:i.dataSources||a},!1),{status:"success"}}}),el=(0,r.useMemo)(()=>[{label:"CSV file",value:"CSV"},{label:"Google sheet",value:"GOOGLE_SHEET"},{label:"Shopify query",value:"QUERY"}],[]),[eo,es]=(0,r.useState)(!1),[ec,eu]=(0,r.useState)(null),[ed,em]=(0,r.useState)(!1),[eh,ep]=(0,r.useState)(""),[ev,eg]=(0,r.useState)(""),[ef,ey]=(0,r.useState)(","),[eS,ex]=(0,r.useState)(""),[ej,eE]=(0,r.useState)([]),eC=(0,r.useMemo)(()=>{var e;return null==ec?null:(null===(e=ee.value)||void 0===e?void 0:e[ec])||null},[ee.value,ec]),eb=(0,r.useMemo)(()=>{if(!ev)return[];try{return D()(ev,{delimiter:ef,relax:!0,relax_column_count:!0})}catch(e){return[]}},[ev,ef]),e_=(0,r.useMemo)(()=>{if(!eC||!eb.length)return new Map;let e=parseInt(String(eC.keyColumn||"1"),10)||1,t=parseInt(String(eC.valueColumn||"2"),10)||2;try{let n=new Map;for(let a=1;a<eb.length;a++){let r=eb[a],i=null==r?void 0:r[e-1];if(null==i)continue;let l=String(i);if(!l)continue;let o=null==r?void 0:r[t-1];n.set(l,null==o?null:String(o))}return n}catch(e){return new Map}},[eC,eb]),ew=(0,r.useMemo)(()=>eS?e_.get(eS):"",[e_,eS]),eM=(0,r.useCallback)(e=>String(e||"").replaceAll("\\","\\\\").replaceAll('"','\\"'),[]),eA=(0,r.useCallback)(e=>String(e||"").replaceAll("\\","\\\\").replaceAll("'","\\'"),[]),ek=(0,r.useMemo)(()=>{if(!eC)return"";let e=String(eC.name||"").trim();return(0,a.jsxs)(i.D,{alignment:"center",spacing:"tight",children:[(0,a.jsxs)(l.x,{as:"p",variant:"bodySm",tone:void 0==ew?"critical":"success",children:['lookup("',eM(eS||"{key}"),"\", 't#",eA(e||"{table_name}"),"')",eS?" → "+'"'.concat(eM(ew),'"'):""]})," ",(0,a.jsx)("div",{style:{height:20},children:void 0===ew?(0,a.jsx)(o.C,{tone:"warning-strong",children:"Not found"}):null===ew?(0,a.jsxs)(i.D,{alignment:"center",spacing:"extraTight",children:[(0,a.jsx)(o.C,{tone:"warning",children:"No data"}),(0,a.jsxs)("p",{children:["at value column ",null==eC?void 0:eC.valueColumn]})]}):null})]})},[eM,eA,ew,eS,eC]),eL=(0,r.useCallback)(()=>{es(!1),eu(null),em(!1),ep(""),eg(""),ey(","),ex(""),eE([])},[]),eP=(0,r.useCallback)(async t=>{eu(t),es(!0),em(!0),ep(""),eg(""),ey(","),ex(""),eE([]);try{var n;let a=null===(n=ee.value)||void 0===n?void 0:n[t],r=await (0,U.Z)(e)("/api/shop/datasources",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({dataSource:a,limit:1e3})}),i=await r.json().catch(()=>({}));if(!r.ok)throw Error((null==i?void 0:i.error)||"Failed to test data source");eg((null==i?void 0:i.csv)||""),ey((null==i?void 0:i.delimiter)||","),eE(Array.isArray(null==i?void 0:i.parseErrors)?i.parseErrors:[])}catch(e){ep((null==e?void 0:e.message)||String(e))}finally{em(!1)}},[e,ee.value,P]);return(0,a.jsx)(s.A,{children:(0,a.jsxs)(r.Fragment,{children:[(0,a.jsx)(c.u,{open:eo,onClose:eL,title:(null==eC?void 0:eC.name)?"Test data source: ".concat(eC.name):"Test data source",primaryAction:{content:"Close",onAction:eL},children:(0,a.jsx)(c.u.Section,{children:(0,a.jsxs)(u.E,{gap:"300",children:[eh?(0,a.jsx)(d.jL,{tone:"critical",children:(0,a.jsx)("p",{children:eh})}):null,(null==ej?void 0:ej.length)?(0,a.jsx)(d.jL,{tone:"warning",children:(0,a.jsx)("p",{children:JSON.stringify(ej)})}):null,(0,a.jsx)(m.n,{placeholder:"Enter a key to test lookup",label:"Key",prefix:(0,a.jsx)(h.J,{source:C.S}),value:eS,onChange:ex,autoComplete:"off",clearButton:!0,onClearButtonClick:()=>ex(""),disabled:ed||!!eh||!ev}
1),ek,(0,a.jsxs)(l.x,{variant:"bodySm",tone:"subdued",children:["Result by searching on"," ",(null==eb?void 0:eb.length)>=1e3?"first ".concat(1e3):null==eb?void 0:eb.length," ","data rows.",(null==eb?void 0:eb.length)>100?" Only ".concat(100," rows are displayed below for example."):""]}),(0,a.jsx)("div",{style:{height:"calc(100vh - 360px)",overflow:"auto"},children:ed?(0,a.jsxs)(p.g,{gap:"200",blockAlign:"center",children:[(0,a.jsx)(v.$,{size:"small"}),(0,a.jsx)(l.x,{children:"Loading..."})]}):ev?(0,a.jsx)(I.Z,{csv:ev,preParsedData:eb.slice(0,101),delimiter:ef,showToastMessage:t,showAll:!0}):null})]})})}),(0,a.jsx)(Z.Z,{active:er,saveAction:{content:"Save",onAction:en,loading:ei},discardAction:{content:"Discard",onAction:ea,disabled:ei}}),(0,a.jsx)(s.A.AnnotatedSection,{title:(0,a.jsxs)(p.g,{gap:"200",children:[(0,a.jsx)(l.x,{as:"h2",variant:"headingMd",children:"Data sources for lookup"}),(0,a.jsx)(R.b,{url:"https://docs.woolytech.com/article/174-what-are-the-access-scopes-that-the-app-requires-and-how-they-are-used"})]}),description:(0,a.jsx)(u.E,{gap:"200",children:(0,a.jsx)(l.x,{children:"Add reusable sources that can later be referenced in expressions using lookup function."})}),children:(0,a.jsx)(i.D,{vertical:!0,gap:"300",children:(0,a.jsxs)(g.z,{children:[ee.fields.map((e,t)=>{var n;let{name:s,type:c,csvUrl:p,sheetUrl:v,sheetTitle:j,query:E,keyColumn:C,valueColumn:w}=e;return(0,a.jsxs)(r.Fragment,{children:[t>0&&(0,a.jsx)("div",{style:{marginTop:10},children:(0,a.jsx)(f.i,{})}),(0,a.jsx)(g.z.Section,{children:(0,a.jsxs)(y.l,{children:[(0,a.jsxs)(i.D,{alignment:"center",spacing:"tight",children:[(0,a.jsx)(h.J,{source:{CSV:b.S,GOOGLE_SHEET:SvgColumns3Minor,QUERY:SvgAnalyticsTableMinor}[c.value]}),(0,a.jsx)(l.x,{variant:"headingSm",children:s.value||"".concat((null===(n=el.find(e=>e.value===c.value))||void 0===n?void 0:n.label)||c.value)}),(()=>{var e;if(!(null===(e=ee.fields[t].id)||void 0===e?void 0:e.value))return(0,a.jsx)(o.C,{tone:"attention",children:"New"});let n=Object.values(ee.fields[t]).some(e=>e.dirty);if(n)return(0,a.jsx)(o.C,{tone:"warning",children:"Modified"})})(),t<N&&(0,a.jsx)(o.C,{tone:"info",children:"Free"}),(0,a.jsx)(i.D.Item,{fill:!0}),(0,a.jsx)(S.z,{icon:SvgPriceLookupMinor,onClick:()=>eP(t),children:"Test"}),(0,a.jsx)(S.z,{tone:"critical",icon:_.S,onClick:()=>ee.removeItem(t),children:"Remove"})]}),(0,a.jsxs)(i.D,{children:[(0,a.jsx)(i.D.Item,{fill:!0,children:(0,a.jsx)(m.n,{label:"Name",placeholder:"e.g. Pricing sheet",autoComplete:"off",...s})}),(0,a.jsx)("div",{style:{width:130},children:(0,a.jsx)(x.P,{label:"Type",options:el,value:c.value,error:c.error,onChange:e=>{c.onChange(e)}})}),(0,a.jsxs)(i.D,{spacing:"tight",children:[(0,a.jsx)("div",{style:{width:90},children:(0,a.jsx)(m.n,{label:"Key column",suffix:["st","nd","rd","th"][C.value-1]||"th",type:"number",min:1,...C})}),(0,a.jsx)("div",{style:{width:90},children:(0,a.jsx)(m.n,{label:"Value column",suffix:["st","nd","rd","th"][w.value-1]||"th",type:"number",min:1,...w})})]})]}),"CSV"===c.value&&(0,a.jsx)(m.n,{label:"CSV file URL",placeholder:"https://example.com/file.csv",autoComplete:"off",...p}),"GOOGLE_SHEET"===c.value&&(0,a.jsxs)(i.D,{vertical:!0,spacing:"tight",children:[(0,a.jsx)(m.n,{label:"Google sheet URL",placeholder:"https://docs.google.com/spreadsheets/d/{sheetId}/edit",autoComplete:"off",helpText:"Use public shared link to Google sheet (everyone with link can access)",...v}),(0,a.jsx)(m.n,{label:"Sheet title",placeholder:"Leave blank to use the first sheet",autoComplete:"off",...j})]}),"QUERY"===c.value&&(0,a.jsxs)(u.E,{gap:"200",children:[K.includes("read_reports")?null:(0,a.jsx)(d.jL,{tone:"warning",title:"Additional permission required",action:{content:"Grant access",onAction:()=>$("read_reports")},children:(0,a.jsxs)(l.x,{as:"p",children:["Shopify query data sources require the"," ",(0,a.jsx)(l.x,{as:"span",fontWeight:"semibold",children:"read_reports"})," ","access scope."]})}),(0,a.jsx)(m.n,{label:"Query string",placeholder:"e.g. FROM sales SHOW net_items_sold GROUP BY product_id WITH TOTALS...",autoComplete:"off",monospaced:!0,multiline:5,...E})]})]})})]},t)}),(0,a.jsx)(j.u,{action:{content:"Add data source",onAction:ee.addItem,icon:w.S},children:Y?(0,a.jsx)(s.A.Section,{children:(0,a.jsx)(E.x,{padding:"400",children:(0,a.jsxs)(p.g,{gap:"200",blockAlign:"center",children:[(0,a.jsx)(v.$,{size:"small"}),(0,a.jsx)(l.x,{children:"Loading..."})]})})}):ee.fields.length?null:(0,a.jsx)(l.x,{children:"No data sources added yet"})})]})})})]})})};DataSourcesPage.getLayout=N.getLayout;var B=DataSourcesPage},11742:function(e){e.exports=function(){var e=document.getSelection();if(!e.rangeCount)return function(){};for(var t=document.activeElement,n=[],a=0;a<e.rangeCount;a++)n.push(e.getRangeAt(a));switch(t.tagName.toUpperCase()){case"INPUT":case"TEXTAREA":t.blur();break;default:t=null}return e.removeAllRanges(),function(){"Caret"===e.type&&e.removeAllRanges(),e.rangeCount||n.forEac
1h(function(t){e.addRange(t)}),t&&t.focus()}}}},function(e){e.O(0,[4322,8744,2545,302,6199,5253,2695,5739,9554,9976,9774,2888,179],function(){return e(e.s=90821)}),_N_E=e.O()}]);

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.