PageSourceSearch

https://www.hi-chew.com/cdn/shopifycloud/checkout-web/assets/c1/page-Throttle.B38KvUI9.js

js hi-chew.com collected 2026-09-25 18:59:39 UTC 10,654 bytes, 1 lines download raw bytes

1import{k as L,h as x,a0 as ie,M as oe,l as J,f as S,A as w,u as e,g as se,T as ce,p as ue,i as T}from"./esnext-vendor.B9Da21W6.js";import{cM as X,cN as M,m as q,P as m,L as de,k as p,B as A,Y,A as he,l as P,W as me,I as Z,a8 as fe,f as pe,n as ge,X as ve,G as z,cO as be,b as ye,ap as _e,am as Te,an as U,ao as Se,aj as we,ag as H,ak as xe,cP as Ie}from"./hydrate.DZ4YTm7p.js";import{S as ke}from"./Section-SectionStyleOverride.hMiKajvE.js";import{a4 as K,S as v,H as Ae,bz as Pe}from"./addresses-is-address-empty.Bn2lNY_L.js";import{a as Ee}from"./graphql-PaymentSessionMutation.CAXCwUvV.js";import{u as Re,S as Ve}from"./stopwatch.CfKlh48v.js";import{S as ee}from"./app.DbSrjjlA.js";import{d as Le}from"./shared-report-graphql-error.0sJ2-gTk.js";import"./hooks-useShopPayExternalAppContext.DWwMuRnz.js";import"./hooks-useReplaceShopPayInHistory.DPpLejwu.js";function te(){const[t,n]=L(typeof document>"u"?"visible":document.visibilityState);return x(()=>{const r=()=>n(document.visibilityState);return window.addEventListener("visibilitychange",r,!1),()=>{window.removeEventListener("visibilitychange",r)}},[]),t}function Me(t){return t.length===0?"empty":t.every(G)?"unavailable":t.some(G)?"partially_available":"available"}function G(t){return t.available===!1}const qe={id:"186ea50e2b37f36013ff760cddcee64b27d2785edc79d3078d8bb95e4186410b",type:"query",name:"ThrottlePoll",source:"query ThrottlePoll($token:String!,$variantIdsV2:[Int!]){poll(token:$token,variantIdsV2:$variantIdsV2){...on PollContinue{token pollAfter queueEtaSeconds productVariantAvailabilityV2{available id __typename}__typename}...on PollComplete{token __typename}__typename}}"};class k extends ee{constructor(){super(...arguments),this.name="ThrottleError",this.defaultGroupingHash="ThrottleError::Exiting::Status"}}class O extends ee{constructor(){super(...arguments),this.name="UnactionableThrottleError",this.unactionable=!0}}function Be(){const[t,n]=L(null),r=X(),a=ie(),[i,o]=L(),{throttle:s,setThrottle:_}=M(),{value:I}=K().merchandiseLines,{graphql:{throttleGraphql:b},observability:E}=v();if(x(()=>{n(u=>u??new Date)},[]),Ce(async()=>{if(s.status==="queued")try{const u=I?I.lines.filter(h=>h.variantId).map(h=>re(h.variantId)):[],{data:d,error:g}=await b.staticQuery(qe,{cache:!1,variables:{token:s.token,variantIdsV2:u}});if(!r.current)return;if(g)throw g;if(!d)throw new k("Throttle poll did not return data",{groupingHash:"ThrottleError::PollMissingReturnData"});const c=De(d,s);c.status==="queued"&&s?.pollAfter===c.pollAfter&&(c.pollAfter=Date.now()+1e3),_(c),n(new Date),a.reset()}catch(u){const d=a.next(),g=d.done,c=Le(u),h=u instanceof oe?u.response.status:void 0;if(g){o(new(c.actionable?k:O)("Throttle exited on maximum retries",{cause:u})),E.counter({name:"throttle_exited_on_maximum_retries",value:1});return}else if(h&&h<500){o(new(c.actionable?k:O)(`Throttle exiting on ${h} status`,{cause:u}));return}_({...s,pollAfter:Date.now()+d.value})}},s.status==="queued"?s.pollAfter:void 0),i)throw i;return{throttle:s,lastUpdated:t}}function Ce(t,n){const r=w(t);r.current=t;const a=te();x(()=>{if(!n)return;const i=Math.max(n-Date.now(),0);if(i===0)r.current();else{const o=setTimeout(r.current,i);return()=>clearTimeout(o)}},[n,a])}function De({poll:t},n){if(t.__typename==="PollContinue")return{status:"queued",pollAfter:new Date(t.pollAfter).getTime(),token:t.token,queueEtaSeconds:t.queueEtaSeconds??void 0,productVariantAvailabilityV2:t.productVariantAvailabilityV2,pollUrl:n.pollUrl};if(t.__typename==="PollComplete")return{status:"complete",token:t.token,productVariantAvailabilityV2:n.productVariantAvailabilityV2};throw new k("unable to handle Throttle type",{groupingHash:"ThrottleError::ThrottleType"})}function Ne(){const{throttle:t}=M(),n=J(t),r=K().merchandiseLines;return S(()=>{const a=n.value;if(a.status==="inactive"||a.status==="loading"||!r.value)return[];const i=new Map(a.productVariantAvailabilityV2.map(({id:o,available:s})=>[o,s]));return r.value.lines.filter(o=>o.variantId).map(o=>({...o,available:i.get(re(o.variantId))}))})}function re(t){return parseInt(Ae(t),10)}function W({inventoryStatus:t}){const{i18n:n,shop:{hasStorefront:r},url:a,checkout:{configuration:i}}=v(),o=t==="empty"?n.translate("stock.empty_cart_label"):n.translate("throttle.inventory.sold_out.heading"),s=t==="empty"?n.translate("stock.return_to_store_label"):n.translate("throttle.inventory.sold_out.link");return e(p,{gap:"small-200",alignItems:"center",padding:"large-300",children:[e(q,{level:1,children:o}),r&&t==="unavailable"&&e(m,{size:"large",textAlign:"center",children:n.translate("throttle.inventory.sold_out.storefront_body")}),r&&i.allowRedirectToStorefront&&e(m,{textAlign:"center",children:e(de,{href:a.storefront(),children:s})}),!r&&t==="unavailable"&&e(m,{size:"large",textAlign:"center",children:n.translate("throttle.inventory.sold_out.no_storefront_body")})]})}function $e({heading:t,details:n,children:r}){return e(Y,{borderRadius:"base",border:"base",children:[e(A,{padding:"large-200",accessibilityRole:"header",children:e(p,{direction:"inline",gap:"small-200",alignItems:"baseline",children:[e(q,{level:2,children:t}),n?e(m,{color:"subdued",type:"small",children:n}):null]})}),e(A,{borderWidth:"base none none none",padding:"large-200",children:r})]})}function Fe(){const{i18n:t}=v();return e(me,{tone:"warning",errorType:he.InventoryError,children:e(m,{type:"small",children:e(P,{type:"strong",children:t.translate("throttle.inventory.partial_inventory_banner")})})})}const ze="NMORO",Q={ProgressBar:ze,"ProgressBar-line":"zetxR"};function Ue({barCount:t=7}){const r={"--ProgressBar-width":`${t*13}px`},a=[];for(let i=0;i<t;i++)a.push(e("div",{className:se(Q["ProgressBar-line"])},i));return e("div",{className:Q.ProgressBar,style:r,children:a})}const j=60;function He(){const{i18n:t}=v(),{throttle:n}=M(),r=n.status==="queued"?n.queueEtaSeconds:0,a=ce(()=>r==null?t.translate("throttle.estimated_wait_time.calculating"):r<j?t.translate("throttle.estimated_wait_time.less_than_one"):t.translate("throttle.estimated_wait_time",{count:Math.round(r/j)}),[r,t]);return e(p,{alignItems:"center",gap:"large-200",padding:"large-200",children:[e(Ue,{}),e(p,{gap:"small-200",alignItems:"center",children:[e(q,{level:1,textAlign:"center",children:t.translate("throttle.line_to_check_out")}),e(m,{size:"base",children:a})]})]})}const Ge="broxv",Oe={Text:Ge};function We(){const{i18n:t}=v(),n=t.translate("throttle.merchandise.available").trim();return n.length===0?null:e(m,{children:e(p,{direction:"inline",gap:"small-400",alignItems:"center",children:[e(Z,{size:"small-200",tone:"success",type:"check"}),e(P,{type:"strong",tone:"success",size:"small",children:e("span",{className:Oe.Text,children:n})})]})})}const Qe="hG8Tu",je={Text:Qe};function Je(){const{i18n:t}=v(),n=t.translate("throttle.merchandise.sold_out").trim();return n.length===0?null:e(fe,{children:e(p,{direction:"inline",gap:"small-400",alignItems:"center",children:[e(Z,{size:"small-200",tone:"critical",type:"disabled"}),e(P,{size:"small",children:e("span",{className:je.Text,children:n})})]})})}function Xe(t){return t.endsWith("status: 429")}function ct(){const{progress:t}=pe(),n=J(Be()),{i18n:r,shop:a,url:i,observability:o,embed:s,router:_}=v(),I=te(),b=Ne(),E=S(()=>b.value.length>0?b.value:null),u=X(),d=S(()=>n.value.throttle.status),g=S(()=>n.value.lastUpdated),c=S(()=>d.value==="complete"||d.value==="queued"?Me(b.value):null),h=w(t),{currentPage:ne}=ge().value;h.current=t;const B=w(!1);ue(()=>{if(B.current)return;const y=c.value;if(!y)return;const f=b.value;o.counter({name:"throttle_rendered",value:1,attributes:{throttle_status:d.value,inventory_status:y,merchandise_available:f.filter(({available:l})=>l).length,merchandise_unavailable:f.filter(({available:l})=>!l).length,has_storefront:a.hasStorefront}}),B.current=!0});const C=w(!1);x(()=>{C.current||(C.current=!0,Pe(s,"throttle"))},[s]),Ee(d.value==="complete"&&I==="hidden"?r.translate("throttle.time_to_checkout_title",{shopName:a.name}):d.value==="loading"?r.translate("general.loading_title",{shopName:a.name}):r.translate("general.full_title",{pageTitle:r.translate("throttle.title"),shopName:a.name}));const R=ne?.route,V=w(!1);x(()=>{function y(l){return l.status==="fetch_failed"&&Xe(l.reason)&&!V.current&&u.current}function f(){h.current("throttle-run",l=>{l.status==="throttled"&&u.current?(V.current=!1,f()):y(l)?(V.current=!0,f()):(l.status==="error"||l.status==="fetch_failed")&&(R?_.navigate(R,{replace:!0}):window.location.assign(i.cart()))})}f()},[h,u,i,R,_]),Re({stage:Ve.Usable,id:"Throttle"});const{header:{logo:D}}=ve();return d.value==="inactive"?null:e(z,{placeItems:"center",minBlockSize:"100vh",background:"base",children:e(A,{maxInlineSize:"450px",padding:"base",children:e(ke,{target:"card",children:e(Y,{accessibilityLabel:r.translate("throttle.title"),children:e(p,{gap:"base",children:[D&&e(z,{gridAutoFlow:"column",gridTemplateColumns:"minmax(0, 1fr)",gridTemplateRows:"minmax(0, 1fr)",justifyContent:"center",justifyItems:"center",children:e(be,{width:D.maxWidth})}),e(T,{when:()=>c.value==="empty",fallback:e(T,{when:()=>c.value==="unavailable",fallback:e(He,{}),children:e(W,{inventoryStatus:"unavailable"})}),children:e(W,{inventoryStatus:"empty"})}),e(T,{when:E,children:y=>e($e,{heading:r.translate("throttle.cart_summary_heading"),details:g.value?r.translate("throttle.last_checked",{time:r.formatDate(g.value,{hour:"numeric",minute:"numeric",timeZoneName:"short"})}):void 0,children:[e(T,{when:()=>c.value==="partially_available",children:[e(Fe,{}),e(ye,{blockSize:"large-200"})]}),e(_e,{children:[e(Te,{hidden:!0,children:[e(U,{hidden:!0,children:r.translate("order_summary.product_image_label")}),e(U,{hidden:!0,children:r.translate("order_summary.description_label")})]}),e(Se,{children:y.map(({digest:f,image:l,available:N,title:ae,subtitle:$,quantity:le,properties:F})=>e(we,{children:[e(H,{children:e(xe,{src:l?.one,srcSet:l?`${l.one} 1x, ${l.two} 2x, ${l.four} 4x`:void 0,alt:l?.altText,totalItems:le})}),e(H,{primary:!0,children:[e(m,{children:e(P,{type:"strong",children:ae})}),$?e(m,{color:"subdued",children:$}):null,F?e(Ie,{properties:F}):null,N==null?null:e(Ye,{available:N})]})]},f))})]})]})}),e(T,{when:()=>c.value!=="empty"&&c.value!=="unavailable",children:e(A,{padding:"large-200 none",children:e(p,{alignItems:"center",gap:"small-200",accessibilityRole:"footer",children:[e(m,{color:"subdued",textAlign:"center",children:r.translate("throttle.footer.heading")}),e(m,{color:"subdued",textAlign:"center",children:r.translate("throttle.footer.body")})]})})})]})})})})})}function Ye({available:t}){return t?e(We,{}):e(Je,{})}export{ct as default};

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.