1"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[5328],{25051:function(e,t,n){n.d(t,{Z:function(){return f}});var r=n(85893),i=n(19201),a=n(67294),o=n(58907),s=n(93223),l=n(62461),u=n(87756),c=n(84617),d=n(41352);function f(e){var t=(0,a.useState)(0),n=t[0],f=t[1],p=(0,a.useRef)(null),m=e.id,h=void 0===m?"fileInput":m,v=e.fileName,x=e.setFileName,g=e.accept,y=e.invalid,b=e.uploadPath,N=(e.maxFileSize,e.onUploadStart),_=e.onUploadEnd,j=e.type,w=void 0===j?"":j,k=null===v||void 0===v?void 0:v.split("/").pop();return(0,r.jsxs)("div",{className:"w-full space-y-2",children:[(0,r.jsx)("input",{ref:p,type:"file",id:h,accept:g,className:"hidden",onChange:function(t){var n,r,a=null===(n=t.target.files)||void 0===n?void 0:n[0];if(a)if(null===(r=e.accept)||void 0===r?void 0:r.replace(" ","").split(",").includes(a.type)){var s=Date.now()+a.name;null===N||void 0===N||N(),(0,o.c)({fileName:s,file:a,path:b,cb:function(e,t){f(0),null===_||void 0===_||_(),e?i.A.error("Something went wrong in uploading file"):(i.A.success("File uploaded successfully."),x(t.Location))}
1,progressCb:function(e){return f(Math.round(e.loaded/e.total*100))},type:w})}else i.A.error("File type not supported")}}),(0,r.jsxs)(s._,{htmlFor:h,className:(0,l.cn)("flex items-center gap-3 w-full px-3 py-2.5 rounded-md border bg-background cursor-pointer","text-sm transition-colors hover:bg-accent",y?"border-red-500 focus-within:ring-red-500":"border-input hover:border-input",n>0&&"pointer-events-none opacity-70"),children:[(0,r.jsx)(u.Z,{className:"h-4 w-4 text-muted-foreground shrink-0"}),k?(0,r.jsxs)("span",{className:"flex items-center gap-2 flex-1 min-w-0",children:[(0,r.jsx)(c.Z,{className:"h-3.5 w-3.5 text-muted-foreground shrink-0"}),(0,r.jsx)("span",{className:"truncate text-muted-foreground",children:k})]}):(0,r.jsx)("span",{className:"flex-1 text-muted-foreground",children:"Choose file"}),k&&0===n&&(0,r.jsx)("button",{type:"button",onClick:function(e){e.preventDefault(),e.stopPropagation(),x(""),p.current&&(p.current.value="")},className:"ml-auto shrink-0 rounded-full p-0.5 text-muted-foreground hover:text-muted-foreground hover:bg-accent transition-colors",children:(0,r.jsx)(d.Z,{className:"h-3.5 w-3.5"})})]}),n>0&&(0,r.jsxs)("div",{className:"w-full space-y-1",children:[(0,r.jsx)("div",{className:"h-1.5 w-full rounded-full bg-muted overflow-hidden",children:(0,r.jsx)("div",{className:"h-full rounded-full bg-green-500 transition-all duration-200",style:{width:"".concat(n,"%")}})}),(0,r.jsxs)("p",{className:"text-xs text-muted-foreground text-right",children:[n,"%"]})]})]})}},95537:function(e,t,n){n.d(t,{y:function(){return s}});var r=n(85893),i=n(67294),a=n(8971),o=/((?:https?:\/\/|www\.)[^\s<]+)/gi;function s(e){var t=e.text,n=e.fade,s=void 0!==n&&n,l=e.collapsedHeight,u=void 0===l?160:l,c=(0,i.useState)(!1),d=c[0],f=c[1],p=(0,i.useState)(!1),m=p[0],h=p[1],v=(0,i.useState)(0),x=v[0],g=v[1],y=(0,i.useRef)(null),b=(0,i.useRef)();(0,i.useEffect)((function(){var e=y.current;if(e){!function(e){for(var t=document.createTreeWalker(e,NodeFilter.SHOW_TEXT,{acceptNode:function(e){var t=e.parentElement;return!t||t.closest("a, script, style")?NodeFilter.FILTER_REJECT:NodeFilter.FILTER_ACCEPT}}),n=[],r=t.nextNode();r;)n.push(r),r=t.nextNode();n.forEach((function(e){var t,n=e.data;if(o.lastIndex=0,o.test(n)){o.lastIndex=0;for(var r,i=document.createDocumentFragment(),a=0;r=o.exec(n);){var s=r[0],l=s.match(/[.,;:!?)\]}'"]+$/);if(l&&(s=s.slice(0,-l[0].length)),s){r.index>a&&i.appendChild(document.createTextNode(n.slice(a,r.index)));var u=document.createElement("a");u.href=s.startsWith("http")?s:"https://".concat(s),u.textContent=s,u.target="_blank",u.rel="noopener noreferrer",u.className="text-primary underline break-words",i.appendChild(u),a=r.index+s.length}}a<n.length&&i.appendChild(document.createTextNode(n.slice(a))),null===(t=e.parentNode)||void 0===t||t.replaceChild(i,e)}}))}(e);var t=function(){return g(Math.ceil(e.getBoundingClientRect().height))};if(t(),"undefined"!==typeof ResizeObserver){var n=new ResizeObserver(t);return n.observe(e),function(){return n.disconnect()}}}}),[t]),(0,i.useEffect)((function(){return function(){return clearTimeout(b.current)}}),[]);var N=x>u+16,_=N&&!d,j=N?d?m?x:void 0:u:void 0;return(0,r.jsxs)("div",{className:"flex w-full flex-col items-start text-[15px] leading-relaxed text-muted-foreground",children:[(0,r.jsxs)("div",{className:"relative w-full overflow-hidden transition-[max-height] duration-500 ease-[cubic-bezier(0.4,0,0.2,1)] motion-reduce:transition-none",style:void 0===j?void 0:{maxHeight:j},children:[(0,r.jsx)("div",{ref:y,className:"[&>*:last-child]:mb-0",dangerouslySetInnerHTML:{__html:t}}),s&&(0,r.jsx)("div",{"aria-hidden":"true",className:"pointer-events-none absolute inset-x-0 bottom-0 h-16 bg-gradient-to-t from-card via-card/70 to-transparent transition-opacity duration-300 ease-out motion-reduce:transition-none ".concat(_?"opacity-100":"opacity-0")})]}),N&&(0,r.jsxs)("button",{type:"button",onClick:function(){clearTimeout(b.current),h(!0),b.current=setTimeout((function(){return h(!1)}),600),d?requestAnimationFrame((function(){return requestAnimationFrame((function(){return f(!1)}))})):f(!0)},"aria-expanded":d,className:"-ml-1 mt-2 inline-flex items-center gap-1 rounded-md px-1 py-1 text-sm font-medium text-primary outline-none transition-colors duration-200 hover:bg-primary/5 focus-visible:ring-2 focus-visible:ring-ring",children:[d?"Read less":"Read more",(0,r.jsx)(a.Z,{className:"h-4 w-4 transition-transform duration-300 ease-out motion-reduce:transition-none ".concat(d?"-rotate-180":"rotate-0")})]})]})}},72685:function(e,t,n){n.d(t,{I:function(){return l}});var r=n(26042),i=n(99534),a=n(85893),o=n(67294),s=n(62461),l=o.forwardRef((function(e,t){var n=e.className,o=e.type,l=(0,i.Z)(e,["className","type"]);return(0,a.jsx)("input",(0,r.Z)({type:o,className:(0,s.cn)("flex h-10 w-full rounded-md border border-foreground
1/50 bg-background px-3 py-2 text-base text-foreground file:border-0 file:bg-transparent file:text-sm file:font-medium file:text-foreground placeholder:text-muted-foreground focus-visible:outline-none focus-visible:border-ring disabled:cursor-not-allowed disabled:opacity-50 md:text-[13px]",n),ref:t},l))}));l.displayName="Input"},93223:function(e,t,n){n.d(t,{_:function(){return d}});var r=n(26042),i=n(99534),a=n(85893),o=n(67294),s=n(49102),l=n(12003),u=n(62461),c=(0,l.j)("text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70"),d=o.forwardRef((function(e,t){var n=e.className,o=(0,i.Z)(e,["className"]);return(0,a.jsx)(s.f,(0,r.Z)({ref:t,className:(0,u.cn)(c(),n)},o))}));d.displayName=s.f.displayName},15328:function(e,t,n){n.d(t,{U:function(){return _}});var r=n(47568),i=n(97582),a=n(85893),o=n(67294),s=n(7065),l=n(14924),u=n(26042),c=n(69396),d=n(70499),f=n(35739),p=n(72685),m=n(41352),h=n(36316),v=n(25051),x=n(73716),g=n(95537);function y(e){var t=e.open,n=e.onClose,y=e.form,b=e.appConfig,N=e.itemId,_=e.targetId,j=e.onSuccess,w=(0,o.useState)(!1),k=w[0],S=w[1],C=(0,o.useState)({}),E=C[0],Z=C[1],T=(0,o.useState)({}),I=T[0],F=T[1],R=(0,o.useState)(!1),P=R[0],A=R[1],U=(0,o.useMemo)((function(){var e;return"1"===(null===y||void 0===y||null===(e=y.config)||void 0===e?void 0:e.mandatory)}),[y]);if((0,o.useEffect)((function(){Z({}),F({})}),[t]),!y)return null;var q=function(e,t){Z((function(n){return(0,c.Z)((0,u.Z)({},n),(0,l.Z)({},e,t))})),I[e]&&F((function(t){var n=(0,u.Z)({},t);return delete n[e],n}))},M=function(e){return"number"===e.type?"Enter ".concat(e.label.toLowerCase()):"Type ".concat(e.label.toLowerCase())},O=function(e){if("file"===e.type)return(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(v.Z,{id:e.key,fileName:E[e.key]||"",setFileName:function(t){return q(e.key,t)},accept:"image/jpeg,image/png,application/pdf",uploadPath:"form-uploads/",invalid:!!I[e.key],onUploadStart:function(){return A(!0)},onUploadEnd:function(){return A(!1)},type:"public_media"}),I[e.key]&&(0,a.jsx)("small",{className:"text-red-500 text-xs mt-1",children:I[e.key]})]});var t={required:e.required,value:E[e.key]||""};switch(e.type){case"textarea":return(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)("textarea",(0,c.Z)((0,u.Z)({},t),{placeholder:M(e),className:"bg-background w-full rounded-md border px-3 py-2 text-sm min-h-[100px] resize-none focus:outline-none focus:ring-2 focus:ring-ring ".concat(I[e.key]?"border-red-500":"border-input"),onChange:function(t){return q(e.key,t.target.value)}})),I[e.key]&&(0,a.jsx)("small",{className:"text-red-500 text-xs mt-1",children:I[e.key]})]});case"number":return(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(p.I,(0,c.Z)((0,u.Z)({},t),{type:"text",inputMode:"numeric",placeholder:M(e),className:"h-11 bg-background ".concat(I[e.key]?"border-red-500":""),onChange:function(t){var n=t.target.value.replace(/\D/g,"");q(e.key,n)}})),I[e.key]&&(0,a.jsx)("small",{className:"text-red-500 text-xs mt-1",children:I[e.key]})]});default:return(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(p.I,(0,c.Z)((0,u.Z)({},t),{type:e.type,placeholder:M(e),className:"h-11 bg-background ".concat(I[e.key]?"border-red-500":""),onChange:function(t){return q(e.key,t.target.value)}})),I[e.key]&&(0,a.jsx)("small",{className:"text-red-500 text-xs mt-1",children:I[e.key]})]})}},z=function(){var e=(0,r.Z)((function(){var e,t;return(0,i.__generator)(this,(function(n){switch(n.label){case 0:if(!function(){var e={};return y.fields.forEach((function(t){var n;!t.required||(null===(n=E[t.key])||void 0===n?void 0:n.trim())?"number"===t.type&&E[t.key]&&!(0,x.n6)(E[t.key])&&(e[t.key]="".concat(t.label," must be a valid phone number")):e[t.key]="".concat(t.label," is required")})),F(e),0===Object.keys(e).length}())return[2];n.label=1;case 1:return n.trys.push([1,4,5,6]),S(!0),e=y.fields.map((function(e){return{key:e.key,label:e.label,value:E[e.key]||""}})),[4,(0,s.R2)(b.web_apiurl,{form_id:String(y.id),item_type:y.item_type,item_id:null!==N&&void 0!==N?N:"",target_type:y.target_type,target_id:null!==_&&void 0!==_?_:"",response:e})];case 2:return n.sent(),[4,j()];case 3:return n.sent(),[3,6];case 4:return t=n.sent(),console.error("Submit form failed",t),[3,6];case 5:return S(!1),[7];case 6:return[2]}}
1))}));return function(){return e.apply(this,arguments)}}();return(0,a.jsx)(d.Vq,{open:t,onOpenChange:function(){U||n()},children:(0,a.jsxs)(d.cZ,{className:"text-foreground border-border rounded-2xl max-h-[95dvh] p-0 flex flex-col overflow-hidden gap-0",children:[(0,a.jsxs)("div",{className:"flex-shrink-0 px-3 pt-2 pb-2 relative",children:[!U&&(0,a.jsx)(d.GG,{onClick:function(e){e.stopPropagation(),n()},className:"absolute right-3 top-3 p-1 rounded-md hover:bg-accent transition",children:(0,a.jsx)(m.Z,{className:"h-5 w-5 text-muted-foreground"})}),(0,a.jsx)(d.fK,{children:(0,a.jsx)(d.$N,{className:"text-lg md:text-xl mb-0 p-0 pr-8",children:y.title})})]}),(0,a.jsxs)("div",{className:"flex-1 overflow-y-auto px-3 py-4",children:[y.description&&(0,a.jsx)("div",{className:"mb-4",children:(0,a.jsx)(g.y,{text:String(y.description)})}),(0,a.jsx)("div",{className:"flex flex-col gap-3",children:y.fields.map((function(e){return(0,a.jsxs)("div",{className:"flex flex-col gap-1",children:[(0,a.jsxs)("label",{className:"text-sm font-medium text-foreground",children:[e.label,e.required&&(0,a.jsx)("span",{className:"text-red-500 ml-1",children:"*"})]}),O(e)]},e.key)}))})]}),(0,a.jsx)("div",{className:"flex-shrink-0 p-3 border-t bg-muted",children:(0,a.jsxs)("div",{className:"flex gap-2",children:[!U&&(0,a.jsx)(f.z,{variant:"secondary",onClick:j,disabled:k,children:"Skip"}),(0,a.jsxs)(f.z,{onClick:z,disabled:k||P,className:"w-full",children:[(k||P)&&(0,a.jsx)(h.Z,{className:"mr-2 h-4 w-4 animate-spin"}),"Submit"]})]})})]})})}var b=n(96076),N=function(e){var t=e.event,n=void 0===t?"BEFORE_TEST_ATTEMPT":t,r=e.itemType,i=e.itemId,a=e.testSeriesId,o=e.testId;var s=JSON.parse(localStorage.getItem(b.dA.FORM_CONFIG_CACHE_KEY)||"[]").filter((function(e){return e.event===n}));if(null!=r&&null!=i){var l=s.find((function(e){var t=e.item_id.split(",").map((function(e){return e.trim()})).filter(Boolean);return String(e.item_type)===String(r)&&t.includes(String(i))}));if(l)return{form:l,matchedItemId:String(i)}}if(null!=o){var u=s.find((function(e){var t=e.item_id.split(",").map((function(e){return e.trim()})).filter(Boolean);return"27"===e.item_type&&t.includes(String(o))}));if(u)return{form:u,matchedItemId:String(o)}}var c=s.find((function(e){var t=e.item_id.split(",").map((function(e){return e.trim()})).filter(Boolean);return"3"===e.item_type&&t.includes(String(a))}));return c?{form:c,matchedItemId:String(a)}:null},_=function(e){var t,n=e.appConfig,l=e.test,u=void 0===l?null:l,c=e.next,d=void 0===c?null:c,f=(0,o.useState)(!1),p=f[0],m=f[1],h=(0,o.useState)(null),v=h[0],x=h[1],g=(0,o.useState)(null),_=g[0],j=g[1],w=(0,o.useState)(null),k=w[0],S=w[1],C=(0,o.useState)(null),E=C[0],Z=C[1],T=(0,o.useState)(null),I=T[0],F=T[1],R=function(){var e=(0,r.Z)((function(){var e,t,r,a,o,l,c,f,p,h,v,g,y,_,w,k,C,E,T,I,R=arguments;return(0,i.__generator)(this,(function(i){switch(i.label){case 0:return e=R.length>0&&void 0!==R[0]?R[0]:{},t=e.test,r=void 0===t?u:t,a=e.entity,o=e.itemType,l=e.itemId,c=e.onDismiss,f=e.next,p=void 0===f?d:f,h=e.event,v=void 0===h?"BEFORE_TEST_ATTEMPT":h,p?(g=a||r,(y=N({event:v,itemType:o,itemId:l,testSeriesId:null===r||void 0===r?void 0:r.test_series_id,testId:null===r||void 0===r?void 0:r.id}))?[3,2]:[4,p()]):[2];case 1:return i.sent(),[2];case 2:_=y.form,w=y.matchedItemId,i.label=3;case 3:return i.trys.push([3,7,,9]),[4,(0,s.nC)(n.web_apiurl,_.id,w)];case 4:return C=i.sent(),E=C.data.data,T=null===(k=E.config)||void 0===k?void 0:k.show_frequency,I=C.data.already_submitted,T===b.Jt.EVERYTIME||T===b.Jt.ONCE_PER_USER&&!I||T===b.Jt.ONCE_PER_ITEM&&!I?[3,6]:[4,p()];case 5:return i.sent(),[2];case 6:return x(E),j(g),S((function(){return p})),F((function(){return null!==c&&void 0!==c?c:null})),Z(w),m(!0),[3,9];case 7:return i.sent(),[4,p()];case 8:return i.sent(),[3,9];case 9:return[2]}}
1))}));return function(){return e.apply(this,arguments)}}();return{execute:R,FormBuilderModal:(0,a.jsx)(y,{open:p,onClose:function(){m(!1),null===I||void 0===I||I(),F(null)},form:v,appConfig:n,itemId:E,targetId:null!==(t=null===_||void 0===_?void 0:_.id)&&void 0!==t?t:null,onSuccess:(0,r.Z)((function(){return(0,i.__generator)(this,(function(e){switch(e.label){case 0:return m(!1),x(null),j(null),k?[4,k()]:[3,2];case 1:e.sent(),S(null),e.label=2;case 2:return[2]}}))}))})}}},58907:function(e,t,n){n.d(t,{c:function(){return N},s:function(){return _}});var r=n(47568),i=n(51438),a=n(28668),o=n(25892),s=n(76166),l=n(97582),u=n(29061),c=n(27432),d=function(e){(0,a.Z)(n,e);var t=(0,s.Z)(n);function n(e,r){var a;return(0,i.Z)(this,n),(a=t.call(this,e)).name="UploadError",a.status=r,a}return n}((0,o.Z)(Error)),f=function(e){return new Promise((function(t){return setTimeout(t,e)}))},p=function(e){return{400:"Invalid request format",401:"Unauthorized access",403:"Permission denied",404:"Resource not found",408:"Request timeout",413:"File too large",422:"File format not supported",429:"Too many requests",500:"Server error",503:"Service unavailable"}[e]||"Unknown error occurred"};function m(e){return h.apply(this,arguments)}function h(){return h=(0,r.Z)((function(e){var t,n,r,i,a,o,s,u,c,m,h,v,x,g,y=arguments;return(0,l.__generator)(this,(function(l){switch(l.label){case 0:t=y.length>1&&void 0!==y[1]?y[1]:{},n=t.maxRetries,r=void 0===n?3:n,i=t.baseDelay,a=void 0===i?1e3:i,o=t.retryStatusCodes,s=void 0===o?[408,413,422,429,500,503]:o,c=0,l.label=1;case 1:if(!(c<=r))return[3,7];l.label=2;case 2:return l.trys.push([2,4,,6]),[4,e()];case 3:return[2,l.sent()];case 4:if(m=l.sent(),u=m,v=(null===(h=m.response)||void 0===h?void 0:h.status)||500,!s.includes(v)||c===r)throw x="".concat(p(v)," (Status: ").concat(v,")"),new d(x,v);return g=a*Math.pow(2,c),[4,f(g)];case 5:return l.sent(),[3,6];case 6:return c++,[3,1];case 7:throw u}}))})),h.apply(this,arguments)}var v=function(e){return e.replaceAll(" ","-").replaceAll("&","and").replaceAll("+","-")};function x(e,t,n){return g.apply(this,arguments)}function g(){return g=(0,r.Z)((function(e,t,n){var r,i,a=arguments;return(0,l.__generator)(this,(function(o){switch(o.label){case 0:return r=a.length>3&&void 0!==a[3]?a[3]:"",i={filePath:e},n?i.type="test":r&&(i.type=r),[4,u.Z.post("/post/generateTencentWebsitePresignedUrl",i,{headers:{"Content-Type":t}})];case 1:return[2,o.sent().data.data]}}))})),g.apply(this,arguments)}function y(e,t,n,r){return b.apply(this,arguments)}function b(){return(b=(0,r.Z)((function(e,t,n,r){return(0,l.__generator)(this,(function(i){return[2,u.Z.put(e,t,{headers:{"Content-Type":n},onUploadProgress:r})]}))}))).apply(this,arguments)}var N=function(){var e=(0,r.Z)((function(e){var t,n,i,a,o,s,u,d,f,p,h,g,b,N,_,j,w,k=arguments;return(0,l.__generator)(this,(function(S){switch(S.label){case 0:t=e.fileName,n=e.file,i=e.path,a=e.cb,o=e.progressCb,s=void 0===o?void 0:o,u=e.isTest,d=void 0!==u&&u,f=e.type,p=void 0===f?"":f,h=k.length>1&&void 0!==k[1]?k[1]:{maxRetries:0},S.label=1;case 1:return S.trys.push([1,3,,4]),g=v(t),b="".concat(i,"/").concat(g),N=c.Z.getType(t),_=function(){var e=(0,r.Z)((function(){var e;return(0,l.__generator)(this,(function(t){switch(t.label){case 0:return[4,x(b,N,d,p)];case 1:return[4,y((e=t.sent()).presignedUrl,n,N,s?function(e){s({loaded:e.loaded,total:e.total,lengthComputable:!0})}:void 0)];case 2:return t.sent(),[2,{Location:e.actualUrl}]}}))}));return function(){return e.apply(this,arguments)}}(),[4,m(_,h)];case 2:return j=S.sent(),a(null,j),[2,j];case 3:throw w=S.sent(),console.error("Error in uploadFile:",w),a(w,null),w;case 4:return[2]}}
1))}));return function(t){return e.apply(this,arguments)}}();function _(e){return j.apply(this,arguments)}function j(){return j=(0,r.Z)((function(e){var t,n,r,i,a,o,s,u,c,d=arguments;return(0,l.__generator)(this,(function(l){return t=e.fileName,n=e.file,r=e.path,i=e.progressCb,a=void 0===i?void 0:i,o=e.isTest,s=void 0!==o&&o,u=e.type,c=void 0===u?"":u,[2,m((function(){return new Promise((function(e,i){N({fileName:t,file:n,path:r,cb:function(t,n){if(t)return console.error(t),void i(t);e(n)},progressCb:a,isTest:s,type:c})}))}),d.length>1&&void 0!==d[1]?d[1]:{maxRetries:0})]}))})),j.apply(this,arguments)}}}]);
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.