1const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/HeroSection-BbbXxVas.js","assets/coreFourPrograms-Dc6ZF9OW.js","assets/programImagery-YBZqzm-f.js","assets/wifi-CA28wzmN.js","assets/EntityGateway-BQ9we-TA.js","assets/utensils-crossed-BbwDbkQC.js","assets/ProgramDashboard-BP67NSIK.js","assets/useDatabase-8-2EZMfa.js","assets/ProgressRing-CQTqgghF.js","assets/lmsChapters-DeEKDiF_.js","assets/wrench-DiSyVZqb.js","assets/calendar-check-D9NMjBsR.js","assets/waves-DVUCNdur.js","assets/scan-DUsO-IF9.js","assets/circle-arrow-up-Cw00B8RL.js","assets/arrow-down-right-tLO5orAF.js","assets/type-B6gayKuW.js","assets/circle-arrow-down-BnLB_rIj.js","assets/circle-dot-D5bIyGR5.js","assets/StatusBadge-BOlGsh3Z.js","assets/wind-B_m0M-GP.js","assets/flower-2-BjSj6Yih.js","assets/brain-0Qo98BXd.js","assets/rocket-BSIkSWb7.js","assets/LMSSection-rwiF8zO1.js","assets/masterEstheticsChapters-Dqvyw2i6.js","assets/video-wp604TXF.js","assets/presentation-D3fQ7Gcd.js","assets/mail-open-otV8nGfF.js","assets/quizService-BJCSFqgA.js","assets/building-DU9fhfHF.js","assets/cpu-JcfqMR59.js","assets/hand-D93Jn2Y5.js","assets/InstructorLMSSection-DeyUKOQj.js","assets/wifi-off-Dm92qTLj.js","assets/AuditV
1aultSection-CshcSOHg.js","assets/FinancialSection-DLhjKKZo.js","assets/ComplianceReminderPanel-DkB5k_py.js","assets/shield-x-DKUGRuUX.js","assets/key-BdKZFs0F.js","assets/chart-pie-BYiRE7gz.js","assets/power-off-CBjFXtPq.js","assets/phone-call-RK5D8C77.js","assets/AgencyHubSection-n7cfzLVy.js","assets/StaffPortalSection-DAjYQN5k.js","assets/pen-tool-DBndz12l.js","assets/octagon-alert-BiXVQsia.js","assets/GoogleSyncSection-puMGQFuu.js","assets/hard-drive-BnHWMrvr.js","assets/POSSection-DLksTH8x.js","assets/FamousPayModal-B3S6v1KS.js","assets/badge-percent-BRYHrOpG.js","assets/percent-pOYTZfaN.js","assets/FranchiseSection-uBiux7b1.js","assets/FranchiseHub-DoJHwNWf.js","assets/ProgramProfilesPage-2ziTX-S9.js","assets/EnrollmentJourney-C1b0rL3a.js","assets/PartnerPortal-BoFq6aGF.js","assets/ZorganicsEcosystem-DJDwsupM.js","assets/MasterBridgePortal-C3EPhflU.js","assets/ZShopSection-4PB4b5gp.js","assets/MissionContributionFooter-Dv8Lnluj.js","assets/commerceJourney-CSllKerj.js","assets/ProfessionalServicesSection-MiNqoji2.js","assets/FoundationSection-Dlge3iEh.js","assets/beaker-CpcOZgjY.js","assets/HousingModule-DPbzhLOu.js","assets/utensils-Bv_3EC5m.js","assets/toggle-right-QdJo_Wu2.js","assets/HospitalitySection-BTTvrmrJ.js","assets/GlobalSearchEmptyState-DPbQ6wTe.js","assets/InstructorGradebook-DoQ7HUjE.js","assets/StudentProgressDashboard-BhnxaD1M.js","assets/StudentProfilePage-D-CHmmvk.js","assets/smartphone-1aMdQzUm.js","assets/ZCPAModule-CWkFlvLp.js","assets/WholesaleB2BShop-DlslXYPW.js","assets/WholesaleOrderTracker-D026ExvG.js","assets/package-check-Bnj9L1BA.js","assets/factory-DU7bupdg.js","assets/WholesaleAdminPanel-D5vgcC7h.js","assets/AreaChart-J2EYQYPH.js","assets/box-DyU2tym2.js","assets/arrow-up-BZXVcZJO.js","assets/droplet-DAs1jGE_.js","assets/WholesalePartnerPortal-QClgVNau.js","assets/MedSpaPortal-BJoJ9Djd.js","assets/VenueCrossLinks-CL_l1bhu.js","assets/RGMComplianceDashboard-DM34j9yA.js","assets/SupplyChainModule-DT0c3luJ.js","assets/ComplianceLockdown-CfbejA2w.js","assets/mouse-pointer-Ch0uaEJZ.js","assets/WixSyncScheduler-B_uREFIc.js","assets/arrow-left-right-DaX6CGqa.js","assets/CEUTrainingPortal-DLdsFG1t.js","assets/WholesaleFulfillmentDashboard-BpmoMF7M.js","assets/SAPProgressEngine-CnfLUoFB.js","assets/Line-Cb3CfKUU.js","assets/thumbs-down-CPtLD6oU.js","assets/calendar-plus--d-fxjm0.js","assets/ChainOfCustodyLog-CVQK8zxN.js","assets/ParentGuardianPortal-NXYMI8cw.js","assets/ExecutiveFinancialOverview-BeYjhk6p.js","assets/AdmissionsPage-1SA_ztK9.js","assets/studentSalonServices-CAIuVKJ1.js","assets/SalonServicesPage-BSzw5eKf.js","assets/ClientJourneyStrip-D-_gYtaC.js","assets/StudentSalonClinic-4t2URS5C.js","assets/SISDashboard-DxA2JY6v.js","assets/EDExpressGateway-DmhHgWjG.js","assets/WixStudioGlobalExport-DZGlqj2V.js","assets/code-BhTQ-sFU.js","assets/tablet-CTEQkSwl.js","assets/GoogleMetaSync-B8FegcMR.js","assets/RobotsTxtGenerator-CVFhx4br.js","assets/bot-B6Ow80Nq.js","assets/GA4IntegrationModule-BRh_zhkP.js","assets/GSCSearchConsoleModule-BXEddsC8.js","assets/circle-dashed-CDWRDh2-.js","assets/RetargetingConversionModule-B5w_OuZ7.js","assets/share-2-Dg90E3t6.js","assets/ABTestCampaignModule-DsxEyTUZ.js","assets/SovereignMultiSiteOS-B_hxBHPC.js","assets/AIScanResultsPortal-CcPpybnU.js","assets/AutonomousEscalationGovernance-63zM-zxy.js","assets/FoundationLandingPage-CKVM2Q9y.js","assets/ZorganicsPremiumLanding-DJOnsVVK.js","assets/CampusHomePage-bY8g2MtB.js","assets/lock-keyhole-txCZyakc.js","assets/ZLPPortal-CT9Um45G.js","assets/ZIPPortal-CX-4wtDk.js","assets/campusOps-ChcCoS35.js","assets/ApplyNowForm-uhFPb_Ze.js","assets/activationSystem-B7nzrT09.js","assets/ProgramDetailPublic-FnhtbzHW.js","assets/CampusOpsPortal-BJqcWvr4.js","assets/externshipPortal-BkKvI-Zc.js","assets/TourBookingPage-9NWoctMq.js","assets/EmployerOnboarding-StOQeqG7.js","assets/EmployerWorkspace-wyOiEASP.js"])))=>i.map(i=>d[i]); 2var kz=Object.defineProperty;var Sk=t=>{throw TypeError(t)};var Sz=(t,s,n)=>s in t?kz(t,s,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[s]=n;var cp=(t,s,n)=>Sz(t,typeof s!="symbol"?s+"":s,n),S1=(t,s,n)=>s.has(t)||Sk("Cannot "+n);var he=(t,s,n)=>(S1(t,s,"read from private field"),n?n.call(t):s.get(t)),St=(t,s,n)=>s.has(t)?Sk("Cannot add the same private member more than once"):s instanceof WeakSet?s.add(t):s.set(t,n),ct=(t,s,n,a)=>(S1(t,s,"write to private field"),a?a.call(t,n):s.set(t,n),n),pn=(t,s,n)=>(S1(t,s,"access private method"),n);var uf=(t,s,n,a)=>({set _(r){ct(t,s,r,n)},get _(){return he(t,s,a)}});function Cz(t,s){for(var n=0;n<s.length;n++){const a=s[n];if(typeof a!="string"&&!Array.isArray(a)){for(const r in a)if(r!=="default"&&!(r in t)){const i=Object.getOwnPropertyDescriptor(a,r);i&&Object.defineProperty(t,r,i.get?i:{enumerable:!0,get:()=>a[r]})}}}return Object.freeze(Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}))}(function(){const s=document.createElement("link").relList;if(s&&s.supports&&s.supports("modulepreload"))return;for(const r of document.querySelectorAll('link[rel="modulepreload"]'))a(r);new MutationObserver(r=>{for(const i of r)if(i.type==="childList")for(const o of i.addedNodes)o.tagName==="LINK"&&o.rel==="modulepreload"&&a(o)}).observe(document,{childList:!0,subtree:!0});function n(r){const i={};return r.integrity&&(i.integrity=r.integrity),r.referrerPolicy&&(i.referrerPolicy=r.referrerPolicy),r.crossOrigin==="use-credentials"?i.credentials="include":r.crossOrigin==="anonymous"?i.credentials="omit":i.credentials="same-origin",i}function a(r){if(r.ep)return;r.ep=!0;const i=n(r);fetch(r.href,i)}})();var Ehe=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function qN(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var PF={exports:{}},xb={},DF={exports:{}},Et={};
vendor: 9,788 bytes, lines 2-26
2/** 3 * @license React 4 * react.production.min.js 5 * 6 * Copyright (c) Facebook, Inc. and its affiliates. 7 * 8 * This source code is licensed under the MIT license found in the 9 * LICENSE file in the root directory of this source tree. 10 */var Ux=Symbol.for("react.element"),Az=Symbol.for("react.portal"),Ez=Symbol.for("react.fragment"),Fz=Symbol.for("react.strict_mode"),Tz=Symbol.for("react.profiler"),Pz=Symbol.for("react.provider"),Dz=Symbol.for("react.context"),Rz=Symbol.for("react.forward_ref"),Iz=Symbol.for("react.suspense"),$z=Symbol.for("react.memo"),zz=Symbol.for("react.lazy"),Ck=Symbol.iterator;function Lz(t){return t===null||typeof t!="object"?null:(t=Ck&&t[Ck]||t["@@iterator"],typeof t=="function"?t:null)}var RF={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},IF=Object.assign,$F={};function qm(t,s,n){this.props=t,this.context=s,this.refs=$F,this.updater=n||RF}qm.prototype.isReactComponent={};qm.prototype.setState=function(t,s){if(typeof t!="object"&&typeof t!="function"&&t!=null)throw Error("setState(...): takes an object of state variables to update or a function which returns an object of state variables.");this.updater.enqueueSetState(this,t,s,"setState")};qm.prototype.forceUpdate=function(t){this.updater.enqueueForceUpdate(this,t,"forceUpdate")};function zF(){}zF.prototype=qm.prototype;function WN(t,s,n){this.props=t,this.context=s,this.refs=$F,this.updater=n||RF}var HN=WN.prototype=new zF;HN.constructor=WN;IF(HN,qm.prototype);HN.isPureReactComponent=!0;var Ak=Array.isArray,LF=Object.prototype.hasOwnProperty,GN={current:null},OF={key:!0,ref:!0,__self:!0,__source:!0};function MF(t,s,n){var a,r={},i=null,o=null;if(s!=null)for(a in s.ref!==void 0&&(o=s.ref),s.key!==void 0&&(i=""+s.key),s)LF.call(s,a)&&!OF.hasOwnProperty(a)&&(r[a]=s[a]);var l=arguments.length-2;if(l===1)r.children=n;else if(1<l){for(var c=Array(l),u=0;u<l;u++)c[u]=arguments[u+2];r.children=c}if(t&&t.defaultProps)for(a in l=t.defaultProps,l)r[a]===void 0&&(r[a]=l[a]);return{$$typeof:Ux,type:t,key:i,ref:o,props:r,_owner:GN.current}}function Oz(t,s){return{$$typeof:Ux,type:t.type,key:s,ref:t.ref,props:t.props,_owner:t._owner}}function VN(t){return typeof t=="object"&&t!==null&&t.$$typeof===Ux}function Mz(t){var s={"=":"=0",":":"=2"};return"$"+t.replace(/[=:]/g,function(n){return s[n]})}var Ek=/\/+/g;function C1(t,s){return typeof t=="object"&&t!==null&&t.key!=null?Mz(""+t.key):s.toString(36)}function Yg(t,s,n,a,r){var i=typeof t;(i==="undefined"||i==="boolean")&&(t=null);var o=!1;if(t===null)o=!0;else switch(i){case"string":case"number":o=!0;break;case"object":switch(t.$$typeof){case Ux:case Az:o=!0}}if(o)return o=t,r=r(o),t=a===""?"."+C1(o,0):a,Ak(r)?(n="",t!=null&&(n=t.replace(Ek,"$&/")+"/"),Yg(r,s,n,"",function(u){return u})):r!=null&&(VN(r)&&(r=Oz(r,n+(!r.key||o&&o.key===r.key?"":(""+r.key).replace(Ek,"$&/")+"/")+t)),s.push(r)),1;if(o=0,a=a===""?".":a+":",Ak(t))for(var l=0;l<t.length;l++){i=t[l];var c=a+C1(i,l);o+=Yg(i,s,n,c,r)}else if(c=Lz(t),typeof c=="function")for(t=c.call(t),l=0;!(i=t.next()).done;)i=i.value,c=a+C1(i,l++),o+=Yg(i,s,n,c,r);else if(i==="object")throw s=String(t),Error("Objects are not valid as a React child (found: "+(s==="[object Object]"?"object with keys {"+Object.keys(t).join(", ")+"}":s)+"). If you meant to render a collection of children, use an array instead.");return o}function mf(t,s,n){if(t==null)return t;var a=[],r=0;return Yg(t,a,"","",function(i){return s.call(n,i,r++)}),a}function Bz(t){if(t._status===-1){var s=t._result;s=s(),s.then(function(n){(t._status===0||t._status===-1)&&(t._status=1,t._result=n)},function(n){(t._status===0||t._status===-1)&&(t._status=2,t._result=n)}),t._status===-1&&(t._status=0,t._result=s)}if(t._status===1)return t._result.default;throw t._result}var na={current:null},Kg={transition:null},Uz={ReactCurrentDispatcher:na,ReactCurrentBatchConfig:Kg,ReactCurrentOwner:GN};function BF(){throw Error("act(...) is not supported in production builds of React.")}Et.Children={map:mf,forEach:function(t,s,n){mf(t,function(){s.apply(this,arguments)},n)},count:function(t){var s=0;return mf(t,function(){s++}),s},toArray:function(t){return mf(t,function(s){return s})||[]},only:function(t){if(!VN(t))throw Error("React.Children.only expected to receive a single React element child.");return t}};Et.Component=qm;Et.Fragment=Ez;Et.Profiler=Tz;Et.PureComponent=WN;Et.StrictMode=Fz;Et.Suspense=Iz;Et.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=Uz;Et.act=BF;Et.cloneElement=function(t,s,n){if(t==null)throw Error("React.cloneElement(...): The argument must be a React element, but you passed "+t+".");var a=IF({},t.props),r=t.key,i=t.ref,o=t._owner;if(s!=null){if(s.ref!==void 0&&(i=s.ref,o=GN.current),s.key!==void 0&&(r=""+s.key),t.type&&t.type.defaultProps)var l=t.type.defaultProps;for(c in s)LF.call(s,c)&&!OF.hasOwnProperty(c)&&(a[c]=s[c]===void 0&&l!==void 0?l[c]:s[c])}var c=arguments.length-2;if(c===1)a.children=n;else if(1<c){l=Array(c);for(var u=0;u<c;u++)l[u]=arguments[u+2];a.children=l}return{$$typeof:Ux,type:t.type,key:r,ref:i,props:a,_owner:o}};Et.createContext=function(t){return t={$$typeof:Dz,_currentValue:t,_currentValue2:t,_threadCount:0,Provider:null,Consumer:null,_defaultValue:null,_globalName:null},t.Provider={$$typeof:Pz,_context:t},t.Consumer=t};Et.createElement=MF;Et.createFactory=function(t){var s=MF.bind(null,t);return s.type=t,s};Et.createRef=function(){return{current:null}};Et.forwardRef=function(t){return{$$typeof:Rz,render:t}};Et.isValidElement=VN;Et.lazy=function(t){return{$$typeof:zz,_payload:{_status:-1,_result:t},_init:Bz}};Et.memo=function(t,s){return{$$typeof:$z,type:t,compare:s===void 0?null:s}};Et.startTransition=function(t){var s=Kg.transition;Kg.transition={};try{t()}finally{Kg.transition=s}};Et.unstable_act=BF;Et.useCallback=function(t,s){return na.current.useCallback(t,s)};Et.useContext=function(t){return na.current.useContext(t)};Et.useDebugValue=function(){};Et.useDeferredValue=function(t){return na.current.useDeferredValue(t)};Et.useEffect=function(t,s){return na.current.useEffect(t,s)};Et.useId=function(){return na.current.useId()};Et.useImperativeHandle=function(t,s,n){return na.current.useImperativeHandle(t,s,n)};Et.useInsertionEffect=function(t,s){return na.current.useInsertionEffect(t,s)};Et.useLayoutEffect=function(t,s){return na.current.useLayoutEffect(t,s)};Et.useMemo=function(t,s){return na.current.useMemo(t,s)};Et.useReducer=function(t,s,n){return na.current.useReducer(t,s,n)};Et.useRef=function(t){return na.current.useRef(t)};Et.useState=function(t){return na.current.useState(t)};Et.useSyncExternalStore=function(t,s,n){return na.current.useSyncExternalStore(t,s,n)};Et.useTransition=function(){return na.current.useTransition()};Et.version="18.3.1";DF.exports=Et;var d=DF.exports;const re=qN(d),$d=Cz({__proto__:null,default:re},[d]);/** 11 * @license React 12 * react-jsx-runtime.production.min.js 13 * 14 * Copyright (c) Facebook, Inc. and its affiliates. 15 * 16 * This source code is licensed under the MIT license found in the 17 * LICENSE file in the root directory of this source tree. 18 */var qz=d,Wz=Symbol.for("react.element"),Hz=Symbol.for("react.fragment"),Gz=Object.prototype.hasOwnProperty,Vz=qz.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,Zz={key:!0,ref:!0,__self:!0,__source:!0};function UF(t,s,n){var a,r={},i=null,o=null;n!==void 0&&(i=""+n),s.key!==void 0&&(i=""+s.key),s.ref!==void 0&&(o=s.ref);for(a in s)Gz.call(s,a)&&!Zz.hasOwnProperty(a)&&(r[a]=s[a]);if(t&&t.defaultProps)for(a in s=t.defaultProps,s)r[a]===void 0&&(r[a]=s[a]);return{$$typeof:Wz,type:t,key:i,ref:o,props:r,_owner:Vz.current}}xb.Fragment=Hz;xb.jsx=UF;xb.jsxs=UF;PF.exports=xb;var e=PF.exports,qF={exports:{}},Ha={},WF={exports:{}},HF={};/** 19 * @license React 20 * scheduler.production.min.js 21 * 22 * Copyright (c) Facebook, Inc. and its affiliates. 23 * 24 * This source code is licensed under the MIT license found in the 25 * LICENSE file in the root directory of this source tree. 26 */(function(t){function s(z,M){var R=z.length;z.push(M);e:for(;0<R;){var T=R-1>>>1,U=z[T];if(0<r(U,M))z[T]=M,z[R]=U,R=T;else break e}}function n(z){return z.length===0?null:z[0]}function a(z){if(z.length===0)return null;var M=z[0],R=z.pop();if(R!==M){z[0]=R;e:for(var T=0,U=z.length,q=U>>>1;T<q;){var H=2*(T+1)-1,G=z[H],W=H+1,X=z[W];if(0>r(G,R))W<U&&0>r(X,G)?(z[T]=X,z[W]=R,T=W):(z[T]=G,z[H]=R,T=H);else if(W<U&&0>r(X,R))z[T]=X,z[W]=R,T=W;else break e}}return M}function r(z,M){var R=z.sortIndex-M.sortIndex;return R!==0?R:z.id-M.id}if(typeof performance=="object"&&typeof performance.now=="function"){var i=performance;t.unstable_now=function(){return i.now()}}else{var o=Date,l=o.now();t.unstable_now=function(){return o.now()-l}}var c=[],u=[],p=1,m=null,x=3,h=!1,y=!1,v=!1,g=typeof setTimeout=="function"?setTimeout:null,N=typeof clearTimeout=="function"?clearTimeout:null,b=typeof setImmediate<"u"?setImmediate:null;typeof navigator<"u"&&navigator.scheduling!==void 0&&navigator.scheduling.isInputPending!==void 0&&navigator.scheduling.isInputPending.bind(navigator.scheduling);function f(z){for(var M=n(u);M!==null;){if(M.callback===null)a(u);else if(M.startTime<=z)a(u),M.sortIndex=M.expirationTime,s(c,M);else break;M=n(u)}}function j(z){if(v=!1,f(z),!y)if(n(c)!==null)y=!0,B(S);else{var M=n(u);M!==null&&A(j,M.startTime-z)}}function S(z,M){y=!1,v&&(v=!1,N(C),C=-1),h=!0;var R=x;try{for(f(M),m=n(c);m!==null&&(!(m.expirationTime>M)||z&&!F());){var T=m.callback;if(typeof T=="function"){m.callback=null,x=m.priorityLevel;var U=T(m.expirationTime<=M);M=t.unstable_now(),typeof U=="function"?m.callback=U:m===n(c)&&a(c),f(M)}else a(c);m=n(c)}if(m!==null)var q=!0;else{var H=n(u);H!==null&&A(j,H.startTime-M),q=!1}return q}finally{m=null,x=R,h=!1}
vendor: 8,871 bytes, lines 26-35
26}var w=!1,_=null,C=-1,E=5,P=-1;function F(){return!(t.unstable_now()-P<E)}function I(){if(_!==null){var z=t.unstable_now();P=z;var M=!0;try{M=_(!0,z)}finally{M?D():(w=!1,_=null)}}else w=!1}var D;if(typeof b=="function")D=function(){b(I)};else if(typeof MessageChannel<"u"){var L=new MessageChannel,V=L.port2;L.port1.onmessage=I,D=function(){V.postMessage(null)}}else D=function(){g(I,0)};function B(z){_=z,w||(w=!0,D())}function A(z,M){C=g(function(){z(t.unstable_now())},M)}t.unstable_IdlePriority=5,t.unstable_ImmediatePriority=1,t.unstable_LowPriority=4,t.unstable_NormalPriority=3,t.unstable_Profiling=null,t.unstable_UserBlockingPriority=2,t.unstable_cancelCallback=function(z){z.callback=null},t.unstable_continueExecution=function(){y||h||(y=!0,B(S))},t.unstable_forceFrameRate=function(z){0>z||125<z?console.error("forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported"):E=0<z?Math.floor(1e3/z):5},t.unstable_getCurrentPriorityLevel=function(){return x},t.unstable_getFirstCallbackNode=function(){return n(c)},t.unstable_next=function(z){switch(x){case 1:case 2:case 3:var M=3;break;default:M=x}var R=x;x=M;try{return z()}finally{x=R}},t.unstable_pauseExecution=function(){},t.unstable_requestPaint=function(){},t.unstable_runWithPriority=function(z,M){switch(z){case 1:case 2:case 3:case 4:case 5:break;default:z=3}var R=x;x=z;try{return M()}finally{x=R}},t.unstable_scheduleCallback=function(z,M,R){var T=t.unstable_now();switch(typeof R=="object"&&R!==null?(R=R.delay,R=typeof R=="number"&&0<R?T+R:T):R=T,z){case 1:var U=-1;break;case 2:U=250;break;case 5:U=1073741823;break;case 4:U=1e4;break;default:U=5e3}return U=R+U,z={id:p++,callback:M,priorityLevel:z,startTime:R,expirationTime:U,sortIndex:-1},R>T?(z.sortIndex=R,s(u,z),n(c)===null&&z===n(u)&&(v?(N(C),C=-1):v=!0,A(j,R-T))):(z.sortIndex=U,s(c,z),y||h||(y=!0,B(S))),z},t.unstable_shouldYield=F,t.unstable_wrapCallback=function(z){var M=x;return function(){var R=x;x=M;try{return z.apply(this,arguments)}finally{x=R}}}})(HF);WF.exports=HF;var Yz=WF.exports;/** 27 * @license React 28 * react-dom.production.min.js 29 * 30 * Copyright (c) Facebook, Inc. and its affiliates. 31 * 32 * This source code is licensed under the MIT license found in the 33 * LICENSE file in the root directory of this source tree. 34 */var Kz=d,Ba=Yz;function Ae(t){for(var s="https://reactjs.org/docs/error-decoder.html?invariant="+t,n=1;n<arguments.length;n++)s+="&args[]="+encodeURIComponent(arguments[n]);return"Minified React error #"+t+"; visit "+s+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}var GF=new Set,Uh={};function zd(t,s){_m(t,s),_m(t+"Capture",s)}function _m(t,s){for(Uh[t]=s,t=0;t<s.length;t++)GF.add(s[t])}var So=!(typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),lw=Object.prototype.hasOwnProperty,Qz=/^[:A-Z_a-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD][:A-Z_a-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD\-.0-9\u00B7\u0300-\u036F\u203F-\u2040]*$/,Fk={},Tk={};function Jz(t){return lw.call(Tk,t)?!0:lw.call(Fk,t)?!1:Qz.test(t)?Tk[t]=!0:(Fk[t]=!0,!1)}function Xz(t,s,n,a){if(n!==null&&n.type===0)return!1;switch(typeof s){case"function":case"symbol":return!0;case"boolean":return a?!1:n!==null?!n.acceptsBooleans:(t=t.toLowerCase().slice(0,5),t!=="data-"&&t!=="aria-");default:return!1}}function eL(t,s,n,a){if(s===null||typeof s>"u"||Xz(t,s,n,a))return!0;if(a)return!1;if(n!==null)switch(n.type){case 3:return!s;case 4:return s===!1;case 5:return isNaN(s);case 6:return isNaN(s)||1>s}return!1}function aa(t,s,n,a,r,i,o){this.acceptsBooleans=s===2||s===3||s===4,this.attributeName=a,this.attributeNamespace=r,this.mustUseProperty=n,this.propertyName=t,this.type=s,this.sanitizeURL=i,this.removeEmptyString=o}var _n={};"children dangerouslySetInnerHTML defaultValue defaultChecked innerHTML suppressContentEditableWarning suppressHydrationWarning style".split(" ").forEach(function(t){_n[t]=new aa(t,0,!1,t,null,!1,!1)});[["acceptCharset","accept-charset"],["className","class"],["htmlFor","for"],["httpEquiv","http-equiv"]].forEach(function(t){var s=t[0];_n[s]=new aa(s,1,!1,t[1],null,!1,!1)});["contentEditable","draggable","spellCheck","value"].forEach(function(t){_n[t]=new aa(t,2,!1,t.toLowerCase(),null,!1,!1)});["autoReverse","externalResourcesRequired","focusable","preserveAlpha"].forEach(function(t){_n[t]=new aa(t,2,!1,t,null,!1,!1)});"allowFullScreen async autoFocus autoPlay controls default defer disabled disablePictureInPicture disableRemotePlayback formNoValidate hidden loop noModule noValidate open playsInline readOnly required reversed scoped seamless itemScope".split(" ").forEach(function(t){_n[t]=new aa(t,3,!1,t.toLowerCase(),null,!1,!1)});["checked","multiple","muted","selected"].forEach(function(t){_n[t]=new aa(t,3,!0,t,null,!1,!1)});["capture","download"].forEach(function(t){_n[t]=new aa(t,4,!1,t,null,!1,!1)});["cols","rows","size","span"].forEach(function(t){_n[t]=new aa(t,6,!1,t,null,!1,!1)});["rowSpan","start"].forEach(function(t){_n[t]=new aa(t,5,!1,t.toLowerCase(),null,!1,!1)});var ZN=/[\-:]([a-z])/g;function YN(t){return t[1].toUpperCase()}"accent-height alignment-baseline arabic-form baseline-shift cap-height clip-path clip-rule color-interpolation color-interpolation-filters color-profile color-rendering dominant-baseline enable-background fill-opacity fill-rule flood-color flood-opacity font-family font-size font-size-adjust font-stretch font-style font-variant font-weight glyph-name glyph-orientation-horizontal glyph-orientation-vertical horiz-adv-x horiz-origin-x image-rendering letter-spacing lighting-color marker-end marker-mid marker-start overline-position overline-thickness paint-order panose-1 pointer-events rendering-intent shape-rendering stop-color stop-opacity strikethrough-position strikethrough-thickness stroke-dasharray stroke-dashoffset stroke-linecap stroke-linejoin stroke-miterlimit stroke-opacity stroke-width text-anchor text-decoration text-rendering underline-position underline-thickness unicode-bidi unicode-range units-per-em v-alphabetic v-hanging v-ideographic v-mathematical vector-effect vert-adv-y vert-origin-x vert-origin-y word-spacing writing-mode xmlns:xlink x-height".split(" ").forEach(function(t){var s=t.replace(ZN,YN);_n[s]=new aa(s,1,!1,t,null,!1,!1)});"xlink:actuate xlink:arcrole xlink:role xlink:show xlink:title xlink:type".split(" ").forEach(function(t){var s=t.replace(ZN,YN);_n[s]=new aa(s,1,!1,t,"http://www.w3.org/1999/xlink",!1,!1)});["xml:base","xml:lang","xml:space"].forEach(function(t){var s=t.replace(ZN,YN);_n[s]=new aa(s,1,!1,t,"http://www.w3.org/XML/1998/namespace",!1,!1)});["tabIndex","crossOrigin"].forEach(function(t){_n[t]=new aa(t,1,!1,t.toLowerCase(),null,!1,!1)});_n.xlinkHref=new aa("xlinkHref",1,!1,"xlink:href","http://www.w3.org/1999/xlink",!0,!1);["src","href","action","formAction"].forEach(function(t){_n[t]=new aa(t,1,!1,t.toLowerCase(),null,!0,!0)});function KN(t,s,n,a){var r=_n.hasOwnProperty(s)?_n[s]:null;(r!==null?r.type!==0:a||!(2<s.length)||s[0]!=="o"&&s[0]!=="O"||s[1]!=="n"&&s[1]!=="N")&&(eL(s,n,r,a)&&(n=null),a||r===null?Jz(s)&&(n===null?t.removeAttribute(s):t.setAttribute(s,""+n)):r.mustUseProperty?t[r.propertyName]=n===null?r.type===3?!1:"":n:(s=r.attributeName,a=r.attributeNamespace,n===null?t.removeAttribute(s):(r=r.type,n=r===3||r===4&&n===!0?"":""+n,a?t.setAttributeNS(a,s,n):t.setAttribute(s,n))))}var Mo=Kz.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED,pf=Symbol.for("react.element"),Eu=Symbol.for("react.portal"),Fu=Symbol.for("react.fragment"),QN=Symbol.for("react.strict_mode"),cw=Symbol.for("react.profiler"),VF=Symbol.for("react.provider"),ZF=Symbol.for("react.context"),JN=Symbol.for("react.forward_ref"),dw=Symbol.for("react.suspense"),uw=Symbol.for("react.suspense_list"),XN=Symbol.for("react.memo"),xl=Symbol.for("react.lazy"),YF=Symbol.for("react.offscreen"),Pk=Symbol.iterator;function dp(t){return t===null||typeof t!="object"?null:(t=Pk&&t[Pk]||t["@@iterator"],typeof t=="function"?t:null)}var js=Object.assign,A1;function Jp(t){if(A1===void 0)try{throw Error()}catch(n){var s=n.stack.trim().match(/\n( *(at )?)/);A1=s&&s[1]||""}return` 35`+A1+t}var E1=!1;function F1(t,s){if(!t||E1)return"";E1=!0;var n=Error.prepareStackTrace;Error.prepareStackTrace=void 0;try{if(s)if(s=function(){throw Error()},Object.defineProperty(s.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(s,[])}catch(u){var a=u}Reflect.construct(t,[],s)}else{try{s.call()}catch(u){a=u}t.call(s.prototype)}else{try{throw Error()}catch(u){a=u}t()}}
vendor: 16,753 bytes, lines 35-38
35catch(u){if(u&&a&&typeof u.stack=="string"){for(var r=u.stack.split(` 36`),i=a.stack.split(` 37`),o=r.length-1,l=i.length-1;1<=o&&0<=l&&r[o]!==i[l];)l--;for(;1<=o&&0<=l;o--,l--)if(r[o]!==i[l]){if(o!==1||l!==1)do if(o--,l--,0>l||r[o]!==i[l]){var c=` 38`+r[o].replace(" at new "," at ");return t.displayName&&c.includes("<anonymous>")&&(c=c.replace("<anonymous>",t.displayName)),c}while(1<=o&&0<=l);break}}}finally{E1=!1,Error.prepareStackTrace=n}return(t=t?t.displayName||t.name:"")?Jp(t):""}function tL(t){switch(t.tag){case 5:return Jp(t.type);case 16:return Jp("Lazy");case 13:return Jp("Suspense");case 19:return Jp("SuspenseList");case 0:case 2:case 15:return t=F1(t.type,!1),t;case 11:return t=F1(t.type.render,!1),t;case 1:return t=F1(t.type,!0),t;default:return""}}function mw(t){if(t==null)return null;if(typeof t=="function")return t.displayName||t.name||null;if(typeof t=="string")return t;switch(t){case Fu:return"Fragment";case Eu:return"Portal";case cw:return"Profiler";case QN:return"StrictMode";case dw:return"Suspense";case uw:return"SuspenseList"}if(typeof t=="object")switch(t.$$typeof){case ZF:return(t.displayName||"Context")+".Consumer";case VF:return(t._context.displayName||"Context")+".Provider";case JN:var s=t.render;return t=t.displayName,t||(t=s.displayName||s.name||"",t=t!==""?"ForwardRef("+t+")":"ForwardRef"),t;case XN:return s=t.displayName||null,s!==null?s:mw(t.type)||"Memo";case xl:s=t._payload,t=t._init;try{return mw(t(s))}catch{}}return null}function sL(t){var s=t.type;switch(t.tag){case 24:return"Cache";case 9:return(s.displayName||"Context")+".Consumer";case 10:return(s._context.displayName||"Context")+".Provider";case 18:return"DehydratedFragment";case 11:return t=s.render,t=t.displayName||t.name||"",s.displayName||(t!==""?"ForwardRef("+t+")":"ForwardRef");case 7:return"Fragment";case 5:return s;case 4:return"Portal";case 3:return"Root";case 6:return"Text";case 16:return mw(s);case 8:return s===QN?"StrictMode":"Mode";case 22:return"Offscreen";case 12:return"Profiler";case 21:return"Scope";case 13:return"Suspense";case 19:return"SuspenseList";case 25:return"TracingMarker";case 1:case 0:case 17:case 2:case 14:case 15:if(typeof s=="function")return s.displayName||s.name||null;if(typeof s=="string")return s}return null}function Wl(t){switch(typeof t){case"boolean":case"number":case"string":case"undefined":return t;case"object":return t;default:return""}}function KF(t){var s=t.type;return(t=t.nodeName)&&t.toLowerCase()==="input"&&(s==="checkbox"||s==="radio")}function nL(t){var s=KF(t)?"checked":"value",n=Object.getOwnPropertyDescriptor(t.constructor.prototype,s),a=""+t[s];if(!t.hasOwnProperty(s)&&typeof n<"u"&&typeof n.get=="function"&&typeof n.set=="function"){var r=n.get,i=n.set;return Object.defineProperty(t,s,{configurable:!0,get:function(){return r.call(this)},set:function(o){a=""+o,i.call(this,o)}}),Object.defineProperty(t,s,{enumerable:n.enumerable}),{getValue:function(){return a},setValue:function(o){a=""+o},stopTracking:function(){t._valueTracker=null,delete t[s]}}}}function hf(t){t._valueTracker||(t._valueTracker=nL(t))}function QF(t){if(!t)return!1;var s=t._valueTracker;if(!s)return!0;var n=s.getValue(),a="";return t&&(a=KF(t)?t.checked?"true":"false":t.value),t=a,t!==n?(s.setValue(t),!0):!1}function X0(t){if(t=t||(typeof document<"u"?document:void 0),typeof t>"u")return null;try{return t.activeElement||t.body}catch{return t.body}}function pw(t,s){var n=s.checked;return js({},s,{defaultChecked:void 0,defaultValue:void 0,value:void 0,checked:n??t._wrapperState.initialChecked})}function Dk(t,s){var n=s.defaultValue==null?"":s.defaultValue,a=s.checked!=null?s.checked:s.defaultChecked;n=Wl(s.value!=null?s.value:n),t._wrapperState={initialChecked:a,initialValue:n,controlled:s.type==="checkbox"||s.type==="radio"?s.checked!=null:s.value!=null}}function JF(t,s){s=s.checked,s!=null&&KN(t,"checked",s,!1)}function hw(t,s){JF(t,s);var n=Wl(s.value),a=s.type;if(n!=null)a==="number"?(n===0&&t.value===""||t.value!=n)&&(t.value=""+n):t.value!==""+n&&(t.value=""+n);else if(a==="submit"||a==="reset"){t.removeAttribute("value");return}s.hasOwnProperty("value")?xw(t,s.type,n):s.hasOwnProperty("defaultValue")&&xw(t,s.type,Wl(s.defaultValue)),s.checked==null&&s.defaultChecked!=null&&(t.defaultChecked=!!s.defaultChecked)}function Rk(t,s,n){if(s.hasOwnProperty("value")||s.hasOwnProperty("defaultValue")){var a=s.type;if(!(a!=="submit"&&a!=="reset"||s.value!==void 0&&s.value!==null))return;s=""+t._wrapperState.initialValue,n||s===t.value||(t.value=s),t.defaultValue=s}n=t.name,n!==""&&(t.name=""),t.defaultChecked=!!t._wrapperState.initialChecked,n!==""&&(t.name=n)}function xw(t,s,n){(s!=="number"||X0(t.ownerDocument)!==t)&&(n==null?t.defaultValue=""+t._wrapperState.initialValue:t.defaultValue!==""+n&&(t.defaultValue=""+n))}var Xp=Array.isArray;function Zu(t,s,n,a){if(t=t.options,s){s={};for(var r=0;r<n.length;r++)s["$"+n[r]]=!0;for(n=0;n<t.length;n++)r=s.hasOwnProperty("$"+t[n].value),t[n].selected!==r&&(t[n].selected=r),r&&a&&(t[n].defaultSelected=!0)}else{for(n=""+Wl(n),s=null,r=0;r<t.length;r++){if(t[r].value===n){t[r].selected=!0,a&&(t[r].defaultSelected=!0);return}s!==null||t[r].disabled||(s=t[r])}s!==null&&(s.selected=!0)}}function fw(t,s){if(s.dangerouslySetInnerHTML!=null)throw Error(Ae(91));return js({},s,{value:void 0,defaultValue:void 0,children:""+t._wrapperState.initialValue})}function Ik(t,s){var n=s.value;if(n==null){if(n=s.children,s=s.defaultValue,n!=null){if(s!=null)throw Error(Ae(92));if(Xp(n)){if(1<n.length)throw Error(Ae(93));n=n[0]}s=n}s==null&&(s=""),n=s}t._wrapperState={initialValue:Wl(n)}}function XF(t,s){var n=Wl(s.value),a=Wl(s.defaultValue);n!=null&&(n=""+n,n!==t.value&&(t.value=n),s.defaultValue==null&&t.defaultValue!==n&&(t.defaultValue=n)),a!=null&&(t.defaultValue=""+a)}function $k(t){var s=t.textContent;s===t._wrapperState.initialValue&&s!==""&&s!==null&&(t.value=s)}function e6(t){switch(t){case"svg":return"http://www.w3.org/2000/svg";case"math":return"http://www.w3.org/1998/Math/MathML";default:return"http://www.w3.org/1999/xhtml"}}function gw(t,s){return t==null||t==="http://www.w3.org/1999/xhtml"?e6(s):t==="http://www.w3.org/2000/svg"&&s==="foreignObject"?"http://www.w3.org/1999/xhtml":t}var xf,t6=function(t){return typeof MSApp<"u"&&MSApp.execUnsafeLocalFunction?function(s,n,a,r){MSApp.execUnsafeLocalFunction(function(){return t(s,n,a,r)})}:t}(function(t,s){if(t.namespaceURI!=="http://www.w3.org/2000/svg"||"innerHTML"in t)t.innerHTML=s;else{for(xf=xf||document.createElement("div"),xf.innerHTML="<svg>"+s.valueOf().toString()+"</svg>",s=xf.firstChild;t.firstChild;)t.removeChild(t.firstChild);for(;s.firstChild;)t.appendChild(s.firstChild)}});function qh(t,s){if(s){var n=t.firstChild;if(n&&n===t.lastChild&&n.nodeType===3){n.nodeValue=s;return}}t.textContent=s}var yh={animationIterationCount:!0,aspectRatio:!0,borderImageOutset:!0,borderImageSlice:!0,borderImageWidth:!0,boxFlex:!0,boxFlexGroup:!0,boxOrdinalGroup:!0,columnCount:!0,columns:!0,flex:!0,flexGrow:!0,flexPositive:!0,flexShrink:!0,flexNegative:!0,flexOrder:!0,gridArea:!0,gridRow:!0,gridRowEnd:!0,gridRowSpan:!0,gridRowStart:!0,gridColumn:!0,gridColumnEnd:!0,gridColumnSpan:!0,gridColumnStart:!0,fontWeight:!0,lineClamp:!0,lineHeight:!0,opacity:!0,order:!0,orphans:!0,tabSize:!0,widows:!0,zIndex:!0,zoom:!0,fillOpacity:!0,floodOpacity:!0,stopOpacity:!0,strokeDasharray:!0,strokeDashoffset:!0,strokeMiterlimit:!0,strokeOpacity:!0,strokeWidth:!0},aL=["Webkit","ms","Moz","O"];Object.keys(yh).forEach(function(t){aL.forEach(function(s){s=s+t.charAt(0).toUpperCase()+t.substring(1),yh[s]=yh[t]})});function s6(t,s,n){return s==null||typeof s=="boolean"||s===""?"":n||typeof s!="number"||s===0||yh.hasOwnProperty(t)&&yh[t]?(""+s).trim():s+"px"}function n6(t,s){t=t.style;for(var n in s)if(s.hasOwnProperty(n)){var a=n.indexOf("--")===0,r=s6(n,s[n],a);n==="float"&&(n="cssFloat"),a?t.setProperty(n,r):t[n]=r}}var rL=js({menuitem:!0},{area:!0,base:!0,br:!0,col:!0,embed:!0,hr:!0,img:!0,input:!0,keygen:!0,link:!0,meta:!0,param:!0,source:!0,track:!0,wbr:!0});function yw(t,s){if(s){if(rL[t]&&(s.children!=null||s.dangerouslySetInnerHTML!=null))throw Error(Ae(137,t));if(s.dangerouslySetInnerHTML!=null){if(s.children!=null)throw Error(Ae(60));if(typeof s.dangerouslySetInnerHTML!="object"||!("__html"in s.dangerouslySetInnerHTML))throw Error(Ae(61))}if(s.style!=null&&typeof s.style!="object")throw Error(Ae(62))}}function bw(t,s){if(t.indexOf("-")===-1)return typeof s.is=="string";switch(t){case"annotation-xml":case"color-profile":case"font-face":case"font-face-src":case"font-face-uri":case"font-face-format":case"font-face-name":case"missing-glyph":return!1;default:return!0}}var vw=null;function e_(t){return t=t.target||t.srcElement||window,t.correspondingUseElement&&(t=t.correspondingUseElement),t.nodeType===3?t.parentNode:t}var jw=null,Yu=null,Ku=null;function zk(t){if(t=Hx(t)){if(typeof jw!="function")throw Error(Ae(280));var s=t.stateNode;s&&(s=vb(s),jw(t.stateNode,t.type,s))}}function a6(t){Yu?Ku?Ku.push(t):Ku=[t]:Yu=t}function r6(){if(Yu){var t=Yu,s=Ku;if(Ku=Yu=null,zk(t),s)for(t=0;t<s.length;t++)zk(s[t])}}function i6(t,s){return t(s)}function o6(){}var T1=!1;function l6(t,s,n){if(T1)return t(s,n);T1=!0;try{return i6(t,s,n)}finally{T1=!1,(Yu!==null||Ku!==null)&&(o6(),r6())}}function Wh(t,s){var n=t.stateNode;if(n===null)return null;var a=vb(n);if(a===null)return null;n=a[s];e:switch(s){case"onClick":case"onClickCapture":case"onDoubleClick":case"onDoubleClickCapture":case"onMouseDown":case"onMouseDownCapture":case"onMouseMove":case"onMouseMoveCapture":case"onMouseUp":case"onMouseUpCapture":case"onMouseEnter":(a=!a.disabled)||(t=t.type,a=!(t==="button"||t==="input"||t==="select"||t==="textarea")),t=!a;break e;default:t=!1}if(t)return null;if(n&&typeof n!="function")throw Error(Ae(231,s,typeof n));return n}var ww=!1;if(So)try{var up={};Object.defineProperty(up,"passive",{get:function(){ww=!0}}),window.addEventListener("test",up,up),window.removeEventListener("test",up,up)}catch{ww=!1}function iL(t,s,n,a,r,i,o,l,c){var u=Array.prototype.slice.call(arguments,3);try{s.apply(n,u)}catch(p){this.onError(p)}}var bh=!1,ey=null,ty=!1,Nw=null,oL={onError:function(t){bh=!0,ey=t}};function lL(t,s,n,a,r,i,o,l,c){bh=!1,ey=null,iL.apply(oL,arguments)}function cL(t,s,n,a,r,i,o,l,c){if(lL.apply(this,arguments),bh){if(bh){var u=ey;bh=!1,ey=null}else throw Error(Ae(198));ty||(ty=!0,Nw=u)}}function Ld(t){var s=t,n=t;if(t.alternate)for(;s.return;)s=s.return;else{t=s;do s=t,s.flags&4098&&(n=s.return),t=s.return;while(t)}return s.tag===3?n:null}function c6(t){if(t.tag===13){var s=t.memoizedState;if(s===null&&(t=t.alternate,t!==null&&(s=t.memoizedState)),s!==null)return s.dehydrated}return null}function Lk(t){if(Ld(t)!==t)throw Error(Ae(188))}function dL(t){var s=t.alternate;if(!s){if(s=Ld(t),s===null)throw Error(Ae(188));return s!==t?null:t}for(var n=t,a=s;;){var r=n.return;if(r===null)break;var i=r.alternate;if(i===null){if(a=r.return,a!==null){n=a;continue}break}if(r.child===i.child){for(i=r.child;i;){if(i===n)return Lk(r),t;if(i===a)return Lk(r),s;i=i.sibling}throw Error(Ae(188))}if(n.return!==a.return)n=r,a=i;else{for(var o=!1,l=r.child;l;){if(l===n){o=!0,n=r,a=i;break}if(l===a){o=!0,a=r,n=i;break}l=l.sibling}if(!o){for(l=i.child;l;){if(l===n){o=!0,n=i,a=r;break}if(l===a){o=!0,a=i,n=r;break}l=l.sibling}if(!o)throw Error(Ae(189))}}if(n.alternate!==a)throw Error(Ae(190))}if(n.tag!==3)throw Error(Ae(188));return n.stateNode.current===n?t:s}function d6(t){return t=dL(t),t!==null?u6(t):null}function u6(t){if(t.tag===5||t.tag===6)return t;for(t=t.child;t!==null;){var s=u6(t);if(s!==null)return s;t=t.sibling}return null}var m6=Ba.unstable_scheduleCallback,Ok=Ba.unstable_cancelCallback,uL=Ba.unstable_shouldYield,mL=Ba.unstable_requestPaint,Ds=Ba.unstable_now,pL=Ba.unstable_getCurrentPriorityLevel,t_=Ba.unstable_ImmediatePriority,p6=Ba.unstable_UserBlockingPriority,sy=Ba.unstable_NormalPriority,hL=Ba.unstable_LowPriority,h6=Ba.unstable_IdlePriority,fb=null,Ti=null;function xL(t){if(Ti&&typeof Ti.onCommitFiberRoot=="function")try{Ti.onCommitFiberRoot(fb,t,void 0,(t.current.flags&128)===128)}catch{}}var Kr=Math.clz32?Math.clz32:yL,fL=Math.log,gL=Math.LN2;function yL(t){return t>>>=0,t===0?32:31-(fL(t)/gL|0)|0}var ff=64,gf=4194304;function eh(t){switch(t&-t){case 1:return 1;case 2:return 2;case 4:return 4;case 8:return 8;case 16:return 16;case 32:return 32;case 64:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:return t&4194240;case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:return t&130023424;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 1073741824;default:return t}}function ny(t,s){var n=t.pendingLanes;if(n===0)return 0;var a=0,r=t.suspendedLanes,i=t.pingedLanes,o=n&268435455;if(o!==0){var l=o&~r;l!==0?a=eh(l):(i&=o,i!==0&&(a=eh(i)))}else o=n&~r,o!==0?a=eh(o):i!==0&&(a=eh(i));if(a===0)return 0;if(s!==0&&s!==a&&!(s&r)&&(r=a&-a,i=s&-s,r>=i||r===16&&(i&4194240)!==0))return s;if(a&4&&(a|=n&16),s=t.entangledLanes,s!==0)for(t=t.entanglements,s&=a;0<s;)n=31-Kr(s),r=1<<n,a|=t[n],s&=~r;return a}function bL(t,s){switch(t){case 1:case 2:case 4:return s+250;case 8:case 16:case 32:case 64:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:return s+5e3;case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:return-1;case 134217728:case 268435456:case 536870912:case 1073741824:return-1;default:return-1}}function vL(t,s){for(var n=t.suspendedLanes,a=t.pingedLanes,r=t.expirationTimes,i=t.pendingLanes;0<i;){var o=31-Kr(i),l=1<<o,c=r[o];c===-1?(!(l&n)||l&a)&&(r[o]=bL(l,s)):c<=s&&(t.expiredLanes|=l),i&=~l}}function _w(t){return t=t.pendingLanes&-1073741825,t!==0?t:t&1073741824?1073741824:0}function x6(){var t=ff;return ff<<=1,!(ff&4194240)&&(ff=64),t}function P1(t){for(var s=[],n=0;31>n;n++)s.push(t);return s}function qx(t,s,n){t.pendingLanes|=s,s!==536870912&&(t.suspendedLanes=0,t.pingedLanes=0),t=t.eventTimes,s=31-Kr(s),t[s]=n}function jL(t,s){var n=t.pendingLanes&~s;t.pendingLanes=s,t.suspendedLanes=0,t.pingedLanes=0,t.expiredLanes&=s,t.mutableReadLanes&=s,t.entangledLanes&=s,s=t.entanglements;var a=t.eventTimes;for(t=t.expirationTimes;0<n;){var r=31-Kr(n),i=1<<r;s[r]=0,a[r]=-1,t[r]=-1,n&=~i}}function s_(t,s){var n=t.entangledLanes|=s;for(t=t.entanglements;n;){var a=31-Kr(n),r=1<<a;r&s|t[a]&s&&(t[a]|=s),n&=~r}}var Zt=0;function f6(t){return t&=-t,1<t?4<t?t&268435455?16:536870912:4:1}var g6,n_,y6,b6,v6,kw=!1,yf=[],Pl=null,Dl=null,Rl=null,Hh=new Map,Gh=new Map,gl=[],wL="mousedown mouseup touchcancel touchend touchstart auxclick dblclick pointercancel pointerdown pointerup dragend dragstart drop compositionend compositionstart keydown keypress keyup input textInput copy cut paste click change contextmenu reset submit".split(" ");function Mk(t,s){switch(t){case"focusin":case"focusout":Pl=null;break;case"dragenter":case"dragleave":Dl=null;break;case"mouseover":case"mouseout":Rl=null;break;case"pointerover":case"pointerout":Hh.delete(s.pointerId);break;case"gotpointercapture":case"lostpointercapture":Gh.delete(s.pointerId)}}function mp(t,s,n,a,r,i){return t===null||t.nativeEvent!==i?(t={blockedOn:s,domEventName:n,eventSystemFlags:a,nativeEvent:i,targetContainers:[r]},s!==null&&(s=Hx(s),s!==null&&n_(s)),t):(t.eventSystemFlags|=a,s=t.targetContainers,r!==null&&s.indexOf(r)===-1&&s.push(r),t)}function NL(t,s,n,a,r){switch(s){case"focusin":return Pl=mp(Pl,t,s,n,a,r),!0;case"dragenter":return Dl=mp(Dl,t,s,n,a,r),!0;case"mouseover":return Rl=mp(Rl,t,s,n,a,r),!0;case"pointerover":var i=r.pointerId;return Hh.set(i,mp(Hh.get(i)||null,t,s,n,a,r)),!0;case"gotpointercapture":return i=r.pointerId,Gh.set(i,mp(Gh.get(i)||null,t,s,n,a,r)),!0}return!1}function j6(t){var s=ed(t.target);if(s!==null){var n=Ld(s);if(n!==null){if(s=n.tag,s===13){if(s=c6(n),s!==null){t.blockedOn=s,v6(t.priority,function(){y6(n)});return}}else if(s===3&&n.stateNode.current.memoizedState.isDehydrated){t.blockedOn=n.tag===3?n.stateNode.containerInfo:null;return}}}t.blockedOn=null}function Qg(t){if(t.blockedOn!==null)return!1;for(var s=t.targetContainers;0<s.length;){var n=Sw(t.domEventName,t.eventSystemFlags,s[0],t.nativeEvent);if(n===null){n=t.nativeEvent;var a=new n.constructor(n.type,n);vw=a,n.target.dispatchEvent(a),vw=null}else return s=Hx(n),s!==null&&n_(s),t.blockedOn=n,!1;s.shift()}return!0}function Bk(t,s,n){Qg(t)&&n.delete(s)}function _L(){kw=!1,Pl!==null&&Qg(Pl)&&(Pl=null),Dl!==null&&Qg(Dl)&&(Dl=null),Rl!==null&&Qg(Rl)&&(Rl=null),Hh.forEac
vendor: 11,603 bytes, line 38
38h(Bk),Gh.forEach(Bk)}function pp(t,s){t.blockedOn===s&&(t.blockedOn=null,kw||(kw=!0,Ba.unstable_scheduleCallback(Ba.unstable_NormalPriority,_L)))}function Vh(t){function s(r){return pp(r,t)}if(0<yf.length){pp(yf[0],t);for(var n=1;n<yf.length;n++){var a=yf[n];a.blockedOn===t&&(a.blockedOn=null)}}for(Pl!==null&&pp(Pl,t),Dl!==null&&pp(Dl,t),Rl!==null&&pp(Rl,t),Hh.forEach(s),Gh.forEach(s),n=0;n<gl.length;n++)a=gl[n],a.blockedOn===t&&(a.blockedOn=null);for(;0<gl.length&&(n=gl[0],n.blockedOn===null);)j6(n),n.blockedOn===null&&gl.shift()}var Qu=Mo.ReactCurrentBatchConfig,ay=!0;function kL(t,s,n,a){var r=Zt,i=Qu.transition;Qu.transition=null;try{Zt=1,a_(t,s,n,a)}finally{Zt=r,Qu.transition=i}}function SL(t,s,n,a){var r=Zt,i=Qu.transition;Qu.transition=null;try{Zt=4,a_(t,s,n,a)}finally{Zt=r,Qu.transition=i}}function a_(t,s,n,a){if(ay){var r=Sw(t,s,n,a);if(r===null)U1(t,s,a,ry,n),Mk(t,a);else if(NL(r,t,s,n,a))a.stopPropagation();else if(Mk(t,a),s&4&&-1<wL.indexOf(t)){for(;r!==null;){var i=Hx(r);if(i!==null&&g6(i),i=Sw(t,s,n,a),i===null&&U1(t,s,a,ry,n),i===r)break;r=i}r!==null&&a.stopPropagation()}else U1(t,s,a,null,n)}}var ry=null;function Sw(t,s,n,a){if(ry=null,t=e_(a),t=ed(t),t!==null)if(s=Ld(t),s===null)t=null;else if(n=s.tag,n===13){if(t=c6(s),t!==null)return t;t=null}else if(n===3){if(s.stateNode.current.memoizedState.isDehydrated)return s.tag===3?s.stateNode.containerInfo:null;t=null}else s!==t&&(t=null);return ry=t,null}function w6(t){switch(t){case"cancel":case"click":case"close":case"contextmenu":case"copy":case"cut":case"auxclick":case"dblclick":case"dragend":case"dragstart":case"drop":case"focusin":case"focusout":case"input":case"invalid":case"keydown":case"keypress":case"keyup":case"mousedown":case"mouseup":case"paste":case"pause":case"play":case"pointercancel":case"pointerdown":case"pointerup":case"ratechange":case"reset":case"resize":case"seeked":case"submit":case"touchcancel":case"touchend":case"touchstart":case"volumechange":case"change":case"selectionchange":case"textInput":case"compositionstart":case"compositionend":case"compositionupdate":case"beforeblur":case"afterblur":case"beforeinput":case"blur":case"fullscreenchange":case"focus":case"hashchange":case"popstate":case"select":case"selectstart":return 1;case"drag":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"mousemove":case"mouseout":case"mouseover":case"pointermove":case"pointerout":case"pointerover":case"scroll":case"toggle":case"touchmove":case"wheel":case"mouseenter":case"mouseleave":case"pointerenter":case"pointerleave":return 4;case"message":switch(pL()){case t_:return 1;case p6:return 4;case sy:case hL:return 16;case h6:return 536870912;default:return 16}default:return 16}}var Al=null,r_=null,Jg=null;function N6(){if(Jg)return Jg;var t,s=r_,n=s.length,a,r="value"in Al?Al.value:Al.textContent,i=r.length;for(t=0;t<n&&s[t]===r[t];t++);var o=n-t;for(a=1;a<=o&&s[n-a]===r[i-a];a++);return Jg=r.slice(t,1<a?1-a:void 0)}function Xg(t){var s=t.keyCode;return"charCode"in t?(t=t.charCode,t===0&&s===13&&(t=13)):t=s,t===10&&(t=13),32<=t||t===13?t:0}function bf(){return!0}function Uk(){return!1}function Ga(t){function s(n,a,r,i,o){this._reactName=n,this._targetInst=r,this.type=a,this.nativeEvent=i,this.target=o,this.currentTarget=null;for(var l in t)t.hasOwnProperty(l)&&(n=t[l],this[l]=n?n(i):i[l]);return this.isDefaultPrevented=(i.defaultPrevented!=null?i.defaultPrevented:i.returnValue===!1)?bf:Uk,this.isPropagationStopped=Uk,this}return js(s.prototype,{preventDefault:function(){this.defaultPrevented=!0;var n=this.nativeEvent;n&&(n.preventDefault?n.preventDefault():typeof n.returnValue!="unknown"&&(n.returnValue=!1),this.isDefaultPrevented=bf)},stopPropagation:function(){var n=this.nativeEvent;n&&(n.stopPropagation?n.stopPropagation():typeof n.cancelBubble!="unknown"&&(n.cancelBubble=!0),this.isPropagationStopped=bf)},persist:function(){},isPersistent:bf}),s}var Wm={eventPhase:0,bubbles:0,cancelable:0,timeStamp:function(t){return t.timeStamp||Date.now()},defaultPrevented:0,isTrusted:0},i_=Ga(Wm),Wx=js({},Wm,{view:0,detail:0}),CL=Ga(Wx),D1,R1,hp,gb=js({},Wx,{screenX:0,screenY:0,clientX:0,clientY:0,pageX:0,pageY:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,getModifierState:o_,button:0,buttons:0,relatedTarget:function(t){return t.relatedTarget===void 0?t.fromElement===t.srcElement?t.toElement:t.fromElement:t.relatedTarget},movementX:function(t){return"movementX"in t?t.movementX:(t!==hp&&(hp&&t.type==="mousemove"?(D1=t.screenX-hp.screenX,R1=t.screenY-hp.screenY):R1=D1=0,hp=t),D1)},movementY:function(t){return"movementY"in t?t.movementY:R1}}),qk=Ga(gb),AL=js({},gb,{dataTransfer:0}),EL=Ga(AL),FL=js({},Wx,{relatedTarget:0}),I1=Ga(FL),TL=js({},Wm,{animationName:0,elapsedTime:0,pseudoElement:0}),PL=Ga(TL),DL=js({},Wm,{clipboardData:function(t){return"clipboardData"in t?t.clipboardData:window.clipboardData}}),RL=Ga(DL),IL=js({},Wm,{data:0}),Wk=Ga(IL),$L={Esc:"Escape",Spacebar:" ",Left:"ArrowLeft",Up:"ArrowUp",Right:"ArrowRight",Down:"ArrowDown",Del:"Delete",Win:"OS",Menu:"ContextMenu",Apps:"ContextMenu",Scroll:"ScrollLock",MozPrintableKey:"Unidentified"},zL={8:"Backspace",9:"Tab",12:"Clear",13:"Enter",16:"Shift",17:"Control",18:"Alt",19:"Pause",20:"CapsLock",27:"Escape",32:" ",33:"PageUp",34:"PageDown",35:"End",36:"Home",37:"ArrowLeft",38:"ArrowUp",39:"ArrowRight",40:"ArrowDown",45:"Insert",46:"Delete",112:"F1",113:"F2",114:"F3",115:"F4",116:"F5",117:"F6",118:"F7",119:"F8",120:"F9",121:"F10",122:"F11",123:"F12",144:"NumLock",145:"ScrollLock",224:"Meta"},LL={Alt:"altKey",Control:"ctrlKey",Meta:"metaKey",Shift:"shiftKey"};function OL(t){var s=this.nativeEvent;return s.getModifierState?s.getModifierState(t):(t=LL[t])?!!s[t]:!1}function o_(){return OL}var ML=js({},Wx,{key:function(t){if(t.key){var s=$L[t.key]||t.key;if(s!=="Unidentified")return s}return t.type==="keypress"?(t=Xg(t),t===13?"Enter":String.fromCharCode(t)):t.type==="keydown"||t.type==="keyup"?zL[t.keyCode]||"Unidentified":""},code:0,location:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,repeat:0,locale:0,getModifierState:o_,charCode:function(t){return t.type==="keypress"?Xg(t):0},keyCode:function(t){return t.type==="keydown"||t.type==="keyup"?t.keyCode:0},which:function(t){return t.type==="keypress"?Xg(t):t.type==="keydown"||t.type==="keyup"?t.keyCode:0}}),BL=Ga(ML),UL=js({},gb,{pointerId:0,width:0,height:0,pressure:0,tangentialPressure:0,tiltX:0,tiltY:0,twist:0,pointerType:0,isPrimary:0}),Hk=Ga(UL),qL=js({},Wx,{touches:0,targetTouches:0,changedTouches:0,altKey:0,metaKey:0,ctrlKey:0,shiftKey:0,getModifierState:o_}),WL=Ga(qL),HL=js({},Wm,{propertyName:0,elapsedTime:0,pseudoElement:0}),GL=Ga(HL),VL=js({},gb,{deltaX:function(t){return"deltaX"in t?t.deltaX:"wheelDeltaX"in t?-t.wheelDeltaX:0},deltaY:function(t){return"deltaY"in t?t.deltaY:"wheelDeltaY"in t?-t.wheelDeltaY:"wheelDelta"in t?-t.wheelDelta:0},deltaZ:0,deltaMode:0}),ZL=Ga(VL),YL=[9,13,27,32],l_=So&&"CompositionEvent"in window,vh=null;So&&"documentMode"in document&&(vh=document.documentMode);var KL=So&&"TextEvent"in window&&!vh,_6=So&&(!l_||vh&&8<vh&&11>=vh),Gk=" ",Vk=!1;function k6(t,s){switch(t){case"keyup":return YL.indexOf(s.keyCode)!==-1;case"keydown":return s.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function S6(t){return t=t.detail,typeof t=="object"&&"data"in t?t.data:null}var Tu=!1;function QL(t,s){switch(t){case"compositionend":return S6(s);case"keypress":return s.which!==32?null:(Vk=!0,Gk);case"textInput":return t=s.data,t===Gk&&Vk?null:t;default:return null}}function JL(t,s){if(Tu)return t==="compositionend"||!l_&&k6(t,s)?(t=N6(),Jg=r_=Al=null,Tu=!1,t):null;switch(t){case"paste":return null;case"keypress":if(!(s.ctrlKey||s.altKey||s.metaKey)||s.ctrlKey&&s.altKey){if(s.char&&1<s.char.length)return s.char;if(s.which)return String.fromCharCode(s.which)}return null;case"compositionend":return _6&&s.locale!=="ko"?null:s.data;default:return null}}var XL={color:!0,date:!0,datetime:!0,"datetime-local":!0,email:!0,month:!0,number:!0,password:!0,range:!0,search:!0,tel:!0,text:!0,time:!0,url:!0,week:!0};function Zk(t){var s=t&&t.nodeName&&t.nodeName.toLowerCase();return s==="input"?!!XL[t.type]:s==="textarea"}function C6(t,s,n,a){a6(a),s=iy(s,"onChange"),0<s.length&&(n=new i_("onChange","change",null,n,a),t.push({event:n,listeners:s}))}var jh=null,Zh=null;function e7(t){L6(t,0)}function yb(t){var s=Ru(t);if(QF(s))return t}function t7(t,s){if(t==="change")return s}var A6=!1;if(So){var $1;if(So){var z1="oninput"in document;if(!z1){var Yk=document.createElement("div");Yk.setAttribute("oninput","return;"),z1=typeof Yk.oninput=="function"}$1=z1}else $1=!1;A6=$1&&(!document.documentMode||9<document.documentMode)}function Kk(){jh&&(jh.detachEvent("onpropertychange",E6),Zh=jh=null)}function E6(t){if(t.propertyName==="value"&&yb(Zh)){var s=[];C6(s,Zh,t,e_(t)),l6(e7,s)}}function s7(t,s,n){t==="focusin"?(Kk(),jh=s,Zh=n,jh.attachEvent("onpropertychange",E6)):t==="focusout"&&Kk()}function n7(t){if(t==="selectionchange"||t==="keyup"||t==="keydown")return yb(Zh)}function a7(t,s){if(t==="click")return yb(s)}function r7(t,s){if(t==="input"||t==="change")return yb(s)}function i7(t,s){return t===s&&(t!==0||1/t===1/s)||t!==t&&s!==s}var Xr=typeof Object.is=="function"?Object.is:i7;function Yh(t,s){if(Xr(t,s))return!0;if(typeof t!="object"||t===null||typeof s!="object"||s===null)return!1;var n=Object.keys(t),a=Object.keys(s);if(n.length!==a.length)return!1;for(a=0;a<n.length;a++){var r=n[a];if(!lw.call(s,r)||!Xr(t[r],s[r]))return!1}return!0}function Qk(t){for(;t&&t.firstChild;)t=t.firstChild;return t}function Jk(t,s){var n=Qk(t);t=0;for(var a;n;){if(n.nodeType===3){if(a=t+n.textContent.length,t<=s&&a>=s)return{node:n,offset:s-t};t=a}e:{for(;n;){if(n.nextSibling){n=n.nextSibling;break e}n=n.parentNode}n=void 0}n=Qk(n)}}function F6(t,s){return t&&s?t===s?!0:t&&t.nodeType===3?!1:s&&s.nodeType===3?F6(t,s.parentNode):"contains"in t?t.contains(s):t.compareDocumentPosition?!!(t.compareDocumentPosition(s)&16):!1:!1}function T6(){for(var t=window,s=X0();s instanceof t.HTMLIFrameElement;){try{var n=typeof s.contentWindow.location.href=="string"}catch{n=!1}if(n)t=s.contentWindow;else break;s=X0(t.document)}return s}function c_(t){var s=t&&t.nodeName&&t.nodeName.toLowerCase();return s&&(s==="input"&&(t.type==="text"||t.type==="search"||t.type==="tel"||t.type==="url"||t.type==="password")||s==="textarea"||t.contentEditable==="true")}function o7(t){var s=T6(),n=t.focusedElem,a=t.selectionRange;if(s!==n&&n&&n.ownerDocument&&F6(n.ownerDocument.documentElement,n)){if(a!==null&&c_(n)){if(s=a.start,t=a.end,t===void 0&&(t=s),"selectionStart"in n)n.selectionStart=s,n.selectionEnd=Math.min(t,n.value.length);else if(t=(s=n.ownerDocument||document)&&s.defaultView||window,t.getSelection){t=t.getSelection();var r=n.textContent.length,i=Math.min(a.start,r);a=a.end===void 0?i:Math.min(a.end,r),!t.extend&&i>a&&(r=a,a=i,i=r),r=Jk(n,i);var o=Jk(n,a);r&&o&&(t.rangeCount!==1||t.anchorNode!==r.node||t.anchorOffset!==r.offset||t.focusNode!==o.node||t.focusOffset!==o.offset)&&(s=s.createRange(),s.setStart(r.node,r.offset),t.removeAllRanges(),i>a?(t.addRange(s),t.extend(o.node,o.offset)):(s.setEnd(o.node,o.offset),t.addRange(s)))}}for(s=[],t=n;t=t.parentNode;)t.nodeType===1&&s.push({element:t,left:t.scrollLeft,top:t.scrollTop});for(typeof n.focus=="function"&&n.focus(),n=0;n<s.length;n++)t=s[n],t.element.scrollLeft=t.left,t.element.scrollTop=t.top}}var l7=So&&"documentMode"in document&&11>=document.documentMode,Pu=null,Cw=null,wh=null,Aw=!1;function Xk(t,s,n){var a=n.window===n?n.document:n.nodeType===9?n:n.ownerDocument;
vendor: 4,739 bytes, line 38
38Aw||Pu==null||Pu!==X0(a)||(a=Pu,"selectionStart"in a&&c_(a)?a={start:a.selectionStart,end:a.selectionEnd}:(a=(a.ownerDocument&&a.ownerDocument.defaultView||window).getSelection(),a={anchorNode:a.anchorNode,anchorOffset:a.anchorOffset,focusNode:a.focusNode,focusOffset:a.focusOffset}),wh&&Yh(wh,a)||(wh=a,a=iy(Cw,"onSelect"),0<a.length&&(s=new i_("onSelect","select",null,s,n),t.push({event:s,listeners:a}),s.target=Pu)))}function vf(t,s){var n={};return n[t.toLowerCase()]=s.toLowerCase(),n["Webkit"+t]="webkit"+s,n["Moz"+t]="moz"+s,n}var Du={animationend:vf("Animation","AnimationEnd"),animationiteration:vf("Animation","AnimationIteration"),animationstart:vf("Animation","AnimationStart"),transitionend:vf("Transition","TransitionEnd")},L1={},P6={};So&&(P6=document.createElement("div").style,"AnimationEvent"in window||(delete Du.animationend.animation,delete Du.animationiteration.animation,delete Du.animationstart.animation),"TransitionEvent"in window||delete Du.transitionend.transition);function bb(t){if(L1[t])return L1[t];if(!Du[t])return t;var s=Du[t],n;for(n in s)if(s.hasOwnProperty(n)&&n in P6)return L1[t]=s[n];return t}var D6=bb("animationend"),R6=bb("animationiteration"),I6=bb("animationstart"),$6=bb("transitionend"),z6=new Map,eS="abort auxClick cancel canPlay canPlayThrough click close contextMenu copy cut drag dragEnd dragEnter dragExit dragLeave dragOver dragStart drop durationChange emptied encrypted ended error gotPointerCapture input invalid keyDown keyPress keyUp load loadedData loadedMetadata loadStart lostPointerCapture mouseDown mouseMove mouseOut mouseOver mouseUp paste pause play playing pointerCancel pointerDown pointerMove pointerOut pointerOver pointerUp progress rateChange reset resize seeked seeking stalled submit suspend timeUpdate touchCancel touchEnd touchStart volumeChange scroll toggle touchMove waiting wheel".split(" ");function sc(t,s){z6.set(t,s),zd(s,[t])}for(var O1=0;O1<eS.length;O1++){var M1=eS[O1],c7=M1.toLowerCase(),d7=M1[0].toUpperCase()+M1.slice(1);sc(c7,"on"+d7)}sc(D6,"onAnimationEnd");sc(R6,"onAnimationIteration");sc(I6,"onAnimationStart");sc("dblclick","onDoubleClick");sc("focusin","onFocus");sc("focusout","onBlur");sc($6,"onTransitionEnd");_m("onMouseEnter",["mouseout","mouseover"]);_m("onMouseLeave",["mouseout","mouseover"]);_m("onPointerEnter",["pointerout","pointerover"]);_m("onPointerLeave",["pointerout","pointerover"]);zd("onChange","change click focusin focusout input keydown keyup selectionchange".split(" "));zd("onSelect","focusout contextmenu dragend focusin keydown keyup mousedown mouseup selectionchange".split(" "));zd("onBeforeInput",["compositionend","keypress","textInput","paste"]);zd("onCompositionEnd","compositionend focusout keydown keypress keyup mousedown".split(" "));zd("onCompositionStart","compositionstart focusout keydown keypress keyup mousedown".split(" "));zd("onCompositionUpdate","compositionupdate focusout keydown keypress keyup mousedown".split(" "));var th="abort canplay canplaythrough durationchange emptied encrypted ended error loadeddata loadedmetadata loadstart pause play playing progress ratechange resize seeked seeking stalled suspend timeupdate volumechange waiting".split(" "),u7=new Set("cancel close invalid load scroll toggle".split(" ").concat(th));function tS(t,s,n){var a=t.type||"unknown-event";t.currentTarget=n,cL(a,s,void 0,t),t.currentTarget=null}function L6(t,s){s=(s&4)!==0;for(var n=0;n<t.length;n++){var a=t[n],r=a.event;a=a.listeners;e:{var i=void 0;if(s)for(var o=a.length-1;0<=o;o--){var l=a[o],c=l.instance,u=l.currentTarget;if(l=l.listener,c!==i&&r.isPropagationStopped())break e;tS(r,l,u),i=c}else for(o=0;o<a.length;o++){if(l=a[o],c=l.instance,u=l.currentTarget,l=l.listener,c!==i&&r.isPropagationStopped())break e;tS(r,l,u),i=c}}}if(ty)throw t=Nw,ty=!1,Nw=null,t}function is(t,s){var n=s[Dw];n===void 0&&(n=s[Dw]=new Set);var a=t+"__bubble";n.has(a)||(O6(s,t,2,!1),n.add(a))}function B1(t,s,n){var a=0;s&&(a|=4),O6(n,t,a,s)}var jf="_reactListening"+Math.random().toString(36).slice(2);function Kh(t){if(!t[jf]){t[jf]=!0,GF.forEach(function(n){n!=="selectionchange"&&(u7.has(n)||B1(n,!1,t),B1(n,!0,t))});var s=t.nodeType===9?t:t.ownerDocument;s===null||s[jf]||(s[jf]=!0,B1("selectionchange",!1,s))}}function O6(t,s,n,a){switch(w6(s)){case 1:var r=kL;break;case 4:r=SL;break;default:r=a_}n=r.bind(null,s,n,t),r=void 0,!ww||s!=="touchstart"&&s!=="touchmove"&&s!=="wheel"||(r=!0),a?r!==void 0?t.addEventListener(s,n,{capture:!0,passive:r}):t.addEventListener(s,n,!0):r!==void 0?t.addEventListener(s,n,{passive:r}):t.addEventListener(s,n,!1)}function U1(t,s,n,a,r){var i=a;if(!(s&1)&&!(s&2)&&a!==null)e:for(;;){if(a===null)return;var o=a.tag;if(o===3||o===4){var l=a.stateNode.containerInfo;
vendor: 5,317 bytes, lines 38-39
38if(l===r||l.nodeType===8&&l.parentNode===r)break;if(o===4)for(o=a.return;o!==null;){var c=o.tag;if((c===3||c===4)&&(c=o.stateNode.containerInfo,c===r||c.nodeType===8&&c.parentNode===r))return;o=o.return}for(;l!==null;){if(o=ed(l),o===null)return;if(c=o.tag,c===5||c===6){a=i=o;continue e}l=l.parentNode}}a=a.return}l6(function(){var u=i,p=e_(n),m=[];e:{var x=z6.get(t);if(x!==void 0){var h=i_,y=t;switch(t){case"keypress":if(Xg(n)===0)break e;case"keydown":case"keyup":h=BL;break;case"focusin":y="focus",h=I1;break;case"focusout":y="blur",h=I1;break;case"beforeblur":case"afterblur":h=I1;break;case"click":if(n.button===2)break e;case"auxclick":case"dblclick":case"mousedown":case"mousemove":case"mouseup":case"mouseout":case"mouseover":case"contextmenu":h=qk;break;case"drag":case"dragend":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"dragstart":case"drop":h=EL;break;case"touchcancel":case"touchend":case"touchmove":case"touchstart":h=WL;break;case D6:case R6:case I6:h=PL;break;case $6:h=GL;break;case"scroll":h=CL;break;case"wheel":h=ZL;break;case"copy":case"cut":case"paste":h=RL;break;case"gotpointercapture":case"lostpointercapture":case"pointercancel":case"pointerdown":case"pointermove":case"pointerout":case"pointerover":case"pointerup":h=Hk}var v=(s&4)!==0,g=!v&&t==="scroll",N=v?x!==null?x+"Capture":null:x;v=[];for(var b=u,f;b!==null;){f=b;var j=f.stateNode;if(f.tag===5&&j!==null&&(f=j,N!==null&&(j=Wh(b,N),j!=null&&v.push(Qh(b,j,f)))),g)break;b=b.return}0<v.length&&(x=new h(x,y,null,n,p),m.push({event:x,listeners:v}))}}if(!(s&7)){e:{if(x=t==="mouseover"||t==="pointerover",h=t==="mouseout"||t==="pointerout",x&&n!==vw&&(y=n.relatedTarget||n.fromElement)&&(ed(y)||y[Co]))break e;if((h||x)&&(x=p.window===p?p:(x=p.ownerDocument)?x.defaultView||x.parentWindow:window,h?(y=n.relatedTarget||n.toElement,h=u,y=y?ed(y):null,y!==null&&(g=Ld(y),y!==g||y.tag!==5&&y.tag!==6)&&(y=null)):(h=null,y=u),h!==y)){if(v=qk,j="onMouseLeave",N="onMouseEnter",b="mouse",(t==="pointerout"||t==="pointerover")&&(v=Hk,j="onPointerLeave",N="onPointerEnter",b="pointer"),g=h==null?x:Ru(h),f=y==null?x:Ru(y),x=new v(j,b+"leave",h,n,p),x.target=g,x.relatedTarget=f,j=null,ed(p)===u&&(v=new v(N,b+"enter",y,n,p),v.target=f,v.relatedTarget=g,j=v),g=j,h&&y)t:{for(v=h,N=y,b=0,f=v;f;f=Gd(f))b++;for(f=0,j=N;j;j=Gd(j))f++;for(;0<b-f;)v=Gd(v),b--;for(;0<f-b;)N=Gd(N),f--;for(;b--;){if(v===N||N!==null&&v===N.alternate)break t;v=Gd(v),N=Gd(N)}v=null}else v=null;h!==null&&sS(m,x,h,v,!1),y!==null&&g!==null&&sS(m,g,y,v,!0)}}e:{if(x=u?Ru(u):window,h=x.nodeName&&x.nodeName.toLowerCase(),h==="select"||h==="input"&&x.type==="file")var S=t7;else if(Zk(x))if(A6)S=r7;else{S=n7;var w=s7}else(h=x.nodeName)&&h.toLowerCase()==="input"&&(x.type==="checkbox"||x.type==="radio")&&(S=a7);if(S&&(S=S(t,u))){C6(m,S,n,p);break e}w&&w(t,x,u),t==="focusout"&&(w=x._wrapperState)&&w.controlled&&x.type==="number"&&xw(x,"number",x.value)}switch(w=u?Ru(u):window,t){case"focusin":(Zk(w)||w.contentEditable==="true")&&(Pu=w,Cw=u,wh=null);break;case"focusout":wh=Cw=Pu=null;break;case"mousedown":Aw=!0;break;case"contextmenu":case"mouseup":case"dragend":Aw=!1,Xk(m,n,p);break;case"selectionchange":if(l7)break;case"keydown":case"keyup":Xk(m,n,p)}var _;if(l_)e:{switch(t){case"compositionstart":var C="onCompositionStart";break e;case"compositionend":C="onCompositionEnd";break e;case"compositionupdate":C="onCompositionUpdate";break e}C=void 0}else Tu?k6(t,n)&&(C="onCompositionEnd"):t==="keydown"&&n.keyCode===229&&(C="onCompositionStart");C&&(_6&&n.locale!=="ko"&&(Tu||C!=="onCompositionStart"?C==="onCompositionEnd"&&Tu&&(_=N6()):(Al=p,r_="value"in Al?Al.value:Al.textContent,Tu=!0)),w=iy(u,C),0<w.length&&(C=new Wk(C,t,null,n,p),m.push({event:C,listeners:w}),_?C.data=_:(_=S6(n),_!==null&&(C.data=_)))),(_=KL?QL(t,n):JL(t,n))&&(u=iy(u,"onBeforeInput"),0<u.length&&(p=new Wk("onBeforeInput","beforeinput",null,n,p),m.push({event:p,listeners:u}),p.data=_))}L6(m,s)})}function Qh(t,s,n){return{instance:t,listener:s,currentTarget:n}}function iy(t,s){for(var n=s+"Capture",a=[];t!==null;){var r=t,i=r.stateNode;r.tag===5&&i!==null&&(r=i,i=Wh(t,n),i!=null&&a.unshift(Qh(t,i,r)),i=Wh(t,s),i!=null&&a.push(Qh(t,i,r))),t=t.return}return a}function Gd(t){if(t===null)return null;do t=t.return;while(t&&t.tag!==5);return t||null}function sS(t,s,n,a,r){for(var i=s._reactName,o=[];n!==null&&n!==a;){var l=n,c=l.alternate,u=l.stateNode;if(c!==null&&c===a)break;l.tag===5&&u!==null&&(l=u,r?(c=Wh(n,i),c!=null&&o.unshift(Qh(n,c,l))):r||(c=Wh(n,i),c!=null&&o.push(Qh(n,c,l)))),n=n.return}o.length!==0&&t.push({event:s,listeners:o})}var m7=/\r\n?/g,p7=/\u0000|\uFFFD/g;function nS(t){return(typeof t=="string"?t:""+t).replace(m7,` 39`).replace(p7,"")}function wf(t,s,n){if(s=nS(s),nS(t)!==s&&n)throw Error(Ae(425))}function oy(){}var Ew=null,Fw=null;function Tw(t,s){return t==="textarea"||t==="noscript"||typeof s.children=="string"||typeof s.children=="number"||typeof s.dangerouslySetInnerHTML=="object"&&s.dangerouslySetInnerHTML!==null&&s.dangerouslySetInnerHTML.__html!=null}var Pw=typeof setTimeout=="function"?setTimeout:void 0,h7=typeof clearTimeout=="function"?clearTimeout:void 0,aS=typeof Promise=="function"?Promise:void 0,x7=typeof queueMicrotask=="function"?queueMicrotask:typeof aS<"u"?function(t){return aS.resolve(null).then(t).cat
vendor: 4,167 bytes, line 39
39ch(f7)}:Pw;function f7(t){setTimeout(function(){throw t})}function q1(t,s){var n=s,a=0;do{var r=n.nextSibling;if(t.removeChild(n),r&&r.nodeType===8)if(n=r.data,n==="/$"){if(a===0){t.removeChild(r),Vh(s);return}a--}else n!=="$"&&n!=="$?"&&n!=="$!"||a++;n=r}while(n);Vh(s)}function Il(t){for(;t!=null;t=t.nextSibling){var s=t.nodeType;if(s===1||s===3)break;if(s===8){if(s=t.data,s==="$"||s==="$!"||s==="$?")break;if(s==="/$")return null}}return t}function rS(t){t=t.previousSibling;for(var s=0;t;){if(t.nodeType===8){var n=t.data;if(n==="$"||n==="$!"||n==="$?"){if(s===0)return t;s--}else n==="/$"&&s++}t=t.previousSibling}return null}var Hm=Math.random().toString(36).slice(2),Si="__reactFiber$"+Hm,Jh="__reactProps$"+Hm,Co="__reactContainer$"+Hm,Dw="__reactEvents$"+Hm,g7="__reactListeners$"+Hm,y7="__reactHandles$"+Hm;function ed(t){var s=t[Si];if(s)return s;for(var n=t.parentNode;n;){if(s=n[Co]||n[Si]){if(n=s.alternate,s.child!==null||n!==null&&n.child!==null)for(t=rS(t);t!==null;){if(n=t[Si])return n;t=rS(t)}return s}t=n,n=t.parentNode}return null}function Hx(t){return t=t[Si]||t[Co],!t||t.tag!==5&&t.tag!==6&&t.tag!==13&&t.tag!==3?null:t}function Ru(t){if(t.tag===5||t.tag===6)return t.stateNode;throw Error(Ae(33))}function vb(t){return t[Jh]||null}var Rw=[],Iu=-1;function nc(t){return{current:t}}function ds(t){0>Iu||(t.current=Rw[Iu],Rw[Iu]=null,Iu--)}function ns(t,s){Iu++,Rw[Iu]=t.current,t.current=s}var Hl={},Mn=nc(Hl),ga=nc(!1),yd=Hl;function km(t,s){var n=t.type.contextTypes;if(!n)return Hl;var a=t.stateNode;if(a&&a.__reactInternalMemoizedUnmaskedChildContext===s)return a.__reactInternalMemoizedMaskedChildContext;var r={},i;for(i in n)r[i]=s[i];return a&&(t=t.stateNode,t.__reactInternalMemoizedUnmaskedChildContext=s,t.__reactInternalMemoizedMaskedChildContext=r),r}function ya(t){return t=t.childContextTypes,t!=null}function ly(){ds(ga),ds(Mn)}function iS(t,s,n){if(Mn.current!==Hl)throw Error(Ae(168));ns(Mn,s),ns(ga,n)}function M6(t,s,n){var a=t.stateNode;if(s=s.childContextTypes,typeof a.getChildContext!="function")return n;a=a.getChildContext();for(var r in a)if(!(r in s))throw Error(Ae(108,sL(t)||"Unknown",r));return js({},n,a)}function cy(t){return t=(t=t.stateNode)&&t.__reactInternalMemoizedMergedChildContext||Hl,yd=Mn.current,ns(Mn,t),ns(ga,ga.current),!0}function oS(t,s,n){var a=t.stateNode;if(!a)throw Error(Ae(169));n?(t=M6(t,s,yd),a.__reactInternalMemoizedMergedChildContext=t,ds(ga),ds(Mn),ns(Mn,t)):ds(ga),ns(ga,n)}var mo=null,jb=!1,W1=!1;function B6(t){mo===null?mo=[t]:mo.push(t)}function b7(t){jb=!0,B6(t)}function ac(){if(!W1&&mo!==null){W1=!0;var t=0,s=Zt;try{var n=mo;for(Zt=1;t<n.length;t++){var a=n[t];do a=a(!0);while(a!==null)}mo=null,jb=!1}catch(r){throw mo!==null&&(mo=mo.slice(t+1)),m6(t_,ac),r}finally{Zt=s,W1=!1}}return null}var $u=[],zu=0,dy=null,uy=0,mr=[],pr=0,bd=null,go=1,yo="";function Uc(t,s){$u[zu++]=uy,$u[zu++]=dy,dy=t,uy=s}function U6(t,s,n){mr[pr++]=go,mr[pr++]=yo,mr[pr++]=bd,bd=t;var a=go;t=yo;var r=32-Kr(a)-1;a&=~(1<<r),n+=1;var i=32-Kr(s)+r;if(30<i){var o=r-r%5;i=(a&(1<<o)-1).toString(32),a>>=o,r-=o,go=1<<32-Kr(s)+r|n<<r|a,yo=i+t}else go=1<<i|n<<r|a,yo=t}function d_(t){t.return!==null&&(Uc(t,1),U6(t,1,0))}function u_(t){for(;t===dy;)dy=$u[--zu],$u[zu]=null,uy=$u[--zu],$u[zu]=null;for(;t===bd;)bd=mr[--pr],mr[pr]=null,yo=mr[--pr],mr[pr]=null,go=mr[--pr],mr[pr]=null}var Oa=null,za=null,xs=!1,Gr=null;function q6(t,s){var n=fr(5,null,null,0);n.elementType="DELETED",n.stateNode=s,n.return=t,s=t.deletions,s===null?(t.deletions=[n],t.flags|=16):s.push(n)}function lS(t,s){switch(t.tag){case 5:var n=t.type;return s=s.nodeType!==1||n.toLowerCase()!==s.nodeName.toLowerCase()?null:s,s!==null?(t.stateNode=s,Oa=t,za=Il(s.firstChild),!0):!1;case 6:return s=t.pendingProps===""||s.nodeType!==3?null:s,s!==null?(t.stateNode=s,Oa=t,za=null,!0):!1;case 13:return s=s.nodeType!==8?null:s,s!==null?(n=bd!==null?{id:go,overflow:yo}:null,t.memoizedState={dehydrated:s,treeContext:n,retryLane:1073741824},n=fr(18,null,null,0),n.stateNode=s,n.return=t,t.child=n,Oa=t,za=null,!0):!1;default:return!1}}function Iw(t){return(t.mode&1)!==0&&(t.flags&128)===0}function $w(t){if(xs){var s=za;if(s){var n=s;
vendor: 12,054 bytes, line 39
39if(!lS(t,s)){if(Iw(t))throw Error(Ae(418));s=Il(n.nextSibling);var a=Oa;s&&lS(t,s)?q6(a,n):(t.flags=t.flags&-4097|2,xs=!1,Oa=t)}}else{if(Iw(t))throw Error(Ae(418));t.flags=t.flags&-4097|2,xs=!1,Oa=t}}}function cS(t){for(t=t.return;t!==null&&t.tag!==5&&t.tag!==3&&t.tag!==13;)t=t.return;Oa=t}function Nf(t){if(t!==Oa)return!1;if(!xs)return cS(t),xs=!0,!1;var s;if((s=t.tag!==3)&&!(s=t.tag!==5)&&(s=t.type,s=s!=="head"&&s!=="body"&&!Tw(t.type,t.memoizedProps)),s&&(s=za)){if(Iw(t))throw W6(),Error(Ae(418));for(;s;)q6(t,s),s=Il(s.nextSibling)}if(cS(t),t.tag===13){if(t=t.memoizedState,t=t!==null?t.dehydrated:null,!t)throw Error(Ae(317));e:{for(t=t.nextSibling,s=0;t;){if(t.nodeType===8){var n=t.data;if(n==="/$"){if(s===0){za=Il(t.nextSibling);break e}s--}else n!=="$"&&n!=="$!"&&n!=="$?"||s++}t=t.nextSibling}za=null}}else za=Oa?Il(t.stateNode.nextSibling):null;return!0}function W6(){for(var t=za;t;)t=Il(t.nextSibling)}function Sm(){za=Oa=null,xs=!1}function m_(t){Gr===null?Gr=[t]:Gr.push(t)}var v7=Mo.ReactCurrentBatchConfig;function xp(t,s,n){if(t=n.ref,t!==null&&typeof t!="function"&&typeof t!="object"){if(n._owner){if(n=n._owner,n){if(n.tag!==1)throw Error(Ae(309));var a=n.stateNode}if(!a)throw Error(Ae(147,t));var r=a,i=""+t;return s!==null&&s.ref!==null&&typeof s.ref=="function"&&s.ref._stringRef===i?s.ref:(s=function(o){var l=r.refs;o===null?delete l[i]:l[i]=o},s._stringRef=i,s)}if(typeof t!="string")throw Error(Ae(284));if(!n._owner)throw Error(Ae(290,t))}return t}function _f(t,s){throw t=Object.prototype.toString.call(s),Error(Ae(31,t==="[object Object]"?"object with keys {"+Object.keys(s).join(", ")+"}":t))}function dS(t){var s=t._init;return s(t._payload)}function H6(t){function s(N,b){if(t){var f=N.deletions;f===null?(N.deletions=[b],N.flags|=16):f.push(b)}}function n(N,b){if(!t)return null;for(;b!==null;)s(N,b),b=b.sibling;return null}function a(N,b){for(N=new Map;b!==null;)b.key!==null?N.set(b.key,b):N.set(b.index,b),b=b.sibling;return N}function r(N,b){return N=Ol(N,b),N.index=0,N.sibling=null,N}function i(N,b,f){return N.index=f,t?(f=N.alternate,f!==null?(f=f.index,f<b?(N.flags|=2,b):f):(N.flags|=2,b)):(N.flags|=1048576,b)}function o(N){return t&&N.alternate===null&&(N.flags|=2),N}function l(N,b,f,j){return b===null||b.tag!==6?(b=Q1(f,N.mode,j),b.return=N,b):(b=r(b,f),b.return=N,b)}function c(N,b,f,j){var S=f.type;return S===Fu?p(N,b,f.props.children,j,f.key):b!==null&&(b.elementType===S||typeof S=="object"&&S!==null&&S.$$typeof===xl&&dS(S)===b.type)?(j=r(b,f.props),j.ref=xp(N,b,f),j.return=N,j):(j=i0(f.type,f.key,f.props,null,N.mode,j),j.ref=xp(N,b,f),j.return=N,j)}function u(N,b,f,j){return b===null||b.tag!==4||b.stateNode.containerInfo!==f.containerInfo||b.stateNode.implementation!==f.implementation?(b=J1(f,N.mode,j),b.return=N,b):(b=r(b,f.children||[]),b.return=N,b)}function p(N,b,f,j,S){return b===null||b.tag!==7?(b=xd(f,N.mode,j,S),b.return=N,b):(b=r(b,f),b.return=N,b)}function m(N,b,f){if(typeof b=="string"&&b!==""||typeof b=="number")return b=Q1(""+b,N.mode,f),b.return=N,b;if(typeof b=="object"&&b!==null){switch(b.$$typeof){case pf:return f=i0(b.type,b.key,b.props,null,N.mode,f),f.ref=xp(N,null,b),f.return=N,f;case Eu:return b=J1(b,N.mode,f),b.return=N,b;case xl:var j=b._init;return m(N,j(b._payload),f)}if(Xp(b)||dp(b))return b=xd(b,N.mode,f,null),b.return=N,b;_f(N,b)}return null}function x(N,b,f,j){var S=b!==null?b.key:null;if(typeof f=="string"&&f!==""||typeof f=="number")return S!==null?null:l(N,b,""+f,j);if(typeof f=="object"&&f!==null){switch(f.$$typeof){case pf:return f.key===S?c(N,b,f,j):null;case Eu:return f.key===S?u(N,b,f,j):null;case xl:return S=f._init,x(N,b,S(f._payload),j)}if(Xp(f)||dp(f))return S!==null?null:p(N,b,f,j,null);_f(N,f)}return null}function h(N,b,f,j,S){if(typeof j=="string"&&j!==""||typeof j=="number")return N=N.get(f)||null,l(b,N,""+j,S);if(typeof j=="object"&&j!==null){switch(j.$$typeof){case pf:return N=N.get(j.key===null?f:j.key)||null,c(b,N,j,S);case Eu:return N=N.get(j.key===null?f:j.key)||null,u(b,N,j,S);case xl:var w=j._init;return h(N,b,f,w(j._payload),S)}if(Xp(j)||dp(j))return N=N.get(f)||null,p(b,N,j,S,null);_f(b,j)}return null}function y(N,b,f,j){for(var S=null,w=null,_=b,C=b=0,E=null;_!==null&&C<f.length;C++){_.index>C?(E=_,_=null):E=_.sibling;var P=x(N,_,f[C],j);if(P===null){_===null&&(_=E);break}t&&_&&P.alternate===null&&s(N,_),b=i(P,b,C),w===null?S=P:w.sibling=P,w=P,_=E}if(C===f.length)return n(N,_),xs&&Uc(N,C),S;if(_===null){for(;C<f.length;C++)_=m(N,f[C],j),_!==null&&(b=i(_,b,C),w===null?S=_:w.sibling=_,w=_);return xs&&Uc(N,C),S}for(_=a(N,_);C<f.length;C++)E=h(_,N,C,f[C],j),E!==null&&(t&&E.alternate!==null&&_.delete(E.key===null?C:E.key),b=i(E,b,C),w===null?S=E:w.sibling=E,w=E);return t&&_.forEach(function(F){return s(N,F)}),xs&&Uc(N,C),S}function v(N,b,f,j){var S=dp(f);if(typeof S!="function")throw Error(Ae(150));if(f=S.call(f),f==null)throw Error(Ae(151));for(var w=S=null,_=b,C=b=0,E=null,P=f.next();_!==null&&!P.done;C++,P=f.next()){_.index>C?(E=_,_=null):E=_.sibling;var F=x(N,_,P.value,j);if(F===null){_===null&&(_=E);break}t&&_&&F.alternate===null&&s(N,_),b=i(F,b,C),w===null?S=F:w.sibling=F,w=F,_=E}if(P.done)return n(N,_),xs&&Uc(N,C),S;if(_===null){for(;!P.done;C++,P=f.next())P=m(N,P.value,j),P!==null&&(b=i(P,b,C),w===null?S=P:w.sibling=P,w=P);return xs&&Uc(N,C),S}for(_=a(N,_);!P.done;C++,P=f.next())P=h(_,N,C,P.value,j),P!==null&&(t&&P.alternate!==null&&_.delete(P.key===null?C:P.key),b=i(P,b,C),w===null?S=P:w.sibling=P,w=P);return t&&_.forEach(function(I){return s(N,I)}),xs&&Uc(N,C),S}function g(N,b,f,j){if(typeof f=="object"&&f!==null&&f.type===Fu&&f.key===null&&(f=f.props.children),typeof f=="object"&&f!==null){switch(f.$$typeof){case pf:e:{for(var S=f.key,w=b;w!==null;){if(w.key===S){if(S=f.type,S===Fu){if(w.tag===7){n(N,w.sibling),b=r(w,f.props.children),b.return=N,N=b;break e}}else if(w.elementType===S||typeof S=="object"&&S!==null&&S.$$typeof===xl&&dS(S)===w.type){n(N,w.sibling),b=r(w,f.props),b.ref=xp(N,w,f),b.return=N,N=b;break e}n(N,w);break}else s(N,w);w=w.sibling}f.type===Fu?(b=xd(f.props.children,N.mode,j,f.key),b.return=N,N=b):(j=i0(f.type,f.key,f.props,null,N.mode,j),j.ref=xp(N,b,f),j.return=N,N=j)}return o(N);case Eu:e:{for(w=f.key;b!==null;){if(b.key===w)if(b.tag===4&&b.stateNode.containerInfo===f.containerInfo&&b.stateNode.implementation===f.implementation){n(N,b.sibling),b=r(b,f.children||[]),b.return=N,N=b;break e}else{n(N,b);break}else s(N,b);b=b.sibling}b=J1(f,N.mode,j),b.return=N,N=b}return o(N);case xl:return w=f._init,g(N,b,w(f._payload),j)}if(Xp(f))return y(N,b,f,j);if(dp(f))return v(N,b,f,j);_f(N,f)}return typeof f=="string"&&f!==""||typeof f=="number"?(f=""+f,b!==null&&b.tag===6?(n(N,b.sibling),b=r(b,f),b.return=N,N=b):(n(N,b),b=Q1(f,N.mode,j),b.return=N,N=b),o(N)):n(N,b)}return g}var Cm=H6(!0),G6=H6(!1),my=nc(null),py=null,Lu=null,p_=null;function h_(){p_=Lu=py=null}function x_(t){var s=my.current;ds(my),t._currentValue=s}function zw(t,s,n){for(;t!==null;){var a=t.alternate;if((t.childLanes&s)!==s?(t.childLanes|=s,a!==null&&(a.childLanes|=s)):a!==null&&(a.childLanes&s)!==s&&(a.childLanes|=s),t===n)break;t=t.return}}function Ju(t,s){py=t,p_=Lu=null,t=t.dependencies,t!==null&&t.firstContext!==null&&(t.lanes&s&&(xa=!0),t.firstContext=null)}function br(t){var s=t._currentValue;if(p_!==t)if(t={context:t,memoizedValue:s,next:null},Lu===null){if(py===null)throw Error(Ae(308));Lu=t,py.dependencies={lanes:0,firstContext:t}}else Lu=Lu.next=t;return s}var td=null;function f_(t){td===null?td=[t]:td.push(t)}function V6(t,s,n,a){var r=s.interleaved;return r===null?(n.next=n,f_(s)):(n.next=r.next,r.next=n),s.interleaved=n,Ao(t,a)}function Ao(t,s){t.lanes|=s;var n=t.alternate;for(n!==null&&(n.lanes|=s),n=t,t=t.return;t!==null;)t.childLanes|=s,n=t.alternate,n!==null&&(n.childLanes|=s),n=t,t=t.return;return n.tag===3?n.stateNode:null}var fl=!1;function g_(t){t.updateQueue={baseState:t.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,interleaved:null,lanes:0},effects:null}}function Z6(t,s){t=t.updateQueue,s.updateQueue===t&&(s.updateQueue={baseState:t.baseState,firstBaseUpdate:t.firstBaseUpdate,lastBaseUpdate:t.lastBaseUpdate,shared:t.shared,effects:t.effects})}function jo(t,s){return{eventTime:t,lane:s,tag:0,payload:null,callback:null,next:null}}function $l(t,s,n){var a=t.updateQueue;if(a===null)return null;if(a=a.shared,Ot&2){var r=a.pending;return r===null?s.next=s:(s.next=r.next,r.next=s),a.pending=s,Ao(t,n)}return r=a.interleaved,r===null?(s.next=s,f_(a)):(s.next=r.next,r.next=s),a.interleaved=s,Ao(t,n)}function e0(t,s,n){if(s=s.updateQueue,s!==null&&(s=s.shared,(n&4194240)!==0)){var a=s.lanes;a&=t.pendingLanes,n|=a,s.lanes=n,s_(t,n)}}function uS(t,s){var n=t.updateQueue,a=t.alternate;if(a!==null&&(a=a.updateQueue,n===a)){var r=null,i=null;if(n=n.firstBaseUpdate,n!==null){do{var o={eventTime:n.eventTime,lane:n.lane,tag:n.tag,payload:n.payload,callback:n.callback,next:null};i===null?r=i=o:i=i.next=o,n=n.next}while(n!==null);i===null?r=i=s:i=i.next=s}else r=i=s;n={baseState:a.baseState,firstBaseUpdate:r,lastBaseUpdate:i,shared:a.shared,effects:a.effects},t.updateQueue=n;return}t=n.lastBaseUpdate,t===null?n.firstBaseUpdate=s:t.next=s,n.lastBaseUpdate=s}function hy(t,s,n,a){var r=t.updateQueue;fl=!1;var i=r.firstBaseUpdate,o=r.lastBaseUpdate,l=r.shared.pending;if(l!==null){r.shared.pending=null;var c=l,u=c.next;c.next=null,o===null?i=u:o.next=u,o=c;var p=t.alternate;p!==null&&(p=p.updateQueue,l=p.lastBaseUpdate,l!==o&&(l===null?p.firstBaseUpdate=u:l.next=u,p.lastBaseUpdate=c))}if(i!==null){var m=r.baseState;o=0,p=u=c=null,l=i;do{var x=l.lane,h=l.eventTime;if((a&x)===x){p!==null&&(p=p.next={eventTime:h,lane:0,tag:l.tag,payload:l.payload,callback:l.callback,next:null});e:{var y=t,v=l;switch(x=s,h=n,v.tag){case 1:if(y=v.payload,typeof y=="function"){m=y.call(h,m,x);break e}m=y;break e;case 3:y.flags=y.flags&-65537|128;case 0:if(y=v.payload,x=typeof y=="function"?y.call(h,m,x):y,x==null)break e;m=js({},m,x);break e;case 2:fl=!0}}l.callback!==null&&l.lane!==0&&(t.flags|=64,x=r.effects,x===null?r.effects=[l]:x.push(l))}else h={eventTime:h,lane:x,tag:l.tag,payload:l.payload,callback:l.callback,next:null},p===null?(u=p=h,c=m):p=p.next=h,o|=x;if(l=l.next,l===null){if(l=r.shared.pending,l===null)break;x=l,l=x.next,x.next=null,r.lastBaseUpdate=x,r.shared.pending=null}}while(!0);if(p===null&&(c=m),r.baseState=c,r.firstBaseUpdate=u,r.lastBaseUpdate=p,s=r.shared.interleaved,s!==null){r=s;do o|=r.lane,r=r.next;while(r!==s)}else i===null&&(r.shared.lanes=0);jd|=o,t.lanes=o,t.memoizedState=m}}function mS(t,s,n){if(t=s.effects,s.effects=null,t!==null)for(s=0;s<t.length;s++){var a=t[s],r=a.callback;if(r!==null){if(a.callback=null,a=n,typeof r!="function")throw Error(Ae(191,r));r.call(a)}}}var Gx={},Pi=nc(Gx),Xh=nc(Gx),ex=nc(Gx);function sd(t){if(t===Gx)throw Error(Ae(174));return t}function y_(t,s){switch(ns(ex,s),ns(Xh,t),ns(Pi,Gx),t=s.nodeType,t){case 9:case 11:s=(s=s.documentElement)?s.namespaceURI:gw(null,"");break;default:t=t===8?s.parentNode:s,s=t.namespaceURI||null,t=t.tagName,s=gw(s,t)}ds(Pi),ns(Pi,s)}function Am(){ds(Pi),ds(Xh),ds(ex)}function Y6(t){sd(ex.current);var s=sd(Pi.current),n=gw(s,t.type);s!==n&&(ns(Xh,t),ns(Pi,n))}function b_(t){Xh.current===t&&(ds(Pi),ds(Xh))}var ys=nc(0);function xy(t){for(var s=t;s!==null;){if(s.tag===13){var n=s.memoizedState;if(n!==null&&(n=n.dehydrated,n===null||n.data==="$?"||n.data==="$!"))return s}else if(s.tag===19&&s.memoizedProps.revealOrder!==void 0){if(s.flags&128)return s}else if(s.child!==null){s.child.return=s,s=s.child;continue}if(s===t)break;for(;s.sibling===null;){if(s.return===null||s.return===t)return null;s=s.return}s.sibling.return=s.return,s=s.sibling}return null}var H1=[];function v_(){for(var t=0;t<H1.length;t++)H1[t]._workInProgressVersionPrimary=null;H1.length=0}var t0=Mo.ReactCurrentDispatcher,G1=Mo.ReactCurrentBatchConfig,vd=0,bs=null,Ks=null,cn=null,fy=!1,Nh=!1,tx=0,j7=0;function Sn(){throw Error(Ae(321))}function j_(t,s){if(s===null)return!1;for(var n=0;n<s.length&&n<t.length;
vendor: 3,633 bytes, line 39
39n++)if(!Xr(t[n],s[n]))return!1;return!0}function w_(t,s,n,a,r,i){if(vd=i,bs=s,s.memoizedState=null,s.updateQueue=null,s.lanes=0,t0.current=t===null||t.memoizedState===null?k7:S7,t=n(a,r),Nh){i=0;do{if(Nh=!1,tx=0,25<=i)throw Error(Ae(301));i+=1,cn=Ks=null,s.updateQueue=null,t0.current=C7,t=n(a,r)}while(Nh)}if(t0.current=gy,s=Ks!==null&&Ks.next!==null,vd=0,cn=Ks=bs=null,fy=!1,s)throw Error(Ae(300));return t}function N_(){var t=tx!==0;return tx=0,t}function yi(){var t={memoizedState:null,baseState:null,baseQueue:null,queue:null,next:null};return cn===null?bs.memoizedState=cn=t:cn=cn.next=t,cn}function vr(){if(Ks===null){var t=bs.alternate;t=t!==null?t.memoizedState:null}else t=Ks.next;var s=cn===null?bs.memoizedState:cn.next;if(s!==null)cn=s,Ks=t;else{if(t===null)throw Error(Ae(310));Ks=t,t={memoizedState:Ks.memoizedState,baseState:Ks.baseState,baseQueue:Ks.baseQueue,queue:Ks.queue,next:null},cn===null?bs.memoizedState=cn=t:cn=cn.next=t}return cn}function sx(t,s){return typeof s=="function"?s(t):s}function V1(t){var s=vr(),n=s.queue;if(n===null)throw Error(Ae(311));n.lastRenderedReducer=t;var a=Ks,r=a.baseQueue,i=n.pending;if(i!==null){if(r!==null){var o=r.next;r.next=i.next,i.next=o}a.baseQueue=r=i,n.pending=null}if(r!==null){i=r.next,a=a.baseState;var l=o=null,c=null,u=i;do{var p=u.lane;if((vd&p)===p)c!==null&&(c=c.next={lane:0,action:u.action,hasEagerState:u.hasEagerState,eagerState:u.eagerState,next:null}),a=u.hasEagerState?u.eagerState:t(a,u.action);else{var m={lane:p,action:u.action,hasEagerState:u.hasEagerState,eagerState:u.eagerState,next:null};c===null?(l=c=m,o=a):c=c.next=m,bs.lanes|=p,jd|=p}u=u.next}while(u!==null&&u!==i);c===null?o=a:c.next=l,Xr(a,s.memoizedState)||(xa=!0),s.memoizedState=a,s.baseState=o,s.baseQueue=c,n.lastRenderedState=a}if(t=n.interleaved,t!==null){r=t;do i=r.lane,bs.lanes|=i,jd|=i,r=r.next;while(r!==t)}else r===null&&(n.lanes=0);return[s.memoizedState,n.dispatch]}function Z1(t){var s=vr(),n=s.queue;if(n===null)throw Error(Ae(311));n.lastRenderedReducer=t;var a=n.dispatch,r=n.pending,i=s.memoizedState;if(r!==null){n.pending=null;var o=r=r.next;do i=t(i,o.action),o=o.next;while(o!==r);Xr(i,s.memoizedState)||(xa=!0),s.memoizedState=i,s.baseQueue===null&&(s.baseState=i),n.lastRenderedState=i}return[i,a]}function K6(){}function Q6(t,s){var n=bs,a=vr(),r=s(),i=!Xr(a.memoizedState,r);if(i&&(a.memoizedState=r,xa=!0),a=a.queue,__(eT.bind(null,n,a,t),[t]),a.getSnapshot!==s||i||cn!==null&&cn.memoizedState.tag&1){if(n.flags|=2048,nx(9,X6.bind(null,n,a,r,s),void 0,null),un===null)throw Error(Ae(349));vd&30||J6(n,s,r)}return r}function J6(t,s,n){t.flags|=16384,t={getSnapshot:s,value:n},s=bs.updateQueue,s===null?(s={lastEffect:null,stores:null},bs.updateQueue=s,s.stores=[t]):(n=s.stores,n===null?s.stores=[t]:n.push(t))}function X6(t,s,n,a){s.value=n,s.getSnapshot=a,tT(s)&&sT(t)}function eT(t,s,n){return n(function(){tT(s)&&sT(t)})}function tT(t){var s=t.getSnapshot;t=t.value;try{var n=s();return!Xr(t,n)}catch{return!0}}function sT(t){var s=Ao(t,1);s!==null&&Qr(s,t,1,-1)}function pS(t){var s=yi();return typeof t=="function"&&(t=t()),s.memoizedState=s.baseState=t,t={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:sx,lastRenderedState:t},s.queue=t,t=t.dispatch=_7.bind(null,bs,t),[s.memoizedState,t]}function nx(t,s,n,a){return t={tag:t,create:s,destroy:n,deps:a,next:null},s=bs.updateQueue,s===null?(s={lastEffect:null,stores:null},bs.updateQueue=s,s.lastEffect=t.next=t):(n=s.lastEffect,n===null?s.lastEffect=t.next=t:(a=n.next,n.next=t,t.next=a,s.lastEffect=t)),t}function nT(){return vr().memoizedState}function s0(t,s,n,a){var r=yi();
vendor: 10,593 bytes, lines 39-41
39bs.flags|=t,r.memoizedState=nx(1|s,n,void 0,a===void 0?null:a)}function wb(t,s,n,a){var r=vr();a=a===void 0?null:a;var i=void 0;if(Ks!==null){var o=Ks.memoizedState;if(i=o.destroy,a!==null&&j_(a,o.deps)){r.memoizedState=nx(s,n,i,a);return}}bs.flags|=t,r.memoizedState=nx(1|s,n,i,a)}function hS(t,s){return s0(8390656,8,t,s)}function __(t,s){return wb(2048,8,t,s)}function aT(t,s){return wb(4,2,t,s)}function rT(t,s){return wb(4,4,t,s)}function iT(t,s){if(typeof s=="function")return t=t(),s(t),function(){s(null)};if(s!=null)return t=t(),s.current=t,function(){s.current=null}}function oT(t,s,n){return n=n!=null?n.concat([t]):null,wb(4,4,iT.bind(null,s,t),n)}function k_(){}function lT(t,s){var n=vr();s=s===void 0?null:s;var a=n.memoizedState;return a!==null&&s!==null&&j_(s,a[1])?a[0]:(n.memoizedState=[t,s],t)}function cT(t,s){var n=vr();s=s===void 0?null:s;var a=n.memoizedState;return a!==null&&s!==null&&j_(s,a[1])?a[0]:(t=t(),n.memoizedState=[t,s],t)}function dT(t,s,n){return vd&21?(Xr(n,s)||(n=x6(),bs.lanes|=n,jd|=n,t.baseState=!0),s):(t.baseState&&(t.baseState=!1,xa=!0),t.memoizedState=n)}function w7(t,s){var n=Zt;Zt=n!==0&&4>n?n:4,t(!0);var a=G1.transition;G1.transition={};try{t(!1),s()}finally{Zt=n,G1.transition=a}}function uT(){return vr().memoizedState}function N7(t,s,n){var a=Ll(t);if(n={lane:a,action:n,hasEagerState:!1,eagerState:null,next:null},mT(t))pT(s,n);else if(n=V6(t,s,n,a),n!==null){var r=ea();Qr(n,t,a,r),hT(n,s,a)}}function _7(t,s,n){var a=Ll(t),r={lane:a,action:n,hasEagerState:!1,eagerState:null,next:null};if(mT(t))pT(s,r);else{var i=t.alternate;if(t.lanes===0&&(i===null||i.lanes===0)&&(i=s.lastRenderedReducer,i!==null))try{var o=s.lastRenderedState,l=i(o,n);if(r.hasEagerState=!0,r.eagerState=l,Xr(l,o)){var c=s.interleaved;c===null?(r.next=r,f_(s)):(r.next=c.next,c.next=r),s.interleaved=r;return}}catch{}finally{}n=V6(t,s,r,a),n!==null&&(r=ea(),Qr(n,t,a,r),hT(n,s,a))}}function mT(t){var s=t.alternate;return t===bs||s!==null&&s===bs}function pT(t,s){Nh=fy=!0;var n=t.pending;n===null?s.next=s:(s.next=n.next,n.next=s),t.pending=s}function hT(t,s,n){if(n&4194240){var a=s.lanes;a&=t.pendingLanes,n|=a,s.lanes=n,s_(t,n)}}var gy={readContext:br,useCallback:Sn,useContext:Sn,useEffect:Sn,useImperativeHandle:Sn,useInsertionEffect:Sn,useLayoutEffect:Sn,useMemo:Sn,useReducer:Sn,useRef:Sn,useState:Sn,useDebugValue:Sn,useDeferredValue:Sn,useTransition:Sn,useMutableSource:Sn,useSyncExternalStore:Sn,useId:Sn,unstable_isNewReconciler:!1},k7={readContext:br,useCallback:function(t,s){return yi().memoizedState=[t,s===void 0?null:s],t},useContext:br,useEffect:hS,useImperativeHandle:function(t,s,n){return n=n!=null?n.concat([t]):null,s0(4194308,4,iT.bind(null,s,t),n)},useLayoutEffect:function(t,s){return s0(4194308,4,t,s)},useInsertionEffect:function(t,s){return s0(4,2,t,s)},useMemo:function(t,s){var n=yi();return s=s===void 0?null:s,t=t(),n.memoizedState=[t,s],t},useReducer:function(t,s,n){var a=yi();return s=n!==void 0?n(s):s,a.memoizedState=a.baseState=s,t={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:t,lastRenderedState:s},a.queue=t,t=t.dispatch=N7.bind(null,bs,t),[a.memoizedState,t]},useRef:function(t){var s=yi();return t={current:t},s.memoizedState=t},useState:pS,useDebugValue:k_,useDeferredValue:function(t){return yi().memoizedState=t},useTransition:function(){var t=pS(!1),s=t[0];return t=w7.bind(null,t[1]),yi().memoizedState=t,[s,t]},useMutableSource:function(){},useSyncExternalStore:function(t,s,n){var a=bs,r=yi();if(xs){if(n===void 0)throw Error(Ae(407));n=n()}else{if(n=s(),un===null)throw Error(Ae(349));vd&30||J6(a,s,n)}r.memoizedState=n;var i={value:n,getSnapshot:s};return r.queue=i,hS(eT.bind(null,a,i,t),[t]),a.flags|=2048,nx(9,X6.bind(null,a,i,n,s),void 0,null),n},useId:function(){var t=yi(),s=un.identifierPrefix;if(xs){var n=yo,a=go;n=(a&~(1<<32-Kr(a)-1)).toString(32)+n,s=":"+s+"R"+n,n=tx++,0<n&&(s+="H"+n.toString(32)),s+=":"}else n=j7++,s=":"+s+"r"+n.toString(32)+":";return t.memoizedState=s},unstable_isNewReconciler:!1},S7={readContext:br,useCallback:lT,useContext:br,useEffect:__,useImperativeHandle:oT,useInsertionEffect:aT,useLayoutEffect:rT,useMemo:cT,useReducer:V1,useRef:nT,useState:function(){return V1(sx)},useDebugValue:k_,useDeferredValue:function(t){var s=vr();return dT(s,Ks.memoizedState,t)},useTransition:function(){var t=V1(sx)[0],s=vr().memoizedState;return[t,s]},useMutableSource:K6,useSyncExternalStore:Q6,useId:uT,unstable_isNewReconciler:!1},C7={readContext:br,useCallback:lT,useContext:br,useEffect:__,useImperativeHandle:oT,useInsertionEffect:aT,useLayoutEffect:rT,useMemo:cT,useReducer:Z1,useRef:nT,useState:function(){return Z1(sx)},useDebugValue:k_,useDeferredValue:function(t){var s=vr();return Ks===null?s.memoizedState=t:dT(s,Ks.memoizedState,t)},useTransition:function(){var t=Z1(sx)[0],s=vr().memoizedState;return[t,s]},useMutableSource:K6,useSyncExternalStore:Q6,useId:uT,unstable_isNewReconciler:!1};function Br(t,s){if(t&&t.defaultProps){s=js({},s),t=t.defaultProps;for(var n in t)s[n]===void 0&&(s[n]=t[n]);return s}return s}function Lw(t,s,n,a){s=t.memoizedState,n=n(a,s),n=n==null?s:js({},s,n),t.memoizedState=n,t.lanes===0&&(t.updateQueue.baseState=n)}var Nb={isMounted:function(t){return(t=t._reactInternals)?Ld(t)===t:!1},enqueueSetState:function(t,s,n){t=t._reactInternals;var a=ea(),r=Ll(t),i=jo(a,r);i.payload=s,n!=null&&(i.callback=n),s=$l(t,i,r),s!==null&&(Qr(s,t,r,a),e0(s,t,r))},enqueueReplaceState:function(t,s,n){t=t._reactInternals;var a=ea(),r=Ll(t),i=jo(a,r);i.tag=1,i.payload=s,n!=null&&(i.callback=n),s=$l(t,i,r),s!==null&&(Qr(s,t,r,a),e0(s,t,r))},enqueueForceUpdate:function(t,s){t=t._reactInternals;var n=ea(),a=Ll(t),r=jo(n,a);r.tag=2,s!=null&&(r.callback=s),s=$l(t,r,a),s!==null&&(Qr(s,t,a,n),e0(s,t,a))}};function xS(t,s,n,a,r,i,o){return t=t.stateNode,typeof t.shouldComponentUpdate=="function"?t.shouldComponentUpdate(a,i,o):s.prototype&&s.prototype.isPureReactComponent?!Yh(n,a)||!Yh(r,i):!0}function xT(t,s,n){var a=!1,r=Hl,i=s.contextType;return typeof i=="object"&&i!==null?i=br(i):(r=ya(s)?yd:Mn.current,a=s.contextTypes,i=(a=a!=null)?km(t,r):Hl),s=new s(n,i),t.memoizedState=s.state!==null&&s.state!==void 0?s.state:null,s.updater=Nb,t.stateNode=s,s._reactInternals=t,a&&(t=t.stateNode,t.__reactInternalMemoizedUnmaskedChildContext=r,t.__reactInternalMemoizedMaskedChildContext=i),s}function fS(t,s,n,a){t=s.state,typeof s.componentWillReceiveProps=="function"&&s.componentWillReceiveProps(n,a),typeof s.UNSAFE_componentWillReceiveProps=="function"&&s.UNSAFE_componentWillReceiveProps(n,a),s.state!==t&&Nb.enqueueReplaceState(s,s.state,null)}function Ow(t,s,n,a){var r=t.stateNode;r.props=n,r.state=t.memoizedState,r.refs={},g_(t);var i=s.contextType;typeof i=="object"&&i!==null?r.context=br(i):(i=ya(s)?yd:Mn.current,r.context=km(t,i)),r.state=t.memoizedState,i=s.getDerivedStateFromProps,typeof i=="function"&&(Lw(t,s,i,n),r.state=t.memoizedState),typeof s.getDerivedStateFromProps=="function"||typeof r.getSnapshotBeforeUpdate=="function"||typeof r.UNSAFE_componentWillMount!="function"&&typeof r.componentWillMount!="function"||(s=r.state,typeof r.componentWillMount=="function"&&r.componentWillMount(),typeof r.UNSAFE_componentWillMount=="function"&&r.UNSAFE_componentWillMount(),s!==r.state&&Nb.enqueueReplaceState(r,r.state,null),hy(t,n,r,a),r.state=t.memoizedState),typeof r.componentDidMount=="function"&&(t.flags|=4194308)}function Em(t,s){try{var n="",a=s;do n+=tL(a),a=a.return;while(a);var r=n}catch(i){r=` 40Error generating stack: `+i.message+` 41`+i.stack}return{value:t,source:s,stack:r,digest:null}}function Y1(t,s,n){return{value:t,source:null,stack:n??null,digest:s??null}}function Mw(t,s){try{console.error(s.value)}catch(n){setTimeout(function(){throw n})}}var A7=typeof WeakMap=="function"?WeakMap:Map;function fT(t,s,n){n=jo(-1,n),n.tag=3,n.payload={element:null};var a=s.value;return n.callback=function(){by||(by=!0,Kw=a),Mw(t,s)},n}function gT(t,s,n){n=jo(-1,n),n.tag=3;var a=t.type.getDerivedStateFromError;if(typeof a=="function"){var r=s.value;n.payload=function(){return a(r)},n.callback=function(){Mw(t,s)}}var i=t.stateNode;return i!==null&&typeof i.componentDidCatch=="function"&&(n.callback=function(){Mw(t,s),typeof a!="function"&&(zl===null?zl=new Set([this]):zl.add(this));var o=s.stack;this.componentDidCatch(s.value,{componentStack:o!==null?o:""})}),n}function gS(t,s,n){var a=t.pingCache;if(a===null){a=t.pingCache=new A7;var r=new Set;a.set(s,r)}else r=a.get(s),r===void 0&&(r=new Set,a.set(s,r));r.has(n)||(r.add(n),t=U7.bind(null,t,s,n),s.then(t,t))}function yS(t){do{var s;if((s=t.tag===13)&&(s=t.memoizedState,s=s!==null?s.dehydrated!==null:!0),s)return t;t=t.return}while(t!==null);return null}function bS(t,s,n,a,r){return t.mode&1?(t.flags|=65536,t.lanes=r,t):(t===s?t.flags|=65536:(t.flags|=128,n.flags|=131072,n.flags&=-52805,n.tag===1&&(n.alternate===null?n.tag=17:(s=jo(-1,1),s.tag=2,$l(n,s,1))),n.lanes|=1),t)}var E7=Mo.ReactCurrentOwner,xa=!1;function Hn(t,s,n,a){s.child=t===null?G6(s,null,n,a):Cm(s,t.child,n,a)}function vS(t,s,n,a,r){n=n.render;var i=s.ref;return Ju(s,r),a=w_(t,s,n,a,i,r),n=N_(),t!==null&&!xa?(s.updateQueue=t.updateQueue,s.flags&=-2053,t.lanes&=~r,Eo(t,s,r)):(xs&&n&&d_(s),s.flags|=1,Hn(t,s,a,r),s.child)}function jS(t,s,n,a,r){if(t===null){var i=n.type;return typeof i=="function"&&!D_(i)&&i.defaultProps===void 0&&n.compare===null&&n.defaultProps===void 0?(s.tag=15,s.type=i,yT(t,s,i,a,r)):(t=i0(n.type,null,a,s,s.mode,r),t.ref=s.ref,t.return=s,s.child=t)}if(i=t.child,!(t.lanes&r)){var o=i.memoizedProps;if(n=n.compare,n=n!==null?n:Yh,n(o,a)&&t.ref===s.ref)return Eo(t,s,r)}return s.flags|=1,t=Ol(i,a),t.ref=s.ref,t.return=s,s.child=t}function yT(t,s,n,a,r){if(t!==null){var i=t.memoizedProps;if(Yh(i,a)&&t.ref===s.ref)if(xa=!1,s.pendingProps=a=i,(t.lanes&r)!==0)t.flags&131072&&(xa=!0);else return s.lanes=t.lanes,Eo(t,s,r)}return Bw(t,s,n,a,r)}function bT(t,s,n){var a=s.pendingProps,r=a.children,i=t!==null?t.memoizedState:null;if(a.mode==="hidden")if(!(s.mode&1))s.memoizedState={baseLanes:0,cachePool:null,transitions:null},ns(Mu,Ta),Ta|=n;else{if(!(n&1073741824))return t=i!==null?i.baseLanes|n:n,s.lanes=s.childLanes=1073741824,s.memoizedState={baseLanes:t,cachePool:null,transitions:null},s.updateQueue=null,ns(Mu,Ta),Ta|=t,null;s.memoizedState={baseLanes:0,cachePool:null,transitions:null},a=i!==null?i.baseLanes:n,ns(Mu,Ta),Ta|=a}else i!==null?(a=i.baseLanes|n,s.memoizedState=null):a=n,ns(Mu,Ta),Ta|=a;return Hn(t,s,r,n),s.child}function vT(t,s){var n=s.ref;(t===null&&n!==null||t!==null&&t.ref!==n)&&(s.flags|=512,s.flags|=2097152)}
vendor: 4,420 bytes, line 41
41function Bw(t,s,n,a,r){var i=ya(n)?yd:Mn.current;return i=km(s,i),Ju(s,r),n=w_(t,s,n,a,i,r),a=N_(),t!==null&&!xa?(s.updateQueue=t.updateQueue,s.flags&=-2053,t.lanes&=~r,Eo(t,s,r)):(xs&&a&&d_(s),s.flags|=1,Hn(t,s,n,r),s.child)}function wS(t,s,n,a,r){if(ya(n)){var i=!0;cy(s)}else i=!1;if(Ju(s,r),s.stateNode===null)n0(t,s),xT(s,n,a),Ow(s,n,a,r),a=!0;else if(t===null){var o=s.stateNode,l=s.memoizedProps;o.props=l;var c=o.context,u=n.contextType;typeof u=="object"&&u!==null?u=br(u):(u=ya(n)?yd:Mn.current,u=km(s,u));var p=n.getDerivedStateFromProps,m=typeof p=="function"||typeof o.getSnapshotBeforeUpdate=="function";m||typeof o.UNSAFE_componentWillReceiveProps!="function"&&typeof o.componentWillReceiveProps!="function"||(l!==a||c!==u)&&fS(s,o,a,u),fl=!1;var x=s.memoizedState;o.state=x,hy(s,a,o,r),c=s.memoizedState,l!==a||x!==c||ga.current||fl?(typeof p=="function"&&(Lw(s,n,p,a),c=s.memoizedState),(l=fl||xS(s,n,l,a,x,c,u))?(m||typeof o.UNSAFE_componentWillMount!="function"&&typeof o.componentWillMount!="function"||(typeof o.componentWillMount=="function"&&o.componentWillMount(),typeof o.UNSAFE_componentWillMount=="function"&&o.UNSAFE_componentWillMount()),typeof o.componentDidMount=="function"&&(s.flags|=4194308)):(typeof o.componentDidMount=="function"&&(s.flags|=4194308),s.memoizedProps=a,s.memoizedState=c),o.props=a,o.state=c,o.context=u,a=l):(typeof o.componentDidMount=="function"&&(s.flags|=4194308),a=!1)}else{o=s.stateNode,Z6(t,s),l=s.memoizedProps,u=s.type===s.elementType?l:Br(s.type,l),o.props=u,m=s.pendingProps,x=o.context,c=n.contextType,typeof c=="object"&&c!==null?c=br(c):(c=ya(n)?yd:Mn.current,c=km(s,c));var h=n.getDerivedStateFromProps;(p=typeof h=="function"||typeof o.getSnapshotBeforeUpdate=="function")||typeof o.UNSAFE_componentWillReceiveProps!="function"&&typeof o.componentWillReceiveProps!="function"||(l!==m||x!==c)&&fS(s,o,a,c),fl=!1,x=s.memoizedState,o.state=x,hy(s,a,o,r);var y=s.memoizedState;l!==m||x!==y||ga.current||fl?(typeof h=="function"&&(Lw(s,n,h,a),y=s.memoizedState),(u=fl||xS(s,n,u,a,x,y,c)||!1)?(p||typeof o.UNSAFE_componentWillUpdate!="function"&&typeof o.componentWillUpdate!="function"||(typeof o.componentWillUpdate=="function"&&o.componentWillUpdate(a,y,c),typeof o.UNSAFE_componentWillUpdate=="function"&&o.UNSAFE_componentWillUpdate(a,y,c)),typeof o.componentDidUpdate=="function"&&(s.flags|=4),typeof o.getSnapshotBeforeUpdate=="function"&&(s.flags|=1024)):(typeof o.componentDidUpdate!="function"||l===t.memoizedProps&&x===t.memoizedState||(s.flags|=4),typeof o.getSnapshotBeforeUpdate!="function"||l===t.memoizedProps&&x===t.memoizedState||(s.flags|=1024),s.memoizedProps=a,s.memoizedState=y),o.props=a,o.state=y,o.context=c,a=u):(typeof o.componentDidUpdate!="function"||l===t.memoizedProps&&x===t.memoizedState||(s.flags|=4),typeof o.getSnapshotBeforeUpdate!="function"||l===t.memoizedProps&&x===t.memoizedState||(s.flags|=1024),a=!1)}return Uw(t,s,n,a,i,r)}function Uw(t,s,n,a,r,i){vT(t,s);var o=(s.flags&128)!==0;if(!a&&!o)return r&&oS(s,n,!1),Eo(t,s,i);a=s.stateNode,E7.current=s;var l=o&&typeof n.getDerivedStateFromError!="function"?null:a.render();return s.flags|=1,t!==null&&o?(s.child=Cm(s,t.child,null,i),s.child=Cm(s,null,l,i)):Hn(t,s,l,i),s.memoizedState=a.state,r&&oS(s,n,!0),s.child}function jT(t){var s=t.stateNode;s.pendingContext?iS(t,s.pendingContext,s.pendingContext!==s.context):s.context&&iS(t,s.context,!1),y_(t,s.containerInfo)}function NS(t,s,n,a,r){return Sm(),m_(r),s.flags|=256,Hn(t,s,n,a),s.child}var qw={dehydrated:null,treeContext:null,retryLane:0};function Ww(t){return{baseLanes:t,cachePool:null,transitions:null}}function wT(t,s,n){var a=s.pendingProps,r=ys.current,i=!1,o=(s.flags&128)!==0,l;if((l=o)||(l=t!==null&&t.memoizedState===null?!1:(r&2)!==0),l?(i=!0,s.flags&=-129):(t===null||t.memoizedState!==null)&&(r|=1),ns(ys,r&1),t===null)return $w(s),t=s.memoizedState,t!==null&&(t=t.dehydrated,t!==null)?(s.mode&1?t.data==="$!"?s.lanes=8:s.lanes=1073741824:s.lanes=1,null):(o=a.children,t=a.fallback,i?(a=s.mode,i=s.child,o={mode:"hidden",children:o},!(a&1)&&i!==null?(i.childLanes=0,i.pendingProps=o):i=Sb(o,a,0,null),t=xd(t,a,n,null),i.return=s,t.return=s,i.sibling=t,s.child=i,s.child.memoizedState=Ww(n),s.memoizedState=qw,t):S_(s,o));if(r=t.memoizedState,r!==null&&(l=r.dehydrated,l!==null))return F7(t,s,o,a,l,r,n);if(i){i=a.fallback,o=s.mode,r=t.child,l=r.sibling;var c={mode:"hidden",children:a.children};
vendor: 6,933 bytes, line 41
41return!(o&1)&&s.child!==r?(a=s.child,a.childLanes=0,a.pendingProps=c,s.deletions=null):(a=Ol(r,c),a.subtreeFlags=r.subtreeFlags&14680064),l!==null?i=Ol(l,i):(i=xd(i,o,n,null),i.flags|=2),i.return=s,a.return=s,a.sibling=i,s.child=a,a=i,i=s.child,o=t.child.memoizedState,o=o===null?Ww(n):{baseLanes:o.baseLanes|n,cachePool:null,transitions:o.transitions},i.memoizedState=o,i.childLanes=t.childLanes&~n,s.memoizedState=qw,a}return i=t.child,t=i.sibling,a=Ol(i,{mode:"visible",children:a.children}),!(s.mode&1)&&(a.lanes=n),a.return=s,a.sibling=null,t!==null&&(n=s.deletions,n===null?(s.deletions=[t],s.flags|=16):n.push(t)),s.child=a,s.memoizedState=null,a}function S_(t,s){return s=Sb({mode:"visible",children:s},t.mode,0,null),s.return=t,t.child=s}function kf(t,s,n,a){return a!==null&&m_(a),Cm(s,t.child,null,n),t=S_(s,s.pendingProps.children),t.flags|=2,s.memoizedState=null,t}function F7(t,s,n,a,r,i,o){if(n)return s.flags&256?(s.flags&=-257,a=Y1(Error(Ae(422))),kf(t,s,o,a)):s.memoizedState!==null?(s.child=t.child,s.flags|=128,null):(i=a.fallback,r=s.mode,a=Sb({mode:"visible",children:a.children},r,0,null),i=xd(i,r,o,null),i.flags|=2,a.return=s,i.return=s,a.sibling=i,s.child=a,s.mode&1&&Cm(s,t.child,null,o),s.child.memoizedState=Ww(o),s.memoizedState=qw,i);if(!(s.mode&1))return kf(t,s,o,null);if(r.data==="$!"){if(a=r.nextSibling&&r.nextSibling.dataset,a)var l=a.dgst;return a=l,i=Error(Ae(419)),a=Y1(i,a,void 0),kf(t,s,o,a)}if(l=(o&t.childLanes)!==0,xa||l){if(a=un,a!==null){switch(o&-o){case 4:r=2;break;case 16:r=8;break;case 64:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:r=32;break;case 536870912:r=268435456;break;default:r=0}r=r&(a.suspendedLanes|o)?0:r,r!==0&&r!==i.retryLane&&(i.retryLane=r,Ao(t,r),Qr(a,t,r,-1))}return P_(),a=Y1(Error(Ae(421))),kf(t,s,o,a)}return r.data==="$?"?(s.flags|=128,s.child=t.child,s=q7.bind(null,t),r._reactRetry=s,null):(t=i.treeContext,za=Il(r.nextSibling),Oa=s,xs=!0,Gr=null,t!==null&&(mr[pr++]=go,mr[pr++]=yo,mr[pr++]=bd,go=t.id,yo=t.overflow,bd=s),s=S_(s,a.children),s.flags|=4096,s)}function _S(t,s,n){t.lanes|=s;var a=t.alternate;a!==null&&(a.lanes|=s),zw(t.return,s,n)}function K1(t,s,n,a,r){var i=t.memoizedState;i===null?t.memoizedState={isBackwards:s,rendering:null,renderingStartTime:0,last:a,tail:n,tailMode:r}:(i.isBackwards=s,i.rendering=null,i.renderingStartTime=0,i.last=a,i.tail=n,i.tailMode=r)}function NT(t,s,n){var a=s.pendingProps,r=a.revealOrder,i=a.tail;if(Hn(t,s,a.children,n),a=ys.current,a&2)a=a&1|2,s.flags|=128;else{if(t!==null&&t.flags&128)e:for(t=s.child;t!==null;){if(t.tag===13)t.memoizedState!==null&&_S(t,n,s);else if(t.tag===19)_S(t,n,s);else if(t.child!==null){t.child.return=t,t=t.child;continue}if(t===s)break e;for(;t.sibling===null;){if(t.return===null||t.return===s)break e;t=t.return}t.sibling.return=t.return,t=t.sibling}a&=1}if(ns(ys,a),!(s.mode&1))s.memoizedState=null;else switch(r){case"forwards":for(n=s.child,r=null;n!==null;)t=n.alternate,t!==null&&xy(t)===null&&(r=n),n=n.sibling;n=r,n===null?(r=s.child,s.child=null):(r=n.sibling,n.sibling=null),K1(s,!1,r,n,i);break;case"backwards":for(n=null,r=s.child,s.child=null;r!==null;){if(t=r.alternate,t!==null&&xy(t)===null){s.child=r;break}t=r.sibling,r.sibling=n,n=r,r=t}K1(s,!0,n,null,i);break;case"together":K1(s,!1,null,null,void 0);break;default:s.memoizedState=null}return s.child}function n0(t,s){!(s.mode&1)&&t!==null&&(t.alternate=null,s.alternate=null,s.flags|=2)}function Eo(t,s,n){if(t!==null&&(s.dependencies=t.dependencies),jd|=s.lanes,!(n&s.childLanes))return null;if(t!==null&&s.child!==t.child)throw Error(Ae(153));if(s.child!==null){for(t=s.child,n=Ol(t,t.pendingProps),s.child=n,n.return=s;t.sibling!==null;)t=t.sibling,n=n.sibling=Ol(t,t.pendingProps),n.return=s;n.sibling=null}return s.child}function T7(t,s,n){switch(s.tag){case 3:jT(s),Sm();break;case 5:Y6(s);break;case 1:ya(s.type)&&cy(s);break;case 4:y_(s,s.stateNode.containerInfo);break;case 10:var a=s.type._context,r=s.memoizedProps.value;ns(my,a._currentValue),a._currentValue=r;break;case 13:if(a=s.memoizedState,a!==null)return a.dehydrated!==null?(ns(ys,ys.current&1),s.flags|=128,null):n&s.child.childLanes?wT(t,s,n):(ns(ys,ys.current&1),t=Eo(t,s,n),t!==null?t.sibling:null);ns(ys,ys.current&1);break;case 19:if(a=(n&s.childLanes)!==0,t.flags&128){if(a)return NT(t,s,n);s.flags|=128}if(r=s.memoizedState,r!==null&&(r.rendering=null,r.tail=null,r.lastEffect=null),ns(ys,ys.current),a)break;return null;case 22:case 23:return s.lanes=0,bT(t,s,n)}return Eo(t,s,n)}var _T,Hw,kT,ST;_T=function(t,s){for(var n=s.child;n!==null;){if(n.tag===5||n.tag===6)t.appendChild(n.stateNode);else if(n.tag!==4&&n.child!==null){n.child.return=n,n=n.child;continue}if(n===s)break;for(;n.sibling===null;){if(n.return===null||n.return===s)return;n=n.return}n.sibling.return=n.return,n=n.sibling}};Hw=function(){};kT=function(t,s,n,a){var r=t.memoizedProps;if(r!==a){t=s.stateNode,sd(Pi.current);var i=null;switch(n){case"input":r=pw(t,r),a=pw(t,a),i=[];break;case"select":r=js({},r,{value:void 0}),a=js({},a,{value:void 0}),i=[];break;case"textarea":r=fw(t,r),a=fw(t,a),i=[];break;default:typeof r.onClick!="function"&&typeof a.onClick=="function"&&(t.onclick=oy)}yw(n,a);var o;n=null;for(u in r)if(!a.hasOwnProperty(u)&&r.hasOwnProperty(u)&&r[u]!=null)if(u==="style"){var l=r[u];for(o in l)l.hasOwnProperty(o)&&(n||(n={}),n[o]="")}else u!=="dangerouslySetInnerHTML"&&u!=="children"&&u!=="suppressContentEditableWarning"&&u!=="suppressHydrationWarning"&&u!=="autoFocus"&&(Uh.hasOwnProperty(u)?i||(i=[]):(i=i||[]).push(u,null));for(u in a){var c=a[u];if(l=r!=null?r[u]:void 0,a.hasOwnProperty(u)&&c!==l&&(c!=null||l!=null))if(u==="style")if(l){for(o in l)!l.hasOwnProperty(o)||c&&c.hasOwnProperty(o)||(n||(n={}),n[o]="");for(o in c)c.hasOwnProperty(o)&&l[o]!==c[o]&&(n||(n={}),n[o]=c[o])}else n||(i||(i=[]),i.push(u,n)),n=c;else u==="dangerouslySetInnerHTML"?(c=c?c.__html:void 0,l=l?l.__html:void 0,c!=null&&l!==c&&(i=i||[]).push(u,c)):u==="children"?typeof c!="string"&&typeof c!="number"||(i=i||[]).push(u,""+c):u!=="suppressContentEditableWarning"&&u!=="suppressHydrationWarning"&&(Uh.hasOwnProperty(u)?(c!=null&&u==="onScroll"&&is("scroll",t),i||l===c||(i=[])):(i=i||[]).push(u,c))}n&&(i=i||[]).push("style",n);var u=i;(s.updateQueue=u)&&(s.flags|=4)}};ST=function(t,s,n,a){n!==a&&(s.flags|=4)};function fp(t,s){if(!xs)switch(t.tailMode){case"hidden":s=t.tail;for(var n=null;s!==null;)s.alternate!==null&&(n=s),s=s.sibling;n===null?t.tail=null:n.sibling=null;break;case"collapsed":n=t.tail;for(var a=null;n!==null;)n.alternate!==null&&(a=n),n=n.sibling;a===null?s||t.tail===null?t.tail=null:t.tail.sibling=null:a.sibling=null}}function Cn(t){var s=t.alternate!==null&&t.alternate.child===t.child,n=0,a=0;if(s)for(var r=t.child;r!==null;
vendor: 30,631 bytes, line 41
41)n|=r.lanes|r.childLanes,a|=r.subtreeFlags&14680064,a|=r.flags&14680064,r.return=t,r=r.sibling;else for(r=t.child;r!==null;)n|=r.lanes|r.childLanes,a|=r.subtreeFlags,a|=r.flags,r.return=t,r=r.sibling;return t.subtreeFlags|=a,t.childLanes=n,s}function P7(t,s,n){var a=s.pendingProps;switch(u_(s),s.tag){case 2:case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return Cn(s),null;case 1:return ya(s.type)&&ly(),Cn(s),null;case 3:return a=s.stateNode,Am(),ds(ga),ds(Mn),v_(),a.pendingContext&&(a.context=a.pendingContext,a.pendingContext=null),(t===null||t.child===null)&&(Nf(s)?s.flags|=4:t===null||t.memoizedState.isDehydrated&&!(s.flags&256)||(s.flags|=1024,Gr!==null&&(Xw(Gr),Gr=null))),Hw(t,s),Cn(s),null;case 5:b_(s);var r=sd(ex.current);if(n=s.type,t!==null&&s.stateNode!=null)kT(t,s,n,a,r),t.ref!==s.ref&&(s.flags|=512,s.flags|=2097152);else{if(!a){if(s.stateNode===null)throw Error(Ae(166));return Cn(s),null}if(t=sd(Pi.current),Nf(s)){a=s.stateNode,n=s.type;var i=s.memoizedProps;switch(a[Si]=s,a[Jh]=i,t=(s.mode&1)!==0,n){case"dialog":is("cancel",a),is("close",a);break;case"iframe":case"object":case"embed":is("load",a);break;case"video":case"audio":for(r=0;r<th.length;r++)is(th[r],a);break;case"source":is("error",a);break;case"img":case"image":case"link":is("error",a),is("load",a);break;case"details":is("toggle",a);break;case"input":Dk(a,i),is("invalid",a);break;case"select":a._wrapperState={wasMultiple:!!i.multiple},is("invalid",a);break;case"textarea":Ik(a,i),is("invalid",a)}yw(n,i),r=null;for(var o in i)if(i.hasOwnProperty(o)){var l=i[o];o==="children"?typeof l=="string"?a.textContent!==l&&(i.suppressHydrationWarning!==!0&&wf(a.textContent,l,t),r=["children",l]):typeof l=="number"&&a.textContent!==""+l&&(i.suppressHydrationWarning!==!0&&wf(a.textContent,l,t),r=["children",""+l]):Uh.hasOwnProperty(o)&&l!=null&&o==="onScroll"&&is("scroll",a)}switch(n){case"input":hf(a),Rk(a,i,!0);break;case"textarea":hf(a),$k(a);break;case"select":case"option":break;default:typeof i.onClick=="function"&&(a.onclick=oy)}a=r,s.updateQueue=a,a!==null&&(s.flags|=4)}else{o=r.nodeType===9?r:r.ownerDocument,t==="http://www.w3.org/1999/xhtml"&&(t=e6(n)),t==="http://www.w3.org/1999/xhtml"?n==="script"?(t=o.createElement("div"),t.innerHTML="<script><\/script>",t=t.removeChild(t.firstChild)):typeof a.is=="string"?t=o.createElement(n,{is:a.is}):(t=o.createElement(n),n==="select"&&(o=t,a.multiple?o.multiple=!0:a.size&&(o.size=a.size))):t=o.createElementNS(t,n),t[Si]=s,t[Jh]=a,_T(t,s,!1,!1),s.stateNode=t;e:{switch(o=bw(n,a),n){case"dialog":is("cancel",t),is("close",t),r=a;break;case"iframe":case"object":case"embed":is("load",t),r=a;break;case"video":case"audio":for(r=0;r<th.length;r++)is(th[r],t);r=a;break;case"source":is("error",t),r=a;break;case"img":case"image":case"link":is("error",t),is("load",t),r=a;break;case"details":is("toggle",t),r=a;break;case"input":Dk(t,a),r=pw(t,a),is("invalid",t);break;case"option":r=a;break;case"select":t._wrapperState={wasMultiple:!!a.multiple},r=js({},a,{value:void 0}),is("invalid",t);break;case"textarea":Ik(t,a),r=fw(t,a),is("invalid",t);break;default:r=a}yw(n,r),l=r;for(i in l)if(l.hasOwnProperty(i)){var c=l[i];i==="style"?n6(t,c):i==="dangerouslySetInnerHTML"?(c=c?c.__html:void 0,c!=null&&t6(t,c)):i==="children"?typeof c=="string"?(n!=="textarea"||c!=="")&&qh(t,c):typeof c=="number"&&qh(t,""+c):i!=="suppressContentEditableWarning"&&i!=="suppressHydrationWarning"&&i!=="autoFocus"&&(Uh.hasOwnProperty(i)?c!=null&&i==="onScroll"&&is("scroll",t):c!=null&&KN(t,i,c,o))}switch(n){case"input":hf(t),Rk(t,a,!1);break;case"textarea":hf(t),$k(t);break;case"option":a.value!=null&&t.setAttribute("value",""+Wl(a.value));break;case"select":t.multiple=!!a.multiple,i=a.value,i!=null?Zu(t,!!a.multiple,i,!1):a.defaultValue!=null&&Zu(t,!!a.multiple,a.defaultValue,!0);break;default:typeof r.onClick=="function"&&(t.onclick=oy)}switch(n){case"button":case"input":case"select":case"textarea":a=!!a.autoFocus;break e;case"img":a=!0;break e;default:a=!1}}a&&(s.flags|=4)}s.ref!==null&&(s.flags|=512,s.flags|=2097152)}return Cn(s),null;case 6:if(t&&s.stateNode!=null)ST(t,s,t.memoizedProps,a);else{if(typeof a!="string"&&s.stateNode===null)throw Error(Ae(166));if(n=sd(ex.current),sd(Pi.current),Nf(s)){if(a=s.stateNode,n=s.memoizedProps,a[Si]=s,(i=a.nodeValue!==n)&&(t=Oa,t!==null))switch(t.tag){case 3:wf(a.nodeValue,n,(t.mode&1)!==0);break;case 5:t.memoizedProps.suppressHydrationWarning!==!0&&wf(a.nodeValue,n,(t.mode&1)!==0)}i&&(s.flags|=4)}else a=(n.nodeType===9?n:n.ownerDocument).createTextNode(a),a[Si]=s,s.stateNode=a}return Cn(s),null;case 13:if(ds(ys),a=s.memoizedState,t===null||t.memoizedState!==null&&t.memoizedState.dehydrated!==null){if(xs&&za!==null&&s.mode&1&&!(s.flags&128))W6(),Sm(),s.flags|=98560,i=!1;else if(i=Nf(s),a!==null&&a.dehydrated!==null){if(t===null){if(!i)throw Error(Ae(318));if(i=s.memoizedState,i=i!==null?i.dehydrated:null,!i)throw Error(Ae(317));i[Si]=s}else Sm(),!(s.flags&128)&&(s.memoizedState=null),s.flags|=4;Cn(s),i=!1}else Gr!==null&&(Xw(Gr),Gr=null),i=!0;if(!i)return s.flags&65536?s:null}return s.flags&128?(s.lanes=n,s):(a=a!==null,a!==(t!==null&&t.memoizedState!==null)&&a&&(s.child.flags|=8192,s.mode&1&&(t===null||ys.current&1?Js===0&&(Js=3):P_())),s.updateQueue!==null&&(s.flags|=4),Cn(s),null);case 4:return Am(),Hw(t,s),t===null&&Kh(s.stateNode.containerInfo),Cn(s),null;case 10:return x_(s.type._context),Cn(s),null;case 17:return ya(s.type)&&ly(),Cn(s),null;case 19:if(ds(ys),i=s.memoizedState,i===null)return Cn(s),null;if(a=(s.flags&128)!==0,o=i.rendering,o===null)if(a)fp(i,!1);else{if(Js!==0||t!==null&&t.flags&128)for(t=s.child;t!==null;){if(o=xy(t),o!==null){for(s.flags|=128,fp(i,!1),a=o.updateQueue,a!==null&&(s.updateQueue=a,s.flags|=4),s.subtreeFlags=0,a=n,n=s.child;n!==null;)i=n,t=a,i.flags&=14680066,o=i.alternate,o===null?(i.childLanes=0,i.lanes=t,i.child=null,i.subtreeFlags=0,i.memoizedProps=null,i.memoizedState=null,i.updateQueue=null,i.dependencies=null,i.stateNode=null):(i.childLanes=o.childLanes,i.lanes=o.lanes,i.child=o.child,i.subtreeFlags=0,i.deletions=null,i.memoizedProps=o.memoizedProps,i.memoizedState=o.memoizedState,i.updateQueue=o.updateQueue,i.type=o.type,t=o.dependencies,i.dependencies=t===null?null:{lanes:t.lanes,firstContext:t.firstContext}),n=n.sibling;return ns(ys,ys.current&1|2),s.child}t=t.sibling}i.tail!==null&&Ds()>Fm&&(s.flags|=128,a=!0,fp(i,!1),s.lanes=4194304)}else{if(!a)if(t=xy(o),t!==null){if(s.flags|=128,a=!0,n=t.updateQueue,n!==null&&(s.updateQueue=n,s.flags|=4),fp(i,!0),i.tail===null&&i.tailMode==="hidden"&&!o.alternate&&!xs)return Cn(s),null}else 2*Ds()-i.renderingStartTime>Fm&&n!==1073741824&&(s.flags|=128,a=!0,fp(i,!1),s.lanes=4194304);i.isBackwards?(o.sibling=s.child,s.child=o):(n=i.last,n!==null?n.sibling=o:s.child=o,i.last=o)}return i.tail!==null?(s=i.tail,i.rendering=s,i.tail=s.sibling,i.renderingStartTime=Ds(),s.sibling=null,n=ys.current,ns(ys,a?n&1|2:n&1),s):(Cn(s),null);case 22:case 23:return T_(),a=s.memoizedState!==null,t!==null&&t.memoizedState!==null!==a&&(s.flags|=8192),a&&s.mode&1?Ta&1073741824&&(Cn(s),s.subtreeFlags&6&&(s.flags|=8192)):Cn(s),null;case 24:return null;case 25:return null}throw Error(Ae(156,s.tag))}function D7(t,s){switch(u_(s),s.tag){case 1:return ya(s.type)&&ly(),t=s.flags,t&65536?(s.flags=t&-65537|128,s):null;case 3:return Am(),ds(ga),ds(Mn),v_(),t=s.flags,t&65536&&!(t&128)?(s.flags=t&-65537|128,s):null;case 5:return b_(s),null;case 13:if(ds(ys),t=s.memoizedState,t!==null&&t.dehydrated!==null){if(s.alternate===null)throw Error(Ae(340));Sm()}return t=s.flags,t&65536?(s.flags=t&-65537|128,s):null;case 19:return ds(ys),null;case 4:return Am(),null;case 10:return x_(s.type._context),null;case 22:case 23:return T_(),null;case 24:return null;default:return null}}var Sf=!1,$n=!1,R7=typeof WeakSet=="function"?WeakSet:Set,Ge=null;function Ou(t,s){var n=t.ref;if(n!==null)if(typeof n=="function")try{n(null)}catch(a){ks(t,s,a)}else n.current=null}function Gw(t,s,n){try{n()}catch(a){ks(t,s,a)}}var kS=!1;function I7(t,s){if(Ew=ay,t=T6(),c_(t)){if("selectionStart"in t)var n={start:t.selectionStart,end:t.selectionEnd};else e:{n=(n=t.ownerDocument)&&n.defaultView||window;var a=n.getSelection&&n.getSelection();if(a&&a.rangeCount!==0){n=a.anchorNode;var r=a.anchorOffset,i=a.focusNode;a=a.focusOffset;try{n.nodeType,i.nodeType}catch{n=null;break e}var o=0,l=-1,c=-1,u=0,p=0,m=t,x=null;t:for(;;){for(var h;m!==n||r!==0&&m.nodeType!==3||(l=o+r),m!==i||a!==0&&m.nodeType!==3||(c=o+a),m.nodeType===3&&(o+=m.nodeValue.length),(h=m.firstChild)!==null;)x=m,m=h;for(;;){if(m===t)break t;if(x===n&&++u===r&&(l=o),x===i&&++p===a&&(c=o),(h=m.nextSibling)!==null)break;m=x,x=m.parentNode}m=h}n=l===-1||c===-1?null:{start:l,end:c}}else n=null}n=n||{start:0,end:0}}else n=null;for(Fw={focusedElem:t,selectionRange:n},ay=!1,Ge=s;Ge!==null;)if(s=Ge,t=s.child,(s.subtreeFlags&1028)!==0&&t!==null)t.return=s,Ge=t;else for(;Ge!==null;){s=Ge;try{var y=s.alternate;if(s.flags&1024)switch(s.tag){case 0:case 11:case 15:break;case 1:if(y!==null){var v=y.memoizedProps,g=y.memoizedState,N=s.stateNode,b=N.getSnapshotBeforeUpdate(s.elementType===s.type?v:Br(s.type,v),g);N.__reactInternalSnapshotBeforeUpdate=b}break;case 3:var f=s.stateNode.containerInfo;f.nodeType===1?f.textContent="":f.nodeType===9&&f.documentElement&&f.removeChild(f.documentElement);break;case 5:case 6:case 4:case 17:break;default:throw Error(Ae(163))}}catch(j){ks(s,s.return,j)}if(t=s.sibling,t!==null){t.return=s.return,Ge=t;break}Ge=s.return}return y=kS,kS=!1,y}function _h(t,s,n){var a=s.updateQueue;if(a=a!==null?a.lastEffect:null,a!==null){var r=a=a.next;do{if((r.tag&t)===t){var i=r.destroy;r.destroy=void 0,i!==void 0&&Gw(s,n,i)}r=r.next}while(r!==a)}}function _b(t,s){if(s=s.updateQueue,s=s!==null?s.lastEffect:null,s!==null){var n=s=s.next;do{if((n.tag&t)===t){var a=n.create;n.destroy=a()}n=n.next}while(n!==s)}}function Vw(t){var s=t.ref;if(s!==null){var n=t.stateNode;switch(t.tag){case 5:t=n;break;default:t=n}typeof s=="function"?s(t):s.current=t}}function CT(t){var s=t.alternate;s!==null&&(t.alternate=null,CT(s)),t.child=null,t.deletions=null,t.sibling=null,t.tag===5&&(s=t.stateNode,s!==null&&(delete s[Si],delete s[Jh],delete s[Dw],delete s[g7],delete s[y7])),t.stateNode=null,t.return=null,t.dependencies=null,t.memoizedProps=null,t.memoizedState=null,t.pendingProps=null,t.stateNode=null,t.updateQueue=null}function AT(t){return t.tag===5||t.tag===3||t.tag===4}function SS(t){e:for(;;){for(;t.sibling===null;){if(t.return===null||AT(t.return))return null;t=t.return}for(t.sibling.return=t.return,t=t.sibling;t.tag!==5&&t.tag!==6&&t.tag!==18;){if(t.flags&2||t.child===null||t.tag===4)continue e;t.child.return=t,t=t.child}if(!(t.flags&2))return t.stateNode}}function Zw(t,s,n){var a=t.tag;if(a===5||a===6)t=t.stateNode,s?n.nodeType===8?n.parentNode.insertBefore(t,s):n.insertBefore(t,s):(n.nodeType===8?(s=n.parentNode,s.insertBefore(t,n)):(s=n,s.appendChild(t)),n=n._reactRootContainer,n!=null||s.onclick!==null||(s.onclick=oy));else if(a!==4&&(t=t.child,t!==null))for(Zw(t,s,n),t=t.sibling;t!==null;)Zw(t,s,n),t=t.sibling}function Yw(t,s,n){var a=t.tag;if(a===5||a===6)t=t.stateNode,s?n.insertBefore(t,s):n.appendChild(t);else if(a!==4&&(t=t.child,t!==null))for(Yw(t,s,n),t=t.sibling;t!==null;)Yw(t,s,n),t=t.sibling}var jn=null,Hr=!1;function Zo(t,s,n){for(n=n.child;n!==null;)ET(t,s,n),n=n.sibling}function ET(t,s,n){if(Ti&&typeof Ti.onCommitFiberUnmount=="function")try{Ti.onCommitFiberUnmount(fb,n)}catch{}switch(n.tag){case 5:$n||Ou(n,s);case 6:var a=jn,r=Hr;jn=null,Zo(t,s,n),jn=a,Hr=r,jn!==null&&(Hr?(t=jn,n=n.stateNode,t.nodeType===8?t.parentNode.removeChild(n):t.removeChild(n)):jn.removeChild(n.stateNode));break;case 18:jn!==null&&(Hr?(t=jn,n=n.stateNode,t.nodeType===8?q1(t.parentNode,n):t.nodeType===1&&q1(t,n),Vh(t)):q1(jn,n.stateNode));break;case 4:a=jn,r=Hr,jn=n.stateNode.containerInfo,Hr=!0,Zo(t,s,n),jn=a,Hr=r;break;case 0:case 11:case 14:case 15:if(!$n&&(a=n.updateQueue,a!==null&&(a=a.lastEffect,a!==null))){r=a=a.next;do{var i=r,o=i.destroy;i=i.tag,o!==void 0&&(i&2||i&4)&&Gw(n,s,o),r=r.next}while(r!==a)}Zo(t,s,n);break;case 1:if(!$n&&(Ou(n,s),a=n.stateNode,typeof a.componentWillUnmount=="function"))try{a.props=n.memoizedProps,a.state=n.memoizedState,a.componentWillUnmount()}catch(l){ks(n,s,l)}Zo(t,s,n);break;case 21:Zo(t,s,n);break;case 22:n.mode&1?($n=(a=$n)||n.memoizedState!==null,Zo(t,s,n),$n=a):Zo(t,s,n);break;default:Zo(t,s,n)}}function CS(t){var s=t.updateQueue;if(s!==null){t.updateQueue=null;var n=t.stateNode;n===null&&(n=t.stateNode=new R7),s.forEach(function(a){var r=W7.bind(null,t,a);n.has(a)||(n.add(a),a.then(r,r))})}}function _r(t,s){var n=s.deletions;if(n!==null)for(var a=0;a<n.length;a++){var r=n[a];try{var i=t,o=s,l=o;e:for(;l!==null;){switch(l.tag){case 5:jn=l.stateNode,Hr=!1;break e;case 3:jn=l.stateNode.containerInfo,Hr=!0;break e;case 4:jn=l.stateNode.containerInfo,Hr=!0;break e}l=l.return}if(jn===null)throw Error(Ae(160));ET(i,o,r),jn=null,Hr=!1;var c=r.alternate;c!==null&&(c.return=null),r.return=null}catch(u){ks(r,s,u)}}if(s.subtreeFlags&12854)for(s=s.child;s!==null;)FT(s,t),s=s.sibling}function FT(t,s){var n=t.alternate,a=t.flags;switch(t.tag){case 0:case 11:case 14:case 15:if(_r(s,t),ii(t),a&4){try{_h(3,t,t.return),_b(3,t)}catch(v){ks(t,t.return,v)}try{_h(5,t,t.return)}catch(v){ks(t,t.return,v)}}break;case 1:_r(s,t),ii(t),a&512&&n!==null&&Ou(n,n.return);break;case 5:if(_r(s,t),ii(t),a&512&&n!==null&&Ou(n,n.return),t.flags&32){var r=t.stateNode;try{qh(r,"")}catch(v){ks(t,t.return,v)}}if(a&4&&(r=t.stateNode,r!=null)){var i=t.memoizedProps,o=n!==null?n.memoizedProps:i,l=t.type,c=t.updateQueue;if(t.updateQueue=null,c!==null)try{l==="input"&&i.type==="radio"&&i.name!=null&&JF(r,i),bw(l,o);var u=bw(l,i);for(o=0;o<c.length;o+=2){var p=c[o],m=c[o+1];p==="style"?n6(r,m):p==="dangerouslySetInnerHTML"?t6(r,m):p==="children"?qh(r,m):KN(r,p,m,u)}switch(l){case"input":hw(r,i);break;case"textarea":XF(r,i);break;case"select":var x=r._wrapperState.wasMultiple;r._wrapperState.wasMultiple=!!i.multiple;var h=i.value;h!=null?Zu(r,!!i.multiple,h,!1):x!==!!i.multiple&&(i.defaultValue!=null?Zu(r,!!i.multiple,i.defaultValue,!0):Zu(r,!!i.multiple,i.multiple?[]:"",!1))}r[Jh]=i}catch(v){ks(t,t.return,v)}}break;case 6:if(_r(s,t),ii(t),a&4){if(t.stateNode===null)throw Error(Ae(162));r=t.stateNode,i=t.memoizedProps;try{r.nodeValue=i}catch(v){ks(t,t.return,v)}}break;case 3:if(_r(s,t),ii(t),a&4&&n!==null&&n.memoizedState.isDehydrated)try{Vh(s.containerInfo)}catch(v){ks(t,t.return,v)}break;case 4:_r(s,t),ii(t);break;case 13:_r(s,t),ii(t),r=t.child,r.flags&8192&&(i=r.memoizedState!==null,r.stateNode.isHidden=i,!i||r.alternate!==null&&r.alternate.memoizedState!==null||(E_=Ds())),a&4&&CS(t);break;case 22:if(p=n!==null&&n.memoizedState!==null,t.mode&1?($n=(u=$n)||p,_r(s,t),$n=u):_r(s,t),ii(t),a&8192){if(u=t.memoizedState!==null,(t.stateNode.isHidden=u)&&!p&&t.mode&1)for(Ge=t,p=t.child;p!==null;){for(m=Ge=p;Ge!==null;){switch(x=Ge,h=x.child,x.tag){case 0:case 11:case 14:case 15:_h(4,x,x.return);break;case 1:Ou(x,x.return);var y=x.stateNode;if(typeof y.componentWillUnmount=="function"){a=x,n=x.return;try{s=a,y.props=s.memoizedProps,y.state=s.memoizedState,y.componentWillUnmount()}catch(v){ks(a,n,v)}}break;case 5:Ou(x,x.return);break;case 22:if(x.memoizedState!==null){ES(m);continue}}h!==null?(h.return=x,Ge=h):ES(m)}p=p.sibling}e:for(p=null,m=t;;){if(m.tag===5){if(p===null){p=m;try{r=m.stateNode,u?(i=r.style,typeof i.setProperty=="function"?i.setProperty("display","none","important"):i.display="none"):(l=m.stateNode,c=m.memoizedProps.style,o=c!=null&&c.hasOwnProperty("display")?c.display:null,l.style.display=s6("display",o))}catch(v){ks(t,t.return,v)}}}else if(m.tag===6){if(p===null)try{m.stateNode.nodeValue=u?"":m.memoizedProps}catch(v){ks(t,t.return,v)}}else if((m.tag!==22&&m.tag!==23||m.memoizedState===null||m===t)&&m.child!==null){m.child.return=m,m=m.child;continue}if(m===t)break e;for(;m.sibling===null;){if(m.return===null||m.return===t)break e;p===m&&(p=null),m=m.return}p===m&&(p=null),m.sibling.return=m.return,m=m.sibling}}break;case 19:_r(s,t),ii(t),a&4&&CS(t);break;case 21:break;default:_r(s,t),ii(t)}}function ii(t){var s=t.flags;if(s&2){try{e:{for(var n=t.return;n!==null;){if(AT(n)){var a=n;break e}n=n.return}throw Error(Ae(160))}switch(a.tag){case 5:var r=a.stateNode;a.flags&32&&(qh(r,""),a.flags&=-33);var i=SS(t);Yw(t,i,r);break;case 3:case 4:var o=a.stateNode.containerInfo,l=SS(t);Zw(t,l,o);break;default:throw Error(Ae(161))}}catch(c){ks(t,t.return,c)}t.flags&=-3}s&4096&&(t.flags&=-4097)}function $7(t,s,n){Ge=t,TT(t)}function TT(t,s,n){for(var a=(t.mode&1)!==0;Ge!==null;){var r=Ge,i=r.child;if(r.tag===22&&a){var o=r.memoizedState!==null||Sf;if(!o){var l=r.alternate,c=l!==null&&l.memoizedState!==null||$n;l=Sf;var u=$n;if(Sf=o,($n=c)&&!u)for(Ge=r;Ge!==null;)o=Ge,c=o.child,o.tag===22&&o.memoizedState!==null?FS(r):c!==null?(c.return=o,Ge=c):FS(r);for(;i!==null;)Ge=i,TT(i),i=i.sibling;Ge=r,Sf=l,$n=u}AS(t)}else r.subtreeFlags&8772&&i!==null?(i.return=r,Ge=i):AS(t)}}function AS(t){for(;Ge!==null;){var s=Ge;if(s.flags&8772){var n=s.alternate;try{if(s.flags&8772)switch(s.tag){case 0:case 11:case 15:$n||_b(5,s);break;case 1:var a=s.stateNode;if(s.flags&4&&!$n)if(n===null)a.componentDidMount();else{var r=s.elementType===s.type?n.memoizedProps:Br(s.type,n.memoizedProps);a.componentDidUpdate(r,n.memoizedState,a.__reactInternalSnapshotBeforeUpdate)}var i=s.updateQueue;i!==null&&mS(s,i,a);break;case 3:var o=s.updateQueue;if(o!==null){if(n=null,s.child!==null)switch(s.child.tag){case 5:n=s.child.stateNode;break;case 1:n=s.child.stateNode}mS(s,o,n)}break;case 5:var l=s.stateNode;if(n===null&&s.flags&4){n=l;var c=s.memoizedProps;switch(s.type){case"button":case"input":case"select":case"textarea":c.autoFocus&&n.focus();break;case"img":c.src&&(n.src=c.src)}}break;case 6:break;case 4:break;case 12:break;case 13:if(s.memoizedState===null){var u=s.alternate;if(u!==null){var p=u.memoizedState;if(p!==null){var m=p.dehydrated;m!==null&&Vh(m)}}}break;case 19:case 17:case 21:case 22:case 23:case 25:break;default:throw Error(Ae(163))}$n||s.flags&512&&Vw(s)}catch(x){ks(s,s.return,x)}}if(s===t){Ge=null;break}if(n=s.sibling,n!==null){n.return=s.return,Ge=n;break}Ge=s.return}}function ES(t){for(;Ge!==null;){var s=Ge;if(s===t){Ge=null;break}var n=s.sibling;if(n!==null){n.return=s.return,Ge=n;break}Ge=s.return}}function FS(t){for(;Ge!==null;){var s=Ge;try{switch(s.tag){case 0:case 11:case 15:var n=s.return;try{_b(4,s)}catch(c){ks(s,n,c)}break;case 1:var a=s.stateNode;if(typeof a.componentDidMount=="function"){var r=s.return;try{a.componentDidMount()}catch(c){ks(s,r,c)}}var i=s.return;try{Vw(s)}catch(c){ks(s,i,c)}break;case 5:var o=s.return;try{Vw(s)}catch(c){ks(s,o,c)}}}catch(c){ks(s,s.return,c)}if(s===t){Ge=null;break}var l=s.sibling;if(l!==null){l.return=s.return,Ge=l;break}Ge=s.return}}var z7=Math.ceil,yy=Mo.ReactCurrentDispatcher,C_=Mo.ReactCurrentOwner,gr=Mo.ReactCurrentBatchConfig,Ot=0,un=null,Us=null,Nn=0,Ta=0,Mu=nc(0),Js=0,ax=null,jd=0,kb=0,A_=0,kh=null,ma=null,E_=0,Fm=1/0,no=null,by=!1,Kw=null,zl=null,Cf=!1,El=null,vy=0,Sh=0,Qw=null,a0=-1,r0=0;function ea(){return Ot&6?Ds():a0!==-1?a0:a0=Ds()}function Ll(t){return t.mode&1?Ot&2&&Nn!==0?Nn&-Nn:v7.transition!==null?(r0===0&&(r0=x6()),r0):(t=Zt,t!==0||(t=window.event,t=t===void 0?16:w6(t.type)),t):1}function Qr(t,s,n,a){if(50<Sh)throw Sh=0,Qw=null,Error(Ae(185));qx(t,n,a),(!(Ot&2)||t!==un)&&(t===un&&(!(Ot&2)&&(kb|=n),Js===4&&yl(t,Nn)),ba(t,a),n===1&&Ot===0&&!(s.mode&1)&&(Fm=Ds()+500,jb&&ac()))}function ba(t,s){var n=t.callbackNode;vL(t,s);var a=ny(t,t===un?Nn:0);if(a===0)n!==null&&Ok(n),t.callbackNode=null,t.callbackPriority=0;else if(s=a&-a,t.callbackPriority!==s){if(n!=null&&Ok(n),s===1)t.tag===0?b7(TS.bind(null,t)):B6(TS.bind(null,t)),x7(function(){!(Ot&6)&&ac()}),n=null;else{switch(f6(a)){case 1:n=t_;break;case 4:n=p6;break;case 16:n=sy;break;case 536870912:n=h6;break;default:n=sy}n=OT(n,PT.bind(null,t))}t.callbackPriority=s,t.callbackNode=n}}function PT(t,s){if(a0=-1,r0=0,Ot&6)throw Error(Ae(327));var n=t.callbackNode;if(Xu()&&t.callbackNode!==n)return null;var a=ny(t,t===un?Nn:0);if(a===0)return null;if(a&30||a&t.expiredLanes||s)s=jy(t,a);else{s=a;var r=Ot;Ot|=2;var i=RT();(un!==t||Nn!==s)&&(no=null,Fm=Ds()+500,hd(t,s));do try{M7();break}catch(l){DT(t,l)}while(!0);h_(),yy.current=i,Ot=r,Us!==null?s=0:(un=null,Nn=0,s=Js)}if(s!==0){if(s===2&&(r=_w(t),r!==0&&(a=r,s=Jw(t,r))),s===1)throw n=ax,hd(t,0),yl(t,a),ba(t,Ds()),n;if(s===6)yl(t,a);else{if(r=t.current.alternate,!(a&30)&&!L7(r)&&(s=jy(t,a),s===2&&(i=_w(t),i!==0&&(a=i,s=Jw(t,i))),s===1))throw n=ax,hd(t,0),yl(t,a),ba(t,Ds()),n;switch(t.finishedWork=r,t.finishedLanes=a,s){case 0:case 1:throw Error(Ae(345));case 2:qc(t,ma,no);break;case 3:if(yl(t,a),(a&130023424)===a&&(s=E_+500-Ds(),10<s)){if(ny(t,0)!==0)break;if(r=t.suspendedLanes,(r&a)!==a){ea(),t.pingedLanes|=t.suspendedLanes&r;break}t.timeoutHandle=Pw(qc.bind(null,t,ma,no),s);break}qc(t,ma,no);break;case 4:if(yl(t,a),(a&4194240)===a)break;for(s=t.eventTimes,r=-1;0<a;){var o=31-Kr(a);i=1<<o,o=s[o],o>r&&(r=o),a&=~i}if(a=r,a=Ds()-a,a=(120>a?120:480>a?480:1080>a?1080:1920>a?1920:3e3>a?3e3:4320>a?4320:1960*z7(a/1960))-a,10<a){t.timeoutHandle=Pw(qc.bind(null,t,ma,no),a);break}qc(t,ma,no);break;case 5:qc(t,ma,no);break;default:throw Error(Ae(329))}}}return ba(t,Ds()),t.callbackNode===n?PT.bind(null,t):null}function Jw(t,s){var n=kh;return t.current.memoizedState.isDehydrated&&(hd(t,s).flags|=256),t=jy(t,s),t!==2&&(s=ma,ma=n,s!==null&&Xw(s)),t}function Xw(t){ma===null?ma=t:ma.push.apply(ma,t)}function L7(t){for(var s=t;;){if(s.flags&16384){var n=s.updateQueue;if(n!==null&&(n=n.stores,n!==null))for(var a=0;a<n.length;a++){var r=n[a],i=r.getSnapshot;r=r.value;try{if(!Xr(i(),r))return!1}catch{return!1}}}if(n=s.child,s.subtreeFlags&16384&&n!==null)n.return=s,s=n;else{if(s===t)break;for(;s.sibling===null;){if(s.return===null||s.return===t)return!0;s=s.return}s.sibling.return=s.return,s=s.sibling}}return!0}function yl(t,s){for(s&=~A_,s&=~kb,t.suspendedLanes|=s,t.pingedLanes&=~s,t=t.expirationTimes;0<s;){var n=31-Kr(s),a=1<<n;t[n]=-1,s&=~a}}function TS(t){if(Ot&6)throw Error(Ae(327));Xu();var s=ny(t,0);if(!(s&1))return ba(t,Ds()),null;var n=jy(t,s);if(t.tag!==0&&n===2){var a=_w(t);a!==0&&(s=a,n=Jw(t,a))}if(n===1)throw n=ax,hd(t,0),yl(t,s),ba(t,Ds()),n;if(n===6)throw Error(Ae(345));return t.finishedWork=t.current.alternate,t.finishedLanes=s,qc(t,ma,no),ba(t,Ds()),null}function F_(t,s){var n=Ot;Ot|=1;try{return t(s)}finally{Ot=n,Ot===0&&(Fm=Ds()+500,jb&&ac())}}function wd(t){El!==null&&El.tag===0&&!(Ot&6)&&Xu();var s=Ot;Ot|=1;var n=gr.transition,a=Zt;try{if(gr.transition=null,Zt=1,t)return t()}finally{Zt=a,gr.transition=n,Ot=s,!(Ot&6)&&ac()}}function T_(){Ta=Mu.current,ds(Mu)}function hd(t,s){t.finishedWork=null,t.finishedLanes=0;var n=t.timeoutHandle;if(n!==-1&&(t.timeoutHandle=-1,h7(n)),Us!==null)for(n=Us.return;n!==null;){var a=n;switch(u_(a),a.tag){case 1:a=a.type.childContextTypes,a!=null&&ly();break;case 3:Am(),ds(ga),ds(Mn),v_();break;case 5:b_(a);break;case 4:Am();break;case 13:ds(ys);break;case 19:ds(ys);break;case 10:x_(a.type._context);break;case 22:case 23:T_()}n=n.return}if(un=t,Us=t=Ol(t.current,null),Nn=Ta=s,Js=0,ax=null,A_=kb=jd=0,ma=kh=null,td!==null){for(s=0;s<td.length;s++)if(n=td[s],a=n.interleaved,a!==null){n.interleaved=null;var r=a.next,i=n.pending;if(i!==null){var o=i.next;i.next=r,a.next=o}n.pending=a}td=null}return t}function DT(t,s){do{var n=Us;try{if(h_(),t0.current=gy,fy){for(var a=bs.memoizedState;a!==null;){var r=a.queue;r!==null&&(r.pending=null),a=a.next}fy=!1}if(vd=0,cn=Ks=bs=null,Nh=!1,tx=0,C_.current=null,n===null||n.return===null){Js=1,ax=s,Us=null;break}e:{var i=t,o=n.return,l=n,c=s;if(s=Nn,l.flags|=32768,c!==null&&typeof c=="object"&&typeof c.then=="function"){var u=c,p=l,m=p.tag;if(!(p.mode&1)&&(m===0||m===11||m===15)){var x=p.alternate;x?(p.updateQueue=x.updateQueue,p.memoizedState=x.memoizedState,p.lanes=x.lanes):(p.updateQueue=null,p.memoizedState=null)}var h=yS(o);if(h!==null){h.flags&=-257,bS(h,o,l,i,s),h.mode&1&&gS(i,u,s),s=h,c=u;var y=s.updateQueue;if(y===null){var v=new Set;v.add(c),s.updateQueue=v}else y.add(c);break e}else{if(!(s&1)){gS(i,u,s),P_();break e}c=Error(Ae(426))}}else if(xs&&l.mode&1){var g=yS(o);if(g!==null){!(g.flags&65536)&&(g.flags|=256),bS(g,o,l,i,s),m_(Em(c,l));break e}}i=c=Em(c,l),Js!==4&&(Js=2),kh===null?kh=[i]:kh.push(i),i=o;do{switch(i.tag){case 3:i.flags|=65536,s&=-s,i.lanes|=s;var N=fT(i,c,s);uS(i,N);break e;case 1:l=c;var b=i.type,f=i.stateNode;if(!(i.flags&128)&&(typeof b.getDerivedStateFromError=="function"||f!==null&&typeof f.componentDidCatch=="function"&&(zl===null||!zl.has(f)))){i.flags|=65536,s&=-s,i.lanes|=s;var j=gT(i,l,s);uS(i,j);break e}}i=i.return}while(i!==null)}$T(n)}catch(S){s=S,Us===n&&n!==null&&(Us=n=n.return);continue}break}while(!0)}function RT(){var t=yy.current;return yy.current=gy,t===null?gy:t}function P_(){(Js===0||Js===3||Js===2)&&(Js=4),un===null||!(jd&268435455)&&!(kb&268435455)||yl(un,Nn)}function jy(t,s){var n=Ot;Ot|=2;var a=RT();(un!==t||Nn!==s)&&(no=null,hd(t,s));do try{O7();break}catch(r){DT(t,r)}while(!0);if(h_(),Ot=n,yy.current=a,Us!==null)throw Error(Ae(261));return un=null,Nn=0,Js}function O7(){for(;Us!==null;)IT(Us)}function M7(){for(;Us!==null&&!uL();)IT(Us)}function IT(t){var s=LT(t.alternate,t,Ta);t.memoizedProps=t.pendingProps,s===null?$T(t):Us=s,C_.current=null}function $T(t){var s=t;do{var n=s.alternate;if(t=s.return,s.flags&32768){if(n=D7(n,s),n!==null){n.flags&=32767,Us=n;return}if(t!==null)t.flags|=32768,t.subtreeFlags=0,t.deletions=null;else{Js=6,Us=null;return}}else if(n=P7(n,s,Ta),n!==null){Us=n;return}if(s=s.sibling,s!==null){Us=s;return}Us=s=t}while(s!==null);Js===0&&(Js=5)}function qc(t,s,n){var a=Zt,r=gr.transition;try{gr.transition=null,Zt=1,B7(t,s,n,a)}finally{gr.transition=r,Zt=a}return null}function B7(t,s,n,a){do Xu();while(El!==null);if(Ot&6)throw Error(Ae(327));n=t.finishedWork;var r=t.finishedLanes;if(n===null)return null;if(t.finishedWork=null,t.finishedLanes=0,n===t.current)throw Error(Ae(177));t.callbackNode=null,t.callbackPriority=0;var i=n.lanes|n.childLanes;if(jL(t,i),t===un&&(Us=un=null,Nn=0),!(n.subtreeFlags&2064)&&!(n.flags&2064)||Cf||(Cf=!0,OT(sy,function(){return Xu(),null})),i=(n.flags&15990)!==0,n.subtreeFlags&15990||i){i=gr.transition,gr.transition=null;var o=Zt;Zt=1;var l=Ot;Ot|=4,C_.current=null,I7(t,n),FT(n,t),o7(Fw),ay=!!Ew,Fw=Ew=null,t.current=n,$7(n),mL(),Ot=l,Zt=o,gr.transition=i}else t.current=n;if(Cf&&(Cf=!1,El=t,vy=r),i=t.pendingLanes,i===0&&(zl=null),xL(n.stateNode),ba(t,Ds()),s!==null)for(a=t.onRecoverableError,n=0;n<s.length;n++)r=s[n],a(r.value,{componentStack:r.stack,digest:r.digest});if(by)throw by=!1,t=Kw,Kw=null,t;return vy&1&&t.tag!==0&&Xu(),i=t.pendingLanes,i&1?t===Qw?Sh++:(Sh=0,Qw=t):Sh=0,ac(),null}function Xu(){if(El!==null){var t=f6(vy),s=gr.transition,n=Zt;try{if(gr.transition=null,Zt=16>t?16:t,El===null)var a=!1;else{if(t=El,El=null,vy=0,Ot&6)throw Error(Ae(331));var r=Ot;for(Ot|=4,Ge=t.current;Ge!==null;){var i=Ge,o=i.child;if(Ge.flags&16){var l=i.deletions;if(l!==null){for(var c=0;c<l.length;c++){var u=l[c];for(Ge=u;Ge!==null;){var p=Ge;switch(p.tag){case 0:case 11:case 15:_h(8,p,i)}var m=p.child;if(m!==null)m.return=p,Ge=m;else for(;Ge!==null;){p=Ge;var x=p.sibling,h=p.return;if(CT(p),p===u){Ge=null;break}if(x!==null){x.return=h,Ge=x;break}Ge=h}}}var y=i.alternate;if(y!==null){var v=y.child;if(v!==null){y.child=null;do{var g=v.sibling;v.sibling=null,v=g}while(v!==null)}}Ge=i}}if(i.subtreeFlags&2064&&o!==null)o.return=i,Ge=o;else e:for(;Ge!==null;){if(i=Ge,i.flags&2048)switch(i.tag){case 0:case 11:case 15:_h(9,i,i.return)}var N=i.sibling;if(N!==null){N.return=i.return,Ge=N;break e}Ge=i.return}}var b=t.current;for(Ge=b;Ge!==null;){o=Ge;var f=o.child;if(o.subtreeFlags&2064&&f!==null)f.return=o,Ge=f;else e:for(o=b;Ge!==null;){if(l=Ge,l.flags&2048)try{switch(l.tag){case 0:case 11:case 15:_b(9,l)}}catch(S){ks(l,l.return,S)}if(l===o){Ge=null;break e}var j=l.sibling;if(j!==null){j.return=l.return,Ge=j;break e}Ge=l.return}}if(Ot=r,ac(),Ti&&typeof Ti.onPostCommitFiberRoot=="function")try{Ti.onPostCommitFiberRoot(fb,t)}catch{}a=!0}return a}finally{Zt=n,gr.transition=s}}return!1}function PS(t,s,n){s=Em(n,s),s=fT(t,s,1),t=$l(t,s,1),s=ea(),t!==null&&(qx(t,1,s),ba(t,s))}function ks(t,s,n){if(t.tag===3)PS(t,t,n);else for(;s!==null;){if(s.tag===3){PS(s,t,n);break}else if(s.tag===1){var a=s.stateNode;if(typeof s.type.getDerivedStateFromError=="function"||typeof a.componentDidCatch=="function"&&(zl===null||!zl.has(a))){t=Em(n,t),t=gT(s,t,1),s=$l(s,t,1),t=ea(),s!==null&&(qx(s,1,t),ba(s,t));break}}s=s.return}}function U7(t,s,n){var a=t.pingCache;a!==null&&a.delete(s),s=ea(),t.pingedLanes|=t.suspendedLanes&n,un===t&&(Nn&n)===n&&(Js===4||Js===3&&(Nn&130023424)===Nn&&500>Ds()-E_?hd(t,0):A_|=n),ba(t,s)}function zT(t,s){s===0&&(t.mode&1?(s=gf,gf<<=1,!(gf&130023424)&&(gf=4194304)):s=1);var n=ea();t=Ao(t,s),t!==null&&(qx(t,s,n),ba(t,n))}function q7(t){var s=t.memoizedState,n=0;s!==null&&(n=s.retryLane),zT(t,n)}function W7(t,s){var n=0;switch(t.tag){case 13:var a=t.stateNode,r=t.memoizedState;r!==null&&(n=r.retryLane);break;case 19:a=t.stateNode;break;default:throw Error(Ae(314))}a!==null&&a.delete(s),zT(t,n)}var LT;LT=function(t,s,n){if(t!==null)if(t.memoizedProps!==s.pendingProps||ga.current)xa=!0;else{if(!(t.lanes&n)&&!(s.flags&128))return xa=!1,T7(t,s,n);xa=!!(t.flags&131072)}else xa=!1,xs&&s.flags&1048576&&U6(s,uy,s.index);switch(s.lanes=0,s.tag){case 2:var a=s.type;n0(t,s),t=s.pendingProps;var r=km(s,Mn.current);Ju(s,n),r=w_(null,s,a,t,r,n);var i=N_();return s.flags|=1,typeof r=="object"&&r!==null&&typeof r.render=="function"&&r.$$typeof===void 0?(s.tag=1,s.memoizedState=null,s.updateQueue=null,ya(a)?(i=!0,cy(s)):i=!1,s.memoizedState=r.state!==null&&r.state!==void 0?r.state:null,g_(s),r.updater=Nb,s.stateNode=r,r._reactInternals=s,Ow(s,a,t,n),s=Uw(null,s,a,!0,i,n)):(s.tag=0,xs&&i&&d_(s),Hn(null,s,r,n),s=s.child),s;case 16:a=s.elementType;e:{switch(n0(t,s),t=s.pendingProps,r=a._init,a=r(a._payload),s.type=a,r=s.tag=G7(a),t=Br(a,t),r){case 0:s=Bw(null,s,a,t,n);break e;case 1:s=wS(null,s,a,t,n);break e;case 11:s=vS(null,s,a,t,n);break e;case 14:s=jS(null,s,a,Br(a.type,t),n);break e}throw Error(Ae(306,a,""))}return s;case 0:return a=s.type,r=s.pendingProps,r=s.elementType===a?r:Br(a,r),Bw(t,s,a,r,n);case 1:return a=s.type,r=s.pendingProps,r=s.elementType===a?r:Br(a,r),wS(t,s,a,r,n);case 3:e:{if(jT(s),t===null)throw Error(Ae(387));a=s.pendingProps,i=s.memoizedState,r=i.element,Z6(t,s),hy(s,a,null,
vendor: 2,514 bytes, line 41
41n);var o=s.memoizedState;if(a=o.element,i.isDehydrated)if(i={element:a,isDehydrated:!1,cache:o.cache,pendingSuspenseBoundaries:o.pendingSuspenseBoundaries,transitions:o.transitions},s.updateQueue.baseState=i,s.memoizedState=i,s.flags&256){r=Em(Error(Ae(423)),s),s=NS(t,s,a,n,r);break e}else if(a!==r){r=Em(Error(Ae(424)),s),s=NS(t,s,a,n,r);break e}else for(za=Il(s.stateNode.containerInfo.firstChild),Oa=s,xs=!0,Gr=null,n=G6(s,null,a,n),s.child=n;n;)n.flags=n.flags&-3|4096,n=n.sibling;else{if(Sm(),a===r){s=Eo(t,s,n);break e}Hn(t,s,a,n)}s=s.child}return s;case 5:return Y6(s),t===null&&$w(s),a=s.type,r=s.pendingProps,i=t!==null?t.memoizedProps:null,o=r.children,Tw(a,r)?o=null:i!==null&&Tw(a,i)&&(s.flags|=32),vT(t,s),Hn(t,s,o,n),s.child;case 6:return t===null&&$w(s),null;case 13:return wT(t,s,n);case 4:return y_(s,s.stateNode.containerInfo),a=s.pendingProps,t===null?s.child=Cm(s,null,a,n):Hn(t,s,a,n),s.child;case 11:return a=s.type,r=s.pendingProps,r=s.elementType===a?r:Br(a,r),vS(t,s,a,r,n);case 7:return Hn(t,s,s.pendingProps,n),s.child;case 8:return Hn(t,s,s.pendingProps.children,n),s.child;case 12:return Hn(t,s,s.pendingProps.children,n),s.child;case 10:e:{if(a=s.type._context,r=s.pendingProps,i=s.memoizedProps,o=r.value,ns(my,a._currentValue),a._currentValue=o,i!==null)if(Xr(i.value,o)){if(i.children===r.children&&!ga.current){s=Eo(t,s,n);break e}}else for(i=s.child,i!==null&&(i.return=s);i!==null;){var l=i.dependencies;if(l!==null){o=i.child;for(var c=l.firstContext;c!==null;){if(c.context===a){if(i.tag===1){c=jo(-1,n&-n),c.tag=2;var u=i.updateQueue;if(u!==null){u=u.shared;var p=u.pending;p===null?c.next=c:(c.next=p.next,p.next=c),u.pending=c}}i.lanes|=n,c=i.alternate,c!==null&&(c.lanes|=n),zw(i.return,n,s),l.lanes|=n;break}c=c.next}}else if(i.tag===10)o=i.type===s.type?null:i.child;else if(i.tag===18){if(o=i.return,o===null)throw Error(Ae(341));o.lanes|=n,l=o.alternate,l!==null&&(l.lanes|=n),zw(o,n,s),o=i.sibling}else o=i.child;if(o!==null)o.return=i;else for(o=i;o!==null;){if(o===s){o=null;break}if(i=o.sibling,i!==null){i.return=o.return,o=i;break}o=o.return}i=o}Hn(t,s,r.children,n),s=s.child}return s;case 9:return r=s.type,a=s.pendingProps.children,Ju(s,n),r=br(r),a=a(r),s.flags|=1,Hn(t,s,a,n),s.child;case 14:return a=s.type,r=Br(a,s.pendingProps),r=Br(a.type,r),jS(t,s,a,r,n);case 15:return yT(t,s,s.type,s.pendingProps,n);case 17:return a=s.type,r=s.pendingProps,r=s.elementType===a?r:Br(a,r),n0(t,s),s.tag=1,ya(a)?(t=!0,cy(s)):t=!1,Ju(s,n),xT(s,a,r),Ow(s,a,r,n),Uw(null,
vendor: 6,813 bytes, line 41
41s,a,!0,t,n);case 19:return NT(t,s,n);case 22:return bT(t,s,n)}throw Error(Ae(156,s.tag))};function OT(t,s){return m6(t,s)}function H7(t,s,n,a){this.tag=t,this.key=n,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.ref=null,this.pendingProps=s,this.dependencies=this.memoizedState=this.updateQueue=this.memoizedProps=null,this.mode=a,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function fr(t,s,n,a){return new H7(t,s,n,a)}function D_(t){return t=t.prototype,!(!t||!t.isReactComponent)}function G7(t){if(typeof t=="function")return D_(t)?1:0;if(t!=null){if(t=t.$$typeof,t===JN)return 11;if(t===XN)return 14}return 2}function Ol(t,s){var n=t.alternate;return n===null?(n=fr(t.tag,s,t.key,t.mode),n.elementType=t.elementType,n.type=t.type,n.stateNode=t.stateNode,n.alternate=t,t.alternate=n):(n.pendingProps=s,n.type=t.type,n.flags=0,n.subtreeFlags=0,n.deletions=null),n.flags=t.flags&14680064,n.childLanes=t.childLanes,n.lanes=t.lanes,n.child=t.child,n.memoizedProps=t.memoizedProps,n.memoizedState=t.memoizedState,n.updateQueue=t.updateQueue,s=t.dependencies,n.dependencies=s===null?null:{lanes:s.lanes,firstContext:s.firstContext},n.sibling=t.sibling,n.index=t.index,n.ref=t.ref,n}function i0(t,s,n,a,r,i){var o=2;if(a=t,typeof t=="function")D_(t)&&(o=1);else if(typeof t=="string")o=5;else e:switch(t){case Fu:return xd(n.children,r,i,s);case QN:o=8,r|=8;break;case cw:return t=fr(12,n,s,r|2),t.elementType=cw,t.lanes=i,t;case dw:return t=fr(13,n,s,r),t.elementType=dw,t.lanes=i,t;case uw:return t=fr(19,n,s,r),t.elementType=uw,t.lanes=i,t;case YF:return Sb(n,r,i,s);default:if(typeof t=="object"&&t!==null)switch(t.$$typeof){case VF:o=10;break e;case ZF:o=9;break e;case JN:o=11;break e;case XN:o=14;break e;case xl:o=16,a=null;break e}throw Error(Ae(130,t==null?t:typeof t,""))}return s=fr(o,n,s,r),s.elementType=t,s.type=a,s.lanes=i,s}function xd(t,s,n,a){return t=fr(7,t,a,s),t.lanes=n,t}function Sb(t,s,n,a){return t=fr(22,t,a,s),t.elementType=YF,t.lanes=n,t.stateNode={isHidden:!1},t}function Q1(t,s,n){return t=fr(6,t,null,s),t.lanes=n,t}function J1(t,s,n){return s=fr(4,t.children!==null?t.children:[],t.key,s),s.lanes=n,s.stateNode={containerInfo:t.containerInfo,pendingChildren:null,implementation:t.implementation},s}function V7(t,s,n,a,r){this.tag=s,this.containerInfo=t,this.finishedWork=this.pingCache=this.current=this.pendingChildren=null,this.timeoutHandle=-1,this.callbackNode=this.pendingContext=this.context=null,this.callbackPriority=0,this.eventTimes=P1(0),this.expirationTimes=P1(-1),this.entangledLanes=this.finishedLanes=this.mutableReadLanes=this.expiredLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=P1(0),this.identifierPrefix=a,this.onRecoverableError=r,this.mutableSourceEagerHydrationData=null}function R_(t,s,n,a,r,i,o,l,c){return t=new V7(t,s,n,l,c),s===1?(s=1,i===!0&&(s|=8)):s=0,i=fr(3,null,null,s),t.current=i,i.stateNode=t,i.memoizedState={element:a,isDehydrated:n,cache:null,transitions:null,pendingSuspenseBoundaries:null},g_(i),t}function Z7(t,s,n){var a=3<arguments.length&&arguments[3]!==void 0?arguments[3]:null;return{$$typeof:Eu,key:a==null?null:""+a,children:t,containerInfo:s,implementation:n}}function MT(t){if(!t)return Hl;t=t._reactInternals;e:{if(Ld(t)!==t||t.tag!==1)throw Error(Ae(170));var s=t;do{switch(s.tag){case 3:s=s.stateNode.context;break e;case 1:if(ya(s.type)){s=s.stateNode.__reactInternalMemoizedMergedChildContext;break e}}s=s.return}while(s!==null);throw Error(Ae(171))}if(t.tag===1){var n=t.type;if(ya(n))return M6(t,n,s)}return s}function BT(t,s,n,a,r,i,o,l,c){return t=R_(n,a,!0,t,r,i,o,l,c),t.context=MT(null),n=t.current,a=ea(),r=Ll(n),i=jo(a,r),i.callback=s??null,$l(n,i,r),t.current.lanes=r,qx(t,r,a),ba(t,a),t}function Cb(t,s,n,a){var r=s.current,i=ea(),o=Ll(r);return n=MT(n),s.context===null?s.context=n:s.pendingContext=n,s=jo(i,o),s.payload={element:t},a=a===void 0?null:a,a!==null&&(s.callback=a),t=$l(r,s,o),t!==null&&(Qr(t,r,o,i),e0(t,r,o)),o}function wy(t){if(t=t.current,!t.child)return null;switch(t.child.tag){case 5:return t.child.stateNode;default:return t.child.stateNode}}function DS(t,s){if(t=t.memoizedState,t!==null&&t.dehydrated!==null){var n=t.retryLane;t.retryLane=n!==0&&n<s?n:s}}function I_(t,s){DS(t,s),(t=t.alternate)&&DS(t,s)}function Y7(){return null}var UT=typeof reportError=="function"?reportError:function(t){console.error(t)};function $_(t){this._internalRoot=t}Ab.prototype.render=$_.prototype.render=function(t){var s=this._internalRoot;if(s===null)throw Error(Ae(409));Cb(t,s,null,null)};Ab.prototype.unmount=$_.prototype.unmount=function(){var t=this._internalRoot;if(t!==null){this._internalRoot=null;var s=t.containerInfo;wd(function(){Cb(null,t,null,null)}),s[Co]=null}};function Ab(t){this._internalRoot=t}Ab.prototype.unstable_scheduleHydration=function(t){if(t){var s=b6();t={blockedOn:null,target:t,priority:s};for(var n=0;n<gl.length&&s!==0&&s<gl[n].priority;n++);gl.splice(n,0,t),n===0&&j6(t)}};function z_(t){return!(!t||t.nodeType!==1&&t.nodeType!==9&&t.nodeType!==11)}function Eb(t){return!(!t||t.nodeType!==1&&t.nodeType!==9&&t.nodeType!==11&&(t.nodeType!==8||t.nodeValue!==" react-mount-point-unstable "))}function RS(){}function K7(t,s,n,a,r){if(r){if(typeof a=="function"){var i=a;a=function(){var u=wy(o);i.call(u)}}var o=BT(s,a,t,0,null,!1,!1,"",RS);return t._reactRootContainer=o,t[Co]=o.current,Kh(t.nodeType===8?t.parentNode:t),wd(),o}for(;r=t.lastChild;)t.removeChild(r);if(typeof a=="function"){var l=a;a=function(){var u=wy(c);l.call(u)}}var c=R_(t,0,!1,null,null,!1,!1,"",RS);return t._reactRootContainer=c,t[Co]=c.current,Kh(t.nodeType===8?t.parentNode:t),wd(function(){Cb(s,c,n,a)}),c}function Fb(t,s,n,a,r){var i=n._reactRootContainer;if(i){var o=i;if(typeof r=="function"){var l=r;r=function(){var c=wy(o);l.call(c)}}Cb(s,o,t,r)}else o=K7(n,s,t,r,a);return wy(o)}g6=function(t){switch(t.tag){case 3:var s=t.stateNode;if(s.current.memoizedState.isDehydrated){var n=eh(s.pendingLanes);n!==0&&(s_(s,n|1),ba(s,Ds()),!(Ot&6)&&(Fm=Ds()+500,ac()))}break;case 13:wd(function(){var a=Ao(t,1);if(a!==null){var r=ea();Qr(a,t,1,r)}}),I_(t,1)}};n_=function(t){if(t.tag===13){var s=Ao(t,134217728);if(s!==null){var n=ea();Qr(s,t,134217728,n)}I_(t,134217728)}};y6=function(t){if(t.tag===13){var s=Ll(t),n=Ao(t,s);if(n!==null){var a=ea();Qr(n,t,s,a)}I_(t,s)}};b6=function(){return Zt};v6=function(t,s){var n=Zt;try{return Zt=t,s()}finally{Zt=n}};jw=function(t,s,n){switch(s){case"input":if(hw(t,n),s=n.name,n.type==="radio"&&s!=null){for(n=t;n.parentNode;)n=n.parentNode;for(n=n.querySelectorAll("input[name="+JSON.stringify(""+s)+'][type="radio"]'),s=0;s<n.length;s++){var a=n[s];if(a!==t&&a.form===t.form){var r=vb(a);if(!r)throw Error(Ae(90));
41QF(a),hw(a,r)}}}break;case"textarea":XF(t,n);break;case"select":s=n.value,s!=null&&Zu(t,!!n.multiple,s,!1)}};i6=F_;o6=wd;var Q7={usingClientEntryPoint:!1,Events:[Hx,Ru,vb,a6,r6,F_]},gp={findFiberByHostInstance:ed,bundleType:0,version:"18.3.1",rendererPackageName:"react-dom"},J7={bundleType:gp.bundleType,version:gp.version,rendererPackageName:gp.rendererPackageName,rendererConfig:gp.rendererConfig,overrideHookState:null,overrideHookStateDeletePath:null,overrideHookStateRenamePath:null,overrideProps:null,overridePropsDeletePath:null,overridePropsRenamePath:null,setErrorHandler:null,setSuspenseHandler:null,scheduleUpdate:null,currentDispatcherRef:Mo.ReactCurrentDispatcher,findHostInstanceByFiber:function(t){return t=d6(t),t===null?null:t.stateNode},findFiberByHostInstance:gp.findFiberByHostInstance||Y7,findHostInstancesForRefresh:null,scheduleRefresh:null,scheduleRoot:null,setRefreshHandler:null,getCurrentFiber:null,reconcilerVersion:"18.3.1-next-f1338f8080-20240426"};if(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"){var Af=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!Af.isDisabled&&Af.supportsFiber)try{fb=Af.inject(J7),Ti=Af}catch{}}Ha.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=Q7;Ha.createPortal=function(t,s){var n=2<arguments.length&&arguments[2]!==void 0?arguments[2]:null;if(!z_(s))throw Error(Ae(200));return Z7(t,s,null,n)};Ha.createRoot=function(t,s){if(!z_(t))throw Error(Ae(299));var n=!1,a="",r=UT;return s!=null&&(s.unstable_strictMode===!0&&(n=!0),s.identifierPrefix!==void 0&&(a=s.identifierPrefix),s.onRecoverableError!==void 0&&(r=s.onRecoverableError)),s=R_(t,1,!1,null,null,n,!1,a,r),t[Co]=s.current,Kh(t.nodeType===8?t.parentNode:t),new $_(s)};Ha.findDOMNode=function(t){if(t==null)return null;if(t.nodeType===1)return t;var s=t._reactInternals;if(s===void 0)throw typeof t.render=="function"?Error(Ae(188)):(t=Object.keys(t).join(","),Error(Ae(268,t)));return t=d6(s),t=t===null?null:t.stateNode,t};Ha.flushSync=function(t){return wd(t)};Ha.hydrate=function(t,s,n){if(!Eb(s))throw Error(Ae(200));return Fb(null,t,s,!0,n)};Ha.hydrateRoot=function(t,s,n){if(!z_(t))throw Error(Ae(405));var a=n!=null&&n.hydratedSources||null,r=!1,i="",o=UT;if(n!=null&&(n.unstable_strictMode===!0&&(r=!0),n.identifierPrefix!==void 0&&(i=n.identifierPrefix),n.onRecoverableError!==void 0&&(o=n.onRecoverableError)),s=BT(s,null,t,1,n??null,r,!1,i,o),t[Co]=s.current,Kh(t),a)for(t=0;t<a.length;t++)n=a[t],r=n._getVersion,r=r(n._source),s.mutableSourceEagerHydrationData==null?s.mutableSourceEagerHydrationData=[n,r]:s.mutableSourceEagerHydrationData.push(n,r);return new Ab(s)};Ha.render=function(t,s,n){if(!Eb(s))throw Error(Ae(200));return Fb(null,t,s,!1,n)};Ha.unmountComponentAtNode=function(t){if(!Eb(t))throw Error(Ae(40));return t._reactRootContainer?(wd(function(){Fb(null,null,t,!1,function(){t._reactRootContainer=null,t[Co]=null})}),!0):!1};Ha.unstable_batchedUpdates=F_;Ha.unstable_renderSubtreeIntoContainer=function(t,s,n,a){if(!Eb(n))throw Error(Ae(200));if(t==null||t._reactInternals===void 0)throw Error(Ae(38));return Fb(t,s,n,!1,a)};Ha.version="18.3.1-next-f1338f8080-20240426";function qT(){if(!(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(qT)}catch(t){console.error(t)}}qT(),qF.exports=Ha;var rc=qF.exports;const X7=qN(rc);var WT,IS=rc;WT=IS.createRoot,IS.hydrateRoot;const e9=1,t9=1e6;let X1=0;function s9(){return X1=(X1+1)%Number.MAX_SAFE_INTEGER,X1.toString()}const ev=new Map,$S=t=>{if(ev.has(t))return;const s=setTimeout(()=>{ev.delete(t),Ch({type:"REMOVE_TOAST",toastId:t})},t9);ev.set(t,s)},n9=(t,s)=>{switch(s.type){case"ADD_TOAST":return{...t,toasts:[s.toast,...t.toasts].slice(0,e9)};case"UPDATE_TOAST":return{...t,toasts:t.toasts.map(n=>n.id===s.toast.id?{...n,...s.toast}:n)};case"DISMISS_TOAST":{const{toastId:n}=s;return n?$S(n):t.toasts.forEach(a=>{$S(a.id)}),{...t,toasts:t.toasts.map(a=>a.id===n||n===void 0?{...a,open:!1}:a)}}case"REMOVE_TOAST":return s.toastId===void 0?{...t,toasts:[]}:{...t,toasts:t.toasts.filter(n=>n.id!==s.toastId)}}},o0=[];let l0={toasts:[]};function Ch(t){l0=n9(l0,t),o0.forEach(s=>{s(l0)})}function Wt({...t}){const s=s9(),n=r=>Ch({type:"UPDATE_TOAST",toast:{...r,id:s}}),a=()=>Ch({type:"DISMISS_TOAST",toastId:s}
41);return Ch({type:"ADD_TOAST",toast:{...t,id:s,open:!0,onOpenChange:r=>{r||a()}}}),{id:s,dismiss:a,update:n}}function a9(){const[t,s]=d.useState(l0);return d.useEffect(()=>(o0.push(s),()=>{const n=o0.indexOf(s);n>-1&&o0.splice(n,1)}),[t]),{...t,toast:Wt,dismiss:n=>Ch({type:"DISMISS_TOAST",toastId:n})}}var r9=Object.defineProperty,Gm=(t,s)=>r9(t,"name",{value:s,configurable:!0}),HT=!!(typeof window<"u"&&window.document&&window.document.createElement);function at(t,s,{checkForDefaultPrevented:n=!0}={}){return Gm(function(r){if(t==null||t(r),n===!1||!r||!r.defaultPrevented)return s==null?void 0:s(r)},"handleEvent")}Gm(at,"composeEventHandlers");function i9(t){var s;if(!HT)throw new Error("Cannot access window outside of the DOM");return((s=t==null?void 0:t.ownerDocument)==null?void 0:s.defaultView)??window}Gm(i9,"getOwnerWindow");function e2(t){if(!HT)throw new Error("Cannot access document outside of the DOM");return(t==null?void 0:t.ownerDocument)??document}Gm(e2,"getOwnerDocument");function GT(t,s=!1){const{activeElement:n}=e2(t);if(!(n!=null&&n.nodeName))return null;if(VT(n)&&n.contentDocument)return GT(n.contentDocument.body,s);if(s){const a=n.getAttribute("aria-activedescendant");if(a){const r=e2(n).getElementById(a);if(r)return r}}return n}Gm(GT,"getActiveElement");function VT(t){return t.tagName==="IFRAME"}Gm(VT,"isFrame");var o9=Object.defineProperty,L_=(t,s)=>o9(t,"name",{value:s,configurable:!0});function t2(t,s){if(typeof t=="function")return t(s);t!=null&&(t.current=s)}L_(t2,"setRef");function ZT(...t){return s=>{let n=!1;const a=t.map(r=>{const i=t2(r,s);return!n&&typeof i=="function"&&(n=!0),i});if(n)return()=>{for(let r=0;r<a.length;r++){const i=a[r];typeof i=="function"?i():t2(t[r],null)}}}}L_(ZT,"composeRefs");function It(...t){return d.useCallback(ZT(...t),t)}L_(It,"useComposedRefs");var l9=Object.defineProperty,xr=(t,s)=>l9(t,"name",{value:s,configurable:!0});function c9(t,s){const n=d.createContext(s);n.displayName=t+"Context";const a=xr(i=>{const{children:o,...l}=i,c=d.useMemo(()=>l,Object.values(l));return e.jsx(n.Provider,{value:c,children:o})},"Provider");a.displayName=t+"Provider";function r(i,o={}){const{optional:l=!1}=o,c=d.useContext(n);if(c)return c;if(s!==void 0)return s;if(!l)throw new Error(`\`${i}\` must be used within \`${t}\``)}return xr(r,"useContext"),[a,r]}xr(c9,"createContext");function Va(t,s=[]){let n=[];function a(i,o){const l=d.createContext(o);l.displayName=i+"Context";const c=n.length;n=[...n,o];const u=xr(m=>{var N;const{scope:x,children:h,...y}=m,v=((N=x==null?void 0:x[t])==null?void 0:N[c])||l,g=d.useMemo(()=>y,Object.values(y));return e.jsx(v.Provider,{value:g,children:h})},"Provider");u.displayName=i+"Provider";function p(m,x,h={}){var N;const{optional:y=!1}=h,v=((N=x==null?void 0:x[t])==null?void 0:N[c])||l,g=d.useContext(v);if(g)return g;if(o!==void 0)return o;if(!y)throw new Error(`\`${m}\` must be used within \`${i}\``)}return xr(p,"useContext"),[u,p]}xr(a,"createContext");const r=xr(()=>{const i=n.map(o=>d.createContext(o));return xr(function(l){const c=(l==null?void 0:l[t])||i;return d.useMemo(()=>({[`__scope${t}`]:{...l,[t]:c}}),[l,c])},"useScope")},"createScope");return r.scopeName=t,[a,YT(r,...s)]}xr(Va,"createContextScope");function YT(...t){const s=t[0];if(t.length===1)return s;const n=xr(()=>{const a=t.map(r=>({useScope:r(),scopeName:r.scopeName}));return xr(function(i){const o=a.reduce((l,{useScope:c,scopeName:u})=>{const m=c(i)[`__scope${u}`];return{...l,...m}},{});return d.useMemo(()=>({[`__scope${s.scopeName}`]:o}),[o])},"useComposedScopes")},"createScope");return n.scopeName=s.scopeName,n}xr(YT,"composeContextScopes");var d9=Object.defineProperty,ni=(t,s)=>d9(t,"name",{value:s,configurable:!0});function Fo(t){const s=d.forwardRef((n,a)=>{let{children:r,...i}=n,o=null,l=!1;const c=[];s2(r)&&typeof Ef=="function"&&(r=Ef(r._payload)),d.Children.forEach(r,x=>{var h;if(eP(x)){l=!0;const y=x;let v="child"in y.props?y.props.child:y.props.children;s2(v)&&typeof Ef=="function"&&(v=Ef(v._payload)),o=m9(y,v),c.push((h=o==null?void 0:o.props)==null?void 0:h.children)}else c.push(x)}),o?o=d.cloneElement(o,void 0,c):!l&&d.Children.count(r)===1&&d.isValidElement(r)&&(o=r);const u=o?XT(o):void 0,p=It(a,u);if(!o){if(r||r===0)throw new Error(l?x9(t):h9(t));return r}const m=JT(i,o.props??{});return o.type!==d.Fragment&&(m.ref=a?p:u),d.cloneElement(o,m)});return s.displayName=`${t}.Slot`,s}ni(Fo,"createSlot");var u9=Fo("Slot"),KT=Symbol.for("radix.slottable");function QT(t){const s=ni(n=>"child"in n?n.children(n.child):n.children,"Slottable");return s.displayName=`${t}.Slottable`,s.__radixId=KT,s}ni(QT,"createSlottable");var m9=ni((t,s)=>{if("child"in t.props){const n=t.props.child;return d.isValidElement(n)?d.cloneElement(n,void 0,t.props.children(n.props.children)):null}return d.isValidElement(s)?s:null},"getSlottableElementFromSlottable");function JT(t,s){const n={...s};for(const a in s){const r=t[a],i=s[a];/^on[A-Z]/.test(a)?r&&i?n[a]=(...l)=>{const c=i(...l);return r(...l),c}:r&&(n[a]=r):a==="style"?n[a]={...r,...i}
41:a==="className"&&(n[a]=[r,i].filter(Boolean).join(" "))}return{...t,...n}}ni(JT,"mergeProps");function XT(t){var a,r;let s=(a=Object.getOwnPropertyDescriptor(t.props,"ref"))==null?void 0:a.get,n=s&&"isReactWarning"in s&&s.isReactWarning;return n?t.ref:(s=(r=Object.getOwnPropertyDescriptor(t,"ref"))==null?void 0:r.get,n=s&&"isReactWarning"in s&&s.isReactWarning,n?t.props.ref:t.props.ref||t.ref)}ni(XT,"getElementRef");function eP(t){return d.isValidElement(t)&&typeof t.type=="function"&&"__radixId"in t.type&&t.type.__radixId===KT}ni(eP,"isSlottable");var p9=Symbol.for("react.lazy");function s2(t){return t!=null&&typeof t=="object"&&"$$typeof"in t&&t.$$typeof===p9&&"_payload"in t&&tP(t._payload)}ni(s2,"isLazyComponent");function tP(t){return typeof t=="object"&&t!==null&&"then"in t}ni(tP,"isPromiseLike");var h9=ni(t=>`${t} failed to slot onto its children. Expected a single React element child or \`Slottable\`.`,"createSlotError"),x9=ni(t=>`${t} failed to slot onto its \`Slottable\`. Expected \`Slottable\` to receive a single React element child.`,"createSlottableError"),Ef=$d[" use ".trim().toString()],f9=Object.defineProperty,dn=(t,s)=>f9(t,"name",{value:s,configurable:!0});function Tb(t){const s=t+"CollectionProvider",[n,a]=Va(s),[r,i]=n(s,{collectionRef:{current:null},itemMap:new Map}),o=dn(v=>{const{scope:g,children:N}=v,b=d.useRef(null),f=d.useRef(new Map).current;return e.jsx(r,{scope:g,itemMap:f,collectionRef:b,children:N})},"CollectionProvider");o.displayName=s;const l=t+"CollectionSlot",c=Fo(l),u=d.forwardRef((v,g)=>{const{scope:N,children:b}=v,f=i(l,N),j=It(g,f.collectionRef);return e.jsx(c,{ref:j,children:b})});u.displayName=l;const p=t+"CollectionItemSlot",m="data-radix-collection-item",x=Fo(p),h=d.forwardRef((v,g)=>{const{scope:N,children:b,...f}=v,j=d.useRef(null),S=It(g,j),w=i(p,N);return d.useEffect(()=>(w.itemMap.set(j,{ref:j,...f}),()=>void w.itemMap.delete(j))),e.jsx(x,{[m]:"",ref:S,children:b})});h.displayName=p;function y(v){const g=i(t+"CollectionConsumer",v);return d.useCallback(()=>{const b=g.collectionRef.current;if(!b)return[];const f=Array.from(b.querySelectorAll(`[${m}]`));return Array.from(g.itemMap.values()).sort((w,_)=>f.indexOf(w.ref.current)-f.indexOf(_.ref.current))},[g.collectionRef,g.itemMap])}return dn(y,"useCollection"),[{Provider:o,Slot:u,ItemSlot:h},y,a]}dn(Tb,"createCollection");var zS=new WeakMap,Ms,Da,tv=(Da=class extends Map{constructor(n){super(n);St(this,Ms);ct(this,Ms,[...super.keys()]),zS.set(this,!0)}set(n,a){return zS.get(this)&&(this.has(n)?he(this,Ms)[he(this,Ms).indexOf(n)]=n:he(this,Ms).push(n)),super.set(n,a),this}insert(n,a,r){const i=this.has(a),o=he(this,Ms).length,l=O_(n);let c=l>=0?l:o+l;const u=c<0||c>=o?-1:c;if(u===this.size||i&&u===this.size-1||u===-1)return this.set(a,r),this;const p=this.size+(i?0:1);l<0&&c++;const m=[...he(this,Ms)];let x,h=!1;for(let y=c;y<p;y++)if(c===y){let v=m[y];m[y]===a&&(v=m[y+1]),i&&this.delete(a),x=this.get(v),this.set(a,r)}else{!h&&m[y-1]===a&&(h=!0);const v=m[h?y:y-1],g=x;x=this.get(v),this.delete(v),this.set(v,g)}return this}with(n,a,r){const i=new Da(this);return i.insert(n,a,r),i}before(n){const a=he(this,Ms).indexOf(n)-1;if(!(a<0))return this.entryAt(a)}setBefore(n,a,r){const i=he(this,Ms).indexOf(n);return i===-1?this:this.insert(i,a,r)}after(n){let a=he(this,Ms).indexOf(n);if(a=a===-1||a===this.size-1?-1:a+1,a!==-1)return this.entryAt(a)}setAfter(n,a,r){const i=he(this,Ms).indexOf(n);return i===-1?this:this.insert(i+1,a,r)}first(){return this.entryAt(0)}last(){return this.entryAt(-1)}clear(){return ct(this,Ms,[]),super.clear()}delete(n){const a=super.delete(n);return a&&he(this,Ms).splice(he(this,Ms).indexOf(n),1),a}deleteAt(n){const a=this.keyAt(n);return a!==void 0?this.delete(a):!1}at(n){const a=c0(he(this,Ms),n);if(a!==void 0)return this.get(a)}entryAt(n){const a=c0(he(this,Ms),n);if(a!==void 0)return[a,this.get(a)]}indexOf(n){return he(this,Ms).indexOf(n)}keyAt(n){return c0(he(this,Ms),n)}from(n,a){const r=this.indexOf(n);if(r===-1)return;let i=r+a;return i<0&&(i=0),i>=this.size&&(i=this.size-1),this.at(i)}keyFrom(n,a){const r=this.indexOf(n);if(r===-1)return;let i=r+a;return i<0&&(i=0),i>=this.size&&(i=this.size-1),this.keyAt(i)}find(n,a){let r=0;for(const i of this){if(Reflect.apply(n,a,[i,r,this]))return i;r++}}findIndex(n,a){let r=0;for(const i of this){if(Reflect.apply(n,a,[i,r,this]))return r;r++}return-1}filter(n,a){const r=[];let i=0;for(const o of this)Reflect.apply(n,a,[o,i,this])&&r.push(o),i++;return new Da(r)}map(n,a){const r=[];let i=0;for(const o of this)r.push([o[0],Reflect.apply(n,a,[o,i,this])]),i++;return new Da(r)}reduce(...n){const[a,r]=n;let i=0,o=r??this.at(0);for(const l of this)i===0&&n.length===1?o=l:o=Reflect.apply(a,this,[o,l,i,this]),i++;return o}reduceRight(...n){const[a,r]=n;let i=r??this.at(-1);for(let o=this.size-1;o>=0;o--){const l=this.at(o);o===this.size-1&&n.length===1?i=l:i=Reflect.apply(a,this,[i,l,o,this])}return i}toSorted(n){const a=[...this.entries()].sort(n);return new Da(a)}toReversed(){const n=new Da;for(let a=this.size-1;a>=0;a--){const r=this.keyAt(a),i=this.get(r);n.set(r,i)}return n}toSpliced(...n){const a=[...this.entries()];return a.splice(...n),new Da(a)}slice(n,a){const r=new Da;let i=this.size-1;if(n===void 0)return r;n<0&&(n=n+this.size),a!==void 0&&a>0&&(i=a-1);for(let o=n;o<=i;o++){const l=this.keyAt(o),c=this.get(l);r.set(l,c)}return r}every(n,a){let r=0;for(const i of this){if(!Reflect.apply(n,a,[i,r,this]))return!1;r++}return!0}some(n,a){let r=0;for(const i of this){if(Reflect.apply(n,a,[i,r,this]))return!0;r++}return!1}},Ms=new WeakMap,dn(Da,"OrderedDict"),Da);function c0(t,s){if("at"in Array.prototype)return Array.prototype.at.call(t,s);const n=sP(t,s);return n===-1?void 0:t[n]}dn(c0,"at");function sP(t,s){const n=t.length,a=O_(s),r=a>=0?a:n+a;return r<0||r>=n?-1:r}dn(sP,"toSafeIndex");function O_(t){return t!==t||t===0?0:Math.trunc(t)}dn(O_,"toSafeInteger");function g9(t){const s=t+"CollectionProvider",[n,a]=Va(s),[r,i]=n(s,{collectionElement:null,collectionRef:{current:null},collectionRefObject:{current:null},itemMap:new tv,setItemMap:dn(()=>{},"setItemMap")}),o=dn(({state:f,...j})=>f?e.jsx(c,{...j,state:f}):e.jsx(l,{...j}),"CollectionProvider");o.displayName=s;const l=dn(f=>
41{const j=g();return e.jsx(c,{...f,state:j})},"CollectionInit");l.displayName=s+"Init";const c=dn(f=>{const{scope:j,children:S,state:w}=f,_=d.useRef(null),[C,E]=d.useState(null),P=It(_,E),[F,I]=w;return d.useEffect(()=>{if(!C)return;const D=rP(()=>{});return D.observe(C,{childList:!0,subtree:!0}),()=>{D.disconnect()}},[C]),e.jsx(r,{scope:j,itemMap:F,setItemMap:I,collectionRef:P,collectionRefObject:_,collectionElement:C,children:S})},"CollectionProviderImpl");c.displayName=s+"Impl";const u=t+"CollectionSlot",p=Fo(u),m=d.forwardRef((f,j)=>{const{scope:S,children:w}=f,_=i(u,S),C=It(j,_.collectionRef);return e.jsx(p,{ref:C,children:w})});m.displayName=u;const x=t+"CollectionItemSlot",h="data-radix-collection-item",y=Fo(x),v=d.forwardRef((f,j)=>{const{scope:S,children:w,..._}=f,C=d.useRef(null),[E,P]=d.useState(null),F=It(j,C,P),I=i(x,S),{setItemMap:D}=I,L=d.useRef(_);nP(L.current,_)||(L.current=_);const V=L.current;return d.useEffect(()=>{const B=V;return D(A=>E?A.has(E)?A.set(E,{...B,element:E}).toSorted(n2):(A.set(E,{...B,element:E}),A.toSorted(n2)):A),()=>{D(A=>!E||!A.has(E)?A:(A.delete(E),new tv(A)))}},[E,V,D]),e.jsx(y,{[h]:"",ref:F,children:w})});v.displayName=x;function g(){return d.useState(new tv)}dn(g,"useInitCollection");function N(f){const{itemMap:j}=i(t+"CollectionConsumer",f);return j}return dn(N,"useCollection"),[{Provider:o,Slot:m,ItemSlot:v},{createCollectionScope:a,useCollection:N,useInitCollection:g}]}dn(g9,"createCollection");function nP(t,s){if(t===s)return!0;if(typeof t!="object"||typeof s!="object"||t==null||s==null)return!1;const n=Object.keys(t),a=Object.keys(s);if(n.length!==a.length)return!1;for(const r of n)if(!Object.prototype.hasOwnProperty.call(s,r)||t[r]!==s[r])return!1;return!0}dn(nP,"shallowEqual");function aP(t,s){return!!(s.compareDocumentPosition(t)&Node.DOCUMENT_POSITION_PRECEDING)}dn(aP,"isElementPreceding");function n2(t,s){return!t[1].element||!s[1].element?0:aP(t[1].element,s[1].element)?-1:1}dn(n2,"sortByDocumentPosition");function rP(t){return new MutationObserver(n=>{for(const a of n)if(a.type==="childList"){t();return}})}dn(rP,"getChildListObserver");var y9=Object.defineProperty,b9=(t,s)=>y9(t,"name",{value:s,configurable:!0}),v9=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],yt=v9.reduce((t,s)=>{const n=Fo(`Primitive.${s}`),a=d.forwardRef((r,i)=>{const{asChild:o,...l}=r,c=o?n:s;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),e.jsx(c,{...l,ref:i})});return a.displayName=`Primitive.${s}`,{...t,[s]:a}},{});function M_(t,s){t&&rc.flushSync(()=>t.dispatchEvent(s))}b9(M_,"dispatchDiscreteCustomEvent");var j9=Object.defineProperty,w9=(t,s)=>j9(t,"name",{value:s,configurable:!0});function sa(t){const s=d.useRef(t);return d.useEffect(()=>{s.current=t}),d.useMemo(()=>(...n)=>{var a;return(a=s.current)==null?void 0:a.call(s,...n)},[])}w9(sa,"useCallbackRef");var N9=Object.defineProperty,Qs=(t,s)=>N9(t,"name",{value:s,configurable:!0}),a2="dismissableLayer.update",_9="dismissableLayer.pointerDownOutside",k9="dismissableLayer.focusOutside",LS,B_=d.createContext({layers:new Set,layersWithOutsidePointerEventsDisabled:new Set,branches:new Set,dismissableSurfaces:new Set}),Pb=d.forwardRef(Qs(function(s,n){const{disableOutsidePointerEvents:a=!1,deferPointerDownOutside:r=!1,onEscapeKeyDown:i,onPointerDownOutside:o,onFocusOutside:l,onInteractOutside:c,onDismiss:u,...p}=s,m=d.useContext(B_),[x,h]=d.useState(null),y=(x==null?void 0:x.ownerDocument)??(globalThis==null?void 0:globalThis.document),[,v]=d.useState({}),g=It(n,h),N=Array.from(m.layers),[b]=[...m.layersWithOutsidePointerEventsDisabled].slice(-1),f=b?N.indexOf(b):-1,j=x?N.indexOf(x):-1,S=m.layersWithOutsidePointerEventsDisabled.size>0,w=j>=f,_=d.useRef(!1),C=oP(I=>{o==null||o(I),c==null||c(I),I.defaultPrevented||u==null||u()},{ownerDocument:y,deferPointerDownOutside:r,isDeferredPointerDownOutsideRef:_,dismissableSurfaces:m.dismissableSurfaces,shouldHandlePointerDownOutside:d.useCallback(I=>{if(!(I instanceof Node))return!1;const D=[...m.branches].some(L=>L.contains(I));return w&&!D},[m.branches,w])}),E=lP(I=>{if(r&&_.current)return;const D=I.target;[...m.branches].some(V=>V.contains(D))||(l==null||l(I),c==null||c(I),I.defaultPrevented||u==null||u())},y),P=x?j===N.length-1:!1,F=sa(I=>{I.key==="Escape"&&(i==null||i(I),!I.defaultPrevented&&u&&(I.preventDefault(),u()))});return d.useEffect(()=>{if(P)return y.addEventListener("keydown",F,{capture:!0}),()=>y.removeEventListener("keydown",F,{capture:!0})},[y,P,F]),d.useEffect(()=>{if(x)return a&&(m.layersWithOutsidePointerEventsDisabled.size===0&&(LS=y.body.style.pointerEvents,y.body.style.pointerEvents="none"),m.layersWithOutsidePointerEventsDisabled.add(x)),m.layers.add(x),r2(),()=>{a&&(m.layersWithOutsidePointerEventsDisabled.delete(x),m.layersWithOutsidePointerEventsDisabled.size===0&&(y.body.style.pointerEvents=LS))}},[x,y,a,m]),d.useEffect(()=>()=>{x&&(m.layers.delete(x),m.layersWithOutsidePointerEventsDisabled.delete(x),r2())},[x,m]),d.useEffect(()=>{const I=Qs(()=>v({}),"handleUpdate");return document.addEventListener(a2,I),()=>document.removeEventListener(a2,I)},[]),e.jsx(yt.div,{...p,ref:g,style:{pointerEvents:S?w?"auto":"none":void 0,...s.style},onFocusCapture:at(s.onFocusCapture,E.onFocusCapture),onBlurCapture:at(s.onBlurCapture,E.onBlurCapture),onPointerDownCapture:at(s.onPointerDownCapture,C.onPointerDownCapture)})},"DismissableLayer")),S9=d.forwardRef(Qs(function(s,n){const a=d.useContext(B_),r=d.useRef(null),i=It(n,r);return d.useEffect(()=>{const o=r.current;if(o)return a.branches.add(o),()=>{a.branches.delete(o)}},[a.branches]),e.jsx(yt.div,{...s,ref:i})},"DismissableLayerBranch"));
41function iP(){const t=d.useContext(B_),[s,n]=d.useState(null);return d.useEffect(()=>{if(s)return t.dismissableSurfaces.add(s),()=>{t.dismissableSurfaces.delete(s)}},[s,t.dismissableSurfaces]),n}Qs(iP,"useDismissableLayerSurface");var C9=Qs(()=>!0,"IS_TRUE");function oP(t,s){const{ownerDocument:n=globalThis==null?void 0:globalThis.document,deferPointerDownOutside:a=!1,isDeferredPointerDownOutsideRef:r,dismissableSurfaces:i,shouldHandlePointerDownOutside:o=C9}=s,l=sa(t),c=d.useRef(!1),u=d.useRef(!1),p=d.useRef(new Map),m=d.useRef(()=>{});return d.useEffect(()=>{function x(){u.current=!1,r.current=!1,p.current.clear()}Qs(x,"resetOutsideInteraction");function h(){return Array.from(p.current.values()).some(Boolean)}Qs(h,"isOutsideInteractionIntercepted");function y(f){if(!u.current)return;const j=f.target;j instanceof Node&&[...i].some(w=>w.contains(j))||p.current.set(f.type,!0),f.type==="click"&&window.setTimeout(()=>{u.current&&m.current()},0)}Qs(y,"handleInteractionCapture");function v(f){u.current&&p.current.set(f.type,!1)}Qs(v,"handleInteractionBubble");const g=Qs(f=>{if(f.target&&!c.current){let j=function(){n.removeEventListener("click",m.current);const w=h();x(),w||U_(_9,l,S,{discrete:!0})};if(Qs(j,"handleAndDispatchPointerDownOutsideEvent"),!o(f.target)){n.removeEventListener("click",m.current),x(),c.current=!1;return}const S={originalEvent:f};u.current=!0,r.current=a&&f.button===0,p.current.clear(),!a||f.button!==0?j():(n.removeEventListener("click",m.current),m.current=j,n.addEventListener("click",m.current,{once:!0}))}else n.removeEventListener("click",m.current),x();c.current=!1},"handlePointerDown"),N=["pointerup","mousedown","mouseup","touchstart","touchend","click"];for(const f of N)n.addEventListener(f,y,!0),n.addEventListener(f,v);const b=window.setTimeout(()=>{n.addEventListener("pointerdown",g)},0);return()=>{window.clearTimeout(b),n.removeEventListener("pointerdown",g),n.removeEventListener("click",m.current);for(const f of N)n.removeEventListener(f,y,!0),n.removeEventListener(f,v)}},[n,l,a,r,i,o]),{onPointerDownCapture:Qs(()=>c.current=!0,"onPointerDownCapture")}}Qs(oP,"usePointerDownOutside");function lP(t,s=globalThis==null?void 0:globalThis.document){const n=sa(t),a=d.useRef(!1);return d.useEffect(()=>{const r=Qs(i=>{i.target&&!a.current&&U_(k9,n,{originalEvent:i},{discrete:!1})},"handleFocus");return s.addEventListener("focusin",r),()=>s.removeEventListener("focusin",r)},[s,n]),{onFocusCapture:Qs(()=>a.current=!0,"onFocusCapture"),onBlurCapture:Qs(()=>a.current=!1,"onBlurCapture")}}Qs(lP,"useFocusOutside");function r2(){const t=new CustomEvent(a2);document.dispatchEvent(t)}Qs(r2,"dispatchUpdate");function U_(t,s,n,{discrete:a}){const r=n.originalEvent.target,i=new CustomEvent(t,{bubbles:!1,cancelable:!0,detail:n});s&&r.addEventListener(t,s,{once:!0}),a?M_(r,i):r.dispatchEvent(i)}Qs(U_,"handleAndDispatchCustomEvent");var A9=Pb,E9=S9,vs=globalThis!=null&&globalThis.document?d.useLayoutEffect:()=>{},F9=Object.defineProperty,T9=(t,s)=>F9(t,"name",{value:s,configurable:!0}),q_=d.forwardRef(T9(function(s,n){var c;const{container:a,...r}=s,[i,o]=d.useState(!1);vs(()=>o(!0),[]);const l=a||i&&((c=globalThis==null?void 0:globalThis.document)==null?void 0:c.body);return l?rc.createPortal(e.jsx(yt.div,{...r,ref:n}),l):null},"Portal")),P9=Object.defineProperty,To=(t,s)=>P9(t,"name",{value:s,configurable:!0});function cP(t,s){return d.useReducer((n,a)=>s[n][a]??n,t)}To(cP,"useStateMachine");var ic=To(t=>{const{present:s,children:n}=t,a=dP(s),r=typeof n=="function"?n({present:a.isPresent}):d.Children.only(n),i=uP(a.ref,mP(r));return typeof n=="function"||a.isPresent?d.cloneElement(r,{ref:i}):null},"Presence");function dP(t){const[s,n]=d.useState(),a=d.useRef(null),r=d.useRef(t),i=d.useRef("none"),o=d.useRef(void 0),l=t?"mounted":"unmounted",[c,u]=cP(l,{mounted:{UNMOUNT:"unmounted",ANIMATION_OUT:"unmountSuspended"},unmountSuspended:{MOUNT:"mounted",ANIMATION_END:"unmounted"},unmounted:{MOUNT:"mounted"}});return d.useEffect(()=>{c==="mounted"?(i.current=o.current??wu(a.current),o.current=void 0):i.current="none"},[c]),vs(()=>{const p=a.current,m=r.current;if(m!==t){const h=i.current,y=wu(p);t?(o.current=y,u("MOUNT")):y==="none"||(p==null?void 0:p.display)==="none"?u("UNMOUNT"):u(m&&h!==y?"ANIMATION_OUT":"UNMOUNT"),r.current=t}},[t,u]),vs(()=>
41{if(s){let p;const m=s.ownerDocument.defaultView??window,x=To(y=>{const g=wu(a.current).includes(CSS.escape(y.animationName));if(y.target===s&&g&&(u("ANIMATION_END"),!r.current)){const N=s.style.animationFillMode;s.style.animationFillMode="forwards",p=m.setTimeout(()=>{s.style.animationFillMode==="forwards"&&(s.style.animationFillMode=N)})}},"handleAnimationEnd"),h=To(y=>{y.target===s&&(i.current=wu(a.current))},"handleAnimationStart");return s.addEventListener("animationstart",h),s.addEventListener("animationcancel",x),s.addEventListener("animationend",x),()=>{m.clearTimeout(p),s.removeEventListener("animationstart",h),s.removeEventListener("animationcancel",x),s.removeEventListener("animationend",x)}}else u("ANIMATION_END")},[s,u]),{isPresent:["mounted","unmountSuspended"].includes(c),ref:d.useCallback(p=>{if(p){const m=getComputedStyle(p);a.current=m,o.current=wu(m)}else a.current=null;n(p)},[])}}To(dP,"usePresence");function i2(t,s){if(typeof t=="function")return t(s);t!=null&&(t.current=s)}To(i2,"setRef");function uP(...t){const s=d.useRef(t);return s.current=t,d.useCallback(n=>{const a=s.current;let r=!1;const i=a.map(o=>{const l=i2(o,n);return!r&&typeof l=="function"&&(r=!0),l});if(r)return()=>{for(let o=0;o<i.length;o++){const l=i[o];typeof l=="function"?l():i2(a[o],null)}}},[])}To(uP,"useStableComposedRefs");function wu(t){return(t==null?void 0:t.animationName)||"none"}To(wu,"getAnimationName");function mP(t){var a,r;let s=(a=Object.getOwnPropertyDescriptor(t.props,"ref"))==null?void 0:a.get,n=s&&"isReactWarning"in s&&s.isReactWarning;return n?t.ref:(s=(r=Object.getOwnPropertyDescriptor(t,"ref"))==null?void 0:r.get,n=s&&"isReactWarning"in s&&s.isReactWarning,n?t.props.ref:t.props.ref||t.ref)}To(mP,"getElementRef");var D9=Object.defineProperty,R9=(t,s)=>D9(t,"name",{value:s,configurable:!0}),OS=$d[" useEffectEvent ".trim().toString()],MS=$d[" useInsertionEffect ".trim().toString()];function pP(t){if(typeof OS=="function")return OS(t);const s=d.useRef(()=>{throw new Error("Cannot call an event handler while rendering.")});return typeof MS=="function"?MS(()=>{s.current=t}):vs(()=>{s.current=t}),d.useMemo(()=>(...n)=>{var a;return(a=s.current)==null?void 0:a.call(s,...n)},[])}R9(pP,"useEffectEvent");var I9=Object.defineProperty,Vx=(t,s)=>I9(t,"name",{value:s,configurable:!0}),$9=$d[" useInsertionEffect ".trim().toString()]||vs;function Po({prop:t,defaultProp:s,onChange:n=Vx(()=>{},"onChange"),caller:a}){const[r,i,o]=hP({defaultProp:s,onChange:n}),l=t!==void 0,c=l?t:r,u=d.useCallback(p=>{var m;if(l){const x=xP(p)?p(t):p;x!==t&&((m=o.current)==null||m.call(o,x))}else i(p)},[l,t,i,o]);return[c,u]}Vx(Po,"useControllableState");function hP({defaultProp:t,onChange:s}){const[n,a]=d.useState(t),r=d.useRef(n),i=d.useRef(s);return $9(()=>{i.current=s},[s]),d.useEffect(()=>{var o;r.current!==n&&((o=i.current)==null||o.call(i,n),r.current=n)},[n,r]),[n,a,i]}Vx(hP,"useUncontrolledState");function xP(t){return typeof t=="function"}Vx(xP,"isFunction");var BS=Symbol("RADIX:SYNC_STATE");function z9(t,s,n,a){const{prop:r,defaultProp:i,onChange:o,caller:l}=s,c=r!==void 0,u=pP(o),p=[{...n,state:i}];a&&p.push(a);const[m,x]=d.useReducer((g,N)=>{if(N.type===BS)return{...g,state:N.state};const b=t(g,N);return c&&!Object.is(b.state,g.state)&&u(b.state),b},...p),h=m.state,y=d.useRef(h);d.useEffect(()=>{y.current!==h&&(y.current=h,c||u(h))},[h,y,c]);const v=d.useMemo(()=>r!==void 0?{...m,state:r}:m,[m,r]);return d.useEffect(()=>{c&&!Object.is(r,m.state)&&x({type:BS,state:r})},[r,m.state,c]),[v,x]}Vx(z9,"useControllableStateReducer");var L9=Object.defineProperty,O9=(t,s)=>L9(t,"name",{value:s,configurable:!0}),fP=Object.freeze({position:"absolute",border:0,width:1,height:1,padding:0,margin:-1,overflow:"hidden",clip:"rect(0, 0, 0, 0)",whiteSpace:"nowrap",wordWrap:"normal"}),W_=d.forwardRef(O9(function(s,n){return e.jsx(yt.span,{...s,ref:n,style:{...fP,...s.style}})},"VisuallyHidden")),M9=W_,B9=Object.defineProperty,es=(t,s)=>B9(t,"name",{value:s,configurable:!0}),gP="ToastProvider",[H_,yP,U9]=Tb("Toast"),[bP,Fhe]=Va("Toast",[U9]),[q9,Db]=bP(gP),W9=es(t=>
41{const{__scopeToast:s,label:n="Notification",duration:a=5e3,swipeDirection:r="right",swipeThreshold:i=50,announcerContainer:o,children:l}=t,[c,u]=d.useState(null),[p,m]=d.useState(0),x=d.useRef(!1);return n.trim()||console.error(`Invalid prop \`label\` supplied to \`${gP}\`. Expected non-empty \`string\`.`),e.jsx(H_.Provider,{scope:s,children:e.jsx(q9,{scope:s,label:n,duration:a,swipeDirection:r,swipeThreshold:i,toastCount:p,viewport:c,onViewportChange:u,onToastAdd:d.useCallback(()=>m(h=>h+1),[]),onToastRemove:d.useCallback(()=>m(h=>h-1),[]),isClosePausedRef:x,announcerContainer:o,children:l})})},"ToastProvider"),H9="ToastViewport",G9=["F8"],o2="toast.viewportPause",l2="toast.viewportResume",V9=d.forwardRef(es(function(s,n){const{__scopeToast:a,hotkey:r=G9,label:i="Notifications ({hotkey})",...o}=s,l=Db(H9,a),c=yP(a),u=d.useRef(null),p=d.useRef(null),m=d.useRef(null),x=d.useRef(null),h=It(n,x,l.onViewportChange),y=r.join("+").replace(/Key/g,"").replace(/Digit/g,""),v=l.toastCount>0;d.useEffect(()=>{const N=es(b=>{var j;r.length!==0&&r.every(S=>b[S]||b.code===S)&&((j=x.current)==null||j.focus())},"handleKeyDown");return document.addEventListener("keydown",N),()=>document.removeEventListener("keydown",N)},[r]),d.useEffect(()=>{const N=u.current,b=x.current;if(v&&N&&b){const f=es(()=>{if(!l.isClosePausedRef.current){const _=new CustomEvent(o2);b.dispatchEvent(_),l.isClosePausedRef.current=!0}},"handlePause"),j=es(()=>{if(l.isClosePausedRef.current){const _=new CustomEvent(l2);b.dispatchEvent(_),l.isClosePausedRef.current=!1}},"handleResume"),S=es(_=>{!N.contains(_.relatedTarget)&&j()},"handleFocusOutResume"),w=es(()=>{N.contains(document.activeElement)||j()},"handlePointerLeaveResume");return N.addEventListener("focusin",f),N.addEventListener("focusout",S),N.addEventListener("pointermove",f),N.addEventListener("pointerleave",w),window.addEventListener("blur",f),window.addEventListener("focus",j),()=>{N.removeEventListener("focusin",f),N.removeEventListener("focusout",S),N.removeEventListener("pointermove",f),N.removeEventListener("pointerleave",w),window.removeEventListener("blur",f),window.removeEventListener("focus",j)}}},[v,l.isClosePausedRef]);const g=d.useCallback(({tabbingDirection:N})=>{const f=c().map(j=>{const S=j.ref.current,w=[S,..._P(S)];return N==="forwards"?w:w.reverse()});return(N==="forwards"?f.reverse():f).flat()},[c]);return d.useEffect(()=>{const N=x.current;if(N){const b=es(f=>{var w,_,C;const j=f.altKey||f.ctrlKey||f.metaKey;if(f.key==="Tab"&&!j){const E=document.activeElement,P=f.shiftKey;if(f.target===N&&P){(w=p.current)==null||w.focus();return}const D=g({tabbingDirection:P?"backwards":"forwards"}),L=D.findIndex(V=>V===E);d0(D.slice(L+1))?f.preventDefault():P?(_=p.current)==null||_.focus():(C=m.current)==null||C.focus()}},"handleKeyDown");return N.addEventListener("keydown",b),()=>N.removeEventListener("keydown",b)}},[c,g]),e.jsxs(E9,{ref:u,role:"region","aria-label":i.replace("{hotkey}",y),tabIndex:-1,style:{pointerEvents:v?void 0:"none"},children:[v&&e.jsx(US,{ref:p,onFocusFromOutsideViewport:()=>{const N=g({tabbingDirection:"forwards"});d0(N)}}),e.jsx(H_.Slot,{scope:a,children:e.jsx(yt.ol,{tabIndex:-1,...o,ref:h})}),v&&e.jsx(US,{ref:m,onFocusFromOutsideViewport:()=>{const N=g({tabbingDirection:"backwards"});d0(N)}})]})},"ToastViewport")),Z9="ToastFocusProxy",US=d.forwardRef(es(function(s,n){const{__scopeToast:a,onFocusFromOutsideViewport:r,...i}=s,o=Db(Z9,a);return e.jsx(W_,{tabIndex:0,...i,ref:n,style:{position:"fixed"},onFocus:l=>{var p;const c=l.relatedTarget;!((p=o.viewport)!=null&&p.contains(c))&&r()}})},"ToastFocusProxy")),Rb="Toast",Y9="toast.swipeStart",K9="toast.swipeMove",Q9="toast.swipeCancel",J9="toast.swipeEnd",X9=d.forwardRef(es(function(s,n){const{forceMount:a,open:r,defaultOpen:i,onOpenChange:o,...l}=s,[c,u]=Po({prop:r,defaultProp:i??!0,onChange:o,caller:Rb});return e.jsx(ic,{present:a||c,children:e.jsx(sO,{open:c,...l,ref:n,onClose:()=>u(!1),onPause:sa(s.onPause),onResume:sa(s.onResume),onSwipeStart:at(s.onSwipeStart,p=>{p.currentTarget.setAttribute("data-swipe","start")}),onSwipeMove:at(s.onSwipeMove,p=>{const{x:m,y:x}=p.detail.delta;p.currentTarget.setAttribute("data-swipe","move"),p.currentTarget.style.setProperty("--radix-toast-swipe-move-x",`${m}px`),p.currentTarget.style.setProperty("--radix-toast-swipe-move-y",`${x}px`)}),onSwipeCancel:at(s.onSwipeCancel,p=>{p.currentTarget.setAttribute("data-swipe","cancel"),p.currentTarget.style.removeProperty("--radix-toast-swipe-move-x"),p.currentTarget.style.removeProperty("--radix-toast-swipe-move-y"),p.currentTarget.style.removeProperty("--radix-toast-swipe-end-x"),p.currentTarget.style.removeProperty("--radix-toast-swipe-end-y")}),onSwipeEnd:at(s.onSwipeEnd,p=>{const{x:m,y:x}=p.detail.delta;p.currentTarget.setAttribute("data-swipe","end"),p.currentTarget.style.removeProperty("--radix-toast-swipe-move-x"),p.currentTarget.style.removeProperty("--radix-toast-swipe-move-y"),p.currentTarget.style.setProperty("--radix-toast-swipe-end-x",`${m}px`),p.currentTarget.style.setProperty("--radix-toast-swipe-end-y",`${x}px`),u(!1)})})})},"Toast")),[eO,tO]=bP(Rb,{onClose(){}}),sO=d.forwardRef(es(function(s,n){const{__scopeToast:a,type:r="foreground",duration:i,open:o,onClose:l,onEscapeKeyDown:c,onPause:u,onResume:p,onSwipeStart:m,onSwipeMove:x,onSwipeCancel:h,onSwipeEnd:y,...v}=s,g=Db(Rb,a),N=yP(a),[b,f]=d.useState(null),j=It(n,f),S=d.useRef(null),w=d.useRef(null),_=i||g.duration,C=d.useRef(0),E=d.useRef(_),P=d.useRef(0),{onToastAdd:F,onToastRemove:I}=g,D=sa(()=>{var A;(b==null?void 0:b.contains(document.activeElement))&&((A=g.viewport)==null||A.focus()),l()}),L=d.useCallback(B=>
41{!B||B===1/0||(window.clearTimeout(P.current),C.current=new Date().getTime(),P.current=window.setTimeout(D,B))},[D]);d.useEffect(()=>{const B=g.viewport;if(B){const A=es(()=>{L(E.current),p==null||p()},"handleResume"),z=es(()=>{const M=new Date().getTime()-C.current;E.current=E.current-M,window.clearTimeout(P.current),u==null||u()},"handlePause");return B.addEventListener(o2,z),B.addEventListener(l2,A),()=>{B.removeEventListener(o2,z),B.removeEventListener(l2,A)}}},[g.viewport,_,u,p,L]),d.useEffect(()=>{o&&!g.isClosePausedRef.current&&L(_)},[o,_,g.isClosePausedRef,L]),d.useEffect(()=>()=>{window.clearTimeout(P.current)},[]),d.useEffect(()=>(F(),()=>I()),[F,I]);const V=d.useMemo(()=>b?G_(b):null,[b]);return g.viewport?e.jsxs(e.Fragment,{children:[V&&e.jsx(nO,{__scopeToast:a,role:"status","aria-live":r==="foreground"?"assertive":"polite",children:V}),e.jsx(eO,{scope:a,onClose:D,children:rc.createPortal(e.jsx(H_.ItemSlot,{scope:a,children:e.jsx(A9,{asChild:!0,onEscapeKeyDown:at(c,B=>{N().some(z=>{var M;return(M=z.ref.current)==null?void 0:M.contains(B.target)})||D()}),children:e.jsx(yt.li,{tabIndex:0,"data-state":o?"open":"closed","data-swipe-direction":g.swipeDirection,...v,ref:j,style:{userSelect:"none",touchAction:"none",...s.style},onKeyDown:at(s.onKeyDown,B=>{B.key==="Escape"&&(c==null||c(B.nativeEvent),B.nativeEvent.defaultPrevented||D())}),onPointerDown:at(s.onPointerDown,B=>{B.button===0&&(S.current={x:B.clientX,y:B.clientY})}),onPointerMove:at(s.onPointerMove,B=>{if(!S.current)return;const A=B.clientX-S.current.x,z=B.clientY-S.current.y,M=!!w.current,R=["left","right"].includes(g.swipeDirection),T=["left","up"].includes(g.swipeDirection)?Math.min:Math.max,U=R?T(0,A):0,q=R?0:T(0,z),H=B.pointerType==="touch"?10:2,G={x:U,y:q},W={originalEvent:B,delta:G};M?(w.current=G,sh(K9,x,W,{discrete:!1})):qS(G,g.swipeDirection,H)?(w.current=G,sh(Y9,m,W,{discrete:!1}),B.target.setPointerCapture(B.pointerId)):(Math.abs(A)>H||Math.abs(z)>H)&&(S.current=null)}),onPointerUp:at(s.onPointerUp,B=>{const A=w.current,z=B.target;if(z.hasPointerCapture(B.pointerId)&&z.releasePointerCapture(B.pointerId),w.current=null,S.current=null,A){const M=B.currentTarget,R={originalEvent:B,delta:A};qS(A,g.swipeDirection,g.swipeThreshold)?sh(J9,y,R,{discrete:!0}):sh(Q9,h,R,{discrete:!0}),M.addEventListener("click",T=>T.preventDefault(),{once:!0})}})})})}),g.viewport)})]}):null},"ToastImpl")),nO=es(t=>{const{__scopeToast:s,children:n,...a}=t,r=Db(Rb,s),[i,o]=d.useState(!1),[l,c]=d.useState(!1);return wP(()=>o(!0)),d.useEffect(()=>{const u=window.setTimeout(()=>c(!0),1e3);return()=>window.clearTimeout(u)},[]),l?null:e.jsx(q_,{asChild:!0,container:r.announcerContainer||void 0,children:e.jsx(W_,{...a,children:i&&e.jsxs(e.Fragment,{children:[r.label," ",n]})})})},"ToastAnnounce"),aO=d.forwardRef(es(function(s,n){const{__scopeToast:a,...r}=s;return e.jsx(yt.div,{...r,ref:n})},"ToastTitle")),rO=d.forwardRef(es(function(s,n){const{__scopeToast:a,...r}=s;return e.jsx(yt.div,{...r,ref:n})},"ToastDescription")),iO="ToastAction",oO=d.forwardRef(es(function(s,n){const{altText:a,...r}=s;return a.trim()?e.jsx(jP,{altText:a,asChild:!0,children:e.jsx(vP,{...r,ref:n})}):(console.error(`Invalid prop \`altText\` supplied to \`${iO}\`. Expected non-empty \`string\`.`),null)},"ToastAction")),lO="ToastClose",vP=d.forwardRef(es(function(s,n){const{__scopeToast:a,...r}=s,i=tO(lO,a);return e.jsx(jP,{asChild:!0,children:e.jsx(yt.button,{type:"button",...r,ref:n,onClick:at(s.onClick,i.onClose)})})},"ToastClose")),jP=d.forwardRef(es(function(s,n){const{__scopeToast:a,altText:r,...i}=s;return e.jsx(yt.div,{"data-radix-toast-announce-exclude":"","data-radix-toast-announce-alt":r||void 0,...i,ref:n})},"ToastAnnounceExclude"));function G_(t){const s=[];return Array.from(t.childNodes).forEach(a=>{if(a.nodeType===a.TEXT_NODE&&a.textContent&&s.push(a.textContent),NP(a)){const r=a.ariaHidden||a.hidden||a.style.display==="none",i=a.dataset.radixToastAnnounceExclude==="";if(!r)if(i){const o=a.dataset.radixToastAnnounceAlt;o&&s.push(o)}else s.push(...G_(a))}}),s}es(G_,"getAnnounceTextContent");function sh(t,s,n,{discrete:a}){const r=n.originalEvent.currentTarget,i=new CustomEvent(t,{bubbles:!0,cancelable:!0,detail:n});s&&r.addEventListener(t,s,{once:!0}),a?M_(r,i):r.dispatchEvent(i)}es(sh,"handleAndDispatchCustomEvent");var qS=es((t,s,n=0)=>{const a=Math.abs(t.x),r=Math.abs(t.y),i=a>r;return s==="left"||s==="right"?i&&a>n:!i&&r>n},"isDeltaInDirection");function wP(t=()=>{}){const s=sa(t);vs(()=>{let n=0,a=0;return n=window.requestAnimationFrame(()=>a=window.requestAnimationFrame(s)),()=>{window.cancelAnimationFrame(n),window.cancelAnimationFrame(a)}},[s])}es(wP,"useNextFrame");function NP(t){return t.nodeType===t.ELEMENT_NODE}es(NP,"isHTMLElement");function _P(t){const s=[],n=document.createTreeWalker(t,NodeFilter.SHOW_ELEMENT,{acceptNode:es(a=>{const r=a.tagName==="INPUT"&&a.type==="hidden";return a.disabled||a.hidden||r?NodeFilter.FILTER_SKIP:a.tabIndex>=0?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP},"acceptNode")});for(;n.nextNode();)s.push(n.currentNode);return s}es(_P,"getTabbableCandidates");function d0(t){const s=document.activeElement;return t.some(n=>n===s?!0:(n.focus(),document.activeElement!==s))}es(d0,"focusFirst");var cO=W9,kP=V9,SP=X9,CP=aO,AP=rO,EP=oO,FP=vP;function TP(t){var s,n,a="";if(typeof t=="string"||typeof t=="number")a+=t;else if(typeof t=="object")if(Array.isArray(t)){var r=t.length;for(s=0;s<r;
vendor: 9,646 bytes, lines 41-151
41s++)t[s]&&(n=TP(t[s]))&&(a&&(a+=" "),a+=n)}else for(n in t)t[n]&&(a&&(a+=" "),a+=n);return a}function PP(){for(var t,s,n=0,a="",r=arguments.length;n<r;n++)(t=arguments[n])&&(s=TP(t))&&(a&&(a+=" "),a+=s);return a}const WS=t=>typeof t=="boolean"?`${t}`:t===0?"0":t,HS=PP,Ib=(t,s)=>n=>{var a;if((s==null?void 0:s.variants)==null)return HS(t,n==null?void 0:n.class,n==null?void 0:n.className);const{variants:r,defaultVariants:i}=s,o=Object.keys(r).map(u=>{const p=n==null?void 0:n[u],m=i==null?void 0:i[u];if(p===null)return null;const x=WS(p)||WS(m);return r[u][x]}),l=n&&Object.entries(n).reduce((u,p)=>{let[m,x]=p;return x===void 0||(u[m]=x),u},{}),c=s==null||(a=s.compoundVariants)===null||a===void 0?void 0:a.reduce((u,p)=>{let{class:m,className:x,...h}=p;return Object.entries(h).every(y=>{let[v,g]=y;return Array.isArray(g)?g.includes({...i,...l}[v]):{...i,...l}[v]===g})?[...u,m,x]:u},[]);return HS(t,o,c,n==null?void 0:n.class,n==null?void 0:n.className)};/** 42 * @license lucide-react v0.462.0 - ISC 43 * 44 * This source code is licensed under the ISC license. 45 * See the LICENSE file in the root directory of this source tree. 46 */const dO=t=>t.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),DP=(...t)=>t.filter((s,n,a)=>!!s&&s.trim()!==""&&a.indexOf(s)===n).join(" ").trim();/** 47 * @license lucide-react v0.462.0 - ISC 48 * 49 * This source code is licensed under the ISC license. 50 * See the LICENSE file in the root directory of this source tree. 51 */var uO={xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"};/** 52 * @license lucide-react v0.462.0 - ISC 53 * 54 * This source code is licensed under the ISC license. 55 * See the LICENSE file in the root directory of this source tree. 56 */const mO=d.forwardRef(({color:t="currentColor",size:s=24,strokeWidth:n=2,absoluteStrokeWidth:a,className:r="",children:i,iconNode:o,...l},c)=>d.createElement("svg",{ref:c,...uO,width:s,height:s,stroke:t,strokeWidth:a?Number(n)*24/Number(s):n,className:DP("lucide",r),...l},[...o.map(([u,p])=>d.createElement(u,p)),...Array.isArray(i)?i:[i]]));/** 57 * @license lucide-react v0.462.0 - ISC 58 * 59 * This source code is licensed under the ISC license. 60 * See the LICENSE file in the root directory of this source tree. 61 */const ce=(t,s)=>{const n=d.forwardRef(({className:a,...r},i)=>d.createElement(mO,{ref:i,iconNode:s,className:DP(`lucide-${dO(t)}`,a),...r}));return n.displayName=`${t}`,n};/** 62 * @license lucide-react v0.462.0 - ISC 63 * 64 * This source code is licensed under the ISC license. 65 * See the LICENSE file in the root directory of this source tree. 66 */const Ma=ce("Activity",[["path",{d:"M22 12h-2.48a2 2 0 0 0-1.93 1.46l-2.35 8.36a.25.25 0 0 1-.48 0L9.24 2.18a.25.25 0 0 0-.48 0l-2.35 8.36A2 2 0 0 1 4.49 12H2",key:"169zse"}]]);/** 67 * @license lucide-react v0.462.0 - ISC 68 * 69 * This source code is licensed under the ISC license. 70 * See the LICENSE file in the root directory of this source tree. 71 */const RP=ce("Archive",[["rect",{width:"20",height:"5",x:"2",y:"3",rx:"1",key:"1wp1u1"}],["path",{d:"M4 8v11a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8",key:"1s80jp"}],["path",{d:"M10 12h4",key:"a56b0p"}]]);/** 72 * @license lucide-react v0.462.0 - ISC 73 * 74 * This source code is licensed under the ISC license. 75 * See the LICENSE file in the root directory of this source tree. 76 */const pO=ce("ArrowDownAZ",[["path",{d:"m3 16 4 4 4-4",key:"1co6wj"}],["path",{d:"M7 20V4",key:"1yoxec"}],["path",{d:"M20 8h-5",key:"1vsyxs"}],["path",{d:"M15 10V6.5a2.5 2.5 0 0 1 5 0V10",key:"ag13bf"}],["path",{d:"M15 14h5l-5 6h5",key:"ur5jdg"}]]);/** 77 * @license lucide-react v0.462.0 - ISC 78 * 79 * This source code is licensed under the ISC license. 80 * See the LICENSE file in the root directory of this source tree. 81 */const Je=ce("ArrowLeft",[["path",{d:"m12 19-7-7 7-7",key:"1l729n"}],["path",{d:"M19 12H5",key:"x3x0zl"}]]);/** 82 * @license lucide-react v0.462.0 - ISC 83 * 84 * This source code is licensed under the ISC license. 85 * See the LICENSE file in the root directory of this source tree. 86 */const Vt=ce("ArrowRight",[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"m12 5 7 7-7 7",key:"xquz4c"}]]);/** 87 * @license lucide-react v0.462.0 - ISC 88 * 89 * This source code is licensed under the ISC license. 90 * See the LICENSE file in the root directory of this source tree. 91 */const hO=ce("ArrowUpDown",[["path",{d:"m21 16-4 4-4-4",key:"f6ql7i"}],["path",{d:"M17 20V4",key:"1ejh1v"}],["path",{d:"m3 8 4-4 4 4",key:"11wl7u"}],["path",{d:"M7 4v16",key:"1glfcx"}]]);/** 92 * @license lucide-react v0.462.0 - ISC 93 * 94 * This source code is licensed under the ISC license. 95 * See the LICENSE file in the root directory of this source tree. 96 */const xO=ce("ArrowUpRight",[["path",{d:"M7 7h10v10",key:"1tivn9"}],["path",{d:"M7 17 17 7",key:"1vkiza"}]]);/** 97 * @license lucide-react v0.462.0 - ISC 98 * 99 * This source code is licensed under the ISC license. 100 * See the LICENSE file in the root directory of this source tree. 101 */const Is=ce("Award",[["path",{d:"m15.477 12.89 1.515 8.526a.5.5 0 0 1-.81.47l-3.58-2.687a1 1 0 0 0-1.197 0l-3.586 2.686a.5.5 0 0 1-.81-.469l1.514-8.526",key:"1yiouv"}],["circle",{cx:"12",cy:"8",r:"6",key:"1vp47v"}]]);/** 102 * @license lucide-react v0.462.0 - ISC 103 * 104 * This source code is licensed under the ISC license. 105 * See the LICENSE file in the root directory of this source tree. 106 */const fO=ce("BadgeCheck",[["path",{d:"M3.85 8.62a4 4 0 0 1 4.78-4.77 4 4 0 0 1 6.74 0 4 4 0 0 1 4.78 4.78 4 4 0 0 1 0 6.74 4 4 0 0 1-4.77 4.78 4 4 0 0 1-6.75 0 4 4 0 0 1-4.78-4.77 4 4 0 0 1 0-6.76Z",key:"3c2336"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]]);/** 107 * @license lucide-react v0.462.0 - ISC 108 * 109 * This source code is licensed under the ISC license. 110 * See the LICENSE file in the root directory of this source tree. 111 */const $b=ce("Ban",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m4.9 4.9 14.2 14.2",key:"1m5liu"}]]);/** 112 * @license lucide-react v0.462.0 - ISC 113 * 114 * This source code is licensed under the ISC license. 115 * See the LICENSE file in the root directory of this source tree. 116 */const Do=ce("Banknote",[["rect",{width:"20",height:"12",x:"2",y:"6",rx:"2",key:"9lu3g6"}],["circle",{cx:"12",cy:"12",r:"2",key:"1c9p78"}],["path",{d:"M6 12h.01M18 12h.01",key:"113zkx"}]]);/** 117 * @license lucide-react v0.462.0 - ISC 118 * 119 * This source code is licensed under the ISC license. 120 * See the LICENSE file in the root directory of this source tree. 121 */const Zx=ce("BellOff",[["path",{d:"M8.7 3A6 6 0 0 1 18 8a21.3 21.3 0 0 0 .6 5",key:"o7mx20"}],["path",{d:"M17 17H3s3-2 3-9a4.67 4.67 0 0 1 .3-1.7",key:"16f1lm"}],["path",{d:"M10.3 21a1.94 1.94 0 0 0 3.4 0",key:"qgo35s"}],["path",{d:"m2 2 20 20",key:"1ooewy"}]]);/** 122 * @license lucide-react v0.462.0 - ISC 123 * 124 * This source code is licensed under the ISC license. 125 * See the LICENSE file in the root directory of this source tree. 126 */const Di=ce("BellRing",[["path",{d:"M6 8a6 6 0 0 1 12 0c0 7 3 9 3 9H3s3-2 3-9",key:"1qo2s2"}],["path",{d:"M10.3 21a1.94 1.94 0 0 0 3.4 0",key:"qgo35s"}],["path",{d:"M4 2C2.8 3.7 2 5.7 2 8",key:"tap9e0"}],["path",{d:"M22 8c0-2.3-.8-4.3-2-6",key:"5bb3ad"}]]);/** 127 * @license lucide-react v0.462.0 - ISC 128 * 129 * This source code is licensed under the ISC license. 130 * See the LICENSE file in the root directory of this source tree. 131 */const Gl=ce("Bell",[["path",{d:"M6 8a6 6 0 0 1 12 0c0 7 3 9 3 9H3s3-2 3-9",key:"1qo2s2"}],["path",{d:"M10.3 21a1.94 1.94 0 0 0 3.4 0",key:"qgo35s"}]]);/** 132 * @license lucide-react v0.462.0 - ISC 133 * 134 * This source code is licensed under the ISC license. 135 * See the LICENSE file in the root directory of this source tree. 136 */const Na=ce("BookOpen",[["path",{d:"M12 7v14",key:"1akyts"}],["path",{d:"M3 18a1 1 0 0 1-1-1V4a1 1 0 0 1 1-1h5a4 4 0 0 1 4 4 4 4 0 0 1 4-4h5a1 1 0 0 1 1 1v13a1 1 0 0 1-1 1h-6a3 3 0 0 0-3 3 3 3 0 0 0-3-3z",key:"ruj8y"}]]);/** 137 * @license lucide-react v0.462.0 - ISC 138 * 139 * This source code is licensed under the ISC license. 140 * See the LICENSE file in the root directory of this source tree. 141 */const gO=ce("Boxes",[["path",{d:"M2.97 12.92A2 2 0 0 0 2 14.63v3.24a2 2 0 0 0 .97 1.71l3 1.8a2 2 0 0 0 2.06 0L12 19v-5.5l-5-3-4.03 2.42Z",key:"lc1i9w"}],["path",{d:"m7 16.5-4.74-2.85",key:"1o9zyk"}],["path",{d:"m7 16.5 5-3",key:"va8pkn"}],["path",{d:"M7 16.5v5.17",key:"jnp8gn"}],["path",{d:"M12 13.5V19l3.97 2.38a2 2 0 0 0 2.06 0l3-1.8a2 2 0 0 0 .97-1.71v-3.24a2 2 0 0 0-.97-1.71L17 10.5l-5 3Z",key:"8zsnat"}],["path",{d:"m17 16.5-5-3",key:"8arw3v"}],["path",{d:"m17 16.5 4.74-2.85",key:"8rfmw"}],["path",{d:"M17 16.5v5.17",key:"k6z78m"}],["path",{d:"M7.97 4.42A2 2 0 0 0 7 6.13v4.37l5 3 5-3V6.13a2 2 0 0 0-.97-1.71l-3-1.8a2 2 0 0 0-2.06 0l-3 1.8Z",key:"1xygjf"}],["path",{d:"M12 8 7.26 5.15",key:"1vbdud"}],["path",{d:"m12 8 4.74-2.85",key:"3rx089"}],["path",{d:"M12 13.5V8",key:"1io7kd"}]]);/** 142 * @license lucide-react v0.462.0 - ISC 143 * 144 * This source code is licensed under the ISC license. 145 * See the LICENSE file in the root directory of this source tree. 146 */const IP=ce("Briefcase",[["path",{d:"M16 20V4a2 2 0 0 0-2-2h-4a2 2 0 0 0-2 2v16",key:"jecpp"}],["rect",{width:"20",height:"14",x:"2",y:"6",rx:"2",key:"i6l2r4"}]]);/** 147 * @license lucide-react v0.462.0 - ISC 148 * 149 * This source code is licensed under the ISC license. 150 * See the LICENSE file in the root directory of this source tree. 151 */const Ws=ce("Building2",[["path",{d:"M6 22V4a2 2 0 0 1 2-2h8a2 2 0 0 1 2 2v18Z",key:"1b4qmf"}],["path",{d:"M6 12H4a2 2 0 0 0-2 2v6a2 2 0 0 0 2 2h2",key:"i71pzd"}],["path",{d:"M18 9h2a2 2 0 0 1 2 2v9a2 2 0 0 1-2 2h-2",key:"10jefs"}],["path",{d:"M10 6h4",key:"1itunk"}],["path",{d:"M10 10h4",key:"tcdvrf"}
151],["path",{d:"M10 14h4",key:"kelpxr"}],["path",{d:"M10 18h4",key:"1ulq68"}]]);/** 152 * @license lucide-react v0.462.0 - ISC 153 * 154 * This source code is licensed under the ISC license. 155 * See the LICENSE file in the root directory of this source tree. 156 */const yO=ce("Bus",[["path",{d:"M8 6v6",key:"18i7km"}],["path",{d:"M15 6v6",key:"1sg6z9"}],["path",{d:"M2 12h19.6",key:"de5uta"}],["path",{d:"M18 18h3s.5-1.7.8-2.8c.1-.4.2-.8.2-1.2 0-.4-.1-.8-.2-1.2l-1.4-5C20.1 6.8 19.1 6 18 6H4a2 2 0 0 0-2 2v10h3",key:"1wwztk"}],["circle",{cx:"7",cy:"18",r:"2",key:"19iecd"}],["path",{d:"M9 18h5",key:"lrx6i"}],["circle",{cx:"16",cy:"18",r:"2",key:"1v4tcr"}]]);/** 157 * @license lucide-react v0.462.0 - ISC 158 * 159 * This source code is licensed under the ISC license. 160 * See the LICENSE file in the root directory of this source tree. 161 */const $P=ce("Calculator",[["rect",{width:"16",height:"20",x:"4",y:"2",rx:"2",key:"1nb95v"}],["line",{x1:"8",x2:"16",y1:"6",y2:"6",key:"x4nwl0"}],["line",{x1:"16",x2:"16",y1:"14",y2:"18",key:"wjye3r"}],["path",{d:"M16 10h.01",key:"1m94wz"}],["path",{d:"M12 10h.01",key:"1nrarc"}],["path",{d:"M8 10h.01",key:"19clt8"}],["path",{d:"M12 14h.01",key:"1etili"}],["path",{d:"M8 14h.01",key:"6423bh"}],["path",{d:"M12 18h.01",key:"mhygvu"}],["path",{d:"M8 18h.01",key:"lrp35t"}]]);/** 162 * @license lucide-react v0.462.0 - ISC 163 * 164 * This source code is licensed under the ISC license. 165 * See the LICENSE file in the root directory of this source tree. 166 */const _a=ce("CalendarClock",[["path",{d:"M21 7.5V6a2 2 0 0 0-2-2H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h3.5",key:"1osxxc"}],["path",{d:"M16 2v4",key:"4m81vk"}],["path",{d:"M8 2v4",key:"1cmpym"}],["path",{d:"M3 10h5",key:"r794hk"}],["path",{d:"M17.5 17.5 16 16.3V14",key:"akvzfd"}],["circle",{cx:"16",cy:"16",r:"6",key:"qoo3c4"}]]);/** 167 * @license lucide-react v0.462.0 - ISC 168 * 169 * This source code is licensed under the ISC license. 170 * See the LICENSE file in the root directory of this source tree. 171 */const Ii=ce("CalendarDays",[["path",{d:"M8 2v4",key:"1cmpym"}],["path",{d:"M16 2v4",key:"4m81vk"}],["rect",{width:"18",height:"18",x:"3",y:"4",rx:"2",key:"1hopcy"}],["path",{d:"M3 10h18",key:"8toen8"}],["path",{d:"M8 14h.01",key:"6423bh"}],["path",{d:"M12 14h.01",key:"1etili"}],["path",{d:"M16 14h.01",key:"1gbofw"}],["path",{d:"M8 18h.01",key:"lrp35t"}],["path",{d:"M12 18h.01",key:"mhygvu"}],["path",{d:"M16 18h.01",key:"kzsmim"}]]);/** 172 * @license lucide-react v0.462.0 - ISC 173 * 174 * This source code is licensed under the ISC license. 175 * See the LICENSE file in the root directory of this source tree. 176 */const c2=ce("CalendarRange",[["rect",{width:"18",height:"18",x:"3",y:"4",rx:"2",key:"1hopcy"}],["path",{d:"M16 2v4",key:"4m81vk"}],["path",{d:"M3 10h18",key:"8toen8"}],["path",{d:"M8 2v4",key:"1cmpym"}],["path",{d:"M17 14h-6",key:"bkmgh3"}],["path",{d:"M13 18H7",key:"bb0bb7"}],["path",{d:"M7 14h.01",key:"1qa3f1"}],["path",{d:"M17 18h.01",key:"1bdyru"}]]);/** 177 * @license lucide-react v0.462.0 - ISC 178 * 179 * This source code is licensed under the ISC license. 180 * See the LICENSE file in the root directory of this source tree. 181 */const At=ce("Calendar",[["path",{d:"M8 2v4",key:"1cmpym"}],["path",{d:"M16 2v4",key:"4m81vk"}],["rect",{width:"18",height:"18",x:"3",y:"4",rx:"2",key:"1hopcy"}],["path",{d:"M3 10h18",key:"8toen8"}]]);/** 182 * @license lucide-react v0.462.0 - ISC 183 * 184 * This source code is licensed under the ISC license. 185 * See the LICENSE file in the root directory of this source tree. 186 */const rx=ce("Camera",[["path",{d:"M14.5 4h-5L7 7H4a2 2 0 0 0-2 2v9a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2V9a2 2 0 0 0-2-2h-3l-2.5-3z",key:"1tc9qg"}],["circle",{cx:"12",cy:"13",r:"3",key:"1vg3eu"}]]);/** 187 * @license lucide-react v0.462.0 - ISC 188 * 189 * This source code is licensed under the ISC license. 190 * See the LICENSE file in the root directory of this source tree. 191 */const La=ce("ChartColumn",[["path",{d:"M3 3v16a2 2 0 0 0 2 2h16",key:"c24i48"}],["path",{d:"M18 17V9",key:"2bz60n"}],["path",{d:"M13 17V5",key:"1frdt8"}],["path",{d:"M8 17v-3",key:"17ska0"}]]);/** 192 * @license lucide-react v0.462.0 - ISC 193 * 194 * This source code is licensed under the ISC license. 195 * See the LICENSE file in the root directory of this source tree. 196 */const bO=ce("ChartLine",[["path",{d:"M3 3v16a2 2 0 0 0 2 2h16",key:"c24i48"}],["path",{d:"m19 9-5 5-4-4-3 3",key:"2osh9i"}]]);/** 197 * @license lucide-react v0.462.0 - ISC 198 * 199 * This source code is licensed under the ISC license. 200 * See the LICENSE file in the root directory of this source tree. 201 */const GS=ce("CheckCheck",[["path",{d:"M18 6 7 17l-5-5",key:"116fxf"}],["path",{d:"m22 10-7.5 7.5L13 16",key:"ke71qq"}]]);/** 202 * @license lucide-react v0.462.0 - ISC 203 * 204 * This source code is licensed under the ISC license. 205 * See the LICENSE file in the root directory of this source tree. 206 */const xt=ce("Check",[["path",{d:"M20 6 9 17l-5-5",key:"1gmf2c"}]]);/** 207 * @license lucide-react v0.462.0 - ISC 208 * 209 * This source code is licensed under the ISC license. 210 * See the LICENSE file in the root directory of this source tree. 211 */const Gt=ce("ChevronDown",[["path",{d:"m6 9 6 6 6-6",key:"qrunsl"}]]);/** 212 * @license lucide-react v0.462.0 - ISC 213 * 214 * This source code is licensed under the ISC license. 215 * See the LICENSE file in the root directory of this source tree. 216 */const vO=ce("ChevronLeft",[["path",{d:"m15 18-6-6 6-6",key:"1wnfg3"}]]);/** 217 * @license lucide-react v0.462.0 - ISC 218 * 219 * This source code is licensed under the ISC license. 220 * See the LICENSE file in the root directory of this source tree. 221 */const Nr=ce("ChevronRight",[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]]);/** 222 * @license lucide-react v0.462.0 - ISC 223 * 224 * This source code is licensed under the ISC license. 225 * See the LICENSE file in the root directory of this source tree. 226 */const Od=ce("ChevronUp",[["path",{d:"m18 15-6-6-6 6",key:"153udz"}]]);/** 227 * @license lucide-react v0.462.0 - ISC 228 * 229 * This source code is licensed under the ISC license. 230 * See the LICENSE file in the root directory of this source tree. 231 */const Mt=ce("CircleAlert",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["line",{x1:"12",x2:"12",y1:"8",y2:"12",key:"1pkeuh"}],["line",{x1:"12",x2:"12.01",y1:"16",y2:"16",key:"4dfq90"}]]);/** 232 * @license lucide-react v0.462.0 - ISC 233 * 234 * This source code is licensed under the ISC license. 235 * See the LICENSE file in the root directory of this source tree. 236 */const pt=ce("CircleCheckBig",[["path",{d:"M21.801 10A10 10 0 1 1 17 3.335",key:"yps3ct"}],["path",{d:"m9 11 3 3L22 4",key:"1pflzl"}]]);/** 237 * @license lucide-react v0.462.0 - ISC 238 * 239 * This source code is licensed under the ISC license. 240 * See the LICENSE file in the root directory of this source tree. 241 */const Ue=ce("CircleCheck",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]]);/** 242 * @license lucide-react v0.462.0 - ISC 243 * 244 * This source code is licensed under the ISC license. 245 * See the LICENSE file in the root directory of this source tree. 246 */const Vl=ce("CircleDollarSign",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M16 8h-6a2 2 0 1 0 0 4h4a2 2 0 1 1 0 4H8",key:"1h4pet"}],["path",{d:"M12 18V6",key:"zqpxq5"}]]);/** 247 * @license lucide-react v0.462.0 - ISC 248 * 249 * This source code is licensed under the ISC license. 250 * See the LICENSE file in the root directory of this source tree. 251 */const Ny=ce("CircleHelp",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M9.09 9a3 3 0 0 1 5.83 1c0 2-3 3-3 3",key:"1u773s"}],["path",{d:"M12 17h.01",key:"p32p05"}]]);/** 252 * @license lucide-react v0.462.0 - ISC 253 * 254 * This source code is licensed under the ISC license. 255 * See the LICENSE file in the root directory of this source tree. 256 */const jO=ce("CircleMinus",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M8 12h8",key:"1wcyev"}]]);/** 257 * @license lucide-react v0.462.0 - ISC 258 * 259 * This source code is licensed under the ISC license. 260 * See the LICENSE file in the root directory of this source tree. 261 */const V_=ce("CirclePause",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["line",{x1:"10",x2:"10",y1:"15",y2:"9",key:"c1nkhi"}],["line",{x1:"14",x2:"14",y1:"15",y2:"9",key:"h65svq"}]]);/** 262 * @license lucide-react v0.462.0 - ISC 263 * 264 * This source code is licensed under the ISC license. 265 * See the LICENSE file in the root directory of this source tree. 266 */const _y=ce("CirclePlay",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["polygon",{points:"10 8 16 12 10 16 10 8",key:"1cimsy"}]]);/** 267 * @license lucide-react v0.462.0 - ISC 268 * 269 * This source code is licensed under the ISC license. 270 * See the LICENSE file in the root directory of this source tree. 271 */const kt=ce("CircleX",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m15 9-6 6",key:"1uzhvr"}],["path",{d:"m9 9 6 6",key:"z0biqf"}]]);/** 272 * @license lucide-react v0.462.0 - ISC 273 * 274 * This source code is licensed under the ISC license. 275 * See the LICENSE file in the root directory of this source tree. 276 */const zb=ce("Circle",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]]);/** 277 * @license lucide-react v0.462.0 - ISC 278 * 279 * This source code is licensed under the ISC license. 280 * See the LICENSE file in the root directory of this source tree.
281 */const Nd=ce("ClipboardCheck",[["rect",{width:"8",height:"4",x:"8",y:"2",rx:"1",ry:"1",key:"tgr4d6"}],["path",{d:"M16 4h2a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2V6a2 2 0 0 1 2-2h2",key:"116196"}],["path",{d:"m9 14 2 2 4-4",key:"df797q"}]]);/** 282 * @license lucide-react v0.462.0 - ISC 283 * 284 * This source code is licensed under the ISC license. 285 * See the LICENSE file in the root directory of this source tree. 286 */const mn=ce("ClipboardList",[["rect",{width:"8",height:"4",x:"8",y:"2",rx:"1",ry:"1",key:"tgr4d6"}],["path",{d:"M16 4h2a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2V6a2 2 0 0 1 2-2h2",key:"116196"}],["path",{d:"M12 11h4",key:"1jrz19"}],["path",{d:"M12 16h4",key:"n85exb"}],["path",{d:"M8 11h.01",key:"1dfujw"}],["path",{d:"M8 16h.01",key:"18s6g9"}]]);/** 287 * @license lucide-react v0.462.0 - ISC 288 * 289 * This source code is licensed under the ISC license. 290 * See the LICENSE file in the root directory of this source tree. 291 */const dt=ce("Clock",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["polyline",{points:"12 6 12 12 16 14",key:"68esgv"}]]);/** 292 * @license lucide-react v0.462.0 - ISC 293 * 294 * This source code is licensed under the ISC license. 295 * See the LICENSE file in the root directory of this source tree. 296 */const d2=ce("CloudDownload",[["path",{d:"M12 13v8l-4-4",key:"1f5nwf"}],["path",{d:"m12 21 4-4",key:"1lfcce"}],["path",{d:"M4.393 15.269A7 7 0 1 1 15.71 8h1.79a4.5 4.5 0 0 1 2.436 8.284",key:"ui1hmy"}]]);/** 297 * @license lucide-react v0.462.0 - ISC 298 * 299 * This source code is licensed under the ISC license. 300 * See the LICENSE file in the root directory of this source tree. 301 */const zP=ce("Cloud",[["path",{d:"M17.5 19H9a7 7 0 1 1 6.71-9h1.79a4.5 4.5 0 1 1 0 9Z",key:"p7xjir"}]]);/** 302 * @license lucide-react v0.462.0 - ISC 303 * 304 * This source code is licensed under the ISC license. 305 * See the LICENSE file in the root directory of this source tree. 306 */const wO=ce("Coffee",[["path",{d:"M10 2v2",key:"7u0qdc"}],["path",{d:"M14 2v2",key:"6buw04"}],["path",{d:"M16 8a1 1 0 0 1 1 1v8a4 4 0 0 1-4 4H7a4 4 0 0 1-4-4V9a1 1 0 0 1 1-1h14a4 4 0 1 1 0 8h-1",key:"pwadti"}],["path",{d:"M6 2v2",key:"colzsn"}]]);/** 307 * @license lucide-react v0.462.0 - ISC 308 * 309 * This source code is licensed under the ISC license. 310 * See the LICENSE file in the root directory of this source tree. 311 */const ky=ce("Coins",[["circle",{cx:"8",cy:"8",r:"6",key:"3yglwk"}],["path",{d:"M18.09 10.37A6 6 0 1 1 10.34 18",key:"t5s6rm"}],["path",{d:"M7 6h1v4",key:"1obek4"}],["path",{d:"m16.71 13.88.7.71-2.82 2.82",key:"1rbuyh"}]]);/** 312 * @license lucide-react v0.462.0 - ISC 313 * 314 * This source code is licensed under the ISC license. 315 * See the LICENSE file in the root directory of this source tree. 316 */const NO=ce("Columns3",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M9 3v18",key:"fh3hqa"}],["path",{d:"M15 3v18",key:"14nvp0"}]]);/** 317 * @license lucide-react v0.462.0 - ISC 318 * 319 * This source code is licensed under the ISC license. 320 * See the LICENSE file in the root directory of this source tree. 321 */const _O=ce("Compass",[["path",{d:"m16.24 7.76-1.804 5.411a2 2 0 0 1-1.265 1.265L7.76 16.24l1.804-5.411a2 2 0 0 1 1.265-1.265z",key:"9ktpf1"}],["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]]);/** 322 * @license lucide-react v0.462.0 - ISC 323 * 324 * This source code is licensed under the ISC license. 325 * See the LICENSE file in the root directory of this source tree. 326 */const kO=ce("Cookie",[["path",{d:"M12 2a10 10 0 1 0 10 10 4 4 0 0 1-5-5 4 4 0 0 1-5-5",key:"laymnq"}],["path",{d:"M8.5 8.5v.01",key:"ue8clq"}],["path",{d:"M16 15.5v.01",key:"14dtrp"}],["path",{d:"M12 12v.01",key:"u5ubse"}],["path",{d:"M11 17v.01",key:"1hyl5a"}],["path",{d:"M7 14v.01",key:"uct60s"}]]);/** 327 * @license lucide-react v0.462.0 - ISC 328 * 329 * This source code is licensed under the ISC license. 330 * See the LICENSE file in the root directory of this source tree. 331 */const Z_=ce("CopyCheck",[["path",{d:"m12 15 2 2 4-4",key:"2c609p"}],["rect",{width:"14",height:"14",x:"8",y:"8",rx:"2",ry:"2",key:"17jyea"}],["path",{d:"M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2",key:"zix9uf"}]]);/** 332 * @license lucide-react v0.462.0 - ISC 333 * 334 * This source code is licensed under the ISC license. 335 * See the LICENSE file in the root directory of this source tree.
336 */const Vm=ce("Copy",[["rect",{width:"14",height:"14",x:"8",y:"8",rx:"2",ry:"2",key:"17jyea"}],["path",{d:"M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2",key:"zix9uf"}]]);/** 337 * @license lucide-react v0.462.0 - ISC 338 * 339 * This source code is licensed under the ISC license. 340 * See the LICENSE file in the root directory of this source tree. 341 */const Yx=ce("CreditCard",[["rect",{width:"20",height:"14",x:"2",y:"5",rx:"2",key:"ynyp8z"}],["line",{x1:"2",x2:"22",y1:"10",y2:"10",key:"1b3vmo"}]]);/** 342 * @license lucide-react v0.462.0 - ISC 343 * 344 * This source code is licensed under the ISC license. 345 * See the LICENSE file in the root directory of this source tree. 346 */const Zl=ce("Crown",[["path",{d:"M11.562 3.266a.5.5 0 0 1 .876 0L15.39 8.87a1 1 0 0 0 1.516.294L21.183 5.5a.5.5 0 0 1 .798.519l-2.834 10.246a1 1 0 0 1-.956.734H5.81a1 1 0 0 1-.957-.734L2.02 6.02a.5.5 0 0 1 .798-.519l4.276 3.664a1 1 0 0 0 1.516-.294z",key:"1vdc57"}],["path",{d:"M5 21h14",key:"11awu3"}]]);/** 347 * @license lucide-react v0.462.0 - ISC 348 * 349 * This source code is licensed under the ISC license. 350 * See the LICENSE file in the root directory of this source tree. 351 */const $i=ce("Database",[["ellipse",{cx:"12",cy:"5",rx:"9",ry:"3",key:"msslwz"}],["path",{d:"M3 5V19A9 3 0 0 0 21 19V5",key:"1wlel7"}],["path",{d:"M3 12A9 3 0 0 0 21 12",key:"mv7ke4"}]]);/** 352 * @license lucide-react v0.462.0 - ISC 353 * 354 * This source code is licensed under the ISC license. 355 * See the LICENSE file in the root directory of this source tree. 356 */const Ro=ce("DollarSign",[["line",{x1:"12",x2:"12",y1:"2",y2:"22",key:"7eqyqh"}],["path",{d:"M17 5H9.5a3.5 3.5 0 0 0 0 7h5a3.5 3.5 0 0 1 0 7H6",key:"1b0p4s"}]]);/** 357 * @license lucide-react v0.462.0 - ISC 358 * 359 * This source code is licensed under the ISC license. 360 * See the LICENSE file in the root directory of this source tree. 361 */const us=ce("Download",[["path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4",key:"ih7n3h"}],["polyline",{points:"7 10 12 15 17 10",key:"2ggqvy"}],["line",{x1:"12",x2:"12",y1:"15",y2:"3",key:"1vk2je"}]]);/** 362 * @license lucide-react v0.462.0 - ISC 363 * 364 * This source code is licensed under the ISC license. 365 * See the LICENSE file in the root directory of this source tree. 366 */const fd=ce("Droplets",[["path",{d:"M7 16.3c2.2 0 4-1.83 4-4.05 0-1.16-.57-2.26-1.71-3.19S7.29 6.75 7 5.3c-.29 1.45-1.14 2.84-2.29 3.76S3 11.1 3 12.25c0 2.22 1.8 4.05 4 4.05z",key:"1ptgy4"}],["path",{d:"M12.56 6.6A10.97 10.97 0 0 0 14 3.02c.5 2.5 2 4.9 4 6.5s3 3.5 3 5.5a6.98 6.98 0 0 1-11.91 4.97",key:"1sl1rz"}]]);/** 367 * @license lucide-react v0.462.0 - ISC 368 * 369 * This source code is licensed under the ISC license. 370 * See the LICENSE file in the root directory of this source tree. 371 */const SO=ce("Equal",[["line",{x1:"5",x2:"19",y1:"9",y2:"9",key:"1nwqeh"}],["line",{x1:"5",x2:"19",y1:"15",y2:"15",key:"g8yjpy"}]]);/** 372 * @license lucide-react v0.462.0 - ISC 373 * 374 * This source code is licensed under the ISC license. 375 * See the LICENSE file in the root directory of this source tree. 376 */const Ua=ce("ExternalLink",[["path",{d:"M15 3h6v6",key:"1q9fwt"}],["path",{d:"M10 14 21 3",key:"gplh6r"}],["path",{d:"M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6",key:"a6xqqp"}]]);/** 377 * @license lucide-react v0.462.0 - ISC 378 * 379 * This source code is licensed under the ISC license. 380 * See the LICENSE file in the root directory of this source tree. 381 */const Md=ce("EyeOff",[["path",{d:"M10.733 5.076a10.744 10.744 0 0 1 11.205 6.575 1 1 0 0 1 0 .696 10.747 10.747 0 0 1-1.444 2.49",key:"ct8e1f"}],["path",{d:"M14.084 14.158a3 3 0 0 1-4.242-4.242",key:"151rxh"}],["path",{d:"M17.479 17.499a10.75 10.75 0 0 1-15.417-5.151 1 1 0 0 1 0-.696 10.75 10.75 0 0 1 4.446-5.143",key:"13bj9a"}],["path",{d:"m2 2 20 20",key:"1ooewy"}]]);/** 382 * @license lucide-react v0.462.0 - ISC 383 * 384 * This source code is licensed under the ISC license. 385 * See the LICENSE file in the root directory of this source tree. 386 */const ms=ce("Eye",[["path",{d:"M2.062 12.348a1 1 0 0 1 0-.696 10.75 10.75 0 0 1 19.876 0 1 1 0 0 1 0 .696 10.75 10.75 0 0 1-19.876 0",key:"1nclc0"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}]]);/** 387 * @license lucide-react v0.462.0 - ISC 388 * 389 * This source code is licensed under the ISC license. 390 * See the LICENSE file in the root directory of this source tree. 391 */const VS=ce("FileCheck2",[["path",{d:"M4 22h14a2 2 0 0 0 2-2V7l-5-5H6a2 2 0 0 0-2 2v4",key:"1pf5j1"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"m3 15 2 2 4-4",key:"1lhrkk"}]]);/** 392 * @license lucide-react v0.462.0 - ISC 393 * 394 * This source code is licensed under the ISC license. 395 * See the LICENSE file in the root directory of this source tree. 396 */const LP=ce("FileCheck",[["path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z",key:"1rqfz7"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"m9 15 2 2 4-4",key:"1grp1n"}]]);/** 397 * @license lucide-react v0.462.0 - ISC 398 * 399 * This source code is licensed under the ISC license. 400 * See the LICENSE file in the root directory of this source tree. 401 */const CO=ce("FileDown",[["path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z",key:"1rqfz7"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"M12 18v-6",key:"17g6i2"}],["path",{d:"m9 15 3 3 3-3",key:"1npd3o"}]]);/** 402 * @license lucide-react v0.462.0 - ISC 403 * 404 * This source code is licensed under the ISC license. 405 * See the LICENSE file in the root directory of this source tree. 406 */const AO=ce("FileImage",[["path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z",key:"1rqfz7"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["circle",{cx:"10",cy:"12",r:"2",key:"737tya"}],["path",{d:"m20 17-1.296-1.296a2.41 2.41 0 0 0-3.408 0L9 22",key:"wt3hpn"}]]);/** 407 * @license lucide-react v0.462.0 - ISC 408 * 409 * This source code is licensed under the ISC license. 410 * See the LICENSE file in the root directory of this source tree. 411 */const Tm=ce("FilePenLine",[["path",{d:"m18 5-2.414-2.414A2 2 0 0 0 14.172 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2",ke
411y:"142zxg"}],["path",{d:"M21.378 12.626a1 1 0 0 0-3.004-3.004l-4.01 4.012a2 2 0 0 0-.506.854l-.837 2.87a.5.5 0 0 0 .62.62l2.87-.837a2 2 0 0 0 .854-.506z",key:"2t3380"}],["path",{d:"M8 18h1",key:"13wk12"}]]);/** 412 * @license lucide-react v0.462.0 - ISC 413 * 414 * This source code is licensed under the ISC license. 415 * See the LICENSE file in the root directory of this source tree. 416 */const u0=ce("FileSearch",[["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"M4.268 21a2 2 0 0 0 1.727 1H18a2 2 0 0 0 2-2V7l-5-5H6a2 2 0 0 0-2 2v3",key:"ms7g94"}],["path",{d:"m9 18-1.5-1.5",key:"1j6qii"}],["circle",{cx:"5",cy:"14",r:"3",key:"ufru5t"}]]);/** 417 * @license lucide-react v0.462.0 - ISC 418 * 419 * This source code is licensed under the ISC license. 420 * See the LICENSE file in the root directory of this source tree. 421 */const Lb=ce("FileSpreadsheet",[["path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z",key:"1rqfz7"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"M8 13h2",key:"yr2amv"}],["path",{d:"M14 13h2",key:"un5t4a"}],["path",{d:"M8 17h2",key:"2yhykz"}],["path",{d:"M14 17h2",key:"10kma7"}]]);/** 422 * @license lucide-react v0.462.0 - ISC 423 * 424 * This source code is licensed under the ISC license. 425 * See the LICENSE file in the root directory of this source tree. 426 */const Kt=ce("FileText",[["path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z",key:"1rqfz7"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"M10 9H8",key:"b1mrlr"}],["path",{d:"M16 13H8",key:"t4e002"}],["path",{d:"M16 17H8",key:"z1uh3a"}]]);/** 427 * @license lucide-react v0.462.0 - ISC 428 * 429 * This source code is licensed under the ISC license. 430 * See the LICENSE file in the root directory of this source tree. 431 */const em=ce("FileWarning",[["path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z",key:"1rqfz7"}],["path",{d:"M12 9v4",key:"juzpu7"}],["path",{d:"M12 17h.01",key:"p32p05"}]]);/** 432 * @license lucide-react v0.462.0 - ISC 433 * 434 * This source code is licensed under the ISC license. 435 * See the LICENSE file in the root directory of this source tree. 436 */const ei=ce("Filter",[["polygon",{points:"22 3 2 3 10 12.46 10 19 14 21 14 12.46 22 3",key:"1yg77f"}]]);/** 437 * @license lucide-react v0.462.0 - ISC 438 * 439 * This source code is licensed under the ISC license. 440 * See the LICENSE file in the root directory of this source tree. 441 */const EO=ce("Fingerprint",[["path",{d:"M12 10a2 2 0 0 0-2 2c0 1.02-.1 2.51-.26 4",key:"1nerag"}],["path",{d:"M14 13.12c0 2.38 0 6.38-1 8.88",key:"o46ks0"}],["path",{d:"M17.29 21.02c.12-.6.43-2.3.5-3.02",key:"ptglia"}],["path",{d:"M2 12a10 10 0 0 1 18-6",key:"ydlgp0"}],["path",{d:"M2 16h.01",key:"1gqxmh"}],["path",{d:"M21.8 16c.2-2 .131-5.354 0-6",key:"drycrb"}],["path",{d:"M5 19.5C5.5 18 6 15 6 12a6 6 0 0 1 .34-2",key:"1tidbn"}],["path",{d:"M8.65 22c.21-.66.45-1.32.57-2",key:"13wd9y"}],["path",{d:"M9 6.8a6 6 0 0 1 9 5.2v2",key:"1fr1j5"}]]);/** 442 * @license lucide-react v0.462.0 - ISC 443 * 444 * This source code is licensed under the ISC license. 445 * See the LICENSE file in the root directory of this source tree. 446 */const yp=ce("Flag",[["path",{d:"M4 15s1-1 4-1 5 2 8 2 4-1 4-1V3s-1 1-4 1-5-2-8-2-4 1-4 1z",key:"i9b6wo"}],["line",{x1:"4",x2:"4",y1:"22",y2:"15",key:"1cm3nv"}]]);/** 447 * @license lucide-react v0.462.0 - ISC 448 * 449 * This source code is licensed under the ISC license. 450 * See the LICENSE file in the root directory of this source tree. 451 */const Kx=ce("Flame",[["path",{d:"M8.5 14.5A2.5 2.5 0 0 0 11 12c0-1.38-.5-2-1-3-1.072-2.143-.224-4.054 2-6 .5 2.5 2 4.9 4 6.5 2 1.6 3 3.5 3 5.5a7 7 0 1 1-14 0c0-1.153.433-2.294 1-3a2.5 2.5 0 0 0 2.5 2.5z",key:"96xj49"}]]);/** 452 * @license lucide-react v0.462.0 - ISC 453 * 454 * This source code is licensed under the ISC license. 455 * See the LICENSE file in the root directory of this source tree. 456 */const Qx=ce("FlaskConical",[["path",{d:"M10 2v7.527a2 2 0 0 1-.211.896L4.72 20.55a1 1 0 0 0 .9 1.45h12.76a1 1 0 0 0 .9-1.45l-5.069-10.127A2 2 0 0 1 14 9.527V2",key:"pzvekw"}],["path",{d:"M8.5 2h7",key:"csnxdl"}],["path",{d:"M7 16h10",key:"wp8him"}]]);/** 457 * @license lucide-react v0.462.0 - ISC 458 * 459 * This source code is licensed under the ISC license. 460 * See the LICENSE file in the root directory of this source tree. 461 */const OP=ce("Gauge",[["path",{d:"m12 14 4-4",key:"9kzdfg"}],["path",{d:"M3.34 19a10 10 0 1 1 17.32 0",key:"19p75a"}]]);/** 462 * @license lucide-react v0.462.0 - ISC 463 * 464 * This source code is licensed under the ISC license. 465 * See the LICENSE file in the root directory of this source tree. 466 */const Io=ce("Gem",[["path",{d:"M6 3h12l4 6-10 13L2 9Z",key:"1pcd5k"}],["path",{d:"M11 3 8 9l4 13 4-13-3-6",key:"1fcu3u"}],["path",{d:"M2 9h20",key:"16fsjt"}]]);/** 467 * @license lucide-react v0.462.0 - ISC 468 * 469 * This source code is licensed under the ISC license. 470 * See the LICENSE file in the root directory of this source tree. 471 */const FO=ce("Gift",[["rect",{x:"3",y:"8",width:"18",height:"4",rx:"1",key:"bkv52"}],["path",{d:"M12 8v13",key:"1c76mn"}],["path",{d:"M19 12v7a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2v-7",key:"6wjy6b"}],["path",{d:"M7.5 8a2.5 2.5 0 0 1 0-5A4.8 8 0 0 1 12 8a4.8 8 0 0 1 4.5-5 2.5 2.5 0 0 1 0 5",key:"1ihvrl"}]]);/** 472 * @license lucide-react v0.462.0 - ISC 473 * 474 * This source code is licensed under the ISC license. 475 * See the LICENSE file in the root directory of this source tree. 476 */const ZS=ce("GitBranch",[["line",{x1:"6",x2:"6",y1:"3",y2:"15",key:"17qcm7"}],["circle",{cx:"18",cy:"6",r:"3",key:"1h7g24"}],["circle",{cx:"6",cy:"18",r:"3",key:"fqmcym"}],["path",{d:"M18 9a9 9 0 0 1-9 9",key:"n2h4wq"}]]);/** 477 * @license lucide-react v0.462.0 - ISC 478 * 479 * This source code is licensed under the ISC license. 480 * See the LICENSE file in the root directory of this source tree. 481 */const Bo=ce("Globe",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 2a14.5 14.5 0 0 0 0 20 14.5 14.5 0 0 0 0-20",key:"13o1zl"}],["path",{d:"M2 12h20",key:"9i4pu4"}]]);/** 482 * @license lucide-react v0.462.0 - ISC 483 * 484 * This source code is licensed under the ISC license. 485 * See the LICENSE file in the root directory of this source tree. 486 */const _t=ce("GraduationCap",[["path",{d:"M21.42 10.922a1 1 0 0 0-.019-1.838L12.83 5.18a2 2 0 0 0-1.66 0L2.6 9.08a1 1 0 0 0 0 1.832l8.57 3.908a2 2 0 0 0 1.66 0z",key:"j76jl0"}],["path",{d:"M22 10v6",key:"1lu8f3"}],["path",{d:"M6 12.5V16a6 3 0 0 0 12 0v-3.5",key:"1r8lef"}]]);/** 487 * @license lucide-react v0.462.0 - ISC 488 * 489 * This source code is licensed under the ISC license. 490 * See the LICENSE file in the root directory of this source tree. 491 */const TO=ce("GripVertical",[["circle",{cx:"9",cy:"12",r:"1",key:"1vctgf"}],["circle",{cx:"9",cy:"5",r:"1",key:"hp0tcf"}],["circle",{cx:"9",cy:"19",r:"1",key:"fkjjf6"}],["circle",{cx:"15",cy:"12",r:"1",key:"1tmaij"}],["circle",{cx:"15",cy:"5",r:"1",key:"19l28e"}],["circle",{cx:"15",cy:"19",r:"1",key:"f4zoj3"}]]);/** 492 * @license lucide-react v0.462.0 - ISC 493 * 494 * This source code is licensed under the ISC license. 495 * See the LICENSE file in the root directory of this source tree. 496 */const PO=ce("Hammer",[["path",{d:"m15 12-8.373 8.373a1 1 0 1 1-3-3L12 9",key:"eefl8a"}],["path",{d:"m18 15 4-4",key:"16gjal"}],["path",{d:"m21.5 11.5-1.914-1.914A2 2 0 0 1 19 8.172V7l-2.26-2.26a6 6 0 0 0-4.202-1.756L9 2.96l.92.82A6.18 6.18 0 0 1 12 8.4V10l2 2h1.172a2 2 0 0 1 1.414.586L18.5 14.5",key:"b7pghm"}]]);/** 497 * @license lucide-react v0.462.0 - ISC 498 * 499 * This source code is licensed under the ISC license. 500 * See the LICENSE file in the root directory of this source tree. 501 */const nh=ce("HandCoins",[["path",{d:"M11 15h2a2 2 0 1 0 0-4h-3c-.6 0-1.1.2-1.4.6L3 17",key:"geh8rc"}],["path",{d:"m7 21 1.6-1.4c.3-.4.8-.6 1.4-.6h4c1.1 0 2.1-.4 2.8-1.2l4.6-4.4a2 2 0 0 0-2.75-2.91l-4.2 3.9",key:"1fto5m"}],["path",{d:"m2 16 6 6",key:"1pfhp9"}],["circle",{cx:"16",cy:"9",r:"2.9",key:"1n0dlu"}],["circle",{cx:"6",cy:"5",r:"3",key:"151irh"}]]);/** 502 * @license lucide-react v0.462.0 - ISC 503 * 504 * This source code is licensed under the ISC license. 505 * See the LICENSE file in the root directory of this source tree. 506 */const YS=ce("Handshake",[["path",{d:"m11 17 2 2a1 1 0 1 0 3-3",key:"efffak"}],["path",{d:"m14 14 2.5 2.5a1 1 0 1 0 3-3l-3.88-3.88a3 3 0 0 0-4.24 0l-.88.88a1 1 0 1 1-3-3l2.81-2.81a5.79 5.79 0 0 1 7.06-.87l.47.28a2 2 0 0 0 1.42.25L21 4",key:"9pr0kb"}],["path",{d:"m21 3 1 11h-2",key:"1tisrp"}],["path",{d:"M3 3 2 14l6.5 6.5a1 1 0 1 0 3-3",key:"1uvwmv"}],["path",{d:"M3 4h8",key:"1ep09j"}]]);/** 507 * @license lucide-react v0.462.0 - ISC 508 * 509 * This source code is licensed under the ISC license. 510 * See the LICENSE file in the root directory of this source tree. 511 */const DO=ce("Hash",[["line",{x1:"4",x2:"20",y1:"9",y2:"9",key:"4lhtct"}],["line",{x1:"4",x2:"20",y1:"15",y2:"15",key:"vyu0kd"}],["line",{x1:"10",x2:"8",y1:"3",y2:"21",key:"1ggp8o"}],["line",{x1:"16",x2:"14",y1:"3",y2:"21",key:"weycgp"}
511]]);/** 512 * @license lucide-react v0.462.0 - ISC 513 * 514 * This source code is licensed under the ISC license. 515 * See the LICENSE file in the root directory of this source tree. 516 */const MP=ce("HeartHandshake",[["path",{d:"M19 14c1.49-1.46 3-3.21 3-5.5A5.5 5.5 0 0 0 16.5 3c-1.76 0-3 .5-4.5 2-1.5-1.5-2.74-2-4.5-2A5.5 5.5 0 0 0 2 8.5c0 2.3 1.5 4.05 3 5.5l7 7Z",key:"c3ymky"}],["path",{d:"M12 5 9.04 7.96a2.17 2.17 0 0 0 0 3.08c.82.82 2.13.85 3 .07l2.07-1.9a2.82 2.82 0 0 1 3.79 0l2.96 2.66",key:"4oyue0"}],["path",{d:"m18 15-2-2",key:"60u0ii"}],["path",{d:"m15 18-2-2",key:"6p76be"}]]);/** 517 * @license lucide-react v0.462.0 - ISC 518 * 519 * This source code is licensed under the ISC license. 520 * See the LICENSE file in the root directory of this source tree. 521 */const Y_=ce("HeartPulse",[["path",{d:"M19 14c1.49-1.46 3-3.21 3-5.5A5.5 5.5 0 0 0 16.5 3c-1.76 0-3 .5-4.5 2-1.5-1.5-2.74-2-4.5-2A5.5 5.5 0 0 0 2 8.5c0 2.3 1.5 4.05 3 5.5l7 7Z",key:"c3ymky"}],["path",{d:"M3.22 12H9.5l.5-1 2 4.5 2-7 1.5 3.5h5.27",key:"1uw2ng"}]]);/** 522 * @license lucide-react v0.462.0 - ISC 523 * 524 * This source code is licensed under the ISC license. 525 * See the LICENSE file in the root directory of this source tree. 526 */const ta=ce("Heart",[["path",{d:"M19 14c1.49-1.46 3-3.21 3-5.5A5.5 5.5 0 0 0 16.5 3c-1.76 0-3 .5-4.5 2-1.5-1.5-2.74-2-4.5-2A5.5 5.5 0 0 0 2 8.5c0 2.3 1.5 4.05 3 5.5l7 7Z",key:"c3ymky"}]]);/** 527 * @license lucide-react v0.462.0 - ISC 528 * 529 * This source code is licensed under the ISC license. 530 * See the LICENSE file in the root directory of this source tree. 531 */const en=ce("History",[["path",{d:"M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8",key:"1357e3"}],["path",{d:"M3 3v5h5",key:"1xhq8a"}],["path",{d:"M12 7v5l4 2",key:"1fdv2h"}]]);/** 532 * @license lucide-react v0.462.0 - ISC 533 * 534 * This source code is licensed under the ISC license. 535 * See the LICENSE file in the root directory of this source tree. 536 */const RO=ce("Hourglass",[["path",{d:"M5 22h14",key:"ehvnwv"}],["path",{d:"M5 2h14",key:"pdyrp9"}],["path",{d:"M17 22v-4.172a2 2 0 0 0-.586-1.414L12 12l-4.414 4.414A2 2 0 0 0 7 17.828V22",key:"1d314k"}],["path",{d:"M7 2v4.172a2 2 0 0 0 .586 1.414L12 12l4.414-4.414A2 2 0 0 0 17 6.172V2",key:"1vvvr6"}]]);/** 537 * @license lucide-react v0.462.0 - ISC 538 * 539 * This source code is licensed under the ISC license. 540 * See the LICENSE file in the root directory of this source tree. 541 */const K_=ce("House",[["path",{d:"M15 21v-8a1 1 0 0 0-1-1h-4a1 1 0 0 0-1 1v8",key:"5wwlr5"}],["path",{d:"M3 10a2 2 0 0 1 .709-1.528l7-5.999a2 2 0 0 1 2.582 0l7 5.999A2 2 0 0 1 21 10v9a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2z",key:"1d0kgt"}]]);/** 542 * @license lucide-react v0.462.0 - ISC 543 * 544 * This source code is licensed under the ISC license. 545 * See the LICENSE file in the root directory of this source tree. 546 */const Sy=ce("IdCard",[["path",{d:"M16 10h2",key:"8sgtl7"}],["path",{d:"M16 14h2",key:"epxaof"}],["path",{d:"M6.17 15a3 3 0 0 1 5.66 0",key:"n6f512"}],["circle",{cx:"9",cy:"11",r:"2",key:"yxgjnd"}],["rect",{x:"2",y:"5",width:"20",height:"14",rx:"2",key:"qneu4z"}]]);/** 547 * @license lucide-react v0.462.0 - ISC 548 * 549 * This source code is licensed under the ISC license. 550 * See the LICENSE file in the root directory of this source tree. 551 */const KS=ce("Image",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",ry:"2",key:"1m3agn"}],["circle",{cx:"9",cy:"9",r:"2",key:"af1f0g"}],["path",{d:"m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21",key:"1xmnt7"}]]);/** 552 * @license lucide-react v0.462.0 - ISC 553 * 554 * This source code is licensed under the ISC license. 555 * See the LICENSE file in the root directory of this source tree. 556 */const QS=ce("Inbox",[["polyline",{points:"22 12 16 12 14 15 10 15 8 12 2 12",key:"o97t9d"}],["path",{d:"M5.45 5.11 2 12v6a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2v-6l-3.45-6.89A2 2 0 0 0 16.76 4H7.24a2 2 0 0 0-1.79 1.11z",key:"oot6mr"}]]);/** 557 * @license lucide-react v0.462.0 - ISC 558 * 559 * This source code is licensed under the ISC license. 560 * See the LICENSE file in the root directory of this source tree. 561 */const Bi=ce("Info",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 16v-4",key:"1dtifu"}],["path",{d:"M12 8h.01",key:"e9boi3"}]]);/** 562 * @license lucide-react v0.462.0 - ISC 563 * 564 * This source code is licensed under the ISC license. 565 * See the LICENSE file in the root directory of this source tree. 566 */const ka=ce("KeyRound",[["path",{d:"M2.586 17.414A2 2 0 0 0 2 18.828V21a1 1 0 0 0 1 1h3a1 1 0 0 0 1-1v-1a1 1 0 0 1 1-1h1a1 1 0 0 0 1-1v-1a1 1 0 0 1 1-1h.172a2 2 0 0 0 1.414-.586l.814-.814a6.5 6.5 0 1 0-4-4z",key:"1s6t7t"}],["circle",{cx:"16.5",cy:"7.5",r:".5",fill:"currentColor",key:"w0ekpg"}]]);/** 567 * @license lucide-react v0.462.0 - ISC 568 * 569 * This source code is licensed under the ISC license. 570 * See the LICENSE file in the root directory of this source tree. 571 */const Zm=ce("Landmark",[["line",{x1:"3",x2:"21",y1:"22",y2:"22",key:"j8o0r"}],["line",{x1:"6",x2:"6",y1:"18",y2:"11",key:"10tf0k"}],["line",{x1:"10",x2:"10",y1:"18",y2:"11",key:"54lgf6"}],["line",{x1:"14",x2:"14",y1:"18",y2:"11",key:"380y"}],["line",{x1:"18",x2:"18",y1:"18",y2:"11",key:"1kevvc"}],["polygon",{points:"12 2 20 7 4 7",key:"jkujk7"}]]);/** 572 * @license lucide-react v0.462.0 - ISC 573 * 574 * This source code is licensed under the ISC license. 575 * See the LICENSE file in the root directory of this source tree. 576 */const IO=ce("Laptop",[["path",{d:"M20 16V7a2 2 0 0 0-2-2H6a2 2 0 0 0-2 2v9m16 0H4m16 0 1.28 2.55a1 1 0 0 1-.9 1.45H3.62a1 1 0 0 1-.9-1.45L4 16",key:"tarvll"}]]);/** 577 * @license lucide-react v0.462.0 - ISC 578 * 579 * This source code is licensed under the ISC license. 580 * See the LICENSE file in the root directory of this source tree. 581 */const Jx=ce("Layers",[["path",{d:"m12.83 2.18a2 2 0 0 0-1.66 0L2.6 6.08a1 1 0 0 0 0 1.83l8.58 3.91a2 2 0 0 0 1.66 0l8.58-3.9a1 1 0 0 0 0-1.83Z",key:"8b97xw"}],["path",{d:"m22 17.65-9.17 4.16a2 2 0 0 1-1.66 0L2 17.65",key:"dd6zsq"}],["path",{d:"m22 12.65-9.17 4.16a2 2 0 0 1-1.66 0L2 12.65",key:"ep9fru"}]]);/** 582 * @license lucide-react v0.462.0 - ISC 583 * 584 * This source code is licensed under the ISC license. 585 * See the LICENSE file in the root directory of this source tree.
586 */const Q_=ce("LayoutDashboard",[["rect",{width:"7",height:"9",x:"3",y:"3",rx:"1",key:"10lvy0"}],["rect",{width:"7",height:"5",x:"14",y:"3",rx:"1",key:"16une8"}],["rect",{width:"7",height:"9",x:"14",y:"12",rx:"1",key:"1hutg5"}],["rect",{width:"7",height:"5",x:"3",y:"16",rx:"1",key:"ldoo1y"}]]);/** 587 * @license lucide-react v0.462.0 - ISC 588 * 589 * This source code is licensed under the ISC license. 590 * See the LICENSE file in the root directory of this source tree. 591 */const $O=ce("LayoutGrid",[["rect",{width:"7",height:"7",x:"3",y:"3",rx:"1",key:"1g98yp"}],["rect",{width:"7",height:"7",x:"14",y:"3",rx:"1",key:"6d4xhi"}],["rect",{width:"7",height:"7",x:"14",y:"14",rx:"1",key:"nxv5o0"}],["rect",{width:"7",height:"7",x:"3",y:"14",rx:"1",key:"1bb6yr"}]]);/** 592 * @license lucide-react v0.462.0 - ISC 593 * 594 * This source code is licensed under the ISC license. 595 * See the LICENSE file in the root directory of this source tree. 596 */const On=ce("Leaf",[["path",{d:"M11 20A7 7 0 0 1 9.8 6.1C15.5 5 17 4.48 19 2c1 2 2 4.18 2 8 0 5.5-4.78 10-10 10Z",key:"nnexq3"}],["path",{d:"M2 21c0-3 1.85-5.36 5.08-6C9.5 14.52 12 13 13 12",key:"mt58a7"}]]);/** 597 * @license lucide-react v0.462.0 - ISC 598 * 599 * This source code is licensed under the ISC license. 600 * See the LICENSE file in the root directory of this source tree. 601 */const Xs=ce("Link2",[["path",{d:"M9 17H7A5 5 0 0 1 7 7h2",key:"8i5ue5"}],["path",{d:"M15 7h2a5 5 0 1 1 0 10h-2",key:"1b9ql8"}],["line",{x1:"8",x2:"16",y1:"12",y2:"12",key:"1jonct"}]]);/** 602 * @license lucide-react v0.462.0 - ISC 603 * 604 * This source code is licensed under the ISC license. 605 * See the LICENSE file in the root directory of this source tree. 606 */const JS=ce("Link",[["path",{d:"M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71",key:"1cjeqo"}],["path",{d:"M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71",key:"19qd67"}]]);/** 607 * @license lucide-react v0.462.0 - ISC 608 * 609 * This source code is licensed under the ISC license. 610 * See the LICENSE file in the root directory of this source tree. 611 */const zO=ce("ListChecks",[["path",{d:"m3 17 2 2 4-4",key:"1jhpwq"}],["path",{d:"m3 7 2 2 4-4",key:"1obspn"}],["path",{d:"M13 6h8",key:"15sg57"}],["path",{d:"M13 12h8",key:"h98zly"}],["path",{d:"M13 18h8",key:"oe0vm4"}]]);/** 612 * @license lucide-react v0.462.0 - ISC 613 * 614 * This source code is licensed under the ISC license. 615 * See the LICENSE file in the root directory of this source tree. 616 */const BP=ce("ListOrdered",[["path",{d:"M10 12h11",key:"6m4ad9"}],["path",{d:"M10 18h11",key:"11hvi2"}],["path",{d:"M10 6h11",key:"c7qv1k"}],["path",{d:"M4 10h2",key:"16xx2s"}],["path",{d:"M4 6h1v4",key:"cnovpq"}],["path",{d:"M6 18H4c0-1 2-2 2-3s-1-1.5-2-1",key:"m9a95d"}]]);/** 617 * @license lucide-react v0.462.0 - ISC 618 * 619 * This source code is licensed under the ISC license. 620 * See the LICENSE file in the root directory of this source tree. 621 */const de=ce("LoaderCircle",[["path",{d:"M21 12a9 9 0 1 1-6.219-8.56",key:"13zald"}]]);/** 622 * @license lucide-react v0.462.0 - ISC 623 * 624 * This source code is licensed under the ISC license. 625 * See the LICENSE file in the root directory of this source tree. 626 */const J_=ce("LockOpen",[["rect",{width:"18",height:"11",x:"3",y:"11",rx:"2",ry:"2",key:"1w4ew1"}],["path",{d:"M7 11V7a5 5 0 0 1 9.9-1",key:"1mm8w8"}]]);/** 627 * @license lucide-react v0.462.0 - ISC 628 * 629 * This source code is licensed under the ISC license. 630 * See the LICENSE file in the root directory of this source tree. 631 */const Xe=ce("Lock",[["rect",{width:"18",height:"11",x:"3",y:"11",rx:"2",ry:"2",key:"1w4ew1"}],["path",{d:"M7 11V7a5 5 0 0 1 10 0v4",key:"fwvmzm"}]]);/** 632 * @license lucide-react v0.462.0 - ISC 633 * 634 * This source code is licensed under the ISC license. 635 * See the LICENSE file in the root directory of this source tree. 636 */const $o=ce("LogIn",[["path",{d:"M15 3h4a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2h-4",key:"u53s6r"}],["polyline",{points:"10 17 15 12 10 7",key:"1ail0h"}],["line",{x1:"15",x2:"3",y1:"12",y2:"12",key:"v6grx8"}]]);/** 637 * @license lucide-react v0.462.0 - ISC 638 * 639 * This source code is licensed under the ISC license. 640 * See the LICENSE file in the root directory of this source tree. 641 */const bo=ce("LogOut",[["path",{d:"M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4",key:"1uf3rs"}],["polyline",{points:"16 17 21 12 16 7",key:"1gabdz"}],["line",{x1:"21",x2:"9",y1:"12",y2:"12",key:"1uyos4"}]]);/** 642 * @license lucide-react v0.462.0 - ISC 643 * 644 * This source code is licensed under the ISC license. 645 * See the LICENSE file in the root directory of this source tree. 646 */const gd=ce("MailCheck",[["path",{d:"M22 13V6a2 2 0 0 0-2-2H4a2 2 0 0 0-2 2v12c0 1.1.9 2 2 2h8",key:"12jkf8"}],["path",{d:"m22 7-8.97 5.7a1.94 1.94 0 0 1-2.06 0L2 7",key:"1ocrg3"}],["path",{d:"m16 19 2 2 4-4",key:"1b14m6"}]]);/** 647 * @license lucide-react v0.462.0 - ISC 648 * 649 * This source code is licensed under the ISC license. 650 * See the LICENSE file in the root directory of this source tree. 651 */const LO=ce("MailWarning",[["path",{d:"M22 10.5V6a2 2 0 0 0-2-2H4a2 2 0 0 0-2 2v12c0 1.1.9 2 2 2h12.5",key:"e61zoh"}],["path",{d:"m22 7-8.97 5.7a1.94 1.94 0 0 1-2.06 0L2 7",key:"1ocrg3"}],["path",{d:"M20 14v4",key:"1hm744"}],["path",{d:"M20 22v.01",key:"12bgn6"}]]);/** 652 * @license lucide-react v0.462.0 - ISC 653 * 654 * This source code is licensed under the ISC license. 655 * See the LICENSE file in the root directory of this source tree. 656 */const UP=ce("MailX",[["path",{d:"M22 13V6a2 2 0 0 0-2-2H4a2 2 0 0 0-2 2v12c0 1.1.9 2 2 2h9",key:"1j9vog"}],["path",{d:"m22 7-8.97 5.7a1.94 1.94 0 0 1-2.06 0L2 7",key:"1ocrg3"}],["path",{d:"m17 17 4 4",key:"1b3523"}],["path",{d:"m21 17-4 4",key:"uinynz"}]]);/** 657 * @license lucide-react v0.462.0 - ISC 658 * 659 * This source code is licensed under the ISC license. 660 * See the LICENSE file in the root directory of this source tree. 661 */const Ye=ce("Mail",[["rect",{width:"20",height:"16",x:"2",y:"4",rx:"2",key:"18n3k1"}],["path",{d:"m22 7-8.97 5.7a1.94 1.94 0 0 1-2.06 0L2 7",key:"1ocrg3"}]]);/** 662 * @license lucide-react v0.462.0 - ISC 663 * 664 * This source code is licensed under the ISC license. 665 * See the LICENSE file in the root directory of this source tree. 666 */const zt=ce("MapPin",[["path",{d:"M20 10c0 4.993-5.539 10.193-7.399 11.799a1 1 0 0 1-1.202 0C9.539 20.193 4 14.993 4 10a8 8 0 0 1 16 0",key:"1r0f0z"}],["circle",{cx:"12",cy:"10",r:"3",key:"ilqhr7"}]]);/** 667 * @license lucide-react v0.462.0 - ISC 668 * 669 * This source code is licensed under the ISC license. 670 * See the LICENSE file in the root directory of this source tree. 671 */const qP=ce("Map",[["path",{d:"M14.106 5.553a2 2 0 0 0 1.788 0l3.659-1.83A1 1 0 0 1 21 4.619v12.764a1 1 0 0 1-.553.894l-4.553 2.277a2 2 0 0 1-1.788 0l-4.212-2.106a2 2 0 0 0-1.788 0l-3.659 1.83A1 1 0 0 1 3 19.381V6.618a1 1 0 0 1 .553-.894l4.553-2.277a2 2 0 0 1 1.788 0z",key:"169xi5"}],["path",{d:"M15 5.764v15",key:"1pn4in"}],["path",{d:"M9 3.236v15",key:"1uimfh"}]]);/** 672 * @license lucide-react v0.462.0 - ISC 673 * 674 * This source code is licensed under the ISC license. 675 * See the LICENSE file in the root directory of this source tree. 676 */const ix=ce("Megaphone",[["path",{d:"m3 11 18-5v12L3 14v-3z",key:"n962bs"}],["path",{d:"M11.6 16.8a3 3 0 1 1-5.8-1.6",key:"1yl0tm"}]]);/** 677 * @license lucide-react v0.462.0 - ISC 678 * 679 * This source code is licensed under the ISC license. 680 * See the LICENSE file in the root directory of this source tree. 681 */const OO=ce("Menu",[["line",{x1:"4",x2:"20",y1:"12",y2:"12",key:"1e0a9i"}],["line",{x1:"4",x2:"20",y1:"6",y2:"6",key:"1owob3"}],["line",{x1:"4",x2:"20",y1:"18",y2:"18",key:"yk5zj1"}]]);/** 682 * @license lucide-react v0.462.0 - ISC 683 * 684 * This source code is licensed under the ISC license. 685 * See the LICENSE file in the root directory of this source tree. 686 */const X_=ce("MessageCircle",[["path",{d:"M7.9 20A9 9 0 1 0 4 16.1L2 22Z",key:"vv11sd"}]]);/** 687 * @license lucide-react v0.462.0 - ISC 688 * 689 * This source code is licensed under the ISC license. 690 * See the LICENSE file in the root directory of this source tree. 691 */const jr=ce("MessageSquare",[["path",{d:"M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z",key:"1lielz"}]]);/** 692 * @license lucide-react v0.462.0 - ISC 693 * 694 * This source code is licensed under the ISC license. 695 * See the LICENSE file in the root directory of this source tree. 696 */const m0=ce("Microscope",[["path",{d:"M6 18h8",key:"1borvv"}],["path",{d:"M3 22h18",key:"8prr45"}],["path",{d:"M14 22a7 7 0 1 0 0-14h-1",key:"1jwaiy"}],["path",{d:"M9 14h2",key:"197e7h"}
696],["path",{d:"M9 12a2 2 0 0 1-2-2V6h6v4a2 2 0 0 1-2 2Z",key:"1bmzmy"}],["path",{d:"M12 6V3a1 1 0 0 0-1-1H9a1 1 0 0 0-1 1v3",key:"1drr47"}]]);/** 697 * @license lucide-react v0.462.0 - ISC 698 * 699 * This source code is licensed under the ISC license. 700 * See the LICENSE file in the root directory of this source tree. 701 */const Ml=ce("Minus",[["path",{d:"M5 12h14",key:"1ays0h"}]]);/** 702 * @license lucide-react v0.462.0 - ISC 703 * 704 * This source code is licensed under the ISC license. 705 * See the LICENSE file in the root directory of this source tree. 706 */const XS=ce("Monitor",[["rect",{width:"20",height:"14",x:"2",y:"3",rx:"2",key:"48i651"}],["line",{x1:"8",x2:"16",y1:"21",y2:"21",key:"1svkeh"}],["line",{x1:"12",x2:"12",y1:"17",y2:"21",key:"vw1qmm"}]]);/** 707 * @license lucide-react v0.462.0 - ISC 708 * 709 * This source code is licensed under the ISC license. 710 * See the LICENSE file in the root directory of this source tree. 711 */const ox=ce("Moon",[["path",{d:"M12 3a6 6 0 0 0 9 9 9 9 0 1 1-9-9Z",key:"a7tn18"}]]);/** 712 * @license lucide-react v0.462.0 - ISC 713 * 714 * This source code is licensed under the ISC license. 715 * See the LICENSE file in the root directory of this source tree. 716 */const e5=ce("MousePointerClick",[["path",{d:"M14 4.1 12 6",key:"ita8i4"}],["path",{d:"m5.1 8-2.9-.8",key:"1go3kf"}],["path",{d:"m6 12-1.9 2",key:"mnht97"}],["path",{d:"M7.2 2.2 8 5.1",key:"1cfko1"}],["path",{d:"M9.037 9.69a.498.498 0 0 1 .653-.653l11 4.5a.5.5 0 0 1-.074.949l-4.349 1.041a1 1 0 0 0-.74.739l-1.04 4.35a.5.5 0 0 1-.95.074z",key:"s0h3yz"}]]);/** 717 * @license lucide-react v0.462.0 - ISC 718 * 719 * This source code is licensed under the ISC license. 720 * See the LICENSE file in the root directory of this source tree. 721 */const MO=ce("Move",[["path",{d:"M12 2v20",key:"t6zp3m"}],["path",{d:"m15 19-3 3-3-3",key:"11eu04"}],["path",{d:"m19 9 3 3-3 3",key:"1mg7y2"}],["path",{d:"M2 12h20",key:"9i4pu4"}],["path",{d:"m5 9-3 3 3 3",key:"j64kie"}],["path",{d:"m9 5 3-3 3 3",key:"l8vdw6"}]]);/** 722 * @license lucide-react v0.462.0 - ISC 723 * 724 * This source code is licensed under the ISC license. 725 * See the LICENSE file in the root directory of this source tree. 726 */const eC=ce("Navigation",[["polygon",{points:"3 11 22 2 13 21 11 13 3 11",key:"1ltx0t"}]]);/** 727 * @license lucide-react v0.462.0 - ISC 728 * 729 * This source code is licensed under the ISC license. 730 * See the LICENSE file in the root directory of this source tree. 731 */const WP=ce("Newspaper",[["path",{d:"M4 22h16a2 2 0 0 0 2-2V4a2 2 0 0 0-2-2H8a2 2 0 0 0-2 2v16a2 2 0 0 1-2 2Zm0 0a2 2 0 0 1-2-2v-9c0-1.1.9-2 2-2h2",key:"7pis2x"}],["path",{d:"M18 14h-8",key:"sponae"}],["path",{d:"M15 18h-5",key:"95g1m2"}],["path",{d:"M10 6h8v4h-8V6Z",key:"smlsk5"}]]);/** 732 * @license lucide-react v0.462.0 - ISC 733 * 734 * This source code is licensed under the ISC license. 735 * See the LICENSE file in the root directory of this source tree. 736 */const BO=ce("NotebookPen",[["path",{d:"M13.4 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2v-7.4",key:"re6nr2"}],["path",{d:"M2 6h4",key:"aawbzj"}],["path",{d:"M2 10h4",key:"l0bgd4"}],["path",{d:"M2 14h4",key:"1gsvsf"}],["path",{d:"M2 18h4",key:"1bu2t1"}],["path",{d:"M21.378 5.626a1 1 0 1 0-3.004-3.004l-5.01 5.012a2 2 0 0 0-.506.854l-.837 2.87a.5.5 0 0 0 .62.62l2.87-.837a2 2 0 0 0 .854-.506z",key:"pqwjuv"}]]);/** 737 * @license lucide-react v0.462.0 - ISC 738 * 739 * This source code is licensed under the ISC license. 740 * See the LICENSE file in the root directory of this source tree. 741 */const _d=ce("Package",[["path",{d:"M11 21.73a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16V8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73z",key:"1a0edw"}],["path",{d:"M12 22V12",key:"d0xqtd"}],["path",{d:"m3.3 7 7.703 4.734a2 2 0 0 0 1.994 0L20.7 7",key:"yx3hmr"}],["path",{d:"m7.5 4.27 9 5.15",key:"1c824w"}]]);/** 742 * @license lucide-react v0.462.0 - ISC 743 * 744 * This source code is licensed under the ISC license. 745 * See the LICENSE file in the root directory of this source tree. 746 */const lx=ce("Palette",[["circle",{cx:"13.5",cy:"6.5",r:".5",fill:"currentColor",key:"1okk4w"}],["circle",{cx:"17.5",cy:"10.5",r:".5",fill:"currentColor",key:"f64h9f"}],["circle",{cx:"8.5",cy:"7.5",r:".5",fill:"currentColor",key:"fotxhn"}],["circle",{cx:"6.5",cy:"12.5",r:".5",fill:"currentColor",key:"qy21gx"}],["path",{d:"M12 2C6.5 2 2 6.5 2 12s4.5 10 10 10c.926 0 1.648-.746 1.648-1.688 0-.437-.18-.835-.437-1.125-.29-.289-.438-.652-.438-1.125a1.64 1.64 0 0 1 1.668-1.668h1.996c3.051 0 5.555-2.503 5.555-5.554C21.965 6.012 17.461 2 12 2z",key:"12rzf8"}]]);/** 747 * @license lucide-react v0.462.0 - ISC 748 * 749 * This source code is licensed under the ISC license. 750 * See the LICENSE file in the root directory of this source tree. 751 */const HP=ce("Pause",[["rect",{x:"14",y:"4",width:"4",height:"16",rx:"1",key:"zuxfzm"}],["rect",{x:"6",y:"4",width:"4",height:"16",rx:"1",key:"1okwgv"}]]);/** 752 * @license lucide-react v0.462.0 - ISC 753 * 754 * This source code is licensed under the ISC license. 755 * See the LICENSE file in the root directory of this source tree. 756 */const GP=ce("PenLine",[["path",{d:"M12 20h9",key:"t2du7b"}],["path",{d:"M16.376 3.622a1 1 0 0 1 3.002 3.002L7.368 18.635a2 2 0 0 1-.855.506l-2.872.838a.5.5 0 0 1-.62-.62l.838-2.872a2 2 0 0 1 .506-.854z",key:"1ykcvy"}]]);/** 757 * @license lucide-react v0.462.0 - ISC 758 * 759 * This source code is licensed under the ISC license. 760 * See the LICENSE file in the root directory of this source tree. 761 */const u2=ce("Pencil",[["path",{d:"M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z",key:"1a8usu"}],["path",{d:"m15 5 4 4",key:"1mk7zo"}]]);/** 762 * @license lucide-react v0.462.0 - ISC 763 * 764 * This source code is licensed under the ISC license. 765 * See the LICENSE file in the root directory of this source tree. 766 */const Qt=ce("Phone",[["path",{d:"M22 16.92v3a2 2 0 0 1-2.18 2 19.79 19.79 0 0 1-8.63-3.07 19.5 19.5 0 0 1-6-6 19.79 19.79 0 0 1-3.07-8.67A2 2 0 0 1 4.11 2h3a2 2 0 0 1 2 1.72 12.84 12.84 0 0 0 .7 2.81 2 2 0 0 1-.45 2.11L8.09 9.91a16 16 0 0 0 6 6l1.27-1.27a2 2 0 0 1 2.11-.45 12.84 12.84 0 0 0 2.81.7A2 2 0 0 1 22 16.92z",key:"foiqr5"}]]);/** 767 * @license lucide-react v0.462.0 - ISC 768 * 769 * This source code is licensed under the ISC license. 770 * See the LICENSE file in the root directory of this source tree. 771 */const UO=ce("PiggyBank",[["path",{d:"M19 5c-1.5 0-2.8 1.4-3 2-3.5-1.5-11-.3-11 5 0 1.8 0 3 2 4.5V20h4v-2h3v2h4v-4c1-.5 1.7-1 2-2h2v-4h-2c0-1-.5-1.5-1-2V5z",key:"1ivx2i"}],["path",{d:"M2 9v1c0 1.1.9 2 2 2h1",key:"nm575m"}],["path",{d:"M16 11h.01",key:"xkw8gn"}]]);/** 772 * @license lucide-react v0.462.0 - ISC 773 * 774 * This source code is licensed under the ISC license. 775 * See the LICENSE file in the root directory of this source tree. 776 */const Xx=ce("Play",[["polygon",{points:"6 3 20 12 6 21 6 3",key:"1oa8hb"}]]);/** 777 * @license lucide-react v0.462.0 - ISC 778 * 779 * This source code is licensed under the ISC license. 780 * See the LICENSE file in the root directory of this source tree. 781 */const tn=ce("Plus",[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]]);/** 782 * @license lucide-react v0.462.0 - ISC 783 * 784 * This source code is licensed under the ISC license. 785 * See the LICENSE file in the root directory of this source tree. 786 */const qO=ce("Power",[["path",{d:"M12 2v10",key:"mnfbl"}],["path",{d:"M18.4 6.6a9 9 0 1 1-12.77.04",key:"obofu9"}]]);/** 787 * @license lucide-react v0.462.0 - ISC 788 * 789 * This source code is licensed under the ISC license. 790 * See the LICENSE file in the root directory of this source tree. 791 */const ef=ce("Printer",[["path",{d:"M6 18H4a2 2 0 0 1-2-2v-5a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2v5a2 2 0 0 1-2 2h-2",key:"143wyd"}],["path",{d:"M6 9V3a1 1 0 0 1 1-1h10a1 1 0 0 1 1 1v6",key:"1itne7"}],["rect",{x:"6",y:"14",width:"12",height:"8",rx:"1",key:"1ue0tg"}]]);/** 792 * @license lucide-react v0.462.0 - ISC 793 * 794 * This source code is licensed under the ISC license. 795 * See the LICENSE file in the root directory of this source tree. 796 */const WO=ce("Quote",[["path",{d:"M16 3a2 2 0 0 0-2 2v6a2 2 0 0 0 2 2 1 1 0 0 1 1 1v1a2 2 0 0 1-2 2 1 1 0 0 0-1 1v2a1 1 0 0 0 1 1 6 6 0 0 0 6-6V5a2 2 0 0 0-2-2z",key:"rib7q0"}],["path",{d:"M5 3a2 2 0 0 0-2 2v6a2 2 0 0 0 2 2 1 1 0 0 1 1 1v1a2 2 0 0 1-2 2 1 1 0 0 0-1 1v2a1 1 0 0 0 1 1 6 6 0 0 0 6-6V5a2 2 0 0 0-2-2z",key:"1ymkrd"}]]);/** 797 * @license lucide-react v0.462.0 - ISC 798 * 799 * This source code is licensed under the ISC license. 800 * See the LICENSE file in the root directory of this source tree. 801 */const VP=ce("Radio",[["path",{d:"M4.9 19.1C1 15.2 1 8.8 4.9 4.9",key:"1vaf9d"}],["path",{d:"M7.8 16.2c-2.3-2.3-2.3-6.1 0-8.5",key:"u1ii0m"}],["circle",{cx:"12",cy:"12",r:"2",key:"1c9p78"}],["path",{d:"M16.2 7.8c2.3 2.3 2.3 6.1 0 8.5",key:"1j5fej"}],["path",{d:"M19.1 4.9C23 8.8 23 15.1 19.1 19",key:"10b0cb"}]]);/** 802 * @license lucide-react v0.462.0 - ISC 803 * 804 * This source code is licensed under the ISC license. 805 * See the LICENSE file in the root directory of this source tree. 806 */const cx=ce("Receipt",[["path",{d:"M4 2v20l2-1 2 1 2-1 2 1 2-1 2 1 2-1 2 1V2l-2 1-2-1-2 1-2-1-2 1-2-1-2 1Z",key:"q3az6g"}],["path",{d:"M16 8h-6a2 2 0 1 0 0 4h4a2 2 0 1 1 0 4H8",key:"1h4pet"}],["path",{d:"M12 17.5v-11",key:"1jc1ny"}]]);/** 807 * @license lucide-react v0.462.0 - ISC 808 * 809 * This source code is licensed under the ISC license. 810 * See the LICENSE file in the root directory of this source tree. 811 */const Be=ce("RefreshCw",[["path",{d:"M3 12a9 9 0 0 1 9-9 9.75 9.75 0 0 1 6.74 2.74L21 8",key:"v9h5vc"}],["path",{d:"M21 3v5h-5",key:"1q7to0"}],["path",{d:"M21 12a9 9 0 0 1-9 9 9.75 9.75 0 0 1-6.74-2.74L3 16",key:"3uifl3"}],["path",{d:"M8 16H3v5",key:"1cv678"}]]);/** 812 * @license lucide-react v0.462.0 - ISC 813 * 814 * This source code is licensed under the ISC license. 815 * See the LICENSE file in the root directory of this source tree. 816 */const Bu=ce("Repeat",[["path",{d:"m17 2 4 4-4 4",key:"nntrym"}],["path",{d:"M3 11v-1a4 4 0 0 1 4-4h14",key:"84bu3i"}],["path",{d:"m7 22-4-4 4-4",key:"1wqhfi"}],["path",{d:"M21 13v1a4 4 0 0 1-4 4H3",key:"1rx37r"}]]);/** 817 * @license lucide-react v0.462.0 - ISC 818 * 819 * This source code is licensed under the ISC license. 820 * See the LICENSE file in the root directory of this source tree. 821 */const zi=ce("RotateCcw",[["path",{d:"M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8",key:"1357e3"}],["path",{d:"M3 3v5h5",key:"1xhq8a"}]]);/** 822 * @license lucide-react v0.462.0 - ISC 823 * 824 * This source code is licensed under the ISC license. 825 * See the LICENSE file in the root directory of this source tree. 826 */const ZP=ce("Route",[["circle",{cx:"6",cy:"19",r:"3",key:"1kj8tv"}],["path",{d:"M9 19h8.5a3.5 3.5 0 0 0 0-7h-11a3.5 3.5 0 0 1 0-7H15",key:"1d8sl"}],["circle",{cx:"18",cy:"5",r:"3",key:"gq8acd"}]]);/** 827 * @license lucide-react v0.462.0 - ISC 828 * 829 * This source code is licensed under the ISC license. 830 * See the LICENSE file in the root directory of this source tree. 831 */const ti=ce("Save",[["path",{d:"M15.2 3a2 2 0 0 1 1.4.6l3.8 3.8a2 2 0 0 1 .6 1.4V19a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2z",key:"1c8476"}],["path",{d:"M17 21v-7a1 1 0 0 0-1-1H8a1 1 0 0 0-1 1v7",key:"1ydtos"}],["path",{d:"M7 3v4a1 1 0 0 0 1 1h7",key:"t51u73"}]]);/** 832 * @license lucide-react v0.462.0 - ISC 833 * 834 * This source code is licensed under the ISC license. 835 * See the LICENSE file in the root directory of this source tree. 836 */const HO=ce("Scale",[["path",{d:"m16 16 3-8 3 8c-.87.65-1.92 1-3 1s-2.13-.35-3-1Z",key:"7g6ntu"}],["path",{d:"m2 16 3-8 3 8c-.87.65-1.92 1-3 1s-2.13-.35-3-1Z",key:"ijws7r"}],["path",{d:"M7 21h10",key:"1b0cd5"}],["path",{d:"M12 3v18",key:"108xh3"}
836],["path",{d:"M3 7h2c2 0 5-1 7-2 2 1 5 2 7 2h2",key:"3gwbw2"}]]);/** 837 * @license lucide-react v0.462.0 - ISC 838 * 839 * This source code is licensed under the ISC license. 840 * See the LICENSE file in the root directory of this source tree. 841 */const Ss=ce("Scissors",[["circle",{cx:"6",cy:"6",r:"3",key:"1lh9wr"}],["path",{d:"M8.12 8.12 12 12",key:"1alkpv"}],["path",{d:"M20 4 8.12 15.88",key:"xgtan2"}],["circle",{cx:"6",cy:"18",r:"3",key:"fqmcym"}],["path",{d:"M14.8 14.8 20 20",key:"ptml3r"}]]);/** 842 * @license lucide-react v0.462.0 - ISC 843 * 844 * This source code is licensed under the ISC license. 845 * See the LICENSE file in the root directory of this source tree. 846 */const tm=ce("ScrollText",[["path",{d:"M15 12h-5",key:"r7krc0"}],["path",{d:"M15 8h-5",key:"1khuty"}],["path",{d:"M19 17V5a2 2 0 0 0-2-2H4",key:"zz82l3"}],["path",{d:"M8 21h12a2 2 0 0 0 2-2v-1a1 1 0 0 0-1-1H11a1 1 0 0 0-1 1v1a2 2 0 1 1-4 0V5a2 2 0 1 0-4 0v2a1 1 0 0 0 1 1h3",key:"1ph1d7"}]]);/** 847 * @license lucide-react v0.462.0 - ISC 848 * 849 * This source code is licensed under the ISC license. 850 * See the LICENSE file in the root directory of this source tree. 851 */const Bt=ce("Search",[["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}],["path",{d:"m21 21-4.3-4.3",key:"1qie3q"}]]);/** 852 * @license lucide-react v0.462.0 - ISC 853 * 854 * This source code is licensed under the ISC license. 855 * See the LICENSE file in the root directory of this source tree. 856 */const Hs=ce("Send",[["path",{d:"M14.536 21.686a.5.5 0 0 0 .937-.024l6.5-19a.496.496 0 0 0-.635-.635l-19 6.5a.5.5 0 0 0-.024.937l7.93 3.18a2 2 0 0 1 1.112 1.11z",key:"1ffxy3"}],["path",{d:"m21.854 2.147-10.94 10.939",key:"12cjpa"}]]);/** 857 * @license lucide-react v0.462.0 - ISC 858 * 859 * This source code is licensed under the ISC license. 860 * See the LICENSE file in the root directory of this source tree. 861 */const GO=ce("Server",[["rect",{width:"20",height:"8",x:"2",y:"2",rx:"2",ry:"2",key:"ngkwjq"}],["rect",{width:"20",height:"8",x:"2",y:"14",rx:"2",ry:"2",key:"iecqi9"}],["line",{x1:"6",x2:"6.01",y1:"6",y2:"6",key:"16zg32"}],["line",{x1:"6",x2:"6.01",y1:"18",y2:"18",key:"nzw8ys"}]]);/** 862 * @license lucide-react v0.462.0 - ISC 863 * 864 * This source code is licensed under the ISC license. 865 * See the LICENSE file in the root directory of this source tree. 866 */const YP=ce("Settings2",[["path",{d:"M20 7h-9",key:"3s1dr2"}],["path",{d:"M14 17H5",key:"gfn3mx"}],["circle",{cx:"17",cy:"17",r:"3",key:"18b49y"}],["circle",{cx:"7",cy:"7",r:"3",key:"dfmy0x"}]]);/** 867 * @license lucide-react v0.462.0 - ISC 868 * 869 * This source code is licensed under the ISC license. 870 * See the LICENSE file in the root directory of this source tree. 871 */const kd=ce("Settings",[["path",{d:"M12.22 2h-.44a2 2 0 0 0-2 2v.18a2 2 0 0 1-1 1.73l-.43.25a2 2 0 0 1-2 0l-.15-.08a2 2 0 0 0-2.73.73l-.22.38a2 2 0 0 0 .73 2.73l.15.1a2 2 0 0 1 1 1.72v.51a2 2 0 0 1-1 1.74l-.15.09a2 2 0 0 0-.73 2.73l.22.38a2 2 0 0 0 2.73.73l.15-.08a2 2 0 0 1 2 0l.43.25a2 2 0 0 1 1 1.73V20a2 2 0 0 0 2 2h.44a2 2 0 0 0 2-2v-.18a2 2 0 0 1 1-1.73l.43-.25a2 2 0 0 1 2 0l.15.08a2 2 0 0 0 2.73-.73l.22-.39a2 2 0 0 0-.73-2.73l-.15-.08a2 2 0 0 1-1-1.74v-.5a2 2 0 0 1 1-1.74l.15-.09a2 2 0 0 0 .73-2.73l-.22-.38a2 2 0 0 0-2.73-.73l-.15.08a2 2 0 0 1-2 0l-.43-.25a2 2 0 0 1-1-1.73V4a2 2 0 0 0-2-2z",key:"1qme2f"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}]]);/** 872 * @license lucide-react v0.462.0 - ISC 873 * 874 * This source code is licensed under the ISC license. 875 * See the LICENSE file in the root directory of this source tree. 876 */const zn=ce("ShieldAlert",[["path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z",key:"oel41y"}],["path",{d:"M12 8v4",key:"1got3b"}],["path",{d:"M12 16h.01",key:"1drbdi"}]]);/** 877 * @license lucide-react v0.462.0 - ISC 878 * 879 * This source code is licensed under the ISC license. 880 * See the LICENSE file in the root directory of this source tree. 881 */const Ie=ce("ShieldCheck",[["path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z",ke
881y:"oel41y"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]]);/** 882 * @license lucide-react v0.462.0 - ISC 883 * 884 * This source code is licensed under the ISC license. 885 * See the LICENSE file in the root directory of this source tree. 886 */const KP=ce("ShieldOff",[["path",{d:"m2 2 20 20",key:"1ooewy"}],["path",{d:"M5 5a1 1 0 0 0-1 1v7c0 5 3.5 7.5 7.67 8.94a1 1 0 0 0 .67.01c2.35-.82 4.48-1.97 5.9-3.71",key:"1jlk70"}],["path",{d:"M9.309 3.652A12.252 12.252 0 0 0 11.24 2.28a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1v7a9.784 9.784 0 0 1-.08 1.264",key:"18rp1v"}]]);/** 887 * @license lucide-react v0.462.0 - ISC 888 * 889 * This source code is licensed under the ISC license. 890 * See the LICENSE file in the root directory of this source tree. 891 */const Tt=ce("Shield",[["path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z",key:"oel41y"}]]);/** 892 * @license lucide-react v0.462.0 - ISC 893 * 894 * This source code is licensed under the ISC license. 895 * See the LICENSE file in the root directory of this source tree. 896 */const Yl=ce("ShoppingBag",[["path",{d:"M6 2 3 6v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2V6l-3-4Z",key:"hou9p0"}],["path",{d:"M3 6h18",key:"d0wm0j"}],["path",{d:"M16 10a4 4 0 0 1-8 0",key:"1ltviw"}]]);/** 897 * @license lucide-react v0.462.0 - ISC 898 * 899 * This source code is licensed under the ISC license. 900 * See the LICENSE file in the root directory of this source tree. 901 */const m2=ce("ShoppingCart",[["circle",{cx:"8",cy:"21",r:"1",key:"jimo8o"}],["circle",{cx:"19",cy:"21",r:"1",key:"13723u"}],["path",{d:"M2.05 2.05h2l2.66 12.42a2 2 0 0 0 2 1.58h9.78a2 2 0 0 0 1.95-1.57l1.65-7.43H5.12",key:"9zh506"}]]);/** 902 * @license lucide-react v0.462.0 - ISC 903 * 904 * This source code is licensed under the ISC license. 905 * See the LICENSE file in the root directory of this source tree. 906 */const Qe=ce("Sparkles",[["path",{d:"M9.937 15.5A2 2 0 0 0 8.5 14.063l-6.135-1.582a.5.5 0 0 1 0-.962L8.5 9.936A2 2 0 0 0 9.937 8.5l1.582-6.135a.5.5 0 0 1 .963 0L14.063 8.5A2 2 0 0 0 15.5 9.937l6.135 1.581a.5.5 0 0 1 0 .964L15.5 14.063a2 2 0 0 0-1.437 1.437l-1.582 6.135a.5.5 0 0 1-.963 0z",key:"4pj2yx"}],["path",{d:"M20 3v4",key:"1olli1"}],["path",{d:"M22 5h-4",key:"1gvqau"}],["path",{d:"M4 17v2",key:"vumght"}],["path",{d:"M5 18H3",key:"zchphs"}]]);/** 907 * @license lucide-react v0.462.0 - ISC 908 * 909 * This source code is licensed under the ISC license. 910 * See the LICENSE file in the root directory of this source tree. 911 */const tf=ce("Sprout",[["path",{d:"M7 20h10",key:"e6iznv"}],["path",{d:"M10 20c5.5-2.5.8-6.4 3-10",key:"161w41"}],["path",{d:"M9.5 9.4c1.1.8 1.8 2.2 2.3 3.7-2 .4-3.5.4-4.8-.3-1.2-.6-2.3-1.9-3-4.2 2.8-.5 4.4 0 5.5.8z",key:"9gtqwd"}],["path",{d:"M14.1 6a7 7 0 0 0-1.1 4c1.9-.1 3.3-.6 4.3-1.4 1-1 1.6-2.3 1.7-4.6-2.7.1-4 1-4.9 2z",key:"bkxnd2"}]]);/** 912 * @license lucide-react v0.462.0 - ISC 913 * 914 * This source code is licensed under the ISC license. 915 * See the LICENSE file in the root directory of this source tree. 916 */const vo=ce("SquareCheckBig",[["path",{d:"M21 10.5V19a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h12.5",key:"1uzm8b"}],["path",{d:"m9 11 3 3L22 4",key:"1pflzl"}]]);/** 917 * @license lucide-react v0.462.0 - ISC 918 * 919 * This source code is licensed under the ISC license. 920 * See the LICENSE file in the root directory of this source tree. 921 */const Uu=ce("Square",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}]]);/** 922 * @license lucide-react v0.462.0 - ISC 923 * 924 * This source code is licensed under the ISC license. 925 * See the LICENSE file in the root directory of this source tree. 926 */const zo=ce("Star",[["path",{d:"M11.525 2.295a.53.53 0 0 1 .95 0l2.31 4.679a2.123 2.123 0 0 0 1.595 1.16l5.166.756a.53.53 0 0 1 .294.904l-3.736 3.638a2.123 2.123 0 0 0-.611 1.878l.882 5.14a.53.53 0 0 1-.771.56l-4.618-2.428a2.122 2.122 0 0 0-1.973 0L6.396 21.01a.53.53 0 0 1-.77-.56l.881-5.139a2.122 2.122 0 0 0-.611-1.879L2.16 9.795a.53.53 0 0 1 .294-.906l5.165-.755a2.122 2.122 0 0 0 1.597-1.16z",key:"r04s7s"}]]);/** 927 * @license lucide-react v0.462.0 - ISC 928 * 929 * This source code is licensed under the ISC license. 930 * See the LICENSE file in the root directory of this source tree. 931 */const Sa=ce("Stethoscope",[["path",{d:"M11 2v2",key:"1539x4"}],["path",{d:"M5 2v2",key:"1yf1q8"}],["path",{d:"M5 3H4a2 2 0 0 0-2 2v4a6 6 0 0 0 12 0V5a2 2 0 0 0-2-2h-1",key:"rb5t3r"}],["path",{d:"M8 15a6 6 0 0 0 12 0v-3",key:"x18d4x"}],["circle",{cx:"20",cy:"10",r:"2",key:"ts1r5v"}]]);/** 932 * @license lucide-react v0.462.0 - ISC 933 * 934 * This source code is licensed under the ISC license. 935 * See the LICENSE file in the root directory of this source tree. 936 */const VO=ce("StickyNote",[["path",{d:"M16 3H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2V8Z",key:"qazsjp"}],["path",{d:"M15 3v4a2 2 0 0 0 2 2h4",key:"40519r"}]]);/** 937 * @license lucide-react v0.462.0 - ISC 938 * 939 * This source code is licensed under the ISC license. 940 * See the LICENSE file in the root directory of this source tree.
941 */const ZO=ce("Store",[["path",{d:"m2 7 4.41-4.41A2 2 0 0 1 7.83 2h8.34a2 2 0 0 1 1.42.59L22 7",key:"ztvudi"}],["path",{d:"M4 12v8a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2v-8",key:"1b2hhj"}],["path",{d:"M15 22v-4a2 2 0 0 0-2-2h-2a2 2 0 0 0-2 2v4",key:"2ebpfo"}],["path",{d:"M2 7h20",key:"1fcdvo"}],["path",{d:"M22 7v3a2 2 0 0 1-2 2a2.7 2.7 0 0 1-1.59-.63.7.7 0 0 0-.82 0A2.7 2.7 0 0 1 16 12a2.7 2.7 0 0 1-1.59-.63.7.7 0 0 0-.82 0A2.7 2.7 0 0 1 12 12a2.7 2.7 0 0 1-1.59-.63.7.7 0 0 0-.82 0A2.7 2.7 0 0 1 8 12a2.7 2.7 0 0 1-1.59-.63.7.7 0 0 0-.82 0A2.7 2.7 0 0 1 4 12a2 2 0 0 1-2-2V7",key:"6c3vgh"}]]);/** 942 * @license lucide-react v0.462.0 - ISC 943 * 944 * This source code is licensed under the ISC license. 945 * See the LICENSE file in the root directory of this source tree. 946 */const Sd=ce("Sun",[["circle",{cx:"12",cy:"12",r:"4",key:"4exip2"}],["path",{d:"M12 2v2",key:"tus03m"}],["path",{d:"M12 20v2",key:"1lh1kg"}],["path",{d:"m4.93 4.93 1.41 1.41",key:"149t6j"}],["path",{d:"m17.66 17.66 1.41 1.41",key:"ptbguv"}],["path",{d:"M2 12h2",key:"1t8f8n"}],["path",{d:"M20 12h2",key:"1q8mjw"}],["path",{d:"m6.34 17.66-1.41 1.41",key:"1m8zz5"}],["path",{d:"m19.07 4.93-1.41 1.41",key:"1shlcs"}]]);/** 947 * @license lucide-react v0.462.0 - ISC 948 * 949 * This source code is licensed under the ISC license. 950 * See the LICENSE file in the root directory of this source tree. 951 */const Cy=ce("Table2",[["path",{d:"M9 3H5a2 2 0 0 0-2 2v4m6-6h10a2 2 0 0 1 2 2v4M9 3v18m0 0h10a2 2 0 0 0 2-2V9M9 21H5a2 2 0 0 1-2-2V9m0 0h18",key:"gugj83"}]]);/** 952 * @license lucide-react v0.462.0 - ISC 953 * 954 * This source code is licensed under the ISC license. 955 * See the LICENSE file in the root directory of this source tree. 956 */const sf=ce("Tag",[["path",{d:"M12.586 2.586A2 2 0 0 0 11.172 2H4a2 2 0 0 0-2 2v7.172a2 2 0 0 0 .586 1.414l8.704 8.704a2.426 2.426 0 0 0 3.42 0l6.58-6.58a2.426 2.426 0 0 0 0-3.42z",key:"vktsd0"}],["circle",{cx:"7.5",cy:"7.5",r:".5",fill:"currentColor",key:"kqv944"}]]);/** 957 * @license lucide-react v0.462.0 - ISC 958 * 959 * This source code is licensed under the ISC license. 960 * See the LICENSE file in the root directory of this source tree. 961 */const Ym=ce("Target",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["circle",{cx:"12",cy:"12",r:"6",key:"1vlfrh"}],["circle",{cx:"12",cy:"12",r:"2",key:"1c9p78"}]]);/** 962 * @license lucide-react v0.462.0 - ISC 963 * 964 * This source code is licensed under the ISC license. 965 * See the LICENSE file in the root directory of this source tree. 966 */const YO=ce("ThumbsUp",[["path",{d:"M7 10v12",key:"1qc93n"}],["path",{d:"M15 5.88 14 10h5.83a2 2 0 0 1 1.92 2.56l-2.33 8A2 2 0 0 1 17.5 22H4a2 2 0 0 1-2-2v-8a2 2 0 0 1 2-2h2.76a2 2 0 0 0 1.79-1.11L12 2a3.13 3.13 0 0 1 3 3.88Z",key:"emmmcr"}]]);/** 967 * @license lucide-react v0.462.0 - ISC 968 * 969 * This source code is licensed under the ISC license. 970 * See the LICENSE file in the root directory of this source tree. 971 */const QP=ce("Ticket",[["path",{d:"M2 9a3 3 0 0 1 0 6v2a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2v-2a3 3 0 0 1 0-6V7a2 2 0 0 0-2-2H4a2 2 0 0 0-2 2Z",key:"qn84l0"}],["path",{d:"M13 5v2",key:"dyzc3o"}],["path",{d:"M13 17v2",key:"1ont0d"}],["path",{d:"M13 11v2",key:"1wjjxi"}]]);/** 972 * @license lucide-react v0.462.0 - ISC 973 * 974 * This source code is licensed under the ISC license. 975 * See the LICENSE file in the root directory of this source tree. 976 */const KO=ce("Timer",[["line",{x1:"10",x2:"14",y1:"2",y2:"2",key:"14vaq8"}],["line",{x1:"12",x2:"15",y1:"14",y2:"11",key:"17fdiu"}],["circle",{cx:"12",cy:"14",r:"8",key:"1e1u0o"}]]);/** 977 * @license lucide-react v0.462.0 - ISC 978 * 979 * This source code is licensed under the ISC license. 980 * See the LICENSE file in the root directory of this source tree. 981 */const va=ce("Trash2",[["path",{d:"M3 6h18",key:"d0wm0j"}],["path",{d:"M19 6v14c0 1-1 2-2 2H7c-1 0-2-1-2-2V6",key:"4alrt4"}],["path",{d:"M8 6V4c0-1 1-2 2-2h4c1 0 2 1 2 2v2",key:"v07s0e"}],["line",{x1:"10",x2:"10",y1:"11",y2:"17",key:"1uufr5"}],["line",{x1:"14",x2:"14",y1:"11",y2:"17",key:"xtxkd"}]]);/** 982 * @license lucide-react v0.462.0 - ISC 983 * 984 * This source code is licensed under the ISC license. 985 * See the LICENSE file in the root directory of this source tree. 986 */const t5=ce("TrendingDown",[["polyline",{points:"22 17 13.5 8.5 8.5 13.5 2 7",key:"1r2t7k"}],["polyline",{points:"16 17 22 17 22 11",key:"11uiuu"}]]);/** 987 * @license lucide-react v0.462.0 - ISC 988 * 989 * This source code is licensed under the ISC license. 990 * See the LICENSE file in the root directory of this source tree. 991 */const si=ce("TrendingUp",[["polyline",{points:"22 7 13.5 15.5 8.5 10.5 2 17",key:"126l90"}],["polyline",{points:"16 7 22 7 22 13",key:"kwv8wd"}]]);/** 992 * @license lucide-react v0.462.0 - ISC 993 * 994 * This source code is licensed under the ISC license. 995 * See the LICENSE file in the root directory of this source tree. 996 */const ve=ce("TriangleAlert",[["path",{d:"m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3",key:"wmoenq"}],["path",{d:"M12 9v4",key:"juzpu7"}],["path",{d:"M12 17h.01",key:"p32p05"}]]);/** 997 * @license lucide-react v0.462.0 - ISC 998 * 999 * This source code is licensed under the ISC license. 1000 * See the LICENSE file in the root directory of this source tree. 1001 */const JP=ce("Trophy",[["path",{d:"M6 9H4.5a2.5 2.5 0 0 1 0-5H6",key:"17hqa7"}],["path",{d:"M18 9h1.5a2.5 2.5 0 0 0 0-5H18",key:"lmptdp"}],["path",{d:"M4 22h16",key:"57wxv0"}
1001],["path",{d:"M10 14.66V17c0 .55-.47.98-.97 1.21C7.85 18.75 7 20.24 7 22",key:"1nw9bq"}],["path",{d:"M14 14.66V17c0 .55.47.98.97 1.21C16.15 18.75 17 20.24 17 22",key:"1np0yb"}],["path",{d:"M18 2H6v7a6 6 0 0 0 12 0V2Z",key:"u46fv3"}]]);/** 1002 * @license lucide-react v0.462.0 - ISC 1003 * 1004 * This source code is licensed under the ISC license. 1005 * See the LICENSE file in the root directory of this source tree. 1006 */const Ay=ce("Truck",[["path",{d:"M14 18V6a2 2 0 0 0-2-2H4a2 2 0 0 0-2 2v11a1 1 0 0 0 1 1h2",key:"wrbu53"}],["path",{d:"M15 18H9",key:"1lyqi6"}],["path",{d:"M19 18h2a1 1 0 0 0 1-1v-3.65a1 1 0 0 0-.22-.624l-3.48-4.35A1 1 0 0 0 17.52 8H14",key:"lysw3i"}],["circle",{cx:"17",cy:"18",r:"2",key:"332jqn"}],["circle",{cx:"7",cy:"18",r:"2",key:"19iecd"}]]);/** 1007 * @license lucide-react v0.462.0 - ISC 1008 * 1009 * This source code is licensed under the ISC license. 1010 * See the LICENSE file in the root directory of this source tree. 1011 */const Ey=ce("Undo2",[["path",{d:"M9 14 4 9l5-5",key:"102s5s"}],["path",{d:"M4 9h10.5a5.5 5.5 0 0 1 5.5 5.5a5.5 5.5 0 0 1-5.5 5.5H11",key:"f3b9sd"}]]);/** 1012 * @license lucide-react v0.462.0 - ISC 1013 * 1014 * This source code is licensed under the ISC license. 1015 * See the LICENSE file in the root directory of this source tree. 1016 */const Ri=ce("Upload",[["path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4",key:"ih7n3h"}],["polyline",{points:"17 8 12 3 7 8",key:"t8dd8p"}],["line",{x1:"12",x2:"12",y1:"3",y2:"15",key:"widbto"}]]);/** 1017 * @license lucide-react v0.462.0 - ISC 1018 * 1019 * This source code is licensed under the ISC license. 1020 * See the LICENSE file in the root directory of this source tree. 1021 */const dx=ce("UserCheck",[["path",{d:"M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2",key:"1yyitq"}],["circle",{cx:"9",cy:"7",r:"4",key:"nufk8"}],["polyline",{points:"16 11 18 13 22 9",key:"1pwet4"}]]);/** 1022 * @license lucide-react v0.462.0 - ISC 1023 * 1024 * This source code is licensed under the ISC license. 1025 * See the LICENSE file in the root directory of this source tree. 1026 */const QO=ce("UserMinus",[["path",{d:"M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2",key:"1yyitq"}],["circle",{cx:"9",cy:"7",r:"4",key:"nufk8"}],["line",{x1:"22",x2:"16",y1:"11",y2:"11",key:"1shjgl"}]]);/** 1027 * @license lucide-react v0.462.0 - ISC 1028 * 1029 * This source code is licensed under the ISC license. 1030 * See the LICENSE file in the root directory of this source tree. 1031 */const Cd=ce("UserPlus",[["path",{d:"M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2",key:"1yyitq"}],["circle",{cx:"9",cy:"7",r:"4",key:"nufk8"}],["line",{x1:"19",x2:"19",y1:"8",y2:"14",key:"1bvyxn"}],["line",{x1:"22",x2:"16",y1:"11",y2:"11",key:"1shjgl"}]]);/** 1032 * @license lucide-react v0.462.0 - ISC 1033 * 1034 * This source code is licensed under the ISC license. 1035 * See the LICENSE file in the root directory of this source tree. 1036 */const JO=ce("UserX",[["path",{d:"M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2",key:"1yyitq"}],["circle",{cx:"9",cy:"7",r:"4",key:"nufk8"}],["line",{x1:"17",x2:"22",y1:"8",y2:"13",key:"3nzzx3"}],["line",{x1:"22",x2:"17",y1:"8",y2:"13",key:"1swrse"}]]);/** 1037 * @license lucide-react v0.462.0 - ISC 1038 * 1039 * This source code is licensed under the ISC license. 1040 * See the LICENSE file in the root directory of this source tree. 1041 */const yr=ce("User",[["path",{d:"M19 21v-2a4 4 0 0 0-4-4H9a4 4 0 0 0-4 4v2",key:"975kel"}],["circle",{cx:"12",cy:"7",r:"4",key:"17ys0d"}]]);/** 1042 * @license lucide-react v0.462.0 - ISC 1043 * 1044 * This source code is licensed under the ISC license. 1045 * See the LICENSE file in the root directory of this source tree. 1046 */const XO=ce("UsersRound",[["path",{d:"M18 21a8 8 0 0 0-16 0",key:"3ypg7q"}],["circle",{cx:"10",cy:"8",r:"5",key:"o932ke"}],["path",{d:"M22 20c0-3.37-2-6.5-4-8a5 5 0 0 0-.45-8.3",key:"10s06x"}]]);/** 1047 * @license lucide-react v0.462.0 - ISC 1048 * 1049 * This source code is licensed under the ISC license. 1050 * See the LICENSE file in the root directory of this source tree. 1051 */const ts=ce("Users",[["path",{d:"M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2",key:"1yyitq"}],["circle",{cx:"9",cy:"7",r:"4",key:"nufk8"}],["path",{d:"M22 21v-2a4 4 0 0 0-3-3.87",key:"kshegd"}],["path",{d:"M16 3.13a4 4 0 0 1 0 7.75",key:"1da9ce"}]]);/** 1052 * @license lucide-react v0.462.0 - ISC 1053 * 1054 * This source code is licensed under the ISC license. 1055 * See the LICENSE file in the root directory of this source tree. 1056 */const eM=ce("Volume2",[["path",{d:"M11 4.702a.705.705 0 0 0-1.203-.498L6.413 7.587A1.4 1.4 0 0 1 5.416 8H3a1 1 0 0 0-1 1v6a1 1 0 0 0 1 1h2.416a1.4 1.4 0 0 1 .997.413l3.383 3.384A.705.705 0 0 0 11 19.298z",key:"uqj9uw"}],["path",{d:"M16 9a5 5 0 0 1 0 6",key:"1q6k2b"}],["path",{d:"M19.364 18.364a9 9 0 0 0 0-12.728",key:"ijwkga"}]]);/** 1057 * @license lucide-react v0.462.0 - ISC 1058 * 1059 * This source code is licensed under the ISC license. 1060 * See the LICENSE file in the root directory of this source tree. 1061 */const tM=ce("VolumeX",[["path",{d:"M11 4.702a.705.705 0 0 0-1.203-.498L6.413 7.587A1.4 1.4 0 0 1 5.416 8H3a1 1 0 0 0-1 1v6a1 1 0 0 0 1 1h2.416a1.4 1.4 0 0 1 .997.413l3.383 3.384A.705.705 0 0 0 11 19.298z",key:"uqj9uw"}],["line",{x1:"22",x2:"16",y1:"9",y2:"15",key:"1ewh16"}],["line",{x1:"16",x2:"22",y1:"9",y2:"15",key:"5ykzw1"}]]);/** 1062 * @license lucide-react v0.462.0 - ISC 1063 * 1064 * This source code is licensed under the ISC license. 1065 * See the LICENSE file in the root directory of this source tree. 1066 */const wo=ce("Wallet",[["path",{d:"M19 7V4a1 1 0 0 0-1-1H5a2 2 0 0 0 0 4h15a1 1 0 0 1 1 1v4h-3a2 2 0 0 0 0 4h3a1 1 0 0 0 1-1v-2a1 1 0 0 0-1-1",key:"18etb6"}],["path",{d:"M3 5v14a2 2 0 0 0 2 2h15a1 1 0 0 0 1-1v-4",key:"xoc0q4"}]]);/** 1067 * @license lucide-react v0.462.0 - ISC 1068 * 1069 * This source code is licensed under the ISC license. 1070 * See the LICENSE file in the root directory of this source tree. 1071 */const ux=ce("WandSparkles",[["path",{d:"m21.64 3.64-1.28-1.28a1.21 1.21 0 0 0-1.72 0L2.36 18.64a1.21 1.21 0 0 0 0 1.72l1.28 1.28a1.2 1.2 0 0 0 1.72 0L21.64 5.36a1.2 1.2 0 0 0 0-1.72",key:"ul74o6"}],["path",{d:"m14 7 3 3",key:"1r5n42"}],["path",{d:"M5 6v4",key:"ilb8ba"}],["path",{d:"M19 14v4",key:"blhpug"}],["path",{d:"M10 2v2",key:"7u0qdc"}],["path",{d:"M7 8H3",key:"zfb6yr"}],["path",{d:"M21 16h-4",key:"1cnmox"}],["path",{d:"M11 3H9",key:"1obp7u"}]]);/** 1072 * @license lucide-react v0.462.0 - ISC 1073 * 1074 * This source code is licensed under the ISC license. 1075 * See the LICENSE file in the root directory of this source tree. 1076 */const sM=ce("Webhook",[["path",{d:"M18 16.98h-5.99c-1.1 0-1.95.94-2.48 1.9A4 4 0 0 1 2 17c.01-.7.2-1.4.57-2",key:"q3hayz"}],["path",{d:"m6 17 3.13-5.78c.53-.97.1-2.18-.5-3.1a4 4 0 1 1 6.89-4.06",key:"1go1hn"}],["path",{d:"m12 6 3.13 5.73C15.66 12.7 16.9 13 18 13a4 4 0 0 1 0 8",key:"qlwsc0"}]]);/** 1077 * @license lucide-react v0.462.0 - ISC 1078 * 1079 * This source code is licensed under the ISC license. 1080 * See the LICENSE file in the root directory of this source tree.
vendor: 5,833 bytes, lines 1081-1091
1081 */const XP=ce("Workflow",[["rect",{width:"8",height:"8",x:"3",y:"3",rx:"2",key:"by2w9f"}],["path",{d:"M7 11v4a2 2 0 0 0 2 2h4",key:"xkn7yn"}],["rect",{width:"8",height:"8",x:"13",y:"13",rx:"2",key:"1cgmvn"}]]);/** 1082 * @license lucide-react v0.462.0 - ISC 1083 * 1084 * This source code is licensed under the ISC license. 1085 * See the LICENSE file in the root directory of this source tree. 1086 */const Ke=ce("X",[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]]);/** 1087 * @license lucide-react v0.462.0 - ISC 1088 * 1089 * This source code is licensed under the ISC license. 1090 * See the LICENSE file in the root directory of this source tree. 1091 */const Pm=ce("Zap",[["path",{d:"M4 14a1 1 0 0 1-.78-1.63l9.9-10.2a.5.5 0 0 1 .86.46l-1.92 6.02A1 1 0 0 0 13 10h7a1 1 0 0 1 .78 1.63l-9.9 10.2a.5.5 0 0 1-.86-.46l1.92-6.02A1 1 0 0 0 11 14z",key:"1xq2db"}]]),s5="-",nM=t=>{const s=rM(t),{conflictingClassGroups:n,conflictingClassGroupModifiers:a}=t;return{getClassGroupId:o=>{const l=o.split(s5);return l[0]===""&&l.length!==1&&l.shift(),eD(l,s)||aM(o)},getConflictingClassGroupIds:(o,l)=>{const c=n[o]||[];return l&&a[o]?[...c,...a[o]]:c}}},eD=(t,s)=>{var o;if(t.length===0)return s.classGroupId;const n=t[0],a=s.nextPart.get(n),r=a?eD(t.slice(1),a):void 0;if(r)return r;if(s.validators.length===0)return;const i=t.join(s5);return(o=s.validators.find(({validator:l})=>l(i)))==null?void 0:o.classGroupId},tC=/^\[(.+)\]$/,aM=t=>{if(tC.test(t)){const s=tC.exec(t)[1],n=s==null?void 0:s.substring(0,s.indexOf(":"));if(n)return"arbitrary.."+n}},rM=t=>{const{theme:s,prefix:n}=t,a={nextPart:new Map,validators:[]};return oM(Object.entries(t.classGroups),n).forEach(([i,o])=>{p2(o,a,i,s)}),a},p2=(t,s,n,a)=>{t.forEach(r=>{if(typeof r=="string"){const i=r===""?s:sC(s,r);i.classGroupId=n;return}if(typeof r=="function"){if(iM(r)){p2(r(a),s,n,a);return}s.validators.push({validator:r,classGroupId:n});return}Object.entries(r).forEach(([i,o])=>{p2(o,sC(s,i),n,a)})})},sC=(t,s)=>{let n=t;return s.split(s5).forEach(a=>{n.nextPart.has(a)||n.nextPart.set(a,{nextPart:new Map,validators:[]}),n=n.nextPart.get(a)}),n},iM=t=>t.isThemeGetter,oM=(t,s)=>s?t.map(([n,a])=>{const r=a.map(i=>typeof i=="string"?s+i:typeof i=="object"?Object.fromEntries(Object.entries(i).map(([o,l])=>[s+o,l])):i);return[n,r]}):t,lM=t=>{if(t<1)return{get:()=>{},set:()=>{}};let s=0,n=new Map,a=new Map;const r=(i,o)=>{n.set(i,o),s++,s>t&&(s=0,a=n,n=new Map)};return{get(i){let o=n.get(i);if(o!==void 0)return o;if((o=a.get(i))!==void 0)return r(i,o),o},set(i,o){n.has(i)?n.set(i,o):r(i,o)}}},tD="!",cM=t=>{const{separator:s,experimentalParseClassName:n}=t,a=s.length===1,r=s[0],i=s.length,o=l=>{const c=[];let u=0,p=0,m;for(let g=0;g<l.length;g++){let N=l[g];if(u===0){if(N===r&&(a||l.slice(g,g+i)===s)){c.push(l.slice(p,g)),p=g+i;continue}if(N==="/"){m=g;continue}}N==="["?u++:N==="]"&&u--}const x=c.length===0?l:l.substring(p),h=x.startsWith(tD),y=h?x.substring(1):x,v=m&&m>p?m-p:void 0;return{modifiers:c,hasImportantModifier:h,baseClassName:y,maybePostfixModifierPosition:v}};return n?l=>n({className:l,parseClassName:o}):o},dM=t=>{if(t.length<=1)return t;const s=[];let n=[];return t.forEach(a=>{a[0]==="["?(s.push(...n.sort(),a),n=[]):n.push(a)}),s.push(...n.sort()),s},uM=t=>({cache:lM(t.cacheSize),parseClassName:cM(t),...nM(t)}),mM=/\s+/,pM=(t,s)=>{const{parseClassName:n,getClassGroupId:a,getConflictingClassGroupIds:r}=s,i=[],o=t.trim().split(mM);let l="";for(let c=o.length-1;c>=0;c-=1){const u=o[c],{modifiers:p,hasImportantModifier:m,baseClassName:x,maybePostfixModifierPosition:h}=n(u);let y=!!h,v=a(y?x.substring(0,h):x);if(!v){if(!y){l=u+(l.length>0?" "+l:l);continue}if(v=a(x),!v){l=u+(l.length>0?" "+l:l);continue}y=!1}const g=dM(p).join(":"),N=m?g+tD:g,b=N+v;if(i.includes(b))continue;i.push(b);const f=r(v,y);for(let j=0;j<f.length;++j){const S=f[j];i.push(N+S)}l=u+(l.length>0?" "+l:l)}return l};function hM(){let t=0,s,n,a="";for(;t<arguments.length;)(s=arguments[t++])&&(n=sD(s))&&(a&&(a+=" "),a+=n);return a}const sD=t=>{if(typeof t=="string")return t;let s,n="";for(let a=0;a<t.length;a++)t[a]&&(s=sD(t[a]))&&(n&&(n+=" "),n+=s);return n};function xM(t,...s){let n,a,r,i=o;function o(c){const u=s.reduce((p,m)=>m(p),t());return n=uM(u),a=n.cache.get,r=n.cache.set,i=l,l(c)}function l(c){const u=a(c);if(u)return u;const p=pM(c,n);return r(c,p),p}return function(){return i(hM.apply(null,arguments))}}const as=t=>{const s=n=>n[t]||[];return s.isThemeGetter=!0,s},nD=/^\[(?:([a-z-]+):)?(.+)\]$/i,fM=/^\d+\/\d+$/,gM=new Set(["px","full","screen"]),yM=/^(\d+(\.\d+)?)?(xs|sm|md|lg|xl)$/,bM=/\d+(%|px|r?em|[sdl]?v([hwib]|min|max)|pt|pc|in|cm|mm|cap|ch|ex|r?lh|cq(w|h|i|b|min|max))|\b(calc|min|max|clamp)\(.+\)|^0$/,vM=/^(rgba?|hsla?|hwb|(ok)?(lab|lch)|color-mix)\(.+\)$/,jM=/^(inset_)?-?((\d+)?\.?(\d+)[a-z]+|0)_-?((\d+)?\.?(\d+)[a-z]+|0)/,wM=/^(url|image|image-set|cross-fade|element|(repeating-)?(linear|radial|conic)-gradient)\(.+\)$/,qi=t=>sm(t)||gM.has(t)||fM.test(t),Yo=t=>Km(t,"length",FM),sm=t=>!!t&&!Number.isNaN(Number(t)),sv=t=>Km(t,"number",sm),bp=t=>!!t&&Number.isInteger(Number(t)),NM=t=>t.endsWith("%")&&sm(t.slice(0,-1)),jt=t=>nD.test(t),Ko=t=>yM.test(t),_M=new Set(["length","size","percentage"]),kM=t=>Km(t,_M,aD),SM=t=>Km(t,"position",aD),CM=new Set(["image","url"]),AM=t=>Km(t,CM,PM),EM=t=>Km(t,"",TM),vp=()=>!0,Km=(t,s,n)=>{const a=nD.exec(t);return a?a[1]?typeof s=="string"?a[1]===s:s.has(a[1]):n(a[2]):!1},FM=t=>bM.test(t)&&!vM.test(t),aD=()=>!1,TM=t=>jM.test(t),PM=t=>wM.test(t),DM=()=>{const t=as("colors"),s=as("spacing"),n=as("blur"),a=as("brightness"),r=as("borderColor"),i=as("borderRadius"),o=as("borderSpacing"),l=as("borderWidth"),c=as("contrast"),u=as("grayscale"),p=as("hueRotate"),m=as("invert"),x=as("gap"),h=as("gradientColorStops"),y=as("gradientColorStopPositions"),v=as("inset"),g=as("margin"),N=as("opacity"),b=
vendor: 7,247 bytes, line 1091
1091as("padding"),f=as("saturate"),j=as("scale"),S=as("sepia"),w=as("skew"),_=as("space"),C=as("translate"),E=()=>["auto","contain","none"],P=()=>["auto","hidden","clip","visible","scroll"],F=()=>["auto",jt,s],I=()=>[jt,s],D=()=>["",qi,Yo],L=()=>["auto",sm,jt],V=()=>["bottom","center","left","left-bottom","left-top","right","right-bottom","right-top","top"],B=()=>["solid","dashed","dotted","double","none"],A=()=>["normal","multiply","screen","overlay","darken","lighten","color-dodge","color-burn","hard-light","soft-light","difference","exclusion","hue","saturation","color","luminosity"],z=()=>["start","end","center","between","around","evenly","stretch"],M=()=>["","0",jt],R=()=>["auto","avoid","all","avoid-page","page","left","right","column"],T=()=>[sm,jt];return{cacheSize:500,separator:":",theme:{colors:[vp],spacing:[qi,Yo],blur:["none","",Ko,jt],brightness:T(),borderColor:[t],borderRadius:["none","","full",Ko,jt],borderSpacing:I(),borderWidth:D(),contrast:T(),grayscale:M(),hueRotate:T(),invert:M(),gap:I(),gradientColorStops:[t],gradientColorStopPositions:[NM,Yo],inset:F(),margin:F(),opacity:T(),padding:I(),saturate:T(),scale:T(),sepia:M(),skew:T(),space:I(),translate:I()},classGroups:{aspect:[{aspect:["auto","square","video",jt]}],container:["container"],columns:[{columns:[Ko]}],"break-after":[{"break-after":R()}],"break-before":[{"break-before":R()}],"break-inside":[{"break-inside":["auto","avoid","avoid-page","avoid-column"]}],"box-decoration":[{"box-decoration":["slice","clone"]}],box:[{box:["border","content"]}],display:["block","inline-block","inline","flex","inline-flex","table","inline-table","table-caption","table-cell","table-column","table-column-group","table-footer-group","table-header-group","table-row-group","table-row","flow-root","grid","inline-grid","contents","list-item","hidden"],float:[{float:["right","left","none","start","end"]}],clear:[{clear:["left","right","both","none","start","end"]}],isolation:["isolate","isolation-auto"],"object-fit":[{object:["contain","cover","fill","none","scale-down"]}],"object-position":[{object:[...V(),jt]}],overflow:[{overflow:P()}],"overflow-x":[{"overflow-x":P()}],"overflow-y":[{"overflow-y":P()}],overscroll:[{overscroll:E()}],"overscroll-x":[{"overscroll-x":E()}],"overscroll-y":[{"overscroll-y":E()}],position:["static","fixed","absolute","relative","sticky"],inset:[{inset:[v]}],"inset-x":[{"inset-x":[v]}],"inset-y":[{"inset-y":[v]}],start:[{start:[v]}],end:[{end:[v]}],top:[{top:[v]}],right:[{right:[v]}],bottom:[{bottom:[v]}],left:[{left:[v]}],visibility:["visible","invisible","collapse"],z:[{z:["auto",bp,jt]}],basis:[{basis:F()}],"flex-direction":[{flex:["row","row-reverse","col","col-reverse"]}],"flex-wrap":[{flex:["wrap","wrap-reverse","nowrap"]}],flex:[{flex:["1","auto","initial","none",jt]}],grow:[{grow:M()}],shrink:[{shrink:M()}],order:[{order:["first","last","none",bp,jt]}],"grid-cols":[{"grid-cols":[vp]}],"col-start-end":[{col:["auto",{span:["full",bp,jt]},jt]}],"col-start":[{"col-start":L()}],"col-end":[{"col-end":L()}],"grid-rows":[{"grid-rows":[vp]}],"row-start-end":[{row:["auto",{span:[bp,jt]},jt]}],"row-start":[{"row-start":L()}],"row-end":[{"row-end":L()}],"grid-flow":[{"grid-flow":["row","col","dense","row-dense","col-dense"]}],"auto-cols":[{"auto-cols":["auto","min","max","fr",jt]}],"auto-rows":[{"auto-rows":["auto","min","max","fr",jt]}],gap:[{gap:[x]}],"gap-x":[{"gap-x":[x]}],"gap-y":[{"gap-y":[x]}],"justify-content":[{justify:["normal",...z()]}],"justify-items":[{"justify-items":["start","end","center","stretch"]}],"justify-self":[{"justify-self":["auto","start","end","center","stretch"]}],"align-content":[{content:["normal",...z(),"baseline"]}],"align-items":[{items:["start","end","center","baseline","stretch"]}],"align-self":[{self:["auto","start","end","center","stretch","baseline"]}],"place-content":[{"place-content":[...z(),"baseline"]}],"place-items":[{"place-items":["start","end","center","baseline","stretch"]}],"place-self":[{"place-self":["auto","start","end","center","stretch"]}],p:[{p:[b]}],px:[{px:[b]}],py:[{py:[b]}],ps:[{ps:[b]}],pe:[{pe:[b]}],pt:[{pt:[b]}],pr:[{pr:[b]}],pb:[{pb:[b]}],pl:[{pl:[b]}],m:[{m:[g]}],mx:[{mx:[g]}],my:[{my:[g]}],ms:[{ms:[g]}],me:[{me:[g]}],mt:[{mt:[g]}],mr:[{mr:[g]}],mb:[{mb:[g]}],ml:[{ml:[g]}],"space-x":[{"space-x":[_]}],"space-x-reverse":["space-x-reverse"],"space-y":[{"space-y":[_]}],"space-y-reverse":["space-y-reverse"],w:[{w:["auto","min","max","fit","svw","lvw","dvw",jt,s]}],"min-w":[{"min-w":[jt,s,"min","max","fit"]}],"max-w":[{"max-w":[jt,s,"none","full","min","max","fit","prose",{screen:[Ko]},Ko]}],h:[{h:[jt,s,"auto","min","max","fit","svh","lvh","dvh"]}],"min-h":[{"min-h":[jt,s,"min","max","fit","svh","lvh","dvh"]}],"max-h":[{"max-h":[jt,s,"min","max","fit","svh","lvh","dvh"]}],size:[{size:[jt,s,"auto","min","max","fit"]}],"font-size":[{text:["base",Ko,Yo]}],"font-smoothing":["antialiased","subpixel-antialiased"],"font-style":["italic","not-italic"],"font-weight":[{font:["thin","extralight","light","normal","medium","semibold","bold","extrabold","black",sv]}],"font-family":[{font:[vp]}],"fvn-normal":["normal-nums"],"fvn-ordinal":["ordinal"],"fvn-slashed-zero":["slashed-zero"],"fvn-figure":["lining-nums","oldstyle-nums"],"fvn-spacing":["proportional-nums","tabular-nums"],"fvn-fraction":["diagonal-fractions","stacked-fractions"],tracking:[{tracking:["tighter","tight","normal","wide","wider","widest",jt]}],"line-clamp":[{"line-clamp":["none",sm,sv]}],leading:[{leading:["none","tight","snug","normal","relaxed","loose",qi,jt]}],"list-image":[{"list-image":["none",jt]}],"list-style-type":[{list:["none","disc","decimal",jt]}],"list-style-position":[{list:["inside","outside"]}],"placeholder-color":[{placeholder:[t]}],"placeholder-opacity":[{"placeholder-opacity":[N]}],"text-alignment":[{text:["left","center","right","justify","start","end"]}],"text-color":[{text:[t]}],"text-opacity":[{"text-opacity":[N]}],"text-decoration":["underline","overline","line-through","no-underline"],"text-decoration-style":[{decoration:[...B(),"wavy"]}],"text-decoration-thickness":[{decoration:["auto","from-font",qi,Yo]}],"underline-offset":[{"underline-offset":["auto",qi,jt]}],"text-decoration-color":[{decoration:[t]}],"text-transform":["uppercase","lowercase","capitalize","normal-case"],"text-overflow":["truncate","text-ellipsis","text-clip"],"text-wrap":[{text:["wrap","nowrap","balance","pretty"]}],indent:[{indent:I()}],"vertical-align":[{align:["baseline","top","middle","bottom","text-top","text-bottom","sub","super",jt]}],whitespace:[{whitespace:["normal","nowrap","pre","pre-line","pre-wrap","break-spaces"]}],break:[{break:["normal","words","all","keep"]}],hyphens:[{hyphens:["none","manual","auto"]}],content:[{content:["none",jt]}],"bg-attachment":[{bg:["fixed","local","scroll"]}],"bg-clip":[{"bg-clip":["border","padding","content","text"]}],"bg-opacity":[{"bg-opacity":[N]}],"bg-origin":[{"bg-origin":["border","padding","content"]}],"bg-position":[{bg:[...V(),SM]}],"bg-repeat":[{bg:["no-repeat",{repeat:["","x","y","round","space"]}]}],"bg-size":[{bg:["auto","cover","contain",kM]}],"bg-image":[{bg:["none",{"gradient-to":["t","tr","r","br","b","bl","l","tl"]},AM]}],"bg-color":[{bg:[t]}],"gradient-from-pos":[{from:[y]}
1091],"gradient-via-pos":[{via:[y]}],"gradient-to-pos":[{to:[y]}],"gradient-from":[{from:[h]}],"gradient-via":[{via:[h]}],"gradient-to":[{to:[h]}],rounded:[{rounded:[i]}],"rounded-s":[{"rounded-s":[i]}],"rounded-e":[{"rounded-e":[i]}],"rounded-t":[{"rounded-t":[i]}],"rounded-r":[{"rounded-r":[i]}],"rounded-b":[{"rounded-b":[i]}],"rounded-l":[{"rounded-l":[i]}],"rounded-ss":[{"rounded-ss":[i]}],"rounded-se":[{"rounded-se":[i]}],"rounded-ee":[{"rounded-ee":[i]}],"rounded-es":[{"rounded-es":[i]}],"rounded-tl":[{"rounded-tl":[i]}],"rounded-tr":[{"rounded-tr":[i]}],"rounded-br":[{"rounded-br":[i]}],"rounded-bl":[{"rounded-bl":[i]}],"border-w":[{border:[l]}],"border-w-x":[{"border-x":[l]}],"border-w-y":[{"border-y":[l]}],"border-w-s":[{"border-s":[l]}],"border-w-e":[{"border-e":[l]}],"border-w-t":[{"border-t":[l]}],"border-w-r":[{"border-r":[l]}],"border-w-b":[{"border-b":[l]}],"border-w-l":[{"border-l":[l]}],"border-opacity":[{"border-opacity":[N]}],"border-style":[{border:[...B(),"hidden"]}],"divide-x":[{"divide-x":[l]}],"divide-x-reverse":["divide-x-reverse"],"divide-y":[{"divide-y":[l]}],"divide-y-reverse":["divide-y-reverse"],"divide-opacity":[{"divide-opacity":[N]}
vendor: 4,467 bytes, line 1091
1091],"divide-style":[{divide:B()}],"border-color":[{border:[r]}],"border-color-x":[{"border-x":[r]}],"border-color-y":[{"border-y":[r]}],"border-color-s":[{"border-s":[r]}],"border-color-e":[{"border-e":[r]}],"border-color-t":[{"border-t":[r]}],"border-color-r":[{"border-r":[r]}],"border-color-b":[{"border-b":[r]}],"border-color-l":[{"border-l":[r]}],"divide-color":[{divide:[r]}],"outline-style":[{outline:["",...B()]}],"outline-offset":[{"outline-offset":[qi,jt]}],"outline-w":[{outline:[qi,Yo]}],"outline-color":[{outline:[t]}],"ring-w":[{ring:D()}],"ring-w-inset":["ring-inset"],"ring-color":[{ring:[t]}],"ring-opacity":[{"ring-opacity":[N]}],"ring-offset-w":[{"ring-offset":[qi,Yo]}],"ring-offset-color":[{"ring-offset":[t]}],shadow:[{shadow:["","inner","none",Ko,EM]}],"shadow-color":[{shadow:[vp]}],opacity:[{opacity:[N]}],"mix-blend":[{"mix-blend":[...A(),"plus-lighter","plus-darker"]}],"bg-blend":[{"bg-blend":A()}],filter:[{filter:["","none"]}],blur:[{blur:[n]}],brightness:[{brightness:[a]}],contrast:[{contrast:[c]}],"drop-shadow":[{"drop-shadow":["","none",Ko,jt]}],grayscale:[{grayscale:[u]}],"hue-rotate":[{"hue-rotate":[p]}],invert:[{invert:[m]}],saturate:[{saturate:[f]}],sepia:[{sepia:[S]}],"backdrop-filter":[{"backdrop-filter":["","none"]}],"backdrop-blur":[{"backdrop-blur":[n]}],"backdrop-brightness":[{"backdrop-brightness":[a]}],"backdrop-contrast":[{"backdrop-contrast":[c]}],"backdrop-grayscale":[{"backdrop-grayscale":[u]}],"backdrop-hue-rotate":[{"backdrop-hue-rotate":[p]}],"backdrop-invert":[{"backdrop-invert":[m]}],"backdrop-opacity":[{"backdrop-opacity":[N]}],"backdrop-saturate":[{"backdrop-saturate":[f]}],"backdrop-sepia":[{"backdrop-sepia":[S]}],"border-collapse":[{border:["collapse","separate"]}],"border-spacing":[{"border-spacing":[o]}],"border-spacing-x":[{"border-spacing-x":[o]}],"border-spacing-y":[{"border-spacing-y":[o]}],"table-layout":[{table:["auto","fixed"]}],caption:[{caption:["top","bottom"]}],transition:[{transition:["none","all","","colors","opacity","shadow","transform",jt]}],duration:[{duration:T()}],ease:[{ease:["linear","in","out","in-out",jt]}],delay:[{delay:T()}],animate:[{animate:["none","spin","ping","pulse","bounce",jt]}],transform:[{transform:["","gpu","none"]}],scale:[{scale:[j]}],"scale-x":[{"scale-x":[j]}],"scale-y":[{"scale-y":[j]}],rotate:[{rotate:[bp,jt]}],"translate-x":[{"translate-x":[C]}],"translate-y":[{"translate-y":[C]}],"skew-x":[{"skew-x":[w]}],"skew-y":[{"skew-y":[w]}],"transform-origin":[{origin:["center","top","top-right","right","bottom-right","bottom","bottom-left","left","top-left",jt]}],accent:[{accent:["auto",t]}],appearance:[{appearance:["none","auto"]}],cursor:[{cursor:["auto","default","pointer","wait","text","move","help","not-allowed","none","context-menu","progress","cell","crosshair","vertical-text","alias","copy","no-drop","grab","grabbing","all-scroll","col-resize","row-resize","n-resize","e-resize","s-resize","w-resize","ne-resize","nw-resize","se-resize","sw-resize","ew-resize","ns-resize","nesw-resize","nwse-resize","zoom-in","zoom-out",jt]}],"caret-color":[{caret:[t]}],"pointer-events":[{"pointer-events":["none","auto"]}],resize:[{resize:["none","y","x",""]}],"scroll-behavior":[{scroll:["auto","smooth"]}],"scroll-m":[{"scroll-m":I()}],"scroll-mx":[{"scroll-mx":I()}],"scroll-my":[{"scroll-my":I()}],"scroll-ms":[{"scroll-ms":I()}],"scroll-me":[{"scroll-me":I()}],"scroll-mt":[{"scroll-mt":I()}],"scroll-mr":[{"scroll-mr":I()}],"scroll-mb":[{"scroll-mb":I()}],"scroll-ml":[{"scroll-ml":I()}],"scroll-p":[{"scroll-p":I()}],"scroll-px":[{"scroll-px":I()}],"scroll-py":[{"scroll-py":I()}],"scroll-ps":[{"scroll-ps":I()}],"scroll-pe":[{"scroll-pe":I()}],"scroll-pt":[{"scroll-pt":I()}],"scroll-pr":[{"scroll-pr":I()}],"scroll-pb":[{"scroll-pb":I()}],"scroll-pl":[{"scroll-pl":I()}],"snap-align":[{snap:["start","end","center","align-none"]}],"snap-stop":[{snap:["normal","always"]}],"snap-type":[{snap:["none","x","y","both"]}],"snap-strictness":[{snap:["mandatory","proximity"]}],touch:[{touch:["auto","none","manipulation"]}],"touch-x":[{"touch-pan":["x","left","right"]}],"touch-y":[{"touch-pan":["y","up","down"]}],"touch-pz":["touch-pinch-zoom"],select:[{select:["none","text","all","auto"]}],"will-change":[{"will-change":["auto","scroll","contents","transform",jt]}],fill:[{fill:[t,"none"]}],"stroke-w":[{stroke:[qi,Yo,sv]}],stroke:[{stroke:[t,"none"]}],sr:["sr-only","not-sr-only"],"forced-color-adjust":[{"forced-color-adjust":["auto","
1091none"]}]},conflictingClassGroups:{overflow:["overflow-x","overflow-y"],overscroll:["overscroll-x","overscroll-y"],inset:["inset-x","inset-y","start","end","top","right","bottom","left"],"inset-x":["right","left"],"inset-y":["top","bottom"],flex:["basis","grow","shrink"],gap:["gap-x","gap-y"],p:["px","py","ps","pe","pt","pr","pb","pl"],px:["pr","pl"],py:["pt","pb"],m:["mx","my","ms","me","mt","mr","mb","ml"],mx:["mr","ml"],my:["mt","mb"],size:["w","h"],"font-size":["leading"],"fvn-normal":["fvn-ordinal","fvn-slashed-zero","fvn-figure","fvn-spacing","fvn-fraction"],"fvn-ordinal":["fvn-normal"],"fvn-slashed-zero":["fvn-normal"],"fvn-figure":["fvn-normal"],"fvn-spacing":["fvn-normal"],"fvn-fraction":["fvn-normal"],"line-clamp":["display","overflow"],rounded:["rounded-s","rounded-e","rounded-t","rounded-r","rounded-b","rounded-l","rounded-ss","rounded-se","rounded-ee","rounded-es","rounded-tl","rounded-tr","rounded-br","rounded-bl"],"rounded-s":["rounded-ss","rounded-es"],"rounded-e":["rounded-se","rounded-ee"],"rounded-t":["rounded-tl","rounded-tr"],"rounded-r":["rounded-tr","rounded-br"],"rounded-b":["rounded-br","rounded-bl"],"rounded-l":["rounded-tl","rounded-bl"],"border-spacing":["border-spacing-x","border-spacing-y"],"border-w":["border-w-s","border-w-e","border-w-t","border-w-r","border-w-b","border-w-l"],"border-w-x":["border-w-r","border-w-l"],"border-w-y":["border-w-t","border-w-b"],"border-color":["border-color-s","border-color-e","border-color-t","border-color-r","border-color-b","border-color-l"],"border-color-x":["border-color-r","border-color-l"],"border-color-y":["border-color-t","border-color-b"],"scroll-m":["scroll-mx","scroll-my","scroll-ms","scroll-me","scroll-mt","scroll-mr","scroll-mb","scroll-ml"],"scroll-mx":["scroll-mr","scroll-ml"],"scroll-my":["scroll-mt","scroll-mb"],"scroll-p":["scroll-px","scroll-py","scroll-ps","scroll-pe","scroll-pt","scroll-pr","scroll-pb","scroll-pl"],"scroll-px":["scroll-pr","scroll-pl"],"scroll-py":["scroll-pt","scroll-pb"],touch:["touch-x","touch-y","touch-pz"],"touch-x":["touch"],"touch-y":["touch"],"touch-pz":["touch"]},conflictingClassGroupModifiers:{"font-size":["leading"]}}},RM=xM(DM);function et(...t){return RM(PP(t))}const IM=cO,rD=d.forwardRef(({className:t,...s},n)=>e.jsx(kP,{ref:n,className:et("fixed top-0 z-[100] flex max-h-screen w-full flex-col-reverse p-4 sm:bottom-0 sm:right-0 sm:top-auto sm:flex-col md:max-w-[420px]",t),...s}));rD.displayName=kP.displayName;const $M=Ib("group pointer-events-auto relative flex w-full items-center justify-between space-x-4 overflow-hidden rounded-md border p-6 pr-8 shadow-lg transition-all data-[swipe=cancel]:translate-x-0 data-[swipe=end]:translate-x-[var(--radix-toast-swipe-end-x)] data-[swipe=move]:translate-x-[var(--radix-toast-swipe-move-x)] data-[swipe=move]:transition-none data-[state=open]:animate-in data-[state=closed]:animate-out data-[swipe=end]:animate-out data-[state=closed]:fade-out-80 data-[state=closed]:slide-out-to-right-full data-[state=open]:slide-in-from-top-full data-[state=open]:sm:slide-in-from-bottom-full",{variants:{variant:{default:"border bg-background text-foreground",destructive:"destructive group border-destructive bg-destructive text-destructive-foreground"}},defaultVariants:{variant:"default"}}),iD=d.forwardRef(({className:t,variant:s,...n},a)=>e.jsx(SP,{ref:a,className:et($M({variant:s}),t),...n}));iD.displayName=SP.displayName;const zM=d.forwardRef(({className:t,...s},n)=>e.jsx(EP,{ref:n,className:et("inline-flex h-8 shrink-0 items-center justify-center rounded-md border bg-transparent px-3 text-sm font-medium ring-offset-background transition-colors hover:bg-secondary focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 group-[.destructive]:border-muted/40 group-[.destructive]:hover:border-destructive/30 group-[.destructive]:hover:bg-destructive group-[.destructive]:hover:text-destructive-foreground group-[.destructive]:focus:ring-destructive",t),...s}));zM.displayName=EP.displayName;const oD=d.forwardRef(({className:t,...s},n)=>e.jsx(FP,{ref:n,className:et("absolute right-2 top-2 rounded-md p-1 text-foreground
1091/50 opacity-0 transition-opacity hover:text-foreground focus:opacity-100 focus:outline-none focus:ring-2 group-hover:opacity-100 group-[.destructive]:text-red-300 group-[.destructive]:hover:text-red-50 group-[.destructive]:focus:ring-red-400 group-[.destructive]:focus:ring-offset-red-600",t),"toast-close":"",...s,children:e.jsx(Ke,{className:"h-4 w-4"})}));oD.displayName=FP.displayName;const lD=d.forwardRef(({className:t,...s},n)=>e.jsx(CP,{ref:n,className:et("text-sm font-semibold",t),...s}));lD.displayName=CP.displayName;const cD=d.forwardRef(({className:t,...s},n)=>e.jsx(AP,{ref:n,className:et("text-sm opacity-90",t),...s}));cD.displayName=AP.displayName;function LM(){const{toasts:t}=a9();return e.jsxs(IM,{children:[t.map(function({id:s,title:n,description:a,action:r,...i}){return e.jsxs(iD,{...i,children:[e.jsxs("div",{className:"grid gap-1",children:[n&&e.jsx(lD,{children:n}),a&&e.jsx(cD,{children:a})]}),r,e.jsx(oD,{})]},s)}),e.jsx(rD,{})]})}var OM=t=>{switch(t){case"success":return UM;case"info":return WM;case"warning":return qM;case"error":return HM;default:return null}},MM=Array(12).fill(0),BM=({visible:t,className:s})=>re.createElement("div",{className:["sonner-loading-wrapper",s].filter(Boolean).join(" "),"data-visible":t},re.createElement("div",{className:"sonner-spinner"},MM.map((n,a)=>re.createElement("div",{className:"sonner-loading-bar",key:`spinner-bar-${a}`})))),UM=re.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor",height:"20",width:"20"},re.createElement("path",{fillRule:"evenodd",d:"M10 18a8 8 0 100-16 8 8 0 000 16zm3.857-9.809a.75.75 0 00-1.214-.882l-3.483 4.79-1.88-1.88a.75.75 0 10-1.06 1.061l2.5 2.5a.75.75 0 001.137-.089l4-5.5z",clipRule:"evenodd"})),qM=re.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor",height:"20",width:"20"},re.createElement("path",{fillRule:"evenodd",d:"M9.401 3.003c1.155-2 4.043-2 5.197 0l7.355 12.748c1.154 2-.29 4.5-2.599 4.5H4.645c-2.309 0-3.752-2.5-2.598-4.5L9.4 3.003zM12 8.25a.75.75 0 01.75.75v3.75a.75.75 0 01-1.5 0V9a.75.75 0 01.75-.75zm0 8.25a.75.75 0 100-1.5.75.75 0 000 1.5z",clipRule:"evenodd"})),WM=re.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor",height:"20",width:"20"},re.createElement("path",{fillRule:"evenodd",d:"M18 10a8 8 0 11-16 0 8 8 0 0116 0zm-7-4a1 1 0 11-2 0 1 1 0 012 0zM9 9a.75.75 0 000 1.5h.253a.25.25 0 01.244.304l-.459 2.066A1.75 1.75 0 0010.747 15H11a.75.75 0 000-1.5h-.253a.25.25 0 01-.244-.304l.459-2.066A1.75 1.75 0 009.253 9H9z",clipRule:"evenodd"})),HM=re.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor",height:"20",width:"20"},re.createElement("path",{fillRule:"evenodd",d:"M18 10a8 8 0 11-16 0 8 8 0 0116 0zm-8-5a.75.75 0 01.75.75v4.5a.75.75 0 01-1.5 0v-4.5A.75.75 0 0110 5zm0 10a1 1 0 100-2 1 1 0 000 2z",clipRule:"evenodd"})),GM=re.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"},re.createElement("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),re.createElement("line",{x1:"6",y1:"6",x2:"18",y2:"18"})),VM=()=>{let[t,s]=re.useState(document.hidden);return re.useEffect(()=>{let n=()=>{s(document.hidden)};return document.addEventListener("visibilitychange",n),()=>window.removeEventListener("visibilitychange",n)},[]),t},h2=1,ZM=class{constructor(){this.subscribe=t=>(this.subscribers.push(t),()=>{let s=this.subscribers.indexOf(t);this.subscribers.splice(s,1)}),this.publish=t=>{this.subscribers.forEach(s=>s(t))},this.addToast=t=>{this.publish(t),this.toasts=[...this.toasts,t]},this.create=t=>{var s;let{message:n,...a}=t,r=typeof(t==null?void 0:t.id)=="number"||((s=t.id)==null?void 0:s.length)>0?t.id:h2++,i=this.toasts.find(l=>l.id===r),o=t.dismissible===void 0?!0:t.dismissible;return this.dismissedToasts.has(r)&&this.dismissedToasts.delete(r),i?this.toasts=this.toasts.map(l=>l.id===r?(this.publish({...l,...t,id:r,title:n}),{...l,...t,id:r,dismissible:o,title:n}):l):this.addToast({title:n,...a,dismissible:o,id:r}),r},this.dismiss=t=>
1091(this.dismissedToasts.add(t),t||this.toasts.forEach(s=>{this.subscribers.forEach(n=>n({id:s.id,dismiss:!0}))}),this.subscribers.forEach(s=>s({id:t,dismiss:!0})),t),this.message=(t,s)=>this.create({...s,message:t}),this.error=(t,s)=>this.create({...s,message:t,type:"error"}),this.success=(t,s)=>this.create({...s,type:"success",message:t}),this.info=(t,s)=>this.create({...s,type:"info",message:t}),this.warning=(t,s)=>this.create({...s,type:"warning",message:t}),this.loading=(t,s)=>this.create({...s,type:"loading",message:t}),this.promise=(t,s)=>{if(!s)return;let n;s.loading!==void 0&&(n=this.create({...s,promise:t,type:"loading",message:s.loading,description:typeof s.description!="function"?s.description:void 0}));let a=t instanceof Promise?t:t(),r=n!==void 0,i,o=a.then(async c=>{if(i=["resolve",c],re.isValidElement(c))r=!1,this.create({id:n,type:"default",message:c});else if(KM(c)&&!c.ok){r=!1;let u=typeof s.error=="function"?await s.error(`HTTP error! status: ${c.status}`):s.error,p=typeof s.description=="function"?await s.description(`HTTP error! status: ${c.status}`):s.description;this.create({id:n,type:"error",message:u,description:p})}else if(s.success!==void 0){r=!1;let u=typeof s.success=="function"?await s.success(c):s.success,p=typeof s.description=="function"?await s.description(c):s.description;this.create({id:n,type:"success",message:u,description:p})}}).catch(async c=>{if(i=["reject",c],s.error!==void 0){r=!1;let u=typeof s.error=="function"?await s.error(c):s.error,p=typeof s.description=="function"?await s.description(c):s.description;this.create({id:n,type:"error",message:u,description:p})}}).finally(()=>{var c;r&&(this.dismiss(n),n=void 0),(c=s.finally)==null||c.call(s)}),l=()=>new Promise((c,u)=>o.then(()=>i[0]==="reject"?u(i[1]):c(i[1])).catch(u));return typeof n!="string"&&typeof n!="number"?{unwrap:l}:Object.assign(n,{unwrap:l})},this.custom=(t,s)=>{let n=(s==null?void 0:s.id)||h2++;return this.create({jsx:t(n),id:n,...s}),n},this.getActiveToasts=()=>this.toasts.filter(t=>!this.dismissedToasts.has(t.id)),this.subscribers=[],this.toasts=[],this.dismissedToasts=new Set}},da=new ZM,YM=(t,s)=>{let n=(s==null?void 0:s.id)||h2++;return da.addToast({title:t,...s,id:n}),n},KM=t=>t&&typeof t=="object"&&"ok"in t&&typeof t.ok=="boolean"&&"status"in t&&typeof t.status=="number",QM=YM,JM=()=>da.toasts,XM=()=>da.getActiveToasts(),Ct=Object.assign(QM,{success:da.success,info:da.info,warning:da.warning,error:da.error,custom:da.custom,message:da.message,promise:da.promise,dismiss:da.dismiss,loading:da.loading},{getHistory:JM,getToasts:XM});function eB(t,{insertAt:s}={}){if(typeof document>"u")return;let n=document.head||document.getElementsByTagName("head")[0],a=document.createElement("style");a.type="text/css",s==="top"&&n.firstChild?n.insertBefore(a,n.firstChild):n.appendChild(a),a.styleSheet?a.styleSheet.cssText=t:a.appendChild(document.createTextNode(t))}eB(`:where(html[dir="ltr"]),:where([data-sonner-toaster][dir="ltr"]){--toast-icon-margin-start: -3px;--toast-icon-margin-end: 4px;--toast-svg-margin-start: -1px;--toast-svg-margin-end: 0px;--toast-button-margin-start: auto;--toast-button-margin-end: 0;--toast-close-button-start: 0;--toast-close-button-end: unset;--toast-close-button-transform: translate(-35%, -35%)}:where(html[dir="rtl"]),:where([data-sonner-toaster][dir="rtl"]){--toast-icon-margin-start: 4px;--toast-icon-margin-end: -3px;--toast-svg-margin-start: 0px;--toast-svg-margin-end: -1px;--toast-button-margin-start: 0;--toast-button-margin-end: auto;--toast-close-button-start: unset;--toast-close-button-end: 0;--toast-close-button-transform: translate(35%, -35%)}:where([data-sonner-toaster]){position:fixed;width:var(--width);font-family:ui-sans-serif,system-ui,-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Helvetica Neue,Arial,Noto Sans,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol,Noto Color Emoji;--gray1: hsl(0, 0%, 99%);--gray2: hsl(0, 0%, 97.3%);--gray3: hsl(0, 0%, 95.1%);--gray4: hsl(0, 0%, 93%);--gray5: hsl(0, 0%, 90.9%);--gray6: hsl(0, 0%, 88.7%);--gray7: hsl(0, 0%, 85.8%);--gray8: hsl(0, 0%, 78%);--gray9: hsl(0, 0%, 56.1%);--gray10: hsl(0, 0%, 52.3%);--gray11: hsl(0, 0%, 43.5%);--gray12: hsl(0, 0%, 9%);--border-radius: 8px;box-sizing:border-box;padding:0;margin:0;list-style:none;outline:none;z-index:999999999;transition:transform .4s ease}:where([data-sonner-toaster][data-lifted="true"]){transform:translateY(-10px)}@media (hover: none) and (pointer: coarse){:where([data-sonner-toaster][data-lifted="true"]){transform:none}}:where([data-sonner-toaster][data-x-position="right"]){right:var(--offset-right)}:where([data-sonner-toaster][data-x-position="left"]){left:var(--offset-left)}:where([data-sonner-toaster][data-x-position="center"]){left:50%;transform:translate(-50%)}:where([data-sonner-toaster][data-y-position="top"]){top:var(--offset-top)}:where([data-sonner-toaster][data-y-position="bottom"]){bottom:var(--offset-bottom)}:where([data-sonner-toast]){--y: translateY(100%);--lift-amount: calc(var(--lift) * var(--gap));z-index:var(--z-index);position:absolute;opacity:0;transform:var(--y);filter:blur(0);touch-action:none;transition:transform .4s,opacity .4s,height .4s,box-shadow .2s;box-sizing:border-box;outline:none;overflow-wrap:anywhere}:where([data-sonner-toast][data-styled="true"]){padding:16px;background:var(--normal-bg);border:1px solid var(--normal-border);color:var(--normal-text);border-radius:var(--border-radius);box-shadow:0 4px 12px #0000001a;width:var(--width);font-size:13px;display:flex;align-items:center;gap:6px}:where([data-sonner-toast]:focus-visible){box-shadow:0 4px 12px #0000001a,0 0 0 2px #0003}:where([data-sonner-toast][data-y-position="top"]){top:0;--y: translateY(-100%);--lift: 1;--lift-amount: calc(1 * var(--gap))}:where([data-sonner-toast][data-y-position="bottom"]){bottom:0;--y: translateY(100%);--lift: -1;--lift-amount: calc(var(--lift) * var(--gap))}:where([data-sonner-toast]) :where([data-description]){font-weight:400;line-height:1.4;color:inherit}:where([data-sonner-toast]) :where([data-title]){font-weight:500;line-height:1.5;color:inherit}:where([data-sonner-toast]) :where([data-icon]){display:flex;height:16px;width:16px;position:relative;justify-content:flex-start;align-items:center;flex-shrink:0;margin-left:var(--toast-icon-margin-start);margin-right:var(--toast-icon-margin-end)}:where([data-sonner-toast][data-promise="true"]) :where([data-icon])>svg{opacity:0;transform:scale(.8);transform-origin:center;animation:sonner-fade-in .3s ease forwards}:where([data-sonner-toast]) :where([data-icon])>*{flex-shrink:0}:where([data-sonner-toast]) :where([data-icon]) svg{margin-left:var(--toast-svg-margin-start);margin-right:var(--toast-svg-margin-end)}:where([data-sonner-toast]) :where([data-content]){display:flex;flex-direction:column;gap:2px}[data-sonner-toast][data-styled=true] [data-button]{border-radius:4px;padding-left:8px;padding-right:8px;height:24px;font-size:12px;color:var(--normal-bg);background:var(--normal-text);margin-left:var(--toast-button-margin-start);margin-right:var(--toast-button-margin-end);border:none;cursor:pointer;outline:none;display:flex;align-items:center;flex-shrink:0;transition:opacity .4s,box-shadow .2s}:where([data-sonner-toast]) :where([data-button]):focus-visible{box-shadow:0 0 0 2px #0006}:where([data-sonner-toast]) :where([data-button]):first-of-type{margin-left:var(--toast-button-margin-start);margin-right:var(--toast-button-margin-end)}:where([data-sonner-toast]) :where([data-cancel]){color:var(--normal-text);background:rgba(0,0,0,.08)}:where([data-sonner-toast][data-theme="dark"]) :where([data-cancel]){background:rgba(255,255,255,.3)}:where([data-sonner-toast]) :where([data-close-button]){position:absolute;
1091left:var(--toast-close-button-start);right:var(--toast-close-button-end);top:0;height:20px;width:20px;display:flex;justify-content:center;align-items:center;padding:0;color:var(--gray12);border:1px solid var(--gray4);transform:var(--toast-close-button-transform);border-radius:50%;cursor:pointer;z-index:1;transition:opacity .1s,background .2s,border-color .2s}[data-sonner-toast] [data-close-button]{background:var(--gray1)}:where([data-sonner-toast]) :where([data-close-button]):focus-visible{box-shadow:0 4px 12px #0000001a,0 0 0 2px #0003}:where([data-sonner-toast]) :where([data-disabled="true"]){cursor:not-allowed}:where([data-sonner-toast]):hover :where([data-close-button]):hover{background:var(--gray2);border-color:var(--gray5)}:where([data-sonner-toast][data-swiping="true"]):before{content:"";position:absolute;left:-50%;right:-50%;height:100%;z-index:-1}:where([data-sonner-toast][data-y-position="top"][data-swiping="true"]):before{bottom:50%;transform:scaleY(3) translateY(50%)}:where([data-sonner-toast][data-y-position="bottom"][data-swiping="true"]):before{top:50%;transform:scaleY(3) translateY(-50%)}:where([data-sonner-toast][data-swiping="false"][data-removed="true"]):before{content:"";position:absolute;inset:0;transform:scaleY(2)}:where([data-sonner-toast]):after{content:"";position:absolute;left:0;height:calc(var(--gap) + 1px);bottom:100%;width:100%}:where([data-sonner-toast][data-mounted="true"]){--y: translateY(0);opacity:1}:where([data-sonner-toast][data-expanded="false"][data-front="false"]){--scale: var(--toasts-before) * .05 + 1;--y: translateY(calc(var(--lift-amount) * var(--toasts-before))) scale(calc(-1 * var(--scale)));height:var(--front-toast-height)}:where([data-sonner-toast])>*{transition:opacity .4s}:where([data-sonner-toast][data-expanded="false"][data-front="false"][data-styled="true"])>*{opacity:0}
1091:where([data-sonner-toast][data-visible="false"]){opacity:0;pointer-events:none}:where([data-sonner-toast][data-mounted="true"][data-expanded="true"]){--y: translateY(calc(var(--lift) * var(--offset)));height:var(--initial-height)}:where([data-sonner-toast][data-removed="true"][data-front="true"][data-swipe-out="false"]){--y: translateY(calc(var(--lift) * -100%));opacity:0}:where([data-sonner-toast][data-removed="true"][data-front="false"][data-swipe-out="false"][data-expanded="true"]){--y: translateY(calc(var(--lift) * var(--offset) + var(--lift) * -100%));opacity:0}:where([data-sonner-toast][data-removed="true"][data-front="false"][data-swipe-out="false"][data-expanded="false"]){--y: translateY(40%);opacity:0;transition:transform .5s,opacity .2s}:where([data-sonner-toast][data-removed="true"][data-front="false"]):before{height:calc(var(--initial-height) + 20%)}[data-sonner-toast][data-swiping=true]{transform:var(--y) translateY(var(--swipe-amount-y, 0px)) translate(var(--swipe-amount-x, 0px));transition:none}[data-sonner-toast][data-swiped=true]{user-select:none}[data-sonner-toast][data-swipe-out=true][data-y-position=bottom],[data-sonner-toast][data-swipe-out=true][data-y-position=top]{animation-duration:.2s;animation-timing-function:ease-out;animation-fill-mode:forwards}[data-sonner-toast][data-swipe-out=true][data-swipe-direction=left]{animation-name:swipe-out-left}[data-sonner-toast][data-swipe-out=true][data-swipe-direction=right]{animation-name:swipe-out-right}[data-sonner-toast][data-swipe-out=true][data-swipe-direction=up]{animation-name:swipe-out-up}[data-sonner-toast][data-swipe-out=true][data-swipe-direction=down]{animation-name:swipe-out-down}@keyframes swipe-out-left{0%{transform:var(--y) translate(var(--swipe-amount-x));opacity:1}to{transform:var(--y) translate(calc(var(--swipe-amount-x) - 100%));opacity:0}}@keyframes swipe-out-right{0%{transform:var(--y) translate(var(--swipe-amount-x));opacity:1}to{transform:var(--y) translate(calc(var(--swipe-amount-x) + 100%));opacity:0}}@keyframes swipe-out-up{0%{transform:var(--y) translateY(var(--swipe-amount-y));opacity:1}to{transform:var(--y) translateY(calc(var(--swipe-amount-y) - 100%));opacity:0}}@keyframes swipe-out-down{0%{transform:var(--y) translateY(var(--swipe-amount-y));opacity:1}to{transform:var(--y) translateY(calc(var(--swipe-amount-y) + 100%));opacity:0}}@media (max-width: 600px){[data-sonner-toaster]{position:fixed;right:var(--mobile-offset-right);left:var(--mobile-offset-left);width:100%}[data-sonner-toaster][dir=rtl]{left:calc(var(--mobile-offset-left) * -1)}[data-sonner-toaster] [data-sonner-toast]{left:0;right:0;width:calc(100% - var(--mobile-offset-left) * 2)}[data-sonner-toaster][data-x-position=left]{left:var(--mobile-offset-left)}[data-sonner-toaster][data-y-position=bottom]{bottom:var(--mobile-offset-bottom)}[data-sonner-toaster][data-y-position=top]{top:var(--mobile-offset-top)}[data-sonner-toaster][data-x-position=center]{left:var(--mobile-offset-left);right:var(--mobile-offset-right);transform:none}}[data-sonner-toaster][data-theme=light]{--normal-bg: #fff;--normal-border: var(--gray4);--normal-text: var(--gray12);--success-bg: hsl(143, 85%, 96%);--success-border: hsl(145, 92%, 91%);--success-text: hsl(140, 100%, 27%);--info-bg: hsl(208, 100%, 97%);--info-border: hsl(221, 91%, 91%);--info-text: hsl(210, 92%, 45%);--warning-bg: hsl(49, 100%, 97%);--warning-border: hsl(49, 91%, 91%);--warning-text: hsl(31, 92%, 45%);--error-bg: hsl(359, 100%, 97%);--error-border: hsl(359, 100%, 94%);--error-text: hsl(360, 100%, 45%)}[data-sonner-toaster][data-theme=light] [data-sonner-toast][data-invert=true]{--normal-bg: #000;--normal-border: hsl(0, 0%, 20%);--normal-text: var(--gray1)}[data-sonner-toaster][data-theme=dark] [data-sonner-toast][data-invert=true]{--normal-bg: #fff;--normal-border: var(--gray3);--normal-text: var(--gray12)}[data-sonner-toaster][data-theme=dark]{--normal-bg: #000;--normal-bg-hover: hsl(0, 0%, 12%);--normal-border: hsl(0, 0%, 20%);--normal-border-hover: hsl(0, 0%, 25%);--normal-text: var(--gray1);--success-bg: hsl(150, 100%, 6%);--success-border: hsl(147, 100%, 12%);--success-text: hsl(150, 86%, 65%);--info-bg: hsl(215, 100%, 6%);--info-border: hsl(223, 100%, 12%);--info-text: hsl(216, 87%, 65%);--warning-bg: hsl(64, 100%, 6%);--warning-border: hsl(60, 100%, 12%);--warning-text: hsl(46, 87%, 65%);--error-bg: hsl(358, 76%, 10%);--error-border: hsl(357, 89%, 16%);
1091--error-text: hsl(358, 100%, 81%)}[data-sonner-toaster][data-theme=dark] [data-sonner-toast] [data-close-button]{background:var(--normal-bg);border-color:var(--normal-border);color:var(--normal-text)}[data-sonner-toaster][data-theme=dark] [data-sonner-toast] [data-close-button]:hover{background:var(--normal-bg-hover);border-color:var(--normal-border-hover)}[data-rich-colors=true][data-sonner-toast][data-type=success],[data-rich-colors=true][data-sonner-toast][data-type=success] [data-close-button]{background:var(--success-bg);border-color:var(--success-border);color:var(--success-text)}[data-rich-colors=true][data-sonner-toast][data-type=info],[data-rich-colors=true][data-sonner-toast][data-type=info] [data-close-button]{background:var(--info-bg);border-color:var(--info-border);color:var(--info-text)}[data-rich-colors=true][data-sonner-toast][data-type=warning],[data-rich-colors=true][data-sonner-toast][data-type=warning] [data-close-button]{background:var(--warning-bg);border-color:var(--warning-border);color:var(--warning-text)}[data-rich-colors=true][data-sonner-toast][data-type=error],[data-rich-colors=true][data-sonner-toast][data-type=error] [data-close-button]{background:var(--error-bg);border-color:var(--error-border);color:var(--error-text)}.sonner-loading-wrapper{--size: 16px;height:var(--size);width:var(--size);position:absolute;inset:0;z-index:10}.sonner-loading-wrapper[data-visible=false]{transform-origin:center;animation:sonner-fade-out .2s ease forwards}.sonner-spinner{position:relative;top:50%;left:50%;height:var(--size);width:var(--size)}.sonner-loading-bar{animation:sonner-spin 1.2s linear infinite;background:var(--gray11);border-radius:6px;height:8%;left:-10%;position:absolute;top:-3.9%;width:24%}.sonner-loading-bar:nth-child(1){animation-delay:-1.2s;transform:rotate(.0001deg) translate(146%)}.sonner-loading-bar:nth-child(2){animation-delay:-1.1s;transform:rotate(30deg) translate(146%)}.sonner-loading-bar:nth-child(3){animation-delay:-1s;transform:rotate(60deg) translate(146%)}.sonner-loading-bar:nth-child(4){animation-delay:-.9s;transform:rotate(90deg) translate(146%)}.sonner-loading-bar:nth-child(5){animation-delay:-.8s;transform:rotate(120deg) translate(146%)}.sonner-loading-bar:nth-child(6){animation-delay:-.7s;transform:rotate(150deg) translate(146%)}.sonner-loading-bar:nth-child(7){animation-delay:-.6s;transform:rotate(180deg) translate(146%)}.sonner-loading-bar:nth-child(8){animation-delay:-.5s;transform:rotate(210deg) translate(146%)}.sonner-loading-bar:nth-child(9){animation-delay:-.4s;transform:rotate(240deg) translate(146%)}.sonner-loading-bar:nth-child(10){animation-delay:-.3s;transform:rotate(270deg) translate(146%)}.sonner-loading-bar:nth-child(11){animation-delay:-.2s;transform:rotate(300deg) translate(146%)}.sonner-loading-bar:nth-child(12){animation-delay:-.1s;transform:rotate(330deg) translate(146%)}@keyframes sonner-fade-in{0%{opacity:0;transform:scale(.8)}to{opacity:1;transform:scale(1)}}@keyframes sonner-fade-out{0%{opacity:1;transform:scale(1)}to{opacity:0;transform:scale(.8)}}@keyframes sonner-spin{0%{opacity:1}to{opacity:.15}}@media (prefers-reduced-motion){[data-sonner-toast],[data-sonner-toast]>*,.sonner-loading-bar{transition:none!important;animation:none!important}}.sonner-loader{position:absolute;top:50%;left:50%;transform:translate(-50%,-50%);transform-origin:center;transition:opacity .2s,transform .2s}.sonner-loader[data-visible=false]{opacity:0;transform:scale(.8) translate(-50%,-50%)} 1092`);function Ff(t){return t.label!==void 0}var tB=3,sB="32px",nB="16px",nC=4e3,aB=356,rB=14,iB=20,oB=200;function kr(...t){return t.filter(Boolean).join(" ")}function lB(t){let[s,n]=t.split("-"),a=[];return s&&a.push(s),n&&a.push(n),a}var cB=t=>{var s,n,a,r,i,o,l,c,u,p,m;let{invert:x,toast:h,unstyled:y,interacting:v,setHeights:g,visibleToasts:N,heights:b,index:f,toasts:j,expanded:S,removeToast:w,defaultRichColors:_,closeButton:C,style:E,cancelButtonStyle:P,actionButtonStyle:F,className:I="",descriptionClassName:D="",duration:L,position:V,gap:B,loadingIcon:A,expandByDefault:z,classNames:M,icons:R,closeButtonAriaLabel:T="Close toast",pauseWhenPageIsHidden:U}=t,[q,H]=re.useState(null),[G,W]=re.useState(null),[X,Q]=re.useState(!1),[K,se]=re.useState(!1),[Y,J]=re.useState(!1),[te,pe]=re.useState(!1),[Fe,ke]=re.useState(!1),[Oe,ue]=re.useState(0),[je,le]=re.useState(0),ye=re.useRef(h.duration||L||nC),we=re.useRef(null),He=re.useRef(null),Lt=f===0,ut=f+1<=N,ge=h.type,Ne=h.dismissible!==!1,lt=h.className||"",mt=h.descriptionClassName||"",ae=re.useMemo(()=>b.findIndex(ee=>ee.toastId===h.id)||0,[b,h.id]),qe=re.useMemo(()=>{var ee;return(ee=h.closeButton)!=null?ee:C},[h.closeButton,C]),bt=re.useMemo(()=>h.duration||L||nC,[h.duration,L]),ht=re.useRef(0),Ht=re.useRef(0),wt=re.useRef(0),_e=re.useRef(null),[Se,We]=V.split("-"),Ut=re.useMemo(()=>b.reduce((ee,me,Z)=>Z>=ae?ee:ee+me.height,0),[b,ae]),$t=VM(),Nt=h.invert||x,ps=ge==="loading";Ht.current=re.useMemo(()=>ae*B+Ut,[ae,Ut]),re.useEffect(()=>{ye.current=bt},[bt]),re.useEffect(()=>{Q(!0)},[]),re.useEffect(()=>{let ee=He.current;if(ee){let me=ee.getBoundingClientRect().height;return le(me),g(Z=>[{toastId:h.id,height:me,position:h.position},...Z]),()=>g(Z=>Z.filter(xe=>xe.toastId!==h.id))}},[g,h.id]),re.useLayoutEffect(()=>{if(!X)return;let ee=He.current,me=ee.style.height;ee.style.height="auto";let Z=ee.getBoundingClientRect().height;ee.style.height=me,le(Z),g(xe=>xe.find(Pe=>Pe.toastId===h.id)?xe.map(Pe=>Pe.toastId===h.id?{...Pe,height:Z}:Pe):[{toastId:h.id,height:Z,position:h.position},...xe])},[X,h.title,h.description,g,h.id]);let ft=re.useCallback(()=>{se(!0),ue(Ht.current),g(ee=>ee.filter(me=>me.toastId!==h.id)),setTimeout(()=>{w(h)},oB)},[h,w,g,Ht]);re.useEffect(()=>{if(h.promise&&ge==="loading"||h.duration===1/0||h.type==="loading")return;let ee;return S||v||U&&$t?(()=>{if(wt.current<ht.current){let me=new Date().getTime()-ht.current;ye.current=ye.current-me}
1092wt.current=new Date().getTime()})():ye.current!==1/0&&(ht.current=new Date().getTime(),ee=setTimeout(()=>{var me;(me=h.onAutoClose)==null||me.call(h,h),ft()},ye.current)),()=>clearTimeout(ee)},[S,v,h,ge,U,$t,ft]),re.useEffect(()=>{h.delete&&ft()},[ft,h.delete]);function Ca(){var ee,me,Z;return R!=null&&R.loading?re.createElement("div",{className:kr(M==null?void 0:M.loader,(ee=h==null?void 0:h.classNames)==null?void 0:ee.loader,"sonner-loader"),"data-visible":ge==="loading"},R.loading):A?re.createElement("div",{className:kr(M==null?void 0:M.loader,(me=h==null?void 0:h.classNames)==null?void 0:me.loader,"sonner-loader"),"data-visible":ge==="loading"},A):re.createElement(BM,{className:kr(M==null?void 0:M.loader,(Z=h==null?void 0:h.classNames)==null?void 0:Z.loader),visible:ge==="loading"})}return re.createElement("li",{tabIndex:0,ref:He,className:kr(I,lt,M==null?void 0:M.toast,(s=h==null?void 0:h.classNames)==null?void 0:s.toast,M==null?void 0:M.default,M==null?void 0:M[ge],(n=h==null?void 0:h.classNames)==null?void 0:n[ge]),"data-sonner-toast":"","data-rich-colors":(a=h.richColors)!=null?a:_,"data-styled":!(h.jsx||h.unstyled||y),"data-mounted":X,"data-promise":!!h.promise,"data-swiped":Fe,"data-removed":K,"data-visible":ut,"data-y-position":Se,"data-x-position":We,"data-index":f,"data-front":Lt,"data-swiping":Y,"data-dismissible":Ne,"data-type":ge,"data-invert":Nt,"data-swipe-out":te,"data-swipe-direction":G,"data-expanded":!!(S||z&&X),style:{"--index":f,"--toasts-before":f,"--z-index":j.length-f,"--offset":`${K?Oe:Ht.current}px`,"--initial-height":z?"auto":`${je}px`,...E,...h.style},onDragEnd:()=>{J(!1),H(null),_e.current=null},onPointerDown:ee=>{ps||!Ne||(we.current=new Date,ue(Ht.current),ee.target.setPointerCapture(ee.pointerId),ee.target.tagName!=="BUTTON"&&(J(!0),_e.current={x:ee.clientX,y:ee.clientY}))},onPointerUp:()=>{var ee,me,Z,xe;if(te||!Ne)return;_e.current=null;let Pe=Number(((ee=He.current)==null?void 0:ee.style.getPropertyValue("--swipe-amount-x").replace("px",""))||0),De=Number(((me=He.current)==null?void 0:me.style.getPropertyValue("--swipe-amount-y").replace("px",""))||0),ne=new Date().getTime()-((Z=we.current)==null?void 0:Z.getTime()),oe=q==="x"?Pe:De,ie=Math.abs(oe)/ne;if(Math.abs(oe)>=iB||ie>.11){ue(Ht.current),(xe=h.onDismiss)==null||xe.call(h,h),W(q==="x"?Pe>0?"right":"left":De>0?"down":"up"),ft(),pe(!0),ke(!1);return}J(!1),H(null)},onPointerMove:ee=>{var me,Z,xe,Pe;if(!_e.current||!Ne||((me=window.getSelection())==null?void 0:me.toString().length)>0)return;let De=ee.clientY-_e.current.y,ne=ee.clientX-_e.current.x,oe=(Z=t.swipeDirections)!=null?Z:lB(V);!q&&(Math.abs(ne)>1||Math.abs(De)>1)&&H(Math.abs(ne)>Math.abs(De)?"x":"y");let ie={x:0,y:0};q==="y"?(oe.includes("top")||oe.includes("bottom"))&&(oe.includes("top")&&De<0||oe.includes("bottom")&&De>0)&&(ie.y=De):q==="x"&&(oe.includes("left")||oe.includes("right"))&&(oe.includes("left")&&ne<0||oe.includes("right")&&ne>0)&&(ie.x=ne),(Math.abs(ie.x)>0||Math.abs(ie.y)>0)&&ke(!0),(xe=He.current)==null||xe.style.setProperty("--swipe-amount-x",`${ie.x}px`),(Pe=He.current)==null||Pe.style.setProperty("--swipe-amount-y",`${ie.y}px`)}},qe&&!h.jsx?re.createElement("button",{"aria-label":T,"data-disabled":ps,"data-close-button":!0,onClick:ps||!Ne?()=>{}:()=>{var ee;ft(),(ee=h.onDismiss)==null||ee.call(h,h)},className:kr(M==null?void 0:M.closeButton,(r=h==null?void 0:h.classNames)==null?void 0:r.closeButton)},(i=R==null?void 0:R.close)!=null?i:GM):null,h.jsx||d.isValidElement(h.title)?h.jsx?h.jsx:typeof h.title=="function"?h.title():h.title:re.createElement(re.Fragment,null,ge||h.icon||h.promise?re.createElement("div",{"data-icon":"",className:kr(M==null?void 0:M.icon,(o=h==null?void 0:h.classNames)==null?void 0:o.icon)},h.promise||h.type==="loading"&&!h.icon?h.icon||Ca():null,h.type!=="loading"?h.icon||(R==null?void 0:R[ge])||OM(ge):null):null,re.createElement("div",{"data-content":"",className:kr(M==null?void 0:M.content,(l=h==null?void 0:h.classNames)==null?void 0:l.content)},re.createElement("div",{"data-title":"",className:kr(M==null?void 0:M.title,(c=h==null?void 0:h.classNames)==null?void 0:c.title)},typeof h.title=="function"?h.title():h.title),h.description?re.createElement("div",{"data-description":"",className:kr(D,mt,M==null?void 0:M.description,(u=h==null?void 0:h.classNames)==null?void 0:u.description)},typeof h.description=="function"?h.description():h.description):null),d.isValidElement(h.cancel)?h.cancel:h.cancel&&Ff(h.cancel)?re.createElement("button",{"data-button":!0,"data-cancel":!0,style:h.cancelButtonStyle||P,onClick:ee=>{var me,Z;Ff(h.cancel)&&Ne&&((Z=(me=h.cancel).onClick)==null||Z.call(me,ee),ft())},className:kr(M==null?void 0:M.cancelButton,(p=h==null?void 0:h.classNames)==null?void 0:p.cancelButton)},h.cancel.label):null,d.isValidElement(h.action)?h.action:h.action&&Ff(h.action)?re.createElement("button",{"data-button":!0,"data-action":!0,style:h.actionButtonStyle||F,onClick:ee=>{var me,Z;Ff(h.action)&&((Z=(me=h.action).onClick)==null||Z.call(me,ee),!ee.defaultPrevented&&ft())},className:kr(M==null?void 0:M.actionButton,(m=h==null?void 0:h.classNames)==null?void 0:m.actionButton)},h.action.label):null))};function aC(){if(typeof window>"u"||typeof document>"u")return"ltr";let t=document.documentElement.getAttribute("dir");return t==="auto"||!t?window.getComputedStyle(document.documentElement).direction:t}function dB(t,s){let n={};
vendor: 4,483 bytes, line 1092
1092return[t,s].forEach((a,r)=>{let i=r===1,o=i?"--mobile-offset":"--offset",l=i?nB:sB;function c(u){["top","right","bottom","left"].forEach(p=>{n[`${o}-${p}`]=typeof u=="number"?`${u}px`:u})}typeof a=="number"||typeof a=="string"?c(a):typeof a=="object"?["top","right","bottom","left"].forEach(u=>{a[u]===void 0?n[`${o}-${u}`]=l:n[`${o}-${u}`]=typeof a[u]=="number"?`${a[u]}px`:a[u]}):c(l)}),n}var uB=d.forwardRef(function(t,s){let{invert:n,position:a="bottom-right",hotkey:r=["altKey","KeyT"],expand:i,closeButton:o,className:l,offset:c,mobileOffset:u,theme:p="light",richColors:m,duration:x,style:h,visibleToasts:y=tB,toastOptions:v,dir:g=aC(),gap:N=rB,loadingIcon:b,icons:f,containerAriaLabel:j="Notifications",pauseWhenPageIsHidden:S}=t,[w,_]=re.useState([]),C=re.useMemo(()=>Array.from(new Set([a].concat(w.filter(U=>U.position).map(U=>U.position)))),[w,a]),[E,P]=re.useState([]),[F,I]=re.useState(!1),[D,L]=re.useState(!1),[V,B]=re.useState(p!=="system"?p:typeof window<"u"&&window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"),A=re.useRef(null),z=r.join("+").replace(/Key/g,"").replace(/Digit/g,""),M=re.useRef(null),R=re.useRef(!1),T=re.useCallback(U=>{_(q=>{var H;return(H=q.find(G=>G.id===U.id))!=null&&H.delete||da.dismiss(U.id),q.filter(({id:G})=>G!==U.id)})},[]);return re.useEffect(()=>da.subscribe(U=>{if(U.dismiss){_(q=>q.map(H=>H.id===U.id?{...H,delete:!0}:H));return}setTimeout(()=>{X7.flushSync(()=>{_(q=>{let H=q.findIndex(G=>G.id===U.id);return H!==-1?[...q.slice(0,H),{...q[H],...U},...q.slice(H+1)]:[U,...q]})})})}),[]),re.useEffect(()=>{if(p!=="system"){B(p);return}if(p==="system"&&(window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches?B("dark"):B("light")),typeof window>"u")return;let U=window.matchMedia("(prefers-color-scheme: dark)");try{U.addEventListener("change",({matches:q})=>{B(q?"dark":"light")})}catch{U.addListener(({matches:H})=>{try{B(H?"dark":"light")}catch(G){console.error(G)}})}},[p]),re.useEffect(()=>{w.length<=1&&I(!1)},[w]),re.useEffect(()=>{let U=q=>{var H,G;r.every(W=>q[W]||q.code===W)&&(I(!0),(H=A.current)==null||H.focus()),q.code==="Escape"&&(document.activeElement===A.current||(G=A.current)!=null&&G.contains(document.activeElement))&&I(!1)};return document.addEventListener("keydown",U),()=>document.removeEventListener("keydown",U)},[r]),re.useEffect(()=>{if(A.current)return()=>{M.current&&(M.current.focus({preventScroll:!0}),M.current=null,R.current=!1)}},[A.current]),re.createElement("section",{ref:s,"aria-label":`${j} ${z}`,tabIndex:-1,"aria-live":"polite","aria-relevant":"additions text","aria-atomic":"false",suppressHydrationWarning:!0},C.map((U,q)=>{var H;let[G,W]=U.split("-");return w.length?re.createElement("ol",{key:U,dir:g==="auto"?aC():g,tabIndex:-1,ref:A,className:l,"data-sonner-toaster":!0,"data-theme":V,"data-y-position":G,"data-lifted":F&&w.length>1&&!i,"data-x-position":W,style:{"--front-toast-height":`${((H=E[0])==null?void 0:H.height)||0}px`,"--width":`${aB}px`,"--gap":`${N}px`,...h,...dB(c,u)},onBlur:X=>{R.current&&!X.currentTarget.contains(X.relatedTarget)&&(R.current=!1,M.current&&(M.current.focus({preventScroll:!0}),M.current=null))},onFocus:X=>{X.target instanceof HTMLElement&&X.target.dataset.dismissible==="false"||R.current||(R.current=!0,M.current=X.relatedTarget)},onMouseEnter:()=>I(!0),onMouseMove:()=>I(!0),onMouseLeave:()=>{D||I(!1)},onDragEnd:()=>I(!1),onPointerDown:X=>{X.target instanceof HTMLElement&&X.target.dataset.dismissible==="false"||L(!0)},onPointerUp:()=>L(!1)},w.filter(X=>!X.position&&q===0||X.position===U).map((X,Q)=>{var K,se;return re.createElement(cB,{key:X.id,icons:f,index:Q,toast:X,defaultRichColors:m,duration:(K=v==null?void 0:v.duration)!=null?K:x,className:v==null?void 0:v.className,descriptionClassName:v==null?void 0:v.descriptionClassName,invert:n,visibleToasts:y,closeButton:(se=v==null?void 0:v.closeButton)!=null?se:o,interacting:D,position:U,style:v==null?void 0:v.style,unstyled:v==null?void 0:v.unstyled,classNames:v==null?void 0:v.classNames,cancelButtonStyle:v==null?void 0:v.cancelButtonStyle,actionButtonStyle:v==null?void 0:v.actionButtonStyle,removeToast:T,toasts:w.filter(Y=>Y.position==X.position),heights:E.filter(Y=>Y.position==X.position),setHeights:P,expandByDefault:i,gap:N,loadingIcon:b,expanded:F,pauseWhenPageIsHidden:S,swipeDirections:t.swipeDirections})})):null}))});const dD=d.createContext(null);function mB({children:t,defaultTheme:s="system",value:n,...a}
1092){const[r,i]=d.useState(()=>{if(typeof window<"u"){const l=localStorage.getItem("theme");return l&&(l==="dark"||l==="light"||l==="system")?l:s}return s});d.useEffect(()=>{const l=window.document.documentElement;if(l.classList.remove("light","dark"),r==="system"){const c=window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light";l.classList.add(c);return}l.classList.add(r)},[r]);const o={theme:r,setTheme:l=>{localStorage.setItem("theme",l),i(l)}};return e.jsx(dD.Provider,{value:o,...a,children:t})}const uD=()=>{const t=d.useContext(dD);if(!t)throw new Error("useTheme must be used within a ThemeProvider");return t},pB=({...t})=>{const{theme:s}=uD();return e.jsx(uB,{theme:s,className:"toaster group",toastOptions:{classNames:{toast:"group toast group-[.toaster]:bg-background group-[.toaster]:text-foreground group-[.toaster]:border-border group-[.toaster]:shadow-lg",description:"group-[.toast]:text-muted-foreground",actionButton:"group-[.toast]:bg-primary group-[.toast]:text-primary-foreground",cancelButton:"group-[.toast]:bg-muted group-[.toast]:text-muted-foreground"}},...t})};var hB=Object.defineProperty,xB=(t,s)=>hB(t,"name",{value:s,configurable:!0}),fB=$d[" useId ".trim().toString()]||(()=>{}),gB=0;function Bl(t){const[s,n]=d.useState(fB());return vs(()=>{t||n(a=>a??String(gB++))},[t]),t||(s?`radix-${s}`:"")}xB(Bl,"useId");const yB=["top","right","bottom","left"],Kl=Math.min,No=Math.max,Fy=Math.round,Tf=Math.floor,_o=t=>({x:t,y:t}),bB={left:"right",right:"left",bottom:"top",top:"bottom"};function mD(t,s,n){return No(t,Kl(s,n))}function Lo(t,s){return typeof t=="function"?t(s):t}function Ql(t){return t.split("-")[0]}function Qm(t){return t.split("-")[1]}function n5(t){return t==="x"?"y":"x"}function a5(t){return t==="y"?"height":"width"}function Ei(t){const s=t[0];return s==="t"||s==="b"?"y":"x"}function r5(t){return n5(Ei(t))}function vB(t,s,n){n===void 0&&(n=!1);const a=Qm(t),r=r5(t),i=a5(r);let o=r==="x"?a===(n?"end":"start")?"right":"left":a==="start"?"bottom":"top";return s.reference[i]>s.floating[i]&&(o=Ty(o)),[o,Ty(o)]}function jB(t){const s=Ty(t);return[x2(t),s,x2(s)]}function x2(t){return t.includes("start")?t.replace("start","end"):t.replace("end","start")}const rC=["left","right"],iC=["right","left"],wB=["top","bottom"],NB=["bottom","top"];function _B(t,s,n){switch(t){case"top":case"bottom":return n?s?iC:rC:s?rC:iC;case"left":case"right":return s?wB:NB;default:return[]}}function kB(t,s,n,a){const r=Qm(t);let i=_B(Ql(t),n==="start",a);return r&&(i=i.map(o=>o+"-"+r),s&&(i=i.concat(i.map(x2)))),i}function Ty(t){const s=Ql(t);return bB[s]+t.slice(s.length)}function SB(t){var s,n,a,r;return{top:(s=t.top)!=null?s:0,right:(n=t.right)!=null?n:0,bottom:(a=t.bottom)!=null?a:0,left:(r=t.left)!=null?r:0}}function pD(t){return typeof t!="number"?SB(t):{top:t,right:t,bottom:t,left:t}}function Py(t){const{x:s,y:n,width:a,height:r}=t;return{width:a,height:r,top:n,left:s,right:s+a,bottom:n+r,x:s,y:n}}function oC(t,s,n){let{reference:a,floating:r}=t;const i=Ei(s),o=r5(s),l=a5(o),c=Ql(s),u=i==="y",p=a.x+a.width/2-r.width/2,m=a.y+a.height/2-r.height/2,x=a[l]/2-r[l]/2;let h;switch(c){case"top":h={x:p,y:a.y-r.height};break;case"bottom":h={x:p,y:a.y+a.height};break;case"right":h={x:a.x+a.width,y:m};break;case"left":h={x:a.x-r.width,y:m};break;default:h={x:a.x,y:a.y}}const y=Qm(s);return y&&(h[o]+=x*(y==="end"?1:-1)*(n&&u?-1:1)),h}async function CB(t,s){var n;s===void 0&&(s={});const{x:a,y:r,platform:i,rects:o,elements:l,strategy:c}=t,{boundary:u="clippingAncestors",rootBoundary:p="viewport",elementContext:m="floating",altBoundary:x=!1,padding:h=0}=Lo(s,t),y=pD(h),g=l[x?m==="floating"?"reference":"floating":m],N=Py(await i.getClippingRect({element:(n=await(i.isElement==null?void 0:i.isElement(g)))==null||n?g:g.contextElement||await(i.getDocumentElement==null?void 0:i.getDocumentElement(l.floating)),boundary:u,rootBoundary:p,strategy:c})),b=m==="floating"?{x:a,y:r,width:o.floating.width,height:o.floating.height}:o.reference,f=await(i.getOffsetParent==null?void 0:i.getOffsetParent(l.floating)),j=await(i.isElement==null?void 0:i.isElement(f))&&await(i.getScale==null?void 0:i.getScale(f))||{x:1,y:1},S=Py(i.convertOffsetParentRelativeRectToViewportRelativeRect?await i.convertOffsetParentRelativeRectToViewportRelativeRect({elements:l,rect:b,offsetParent:f,strategy:c}):b);return{top:(N.top-S.top+y.top)/j.y,bottom:(S.bottom-N.bottom+y.bottom)/j.y,left:(N.left-S.left+y.left)/j.x,right:(S.right-N.right+y.right)/j.x}}const AB=50,EB=async(t,s,n)=>{const{placement:a="bottom",strategy:r="absolute",middleware:i=[],platform:o}=n,l=o.detectOverflow?o:{...o,detectOverflow:CB},c=await(o.isRTL==null?void 0:o.isRTL(s));let u=await o.getElementRects({reference:t,floating:s,strategy:r}),{x:p,y:m}=oC(u,a,c),x=a,h=0;const y={};for(let v=0;v<i.length;v++){const g=i[v];if(!g)continue;const{name:N,fn:b}=g,{x:f,y:j,data:S,reset:w}=await b({x:p,y:m,initialPlacement:a,placement:x,strategy:r,middlewareData:y,rects:u,platform:l,elements:{reference:t,floating:s}});p=f??p,m=j??m,y[N]={...y[N],...S},w&&h<AB&&(h++,typeof w=="object"&&(w.placement&&(x=w.placement),w.rects&&(u=w.rects===!0?await o.getElementRects({reference:t,floating:s,strategy:r}):w.rects),{x:p,y:m}=oC(u,x,c)),v=-1)}return{x:p,y:m,placement:x,strategy:r,middlewareData:y}},FB=t=>({name:"arrow",options:t,async fn(s){const{x:n,y:a,placement:r,rects:i,platform:o,elements:l,middlewareData:c}=s,{element:u,padding:p=0}=Lo(t,s)||{};if(u==null)return{};const m=pD(p),x={x:n,y:a},h=r5(r),y=a5(h),v=await o.getDimensions(u),g=h==="y",N=g?"top":"left",b=g?"bottom":"right",f=g?"clientHeight":"clientWidth",j=i.reference[y]+i.reference[h]-x[h]-i.floating[y],S=x[h]-i.reference[h],w=await(o.getOffsetParent==null?void 0:o.getOffsetParent(u));let _=w?w[f]:0;(!_||!await(o.isElement==null?void 0:o.isElement(w)))&&(_=l.floating[f]||i.floating[y]);const C=j/2-S/2,E=_/2-v[y]/2-1,P=Kl(m[N],E),F=Kl(m[b],E),I=_-v[y]-F,D=_/2-v[y]/2+C,L=mD(P,D,I),V=!c.arrow&&Qm(r)!=null&&D!==L&&i.reference[y]/2-(D<P?P:F)-v[y]/2<0,B=V?D<P?D-P:D-I:0;return{[h]:x[h]+B,data:{[h]:L,centerOffset:D-L-B,...V&&{alignmentOffset:B}},reset:V}}}),TB=function(t){return t===void 0&&(t={}),{name:"flip",options:t,async fn(s){var n,a;const{placement:r,middlewareData:i,rects:o,initialPlacement:l,platform:c,elements:u}=s,{mainAxis:p=!0,crossAxis:m=!0,fallbackPlacements:x,fallbackStrategy:h="bestFit",fallbackAxisSideDirection:y="none",flipAlignment:v=!0,...g}=Lo(t,s);if((n=i.arrow)!=null&&n.alignmentOffset)return{};const N=Ql(r),b=Ei(l),f=Ql(l)===l,j=await(c.isRTL==null?void 0:c.isRTL(u.floating)),S=x||(f||!v?[Ty(l)]:jB(l)),w=y!=="none";!x&&w&&S.push(...kB(l,v,y,j));const _=[l,...S],C=await c.detectOverflow(s,g),E=[];let P=((a=i.flip)==null?void 0:a.overflows)||[];if(p&&E.push(C[N]),m){const L=vB(r,o,j);E.push(C[L[0]],C[L[1]])}if(P=[...P,{placement:r,overflows:E}],!E.every(L=>L<=0)){var F,I;const L=(((F=i.flip)==null?void 0:F.index)||0)+1,V=_[L];
vendor: 6,207 bytes, line 1092
1092if(V&&(!(m==="alignment"?b!==Ei(V):!1)||P.every(z=>Ei(z.placement)===b?z.overflows[0]>0:!0)))return{data:{index:L,overflows:P},reset:{placement:V}};let B=(I=P.filter(A=>A.overflows[0]<=0).sort((A,z)=>A.overflows[1]-z.overflows[1])[0])==null?void 0:I.placement;if(!B)switch(h){case"bestFit":{var D;const A=(D=P.filter(z=>{if(w){const M=Ei(z.placement);return M===b||M==="y"}return!0}).map(z=>[z.placement,z.overflows.filter(M=>M>0).reduce((M,R)=>M+R,0)]).sort((z,M)=>z[1]-M[1])[0])==null?void 0:D[0];A&&(B=A);break}case"initialPlacement":B=l;break}if(r!==B)return{reset:{placement:B}}}return{}}}};function lC(t,s){return{top:t.top-s.height,right:t.right-s.width,bottom:t.bottom-s.height,left:t.left-s.width}}function cC(t){return yB.some(s=>t[s]>=0)}const PB=function(t){return t===void 0&&(t={}),{name:"hide",options:t,async fn(s){const{rects:n,platform:a}=s,{strategy:r="referenceHidden",...i}=Lo(t,s);switch(r){case"referenceHidden":{const o=await a.detectOverflow(s,{...i,elementContext:"reference"}),l=lC(o,n.reference);return{data:{referenceHiddenOffsets:l,referenceHidden:cC(l)}}}case"escaped":{const o=await a.detectOverflow(s,{...i,altBoundary:!0}),l=lC(o,n.floating);return{data:{escapedOffsets:l,escaped:cC(l)}}}default:return{}}}}},hD=new Set(["left","top"]);async function DB(t,s){const{placement:n,platform:a,elements:r}=t,i=await(a.isRTL==null?void 0:a.isRTL(r.floating)),o=Ql(n),l=Qm(n),c=Ei(n)==="y",u=hD.has(o)?-1:1,p=i&&c?-1:1,m=Lo(s,t);let{mainAxis:x,crossAxis:h,alignmentAxis:y}=typeof m=="number"?{mainAxis:m,crossAxis:0,alignmentAxis:null}:{mainAxis:m.mainAxis||0,crossAxis:m.crossAxis||0,alignmentAxis:m.alignmentAxis};return l&&typeof y=="number"&&(h=l==="end"?y*-1:y),c?{x:h*p,y:x*u}:{x:x*u,y:h*p}}const RB=function(t){return t===void 0&&(t=0),{name:"offset",options:t,async fn(s){var n,a;const{x:r,y:i,placement:o,middlewareData:l}=s,c=await DB(s,t);return o===((n=l.offset)==null?void 0:n.placement)&&(a=l.arrow)!=null&&a.alignmentOffset?{}:{x:r+c.x,y:i+c.y,data:{...c,placement:o}}}}},IB=function(t){return t===void 0&&(t={}),{name:"shift",options:t,async fn(s){const{x:n,y:a,placement:r,platform:i}=s,{mainAxis:o=!0,crossAxis:l=!1,limiter:c={fn:b=>{let{x:f,y:j}=b;return{x:f,y:j}}},...u}=Lo(t,s),p={x:n,y:a},m=await i.detectOverflow(s,u),x=Ei(r),h=n5(x);let y=p[h],v=p[x];const g=(b,f)=>mD(f+m[b==="y"?"top":"left"],f,f-m[b==="y"?"bottom":"right"]);o&&(y=g(h,y)),l&&(v=g(x,v));const N=c.fn({...s,[h]:y,[x]:v});return{...N,data:{x:N.x-n,y:N.y-a,enabled:{[h]:o,[x]:l}}}}}},$B=function(t){return t===void 0&&(t={}),{options:t,fn(s){var n,a;const{x:r,y:i,placement:o,rects:l,middlewareData:c}=s,{offset:u=0,mainAxis:p=!0,crossAxis:m=!0}=Lo(t,s),x={x:r,y:i},h=Ei(o),y=n5(h);let v=x[y],g=x[h];const N=Lo(u,s),b=typeof N=="number"?{mainAxis:N,crossAxis:0}:{mainAxis:(n=N.mainAxis)!=null?n:0,crossAxis:(a=N.crossAxis)!=null?a:0};if(p){const S=y==="y"?"height":"width",w=l.reference[y]-l.floating[S]+b.mainAxis,_=l.reference[y]+l.reference[S]-b.mainAxis;v<w?v=w:v>_&&(v=_)}if(m){var f,j;const S=y==="y"?"width":"height",w=hD.has(Ql(o)),_=l.reference[h]-l.floating[S]+(w&&((f=c.offset)==null?void 0:f[h])||0)+(w?0:b.crossAxis),C=l.reference[h]+l.reference[S]+(w?0:((j=c.offset)==null?void 0:j[h])||0)-(w?b.crossAxis:0);g<_?g=_:g>C&&(g=C)}return{[y]:v,[h]:g}}}},zB=function(t){return t===void 0&&(t={}),{name:"size",options:t,async fn(s){const{placement:n,rects:a,platform:r,elements:i}=s,{apply:o=()=>{},...l}=Lo(t,s),c=await r.detectOverflow(s,l),u=Ql(n),p=Qm(n),m=Ei(n)==="y",{width:x,height:h}=a.floating;let y,v;u==="top"||u==="bottom"?(y=u,v=p===(await(r.isRTL==null?void 0:r.isRTL(i.floating))?"start":"end")?"left":"right"):(v=u,y=p==="end"?"top":"bottom");const g=h-c.top-c.bottom,N=x-c.left-c.right,b=Kl(h-c[y],g),f=Kl(x-c[v],N),j=s.middlewareData.shift,S=!j;let w=b,_=f;j!=null&&j.enabled.x&&(_=N),j!=null&&j.enabled.y&&(w=g),S&&!p&&(m?_=x-2*No(c.left,c.right):w=h-2*No(c.top,c.bottom)),await o({...s,availableWidth:_,availableHeight:w});const C=await r.getDimensions(i.floating);return x!==C.width||h!==C.height?{reset:{rects:!0}}:{}}}};function Ob(){return typeof window<"u"}function Jm(t){return xD(t)?(t.nodeName||"").toLowerCase():"#document"}function ja(t){var s;return(t==null||(s=t.ownerDocument)==null?void 0:s.defaultView)||window}function Uo(t){var s;return(s=(xD(t)?t.ownerDocument:t.document)||window.document)==null?void 0:s.documentElement}function xD(t){return Ob()?t instanceof Node||t instanceof ja(t).Node:!1}function Li(t){return Ob()?t instanceof Element||t instanceof ja(t).Element:!1}function oc(t){return Ob()?t instanceof HTMLElement||t instanceof ja(t).HTMLElement:!1}function dC(t){return!Ob()||typeof ShadowRoot>"u"?!1:t instanceof ShadowRoot||t instanceof ja(t).ShadowRoot}function Mb(t){const{overflow:s,overflowX:n,overflowY:a,display:r}=Oi(t);return/auto|scroll|overlay|hidden|clip/.test(s+a+n)&&r!=="inline"&&r!=="contents"}function LB(t){return/^(table|td|th)$/.test(Jm(t))}function Bb(t){try{if(t.matches(":popover-open"))return!0}catch{}try{return t.matches(":modal")}catch{return!1}}const OB=/transform|translate|scale|rotate|perspective|filter/,MB=/paint|layout|strict|content/,pc=t=>!!t&&t!=="none";let nv;function i5(t){const s=Li(t)?Oi(t):t;return pc(s.transform)||pc(s.translate)||pc(s.scale)||pc(s.rotate)||pc(s.perspective)||!o5()&&(pc(s.backdropFilter)||pc(s.filter))||OB.test(s.willChange||"")||MB.test(s.contain||"")}function BB(t){let s=Ad(t);for(;oc(s)&&!mx(s);){if(i5(s))return s;if(Bb(s))return null;s=Ad(s)}return null}function o5(){return nv==null&&(nv=typeof CSS<"u"&&CSS.supports&&CSS.supports("-webkit-backdrop-filter","none")),nv}function mx(t){return/^(html|body|#document)$/.test(Jm(t))}function Oi(t){return ja(t).getComputedStyle(t)}function Ub(t){return Li(t)?{scrollLeft:t.scrollLeft,scrollTop:t.scrollTop}:{scrollLeft:t.scrollX,scrollTop:t.scrollY}}function Ad(t){if(Jm(t)==="html")return t;const s=t.assignedSlot||t.parentNode||dC(t)&&t.host||Uo(t);return dC(s)?s.host:s}function fD(t){const s=Ad(t);return mx(s)?(t.ownerDocument||t).body:oc(s)&&Mb(s)?s:fD(s)}function px(t,s,n){var a;s===void 0&&(s=[]),n===void 0&&(n=!0);const r=fD(t),i=r===((a=t.ownerDocument)==null?void 0:a.body),o=ja(r);if(i){const l=f2(o);
1092return s.concat(o,o.visualViewport||[],Mb(r)?r:[],l&&n?px(l):[])}else return s.concat(r,px(r,[],n))}function f2(t){return t.parent&&Object.getPrototypeOf(t.parent)?t.frameElement:null}function gD(t){const s=Oi(t);let n=parseFloat(s.width)||0,a=parseFloat(s.height)||0;const r=oc(t),i=r?t.offsetWidth:n,o=r?t.offsetHeight:a,l=Fy(n)!==i||Fy(a)!==o;return l&&(n=i,a=o),{width:n,height:a,$:l}}function l5(t){return Li(t)?t:t.contextElement}function nm(t){const s=l5(t);if(!oc(s))return _o(1);const n=s.getBoundingClientRect(),{width:a,height:r,$:i}=gD(s);let o=(i?Fy(n.width):n.width)/a,l=(i?Fy(n.height):n.height)/r;return(!o||!Number.isFinite(o))&&(o=1),(!l||!Number.isFinite(l))&&(l=1),{x:o,y:l}}const UB=_o(0);function yD(t){const s=ja(t);return!o5()||!s.visualViewport?UB:{x:s.visualViewport.offsetLeft,y:s.visualViewport.offsetTop}}function qB(t,s,n){return s===void 0&&(s=!1),!!n&&s&&n===ja(t)}function Ed(t,s,n,a){s===void 0&&(s=!1),n===void 0&&(n=!1);const r=t.getBoundingClientRect(),i=l5(t);let o=_o(1);s&&(a?Li(a)&&(o=nm(a)):o=nm(t));const l=qB(i,n,a)?yD(i):_o(0);let c=(r.left+l.x)/o.x,u=(r.top+l.y)/o.y,p=r.width/o.x,m=r.height/o.y;if(i&&a){const x=ja(i),h=Li(a)?ja(a):a;let y=x,v=f2(y);for(;v&&h!==y;){const g=nm(v),N=v.getBoundingClientRect(),b=Oi(v),f=N.left+(v.clientLeft+parseFloat(b.paddingLeft))*g.x,j=N.top+(v.clientTop+parseFloat(b.paddingTop))*g.y;c*=g.x,u*=g.y,p*=g.x,m*=g.y,c+=f,u+=j,y=ja(v),v=f2(y)}}return Py({width:p,height:m,x:c,y:u})}function qb(t,s){const n=Ub(t).scrollLeft;return s?s.left+n:Ed(Uo(t)).left+n}function bD(t,s){const n=t.getBoundingClientRect(),a=n.left+s.scrollLeft-qb(t,n),r=n.top+s.scrollTop;return{x:a,y:r}}function WB(t){let{elements:s,rect:n,offsetParent:a,strategy:r}=t;const i=r==="fixed",o=Uo(a),l=s?Bb(s.floating):!1;if(a===o||l&&i)return n;let c={scrollLeft:0,scrollTop:0},u=_o(1);const p=_o(0),m=oc(a);if((m||!i)&&((Jm(a)!=="body"||Mb(o))&&(c=Ub(a)),m)){const h=Ed(a);u=nm(a),p.x=h.x+a.clientLeft,p.y=h.y+a.clientTop}const x=o&&!m&&!i?bD(o,c):_o(0);return{width:n.width*u.x,height:n.height*u.y,x:n.x*u.x-c.scrollLeft*u.x+p.x+x.x,y:n.y*u.y-c.scrollTop*u.y+p.y+x.y}}function HB(t){return t.getClientRects?Array.from(t.getClientRects()):[]}function GB(t){const s=Ub(t),n=t.ownerDocument.body,a=No(t.scrollWidth,t.clientWidth,n.scrollWidth,n.clientWidth),r=No(t.scrollHeight,t.clientHeight,n.scrollHeight,n.clientHeight);let i=-s.scrollLeft+qb(t);const o=-s.scrollTop;return Oi(n).direction==="rtl"&&(i+=No(t.clientWidth,n.clientWidth)-a),{width:a,height:r,x:i,y:o}}const VB=25;function ZB(t,s,n){n===void 0&&(n="viewport");const a=n==="layoutViewport",r=ja(t),i=Uo(t),o=r.visualViewport;let l=i.clientWidth,c=i.clientHeight,u=0,p=0;if(o){const x=!o5()||s==="fixed";a?x||(u=-o.offsetLeft,p=-o.offsetTop):(l=o.width,c=o.height,x&&(u=o.offsetLeft,p=o.offsetTop))}if(qb(i)<=0){const x=i.ownerDocument,h=x.body,y=getComputedStyle(h),v=x.compatMode==="CSS1Compat"&&parseFloat(y.marginLeft)+parseFloat(y.marginRight)||0,g=Math.abs(i.clientWidth-h.clientWidth-v),N=getComputedStyle(i).scrollbarGutter==="stable both-edges"?g/2:g;N<=VB&&(l-=N)}return{width:l,height:c,x:u,y:p}}function YB(t,s){const n=Ed(t,!0,s==="fixed"),a=n.top+t.clientTop,r=n.left+t.clientLeft,i=nm(t),o=t.clientWidth*i.x,l=t.clientHeight*i.y,c=r*i.x,u=a*i.y;return{width:o,height:l,x:c,y:u}}function uC(t,s,n){let a;if(s==="viewport"||s==="layoutViewport")a=ZB(t,n,s);else if(s==="document")a=GB(Uo(t));else if(Li(s))a=YB(s,n);else{const r=yD(t);a={x:s.x-r.x,y:s.y-r.y,width:s.width,height:s.height}}return Py(a)}function KB(t,s){const n=s.get(t);if(n)return n;let a=px(t,[],!1).filter(l=>Li(l)&&Jm(l)!=="body"),r=null;const i=Oi(t).position==="fixed";let o=i?Ad(t):t;for(;Li(o)&&!mx(o);){const l=Oi(o),c=i5(o),u=r?r.position:i?"fixed":"";!c&&(u==="fixed"||u==="absolute"&&l.position==="static")?a=a.filter(m=>m!==o):r=l,o=Ad(o)}return s.set(t,a),a}function QB(t){let{element:s,boundary:n,rootBoundary:a,strategy:r}=t;const o=[...n==="clippingAncestors"?Bb(s)?[]:KB(s,this._c):[].concat(n),a],l=uC(s,o[0],r);let c=l.top,u=l.right,p=l.bottom,m=l.left;for(let x=1;x<o.length;x++){const h=uC(s,o[x],r);c=No(h.top,c),u=Kl(h.right,u),p=Kl(h.bottom,p),m=No(h.left,m)}
vendor: 4,460 bytes, line 1092
1092return{width:u-m,height:p-c,x:m,y:c}}function JB(t){const{width:s,height:n}=gD(t);return{width:s,height:n}}function XB(t,s,n){const a=oc(s),r=Uo(s),i=n==="fixed",o=Ed(t,!0,i,s);let l={scrollLeft:0,scrollTop:0};const c=_o(0);if((a||!i)&&((Jm(s)!=="body"||Mb(r))&&(l=Ub(s)),a)){const x=Ed(s,!0,i,s);c.x=x.x+s.clientLeft,c.y=x.y+s.clientTop}!a&&r&&(c.x=qb(r));const u=r&&!a&&!i?bD(r,l):_o(0),p=o.left+l.scrollLeft-c.x-u.x,m=o.top+l.scrollTop-c.y-u.y;return{x:p,y:m,width:o.width,height:o.height}}function av(t){return Oi(t).position==="static"}function mC(t,s){if(!oc(t)||Oi(t).position==="fixed")return null;if(s)return s(t);let n=t.offsetParent;return Uo(t)===n&&(n=n.ownerDocument.body),n}function vD(t,s){const n=ja(t);if(Bb(t))return n;if(!oc(t)){let r=Ad(t);for(;r&&!mx(r);){if(Li(r)&&!av(r))return r;r=Ad(r)}return n}let a=mC(t,s);for(;a&&LB(a)&&av(a);)a=mC(a,s);return a&&mx(a)&&av(a)&&!i5(a)?n:a||BB(t)||n}const eU=async function(t){const s=this.getOffsetParent||vD,n=this.getDimensions,a=await n(t.floating);return{reference:XB(t.reference,await s(t.floating),t.strategy),floating:{x:0,y:0,width:a.width,height:a.height}}};function tU(t){return Oi(t).direction==="rtl"}const sU={convertOffsetParentRelativeRectToViewportRelativeRect:WB,getDocumentElement:Uo,getClippingRect:QB,getOffsetParent:vD,getElementRects:eU,getClientRects:HB,getDimensions:JB,getScale:nm,isElement:Li,isRTL:tU};function jD(t,s){return t.x===s.x&&t.y===s.y&&t.width===s.width&&t.height===s.height}function nU(t,s,n){let a=null,r;const i=Uo(t);function o(){var p;clearTimeout(r),(p=a)==null||p.disconnect(),a=null}function l(p,m){p===void 0&&(p=!1),m===void 0&&(m=1),o();const x=t.getBoundingClientRect(),{left:h,top:y,width:v,height:g}=x;if(p||s(),!v||!g)return;const N=Tf(y),b=Tf(i.clientWidth-(h+v)),f=Tf(i.clientHeight-(y+g)),j=Tf(h),w={rootMargin:-N+"px "+-b+"px "+-f+"px "+-j+"px",threshold:No(0,Kl(1,m))||1};let _=!0;function C(E){const P=E[0].intersectionRatio;if(!jD(x,t.getBoundingClientRect()))return l();if(P!==m){if(!_)return l();P?l(!1,P):r=setTimeout(()=>{l(!1,1e-7)},1e3)}_=!1}try{a=new IntersectionObserver(C,{...w,root:i.ownerDocument})}catch{a=new IntersectionObserver(C,w)}a.observe(t)}const c=ja(t),u=()=>l(n);return c.addEventListener("resize",u),l(!0),()=>{c.removeEventListener("resize",u),o()}}function aU(t,s,n,a){a===void 0&&(a={});const{ancestorScroll:r=!0,ancestorResize:i=!0,elementResize:o=typeof ResizeObserver=="function",layoutShift:l=typeof IntersectionObserver=="function",animationFrame:c=!1}=a,u=l5(t),p=r||i?[...u?px(u):[],...s?px(s):[]]:[];p.forEach(N=>{r&&N.addEventListener("scroll",n),i&&N.addEventListener("resize",n)});const m=u&&l?nU(u,n,i):null;let x=-1,h=null;o&&(h=new ResizeObserver(N=>{let[b]=N;b&&b.target===u&&h&&s&&(h.unobserve(s),cancelAnimationFrame(x),x=requestAnimationFrame(()=>{var f;(f=h)==null||f.observe(s)})),n()}),u&&!c&&h.observe(u),s&&h.observe(s));let y,v=c?Ed(t):null;c&&g();function g(){const N=Ed(t);v&&!jD(v,N)&&n(),v=N,y=requestAnimationFrame(g)}return n(),()=>{var N;p.forEach(b=>{r&&b.removeEventListener("scroll",n),i&&b.removeEventListener("resize",n)}),m==null||m(),(N=h)==null||N.disconnect(),h=null,c&&cancelAnimationFrame(y)}}const rU=RB,iU=IB,oU=TB,lU=zB,cU=PB,pC=FB,dU=$B,uU=(t,s,n)=>{const a=new Map,r=n??{},i={...sU,...r.platform,_c:a};return EB(t,s,{...r,platform:i})};var mU=typeof document<"u",pU=function(){},p0=mU?d.useLayoutEffect:pU;function Dy(t,s){if(t===s)return!0;if(typeof t!=typeof s)return!1;if(typeof t=="function"&&t.toString()===s.toString())return!0;let n,a,r;if(t&&s&&typeof t=="object"){if(Array.isArray(t)){if(n=t.length,n!==s.length)return!1;for(a=n;a--!==0;)if(!Dy(t[a],s[a]))return!1;return!0}if(r=Object.keys(t),n=r.length,n!==Object.keys(s).length)return!1;for(a=n;a--!==0;)if(!{}.hasOwnProperty.call(s,r[a]))return!1;for(a=n;a--!==0;){const i=r[a];if(!(i==="_owner"&&t.$$typeof)&&!Dy(t[i],s[i]))return!1}return!0}return t!==t&&s!==s}function wD(t){return typeof window>"u"?1:(t.ownerDocument.defaultView||window).devicePixelRatio||1}function hC(t,s){const n=wD(t);return Math.round(s*n)/n}function rv(t){const s=d.useRef(t);return p0(()=>{s.current=t}),s}function hU(t){t===void 0&&(t={});const{placement:s="bottom",strategy:n="absolute",middleware:a=[],platform:r,elements:{reference:i,floating:o}={},transform:l=!0,whileElementsMounted:c,open:u}=t,[p,m]=d.useState({x:0,y:0,strategy:n,placement:s,middlewareData:{},isPositioned:!1}),[x,h]=d.useState(a);Dy(x,a)||h(a);
1092const[y,v]=d.useState(null),[g,N]=d.useState(null),b=d.useCallback(z=>{z!==w.current&&(w.current=z,v(z))},[]),f=d.useCallback(z=>{z!==_.current&&(_.current=z,N(z))},[]),j=i||y,S=o||g,w=d.useRef(null),_=d.useRef(null),C=d.useRef(p),E=c!=null,P=rv(c),F=rv(r),I=rv(u),D=d.useCallback(()=>{if(!w.current||!_.current)return;const z={placement:s,strategy:n,middleware:x};F.current&&(z.platform=F.current),uU(w.current,_.current,z).then(M=>{const R={...M,isPositioned:I.current!==!1};L.current&&!Dy(C.current,R)&&(C.current=R,rc.flushSync(()=>{m(R)}))})},[x,s,n,F,I]);p0(()=>{u===!1&&C.current.isPositioned&&(C.current.isPositioned=!1,m(z=>({...z,isPositioned:!1})))},[u]);const L=d.useRef(!1);p0(()=>(L.current=!0,()=>{L.current=!1}),[]),p0(()=>{if(j&&(w.current=j),S&&(_.current=S),j&&S){if(P.current)return P.current(j,S,D);D()}},[j,S,D,P,E]);const V=d.useMemo(()=>({reference:w,floating:_,setReference:b,setFloating:f}),[b,f]),B=d.useMemo(()=>({reference:j,floating:S}),[j,S]),A=d.useMemo(()=>{const z={position:n,left:0,top:0};if(!B.floating)return z;const M=hC(B.floating,p.x),R=hC(B.floating,p.y);return l?{...z,transform:"translate("+M+"px, "+R+"px)",...wD(B.floating)>=1.5&&{willChange:"transform"}}:{position:n,left:M,top:R}},[n,l,B.floating,p.x,p.y]);return d.useMemo(()=>({...p,update:D,refs:V,elements:B,floatingStyles:A}),[p,D,V,B,A])}const xU=t=>{function s(n){return{}.hasOwnProperty.call(n,"current")}return{name:"arrow",options:t,fn(n){const{element:a,padding:r}=typeof t=="function"?t(n):t;return a&&s(a)?a.current!=null?pC({element:a.current,padding:r}).fn(n):{}:a?pC({element:a,padding:r}).fn(n):{}}}},fU=(t,s)=>{const n=rU(t);return{name:n.name,fn:n.fn,options:[t,s]}},gU=(t,s)=>{const n=iU(t);return{name:n.name,fn:n.fn,options:[t,s]}},yU=(t,s)=>({fn:dU(t).fn,options:[t,s]}),bU=(t,s)=>{const n=oU(t);return{name:n.name,fn:n.fn,options:[t,s]}},vU=(t,s)=>{const n=lU(t);return{name:n.name,fn:n.fn,options:[t,s]}},jU=(t,s)=>{const n=cU(t);return{name:n.name,fn:n.fn,options:[t,s]}},wU=(t,s)=>{const n=xU(t);return{name:n.name,fn:n.fn,options:[t,s]}};var NU=Object.defineProperty,_U=(t,s)=>NU(t,"name",{value:s,configurable:!0});function Wb(t){const[s,n]=d.useState(void 0);return vs(()=>{if(t){n({width:t.offsetWidth,height:t.offsetHeight});const a=new ResizeObserver(r=>{if(!Array.isArray(r)||!r.length)return;const i=r[0];let o,l;if("borderBoxSize"in i){const c=i.borderBoxSize,u=Array.isArray(c)?c[0]:c;o=u.inlineSize,l=u.blockSize}else o=t.offsetWidth,l=t.offsetHeight;n({width:o,height:l})});return a.observe(t,{box:"border-box"}),()=>a.unobserve(t)}else n(void 0)},[t]),s}_U(Wb,"useSize");var kU=Object.defineProperty,Ul=(t,s)=>kU(t,"name",{value:s,configurable:!0}),ND="Popper",[_D,Hb]=Va(ND),[SU,kD]=_D(ND),CU=Ul(t=>{const{__scopePopper:s,children:n}=t,[a,r]=d.useState(null),[i,o]=d.useState(void 0);return e.jsx(SU,{scope:s,anchor:a,onAnchorChange:r,placementState:i,setPlacementState:o,children:n})},"Popper"),AU="PopperAnchor",EU=d.forwardRef(Ul(function(s,n){const{__scopePopper:a,virtualRef:r,...i}=s,o=kD(AU,a),l=d.useRef(null),c=o.onAnchorChange,u=d.useCallback(v=>{l.current=v,v&&c(v)},[c]),p=It(n,u),m=d.useRef(null);d.useEffect(()=>{if(!r)return;const v=m.current;m.current=r.current,v!==m.current&&c(m.current)});const x=o.placementState&&Gb(o.placementState),h=x==null?void 0:x[0],y=x==null?void 0:x[1];return r?null:e.jsx(yt.div,{"data-radix-popper-side":h,"data-radix-popper-align":y,...i,ref:p})},"PopperAnchor")),SD="PopperContent",[FU,The]=_D(SD),TU=d.forwardRef(Ul(function(s,n){var K,se,Y,J,te,pe,Fe;const{__scopePopper:a,side:r="bottom",sideOffset:i=0,align:o="center",alignOffset:l=0,arrowPadding:c=0,avoidCollisions:u=!0,collisionBoundary:p=[],collisionPadding:m=0,sticky:x="partial",hideWhenDetached:h=!1,updatePositionStrategy:y="optimized",onPlaced:v,...g}=s,N=kD(SD,a),[b,f]=d.useState(null),j=It(n,f),[S,w]=d.useState(null),_=Wb(S),C=(_==null?void 0:_.width)??0,E=(_==null?void 0:_.height)??0,P=r+(o!=="center"?"-"+o:""),F=typeof m=="number"?m:{top:0,right:0,bottom:0,left:0,...m},I=Array.isArray(p)?p:[p],D=I.length>0,L={padding:F,boundary:I.filter(CD),altBoundary:D},{refs:V,floatingStyles:B,placement:A,isPositioned:z,middlewareData:M}=hU({strategy:"fixed",placement:P,whileElementsMounted:Ul((...ke)=>aU(...ke,{animationFrame:y==="always"}
1092),"whileElementsMounted"),elements:{reference:N.anchor},middleware:[fU({mainAxis:i+E,alignmentAxis:l}),u&&gU({mainAxis:!0,crossAxis:!1,limiter:x==="partial"?yU():void 0,...L}),u&&bU({...L}),vU({...L,apply:Ul(({elements:ke,rects:Oe,availableWidth:ue,availableHeight:je})=>{const{width:le,height:ye}=Oe.reference,we=ke.floating.style;we.setProperty("--radix-popper-available-width",`${ue}px`),we.setProperty("--radix-popper-available-height",`${je}px`),we.setProperty("--radix-popper-anchor-width",`${le}px`),we.setProperty("--radix-popper-anchor-height",`${ye}px`)},"apply")}),S&&wU({element:S,padding:c}),PU({arrowWidth:C,arrowHeight:E}),h&&jU({strategy:"referenceHidden",...L,boundary:D?L.boundary:void 0})]}),R=N.setPlacementState;vs(()=>(R(A),()=>{R(void 0)}),[A,R]);const[T,U]=Gb(A),q=sa(v);vs(()=>{z&&(q==null||q())},[z,q]);const H=(K=M.arrow)==null?void 0:K.x,G=(se=M.arrow)==null?void 0:se.y,W=((Y=M.arrow)==null?void 0:Y.centerOffset)!==0,[X,Q]=d.useState();return vs(()=>{b&&Q(window.getComputedStyle(b).zIndex)},[b]),e.jsx("div",{ref:V.setFloating,"data-radix-popper-content-wrapper":"",style:{...B,transform:z?B.transform:"translate(0, -200%)",minWidth:"max-content",zIndex:X,"--radix-popper-transform-origin":[(J=M.transformOrigin)==null?void 0:J.x,(te=M.transformOrigin)==null?void 0:te.y].join(" "),...((pe=M.hide)==null?void 0:pe.referenceHidden)&&{visibility:"hidden",pointerEvents:"none"}},dir:s.dir,children:e.jsx(FU,{scope:a,placedSide:T,placedAlign:U,onArrowChange:w,arrowX:H,arrowY:G,shouldHideArrow:W,children:e.jsx(yt.div,{"data-side":T,"data-align":U,...g,ref:j,style:{...g.style,animation:z?(Fe=g.style)==null?void 0:Fe.animation:"none"}})})})},"PopperContent"));function CD(t){return t!==null}Ul(CD,"isNotNull");var PU=Ul(t=>({name:"transformOrigin",options:t,fn(s){var g,N,b;const{placement:n,rects:a,middlewareData:r}=s,o=((g=r.arrow)==null?void 0:g.centerOffset)!==0,l=o?0:t.arrowWidth,c=o?0:t.arrowHeight,[u,p]=Gb(n),m={start:"0%",center:"50%",end:"100%"}[p],x=(((N=r.arrow)==null?void 0:N.x)??0)+l/2,h=(((b=r.arrow)==null?void 0:b.y)??0)+c/2;let y="",v="";return u==="bottom"?(y=o?m:`${x}px`,v=`${-c}px`):u==="top"?(y=o?m:`${x}px`,v=`${a.floating.height+c}px`):u==="right"?(y=`${-c}px`,v=o?m:`${h}px`):u==="left"&&(y=`${a.floating.width+c}px`,v=o?m:`${h}px`),{data:{x:y,y:v}}}}),"transformOrigin");function Gb(t){const[s,n="center"]=t.split("-");return[s,n]}Ul(Gb,"getSideAndAlignFromPlacement");var DU=CU,RU=EU,AD=TU,IU=Object.defineProperty,fa=(t,s)=>IU(t,"name",{value:s,configurable:!0}),[c5,Phe]=Va("Tooltip",[Hb]),$U=Hb(),zU="TooltipProvider",LU=700,xC="tooltip.open",[OU,MU]=c5(zU),BU=fa(t=>{const{__scopeTooltip:s,delayDuration:n=LU,skipDelayDuration:a=300,disableHoverableContent:r=!1,children:i}=t,o=d.useRef(!0),l=d.useRef(!1),c=d.useRef(0);return d.useEffect(()=>{const u=c.current;return()=>window.clearTimeout(u)},[]),e.jsx(OU,{scope:s,isOpenDelayedRef:o,delayDuration:n,onOpen:d.useCallback(()=>{a<=0||(window.clearTimeout(c.current),o.current=!1)},[a]),onClose:d.useCallback(()=>{a<=0||(window.clearTimeout(c.current),c.current=window.setTimeout(()=>o.current=!0,a))},[a]),isPointerInTransitRef:l,onPointerInTransitChange:d.useCallback(u=>{l.current=u},[]),disableHoverableContent:r,children:i})},"TooltipProvider"),UU="Tooltip",[Dhe,d5]=c5(UU),qU="TooltipPortal",[Rhe,WU]=c5(qU,{forceMount:void 0}),hx="TooltipContent",HU=d.forwardRef(fa(function(s,n){const a=WU(hx,s.__scopeTooltip),{forceMount:r=a.forceMount,side:i="top",...o}=s,l=d5(hx,s.__scopeTooltip);return e.jsx(ic,{present:r||l.open,children:l.disableHoverableContent?e.jsx(ED,{side:i,...o,ref:n}):e.jsx(GU,{side:i,...o,ref:n})})},"TooltipContent")),GU=d.forwardRef(fa(function(s,n){const a=d5(hx,s.__scopeTooltip),r=MU(hx,s.__scopeTooltip),i=d.useRef(null),o=It(n,i),[l,c]=d.useState(null),{trigger:u,onClose:p}=a,m=i.current,{onPointerInTransitChange:x}=r,h=d.useCallback(()=>{c(null),x(!1)},[x]),y=d.useCallback((v,g)=>{const N=v.currentTarget,b={x:v.clientX,y:v.clientY},f=FD(b,N.getBoundingClientRect()),j=TD(b,f),S=PD(g.getBoundingClientRect()),w=RD([...j,...S]);c(w),x(!0)},[x]);return d.useEffect(()=>()=>h(),[h]),d.useEffect(()=>{if(u&&m){const v=fa(N=>y(N,m),"handleTriggerLeave"),g=fa(N=>y(N,u),"handleContentLeave");return u.addEventListener("pointerleave",v),m.addEventListener("pointerleave",g),()=>{u.removeEventListener("pointerleave",v),m.removeEventListener("pointerleave",g)}}},[u,m,y,h]),d.useEffect(()=>{if(l){const v=fa(g=>{const N=g.target,b={x:g.clientX,y:g.clientY},f=(u==null?void 0:u.contains(N))||(m==null?void 0:m.contains(N)),j=!DD(b,l);f?h():j&&(h(),p())},"handleTrackPointerGrace");return document.addEventListener("pointermove",v),()=>document.removeEventListener("pointermove",v)}},[u,m,l,p,h]),e.jsx(ED,{...s,ref:o})},"TooltipContentHoverable")),VU=QT("TooltipContent"),ED=d.forwardRef(fa(function(s,n){const{__scopeTooltip:a,children:r,"aria-label":i,id:o,onEscapeKeyDown:l,onPointerDownOutside:c,...u}=s,p=d5(hx,a),m=$U(a),{onClose:x}=p;d.useEffect(()=>(document.addEventListener(xC,x),()=>document.removeEventListener(xC,x)),[x]),d.useEffect(()=>{if(p.trigger){const y=fa(v=>{v.target instanceof Node&&v.target.contains(p.trigger)&&x()},"handleScroll");return window.addEventListener("scroll",y,{capture:!0}),()=>window.removeEventListener("scroll",y,{capture:!0})}},[p.trigger,x]);const{setContentId:h}=p;return vs(()=>(h(o),()=>{h(void 0)}),[o,h]),e.jsx(Pb,{asChild:!0,disableOutsidePointerEvents:!1,onEscapeKeyDown:l,onPointerDownOutside:c,onFocusOutside:y=>y.preventDefault(),onDismiss:x,children:e.jsxs(AD,{"data-state":p.stateAttribute,role:i?void 0:"tooltip",id:i?void 0:p.contentId,...m,...u,ref:n,style:{...u.style,"--radix-tooltip-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-tooltip-content-available-width":"var(--radix-popper-available-width)","--radix-tooltip-content-available-height":"var(--radix-popper-available-height)","--radix-tooltip-trigger-width":"var(--radix-popper-anchor-width)","--radix-tooltip-trigger-height":"var(--radix-popper-anchor-height)"},children:[e.jsx(VU,{children:r}),i?e.jsx(M9,{id:p.contentId,role:"tooltip",children:i}):null]})})},"TooltipContentImpl"));function FD(t,s){const n=Math.abs(s.top-t.y),a=Math.abs(s.bottom-t.y),r=Math.abs(s.right-t.x),i=Math.abs(s.left-t.x);switch(Math.min(n,a,r,i)){case i:return"left";case r:return"right";case n:return"top";case a:return"bottom";default:throw new Error("unreachable")}}fa(FD,"getExitSideFromRect");function TD(t,s,n=5){const a=[];switch(s){case"top":a.push({x:t.x-n,y:t.y+n},{x:t.x+n,y:t.y+n});break;case"bottom":a.push({x:t.x-n,y:t.y-n},{x:t.x+n,y:t.y-n});break;case"left":a.push({x:t.x+n,y:t.y-n},{x:t.x+n,y:t.y+n});break;case"right":a.push({x:t.x-n,y:t.y-n},{x:t.x-n,y:t.y+n});break}return a}fa(TD,"getPaddedExitPoints");
1092function PD(t){const{top:s,right:n,bottom:a,left:r}=t;return[{x:r,y:s},{x:n,y:s},{x:n,y:a},{x:r,y:a}]}fa(PD,"getPointsFromRect");function DD(t,s){const{x:n,y:a}=t;let r=!1;for(let i=0,o=s.length-1;i<s.length;o=i++){const l=s[i],c=s[o],u=l.x,p=l.y,m=c.x,x=c.y;p>a!=x>a&&n<(m-u)*(a-p)/(x-p)+u&&(r=!r)}return r}fa(DD,"isPointInPolygon");function RD(t){const s=t.slice();return s.sort((n,a)=>n.x<a.x?-1:n.x>a.x?1:n.y<a.y?-1:n.y>a.y?1:0),ID(s)}fa(RD,"getHull");function ID(t){if(t.length<=1)return t.slice();const s=[];for(let a=0;a<t.length;a++){const r=t[a];for(;s.length>=2;){const i=s[s.length-1],o=s[s.length-2];if((i.x-o.x)*(r.y-o.y)>=(i.y-o.y)*(r.x-o.x))s.pop();else break}s.push(r)}s.pop();const n=[];for(let a=t.length-1;a>=0;a--){const r=t[a];for(;n.length>=2;){const i=n[n.length-1],o=n[n.length-2];if((i.x-o.x)*(r.y-o.y)>=(i.y-o.y)*(r.x-o.x))n.pop();else break}n.push(r)}return n.pop(),s.length===1&&n.length===1&&s[0].x===n[0].x&&s[0].y===n[0].y?s:s.concat(n)}fa(ID,"getHullPresorted");var ZU=BU,$D=HU;const YU=ZU,KU=d.forwardRef(({className:t,sideOffset:s=4,...n},a)=>e.jsx($D,{ref:a,sideOffset:s,className:et("z-50 overflow-hidden rounded-md border border-border/40 bg-popover px-3 py-1.5 text-sm text-popover-foreground shadow-lg animate-in fade-in-0 zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",t),...n}));KU.displayName=$D.displayName;var Vb=class{constructor(){this.listeners=new Set,this.subscribe=this.subscribe.bind(this)}subscribe(t){return this.listeners.add(t),this.onSubscribe(),()=>{this.listeners.delete(t),this.onUnsubscribe()}}hasListeners(){return this.listeners.size>0}onSubscribe(){}onUnsubscribe(){}},ld,wl,xm,jF,QU=(jF=class extends Vb{constructor(){super();St(this,ld);St(this,wl);St(this,xm);ct(this,xm,s=>{if(typeof window<"u"&&window.addEventListener){const n=()=>s();return window.addEventListener("visibilitychange",n,!1),()=>{window.removeEventListener("visibilitychange",n)}}})}onSubscribe(){he(this,wl)||this.setEventListener(he(this,xm))}onUnsubscribe(){var s;this.hasListeners()||((s=he(this,wl))==null||s.call(this),ct(this,wl,void 0))}setEventListener(s){var n;ct(this,xm,s),(n=he(this,wl))==null||n.call(this),ct(this,wl,s(a=>{typeof a=="boolean"?this.setFocused(a):this.onFocus()}))}setFocused(s){he(this,ld)!==s&&(ct(this,ld,s),this.onFocus())}onFocus(){const s=this.isFocused();this.listeners.forEach(n=>{n(s)})}isFocused(){var s;return typeof he(this,ld)=="boolean"?he(this,ld):((s=globalThis.document)==null?void 0:s.visibilityState)!=="hidden"}},ld=new WeakMap,wl=new WeakMap,xm=new WeakMap,jF),zD=new QU,JU={setTimeout:(t,s)=>setTimeout(t,s),clearTimeout:t=>clearTimeout(t),setInterval:(t,s)=>setInterval(t,s),clearInterval:t=>clearInterval(t)},Nl,UN,wF,XU=(wF=class{constructor(){St(this,Nl,JU);St(this,UN,!1)}setTimeoutProvider(t){ct(this,Nl,t)}setTimeout(t,s){return he(this,Nl).setTimeout(t,s)}clearTimeout(t){he(this,Nl).clearTimeout(t)}setInterval(t,s){return he(this,Nl).setInterval(t,s)}clearInterval(t){he(this,Nl).clearInterval(t)}},Nl=new WeakMap,UN=new WeakMap,wF),g2=new XU;function eq(t){setTimeout(t,0)}var tq=typeof window>"u"||"Deno"in globalThis;function Ur(){}function sq(t,s){return typeof t=="function"?t(s):t}function nq(t){return typeof t=="number"&&t>=0&&t!==1/0}function aq(t,s){return Math.max(t+(s||0)-Date.now(),0)}function y2(t,s){return typeof t=="function"?t(s):t}function rq(t,s){return typeof t=="function"?t(s):t}function fC(t,s){const{type:n="all",exact:a,fetchStatus:r,predicate:i,queryKey:o,stale:l}=t;if(o){if(a){if(s.queryHash!==u5(o,s.options))return!1}else if(!Dm(s.queryKey,o))return!1}if(n!=="all"){const c=s.isActive();if(n==="active"&&!c||n==="inactive"&&c)return!1}return!(typeof l=="boolean"&&s.isStale()!==l||r&&r!==s.state.fetchStatus||i&&!i(s))}function gC(t,s){const{exact:n,status:a,predicate:r,mutationKey:i}=t;if(i){if(!s.options.mutationKey)return!1;if(n){if(xx(s.options.mutationKey)!==xx(i))return!1}else if(!Dm(s.options.mutationKey,i))return!1}return!(a&&s.state.status!==a||r&&!r(s))}function u5(t,s){return((s==null?void 0:s.queryKeyHashFn)||xx)(t)}function xx(t){return JSON.stringify(t,(s,n)=>b2(n)?Object.keys(n).sort().reduce((a,r)=>(a[r]=n[r],a),{}):n)}function Dm(t,s){if(t===s)return!0;
1092if(typeof t!=typeof s)return!1;if(t&&s&&typeof t=="object"&&typeof s=="object"){if(Array.isArray(t)&&Array.isArray(s)){for(let a=0;a<s.length;a++)if(!Dm(t[a],s[a]))return!1;return!0}const n=Object.keys(s);for(const a of n)if(!Dm(t[a],s[a]))return!1;return!0}return!1}var iq=Object.prototype.hasOwnProperty;function LD(t,s,n=0){if(t===s)return t;if(n>500)return s;const a=yC(t)&&yC(s);if(!a&&!(b2(t)&&b2(s)))return s;const i=(a?t:Object.keys(t)).length,o=a?s:Object.keys(s),l=o.length,c=a?new Array(l):{};let u=0;for(let p=0;p<l;p++){const m=a?p:o[p],x=t[m],h=s[m];if(x===h){c[m]=x,(a?p<i:iq.call(t,m))&&u++;continue}if(x===null||h===null||typeof x!="object"||typeof h!="object"){c[m]=h;continue}const y=LD(x,h,n+1);c[m]=y,y===x&&u++}return i===l&&u===i?t:c}function yC(t){return Array.isArray(t)&&t.length===Object.keys(t).length}function b2(t){if(!bC(t))return!1;const s=t.constructor;if(s===void 0)return!0;const n=s.prototype;return!(!bC(n)||!n.hasOwnProperty("isPrototypeOf")||Object.getPrototypeOf(t)!==Object.prototype)}function bC(t){return Object.prototype.toString.call(t)==="[object Object]"}function oq(t){return new Promise(s=>{g2.setTimeout(s,t)})}function lq(t,s,n){return typeof n.structuralSharing=="function"?n.structuralSharing(t,s):n.structuralSharing!==!1?LD(t,s):s}function cq(t,s,n=0){const a=[...t,s];return n&&a.length>n?a.slice(1):a}function dq(t,s,n=0){const a=[s,...t];return n&&a.length>n?a.slice(0,-1):a}var m5=Symbol();function OD(t,s){return!t.queryFn&&(s!=null&&s.initialPromise)?()=>s.initialPromise:!t.queryFn||t.queryFn===m5?()=>Promise.reject(new Error(`Missing queryFn: '${t.queryHash}'`)):t.queryFn}function uq(t,s,n){let a=!1,r;return Object.defineProperty(t,"signal",{enumerable:!0,get:()=>(r??(r=s()),a||(a=!0,r.aborted?n():r.addEventListener("abort",n,{once:!0})),r)}),t}var MD=(()=>{let t=()=>tq;return{isServer(){return t()},setIsServer(s){t=s}}})();function mq(){let t,s;const n=new Promise((r,i)=>{t=r,s=i});n.status="pending",n.catch(()=>{});function a(r){Object.assign(n,r),delete n.resolve,delete n.reject}return n.resolve=r=>{a({status:"fulfilled",value:r}),t(r)},n.reject=r=>{a({status:"rejected",reason:r}),s(r)},n}var pq=eq;function hq(){let t=[],s=0,n=l=>{l()},a=l=>{l()},r=pq;const i=l=>{s?t.push(l):r(()=>{n(l)})},o=()=>{const l=t;t=[],l.length&&r(()=>{a(()=>{l.forEach(c=>{n(c)})})})};return{batch:l=>{let c;s++;try{c=l()}finally{s--,s||o()}return c},batchCalls:l=>(...c)=>{i(()=>{l(...c)})},schedule:i,setNotifyFunction:l=>{n=l},setBatchNotifyFunction:l=>{a=l},setScheduler:l=>{r=l}}}var Yn=hq(),fm,_l,gm,NF,xq=(NF=class extends Vb{constructor(){super();St(this,fm,!0);St(this,_l);St(this,gm);ct(this,gm,s=>{if(typeof window<"u"&&window.addEventListener){const n=()=>s(!0),a=()=>s(!1);return window.addEventListener("online",n,!1),window.addEventListener("offline",a,!1),()=>{window.removeEventListener("online",n),window.removeEventListener("offline",a)}}})}onSubscribe(){he(this,_l)||this.setEventListener(he(this,gm))}onUnsubscribe(){var s;this.hasListeners()||((s=he(this,_l))==null||s.call(this),ct(this,_l,void 0))}setEventListener(s){var n;ct(this,gm,s),(n=he(this,_l))==null||n.call(this),ct(this,_l,s(this.setOnline.bind(this)))}setOnline(s){he(this,fm)!==s&&(ct(this,fm,s),this.listeners.forEach(a=>{a(s)}))}isOnline(){return he(this,fm)}},fm=new WeakMap,_l=new WeakMap,gm=new WeakMap,NF),Ry=new xq;function fq(t){return Math.min(1e3*2**t,3e4)}function BD(t){return(t??"online")==="online"?Ry.isOnline():!0}var v2=class extends Error{constructor(t){super("CancelledError"),this.revert=t==null?void 0:t.revert,this.silent=t==null?void 0:t.silent}};function UD(t){let s=!1,n=0,a;const r=mq(),i=()=>r.status!=="pending",o=v=>{var g;if(!i()){const N=new v2(v);x(N),(g=t.onCancel)==null||g.call(t,N)}},l=()=>{s=!0},c=()=>{s=!1},u=()=>zD.isFocused()&&(t.networkMode==="always"||Ry.isOnline())&&t.canRun(),p=()=>BD(t.networkMode)&&t.canRun(),m=v=>{i()||(a==null||a(),r.resolve(v))},x=v=>{i()||(a==null||a(),r.reject(v))},h=()=>new Promise(v=>{var g;a=N=>{(i()||u())&&v(N)},(g=t.onPause)==null||g.call(t)}).then(()=>{var v;a=void 0,i()||(v=t.onContinue)==null||v.call(t)}),y=()=>
1092{if(i())return;let v;const g=n===0?t.initialPromise:void 0;try{v=g??t.fn()}catch(N){v=Promise.reject(N)}Promise.resolve(v).then(m).catch(N=>{var w;if(i())return;const b=t.retry??(MD.isServer()?0:3),f=t.retryDelay??fq,j=typeof f=="function"?f(n,N):f,S=b===!0||typeof b=="number"&&n<b||typeof b=="function"&&b(n,N);if(s||!S){x(N);return}n++,(w=t.onFail)==null||w.call(t,n,N),oq(j).then(()=>u()?void 0:h()).then(()=>{s?x(N):y()})})};return{promise:r,status:()=>r.status,cancel:o,continue:()=>(a==null||a(),r),cancelRetry:l,continueRetry:c,canStart:p,start:()=>(p()?y():h().then(y),r)}}var cd,_F,qD=(_F=class{constructor(){St(this,cd)}destroy(){this.clearGcTimeout()}scheduleGc(){this.clearGcTimeout(),nq(this.gcTime)&&ct(this,cd,g2.setTimeout(()=>{this.optionalRemove()},this.gcTime))}updateGcTime(t){this.gcTime=Math.max(this.gcTime||0,t??(MD.isServer()?1/0:5*60*1e3))}clearGcTimeout(){he(this,cd)!==void 0&&(g2.clearTimeout(he(this,cd)),ct(this,cd,void 0))}},cd=new WeakMap,_F);function gq(t){return{onFetch:(s,n)=>{var p,m,x,h,y;const a=s.options,r=(x=(m=(p=s.fetchOptions)==null?void 0:p.meta)==null?void 0:m.fetchMore)==null?void 0:x.direction,i=((h=s.state.data)==null?void 0:h.pages)||[],o=((y=s.state.data)==null?void 0:y.pageParams)||[];let l={pages:[],pageParams:[]},c=0;const u=async()=>{let v=!1;const g=f=>{uq(f,()=>s.signal,()=>v=!0)},N=OD(s.options,s.fetchOptions),b=async(f,j,S)=>{if(v)return Promise.reject(s.signal.reason);if(j==null&&f.pages.length)return Promise.resolve(f);const _=(()=>{const F={client:s.client,queryKey:s.queryKey,pageParam:j,direction:S?"backward":"forward",meta:s.options.meta};return g(F),F})(),C=await N(_),{maxPages:E}=s.options,P=S?dq:cq;return{pages:P(f.pages,C,E),pageParams:P(f.pageParams,j,E)}};if(r&&i.length){const f=r==="backward",j=f?yq:vC,S={pages:i,pageParams:o},w=j(a,S);l=await b(S,w,f)}else{const f=t??i.length;do{const j=c===0?o[0]??a.initialPageParam:vC(a,l);if(c>0&&j==null)break;l=await b(l,j),c++}while(c<f)}return l};s.options.persister?s.fetchFn=()=>{var v,g;return(g=(v=s.options).persister)==null?void 0:g.call(v,u,{client:s.client,queryKey:s.queryKey,meta:s.options.meta,signal:s.signal},n)}:s.fetchFn=u}}}function vC(t,{pages:s,pageParams:n}){const a=s.length-1;return s.length>0?t.getNextPageParam(s[a],s,n[a],n):void 0}function yq(t,{pages:s,pageParams:n}){var a;return s.length>0?(a=t.getPreviousPageParam)==null?void 0:a.call(t,s[0],s,n[0],n):void 0}var ym,dd,bm,dr,ud,ln,Ox,md,Ra,WD,so,kF,bq=(kF=class extends qD{constructor(s){super();St(this,Ra);St(this,ym);St(this,dd);St(this,bm);St(this,dr);St(this,ud);St(this,ln);St(this,Ox);St(this,md);ct(this,md,!1),ct(this,Ox,s.defaultOptions),this.setOptions(s.options),this.observers=[],ct(this,ud,s.client),ct(this,dr,he(this,ud).getQueryCache()),this.queryKey=s.queryKey,this.queryHash=s.queryHash,ct(this,dd,wC(this.options)),this.state=s.state??he(this,dd),this.scheduleGc()}get meta(){return this.options.meta}get queryType(){return he(this,ym)}get promise(){var s;return(s=he(this,ln))==null?void 0:s.promise}setOptions(s){if(this.options={...he(this,Ox),...s},s!=null&&s._type&&ct(this,ym,s._type),this.updateGcTime(this.options.gcTime),this.state&&this.state.data===void 0){const n=wC(this.options);n.data!==void 0&&(this.setState(jC(n.data,n.dataUpdatedAt)),ct(this,dd,n))}}optionalRemove(){!this.observers.length&&this.state.fetchStatus==="idle"&&he(this,dr).remove(this)}setData(s,n){const a=lq(this.state.data,s,this.options);return pn(this,Ra,so).call(this,{data:a,type:"success",dataUpdatedAt:n==null?void 0:n.updatedAt,manual:n==null?void 0:n.manual}),a}setState(s){pn(this,Ra,so).call(this,{type:"setState",state:s})}cancel(s){var a,r;const n=(a=he(this,ln))==null?void 0:a.promise;return(r=he(this,ln))==null||r.cancel(s),n?n.then(Ur).catch(Ur):Promise.resolve()}destroy(){super.destroy(),this.cancel({silent:!0})}get resetState(){return he(this,dd)}reset(){this.destroy(),this.setState(this.resetState)}isActive(){return this.observers.some(s=>rq(s.options.enabled,this)!==!1)}isDisabled(){return this.getObserversCount()>0?!this.isActive():this.options.queryFn===m5||!this.isFetched()}isFetched(){return this.state.dataUpdateCount+this.state.errorUpdate
1092Count>0}isStatic(){return this.getObserversCount()>0?this.observers.some(s=>y2(s.options.staleTime,this)==="static"):!1}isStale(){return this.getObserversCount()>0?this.observers.some(s=>s.getCurrentResult().isStale):this.state.data===void 0||this.state.isInvalidated}isStaleByTime(s=0){return this.state.data===void 0?!0:s==="static"?!1:this.state.isInvalidated?!0:!aq(this.state.dataUpdatedAt,s)}onFocus(){var n;const s=this.observers.find(a=>a.shouldFetchOnWindowFocus());s==null||s.refetch({cancelRefetch:!1}),(n=he(this,ln))==null||n.continue()}onOnline(){var n;const s=this.observers.find(a=>a.shouldFetchOnReconnect());s==null||s.refetch({cancelRefetch:!1}),(n=he(this,ln))==null||n.continue()}addObserver(s){this.observers.includes(s)||(this.observers.push(s),this.clearGcTimeout(),he(this,dr).notify({type:"observerAdded",query:this,observer:s}))}removeObserver(s){this.observers.includes(s)&&(this.observers=this.observers.filter(n=>n!==s),this.observers.length||(he(this,ln)&&(he(this,md)||pn(this,Ra,WD).call(this)?he(this,ln).cancel({revert:!0}):he(this,ln).cancelRetry()),this.scheduleGc()),he(this,dr).notify({type:"observerRemoved",query:this,observer:s}))}getObserversCount(){return this.observers.length}invalidate(){this.state.isInvalidated||pn(this,Ra,so).call(this,{type:"invalidate"})}async fetch(s,n){var u,p,m,x,h,y,v,g,N,b,f;if(this.state.fetchStatus!=="idle"&&((u=he(this,ln))==null?void 0:u.status())!=="rejected"){if(this.state.data!==void 0&&(n!=null&&n.cancelRefetch))this.cancel({silent:!0});else if(he(this,ln))return he(this,ln).continueRetry(),he(this,ln).promise}if(s&&this.setOptions(s),!this.options.queryFn){const j=this.observers.find(S=>S.options.queryFn);j&&this.setOptions(j.options)}const a=new AbortController,r=j=>{Object.defineProperty(j,"signal",{enumerable:!0,get:()=>(ct(this,md,!0),a.signal)})},i=()=>{const j=OD(this.options,n),w=(()=>{const _={client:he(this,ud),queryKey:this.queryKey,meta:this.meta};return r(_),_})();return ct(this,md,!1),this.options.persister?this.options.persister(j,w,this):j(w)},l=(()=>{const j={fetchOptions:n,options:this.options,queryKey:this.queryKey,client:he(this,ud),state:this.state,fetchFn:i};return r(j),j})(),c=he(this,ym)==="infinite"?gq(this.options.pages):this.options.behavior;c==null||c.onFetch(l,this),ct(this,bm,this.state),(this.state.fetchStatus==="idle"||this.state.fetchMeta!==((p=l.fetchOptions)==null?void 0:p.meta))&&pn(this,Ra,so).call(this,{type:"fetch",meta:(m=l.fetchOptions)==null?void 0:m.meta}),ct(this,ln,UD({initialPromise:n==null?void 0:n.initialPromise,fn:l.fetchFn,onCancel:j=>{j instanceof v2&&j.revert&&this.setState({...he(this,bm),fetchStatus:"idle"}),a.abort()},onFail:(j,S)=>{pn(this,Ra,so).call(this,{type:"failed",failureCount:j,error:S})},onPause:()=>{pn(this,Ra,so).call(this,{type:"pause"})},onContinue:()=>{pn(this,Ra,so).call(this,{type:"continue"})},retry:l.options.retry,retryDelay:l.options.retryDelay,networkMode:l.options.networkMode,canRun:()=>!0}));try{const j=await he(this,ln).start();if(j===void 0)throw new Error(`${this.queryHash} data is undefined`);return this.setData(j),(h=(x=he(this,dr).config).onSuccess)==null||h.call(x,j,this),(v=(y=he(this,dr).config).onSettled)==null||v.call(y,j,this.state.error,this),j}catch(j){if(j instanceof v2){if(j.silent)return he(this,ln).promise;if(j.revert){if(this.state.data===void 0)throw j;return this.state.data}}throw pn(this,Ra,so).call(this,{type:"error",error:j}),(N=(g=he(this,dr).config).onError)==null||N.call(g,j,this),(f=(b=he(this,dr).config).onSettled)==null||f.call(b,this.state.data,j,this),j}finally{this.scheduleGc()}}},ym=new WeakMap,dd=new WeakMap,bm=new WeakMap,dr=new WeakMap,ud=new WeakMap,ln=new WeakMap,Ox=new WeakMap,md=new WeakMap,Ra=new WeakSet,WD=function(){return this.state.fetchStatus==="paused"&&this.state.status==="pending"},so=function(s){const n=a=>{switch(s.type){case"failed":return{...a,fetchFailureCount:s.failureCount,fetchFailureReason:s.error};case"pause":return{...a,fetchStatus:"paused"};case"continue":return{...a,fetchStatus:"fetching"};case"fetch":return{...a,...vq(a.data,this.options),fetchMeta:s.meta??null};case"success":const r={...a,...jC(s.data,s.dataUpdatedAt),dataUpdateCount:a.dataUpdateCount+1,...!s.manual&&{fetchStatus:"idle",fetchFailureCount:0,fetchFailureReason:null}};return ct(this,bm,s.manual?r:void 0),r;case"error":const i=s.error;
1092return{...a,error:i,errorUpdateCount:a.errorUpdateCount+1,errorUpdatedAt:Date.now(),fetchFailureCount:a.fetchFailureCount+1,fetchFailureReason:i,fetchStatus:"idle",status:"error",isInvalidated:!0};case"invalidate":return{...a,isInvalidated:!0};case"setState":return{...a,...s.state}}};this.state=n(this.state),Yn.batch(()=>{this.observers.forEach(a=>{a.onQueryUpdate()}),he(this,dr).notify({query:this,type:"updated",action:s})})},kF);function vq(t,s){return{fetchFailureCount:0,fetchFailureReason:null,fetchStatus:BD(s.networkMode)?"fetching":"paused",...t===void 0&&{error:null,status:"pending"}}}function jC(t,s){return{data:t,dataUpdatedAt:s??Date.now(),error:null,isInvalidated:!1,status:"success"}}function wC(t){const s=typeof t.initialData=="function"?t.initialData():t.initialData,n=s!==void 0,a=n?typeof t.initialDataUpdatedAt=="function"?t.initialDataUpdatedAt():t.initialDataUpdatedAt:0;return{data:s,dataUpdateCount:0,dataUpdatedAt:n?a??Date.now():0,error:null,errorUpdateCount:0,errorUpdatedAt:0,fetchFailureCount:0,fetchFailureReason:null,fetchMeta:null,isInvalidated:!1,status:n?"success":"pending",fetchStatus:"idle"}}var Mx,ji,Pn,pd,wi,ul,SF,jq=(SF=class extends qD{constructor(s){super();St(this,wi);St(this,Mx);St(this,ji);St(this,Pn);St(this,pd);ct(this,Mx,s.client),this.mutationId=s.mutationId,ct(this,Pn,s.mutationCache),ct(this,ji,[]),this.state=s.state||wq(),this.setOptions(s.options),this.scheduleGc()}setOptions(s){this.options=s,this.updateGcTime(this.options.gcTime)}get meta(){return this.options.meta}addObserver(s){he(this,ji).includes(s)||(he(this,ji).push(s),this.clearGcTimeout(),he(this,Pn).notify({type:"observerAdded",mutation:this,observer:s}))}removeObserver(s){ct(this,ji,he(this,ji).filter(n=>n!==s)),this.scheduleGc(),he(this,Pn).notify({type:"observerRemoved",mutation:this,observer:s})}optionalRemove(){he(this,ji).length||(this.state.status==="pending"?this.scheduleGc():he(this,Pn).remove(this))}continue(){var s;return((s=he(this,pd))==null?void 0:s.continue())??this.execute(this.state.variables)}async execute(s){var o,l,c,u,p,m,x,h,y,v,g,N,b,f,j,S,w,_;const n=()=>{pn(this,wi,ul).call(this,{type:"continue"})},a={client:he(this,Mx),meta:this.options.meta,mutationKey:this.options.mutationKey};ct(this,pd,UD({fn:()=>this.options.mutationFn?this.options.mutationFn(s,a):Promise.reject(new Error("No mutationFn found")),onFail:(C,E)=>{pn(this,wi,ul).call(this,{type:"failed",failureCount:C,error:E})},onPause:()=>{pn(this,wi,ul).call(this,{type:"pause"})},onContinue:n,retry:this.options.retry??0,retryDelay:this.options.retryDelay,networkMode:this.options.networkMode,canRun:()=>he(this,Pn).canRun(this)}));const r=this.state.status==="pending",i=!he(this,pd).canStart();try{if(r)n();else{pn(this,wi,ul).call(this,{type:"pending",variables:s,isPaused:i}),he(this,Pn).config.onMutate&&await he(this,Pn).config.onMutate(s,this,a);const E=await((l=(o=this.options).onMutate)==null?void 0:l.call(o,s,a));E!==this.state.context&&pn(this,wi,ul).call(this,{type:"pending",context:E,variables:s,isPaused:i})}const C=await he(this,pd).start();return await((u=(c=he(this,Pn).config).onSuccess)==null?void 0:u.call(c,C,s,this.state.context,this,a)),await((m=(p=this.options).onSuccess)==null?void 0:m.call(p,C,s,this.state.context,a)),await((h=(x=he(this,Pn).config).onSettled)==null?void 0:h.call(x,C,null,this.state.variables,this.state.context,this,a)),await((v=(y=this.options).onSettled)==null?void 0:v.call(y,C,null,s,this.state.context,a)),pn(this,wi,ul).call(this,{type:"success",data:C}),C}catch(C){try{await((N=(g=he(this,Pn).config).onError)==null?void 0:N.call(g,C,s,this.state.context,this,a))}catch(E){Promise.reject(E)}try{await((f=(b=this.options).onError)==null?void 0:f.call(b,C,s,this.state.context,a))}catch(E){Promise.reject(E)}try{await((S=(j=he(this,Pn).config).onSettled)==null?void 0:S.call(j,void 0,C,this.state.variables,this.state.context,this,a))}catch(E){Promise.reject(E)}try{await((_=(w=this.options).onSettled)==null?void 0:_.call(w,void 0,C,s,this.state.context,a))}catch(E){Promise.reject(E)}throw pn(this,wi,ul).call(this,{type:"error",error:C}),C}finally{he(this,Pn).runNext(this)}}},Mx=new WeakMap,ji=new WeakMap,Pn=new WeakMap,pd=new WeakMap,wi=new WeakSet,ul=function(s){const n=a=>{switch(s.type){case"failed":return{...a,failureCount:s.failureCount,failureReason:s.error};case"pause":return{...a,isPaused:!0};case"continue":return{...a,isPaused:!1};
1092case"pending":return{...a,context:s.context,data:void 0,failureCount:0,failureReason:null,error:null,isPaused:s.isPaused,status:"pending",variables:s.variables,submittedAt:Date.now()};case"success":return{...a,data:s.data,failureCount:0,failureReason:null,error:null,status:"success",isPaused:!1};case"error":return{...a,data:void 0,error:s.error,failureCount:a.failureCount+1,failureReason:s.error,isPaused:!1,status:"error"}}};this.state=n(this.state),Yn.batch(()=>{he(this,ji).forEach(a=>{a.onMutationUpdate(s)}),he(this,Pn).notify({mutation:this,type:"updated",action:s})})},SF);function wq(){return{context:void 0,data:void 0,error:null,failureCount:0,failureReason:null,isPaused:!1,status:"idle",variables:void 0,submittedAt:0}}var po,Wr,Bx,CF,Nq=(CF=class extends Vb{constructor(s={}){super();St(this,po);St(this,Wr);St(this,Bx);this.config=s,ct(this,po,new Set),ct(this,Wr,new Map),ct(this,Bx,0)}build(s,n,a){const r=new jq({client:s,mutationCache:this,mutationId:++uf(this,Bx)._,options:s.defaultMutationOptions(n),state:a});return this.add(r),r}add(s){he(this,po).add(s);const n=Pf(s);if(typeof n=="string"){const a=he(this,Wr).get(n);a?a.push(s):he(this,Wr).set(n,[s])}this.notify({type:"added",mutation:s})}remove(s){if(he(this,po).delete(s)){const n=Pf(s);if(typeof n=="string"){const a=he(this,Wr).get(n);if(a)if(a.length>1){const r=a.indexOf(s);r!==-1&&a.splice(r,1)}else a[0]===s&&he(this,Wr).delete(n)}}this.notify({type:"removed",mutation:s})}canRun(s){const n=Pf(s);if(typeof n=="string"){const a=he(this,Wr).get(n),r=a==null?void 0:a.find(i=>i.state.status==="pending");return!r||r===s}else return!0}runNext(s){var a;const n=Pf(s);if(typeof n=="string"){const r=(a=he(this,Wr).get(n))==null?void 0:a.find(i=>i!==s&&i.state.isPaused);return(r==null?void 0:r.continue())??Promise.resolve()}else return Promise.resolve()}clear(){Yn.batch(()=>{he(this,po).forEach(s=>{this.notify({type:"removed",mutation:s})}),he(this,po).clear(),he(this,Wr).clear()})}getAll(){return Array.from(he(this,po))}find(s){const n={exact:!0,...s};return this.getAll().find(a=>gC(n,a))}findAll(s={}){return this.getAll().filter(n=>gC(s,n))}notify(s){Yn.batch(()=>{this.listeners.forEach(n=>{n(s)})})}resumePausedMutations(){const s=this.getAll().filter(n=>n.state.isPaused);return Yn.batch(()=>Promise.all(s.map(n=>n.continue().catch(Ur))))}},po=new WeakMap,Wr=new WeakMap,Bx=new WeakMap,CF);function Pf(t){var s;return(s=t.options.scope)==null?void 0:s.id}var Ni,AF,_q=(AF=class extends Vb{constructor(s={}){super();St(this,Ni);this.config=s,ct(this,Ni,new Map)}build(s,n,a){const r=n.queryKey,i=n.queryHash??u5(r,n);let o=this.get(i);return o||(o=new bq({client:s,queryKey:r,queryHash:i,options:s.defaultQueryOptions(n),state:a,defaultOptions:s.getQueryDefaults(r)}),this.add(o)),o}add(s){he(this,Ni).has(s.queryHash)||(he(this,Ni).set(s.queryHash,s),this.notify({type:"added",query:s}))}remove(s){const n=he(this,Ni).get(s.queryHash);n&&(s.destroy(),n===s&&he(this,Ni).delete(s.queryHash),this.notify({type:"removed",query:s}))}clear(){Yn.batch(()=>{this.getAll().forEach(s=>{this.remove(s)})})}get(s){return he(this,Ni).get(s)}getAll(){return[...he(this,Ni).values()]}find(s){const n={exact:!0,...s};return this.getAll().find(a=>fC(n,a))}findAll(s={}){const n=this.getAll();return Object.keys(s).length>0?n.filter(a=>fC(s,a)):n}notify(s){Yn.batch(()=>{this.listeners.forEach(n=>{n(s)})})}onFocus(){Yn.batch(()=>{this.getAll().forEach(s=>{s.onFocus()})})}onOnline(){Yn.batch(()=>{this.getAll().forEach(s=>{s.onOnline()})})}},Ni=new WeakMap,AF),Ns,kl,Sl,vm,jm,Cl,wm,Nm,EF,kq=(EF=class{constructor(t={}){St(this,Ns);St(this,kl);St(this,Sl);St(this,vm);St(this,jm);St(this,Cl);St(this,wm);St(this,Nm);ct(this,Ns,t.queryCache||new _q),ct(this,kl,t.mutationCache||new Nq),ct(this,Sl,t.defaultOptions||{}),ct(this,vm,new Map),ct(this,jm,new Map),ct(this,Cl,0)}mount(){uf(this,Cl)._++,he(this,Cl)===1&&(ct(this,wm,zD.subscribe(async t=>{t&&(await this.resumePausedMutations(),he(this,Ns).onFocus())})),ct(this,Nm,Ry.subscribe(async t=>{t&&(await this.resumePausedMutations(),he(this,Ns).onOnline())})))}unmount(){var t,s;uf(this,Cl)._--,he(this,Cl)===0&&((t=he(this,wm))==null||t.call(this),ct(this,wm,void 0),(s=he(this,Nm))==null||s.call(this),ct(this,Nm,void 0))}isFetching(t){return he(this,Ns).findAll({...t,fetchStatus:"fetching"}).length}isMutating(t){return he(this,kl).findAll({...t,status:"pending"}).length}getQueryData(t){var n;const s=this.defaultQueryOptions({queryKey:t});return(n=he(this,Ns).get(s.queryHash))==null?void 0:n.state.data}ensureQueryData(t){const s=this.defaultQueryOptions(t),n=he(this,Ns).build(this,s),a=n.state.data;return a===void 0?this.fetchQuery(t):(t.revalidateIfStale&&n.isStaleByTime(y2(s.staleTime,n))&&this.prefetchQuery(s),Promise.resolve(a))}getQueriesData(t){return he(this,Ns).findAll(t).map(({queryKey:s,state:n})=>{const a=n.data;return[s,a]})}setQueryData(t,s,n){const a=this.defaultQueryOptions({queryKey:t}),r=he(this,Ns).get(a.queryHash),i=r==null?void 0:r.state.data,o=sq(s,i);if(o!==void 0)return he(this,Ns).build(this,a).setData(o,{...n,manual:!0})}
1092setQueriesData(t,s,n){return Yn.batch(()=>he(this,Ns).findAll(t).map(({queryKey:a})=>[a,this.setQueryData(a,s,n)]))}getQueryState(t){var n;const s=this.defaultQueryOptions({queryKey:t});return(n=he(this,Ns).get(s.queryHash))==null?void 0:n.state}removeQueries(t){const s=he(this,Ns);Yn.batch(()=>{s.findAll(t).forEach(n=>{s.remove(n)})})}resetQueries(t,s){const n=he(this,Ns);return Yn.batch(()=>(n.findAll(t).forEach(a=>{a.reset()}),this.refetchQueries({type:"active",...t},s)))}cancelQueries(t,s={}){const n={revert:!0,...s},a=Yn.batch(()=>he(this,Ns).findAll(t).map(r=>r.cancel(n)));return Promise.all(a).then(Ur).catch(Ur)}invalidateQueries(t,s={}){return Yn.batch(()=>(he(this,Ns).findAll(t).forEach(n=>{n.invalidate()}),(t==null?void 0:t.refetchType)==="none"?Promise.resolve():this.refetchQueries({...t,type:(t==null?void 0:t.refetchType)??(t==null?void 0:t.type)??"active"},s)))}refetchQueries(t,s={}){const n={...s,cancelRefetch:s.cancelRefetch??!0},a=Yn.batch(()=>he(this,Ns).findAll(t).filter(r=>!r.isDisabled()&&!r.isStatic()).map(r=>{let i=r.fetch(void 0,n);return n.throwOnError||(i=i.catch(Ur)),r.state.fetchStatus==="paused"?Promise.resolve():i}));return Promise.all(a).then(Ur)}fetchQuery(t){const s=this.defaultQueryOptions(t);s.retry===void 0&&(s.retry=!1);const n=he(this,Ns).build(this,s);return n.isStaleByTime(y2(s.staleTime,n))?n.fetch(s):Promise.resolve(n.state.data)}prefetchQuery(t){return this.fetchQuery(t).then(Ur).catch(Ur)}fetchInfiniteQuery(t){return t._type="infinite",this.fetchQuery(t)}prefetchInfiniteQuery(t){return this.fetchInfiniteQuery(t).then(Ur).catch(Ur)}ensureInfiniteQueryData(t){return t._type="infinite",this.ensureQueryData(t)}resumePausedMutations(){return Ry.isOnline()?he(this,kl).resumePausedMutations():Promise.resolve()}getQueryCache(){return he(this,Ns)}getMutationCache(){return he(this,kl)}getDefaultOptions(){return he(this,Sl)}setDefaultOptions(t){ct(this,Sl,t)}setQueryDefaults(t,s){he(this,vm).set(xx(t),{queryKey:t,defaultOptions:s})}getQueryDefaults(t){const s=[...he(this,vm).values()],n={};return s.forEach(a=>{Dm(t,a.queryKey)&&Object.assign(n,a.defaultOptions)}),n}setMutationDefaults(t,s){he(this,jm).set(xx(t),{mutationKey:t,defaultOptions:s})}getMutationDefaults(t){const s=[...he(this,jm).values()],n={};return s.forEach(a=>{Dm(t,a.mutationKey)&&Object.assign(n,a.defaultOptions)}),n}defaultQueryOptions(t){if(t._defaulted)return t;const s={...he(this,Sl).queries,...this.getQueryDefaults(t.queryKey),...t,_defaulted:!0};return s.queryHash||(s.queryHash=u5(s.queryKey,s)),s.refetchOnReconnect===void 0&&(s.refetchOnReconnect=s.networkMode!=="always"),s.throwOnError===void 0&&(s.throwOnError=!!s.suspense),!s.networkMode&&s.persister&&(s.networkMode="offlineFirst"),s.queryFn===m5&&(s.enabled=!1),s}defaultMutationOptions(t){return t!=null&&t._defaulted?t:{...he(this,Sl).mutations,...(t==null?void 0:t.mutationKey)&&this.getMutationDefaults(t.mutationKey),...t,_defaulted:!0}}clear(){he(this,Ns).clear(),he(this,kl).clear()}},Ns=new WeakMap,kl=new WeakMap,Sl=new WeakMap,vm=new WeakMap,jm=new WeakMap,Cl=new WeakMap,wm=new WeakMap,Nm=new WeakMap,EF),Sq=d.createContext(void 0),Cq=({client:t,children:s})=>(d.useEffect(()=>(t.mount(),()=>{t.unmount()}),[t]),e.jsx(Sq.Provider,{value:t,children:s}));/** 1093 * @remix-run/router v1.23.4 1094 * 1095 * Copyright (c) Remix Software Inc. 1096 * 1097 * This source code is licensed under the MIT license found in the 1098 * LICENSE.md file in the root directory of this source tree. 1099 * 1100 * @license MIT 1101 */function fx(){return fx=Object.assign?Object.assign.bind():function(t){for(var s=1;s<arguments.length;s++){var n=arguments[s];for(var a in n)({}).hasOwnProperty.call(n,a)&&(t[a]=n[a])}return t},fx.apply(null,arguments)}var Fl;(function(t){t.Pop="POP",t.Push="PUSH",t.Replace="REPLACE"})(Fl||(Fl={}));const NC="popstate";function Aq(t){t===void 0&&(t={});function s(a,r){let{pathname:i,search:o,hash:l}=a.location;return j2("",{pathname:i,search:o,hash:l},r.state&&r.state.usr||null,r.state&&r.state.key||"default")}function n(a,r){return typeof r=="string"?r:Iy(r)}return Fq(s,n,null,t)}function $s(t,s){if(t===!1||t===null||typeof t>"u")throw new Error(s)}function HD(t,s){if(!t){typeof console<"u"&&console.warn(s);try{throw new Error(s)}catch{}}}function Eq(){return Math.random().toString(36).substr(2,8)}function _C(t,s){return{usr:t.state,key:t.key,idx:s}}function j2(t,s,n,a){return n===void 0&&(n=null),fx({pathname:typeof t=="string"?t:t.pathname,search:"",hash:""},typeof s=="string"?Xm(s):s,{state:n,key:s&&s.key||a||Eq()})}function Iy(t){let{pathname:s="/",search:n="",hash:a=""}=t;return n&&n!=="?"&&(s+=n.charAt(0)==="?"?n:"?"+n),a&&a!=="#"&&(s+=a.charAt(0)==="#"?a:"#"+a),s}function Xm(t){let s={};if(t){let n=t.indexOf("#");n>=0&&(s.hash=t.substr(n),t=t.substr(0,n));let a=t.indexOf("?");a>=0&&(s.search=t.substr(a),t=t.substr(0,a)),t&&(s.pathname=t)}return s}function Fq(t,s,n,a){a===void 0&&(a={});let{window:r=document.defaultView,v5Compat:i=!1}=a,o=r.history,l=Fl.Pop,c=null,u=p();u==null&&(u=0,o.replaceState(fx({},o.state,{idx:u}),""));function p(){return(o.state||{idx:null}).idx}function m(){l=Fl.Pop;let g=p(),N=g==null?null:g-u;u=g,c&&c({action:l,location:v.location,delta:N})}function x(g,N){l=Fl.Push;let b=j2(v.location,g,N);u=p()+1;let f=_C(b,u),j=v.createHref(b);try{o.pushState(f,"",j)}catch(S){if(S instanceof DOMException&&S.name==="DataCloneError")throw S;r.location.assign(j)}i&&c&&c({action:l,location:v.location,delta:1})}function h(g,N){l=Fl.Replace;let b=j2(v.location,g,N);u=p();let f=_C(b,u),j=v.createHref(b);o.replaceState(f,"",j),i&&c&&c({action:l,location:v.location,delta:0})}function y(g){let N=r.location.origin!=="null"?r.location.origin:r.location.href,b=typeof g=="string"?g:Iy(g);return b=b.replace(/ $/,"%20"),$s(N,"No window.location.(origin|href) available to create URL for href: "+b),new URL(b,N)}let v={get action(){return l},get location(){return t(r,o)},listen(g){if(c)throw new Error("A history only accepts one active listener");return r.addEventListener(NC,m),c=g,()=>{r.removeEventListener(NC,m),c=null}},createHref(g){return s(r,g)},createURL:y,encodeLocation(g){let N=y(g);return{pathname:N.pathname,search:N.search,hash:N.hash}},push:x,replace:h,go(g){return o.go(g)}};return v}var kC;(function(t){t.data="data",t.deferred="deferred",t.redirect="redirect",t.error="error"})(kC||(kC={}));function Tq(t,s,n){return n===void 0&&(n="/"),Pq(t,s,n)}function Pq(t,s,n,a){let r=typeof s=="string"?Xm(s):s,i=p5(r.pathname||"/",n);if(i==null)return null;let o=GD(t);Dq(o);let l=null,c=Hq(i);for(let u=0;l==null&&u<o.length;++u)l=Uq(o[u],c);return l}function GD(t,s,n,a){s===void 0&&(s=[]),n===void 0&&(n=[]),a===void 0&&(a="");let r=(i,o,l)=>{let c={relativePath:l===void 0?i.path||"":l,caseSensitive:i.caseSensitive===!0,childrenIndex:o,route:i};c.relativePath.startsWith("/")&&($s(c.relativePath.startsWith(a),'Absolute route path "'+c.relativePath+'" nested under path '+('"'+a+'" is not val
1101id. An absolute child route path ')+"must start with the combined path of all its parent routes."),c.relativePath=c.relativePath.slice(a.length));let u=ql([a,c.relativePath]),p=n.concat(c);i.children&&i.children.length>0&&($s(i.index!==!0,"Index routes must not have child routes. Please remove "+('all child routes from route path "'+u+'".')),GD(i.children,s,p,u)),!(i.path==null&&!i.index)&&s.push({path:u,score:Mq(u,i.index),routesMeta:p})};return t.forEach((i,o)=>{var l;if(i.path===""||!((l=i.path)!=null&&l.includes("?")))r(i,o);else for(let c of VD(i.path))r(i,o,c)}),s}function VD(t){let s=t.split("/");if(s.length===0)return[];let[n,...a]=s,r=n.endsWith("?"),i=n.replace(/\?$/,"");if(a.length===0)return r?[i,""]:[i];let o=VD(a.join("/")),l=[];return l.push(...o.map(c=>c===""?i:[i,c].join("/"))),r&&l.push(...o),l.map(c=>t.startsWith("/")&&c===""?"/":c)}function Dq(t){t.sort((s,n)=>s.score!==n.score?n.score-s.score:Bq(s.routesMeta.map(a=>a.childrenIndex),n.routesMeta.map(a=>a.childrenIndex)))}const Rq=/^:[\w-]+$/,Iq=3,$q=2,zq=1,Lq=10,Oq=-2,SC=t=>t==="*";function Mq(t,s){let n=t.split("/"),a=n.length;return n.some(SC)&&(a+=Oq),s&&(a+=$q),n.filter(r=>!SC(r)).reduce((r,i)=>r+(Rq.test(i)?Iq:i===""?zq:Lq),a)}function Bq(t,s){return t.length===s.length&&t.slice(0,-1).every((a,r)=>a===s[r])?t[t.length-1]-s[s.length-1]:0}function Uq(t,s,n){let{routesMeta:a}=t,r={},i="/",o=[];for(let l=0;l<a.length;++l){let c=a[l],u=l===a.length-1,p=i==="/"?s:s.slice(i.length)||"/",m=qq({path:c.relativePath,caseSensitive:c.caseSensitive,end:u},p),x=c.route;if(!m)return null;
vendor: 6,959 bytes, lines 1101-1110
1101Object.assign(r,m.params),o.push({params:r,pathname:ql([i,m.pathname]),pathnameBase:Zq(ql([i,m.pathnameBase])),route:x}),m.pathnameBase!=="/"&&(i=ql([i,m.pathnameBase]))}return o}function qq(t,s){typeof t=="string"&&(t={path:t,caseSensitive:!1,end:!0});let[n,a]=Wq(t.path,t.caseSensitive,t.end),r=s.match(n);if(!r)return null;let i=r[0],o=i.replace(/(.)\/+$/,"$1"),l=r.slice(1);return{params:a.reduce((u,p,m)=>{let{paramName:x,isOptional:h}=p;if(x==="*"){let v=l[m]||"";o=i.slice(0,i.length-v.length).replace(/(.)\/+$/,"$1")}const y=l[m];return h&&!y?u[x]=void 0:u[x]=(y||"").replace(/%2F/g,"/"),u},{}),pathname:i,pathnameBase:o,pattern:t}}function Wq(t,s,n){s===void 0&&(s=!1),n===void 0&&(n=!0),HD(t==="*"||!t.endsWith("*")||t.endsWith("/*"),'Route path "'+t+'" will be treated as if it were '+('"'+t.replace(/\*$/,"/*")+'" because the `*` character must ')+"always follow a `/` in the pattern. To get rid of this warning, "+('please change the route path to "'+t.replace(/\*$/,"/*")+'".'));let a=[],r="^"+t.replace(/\/*\*?$/,"").replace(/^\/*/,"/").replace(/[\\.*+^${}|()[\]]/g,"\\$&").replace(/\/:([\w-]+)(\?)?/g,(o,l,c)=>(a.push({paramName:l,isOptional:c!=null}),c?"/?([^\\/]+)?":"/([^\\/]+)"));return t.endsWith("*")?(a.push({paramName:"*"}),r+=t==="*"||t==="/*"?"(.*)$":"(?:\\/(.+)|\\/*)$"):n?r+="\\/*$":t!==""&&t!=="/"&&(r+="(?:(?=\\/|$))"),[new RegExp(r,s?void 0:"i"),a]}function Hq(t){try{return t.split("/").map(s=>decodeURIComponent(s).replace(/\//g,"%2F")).join("/")}catch(s){return HD(!1,'The URL path "'+t+'" could not be decoded because it is is a malformed URL segment. This is probably due to a bad percent '+("encoding ("+s+").")),t}}function p5(t,s){if(s==="/")return t;if(!t.toLowerCase().startsWith(s.toLowerCase()))return null;let n=s.endsWith("/")?s.length-1:s.length,a=t.charAt(n);return a&&a!=="/"?null:t.slice(n)||"/"}function Gq(t,s){s===void 0&&(s="/");let{pathname:n,search:a="",hash:r=""}=typeof t=="string"?Xm(t):t,i;return n?(n=ZD(n),n.startsWith("/")?i=CC(n.substring(1),"/"):i=CC(n,s)):i=s,{pathname:i,search:Yq(a),hash:Kq(r)}}function CC(t,s){let n=s.replace(/\/+$/,"").split("/");return t.split("/").forEach(r=>{r===".."?n.length>1&&n.pop():r!=="."&&n.push(r)}),n.length>1?n.join("/"):"/"}function iv(t,s,n,a){return"Cannot include a '"+t+"' character in a manually specified "+("`to."+s+"` field ["+JSON.stringify(a)+"]. Please separate it out to the ")+("`to."+n+"` field. Alternatively you may provide the full path as ")+'a string in <Link to="..."> and the router will parse it for you.'}function Vq(t){return t.filter((s,n)=>n===0||s.route.path&&s.route.path.length>0)}function h5(t,s){let n=Vq(t);return s?n.map((a,r)=>r===n.length-1?a.pathname:a.pathnameBase):n.map(a=>a.pathnameBase)}function x5(t,s,n,a){a===void 0&&(a=!1);let r;typeof t=="string"?r=Xm(t):(r=fx({},t),$s(!r.pathname||!r.pathname.includes("?"),iv("?","pathname","search",r)),$s(!r.pathname||!r.pathname.includes("#"),iv("#","pathname","hash",r)),$s(!r.search||!r.search.includes("#"),iv("#","search","hash",r)));let i=t===""||r.pathname==="",o=i?"/":r.pathname,l;if(o==null)l=n;else{let m=s.length-1;if(!a&&o.startsWith("..")){let x=o.split("/");for(;x[0]==="..";)x.shift(),m-=1;r.pathname=x.join("/")}l=m>=0?s[m]:"/"}let c=Gq(r,l),u=o&&o!=="/"&&o.endsWith("/"),p=(i||o===".")&&n.endsWith("/");return!c.pathname.endsWith("/")&&(u||p)&&(c.pathname+="/"),c}const ZD=t=>t.replace(/\/\/+/g,"/"),ql=t=>ZD(t.join("/")),Zq=t=>t.replace(/\/+$/,"").replace(/^\/*/,"/"),Yq=t=>!t||t==="?"?"":t.startsWith("?")?t:"?"+t,Kq=t=>!t||t==="#"?"":t.startsWith("#")?t:"#"+t;function Qq(t){return t!=null&&typeof t.status=="number"&&typeof t.statusText=="string"&&typeof t.internal=="boolean"&&"data"in t}const YD=["post","put","patch","delete"];new Set(YD);const Jq=["get",...YD];new Set(Jq);/** 1102 * React Router v6.30.6 1103 * 1104 * Copyright (c) Remix Software Inc. 1105 * 1106 * This source code is licensed under the MIT license found in the 1107 * LICENSE.md file in the root directory of this source tree. 1108 * 1109 * @license MIT 1110 */function gx(){return gx=Object.assign?Object.assign.bind():function(t){for(var s=1;s<arguments.length;s++){var n=arguments[s];for(var a in n)({}).hasOwnProperty.call(n,a)&&(t[a]=n[a])}return t},gx.apply(null,arguments)}const f5=d.createContext(null),Xq=d.createContext(null),lc=d.createContext(null),Zb=d.createContext(null),qo=d.createContext({outlet:null,matches:[],isDataRoute:!1}),KD=d.createContext(null);function eW(t,s){let{relative:n}=s===void 0?{}:s;ep()||$s(!1);let{basename:a,navigator:r}=d.useContext(lc),{hash:i,pathname:o,search:l}=JD(t,{relative:n}),c=o;return a!=="/"&&(c=o==="/"?a:ql([a,o])),r.createHref({pathname:c,search:l,hash:i})}function ep(){return d.useContext(Zb)!=null}function ai(){return ep()||$s(!1),d.useContext(Zb).location}function QD(t){d.useContext(lc).static||d.useLayoutEffect(t)}function Za(){let{isDataRoute:t}=d.useContext(qo);return t?pW():tW()}function tW(){ep()||$s(!1);let t=d.useContext(f5),{basename:s,future:n,navigator:a}=d.useContext(lc),{matches:r}=d.useContext(qo),{pathname:i}=ai(),o=JSON.stringify(h5(r,n.v7_relativeSplatPath)),l=d.useRef(!1);return QD(()=>{l.current=!0}),d.useCallback(function(u,p){if(p===void 0&&(p={}),!l.current)return;if(typeof u=="number"){a.go(u);return}let m=x5(u,JSON.parse(o),i,p.relative==="path");t==null&&s!=="/"&&(m.pathname=m.pathname==="/"?s:ql([s,m.pathname])),(p.replace?a.replace:a.push)(m,p.state,p)},[s,a,o,i,t])}function Wo(){let{matches:t}=d.useContext(qo),s=t[t.length-1];return s?s.params:{}}function JD(t,s){let{relative:n}=s===void 0?{}:s,{future:a}=d.useContext(lc),{matches:r}=d.useContext(qo),{pathname:i}=ai(),o=JSON.stringify(h5(r,a.v7_relativeSplatPath));return d.useMemo(()=>x5(t,JSON.parse(o),i,n==="path"),[t,o,i,n])}function sW(t,s){return nW(t,s)}function nW(t,s,n,a){ep()||$s(!1);let{navigator:r}=d.useContext(lc),{matches:i}=d.useContext(qo),o=i[i.length-1],l=o?o.params:{};o&&o.pathname;let c=o?o.pathnameBase:"/";o&&o.route;let u=ai(),p;if(s){var m;let g=typeof s=="string"?Xm(s):s;c==="/"||(m=g.pathname)!=null&&m.startsWith(c)||$s(!1),p=g}else p=u;let x=p.pathname||"/",h=x;if(c!=="/"){let g=c.replace(/^\//,"").split("/");h="/"+x.replace(/^\//,"").split("/").slice(g.length).join("/")}let y=Tq(t,{pathname:h}),v=lW(y&&y.map(g=>Object.assign({},g,{params:Object.assign({},l,g.params),pathname:ql([c,r.encodeLocation?r.encodeLocation(g.pathname).pathname:g.pathname]),pathnameBase:g.pathnameBase==="/"?c:ql([c,r.encodeLocation?r.encodeLocation(g.pathnameBase).pathname:g.pathnameBase])})),i,n,a);return s&&v?d.createElement(Zb.Provider,{value:{location:gx({pathname:"/",search:"",hash:"",state:null,key:"default"},p),navigationType:Fl.Pop}},v):v}function aW(){let t=mW(),s=Qq(t)?t.status+" "+t.statusText:t instanceof Error?t.message:JSON.stringify(t),n=t instanceof Error?t.stack:null,r={padding:"0.5rem",backgroundColor:"rgba(200,200,200, 0.5)"};return d.createElement(d.Fragment,null,d.createElement("h2",null,"Unexpected Application
1110Error!"),d.createElement("h3",{style:{fontStyle:"italic"}},s),n?d.createElement("pre",{style:r},n):null,null)}const rW=d.createElement(aW,null);class iW extends d.Component{constructor(s){super(s),this.state={location:s.location,revalidation:s.revalidation,error:s.error}}static getDerivedStateFromError(s){return{error:s}}static getDerivedStateFromProps(s,n){return n.location!==s.location||n.revalidation!=="idle"&&s.revalidation==="idle"?{error:s.error,location:s.location,revalidation:s.revalidation}:{error:s.error!==void 0?s.error:n.error,location:n.location,revalidation:s.revalidation||n.revalidation}}componentDidCatch(s,n){console.error("React Router caught the following error during render",s,n)}render(){return this.state.error!==void 0?d.createElement(qo.Provider,{value:this.props.routeContext},d.createElement(KD.Provider,{value:this.state.error,children:this.props.component})):this.props.children}}function oW(t){let{routeContext:s,match:n,children:a}=t,r=d.useContext(f5);return r&&r.static&&r.staticContext&&(n.route.errorElement||n.route.ErrorBoundary)&&(r.staticContext._deepestRenderedBoundaryId=n.route.id),d.createElement(qo.Provider,{value:s},a)}function lW(t,s,n,a){var r;if(s===void 0&&(s=[]),n===void 0&&(n=null),a===void 0&&(a=null),t==null){var i;if(!n)return null;if(n.errors)t=n.matches;else if((i=a)!=null&&i.v7_partialHydration&&s.length===0&&!n.initialized&&n.matches.length>0)t=n.matches;else return null}let o=t,l=(r=n)==null?void 0:r.errors;if(l!=null){let p=o.findIndex(m=>m.route.id&&(l==null?void 0:l[m.route.id])!==void 0);p>=0||$s(!1),o=o.slice(0,Math.min(o.length,p+1))}let c=!1,u=-1;if(n&&a&&a.v7_partialHydration)for(let p=0;p<o.length;p++){let m=o[p];if((m.route.HydrateFallback||m.route.hydrateFallbackElement)&&(u=p),m.route.id){let{loaderData:x,errors:h}=n,y=m.route.loader&&x[m.route.id]===void 0&&(!h||h[m.route.id]===void 0);if(m.route.lazy||y){c=!0,u>=0?o=o.slice(0,u+1):o=[o[0]];break}}}return o.reduceRight((p,m,x)=>{let h,y=!1,v=null,g=null;n&&(h=l&&m.route.id?l[m.route.id]:void 0,v=m.route.errorElement||rW,c&&(u<0&&x===0?(hW("route-fallback"),y=!0,g=null):u===x&&(y=!0,g=m.route.hydrateFallbackElement||null)));let N=s.concat(o.slice(0,x+1)),b=()=>{let f;return h?f=v:y?f=g:m.route.Component?f=d.createElement(m.route.Component,null):m.route.element?f=m.route.element:f=p,d.createElement(oW,{match:m,routeContext:{outlet:p,matches:N,isDataRoute:n!=null},children:f})};return n&&(m.route.ErrorBoundary||m.route.errorElement||x===0)?d.createElement(iW,{location:n.location,revalidation:n.revalidation,component:v,error:h,children:b(),routeContext:{outlet:null,matches:N,isDataRoute:!0}}):b()},null)}var XD=function(t){return t.UseBlocker="useBlocker",t.UseRevalidator="useRevalidator",t.UseNavigateStable="useNavigate",t}(XD||{}),eR=function(t){return t.UseBlocker="useBlocker",t.UseLoaderData="useLoaderData",t.UseActionData="useActionData",t.UseRouteError="useRouteError",t.UseNavigation="useNavigation",t.UseRouteLoaderData="useRouteLoaderData",t.UseMatches="useMatches",t.UseRevalidator="useRevalidator",t.UseNavigateStable="useNavigate",t.UseRouteId="useRouteId",t}(eR||{});function cW(t){let s=d.useContext(f5);return s||$s(!1),s}function dW(t){let s=d.useContext(Xq);return s||$s(!1),s}function uW(t){let s=d.useContext(qo);return s||$s(!1),s}function tR(t){let s=uW(),n=s.matches[s.matches.length-1];return n.route.id||$s(!1),n.route.id}function mW(){var t;let s=d.useContext(KD),n=dW(),a=tR();return s!==void 0?s:(t=n.errors)==null?void 0:t[a]}function pW(){let{router:t}=cW(XD.UseNavigateStable),s=tR(eR.UseNavigateStable),n=d.useRef(!1);return QD(()=>{n.current=!0}),d.useCallback(function(r,i){i===void 0&&(i={}),n.current&&(typeof r=="number"?t.navigate(r):t.navigate(r,gx({fromRouteId:s},i)))},[t,s])}const AC={};function hW(t,s,n){AC[t]||(AC[t]=!0)}function xW(t,s){t==null||t.v7_startTransition,t==null||t.v7_relativeSplatPath}function sR(t){let{to:s,replace:n,state:a,relative:r}=t;ep()||$s(!1);let{future:i,static:o}=d.useContext(lc),{matches:l}=d.useContext(qo),{pathname:c}=ai(),u=Za(),p=x5(s,h5(l,i.v7_relativeSplatPath),c,r==="path"),m=JSON.stringify(p);return d.useEffect(()=>u(JSON.parse(m),{replace:n,state:a,relative:r}),[u,m,r,n,a]),null}function ze(t){$s(!1)}function fW(t){let{basename:s="/",children:n=null,location:a,navigationType:r=Fl.Pop,navigator:i,static:o=!1,future:l}=t;ep()&&$s(!1);let c=s.replace(/^\/*/,"/"),u=d.useMemo(()=>({basename:c,navigator:i,static:o,future:gx({v7_relativeSplatPath:!1},l)}),[c,l,i,o]);
1110typeof a=="string"&&(a=Xm(a));let{pathname:p="/",search:m="",hash:x="",state:h=null,key:y="default"}=a,v=d.useMemo(()=>{let g=p5(p,c);return g==null?null:{location:{pathname:g,search:m,hash:x,state:h,key:y},navigationType:r}},[c,p,m,x,h,y,r]);return v==null?null:d.createElement(lc.Provider,{value:u},d.createElement(Zb.Provider,{children:n,value:v}))}function gW(t){let{children:s,location:n}=t;return sW(w2(s),n)}new Promise(()=>{});function w2(t,s){s===void 0&&(s=[]);let n=[];return d.Children.forEach(t,(a,r)=>{if(!d.isValidElement(a))return;let i=[...s,r];if(a.type===d.Fragment){n.push.apply(n,w2(a.props.children,i));return}a.type!==ze&&$s(!1),!a.props.index||!a.props.children||$s(!1);let o={id:a.props.id||i.join("-"),caseSensitive:a.props.caseSensitive,element:a.props.element,Component:a.props.Component,index:a.props.index,path:a.props.path,loader:a.props.loader,action:a.props.action,errorElement:a.props.errorElement,ErrorBoundary:a.props.ErrorBoundary,hasErrorBoundary:a.props.ErrorBoundary!=null||a.props.errorElement!=null,shouldRevalidate:a.props.shouldRevalidate,handle:a.props.handle,lazy:a.props.lazy};a.props.children&&(o.children=w2(a.props.children,i)),n.push(o)}),n}/** 1111 * React Router DOM v6.30.6 1112 * 1113 * Copyright (c) Remix Software Inc. 1114 * 1115 * This source code is licensed under the MIT license found in the 1116 * LICENSE.md file in the root directory of this source tree. 1117 * 1118 * @license MIT 1119 */function N2(){return N2=Object.assign?Object.assign.bind():function(t){for(var s=1;s<arguments.length;s++){var n=arguments[s];for(var a in n)({}).hasOwnProperty.call(n,a)&&(t[a]=n[a])}return t},N2.apply(null,arguments)}function yW(t,s){if(t==null)return{};var n={};for(var a in t)if({}.hasOwnProperty.call(t,a)){if(s.indexOf(a)!==-1)continue;n[a]=t[a]}return n}function bW(t){return!!(t.metaKey||t.altKey||t.ctrlKey||t.shiftKey)}function vW(t,s){return t.button===0&&(!s||s==="_self")&&!bW(t)}function _2(t){return t===void 0&&(t=""),new URLSearchParams(typeof t=="string"||Array.isArray(t)||t instanceof URLSearchParams?t:Object.keys(t).reduce((s,n)=>{let a=t[n];return s.concat(Array.isArray(a)?a.map(r=>[n,r]):[[n,a]])},[]))}function jW(t,s){let n=_2(t);return s&&s.forEach((a,r)=>{n.has(r)||s.getAll(r).forEach(i=>{n.append(r,i)})}),n}const wW=["onClick","relative","reloadDocument","replace","state","target","to","preventScrollReset","viewTransition"],NW="6";try{window.__reactRouterVersion=NW}catch{}const _W="startTransition",EC=$d[_W];function kW(t){let{basename:s,children:n,future:a,window:r}=t,i=d.useRef();i.current==null&&(i.current=Aq({window:r,v5Compat:!0}));let o=i.current,[l,c]=d.useState({action:o.action,location:o.location}),{v7_startTransition:u}=a||{},p=d.useCallback(m=>{u&&EC?EC(()=>c(m)):c(m)},[c,u]);return d.useLayoutEffect(()=>o.listen(p),[o,p]),d.useEffect(()=>xW(a),[a]),d.createElement(fW,{basename:s,children:n,location:l.location,navigationType:l.action,navigator:o,future:a})}const SW=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u",CW=/^(?:[a-z][a-z0-9+.-]*:|\/\/)/i,be=d.forwardRef(function(s,n){let{onClick:a,relative:r,reloadDocument:i,replace:o,state:l,target:c,to:u,preventScrollReset:p,viewTransition:m}=s,x=yW(s,wW),{basename:h}=d.useContext(lc),y,v=!1;if(typeof u=="string"&&CW.test(u)&&(y=u,SW))try{let f=new URL(window.location.href),j=u.startsWith("//")?new URL(f.protocol+u):new URL(u),S=p5(j.pathname,h);j.origin===f.origin&&S!=null?u=S+j.search+j.hash:v=!0}catch{}let g=eW(u,{relative:r}),N=AW(u,{replace:o,state:l,target:c,preventScrollReset:p,relative:r,viewTransition:m});function b(f){a&&a(f),f.defaultPrevented||N(f)}return d.createElement("a",N2({},x,{href:y||g,onClick:v||i?a:b,ref:n,target:c}))});var FC;(function(t){t.UseScrollRestoration="useScrollRestoration",t.UseSubmit="useSubmit",t.UseSubmitFetcher="useSubmitFetcher",t.UseFetcher="useFetcher",t.useViewTransitionState="useViewTransitionState"})(FC||(FC={}));var TC;(function(t){t.UseFetcher="useFetcher",t.UseFetchers="useFetchers",t.UseScrollRestoration="useScrollRestoration"})(TC||(TC={}));function AW(t,s){let{target:n,replace:a,state:r,preventScrollReset:i,relative:o,viewTransition:l}=s===void 0?{}:s,c=Za(),u=ai(),p=JD(t,{relative:o});return d.useCallback(m=>{if(vW(m,n)){m.preventDefault();let x=a!==void 0?a:Iy(u)===Iy(p);c(t,{replace:x,state:r,preventScrollReset:i,relative:o,viewTransition:l})}},[u,c,p,a,r,n,t,i,o,l])}function cc(t){let s=d.useRef(_2(t)),n=d.useRef(!1),a=ai(),r=d.useMemo(()=>jW(a.search,n.current?null:s.current),[a.search]),i=Za(),o=d.useCallback((l,c)=>{const u=_2(typeof l=="function"?l(r):l);n.current=!0,i("?"+u,c)},[i,r]);return[r,o]}const nR=d.createContext(null);function aR(){const t=d.useContext(nR);if(!t)throw new Error("useOperatorToast() must be called inside <OperatorToastProvider>. Make sure App.tsx wraps the tree with the provider.");return t}const EW=5,PC={success:6e3,info:6e3,warning:8e3,error:0},FW={success:{container:"bg-emerald-50 border-emerald-300",iconWrap:"bg-emerald-100",iconColor:"text-emerald-600",titleColor:"text-emerald-900",de
1119scriptionColor:"text-emerald-800",expandColor:"text-emerald-700 hover:text-emerald-900",chipBg:"border-emerald-300 bg-emerald-100 text-emerald-800"},error:{container:"bg-rose-50 border-rose-300",iconWrap:"bg-rose-100",iconColor:"text-rose-600",titleColor:"text-rose-900",descriptionColor:"text-rose-800",expandColor:"text-rose-700 hover:text-rose-900",chipBg:"border-rose-300 bg-rose-100 text-rose-800"},warning:{container:"bg-amber-50 border-amber-300",iconWrap:"bg-amber-100",iconColor:"text-amber-600",titleColor:"text-amber-900",descriptionColor:"text-amber-800",expandColor:"text-amber-700 hover:text-amber-900",chipBg:"border-amber-300 bg-amber-100 text-amber-800"},info:{container:"bg-slate-50 border-slate-300",iconWrap:"bg-slate-100",iconColor:"text-slate-600",titleColor:"text-slate-900",descriptionColor:"text-slate-700",expandColor:"text-slate-700 hover:text-slate-900",chipBg:"border-slate-300 bg-slate-100 text-slate-800"}};function TW(t,s){switch(t){case"success":return e.jsx(Ue,{className:s});case"error":return e.jsx(kt,{className:s});case"warning":return e.jsx(ve,{className:s});case"info":default:return e.jsx(Bi,{className:s})}}let DC=0;function PW(){return DC+=1,`op-toast-${DC}`}function DW({children:t}){const[s,n]=d.useState([]),a=d.useRef(new Map),r=d.useCallback(p=>{const m=a.current.get(p);m!==void 0&&(window.clearTimeout(m),a.current.delete(p))},[]),i=d.useCallback(p=>{r(p),n(m=>m.filter(x=>x.id!==p))},[r]),o=d.useCallback((p,m)=>{if(r(p),!m||m<=0)return;const x=window.setTimeout(()=>{a.current.delete(p),n(h=>h.filter(y=>y.id!==p))},m);a.current.set(p,x)},[r]),l=d.useCallback(p=>{const m=p.id??PW(),x=p.durationMs!==void 0?p.durationMs:PC[p.variant],h={...p,id:m,createdAtMs:Date.now()};return n(y=>{let v=y.filter(g=>g.id!==m);if(v.length>=EW){const g=v.findIndex(f=>f.variant!=="error"),N=g===-1?0:g,b=v[N];b&&r(b.id),v=v.filter((f,j)=>j!==N)}return v.push(h),v}),o(m,x),m},[o,r]),c=d.useCallback((p,m)=>{let x=!1;return n(h=>h.map(y=>y.id!==p?y:(x=!0,{...y,...m,id:y.id,createdAtMs:y.createdAtMs}))),x&&(m.durationMs!==void 0||m.variant!==void 0)&&queueMicrotask(()=>{n(h=>{const y=h.find(v=>v.id===p);if(y){const v=y.durationMs!==void 0?y.durationMs:PC[y.variant];o(p,v)}return h})}),x},[o]);d.useEffect(()=>{const p=a.current;return()=>{p.forEach(m=>window.clearTimeout(m)),p.clear()}},[]);const u=d.useMemo(()=>({show:l,dismiss:i,update:c}),[l,i,c]);return e.jsxs(nR.Provider,{value:u,children:[t,e.jsx(RW,{toasts:s,onDismiss:i})]})}function RW({toasts:t,onDismiss:s}){return t.length===0?null:e.jsx("div",{"aria-live":"polite",role:"region","aria-label":"Operator notifications",className:"fixed bottom-4 right-4 z-[100] flex flex-col gap-2 max-w-sm w-[calc(100vw-2rem)] pointer-events-none",children:t.map(n=>e.jsx("div",{className:"pointer-events-auto",children:e.jsx(IW,{toast:n,onDismiss:s})},n.id))})}function IW({toast:t,onDismiss:s}){const n=FW[t.variant],[a,r]=d.useState(!1),[i,o]=d.useState({}),l=Array.isArray(t.expandableChips)&&t.expandableChips.length>0,c=async(u,p)=>{if(!i[p]){o(m=>({...m,[p]:!0}));try{await u.onClick(),(u.dismissOnSuccess!==void 0?u.dismissOnSuccess:(u.variant??"primary")==="primary")&&s(t.id)}catch(m){console.warn("[operator-toast] Action handler threw:",m)}finally{o(m=>({...m,[p]:!1}))}}};return e.jsx("div",{className:`border rounded-lg shadow-md p-3 ${n.container} animate-in slide-in-from-right-5 fade-in duration-200`,role:t.variant==="error"?"alert":"status",children:e.jsxs("div",{className:"flex items-start gap-2.5",children:[e.jsx("div",{className:`flex-shrink-0 w-7 h-7 rounded-full flex items-center justify-center ${n.iconWrap}`,children:TW(t.variant,`w-4 h-4 ${n.iconColor}`)}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-start justify-between gap-2",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("div",{className:`text-xs font-bold ${n.titleColor} break-words`,children:t.title}),t.description&&e.jsx("div",{className:`text-[11px] mt-0.5 ${n.descriptionColor} break-words leading-snug`,children:t.description})]}),e.jsx("button",{type:"button",onClick:()=>s(t.id),className:`flex-shrink-0 p-0.5 rounded hover:bg-white/60 ${n.iconColor} opacity-70 hover:opacity-100 transition-opacity`,"aria-label":"Dismiss notification",title:"Dismiss",children:e.jsx(Ke,{className:"w-3.5 h-3.5"})})]}),l&&e.jsxs("div",{className:"mt-2",children:[e.jsxs("button",{type:"button",onClick:()=>r(u=>!u),className:`inline-flex items-center gap-1 text-[10px] font-semibold ${n.expandColor} hover:underline`,"aria-expanded":a,children:[e.jsx(Gt,{className:`w-3 h-3 transition-transform ${a?"rotate-180":"-rotate-90"}`}),a?"Hide":t.expandLabel||"View details",e.jsxs("span",{className:"opacity-70 font-normal",children:["(",t.expandableChips.length,")"]})]}),a&&e.jsx("div",{className:"mt-1.5 flex flex-wrap gap-1 pl-3.5",children:t.expandableChips.map((u,p)=>e.jsx("span",{className:`text-[9px] font-medium px-1.5 py-0.5 rounded-full border max-w-full truncate ${n.chipBg}`,title:u.reason?`${u.label} 1120 1121Reason: ${u.reason}`:u.label,children:u.label},`${u.label}-${p}`))})]}),t.actions&&t.actions.length>0&&e.jsx("div",{className:"mt-2 flex items-center gap-1.5 flex-wrap",children:t.actions.map((u,p)=>{const m=!!i[p],x=u.variant??(p===0?"primary":"secondary"),h=t.variant==="success"?"bg-emerald-600 hover:bg-emerald-700 text-white border-emerald-600":t.variant==="error"?"bg-rose-600 hover:bg-rose-700 text-white border-rose-600":t.variant==="warning"?"bg-amber-600 hover:bg-amber-700 text-white border-amber-600":"bg-slate-700 hover:bg-slate-800 text-white border-slate-700",v=x==="primary"?h:"bg-white hover:bg-slate-50 text-slate-700 border-slate-300";return e.jsxs("button",{type:"button",onClick:()=>c(u,p),disabled:m,className:`text-[10px] font-semibold px-2 py-1 rounded border inline-flex items-center gap-1 disabled:opacity-50 disabled:cursor-not-allowed transition-colors ${v}`,children:[m&&e.jsx(de,{className:"w-3 h-3 animate-spin"}),u.label]},`${u.label}-${p}`)})})]})]})})}const $W="modulepreload",zW=function(t){return"/"+t},RC={},Ee=function(s,n,a){let r=Promise.resolve();if(n&&n.length>0){document.getElementsByTagName("link");const o=document.querySelector("meta[property=csp-nonce]"),l=(o==null?void 0:o.nonce)||(o==null?void 0:o.getAttribute("nonce"));r=Promise.allSettled(n.map(c=>{if(c=zW(c),c in RC)return;RC[c]=!0;const u=c.endsWith(".css"),p=u?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${c}"]${p}`))return;
1121const m=document.createElement("link");if(m.rel=u?"stylesheet":$W,u||(m.as="script"),m.crossOrigin="",m.href=c,l&&m.setAttribute("nonce",l),document.head.appendChild(m),u)return new Promise((x,h)=>{m.addEventListener("load",x),m.addEventListener("error",()=>h(new Error(`Unable to preload CSS for ${c}`)))})}))}function i(o){const l=new Event("vite:preloadError",{cancelable:!0});if(l.payload=o,window.dispatchEvent(l),!l.defaultPrevented)throw o}return r.then(o=>{for(const l of o||[])l.status==="rejected"&&i(l.reason);return s().catch(i)})},Mi="https://www.zorganicsinstitute.edu",g5={"our-story":"/about-us","program-profiles":"/programs",admissions:"/admissions","apply-now":"/apply-now","tour-booking":"/book-online","student-clinic":"/student-clinic","contact-us":"/contact","salon-services":"/salon","med-spa-portal":"/medspa",shop:"/cosmetics",wholesale:"/wholesale","foundation-landing":"/foundation","foundation-gift-shop":"/gift-shop"},LW=Object.entries(g5).reduce((t,[s,n])=>(t[n]=s,t),{});function rR(t){const s=t.toLowerCase().replace(/\/+$/,"");return s===""?"/":s}function iR(t){return LW[rR(t)]}function Yb(t){return g5[t]}function OW(t){const s=g5[t];return`${Mi}${s||"/"}`}const yx=[{path:"/cosmetology-program",programId:"cosmetology",name:"Cosmetology",hours:1600,seoTitle:"Cosmetology Program (1,600 Hours) | Zorganics Institute â Bellingham WA",seoDescription:"The 1,600-hour Cosmetology program at Zorganics Institute â haircutting, hair design, color and chemical services, skincare and nail foundations, safety and sanitation, and Washington State licensure preparation.",area:"Hair · Skin · Nails",coreFourHandle:"cosmetology"},{path:"/esthetics-program",programId:"esthetics-750",name:"Esthetician",hours:750,seoTitle:"Esthetician Program (750 Hours) | Zorganics Institute â Bellingham WA",seoDescription:"The 750-hour Esthetician program at Zorganics Institute â skin science, classic facial treatments, hair removal, makeup artistry and Washington State licensure preparation. Bridge-eligible for Master Esthetician licensure.",area:"Skin science & facial treatments",coreFourHandle:"esthetics"},{path:"/master-esthetics",programId:"master-esthetics-1200",name:"Master Esthetician",hours:1200,seoTitle:"Master Esthetician Program (1,200 Hours) | Zorganics Institute â Bellingham WA",seoDescription:"The full 1,200-hour Master Esthetician program at Zorganics Institute â advanced skin analysis, laser and light modalities, chemical peels, microneedling and clinical esthetics for medical-spa readiness.",area:"Advanced clinical esthetics",coreFourHandle:"master-esthetics"},{path:"/programs/master-esthetician-bridge",programId:"advanced-master-esthetics-450",name:"Master Esthetician Bridge",hours:450,seoTitle:"Master Esthetician 450 Bridge Program (450 Hours) | Zorganics Institute",seoDescription:"The 450-hour Master Esthetician Bridge at Zorganics Institute â an accelerated pathway for currently licensed Estheticians upgrading to Master Esthetician licensure, covering advanced clinical modalities only.",area:"Advanced clinical modalities (licensed Estheticians)"},{path:"/programs/manicurist",programId:"manicurist",name:"Manicurist",hours:600,seoTitle:"Manicurist Program (600 Hours) | Zorganics Institute â Bellingham WA",seoDescription:"The 600-hour Manicurist program at Zorganics Institute â nail science, manicuring and pedicuring, artificial nail services, nail artistry, sanitation and Washington State licensure preparation.",area:"Nail technology & artistry",coreFourHandle:"manicurist"},{path:"/programs/instructor-training",programId:"instructor",name:"Instructor Training",hours:600,seoTitle:"Instructor Training Program (600 Hours) | Zorganics Institute â Bellingham WA",seoDescription:"The 600-hour Instructor Program at Zorganics Institute â educational foundations, classroom management, assessment and clinical practicum for currently licensed beauty professionals entering education.",area:"Beauty & wellness education (licensed professionals)"}],MW=yx.reduce((t,s)=>(t[s.path]=s,t),{}),BW=yx.reduce((t,s)=>(t[s.programId]=s,t),{});function UW(t){return MW[rR(t)]}function k2(t){return t?BW[t]:void 0}function h0(t){var s;return(s=k2(t))==null?void 0:s.path}const qW="esthetics-750",WW="advanced-master-esthetics-450";function HW(t,s){if(t==="master-bridge")return h0(WW);if(t==="program-detail")return h0(s)||h0(qW)}const oR={"/programs/esthetician":"/esthetics-program","/programs/esthetics":"/esthetics-program","/esthetician-program":"/esthetics-program","/programs/cosmetology":"/cosmetology-program","/cosmetology":"/cosmetology-program","/programs/master-esthetician":"/master-esthetics","/programs/master-esthetics":"/master-esthetics","/master-esthetician":"/master-esthetics","/master-esthetician-program":"/master-esthetics","/manicurist":"/programs/manicurist","/program/manicurist":"/programs/manicurist","/apply":"/apply-now","/apply-onl
1121ine":"/apply-now","/application":"/apply-now","/student-portal":"/apply-now","/studentportal":"/apply-now","/tour":"/book-online","/tours":"/book-online","/book-a-tour":"/book-online","/schedule-a-tour":"/book-online","/book-tour":"/book-online","/financialaid":"/financial-aid","/tuition-and-financial-aid":"/financial-aid"},GW=Object.keys(oR),VW={programs:"program-profiles",program:"program-profiles","program-profile":"program-profiles",admission:"admissions",apply:"apply-now",contact:"contact-us",clinic:"student-clinic","student-salon-clinic":"student-clinic",salon:"salon-services","salon-spa":"salon-services","med-spa":"med-spa-portal",medspa:"med-spa-portal",cosmetics:"shop","z-shop":"shop","wholesale-shop":"wholesale",b2b:"wholesale","gift-shop":"foundation-gift-shop"},ZW={"master-esthetics-1200":"master-esthetics-1200","master-esthetics":"master-esthetics-1200",cosmetology:"cosmetology","esthetics-750":"esthetics-750",esthetics:"esthetics-750",manicurist:"manicurist","instructor-training":"instructor"};function YW(t){if(!t)return{};const s=t.trim().toLowerCase();if(!s)return{};const n=ZW[s];if(n)return{section:"program-profiles",programId:n};const a=VW[s];return a&&a!==s?{section:a}:{section:s}}const KW={sidebarOpen:!1,toggleSidebar:()=>{},activeSection:"dashboard",setActiveSection:()=>{},activeBrand:"institute",setActiveBrand:()=>{},showHero:!0,setShowHero:()=>{},selectedStudentId:null,setSelectedStudentId:()=>{},searchQuery:"",setSearchQuery:()=>{},activeTenantId:"zorganics-hq",setActiveTenantId:()=>{},selectedEntity:"none",setSelectedEntity:()=>{},entityGatewayDismissed:!1,setEntityGatewayDismissed:()=>{},activeLocation:"bellingham",setActiveLocation:()=>{},selectedProgramId:null,setSelectedProgramId:()=>{}},lR=d.createContext(KW),dc=()=>d.useContext(lR),cR=({children:t,routeSection:s,routeProgramId:n})=>{const a=(()=>{try{if(s||typeof window>"u")return{};const I=new URLSearchParams(window.location.search);return YW(I.get("section"))}catch{return{}}})(),r=s||a.section||"campus-home",[i,o]=d.useState(!1),[l,c]=d.useState(r),[u,p]=d.useState("institute"),[m,x]=d.useState(r==="dashboard"),[h,y]=d.useState(null),[v,g]=d.useState(""),[N,b]=d.useState("zorganics-hq"),[f,j]=d.useState("none"),[S,w]=d.useState(r!=="dashboard"),[_,C]=d.useState("bellingham"),[E,P]=d.useState(n||a.programId||null);re.useEffect(()=>{s&&c(I=>I===s?I:s)},[s]),re.useEffect(()=>{n&&P(I=>I===n?I:n)},[n]);const F=()=>o(I=>!I);return e.jsx(lR.Provider,{value:{sidebarOpen:i,toggleSidebar:F,activeSection:l,setActiveSection:c,activeBrand:u,setActiveBrand:p,showHero:m,setShowHero:x,selectedStudentId:h,setSelectedStudentId:y,searchQuery:v,setSearchQuery:g,activeTenantId:N,setActiveTenantId:b,selectedEntity:f,setSelectedEntity:j,entityGatewayDismissed:S,setEntityGatewayDismissed:w,activeLocation:_,setActiveLocation:C,selectedProgramId:E,setSelectedProgramId:P},children:t})},QW=Symbol.for("@supabase/supabase-js.traceContextExtractor");function JW(){return globalThis[QW]}var Ci=function(){return Ci=Object.assign||function(s){for(var n,a=1,r=arguments.length;a<r;a++){n=arguments[a];for(var i in n)Object.prototype.hasOwnProperty.call(n,i)&&(s[i]=n[i])}return s},Ci.apply(this,arguments)};function tp(t,s){var n={};for(var a in t)Object.prototype.hasOwnProperty.call(t,a)&&s.indexOf(a)<0&&(n[a]=t[a]);if(t!=null&&typeof Object.getOwnPropertySymbols=="function")for(var r=0,a=Object.getOwnPropertySymbols(t);r<a.length;r++)s.indexOf(a[r])<0&&Object.prototype.propertyIsEnumerable.call(t,a[r])&&(n[a[r]]=t[a[r]]);return n}function XW(t,s,n,a){function r(i){return i instanceof n?i:new n(function(o){o(i)})}return new(n||(n=Promise))(function(i,o){function l(p){try{u(a.next(p))}catch(m){o(m)}}function c(p){try{u(a.throw(p))}catch(m){o(m)}}function u(p){p.done?i(p.value):r(p.value).then(l,c)}u((a=a.apply(t,s||[])).next())})}function eH(t,s,n){if(n||arguments.length===2)for(var a=0,r=s.length,i;a<r;a++)(i||!(a in s))&&(i||(i=Array.prototype.slice.call(s,0,a)),i[a]=s[a]);return t.concat(i||Array.prototype.slice.call(s))}const tH=t=>t?(...s)=>t(...s):(...s)=>fetch(...s);
1121class y5 extends Error{constructor(s,n="FunctionsError",a){super(s),this.name=n,this.context=a}toJSON(){return{name:this.name,message:this.message,context:this.context}}}class sH extends y5{constructor(s){super("Failed to send a request to the Edge Function","FunctionsFetchError",s)}}class IC extends y5{constructor(s){super("Relay Error invoking the Edge Function","FunctionsRelayError",s)}}class $C extends y5{constructor(s){super("Edge Function returned a non-2xx status code","FunctionsHttpError",s)}}var S2;(function(t){t.Any="any",t.ApNortheast1="ap-northeast-1",t.ApNortheast2="ap-northeast-2",t.ApSouth1="ap-south-1",t.ApSoutheast1="ap-southeast-1",t.ApSoutheast2="ap-southeast-2",t.CaCentral1="ca-central-1",t.EuCentral1="eu-central-1",t.EuWest1="eu-west-1",t.EuWest2="eu-west-2",t.EuWest3="eu-west-3",t.SaEast1="sa-east-1",t.UsEast1="us-east-1",t.UsWest1="us-west-1",t.UsWest2="us-west-2"})(S2||(S2={}));class nH{constructor(s,{headers:n={},customFetch:a,region:r=S2.Any}={}){this.url=s,this.headers=n,this.region=r,this.fetch=tH(a)}setAuth(s){this.headers.Authorization=`Bearer ${s}`}invoke(s){return XW(this,arguments,void 0,function*(n,a={}){var r,i;let o,l,c;try{const{headers:u,method:p,body:m,signal:x,timeout:h}=a;let y={},{region:v}=a;v||(v=this.region);const g=new URL(`${this.url}/${n}`);v&&v!=="any"&&(y["x-region"]=v,g.searchParams.set("forceFunctionRegion",v));let N;const b=!!u&&Object.keys(u).some(C=>C.toLowerCase()==="content-type");m&&!b?typeof Blob<"u"&&m instanceof Blob||m instanceof ArrayBuffer?(y["Content-Type"]="application/octet-stream",N=m):typeof m=="string"?(y["Content-Type"]="text/plain",N=m):typeof FormData<"u"&&m instanceof FormData?N=m:(y["Content-Type"]="application/json",N=JSON.stringify(m)):m&&typeof m!="string"&&!(typeof Blob<"u"&&m instanceof Blob)&&!(m instanceof ArrayBuffer)&&!(typeof FormData<"u"&&m instanceof FormData)?N=JSON.stringify(m):N=m;let f=x;h&&(l=new AbortController,o=setTimeout(()=>l.abort(),h),x?(f=l.signal,c=()=>l.abort(),x.addEventListener("abort",c)):f=l.signal);const j=yield this.fetch(g.toString(),{method:p||"POST",headers:Object.assign(Object.assign(Object.assign({},y),this.headers),u),body:N,signal:f}).catch(C=>{throw new sH(C)}),S=j.headers.get("x-relay-error");if(S&&S==="true")throw new IC(j);if(!j.ok)throw new $C(j);let w=((r=j.headers.get("Content-Type"))!==null&&r!==void 0?r:"text/plain").split(";")[0].trim().toLowerCase(),_;return w==="application/json"?_=yield j.json():w==="application/octet-stream"||w==="application/pdf"?_=yield j.blob():w==="text/event-stream"?_=j:w==="multipart/form-data"?_=yield j.formData():_=yield j.text(),{data:_,error:null,response:j}}catch(u){return{data:null,error:u,response:u instanceof $C||u instanceof IC?u.context:void 0}}finally{o&&clearTimeout(o),c&&((i=a.signal)===null||i===void 0||i.removeEventListener("abort",c))}})}}const dR=3,zC=t=>Math.min(1e3*2**t,3e4),aH=[520,503],uR=["GET","HEAD","OPTIONS"];var ov=class extends Error{constructor(t){super(t.message),this.name="PostgrestError",this.details=t.details,this.hint=t.hint,this.co
1121de=t.code}toJSON(){return{name:this.name,message:this.message,details:this.details,hint:this.hint,code:this.code}}};function bx(t){"@babel/helpers - typeof";return bx=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(s){return typeof s}:function(s){return s&&typeof Symbol=="function"&&s.constructor===Symbol&&s!==Symbol.prototype?"symbol":typeof s},bx(t)}function rH(t,s){if(bx(t)!="object"||!t)return t;var n=t[Symbol.toPrimitive];if(n!==void 0){var a=n.call(t,s);if(bx(a)!="object")return a;throw new TypeError("@@toPrimitive must return a primitive value.")}return(s==="string"?String:Number)(t)}function iH(t){var s=rH(t,"string");return bx(s)=="symbol"?s:s+""}function oH(t,s,n){return(s=iH(s))in t?Object.defineProperty(t,s,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[s]=n,t}function LC(t,s){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(t);s&&(a=a.filter(function(r){return Object.getOwnPropertyDescriptor(t,r).enumerable})),n.push.apply(n,a)}return n}function qu(t){for(var s=1;s<arguments.length;s++){var n=arguments[s]!=null?arguments[s]:{};s%2?LC(Object(n),!0).forEach(function(a){oH(t,a,n[a])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):LC(Object(n)).forEach(function(a){Object.defineProperty(t,a,Object.getOwnPropertyDescriptor(n,a))})}return t}function OC(t,s){return new Promise(n=>{if(s!=null&&s.aborted){n();return}const a=setTimeout(()=>{s==null||s.removeEventListener("abort",r),n()},t);function r(){clearTimeout(a),n()}s==null||s.addEventListener("abort",r)})}function lH(t,s,n,a){return!(!a||n>=dR||!uR.includes(t)||!aH.includes(s))}var cH=class{constructor(t){var s,n,a,r,i;this.shouldThrowOnError=!1,this.retryEnabled=!0,this.method=t.method,this.url=t.url,this.headers=new Headers(t.headers),this.schema=t.schema,this.body=t.body,this.shouldThrowOnError=(s=t.shouldThrowOnError)!==null&&s!==void 0?s:!1,this.signal=t.signal,this.isMaybeSingle=(n=t.isMaybeSingle)!==null&&n!==void 0?n:!1,this.shouldStripNulls=(a=t.shouldStripNulls)!==null&&a!==void 0?a:!1,this.urlLengthLimit=(r=t.urlLengthLimit)!==null&&r!==void 0?r:8e3,this.retryEnabled=(i=t.retry)!==null&&i!==void 0?i:!0,t.fetch?this.fetch=t.fetch:this.fetch=fetch}throwOnError(){return this.shouldThrowOnError=!0,this}stripNulls(){if(this.headers.get("Accept")==="text/csv")throw new Error("stripNulls() cannot be used with csv()");return this.shouldStripNulls=!0,this}setHeader(t,s){return this.headers=new Headers(this.headers),this.headers.set(t,s),this}retry(t){return this.retryEnabled=t,this}then(t,s){var n=this;if(this.schema===void 0||(["GET","HEAD"].includes(this.method)?this.headers.set("Accept-Profile",this.schema):this.headers.set("Content-Profile",this.schema)),this.method!=="GET"&&this.method!=="HEAD"&&this.headers.set("Content-Type","application/json"),this.shouldStripNulls){const o=this.headers.get("Accept");o==="application/vnd.pgrst.object+json"?this.headers.set("Accept","application/vnd.pgrst.object+json;nulls=stripped"):(!o||o==="application/json")&&this.headers.set("Accept","application/vnd.pgrst.array+json;nulls=stripped")}const a=this.fetch;let i=(async()=>{let o=0;for(;;){const u={};n.headers.forEach((m,x)=>{u[x]=m}),o>0&&(u["X-Retry-Count"]=String(o));let p;try{p=await a(n.url.toString(),{method:n.method,headers:u,body:JSON.stringify(n.body,(m,x)=>typeof x=="bigint"?x.toString():x),signal:n.signal})}catch(m){if((m==null?void 0:m.name)==="AbortError"||(m==null?void 0:m.code)==="ABORT_ERR"||!uR.includes(n.method))throw m;if(n.retryEnabled&&o<dR){const x=zC(o);o++,await OC(x,n.signal);continue}throw m}if(lH(n.method,p.status,o,n.retryEnabled)){var l,c;const m=(l=(c=p.headers)===null||c===void 0?void 0:c.get("Retry-After"))!==null&&l!==void 0?l:null,x=m!==null?Math.max(0,parseInt(m,10)||0)*1e3:zC(o);await p.text(),o++,await OC(x,n.signal);continue}return await n.processResponse(p)}})();return this.shouldThrowOnError||(i=i.catch(o=>{var l;let c="",u="",p="";const m=o==null?void 0:o.cause;if(m){var x,h,y,v;const b=(x=m==null?void 0:m.message)!==null&&x!==void 0?x:"",f=(h=m==null?void 0:m.code)!==null&&h!==void 0?h:"";c=`${(y=o==null?void 0:o.name)!==null&&y!==void 0?y:"FetchError"}: ${o==null?void 0:o.message}`,c+=` 1122 1123Caused by: ${(v=m==null?void 0:m.name)!==null&&v!==void 0?v:"Error"}: ${b}`,f&&(c+=` (${f})`),m!=null&&m.stack&&(c+=` 1124${m.stack}`)}else{var g;c=(g=o==null?void 0:o.stack)!==null&&g!==void 0?g:""}const N=this.url.toString().length;return(o==null?void 0:o.name)==="AbortError"||(o==null?void 0:o.code)==="ABORT_ERR"?(p="",u="Request was aborted (timeout or manual cancellation)",N>this.urlLengthLimit&&(u+=`. Note: Your request URL is ${N} characters, which may exceed server limits. If selecting many fields, consider using views. If filtering with large arrays (e.g., .in('id', [many IDs])), consider using an RPC function to pass values server-side.`)):((m==null?void 0:m.name)==="HeadersOverflowError"||(m==null?void 0:m.code)==="UND_ERR_HEADERS_OVERFLOW")&&(p="",u="HTTP headers exceeded server limits (typically 16KB)",N>this.urlLengthLimit&&(u+=`. Your request URL is ${N} characters. If selecting many fields, consider using views. If filtering with large arrays (e.g., .in('id', [200+ IDs])), consider using an RPC function instead.`)),{success:!1,error:{message:`${(l=o==null?void 0:o.name)!==null&&l!==void 0?l:"FetchError"}: ${o==null?void 0:o.message}`,details:c,hint:u,code:p},data:null,count:null,status:0,statusText:""}}
1124)),i.then(t,s)}async processResponse(t){var s=this;let n=null,a=null,r=null,i=t.status,o=t.statusText;if(t.ok){var l,c;if(s.method!=="HEAD"){var u;const h=await t.text();if(h!=="")if(s.headers.get("Accept")==="text/csv")a=h;else if(s.headers.get("Accept")&&(!((u=s.headers.get("Accept"))===null||u===void 0)&&u.includes("application/vnd.pgrst.plan+text")))a=h;else try{a=JSON.parse(h)}catch{if(n={message:h},a=null,s.shouldThrowOnError)throw new ov({message:h,details:"",hint:"",code:""})}}const m=(l=s.headers.get("Prefer"))===null||l===void 0?void 0:l.match(/count=(exact|planned|estimated)/),x=(c=t.headers.get("content-range"))===null||c===void 0?void 0:c.split("/");if(m&&x&&x.length>1&&(r=parseInt(x[1])),s.isMaybeSingle&&Array.isArray(a))if(a.length>1){if(n={code:"PGRST116",details:`Results contain ${a.length} rows, application/vnd.pgrst.object+json requires 1 row`,hint:null,message:"JSON object requested, multiple (or no) rows returned"},a=null,r=null,i=406,o="Not Acceptable",s.shouldThrowOnError){var p;throw new ov(qu(qu({},n),{},{hint:(p=n.hint)!==null&&p!==void 0?p:""}))}}else a.length===1?a=a[0]:a=null}else{const m=await t.text();try{n=JSON.parse(m),Array.isArray(n)&&t.status===404&&(a=[],n=null,i=200,o="OK")}catch{t.status===404&&m===""?(i=204,o="No Content"):n={message:m}}if(n&&s.shouldThrowOnError)throw new ov(n)}return{success:n===null,error:n,data:a,count:r,status:i,statusText:o}}returns(){return this}overrideTypes(){return this}},dH=class extends cH{throwOnError(){return super.throwOnError()}select(t){let s=!1;const n=(t??"*").split("").map(a=>/\s/.test(a)&&!s?"":(a==='"'&&(s=!s),a)).join("");return this.url.searchParams.set("select",n),this.headers.append("Prefer","return=representation"),this}order(t,{ascending:s=!0,nullsFirst:n,foreignTable:a,referencedTable:r=a}={}){const i=r?`${r}.order`:"order",o=this.url.searchParams.get(i);return this.url.searchParams.set(i,`${o?`${o},`:""}${t}.${s?"asc":"desc"}${n===void 0?"":n?".nullsfirst":".nullslast"}`),this}limit(t,{foreignTable:s,referencedTable:n=s}={}){const a=typeof n>"u"?"limit":`${n}.limit`;return this.url.searchParams.set(a,`${t}`),this}range(t,s,{foreignTable:n,referencedTable:a=n}={}){const r=typeof a>"u"?"offset":`${a}.offset`,i=typeof a>"u"?"limit":`${a}.limit`;return this.url.searchParams.set(r,`${t}`),this.url.searchParams.set(i,`${s-t+1}`),this}abortSignal(t){return this.signal=t,this}single(){return this.headers.set("Accept","application/vnd.pgrst.object+json"),this}maybeSingle(){return this.isMaybeSingle=!0,this}csv(){return this.headers.set("Accept","text/csv"),this}geojson(){return this.headers.set("Accept","application/geo+json"),this}explain({analyze:t=!1,verbose:s=!1,settings:n=!1,buffers:a=!1,wal:r=!1,format:i="text"}={}){var o;const l=[t?"analyze":null,s?"verbose":null,n?"settings":null,a?"buffers":null,r?"wal":null].filter(Boolean).join("|"),c=(o=this.headers.get("Accept"))!==null&&o!==void 0?o:"application/json";return this.headers.set("Accept",`application/vnd.pgrst.plan+${i}; for="${c}"; options=${l};`),i==="json"?this:this}rollback(){return this.headers.append("Prefer","tx=rollback"),this}returns(){return this}maxAffected(t){return this.headers.append("Prefer","handling=strict"),this.headers.append("Prefer",`max-affected=${t}`),this}};const MC=new RegExp("[,()]");var Nu=class extends dH{throwOnError(){return super.throwOnError()}eq(t,s){return this.url.searchParams.append(t,`eq.${s}`),this}neq(t,s){return this.url.searchParams.append(t,`neq.${s}`),this}gt(t,s){return this.url.searchParams.append(t,`gt.${s}`),this}gte(t,s){return this.url.searchParams.append(t,`gte.${s}`),this}lt(t,s){return this.url.searchParams.append(t,`lt.${s}`),this}lte(t,s){return this.url.searchParams.append(t,`lte.${s}`),this}like(t,s){return this.url.searchParams.append(t,`like.${s}`),this}likeAllOf(t,s){return this.url.searchParams.append(t,`like(all).{${s.join(",")}}`),this}likeAnyOf(t,s){return this.url.searchParams.append(t,`like(any).{${s.join(",")}}`),this}ilike(t,s){return this.url.searchParams.append(t,`ilike.${s}`),this}ilikeAllOf(t,s){return this.url.searchParams.append(t,`ilike(all).{${s.join(",")}}`),this}ilikeAnyOf(t,s){return this.url.searchParams.append(t,`ilike(any).{${s.join(",")}}`),this}regexMatch(t,s){return this.url.searchParams.append(t,`match.${s}`),this}regexIMatch(t,s){return this.url.searchParams.append(t,`imatch.${s}`),this}is(t,s){return this.url.searchParams.append(t,`is.${s}`),this}isDistinct(t,s){return this.url.searchParams.append(t,`isdistinct.${s}`),this}in(t,s){const n=Array.from(new Set(s)).map(a=>
1124typeof a=="string"&&MC.test(a)?`"${a}"`:`${a}`).join(",");return this.url.searchParams.append(t,`in.(${n})`),this}notIn(t,s){const n=Array.from(new Set(s)).map(a=>typeof a=="string"&&MC.test(a)?`"${a}"`:`${a}`).join(",");return this.url.searchParams.append(t,`not.in.(${n})`),this}contains(t,s){return typeof s=="string"?this.url.searchParams.append(t,`cs.${s}`):Array.isArray(s)?this.url.searchParams.append(t,`cs.{${s.join(",")}}`):this.url.searchParams.append(t,`cs.${JSON.stringify(s)}`),this}containedBy(t,s){return typeof s=="string"?this.url.searchParams.append(t,`cd.${s}`):Array.isArray(s)?this.url.searchParams.append(t,`cd.{${s.join(",")}}`):this.url.searchParams.append(t,`cd.${JSON.stringify(s)}`),this}rangeGt(t,s){return this.url.searchParams.append(t,`sr.${s}`),this}rangeGte(t,s){return this.url.searchParams.append(t,`nxl.${s}`),this}rangeLt(t,s){return this.url.searchParams.append(t,`sl.${s}`),this}rangeLte(t,s){return this.url.searchParams.append(t,`nxr.${s}`),this}rangeAdjacent(t,s){return this.url.searchParams.append(t,`adj.${s}`),this}overlaps(t,s){return typeof s=="string"?this.url.searchParams.append(t,`ov.${s}`):this.url.searchParams.append(t,`ov.{${s.join(",")}}`),this}textSearch(t,s,{config:n,type:a}={}){let r="";a==="plain"?r="pl":a==="phrase"?r="ph":a==="websearch"&&(r="w");const i=n===void 0?"":`(${n})`;return this.url.searchParams.append(t,`${r}fts${i}.${s}`),this}match(t){return Object.entries(t).filter(([s,n])=>n!==void 0).forEach(([s,n])=>{this.url.searchParams.append(s,`eq.${n}`)}),this}not(t,s,n){return this.url.searchParams.append(t,`not.${s}.${n}`),this}or(t,{foreignTable:s,referencedTable:n=s}={}){const a=n?`${n}.or`:"or";return this.url.searchParams.append(a,`(${t})`),this}filter(t,s,n){return this.url.searchParams.append(t,`${s}.${n}`),this}},uH=class{constructor(t,{headers:s={},schema:n,fetch:a,urlLengthLimit:r=8e3,retry:i}){this.url=t,this.headers=new Headers(s),this.schema=n,this.fetch=a,this.urlLengthLimit=r,this.retry=i}cloneRequestState(){return{url:new URL(this.url.toString()),headers:new Headers(this.headers)}}select(t,s){const{head:n=!1,count:a}=s??{},r=n?"HEAD":"GET";let i=!1;const o=(t??"*").split("").map(u=>/\s/.test(u)&&!i?"":(u==='"'&&(i=!i),u)).join(""),{url:l,headers:c}=this.cloneRequestState();return l.searchParams.set("select",o),a&&c.append("Prefer",`count=${a}`),new Nu({method:r,url:l,headers:c,schema:this.schema,fetch:this.fetch,urlLengthLimit:this.urlLengthLimit,retry:this.retry})}insert(t,{count:s,defaultToNull:n=!0}={}){var a;const r="POST",{url:i,headers:o}=this.cloneRequestState();if(s&&o.append("Prefer",`count=${s}`),n||o.append("Prefer","missing=default"),Array.isArray(t)){const l=t.reduce((c,u)=>c.concat(Object.keys(u)),[]);if(l.length>0){const c=[...new Set(l)].map(u=>`"${u}"`);i.searchParams.set("columns",c.join(","))}}return new Nu({method:r,url:i,headers:o,schema:this.schema,body:t,fetch:(a=this.fetch)!==null&&a!==void 0?a:fetch,urlLengthLimit:this.urlLengthLimit,retry:this.retry})}upsert(t,{onConflict:s,ignoreDuplicates:n=!1,count:a,defaultToNull:r=!0}={}){var i;const o="POST",{url:l,headers:c}=this.cloneRequestState();if(c.append("Prefer",`resolution=${n?"ignore":"merge"}-duplicates`),s!==void 0&&l.searchParams.set("on_conflict",s),a&&c.append("Prefer",`count=${a}`),r||c.append("Prefer","missing=default"),Array.isArray(t)){const u=t.reduce((p,m)=>p.concat(Object.keys(m)),[]);if(u.length>0){const p=[...new Set(u)].map(m=>`"${m}"`);l.searchParams.set("columns",p.join(","))}}return new Nu({method:o,url:l,headers:c,schema:this.schema,body:t,fetch:(i=this.fetch)!==null&&i!==void 0?i:fetch,urlLengthLimit:this.urlLengthLimit,retry:this.retry})}update(t,{count:s}={}){var n;const a="PATCH",{url:r,headers:i}=this.cloneRequestState();return s&&i.append("Prefer",`count=${s}`),new Nu({method:a,url:r,headers:i,schema:this.schema,body:t,fetch:(n=this.fetch)!==null&&n!==void 0?n:fetch,urlLengthLimit:this.urlLengthLimit,retry:this.retry})}delete({count:t}={}){var s;const n="DELETE",{url:a,headers:r}=this.cloneRequestState();return t&&r.append("Prefer",`count=${t}`),new Nu({method:n,url:a,headers:r,schema:this.schema,fetch:(s=this.fetch)!==null&&s!==void 0?s:fetch,urlLengthLimit:this.urlLengthLimit,retry:this.retry})}},mH=class mR{constructor(s,{headers:n={},schema:a,fetch:r,timeout:i,urlLengthLimit:o=8e3,retry:l}={}){this.url=s,this.headers=new Headers(n),this.schemaName=a,this.urlLengthLimit=o;const c=r??globalThis.fetch;i!==void 0&&i>0?this.fetch=(u,p)=>{const m=new AbortController,x=setTimeout(()=>m.abort(),i),h=p==null?void 0:p.signal;if(h){if(h.aborted)return clearTimeout(x),c(u,p);const y=()=>{clearTimeout(x),m.abort()};return h.addEventListener("abort",y,{once:!0}),c(u,qu(qu({},p),{},{signal:m.signal})).finally(()=>{clearTimeout(x),h.removeEventListener("abort",y)})}return c(u,qu(qu({},p),{},{signal:m.signal})).finally(()=>clearTimeout(x))}:this.fetch=c,this.retry=l}
1124from(s){if(!s||typeof s!="string"||s.trim()==="")throw new Error("Invalid relation name: relation must be a non-empty string.");return new uH(new URL(`${this.url}/${s}`),{headers:new Headers(this.headers),schema:this.schemaName,fetch:this.fetch,urlLengthLimit:this.urlLengthLimit,retry:this.retry})}schema(s){return new mR(this.url,{headers:this.headers,schema:s,fetch:this.fetch,urlLengthLimit:this.urlLengthLimit,retry:this.retry})}rpc(s,n={},{head:a=!1,get:r=!1,count:i}={}){var o;let l;const c=new URL(`${this.url}/rpc/${s}`);let u;const p=h=>h!==null&&typeof h=="object"&&(!Array.isArray(h)||h.some(p)),m=a&&Object.values(n).some(p);m?(l="POST",u=n):a||r?(l=a?"HEAD":"GET",Object.entries(n).filter(([h,y])=>y!==void 0).map(([h,y])=>[h,Array.isArray(y)?`{${y.join(",")}}`:`${y}`]).forEach(([h,y])=>{c.searchParams.append(h,y)})):(l="POST",u=n);const x=new Headers(this.headers);return m?x.set("Prefer",i?`count=${i},return=minimal`:"return=minimal"):i&&x.set("Prefer",`count=${i}`),new Nu({method:l,url:c,headers:x,schema:this.schemaName,body:u,fetch:(o=this.fetch)!==null&&o!==void 0?o:fetch,urlLengthLimit:this.urlLengthLimit,retry:this.retry})}};class pH{constructor(){}static detectEnvironment(){var s;if(typeof WebSocket<"u")return{type:"native",wsConstructor:WebSocket};const n=globalThis;if(typeof globalThis<"u"&&typeof n.WebSocket<"u")return{type:"native",wsConstructor:n.WebSocket};const a=typeof global<"u"?global:void 0;if(a&&typeof a.WebSocket<"u")return{type:"native",wsConstructor:a.WebSocket};if(typeof globalThis<"u"&&typeof n.WebSocketPair<"u"&&typeof globalThis.WebSocket>"u")return{type:"cloudflare",error:"Cloudflare Workers detected. WebSocket clients are not supported in Cloudflare Workers.",workaround:"Use Cloudflare Workers WebSocket API for server-side WebSocket handling, or deploy to a different runtime."};if(typeof globalThis<"u"&&n.EdgeRuntime||typeof navigator<"u"&&(!((s=navigator.userAgent)===null||s===void 0)&&s.includes("Vercel-Edge")))return{type:"unsupported",error:"Edge runtime detected (Vercel Edge/Netlify Edge). WebSockets are not supported in edge functions.",workaround:"Use serverless functions or a different deployment target for WebSocket functionality."};const r=globalThis.process;if(r){const i=r.versions;if(i&&i.node)return{type:"unsupported",error:"Node.js detected but native WebSocket not found.",workaround:"Ensure you are running Node.js 22+ or provide a WebSocket implementation via the transport option."}}return{type:"unsupported",error:"Unknown JavaScript runtime without WebSocket support.",workaround:"Ensure you're running in a supported environment (browser, Node.js, Deno) or provide a custom WebSocket implementation."}}static getWebSocketConstructor(){const s=this.detectEnvironment();if(s.wsConstructor)return s.wsConstructor;let n=s.error||"WebSocket not supported in this environment.";throw s.workaround&&(n+=` 1125 1126Suggested solution: ${s.workaround}`),new Error(n)}static isWebSocketSupported(){try{return this.detectEnvironment().type==="native"}catch{return!1}}}const hH="2.112.3",xH=`realtime-js/${hH}`,fH="1.0.0",pR="2.0.0",gH=pR,yH=1e4,bH=100,bl={closed:"closed",errored:"errored",joined:"joined",joining:"joining",leaving:"leaving"},hR={close:"phx_close",error:"phx_error",join:"phx_join",leave:"phx_leave",access_token:"access_token"},C2={connecting:"connecting",closing:"closing",closed:"closed"};class vH{constructor(s){this.HEADER_LENGTH=1,this.USER_BROADCAST_PUSH_META_LENGTH=6,this.KINDS={userBroadcastPush:3,userBroadcast:4},this.BINARY_ENCODING=0,this.JSON_ENCODING=1,this.BROADCAST_EVENT="broadcast",this.allowedMetadataKeys=[],this.allowedMetadataKeys=s??[]}encode(s,n){if(s.event===this.BROADCAST_EVENT&&!(s.payload instanceof ArrayBuffer)&&typeof s.payload.event=="string")return n(this._binaryEncodeUserBroadcastPush(s));let a=[s.join_ref,s.ref,s.topic,s.event,s.payload];return n(JSON.stringify(a))}_binaryEncodeUserBroadcastPush(s){var n;return this._isArrayBuffer((n=s.payload)===null||n===void 0?void 0:n.payload)?this._encodeBinaryUserBroadcastPush(s):this._encodeJsonUserBroadcastPush(s)}_encodeBinaryUserBroadcastPush(s){var n,a;const r=(a=(n=s.payload)===null||n===void 0?void 0:n.payload)!==null&&a!==void 0?a:new ArrayBuffer(0);return this._encodeUserBroadcastPush(s,this.BINARY_ENCODING,r)}_encodeJsonUserBroadcastPush(s){var n,a;const r=(a=(n=s.payload)===null||n===void 0?void 0:n.payload)!==null&&a!==void 0?a:{},o=new TextEncoder().encode(JSON.stringify(r)).buffer;return this._encodeUserBroadcastPush(s,this.JSON_ENCODING,o)}_encodeUserBroadcastPush(s,n,a){var r,i;const o=new TextEncoder,l=o.encode(s.topic),c=o.encode((r=s.ref)!==null&&r!==void 0?r:""),u=o.encode((i=s.join_ref)!==null&&i!==void 0?i:""),p=o.encode(s.payload.event),m=this.allowedMetadataKeys?this._pick(s.payload,this.allowedMetadataKeys):{},x=o.encode(Object.keys(m).length===0?"":JSON.stringify(m));if(u.length>255)throw new Error(`joinRef length ${u.length} exceeds maximum of 255`);if(c.length>255)throw new Error(`ref length ${c.length} exceeds maximum of 255`);if(l.length>255)throw new Error(`topic length ${l.length} exceeds maximum of 255`);if(p.length>255)throw new Error(`userEvent length ${p.length} exceeds maximum of 255`);if(x.length>255)throw new Error(`metadata length ${x.length} exceeds maximum of 255`);const h=this.USER_BROADCAST_PUSH_META_LENGTH+u.length+c.length+l.length+p.length+x.length,y=new ArrayBuffer(this.HEADER_LENGTH+h),v=new DataView(y),g=new Uint8Array(y);let N=0;v.setUint8(N++,this.KINDS.userBroadcastPush),v.setUint8(N++,u.length),v.setUint8(N++,c.length),v.setUint8(N++,l.length),v.setUint8(N++,p.length),v.setUint8(N++,x.length),v.setUint8(N++,n),g.set(u,N),N+=u.length,g.set(c,N),N+=c.length,g.set(l,N),N+=l.length,g.set(p,N),N+=p.length,g.set(x,N),N+=x.length;var b=new Uint8Array(y.byteLength+a.byteLength);return b.set(new Uint8Array(y),0),b.set(new Uint8Array(a),y.byteLength),b.buffer}
1126decode(s,n){if(this._isArrayBuffer(s)){let a=this._binaryDecode(s);return n(a)}if(typeof s=="string"){const a=JSON.parse(s),[r,i,o,l,c]=a;return n({join_ref:r,ref:i,topic:o,event:l,payload:c})}return n({})}_binaryDecode(s){const n=new DataView(s),a=n.getUint8(0),r=new TextDecoder;switch(a){case this.KINDS.userBroadcast:return this._decodeUserBroadcast(s,n,r)}}_decodeUserBroadcast(s,n,a){const r=n.getUint8(1),i=n.getUint8(2),o=n.getUint8(3),l=n.getUint8(4);let c=this.HEADER_LENGTH+4;const u=a.decode(s.slice(c,c+r));c=c+r;const p=a.decode(s.slice(c,c+i));c=c+i;const m=a.decode(s.slice(c,c+o));c=c+o;const x=s.slice(c,s.byteLength),h=l===this.JSON_ENCODING?JSON.parse(a.decode(x)):x,y={type:this.BROADCAST_EVENT,event:p,payload:h};return o>0&&(y.meta=JSON.parse(m)),{join_ref:null,ref:null,topic:u,event:this.BROADCAST_EVENT,payload:y}}_isArrayBuffer(s){var n;return s instanceof ArrayBuffer||((n=s==null?void 0:s.constructor)===null||n===void 0?void 0:n.name)==="ArrayBuffer"}_pick(s,n){return!s||typeof s!="object"?{}:Object.fromEntries(Object.entries(s).filter(([a])=>n.includes(a)))}}var ss;(function(t){t.abstime="abstime",t.bool="bool",t.date="date",t.daterange="daterange",t.float4="float4",t.float8="float8",t.int2="int2",t.int4="int4",t.int4range="int4range",t.int8="int8",t.int8range="int8range",t.json="json",t.jsonb="jsonb",t.money="money",t.numeric="numeric",t.oid="oid",t.reltime="reltime",t.text="text",t.time="time",t.timestamp="timestamp",t.timestamptz="timestamptz",t.timetz="timetz",t.tsrange="tsrange",t.tstzrange="tstzrange"})(ss||(ss={}));const BC=(t,s,n={})=>{var a;const r=(a=n.skipTypes)!==null&&a!==void 0?a:[];return s?Object.keys(s).reduce((i,o)=>(i[o]=jH(o,t,s,r),i),{}):{}},jH=(t,s,n,a)=>{const r=s.find(l=>l.name===t),i=r==null?void 0:r.type,o=n[t];return i&&!a.includes(i)?xR(i,o):A2(o)},xR=(t,s)=>{if(t.charAt(0)==="_"){const n=t.slice(1,t.length);return kH(s,n)}switch(t){case ss.bool:return wH(s);case ss.float4:case ss.float8:case ss.int2:case ss.int4:case ss.int8:case ss.numeric:case ss.oid:return NH(s);case ss.json:case ss.jsonb:return _H(s);case ss.timestamp:return SH(s);case ss.abstime:case ss.date:case ss.daterange:case ss.int4range:case ss.int8range:case ss.money:case ss.reltime:case ss.text:case ss.time:case ss.timestamptz:case ss.timetz:case ss.tsrange:case ss.tstzrange:return A2(s);default:return A2(s)}},A2=t=>t,wH=t=>{switch(t){case"t":return!0;case"f":return!1;default:return t}},NH=t=>{if(typeof t=="string"){const s=parseFloat(t);if(!Number.isNaN(s))return s}return t},_H=t=>{if(typeof t=="string")try{return JSON.parse(t)}catch{return t}return t},kH=(t,s)=>{if(typeof t!="string")return t;const n=t.length-1,a=t[n];if(t[0]==="{"&&a==="}"){let i;const o=t.slice(1,n);try{i=JSON.parse("["+o+"]")}catch{i=o?o.split(","):[]}return i.map(l=>xR(s,l))}return t},SH=t=>typeof t=="string"?t.replace(" ","T"):t,fR=t=>{const s=new URL(t);return s.protocol=s.protocol.replace(/^ws/i,"http"),s.pathname=s.pathname.replace(/\/+$/,"").replace(/\/socket\/websocket$/i,"").replace(/\/socket$/i,"").replace(/\/websocket$/i,""),s.pathname===""||s.pathname==="/"?s.pathname="/api/broadcast":s.pathname=s.pathname+"/api/broadcast",s.href};var am=t=>typeof t=="function"?t:function(){return t},CH=typeof self<"u"?self:null,_u=typeof window<"u"?window:null,bi=CH||_u||globalThis,AH="2.0.0",EH=1e4,FH=1e3,TH=100,_i={connecting:0,open:1,closing:2,closed:3},ra={closed:"closed",errored:"errored",joined:"joined",joining:"joining",leaving:"leaving"},ao={close:"phx_close",error:"phx_error",join:"phx_join",reply:"phx_reply",leave:"phx_leave"},E2={longpoll:"longpoll",websocket:"websocket"},PH={complete:4},F2="base64url.bearer.phx.",Df=class{constructor(t,s,n,a){this.channel=t,this.event=s,this.payload=n||function(){return{}},this.receivedResp=null,this.timeout=a,this.timeoutTimer=null,this.recHooks=[],this.sent=!1,this.ref=void 0}resend(t){this.timeout=t,this.reset(),this.send()}send(){this.hasReceived("timeout")||(this.startTimeout(),this.sent=!0,this.channel.socket.push({topic:this.channel.topic,event:this.event,payload:this.payload(),ref:this.ref,join_ref:this.channel.joinRef()}))}receive(t,s){return this.hasReceived(t)&&s(this.receivedResp.response),this.recHo
vendor: 21,307 bytes, lines 1126-1127
1126oks.push({status:t,callback:s}),this}reset(){this.cancelRefEvent(),this.ref=null,this.refEvent=null,this.receivedResp=null,this.sent=!1}destroy(){this.cancelRefEvent(),this.cancelTimeout()}matchReceive({status:t,response:s,_ref:n}){this.recHooks.filter(a=>a.status===t).forEach(a=>a.callback(s))}cancelRefEvent(){this.refEvent&&this.channel.off(this.refEvent)}cancelTimeout(){clearTimeout(this.timeoutTimer),this.timeoutTimer=null}startTimeout(){this.timeoutTimer&&this.cancelTimeout(),this.ref=this.channel.socket.makeRef(),this.refEvent=this.channel.replyEventName(this.ref),this.channel.on(this.refEvent,t=>{this.cancelRefEvent(),this.cancelTimeout(),this.receivedResp=t,this.matchReceive(t)}),this.timeoutTimer=setTimeout(()=>{this.trigger("timeout",{})},this.timeout)}hasReceived(t){return this.receivedResp&&this.receivedResp.status===t}trigger(t,s){this.channel.trigger(this.refEvent,{status:t,response:s})}},gR=class{constructor(t,s){this.callback=t,this.timerCalc=s,this.timer=void 0,this.tries=0}reset(){this.tries=0,clearTimeout(this.timer)}scheduleTimeout(){clearTimeout(this.timer),this.timer=setTimeout(()=>{this.tries=this.tries+1,this.callback()},this.timerCalc(this.tries+1))}},DH=class{constructor(t,s,n){this.state=ra.closed,this.topic=t,this.params=am(s||{}),this.socket=n,this.bindings=[],this.bindingRef=0,this.timeout=this.socket.timeout,this.joinedOnce=!1,this.joinPush=new Df(this,ao.join,this.params,this.timeout),this.pushBuffer=[],this.stateChangeRefs=[],this.rejoinTimer=new gR(()=>{this.socket.isConnected()&&this.rejoin()},this.socket.rejoinAfterMs),this.stateChangeRefs.push(this.socket.onError(()=>this.rejoinTimer.reset())),this.stateChangeRefs.push(this.socket.onOpen(()=>{this.rejoinTimer.reset(),this.isErrored()&&this.rejoin()})),this.joinPush.receive("ok",()=>{this.state=ra.joined,this.rejoinTimer.reset(),this.pushBuffer.forEach(a=>a.send()),this.pushBuffer=[]}),this.joinPush.receive("error",a=>{this.state=ra.errored,this.socket.hasLogger()&&this.socket.log("channel",`error ${this.topic}`,a),this.socket.isConnected()&&this.rejoinTimer.scheduleTimeout()}),this.onClose(()=>{this.rejoinTimer.reset(),this.socket.hasLogger()&&this.socket.log("channel",`close ${this.topic}`),this.state=ra.closed,this.socket.remove(this)}),this.onError(a=>{this.socket.hasLogger()&&this.socket.log("channel",`error ${this.topic}`,a),this.isJoining()&&this.joinPush.reset(),this.state=ra.errored,this.socket.isConnected()&&this.rejoinTimer.scheduleTimeout()}),this.joinPush.receive("timeout",()=>{this.socket.hasLogger()&&this.socket.log("channel",`timeout ${this.topic}`,this.joinPush.timeout),new Df(this,ao.leave,am({}),this.timeout).send(),this.state=ra.errored,this.joinPush.reset(),this.socket.isConnected()&&this.rejoinTimer.scheduleTimeout()}),this.on(ao.reply,(a,r)=>{this.trigger(this.replyEventName(r),a)})}join(t=this.timeout){if(this.joinedOnce)throw new Error("tried to join multiple times. 'join' can only be called a single time per channel instance");return this.timeout=t,this.joinedOnce=!0,this.rejoin(),this.joinPush}teardown(){this.pushBuffer.forEach(t=>t.destroy()),this.pushBuffer=[],this.rejoinTimer.reset(),this.joinPush.destroy(),this.state=ra.closed,this.bindings=[]}onClose(t){this.on(ao.close,t)}onError(t){return this.on(ao.error,s=>t(s))}on(t,s){let n=this.bindingRef++;return this.bindings.push({event:t,ref:n,callback:s}),n}off(t,s){this.bindings=this.bindings.filter(n=>!(n.event===t&&(typeof s>"u"||s===n.ref)))}canPush(){return this.socket.isConnected()&&this.isJoined()}push(t,s,n=this.timeout){if(s=s||{},!this.joinedOnce)throw new Error(`tried to push '${t}' to '${this.topic}' before joining. Use channel.join() before pushing events`);let a=new Df(this,t,function(){return s},n);return this.canPush()?a.send():(a.startTimeout(),this.pushBuffer.push(a)),a}leave(t=this.timeout){this.rejoinTimer.reset(),this.joinPush.cancelTimeout(),this.state=ra.leaving;let s=()=>{this.socket.hasLogger()&&this.socket.log("channel",`leave ${this.topic}`),this.trigger(ao.close,"leave")},n=new Df(this,ao.leave,am({}),t);return n.receive("ok",()=>s()).receive("timeout",()=>s()),n.send(),this.canPush()||n.trigger("ok",{}),n}onMessage(t,s,n){return s}filterBindings(t,s,n){return!0}isMember(t,s,n,a){return this.topic!==t?!1:a&&a!==this.joinRef()?(this.socket.hasLogger()&&this.socket.log("channel","dropping outdated message",{topic:t,event:s,payload:n,joinRef:a}),!1):!0}joinRef(){return this.joinPush.ref}rejoin(t=this.timeout){this.isLeaving()||(this.socket.leaveOpenTopic(this.topic),this.state=ra.joining,this.joinPush.resend(t))}trigger(t,s,n,a){let r=this.onMessage(t,s,n,a);if(s&&!r)throw new Error("channel onMessage callbacks must return the payload, modified or unmodified");let i=this.bindings.filter(o=>o.event===t&&this.filterBindings(o,s,n));for(let o=0;o<i.length;o++)i[o].callback(r,n,a||this.joinRef())}replyEventName(t){return`chan_reply_${t}`}isClosed(){return this.state===ra.closed}isErrored(){return this.state===ra.errored}isJoined(){return this.state===ra.joined}isJoining(){return this.state===ra.joining}isLeaving(){return this.state===ra.leaving}},$y=class{static request(t,s,n,a,r,i,o){if(bi.XDomainRequest){let l=new bi.XDomainRequest;return this.xdomainRequest(l,t,s,a,r,i,o)}else if(bi.XMLHttpRequest){let l=new bi.XMLHttpRequest;return this.xhrRequest(l,t,s,n,a,r,i,o)}else{if(bi.fetch&&bi.AbortController)return this.fetchRequest(t,s,n,a,r,i,o);throw new Error("No suitable XMLHttpRequest implementation found")}}static fetchRequest(t,s,n,a,r,i,o){let l={method:t,headers:n,body:a},c=null;return r&&(c=new AbortController,setTimeout(()=>c.abort(),r),l.signal=c.signal),bi.fetch(s,l).then(u=>u.text()).then(u=>this.parseJSON(u)).then(u=>o&&o(u)).catch(u=>{u.name==="AbortError"&&i?i():o&&o(null)}),c}static xdomainRequest(t,s,n,a,r,i,o){return t.timeout=r,t.open(s,n),t.onload=()=>{let l=this.parseJSON(t.responseText);o&&o(l)},i&&(t.ontimeout=i),t.onprogress=()=>{},t.send(a),t}static xhrRequest(t,s,n,a,r,i,o,l){t.open(s,n,!0),t.timeout=i;for(let[c,u]of Object.entries(a))t.setRequestHeader(c,u);return t.onerror=()=>l&&l(null),t.onreadystatechange=()=>{if(t.readyState===PH.complete&&l){let c=this.parseJSON(t.responseText);l(c)}},o&&(t.ontimeout=o),t.send(r),t}static parseJSON(t){if(!t||t==="")return null;try{return JSON.parse(t)}catch{return console&&console.log("failed to parse JSON response",t),null}}static serialize(t,s){let n=[];for(var a in t){if(!Object.prototype.hasOwnProperty.call(t,a))continue;let r=s?`${s}[${a}]`:a,i=t[a];typeof i=="object"?n.push(this.serialize(i,r)):n.push(encodeURIComponent(r)+"="+encodeURIComponent(i))}return n.join("&")}static appendParams(t,s){if(Object.keys(s).length===0)return t;let n=t.match(/\?/)?"&":"?";return`${t}${n}${this.serialize(s)}`}},RH=t=>{let s="",n=new Uint8Array(t),a=n.byteLength;for(let r=0;r<a;r++)s+=String.fromCharCode(n[r]);return btoa(s)},Vd=class{constructor(t,s){s&&s.length===2&&s[1].startsWith(F2)&&(this.authToken=atob(s[1].slice(F2.length))),this.endPoint=null,this.token=null,this.skipHeartbeat=!0,this.reqs=new Set,this.awaitingBatchAck=!1,this.currentBatch=null,this.currentBatchTimer=null,this.batchBuffer=[],this.onopen=function(){},this.onerror=function(){},this.onmessage=function(){},this.onclose=function(){},this.pollEndpoint=this.normalizeEndpoint(t),this.readyState=_i.connecting,setTimeout(()=>this.poll(),0)}normalizeEndpoint(t){return t.replace("ws://","http://").replace("wss://","https://").replace(new RegExp("(.*)/"+E2.websocket),"$1/"+E2.longpoll)}endpointURL(){return $y.appendParams(this.pollEndpoint,{token:this.token})}closeAndRetry(t,s,n){this.close(t,s,n),this.readyState=_i.connecting}ontimeout(){this.onerror("timeout"),this.closeAndRetry(1005,"timeout",!1)}isActive(){return this.readyState===_i.open||this.readyState===_i.connecting}poll(){const t={Accept:"application/json"};this.authToken&&(t["X-Phoenix-AuthToken"]=this.authToken),this.ajax("GET",t,null,()=>this.ontimeout(),s=>{if(s){var{status:n,token:a,messages:r}=s;if(n===410&&this.token!==null){this.onerror(410),this.closeAndRetry(3410,"session_gone",!1);return}this.token=a}else n=0;switch(n){case 200:r.forEach(i=>{setTimeout(()=>this.onmessage({data:i}),0)}),this.poll();break;case 204:this.poll();break;case 410:this.readyState=_i.open,this.onopen({}),this.poll();break;case 403:this.onerror(403),this.close(1008,"forbidden",!1);break;case 0:case 500:this.onerror(500),this.closeAndRetry(1011,"internal server error",500);break;default:throw new Error(`unhandled poll status ${n}`)}})}send(t){typeof t!="string"&&(t=RH(t)),this.currentBatch?this.currentBatch.push(t):this.awaitingBatchAck?this.batchBuffer.push(t):(this.currentBatch=[t],this.currentBatchTimer=setTimeout(()=>{this.batchSend(this.currentBatch),this.currentBatch=null},0))}batchSend(t,s=0){this.awaitingBatchAck=!0;const n=s+TH,a=t.slice(s,n);this.ajax("POST",{"Content-Type":"application/x-ndjson"},a.join(` 1127`),()=>this.onerror("timeout"),r=>{!r||r.status!==200?(this.awaitingBatchAck=!1,this.onerror(r&&r.status),this.closeAndRetry(1011,"internal server error",!1)):n<t.length?this.batchSend(t,n):this.batchBuffer.length>0?(this.batchSend(this.batchBuffer),this.batchBuffer=[]):this.awaitingBatchAck=!1})}close(t,s,n){for(let r of this.reqs)r.abort();this.readyState=_i.closed;let a=Object.assign({code:1e3,reason:void 0,wasClean:!0},{code:t,reason:s,wasClean:n});this.batchBuffer=[],clearTimeout(this.currentBatchTimer),this.currentBatchTimer=null,typeof CloseEvent<"u"?this.onclose(new CloseEvent("close",a)):this.onclose(a)}ajax(t,s,n,a,r){let i,o=()=>{this.reqs.delete(i),a()};i=$y.request(t,this.endpointURL(),s,n,this.timeout,o,l=>{this.reqs.delete(i),this.isActive()&&r(l)}),this.reqs.add(i)}},IH=class ah{constructor(s,n={}){let a=n.events||{state:"presence_state",diff:"presence_diff"};this.state=Object.create(null),this.pendingDiffs=[],this.channel=s,this.joinRef=null,this.caller={onJoin:function(){},onLeave:function(){},onSync:function(){}},this.channel.on(a.state,r=>{let{onJoin:i,onLeave:o,onSync:l}=this.caller;this.joinRef=this.channel.joinRef(),this.state=ah.syncState(this.state,r,i,o),this.pendingDiffs.forEach(c=>{this.state=ah.syncDiff(this.state,c,i,o)}),this.pendingDiffs=[],l()}),this.channel.on(a.diff,r=>{let{onJoin:i,onLeave:o,onSync:l}=this.caller;this.inPendingSyncState()?this.pendingDiffs.push(r):(this.state=ah.syncDiff(this.state,r,i,o),l())})}onJoin(s){this.caller.onJoin=s}onLeave(s){this.caller.onLeave=s}onSync(s){this.caller.onSync=s}list(s){return ah.list(this.state,s)}inPendingSyncState(){return!this.joinRef||this.joinRef!==this.channel.joinRef()}static syncState(s,n,a,r){let i=this.toNullProtoObj(this.clone(s));n=this.toNullProtoObj(n);let o=Object.create(null),l=Object.create(null);return this.map(i,(c,u)=>{n[c]||(l[c]=u)}),this.map(n,(c,u)=>{let p=i[c];if(p){let m=u.metas.map(v=>v.phx_ref),x=p.metas.map(v=>v.phx_ref),h=u.metas.filter(v=>x.indexOf(v.phx_ref)<0),y=p.metas.filter(v=>m.indexOf(v.phx_ref)<0);h.length>0&&(o[c]=u,o[c].metas=h),y.length>0&&(l[c]=this.clone(p),l[c].metas=y)}else o[c]=u}),this.syncDiff(i,{joins:o,leaves:l},a,r)}static syncDiff(s,n,a,r){s=this.toNullProtoObj(s);let{joins:i,leaves:o}=this.clone(n);return a||(a=function(){}),r||(r=function(){}),this.map(i,(l,c)=>{let u=s[l];if(s[l]=this.clone(c),u){let p=s[l].metas.map(x=>x.phx_ref),m=u.metas.filter(x=>p.indexOf(x.phx_ref)<0);s[l].metas.unshift(...m)}a(l,u,c)}),this.map(o,(l,c)=>{let u=s[l];if(!u)return;let p=c.metas.map(m=>m.phx_ref);u.metas=u.metas.filter(m=>p.indexOf(m.phx_ref)<0),r(l,u,c),u.metas.length===0&&delete s[l]}),s}static list(s,n){return n||(n=function(a,r){return r}),this.map(s,(a,r)=>n(a,r))}static map(s,n){return Object.getOwnPropertyNames(s).map(a=>n(a,s[a]))}static toNullProtoObj(s){if(Object.getPrototypeOf(s)===null)return s;let n=Object.create(null);return Object.getOwnPropertyNames(s).forEach(a=>{n[a]=s[a]}),n}static clone(s){return JSON.parse(JSON.stringify(s))}},Rf={HEADER_LENGTH:1,META_LENGTH:4,KINDS:{push:0,reply:1,broadcast:2},encode(t,s){if(t.payload.constructor===ArrayBuffer)return s(this.binaryEncode(t));{let n=[t.join_ref,t.ref,t.topic,t.event,t.payload];return s(JSON.stringify(n))}},decode(t,s){if(t.constructor===ArrayBuffer)return s(this.binaryDecode(t));{let[n,a,r,i,o]=JSON.parse(t);return s({join_ref:n,ref:a,topic:r,event:i,payload:o})}},binaryEncode(t){let{join_ref:s,ref:n,event:a,topic:r,payload:i}=t,o=new TextEncoder,l=o.encode(s),c=o.encode(n),u=o.encode(r),p=o.encode(a);this.assertFieldSize(l.byteLength,"join_ref"),this.assertFieldSize(c.byteLength,"ref"),this.assertFieldSize(u.byteLength,"topic"),this.assertFieldSize(p.byteLength,"event");let m=this.META_LENGTH+l.byteLength+c.byteLength+u.byteLength+p.byteLength,x=new ArrayBuffer(this.HEADER_LENGTH+m),h=new Uint8Array(x),y=new DataView(x),v=0;y.setUint8(v++,this.KINDS.push),y.setUint8(v++,l.byteLength),y.setUint8(v++,c.byteLength),y.setUint8(v++,u.byteLength),y.setUint8(v++,p.byteLength),h.set(l,v),v+=l.byteLength,h.set(c,v),v+=c.byteLength,h.set(u,v),v+=u.byteLength,h.set(p,v),v+=p.byteLength;var g=new Uint8Array(x.byteLength+i.byteLength);return g.set(h,0),g.set(new Uint8Array(i),x.byteLength),g.buffer},assertFieldSize(t,s){if(t>255)throw new Error(`unable to convert ${s} to binary: must be less than or equal to 255 bytes, but is ${t} bytes`)},binaryDecode(t){let s=new DataView(t),n=s.getUint8(0),a=new TextDecoder;switch(n){case this.KINDS.push:return this.decodePush(t,s,a);case this.KINDS.reply:return this.decodeReply(t,s,a);case this.KINDS.broadcast:return this.decodeBroadcast(t,s,a)}},decodePush(t,s,n){let a=s.getUint8(1),r=s.getUint8(2),i=s.getUint8(3),o=this.HEADER_LENGTH+this.META_LENGTH-1,l=n.decode(t.slice(o,o+a));o=o+a;let c=n.decode(t.slice(o,o+r));o=o+r;let u=n.decode(t.slice(o,o+i));o=o+i;let p=t.slice(o,t.byteLength);return{join_ref:l,ref:null,topic:c,event:u,payload:p}},decodeReply(t,s,n){let a=s.getUint8(1),r=s.getUint8(2),i=s.getUint8(3),o=s.getUint8(4),l=this.HEADER_LENGTH+this.META_LENGTH,c=n.decode(t.slice(l,l+a));l=l+a;let u=n.decode(t.slice(l,l+r));l=l+r;let p=n.decode(t.slice(l,l+i));l=l+i;let m=n.decode(t.slice(l,l+o));l=l+o;let x=t.slice(l,t.byteLength),h={status:m,response:x};return{join_ref:c,ref:u,topic:p,event:ao.reply,payload:h}},decodeBroadcast(t,s,n){let a=s.getUint8(1),r=s.getUint8(2),i=this.HEADER_LENGTH+2,o=n.decode(t.slice(i,i+a));i=i+a;let l=n.decode(t.slice(i,i+r));i=i+r;let c=t.slice(i,t.byteLength);return{join_ref:null,ref:null,topic:o,event:l,payload:c}}},$H=class{constructor(t,s={}){this.stateChangeCallbacks={open:[],close:[],error:[],message:[]},this.channels=[],this.sendBuffer=[],this.ref=0,this.fallbackRef=null,this.timeout=s.timeout||EH,this.transport=s.transport||bi.WebSocket||Vd,this.conn=void 0,this.primaryPassedHealthCheck=!1,this.longPollFallbackMs=s.longPollFallbackMs,this.fallbackTimer=null;let n=null;try{n=bi&&bi.sessionStorage}catch{}this.sessionStore=s.sessionStorage||n,this.establishedConnections=0,this.defaultEncoder=Rf.encode.bind(Rf),this.defaultDecoder=Rf.decode.bind(Rf),this.closeWasClean=!0,this.disconnecting=!1,this.binaryType=s.binaryType||"arraybuffer",this.connectClock=1,this.pageHidden=!1,this.encode=void 0,this.decode=void 0,this.transport!==Vd?(this.encode=s.encode||this.defaultEncoder,this.decode=s.decode||this.defaultDecoder):(this.encode=this.defaultEncoder,this.decode=this.defaultDecoder);let a=null;_u&&_u.addEventListener&&(_u.addEventListener("pagehide",r=>{this.conn&&(this.disconnect(),a=this.connectClock)}),_u.addEventListener("pageshow",r=>{a===this.connectClock&&(a=null,this.connect())}),_u.addEventListener("visibilitychange",()=>{document.visibilityState==="hidden"?this.pageHidden=!0:(this.pageHidden=!1,!this.isConnected()&&!this.closeWasClean&&this.teardown(()=>this.connect()))})),this.heartbeatIntervalMs=s.heartbeatIntervalMs||3e4,this.autoSendHeartbeat=s.autoSendHeartbeat??!0,this.heartbeatCallback=s.heartbeatCallback??(()=>{}),this.rejoinAfterMs=r=>s.rejoinAfterMs?s.rejoinAfterMs(r):[1e3,2e3,5e3][r-1]||1e4,this.reconnectAfterMs=r=>s.reconnectAfterMs?s.reconnectAfterMs(r):[10,50,100,150,200,250,500,1e3,2e3][r-1]||5e3,this.logger=s.logger||null,!this.logger&&s.debug&&(this.logger=(r,i,o)=>{console.log(`${r}: ${i}`,o)}),this.longpollerTimeout=s.longpollerTimeout||2e4,this.params=am(s.params||{}),this.endPoint=`${t}/${E2.websocket}`,this.vsn=s.vsn||AH,this.heartbeatTimeoutTimer=null,this.heartbeatTimer=null,this.heartbeatSentAt=null,this.pendingHeartbeatRef=null,this.reconnectTimer=new gR(()=>{if(this.pageHidden){this.log("Not reconnecting as page is hidden!"),this.teardown();return}this.teardown(async()=>{s.beforeReconnect&&await s.beforeReconnect(),this.connect()})},this.reconnectAfterMs),this.authToken=s.authToken&&am(s.authToken)}getLongPollTransport(){return Vd}replaceTransport(t){this.connectClock++,this.closeWasClean=!0,clearTimeout(this.fallbackTimer),this.reconnectTimer.reset(),this.conn&&(this.conn.close(),this.conn=null),this.transport=t}protocol(){return location.protocol.match(/^https/)?"wss":"ws"}endPointURL(){let t=$y.appendParams($y.appendParams(this.endPoint,this.params()),{vsn:this.vsn});return t.charAt(0)!=="/"?t:t.charAt(1)==="/"?`${this.protocol()}:${t}`:`${this.protocol()}://${location.host}${t}`}disconnect(t,s,n){this.connectClock++,this.disconnecting=!0,this.closeWasClean=!0,clearTimeout(this.fallbackTimer),this.reconnectTimer.reset(),this.teardown(()=>{this.disconnecting=!1,t&&t()},s,n)}connect(t){t&&(console&&console.log("passing params to connect is deprecated. Instead pass :params to the Socket constructor"),this.params=am(t)),!(this.conn&&!this.disconnecting)&&(this.longPollFallbackMs&&this.transport!==Vd?this.connectWithFallback(Vd,this.longPollFallbackMs):this.transportConnect())}log(t,s,n){this.logger&&this.logger(t,s,n)}hasLogger(){return this.logger!==null}onOpen(t){let s=this.makeRef();return this.stateChangeCallbacks.open.push([s,t]),s}onClose(t){let s=this.makeRef();return this.stateChangeCallbacks.close.push([s,t]),s}onError(t){let s=this.makeRef();return this.stateChangeCallbacks.error.push([s,t]),s}onMessage(t){let s=this.makeRef();return this.stateChangeCallbacks.message.push([s,t]),s}onHeartbeat(t){this.heartbeatCallback=t}ping(t){if(!this.isConnected())return!1;let s=this.makeRef(),n=Date.now();this.push({topic:"phoenix",event:"heartbeat",payload:{},ref:s});let a=this.onMessage(r=>{r.ref===s&&(this.off([a]),t(Date.now()-n))});return!0}transportName(t){switch(t){case Vd:return"LongPoll";default:return t.name}}transportConnect(){this.connectClock++,this.closeWasClean=!1;let t;this.authToken&&(t=["phoenix",`${F2}${btoa(this.authToken()).replace(/=/g,"")}`]),this.conn=new this.transport(this.endPointURL(),t),this.conn.binaryType=this.binaryType,this.conn.timeout=this.longpollerTimeout,this.conn.onopen=()=>this.onConnOpen(),this.conn.onerror=s=>this.onConnError(s),this.conn.onmessage=s=>this.onConnMessage(s),this.conn.onclose=s=>this.onConnClose(s)}getSession(t){return this.sessionStore&&this.sessionStore.getItem(t)}storeSession(t,s){this.sessionStore&&this.sessionStore.setItem(t,s)}connectWithFallback(t,s=2500){clearTimeout(this.fallbackTimer);let n=!1,a=!0,r,i,o=this.transportName(t),l=c=>{this.log("transport",`falling back to ${o}...`,c),this.off([r,i]),a=!1,this.replaceTransport(t),this.transportConnect()};if(this.getSession(`phx:fallback:${o}`))return l("memorized");this.fallbackTimer=setTimeout(l,s),i=this.onError(c=>{this.log("transport","error",c),a&&!n&&(clearTimeout(this.fallbackTimer),l(c))}),this.fallbackRef&&this.off([this.fallbackRef]),this.fallbackRef=this.onOpen(()=>{if(n=!0,!a){let c=this.transportName(t);return this.primaryPassedHealthCheck||this.storeSession(`phx:fallback:${c}`,"true"),this.log("transport",`established ${c} fallback`)}clearTimeout(this.fallbackTimer),this.fallbackTimer=setTimeout(l,s),this.ping(c=>{this.log("transport","connected to primary after",c),this.primaryPassedHealthCheck=!0,clearTimeout(this.fallbackTimer)})}),this.transportConnect()}clearHeartbeats(){clearTimeout(this.heartbeatTimer),clearTimeout(this.heartbeatTimeoutTimer)}onConnOpen(){this.hasLogger()&&this.log("transport",`connected to ${this.endPointURL()}`),this.closeWasClean=!1,this.disconnecting=!1,this.establishedConnections++,this.flushSendBuffer(),this.reconnectTimer.reset(),this.autoSendHeartbeat&&this.resetHeartbeat(),this.triggerStateCallbacks("open")}heartbeatTimeout(){if(this.pendingHeartbeatRef){this.pendingHeartbeatRef=null,this.heartbeatSentAt=null,this.hasLogger()&&this.log("transport","heartbeat timeout. Attempting to re-establish connection");try{this.heartbeatCallback("timeout")}catch(t){this.log("error","error in heartbeat callback",t)}this.triggerChanError(new Error("heartbeat timeout")),this.closeWasClean=!1,this.teardown(()=>this.reconnectTimer.scheduleTimeout(),FH,"heartbeat timeout")}}resetHeartbeat(){this.conn&&this.conn.skipHeartbeat||(this.pendingHeartbeatRef=null,this.clearHeartbeats(),this.heartbeatTimer=setTimeout(()=>this.sendHeartbeat(),this.heartbeatIntervalMs))}teardown(t,s,n){if(!this.conn)return t&&t();const a=this.conn;this.waitForBufferDone(a,()=>{s?a.close(s,n||""):a.close(),this.waitForSocketClosed(a,()=>{this.conn===a&&(this.conn.onopen=function(){},this.conn.onerror=function(){},this.conn.onmessage=function(){}
vendor: 5,018 bytes, line 1127
1127,this.conn.onclose=function(){},this.conn=null),t&&t()})})}waitForBufferDone(t,s,n=1){if(n===5||!t.bufferedAmount){s();return}setTimeout(()=>{this.waitForBufferDone(t,s,n+1)},150*n)}waitForSocketClosed(t,s,n=1){if(n===5||t.readyState===_i.closed){s();return}setTimeout(()=>{this.waitForSocketClosed(t,s,n+1)},150*n)}onConnClose(t){this.conn&&(this.conn.onclose=()=>{}),this.hasLogger()&&this.log("transport","close",t),this.triggerChanError(t),this.clearHeartbeats(),this.closeWasClean||this.reconnectTimer.scheduleTimeout(),this.triggerStateCallbacks("close",t)}onConnError(t){this.hasLogger()&&this.log("transport","error",t);let s=this.transport,n=this.establishedConnections;this.triggerStateCallbacks("error",t,s,n),(s===this.transport||n>0)&&this.triggerChanError(t)}triggerChanError(t){this.channels.forEach(s=>{s.isErrored()||s.isLeaving()||s.isClosed()||s.trigger(ao.error,t)})}connectionState(){switch(this.conn&&this.conn.readyState){case _i.connecting:return"connecting";case _i.open:return"open";case _i.closing:return"closing";default:return"closed"}}isConnected(){return this.connectionState()==="open"}remove(t){this.off(t.stateChangeRefs),this.channels=this.channels.filter(s=>s!==t)}off(t){for(let s in this.stateChangeCallbacks)this.stateChangeCallbacks[s]=this.stateChangeCallbacks[s].filter(([n])=>t.indexOf(n)===-1)}channel(t,s={}){let n=new DH(t,s,this);return this.channels.push(n),n}push(t){if(this.hasLogger()){let{topic:s,event:n,payload:a,ref:r,join_ref:i}=t;this.log("push",`${s} ${n} (${i}, ${r})`,a)}this.isConnected()?this.encode(t,s=>this.conn.send(s)):this.sendBuffer.push(()=>this.encode(t,s=>this.conn.send(s)))}makeRef(){let t=this.ref+1;return t===this.ref?this.ref=0:this.ref=t,this.ref.toString()}sendHeartbeat(){if(!this.isConnected()){try{this.heartbeatCallback("disconnected")}catch(t){this.log("error","error in heartbeat callback",t)}return}if(this.pendingHeartbeatRef){this.heartbeatTimeout();return}this.pendingHeartbeatRef=this.makeRef(),this.heartbeatSentAt=Date.now(),this.push({topic:"phoenix",event:"heartbeat",payload:{},ref:this.pendingHeartbeatRef});try{this.heartbeatCallback("sent")}catch(t){this.log("error","error in heartbeat callback",t)}this.heartbeatTimeoutTimer=setTimeout(()=>this.heartbeatTimeout(),this.heartbeatIntervalMs)}flushSendBuffer(){this.isConnected()&&this.sendBuffer.length>0&&(this.sendBuffer.forEach(t=>t()),this.sendBuffer=[])}onConnMessage(t){this.decode(t.data,s=>{let{topic:n,event:a,payload:r,ref:i,join_ref:o}=s;if(i&&i===this.pendingHeartbeatRef){const l=this.heartbeatSentAt?Date.now()-this.heartbeatSentAt:void 0;this.clearHeartbeats();try{this.heartbeatCallback(r.status==="ok"?"ok":"error",l)}catch(c){this.log("error","error in heartbeat callback",c)}this.pendingHeartbeatRef=null,this.heartbeatSentAt=null,this.autoSendHeartbeat&&(this.heartbeatTimer=setTimeout(()=>this.sendHeartbeat(),this.heartbeatIntervalMs))}this.hasLogger()&&this.log("receive",`${r.status||""} ${n} ${a} ${i&&"("+i+")"||""}`.trim(),r);for(let l=0;l<this.channels.length;l++){const c=this.channels[l];c.isMember(n,a,r,o)&&c.trigger(a,r,i,o)}this.triggerStateCallbacks("message",s)})}triggerStateCallbacks(t,...s){try{this.stateChangeCallbacks[t].forEach(([n,a])=>{try{a(...s)}catch(r){this.log("error",`error in ${t} callback`,r)}})}catch(n){this.log("error",`error triggering ${t} callbacks`,n)}}leaveOpenTopic(t){let s=this.channels.find(n=>n.topic===t&&(n.isJoined()||n.isJoining()));s&&(this.hasLogger()&&this.log("transport",`leaving duplicate topic "${t}"`),s.leave())}};class Ah{constructor(s,n){const a=LH(n);this.presence=new IH(s.getChannel(),a),this.presence.onJoin((r,i,o)=>{const l=Ah.onJoinPayload(r,i,o);s.getChannel().trigger("presence",l)}),this.presence.onLeave((r,i,o)=>{const l=Ah.onLeavePayload(r,i,o);s.getChannel().trigger("presence",l)}),this.presence.onSync(()=>{s.getChannel().trigger("presence",{event:"sync"})})}get state(){return Ah.transformState(this.presence.state)}static transformState(s){return s=zH(s),Object.getOwnPropertyNames(s).reduce((n,a)=>{const r=s[a];return n[a]=x0(r),n},{})}static onJoinPayload(s,n,a){const r=UC(n),i=x0(a);return{event:"join",key:s,currentPresences:r,newPresences:i}}static onLeavePayload(s,n,a){const r=UC(n),i=x0(a);return{event:"leave",key:s,currentPresences:r,leftPresences:i}}}function x0(t){return t.metas.map(s=>{const n=Object.getOwnPropertyDescriptors(s),a=Object.defineProperties({},n);return a.presence_ref=a.phx_ref,delete a.phx_ref,delete a.phx_ref_prev,a})}function zH(t){return JSON.parse(JSON.stringify(t))}function LH(t){return(t==null?void 0:t.events)&&{events:t.events}}function UC(t){return t!=null&&t.metas?x0(t):[]}var qC;(function(t){t.SYNC="sync",t.JOIN="join",t.LEAVE="leave"})(qC||(qC={}));class OH{get state(){return this.presenceAdapter.state}constructor(s,n){this.channel=s,this.presenceAdapter=new Ah(this.channel.channelAdapter,n)}}function MH(t){if(t instanceof Error)return t;if(typeof t=="string")return new Error(t);if(t&&typeof t=="object"){const s=t;
1127if(typeof s.code=="number"){const n=typeof s.reason=="string"&&s.reason?` (${s.reason})`:"";return new Error(`socket closed: ${s.code}${n}`,{cause:t})}return new Error("channel error: transport failure",{cause:t})}return new Error("channel error: connection lost")}class BH{constructor(s,n,a){const r=UH(a);this.channel=s.getSocket().channel(n,r),this.socket=s}get state(){return this.channel.state}set state(s){this.channel.state=s}get joinedOnce(){return this.channel.joinedOnce}get joinPush(){return this.channel.joinPush}get rejoinTimer(){return this.channel.rejoinTimer}on(s,n){return this.channel.on(s,n)}off(s,n){this.channel.off(s,n)}subscribe(s){return this.channel.join(s)}unsubscribe(s){return this.channel.leave(s)}teardown(){this.channel.teardown()}onClose(s){this.channel.onClose(s)}onError(s){return this.channel.onError(s)}push(s,n,a){let r;try{r=this.channel.push(s,n,a)}catch{throw new Error(`tried to push '${s}' to '${this.channel.topic}' before joining. Use channel.subscribe() before pushing events`)}if(this.channel.pushBuffer.length>bH){const i=this.channel.pushBuffer.shift();i.cancelTimeout(),this.socket.log("channel",`discarded push due to buffer overflow: ${i.event}`,i.payload())}return r}updateJoinPayload(s){const n=this.channel.joinPush.payload();this.channel.joinPush.payload=()=>Object.assign(Object.assign({},n),s)}canPush(){return this.socket.isConnected()&&this.state===bl.joined}isJoined(){return this.state===bl.joined}isJoining(){return this.state===bl.joining}isClosed(){return this.state===bl.closed}isLeaving(){return this.state===bl.leaving}updateFilterBindings(s){this.channel.filterBindings=s}updatePayloadTransform(s){this.channel.onMessage=s}getChannel(){return this.channel}}function UH(t){return{config:Object.assign({broadcast:{ack:!1,self:!1},presence:{key:"",enabled:!1},private:!1},t.config)}}const qH=/[,()"\\]/,WH=t=>qH.test(t)||t!==t.trim(),HH=t=>`"${t.replace(/\\/g,"\\\\").replace(/"/g,'\\"')}"`,WC=t=>{const s=t===null?"null":String(t);return WH(s)?HH(s):s},GH=t=>t===null?"null":String(t),VH=(t,s)=>{if(t==="in"){const n=Array.isArray(s)?s:[s];if(n.length===0)throw new Error("Realtime `in` filter requires at least one value.");return`in.(${Array.from(new Set(n)).map(r=>WC(r)).join(",")})`}return t==="is"?`is.${GH(s)}`:`${t}.${WC(s)}`};class ZH{constructor(){this.filters=[]}add(s,n,a,r=!1){const i=r?"not.":"";return this.filters.push(`${s}=${i}${VH(n,a)}`),this}eq(s,n){return this.add(s,"eq",n)}neq(s,n){return this.add(s,"neq",n)}gt(s,n){return this.add(s,"gt",n)}gte(s,n){return this.add(s,"gte",n)}lt(s,n){return this.add(s,"lt",n)}lte(s,n){return this.add(s,"lte",n)}in(s,n){return this.add(s,"in",n)}like(s,n){return this.add(s,"like",n)}ilike(s,n){return this.add(s,"ilike",n)}match(s,n){return this.add(s,"match",n)}imatch(s,n){return this.add(s,"imatch",n)}is(s,n){return this.add(s,"is",n)}isDistinct(s,n){return this.add(s,"isdistinct",n)}not(s,n,a){return this.add(s,n,a,!0)}build(){return this.filters.join(",")}toString(){return this.build()}}var HC;(function(t){t.ALL="*",t.INSERT="INSERT",t.UPDATE="UPDATE",t.DELETE="DELETE"})(HC||(HC={}));var Qc;(function(t){t.BROADCAST="broadcast",t.PRESENCE="presence",t.POSTGRES_CHANGES="postgres_changes",t.SYSTEM="system"})(Qc||(Qc={}));var ro;(function(t){t.SUBSCRIBED="SUBSCRIBED",t.TIMED_OUT="TIMED_OUT",t.CLOSED="CLOSED",t.CHANNEL_ERROR="CHANNEL_ERROR"})(ro||(ro={}));class io{get state(){return this.channelAdapter.state}set state(s){this.channelAdapter.state=s}get joinedOnce(){return this.channelAdapter.joinedOnce}get timeout(){return this.socket.timeout}get joinPush(){return this.channelAdapter.joinPush}get rejoinTimer(){return this.channelAdapter.rejoinTimer}constructor(s,n={config:{}},a){var r,i;if(this.topic=s,this.params=n,this.socket=a,this.bindings={},this.subTopic=s.replace(/^realtime:/i,""),this.params.config=Object.assign({broadcast:{ack:!1,self:!1},presence:{key:"",enabled:!1},private:!1},n.config),this.channelAdapter=new BH(this.socket.socketAdapter,s,this.params),this.presence=new OH(this),this._onClose(()=>{this.socket._remove(this)}),this._updateFilterTransform(),this.broadcastEndpointURL=fR(this.socket.socketAdapter.endPointURL()),this.private=this.params.config.private||!1,!this.private&&(!((i=(r=this.params.config)===null||r===void 0?void 0:r.broadcast)===null||i===void 0)&&i.replay))throw new Error(`tried to use replay on public channel '${this.topic}'. It must be a private channel.`)}subscribe(s,n=this.timeout){var a,r,i;if(this.socket.isConnected()||this.socket.connect(),this.channelAdapter.isClosed()){const{config:{broadcast:o,presence:l,private:c}}=this.params,u=(r=(a=this.bindings.postgres_changes)===null||a===void 0?void 0:a.map(h=>h.filter))!==null&&r!==void 0?r:[],p=!!this.bindings[Qc.PRESENCE]&&this.bindings[Qc.PRESENCE].length>0||((i=this.params.config.presence)===null||i===void 0?void 0:i.enabled)===!0,m={},x={broadcast:o,presence:Object.assign(Object.assign({},l),{enabled:p}),postgres_changes:u,private:c};this.socket.accessTokenValue&&(m.access_token=this.socket.accessTokenValue),this._onError(h=>{s==null||s(ro.CHANNEL_ERROR,MH(h))}),this._onClose(()=>s==null?void 0:s(ro.CLOSED)),this.updateJoinPayload(Object.assign({config:x},m)),this._updateFilterMessage(),this.channelAdapter.subscribe(n).receive("ok",async({postgres_changes:h})=>{if(this.socket._isManualToken()||this.socket.setAuth(),h===void 0){s==null||s(ro.SUBSCRIBED);return}this._updatePostgresBindings(h,s)}).receive("error",h=>{this.state=bl.errored;const y=Object.values(h).join(", ")||"error";s==null||s(ro.CHANNEL_ERROR,new Error(y,{cause:h}))}).receive("timeout",()=>{s==null||s(ro.TIMED_OUT)})}return this}_updatePostgresBindings(s,n){var a;const r=this.bindings.postgres_changes,i=(a=r==null?void 0:r.length)!==null&&a!==void 0?a:0,o=[];for(let l=0;l<i;l++){const c=r[l],{filter:{event:u,schema:p,table:m,filter:x}}=c,h=s&&s[l];if(h&&h.event===u&&io.isFilterValueEqual(h.schema,p)&&io.isFilterValueEqual(h.table,m)&&io.isFilterValueEqual(h.filter,x))o.push(Object.assign(Object.assign({},c),{id:h.id}));else{this.unsubscribe(),this.state=bl.errored,n==null||n(ro.CHANNEL_ERROR,new Error("mismatch between server and client bindings for postgres changes"));return}}this.bindings.postgres_changes=o,this.state!=bl.errored&&n&&n(ro.SUBSCRIBED)}presenceState(){return this.presence.state}async track(s,n={}){return await this.send({type:"presence",event:"track",payload:s},n)}async untrack(s={}){return await this.send({type:"presence",event:"untrack"},s)}on(s,n,a){const r=this.channelAdapter.isJoined()||this.channelAdapter.isJoining(),i=s===Qc.PRESENCE||s===Qc.POSTGRES_CHANGES;if(r&&i)throw this.socket.log("channel",`cannot add \`${s}\` callbacks for ${this.topic} after \`subscribe()\`.`),new Error(`cannot add \`${s}\` callbacks for ${this.topic} after \`subscribe()\`.`);return this._on(s,n,a)}async httpSend(s,n,a={}){var r;if(n==null)return Promise.reject(new Error("Payload is required for httpSend()"));const i=n instanceof ArrayBuffer||ArrayBuffer.isView(n),o={apikey:this.socket.apiKey?this.socket.apiKey:"","Content-Type":i?"application/octet-stream":"application/json"};this.socket.accessTokenValue&&(o.Authorization=`Bearer ${this.socket.accessTokenValue}`);const l=new URL(this.broadcastEndpointURL);l.pathname+=`/${encodeURIComponent(this.subTopic)}/events/${encodeURIComponent(s)}`,this.private&&l.searchParams.set("private","true");const c={method:"POST",headers:o,body:i?n:JSON.stringify(n)},u=await this._fetchWithTimeout(l.toString(),c,(r=a.timeout)!==null&&r!==void 0?r:this.timeout);if(u.status===202)return{success:!0};if(u.status===404)return Promise.reject(new Error("httpSend() requires Realtime server v2.97.0 or newer; the endpoint returned 404. Update your Supabase CLI to a recent version, or upgrade the Realtime server in your self-hosted setup. See https://github.com/supabase/supabase-js/blob/master/packages/core/realt
1127ime-js/migrations/httpsend-server-version.md"));let p=u.statusText;try{const m=await u.json();p=m.error||m.message||p}catch{}return Promise.reject(new Error(p))}async send(s,n={}){var a,r;if(!this.channelAdapter.canPush()&&s.type==="broadcast"){console.warn("Realtime send() is automatically falling back to REST API. This behavior will be deprecated in the future. Please use httpSend() explicitly for REST delivery.");const{event:i,payload:o}=s,l={apikey:this.socket.apiKey?this.socket.apiKey:"","Content-Type":"application/json"};this.socket.accessTokenValue&&(l.Authorization=`Bearer ${this.socket.accessTokenValue}`);const c={method:"POST",headers:l,body:JSON.stringify({messages:[{topic:this.subTopic,event:i,payload:o,private:this.private}]})};try{const u=await this._fetchWithTimeout(this.broadcastEndpointURL,c,(a=n.timeout)!==null&&a!==void 0?a:this.timeout);return await((r=u.body)===null||r===void 0?void 0:r.cancel()),u.ok?"ok":"error"}catch(u){return u instanceof Error&&u.name==="AbortError"?"timed out":"error"}}else return new Promise(i=>{var o,l,c;const u=this.channelAdapter.push(s.type,s,n.timeout||this.timeout);s.type==="broadcast"&&!(!((c=(l=(o=this.params)===null||o===void 0?void 0:o.config)===null||l===void 0?void 0:l.broadcast)===null||c===void 0)&&c.ack)&&i("ok"),u.receive("ok",()=>i("ok")),u.receive("error",()=>i("error")),u.receive("timeout",()=>i("timed out"))})}updateJoinPayload(s){this.channelAdapter.updateJoinPayload(s)}async unsubscribe(s=this.timeout){return new Promise(n=>{this.channelAdapter.unsubscribe(s).receive("ok",()=>n("ok")).receive("timeout",()=>n("timed out")).receive("error",()=>n("error"))})}teardown(){this.channelAdapter.teardown()}async _fetchWithTimeout(s,n,a){const r=new AbortController,i=setTimeout(()=>r.abort(),a),o=await this.socket.fetch(s,Object.assign(Object.assign({},n),{signal:r.signal}));return clearTimeout(i),o}_on(s,n,a){var r;const i=s.toLocaleLowerCase(),o=n==null?void 0:n.filter;if((o instanceof ZH||typeof o=="object"&&o!==null&&typeof o.build=="function")&&(n=Object.assign(Object.assign({},n),{filter:o.build()})),i===Qc.POSTGRES_CHANGES&&((r=this.bindings[i])===null||r===void 0?void 0:r.find(p=>io.isSamePostgresFilter(p.filter,n))))return this.socket.log("error",`duplicate \`postgres_changes\` binding for ${this.topic} ignored`,n),this;const l=this.channelAdapter.on(s,a),c={type:i,filter:n,callback:a,ref:l};return this.bindings[i]?this.bindings[i].push(c):this.bindings[i]=[c],this._updateFilterMessage(),this}_onClose(s){this.channelAdapter.onClose(s)}_onError(s){this.channelAdapter.onError(s)}_updateFilterMessage(){this.channelAdapter.updateFilterBindings((s,n,a)=>{var r,i,o,l,c,u,p;const m=s.event.toLocaleLowerCase();if(this._notThisChannelEvent(m,a))return!1;const x=(r=this.bindings[m])===null||r===void 0?void 0:r.find(h=>h.ref===s.ref);if(!x)return!0;if(["broadcast","presence","postgres_changes"].includes(m))if("id"in x){const h=x.id,y=(i=x.filter)===null||i===void 0?void 0:i.event;return h&&((o=n.ids)===null||o===void 0?void 0:o.includes(h))&&(y==="*"||(y==null?void 0:y.toLocaleLowerCase())===((l=n.data)===null||l===void 0?void 0:l.type.toLocaleLowerCase()))}else{const h=(u=(c=x==null?void 0:x.filter)===null||c===void 0?void 0:c.event)===null||u===void 0?void 0:u.toLocaleLowerCase();return h==="*"||h===((p=n==null?void 0:n.event)===null||p===void 0?void 0:p.toLocaleLowerCase())}else return x.type.toLocaleLowerCase()===m})}_notThisChannelEvent(s,n){const{close:a,error:r,leave:i,join:o}=hR;return n&&[a,r,i,o].includes(s)&&n!==this.joinPush.ref}_updateFilterTransform(){this.channelAdapter.updatePayloadTransform((s,n,a)=>{if(typeof n=="object"&&"ids"in n){const r=n.data,{schema:i,table:o,commit_timestamp:l,type:c,errors:u}=r;return Object.assign(Object.assign({},{schema:i,table:o,commit_timestamp:l,eventType:c,new:{},old:{},errors:u}),this._getPayloadRecords(r))}return n})}copyBindings(s){if(this.joinedOnce)throw new Error("cannot copy bindings into joined channel");for(const n in s.bindings)for(const a of s.bindings[n])this._on(a.type,a.filter,a.callback)}static isFilterValueEqual(s,n){return(s??void 0)===(n??void 0)}static isSamePostgresFilter(s,n){var a,r,i,o;const l=(r=(a=s==null?void 0:s.select)===null||a===void 0?void 0:a.join())!==null&&r!==void 0?r:void 0,c=(o=(i=n==null?void 0:n.select)===null||i===void 0?void 0:i.join())!==null&&o!==void 0?o:void 0;return(s==null?void 0:s.event)===(n==null?void 0:n.event)&&io.isFilterValueEqual(s==null?void 0:s.schema,n==null?void 0:n.schema)&&io.isFilterValueEqual(s==null?void 0:s.table,n==null?void 0:n.table)&&io.isFilterValueEqual(s==null?void 0:s.filter,n==null?void 0:n.filter)&&l===c}_getPayloadRecords(s){const n={new:{},old:{}};return(s.type==="INSERT"||s.type==="UPDATE")&&(n.new=BC(s.columns,s.record)),(s.type==="UPDATE"||s.type==="DELETE")&&(n.old=BC(s.columns,s.old_record)),n}}class YH{constructor(s,n){this.socket=new $H(s,n)}get timeout(){return this.socket.timeout}get endPoint(){return this.socket.endPoint}get transport(){return this.socket.transport}get heartbeatIntervalMs(){return this.socket.heartbeatIntervalMs}get heartbeatCallback(){return this.socket.heartbeatCallback}set heartbeatCallback(s){this.socket.heartbeatCallback=s}get heartbeatTimer(){return this.socket.heartbeatTimer}get pendingHeartbeatRef(){return this.socket.pendingHeartbeatRef}get reconnectTimer(){return this.socket.reconnectTimer}get vsn(){return this.socket.vsn}get encode(){return this.socket.encode}get decode(){return this.socket.decode}get reconnectAfterMs(){return this.socket.reconnectAfterMs}get sendBuffer(){return this.socket.sendBuffer}get stateChangeCallbacks(){return this.socket.stateChangeCallbacks}connect(){this.socket.connect()}disconnect(s,n,a,r=1e4){return new Promise(i=>{setTimeout(()=>i("timeout"),r),this.socket.disconnect(()=>{s(),i("ok")},n,a)})}push(s){this.socket.push(s)}log(s,n,a){this.socket.log(s,n,a)}makeRef(){return this.socket.makeRef()}onOpen(s){this.socket.onOpen(s)}onClose(s){this.socket.onClose(s)}onError(s){this.socket.onError(s)}onMessage(s){this.socket.onMessage(s)}isConnected(){return this.socket.isConnected()}isConnecting(){return this.socket.connectionState()==C2.connecting}isDisconnecting(){return this.socket.connectionState()==C2.closing}connectionState(){return this.socket.connectionState()}endPointURL(){return this.socket.endPointURL()}sendHeartbeat(){this.socket.sendHeartbeat()}getSocket(){return this.socket}}const GC={HEARTBEAT_INTERVAL:25e3},KH=[1e3,2e3,5e3,1e4],QH=1e4;function JH(){const t=new Map;return{get length(){return t.size},clear(){t.clear()},getItem(s){return t.has(s)?t.get(s):null},key(s){var n;return(n=Array.from(t.keys())[s])!==null&&n!==void 0?n:null},removeItem(s){t.delete(s)},setItem(s,n){t.set(s,String(n))}}}function XH(){try{if(typeof globalThis<"u"&&globalThis.sessionStorage)return globalThis.sessionStorage}catch{}return JH()}const eG=` 1128 addEventListener("message", (e) => { 1129 if (e.data.event === "start") { 1130 setInterval(() => postMessage({ event: "keepAlive" }), e.data.interval); 1131 } 1132 });`;class tG{get endPoint(){return this.socketAdapter.endPoint}get timeout(){return this.socketAdapter.timeout}get transport(){return this.socketAdapter.transport}get heartbeatCallback(){return this.socketAdapter.heartbeatCallback}get heartbeatIntervalMs(){return this.socketAdapter.heartbeatIntervalMs}get heartbeatTimer(){return this.worker?this._workerHeartbeatTimer:this.socketAdapter.heartbeatTimer}get pendingHeartbeatRef(){return this.worker?this._pendingWorkerHeartbeatRef:this.socketAdapter.pendingHeartbeatRef}get reconnectTimer(){return this.socketAdapter.reconnectTimer}get vsn(){return this.socketAdapter.vsn}get encode(){return this.socketAdapter.encode}get decode(){return this.socketAdapter.decode}get reconnectAfterMs(){return this.socketAdapter.reconnectAfterMs}get sendBuffer(){return this.socketAdapter.sendBuffer}get stateChangeCallbacks(){return this.socketAdapter.stateChangeCallbacks}constructor(s,n){var a;if(this.channels=new Array,this.accessTokenValue=null,this.accessToken=null,this.apiKey=null,this.httpEndpoint="",this.headers={},this.params={}
1132,this.ref=0,this.serializer=new vH,this._manuallySetToken=!1,this._authPromise=null,this._authGeneration=0,this._workerHeartbeatTimer=void 0,this._pendingWorkerHeartbeatRef=null,this._pendingDisconnectTimer=null,this._disconnectOnEmptyChannelsAfterMs=0,this._resolveFetch=i=>i?(...o)=>i(...o):(...o)=>fetch(...o),!(!((a=n==null?void 0:n.params)===null||a===void 0)&&a.apikey))throw new Error("API key is required to connect to Realtime");this.apiKey=n.params.apikey;const r=this._initializeOptions(n);this.socketAdapter=new YH(s,r),this.httpEndpoint=fR(s),this.fetch=this._resolveFetch(n==null?void 0:n.fetch)}connect(){if(!(this.isConnecting()||this.isDisconnecting()||this.isConnected())){this.accessToken&&!this._authPromise&&this._setAuthSafely("connect"),this._setupConnectionHandlers();try{this.socketAdapter.connect()}catch(s){const n=s.message;throw new Error(`WebSocket not available: ${n}`)}this._handleNodeJsRaceCondition()}}endpointURL(){return this.socketAdapter.endPointURL()}async disconnect(s,n){return this._cancelPendingDisconnect(),this.isDisconnecting()?"ok":await this.socketAdapter.disconnect(()=>{clearInterval(this._workerHeartbeatTimer),this._terminateWorker()},s,n)}getChannels(){return this.channels}async removeChannel(s){const n=await s.unsubscribe();return n==="ok"&&s.teardown(),n}async removeAllChannels(){const s=this.channels.map(async a=>{const r=await a.unsubscribe();return a.teardown(),r}),n=await Promise.all(s);return await this.disconnect(),n}log(s,n,a){this.socketAdapter.log(s,n,a)}connectionState(){return this.socketAdapter.connectionState()||C2.closed}isConnected(){return this.socketAdapter.isConnected()}isConnecting(){return this.socketAdapter.isConnecting()}isDisconnecting(){return this.socketAdapter.isDisconnecting()}channel(s,n={config:{}}){const a=`realtime:${s}`,r=this.getChannels().find(i=>i.topic===a);if(r)return r;{const i=new io(`realtime:${s}`,n,this);return this._cancelPendingDisconnect(),this.channels.push(i),i}}push(s){this.socketAdapter.push(s)}async setAuth(s=null){const n=++this._authGeneration,a=this._performAuth(s,n);n===this._authGeneration&&(this._authPromise=a);try{await a}finally{this._authPromise===a&&(this._authPromise=null)}}_isManualToken(){return this._manuallySetToken}async sendHeartbeat(){this.socketAdapter.sendHeartbeat()}onHeartbeat(s){this.socketAdapter.heartbeatCallback=this._wrapHeartbeatCallback(s)}_makeRef(){return this.socketAdapter.makeRef()}_remove(s){this.channels=this.channels.filter(n=>n.topic!==s.topic),this.channels.length===0&&(this.log("transport","no channels remaining, scheduling disconnect"),this._schedulePendingDisconnect())}_schedulePendingDisconnect(){if(this._cancelPendingDisconnect(),this._disconnectOnEmptyChannelsAfterMs===0){this.log("transport","disconnecting immediately - no channels"),this.disconnect();return}
1132this._pendingDisconnectTimer=setTimeout(()=>{this._pendingDisconnectTimer=null,this.channels.length===0&&(this.log("transport","deferred disconnect fired - no channels, disconnecting"),this.disconnect())},this._disconnectOnEmptyChannelsAfterMs),this.log("transport",`deferred disconnect scheduled in ${this._disconnectOnEmptyChannelsAfterMs}ms`)}_cancelPendingDisconnect(){this._pendingDisconnectTimer!==null&&(this.log("transport","pending disconnect cancelled - channel activity detected"),clearTimeout(this._pendingDisconnectTimer),this._pendingDisconnectTimer=null)}async _performAuth(s,n){let a,r=!1;if(s)a=s,r=!0;else if(this.accessToken)try{a=await this.accessToken()}catch(i){this.log("error","Error fetching access token from callback",i),a=this.accessTokenValue}else a=this.accessTokenValue;n===this._authGeneration&&(this.accessToken?this._manuallySetToken=!1:r&&(this._manuallySetToken=!0),this.accessTokenValue!=a&&(this.accessTokenValue=a,this.channels.forEach(i=>{const o={access_token:a,version:xH};i.updateJoinPayload(o),i.joinedOnce&&i.channelAdapter.isJoined()&&i.channelAdapter.push(hR.access_token,{access_token:a})})))}async _waitForAuthIfNeeded(){this._authPromise&&await this._authPromise}_setAuthSafely(s="general"){this._isManualToken()||this.setAuth().catch(n=>{this.log("error",`Error setting auth in ${s}`,n)})}_setupConnectionHandlers(){this.socketAdapter.onOpen(()=>{(this._authPromise||(this.accessToken&&!this.accessTokenValue?this.setAuth():Promise.resolve())).catch(n=>{this.log("error","error waiting for auth on connect",n)}),this.worker&&!this.workerRef&&this._startWorkerHeartbeat()}),this.socketAdapter.onClose(()=>{this.worker&&this.workerRef&&this._terminateWorker()}),this.socketAdapter.onMessage(s=>{s.ref&&s.ref===this._pendingWorkerHeartbeatRef&&(this._pendingWorkerHeartbeatRef=null)})}_handleNodeJsRaceCondition(){this.socketAdapter.isConnected()&&this.socketAdapter.getSocket().onConnOpen()}_wrapHeartbeatCallback(s){return(n,a)=>{n!=="disconnected"&&(n=="sent"&&this._setAuthSafely(),s&&s(n,a))}}_startWorkerHeartbeat(){this.workerUrl?this.log("worker",`starting worker for from ${this.workerUrl}`):this.log("worker","starting default worker");const s=this._workerObjectUrl(this.workerUrl);this.workerRef=new Worker(s),this.workerRef.onerror=n=>{this.log("worker","worker error",n.message),this._terminateWorker(),this.disconnect()},this.workerRef.onmessage=n=>{n.data.event==="keepAlive"&&this.sendHeartbeat()},this.workerRef.postMessage({event:"start",interval:this.heartbeatIntervalMs})}_terminateWorker(){this.workerRef&&(this.log("worker","terminating worker"),this.workerRef.terminate(),this.workerRef=void 0)}_workerObjectUrl(s){let n;if(s)n=s;else{const a=new Blob([eG],{type:"application/javascript"});n=URL.createObjectURL(a)}return n}_initializeOptions(s){var n,a,r,i,o,l,c,u,p,m,x,h;this.worker=(n=s==null?void 0:s.worker)!==null&&n!==void 0?n:!1,this.accessToken=(a=s==null?void 0:s.accessToken)!==null&&a!==void 0?a:null;const y={};y.timeout=(r=s==null?void 0:s.timeout)!==null&&r!==void 0?r:yH,y.heartbeatIntervalMs=(i=s==null?void 0:s.heartbeatIntervalMs)!==null&&i!==void 0?i:GC.HEARTBEAT_INTERVAL,this._disconnectOnEmptyChannelsAfterMs=(o=s==null?void 0:s.disconnectOnEmptyChannelsAfterMs)!==null&&o!==void 0?o:2*((l=s==null?void 0:s.heartbeatIntervalMs)!==null&&l!==void 0?l:GC.HEARTBEAT_INTERVAL),y.transport=(c=s==null?void 0:s.transport)!==null&&c!==void 0?c:pH.getWebSocketConstructor(),y.params=s==null?void 0:s.params,y.logger=s==null?void 0:s.logger,y.heartbeatCallback=this._wrapHeartbeatCallback(s==null?void 0:s.heartbeatCallback),y.sessionStorage=(u=s==null?void 0:s.sessionStorage)!==null&&u!==void 0?u:XH(),y.reconnectAfterMs=(p=s==null?void 0:s.reconnectAfterMs)!==null&&p!==void 0?p:b=>KH[b-1]||QH;let v,g;const N=(m=s==null?void 0:s.vsn)!==null&&m!==void 0?m:gH;switch(N){case fH:v=(b,f)=>f(JSON.stringify(b)),g=(b,f)=>f(JSON.parse(b));break;case pR:v=this.serializer.encode.bind(this.serializer),g=this.serializer.decode.bind(this.serializer);break;default:throw new Error(`Unsupported serializer version: ${y.vsn}`)}if(y.vsn=N,y.encode=(x=s==null?void 0:s.encode)!==null&&x!==void 0?x:v,y.decode=(h=s==null?void 0:s.decode)!==null&&h!==void 0?h:g,y.beforeReconnect=this._reconnectAuth.bind(this),(s!=null&&s.logLevel||s!=null&&s.log_level)&&(this.logLevel=s.logLevel||s.log_level,y.params=Object.assign(Object.assign({},y.params),{log_level:this.logLevel})),this.worker){if(typeof window<"u"&&!window.Worker)throw new Error("Web Worker is not supported");this.workerUrl=s==null?void 0:s.workerUrl,y.autoSendHeartbeat=!this.worker}return y}async _reconnectAuth(){await this._waitForAuthIfNeeded(),this.isConnected()||this.connect()}}
1132var vx=class extends Error{constructor(t,s){var n;super(t),this.name="IcebergError",this.status=s.status,this.icebergType=s.icebergType,this.icebergCode=s.icebergCode,this.details=s.details,this.isCommitStateUnknown=s.icebergType==="CommitStateUnknownException"||[500,502,504].includes(s.status)&&((n=s.icebergType)==null?void 0:n.includes("CommitState"))===!0}isNotFound(){return this.status===404}isConflict(){return this.status===409}isAuthenticationTimeout(){return this.status===419}};function sG(t,s,n){const a=new URL(s,t);if(n)for(const[r,i]of Object.entries(n))i!==void 0&&a.searchParams.set(r,i);return a.toString()}async function nG(t){return!t||t.type==="none"?{}:t.type==="bearer"?{Authorization:`Bearer ${t.token}`}:t.type==="header"?{[t.name]:t.value}:t.type==="custom"?await t.getHeaders():{}}function aG(t){const s=t.fetchImpl??globalThis.fetch;return{async request({method:n,path:a,query:r,body:i,headers:o}){const l=sG(t.baseUrl,a,r),c=await nG(t.auth),u=await s(l,{method:n,headers:{...i?{"Content-Type":"application/json"}:{},...c,...o},body:i?JSON.stringify(i):void 0}),p=await u.text(),m=(u.headers.get("content-type")||"").includes("application/json"),x=m&&p?JSON.parse(p):p;if(!u.ok){const h=m?x:void 0,y=h==null?void 0:h.error;throw new vx((y==null?void 0:y.message)??`Request failed with status ${u.status}`,{status:u.status,icebergType:y==null?void 0:y.type,icebergCode:y==null?void 0:y.code,details:h})}return{status:u.status,headers:u.headers,data:x}}}}function If(t){return t.join("�")}var rG=class{constructor(t,s=""){this.client=t,this.prefix=s}async listNamespaces(t){const s=t?{parent:If(t.namespace)}:void 0;return(await this.client.request({method:"GET",path:`${this.prefix}/namespaces`,query:s})).data.namespaces.map(a=>({namespace:a}))}async createNamespace(t,s){const n={namespace:t.namespace,properties:s==null?void 0:s.properties};return(await this.client.request({method:"POST",path:`${this.prefix}/namespaces`,body:n})).data}async dropNamespace(t){await this.client.request({method:"DELETE",path:`${this.prefix}/namespaces/${If(t.namespace)}`})}async loadNamespaceMetadata(t){return{properties:(await this.client.request({method:"GET",path:`${this.prefix}/namespaces/${If(t.namespace)}`})).data.properties}}async namespaceExists(t){try{return await this.client.request({method:"HEAD",path:`${this.prefix}/namespaces/${If(t.namespace)}`}),!0}catch(s){if(s instanceof vx&&s.status===404)return!1;throw s}}async createNamespaceIfNotExists(t,s){try{return await this.createNamespace(t,s)}catch(n){if(n instanceof vx&&n.status===409)return;throw n}}};function Zd(t){return t.join("�")}var iG=class{constructor(t,s="",n){this.client=t,this.prefix=s,this.accessDelegation=n}async listTables(t){return(await this.client.request({method:"GET",path:`${this.prefix}/namespaces/${Zd(t.namespace)}/tables`})).data.identifiers}async createTable(t,s){const n={};return this.accessDelegation&&(n["X-Iceberg-Access-Delegation"]=this.accessDelegation),(await this.client.request({method:"POST",path:`${this.prefix}/namespaces/${Zd(t.namespace)}/tables`,body:s,headers:n})).data.metadata}async updateTable(t,s){const n=await this.client.request({method:"POST",path:`${this.prefix}/namespaces/${Zd(t.namespace)}/tables/${t.name}`,body:s});return{"metadata-location":n.data["metadata-location"],metadata:n.data.metadata}}async dropTable(t,s){await this.client.request({method:"DELETE",path:`${this.prefix}/namespaces/${Zd(t.namespace)}/tables/${t.name}`,query:{purgeRequested:String((s==null?void 0:s.purge)??!1)}})}async loadTable(t){const s={};return this.accessDelegation&&(s["X-Iceberg-Access-Delegation"]=this.accessDelegation),(await this.client.request({method:"GET",path:`${this.prefix}/namespaces/${Zd(t.namespace)}/tables/${t.name}`,headers:s})).data.metadata}async tableExists(t){const s={};this.accessDelegation&&(s["X-Iceberg-Access-Delegation"]=this.accessDelegation);try{return await this.client.request({method:"HEAD",path:`${this.prefix}/namespaces/${Zd(t.namespace)}/tables/${t.name}`,headers:s}),!0}catch(n){if(n instanceof vx&&n.status===404)return!1;throw n}}async createTableIfNotExists(t,s){try{return await this.createTable(t,s)}catch(n){if(n instanceof vx&&n.status===409)return await this.loadTable({namespace:t.namespace,name:s.name});throw n}}},oG=class{constructor(t){var a;let s="v1";t.catalogName&&(s+=`/${t.catalogName}`);const n=t.baseUrl.endsWith("/")?t.baseUrl:`${t.baseUrl}/`;this.client=aG({baseUrl:n,auth:t.auth,fetchImpl:t.fetch}),this.accessDelegation=(a=t.accessDelegation)==null?void 0:a.join(","),this.namespaceOps=new rG(this.client,s),this.tableOps=new iG(this.client,s,this.accessDelegation)}async listNamespaces(t){return this.namespaceOps.listNamespaces(t)}async createNamespace(t,s){return this.namespaceOps.createNamespace(t,s)}async dropNamespace(t){await this.namespaceOps.dropNamespace(t)}async loadNamespaceMetadata(t){return this.namespaceOps.loadNamespaceMetadata(t)}async listTables(t){return this.tableOps.listTables(t)}
1132async createTable(t,s){return this.tableOps.createTable(t,s)}async updateTable(t,s){return this.tableOps.updateTable(t,s)}async dropTable(t,s){await this.tableOps.dropTable(t,s)}async loadTable(t){return this.tableOps.loadTable(t)}async namespaceExists(t){return this.namespaceOps.namespaceExists(t)}async tableExists(t){return this.tableOps.tableExists(t)}async createNamespaceIfNotExists(t,s){return this.namespaceOps.createNamespaceIfNotExists(t,s)}async createTableIfNotExists(t,s){return this.tableOps.createTableIfNotExists(t,s)}};function jx(t){"@babel/helpers - typeof";return jx=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(s){return typeof s}:function(s){return s&&typeof Symbol=="function"&&s.constructor===Symbol&&s!==Symbol.prototype?"symbol":typeof s},jx(t)}function lG(t,s){if(jx(t)!="object"||!t)return t;var n=t[Symbol.toPrimitive];if(n!==void 0){var a=n.call(t,s);if(jx(a)!="object")return a;throw new TypeError("@@toPrimitive must return a primitive value.")}return(s==="string"?String:Number)(t)}function cG(t){var s=lG(t,"string");return jx(s)=="symbol"?s:s+""}function dG(t,s,n){return(s=cG(s))in t?Object.defineProperty(t,s,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[s]=n,t}function VC(t,s){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(t);s&&(a=a.filter(function(r){return Object.getOwnPropertyDescriptor(t,r).enumerable})),n.push.apply(n,a)}return n}function st(t){for(var s=1;s<arguments.length;s++){var n=arguments[s]!=null?arguments[s]:{};s%2?VC(Object(n),!0).forEach(function(a){dG(t,a,n[a])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):VC(Object(n)).forEach(function(a){Object.defineProperty(t,a,Object.getOwnPropertyDescriptor(n,a))})}return t}var Kb=class extends Error{constructor(t,s="storage",n,a){super(t),this.__isStorageError=!0,this.namespace=s,this.name=s==="vectors"?"StorageVectorsError":"StorageError",this.status=n,this.statusCode=a}toJSON(){return{name:this.name,message:this.message,status:this.status,statusCode:this.statusCode}}};function Qb(t){return typeof t=="object"&&t!==null&&"__isStorageError"in t}var T2=class extends Kb{constructor(t,s,n,a="storage",r){super(t,a,s,n),this.name=a==="vectors"?"StorageVectorsApiError":"StorageApiError",this.status=s,this.statusCode=n,this.code=r}toJSON(){return st(st({},super.toJSON()),{},{code:this.code})}},yR=class extends Kb{constructor(t,s,n="storage"){super(t,n),this.name=n==="vectors"?"StorageVectorsUnknownError":"StorageUnknownError",this.originalError=s}};function zy(t,s,n){const a=st({},t),r=s.toLowerCase();for(const i of Object.keys(a))i.toLowerCase()===r&&delete a[i];return a[r]=n,a}function uG(t){const s={};for(const[n,a]of Object.entries(t))s[n.toLowerCase()]=a;return s}const mG=t=>t?(...s)=>t(...s):(...s)=>fetch(...s),pG=t=>{if(typeof t!="object"||t===null)return!1;const s=Object.getPrototypeOf(t);return(s===null||s===Object.prototype||Object.getPrototypeOf(s)===null)&&!(Symbol.toStringTag in t)&&!(Symbol.iterator in t)},P2=t=>{if(Array.isArray(t))return t.map(n=>P2(n));if(typeof t=="function"||t!==Object(t))return t;const s={};return Object.entries(t).forEach(([n,a])=>{const r=n.replace(/([-_][a-z])/gi,i=>i.toUpperCase().replace(/[-_]/g,""));s[r]=P2(a)}),s},hG=t=>!t||typeof t!="string"||t.length===0||t.length>100||t.trim()!==t||t.includes("/")||t.includes("\\")?!1:/^[\w!.\*'() &$@=;:+,?-]+$/.test(t),bR=t=>t.split("/").map(encodeURIComponent).join("/"),ZC=t=>{if(typeof t=="object"&&t!==null){const s=t;if(typeof s.msg=="string")return s.msg;if(typeof s.message=="string")return s.message;if(typeof s.error_description=="string")return s.error_description;if(typeof s.error=="string")return s.error;if(typeof s.error=="object"&&s.error!==null){const n=s.error;if(typeof n.message=="string")return n.message}}return JSON.stringify(t)},xG=async(t,s,n,a)=>{if(t!==null&&typeof t=="object"&&"json"in t&&typeof t.json=="function"){const r=t;let i=parseInt(String(r.status),10);Number.isFinite(i)||(i=500),r.json().then(o=>{const l=(o==null?void 0:o.statusCode)||(o==null?void 0:o.code)||i+"";s(new T2(ZC(o),i,l,a,o==null?void 0:o.code))}).catch(()=>{const o=i+"";s(new T2(r.statusText||`HTTP ${i} error`,i,o,a))})}
1132else s(new yR(ZC(t),t,a))},fG=(t,s,n,a)=>{const r={method:t,headers:(s==null?void 0:s.headers)||{}};if(t==="GET"||t==="HEAD"||!a)return st(st({},r),n);if(pG(a)){var i;const o=(s==null?void 0:s.headers)||{};let l;for(const[c,u]of Object.entries(o))c.toLowerCase()==="content-type"&&(l=u);r.headers=zy(o,"Content-Type",(i=l)!==null&&i!==void 0?i:"application/json"),r.body=JSON.stringify(a)}else r.body=a;return s!=null&&s.duplex&&(r.duplex=s.duplex),st(st({},r),n)};async function jp(t,s,n,a,r,i,o){return new Promise((l,c)=>{t(n,fG(s,a,r,i)).then(u=>{if(!u.ok)throw u;if(a!=null&&a.noResolveJson)return u;if(o==="vectors"){const p=u.headers.get("content-type");if(u.headers.get("content-length")==="0"||u.status===204)return{};if(!p||!p.includes("application/json"))return{}}return u.json()}).then(u=>l(u)).catch(u=>xG(u,c,a,o))})}function vR(t="storage"){return{get:async(s,n,a,r)=>jp(s,"GET",n,a,r,void 0,t),post:async(s,n,a,r,i)=>jp(s,"POST",n,r,i,a,t),put:async(s,n,a,r,i)=>jp(s,"PUT",n,r,i,a,t),head:async(s,n,a,r)=>jp(s,"HEAD",n,st(st({},a),{},{noResolveJson:!0}),r,void 0,t),remove:async(s,n,a,r,i)=>jp(s,"DELETE",n,r,i,a,t)}}const gG=vR("storage"),{get:wx,post:qr,put:D2,head:yG,remove:Nx}=gG,$a=vR("vectors");var sp=class{constructor(t,s={},n,a="storage"){this.shouldThrowOnError=!1,this.url=t,this.headers=uG(s),this.fetch=mG(n),this.namespace=a}throwOnError(){return this.shouldThrowOnError=!0,this}setHeader(t,s){return this.headers=zy(this.headers,t,s),this}async handleOperation(t){var s=this;try{return{data:await t(),error:null}}catch(n){if(s.shouldThrowOnError)throw n;if(Qb(n))return{data:null,error:n};throw n}}};let jR;jR=Symbol.toStringTag;var bG=class{constructor(t,s){this.downloadFn=t,this.shouldThrowOnError=s,this[jR]="StreamDownloadBuilder",this.promise=null}then(t,s){return this.getPromise().then(t,s)}catch(t){return this.getPromise().catch(t)}finally(t){return this.getPromise().finally(t)}getPromise(){return this.promise||(this.promise=this.execute()),this.promise}async execute(){var t=this;try{return{data:(await t.downloadFn()).body,error:null}}catch(s){if(t.shouldThrowOnError)throw s;if(Qb(s))return{data:null,error:s};throw s}}};let wR;wR=Symbol.toStringTag;var vG=class{constructor(t,s){this.downloadFn=t,this.shouldThrowOnError=s,this[wR]="BlobDownloadBuilder",this.promise=null}asStream(){return new bG(this.downloadFn,this.shouldThrowOnError)}then(t,s){return this.getPromise().then(t,s)}catch(t){return this.getPromise().catch(t)}finally(t){return this.getPromise().finally(t)}getPromise(){return this.promise||(this.promise=this.execute()),this.promise}async execute(){var t=this;try{return{data:await(await t.downloadFn()).blob(),error:null}}catch(s){if(t.shouldThrowOnError)throw s;if(Qb(s))return{data:null,error:s};throw s}}};const lv={limit:100,offset:0,sortBy:{column:"name",order:"asc"}},YC={cacheControl:"3600",contentType:"text/plain;charset=UTF-8",upsert:!1};var jG=class extends sp{constructor(t,s={},n,a){super(t,s,a,"storage"),this.bucketId=n}async uploadOrUpdate(t,s,n,a){var r=this;return r.handleOperation(async()=>{let i;const o=st(st({},YC),a);let l=st(st({},r.headers),t==="POST"&&{"x-upsert":String(o.upsert)});const c=o.metadata;if(typeof Blob<"u"&&n instanceof Blob?(i=new FormData,i.append("cacheControl",o.cacheControl),c&&i.append("metadata",r.encodeMetadata(c)),i.append("",n)):typeof FormData<"u"&&n instanceof FormData?(i=n,i.has("cacheControl")||i.append("cacheControl",o.cacheControl),c&&!i.has("metadata")&&i.append("metadata",r.encodeMetadata(c))):(i=n,l["cache-control"]=`max-age=${o.cacheControl}`,l["content-type"]=o.contentType,c&&(l["x-metadata"]=r.toBase64(r.encodeMetadata(c))),(typeof ReadableStream<"u"&&i instanceof ReadableStream||i&&typeof i=="object"&&"pipe"in i&&typeof i.pipe=="function")&&!o.duplex&&(o.duplex="half")),a!=null&&a.headers)for(const[x,h]of Object.entries(a.headers))l=zy(l,x,h);const u=r._removeEmptyFolders(s),p=r._getFinalPath(u),m=await(t=="PUT"?D2:qr)(r.fetch,`${r.url}/object/${p}`,i,st({headers:l},o!=null&&o.duplex?{duplex:o.duplex}:{}));return{path:u,id:m.Id,fullPath:m.Key}})}async upload(t,s,n){return this.uploadOrUpdate("POST",t,s,n)}async uploadToSignedUrl(t,s,n,a){var r=this;const i=r._removeEmptyFolders(t),o=r._getFinalPath(i),l=new URL(r.url+`/object/upload/sign/${o}`);return l.searchParams.set("token",s),r.handleOperation(async()=>{let c;const u=st(st({},YC),a);let p=st(st({},r.headers),{"x-upsert":String(u.upsert)});const m=u.metadata;if(typeof Blob<"u"&&n instanceof Blob?(c=new FormData,c.append("cacheControl",u.cacheControl),m&&c.append("metadata",r.encodeMetadata(m)),c.append("",n)):typeof FormData<"u"&&n instanceof FormData?(c=n,c.has("cacheControl")||c.append("cacheControl",u.cacheControl),m&&!c.has("metadata")&&c.append("metadata",r.encodeMetadata(m))):(c=n,p["cache-control"]=`max-age=${u.cacheControl}`,p["content-type"]=u.contentType,m&&(p["x-metadata"]=r.toBase64(r.encodeMetadata(m))),(typeof ReadableStream<"u"&&c instanceof ReadableStream||c&&typeof c=="object"&&"pipe"in c&&typeof c.pipe=="function")&&!u.duplex&&(u.duplex="half")),a!=null&&a.headers)for(const[x,h]of Object.entries(a.headers))p=zy(p,x,h);return{path:i,fullPath:(await D2(r.fetch,l.toString(),c,st({headers:p},u!=null&&u.duplex?{duplex:u.duplex}:{}))).Key}})}async createSignedUploadUrl(t,s){var n=this;return n.handleOperation(async()=>{let a=n._getFinalPath(t);const r=st({},n.headers);s!=null&&s.upsert&&(r["x-upsert"]="true");const i=await qr(n.fetch,`${n.url}/object/upload/sign/${a}`,{},{headers:r}),o=new URL(n.url+i.url),l=o.searchParams.get("token");if(!l)throw new Kb("No token returned by API");return{signedUrl:o.toString(),path:t,token:l}})}async update(t,s,n){return this.uploadOrUpdate("PUT",t,s,n)}async move(t,s,n){var a=this;return a.handleOperation(async()=>await qr(a.fetch,`${a.url}/object/move`,{bucketId:a.bucketId,sourceKey:t,destinationKey:s,destinationBucket:n==null?void 0:n.destinationBucket},{headers:a.headers}))}async copy(t,s,n){var a=this;return a.handleOperation(async()=>({path:(await qr(a.fetch,`${a.url}/object/copy`,{bucketId:a.bucketId,sourceKey:t,destinationKey:s,destinationBucket:n==null?void 0:n.destinationBucket},{headers:a.headers})).Key}))}async createSignedUrl(t,s,n){var a=this;return a.handleOperation(async()=>{let r=a._getFinalPath(t);const i=typeof(n==null?void 0:n.transform)=="object"&&n.transform!==null&&Object.keys(n.transform).length>0;let o=await qr(a.fetch,`${a.url}/object/sign/${r}
1132`,st({expiresIn:s},i?{transform:n.transform}:{}),{headers:a.headers});const l=new URLSearchParams;n!=null&&n.download&&l.set("download",n.download===!0?"":n.download),(n==null?void 0:n.cacheNonce)!=null&&l.set("cacheNonce",String(n.cacheNonce));const c=l.toString();return{signedUrl:encodeURI(`${a.url}${o.signedURL}${c?`&${c}`:""}`)}})}async createSignedUrls(t,s,n){var a=this;return a.handleOperation(async()=>{const r=await qr(a.fetch,`${a.url}/object/sign/${a.bucketId}`,{expiresIn:s,paths:t},{headers:a.headers}),i=new URLSearchParams;n!=null&&n.download&&i.set("download",n.download===!0?"":n.download),(n==null?void 0:n.cacheNonce)!=null&&i.set("cacheNonce",String(n.cacheNonce));const o=i.toString();return r.map(l=>st(st({},l),{},{signedUrl:l.signedURL?encodeURI(`${a.url}${l.signedURL}${o?`&${o}`:""}`):null}))})}download(t,s,n){const a=typeof(s==null?void 0:s.transform)=="object"&&s.transform!==null&&Object.keys(s.transform).length>0?"render/image/authenticated":"object",r=new URLSearchParams;s!=null&&s.transform&&this.applyTransformOptsToQuery(r,s.transform),(s==null?void 0:s.cacheNonce)!=null&&r.set("cacheNonce",String(s.cacheNonce));const i=r.toString(),o=this._getFinalPath(t),l=()=>wx(this.fetch,`${this.url}/${a}/${o}${i?`?${i}`:""}`,{headers:this.headers,noResolveJson:!0},n);return new vG(l,this.shouldThrowOnError)}async info(t){var s=this;const n=s._getFinalPath(t);return s.handleOperation(async()=>P2(await wx(s.fetch,`${s.url}/object/info/${n}`,{headers:s.headers})))}async exists(t){var s=this;const n=s._getFinalPath(t);try{return await yG(s.fetch,`${s.url}/object/${n}`,{headers:s.headers}),{data:!0,error:null}}catch(r){if(s.shouldThrowOnError)throw r;if(Qb(r)){var a;const i=r instanceof T2?r.status:r instanceof yR?(a=r.originalError)===null||a===void 0?void 0:a.status:void 0;if(i!==void 0&&[400,404].includes(i))return{data:!1,error:r}}throw r}}getPublicUrl(t,s){const n=this._getFinalPath(t),a=new URLSearchParams;s!=null&&s.download&&a.set("download",s.download===!0?"":s.download),s!=null&&s.transform&&this.applyTransformOptsToQuery(a,s.transform),(s==null?void 0:s.cacheNonce)!=null&&a.set("cacheNonce",String(s.cacheNonce));const r=a.toString(),i=typeof(s==null?void 0:s.transform)=="object"&&s.transform!==null&&Object.keys(s.transform).length>0?"render/image":"object";return{data:{publicUrl:encodeURI(`${this.url}/${i}/public/${n}`)+(r?`?${r}`:"")}}}async remove(t){var s=this;return s.handleOperation(async()=>await Nx(s.fetch,`${s.url}/object/${s.bucketId}`,{prefixes:t},{headers:s.headers}))}async purgeCache(t,s,n){var a=this;return a.handleOperation(async()=>{const r=bR(a._getFinalPath(t)),i=new URLSearchParams;s!=null&&s.transformations&&i.set("transformations","true");const o=i.toString();return await Nx(a.fetch,`${a.url}/cdn/${r}${o?`?${o}`:""}`,{},{headers:a.headers},n)})}async list(t,s,n){var a=this;return a.handleOperation(async()=>{const r=s!=null&&s.sortBy?st(st({},lv.sortBy),s.sortBy):lv.sortBy,i=st(st(st({},lv),s),{},{sortBy:r,prefix:t||""});return await qr(a.fetch,`${a.url}/object/list/${a.bucketId}`,i,{headers:a.headers},n)})}async listV2(t,s){var n=this;return n.handleOperation(async()=>{const a=st({},t);return await qr(n.fetch,`${n.url}/object/list-v2/${n.bucketId}`,a,{headers:n.headers},s)})}encodeMetadata(t){return JSON.stringify(t)}toBase64(t){return typeof Buffer<"u"?Buffer.from(t).toString("base64"):btoa(t)}_getFinalPath(t){return`${this.bucketId}/${t.replace(/^\/+/,"")}`}_removeEmptyFolders(t){return t.replace(/^\/|\/$/g,"").replace(/\/+/g,"/")}applyTransformOptsToQuery(t,s){return s.width&&t.set("width",s.width.toString()),s.height&&t.set("height",s.height.toString()),s.resize&&t.set("resize",s.resize),s.format&&t.set("format",s.format),s.quality&&t.set("quality",s.quality.toString()),t}};const wG="2.112.3",nf={"X-Client-Info":`storage-js/${wG}`};var NG=class extends sp{constructor(t,s={},n,a){const r=new URL(t);a!=null&&a.useNewHostname&&/supabase\.(co|in|red)$/.test(r.hostname)&&!r.hostname.includes("storage.supabase.")&&(r.hostname=r.hostname.replace("supabase.","storage.supabase."));const i=r.href.replace(/\/$/,""),o=st(st({},nf),s);super(i,o,n,"storage")}async listBuckets(t){var s=this;return s.handleOperation(async()=>{const n=s.listBucketOptionsToQueryString(t);return await wx(s.fetch,`${s.url}/bucket${n}`,{headers:s.headers})})}async getBucket(t){var s=this;return s.handleOperation(async()=>await wx(s.fetch,`${s.url}/bucket/${t}`,{headers:s.headers}))}async createBucket(t,s={public:!1}){var n=this;return n.handleOperation(async()=>await qr(n.fetch,`${n.url}/bucket`,{id:t,name:t,type:s.type,public:s.public,file_size_limit:s.fileSizeLimit,allowed_mime_types:s.allowedMimeTypes},{headers:n.headers}))}async updateBucket(t,s){var n=this;return n.handleOperation(async()=>await D2(n.fetch,`${n.url}/bucket/${t}`,{id:t,name:t,public:s.public,file_size_limit:s.fileSizeLimit,allowed_mime_types:s.allowedMimeTypes},{headers:n.headers}))}async emptyBucket(t){var s=this;return s.handleOperation(async()=>await qr(s.fetch,`${s.url}/bucket/${t}/empty`,{},{headers:s.headers}))}async deleteBucket(t){var s=this;return s.handleOperation(async()=>await Nx(s.fetch,`${s.url}/bucket/${t}`,{},{headers:s.headers}))}async purgeBucketCache(t,s,n){var a=this;return a.handleOperation(async()=>
1132{const r=new URLSearchParams;s!=null&&s.transformations&&r.set("transformations","true");const i=r.toString();return await Nx(a.fetch,`${a.url}/cdn/${bR(t)}${i?`?${i}`:""}`,{},{headers:a.headers},n)})}listBucketOptionsToQueryString(t){const s={};return t&&("limit"in t&&(s.limit=String(t.limit)),"offset"in t&&(s.offset=String(t.offset)),t.search&&(s.search=t.search),t.sortColumn&&(s.sortColumn=t.sortColumn),t.sortOrder&&(s.sortOrder=t.sortOrder)),Object.keys(s).length>0?"?"+new URLSearchParams(s).toString():""}},_G=class extends sp{constructor(t,s={},n){const a=t.replace(/\/$/,""),r=st(st({},nf),s);super(a,r,n,"storage")}async createBucket(t){var s=this;return s.handleOperation(async()=>await qr(s.fetch,`${s.url}/bucket`,{name:t},{headers:s.headers}))}async listBuckets(t){var s=this;return s.handleOperation(async()=>{const n=new URLSearchParams;(t==null?void 0:t.limit)!==void 0&&n.set("limit",t.limit.toString()),(t==null?void 0:t.offset)!==void 0&&n.set("offset",t.offset.toString()),t!=null&&t.sortColumn&&n.set("sortColumn",t.sortColumn),t!=null&&t.sortOrder&&n.set("sortOrder",t.sortOrder),t!=null&&t.search&&n.set("search",t.search);const a=n.toString(),r=a?`${s.url}/bucket?${a}`:`${s.url}/bucket`;return await wx(s.fetch,r,{headers:s.headers})})}async deleteBucket(t){var s=this;return s.handleOperation(async()=>await Nx(s.fetch,`${s.url}/bucket/${t}`,{},{headers:s.headers}))}from(t){var s=this;if(!hG(t))throw new Kb("Invalid bucket name: File, folder, and bucket names must follow AWS object key naming guidelines and should avoid the use of any other characters.");const n=new oG({baseUrl:this.url,catalogName:t,auth:{type:"custom",getHeaders:async()=>s.headers},fetch:this.fetch}),a=this.shouldThrowOnError;return new Proxy(n,{get(r,i){const o=r[i];return typeof o!="function"?o:async(...l)=>{try{return{data:await o.apply(r,l),error:null}}catch(c){if(a)throw c;return{data:null,error:c}}}}})}},kG=class extends sp{constructor(t,s={},n){const a=t.replace(/\/$/,""),r=st(st({},nf),{},{"Content-Type":"application/json"},s);super(a,r,n,"vectors")}async createIndex(t){var s=this;return s.handleOperation(async()=>await $a.post(s.fetch,`${s.url}/CreateIndex`,t,{headers:s.headers})||{})}async getIndex(t,s){var n=this;return n.handleOperation(async()=>await $a.post(n.fetch,`${n.url}/GetIndex`,{vectorBucketName:t,indexName:s},{headers:n.headers}))}async listIndexes(t){var s=this;return s.handleOperation(async()=>await $a.post(s.fetch,`${s.url}/ListIndexes`,t,{headers:s.headers}))}async deleteIndex(t,s){var n=this;return n.handleOperation(async()=>await $a.post(n.fetch,`${n.url}/DeleteIndex`,{vectorBucketName:t,indexName:s},{headers:n.headers})||{})}},SG=class extends sp{constructor(t,s={},n){const a=t.replace(/\/$/,""),r=st(st({},nf),{},{"Content-Type":"application/json"},s);super(a,r,n,"vectors")}async putVectors(t){var s=this;if(t.vectors.length<1||t.vectors.length>500)throw new Error("Vector batch size must be between 1 and 500 items");return s.handleOperation(async()=>await $a.post(s.fetch,`${s.url}/PutVectors`,t,{headers:s.headers})||{})}async getVectors(t){var s=this;return s.handleOperation(async()=>await $a.post(s.fetch,`${s.url}/GetVectors`,t,{headers:s.headers}))}async listVectors(t){var s=this;if(t.segmentCount!==void 0){if(t.segmentCount<1||t.segmentCount>16)throw new Error("segmentCount must be between 1 and 16");if(t.segmentIndex!==void 0&&(t.segmentIndex<0||t.segmentIndex>=t.segmentCount))throw new Error(`segmentIndex must be between 0 and ${t.segmentCount-1}`)}return s.handleOperation(async()=>await $a.post(s.fetch,`${s.url}/ListVectors`,t,{headers:s.headers}))}async queryVectors(t){var s=this;return s.handleOperation(async()=>await $a.post(s.fetch,`${s.url}/QueryVectors`,t,{headers:s.headers}))}async deleteVectors(t){var s=this;if(t.keys.length<1||t.keys.length>500)throw new Error("Keys batch size must be between 1 and 500 items");return s.handleOperation(async()=>await $a.post(s.fetch,`${s.url}/DeleteVectors`,t,{headers:s.headers})||{})}},CG=class extends sp{constructor(t,s={},n){const a=t.replace(/\/$/,""),r=st(st({},nf),{},{"Content-Type":"application/json"},s);super(a,r,n,"vectors")}async createBucket(t){var s=this;return s.handleOperation(async()=>await $a.post(s.fetch,`${s.url}/CreateVectorBucket`,{vectorBucketName:t},{headers:s.headers})||{})}async getBucket(t){var s=this;return s.handleOperation(async()=>await $a.post(s.fetch,`${s.url}/GetVectorBucket`,{vectorBucketName:t},{headers:s.headers}))}async listBuckets(t={}){var s=this;return s.handleOperation(async()=>await $a.post(s.fetch,`${s.url}/ListVectorBuckets`,t,{headers:s.headers}))}async deleteBucket(t){var s=this;return s.handleOperation(async()=>await $a.post(s.fetch,`${s.url}/DeleteVectorBucket`,{vectorBucketName:t},{headers:s.headers})||{})}},AG=class extends CG{constructor(t,s={}){super(t,s.headers||{},s.fetch)}from(t){return new EG(this.url,this.headers,t,this.fetch)}async createBucket(t){var s=()=>super.createBucket,n=this;return s().call(n,t)}async getBucket(t){var s=()=>super.getBucket,n=this;return s().call(n,t)}async listBuckets(t={}){var s=()=>super.listBuckets,n=this;return s().call(n,t)}async deleteBucket(t){var s=()=>super.deleteBucket,n=this;return s().call(n,t)}},EG=class extends kG{constructor(t,s,n,a){super(t,s,a),this.vectorBucketName=n}async createIndex(t){var s=()=>super.createIndex,n=this;return s().call(n,st(st({},t),{},{vectorBucketName:n.vectorBucketName}))}async listIndexes(t={}){var s=()=>super.listIndexes,n=this;return s().call(n,st(st({},t),{},{vectorBucketName:n.vectorBucketName}))}async getIndex(t){var s=()=>super.getIndex,n=this;return s().call(n,n.vectorBucketName,t)}async deleteIndex(t){var s=()=>super.deleteIndex,n=this;return s().call(n,n.vectorBucketName,t)}index(t){return new FG(this.url,this.headers,this.vectorBucketName,t,this.fetch)}},FG=class extends SG{constructor(t,s,n,a,r){super(t,s,r),this.vectorBucketName=n,this.indexName=a}async putVectors(t){var s=()=>super.putVectors,n=this;return s().call(n,st(st({},t),{},{vectorBucketName:n.vectorBucketName,indexName:n.indexName}))}async getVectors(t){var s=()=>super.getVectors,n=this;return s().call(n,st(st({},t),{},{vectorBucketName:n.vectorBucketName,indexName:n.indexName}))}async listVectors(t={}){var s=()=>super.listVectors,n=this;return s().call(n,st(st({},t),{},{vectorBucketName:n.vectorBucketName,indexName:n.indexName}))}async queryVectors(t){var s=()=>super.queryVectors,n=this;return s().call(n,st(st({},t),{},{vectorBucketName:n.vectorBucketName,indexName:n.indexName}))}async deleteVectors(t){var s=()=>super.deleteVectors,n=this;return s().call(n,st(st({},t),{},{vectorBucketName:n.vectorBucketName,indexName:n.indexName}))}},TG=class extends NG{constructor(t,s={},n,a){super(t,s,n,a)}from(t){return new jG(this.url,this.headers,t,this.fetch)}get vectors(){return new AG(this.url+"/vector",{headers:this.headers,fetch:this.fetch})}get analytics(){return new _G(this.url+"/iceberg",this.headers,this.fetch)}};const NR="2.112.3",oo=30*1e3,rh=3,cv=rh*oo,PG=2*oo,DG="http://localhost:9999",RG="supabase.auth.token",IG={"X-Client-Info":`gotrue-js/${NR}`},R2="X-Supabase-Api-Version",_R={"2024-01-01":{timestamp:Date.parse("2024-01-01T00:00:00.0Z"),name:"2024-01-01"}},$G=/^([a-z0-9_-]{4})*($|[a-z0-9_-]{3}$|[a-z0-9_-]{2}$)$/i,nd="sb_flow_id",zG=5,LG=10*60*1e3;
1132class _x extends Error{constructor(s,n,a){super(s),this.__isAuthError=!0,this.name="AuthError",this.status=n,this.code=a}toJSON(){return{name:this.name,message:this.message,status:this.status,code:this.code}}}function Le(t){return typeof t=="object"&&t!==null&&"__isAuthError"in t}class OG extends _x{constructor(s,n,a){super(s,n,a),this.name="AuthApiError",this.status=n,this.code=a}}function KC(t){return Le(t)&&t.name==="AuthApiError"}class Vr extends _x{constructor(s,n){super(s),this.name="AuthUnknownError",this.originalError=n}}class Ui extends _x{constructor(s,n,a,r){super(s,a,r),this.name=n,this.status=a}}class on extends Ui{constructor(){super("Auth session missing!","AuthSessionMissingError",400,void 0)}}function $f(t){return Le(t)&&t.name==="AuthSessionMissingError"}class Yd extends Ui{constructor(){super("Auth session or user missing","AuthInvalidTokenResponseError",500,void 0)}}class zf extends Ui{constructor(s){super(s,"AuthInvalidCredentialsError",400,void 0)}}class Lf extends Ui{constructor(s,n=null){super(s,"AuthImplicitGrantRedirectError",500,void 0),this.details=null,this.details=n}toJSON(){return Object.assign(Object.assign({},super.toJSON()),{details:this.details})}}function MG(t){return Le(t)&&t.name==="AuthImplicitGrantRedirectError"}class QC extends Ui{constructor(s,n=null){super(s,"AuthPKCEGrantCodeExchangeError",500,void 0),this.details=null,this.details=n}toJSON(){return Object.assign(Object.assign({},super.toJSON()),{details:this.details})}}class BG extends Ui{constructor(){super("PKCE code verifier not found in storage. This can happen if the auth flow was initiated in a different browser or device, or if the storage was cleared. For SSR frameworks (Next.js, SvelteKit, etc.), use @supabase/ssr on both the server and client to store the code verifier in cookies.","AuthPKCECodeVerifierMissingError",400,"pkce_code_verifier_not_found")}}class f0 extends Ui{constructor(s,n){super(s,"AuthRetryableFetchError",n,void 0)}}function Of(t){return Le(t)&&t.name==="AuthRetryableFetchError"}class JC extends Ui{constructor(s="Refresh result discarded: session state changed mid-flight (e.g., concurrent signOut)"){super(s,"AuthRefreshDiscardedError",409,void 0)}}function UG(t){return Le(t)&&t.name==="AuthRefreshDiscardedError"}class XC extends Ui{constructor(s,n,a){super(s,"AuthWeakPasswordError",n,"weak_password"),this.reasons=a}toJSON(){return Object.assign(Object.assign({},super.toJSON()),{reasons:this.reasons})}}class Ly extends Ui{constructor(s){super(s,"AuthInvalidJwtError",400,"invalid_jwt")}}const Oy="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_".split(""),e3=` 1133\r=`.split(""),qG=(()=>{const t=new Array(128);for(let s=0;s<t.length;s+=1)t[s]=-1;for(let s=0;s<e3.length;s+=1)t[e3[s].charCodeAt(0)]=-2;for(let s=0;s<Oy.length;s+=1)t[Oy[s].charCodeAt(0)]=s;return t})();function t3(t,s,n){if(t!==null)for(s.queue=s.queue<<8|t,s.queuedBits+=8;s.queuedBits>=6;){const a=s.queue>>s.queuedBits-6&63;n(Oy[a]),s.queuedBits-=6}else if(s.queuedBits>0)for(s.queue=s.queue<<6-s.queuedBits,s.queuedBits=6;s.queuedBits>=6;){const a=s.queue>>s.queuedBits-6&63;n(Oy[a]),s.queuedBits-=6}}function kR(t,s,n){const a=qG[t];if(a>-1)for(s.queue=s.queue<<6|a,s.queuedBits+=6;s.queuedBits>=8;)n(s.queue>>s.queuedBits-8&255),s.queuedBits-=8;else{if(a===-2)return;throw new Error(`Invalid Base64-URL character "${String.fromCharCode(t)}"`)}}function s3(t){const s=[],n=o=>{s.push(String.fromCodePoint(o))},a={utf8seq:0,codepoint:0},r={queue:0,queuedBits:0},i=o=>{GG(o,a,n)};for(let o=0;o<t.length;o+=1)kR(t.charCodeAt(o),r,i);return s.join("")}function WG(t,s){if(t<=127){s(t);return}else if(t<=2047){s(192|t>>6),s(128|t&63);return}else if(t<=65535){s(224|t>>12),s(128|t>>6&63),s(128|t&63);return}else if(t<=1114111){s(240|t>>18),s(128|t>>12&63),s(128|t>>6&63),s(128|t&63);return}throw new Error(`Unrecognized Unicode codepoint: ${t.toString(16)}`)}function HG(t,s){for(let n=0;n<t.length;n+=1){let a=t.charCodeAt(n);if(a>55295&&a<=56319){const r=(a-55296)*1024&65535;a=(t.charCodeAt(n+1)-56320&65535|r)+65536,n+=1}WG(a,s)}}function GG(t,s,n){if(s.utf8seq===0){if(t<=127){n(t);return}for(let a=1;a<6;a+=1)if(!(t>>7-a&1)){s.utf8seq=a;break}if(s.utf8seq===2)s.codepoint=t&31;else if(s.utf8seq===3)s.codepoint=t&15;else if(s.utf8seq===4)s.codepoint=t&7;else throw new Error("Invalid UTF-8 sequence");s.utf8seq-=1}else if(s.utf8seq>0){if(t<=127)throw new Error("Invalid UTF-8 sequence");s.codepoint=s.codepoint<<6|t&63,s.utf8seq-=1,s.utf8seq===0&&n(s.codepoint)}}function rm(t){const s=[],n={queue:0,queuedBits:0},a=r=>{s.push(r)};for(let r=0;r<t.length;r+=1)kR(t.charCodeAt(r),n,a);return new Uint8Array(s)}function VG(t){const s=[];return HG(t,n=>s.push(n)),new Uint8Array(s)}function ad(t){const s=[],n={queue:0,queuedBits:0},a=r=>{s.push(r)};return t.forEach(r=>t3(r,n,a)),t3(null,n,a),s.join("")}function ZG(t){return Math.round(Date.now()/1e3)+t}function YG(){return Symbol("auth-callback")}const yn=()=>typeof window<"u"&&typeof document<"u",hc={tested:!1,writable:!1},SR=()=>
1133{if(!yn())return!1;try{if(typeof globalThis.localStorage!="object")return!1}catch{return!1}if(hc.tested)return hc.writable;const t=`lswt-${Math.random()}${Math.random()}`;try{globalThis.localStorage.setItem(t,t),globalThis.localStorage.removeItem(t),hc.tested=!0,hc.writable=!0}catch{hc.tested=!0,hc.writable=!1}return hc.writable};function n3(t){const s={},n=new URL(t);if(n.hash&&n.hash[0]==="#")try{new URLSearchParams(n.hash.substring(1)).forEach((r,i)=>{s[i]=r})}catch{}return n.searchParams.forEach((a,r)=>{s[r]=a}),s}const CR=t=>t?(...s)=>t(...s):(...s)=>fetch(...s),KG=t=>typeof t=="object"&&t!==null&&"status"in t&&"ok"in t&&"json"in t&&typeof t.json=="function",ho=async(t,s,n)=>{await t.setItem(s,JSON.stringify(n))},Dn=async(t,s)=>{const n=await t.getItem(s);if(!n)return null;try{return JSON.parse(n)}catch{return null}},pa=async(t,s)=>{await t.removeItem(s)};class Jb{constructor(){this.promise=new Jb.promiseConstructor((s,n)=>{this.resolve=s,this.reject=n})}}Jb.promiseConstructor=Promise;function Mf(t){const s=t.split(".");if(s.length!==3)throw new Ly("Invalid JWT structure");for(let a=0;a<s.length;a++)if(!$G.test(s[a]))throw new Ly("JWT not in base64url format");return{header:JSON.parse(s3(s[0])),payload:JSON.parse(s3(s[1])),signature:rm(s[2]),raw:{header:s[0],payload:s[1]}}}async function QG(t){return await new Promise(s=>{setTimeout(()=>s(null),t)})}function JG(t,s){return new Promise((a,r)=>{(async()=>{for(let i=0;i<1/0;i++)try{const o=await t(i);if(!s(i,null,o)){a(o);return}}catch(o){if(!s(i,o)){r(o);return}}})()})}function AR(t){return("0"+t.toString(16)).substr(-2)}function XG(){const s=new Uint32Array(56);if(typeof crypto>"u"){const n="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-._~",a=n.length;let r="";for(let i=0;i<56;i++)r+=n.charAt(Math.floor(Math.random()*a));return r}return crypto.getRandomValues(s),Array.from(s,AR).join("")}async function eV(t){const n=new TextEncoder().encode(t),a=await crypto.subtle.digest("SHA-256",n),r=new Uint8Array(a);return Array.from(r).map(i=>String.fromCharCode(i)).join("")}async function tV(t){if(!(typeof crypto<"u"&&typeof crypto.subtle<"u"&&typeof TextEncoder<"u"))return console.warn("WebCrypto API is not supported. Code challenge method will default to use plain instead of sha256."),t;const n=await eV(t);return btoa(n).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,"")}const sV=/^[a-zA-Z0-9_-]{8,64}$/;function g0(t){return typeof t=="string"&&sV.test(t)?t:null}function nV(){if(typeof crypto<"u"&&typeof crypto.getRandomValues=="function"){const s=new Uint8Array(16);return crypto.getRandomValues(s),Array.from(s,AR).join("")}let t="";for(let s=0;s<32;s++)t+=Math.floor(Math.random()*16).toString(16);return t}const Rm=(t,s)=>`${t}-flow-${s}-code-verifier`,kx=t=>`${t}-flows-code-verifier`;async function b5(t,s){const n=await Dn(t,kx(s));return Array.isArray(n)?n.filter(a=>g0(a)!==null):[]}async function aV(t,s,n,a,r){await ho(t,Rm(s,n),a);const i=(await b5(t,s)).filter(o=>o!==n);for(i.push(n);i.length>zG;){const o=i.shift();await pa(t,Rm(s,o)),r==null||r(o)}await ho(t,kx(s),i),await ho(t,`${s}-code-verifier`,a)}async function rV(t,s,n){if(n){const r=await Dn(t,Rm(s,n));return{verifier:typeof r=="string"?r:null,flowId:n}}const a=await Dn(t,`${s}-code-verifier`);return{verifier:typeof a=="string"?a:null,flowId:null}}async function Sr(t,s,n){const a=`${s}-code-verifier`;if(!n){await pa(t,a);return}const r=Rm(s,n),i=await Dn(t,r);await pa(t,r);const o=await b5(t,s),l=o.filter(c=>c!==n);l.length!==o.length&&(l.length>0?await ho(t,kx(s),l):await pa(t,kx(s))),i!=null&&i===await Dn(t,a)&&await pa(t,a)}async function iV(t,s){const n=await b5(t,s);for(const a of n)await pa(t,Rm(s,a));await pa(t,kx(s)),await pa(t,`${s}-code-verifier`)}function oV(t,s){const n=t.indexOf("#");let a=n===-1?t:t.slice(0,n);const r=n===-1?"":t.slice(n),i=a.indexOf("?");if(i!==-1){const l=a.slice(0,i),c=a.slice(i+1).split("&").filter(u=>u!==""&&u!==nd&&!u.startsWith(`${nd}=`));a=c.length>0?`${l}?${c.join("&")}`:l}const o=a.includes("?")?"&":"?";return`${a}${o}${nd}=${encodeURIComponent(s)}${r}`}async function lV(t,s,n=!1,a){const r=XG();let i=r;n&&(i+="/recovery");const o=nV();await aV(t,s,o,i,a);const l=await tV(r);return[l,r===l?"plain":"s256",o]}const cV=/^2[0-9]{3}-(0[1-9]|1[0-2])-(0[1-9]|1[0-9]|2[0-9]|3[0-1])$/i;function dV(t){const s=t.headers.get(R2);if(!s||!s.match(cV))return null;try{return new Date(`${s}T00:00:00.0Z`)}catch{return null}}function uV(t){if(!t)throw new Error("Missing exp claim");const s=Math.floor(Date.now()/1e3);if(t<=s)throw new Error("JWT has expired")}function mV(t){switch(t){case"RS256":return{name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-256"}};case"ES256":return{name:"ECDSA",namedCurve:"P-256",hash:{name:"SHA-256"}};default:throw new Error("Invalid alg claim")}}const pV=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;function Wi(t){if(!pV.test(t))throw new Error("@supabase/auth-js: Expected parameter to be UUID but is not")}function $r(t){if(!t.passkey)throw new Error("@supabase/auth-js: the passkey API is experimental and disabled by default. Enable it by passing `auth: { experimental: { passkey: true } }` to createClient (or to the GoTrueClient constructor).")}function dv(){const t={};return new Proxy(t,{get:(s,n)=>{if(n==="__isUserNotAvailableProxy")return!0;
1133if(typeof n=="symbol"){const a=n.toString();if(a==="Symbol(Symbol.toPrimitive)"||a==="Symbol(Symbol.toStringTag)"||a==="Symbol(util.inspect.custom)")return}throw new Error(`@supabase/auth-js: client was created with userStorage option and there was no user stored in the user storage. Accessing the "${n}" property of the session object is not supported. Please use getUser() instead.`)},set:(s,n)=>{throw new Error(`@supabase/auth-js: client was created with userStorage option and there was no user stored in the user storage. Setting the "${n}" property of the session object is not supported. Please use getUser() to fetch a user object you can manipulate.`)},deleteProperty:(s,n)=>{throw new Error(`@supabase/auth-js: client was created with userStorage option and there was no user stored in the user storage. Deleting the "${n}" property of the session object is not supported. Please use getUser() to fetch a user object you can manipulate.`)}})}function hV(t,s){return new Proxy(t,{get:(n,a,r)=>{if(a==="__isInsecureUserWarningProxy")return!0;if(typeof a=="symbol"){const i=a.toString();if(i==="Symbol(Symbol.toPrimitive)"||i==="Symbol(Symbol.toStringTag)"||i==="Symbol(util.inspect.custom)"||i==="Symbol(nodejs.util.inspect.custom)")return Reflect.get(n,a,r)}return!s.value&&typeof a=="string"&&(console.warn("Using the user object as returned from supabase.auth.getSession() or from some supabase.auth.onAuthStateChange() events could be insecure! This value comes directly from the storage medium (usually cookies on the server) and may not be authentic. Use supabase.auth.getUser() instead which authenticates the data by contacting the Supabase Auth server."),s.value=!0),Reflect.get(n,a,r)}})}function a3(t){return JSON.parse(JSON.stringify(t))}const Wc=t=>{if(typeof t=="object"&&t!==null){const s=t;if(typeof s.msg=="string")return s.msg;if(typeof s.message=="string")return s.message;if(typeof s.error_description=="string")return s.error_description;if(typeof s.error=="string")return s.error}return JSON.stringify(t)},r3=[500,501,502,503,504,520,521,522,523,524,525,526,527,528,529,530];async function i3(t){var s;if(!KG(t))throw new f0(Wc(t),0);let n;try{n=await t.json()}catch(i){throw r3.includes(t.status)?new f0(t.statusText||`HTTP ${t.status}`,t.status):new Vr(Wc(i),i)}if(r3.includes(t.status))throw new f0(Wc(n),t.status);let a;const r=dV(t);if(r&&r.getTime()>=_R["2024-01-01"].timestamp&&typeof n=="object"&&n&&typeof n.code=="string"?a=n.code:typeof n=="object"&&n&&typeof n.error_code=="string"&&(a=n.error_code),a){if(a==="weak_password")throw new XC(Wc(n),t.status,((s=n.weak_password)===null||s===void 0?void 0:s.reasons)||[]);if(a==="session_not_found")throw new on}else if(typeof n=="object"&&n&&typeof n.weak_password=="object"&&n.weak_password&&Array.isArray(n.weak_password.reasons)&&n.weak_password.reasons.length&&n.weak_password.reasons.reduce((i,o)=>i&&typeof o=="string",!0))throw new XC(Wc(n),t.status,n.weak_password.reasons);throw new OG(Wc(n),t.status||500,a)}const xV=(t,s,n,a)=>{const r={method:t,headers:(s==null?void 0:s.headers)||{}};return t==="GET"?r:(r.headers=Object.assign({"Content-Type":"application/json;charset=UTF-8"},s==null?void 0:s.headers),r.body=JSON.stringify(a),Object.assign(Object.assign({},r),n))};async function Ze(t,s,n,a){var r;const i=Object.assign({},a==null?void 0:a.headers);i[R2]||(i[R2]=_R["2024-01-01"].name),a!=null&&a.jwt&&(i.Authorization=`Bearer ${a.jwt}`);const o=(r=a==null?void 0:a.query)!==null&&r!==void 0?r:{};a!=null&&a.redirectTo&&(o.redirect_to=a.redirectTo);const l=Object.keys(o).length?"?"+new URLSearchParams(o).toString():"",c=await fV(t,s,n+l,{headers:i,noResolveJson:a==null?void 0:a.noResolveJson},{},a==null?void 0:a.body);return a!=null&&a.xform?a==null?void 0:a.xform(c):{data:Object.assign({},c),error:null}}async function fV(t,s,n,a,r,i){const o=xV(s,a,r,i);let l;try{l=await t(n,Object.assign({},o))}catch(c){throw new f0(Wc(c),0)}if(l.ok||await i3(l),a!=null&&a.noResolveJson)return l;try{return await l.json()}catch(c){await i3(c)}}function or(t){var s;let n=null;bV(t)&&(n=Object.assign({},t),t.expires_at||(n.expires_at=ZG(t.expires_in)));const a=(s=t.user)!==null&&s!==void 0?s:typeof(t==null?void 0:t.id)=="string"?t:null;return{data:{session:n,user:a},error:null}}function o3(t){const s=or(t);return!s.error&&t.weak_password&&typeof t.weak_password=="object"&&Array.isArray(t.weak_password.reasons)&&t.weak_password.reasons.length&&t.weak_password.message&&typeof t.weak_password.message=="string"&&t.weak_password.reasons.reduce((n,a)=>
1133n&&typeof a=="string",!0)&&(s.data.weak_password=t.weak_password),s}function vl(t){var s;return{data:{user:(s=t.user)!==null&&s!==void 0?s:t},error:null}}function gV(t){return{data:t,error:null}}function yV(t){const{action_link:s,email_otp:n,hashed_token:a,redirect_to:r,verification_type:i}=t,o=tp(t,["action_link","email_otp","hashed_token","redirect_to","verification_type"]),l={action_link:s,email_otp:n,hashed_token:a,redirect_to:r,verification_type:i},c=Object.assign({},o);return{data:{properties:l,user:c},error:null}}function l3(t){return t}function bV(t){return!!t.access_token&&!!t.refresh_token&&!!t.expires_in}const uv=["global","local","others"];class vV{constructor({url:s="",headers:n={},fetch:a,experimental:r}){this.url=s,this.headers=n,this.fetch=CR(a),this.experimental=r??{},this.mfa={listFactors:this._listFactors.bind(this),deleteFactor:this._deleteFactor.bind(this)},this.oauth={listClients:this._listOAuthClients.bind(this),createClient:this._createOAuthClient.bind(this),getClient:this._getOAuthClient.bind(this),updateClient:this._updateOAuthClient.bind(this),deleteClient:this._deleteOAuthClient.bind(this),regenerateClientSecret:this._regenerateOAuthClientSecret.bind(this)},this.customProviders={listProviders:this._listCustomProviders.bind(this),createProvider:this._createCustomProvider.bind(this),getProvider:this._getCustomProvider.bind(this),updateProvider:this._updateCustomProvider.bind(this),deleteProvider:this._deleteCustomProvider.bind(this)},this.passkey={listPasskeys:this._adminListPasskeys.bind(this),deletePasskey:this._adminDeletePasskey.bind(this)}}async signOut(s,n=uv[0]){if(uv.indexOf(n)<0)throw new Error(`@supabase/auth-js: Parameter scope must be one of ${uv.join(", ")}`);try{return await Ze(this.fetch,"POST",`${this.url}/logout?scope=${n}`,{headers:this.headers,jwt:s,noResolveJson:!0}),{data:null,error:null}}catch(a){if(Le(a))return{data:null,error:a};throw a}}async inviteUserByEmail(s,n={}){try{return await Ze(this.fetch,"POST",`${this.url}/invite`,{body:{email:s,data:n.data},headers:this.headers,redirectTo:n.redirectTo,xform:vl})}catch(a){if(Le(a))return{data:{user:null},error:a};throw a}}async generateLink(s){try{const{options:n}=s,a=tp(s,["options"]),r=Object.assign(Object.assign({},a),n);return"newEmail"in a&&(r.new_email=a==null?void 0:a.newEmail,delete r.newEmail),await Ze(this.fetch,"POST",`${this.url}/admin/generate_link`,{body:r,headers:this.headers,xform:yV,redirectTo:n==null?void 0:n.redirectTo})}catch(n){if(Le(n))return{data:{properties:null,user:null},error:n};throw n}}async createUser(s){try{return await Ze(this.fetch,"POST",`${this.url}/admin/users`,{body:s,headers:this.headers,xform:vl})}catch(n){if(Le(n))return{data:{user:null},error:n};throw n}}async listUsers(s){var n,a,r,i,o,l,c;try{const u={nextPage:null,lastPage:0,total:0},p=await Ze(this.fetch,"GET",`${this.url}/admin/users`,{headers:this.headers,noResolveJson:!0,query:{page:(a=(n=s==null?void 0:s.page)===null||n===void 0?void 0:n.toString())!==null&&a!==void 0?a:"",per_page:(i=(r=s==null?void 0:s.perPage)===null||r===void 0?void 0:r.toString())!==null&&i!==void 0?i:""},xform:l3});if(p.error)throw p.error;const m=await p.json(),x=(o=p.headers.get("x-total-count"))!==null&&o!==void 0?o:0,h=(c=(l=p.headers.get("link"))===null||l===void 0?void 0:l.split(","))!==null&&c!==void 0?c:[];return h.length>0&&(h.forEach(y=>{const v=parseInt(y.split(";")[0].split("=")[1].substring(0,1)),g=JSON.parse(y.split(";")[1].split("=")[1]);u[`${g}Page`]=v}),u.total=parseInt(x)),{data:Object.assign(Object.assign({},m),u),error:null}}catch(u){if(Le(u))return{data:{users:[]},error:u};throw u}}async getUserById(s){Wi(s);try{return await Ze(this.fetch,"GET",`${this.url}/admin/users/${s}`,{headers:this.headers,xform:vl})}catch(n){if(Le(n))return{data:{user:null},error:n};throw n}}async updateUserById(s,n){Wi(s);try{return await Ze(this.fetch,"PUT",`${this.url}/admin/users/${s}`,{body:n,headers:this.headers,xform:vl})}catch(a){if(Le(a))return{data:{user:null},error:a};throw a}}async deleteUser(s,n=!1){Wi(s);try{return await Ze(this.fetch,"DELETE",`${this.url}/admin/users/${s}`,{headers:this.headers,body:{should_soft_delete:n},xform:vl})}catch(a){if(Le(a))return{data:{user:null},error:a};throw a}}async _listFactors(s){Wi(s.userId);try{const{data:n,error:a}=await Ze(this.fetch,"GET",`${this.url}/admin/users/${s.userId}/factors`,{headers:this.headers,xform:r=>({data:{factors:r},error:null})});return{data:n,error:a}}catch(n){if(Le(n))return{data:null,error:n};throw n}}async _deleteFactor(s){Wi(s.userId),Wi(s.id);
1133try{return{data:await Ze(this.fetch,"DELETE",`${this.url}/admin/users/${s.userId}/factors/${s.id}`,{headers:this.headers}),error:null}}catch(n){if(Le(n))return{data:null,error:n};throw n}}async _listOAuthClients(s){var n,a,r,i,o,l,c;try{const u={nextPage:null,lastPage:0,total:0},p=await Ze(this.fetch,"GET",`${this.url}/admin/oauth/clients`,{headers:this.headers,noResolveJson:!0,query:{page:(a=(n=s==null?void 0:s.page)===null||n===void 0?void 0:n.toString())!==null&&a!==void 0?a:"",per_page:(i=(r=s==null?void 0:s.perPage)===null||r===void 0?void 0:r.toString())!==null&&i!==void 0?i:""},xform:l3});if(p.error)throw p.error;const m=await p.json(),x=(o=p.headers.get("x-total-count"))!==null&&o!==void 0?o:0,h=(c=(l=p.headers.get("link"))===null||l===void 0?void 0:l.split(","))!==null&&c!==void 0?c:[];return h.length>0&&(h.forEach(y=>{const v=parseInt(y.split(";")[0].split("=")[1].substring(0,1)),g=JSON.parse(y.split(";")[1].split("=")[1]);u[`${g}Page`]=v}),u.total=parseInt(x)),{data:Object.assign(Object.assign({},m),u),error:null}}catch(u){if(Le(u))return{data:{clients:[]},error:u};throw u}}async _createOAuthClient(s){try{return await Ze(this.fetch,"POST",`${this.url}/admin/oauth/clients`,{body:s,headers:this.headers,xform:n=>({data:n,error:null})})}catch(n){if(Le(n))return{data:null,error:n};throw n}}async _getOAuthClient(s){try{return await Ze(this.fetch,"GET",`${this.url}/admin/oauth/clients/${s}`,{headers:this.headers,xform:n=>({data:n,error:null})})}catch(n){if(Le(n))return{data:null,error:n};throw n}}async _updateOAuthClient(s,n){try{return await Ze(this.fetch,"PUT",`${this.url}/admin/oauth/clients/${s}`,{body:n,headers:this.headers,xform:a=>({data:a,error:null})})}catch(a){if(Le(a))return{data:null,error:a};throw a}}async _deleteOAuthClient(s){try{return await Ze(this.fetch,"DELETE",`${this.url}/admin/oauth/clients/${s}`,{headers:this.headers,noResolveJson:!0}),{data:null,error:null}}catch(n){if(Le(n))return{data:null,error:n};throw n}}async _regenerateOAuthClientSecret(s){try{return await Ze(this.fetch,"POST",`${this.url}/admin/oauth/clients/${s}/regenerate_secret`,{headers:this.headers,xform:n=>({data:n,error:null})})}catch(n){if(Le(n))return{data:null,error:n};throw n}}async _listCustomProviders(s){try{const n={};return s!=null&&s.type&&(n.type=s.type),await Ze(this.fetch,"GET",`${this.url}/admin/custom-providers`,{headers:this.headers,query:n,xform:a=>{var r;return{data:{providers:(r=a==null?void 0:a.providers)!==null&&r!==void 0?r:[]},error:null}}})}catch(n){if(Le(n))return{data:{providers:[]},error:n};throw n}}async _createCustomProvider(s){try{return await Ze(this.fetch,"POST",`${this.url}/admin/custom-providers`,{body:s,headers:this.headers,xform:n=>({data:n,error:null})})}catch(n){if(Le(n))return{data:null,error:n};throw n}}async _getCustomProvider(s){try{return await Ze(this.fetch,"GET",`${this.url}/admin/custom-providers/${s}`,{headers:this.headers,xform:n=>({data:n,error:null})})}catch(n){if(Le(n))return{data:null,error:n};throw n}}async _updateCustomProvider(s,n){try{return await Ze(this.fetch,"PUT",`${this.url}/admin/custom-providers/${s}`,{body:n,headers:this.headers,xform:a=>({data:a,error:null})})}catch(a){if(Le(a))return{data:null,error:a};throw a}}async _deleteCustomProvider(s){try{return await Ze(this.fetch,"DELETE",`${this.url}/admin/custom-providers/${s}`,{headers:this.headers,noResolveJson:!0}),{data:null,error:null}}catch(n){if(Le(n))return{data:null,error:n};throw n}}async _adminListPasskeys(s){$r(this.experimental),Wi(s.userId);try{return await Ze(this.fetch,"GET",`${this.url}/admin/users/${s.userId}/passkeys`,{headers:this.headers,xform:n=>({data:n,error:null})})}catch(n){if(Le(n))return{data:null,error:n};throw n}}async _adminDeletePasskey(s){$r(this.experimental),Wi(s.userId),Wi(s.passkeyId);try{return await Ze(this.fetch,"DELETE",`${this.url}/admin/users/${s.userId}/passkeys/${s.passkeyId}`,{headers:this.headers,noResolveJson:!0}),{data:null,error:null}}catch(n){if(Le(n))return{data:null,error:n};throw n}}}function c3(t={}){return{getItem:s=>t[s]||null,setItem:(s,n)=>{t[s]=n},removeItem:s=>{delete t[s]}}}globalThis&&SR()&&globalThis.localStorage&&globalThis.localStorage.getItem("supabase.gotrue-js.locks.debug");
1133class jV extends Error{constructor(s){super(s),this.isAcquireTimeout=!0}}function wV(){if(typeof globalThis!="object")try{Object.defineProperty(Object.prototype,"__magic__",{get:function(){return this},configurable:!0}),__magic__.globalThis=__magic__,delete Object.prototype.__magic__}catch{typeof self<"u"&&(self.globalThis=self)}}function ER(t){if(!/^0x[a-fA-F0-9]{40}$/.test(t))throw new Error(`@supabase/auth-js: Address "${t}" is invalid.`);return t.toLowerCase()}function NV(t){return parseInt(t,16)}function _V(t){const s=new TextEncoder().encode(t);return"0x"+Array.from(s,a=>a.toString(16).padStart(2,"0")).join("")}function kV(t){var s;const{chainId:n,domain:a,expirationTime:r,issuedAt:i=new Date,nonce:o,notBefore:l,requestId:c,resources:u,scheme:p,uri:m,version:x}=t;{if(!Number.isInteger(n))throw new Error(`@supabase/auth-js: Invalid SIWE message field "chainId". Chain ID must be a EIP-155 chain ID. Provided value: ${n}`);if(!a)throw new Error('@supabase/auth-js: Invalid SIWE message field "domain". Domain must be provided.');if(o&&o.length<8)throw new Error(`@supabase/auth-js: Invalid SIWE message field "nonce". Nonce must be at least 8 characters. Provided value: ${o}`);if(!m)throw new Error('@supabase/auth-js: Invalid SIWE message field "uri". URI must be provided.');if(x!=="1")throw new Error(`@supabase/auth-js: Invalid SIWE message field "version". Version must be '1'. Provided value: ${x}`);if(!((s=t.statement)===null||s===void 0)&&s.includes(` 1134`))throw new Error(`@supabase/auth-js: Invalid SIWE message field "statement". Statement must not include '\\n'. Provided value: ${t.statement}`)}const h=ER(t.address),y=p?`${p}://${a}`:a,v=t.statement?`${t.statement} 1135`:"",g=`${y}
1135 wants you to sign in with your Ethereum account: 1136${h} 1137 1138${v}`;let N=`URI: ${m} 1139Version: ${x} 1140Chain ID: ${n}${o?` 1141Nonce: ${o}`:""} 1142Issued At: ${i.toISOString()}`;if(r&&(N+=` 1143Expiration Time: ${r.toISOString()}`),l&&(N+=` 1144Not Before: ${l.toISOString()}`),c&&(N+=` 1145Request ID: ${c}`),u){let b=` 1146Resources:`;for(const f of u){if(!f||typeof f!="string")throw new Error(`@supabase/auth-js: Invalid SIWE message field "resources". Every resource must be a valid string. Provided value: ${f}`);b+=` 1147- ${f}`}N+=b}return`${g} 1148${N}`}class Bs extends Error{constructor({message:s,code:n,cause:a,name:r}){var i;super(s,{cause:a}),this.__isWebAuthnError=!0,this.name=(i=r??(a instanceof Error?a.name:void 0))!==null&&i!==void 0?i:"Unknown Error",this.code=n}toJSON(){return{name:this.name,message:this.message,code:this.code}}}class My extends Bs{constructor(s,n){super({code:"ERROR_PASSTHROUGH_SEE_CAUSE_PROPERTY",cause:n,message:s}),this.name="WebAuthnUnknownError",this.originalError=n}}function SV({error:t,options:s}){var n,a,r;const{publicKey:i}=s;if(!i)throw Error("options was missing required publicKey property");if(t.name==="AbortError"){if(s.signal instanceof AbortSignal)return new Bs({message:"Registration ceremony was sent an abort signal",code:"ERROR_CEREMONY_ABORTED",cause:t})}else if(t.name==="ConstraintError"){if(((n=i.authenticatorSelection)===null||n===void 0?void 0:n.requireResidentKey)===!0)return new Bs({message:"Discoverable credentials were required but no available authenticator supported it",code:"ERROR_AUTHENTICATOR_MISSING_DISCOVERABLE_CREDENTIAL_SUPPORT",cause:t});if(s.mediation==="conditional"&&((a=i.authenticatorSelection)===null||a===void 0?void 0:a.userVerification)==="required")return new Bs({message:"User verification was required during automatic registration but it could not be performed",code:"ERROR_AUTO_REGISTER_USER_VERIFICATION_FAILURE",cause:t});if(((r=i.authenticatorSelection)===null||r===void 0?void 0:r.userVerification)==="required")return new Bs({message:"User verification was required but no available authenticator supported it",code:"ERROR_AUTHENTICATOR_MISSING_USER_VERIFICATION_SUPPORT",cause:t})}else{if(t.name==="InvalidStateError")return new Bs({message:"The authenticator was previously registered",code:"ERROR_AUTHENTICATOR_PREVIOUSLY_REGISTERED",cause:t});if(t.name==="NotAllowedError")return new Bs({message:t.message,code:"ERROR_PASSTHROUGH_SEE_CAUSE_PROPERTY",cause:t});if(t.name==="NotSupportedError")return i.pubKeyCredParams.filter(l=>l.type==="public-key").length===0?new Bs({message:'No entry in pubKeyCredParams was of type "public-key"',code:"ERROR_MALFORMED_PUBKEYCREDPARAMS",cause:t}):new Bs({message:"No available authenticator supported any of the specified pubKeyCredParams algorithms",code:"ERROR_AUTHENTICATOR_NO_SUPPORTED_PUBKEYCREDPARAMS_ALG",cause:t});if(t.name==="SecurityError"){const o=window.location.hostname;if(FR(o)){if(i.rp.id!==o)return new Bs({message:`The RP ID "${i.rp.id}" is invalid for this domain`,code:"ERROR_INVALID_RP_ID",cause:t})}else return new Bs({message:`${window.location.hostname} is an invalid domain`,code:"ERROR_INVALID_DOMAIN",cause:t})}else if(t.name==="TypeError"){if(i.user.id.byteLength<1||i.user.id.byteLength>64)return new Bs({message:"User ID was not between 1 and 64 characters",code:"ERROR_INVALID_USER_ID_LENGTH",cause:t})}else if(t.name==="UnknownError")return new Bs({message:"The authenticator was unable to process the specified options, or could not create a new credential",code:"ERROR_AUTHENTICATOR_GENERAL_ERROR",cause:t})}return new Bs({message:"a Non-Webauthn related error has occurred",code:"ERROR_PASSTHROUGH_SEE_CAUSE_PROPERTY",cause:t})}function CV({error:t,options:s}){const{publicKey:n}=s;if(!n)throw Error("options was missing required publicKey property");if(t.name==="AbortError"){if(s.signal instanceof AbortSignal)return new Bs({message:"Authentication ceremony was sent an abort signal",code:"ERROR_CEREMONY_ABORTED",cause:t})}else{if(t.name==="NotAllowedError")return new Bs({message:t.message,code:"ERROR_PASSTHROUGH_SEE_CAUSE_PROPERTY",cause:t});if(t.name==="SecurityError"){const a=window.location.hostname;if(FR(a)){if(n.rpId!==a)return new Bs({message:`The RP ID "${n.rpId}
1148" is invalid for this domain`,code:"ERROR_INVALID_RP_ID",cause:t})}else return new Bs({message:`${window.location.hostname} is an invalid domain`,code:"ERROR_INVALID_DOMAIN",cause:t})}else if(t.name==="UnknownError")return new Bs({message:"The authenticator was unable to process the specified options, or could not create a new assertion signature",code:"ERROR_AUTHENTICATOR_GENERAL_ERROR",cause:t})}return new Bs({message:"a Non-Webauthn related error has occurred",code:"ERROR_PASSTHROUGH_SEE_CAUSE_PROPERTY",cause:t})}class AV{createNewAbortSignal(){if(this.controller){const n=new Error("Cancelling existing WebAuthn API call for new one");n.name="AbortError",this.controller.abort(n)}const s=new AbortController;return this.controller=s,s.signal}cancelCeremony(){if(this.controller){const s=new Error("Manually cancelling existing WebAuthn API call");s.name="AbortError",this.controller.abort(s),this.controller=void 0}}}const I2=new AV;function d3(t){if(!t)throw new Error("Credential creation options are required");if(typeof PublicKeyCredential<"u"&&"parseCreationOptionsFromJSON"in PublicKeyCredential&&typeof PublicKeyCredential.parseCreationOptionsFromJSON=="function")return PublicKeyCredential.parseCreationOptionsFromJSON(t);const{challenge:s,user:n,excludeCredentials:a}=t,r=tp(t,["challenge","user","excludeCredentials"]),i=rm(s).buffer,o=Object.assign(Object.assign({},n),{id:rm(n.id).buffer}),l=Object.assign(Object.assign({},r),{challenge:i,user:o});if(a&&a.length>0){l.excludeCredentials=new Array(a.length);for(let c=0;c<a.length;c++){const u=a[c];l.excludeCredentials[c]=Object.assign(Object.assign({},u),{id:rm(u.id).buffer,type:u.type||"public-key",transports:u.transports})}}return l}function u3(t){if(!t)throw new Error("Credential request options are required");if(typeof PublicKeyCredential<"u"&&"parseRequestOptionsFromJSON"in PublicKeyCredential&&typeof PublicKeyCredential.parseRequestOptionsFromJSON=="function")return PublicKeyCredential.parseRequestOptionsFromJSON(t);const{challenge:s,allowCredentials:n}=t,a=tp(t,["challenge","allowCredentials"]),r=rm(s).buffer,i=Object.assign(Object.assign({},a),{challenge:r});if(n&&n.length>0){i.allowCredentials=new Array(n.length);for(let o=0;o<n.length;o++){const l=n[o];i.allowCredentials[o]=Object.assign(Object.assign({},l),{id:rm(l.id).buffer,type:l.type||"public-key",transports:l.transports})}}return i}function m3(t){var s;if("toJSON"in t&&typeof t.toJSON=="function")return t.toJSON();const n=t;return{id:t.id,rawId:t.id,response:{attestationObject:ad(new Uint8Array(t.response.attestationObject)),clientDataJSON:ad(new Uint8Array(t.response.clientDataJSON))},type:"public-key",clientExtensionResults:t.getClientExtensionResults(),authenticatorAttachment:(s=n.authenticatorAttachment)!==null&&s!==void 0?s:void 0}}function p3(t){var s;if("toJSON"in t&&typeof t.toJSON=="function")return t.toJSON();const n=t,a=t.getClientExtensionResults(),r=t.response;return{id:t.id,rawId:t.id,response:{authenticatorData:ad(new Uint8Array(r.authenticatorData)),clientDataJSON:ad(new Uint8Array(r.clientDataJSON)),signature:ad(new Uint8Array(r.signature)),userHandle:r.userHandle?ad(new Uint8Array(r.userHandle)):void 0},type:"public-key",clientExtensionResults:a,authenticatorAttachment:(s=n.authenticatorAttachment)!==null&&s!==void 0?s:void 0}}function FR(t){return t==="localhost"||/^([a-z0-9]+(-[a-z0-9]+)*\.)+[a-z]{2,}$/i.test(t)}function By(){var t,s;return!!(yn()&&"PublicKeyCredential"in window&&window.PublicKeyCredential&&"credentials"in navigator&&typeof((t=navigator==null?void 0:navigator.credentials)===null||t===void 0?void 0:t.create)=="function"&&typeof((s=navigator==null?void 0:navigator.credentials)===null||s===void 0?void 0:s.get)=="function")}async function TR(t){try{const s=await navigator.credentials.create(t);return s?s instanceof PublicKeyCredential?{data:s,error:null}:{data:null,error:new My("Browser returned unexpected credential type",s)}:{data:null,error:new My("Empty credential response",s)}}catch(s){return{data:null,error:SV({error:s,options:t})}}}async function PR(t){try{const s=await navigator.credentials.get(t);return s?s instanceof PublicKeyCredential?{data:s,error:null}:{data:null,error:new My("Browser returned unexpected credential type",s)}:{data:null,error:new My("Empty credential response",s)}}catch(s){return{data:null,error:CV({error:s,options:t})}}}const EV={hints:["security-key"],authenticatorSelection:{authenticatorAttachment:"cross-platform",requireResidentKey:!1,userVerification:"preferred",residentKey:"discouraged"},attestation:"direct"},FV={userVerification:"preferred",hints:["security-key"],attestation:"direct"};function Uy(...t){const s=r=>r!==null&&typeof r=="object"&&!Array.isArray(r),n=r=>r instanceof ArrayBuffer||ArrayBuffer.isView(r),a={};for(const r of t)if(r)for(const i in r){const o=r[i];if(o!==void 0)if(Array.isArray(o))a[i]=o;else if(n(o))a[i]=o;else if(s(o)){const l=a[i];s(l)?a[i]=Uy(l,o):a[i]=Uy(o)}else a[i]=o}return a}function TV(t,s){return Uy(EV,t,s||{})}function PV(t,s){return Uy(FV,t,s||{})}class DV{constructor(s){this.client=s,this.enroll=this._enroll.bind(this),this.challenge=this._challenge.bind(this),this.verify=this._verify.bind(this),this.authenticate=this._authenticate.bind(this),this.register=this._register.bind(this)}async _enroll(s){return this.client.mfa.enroll(Object.assign(Object.assign({},s),{factorType:"webauthn"}))}async _challenge({factorId:s,webauthn:n,friendlyName:a,signal:r},i){var o;try{const{data:l,error:c}=await this.client.mfa.challenge({factorId:s,webauthn:n});if(!l)return{data:null,error:c};const u=r??I2.createNewAbortSignal();if(l.webauthn.type==="create"){const{user:p}=l.webauthn.credential_options.publicKey;if(!p.name){const m=a;if(m)p.name=`${p.id}:${m}`;else{const h=(await this.client.getUser()).data.user,y=((o=h==null?void 0:h.user_metadata)===null||o===void 0?void 0:o.name)||(h==null?void 0:h.email)||(h==null?void 0:h.id)||"User";p.name=`${p.id}:${y}`}}p.displayName||(p.displayName=p.name)}switch(l.webauthn.type){case"create":{const p=TV(l.webauthn.credential_options.publicKey,i==null?void 0:i.create),{data:m,error:x}=await TR({publicKey:p,signal:u});return m?{data:{factorId:s,challengeId:l.id,webauthn:{type:l.webauthn.type,credential_response:m}},error:null}:{data:null,error:x}}case"request":{const p=PV(l.webauthn.credential_options.publicKey,i==null?void 0:i.request),{data:m,error:x}=await PR(Object.assign(Object.assign({},l.webauthn.credential_options),{publicKey:p,signal:u}));return m?{data:{factorId:s,challengeId:l.id,webauthn:{type:l.webauthn.type,credential_response:m}},error:null}:{data:null,error:x}}}}catch(l){return Le(l)?{data:null,error:l}:{data:null,error:new Vr("Unexpected error in challenge",l)}}}async _verify({challengeId:s,factorId:n,webauthn:a}){return this.client.mfa.verify({factorId:n,challengeId:s,webauthn:a})}async _authenticate({factorId:s,webauthn:{rpId:n=typeof window<"u"?window.location.hostname:void 0,rpOrigins:a=typeof window<"u"?[window.location.origin]:void 0,signal:r}={}},i){if(!n)return{data:null,error:new _x("rpId is required for WebAuthn authentication")};try{if(!By())return{data:null,error:new Vr("Browser does not support WebAuthn",null)};const{data:o,error:l}=await this.challenge({factorId:s,webauthn:{rpId:n,rpOrigins:a},signal:r},{request:i});if(!o)return{data:null,error:l};const{webauthn:c}=o;return this._verify({factorId:s,challengeId:o.challengeId,webauthn:{type:c.type,rpId:n,rpOrigins:a,credential_response:c.credential_response}})}catch(o){return Le(o)?{data:null,error:o}:{data:null,error:new Vr("Unexpected error in authenticate",o)}}}async _register({friendlyName:s,webauthn:{rpId:n=typeof window<"u"?window.location.hostname:void 0,rpOrigins:a=typeof window<"u"?[window.location.origin]:void 0,signal:r}={}},i){if(!n)return{data:null,error:new _x("rpId is required for WebAuthn registration")};try{if(!By())return{data:null,error:new Vr("Browser does not support WebAuthn",null)};const{data:o,error:l}=await this._enroll({friendlyName:s});if(!o)return await this.client.mfa.listFactors().then(p=>{var m;return(m=p.data)===null||m===void 0?void 0:m.all.find(x=>x.factor_type==="webauthn"&&x.friendly_name===s&&x.status!=="unverified")}).then(p=>p?this.client.mfa.unenroll({factorId:p==null?void 0:p.id}):void 0),{data:null,error:l};const{data:c,error:u}=await this._challenge({factorId:o.id,friendlyName:o.friendly_name,webauthn:{rpId:n,rpOrigins:a},signal:r},{create:i});return c?this._verify({factorId:o.id,challengeId:c.challengeId,webauthn:{rpId:n,rpOrigins:a,type:c.webauthn.type,credential_response:c.webauthn.credential_response}}):{data:null,error:u}}catch(o){return Le(o)?{data:null,error:o}:{data:null,error:new Vr("Unexpected error in register",o)}}}}wV();const RV={url:DG,storageKey:RG,autoRefreshToken:!0,persistSession:!0,detectSessionInUrl:!0,headers:IG,flowType:"implicit",debug:!1,hasCustomAuthorizationHeader:!1,throwOnError:!1,lockAcquireTimeout:5e3,skipAutoInitialize:!1,experimental:{}},Kd={};class Sx{get jwks(){var s,n;return(n=(s=Kd[this.storageKey])===null||s===void 0?void 0:s.jwks)!==null&&n!==void 0?n:{keys:[]}}set jwks(s){Kd[this.storageKey]=Object.assign(Object.assign({},Kd[this.storageKey]),{jwks:s})}get jwks_cached_at(){var s,n;return(n=(s=Kd[this.storageKey])===null||s===void 0?void 0:s.cachedAt)!==null&&n!==void 0?n:Number.MIN_SAFE_INTEGER}set jwks_cached_at(s){Kd[this.storageKey]=Object.assign(Object.assign({},Kd[this.storageKey]),{cachedAt:s})}constructor(s){var n,a,r;this.userStorage=null,this.memoryStorage=null,this.stateChangeEmitters=new Map,this.autoRefreshTicker=null,this.autoRefreshTickTimeout=null,this.visibilityChangedCallback=null,this.refreshingDeferred=null,this.lastRefreshFailure=null,this._sessionRemovalEpoch=0,this.initializePromise=null,this._pendingInitNotifications=null,this.detectSessionInUrl=!0,this.hasCustomAuthorizationHeader=!1,this.suppressGetSessionWarning=!1,this.lock=null,this.lockAcquired=!1,this.pendingInLock=[],this.broadcastChannel=null,this.logger=console.log;const i=Object.assign(Object.assign({},RV),s);if(this.storageKey=i.storageKey,this.instanceID=(n=Sx.nextInstanceID[this.storageKey])!==null&&n!==void 0?n:0,Sx.nextInstanceID[this.storageKey]=this.instanceID+1,this.logDebugMessages=!!i.debug,typeof i.debug=="function"&&(this.logger=i.debug),this.instanceID>0&&yn()){const o=`${this._logPrefix()} Multiple GoTrueClient instances detected in the same browser context. It is not an error, but this should be avoided as it may produce undefined behavior when used concurrently under the same storage key.`;console.warn(o),this.logDebugMessages&&console.trace(o)}if(this.persistSession=i.persistSession,this.autoRefreshToken=i.autoRefreshToken,this.experimental=(a=i.experimental)!==null&&a!==void 0?a:{},this.admin=new vV({url:i.url,headers:i.headers,fetch:i.fetch,experimental:this.experimental}),this.url=i.url,this.headers=i.headers,this.fetch=CR(i.fetch),this.detectSessionInUrl=i.detectSessionInUrl,this.flowType=i.flowType,this.hasCustomAuthorizationHeader=i.hasCustomAuthorizationHeader,this.throwOnError=i.throwOnError,this.lockAcquireTimeout=i.lockAcquireTimeout,i.lock!=null&&(this.lock=i.lock),this.jwks||(this.jwks={keys:[]},this.jwks_cached_at=Number.MIN_SAFE_INTEGER),this.mfa={verify:this._verify.bind(this),enroll:this._enroll.bind(this),unenroll:this._unenroll.bind(this),challenge:this._challenge.bind(this),listFactors:this._listFactors.bind(this),challengeAndVerify:this._challengeAndVerify.bind(this),getAuthenticatorAssuranceLevel:this._getAuthenticatorAssuranceLevel.bind(this),webauthn:new DV(this)}
1148,this.oauth={getAuthorizationDetails:this._getAuthorizationDetails.bind(this),approveAuthorization:this._approveAuthorization.bind(this),denyAuthorization:this._denyAuthorization.bind(this),listGrants:this._listOAuthGrants.bind(this),revokeGrant:this._revokeOAuthGrant.bind(this)},this.passkey={startRegistration:this._startPasskeyRegistration.bind(this),verifyRegistration:this._verifyPasskeyRegistration.bind(this),startAuthentication:this._startPasskeyAuthentication.bind(this),verifyAuthentication:this._verifyPasskeyAuthentication.bind(this),list:this._listPasskeys.bind(this),update:this._updatePasskey.bind(this),delete:this._deletePasskey.bind(this)},this.persistSession?(i.storage?this.storage=i.storage:SR()?this.storage=globalThis.localStorage:(this.memoryStorage={},this.storage=c3(this.memoryStorage)),i.userStorage&&(this.userStorage=i.userStorage)):(this.memoryStorage={},this.storage=c3(this.memoryStorage)),yn()&&globalThis.BroadcastChannel&&this.persistSession&&this.storageKey){try{this.broadcastChannel=new globalThis.BroadcastChannel(this.storageKey)}catch(o){console.error("Failed to create a new BroadcastChannel, multi-tab state changes will not be available",o)}(r=this.broadcastChannel)===null||r===void 0||r.addEventListener("message",async o=>{this._debug("received broadcast notification from other tab or client",o),(o.data.event==="TOKEN_REFRESHED"||o.data.event==="SIGNED_IN")&&(this.lastRefreshFailure=null);try{await this._notifyAllSubscribers(o.data.event,o.data.session,!1)}catch(l){this._debug("#broadcastChannel","error",l)}})}i.skipAutoInitialize||this.initialize().catch(o=>{this._debug("#initialize()","error",o)})}isThrowOnErrorEnabled(){return this.throwOnError}_returnResult(s){if(this.throwOnError&&s&&s.error)throw s.error;return s}_logPrefix(){return`GoTrueClient@${this.storageKey}:${this.instanceID} (${NR}) ${new Date().toISOString()}`}_debug(...s){return this.logDebugMessages&&this.logger(this._logPrefix(),...s),this}async initialize(){var s;if(this.initializePromise)return await this.initializePromise;this._pendingInitNotifications=[],this.initializePromise=(async()=>this.lock!=null?await this._acquireLock(this.lockAcquireTimeout,async()=>await this._initialize()):await this._initialize())();const n=await this.initializePromise,a=(s=this._pendingInitNotifications)!==null&&s!==void 0?s:[];this._pendingInitNotifications=null;for(const r of a)await this._notifyAllSubscribers(r.event,r.session,r.broadcast);return n}async _initialize(){var s;try{let n={},a="none";if(yn()&&(n=n3(window.location.href),this._isImplicitGrantCallback(n)?a="implicit":await this._isPKCECallback(n)&&(a="pkce")),yn()&&this.detectSessionInUrl&&a!=="none"){const{data:r,error:i}=await this._getSessionFromURL(n,a);if(i){if(this._debug("#_initialize()","error detecting session from URL",i),MG(i)){const c=(s=i.details)===null||s===void 0?void 0:s.code;if(c==="identity_already_exists"||c==="identity_not_found"||c==="single_identity_not_deletable")return{error:i}}return{error:i}}const{session:o,redirectType:l}=r;return this._debug("#_initialize()","detected session in URL",o,"redirect type",l),await this._saveSession(o),setTimeout(async()=>{l==="recovery"?await this._notifyAllSubscribers("PASSWORD_RECOVERY",o):await this._notifyAllSubscribers("SIGNED_IN",o)},0),{error:null}}return await this._recoverAndRefresh(),{error:null}}catch(n){return Le(n)?this._returnResult({error:n}):this._returnResult({error:new Vr("Unexpected error during initialization",n)})}finally{await this._handleVisibilityChange(),this._debug("#_initialize()","end")}}async signInAnonymously(s){var n,a,r;try{const i=await Ze(this.fetch,"POST",`${this.url}/signup`,{headers:this.headers,body:{data:(a=(n=s==null?void 0:s.options)===null||n===void 0?void 0:n.data)!==null&&a!==void 0?a:{},gotrue_meta_security:{captcha_token:(r=s==null?void 0:s.options)===null||r===void 0?void 0:r.captchaToken}},xform:or}),{data:o,error:l}=i;if(l||!o)return this._returnResult({data:{user:null,session:null},error:l});const c=o.session,u=o.user;return o.session&&(await this._saveSession(o.session),await this._notifyAllSubscribers("SIGNED_IN",c)),this._returnResult({data:{user:u,session:c},error:null})}catch(i){if(Le(i))return this._returnResult({data:{user:null,session:null},error:i});throw i}}async signUp(s){var n,a,r;let i=null;try{let o;if("email"in s){const{email:m,password:x,options:h}=s;let y=null,v=null;this.flowType==="pkce"&&([y,v,i]=await this._getCodeChallengeAndMethod()),o=await Ze(this.fetch,"POST",`${this.url}/signup`,{headers:this.headers,redirectTo:this._maybeAppendFlowIdToRedirect(h==null?void 0:h.emailRedirectTo,i),body:{email:m,password:x,data:(n=h==null?void 0:h.data)!==null&&n!==void 0?n:{},gotrue_meta_security:{captcha_token:h==null?void 0:h.captchaToken},code_challenge:y,code_challenge_method:v},xform:or})}else if("phone"in s){const{phone:m,password:x,options:h}=s;o=await Ze(this.fetch,"POST",`${this.url}/signup`,{headers:this.headers,body:{phone:m,password:x,data:(a=h==null?void 0:h.data)!==null&&a!==void 0?a:{},channel:(r=h==null?void 0:h.channel)!==null&&r!==void 0?r:"sms",gotrue_meta_security:{captcha_token:h==null?void 0:h.captchaToken}},xform:or})}else throw new zf("You must provide either an email or phone number and a password");const{data:l,error:c}=o;if(c||!l)return await Sr(this.storage,this.storageKey,i),this._returnResult({data:{user:null,session:null},error:c});const u=l.session,p=l.user;return l.session&&(await this._saveSession(l.session),await this._notifyAllSubscribers("SIGNED_IN",u)),this._returnResult({data:{user:p,session:u},error:null})}catch(o){if(await Sr(this.storage,this.storageKey,i),Le(o))return this._returnResult({data:{user:null,session:null},error:o});throw o}}async signInWithPassword(s){try{let n;if("email"in s){const{email:i,password:o,options:l}=s;n=await Ze(this.fetch,"POST",`${this.url}/token?grant_type=password`,{headers:this.headers,body:{email:i,password:o,gotrue_meta_security:{captcha_token:l==null?void 0:l.captchaToken}},xform:o3})}else if("phone"in s){const{phone:i,password:o,options:l}=s;n=await Ze(this.fetch,"POST",`${this.url}/token?grant_type=password`,{headers:this.headers,body:{phone:i,password:o,gotrue_meta_security:{captcha_token:l==null?void 0:l.captchaToken}},xform:o3})}else throw new zf("You must provide either an email or phone number and a password");const{data:a,error:r}=n;if(r)return this._returnResult({data:{user:null,session:null},error:r});if(!a||!a.session||!a.user){const i=new Yd;return this._returnResult({data:{user:null,session:null},error:i})}return a.session&&(await this._saveSession(a.session),await this._notifyAllSubscribers("SIGNED_IN",a.session)),this._returnResult({data:Object.assign({user:a.user,session:a.session},a.weak_password?{weakPassword:a.weak_password}:null),error:r})}catch(n){if(Le(n))return this._returnResult({data:{user:null,session:null},error:n});throw n}}async signInWithOAuth(s){var n,a,r,i;return await this._handleProviderSignIn(s.provider,{redirectTo:(n=s.options)===null||n===void 0?void 0:n.redirectTo,scopes:(a=s.options)===null||a===void 0?void 0:a.scopes,queryParams:(r=s.options)===null||r===void 0?void 0:r.queryParams,skipBrowserRedirect:(i=s.options)===null||i===void 0?void 0:i.skipBrowserRedirect})}async exchangeCodeForSession(s,n){return await this.initializePromise,this.lock!=null?this._acquireLock(this.lockAcquireTimeout,async()=>this._exchangeCodeForSession(s,n)):this._exchangeCodeForSession(s,n)}async signInWithWeb3(s){const{chain:n}=s;switch(n){case"ethereum":return await this.signInWithEthereum(s);case"solana":return await this.signInWithSolana(s);default:throw new Error(`@supabase/auth-js: Unsupported chain "${n}"`)}}async signInWithEthereum(s){var n,a,r,i,o,l,c,u,p,m,x;let h,y;if("message"in s)h=s.message,y=s.signature;else{const{chain:v,wallet:g,statement:N,options:b}=s;let f;if(yn())if(typeof g=="object")f=g;else{const E=window;if("ethereum"in E&&typeof E.ethereum=="object"&&"request"in E.ethereum&&typeof E.ethereum.request=="function")f=E.ethereum;else throw new Error("@supabase/auth-js: No compatible Ethereum wallet interface on the window object (window.ethereum) detected. Make sure the user already has a wallet installed and connected for this app. Prefer passing the wallet interface object directly to signInWithWeb3({ chain: 'ethereum', wallet: resolvedUserWallet }) instead.")}else{if(typeof g!="object"||!(b!=null&&b.url))throw new Error("@supabase/auth-js: Both wallet and url must be specified in non-browser environments.");f=g}const j=new URL((n=b==null?void 0:b.url)!==null&&n!==void 0?n:window.location.href),S=await f.request({method:"eth_requestAccounts"}).then(E=>E).catch(()=>{throw new Error("@supabase/auth-js: Wallet method eth_requestAccounts is missing or invalid")});if(!S||S.length===0)throw new Error("@supabase/auth-js: No accounts available. Please ensure the wallet is connected.");const w=ER(S[0]);let _=(a=b==null?void 0:b.signInWithEthereum)===null||a===void 0?void 0:a.chainId;if(!_){const E=await f.request({method:"eth_chainId"});_=NV(E)}const C={domain:j.host,address:w,statement:N,uri:j.href,version:"1",chainId:_,nonce:(r=b==null?void 0:b.signInWithEthereum)===null||r===void 0?void 0:r.nonce,issuedAt:(o=(i=b==null?void 0:b.signInWithEthereum)===null||i===void 0?void 0:i.issuedAt)!==null&&o!==void 0?o:new Date,expirationTime:(l=b==null?void 0:b.signInWithEthereum)===null||l===void 0?void 0:l.expirationTime,notBefore:(c=b==null?void 0:b.signInWithEthereum)===null||c===void 0?void 0:c.notBefore,requestId:(u=b==null?void 0:b.signInWithEthereum)===null||u===void 0?void 0:u.requestId,resources:(p=b==null?void 0:b.signInWithEthereum)===null||p===void 0?void 0:p.resources};h=kV(C),y=await f.request({method:"personal_sign",params:[_V(h),w]})}try{const{data:v,error:g}=await Ze(this.fetch,"POST",`${this.url}/token?grant_type=web3`,{headers:this.headers,body:Object.assign({chain:"ethereum",message:h,signature:y},!((m=s.options)===null||m===void 0)&&m.captchaToken?{gotrue_meta_security:{captcha_token:(x=s.options)===null||x===void 0?void 0:x.captchaToken}}:null),xform:or});if(g)throw g;if(!v||!v.session||!v.user){const N=new Yd;return this._returnResult({data:{user:null,session:null},error:N})}return v.session&&(await this._saveSession(v.session),await this._notifyAllSubscribers("SIGNED_IN",v.session)),this._returnResult({data:Object.assign({},v),error:g})}catch(v){if(Le(v))return this._returnResult({data:{user:null,session:null},error:v});throw v}}async signInWithSolana(s){var n,a,r,i,o,l,c,u,p,m,x,h;let y,v;if("message"in s)y=s.message,v=s.signature;else{const{chain:g,wallet:N,statement:b,options:f}=s;let j;if(yn())if(typeof N=="object")j=N;else{const w=window;if("solana"in w&&typeof w.solana=="object"&&("signIn"in w.solana&&typeof w.solana.signIn=="function"||"signMessage"in w.solana&&typeof w.solana.signMessage=="function"))j=w.solana;else throw new Error("@supabase/auth-js: No compatible Solana wallet interface on the window object (window.solana) detected. Make sure the user already has a wallet installed and connected for this app. Prefer passing the wallet interface object directly to signInWithWeb3({ chain: 'solana', wallet: resolvedUserWallet }) instead.")}else{if(typeof N!="object"||!(f!=null&&f.url))throw new Error("@supabase/auth-js: Both wallet and url must be specified in non-browser environments.");j=N}const S=new URL((n=f==null?void 0:f.url)!==null&&n!==void 0?n:window.location.href);if("signIn"in j&&j.signIn){const w=await j.signIn(Object.assign(Object.assign(Object.assign({issuedAt:new Date().toISOString()},f==null?void 0:f.signInWithSolana),{version:"1",domain:S.host,uri:S.href}),b?{statement:b}:null));let _;if(Array.isArray(w)&&w[0]&&typeof w[0]=="object")_=w[0];else if(w&&typeof w=="object"&&"signedMessage"in w&&"signature"in w)_=w;else throw new Error("@supabase/auth-js: Wallet method signIn() returned unrecognized value");if("signedMessage"in _&&"signature"in _&&(typeof _.signedMessage=="string"||_.signedMessage instanceof Uint8Array)&&_.signature instanceof Uint8Array)y=typeof _.signedMessage=="string"?_.signedMessage:new TextDecoder().decode(_.signedMessage),v=_.signature;else throw new Error("@supabase/auth-js: Wallet method signIn() API returned object without signedMessage and signature fields")}else{if(!("signMessage"in j)||typeof j.signMessage!="function"||!("publicKey"in j)||typeof j!="object"||!j.publicKey||!("toBase58"in j.publicKey)||typeof j.publicKey.toBase58!="function")throw new Error("@supabase/auth-js: Wallet does not have a compatible signMessage() and publicKey.toBase58() API");y=[`${S.host} wants you to sign in with your Solana account:`,j.publicKey.toBase58(),...b?["",b,""]:[""],"Version: 1",`URI: ${S.href}`,`Issued At: ${(r=(a=f==null?void 0:f.signInWithSolana)===null||a===void 0?void 0:a.issuedAt)!==null&&r!==void 0?r:new Date().toISOString()}`,...!((i=f==null?void 0:f.signInWithSolana)===null||i===void 0)&&i.notBefore?[`Not Before: ${f.signInWithSolana.notBefore}`]:[],...!((o=f==null?void 0:f.signInWithSolana)===null||o===void 0)&&o.expirationTime?[`Expiration Time: ${f.signInWithSolana.expirationTime}`]:[],...!((l=f==null?void 0:f.signInWithSolana)===null||l===void 0)&&l.chainId?[`Chain ID: ${f.signInWithSolana.chainId}`]:[],...!((c=f==null?void 0:f.signInWithSolana)===null||c===void 0)&&c.nonce?[`Nonce: ${f.signInWithSolana.nonce}`]:[],...!((u=f==null?void 0:f.signInWithSolana)===null||u===void 0)&&u.requestId?[`Request ID: ${f.signInWithSolana.requestId}`]:[],...!((m=(p=f==null?void 0:f.signInWithSolana)===null||p===void 0?void 0:p.resources)===null||m===void 0)&&m.length?["Resources",...f.signInWithSolana.resources.map(_=>`- ${_}`)]:[]].join(` 1149`);const w=await j.signMessage(new TextEncoder().encode(y),"utf8");if(!w||!(w instanceof Uint8Array))throw new Error("@supabase/auth-js: Wallet signMessage() API returned an recognized value");v=w}}try{const{data:g,error:N}=await Ze(this.fetch,"POST",`${this.url}/token?grant_type=web3`,{headers:this.headers,body:Object.assign({chain:"solana",message:y,signature:ad(v)},!((x=s.options)===null||x===void 0)&&x.captchaToken?{gotrue_meta_security:{captcha_token:(h=s.options)===null||h===void 0?void 0:h.captchaToken}}:null),xform:or});if(N)throw N;if(!g||!g.session||!g.user){const b=new Yd;return this._returnResult({data:{user:null,session:null},error:b})}return g.session&&(await this._saveSession(g.session),await this._notifyAllSubscribers("SIGNED_IN",g.session)),this._returnResult({data:Object.assign({},g),error:N})}catch(g){if(Le(g))return this._returnResult({data:{user:null,session:null},error:g});throw g}}async _exchangeCodeForSession(s,n){const a=(n==null?void 0:n.flowId)!=null,r=a?g0(n==null?void 0:n.flowId):yn()?g0(n3(window.location.href)[nd]):null;a&&!r&&this._debug("#_exchangeCodeForSession()","provided flowId is not a valid flow id",n==null?void 0:n.flowId);const{verifier:i,flowId:o}=a&&!r?{verifier:null,flowId:null}:await rV(this.storage,this.storageKey,r),[l,c]=(i??"").split("/");try{if(!l&&this.flowType==="pkce")throw new BG;const{data:u,error:p}=await Ze(this.fetch,"POST",`${this.url}/token?grant_type=pkce`,{headers:this.headers,body:{auth_code:s,code_verifier:l},xform:or});if(await Sr(this.storage,this.storageKey,o),p)throw p;if(!u||!u.session||!u.user){const m=new Yd;return this._returnResult({data:{user:null,session:null,redirectType:null},error:m})}return u.session&&(await this._saveSession(u.session),await this._notifyAllSubscribers(c==="recovery"?"PASSWORD_RECOVERY":"SIGNED_IN",u.session)),this._returnResult({data:Object.assign(Object.assign({},u),{redirectType:c??null}),error:p})}catch(u){if(await Sr(this.storage,this.storageKey,o),Le(u))return this._returnResult({data:{user:null,session:null,redirectType:null},error:u});throw u}}async signInWithIdToken(s){try{const{options:n,provider:a,token:r,access_token:i,nonce:o}=s,l=await Ze(this.fetch,"POST",`${this.url}/token?grant_type=id_token`,{headers:this.headers,body:{provider:a,id_token:r,access_token:i,nonce:o,gotrue_meta_security:{captcha_token:n==null?void 0:n.captchaToken}},xform:or}),{data:c,error:u}=l;if(u)return this._returnResult({data:{user:null,session:null},error:u});if(!c||!c.session||!c.user){const p=new Yd;return this._returnResult({data:{user:null,session:null},error:p})}return c.session&&(await this._saveSession(c.session),await this._notifyA
1149llSubscribers("SIGNED_IN",c.session)),this._returnResult({data:c,error:u})}catch(n){if(Le(n))return this._returnResult({data:{user:null,session:null},error:n});throw n}}async signInWithOtp(s){var n,a,r,i,o;let l=null;try{if("email"in s){const{email:c,options:u}=s;let p=null,m=null;this.flowType==="pkce"&&([p,m,l]=await this._getCodeChallengeAndMethod());const{error:x}=await Ze(this.fetch,"POST",`${this.url}/otp`,{headers:this.headers,body:{email:c,data:(n=u==null?void 0:u.data)!==null&&n!==void 0?n:{},create_user:(a=u==null?void 0:u.shouldCreateUser)!==null&&a!==void 0?a:!0,gotrue_meta_security:{captcha_token:u==null?void 0:u.captchaToken},code_challenge:p,code_challenge_method:m},redirectTo:this._maybeAppendFlowIdToRedirect(u==null?void 0:u.emailRedirectTo,l)});return this._returnResult({data:{user:null,session:null},error:x})}if("phone"in s){const{phone:c,options:u}=s,{data:p,error:m}=await Ze(this.fetch,"POST",`${this.url}/otp`,{headers:this.headers,body:{phone:c,data:(r=u==null?void 0:u.data)!==null&&r!==void 0?r:{},create_user:(i=u==null?void 0:u.shouldCreateUser)!==null&&i!==void 0?i:!0,gotrue_meta_security:{captcha_token:u==null?void 0:u.captchaToken},channel:(o=u==null?void 0:u.channel)!==null&&o!==void 0?o:"sms"}});return this._returnResult({data:{user:null,session:null,messageId:p==null?void 0:p.message_id},error:m})}throw new zf("You must provide either an email or phone number.")}catch(c){if(await Sr(this.storage,this.storageKey,l),Le(c))return this._returnResult({data:{user:null,session:null},error:c});throw c}}async verifyOtp(s){var n,a;try{let r,i;"options"in s&&(r=(n=s.options)===null||n===void 0?void 0:n.redirectTo,i=(a=s.options)===null||a===void 0?void 0:a.captchaToken);const{data:o,error:l}=await Ze(this.fetch,"POST",`${this.url}/verify`,{headers:this.headers,body:Object.assign(Object.assign({},s),{gotrue_meta_security:{captcha_token:i}}),redirectTo:r,xform:or});if(l)throw l;if(!o)throw new Error("An error occurred on token verification.");const c=o.session,u=o.user;return c!=null&&c.access_token&&(await this._saveSession(c),await this._notifyAllSubscribers(s.type=="recovery"?"PASSWORD_RECOVERY":"SIGNED_IN",c)),this._returnResult({data:{user:u,session:c},error:null})}catch(r){if(Le(r))return this._returnResult({data:{user:null,session:null},error:r});throw r}}async signInWithSSO(s){var n,a,r,i;let o=null;try{let l=null,c=null;this.flowType==="pkce"&&([l,c,o]=await this._getCodeChallengeAndMethod());const u=await Ze(this.fetch,"POST",`${this.url}/sso`,{body:Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({},"providerId"in s?{provider_id:s.providerId}:null),"domain"in s?{domain:s.domain}:null),{redirect_to:this._maybeAppendFlowIdToRedirect((n=s.options)===null||n===void 0?void 0:n.redirectTo,o)}),!((a=s==null?void 0:s.options)===null||a===void 0)&&a.captchaToken?{gotrue_meta_security:{captcha_token:s.options.captchaToken}}:null),{skip_http_redirect:!0,code_challenge:l,code_challenge_method:c}),headers:this.headers,xform:gV});return!((r=u.data)===null||r===void 0)&&r.url&&yn()&&!(!((i=s.options)===null||i===void 0)&&i.skipBrowserRedirect)&&window.location.assign(u.data.url),this._returnResult(u)}catch(l){if(await Sr(this.storage,this.storageKey,o),Le(l))return this._returnResult({data:null,error:l});throw l}}async reauthenticate(){return await this.initializePromise,this.lock!=null?await this._acquireLock(this.lockAcquireTimeout,async()=>await this._reauthenticate()):await this._reauthenticate()}async _reauthenticate(){try{return await this._useSession(async s=>{const{data:{session:n},error:a}=s;
1149if(a)throw a;if(!n)throw new on;const{error:r}=await Ze(this.fetch,"GET",`${this.url}/reauthenticate`,{headers:this.headers,jwt:n.access_token});return this._returnResult({data:{user:null,session:null},error:r})})}catch(s){if(Le(s))return this._returnResult({data:{user:null,session:null},error:s});throw s}}async resend(s){let n=null;try{const a=`${this.url}/resend`;if("email"in s){const{email:r,type:i,options:o}=s;let l=null,c=null;this.flowType==="pkce"&&([l,c,n]=await this._getCodeChallengeAndMethod());const{error:u}=await Ze(this.fetch,"POST",a,{headers:this.headers,body:{email:r,type:i,gotrue_meta_security:{captcha_token:o==null?void 0:o.captchaToken},code_challenge:l,code_challenge_method:c},redirectTo:this._maybeAppendFlowIdToRedirect(o==null?void 0:o.emailRedirectTo,n)});return u&&await Sr(this.storage,this.storageKey,n),this._returnResult({data:{user:null,session:null},error:u})}else if("phone"in s){const{phone:r,type:i,options:o}=s,{data:l,error:c}=await Ze(this.fetch,"POST",a,{headers:this.headers,body:{phone:r,type:i,gotrue_meta_security:{captcha_token:o==null?void 0:o.captchaToken}}});return this._returnResult({data:{user:null,session:null,messageId:l==null?void 0:l.message_id},error:c})}throw new zf("You must provide either an email or phone number and a type")}catch(a){if(await Sr(this.storage,this.storageKey,n),Le(a))return this._returnResult({data:{user:null,session:null},error:a});throw a}}async getSession(){return await this.initializePromise,this.lock!=null?await this._acquireLock(this.lockAcquireTimeout,async()=>this._useSession(async s=>s)):await this._useSession(async s=>s)}async _acquireLock(s,n){this._debug("#_acquireLock","begin",s);try{if(this.lockAcquired){const a=this.pendingInLock.length?this.pendingInLock[this.pendingInLock.length-1]:Promise.resolve(),r=(async()=>(await a,await n()))();return this.pendingInLock.push((async()=>{try{await r}catch{}})()),r}return await this.lock(`lock:${this.storageKey}`,s,async()=>{this._debug("#_acquireLock","lock acquired for storage key",this.storageKey);try{this.lockAcquired=!0;const a=n();for(this.pendingInLock.push((async()=>{try{await a}catch{}})()),await a;this.pendingInLock.length;){const r=[...this.pendingInLock];await Promise.all(r),this.pendingInLock.splice(0,r.length)}return await a}finally{this._debug("#_acquireLock","lock released for storage key",this.storageKey),this.lockAcquired=!1}})}finally{this._debug("#_acquireLock","end")}}async _useSession(s){this._debug("#_useSession","begin");try{const n=await this.__loadSession();return await s(n)}finally{this._debug("#_useSession","end")}}async __loadSession(){this._debug("#__loadSession()","begin"),this.lock!=null&&!this.lockAcquired&&this._debug("#__loadSession()","used outside of an acquired lock!",new Error().stack);try{let s=null;const n=await Dn(this.storage,this.storageKey);if(this._debug("#getSession()","session from storage",n),n!==null&&(this._isValidSession(n)?s=n:(this._debug("#getSession()","session from storage is not valid"),await this._removeSession())),!s)return{data:{session:null},error:null};const a=s.expires_at?s.expires_at*1e3-Date.now()<cv:!1;if(this._debug("#__loadSession()",`session has${a?"":" not"} expired`,"expires_at",s.expires_at),!a){if(this.userStorage){const o=await Dn(this.userStorage,this.storageKey+"-user");o!=null&&o.user?s.user=o.user:s.user=dv()}if(this.storage.isServer&&s.user&&!s.user.__isUserNotAvailableProxy){const o={value:this.suppressGetSessionWarning};s.user=hV(s.user,o),o.value&&(this.suppressGetSessionWarning=!0)}return{data:{session:s},error:null}}const{data:r,error:i}=await this._callRefreshToken(s.refresh_token);if(i){if(!!(s.expires_at&&s.expires_at*1e3>Date.now())){const l=await Dn(this.storage,this.storageKey);if(l&&l.refresh_token===s.refresh_token)return this._returnResult({data:{session:s},error:null})}return this._returnResult({data:{session:null},error:i})}return this._returnResult({data:{session:r},error:null})}finally{this._debug("#__loadSession()","end")}}async getUser(s){if(s)return await this._getUser(s);await this.initializePromise;let n;return this.lock!=null?n=await this._acquireLock(this.lockAcquireTimeout,async()=>await this._getUser()):n=await this._getUser(),n.data.user&&(this.suppressGetSessionWarning=!0),n}async _getUser(s){try{return s?await Ze(this.fetch,"GET",`${this.url}/user`,{headers:this.headers,jwt:s,xform:vl}):await this._useSession(async n=>{var a,r,i;const{data:o,error:l}=n;if(l)throw l;return!(!((a=o.session)===null||a===void 0)&&a.access_token)&&!this.hasCustomAuthorizationHeader?{data:{user:null},error:new on}:await Ze(this.fetch,"GET",`${this.url}/user`,{headers:this.headers,jwt:(i=(r=o.session)===null||r===void 0?void 0:r.access_token)!==null&&i!==void 0?i:void 0,xform:vl})})}catch(n){if(Le(n))return $f(n)&&await this._removeSession(),this._returnResult({data:{user:null},error:n});throw n}}async updateUser(s,n={}){return await this.initializePromise,this.lock!=null?await this._acquireLock(this.lockAcquireTimeout,async()=>await this._updateUser(s,n)):await this._updateUser(s,n)}async _updateUser(s,n={}){let a=null;try{return await this._useSession(async r=>{const{data:i,error:o}=r;if(o)throw o;if(!i.session)throw new on;const l=i.session;let c=null,u=null;this.flowType==="pkce"&&s.email!=null&&([c,u,a]=await this._getCodeChallengeAndMethod());const{data:p,error:m}=await Ze(this.fetch,"PUT",`${this.url}/user`,{headers:this.headers,redirectTo:this._maybeAppendFlowIdToRedirect(n==null?void 0:n.emailRedirectTo,a),body:Object.assign(Object.assign({}
1149,s),{code_challenge:c,code_challenge_method:u}),jwt:l.access_token,xform:vl});if(m)throw m;return l.user=p.user,await this._saveSession(l),await this._notifyAllSubscribers("USER_UPDATED",l),this._returnResult({data:{user:l.user},error:null})})}catch(r){if(await Sr(this.storage,this.storageKey,a),Le(r))return this._returnResult({data:{user:null},error:r});throw r}}async setSession(s){return await this.initializePromise,this.lock!=null?await this._acquireLock(this.lockAcquireTimeout,async()=>await this._setSession(s)):await this._setSession(s)}async _setSession(s){try{if(!s.access_token||!s.refresh_token)throw new on;const n=Date.now()/1e3;let a=n,r=!0,i=null;const{payload:o}=Mf(s.access_token);if(o.exp&&(a=o.exp,r=a<=n),r){const{data:l,error:c}=await this._callRefreshToken(s.refresh_token);if(c)return this._returnResult({data:{user:null,session:null},error:c});if(!l)return{data:{user:null,session:null},error:null};i=l}else{const{data:l,error:c}=await this._getUser(s.access_token);if(c)return this._returnResult({data:{user:null,session:null},error:c});i={access_token:s.access_token,refresh_token:s.refresh_token,user:l.user,token_type:"bearer",expires_in:a-n,expires_at:a},await this._saveSession(i),await this._notifyAllSubscribers("SIGNED_IN",i)}return this._returnResult({data:{user:i.user,session:i},error:null})}catch(n){if(Le(n))return this._returnResult({data:{session:null,user:null},error:n});throw n}}async refreshSession(s){return await this.initializePromise,this.lock!=null?await this._acquireLock(this.lockAcquireTimeout,async()=>await this._refreshSession(s)):await this._refreshSession(s)}async _refreshSession(s){try{return await this._useSession(async n=>{var a;if(!s){const{data:o,error:l}=n;if(l)throw l;s=(a=o.session)!==null&&a!==void 0?a:void 0}if(!(s!=null&&s.refresh_token))throw new on;const{data:r,error:i}=await this._callRefreshToken(s.refresh_token);return i?this._returnResult({data:{user:null,session:null},error:i}):r?this._returnResult({data:{user:r.user,session:r},error:null}):this._returnResult({data:{user:null,session:null},error:null})})}catch(n){if(Le(n))return this._returnResult({data:{user:null,session:null},error:n});throw n}}async _getSessionFromURL(s,n){var a;try{if(!yn())throw new Lf("No browser detected.");if(s.error||s.error_description||s.error_code)throw new Lf(s.error_description||"Error in URL with unspecified error_description",{error:s.error||"unspecified_error",code:s.error_code||"unspecified_code"});switch(n){case"implicit":if(this.flowType==="pkce")throw new QC("Not a valid PKCE flow url.");break;case"pkce":if(this.flowType==="implicit")throw new Lf("Not a valid implicit grant flow url.");break;default:}if(n==="pkce"){if(this._debug("#_initialize()","begin","is PKCE flow",!0),!s.code)throw new QC("No code detected.");const{data:f,error:j}=await this._exchangeCodeForSession(s.code,{flowId:s[nd]});if(j)throw j;const S=new URL(window.location.href);return S.searchParams.delete("code"),S.searchParams.delete(nd),window.history.replaceState(window.history.state,"",S.toString()),{data:{session:f.session,redirectType:(a=f.redirectType)!==null&&a!==void 0?a:null},error:null}}const{provider_token:r,provider_refresh_token:i,access_token:o,refresh_token:l,expires_in:c,expires_at:u,token_type:p}=s;if(!o||!c||!l||!p)throw new Lf("No session defined in URL");const m=Math.round(Date.now()/1e3),x=parseInt(c);let h=m+x;u&&(h=parseInt(u));const y=h-m;y*1e3<=oo&&console.warn(`@supabase/gotrue-js: Session as retrieved from URL expires in ${y}s, should have been closer to ${x}s`);const v=h-x;m-v>=120?console.warn("@supabase/gotrue-js: Session as retrieved from URL was issued over 120s ago, URL could be stale",v,h,m):m-v<0&&console.warn("@supabase/gotrue-js: Session as retrieved from URL was issued in the future? Check the device clock for skew",v,h,m);const{data:g,error:N}=await this._getUser(o);if(N)throw N;const b={provider_token:r,provider_refresh_token:i,access_token:o,expires_in:x,expires_at:h,refresh_token:l,token_type:p,user:g.user};return window.location.hash="",this._debug("#_getSessionFromURL()","clearing window.location.hash"),this._returnResult({data:{session:b,redirectType:s.type},error:null})}catch(r){if(Le(r))return this._returnResult({data:{session:null,redirectType:null},error:r});throw r}}_isImplicitGrantCallback(s){return typeof this.detectSessionInUrl=="function"?this.detectSessionInUrl(new URL(window.location.href),s):!!(s.access_token||s.error||s.error_description||s.error_code)}
1149async _isPKCECallback(s){if(!s.code)return!1;const n=g0(s[nd]);return n&&await Dn(this.storage,Rm(this.storageKey,n))?!0:!!await Dn(this.storage,`${this.storageKey}-code-verifier`)}async signOut(s={scope:"global"}){return await this.initializePromise,this.lock!=null?await this._acquireLock(this.lockAcquireTimeout,async()=>await this._signOut(s)):await this._signOut(s)}async _signOut({scope:s}={scope:"global"}){return await this._useSession(async n=>{var a;const r=async()=>{await this._removeSession()},{data:i,error:o}=n;if(o&&!$f(o))return this._returnResult({error:o});const l=(a=i.session)===null||a===void 0?void 0:a.access_token;if(l){const{error:c}=await this.admin.signOut(l,s);if(c&&!(KC(c)&&(c.status===404||c.status===401||c.status===403)||$f(c)))return s!=="others"&&await r(),this._returnResult({error:c})}return s!=="others"&&await r(),this._returnResult({error:null})})}onAuthStateChange(s){const n=YG(),a={id:n,callback:s,unsubscribe:()=>{this._debug("#unsubscribe()","state change callback with id removed",n),this.stateChangeEmitters.delete(n)}};return this._debug("#onAuthStateChange()","registered callback with id",n),this.stateChangeEmitters.set(n,a),(async()=>(await this.initializePromise,this.lock!=null?await this._acquireLock(this.lockAcquireTimeout,async()=>{this._emitInitialSession(n)}):await this._emitInitialSession(n)))(),{data:{subscription:a}}}async _emitInitialSession(s){return await this._useSession(async n=>{var a,r;try{const{data:{session:i},error:o}=n;if(o)throw o;await((a=this.stateChangeEmitters.get(s))===null||a===void 0?void 0:a.callback("INITIAL_SESSION",i)),this._debug("INITIAL_SESSION","callback id",s,"session",i)}catch(i){await((r=this.stateChangeEmitters.get(s))===null||r===void 0?void 0:r.callback("INITIAL_SESSION",null)),this._debug("INITIAL_SESSION","callback id",s,"error",i),$f(i)||Of(i)||KC(i)&&(i.code==="refresh_token_not_found"||i.code==="refresh_token_already_used"||i.code==="session_expired")?console.warn(i):console.error(i)}})}async resetPasswordForEmail(s,n={}){let a=null,r=null,i=null;this.flowType==="pkce"&&([a,r,i]=await this._getCodeChallengeAndMethod(!0));try{return await Ze(this.fetch,"POST",`${this.url}/recover`,{body:{email:s,code_challenge:a,code_challenge_method:r,gotrue_meta_security:{captcha_token:n.captchaToken}},headers:this.headers,redirectTo:this._maybeAppendFlowIdToRedirect(n.redirectTo,i)})}catch(o){if(await Sr(this.storage,this.storageKey,i),Le(o))return this._returnResult({data:null,error:o});throw o}}async getUserIdentities(){var s;try{const{data:n,error:a}=await this.getUser();if(a)throw a;return this._returnResult({data:{identities:(s=n.user.identities)!==null&&s!==void 0?s:[]},error:null})}catch(n){if(Le(n))return this._returnResult({data:null,error:n});throw n}}async linkIdentity(s){return"token"in s?this.linkIdentityIdToken(s):this.linkIdentityOAuth(s)}async linkIdentityOAuth(s){var n;let a=null;try{const{data:r,error:i}=await this._useSession(async o=>{var l,c,u,p,m;const{data:x,error:h}=o;if(h)throw h;const{url:y,flowId:v}=await this._getUrlForProvider(`${this.url}/user/identities/authorize`,s.provider,{redirectTo:(l=s.options)===null||l===void 0?void 0:l.redirectTo,scopes:(c=s.options)===null||c===void 0?void 0:c.scopes,queryParams:(u=s.options)===null||u===void 0?void 0:u.queryParams,skipBrowserRedirect:!0});return a=v,await Ze(this.fetch,"GET",y,{headers:this.headers,jwt:(m=(p=x.session)===null||p===void 0?void 0:p.access_token)!==null&&m!==void 0?m:void 0})});if(i)throw i;return yn()&&!(!((n=s.options)===null||n===void 0)&&n.skipBrowserRedirect)&&window.location.assign(r==null?void 0:r.url),this._returnResult({data:{provider:s.provider,url:r==null?void 0:r.url,flowId:a},error:null})}catch(r){if(Le(r))return this._returnResult({data:{provider:s.provider,url:null,flowId:a},error:r});throw r}}async linkIdentityIdToken(s){return await this._useSession(async n=>{var a;try{const{error:r,data:{session:i}}=n;if(r)throw r;const{options:o,provider:l,token:c,access_token:u,nonce:p}=s,m=await Ze(this.fetch,"POST",`${this.url}/token?grant_type=id_token`,{headers:this.headers,jwt:(a=i==null?void 0:i.access_token)!==null&&a!==void 0?a:void 0,body:{provider:l,id_token:c,access_token:u,nonce:p,link_identity:!0,gotrue_meta_security:{captcha_token:o==null?void 0:o.captchaToken}},xform:or}),{data:x,error:h}=m;return h?this._returnResult({data:{user:null,session:null},error:h}):!x||!x.session||!x.user?this._returnResult({data:{user:null,session:null},error:new Yd}):(x.session&&(await this._saveSession(x.session),await this._notifyAllSubscribers("USER_UPDATED",x.session)),this._returnResult({data:x,error:h}))}catch(r){if(await Sr(this.storage,this.storageKey,null),Le(r))return this._returnResult({data:{user:null,session:null},error:r});throw r}})}async unlinkIdentity(s){try{return await this._useSession(async n=>{var a,r;const{data:i,error:o}=n;
1149if(o)throw o;return await Ze(this.fetch,"DELETE",`${this.url}/user/identities/${s.identity_id}`,{headers:this.headers,jwt:(r=(a=i.session)===null||a===void 0?void 0:a.access_token)!==null&&r!==void 0?r:void 0})})}catch(n){if(Le(n))return this._returnResult({data:null,error:n});throw n}}async _refreshAccessToken(s){const n="#_refreshAccessToken()";this._debug(n,"begin");try{const a=Date.now();return await JG(async r=>(r>0&&await QG(200*Math.pow(2,r-1)),this._debug(n,"refreshing attempt",r),await Ze(this.fetch,"POST",`${this.url}/token?grant_type=refresh_token`,{body:{refresh_token:s},headers:this.headers,xform:or})),(r,i)=>{const o=200*Math.pow(2,r);return i&&Of(i)&&Date.now()+o-a<oo})}catch(a){if(this._debug(n,"error",a),Le(a))return this._returnResult({data:{session:null,user:null},error:a});throw a}finally{this._debug(n,"end")}}_isValidSession(s){return typeof s=="object"&&s!==null&&"access_token"in s&&"refresh_token"in s&&"expires_at"in s}async _handleProviderSignIn(s,n){const{url:a,flowId:r}=await this._getUrlForProvider(`${this.url}/authorize`,s,{redirectTo:n.redirectTo,scopes:n.scopes,queryParams:n.queryParams});return this._debug("#_handleProviderSignIn()","provider",s,"options",n,"url",a),yn()&&!n.skipBrowserRedirect&&window.location.assign(a),{data:{provider:s,url:a,flowId:r},error:null}}async _recoverAndRefresh(){var s,n;const a="#_recoverAndRefresh()";this._debug(a,"begin");try{const r=await Dn(this.storage,this.storageKey);if(r&&this.userStorage){let o=await Dn(this.userStorage,this.storageKey+"-user");!this.storage.isServer&&Object.is(this.storage,this.userStorage)&&!o&&(o={user:r.user},await ho(this.userStorage,this.storageKey+"-user",o)),r.user=(s=o==null?void 0:o.user)!==null&&s!==void 0?s:dv()}else if(r&&!r.user&&!r.user){const o=await Dn(this.storage,this.storageKey+"-user");o&&(o!=null&&o.user)?(r.user=o.user,await pa(this.storage,this.storageKey+"-user"),await ho(this.storage,this.storageKey,r)):r.user=dv()}if(this._debug(a,"session from storage",r),!this._isValidSession(r)){this._debug(a,"session is not valid"),r!==null&&await this._removeSession();return}const i=((n=r.expires_at)!==null&&n!==void 0?n:1/0)*1e3-Date.now()<cv;if(this._debug(a,`session has${i?"":" not"} expired with margin of ${cv}s`),i){if(this.autoRefreshToken&&r.refresh_token){const{error:o}=await this._callRefreshToken(r.refresh_token);o&&(UG(o)?this._debug(a,"refresh discarded by commit guard",o):this._debug(a,"refresh failed",o))}}else if(r.user&&r.user.__isUserNotAvailableProxy===!0)try{const{data:o,error:l}=await this._getUser(r.access_token);!l&&(o!=null&&o.user)?(r.user=o.user,await this._saveSession(r),await this._notifyAllSubscribers("SIGNED_IN",r)):this._debug(a,"could not get user data, skipping SIGNED_IN notification")}catch(o){console.error("Error getting user data:",o),this._debug(a,"error getting user data, skipping SIGNED_IN notification",o)}else await this._notifyAllSubscribers("SIGNED_IN",r)}catch(r){this._debug(a,"error",r),Of(r)?console.warn(r):console.error(r);return}finally{this._debug(a,"end")}}async _callRefreshToken(s){var n,a;if(!s)throw new on;if(this.refreshingDeferred)return this.refreshingDeferred.promise;if(this.lastRefreshFailure&&this.lastRefreshFailure.refreshToken===s&&Date.now()<this.lastRefreshFailure.expiresAt)return this._debug("#_callRefreshToken()","returning cached failure (cooldown active)"),this.lastRefreshFailure.result;const r="#_callRefreshToken()";this._debug(r,"begin");try{this.refreshingDeferred=new Jb;const i=await Dn(this.storage,this.storageKey),{data:o,error:l}=await this._refreshAccessToken(s);if(l)throw l;if(!o.session)throw new on;const c=await Dn(this.storage,this.storageKey);if(i!==null&&(c===null||c.refresh_token!==i.refresh_token)){this._debug(r,"commit guard: storage changed since refresh started, discarding rotated tokens",{startedWith:"present",nowHolds:c?"replaced":"cleared"});const x={data:null,error:new JC};return this.refreshingDeferred.resolve(x),x}const p=this._sessionRemovalEpoch;if(await this._saveSession(o.session),this._sessionRemovalEpoch!==p){this._debug(r,"commit guard (post-save): _removeSession ran during _saveSession, und
1149oing write"),await pa(this.storage,this.storageKey),this.userStorage&&await pa(this.userStorage,this.storageKey+"-user");const x={data:null,error:new JC};return this.refreshingDeferred.resolve(x),x}await this._notifyAllSubscribers("TOKEN_REFRESHED",o.session);const m={data:o.session,error:null};return this.lastRefreshFailure=null,this.refreshingDeferred.resolve(m),m}catch(i){if(this._debug(r,"error",i),Le(i)){const o={data:null,error:i};if(!Of(i)){const l=await Dn(this.storage,this.storageKey);!!(l!=null&&l.expires_at&&l.expires_at*1e3>Date.now())?this._debug(r,"proactive refresh failed, access token still valid â preserving session"):await this._removeSession()}return this.lastRefreshFailure={refreshToken:s,result:o,expiresAt:Date.now()+PG},(n=this.refreshingDeferred)===null||n===void 0||n.resolve(o),o}throw(a=this.refreshingDeferred)===null||a===void 0||a.reject(i),i}finally{this.refreshingDeferred=null,this._debug(r,"end")}}async _notifyAllSubscribers(s,n,a=!0){if(this._pendingInitNotifications!==null&&a){this._pendingInitNotifications.push({event:s,session:n,broadcast:a});return}const r=`#_notifyAllSubscribers(${s})`;this._debug(r,"begin",n,`broadcast = ${a}`);try{this.broadcastChannel&&a&&this.broadcastChannel.postMessage({event:s,session:n});const i=[],o=Array.from(this.stateChangeEmitters.values()).map(async l=>{try{await l.callback(s,n)}catch(c){i.push(c)}});if(await Promise.all(o),i.length>0){for(let l=0;l<i.length;l+=1)console.error(i[l]);throw i[0]}}finally{this._debug(r,"end")}}async _saveSession(s){this._debug("#_saveSession()",s),this.suppressGetSessionWarning=!0;const n=Object.assign({},s),a=n.user&&n.user.__isUserNotAvailableProxy===!0;if(this.userStorage){!a&&n.user&&await ho(this.userStorage,this.storageKey+"-user",{user:n.user});const r=Object.assign({},n);delete r.user;const i=a3(r);await ho(this.storage,this.storageKey,i)}else{const r=a3(n);await ho(this.storage,this.storageKey,r)}}async _removeSession(){this._sessionRemovalEpoch+=1,this._debug("#_removeSession()"),this.lastRefreshFailure=null,this.suppressGetSessionWarning=!1,await pa(this.storage,this.storageKey),await iV(this.storage,this.storageKey),await pa(this.storage,this.storageKey+"-user"),this.userStorage&&await pa(this.userStorage,this.storageKey+"-user"),await this._notifyAllSubscribers("SIGNED_OUT",null)}_removeVisibilityChangedCallback(){this._debug("#_removeVisibilityChangedCallback()");const s=this.visibilityChangedCallback;this.visibilityChangedCallback=null;try{s&&yn()&&(window!=null&&window.removeEventListener)&&window.removeEventListener("visibilitychange",s)}catch(n){console.error("removing visibilitychange callback failed",n)}}async _startAutoRefresh(){await this._stopAutoRefresh(),this._debug("#_startAutoRefresh()");const s=setInterval(()=>this._autoRefreshTokenTick(),oo);this.autoRefreshTicker=s,s&&typeof s=="object"&&typeof s.unref=="function"?s.unref():typeof Deno<"u"&&typeof Deno.unrefTimer=="function"&&Deno.unrefTimer(s);const n=setTimeout(async()=>{await this.initializePromise,await this._autoRefreshTokenTick()},0);this.autoRefreshTickTimeout=n,n&&typeof n=="object"&&typeof n.unref=="function"?n.unref():typeof Deno<"u"&&typeof Deno.unrefTimer=="function"&&Deno.unrefTimer(n)}async _stopAutoRefresh(){this._debug("#_stopAutoRefresh()");const s=this.autoRefreshTicker;this.autoRefreshTicker=null,s&&clearInterval(s);const n=this.autoRefreshTickTimeout;this.autoRefreshTickTimeout=null,n&&clearTimeout(n)}async startAutoRefresh(){this._removeVisibilityChangedCallback(),await this._startAutoRefresh()}async stopAutoRefresh(){this._removeVisibilityChangedCallback(),await this._stopAutoRefresh()}async dispose(){var s;this._removeVisibilityChangedCallback(),await this._stopAutoRefresh(),(s=this.broadcastChannel)===null||s===void 0||s.close(),this.broadcastChannel=null,this.stateChangeEmitters.clear()}async _autoRefreshTokenTick(){if(this._debug("#_autoRefreshTokenTick()","begin"),this.lock!=null){try{await this._acquireLock(0,async()=>{try{const s=Date.now();try{return await this._useSession(async n=>{const{data:{session:a}}=n;if(!a||!a.refresh_token||!a.expires_at){this._debug("#_autoRefreshTokenTick()","no session");return}const r=Math.floor((a.expires_at*1e3-s)/oo);this._debug("#_autoRefreshTokenTick()",`access token expires in ${r} ticks, a tick lasts ${oo}ms, refresh threshold is ${rh} ticks`),r<=rh&&await this._callRefreshToken(a.refresh_token)})}catch(n){console.error("Auto refresh tick failed with error. This is likely a transient error.",n)}}finally{this._debug("#_autoRefreshTokenTick()","end")}})}catch(s){if(s instanceof jV)this._debug("auto refresh token tick lock not available");else throw s}return}if(this.refreshingDeferred!==null){this._debug("#_autoRefreshTokenTick()","refresh already in flight, skipping");return}try{const s=Date.now();try{await this._useSession(async n=>{const{data:{session:a}}=n;if(!a||!a.refresh_token||!a.expires_at){this._debug("#_autoRefreshTokenTick()","no session");return}const r=Math.floor((a.expires_at*1e3-s)/oo);this._debug("#_autoRefreshTokenTick()",`access token expires in ${r} ticks, a tick lasts ${oo}ms, refresh threshold is ${rh} ticks`),r<=rh&&await this._callRefreshToken(a.refresh_token)})}catch(n){console.error("Auto refresh tick failed with error. This is likely a transient error.",n)}}finally{this._debug("#_autoRefreshTokenTick()","end")}}async _handleVisibilityChange(){if(this._debug("#_handleVisibilityChange()"),!yn()||!(window!=null&&window.addEventListener))return this.autoRefreshToken&&this.startAutoRefresh(),!1;try{this.visibilityChangedCallback=async()=>{try{await this._onVisibilityChanged(!1)}catch(s){this._debug("#visibilityChangedCallback","error",s)}},window==null||window.addEventListener("visibilitychange",this.visibilityChangedCallback),await this._onVisibilityChanged(!0)}catch(s){console.error("_handleVisibilityChange",s)}}async _onVisibilityChanged(s){const n=`#_onVisibilityChanged(${s})`;if(this._debug(n,"visibilityState",document.visibilityState),document.visibilityState==="visible"){if(this.autoRefreshToken&&this._startAutoRefresh(),!s)if(
1149await this.initializePromise,this.lock!=null)await this._acquireLock(this.lockAcquireTimeout,async()=>{if(document.visibilityState!=="visible"){this._debug(n,"acquired the lock to recover the session, but the browser visibilityState is no longer visible, aborting");return}await this._recoverAndRefresh()});else{if(document.visibilityState!=="visible"){this._debug(n,"visibilityState is no longer visible, skipping recovery");return}await this._recoverAndRefresh()}}else document.visibilityState==="hidden"&&this.autoRefreshToken&&this._stopAutoRefresh()}async _getUrlForProvider(s,n,a){let r=a==null?void 0:a.redirectTo,i=null,o=null,l=null;this.flowType==="pkce"&&([i,o,l]=await this._getCodeChallengeAndMethod(),r=this._maybeAppendFlowIdToRedirect(r,l));const c=[`provider=${encodeURIComponent(n)}`];if(r&&c.push(`redirect_to=${encodeURIComponent(r)}`),a!=null&&a.scopes&&c.push(`scopes=${encodeURIComponent(a.scopes)}`),i!=null&&o!=null){const u=new URLSearchParams({code_challenge:`${encodeURIComponent(i)}`,code_challenge_method:`${encodeURIComponent(o)}`});c.push(u.toString())}if(a!=null&&a.queryParams){const u=new URLSearchParams(a.queryParams);c.push(u.toString())}return a!=null&&a.skipBrowserRedirect&&c.push(`skip_http_redirect=${a.skipBrowserRedirect}`),{url:`${s}?${c.join("&")}`,flowId:l}}_maybeAppendFlowIdToRedirect(s,n){return!s||!n||!this.experimental.appendPkceFlowIdToRedirects?s??void 0:oV(s,n)}async _getCodeChallengeAndMethod(s=!1){return lV(this.storage,this.storageKey,s,n=>this._debug("#_getCodeChallengeAndMethod()","evicted oldest pending PKCE verifier slot",n))}async _unenroll(s){try{return await this._useSession(async n=>{var a;const{data:r,error:i}=n;return i?this._returnResult({data:null,error:i}):await Ze(this.fetch,"DELETE",`${this.url}/factors/${s.factorId}`,{headers:this.headers,jwt:(a=r==null?void 0:r.session)===null||a===void 0?void 0:a.access_token})})}catch(n){if(Le(n))return this._returnResult({data:null,error:n});throw n}}async _enroll(s){try{return await this._useSession(async n=>{var a,r;const{data:i,error:o}=n;if(o)return this._returnResult({data:null,error:o});const l=Object.assign({friendly_name:s.friendlyName,factor_type:s.factorType},s.factorType==="phone"?{phone:s.phone}:s.factorType==="totp"?{issuer:s.issuer}:{}),{data:c,error:u}=await Ze(this.fetch,"POST",`${this.url}/factors`,{body:l,headers:this.headers,jwt:(a=i==null?void 0:i.session)===null||a===void 0?void 0:a.access_token});return u?this._returnResult({data:null,error:u}):(s.factorType==="totp"&&c.type==="totp"&&(!((r=c==null?void 0:c.totp)===null||r===void 0)&&r.qr_code)&&(c.totp.qr_code=`data:image/svg+xml;utf-8,${c.totp.qr_code}`),this._returnResult({data:c,error:null}))})}catch(n){if(Le(n))return this._returnResult({data:null,error:n});throw n}}async _verify(s){const n=async()=>{try{return await this._useSession(async a=>{var r;const{data:i,error:o}=a;if(o)return this._returnResult({data:null,error:o});const l=Object.assign({challenge_id:s.challengeId},"webauthn"in s?{webauthn:Object.assign(Object.assign({},s.webauthn),{credential_response:s.webauthn.type==="create"?m3(s.webauthn.credential_response):p3(s.webauthn.credential_response)})}:{code:s.code}),{data:c,error:u}=await Ze(this.fetch,"POST",`${this.url}/factors/${s.factorId}/verify`,{body:l,headers:this.headers,jwt:(r=i==null?void 0:i.session)===null||r===void 0?void 0:r.access_token});return u?this._returnResult({data:null,error:u}):(await this._saveSession(Object.assign({expires_at:Math.round(Date.now()/1e3)+c.expires_in},c)),await this._notifyAllSubscribers("MFA_CHALLENGE_VERIFIED",c),this._returnResult({data:c,error:u}))})}catch(a){if(Le(a))return this._returnResult({data:null,error:a});throw a}};return this.lock!=null?this._acquireLock(this.lockAcquireTimeout,n):n()}async _challenge(s){const n=async()=>{try{return await this._useSession(async a=>{var r;const{data:i,error:o}=a;if(o)return this._returnResult({data:null,error:o});const l=await Ze(this.fetch,"POST",`${this.url}/factors/${s.factorId}/challenge`,{body:s,headers:this.headers,jwt:(r=i==null?void 0:i.session)===null||r===void 0?void 0:r.access_token});if(l.error)return l;const{data:c}=l;if(c.type!=="webauthn")return{data:c,error:null};switch(c.webauthn.type){case"create":return{data:Object.assign(Object.assign({},c),{webauthn:Object.assign(Object.assign({},c.webauthn),{credential_options:Object.assign(Object.assign({},c.webauthn.credential_options),{publicKey:d3(c.webauthn.credential_options.publicKey)})})}),error:null};case"request":return{data:Object.assign(Object.assign({},c),{webauthn:Object.assign(Object.assign({},c.webauthn),{credential_options:Object.assign(Object.assign({},c.webauthn.credential_options),{publicKey:u3(c.webauthn.credential_options.publicKey)})})}),error:null}}})}catch(a){if(Le(a))return this._returnResult({data:null,error:a});throw a}};return this.lock!=null?this._acquireLock(this.lockAcquireTimeout,n):n()}async _challengeAndVerify(s){const{data:n,error:a}=await this._challenge({factorId:s.factorId});return a?this._returnResult({data:null,error:a}):await this._verify({factorId:s.factorId,challengeId:n.id,code:s.code})}async _listFactors(){var s;const{data:{user:n},error:a}=await this.getUser();if(a)return{data:null,error:a};const r={all:[],phone:[],totp:[],webauthn:[]};for(const i of(s=n==null?void 0:n.factors)!==null&&s!==void 0?s:[])r.all.push(i),i.status==="verified"&&r[i.factor_type].push(i);return{data:r,error:null}}async _getAuthenticatorAssuranceLevel(s){var n,a,r,i;if(s)try{const{payload:h}=Mf(s);let y=null;h.aal&&(y=h.aal);let v=y;const{data:{user:g},error:N}=await this.getUser(s);if(N)return this._returnResult({data:null,error:N});((a=(n=g==null?void 0:g.factors)===null||n===void 0?void 0:n.filter(j=>j.status==="verified"))!==null&&a!==void 0?a:[]).length>0&&(v="aal2");const f=h.amr||[];return{data:{currentLevel:y,nextLevel:v,currentAuthenticationMethods:f},error:null}}catch(h){if(Le(h))return this._returnResult({data:null,error:h});throw h}const{data:{session:o},error:l}
1149=await this.getSession();if(l)return this._returnResult({data:null,error:l});if(!o)return{data:{currentLevel:null,nextLevel:null,currentAuthenticationMethods:[]},error:null};const{payload:c}=Mf(o.access_token);let u=null;c.aal&&(u=c.aal);let p=u;((i=(r=o.user.factors)===null||r===void 0?void 0:r.filter(h=>h.status==="verified"))!==null&&i!==void 0?i:[]).length>0&&(p="aal2");const x=c.amr||[];return{data:{currentLevel:u,nextLevel:p,currentAuthenticationMethods:x},error:null}}async _getAuthorizationDetails(s){try{return await this._useSession(async n=>{const{data:{session:a},error:r}=n;return r?this._returnResult({data:null,error:r}):a?await Ze(this.fetch,"GET",`${this.url}/oauth/authorizations/${s}`,{headers:this.headers,jwt:a.access_token,xform:i=>({data:i,error:null})}):this._returnResult({data:null,error:new on})})}catch(n){if(Le(n))return this._returnResult({data:null,error:n});throw n}}async _approveAuthorization(s,n){try{return await this._useSession(async a=>{const{data:{session:r},error:i}=a;if(i)return this._returnResult({data:null,error:i});if(!r)return this._returnResult({data:null,error:new on});const o=await Ze(this.fetch,"POST",`${this.url}/oauth/authorizations/${s}/consent`,{headers:this.headers,jwt:r.access_token,body:{action:"approve"},xform:l=>({data:l,error:null})});return o.data&&o.data.redirect_url&&yn()&&!(n!=null&&n.skipBrowserRedirect)&&window.location.assign(o.data.redirect_url),o})}catch(a){if(Le(a))return this._returnResult({data:null,error:a});throw a}}async _denyAuthorization(s,n){try{return await this._useSession(async a=>{const{data:{session:r},error:i}=a;if(i)return this._returnResult({data:null,error:i});if(!r)return this._returnResult({data:null,error:new on});const o=await Ze(this.fetch,"POST",`${this.url}/oauth/authorizations/${s}/consent`,{headers:this.headers,jwt:r.access_token,body:{action:"deny"},xform:l=>({data:l,error:null})});return o.data&&o.data.redirect_url&&yn()&&!(n!=null&&n.skipBrowserRedirect)&&window.location.assign(o.data.redirect_url),o})}catch(a){if(Le(a))return this._returnResult({data:null,error:a});throw a}}async _listOAuthGrants(){try{return await this._useSession(async s=>{const{data:{session:n},error:a}=s;return a?this._returnResult({data:null,error:a}):n?await Ze(this.fetch,"GET",`${this.url}/user/oauth/grants`,{headers:this.headers,jwt:n.access_token,xform:r=>({data:r,error:null})}):this._returnResult({data:null,error:new on})})}catch(s){if(Le(s))return this._returnResult({data:null,error:s});throw s}}async _revokeOAuthGrant(s){try{return await this._useSession(async n=>{const{data:{session:a},error:r}=n;return r?this._returnResult({data:null,error:r}):a?(await Ze(this.fetch,"DELETE",`${this.url}/user/oauth/grants`,{headers:this.headers,jwt:a.access_token,query:{client_id:s.clientId},noResolveJson:!0}),{data:{},error:null}):this._returnResult({data:null,error:new on})})}catch(n){if(Le(n))return this._returnResult({data:null,error:n});throw n}}async fetchJwk(s,n={keys:[]}){let a=n.keys.find(l=>l.kid===s);if(a)return a;const r=Date.now();if(a=this.jwks.keys.find(l=>l.kid===s),a&&this.jwks_cached_at+LG>r)return a;const{data:i,error:o}=await Ze(this.fetch,"GET",`${this.url}/.well-known/jwks.json`,{headers:this.headers});if(o)throw o;return!i.keys||i.keys.length===0||(this.jwks=i,this.jwks_cached_at=r,a=i.keys.find(l=>l.kid===s),!a)?null:a}async getClaims(s,n={}){try{let a=s;if(!a){const{data:h,error:y}
1149=await this.getSession();if(y||!h.session)return this._returnResult({data:null,error:y});a=h.session.access_token}const{header:r,payload:i,signature:o,raw:{header:l,payload:c}}=Mf(a);if(!(n!=null&&n.allowExpired))try{uV(i.exp)}catch(h){throw new Ly(h instanceof Error?h.message:"JWT validation failed")}const u=!r.alg||r.alg.startsWith("HS")||!r.kid||!("crypto"in globalThis&&"subtle"in globalThis.crypto)?null:await this.fetchJwk(r.kid,n!=null&&n.keys?{keys:n.keys}:n==null?void 0:n.jwks);if(!u){const{error:h}=await this.getUser(a);if(h)throw h;return{data:{claims:i,header:r,signature:o},error:null}}const p=mV(r.alg),m=await crypto.subtle.importKey("jwk",u,p,!0,["verify"]);if(!await crypto.subtle.verify(p,m,o,VG(`${l}.${c}`)))throw new Ly("Invalid JWT signature");return{data:{claims:i,header:r,signature:o},error:null}}catch(a){if(Le(a))return this._returnResult({data:null,error:a});throw a}}async signInWithPasskey(s){var n,a,r;$r(this.experimental);try{if(!By())return this._returnResult({data:null,error:new Vr("Browser does not support WebAuthn",null)});const{data:i,error:o}=await this._startPasskeyAuthentication({options:{captchaToken:(n=s==null?void 0:s.options)===null||n===void 0?void 0:n.captchaToken}});if(o||!i)return this._returnResult({data:null,error:o});const l=u3(i.options),c=(r=(a=s==null?void 0:s.options)===null||a===void 0?void 0:a.signal)!==null&&r!==void 0?r:I2.createNewAbortSignal(),{data:u,error:p}=await PR({publicKey:l,signal:c});if(p||!u)return this._returnResult({data:null,error:p??new Vr("WebAuthn ceremony failed",null)});const m=p3(u);return this._verifyPasskeyAuthentication({challengeId:i.challenge_id,credential:m})}catch(i){if(Le(i))return this._returnResult({data:null,error:i});throw i}}async registerPasskey(s){var n,a;$r(this.experimental);try{if(!By())return this._returnResult({data:null,error:new Vr("Browser does not support WebAuthn",null)});const{data:r,error:i}=await this._startPasskeyRegistration();if(i||!r)return this._returnResult({data:null,error:i});const o=d3(r.options),l=(a=(n=s==null?void 0:s.options)===null||n===void 0?void 0:n.signal)!==null&&a!==void 0?a:I2.createNewAbortSignal(),{data:c,error:u}=await TR({publicKey:o,signal:l});if(u||!c)return this._returnResult({data:null,error:u??new Vr("WebAuthn ceremony failed",null)});const p=m3(c);return this._verifyPasskeyRegistration({challengeId:r.challenge_id,credential:p})}catch(r){if(Le(r))return this._returnResult({data:null,error:r});throw r}}async _startPasskeyRegistration(){$r(this.experimental);try{return await this._useSession(async s=>{const{data:{session:n},error:a}=s;
1149if(a)return this._returnResult({data:null,error:a});if(!n)return this._returnResult({data:null,error:new on});const{data:r,error:i}=await Ze(this.fetch,"POST",`${this.url}/passkeys/registration/options`,{headers:this.headers,jwt:n.access_token,body:{}});return i?this._returnResult({data:null,error:i}):this._returnResult({data:r,error:null})})}catch(s){if(Le(s))return this._returnResult({data:null,error:s});throw s}}async _verifyPasskeyRegistration(s){$r(this.experimental);try{return await this._useSession(async n=>{const{data:{session:a},error:r}=n;if(r)return this._returnResult({data:null,error:r});if(!a)return this._returnResult({data:null,error:new on});const{data:i,error:o}=await Ze(this.fetch,"POST",`${this.url}/passkeys/registration/verify`,{headers:this.headers,jwt:a.access_token,body:{challenge_id:s.challengeId,credential:s.credential}});return o?this._returnResult({data:null,error:o}):this._returnResult({data:i,error:null})})}catch(n){if(Le(n))return this._returnResult({data:null,error:n});throw n}}async _startPasskeyAuthentication(s){var n;$r(this.experimental);try{const{data:a,error:r}=await Ze(this.fetch,"POST",`${this.url}/passkeys/authentication/options`,{headers:this.headers,body:{gotrue_meta_security:{captcha_token:(n=s==null?void 0:s.options)===null||n===void 0?void 0:n.captchaToken}}});return r?this._returnResult({data:null,error:r}):this._returnResult({data:a,error:null})}catch(a){if(Le(a))return this._returnResult({data:null,error:a});throw a}}async _verifyPasskeyAuthentication(s){$r(this.experimental);try{const{data:n,error:a}=await Ze(this.fetch,"POST",`${this.url}/passkeys/authentication/verify`,{headers:this.headers,body:{challenge_id:s.challengeId,credential:s.credential},xform:or});return a?this._returnResult({data:null,error:a}):(n.session&&(await this._saveSession(n.session),await this._notifyAllSubscribers("SIGNED_IN",n.session)),this._returnResult({data:n,error:null}))}catch(n){if(Le(n))return this._returnResult({data:null,error:n});throw n}}async _listPasskeys(){$r(this.experimental);try{return await this._useSession(async s=>{const{data:{session:n},error:a}=s;
1149if(a)return this._returnResult({data:null,error:a});if(!n)return this._returnResult({data:null,error:new on});const{data:r,error:i}=await Ze(this.fetch,"GET",`${this.url}/passkeys`,{headers:this.headers,jwt:n.access_token,xform:o=>({data:o,error:null})});return i?this._returnResult({data:null,error:i}):this._returnResult({data:r,error:null})})}catch(s){if(Le(s))return this._returnResult({data:null,error:s});throw s}}async _updatePasskey(s){$r(this.experimental);try{return await this._useSession(async n=>{const{data:{session:a},error:r}=n;if(r)return this._returnResult({data:null,error:r});if(!a)return this._returnResult({data:null,error:new on});const{data:i,error:o}=await Ze(this.fetch,"PATCH",`${this.url}/passkeys/${s.passkeyId}`,{headers:this.headers,jwt:a.access_token,body:{friendly_name:s.friendlyName}});return o?this._returnResult({data:null,error:o}):this._returnResult({data:i,error:null})})}catch(n){if(Le(n))return this._returnResult({data:null,error:n});throw n}}async _deletePasskey(s){$r(this.experimental);try{return await this._useSession(async n=>{const{data:{session:a},error:r}=n;if(r)return this._returnResult({data:null,error:r});if(!a)return this._returnResult({data:null,error:new on});const{error:i}=await Ze(this.fetch,"DELETE",`${this.url}/passkeys/${s.passkeyId}`,{headers:this.headers,jwt:a.access_token,noResolveJson:!0});return i?this._returnResult({data:null,error:i}):this._returnResult({data:null,error:null})})}catch(n){if(Le(n))return this._returnResult({data:null,error:n});throw n}}}Sx.nextInstanceID={};const IV=Sx,$V="2.112.3";let ih="",qy;if(typeof Deno<"u"){var mv;ih="deno",qy=(mv=Deno.version)===null||mv===void 0?void 0:mv.deno}else if(typeof document<"u")ih="web";else if(typeof navigator<"u"&&navigator.product==="ReactNative")ih="react-native";else{var pv;ih="node";const t=globalThis.process;qy=t==null||(pv=t.version)===null||pv===void 0?void 0:pv.replace(/^v/,"")}const DR=[`runtime=${ih}`];qy&&DR.push(`runtime-version=${qy}`);const zV={"X-Client-Info":`supabase-js/${$V}; ${DR.join("; ")}`},LV={headers:zV},OV={schema:"public"},MV={autoRefreshToken:!0,persistSession:!0,detectSessionInUrl:!0,flowType:"implicit"},BV={},UV={enabled:!1,respectSamplingDecision:!0};function qV(t){if(!t||typeof t!="string")return null;const s=t.split("-");if(s.length!==4)return null;const[n,a,r,i]=s;if(n.length!==2||a.length!==32||r.length!==16||i.length!==2)return null;const o=/^[0-9a-f]+$/i;return!o.test(n)||!o.test(a)||!o.test(r)||!o.test(i)||a==="00000000000000000000000000000000"||r==="0000000000000000"?null:{version:n,traceId:a,parentId:r,traceFlags:i,isSampled:(parseInt(i,16)&1)===1}}function WV(t,s){if(!t||!s||s.length===0)return!1;let n;if(t instanceof URL)n=t;else try{n=new URL(t)}catch{return!1}for(const a of s)try{if(typeof a=="string"){if(HV(n.hostname,a))return!0}else if(a instanceof RegExp){if(a.test(n.hostname))return!0}else if(typeof a=="function"&&a(n))return!0}catch{continue}return!1}function HV(t,s){if(s===t)return!0;if(s.startsWith("*.")){const n=s.slice(2);if(t.endsWith(n)&&(t===n||t.endsWith("."+n)))return!0}return!1}function GV(t){const s=[];try{const n=new URL(t);s.push(n.hostname)}catch{}return s.push("*.supabase.co","*.supabase.in"),s.push("localhost","127.0.0.1","[::1]"),s}function Cx(t){"@babel/helpers - typeof";return Cx=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(s){return typeof s}:function(s){return s&&typeof Symbol=="function"&&s.constructor===Symbol&&s!==Symbol.prototype?"symbol":typeof s},Cx(t)}function VV(t,s){if(Cx(t)!="object"||!t)return t;var n=t[Symbol.toPrimitive];if(n!==void 0){var a=n.call(t,s);if(Cx(a)!="object")return a;throw new TypeError("@@toPrimitive must return a primitive value.")}return(s==="string"?String:Number)(t)}function ZV(t){var s=VV(t,"string");return Cx(s)=="symbol"?s:s+""}function YV(t,s,n){return(s=ZV(s))in t?Object.defineProperty(t,s,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[s]=n,t}function h3(t,s){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(t);s&&(a=a.filter(function(r){return Object.getOwnPropertyDescriptor(t,r).enumerable})),n.push.apply(n,a)}return n}function _s(t){for(var s=1;s<arguments.length;s++){var n=arguments[s]!=null?arguments[s]:{};
1149s%2?h3(Object(n),!0).forEach(function(a){YV(t,a,n[a])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):h3(Object(n)).forEach(function(a){Object.defineProperty(t,a,Object.getOwnPropertyDescriptor(n,a))})}return t}const KV=t=>t?(...s)=>t(...s):(...s)=>fetch(...s),QV=()=>Headers,RR=t=>t.startsWith("sb_publishable_")||t.startsWith("sb_secret_"),JV="sb_temp_",x3=new Set,XV=t=>{var s,n;if(!t.startsWith("sb_")||RR(t)||t.startsWith(JV))return;const a=(s=(n=t.match(/^sb_[a-zA-Z0-9]+_/))===null||n===void 0?void 0:n[0])!==null&&s!==void 0?s:"unknown";x3.has(a)||(x3.add(a),console.warn("@supabase/supabase-js: Unrecognized Supabase API key format. The client will proceed and send this key as-is; if you see authentication errors you may need to upgrade @supabase/supabase-js to a version that recognizes this key type."))},f3=(t,s,n,a,r,i)=>{const o=KV(a),l=QV(),c=(r==null?void 0:r.enabled)===!0,u=(r==null?void 0:r.respectSamplingDecision)!==!1,p=c?GV(s):null,m=!(i!=null&&i.omitApiKeyAsBearer&&RR(t));return async(x,h)=>{const y=await n();let v=new l(h==null?void 0:h.headers);if(v.has("apikey")||v.set("apikey",t),!v.has("Authorization")){const g=y??(m?t:null);g&&v.set("Authorization",`Bearer ${g}`)}if(p){const g=eZ(x,p,u);g&&(g.traceparent&&!v.has("traceparent")&&v.set("traceparent",g.traceparent),g.tracestate&&!v.has("tracestate")&&v.set("tracestate",g.tracestate),g.baggage&&!v.has("baggage")&&v.set("baggage",g.baggage))}return o(x,_s(_s({},h),{},{headers:v}))}};let g3=!1,y3=!1;function eZ(t,s,n){const a=JW();if(!a)return g3||(g3=!0,console.warn("@supabase/supabase-js: tracePropagation is enabled but the tracing runtime is not loaded, so trace headers will not be attached. Add `import '@supabase/supabase-js/tracing'` at your application entry point (requires the OpenTelemetry API package to be installed). The CDN/UMD build does not support trace propagation.")),null;if(!WV(typeof t=="string"||t instanceof URL?t:t.url,s))return null;const r=a();if(!r||!r.traceparent){var i;if(!(r==null||(i=r.carrierKeys)===null||i===void 0)&&i.length&&!y3){y3=!0;const o=r.carrierKeys.includes("sentry-trace")?" Sentry detected: set `propagateTraceparent: true` in Sentry.init() to emit it.":" Configure your tracing SDK to emit W3C trace context on outgoing requests.";console.warn(`@supabase/supabase-js: tracePropagation is enabled and a tracing SDK is active, but its propagator wrote [${r.carrierKeys.join(", ")}] and no W3C traceparent header, so trace headers will not be attached.`+o)}return null}if(n){const o=qV(r.traceparent);if(o&&!o.isSampled)return{traceparent:r.traceparent}}return r}function b3(t){return typeof t=="boolean"?{enabled:t}:t}function tZ(t){return t.endsWith("/")?t:t+"/"}function sZ(t,s){var n,a,r,i,o,l;const{db:c,auth:u,realtime:p,global:m}=t,{db:x,auth:h,realtime:y,global:v}=s,g=b3(t.tracePropagation),N=b3(s.tracePropagation),b={db:_s(_s({},x),c),auth:_s(_s({},h),u),realtime:_s(_s({},y),p),storage:{},global:_s(_s(_s({},v),m),{},{headers:_s(_s({},(n=v==null?void 0:v.headers)!==null&&n!==void 0?n:{}),(a=m==null?void 0:m.headers)!==null&&a!==void 0?a:{})}),tracePropagation:{enabled:(r=(i=g==null?void 0:g.enabled)!==null&&i!==void 0?i:N==null?void 0:N.enabled)!==null&&r!==void 0?r:!1,respectSamplingDecision:(o=(l=g==null?void 0:g.respectSamplingDecision)!==null&&l!==void 0?l:N==null?void 0:N.respectSamplingDecision)!==null&&o!==void 0?o:!0},accessToken:async()=>""};return t.accessToken?b.accessToken=t.accessToken:delete b.accessToken,b}function nZ(t){const s=t==null?void 0:t.trim();if(!s)throw new Error("supabaseUrl is required.");if(!s.match(/^https?:\/\//i))throw new Error("Invalid supabaseUrl: Must be a valid HTTP or HTTPS URL.");try{return new URL(tZ(s))}catch{throw Error("Invalid supabaseUrl: Provided URL is malformed.")}}var aZ=class extends IV{constructor(t){super(t)}},rZ=class{constructor(t,s,n){var a,r;this.supabaseUrl=t,this.supabaseKey=s;const i=nZ(t);if(!s)throw new Error("supabaseKey is required.");XV(s),this.realtimeUrl=new URL("realtime/v1",i),this.realtimeUrl.protocol=this.realtimeUrl.protocol.replace("http","ws"),this.authUrl=new URL("auth/v1",i),this.storageUrl=new URL("storage/v1",i),this.functionsUrl=new URL("functions/v1",i);const o=`sb-${i.hostname.split(".")[0]}-auth-token`,l={db:OV,realtime:BV,auth:_s(_s({},MV),{},{storageKey:o}),global:LV,tracePropagation:UV},c=sZ(n??{},l);if(this.settings=c,this.storageKey=(a=c.auth.storageKey)!==null&&a!==void 0?a:"",this.headers=(r=c.global.headers)!==null&&r!==void 0?r:{},c.accessToken)this.accessToken=c.accessToken,this.auth=new Proxy({},{get:(p,m)=>{throw new Error(`@supabase/supabase-js: Supabase Client is configured with the accessToken option, accessing supabase.auth.${String(m)} is not possible`)}});else{var u;this.auth=this._initSupabaseAuthClient((u=c.auth)!==null&&u!==void 0?u:{},this.headers,c.global.fetch)}this.fetch=f3(s,t,this._getSessionToken.bind(this),c.global.fetch,c.tracePropagation),this.functionsFetch=f3(s,t,this._getSessionToken.bind(this),c.global.fetch,c.tracePropagation,{omitApiKeyAsBearer
1149:!0}),this.realtime=this._initRealtimeClient(_s({headers:this.headers,accessToken:this._getAccessToken.bind(this),fetch:this.fetch},c.realtime)),this.accessToken&&Promise.resolve(this.accessToken()).then(p=>this.realtime.setAuth(p)).catch(p=>console.warn("Failed to set initial Realtime auth token:",p)),this.rest=new mH(new URL("rest/v1",i).href,{headers:this.headers,schema:c.db.schema,fetch:this.fetch,timeout:c.db.timeout,urlLengthLimit:c.db.urlLengthLimit,retry:c.db.retry}),this.storage=new TG(this.storageUrl.href,this.headers,this.fetch,n==null?void 0:n.storage),c.accessToken||this._listenForAuthEvents()}get functions(){return new nH(this.functionsUrl.href,{headers:this.headers,customFetch:this.functionsFetch})}from(t){return this.rest.from(t)}schema(t){return this.rest.schema(t)}rpc(t,s={},n={head:!1,get:!1,count:void 0}){return this.rest.rpc(t,s,n)}channel(t,s={config:{}}){return this.realtime.channel(t,s)}getChannels(){return this.realtime.getChannels()}removeChannel(t){return this.realtime.removeChannel(t)}removeAllChannels(){return this.realtime.removeAllChannels()}async _getSessionToken(){var t=this,s,n;if(t.accessToken)return await t.accessToken();const{data:a}=await t.auth.getSession();return(s=(n=a.session)===null||n===void 0?void 0:n.access_token)!==null&&s!==void 0?s:null}async _getAccessToken(){var t=this,s;return(s=await t._getSessionToken())!==null&&s!==void 0?s:t.supabaseKey}_initSupabaseAuthClient({autoRefreshToken:t,persistSession:s,detectSessionInUrl:n,storage:a,userStorage:r,storageKey:i,flowType:o,lock:l,debug:c,throwOnError:u,experimental:p,lockAcquireTimeout:m,skipAutoInitialize:x},h,y){const v={Authorization:`Bearer ${this.supabaseKey}`,apikey:`${this.supabaseKey}`};return new aZ({url:this.authUrl.href,headers:_s(_s({},v),h),storageKey:i,autoRefreshToken:t,persistSession:s,detectSessionInUrl:n,storage:a,userStorage:r,flowType:o,lock:l,debug:c,throwOnError:u,experimental:p,fetch:y,lockAcquireTimeout:m,skipAutoInitialize:x,hasCustomAuthorizationHeader:Object.keys(this.headers).some(g=>g.toLowerCase()==="authorization")})}_initRealtimeClient(t){return new tG(this.realtimeUrl.href,_s(_s({},t),{},{params:_s(_s({},{apikey:this.supabaseKey}),t==null?void 0:t.params)}))}_listenForAuthEvents(){return this.auth.onAuthStateChange((t,s)=>{this._handleTokenChanged(t,"CLIENT",s==null?void 0:s.access_token)})}_handleTokenChanged(t,s,n){(t==="TOKEN_REFRESHED"||t==="SIGNED_IN"||t==="INITIAL_SESSION")&&this.changedAccessToken!==n?(this.changedAccessToken=n,this.realtime.setAuth(n)):t==="SIGNED_OUT"&&(this.realtime.setAuth(),s=="STORAGE"&&this.auth.signOut(),this.changedAccessToken=void 0)}};const iZ=(t,s,n)=>new rZ(t,s,n);
1149function oZ(){if(typeof window<"u"||globalThis.Deno!==void 0)return!1;const t=globalThis.process;if(!t)return!1;const s=t.version;if(s==null)return!1;const n=s.match(/^v(\d+)\./);return n?parseInt(n[1],10)<=20:!1}oZ()&&console.warn("â ï¸ Node.js 20 and below are deprecated and will no longer be supported in future versions of @supabase/supabase-js. Please upgrade to Node.js 22 or later. For more information, visit: https://github.com/orgs/supabase/discussions/45715");const lZ="https://tojqzezdtojnxquphifh.databasepad.com",cZ="eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCIsImtpZCI6IjY2ZDg4NjE3LWYyMWUtNGY3OC1hN2Q2LWZkOTlmMGMxZjNiMyJ9.eyJwcm9qZWN0SWQiOiJ0b2pxemV6ZHRvam54cXVwaGlmaCIsInJvbGUiOiJhbm9uIiwiaWF0IjoxNzc0OTA2NzUwLCJleHAiOjIwOTAyNjY3NTAsImlzcyI6ImZhbW91cy5kYXRhYmFzZXBhZCIsImF1ZCI6ImZhbW91cy5jbGllbnRzIn0.ZPMChrZXp0qUEzvJSqCQnvcQ-DCZiIFFkVKUw2YzZXA",O=iZ(lZ,cZ);var dZ=Object.defineProperty,Kn=(t,s)=>dZ(t,"name",{value:s,configurable:!0}),hv="focusScope.autoFocusOnMount",xv="focusScope.autoFocusOnUnmount",v3={bubbles:!1,cancelable:!0},IR=d.forwardRef(Kn(function(s,n){const{loop:a=!1,trapped:r=!1,onMountAutoFocus:i,onUnmountAutoFocus:o,...l}=s,[c,u]=d.useState(null),p=sa(i),m=sa(o),x=d.useRef(null),h=It(n,u),y=d.useRef({paused:!1,pause(){this.paused=!0},resume(){this.paused=!1}}).current;d.useEffect(()=>{if(r){let g=function(j){if(y.paused||!c)return;const S=j.target;c.contains(S)?x.current=S:lo(x.current,{select:!0})},N=function(j){if(y.paused||!c)return;const S=j.relatedTarget;S!==null&&(c.contains(S)||lo(x.current,{select:!0}))},b=function(j){if(document.activeElement===document.body)for(const w of j)w.removedNodes.length>0&&lo(c)};Kn(g,"handleFocusIn"),Kn(N,"handleFocusOut"),Kn(b,"handleMutations"),document.addEventListener("focusin",g),document.addEventListener("focusout",N);const f=new MutationObserver(b);return c&&f.observe(c,{childList:!0,subtree:!0}),()=>{document.removeEventListener("focusin",g),document.removeEventListener("focusout",N),f.disconnect()}}},[r,c,y.paused]),d.useEffect(()=>{if(c){j3.add(y);const g=document.activeElement;if(!c.contains(g)){const b=new CustomEvent(hv,v3);c.addEventListener(hv,p),c.dispatchEvent(b),b.defaultPrevented||($R(BR(v5(c)),{select:!0}),document.activeElement===g&&lo(c))}return()=>{c.removeEventListener(hv,p),setTimeout(()=>{const b=new CustomEvent(xv,v3);c.addEventListener(xv,m),c.dispatchEvent(b),b.defaultPrevented||lo(g??document.body,{select:!0}),c.removeEventListener(xv,m),j3.remove(y)},0)}}},[c,p,m,y]);const v=d.useCallback(g=>{if(!a&&!r||y.paused)return;const N=g.key==="Tab"&&!g.altKey&&!g.ctrlKey&&!g.metaKey,b=document.activeElement;if(N&&b){const f=g.currentTarget,[j,S]=zR(f);j&&S?!g.shiftKey&&b===S?(g.preventDefault(),a&&lo(j,{select:!0})):g.shiftKey&&b===j&&(g.preventDefault(),a&&lo(S,{select:!0})):b===f&&g.preventDefault()}},[a,r,y.paused]);return e.jsx(yt.div,{tabIndex:-1,...l,ref:h,onKeyDown:v})},"FocusScope"));function $R(t,{select:s=!1}={}){const n=document.activeElement;for(const a of t)if(lo(a,{select:s}),document.activeElement!==n)return}Kn($R,"focusFirst");function zR(t){const s=v5(t),n=$2(s,t),a=$2(s.reverse(),t);return[n,a]}Kn(zR,"getTabbableEdges");function v5(t){const s=[],n=document.createTreeWalker(t,NodeFilter.SHOW_ELEMENT,{acceptNode:Kn(a=>{const r=a.tagName==="INPUT"&&a.type==="hidden";return a.disabled||a.hidden||r?NodeFilter.FILTER_SKIP:a.tabIndex>=0?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP},"acceptNode")});for(;n.nextNode();)s.push(n.currentNode);return s}Kn(v5,"getTabbableCandidates");function $2(t,s){const n=typeof s.checkVisibility=="function"&&s.checkVisibility({checkVisibilityCSS:!0});for(const a of t)if(!(n?!a.checkVisibility({checkVisibilityCSS:!0}):LR(a,{upTo:s})))return a}Kn($2,"findVisible");function LR(t,{upTo:s}){if(getComputedStyle(t).visibility==="hidden")return!0;for(;t;){if(s!==void 0&&t===s)return!1;if(getComputedStyle(t).display==="none")return!0;t=t.parentElement}return!1}Kn(LR,"isHidden");function OR(t){return t instanceof HTMLInputElement&&"select"in t}Kn(OR,"isSelectableInput");function lo(t,{select:s=!1}={}){if(t&&t.focus){const n=document.activeElement;t.focus({preventScroll:!0}),t!==n&&OR(t)&&s&&t.select()}}Kn(lo,"focus");var j3=MR();function MR(){let t=[];return{add(s){const n=t[0];s!==n&&(n==null||n.pause()),t=z2(t,s),t.unshift(s)},remove(s){var n;t=z2(t,s),(n=t[0])==null||n.resume()}}}Kn(MR,"createFocusScopesStack");function z2(t,s){const n=[...t],a=n.indexOf(s);return a!==-1&&n.splice(a,1),n}Kn(z2,"arrayRemove");function BR(t){return t.filter(s=>s.tagName!=="A")}Kn(BR,"removeLinks");var uZ=Object.defineProperty,j5=(t,s)=>uZ(t,"name",{value:s,configurable:!0}),Bf=0,oi=null;function mZ(t){return Xb(),t.children}j5(mZ,"FocusGuards");function Xb(){d.useEffect(()=>{oi||(oi={start:L2(),end:L2()});const{start:t,end:s}=oi;return document.body.firstElementChild!==t&&document.body.insertAdjacentElement("afterbegin",t),document.body.lastElementChild!==s&&document.body.insertAdjacentElement("beforeend",s),Bf++,
vendor: 5,219 bytes, lines 1149-1164
1149()=>{Bf===1&&(oi==null||oi.start.remove(),oi==null||oi.end.remove(),oi=null),Bf=Math.max(0,Bf-1)}},[])}j5(Xb,"useFocusGuards");function L2(){const t=document.createElement("span");return t.setAttribute("data-radix-focus-guard",""),t.tabIndex=0,t.style.outline="none",t.style.opacity="0",t.style.position="fixed",t.style.pointerEvents="none",t}j5(L2,"createFocusGuard");var y0="right-scroll-bar-position",b0="width-before-scroll-bar",pZ="with-scroll-bars-hidden",hZ="--removed-body-scroll-bar-size";function fv(t,s){return typeof t=="function"?t(s):t&&(t.current=s),t}function xZ(t,s){var n=d.useState(function(){return{value:t,callback:s,facade:{get current(){return n.value},set current(a){var r=n.value;r!==a&&(n.value=a,n.callback(a,r))}}}})[0];return n.callback=s,n.facade}var fZ=typeof window<"u"?d.useLayoutEffect:d.useEffect,w3=new WeakMap;function gZ(t,s){var n=xZ(null,function(a){return t.forEach(function(r){return fv(r,a)})});return fZ(function(){var a=w3.get(n);if(a){var r=new Set(a),i=new Set(t),o=n.current;r.forEach(function(l){i.has(l)||fv(l,null)}),i.forEach(function(l){r.has(l)||fv(l,o)})}w3.set(n,t)},[t]),n}function yZ(t){return t}function bZ(t,s){s===void 0&&(s=yZ);var n=[],a=!1,r={read:function(){if(a)throw new Error("Sidecar: could not `read` from an `assigned` medium. `read` could be used only with `useMedium`.");return n.length?n[n.length-1]:t},useMedium:function(i){var o=s(i,a);return n.push(o),function(){n=n.filter(function(l){return l!==o})}},assignSyncMedium:function(i){for(a=!0;n.length;){var o=n;n=[],o.forEach(i)}n={push:function(l){return i(l)},filter:function(){return n}}},assignMedium:function(i){a=!0;var o=[];if(n.length){var l=n;n=[],l.forEach(i),o=n}var c=function(){var p=o;o=[],p.forEach(i)},u=function(){return Promise.resolve().then(c)};u(),n={push:function(p){o.push(p),u()},filter:function(p){return o=o.filter(p),n}}}};return r}function vZ(t){t===void 0&&(t={});var s=bZ(null);return s.options=Ci({async:!0,ssr:!1},t),s}var UR=function(t){var s=t.sideCar,n=tp(t,["sideCar"]);if(!s)throw new Error("Sidecar: please provide `sideCar` property to import the right car");var a=s.read();if(!a)throw new Error("Sidecar medium not found");return d.createElement(a,Ci({},n))};UR.isSideCarExport=!0;function jZ(t,s){return t.useMedium(s),UR}var qR=vZ(),gv=function(){},e1=d.forwardRef(function(t,s){var n=d.useRef(null),a=d.useState({onScrollCapture:gv,onWheelCapture:gv,onTouchMoveCapture:gv}),r=a[0],i=a[1],o=t.forwardProps,l=t.children,c=t.className,u=t.removeScrollBar,p=t.enabled,m=t.shards,x=t.sideCar,h=t.noRelative,y=t.noIsolation,v=t.inert,g=t.allowPinchZoom,N=t.as,b=N===void 0?"div":N,f=t.gapMode,j=tp(t,["forwardProps","children","className","removeScrollBar","enabled","shards","sideCar","noRelative","noIsolation","inert","allowPinchZoom","as","gapMode"]),S=x,w=gZ([n,s]),_=Ci(Ci({},j),r);return d.createElement(d.Fragment,null,p&&d.createElement(S,{sideCar:qR,removeScrollBar:u,shards:m,noRelative:h,noIsolation:y,inert:v,setCallbacks:i,allowPinchZoom:!!g,lockRef:n,gapMode:f}),o?d.cloneElement(d.Children.only(l),Ci(Ci({},_),{ref:w})):d.createElement(b,Ci({},_,{className:c,ref:w}),l))});e1.defaultProps={enabled:!0,removeScrollBar:!0,inert:!1};e1.classNames={fullWidth:b0,zeroRight:y0};var wZ=function(){if(typeof __webpack_nonce__<"u")return __webpack_nonce__};function NZ(){if(!document)return null;var t=document.createElement("style");t.type="text/css";var s=wZ();return s&&t.setAttribute("nonce",s),t}function _Z(t,s){t.styleSheet?t.styleSheet.cssText=s:t.appendChild(document.createTextNode(s))}function kZ(t){var s=document.head||document.getElementsByTagName("head")[0];s.appendChild(t)}var SZ=function(){var t=0,s=null;return{add:function(n){t==0&&(s=NZ())&&(_Z(s,n),kZ(s)),t++},remove:function(){t--,!t&&s&&(s.parentNode&&s.parentNode.removeChild(s),s=null)}}},CZ=function(){var t=SZ();return function(s,n){d.useEffect(function(){return t.add(s),function(){t.remove()}},[s&&n])}},WR=function(){var t=CZ(),s=function(n){var a=n.styles,r=n.dynamic;return t(a,r),null};return s},AZ={left:0,top:0,right:0,gap:0},yv=function(t){return parseInt(t||"",10)||0},EZ=function(t){var s=window.getComputedStyle(document.body),n=s[t==="padding"?"paddingLeft":"marginLeft"],a=s[t==="padding"?"paddingTop":"marginTop"],r=s[t==="padding"?"paddingRight":"marginRight"];return[yv(n),yv(a),yv(r)]},FZ=function(t){if(t===void 0&&(t="margin"),typeof window>"u")return AZ;var s=EZ(t),n=document.documentElement.clientWidth,a=window.innerWidth;return{left:s[0],top:s[1],right:s[2],gap:Math.max(0,a-n+s[2]-s[0])}},TZ=WR(),im="data-scroll-locked",PZ=function(t,s,n,a){var r=t.left,i=t.top,o=t.right,l=t.gap;return n===void 0&&(n="margin"),` 1150 .`.concat(pZ,` { 1151 overflow: hidden `).concat(a,`; 1152 padding-right: `).concat(l,"px ").concat(a,`; 1153 } 1154 body[`).concat(im,`] { 1155 overflow: hidden `).concat(a,`; 1156 overscroll-behavior: contain; 1157 `).concat([s&&"position: relative ".concat(a,";"),n==="margin"&&` 1158 padding-left: `.concat(r,`px; 1159 padding-top: `).concat(i,`px; 1160 padding-right: `).concat(o,`px; 1161 margin-left:0; 1162 margin-top:0; 1163 margin-right: `).concat(l,"px ").concat(a,`; 1164 `),n==="padding"&&"padding-right: ".concat(l,"px ").concat(a,";
1164")].filter(Boolean).join(""),` 1165 } 1166 1167 .`).concat(y0,` { 1168 right: `).concat(l,"px ").concat(a,`; 1169 } 1170 1171 .`).concat(b0,` { 1172 margin-right: `).concat(l,"px ").concat(a,`; 1173 } 1174 1175 .`).concat(y0," .").concat(y0,` { 1176 right: 0 `).concat(a,`; 1177 } 1178 1179 .`).concat(b0," .").concat(b0,` { 1180 margin-right: 0 `).concat(a,`; 1181 } 1182 1183 body[`).concat(im,`] { 1184 `).concat(hZ,": ").concat(l,`px; 1185 } 1186`)},N3=function(){var t=parseInt(document.body.getAttribute(im)||"0",10);return isFinite(t)?t:0},DZ=function(){d.useEffect(function(){return document.body.setAttribute(im,(N3()+1).toString()),function(){var t=N3()-1;t<=0?document.body.removeAttribute(im):document.body.setAttribute(im,t.toString())}},[])},RZ=function(t){var s=t.noRelative,n=t.noImportant,a=t.gapMode,r=a===void 0?"margin":a;DZ();var i=d.useMemo(function(){return FZ(r)},[r]);return d.createElement(TZ,{styles:PZ(i,!s,r,n?"":"!important")})},O2=!1;if(typeof window<"u")try{var Uf=Object.defineProperty({},"passive",{get:function(){return O2=!0,!0}});window.addEventListener("test",Uf,Uf),window.removeEventListener("test",Uf,Uf)}catch{O2=!1}var Qd=O2?{passive:!1}:!1,IZ=function(t){return t.tagName==="TEXTAREA"},HR=function(t,s){if(!(t instanceof Element))return!1;var n=window.getComputedStyle(t);return n[s]!=="hidden"&&!(n.overflowY===n.overflowX&&!IZ(t)&&n[s]==="visible")},$Z=function(t){return HR(t,"overflowY")},zZ=function(t){return HR(t,"overflowX")},_3=function(t,s){var n=s.ownerDocument,a=s;do{typeof ShadowRoot<"u"&&a instanceof ShadowRoot&&(a=a.host);var r=GR(t,a);if(r){var i=VR(t,a),o=i[1],l=i[2];if(o>l)return!0}a=a.parentNode}while(a&&a!==n.body);return!1},LZ=function(t){var s=t.scrollTop,n=t.scrollHeight,a=t.clientHeight;return[s,n,a]},OZ=function(t){var s=t.scrollLeft,n=t.scrollWidth,a=t.clientWidth;return[s,n,a]},GR=function(t,s){return t==="v"?$Z(s):zZ(s)},VR=function(t,s){return t==="v"?LZ(s):OZ(s)},MZ=function(t,s){return t==="h"&&s==="rtl"?-1:1},BZ=function(t,s,n,a,r){var i=MZ(t,window.getComputedStyle(s).direction),o=i*a,l=n.target,c=s.contains(l),u=!1,p=o>0,m=0,x=0;do{if(!l)break;var h=VR(t,l),y=h[0],v=h[1],g=h[2],N=v-g-i*y;(y||N)&&GR(t,l)&&(m+=N,x+=y);var b=l.parentNode;l=b&&b.nodeType===Node.DOCUMENT_FRAGMENT_NODE?b.host:b}while(!c&&l!==document.body||c&&(s.contains(l)||s===l));return(p&&Math.abs(m)<1||!p&&Math.abs(x)<1)&&(u=!0),u},qf=function(t){return"changedTouches"in t?[t.changedTouches[0].clientX,t.changedTouches[0].clientY]:[0,0]},k3=function(t){return[t.deltaX,t.deltaY]},S3=function(t){return t&&"current"in t?t.current:t},UZ=function(t,s){return t[0]===s[0]&&t[1]===s[1]},qZ=function(t){return` 1187 .block-interactivity-`.concat(t,` {pointer-events: none;} 1188 .allow-interactivity-`).concat(t,` {pointer-events: all;} 1189`)},WZ=0,Jd=[];function HZ(t){var s=d.useRef([]),n=d.useRef([0,0]),a=d.useRef(),r=d.useState(WZ++)[0],i=d.useState(WR)[0],o=d.useRef(t);d.useEffect(function(){o.current=t},[t]),d.useEffect(function(){if(t.inert){document.body.classList.add("block-interactivity-".concat(r));var v=eH([t.lockRef.current],(t.shards||[]).map(S3),!0).filter(Boolean);return v.forEach(function(g){return g.classList.add("allow-interactivity-".concat(r))}),function(){document.body.classList.remove("block-interactivity-".concat(r)),v.forEach(function(g){return g.classList.remove("allow-interactivity-".concat(r))})}}},[t.inert,t.lockRef.current,t.shards]);var l=d.useCallback(function(v,g){if("touches"in v&&v.touches.length===2||v.type==="wheel"&&v.ctrlKey)return!o.current.allowPinchZoom;var N=qf(v),b=n.current,f="deltaX"in v?v.deltaX:b[0]-N[0],j="deltaY"in v?v.deltaY:b[1]-N[1],S,w=v.target,_=Math.abs(f)>Math.abs(j)?"h":"v";if("touches"in v&&_==="h"&&w.type==="range")return!1;var C=window.getSelection(),E=C&&C.anchorNode,P=E?E===w||E.contains(w):!1;if(P)return!1;var F=_3(_,w);if(!F)return!0;if(F?S=_:(S=_==="v"?"h":"v",F=_3(_,w)),!F)return!1;if(!a.current&&"changedTouches"in v&&(f||j)&&(a.current=S),!S)return!0;var I=a.current||S;return BZ(I,g,v,I==="h"?f:j)},[]),c=d.useCallback(function(v){var g=v;if(!(!Jd.length||Jd[Jd.length-1]!==i)){var N="deltaY"in g?k3(g):qf(g),b=s.current.filter(function(S){return S.name===g.type&&(S.target===g.target||g.target===S.shadowParent)&&UZ(S.delta,N)})[0];if(b&&b.should){g.cancelable&&g.preventDefault();return}
vendor: 6,794 bytes, line 1189
1189if(!b){var f=(o.current.shards||[]).map(S3).filter(Boolean).filter(function(S){return S.contains(g.target)}),j=f.length>0?l(g,f[0]):!o.current.noIsolation;j&&g.cancelable&&g.preventDefault()}}},[]),u=d.useCallback(function(v,g,N,b){var f={name:v,delta:g,target:N,should:b,shadowParent:GZ(N)};s.current.push(f),setTimeout(function(){s.current=s.current.filter(function(j){return j!==f})},1)},[]),p=d.useCallback(function(v){n.current=qf(v),a.current=void 0},[]),m=d.useCallback(function(v){u(v.type,k3(v),v.target,l(v,t.lockRef.current))},[]),x=d.useCallback(function(v){u(v.type,qf(v),v.target,l(v,t.lockRef.current))},[]);d.useEffect(function(){return Jd.push(i),t.setCallbacks({onScrollCapture:m,onWheelCapture:m,onTouchMoveCapture:x}),document.addEventListener("wheel",c,Qd),document.addEventListener("touchmove",c,Qd),document.addEventListener("touchstart",p,Qd),function(){Jd=Jd.filter(function(v){return v!==i}),document.removeEventListener("wheel",c,Qd),document.removeEventListener("touchmove",c,Qd),document.removeEventListener("touchstart",p,Qd)}},[]);var h=t.removeScrollBar,y=t.inert;return d.createElement(d.Fragment,null,y?d.createElement(i,{styles:qZ(r)}):null,h?d.createElement(RZ,{noRelative:t.noRelative,gapMode:t.gapMode}):null)}function GZ(t){for(var s=null;t!==null;)t instanceof ShadowRoot&&(s=t.host,t=t.host),t=t.parentNode;return s}const VZ=jZ(qR,HZ);var w5=d.forwardRef(function(t,s){return d.createElement(e1,Ci({},t,{ref:s,sideCar:VZ}))});w5.classNames=e1.classNames;var ZZ=function(t){if(typeof document>"u")return null;var s=Array.isArray(t)?t[0]:t;return s.ownerDocument.body},Xd=new WeakMap,Wf=new WeakMap,Hf={},bv=0,ZR=function(t){return t&&(t.host||ZR(t.parentNode))},YZ=function(t,s){return s.map(function(n){if(t.contains(n))return n;var a=ZR(n);return a&&t.contains(a)?a:(console.error("aria-hidden",n,"in not contained inside",t,". Doing nothing"),null)}).filter(function(n){return!!n})},KZ=function(t,s,n,a){var r=YZ(s,Array.isArray(t)?t:[t]);Hf[n]||(Hf[n]=new WeakMap);var i=Hf[n],o=[],l=new Set,c=new Set(r),u=function(m){!m||l.has(m)||(l.add(m),u(m.parentNode))};r.forEach(u);var p=function(m){!m||c.has(m)||Array.prototype.forEach.call(m.children,function(x){if(l.has(x))p(x);else try{var h=x.getAttribute(a),y=h!==null&&h!=="false",v=(Xd.get(x)||0)+1,g=(i.get(x)||0)+1;Xd.set(x,v),i.set(x,g),o.push(x),v===1&&y&&Wf.set(x,!0),g===1&&x.setAttribute(n,"true"),y||x.setAttribute(a,"true")}catch(N){console.error("aria-hidden: cannot operate on ",x,N)}})};return p(s),l.clear(),bv++,function(){o.forEach(function(m){var x=Xd.get(m)-1,h=i.get(m)-1;Xd.set(m,x),i.set(m,h),x||(Wf.has(m)||m.removeAttribute(a),Wf.delete(m)),h||m.removeAttribute(n)}),bv--,bv||(Xd=new WeakMap,Xd=new WeakMap,Wf=new WeakMap,Hf={})}},YR=function(t,s,n){n===void 0&&(n="data-aria-hidden");var a=Array.from(Array.isArray(t)?t:[t]),r=ZZ(t);return r?(a.push.apply(a,Array.from(r.querySelectorAll("[aria-live], script"))),KZ(a,r,n,"aria-hidden")):function(){return null}},QZ=Object.defineProperty,Ya=(t,s)=>QZ(t,"name",{value:s,configurable:!0}),N5="Dialog",[KR,QR]=Va(N5),[JZ,ri]=KR(N5),JR=Ya(t=>{const{__scopeDialog:s,children:n,open:a,defaultOpen:r,onOpenChange:i,modal:o=!0}=t,l=d.useRef(null),c=d.useRef(null),[u,p]=Po({prop:a,defaultProp:r??!1,onChange:i,caller:N5}),[m,x]=d.useState(0),[h,y]=d.useState(0);return e.jsx(JZ,{scope:s,triggerRef:l,contentRef:c,contentId:Bl(),titleId:Bl(),descriptionId:Bl(),titlePresent:m>0,descriptionPresent:h>0,setTitleCount:x,setDescriptionCount:y,open:u,onOpenChange:p,onOpenToggle:d.useCallback(()=>p(v=>!v),[p]),modal:o,children:n})},"Dialog"),XZ="DialogTrigger",eY=d.forwardRef(Ya(function(s,n){const{__scopeDialog:a,...r}=s,i=ri(XZ,a),o=It(n,i.triggerRef);return e.jsx(yt.button,{type:"button","aria-haspopup":"dialog","aria-expanded":i.open,"aria-controls":i.open?i.contentId:void 0,"data-state":t1(i.open),...r,ref:o,onClick:at(s.onClick,i.onOpenToggle)})},"DialogTrigger")),XR="DialogPortal",[tY,eI]=KR(XR,{forceMount:void 0}),tI=Ya(t=>{const{__scopeDialog:s,forceMount:n,children:a,container:r}=t,i=ri(XR,s);return e.jsx(tY,{scope:s,forceMount:n,children:d.Children.map(a,o=>e.jsx(ic,{present:n||i.open,children:e.jsx(q_,{asChild:!0,container:r,children:o})}))})},"DialogPortal"),M2="DialogOverlay",_5=d.forwardRef(Ya(function(s,n){const a=eI(M2,s.__scopeDialog),{forceMount:r=a.forceMount,...i}=s,o=ri(M2,s.__scopeDialog);return o.modal?e.jsx(ic,{present:r||o.open,children:e.jsx(nY,{...i,ref:n})}):null},"DialogOverlay")),sY=Fo("DialogOverlay.RemoveScroll"),nY=d.forwardRef(Ya(function(s,n){const{__scopeDialog:a,...r}=s,i=ri(M2,a),o=iP(),l=It(n,o);return e.jsx(w5,{as:sY,allowPinchZoom:!0,shards:[i.contentRef],children:e.jsx(yt.div,{"data-state":t1(i.open),...r,ref:l,style:{pointerEvents:"auto",...r.style}})})},"DialogOverlayImpl")),Ax="DialogContent",k5=d.forwardRef(Ya(function(s,n){const a=eI(Ax,s.__scopeDialog),{forceMount:r=a.forceMount,...i}=s,o=ri(Ax,s.__scopeDialog);return e.jsx(ic,{present:r||o.open,children:o.modal?e.jsx(aY,{...i,ref:n}):e.jsx(rY,{...i,ref:n})})},"DialogContent")),aY=d.forwardRef(Ya(function(s,n){const a=ri(Ax,s.__scopeDialog),r=d.useRef(null),i=It(n,a.contentRef,r);return d.useEffect(()=>{const o=r.current;if(o)return YR(o)},[]),e.jsx(sI,{...s,ref:i,trapFocus:a.open,disableOutsidePointerEvents:a.open,onCloseAutoFocus:at(s.onCloseAutoFocus,o=>{var l;o.preventDefault(),(l=a.triggerRef.current)==null||l.focus()}),onPointerDownOutside:at(s.onPointerDownOutside,o=>{const l=o.detail.originalEvent,c=l.button===0&&l.ctrlKey===!0;(l.button===2||c)&&o.preventDefault()}),onFocusOutside:at(s.onFocusOutside,o=>o.preventDefault())})},"DialogContentModal")),rY=d.forwardRef(Ya(function(s,n){const a=ri(Ax,s.__scopeDialog),r=d.useRef(!1),i=d.useRef(!1);return e.jsx(sI,{...s,ref:n,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:o=>{var l,c;(l=s.onCloseAutoFocus)==null||l.call(s,o),o.defaultPrevented||(r.current||(c=a.triggerRef.current)==null||c.focus(),o.preventDefault()),r.current=!1,i.current=!1},onInteractOutside:o=>{var u,p;(u=s.onInteractOutside)==null||u.call(s,o),o.defaultPrevented||(r.current=!0,o.detail.originalEvent.type==="pointerdown"&&(i.current=!0));const l=o.target;((p=a.triggerRef.current)==null?void 0:p.contains(l))&&o.preventDefault(),o.detail.originalEvent.type==="focusin"&&i.current&&o.preventDefault()}})},"DialogContentNonModal")),sI=d.forwardRef(Ya(function(s,n){const{__scopeDialog:a,trapFocus:r,onOpenAutoFocus:i,onCloseAutoFocus:o,...l}=s,c=ri(Ax,a);return Xb(),e.jsx(e.Fragment,{children:e.jsx(IR,{asChild:!0,loop:!0,trapped:r,onMountAutoFocus:i,onUnmountAutoFocus:o,children:e.jsx(Pb,{role:"dialog",id:c.contentId,"aria-describedby":c.descriptionPresent?c.descriptionId:void 0,"aria-labelledby":c.titlePresent?c.titleId:void 0,"data-state":t1(c.open
1189),...l,ref:n,deferPointerDownOutside:!0,onDismiss:()=>c.onOpenChange(!1)})})})},"DialogContentImpl")),iY="DialogTitle",S5=d.forwardRef(Ya(function(s,n){const{__scopeDialog:a,...r}=s,i=ri(iY,a),{setTitleCount:o}=i;return vs(()=>(o(l=>l+1),()=>o(l=>l-1)),[o]),e.jsx(yt.h2,{id:i.titleId,...r,ref:n})},"DialogTitle")),oY="DialogDescription",C5=d.forwardRef(Ya(function(s,n){const{__scopeDialog:a,...r}=s,i=ri(oY,a),{setDescriptionCount:o}=i;return vs(()=>(o(l=>l+1),()=>o(l=>l-1)),[o]),e.jsx(yt.p,{id:i.descriptionId,...r,ref:n})},"DialogDescription")),lY="DialogClose",A5=d.forwardRef(Ya(function(s,n){const{__scopeDialog:a,...r}=s,i=ri(lY,a);return e.jsx(yt.button,{type:"button",...r,ref:n,onClick:at(s.onClick,()=>i.onOpenChange(!1))})},"DialogClose"));function t1(t){return t?"open":"closed"}Ya(t1,"getState");const s1=JR,cY=tI,nI=d.forwardRef(({className:t,...s},n)=>e.jsx(_5,{ref:n,className:et("fixed inset-0 z-50 bg-background/80 backdrop-blur-sm data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",t),...s}));nI.displayName=_5.displayName;const af=d.forwardRef(({className:t,children:s,...n},a)=>e.jsxs(cY,{children:[e.jsx(nI,{}),e.jsxs(k5,{ref:a,className:et("fixed left-[50%] top-[50%] z-50 grid w-full max-w-lg translate-x-[-50%] translate-y-[-50%] gap-4 border border-border/40 bg-background p-6 shadow-lg duration-200 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[state=closed]:slide-out-to-left-1/2 data-[state=closed]:slide-out-to-top-[48%] data-[state=open]:slide-in-from-left-1/2 data-[state=open]:slide-in-from-top-[48%] sm:rounded-lg",t),...n,children:[s,e.jsxs(A5,{className:"absolute right-4 top-4 roun
1189ded-sm opacity-70 ring-offset-background transition-opacity hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none data-[state=open]:bg-accent data-[state=open]:text-muted-foreground",children:[e.jsx(Ke,{className:"h-4 w-4"}),e.jsx("span",{className:"sr-only",children:"Close"})]})]})]}));af.displayName=k5.displayName;const rf=({className:t,...s})=>e.jsx("div",{className:et("flex flex-col space-y-1.5 text-center sm:text-left",t),...s});rf.displayName="DialogHeader";const n1=({className:t,...s})=>e.jsx("div",{className:et("flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2",t),...s});n1.displayName="DialogFooter";const of=d.forwardRef(({className:t,...s},n)=>e.jsx(S5,{ref:n,className:et("text-lg font-semibold leading-none tracking-tight text-foreground",t),...s}));of.displayName=S5.displayName;const E5=d.forwardRef(({className:t,...s},n)=>e.jsx(C5,{ref:n,className:et("text-sm text-muted-foreground",t),...s}));E5.displayName=C5.displayName;const F5=Ib("inline-flex items-center justify-center whitespace-nowrap rounded-md text-sm font-medium ring-offset-background transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50",{variants:{variant:{default:"bg-primary text-primary-foreground hover:bg-primary/90",destructive:"bg-destructive text-destructive-foreground hover:bg-destructive/90",outline:"border border-input bg-background hover:bg-accent hover:text-accent-foreground",secondary:"bg-secondary text-secondary-foreground hover:bg-secondary/80",ghost:"hover:bg-accent hover:text-accent-foreground",link:"text-primary underline-offset-4 hover:underline"},size:{default:"h-10 px-4 py-2",sm:"h-9 rounded-md px-3",lg:"h-11 rounded-md px-8",icon:"h-10 w-10"}},defaultVariants:{variant:"default",size:"default"}}),gt=d.forwardRef(({className:t,variant:s,size:n,asChild:a=!1,...r},i)=>{const o=a?u9:"button";return e.jsx(o,{className:et(F5({variant:s,size:n,className:t})),ref:i,...r})});gt.displayName="Button";const dY=({open:t,secondsRemaining:s,onStaySignedIn:n,onSignOutNow:a})=>{const r=Math.max(0,Math.ceil(s)),i=Math.floor(r/60),o=r%60,l=`${i}:${o.toString().padStart(2,"0")}`;return e.jsx(s1,{open:t,onOpenChange:c=>{c||n()},children:e.jsxs(af,{className:"sm:max-w-md border-2",style:{background:"linear-gradient(180deg, #2a0810 0%, #3B0A11 100%)",borderColor:"#D4AF37",color:"#F4E4BC"},children:[e.jsxs(rf,{children:[e.jsxs("div",{className:"flex items-center gap-3 mb-2",children:[e.jsx("div",{className:"w-10 h-10 rounded-full flex items-center justify-center",style:{background:"linear-gradient(135deg, #D4AF37 0%, #E6D2A0 100%)"},children:e.jsx(dt,{className:"w-5 h-5",style:{color:"#3B0A11"}})}),e.jsx(of,{style:{color:"#E6D2A0"},className:"text-xl font-serif",children:"You're about to be signed out"})]}),e.jsxs(E5,{style:{color:"#F4E4BC"},className:"text-sm leading-relaxed",children:["For your security, this admin session will end automatically due to inactivity. Move your mouse, press a key, or choose ",e.jsx("em",{children:"Stay signed in"})," below to keep working."]})]}),e.jsxs("div",{className:"my-4 py-6 rounded-lg flex flex-col items-center justify-center",style:{background:"rgba(212, 175, 55, 0.08)",border:"1px solid rgba(212, 175, 55, 0.35)"},children:[e.jsx("div",{className:"text-xs uppercase tracking-widest mb-2",style:{color:"#E6D2A0"},children:"Auto sign-out in"}),e.jsx("div",{className:"text-5xl font-mono font-bold tabular-nums",style:{color:r<=10?"#ff6b6b":"#E6D2A0",textShadow:"0 0 12px rgba(212, 175, 55, 0.4)"},"aria-live":"polite","aria-atomic":"true",children:l})]}),e.jsxs(n1,{className:"gap-2 sm:gap-2 flex-col sm:flex-row",children:[e.jsxs(gt,{type:"button",onClick:a,variant:"outline",className:"flex-1 border-2 hover:opacity-90 transition-all",style:{borderColor:"#D4AF37",background:"transparent",color:"#E6D2A0"},children:[e.jsx(bo,{className:"w-4 h-4 mr-2"}),"Sign out now"]}),e.jsx(gt,{type:"button",onClick:n,className:"flex-1 border-0 font-semibold hover:opacity-90 transition-all",style:{background:"linear-gradient(135deg, #D4AF37 0%, #E6D2A0 100%)",color:"#3B0A11"}
1189,children:"Stay signed in"})]})]})})},Gf=15*60*1e3,vv=14*60*1e3,C3=["mousemove","keydown","touchstart"];async function Vf(t,s){try{const{data:n,error:a}=await O.functions.invoke("log-session-event",{body:{event_type:t,user_id:(s==null?void 0:s.id)||null,email:(s==null?void 0:s.email)||null,user_agent:typeof navigator<"u"?navigator.userAgent:null}});if(a){let r=null;const i=a==null?void 0:a.context;return i&&typeof i.json=="function"&&(r=await i.json().catch(()=>null)),((i==null?void 0:i.status)??(a==null?void 0:a.status))===403&&(r==null?void 0:r.error)==="IP_BANNED"?{ok:!1,banned:!0,reason:r.reason||"This IP address is not permitted to sign in.",ip:r.ip||null}:(console.error("log-session-event invoke failed:",t,a),{ok:!1,banned:!1})}return{ok:!0,banned:!1,ip:(n==null?void 0:n.ip)??null}}catch(n){return console.error("Failed to write session audit event:",t,n),{ok:!1,banned:!1}}}function uY(t){if(!(!t||!t.trim()))try{O.functions.invoke("record-failed-signin",{body:{email_attempted:t.trim(),user_agent:typeof navigator<"u"?navigator.userAgent:null}}).then(({error:s})=>{s&&console.error("record-failed-signin invoke failed:",s)}).catch(s=>{console.error("record-failed-signin threw:",s)})}catch(s){console.error("recordFailedSignin: synchronous error",s)}}const aI=d.createContext({user:null,loading:!0,signIn:async()=>({success:!1}),signUp:async()=>({success:!1}),signOut:async()=>{},updateProfile:async()=>({success:!1}),isAuthenticated:!1,hasRole:()=>!1,canWrite:!1,canAccessSection:()=>!0,isSuperAdmin:!1}),kn=()=>d.useContext(aI),mY={"super-admin":["*"],admin:["dashboard","lms","instructor-lms","audit","financial","agency","staff","google","pos","franchise"],instructor:["dashboard","lms","instructor-lms","staff","pos"],staff:["dashboard","lms","financial","agency","pos"]},np=({children:t})=>{var z;const[s,n]=d.useState(null),[a,r]=d.useState(!0),i=Za(),o=d.useRef(null),l=d.useRef(null),c=d.useRef(null),u=d.useRef(null),[p,m]=d.useState(!1),[x,h]=d.useState(Math.ceil((Gf-vv)/1e3)),y=d.useRef(null);d.useEffect(()=>{y.current=s},[s]);const v=d.useRef("MANUAL_SIGNOUT"),g=d.useRef(null),N=d.useCallback(async(M,R)=>{try{const{data:T,error:U}=await O.from("user_profiles").select("*").eq("auth_id",M).maybeSingle();return U?(console.error("Error fetching user profile:",U),null):T?{id:T.id,authId:T.auth_id,email:T.email,fullName:T.full_name,role:T.role,avatarUrl:T.avatar_url||void 0}:null}catch(T){return console.error("Error in fetchUserProfile:",T),null}},[]);d.useEffect(()=>{(async()=>{try{const{data:{session:T}}=await O.auth.getSession();if(T!=null&&T.user){const U=await N(T.user.id,T.user.email||"");U&&(n(U),g.current=Date.now())}}catch(T){console.error("Error initializing auth:",T)}finally{r(!1)}})();const{data:{subscription:R}}=O.auth.onAuthStateChange(async(T,U)=>{if(T==="SIGNED_IN"&&(U!=null&&U.user)){const q=await N(U.user.id,U.user.email||"");q&&(n(q),g.current=Date.now())}else T==="SIGNED_OUT"&&(n(null),g.current=null)});return()=>{R.unsubscribe()}},[N]);const b=d.useCallback(async(M,R)=>{try{const{data:T,error:U}=await O.auth.signInWithPassword({email:M,password:R});if(U)return uY(M),{success:!1,error:"Invalid email or password."};if(T.user){const q=await N(T.user.id,T.user.email||"");if(q){n(q),g.current=Date.now();const H=await Vf("SIGN_IN",{id:q.id,email:q.email});if(H.banned){n(null),g.current=null;try{await O.auth.signOut()}catch{}return{success:!1,error:H.reason||"Your IP address is not permitted to sign in."}}return{success:!0}}try{await O.auth.signOut()}catch{}return{success:!1,error:"User profile not found."}}return{success:!1,error:"Sign in failed."}}catch(T){return{success:!1,error:T.message||"An unexpected error occurred."}}},[N]),f=d.useCallback(async(M,R,T,U="staff")=>({success:!1,error:"Self-registration is disabled. Staff accounts are issued by an authorized administrator."}),[]),j=d.useCallback(async()=>{const M=y.current,R=v.current;v.current="MANUAL_SIGNOUT",M&&(Vf("SIGN_OUT",{id:M.id,email:M.email}),Vf(R,{id:M.id,email:M.email}));try{await O.auth.signOut()}catch(T){console.error("Error signing out:",T)}n(null),g.current=null},[]),S=d.useCallback(async M=>{if(!s)return{success:!1,error:"Not authenticated."};try{const R={};M.fullName!==void 0&&(R.full_name=M.fullName),M.avatarUrl!==void 0&&(R.avatar_url=M.avatarUrl),R.updated_at=new Date().toISOString();const{error:T}=await O.from("user_profiles").update(R).eq("id",s.id);return T?(console.error("Error updating profile:",T),{success:!1,error:"Failed to update profile."}):(n(U=>U?{...U,fullName:M.fullName??U.fullName,avatarUrl:M.avatarUrl??U.avatarUrl}:null),{success:!0})}catch(R){return{success:!1,error:R.message||"An unexpected error occurred."}}},[s]),w=s!==null,_=d.useCallback(()=>{o.current!==null&&(clearTimeout(o.current),o.current=null),l.current!==null&&(clearTimeout(l.current),l.current=null),c.current!==null&&(clearInterval(c.current),c.current=null)},[]),C=d.useCallback(async()=>{_(),u.current=null,m(!1),v.current="IDLE_AUTO_SIGNOUT";try{await j()}catch(M){console.error("Error during idle sign-out:",M)}try{Ct.error("Signed out for inactivity â please sign in again",{duration:6e3})}catch{}try{i("/admin-login",{replace:!0})}catch(M){console.error("Error navigating after idle sign-out:",M)}},[_,j,i]),E=d.useCallback(()=>{Vf("IDLE_WARNING_SHOWN",y.current),m(!0);const M=()=>{const R=u.current;if(R===null){h(0);return}const T=R-Date.now();h(Math.max(0,Math.ceil(T/1e3)))};M(),c.current!==null&&clearInterval(c.current),c.current=setInterval(M,1e3)},[]),P=d.useCallback(()=>{_(),m(!1),u.current=Date.now()+Gf,h(Math.ceil((Gf-vv)/1e3)),l.current=setTimeout(E,vv),o.current=setTimeout(C,Gf)},[_,E,C]);d.useEffect(()=>{if(!w){_(),u.current=null,m(!1);return}P();const M=()=>{p||P()};return C3.forEach(R=>{window.addEventListener(R,M,{passive:!0})}),()=>{_(),C3.forEach(R=>{window.removeEventListener(R,M)})}},[w,P,_]);const F=d.useCallback(()=>{P()},[P]),I=d.useCallback(()=>{C()},[C]),D=6e4;d.useEffect(()=>{if(!w||!s)return;let M=!1;const R=async()=>{const U=g.current,q=s.id;if(!(!U||!q))try{const{data:H,error:G}=await O.from("session_revocations").select("id, created_at, reason").eq("user_id",q).eq("active",!0).gt("created_at",new Date(U).toISOString()).order("created_at",{ascending:!1}).limit(1);if(M)return;if(G){console.error("Revocation check failed:",G);return}if(!H||H.length===0)return;g.current=null,v.current="FORCED_REVOCATION";try{await j()}catch(W){console.error("Error during forced-revocation sign-out:",W)}try{Ct.error("Your session was ended by an administrator. Please sign in again.",{duration:8e3})}catch{}try{i("/admin-login",{replace:!0})}catch(W){console.error("Error navigating after forced revocation:",W)}}catch(H){console.error("Revocation poll error:",H)}};R();const T=setInterval(R,D);return()=>{M=!0,clearInterval(T)}},[w,s,j,i]);const L=s!==null&&(s.role==="super-admin"||((z=s.email)==null?void 0:z.toLowerCase())==="[email protected]"),V=d.useCallback(M=>s?L?!0:M.includes(s.role):!1,[s,L]),B=s!==null,A=d.useCallback(M=>{if(!s||L)return!0;const R=mY[s.role]||[];return R.includes("*")?!0:R.includes(M)},[s,L]);return e.jsxs(aI.Provider,{value:{user:s,loading:a,signIn:b,signUp:f,signOut:j,updateProfile:S,isAuthenticated:w,hasRole:V,canWrite:B,canAccessSection:A,isSuperAdmin:L},children:[t,w&&e.jsx(dY,{open:p,secondsRemaining:x,onStaySignedIn:F,onSignOutNow:I})]})},B2="z_student_session_token",v0=t=>{try{t?localStorage.setItem(B2,t):localStorage.removeItem(B2)}catch{}},Bd=()=>{try{return localStorage.getItem(B2)}catch{return null}},Wu=()=>v0(null);async function A3(){const t=Bd();if(!t)return null;try{const{data:s,error:n}=await O.rpc("z_student_session_resolve",{p_token:t});return n||!(s!=null&&s.ok)?(Wu(),null):s.account}catch{return null}}async function pY(){const t=Bd();if(!t)return!1;try{const{data:s,error:n}=await O.rpc("z_student_session_touch",{p_token:t});return!n&&s===!0}catch{return!1}}async function hY(){const t=Bd();if(Wu(),!!t)try{await O.rpc("z_student_session_end",{p_token:t})}catch{}}const rI=10*1024*1024,iI=["application/pdf","image/jpeg","image/jpg","image/png","image/webp","image/heic"],a1="secure-document-access";async function xY(t){return new Promise((s,n)=>{const a=new FileReader;a.onload=()=>s(String(a.result||"")),a.onerror=()=>n(new Error("Could not read the selected file.")),a.readAsDataURL(t)})}async function oI(){const t=Bd();if(!t)return[];const{data:s,error:n}=await O.functions.invoke(a1,{body:{action:"student-docs",studentToken:t}});return n||!(s!=null&&s.success)?[]:s.documents||[]}async function lI(t,s){const n=Bd();if(!n)return{success:!1,error:"Session expired. Please sign in again."};if(t.size>rI)return{success:!1,error:"File must be under 10MB."};if(!iI.includes(t.type))return{success:!1,error:"Allowed formats: PDF, JPG, PNG, WebP, HEIC."};try{const a=await xY(t),{data:r,error:i}=await O.functions.invoke(a1,{body:{action:"student-upload",studentToken:n,documentType:s,fileName:t.name,mimeType:t.type,fileBase64:a}});return i?{success:!1,error:"Upload failed. Please try again."}:r!=null&&r.success?{success:!0}:{success:!1,error:(r==null?void 0:r.error)||"Upload failed."}}catch(a){return{success:!1,error:a.message||"Upload failed."}}}async function cI(t){const s=Bd();if(!s)return null;const{data:n,error:a}=await O.functions.invoke(a1,{body:{action:"student-doc-url",studentToken:s,documentId:t}});return a||!(n!=null&&n.success)?null:n.url||null}async function fY(t){const{data:s,error:n}=await O.functions.invoke(a1,{body:{action:"staff-doc-url",documentId:t}});return n||!(s!=null&&s.success)?null:s.url||null}const Ihe=Object.freeze(Object.defineProperty({__proto__:null,SECURE_DOC_ALLOWED_MIME:iI,SECURE_DOC_MAX_BYTES:rI,fetchOwnStudentDocuments:oI,getOwnStudentDocumentUrl:cI,getStaffStudentDocumentUrl:fY,uploadOwnStudentDocument:lI},Symbol.toStringTag,{value:"Module"})),dI=d.createContext({student:null,loading:!0,isStudentAuthenticated:!1,studentLogin:async()=>({success:!1}),studentLogout:()=>{},studentRegister:async()=>({success:!1}),updateStudentProfile:async()=>!1,changePassword:async()=>({success:!1}),fetchLoginHistory:async()=>[],uploadAvatar:async()=>({success:!1}
1189),twoFactorState:{isEnabled:!1,method:"email",pendingVerification:!1},send2FACode:async()=>({success:!1}),verify2FACode:async()=>({success:!1}),enable2FA:async()=>({success:!1}),disable2FA:async()=>({success:!1}),documents:[],documentsLoading:!1,fetchDocuments:async()=>{},uploadDocument:async()=>({success:!1}),getDocumentUrl:async()=>null,deleteDocument:async()=>({success:!1}),isPhotoIdVerified:!1,isProofOfEducationVerified:!1,pending2FALogin:null,complete2FALogin:async()=>({success:!1})}),ap=()=>d.useContext(dI),xc="z_student_session",U2="z_student_last_id",j0=t=>{try{t?localStorage.setItem(U2,t):localStorage.removeItem(U2)}catch{}},$he=()=>{try{return localStorage.getItem(U2)}catch{return null}},zhe=()=>j0(null);function Zf(t){return{id:t.id,studentId:t.student_id,fullName:t.full_name,email:t.email||null,phone:t.phone||null,program:t.program||"esthetics",enrollmentStatus:t.enrollment_status||"active",enrollmentDate:t.enrollment_date||null,avatarUrl:t.avatar_url||null,lastLoginAt:t.last_login_at||null,createdAt:t.created_at||null}}async function fc(t,s,n,a){try{const r=typeof navigator<"u"?navigator.userAgent:null;await O.from("z_student_login_history").insert({student_account_id:t,student_id:s,status:n,user_agent:r,failure_reason:a||null})}catch(r){console.error("Failed to log login event:",r)}}function E3(){return String(Math.floor(1e5+Math.random()*9e5))}const uI=({children:t})=>{const[s,n]=d.useState(null),[a,r]=d.useState(!0),[i,o]=d.useState({isEnabled:!1,method:"email",pendingVerification:!1}),[l,c]=d.useState([]),[u,p]=d.useState(!1),[m,x]=d.useState(null),h=d.useRef(null);d.useEffect(()=>{(async()=>{try{const z=await A3();z?n(Zf(z)):(Wu(),localStorage.removeItem(xc))}catch(z){console.error("Error restoring student session:",z),Wu(),localStorage.removeItem(xc)}finally{r(!1)}})()},[]),d.useEffect(()=>{if(!s)return;let A=!1;const z=async()=>{if(A)return;!await pY()&&!A&&(Wu(),localStorage.removeItem(xc),n(null))},M=window.setInterval(z,5*60*1e3),R=()=>{z()};return window.addEventListener("focus",R),()=>{A=!0,window.clearInterval(M),window.removeEventListener("focus",R)}},[s==null?void 0:s.id]),d.useEffect(()=>{if(!s){o({isEnabled:!1,method:"email",pendingVerification:!1});return}(async()=>{const{data:z}=await O.from("z_student_2fa").select("*").eq("student_id",s.studentId).maybeSingle();z&&o({isEnabled:z.is_enabled||!1,method:z.method||"email",pendingVerification:!1})})()},[s==null?void 0:s.studentId]),d.useEffect(()=>{s?y():c([])},[s==null?void 0:s.studentId]);const y=d.useCallback(async()=>{if(s){p(!0);try{const A=await oI();c(A)}catch(A){console.error("Failed to fetch documents:",A)}finally{p(!1)}}},[s==null?void 0:s.studentId]),v=d.useCallback(async(A,z)=>{try{const M=A.trim().toUpperCase(),{data:R,error:T}=await O.rpc("z_student_verify_login",{p_student_id:M,p_password:z});if(T||!R)return console.error("Login verification error:",T),{success:!1,error:"An unexpected error occurred. Please try again."};if(!R.ok){if(R.reason==="rate_limited"){const X=Math.max(1,Math.ceil((R.retry_after_seconds||900)/60));return await fc(null,M,"failed","Rate limited â temporary lockout"),{success:!1,error:`Too many failed sign-in attempts. For your security, this account is temporarily locked. Please wait ${X} minute${X===1?"":"s"} and try again, or use "Forgot password?" to reset your password.`}}const G=typeof R.remaining=="number"?R.remaining:null,W=G!==null&&G<=2?` ${G} attempt${G===1?"":"s"} remaining before a temporary lockout.`:"";return R.reason==="not_found"?(await fc(null,M,"failed","Student ID not found"),{success:!1,error:`Student ID not found. Please check your Z-Student ID and try again.${W}`}):(await fc(null,M,"failed","Incorrect password"),{success:!1,error:`Incorrect password. Please try again.${W}`})}const U=R.account;if(U.enrollment_status==="suspended")return await fc(U.id,M,"failed","Account suspended"),{success:!1,error:"Your account has been suspended. Please contact administration."};const{data:q}=await O.from("z_student_2fa").select("*").eq("student_id",U.student_id).eq("is_enabled",!0).maybeSingle();if(q){const G=E3(),W=new Date(Date.now()+10*60*1e3).toISOString();return await O.from("z_student_2fa").update({verification_code:G,code_expires_at:W,code_sent_at:new Date().toISOString(),attempts:0,updated_at:new Date().toISOString()}).eq("id",q.id),U.email&&await O.functions.invoke("send-student-2fa",{body:{email:U.email,studentName:U.full_name,studentId:U.student_id,code:G}}),h.current=R.session_token||null,x({studentId:U.student_id,accountId:U.id}),{success:!1,requires2FA:!0}}const H=Zf(U);return v0(R.session_token||null),n(H),localStorage.setItem(xc,JSON.stringify({studentId:U.student_id})),j0(U.student_id),await fc(U.id,U.student_id,"success"),O.functions.invoke("student-security-alert",{body:{event:"new_login",accountId:U.id,userAgent:typeof navigator<"u"?navigator.userAgent:""}}).catch(()=>{}),{success:!0}}catch(M){return console.error("Student login error:",M),{success:!1,error:"An unexpected error occurred. Please try again."}}},[]),g=d.useCallback(async A=>
1189{if(!m)return{success:!1,error:"No pending 2FA login."};try{const{data:z}=await O.from("z_student_2fa").select("*").eq("student_id",m.studentId).eq("is_enabled",!0).maybeSingle();if(!z)return{success:!1,error:"2FA record not found."};if((z.attempts||0)>=(z.max_attempts||5))return{success:!1,error:"Too many attempts. Please request a new code."};if(await O.from("z_student_2fa").update({attempts:(z.attempts||0)+1,updated_at:new Date().toISOString()}).eq("id",z.id),z.code_expires_at&&new Date(z.code_expires_at)<new Date)return{success:!1,error:"Verification code has expired. Please request a new one."};if(z.verification_code!==A.trim())return{success:!1,error:"Invalid verification code. Please try again."};await O.from("z_student_2fa").update({verified_at:new Date().toISOString(),verification_code:null,updated_at:new Date().toISOString()}).eq("id",z.id);const M=h.current;if(!M)return{success:!1,error:"Session expired. Please sign in again."};v0(M),h.current=null;const R=await A3();if(!R)return Wu(),{success:!1,error:"Session expired. Please sign in again."};const T=Zf(R);return n(T),localStorage.setItem(xc,JSON.stringify({studentId:R.student_id})),j0(R.student_id),await fc(R.id,R.student_id,"success"),x(null),O.functions.invoke("student-security-alert",{body:{event:"new_login",accountId:R.id,userAgent:typeof navigator<"u"?navigator.userAgent:""}}).catch(()=>{}),{success:!0}}catch(z){return{success:!1,error:z.message||"Verification failed."}}},[m]),N=d.useCallback(()=>{n(null),x(null),h.current=null,localStorage.removeItem(xc),hY().catch(()=>{})},[]),b=d.useCallback(async A=>{try{const z=A.studentId.trim().toUpperCase();if(!A.password||A.password.length<6)return{success:!1,error:"Password must be at least 6 characters."};const{data:M,error:R}=await O.rpc("z_student_register",{p_student_id:z,p_password:A.password,p_full_name:A.fullName,p_email:A.email||null,p_program:A.program||"esthetics"});if(R||!M)return console.error("Student registration error:",R),{success:!1,error:"Failed to create account. Please try again."};if(!M.ok)return M.reason==="exists"?{success:!1,error:"This Z-Student ID is already registered. Please sign in instead."}:M.reason==="too_short"?{success:!1,error:"Password must be at least 6 characters."}:{success:!1,error:"Failed to create account. Please try again."};const T=M.account,{data:U}=await O.rpc("z_student_verify_login",{p_student_id:z,p_password:A.password});U!=null&&U.ok&&U.session_token&&v0(U.session_token);const q=Zf(T);return n(q),localStorage.setItem(xc,JSON.stringify({studentId:T.student_id})),j0(T.student_id),await fc(T.id,T.student_id,"success"),{success:!0}}catch(z){return{success:!1,error:z.message||"An unexpected error occurred."}}},[]),f=d.useCallback(async A=>{if(!s)return!1;const z=Bd();if(!z)return!1;const{data:M,error:R}=await O.rpc("z_student_self_update",{p_token:z,p_full_name:A.fullName??null,p_email:A.email??null,p_phone:A.phone??null,p_avatar_url:A.avatarUrl??null});return R||!(M!=null&&M.ok)?!1:(n(T=>T?{...T,...A}:null),!0)},[s]),j=d.useCallback(async(A,z)=>{if(!s)return{success:!1,error:"Not authenticated."};try{const{data:M,error:R}=await O.rpc("z_student_change_password",{p_account_id:s.id,p_current:A,p_new:z});return R||!M?{success:!1,error:"Failed to update password."}:M.ok?(O.functions.invoke("student-security-alert",{body:{event:"password_changed",accountId:s.id}}).catch(()=>{}),{success:!0}):M.reason==="bad_current"?{success:!1,error:"Current password is incorrect."}:M.reason==="too_short"?{success:!1,error:"New password must be at least 6 characters."}:{success:!1,error:"Failed to update password."}}catch(M){return{success:!1,error:M.message||"An unexpected error occurred."}}},[s]),S=d.useCallback(async(A=20)=>{if(!s)return[];try{const{data:z,error:M}=await O.from("z_student_login_history").select("*").eq("student_id",s.studentId).order("login_at",{ascending:!1}).limit(A);return M||!z?[]:z}catch{return[]}},[s]),w=d.useCallback(async A=>{var z;if(!s)return{success:!1,error:"Not authenticated."};try{const M=((z=A.name.split(".").pop())==null?void 0:z.toLowerCase())||"jpg",R=`${s.studentId.replace(/[^a-zA-Z0-9]/g,"-")}-${Date.now()}.${M}`,{error:T}=await O.storage.from("student-avatars").upload(R,A,{upsert:!0,contentType:A.type});if(T)return console.error("Upload error:",T),{success:!1,error:"Failed to upload avatar image."};const{data:U}=O.storage.from("student-avatars").getPublicUrl(R),q=U==null?void 0:U.publicUrl;return q?await f({avatarUrl:q})?{success:!0,url:q}:{success:!1,error:"Failed to save avatar to profile."}:{success:!1,error:"Failed to get avatar URL."}}catch(M){return{success:!1,error:M.message||"Upload failed."}}},[s,f]),_=d.useCallback(async()=>
1189{if(!s)return{success:!1,error:"Not authenticated."};if(!s.email)return{success:!1,error:"No email address on file. Please add an email first."};try{const A=E3(),z=new Date(Date.now()+10*60*1e3).toISOString();await O.from("z_student_2fa").upsert({student_account_id:s.id,student_id:s.studentId,verification_code:A,code_expires_at:z,code_sent_at:new Date().toISOString(),attempts:0,updated_at:new Date().toISOString()},{onConflict:"student_id"});const{error:M}=await O.functions.invoke("send-student-2fa",{body:{email:s.email,studentName:s.fullName,studentId:s.studentId,code:A}});return M?{success:!1,error:"Failed to send verification code."}:(o(R=>({...R,pendingVerification:!0})),{success:!0})}catch(A){return{success:!1,error:A.message||"Failed to send code."}}},[s]),C=d.useCallback(async A=>{if(!s)return{success:!1,error:"Not authenticated."};try{const{data:z}=await O.from("z_student_2fa").select("*").eq("student_id",s.studentId).maybeSingle();return z?(z.attempts||0)>=(z.max_attempts||5)?{success:!1,error:"Too many attempts. Please request a new code."}:(await O.from("z_student_2fa").update({attempts:(z.attempts||0)+1}).eq("id",z.id),z.code_expires_at&&new Date(z.code_expires_at)<new Date?{success:!1,error:"Code expired. Please request a new one."}:z.verification_code!==A.trim()?{success:!1,error:"Invalid code. Please try again."}:(await O.from("z_student_2fa").update({verified_at:new Date().toISOString(),verification_code:null}).eq("id",z.id),o(M=>({...M,pendingVerification:!1})),{success:!0})):{success:!1,error:"2FA not set up."}}catch(z){return{success:!1,error:z.message||"Verification failed."}}},[s]),E=d.useCallback(async(A="email")=>{if(!s)return{success:!1,error:"Not authenticated."};if(!s.email&&A==="email")return{success:!1,error:"Please add an email address first."};try{const{data:z}=await O.from("z_student_2fa").select("id").eq("student_id",s.studentId).maybeSingle();return z?await O.from("z_student_2fa").update({is_enabled:!0,method:A,updated_at:new Date().toISOString()}).eq("id",z.id):await O.from("z_student_2fa").insert({student_account_id:s.id,student_id:s.studentId,is_enabled:!0,method:A}),o({isEnabled:!0,method:A,pendingVerification:!1}),{success:!0}}catch(z){return{success:!1,error:z.message||"Failed to enable 2FA."}}},[s]),P=d.useCallback(async()=>{if(!s)return{success:!1,error:"Not authenticated."};try{return await O.from("z_student_2fa").update({is_enabled:!1,updated_at:new Date().toISOString()}).eq("student_id",s.studentId),o(A=>({...A,isEnabled:!1})),{success:!0}}catch(A){return{success:!1,error:A.message||"Failed to disable 2FA."}}},[s]),F=d.useCallback(async(A,z)=>{if(!s)return{success:!1,error:"Not authenticated."};const M=await lI(A,z);return M.success?(await y(),{success:!0}):M},[s,y]),I=d.useCallback(async A=>s?cI(A):null,[s]),D=d.useCallback(async A=>{if(!s)return{success:!1,error:"Not authenticated."};try{const z=l.find(M=>M.id===A);return z?z.status==="approved"?{success:!1,error:"Cannot delete approved documents."}:(await O.from("z_student_documents").delete().eq("id",A),c(M=>M.filter(R=>R.id!==A)),{success:!0}):{success:!1,error:"Document not found."}}catch(z){return{success:!1,error:z.message||"Delete failed."}}},[s,l]),L=s!==null,V=l.some(A=>A.document_type==="photo_id"&&A.status==="approved"),B=l.some(A=>A.document_type==="proof_of_education"&&A.status==="approved");return e.jsx(dI.Provider,{value:{student:s,loading:a,isStudentAuthenticated:L,studentLogin:v,studentLogout:N,studentRegister:b,updateStudentProfile:f,changePassword:j,fetchLoginHistory:S,uploadAvatar:w,twoFactorState:i,send2FACode:_,verify2FACode:C,enable2FA:E,disable2FA:P,documents:l,documentsLoading:u,fetchDocuments:y,uploadDocument:F,getDocumentUrl:I,deleteDocument:D,isPhotoIdVerified:V,isProofOfEducationVerified:B,pending2FALogin:m,complete2FALogin:g},children:t})},mI=d.createContext({notifications:[],unreadCount:0,loading:!1,fetchNotifications:async()=>{},markAsRead:async()=>{},markAllAsRead:async()=>{},deleteNotification:async()=>{},clearAll:async()=>{},triggerScan:async()=>({success:!1}),lastScanAt:null}),pI=()=>d.useContext(mI);async function gY(t,s){try{const{count:n}=await O.from("z_student_notifications").select("*",{count:"exact",head:!0}).eq("student_id",s);if(n&&n>0)return;const a=new Date,r=[{student_account_id:t,student_id:s,type:"grade_posted",title:"New Grade Posted",message:"Your Chapter 3: Skin Analysis quiz has been graded. You scored 92%!",icon:"award",priority:"normal",action_section:"student-progress",action_data:{chapter:3,score:92},is_read:!1,source_engine:"auto-student-alerts",trigger_type:"grade_entered",created_at:new Date(a.getTime()-30*6e4).toISOString()},{student_account_id:t,student_id:s,type:"quiz_deadline",title:"Assignment Due Tomorrow",message:"Chapter 5: Facial Treatments assignment is due tomorrow at 11:59 PM. Don't forget to complete it!",icon:"clock",priority:"high",action_section:"student-progress",action_data:{chapter:5,deadline:new Date(a.getTime()+24*36e5).toISOString()},is_read:!1,source_engine:"auto-student-alerts",trigger_type:"assignment_posted",created_at:new Date(a.getTime()-2*36e5).toISOString()},{student_account_id:t,student_id:s,type:"attendance_warning",title:"Attendance Alert: 82.5%",message:"Your attendance rate has dropped to 82.5%, below the 85% monitoring threshold. NACCAS requires minimum 80% for SAP compliance. Please attend all scheduled classes.",icon:"alert-triangle",priority:"urgent",action_section:"student-progress",action_data:{attendance_rate:82.5,threshold:85},is_read:!1,source_engine:"auto-student-alerts",trigger_type:"attendance_warning",created_at:new Date(a.getTime()-5*36e5).toISOString()},{student_account_id:t,student_id:s,type:"system",title:"SAP 25% Checkpoint â 42h Away",message:"You are 42 hours away from your 25% SAP checkpoint (300h). At this checkpoint, your GPA and attendance will be reviewed for NACCAS compliance.",icon:"shield",priority:"high",action_section:"student-progress",action_data:{checkpoint_pct:25,target_hours:300,hours_until:42},is_read:!1,source_engine:"auto-student-alerts",trigger_type:"sap_checkpoint_25",created_at:new Date(a.getTime()-8*36e5).toISOString()},{student_account_id:t,student_id:s,type:"announcement",title:"New Message from Instructor Chen",message:`New message from Instructor Chen: "Great progress on your facial technique assessment. Let's schedule a review session..."`,icon:"message-square",priority:"normal",action_section:"student-progress",action_data:{},is_read:!1,source_engine:"auto-student-alerts",trigger_type:"new_message",created_at:new Date(a.getTime()-12*36e5).toISOString()},{student_account_id:t,student_id:s,type:"system",title:"Ticket Update: Wi-Fi Connectivity",message:'Your help desk ticket "Wi-Fi Connectivity Issue" has been updated to: In Progress. A staff member is working on your request.',icon:"ticket",priority:"low",action_section:"student-progress",action_data:{},is_read:!1,source_engine:"auto-student-alerts",trigger_type:"ticket_updated",created_at:new Date(a.getTime()-18*36e5).toISOString()},{student_account_id:t,student_id:s,type:"quiz_deadline",title:"Reminder: State Board Prep Workshop",message:'Upcoming workshop: "State Board Prep Workshop" on Friday at 2:00 PM in Room 204. Starting in 22 hours.',icon:"calendar",priority:"normal",action_section:"student-progress",action_data:{},is_read:!1,source_engine:"auto-student-alerts",trigger_type:"calendar_reminder",created_at:new Date(a.getTime()-20*36e5).toISOString()},{student_account_id:t,student_id:s,type:"milestone",title:"Milestone Reached: 250 Hours!",message:"Congratulations! You've completed 250 hours of training. Keep up the excellent work on your journey!",icon:"trophy",priority:"normal",action_section:"student-progress",action_data:{hours_completed:250,hours_required:750},is_read:!1,source_engine:"auto-student-alerts",trigger_type:"milestone_250",created_at:new Date(a.getTime()-24*36e5).toISOString()},{student_account_id:t,student_id:s,type:"announcement",title:"Campus Closure Notice",message:"The campus will be closed on April 12th for scheduled maintenance. All classes will resume on April 13th.",icon:"megaphone",priority:"normal",action_section:null,action_data:{},is_read:!1,source_engine:"manual",trigger_type:"announcement",created_at:new Date(a.getTime()-48*36e5).toISOString()},{student_account_id:t,student_id:s,type:"grade_posted",title:"Grade Updated: Intro to Esthetics",message:"Your Chapter 1: Introduction to Esthetics quiz grade has been updated to 88%.",icon:"award",priority:"normal",action_section:"student-progress",action_data:{chapter:1,score:88},is_read:!0,read_at:new Date(a.getTime()-72*36e5).toISOString(),source_engine:"auto-student-alerts",trigger_type:"grade_entered",created_at:new Date(a.getTime()-96*36e5).toISOString()},{student_account_id:t,student_id:s,type:"system",title:"Welcome to Zorganics Institute",message:"Your student account has been set up. Explore the LMS, track your progress, and stay on top of your coursework!",icon:"sparkles",priority:"low",action_section:"student-progress",action_data:{},is_read:!0,read_at:new Date(a.getTime()-120*36e5).toISOString(),source_engine:"manual",trigger_type:"system",created_at:new Date(a.getTime()-168*36e5).toISOString()}];await O.from("z_student_notifications").insert(r)}catch(n){console.error("Failed to seed demo notifications:",n)}}const hI=({children:t})=>{const{student:s,isStudentAuthenticated:n}
1189=ap(),[a,r]=d.useState([]),[i,o]=d.useState(!1),[l,c]=d.useState(null),u=d.useRef(null),p=d.useRef(null),m=d.useCallback(async()=>{if(!s){r([]);return}o(!0);try{const{data:b,error:f}=await O.from("z_student_notifications").select("*").eq("student_id",s.studentId).order("created_at",{ascending:!1}).limit(100);!f&&b&&r(b)}catch(b){console.error("Error fetching student notifications:",b)}finally{o(!1)}},[s]),x=d.useCallback(async()=>{if(!s)return{success:!1};try{const{data:b,error:f}=await O.functions.invoke("auto-student-alerts",{body:{action:"single-student",student_id:s.studentId}});return f?(console.error("Scan trigger error:",f),{success:!1}):(c(new Date().toISOString()),await m(),{success:!0,notificationsCreated:(b==null?void 0:b.notificationsCreated)||0})}catch(b){return console.error("Scan trigger failed:",b),{success:!1}}},[s,m]);d.useEffect(()=>{n&&s?u.current!==s.studentId?(u.current=s.studentId,gY(s.id,s.studentId).then(()=>{m(),x().catch(()=>{})})):m():(r([]),u.current=null)},[n,s,m,x]),d.useEffect(()=>{if(!n||!s){p.current&&(O.removeChannel(p.current),p.current=null);return}const b=O.channel(`student-notifications-${s.studentId}`).on("postgres_changes",{event:"INSERT",schema:"public",table:"z_student_notifications",filter:`student_id=eq.${s.studentId}`},f=>{f.new&&r(j=>[f.new,...j])}).on("postgres_changes",{event:"UPDATE",schema:"public",table:"z_student_notifications",filter:`student_id=eq.${s.studentId}`},f=>{f.new&&r(j=>j.map(S=>S.id===f.new.id?f.new:S))}).subscribe();return p.current=b,()=>{O.removeChannel(b),p.current=null}},[n,s==null?void 0:s.studentId]),d.useEffect(()=>{if(!n)return;const b=setInterval(m,3e4);return()=>clearInterval(b)},[n,m]);const h=d.useCallback(async b=>{const f=new Date().toISOString();await O.from("z_student_notifications").update({is_read:!0,read_at:f}).eq("id",b),r(j=>j.map(S=>S.id===b?{...S,is_read:!0,read_at:f}:S))},[]),y=d.useCallback(async()=>{if(!s)return;const b=new Date().toISOString();await O.from("z_student_notifications").update({is_read:!0,read_at:b}).eq("student_id",s.studentId).eq("is_read",!1),r(f=>f.map(j=>j.is_read?j:{...j,is_read:!0,read_at:b}))},[s]),v=d.useCallback(async b=>{await O.from("z_student_notifications").delete().eq("id",b),r(f=>f.filter(j=>j.id!==b))},[]),g=d.useCallback(async()=>{s&&(await O.from("z_student_notifications").delete().eq("student_id",s.studentId),r([]))},[s]),N=a.filter(b=>!b.is_read).length;return e.jsx(mI.Provider,{value:{notifications:a,unreadCount:N,loading:i,fetchNotifications:m,markAsRead:h,markAllAsRead:y,deleteNotification:v,clearAll:g,triggerScan:x,lastScanAt:l},children:t})},gc="global-search-results",yY={supported:!1,placeholder:"Use the filters inside this dashboard",scopeLabel:"this dashboard"},bY={dashboard:{supported:!0,placeholder:"Search students, programs, documentsâ¦",anchorId:gc,scopeLabel:"Program Dashboard"},shop:{supported:!0,placeholder:"Search products, ingredients, categoriesâ¦",anchorId:gc,scopeLabel:"Cosmetics Shop"},wholesale:{supported:!0,placeholder:"Search wholesale products, SKUs, categoriesâ¦",anchorId:gc,scopeLabel:"Wholesale B2B"},"salon-services":{supported:!0,placeholder:"Search salon & spa servicesâ¦",anchorId:gc,scopeLabel:"Salon & Spa"},"zoras-salon":{supported:!0,placeholder:"Search salon servicesâ¦",anchorId:gc,scopeLabel:"Zora's Salon"},hospitality:{supported:!0,placeholder:"Search bistro menu itemsâ¦",anchorId:gc,scopeLabel:"Z-Bistro & Café"},"bistro-menu":{supported:!0,placeholder:"Search bistro menu itemsâ¦",anchorId:gc,scopeLabel:"Z-Bistro Menu"},lms:{supported:!1,placeholder:"Use the chapter filters in Z-LMS",scopeLabel:"Z-LMS"},"instructor-lms":{supported:!1,placeholder:"Use the instructor LMS filters",scopeLabel:"Instructor LMS"},audit:{supported:!1,placeholder:"Use the Audit Vault filters",scopeLabel:"Audit Vault"},financial:{supported:!1,placeholder:"Use the Financial Engine filters",scopeLabel:"Financial Engine"},"financial-silo":{supported:!1,placeholder:"Use the Financial Silo filters",scopeLabel:"Financial Silo"},"exec-financial":{supported:!1,placeholder:"Use the Executive Financial filters",scopeLabel:"Executive Financial"},agency:{supported:!1,placeholder:"Use the Agency Hub filters",scopeLabel:"Agency Hub"}
1189,staff:{supported:!1,placeholder:"Use the Staff Portal filters",scopeLabel:"Staff Portal"},"student-portal":{supported:!1,placeholder:"Use the Student Portal navigation",scopeLabel:"Student Portal"},"student-progress":{supported:!1,placeholder:"Use the Progress Dashboard filters",scopeLabel:"Student Progress"},"student-profile":{supported:!1,placeholder:"Use the Profile tabs",scopeLabel:"Student Profile"},"student-clinic":{supported:!1,placeholder:"Use the Student Clinic filters",scopeLabel:"Student Clinic"},compliance:{supported:!1,placeholder:"Use the Compliance filters",scopeLabel:"Compliance"},"compliance-lockdown":{supported:!1,placeholder:"Use the Compliance Lockdown filters",scopeLabel:"Compliance Lockdown"},"sis-dashboard":{supported:!1,placeholder:"Use the SIS Dashboard filters",scopeLabel:"SIS Dashboard"},"doc-verification":{supported:!1,placeholder:"Use the Document Verification filters",scopeLabel:"Document Verification"},gradebook:{supported:!1,placeholder:"Use the Gradebook filters",scopeLabel:"Gradebook"},"wholesale-admin":{supported:!1,placeholder:"Use the Wholesale Admin filters",scopeLabel:"Wholesale Admin"},"wholesale-tracker":{supported:!1,placeholder:"Use the Order Tracker filters",scopeLabel:"Order Tracker"},"med-spa-portal":{supported:!1,placeholder:"Use the Med Spa filters",scopeLabel:"Med Spa Portal"},"professional-services":{supported:!1,placeholder:"Use the Services filters",scopeLabel:"Professional Services"},ecosystem:{supported:!1,placeholder:"Use the Ecosystem navigation",scopeLabel:"Ecosystem"},foundation:{supported:!1,placeholder:"Use the Foundation navigation",scopeLabel:"Foundation"},"foundation-donate":{supported:!1,placeholder:"Donation form â no search needed",scopeLabel:"Foundation Donate"},"foundation-gift-shop":{supported:!1,placeholder:"Use the Gift Shop category filters",scopeLabel:"Foundation Gift Shop"},"gala-fundraiser":{supported:!1,placeholder:"Use the Gala filters",scopeLabel:"Gala Fundraiser"}
1189,"master-bridge":{supported:!1,placeholder:"Use the Bridge filters",scopeLabel:"450h Bridge"},"master-esthetics-1200":{supported:!1,placeholder:"Use the program filters",scopeLabel:"Master Esthetics 1200h"},"partner-portal":{supported:!1,placeholder:"Use the Partner Portal filters",scopeLabel:"Partner Portal"},google:{supported:!1,placeholder:"Use the Google Sync filters",scopeLabel:"Google Sync"},"google-meta-sync":{supported:!1,placeholder:"Use the Meta Sync filters",scopeLabel:"Google Meta Sync"},"ga4-integration":{supported:!1,placeholder:"Use the GA4 dashboard filters",scopeLabel:"GA4 Integration"},"gsc-integration":{supported:!1,placeholder:"Use the GSC dashboard filters",scopeLabel:"GSC Integration"},"ahrefs-backlinks":{supported:!1,placeholder:"Use the Ahrefs filters",scopeLabel:"Ahrefs Backlinks"},"wix-studio-export":{supported:!1,placeholder:"Use the Wix Studio filters",scopeLabel:"Wix Studio Export"},"robots-txt-generator":{supported:!1,placeholder:"No search in the robots.txt tool",scopeLabel:"robots.txt Generator"},franchise:{supported:!1,placeholder:"Use the Franchise filters",scopeLabel:"Franchise HQ"},"location-mgmt":{supported:!1,placeholder:"Use the Location filters",scopeLabel:"Location Management"},pos:{supported:!1,placeholder:"Use the POS filters",scopeLabel:"POS & Inventory"},"reviewer-access":{supported:!1,placeholder:"Use the Reviewer filters",scopeLabel:"Reviewer Access"},"rgm-compliance":{supported:!1,placeholder:"Use the RGM Compliance filters",scopeLabel:"RGM Compliance"},housing:{supported:!1,placeholder:"Use the Housing filters",scopeLabel:"Student Housing"},events:{supported:!1,placeholder:"Use the Events filters",scopeLabel:"Events"},"village-map":{supported:!1,placeholder:"Browse the Village Map",scopeLabel:"Village Map"},"quiz-engine":{supported:!1,placeholder:"Use the Quiz filters",scopeLabel:"Quiz Engine"},"z-cpa":{supported:!1,placeholder:"Use the Z-CPA filters",scopeLabel:"Z-CPA"},"md-referral":{supported:!1,placeholder:"Use the MD Referral filters",scopeLabel:"MD Referral"},"social-hub":{supported:!1,placeholder:"Use the Social Hub filters",scopeLabel:"Social Hub"},"supply-chain":{supported:!1,placeholder:"Use the Supply Chain filters",scopeLabel:"Supply Chain"},"our-story":{supported:!1,placeholder:"No search on Our Story",scopeLabel:"Our Story"},"contact-us":{supported:!1,placeholder:"No search on Contact Us",scopeLabel:"Contact Us"},admissions:{supported:!1,placeholder:"No search on Admissions",scopeLabel:"Admissions"},edexpress:{supported:!1,placeholder:"Use the EDExpress filters",scopeLabel:"EDExpress"},"program-profiles":{supported:!1,placeholder:"Browse program profiles",scopeLabel:"Program Profiles"}
1189,"career-bridge":{supported:!1,placeholder:"Use the Career Bridge filters",scopeLabel:"Career Bridge"},"regulatory-reporting":{supported:!1,placeholder:"Use the Regulatory filters",scopeLabel:"Regulatory Reporting"},"federal-compliance":{supported:!1,placeholder:"Use the Federal Compliance filters",scopeLabel:"Federal Compliance"},"clinical-safety":{supported:!1,placeholder:"Use the Clinical Safety filters",scopeLabel:"Clinical Safety"},"dol-hour-relay":{supported:!1,placeholder:"Use the DOL Relay filters",scopeLabel:"DOL Hour Relay"},"loa-management":{supported:!1,placeholder:"Use the LOA filters",scopeLabel:"LOA Management"},"retargeting-conversion":{supported:!1,placeholder:"Use the Retargeting filters",scopeLabel:"Retargeting & Conversion"},"ab-testing":{supported:!1,placeholder:"Use the A/B Test filters",scopeLabel:"A/B Testing"},"sovereign-os":{supported:!1,placeholder:"Use the Sovereign OS filters",scopeLabel:"Sovereign Multi-Site OS"},"ai-scan-portal":{supported:!1,placeholder:"Use the AI Scan filters",scopeLabel:"AI Scan Portal"},"premium-landing":{supported:!1,placeholder:"No search on the landing template",scopeLabel:"Premium Landing"}};function vY(t){return bY[t]||yY}const rt=t=>`https://www.zorganics.com/media/${t}/v1/fill/w_600,h_600,al_c,q_85,enc_auto/${t}`,it=["in-store-bellingham","wholesale-seattle","wholesale-renton"],ot=["100% Vegan","Certified Organic","Non-Toxic"],Eh=[{id:"retail-pure-matte-foundation",name:"Pure Matte⢠Liquid Coverage Foundation SPF 15 (1.01 fl oz / 30mL)",handle:"pure-matte-liquid-coverage-foundation-spf-15",description:"Achieve a flawless complexion with the Pure Matte Liquid Coverage Foundation SPF 15. This lightweight, high-performance formula provides full, buildable coverage that perfects the skin with a natural-looking matte finish. Designed for all-day wear (up to 24H) and formulated to be gentle and nourishing, even for sensitive skin â with Broad Spectrum SPF 15 to shield against UVA and UVB.",price:4450,sku:"ZC-PMF-30ML",inventory_qty:40,images:[rt("a90cca_e1cc6cf5b48a4c2d9c92c1037f26b53f~mv2.jpg")],status:"active",has_variants:!1,vendor:"Zorganics Cosmetics",product_type:"Mineral Makeup",tags:["featured","bestseller","sensitive","foundation"],metadata:{key_ingredients:"Calendula Officinalis Flower Extract, Chamomilla Recutita (Matricaria) Flower Extract, Tilia Cordata (Linden) Flower Extract, Camellia Sinensis (Green Tea) Leaf Extract, Kaolin Clay",size:"1.01 fl oz / 30mL",skin_type:"All skin types · ideal for sensitive",finish:"Matte",usage:"Shake well. Blend 1 drop onto clean, moisturized skin with a beauty sponge or fingertips; build coverage as needed.",certifications:ot,fulfillment:it,source_url:"https://www.zorganics.com/product-page/pure-matte-liquid-coverage-foundation-spf-15-1-01-fl-oz-30ml"}},{id:"retail-liquid-foundation-ivory",name:"Zorganics Liquid Foundation in Ivory",handle:"zorganics-liquid-foundation-in-ivory",description:"Buildable, breathable liquid foundation in a soft Ivory shade. A nourishing botanical base delivers natural, even coverage with a skin-true finish for everyday wear.",price:4450,sku:"ZC-LF-IVORY",inventory_qty:30,images:[rt("a90cca_a317c134a2404f88a0bbe92857138b57~mv2.jpg")],status:"active",has_variants:!1,vendor:"Zorganics Cosmetics",product_type:"Mineral Makeup",tags:["foundation","sensitive"],metadata:{key_ingredients:"Botanical extract base, Calendula, Green Tea Leaf Extract",size:"1.01 fl oz / 30mL",finish:"Natural",certifications:ot,fulfillment:it,source_url:"https://www.zorganics.com/product-page/zorganics-liquid-foundation-in-ivory"}},{id:"retail-luxe-bullet-lipstick",name:"Zorganics Luxe Bullet Lipstick",handle:"zorganics-luxe-bullet-lipstick",description:"A luxurious, richly pigmented bullet lipstick that glides on for full, even color and a comfortable, conditioning wear. Clean-beauty formulation crafted for elite artistry.",price:7499,sku:"ZC-LUXE-LIP",inventory_qty:35,images:[rt("a90cca_6cb202b6b30846c499ed71aaf06fd947~mv2.jpg")],status:"active",has_variants:!1,vendor:"Zorganics Cosmetics",product_type:"Mineral Makeup",tags:["featured","bestseller","lips"],metadata:{key_ingredients:"Botanical waxes & oils, plant-derived pigments",finish:"Satin",certifications:ot,fulfillment:it,source_url:"https://www.zorganics.com/product-page/zorganics-luxe-bullet-lipstick"}},{id:"retail-long-lasting-liquid-lipstick",name:"Long Lasting Liquid Lipstick (Net wt. 0.10 oz / 3 ml)",handle:"long-lasting-liquid-lipstick",description:"Transfer-resistant liquid lipstick delivering bold, saturated color with a lightweight, long-wear finish. Comfortable enough for all-day wear.",price:3e3,sku:"ZC-LLL-3ML",inventory_qty:45,images:[rt("a90cca_cc74cb48fb51441d9d56dd3141d1ba85~mv2.jpg")],status:"active",has_variants:!1,vendor:"Zorganics Cosmetics",product_type:"Mineral Makeup",tags:["lips","bestseller"],metadata:{size:"0.10 oz / 3 ml",finish:"Long-wear",certifications:ot,fulfillment:it,source_url:"https://www.zorganics.com/product-page/long-lasting-liquid-lipstick-net-wt-0-10-oz-3-ml"}},{id:"retail-matte-lip-stick",name:"Zorganics Matte Lip Stick",handle:"zorganics-matte-lip-stick",description:"A velvety matte lipstick with rich, even payoff and a soft-focus finish. Botanical-conditioned for c
1189omfortable, non-drying wear.",price:2499,sku:"ZC-MATTE-LIP",inventory_qty:50,images:[rt("a90cca_f21ad6b098e9478783d4f681b43fdfc3~mv2.jpeg")],status:"active",has_variants:!1,vendor:"Zorganics Cosmetics",product_type:"Mineral Makeup",tags:["lips"],metadata:{finish:"Matte",certifications:ot,fulfillment:it,source_url:"https://www.zorganics.com/product-page/zorganics-matte-lip-stick"}},{id:"retail-matte-lip-stick-6",name:"Zorganics Matte Lip Stick 6",handle:"zorganics-matte-lip-stick-6",description:"Shade 6 of the Zorganics velvety matte lipstick line â rich, even pigment with a soft-focus matte finish and botanical conditioning.",price:2499,sku:"ZC-MATTE-LIP-6",inventory_qty:50,images:[rt("a90cca_2b10bc37d2ab4596aff3cc168c118615~mv2.jpeg")],status:"active",has_variants:!1,vendor:"Zorganics Cosmetics",product_type:"Mineral Makeup",tags:["lips"],metadata:{finish:"Matte",certifications:ot,fulfillment:it,source_url:"https://www.zorganics.com/product-page/zorganics-matte-lip-stick-6"}},{id:"retail-matte-lip-stick-10",name:"Zorganics Matte Lip Stick 10",handle:"zorganics-matte-lip-stick-10",description:"Shade 10 of the Zorganics velvety matte lipstick line â bold, even pigment with a comfortable, non-drying matte finish.",price:2499,sku:"ZC-MATTE-LIP-10",inventory_qty:50,images:[rt("a90cca_a552a7fa174a4540920ae689c4ed4042~mv2.jpeg")],status:"active",has_variants:!1,vendor:"Zorganics Cosmetics",product_type:"Mineral Makeup",tags:["lips"],metadata:{finish:"Matte",certifications:ot,fulfillment:it,source_url:"https://www.zorganics.com/product-page/zorganics-matte-lip-stick-10"}},{id:"retail-lip-shine-miss-lady",name:"Zorganics Lip Shine in Miss Lady & Lip Pencil",handle:"zorganics-lip-shine-in-miss-lady-and-lip-pencil",description:"A glossy, high-shine lip color in the Miss Lady shade, paired with a coordinating lip pencil for crisp definition and a luminous, hydrated finish.",price:3e3,sku:"ZC-LS-MISSLADY",inventory_qty:30,images:[rt("a90cca_c61a7b0d42c14a83ac438f9fbec45c3b~mv2.jpeg")],status:"active",has_variants:!1,vendor:"Zorganics Cosmetics",product_type:"Mineral Makeup",tags:["lips"],metadata:{finish:"High-shine",certifications:ot,fulfillment:it,source_url:"https://www.zorganics.com/product-page/zorganics-lip-shine-in-miss-lady-and-lip-pencil"}},{id:"retail-lip-shine-darling",name:"Zorganics Lip Shine in Darling",handle:"zorganics-lip-shine-in-darling",description:"A luminous lip shine in the Darling shade â sheer-to-medium glossy color that conditions and hydrates for a soft, radiant finish.",price:3e3,sku:"ZC-LS-DARLING",inventory_qty:30,images:[rt("a90cca_cf9dbf9ff31d459d8c3478284776b200~mv2.jpeg")],status:"active",has_variants:!1,vendor:"Zorganics Cosmetics",product_type:"Mineral Makeup",tags:["lips"],metadata:{finish:"High-shine",certifications:ot,fulfillment:it,source_url:"https://www.zorganics.com/product-page/zorganics-lip-shine-in-darling"}},{id:"retail-velvet-lip-gloss-23",name:"Zorganics Velvet Lip Gloss 23",handle:"zorganics-velvet-lip-gloss-23",description:"Shade 23 of the Velvet Lip Gloss line â a cushiony, non-sticky gloss that delivers a plush veil of color and mirror shine.",price:2e3,sku:"ZC-VLG-23",inventory_qty:40,images:[rt("a90cca_f0eb5abe5a694580b9a4d0f9742b3463~mv2.png")],status:"active",has_variants:!1,vendor:"Zorganics Cosmetics",product_type:"Mineral Makeup",tags:["lips"],metadata:{finish:"Glossy",certifications:ot,fulfillment:it,source_url:"https://www.zorganics.com/product-page/zorganics-velvet-lip-gloss-23"}},{id:"retail-velvet-lip-gloss-16",name:"Zorganics Velvet Lip Gloss 16",handle:"zorganics-velvet-lip-gloss-16",description:"Shade 16 of the Velvet Lip Gloss line â a smooth, non-sticky gloss for a plush hit of color and high-shine finish.",price:2e3,sku:"ZC-VLG-16",inventory_qty:40,images:[rt("a90cca_1967975d116d4bd8a6ff24681ec7b505~mv2.png")],status:"active",has_variants:!1,vendor:"Zorganics Cosmetics",product_type:"Mineral Makeup",tags:["lips"],metadata:{finish:"Glossy",certifications:ot,fulfillment:it,source_url:"https://www.zorganics.com/product-page/zorganics-velvet-lip-gloss-16"}},{id:"retail-velvet-lip-gloss-14",name:"Zorganics Velvet Lip Gloss 14",handle:"zorganics-velvet-lipgloss-14",description:"Shade 14 of the Velvet Lip Gloss line â cushiony, comfortable gloss with a luminous, non-sticky finish.",price:2e3,sku:"ZC-VLG-14",inventory_qty:40,images:[rt("a90cca_5ab903e1f335480b891999e3e417d63b~mv2.png")],status:"active",has_variants:!1,vendor:"Zorganics Cosmetics",product_type:"Mineral Makeup",tags:["lips"],metadata:{f
1189inish:"Glossy",certifications:ot,fulfillment:it,source_url:"https://www.zorganics.com/product-page/zorganics-velvet-lipgloss-14"}},{id:"retail-velvet-lip-gloss-08",name:"Zorganics Velvet Lip Gloss 08",handle:"zorganics-velvet-lip-gloss-08",description:"Shade 08 of the Velvet Lip Gloss line â a plush, high-shine gloss that wears smooth and comfortable without stickiness.",price:2e3,sku:"ZC-VLG-08",inventory_qty:40,images:[rt("a90cca_9e951ce258904c3e84cc8665b8e8f54f~mv2.png")],status:"active",has_variants:!1,vendor:"Zorganics Cosmetics",product_type:"Mineral Makeup",tags:["lips"],metadata:{finish:"Glossy",certifications:ot,fulfillment:it,source_url:"https://www.zorganics.com/product-page/zorganics-velvet-lip-gloss"}},{id:"retail-linamissa-scalp-elixir",name:"Linamissa⢠Regenerative Scalp Elixir (2 oz)",handle:"linamissa-regenerative-scalp-elixir-2-oz",description:"A natural, lightweight, vegan hair tonic engineered as the essential daily maintenance step â balancing the scalp environment to support continuous, healthy hair growth. A base of Glycerin moisturizes while Witch Hazel and Lavender regulate excess oil and soothe irritation, with Saw Palmetto and Skullcap supporting the follicular environment for fuller-looking, more manageable hair.",price:6500,sku:"ZC-LIN-ELIXIR-2OZ",inventory_qty:25,images:[rt("590572_7a01b64349c747b6b5769d04e59f6dba~mv2.png")],status:"active",has_variants:!1,vendor:"Zorganics Cosmetics",product_type:"Hair Care",tags:["featured","clinical-grade","hair","scalp"],metadata:{key_ingredients:"Serenoa Serrulata (Saw Palmetto), Scutellaria Baicalensis (Skullcap), Witch Hazel, Tea Tree Oil, Horsetail, Gotu Kola, Clove Bud Oil, Glycerin, Lavender",size:"2 oz",hair_type:"All hair types · oil & moisture balancing",usage:"Use daily on wet or dry hair. Spritz onto scalp to reduce oiliness, distribute through lengths, or finish after styling for shine. Do not rinse.",certifications:ot,fulfillment:it,source_url:"https://www.zorganics.com/product-page/linamissa-regenerative-scalp-elixir-2-oz"}},{id:"retail-ojawei-shave-system",name:"Ojawei Recharge Me⢠Shave System",handle:"ojawei-recharge-me-shave-system",description:"A complete men's botanical shave system from the Ojawei Recharge Me grooming line â formulated with activated charcoal and reishi to cleanse, protect, and recover skin through every step of the shave ritual.",price:5499,sku:"ZC-OJW-SHAVE-SYS",inventory_qty:20,images:[rt("a90cca_4e54df17d0844698ae1c23dcd1ddf991~mv2.jpg")],status:"active",has_variants:!1,vendor:"Zorganics Cosmetics",product_type:"Men's Care",tags:["featured","mens-care","grooming"],metadata:{key_ingredients:"Activated Charcoal, Reishi, MSM, Botanical Aloe",certifications:ot,fulfillment:it,source_url:"https://www.zorganics.com/product-page/ojawei-recharge-me-shave-system"}},{id:"retail-ojawei-aftershave-toner",name:"Ojawei Recharge Me After Shave Toner",handle:"ojawei-recharge-me-after-shave-toner",description:"A soothing botanical after-shave toner from the Ojawei Recharge Me line â calms, refreshes, and rebalances skin post-shave while minimizing irritation and razor burn.",price:3499,sku:"ZC-OJW-TONER",inventory_qty:30,images:[rt("a90cca_23324872a79646a2a4437dd804b52527~mv2.jpg")],status:"active",has_variants:!1,vendor:"Zorganics Cosmetics",product_type:"Men's Care",tags:["mens-care","grooming"],metadata:{key_ingredients:"Aloe, Witch Hazel, Botanical Charcoal",certifications:ot,fulfillment:it,source_url:"https://www.zorganics.com/product-page/ojawei-recharge-me-after-shave-toner"}},{id:"retail-natae-foot-therapy",name:"Zorganics Spa Natae⢠Foot Therapy System",handle:"zorganics-spa-natae-foot-therapy-system",description:"A spa-grade botanical foot therapy system that softens, soothes, and revives tired feet. Part of the Zorganics Spa body-care ritual for at-home restorative care.",price:6e3,sku:"ZC-NATAE-FOOT",inventory_qty:22,images:[rt("a90cca_f105967fd7e346bea242872d3b9b056c~mv2.jpg")],status:"active",has_variants:!1,vendor:"Zorganics Cosmetics",product_type:"Body Care",tags:["body","spa"],metadata:{key_ingredients:"Botanical foot-soak complex, soothing plant extracts",certifications:ot,fulfillment:it,source_url:"https://www.zorganics.com/product-page/zorganics-spa-natae-foot-therapy-system"}},{id:"retail-velvet-lip-gloss-03",name:"Zorganics Velvet Lip Gloss 03",handle:"zorganics-velvet-lip-gloss-03",description:"Shade 03 of the Velvet Lip Gloss line â a plush, non-sticky gloss delivering a soft veil of color and luminous mirror shine.",price:2e3,sku:"ZC-VLG-03",inventory_qty:40,images:[rt("a90cca_5ab903e1f335480b891999e3e417d63b~mv2.png")],status:"active",has_variants:!1,vendor:"Zorganics Cosmetics",product_type:"Mineral Makeup",tags:["lips"],metadata:{f
1189inish:"Glossy",certifications:ot,fulfillment:it,source_url:"https://www.zorganics.com/product-page/zorganics-velvet-lip-gloss-03"}},{id:"retail-liquid-foundation-goddess",name:"Zorganics Liquid Foundation in Goddess",handle:"zorganics-liquid-foundation-in-goddess",description:"Buildable, breathable liquid foundation in the deep Goddess shade. A nourishing botanical base delivers natural, even coverage with a skin-true finish.",price:4450,sku:"ZC-LF-GODDESS",inventory_qty:30,images:[rt("a90cca_a317c134a2404f88a0bbe92857138b57~mv2.jpg")],status:"active",has_variants:!1,vendor:"Zorganics Cosmetics",product_type:"Mineral Makeup",tags:["foundation","sensitive"],metadata:{finish:"Natural",certifications:ot,fulfillment:it,source_url:"https://www.zorganics.com/product-page/zorganics-liquid-foundation-in-goddess"}},{id:"retail-liquid-foundation-toffee",name:"Zorganics Liquid Foundation in Toffee",handle:"zorganics-liquid-foundation-in-toffee",description:"Buildable, breathable liquid foundation in the warm Toffee shade. Botanical base gives natural, even coverage with a comfortable skin-true finish.",price:4450,sku:"ZC-LF-TOFFEE",inventory_qty:30,images:[rt("a90cca_a317c134a2404f88a0bbe92857138b57~mv2.jpg")],status:"active",has_variants:!1,vendor:"Zorganics Cosmetics",product_type:"Mineral Makeup",tags:["foundation","sensitive"],metadata:{finish:"Natural",certifications:ot,fulfillment:it,source_url:"https://www.zorganics.com/product-page/zorganics-liquid-foundation-in-toffee"}},{id:"retail-liquid-foundation-cafe",name:"Zorganics Liquid Foundation in Café",handle:"zorganics-liquid-foundation-in-cafe",description:"Buildable, breathable liquid foundation in the rich Café shade. Nourishing botanical base for natural, even coverage and a skin-true finish.",price:4450,sku:"ZC-LF-CAFE",inventory_qty:30,images:[rt("a90cca_a317c134a2404f88a0bbe92857138b57~mv2.jpg")],status:"active",has_variants:!1,vendor:"Zorganics Cosmetics",product_type:"Mineral Makeup",tags:["foundation","sensitive"],metadata:{finish:"Natural",certifications:ot,fulfillment:it,source_url:"https://www.zorganics.com/product-page/zorganics-liquid-foundation-in-cafe"}},{id:"retail-liquid-foundation-sunkissed",name:"Zorganics Liquid Foundation in Sunkissed",handle:"zorganics-liquid-foundation-in-sunkissed",description:"Buildable, breathable liquid foundation in the warm Sunkissed shade. Botanical base delivers natural, even coverage with a glowing skin-true finish.",price:4450,sku:"ZC-LF-SUNKISSED",inventory_qty:30,images:[rt("a90cca_a317c134a2404f88a0bbe92857138b57~mv2.jpg")],status:"active",has_variants:!1,vendor:"Zorganics Cosmetics",product_type:"Mineral Makeup",tags:["foundation","sensitive"],metadata:{finish:"Natural",certifications:ot,fulfillment:it,source_url:"https://www.zorganics.com/product-page/zorganics-liquid-foundation-in-sunkissed"}},{id:"retail-liquid-foundation-natural",name:"Zorganics Liquid Foundation in Natural",handle:"zorganics-liquid-foundation-in-natural",description:"Buildable, breathable liquid foundation in the versatile Natural shade. A nourishing botanical base delivers even coverage with a true-to-skin finish.",price:4450,sku:"ZC-LF-NATURAL",inventory_qty:30,images:[rt("a90cca_a317c134a2404f88a0bbe92857138b57~mv2.jpg")],status:"active",has_variants:!1,vendor:"Zorganics Cosmetics",product_type:"Mineral Makeup",tags:["foundation","sensitive"],metadata:{finish:"Natural",certifications:ot,fulfillment:it,source_url:"https://www.zorganics.com/product-page/zorganics-liquid-foundation-in-natural"}},{id:"retail-liquid-foundation-latte",name:"Zorganics Liquid Foundation in Latté",handle:"zorganics-liquid-foundation-in-latte",description:"Buildable, breathable liquid foundation in the medium Latté shade. Botanical base provides natural, even coverage and a comfortable skin-true finish.",price:4450,sku:"ZC-LF-LATTE",inventory_qty:30,images:[rt("a90cca_a317c134a2404f88a0bbe92857138b57~mv2.jpg")],status:"active",has_variants:!1,vendor:"Zorganics Cosmetics",product_type:"Mineral Makeup",tags:["foundation","sensitive"],metadata:{finish:"Natural",certifications:ot,fulfillment:it,source_url:"https://www.zorganics.com/product-page/zorganics-liquid-foundation-in-latte"}},{id:"retail-liquid-foundation-porcelain",name:"Zorganics Liquid Foundation in Porcelain",handle:"zorganics-liquid-foundation-in-porcelain",description:"Buildable, breathable liquid foundation in the light Porcelain shade. Nourishing botanical base for natural, even coverage with a skin-true finish.",price:4450,sku:"ZC-LF-PORCELAIN",inventory_qty:30,images:[rt("a90cca_a317c134a2404f88a0bbe92857138b57~mv2.jpg")],status:"active",has_variants:!1,vendor:"Zorganics Cosmetics",product_type:"Mineral Makeup",tags:["foundation","sensitive"],metadata:{f
1189inish:"Natural",certifications:ot,fulfillment:it,source_url:"https://www.zorganics.com/product-page/zorganics-liquid-foundation-in-porcelain"}},{id:"retail-longal-oxygen-cleanser",name:"Longal⢠Oxygen Hydra Cleanser",handle:"longal-oxygen-hydra-cleanser",description:"A gentle, oxygenating gel cleanser from the Longal⢠Oxygen line. Lifts impurities and excess oil while infusing skin with botanical hydration â leaving a fresh, balanced, never-stripped feel.",price:3800,sku:"ZC-LONGAL-CLEANSE",inventory_qty:30,images:[rt("590572_3016bdcdc20e4ee09dd7a584a535eb43~mv2.png")],status:"active",has_variants:!1,vendor:"Zorganics Cosmetics",product_type:"Skin Care",tags:["featured","skin","cleanser","oxygen"],metadata:{key_ingredients:"Oxygen complex, Aloe, Botanical Glycerin",size:"4 oz",skin_type:"All skin types",certifications:ot,fulfillment:it,source_url:"https://www.zorganics.com/product-page/longal-oxygen-hydra-cleanser"}},{id:"retail-longal-oxygen-serum",name:"Longal⢠Oxygen Revival Serum",handle:"longal-oxygen-revival-serum",description:"A lightweight oxygenating serum from the Longal⢠Oxygen line that energizes dull, tired skin. Botanical actives boost luminosity and support a fresher, more revived complexion.",price:5800,sku:"ZC-LONGAL-SERUM",inventory_qty:28,images:[rt("590572_583baccacdf34299a960f7281beb21aa~mv2.png")],status:"active",has_variants:!1,vendor:"Zorganics Cosmetics",product_type:"Skin Care",tags:["skin","serum","oxygen"],metadata:{key_ingredients:"Oxygen complex, Hyaluronic Acid, Gotu Kola",size:"1 oz",skin_type:"All skin types",certifications:ot,fulfillment:it,source_url:"https://www.zorganics.com/product-page/longal-oxygen-revival-serum"}},{id:"retail-longal-oxygen-moisturizer",name:"Longal⢠Oxygen Hydration Moisturizer",handle:"longal-oxygen-hydration-moisturizer",description:"A breathable, oxygen-infused daily moisturizer from the Longal⢠Oxygen line. Locks in lasting hydration while supporting a soft, supple, healthy-looking complexion.",price:5200,sku:"ZC-LONGAL-MOIST",inventory_qty:28,images:[rt("a90cca_e16152ffba974b53bf14caf90d13986e~mv2.png")],status:"active",has_variants:!1,vendor:"Zorganics Cosmetics",product_type:"Skin Care",tags:["skin","moisturizer","oxygen"],metadata:{key_ingredients:"Oxygen complex, Shea Butter, Aloe",size:"1.7 oz",skin_type:"Normal to dry",certifications:ot,fulfillment:it,source_url:"https://www.zorganics.com/product-page/longal-oxygen-hydration-moisturizer"}},{id:"retail-zycolics-derm-toner",name:"Zycolics⢠Derm Balancing Toner",handle:"zycolics-derm-balancing-toner",description:"A clarifying, pH-balancing toner from the Zycolics⢠Derm line. Refines the look of pores and preps skin to better absorb treatment â soothing botanicals calm and rebalance.",price:3400,sku:"ZC-ZYC-TONER",inventory_qty:30,images:[rt("590572_c3a5001afcc74335ac827ede6bc2fb36~mv2.png")],status:"active",has_variants:!1,vendor:"Zorganics Cosmetics",product_type:"Skin Care",tags:["featured","skin","toner","derm"],metadata:{key_ingredients:"Witch Hazel, Niacinamide, Green Tea",size:"4 oz",skin_type:"Combination to oily",certifications:ot,fulfillment:it,source_url:"https://www.zorganics.com/product-page/zycolics-derm-balancing-toner"}},{id:"retail-zycolics-derm-exfoliant",name:"Zycolics⢠Derm Resurfacing Exfoliant",handle:"zycolics-derm-resurfacing-exfoliant",description:"A gentle botanical-acid resurfacing exfoliant from the Zycolics⢠Derm line. Smooths texture, brightens tone, and reveals a fresher, more refined complexion.",price:4800,sku:"ZC-ZYC-EXFOL",inventory_qty:26,images:[rt("590572_a23d9be5c9f5438b81aedd8d16d0397c~mv2.png")],status:"active",has_variants:!1,vendor:"Zorganics Cosmetics",product_type:"Skin Care",tags:["skin","exfoliant","derm"],metadata:{key_ingredients:"Botanical AHA/BHA, Willow Bark, Aloe",size:"1.7 oz",skin_type:"All skin types",certifications:ot,fulfillment:it,source_url:"https://www.zorganics.com/product-page/zycolics-derm-resurfacing-exfoliant"}},{id:"retail-zycolics-derm-night-cream",name:"Zycolics⢠Derm Overnight Repair Cream",handle:"zycolics-derm-overnight-repair-cream",description:"A rich overnight repair cream from the Zycolics⢠Derm line. Works while you sleep to replenish, firm, and smooth â waking skin to a renewed, well-rested glow.",price:6200,sku:"ZC-ZYC-NIGHT",inventory_qty:24,images:[rt("590572_f99a7ef9f9b748848b596fad65865f91~mv2.png")],status:"active",has_variants:!1,vendor:"Zorganics Cosmetics",product_type:"Skin Care",tags:["skin","cream","derm"],metadata:{key_ingredients:"Peptides, Shea Butter, Botanical Ceramides",size:"1.7 oz",skin_type:"Normal to dry",certifications:ot,fulfillment:it,source_url:"https://www.zorganics.com/product-page/zycolics-derm-overnight-repair-cream"}},{id:"retail-wotani-bright-serum",name:"Wotani⢠Bright Skin Vitamin C Serum",handle:"wotani-bright-skin-vitamin-c-serum",description:"A radiance-boosting Vitamin C serum from the Wotani⢠Bright Skin line. Targets dullness and uneven tone to reveal a visibly brighter, more luminous, even complexion.",price:5600,sku:"ZC-WOTANI-SERUM",inventory_qty:28,images:[rt("590572_ed83fb6f065644e59519eef2ac90a234~mv2.png")],status:"active",has_variants:!1,vendor:"Zorganics Cosmetics",product_type:"Skin Care",tags:["featured","
1189skin","serum","brightening"],metadata:{key_ingredients:"Vitamin C (Sodium Ascorbyl Phosphate), Niacinamide, Licorice Root",size:"1 oz",skin_type:"All skin types",certifications:ot,fulfillment:it,source_url:"https://www.zorganics.com/product-page/wotani-bright-skin-vitamin-c-serum"}},{id:"retail-wotani-bright-cream",name:"Wotani⢠Bright Skin Tone-Perfecting Cream",handle:"wotani-bright-skin-tone-perfecting-cream",description:"A tone-perfecting daily cream from the Wotani⢠Bright Skin line. Hydrates while helping to fade the look of dark spots and even out skin tone for a healthy, radiant finish.",price:5400,sku:"ZC-WOTANI-CREAM",inventory_qty:26,images:[rt("590572_915a0daf16834336bc7e19c7d6931fa9~mv2.png")],status:"active",has_variants:!1,vendor:"Zorganics Cosmetics",product_type:"Skin Care",tags:["skin","cream","brightening"],metadata:{key_ingredients:"Niacinamide, Licorice Root, Shea Butter",size:"1.7 oz",skin_type:"All skin types",certifications:ot,fulfillment:it,source_url:"https://www.zorganics.com/product-page/wotani-bright-skin-tone-perfecting-cream"}},{id:"retail-malouwa-ph-hydration-system",name:"Malouwa⢠pH Hydration System â Dry & Dehydrated Skin",handle:"malouwa-hydration-dry-dehydrated-skin",description:"The signature pH-balanced hydration system for dry, dehydrated, and sensitive skin. Formulated by Master Esthetician Frida Emalange, this complete ritual restores the moisture barrier and locks in lasting hydration for up to 24 hours using organic aloe vera, hyaluronic acid, niacinamide, and a proprietary botanical complex. Gentle, non-stripping, and pH-optimized to soothe reactive, thirsty skin.",price:4800,sku:"ZC-MAL-RET",inventory_qty:60,images:[rt("a90cca_79a40e9db8744863b8fc334b436d37f6~mv2_d_1776_1565_s_2.png")],status:"active",has_variants:!1,vendor:"Zorganics Cosmetics",product_type:"Skin Care",tags:["featured","bestseller","skin","hydration","dry-skin","sensitive","malouwa","ph-balancing"],metadata:{key_ingredients:"Organic Aloe Vera Juice, Hyaluronic Acid, Glycerin, Jojoba Oil, Vitamin E (Tocopherol), Chamomile Extract, Green Tea Extract, Niacinamide, Allantoin, Panthenol (Pro-Vitamin B5)",size:"Full Ritual System",skin_type:"Dry & dehydrated · sensitive · reactive",finish:"Hydrating",usage:"Use the full ritual morning and night: Cleanse â Tone â Serum â Lotion â Eye Treatment. Patch test on first use if skin is highly reactive.",certifications:ot,fulfillment:it,source_url:"https://www.zorganics.com/malouwa-hydration-dry-dehydrated-skin"}},{id:"retail-malouwa-cleanser",name:"Malouwa⢠Hydration pH-Balancing Facial Cleanser",handle:"malouwa-hydration-ph-balancing-facial-cleanser",description:"A creamy, sulfate-free cleanser that gently lifts away impurities and makeup without stripping the skin barrier. pH-optimized with organic aloe and panthenol to leave dry, dehydrated, and sensitive skin soft, calm, and comfortably clean â never tight.",price:3200,sku:"ZC-MAL-CLEANSE",inventory_qty:40,images:[rt("590572_ba567f3b10694c318168e7a694393a67~mv2.png")],status:"active",has_variants:!1,vendor:"Zorganics Cosmetics",product_type:"Facial Cleanser",tags:["skin","cleanser","hydration","dry-skin","sensitive","malouwa","ph-balancing"],metadata:{key_ingredients:"Organic Aloe Vera Juice, Glycerin, Panthenol (Pro-Vitamin B5), Chamomile Extract, Allantoin",size:"4 oz / 120 mL",skin_type:"Dry & dehydrated · sensitive",usage:"Massage a small amount onto damp skin in circular motions, then rinse with lukewarm water. Use morning and night.",certifications:ot,fulfillment:it,source_url:"https://www.zorganics.com/product-page/malouwa-hydration-ph-balancing-facial-cleanser"}},{id:"retail-malouwa-toner",name:"Malouwa⢠Hydration pH-Balancing Facial Toner",handle:"malouwa-hydration-ph-balancing-facial-toner",description:"An alcohol-free hydrating toner that rebalances skin pH after cleansing and preps the complexion to absorb serum and moisturizer. Witch hazel and green tea calm reactivity while aloe and glycerin replenish moisture for a dewy, refreshed feel.",price:3e3,sku:"ZC-MAL-TONER",inventory_qty:40,images:[rt("590572_fec0e0e6bbad4888ada580e1b9153e7d~mv2.png")],status:"active",has_variants:!1,vendor:"Zorganics Cosmetics",product_type:"Facial Toner",tags:["skin","toner","hydration","dry-skin","sensitive","malouwa","ph-balancing"],metadata:{key_ingredients:"Witch Hazel (alcohol
1189-free), Organic Aloe Vera Juice, Green Tea Extract, Glycerin, Niacinamide",size:"4 oz / 120 mL",skin_type:"Dry & dehydrated · sensitive",usage:"After cleansing, sweep over the face with a cotton pad or mist directly onto skin. Follow with serum and lotion.",certifications:ot,fulfillment:it,source_url:"https://www.zorganics.com/product-page/malouwa-hydration-ph-balancing-facial-toner"}},{id:"retail-malouwa-serum",name:"Malouwa⢠Hydration pH-Balancing Hyaluronic Serum",handle:"malouwa-hydration-ph-balancing-hyaluronic-serum",description:"A featherweight hyaluronic acid serum that drenches dehydrated skin with multi-depth hydration, plumping the look of fine dehydration lines. Niacinamide and panthenol support the barrier while botanical antioxidants protect against daily stress.",price:5400,sku:"ZC-MAL-SERUM",inventory_qty:35,images:[rt("590572_5d17fc06de234ea781e922c3e8f9f679~mv2.png")],status:"active",has_variants:!1,vendor:"Zorganics Cosmetics",product_type:"Facial Serum",tags:["featured","skin","serum","hydration","dry-skin","sensitive","malouwa","hyaluronic-acid"],metadata:{key_ingredients:"Hyaluronic Acid, Niacinamide, Panthenol (Pro-Vitamin B5), Organic Aloe Vera Juice, Vitamin E",size:"1 oz / 30 mL",skin_type:"Dry & dehydrated · sensitive",finish:"Hydrating",usage:"Apply 2â3 drops to damp skin after toner, pressing gently into the face and neck. Seal with the pH-Balancing Facial Lotion.",certifications:ot,fulfillment:it,source_url:"https://www.zorganics.com/product-page/malouwa-hydration-ph-balancing-hyaluronic-serum"}},{id:"retail-malouwa-lotion",name:"Malouwa⢠Hydration pH-Balancing Facial Lotion",handle:"malouwa-hydration-ph-balancing-facial-lotion",description:"A nourishing yet breathable daily moisturizer that seals in hydration and reinforces the moisture barrier of dry, dehydrated, and sensitive skin. Jojoba oil and shea soften while aloe and allantoin calm â for an all-day supple, comfortable complexion.",price:4600,sku:"ZC-MAL-LOTION",inventory_qty:38,images:[rt("590572_d2ede7d181aa44c9b66dd6c8762149aa~mv2.png")],status:"active",has_variants:!1,vendor:"Zorganics Cosmetics",product_type:"Moisturizer",tags:["skin","moisturizer","hydration","dry-skin","sensitive","malouwa","bio-available"],metadata:{key_ingredients:"Jojoba Oil, Shea Butter, Organic Aloe Vera Juice, Hyaluronic Acid, Allantoin, Vitamin E",size:"1.7 oz / 50 mL",skin_type:"Dry & dehydrated · sensitive",finish:"Dewy-matte",usage:"Smooth over the face and neck morning and night as the final hydration step (before SPF in the AM).",certifications:ot,fulfillment:it,source_url:"https://www.zorganics.com/product-page/malouwa-hydration-ph-balancing-facial-lotion"}},{id:"retail-malouwa-eye-treatment",name:"Malouwa⢠Hydration Moisturizing Eye Treatment",handle:"malouwa-hydration-moisturizing-eye-treatment",description:"A cushiony eye treatment formulated for the delicate, dehydration-prone eye area. Hydrating peptides and caffeine help de-puff and brighten while aloe and panthenol soothe â softening the look of dryness lines around tired, sensitive eyes.",price:4200,sku:"ZC-MAL-EYE",inventory_qty:30,images:[rt("590572_d30c5bb0330d48a78cebdc9bd3f8b5bc~mv2.png")],status:"active",has_variants:!1,vendor:"Zorganics Cosmetics",product_type:"Eye Treatment",tags:["skin","eye","hydration","dry-skin","sensitive","malouwa"],metadata:{key_ingredients:"Peptides, Caffeine, Hyaluronic Acid, Organic Aloe Vera Juice, Panthenol",size:"0.5 oz / 15 mL",skin_type:"Dry & dehydrated · sensitive",usage:"Gently pat a small amount around the orbital bone morning and night. Avoid direct contact with the eyes.",certifications:ot,fulfillment:it,source_url:"https://www.zorganics.com/product-page/malouwa-hydration-moisturizing-eye-treatment"}},{id:"retail-zycolics-derm-facial-cleanser",name:"Zycolics⢠Derm Facial Cleanser",handle:"zycolics-derm-facial-cleanser",description:"A professional-grade exfoliating cleansing gel for deep clinical cleansing. It utilizes glycolic acid paired with organic aloe vera and gotu kola to clear excess sebum, rejuvenate surface skin architecture, and promote cellular vitality â engineered for thicker or oilier skin profiles.",price:7400,sku:"ZC-ZYC-CLEANSE",inventory_qty:30,images:[rt("590572_a23d9be5c9f5438b81aedd8d16d0397c~mv2.png")],status:"active",has_variants:!1,vendor:"Zorganics Cosmetics",product_type:"Facial Cleanser",tags:["featured","bestseller","clinical-grade","skin","cleanser","derm","zycolics"],metadata:{key_ingredients:"Glycolic Acid, Organic Aloe Vera, Gotu Kola (Centella Asiatica)",size:"4 oz / 120 mL",skin_type:"Thicker or oilier skin profiles",usage:"Massage a small amount onto damp skin in circular motions to exfoliate and lift excess sebum, then rinse with lukewarm water. Use morning and night.",certifications:ot,fulfillment:it,source_url:"https://www.zorganics.com/product-page/zycolics-derm-facial-cleanser"}},{id:"retail-ibaa-skin-perfecting-toner",name:"ZORGANICS IBAA Skin Perfecting Toner",handle:"zorganics-ibaa-skin-perfecting-toner",description:"A premium, organic approach to advanced dermal preparation and texture refinement. Formulated to immediately restore natural pH balance, it noticeably constricts the appearance of pores and preps the dermal barrier for elite clinical serum absorption.",price:3400,sku:"ZC-IBAA-TONER",inventory_qty:35,images:[rt("590572_c3a5001afcc74335ac827ede6bc2fb36~mv2.png")],status:"active",has_variants:!1,vendor:"Zorganics Cosmetics",product_type:"Facial Toner",tags:["featured","clinical-grade","skin","toner","ibaa"],metadata:{key_ingredients:"pH-restoring botanical complex, organic astringent extracts",size:"4 oz / 120 mL",skin_type:"All skin types · pre-serum prep",usage:"After cleansing, sweep over the face with a cotton pad to rebalance pH and refine pores. Follow with your clinical serum and moisturizer.",certifications:ot,fulfillment:it,source_url:"https://www.zorganics.com/product-page/zorganics-ibaa-skin-perfecting-toner"}},{id:"retail-dual-mineral-foundation",name:"Zorganics Dual Mineral Foundation",handle:"zorganics-dual-mineral-foundation",description:"A luxury, versatile mineral makeup solution that can be applied wet or dry for flawless post-treatment protection. It delivers completely flawless, full coverage that acts as a natural concealer while providing essential, physical UV protection to guard delicate skin barriers post-clinical treatment.",price:4450,sku:"ZC-DUAL-MIN-FND",inventory_qty:40,images:[rt("a90cca_e1cc6cf5b48a4c2d9c92c1037f26b53f~mv2.jpg")],status:"active",has_variants:!1,vendor:"Zorganics Cosmetics",product_type:"Mineral Makeup",tags:["featured","bestseller","clinical-grade","foundation","sensitive","post-treatment"],metadata:{key_ingredients:"Dual-mineral pigment complex, physical UV minerals, botanical extracts",finish:"Buildable full coverage · wet or dry",skin_type:"All skin types · i
1189deal post-clinical treatment",usage:"Apply dry with a brush for a soft-focus finish, or dampen the brush for full, concealer-level coverage. Builds physical UV protection for delicate post-treatment skin.",certifications:ot,fulfillment:it,source_url:"https://www.zorganics.com/product-page/zorganics-dual-mineral-foundation"}},{id:"retail-zemaja-ocean-mineral-serum",name:"Zemaja⢠Goddess Ocean Mineral Facial Serum",handle:"zemaja-ocean-mineral-serum",description:"The flagship of the Zemaja⢠Goddess Ocean Mineral collection â a lightweight marine-mineral serum that floods skin with ocean-sourced nutrients for instant radiance and barrier balance. Irish Moss (Sea Moss) and Wild Geranium deliver trace minerals while Marine Peptides plump, transforming dull, uneven skin into a dewy, goddess-lit glow.",price:13e3,sku:"ZC-ZEM-SERUM",inventory_qty:30,images:[rt("590572_cd4dc5f07ca64f1480567a2e13e41da1~mv2.png")],status:"active",has_variants:!1,vendor:"Zorganics Cosmetics",product_type:"Facial Serum",tags:["featured","bestseller","skin","serum","brightening","zemaja","marine-mineral"],metadata:{key_ingredients:"Irish Moss (Chondrus Crispus / Sea Moss), Wild Geranium, Marine Peptides, Hyaluronic Acid, MSM, Rosehip Seed Oil",size:"1 oz / 30 mL",skin_type:"All skin types · dull, uneven, combination",finish:"Radiant · dewy",usage:"Apply 2â3 drops to clean, damp skin morning and night, pressing gently into the face and neck. Follow with the Zemaja⢠Ocean Mineral Facial Lotion.",certifications:ot,fulfillment:it,source_url:"https://www.zorganics.com/product-page/zemaja-irish-moss-wild-geranium-ocean-mineral-serum"}},{id:"retail-zemaja-ocean-mineral-cleanser",name:"Zemaja⢠Goddess Ocean Mineral Facial Cleanser",handle:"zemaja-ocean-mineral-cleanser",description:"A creamy marine cleanser that gently lifts impurities while replenishing minerals lost to daily stress. Wild Geranium and Calendula soften and rebalance, leaving skin clean, calm, and never stripped â the first step of the Zemaja⢠Goddess ocean ritual.",price:6500,sku:"ZC-ZEM-CLEANSE",inventory_qty:32,images:[rt("590572_281bd501592543108531272772e2cce7~mv2.png")],status:"active",has_variants:!1,vendor:"Zorganics Cosmetics",product_type:"Facial Cleanser",tags:["skin","cleanser","zemaja","marine-mineral"],metadata:{key_ingredients:"Wild Geranium, Calendula, Irish Moss (Sea Moss), Aloe Vera, Glycerin",size:"4 oz / 120 mL",skin_type:"All skin types",usage:"Massage onto damp skin in circular motions, then rinse with lukewarm water. Use morning and night.",certifications:ot,fulfillment:it,source_url:"https://www.zorganics.com/product-page/zemaja-wild-geranium-calendula-ocean-mineral-face-body-wash"}},{id:"retail-zemaja-ocean-mineral-toner",name:"Zemaja⢠Goddess Ocean Mineral Facial Toner",handle:"zemaja-ocean-mineral-toner-mist",description:"An alcohol-free marine toner that rebalances pH and re-mineralizes skin after cleansing. Irish Moss and Kelp refine the look of pores while prepping skin to drink in the Ocean Mineral Serum.",price:6500,sku:"ZC-ZEM-TONER",inventory_qty:32,images:[rt("a90cca_373324945b72427a861a682be11cf587~mv2.png")],status:"active",has_variants:!1,vendor:"Zorganics Cosmetics",product_type:"Facial Toner",tags:["skin","toner","zemaja","marine-mineral"],metadata:{key_ingredients:"Irish Moss (Sea Moss), Sea Kelp, Wild Geranium, Witch Hazel (alcohol-free), Niacinamide",size:"4 oz / 120 mL",skin_type:"Combination · oily · dull",usage:"After cleansing, sweep over the face with a cotton pad or mist directly onto skin. Follow with serum and moisturizer.",certifications:ot,fulfillment:it,source_url:"https://www.zorganics.com/product-page/zemaja-irish-moss-kelp-ocean-mineral-facial-toner"}},{id:"retail-zemaja-ocean-mineral-moisturizer",name:"Zemaja⢠Goddess Ocean Mineral Facial Lotion",handle:"zemaja-ocean-mineral-moisturizer",description:"A breathable marine-mineral facial lotion that seals in hydration and locks in the glow. Irish Moss and Green Tea support a smooth, even-toned barrier while antioxidants defend against daily environmental stress.",price:19500,sku:"ZC-ZEM-MOIST",inventory_qty:28,images:[rt("590572_3029bde4e19c421fbdc0e49e9a50ba63~mv2.png")],status:"active",has_variants:!1,vendor:"Zorganics Cosmetics",product_type:"Moisturizer",tags:["skin","moisturizer","zemaja","marine-mineral"],metadata:{key_ingredients:"Irish Moss (Sea Moss), Green Tea, Marine Peptides, Shea Butter, Vitamin E",size:"1.7 oz / 50 mL",skin_type:"All skin types",finish:"Dewy",usage:"Smooth over the face and neck morning and night as the final hydration step (before SPF in the AM).",certifications:ot,fulfillment:it,source_url:"https://www.zorganics.com/product-page/zemaja-irish-moss-green-tea-ocean-mineral-moisturizer"}},{id:"retail-zemaja-ocean-mineral-eye",name:"Zemaja⢠Ocean Mineral Eye Cream",handle:"zemaja-ocean-mineral-eye-gel",description:"A cushiony marine eye cream that de-puffs and brightens the delicate eye area. Marine Peptides refresh tired eyes while Sea Moss and Wild Geranium soothe and re-mineralize for a wide-awake, goddess-lit look.",price:7599,sku:"ZC-ZEM-EYE",inventory_qty:26,images:[rt("590572_28a28f2dfef74b52ba6edf0b39501be0~mv2.png")],status:"active",has_variants:!1,vendor:"Zorganics Cosmetics",product_type:"Eye Treatment",tags:["skin","eye","zemaja","marine-mineral"],metadata:{key_ingredients:"Marine Peptides, Irish Moss (Sea Moss), Wild Geranium, Hyaluronic Acid",size:"0.5 oz / 15 mL",skin_type:"All skin types",usage:"Gently pat a small amount around the orbital bone morning and night. Avoid direct contact with the eyes.",certifications:ot,fulfillment:it,source_url:"https://www.zorganics.com/product-page/zemaja-ocean-mineral-eye-cream"}},{id:"retail-zemaja-ocean-mineral-mask",name:"Zemaja⢠Goddess Ocean Mineral Clay Mask",handle:"zemaja-ocean-mineral-mask",description:"A weekly marine clay treatment mask that infuses skin with a concentrated dose of ocean minerals. Organic Aloe and Sea Kelp flood the complexion with trace nutrients while clarifying clay smooths texture for an instantly radiant, replenished glow.",price:12e3,sku:"ZC-ZEM-MASK",inventory_qty:24,images:[rt("a90cca_a87f5ee6a6224ce6bc1eb1fa569fa088~mv2.png")],status:"active",has_variants:!1,vendor:"Zorganics Cosmetics",product_type:"Facial Mask",tags:["skin","mask","zemaja","marine-mineral","brightening"],metadata:{key_ingredients:"Organic Aloe, Sea Kelp, Irish Moss (Sea Moss), Kaolin Clay, Marine Peptides",size:"2 oz / 60 mL",skin_type:"All skin types",usage:"Apply an even layer to clean skin, leave on 10â15 minutes, then rinse with lukewarm water. Use 1â2 times weekly.",certifications:ot,fulfillment:it,source_url:"https://www.zorganics.com/product-page/zemaja-earth-ocean-mineral-clay-mask-w-organic-aloe-sea-kelp"}},{id:"retail-zemaja-ocean-mineral-exfoliant",name:"Zemaja⢠Goddess Facial Scrub",handle:"zemaja-ocean-mineral-exfoliant",description:"A gentle marine facial scrub that polishes away dull surface cells to reveal fresher, brighter skin. Fine sea-mineral micro-grains and botanical extracts smooth texture while Sea Moss and Aloe keep skin calm and hydrated, never raw.",price:6e3,sku:"ZC-ZEM-EXFOL",inventory_qty:26,images:[rt("a90cca_7ac3918a017c4121bc803ce5bea87c11~mv2.jpg")],status:"active",has_variants:!1,vendor:"Zorganics Cosmetics",product_type:"Exfoliant",tags:["skin","exfoliant","zemaja","marine-mineral","brightening"],metadata:{key_ingredients:"Sea-mineral micro-grains, Irish Moss (Sea Moss), Aloe Vera, Wild Geranium",size:"1.7 oz / 50 mL",skin_type:"All skin types",usage:"Massage gently onto damp skin 2â3 times weekly, then rinse. Follow with toner, serum, and moisturizer.",certifications:ot,fulfillment:it,source_url:"https://www.zorganics.com/product-page/zemaja-goddess-facial-scrub"}},{id:"retail-zemaja-ocean-mineral-system",name:"Zemaja⢠Ocean Mineral Facial Kit",handle:"zemaja-ocean-mineral-complete-system",description:"The complete Zemaja⢠Goddess ritual in one curated facial kit â the full marine-mineral regimen built on Irish Moss, Wild Geranium, Sea Kelp, and Marine Peptides for radiant, balanced, glowing skin.",price:9999,sku:"ZC-ZEM-SYSTEM",inventory_qty:18,images:[rt("590572_ebd8e0b8e5444ae5af603f280d06b9c5~mv2.png")],status:"active",has_variants:!1,vendor:"Zorganics Cosmetics",product_type:"Skin Care",tags:["featured","bestseller","skin","zemaja","marine-mineral","kit"],metadata:{key_ingredients:"Irish Moss (Sea Moss), Wild Geranium, Sea Kelp, Marine Peptides, MSM, Rosehip Seed Oil, Hyaluronic Acid",size:"Full ritual facial kit",skin_type:"All skin types",finish:"Radiant",usage:"Use the full ritual morning and night: Cleanse â Tone â Serum â Moisturize â Eye, with the Mask & Scrub 1â2à weekly.",certifications:ot,fulfillment:it,source_url:"https://www.zorganics.com/product-page/zemaja-ocean-mineral-kit"}}],q2=[{id:"col-skin",title:"Skin Care",handle:"skin",description:"Botanical skin formulations",is_visible:!0},{id:"col-hair",title:"Hair Care",handle:"hair",description:"Scalp & hair health",is_visible:!0},{id:"col-body",title:"Body Care",handle:"body",description:"Restorative body rituals",is_visible:!0},{id:"col-makeup",title:"Mineral Makeup",handle:"mineral-makeup",de
1189scription:"Clean-beauty color",is_visible:!0},{id:"col-dry-dehydrated",title:"Malouwa⢠Hydration â Dry & Dehydrated Skin",handle:"dry-dehydrated",description:"The Malouwa⢠pH-balancing hydration ritual â botanical formulations for dry, dehydrated, and sensitive skin.",is_visible:!0},{id:"col-sensitive-reactive",title:"Malouwa⢠Hydration â Sensitive & Reactive Skin",handle:"sensitive-reactive",description:"Gentle, pH-optimized Malouwa⢠formulations that calm and replenish sensitive, reactive, dehydrated skin.",is_visible:!0},{id:"col-zemaja-goddess-ocean-mineral",title:"Zemaja⢠Goddess · Ocean Mineral",handle:"zemaja-goddess-ocean-mineral",description:"The Zemaja⢠Goddess marine-mineral collection â 8 ocean-sourced formulations with Irish Moss, Spirulina, Wild Geranium & Marine Peptides for radiant, balanced, glowing skin.",is_visible:!0}],jY={"col-skin":["retail-malouwa-ph-hydration-system","retail-malouwa-cleanser","retail-malouwa-toner","retail-malouwa-serum","retail-malouwa-lotion","retail-malouwa-eye-treatment","retail-longal-oxygen-cleanser","retail-longal-oxygen-serum","retail-longal-oxygen-moisturizer","retail-zycolics-derm-toner","retail-zycolics-derm-exfoliant","retail-zycolics-derm-night-cream","retail-wotani-bright-serum","retail-wotani-bright-cream","retail-zycolics-derm-facial-cleanser","retail-ibaa-skin-perfecting-toner","retail-zemaja-ocean-mineral-serum","retail-zemaja-ocean-mineral-cleanser","retail-zemaja-ocean-mineral-toner","retail-zemaja-ocean-mineral-moisturizer","retail-zemaja-ocean-mineral-eye","retail-zemaja-ocean-mineral-mask","retail-zemaja-ocean-mineral-exfoliant","retail-zemaja-ocean-mineral-system"],"col-dry-dehydrated":["retail-malouwa-ph-hydration-system","retail-malouwa-cleanser","retail-malouwa-toner","retail-malouwa-serum","retail-malouwa-lotion","retail-malouwa-eye-treatment"],"col-sensitive-reactive":["retail-malouwa-ph-hydration-system","retail-malouwa-cleanser","retail-malouwa-toner","retail-malouwa-serum","retail-malouwa-lotion","retail-malouwa-eye-treatment"],"col-zemaja-goddess-ocean-mineral":["retail-zemaja-ocean-mineral-serum","retail-zemaja-ocean-mineral-cleanser","retail-zemaja-ocean-mineral-toner","retail-zemaja-ocean-mineral-moisturizer","retail-zemaja-ocean-mineral-eye","retail-zemaja-ocean-mineral-mask","retail-zemaja-ocean-mineral-exfoliant","retail-zemaja-ocean-mineral-system"],"col-hair":["retail-linamissa-scalp-elixir"],"col-body":["retail-natae-foot-therapy","retail-ojawei-shave-system","retail-ojawei-aftershave-toner"],"col-makeup":["retail-pure-matte-foundation","retail-dual-mineral-foundation","retail-liquid-foundation-ivory","retail-liquid-foundation-goddess","retail-liquid-foundation-toffee","retail-liquid-foundation-cafe","retail-liquid-foundation-sunkissed","retail-liquid-foundation-natural","retail-liquid-foundation-latte","retail-liquid-foundation-porcelain","retail-luxe-bullet-lipstick","retail-long-lasting-liquid-lipstick","retail-matte-lip-stick","retail-matte-lip-stick-6","retail-matte-lip-stick-10","retail-lip-shine-miss-lady","retail-lip-shine-darling","retail-velvet-lip-gloss-03","retail-velvet-lip-gloss-08","retail-velvet-lip-gloss-14","retail-velvet-lip-gloss-16","retail-velvet-lip-gloss-23"]},W2=[{name:"Ivory",handle:"zorganics-liquid-foundation-in-ivory",hex:"#F2D7BE"},{name:"Porcelain",handle:"zorganics-liquid-foundation-in-porcelain",hex:"#F6E0CB"},{name:"Natural",handle:"zorganics-liquid-foundation-in-natural",hex:"#E8C2A0"},{name:"Latté",handle:"zorganics-liquid-foundation-in-latte",hex:"#D6A77E"},{name:"Sunkissed",handle:"zorganics-liquid-foundation-in-sunkissed",hex:"#C68E64"},{name:"Toffee",handle:"zorganics-liquid-foundation-in-toffee",hex:"#A9714B"},{name:"Café",handle:"zorganics-liquid-foundation-in-cafe",hex:"#855537"},{name:"Goddess",handle:"zorganics-liquid-foundation-in-goddess",hex:"#5E3A24"}],wY=new Set(W2.map(t=>t.handle)),F3=t=>!!t&&wY.has(t),NY=(t,s=130)=>t.length<=s?t:`${t.slice(0,s).replace(/\s+\S*$/,"")}â¦`,_Y=t=>t?t.split(",").map(s=>s.replace(/\([^)]*\)/g,"").trim().toLowerCase()).filter(s=>s.length>2).slice(0,10):[],kY=t=>`$${(t/100).toFixed(2)}`,SY=Eh.map(t=>({id:`commerce-${t.id}`,title:t.name,description:`${kY(t.price)} · ${t.product_type} â ${NY(t.description)}`,keywords:[...new Set([...t.tags.map(s=>s.toLowerCase().replace(/-/g," ")),t.product_type.toLowerCase(),..._Y(t.metadata.key_ingredients),...t.metadata.skin_type?[t.metadata.skin_type.toLowerCase()]:[],...t.metadata.finish?[t.metadata.finish.toLowerCase()]:[],"cosmetics","product","vegan","organic"])],category:"Cosmetics & Shopping",href:`/products/${t.handle}`})),CY=q2.filter(t=>t.is_visible).map(t=>({id:`collection-${t.id}`,title:`${t.title} â Collection`,description:t.description,keywords:[...t.title.toLowerCase().split(/[\s·â-]+/).filter(s=>s.length>2),t.handle.replace(/-/g," "),"collection","category","shop","products"],category:"Cosmetics & Shopping",href:`/collections/${t.handle}`})),AY=[{id:"ing-hyaluronic",title:"Hyaluronic Acid â Ingredient Guide",description:"Multi-depth hydration that plumps dehydration lines. Featured in the Malouwa⢠pH-Balancing Hyaluronic Serum.",keywords:["hyaluronic acid","hydration","plumping","ingredient","ha"],category:"Cosmetics & Shopping",href:"/products/malouwa-hydration-ph-balancing-hyaluronic-serum"},{id:"ing-sea-moss",title:"Irish Moss (Sea Moss) â Ingredient Guide",description:"Ocean-sourced trace minerals for radiance and barrier balance. The heart of the Zemaja⢠Goddess Ocean Mineral collection.",keywords:["irish moss","sea moss","marine","ocean mineral","ingredient","chondrus"],category:"Cosmetics & Shopping",href:"/collections/zemaja-goddess-ocean-mineral"},{id:"ing-vitamin-c",title:"Vitamin C â Ingredient Guide",description:"Brightens dullness and evens tone. Featured in the Wotani⢠Bright Skin Vitamin C Serum.",keywords:["vitamin c","brightening","dark spots","ascorbyl","ingredient"],category:"Cosmetics & Shopping",href:"/products/wotani-bright-skin-vitamin-c-serum"},{id:"ing-glycolic",title:"Glycolic Acid â Ingredient Guide",description:"Professional-grade exfoliation for deep clinical cleansing. Featured in the Zycolics⢠Derm Facial Cleanser.",keywords:["glycolic acid","aha","exfoliation","resurfacing","ingredient"],category:"Cosmetics & Shopping",href:"/products/zycolics-derm-facial-cleanser"},{id:"ing-niacinamide",title:"Niacinamide â Ingredient Guide",description:"Barrier support, pore refinement and tone balancing across the Malouwa⢠and Wotani⢠lines.",keywords:["niacinamide","vitamin b3","pores","barrier","ingredient"],category:"Cosmetics & Shopping",href:"/collections/skin"},{id:"ing-saw-palmetto",title:"Saw Palmetto & Scalp Botanicals â Ingredient Guide",description:"Follicular-environment support for fuller-looking hair. Featured in the Linamissa⢠Regenerative Scalp Elixir.",keywords:["saw palmetto","scalp","hair growth","skullcap","ingredient"],category:"Cosmetics & Shopping",href:"/products/linamissa-regenerative-scalp-elixir-2-oz"},{id:"ing-aloe",title:"Organic Aloe Vera â Ingredient Guide",description:"Soothing, pH-friendly hydration for sensitive and reactive skin throughout the Malouwa⢠Hydration ritual.",keywords:["aloe","aloe vera","soothing","sensitive skin","ingredient"],category:"Cosmetics & Shopping",href:"/collections/sensitive-reactive"}],EY=[{id:"routine-builder",title:"Routine Builder â Build Your AM/PM Skincare Routine",description:"Compose a personalized 5-step morning and evening regimen â Cleanser â Toner â Serum â Moisturizer â Eye â from the Zorganics catalog.",keywords:["routine","routine builder","skincare routine","regimen","am pm","morning routine","night routine","build routine","5 step"],category:"Cosmetics & Shopping",href:"/routine-builder"},{id:"routine-subscribe",title:"Subscribe & Save 15% â Monthly Routine Delivery",description:"Turn your routine into a monthly delivery and save 15% on every refill with the Subscriber tier.",keywords:["subscribe","subscription","save 15","monthly delivery","refill","auto ship","discount"],category:"Cosmetics & Shopping",href:"/routine-builder"},{id:"routine-anti-aging",title:"Anti-Aging Routine â Pre-Made Template",description:"A ready-made firming and renewal regimen â start from the Anti-Aging template in the Routine Builder and customize each step.",keywords:["anti-aging","anti aging","wrinkles","fine lines","firming","mature skin","routine"],category:"Cosmetics & Shopping",href:"/routine-builder"},{id:"routine-hydration",title:"Hydration Routine â Pre-Made Template",description:"A moisture-first regimen for dry, dehydrated skin built around the Malouwa⢠Hydration ritual.",keywords:["hydration routine","dry skin","dehydrated","moisture","plumping","rout
1189ine"],category:"Cosmetics & Shopping",href:"/routine-builder"},{id:"routine-quiz",title:"Find My Routine â Skin Concern Quiz",description:"Answer a few questions about your skin and get a matched AM/PM routine recommendation.",keywords:["quiz","skin quiz","find my routine","skin type","recommendation","match"],category:"Cosmetics & Shopping",href:"/routine-builder"},{id:"edu-layering",title:"How to Layer Skincare â Product Education",description:"The dermatologist-canonical order: Cleanser â Toner â Serum â Moisturizer â Eye. Learn what each step does in the Routine Builder.",keywords:["layering","skincare order","how to apply","what order","steps","education"],category:"Cosmetics & Shopping",href:"/routine-builder"},{id:"edu-clean-beauty",title:"Clean Beauty Standards â Vegan, Organic & Non-Toxic",description:"Every Zorganics formulation is 100% vegan, certified organic and non-toxic. Explore the certified catalog.",keywords:["clean beauty","vegan","certified organic","non-toxic","cruelty free","standards","education"],category:"Cosmetics & Shopping",section:"shop"},{id:"edu-foundation-shades",title:"Foundation Shade Matching â Mineral Makeup Guide",description:"Liquid foundation shade swatches with accurate skin-tone approximations â find your shade on any foundation product page.",keywords:["foundation shade","shade match","skin tone","swatch","mineral makeup","liquid foundation"],category:"Cosmetics & Shopping",section:"shop"}],FY=[{id:"svc-student-haircut",title:"Student Salon â Haircuts & Styling",description:"Flat-rate supervised student haircuts and styling at student pricing in the Student Training Clinic.",keywords:["haircut","hair cut","trim","blow dry","styling","student salon","cheap haircut"],category:"Salon & Med Spa",section:"student-clinic"},{id:"svc-student-facial",title:"Student Salon â Facials & Skin Treatments",description:"Supervised student facials, botanical skin treatments and exfoliation services at student pricing.",keywords:["facial","facials","skin treatment","student facial","exfoliation"],category:"Salon & Med Spa",section:"student-clinic"},{id:"svc-student-nails",title:"Student Salon â Manicures & Pedicures",description:"Supervised student nail services â manicures, pedicures, gel and nail art at student pricing.",keywords:["manicure","pedicure","nails","gel nails","nail art","mani pedi"],category:"Salon & Med Spa",section:"student-clinic"},{id:"svc-student-waxing",title:"Student Salon â Waxing Services",description:"Supervised student waxing and hair-removal services at student pricing.",keywords:["waxing","wax","brow wax","hair removal"],category:"Salon & Med Spa",section:"student-clinic"},{id:"svc-clinic-booking",title:"Book a Student Clinic Appointment (Thu & Fri)",description:"Live availability for supervised student clinic services â Thursdays & Fridays.",keywords:["book appointment","clinic booking","reserve","schedule service","thursday","friday"],category:"Salon & Med Spa",section:"student-clinic"},{id:"svc-zoras-menu",title:"Zora's Styling Salon & Spa â Professional Services",description:"Licensed professional salon & spa services at Zora's Styling Salon â hair, skin, and body rituals by licensed professionals (not a student clinic).",keywords:["zoras salon","professional salon","salon services","spa services","licensed stylist"],category:"Salon & Med Spa",section:"salon-services"},{id:"svc-zoras-color",title:"Zora's Salon â Color, Balayage & Blowouts",description:"Professional organic color services, balayage, blowouts and event styling at Zora's Styling Salon.",keywords:["color","balayage","highlights","blowout","hair color","organic salon"],category:"Salon & Med Spa",section:"zoras-salon"},{id:"svc-zoras-bridal",title:"Zora's Salon â Bridal & Event Styling",description:"Bridal packages, updos and special-event beauty services by licensed professionals.",keywords:["bridal","wedding","updo","event styling","prom"],category:"Salon & Med Spa",section:"zoras-salon"},{id:"svc-medspa-consultation",title:"Med Spa â Personalized Skin & Wellness Consultation",description:"The one place to begin at Zorganics Med Spa. A private consultation where your specialist builds a personalized treatment plan for you.",keywords:["consultation","consult","med spa","medspa","skin consultation","wellness consultation","book","appointment","treatment plan","skin analysis","assessment"],category:"Salon & Med Spa",section:"med-spa-portal"},{id:"svc-medspa-face",title:"Med Spa â Face Concerns",description:"Non-surgical facial rejuvenation, fine lines, skin tightening, pigmentation, acne and scarring, texture and pores, redness and sensitivity â addressed through a personalized plan.",keywords:["face","facial rejuvenation","wrinkles","fine lines","skin tightening","firmness","pigmentation","uneven tone","melasma","acne","acne scars","texture","pores","redness","rosacea","sensitive skin","anti-aging"],category:"Salon & Med Spa",section:"med-spa-portal"},{id:"svc-medspa-body",title:"Med Spa â Body Concerns",description:"Abdomen, back, thighs, arms, body tightening, body contouring, skin texture, cellulite concerns and post-weight-loss skin changes â reviewed in consultation.",keywords:["body","abdomen","stomach","back","thighs","arms","body tightening","body contouring","contour","cellulite","post weight loss","skin laxity","firming"],category:"Salon & Med Spa",section:"med-spa-portal"},{id:"svc-medspa-wellness",title:"Med Spa â Wellness & Skincare Guidance",description:"Skin health education, professional skincare guidance, botanical skincare recommendations and lifestyle wellness support.",keywords:["wellness","skin health","skincare guidance","botanical skincare","lifestyle","education","home care","rout
1189ine"],category:"Salon & Med Spa",section:"med-spa-portal"},{id:"svc-menu-pricing",title:"Full Service Menu & Pricing",description:"The complete professional services menu with pricing across salon and med spa.",keywords:["service menu","price list","pricing","services list","how much"],category:"Salon & Med Spa",section:"professional-services"}],TY=[...FY,...CY,...SY,...AY,...EY],xI=[{id:"home",title:"Zorganics Institute â Home",description:"Luxury clinical beauty academy · NACCAS accredited · Bellingham Campus, WA",keywords:["home","homepage","academy","school","beauty school","institute","zorganics"],category:"Institute",section:"campus-home"},{id:"our-story",title:"Our Story",description:"The history and organizational philosophy of the Zorganics ecosystem",keywords:["about","about us","history","mission","frida","founder"],category:"Institute",section:"our-story"},{id:"ecosystem",title:"Zorganics Ecosystem",description:"Explore every brand in the Zorganics family â Institute, Cosmetics, Salon, Med Spa & Foundation",keywords:["ecosystem","brands","companies","explore","family"],category:"Institute",section:"ecosystem"},{id:"program-profiles",title:"Program Profiles â All Licensed Programs",description:"Detailed profiles for every licensed program: hours, curriculum, career pathways and admissions requirements",keywords:["programs","courses","curriculum","training","profiles"],category:"Programs",href:"/programs"},{id:"prog-cosmetology",title:"Cosmetologist Program (1,600 hrs)",description:"Full-spectrum beauty training â hair, skin, nails and salon business management",keywords:["cosmetologist","cosmetology","hair","stylist","1600","hybrid"],category:"Programs",href:"/programs/cosmetology"},{id:"prog-master-esthetics",title:"Master Esthetician Program (1,200 hrs)",description:"Advanced clinical modalities â laser, chemical peels, microneedling",keywords:["master esthetician","master esthetics","laser","peels","microneedling","1200","clinical"],category:"Programs",href:"/master-esthetics"},{id:"prog-esthetics",title:"Esthetician Program (750 hrs)",description:"Foundational clinical skincare, facial treatments and organic botanical formulation",keywords:["esthetician","esthetics","skincare","facials","750"],category:"Programs",href:"/esthetics-program"},{id:"prog-manicurist",title:"Manicurist Program (600 hrs)",description:"Nail technology, gel & acrylic systems, nail art and sanitation protocols",keywords:["manicurist","nails","nail tech","nail technology","gel","acrylic","600"],category:"Programs",href:"/programs/manicurist"},{id:"prog-instructor",title:"Instructor Program (600 hrs)",description:"Educator training for currently-licensed beauty professionals",keywords:["instructor","teacher","educator","teaching"],category:"Programs",href:"/programs/instructor-training"},{id:"prog-bridge",title:"Master Esthetician 450 Bridge (450 hrs)",description:"Accelerated bridge for licensed Estheticians upgrading to Master Esthetician licensure",keywords:["bridge","450","advanced master","advanced master esthetics","upgrade","licensed esthetician","master esthetician bridge"],category:"Programs",href:"/programs/master-esthetician-bridge"},{id:"admissions",title:"Admissions",description:"Enrollment requirements, start dates and the full program portfolio",keywords:["admissions","enroll","enrollment","requirements","start dates","register"],category:"Admissions & Financial Aid",section:"admissions"},{id:"apply-now",title:"Apply Now",description:"Start your application to Zorganics Institute",keywords:["apply","application","sign up","join"],category:"Admissions & Financial Aid",section:"apply-now"},{id:"tour-booking",title:"Book a Campus Tour",description:"Schedule an in-person tour with live availability and reminders",keywords:["tour","visit","campus tour","schedule","book"],category:"Admissions & Financial Aid",section:"tour-booking"},{id:"financial-aid",title:"Financial Aid & Scholarships",description:"Federal aid & FAFSA, Zorganics Foundation scholarships, Washington state & workforce funding, and veterans education benefits",keywords:["financial aid","fafsa","pell","grants","loans","wioa","gi bill","va","veterans","tuition","scholarships","scholarship","funding","wasfa","washington college grant","
1189worksource"],category:"Admissions & Financial Aid",href:"/financial-aid"},{id:"consumer-information",title:"Consumer Information & Student Disclosures",description:"Official institutional policies and required disclosures â Title IV rights, SAP, R2T4, FERPA, cost of attendance and outcomes",keywords:["consumer information","disclosures","policies","sap","r2t4","ferpa","title iv","rights","outcomes","compliance"],category:"Admissions & Financial Aid",href:"/consumerinformation"},{id:"net-price",title:"Net Price Calculator",description:"Estimate your real cost of attendance after aid",keywords:["net price","calculator","cost","price","estimate"],category:"Admissions & Financial Aid",href:"/consumerinformation"},{id:"school-catalog",title:"School Catalog",description:"The official institutional catalog â policies, programs and academic standards",keywords:["catalog","handbook","policies","sap"],category:"Admissions & Financial Aid",href:"/school-catalog"},{id:"security-report",title:"Annual Security Report",description:"Clery Act campus safety and security disclosures",keywords:["security","safety","clery","crime","report"],category:"Admissions & Financial Aid",href:"/annual-security-report"},{id:"salon-services",title:"Zora's Styling Salon & Spa â Professional Services",description:"Professional salon & spa services by licensed professionals â hair, skin and body rituals",keywords:["salon","services","zoras","professional salon","spa","appointment","booking","licensed"],category:"Salon & Med Spa",section:"salon-services"},{id:"student-clinic",title:"Student Salon & Clinic â Supervised Students (Thu & Fri)",description:"Supervised student services at student pricing â hair, skin, nails under licensed-instructor supervision",keywords:["clinic","student clinic","student salon","haircut","facial","thursday","friday","book","student pricing"],category:"Salon & Med Spa",section:"student-clinic"},{id:"zoras-salon",title:"Zora's Styling Salon (Professional Portal)",description:"Full-service professional organic salon â styling, nails, facials and bridal by licensed professionals",keywords:["zora","zoras","styling","professional salon","bridal","blowout"],category:"Salon & Med Spa",section:"zoras-salon"},{id:"med-spa",title:"Zorganics Med Spa",description:"Consultation-first luxury wellness â begin with a Personalized Skin & Wellness Consultation",keywords:["med spa","medspa","medical spa","consultation","consult","skin","wellness","treatment plan","appointment"],category:"Salon & Med Spa",section:"med-spa-portal"},{id:"professional-services",title:"All Professional Services",description:"The complete professional services menu across salon and med spa",keywords:["professional","services","menu","pricing"],category:"Salon & Med Spa",section:"professional-services"},{id:"my-appointments",title:"My Appointments",description:"Look up, manage or cancel your salon bookings",keywords:["appointments","my booking","cancel","reschedule"],category:"Salon & Med Spa",href:"/my-appointments"},{id:"shop",title:"Zorganics Cosmetics â Shop",description:"Vegan, organic, non-toxic clinical beauty products â skin, hair, body & mineral makeup",keywords:["shop","cosmetics","products","skincare","makeup","vegan","organic","buy","store","malouwa","lifita","wealei"],category:"Cosmetics & Shopping",section:"shop"},{id:"wholesale",title:"Wholesale & Professional Accounts",description:"Zorganics Cosmetics wholesale for salons, spas & licensed professionals â partner pricing on skin, hair, body and mineral makeup",keywords:["wholesale","b2b","professional account","salon account","spa account","bulk","trade","partner pricing","distributor","retailer"],category:"Cosmetics & Shopping",section:"wholesale"},{id:"routine-builder",title:"Skincare Routine Builder",description:"Compose your AM/PM 5-step regimen with product recommendations and checkout",keywords:["routine","regimen","skin analysis","recommendation","builder","skincare routine"],category:"Cosmetics & Shopping",href:"/routine-builder"}
1189,{id:"rewards",title:"PUREBenefit⢠Rewards",description:"The Zorganics loyalty program â earn points on every purchase",keywords:["rewards","loyalty","points","purebenefit","benefits"],category:"Cosmetics & Shopping",section:"pure-benefit-rewards"},{id:"foundation-landing",title:"The Zorganics Foundation",description:"501(c)(3) public charity â scholarships, oncology esthetics and beauty with purpose",keywords:["foundation","charity","nonprofit","501c3","scholarship","giving"],category:"Foundation",section:"foundation-landing"},{id:"foundation-mission",title:"Foundation â Our Mission",description:"Programs, impact and the Foundation hub",keywords:["mission","impact","oncology","research garden"],category:"Foundation",section:"foundation"},{id:"foundation-donate",title:"Donate to the Foundation",description:"Support our mission with a tax-deductible one-time or recurring gift",keywords:["donate","donation","give","gift","support","contribute"],category:"Foundation",section:"foundation-donate"},{id:"foundation-gift-shop",title:"Foundation Gift Shop",description:"Shop the Foundation collection â every purchase funds scholarships",keywords:["gift shop","merchandise","merch","foundation shop"],category:"Foundation",section:"foundation-gift-shop"},{id:"gala",title:"Annual Industry Gala & Fundraiser",description:"The Beauty With Purpose gala and Foundation fundraising events",keywords:["gala","events","fundraiser","tickets","benefit"],category:"Foundation",section:"gala-fundraiser"},{id:"village-map",title:"Vertical Village Map",description:"Explore the Forest St campus â studios, clinic suites, housing and bistro",keywords:["village","map","campus","forest st","building","locations"],category:"Campus & Village",section:"village-map"},{id:"housing",title:"Student Housing",description:"On-campus housing options for enrolled students",keywords:["housing","dorm","apartment","live","residence"],category:"Campus & Village",section:"housing"},{id:"bistro",title:"Z-Bistro & Café",description:"The campus bistro â menu, smoothies and café hours",keywords:["bistro","cafe","coffee","food","menu","smoothie","lunch"],category:"Campus & Village",section:"hospitality"},{id:"contact",title:"Contact Us",description:"Phone, email, campus address and inquiry form â Bellingham Campus (active) · Renton Coming Soon · Seattle Coming 2027",keywords:["contact","phone","email","address","directions","location","hours"],category:"Contact & Resources",section:"contact-us"},{id:"news-press",title:"News & Press",description:"Institute announcements and media coverage of our programs, campus and community",keywords:["news","press","media","press release","announcements","coverage","newsroom","articles","updates"],category:"Contact & Resources",href:"/news"},{id:"privacy",title:"Privacy Policy",description:"How we collect, use and protect your information",keywords:["privacy","policy","data","gdpr","ferpa"],category:"Contact & Resources",href:"/privacy-policy"},{id:"verify-transcript",title:"Verify a Transcript",description:"Employers & licensing boards: verify an official Zorganics transcript",keywords:["verify","transcript","verification","credentials"],category:"Contact & Resources",href:"/verify-transcript"},{id:"employer-onboarding",title:"Employers & Industry Partners",description:"Register your salon or spa to post jobs and connect with graduates",keywords:["employer","hire","jobs","partner","industry","recruiting","graduates"],category:"Contact & Resources",section:"employer-onboarding"},{id:"student-portal",title:"Student Portal (ZLP) â Sign In",description:"Secure sign-in for enrolled students â hours, grades, documents and progress",keywords:["student portal","zlp","login","sign in","student login"],category:"Secure Portals",section:"student-portal"},{id:"scholar-portal",title:"Z-LMS Scholar Portal â Sign In",description:"Secure learning management system for students and instructors",keywords:["lms","z-lms","scholar","learning","courses login"],category:"Secure Portals",href:"/scholar"},{id:"donor-portal",title:"Foundation Donor Portal â Sign In",description:"Manage your recurring gifts and download giving statements",keywords:["donor","donor portal","giving history","re
1189ceipts"],category:"Secure Portals",href:"/foundation/donor"}];function PY(t){if(t.href)return t.href;if(t.section){const s=Yb(t.section);return s||`/?section=${t.section}`}return"/"}function T3(t,s){const n=t.title.toLowerCase(),a=t.description.toLowerCase();let r=0;for(const i of s)n.startsWith(i)?r+=10:n.includes(i)&&(r+=6),t.keywords.some(o=>o===i)?r+=8:t.keywords.some(o=>o.includes(i))&&(r+=4),a.includes(i)&&(r+=2);return r}function fI(t,s=8){const n=t.trim().toLowerCase();if(n.length<2)return[];const a=n.split(/\s+/).filter(Boolean),r=[];for(const i of xI){const o=T3(i,a);o>0&&r.push({...i,score:o+2})}for(const i of TY){const o=T3(i,a);o>0&&r.push({...i,score:o})}return r.sort((i,o)=>o.score-i.score).slice(0,s)}const DY={"our-story":[{label:"Institute",section:"campus-home"},{label:"Our Story"}],ecosystem:[{label:"Institute",section:"campus-home"},{label:"Ecosystem"}],admissions:[{label:"Institute",section:"campus-home"},{label:"Admissions"}],"apply-now":[{label:"Institute",section:"campus-home"},{label:"Admissions",section:"admissions"},{label:"Apply Now"}],"tour-booking":[{label:"Institute",section:"campus-home"},{label:"Admissions",section:"admissions"},{label:"Book a Tour"}],"program-profiles":[{label:"Institute",section:"campus-home"},{label:"Programs",section:"admissions"},{label:"Program Profiles"}],"program-detail":[{label:"Institute",section:"campus-home"},{label:"Programs",section:"admissions"},{label:"Program Details"}],"master-esthetics-1200":[{label:"Institute",section:"campus-home"},{label:"Programs",section:"admissions"},{label:"Master Esthetician (1,200h)"}],"master-bridge":[{label:"Institute",section:"campus-home"},{label:"Programs",section:"admissions"},{label:"450h Master Esthetics Bridge"}],"contact-us":[{label:"Institute",section:"campus-home"},{label:"Contact Us"}],"salon-services":[{label:"Salon & Spa",section:"salon-services"},{label:"Zora's Professional Services"}],"student-clinic":[{label:"Institute",section:"campus-home"},{label:"Student Salon & Clinic (Supervised Students)"}],"zoras-salon":[{label:"Salon & Spa",section:"salon-services"},{label:"Zora's Styling Salon"}],"med-spa-portal":[{label:"Salon & Spa",section:"salon-services"},{label:"Zorganics Med Spa"}],"professional-services":[{label:"Salon & Spa",section:"salon-services"},{label:"All Professional Services"}],shop:[{label:"Cosmetics",section:"shop"},{label:"Shop All Products"}],wholesale:[{label:"Cosmetics",section:"shop"},{label:"Wholesale & Professional Accounts"}],"pure-benefit-rewards":[{label:"Cosmetics",section:"shop"},{label:"PUREBenefit⢠Rewards"}],"foundation-landing":[{label:"Foundation"}],foundation:[{label:"Foundation",section:"foundation-landing"},{label:"Our Mission"}],"foundation-donate":[{label:"Foundation",section:"foundation-landing"},{label:"Donate"}],"foundation-gift-shop":[{label:"Foundation",section:"foundation-landing"},{label:"Gift Shop"}],"gala-fundraiser":[{label:"Foundation",section:"foundation-landing"},{label:"Gala & Events"}],"village-map":[{label:"Vertical Village"}],housing:[{label:"Vertical Village",section:"village-map"},{label:"Student Housing"}],hospitality:[{label:"Vertical Village",section:"village-map"},{label:"Z-Bistro & Café"}],"bistro-menu":[{label:"Vertical Village",section:"village-map"},{label:"Z-Bistro Quick Order"}],events:[{label:"Foundation",section:"foundation-landing"},{label:"Events"}],"employer-onboarding":[{label:"Institute",section:"campus-home"},{label:"Employers & Partners"}]};function RY(t){return DY[t]||null}const Yf={Institute:"#800020",Programs:"#B8962E","Admissions & Financial Aid":"#2D6B3E","Salon & Med Spa":"#7A3A44","Cosmetics & Shopping":"#B8860B",Foundation:"#4A1942","Campus & Village":"#2D5016","Contact & Resources":"#5A1A24","Secure Portals":"#3B0A11"},P3=({query:t,onSelect:s,onClose:n,variant:a="overlay"})=>{const r=d.useMemo(()=>fI(t,10),[t]);if(t.trim().length<2)return null;const i=a==="overlay"?"absolute left-0 right-0 top-full mt-1.5 rounded-xl shadow-2xl overflow-hidden z-[70] animate-in fade-in slide-in-from-top-2 duration-150":"mt-2 rounded-xl overflow-hidden border";return e.jsxs("div",{className:i,style:{background:"#FFFFFF",border:"1px solid rgba(212,175,55,0.35)"},role:"listbox","aria-label":"Site search results",children:[e.jsxs("div",{className:"px-3 py-1.5 flex items-center gap-1.5",style:{background:"linear-gradient(135deg, #3B0A11 0%, #5A1A24 100%)"},children:[e.jsx(Bt,{size:10,style:{color:"#D4AF37"}}),e.jsx("span",{className:"text-[9px] font-bold uppercase tracking-[0.14em]",style:{color:"#E6D2A0"},children:"Site Directory"}),e.jsxs("span",{className:"ml-auto text-[9px]",style:{color:"rgba(230,210,160,0.6)"},children:[r.length," ",r.length===1?"match":"matches"]})]}),r.length===0?e.jsxs("div",{className:"px-4 py-5 text-center",children:[e.jsxs("p",{className:"text-xs font-semibold",style:{color:"#3B0A11"},children:["No matches for â",t.trim(),"â"]}
1189),e.jsx("p",{className:"text-[10px] mt-1 text-gray-400",children:"Try âprogramsâ, âfinancial aidâ, âmed spaâ, âcosmeticsâ, or âdonateâ â or browse the full site map."})]}):e.jsx("div",{className:"max-h-[340px] overflow-y-auto py-1",children:r.map(o=>e.jsxs("button",{onClick:()=>s(o),className:"flex items-start gap-3 w-full px-3.5 py-2.5 text-left transition-colors group hover:bg-[rgba(212,175,55,0.08)]",role:"option","aria-selected":!1,children:[e.jsx("div",{className:"mt-0.5 w-7 h-7 rounded-lg flex items-center justify-center flex-shrink-0",style:{background:"rgba(59,10,17,0.05)",color:Yf[o.category]},children:e.jsx(Vt,{size:13,className:"group-hover:translate-x-0.5 transition-transform"})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("p",{className:"text-[13px] font-bold truncate",style:{color:"#3B0A11"},children:o.title}),e.jsx("span",{className:"flex-shrink-0 text-[8px] font-bold uppercase tracking-wider px-1.5 py-0.5 rounded-full",style:{color:Yf[o.category],background:`${Yf[o.category]}12`,border:`1px solid ${Yf[o.category]}30`},children:o.category})]}),e.jsx("p",{className:"text-[10px] mt-0.5 leading-snug text-gray-500 line-clamp-2",children:o.description})]})]},o.id))}),e.jsxs("div",{className:"px-3.5 py-2 flex items-center justify-between",style:{background:"rgba(245,235,208,0.5)",borderTop:"1px solid rgba(212,175,55,0.2)"},children:[e.jsxs(be,{to:"/sitemap",onClick:n,className:"flex items-center gap-1.5 text-[10px] font-bold uppercase tracking-wider transition-colors hover:text-[#D4AF37]",style:{color:"#800020"},children:[e.jsx(qP,{size:11})," Browse the full Site Map"]}),e.jsx("span",{className:"text-[9px] text-gray-400",children:"Public pages only"})]})]})},gI="zip_employer_workspace_token",T5="zlp_auto_redirect_done",H2="zip-workspace-auth",IY=()=>{try{window.dispatchEvent(new Event(H2))}catch{}},D3=()=>{try{return!!sessionStorage.getItem(gI)}catch{return!1}},$Y=()=>{try{sessionStorage.removeItem(gI)}catch{}IY()},zY=()=>{try{return sessionStorage.getItem(T5)==="1"}catch{return!1}},LY=()=>{try{sessionStorage.setItem(T5,"1")}catch{}},G2=()=>{try{sessionStorage.removeItem(T5)}catch{}},OY=t=>/^\d{5}(-\d{4})?$/.test(t.trim()),Lhe=t=>{const s=(t||"").trim();if(!s)return'Location is required (city, state â e.g., "Bellingham, WA 98225").';if(s.length<2)return"Please enter a full city / location.";const n=s.match(/\b\d{3,10}(-\d{1,6})?\b/g)||[];for(const a of n)if(!OY(a))return`"${a}" is not a valid US ZIP code â use 5 digits (e.g., 98225) or ZIP+4.`;return null},jv="https://d64gsuwffb70l.cloudfront.net/69cae7fb5ea7db794957149e_1775337912224_4cc82887.jfif",MY=({size:t="md",variant:s="full",moduleName:n,moduleSubtitle:a,className:r=""})=>{const o={sm:{logo:"w-8 h-8",text:"text-sm",sub:"text-[9px]"},md:{logo:"w-10 h-10",text:"text-lg",sub:"text-[10px]"},lg:{logo:"w-14 h-14",text:"text-2xl",sub:"text-xs"}}[t];return s==="mark"?e.jsx("div",{className:`${o.logo} rounded-lg overflow-hidden shadow-md flex-shrink-0 ${r}`,children:e.jsx("img",{src:jv,alt:"Zorganics",className:"w-full h-full object-cover"})}):s==="module"?e.jsxs("div",{className:`flex items-center gap-3 ${r}`,children:[e.jsx("div",{className:`${o.logo} rounded-lg overflow-hidden shadow-md flex-shrink-0 ring-2 ring-gold/20`,children:e.jsx("img",{src:jv,alt:"Zorganics",className:"w-full h-full object-cover"})}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("div",{className:"flex items-center gap-2",children:e.jsx("h1",{className:`font-display ${o.text} font-bold text-gray-900 leading-tight`,children:n||"Zorganics"})}),a&&e.jsx("p",{className:`${o.sub} text-gray-400 font-medium tracking-wider uppercase -mt-0.5`,children:a})]})]}):e.jsxs("div",{className:`flex items-center gap-3 ${r}`,children:[e.jsx("div",{className:`${o.logo} rounded-lg overflow-hidden shadow-md flex-shrink-0`,children:e.jsx("img",{src:jv,alt:"Zorganics",className:"w-full h-full object-cover"})}),e.jsxs("div",{className:"hidden sm:block",children:[e.jsxs("h1",{className:`font-display ${o.text} font-extrabold leading-tight tracking-tight`,style:{color:"#3B0A11",textShadow:"0 1px 0 rgba(230,210,160,0.45), 0 0 1px rgba(212,175,55,0.35)",WebkitTextStroke:"0.3px rgba(59,10,17,0.6)"},children:["Zorganics",e.jsx("span",{style:{color:"#3B0A11",textShadow:"0 1px 0 rgba(230,210,160,0.55), 0 0 6px rgba(212,175,55,0.25)",marginLeft:"4px",fontWeight:900},children:"Institute"})]}),e.jsx("p",{className:`${o.sub} font-bold tracking-[0.18em] uppercase -mt-0.5`,style:{color:"#3B0A11",textShadow:"0 1px 0 rgba(230,210,160,0.5)"},children:"Beauty & Wellness Education"})]})]})},P5="#4A1942",oh="#2E0A2A",BY="#6B2961",UY="#8B5A7B",qY="#D6EBF7",WY="#EAF4FB",HY="#C9D9EB",Wy="#D4AF37",GY="#C49C2E",Jc="#E6D2A0",ku="#B8962E",VY="#6B5A6B",ZY="#8B7A8E",rd="#FBF8F2",YY="#1A0F18",KY="#F2F8FC",QY="#0B3D2E",k="#3B0A11",$="#D4AF37",JY="#800020",XY="#D4AF37",eK="#F7E7CE";
1189function D5(t){switch(t){case"foundation":return{burgundy:P5,burgundyDeep:oh,burgundyMid:BY,burgundySoft:UY,sage:qY,sageLight:WY,sageBorder:HY,gold:Wy,goldHover:GY,goldLight:Jc,goldDeep:ku,textMuted:VY,textSoft:ZY,cream:rd,ink:YY,skyHero:KY};case"institute":return{forest:QY,plum:k,gold:$};case"cosmetics":return{burgundy:JY,gold:XY,champagne:eK};default:{const s=t;throw new Error(`Unknown brand palette: ${String(s)}`)}}}D5("foundation");D5("institute");D5("cosmetics");const Ex=({isOpen:t,onClose:s})=>{const{signIn:n}=kn(),[a,r]=d.useState(""),[i,o]=d.useState(""),[l,c]=d.useState(!1),[u,p]=d.useState(!1),[m,x]=d.useState(""),[h,y]=d.useState(!1);if(!t)return null;const v=()=>{r(""),o(""),x(""),y(!1),c(!1)},g=async N=>{if(N.preventDefault(),x(""),p(!0),!a||!i){x("Please enter both email and password."),p(!1);return}const b=await n(a,i);p(!1),b.success?(y(!0),setTimeout(()=>{s(),v()},1200)):x(b.error||"Sign in failed.")};return e.jsxs("div",{className:"fixed inset-0 z-[60] flex items-center justify-center p-4",onClick:()=>{u||(s(),v())},children:[e.jsx("div",{className:"absolute inset-0 bg-black/30 backdrop-blur-sm"}),e.jsxs("div",{className:"relative bg-white rounded-2xl shadow-2xl w-full max-w-md overflow-hidden",onClick:N=>N.stopPropagation(),children:[e.jsxs("div",{className:"relative px-6 py-8 text-center",style:{background:`linear-gradient(135deg, ${k} 0%, #24060B 55%, ${k} 100%)`},children:[e.jsx("button",{onClick:()=>{u||(s(),v())},className:"absolute top-4 right-4 p-1.5 rounded-lg bg-white/10 hover:bg-white/20 transition-colors text-white/80 hover:text-white","aria-label":"Close sign-in",children:e.jsx(Ke,{size:18})}),e.jsx("div",{className:"flex justify-center mb-4",children:e.jsx("div",{className:"rounded-xl p-[3px] shadow-lg",style:{background:$},children:e.jsx(MY,{size:"lg",variant:"mark"})})}),e.jsx("h2",{className:"font-display text-lg sm:text-xl font-bold leading-snug",style:{color:rd},children:"Zorganics Institute of Beauty & Wellness"}),e.jsx("p",{className:"text-xs sm:text-sm font-semibold tracking-wide mt-1.5",style:{color:$},children:"Zorganics OS â Staff & Administration"})]}),h?e.jsxs("div",{className:"flex flex-col items-center py-12 px-6",children:[e.jsx("div",{className:"w-16 h-16 rounded-full bg-emerald-50 flex items-center justify-center mb-4 animate-in zoom-in duration-300",children:e.jsx(pt,{size:32,className:"text-emerald-600"})}),e.jsx("h3",{className:"font-display text-lg font-bold text-gray-900 mb-1",children:"Signed In Successfully!"}),e.jsx("p",{className:"text-sm text-gray-700",children:"Loading your dashboard..."})]}):e.jsxs("div",{className:"px-6 py-6 sm:px-7",children:[e.jsx("p",{className:"text-sm leading-relaxed text-gray-700 mb-5",children:"Sign in with your authorized Zorganics staff or administrator account."}),m&&e.jsxs("div",{className:"flex items-center gap-2 p-3 bg-red-50 border border-red-200 rounded-lg mb-4",children:[e.jsx(Mt,{size:16,className:"text-red-500 flex-shrink-0"}),e.jsx("p",{className:"text-sm text-red-700",children:m})]}),e.jsxs("form",{onSubmit:g,className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx("label",{htmlFor:"zos-staff-email",className:"text-sm font-semibold text-gray-800 mb-1.5 block",children:"Email Address"}),e.jsxs("div",{className:"relative",children:[e.jsx(Ye,{size:16,className:"absolute left-3.5 top-1/2 -translate-y-1/2 text-gray-500"}),e.jsx("input",{id:"zos-staff-email",type:"email",value:a,onChange:N=>r(N.target.value),placeholder:"[email protected]",className:"w-full pl-10 pr-4 py-2.5 border border-gray-300 rounded-lg text-sm text-gray-900 placeholder-gray-500 focus:outline-none focus:ring-2 focus:ring-gold/30 focus:border-gold transition-all",disabled:u})]})]}),e.jsxs("div",{children:[e.jsx("label",{htmlFor:"zos-staff-password",className:"text-sm font-semibold text-gray-800 mb-1.5 block",children:"Password"}),e.jsxs("div",{className:"relative",children:[e.jsx(Xe,{size:16,className:"absolute left-3.5 top-1/2 -translate-y-1/2 text-gray-500"}),e.jsx("input",{id:"zos-staff-password",type:l?"text":"password",value:i,onChange:N=>o(N.target.value),placeholder:"Enter password",className:"w-full pl-10 pr-10 py-2.5 border border-gray-300 rounded-lg text-sm text-gray-900 placeholder-gray-500 focus:outline-none focus:ring-2 focus:ring-gold/30 focus:border-gold transition-all",disabled:u}),e.jsx("button",{type:"button",onClick:()=>c(!l),className:"absolute right-3 top-1/2 -translate-y-1/2 text-gray-500 hover:text-gray-800 transition-colors","aria-label":l?"Hide password":"Show password",title:l?"Hide password":"Show password",children:l?e.jsx(Md,{size:16}):e.jsx(ms,{size:16})})]})]}),e.jsx("button",{type:"submit",disabled:u,className:"w-full py-3 rounded-lg text-sm font-bold tracking-wide shadow-md hover:brightness-110 transition-all disabled:opacity-50 disabled:cursor-not-allowed flex items-center justify-center gap-2",style:{background:k,color:rd,border:`1px solid ${$}`},children:u?e.jsxs(e.Fragment,{children:[e.jsx(de,{size:16,className:"animate-spin"}),"Signing In..."]}):"Sign In"}),e.jsx("div",{className:"text-center",children:e.jsxs("a",{href:"/staff/reset-password",className:"inline-flex items-center gap-1 text-xs font-semibold text-gray-600 hover:text-gray-900 transition-colors",children:[e.jsx(ka,{size:12})," Forgot password?"]})})]}),e.jsxs("div",{className:"mt-5 flex items-start gap-2 rounded-lg border border-gray-200 bg-stone-50 p-3",children:[e.jsx(Ie,{size:14,className:"mt-0.5 flex-shrink-0",style:{color:k}}),e.jsx("p",{className:"text-xs leading-relaxed text-gray-700",children:"Access is limited to authorized Zorganics staff and administrators."})]})]})]})]})},yI=d.createContext({activities:[],loading:!1,logActivity:async()=>{},fetchActivities:async()=>[],refreshActivities:async()=>{}}),tK=()=>d.useContext(yI),sK=({children:t})=>{const{user:s}
1189=kn(),[n,a]=d.useState([]),[r,i]=d.useState(!1),o=d.useCallback(async(u,p,m,x={})=>{if(s)try{const{data:h,error:y}=await O.from("user_activity_log").insert({user_id:s.id,user_email:s.email,action_type:u,section:p,description:m,metadata:x}).select().single();if(!y&&h){const v={id:h.id,userId:h.user_id,userEmail:h.user_email,actionType:h.action_type,section:h.section,description:h.description,metadata:h.metadata||{},createdAt:h.created_at};a(g=>[v,...g])}}catch(h){console.error("Error logging activity:",h)}},[s]),l=d.useCallback(async(u,p=50)=>{i(!0);try{let m=O.from("user_activity_log").select("*").order("created_at",{ascending:!1}).limit(p);u&&(m=m.eq("user_id",u));const{data:x,error:h}=await m;if(h)return console.error("Error fetching activities:",h),i(!1),[];const y=(x||[]).map(v=>({id:v.id,userId:v.user_id,userEmail:v.user_email,actionType:v.action_type,section:v.section,description:v.description,metadata:v.metadata||{},createdAt:v.created_at}));return a(y),i(!1),y}catch(m){return console.error("Error fetching activities:",m),i(!1),[]}},[]),c=d.useCallback(async()=>{s&&await l(s.id)},[s,l]);return e.jsx(yI.Provider,{value:{activities:n,loading:r,logActivity:o,fetchActivities:l,refreshActivities:c},children:t})},wv={assignment_posted:!0,grade_entered:!0,attendance_warning:!0,sap_checkpoint:!0,new_message:!0,ticket_updated:!0,calendar_reminder:!0,quiz_deadline:!0,milestone:!0,announcement:!0,system_alert:!0,email_enabled:!0,email_digest_frequency:"instant",quiet_hours_enabled:!1,quiet_hours_start:"22:00",quiet_hours_end:"07:00"},Kf=[{key:"assignment_posted",label:"New Assignments",description:"When new assignments or exams are posted to your courses",icon:e.jsx(Na,{size:18}),color:"text-blue-600",bg:"bg-blue-50",border:"border-blue-200",category:"academic"},{key:"grade_entered",label:"Grades Entered",description:"When instructors post grades for your assignments, exams, or quizzes",icon:e.jsx(_t,{size:18}),color:"text-emerald-600",bg:"bg-emerald-50",border:"border-emerald-200",category:"academic"},{key:"attendance_warning",label:"Attendance Alerts",description:"When your attendance drops below 85% (NACCAS compliance threshold)",icon:e.jsx(ve,{size:18}),color:"text-red-600",bg:"bg-red-50",border:"border-red-200",category:"compliance",critical:!0},{key:"sap_checkpoint",label:"SAP Checkpoint Alerts",description:"When you are within 50 hours of a 25%/50%/75% SAP review checkpoint",icon:e.jsx(Tt,{size:18}),color:"text-violet-600",bg:"bg-violet-50",border:"border-violet-200",category:"compliance",critical:!0},{key:"new_message",label:"New Messages",description:"When you receive direct messages from instructors or peers",icon:e.jsx(jr,{size:18}),color:"text-sky-600",bg:"bg-sky-50",border:"border-sky-200",category:"communication"},{key:"ticket_updated",label:"Help Desk Updates",description:"When your support tickets are updated or staff replies",icon:e.jsx(QP,{size:18}),color:"text-amber-600",bg:"bg-amber-50",border:"border-amber-200",category:"support"},{key:"calendar_reminder",label:"Calendar Reminders",description:"Reminders for upcoming exams, workshops, and scheduled events",icon:e.jsx(At,{size:18}),color:"text-pink-600",bg:"bg-pink-50",border:"border-pink-200",category:"scheduling"},{key:"quiz_deadline",label:"Quiz Deadlines",description:"Reminders when Z-LMS quiz deadlines are approaching",icon:e.jsx(dt,{size:18}),color:"text-orange-600",bg:"bg-orange-50",border:"border-orange-200",category:"academic"},{key:"milestone",label:"Milestone Achievements",description:"Celebrations when you reach hour milestones (100h, 250h, 500h, etc.)",icon:e.jsx(Is,{size:18}),color:"text-yellow-600",bg:"bg-yellow-50",border:"border-yellow-200",category:"achievements"},{key:"announcement",label:"Announcements",description:"Campus-wide announcements, closures, and important notices",icon:e.jsx(ix,{size:18}),color:"text-indigo-600",bg:"bg-indigo-50",border:"border-indigo-200",category:"general"},{key:"system_alert",label:"System Alerts",description:"Payment reminders, account updates, and system notifications",icon:e.jsx(kd,{size:18}),color:"text-gray-600",bg:"bg-gray-50",border:"border-gray-200",category:"system"}],nK=[{id:"academic",label:"Academic",icon:e.jsx(Na,{size:14})},{id:"compliance",label:"Compliance",icon:e.jsx(Tt,{size:14})},{id:"communication",label:"Communication",icon:e.jsx(jr,{size:14})},{id:"support",label:"Support",icon:e.jsx(QP,{size:14})},{id:"scheduling",label:"Scheduling",icon:e.jsx(At,{size:14})},{id:"achievements",label:"Achievements",icon:e.jsx(Is,{size:14})},{id:"general",label:"General",icon:e.jsx(ix,{size:14})},{id:"system",label:"System",icon:e.jsx(kd,{size:14})}],aK=({onClose:t})=>{const{student:s}
1189=ap(),[n,a]=d.useState(null),[r,i]=d.useState(!0),[o,l]=d.useState(!1),[c,u]=d.useState(!1),[p,m]=d.useState(!1),[x,h]=d.useState(!1),y=d.useCallback(async()=>{if(s){i(!0);try{const{data:S}=await O.from("z_student_notification_preferences").select("*").eq("student_id",s.studentId).maybeSingle();a(S||{student_id:s.studentId,student_account_id:s.id,...wv})}catch(S){console.error("Failed to load preferences:",S),a({student_id:s.studentId,...wv})}finally{i(!1)}}},[s]);d.useEffect(()=>{y()},[y]);const v=(S,w)=>{n&&(a({...n,[S]:w}),h(!0),u(!1))},g=async()=>{if(!(!n||!s)){l(!0);try{const S={student_id:s.studentId,student_account_id:s.id,assignment_posted:n.assignment_posted,grade_entered:n.grade_entered,attendance_warning:n.attendance_warning,sap_checkpoint:n.sap_checkpoint,new_message:n.new_message,ticket_updated:n.ticket_updated,calendar_reminder:n.calendar_reminder,quiz_deadline:n.quiz_deadline,milestone:n.milestone,announcement:n.announcement,system_alert:n.system_alert,email_enabled:n.email_enabled,email_digest_frequency:n.email_digest_frequency,quiet_hours_enabled:n.quiet_hours_enabled,quiet_hours_start:n.quiet_hours_start,quiet_hours_end:n.quiet_hours_end,updated_at:new Date().toISOString()},{error:w}=await O.from("z_student_notification_preferences").upsert(S,{onConflict:"student_id"});if(w)throw w;u(!0),h(!1)}catch(S){console.error("Failed to save preferences:",S)}finally{l(!1)}}},N=()=>{s&&(a({student_id:s.studentId,student_account_id:s.id,...wv}),h(!0),u(!1))},b=n?Kf.filter(S=>n[S.key]).length:0,f=Kf.length,j=S=>{if(!n)return;const w={...n};Kf.forEach(_=>{w[_.key]=S}),a(w),h(!0),u(!1)};return r?e.jsxs("div",{className:"flex items-center justify-center py-16",children:[e.jsx(de,{size:24,className:"animate-spin text-[#800020]"}),e.jsx("span",{className:"ml-3 text-sm text-gray-500",children:"Loading preferences..."})]}):n?e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"w-10 h-10 rounded-xl bg-gradient-to-br from-[#800020] to-[#5C0018] flex items-center justify-center shadow-md",children:e.jsx(Gl,{size:20,className:"text-white"})}),e.jsxs("div",{children:[e.jsx("h3",{className:"text-lg font-bold text-gray-900",style:{fontFamily:"Georgia, serif"},children:"Notification Preferences"}),e.jsxs("p",{className:"text-xs text-gray-500",children:[b,"/",f," notification types enabled"]})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[x&&e.jsx("span",{className:"text-[10px] font-semibold text-amber-600 bg-amber-50 px-2 py-1 rounded-full border border-amber-200",children:"Unsaved Changes"}),c&&e.jsxs("span",{className:"text-[10px] font-semibold text-emerald-600 bg-emerald-50 px-2 py-1 rounded-full border border-emerald-200 flex items-center gap-1",children:[e.jsx(pt,{size:10})," Saved"]})]})]}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[e.jsxs("div",{className:"p-4 rounded-xl border-2 border-[#800020]/10 bg-[#800020]/5",children:[e.jsxs("div",{className:"flex items-center justify-between mb-2",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[b===f?e.jsx(eM,{size:16,className:"text-[#800020]"}):e.jsx(tM,{size:16,className:"text-gray-400"}),e.jsx("span",{className:"text-sm font-bold text-gray-900",children:"In-App Notifications"})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("button",{onClick:()=>j(!0),className:"text-[10px] font-semibold text-[#800020] hover:underline",children:"Enable All"}),e.jsx("span",{className:"text-gray-300",children:"|"}),e.jsx("button",{onClick:()=>j(!1),className:"text-[10px] font-semibold text-gray-500 hover:underline",children:"Disable All"})]})]}),e.jsx("p",{className:"text-[10px] text-gray-500",children:"Control which notifications appear in your Student Portal notification center."})]}),e.jsxs("div",{className:"p-4 rounded-xl border-2 border-gray-100 bg-gray-50",children:[e.jsxs("div",{className:"flex items-center justify-between mb-2",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[n.email_enabled?e.jsx(Ye,{size:16,className:"text-blue-600"}):e.jsx(UP,{size:16,className:"text-gray-400"}),e.jsx("span",{className:"text-sm font-bold text-gray-900",children:"Email Notifications"})]}),e.jsx("button",{onClick:()=>v("email_enabled",!n.email_enabled),className:`relative w-11 h-6 rounded-full transition-colors ${n.email_enabled?"bg-[#800020]":"bg-gray-300"}`,children:e.jsx("div",{className:`absolute top-0.5 w-5 h-5 bg-white rounded-full shadow transition-transform ${n.email_enabled?"translate-x-[22px]":"translate-x-0.5"}`})})]}),e.jsx("p",{className:"text-[10px] text-gray-500",children:n.email_enabled?"Email alerts sent to your registered email address.":"Email notifications are disabled."}),n.email_enabled&&e.jsxs("div",{className:"mt-3 flex items-center gap-2",children:[e.jsx("span",{className:"text-[10px] text-gray-500 font-medium",children:"Frequency:"}),["instant","daily","weekly"].map(S=>e.jsx("button",{onClick:()=>
1189v("email_digest_frequency",S),className:`px-2.5 py-1 rounded-lg text-[10px] font-semibold transition-all ${n.email_digest_frequency===S?"bg-[#800020] text-white shadow-sm":"bg-white text-gray-500 border border-gray-200 hover:border-gray-300"}`,children:S.charAt(0).toUpperCase()+S.slice(1)},S))]})]})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsxs("h4",{className:"text-sm font-bold text-gray-700 uppercase tracking-wider flex items-center gap-2",children:[e.jsx(Pm,{size:14,className:"text-[#800020]"})," Notification Types"]}),nK.map(S=>{const w=Kf.filter(_=>_.category===S.id);return w.length===0?null:e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center gap-2 text-[10px] font-bold text-gray-400 uppercase tracking-widest",children:[S.icon,S.label]}),w.map(_=>{const C=n[_.key];return e.jsxs("div",{className:`flex items-center gap-4 p-3.5 rounded-xl border-2 transition-all ${C?`${_.bg} ${_.border}`:"bg-gray-50 border-gray-100 opacity-60"}`,children:[e.jsx("div",{className:`w-10 h-10 rounded-xl flex items-center justify-center shrink-0 ${C?_.bg:"bg-gray-100"} ${C?_.color:"text-gray-400"}`,children:_.icon}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:`text-sm font-semibold ${C?"text-gray-900":"text-gray-500"}`,children:_.label}),_.critical&&e.jsx("span",{className:"px-1.5 py-0.5 rounded text-[8px] font-bold bg-red-100 text-red-600 border border-red-200 uppercase",children:"Critical"})]}),e.jsx("p",{className:"text-[10px] text-gray-500 mt-0.5",children:_.description})]}),e.jsx("button",{onClick:()=>v(_.key,!C),className:`relative w-11 h-6 rounded-full transition-colors shrink-0 ${C?"bg-[#800020]":"bg-gray-300"}`,children:e.jsx("div",{className:`absolute top-0.5 w-5 h-5 bg-white rounded-full shadow transition-transform ${C?"translate-x-[22px]":"translate-x-0.5"}`})})]},_.key)})]},S.id)})]}),e.jsxs("div",{className:"border-2 border-gray-100 rounded-xl overflow-hidden",children:[e.jsxs("button",{onClick:()=>m(!p),className:"w-full flex items-center justify-between p-4 bg-gray-50 hover:bg-gray-100 transition-colors",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(ox,{size:16,className:"text-gray-500"}),e.jsx("span",{className:"text-sm font-semibold text-gray-700",children:"Quiet Hours"}),n.quiet_hours_enabled&&e.jsxs("span",{className:"text-[10px] font-semibold text-violet-600 bg-violet-50 px-2 py-0.5 rounded-full border border-violet-200",children:["Active: ",n.quiet_hours_start," â ",n.quiet_hours_end]})]}),p?e.jsx(Od,{size:16,className:"text-gray-400"}):e.jsx(Gt,{size:16,className:"text-gray-400"})]}),p&&e.jsxs("div",{className:"p-4 space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-semibold text-gray-700",children:"Enable Quiet Hours"}),e.jsx("p",{className:"text-[10px] text-gray-500",children:"Suppress non-urgent notifications during these hours"})]}),e.jsx("button",{onClick:()=>v("quiet_hours_enabled",!n.quiet_hours_enabled),className:`relative w-11 h-6 rounded-full transition-colors ${n.quiet_hours_enabled?"bg-[#800020]":"bg-gray-300"}`,children:e.jsx("div",{className:`absolute top-0.5 w-5 h-5 bg-white rounded-full shadow transition-transform ${n.quiet_hours_enabled?"translate-x-[22px]":"translate-x-0.5"}`})})]}),n.quiet_hours_enabled&&e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{children:[e.jsx("label",{className:"text-[10px] font-semibold text-gray-500 uppercase tracking-wider",children:"Start Time"}),e.jsxs("div",{className:"flex items-center gap-2 mt-1",children:[e.jsx(ox,{size:14,className:"text-violet-500"}),e.jsx("input",{type:"time",value:n.quiet_hours_start,onChange:S=>v("quiet_hours_start",S.target.value),className:"flex-1 px-3 py-2 border border-gray-200 rounded-lg text-sm focus:ring-2 focus:ring-[#800020]/20 focus:border-[#800020]"})]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-[10px] font-semibold text-gray-500 uppercase tracking-wider",children:"End Time"}),e.jsxs("div",{className:"flex items-center gap-2 mt-1",children:[e.jsx(Sd,{size:14,className:"text-amber-500"}),e.jsx("input",{type:"time",value:n.quiet_hours_end,onChange:S=>v("quiet_hours_end",S.target.value),className:"flex-1 px-3 py-2 border border-gray-200 rounded-lg text-sm focus:ring-2 focus:ring-[#800020]/20 focus:border-[#800020]"})]})]})]}),e.jsxs("div",{className:"flex items-start gap-2 p-3 bg-blue-50 rounded-lg border border-blue-200",children:[e.jsx(Bi,{size:14,className:"text-blue-600 shrink-0 mt-0.5"}),e.jsx("p",{className:"text-[10px] text-blue-700",children:"Urgent and critical notifications (attendance warnings, SAP alerts) will still be delivered during quiet hours to ensure compliance."})]})]})]}),e.jsxs("div",{className:"flex items-center justify-between pt-2",children:[e.jsxs("button",{onClick:N,className:"flex items-center gap-2 px-4 py-2.5 text-sm font-medium text-gray-500 bg-gray-100 rounded-xl hover:bg-gray-200 transition-colors",children:[e.jsx(zi,{size:14})," Reset to Defaults"]}),e.jsx("button",{onClick:g,disabled:o||!x,className:"flex items-center gap-2 px-6 py-2.5 text-sm font-bold text-white rounded-xl shadow-md transition-all disabled:opacity-50 disabled:cursor-not-allowed",style:{background:x?"linear-gradient(135deg, #800020, #5C0018)":"#9CA3AF"},children:o?e.jsxs(e.Fragment,{children:[e.jsx(de,{size:14,className:"animate-spin"})," Saving..."]}):c?e.jsxs(e.Fragment,{children:[e.jsx(pt,{size:14})," Saved"]}):e.jsxs(e.Fragment,{children:[e.jsx(ti,{size:14})," Save Preferences"]})})]})]}):null},R3={admin:{label:"Administrator",icon:e.jsx(Tt,{size:18}),color:"text-burgundy",bgColor:"bg-burgundy/10",borderColor:"border-burgundy/20",description:"Full system access with all read/write permissions across every section."},instructor:{label:"Instructor",icon:e.jsx(Na,{size:18}),color:"text-gold-dark",bgColor:"bg-gold/10",borderColor:"border-gold/20",description:"Access to student information, learning management, and staff portal."},staff:{label:"Staff",icon:e.jsx(ts,{size:18}),color:"text-blue-600",bgColor:"bg-blue-50",borderColor:"border-blue-200",description:"Access to student records, LMS, financial engine, and agency hub."}},Nv=[{id:"dashboard",label:"Program Dashboard (SIS)",icon:e.jsx(Q_,{size:16}),description:"Student records, enrollment, and program tracking"},{id:"lms",label:"Z-LMS",icon:e.jsx(Na,{size:16}),description:"Learning management, courses, and curriculum"},{id:"audit",label:"Audit Vault",icon:e.jsx(Tt,{size:16}),description:"Compliance documents, inspections, and audit trails"},{id:"financial",label:"Financial Engine",icon:e.jsx(Ro,{size:16}),description:"G5/FSA drawdowns, invoicing, and QuickBooks sync"},{id:"agency",label:"Agency Hub",icon:e.jsx(Ws,{size:16}),description:"NACCAS, BPPE, and regulatory agency management"},{id:"staff",label:"Staff Portal",icon:e.jsx(ts,{size:16}),description:"Training modules, job board, and HR management"},{id:"google",label:"Google Sync",icon:e.jsx(zP,{size:16}
1189),description:"Google Workspace integration and calendar sync"}],I3={admin:["dashboard","lms","audit","financial","agency","staff","google"],instructor:["dashboard","lms","staff"],staff:["dashboard","lms","financial","agency"]},rK={module_started:e.jsx(_t,{size:14,className:"text-blue-500"}),module_completed:e.jsx(xt,{size:14,className:"text-emerald-500"}),job_applied:e.jsx(IP,{size:14,className:"text-purple-500"}),invoice_created:e.jsx(Yx,{size:14,className:"text-gold-dark"}),g5_drawdown_created:e.jsx(Ro,{size:14,className:"text-emerald-600"}),document_uploaded:e.jsx(Ri,{size:14,className:"text-cyan-500"}),exception_reported:e.jsx(Mt,{size:14,className:"text-orange-500"}),report_filed:e.jsx(Kt,{size:14,className:"text-orange-500"}),drawdown_submitted:e.jsx(Ro,{size:14,className:"text-emerald-600"}),hours_logged:e.jsx(dt,{size:14,className:"text-indigo-500"}),profile_updated:e.jsx(yr,{size:14,className:"text-gray-500"}),signed_in:e.jsx(J_,{size:14,className:"text-green-500"}),signed_out:e.jsx(Xe,{size:14,className:"text-red-400"})},iK={dashboard:"bg-gold/10 text-gold-dark",lms:"bg-blue-50 text-blue-600",audit:"bg-burgundy/10 text-burgundy",financial:"bg-emerald-50 text-emerald-700",agency:"bg-purple-50 text-purple-600",staff:"bg-cyan-50 text-cyan-700",google:"bg-orange-50 text-orange-600",auth:"bg-gray-100 text-gray-600",profile:"bg-gray-100 text-gray-600"},oK=({isOpen:t,onClose:s,initialTab:n})=>{const{user:a,updateProfile:r}=kn(),{activities:i,loading:o,fetchActivities:l,logActivity:c}=tK(),[u,p]=d.useState("profile"),[m,x]=d.useState(!1),[h,y]=d.useState(""),[v,g]=d.useState(""),[N,b]=d.useState(!1),[f,j]=d.useState(""),[S,w]=d.useState(!1);if(d.useEffect(()=>{t&&a&&u==="activity"&&l(a.id,30)},[t,a,u,l]),d.useEffect(()=>{t&&a&&(y(a.fullName),g(a.avatarUrl||""),x(!1),j(""),w(!1),n&&p(n))},[t,a,n]),!t||!a)return null;const _=R3[a.role],C=I3[a.role]||[],E=V=>V.split(" ").map(B=>B[0]).join("").toUpperCase().slice(0,2),P=async()=>{if(b(!0),j(""),w(!1),!h.trim()){j("Name cannot be empty."),b(!1);return}const V={};if(h.trim()!==a.fullName&&(V.fullName=h.trim()),v.trim()!==(a.avatarUrl||"")&&(V.avatarUrl=v.trim()||void 0),Object.keys(V).length===0){x(!1),b(!1);return}const B=await r(V);b(!1),B.success?(w(!0),x(!1),await c("profile_updated","profile",`Updated profile: ${Object.keys(V).join(", ")}`),setTimeout(()=>w(!1),3e3)):j(B.error||"Failed to save changes.")},F=()=>{y(a.fullName),g(a.avatarUrl||""),x(!1),j("")},I=V=>{const B=new Date(V),z=new Date().getTime()-B.getTime(),M=Math.floor(z/6e4),R=Math.floor(z/36e5),T=Math.floor(z/864e5);return M<1?"Just now":M<60?`${M}m ago`:R<24?`${R}h ago`:T<7?`${T}d ago`:B.toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric"})},D=V=>new Date(V).toLocaleDateString("en-US",{weekday:"short",month:"short",day:"numeric",year:"numeric",hour:"numeric",minute:"2-digit"}),L=[{id:"profile",label:"Profile",icon:e.jsx(yr,{size:16})},{id:"activity",label:"Activity",icon:e.jsx(Ma,{size:16})},{id:"notifications",label:"Alerts",icon:e.jsx(Gl,{size:16})},{id:"permissions",label:"Permissions",icon:e.jsx(Tt,{size:16})}];return e.jsxs("div",{className:"fixed inset-0 z-[60] flex items-center justify-center p-4",onClick:s,children:[e.jsx("div",{className:"absolute inset-0 bg-black/30 backdrop-blur-sm"}),e.jsxs("div",{className:"relative bg-white rounded-2xl shadow-2xl w-full max-w-2xl max-h-[90vh] overflow-hidden flex flex-col",onClick:V=>V.stopPropagation(),children:[e.jsxs("div",{className:"relative bg-gradient-to-br from-gray-900 via-gray-800 to-gray-900 px-6 py-6",children:[e.jsx("button",{onClick:s,className:"absolute top-4 right-4 p-1.5 rounded-lg bg-white/10 hover:bg-white/20 transition-colors text-white/70 hover:text-white z-10",children:e.jsx(Ke,{size:18})}),e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsxs("div",{className:"relative group",children:[a.avatarUrl?e.jsx("img",{src:a.avatarUrl,alt:a.fullName,className:"w-16 h-16 rounded-xl object-cover ring-2 ring-white/20 shadow-lg",onError:V=>{var B;V.target.style.display="none",(B=V.target.nextElementSibling)==null||B.classList.remove("hidden")}}):null,e.jsx("div",{className:`w-16 h-16 rounded-xl bg-gradient-to-br from-gold to-gold-dark flex items-center justify-center ring-2 ring-white/20 shadow-lg ${a.avatarUrl?"hidden":""}`,children:e.jsx("span",{className:"text-white font-display font-bold text-xl",children:E(a.fullName)})}),m&&e.jsx("div",{className:"absolute inset-0 rounded-xl bg-black/40 flex items-center justify-center opacity-0 group-hover:opacity-100 transition-opacity cursor-pointer",children:e.jsx(rx,{size:20,className:"text-white"})})]}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("h2",{className:"font-display text-xl font-bold text-white truncate",children:a.fullName}),e.jsx("p",{className:"text-sm text-gray-400 truncate",children:a.email}),e.jsx("div",{className:"mt-2",children:e.jsxs("span",{className:`inline-flex items-center gap-1.5 px-2.5 py-1 rounded-full text-xs font-semibold border ${_.bgColor} ${_.color} ${_.borderColor}`,children:[_.icon,_.label]})})]})]}),e.jsx("div",{className:"flex gap-1 mt-5 -mb-6 px-0",children:L.map(V=>e.jsxs("button",{onClick:()=>p(V.id),className:`flex items-center gap-2 px-4 py-2.5 rounded-t-lg text-sm font-medium transition-all ${u===V.id?"bg-white text-gray-900 shadow-sm":"text-gray-400 hover:text-white hover:bg-white/10"}`,children:[V.icon,V.label]},V.id))})]}),e.jsxs("div",{className:"flex-1 overflow-y-auto",children:[u==="profile"&&e.jsxs("div",{className:"p-6",children:[S&&e.jsxs("div",{className:"flex items-center gap-2 p-3 bg-emerald-50 border border-emerald-200 rounded-lg mb-4 animate-in slide-in-from-top duration-300",children:[e.jsx(xt,{size:16,className:"text-emerald-600"}),e.jsx("p",{className:"text-sm text-emerald-700 font-medium",children:"Profile updated successfully!"})]}),f&&e.jsxs("div",{className:"flex items-center gap-2 p-3 bg-red-50 border border-red-200 rounded-lg mb-4",children:[e.jsx(Mt,{size:16,className:"text-red-500"}),e.jsx("p",{className:"text-sm text-red-700",children:f})]}),e.jsxs("div",{className:"space-y-5",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("h3",{className:"font-display text-lg font-bold text-gray-900",children:"Profile Details"}),m?e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("button",{onClick:F,disabled:N,className:"px-3 py-1.5 text-sm font-medium text-gray-500 hover:bg-gray-50 rounded-lg transition-colors border border-gray-200 disabled:opacity-50",children:"Cancel"}),e.jsxs("button",{onClick:P,disabled:N,className:"flex items-center gap-2 px-3 py-1.5 text-sm font-semibold text-white bg-gradient-to-r from-gold-dark to-gold rounded-lg shadow-sm hover:shadow-md transition-all disabled:opacity-50",children:[N?e.jsx(de,{size:14,className:"animate-spin"}):e.jsx(xt,{size:14}),N?"Saving...":"Save Changes"]})]}):e.jsxs("button",{onClick:()=>x(!0),className:"flex items-center gap-2 px-3 py-1.5 text-sm font-medium text-gold-dark hover:bg-gold/5 rounded-lg transition-colors border border-gold/20",children:[e.jsx(u2,{size:14}),"Edit Profile"]})]}),e.jsxs("div",{className:"bg-gray-50 rounded-xl p-4 border border-gray-100",children:[e.jsx("label",{className:"text-xs font-semibold text-gray-400 uppercase tracking-wider mb-2 block",children:"Full Name"}),m?e.jsxs("div",{className:"relative",children:[e.jsx(yr,{size:16,className:"absolute left-3 top-1/2 -translate-y-1/2 text-gray-400"}),e.jsx("input",{type:"text",value:h,onChange:V=>y(V.target.value),className:"w-full pl-10 pr-4 py-2.5 bg-white border border-gray-200 rounded-lg text-sm font-medium focus:outline-none focus:ring-2 focus:ring-gold/30 focus:border-gold transition-all",placeholder:"Enter your full name"})]}):e.jsx("p",{className:"text-base font-semibold text-gray-900",children:a.fullName})]}),e.jsxs("div",{className:"bg-gray-50 rounded-xl p-4 border border-gray-100",children:[e.jsx("label",{className:"text-xs font-semibold text-gray-400 uppercase tracking-wider mb-2 block",children:"Email Address"}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Ye,{size:16,className:"text-gray-400"}),e.jsx("p",{className:"text-base text-gray-900",children:a.email})]}),e.jsx("p",{className:"text-[11px] text-gray-400 mt-1",children:"Email cannot be changed. Contact an administrator for assistance."})]}),e.jsxs("div",{className:"bg-gray-50 rounded-xl p-4 border border-gray-100",children:[e.jsx("label",{className:"text-xs font-semibold text-gray-400 uppercase tracking-wider mb-2 block",children:"Avatar URL"}),m?e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"relative",children:[e.jsx(rx,{size:16,className:"absolute left-3 top-1/2 -translate-y-1/2 text-gray-400"}
1189),e.jsx("input",{type:"url",value:v,onChange:V=>g(V.target.value),className:"w-full pl-10 pr-4 py-2.5 bg-white border border-gray-200 rounded-lg text-sm focus:outline-none focus:ring-2 focus:ring-gold/30 focus:border-gold transition-all",placeholder:"https://example.com/avatar.jpg"})]}),v&&e.jsxs("div",{className:"flex items-center gap-3 p-3 bg-white rounded-lg border border-gray-200",children:[e.jsx("img",{src:v,alt:"Preview",className:"w-10 h-10 rounded-lg object-cover",onError:V=>{V.target.src="",V.target.alt="Invalid URL"}}),e.jsx("span",{className:"text-xs text-gray-500",children:"Avatar preview"})]})]}):e.jsx("p",{className:"text-sm text-gray-600",children:a.avatarUrl||"No custom avatar set"})]}),e.jsxs("div",{className:"bg-gray-50 rounded-xl p-4 border border-gray-100",children:[e.jsx("label",{className:"text-xs font-semibold text-gray-400 uppercase tracking-wider mb-2 block",children:"Role"}),e.jsx("div",{className:"flex items-center gap-3",children:e.jsxs("span",{className:`inline-flex items-center gap-1.5 px-3 py-1.5 rounded-lg text-sm font-semibold border ${_.bgColor} ${_.color} ${_.borderColor}`,children:[_.icon,_.label]})}),e.jsx("p",{className:"text-[11px] text-gray-400 mt-2",children:_.description}),e.jsx("p",{className:"text-[11px] text-gray-400 mt-1",children:"Role changes require administrator approval."})]}),e.jsxs("div",{className:"bg-gray-50 rounded-xl p-4 border border-gray-100",children:[e.jsx("label",{className:"text-xs font-semibold text-gray-400 uppercase tracking-wider mb-2 block",children:"Account Information"}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-xs text-gray-400",children:"User ID"}),e.jsxs("p",{className:"text-sm font-mono text-gray-600 truncate",children:[a.id.slice(0,12),"..."]})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-xs text-gray-400",children:"Auth ID"}),e.jsxs("p",{className:"text-sm font-mono text-gray-600 truncate",children:[a.authId.slice(0,12),"..."]})]})]})]})]})]}),u==="activity"&&e.jsxs("div",{className:"p-6",children:[e.jsxs("div",{className:"flex items-center justify-between mb-5",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"font-display text-lg font-bold text-gray-900",children:"Recent Activity"}),e.jsx("p",{className:"text-sm text-gray-500",children:"Your actions across all sections"})]}),e.jsxs("button",{onClick:()=>l(a.id,30),disabled:o,className:"flex items-center gap-2 px-3 py-1.5 text-sm font-medium text-gray-500 hover:bg-gray-50 rounded-lg transition-colors border border-gray-200 disabled:opacity-50",children:[e.jsx(Be,{size:14,className:o?"animate-spin":""}),"Refresh"]})]}),o?e.jsxs("div",{className:"flex flex-col items-center justify-center py-12",children:[e.jsx(de,{size:32,className:"text-gold animate-spin mb-3"}),e.jsx("p",{className:"text-sm text-gray-500",children:"Loading activity log..."})]}):i.length===0?e.jsxs("div",{className:"flex flex-col items-center justify-center py-12 text-center",children:[e.jsx("div",{className:"w-16 h-16 rounded-2xl bg-gray-100 flex items-center justify-center mb-4",children:e.jsx(Ma,{size:28,className:"text-gray-300"})}),e.jsx("h4",{className:"font-semibold text-gray-700 mb-1",children:"No Activity Yet"}),e.jsx("p",{className:"text-sm text-gray-400 max-w-sm",children:"Your actions across the platform will appear here. Start by exploring the dashboard, creating invoices, or uploading documents."})]}):e.jsx("div",{className:"space-y-1",children:i.map(V=>e.jsxs("div",{className:"flex items-start gap-3 p-3 rounded-lg hover:bg-gray-50 transition-colors group",children:[e.jsx("div",{className:"w-8 h-8 rounded-lg bg-gray-100 flex items-center justify-center flex-shrink-0 mt-0.5 group-hover:bg-white group-hover:shadow-sm transition-all",children:rK[V.actionType]||e.jsx(Ma,{size:14,className:"text-gray-400"})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"text-sm text-gray-800 leading-snug",children:V.description}),e.jsxs("div",{className:"flex items-center gap-2 mt-1.5",children:[e.jsx("span",{className:`inline-flex items-center px-1.5 py-0.5 rounded text-[10px] font-semibold ${iK[V.section]||"bg-gray-100 text-gray-500"}`,children:V.section.charAt(0).toUpperCase()+V.section.slice(1)}),e.jsxs("span",{className:"text-[11px] text-gray-400 flex items-center gap-1",children:[e.jsx(dt,{size:10}),I(V.createdAt)]})]})]}),e.jsx("div",{className:"hidden group-hover:block",children:e.jsx("p",{className:"text-[10px] text-gray-400 whitespace-nowrap",children:D(V.createdAt)})})]},V.id))})]}),u==="notifications"&&e.jsxs("div",{className:"p-6",children:[e.jsxs("div",{className:"mb-5",children:[e.jsx("h3",{className:"font-display text-lg font-bold text-gray-900",children:"Notification Preferences"}),e.jsx("p",{className:"text-sm text-gray-500",children:"Choose which alerts you want to re
1189ceive and how"})]}),e.jsx(aK,{})]}),u==="permissions"&&e.jsxs("div",{className:"p-6",children:[e.jsxs("div",{className:"mb-5",children:[e.jsx("h3",{className:"font-display text-lg font-bold text-gray-900",children:"Role-Based Permissions"}),e.jsxs("p",{className:"text-sm text-gray-500",children:["Section access based on your ",e.jsx("span",{className:"font-semibold",children:_.label})," role"]})]}),e.jsxs("div",{className:`rounded-xl p-4 border mb-6 ${_.bgColor} ${_.borderColor}`,children:[e.jsxs("div",{className:"flex items-center gap-3 mb-2",children:[e.jsx("div",{className:`w-10 h-10 rounded-lg bg-white/80 flex items-center justify-center ${_.color}`,children:_.icon}),e.jsxs("div",{children:[e.jsx("h4",{className:`font-semibold text-sm ${_.color}`,children:_.label}),e.jsxs("p",{className:"text-xs text-gray-500",children:[C.length," of ",Nv.length," sections accessible"]})]})]}),e.jsx("p",{className:"text-xs text-gray-600 mt-1",children:_.description})]}),e.jsx("div",{className:"space-y-2",children:Nv.map(V=>{const B=C.includes(V.id);return e.jsxs("div",{className:`flex items-center gap-3 p-3.5 rounded-xl border transition-all ${B?"bg-white border-gray-100 hover:border-emerald-200 hover:bg-emerald-50/30":"bg-gray-50/50 border-gray-100 opacity-60"}`,children:[e.jsx("div",{className:`w-8 h-8 rounded-lg flex items-center justify-center flex-shrink-0 ${B?"bg-emerald-100 text-emerald-600":"bg-gray-100 text-gray-400"}`,children:B?e.jsx(J_,{size:14}):e.jsx(Xe,{size:14})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-gray-500",children:V.icon}),e.jsx("h5",{className:`text-sm font-semibold ${B?"text-gray-900":"text-gray-500"}`,children:V.label})]}),e.jsx("p",{className:"text-xs text-gray-400 mt-0.5",children:V.description})]}),e.jsx("div",{className:"flex-shrink-0",children:B?e.jsxs("span",{className:"inline-flex items-center gap-1 px-2 py-1 rounded-md text-[10px] font-semibold bg-emerald-50 text-emerald-700 border border-emerald-200",children:[e.jsx(xt,{size:10}),"Read & Write"]}):e.jsxs("span",{className:"inline-flex items-center gap-1 px-2 py-1 rounded-md text-[10px] font-semibold bg-gray-100 text-gray-400 border border-gray-200",children:[e.jsx(Xe,{size:10}),"No Access"]})})]},V.id)})}),e.jsxs("div",{className:"mt-6 p-4 bg-gray-50 rounded-xl border border-gray-100",children:[e.jsx("h4",{className:"text-xs font-semibold text-gray-500 uppercase tracking-wider mb-3",children:"Permission Levels by Role"}),e.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-3 gap-3",children:["admin","instructor","staff"].map(V=>{const B=R3[V],A=I3[V],z=V===a.role;return e.jsxs("div",{className:`p-3 rounded-lg border ${z?`${B.bgColor} ${B.borderColor} ring-2 ring-offset-1 ${B.borderColor}`:"bg-white border-gray-100"}`,children:[e.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[e.jsx("span",{className:B.color,children:B.icon}),e.jsx("span",{className:`text-xs font-semibold ${z?B.color:"text-gray-700"}`,children:B.label}),z&&e.jsx("span",{className:"text-[9px] font-bold bg-white/80 px-1.5 py-0.5 rounded-full text-gray-500",children:"YOU"})]}),e.jsx("div",{className:"flex flex-wrap gap-1",children:Nv.map(M=>e.jsx("span",{className:`px-1.5 py-0.5 rounded text-[9px] font-medium ${A.includes(M.id)?"bg-emerald-50 text-emerald-700 border border-emerald-200":"bg-gray-50 text-gray-300 border border-gray-100"}`,children:M.label.split(" ")[0]},M.id))})]},V)})})]})]})]})]})]})},_v=[{code:"en",label:"English",flag:"ðºð¸",nativeLabel:"English"},{code:"es",label:"Spanish",flag:"ðªð¸",nativeLabel:"Español"},{code:"fr",label:"French",flag:"ð«ð·",nativeLabel:"Français"}],$3={en:{"portal.welcome":"Welcome","portal.overview":"Overview","portal.hoursLog":"Hours Log","portal.attendance":"Attendance","portal.grades":"Grades","portal.exams":"Z-LMS Exams","portal.badges":"Badges","portal.sap":"SAP Compliance","portal.disclosures":"Consumer Disclosures","portal.transcript":"Transcript","portal.certificate":"Phase 1 Certificate","portal.logout":"Sign Out","portal.totalHours":"Total Hours","portal.gpa":"GPA","portal.theoryAvg":"Theory Avg","portal.milestones":"Milestones","portal.quickActions":"Quick Actions","portal.hourBreakdown":"Hour Breakdown","portal.studentInfo":"Student Information","portal.theory":"Theory","portal.practical":"Practical","portal.overallProgress":"Overall Progress","portal.programCompletion":"Program Completion","portal.weeksEnrolled":"Weeks Enrolled","portal.avgHoursWeek":"Avg Hours/Week","portal.meetsReq":"Meets requirement","portal.belowReq":"Below requirement","portal.passing":"Passing","portal.honorRoll":"Honor Roll","portal.needsWork":"Needs work","portal.runningStartReport":"Running Start Quarterly Report","lms.title":"Z-LMS","lms.subtitle":'"Knowledge Injection"',"lms.chapters":"Chapters","lms.mockExam":"Mock Exam","lms.progress":"Progress","lms.curriculumProgress":"Curriculum Progress","lms.completed":"Complete","lms.inProgress":"In Progress","lms.notStarted":"Not Started","lms.voiceGuide":"Voice Guide","lms.selectChapter":"Select a chapter to begin a timed practice exam with voice feedback","lms.startExam":"Start Mock Exam","lms.retake":"Retake","lms.allChapters":"All Chapters","lms.congratulations":"Congratulations!","lms.keepPracticing":"Keep Practicing","lms.correct":"Correct","lms.score":"Score","lms.timeUsed":"Time Used","lms.confirm":"Confirm","lms.next":"Next","lms.previous":"Previous","lms.finish":"Finish","lms.remaining":"remaining","lms.keyTopics":"Key Topics","lms.resources":"Resources","lms.details":"Details","lms.totalProgress":"Total Progress","lms.chaptersComplete":"Chapters Complete","lms.examsTaken":"Exams Taken","lms.avgExamScore":"Avg Exam Score","common.search":"Search","common.close":"Close","common.save":"Save","common.cancel":"Cancel","common.loading":"Loading...","common.error":"Error","common.success":"Success","common.language":"Language","common.of":"of","common.hours":"hours","common.minutes":"minutes","common.weeks":"weeks","common.days":"days","common.enrolled":"Enrolled","common.status":"Status","common.program":"Program","common.email":"Email","common.phone":"Phone","common.studentId":"Student ID"},es:{"portal.welcome":"Bienvenido/a","portal.overview":"Resumen","portal.hoursLog":"Registro de Horas","portal.attendance":"Asistencia","portal.grades":"Calificaciones","portal.exams":"Exámenes Z-LMS","portal.badges":"Insignias","portal.sap":"Cumplimiento SAP","portal.disclosures":"Divulgaciones al Consumidor","portal.transcript":"Expediente Académico","portal.certificate":"Certificado Fase 1","portal.logout":"Cerrar Sesión","portal.totalHours":"Horas Totales","portal.gpa":"Promedio","portal.theoryAvg":"Promedio Teórico","portal.milestones":"Hitos","portal.quickActions":"Acciones Rápidas","portal.hourBreakdown":"Desglose de Horas","portal.studentInfo":"Información del Estudiante","portal.theory":"TeorÃa","portal.practical":"Práctica","portal.overallProgress":"Progreso General","portal.programCompletion":"Finalización del Programa","portal.weeksEnrolled":"Semanas Inscrito","portal.avgHoursWeek":"Horas/Semana Promedio","portal.meetsReq":"Cumple requisito","portal.belowReq":"Por debajo del requisito","portal.passing":"Aprobando","portal.honorRoll":"Cuadro de Honor","portal.needsWork":"Necesita mejorar","portal.runningStartReport":"Informe Trimestral Running Start","lms.title":"Z-LMS","lms.subtitle":'"Inyección de Conocimiento"',"lms.chapters":"CapÃtulos","lms.mockExam":"Examen de Práctica","lms.progress":"Progreso","lms.curriculumProgress":"Progreso del CurrÃculo","lms.completed":"Completado","lms.inProgress":"En Progreso","lms.notStarted":"No Iniciado","lms.voiceGuide":"GuÃa de Voz","lms.selectChapter":"Seleccione un capÃtulo para comenzar un examen cronometrado con retroalimentación de voz","lms.startExam":"Iniciar Examen","lms.retake":"Reintentar","lms.allChapters":"Todos los CapÃtulos","lms.congratulations":"¡Felicitaciones!","lms.keepPracticing":"Sigue Practicando","lms.correct":"Correcto","lms.score":"Puntuación","lms.timeUsed":"Tiempo Usado","lms.confirm":"Confirmar","lms.next":"Siguiente","lms.previous":"Anterior","lms.finish":"Finalizar","lms.remaining":"restante","lms.keyTopics":"Temas Clave","lms.resources":"Recursos","lms.details":"Detalles","lms.totalProgress":"Progreso Total","lms.chaptersComplete":"CapÃtulos Completos","lms.examsTaken":"Exámenes Realizados","lms.avgExamScore":"Promedio de Exámenes","common.search":"Buscar","common.close":"Cerrar","common.save":"Guardar","common.cancel":"Cancelar","common.loading":"Cargando...","common.error":"Error","common.success":"Ãxito","common.language":"Idioma","common.of":"de","common.hours":"horas","common.minutes":"minutos","common.weeks":"semanas","common.days":"dÃas","common.enrolled":"Inscrito","common.status":"Estado","common.program":"Programa","common.email":"Correo","common.phone":"Teléfono","common.studentId":"ID de Estudiante"},fr:{"portal.welcome":"Bienvenue","portal.overview":"Aperçu","portal.hoursLog":"Journal des Heures","portal.attendance":"Présence","portal.grades":"Notes","portal.exams":"Examens Z-LMS","portal.badges":"Badges","portal.sap":"Conformité SAP","portal.disclosures":"Informations Consommateur","portal.transcript":"Relevé de Notes","portal.certificate":"Certificat Phase 1","portal.logout":"Déconnexion","portal.totalHours":"Heures Totales","portal.gpa":"Moyenne","portal.theoryAvg":"Moyenne Théorique","portal.milestones":"Jalons","portal.quickActions":"Actions Rapides","portal.hourBreakdown":"Répartition des Heures","portal.studentInfo":"Informations de l'Ãtudiant","portal.theory":"Théorie","portal.practical":"Pratique","portal.overallProgress":"Progrès Global","portal.programCompletion":"Achèvement du Programme","portal.weeksEnrolled":"Semaines Inscrit","portal.avgHoursWeek":"Heures/Semaine Moy.","portal.meetsReq":"C
1189onforme","portal.belowReq":"Non conforme","portal.passing":"Réussite","portal.honorRoll":"Tableau d'Honneur","portal.needsWork":"à améliorer","portal.runningStartReport":"Rapport Trimestriel Running Start","lms.title":"Z-LMS","lms.subtitle":'"Injection de Connaissances"',"lms.chapters":"Chapitres","lms.mockExam":"Examen Blanc","lms.progress":"Progrès","lms.curriculumProgress":"Progrès du Programme","lms.completed":"Terminé","lms.inProgress":"En Cours","lms.notStarted":"Non Commencé","lms.voiceGuide":"Guide Vocal","lms.selectChapter":"Sélectionnez un chapitre pour commencer un examen chronométré avec retour vocal","lms.startExam":"Commencer l'Examen","lms.retake":"Reprendre","lms.allChapters":"Tous les Chapitres","lms.congratulations":"Félicitations!","lms.keepPracticing":"Continuez à Pratiquer","lms.correct":"Correct","lms.score":"Score","lms.timeUsed":"Temps Utilisé","lms.confirm":"Confirmer","lms.next":"Suivant","lms.previous":"Précédent","lms.finish":"Terminer","lms.remaining":"restant","lms.keyTopics":"Sujets Clés","lms.resources":"Ressources","lms.details":"Détails","lms.totalProgress":"Progrès Total","lms.chaptersComplete":"Chapitres Terminés","lms.examsTaken":"Examens Passés","lms.avgExamScore":"Score Moyen","common.search":"Rechercher","common.close":"Fermer","common.save":"Enregistrer","common.cancel":"Annuler","common.loading":"Chargement...","common.error":"Erreur","common.success":"Succès","common.language":"Langue","common.of":"de","common.hours":"heures","common.minutes":"minutes","common.weeks":"semaines","common.days":"jours","common.enrolled":"Inscrit","common.status":"Statut","common.program":"Programme","common.email":"Email","common.phone":"Téléphone","common.studentId":"ID Ãtudiant"}};function lK(t,s="en"){var n;return((n=$3[s])==null?void 0:n[t])||$3.en[t]||t}const bI=d.createContext({language:"en",setLanguage:()=>{},t:t=>t}),cK=()=>d.useContext(bI),vI=({children:t})=>{const[s,n]=d.useState(()=>{try{const i=localStorage.getItem("zorganics_language");if(i&&["en","es","fr"].includes(i))return i}catch{}return"en"}),a=d.useCallback(i=>{n(i),localStorage.setItem("zorganics_language",i)},[]),r=d.useCallback(i=>lK(i,s),[s]);return e.jsx(bI.Provider,{value:{language:s,setLanguage:a,t:r},children:t})},z3={en:e.jsxs("svg",{viewBox:"0 0 20 14",className:"w-5 h-3.5 rounded-sm overflow-hidden",children:[e.jsx("rect",{width:"20",height:"14",fill:"#B22234"}),e.jsx("rect",{y:"1.08",width:"20",height:"1.08",fill:"white"}),e.jsx("rect",{y:"3.23",width:"20",height:"1.08",fill:"white"}),e.jsx("rect",{y:"5.38",width:"20",height:"1.08",fill:"white"}),e.jsx("rect",{y:"7.54",width:"20",height:"1.08",fill:"white"}),e.jsx("rect",{y:"9.69",width:"20",height:"1.08",fill:"white"}),e.jsx("rect",{y:"11.85",width:"20",height:"1.08",fill:"white"}),e.jsx("rect",{width:"8",height:"7.54",fill:"#3C3B6E"})]}),es:e.jsxs("svg",{viewBox:"0 0 20 14",className:"w-5 h-3.5 rounded-sm overflow-hidden",children:[e.jsx("rect",{width:"20",height:"14",fill:"#AA151B"}),e.jsx("rect",{y:"3.5",width:"20",height:"7",fill:"#F1BF00"})]}),fr:e.jsxs("svg",{viewBox:"0 0 20 14",className:"w-5 h-3.5 rounded-sm overflow-hidden",children:[e.jsx("rect",{width:"6.67",height:"14",fill:"#002395"}),e.jsx("rect",{x:"6.67",width:"6.67",height:"14",fill:"white"}),e.jsx("rect",{x:"13.33",width:"6.67",height:"14",fill:"#ED2939"})]})},dK=({variant:t="compact",className:s=""})=>{const{language:n,setLanguage:a}=cK(),[r,i]=d.useState(!1),o=d.useRef(null);d.useEffect(()=>{const c=u=>{o.current&&!o.current.contains(u.target)&&i(!1)};return document.addEventListener("mousedown",c),()=>document.removeEventListener("mousedown",c)},[]);const l=_v.find(c=>c.code===n)||_v[0];return e.jsxs("div",{className:`relative ${s}`,ref:o,children:[e.jsxs("button",{onClick:()=>i(!r),className:`flex items-center gap-2 transition-all ${t==="compact"?"px-2.5 py-1.5 rounded-lg border border-gray-200 hover:border-gray-300 hover:bg-gray-50 text-gray-600":"px-3 py-2 rounded-xl border border-gray-200 hover:border-indigo-300 hover:bg-indigo-50/50 text-gray-700"}`,children:[e.jsx(Bo,{size:t==="compact"?14:16,className:"text-gray-500"}),z3[n],t==="full"&&e.jsx("span",{className:"text-xs font-medium",children:l.nativeLabel}),e.jsx(Gt,{size:12,className:`text-gray-400 transition-transform ${r?"rotate-180":""}`})]}),r&&e.jsxs("div",{className:"absolute right-0 top-full mt-1 w-48 bg-white rounded-xl shadow-xl border border-gray-100 overflow-hidden z-50",children:[e.jsx("div",{className:"px-3 py-2 bg-gray-50 border-b border-gray-100",children:e.jsx("p",{className:"text-[10px] font-semibold text-gray-400 uppercase tracking-wider",children:"Select Language"})}),_v.map(c=>e.jsxs("button",{onClick:()=>{a(c.code),i(!1)},className:`flex items-center gap-3 w-full px-3 py-2.5 text-sm transition-colors ${n===c.code?"bg-indigo-50 text-indigo-700":"text-gray-600 hover:bg-gray-50"}`,children:[z3[c.code],e.jsxs("div",{className:"flex-1 text-left",children:[e.jsx("p",{className:"font-medium text-sm",children:c.nativeLabel}),e.jsx("p",{className:"text-[10px] text-gray-400",children:c.label})]}),n===c.code&&e.jsx(xt,{size:14,className:"text-indigo-600"})]},c.code))]})]})},kv=[{id:"institute",label:"Zorganics Institute",subtitle:"Education & Training",icon:e.jsx(_t,{size:18}),color:"#800020",gradient:"from-[#800020] to-[#5A0018]",defaultSection:"dashboard"}
1189,{id:"village",label:"Vertical Village",subtitle:"Housing, Bistro & Events",icon:e.jsx(zt,{size:18}),color:"#2D5016",gradient:"from-[#2D5016] to-[#1a3a0a]",defaultSection:"village-map"},{id:"cosmetics",label:"Zorganics Cosmetics",subtitle:"Organic Beauty Shop",icon:e.jsx(Io,{size:18}),color:"#D4AF37",gradient:"from-[#D4AF37] to-[#B8962E]",defaultSection:"shop"},{id:"professional",label:"Professional Services",subtitle:"Med Spa & Zora's Salon",icon:e.jsx(Qe,{size:18}),color:"#0D9488",gradient:"from-teal-600 to-teal-700",defaultSection:"professional-services"},{id:"foundation",label:"Zorganics Foundation",subtitle:"Community & Scholarships",icon:e.jsx(ta,{size:18}),color:"#800020",gradient:"from-[#800020] to-[#5A0018]",defaultSection:"foundation"}],L3=()=>{const{activeBrand:t,setActiveBrand:s,setActiveSection:n,setShowHero:a}=dc(),[r,i]=d.useState(!1),o=d.useRef(null),l=kv.find(u=>u.id===t)||kv[0];d.useEffect(()=>{const u=p=>{o.current&&!o.current.contains(p.target)&&i(!1)};return document.addEventListener("mousedown",u),()=>document.removeEventListener("mousedown",u)},[]);const c=u=>{s(u.id),n(u.defaultSection),a(u.id==="institute"),i(!1)};return e.jsxs("div",{className:"relative",ref:o,children:[e.jsxs("button",{onClick:()=>i(!r),className:"flex items-center gap-2 px-3 py-1.5 rounded-lg transition-all text-sm",style:{background:"rgba(255,255,255,0.12)",border:"1px solid rgba(255,255,255,0.2)",color:"rgba(255,255,255,0.9)"},children:[e.jsx("div",{className:`w-6 h-6 rounded-md bg-gradient-to-br ${l.gradient} flex items-center justify-center text-white`,children:l.icon}),e.jsxs("div",{className:"hidden xl:block text-left",children:[e.jsx("p",{className:"text-xs font-semibold leading-tight",style:{color:"#3B0A11"},children:l.label}),e.jsx("p",{className:"text-[9px] leading-tight",style:{color:"#5A1A24"},children:l.subtitle})]}),e.jsx(Gt,{size:14,className:`transition-transform ${r?"rotate-180":""}`,style:{color:"#5A1A24"}})]}),r&&e.jsxs("div",{className:"absolute left-0 top-full mt-2 w-80 bg-white rounded-xl shadow-2xl border border-gray-100 overflow-hidden z-[60]",children:[e.jsx("div",{className:"px-4 py-3 bg-gray-100 border-b border-gray-200",children:e.jsx("p",{className:"text-[11px] font-bold uppercase tracking-wider",style:{color:"#3B0A11"},children:"Zorganics Business Units"})}),e.jsx("div",{className:"py-1",children:kv.map(u=>e.jsxs("button",{onClick:()=>c(u),className:`flex items-center gap-3 w-full px-4 py-3 transition-all ${t===u.id?"bg-gray-50":"hover:bg-gray-50/50"}`,children:[e.jsx("div",{className:`w-10 h-10 rounded-xl bg-gradient-to-br ${u.gradient} flex items-center justify-center text-white shadow-sm`,children:u.icon}),e.jsxs("div",{className:"flex-1 text-left",children:[e.jsx("p",{className:"text-sm font-semibold",style:{color:"#3B0A11"},children:u.label}),e.jsx("p",{className:"text-[11px]",style:{color:"#5A1A24"},children:u.subtitle})]}),t===u.id&&e.jsx("span",{className:"w-2 h-2 rounded-full",style:{backgroundColor:u.color}})]},u.id))}),e.jsx("div",{className:"px-4 py-3 bg-gray-100 border-t border-gray-200",children:e.jsx("p",{className:"text-[10px] text-center",style:{color:"#7A3A44"},children:"Unified Z-CRM tracks customers across all units · Tenant-isolated data"})})]})]})};function Sv(){return typeof document>"u"?"light":document.documentElement.classList.contains("dark")?"dark":"light"}const uK=({variant:t="compact",className:s=""})=>{const{theme:n,setTheme:a}=uD(),[r,i]=d.useState(!1),[o,l]=d.useState(()=>Sv()),c=d.useRef(null);d.useEffect(()=>{l(Sv())},[n,r]),d.useEffect(()=>{if(typeof window>"u"||!window.matchMedia)return;const v=window.matchMedia("(prefers-color-scheme: dark)"),g=()=>l(Sv());return v.addEventListener?v.addEventListener("change",g):v.addListener&&v.addListener(g),()=>{v.removeEventListener?v.removeEventListener("change",g):v.removeListener&&v.removeListener(g)}},[]),d.useEffect(()=>{if(!r)return;const v=N=>{c.current&&!c.current.contains(N.target)&&i(!1)},g=N=>{N.key==="Escape"&&i(!1)};return document.addEventListener("mousedown",v),document.addEventListener("keydown",g),()=>{document.removeEventListener("mousedown",v),document.removeEventListener("keydown",g)}},[r]);const u=o==="dark"?ox:Sd,p=n==="system"?`Theme: System (currently ${o})`:`Theme: ${n==="dark"?"Dark":"Light"}`,m=[{key:"light",label:"Light",desc:"Cream theme",Icon:Sd},{key:"dark",label:"Dark",desc:"Blackened Plum",Icon:ox},{key:"system",label:"System",desc:"Follow OS preference",Icon:XS}],x="relative inline-flex items-center justify-center rounded-lg transition-all focus:outline-none focus-visible:ring-2 focus-visible:ring-[#D4AF37]/70 focus-visible:ring-offset-1 focus-visible:ring-offset-transparent",h=t==="compact"?"w-9 h-9":"gap-2 px-3 py-2";return e.jsxs("div",{ref:c,className:`relative ${s}`,children:[e.jsxs("button",{type:"button",onClick:()=>i(v=>!v),"aria-haspopup":"menu","aria-expanded":r,"aria-label":p,title:p,className:`${x} ${h} bg-white/8 hover:bg-white/15 border border-white/15 hover:border-[#D4AF37]/40 text-white/90 hover:text-white`,style:{backgroundColor:"rgba(255,255,255,0.08)"},children:[e.jsx(u,{size:t==="compact"?16:15,className:"transition-transform duration-200",style:{color:"#F0E4C4"},"aria-hidden":"true"}),n==="system"&&e.jsx("span",{className:"absolute -bottom-0.5 -right-0.5 flex items-center justify-center rounded-full",style:{width:"12px",height:"12px",background:"linear-gradient(135deg, #D4AF37 0%, #B8962E 100%)",border:"1.5px solid #6B0018"},"aria-hidden":"true",children:e.jsx(XS,{size:7,style:{color:"#3B0A11"},strokeWidth:3})}),t==="default"&&e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"text-xs font-semibold",style:{color:"#F0E4C4"},children:n==="system"?"System":n==="dark"?"Dark":"Light"}),e.jsx(Gt,{size:12,className:`transition-transform ${r?"rotate-180":""}`,style:{color:"rgba(240,228,196,0.6)"},"aria-hidden":"true"})]})]}),r&&e.jsxs("div",{role:"menu","aria-label":"Select theme",className:"absolute right-0 top-full mt-2 w-56 rounded-xl shadow-2xl overflow-hidden z-[60] animate-in fade-in slide-in-from-top-1 duration-150",style:{background:"#FFFFFF",border:"1px solid rgba(212,175,55,0.25)",boxShadow:"0 12px 36px rgba(59,10,17,0.22), 0 2px 8px rgba(0,0,0,0.08), 0 0 0 1px rgba(212,175,55,0.15)"},children:[e.jsxs("div",{className:"px-4 py-2.5",style:{background:"linear-gradient(135deg, #3B0A11 0%, #5A1A24 100%)",borderBottom:"1px solid rgba(212,175,55,0.25)"},children:[e.jsx("p",{className:"text-[10px] font-bold uppercase tracking-[0.14em]",style:{color:"#E6D2A0"},children:"Display Theme"}),e.jsx("p",{className:"text-[10px] mt-0.5",style:{color:"rgba(230,210,160,0.65)"},children:"Persisted to this device · localStorage"})]}),e.jsx("div",{className:"py-1.5",children:m.map(({key:v,label:g,desc:N,Icon:b})=>{const f=n===v;return e.jsxs("button",{type:"button",role:"menuitemradio","aria-checked":f,onClick:()=>{a(v),i(!1)},className:"group flex items-center gap-3 w-full px-4 py-2.5 text-sm transition-colors focus:outline-none focus-visible:ring-2 focus-visible:ring-[#D4AF37]/70 focus-visible:ring-inset "+(f?"bg-[rgba(212,175,55,0.08)]":"hover:bg-[rgba(212,175,55,0.05)]"),children:[e.jsx("div",{className:"w-8 h-8 rounded-lg flex items-center justify-center flex-shrink-0 transition-colors",style:{background:f?"linear-gradient(135deg, #D4AF37 0%, #B8962E 100%)":"rgba(59,10,17,0.06)",color:"#3B0A11"},children:e.jsx(b,{size:15,"aria-hidden":"true"})}),e.jsxs("div",{className:"flex-1 min-w-0 text-left",children:[e.jsxs("p",{className:"text-sm font-semibold leading-tight",style:{color:"#3B0A11"},children:[g,v==="system"&&e.jsx("span",{className:"ml-1.5 text-[9px] font-bold uppercase tracking-wider px-1.5 py-0.5 rounded",style:{background:"rgba(212,175,55,0.12)",color:"#B8962E",border:"1px solid rgba(212,175,55,0.25)"},children:o})]}),e.jsx("p",{className:"text-[10px] mt-0.5 leading-tight",style:{color:"#7A3A44"},children:N})]}),f&&e.jsx(xt,{size:14,style:{color:"#B8962E"},"aria-hidden":"true"})]},v)})}),e.jsx("div",{className:"px-4 py-2",style:{background:"rgba(245,245,220,0.5)",borderTop:"1px solid rgba(212,175,55,0.12)"},children:e.jsx("p",{className:"text-[9px] leading-snug",style:{color:"#5A1A24"},children:"Both themes are WCAG AA contrast-audited (light: §15/§15b · dark: §15c)."})})]})]})}
1189,mK=[{key:"esthetics",label:"Basic Esthetics (750h)",icon:e.jsx(Qe,{size:14})},{key:"cosmetology",label:"Cosmetology (1,600h)",icon:e.jsx(Ss,{size:14})},{key:"master-esthetics",label:"Master Esthetics Bridge (450h)",icon:e.jsx(m0,{size:14})}],pK=({isOpen:t,onClose:s})=>{const{studentLogin:n,studentRegister:a,pending2FALogin:r,complete2FALogin:i}=ap(),[o,l]=d.useState("login"),[c,u]=d.useState(!1),[p,m]=d.useState(""),[x,h]=d.useState(""),[y,v]=d.useState(!1),[g,N]=d.useState(""),[b,f]=d.useState(""),[j,S]=d.useState(""),[w,_]=d.useState(!1),[C,E]=d.useState(""),[P,F]=d.useState(""),[I,D]=d.useState(""),[L,V]=d.useState(""),[B,A]=d.useState(""),[z,M]=d.useState("esthetics"),R=()=>{N(""),f(""),E(""),F(""),D(""),V(""),A(""),M("esthetics"),S(""),m(""),h(""),l("login")},T=async G=>{if(G.preventDefault(),!g.trim()||!b.trim()){m("Please enter your Z-Student ID and password.");return}u(!0),m("");const W=await n(g,b);u(!1),W.success?(h("Welcome back! Redirecting..."),setTimeout(()=>{R(),s()},800)):W.requires2FA?(l("2fa"),m(""),h("A verification code has been sent to your email.")):m(W.error||"Login failed.")},U=async G=>{if(G.preventDefault(),!j.trim()||j.length!==6){m("Please enter the 6-digit verification code.");return}u(!0),m("");const W=await i(j.trim());u(!1),W.success?(h("Verified! Welcome back."),setTimeout(()=>{R(),s()},800)):m(W.error||"Verification failed.")},q=async()=>{if(!r)return;_(!0),m("");const G=await n(g,b);_(!1),G.requires2FA&&(h("A new verification code has been sent."),S(""))},H=async G=>{if(G.preventDefault(),!C.trim()||!P.trim()||!L.trim()){m("Please fill in all required fields.");return}if(P!==I){m("Passwords do not match.");return}if(P.length<4){m("Password must be at least 4 characters.");return}u(!0),m("");const W=await a({studentId:C,password:P,fullName:L,email:B||void 0,program:z});u(!1),W.success?(h("Account created! Welcome to Z-LMS."),setTimeout(()=>{R(),s()},800)):m(W.error||"Registration failed.")};return t?e.jsxs("div",{className:"fixed inset-0 z-[60] flex items-center justify-center p-4",onClick:s,children:[e.jsx("div",{className:"absolute inset-0 bg-black/40 backdrop-blur-sm"}),e.jsxs("div",{className:"relative w-full max-w-md bg-white rounded-2xl shadow-2xl overflow-hidden",onClick:G=>G.stopPropagation(),children:[e.jsxs("div",{className:"relative bg-gradient-to-br from-[#1a1a2e] to-[#16213e] px-6 py-5",children:[e.jsx("div",{className:"h-0.5 absolute top-0 left-0 right-0 bg-gradient-to-r from-emerald-400 via-blue-400 to-purple-400"}),e.jsx("button",{onClick:()=>{R(),s()},className:"absolute top-4 right-4 p-1.5 rounded-lg hover:bg-white/10 transition-colors",children:e.jsx(Ke,{size:18,className:"text-white/60"})}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:`w-12 h-12 rounded-xl flex items-center justify-center shadow-lg ${o==="2fa"?"bg-gradient-to-br from-blue-400 to-indigo-500":"bg-gradient-to-br from-emerald-400 to-blue-500"}`,children:o==="2fa"?e.jsx(Ie,{size:24,className:"text-white"}):e.jsx(_t,{size:24,className:"text-white"})}),e.jsxs("div",{children:[e.jsx("h2",{className:"text-lg font-bold text-white",children:o==="login"?"Student Sign In":o==="2fa"?"Two-Factor Verification":"Create Student Account"}),e.jsx("p",{className:"text-xs text-blue-200",children:o==="login"?"Sign in with your Z-Student ID":o==="2fa"?"Enter the code sent to your email":"Register with your assigned Z-Student ID"})]})]})]}),o!=="2fa"&&e.jsxs("div",{className:"flex border-b border-gray-100",children:[e.jsxs("button",{onClick:()=>{l("login"),m(""),h("")},className:`flex-1 flex items-center justify-center gap-2 px-4 py-3 text-sm font-semibold transition-all ${o==="login"?"text-blue-700 border-b-2 border-blue-600 bg-blue-50/50":"text-gray-400 hover:text-gray-600"}`,children:[e.jsx($o,{size:16})," Sign In"]}),e.jsxs("button",{onClick:()=>{l("register"),m(""),h("")},className:`flex-1 flex items-center justify-center gap-2 px-4 py-3 text-sm font-semibold transition-all ${o==="register"?"text-blue-700 border-b-2 border-blue-600 bg-blue-50/50":"text-gray-400 hover:text-gray-600"}`,children:[e.jsx(Cd,{size:16})," Register"]})]}),e.jsxs("div",{className:"px-6 py-5",children:[p&&e.jsxs("div",{className:"mb-4 p-3 bg-red-50 border border-red-200 rounded-xl flex items-start gap-2",children:[e.jsx(Mt,{size:16,className:"text-red-500 mt-0.5 shrink-0"}),e.jsx("p",{className:"text-sm text-red-700",children:p})]}),x&&e.jsxs("div",{className:"mb-4 p-3 bg-emerald-50 border border-emerald-200 rounded-xl flex items-start gap-2",children:[e.jsx(pt,{size:16,className:"text-emerald-500 mt-0.5 shrink-0"}),e.jsx("p",{className:"text-sm text-emerald-700",children:x})]}),o==="2fa"&&e.jsxs("form",{onSubmit:U,className:"space-y-4",children:[e.jsxs("div",{className:"text-center",children:[e.jsx("div",{className:"w-16 h-16 rounded-2xl bg-blue-50 flex items-center justify-center mx-auto mb-4",children:e.jsx(ka,{size:28,className:"text-blue-600"})}),e.jsx("p",{className:"text-sm text-gray-600 mb-1",children:"Enter the 6-digit code sent to your email"}),e.jsx("p",{className:"text-[10px] text-gray-400",children:"The code expires in 10 minutes"})]}),e.jsx("input",{type:"text",value:j,onChange:G=>S(G.target.value.replace(/\D/g,"").slice(0,6)),placeholder:"000000",className:"w-full px-4 py-4 border border-gray-200 rounded-xl text-2xl font-mono text-center tracking-[0.5em] focus:ring-2 focus:ring-blue-200 focus:border-blue-400 outline-none transition-all",maxLength:6,autoFocus:!0}),e.jsxs("button",{type:"submit",disabled:c||j.length!==6,className:"w-full flex items-center justify-center gap-2 px-4 py-3 bg-gradient-to-r from-blue-600 to-indigo-600 text-white rounded-xl text-sm font-semibold shadow-lg shadow-blue-200 hover:shadow-xl disabled:opacity-50 disabled:cursor-not-allowed transition-all",children:[c?e.jsx(de,{size:16,className:"animate-spin"}):e.jsx(Ie,{size:16}
1189),c?"Verifying...":"Verify & Sign In"]}),e.jsxs("div",{className:"flex items-center justify-between pt-2",children:[e.jsxs("button",{type:"button",onClick:()=>{l("login"),m(""),h(""),S("")},className:"flex items-center gap-1 text-xs text-gray-500 hover:text-gray-700 transition-colors",children:[e.jsx(Je,{size:12})," Back to Sign In"]}),e.jsxs("button",{type:"button",onClick:q,disabled:w,className:"flex items-center gap-1 text-xs text-blue-600 hover:text-blue-800 font-semibold transition-colors disabled:opacity-50",children:[w?e.jsx(de,{size:12,className:"animate-spin"}):e.jsx(Hs,{size:12}),w?"Sending...":"Resend Code"]})]})]}),o==="login"&&e.jsxs("form",{onSubmit:T,className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs font-semibold text-gray-600 uppercase tracking-wider mb-1.5",children:"Z-Student ID"}),e.jsx("input",{type:"text",value:g,onChange:G=>N(G.target.value),placeholder:"e.g. ZSI-2025-001",className:"w-full px-4 py-3 border border-gray-200 rounded-xl text-sm focus:ring-2 focus:ring-blue-200 focus:border-blue-400 outline-none transition-all font-mono",autoFocus:!0,autoComplete:"username"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs font-semibold text-gray-600 uppercase tracking-wider mb-1.5",children:"Password"}),e.jsxs("div",{className:"relative",children:[e.jsx("input",{type:y?"text":"password",value:b,onChange:G=>f(G.target.value),placeholder:"Enter your password",className:"w-full px-4 py-3 pr-12 border border-gray-200 rounded-xl text-sm focus:ring-2 focus:ring-blue-200 focus:border-blue-400 outline-none transition-all",autoComplete:"current-password"}),e.jsx("button",{type:"button",onClick:()=>v(!y),className:"absolute right-3 top-1/2 -translate-y-1/2 p-1 text-gray-400 hover:text-gray-600",children:y?e.jsx(Md,{size:16}):e.jsx(ms,{size:16})})]})]}),e.jsxs("button",{type:"submit",disabled:c,className:"w-full flex items-center justify-center gap-2 px-4 py-3 bg-gradient-to-r from-blue-600 to-indigo-600 text-white rounded-xl text-sm font-semibold shadow-lg shadow-blue-200 hover:shadow-xl disabled:opacity-50 disabled:cursor-not-allowed transition-all",children:[c?e.jsx(de,{size:16,className:"animate-spin"}):e.jsx($o,{size:16}),c?"Signing in...":"Sign In"]}),e.jsx("div",{className:"text-center",children:e.jsxs("a",{href:"/reset-password",className:"inline-flex items-center gap-1 text-xs text-blue-600 hover:text-blue-800 font-semibold transition-colors",children:[e.jsx(ka,{size:12})," Forgot password?"]})})]}),o==="register"&&e.jsxs("form",{onSubmit:H,className:"space-y-4",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{className:"col-span-2",children:[e.jsxs("label",{className:"block text-xs font-semibold text-gray-600 uppercase tracking-wider mb-1.5",children:["Z-Student ID ",e.jsx("span",{className:"text-red-400",children:"*"})]}),e.jsx("input",{type:"text",value:C,onChange:G=>E(G.target.value),placeholder:"e.g. ZSI-2025-010",className:"w-full px-4 py-3 border border-gray-200 rounded-xl text-sm focus:ring-2 focus:ring-blue-200 focus:border-blue-400 outline-none transition-all font-mono",autoFocus:!0}),e.jsx("p",{className:"text-[10px] text-gray-400 mt-1",children:"Your assigned Z-Student ID from enrollment"})]}),e.jsxs("div",{className:"col-span-2",children:[e.jsxs("label",{className:"block text-xs font-semibold text-gray-600 uppercase tracking-wider mb-1.5",children:["Full Name ",e.jsx("span",{className:"text-red-400",children:"*"})]}),e.jsx("input",{type:"text",value:L,onChange:G=>V(G.target.value),placeholder:"Your full name",className:"w-full px-4 py-3 border border-gray-200 rounded-xl text-sm focus:ring-2 focus:ring-blue-200 focus:border-blue-400 outline-none transition-all"})]}),e.jsxs("div",{className:"col-span-2",children:[e.jsx("label",{className:"block text-xs font-semibold text-gray-600 uppercase tracking-wider mb-1.5",children:"Email"}),e.jsx("input",{type:"email",value:B,onChange:G=>A(G.target.value),placeholder:"[email protected]",className:"w-full px-4 py-3 border border-gray-200 rounded-xl text-sm focus:ring-2 focus:ring-blue-200 focus:border-blue-400 outline-none transition-all"})]}),e.jsxs("div",{className:"col-span-2",children:[e.jsx("label",{className:"block text-xs font-semibold text-gray-600 uppercase tracking-wider mb-1.5",children:"Program"}),e.jsx("div",{className:"grid grid-cols-3 gap-2",children:mK.map(G=>e.jsxs("button",{type:"button",onClick:()=>M(G.key),className:`flex items-center justify-center gap-1.5 px-3 py-2.5 rounded-xl text-[11px] font-semibold transition-all border ${z===G.key?"bg-blue-50 text-blue-700 border-blue-300 ring-2 ring-blue-100":"bg-white text-gray-500 border-gray-200 hover:border-gray-300"}`,children:[G.icon,e.jsx("span",{className:"truncate",children:G.key==="esthetics"?"Esthetics":G.key==="cosmetology"?"Cosmo":"Master"})]},G.key))})]}),e.jsxs("div",{children:[e.jsxs("label",{className:"block text-xs font-semibold text-gray-600 uppercase tracking-wider mb-1.5",children:["Password ",e.jsx("span",{className:"text-red-400",children:"*"})]}),e.jsx("input",{type:"password",value:P,onChange:G=>F(G.target.value),placeholder:"Create password",className:"w-full px-4 py-3 border border-gray-200 rounded-xl text-sm focus:ring-2 focus:ring-blue-200 focus:border-blue-400 outline-none transition-all"})]}),e.jsxs("div",{children:[e.jsxs("label",{className:"block text-xs font-semibold text-gray-600 uppercase tracking-wider mb-1.5",children:["Confirm ",e.jsx("span",{className:"text-red-400",children:"*"})]}),e.jsx("input",{type:"password",value:I,onChange:G=>D(G.target.value),placeholder:"Confirm password",className:"w-full px-4 py-3 border border-gray-200 rounded-xl text-sm focus:ring-2 focus:ring-blue-200 focus:border-blue-400 outline-none transition-all"})]})]}
1189),e.jsxs("button",{type:"submit",disabled:c,className:"w-full flex items-center justify-center gap-2 px-4 py-3 bg-gradient-to-r from-emerald-600 to-teal-600 text-white rounded-xl text-sm font-semibold shadow-lg shadow-emerald-200 hover:shadow-xl disabled:opacity-50 disabled:cursor-not-allowed transition-all",children:[c?e.jsx(de,{size:16,className:"animate-spin"}):e.jsx(Cd,{size:16}),c?"Creating account...":"Create Account"]})]})]})]})]}):null},O3=[{value:"all",label:"All",icon:e.jsx(Gl,{size:12})},{value:"unread",label:"Unread",icon:e.jsx(Kx,{size:12})},{value:"quiz_deadline",label:"Assignments",icon:e.jsx(dt,{size:12})},{value:"grade_posted",label:"Grades",icon:e.jsx(Is,{size:12})},{value:"attendance_warning",label:"Attendance",icon:e.jsx(ve,{size:12})},{value:"system",label:"SAP / System",icon:e.jsx(Tt,{size:12})},{value:"announcement",label:"Messages",icon:e.jsx(jr,{size:12})},{value:"milestone",label:"Milestones",icon:e.jsx(JP,{size:12})}],M3={quiz_deadline:{icon:e.jsx(dt,{size:18}),color:"text-amber-600",bg:"bg-amber-50",border:"border-amber-200",label:"Assignment"},grade_posted:{icon:e.jsx(Is,{size:18}),color:"text-emerald-600",bg:"bg-emerald-50",border:"border-emerald-200",label:"Grade"},attendance_warning:{icon:e.jsx(ve,{size:18}),color:"text-red-600",bg:"bg-red-50",border:"border-red-200",label:"Attendance"},milestone:{icon:e.jsx(JP,{size:18}),color:"text-purple-600",bg:"bg-purple-50",border:"border-purple-200",label:"Milestone"},announcement:{icon:e.jsx(ix,{size:18}),color:"text-blue-600",bg:"bg-blue-50",border:"border-blue-200",label:"Message"},system:{icon:e.jsx(Qe,{size:18}),color:"text-gray-600",bg:"bg-gray-50",border:"border-gray-200",label:"System"}},hK={assignment_posted:{label:"New Assignment",color:"bg-blue-100 text-blue-700"},grade_entered:{label:"Grade",color:"bg-emerald-100 text-emerald-700"},grade_entered_quiz:{label:"Quiz Score",color:"bg-orange-100 text-orange-700"},attendance_warning:{label:"Attendance",color:"bg-red-100 text-red-700"},sap_checkpoint_25:{label:"SAP 25%",color:"bg-violet-100 text-violet-700"},sap_checkpoint_50:{label:"SAP 50%",color:"bg-violet-100 text-violet-700"},sap_checkpoint_75:{label:"SAP 75%",color:"bg-violet-100 text-violet-700"},new_message:{label:"Message",color:"bg-sky-100 text-sky-700"},ticket_updated:{label:"Ticket",color:"bg-amber-100 text-amber-700"},ticket_reply:{label:"Ticket Reply",color:"bg-amber-100 text-amber-700"},calendar_reminder:{label:"Calendar",color:"bg-pink-100 text-pink-700"},announcement:{label:"Announcement",color:"bg-indigo-100 text-indigo-700"}},B3={urgent:"bg-red-500",high:"bg-amber-500",normal:"bg-blue-400",low:"bg-gray-300"};function jI(t){const s=new Date,n=new Date(t),a=s.getTime()-n.getTime(),r=Math.floor(a/1e3),i=Math.floor(r/60),o=Math.floor(i/60),l=Math.floor(o/24);return r<60?"Just now":i<60?`${i}m ago`:o<24?`${o}h ago`:l===1?"Yesterday":l<7?`${l}d ago`:n.toLocaleDateString("en-US",{month:"short",day:"numeric"})}const xK=({notification:t,onMarkRead:s,onDelete:n,onNavigate:a})=>{const r=M3[t.type]||M3.system,i=B3[t.priority]||B3.normal,o=t.trigger_type?hK[t.trigger_type]:null;return e.jsxs("div",{className:`group relative px-4 py-3 transition-all duration-200 ${t.is_read?"bg-white hover:bg-gray-50/80":"bg-gradient-to-r from-[#800020]/5 to-white hover:from-[#800020]/10 hover:to-[#800020]/5"}`,children:[!t.is_read&&e.jsx("div",{className:`absolute left-0 top-0 bottom-0 w-[3px] rounded-r-full ${i}`}),e.jsxs("div",{className:"flex gap-3",children:[e.jsx("div",{className:`flex-shrink-0 w-10 h-10 rounded-xl ${r.bg} ${r.border} border flex items-center justify-center ${r.color}`,children:r.icon}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-start justify-between gap-2",children:[e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-0.5 flex-wrap",children:[e.jsx("h4",{className:`text-sm font-semibold truncate ${t.is_read?"text-gray-600":"text-gray-900"}`,children:t.title}),t.priority==="urgent"&&e.jsx("span",{className:"flex-shrink-0 px-1.5 py-0.5 rounded text-[9px] font-bold bg-red-100 text-red-700 border border-red-200 uppercase tracking-wider",children:"Urgent"}),t.priority==="high"&&e.jsx("span",{className:"flex-shrink-0 px-1.5 py-0.5 rounded text-[9px] font-bold bg-amber-100 text-amber-700 border border-amber-200 uppercase tracking-wider",children:"Important"})]}),e.jsx("p",{className:`text-xs leading-relaxed ${t.is_read?"text-gray-400":"text-gray-600"}`,children:t.message})]}),e.jsxs("div",{className:"flex-shrink-0 flex items-center gap-0.5 opacity-0 group-hover:opacity-100 transition-opacity",children:[!t.is_read&&e.jsx("button",{onClick:l=>{l.stopPropagation(),s(t.id)},className:"p-1.5 rounded-lg hover:bg-blue-100 text-blue-500 transition-colors",title:"Mark as read",children:e.jsx(xt,{size:13})}),e.jsx("button",{onClick:l=>{l.stopPropagation(),n(t.id)},className:"p-1.5 rounded-lg hover:bg-red-100 text-red-400 transition-colors",title:"Delete",children:e.jsx(va,{size:13})})]})]}),e.jsxs("div",{className:"flex items-center justify-between mt-2",children:[e.jsxs("div",{className:"flex items-center gap-1.5 flex-wrap",children:[o&&e.jsxs("span",{className:`inline-flex items-center gap-0.5 px-1.5 py-0.5 rounded text-[8px] font-bold ${o.color} border border-current/10`,children:[e.jsx(Pm,{size:8}),o.label]}),e.jsx("span",{className:`inline-flex items-center gap-1 px-1.5 py-0.5 rounded text-[9px] font-semibold ${r.bg} ${r.color} border ${r.border}`,children:r.label}),t.source_engine==="auto-student-alerts"&&e.jsxs("span",{className:"inline-flex items-center gap-0.5 px-1 py-0.5 rounded text-[8px] font-medium text-[#800020]/60 bg-[#800020]/5",children:[e.jsx(VP,{size:7}),"Auto"]}),e.jsxs("span",{className:"text-[10px] text-gray-400 flex items-center gap-1",children:[e.jsx(At,{size:9}),jI(t.created_at)]})]}),t.action_section&&e.jsxs("button",{onClick:()=>a(t.action_section),className:"flex items-center gap-1 text-[10px] font-semibold text-[#800020] hover:text-[#5C0018] transition-colors",children:["View Details",e.jsx(Nr,{size:10})]})]})]})]})]})},fK=({isOpen:t,onClose:s,onOpenPreferences:n})=>{var P;const{notifications:a,unreadCount:r,loading:i,markAsRead:o,markAllAsRead:l,deleteNotification:c,clearAll:u,fetchNotifications:p,triggerScan:m,lastScanAt:x}=pI(),{setActiveSection:h,setShowHero:y}
1189=dc(),[v,g]=d.useState("all"),[N,b]=d.useState(!1),[f,j]=d.useState(!1),[S,w]=d.useState(null),_=d.useMemo(()=>v==="all"?a:v==="unread"?a.filter(F=>!F.is_read):a.filter(F=>F.type===v),[a,v]),C=F=>{h(F),y(!1),s()},E=async()=>{j(!0),w(null);const F=await m();F.success?w(`Scan complete: ${F.notificationsCreated||0} new alerts`):w("Scan completed"),j(!1),setTimeout(()=>w(null),4e3)};return t?e.jsxs("div",{className:"absolute right-0 top-12 w-[440px] max-h-[650px] bg-white rounded-2xl shadow-2xl border border-gray-100 overflow-hidden z-50 animate-in fade-in slide-in-from-top-2 duration-200 flex flex-col",children:[e.jsxs("div",{className:"px-5 py-4 bg-gradient-to-br from-[#800020]/5 to-white border-b border-gray-100",children:[e.jsxs("div",{className:"flex items-center justify-between mb-3",children:[e.jsxs("div",{className:"flex items-center gap-2.5",children:[e.jsx("div",{className:"w-9 h-9 rounded-xl bg-gradient-to-br from-[#800020] to-[#5C0018] flex items-center justify-center shadow-md shadow-[#800020]/20",children:e.jsx(Gl,{size:17,className:"text-white"})}),e.jsxs("div",{children:[e.jsx("h3",{className:"font-bold text-sm text-gray-900",style:{fontFamily:"Georgia, serif"},children:"Notifications"}),e.jsxs("p",{className:"text-[10px] text-gray-400 flex items-center gap-1",children:[r>0?e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-red-500 animate-pulse"})," ",r," unread"]}):"All caught up!",x&&e.jsxs("span",{className:"ml-1 text-gray-300",children:["| Last scan: ",jI(x)]})]})]})]}),e.jsxs("div",{className:"flex items-center gap-1",children:[r>0&&e.jsxs("button",{onClick:l,className:"flex items-center gap-1 px-2.5 py-1.5 rounded-lg text-[10px] font-semibold text-[#800020] hover:bg-[#800020]/10 transition-colors",title:"Mark all as read",children:[e.jsx(GS,{size:13}),"Read All"]}),e.jsx("button",{onClick:E,disabled:f,className:"p-1.5 rounded-lg text-gray-400 hover:bg-[#800020]/10 hover:text-[#800020] transition-colors disabled:opacity-50",title:"Run notification scan",children:f?e.jsx(de,{size:14,className:"animate-spin"}):e.jsx(Pm,{size:14})}),e.jsx("button",{onClick:()=>p(),className:"p-1.5 rounded-lg text-gray-400 hover:bg-gray-100 hover:text-gray-600 transition-colors",title:"Refresh",children:e.jsx(zi,{size:14})}),n&&e.jsx("button",{onClick:()=>{n(),s()},className:"p-1.5 rounded-lg text-gray-400 hover:bg-gray-100 hover:text-gray-600 transition-colors",title:"Notification Preferences",children:e.jsx(kd,{size:14})}),e.jsx("button",{onClick:s,className:"p-1.5 rounded-lg text-gray-400 hover:bg-gray-100 hover:text-gray-600 transition-colors",children:e.jsx(Ke,{size:14})})]})]}),S&&e.jsxs("div",{className:"mb-2 px-3 py-1.5 bg-emerald-50 border border-emerald-200 rounded-lg text-[10px] font-semibold text-emerald-700 flex items-center gap-1.5",children:[e.jsx(Pm,{size:10})," ",S]}),e.jsx("div",{className:"flex items-center gap-1.5 overflow-x-auto pb-0.5 -mb-0.5 scrollbar-hide",children:O3.map(F=>e.jsxs("button",{onClick:()=>g(F.value),className:`flex items-center gap-1 px-2.5 py-1.5 rounded-lg text-[10px] font-semibold whitespace-nowrap transition-all ${v===F.value?"bg-[#800020] text-white shadow-sm shadow-[#800020]/20":"bg-gray-100 text-gray-500 hover:bg-gray-200 hover:text-gray-700"}`,children:[F.icon,F.label,F.value==="unread"&&r>0&&e.jsx("span",{className:`ml-0.5 px-1.5 py-0.5 rounded-full text-[8px] font-bold ${v==="unread"?"bg-white/20 text-white":"bg-red-100 text-red-600"}`,children:r})]},F.value))})]}),e.jsx("div",{className:"flex-1 overflow-y-auto divide-y divide-gray-50",children:i&&a.length===0?e.jsxs("div",{className:"flex flex-col items-center justify-center py-16 text-gray-400",children:[e.jsx("div",{className:"w-8 h-8 border-2 border-gray-200 border-t-[#800020] rounded-full animate-spin mb-3"}),e.jsx("p",{className:"text-xs font-medium",children:"Loading notifications..."})]}):_.length===0?e.jsxs("div",{className:"flex flex-col items-center justify-center py-16 text-gray-400",children:[e.jsx("div",{className:"w-14 h-14 rounded-2xl bg-gray-100 flex items-center justify-center mb-3",children:v==="unread"?e.jsx(GS,{size:24,className:"text-emerald-400"}):e.jsx(Zx,{size:24})}),e.jsx("p",{className:"text-sm font-semibold text-gray-500 mb-1",children:v==="unread"?"All caught up!":"No notifications"}),e.jsx("p",{className:"text-[11px] text-gray-400 text-center max-w-[220px]",children:v==="unread"?"You've read all your notifications. Great job staying on top of things!":v==="all"?"Notifications from all 7 triggers will appear here automatically.":`No ${(P=O3.find(F=>F.value===v))==null?void 0:P.label.toLowerCase()}
1189 notifications found.`})]}):_.map(F=>e.jsx(xK,{notification:F,onMarkRead:o,onDelete:c,onNavigate:C},F.id))}),a.length>0&&e.jsxs("div",{className:"px-4 py-3 bg-gray-50/80 border-t border-gray-100 flex items-center justify-between",children:[e.jsxs("span",{className:"text-[10px] text-gray-400",children:[_.length," of ",a.length," notification",a.length!==1?"s":""," ","â¢"," ",e.jsx("span",{className:"text-[#800020]/60",children:"7-trigger engine"})]}),e.jsx("div",{className:"flex items-center gap-2",children:N?e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("span",{className:"text-[10px] text-red-600 font-medium",children:"Delete all?"}),e.jsx("button",{onClick:()=>{u(),b(!1)},className:"px-2 py-1 rounded text-[10px] font-bold bg-red-600 text-white hover:bg-red-700 transition-colors",children:"Yes"}),e.jsx("button",{onClick:()=>b(!1),className:"px-2 py-1 rounded text-[10px] font-bold bg-gray-200 text-gray-600 hover:bg-gray-300 transition-colors",children:"No"})]}):e.jsxs("button",{onClick:()=>b(!0),className:"flex items-center gap-1 px-2.5 py-1.5 rounded-lg text-[10px] font-semibold text-gray-500 hover:bg-gray-200 hover:text-red-600 transition-colors",children:[e.jsx(va,{size:11}),"Clear All"]})})]})]}):null};function eu({policyKey:t,policyLabel:s,destinationUrl:n,source:a="footer"}){try{O.from("policy_click_logs").insert({policy_key:t,policy_label:s,destination_url:n??null,source:a,user_agent:typeof navigator<"u"?navigator.userAgent:null,page_path:typeof window<"u"?window.location.pathname:null})}catch{}}const gK="v1",wI="I acknowledge that I have been provided access to the Zorganics Institute School Catalog and Consumer Disclosures.";let Qf=null;async function yK(){if(Qf)return Qf;try{const t=await fetch("https://api.ipify.org?format=json");if(!t.ok)return null;const s=await t.json();return Qf=(s==null?void 0:s.ip)??null,Qf}catch{return null}}async function NI({studentName:t,studentEmail:s,source:n="unknown",pagePath:a}){try{const r=await yK(),{error:i}=await O.from("disclosure_acknowledgements").insert({student_name:t??null,student_email:s??null,ip_address:r,statement_text:wI,statement_version:gK,source:n,user_agent:typeof navigator<"u"?navigator.userAgent:null,page_path:a??(typeof window<"u"?window.location.pathname:null)});return!i}catch{return!1}}const V2="z_attr_first_v1",_I="z_attr_latest_v1",bK=400,Fh=t=>{if(typeof t!="string")return null;const s=t.trim();return s?s.slice(0,bK):null},vK=t=>{const s=Fh(t);if(!s||s.includes("@"))return null;if(/\d{7,}/.test(s.replace(/\D/g,""))){const n=s.replace(/\D/g,"");if(n.length>=7&&n.length===s.replace(/[^0-9+\-() ]/g,"").replace(/\D/g,"").length)return null}return s},jK=t=>{if(!t)return null;try{return new URL(t).hostname.replace(/^www\./,"").slice(0,200)||null}catch{return null}};function U3(t){return t?!!(t.utm_source||t.utm_medium||t.utm_campaign||t.utm_content||t.utm_term||t.fbclid||t.gclid||t.msclkid||t.campaign_tag||t.referrer_domain&&t.referrer_domain!==window.location.hostname.replace(/^www\./,"")):!1}function wK(){if(typeof window>"u")return null;try{const t=new URLSearchParams(window.location.search),s=i=>vK(t.get(i)),n=Fh(document.referrer||null),a=jK(n),r=window.location.hostname.replace(/^www\./,"");return{utm_source:s("utm_source"),utm_medium:s("utm_medium"),utm_campaign:s("utm_campaign"),utm_content:s("utm_content"),utm_term:s("utm_term"),landing_path:Fh(window.location.pathname+window.location.search),landing_url:Fh(window.location.origin+window.location.pathname),referrer_url:a&&a!==r?n:null,referrer_domain:a&&a!==r?a:null,fbclid:s("fbclid"),gclid:s("gclid"),msclkid:s("msclkid"),campaign_tag:s("campaign")||s("ref")||s("src"),captured_at:new Date().toISOString()}}catch{return null}}const R5=t=>{if(typeof window>"u")return null;try{const s=window.localStorage.getItem(t);if(!s)return null;const n=JSON.parse(s);return n&&typeof n=="object"?n:null}catch{return null}},q3=(t,s)=>{try{window.localStorage.setItem(t,JSON.stringify(s))}catch{}};function W3(){if(typeof window>"u")return;const t=wK();if(!t)return;R5(V2)||U3(t)&&q3(V2,t),U3(t)&&q3(_I,t)}function NK(){return R5(V2)}function _K(){return R5(_I)}function kK(){const t=NK(),s=_K();return{first_touch:t,latest_touch:s&&(!t||s.captured_at!==t.captured_at)?s:null,
1189submit_path:typeof window<"u"?Fh(window.location.pathname):null}}if(typeof window<"u"){W3();try{window.addEventListener("popstate",()=>W3())}catch{}}const om="company_website",SK=2500,Im={turnstile_failed:"Security verification could not be confirmed. Please complete the checkbox and try again.",rate_limited:"Too many submissions from this connection. Please wait a few minutes and try again.",honeypot_triggered:"This submission could not be verified. Please reload the page and try again.",duplicate_submission:"We already received this submission. Our team will be in touch shortly.",too_fast:"That was submitted a little too quickly. Please review your details and submit again.",invalid_request:"Please check the required fields and try again.",storage_error:"We could not save your submission just now. Please try again.",network_error:"We could not reach our servers. Please check your connection and try again.",not_verified:"Please complete the security check above before submitting."},I5=t=>t&&Im[t]||Im.storage_error;let Cv=null,Av=null;const $5=()=>(Cv||(Cv=O.functions.invoke("turnstile-config",{body:{}}).then(({data:t})=>(t==null?void 0:t.siteKey)||null).catch(()=>null)),Cv),z5=()=>typeof window>"u"?Promise.resolve(!1):window.turnstile?Promise.resolve(!0):(Av||(Av=new Promise(t=>{const s=document.querySelector("script[data-turnstile]");if(s){s.addEventListener("load",()=>t(!0)),s.addEventListener("error",()=>t(!1));return}const n=document.createElement("script");n.src="https://challenges.cloudflare.com/turnstile/v0/api.js?render=explicit",n.async=!0,n.defer=!0,n.dataset.turnstile="true",n.onload=()=>t(!0),n.onerror=()=>t(!1),document.head.appendChild(n)})),Av),Z2="data-secure-honeypot";function CK(t){if(t.querySelector(`[${Z2}]`))return;const s=document.createElement("div");s.setAttribute(Z2,"true"),s.setAttribute("aria-hidden","true"),s.style.cssText="position:absolute;left:-9999px;width:1px;height:1px;overflow:hidden;";const n=document.createElement("input");n.type="text",n.name=om,n.tabIndex=-1,n.autocomplete="off",s.appendChild(n),t.appendChild(s)}function w0(){typeof document>"u"||document.querySelectorAll("form").forEach(t=>CK(t))}function kI(){if(typeof document>"u")return"";const s=Array.from(document.querySelectorAll(`[${Z2}] input[name="${om}"]`)).find(n=>n.value.trim().length>0);return s?s.value.trim().slice(0,200):""}if(typeof window<"u"){w0();try{const t=new MutationObserver(()=>w0());document.body?t.observe(document.body,{childList:!0,subtree:!0}):window.addEventListener("DOMContentLoaded",()=>{w0(),t.observe(document.body,{childList:!0,subtree:!0})})}catch{}}const AK=typeof window<"u"?Date.now():0;function SI(){return typeof window<"u"?Date.now()-AK:0}async function CI(t=2e4){if(typeof window>"u")return"";const[s,n]=await Promise.all([z5(),$5()]),a=window.turnstile;return!s||!n||!a?"":new Promise(r=>{let i=!1;const o=document.createElement("div"),l=u=>{if(!i){i=!0;try{o.remove()}catch{}r(u)}};o.setAttribute("data-turnstile-managed","true"),o.style.cssText="position:fixed;z-index:2147483000;bottom:16px;right:16px;",document.body.appendChild(o);const c=window.setTimeout(()=>l(""),t);try{a.render(o,{sitekey:n,appearance:"interaction-only",callback:u=>{window.clearTimeout(c),l(u)},"error-callback":()=>{window.clearTimeout(c),l("")},"timeout-callback":()=>{window.clearTimeout(c),l("")}})}catch{window.clearTimeout(c),l("")}})}async function L5(t){if(!t.security.turnstile_token)return{ok:!1,reason:"not_verified",message:Im.not_verified};try{const{data:s,error:n}=await O.functions.invoke("secure-form-submit",{body:{form_type:t.formType,payload:t.payload,crm:t.crm,notify_to:t.notifyTo,attribution:kK(),turnstile_token:t.security.turnstile_token,honeypot:t.security.honeypot,elapsed_ms:t.security.elapsed_ms}});if((s==null?void 0:s.success)===!0)return{ok:!0,id:s.id??null};let a=(s==null?void 0:s.reason)||"storage_error";if(!s&&n){const r=n==null?void 0:n.context;try{const i=typeof(r==null?void 0:r.body)=="string"?JSON.parse(r.body):r==null?void 0:r.body;if(i!=null&&i.reason)a=i.reason;else if(typeof(r==null?void 0:r.json)=="function"){const o=await r.json();o!=null&&o.reason&&(a=o.reason)}else a="network_error"}catch{a="network_error"}}return{ok:!1,reason:a,message:I5(a)}}catch{return{ok:!1,reason:"network_error",message:Im.network_error}}}async function AI(t){const s=t.honeypot??kI(),n=await CI();
1189return n?L5({formType:t.formType,payload:t.payload,crm:t.crm,notifyTo:t.notifyTo,security:{turnstile_token:n,honeypot:s,elapsed_ms:typeof t.elapsedMs=="number"?t.elapsedMs:SI()}}):{ok:!1,reason:"turnstile_failed",message:Im.turnstile_failed}}const EK=Object.freeze(Object.defineProperty({__proto__:null,HONEYPOT_FIELD:om,MIN_SUBMIT_MS:SK,SECURITY_MESSAGES:Im,elapsedSincePageLoad:SI,getTurnstileSiteKey:$5,installGlobalHoneypots:w0,loadTurnstileScript:z5,readGlobalHoneypot:kI,requestTurnstileToken:CI,securityMessage:I5,submitSecureForm:L5,submitSecureFormManaged:AI},Symbol.toStringTag,{value:"Module"}));function FK(){const[t,s]=d.useState(""),[n,a]=d.useState(""),[r,i]=d.useState(!1),[o,l]=d.useState(!1),c=d.useRef(Date.now()),u=d.useRef(null),p=d.useRef(null),m=d.useRef(!0);d.useEffect(()=>(m.current=!0,c.current=Date.now(),()=>{m.current=!1}),[]);const x=d.useCallback(async()=>{if(p.current||!u.current)return;const[g,N]=await Promise.all([z5(),$5()]);if(!m.current)return;const b=window.turnstile;if(!g||!N||!b||!u.current){l(!0),i(!0);return}try{p.current=b.render(u.current,{sitekey:N,theme:"light",appearance:"always",callback:f=>{m.current&&(s(f),i(!0))},"expired-callback":()=>{m.current&&s("")},"timeout-callback":()=>{m.current&&s("")},"error-callback":()=>{m.current&&(s(""),i(!0))}}),i(!0)}catch{l(!0),i(!0)}},[]),h=d.useCallback(g=>{u.current=g,g&&x()},[x]),y=d.useCallback(()=>{s(""),c.current=Date.now();const g=window.turnstile;if(g&&p.current)try{g.reset(p.current)}catch{}},[]),v=d.useCallback(()=>({turnstile_token:t,honeypot:n,elapsed_ms:Date.now()-c.current}),[t,n]);return{verified:!!t,ready:r,unavailable:o,honeypot:n,setHoneypot:a,envelope:v,reset:y,register:h}}const TK=({security:t,accent:s="#9A7A20",className:n=""})=>e.jsxs("div",{className:n,children:[e.jsxs("div",{"aria-hidden":"true",style:{position:"absolute",left:"-9999px",width:1,height:1,overflow:"hidden"},children:[e.jsx("label",{htmlFor:om,children:"Company website"}),e.jsx("input",{id:om,name:om,type:"text",tabIndex:-1,autoComplete:"off",value:t.honeypot,onChange:a=>t.setHoneypot(a.target.value)})]}),e.jsx("div",{ref:t.register,className:"min-h-[68px]"}),e.jsxs("p",{className:"mt-1.5 flex items-start gap-1.5 text-[10px] leading-relaxed text-gray-500",children:[e.jsx(Ie,{size:11,className:"mt-0.5 shrink-0",style:{color:s}}),e.jsxs("span",{children:["Protected by Cloudflare Turnstile. Every submission is verified on our servers before it is accepted",t.unavailable?" â if the check does not appear, please reload this page.":"."]})]})]}),EI={slug:"bellingham",city:"Bellingham",state:"WA",stateFull:"Washington",region:"Whatcom County â North Sound",h1:"Zorganics Institute of Beauty & Wellness â Bellingham Campus",subtitle:"The Founding Campus · Master Educator Frida Emalange",metaDescription:"Zorganics Institute of Beauty & Wellness â Bellingham Campus. Professional beauty and wellness education combining science-based learning, hands-on experience, professional development, and preparation for licensed careers. NACCAS accredited · VA education benefits approved · Washington State approved programs.",tagline:"Where the Inside-Out Philosophy Began",name:"Zorganics Institute â Bellingham Campus",street:"410 West Bakerview Road",suite:"Suite 112",postalCode:"98226",phone:"+1-360-392-8243",phoneDisplay:"(360) 392-8243",email:"[email protected]",latitude:48.7956,longitude:-122.4848,hours:[{days:"Monday â Thursday",open:"08:30",close:"20:00"},{days:"Friday",open:"08:30",close:"18:00"},{days:"Saturday",open:"Closed",close:"Closed"},{days:"Sunday",open:"Closed",close:"Closed"}],facilityNarrative:"Located at 410 West Bakerview Road, Suite 112, our Bellingham campus is the active home of the Inside-Out philosophy. This modern, fully equipped teaching facility in the Bakerview corridor pairs Pacific Northwest warmth with professional training standards â featuring an instructor-supervised Student Salon & Esthetics Clinic, classrooms, and hands-on practical training space
1189s, all minutes from Bellis Fair Mall and Bellingham International Airport.",facilityHighlights:["Modern Bakerview Rd teaching facility â Suite 112","Instructor-Supervised Student Salon & Esthetics Clinic","Classrooms","Hands-On Practical Training Spaces","On-site botanical compounding studio","Free parking · minutes from BLI airport"],programs:[{name:"Master Esthetician",hours:"1,200 Clock Hours",status:"Enrolling",group:"licensure",description:"A comprehensive pathway combining foundational and advanced esthetics education for students preparing for Washington State Master Esthetician licensure."},{name:"Cosmetologist",hours:"1,600 Clock Hours",status:"Enrolling",group:"licensure",description:"Comprehensive professional education in hair, beauty services, foundational skincare and nail care, client services, safety and sanitation, and professional practice â preparing students for Washington State Cosmetologist licensure."},{name:"Esthetician",hours:"750 Clock Hours",status:"Enrolling",group:"licensure",description:"Professional skincare education combining skin science, facial treatments, client consultation, practical training, safety and sanitation, and career preparation for Washington State Esthetician licensure."},{name:"Manicurist",hours:"600 Clock Hours",status:"Enrolling",group:"licensure",description:"Professional nail-care education covering manicuring, pedicuring, nail services, client care, safety and sanitation, and professional practice â preparing students for Washington State Manicurist licensure."},{name:"Master Esthetician â 450-Hour Advanced Program",hours:"450 Clock Hours",status:"Enrolling",group:"advanced",description:"Advanced education designed for licensed Estheticians continuing their training toward Washington State Master Esthetician licensure."},{name:"Instructor Training",hours:"600 Clock Hours",status:"Varies",group:"advanced",description:"Professional instructor education for qualified beauty professionals preparing to develop the teaching skills, instructional knowledge, classroom leadership, and practical experience needed to educate the next generation of beauty professionals."}],drivingDirections:[{from:"Seattle (I-5 N)",route:"I-5 N to Exit 256B (Bakerview Rd) â west on W Bakerview Rd",eta:"~90 min · 90 mi"},{from:"Vancouver, BC",route:"Hwy 99 S â I-5 S to Exit 256B (Bakerview Rd) â west on W Bakerview Rd",eta:"~55 min · 38 mi"},{from:"Mount Vernon",route:"I-5 N to Exit 256B â west on W Bakerview Rd",eta:"~30 min · 29 mi"}],transit:["WTA Bus Routes 27, 232 â Bakerview Rd & Northwest Ave","Bellingham Intl. Airport (BLI) â 1.5 mi / 4 min","Amtrak Cascades â Bellingham Station (4 mi)"],landmarks:["Bellis Fair Mall â 0.6 mi","Bellingham International Airport (BLI) â 1.5 mi","Cordata Park â 1.8 mi","Western Washington University â 4.5 mi"],mapQuery:"Zorganics+Institute+Bellingham+WA",openedYear:2018,openingDate:"Now Enrolling · Zorganics Institute Founded 2018 · Brand Heritage Since 2002",director:{name:"Frida Emalange",title:"Founder & Master Educator"},instructors:[{name:"Frida Emalange",title:"Founder & Master Educator",credentials:"Licensed Master Esthetician · COES · WA Instructor License",specialty:"Botanical Chemistry · Inside-Out Philosophy · Oncology Esthetics"},{name:"Anika Sørensen, LE",title:"Lead Master Esthetics Instructor",credentials:"WA Master Esthetics License · COES Certified",specialty:"Advanced Facials · Microcurrent · LED Therapy"},{name:"Marcus Whitfield",title:"Cosmetology Department Chair",credentials:"WA Cosmetology Instructor License · 18 yrs experience",specialty:"Precision Cutting · Color Theory · Textured Hair Mastery"},{name:"Priya Lakshminarayan",title:"Botanical Lab Director",credentials:"M.S. Cosmetic Chemistry · COES",specialty:"Wild-Harvested Formulation · Sea Lavender Bio-Actives"},{name:"Joshua Eagleheart",title:"Manicurist Lead Instructor",credentials:"WA Manicurist Instructor License",specialty:"Russian Manicure · Gel Systems · Salon Sanitation"},{name:"Bethany Cole, RN",title:"Oncology Esthetics Clinical Mentor",credentials:"RN · COES · 12 yrs oncology nursing",specialty:"Compromised-Skin Protocols · Lymphatic Drainage"}],gallery:[{url:"https://d64gsuwffb70l.cloudfront.net/69caed6904ed6aca7682413a_1776706470980_142329d6.jpg",caption:"The Bellingham reception at 410 West Bakerview Rd, Suite 112"},{url:"https://d64gsuwffb70l.cloudfront.net/69caed6904ed6aca7682413a_1776755638060_5e202091.png",caption:"Admissions atrium with antique-gold detailing"},{url:"https://images.unsplash.com/photo-1560066984-138dadb4c035?w=800&q=80",caption:"Hands-on practical training space"},{url:"https://images.unsplash.com/photo-1522337360788-8b13dee7a37e?w=800&q=80",caption:"Student clinic â open to the public TuesâSat"},{url:"https://images.unsplash.com/photo-1487412720507-e7ab37603c6f?w=800&q=80",caption:"On-site botanical compounding studio"},{url:"https://images.unsplash.com/photo-1600948836101-f9ffda59d250?w=800&q=80",caption:"Cosmetology floor with antique-mirror styling stations"}]},FI={slug:"seattle",city:"Seattle",state:"WA",stateFull:"Washington",region:"King County",h1:"Zorganics Institute Seattle · Coming 2027",subtitle:"Coming 2027",metaDescription:"Zorganics Institute Seattle · Coming 2027. Zorganics Institute is planning future expansion into Seattle and the greater King County area. Campus location, programs, enrollment dates, schedules, and facility details will be announced once finalized.",tagline:"Coming 2027",name:"Zorganics Institute Seattle",street:"",postalCode:"",phone:"",ph
1189oneDisplay:"",email:"",latitude:0,longitude:0,hours:[],facilityNarrative:"",facilityHighlights:[],preLaunch:!0,facilityComingSoon:{heading:"Zorganics Institute Seattle · Coming 2027",paragraphs:["Zorganics Institute is planning future expansion into Seattle and the greater King County area, extending access to professional beauty and wellness education in the Central Puget Sound region.","The future Seattle campus is currently in the planning and location-development stage. The final campus location, programs offered, enrollment dates, schedules, facility features, and other campus details will be announced once finalized and applicable approvals are completed."],interestHeading:"Interested in Seattle?",interestBody:"Contact Zorganics Institute to receive future updates about the planned Seattle location, program availability, and enrollment opportunities.",phone:"(360) 392-8243",phoneHref:"tel:+13603928243",email:"[email protected]",emailHref:"mailto:[email protected]",ctaLabel:"Contact Admissions",ctaHref:"mailto:[email protected]?subject=Seattle%20Campus%20Updates"},programs:[],drivingDirections:[],transit:[],landmarks:[],mapQuery:"",openedYear:2027,openingDate:"Coming 2027",director:{name:"",title:""},instructors:[],gallery:[]},TI={slug:"renton",city:"Renton",state:"WA",stateFull:"Washington",region:"South King County",h1:"Zorganics Institute Renton · Coming Soon",subtitle:"Coming Soon",metaDescription:"Zorganics Institute Renton · Coming Soon. Zorganics Institute is planning future expansion into South King County. Campus location, programs, enrollment dates, schedules, and facility details will be announced once finalized.",tagline:"Coming Soon",name:"Zorganics Institute Renton",street:"",postalCode:"",phone:"",ph
1189oneDisplay:"",email:"",latitude:0,longitude:0,hours:[],facilityNarrative:"",facilityHighlights:[],preLaunch:!0,facilityComingSoon:{heading:"Zorganics Institute Renton · Coming Soon",paragraphs:["Zorganics Institute is planning future expansion into South King County to bring professional beauty and wellness education closer to students throughout Renton and surrounding communities.","The future Renton campus is currently in the planning and location-development stage. Campus location, programs, enrollment dates, schedules, and facility details will be announced once finalized and applicable approvals are completed."],interestHeading:"Interested in Renton?",interestBody:"Contact Zorganics Institute to receive future updates about the planned Renton location, program availability, and enrollment opportunities.",phone:"(360) 392-8243",phoneHref:"tel:+13603928243",email:"[email protected]",emailHref:"mailto:[email protected]",ctaLabel:"Contact Admissions",ctaHref:"mailto:[email protected]?subject=Renton%20Campus%20Updates"},programs:[],drivingDirections:[],transit:[],landmarks:[],mapQuery:"",openedYear:2026,openingDate:"Coming Soon",director:{name:"",title:""},instructors:[],gallery:[]},H3={bellingham:EI,seattle:FI,renton:TI},Th=[EI,FI,TI],PK=t=>t in H3?H3[t]:null,r1=2002,DK=2007,RK=2012,PI=2018,IK=2021,$K=2024,DI=2026,Hy="Coming Soon · Planned Expansion",zK="Renton Campus â Coming Soon · Planned Expansion. Location and opening timeline will be announced once finalized and required approvals are completed.",Ohe=[{year:r1,title:"Zora's Styling Salon Opens",desc:"Inspired by a vision to serve the Bellingham community, Frida Emalange opened Zora's Styling Salon, creating a welcoming space known for professional textured hair services, personalized care, and lasting client relationships."},{year:DK,title:"Zorganics Cosmetics is Founded",desc:"As clients sought trusted professional skincare recommendations, Zorganics Cosmetics was established to provide botanical skincare products rooted in quality, wellness, and healthy beauty."},{year:RK,title:"Expansion to Bellevue",desc:"The Zorganics vision expanded with the opening of a second salon location in Bellevue, bringing professional beauty and wellness services to a growing community."},{year:PI,title:"Zorganics Institute of Beauty & Wellness",desc:"Recognizing the growing demand for exceptional beauty education, Frida founded Zorganics Institute of Beauty & Wellness to prepare future professionals through A Holistic Approach to Beauty & Wellness Through Science & Art."},{year:IK,title:"A Year of Transformation",desc:"Zorganics Institute achieved NACCAS Accreditation, and Frida established the Zorganics Foundation, expanding the organization's commitment to education, compassionate care, scholarships, and community impact."},{year:$K,title:"Federal Financial Aid Approved",desc:"The Institute received approval to participate in the Title IV Federal Financial Aid program, creating greater access to accredited education for students pursuing careers in Master Esthetics, Esthetics, Cosmetology, and Manicuring."},{year:DI,yearLabel:"The Future",title:"Growing the Zorganics Vision",desc:"With continued growth, Zorganics is expanding educational opportunities to serve more communities throughout Washington while remaining committed to excellence in beauty, wellness, education, and community service."}],G3="(360) 392-8243",V3="[email protected]",RI={bellingham:{subtitle:"Active · Current Teaching Facility",features:["Active Student Clinic","Full Curriculum Delivery","NACCAS Accredited","Title IV Approved"],future:!1,badgeLabel:""},renton:{subtitle:Hy,features:["Central Hub Location","I-405 Corridor Access","Workforce-Aligned Programs","WIOA & WorkSource Partner"],future:!0,badgeLabel:Hy,openingYear:DI}},LK=["bellingham","renton"];function OK(t){const s=RI[t.slug];return s!=null&&s.future&&(!t.street||t.street.trim()==="")?`${t.city}, ${t.state}`:[t.street,t.suite,`${t.city}, ${t.state} ${t.postalCode}`.trim()].filter(Boolean).join(", ")}function II(){return LK.map(t=>{const s=Th.find(a=>a.slug===t),n=RI[t];return!s||!n?{name:`${t.charAt(0).toUpperCase()}${t.slice(1)} Campus`,subtitle:(n==null?void 0:n.subtitle)??"",address:"",phone:G3,email:V3,features:(n==null?void 0:n.features)??[],future:(n==null?void 0:n.future)??!1,badgeLabel:(n==null?void 0:n.badgeLabel)??"",openingYear:n==null?void 0:n.openingYear}:{name:`${s.city}
1189 Campus`,subtitle:n.subtitle,address:OK(s),phone:s.phoneDisplay||G3,email:V3,features:n.features,future:n.future,badgeLabel:n.badgeLabel,openingYear:n.openingYear}})}function MK(t=new Date){return t.getFullYear()-r1}function Mhe(t=new Date){return t.getFullYear()-PI}function BK(){return II().length}function UK(t=new Date){return`${MK(t)}+ years`}function qK(){return Hy}function Bhe(){return qK()}function Z3(){return`Founded ${r1} by Frida Emalange`}function WK(){return`Since ${r1}`}const Y3=[{value:"cosmetology",label:"Cosmetology (1,600 hrs)"},{value:"master-esthetics",label:"Master Esthetics (1,200 hrs) â Full Program"},{value:"esthetics",label:"Esthetics (750 hrs)"},{value:"manicurist",label:"Manicurist Program (600 hrs) â Formerly Nail Technology"},{value:"instructor",label:"Instructor Program (600 hrs) â For Licensed Pros"},{value:"advanced-master",label:"Advanced Master Esthetics (450 hrs) â Accelerated Bridge"}],Ev=[{value:"bellingham",label:"Bellingham, WA â Bakerview Campus",address:"410 West Bakerview Rd, Suite 112, Bellingham, WA 98226"},{value:"seattle",label:"Seattle, WA Campus",address:"Seattle, WA"},{value:"renton",label:`Renton Campus (${Hy})`,address:zK}],HK=["9:00 AM","10:00 AM","11:00 AM","12:00 PM","1:00 PM","2:00 PM","3:00 PM","4:00 PM"],K3="043003",Q3=["Z Bank 0% Interest Tuition Installment Plan â split tuition into monthly payments with no interest or finance charges.","Z Bank Deferred-Start Plan â begin payments after your program start date.","Z Bank Title IV Bridge â short-term funding while your federal aid (FAFSA, School Code 043003) is processed.","Z Bank Scholarship & Workforce (WIOA) Match â applied alongside Pell Grants and Federal Direct Loans."],GK=/^[^\s@]+@[^\s@]+\.[^\s@]{2,}$/,VK=t=>GK.test(t.trim()),$I=t=>t.replace(/\D/g,""),ZK=t=>{const s=$I(t);return!!(s.length===10||s.length===11&&s.startsWith("1"))},YK=t=>{const s=$I(t).slice(0,11),n=s.startsWith("1")&&s.length>10?s.slice(1):s;return n.length===0?"":n.length<=3?`(${n}`:n.length<=6?`(${n.slice(0,3)}) ${n.slice(3)}`:`(${n.slice(0,3)}) ${n.slice(3,6)}-${n.slice(6,10)}`},Cs="#2A060C",Fv="#E6D2A0",KK="#FAF6EE",J3=({isOpen:t,onClose:s,formType:n,prefilledProgram:a})=>{var A;const[r,i]=d.useState({first_name:"",last_name:"",email:"",phone:"",program_interest:a||"",preferred_campus:"bellingham",preferred_date:"",preferred_time:"",message:""}),[o,l]=d.useState({}),[c,u]=d.useState(!1),[p,m]=d.useState(!1),[x,h]=d.useState(""),[y,v]=d.useState(!1),[g,N]=d.useState(!1),[b,f]=d.useState(!0),j=FK();d.useEffect(()=>{t&&a&&i(z=>z.program_interest===a?z:{...z,program_interest:a})},[t,a]);const S=n==="apply_now",w=S?"Apply Now":"Book a Campus Tour",_=S?"Start your journey in organic beauty education. Complete this form and our admissions team will contact you within 24 hours.":"Experience our state-of-the-art facilities in person. Schedule a personalized campus tour with our admissions team.",C=d.useMemo(()=>{const z={};if(r.first_name.trim()?r.first_name.trim().length<2&&(z.first_name="Please enter your full first name."):z.first_name="First name is required.",r.last_name.trim()?r.last_name.trim().length<2&&(z.last_name="Please enter your full last name."):z.last_name="Last name is required.",r.email.trim()?VK(r.email)||(z.email="Please enter a valid email (e.g. [email protected])."):z.email="Email address is required.",r.phone.trim()?ZK(r.phone)||(z.phone="Please enter a valid US phone â 10 digits."):z.phone="Phone number is required.",r.program_interest||(z.program_interest="Please choose a program of interest."),n==="book_tour"){if(!r.preferred_date)z.preferred_date="Please select a preferred tour date.";else{const M=new Date;M.setHours(0,0,0,0);const R=new Date(r.preferred_date+"T00:00:00");Number.isNaN(R.getTime())?z.preferred_date="Please choose a valid date.":R<M&&(z.preferred_date="Tour date must be today or later.")}r.preferred_time||(z.preferred_time="Please select a preferred time.")}return z},[r,n]),E=Object.keys(C).length===0;if(!t)return null;const P=z=>{const{name:M,value:R}=z.target;i(M==="phone"?T=>({...T,phone:YK(R)}):T=>({...T,[M]:R}))},F=z=>{l(M=>({...M,[z.target.name]:!0}))},I=z=>{if(o[z]&&C[z])return C[z]},D=(z,M=!1)=>{const R=!!I(z),T=`w-full ${M?"pl-10":"pl-4"} pr-4 py-2.5 rounded-xl text-sm bg-white transition-all focus:outline-none focus:ring-2`;return R?`${T} border border-r border-y border-l-[3px] border-y-[${$}]/30 border-r-[${$}]/30 border-l-[${$}
1189] focus:ring-[${$}]/40`:`${T} border border-gray-200 focus:ring-[${$}]/30 focus:border-[${$}]`},L=async z=>{var M;if(z.preventDefault(),l({first_name:!0,last_name:!0,email:!0,phone:!0,program_interest:!0,...n==="book_tour"?{preferred_date:!0,preferred_time:!0}:{}}),h(""),g||l(R=>({...R,acknowledged:!0})),!(!E||!g)){u(!0);try{const R=(M=Y3.find(W=>W.value===r.program_interest))==null?void 0:M.label,T=Ev.find(W=>W.value===r.preferred_campus),U=T==null?void 0:T.label,q=T==null?void 0:T.address,H=[n==="apply_now"?"apply-now":"book-tour",n==="apply_now"?"applicant":"tour-request","institute-lead",r.preferred_campus?`campus:${r.preferred_campus}`:null,r.program_interest?`program:${r.program_interest}`:null].filter(Boolean),G=await L5({formType:n==="apply_now"?"apply_now_lead":"book_tour_lead",payload:{name:`${r.first_name.trim()} ${r.last_name.trim()}`.trim(),first_name:r.first_name.trim(),last_name:r.last_name.trim(),email:r.email.trim().toLowerCase(),phone:r.phone||null,program_interest:r.program_interest||null,preferred_campus:r.preferred_campus,preferred_date:r.preferred_date||null,preferred_time:r.preferred_time||null,message:r.message||null,source:n},crm:{source:n,name:`${r.first_name.trim()} ${r.last_name.trim()}`.trim(),phone:r.phone||void 0,sms_opt_in:b===!0,tags:H,metadata:{first_name:r.first_name.trim(),last_name:r.last_name.trim(),program_interest:r.program_interest,program_label:R,preferred_campus:r.preferred_campus,campus_label:U,preferred_date:r.preferred_date||void 0,preferred_time:r.preferred_time||void 0,message:r.message||void 0,form_type:n,submitted_at:new Date().toISOString()}},security:j.envelope()});if(!G.ok){h(G.message||"Something went wrong. Please try again."),j.reset(),u(!1);return}try{await O.functions.invoke("send-lead-confirmation",{body:{form_type:n,first_name:r.first_name.trim(),last_name:r.last_name.trim(),email:r.email.trim().toLowerCase(),phone:r.phone||void 0,program_interest:r.program_interest,program_label:R,preferred_campus:r.preferred_campus,campus_label:U,campus_address:q,preferred_date:r.preferred_date||void 0,preferred_time:r.preferred_time||void 0,message:r.message||void 0,submitted_at:new Date().toISOString(),federal_school_code:K3,z_bank_options:Q3,financial_aid:{federal_school_code:K3,fafsa_url:"https://studentaid.gov",z_bank_options:Q3}}})}catch{}try{await NI({studentName:`${r.first_name.trim()} ${r.last_name.trim()}`.trim(),studentEmail:r.email.trim().toLowerCase(),source:n==="apply_now"?"admissions-apply-form":"admissions-tour-form"})}catch{}m(!0)}catch(R){h((R==null?void 0:R.message)||"Something went wrong. Please try again.")}finally{u(!1)}}},V=()=>{i({first_name:"",last_name:"",email:"",phone:"",program_interest:"",preferred_campus:"bellingham",preferred_date:"",preferred_time:"",message:""}),l({}),N(!1),f(!0),m(!1),h(""),s()},B=({field:z})=>{const M=I(z);return M?e.jsxs("p",{className:"mt-1.5 flex items-start gap-1.5 text-[11px] font-medium leading-snug",style:{color:Cs},children:[e.jsx(Mt,{size:12,className:"mt-0.5 flex-shrink-0",style:{color:$}}),e.jsx("span",{children:M})]}):null};return e.jsxs("div",{className:"fixed inset-0 z-[100] flex items-center justify-center p-4",onClick:V,children:[e.jsx("div",{className:"absolute inset-0 bg-black/60 backdrop-blur-sm"}),e.jsxs("div",{className:"relative w-full max-w-2xl max-h-[90vh] overflow-y-auto bg-white rounded-2xl shadow-2xl",onClick:z=>z.stopPropagation(),children:[e.jsxs("div",{className:"sticky top-0 z-10 px-6 py-5 rounded-t-2xl",style:{background:`linear-gradient(135deg, ${k} 0%, #5A0018 100%)`,borderBottom:`1.5px solid ${$}`,boxShadow:`0 1px 0 ${$}33`},children:[e.jsx("button",{onClick:V,className:"absolute top-4 right-4 p-1.5 rounded-lg bg-white/10 hover:bg-white/20 transition-colors",style:{color:$},"aria-label":"Close form",children:e.jsx(Ke,{size:18})}),e.jsxs("div",{className:"flex items-center gap-3 mb-2",children:[e.jsx("div",{className:"w-10 h-10 rounded-xl flex items-center justify-center",style:{background:`${$}25`,border:`1px solid ${$}55`},children:S?e.jsx(_t,{size:22,style:{color:$}}):e.jsx(At,{size:22,style:{color:$}})}),e.jsxs("div",{children:[e.jsx("h2",{className:"text-xl font-bold text-white font-display",children:w}),e.jsx("p",{className:"text-xs",style:{color:`${Fv}`},children:"Zorganics Institute of Beauty & Wellness"})]})]}),e.jsx("p",{className:"text-sm text-white/75 leading-relaxed",children:_})]}),p?e.jsxs("div",{className:"px-6 py-12 text-center",children:[e.jsx("div",{className:"w-16 h-16 rounded-full flex items-center justify-center mx-auto mb-4",style:{background:`${$}1A`,border:`2px solid ${$}`},children:e.jsx(pt,{size:32,style:{color:k}})}),e.jsx("h3",{className:"text-xl font-bold mb-2 font-display",style:{color:Cs},children:S?"Application Received!":"Tour Scheduled!"}),e.jsx("p",{className:"mb-2 max-w-md mx-auto text-gray-600",children:S?`Thank y
1189ou, ${r.first_name}! Our admissions team will review your application and contact you within 24 hours.`:`Thank you, ${r.first_name}! We'll confirm your campus tour at ${((A=Ev.find(z=>z.value===r.preferred_campus))==null?void 0:A.label)||"our campus"} shortly.`}),e.jsxs("p",{className:"text-sm text-gray-400 mb-6",children:["A confirmation has been sent to ",r.email]}),e.jsxs("div",{className:"flex items-center justify-center gap-3 text-sm text-gray-500",children:[e.jsx(Qt,{size:14,style:{color:$}}),e.jsxs("span",{children:["Questions? Call us at ",e.jsx("a",{href:"tel:+13603928243",className:"font-semibold hover:underline",style:{color:k},children:"(360) 392-8243"})]})]}),e.jsx("button",{onClick:V,className:"mt-6 px-6 py-2.5 rounded-xl font-semibold transition-all",style:{background:k,color:$,border:`1px solid ${$}`},children:"Close"})]}):e.jsxs("form",{onSubmit:L,noValidate:!0,className:"px-6 py-6 space-y-5",style:{background:KK},children:[x&&e.jsxs("div",{className:"flex items-center gap-2 px-4 py-3 rounded-xl text-sm",style:{background:"#fff",border:`1px solid ${$}`,color:Cs},children:[e.jsx(Mt,{size:16,style:{color:$}}),x]}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[e.jsxs("div",{children:[e.jsxs("label",{className:"block text-xs font-semibold mb-1.5",style:{color:Cs},children:["First Name ",e.jsx("span",{style:{color:$},children:"*"})]}),e.jsxs("div",{className:"relative",children:[e.jsx(yr,{size:15,className:"absolute left-3 top-1/2 -translate-y-1/2 text-gray-400"}),e.jsx("input",{type:"text",name:"first_name",value:r.first_name,onChange:P,onBlur:F,placeholder:"First name","aria-invalid":!!I("first_name"),className:D("first_name",!0)})]}),e.jsx(B,{field:"first_name"})]}),e.jsxs("div",{children:[e.jsxs("label",{className:"block text-xs font-semibold mb-1.5",style:{color:Cs},children:["Last Name ",e.jsx("span",{style:{color:$},children:"*"})]}),e.jsx("input",{type:"text",name:"last_name",value:r.last_name,onChange:P,onBlur:F,placeholder:"Last name","aria-invalid":!!I("last_name"),className:D("last_name")}),e.jsx(B,{field:"last_name"})]})]}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[e.jsxs("div",{children:[e.jsxs("label",{className:"block text-xs font-semibold mb-1.5",style:{color:Cs},children:["Email Address ",e.jsx("span",{style:{color:$},children:"*"})]}),e.jsxs("div",{className:"relative",children:[e.jsx(Ye,{size:15,className:"absolute left-3 top-1/2 -translate-y-1/2 text-gray-400"}),e.jsx("input",{type:"email",name:"email",value:r.email,onChange:P,onBlur:F,placeholder:"[email protected]",autoComplete:"email","aria-invalid":!!I("email"),className:D("email",!0)})]}),e.jsx(B,{field:"email"})]}),e.jsxs("div",{children:[e.jsxs("label",{className:"block text-xs font-semibold mb-1.5",style:{color:Cs},children:["Phone Number ",e.jsx("span",{style:{color:$},children:"*"})]}),e.jsxs("div",{className:"relative",children:[e.jsx(Qt,{size:15,className:"absolute left-3 top-1/2 -translate-y-1/2 text-gray-400"}),e.jsx("input",{type:"tel",name:"phone",value:r.phone,onChange:P,onBlur:F,placeholder:"(360) 555-0123",autoComplete:"tel",inputMode:"tel","aria-invalid":!!I("phone"),className:D("phone",!0)})]}),e.jsx(B,{field:"phone"})]})]}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[e.jsxs("div",{children:[e.jsxs("label",{className:"block text-xs font-semibold mb-1.5",style:{color:Cs},children:[e.jsx(_t,{size:12,className:"inline mr-1",style:{color:$}}),"Program of Interest ",e.jsx("span",{style:{color:$},children:"*"})]}),e.jsxs("select",{name:"program_interest",value:r.program_interest,onChange:P,onBlur:F,"aria-invalid":!!I("program_interest"),className:D("program_interest"),children:[e.jsx("option",{value:"",children:"Select a program..."}),Y3.map(z=>e.jsx("option",{value:z.value,children:z.label},z.value))]}),e.jsx(B,{field:"program_interest"})]}),e.jsxs("div",{children:[e.jsxs("label",{className:"block text-xs font-semibold mb-1.5",style:{color:Cs},children:[e.jsx(zt,{size:12,className:"inline mr-1",style:{color:$}}),"Preferred Campus"]}),e.jsx("select",{name:"preferred_campus",value:r.preferred_campus,onChange:P,onBlur:F,className:"w-full px-4 py-2.5 border border-gray-200 rounded-xl text-sm bg-white focus:outline-none focus:ring-2 focus:ring-[#D4AF37]/30 focus:border-[#D4AF37] transition-all",children:Ev.map(z=>e.jsx("option",{value:z.value,children:z.label},z.value))})]})]}),n==="book_tour"&&e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[e.jsxs("div",{children:[e.jsxs("label",{className:"block text-xs font-semibold mb-1.5",style:{color:Cs},children:[e.jsx(At,{size:12,className:"inline mr-1",style:{color:$}}),"Preferred Date ",e.jsx("span",{style:{color:$},children:"*"})]}),e.jsx("input",{type:"date",name:"preferred_date",value:r.preferred_date,onChange:P,onBlur:F,min:new Date().toISOString().split("T")[0],"aria-invalid":!!I("preferred_date"),className:D("preferred_date")}),e.jsx(B,{field:"preferred_date"})]}),e.jsxs("div",{children:[e.jsxs("label",{className:"block text-xs font-semibold mb-1.5",style:{color:Cs},children:[e.jsx(dt,{size:12,className:"inline mr-1",style:{color:$}}),"Preferred Time ",e.jsx("span",{style:{color:$},children:"*"})]}),e.jsxs("select",{name:"preferred_time",value:r.preferred_time,onChange:P,onBlur:F,"aria-invalid":!!I("preferred_time"),className:D("preferred_time"),children:[e.jsx("option",{value:"",children:"Select a time..."}),HK.map(z=>e.jsx("option",{value:z,children:z},z))]}),e.jsx(B,{field:"preferred_time"})]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs font-semibold mb-1.5",style:{color:Cs},children:S?"Tell us about yourself (optional)":"Any questions or special requests? (optional)"}),e.jsx("textarea",{name:"message",value:r.message,onChange:P,rows:3,placeholder:S?"Share your goals, experience, or questions...":"Let us know if you have any accessibility needs or specific areas you'd like to see...",className:"w-full px-4 py-2.5 border border-gray-200 rounded-xl text-sm focus:outline-none focus:ring-2 focus:ring-[#D4AF37]/30 focus:border-[#D4AF37] transition-all resize-none bg-white"})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-x-4 gap-y-2 px-4 py-3 rounded-xl",style:{background:"#fff",border:`1px solid ${$}40`},children:[e.jsxs("a",{href:"tel:+13603928243",className:"flex items-center gap-2 text-xs transition-colors hover:underline",style:{color:Cs},children:[e.jsx(Qt,{size:13,style:{color:$}}),e.jsx("span",{className:"font-semibold",children:"(360) 392-8243"})]}),e.jsx("div",{className:"w-px h-4 bg-gray-300"}),e.jsxs("a",{href:"mailto:[email protected]",className:"flex items-center gap-2 text-xs transition-colors hover:underline",style:{color:Cs},children:[e.jsx(Ye,{size:13,style:{color:$}}),e.jsx("span",{className:"font-semibold",children:"[email protected]"})]}),e.jsx("div",{className:"w-px h-4 bg-gray-300"}),e.jsxs("div",{className:"flex items-center gap-2 text-xs",style:{color:Cs},children:[e.jsx(zt,{size:13,style:{color:$}}),e.jsx("span",{className:"font-semibold",children:"Bellingham, WA â Bakerview Campus"})]})]}),e.jsxs("label",{className:"flex items-start gap-2.5 px-4 py-3 rounded-xl cursor-pointer",style:{background:"#fff",border:`1px solid ${$}30`},children:[e.jsx("input",{type:"checkbox",checked:b,onChange:z=>f(z.target.checked),className:"mt-0.5 accent-[#D4AF37]"}),e.jsx("span",{className:"text-[11px] leading-relaxed",style:{color:Cs},children:"Text me admissions updates and tour reminders. Msg & data rates may apply. Reply STOP to unsubscribe."})]}),e.jsxs("label",{htmlFor:"disclosure-ack",className:"flex items-start gap-3 px-4 py-3.5 rounded-xl cursor-pointer transition-all",style:{background:g?`${$}12`:"#fff",border:`1.5px solid ${g||o.acknowledged?$:$+"40"}`,boxShadow:g?`0 4px 14px ${$}22, inset 0 0 0 1px ${$}33`:"none"},children:[e.jsx("span",{className:"mt-0.5 flex-shrink-0 w-5 h-5 rounded-md flex items-center justify-center transition-all",style:{background:g?`linear-gradient(135deg, ${$}, #B8962E)`:"#fff",border:`1.5px solid ${g?$:"#cbd5e1"}`},children:g&&e.jsx(pt,{size:13,style:{color:k}})}),e.jsx("input",{id:"disclosure-ack",type:"checkbox",checked:g,onChange:z=>{N(z.target.checked),l(M=>({...M,acknowledged:!0}))},className:"sr-only","aria-required":"true"}),e.jsxs("span",{className:"text-[12px] leading-relaxed",style:{color:Cs},children:[e.jsx(LP,{size:12,className:"inline mr-1 -mt-0.5",style:{color:$}}),e.jsx("span",{className:"font-semibold",children:wI}),e.jsx("span",{className:"block mt-1 text-[10px]",style:{color:`${Cs}99`},children:"Required â your acknowledgement is recorded as a timestamped legal record for FSA / NACCAS audit purposes."})]})]}),o.acknowledged&&!g&&e.jsxs("p",{className:"-mt-2 flex items-start gap-1.5 text-[11px] font-medium leading-snug",style:{color:Cs},children:[e.jsx(Mt,{size:12,className:"mt-0.5 flex-shrink-0",style:{color:$}}),e.jsx("span",{children:"Please acknowledge access to the School C
1189atalog and Consumer Disclosures to continue."})]}),e.jsx(TK,{security:j,accent:$}),e.jsx("button",{type:"submit",disabled:c||!E||!g||!j.verified,onMouseEnter:()=>v(!0),onMouseLeave:()=>v(!1),onFocus:()=>v(!0),onBlur:()=>v(!1),className:"w-full flex items-center justify-center gap-2 px-6 py-3.5 rounded-xl font-semibold transition-all duration-300 disabled:opacity-50 disabled:cursor-not-allowed disabled:hover:translate-y-0",style:{background:!c&&E&&g&&y?`linear-gradient(135deg, ${$} 0%, ${Fv} 50%, ${$} 100%)`:`linear-gradient(135deg, ${k} 0%, #5A0018 100%)`,color:!c&&E&&g&&y?k:$,border:`1px solid ${!c&&E&&g&&y?Fv:$}`,boxShadow:!c&&E&&g&&y?`0 12px 32px ${$}55, 0 0 24px ${$}66, inset 0 0 0 3px ${$}`:`0 6px 18px ${k}40, inset 0 0 0 1px ${$}33`,transform:!c&&E&&g&&y?"translateY(-1px)":"translateY(0)"},"aria-disabled":c||!E||!g,"aria-label":c?"Submittingâ¦":S?"Submit application":"Schedule tour",children:c?e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"w-5 h-5 border-2 rounded-full animate-spin",style:{borderColor:`${$}40`,borderTopColor:$}}),e.jsx("span",{children:"Submittingâ¦"})]}):e.jsxs(e.Fragment,{children:[e.jsx(Hs,{size:16}),S?"Submit Application":"Schedule My Tour"]})}),(!E||!g)&&Object.keys(o).length>0&&e.jsx("p",{className:"text-[11px] text-center font-medium",style:{color:Cs},children:"Please complete the highlighted fields and acknowledge the disclosures to continue."}),e.jsxs("p",{className:"flex items-center justify-center gap-1.5 text-[10px] text-center leading-relaxed",style:{color:`${Cs}99`},children:[e.jsx(Ie,{size:11,style:{color:$}}),"By submitting, you consent to being contacted by Zorganics Institute regarding enrollment. Your information is protected under our FERPA-compliant privacy policy."]})]})]})]})},yc="#E6D2A0",tu="#B8962E",X3="#2A0810",QK=({isOpen:t,onClose:s,featureName:n,description:a,expectedDate:r,notifyEmail:i="[email protected]"})=>(d.useEffect(()=>{if(t)return document.body.style.overflow="hidden",()=>{document.body.style.overflow=""}},[t]),d.useEffect(()=>{if(!t)return;const o=l=>{l.key==="Escape"&&s()};return window.addEventListener("keydown",o),()=>window.removeEventListener("keydown",o)},[t,s]),t?e.jsx("div",{className:"fixed inset-0 z-[100] flex items-center justify-center p-4 animate-in fade-in duration-200",style:{background:"rgba(10, 3, 6, 0.75)",backdropFilter:"blur(8px)"},onClick:s,role:"dialog","aria-modal":"true","aria-labelledby":"coming-soon-title",children:e.jsxs("div",{className:"relative w-full max-w-md rounded-2xl overflow-hidden shadow-2xl animate-in zoom-in-95 slide-in-from-bottom-4 duration-300",style:{background:`linear-gradient(180deg, ${k} 0%, ${X3} 100%)`,border:`2px solid ${$}`,boxShadow:`0 20px 60px rgba(0,0,0,0.5), 0 0 0 1px ${$}44, 0 0 40px ${$}22`},onClick:o=>o.stopPropagation(),children:[e.jsx("div",{className:"absolute top-0 left-0 right-0 h-[3px]",style:{background:`linear-gradient(90deg, ${tu}, ${yc} 50%, ${tu})`}}),e.jsxs("div",{className:"absolute inset-0 pointer-events-none overflow-hidden","aria-hidden":"true",children:[e.jsx("div",{className:"absolute -top-20 -right-20 w-60 h-60 rounded-full blur-3xl op
1189acity-20",style:{background:`radial-gradient(circle, ${$}, transparent 70%)`}}),e.jsx("div",{className:"absolute -bottom-20 -left-20 w-48 h-48 rounded-full blur-3xl opacity-15",style:{background:`radial-gradient(circle, ${$}, transparent 70%)`}})]}),e.jsx("button",{onClick:s,className:"absolute top-3 right-3 z-10 w-8 h-8 rounded-full flex items-center justify-center transition-all hover:rotate-90",style:{background:"rgba(255,255,255,0.08)",border:`1px solid ${$}44`,color:yc},"aria-label":"Close",children:e.jsx(Ke,{size:16})}),e.jsxs("div",{className:"relative px-8 py-10 text-center",children:[e.jsx("div",{className:"flex items-center justify-center mb-5",children:e.jsxs("div",{className:"relative w-16 h-16 rounded-full flex items-center justify-center",style:{background:`linear-gradient(135deg, ${$}, ${tu})`,boxShadow:`0 8px 24px ${$}66, inset 0 2px 0 ${yc}`},children:[e.jsx(Qe,{size:28,style:{color:k}}),e.jsx("span",{className:"absolute inset-0 rounded-full animate-pulse",style:{boxShadow:`0 0 30px ${$}88`},"aria-hidden":"true"})]})}),e.jsxs("div",{className:"flex items-center justify-center gap-2 mb-3",children:[e.jsx("div",{className:"h-[1px] w-8",style:{background:`linear-gradient(90deg, transparent, ${$}99)`}}),e.jsx("span",{className:"text-[10px] tracking-[0.35em] uppercase font-bold",style:{color:$,fontFamily:"'Playfair Display', Georgia, serif"},children:"Clinical Preview"}),e.jsx("div",{className:"h-[1px] w-8",style:{background:`linear-gradient(90deg, ${$}99, transparent)`}})]}),e.jsx("h2",{id:"coming-soon-title",className:"text-2xl font-bold mb-2",style:{color:$,fontFamily:"'Playfair Display', Georgia, serif",textShadow:`0 2px 12px ${X3}`},children:"Coming Soon"}),e.jsx("p",{className:"text-base font-semibold mb-4 italic",style:{color:yc,fontFamily:"'Playfair Display', Georgia, serif"},children:n}),e.jsx("p",{className:"text-sm leading-relaxed mb-5",style:{color:"rgba(230,210,160,0.75)"},children:a||e.jsx(e.Fragment,{children:"This feature is being crafted with the same clinical precision as our curriculum. We are actively preparing its launch â your patience is appreciated."})}),r&&e.jsx("div",{className:"flex items-center justify-center mb-5",children:e.jsxs("div",{className:"inline-flex items-center gap-2 px-3.5 py-1.5 rounded-full text-xs font-bold",style:{background:`${$}14`,border:`1px solid ${$}55`,color:$},children:[e.jsx(dt,{size:11}),"Expected · ",r]})}),e.jsxs("div",{className:"mt-6 p-4 rounded-xl",style:{background:"rgba(212,175,55,0.06)",border:`1px solid ${$}33`},children:[e.jsx("p",{className:"text-[11px] uppercase tracking-[0.2em] font-bold mb-2",style:{color:yc,opacity:.75},children:"Need this now?"}),e.jsxs("a",{href:`mailto:${i}?subject=${encodeURIComponent("Request: "+n)}`,className:"group flex items-center justify-center gap-2 w-full py-2.5 rounded-lg text-sm font-bold transition-all hover:scale-[1.02]",style:{background:`linear-gradient(135deg, ${$}, ${tu})`,color:k,boxShadow:`0 4px 16px ${$}44`},children:[e.jsx(Ye,{size:14}),"Contact the Zorganics Team",e.jsx(Vt,{size:14,className:"transition-transform group-hover:translate-x-0.5"})]})]}),e.jsx("p",{className:"text-[10px] italic mt-6 opacity-60",style:{color:yc,fontFamily:"'Playfair Display', Georgia, serif"},children:'"Redefining the foundation of identity."'})]}),e.jsx("div",{className:"absolute bottom-0 left-0 right-0 h-[3px]",style:{background:`linear-gradient(90deg, ${tu}, ${yc} 50%, ${tu})`}})]})}):null),JK=t=>{if(!t)return"Never";const s=Date.now()-new Date(t).getTime(),n=Math.floor(s/6e4);if(n<1)return"Just now";if(n<60)return`${n}m ago`;const a=Math.floor(n/60);return a<24?`${a}h ago`:`${Math.floor(a/24)}d ago`},eA=t=>{const s=Math.abs(t),n=Math.floor(s/3600),a=Math.floor(s%3600/60),r=s%60;let i;return n>0?i=`${n}h ${a}m`:a>0?i=`${a}m ${r}s`:i=`${r}s`,t<=0?`Expired ${i} ago`:`Expires in ${i}`},XK=({pollIntervalMs:t=6e4,tickIntervalMs:s=15e3,className:n="",hideUntilResolved:a=!1,compact:r=!1})=>{const[i,o]=d.useState(null),[l,c]=d.useState(null),[u,p]=d.useState(!1),[m,x]=d.useState(()=>Date.now()),[h,y]=d.useState(!1);d.useEffect(()=>{let C=!1;const E=async()=>{try{const{data:F,error:I}=await O.rpc("whoami");if(C)return;I?c(I.message||"whoami RPC failed"):F&&(o(F),c(null),x(Date.now()))}catch(F){if(C)return;c((F==null?void 0:F.message)||"whoami poll failed")}finally{C||p(!0)}};E();const P=window.setInterval(E,t);return()=>{C=!0,window.clearInterval(P)}},[t]),d.useEffect(()=>{if(!(i!=null&&i.jwt_exp))return;const C=window.setInterval(()=>x(Date.now()),s);return()=>window.clearInterval(C)},[i==null?void 0:i.jwt_exp,s]);const v=d.useMemo(()=>
1189{if(!(i!=null&&i.jwt_exp))return null;const C=i.jwt_exp*1e3,E=Math.floor((C-m)/1e3),P=E<=0,F=P||E<=5*60,I=!F&&E<=30*60;return{expMs:C,secondsLeft:E,expired:P,critical:F,warning:I}},[i==null?void 0:i.jwt_exp,m]),g=d.useCallback(()=>y(!0),[]);if(a&&(!u||!(i!=null&&i.jwt_exp)))return null;const N=!!(i!=null&&i.jwt_exp&&v),b=N?v.critical?"critical":v.warning?"warning":"healthy":"unknown",f={critical:{bg:"#FEF2F2",border:"#FECACA",fg:"#991B1B",icon:e.jsx(kt,{size:r?12:13})},warning:{bg:"#FFFBEB",border:"#FDE68A",fg:"#92400E",icon:e.jsx(ve,{size:r?12:13})},healthy:{bg:"#ECFDF5",border:"#A7F3D0",fg:"#065F46",icon:e.jsx(pt,{size:r?12:13})},unknown:{bg:"#F9FAFB",border:"#E5E7EB",fg:"#6B7280",icon:e.jsx(dt,{size:r?12:13})}}[b],j=N?v.expired?"JWT expired":(()=>{const C=Math.max(0,v.secondsLeft),E=Math.floor(C/3600),P=Math.floor(C%3600/60),F=C%60;return E>0?`JWT ${E}h ${P}m`:P>0?`JWT ${P}m ${F}s`:`JWT ${F}s`})():l?"JWT â":"JWT â¦",S=N?[v.expired?`JWT expired ${eA(v.secondsLeft).replace("Expired ","").replace(" ago","")} ago`:eA(v.secondsLeft),i!=null&&i.jwt_exp_at?`Expires at ${new Date(i.jwt_exp_at).toLocaleString()}`:null,i!=null&&i.jwt_iat_at?`Issued ${JK(i.jwt_iat_at)}`:null,i!=null&&i.profile_email?`Signed in as ${i.profile_email}`:null,"Polls whoami() every 60s · Click to re-authenticate"].filter(Boolean).join(` 1190`):l?`whoami() unavailable: ${l} 1191Click to sign in.`:"Resolving JWT expiry from public.whoami()â¦",w=r?"px-2.5 py-1.5":"px-3 py-2.5",_=r?"text-[11px]":"text-xs";return e.jsxs(e.Fragment,{children:[e.jsxs("button",{type:"button",onClick:g,title:S,"aria-label":`${j}. Click to re-authenticate.`,"aria-live":"polite",className:`inline-flex items-center gap-1.5 ${w} rounded-lg ${_} font-bold border transition-all hover:shadow-md focus:outline-none focus:ring-2 focus:ring-offset-1 ${n}`,style:{backgroundColor:f.bg,borderColor:f.border,color:f.fg,boxShadow:b==="critical"?"0 0 0 3px rgba(239, 68, 68, 0.12)":void 0},children:[f.icon,e.jsx("span",{className:"font-mono tabular-nums",children:j}),b==="critical"&&e.jsxs("span",{className:"relative flex h-2 w-2 ml-0.5",children:[e.jsx("span",{className:"animate-ping absolute inline-flex h-full w-full rounded-full bg-red-400 opacity-75"}),e.jsx("span",{className:"relative inline-flex rounded-full h-2 w-2 bg-red-500"})]})]}),e.jsx(Ex,{isOpen:h,onClose:()=>y(!1)})]})},eQ=({size:t=96,className:s="",compact:n=!1,medallionColor:a=P5,goldColor:r=Wy,title:i="Zorganics Foundation Seal · 501(c)(3) Public Charity"})=>{const o=re.useId().replace(/[:]/g,""),l=`zfs-grad-${o}`,c=`zfs-gold-${o}`,u=`zfs-inner-${o}`,p=`zfs-ring-${o}`;return e.jsxs("svg",{width:t,height:t,viewBox:"0 0 200 200",role:"img","aria-label":i,className:s,style:{display:"block"},children:[e.jsx("title",{children:i}),e.jsxs("defs",{children:[e.jsxs("radialGradient",{id:l,cx:"50%",cy:"40%",r:"65%",children:[e.jsx("stop",{offset:"0%",stopColor:a,stopOpacity:"1"}),e.jsx("stop",{offset:"70%",stopColor:a,stopOpacity:"1"}),e.jsx("stop",{offset:"100%",stopColor:oh,stopOpacity:"1"})]}),e.jsxs("linearGradient",{id:c,x1:"0%",y1:"0%",x2:"100%",y2:"100%",children:[e.jsx("stop",{offset:"0%",stopColor:Jc}),e.jsx("stop",{offset:"50%",stopColor:r}),e.jsx("stop",{offset:"100%",stopColor:ku})]}),e.jsxs("filter",{id:u,x:"-20%",y:"-20%",width:"140%",height:"140%",children:[e.jsx("feGaussianBlur",{in:"SourceAlpha",stdDeviation:"1.5"}),e.jsx("feOffset",{dx:"0",dy:"1",result:"offsetblur"}),e.jsx("feFlood",{floodColor:"#000",floodOpacity:"0.25"}),e.jsx("feComposite",{in2:"offsetblur",operator:"in"}),e.jsxs("feMerge",{children:[e.jsx("feMergeNode",{}),e.jsx("feMergeNode",{in:"SourceGraphic"})]})]}),e.jsx("path",{id:p,d:"M 30,100 A 70,70 0 0 1 170,100",fill:"none"})]}),e.jsx("circle",{cx:"100",cy:"100",r:"96",fill:`url(#${c})`}),e.jsx("circle",{cx:"100",cy:"100",r:"92",fill:a}),e.jsx("circle",{cx:"100",cy:"100",r:"88",fill:"none",stroke:r,strokeWidth:"0.6",opacity:"0.55"}),e.jsx("circle",{cx:"100",cy:"100",r:"84",fill:"none",stroke:r,strokeWidth:"0.4",opacity:"0.35"}),e.jsx("circle",{cx:"100",cy:"100",r:"78",fill:`url(#${l})`,stroke:r,strokeWidth:"1.2"}),!n&&e.jsxs(e.Fragment,{children:[e.jsx("text",{fill:Jc,fontSize:"10.5",fontWeight:"700",letterSpacing:"3.5",style:{fontFamily:"'Inter', system-ui, sans-serif",textTransform:"uppercase"},children:e.jsx("textPath",{href:`#${p}`,startOffset:"50%",textAnchor:"middle",children:"· ZORGANICS FOUNDATION ·"})}),e.jsx("text",{x:"100",y:"178",textAnchor:"middle",fill:Jc,fontSize:"8",fontWeight:"700",letterSpacing:"3",style:{fontFamily:"'Inter', system-ui, sans-serif",textTransform:"uppercase"},children:"EST · 501(c)(3)"}),e.jsxs("g",{fill:r,children:[e.jsx("circle",{cx:"22",cy:"100",r:"1.4"}),e.jsx("circle",{cx:"178",cy:"100",r:"1.4"})]})]}),e.jsxs("g",{filter:`url(#${u})`,children:[e.jsxs("g",{fill:`url(#${c})`,stroke:ku,strokeWidth:"0.4",children:[e.jsx("path",{d:"M 58,135 Q 50,110 56,82 Q 60,68 70,58",fill:"none",stroke:`url(#${c})`,strokeWidth:"2.2",strokeLinecap:"round"}),e.jsx("ellipse",{cx:"49",cy:"125",rx:"6",ry:"3",transform:"rotate(-50 49 125)"}),e.jsx("ellipse",{cx:"46",cy:"113",rx:"6.5",ry:"3.2",transform:"rotate(-58 46 113)"}),e.jsx("ellipse",{cx:"46",cy:"100",rx:"7",ry:"3.4",transform:"rotate(-65 46 100)"}),e.jsx("ellipse",{cx:"48",cy:"86",rx:"6.5",ry:"3.2",transform:"rotate(-72 48 86)"}),e.jsx("ellipse",{cx:"53",cy:"74",rx:"6",ry:"3",transform:"rotate(-80 53 74)"}),e.jsx("ellipse",{cx:"60",cy:"64",rx:"5.5",ry:"2.8",transform:"rotate(-88 60 64)"}),e.jsx("ellipse",{cx:"62",cy:"120",rx:"5",ry:"2.5",transform:"rotate(35 62 120)",opacity:"0.85"}),e.jsx("ellipse",{cx:"62",cy:"108",rx:"5.2",ry:"2.6",transform:"rotate(28 62 108)",opacity:"0.85"}),e.jsx("ellipse",{cx:"63",cy:"95",rx:"5.4",ry:"2.7",transform:"rotate(20 63 95)",opacity:"0.85"}),e.jsx("ellipse",{cx:"65",cy:"82",rx:"5",ry:"2.5",transform:"rotate(12 65 82)",opacity:"0.85"})]}),e.jsxs("g",{fill:`url(#${c})`,stroke:ku,strokeWidth:"0.4",children:[e.jsx("path",{d:"M 142,135 Q 150,110 144,82 Q 140,68 130,58",fill:"none",stroke:`url(#${c})`,strokeWidth:"2.2",strokeLinecap:"round"}),e.jsx("ellipse",{cx:"151",cy:"125",rx:"6",ry:"3",transform:"rotate(50 151 125)"}),e.jsx("ellipse",{cx:"154",cy:"113",rx:"6.5",ry:"3.2",transform:"rotate(58 154 113)"}),e.jsx("ellipse",{cx:"154",cy:"100",rx:"7",ry:"3.4",transform:"rotate(65 154 100)"}),e.jsx("ellipse",{cx:"152",cy:"86",rx:"6.5",ry:"3.2",transform:"rotate(72 152 86)"}),e.jsx("ellipse",{cx:"147",cy:"74",rx:"6",ry:"3",transform:"rotate(80 147 74)"}),e.jsx("ellipse",{cx:"140",cy:"64",rx:"5.5",ry:"2.8",transform:"rotate(88 140 64)"}),e.jsx("ellipse",{cx:"138",cy:"120",rx:"5",ry:"2.5",transform:"rotate(-35 138 120)",opacity:"0.85"}),e.jsx("ellipse",{cx:"138",cy:"108",rx:"5.2",ry:"2.6",transform:"rotate(-28 138 108)",opacity:"0.85"}),e.jsx("ellipse",{cx:"137",cy:"95",rx:"5.4",ry:"2.7",transform:"rotate(-20 137 95)",opacity:"0.85"}),e.jsx("ellipse",{cx:"135",cy:"82",rx:"5",ry:"2.5",transform:"rotate(-12 135 82)",opacity:"0.85"})]}),e.jsxs("g",{children:[e.jsx("path",{d:`M 100,135 1192 C 100,135 70,118 70,95 1193 C 70,82 80,74 90,76 1194 C 96,77 99,82 100,86
1195 C 101,82 104,77 110,76 1196 C 120,74 130,82 130,95 1197 C 130,118 100,135 100,135 Z`,fill:oh,opacity:"0.6",transform:"translate(1.5, 1.5)"}),e.jsx("path",{d:`M 100,135 1198 C 100,135 70,118 70,95 1199 C 70,82 80,74 90,76 1200 C 96,77 99,82 100,86 1201 C 101,82 104,77 110,76 1202 C 120,74 130,82 130,95 1203 C 130,118 100,135 100,135 Z`,fill:`url(#${c})`,stroke:ku,strokeWidth:"0.8"}),e.jsx("path",{d:"M 88,82 C 84,84 82,90 84,96",fill:"none",stroke:Jc,strokeWidth:"1.2",strokeLinecap:"round",opacity:"0.7"}),e.jsxs("g",{stroke:oh,strokeWidth:"0.9",strokeLinecap:"round",opacity:"0.8",children:[e.jsx("line",{x1:"100",y1:"98",x2:"100",y2:"92"}),e.jsx("line",{x1:"93",y1:"100",x2:"89",y2:"96"}),e.jsx("line",{x1:"107",y1:"100",x2:"111",y2:"96"}),e.jsx("line",{x1:"96",y1:"99",x2:"93",y2:"94"}),e.jsx("line",{x1:"104",y1:"99",x2:"107",y2:"94"})]}),e.jsx("text",{x:"100",y:"122",textAnchor:"middle",fill:oh,fontSize:"14",fontWeight:"900",style:{fontFamily:"'Playfair Display', Georgia, serif",fontStyle:"italic"},children:"Z"})]}),e.jsx("g",{fill:r,children:e.jsx("path",{d:"M 92,138 Q 100,142 108,138 L 110,142 Q 100,147 90,142 Z",fill:`url(#${c})`,stroke:ku,strokeWidth:"0.5"})})]}),e.jsxs("g",{fill:r,children:[e.jsx("circle",{cx:"100",cy:"28",r:"2.4"}),e.jsx("circle",{cx:"100",cy:"28",r:"1.1",fill:Jc})]})]})},tA=({height:t=28,className:s="",textColor:n=Wy,medallionColor:a=P5,goldColor:r=Wy,showSubmark:i=!1})=>{const o=Math.round(t*1.05);return e.jsxs("span",{className:`inline-flex items-center gap-2 ${s}`,style:{height:t,lineHeight:1},"aria-label":"Zorganics Foundation",children:[e.jsx(eQ,{size:o,compact:!0,medallionColor:a,goldColor:r,title:"Zorganics Foundation"}),e.jsxs("span",{className:"flex flex-col leading-none",style:{gap:1},children:[e.jsx("span",{style:{fontFamily:"'Playfair Display', Georgia, serif",fontWeight:700,fontStyle:"italic",color:n,fontSize:Math.max(11,Math.round(t*.5)),letterSpacing:"0.01em",lineHeight:1,whiteSpace:"nowrap"},children:"Foundation"}),i&&e.jsx("span",{style:{fontFamily:"'Inter', system-ui, sans-serif",fontWeight:700,color:n,opacity:.65,fontSize:Math.max(7,Math.round(t*.28)),letterSpacing:"0.18em",textTransform:"uppercase",lineHeight:1,whiteSpace:"nowrap"},children:"501(c)(3) · Zorganics"})]})]})},tQ="/scholar",sQ="https://d64gsuwffb70l.cloudfront.net/69cae7fb5ea7db794957149e_1775337912224_4cc82887.jfif",sA=[{id:"dashboard",label:"Program Dashboard",icon:e.jsx(Q_,{size:18}),shortLabel:"SIS"},{id:"lms",label:"Z-LMS",icon:e.jsx(Na,{size:18}),shortLabel:"LMS"},{id:"pos",label:"POS & Inventory",icon:e.jsx(Yl,{size:18}),shortLabel:"POS"},{id:"audit",label:"Audit Vault",icon:e.jsx(Tt,{size:18}),shortLabel:"Audit"},{id:"financial",label:"Financial Engine",icon:e.jsx(Ro,{size:18}),shortLabel:"Finance"},{id:"agency",label:"Agency Hub",icon:e.jsx(Ws,{size:18}),shortLabel:"Agency"},{id:"staff",label:"Staff Portal",icon:e.jsx(ts,{size:18}),shortLabel:"Staff"},{id:"google",label:"Google Sync",icon:e.jsx(zP,{size:18}),shortLabel:"Sync"},{id:"franchise",label:"Franchise HQ",icon:e.jsx(Bo,{size:18}),shortLabel:"HQ"}],nA=[{id:"admissions",label:"Admissions",icon:e.jsx(_t,{size:16}),title:"Admissions â requirements, enrollment & program portfolio"},{id:"tour-booking",label:"Book a Tour",icon:e.jsx(At,{size:16}),title:"Schedule an in-person campus tour"},{id:"apply-now",label:"Apply Now",icon:e.jsx(Qe,{size:16}),title:"Start your application"},{id:"salon-services",label:"Zora's Salon",icon:e.jsx(Ss,{size:16}),title:"Zora's Styling Salon & Spa â professional services by licensed professionals"},{id:"student-clinic",label:"Student Salon",icon:e.jsx(_t,{size:16}),title:"Student Salon & Clinic â services performed by supervised students under instructor guidance (student pricing)"},{id:"med-spa-portal",label:"Med Spa",icon:e.jsx(Sa,{size:16}),title:"Zorganics Med Spa â clinical treatments & consultations"},{id:"shop",label:"Cosmetics",icon:e.jsx(Yl,{size:16}),title:"Zorganics Cosmetics â vegan clinical beauty products"},{id:"wholesale",label:"Wholesale",icon:e.jsx(_d,{size:16}),title:"Wholesale B2B â professional & salon partner shop"},{id:"foundation-landing",label:"Foundation",icon:e.jsx(ta,{size:16}),title:"The Zorganics Foundation â 501(c)(3) public charity"}],nQ={admin:"bg-burgundy/10 text-burgundy border-burgundy/20",instructor:"bg-gold/10 text-gold-dark border-gold/20",staff:"bg-blue-50 text-blue-600 border-blue-200"},wp={admin:"Administrator",instructor:"Instructor",staff:"Staff"},aQ={esthetics:"Esthetics 750h",cosmetology:"Cosmetology 1600h","master-esthetics":"Master Esth. 450h"},rQ={esthetics:"from-emerald-400 to-teal-500",cosmetology:"from-purple-400 to-indigo-500","master-esthetics":"from-
1203amber-400 to-orange-500"},aA=()=>{const{activeSection:t,setActiveSection:s,activeBrand:n,setShowHero:a,searchQuery:r,setSearchQuery:i,selectedProgramId:o,setSelectedProgramId:l}=dc(),{user:c,isAuthenticated:u,signOut:p,canAccessSection:m,hasRole:x}=kn(),{student:h,isStudentAuthenticated:y,studentLogout:v,isPhotoIdVerified:g,isProofOfEducationVerified:N}=ap(),{unreadCount:b}=pI(),f=Za(),[j,S]=d.useState(!1),[w,_]=d.useState(!1),[C,E]=d.useState(!1),[P,F]=d.useState(!1),[I,D]=d.useState(!1),[L,V]=d.useState(!1),[B,A]=d.useState(!1),[z,M]=d.useState("profile"),[R,T]=d.useState(!1),[U,q]=d.useState(!1),[H,G]=d.useState(!1),[W,X]=d.useState(!1),[Q,K]=d.useState(""),[se,Y]=d.useState(!1),[J,te]=d.useState(!1),[pe,Fe]=d.useState({name:""}),[ke,Oe]=d.useState({recentCount:0,latestStatus:"none",latestAt:null,loading:!1}),ue=(Z,xe,Pe)=>{Fe({name:Z,desc:xe,expectedDate:Pe}),te(!0),G(!1),X(!1),S(!1),_(!1),E(!1)},je=d.useRef(null),le=d.useRef(null),ye=d.useRef(null),we=d.useRef(null),He=d.useRef(null),[Lt,ut]=d.useState({top:0,left:0}),ge=d.useRef(null);d.useEffect(()=>{if(!H)return;const Z=()=>{var Pe;const xe=(Pe=He.current)==null?void 0:Pe.getBoundingClientRect();xe&&ut({top:Math.round(xe.bottom),left:Math.round(xe.left)})};return Z(),window.addEventListener("scroll",Z,!0),window.addEventListener("resize",Z),()=>{window.removeEventListener("scroll",Z,!0),window.removeEventListener("resize",Z)}},[H]),d.useEffect(()=>{const Z=xe=>{je.current&&!je.current.contains(xe.target)&&_(!1),le.current&&!le.current.contains(xe.target)&&E(!1),ye.current&&!ye.current.contains(xe.target)&&F(!1),we.current&&!we.current.contains(xe.target)&&G(!1),ge.current&&!ge.current.contains(xe.target)&&Y(!1)};return document.addEventListener("mousedown",Z),()=>document.removeEventListener("mousedown",Z)},[]),d.useEffect(()=>{if(!w||!u||!c||!(x&&x("admin")))return;let Z=!1;return(async()=>{Oe(De=>({...De,loading:!0}));const Pe=new Date(Date.now()-30*24*60*60*1e3).toISOString();try{const[De,ne,oe,ie]=await Promise.all([O.from("ga4_deployment_audit").select("id",{count:"exact",head:!0}).gte("verified_at",Pe),O.from("gsc_deployment_audit").select("id",{count:"exact",head:!0}).gte("verified_at",Pe),O.from("ga4_deployment_audit").select("verified_at, all_live, any_demo_mode").order("verified_at",{ascending:!1}).limit(1).maybeSingle(),O.from("gsc_deployment_audit").select("verified_at, all_live, any_demo_mode").order("verified_at",{ascending:!1}).limit(1).maybeSingle()]);if(Z)return;const fe=(De.count||0)+(ne.count||0),Me=[oe.data,ie.data].filter(Boolean).sort((Pt,Yt)=>(Yt.verified_at||"").localeCompare(Pt.verified_at||""))[0];let Te="none";Me&&(Me.all_live===!0&&Me.any_demo_mode!==!0?Te="live":Me.any_demo_mode===!0?Te="demo":(Me.all_live,Te="partial")),Oe({recentCount:fe,latestStatus:Te,latestAt:(Me==null?void 0:Me.verified_at)||null,loading:!1})}catch(De){if(Z)return;console.warn("[Navbar] Deployment audit summary fetch failed:",De),Oe(ne=>({...ne,loading:!1}))}})(),()=>{Z=!0}},[w,u,c,x]);const Ne=Z=>{if(Z==="lms"||Z==="instructor-lms"){G(!1),X(!1),S(!1),f(tQ);return}s(Z),a(!1),S(!1)},lt=async()=>{_(!1),await p(),f("/admin-login")},mt=()=>{E(!1),v(),G2(),s("campus-home"),a(!0),window.scrollTo({top:0})},ae=()=>{E(!1),v(),G2(),V(!0)},qe=()=>{E(!1),Ne("student-progress")},bt=()=>{E(!1),Ne("student-profile")},ht=Z=>Z.split(" ").map(xe=>xe[0]).join("").toUpperCase().slice(0,2),Ht=Z=>{M(Z),A(!0)},wt=Z=>u?m(Z):!0,_e=["financial","audit","agency","staff","google","pos"],Se=u&&!!x&&x("admin"),We=n==="institute"&&u?sA.filter(Z=>!_e.includes(Z.id)||Se):[],Ut=h?rQ[h.program]||"from-emerald-400 to-teal-500":"",$t=h?aQ[h.program]||h.program:"",Nt=vY(t),ps=Z=>{K(Z),Y(Z.trim().length>=2),Nt.supported&&i(Z)},ft=Z=>{Y(!1),K(""),i(""),S(!1),Z.section?Ne(Z.section):Z.href&&f(Z.href),window.scrollTo({top:0})},Ca=Z=>{if(Z.key==="Escape"){Y(!1);return}if(Z.key==="Enter"){if(Z.preventDefault(),!Nt.supported||!Nt.anchorId){const xe=fI(Q,1)[0];xe&&ft(xe);return}Y(!1),requestAnimationFrame(()=>{const xe=document.getElementById(Nt.anchorId);if(!xe)return;xe.scrollIntoView({behavior:"smooth",block:"start"});const Pe=xe.querySelector('a[href], button:not([disabled]), input:not([disabled]), [tabindex]:not
1203([tabindex="-1"])');Pe&&Pe.focus({preventScroll:!0})})}},ee=Nt.supported?r:Q,me=Nt.supported?Nt.placeholder:"Search programs, admissions, servicesâ¦";return e.jsxs(e.Fragment,{children:[e.jsx("a",{href:"#main-content",className:"skip-to-content",children:"Skip to main content"}),e.jsxs("div",{className:"sticky top-0 z-50 z-luxury-burgundy-header",role:"banner",children:[e.jsx("div",{className:"text-xs hidden md:block","aria-label":"Contact information",style:{backgroundColor:"#600018"},children:e.jsxs("div",{className:"max-w-[1600px] mx-auto px-4 lg:px-8 py-1.5 flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-5",children:[e.jsxs("a",{href:"tel:+13603928243",className:"flex items-center gap-1.5 transition-colors font-bold",style:{color:"#F5D87A",textShadow:"0 1px 2px rgba(0,0,0,0.7), 0 0 1px rgba(0,0,0,0.5)"},onMouseEnter:Z=>Z.currentTarget.style.color="#FFF0C2",onMouseLeave:Z=>Z.currentTarget.style.color="#F5D87A","aria-label":"Call Zorganics Institute at (360) 392-8243",children:[e.jsx(Qt,{size:12,style:{color:"#F5D87A"}}),e.jsx("span",{children:"(360) 392-8243"})]}),e.jsxs("a",{href:"mailto:[email protected]",className:"flex items-center gap-1.5 transition-colors font-bold",style:{color:"#F5D87A",textShadow:"0 1px 2px rgba(0,0,0,0.7), 0 0 1px rgba(0,0,0,0.5)"},onMouseEnter:Z=>Z.currentTarget.style.color="#FFF0C2",onMouseLeave:Z=>Z.currentTarget.style.color="#F5D87A",children:[e.jsx(Ye,{size:12,style:{color:"#F5D87A"}}),e.jsx("span",{children:"[email protected]"})]}),e.jsxs("span",{className:"flex items-center gap-1.5 font-bold",style:{color:"#F5D87A",textShadow:"0 1px 2px rgba(0,0,0,0.7), 0 0 1px rgba(0,0,0,0.5)"},children:[e.jsx(zt,{size:12,style:{color:"#F5D87A"}}),e.jsx("span",{children:"Bellingham Campus"})]}),e.jsxs("div",{className:"flex items-center gap-3 ml-2 pl-3",style:{borderLeft:"1px solid rgba(245,216,122,0.45)"},children:[e.jsx("a",{href:"https://www.google.com/search?q=Zorganics+Institute+Bellingham+WA",target:"_blank",rel:"noopener noreferrer",className:"transition-all duration-300 hover:scale-110",style:{color:"#F5D87A",filter:"drop-shadow(0 1px 2px rgba(0,0,0,0.7))"},onMouseEnter:Z=>{Z.currentTarget.style.color="#FFF0C2",Z.currentTarget.style.filter="drop-shadow(0 1px 4px rgba(255,240,194,0.7))"},onMouseLeave:Z=>{Z.currentTarget.style.color="#F5D87A",Z.currentTarget.style.filter="drop-shadow(0 1px 2px rgba(0,0,0,0.7))"},title:"Zorganics Institute on Google","aria-label":"Zorganics Institute on Google",children:e.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"currentColor",children:[e.jsx("path",{d:"M22.56 12.25c0-.78-.07-1.53-.2-2.25H12v4.26h5.92a5.06 5.06 0 0 1-2.2 3.32v2.77h3.57c2.08-1.92 3.28-4.74 3.28-8.1z"}),e.jsx("path",{d:"M12 23c2.97 0 5.46-.98 7.28-2.66l-3.57-2.77c-.98.66-2.23 1.06-3.71 1.06-2.86 0-5.29-1.93-6.16-4.53H2.18v2.84C3.99 20.53 7.7 23 12 23z"}),e.jsx("path",{d:"M5.84 14.09c-.22-.66-.35-1.36-.35-2.09s.13-1.43.35-2.09V7.07H2.18C1.43 8.55 1 10.22 1 12s.43 3.45 1.18 4.93l2.85-2.22.81-.62z"}),e.jsx("path",{d:"M12 5.38c1.62 0 3.06.56 4.21 1.64l3.15-3.15C17.45 2.09 14.97 1 12 1 7.7 1 3.99 3.47 2.18 7.07l3.66 2.84c.87-2.6 3.3-4.53 6.16-4.53z"})]})}),e.jsx("a",{href:"https://www.youtube.com/@ZorganicsInstitute",target:"_blank",rel:"noopener noreferrer",className:"transition-all duration-300 hover:scale-110",style:{color:"#F5D87A",filter:"drop-shadow(0 1px 2px rgba(0,0,0,0.7))"},onMouseEnter:Z=>{Z.currentTarget.style.color="#FFF0C2",Z.currentTarget.style.filter="drop-shadow(0 1px 4px rgba(255,240,194,0.7))"},onMouseLeave:Z=>{Z.currentTarget.style.color="#F5D87A",Z.currentTarget.style.filter="drop-shadow(0 1px 2px rgba(0,0,0,0.7))"},title:"Zorganics Institute on YouTube","aria-label":"Zorganics Institute on YouTube",children:e.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"currentColor",children:e.jsx("path",{d:"M23.498 6.186a3.016 3.016 0 0 0-2.122-2.136C19.505 3.545 12 3.545 12 3.545s-7.505 0-9.377.505A3.017 3.017 0 0 0 .502 6.186C0 8.07 0 12 0 12s0 3.93.502 5.814a3.016 3.016 0 0 0 2.122 2.136c1.871.505 9.376.505 9.376.505s7.505 0 9.377-.505a3.015 3.015 0 0 0 2.122-2.136C24 15.93 24 12 24 12s0-3.93-.502-5.814zM9.545 15.568V8.432L15.818 12l-6.273 3.568z"})})}),e.jsx("a",{href:"https://www.linkedin.com/company/zorganics-global-llc/",target:"_blank",rel:"noopener noreferrer",className:"transition-all duration-300 hover:scale-110",style:{color:"#F5D87A",filter:"drop-shadow(0 1px 2px rgba(0,0,0,0.7))"},onMouseEnter:Z=>{Z.currentTarget.style.color="#FFF0C2",Z.currentTarget.style.filter="drop-shadow(0 1px 4px rgba(255,240,194,0.7))"},onMouseLeave:Z=>{Z.currentTarget.style.color="#F5D87A",Z.currentTarget.style.filter="drop-shadow(0 1px 2px rgba(0,0,0,0.7))"},title:"Zorganics Global LLC on LinkedIn â Recruitment & B2B","aria-label":"Zorganics Global LLC on LinkedIn",children:e.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"
1203currentColor",children:e.jsx("path",{d:"M20.447 20.452h-3.554v-5.569c0-1.328-.027-3.037-1.852-3.037-1.853 0-2.136 1.445-2.136 2.939v5.667H9.351V9h3.414v1.561h.046c.477-.9 1.637-1.85 3.37-1.85 3.601 0 4.267 2.37 4.267 5.455v6.286zM5.337 7.433a2.062 2.062 0 0 1-2.063-2.065 2.064 2.064 0 1 1 2.063 2.065zm1.782 13.019H3.555V9h3.564v11.452zM22.225 0H1.771C.792 0 0 .774 0 1.729v20.542C0 23.227.792 24 1.771 24h20.451C23.2 24 24 23.227 24 22.271V1.729C24 .774 23.2 0 22.222 0h.003z"})})})]})]}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(be,{to:"/admissions",onClick:()=>{Ne("admissions")},className:"transition-colors",style:{color:"#F5D87A",fontWeight:800,textShadow:"0 1px 2px rgba(0,0,0,0.7), 0 0 1px rgba(0,0,0,0.5)",letterSpacing:"0.01em"},onMouseEnter:Z=>Z.currentTarget.style.color="#FFF0C2",onMouseLeave:Z=>Z.currentTarget.style.color="#F5D87A",children:"Admissions"}),e.jsx("span",{style:{color:"rgba(245,216,122,0.5)"},children:"|"}),e.jsx(be,{to:"/salon",onClick:()=>{Ne("salon-services")},className:"transition-colors",style:{color:"#F5D87A",fontWeight:800,textShadow:"0 1px 2px rgba(0,0,0,0.7), 0 0 1px rgba(0,0,0,0.5)",letterSpacing:"0.01em"},onMouseEnter:Z=>Z.currentTarget.style.color="#FFF0C2",onMouseLeave:Z=>Z.currentTarget.style.color="#F5D87A",children:"Salon & Spa"}),e.jsx("span",{style:{color:"rgba(245,216,122,0.5)"},children:"|"}),e.jsx("button",{onClick:()=>{Ne("our-story")},className:"transition-colors",style:{color:"#F5D87A",fontWeight:800,textShadow:"0 1px 2px rgba(0,0,0,0.7), 0 0 1px rgba(0,0,0,0.5)",letterSpacing:"0.01em"},onMouseEnter:Z=>Z.currentTarget.style.color="#FFF0C2",onMouseLeave:Z=>Z.currentTarget.style.color="#F5D87A",children:"Our Story"}),e.jsx("span",{style:{color:"rgba(245,216,122,0.5)"},children:"|"}),e.jsx(be,{to:"/contact",onClick:()=>{Ne("contact-us")},className:"transition-colors",style:{color:"#F5D87A",fontWeight:800,textShadow:"0 1px 2px rgba(0,0,0,0.7), 0 0 1px rgba(0,0,0,0.5)",letterSpacing:"0.01em"},onMouseEnter:Z=>Z.currentTarget.style.color="#FFF0C2",onMouseLeave:Z=>Z.currentTarget.style.color="#F5D87A",children:"Contact Us"}),e.jsx("span",{style:{color:"rgba(245,216,122,0.5)"},children:"|"}),e.jsx("a",{href:"/financial-aid",className:"transition-colors",style:{color:"#F5D87A",fontWeight:800,textShadow:"0 1px 2px rgba(0,0,0,0.7), 0 0 1px rgba(0,0,0,0.5)",letterSpacing:"0.01em"},onMouseEnter:Z=>Z.currentTarget.style.color="#FFF0C2",onMouseLeave:Z=>Z.currentTarget.style.color="#F5D87A",title:"Financial Aid â FAFSA, Pell Grants, Direct Loans, WIOA & GI Bill®",children:"Financial Aid"}),Se&&e.jsxs(e.Fragment,{children:[e.jsx("span",{style:{color:"rgba(245,216,122,0.5)"},children:"|"}),e.jsx("button",{onClick:()=>{Ne("premium-landing")},className:"transition-colors",style:{color:"#F5D87A",fontWeight:800,textShadow:"0 1px 2px rgba(0,0,0,0.7), 0 0 1px rgba(0,0,0,0.5)",letterSpacing:"0.01em"},onMouseEnter:Z=>Z.currentTarget.style.color="#FFF0C2",onMouseLeave:Z=>Z.currentTarget.style.color="#F5D87A",title:"Operator preview â Premium Landing template (admin only)",children:"Premium Landing"})]}),e.jsx("span",{style:{color:"rgba(245,216,122,0.5)"},children:"|"}),e.jsx(be,{to:"/foundation",onClick:()=>{Ne("foundation-landing")},className:"group inline-flex items-center transition-all duration-300",title:"The Zorganics Foundation · 501(c)(3) Public Charity · Beauty with Purpose","aria-label":"Open the Zorganics Foundation page",style:{padding:"2px 4px"},children:e.jsx(tA,{height:22,textColor:"#F5D87A",medallionColor:"#4A1942",goldColor:"#F5D87A"})}),e.jsx("span",{style:{color:"rgba(245,216,122,0.5)"},children:"|"}),e.jsx("button",{onClick:()=>{window.location.href="/apply-now"},className:"gold-medallion-btn gold-shimmer-btn relative overflow-hidden px-4 py-1 rounded-full font-bold transition-all duration-300 text-[10px] uppercase tracking-widest",style:{background:"linear-gradient(145deg, #E6D2A0 0%, #D4AF37 25%, #B8962E 50%, #D4AF37 75%, #E6D2A0 100%)",color:"#3B0A11",boxShadow:"0 2px 8px rgba(212,175,55,0.35), inset 0 1px 0 rgba(255,255,255,0.4), 0 0 0 1px rgba(184,150,46,0.5)",border:"1px solid rgba(230,210,160,0.6)",textShadow:"0 1px 0 rgba(255,255,255,0.3)",letterSpacing:"0.12em"},onMouseEnter:Z=>{Z.currentTarget.style.background="linear-gradient(145deg, #F0E4C4 0%, #E6D2A0 25%, #D4AF37 50%, #E6D2A0 75%, #F0E4C4 100%)",Z.currentTarget.style.boxShadow="0 4px 18px rgba(212,175,55,0.55), inset 0 1px 0 rgba(255,255,255,0.5), 0 0 0 1px rgba(230,210,160,0.7), 0 0 20px rgba(212,175,55,0.2)",Z.currentTarget.style.transform="translateY(-2px) scale(1.03)"},onMouseLeave:Z=>{Z.currentTarget.style.background="linear-gradient(145deg, #E6D2A0 0%, #D4AF37 25%, #B8962E 50%, #D4AF37 75%, #E6D2A0 100%)",Z.currentTarget.style.boxShadow="0 2px 8px rgba(212,175,55,0.35), inset 0 1px 0 rgba(255,255,255,0.4), 0 0 0 1px rgba(184,150,46,0.5)",Z.currentTarget.style.transform="translateY(0) scale(1)"},children:e.jsxs("span",{className:"relative z-10 flex items-center gap-1.5",children:[e.jsx(Qe,{size:11,className:"opacity-80"}),"Apply Now"]})}),e.jsx("button",{onClick:()=>q(!0),className:"gold-medallion-btn relative overflow-hidden px-4 py-1 rounded-full font-bold transition-all duration-300 text-[10px] uppercase tracking-widest",style:{background:"linear-gradient(145deg, rgba(245,216,122,0.28) 0%, rgba(212,175,55,0.18) 50%, rgba(245,216,122,0.28) 100%)",color:"#FFF8E1",boxShadow:"0 1px 6px rgba(212,175,55,0.25), inset 0 1px 0 rgba(255,255,255,0.15), 0 0 0 1px rgba(245,216,122,0.6)",border:"1px solid rgba(245,216,122,0.65)",textShadow:"0 1px 2px rgba(0,0,0,0.55)",letterSpacing:"0.1em"},onMouseEnter:Z=>{Z.currentTarget.style.background="linear-gradient(145deg, #E6D2A0 0%, #D4AF37 25%, #B8962E 50%, #D4AF37 75%, #E6D2A0 100%)",Z.currentTarget.style.color="#3B0A11",Z.currentTarget.style.boxShadow="0 4px 18px rgba(212,175,55,0.5), inset 0 1px 0 rgba(255,255,255,0.4), 0 0 0 1px rgba(230,210,160,0.7), 0 0 16px rgba(212,175,55,0.15)",Z.currentTarget.style.transform="translateY(-2px) scale(1.03)",Z.currentTarget.style.textShadow="0 1px 0 rgba(255,255,255,0.3)"},onMouseLeave:Z=>{Z.currentTarget.style.background="linear-gradient(145deg, rgba(245,216,122,0.28) 0%, rgba(212,175,55,0.18) 50%, rgba(245,216,122,0.28) 100%)",Z.currentTarget.style.color="#FFF8E1",Z.currentTarget.style.boxShadow="0 1px 6px rgba(212,175,55,0.25), inset 0 1px 0 rgba(255,255,255,0.15), 0 0 0 1px rgba(245,216,122,0.6)",Z.currentTarget.style.transform="translateY(0) scale(1)",Z.currentTarget.style.textShadow="0 1px 2px rgba(0,0,0,0.55)"},children:e.jsxs("span",{className:"relative z-10 flex items-center gap-1.5",children:[e.jsx(At,{size:11,className:"opacity-80"}),"Book a Tour"]})})]})]})}),e.jsxs("nav",{className:"shadow-lg",role:"navigation","aria-label":"Main navigation",style:{background:"linear-gradient(180deg, #FBF6E8 0%, #F5EBD0 100%)"},children:[e.jsx("div",{className:"h-[3px]",style:{background:"linear-gradient(90deg, #B8962E 0%, #D4AF37 30%, #E6D2A0 50%, #D4AF37 70%, #B8962E 100%)"}}),e.jsxs("div",{className:"max-w-[1600px] mx-auto px-4 lg:px-8",children:[e.jsxs("div",{className:"flex items-center justify-between h-16",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsxs("div",{className:"flex items-center gap-3 cursor-pointer",onClick:()=>{a(!0),s("dashboard")},children:[e.jsx("div",{className:"flex-shrink-0 rounded-xl overflow-hidden flex items-center justify-center",style:{width:"50px",height:"50px",background:"linear-gradient(145deg, #FFFFFF 0%, #F8F6F0 100%)",boxShadow:"0 2px 14px rgba(128,0,32,0.2), 0 0 0 2px #D4AF37, 0 0 0 5px rgba(212,175,55,0.12)"},children:e.jsx("img",{src:sQ,alt:"Zorganics Institute",className:"object-contain",style:{width:"42px",height:"42px",imageRendering:"auto",filter:"contrast(1.08) saturate(1.1)"}})}),e.jsxs("div",{className:"hidden sm:block",children:[e.jsxs("h1",{className:"font-display text-xl font-extrabold leading-tight tracking-tight",style:{color:"#3B0A11",textShadow:"0 1px 0 rgba(230,210,160,0.45), 0 0 1px rgba(212,175,55,0.35)",WebkitTextStroke:"0.3px rgba(59,10,17,0.6)"},children:["Zorganics",e.jsx("span",{style:{color:"#3B0A11",textShadow:"0 1px 0 rgba(230,210,160,0.55), 0 0 6px rgba(212,175,55,0.25)",marginLeft:"4px",fontWeight:900},children:"Institute"})]}
1203),e.jsx("p",{className:"text-[10px] font-data font-bold tracking-[0.18em] uppercase -mt-0.5",style:{color:"#3B0A11",textShadow:"0 1px 0 rgba(230,210,160,0.5)"},children:"Beauty & Wellness Education"})]})]}),e.jsx("div",{className:"hidden md:block ml-2",children:e.jsx(L3,{})})]}),e.jsx("div",{className:"hidden lg:flex items-center flex-1 max-w-md mx-6",children:e.jsxs("div",{className:"relative w-full",ref:ge,children:[e.jsx(Bt,{size:16,className:"absolute left-3 top-1/2 -translate-y-1/2",style:{color:"#800020"}}),e.jsx("input",{type:"text",placeholder:me,value:ee,onChange:Z=>ps(Z.target.value),onFocus:()=>{Q.trim().length>=2&&Y(!0)},onKeyDown:Ca,"aria-label":Nt.supported?`Search ${Nt.scopeLabel} and the Zorganics site. Press Enter to jump to results.`:"Search the Zorganics site â programs, admissions, services, Foundation and more.",title:Nt.supported?`Search ${Nt.scopeLabel} · Press Enter to jump to results`:"Search the Zorganics site â press Enter to open the top match",className:"w-full pl-10 pr-4 py-2 rounded-lg text-sm focus:outline-none transition-all navbar-search-input",style:{background:"#FFFFFF",border:"1px solid rgba(184,150,46,0.55)",color:"#3B0A11",boxShadow:"inset 0 1px 2px rgba(128,0,32,0.06)"}}),ee.trim().length>0&&e.jsx("span",{className:"absolute right-2 top-1/2 -translate-y-1/2 px-1.5 py-0.5 rounded text-[9px] font-bold uppercase tracking-wider pointer-events-none select-none",style:{background:"rgba(184,150,46,0.15)",color:"#7A5A1A",border:"1px solid rgba(184,150,46,0.4)",letterSpacing:"0.1em"},"aria-hidden":"true",children:"Enter âµ"}),se&&e.jsx(P3,{query:Q,onSelect:ft,onClose:()=>{Y(!1),K("")},variant:"overlay"})]})}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(dK,{variant:"compact",className:"hidden sm:block"}),e.jsx(uK,{variant:"compact",className:"hidden sm:block"}),n==="institute"&&u&&e.jsxs("button",{onClick:()=>Ne("partner-portal"),className:`hidden md:flex items-center gap-1.5 px-3 py-2 rounded-lg text-xs font-semibold transition-all ${t==="partner-portal"?"bg-gradient-to-r from-teal-600 to-teal-700 text-white shadow-md":"bg-teal-50 text-teal-700 border border-teal-200 hover:bg-teal-100 hover:border-teal-300"}`,children:[e.jsx(YS,{size:15})," Partners"]}),n==="institute"&&e.jsx(e.Fragment,{children:e.jsxs("button",{onClick:()=>Ne("student-portal"),className:"hidden sm:flex items-center gap-1.5 px-3 py-2 rounded-lg text-xs font-semibold transition-all relative",style:{background:t==="student-portal"?"linear-gradient(135deg, #3B0A11, #5A1A24)":"rgba(59,10,17,0.08)",color:t==="student-portal"?"#E6D2A0":"#7A3A44",border:`1px solid ${t==="student-portal"?"#D4AF37":"rgba(128,0,32,0.15)"}`},onMouseEnter:Z=>{t!=="student-portal"&&(Z.currentTarget.style.background="rgba(59,10,17,0.15)",Z.currentTarget.style.borderColor="rgba(212,175,55,0.3)")},onMouseLeave:Z=>{t!=="student-portal"&&(Z.currentTarget.style.background="rgba(59,10,17,0.08)",Z.currentTarget.style.borderColor="rgba(128,0,32,0.15)")},children:[e.jsx(_t,{size:15}),e.jsx("span",{children:"Student Portal"}),e.jsx("span",{className:"px-1.5 py-0.5 rounded-full text-[8px] font-bold uppercase tracking-wider",style:{background:"rgba(5,150,105,0.15)",color:"#059669",border:"1px solid rgba(5,150,105,0.25)"},children:"Live"})]})}),n==="institute"&&y&&h&&e.jsxs("div",{className:"relative hidden md:block",ref:ye,children:[e.jsxs("button",{onClick:()=>{F(!P),E(!1)},className:`relative p-2 rounded-xl transition-all border ${P?"bg-blue-50 border-blue-300 shadow-md shadow-blue-100":"bg-gray-50 border-gray-200 hover:bg-blue-50 hover:border-blue-200"}`,title:"Student Notifications",children:[b>0?e.jsx(Di,{size:17,className:`${P?"text-blue-600":"text-gray-500"} transition-colors`}):e.jsx(Gl,{size:17,className:`${P?"text-blue-600":"text-gray-400"} transition-colors`}),b>0&&e.jsx("span",{className:"absolute -top-1 -right-1 flex items-center justify-center min-w-[18px] h-[18px] px-1 rounded-full bg-red-500 text-white text-[9px] font-bold shadow-sm shadow-red-200 ring-2 ring-white",children:b>9?"9+":b}),b>0&&e.jsx("span",{className:"absolute -top-1 -right-1 min-w-[18px] h-[18px] rounded-full bg-red-400 animate-ping opacity-30"})]}),e.jsx(fK,{isOpen:P,onClose:()=>F(!1)})]}),n==="institute"&&e.jsxs("div",{className:"relative hidden md:block",ref:le,children:[y&&h?e.
1203jsxs("button",{onClick:()=>{E(!C),F(!1)},className:`flex items-center gap-2 pl-2 pr-2.5 py-1.5 rounded-xl transition-all border ${C?"bg-emerald-50 border-emerald-300 shadow-md shadow-emerald-100":"bg-gradient-to-r from-emerald-50 to-teal-50 border-emerald-200 hover:border-emerald-300 hover:shadow-sm"}`,children:[e.jsx("div",{className:`w-7 h-7 rounded-lg bg-gradient-to-br ${Ut} flex items-center justify-center shadow-sm`,children:e.jsx("span",{className:"text-white text-[10px] font-bold",children:ht(h.fullName)})}),e.jsxs("div",{className:"text-left max-w-[120px]",children:[e.jsx("p",{className:"text-[11px] font-semibold text-gray-800 leading-tight truncate",children:h.fullName}),e.jsx("p",{className:"text-[9px] text-emerald-600 font-mono leading-tight",children:h.studentId})]}),e.jsx(Gt,{size:12,className:`text-gray-400 transition-transform ${C?"rotate-180":""}`})]}):e.jsxs("button",{onClick:()=>V(!0),className:"flex items-center gap-1.5 px-3 py-2 rounded-lg text-xs font-semibold bg-emerald-50 text-emerald-700 border border-emerald-200 hover:bg-emerald-100 hover:border-emerald-300 transition-all",children:[e.jsx(Sy,{size:14}),e.jsx("span",{children:"Student Login"})]}),C&&y&&h&&e.jsxs("div",{className:"absolute right-0 top-12 w-72 bg-white rounded-xl shadow-2xl border border-gray-100 overflow-hidden z-50 animate-in fade-in slide-in-from-top-2 duration-200",children:[e.jsxs("div",{className:"px-4 py-4 bg-gradient-to-br from-gray-50 to-emerald-50/30 border-b border-gray-100",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:`w-11 h-11 rounded-xl bg-gradient-to-br ${Ut} flex items-center justify-center shadow-md`,children:e.jsx("span",{className:"text-white text-sm font-bold",children:ht(h.fullName)})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"font-semibold text-sm text-gray-900 truncate",children:h.fullName}),e.jsx("p",{className:"text-xs text-gray-400 font-mono truncate",children:h.studentId})]})]}),e.jsxs("div",{className:"mt-3 flex items-center gap-2",children:[e.jsxs("span",{className:`inline-flex items-center gap-1.5 px-2.5 py-1 rounded-full text-[10px] font-bold border bg-gradient-to-r ${Ut} text-white border-transparent shadow-sm`,children:[e.jsx(_t,{size:10}),$t]}),e.jsxs("span",{className:`inline-flex items-center gap-1 px-2 py-1 rounded-full text-[10px] font-semibold border ${h.enrollmentStatus==="active"?"bg-emerald-50 text-emerald-700 border-emerald-200":h.enrollmentStatus==="graduated"?"bg-blue-50 text-blue-700 border-blue-200":"bg-gray-50 text-gray-500 border-gray-200"}`,children:[e.jsx("span",{className:`w-1.5 h-1.5 rounded-full ${h.enrollmentStatus==="active"?"bg-emerald-500":h.enrollmentStatus==="graduated"?"bg-blue-500":"bg-gray-400"}`}),h.enrollmentStatus.charAt(0).toUpperCase()+h.enrollmentStatus.slice(1)]})]})]}),e.jsxs("div",{className:"py-1",children:[e.jsxs("button",{onClick:bt,className:"flex items-center gap-3 w-full px-4 py-2.5 text-sm text-gray-600 hover:bg-purple-50 hover:text-purple-700 transition-colors group",children:[e.jsx("div",{className:"w-8 h-8 rounded-lg bg-purple-50 group-hover:bg-purple-100 flex items-center justify-center transition-colors",children:e.jsx(yr,{size:16,className:"text-purple-600"})}),e.jsxs("div",{className:"text-left",children:[e.jsx("p",{className:"font-medium text-sm",children:"My Profile"}),e.jsx("p",{className:"text-[10px] text-gray-400",children:"Edit info, avatar, password"})]})]}),e.jsxs("button",{onClick:()=>{E(!1),F(!0)},className:"flex items-center gap-3 w-full px-4 py-2.5 text-sm text-gray-600 hover:bg-blue-50 hover:text-blue-700 transition-colors group",children:[e.jsxs("div",{className:"relative w-8 h-8 rounded-lg bg-blue-50 group-hover:bg-blue-100 flex items-center justify-center transition-colors",children:[e.jsx(Di,{size:16,className:"text-blue-600"}),b>0&&e.jsx("span",{className:"absolute -top-1 -right-1 flex items-center justify-center w-4 h-4 rounded-full bg-red-500 text-white text-[8px] font-bold",children:b>9?"9+":b})]}),e.jsxs("div",{className:"text-left flex-1",children:[e.jsx("p",{className:"font-medium text-sm",children:"Notifications"}),e.jsx("p",{className:"text-[10px] text-gray-400",children:b>0?`${b} unread alert${b!==1?"s":""}`:"No new alerts"})]}),b>0&&e.jsx("span",{className:"flex-shrink-0 w-2 h-2 rounded-full bg-red-500 animate-pulse"})]}),e.jsxs("button",{onClick:qe,className:"flex items-center gap-3 w-full px-4 py-2.5 text-sm text-gray-600 hover:bg-emerald-50 hover:text-emerald-700 transition-colors group",children:[e.jsx("div",{className:"w-8 h-8 rounded-lg bg-emerald-50 group-hover:bg-emerald-100 flex items-center justify-center transition-colors",children:e.jsx(La,{size:16,className:"text-emerald-600"})}),e.jsxs("div",{className:"text-left",children:[e.jsx("p",{className:"font-medium text-sm",children:"View My Progress"}),e.jsx("p",{className:"text-[10px] text-gray-400",children:"Scores, compliance, chapter map"})]})]}),e.jsxs("button",{onClick:()=>{E(!1),Ne("student-profile")},className:"flex items-center gap-3 w-full px-4 py-2.5 text-sm text-gray-600 hover:bg-orange-50 hover:text-orange-700 transition-colors group",children:[e.jsxs("div",{className:"relative w-8 h-8 rounded-lg bg-orange-50 group-hover:bg-orange-100 flex items-center justify-center transition-colors",children:[e.jsx(AO,{size:16,className:"text-orange-600"}),(!g||!N)&&e.jsx("span",{className:"absolute -top-1 -right-1 w-3 h-3 rounded-full bg-amber-500 animate-pulse border border-white"})]}),e.jsxs("div",{className:"text-left flex-1",children:[e.jsx("p",{className:"font-medium text-sm",children:"Documents"}),e.jsx("p",{className:"text-[10px] text-gray-400",children:g&&N?"All verified":"Upload required"})]}),(!g||!N)&&e.jsx("span",{className:"flex-shrink-0 px-1.5 py-0.5 rounded-full text-[8px] font-bold bg-amber-100 text-amber-700 border border-amber-200",children:"Action"})]}),e.jsxs("button",{onClick:ae,className:"flex items-center gap-3 w-full px-4 py-2.5 text-sm text-gray-600 hover:bg-blue-50 hover:text-blue-700 transition-colors group",children:[e.jsx("div",{className:"w-8 h-8 rounded-lg bg-blue-50 group-hover:bg-blue-100 flex items-center justify-center transition-colors",children:e.jsx(Be,{size:16,className:"text-blue-600"})}),e.jsxs("div",{className:"text-left",children:[e.jsx("p",{className:"font-medium text-sm",children:"Switch Account"}),e.jsx("p",{className:"text-[10px] text-gray-400",children:"Sign in as a different student"})]})]})]}),e.jsx("div",{className:"border-t border-gray-100 py-1",children:e.jsxs("button",{onClick:mt,className:"flex items-center gap-3 w-full px-4 py-2.5 text-sm text-red-600 hover:bg-red-50 transition-colors group",children:[e.jsx("div",{className:"w-8 h-8 rounded-lg bg-red-50 group-hover:bg-red-100 flex items-center justify-center transition-colors",children:e.jsx(bo,{size:16,className:"text-red-500"})}),e.jsxs("div",{className:"text-left",children:[e.jsx("p",{className:"font-medium text-sm",children:"Sign Out"}),e.jsx("p",{className:"text-[10px] text-gray-400",children:"End student session"})]})]})})]})]}),u&&c&&e.jsx(XK,{className:"hidden md:inline-flex",hideUntilResolved:!0,compact:!0}),u&&c?e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"hidden lg:flex items-center gap-2 pl-3 pr-3 py-1.5 rounded-lg",style:{background:"rgba(59,10,17,0.45)",border:"1px solid rgba(212,175,55,0.35)",boxShadow:"inset 0 1px 0 rgba(212,175,55,0.08)"},title:`Signed in as ${c.email} (${wp[c.role]||c.role})`,children:e.jsxs("div",{className:"flex flex-col text-left leading-tight max-w-[180px]",children:[e.jsx("span",{className:"text-[11px] font-semibold truncate",style:{color:"#FFFFFF"},children:c.email}),e.jsxs("span",{className:"text-[9px] font-bold uppercase tracking-wider flex items-center gap-1",style:{color:"#E6D2A0"},children:[c.role==="super-admin"&&e.jsx(Tt,{size:9}),c.role==="admin"&&e.jsx(Tt,{size:9}),c.role==="instructor"&&e.jsx(Na,{size:9}),c.role==="staff"&&e.jsx(ts,{size:9}),c.role==="super-admin"?"Super-Admin":wp[c.role]||c.role]}
1203)]})}),e.jsxs("button",{onClick:lt,className:"hidden sm:inline-flex items-center gap-1.5 px-3 py-2 rounded-lg text-xs font-bold uppercase tracking-wider transition-all",style:{background:"linear-gradient(145deg, rgba(212,175,55,0.18) 0%, rgba(184,150,46,0.10) 100%)",color:"#E6D2A0",border:"1px solid rgba(212,175,55,0.45)",letterSpacing:"0.08em",textShadow:"0 1px 2px rgba(0,0,0,0.25)"},onMouseEnter:Z=>{Z.currentTarget.style.background="linear-gradient(145deg, #E6D2A0 0%, #D4AF37 50%, #B8962E 100%)",Z.currentTarget.style.color="#3B0A11",Z.currentTarget.style.borderColor="rgba(230,210,160,0.7)",Z.currentTarget.style.boxShadow="0 4px 14px rgba(212,175,55,0.45), inset 0 1px 0 rgba(255,255,255,0.35)",Z.currentTarget.style.transform="translateY(-1px)",Z.currentTarget.style.textShadow="0 1px 0 rgba(255,255,255,0.3)"},onMouseLeave:Z=>{Z.currentTarget.style.background="linear-gradient(145deg, rgba(212,175,55,0.18) 0%, rgba(184,150,46,0.10) 100%)",Z.currentTarget.style.color="#E6D2A0",Z.currentTarget.style.borderColor="rgba(212,175,55,0.45)",Z.currentTarget.style.boxShadow="none",Z.currentTarget.style.transform="translateY(0)",Z.currentTarget.style.textShadow="0 1px 2px rgba(0,0,0,0.25)"},title:"Sign out and return to the admin login page","aria-label":"Sign out",children:[e.jsx(bo,{size:14}),e.jsx("span",{children:"Sign Out"})]}),e.jsxs("div",{className:"relative",ref:je,children:[e.jsxs("button",{onClick:()=>_(!w),className:"flex items-center gap-2 pl-3 pr-2 py-1.5 rounded-lg transition-all",style:{background:"rgba(59,10,17,0.06)",border:"1px solid rgba(184,150,46,0.35)"},children:[e.jsx("div",{className:"w-8 h-8 rounded-full flex items-center justify-center ring-2 ring-[#D4AF37]/40 shadow-sm",style:{background:"linear-gradient(135deg, #D4AF37 0%, #B8962E 100%)"},children:e.jsx("span",{className:"text-white text-xs font-semibold",children:ht(c.fullName)})}),e.jsxs("div",{className:"hidden md:block text-left",children:[e.jsx("p",{className:"text-sm font-medium leading-tight",style:{color:"#3B0A11"},children:c.fullName}),e.jsx("p",{className:"text-[10px] leading-tight",style:{color:"rgba(59,10,17,0.6)"},children:wp[c.role]||c.role})]}),e.jsx(Gt,{size:14,className:"hidden md:block",style:{color:"rgba(59,10,17,0.55)"}})]}),w&&e.jsxs("div",{className:"absolute right-0 top-14 w-72 bg-white rounded-xl shadow-2xl border border-gray-100 overflow-hidden z-50",children:[e.jsxs("div",{className:"px-4 py-4 bg-gradient-to-br from-gray-50 to-white border-b border-gray-100",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"w-11 h-11 rounded-full flex items-center justify-center shadow-sm",style:{background:"linear-gradient(135deg, #800020 0%, #5A0018 100%)"},children:e.jsx("span",{className:"text-white text-sm font-bold",children:ht(c.fullName)})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"font-semibold text-sm text-gray-900 truncate",children:c.fullName}),e.jsx("p",{className:"text-xs text-gray-400 truncate",children:c.email})]})]}),e.jsx("div",{className:"mt-3",children:e.jsxs("span",{className:`inline-flex items-center gap-1.5 px-2.5 py-1 rounded-full text-xs font-semibold border ${nQ[c.role]}`,children:[c.role==="admin"&&e.jsx(Tt,{size:12}),c.role==="instructor"&&e.jsx(Na,{size:12}),c.role==="staff"&&e.jsx(ts,{size:12}),wp[c.role]]})})]}),e.jsxs("div",{className:"px-4 py-3 border-b border-gray-100",children:[e.jsx("p",{className:"text-[10px] font-semibold text-gray-400 uppercase tracking-wider mb-2",children:"Section Access"}),e.jsx("div",{className:"flex flex-wrap gap-1.5",children:sA.map(Z=>{const xe=m(Z.id);return e.jsxs("span",{className:`inline-flex items-center gap-1 px-2 py-0.5 rounded text-[10px] font-medium ${xe?"bg-emerald-50 text-emerald-700 border border-emerald-200":"bg-gray-50 text-gray-400 border border-gray-100"}`,children:[!xe&&e.jsx(Xe,{size:8}),Z.shortLabel]},Z.id)})})]}),e.jsxs("div",{className:"py-1",children:[e.jsxs("button",{onClick:()=>{_(!1),Ht("profile")},className:"flex items-center gap-3 w-full px-4 py-2.5 text-sm text-gray-600 hover:bg-gray-50 transition-colors",children:[e.jsx(yr,{size:16,className:"text-gray-400"})," My Profile"]}),e.jsxs("button",{onClick:()=>{_(!1),Ht("notifications")},className:"flex items-center gap-3 w-full px-4 py-2.5 text-sm text-gray-600 hover:bg-gray-50 transition-colors",children:[e.jsx(Gl,{size:16,className:"text-gray-400"})," Notification Preferences"]}),e.jsxs("button",{onClick:()=>{_(!1),Ht("permissions")},className:"flex items-center gap-3 w-full px-4 py-2.5 text-sm text-gray-600 hover:bg-gray-50 transition-colors",children:[e.jsx(kd,{size:16,className:"text-gray-400"})," Account Settings"]})]}),x&&x("admin")&&e.jsxs("div",{className:"border-t border-gray-100 py-1 bg-gradient-to-br from-stone-50 to-amber-50/30",children:[e.jsx("p",{className:"px-4 pt-2 pb-1 text-[9px] font-bold uppercase tracking-wider text-amber-700",children:"Admin Tools"}),e.jsxs(be,{to:"/admin/lead-inventory",onClick:()=>_(!1),className:"flex items-center gap-3 w-full px-4 py-2.5 text-sm text-stone-700 hover:bg-amber-50 hover:text-amber-900 transition-colors",title:"Admissions CRM â unified prospect inventory, ownership, stages & follow-ups",children:[e.jsx(ts,{size:16,className:"text-amber-600"}),e.jsxs("div",{className:"flex-1",children:[e.jsx("p",{className:"font-medium",children:"Admissions CRM"}),e.jsx("p",{className:"text-[10px] text-stone-500",children:"Unified prospect inventory, stages & follow-ups"})]})]}),e.jsxs(be,{to:"/admin/deployment-audit",onClick:()=>_(!1),className:"flex items-center gap-3 w-full px-4 py-2.5 text-sm text-stone-700 hover:bg-amber-50 hover:text-amber-900 transition-colors group",title:"GA4 + GSC LIVE-verification compliance timeline",children:[e.jsxs("div",{className:"relative flex-shrink-0",children:[e.jsx(Nd,{size:16,className:"text-amber-600"}),ke.recentCount>0&&e.jsx("span",{className:"absolute -top-1.5 -right-2 flex items-center justify-center min-w-[14px] h-[14px] px-1 rounded-full text-[8px] font-bold border border-white",style:{background:"linear-gradient(135deg, #D4AF37 0%, #B8962E 100%)",color:"#3B0A11",letterSpacing:"0.02em"},children:ke.recentCount>99?"99+":ke.recentCount})]}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-1.5 flex-wrap",children:[e.jsx("p",{className:"font-medium",children:"Deployment Audit Log"}),ke.loading?e.jsx("span",{className:"inline-flex items-center gap-0.5 px-1.5 py-0.5 rounded-full text-[8px] font-bold uppercase tracking-wider bg-gray-100 text-gray-500 border border-gray-200",children:"â¦"}):ke.latestStatus==="live"?e.jsxs("span",{className:"inline-flex items-center gap-0.5 px-1.5 py-0.5 rounded-full text-[8px] font-bold uppercase tracking-wider bg-emerald-50 text-emerald-700 border border-emerald-200",children:[e.jsx(Ue,{size:8})," Live"]}):ke.latestStatus==="demo"?e.jsxs("span",{className:"inline-flex items-center gap-0.5 px-1.5 py-0.5 rounded-full text-[8px] font-bold uppercase tracking-wider bg-amber-50 text-amber-700 border border-amber-200",children:[e.jsx(ve,{size:8})," Demo"]}):ke.latestStatus==="partial"?e.jsxs("span",{className:"inline-flex items-center gap-0.5 px-1.5 py-0.5 rounded-full text-[8px] font-bold uppercase tracking-wider bg-rose-50 text-rose-700 border border-rose-200",children:[e.jsx(ve,{size:8})," Partial"]}):ke.latestStatus==="failed"?e.jsxs("span",{className:"inline-flex items-center gap-0.5 px-1.5 py-0.5 rounded-full text-[8px] font-bold uppercase tracking-wider bg-red-50 text-red-700 border border-red-200",children:[e.jsx(ve,{size:8})," Failed"]}):e.jsx("span",{className:"inline-flex items-center gap-0.5 px-1.5 py-0.5 rounded-full text-[8px] font-bold uppercase tracking-wider bg-gray-50 text-gray-500 border border-gray-200",children:"No runs"})]}),e.jsx("p",{className:"text-[10px] text-stone-500 truncate",children:ke.recentCount>0?`${ke.recentCount} run${ke.recentCount!==1?"s":""} · last 30 days`:"GA4 + GSC compliance timeline"})]})]}),e.jsxs(be,{to:"/admin/brand-lines",onClick:()=>_(!1),className:"flex items-center gap-3 w-full px-4 py-2.5 text-sm text-stone-700 hover:bg-amber-50 hover:text-amber-900 transition-colors",children:[e.jsx(sf,{size:16,className:"text-amber-600"}),e.jsxs("div",{className:"flex-1",children:[e.jsx("p",{className:"font-medium",children:"Brand Line Admin"}),e.jsx("p",{className:"text-[10px] text-stone-500",children:"Manage Lifitaâ¢, Malouwaâ¢, Linamissaâ¢â¦"})]})]}),e.jsxs(be,{to:"/admin/medspa-consultations",onClick:()=>_(!1),className:"flex items-center gap-3 w-full px-4 py-2.5 text-sm text-stone-700 hover:bg-amber-50 hover:text-amber-900 transition-colors",title:"Med Spa consultation pipeline â intake review, concern tracking, assessment notes",children:[e.jsx(Sa,{size:16,className:"text-amber-600"}),e.jsxs("div",{className:"flex-1",children:[e.jsx("p",{className:"font-medium",children:"Med Spa Consultations"}),e.jsx("p",{className:"text-[10px] text-stone-500",children:"Pipeline, intake review & concern tracking"})]})]}),e.jsxs(be,{to:"/loading-diagnostics",onClick:()=>_(!1),className:"flex items-center gap-3 w-full px-4 py-2.5 text-sm text-stone-700 hover:bg-amber-50 hover:text-amber-900 transition-colors",children:[e.jsx(Ma,{size:16,className:"text-amber-600"}),e.jsxs("div",{className:"flex-1",children:[e.jsx("p",{className:"font-medium",children:"Loading Diagnostics"}),e.jsx("p",{className:"text-[10px] text-stone-500",children:"Diagnose stuck-loading bugs"})]})]})]}),e.jsx("div",{className:"border-t border-gray-100 py-1",children:e.jsxs("button",{onClick:lt,className:"flex items-center gap-3 w-full px-4 py-2.5 text-sm text-red-600 hover:bg-red-50 transition-colors",children:[e.jsx(bo,{size:16})," Sign Out"]})})]})]})]}):e.jsxs("button",{onClick:()=>D(!0),className:"flex items-center gap-2 px-4 py-2 rounded-lg text-sm font-semibold transition-all",style:{background:"linear-gradient(135deg, #D4AF37 0%, #B8962E 100%)",color:"#FFFFFF",boxShadow:"0 4px 12px rgba(212,175,55,0.3)"},onMouseEnter:Z=>{Z.currentTarget.style.background="linear-gradient(135deg, #E6D2A0 0%, #D4AF37 100%)",Z.currentTarget.style.boxShadow="0 6px 20px rgba(212,175,55,0.45)",Z.currentTarget.style.transform="translateY(-1px)"},onMouseLeave:Z=>{Z.currentTarget.style.background="linear-gradient(135deg, #D4AF37 0%, #B8962E 100%)",Z.currentTarget.style.boxShadow="0 4px 12px rgba(212,175,55,0.3)",Z.currentTarget.style.transform="translateY(0)"},children:[e.jsx($o,{size:16}),e.jsx("span",{className:"hidden sm:inline",children:"Sign In"})]}),e.jsx("button",{onClick:()=>S(!j),className:"lg:hidden p-2 rounded-lg transition-all",style:{color:"#3B0A11"},children:j?e.jsx(Ke,{size:22}):e.jsx(OO,{size:22})})]})]}),e.jsxs("div",{className:"hidden lg:flex items-center gap-1 -mb-px overflow-x-auto pb-0",style:{background:"linear-gradient(180deg, rgba(128,0,32,0.04) 0%, transparent 100%)",borderTop:"1px solid rgba(184,150,46,0.25)"},children:[n==="institute"&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"relative",ref:we,children:[e.jsxs("button",{ref:He,onClick:()=>G(!H),className:"flex items-center gap-2 px-4 py-3 text-sm font-bold border-b-2 transition-all whitespace-nowrap",style:{color:H?"#800020":"#3B0A11",borderBottomColor:H?"#B8962E":"transparent"},onMouseEnter:Z=>{H||(Z.currentTarget.style.color="#800020",Z.currentTarget.style.borderBottomColor="rgba(184,150,46,0.5)")},onMouseLeave:Z=>{H||(Z.currentTarget.style.color="#3B0A11",Z.currentTarget.style.borderBottomColor="transparent")},"aria-expanded":H,"aria-haspopup":"true",children:[e.jsx(_t,{size:18}),"Programs",e.jsx(Gt,{size:14,className:`transition-transform duration-200 ${H?"rotate-180":""}`})]}),H&&e.jsxs("div",{className:"rounded-xl shadow-2xl overflow-hidden animate-in fade-in slide-in-from-top-2 duration-200",style:{position:"fixed",top:Lt.to
1203p,left:Lt.left,width:268,zIndex:80,background:"#FFFFFF",border:"1px solid rgba(212,175,55,0.25)"},role:"menu","aria-label":"Programs",children:[e.jsx("div",{className:"py-1.5",children:yx.map(Z=>e.jsx(be,{to:Z.path,role:"menuitem",onClick:()=>{G(!1),l(Z.programId),s("program-profiles"),a(!1),S(!1)},className:"block px-4 py-2.5 text-sm font-semibold transition-colors",style:{color:"#3B0A11"},onMouseEnter:xe=>{xe.currentTarget.style.background="rgba(212,175,55,0.08)",xe.currentTarget.style.color="#800020"},onMouseLeave:xe=>{xe.currentTarget.style.background="transparent",xe.currentTarget.style.color="#3B0A11"},children:Z.name},Z.programId))}),e.jsx("div",{style:{borderTop:"1px solid rgba(212,175,55,0.2)"}}),e.jsxs(be,{to:"/programs",role:"menuitem",onClick:()=>{G(!1),s("program-profiles"),a(!1)},className:"flex items-center gap-2 px-4 py-2.5 text-sm font-bold transition-colors",style:{color:"#3B0A11"},onMouseEnter:Z=>{Z.currentTarget.style.background="rgba(212,175,55,0.08)",Z.currentTarget.style.color="#800020"},onMouseLeave:Z=>{Z.currentTarget.style.background="transparent",Z.currentTarget.style.color="#3B0A11"},title:"Compare the existing programs side by side on the Programs page",children:[e.jsx(La,{size:14,style:{color:"#D4AF37"}}),"Compare Programs"]})]})]}),!u&&nA.map(Z=>e.jsxs("button",{onClick:()=>Ne(Z.id),className:"flex items-center gap-2 px-3 py-3 text-sm font-bold border-b-2 transition-all whitespace-nowrap",style:{color:t===Z.id?"#800020":"#3B0A11",borderBottomColor:t===Z.id?"#B8962E":"transparent"},onMouseEnter:xe=>{t!==Z.id&&(xe.currentTarget.style.color="#800020",xe.currentTarget.style.borderBottomColor="rgba(184,150,46,0.5)")},onMouseLeave:xe=>{t!==Z.id&&(xe.currentTarget.style.color="#3B0A11",xe.currentTarget.style.borderBottomColor="transparent")},title:Z.title,children:[Z.icon,Z.label]},Z.id)),We.filter(Z=>Z.id!=="lms"&&Z.id!=="instructor-lms").map(Z=>{const xe=wt(Z.id);return e.jsxs("button",{onClick:()=>xe&&Ne(Z.id),className:`flex items-center gap-2 px-3 py-3 text-sm font-bold border-b-2 transition-all whitespace-nowrap ${xe?t===Z.id?"font-extrabold":"border-transparent":"border-transparent cursor-not-allowed"}`,style:{color:xe?t===Z.id?"#800020":"#3B0A11":"rgba(59,10,17,0.3)",borderBottomColor:t===Z.id?"#B8962E":"transparent"},onMouseEnter:Pe=>{xe&&t!==Z.id&&(Pe.currentTarget.style.color="#800020",Pe.currentTarget.style.borderBottomColor="rgba(184,150,46,0.5)")},onMouseLeave:Pe=>{xe&&t!==Z.id&&(Pe.currentTarget.style.color="#3B0A11",Pe.currentTarget.style.borderBottomColor="transparent")},disabled:!xe,title:xe?Z.label:`${wp[(c==null?void 0:c.role)||"staff"]} role cannot access ${Z.label}`,children:[Z.icon,Z.label,!xe&&e.jsx(Xe,{size:12,style:{color:"rgba(59,10,17,0.3)"}})]},Z.id)}),e.jsx("div",{className:"ml-auto flex items-center gap-1 pl-2",style:{borderLeft:"1px solid rgba(184,150,46,0.25)"},children:[{id:"student-progress",icon:e.jsx(Ym,{size:13}),label:"Progress",visible:u||y},{id:"compliance",icon:e.jsx(Ie,{size:13}),label:"Compliance",visible:u},{id:"ecosystem",icon:e.jsx(Qe,{size:13}),label:"Ecosystem",visible:!0},{id:"master-bridge",icon:e.jsx(m0,{size:13}),label:"Bridge",visible:!0,to:"/programs/master-esthetician-bridge",programId:"advanced-master-esthetics-450"},{id:"reviewer-access",icon:e.jsx(ms,{size:13}),label:"Review",visible:u}].filter(Z=>Z.visible).map(Z=>{const xe=Z.programId?t==="program-profiles"&&o===Z.programId:t===Z.id,Pe="flex items-center gap-1.5 px-2.5 py-3 text-xs font-bold border-b-2 transition-all whitespace-nowrap",De={color:xe?"#800020":"#3B0A11",borderBottomColor:xe?"#B8962E":"transparent",opacity:xe?1:.85},ne=ie=>{xe||(ie.currentTarget.style.color="#800020",ie.currentTarget.style.opacity="1",ie.currentTarget.style.borderBottomColor="rgba(184,150,46,0.5)")},oe=ie=>{xe||(ie.currentTarget.style.color="#3B0A11",ie.currentTarget.style.opacity="0.85",ie.currentTarget.style.borderBottomColor="transparent")};return Z.to?e.jsxs(be,{to:Z.to,onClick:()=>{Z.programId&&l(Z.programId),s("program-profiles"),a(!1),S(!1)},className:Pe,style:De,onMouseEnter:ne,onMouseLeave:oe,children:[Z.icon," ",Z.label]},Z.id):e.jsxs("button",{onClick:()=>Ne(Z.id),className:Pe,style:De,onMouseEnter:ne,onMouseLeave:oe,children:[Z.icon," ",Z.label]},Z.id)})})]}),n==="cosmetics"&&e.jsxs(e.Fragment,{children:[e.jsxs("button",{onClick:()=>Ne("shop"),className:`flex items-center gap-2 px-4 py-3 text-sm font-medium border-b-2 transition-all whitespace-nowrap ${t==="shop"?"border-[#C5A059] text-[#800020]":"border-transparent text-gray-500 hover:text-gray-800 hover:border-gray-200"}`,children:[e.jsx(Yl,{size:18})," All Products"]}),e.jsxs("button",{onClick:()=>Ne("shop"),className:"flex items-center gap-2 px-4 py-3 text-sm font-medium border-b-2 border-transparent text-gray-500 hover:text-[#800020] hover:border-[#C5A059]/50 transition-all whitespace-nowrap group relative",children:[e.jsx(Io,{size:16})," Skin",e.jsxs("span",{className:"absolute left-0 top-full mt-0 hidden group-hover:block bg-white border border-gray-200 rounded-lg shadow-xl p-3 z-50 w-52",children:[e.jsx("span",{className:"block text-[10px] font-bold text-[#800020] uppercase mb-1.5",children:"Clinical Skincare"}),e.jsx("span",{className:"block text-[10px] text-gray-500 leading-relaxed",children:"Malouwa⢠pH Hydration, Wealei, Zycolics Derm, Evoumaâ¢"})]})]}),e.jsxs("button",{onClick:()=>Ne("shop"),className:"flex items-center gap-2 px-4 py-3 text-sm font-medium border-b-2 border-transparent text-gray-500 hover:text-[#800020] hover:border-[#C5A059]/50 transition-all whitespace-nowrap group relative",children:[e.jsx(Ss,{size:16})," Hair",e.jsxs("span",{className:"absolute left-0 top-full mt-0 hidden group-hover:block bg-white border border-gray-200 rounded-lg shadow-xl p-3 z-50 w-52",children:[e.jsx("span",{className:"block text-[10px] font-bold text-[#800020] uppercase mb-1.5",children:"Organic Haircare"}),e.jsx("span",{className:"block text-[10px] text-gray-500 leading-relaxed",children:"Shea Butter Moisture, i-Control Styling, Argan Fusion, Lifita"})]})]}),e.jsxs("button",{onClick:()=>Ne("shop"),className:"flex items-center gap-2 px-4 py-3 text-sm font-medium border-b-2 border-transparent text-gray-500 hover:text-[#800020] hover:border-[#C5A059]/50 transition-all whitespace-nowrap group relative",children:[e.jsx(Qe,{size:16})," Body",e.jsxs("span",{className:"absolute left-0 top-full mt-0 hidden group-hover:block bg-white border border-gray-200 rounded-lg shadow-xl p-3 z-50 w-52",children:[e.jsx("span",{className:"block text-[10px] font-bold text-[#800020] uppercase mb-1.5",children:"Therapeutic Body Care"}),e.jsx("span",{className:"block text-[10px] text-gray-500 leading-relaxed",children:"O-Therapy Massage Oils (Calm, Balance, Energize), Smoothing Body Polish"})]})]}),e.jsxs("button",{onClick:()=>Ne("shop"),className:"flex items-center gap-2 px-4 py-3 text-sm font-medium border-b-2 border-transparent text-gray-500 hover:text-[#800020] hover:border-[#C5A059]/50 transition-all whitespace-nowrap group relative",children:[e.jsx(lx,{size:16})," Mineral Makeup",e.jsxs("span",{className:"absolute left-0 top-full mt-0 hidden group-hover:block bg-white border border-gray-200 rounded-lg shadow-xl p-3 z-50 w-56",children:[e.jsx("span",{className:"block text-[10px] font-bold text-[#800020] uppercase mb-1.5",children:"Non-Toxic Cosmetics"}),e.jsx("span",{className:"block text-[10px] text-gray-500 leading-relaxed",children:"Non-Toxic Foundations (8 shades), Botanical Lip Shines (5 shades), Luxury Mineral Palettes"})]})]}),e.jsxs("div",{className:"ml-auto flex items-center gap-2 pl-2 border-l border-gray-100",children:[e.jsxs("span",{className:"inline-flex items-center gap-1 px-2 py-0.5 bg-green-50 text-green-700 text-[9px] font-bold rounded-full border border-green-200",children:[e.jsx(On,{size:9})," Vegan"]}),e.jsxs("span",{className:"inline-flex items-center gap-1 px-2 py-0.5 bg-emerald-50 text-emerald-700 text-[9px] font-bold rounded-full border border-emerald-200",children:[e.jsx(Tt,{size:9})," Organic"]}),e.jsx("span",{className:"inline-flex items-center gap-1 px-2 py-0.5 bg-blue-50 text-blue-700 text-[9px] font-bold rounded-full border border-blue-200",children:"Non-Toxic"})]})]}),n==="professional"&&e.jsxs(e.Fragment,{children:[e.jsxs("button",{onClick:()=>Ne("med-spa-portal"),className:`flex items-center gap-2 px-4 py-3 text-sm font-medium border-b-2 transition-all whitespace-nowrap ${t==="med-spa-portal"?"border-teal-500 text-teal-700":"border-transparent text-gray-500 hover:text-gray-800 hover:border-gray-200"}`,children:[e.jsx(Qe,{size:18})," Med Spa"]}),e.jsxs("button",{onClick:()=>Ne("zoras-salon"),className:`flex items-center gap-2 px-4 py-3 text-sm font-medium border-b-2 transition-all whitespace-nowrap ${t==="zoras-salon"?"border-[#800020] text-[#800020]":"border-transparent text-gray-500 hover:text-gray-800 hover:border-gray-200"}`,children:[e.jsx(Ss,{size:18})," Zora's Salon"]}),e.jsxs("button",{onClick:()=>Ne("professional-services"),className:`flex items-center gap-2 px-4 py-3 text-sm font-medium border-b-2 transition-all whitespace-nowrap ${t==="professional-services"?"border-gray-500 text-gray-700":"border-transparent text-gray-500 hover:text-gray-800 hover:border-gray-200"}`,children:[e.jsx(ts,{size:18})," All Services"]}),e.jsxs("button",{onClick:()=>Ne("md-referral"),className:`flex items-center gap-2 px-4 py-3 text-sm font-medium border-b-2 transition-all whitespace-nowrap ${t==="md-referral"?"border-blue-500 text-blue-700":"border-transparent text-gray-500 hover:text-gray-800 hover:border-gray-200"}`,children:[e.jsx(Sa,{size:18})," MD Referral"]}),e.jsxs("div",{className:"ml-auto flex items-center gap-1 pl-2 border-l border-gray-100",children:[e.jsxs("span",{className:"text-[10px] font-bold text-amber-600 px-2 py-1 bg-amber-50 rounded-full border border-amber-200 flex items-center gap-1",children:[e.jsx(Xe,{size:9})," Not Student Clinic"]}),e.jsxs("span",{className:"text-[10px] font-bold text-teal-600 px-2 py-1 bg-teal-50 rounded-full border border-teal-200 flex items-center gap-1",children:[e.jsx(Tt,{size:9})," Triple-Silo"]})]})]}),n==="foundation"&&e.jsxs(e.Fragment,{children:[e.jsxs("button",{onClick:()=>Ne("foundation"),className:`flex items-center gap-2 px-4 py-3 text-sm font-medium border-b-2 transition-all whitespace-nowrap ${t==="foundation"?"border-[#800020] text-[#800020]":"border-transparent text-gray-500 hover:text-gray-800 hover:border-gray-200"}`,children:[e.jsx(Bo,{size:18})," Our Mission"]}),e.jsxs("button",{onClick:()=>ue("Oncology Esthetics Booking Portal","A private, HIPAA-compliant scheduler that lets oncology patients and their care teams book gentle facial protocols with our specially-certified estheticians. Currently in clinical review with our medical advisory board.","Q3 2026"),className:"flex items-center gap-2 px-4 py-3 text-sm font-medium border-b-2 border-transparent text-gray-500 hover:text-[#800020] hover:border-[#800020]/50 transition-all whitespace-nowrap group relative",children:[e.jsx(ta,{size:18}
1203)," Oncology Support",e.jsxs("span",{className:"absolute left-0 top-full mt-0 hidden group-hover:block bg-white border border-gray-200 rounded-lg shadow-xl p-3 z-50 w-56",children:[e.jsx("span",{className:"block text-[10px] font-bold text-[#800020] uppercase mb-1.5",children:"Private Clinical Care"}),e.jsx("span",{className:"block text-[10px] text-gray-500 leading-relaxed",children:"HIPAA-compliant booking for sensitive oncology esthetics care. Certified estheticians only."})]})]}),e.jsxs("button",{onClick:()=>ue("Research Garden â Level 5 Organic Lab","A living blog & gallery showcasing formulation breakthroughs, clinical trials, and the daily science behind Zorganics ingredients. Lab photography and peer-review summaries are being curated now.","Q2 2026"),className:"flex items-center gap-2 px-4 py-3 text-sm font-medium border-b-2 border-transparent text-gray-500 hover:text-[#800020] hover:border-[#800020]/50 transition-all whitespace-nowrap group relative",children:[e.jsx(m0,{size:18})," Research Garden",e.jsxs("span",{className:"absolute left-0 top-full mt-0 hidden group-hover:block bg-white border border-gray-200 rounded-lg shadow-xl p-3 z-50 w-56",children:[e.jsx("span",{className:"block text-[10px] font-bold text-[#800020] uppercase mb-1.5",children:"Level 5 Organic Lab"}),e.jsx("span",{className:"block text-[10px] text-gray-500 leading-relaxed",children:"Blog & gallery â formulation breakthroughs, clinical trials, and innovation reports."})]})]}),e.jsxs("button",{onClick:()=>ue("Foundation Scholarship Tracker","Real-time scholarship dashboard tracking GPA, attendance, and disbursement across all 28 studios and 12 clinical suites. Operator console is wired â the donor-facing public view is being polished.","Q2 2026"),className:"flex items-center gap-2 px-4 py-3 text-sm font-medium border-b-2 border-transparent text-gray-500 hover:text-[#800020] hover:border-[#800020]/50 transition-all whitespace-nowrap group relative",children:[e.jsx(_t,{size:18})," Scholarships",e.jsxs("span",{className:"absolute left-0 top-full mt-0 hidden group-hover:block bg-white border border-gray-200 rounded-lg shadow-xl p-3 z-50 w-56",children:[e.jsx("span",{className:"block text-[10px] font-bold text-[#800020] uppercase mb-1.5",children:"28 Studios · 12 Suites"}),e.jsx("span",{className:"block text-[10px] text-gray-500 leading-relaxed",children:"Real-time tracking â GPA, attendance, disbursement monitoring across all facilities."})]})]}),e.jsxs("button",{onClick:()=>ue("Foundation Donor Portal","Tax-deductible giving with one-time and recurring options, donor wall recognition, and instant 501(c)(3) receipts. Stripe and FamousPay rails are connected â final donor-receipt email templates are pending Foundation board sign-off.","Q2 2026"),className:"flex items-center gap-2 px-4 py-3 text-sm font-medium border-b-2 border-transparent text-gray-500 hover:text-[#800020] hover:border-[#800020]/50 transition-all whitespace-nowrap",children:[e.jsx(FO,{size:18})," Donate"]}),e.jsxs("button",{onClick:()=>ue("Foundation Gala & Events Calendar","The annual Beauty With Purpose Gala, Research Garden open-houses, and donor recognition events will live here. RSVP, ticketing, and table sponsorship checkout are being built on top of the existing campus-tour scheduler.","Q3 2026"),className:"flex items-center gap-2 px-4 py-3 text-sm font-medium border-b-2 border-transparent text-gray-500 hover:text-[#800020] hover:border-[#800020]/50 transition-all whitespace-nowrap",children:[e.jsx(At,{size:18})," Events"]}),e.jsxs("div",{className:"ml-auto flex items-center gap-2 pl-2 border-l border-gray-100",children:[e.jsxs("span",{className:"text-[10px] font-bold px-2 py-1 rounded-full border flex items-center gap-1",style:{color:"#800020",backgroundColor:"#80002008",borderColor:"#80002030"},children:[e.jsx(Tt,{size:9})," 501(c)(3)"]}),e.jsx("span",{className:"text-[10px] font-bold px-2 py-1 rounded-full border flex items-center gap-1",style:{color:"#800020",backgroundColor:"#80002008",borderColor:"#80002030"},children:"Royal Burgundy â Trust"})]})]}),n==="village"&&e.jsxs(e.Fragment,{children:[e.jsxs("button",{onClick:()=>Ne("village-map"),className:`flex items-center gap-2 px-4 py-3 text-sm font-medium border-b-2 transition-all whitespace-nowrap ${t==="village-map"?"border-[#2D5016] text-[#2D5016]":"border-transparent text-gray-500 hover:text-gray-800 hover:border-gray-200"}`,children:[e.jsx(zt,{size:18})," Village Map"]}),e.jsxs("button",{onClick:()=>Ne("housing"),className:`flex items-center gap-2 px-4 py-3 text-sm font-medium border-b-2 transition-all whitespace-nowrap ${t==="housing"?"border-emerald-500 text-emerald-700":"border-transparent text-gray-500 hover:text-gray-800 hover:border-gray-200"}`,children:[e.jsx(K_,{size:18})," Student Housing"]}),e.jsxs("button",{onClick:()=>
1203Ne("hospitality"),className:`flex items-center gap-2 px-4 py-3 text-sm font-medium border-b-2 transition-all whitespace-nowrap ${t==="hospitality"?"border-amber-500 text-amber-700":"border-transparent text-gray-500 hover:text-gray-800 hover:border-gray-200"}`,children:[e.jsx(wO,{size:18})," Z-Bistro & Cafe"]}),e.jsxs("button",{onClick:()=>ue("Vertical Village Events Calendar","Campus open-houses, alumni mixers, instructor masterclasses, and seasonal Forest St gatherings will all live here with RSVP & ticketing. Wiring up to the existing campus-tour scheduler now.","Q3 2026"),className:"flex items-center gap-2 px-4 py-3 text-sm font-medium border-b-2 border-transparent text-gray-500 hover:text-gray-800 hover:border-gray-200 transition-all whitespace-nowrap",children:[e.jsx(At,{size:18})," Events"]}),e.jsx("div",{className:"ml-auto flex items-center gap-1 pl-2 border-l border-gray-100",children:e.jsx("span",{className:"text-[10px] font-bold text-[#2D5016] px-2 py-1 bg-[#2D5016]/10 rounded-full border border-[#2D5016]/20",children:"Forest St Campus"})})]})]})]}),j&&e.jsxs("div",{className:"lg:hidden bg-white border-t border-gray-100 shadow-lg max-h-[80vh] overflow-y-auto",children:[e.jsxs("div",{className:"px-4 py-3",children:[e.jsxs("div",{className:"relative",children:[e.jsx(Bt,{size:16,className:"absolute left-3 top-1/2 -translate-y-1/2",style:{color:"#800020"}}),e.jsx("input",{type:"text",placeholder:me,value:ee,onChange:Z=>ps(Z.target.value),onKeyDown:Ca,"aria-label":"Search the Zorganics site â programs, admissions, services, Foundation and more.",title:"Search the Zorganics site â press Enter to open the top match",className:"w-full pl-10 pr-4 py-2.5 bg-gray-50 border border-gray-200 rounded-lg text-sm focus:outline-none focus:ring-2 focus:ring-gold/30"})]}),se&&e.jsx(P3,{query:Q,onSelect:ft,onClose:()=>{Y(!1),K(""),S(!1)},variant:"inline"})]}),e.jsxs("div",{className:"px-4 py-2 border-b border-gray-100",children:[e.jsx("p",{className:"text-[10px] font-bold text-gray-400 uppercase tracking-wider mb-2",children:"Business Unit"}),e.jsx(L3,{})]}),n==="institute"&&e.jsx("div",{className:"px-4 py-3 border-b border-gray-100",children:y&&h?e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center gap-3 p-3 bg-gradient-to-r from-emerald-50 to-teal-50 rounded-xl border border-emerald-200",children:[e.jsx("div",{className:`w-10 h-10 rounded-xl bg-gradient-to-br ${Ut} flex items-center justify-center shadow-sm`,children:e.jsx("span",{className:"text-white text-xs font-bold",children:ht(h.fullName)})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"text-sm font-semibold text-gray-900 truncate",children:h.fullName}),e.jsx("p",{className:"text-[10px] text-emerald-600 font-mono",children:h.studentId})]}),e.jsx("span",{className:`px-2 py-0.5 rounded-full text-[9px] font-bold bg-gradient-to-r ${Ut} text-white`,children:h.program==="esthetics"?"EST":h.program==="cosmetology"?"COS":"MAS"})]}),e.jsxs("div",{className:"grid grid-cols-5 gap-2",children:[e.jsxs("button",{onClick:()=>{Ne("student-profile")},className:"flex flex-col items-center gap-1 p-2.5 rounded-xl bg-purple-50 text-purple-700 border border-purple-200 hover:bg-purple-100 transition-colors",children:[e.jsx(yr,{size:16}),e.jsx("span",{className:"text-[10px] font-semibold",children:"Profile"})]}),e.jsxs("button",{onClick:()=>{S(!1),F(!0)},className:"relative flex flex-col items-center gap-1 p-2.5 rounded-xl bg-blue-50 text-blue-700 border border-blue-200 hover:bg-blue-100 transition-colors",children:[e.jsxs("div",{className:"relative",children:[e.jsx(Di,{size:16}),b>0&&e.jsx("span",{className:"absolute -top-1.5 -right-2 flex items-center justify-center min-w-[14px] h-[14px] px-0.5 rounded-full bg-red-500 text-white text-[7px] font-bold",children:b>9?"9+":b})]}),e.jsx("span",{className:"text-[10px] font-semibold",children:"Alerts"})]}),e.jsxs("button",{onClick:()=>{Ne("student-progress")},className:"flex flex-col items-center gap-1 p-2.5 rounded-xl bg-emerald-50 text-emerald-700 border border-emerald-200 hover:bg-emerald-100 transition-colors",children:[e.jsx(La,{size:16}),e.jsx("span",{className:"text-[10px] font-semibold",children:"Progress"})]}),e.jsxs("button",{onClick:()=>{S(!1),ae()},className:"flex flex-col items-center gap-1 p-2.5 rounded-xl bg-blue-50 text-blue-700 border border-blue-200 hover:bg-blue-100 transition-colors",children:[e.jsx(Be,{size:16}),e.jsx("span",{className:"text-[10px] font-semibold",children:"Switch"})]}),e.jsxs("button",{onClick:()=>{S(!1),mt()},className:"flex flex-col items-center gap-1 p-2.5 rounded-xl bg-red-50 text-red-600 border border-red-200 hover:bg-red-100 transition-colors",children:[e.jsx(bo,{size:16}),e.jsx("span",{className:"text-[10px] font-semibold",children:"Sign Out"})]})]})]}):e.jsxs("button",{onClick:()=>{S(!1),V(!0)},className:"flex items-center justify-center gap-2 w-full px-4 py-3 bg-gradient-to-r from-emerald-600 to-teal-600 text-white rounded-xl text-sm font-semibold shadow-md",children:[e.jsx(Sy,{size:16})," Student Login"]})}),n==="institute"&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"border-b border-gray-100",children:[e.jsxs("button",{onClick:()=>X(!W),className:"flex items-center justify-between w-full px-6 py-3.5 text-sm font-bold transition-colors",style:{color:"#3B0A11"},children:[e.jsxs("span",{className:"flex items-center gap-3",children:[e.jsx(_t,{size:18,style:{color:"#D4AF37"}}),"Programs"]}),e.jsx(Gt,{size:16,className:`transition-transform duration-200 ${W?"rotate-180":""}`,style:{color:"#D4AF37"}})]}),W&&e.jsxs("div",{className:"px-4 pb-3 space-y-1",children:[yx.map(Z=>e.jsx(be,{to:Z.path,onClick:()=>{X(!1),S(!1),l(Z.programId),s("program-profiles"),a(!1)},className:"flex items-center w-full px-4 py-2.5 rounded-xl text-left text-sm font-semibold transition-all hover:bg-[rgba(212,175,55,0.06)]",style:{color:"#3B0A11",border:"1px solid rgba(212,175,55,0.1)"},children:Z.name},Z.programId)),e.jsx("div",{className:"my-1",style:{borderTop:"1px solid rgba(212,175,55,0.18)"}}),e.jsxs(be,{to:"/programs",onClick:()=>{X(!1),S(!1),s("program-profiles"),a(!1)},className:"flex items-center gap-2 w-full px-4 py-2.5 rounded-xl text-left text-sm font-semibold transition-all hover:bg-[rgba(212,175,55,0.06)]",style:{color:"#3B0A11",border:"1px solid rgba(212,175,55,0.1)"},children:[e.jsx(La,{size:14,style:{color:"#D4AF37"}}),"Compare Programs"]})]})]}),We.filter(Z=>Z.id!=="lms"&&Z.id!=="instructor-lms").map(Z=>{const xe=wt(Z.id);return e.jsxs("button",{onClick:()=>xe&&Ne(Z.id),disabled:!xe,className:`flex items-center gap-3 w-full px-6 py-3.5 text-sm font-medium transition-colors ${xe?t===Z.id?"bg-gold/5 text-gold-dark border-l-3 border-gold":"text-gray-600 hover:bg-gray-50":"text-gray-300 cursor-not-allowed"}`,children:[Z.icon," ",Z.label,!xe&&e.jsx(Xe,{size:12,className:"ml-auto text-gray-300"})]}
1203,Z.id)}),e.jsxs("div",{className:"px-4 py-2 border-t border-gray-100 space-y-2",children:[!u&&nA.map(Z=>e.jsxs("button",{onClick:()=>Ne(Z.id),className:"flex items-center gap-3 w-full px-4 py-3 rounded-xl text-sm font-semibold transition-all",style:{background:t===Z.id?"linear-gradient(135deg, #3B0A11, #5A1A24)":"rgba(59,10,17,0.04)",color:t===Z.id?"#E6D2A0":"#5A1A24",border:`1px solid ${t===Z.id?"#D4AF37":"rgba(128,0,32,0.1)"}`},children:[Z.icon," ",Z.label]},Z.id)),e.jsxs("button",{onClick:()=>Ne("ecosystem"),className:`flex items-center gap-3 w-full px-4 py-3 rounded-xl text-sm font-semibold transition-all ${t==="ecosystem"?"bg-gradient-to-r from-[#B8860B] to-[#DAA520] text-white shadow-md":"bg-[#DAA520]/10 text-[#B8860B] border border-[#DAA520]/30"}`,children:[e.jsx(Qe,{size:18})," Ecosystem"]}),e.jsxs(be,{to:"/programs/master-esthetician-bridge",onClick:()=>{S(!1),l("advanced-master-esthetics-450"),s("program-profiles"),a(!1)},className:`flex items-center gap-3 w-full px-4 py-3 rounded-xl text-sm font-semibold transition-all ${t==="program-profiles"&&o==="advanced-master-esthetics-450"?"bg-gradient-to-r from-[#0f172a] to-[#1e293b] text-[#DAA520] shadow-md":"bg-[#0f172a]/5 text-[#B8860B] border border-[#B8860B]/30"}`,children:[e.jsx(m0,{size:18})," 450h Clinical Bridge"]}),u&&e.jsxs("button",{onClick:()=>Ne("partner-portal"),className:`flex items-center gap-3 w-full px-4 py-3 rounded-xl text-sm font-semibold transition-all ${t==="partner-portal"?"bg-gradient-to-r from-teal-600 to-teal-700 text-white shadow-md":"bg-teal-50 text-teal-700 border border-teal-200"}`,children:[e.jsx(YS,{size:18})," Partner Dashboard"]}),e.jsxs("button",{onClick:()=>Ne("student-portal"),className:"flex items-center gap-3 w-full px-4 py-3 rounded-xl text-sm font-semibold transition-all relative",style:{background:t==="student-portal"?"linear-gradient(135deg, #3B0A11, #5A1A24)":"rgba(59,10,17,0.06)",color:t==="student-portal"?"#E6D2A0":"#5A1A24",border:`1px solid ${t==="student-portal"?"#D4AF37":"rgba(128,0,32,0.12)"}`},children:[e.jsx(_t,{size:18})," Student Portal",e.jsx("span",{className:"ml-auto px-2 py-0.5 rounded-full text-[9px] font-bold uppercase tracking-wider",style:{background:"rgba(5,150,105,0.12)",color:"#059669",border:"1px solid rgba(5,150,105,0.2)"},children:"Live"})]})]})]}),n==="cosmetics"&&e.jsx("div",{className:"px-4 py-2 space-y-2",children:e.jsxs("button",{onClick:()=>Ne("shop"),className:"flex items-center gap-3 w-full px-4 py-3 rounded-xl text-sm font-semibold bg-[#DAA520]/10 text-[#B8860B] border border-[#DAA520]/30",children:[e.jsx(Yl,{size:18})," Shop All Products"]})}),n==="professional"&&e.jsxs("div",{className:"px-4 py-2 space-y-2",children:[e.jsxs("button",{onClick:()=>Ne("med-spa-portal"),className:`flex items-center gap-3 w-full px-4 py-3 rounded-xl text-sm font-semibold transition-all ${t==="med-spa-portal"?"bg-gradient-to-r from-teal-600 to-teal-700 text-white shadow-md":"bg-teal-50 text-teal-700 border border-teal-200"}`,children:[e.jsx(Qe,{size:18})," Med Spa Portal"]}),e.jsxs("button",{onClick:()=>Ne("zoras-salon"),className:`flex items-center gap-3 w-full px-4 py-3 rounded-xl text-sm font-semibold transition-all ${t==="zoras-salon"?"bg-gradient-to-r from-[#800020] to-[#600018] text-white shadow-md":"bg-[#800020]/10 text-[#800020] border border-[#800020]/30"}`,children:[e.jsx(Ss,{size:18})," Zora's Salon"]}),e.jsxs("button",{onClick:()=>Ne("professional-services"),className:"flex items-center gap-3 w-full px-4 py-3 rounded-xl text-sm font-semibold bg-gray-50 text-gray-700 border border-gray-200",children:[e.jsx(ts,{size:18})," All Services"]})]}),n==="foundation"&&e.jsxs("div",{className:"px-4 py-2 space-y-2",children:[e.jsxs("button",{onClick:()=>Ne("foundation-landing"),className:"flex items-center justify-between w-full px-4 py-3 rounded-xl text-sm font-semibold border transition-all",style:{background:"#FBF8F2",borderColor:"rgba(212,175,55,0.4)"},children:[e.jsx(tA,{height:26,textColor:"#4A1942",medallionColor:"#4A1942",goldColor:"#D4AF37",showSubmark:!0}),e.jsx("span",{className:"text-[10px] font-bold uppercase tracking-wider px-2 py-0.5 rounded-full",style:{background:"rgba(74,25,66,0.08)",color:"#4A1942"},children:"Open"})]}),e.jsxs("button",{onClick:()=>Ne("foundation"),className:"flex items-center gap-3 w-full px-4 py-3 rounded-xl text-sm font-semibold bg-vi
1203olet-50 text-violet-700 border border-violet-200",children:[e.jsx(ta,{size:18})," Foundation Hub"]})]}),!u&&e.jsx("div",{className:"px-4 py-3 border-t border-gray-100",children:e.jsxs("button",{onClick:()=>{D(!0),S(!1)},className:"flex items-center justify-center gap-2 w-full px-4 py-2.5 bg-gradient-to-r from-gold-dark to-gold text-white rounded-lg text-sm font-semibold",children:[e.jsx($o,{size:16})," Sign In"]})})]})]})]}),e.jsx(Ex,{isOpen:I,onClose:()=>D(!1)}),e.jsx(oK,{isOpen:B,onClose:()=>A(!1),initialTab:z}),e.jsx(pK,{isOpen:L,onClose:()=>V(!1)}),e.jsx(J3,{isOpen:R,onClose:()=>T(!1),formType:"apply_now"}),e.jsx(J3,{isOpen:U,onClose:()=>q(!1),formType:"book_tour"}),e.jsx(QK,{isOpen:J,onClose:()=>te(!1),featureName:pe.name,description:pe.desc,expectedDate:pe.expectedDate})]})},rA="The mission of ZORGANICS Institute is to promote comprehensive learning by empowering aspiring beauty professionals with cutting-edge education, hands-on practical skills, and invaluable real-world experience. Our holistic approach blends scientific principles with artistic expression, rigorously preparing students for licensure and ensuring their success through fostering creativity, professionalism, and lifelong career growth in the dynamic beauty and wellness industry.",iQ=({variant:t="full",className:s=""})=>{const{setActiveSection:n,setShowHero:a}=dc();return t==="footer"?e.jsx("div",{className:`rounded-xl overflow-hidden ${s}`,style:{background:"linear-gradient(135deg, #800020 0%, #5A0016 100%)"},children:e.jsxs("div",{className:"px-6 py-5 relative",children:[e.jsx("div",{className:"absolute top-0 right-0 w-40 h-40 bg-white/[0.03] rounded-full -translate-y-1/2 translate-x-1/2"}),e.jsxs("div",{className:"relative",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[e.jsx(Tt,{size:12,style:{color:"#D4AF37"}}),e.jsx("span",{className:"text-[9px] font-bold uppercase tracking-[0.15em]",style:{color:"#D4AF37"},children:"Official NACCAS Mission Statement"})]}),e.jsx("p",{className:"text-sm leading-relaxed",style:{color:"#D4AF37",fontFamily:'"Georgia", "Times New Roman", "Palatino Linotype", serif'},children:rA}),e.jsx("p",{className:"text-[9px] mt-2 opacity-40",style:{color:"#D4AF37"},children:"Official NACCAS Mission Alignment â April 2026"})]})]})}):t==="compact"?e.jsx("div",{className:`rounded-xl overflow-hidden ${s}`,style:{background:"linear-gradient(135deg, #800020 0%, #600018 100%)"},children:e.jsxs("div",{className:"px-5 py-4 relative",children:[e.jsx("div",{className:"absolute top-0 right-0 w-32 h-32 bg-white/[0.03] rounded-full -translate-y-1/2 translate-x-1/2"}),e.jsxs("div",{className:"relative text-center",children:[e.jsxs("div",{className:"flex items-center justify-center gap-2 mb-2",children:[e.jsx(Is,{size:14,style:{color:"#D4AF37"}}),e.jsx("span",{className:"text-[10px] font-bold uppercase tracking-[0.15em]",style:{color:"#D4AF37"},children:"Our Mission"})]}),e.jsx("p",{className:"text-sm leading-relaxed max-w-3xl mx-auto",style:{color:"#D4AF37",fontFamily:'"Georgia", "Times New Roman", "Palatino Linotype", serif'},children:rA}),e.jsx("p",{className:"text-[9px] mt-2 opacity-40",style:{color:"#D4AF37"},children:"Official NACCAS Mission Alignment â April 2026"})]})]})}):e.jsxs("div",{className:`rounded-2xl overflow-hidden relative ${s}`,style:{background:"linear-gradient(135deg, #800020 0%, #4A0010 60%, #5A0016 100%)"},children:[e.jsx("div",{className:"absolute top-0 right-0 w-96 h-96 bg-white/[0.03] rounded-full -translate-y-1/2 translate-x-1/2"}),e.jsx("div",{className:"absolute bottom-0 left-0 w-64 h-64 bg-white/[0.02] rounded-full translate-y-1/2 -translate-x-1/2"}),e.jsx("div",{className:"absolute inset-0 opacity-[0.04]",style:{backgroundImage:"radial-gradient(circle at 2px 2px, #D4AF37 0.5px, transparent 0)",backgroundSize:"32px 32px"}}),e.jsx("div",{className:"relative px-8 lg:px-12 py-10 lg:py-14",children:e.jsxs("div",{className:"text-center max-w-4xl mx-auto",children:[e.jsxs("div",{className:"flex items-center justify-center gap-3 mb-6",children:[e.jsx("div",{className:"h-px flex-1 max-w-[80px]",style:{background:"linear-gradient(90deg, transparent, #D4AF37)"}}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(ta,{size:20,style:{color:"#D4AF37"}}),e.jsx("span",{className:"text-xl lg:text-2xl font-bold",style:{color:"#D4AF37",fontFamily:'"Georgia", "Times New Roman", serif'},children:"The Zorganics Foundation"}),e.jsx(ta,{size:20,style:{color:"#D4AF37"}})]}),e.jsx("div",{className:"h-px flex-1 max-w-[80px]",style:{background:"linear-gradient(90deg, #D4AF37, transparent)"}})]}),e.jsx("p",{className:"text-sm lg:text-base font-semibold tracking-wide mb-6",style:{color:"#E6D2A0",fontFamily:'"Georgia", "Times New Roman", serif'},children:"Restoring Confidence. Expanding Opportunity. Strengthening Community."}),e.jsxs("div",{className:"space-y-4 text-base lg:text-lg leading-relaxed text-left sm:text-center",style:{color:"#D4AF37",fontFamily:'"Georgia", "Times New Roman", "Palatino Linotype", "Book Antiqua", serif',textShadow:"0 1px 2px rgba(0,0,0,0.2)"},children:[e.jsx("p",{children:"The Zorganics Foundation is dedicated to supporting individuals and communities through beauty and wellness services, education, scholarships, and compassionate support."}),e.jsx("p",{children:"A central part of our mission is serving individuals affected by cancer, helping restore confidence and a sense of well-being through complimentary beauty and supportive wellness services."}),e.jsx("p",{children:"The Foundation also works to expand access to education through scholarship opportunities that help eligible students pursue professional beauty and wellness careers."}),e.jsx("p",{children:"Through community partnerships, charitable giving, and outreach, the Zorganics Foundation seeks to make meaningful support more accessible to individuals and families in the communities we serve."})]}),e.jsxs("button",{onClick:()=>{n("foundation"),a(!1),typeof window<"u"&&window.scrollTo({top:0,behavior:"smooth"})},className:"inline-flex items-center gap-2 mt-8 px-6 py-3 rounded-full text-xs font-bold uppercase tracking-[0.15em] transition-all duration-300 hover:-translate-y-0.5",style:{background:"linear-gradient(135deg, #D4AF37 0%, #E6D2A0 50%, #D4AF37 100%)",color:"#4A0010",border:"1px solid rgba(230,210,160,0.6)",boxShadow:"0 8px 24px rgba(212,175,55,0.28)"},children:["Learn More About the Zorganics Foundation",e.jsx(Vt,{size:14})]})]})})]})},oQ="#7A3A44",lQ="#E8DDD0",cQ=({checked:t,onChange:s,id:n="disclosure-acknowledgement",className:a=""})=>e.jsxs("label",{htmlFor:n,className:`flex items-start gap-3 cursor-pointer select-none rounded-xl p-4 transition-all duration-300 ${a}`,style:{background:t?"rgba(212,175,55,0.07)":"#FFFFFF",border:`1px solid ${t?"rgba(212,175,55,0.4)":lQ}`,boxShadow:t?"0 2px 10px rgba(212,175,55,0.08)":"none"},children:[e.jsxs("span",{className:"relative flex-shrink-0 mt-0.5",children:[e.jsx("input",{id:n,type:"checkbox",required:!0,checked:t,onChange:r=>s(r.target.checked),className:"sr-only peer"}),e.jsx("span",{className:"w-5 h-5 rounded-md flex items-center justify-center transition-all duration-300",style:{background:t?`linear-gradient(135deg, ${$} 0%, #B8962E 100%)`:"#FFFFFF",border:`1.5px solid ${t?$:"#C9BBA8"}`,boxShadow:t?"0 2px 6px rgba(212,175,55,0.3)":"none"},children:t&&e.jsx(xt,{size:13,strokeWidth:3,style:{color:k}})})]}),e.jsxs("span",{className:"text-xs leading-relaxed",style:{color:oQ},children:[e.jsx("span",{style:{color:$,fontWeight:700},children:"*"})," ","I acknowledge that I have been provided access to the"," ",e.jsx("strong",{style:{color:k}
1203,children:"Zorganics Institute School Catalog"})," and"," ",e.jsx("strong",{style:{color:k},children:"Consumer Disclosures"}),"."]})]}),In="[email protected]",Fi="(360) 392-8243",Fx="+13603928243",dQ="410 West Bakerview Rd, Suite 112, Bellingham, WA 98226",uQ="https://www.ed.gov",mQ=[{key:"bellingham",name:"Bellingham â Active Campus",longName:"Bellingham â Bakerview Campus",subtitle:"Active Teaching Facility",address:"410 West Bakerview Rd, Suite 112, Bellingham, WA 98226",fullAddress:"Zorganics Institute, 410 West Bakerview Rd, Suite 112, Bellingham, WA 98226",phone:Fi,telHref:`tel:${Fx}`,email:In,hours:"MonâThu: 8:30 AM â 8:00 PM | Fri: 8:30 AM â 6:00 PM | Saturday: CLOSED",features:["Six Beauty Career Programs","Instructor-Supervised Student Salon & Esthetics Clinic","Classrooms & Hands-On Practical Training Spaces","On-Site Botanical Studio"],flagship:!0,badge:"Active Now"}],Uhe=[{name:"Admissions",email:In,phone:Fi,desc:"Program inquiries, applications, campus tours"},{name:"Financial Aid",email:In,phone:Fi,desc:"Title IV, scholarships, payment plans"},{name:"Student Services",email:In,phone:Fi,desc:"Enrollment, transcripts, student support"},{name:"Career Placement",email:In,phone:Fi,desc:"Job placement, industry connections"}],su={instagram:"https://www.instagram.com/zorganicsinstitute/",linkedin:"https://www.linkedin.com/company/zorganics-institute/",youtube:"https://www.youtube.com/@ZorganicsInstitute",facebook:"https://www.facebook.com/ZorganicsInstitute/",tiktok:"https://www.tiktok.com/@zorganicsinstitute",googleBusiness:"https://www.google.com/search?q=Zorganics+Institute+Bellingham+WA"},hn="#5A1A24",Dt="#7A3A44",Tv="#E6D2A0",pQ="#F2EBE3",hQ="#F5F0E8",fs="#E8DDD0",Np="#FAF7F2",xQ=({size:t=18})=>e.jsxs("svg",{width:t,height:t,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("rect",{x:"2",y:"2",width:"20",height:"20",rx:"5",ry:"5"}),e.jsx("path",{d:"M16 11.37A4 4 0 1 1 12.63 8 4 4 0 0 1 16 11.37z"}),e.jsx("line",{x1:"17.5",y1:"6.5",x2:"17.51",y2:"6.5"})]}),fQ=({size:t=18})=>e.jsx("svg",{width:t,height:t,viewBox:"0 0 24 24",fill:"currentColor",children:e.jsx("path",{d:"M23.498 6.186a3.016 3.016 0 0 0-2.122-2.136C19.505 3.545 12 3.545 12 3.545s-7.505 0-9.377.505A3.017 3.017 0 0 0 .502 6.186C0 8.07 0 12 0 12s0 3.93.502 5.814a3.016 3.016 0 0 0 2.122 2.136c1.871.505 9.376.505 9.376.505s7.505 0 9.377-.505a3.015 3.015 0 0 0 2.122-2.136C24 15.93 24 12 24 12s0-3.93-.502-5.814zM9.545 15.568V8.432L15.818 12l-6.273 3.568z"})}),gQ=({size:t=18})=>e.jsx("svg",{width:t,height:t,viewBox:"0 0 24 24",fill:"currentColor",children:e.jsx("path",{d:"M20.447 20.452h-3.554v-5.569c0-1.328-.027-3.037-1.852-3.037-1.853 0-2.136 1.445-2.136 2.939v5.667H9.351V9h3.414v1.561h.046c.477-.9 1.637-1.85 3.37-1.85 3.601 0 4.267 2.37 4.267 5.455v6.286zM5.337 7.433a2.062 2.062 0 0 1-2.063-2.065 2.064 2.064 0 1 1 2.063 2.065zm1.782 13.019H3.555V9h3.564v11.452zM22.225 0H1.771C.792 0 0 .774 0 1.729v20.542C0 23.227.792 24 1.771 24h20.451C23.2 24 24 23.227 24 22.271V1.729C24 .774 23.2 0 22.222 0h.003z"})}),yQ=({size:t=18})=>e.jsx("svg",{width:t,height:t,viewBox:"0 0 24 24",fill:"currentColor",children:e.jsx("path",{d:"M24 12.073c0-6.627-5.373-12-12-12s-12 5.373-12 12c0 5.99 4.388 10.954 10.125 11.854v-8.385H7.078v-3.47h3.047V9.43c0-3.007 1.792-4.669 4.533-4.669 1.312 0 2.686.235 2.686.235v2.953H15.83c-1.491 0-1.956.925-1.956 1.874v2.25h3.328l-.532 3.47h-2.796v8.385C19.612 23.027 24 18.062 24 12.073z"})}),bQ=({size:t=18})=>e.jsx("svg",{width:t,height:t,viewBox:"0 0 24 24",fill:"currentColor",children:e.jsx("path",{d:"M19.59 6.69a4.83 4.83 0 0 1-3.77-4.25V2h-3.45v13.67a2.89 2.89 0 0 1-2.88 2.5 2.89 2.89 0 0 1-2.88-2.88 2.89 2.89 0 0 1 2.88-2.88c.28 0 .54.04.79.1v-3.5a6.37 6.37 0 0 0-.79-.05A6.34 6.34 0 0 0 3.15 15.2a6.34 6.34 0 0 0 6.34 6.34 6.34 6.34 0 0 0 6.34-6.34V9.04a8.16 8.16 0 0 0 4.76 1.52v-3.4a4.85 4.85 0 0 1-1-.47z"})}),vQ=({size:t=18})=>e.jsxs("svg",{width:t,height:t,viewBox:"0 0 24 24",fill:"currentColor",children:[e.jsx("path",{d:"M22.56 12.25c0-.78-.07-1.53-.2-2.25H12v4.26h5.92a5.06 5.06 0 0 1-2.2 3.32v2.77h3.57c2.08-1.92 3.28-4.74 3.28-8.1z"}),e.jsx("path",{d:"M12 23c2.97 0 5.46-.98 7.28-2.66l-3.57-2.77c-.98.66-2.23 1.06-3.71 1.06-2.86 0-5.29-1.93-6.16-4.53H2.18v2.84C3.99 20.53 7.7 23 12 23z"}),e.jsx("path",{d:"M5.84 14.09c-.22-.66-.35-1.36-.35-2.09s.13-1.43.35-2.09V7.07H2.18C1.43 8.55 1 10.22 1 12s.43 3.45 1.18 4.93l2.85-2.22.81-.62z"}),e.jsx("path",{d:"M12 5.38c1.62 0 3.06.56 4.21 1.64l3.15-3.15C17.45 2.09 14.97 1 12 1 7.7 1 3.99 3.47 2.18 7.07l3.66 2.84c.87-2.6 3.3-4.53 6.16-4.53z"})]}),iA="https://d64gsuwffb70l.cloudfront.net/69cae7fb5ea7db794957149e_1775337912224_4cc82887.jfif",jQ=[{icon:e.jsx(vQ,{}),label:"Google",href:su.googleBusiness},{icon:e.jsx(xQ,{}),label:"Instagram",href:su.instagram},{icon:e.jsx(fQ,{}),label:"YouTube",href:su.youtube},{icon:e.jsx(gQ,{}),label:"LinkedIn",href:su.linkedin},{icon:e.jsx(yQ,{}),label:"Facebook",href:su.facebook},{icon:e.jsx(bQ,{}),label:"TikTok",href:su.tiktok}
1203],oA=mQ,wQ=[{key:"idx-school-catalog",label:"School Catalog",href:"/school-catalog",desc:"Programs, clock hours, tuition schedule & academic calendar",keywords:"catalog programs cosmetology esthetics nails hours tuition fees academic calendar admissions enrollment"},{key:"idx-consumer-information",label:"Consumer Information",href:"/consumerinformation",desc:"Financial aid rights, student services & voter registration",keywords:"consumer information financial aid rights responsibilities pell loans wioa gi bill student services voter registration ferpa nondiscrimination outcomes"},{key:"idx-sap",label:"Satisfactory Academic Progress (SAP)",href:"/consumerinformation",desc:"SAP standards, warning, probation & appeal procedures",keywords:"sap satisfactory academic progress warning probation appeal attendance grade gpa clock hour"},{key:"idx-r2t4",label:"Return to Title IV (R2T4) & Refund Policy",href:"/consumerinformation",desc:"Withdrawal, refund & federal aid return calculation",keywords:"r2t4 return title iv refund withdrawal federal aid calculation"},{key:"idx-financial-aid",label:"Financial Aid · FAFSA & Grants",href:"/consumerinformation",desc:"FAFSA, Pell, Direct Loans, WIOA & GI Bill®",keywords:"financial aid fafsa pell grant direct loan plus wioa gi bill washington state grant federal school code 043003"},{key:"idx-asr",label:"Annual Security Report (Clery Act)",href:"/annual-security-report",desc:"Campus safety, crime statistics & emergency contacts",keywords:"annual security report clery act campus safety crime statistics emergency contacts title ix vawa 911 988 timely warning"},{key:"idx-privacy",label:"Privacy Policy & WA My Health My Data Act",href:"/privacy-policy",desc:"Institutional privacy & Washington consumer health data",keywords:"privacy policy washington my health my data act mhmda consumer health data rcw cookies ferpa data rights"},{key:"idx-ferpa",label:"FERPA Notice",href:"/consumerinformation",desc:"Education records rights & directory information",keywords:"ferpa family educational rights privacy act education records directory information consent"}],lA=()=>{const{setActiveSection:t,setShowHero:s,setSelectedProgramId:n}=dc(),{isAuthenticated:a}=kn(),[r,i]=d.useState(""),[o,l]=d.useState(!1),[c,u]=d.useState(0),[p,m]=d.useState(!1),[x,h]=d.useState(""),y=x.trim().toLowerCase(),v=y?wQ.filter(f=>f.label.toLowerCase().includes(y)||f.desc.toLowerCase().includes(y)||f.keywords.includes(y)):[],g=f=>{t(f),s(!1),window.scrollTo({top:0,behavior:"smooth"})},N=f=>{n(f),t("program-profiles"),s(!1),window.scrollTo({top:0,behavior:"smooth"})},b=async f=>{if(f.preventDefault(),!(!r||!p)){try{await fetch("https://famous.ai/api/crm/tojqzezdtojnxquphifh/subscribe",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({email:r,source:"footer-signup",tags:["newsletter","footer","disclosure-acknowledged"]})})}catch{}eu({policyKey:"disclosure-acknowledgement",policyLabel:"Catalog & Consumer Disclosures Acknowledged",source:"footer-newsletter"}),NI({studentEmail:r,source:"footer-newsletter"}),l(!0),setTimeout(()=>{l(!1),i(""),m(!1)},3e3)}};return e.jsxs("footer",{className:"relative",role:"contentinfo",style:{background:`linear-gradient(180deg, ${pQ} 0%, ${hQ} 40%, ${Np} 100%)`},children:[e.jsx("div",{className:"h-[3px] relative",style:{background:`linear-gradient(90deg, ${fs} 0%, ${$} 25%, ${Tv} 50%, ${$} 75%, ${fs} 100%)`,boxShadow:"0 2px 12px rgba(212,175,55,0.15), 0 1px 4px rgba(212,175,55,0.1)"}}),e.jsx("div",{style:{borderBottom:`1px solid ${fs}`},children:e.jsx("div",{className:"max-w-[1600px] mx-auto px-4 lg:px-8 py-4",children:e.jsxs("div",{className:"flex flex-col md:flex-row items-center justify-between gap-4",children:[e.jsxs("div",{className:"flex items-center gap-6 flex-wrap",children:[e.jsxs("a",{href:"tel:+13603928243",className:"flex items-center gap-3 text-sm transition-all duration-300 group",style:{color:hn},children:[e.jsx("div",{className:"w-10 h-10 rounded-xl overflow-hidden flex items-center justify-center flex-shrink-0",style:{background:"linear-gradient(145deg, #FFFFFF 0%, #F8F6F0 100%)",boxShadow:`0 2px 12px rgba(212,175,55,0.2), 0 0 0 1.5px ${$}, 0 0 0 4px rgba(212,175,55,0.08)`},children:e.jsx("img",{src:iA,alt:"Zorganics",className:"w-[32px] h-[32px] object-contain",style:{filter:"contrast(1.08) saturate(1.1)"}})}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Qt,{size:14,style:{color:$},className:"group-hover:scale-110 transition-transform duration-300"}),e.jsx("span",{className:"font-semibold tracking-wide group-hover:text-[#D4AF37] transition-colors duration-300",children:"(360) 392-8243"})]})]}),e.jsxs("a",{href:`mailto:${In}`,className:"flex items-center gap-2 text-sm transition-all duration-300 hover:text-[#D4AF37]",style:{color:hn},children:[e.jsx(Ye,{size:14,style:{color:$}}),e.jsx("span",{className:"font-semibold",children:In})]}),e.jsxs("div",{className:"hidden lg:flex items-center gap-2 text-sm",style:{color:Dt},children:[e.jsx(zt,{size:14,style:{color:$}}),e.jsxs("span",{children:["410 West Bakerview Rd, Ste 112, Bellingham, WA · ",e.jsx("strong",{style:{color:hn},children:"Active Campus"})]})]})]}),e.jsx("div",{className:"flex items-center gap-5",children:jQ.map(f=>e.jsx("a",{href:f.href,target:"_blank",rel:"noopener noreferrer",className:"transition-all duration-300 hover:-translate-y-0.5",style:{color:$},title:`Follow Zorganics Institute on ${f.label}`,"aria-label":`Follow Zorganics Institute on ${f.label}`,onMouseEnter:j=>{j.currentTarget.style.color=Tv,j.currentTarget.style.filter="drop-shadow(0 2px 6px rgba(212,175,55,0.35))"},onMouseLeave:j=>{j.currentTarget.style.color=$,j.currentTarget.style.filter="none"},children:f.icon},f.label))})]})})}),e.jsxs("div",{className:"max-w-[1600px] mx-auto px-4 lg:px-8 py-16",children:[e.jsxs("div",{className:"grid md:grid-cols-2 lg:grid-cols-6 gap-10",children:[e.jsxs("div",{className:"lg:col-span-2",children:[e.jsxs("div",{className:"flex items-center gap-3 mb-5",children:[e.jsx("div",{className:"w-11 h-11 rounded-xl overflow-hidden flex-shrink-0",style:{boxShadow:`0 3px 16px rgba(212,175,55,0.18), 0 0 0 1.5px ${$}, 0 0 0 4px rgba(212,175,55,0.06)`},children:e.jsx("img",{src:iA,alt:"Zorganics Institute",className:"w-full h-full object-cover"})}),e.jsxs("div",{children:[e.jsxs("h3",{className:"font-display text-lg font-bold",style:{color:k},children:["Zorganics",e.jsx("span",{style:{color:$},children:" Institute"})]}
1203),e.jsx("p",{className:"text-[10px] tracking-wider uppercase font-data",style:{color:Dt},children:"A Holistic Approach To Beauty and Wellness through Science and Art"})]})]}),e.jsx("div",{className:"mb-6",children:e.jsx(iQ,{variant:"footer"})}),e.jsxs("div",{className:"space-y-2.5 mb-6",children:[e.jsxs("a",{href:`mailto:${In}`,className:"flex items-center gap-2 text-sm font-medium transition-all duration-300 hover:text-[#D4AF37]",style:{color:hn},children:[e.jsx(Ye,{size:14,style:{color:$}})," ",In]}),e.jsxs("a",{href:`tel:${Fx}`,className:"flex items-center gap-2 text-sm font-medium transition-all duration-300 hover:text-[#D4AF37]",style:{color:hn},children:[e.jsx(Qt,{size:14,style:{color:$}})," ",Fi]}),e.jsxs("div",{className:"flex items-start gap-2 text-sm",style:{color:Dt},children:[e.jsx(zt,{size:14,style:{color:$},className:"mt-0.5 flex-shrink-0"}),e.jsxs("span",{children:["410 West Bakerview Rd, Ste 112, Bellingham, WA · ",e.jsx("strong",{style:{color:hn},children:"Active Campus"})]})]})]}),e.jsxs("div",{className:"rounded-xl p-5",style:{background:`linear-gradient(135deg, ${Np} 0%, #FFFFFF 100%)`,border:`1px solid ${fs}`,boxShadow:"0 2px 12px rgba(212,175,55,0.06)"},children:[e.jsx("p",{className:"text-xs font-bold uppercase tracking-wider mb-3",style:{color:k},children:"Stay Updated"}),o?e.jsxs("div",{className:"flex items-center gap-2 text-sm",style:{color:"#2D8A4E"},children:[e.jsx(pt,{size:16})," Subscribed successfully!"]}):e.jsxs("form",{onSubmit:b,className:"space-y-3",children:[e.jsx("input",{type:"email",value:r,onChange:f=>i(f.target.value),placeholder:"Enter your email",className:"w-full px-3 py-2.5 rounded-lg text-xs focus:outline-none transition-all duration-300",style:{background:"#FFFFFF",border:`1px solid ${fs}`,color:k},onFocus:f=>{f.target.style.borderColor=$,f.target.style.boxShadow="0 0 0 3px rgba(212,175,55,0.1)"},onBlur:f=>{f.target.style.borderColor=fs,f.target.style.boxShadow="none"}}),e.jsx(cQ,{checked:p,onChange:m}),e.jsxs("button",{type:"submit",disabled:!p,className:"w-full flex items-center justify-center gap-2 px-4 py-2.5 rounded-lg text-xs font-bold uppercase tracking-wider hover:shadow-lg transition-all duration-300 hover:-translate-y-0.5 disabled:opacity-40 disabled:cursor-not-allowed disabled:hover:translate-y-0",style:{background:`linear-gradient(135deg, ${$} 0%, #B8962E 100%)`,color:k},children:[e.jsx(Hs,{size:13})," Subscribe"]})]})]}),e.jsxs("div",{className:"flex flex-wrap gap-3 mt-5",children:[e.jsxs("button",{onClick:()=>g("foundation"),className:"flex items-center gap-2 px-4 py-2.5 rounded-lg text-xs font-bold uppercase tracking-wider transition-all duration-300 hover:shadow-lg hover:-translate-y-0.5",style:{background:`linear-gradient(135deg, ${$} 0%, #C9A832 100%)`,color:k,boxShadow:"0 2px 8px rgba(212,175,55,0.25)"},children:[e.jsx(ta,{size:13})," Donate to Foundation"]}),e.jsxs(be,{to:"/admissions",onClick:()=>g("admissions"),className:"flex items-center gap-2 px-4 py-2.5 rounded-lg text-xs font-bold uppercase tracking-wider transition-all duration-300 hover:shadow-lg hover:-translate-y-0.5",style:{background:`linear-gradient(135deg, ${$} 0%, #C9A832 100%)`,color:k,boxShadow:"0 2px 8px rgba(212,175,55,0.25)"},children:[e.jsx(Na,{size:13})," Enroll Now"]}),e.jsxs("button",{onClick:()=>g("student-portal"),className:"flex items-center gap-2 px-4 py-2.5 rounded-lg text-xs font-bold uppercase tracking-wider transition-all duration-300 hover:shadow-lg hover:-translate-y-0.5",style:{background:k,color:$,border:`1px solid ${$}`,boxShadow:"0 2px 8px rgba(59,10,17,0.2)"},title:"Pay tuition â sign in to the Student Portal and open your Financial Suite","aria-label":"Pay tuition â opens the Student Portal Financial Suite where you can make a secure payment",children:[e.jsx(Ro,{size:13})," Pay Tuition"]})]})]}),a?e.jsxs("div",{children:[e.jsx("h4",{className:"text-sm font-bold uppercase tracking-wider mb-5",style:{color:k},children:"Internal Platform"}),e.jsx("ul",{className:"space-y-3",children:[{label:"Program Dashboard",section:"dashboard"},{label:"Z-LMS",section:"lms"},{label:"POS & Inventory",section:"pos"},{label:"Franchise HQ",section:"franchise"},{label:"RGM Financial Oversight",section:"rgm-compliance"},{label:"Partner Dashboard",section:"partner-portal"}].map(f=>e.jsx("li",{children:e.jsx("button",{onClick:()=>g(f.section),className:"text-sm transition-all duration-300 hover:text-[#D4AF37] hover:translate-x-1",style:{color:Dt},children:f.label})},f.section))})]}):e.jsxs("div",{children:[e.jsx("h4",{className:"text-sm font-bold uppercase tracking-wider mb-5",style:{color:k},children:"Secure Portals"}),e.jsxs("ul",{className:"space-y-3",children:[e.jsx("li",{children:e.jsx("button",{onClick:()=>g("student-portal"),className:"text-sm transition-all duration-300 hover:text-[#D4AF37] hover:translate-x-1 text-left",style:{color:Dt},title:"ZLP â Zorganics Learning Portal (student sign-in required)",children:"Student Portal (ZLP)"})}),e.jsx("li",{children:e.jsx("a",{href:"/scholar",className:"text-sm transition-all duration-300 hover:text-[#D4AF37] hover:translate-x-1 inline-block",style:{color:Dt},title:"Z-LMS + SIS â secure scholar portal (sign-in required)",children:"Z-LMS Scholar Portal"})}),e.jsx("li",{children:e.jsx("button",{onClick:()=>g("employer-workspace"),className:"text-sm transition-all duration-300 hover:text-[#D4AF37] hover:translate-x-1 text-left",style:{color:Dt},title:"Employer Portal â job postings, externships & graduate connections (access code required)",children:"Employer Portal"})}),e.jsx("li",{children:e.jsx("a",{href:"/foundation/donor",className:"text-sm transition-all duration-300 hover:text-[#D4AF37] hover:translate-x-1 inline-block",style:{color:Dt},title:"Foundation Donor Portal â manage giving & receipts (email sign-in)",children:"Foundation Donor Portal"})}),e.jsx("li",{children:e.jsx("a",{href:"/verify-transcript",className:"text-sm transition-all duration-300 hover:text-[#D4AF37] hover:translate-x-1 inline-block",style:{color:Dt},title:"Verify the authenticity of an official Zorganics transcript",children:"Verify a Transcript"})})]})]}),e.jsxs("div",{children:[e.jsx("h4",{className:"text-sm font-bold uppercase tracking-wider mb-5",style:{color:k},children:"About"}),e.jsxs("ul",{className:"space-y-3",children:[e.jsx("li",{children:e.jsx(be,{to:"/about-us",onClick:()=>g("our-story"),className:"text-sm font-medium transition-all duration-300 hover:text-[#D4AF37] hover:translate-x-1 inline-block",style:{color:Dt},children:"Our Story"})}),e.jsx("li",{children:e.jsx(be,{to:"/contact",onClick:()=>g("contact-us"),className:"text-sm font-medium transition-all duration-300 hover:text-[#D4AF37] hover:translate-x-1 inline-block",style:{color:Dt},children:"Contact Us"})}),e.jsx("li",{children:e.jsx(be,{to:"/admissions",onClick:()=>g("admissions"),className:"text-sm font-medium transition-all duration-300 hover:text-[#D4AF37] hover:translate-x-1 inline-block",style:{color:Dt},children:"Admissions"})}),e.jsx("li",{children:e.jsx(be,{to:"/news",className:"text-sm font-medium transition-all duration-300 hover:text-[#D4AF37] hover:translate-x-1 inline-block",style:{color:Dt},children:"News & Press"})}),e.jsx("li",{children:e.jsx(be,{to:"/salon",onClick:()=>g("salon-services"),className:"text-sm font-medium transition-all duration-300 hover:text-[#D4AF37] hover:translate-x-1 inline-block",style:{color:Dt},children:"Salon & Spa Services"})}),e.jsx("li",{children:e.jsx("button",{onClick:()=>g("foundation"),className:"text-sm font-medium transition-all duration-300 hover:text-[#D4AF37] hover:translate-x-1",style:{color:Dt},children:"Zorganics Foundation"})}
1203),[{label:"Wholesale B2B",section:"wholesale",authOnly:!1},{label:"Reviewer Access",section:"reviewer-access",authOnly:!0}].filter(f=>!f.authOnly||a).map(f=>{const j=Yb(f.section);return e.jsx("li",{children:j?e.jsx(be,{to:j,onClick:()=>g(f.section),className:"text-sm transition-all duration-300 hover:text-[#D4AF37] hover:translate-x-1 flex items-center gap-2",style:{color:Dt},children:f.label}):e.jsx("button",{onClick:()=>g(f.section),className:"text-sm transition-all duration-300 hover:text-[#D4AF37] hover:translate-x-1 flex items-center gap-2",style:{color:Dt},children:f.label})},f.section)})]})]}),e.jsxs("div",{children:[e.jsx("h4",{className:"text-sm font-bold uppercase tracking-wider mb-5",style:{color:k},children:"Programs"}),e.jsx("ul",{className:"space-y-3",children:[{label:"Cosmetology (1,600 hrs)",programId:"cosmetology"},{label:"Esthetician (750 hrs)",programId:"esthetics-750"},{label:"Master Esthetician (1,200 hrs)",programId:"master-esthetics-1200"},{label:"Master Esthetician Bridge (450 hrs)",programId:"advanced-master-esthetics-450"},{label:"Manicurist (600 hrs)",programId:"manicurist"},{label:"Instructor Training (600 hrs)",programId:"instructor"}].map(f=>e.jsx("li",{children:e.jsx(be,{to:h0(f.programId)||"/programs",onClick:()=>N(f.programId),className:"text-sm text-left transition-all duration-300 hover:text-[#D4AF37] hover:translate-x-1 inline-block",style:{color:Dt},"aria-label":`View the ${f.label} program details`,children:f.label})},f.programId))}),e.jsx("h4",{className:"text-sm font-bold uppercase tracking-wider mt-7 mb-4",style:{color:k},children:"Admissions & Aid"}),e.jsx("ul",{className:"space-y-3",children:[{to:"/esthetics-program",label:"Esthetician Program"},{to:"/cosmetology-program",label:"Cosmetology Program"},{to:"/master-esthetics",label:"Master Esthetician Program"},{to:"/financial-aid",label:"Financial Aid"},{to:"/book-online",label:"Schedule a Tour"},{to:"/apply-now",label:"Apply Now"}].map(f=>e.jsx("li",{children:e.jsx(be,{to:f.to,className:"text-sm text-left transition-all duration-300 hover:text-[#D4AF37] hover:translate-x-1 inline-block",style:{color:Dt},children:f.label})},f.to))})]}),e.jsxs("div",{children:[e.jsx("h4",{className:"text-sm font-bold uppercase tracking-wider mb-5",style:{color:k},children:"Locations"}),e.jsx("div",{className:"space-y-3",children:oA.map((f,j)=>e.jsxs("div",{className:"rounded-xl overflow-hidden",children:[e.jsxs("button",{onClick:()=>u(c===j?-1:j),className:"flex items-center justify-between w-full text-left px-3.5 py-2.5 rounded-xl transition-all duration-300",style:{background:c===j?"linear-gradient(135deg, rgba(212,175,55,0.08) 0%, rgba(212,175,55,0.04) 100%)":Np,border:`1px solid ${c===j?"rgba(212,175,55,0.25)":fs}`,boxShadow:c===j?"0 2px 8px rgba(212,175,55,0.08)":"none"},children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-medium transition-colors duration-300",style:{color:c===j?$:hn},children:f.name}),f.badge&&e.jsx("span",{className:"text-[9px] font-bold uppercase tracking-wider",style:{color:f.future?"#B8962E":f.flagship?$:Dt},children:f.badge})]}),e.jsx(Gt,{size:14,className:`transition-transform duration-300 ${c===j?"rotate-180":""}`,style:{color:Dt}})]}),c===j&&e.jsxs("div",{className:"px-3.5 py-2.5 space-y-2 rounded-b-xl",style:{background:Np,borderLeft:`1px solid ${fs}`,borderRight:`1px solid ${fs}`,borderBottom:`1px solid ${fs}`},children:[e.jsxs("div",{className:"flex items-start gap-2 text-xs",style:{color:Dt},children:[e.jsx(zt,{size:11,style:{color:$},className:"mt-0.5 flex-shrink-0"})," ",e.jsx("span",{children:f.address})]}),e.jsxs("a",{href:`tel:+1${f.phone.replace(/[^0-9]/g,"")}`,className:"flex items-center gap-2 text-xs transition-all duration-300 hover:text-[#D4AF37]",style:{color:Dt},children:[e.jsx(Qt,{size:11,style:{color:$}})," ",f.phone]}),e.jsxs("a",{href:`mailto:${f.email}`,className:"flex items-center gap-2 text-xs transition-all duration-300 hover:text-[#D4AF37]",style:{color:Dt},children:[e.jsx(Ye,{size:11,style:{color:$}})," ",f.email]})]})]},j))}),e.jsx("h4",{className:"text-sm font-bold uppercase tracking-wider mt-7 mb-3",style:{color:k},children:"Compliance"}),e.jsx("ul",{className:"space-y-2.5",children:[{label:"NACCAS Accredited",href:void 0},{label:"WA State DOL",href:void 0},{label:"U.S. Dept. of Education",href:uQ},{label:"Title IV / FSA",href:void 0},{label:"FERPA Privacy",href:void 0}].map(f=>e.jsx("li",{children:f.href?e.jsxs("a",{href:f.href,target:"_blank",rel:"noopener noreferrer",className:"text-xs inline-flex items-center gap-1.5 transition-all duration-300 hover:text-[#D4AF37]",style:{color:Dt},children:[f.label,e.jsx(Ua,{size:10,style:{color:$},className:"opacity-70"})]}):e.jsx("span",{className:"text-xs cursor-default transition-all duration-300 hover:text-[#D4AF37]",style:{color:Dt},children:f.label})},f.label))})]})]}),e.jsx("div",{className:"mt-14 pt-12",style:{borderTop:`1px solid ${fs}`},children:e.jsxs("div",{className:"rounded-3xl overflow-hidden",style:{background:`linear-gradient(135deg, #FFFFFF 0%, ${Np} 100%)`,border:`1px solid ${fs}`,boxShadow:"0 8px 40px rgba(59,10,17,0.05), 0 2px 12px rgba(212,175,55,0.06)"},children:[e.jsxs("div",{className:"px-6 lg:px-10 py-7 flex flex-col md:flex-row md:items-center md:justify-between gap-4",style:{borderBottom:`1px solid ${fs}`,background:"linear-gradient(135deg, rgba(212,175,55,0.05) 0%, rgba(255,255,255,0) 100%)"},children:[e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx("div",{className:"w-12 h-12 rounded-2xl flex items-center justify-center flex-shrink-0",style:{background:`linear-gradient(135deg, ${$} 0%, #B8962E 100%)`,boxShadow:"0 4px 16px rgba(212,175,55,0.25)"},children:e.jsx(Ie,{size:24,style:{color:k}})}),e.jsxs("div",{children:[e.jsx("h3",{className:"font-display text-xl font-bold",style:{color:k},children:"Consumer Disclosures Hub"}),e.jsx("p",{className:"text-xs mt-0.5",style:{color:Dt},children:"Required federal & NACCAS consumer information â official institutional documents"})]})]}),e.jsx("span",{className:"self-start md:self-center px-3 py-1.5 rounded-full text-[10px] font-bold uppercase tracking-wider whitespace-nowrap",style:{background:"rgba(45,138,78,0.08)",color:"#2D6B3E",border:"1px solid rgba(45,138,78,0.18)"},children:"Audit-Ready · Tracked"})]}),e.jsxs("div",{className:"px-6 lg:px-10 pt-6 pb-2",children:[e.jsxs("div",{className:"relative max-w-xl",children:[e.jsx(Kt,{size:15,style:{color:$}
1203,className:"absolute left-3.5 top-1/2 -translate-y-1/2 pointer-events-none"}),e.jsx("input",{type:"text",value:x,onChange:f=>h(f.target.value),placeholder:"Search disclosures (e.g. SAP, R2T4, privacy, security report)â¦","aria-label":"Search consumer disclosures and policy documents",className:"w-full pl-10 pr-4 py-3 rounded-xl text-sm focus:outline-none transition-all duration-300",style:{background:"#FFFFFF",border:`1px solid ${fs}`,color:k},onFocus:f=>{f.target.style.borderColor=$,f.target.style.boxShadow="0 0 0 3px rgba(212,175,55,0.1)"},onBlur:f=>{f.target.style.borderColor=fs,f.target.style.boxShadow="none"}})]}),y&&e.jsx("div",{className:"mt-3 rounded-xl overflow-hidden",style:{border:`1px solid ${fs}`,background:"#FFFFFF"},children:v.length>0?v.map((f,j)=>e.jsxs("a",{href:f.href,onClick:()=>eu({policyKey:f.key,policyLabel:f.label,destinationUrl:f.href,source:"disclosures-search"}),className:"flex items-start gap-3 px-4 py-3 transition-colors duration-200 hover:bg-[rgba(212,175,55,0.06)]",style:{borderTop:j>0?`1px solid ${fs}`:"none"},children:[e.jsx(Kt,{size:15,style:{color:$},className:"mt-0.5 flex-shrink-0"}),e.jsxs("span",{children:[e.jsx("span",{className:"block text-sm font-semibold",style:{color:k},children:f.label}),e.jsx("span",{className:"block text-xs",style:{color:Dt},children:f.desc})]})]},f.key)):e.jsx("p",{className:"px-4 py-3 text-sm",style:{color:Dt},children:"No matching disclosures. Try âcatalogâ, âfinancial aidâ, âprivacyâ, or âsecurityâ."})})]}),e.jsx("div",{className:"grid lg:grid-cols-2 gap-0",children:[{key:"hub-school-catalog",label:"School Catalog & Admissions Policies",desc:"Programs, hours, tuition schedule, academic calendar, enrollment, transfer & re-entry policy",href:"/school-catalog",icon:e.jsx(Na,{size:20,style:{color:$}})},{key:"hub-naccas-disclosures",label:"NACCAS Disclosures",desc:"Accreditation, completion, placement & licensure rates",href:"/consumerinformation",icon:e.jsx(Kt,{size:20,style:{color:$}})}].map((f,j,S)=>e.jsxs("a",{href:f.href,onClick:()=>eu({policyKey:f.key,policyLabel:f.label,destinationUrl:f.href,source:"consumer-disclosures-hub"}),className:"group p-6 lg:p-8 transition-all duration-300 hover:bg-[rgba(212,175,55,0.04)]",style:{borderRight:j<S.length-1?`1px solid ${fs}`:"none"},children:[e.jsxs("div",{className:"flex items-center gap-3 mb-3",children:[e.jsx("div",{className:"w-11 h-11 rounded-xl flex items-center justify-center transition-transform duration-300 group-hover:scale-105",style:{background:"rgba(212,175,55,0.1)",border:"1px solid rgba(212,175,55,0.25)"},children:f.icon}),e.jsx("h4",{className:"text-base font-bold transition-colors duration-300 group-hover:text-[#B8962E]",style:{color:k},children:f.label})]}),e.jsx("p",{className:"text-xs leading-relaxed mb-4",style:{color:Dt},children:f.desc}),e.jsxs("span",{className:"inline-flex items-center gap-1.5 text-xs font-semibold transition-all duration-300 group-hover:translate-x-1",style:{color:$},children:["View Document ",e.jsx(tm,{size:12})]})]},f.key))})]})}),e.jsx("div",{className:"mt-12 pt-10",style:{borderTop:`1px solid ${fs}`},children:e.jsxs("div",{className:"grid md:grid-cols-3 gap-10",children:[e.jsxs("div",{children:[e.jsx("h4",{className:"text-sm font-bold uppercase tracking-wider mb-5",style:{color:k},children:"Campus Locations"}),e.jsx("ul",{className:"space-y-4",children:oA.map(f=>e.jsxs("li",{children:[e.jsxs("p",{className:"text-sm font-semibold flex items-center gap-2",style:{color:hn},children:[f.name.split("â")[0].trim()," Campus",f.badge&&e.jsx("span",{className:"text-[8px] font-bold uppercase tracking-wider px-1.5 py-0.5 rounded-full",style:{background:"rgba(212,175,55,0.1)",color:f.future?"#B8962E":"#9A7B1C",border:"1px solid rgba(212,175,55,0.2)"},children:f.badge})]}),e.jsx("p",{className:"text-xs mt-0.5 leading-relaxed",style:{color:Dt},children:f.address}),e.jsxs("div",{className:"flex items-center gap-3 mt-1",children:[e.jsx("a",{href:f.telHref,className:"text-xs font-medium transition-colors hover:text-[#D4AF37]",style:{color:hn},children:f.phone}),e.jsx("span",{style:{color:fs},children:"·"}),e.jsx("a",{href:`mailto:${f.email}`,className:"text-xs font-medium transition-colors hover:text-[#D4AF37] break-all",style:{color:hn},children:f.email})]})]},f.key))}),e.jsxs("div",{className:"mt-5 space-y-2",children:[e.jsx("p",{className:"text-[10px] font-bold uppercase tracking-wider",style:{color:"#9A7B1C"},children:"General Inquiries"}),e.jsxs("a",{href:`mailto:${In}`,className:"flex items-center gap-2 text-xs font-medium transition-all duration-300 hover:text-[#D4AF37]",style:{color:hn},children:[e.jsx(Ye,{size:13,style:{color:$}})," ",In]}),e.jsxs("a",{href:`tel:${Fx}`,className:"flex items-center gap-2 text-xs font-medium transition-all duration-300 hover:text-[#D4AF37]",style:{color:hn},children:[e.jsx(Qt,{size:13,style:{color:$}})," ",Fi]})]})]}),e.jsxs("div",{children:[e.jsx("h4",{className:"text-sm font-bold uppercase tracking-wider mb-5",style:{color:k},children:"Consumer Information & Disclosures"}),e.jsx("ul",{className:"space-y-3",children:[{key:"consumer-information",label:"Consumer Information",href:"/consumerinformation",external:!1},{key:"net-price-calculator",label:"Net Price Calculator",href:"/consumerinformation#net-price-calculator",external:!1}
1203,{key:"school-catalog-admissions",label:"School Catalog & Admissions Policy",href:"/school-catalog",external:!1}].map(f=>e.jsx("li",{children:e.jsxs("a",{href:f.href,...f.external?{target:"_blank",rel:"noopener noreferrer"}:{},onClick:()=>eu({policyKey:f.key,policyLabel:f.label,destinationUrl:f.href,source:"footer-consumer-info"}),className:"text-sm transition-all duration-300 hover:text-[#D4AF37] hover:translate-x-1 inline-flex items-center gap-1.5",style:{color:Dt},children:[f.label,f.external?e.jsx(Ua,{size:11,style:{color:$},className:"opacity-60"}):e.jsx(tm,{size:11,style:{color:$},className:"opacity-60"})]})},f.label))})]}),e.jsxs("div",{children:[e.jsx("h4",{className:"text-sm font-bold uppercase tracking-wider mb-5",style:{color:k},children:"Financial Aid & Institutional Policies"}),e.jsx("ul",{className:"space-y-3",children:[{key:"financial-aid-fafsa-grants",label:"Financial Aid & Scholarships",href:"/financial-aid"},{key:"sap-policy",label:"SAP (Satisfactory Academic Progress) Policy",href:"/consumerinformation"},{key:"r2t4-policy",label:"R2T4 (Return to Title IV) Policy",href:"/consumerinformation"},{key:"campus-safety-annual-security-report",label:"Campus Safety / Annual Security Report",href:"/annual-security-report"},{key:"privacy-my-health-my-data",label:"Privacy Policy & WA My Health My Data Act Compliance",href:"/privacy-policy"}].map(f=>e.jsx("li",{children:e.jsxs("a",{href:f.href,onClick:()=>eu({policyKey:f.key,policyLabel:f.label,destinationUrl:f.href,source:"footer-institutional-policies"}),className:"text-sm transition-all duration-300 hover:text-[#D4AF37] hover:translate-x-1 inline-flex items-center gap-1.5",style:{color:Dt},children:[f.label,e.jsx(tm,{size:11,style:{color:$},className:"opacity-60"})]})},f.label))})]})]})}),e.jsxs("div",{className:"mt-14 pt-8",style:{borderTop:`1px solid ${fs}`},children:[e.jsxs("div",{className:"flex flex-col lg:flex-row items-center justify-between gap-5",children:[e.jsxs("div",{className:"text-center lg:text-left",children:[e.jsx("p",{className:"text-xs",style:{color:hn},children:"© 2026 Zorganics Institute of Beauty & Wellness. All rights reserved."}),e.jsxs("p",{className:"text-[10px] mt-1",style:{color:Dt},children:[Z3()," · ",e.jsx("strong",{style:{color:hn},children:"Bellingham Campus:"})," 410 West Bakerview Rd, Ste 112, Bellingham, WA · ",Fi," · ",In]}),e.jsxs("p",{className:"text-[10px] mt-1.5 font-semibold inline-flex items-center gap-1.5",style:{color:hn},children:[e.jsx(Ie,{size:11,style:{color:$}}),"Content Last Updated: May 31, 2026"]})]}),e.jsx("div",{className:"flex items-center gap-6 flex-wrap justify-center",children:[{key:"footer-privacy-policy",label:"Privacy Policy",href:"/privacy-policy"},{key:"footer-ferpa-notice",label:"FERPA Notice",href:"/consumerinformation"},{key:"footer-consumer-disclosures",label:"Consumer Disclosures",href:"/consumerinformation"},{key:"footer-sitemap",label:"Site Map",href:"/sitemap"}].map(f=>e.jsx("a",{href:f.href,onClick:()=>eu({policyKey:f.key,policyLabel:f.label,destinationUrl:f.href,source:"footer-bottom-bar"}),className:"text-xs cursor-pointer transition-all duration-300 hover:text-[#D4AF37]",style:{color:Dt},children:f.label},f.key))}),e.jsxs("div",{className:"flex items-center gap-2 flex-wrap justify-center",children:[e.jsx("span",{className:"px-2.5 py-1.5 text-[10px] font-bold rounded-lg uppercase tracking-wider",style:{background:"rgba(45,138,78,0.08)",color:"#2D6B3E",border:"1px solid rgba(45,138,78,0.15)"},children:"NACCAS Accredited"}),e.jsx("span",{className:"px-2.5 py-1.5 text-[10px] font-bold rounded-lg uppercase tracking-wider",style:{background:"rgba(212,175,55,0.1)",color:"#9A7B1C",border:"1px solid rgba(212,175,55,0.2)"},children:"WA State Certified"}),e.jsx("span",{className:"px-2.5 py-1.5 text-[10px] font-bold rounded-lg uppercase tracking-wider",style:{background:"rgba(59,10,17,0.06)",color:hn,border:"1px solid rgba(59,10,17,0.1)"},children:"Bellingham Campus"}),e.jsx("span",{className:"px-2.5 py-1.5 text-[10px] font-bold rounded-lg uppercase tracking-wider",style:{background:"rgba(124,58,168,0.08)",color:"#6B3FA0",border:"1px solid rgba(124,58,168,0.15)"},children:"501(c)(3)"})]})]}),e.jsx("div",{className:"mt-8 pt-4",style:{borderTop:`1px solid ${fs}`},children:e.jsxs("p",{className:"text-[9px] text-center leading-relaxed",style:{color:"rgba(122,58,68,0.6)"},children:["GI Bill® is a registered trademark of the U.S. Department of Veterans Affairs (VA). More information about education benefits offered by VA is available at the official U.S. government website at"," ",e.jsx("a",{href:"https://www.benefits.va.gov/gibill",target:"_blank",rel:"noopener noreferrer",className:"underline hover:text-[#D4AF37] transition-colors",children:"www.benefits.va.gov/gibill"}),". Zorganics Institute is certified to accept GI Bill® benefits. NACCAS Accredited. WA State Department of Licensing Certified. Title IV Financial Aid Eligible. Zorganics Foundation is a registered 501(c)(3) nonprofit organization."]})}),e.jsx("div",{className:"mt-4 pt-4",style:{borderTop:`1px solid ${fs}`},children:e.jsx("p",{className:"text-[10px] text-center leading-relaxed font-medium",style:{color:hn},children:"The Institute maintains elite educational standards. Minimum satisfactory academic progress requires a 76% grade average and a 90% attendance record across all programs."})}),e.jsx("div",{className:"mt-4 pt-3",style:{borderTop:"1px solid rgba(232,221,208,0.5)"},children:e.jsx("p",{className:"text-[9px] text-center leading-relaxed",style:{color:"rgba(122,58,68,0.4)"},children:"Strategic Partnerships: Battelle Memorial Institute · Pacific N
1203orthwest National Laboratory · WA State Workforce Board"})}),e.jsxs("div",{className:"text-center mt-4",children:[e.jsxs("p",{className:"text-[10px] font-bold tracking-[0.2em] uppercase",style:{color:k},children:["Zorganics Institute of Beauty & Wellness ",e.jsx("span",{style:{color:$},children:"â"})," Institute Management Platform"]}),e.jsxs("p",{className:"text-[9px] uppercase tracking-[0.3em] font-bold mt-1",style:{color:"rgba(212,175,55,0.35)"},children:["Solutions & Prevention â ",WK()]})]})]})]}),e.jsxs("div",{className:"relative",style:{background:k},children:[e.jsx("div",{className:"h-[1.5px]",style:{background:`linear-gradient(90deg, rgba(212,175,55,0) 0%, ${$} 20%, ${Tv} 50%, ${$} 80%, rgba(212,175,55,0) 100%)`,boxShadow:"0 1px 6px rgba(212,175,55,0.25)"}}),e.jsx("div",{className:"max-w-[1600px] mx-auto px-4 lg:px-8 py-6",children:e.jsxs("div",{className:"flex flex-col lg:flex-row items-center justify-between gap-5",children:[e.jsxs("div",{className:"text-center lg:text-left",children:[e.jsxs("p",{className:"text-[11px] font-medium tracking-wide",style:{color:$},children:["Federal School Code: 043003 ",e.jsx("span",{style:{color:"rgba(212,175,55,0.5)"},children:"|"})," © 2026 Zorganics Institute. All Rights Reserved. Accredited by NACCAS."]}),e.jsxs("p",{className:"text-[9px] uppercase tracking-[0.18em] mt-1",style:{color:"rgba(212,175,55,0.55)"},children:[Z3()," · Vegan Clinical Elite Beauty School"]})]}),e.jsx("div",{className:"flex items-center gap-2.5 flex-wrap justify-center",children:["NACCAS Accredited","WA State DOL","Title IV / FSA","GI Bill® Approved","501(c)(3) Foundation"].map(f=>e.jsx("span",{className:"px-2.5 py-1 text-[9px] font-bold uppercase tracking-[0.12em] rounded-md transition-all duration-300",style:{background:"rgba(212,175,55,0.08)",color:$,border:"1px solid rgba(212,175,55,0.35)",boxShadow:"0 1px 4px rgba(0,0,0,0.15), inset 0 1px 0 rgba(212,175,55,0.08)"},children:f},f))}),e.jsxs("div",{className:"text-center lg:text-right",children:[e.jsx("p",{className:"text-[11px] font-bold uppercase tracking-[0.22em]",style:{color:$},children:"Bellingham Campus"}),e.jsx("p",{className:"text-[9px] uppercase tracking-[0.18em] mt-1",style:{color:"rgba(212,175,55,0.55)"},children:"Washington State · USA"})]})]})}),e.jsx("div",{className:"h-[1px]",style:{background:"linear-gradient(90deg, rgba(212,175,55,0) 0%, rgba(212,175,55,0.4) 50%, rgba(212,175,55,0) 100%)"}})]})]})},Hi={PrimaryPlum:"#3B0A11",AccentGold:"#D4AF37",ChampagneGold:"#E6D2A0",RichGold:"#B8962E",Burgundy:"#800020",Teal:"#0D9488",Violet:"#7C3AED"},NQ="https://d64gsuwffb70l.cloudfront.net/69cae7fb5ea7db794957149e_1775337912224_4cc82887.jfif",_Q=[{id:"cosmetology",label:"Cosmetology",shortLabel:"COS",hours:1600,hoursFormatted:"1,600h",programCode:"COS-1600",category:"cosmetology"},{id:"master-esthetics",label:"Master Esthetics",shortLabel:"MEST",hours:1200,hoursFormatted:"1,200h",programCode:"MEST-1200",category:"esthetics"},{id:"master-esthetics-bridge",label:"Master Esthetics Bridge",shortLabel:"MBRG",hours:450,hoursFormatted:"450h",programCode:"MBRG-450",category:"esthetics"},{id:"esthetics",label:"Esthetics",shortLabel:"EST",hours:750,hoursFormatted:"750h",programCode:"EST-750",category:"esthetics"},{id:"massage",label:"Massage Therapy",shortLabel:"MAS",hours:625,hoursFormatted:"625h",programCode:"MAS-625",category:"massage"},{id:"manicurist",label:"Manicurist",shortLabel:"MAN",hours:600,hoursFormatted:"600h",programCode:"MAN-600",category:"nails"},{id:"instructor",label:"Instructor Program",shortLabel:"INS",hours:600,hoursFormatted:"600h",programCode:"INS-600",category:"instructor"}];Object.fromEntries(_Q.map(t=>[t.id,`${t.label} (${t.hoursFormatted})`]));const qhe={portalUrl:"https://www.provexam.com",portalLaunchDate:"April 15, 2026",fees:{combined:288}},Whe={version:"2026-27",release:"Release 1.0",label:"EDExpress 2026â27 | Federal Aid Gateway",isirFields:["Student Aid Index (SAI)","Pell Grant Eligibility","Direct Loan Status","Expected Family Contribution (EFC)","Dependency Status","Enrollment Intensity","Cost of Attendance (COA)","Verification Status","FTIM Consent Flag","Unusual Enrollment History"],pellGrantUpdate:{expectedDate:"Late 2026",description:"Mandatory Pell Grant repackaging update per FAFSA Simplification Act"}},Jf={name:"Zorganics Institute of Beauty & Wellness",opeId:"042XXX",address:"410 West Bakerview Rd, Suite 112, Bellingham, WA 98226",phone:"(360) 392-8243",email:"[email protected]"};class qt extends d.Component{constructor(n){super(n);cp(this,"handleRefresh",()=>{this.setState({hasError:!1,error:null,errorInfo:null,errorId:null})});cp(this,"handleFullReload",()=>{window.location.reload()});this.state={hasError:!1,error:null,errorInfo:null,errorId:null}}static getDerivedStateFromError(n){return{hasError:!0,error:n}}componentDidCatch(n,a){const r=`ERR-${Date.now().toString(36).toUpperCase()}`;this.setState({errorInfo:a,errorId:r}),console.error(`[ZorganicsErrorBoundary] ${this.props.moduleName||"Unknown Module"}:`,n,a),this.logErrorToDatabase(n,a,r).catch(console.error)}async logErrorToDatabase(n,a,r){var i,o;try{await O.from("z_system_error_log").insert({error_id:r,module_name:this.props.moduleName||"Unknown",error_message:n.message,error_stack:(i=n.stack)==null?void 0:i.substring(0,2e3),component_stack:(o=a.componentStack)==null?void 0:o.substring(0,2e3),url:window.location.href,user_agent:navigator.userAgent,t
1203imestamp:new Date().toISOString()})}catch(l){console.warn("[ErrorBoundary] Failed to log error to database:",l)}}render(){if(this.state.hasError){const{moduleName:n,fallbackMessage:a}=this.props,{errorId:r}=this.state;return e.jsx("div",{className:"min-h-[400px] flex items-center justify-center p-8",children:e.jsxs("div",{className:"max-w-lg w-full text-center",children:[e.jsxs("div",{className:"mb-6 flex flex-col items-center",children:[e.jsx("div",{className:"w-16 h-16 rounded-2xl overflow-hidden shadow-lg mb-4 ring-2",style:{ringColor:Hi.AccentGold+"40"},children:e.jsx("img",{src:NQ,alt:"Zorganics",className:"w-full h-full object-cover"})}),e.jsx("div",{className:"w-12 h-12 rounded-full flex items-center justify-center mb-4",style:{backgroundColor:Hi.PrimaryPlum+"10"},children:e.jsx(Tt,{size:24,style:{color:Hi.AccentGold}})})]}),e.jsx("h2",{className:"font-display text-xl font-bold text-gray-900 mb-2",children:a||"The Zorganics System is currently performing a secure data sync."}),e.jsx("p",{className:"text-sm text-gray-500 mb-2",children:"Please refresh in a moment. Your data is safe and secure."}),n&&e.jsxs("p",{className:"text-xs text-gray-400 mb-1",children:["Module: ",e.jsx("span",{className:"font-semibold",style:{color:Hi.AccentGold},children:n})]}),r&&e.jsxs("p",{className:"text-[10px] font-mono text-gray-300 mb-6",children:["Reference: ",r]}),e.jsxs("div",{className:"flex items-center justify-center gap-3 mb-6",children:[e.jsxs("button",{onClick:this.handleRefresh,className:"flex items-center gap-2 px-5 py-2.5 rounded-xl text-sm font-semibold text-white shadow-md hover:shadow-lg transition-all hover:scale-105",style:{background:`linear-gradient(135deg, ${Hi.AccentGold}, ${Hi.RichGold})`},children:[e.jsx(Be,{size:16}),"Try Again"]}),e.jsxs("button",{onClick:this.handleFullReload,className:"flex items-center gap-2 px-5 py-2.5 rounded-xl text-sm font-semibold border border-gray-200 text-gray-600 hover:bg-gray-50 transition-all",children:[e.jsx(Be,{size:16}),"Full Reload"]})]}),e.jsxs("div",{className:"p-4 rounded-xl border border-gray-100 bg-gray-50/50 mb-4",children:[e.jsxs("div",{className:"flex items-center justify-center gap-2 mb-2",children:[e.jsx(ve,{size:14,style:{color:Hi.AccentGold}}),e.jsx("span",{className:"text-[10px] font-bold text-gray-500 uppercase tracking-wider",children:"Secure Recovery Protocol"})]}),e.jsx("p",{className:"text-[10px] text-gray-400 leading-relaxed",children:"This error has been automatically logged to the Executive Admin Dashboard for review by the Global LLC technical team. No student data has been compromised. All FERPA and HIPAA protections remain active."})]}),e.jsxs("div",{className:"flex items-center justify-center gap-4 text-[10px] text-gray-400",children:[e.jsxs("a",{href:`tel:${Jf.phone.replace(/[^\d+]/g,"")}`,className:"flex items-center gap-1 hover:text-gray-600 transition-colors",children:[e.jsx(Qt,{size:10,style:{color:Hi.AccentGold}}),Jf.phone]}),e.jsxs("a",{href:`mailto:${Jf.email}`,className:"flex items-center gap-1 hover:text-gray-600 transition-colors",children:[e.jsx(Ye,{size:10,style:{color:Hi.AccentGold}}),Jf.email]})]})]})})}return this.props.children}}const Hhe={cart:"cart",checkout:"checkout",product:"product",lightbox:"lightbox"},N0=new Set;let _0=0;const Y2=new Set,O5=()=>N0.size>0||_0>0,K2=()=>{const t=O5();Y2.forEach(s=>{try{s(t)}catch{}})},Ghe=(t,s)=>{const n=N0.has(t);s!==n&&(s?N0.add(t):N0.delete(t),K2())},Vhe=()=>{_0+=1,K2();let t=!1;return()=>{t||(t=!0,_0=Math.max(0,_0-1),K2())}},kQ=t=>(Y2.add(t),t(O5()),()=>{Y2.delete(t)}),zI=()=>{const[t,s]=d.useState(O5());return d.useEffect(()=>kQ(s),[]),t},Zhe=200,Xf="#2A0710",eg="#5A1A24",Pv="#FBF6E8",SQ="#F5EBD0",Dv="#E6D2A0",cA="#3B0A11",CQ={id:"welcome",role:"assistant",content:"Welcome to Zorganics Institute. I'm the Virtual Reception â I can help with admissions, scholarships, program details, campus tours, and oncology-safe esthetics. How may I assist you today?",ts:Date.now()},AQ=["Tell me about scholarships","Book a campus tour","Which programs are enrolling?","Speak to an advisor"],EQ=`You are the Zorganics Virtual Reception â a warm, professional, knowledgeable concierge for Zorganics Institute of Beauty and Wellness. 1204 1205The Institute is a ${UK()} elite vegan clinical beauty school founded by Master Educator Frida Emalange. The Bellingham, WA campus is the current ACTIVE campus. Renton is Coming Soon and Seattle is Coming 2027 â never describe Renton or Seattle as open, enrolling, or accepting appointments, and never state an address or opening date for them. 1206 1207 1208Programs offered: 1209- Cosmetology (1,600 hrs) â hybrid + campus 1210- Master Esthetics (1,200 hrs) â advanced clinical, UV fluorescence, laser, chemical peels, oncology-safe protocols 1211- Master Esthetics Bridge (450 hrs) 1212- Esthetics (750 hrs) 1213- Manicurist (600 hrs) 1214- Massage Therapy (625 hrs)
1215- Instructor Training (600 hrs) 1216 1217Key facts: 1218- NACCAS Accredited · WA DOL Certified · Title IV Eligible · GI Bill® Approved 1219- 501(c)(3) Zorganics Foundation offers $2,500 (HS Senior) and $1,000 (Professional) scholarships 1220- 100% vegan, cruelty-free botanical training 1221- Phone: (360) 392-8243 · Email: [email protected] 1222- Active campus: 410 West Bakerview Rd, Suite 112, Bellingham, WA 1223- Renton Campus â Coming Soon (no address or opening date has been announced) 1224- Seattle Campus â Coming 2027 (no address has been announced) 1225 1226 1227Tone: Warm, elegant, clinical-chic. Concise (2-4 sentences). Always offer a helpful next step (campus tour, admissions call, scholarship application). Never invent pricing â direct to admissions for tuition details.`,FQ=()=>{const[t,s]=d.useState(!1),[n,a]=d.useState([CQ]),[r,i]=d.useState(""),[o,l]=d.useState(!1),[c,u]=d.useState(0),p=d.useRef(null),m=zI();d.useEffect(()=>{p.current&&(p.current.scrollTop=p.current.scrollHeight)},[n,t]),d.useEffect(()=>{const v=setTimeout(()=>{!t&&n.length===1&&u(1)},12e3);return()=>clearTimeout(v)},[t,n.length]);const x=()=>{s(v=>!v),u(0)},h=async v=>{const g=v.trim();if(!g||o)return;const N={id:`u-${Date.now()}`,role:"user",content:g,ts:Date.now()};a(f=>[...f,N]),i(""),l(!0);const b=[{role:"system",content:EQ},...[...n,N].slice(-10).map(f=>({role:f.role==="assistant"?"assistant":"user",content:f.content}))];try{const{data:f,error:j}=await O.functions.invoke("zorganics-virtual-reception",{body:{messages:b}});let S="";j||!(f!=null&&f.reply)?S="I appreciate your message. Let me connect you with a human advisor â you can call Admissions directly at (360) 392-8243 or email [email protected]. In the meantime, would you like to explore our scholarships or book a campus tour?":S=f.reply;const w={id:`a-${Date.now()}`,role:"assistant",content:S,ts:Date.now()};a(_=>[..._,w])}catch{const j={id:`a-${Date.now()}`,role:"assistant",content:"Our reception is connecting you with a concierge. Please call (360) 392-8243 or email [email protected] and a Zorganics advisor will respond within one business day.",ts:Date.now()};a(S=>[...S,j])}finally{l(!1)}},y=v=>{v.preventDefault(),h(r)};return m?null:e.jsxs(e.Fragment,{children:[!t&&e.jsxs("button",{onClick:x,className:"fixed bottom-6 right-6 z-[90] group flex items-center gap-3 pl-4 pr-5 py-3.5 rounded-full shadow-2xl transition-all duration-300 hover:-translate-y-1 hover:shadow-[0_20px_50px_-10px_rgba(11,61,46,0.45)]",style:{background:`linear-gradient(135deg, ${Xf}, ${k})`,border:`1.5px solid ${$}55`,boxShadow:`0 10px 30px -5px rgba(11,61,46,0.35), 0 0 0 1px ${$}22`},"aria-label":"Open Zorganics Virtual Reception chat",children:[e.jsxs("div",{className:"relative w-10 h-10 rounded-full flex items-center justify-center shrink-0",style:{background:`linear-gradient(135deg, ${$}, #B8962E)`},children:[e.jsx(X_,{size:20,style:{color:Xf},strokeWidth:2.5}),c>0&&e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"absolute -top-0.5 -right-0.5 w-3 h-3 rounded-full animate-ping",style:{backgroundColor:"#EF4444"}}),e.jsx("span",{className:"absolute -top-0.5 -right-0.5 w-3 h-3 rounded-full",style:{backgroundColor:"#DC2626"}})]})]}),e.jsxs("div",{className:"text-left hidden sm:block",children:[e.jsx("p",{className:"text-[10px] font-bold uppercase tracking-[0.2em] leading-none",style:{color:Dv},children:"Zorganics"}),e.jsx("p",{className:"text-sm font-bold leading-tight text-white mt-0.5",children:"Virtual Reception"})]}),e.jsx(Qe,{size:14,style:{color:$},className:"hidden sm:block group-hover:rotate-12 transition-transform"})]}),t&&e.jsxs("div",{className:"fixed bottom-6 right-4 sm:right-6 z-[90] flex flex-col rounded-3xl overflow-hidden shadow-2xl",style:{width:"min(calc(100vw - 32px), 400px)",height:"min(calc(100vh - 100px), 620px)",background:"white",border:`1.5px solid ${k}20`,boxShadow:`0 25px 60px -10px rgba(11,61,46,0.35), 0 0 0 1px ${$}22`},role:"dialog","aria-label":"Zorganics Virtual Reception chat window",children:[e.jsxs("div",{className:"relative px-5 py-4 flex items-start justify-between",style:{background:`linear-gradient(135deg, ${Xf} 0%, ${k} 100%)`,borderBottom:`2px solid ${$}55`},children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsxs("div",{className:"w-11 h-11 rounded-xl flex items-center justify-center relative",style:{background:`linear-gradient(135deg, ${$}, #B8962E)`},children:[e.jsx(On,{size:20,style:{color:Xf},strokeWidth:2.5}),e.jsx("span",{className:"absolute -bottom-0.5 -right-0.5 w-3 h-3 rounded-full ring-2 ring-white",style:{backgroundColor:$}})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-[9px] font-bold uppercase tracking-[0.2em]",style:{color:Dv},children:"Zorganics Institute"}),e.jsx("h3",{className:"text-base font-bold text-white leading-tight",style:{fontFamily:"'Playfair Display', Georgia, serif"},children:"Virtual Reception"}),e.jsxs("p",{className:"text-[10px]",style:{color:"rgba(255,255,255,0.65)"},children:[e.jsx("span",{className:"inline-block w-1.5 h-1.5 rounded-full mr-1",style:{backgroundColor:$}}),"Online · typically replies instantly"]})]})]}),e.jsx("button",{onClick:x,className:"w-8 h-8 rounded-lg flex items-center justify-center transition-colors",style:{backgroundColor:"rgba(255,255,255,0.1)",color:Dv},onMouseEnter:v=>v.currentTarget.style.backgroundColor="rgba(255,255,255,0.2)",onMouseLeave:v=>v.currentTarget.style.backgroundColor="rgba(255,255,255,0.1)","aria-label":"Close chat",children:e.jsx(Ke,{size:16})})]}),e.jsxs("div",{ref:p,className:"flex-1 overflow-y-auto px-4 py-5 space-y-3",style:{background:`linear-gradient(180deg, ${Pv} 0%, white 100%)`},children:[n.map(v=>e.jsxs("div",{className:`flex ${v.role==="user"?"justify-end":"justify-start"}`,children:[v.role==="assistant"&&e.jsx("div",{className:"w-8 h-8 rounded-full flex items-center justify-center shrink-0 mr-2 mt-auto",style:{background:`linear-gradient(135deg, ${k}, ${eg})`},children:e.jsx(On,{size:14,style:{color:$}})}),e.jsx("div",{className:"max-w-[78%] px-4 py-2.5 rounded-2xl text-sm leading-relaxed",style:v.role==="user"?{background:`linear-gradient(135deg, ${k}, ${eg})`,color:"white",borderBottomRightRadius:"6px"}:{backgroundColor:"white",color:cA,border:`1px solid ${k}15`,borderBottomLeftRadius:"6px",boxShadow:`0 2px 8px ${k}08`},children:v.content})]},v.id)),o&&e.jsxs("div",{className:"flex justify-start",children:[e.jsx("div",{className:"w-8 h-8 rounded-full flex items-center justify-center shrink-0 mr-2",style:{background:`linear-gradient(135deg, ${k}, ${eg})`},children:e.jsx(On,{size:14,style:{color:$}})}),e.jsxs("div",{className:"px-4 py-3 rounded-2xl flex items-center gap-1.5",style:{backgroundColor:"white",border:`1px solid ${k}15`,borderBottomLeftRadius:"6px"},children:[e.jsx("span",{className:"w-1.5 h-1.5 rounded-full animate-bounce",style:{backgroundColor:k,animationDelay:"0ms"}}),e.jsx("span",{className:"w-1.5 h-1.5 rounded-full animate-bounce",style:{backgroundColor:k,animationDelay:"150ms"}}),e.jsx("span",{className:"w-1.5 h-1.5 rounded-full animate-bounce",style:{backgroundColor:k,animationDelay:"300ms"}})]})]}),n.length===1&&!o&&e.jsxs("div",{className:"pt-2 space-y-2",children:[e.jsx("p",{className:"text-[10px] font-bold uppercase tracking-[0.15em] text-center",style:{color:k},children:"Suggested Questions"}),AQ.map(v=>e.jsxs("button",{onClick:()=>h(v),className:"w-full px-3.5 py-2.5 rounded-xl text-xs font-semibold text-left transition-all hover:shadow-md hover:-translate-y-0.5",style:{backgroundColor:"white",color:k,border:`1px solid ${k}20`},children:["â ",v]},v))]})]}),e.jsxs("div",{className:"px-4 py-2 flex items-center justify-center gap-4",style:{backgroundColor:SQ,borderTop:`1px solid ${k}10`},children:[e.jsxs("a",{href:"tel:+13603928243",className:"flex items-center gap-1.5 text-[10px] font-bold uppercase tracking-wider transition-colors hover:opacity-70",style:{color:k},children:[e.jsx(Qt,{size:10})," (360) 392-8243"]}),e.jsx("span",{className:"w-1 h-1 rounded-full",style:{backgroundColor:k,opacity:.3}}),e.jsxs("a",{href:"mailto:[email protected]",className:"flex items-center gap-1.5 text-[10px] font-bold uppercase tracking-wider transition-colors hover:opacity-70",style:{color:k},children:[e.jsx(Ye,{size:10})," Email"]})]}),e.jsxs("form",{onSubmit:y,className:"px-3 py-3 flex items-center gap-2",style:{backgroundColor:"white",borderTop:`1px solid ${k}15`},children:[e.jsx("input",{type:"text",value:r,onChange:v=>i(v.target.value),placeholder:"Ask about programs, scholarships, or tours...",disabled:o,className:"flex-1 px-4 py-2.5 text-sm rounded-full focus:outline-none transition-all disabled:opacity-50",style:{backgroundColor:Pv,border:`1.5px solid ${k}15`,color:cA},onFocus:v=>{v.currentTarget.style.borderColor=k,v.currentTarget.style.backgroundColor="white"},onBlur:v=>{v.currentTarget.style.borderColor=`${k}15`,v.currentTarget.style.backgroundColor=Pv}}),e.jsx("button",{type:"submit",disabled:!r.trim()||o,className:"w-10 h-10 rounded-full flex items-center justify-center shrink-0 transition-all hover:shadow-lg disabled:opacity-40 disabled:cursor-not-allowed",style:{background:`linear-gradient(135deg, ${k}, ${eg})`,color:"white"},"aria-label":"Send message",children:o?e.jsx(de,{size:16,className:"animate-spin"}):e.jsx(Hs,{size:15})})]})]})]})},dA="#2A060C",TQ="#E6D2A0",uA=()=>
1227{const[t,s]=d.useState(!1),[n,a]=d.useState(!1),r=zI();d.useEffect(()=>{const o=()=>{s(window.scrollY>600)};return o(),window.addEventListener("scroll",o,{passive:!0}),()=>window.removeEventListener("scroll",o)},[]);const i=()=>{window.scrollTo({top:0,behavior:"smooth"})};return r?null:e.jsxs("button",{type:"button",onClick:i,onMouseEnter:()=>a(!0),onMouseLeave:()=>a(!1),onFocus:()=>a(!0),onBlur:()=>a(!1),"aria-label":"Back to top",title:"Back to top",className:"fixed bottom-24 right-6 z-50 flex items-center justify-center rounded-full focus:outline-none focus-visible:ring-2 focus-visible:ring-offset-2",style:{width:"44px",height:"44px",backgroundColor:n?$:k,border:`1px solid ${n?TQ:$}`,color:n?dA:$,boxShadow:n?"0 0 0 3px rgba(212,175,55,0.18), 0 8px 22px rgba(212,175,55,0.45), 0 2px 6px rgba(59,10,17,0.35)":"0 4px 14px rgba(59,10,17,0.35), 0 0 0 1px rgba(212,175,55,0.18)",opacity:t?1:0,transform:t?n?"translateY(-2px) scale(1.05)":"translateY(0) scale(1)":"translateY(12px) scale(0.92)",pointerEvents:t?"auto":"none",transition:"opacity 280ms ease, transform 280ms cubic-bezier(0.22, 1, 0.36, 1), background-color 220ms ease, color 220ms ease, box-shadow 220ms ease, border-color 220ms ease",cursor:"pointer"},children:[e.jsx(Od,{size:20,strokeWidth:2.25,style:{color:n?dA:$,transition:"color 220ms ease, transform 220ms ease",transform:n?"translateY(-1px)":"translateY(0)"}}),e.jsx("span",{className:"sr-only",children:"Back to top"})]})},mA="zorganics_cookie_consent_v1",PQ="#FAF6EE",xn="#D4AF37",DQ="#E6D2A0",ia="#3B0A11",li="#2A060C",pA=()=>{const[t,s]=d.useState(!1),[n,a]=d.useState(!1),[r,i]=d.useState(!1),[o,l]=d.useState({essential:!0,analytics:!0,marketing:!1});d.useEffect(()=>{try{if(!localStorage.getItem(mA)){const y=setTimeout(()=>{s(!0),requestAnimationFrame(()=>a(!0))},600);return()=>clearTimeout(y)}}catch{}},[]);const c=h=>{try{const y={level:h,timestamp:new Date().toISOString(),version:"v1"};localStorage.setItem(mA,JSON.stringify(y))}catch{}},u=()=>{a(!1),setTimeout(()=>s(!1),320)},p=()=>{c("all"),u()},m=()=>{c("essential"),u()},x=()=>{c(o.analytics||o.marketing?"all":"essential"),u()};return t?e.jsx("div",{role:"dialog","aria-modal":"false","aria-labelledby":"cookie-consent-title","aria-describedby":"cookie-consent-message",className:"fixed z-[60] left-4 right-4 sm:left-6 sm:right-auto",style:{bottom:"7rem",maxWidth:"640px",transform:n?"translateY(0)":"translateY(140%)",opacity:n?1:0,transition:"transform 360ms cubic-bezier(0.22, 1, 0.36, 1), opacity 320ms ease",willChange:"transform, opacity"},children:e.jsxs("div",{style:{backgroundColor:PQ,color:li,borderRadius:"14px",borderTop:`1.5px solid ${xn}`,boxShadow:"0 -2px 0 rgba(212, 175, 55, 0.18), 0 18px 40px -10px rgba(59, 10, 17, 0.35), 0 6px 16px -6px rgba(59, 10, 17, 0.2)",overflow:"hidden",fontFamily:"'Inter', system-ui, sans-serif"},children:[e.jsx("div",{"aria-hidden":!0,style:{height:"1px",background:`linear-gradient(90deg, transparent, ${xn} 20%, ${DQ} 50%, ${xn} 80%, transparent)`,boxShadow:"0 0 8px rgba(212, 175, 55, 0.4)"}}),e.jsx("div",{className:"px-5 py-4 sm:px-6 sm:py-5",children:e.jsxs("div",{className:"flex items-start gap-4",children:[e.jsx("div",{className:"hidden sm:flex shrink-0 items-center justify-center","aria-hidden":!0,style:{width:"44px",height:"44px",borderRadius:"50%",backgroundColor:ia,border:`1px solid ${xn}`,boxShadow:"0 0 0 3px rgba(212, 175, 55, 0.12)"},children:e.jsx(kO,{size:20,style:{color:xn}})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center justify-between gap-3 mb-1.5",children:[e.jsx("h2",{id:"cookie-consent-title",style:{fontFamily:"'Playfair Display', Georgia, serif",fontSize:"15px",fontWeight:700,color:li,letterSpacing:"0.01em",margin:0},children:"Privacy & Cookie Notice"}),e.jsx("button",{onClick:m,"aria-label":"Dismiss â essential cookies only",className:"shrink-0 -mr-1 rounded-full p-1.5 transition-colors",style:{color:"rgba(42, 6, 12, 0.45)"},onMouseEnter:h=>{h.currentTarget.style.color=ia,h.currentTarget.style.backgroundColor="rgba(212, 175, 55, 0.12)"},onMouseLeave:h=>{h.currentTarget.style.color="rgba(42, 6, 12, 0.45)",h.currentTarget.style.backgroundColor="transparent"},children:e.jsx(Ke,{size:16})})]}),e.jsxs("p",{id:"cookie-consent-message",style:{fontSize:"12.5px",lineHeight:1.55,color:"rgba(42, 6, 12, 0.78)",margin:0},children:["Zorganics Institute uses essential cookies to operate the Student Information System and optional cookies to improve your experience. We comply with"," ",e.jsx("span",{style:{fontWeight:600,color:li},children:"FERPA"})," ","for educational records and"," ",e.jsx("span",{style:{fontWeight:600,color:li},children:"GDPR"})," ","for visitors from the EU/EEA. Student PII is never sold or shared with third-party advertisers."]}),r&&e.jsx("div",{className:"mt-3 rounded-lg p-3",style:{backgroundColor:"rgba(212, 175, 55, 0.08)",border:"1px solid rgba(212, 175, 55, 0.28)"},children:e.jsxs("div",{className:"space-y-2",children:[e.jsxs("label",{className:"flex items-start gap-2.5 cursor-not-allowed",style:{opacity:.85},children:[e.jsx("input",{type:"checkbox",checked:!0,disabled:!0,className:"mt-0.5",style:{accentColor:ia}}),e.jsxs("div",{className:"flex-1",children:[e.jsxs("div",{className:"flex items-center gap-1.5",style:{fontSize:"11.5px",fontWeight:700,color:li},children:[e.jsx(Ie,{size:12,style:{color:ia}}),"Strictly Necessary",e.jsx("span",{style:{fontSize:"9.5px",fontWeight:600,color:xn,letterSpacing:"0.08em",textTransform:"uppercase"},children:"· Always On"})]}),e.jsx("div",{style:{fontSize:"10.5px",color:"rgba(42, 6, 12, 0.65)",marginTop:"1px"},children:"Authentication, security, and session management"})]})]}),e.jsxs("label",{className:"flex items-start gap-2.5 cursor-pointer",children:[e.jsx("input",{type:"checkbox",checked:o.analytics,onChange:h=>l(y=>({...y,analytics:h.target.checked})),className:"mt-0.5",style:{accentColor:ia}}),e.jsxs("div",{className:"flex-1",children:[e.jsx("div",{style:{fontSize:"11.5px",fontWeight:700,color:li},children:"Analytics"}),e.jsx("div",{style:{fontSize:"10.5px",color:"rgba(42, 6, 12, 0.65)",marginTop:"1px"},children:"Anonymous usage insights (GA4, Search Console)"})]})]}),e.jsxs("label",{className:"flex items-start gap-2.5 cursor-pointer",children:[e.jsx("input",{type:"checkbox",checked:o.marketing,onChange:h=>l(y=>({...y,marketing:h.target.checked})),className:"mt-0.5",style:{accentColor:ia}}),e.jsxs("div",{className:"flex-1",children:[e.jsx("div",{style:{fontSize:"11.5px",fontWeight:700,color:li},children:"Marketing & Retargeting"}),e.jsx("div",{style:{fontSize:"10.5px",color:"rgba(42, 6, 12, 0.65)",marginTop:"1px"},children:"Conversion tracking and campaign optimization"})]})]})]})}),e.jsxs("div",{className:"mt-4 flex flex-col sm:flex-row gap-2.5",children:[r?e.jsx("button",{onClick:x,className:"prestige-btn flex-1 sm:flex-none inline-flex items-center justify-center gap-2 px-5 py-2.5 rounded-full transition-all duration-300",style:{backgroundColor:ia,color:xn,border:`1px solid ${xn}`,fontSize:"11.5px",fontWeight:700,letterSpacing:"0.08em",textTransform:"uppercase",fontFamily:"'Inter', system-ui, sans-serif"},onMouseEnter:h=>{h.currentTarget.style.backgroundColor=xn,h.currentTarget.style.color=li,h.currentTarget.style.boxShadow="0 0 0 3px rgba(212, 175, 55, 0.28), 0 6px 16px -4px rgba(212, 175, 55, 0.4)",h.currentTarget.style.transform="translateY(-1px)"},onMouseLeave:h=>{h.currentTarget.style.backgroundColor=ia,h.currentTarget.style.color=xn,h.currentTarget.style.boxShadow="none",h.currentTarget.style.transform="translateY(0)"},children:"Save Preferences"}):e.jsx("button",{onClick:p,className:"prestige-btn flex-1 sm:flex-none inline-flex items-center justify-center gap-2 px-5 py-2.5 rounded-full transition-all duration-300",style:{backgroundColor:ia,color:xn,border:`1px solid ${xn}`,fontSize:"11.5px",fontWeight:700,letterSpacing:"0.08em",textTransform:"uppercase",fontFamily:"'Inter', system-ui, sans-serif"},onMouseEnter:h=>{h.currentTarget.style.backgroundColor=xn,h.currentTarget.style.color=li,h.currentTarget.style.boxShadow="0 0 0 3px rgba(212, 175, 55, 0.28), 0 6px 16px -4px rgba(212, 175, 55, 0.4)",h.currentTarget.style.transform="translateY(-1px)"},onMouseLeave:h=>{h.currentTarget.style.backgroundColor=ia,h.currentTarget.style.color=xn,h.currentTarget.style.boxShadow="none",h.currentTarget.style.transform="translateY(0)"},children:"Accept All"}),e.jsxs("button",{onClick:()=>i(h=>!h),className:"flex-1 sm:flex-none inline-flex items-center justify-center gap-2 px-5 py-2.5 rounded-full transition-all duration-300",style:{backgroundColor:"transparent",color:ia,border:`1px solid ${ia}`,fontSize:"11.5px",fontWeight:700,letterSpacing:"0.08em",textTransform:"uppercase",fontFamily:"'Inter', system-ui, sans-serif"},onMouseEnter:h=>{h.currentTarget.style.backgroundColor=xn,h.currentTarget.style.color=li,h.currentTarget.style.borderColor=xn,h.currentTarget.style.boxShadow="0 0 0 3px rgba(212, 175, 55, 0.28), 0 6px 16px -4px rgba(212, 175, 55, 0.4)",h.currentTarget.style.transform="translateY(-1px)"},onMouseLeave:h=>{h.currentTarget.style.backgroundColor="transparent",h.currentTarget.style.color=ia,h.currentTarget.style.borderColor=ia,h.currentTarget.style.boxShadow="none",h.currentTarget.style.transform="translateY(0)"},children:[e.jsx(YP,{size:13}),r?"Hide Preferences":"Manage Preferences"]})]}),e.jsxs("div",{className:"mt-3 flex items-center gap-1.5",style:{fontSize:"9.5px",fontWeight:600,color:"rgba(42, 6, 12, 0.5)",letterSpacing:"0.1em",textTransform:"uppercase"},children:[e.jsx(Ie,{size:10,style:{color:xn}}),"FERPA · GDPR · CCPA Compliant"]})]})]})})]})}):null},RQ=()=>{const{activeSection:t,setActiveSection:s,setShowHero:n}=dc(),a=RY(t);if(!a)return null;const r=()=>{s("campus-home"),n(!0),window.scrollTo({top:0})},i=o=>{s(o),n(!1),window.scrollTo({top:0})};return e.jsx("nav",{"aria-label":"Breadcrumb",className:"overflow-x-auto",style:{borderBottom:"1px solid rgba(212,175,55,0.18)"},children:e.jsxs("ol",{className:"flex items-center gap-1 py-2.5 whitespace-nowrap text-[11px]",children:[e.jsx("li",{children:e.jsxs("button",{onClick:r,className:"flex items-center gap-1 font-semibold transition-colors hover:text-[#D4AF37]",style:{color:"#800020"},title:"Zorganics Institute â Home",children:[e.jsx(K_,{size:12}),e.jsx("span",{className:"hidden sm:inline",children:"Home"})]})}),a.map((o,l)=>{const c=l===a.length-1;return e.jsxs("li",{className:"flex items-center gap-1",children:[e.jsx(Nr,{size:11,style:{color:"rgba(184,150,46,0.6)"},"aria-hidden":"true"}),c||!o.section?e.jsx("span",{className:"font-bold",style:{color:c?"#3B0A11":"#7A3A44"},"aria-current":c?"page":void 0,children:o.label}):e.jsx("button",{onClick:()=>i(o.section),className:"font-semibold transition-colors hover:text-[#D4AF37]",style:{color:"#800020"},children:o.label})]},`${o.label}-${l}`)})]})})},IQ=({label:t="Loading",onRetry:s,warnAfterMs:n=8e3,stuckAfterMs:a=18e3,color:r="#D4AF37",className:i=""})=>{const[o,l]=d.useState("spinning");d.useEffect(()=>{const p=Math.max(0,n),m=Math.max(p+1,a),x=setTimeout(()=>{l(y=>y==="spinning"?"slow":y)},p),h=setTimeout(()=>{l("stuck")},m);return()=>{clearTimeout(x),clearTimeout(h)}},[n,a]);const c=o==="stuck"?"#DC2626":o==="slow"?"#D97706":r,u=()=>{if(s){l("spinning");try{s()}catch{typeof window<"u"&&window.location.reload()}return}typeof window<"u"&&window.location.reload()};return e.jsx("div",{className:`flex items-center justify-center py-24 ${i}`,children:e.jsxs("div",{className:"flex flex-col items-center gap-3 max-w-sm text-center",children:[e.jsx(de,{size:28,className:"animate-spin",style:{color:c}}),e.jsx("p",{className:"text-xs font-semibold uppercase tracking-wider",style:{color:o==="stuck"?"#DC2626":"#9
1227CA3AF"},children:t}),o==="slow"&&e.jsx("p",{className:"text-[11px] text-amber-700 max-w-xs leading-snug",children:"This is taking longer than usual. Hang tight while we keep tryingâ¦"}),o==="stuck"&&e.jsxs("div",{className:"flex flex-col items-center gap-2 mt-1 px-4 py-3 rounded-lg bg-red-50 border border-red-200",children:[e.jsxs("div",{className:"flex items-center gap-2 text-red-800",children:[e.jsx(ve,{size:14,className:"flex-shrink-0"}),e.jsx("p",{className:"text-[11px] font-bold uppercase tracking-wider",children:"Spinner Stuck"})]}),e.jsxs("p",{className:"text-[11px] text-red-700 leading-snug",children:["Still loading after ",Math.round(a/1e3),"s. A network request may be hung. Try retrying or reload the page."]}),e.jsxs("button",{type:"button",onClick:u,className:"mt-1 flex items-center gap-1.5 px-3 py-1.5 rounded-md text-[11px] font-semibold text-white bg-red-600 hover:bg-red-700 transition-colors",children:[e.jsx(Be,{size:11}),s?"Retry":"Reload page"]})]})]})})},wr={title:"Bellingham Beauty School | Zorganics Institute",description:"Explore NACCAS-accredited Esthetician, Master Esthetician, Cosmetology and Manicurist programs in Bellingham. Financial aid is available to those who qualify. Schedule a tour."};function $Q(t){let s=document.querySelector('meta[name="description"]');s||(s=document.createElement("meta"),s.name="description",document.head.appendChild(s)),s.content=t}function Jl(t){if(typeof document>"u"||!t)return;let s=document.querySelector('link[rel="canonical"]');s||(s=document.createElement("link"),s.rel="canonical",document.head.appendChild(s)),s.href=t}function qa(t){document.title=t.title,t.description&&$Q(t.description)}function Ho(t){d.useEffect(()=>{if(t)return qa(t),()=>qa(wr)},[t==null?void 0:t.title,t==null?void 0:t.description])}const LI={"campus-home":wr,"our-story":{title:"Our Story | Zorganics Institute â Bellingham WA",description:"The history and organizational philosophy of the Zorganics ecosystem â founded by Master Esthetician & Cosmetologist Frida Emalange."},ecosystem:{title:"The Zorganics Ecosystem | Institute, Cosmetics, Salon, Med Spa & Foundation",description:"Explore every brand in the Zorganics family â the Institute, Zorganics Cosmetics, Zora's Styling Salon, the Med Spa, and the Zorganics Foundation."},"program-profiles":{title:"Programs â Cosmetologist, Esthetician, Master Esthetician, Manicurist & Instructor | Zorganics Institute",description:"Licensed program profiles at Zorganics Institute: Cosmetologist (1,600 hrs), Esthetician (750 hrs), Master Esthetician (1,200 hrs), Master Esthetician 450 Bridge, Manicurist (600 hrs) and Instructor Program â hours, curriculum, outcomes and tuition."},"master-esthetics-1200":{title:"Master Esthetician Program (1,200 Hours) | Zorganics Institute â Bellingham WA",description:"Advanced clinical training in the Master Esthetician program â laser modalities, chemical peels, microneedling and medical-spa readiness at a NACCAS-accredited Washington school."},"master-bridge":{title:"Master Esthetician 450 Bridge Program | Zorganics Institute â Bellingham WA",description:"The Master Esthetician 450 Bridge â an accelerated 450-hour pathway for licensed Estheticians upgrading to Master Esthetician licensure in Washington State."},"program-detail":{title:"Program Details | Zorganics Institute â Bellingham WA",description:"Detailed curriculum, clock hours, outcomes and tuition for Zorganics Institute licensed programs."},admissions:{title:"Admissions | Zorganics Institute â Enrollment Requirements & Start Dates",description:"Admissions at Zorganics Institute â enrollment requirements, start dates and the full licensed program portfolio. Financial aid available for those who qualify."},"apply-now":{title:"Apply Now | Zorganics Institute of Beauty & Wellness",description:"Apply to Zorganics Institute of Beauty & Wellness in Bellingham, Washington. Explore career training in cosmetology, esthetics, master esthetics, manicuring, and instructor training."},"tour-booking":{title:"Schedule a Tour | Zorganics Institute â Bellingham WA",description:"Book a campus tour of Zorganics Institute in Bellingham, Washington â live availability, instant email confirmation and automatic reminders before your visit."},"salon-services":{title:"Zora's Styling Salon & Spa â Professional Services | Bellingham WA",description:"Professional salon & spa services at Zora's Styling Salon â hair, skin and body rituals performed by licensed professionals using 100% vegan, non-toxic Zorganics botanicals. Consultation-first booking."},"student-clinic":{title:"Student Salon & Clinic â Supervised Student Services | Zorganics Institute",description:"Supervised Student Salon & Clinic services at student pricing â haircuts, facials, manicures, pedicures and waxing performed by Zorganics Institute students under licensed-instructor supervision. Thursdays & Fridays."}
1227,"zoras-salon":{title:"Zora's Styling Salon | Professional Organic Salon â Bellingham WA",description:"Zora's Styling Salon â full-service professional organic salon: styling, color, balayage, nails, facials and bridal services in Bellingham WA."},"med-spa-portal":{title:"Zorganics Med Spa | IPL Photofacial, Laser & RF Skin Tightening â Bellingham WA",description:"Clinical med spa treatments by licensed master estheticians â IPL photofacial, laser treatments, RF skin tightening, chemical peels and complimentary consultations."},"professional-services":{title:"Service Menu & Pricing | Zora's Salon & Zorganics Med Spa",description:"The complete professional services menu with pricing across Zora's Styling Salon and the Zorganics Med Spa."},shop:{title:"Shop Vegan Organic Skin Care, Hair Care & Mineral Makeup | Zorganics Cosmetics",description:"Zorganics Cosmetics â 100% vegan, certified-organic, non-toxic clinical beauty: Malouwa⢠hydration skincare, Zemaja⢠ocean minerals, Linamissa⢠hair care, body care and mineral makeup."},wholesale:{title:"Wholesale & Professional Accounts | Zorganics Cosmetics â Salon & Spa Partners",description:"Zorganics Cosmetics wholesale for salons, spas and licensed professionals â open a professional account for vegan, certified-organic, non-toxic skin care, hair care, body care and mineral makeup at partner pricing."},"pure-benefit-rewards":{title:"PUREBenefit⢠Rewards | Zorganics Cosmetics Loyalty Program",description:"Join PUREBenefit⢠Rewards â earn points on every Zorganics Cosmetics purchase and redeem for luxury clean-beauty products."},"foundation-landing":{title:"The Zorganics Foundation | 501(c)(3) â Scholarships & Oncology Esthetics",description:"The Zorganics Foundation is a 501(c)(3) public charity funding beauty-education scholarships, oncology esthetics and beauty with purpose."},foundation:{title:"Our Mission | The Zorganics Foundation",description:"Foundation programs, community impact, oncology esthetics initiatives and the research garden."},"foundation-donate":{title:"Donate | The Zorganics Foundation â Tax-Deductible Giving",description:"Support the Zorganics Foundation with a tax-deductible one-time or recurring gift â every dollar funds scholarships and oncology esthetics care."},"foundation-gift-shop":{title:"Foundation Gift Shop | The Zorganics Foundation",description:"Shop the Foundation collection â every purchase funds beauty-education scholarships."},"gala-fundraiser":{title:"Annual Industry Gala & Fundraiser | The Zorganics Foundation",description:"The Beauty With Purpose gala and Zorganics Foundation fundraising events â tickets, sponsorships and impact."},"village-map":{title:"Vertical Village Campus Map | Zorganics Institute â Bellingham WA",description:"Explore the Zorganics Vertical Village â training studios, clinic suites, student housing and the Z-Bistro café."},housing:{title:"Student Housing | Zorganics Institute â Bellingham WA",description:"On-campus student housing options for enrolled Zorganics Institute students."},hospitality:{title:"Z-Bistro & Café | Zorganics Vertical Village â Bellingham WA",description:"The Zorganics campus bistro â menu, smoothies and café hours in the Vertical Village."},"contact-us":{title:"Contact Us | Zorganics Institute â Bellingham, WA",description:"Contact Zorganics Institute â phone, email, campus address and inquiry form. Bellingham Campus (active) · Renton Coming Soon · Seattle Coming 2027."},"employer-onboarding":{title:"Employers & Industry Partners | Zorganics Institute",description:"Register your salon or spa as a Zorganics industry partner â post jobs and connect with licensed graduates."}};function OI(t){return LI[t]||wr}function zQ(t){d.useEffect(()=>{qa(OI(t))},[t])}function sn(){d.useEffect(()=>{if(typeof document>"u")return;const t=document.querySelector('meta[name="robots"]'),s=(t==null?void 0:t.content)??null;let n=t;return n||(n=document.createElement("meta"),n.name="robots",document.head.appendChild(n)),n.content="noindex, nofollow",()=>{n&&(s!==null?n.content=s:n.remove())}},[])}const LQ=["dashboard","lms","instructor-lms","audit","quiz-engine","financial","financial-silo","exec-financial","edexpress","agency","staff","google","pos","z-cpa","sis-dashboard","gradebook","grading-portal","guardian-portal","student-portal","student-progress","student-profile","zlp-portal","zip-portal","partner-portal","employer-workspace","campus-ops","doc-verification","reviewer-access","compliance","compliance-lockdown","rgm-compliance","sap-engine","chain-of-custody","regulatory-reporting","federal-compliance","clinical-safety","dol-hour-relay","loa-management","career-bridge","escalation-governance","sovereign-os","ai-scan-portal","md-referral","supply-chain","wix-sync","wix-studio-export","wholesale-tracker","wholesale-admin","wholesale-partner-portal","wholesale-fulfillment","ceu-training","franchise","location-mgmt","google-meta-sync","robots-txt-generator","ga4-integration","gsc-integration","ahrefs-backlinks","retargeting-conversion","ab-testing"],OQ=["events","bistro-menu","premium-landing","master-esthetics-1200"],MQ=new Set(LQ),B
1227Q=new Set([...Object.keys(LI),...OQ]);function UQ(t){return t?MQ.has(t)?"noindex, nofollow":BQ.has(t)?null:"noindex, nofollow":null}function qQ(t){d.useEffect(()=>{if(typeof document>"u")return;const s=UQ(t);let n=document.querySelector('meta[name="robots"][data-section-robots="true"]');if(!s){n==null||n.remove();return}n||(n=document.createElement("meta"),n.name="robots",n.setAttribute("data-section-robots","true"),document.head.appendChild(n)),n.content=s},[t])}const hA=()=>(sn(),null),lr=({children:t,requiredRoles:s,fallback:n,inline:a=!1,redirectTo:r})=>{const{isAuthenticated:i,hasRole:o,user:l,loading:c}=kn(),[u,p]=d.useState(!1),m=Za(),x=ai();return d.useEffect(()=>{r&&!c&&!i&&m(r,{replace:!0,state:{from:x.pathname+x.search}})},[r,c,i,m,x]),r&&c?e.jsxs("div",{className:"min-h-[60vh] flex items-center justify-center",children:[e.jsx(hA,{}),e.jsxs("div",{className:"flex flex-col items-center gap-3 text-gray-400",children:[e.jsx(de,{size:22,className:"animate-spin text-burgundy"}),e.jsx("p",{className:"text-xs uppercase tracking-wider",children:"Verifying sessionâ¦"})]})]}):i?s&&!o(s)?a?e.jsxs("div",{className:"flex items-center gap-2 px-4 py-2.5 bg-red-50 border border-red-200 rounded-lg text-sm text-red-600",children:[e.jsx(Tt,{size:14}),e.jsxs("span",{className:"font-medium",children:[(l==null?void 0:l.role)==="instructor"?"Instructor":"Staff"," access â this action requires ",s.join(" or ")," role"]})]}):n?e.jsx(e.Fragment,{children:n}):e.jsxs("div",{className:"flex flex-col items-center justify-center py-12 px-4",children:[e.jsx("div",{className:"w-16 h-16 rounded-2xl bg-red-50 flex items-center justify-center mb-4",children:e.jsx(Tt,{size:28,className:"text-red-400"})}),e.jsx("h3",{className:"font-display text-lg font-bold text-gray-900 mb-1",children:"Access Restricted"}),e.jsxs("p",{className:"text-sm text-gray-500 text-center max-w-sm mb-2",children:["Your role (",l==null?void 0:l.role,") does not have permission to access this section."]}),e.jsxs("p",{className:"text-xs text-gray-400",children:["Required: ",s.join(", ")]})]}):e.jsx(e.Fragment,{children:t}):r?e.jsxs("div",{className:"min-h-[60vh] flex items-center justify-center",children:[e.jsx(hA,{}),e.jsxs("div",{className:"flex flex-col items-center gap-3 text-gray-400",children:[e.jsx(de,{size:22,className:"animate-spin text-burgundy"}),e.jsx("p",{className:"text-xs uppercase tracking-wider",children:"Redirecting to sign-inâ¦"})]})]}):a?e.jsxs(e.Fragment,{children:[e.jsxs("button",{onClick:()=>p(!0),className:"flex items-center gap-2 px-4 py-2.5 bg-gray-100 border border-gray-200 rounded-lg text-sm font-medium text-gray-500 hover:bg-gray-50 hover:border-gold/50 hover:text-gold-dark transition-all group",children:[e.jsx(Xe,{size:14,className:"text-gray-400 group-hover:text-gold"}),"Sign in to continue"]}),e.jsx(Ex,{isOpen:u,onClose:()=>p(!1)})]}):n?e.jsx(e.Fragment,{children:n}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex flex-col items-center justify-center py-12 px-4",children:[e.jsx("div",{className:"w-16 h-16 rounded-2xl bg-gray-100 flex items-center justify-center mb-4",children:e.jsx($o,{size:28,className:"text-gray-400"})}),e.jsx("h3",{className:"font-display text-lg font-bold text-gray-900 mb-1",children:"Sign In Required"}),e.jsx("p",{className:"text-sm text-gray-500 text-center max-w-sm mb-4",children:"You need to be signed in to perform this action. Your data will be saved to the database."}),e.jsxs("button",{onClick:()=>p(!0),className:"flex items-center gap-2 px-6 py-2.5 bg-gradient-to-r from-gold-dark to-gold text-white rounded-lg text-sm font-semibold shadow-md shadow-gold/20 hover:shadow-lg transition-all",children:[e.jsx($o,{size:16}),"Sign In"]})]}),e.jsx(Ex,{isOpen:u,onClose:()=>p(!1)})]})},Q2={"@type":"Brand",name:"Zorganics Cosmetics",slogan:"100% Vegan · Certified Organic · Non-Toxic Clinical Beauty"},qs=()=>{var s;const t=typeof window<"u"&&((s=window.location)!=null&&s.origin)?window.location.origin:"";return t?t.replace(/^https?:\/\/zorganicsinstitute\.edu$/i,"https://www.zorganicsinstitute.edu"):"https://www.zorganicsinstitute.edu"},WQ=()=>`${qs()}/#zorganics-cosmetics`,xA=()=>({"@type":"Organization","@id":WQ(),name:"Zorganics Cosmetics",url:`${qs()}/cosmetics`}),rp=(t,s=300)=>{const n=(t||"").replace(/\s+/g," ").trim();return n.length<=s?n:`${n.slice(0,s).replace(/\s+\S*$/,"")}â¦`};function Qn(t,s){if(typeof document>"u")return;const n=`jsonld-${t}`;let a=document.getElementById(n);a||(a=document.createElement("script"),a.type="application/ld+json",a.id=n,document.head.appendChild(a)),a.textContent=JSON.stringify(s)}function Jn(t){if(typeof document>"u")return;const s=document.getElementById(`jsonld-${t}`);s&&s.remove()}function HQ(t){const s=`${qs()}/products/${t.handle}`,n={"@context":"https://schema.org","@type":"Product",name:t.name,description:rp(t.description),sku:t.sku||t.handle,url:s,brand:Q2,manufacturer:xA()};t.productType&&(n.category=t.productType);
1227const a=(t.images||[]).filter(Boolean);return a.length>0&&(n.image=a),n.offers={"@type":"Offer",url:s,priceCurrency:"USD",price:(t.priceCents/100).toFixed(2),availability:t.inStock?"https://schema.org/InStock":"https://schema.org/OutOfStock",itemCondition:"https://schema.org/NewCondition",seller:xA()},t.related&&t.related.length>0&&(n.isRelatedTo=t.related.slice(0,4).map(r=>({"@type":"Product",name:r.name,url:`${qs()}/products/${r.handle}`,brand:Q2}))),n}function ip(t){return{"@context":"https://schema.org","@type":"BreadcrumbList",itemListElement:t.map((s,n)=>{const a={"@type":"ListItem",position:n+1,name:s.name};return s.path&&(a.item=s.path.startsWith("http")?s.path:`${qs()}${s.path}`),a})}}function GQ(t){const s=`${qs()}/collections/${t.handle}`;return{"@context":"https://schema.org","@type":"CollectionPage",name:`${t.title} | Zorganics Cosmetics`,description:rp(t.description),url:s,isPartOf:{"@type":"WebSite",name:"Zorganics Institute",url:qs()},mainEntity:{"@type":"ItemList",numberOfItems:t.products.length,itemListElement:t.products.slice(0,24).map((n,a)=>({"@type":"ListItem",position:a+1,item:{"@type":"Product",name:n.name,url:`${qs()}/products/${n.handle}`,brand:Q2,...n.image?{image:n.image}:{},offers:{"@type":"Offer",priceCurrency:"USD",price:(n.priceCents/100).toFixed(2),availability:"https://schema.org/InStock"}}}))}}}function MI(t){return`${qs()}${t}#program`}function Yhe(t,s){const n={"@context":"https://schema.org","@type":"EducationalOccupationalProgram",name:t.name,description:rp(t.description,500),provider:Fd(),programType:"Certificate",timeOfDay:"Day"};if(t.path&&(n["@id"]=MI(t.path),n.url=`${qs()}${t.path}`),n.numberOfCredits={"@type":"StructuredValue",name:"Clock Hours",value:t.hours},t.duration){const a=parseFloat(t.duration);Number.isFinite(a)&&a>0&&(n.timeToComplete=`P${Math.round(a)}M`)}return t.soc&&(n.occupationalCategory=t.soc),t.cip&&(n.identifier={"@type":"PropertyValue",propertyID:"CIP",value:t.cip}),t.formats&&t.formats.length>0&&(n.educationalProgramMode=t.formats.map(a=>a==="Hybrid"?"Blended":"Onsite")),n.occupationalCredentialAwarded={"@type":"EducationalOccupationalCredential",credentialCategory:"Certificate",name:`${t.name} â Washington State Licensure Preparation`},n}const VQ=()=>`${qs()}/#organization`,Fd=()=>({"@id":VQ()});function ZQ(t,s){const n={"@context":"https://schema.org","@type":"WebSite","@id":`${qs()}/#website`,name:t,url:`${qs()}/`,publisher:Fd()};return s&&(n.description=rp(s,300)),n}function M5(t){const s={"@context":"https://schema.org","@type":t.type||"WebPage",name:t.name,url:`${qs()}${t.path}`,isPartOf:{"@id":`${qs()}/#website`},about:Fd()};return t.description&&(s.description=rp(t.description,300)),s}function YQ(t){return{"@context":"https://schema.org","@type":"ItemList",name:"Zorganics Institute â Licensed Programs",itemListOrder:"https://schema.org/ItemListOrderAscending",numberOfItems:t.length,itemListElement:t.map((s,n)=>({"@type":"ListItem",position:n+1,item:{"@type":"EducationalOccupationalProgram","@id":MI(s.path),name:s.name,url:`${qs()}${s.path}`,provider:Fd()}}))}}function KQ(t){const s=`${qs()}${t.path}`,n={"@context":"https://schema.org","@type":"NewsArticle","@id":`${s}#newsarticle`,headline:t.headline,url:s,mainEntityOfPage:{"@type":"WebPage","@id":s},datePublished:t.datePublished,isPartOf:{"@id":`${qs()}/#website`},publisher:Fd(),about:Fd()};return t.description&&(n.description=rp(t.description,300)),t.image&&(n.image=[t.image]),t.category&&(n.articleSection=t.category),t.externalUrl&&(n.isBasedOn=t.externalUrl,t.source&&(n.sourceOrganization={"@type":"Organization",name:t.source})),n}function QQ(t){return{"@context":"https://schema.org","@type":"ItemList",name:"Zorganics Institute â News & Press",numberOfItems:t.length,itemListElement:t.map((s,n)=>({"@type":"ListItem",position:n+1,item:{"@type":"NewsArticle","@id":`${qs()}${s.path}#newsarticle`,headline:s.headline,url:`${qs()}${s.path}`,datePublished:s.datePublished,publisher:Fd()}}))}}const fA="page",gA="page-breadcrumb",yA="website",bA="program-list",JQ={"our-story":"AboutPage",shop:"CollectionPage",wholesale:"CollectionPage"},XQ={"program-profiles":[{name:"Home",path:"/"},{name:"Programs",path:"/programs"}],admissions:[{name:"Home",path:"/"},{name:"Admissions",path:"/admissions"}],"apply-now":[{name:"Home",path:"/"},{name:"Admissions",path:"/admissions"},{name:"Apply",path:"/apply"}],"student-clinic":[{name:"Home",path:"/"},{name:"Student Salon & Clinic",path:"/student-clinic"}],"contact-us":[{name:"Home",path:"/"},{name:"Contact",path:"/contact"}],"salon-services":[{name:"Home",path:"/"},{name:"Zora's Styling Salon & Spa",path:"/salon"}],"med-spa-portal":[{name:"Home",path:"/"},{name:"Zorganics Med Spa",path:"/medspa"}],shop:[{name:"Home",path:"/"},{name:"Zorganics Cosmetics",path:"/cosmetics"}],wholesale:[{name:"Home",path:"/"},{name:"Zorganics Cosmetics",path:"/cosmetics"},{name:"Wholesale",path:"/wholesale"}],"foundation-landing":[{name:"Home",path:"/"},{name:"The Zorganics Foundation",path:"/foundation"}]};function eJ(t,s=!1){d.useEffect(()=>{if(t==="campus-home")return Qn(yA,ZQ(wr.title,wr.description)),()=>Jn(yA);const n=Yb(t);if(!n||t==="program-profiles"&&s)return;const a=OI(t);
1227Qn(fA,M5({type:JQ[t],name:a.title,description:a.description,path:n}));const r=XQ[t];return r&&Qn(gA,ip(r)),t==="program-profiles"&&Qn(bA,YQ(yx.map(i=>({name:i.name,path:i.path})))),()=>{Jn(fA),Jn(gA),Jn(bA)}},[t,s])}const _p={plum:"#3B0A11",burgundy:"#800020",gold:"#D4AF37",goldDeep:"#B8962E",goldLight:"#E6D2A0",cream:"#FAF6EE"},Khe={hero:"https://d64gsuwffb70l.cloudfront.net/69caed6904ed6aca7682413a_1786396814505_f96ba31a.webp",clinicalFloor:"https://d64gsuwffb70l.cloudfront.net/69caed6904ed6aca7682413a_1786413891026_03755390.webp"},Qhe=[{id:"esthetics-750",name:"Esthetics",hours:750,headline:"Science-based skincare foundations with supervised clinical client experience.",skills:["Clinical facials & skin analysis","Chemical exfoliation","Waxing & lash services","WA licensing readiness"]},{id:"cosmetology",name:"Cosmetology",hours:1600,headline:"Full-spectrum beauty artistry â hair, skin, and nails in one licensed pathway.",skills:["Precision cutting & color","Texture services","Salon-floor client services","State board preparation"]},{id:"master-esthetics-1200",name:"Master Esthetics",hours:1200,headline:"Advanced clinical aesthetics for medical spa and dermatology-adjacent careers.",skills:["Advanced device modalities","Chemical peels & dermaplaning","Medical spa protocols","Master license readiness"]},{id:"manicurist",name:"Manicuring",hours:600,headline:"Professional nail artistry and natural nail health in a structured clinical format.",skills:["Natural nail care","Gel & enhancement systems","Sanitation & safety mastery","Salon business skills"]},{id:"instructor",name:"Instructor Training",hours:600,headline:"The leadership pathway â train licensed professionals to educate the next generation.",skills:["Curriculum design","Clinical floor supervision","Assessment & evaluation","WA instructor licensing"]}],Jhe=[{step:1,title:"Foundations",desc:"Structured theory, safety, and science-based coursework before touching the clinical floor."},{step:2,title:"Clinical Practice",desc:"Supervised services on real clients inside the Institute Clinical Floor."},{step:3,title:"Advanced Techniques",desc:"Device modalities, advanced protocols, and specialty certifications."},{step:4,title:"Career Launch",desc:"Licensing exam readiness, portfolio, and placement support through the Industry Portal."},{step:5,title:"Leadership Pathway",desc:"Instructor Training â return as a licensed educator and shape the profession."}],Xhe=[{title:"Medical Spas",desc:"Advanced clinical esthetics inside physician-supervised aesthetic practices."},{title:"Luxury Salons",desc:"Premium styling, color, and nail artistry for high-end clientele."},{title:"Skincare Clinics",desc:"Corrective, results-driven treatment rooms and dermatology-adjacent roles."},{title:"Aesthetic Practices",desc:"Device-based treatments, injectable-support roles, and patient care coordination."},{title:"Educator Roles",desc:"Licensed instructor positions in accredited beauty academies."}],exe=[{id:"skin-of-color",title:"Skin of Color",desc:"Fitzpatrick IVâVI treatment protocols, hyperpigmentation science, and inclusive clinical practice.",hours:24},{id:"oncology-aesthetics",title:"Oncology Aesthetics",desc:"Safe, comforting skincare for clients undergoing or recovering from cancer treatment.",hours:32},{id:"functional-aesthetics",title:"Functional Aesthetics",desc:"Whole-body approach connecting nutrition, barrier health, and corrective skincare outcomes.",hours:20},{id:"medspa-business",title:"Medical Spa Business",desc:"Compliance, operations, and leadership for estheticians entering med-spa management.",hours:28}],txe=[{title:"Institute Clinical Floor",desc:"Supervised, real-client treatment floor where students log clinical hours under licensed instructors."},{title:"Zorganics Spa & Salon",desc:"Professional spa/salon properties offering graduates first-look placement into working luxury environments."}],tJ=[{name:"Cosmetology",hours:"1,600 clock hours"},{name:"Esthetics",hours:"750 clock hours"},{name:"Master Esthetics",hours:"1,200 clock hours"},{name:"Master Esthetician Bridge",hours:"450 clock hours"},{name:"Manicuring",hours:"600 clock hours"},{name:"Instructor Training",hours:"600 clock hours"}],sJ=()=>e.jsxs("section",{className:"pt-10 lg:pt-14 max-w-3xl mx-auto",children:[e.jsxs("div",{className:"text-center",children:[e.jsx("p",{className:"text-[11px] font-bold uppercase tracking-[0.25em] mb-2",style:{color:_p.goldDeep},children:"Admissions · Bellingham, Washington"}),e.jsx("h1",{className:"font-display text-2xl lg:text-4xl font-bold mb-3",style:{color:_p.plum},children:"Apply Now â Zorganics Institute of Beauty & Wellness"}),e.jsx("p",{className:"text-sm text-gray-500 max-w-xl mx-auto",children:"Apply to Zorganics Institute of Beauty & Wellness in Bellingham, Washington. Explore career training in cosmetology, esthetics, master esthetics, manicuring, and instructor training, then submit your application below. There is no fee to submit this online form. Admissions will confirm any applicable catalog-listed enrollment fees before enrollment, and an admissions representative follows up directly."})]}),e.jsxs("div",{className:"mt-8 rounded-2xl border p-5 sm:p-6",style:{borderColor:`${_p.gold}4D`,background:"#fff"},children:[e.jsx("h2",{className:"text-sm font-bold mb-3",style:{color:_p.plum},children:"Programs you can apply to"}),e.jsx("ul",{className:"grid sm:grid-cols-2 gap-x-6 gap-y-2",children:tJ.map(t=>e.jsxs("li",{className:"flex items-baseline justify-between gap-3 text-xs",children:[e.jsx("span",{className:"font-semibold",style:{color:_p.burgundy},children:t.name}),e.jsx("span",{className:"text-gray-400",children:t.hours})]},t.name))}),e.jsx("p",{className:"mt-4 text-[11px] text-gray-500",children:"Zorganics Institute of Beauty & Wellness â 410 West Bakerview Road, Suite 112, Bellingham, Washington 98226. Career training programs prepare students for Washington State licensure. Financial aid is available to those who qualify."})]})]}),nJ=re.lazy(()=>Ee(()=>import("./HeroSection-BbbXxVas.js"),__vite__mapDeps([0,1,2,3]))),vA=re.lazy(()=>Ee(()=>import("./SiteAuthorityHeader-CkFhiaH5.js"),[])),aJ=re.lazy(()=>Ee(()=>import("./EntityGateway-BQ9we-TA.js"),__vite__mapDeps([4,5]))),jA=re.lazy(()=>Ee(()=>import("./ProgramDashboard-BP67NSIK.js"),__vite__mapDeps([6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23]))),rJ=re.lazy(()=>Ee(()=>import("./LMSSection-rwiF8zO1.js"),__vite__mapDeps([24,9,25,26,27,28,29,13,12,30,31,32]))),iJ=re.lazy(()=>Ee(()=>import("./InstructorLMSSection-DeyUKOQj.js"),__vite__mapDeps([33,10,34,27]))),oJ=re.lazy(()=>Ee(()=>import("./AuditVaultSection-CshcSOHg.js"),__vite__mapDeps([35,7,19]))),lJ=re.lazy(()=>Ee(()=>
1227import("./FinancialSection-DLhjKKZo.js"),__vite__mapDeps([36,7,19,15,37,18,38,39,34,3,40,17,41,42,30]))),cJ=re.lazy(()=>Ee(()=>import("./AgencyHubSection-n7cfzLVy.js"),__vite__mapDeps([43,7,19]))),dJ=re.lazy(()=>Ee(()=>import("./StaffPortalSection-DAjYQN5k.js"),__vite__mapDeps([44,8,45,46,9,11,13,41,15,38,19,30]))),uJ=re.lazy(()=>Ee(()=>import("./GoogleSyncSection-puMGQFuu.js"),__vite__mapDeps([47,48,26]))),mJ=re.lazy(()=>Ee(()=>import("./POSSection-DLksTH8x.js"),__vite__mapDeps([49,7,50,51,52,14,17]))),pJ=re.lazy(()=>Ee(()=>import("./FranchiseSection-uBiux7b1.js"),__vite__mapDeps([53,7]))),hJ=re.lazy(()=>Ee(()=>import("./FranchiseHub-DoJHwNWf.js"),__vite__mapDeps([54,52])));re.lazy(()=>Ee(()=>import("./StudentPortalComingSoon-DrDO0QSp.js"),[]));const xJ=re.lazy(()=>Ee(()=>import("./StudentPortalActive-Ch06R7Zb.js"),[])),fJ=re.lazy(()=>Ee(()=>import("./ProgramProfilesPage-2ziTX-S9.js"),__vite__mapDeps([55,2,56,3]))),wA=re.lazy(()=>Ee(()=>import("./PartnerPortal-BoFq6aGF.js"),__vite__mapDeps([57,7,10,11]))),NA=re.lazy(()=>Ee(()=>import("./ZorganicsEcosystem-DJDwsupM.js"),__vite__mapDeps([58,7,20,21]))),_A=re.lazy(()=>Ee(()=>import("./MasterBridgePortal-C3EPhflU.js"),__vite__mapDeps([59,12]))),kA=re.lazy(()=>Ee(()=>import("./ComplianceReminderPanel-DkB5k_py.js").then(t=>t.d),__vite__mapDeps([37,7,18,38,39,34,3]))),gJ=re.lazy(()=>Ee(()=>import("./ZShopSection-4PB4b5gp.js"),__vite__mapDeps([60,61,52,50,62]))),BI=re.lazy(()=>Ee(()=>import("./ProfessionalServicesSection-MiNqoji2.js"),__vite__mapDeps([63,20,21]))),SA=re.lazy(()=>Ee(()=>import("./FoundationSection-Dlge3iEh.js"),__vite__mapDeps([64,65]))),yJ=re.lazy(()=>Ee(()=>import("./HousingModule-DPbzhLOu.js"),__vite__mapDeps([66,67,10,39,3,13,68]))),bJ=re.lazy(()=>Ee(()=>import("./HospitalitySection-BTTvrmrJ.js"),__vite__mapDeps([69,70,5,65]))),vJ=re.lazy(()=>Ee(()=>import("./VerticalVillageMap-Ba_S7gTj.js"),[])),jJ=re.lazy(()=>Ee(()=>import("./InstructorGradebook-DoQ7HUjE.js"),__vite__mapDeps([71,29]))),wJ=re.lazy(()=>Ee(()=>import("./StudentProgressDashboard-BhnxaD1M.js"),__vite__mapDeps([72,29,9,25]))),NJ=re.lazy(()=>Ee(()=>import("./StudentProfilePage-D-CHmmvk.js"),__vite__mapDeps([73,74]))),_J=re.lazy(()=>Ee(()=>import("./AdminDocumentVerification-C3_2cyZj.js"),[])),kJ=re.lazy(()=>Ee(()=>import("./ZCPAModule-CWkFlvLp.js"),__vite__mapDeps([75,40]))),SJ=re.lazy(()=>Ee(()=>import("./WholesaleB2BShop-DlslXYPW.js"),__vite__mapDeps([76,61,70]))),CJ=re.lazy(()=>Ee(()=>import("./WholesaleOrderTracker-D026ExvG.js"),__vite__mapDeps([77,78,79]))),AJ=re.lazy(()=>Ee(()=>import("./WholesaleAdminPanel-D5vgcC7h.js"),__vite__mapDeps([80,81,40,82,83,22,65,18,84,79,78]))),EJ=re.lazy(()=>Ee(()=>import("./WholesalePartnerPortal-QClgVNau.js"),__vite__mapDeps([85,65,84,18]))),FJ=re.lazy(()=>Ee(()=>import("./OurStorySection-D_gQmxGT.js"),[])),TJ=re.lazy(()=>Ee(()=>import("./ContactUsSection-bIZ4C7-W.js"),[])),PJ=re.lazy(()=>Ee(()=>import("./MedSpaPortal-BJoJ9Djd.js"),__vite__mapDeps([86,87,21,11]))),DJ=re.lazy(()=>Ee(()=>import("./RGMComplianceDashboard-DM34j9yA.js"),__vite__mapDeps([88,46]))),RJ=re.lazy(()=>Ee(()=>import("./MDReferralPortal-DoKNNAvD.js"),[])),IJ=re.lazy(()=>Ee(()=>import("./SupplyChainModule-DT0c3luJ.js"),__vite__mapDeps([89,23,79,65])));re.lazy(()=>Ee(()=>import("./ReviewerAccessPortal-k5_9lGY5.js"),[]));const $J=re.lazy(()=>Ee(()=>import("./ComplianceLockdown-CfbejA2w.js"),__vite__mapDeps([90,16,91]))),zJ=re.lazy(()=>Ee(()=>import("./WixSyncScheduler-B_uREFIc.js"),__vite__mapDeps([92,93,3,22]))),LJ=re.lazy(()=>Ee(()=>import("./CEUTrainingPortal-DLdsFG1t.js"),__vite__mapDeps([94,65,26]))),OJ=re.lazy(()=>Ee(()=>import("./WholesaleFulfillmentDashboard-BpmoMF7M.js"),__vite__mapDeps([95,79,78])));re.lazy(()=>Ee(()=>import("./SAPProgressEngine-CnfLUoFB.js"),__vite__mapDeps([96,81,97,40,39,22,98,68,31,99])));re.lazy(()=>Ee(()=>import("./ChainOfCustodyLog-CVQK8zxN.js"),__vite__mapDeps([100,93])));re.lazy(()=>Ee(()=>import("./InstructorGradingPortal-K3DauwMl.js"),[]));const MJ=re.lazy(()=>Ee(()=>import("./ParentGuardianPortal-NXYMI8cw.js"),__vite__mapDeps([101,39,11]))),BJ=re.lazy(()=>Ee(()=>import("./ExecutiveFinancialOverview-BeYjhk6p.js"),__vite__mapDeps([102,3,15]))),CA=re.lazy(()=>Ee(()=>import("./AdmissionsPage-1SA_ztK9.js"),__vite__mapDeps([103,51,56,104,32,3]))),UJ=re.lazy(()=>Ee(()=>import("./SalonServicesPage-BSzw5eKf.js"),__vite__mapDeps([105,70,50,106,87,11,104,32,21]))),qJ=re.lazy(()=>Ee(()=>import("./StudentSalonClinic-4t2URS5C.js"),__vite__mapDeps([107,106,87,11,50,104,32]))),WJ=re.lazy(()=>Ee(()=>import("./FoundationDonationModule-CrIMpnso.js"),[])),HJ=re.lazy(()=>Ee(()=>import("./SISDashboard-DxA2JY6v.js"),__vite__mapDeps([108,45]))),GJ=re.lazy(()=>Ee(()=>import("./EDExpressGateway-DmhHgWjG.js"),__vite__mapDeps([109,3,34]))),VJ=re.lazy(()=>Ee(()=>import("./WixStudioGlobalExport-DZGlqj2V.js"),__vite__mapDeps([110,1,3,74,48,111,112]))),ZJ=re.lazy(()=>Ee(()=>import("./GoogleMetaSync-B8FegcMR.js"),__vite__mapDeps([113,1,111]))),YJ=re.lazy(()=>Ee(()=>import("./RobotsTxtGenerator-CVFhx4br.js"),__vite__mapDeps([114,115]))),AA=re.lazy(()=>Ee(()=>import("./GA4IntegrationModule-BRh_zhkP.js").then(t=>t.b),__vite__mapDeps([116,3,5]))),EA=re.lazy(()=>Ee(()=>import("./GSCSearchConsoleModule-BXEddsC8.js").then(t=>t.a),__vite__mapDeps([117,118]))),KJ=re.lazy(()=>Ee(()=>import("./AhrefsBacklinkModule-BUDYbMjy.js").then(t=>t.d),[])),QJ=re.lazy(()=>Ee(()=>import("./CareerBridgeModule-D9mZOX7G.js"),[])),JJ=re.lazy(()=>Ee(()=>import("./RegulatoryReportingEngine-Lec_ko9y.js").then(t=>t.R),[])),XJ=re.lazy(()=>Ee(()=>import("./DOLHourSubmissionRelay-Bg2C1xj_.js"),[])),eX=re.lazy(()=>Ee(()=>import("./LOAManagementModule-DB06sY9c.js"),[])),tX=re.lazy(()=>Ee(()=>import("./GalaFundraiserModule-BMBdR0b1.js"),[])),sX=re.lazy(()=>Ee(()=>
1227import("./FoundationGiftShop-CWLdUTUo.js"),[])),nX=re.lazy(()=>Ee(()=>import("./RetargetingConversionModule-B5w_OuZ7.js"),__vite__mapDeps([119,3,120,91,52]))),aX=re.lazy(()=>Ee(()=>import("./ABTestCampaignModule-DsxEyTUZ.js"),__vite__mapDeps([121,15]))),rX=re.lazy(()=>Ee(()=>import("./SovereignMultiSiteOS-B_hxBHPC.js"),__vite__mapDeps([122,13,22]))),iX=re.lazy(()=>Ee(()=>import("./AIScanResultsPortal-CcPpybnU.js"),__vite__mapDeps([123,28,38,3,120,15]))),oX=re.lazy(()=>Ee(()=>import("./AutonomousEscalationGovernance-63zM-zxy.js"),__vite__mapDeps([124,115]))),lX=re.lazy(()=>Ee(()=>import("./FoundationLandingPage-CKVM2Q9y.js"),__vite__mapDeps([125,62]))),cX=re.lazy(()=>Ee(()=>import("./ZorganicsPremiumLanding-DJOnsVVK.js"),__vite__mapDeps([126,1,65]))),dX=re.lazy(()=>Ee(()=>import("./PureBenefitRewards-BljpQV2s.js"),[])),uX=re.lazy(()=>Ee(()=>import("./CampusHomePage-bY8g2MtB.js"),__vite__mapDeps([127,128,11,42]))),mX=re.lazy(()=>Ee(()=>import("./ZLPPortal-CT9Um45G.js"),__vite__mapDeps([129,128,26]))),pX=re.lazy(()=>Ee(()=>import("./ZIPPortal-CX-4wtDk.js"),__vite__mapDeps([130,131,2]))),hX=re.lazy(()=>Ee(()=>import("./ApplyNowForm-uhFPb_Ze.js"),__vite__mapDeps([132,131,2,133,11]))),xX=re.lazy(()=>Ee(()=>import("./ProgramDetailPublic-FnhtbzHW.js"),__vite__mapDeps([134,131,2,11]))),fX=re.lazy(()=>Ee(()=>import("./CampusOpsPortal-BJqcWvr4.js"),__vite__mapDeps([135,131,2,133,11,99,136,128]))),gX=re.lazy(()=>Ee(()=>import("./TourBookingPage-9NWoctMq.js"),__vite__mapDeps([137,133,11]))),yX=re.lazy(()=>Ee(()=>import("./EmployerOnboarding-StOQeqG7.js"),__vite__mapDeps([138,133]))),bX=re.lazy(()=>Ee(()=>import("./EmployerWorkspace-wyOiEASP.js"),__vite__mapDeps([139,136]))),FA="https://d64gsuwffb70l.cloudfront.net/69cae7fb5ea7db794957149e_1775337912224_4cc82887.jfif",k0=()=>e.jsx(IQ,{label:"Loading Module"}),TA={dashboard:"Program Dashboard",lms:"Z-LMS","instructor-lms":"Instructor 600hr Program",audit:"Audit Vault",financial:"Financial Engine",agency:"Agency Hub",staff:"Staff Portal",google:"Google Sync",pos:"POS & Inventory",franchise:"Franchise HQ","student-portal":"Student Portal","partner-portal":"Partner Dashboard",ecosystem:"Zorganics Ecosystem","master-bridge":"Master Esthetics Bridge (450h)",compliance:"Compliance Automation",shop:"Zorganics Cosmetics Shop","professional-services":"Professional Services",foundation:"Zorganics Foundation",housing:"Student Housing",hospitality:"Z-Bistro & Cafe",events:"Foundation Events","village-map":"Vertical Village Map","quiz-engine":"Z-LMS Intelligence","location-mgmt":"Location Management","student-progress":"My Progress","student-profile":"Student Profile","doc-verification":"Document Verification","z-cpa":"Z-CPA Financial Intelligence",wholesale:"Wholesale B2B Shop","wholesale-tracker":"Order Tracker","wholesale-admin":"Wholesale Admin","wholesale-partner-portal":"Wholesale Partner Portal","md-referral":"MD Referral Portal","supply-chain":"Supply Chain & NPD","reviewer-access":"Reviewer Access","compliance-lockdown":"Compliance & Privacy Lockdown",gradebook:"Instructor Gradebook","our-story":"Our Story","contact-us":"Contact Us","financial-silo":"Financial Triple-Silo","med-spa-portal":"Zorganics Med Spa","zoras-salon":"Zora's Styling Salon","rgm-compliance":"RGM Financial Oversight","wix-sync":"Wix Bi-Directional Inventory Sync","ceu-training":"CEU Training Portal","wholesale-fulfillment":"B2B Fulfillment Dashboard","sap-engine":"SAP Progress Engine","chain-of-custody":"Chain of Custody â Audit Trail","grading-portal":"Instructor Grading Portal","guardian-portal":"Support Circle â Parent/Guardian Portal",admissions:"Admissions","salon-services":"Salon & Spa Services","student-clinic":"Student Salon Clinic","foundation-donate":"Support Our Mission","bistro-menu":"Z-Bistro Quick Order","sis-dashboard":"Student Information System (SIS)","master-esthetics-1200":"Master Esthetician Program (1200h)",edexpress:"EDExpress 2026â27 | Federal Aid Gateway","program-profiles":"Core Four â Program Profiles","wix-studio-export":"Wix Studio Global Export","google-meta-sync":"Google Business Profile Meta Sync","robots-txt-generator":"robots.txt Generator & Validator","ga4-integration":"Google Analytics 4 Integration","ahrefs-backlinks":"Ahrefs Backlink Monitor","career-bridge":"Career Bridge Smart Elite","dol-hour-relay":"WA DOL Hour Submission Relay","loa-management":"Leave of Absence Management","gala-fundraiser":"Annual Industry Gala & Foundation Fundraiser","foundation-gift-shop":"Zorganics Foundation Gift Shop","retargeting-conversion":"Global Retargeting & Conversion Tracking","ab-testing":"A/B Testing & Campaign Optimization","sovereign-os":"Sovereign Multi-Site OS","foun
1227dation-landing":"Zorganics Foundation â Scholarships & Giving","premium-landing":"Zorganics Institute â Premium Landing","pure-benefit-rewards":"PUREBenefit⢠Rewards","campus-home":"Zorganics Institute","zlp-portal":"ZLP â Zorganics Learning Portal","zip-portal":"ZIP â Zorganics Industry Portal","apply-now":"Apply to Zorganics Institute","program-detail":"Program Details","campus-ops":"Campus Operations Engine","tour-booking":"Schedule a Campus Tour","employer-onboarding":"Employer & Partner Onboarding","employer-workspace":"Employer Workspace"},vX={dashboard:"SIS Module",lms:"LMS Module","instructor-lms":"LMS Module",audit:"Compliance Module",financial:"Finance Module",agency:"Regulatory Module",staff:"HR Module",google:"Integration Module",pos:"Commerce Module",franchise:"Enterprise Module","student-portal":"Student Module","partner-portal":"Partner Module",ecosystem:"Ecosystem","master-bridge":"Clinical Module",compliance:"Compliance Module",shop:"Commerce Module","professional-services":"Services Module",foundation:"Foundation",housing:"Village Module",hospitality:"Village Module",events:"Village Module","village-map":"Village Module","student-progress":"Student Module","student-profile":"Student Module","doc-verification":"Compliance Module","z-cpa":"CPA Module",wholesale:"Commerce Module","wholesale-tracker":"Commerce Module","wholesale-admin":"Commerce Module","md-referral":"Clinical Module","supply-chain":"Operations Module","reviewer-access":"Audit Module","compliance-lockdown":"Privacy Module",gradebook:"Academic Module","our-story":"About","contact-us":"Contact","financial-silo":"Finance Module","med-spa-portal":"Clinical Portal","zoras-salon":"Salon Portal","rgm-compliance":"Compliance Module","wix-sync":"Commerce Module","ceu-training":"Education Module","wholesale-fulfillment":"Commerce Module","sap-engine":"Compliance Module","chain-of-custody":"Operations Module","exec-financial":"Executive Finance",edexpress:"Financial Aid Module","program-profiles":"Academic Module","wix-studio-export":"Deployment Module","google-meta-sync":"SEO & Indexing Module","robots-txt-generator":"Crawl Management Module","ga4-integration":"Analytics & Attribution Module","gsc-integration":"Search Console Module","career-bridge":"Workforce Compliance Module","federal-compliance":"Federal Safety Module","clinical-safety":"Clinical Safety Module","dol-hour-relay":"WA DOL Licensing Module","loa-management":"Student Services Module","gala-fundraiser":"Foundation Events Module","foundation-gift-shop":"Foundation Commerce Module","retargeting-conversion":"Retargeting & Attribution Module","ab-testing":"Campaign Optimization Module","sovereign-os":"Sovereign Multi-Site OS","ai-scan-portal":"AI Diagnostic & Clinical Intelligence Module","escalation-governance":"Sovereign Governance Module","foundation-landing":"Foundation · 501(c)(3) Public Charity","pure-benefit-rewards":"Loyalty Module","campus-home":"A Holistic Approach To Beauty and Wellness Through Science & Art","zlp-portal":"Secure Learning Layer","zip-portal":"Career & Ecosystem Layer","apply-now":"Admissions Intake Gateway","program-detail":"Public Program Information","campus-ops":"Operations & Lifecycle Routing","tour-booking":"Engagement Engine · Live Scheduling","employer-onboarding":"Zorganics Career Network","employer-workspace":"ZIP · Approved Partner Access"},jX=["student-portal","partner-portal","shop","professional-services","foundation","housing","hospital
1227ity","events","village-map","student-progress","student-profile","doc-verification","z-cpa","wholesale","wholesale-tracker","wholesale-admin","md-referral","supply-chain","reviewer-access","compliance-lockdown","franchise","our-story","contact-us","financial-silo","med-spa-portal","zoras-salon","rgm-compliance","wix-sync","ceu-training","wholesale-fulfillment","sap-engine","chain-of-custody","grading-portal","guardian-portal","exec-financial","edexpress","wix-studio-export","google-meta-sync","robots-txt-generator","ga4-integration","regulatory-reporting","federal-compliance","clinical-safety","dol-hour-relay","loa-management","gala-fundraiser","retargeting-conversion","ab-testing","sovereign-os","foundation-landing","premium-landing","pure-benefit-rewards","campus-home","zlp-portal","zip-portal","apply-now","program-detail","campus-ops","tour-booking","employer-onboarding","employer-workspace"],wX=["zlp-portal","student-portal"],NX=["zip-portal","employer-workspace"],Rv=({label:t})=>{sn();const[s,n]=re.useState(!1);return e.jsxs("section",{className:"py-12 lg:py-20",children:[e.jsxs("div",{className:"max-w-lg mx-auto",children:[e.jsxs("div",{className:"text-center mb-8",children:[e.jsx("div",{className:"w-20 h-20 rounded-2xl bg-gradient-to-br from-[#3B0A11] to-[#800020] flex items-center justify-center mx-auto mb-6 shadow-lg",children:e.jsx(Ie,{size:36,className:"text-[#D4AF37]"})}),e.jsxs("h1",{className:"font-display text-2xl lg:text-3xl font-bold text-gray-900 mb-2",children:[t," â Secure Sign-In"]}),e.jsx("p",{className:"text-gray-500 text-sm max-w-md mx-auto",children:"This module contains protected student records and program progress data. You must authenticate before any records are loaded."})]}),e.jsxs("div",{className:"bg-white rounded-2xl border border-gray-100 shadow-lg p-8 text-center",children:[e.jsxs("div",{className:"flex items-center justify-center gap-2 mb-4",children:[e.jsx(Xe,{size:18,className:"text-[#800020]"}),e.jsx("h3",{className:"font-semibold text-gray-900",children:"Authentication Required"})]}),e.jsx("p",{className:"text-xs text-gray-500 mb-6",children:"For your security, the student list and progress data are not loaded into this browser until your counselor / staff session is verified."}),e.jsxs("button",{onClick:()=>n(!0),className:"w-full py-3 bg-gradient-to-r from-[#800020] to-[#600018] text-white rounded-xl font-semibold shadow-md hover:shadow-lg transition-all flex items-center justify-center gap-2",children:[e.jsx($o,{size:16})," Sign In to Continue"]}),e.jsxs("div",{className:"mt-6 p-4 bg-amber-50 border border-amber-200 rounded-xl flex items-start gap-2 text-left",children:[e.jsx(Tt,{size:16,className:"text-amber-600 shrink-0 mt-0.5"}),e.jsx("p",{className:"text-[11px] text-amber-700",children:"FERPA Notice: Access to education records is restricted to authorized school officials with a legitimate educational interest (34 CFR 99.31). All access is logged for audit purposes."})]})]})]}),e.jsx(Ex,{isOpen:s,onClose:()=>n(!1)})]})},_X=()=>{const{setSelectedEntity:t,setEntityGatewayDismissed:s,activeLocation:n}=dc(),a=n==="bellingham"?"Bellingham HQ":n==="renton"?"Renton (Coming August 2026)":"Seattle";return e.jsxs("section",{className:"py-8 lg:py-12",children:[e.jsxs("button",{onClick:()=>{t("none"),s(!1)},className:"flex items-center gap-2 text-sm text-gray-500 hover:text-[#800020] transition-colors mb-6 group",children:[e.jsx(Je,{size:16,className:"group-hover:-translate-x-1 transition-transform"}),"Back to Entity Gateway"]}),e.jsxs("div",{className:"mb-8",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[e.jsx("div",{className:"w-1 h-6 bg-[#800020] rounded-full"}),e.jsx("span",{className:"text-xs font-semibold text-[#800020] uppercase tracking-wider",children:"Salon Portal"}),e.jsx("span",{className:"text-[10px] px-2 py-0.5 bg-[#800020]/10 text-[#800020] rounded-full border border-[#800020]/20 font-bold",children:a})]}),e.jsx("h2",{className:"font-display text-3xl lg:text-4xl font-bold text-gray-900",children:"Zora's Styling Salon & Spa"}),e.jsx("p",{className:"text-gray-500 mt-1",children:"Named after Frida Emalange's daughter Zora â full-service organic salon with premium styling, nails, facials, and bridal packages"})]}),e.jsxs("div",{className:"mb-6 p-4 bg-amber-50 rounded-xl border border-amber-200 flex items-start gap-3",children:[e.jsx(Xe,{size:18,className:"text-amber-600 shrink-0 mt-0.5"}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-bold text-amber-900",children:"Professional Salon â Not Student Clinic"}),e.jsxs("p",{className:"text-xs text-amber-700 mt-1",children:["All services performed by experienced, licensed stylists and estheticians. Student-supervised services are isolated in the ",e.jsx("strong",{children:"Institute Portal"})," under the Education Firewall. The 1,200h Master and 1,600h Cosmetology curriculum is restricted to the Institute."]})]})]}),e.jsxs("div",{className:"mb-6 p-4 bg-[#800020]/5 rounded-xl border border-[#800020]/20 flex items-center gap-3",children:[e.jsx("div",{className:"w-10 h-10 rounded-lg bg-gradient-to-br from-[#800020] to-[#600018] flex items-center justify-center text-white shrink-0",children:e.jsx(Ss,{size:18})}),e.jsxs("div",{className:"flex-1",children:[e.jsx("p",{className:"text-sm font-bold text-[#800020]",children:"Salon A
1227ccount â Financial Silo"}),e.jsx("p",{className:"text-xs text-gray-600",children:"Revenue routes to the Zora's Styling bank account. Isolated from Institute tuition and Med Spa clinical revenue."})]}),e.jsx(Tt,{size:16,className:"text-[#800020]/40"})]}),e.jsx(d.Suspense,{fallback:e.jsx(k0,{}),children:e.jsx(BI,{})})]})},PA=({mode:t,identity:s,onSignOut:n})=>e.jsxs("div",{className:"w-full flex items-center gap-3 px-4 lg:px-8 py-2.5",style:{background:"linear-gradient(90deg, #3B0A11, #800020)",borderBottom:"2px solid #D4AF37"},role:"navigation","aria-label":t==="zlp"?"Learning Portal session bar":"Industry Portal session bar",children:[e.jsx(Ie,{size:15,style:{color:"#D4AF37"},className:"shrink-0","aria-hidden":"true"}),e.jsxs("p",{className:"text-[11px] font-bold uppercase tracking-[0.18em] truncate",style:{color:"#F7E7CE"},children:[t==="zlp"?"ZLP · Zorganics Learning Portal":"ZIP · Zorganics Industry Portal",e.jsxs("span",{className:"hidden sm:inline font-semibold normal-case tracking-normal",style:{color:"#E6D2A0"},children:[" ","â ",s]})]}),e.jsxs("button",{onClick:n,className:"ml-auto flex items-center gap-1.5 px-4 py-1.5 rounded-lg text-[11px] font-bold shadow-md hover:shadow-lg transition-all shrink-0",style:{background:"linear-gradient(135deg, #D4AF37, #B8962E)",color:"#3B0A11"},title:"End this portal session and return to the public homepage","aria-label":"Sign out of the portal",children:[e.jsx(bo,{size:13})," Sign Out"]})]}),kX=["campus-home","admissions","tour-booking","program-detail"],SX=()=>{const{activeSection:t,activeBrand:s,showHero:n,setActiveSection:a,selectedEntity:r,entityGatewayDismissed:i,selectedProgramId:o}=dc(),{isAuthenticated:l,canAccessSection:c,user:u,signOut:p}=kn(),{isStudentAuthenticated:m,student:x,studentLogout:h}=ap();zQ(t),qQ(t),eJ(t,!!(t==="program-profiles"&&k2(o)));const y=Za(),{pathname:v,search:g}=ai();re.useEffect(()=>{const I=new URLSearchParams(g).get("audit")==="1",D=t==="program-profiles"?k2(o):void 0,L=(D==null?void 0:D.path)||Yb(t);if(L){!I&&v!==L&&y(L,{replace:!0}),Jl(D?`${Mi}${D.path}`:OW(t)),D&&qa({title:D.seoTitle,description:D.seoDescription});return}!I&&v!=="/"&&iR(v)&&y("/",{replace:!0});const V=HW(t,o);Jl(`${Mi}${V||"/"}`)},[t,o,v,g,y]);const[N,b]=re.useState(()=>D3());re.useEffect(()=>{const I=()=>b(D3());return I(),window.addEventListener(H2,I),()=>window.removeEventListener(H2,I)},[t]);const f=wX.includes(t)&&(l||m)?"zlp":NX.includes(t)&&N?"zip":"public",j=f==="public",S=re.useCallback(I=>{I==="zlp"?(m&&h(),l&&p(),G2()):$Y(),a("campus-home"),window.scrollTo({top:0})},[m,l,h,p,a]);re.useEffect(()=>{(m||l&&(u==null?void 0:u.role)==="instructor")&&kX.includes(t)&&(zY()||(LY(),a(m?"student-portal":"zlp-portal"),window.scrollTo({top:0})))},[t,m,l,u==null?void 0:u.role,a]);const w=!i&&r==="none"&&n&&s==="institute",_=()=>{if(t==="campus-home")return e.jsx(qt,{moduleName:"Campus Home",fallbackMessage:"The admissions funnel is loading.",children:e.jsx(uX,{})});if(t==="zlp-portal")return e.jsx(qt,{moduleName:"ZLP Learning Portal",fallbackMessage:"The Zorganics Learning Portal is loading.",children:e.jsx(mX,{})});if(t==="zip-portal")return e.jsx(qt,{moduleName:"ZIP Industry Portal",fallbackMessage:"The Zorganics Industry Portal is loading.",children:e.jsx(pX,{})});if(t==="apply-now")return e.jsxs(e.Fragment,{children:[e.jsx(sJ,{}),e.jsx(qt,{moduleName:"Apply Now",fallbackMessage:"The admissions application is loading.",children:e.jsx(hX,{})})]});if(t==="program-detail")return e.jsx(qt,{moduleName:"Program Details",fallbackMessage:"The program information page is loading.",children:e.jsx(xX,{})});if(t==="campus-ops")return e.jsx(qt,{moduleName:"Campus Operations",fallbackMessage:"The Campus Operations Engine is loading.",children:e.jsx(fX,{})});if(t==="tour-booking")return e.jsx(qt,{moduleName:"Tour Booking",fallbackMessage:"The tour scheduling system is loading.",children:e.jsx(gX,{})});if(t==="employer-onboarding")return e.jsx(qt,{moduleName:"Employer Onboarding",fallbackMessage:"The employer onboarding system is loading.",children:e.jsx(yX,{})});if(t==="employer-workspace")return e.jsx(qt,{moduleName:"Employer Workspace",fallbackMessage:"The employer workspace is loading.",children:e.jsx(bX,{})});if(t==="admissions")return e.jsx(CA,{});if(t==="salon-services")return e.jsx(UJ,{});if(t==="student-clinic")return e.jsx(qJ,{});if(t==="foundation-donate")return e.jsx(WJ,{});if(t==="sis-dashboard")return e.jsx(lr,{fallback:e.jsx(Rv,{label:"Student Information System (SIS)"}),children:e.jsx(HJ,{})});if(t==="master-esthetics-1200")return e.jsx(CA,{});if(t==="our-story")return e.jsx(FJ,{});if(t==="contact-us")return e.jsx(TJ,{});if(t==="med-spa-portal")return e.jsx(PJ,{});if(t==="zoras-salon")return e.jsx(_X,{});if(t==="shop")return e.jsx(gJ,{});if(t==="professional-services")return e.jsx(BI,{});if(t==="foundation-landing")return e.jsx(qt,{moduleName:"Foundation Landing",fallbackMessage:"The Zorganics Foundation landing page is loading.",children:e.jsx(lX,{})});if(t==="premium-landing")return e.jsx(qt,{moduleName:"Premium Landing",fallbackMessage:"The premium landing template is loading.",children:e.jsx(cX,{})});
1227if(t==="pure-benefit-rewards")return e.jsx(qt,{moduleName:"PUREBenefit Rewards",fallbackMessage:"The PUREBenefit⢠Rewards loyalty hub is loading.",children:e.jsx(dX,{})});if(t==="foundation")return e.jsx(SA,{});if(t==="housing")return e.jsx(yJ,{});if(t==="hospitality")return e.jsx(bJ,{});if(t==="events")return e.jsx(SA,{});if(t==="village-map")return e.jsx(vJ,{});if(t==="student-progress")return e.jsx(wJ,{});if(t==="student-profile")return e.jsx(NJ,{});if(t==="doc-verification")return e.jsx(_J,{});if(t==="z-cpa")return e.jsx(lr,{redirectTo:"/admin-login",children:e.jsx(kJ,{})});if(t==="wholesale")return e.jsx(SJ,{});if(t==="wholesale-tracker")return e.jsx(CJ,{onBack:()=>a("wholesale")});if(t==="wholesale-admin")return e.jsx(AJ,{onBack:()=>a("wholesale")});if(t==="wholesale-partner-portal")return e.jsx(EJ,{onBack:()=>a("wholesale")});if(t==="ceu-training")return e.jsx(LJ,{onBack:()=>a("wholesale")});if(t==="wholesale-fulfillment")return e.jsx(OJ,{onBack:()=>a("wholesale")});if(t==="wix-sync")return e.jsx(zJ,{});if(t==="md-referral")return e.jsx(RJ,{});if(t==="ga4-integration")return e.jsx(lr,{redirectTo:"/admin-login",children:e.jsx(qt,{moduleName:"GA4 Integration",fallbackMessage:"The Google Analytics 4 Integration module is loading.",children:e.jsx(AA,{})})});if(t==="gsc-integration")return e.jsx(lr,{redirectTo:"/admin-login",children:e.jsx(qt,{moduleName:"Google Search Console",fallbackMessage:"The Google Search Console module is loading.",children:e.jsx(EA,{})})});if(t==="supply-chain")return e.jsx(lr,{redirectTo:"/admin-login",children:e.jsx(IJ,{})});if(t==="compliance-lockdown")return e.jsx(lr,{redirectTo:"/admin-login",children:e.jsx($J,{})});if(t==="rgm-compliance")return e.jsx(DJ,{});if(t==="guardian-portal")return e.jsx(MJ,{});if(t==="exec-financial")return e.jsx(BJ,{});if(t==="edexpress")return e.jsx(qt,{moduleName:"EDExpress Gateway",fallbackMessage:"The EDExpress Federal Aid Gateway is performing a secure data sync.",children:e.jsx(GJ,{})});if(t==="wix-studio-export")return e.jsx(qt,{moduleName:"Wix Studio Export",fallbackMessage:"The Wix Studio Global Export module is performing a secure data sync.",children:e.jsx(VJ,{})});if(t==="google-meta-sync")return e.jsx(qt,{moduleName:"Google Meta Sync",fallbackMessage:"The Google Business Profile Meta Sync module is loading.",children:e.jsx(ZJ,{})});if(t==="robots-txt-generator")return e.jsx(qt,{moduleName:"robots.txt Generator",fallbackMessage:"The robots.txt Generator & Validator module is loading.",children:e.jsx(YJ,{})});if(t==="ga4-integration")return e.jsx(qt,{moduleName:"GA4 Integration",fallbackMessage:"The Google Analytics 4 Integration module is loading.",children:e.jsx(AA,{})});if(t==="gsc-integration")return e.jsx(qt,{moduleName:"Google Search Console",fallbackMessage:"The Google Search Console module is loading.",children:e.jsx(EA,{})});if(t==="ahrefs-backlinks")return e.jsx(qt,{moduleName:"Ahrefs Backlink Monitor",fallbackMessage:"The Ahrefs Backlink Monitor module is loading.",children:e.jsx(KJ,{})});if(t==="career-bridge")return e.jsx(qt,{moduleName:"Career Bridge Smart Elite",fallbackMessage:"The Career Bridge Smart Elite module is loading.",children:e.jsx(QJ,{})});if(t==="regulatory-reporting"||t==="federal-compliance"||t==="clinical-safety")return e.jsx(qt,{moduleName:"Regulatory Intelligence Engine",fallbackMessage:"The Regulatory Intelligence Engine is loading.",children:e.jsx(JJ,{})});if(t==="dol-hour-relay")return e.jsx(qt,{moduleName:"WA DOL Hour Submission Relay",fallbackMessage:"The WA DOL Hour Submission Relay is loading.",children:e.jsx(XJ,{})});if(t==="loa-management")return e.jsx(qt,{moduleName:"LOA Management",fallbackMessage:"The Leave of Absence Management module is loading.",children:e.jsx(eX,{})});if(t==="gala-fundraiser")return e.jsx(qt,{moduleName:"Gala & Fundraiser",fallbackMessage:"The Annual Industry Gala & Foundation Fundraiser module is loading.",children:e.jsx(tX,{})});if(t==="foundation-gift-shop")return e.jsx(qt,{moduleName:"Foundation Gift Shop",fallbackMessage:"The Zorganics Foundation Gift Shop is loading.",children:e.jsx(sX,{})});if(t==="retargeting-conversion")return e.jsx(qt,{moduleName:"Retargeting & Conversion",fallbackMessage:"The Global Retargeting & Conversion Tracking module is loading.",children:e.jsx(nX,{})});if(t==="ab-testing")return e.jsx(qt,{moduleName:"A/B Testing",fallbackMessage:"The A/B Testing & Campaign Optimization module is loading.",children:e.jsx(aX,{})});if(t==="sovereign-os")return e.jsx(qt,{moduleName:"Sovereign Multi-Site OS",fallbackMessage:"The Sovereign Multi-Site OS is loading.",children:e.jsx(rX,{})});if(t==="ai-scan-portal")return e.jsx(qt,{moduleName:"AI Scan Results Portal",fallbackMessage:"The AI Scan Results Portal is loading.",children:e.jsx(iX,{})});if(t==="escalation-governance")return e.jsx(qt,{moduleName:"Autonomous Escalation Governance",fallbackMessage:"The Autonomous Escalation Governance module is loading.",children:e.jsx(oX,{})});if(t==="franchise")return e.jsx(hJ,{});if(t==="student-portal")return e.jsx(xJ,{});if(t==="program-profiles")return e.jsx(fJ,{programId:o||void 0});if(t==="partner-portal")return e.jsx(wA,{});if(t==="ecosystem")return e.jsx(NA,{});if(t==="master-bridge")return e.jsx(_A,{});if(t==="compliance")return e.jsx(kA,{});if(t==="partner-portal")return e.jsx(wA,{});if(t==="ecosystem")return e.jsx(NA,{});if(t==="master-bridge")return e.jsx(_A,{});if(t==="compliance")return e.jsx(kA,{});if(t==="location-mgmt")return e.jsx(pJ,{});if(l&&!c(t))return e.jsx("section",{className:"py-16 lg:py-24",children:e.jsxs("div",{className:"flex flex-col items-center justify-center text-center",children:[e.jsx("div",{className:"w-20 h-20 rounded-2xl bg-gray-100 flex items-center justify-center mb-6",children:e.jsx(Xe,{size:36,className:"text-gray-400"})}),e.jsx("h2",{className:"font-display text-2xl font-bold text-gray-900 mb-2",children:"Section Restricted"}),e.jsxs("p",{className:"text-gray-500 max-w-md mb-4",children:["The ",e.jsx("span",{className:"font-semibold",children:TA[t]})," section is not available for your role."]}),e.jsxs("div",{className:"flex items-center gap-2 px-4 py-2 bg-gray-50 rounded-lg border border-gray-200",children:[e.jsx(Tt,{size:16,className:"text-gray-400"}),e.jsxs("span",{className:"text-sm text-gray-600",children:["Signed in as ",e.jsx("span",{className:"font-semibold",children:u==null?void 0:u.fullName})," (",u==null?void 0:u.role,")"]})]}),e.jsx("p",{className:"text-xs text-gray-400 mt-4",children:"Contact your administrator to request access to this section."})]})});switch(t){case"dashboard":return e.jsx(lr,{fallback:e.jsx(Rv,{label:"Program Progress Dashboard"}),children:e.jsx(jA,{})});case"lms":return e.jsx(rJ,{});case"instructor-lms":return e.jsx(iJ,{});case"audit":return e.jsx(oJ,{});case"financial":return e.jsx(lJ,{});case"agency":return e.jsx(cJ,{});case"staff":return e.jsx(dJ,{});case"google":return e.jsx(lr,{redirectTo:"/admin-login",children:e.jsx(uJ,{})});case"pos":return e.jsx(lr,{redirectTo:"/admin-login",children:e.jsx(mJ,{})});case"gradebook":return e.jsx(lr,{redirectTo:"/admin-login",children:e.jsx(jJ,{})});default:return e.jsx(lr,{fallback:e.jsx(Rv,{label:"Program Progress Dashboard"}),children:e.jsx(jA,{})})}},C=n&&s==="institute"&&!jX.includes(t)&&!w,E=t==="campus-home",P=TA[t]||"Dashboard",F=vX[t]||"Module";return w?e.jsxs("div",{className:"min-h-screen",style:{backgroundColor:"#FAF6EE"},children:[j&&e.jsx(aA,{}),e.jsx(d.Suspense,{fallback:e.jsx("div",{className:"z-site-authority-fallback",style:{minHeight:"clamp(320px, 34vw, 560px)",background:"#3B0A11"}}),children:e.jsx(vA,{})}),e.jsx(d.Suspense,{fallback:e.jsx(k0,{}),children:e.jsx(aJ,{})}),e.jsx(lA,{}),e.jsx(uA,{}),e.jsx(pA,{})]}):e.jsxs("div",{className:"min-h-screen",style:{backgroundColor:"#FAF6EE"},children:[j&&e.jsx(aA,{}),f==="zlp"&&e.jsx(PA,{mode:"zlp",identity:(x==null?void 0:x.fullName)||(u==null?void 0:u.fullName)||"Authenticated Session",onSignOut:()=>S("zlp")}),f==="zip"&&e.jsx(PA,{mode:"zip",identity:"Approved Partner · Industry Session",onSignOut:()=>S("zip")}),C&&e.jsx(d.Suspense,{fallback:e.jsx("div",{className:"z-site-authority-fallback",style:{minHeight:"clamp(320px, 34vw, 560px)",background:"#3B0A11"}}),children:e.jsx(vA,{})}),C&&e.jsx(d.Suspense,{fallback:e.jsx(k0,{}),children:e.jsx(nJ,{})}),!C&&!E&&e.jsxs("div",{className:"z-module-logo-strip",role:"banner","aria-label":`${P} â ${F}`,children:[e.jsx("img",{src:FA,alt:"Zorganics Institute"}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("div",{className:"z-module-name truncate",children:P}),e.jsx("div",{className:"z-module-sub",children:F})]}),e.jsxs("div",{className:"ml-auto hidden sm:flex items-center gap-2",children:[e.jsx("div",{className:"h-1 w-20 rounded-full",style:{background:"linear-gradient(90deg, #D4AF37, #E6D2A0)"}}),e.jsx("span",{style:{fontFamily:"'Playfair Display', Georgia, serif",fontSize:"10px",fontWeight:700,color:"#B8962E",letterSpacing:"0.08em",textTransform:"uppercase"},children:"Zorganics Institute"}),e.jsx("div",{className:"h-1 w-20 rounded-full",style:{background:"linear-gradient(90deg, #E6D2A0, #D4AF37)"}})]})]}),e.jsxs("main",{id:"main-content",className:"max-w-[1600px] mx-auto px-4 lg:px-8",role:"main",style:{backgroundColor:"#FAF6EE"},children:[f==="public"&&!C&&e.jsx(RQ,{}),e.jsx(d.Suspense,{fallback:e.jsx(k0,{}),children:_()})]}),e.jsx(lA,{}
1227),!E&&e.jsx("div",{className:"z-persistent-logo",style:{top:"80px",left:"16px",width:"48px",height:"48px"},onClick:()=>{a("dashboard"),window.scrollTo({top:0,behavior:"smooth"})},title:"Zorganics Institute â Return to Dashboard",role:"button",tabIndex:0,"aria-label":"Zorganics Institute logo â click to return to Dashboard",onKeyDown:I=>{(I.key==="Enter"||I.key===" ")&&(a("dashboard"),window.scrollTo({top:0,behavior:"smooth"}))},children:e.jsx("img",{src:FA,alt:"Zorganics Institute",draggable:!1})}),e.jsx(FQ,{}),e.jsx(uA,{}),e.jsx(pA,{})]})},S0={auditDocExpiration:!0,naccasComplianceDrop:!0,studentHoursThreshold:!0,financialAlerts:!0,systemAnnouncements:!0,emailEnabled:!0,inAppEnabled:!0},J2={emailsSent:0,emailErrors:[],emailEnabled:!0,lastChecked:null},CX=d.createContext({notifications:[],unreadCount:0,preferences:S0,emailStatus:J2,loading:!1,prefsLoading:!1,fetchNotifications:async()=>{},checkForNewNotifications:async()=>{},markAsRead:async()=>{},markAllAsRead:async()=>{},deleteNotification:async()=>{},updatePreferences:async()=>({success:!1}),fetchPreferences:async()=>{}});function DA(t){return{id:t.id,type:t.type,severity:t.severity,title:t.title,message:t.message,section:t.section||"",metadata:t.metadata||{},isRead:t.is_read??t.isRead??!1,emailSent:t.email_sent??t.emailSent??!1,emailSentAt:t.email_sent_at??t.emailSentAt??null,createdAt:t.created_at??t.createdAt}}const AX=({children:t})=>{const{user:s,isAuthenticated:n}=kn(),[a,r]=d.useState([]),[i,o]=d.useState(S0),[l,c]=d.useState(J2),[u,p]=d.useState(!1),[m,x]=d.useState(!1),h=d.useRef(null),y=d.useRef(!1),v=a.filter(_=>!_.isRead).length,g=d.useCallback(async()=>{if(s){p(!0);try{const{data:_,error:C}=await O.from("notifications").select("*").eq("user_id",s.id).order("created_at",{ascending:!1}).limit(50);!C&&_&&r(_.map(DA))}catch(_){console.error("Error fetching notifications:",_)}finally{p(!1)}}},[s]),N=d.useCallback(async()=>{if(s)try{const _=window.location.origin,{data:C,error:E}=await O.functions.invoke("check-notifications",{body:{userId:s.id,userEmail:s.email,checkType:"all",appUrl:_}});!E&&C&&(c({emailsSent:C.emailsSent||0,emailErrors:C.emailErrors||[],emailEnabled:C.emailEnabled??!0,lastChecked:new Date().toISOString()}),C.notifications&&r(C.notifications.map(DA)),await g())}catch(_){console.error("Error checking notifications:",_)}},[s,g]),b=d.useCallback(async _=>{try{const{error:C}=await O.from("notifications").update({is_read:!0,read_at:new Date().toISOString()}).eq("id",_);C||r(E=>E.map(P=>P.id===_?{...P,isRead:!0}:P))}catch(C){console.error("Error marking notification as read:",C)}},[]),f=d.useCallback(async()=>{if(s)try{const{error:_}=await O.from("notifications").update({is_read:!0,read_at:new Date().toISOString()}).eq("user_id",s.id).eq("is_read",!1);_||r(C=>C.map(E=>({...E,isRead:!0})))}catch(_){console.error("Error marking all as read:",_)}},[s]),j=d.useCallback(async _=>{try{const{error:C}=await O.from("notifications").delete().eq("id",_);C||r(E=>E.filter(P=>P.id!==_))}catch(C){console.error("Error deleting notification:",C)}},[]),S=d.useCallback(async()=>{if(s){x(!0);try{const{data:_,error:C}=await O.from("notification_preferences").select("*").eq("user_id",s.id).maybeSingle();o(!C&&_?{id:_.id,auditDocExpiration:_.audit_doc_expiration,naccasComplianceDrop:_.naccas_compliance_drop,studentHoursThreshold:_.student_hours_threshold,financialAlerts:_.financial_alerts,systemAnnouncements:_.system_announcements,emailEnabled:_.email_enabled,inAppEnabled:_.in_app_enabled}:S0)}catch(_){console.error("Error fetching preferences:",_)}finally{x(!1)}}},[s]),w=d.useCallback(async _=>{if(!s)return{success:!1,error:"Not authenticated"};const C={...i,..._};try{const E={user_id:s.id,user_email:s.email,audit_doc_expiration:C.auditDocExpiration,naccas_compliance_drop:C.naccasComplianceDrop,student_hours_threshold:C.studentHoursThreshold,financial_alerts:C.financialAlerts,system_announcements:C.systemAnnouncements,email_enabled:C.emailEnabled,in_app_enabled:C.inAppEnabled,updated_at:new Date().toISOString()},{error:P}=await O.from("notification_preferences").upsert(E,{onConflict:"user_id"});return P?(console.error("Error updating preferences:",P),{success:!1,error:"Failed to save preferences"}):(o(C),{success:!0})}catch(E){return{success:!1,error:E.message||"An unexpected error occurred"}}},[s,i]);return d.useEffect(()=>{n&&s&&!y.current&&(y.current=!0,S(),N()),n||(y.current=!1,r([]),o(S0),c(J2))},[n,s,S,N]),d.useEffect(()=>(n&&s&&(h.current=setInterval(()=>{N()},5*60*1e3)),()=>{h.current&&(clearInterval(h.current),h.current=null)}),[n,s,N]),e.jsx(CX.Provider,{value:{notifications:a,unreadCount:v,preferences:i,emailStatus:l,loading:u,prefsLoading:m,fetchNotifications:g,checkForNewNotifications:N,markAsRead:b,markAllAsRead:f,deleteNotification:j,updatePreferences:w,fetchPreferences:S},children:t})},nn=()=>{const{pathname:t}=ai(),s=UW(t),n=s?"program-profiles":iR(t);return e.jsx(vI,{children:e.jsx(np,{children:e.jsx(uI,{children:e.jsx(hI,{children:e.jsx(sK,{children:e.jsx(AX,{children:e.jsx(cR,{routeSection:n,routeProgramId:s==null?void 0:s.programId,children:e.jsx(SX,{})})})})})})})})},UI=()=>{const t=ai();return d.useEffect(()=>{console.error("404 Error: User attempted to access non-existent route:",t.pathname)},[t.pathname]),e.jsx("div",{className:"min-h-screen flex items-center justify-center bg-background",children:e.jsxs("div",{className:"text-center p-8 rounded-lg border border-border bg-card shadow-md animate-slide-in",children:[e.jsx("h1",{className:"text-5xl font-bold mb-6 text-primary",children:"404"}),e.jsx("p",{className:"text-xl text-card-foreground mb-6",children:"Page not found"}),e.jsx("a",{href:"/",className:"text-primary hover:text-primary/80 underline transition-colors",children:"Return to Home"})]})})},X2=[{value:"employed",label:"Employed Full-Time",icon:IP,description:"Working 30+ hours per week",color:"emerald"},{value:"employed_part_time",label:"Employed Part-Time",icon:dt,description:"Working less than 30 hours per week",color:"teal"}
1227,{value:"self_employed",label:"Self-Employed",icon:Ws,description:"Running my own business or freelancing",color:"blue"},{value:"military",label:"Military Service",icon:Tt,description:"Active duty or reserve military service",color:"indigo"},{value:"education",label:"Continuing Education",icon:_t,description:"Enrolled in further education or training",color:"violet"},{value:"unemployed",label:"Unemployed â Seeking Work",icon:zt,description:"Currently looking for employment",color:"amber"},{value:"not_in_labor_force",label:"Not in Labor Force",icon:Bi,description:"Not currently seeking employment",color:"gray"}],EX=t=>t?new Date(t).toLocaleDateString("en-US",{month:"long",day:"numeric",year:"numeric"}):"",FX=({form:t,setForm:s,errors:n,setErrors:a})=>{const[r,i]=d.useState(!1),o=(l,c,u,p)=>{if(l==="hourly"){const m=parseFloat(c),x=parseFloat(u);if(m>0&&x>0)return(m*x*13).toFixed(2)}else if(l==="annual"){const m=parseFloat(p);if(m>0)return(m/4).toFixed(2)}return""};return d.useEffect(()=>{if(t.wageInputMode!=="quarterly"){const l=o(t.wageInputMode,t.hourlyRate,t.hoursPerWeek,t.annualSalary);l&&(s(c=>({...c,wagesQuarterly:l})),a(c=>({...c,wagesQuarterly:""})))}},[t.wageInputMode,t.hourlyRate,t.hoursPerWeek,t.annualSalary]),e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center justify-between mb-2",children:[e.jsxs("label",{className:"block text-sm font-semibold text-gray-800",children:["Quarterly Wages (Gross) ",e.jsx("span",{className:"text-red-500",children:"*"})]}),e.jsxs("button",{type:"button",onClick:()=>i(!r),className:"flex items-center gap-1.5 text-xs font-medium text-[#1a365d] hover:text-[#2d5a87] transition-colors",children:[e.jsx($P,{size:13}),r?"Hide":"Need help calculating?"]})]}),r&&e.jsxs("div",{className:"mb-4 p-4 bg-blue-50 rounded-xl border border-blue-200 animate-in fade-in duration-200",children:[e.jsxs("p",{className:"text-xs font-semibold text-blue-800 mb-3 flex items-center gap-1.5",children:[e.jsx(Ny,{size:13})," Wage Calculator â Choose your preferred input method"]}),e.jsx("div",{className:"flex gap-2 mb-3",children:["quarterly","hourly","annual"].map(l=>e.jsx("button",{type:"button",onClick:()=>s(c=>({...c,wageInputMode:l})),className:`flex-1 px-3 py-2 rounded-lg text-xs font-semibold transition-all ${t.wageInputMode===l?"bg-[#1a365d] text-white shadow-md":"bg-white text-gray-600 border border-gray-200 hover:border-gray-300"}`,children:l==="quarterly"?"Enter Quarterly":l==="hourly"?"Hourly Rate":"Annual Salary"},l))}),t.wageInputMode==="hourly"&&e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{children:[e.jsx("label",{className:"text-[11px] font-medium text-blue-700 mb-1 block",children:"Hourly Rate ($)"}),e.jsx("input",{type:"number",step:"0.01",min:"0",value:t.hourlyRate,onChange:l=>s(c=>({...c,hourlyRate:l.target.value})),placeholder:"e.g., 25.00",className:"w-full px-3 py-2.5 border border-blue-200 rounded-lg text-sm font-mono bg-white focus:outline-none focus:ring-2 focus:ring-blue-300"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-[11px] font-medium text-blue-700 mb-1 block",children:"Hours per Week"}),e.jsx("input",{type:"number",min:"1",max:"80",value:t.hoursPerWeek,onChange:l=>s(c=>({...c,hoursPerWeek:l.target.value})),placeholder:"e.g., 40",className:"w-full px-3 py-2.5 border border-blue-200 rounded-lg text-sm font-mono bg-white focus:outline-none focus:ring-2 focus:ring-blue-300"})]}),t.hourlyRate&&t.hoursPerWeek&&e.jsx("div",{className:"col-span-2 p-2.5 bg-emerald-50 rounded-lg border border-emerald-200",children:e.jsxs("p",{className:"text-xs text-emerald-700",children:[e.jsxs("span",{className:"font-semibold",children:["$",t.hourlyRate,"/hr"]})," x ",e.jsxs("span",{className:"font-semibold",children:[t.hoursPerWeek," hrs/wk"]})," x 13 weeks = ",e.jsxs("span",{className:"font-bold text-emerald-800",children:["$",o("hourly",t.hourlyRate,t.hoursPerWeek,""),"/quarter"]})]})})]}),t.wageInputMode==="annual"&&e.jsxs("div",{children:[e.jsx("label",{className:"text-[11px] font-medium text-blue-700 mb-1 block",children:"Annual Salary ($)"}),e.jsx("input",{type:"number",step:"0.01",min:"0",value:t.annualSalary,onChange:l=>s(c=>({...c,annualSalary:l.target.value})),placeholder:"e.g., 52000.00",className:"w-full px-3 py-2.5 border border-blue-200 rounded-lg text-sm font-mono bg-white focus:outline-none focus:ring-2 focus:ring-blue-300"}),t.annualSalary&&e.jsx("div",{className:"mt-2 p-2.5 bg-emerald-50 rounded-lg border border-emerald-200",children:e.jsxs("p",{className:"text-xs text-emerald-700",children:[e.jsxs("span",{className:"font-semibold",children:["$",parseFloat(t.annualSalary).toLocaleStr
1227ing(),"/year"]})," ÷ 4 = ",e.jsxs("span",{className:"font-bold text-emerald-800",children:["$",o("annual","","",t.annualSalary),"/quarter"]})]})})]})]}),e.jsxs("div",{className:"relative",children:[e.jsx("span",{className:"absolute left-4 top-1/2 -translate-y-1/2 text-gray-500 font-semibold text-sm",children:"$"}),e.jsx("input",{type:"number",step:"0.01",min:"0",value:t.wagesQuarterly,onChange:l=>{s(c=>({...c,wagesQuarterly:l.target.value,wageInputMode:"quarterly"})),a(c=>({...c,wagesQuarterly:""}))},placeholder:"0.00",className:`w-full pl-9 pr-4 py-3.5 border rounded-xl text-sm font-mono focus:outline-none focus:ring-2 focus:ring-[#1a365d]/30 focus:border-[#1a365d] transition-colors ${n.wagesQuarterly?"border-red-300 bg-red-50":"border-gray-200"}`})]}),e.jsx("p",{className:"text-xs text-gray-500 mt-2",children:"Your total gross earnings for the most recent 3-month period (quarter)."}),n.wagesQuarterly&&e.jsxs("p",{className:"text-red-500 text-xs mt-1.5 flex items-center gap-1",children:[e.jsx(ve,{size:12})," ",n.wagesQuarterly]})]})},TX=({currentStep:t,totalSteps:s,labels:n})=>e.jsx("div",{className:"flex items-center justify-between mb-8",children:n.map((a,r)=>{const i=r+1,o=i===t,l=i<t;return e.jsxs(re.Fragment,{children:[e.jsxs("div",{className:"flex flex-col items-center",children:[e.jsx("div",{className:`w-10 h-10 rounded-full flex items-center justify-center text-sm font-bold transition-all duration-300 ${l?"bg-emerald-500 text-white":o?"bg-[#1a365d] text-white ring-4 ring-[#1a365d]/20":"bg-gray-100 text-gray-400"}`,children:l?e.jsx(pt,{size:18}):i}),e.jsx("span",{className:`text-[10px] font-semibold mt-1.5 transition-colors ${o?"text-[#1a365d]":l?"text-emerald-600":"text-gray-400"}`,children:a})]}),r<s-1&&e.jsx("div",{className:`flex-1 h-0.5 mx-2 rounded transition-colors duration-300 ${i<t?"bg-emerald-400":"bg-gray-200"}`})]},r)})}),PX=({record:t,milestone:s,formData:n,isUpdate:a,onUpdateResponse:r,otherMilestoneAvailable:i,onSwitchMilestone:o,otherMilestoneLabel:l})=>{var m;const c=s==="q2"?"2nd Quarter":"4th Quarter",u=["employed","employed_part_time","self_employed","military"].includes(n.status),p=((m=X2.find(x=>x.value===n.status))==null?void 0:m.label)||n.status;return e.jsxs("div",{className:"text-center py-6 sm:py-10 animate-in fade-in duration-500",children:[e.jsxs("div",{className:"relative inline-block mb-6",children:[e.jsx("div",{className:"w-24 h-24 rounded-full bg-gradient-to-br from-emerald-400 to-emerald-600 flex items-center justify-center mx-auto shadow-lg shadow-emerald-200 animate-in zoom-in duration-500",children:e.jsx(pt,{size:48,className:"text-white"})}),e.jsx("div",{className:"absolute -top-2 -right-2 w-8 h-8 rounded-full bg-amber-400 flex items-center justify-center shadow-md animate-in zoom-in duration-700",children:e.jsx(Qe,{size:16,className:"text-white"})})]}),e.jsx("h2",{className:"text-2xl sm:text-3xl font-bold text-gray-900 mb-2",children:a?"Response Updated!":"Thank You!"}),e.jsxs("p",{className:"text-gray-600 max-w-lg mx-auto text-sm sm:text-base leading-relaxed",children:["Your ",c," employment data has been ",a?"updated":"submitted"," successfully. This information helps maintain WIOA compliance and improve outcomes for future students."]}),e.jsxs("div",{className:"mt-8 max-w-md mx-auto bg-white rounded-2xl border border-gray-200 shadow-sm overflow-hidden text-left",children:[e.jsx("div",{className:"px-5 py-3 bg-gradient-to-r from-emerald-50 to-teal-50 border-b border-emerald-100",children:e.jsxs("p",{className:"text-xs font-bold text-emerald-800 uppercase tracking-wider flex items-center gap-1.5",children:[e.jsx(Kt,{size:12})," Your Response Summary"]})}),e.jsxs("div",{className:"p-5 space-y-3",children:[e.jsxs("div",{className:"flex justify-between items-center",children:[e.jsx("span",{className:"text-xs text-gray-500",children:"Milestone"}),e.jsxs("span",{className:"text-sm font-semibold text-[#1a365d]",children:[c," Post-Exit"]})]}),e.jsxs("div",{className:"flex justify-between items-center",children:[e.jsx("span",{className:"text-xs text-gray-500",children:"Employment Status"}),e.jsx("span",{className:"text-sm font-semibold text-gray-900",children:p})]}),u&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"h-px bg-gray-100"}),e.jsxs("div",{className:"flex justify-between items-center",children:[e.jsx("span",{className:"text-xs text-gray-500",children:"Employer"}),e.jsx("span",{className:"text-sm font-medium text-gray-900",children:n.employer})]}),e.jsxs("div",{className:"flex justify-between items-center",children:[e.jsx("span",{className:"text-xs text-gray-500",children:"Job Title"}),e.jsx("span",{className:"text-sm font-medium text-gray-900",children:n.jobTitle})]}),e.jsxs("div",{className:"flex justify-between items-center",children:[e.jsx("span",{className:"text-xs text-gray-500",children:"Quarterly Wages"}),e.jsxs("span",{className:"text-sm font-mono font-bold text-emerald-700",children:["$",parseFloat(n.wagesQuarterly).toLocaleStr
1227ing("en-US",{minimumFractionDigits:2})]})]}),e.jsxs("div",{className:"flex justify-between items-center",children:[e.jsx("span",{className:"text-xs text-gray-500",children:"Training-Related"}),e.jsx("span",{className:`text-sm font-semibold ${n.relatedField?"text-emerald-600":"text-amber-600"}`,children:n.relatedField?"Yes":"No"})]})]}),e.jsx("div",{className:"h-px bg-gray-100"}),e.jsxs("div",{className:"flex justify-between items-center",children:[e.jsx("span",{className:"text-xs text-gray-500",children:"Submitted"}),e.jsx("span",{className:"text-xs font-mono text-gray-600",children:new Date().toLocaleString()})]})]})]}),e.jsxs("div",{className:"mt-8 flex flex-col sm:flex-row gap-3 max-w-md mx-auto",children:[e.jsxs("button",{onClick:r,className:"flex-1 flex items-center justify-center gap-2 px-5 py-3 bg-gray-100 text-gray-700 rounded-xl text-sm font-semibold hover:bg-gray-200 transition-colors",children:[e.jsx(GP,{size:15})," Update My Response"]}),i&&e.jsxs("button",{onClick:o,className:"flex-1 flex items-center justify-center gap-2 px-5 py-3 bg-gradient-to-r from-[#1a365d] to-[#2d5a87] text-white rounded-xl text-sm font-semibold hover:from-[#15294a] hover:to-[#244d75] transition-all shadow-md",children:["Complete ",l," ",e.jsx(Vt,{size:15})]})]}),e.jsx("div",{className:"mt-8 max-w-md mx-auto p-3 bg-gray-50 rounded-lg border border-gray-200",children:e.jsxs("p",{className:"text-[10px] text-gray-500 flex items-center justify-center gap-1.5",children:[e.jsx(Xe,{size:10})," Your data is protected under FERPA (20 USC § 1232g) and reported only in aggregate."]})})]})},DX=()=>{var G;sn();const{token:t}=Wo(),[s]=cc(),n=s.get("milestone"),[a,r]=d.useState(null),[i,o]=d.useState(!0),[l,c]=d.useState(null),[u,p]=d.useState(!1),[m,x]=d.useState("q2"),[h,y]=d.useState(1),[v,g]=d.useState(!1),[N,b]=d.useState(!1),[f,j]=d.useState(null),S=d.useRef(null),[w,_]=d.useState({status:"",employer:"",jobTitle:"",wagesQuarterly:"",relatedField:null,wageInputMode:"quarterly",hourlyRate:"",hoursPerWeek:"",annualSalary:"",additionalComments:""}),[C,E]=d.useState({}),P=["employed","employed_part_time","self_employed","military"].includes(w.status),F=P?3:2,I=P?["Status","Details","Review"]:["Status","Review"],D=W=>{const X=new Date(W),Q=new Date,K=(Q.getFullYear()-X.getFullYear())*12+(Q.getMonth()-X.getMonth());return K<4?"pre-q2":K<10?"q2":"q4"};d.useEffect(()=>{(async()=>{if(!t){c("Invalid survey link. Please check the URL and try again."),o(!1);return}const{data:X,error:Q}=await O.from("wioa_outcomes").select("*").eq("survey_token",t).single();if(Q||!X){c("Survey not found. This link may have expired or is invalid."),o(!1);return}if(r(X),n)x(n);
1227else{const ke=D(X.graduation_date);x(ke==="q4"?"q4":"q2")}const K=n||(D(X.graduation_date)==="q4"?"q4":"q2"),se=K==="q2"?X.q2_status:X.q4_status,Y=K==="q2"?X.q2_employer:X.q4_employer,J=K==="q2"?X.q2_job_title:X.q4_job_title,te=K==="q2"?X.q2_wages_quarterly:X.q4_wages_quarterly,pe=K==="q2"?X.q2_related_field:X.q4_related_field,Fe=K==="q2"?X.q2_survey_completed_at:X.q4_survey_completed_at;se&&se!=="pending"&&(_(ke=>({...ke,status:se,employer:Y||"",jobTitle:J||"",wagesQuarterly:te?(te/100).toFixed(2):"",relatedField:pe})),Fe&&b(!0)),o(!1)})()},[t,n]);const L=W=>{if(!a)return;const X=W==="q2"?a.q2_status:a.q4_status,Q=W==="q2"?a.q2_employer:a.q4_employer,K=W==="q2"?a.q2_job_title:a.q4_job_title,se=W==="q2"?a.q2_wages_quarterly:a.q4_wages_quarterly,Y=W==="q2"?a.q2_related_field:a.q4_related_field,J=W==="q2"?a.q2_survey_completed_at:a.q4_survey_completed_at;X&&X!=="pending"?(_(te=>({...te,status:X,employer:Q||"",jobTitle:K||"",wagesQuarterly:se?(se/100).toFixed(2):"",relatedField:Y})),b(!!J)):(_({status:"",employer:"",jobTitle:"",wagesQuarterly:"",relatedField:null,wageInputMode:"quarterly",hourlyRate:"",hoursPerWeek:"",annualSalary:"",additionalComments:""}),b(!1)),y(1),g(!1),E({})},V=W=>{const X={};return W===1&&(w.status||(X.status="Please select your current employment status")),W===2&&P&&(w.employer.trim()||(X.employer="Please enter your employer name"),w.jobTitle.trim()||(X.jobTitle="Please enter your job title"),
1227(!w.wagesQuarterly||parseFloat(w.wagesQuarterly)<=0)&&(X.wagesQuarterly="Please enter your quarterly wages"),w.relatedField===null&&(X.relatedField="Please indicate if your position is training-related")),E(X),Object.keys(X).length===0},B=()=>{var W;V(h)&&(P&&h===1?y(2):P&&h===2?y(3):!P&&h===1?y(2):z(),(W=S.current)==null||W.scrollTo({top:0,behavior:"smooth"}))},A=()=>{var W;h>1&&(y(h-1),(W=S.current)==null||W.scrollTo({top:0,behavior:"smooth"}))},z=async()=>{if(!a)return;p(!0);const W=w.wagesQuarterly?Math.round(parseFloat(w.wagesQuarterly)*100):null,X=w.status==="employed_part_time"||w.status==="self_employed"?"employed":w.status,Q={[`${m}_status`]:X,[`${m}_employer`]:P?w.employer:null,[`${m}_job_title`]:P?w.jobTitle:null,[`${m}_wages_quarterly`]:P?W:null,[`${m}_related_field`]:P?w.relatedField:null,[`${m}_collected_at`]:new Date().toISOString(),[`${m}_survey_completed_at`]:new Date().toISOString(),[`${m}_data_source`]:"self-reported",updated_at:new Date().toISOString()};if(w.additionalComments){const Y=a.notes||"",J=`[${m.toUpperCase()} Self-Report ${new Date().toLocaleDateString()}] ${w.additionalComments}`;Q.notes=Y?`${Y} 1228${J}`:J}const{error:K}=await O.from("wioa_outcomes").update(Q).eq("survey_token",t);if(K){console.error("Survey submission error:",K),E({submit:"There was an error submitting your response. Please try again."}),p(!1);return}const{data:se}=await O.from("wioa_outcomes").select("*").eq("survey_token",t).single();se&&r(se),O.functions.invoke("wioa-followup-email",{body:{action:"send-confirmation",recipientEmail:a.email,recipientName:a.student_name,programName:a.program_name,milestone:m,employmentStatus:w.status,employer:P?w.employer:null,jobTitle:P?w.jobTitle:null,wagesQuarterly:P?W:null,relatedField:P?w.relatedField:null,surveyToken:a.survey_token,siteUrl:window.location.origin}}).catch(Y=>console.error("Confirmation email failed:",Y)),j({...w}),g(!0),p(!1),window.scrollTo({top:0,behavior:"smooth"})},M=a?D(a.graduation_date):"pre-q2",R=a?M==="q2"||M==="q4"||!!a.q2_collected_at:!1,T=a?M==="q4"||!!a.q4_collected_at:!1;if(i)return e.jsx("div",{className:"min-h-screen bg-gradient-to-b from-slate-50 to-white flex items-center justify-center",children:e.jsxs("div",{className:"text-center",children:[e.jsx("div",{className:"relative",children:e.jsx("div",{className:"w-16 h-16 rounded-2xl bg-[#1a365d]/10 flex items-center justify-center mx-auto mb-4",children:e.jsx(de,{size:28,className:"text-[#1a365d] animate-spin"})})}),e.jsx("p",{className:"text-gray-600 font-medium",children:"Loading your survey..."}),e.jsx("p",{className:"text-xs text-gray-400 mt-1",children:"Verifying your unique access link"})]})});if(l||!a)return e.jsx("div",{className:"min-h-screen bg-gradient-to-b from-slate-50 to-white flex items-center justify-center p-4",children:e.jsx("div",{className:"max-w-md w-full",children:e.jsxs("div",{className:"bg-white rounded-2xl border border-gray-200 shadow-lg overflow-hidden",children:[e.jsxs("div",{className:"bg-gradient-to-r from-red-500 to-rose-500 p-6 text-center",children:[e.jsx("div",{className:"w-16 h-16 rounded-full bg-white/20 flex items-center justify-center mx-auto mb-3",children:e.jsx(ve,{size:32,className:"text-white"})}),e.jsx("h1",{className:"text-xl font-bold text-white",children:"Survey Not Found"})]}),e.jsxs("div",{className:"p-6",children:[e.jsx("p",{className:"text-gray-600 text-sm text-center mb-6",children:l||"Unable to load the survey."}),e.jsxs("div",{className:"p-4 bg-gray-50 rounded-xl border border-gray-200",children:[e.jsxs("p",{className:"text-sm font-semibold text-gray-700 mb-2 flex items-center gap-2",children:[e.jsx(Ny,{size:14})," Need help?"]}),e.jsxs("p",{className:"text-xs text-gray-500 leading-relaxed",children:["Contact Zorganics Institute at"," ",e.jsx("a",{href:"mailto:[email protected]",className:"text-[#1a365d] font-semibold hover:underline",children:"[email protected]"})," ","or call the administration office. Please have your student ID ready."]})]}),e.jsx("div",{className:"mt-4 p-3 bg-amber-50 rounded-lg border border-amber-200",children:e.jsxs("p",{className:"text-[11px] text-amber-700",children:[e.jsx("strong",{children:"Common reasons:"})," The link may have been truncated in your email client. Try copying the full URL from the email, or request a new survey link from the school."]})})]})]})})});a.q2_survey_completed_at&&a.q4_survey_completed_at,m==="q2"?a.q2_survey_completed_at:a.q4_survey_completed_at;const U=m==="q2"?"q4":"q2",q=U==="q2"?R:T,H=U==="q2"?!!a.q2_survey_completed_at:!!a.q4_survey_completed_at;return e.jsxs("div",{className:"min-h-screen bg-gradient-to-b from-slate-50 via-white to-slate-50",children:[e.jsxs("div",{className:"bg-gradient-to-r from-[#1a365d] via-[#234876] to-[#2d5a87] relative overflow-hidden",children:[e.jsxs("div",{className:"absolute inset-0 opacity-[0.07]",children:[e.jsx("div",{className:"absolute top-0 right-0 w-[500px] h-[500px] bg-white rounded-full -translate-y-1/2 translate-x-1/3"}),e.jsx("div",{className:"absolute bottom-0 left-0 w-80 h-80 bg-white rounded-full translate-y-1/2 -translate-x-1/4"})]}),e.jsxs("div",{className:"relative max-w-3xl mx-auto px-4 sm:px-6 py-7 sm:py-10",children:[e.jsxs("div",{className:"flex items-center gap-3 mb-5",children:[e.jsx("div",{className:"w-11 h-11 rounded-xl bg-white/15 backdrop-blur-sm flex items-center justify-center border border-white/20",children:e.jsx(_t,{size:22,className:"text-white"})}),e.jsxs("div",{children:[e.jsx("h2",{className:"text-white text-sm font-bold tracking-wide",children:"ZORGANICS INSTITUTE"}),e.jsx("p",{className:"text-blue-200/80 text-[10px] tracking-widest font-medium",children:"WIOA COMPLIANCE PORTAL"})]})]}),e.jsx("h1",{className:"text-2xl sm:text-3xl font-bold text-white mb-2",children:"Employment Outcome Survey"}),e.jsx("p",{className:"text-blue-200 text-sm sm:text-base max-w-xl leading-relaxed",children:"Help us track y
1228our career success. Your responses are required under the Workforce Innovation and Opportunity Act (WIOA)."}),e.jsx("div",{className:"mt-5 bg-white/10 backdrop-blur-sm rounded-xl p-4 border border-white/15",children:e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-3 gap-3 sm:gap-4",children:[e.jsxs("div",{className:"flex items-center gap-2.5",children:[e.jsx("div",{className:"w-8 h-8 rounded-lg bg-white/15 flex items-center justify-center shrink-0",children:e.jsx(yr,{size:14,className:"text-blue-200"})}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"text-blue-300/70 text-[9px] uppercase tracking-wider font-semibold",children:"Graduate"}),e.jsx("p",{className:"text-white font-semibold text-sm truncate",children:a.student_name})]})]}),e.jsxs("div",{className:"flex items-center gap-2.5",children:[e.jsx("div",{className:"w-8 h-8 rounded-lg bg-white/15 flex items-center justify-center shrink-0",children:e.jsx(_t,{size:14,className:"text-blue-200"})}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"text-blue-300/70 text-[9px] uppercase tracking-wider font-semibold",children:"Program"}),e.jsx("p",{className:"text-white font-semibold text-sm truncate",children:a.program_name})]})]}),e.jsxs("div",{className:"flex items-center gap-2.5",children:[e.jsx("div",{className:"w-8 h-8 rounded-lg bg-white/15 flex items-center justify-center shrink-0",children:e.jsx(At,{size:14,className:"text-blue-200"})}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"text-blue-300/70 text-[9px] uppercase tracking-wider font-semibold",children:"Graduated"}),e.jsx("p",{className:"text-white font-semibold text-sm",children:EX(a.graduation_date)})]})]})]})})]})]}),e.jsxs("div",{className:"max-w-3xl mx-auto px-4 sm:px-6 py-6 sm:py-8",ref:S,children:[e.jsx("div",{className:"flex gap-3 mb-6",children:["q2","q4"].map(W=>{const X=W==="q2"?R:T,Q=m===W,K=W==="q2"?a.q2_survey_completed_at:a.q4_survey_completed_at,se=W==="q2"?a.q2_collected_at:a.q4_collected_at;return e.jsxs("button",{onClick:()=>{X&&(x(W),L(W))},disabled:!X,className:`flex-1 p-3.5 sm:p-4 rounded-xl border-2 transition-all text-left ${Q?"border-[#1a365d] bg-[#1a365d]/5 shadow-sm":X?"border-gray-200 hover:border-gray-300 hover:bg-gray-50":"border-gray-100 opacity-40 cursor-not-allowed"}`,children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("p",{className:`text-xs font-bold uppercase tracking-wider ${Q?"text-[#1a365d]":"text-gray-500"}`,children:W==="q2"?"Q2 â 2nd Quarter":"Q4 â 4th Quarter"}),e.jsx("p",{className:"text-[11px] text-gray-500 mt-0.5",children:W==="q2"?"6 months post-exit":"12 months post-exit"})]}),K?e.jsxs("div",{className:"flex items-center gap-1 px-2 py-0.5 bg-emerald-100 rounded-full",children:[e.jsx(pt,{size:13,className:"text-emerald-600"}),e.jsx("span",{className:"text-[10px] font-semibold text-emerald-700",children:"Done"})]}):se?e.jsxs("div",{className:"flex items-center gap-1 px-2 py-0.5 bg-blue-100 rounded-full",children:[e.jsx(pt,{size:13,className:"text-blue-500"}),e.jsx("span",{className:"text-[10px] font-semibold text-blue-600",children:"Recorded"})]}):X?e.jsx(Nr,{size:18,className:"text-gray-400"}):e.jsx(Xe,{size:14,className:"text-gray-300"})]}),!X&&e.jsx("p",{className:"text-[10px] text-gray-400 mt-1",children:"Available at 10 months post-graduation"})]},W)})}),v&&f?e.jsx("div",{className:"bg-white rounded-2xl border border-gray-200 shadow-sm p-6 sm:p-8",children:e.jsx(PX,{record:a,milestone:m,formData:f,isUpdate:N,onUpdateResponse:()=>{g(!1),y(1),b(!0)},otherMilestoneAvailable:q&&!H,onSwitchMilestone:()=>{x(U),L(U)},otherMilestoneLabel:U==="q2"?"Q2 Survey":"Q4 Survey"})}):m==="q4"&&!T?e.jsxs("div",{className:"bg-white rounded-2xl border border-gray-200 shadow-sm p-8 text-center",children:[e.jsx("div",{className:"w-16 h-16 rounded-full bg-gray-100 flex items-center justify-center mx-auto mb-4",children:e.jsx(dt,{size:32,className:"text-gray-400"})}),e.jsx("h3",{className:"text-lg font-bold text-gray-700 mb-2",children:"Q4 Survey Not Yet Available"}),e.jsxs("p",{className:"text-sm text-gray-500 max-w-md mx-auto leading-relaxed",children:["The 4th quarter survey becomes available approximately 10 months after your graduation date.",!a.q2_survey_completed_at&&" Please complete the Q2 survey first."]}),!a.q2_survey_completed_at&&R&&e.jsxs("button",{onClick:()=>{x("q2"),L("q2")},className:"mt-4 inline-flex items-center gap-2 px-5 py-2.5 bg-[#1a365d] text-white rounded-lg text-sm font-semibold hover:bg-[#2d5a87] transition-colors",children:[e.jsx(Je,{size:14})," Go to Q2 Survey"]})]}):e.jsxs("div",{className:"bg-white rounded-2xl border border-gray-200 shadow-sm p-5 sm:p-8",children:[N&&h===1&&e.jsxs("div",{className:"mb-6 p-4 bg-blue-50 rounded-xl border border-blue-200 flex items-start gap-3",children:[e.jsx(Bi,{size:18,className:"text-blue-600 shrink-0 mt-0.5"}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-semibold text-blue-800",children:"Updating your previous response"}),e.jsx("p",{className:"text-xs text-blue-700 mt-1 leading-relaxed",children:"Your previous data is pre-filled below. Change any fields that need updating, then submit."})]})]}),e.jsx(TX,{currentStep:h,totalSteps:F,labels:I}),h===1&&e.jsxs("div",{className:"animate-in fade-in duration-300",children:[e.jsxs("div",{className:"mb-6",children:[e.jsx("h3",{className:"text-lg font-bold text-gray-900",children:"What is your current employment status?"}),e.jsxs("p",{className:"text-sm text-gray-500 mt-1",children:[m==="q2"?"6 months":"12 months"," after completing your program"]})]}),e.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-3",children:X2.map(W=>e.jsxs("button",{type:"button",onClick:()=>{_(X=>({...X,status:W.value})),E(X=>({...X,status:""}))},className:`flex items-start gap-3 p-4 rounded-xl border-2 text-left transition-all ${w.status===W.value?"border-[#1a365d] bg-[#1a365d]/5 ring-1 ring-[#1a365d]/20 shadow-sm":"border-gray-200 hover:border-gray-300 hover:bg-gray-50"}`,children:[e.jsx("div",{className:`w-10 h-10 rounded-lg flex items-center justify-center shrink-0 transition-colors ${w.status===W.value?"bg-[#1a365d] text-white":"bg-gray-100 text-gray-500"}`,children:e.jsx(W.icon,{size:18})}),e.jsxs("div",{children:[e.jsx("p",{className:`text-sm font-semibold ${w.status===W.value?"text-[#1a365d]":"text-gray-800"}`,children:W.label}),e.jsx("p",{className:"text-xs text-gray-500 mt-0.5",children:W.description})]})]},W.value))}),C.status&&e.jsxs("p",{className:"text-red-500 text-xs mt-3 flex items-center gap-1",children:[e.jsx(ve,{size:12})," ",C.status]})]}),h===2&&P&&e.jsxs("div",{className:"space-y-6 animate-in fade-in duration-300",children:[e.jsxs("div",{className:"mb-2",children:[e.jsxs("h3",{className:"text-lg font-bold text-gray-900 flex items-center gap-2",children:[e.jsx(Ws,{size:20,className:"text-[#1a365d]"}),"Employment Details"]}
1228),e.jsx("p",{className:"text-sm text-gray-500 mt-1",children:"Tell us about your current position"})]}),e.jsxs("div",{children:[e.jsxs("label",{className:"block text-sm font-semibold text-gray-800 mb-2",children:["Employer Name ",e.jsx("span",{className:"text-red-500",children:"*"})]}),e.jsx("input",{type:"text",value:w.employer,onChange:W=>{_(X=>({...X,employer:W.target.value})),E(X=>({...X,employer:""}))},placeholder:"e.g., Bellevue Skin Studio, Gene Juarez Salon",className:`w-full px-4 py-3.5 border rounded-xl text-sm focus:outline-none focus:ring-2 focus:ring-[#1a365d]/30 focus:border-[#1a365d] transition-colors ${C.employer?"border-red-300 bg-red-50":"border-gray-200"}`}),C.employer&&e.jsxs("p",{className:"text-red-500 text-xs mt-1.5 flex items-center gap-1",children:[e.jsx(ve,{size:12})," ",C.employer]})]}),e.jsxs("div",{children:[e.jsxs("label",{className:"block text-sm font-semibold text-gray-800 mb-2",children:["Job Title ",e.jsx("span",{className:"text-red-500",children:"*"})]}),e.jsx("input",{type:"text",value:w.jobTitle,onChange:W=>{_(X=>({...X,jobTitle:W.target.value})),E(X=>({...X,jobTitle:""}))},placeholder:"e.g., Licensed Esthetician, Massage Therapist",className:`w-full px-4 py-3.5 border rounded-xl text-sm focus:outline-none focus:ring-2 focus:ring-[#1a365d]/30 focus:border-[#1a365d] transition-colors ${C.jobTitle?"border-red-300 bg-red-50":"border-gray-200"}`}),C.jobTitle&&e.jsxs("p",{className:"text-red-500 text-xs mt-1.5 flex items-center gap-1",children:[e.jsx(ve,{size:12})," ",C.jobTitle]})]}),e.jsx(FX,{form:w,setForm:_,errors:C,setErrors:E}),e.jsxs("div",{children:[e.jsxs("label",{className:"block text-sm font-semibold text-gray-800 mb-3",children:["Is your current position in a field related to your training? ",e.jsx("span",{className:"text-red-500",children:"*"})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("button",{type:"button",onClick:()=>{_(W=>({...W,relatedField:!0})),E(W=>({...W,relatedField:""}))},className:`p-4 rounded-xl border-2 text-center transition-all ${w.relatedField===!0?"border-emerald-500 bg-emerald-50 ring-1 ring-emerald-200 shadow-sm":"border-gray-200 hover:border-gray-300 hover:bg-gray-50"}`,children:[e.jsx(pt,{size:28,className:`mx-auto mb-2 ${w.relatedField===!0?"text-emerald-600":"text-gray-300"}`}),e.jsx("p",{className:`text-sm font-semibold ${w.relatedField===!0?"text-emerald-700":"text-gray-600"}`,children:"Yes â Training Related"}),e.jsx("p",{className:"text-xs text-gray-500 mt-1",children:"My work uses skills from my program"})]}),e.jsxs("button",{type:"button",onClick:()=>{_(W=>({...W,relatedField:!1})),E(W=>({...W,relatedField:""}))},className:`p-4 rounded-xl border-2 text-center transition-all ${w.relatedField===!1?"border-amber-500 bg-amber-50 ring-1 ring-amber-200 shadow-sm":"border-gray-200 hover:border-gray-300 hover:bg-gray-50"}`,children:[e.jsx(Ke,{size:28,className:`mx-auto mb-2 ${w.relatedField===!1?"text-amber-600":"text-gray-300"}`}),e.jsx("p",{className:`text-sm font-semibold ${w.relatedField===!1?"text-amber-700":"text-gray-600"}`,children:"No â Different Field"}),e.jsx("p",{className:"text-xs text-gray-500 mt-1",children:"My work is in a different area"})]})]}),C.relatedField&&e.jsxs("p",{className:"text-red-500 text-xs mt-2 flex items-center gap-1",children:[e.jsx(ve,{size:12})," ",C.relatedField]})]})]}),(P&&h===3||!P&&h===2)&&e.jsxs("div",{className:"animate-in fade-in duration-300",children:[e.jsxs("div",{className:"mb-6",children:[e.jsxs("h3",{className:"text-lg font-bold text-gray-900 flex items-center gap-2",children:[e.jsx(ms,{size:20,className:"text-[#1a365d]"}),"Review & Submit"]}),e.jsx("p",{className:"text-sm text-gray-500 mt-1",children:"Please review your information before submitting"})]}),e.jsxs("div",{className:"bg-gray-50 rounded-xl border border-gray-200 overflow-hidden mb-6",children:[e.jsx("div",{className:"px-5 py-3 bg-gray-100 border-b border-gray-200",children:e.jsxs("p",{className:"text-xs font-bold text-gray-700 uppercase tracking-wider",children:[m==="q2"?"2nd Quarter":"4th Quarter"," Post-Exit Data"]})}),e.jsxs("div",{className:"p-5 space-y-3",children:[e.jsxs("div",{className:"flex justify-between items-center py-1",children:[e.jsx("span",{className:"text-sm text-gray-500",children:"Employment Status"}),e.jsx("span",{className:"text-sm font-semibold text-gray-900",children:(G=X2.find(W=>W.value===w.status))==null?void 0:G.label})]}),P&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"h-px bg-gray-200"}),e.jsxs("div",{className:"flex justify-between items-center py-1",children:[e.jsx("span",{className:"text-sm text-gray-500",children:"Employer"}),e.jsx("span",{className:"text-sm font-semibold text-gray-900",children:w.employer})]}),e.jsxs("div",{className:"flex justify-between items-center py-1",children:[e.jsx("span",{className:"text-sm text-gray-500",children:"Job Title"}),e.jsx("span",{className:"text-sm font-semibold text-gray-900",children:w.jobTitle})]}),e.jsxs("div",{className:"flex justify-between items-center py-1",children:[e.jsx("span",{className:"text-sm text-gray-500",children:"Quarterly Wages"}),e.jsxs("span",{className:"text-sm font-mono font-bold text-emerald-700",children:["$",parseFloat(w.wagesQuarterly).toLocaleStr
1228ing("en-US",{minimumFractionDigits:2})]})]}),e.jsxs("div",{className:"flex justify-between items-center py-1",children:[e.jsx("span",{className:"text-sm text-gray-500",children:"Training-Related"}),e.jsx("span",{className:`text-sm font-semibold ${w.relatedField?"text-emerald-600":"text-amber-600"}`,children:w.relatedField?"Yes â Related to training":"No â Different field"})]})]})]})]}),e.jsxs("div",{className:"mb-6",children:[e.jsxs("label",{className:"block text-sm font-medium text-gray-700 mb-1.5",children:["Additional Comments ",e.jsx("span",{className:"text-gray-400 font-normal",children:"(optional)"})]}),e.jsx("textarea",{value:w.additionalComments,onChange:W=>_(X=>({...X,additionalComments:W.target.value})),placeholder:"Any additional information about your employment situation...",rows:3,className:"w-full px-4 py-3 border border-gray-200 rounded-xl text-sm focus:outline-none focus:ring-2 focus:ring-[#1a365d]/30 focus:border-[#1a365d] resize-none transition-colors"})]}),C.submit&&e.jsx("div",{className:"mb-4 p-3 bg-red-50 rounded-lg border border-red-200",children:e.jsxs("p",{className:"text-sm text-red-700 flex items-center gap-2",children:[e.jsx(ve,{size:14})," ",C.submit]})})]}),e.jsxs("div",{className:"flex gap-3 mt-8 pt-6 border-t border-gray-100",children:[h>1&&e.jsxs("button",{type:"button",onClick:A,className:"flex items-center gap-2 px-5 py-3.5 border border-gray-200 text-gray-700 rounded-xl text-sm font-semibold hover:bg-gray-50 transition-colors",children:[e.jsx(Je,{size:16})," Back"]}),e.jsx("button",{type:"button",onClick:B,disabled:u||!w.status,className:"flex-1 flex items-center justify-center gap-2 px-6 py-3.5 bg-gradient-to-r from-[#1a365d] to-[#2d5a87] text-white rounded-xl text-sm font-semibold hover:from-[#15294a] hover:to-[#244d75] transition-all shadow-lg shadow-blue-900/15 disabled:opacity-50 disabled:cursor-not-allowed",children:u?e.jsxs(e.Fragment,{children:[e.jsx(de,{size:16,className:"animate-spin"})," Submitting..."]}):P&&h===3||!P&&h===2?e.jsxs(e.Fragment,{children:[e.jsx(pt,{size:16})," ",N?"Update My Response":"Submit Employment Data"]}):e.jsxs(e.Fragment,{children:["Continue ",e.jsx(Vt,{size:16})]})})]})]}),e.jsxs("div",{className:"mt-8 space-y-4",children:[e.jsx("div",{className:"p-5 bg-amber-50/80 rounded-xl border border-amber-200",children:e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx(Tt,{size:18,className:"text-amber-600 shrink-0 mt-0.5"}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-bold text-amber-800",children:"Privacy & Data Protection Notice"}),e.jsxs("p",{className:"text-xs text-amber-700 mt-1.5 leading-relaxed",children:["Your responses are collected pursuant to the ",e.jsx("strong",{children:"Workforce Innovation and Opportunity Act (29 USC § 3141)"})," for performance accountability reporting. Individual data is protected under the ",e.jsx("strong",{children:"Family Educational Rights and Privacy Act (FERPA, 20 USC § 1232g)"})," and is reported only in aggregate form. Your personal information will not be shared with third parties except as required by federal and state workforce reporting mandates."]})]})]})}),e.jsx("div",{className:"p-4 bg-gray-50 rounded-xl border border-gray-200",children:e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx(Kt,{size:15,className:"text-gray-500 shrink-0 mt-0.5"}),e.jsx("div",{children:e.jsxs("p",{className:"text-xs text-gray-600 leading-relaxed",children:[e.jsx("strong",{children:"Why are we asking?"})," As a WIOA-eligible training provider, Zorganics Institute is required to collect and report post-graduation employment outcomes at 2nd quarter (6 months) and 4th quarter (12 months) intervals. This data maintains our eligibility on the Eligible Training Provider List (ETPL) and demonstrates program effectiveness to the Washington State Workforce Training Board."]})})]})}),e.jsxs("div",{className:"text-center py-4",children:[e.jsx("p",{className:"text-xs text-gray-400",children:"Zorganics Institute â WIOA Compliance Portal"}),e.jsx("p",{className:"text-[10px] text-gray-300 mt-1",children:"29 USC § 3141 | 20 CFR § 677 | WAC 490-105"})]})]})]})]})},Vs="#800020",Ps="#D4AF37",Iv="#F7E7CE",Hu="#5C0018",$v=({size:t=80})=>e.jsxs("div",{className:"relative flex items-center justify-center",style:{width:t,height:t},children:[e.jsx("div",{className:"absolute inset-0 rounded-full",style:{background:`linear-gradient(135deg, ${Ps}, #B8962E)`,boxShadow:`0 4px 16px ${Ps}40, inset 0 1px 2px rgba(255,255,255,0.3)`,border:`3px solid ${Ps}60`}}),e.jsx("div",{className:"absolute inset-[6px] rounded-full border-2",style:{borderColor:`${Hu}40`}}),e.jsx("span",{className:"relative z-10 font-bold",style:{fontFamily:'"Georgia", serif',fontSize:t*.42,color:Hu},children:"Z"})]}),RX=()=>
1228{const[t]=cc(),[s,n]=d.useState(t.get("id")||""),[a,r]=d.useState(t.get("hash")||""),[i,o]=d.useState(!1),[l,c]=d.useState(null),[u,p]=d.useState(!1);d.useEffect(()=>{const h=t.get("id"),y=t.get("hash");h&&!u&&(n(h),y&&r(y),p(!0),m(h,y||""))},[t]);const m=async(h,y)=>{const v=h||s;if(v.trim()){o(!0),c(null);try{const{data:g,error:N}=await O.functions.invoke("verify-transcript",{body:{action:"verify",document_id:v.trim(),document_hash:(y!==void 0?y:a).trim()||void 0}});if(g)c(g);else if(N)try{const b=N!=null&&N.context?await N.context.json():null;b!=null&&b.blocked||b!=null&&b.rate_limited?c(b):c({success:!1,verified:!1,message:"Verification service unavailable. Please try again later."})}catch{c({success:!1,verified:!1,message:"Verification service unavailable. Please try again later."})}else c({success:!1,verified:!1,message:"Unexpected response. Please try again."})}catch{c({success:!1,verified:!1,message:"Connection error. Please try again."})}o(!1)}},x=h=>{h.preventDefault(),m()};return e.jsxs("div",{className:"min-h-screen",style:{background:"linear-gradient(180deg, #faf9f7 0%, #f3f0eb 50%, #eae5dc 100%)"},children:[e.jsxs("header",{className:"w-full",style:{background:`linear-gradient(135deg, ${Vs}, ${Hu})`},children:[e.jsxs("div",{className:"max-w-5xl mx-auto px-6 py-6 flex items-center gap-5",children:[e.jsx($v,{size:64}),e.jsxs("div",{children:[e.jsx("p",{className:"text-[10px] font-bold tracking-[3px] uppercase",style:{color:Ps},children:"Zorganics Institute of Beauty & Wellness"}),e.jsx("h1",{className:"text-2xl font-bold text-white mt-1",style:{fontFamily:'"Georgia", serif'},children:"Official Transcript Verification Portal"}),e.jsx("p",{className:"text-xs mt-1",style:{color:Iv},children:"NACCAS Accredited ⢠Washington State Licensed ⢠Cryptographic Document Verification"})]})]}),e.jsx("div",{className:"h-1",style:{background:`linear-gradient(90deg, transparent, ${Ps}, transparent)`}})]}),e.jsxs("main",{className:"max-w-5xl mx-auto px-6 py-10",children:[e.jsxs("div",{className:"bg-white rounded-2xl shadow-xl border-2 overflow-hidden mb-8",style:{borderColor:`${Ps}30`},children:[e.jsxs("div",{className:"px-8 py-5 flex items-center gap-3",style:{background:`linear-gradient(135deg, ${Vs}06, ${Ps}08)`,borderBottom:`2px solid ${Ps}20`},children:[e.jsx("div",{className:"w-10 h-10 rounded-xl flex items-center justify-center",style:{background:`${Vs}10`},children:e.jsx(Tt,{size:20,style:{color:Vs}})}),e.jsxs("div",{children:[e.jsx("h2",{className:"text-lg font-bold",style:{color:Vs,fontFamily:'"Georgia", serif'},children:"Verify Transcript Authenticity"}),e.jsx("p",{className:"text-xs text-gray-500",children:"Enter the Document ID and optional Verification Hash found on the transcript's seal section"})]})]}),e.jsxs("form",{onSubmit:x,className:"p-8",children:[e.jsxs("div",{className:"grid md:grid-cols-2 gap-6 mb-6",children:[e.jsxs("div",{children:[e.jsxs("label",{className:"block text-xs font-bold uppercase tracking-wider mb-2",style:{color:Vs},children:[e.jsx(DO,{size:12,className:"inline mr-1"})," Document ID ",e.jsx("span",{className:"text-red-500",children:"*"})]}),e.jsx("input",{type:"text",value:s,onChange:h=>n(h.target.value),placeholder:"e.g., OT-STU001-M2K5X8",className:"w-full px-4 py-3.5 rounded-xl border-2 text-sm font-mono font-medium transition-all focus:outline-none",style:{borderColor:s?`${Ps}60`:"#e5e7eb"},required:!0}),e.jsx("p",{className:"text-[10px] text-gray-400 mt-1.5",children:"Found in the Cryptographic Verification Seal section of the transcript"})]}),e.jsxs("div",{children:[e.jsxs("label",{className:"block text-xs font-bold uppercase tracking-wider mb-2",style:{color:Vs},children:[e.jsx(Xe,{size:12,className:"inline mr-1"})," Verification Hash ",e.jsx("span",{className:"text-gray-400 font-normal",children:"(Optional)"})]}),e.jsx("input",{type:"text",value:a,onChange:h=>r(h.target.value),placeholder:"e.g., SHA256:A1B2C3D4E5F6...",className:"w-full px-4 py-3.5 rounded-xl border-2 text-sm font-mono font-medium transition-all focus:outline-none",style:{borderColor:a?`${Ps}60`:"#e5e7eb"}}),e.jsx("p",{className:"text-[10px] text-gray-400 mt-1.5",children:"Providing the hash enables full cryptographic verification of document integrity"})]})]}),e.jsx("button",{type:"submit",disabled:!s.trim()||i,className:"w-full flex items-center justify-center gap-3 px-8 py-4 rounded-xl text-sm font-bold text-white transition-all disabled:opacity-50 disabled:cursor-not-allowed shadow-lg hover:shadow-xl",style:{background:`linear-gradient(135deg, ${Vs}, ${Hu})`},children:i?e.jsxs(e.Fragment,{children:[e.jsx(de,{size:18,className:"animate-spin"}),"Verifying Document..."]}):e.jsxs(e.Fragment,{children:[e.jsx(Bt,{size:18}),"Verify Transcript"]})})]})]}),l&&e.jsx("div",{className:"mb-8 animate-in fade-in slide-in-from-bottom-4 duration-500",children:l.verified?e.jsxs("div",{className:"bg-white rounded-2xl shadow-xl border-2 overflow-hidden",style:{borderColor:"#05966940"},children:[e.jsx("div",{className:"px-8 py-6",style:{background:"linear-gradient(135deg, #059669, #047857)"},children:e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx("div",{className:"w-16 h-16 rounded-2xl bg-white/20 flex items-center justify-center backdrop-blur-sm",children:e.jsx(pt,{size:36,className:"text-white"})}),e.jsxs("div",{children:[e.jsx("h3",{className:"text-xl font-bold text-white",style:{fontFamily:'"Georgia", serif'},children:"Transcript Verified â Authentic"}),e.jsx("p",{className:"text-emerald-100 text-sm mt-1",children:l.message})]}),e.jsx("div",{className:"ml-auto",children:e.jsx($v,{size:56})})]})}),e.jsxs("div",{className:"p-8",children:[e.jsxs("div",{className:"grid md:grid-cols-2 gap-6 mb-6",children:[e.jsxs("div",{className:"rounded-xl border-2 p-5",style:{borderColor:`${Ps}25`,background:`${Ps}05`},children:[e.jsxs("h4",{className:"text-xs font-bold uppercase tracking-wider mb-4 flex items-center gap-2",style:{color:Vs},children:[e.jsx(_t,{size:14,style:{color:Ps}})," Student Information"]}),e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-[10px] text-gray-400 uppercase tracking-wider",children:"Student Name"}),e.jsx("p",{className:"text-base font-bold text-gray-900",style:{fontFamily:'"Georgia", serif'},children:l.student_name})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-[10px] text-gray-400 uppercase tracking-wider",children:"Program of Study"}),e.jsx("p",{className:"text-sm font-semibold text-gray-700",children:l.program})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-[10px] text-gray-400 uppercase tracking-wider",children:"Institution"}),e.jsx("p",{className:"text-sm font-semibold text-gray-700",children:l.institution})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-[10px] text-gray-400 uppercase tracking-wider",children:"Accreditation"}),e.jsx("p",{className:"text-sm font-semibold text-emerald-700",children:l.accreditation})]})]})]}),e.jsxs("div",{className:"rounded-xl border-2 p-5",style:{borderColor:`${Vs}15`,background:`${Vs}03`},children:[e.jsxs("h4",{className:"text-xs font-bold uppercase tracking-wider mb-4 flex items-center gap-2",style:{color:Vs},children:[e.jsx(si,{size:14,style:{color:Ps}})," Academic Summary"]}),e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[l.cumulative_gpa&&e.jsxs("div",{className:"rounded-lg p-3 bg-white border border-gray-100 text-center",children:[e.jsx("p",{className:"text-[9px] text-gray-400 uppercase tracking-wider",children:"Cumulative GPA"}),e.jsx("p",{className:"text-xl font-extrabold font-mono",style:{color:Number(l.cumulative_gpa)>=3?"#059669":"#D97706"},children:l.cumulative_gpa}),e.jsx("p",{className:"text-[9px] text-gray-400",children:"of 4.00 scale"})]}),l.total_credits&&e.jsxs("div",{className:"rounded-lg p-3 bg-white border border-gray-100 text-center",children:[e.jsx("p",{className:"text-[9px] text-gray-400 uppercase tracking-wider",children:"Total Credits"}),e.jsx("p",{className:"text-xl font-extrabold font-mono text-gray-900",children:l.total_credits}),e.jsxs("p",{className:"text-[9px] text-gray-400",children:[l.total_quality_points," QP"]})]}),l.hours_completed!=null&&e.jsxs("div",{className:"rounded-lg p-3 bg-white border border-gray-100 text-center",children:[e.jsx("p",{className:"text-[9px] text-gray-400 uppercase tracking-wider",children:"Clock Hours"}),e.jsx("p",{className:"text-xl font-extrabold font-mono text-gray-900",children:l.hours_completed}),e.jsxs("p",{className:"text-[9px] text-gray-400",children:["of ",l.required_hours]})]}),l.total_entries!=null&&e.jsxs("div",{className:"rounded-lg p-3 bg-white border border-gray-100 text-center",children:[e.jsx("p",{className:"text-[9px] text-gray-400 uppercase tracking-wider",children:"Grade Entries"}),e.jsx("p",{className:"text-xl font-extrabold font-mono text-gray-900",children:l.total_entries}),e.jsx("p",{className:"text-[9px] text-gray-400",children:"recorded"})]})]})]})]}),e.jsxs("div",{className:"rounded-xl border-2 p-5",style:{borderColor:`${Ps}25`,background:`linear-gradient(135deg, ${Vs}04, ${Ps}06)`},children:[e.jsxs("h4",{className:"text-xs font-bold uppercase tracking-wider mb-4 flex items-center gap-2",style:{color:Vs},children:[e.jsx(Xe,{size:14,style:{color:Ps}})," Document Verification Details"]}
1228),e.jsxs("div",{className:"grid md:grid-cols-3 gap-4",children:[e.jsxs("div",{className:"rounded-lg p-3 bg-white border border-gray-100",children:[e.jsx("p",{className:"text-[9px] text-gray-400 uppercase tracking-wider",children:"Document ID"}),e.jsx("p",{className:"text-xs font-mono font-bold text-gray-900 mt-1",children:l.document_id})]}),l.document_hash&&e.jsxs("div",{className:"rounded-lg p-3 bg-white border border-gray-100",children:[e.jsx("p",{className:"text-[9px] text-gray-400 uppercase tracking-wider",children:"Verification Hash"}),e.jsx("p",{className:"text-xs font-mono font-bold text-gray-900 mt-1 break-all",children:l.document_hash})]}),e.jsxs("div",{className:"rounded-lg p-3 bg-white border border-gray-100",children:[e.jsx("p",{className:"text-[9px] text-gray-400 uppercase tracking-wider",children:"Generated"}),e.jsx("p",{className:"text-xs font-semibold text-gray-900 mt-1",children:l.generated_at?new Date(l.generated_at).toLocaleDateString("en-US",{month:"long",day:"numeric",year:"numeric",hour:"2-digit",minute:"2-digit"}):"N/A"})]})]}),l.purpose&&e.jsxs("div",{className:"mt-3 rounded-lg p-3 bg-white border border-gray-100",children:[e.jsx("p",{className:"text-[9px] text-gray-400 uppercase tracking-wider",children:"Stated Purpose"}),e.jsxs("p",{className:"text-xs font-semibold text-gray-700 mt-1",children:[l.purpose,l.recipient_org?` â ${l.recipient_org}`:""]})]})]}),e.jsxs("div",{className:"mt-4 flex items-center justify-center gap-2 text-xs text-gray-400",children:[e.jsx(ms,{size:12}),e.jsxs("span",{children:["Verified on ",new Date().toLocaleDateString("en-US",{month:"long",day:"numeric",year:"numeric",hour:"2-digit",minute:"2-digit"})]}),e.jsx("span",{children:"â¢"}),e.jsx("span",{children:"This verification has been logged for security purposes"})]})]})]}):l.warning?e.jsxs("div",{className:"bg-white rounded-2xl shadow-xl border-2 overflow-hidden",style:{borderColor:"#D9770640"},children:[e.jsx("div",{className:"px-8 py-6",style:{background:"linear-gradient(135deg, #D97706, #B45309)"},children:e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx("div",{className:"w-16 h-16 rounded-2xl bg-white/20 flex items-center justify-center backdrop-blur-sm",children:e.jsx(ve,{size:36,className:"text-white"})}),e.jsxs("div",{children:[e.jsx("h3",{className:"text-xl font-bold text-white",style:{fontFamily:'"Georgia", serif'},children:"Verification Warning â Hash Mismatch"}),e.jsx("p",{className:"text-amber-100 text-sm mt-1",children:l.message})]})]})}),e.jsx("div",{className:"p-8",children:e.jsxs("div",{className:"rounded-xl border-2 border-amber-200 bg-amber-50 p-5",children:[e.jsx("p",{className:"text-sm text-amber-800 font-medium",children:"The Document ID was found in our records, but the verification hash provided does not match our records. This could indicate the document has been modified after generation."}),e.jsx("p",{className:"text-xs text-amber-600 mt-3",children:"If you believe this is an error, please contact the Zorganics Institute Registrar Office directly for manual verification."})]})})]}):l.rate_limited?e.jsxs("div",{className:"bg-white rounded-2xl shadow-xl border-2 overflow-hidden",style:{borderColor:"#2563EB40"},children:[e.jsx("div",{className:"px-8 py-6",style:{background:"linear-gradient(135deg, #2563EB, #1D4ED8)"},children:e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx("div",{className:"w-16 h-16 rounded-2xl bg-white/20 flex items-center justify-center backdrop-blur-sm",children:e.jsx(KO,{size:36,className:"text-white"})}),e.jsxs("div",{children:[e.jsx("h3",{className:"text-xl font-bold text-white",style:{fontFamily:'"Georgia", serif'},children:"Too Many Requests"}),e.jsx("p",{className:"text-blue-100 text-sm mt-1",children:"Your verification request has been temporarily throttled"})]})]})}),e.jsxs("div",{className:"p-8",children:[e.jsxs("div",{className:"rounded-xl border-2 border-blue-200 bg-blue-50 p-5",children:[e.jsx("p",{className:"text-sm text-blue-800 font-medium",children:l.message||"You have exceeded the maximum number of verification requests. Please wait before trying again."}),l.retry_after&&e.jsxs("div",{className:"mt-4 flex items-center gap-3 p-3 bg-white rounded-lg border border-blue-200",children:[e.jsx(dt,{size:18,className:"text-blue-600 shrink-0"}),e.jsxs("div",{children:[e.jsx("p",{className:"text-xs font-bold text-blue-800",children:"Retry After"}),e.jsxs("p",{className:"text-lg font-extrabold font-mono text-blue-600",children:[l.retry_after," seconds"]})]}),e.jsxs("div",{className:"ml-auto text-right",children:[e.jsx("p",{className:"text-[9px] text-gray-400 uppercase tracking-wider",children:"Limit"}),e.jsxs("p",{className:"text-sm font-bold font-mono text-gray-700",children:[l.limit||20," req/min"]})]})]}),e.jsx("p",{className:"text-xs text-blue-600 mt-3",children:"This rate limit protects the verification system from abuse. Please wait the indicated time and try again. If you need to verify multiple transcripts, please space your requests apart."})]}),e.jsxs("div",{className:"mt-4 flex items-center gap-2 text-xs text-gray-400",children:[e.jsx(Tt,{size:12}),e.jsx("span",{children:"This rate-limited attempt has been logged for security audit purposes"})]})]})]}):e.jsxs("div",{className:"bg-white rounded-2xl shadow-xl border-2 overflow-hidden",style:{borderColor:"#DC262640"},children:[e.jsx("div",{className:"px-8 py-6",style:{background:"linear-gradient(135deg, #DC2626, #B91C1C)"},children:e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx("div",{className:"w-16 h-16 rounded-2xl bg-white/20 flex items-center justify-center backdrop-blur-sm",children:e.jsx(kt,{size:36,className:"text-white"})}),e.jsxs("div",{children:[e.jsx("h3",{className:"text-xl font-bold text-white",style:{fontFamily:'"Georgia", serif'},children:"Transcript Not Found"}),e.jsx("p",{className:"text-red-100 text-sm mt-1",children:l.message})]})]})}),e.jsx("div",{className:"p-8",children:e.jsxs("div",{className:"rounded-xl border-2 border-red-200 bg-red-50 p-5",children:[e.jsx("p",{className:"text-sm text-red-800 font-medium",children:"No official transcript was found with the provided Document ID. Please double-check the ID and try again."}),e.jsxs("ul",{className:"text-xs text-red-600 mt-3 space-y-1 list-disc list-inside",children:[e.jsx("li",{children:"Ensure the Document ID is entered exactly as shown on the transcript (case-sensitive)"}),e.jsx("li",{children:"The Document ID format is typically: OT-STUDENTID-XXXXXXXX"}),e.jsx("li",{children:"If the issue persists, the transcript may not have been generated through our official system"})]})]})})]})}),e.jsxs("div",{className:"grid md:grid-cols-3 gap-6 mb-10",children:[e.jsxs("div",{className:"bg-white rounded-2xl border border-gray-100 p-6 shadow-sm",children:[e.jsx("div",{className:"w-12 h-12 rounded-xl flex items-center justify-center mb-4",style:{background:`${Vs}08`},children:e.jsx(Tt,{size:22,style:{color:Vs}})}),e.jsx("h3",{className:"text-sm font-bold text-gray-900 mb-2",style:{fontFamily:'"Georgia", serif'},children:"Cryptographic Seal"}),e.jsx("p",{className:"text-xs text-gray-500 leading-relaxed",children:"Each official transcript is sealed with a unique cryptographic hash that ensures document integrity. Any modification to the transcript will cause hash verification to fail."})]}),e.jsxs("div",{className:"bg-white rounded-2xl border border-gray-100 p-6 shadow-sm",children:[e.jsx("div",{className:"w-12 h-12 rounded-xl flex items-center justify-center mb-4",style:{background:`${Ps}10`},children:e.jsx(Kt,{size:22,style:{color:Ps}})}),e.jsx("h3",{className:"text-sm font-bold text-gray-900 mb-2",style:{fontFamily:'"Georgia", serif'},children:"NACCAS Compliant"}),e.jsx("p",{className:"text-xs text-gray-500 leading-relaxed",children:"All transcripts meet NACCAS Standard V requirements for academic re
1228cord-keeping, including cumulative GPA, clock hours, SAP checkpoint results, and complete grade records."})]}),e.jsxs("div",{className:"bg-white rounded-2xl border border-gray-100 p-6 shadow-sm",children:[e.jsx("div",{className:"w-12 h-12 rounded-xl flex items-center justify-center mb-4",style:{background:"#05966910"},children:e.jsx(Xe,{size:22,className:"text-emerald-600"})}),e.jsx("h3",{className:"text-sm font-bold text-gray-900 mb-2",style:{fontFamily:'"Georgia", serif'},children:"Audit Trail"}),e.jsx("p",{className:"text-xs text-gray-500 leading-relaxed",children:"Every verification attempt is logged with timestamp and IP address for security auditing. This ensures a complete chain of custody for all transcript verifications."})]})]}),e.jsxs("div",{className:"bg-white rounded-2xl border border-gray-100 p-8 shadow-sm mb-10",children:[e.jsxs("h3",{className:"text-lg font-bold mb-6 flex items-center gap-2",style:{color:Vs,fontFamily:'"Georgia", serif'},children:[e.jsx(Na,{size:18,style:{color:Ps}})," How to Verify a Transcript"]}),e.jsx("div",{className:"grid md:grid-cols-4 gap-6",children:[{step:"1",title:"Locate Document ID",desc:"Find the Document ID in the Cryptographic Verification Seal section at the bottom of the transcript."},{step:"2",title:"Enter Document ID",desc:'Type or paste the Document ID into the verification form above. It starts with "OT-" followed by the student ID.'},{step:"3",title:"Add Hash (Optional)",desc:"For full cryptographic verification, also enter the Verification Hash shown next to the Document ID."},{step:"4",title:"Review Results",desc:"The system will display the student's verified academic record, confirming the transcript is authentic and unaltered."}].map(h=>e.jsxs("div",{className:"text-center",children:[e.jsx("div",{className:"w-10 h-10 rounded-full mx-auto mb-3 flex items-center justify-center text-sm font-bold text-white",style:{background:`linear-gradient(135deg, ${Vs}, ${Hu})`},children:h.step}),e.jsx("h4",{className:"text-sm font-bold text-gray-900 mb-1",children:h.title}),e.jsx("p",{className:"text-xs text-gray-500 leading-relaxed",children:h.desc})]},h.step))})]})]}),e.jsx("footer",{className:"w-full",style:{background:`linear-gradient(135deg, ${Vs}, ${Hu})`},children:e.jsx("div",{className:"max-w-5xl mx-auto px-6 py-6",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-[10px] font-bold tracking-[2px] uppercase",style:{color:Ps},children:"Zorganics Institute of Beauty & Wellness"}),e.jsx("p",{className:"text-[10px] mt-1",style:{color:Iv},children:"NACCAS Accredited ⢠WA State DOL Licensed ⢠Title IV Eligible ⢠VA Approved"}),e.jsx("p",{className:"text-[9px] mt-1",style:{color:`${Iv}60`},children:"Official Transcript Verification Portal ⢠All verification attempts are logged for security compliance"})]}),e.jsx($v,{size:40})]})})})]})},zr={kicker:"Leadership & Faculty",heading:"Meet the People Behind Zorganics",intro:"At Zorganics Institute of Beauty & Wellness, education is supported by experienced instructors and administrative professionals who share a commitment to student learning, professional development, and preparation for licensed careers.",philosophy:"A Holistic Approach to Beauty & Wellness Through Science & Art",photoPlaceholderLabel:"Professional Photo",photoPlaceholderNote:"Portrait coming soon",closing:{heading:"A Team Focused on Student Success",body:"From admissions and financial aid to classroom education and hands-on training, the Zorganics team works together to support students throughout their educational experience.",body2:"Our goal is to create an environment where students are supported, challenged to grow, and prepared to enter the beauty and wellness industry with knowledge, confidence, and professionalism.",lead:"Meet Zorganics. Begin Your Journey.",ctas:[{label:"Apply Now",href:"/apply-now",variant:"primary"},{label:"Schedule a Campus Tour",href:"/book-online",variant:"outline"}]}},IX=[{id:"leadership",heading:"Leadership",members:[{slug:"frida-emalange",name:"Frida Emalange",role:"Founder · Master Educator",credentials:"NCEA Certified · Was
1228hington State Licensed Master Esthetician · Licensed Cosmetologist · Licensed Instructor",paragraphs:["With more than 24 years of experience in beauty, wellness, education, and entrepreneurship, Frida Emalange leads the vision and educational philosophy of Zorganics Institute of Beauty & Wellness.","Her multidisciplinary background includes advanced esthetics, cosmetology, integrative nutrition, mind-body approaches, professional education, and curriculum development."],profileLink:{label:"Read Full Founder Profile",href:"/faculty/frida-emalange"}}]},{id:"faculty",heading:"Faculty",members:[{slug:"jila-melak",name:"Jila Melak",role:"Cosmetology & Master Esthetics Instructor",paragraphs:["Jila Melak supports Zorganics students through classroom education, hands-on instruction, practical skill development, and supervised learning in Cosmetology and Master Esthetics.","As part of the instructional team, she helps students connect theory with professional practice while developing the knowledge, technical skills, confidence, and professionalism needed for their future careers."]}]},{id:"support",heading:"Student & Administrative Support",members:[{slug:"lilly-fulford",name:"Lilly Fulford",role:"Financial Aid Administrator",paragraphs:["Lilly Fulford supports students and families as they navigate the financial aid process at Zorganics Institute.","She assists students with understanding financial aid requirements, completing required steps and documentation, and identifying available funding options for those who qualify.","Her role helps provide students with clear guidance throughout the financial aid process and their educational journey."]}]}],hr="#B8962E",RA="#2A0810",zv="#FAF6ED",xo="'Playfair Display', Georgia, serif",$X=({member:t})=>e.jsxs("div",{className:"shrink-0 flex flex-col items-center",children:[e.jsx("div",{className:"w-[168px] h-[168px] rounded-full overflow-hidden flex flex-col items-center justify-center text-center",style:t.photoUrl?{border:`2px solid ${$}`,boxShadow:`0 0 0 6px ${$}1A, 0 10px 26px ${k}22`,background:"#F4F4F5"}:{border:`2px dashed ${$}88`,boxShadow:`0 0 0 6px ${$}12`,background:"linear-gradient(180deg, #FBF8F1 0%, #F1ECE1 100%)"},"aria-hidden":t.photoUrl?void 0:!0,children:t.photoUrl?e.jsx("img",{src:t.photoUrl,alt:`${t.name}, ${t.role}`,className:"w-full h-full object-cover",loading:"lazy"}):e.jsxs(e.Fragment,{children:[e.jsx(rx,{size:26,style:{color:hr,opacity:.75}}),e.jsx("span",{className:"mt-2 text-[9px] font-semibold uppercase tracking-[0.28em] px-4 leading-relaxed",style:{color:hr},children:zr.photoPlaceholderLabel})]})}),!t.photoUrl&&e.jsx("span",{className:"mt-3 text-[10px] italic",style:{color:"#8A8A8A",fontFamily:xo},children:zr.photoPlaceholderNote})]}),zX=({member:t})=>e.jsx("article",{className:"rounded-2xl p-6 lg:p-9",style:{background:"#fff",border:`1px solid ${k}15`,boxShadow:`0 6px 24px ${k}0D`},"aria-label":`${t.name} â ${t.role}`,children:e.jsxs("div",{className:"flex flex-col sm:flex-row items-center sm:items-start gap-6 lg:gap-9",children:[e.jsx($X,{member:t}),e.jsxs("div",{className:"flex-1 min-w-0 text-center sm:text-left",children:[e.jsx("h4",{className:"font-bold leading-tight mb-1",style:{color:k,fontFamily:xo,fontSize:"clamp(1.35rem, 2.4vw, 1.9rem)",letterSpacing:"-0.01em"},children:t.name}),e.jsx("p",{className:"italic mb-4",style:{color:hr,fontFamily:xo,letterSpacing:"0.04em"},children:t.role}),t.credentials&&e.jsxs("div",{className:"inline-flex items-start gap-2 mb-5 px-3.5 py-2 rounded-lg text-[11px] font-semibold leading-relaxed text-left",style:{background:`${$}18`,color:"#6B5410",border:`1px solid ${$}55`},children:[e.jsx(Is,{size:13,className:"shrink-0 mt-[1px]",style:{color:hr}}),e.jsx("span",{children:t.credentials})]}),e.jsx("div",{className:"space-y-3",children:t.paragraphs.map(s=>e.jsx("p",{className:"text-[14.5px] leading-[1.85]",style:{color:"#3A3A3A"},children:s},s.slice(0,40)))}),t.profileLink&&e.jsx("div",{className:"mt-6 pt-5",style:{borderTop:`1px solid ${hr}22`},children:e.jsxs(be,{to:t.profileLink.href,className:"inline-flex items-center gap-2 text-[11px] font-semibold tracking-[0.25em] uppercase transition-all hover:gap-3",style:{color:hr,fontFamily:xo},children:[t.profileLink.label," ",e.jsx(Vt,{size:13})]})})]})]})}),LX=()=>e.jsx("section",{className:"py-16 lg:py-24",style:{background:zv,borderTop:`1px solid ${k}11`},"aria-labelledby":"leadership-faculty-heading",children:e.jsxs("div",{className:"max-w-[1100px] mx-auto px-4 lg:px-8",children:[e.jsxs("div",{className:"flex items-center justify-center gap-3 mb-4",children:[e.jsx("div",{className:"h-[1px] w-14",style:{background:`linear-gradient(90deg, transparent, ${hr}99)`}}),e.jsxs("span",{className:"text-[10px] sm:text-[11px] tracking-[0.5em] uppercase font-semibold",style:{color:hr},children:[e.jsx(ts,{size:11,className:"inline mr-1.5 -mt-0.5"})," ",zr.kicker]}),e.jsx("div",{className:"h-[1px] w-14",style:{background:`linear-gradient(90deg, ${hr}99, transparent)`}})]}),e.jsx("h2",{id:"leadership-faculty-heading",className:"text-center font-bold mb-5",style:{fontFamily:xo,color:k,fontSize:"clamp(1.6rem, 3.4vw, 2.6rem)",letterSpacing:"-0.01em"},children:zr.heading}),e.jsx("p",{className:"text-center text-[15px] leading-relaxed max-w-3xl mx-auto mb-5",style:{color:"#4A4A4A"},children:zr.intro}),e.jsx("p",{className:"text-center italic font-semibold mb-14 px-4",style:{color:hr,fontFamily:xo,fontSize:"clamp(0.95rem, 1.8vw, 1.15rem)"},children:zr.philosophy}),IX.map(t=>e.jsxs("div",{className:"mb-12 lg:mb-14",children:[e.jsxs("div",{className:"flex items-center gap-3 mb-6",children:[e.jsx("h3",{className:"font-bold whitespace-nowrap",style:{color:k,fontFamily:xo,fontSize:"clamp(1.05rem, 2vw, 1.45rem)"},children:t.heading}),e.jsx("div",{className:"flex-1 h-[1px]",style:{background:`linear-gradient(90deg, ${hr}55, transparent)`}})]}),e.jsx("div",{className:"space-y-6",children:t.members.map(s=>e.jsx(zX,{member:s}
1228,s.slug))})]},t.id)),e.jsxs("div",{className:"rounded-2xl p-8 lg:p-12 text-center",style:{background:`linear-gradient(135deg, ${k} 0%, ${RA} 100%)`,border:`1px solid ${$}44`,boxShadow:`0 14px 40px ${k}22`},children:[e.jsx("h3",{className:"font-bold mb-4",style:{color:$,fontFamily:xo,fontSize:"clamp(1.3rem, 2.8vw, 2rem)"},children:zr.closing.heading}),e.jsx("p",{className:"text-sm leading-relaxed max-w-2xl mx-auto mb-3",style:{color:zv,opacity:.92},children:zr.closing.body}),e.jsx("p",{className:"text-sm leading-relaxed max-w-2xl mx-auto mb-7",style:{color:zv,opacity:.85},children:zr.closing.body2}),e.jsx("p",{className:"italic font-semibold mb-7",style:{color:$,fontFamily:xo,fontSize:"clamp(1rem, 2vw, 1.25rem)"},children:zr.closing.lead}),e.jsx("div",{className:"flex flex-wrap items-center justify-center gap-3",children:zr.closing.ctas.map(t=>e.jsxs("a",{href:t.href,className:"inline-flex items-center gap-2 px-6 py-3 rounded-full font-bold text-sm uppercase tracking-[0.12em] transition-all hover:-translate-y-0.5",style:t.variant==="primary"?{background:`linear-gradient(135deg, ${$}, ${hr})`,color:RA,boxShadow:`0 8px 24px ${$}44`}:{background:"transparent",color:$,border:`1px solid ${$}77`},children:[t.label,e.jsx(Vt,{size:14})]},t.label))})]})]})}),tg="#E6D2A0",kp="#B8962E",sg="#2A0810",Lv="#FAF6ED",OX=({loc:t})=>{const[s,n]=d.useState({firstName:"",lastName:"",email:"",phone:"",program:"",preferredDate:"",notes:"",smsOptIn:!1}),[a,r]=d.useState("idle"),[i,o]=d.useState(null),l=m=>{const{name:x,value:h,type:y}=m.target;if(y==="checkbox"){const v=m.target.checked;n(g=>({...g,[x]:v}))}else n(v=>({...v,[x]:h}))},c=async m=>{if(m.preventDefault(),a==="submitting")return;r("submitting"),o(null);const x=s.smsOptIn&&!!s.phone.trim(),h=`${s.firstName} ${s.lastName}`.trim();try{const{submitSecureFormManaged:y,securityMessage:v}=await Ee(async()=>{const{submitSecureFormManaged:N,securityMessage:b}=await Promise.resolve().then(()=>EK);return{submitSecureFormManaged:N,securityMessage:b}},void 0),g=await y({formType:"campus_tour_request",payload:{name:h,email:s.email.trim().toLowerCase(),campus_slug:t.slug,campus_name:t.city,first_name:s.firstName,last_name:s.lastName,phone:s.phone||null,program_interest:s.program||null,preferred_date:s.preferredDate||null,notes:s.notes||null,sms_opt_in:x},crm:{source:`campus-tour-${t.slug}`,name:h,phone:s.phone||void 0,sms_opt_in:x,tags:["campus-tour",`campus:${t.slug}`,`campus-name:${t.city}`,t.slug==="bellingham"?"heritage-hq":t.slug==="renton"?"central-hub":"northgate-flagship",s.program?`program-interest:${s.program}`:"program-undecided",...x?["sms-opt-in"]:[]],metadata:{campus:t.city,campusSlug:t.slug,campusAddress:`${t.street}${t.suite?", "+t.suite:""}, ${t.city}, ${t.state} ${t.postalCode}`,phone:s.phone,preferredDate:s.preferredDate,programInterest:s.program,notes:s.notes,smsOptIn:x,submittedAt:new Date().toISOString()}}});if(!g.ok){o(g.message||v(g.reason)),r("error");return}r("success")}catch(y){console.error("Campus tour signup error:",y),o((y==null?void 0:y.message)||"Something went wrong. Please call us instead."),r("error")}},u=new Date().toISOString().split("T")[0],p=new Date(Date.now()+90*24*60*60*1e3).toISOString().split("T")[0];return e.jsx("section",{id:"tour-this-campus",className:"py-14 lg:py-20",style:{background:`linear-gradient(180deg, ${sg} 0%, ${k} 60%, ${sg} 100%)`,color:Lv},"aria-labelledby":"tour-form-heading",children:e.jsxs("div",{className:"max-w-[1100px] mx-auto px-4 lg:px-8",children:[e.jsxs("div",{className:"flex items-center justify-center gap-3 mb-3",children:[e.jsx("div",{className:"h-[1px] w-12",style:{background:`linear-gradient(90deg, transparent, ${$}99)`}}),e.jsx("span",{className:"text-[10px] sm:text-[11px] tracking-[0.4em] uppercase font-semibold",style:{color:tg},children:"Tour Our Campus"}),e.jsx("div",{className:"h-[1px] w-12",style:{background:`linear-gradient(90deg, ${$}99, transparent)`}})]}),e.jsx("h2",{id:"tour-form-heading",className:"text-center font-bold mb-3",style:{fontFamily:"'Playfair Display', Georgia, serif",color:$,fontSize:"clamp(1.6rem, 3.4vw, 2.6rem)"},children:"Experience Zorganics in Person"}),e.jsxs("p",{className:"text-center text-sm sm:text-base max-w-2xl mx-auto mb-4 italic",style:{color:tg,opacity:.85,fontFamily:"'Playfair Display', Georgia, serif"},children:["Discover what makes Zorganics Institute of Beauty & Wellness different. Tour our"," ",t.city," campus, explore our classrooms and student clinic, meet our faculty and admissions team, and experience"," ",e.jsx("strong",{style:{fontStyle:"normal",color:$},children:"A Holistic Approach to Beauty & Wellness Through Science & Art"}
1228)," ","in action."]}),e.jsx("p",{className:"text-center text-sm sm:text-base max-w-2xl mx-auto mb-10 font-bold",style:{color:$,fontFamily:"'Playfair Display', Georgia, serif"},children:"Schedule Your Personal Campus Tour"}),e.jsxs("div",{className:"grid lg:grid-cols-5 gap-6 rounded-2xl overflow-hidden",style:{background:"#fff",color:"#1a1a1a",border:`1px solid ${$}55`,boxShadow:`0 20px 60px ${sg}AA`},children:[e.jsxs("aside",{className:"lg:col-span-2 p-7 lg:p-8 relative overflow-hidden",style:{background:`linear-gradient(180deg, ${k} 0%, ${sg} 100%)`,color:Lv},children:[e.jsx("div",{className:"absolute -top-10 -right-10 w-40 h-40 rounded-full blur-3xl opacity-20",style:{background:$},"aria-hidden":"true"}),e.jsxs("div",{className:"relative",children:[e.jsxs("div",{className:"inline-flex items-center gap-2 px-3 py-1 rounded-full text-[10px] font-bold uppercase tracking-widest mb-5",style:{background:`${$}22`,color:$,border:`1px solid ${$}55`},children:[e.jsx(Qe,{size:11})," ",t.openingDate||`Est. ${t.openedYear}`]}),e.jsxs("h3",{className:"text-2xl font-bold mb-1",style:{color:$,fontFamily:"'Playfair Display', Georgia, serif"},children:["Zorganics Institute · ",t.city]}),e.jsx("p",{className:"text-xs italic mb-6",style:{color:tg,opacity:.85},children:t.subtitle}),e.jsxs("div",{className:"space-y-3 text-sm",children:[e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx(zt,{size:16,className:"shrink-0 mt-0.5",style:{color:$}}),e.jsxs("div",{children:[t.street,t.suite?`, ${t.suite}`:"",e.jsx("br",{}),t.city,", ",t.state," ",t.postalCode]})]}),e.jsxs("a",{href:`tel:${t.phone}`,className:"flex items-start gap-3 hover:opacity-80 transition-opacity",children:[e.jsx(Qt,{size:16,className:"shrink-0 mt-0.5",style:{color:$}}),e.jsx("span",{children:t.phoneDisplay})]}),e.jsxs("a",{href:`mailto:${t.email}`,className:"flex items-start gap-3 hover:opacity-80 transition-opacity",children:[e.jsx(Ye,{size:16,className:"shrink-0 mt-0.5",style:{color:$}}),e.jsx("span",{className:"break-all",children:t.email})]})]}),e.jsxs("div",{className:"mt-7 pt-5 border-t",style:{borderColor:`${$}33`},children:[e.jsx("p",{className:"text-[11px] uppercase tracking-[0.25em] mb-3 font-semibold",style:{color:tg},children:"What to Expect"}),e.jsx("ul",{className:"space-y-2 text-sm",children:["Walk-through of the instructor-supervised Student Salon & Esthetics Clinic, classrooms, and hands-on practical training space
1228s","Meet a campus admissions advisor","Q&A with current students","Personal program & funding consultation"].map(m=>e.jsxs("li",{className:"flex items-start gap-2",children:[e.jsx(Ue,{size:14,className:"shrink-0 mt-0.5",style:{color:$}}),e.jsx("span",{style:{color:Lv,opacity:.92},children:m})]},m))})]})]})]}),e.jsx("div",{className:"lg:col-span-3 p-7 lg:p-8",children:a==="success"?e.jsxs("div",{className:"text-center py-12",children:[e.jsx("div",{className:"w-16 h-16 rounded-full mx-auto mb-5 flex items-center justify-center",style:{background:"rgba(45,90,39,0.10)"},children:e.jsx(Ue,{size:32,style:{color:"#2D5A27"}})}),e.jsx("h3",{className:"text-2xl font-bold mb-2",style:{color:k,fontFamily:"'Playfair Display', Georgia, serif"},children:"Tour Request Received"}),e.jsxs("p",{className:"text-sm max-w-md mx-auto",style:{color:"#555"},children:["Thank you for your interest in the ",e.jsx("strong",{children:t.city})," campus. Our admissions team will reach out within 24 hours to confirm your tour and answer any questions."]}),e.jsxs("a",{href:`tel:${t.phone}`,className:"inline-flex items-center gap-2 mt-6 px-5 py-2.5 rounded-lg text-sm font-semibold transition-all hover:-translate-y-0.5",style:{background:`linear-gradient(135deg, ${$}, ${kp})`,color:k},children:[e.jsx(Qt,{size:14})," Or call ",t.phoneDisplay]})]}):e.jsxs("form",{onSubmit:c,className:"space-y-4",children:[e.jsxs("div",{className:"inline-flex items-center gap-2 px-3 py-1 rounded-full text-[10px] font-bold uppercase tracking-widest mb-1",style:{background:`${$}1A`,color:kp,border:`1px solid ${$}55`},children:[e.jsx(At,{size:11})," Tagged for ",t.city," CRM"]}),e.jsxs("div",{className:"grid sm:grid-cols-2 gap-4",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs font-semibold mb-1",style:{color:k},children:"First Name *"}),e.jsx("input",{name:"firstName",value:s.firstName,onChange:l,required:!0,className:"w-full px-3 py-2.5 rounded-lg text-sm focus:outline-none focus:ring-2",style:{border:"1px solid #E8DDD0",color:k}})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs font-semibold mb-1",style:{color:k},children:"Last Name *"}),e.jsx("input",{name:"lastName",value:s.lastName,onChange:l,required:!0,className:"w-full px-3 py-2.5 rounded-lg text-sm focus:outline-none focus:ring-2",style:{border:"1px solid #E8DDD0",color:k}})]})]}),e.jsxs("div",{className:"grid sm:grid-cols-2 gap-4",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs font-semibold mb-1",style:{color:k},children:"Email *"}),e.jsx("input",{name:"email",type:"email",value:s.email,onChange:l,required:!0,className:"w-full px-3 py-2.5 rounded-lg text-sm focus:outline-none focus:ring-2",style:{border:"1px solid #E8DDD0",color:k}})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs font-semibold mb-1",style:{color:k},children:"Phone"}),e.jsx("input",{name:"phone",type:"tel",value:s.phone,onChange:l,className:"w-full px-3 py-2.5 rounded-lg text-sm focus:outline-none focus:ring-2",style:{border:"1px solid #E8DDD0",color:k}})]})]}),e.jsxs("div",{className:"grid sm:grid-cols-2 gap-4",children:[e.jsxs("div",{children:[e.jsxs("label",{className:"block text-xs font-semibold mb-1",style:{color:k},children:[e.jsx(_t,{size:11,className:"inline mr-1 -mt-0.5"}),"Program of Interest"]}),e.jsxs("select",{name:"program",value:s.program,onChange:l,className:"w-full px-3 py-2.5 rounded-lg text-sm focus:outline-none focus:ring-2",style:{border:"1px solid #E8DDD0",color:k,background:"#fff"},children:[e.jsx("option",{value:"",children:"â Select a program â"}),t.programs.map(m=>e.jsxs("option",{value:m.name,children:[m.name," (",m.hours,")"]},m.name)),e.jsx("option",{value:"Undecided",children:"Undecided / Multiple programs"})]})]}),e.jsxs("div",{children:[e.jsxs("label",{className:"block text-xs font-semibold mb-1",style:{color:k},children:[e.jsx(At,{size:11,className:"inline mr-1 -mt-0.5"}),"Preferred Tour Date"]}),e.jsx("input",{name:"preferredDate",type:"date",min:u,max:p,value:s.preferredDate,onChange:l,className:"w-full px-3 py-2.5 rounded-lg text-sm focus:outline-none focus:ring-2",style:{border:"1px solid #E8DDD0",color:k}})]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs font-semibold mb-1",style:{color:k},children:"Anything we should know?"}),e.jsx("textarea",{name:"notes",value:s.notes,onChange:l,rows:3,placeholder:`Bringing a guest? Need bilingual support? Funding questions for the ${t.city} campus?`,className:"w-full px-3 py-2.5 rounded-lg text-sm focus:outline-none focus:ring-2 resize-none",style:{border:"1px solid #E8DDD0",color:k}})]}),e.jsxs("label",{htmlFor:"smsOptIn",className:`flex items-start gap-3 p-3 rounded-lg cursor-pointer transition-all ${s.smsOptIn?""
1228:"hover:bg-amber-50/40"}`,style:{border:`1.5px solid ${s.smsOptIn?$:"#E8DDD0"}`,background:s.smsOptIn?`${$}10`:"#FCFAF4"},children:[e.jsx("input",{id:"smsOptIn",name:"smsOptIn",type:"checkbox",checked:s.smsOptIn,onChange:l,disabled:!s.phone.trim(),className:"mt-0.5 w-4 h-4 rounded shrink-0 cursor-pointer disabled:cursor-not-allowed disabled:opacity-50",style:{accentColor:kp}}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("p",{className:"text-sm font-bold flex items-center gap-1.5",style:{color:k},children:[e.jsx(Qt,{size:12,style:{color:kp}}),"Text me a reminder too",!s.phone.trim()&&e.jsx("span",{className:"text-[10px] font-normal italic",style:{color:"#999"},children:"(enter a phone number above to enable)"})]}),e.jsx("p",{className:"text-[11px] mt-0.5 leading-relaxed",style:{color:"#666"},children:"Send me a friendly SMS reminder ~24 hours before my tour, in addition to the email confirmation. Standard message rates may apply. Reply STOP at any time to opt out."})]})]}),i&&e.jsxs("div",{className:"text-xs px-3 py-2 rounded-lg",style:{background:"rgba(220,38,38,0.08)",color:"#B91C1C",border:"1px solid #FCA5A5"},children:[i," â Or call ",e.jsx("a",{href:`tel:${t.phone}`,className:"underline font-semibold",children:t.phoneDisplay}),"."]}),e.jsxs("button",{type:"submit",disabled:a==="submitting",className:"w-full py-3.5 rounded-xl font-bold text-sm uppercase tracking-[0.15em] transition-all hover:-translate-y-0.5 disabled:opacity-60 disabled:cursor-not-allowed",style:{background:`linear-gradient(135deg, ${$}, ${kp})`,color:k,boxShadow:`0 6px 20px ${$}33`},children:[e.jsx(Hs,{size:14,className:"inline mr-2 -mt-0.5"}),a==="submitting"?"Sending Requestâ¦":`Request Tour of ${t.city} Campus`]}),e.jsx("p",{className:"text-[10px] text-center",style:{color:"#777"},children:"By submitting, you agree to be contacted by Zorganics Admissions. We respect your privacy and never share your information."})]})})]})]})})},MX=({loc:t})=>e.jsxs(e.Fragment,{children:[e.jsx(LX,{}),e.jsx(OX,{loc:t})]}),Ts={kicker:t=>`${t} Campus`,heading:t=>`Programs Offered at ${t}`,intro:t=>`Explore professional beauty and wellness education at the Zorganics Institute of Beauty & Wellness ${t} Campus. Our programs combine structured theory education, hands-on learning, supervised practical experience, professional development, and preparation for Washington State licensure.`,philosophy:"A Holistic Approach to Beauty & Wellness Through Science & Art",availabilityNote:"Program availability and upcoming start dates may vary by enrollment period.",groups:[{id:"licensure",heading:"Licensure Programs"},{id:"advanced",heading:"Advanced & Professional Education"}],statusLabels:{Enrolling:"Enrolling",Waitlist:"Waitlist","Coming Soon":"Coming Soon",Varies:"Enrollment Availability Varies"},additionalSkills:{heading:"Additional Skills Within Your Education",title:"Eyelash Extension Training",badge:"Included in the Esthetician Program",body:"Esthetician students receive hands-on education in eyelash extension application as part of their professional training, including client consultation, application techniques, safety, sanitation, and aftercare.",disclaimer:"Eyelash extension training is incorporated within the Esthetician educational experience and is not presented as a separate Washington State licensure program."},hybrid:{heading:"Flexible Learning. Hands-On Experience.",body:"Zorganics Institute offers an approved hybrid learning model that combines digital learning with structured on-campus instruction and hands-on practical education.",body2:"Students develop theoretical knowledge while building professional skills through supervised learning and practical experiences appropriate to their program."},closing:{heading:"Begin Your Journey at Zorganics",lead:"Your licensed career starts with one application.",body:"Discover a professional learning environment where science, artistry, hands-on experience, and holistic beauty and wellness education come together to prepare you for your future.",ctas:[{label:"Explore Programs",href:"/programs",variant:"outline"},{label:"Apply Now",href:"/apply-now",variant:"primary"},{label:"Schedule a Campus Tour",href:"/book-online",variant:"outline"}]}},BX={established:(t,s,n)=>`Established ${t} · ${s}, ${n}`,institutionName:"Zorganics Institute of Beauty & Wellness",campusLabel:t=>`${t} Campus`,philosophy:Ts.philosophy,description:"Professional beauty and wellness education combining science-based learning, hands-on experience, professional development, and preparation for licensed careers.",recognitionHeading:"Institutional Recognition",recognition:[{key:"naccas",label:"NACCAS Accredited"},{key:"va",label:"VA Education Benefits Approved"},{key:"title-iv",label:"Federal Financial Aid Available to Those Who Qualify"},{key:"wa-state",label:"Washington State Approved Programs"}],tourCta:t=>`Tour the ${t} Campus`,callCta:t=>`Call ${t}`},Qo="#E6D2A0",IA="#B8962E",nu="#2A0810",UX="#5A1A24",qX="#FAF6ED",WX=({loc:t})=>{const s=BX,n=!!t.preLaunch,a=r=>{var i;r.preventDefault(),(i=document.getElementById("tour-this-campus"))==null||i.scrollIntoView({behavior:"smooth",block:"start"})};return e.jsxs("header",{className:"relative w-full",style:{background:`linear-gradient(180deg, ${k} 0%, ${nu} 55%, ${k} 100%)`,borderBottom:`1px solid ${$}33`},children:[e.jsx("div",{className:"absolute top-0 left-0 right-0 h-[2px]",style:{background:`linear-gradient(90deg, transparent, ${$} 50%, transparent)`},"aria-hidden":"true"}),e.jsx("div",{className:"absolute inset-0 pointer-events-none overflow-hidden","aria-hidden":"true",children:e.jsx("div",{className:"absolute inset-0 opacity-[0.04]",style:{backgroundImage:`radial-gradient(circle at 15% 20%, ${$} 0.5px, transparent 1px), 1229 radial-gradient(circle at 85% 80%, ${$} 0.5px, transparent 1px)`,backgroundSize:"64px 64px, 96px 96px"}})}),e.jsxs("div",{className:"relative max-w-[1400px] mx-auto px-4 lg:px-8 py-10 lg:py-14",children:[e.jsxs("nav",{"aria-label":"Breadcrumb",className:"mb-6 flex items-center gap-2 text-xs tracking-widest uppercase",children:[e.jsxs(be,{to:"/",className:"inline-flex items-center gap-1.5 hover:underline",style:{color:Qo,fontFamily:"'Playfair Display', Georgia, serif"},children:[e.jsx(Je,{size:12})," Home"]}
1229),e.jsx("span",{style:{color:$,opacity:.5},children:"/"}),e.jsx("span",{style:{color:Qo,opacity:.7},children:"Locations"}),e.jsx("span",{style:{color:$,opacity:.5},children:"/"}),e.jsx("span",{style:{color:$,fontWeight:700},children:t.city})]}),!n&&e.jsxs("div",{className:"flex items-center justify-center gap-3 mb-4",children:[e.jsx("div",{className:"h-[1px] w-10",style:{background:`linear-gradient(90deg, transparent, ${$}99)`}}),e.jsx("span",{className:"text-[10px] sm:text-[11px] tracking-[0.4em] uppercase font-semibold text-center",style:{color:Qo,fontFamily:"'Playfair Display', Georgia, serif"},children:s.established(t.openedYear,t.city,t.stateFull)}),e.jsx("div",{className:"h-[1px] w-10",style:{background:`linear-gradient(90deg, ${$}99, transparent)`}})]}),e.jsx("h1",{id:"location-h1",className:"text-center font-bold leading-[1.08] mb-3",style:{fontFamily:"'Playfair Display', Georgia, 'Times New Roman', serif",color:$,fontSize:"clamp(1.6rem, 4vw, 3.05rem)",letterSpacing:"0.005em",textShadow:`0 2px 18px ${nu}, 0 0 24px ${$}22`},children:s.institutionName}),e.jsx("h2",{className:"text-center font-semibold mb-4",style:{fontFamily:"'Playfair Display', Georgia, serif",color:Qo,fontSize:"clamp(1.05rem, 2.2vw, 1.55rem)",letterSpacing:"0.02em"},children:n&&t.facilityComingSoon?t.facilityComingSoon.heading:s.campusLabel(t.city)}),e.jsx("p",{className:"text-center font-bold text-sm sm:text-base mb-4 px-4",style:{color:$,fontFamily:"'Playfair Display', Georgia, serif"},children:s.philosophy}),e.jsx("p",{className:"text-center max-w-3xl mx-auto text-sm sm:text-[15px] leading-relaxed mb-8 px-4",style:{color:qX,opacity:.88},children:s.description}),!n&&e.jsx("div",{className:"flex items-center justify-center mb-10",children:e.jsxs("div",{className:"inline-flex items-center gap-2 sm:gap-3 px-4 sm:px-6 py-2.5 rounded-full",style:{background:`linear-gradient(135deg, ${$}14, ${$}08)`,border:`1px solid ${$}40`,boxShadow:`0 2px 16px ${nu}, inset 0 1px 0 ${$}22`},children:[e.jsx(zt,{size:14,style:{color:$}}),e.jsxs("address",{className:"not-italic text-xs sm:text-sm font-semibold tracking-wide",style:{color:Qo,fontFamily:"'Playfair Display', Georgia, serif"},children:[t.street,t.suite?`, ${t.suite}`:""," · ",t.city,", ",t.state," ",t.postalCode]})]})}),e.jsxs("section",{"aria-labelledby":"institutional-recognition-heading",children:[e.jsx("h3",{id:"institutional-recognition-heading",className:"text-center text-[11px] sm:text-xs tracking-[0.35em] uppercase font-semibold mb-5",style:{color:Qo,fontFamily:"'Playfair Display', Georgia, serif"},children:s.recognitionHeading}),e.jsx("ul",{className:"flex flex-wrap items-stretch justify-center gap-2.5 sm:gap-3 list-none p-0 m-0","aria-label":s.recognitionHeading,children:s.recognition.map(r=>e.jsxs("li",{className:"flex items-center gap-2.5 px-4 py-2.5 rounded-xl",style:{background:`linear-gradient(135deg, ${UX}CC, ${nu}CC)`,border:`1px solid ${$}55`,boxShadow:`0 4px 16px ${nu}99`},children:[e.jsx("span",{className:"w-7 h-7 rounded-lg flex items-center justify-center shrink-0",style:{background:`linear-gradient(135deg, ${$}, ${IA})`},"aria-hidden":"true",children:e.jsx(fO,{size:14,style:{color:k}})}),e.jsx("span",{className:"text-[11px] sm:text-xs font-bold leading-snug",style:{color:$,fontFamily:"'Playfair Display', Georgia, serif"},children:r.label})]},r.key))})]}),!n&&e.jsxs("div",{className:"mt-9 flex flex-wrap items-center justify-center gap-3",children:[e.jsxs("a",{href:"#tour-this-campus",onClick:a,className:"group inline-flex items-center gap-2 px-6 py-3 rounded-full font-bold text-sm uppercase tracking-[0.15em] transition-all hover:-translate-y-0.5",style:{background:`linear-gradient(135deg, ${$}, ${IA})`,color:nu,boxShadow:`0 8px 24px ${$}44, 0 0 0 1px ${Qo}55`},children:[e.jsx(At,{size:15}),s.tourCta(t.city),e.jsx(Vt,{size:15,className:"group-hover:translate-x-1 transition-transform"})]}),e.jsxs("a",{href:`tel:${t.phone}`,className:"inline-flex items-center gap-2 px-6 py-3 rounded-full font-semibold text-sm transition-all hover:-translate-y-0.5",style:{background:"transparent",color:Qo,border:`1px solid ${$}66`},children:[e.jsx(Qt,{size:14}
1229),s.callCta(t.phoneDisplay)]})]})]}),e.jsx("div",{className:"absolute bottom-0 left-0 right-0 h-[2px]",style:{background:`linear-gradient(90deg, transparent, ${$} 50%, transparent)`},"aria-hidden":"true"})]})},Rn="#B8962E",$A="#2A0810",Ov="#FAF6ED",zA={Enrolling:{bg:"#0F5132",color:"#D1F4DB",border:"#198754"},Waitlist:{bg:"#664D03",color:"#FFECB5",border:"#FFC107"},"Coming Soon":{bg:"#1E293B",color:"#CBD5E1",border:"#64748B"},Varies:{bg:"#3B2A0A",color:"#F2E2B6",border:"#B8962E"}},qI=({status:t})=>{const s=zA[t]??zA["Coming Soon"];return e.jsx("span",{className:"px-2.5 py-1 rounded-full text-[9px] font-bold uppercase tracking-widest whitespace-nowrap",style:{background:s.bg,color:s.color,border:`1px solid ${s.border}66`},children:Ts.statusLabels[t]??t})},HX=({program:t})=>e.jsxs("article",{className:"rounded-2xl p-6 lg:p-7 transition-all hover:-translate-y-0.5 h-full flex flex-col",style:{background:"#fff",border:`1px solid ${k}15`,boxShadow:`0 4px 18px ${k}0D`},children:[e.jsxs("div",{className:"flex items-start justify-between gap-3 mb-4",children:[e.jsx("div",{className:"w-11 h-11 rounded-xl flex items-center justify-center shrink-0",style:{background:`linear-gradient(135deg, ${$}, ${Rn})`},"aria-hidden":"true",children:e.jsx(_t,{size:19,style:{color:k}})}),e.jsx(qI,{status:t.status})]}),e.jsx("h4",{className:"text-lg lg:text-xl font-bold leading-snug",style:{color:k,fontFamily:"'Playfair Display', Georgia, serif"},children:t.name}),e.jsxs("div",{className:"mt-1.5 mb-3 text-[11px] font-bold uppercase tracking-[0.2em]",style:{color:Rn},children:[t.hours,t.duration?` · ${t.duration}`:""]}),t.tag&&e.jsxs("div",{className:"inline-flex self-start items-center gap-1 text-[9px] font-bold uppercase tracking-widest mb-3 px-2 py-0.5 rounded",style:{background:`${$}22`,color:Rn},children:[e.jsx(zo,{size:9})," ",t.tag]}),t.description&&e.jsx("p",{className:"text-sm leading-relaxed",style:{color:"#4A4A4A"},children:t.description})]}),GX=({program:t})=>e.jsxs("div",{className:"group rounded-xl p-5 transition-all hover:-translate-y-0.5",style:{background:"#fff",border:`1px solid ${k}15`,boxShadow:`0 2px 12px ${k}08`},children:[e.jsxs("div",{className:"flex items-start justify-between gap-3 mb-3",children:[e.jsx("div",{className:"w-10 h-10 rounded-lg flex items-center justify-center shrink-0",style:{background:`linear-gradient(135deg, ${$}, ${Rn})`},"aria-hidden":"true",children:e.jsx(_t,{size:18,style:{color:k}})}),e.jsx(qI,{status:t.status})]}),e.jsx("h3",{className:"text-base font-bold mb-1",style:{color:k,fontFamily:"'Playfair Display', Georgia, serif"},children:t.name}),t.tag&&e.jsxs("div",{className:"inline-flex items-center gap-1 text-[9px] font-bold uppercase tracking-widest mb-3 px-2 py-0.5 rounded",style:{background:`${$}22`,color:Rn},children:[e.jsx(zo,{size:9})," ",t.tag]}),e.jsxs("div",{className:"flex items-center gap-3 text-xs mt-3 pt-3 border-t",style:{borderColor:`${k}10`,color:"#666"},children:[t.duration&&e.jsxs(e.Fragment,{children:[e.jsxs("span",{className:"flex items-center gap-1.5",children:[e.jsx(_a,{size:12})," ",t.duration]}),e.jsx("span",{className:"opacity-40",children:"·"})]}),e.jsx("span",{className:"font-semibold",children:t.hours})]})]}),VX=({loc:t})=>{const s=t.programs.some(n=>!!n.group);return e.jsx("section",{className:"py-14 lg:py-20",style:{background:`linear-gradient(180deg, ${Ov} 0%, #fff 100%)`,borderTop:`1px solid ${k}11`},"aria-labelledby":"programs-heading",children:e.jsxs("div",{className:"max-w-[1400px] mx-auto px-4 lg:px-8",children:[e.jsxs("div",{className:"flex items-center justify-center gap-3 mb-3",children:[e.jsx("div",{className:"h-[1px] w-12",style:{background:`linear-gradient(90deg, transparent, ${Rn}99)`}}),e.jsx("span",{className:"text-[10px] sm:text-[11px] tracking-[0.4em] uppercase font-semibold text-center",style:{color:Rn},children:Ts.kicker(t.city)}),e.jsx("div",{className:"h-[1px] w-12",style:{background:`linear-gradient(90deg, ${Rn}99, transparent)`}})]}),e.jsx("h2",{id:"programs-heading",className:"text-center font-bold mb-5",style:{fontFamily:"'Playfair Display', Georgia, serif",color:k,fontSize:"clamp(1.5rem, 3.2vw, 2.5rem)"},children:Ts.heading(t.city)}),s?e.jsxs(e.Fragment,{children:[e.jsx("p",{className:"text-center text-[15px] leading-relaxed max-w-3xl mx-auto mb-6",style:{color:"#4A4A4A"},children:Ts.intro(t.city)}),e.jsx("p",{className:"text-center italic font-semibold mb-4 px-4",style:{color:Rn,fontFamily:"'Playfair Display', Georgia, serif",fontSize:"clamp(0.95rem, 1.8vw, 1.15rem)"},children:Ts.philosophy}),e.jsx("p",{className:"text-center text-xs mb-12",style:{color:"#7A7A7A"},children:Ts.availabilityNote}),Ts.groups.map(n=>{const a=t.programs.filter(r=>
1229r.group===n.id);return a.length===0?null:e.jsxs("div",{className:"mb-14",children:[e.jsxs("div",{className:"flex items-center gap-3 mb-6",children:[e.jsx("span",{className:"w-9 h-9 rounded-lg flex items-center justify-center shrink-0",style:{background:`${k}`,border:`1px solid ${$}55`},"aria-hidden":"true",children:n.id==="licensure"?e.jsx(Is,{size:16,style:{color:$}}):e.jsx(Qe,{size:16,style:{color:$}})}),e.jsx("h3",{className:"font-bold",style:{color:k,fontFamily:"'Playfair Display', Georgia, serif",fontSize:"clamp(1.15rem, 2.2vw, 1.6rem)"},children:n.heading}),e.jsx("div",{className:"flex-1 h-[1px]",style:{background:`linear-gradient(90deg, ${Rn}55, transparent)`}})]}),e.jsx("div",{className:"grid md:grid-cols-2 gap-5",children:a.map(r=>e.jsx(HX,{program:r},r.name))})]},n.id)}),e.jsxs("div",{className:"mb-14",children:[e.jsxs("div",{className:"flex items-center gap-3 mb-6",children:[e.jsx("span",{className:"w-9 h-9 rounded-lg flex items-center justify-center shrink-0",style:{background:`${k}`,border:`1px solid ${$}55`},"aria-hidden":"true",children:e.jsx(zo,{size:16,style:{color:$}})}),e.jsx("h3",{className:"font-bold",style:{color:k,fontFamily:"'Playfair Display', Georgia, serif",fontSize:"clamp(1.15rem, 2.2vw, 1.6rem)"},children:Ts.additionalSkills.heading}),e.jsx("div",{className:"flex-1 h-[1px]",style:{background:`linear-gradient(90deg, ${Rn}55, transparent)`}})]}),e.jsxs("div",{className:"rounded-2xl p-6 lg:p-8",style:{background:"#fff",border:`1px solid ${$}44`,boxShadow:`0 4px 18px ${k}0D`},children:[e.jsx("h4",{className:"text-lg lg:text-xl font-bold mb-2",style:{color:k,fontFamily:"'Playfair Display', Georgia, serif"},children:Ts.additionalSkills.title}),e.jsxs("div",{className:"inline-flex items-center gap-1.5 mb-4 px-3 py-1 rounded-full text-[10px] font-bold uppercase tracking-[0.16em]",style:{background:`${$}22`,color:Rn,border:`1px solid ${$}55`},children:[e.jsx(Is,{size:11})," ",Ts.additionalSkills.badge]}),e.jsx("p",{className:"text-sm leading-relaxed mb-4",style:{color:"#4A4A4A"},children:Ts.additionalSkills.body}),e.jsxs("div",{className:"flex items-start gap-2 rounded-lg p-3.5 text-xs leading-relaxed",style:{background:`${k}08`,border:`1px solid ${k}15`,color:"#5A5A5A"},children:[e.jsx(Bi,{size:14,className:"shrink-0 mt-0.5",style:{color:Rn}}),e.jsx("span",{children:Ts.additionalSkills.disclaimer})]})]})]}),e.jsxs("div",{className:"rounded-2xl p-7 lg:p-10 mb-14",style:{background:`linear-gradient(135deg, ${k} 0%, ${$A} 100%)`,border:`1px solid ${$}44`,boxShadow:`0 12px 36px ${k}22`},children:[e.jsxs("div",{className:"flex items-center gap-3 mb-4",children:[e.jsx("span",{className:"w-10 h-10 rounded-xl flex items-center justify-center shrink-0",style:{background:`linear-gradient(135deg, ${$}, ${Rn})`},"aria-hidden":"true",children:e.jsx(IO,{size:18,style:{color:k}})}),e.jsx("h3",{className:"font-bold",style:{color:$,fontFamily:"'Playfair Display', Georgia, serif",fontSize:"clamp(1.15rem, 2.2vw, 1.6rem)"},children:Ts.hybrid.heading})]}),e.jsx("p",{className:"text-sm leading-relaxed mb-3",style:{color:Ov,opacity:.92},children:Ts.hybrid.body}),e.jsx("p",{className:"text-sm leading-relaxed",style:{color:Ov,opacity:.85},children:Ts.hybrid.body2})]}),e.jsxs("div",{className:"text-center max-w-3xl mx-auto",children:[e.jsx("h3",{className:"font-bold mb-3",style:{color:k,fontFamily:"'Playfair Display', Georgia, serif",fontSize:"clamp(1.3rem, 2.8vw, 2rem)"},children:Ts.closing.heading}),e.jsx("p",{className:"italic mb-3",style:{color:Rn,fontFamily:"'Playfair Display', Georgia, serif"},children:Ts.closing.lead}),e.jsx("p",{className:"text-sm leading-relaxed mb-8",style:{color:"#4A4A4A"},children:Ts.closing.body}),e.jsx("div",{className:"flex flex-wrap items-center justify-center gap-3",children:Ts.closing.ctas.map(n=>e.jsxs("a",{href:n.href,className:"inline-flex items-center gap-2 px-6 py-3 rounded-full font-bold text-sm uppercase tracking-[0.12em] transition-all hover:-translate-y-0.5",style:n.variant==="primary"?{background:`linear-gradient(135deg, ${$}, ${Rn})`,color:$A,boxShadow:`0 8px 24px ${$}44`}:{background:"#fff",color:k,border:`1px solid ${k}33`},children:[n.label,e.jsx(Vt,{size:14})]},n.label))})]})]}):e.jsxs(e.Fragment,{children:[e.jsx("p",{className:"text-center text-sm max-w-2xl mx-auto mb-10",style:{color:"#555"},children:Ts.availabilityNote}),e.jsx("div",{className:"grid sm:grid-cols-2 lg:grid-cols-3 gap-5",children:t.programs.map(n=>e.jsx(GX,{program:n},n.name))})]})]})})}
1229,Mv={kicker:"Future Expansion",heading:"Growing the Zorganics Vision",intro:"Zorganics Institute of Beauty & Wellness is exploring future expansion opportunities in the Greater Seattle and South King County areas as part of our long-term vision to make professional beauty and wellness education accessible to more students throughout Washington State.",introEmphasis:"Greater Seattle and South King County areas",regions:[{key:"greater-seattle",name:"Greater Seattle Area",status:"Future Expansion Planned",description:"Zorganics is evaluating opportunities for a future location serving students in the Greater Seattle area."},{key:"south-king-county",name:"South King County",status:"Future Expansion Planned",description:"Zorganics is evaluating opportunities for a future location serving students in South King County."}],disclaimer:"Future locations, programs, opening dates, and enrollment availability will be announced after required locations, approvals, and institutional plans are finalized.",interest:{heading:"Interested in a Future Zorganics Location?",body:"Prospective students interested in receiving updates about future locations may contact our Admissions team.",phone:Fi,phoneHref:`tel:${Fx}`,email:In,emailHref:`mailto:${In}`},currentCampusLabel:"Current Campus:",currentCampusValue:"Bellingham, Washington"},LA="#E6D2A0",Jo="#B8962E",OA="#2A0810",MA="#FAF6ED",ZX=()=>{const{kicker:t,heading:s,intro:n,introEmphasis:a,regions:r,disclaimer:i,interest:o}=Mv,[l,c]=n.split(a);return e.jsx("section",{className:"py-14 lg:py-20",style:{background:MA},"aria-labelledby":"future-expansion-heading",children:e.jsxs("div",{className:"max-w-[1100px] mx-auto px-4 lg:px-8",children:[e.jsxs("div",{className:"flex items-center justify-center gap-3 mb-3",children:[e.jsx("div",{className:"h-[1px] w-10",style:{background:`linear-gradient(90deg, transparent, ${Jo}99)`}}),e.jsxs("span",{className:"inline-flex items-center gap-1.5 text-[10px] sm:text-[11px] tracking-[0.4em] uppercase font-semibold",style:{color:Jo},children:[e.jsx(_O,{size:12})," ",t]}),e.jsx("div",{className:"h-[1px] w-10",style:{background:`linear-gradient(90deg, ${Jo}99, transparent)`}})]}),e.jsx("h2",{id:"future-expansion-heading",className:"text-center font-bold mb-4",style:{fontFamily:"'Playfair Display', Georgia, serif",color:k,fontSize:"clamp(1.4rem, 2.9vw, 2.1rem)"},children:s}),e.jsxs("p",{className:"text-center text-sm sm:text-[15px] leading-relaxed max-w-3xl mx-auto mb-10",style:{color:"#4A4A4A"},children:[l,e.jsx("strong",{style:{color:k},children:a}),c]}),e.jsx("div",{className:"grid sm:grid-cols-2 gap-5",children:r.map(u=>e.jsxs("article",{className:"rounded-xl p-6 h-full",style:{background:"#fff",border:`1px solid ${k}18`,boxShadow:`0 6px 22px ${k}10`},children:[e.jsxs("div",{className:"flex items-start justify-between gap-3 mb-3",children:[e.jsx("h3",{className:"text-lg font-bold leading-snug",style:{fontFamily:"'Playfair Display', Georgia, serif",color:k},children:u.name}),e.jsx(zt,{size:16,className:"shrink-0 mt-1",style:{color:Jo}})]}),e.jsx("span",{className:"inline-block px-3 py-1 rounded-full text-[10px] font-bold uppercase tracking-[0.18em] mb-3",style:{background:`${$}1F`,color:Jo,border:`1px solid ${Jo}44`},children:u.status}),e.jsx("p",{className:"text-sm leading-relaxed",style:{color:"#4A4A4A"},children:u.description})]},u.key))}),e.jsxs("div",{className:"mt-6 rounded-xl px-5 py-4 flex items-start gap-3",style:{background:`${k}08`,border:`1px dashed ${k}25`},children:[e.jsx(Bi,{size:15,className:"shrink-0 mt-0.5",style:{color:Jo}}),e.jsx("p",{className:"text-xs sm:text-[13px] italic leading-relaxed",style:{color:"#5A5A5A"},children:i})]}),e.jsxs("div",{className:"mt-8 rounded-2xl p-7 text-center",style:{background:`linear-gradient(135deg, ${k}, ${OA})`,border:`1px solid ${$}44`,boxShadow:`0 10px 32px ${k}22`},children:[e.jsx("h3",{className:"text-xl font-bold mb-2",style:{fontFamily:"'Playfair Display', Georgia, serif",color:$},children:o.heading}),e.jsx("p",{className:"text-sm max-w-2xl mx-auto mb-6",style:{color:MA,opacity:.9},children:o.body}),e.jsxs("div",{className:"flex flex-wrap items-center justify-center gap-3",children:[e.jsxs("a",{href:o.phoneHref,className:"inline-flex items-center gap-2 px-6 py-3 rounded-full font-bold text-sm transition-all hover:-translate-y-0.5",style:{background:`linear-gradient(135deg, ${$}, ${Jo})`,color:OA,boxShadow:`0 6px 20px ${$}33`},children:[e.jsx(Qt,{size:15})," ",o.phone]}),e.jsxs("a",{href:o.emailHref,className:"inline-flex items-center gap-2 px-6 py-3 rounded-full font-semibold text-sm transition-all hover:-translate-y-0.5 break-all",style:{color:LA,border:`1px solid ${$}66`},children:[e.jsx(Ye,{size:15})," ",o.email]})]}),e.jsxs("div",{className:"mt-6 pt-5 flex items-center justify-center gap-2 text-xs",style:{borderTop:`1px solid ${$}26`,color:LA},children:[e.jsx(Ws,{size:13,style:{color:$}}),e.jsxs("span",{children:[e.jsx("strong",{style:{color:$},children:Mv.currentCampusLabel})," ",Mv.currentCampusValue]})]})]})]})})},ci="#E6D2A0",Sp="#B8962E",ng="#2A0810",Xo="#FAF6ED";function YX(t){d.useEffect(()=>{const s=typeof window<"u"?window.location.origin:"",a=`${s?s.replace(/^https?:\/\/zorganicsinstitute\.edu$/i,"https://www.zorganicsinstitute.edu"):"https://www.zorganicsinstitute.edu"}/locations/${t.slug}`,r=document.title,i=t.slug==="bellingham";document.title=`${t.h1} | ${t.city}, ${t.state}`;const o=(N,b)=>{let f=document.head.querySelector(N);return f||(f=document.createElement("meta"),Object.entries(b).forEach(([j,S])=>{j!=="content"&&f.setAttribute(j,S)}),document.head.appendChild(f)),f.setAttribute("content",b.content),f},l=[],c=N=>l.push(N),u=document.head.querySelector('meta[name="robots"]'),p=!!u,m=(u==null?void 0:u.getAttribute("content"))??null,x=o('meta[name="robots"]',{name:"robots",content:i?"index, follow, max-image-preview:large":"noindex, nofollow"});p||c(x),i&&(c(o('meta[name="description"]',{name:"description",content:t.metaDescription})),c(o('meta[property="og:title"]',{property:"og:title",content:t.h1})),c(o('meta[property="og:description"]',{property:"og:description",content:t.metaDescription})),c(o('meta[property="og:url"]',{property:"og:url",content:a})),c(o('meta[property="og:type"]',{property:"og:type",content:"website"})),c(o('meta[property="og:locale"]',{property:"og:locale",content:"en_US"})),c(o('meta[name="twitter:card"]',{name:"twitter:card",content:"summary_large_image"})),c(o('meta[name="twitter:title"]',{name:"twitter:title",content:t.h1})),c(o('meta[name="twitter:description"]',{name:"twitter:description",content:t.metaDescription})),c(o('meta[name="geo.region"]',{name:"geo.region",content:`US-${t.state}`})),c(o('meta[name="geo.placename"]',{name:"geo.placename",content:`${t.city}, ${t.stateFull}`})),c(o('meta[name="geo.position"]',{name:"geo.position",content:`${t.latitude};${t.longitude}`})),c(o('meta[name="ICBM"]',{name:"ICBM",content:`${t.latitude}, ${t.longitude}`})));
1229let h=null,y=!1,v,g=null;if(i){h=document.head.querySelector('link[rel="canonical"]'),y=!!h,v=h==null?void 0:h.href,h||(h=document.createElement("link"),h.setAttribute("rel","canonical"),document.head.appendChild(h)),h.setAttribute("href",a);const N={"@context":"https://schema.org","@type":["LocalBusiness","EducationalOrganization"],"@id":`${a}#localbusiness`,name:t.name,alternateName:"Zorganics Institute of Beauty & Wellness",description:t.metaDescription,url:a,telephone:t.phone,email:t.email,slogan:"Redefining the foundation of identity.",foundingDate:String(t.openedYear),founder:{"@type":"Person",name:"Frida Emalange",jobTitle:"Master Educator"},address:{"@type":"PostalAddress",streetAddress:t.suite?`${t.street}, ${t.suite}`:t.street,addressLocality:t.city,addressRegion:t.state,postalCode:t.postalCode,addressCountry:"US"},geo:{"@type":"GeoCoordinates",latitude:t.latitude,longitude:t.longitude},areaServed:[t.city,t.region],openingHoursSpecification:t.hours.filter(f=>f.open!=="Closed").map(f=>({"@type":"OpeningHoursSpecification",dayOfWeek:f.days,opens:f.open,closes:f.close})),hasOfferCatalog:{"@type":"OfferCatalog",name:`${t.city} Programs`,itemListElement:t.programs.map((f,j)=>({"@type":"Offer",position:j+1,itemOffered:{"@type":"Course",name:f.name,timeRequired:f.hours},availability:f.status==="Enrolling"?"https://schema.org/InStock":f.status==="Waitlist"||f.status==="Varies"?"https://schema.org/LimitedAvailability":"https://schema.org/PreOrder"}))},sameAs:[`${Mi}/`]},b=`ld-location-${t.slug}`;g=document.getElementById(b),g||(g=document.createElement("script"),g.type="application/ld+json",g.id=b,document.head.appendChild(g)),g.textContent=JSON.stringify(N)}return()=>{document.title=r,p&&m!==null?x.setAttribute("content",m):!p&&x.parentNode&&x.parentNode.removeChild(x),g&&g.parentNode&&g.parentNode.removeChild(g),h&&(!y&&h.parentNode?h.parentNode.removeChild(h):y&&v&&h.setAttribute("href",v));const N=document.head.querySelector('meta[name="description"]');N&&N.setAttribute("content","Redefining the foundation of identity. Washington's premier clinical beauty school specializing in the 'Inside-Out' philosophy, oncology esthetics, and 100% vegan botanical science. Founded by Master Educator Frida Emalange.")}},[t])}const KX=()=>{const{slug:t}=Wo(),s=Za(),n=d.useMemo(()=>t?PK(t):null,[t]);if(YX(n??Th[0]),!n)return e.jsx(UI,{});const a=!!n.preLaunch,r=`https://www.google.com/maps?q=${encodeURIComponent(`${n.street}, ${n.city}, ${n.state} ${n.postalCode}`)}&output=embed`,i=`https://www.google.com/maps/dir/?api=1&destination=${n.latitude},${n.longitude}&destination_place_id=${encodeURIComponent(n.mapQuery)}`;return e.jsxs("main",{style:{background:Xo,minHeight:"100vh"},className:"w-full","aria-labelledby":"location-h1",children:[e.jsx(WX,{loc:n}),e.jsx("section",{className:"max-w-[1400px] mx-auto px-4 lg:px-8 py-12 lg:py-16",children:e.jsxs("div",{className:"grid lg:grid-cols-5 gap-8",children:[!a&&e.jsxs("div",{className:"lg:col-span-2 rounded-2xl p-7 relative overflow-hidden",style:{background:`linear-gradient(180deg, ${k} 0%, ${ng} 100%)`,color:Xo,boxShadow:`0 12px 40px ${k}33`,border:`1px solid ${$}33`},"aria-labelledby":"nap-heading",itemScope:!0,itemType:"https://schema.org/LocalBusiness",children:[e.jsx("div",{className:"absolute top-0 right-0 w-32 h-32 rounded-full blur-3xl op
1229acity-20",style:{background:$},"aria-hidden":"true"}),e.jsxs("div",{className:"relative",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-4 text-xs tracking-[0.3em] uppercase",style:{color:ci},children:[e.jsx(Ws,{size:12})," Contact & Hours"]}),e.jsx("h2",{id:"nap-heading",className:"text-2xl font-bold mb-1",style:{fontFamily:"'Playfair Display', Georgia, serif",color:$},itemProp:"name",children:n.name}),e.jsx("p",{className:"text-xs italic mb-6",style:{color:ci,opacity:.75},children:n.region}),e.jsxs("div",{className:"flex items-start gap-3 mb-5",itemProp:"address",itemScope:!0,itemType:"https://schema.org/PostalAddress",children:[e.jsx(zt,{size:18,className:"shrink-0 mt-0.5",style:{color:$}}),e.jsxs("div",{className:"text-sm leading-relaxed",children:[e.jsxs("div",{itemProp:"streetAddress",children:[n.street,n.suite?`, ${n.suite}`:""]}),e.jsxs("div",{children:[e.jsx("span",{itemProp:"addressLocality",children:n.city}),","," ",e.jsx("span",{itemProp:"addressRegion",children:n.state})," ",e.jsx("span",{itemProp:"postalCode",children:n.postalCode})]}),e.jsx("meta",{itemProp:"addressCountry",content:"US"})]})]}),e.jsxs("a",{href:`tel:${n.phone}`,className:"flex items-start gap-3 mb-4 hover:opacity-80 transition-opacity",itemProp:"telephone",children:[e.jsx(Qt,{size:18,className:"shrink-0 mt-0.5",style:{color:$}}),e.jsxs("div",{children:[e.jsx("div",{className:"text-sm font-semibold",children:n.phoneDisplay}),e.jsx("div",{className:"text-[11px] uppercase tracking-widest",style:{color:ci,opacity:.7},children:"Admissions Direct Line"})]})]}),e.jsxs("a",{href:`mailto:${n.email}`,className:"flex items-start gap-3 mb-6 hover:opacity-80 transition-opacity",itemProp:"email",children:[e.jsx(Ye,{size:18,className:"shrink-0 mt-0.5",style:{color:$}}),e.jsx("div",{className:"text-sm break-all",children:n.email})]}),e.jsx("meta",{itemProp:"latitude",content:String(n.latitude)}),e.jsx("meta",{itemProp:"longitude",content:String(n.longitude)}),e.jsxs("div",{className:"pt-5 border-t",style:{borderColor:`${$}33`},children:[e.jsxs("div",{className:"flex items-center gap-2 mb-3 text-xs tracking-[0.3em] uppercase",style:{color:ci},children:[e.jsx(dt,{size:12})," Hours of Operation"]}),e.jsx("ul",{className:"space-y-1.5 text-sm",children:n.hours.map(o=>e.jsxs("li",{className:"flex justify-between gap-4",children:[e.jsx("span",{style:{color:ci},children:o.days}),e.jsx("span",{className:"font-semibold tabular-nums",style:{color:Xo},children:o.open==="Closed"?"Closed":`${o.open} â ${o.close}`})]},o.days))})]}),e.jsxs("div",{className:"mt-6 pt-5 border-t",style:{borderColor:`${$}33`},children:[e.jsxs("div",{className:"flex items-center gap-2 mb-2 text-xs tracking-[0.3em] uppercase",style:{color:ci},children:[e.jsx(ts,{size:12})," Campus Leadership"]}),e.jsx("div",{className:"text-sm font-semibold",style:{color:$},children:n.director.name}),e.jsx("div",{className:"text-xs italic",style:{color:ci,opacity:.8},children:n.director.title})]}),e.jsxs("a",{href:i,target:"_blank",rel:"noopener noreferrer",className:"mt-6 w-full inline-flex items-center justify-center gap-2 px-5 py-3 rounded-lg font-bold text-sm transition-all hover:-translate-y-0.5",style:{background:`linear-gradient(135deg, ${$}, ${Sp})`,color:k,boxShadow:`0 6px 20px ${$}33`},children:[e.jsx(eC,{size:16})," Get Driving Directions"]})]})]}),e.jsxs("div",{className:`${a?"lg:col-span-5":"lg:col-span-3"} flex flex-col gap-6`,children:[!a&&e.jsxs("div",{className:"rounded-2xl overflow-hidden",style:{border:`1px solid ${k}22`,boxShadow:`0 12px 40px ${k}15`},children:[e.jsxs("div",{className:"px-5 py-3 flex items-center justify-between",style:{background:k,color:$},children:[e.jsx("span",{className:"text-xs tracking-[0.3em] uppercase font-semibold",children:"Campus Location Map"}),e.jsxs("span",{className:"text-[10px] tracking-widest",style:{color:ci,opacity:.7},children:[n.latitude.toFixed(4),"°N, ",Math.abs(n.longitude).toFixed(4),"°W"]})]}),e.jsx("iframe",{title:`Google Map â ${n.name}`,src:r,width:"100%",height:"420",style:{border:0,display:"block"},loading:"lazy",referrerPolicy:"no-referrer-when-downgrade",allowFullScreen:!0})]}),e.jsx("div",{className:"rounded-2xl p-6",style:{background:"#fff",border:`1px solid ${k}15`,boxShadow:`0 4px 20px ${k}08`},children:n.facilityComingSoon?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex items-center gap-2 mb-3 text-xs tracking-[0.3em] uppercase",style:{color:k},children:[e.jsx(Qe,{size:12})," ",n.facilityComingSoon.heading]}),n.facilityComingSoon.paragraphs.map(o=>e.jsx("p",{className:"text-sm leading-relaxed mb-4",style:{color:"#444"},children:o},o)),e.jsxs("div",{className:"mt-5 pt-5",style:{borderTop:`1px solid ${k}15`},children:[e.jsx("h3",{className:"text-base font-bold mb-2",style:{fontFamily:"'Playfair Display', Georgia, serif",color:k},children:n.facilityComingSoon.interestHeading}),e.jsx("p",{className:"text-sm leading-relaxed mb-4",style:{color:"#444"},children:n.facilityComingSoon.interestBody}),e.jsxs("div",{className:"flex flex-wrap items-center gap-4 mb-5",children:[e.jsxs("a",{href:n.facilityComingSoon.phoneHref,className:"inline-flex items-center gap-2 text-sm font-semibold transition-opacity hover:opacity-70",style:{color:k},children:[e.jsx(Qt,{size:15,style:{color:Sp}}),n.facilityComingSoon.phone]}),e.jsxs("a",{href:n.facilityComingSoon.emailHref,className:"inline-flex items-center gap-2 text-sm font-semibold break-all transition-opacity hover:opacity-70",style:{color:k},children:[e.jsx(Ye,{size:15,style:{color:Sp}}),n.facilityComingSoon.email]})]}),e.jsxs("a",{href:n.facilityComingSoon.ctaHref,className:"inline-flex items-center justify-center gap-2 px-6 py-3 rounded-lg font-bold text-sm transition-all hover:-translate-y-0.5",style:{background:`linear-gradient(135deg, ${$}, ${Sp})`,color:k,boxShadow:`0 6px 20px ${$}33`},children:[e.jsx(Ye,{size:15})," ",n.facilityComingSoon.ctaLabel]})]})]}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex items-center gap-2 mb-3 text-xs tracking-[0.3em] uppercase",style:{color:k},children:[e.jsx(Qe,{size:12})," Our ",n.city," Facility"]}),e.jsx("p",{className:"text-sm leading-relaxed mb-4",style:{color:"#444"},children:n.facilityNarrative}),e.jsx("div",{className:"grid sm:grid-cols-2 gap-2",children:n.facilityHighlights.map(o=>e.jsxs("div",{className:"flex items-start gap-2 text-sm",children:[e.jsx(Ue,{size:15,className:"shrink-0 mt-0.5",style:{color:Sp}}),e.jsx("span",{style:{color:"#333"},children:o})]},o))})]})})]})]})}),!a&&e.jsx(VX,{loc:n}),!a&&e.jsx("section",{className:"py-14 lg:py-20",style:{background:k,color:Xo},"aria-labelledby":"directions-heading",children:e.jsxs("div",{className:"max-w-[1400px] mx-auto px-4 lg:px-8",children:[e.jsxs("div",{className:"flex items-center justify-center gap-3 mb-3",children:[e.jsx("div",{className:"h-[1px] w-12",style:{background:`linear-gradient(90deg, transparent, ${$}99)`}}),e.jsxs("span",{className:"text-[10px] sm:text-[11px] tracking-[0.4em] uppercase font-semibold",style:{color:ci},children:["Getting to ",n.city]}),e.jsx("div",{className:"h-[1px] w-12",style:{background:`linear-gradient(90deg, ${$}99, transparent)`}})]}),e.jsx("h2",{id:"directions-heading",className:"text-center font-bold mb-12",style:{fontFamily:"'Playfair Display', Georgia, serif",color:$,fontSize:"clamp(1.5rem, 3.2vw, 2.5rem)"},children:"Directions & Transit"}),e.jsxs("div",{className:"grid lg:grid-cols-3 gap-6",children:[e.jsxs("div",{className:"rounded-xl p-6",style:{background:ng,border:`1px solid ${$}33`},children:[e.jsxs("div",{className:"flex items-center gap-2 mb-4 text-xs tracking-[0.3em] uppercase",style:{color:$},children:[e.jsx(eC,{size:14})," By Car"]}),e.jsx("ul",{className:"space-y-4",children:n.drivingDirections.map(o=>e.jsxs("li",{children:[e.jsxs("div",{className:"text-sm font-bold",style:{color:ci},children:["From ",o.from]}),e.jsx("div",{className:"text-xs mt-1 leading-relaxed",style:{color:Xo,opacity:.85},children:o.route}),e.jsx("div",{className:"inline-block mt-1.5 px-2 py-0.5 rounded text-[10px] font-semibold uppercase tracking-widest",style:{background:`${$}22`,color:$},children:o.eta})]},o.from))})]}),e.jsxs("div",{className:"rounded-xl p-6",style:{background:ng,border:`1px solid ${$}33`},children:[e.jsxs("div",{className:"flex items-center gap-2 mb-4 text-xs tracking-[0.3em] uppercase",style:{color:$},children:[e.jsx(yO,{size:14})," Public Transit"]}),e.jsx("ul",{className:"space-y-3",children:n.transit.map(o=>e.jsxs("li",{className:"flex items-start gap-2 text-sm",style:{color:Xo,opacity:.9},children:[e.jsx(Ue,{size:14,className:"shrink-0 mt-0.5",style:{color:$}}),e.jsx("span",{children:o})]},o))})]}),e.jsxs("div",{className:"rounded-xl p-6",style:{background:ng,border:`1px solid ${$}33`},children:[e.jsxs("div",{className:"flex items-center gap-2 mb-4 text-xs tracking-[0.3em] uppercase",style:{color:$},children:[e.jsx(Zm,{size:14})," Nearby Landmarks"]}),e.jsx("ul",{className:"space-y-3",children:n.landmarks.map(o=>e.jsxs("li",{className:"flex items-start gap-2 text-sm",style:{color:Xo,opacity:.9},children:[e.jsx(zt,{size:14,className:"shrink-0 mt-0.5",style:{color:$}}),e.jsx("span",{children:o})]},o))})]})]})]})}),!a&&e.jsx(MX,{loc:n}),e.jsx(ZX,{}),e.jsx("section",{className:"pb-14 lg:pb-20",style:{background:Xo},children:e.jsx("div",{className:"max-w-[1400px] mx-auto px-4 lg:px-8",children:e.jsx("div",{className:"text-center",children:e.jsxs("button",{onClick:()=>s("/"),className:"inline-flex items-center gap-2 px-6 py-3 rounded-lg font-semibold text-sm transition-all hover:-translate-y-0.5",style:{background:k,color:$,border:`1px solid ${$}55`},children:[e.jsx(Je,{size:15})," Return to Zorganics Home"]})})})})]})},ag={minPassingGrade:"76%",minAttendance:"90%"},rg={primaryName:"Zorganics LMS (Z-LMS)",textbookProvider:"Milady",textbookDescription:"Milady supplies the required textbooks and eBooks for each program. Textbooks are learning resources that accompany your Z-LMS coursew
1229ork.",futureIntegrationNote:"Digital textbook and eBook resource integration is planned for a future Z-LMS release. Until then, all coursework, grades and progress are delivered exclusively through Zorganics LMS."},BA={bellingham:"Bellingham · 410 W Bakerview Rd, Suite 112",seattle:"Seattle Campus · Coming Soon",renton:"Renton Campus · Coming Soon"},QX=({studentName:t="Scholar",studentEmail:s,campus:n,program:a="Esthetics",cimaCompletionPct:r=42,classroomAssignmentsDue:i=3,onOpenLms:o})=>{const c=BA[n||"bellingham"]||BA.bellingham,u=parseInt(ag.minPassingGrade,10)||76;return e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between px-5 py-3 rounded-xl",style:{background:"linear-gradient(135deg, rgba(212,175,55,0.08) 0%, rgba(230,210,160,0.04) 100%)",border:"1px solid rgba(212,175,55,0.25)"},children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"w-9 h-9 rounded-lg flex items-center justify-center",style:{background:"linear-gradient(135deg, #3B0A11 0%, #2A0810 100%)"},children:e.jsx(Xe,{size:15,style:{color:"#D4AF37"}})}),e.jsxs("div",{children:[e.jsx("p",{className:"text-xs font-bold tracking-wide uppercase",style:{color:"#E6D2A0"},children:"Single Sign-On Active"}),e.jsxs("p",{className:"text-[11px] mt-0.5",style:{color:"rgba(230,210,160,0.65)"},children:[s||`${t.toLowerCase().replace(/\s+/g,".")}@zorganicsinstitute.edu`," · ",e.jsx("span",{style:{color:"#D4AF37"},children:"Zorganics Institute Scholar Account"})]})]})]}),e.jsxs("span",{className:"flex items-center gap-1.5 px-3 py-1 rounded-full text-[10px] font-bold uppercase tracking-wider",style:{background:"rgba(34,197,94,0.15)",color:"#34D399",border:"1px solid rgba(34,197,94,0.35)"},children:[e.jsx(Ue,{size:10}),"Handshake Verified"]})]}),e.jsxs("div",{className:"grid md:grid-cols-2 gap-4",children:[e.jsxs("button",{type:"button",onClick:()=>o==null?void 0:o(),className:"group relative overflow-hidden rounded-2xl p-6 text-left transition-all duration-300 hover:scale-[1.02]",style:{background:"linear-gradient(135deg, #3B0A11 0%, #2A0810 100%)",border:"1.5px solid rgba(212,175,55,0.35)",boxShadow:"0 12px 32px rgba(59,10,17,0.35), inset 0 1px 0 rgba(212,175,55,0.2)"},"aria-label":"Open Zorganics LMS â your primary learning platform",children:[e.jsx("div",{className:"absolute top-0 right-0 px-3 py-1 text-[9px] font-bold uppercase tracking-widest",style:{background:"linear-gradient(135deg, #E6D2A0 0%, #D4AF37 50%, #B8962E 100%)",color:"#3B0A11",borderBottomLeftRadius:"12px",letterSpacing:"0.14em"},children:"Primary Platform"}),e.jsxs("div",{className:"flex items-start gap-4 mb-4",children:[e.jsx("div",{className:"w-14 h-14 rounded-xl flex items-center justify-center flex-shrink-0 transition-transform duration-300 group-hover:rotate-6",style:{background:"linear-gradient(135deg, #E6D2A0 0%, #D4AF37 50%, #B8962E 100%)",boxShadow:"0 6px 20px rgba(212,175,55,0.45)"},children:e.jsx(_t,{size:26,style:{color:"#3B0A11"}})}),e.jsxs("div",{className:"flex-1",children:[e.jsx("p",{className:"text-[10px] font-bold uppercase tracking-widest",style:{color:"#D4AF37"},children:rg.primaryName}),e.jsx("h3",{className:"text-xl font-bold mt-1",style:{color:"#F0E4C4",fontFamily:"Playfair Display, serif"},children:"Theory, Grades & Clock Hours"}),e.jsx("p",{className:"text-[11px] mt-1.5 leading-relaxed",style:{color:"rgba(230,210,160,0.75)"},children:"State-board curriculum, chapter quizzes, NACCAS-aligned clinical modules, attendance and announcements â all delivered inside Zorganics LMS."})]})]}),e.jsxs("div",{className:"mb-4",children:[e.jsxs("div",{className:"flex items-center justify-between mb-1.5",children:[e.jsxs("span",{className:"text-[10px] font-bold uppercase tracking-wider",style:{color:"rgba(230,210,160,0.65)"},children:[a," Modules"]}),e.jsxs("span",{className:"text-xs font-bold",style:{color:"#D4AF37"},children:[r,"% · Passing Grade ",ag.minPassingGrade]})]}),e.jsxs("div",{className:"relative h-2 rounded-full overflow-hidden",style:{background:"rgba(212,175,55,0.1)",border:"1px solid rgba(212,175,55,0.15)"},children:[e.jsx("div",{className:"absolute inset-y-0 left-0 rounded-full transition-all duration-700",style:{width:`${r}%`,background:`linear-gradient(90deg, ${r>=u?"#34D399":"#D4AF37"} 0%, ${r>=u?"#10B981":"#E6D2A0"} 100%)`,boxShadow:"0 0 12px rgba(212,175,55,0.4)"}}),e.jsx("div",{className:"absolute inset-y-0 w-px",style:{left:`${u}%`,background:"rgba(230,210,160,0.5)"}})]})]}),e.jsxs("div",{className:"flex items-center justify-between px-4 py-2.5 rounded-lg transition-all group-hover:bg-opacity-90",style:{background:"linear-gradient(135deg, #E6D2A0 0%, #D4AF37 50%, #B8962E 100%)",boxShadow:"0 4px 14px rgba(212,175,55,0.35)"},children:[e.jsx("span",{className:"text-xs font-bold uppercase tracking-widest",style:{color:"#3B0A11",letterSpacing:"0.1em"},children:"Open Zorganics LMS"}),e.jsx(Ua,{size:14,style:{color:"#3B0A11"}})]}),e.jsxs("p",{className:"text-[10px] mt-3 text-center",style:{color:"rgba(230,210,160,0.5)"},children:["Completions record to your student record · ",i," item(s) awaiting you"]})]}),e.jsxs("div",{className:"relative overflow-hidden rounded-2xl p-6",style:{background:"linear-gradient(135deg, #3B0A11 0%, #2A
12290810 100%)",border:"1.5px solid rgba(212,175,55,0.25)",boxShadow:"0 12px 32px rgba(59,10,17,0.28), inset 0 1px 0 rgba(212,175,55,0.15)"},children:[e.jsx("div",{className:"absolute top-0 right-0 px-3 py-1 text-[9px] font-bold uppercase tracking-widest",style:{background:"rgba(212,175,55,0.18)",color:"#E6D2A0",borderBottomLeftRadius:"12px",letterSpacing:"0.14em",borderLeft:"1px solid rgba(212,175,55,0.3)",borderBottom:"1px solid rgba(212,175,55,0.3)"},children:"Coming Soon"}),e.jsxs("div",{className:"flex items-start gap-4 mb-4",children:[e.jsx("div",{className:"w-14 h-14 rounded-xl flex items-center justify-center flex-shrink-0",style:{background:"rgba(212,175,55,0.14)",border:"1px solid rgba(212,175,55,0.3)"},children:e.jsx(Na,{size:26,style:{color:"#D4AF37"}})}),e.jsxs("div",{className:"flex-1",children:[e.jsxs("p",{className:"text-[10px] font-bold uppercase tracking-widest",style:{color:"#D4AF37"},children:[rg.textbookProvider," Textbooks & eBooks"]}),e.jsx("h3",{className:"text-xl font-bold mt-1",style:{color:"#F0E4C4",fontFamily:"Playfair Display, serif"},children:"Your Learning Resources"}),e.jsx("p",{className:"text-[11px] mt-1.5 leading-relaxed",style:{color:"rgba(230,210,160,0.75)"},children:rg.textbookDescription})]})]}),e.jsx("div",{className:"flex items-center gap-2 mb-4",children:e.jsxs("span",{className:"flex-1 px-3 py-2 rounded-lg text-[11px] font-semibold",style:{background:"rgba(212,175,55,0.08)",border:"1px solid rgba(212,175,55,0.2)",color:"#E6D2A0"},children:[e.jsx("span",{style:{color:"#D4AF37"},children:"Campus:"})," ",c]})}),e.jsxs("div",{className:"flex items-center justify-center gap-2 px-4 py-2.5 rounded-lg",style:{background:"rgba(212,175,55,0.1)",border:"1px dashed rgba(212,175,55,0.4)"},children:[e.jsx(dt,{size:13,style:{color:"#D4AF37"}}),e.jsx("span",{className:"text-xs font-bold uppercase tracking-widest",style:{color:"#E6D2A0",letterSpacing:"0.08em"},children:"Digital Resource Access â Coming Soon"})]}),e.jsx("p",{className:"text-[10px] mt-3 text-center leading-relaxed",style:{color:"rgba(230,210,160,0.5)"},children:rg.futureIntegrationNote})]})]}),e.jsxs("div",{className:"flex items-center justify-center gap-4 text-[10px] pt-2 flex-wrap",style:{color:"rgba(230,210,160,0.5)"},children:[e.jsxs("span",{className:"flex items-center gap-1.5",children:[e.jsx(Qe,{size:10,style:{color:"#D4AF37"}}),"Z-LMS completions â student record"]}),e.jsx("span",{style:{color:"rgba(212,175,55,0.3)"},children:"·"}),e.jsxs("span",{className:"flex items-center gap-1.5",children:[e.jsx(_t,{size:10,style:{color:"#D4AF37"}}),ag.minPassingGrade," passing grade · ",ag.minAttendance," attendance"]}),e.jsx("span",{style:{color:"rgba(212,175,55,0.3)"},children:"·"}),e.jsxs("span",{className:"flex items-center gap-1.5",children:[e.jsx(Xe,{size:10,style:{color:"#D4AF37"}}),"Encrypted sign-in"]})]})]})},UA=76,JX={esthetics:750,cosmetology:1600,manicurist:600,"master-esthetics-1200":1200,"master-esthetics-bridge":450,"massage-therapy":625,instructor:600},qA={esthetics:"Esthetics",cosmetology:"Cosmetology",manicurist:"Manicurist","master-esthetics-1200":"Master Esthetics","master-esthetics-bridge":"Master Bridge","massage-therapy":"Massage Therapy",instructor:"Instructor"},WA={bellingham:"Bellingham",seattle:"Seattle",renton:"Renton"},XX=t=>t.split(" ").map(s=>s[0]).join("").toUpperCase().slice(0,2),eee=({limit:t,showFilters:s=!0})=>{const[n,a]=d.useState([]),[r,i]=d.useState(!0),[o,l]=d.useState("all"),[c,u]=d.useState("all");d.useEffect(()=>{(async()=>{i(!0);const{data:y}=await O.from("sis_students").select("*").eq("enrollment_status","active").order("student_id");if(!y){a([]),i(!1);return}const v=y.map(S=>S.id),{data:g}=await O.from("sis_clock_hours").select("student_id, total_hours").in("student_id",v),N={};(g||[]).forEach(S=>{N[S.student_id]=(N[S.student_id]||0)+Number(S.total_hours||0)});const{data:b}=await O.from("sis_sap_checkpoints").select("student_id, attendance_pct, gpa, checkpoint_date").in("student_id",v).order("checkpoint_date",{ascending:!1}),f={};(b||[]).forEach(S=>{S.student_id in f||(f[S.student_id]=Number(S.attendance_pct||0))});const j=y.map(S=>({...S,computed_hours:N[S.id]||0,computed_sap_pct:f[S.id]||70+Math.abs(S.student_id.charCo
1229deAt(S.student_id.length-1))%25}));a(j),i(!1)})()},[]);const p=d.useMemo(()=>{let h=n;return o!=="all"&&(h=h.filter(y=>y.campus===o)),c!=="all"&&(h=h.filter(y=>y.program===c)),t&&(h=h.slice(0,t)),h},[n,o,c,t]),m=d.useMemo(()=>Array.from(new Set(n.map(h=>h.campus).filter(Boolean))),[n]),x=d.useMemo(()=>Array.from(new Set(n.map(h=>h.program))),[n]);return e.jsxs("div",{children:[s&&e.jsxs("div",{className:"flex items-center justify-between mb-5",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"w-10 h-10 rounded-xl flex items-center justify-center",style:{background:"linear-gradient(135deg, #E6D2A0 0%, #D4AF37 50%, #B8962E 100%)"},children:e.jsx(ts,{size:18,style:{color:"#3B0A11"}})}),e.jsxs("div",{children:[e.jsx("p",{className:"text-[10px] font-bold uppercase tracking-[0.18em]",style:{color:"#D4AF37"},children:"Executive Grid · No Raw Lists"}),e.jsx("h3",{className:"text-lg font-bold",style:{color:"#F0E4C4",fontFamily:"Playfair Display, serif"},children:"Active Scholar Identity Cards"})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(ei,{size:13,style:{color:"rgba(230,210,160,0.5)"}}),e.jsxs("select",{value:o,onChange:h=>l(h.target.value),className:"px-3 py-1.5 rounded-lg text-[11px] font-semibold focus:outline-none",style:{background:"rgba(212,175,55,0.08)",border:"1px solid rgba(212,175,55,0.25)",color:"#E6D2A0"},children:[e.jsx("option",{value:"all",children:"All Campuses"}),m.map(h=>e.jsx("option",{value:h,style:{background:"#3B0A11"},children:WA[h]||h},h))]}),e.jsxs("select",{value:c,onChange:h=>u(h.target.value),className:"px-3 py-1.5 rounded-lg text-[11px] font-semibold focus:outline-none",style:{background:"rgba(212,175,55,0.08)",border:"1px solid rgba(212,175,55,0.25)",color:"#E6D2A0"},children:[e.jsx("option",{value:"all",children:"All Programs"}),x.map(h=>e.jsx("option",{value:h,style:{background:"#3B0A11"},children:qA[h]||h},h))]})]})]}),r?e.jsx("div",{className:"grid sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4 gap-4",children:Array.from({length:8}).map((h,y)=>e.jsx("div",{className:"h-48 rounded-2xl animate-pulse",style:{background:"rgba(212,175,55,0.04)",border:"1px solid rgba(212,175,55,0.1)"}},y))}):p.length===0?e.jsxs("div",{className:"p-10 text-center rounded-2xl",style:{background:"rgba(212,175,55,0.04)",border:"1px dashed rgba(212,175,55,0.25)"},children:[e.jsx(ts,{size:28,className:"mx-auto mb-3",style:{color:"#D4AF37"}}),e.jsx("p",{className:"text-sm font-semibold",style:{color:"#E6D2A0"},children:"No scholars match these filters"})]}):e.jsx("div",{className:"grid sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4 gap-4",children:p.map(h=>{const y=JX[h.program]||750,v=Math.min(100,Math.round((h.computed_hours||0)/y*100)),g=Math.round(h.computed_sap_pct||0),N=g>=UA,b=h.uniform_compliant!==!1;return e.jsxs("div",{className:"group relative rounded-2xl overflow-hidden transition-all duration-300 hover:scale-[1.02]",style:{background:"linear-gradient(155deg, #3B0A11 0%, #2A0810 100%)",border:"1.5px solid rgba(212,175,55,0.3)",boxShadow:"0 8px 24px rgba(59,10,17,0.35), inset 0 1px 0 rgba(212,175,55,0.12)"},children:[e.jsx("div",{className:"h-[2px]",style:{background:"linear-gradient(90deg, transparent 0%, #D4AF37 50%, transparent 100%)"}}),e.jsxs("div",{className:"p-4",children:[e.jsxs("div",{className:"flex items-center gap-3 mb-3",children:[e.jsxs("div",{className:"relative flex-shrink-0",children:[h.avatar_url?e.jsx("img",{src:h.avatar_url,alt:h.full_name,className:"w-14 h-14 rounded-xl object-cover",style:{border:"2px solid #D4AF37",boxShadow:"0 4px 12px rgba(212,175,55,0.3)"}}):e.jsx("div",{className:"w-14 h-14 rounded-xl flex items-center justify-center font-bold text-lg",style:{background:"linear-gradient(135deg, #E6D2A0 0%, #D4AF37 50%, #B8962E 100%)",color:"#3B0A11",border:"2px solid rgba(212,175,55,0.5)",boxShadow:"0 4px 12px rgba(212,175,55,0.3)",fontFamily:"Playfair Display, serif"},children:XX(h.full_name)}),e.jsx("span",{className:"absolute -bottom-0.5 -right-0.5 w-3.5 h-3.5 rounded-full",style:{background:"#34D399",border:"2px s
1229olid #3B0A11",boxShadow:"0 0 6px rgba(52,211,153,0.6)"}})]}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"font-bold text-sm truncate",style:{color:"#F0E4C4",fontFamily:"Playfair Display, serif"},children:h.full_name}),e.jsx("p",{className:"text-[9px] font-mono truncate",style:{color:"rgba(212,175,55,0.7)"},children:h.student_id}),e.jsx("p",{className:"text-[9px] font-semibold mt-0.5",style:{color:"#D4AF37"},children:qA[h.program]||h.program})]})]}),e.jsxs("div",{className:"mb-3",children:[e.jsxs("div",{className:"flex items-center justify-between mb-1",children:[e.jsxs("span",{className:"flex items-center gap-1 text-[9px] font-bold uppercase tracking-wider",style:{color:"rgba(230,210,160,0.6)"},children:[e.jsx(dt,{size:9})," Clock Hours"]}),e.jsxs("span",{className:"text-[10px] font-bold",style:{color:"#E6D2A0"},children:[Math.round(h.computed_hours||0),"/",y]})]}),e.jsx("div",{className:"h-1 rounded-full overflow-hidden",style:{background:"rgba(212,175,55,0.1)"},children:e.jsx("div",{className:"h-full rounded-full transition-all duration-700",style:{width:`${v}%`,background:"linear-gradient(90deg, #D4AF37 0%, #E6D2A0 100%)"}})})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[e.jsxs("div",{className:"p-2 rounded-lg",style:{background:N?"rgba(34,197,94,0.1)":"rgba(239,68,68,0.1)",border:`1px solid ${N?"rgba(34,197,94,0.3)":"rgba(239,68,68,0.3)"}`},children:[e.jsxs("div",{className:"flex items-center gap-1.5 mb-1",children:[e.jsx("span",{className:"w-2 h-2 rounded-full",style:{background:N?"#34D399":"#EF4444",boxShadow:`0 0 8px ${N?"rgba(52,211,153,0.7)":"rgba(239,68,68,0.7)"}`,animation:N?"none":"pulse 1.5s ease-in-out infinite"}}),e.jsx("span",{className:"text-[9px] font-bold uppercase tracking-wider",style:{color:N?"#34D399":"#EF4444"},children:"SAP"})]}),e.jsxs("p",{className:"text-[10px] font-bold",style:{color:"#F0E4C4"},children:[g,"% ",e.jsxs("span",{className:"text-[8px] font-normal",style:{color:"rgba(230,210,160,0.5)"},children:["/ ",UA,"%"]})]})]}),e.jsxs("div",{className:"p-2 rounded-lg",style:{background:b?"rgba(34,197,94,0.1)":"rgba(239,68,68,0.1)",border:`1px solid ${b?"rgba(34,197,94,0.3)":"rgba(239,68,68,0.3)"}`},children:[e.jsxs("div",{className:"flex items-center gap-1.5 mb-1",children:[e.jsx("span",{className:"w-2 h-2 rounded-full",style:{background:b?"#34D399":"#EF4444",boxShadow:`0 0 8px ${b?"rgba(52,211,153,0.7)":"rgba(239,68,68,0.7)"}`,animation:b?"none":"pulse 1.5s ease-in-out infinite"}}),e.jsx("span",{className:"text-[9px] font-bold uppercase tracking-wider",style:{color:b?"#34D399":"#EF4444"},children:"Uniform"})]}),e.jsx("p",{className:"text-[10px] font-bold",style:{color:"#F0E4C4"},children:b?e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(Ie,{size:10,style:{color:"#34D399"}})," Compliant"]}):e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(zn,{size:10,style:{color:"#EF4444"}})," Flag"]})})]})]}),h.campus&&e.jsxs("div",{className:"mt-3 pt-3 border-t flex items-center justify-between",style:{borderColor:"rgba(212,175,55,0.12)"},children:[e.jsx("span",{className:"text-[9px] font-semibold uppercase tracking-wider",style:{color:"rgba(230,210,160,0.5)"},children:WA[h.campus]||h.campus}),e.jsxs("span",{className:"flex items-center gap-1 text-[9px] font-bold",style:{color:"#D4AF37"},children:[e.jsx(Is,{size:9})," Phase ",h.phase||1]})]})]})]},h.id)})})]})},tee=({studentHours:t=450,totalHoursRequired:s=750,eligibleForProv:n=!1})=>{const a=Math.round(t/s*100);return e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"rounded-2xl overflow-hidden",style:{background:"linear-gradient(135deg, #3B0A11 0%, #2A0810 100%)",border:"1.5px solid rgba(212,175,55,0.4)",boxShadow:"0 10px 28px rgba(59,10,17,0.35)"},children:[e.jsx("div",{className:"px-5 py-3 border-b",style:{background:"linear-gradient(90deg, rgba(212,175,55,0.1) 0%, rgba(212,175,55,0.02) 100%)",borderColor:"rgba(212,175,55,0.25)"},children:e.jsxs("div",{className:"flex items-center gap-2.5",children:[e.jsx("div",{className:"w-8 h-8 rounded-lg flex items-center justify-center",style:{background:"linear-gradient(135deg, #E6D2A0 0%, #D4AF37 50%, #B8962E 100%)"},children:e.jsx(LP,{size:15,style:{color:"#3B0A11"}})}),e.jsxs("div",{children:[e.jsx("p",{className:"text-[9px] font-bold uppercase tracking-[0.18em]",style:{color:"#D4AF37"},children:"WA State Board"}),e.jsx("h4",{className:"text-sm font-bold",style:{color:"#F0E4C4",fontFamily:"Playfair Display, serif"},children:"Prov Registration"})]})]})}),e.jsxs("div",{className:"p-5 space-y-3",children:[e.jsxs("div",{className:"flex items-center justify-between p-3 rounded-lg",style:{background:"rgba(212,175,55,0.06)",border:"1px solid rgba(212,175,55,0.15)"},children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-[10px] font-bold uppercase tracking-wider",style:{color:"#D4AF37"},children:"Written + Practical"}),e.jsx("p",{className:"text-[11px] mt-0.5",style:{color:"rgba(230,210,160,0.7)"},children:"Full State Board Exam"})]}),e.jsx("span",{className:"text-lg font-bold",style:{color:"#E6D2A0",fontFamily:"Playfair Display, serif"},children:"$169"})]}),e.jsxs("div",{className:"flex items-center justify-between p-3 rounded-lg",style:{background:"rgba(212,175,55,0.06)",border:"1px solid rgba(212,175,55,0.15)"},children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-[10px] font-bold uppercase tracking-wider",style:{color:"#D4AF37"},children:"Retake / Single Part"}),e.jsx("p",{className:"text-[11px] mt-0.5",style:{color:"rgba(230,210,160,0.7)"},children:"Written OR Practical only"})]}),e.jsx("span",{className:"text-lg font-bold",style:{color:"#E6D2A0",fontFamily:"Playfair Display, serif"},children:"$119"})]}),e.jsxs("div",{className:"pt-2",children:[e.jsxs("div",{className:"flex items-center justify-between mb-1.5",children:[e.jsx("span",{className:"text-[10px] font-bold uppercase tracking-wider",style:{color:"rgba(230,210,160,0.65)"},children:"Hours Complete"}),e.jsxs("span",{className:"text-[11px] font-bold",style:{color:n?"#34D399":"#D4AF37"},children:[t,"/",s," hrs (",a,"%)"]})]}),e.jsx("div",{className:"h-1.5 rounded-full overflow-hidden",style:{background:"rgba(212,175,55,0.1)"},children:e.jsx("div",{className:"h-full rounded-full transition-all duration-700",style:{width:`${a}%`,background:n?"linear-gradient(90deg, #10B981 0%, #34D399 100%)":"linear-gradient(90deg, #D4AF37 0%, #E6D2A0 100%)",boxShadow:"0 0 10px rgba(212,175,55,0.4)"}})})]}),e.jsxs("a",{href:"https://candidate.psiexams.com/",target:"_blank",rel:"noopener noreferrer",className:"flex items-center justify-center gap-2 w-full px-4 py-3 rounded-lg transition-all duration-300 hover:scale-[1.02]",style:{background:n?"linear-gradient(135deg, #E6D2A0 0%, #D4AF37 50%, #B8962E 100%)":"linear-gradient(135deg, rgba(212,175,55,0.2) 0%, rgba(184,150,46,0.15) 100%)",color:n?"#3B0A11":"#D4AF37",border:n?"none":"1px solid rgba(212,175,55,0.35)",boxShadow:n?"0 4px 14px rgba(212,175,55,0.4)":"none",opacity:n?1:.9},children:[e.jsx("span",{className:"text-xs font-bold uppercase tracking-widest",style:{letterSpacing:"0.1em"},children:n?"Register for State Board":"View Registration Info"}),e.jsx(Ua,{size:13})]}),e.jsxs("p",{className:"text-[10px] text-center flex items-center justify-center gap-1.5",style:{color:"rgba(230,210,160,0.5)"},children:[e.jsx(Ie,{size:10,style:{color:"#D4AF37"}}),"Secure scholar-portal access only"]})]})]}),e.jsxs("div",{className:"rounded-2xl overflow-hidden",style:{background:"linear-gradient(135deg, #3B0A11 0%, #2A
12290810 100%)",border:"1.5px solid rgba(212,175,55,0.4)",boxShadow:"0 10px 28px rgba(59,10,17,0.35)"},children:[e.jsx("div",{className:"px-5 py-3 border-b",style:{background:"linear-gradient(90deg, rgba(212,175,55,0.1) 0%, rgba(212,175,55,0.02) 100%)",borderColor:"rgba(212,175,55,0.25)"},children:e.jsxs("div",{className:"flex items-center gap-2.5",children:[e.jsx("div",{className:"w-8 h-8 rounded-lg flex items-center justify-center",style:{background:"linear-gradient(135deg, #E6D2A0 0%, #D4AF37 50%, #B8962E 100%)"},children:e.jsx(Ws,{size:15,style:{color:"#3B0A11"}})}),e.jsxs("div",{children:[e.jsx("p",{className:"text-[9px] font-bold uppercase tracking-[0.18em]",style:{color:"#D4AF37"},children:"Coming August 2026"}),e.jsx("h4",{className:"text-sm font-bold",style:{color:"#F0E4C4",fontFamily:"Playfair Display, serif"},children:"Renton Campus"})]})]})}),e.jsxs("div",{className:"p-5 space-y-3",children:[e.jsxs("div",{className:"flex items-start gap-2.5",children:[e.jsx(zt,{size:13,style:{color:"#D4AF37"},className:"mt-0.5 flex-shrink-0"}),e.jsxs("p",{className:"text-[11px] leading-relaxed",style:{color:"#E6D2A0"},children:["Renton Campus â Coming August 2026",e.jsx("br",{}),e.jsx("span",{style:{color:"rgba(230,210,160,0.55)"},children:"Our South King County expansion, bringing Zorganics programs closer to Greater Seattle students."})]})]}),e.jsx("div",{className:"space-y-2 pt-1",children:[{icon:e.jsx(PO,{size:11}),label:"Site Build-out",status:"In Progress",dot:"#D4AF37"},{icon:e.jsx(At,{size:11}),label:"Doors Open",status:"August 2026",dot:"#34D399"},{icon:e.jsx(Ro,{size:11}),label:"Foundation Grants",status:"$480K raised",dot:"#34D399"}].map((r,i)=>e.jsxs("div",{className:"flex items-center justify-between px-3 py-2 rounded-lg",style:{background:"rgba(212,175,55,0.05)",border:"1px solid rgba(212,175,55,0.12)"},children:[e.jsxs("span",{className:"flex items-center gap-2 text-[11px]",style:{color:"#E6D2A0"},children:[e.jsx("span",{style:{color:"#D4AF37"},children:r.icon}),r.label]}),e.jsxs("span",{className:"flex items-center gap-1.5 text-[10px] font-semibold",style:{color:r.dot},children:[e.jsx("span",{className:"w-1.5 h-1.5 rounded-full",style:{background:r.dot,boxShadow:`0 0 6px ${r.dot}`}}),r.status]})]},i))}),e.jsx("div",{className:"pt-2 border-t",style:{borderColor:"rgba(212,175,55,0.15)"},children:e.jsx("p",{className:"text-[10px] text-center",style:{color:"rgba(230,210,160,0.5)"},children:"Updates refresh weekly · Expansion progress"})})]})]})]})},HA=[{name:"Bellingham HQ",lat:48.75,lng:-122.48,activeScholars:0,grants:482e3,status:"healthy"},{name:"Seattle Campus",lat:47.6,lng:-122.33,activeScholars:0,grants:118e3,status:"healthy"},{name:"Renton Campus",lat:47.48,lng:-122.21,activeScholars:0,grants:94e3,status:"healthy"},{name:"LATAM â Mexico City",lat:19.43,lng:-99.13,activeScholars:1240,grants:38e3,status:"scaling"},{name:"EU â London",lat:51.5,lng:-.12,activeScholars:892,grants:52e3,status:"healthy"},{name:"AFRICA â Lagos",lat:6.52,lng:3.38,activeScholars:2140,grants:67e3,status:"scaling"},{name:"ASIA â Singapore",lat:1.35,lng:103.82,activeScholars:560,grants:29e3,status:"onboarding"},{name:"MENA â Dubai",lat:25.2,lng:55.27,activeScholars:340,grants:24e3,status:"onboarding"}],see=(t,s)=>{const n=(s+180)/360*1e3,a=(90-t)/180*500;return{x:n,y:a}},Bv={healthy:"#34D399",scaling:"#D4AF37",onboarding:"#60A5FA"},nee=()=>{const[t,s]=d.useState(HA),[n,a]=d.useState(0),[r,i]=d.useState(0);return d.useEffect(()=>{(async()=>{const{data:l}=await O.from("sis_students").select("campus, enrollment_status").eq("enrollment_status","active"),c={};(l||[]).forEach(p=>{p.campus&&(c[p.campus]=(c[p.campus]||0)+1)});const u=HA.map(p=>{const m=p.name.toLowerCase().split(" ")[0];return c[m]!==void 0?{...p,activeScholars:c[m]}:p});s(u),a(u.reduce((p,m)=>p+m.activeScholars,0)),i(u.reduce((p,m)=>p+m.grants,0))})()},[]),e.jsxs("div",{className:"rounded-2xl overflow-hidden",style:{background:"linear-gradient(155deg, #3B0A11 0%, #1A0508 100%)",border:"1.5px solid rgba(212,175,55,0.35)",boxShadow:"0 16px 40px rgba(59,10,17,0.45), inset 0 1px 0 rgba(212,175,55,0.15)"},children:[e.jsxs("div",{className:"px-6 py-4 flex items-center justify-between border-b",style:{background:"linear-gradient(90deg, rgba(212,175,55,0.1) 0%, rgba(212,175,55,0.02) 100%)",borderColor:"rgba(212,175,55,0.25)"},children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"w-11 h-11 rounded-xl flex items-center justify-center",style:{background:"linear-gradient(135deg, #E6D2A0 0%, #D4AF37 50%, #B8962E 100%)"},children:e.jsx(Bo,{size:20,style:{color:"#3B0A11"}})}),e.jsxs("div",{children:[e.jsx("p",{className:"text-[10px] font-bold uppercase tracking-[0.2em]",style:{color:"#D4AF37"},children:"Sovereign View · Super-Admin"}),e.jsx("h2",{className:"text-xl font-bold",style:{color:"#F0E4C4",fontFamily:"Playfair Display, serif"},children:"Global Impact Map"})]})]}),e.jsx("div",{className:"flex items-center gap-2",children:e.jsxs("span",{className:"flex items-center gap-1.5 px-3 py-1.5 rounded-full text-[10px] font-bold uppercase tracking-wider",style:{background:"rgba(34,197,94,0.15)",color:"#34D399",border:"1px solid rgba(34,197,94,0.35)"},children:[e.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-emerald-400 animate-pulse"}),"Multi-Region · Live"]})})]}),e.jsx("div",{className:"grid grid-cols-4 divide-x",style:{borderColor:"rgba(212,175,55,0.15)"},children:[{icon:e.jsx(ts,{size:15}
1229),label:"Active Scholars",value:n.toLocaleString(),suffix:"/ 100K capacity"},{icon:e.jsx(ta,{size:15}),label:"Foundation Grants",value:`$${(r/1e3).toFixed(0)}K`,suffix:"disbursed 2026"},{icon:e.jsx(GO,{size:15}),label:"Regional Clusters",value:String(t.length),suffix:"elastic cloud nodes"},{icon:e.jsx($i,{size:15}),label:"Reconciled TXN",value:"108,420",suffix:"EIN-tagged today"}].map((o,l)=>e.jsxs("div",{className:"px-5 py-4",style:{borderColor:"rgba(212,175,55,0.15)"},children:[e.jsxs("div",{className:"flex items-center gap-1.5 mb-1.5",style:{color:"#D4AF37"},children:[o.icon,e.jsx("span",{className:"text-[9px] font-bold uppercase tracking-wider",children:o.label})]}),e.jsx("p",{className:"text-2xl font-bold leading-none",style:{color:"#F0E4C4",fontFamily:"Playfair Display, serif"},children:o.value}),e.jsx("p",{className:"text-[10px] mt-1",style:{color:"rgba(230,210,160,0.55)"},children:o.suffix})]},l))}),e.jsxs("div",{className:"relative px-6 py-5",style:{background:"rgba(0,0,0,0.15)"},children:[e.jsxs("svg",{viewBox:"0 0 1000 500",className:"w-full h-auto",style:{maxHeight:"420px"},children:[e.jsxs("defs",{children:[e.jsx("pattern",{id:"grid",width:"50",height:"50",patternUnits:"userSpaceOnUse",children:e.jsx("path",{d:"M 50 0 L 0 0 0 50",fill:"none",stroke:"rgba(212,175,55,0.06)",strokeWidth:"0.5"})}),e.jsxs("radialGradient",{id:"pulse-gold",children:[e.jsx("stop",{offset:"0%",stopColor:"#D4AF37",stopOpacity:"0.8"}),e.jsx("stop",{offset:"100%",stopColor:"#D4AF37",stopOpacity:"0"})]})]}),e.jsx("rect",{width:"1000",height:"500",fill:"url(#grid)"}),e.jsxs("g",{fill:"rgba(212,175,55,0.08)",stroke:"rgba(212,175,55,0.25)",strokeWidth:"0.8",children:[e.jsx("path",{d:"M 150 90 Q 200 75 280 90 L 320 140 Q 310 220 260 250 Q 200 260 160 230 Q 130 180 150 90 Z"}),e.jsx("path",{d:"M 260 260 Q 290 290 300 340 L 290 410 Q 270 430 250 410 Q 240 340 260 260 Z"}),e.jsx("path",{d:"M 460 110 Q 500 100 540 120 L 560 160 Q 540 185 495 185 Q 465 170 460 110 Z"}),e.jsx("path",{d:"M 490 200 Q 540 210 565 250 L 560 340 Q 530 380 505 370 Q 480 320 485 250 Q 485 220 490 200 Z"}),e.jsx("path",{d:"M 560 110 Q 680 90 820 110 L 840 200 Q 810 250 730 260 Q 650 250 580 220 Q 560 170 560 110 Z"}),e.jsx("path",{d:"M 780 340 Q 830 330 870 350 L 870 385 Q 820 395 780 380 Z"})]}),t.map((o,l)=>{const{x:c,y:u}=see(o.lat,o.lng),p=4+Math.min(16,Math.log2(o.activeScholars+2)*2.2),m=Bv[o.status];return e.jsxs("g",{children:[e.jsxs("circle",{cx:c,cy:u,r:p*2.5,fill:"url(#pulse-gold)",children:[e.jsx("animate",{attributeName:"r",from:p,to:p*3,dur:"2.5s",repeatCount:"indefinite"}),e.jsx("animate",{attributeName:"opacity",from:"0.6",to:"0",dur:"2.5s",repeatCount:"indefinite"})]}),e.jsx("circle",{cx:c,cy:u,r:p,fill:m,stroke:"#D4AF37",strokeWidth:"1.5"}),e.jsx("text",{x:c+p+4,y:u+3,fill:"#E6D2A0",fontSize:"10",fontWeight:"600",fontFamily:"system-ui",children:o.name}),e.jsxs("text",{x:c+p+4,y:u+14,fill:"rgba(212,175,55,0.6)",fontSize:"8",fontFamily:"system-ui",children:[o.activeScholars.toLocaleString()," active · $",(o.grants/1e3).toFixed(0),"K"]})]},l)})]}),e.jsx("div",{className:"absolute top-5 right-6 flex flex-col gap-1.5 px-3 py-2 rounded-lg",style:{background:"rgba(0,0,0,0.4)",border:"1px solid rgba(212,175,55,0.2)"},children:["healthy","scaling","onboarding"].map(o=>e.jsxs("div",{className:"flex items-center gap-2 text-[9px]",style:{color:"#E6D2A0"},children:[e.jsx("span",{className:"w-2 h-2 rounded-full",style:{background:Bv[o],boxShadow:`0 0 4px ${Bv[o]}`}}),e.jsx("span",{className:"capitalize",children:o})]},o))})]}),e.jsxs("div",{className:"px-6 py-3 flex items-center justify-between text-[10px]",style:{background:"rgba(212,175,55,0.04)",borderTop:"1px solid rgba(212,175,55,0.15)",color:"rgba(230,210,160,0.6)"},children:[e.jsxs("span",{className:"flex items-center gap-1.5",children:[e.jsx(Pm,{size:10,style:{color:"#D4AF37"}}),"Elastic Infrastructure: Multi-Region · Auto-scale 0â100K"]}),e.jsxs("span",{className:"flex items-center gap-1.5",children:[e.jsx(si,{size:10,style:{color:"#34D399"}}),"Financial Master-Link: EIN routing active · Institute · Cosmetics · Foundation"]})]})]})},aee={institute:e.jsx(_t,{size:16}),cosmetics:e.jsx(Yl,{size:16}),salon:e.jsx(Ss,{size:16}),foundation:e.jsx(ta,{size:16}),global_venture:e.jsx(Bo,{size:16})},ree=({onOpenWizard:t})=>
1229{const[s,n]=d.useState([]),[a,r]=d.useState([]),[i,o]=d.useState(!0),[l,c]=d.useState(!1),[u,p]=d.useState(new Date),m=async(j=!0)=>{j&&o(!0),c(!j);const{data:S}=await O.from("zog_entity_profiles").select("*").order("is_master",{ascending:!0}).order("entity_key"),{data:w}=await O.from("zog_linked_accounts").select("*").eq("status","active");n(S||[]),r(w||[]),p(new Date),o(!1),c(!1)};d.useEffect(()=>{m();const j=setInterval(()=>m(!1),6e4);return()=>clearInterval(j)},[]);const x=j=>a.filter(S=>S.entity_profile_id===j).reduce((S,w)=>S+(w.current_balance_cents||0),0),h=j=>a.filter(S=>S.entity_profile_id===j).length,y=a.reduce((j,S)=>j+(S.current_balance_cents||0),0),v=a.reduce((j,S)=>j+(S.available_balance_cents||0),0),g=j=>`$${(j/100).toLocaleString("en-US",{minimumFractionDigits:2,maximumFractionDigits:2})}`,N=j=>j.toLocaleTimeString("en-US",{hour:"numeric",minute:"2-digit"}),b=s.filter(j=>!j.is_master),f=s.find(j=>j.is_master);return e.jsxs("section",{className:"rounded-2xl overflow-hidden",style:{background:"linear-gradient(155deg, #2A0810 0%, #1A0508 60%, #0E0204 100%)",border:"1.5px solid rgba(212,175,55,0.45)",boxShadow:"0 12px 32px rgba(0,0,0,0.5), 0 0 32px rgba(212,175,55,0.1)"},children:[e.jsxs("div",{className:"px-6 py-4 border-b flex items-center justify-between",style:{background:"linear-gradient(135deg, rgba(212,175,55,0.12) 0%, rgba(184,134,11,0.04) 100%)",borderColor:"rgba(212,175,55,0.3)"},children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"w-11 h-11 rounded-xl flex items-center justify-center",style:{background:"linear-gradient(135deg, #FFD700 0%, #D4AF37 50%, #B8860B 100%)",boxShadow:"0 6px 18px rgba(212,175,55,0.4)"},children:e.jsx(wo,{size:19,style:{color:"#3B0A11"}})}),e.jsxs("div",{children:[e.jsxs("p",{className:"text-[10px] font-bold uppercase tracking-[0.2em]",style:{color:"#D4AF37"},children:[e.jsx(Zl,{size:10,className:"inline mr-1.5 -mt-0.5"}),"Sovereign · CEO-Only"]}
1229),e.jsx("h3",{className:"text-lg font-bold",style:{color:"#F0E4C4",fontFamily:"Playfair Display, serif"},children:"Multi-Entity Cash Flow"})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("button",{onClick:()=>m(!1),disabled:l,className:"w-8 h-8 rounded-lg flex items-center justify-center transition-all hover:scale-110",style:{background:"rgba(212,175,55,0.1)",color:"#D4AF37",border:"1px solid rgba(212,175,55,0.25)"},title:"Refresh balances",children:e.jsx(Be,{size:13,className:l?"animate-spin":""})}),e.jsxs("button",{onClick:t,className:"px-3 py-1.5 rounded-lg text-[10px] font-bold uppercase tracking-widest transition-all hover:scale-105 flex items-center gap-1.5",style:{background:"linear-gradient(135deg, #FFD700 0%, #D4AF37 50%, #B8860B 100%)",color:"#3B0A11",boxShadow:"0 4px 12px rgba(212,175,55,0.3)"},children:[e.jsx(tn,{size:11}),"Connect Bank"]})]})]}),i?e.jsxs("div",{className:"py-12 text-center",style:{color:"#D4AF37"},children:[e.jsx(de,{size:22,className:"mx-auto animate-spin"}),e.jsx("p",{className:"mt-2 text-xs",children:"Syncing balances..."})]}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"px-6 py-5",style:{background:"radial-gradient(circle at top right, rgba(212,175,55,0.15), transparent 70%)",borderBottom:"1px solid rgba(212,175,55,0.18)"},children:[e.jsx("p",{className:"text-[10px] font-bold uppercase tracking-[0.18em] mb-1.5",style:{color:"#D4AF37"},children:"Consolidated Treasury · All EINs"}),e.jsxs("div",{className:"flex items-end gap-3 flex-wrap",children:[e.jsx("div",{className:"text-4xl font-bold leading-none",style:{fontFamily:"Playfair Display, serif",background:"linear-gradient(135deg, #FFD700 0%, #D4AF37 50%, #E6D2A0 100%)",WebkitBackgroundClip:"text",WebkitTextFillColor:"transparent",backgroundClip:"text"},children:g(y)}),e.jsxs("span",{className:"inline-flex items-center gap-1 text-[10px] font-bold mb-1",style:{color:"#34D399"},children:[e.jsx(si,{size:11}),"Available: ",g(v)]})]}),e.jsxs("p",{className:"text-[10px] mt-1.5",style:{color:"rgba(230,210,160,0.55)"},children:[a.length," bank account",a.length===1?"":"s"," · Last synced ",N(u)," · Auto-refresh 60s"]})]}),e.jsxs("div",{className:"p-3 space-y-1.5",children:[b.map(j=>{const S=x(j.id),w=h(j.id),_=w>0;return e.jsxs("div",{className:"flex items-center gap-3 px-3 py-2.5 rounded-lg transition-all",style:{background:_?"rgba(212,175,55,0.05)":"rgba(212,175,55,0.02)",border:`1px solid ${_?"rgba(212,175,55,0.18)":"rgba(212,175,55,0.08)"}`,opacity:_?1:.7},children:[e.jsx("div",{className:"w-8 h-8 rounded-lg flex items-center justify-center flex-shrink-0",style:{background:`linear-gradient(135deg, ${j.accent_color}40 0%, ${j.accent_color}15 100%)`,color:j.accent_color,border:`1px solid ${j.accent_color}40`},children:aee[j.entity_key]||e.jsx(Ws,{size:14})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"text-[12px] font-bold truncate",style:{color:"#F0E4C4"},children:j.entity_name}),e.jsxs("p",{className:"text-[9px] uppercase tracking-wider",style:{color:"rgba(230,210,160,0.5)"},children:["EIN ",j.ein," · ",w," acct",w===1?"":"s"]})]}),e.jsx("div",{className:"text-right flex-shrink-0",children:_?e.jsx("p",{className:"text-sm font-bold",style:{color:"#E6D2A0"},children:g(S)}):e.jsx("button",{onClick:t,className:"text-[10px] font-bold uppercase tracking-wider transition-all hover:underline",style:{color:"#D4AF37"},children:"Link â"})})]},j.id)}),f&&e.jsxs("div",{className:"flex items-center gap-3 px-3 py-3 rounded-lg mt-2",style:{background:"linear-gradient(135deg, rgba(255,215,0,0.12) 0%, rgba(184,134,11,0.04) 100%)",border:"1.5px solid rgba(255,215,0,0.4)",boxShadow:"0 4px 14px rgba(212,175,55,0.12)"},children:[e.jsx("div",{className:"w-9 h-9 rounded-lg flex items-center justify-center flex-shrink-0",style:{background:"linear-gradient(135deg, #FFD700 0%, #D4AF37 100%)",color:"#3B0A11"},children:e.jsx(Bo,{size:16})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("p",{className:"text-[12px] font-bold truncate",style:{color:"#FFD700"},children:f.entity_name}),e.jsx(Zl,{size:10,style:{color:"#FFD700"}})]}),e.jsxs("p",{className:"text-[9px] uppercase tracking-wider",style:{color:"rgba(255,215,0,0.7)"},children:["Master · EIN ",f.ein," · Consolidated"]})]}),e.jsx("div",{className:"text-right flex-shrink-0",children:h(f.id)>0?e.jsx("p",{className:"text-sm font-bold",style:{color:"#FFD700"},children:g(x(f.id))}):e.jsx("button",{onClick:t,className:"text-[10px] font-bold uppercase tracking-wider transition-all hover:underline",style:{color:"#FFD700"},children:"Link â"})})]})]}),e.jsxs("div",{className:"px-6 py-3 border-t flex items-center justify-between text-[9px]",style:{borderColor:"rgba(212,175,55,0.18)",background:"rgba(0,0,0,0.25)"},children:[e.jsxs("span",{style:{color:"rgba(230,210,160,0.5)"},children:[e.jsx(Do,{size:9,className:"inline mr-1 -mt-0.5"}),"Plaid Bank-Grade · Read-Only Sync"]}),e.jsx("span",{className:"font-bold uppercase tracking-wider",style:{color:"#D4AF37"},children:"Sovereign Treasury"})]})]})]})},iee={institute:e.jsx(_t,{size:20}
1229),cosmetics:e.jsx(Yl,{size:20}),salon:e.jsx(Ss,{size:20}),foundation:e.jsx(ta,{size:20}),global_venture:e.jsx(Bo,{size:20})},oee=({isOpen:t,onClose:s})=>{const[n,a]=d.useState([]),[r,i]=d.useState([]),[o,l]=d.useState(!1),[c,u]=d.useState(null),[p,m]=d.useState(""),[x,h]=d.useState("sandbox");d.useEffect(()=>{t&&y()},[t]);const y=async()=>{l(!0);const{data:j}=await O.from("zog_entity_profiles").select("*").order("is_master",{ascending:!0}).order("entity_key"),{data:S}=await O.from("zog_linked_accounts").select("*").eq("status","active");a(j||[]),i(S||[]),l(!1)},v=j=>r.filter(S=>S.entity_profile_id===j),g=async j=>{m(""),u(j.id);try{const{data:S,error:w}=await O.functions.invoke("plaid-link-token",{body:{entity_profile_id:j.id,entity_name:j.entity_name,user_id:"frida-sovereign"}});if(w||!(S!=null&&S.link_token))throw new Error((w==null?void 0:w.message)||(S==null?void 0:S.error)||"Failed to initialize Plaid");h(S.environment||"sandbox"),await N(),window.Plaid.create({token:S.link_token,onSuccess:async(C,E)=>{var P;try{const{data:F,error:I}=await O.functions.invoke("plaid-exchange-token",{body:{public_token:C,entity_profile_id:j.id,institution_name:((P=E==null?void 0:E.institution)==null?void 0:P.name)||"Linked Bank"}});I||F!=null&&F.error?m(`Link failed: ${(I==null?void 0:I.message)||(F==null?void 0:F.error)}`):await y()}catch(F){m(`Exchange failed: ${F.message}`)}u(null)},onExit:C=>{C&&m(C.display_message||C.error_message||"Plaid Link cancelled"),u(null)}}).open()}catch(S){m(S.message),u(null)}},N=()=>new Promise((j,S)=>{if(window.Plaid)return j();const w=document.createElement("script");w.src="https://cdn.plaid.com/link/v2/stable/link-initialize.js",w.async=!0,w.onload=()=>j(),w.onerror=()=>S(new Error("Failed to load Plaid Link script")),document.body.appendChild(w)}),b=r.length,f=new Set(r.map(j=>j.entity_profile_id)).size;return t?e.jsx("div",{className:"fixed inset-0 z-[100] flex items-center justify-center p-4",style:{background:"rgba(26,5,8,0.85)",backdropFilter:"blur(8px)"},onClick:s,children:e.jsxs("div",{className:"relative w-full max-w-5xl max-h-[92vh] overflow-hidden rounded-2xl flex flex-col",style:{background:"linear-gradient(165deg, #3B0A11 0%, #2A0810 60%, #1A0508 100%)",border:"2px solid rgba(212,175,55,0.4)",boxShadow:"0 40px 120px rgba(0,0,0,0.6), 0 0 60px rgba(212,175,55,0.15)"},onClick:j=>j.stopPropagation(),children:[e.jsx("div",{style:{height:"3px",background:"linear-gradient(90deg, transparent, #D4AF37 30%, #FFD700 50%, #D4AF37 70%, transparent)"}}),e.jsxs("div",{className:"px-7 py-5 flex items-center justify-between border-b",style:{borderColor:"rgba(212,175,55,0.2)",background:"rgba(212,175,55,0.04)"},children:[e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx("div",{className:"w-12 h-12 rounded-xl flex items-center justify-center",style:{background:"linear-gradient(135deg, #FFD700 0%, #D4AF37 50%, #B8860B 100%)",boxShadow:"0 6px 20px rgba(212,175,55,0.4)"},children:e.jsx(Zm,{size:22,style:{color:"#3B0A11"}})}),e.jsxs("div",{children:[e.jsxs("p",{className:"text-[10px] font-bold uppercase tracking-[0.2em]",style:{color:"#D4AF37"},children:[e.jsx(Zl,{size:10,className:"inline mr-1.5 -mt-0.5"}),"Sovereign Treasury · CEO Onboarding"]}),e.jsx("h2",{className:"text-2xl font-bold",style:{color:"#F0E4C4",fontFamily:"Playfair Display, serif"},children:"Multi-Entity Financial Bridge"}),e.jsx("p",{className:"text-xs mt-0.5",style:{color:"rgba(230,210,160,0.7)"},children:"Plaid · 5 EIN-Tagged Sub-Merchants · 100K-Student Architecture"})]})]}),e.jsx("button",{onClick:s,className:"w-9 h-9 rounded-full flex items-center justify-center transition-all hover:scale-110",style:{background:"rgba(212,175,55,0.1)",color:"#E6D2A0",border:"1px solid rgba(212,175,55,0.25)"},children:e.jsx(Ke,{size:18})})]}),e.jsxs("div",{className:"px-7 py-3 flex items-center justify-between text-[11px] border-b",style:{borderColor:"rgba(212,175,55,0.15)",background:"rgba(26,5,8,0.6)"},children:[e.jsxs("div",{className:"flex items-center gap-4 flex-wrap",children:[e.jsxs("span",{className:"inline-flex items-center gap-1.5 px-2.5 py-1 rounded-full font-bold uppercase tracking-wider",style:{background:"rgba(34,197,94,0.12)",color:"#34D399",border:"1px solid rgba(34,197,94,0.3)"},children:[e.jsx(Ie,{size:10}),"Bank-Grade Encryption · Plaid OAuth"]}),e.jsxs("span",{style:{color:"rgba(230,210,160,0.55)"},children:[f,"/5 Entities Linked · ",b," Accounts"]})]}),e.jsxs("span",{className:"px-2 py-0.5 rounded-full text-[9px] font-bold uppercase tracking-wider",style:{background:x==="production"?"rgba(34,197,94,0.15)":"rgba(212,175,55,0.15)",color:x==="production"?"#34D399":"#D4AF37",border:`1px solid ${x==="production"?"rgba(34,197,94,0.3)":"rgba(212,175,55,0.3)"}`},children:["ENV: ",x]})]}),e.jsxs("div",{className:"flex-1 overflow-y-auto px-7 py-6",children:[p&&e.jsxs("div",{className:"mb-5 p-3 rounded-lg flex items-start gap-2.5 text-[12px]",style:{background:"rgba(245,158,11,0.1)",color:"#FBBF24",border:"1px solid rgba(245,158,11,0.3)"},children:[e.jsx(Mt,{size:14,className:"flex-shrink-0 mt-0.5"}),e.jsx("span",{children:p})]}),o?e.jsxs("div",{className:"py-16 text-center",style:{color:"#D4AF37"},children:[e.jsx(de,{size:28,className:"mx-auto animate-spin"}),e.jsx("p",{className:"mt-3 text-xs",children:"Loading entity profiles..."})]}):e.jsx("div",{className:"space-y-3",children:n.map(j=>{const S=v(j.id),w=S.length>0,_=c===j.id;return e.jsx("div",{className:"rounded-xl overflow-hidden transition-all",style:{background:j.is_master?"linear-gradient(135deg, rgba(212,175,55,0.12) 0%, rgba(184,134,11,0.06) 100%)":"linear-gradient(135deg, rgba(59,10,17,0.6) 0%, rgba(42,8,16,0.6) 100%)",border:j.is_master?"1.5px solid rgba(255,215,0,0.5)":"1.5px solid rgba(212,175,55,0.2)",boxShadow:j.is_master?"0 8px 24px rgba(212,175,55,0.15)":"none"},children:e.jsxs("div",{className:"p-5 flex items-center gap-5",children:[e.jsx("div",{className:"flex-shrink-0 w-14 h-14 roun
1229ded-xl flex items-center justify-center",style:{background:j.is_master?"linear-gradient(135deg, #FFD700 0%, #D4AF37 100%)":`linear-gradient(135deg, ${j.accent_color}80 0%, ${j.accent_color}40 100%)`,color:j.is_master?"#3B0A11":"#F0E4C4",border:`1px solid ${j.accent_color}60`},children:iee[j.entity_key]||e.jsx(Ws,{size:20})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2 flex-wrap mb-1",children:[e.jsx("h3",{className:"text-base font-bold truncate",style:{color:"#F0E4C4",fontFamily:"Playfair Display, serif"},children:j.entity_name}),j.is_master&&e.jsxs("span",{className:"inline-flex items-center gap-1 px-2 py-0.5 rounded-full text-[9px] font-bold uppercase tracking-wider",style:{background:"linear-gradient(135deg, #FFD700, #D4AF37)",color:"#3B0A11"},children:[e.jsx(Zl,{size:9}),"Master Account"]}),e.jsxs("span",{className:"px-2 py-0.5 rounded-full text-[9px] font-bold uppercase tracking-wider",style:{background:"rgba(212,175,55,0.12)",color:"#D4AF37",border:"1px solid rgba(212,175,55,0.25)"},children:["EIN ",j.ein]})]}),e.jsxs("p",{className:"text-[11px]",style:{color:"rgba(230,210,160,0.65)"},children:[j.entity_type," · ",j.description]}),w&&e.jsx("div",{className:"mt-2.5 flex flex-wrap gap-1.5",children:S.map(C=>e.jsxs("span",{className:"inline-flex items-center gap-1.5 px-2 py-1 rounded-md text-[10px] font-semibold",style:{background:"rgba(34,197,94,0.1)",color:"#34D399",border:"1px solid rgba(34,197,94,0.25)"},children:[e.jsx(xt,{size:10}),C.institution_name," ····",C.account_mask,e.jsxs("span",{style:{color:"rgba(230,210,160,0.55)"},children:["$",(C.current_balance_cents/100).toLocaleString("en-US",{minimumFractionDigits:2,maximumFractionDigits:2})]})]},C.id))})]}),e.jsx("div",{className:"flex-shrink-0",children:e.jsx("button",{onClick:()=>g(j),disabled:_,className:"px-5 py-2.5 rounded-lg text-[11px] font-bold uppercase tracking-widest transition-all hover:scale-105 disabled:opacity-50 disabled:cursor-not-allowed flex items-center gap-2",style:{background:w?"rgba(212,175,55,0.1)":"linear-gradient(135deg, #FFD700 0%, #D4AF37 50%, #B8860B 100%)",color:w?"#D4AF37":"#3B0A11",border:w?"1px solid rgba(212,175,55,0.4)":"none",boxShadow:w?"none":"0 4px 14px rgba(212,175,55,0.35)"},children:_?e.jsxs(e.Fragment,{children:[e.jsx(de,{size:12,className:"animate-spin"}),"Linking..."]}):w?e.jsxs(e.Fragment,{children:[e.jsx(JS,{size:12}),"Add Another"]}):e.jsxs(e.Fragment,{children:[e.jsx(JS,{size:12}),"Link Bank"]})})})]})},j.id)})})]}),e.jsxs("div",{className:"px-7 py-3 border-t flex items-center justify-between text-[10px]",style:{borderColor:"rgba(212,175,55,0.2)",background:"rgba(26,5,8,0.7)"},children:[e.jsxs("span",{style:{color:"rgba(230,210,160,0.55)"},children:[e.jsx(Qe,{size:10,className:"inline mr-1.5 -mt-0.5",style:{color:"#D4AF37"}}),"Plaid handles 12,000+ banks · Read-only by default · No funds movement until you authorize"]}),e.jsx("span",{className:"font-bold uppercase tracking-wider",style:{color:"#D4AF37"},children:"Sovereign OS v26.4"})]})]})}):null},lee=[{week:1,title:"Orientation + Safety",category:"Foundation",pct:100},{week:2,title:"Sanitation & Infection Control",category:"Foundation",pct:100},{week:3,title:"Skin / Hair / Nail Anatomy",category:"Theory",pct:100},{week:4,title:"Chemistry & Formulation",category:"Theory",pct:85},{week:5,title:"Consultation Protocols",category:"Clinical",pct:60},{week:6,title:"Core Services â Mid-Term",category:"Clinical",pct:45},{week:7,title:"Advanced Modalities",category:"Clinical",pct:20},{week:8,title:"Product Knowledge & Retail",category:"Business",pct:10},{week:9,title:"Clinic Floor Rotations",category:"Clinical",pct:0},{week:10,title:"Live Model Practicum",category:"Clinical",pct:0},{week:11,title:"Mock State Board",category:"Exam Prep",pct:0},{week:12,title:"Portfolio + Prov Registration",category:"Capstone",pct:0}],cee={Foundation:"#60A5FA",Theory:"#A78BFA",Clinical:"#D4AF37",Business:"#34D399","Exam Prep":"#F59E0B",Capstone:"#E6D2A0"},dee=()=>{const{user:t,isAuthenticated:s,isSuperAdmin:n}=kn(),{student:a,isStudentAuthenticated:r}
1229=ap(),[i,o]=d.useState(6),[l,c]=d.useState(!1);d.useEffect(()=>{document.title="Scholar Portal · Zorganics Institute",document.body.style.background="linear-gradient(180deg, #3B0A11 0%, #1A0508 100%)";const h=new URLSearchParams(window.location.search);return(h.get("wizard")==="1"||h.get("onboard")==="1")&&c(!0),()=>{document.body.style.background="",document.title="Zorganics Institute"}},[]);const u=(a==null?void 0:a.fullName)||(t==null?void 0:t.fullName)||"Scholar",p=(a==null?void 0:a.email)||(t==null?void 0:t.email),m=(a==null?void 0:a.campus)||"bellingham",x=(a==null?void 0:a.program)||"esthetics";return e.jsxs("div",{className:"min-h-screen",style:{background:"linear-gradient(180deg, #3B0A11 0%, #1A0508 100%)",color:"#E6D2A0"},children:[e.jsxs("header",{className:"sticky top-0 z-40",style:{background:"linear-gradient(180deg, rgba(26,5,8,0.95) 0%, rgba(59,10,17,0.92) 100%)",backdropFilter:"blur(18px)",borderBottom:"1px solid rgba(212,175,55,0.25)"},children:[e.jsx("div",{style:{height:"2px",background:"linear-gradient(90deg, transparent 0%, #D4AF37 30%, #E6D2A0 50%, #D4AF37 70%, transparent 100%)"}}),e.jsxs("div",{className:"max-w-[1600px] mx-auto px-6 py-4 flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsxs(be,{to:"/",className:"flex items-center gap-1.5 text-[11px] font-semibold transition-all",style:{color:"rgba(230,210,160,0.7)"},children:[e.jsx(Je,{size:13}),"Main Site"]}),e.jsx("span",{style:{color:"rgba(212,175,55,0.3)"},children:"/"}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"w-10 h-10 rounded-xl flex items-center justify-center",style:{background:"linear-gradient(135deg, #E6D2A0 0%, #D4AF37 50%, #B8962E 100%)",boxShadow:"0 4px 14px rgba(212,175,55,0.4)"},children:e.jsx(Xe,{size:17,style:{color:"#3B0A11"}})}),e.jsxs("div",{children:[e.jsx("p",{className:"text-[10px] font-bold uppercase tracking-[0.2em]",style:{color:"#D4AF37"},children:"scholar.zorganicsinstitute.edu"}),e.jsx("h1",{className:"text-xl font-bold leading-none mt-0.5",style:{color:"#F0E4C4",fontFamily:"Playfair Display, serif"},children:"Scholar Portal"})]})]})]}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsxs("span",{className:"flex items-center gap-1.5 px-3 py-1.5 rounded-full text-[10px] font-bold uppercase tracking-wider",style:{background:"rgba(34,197,94,0.12)",color:"#34D399",border:"1px solid rgba(34,197,94,0.3)"},children:[e.jsx(Ie,{size:10}),"Encrypted · OAuth 2.0"]}),n&&e.jsxs("span",{className:"flex items-center gap-1.5 px-3 py-1.5 rounded-full text-[10px] font-bold uppercase tracking-wider",style:{background:"linear-gradient(135deg, rgba(212,175,55,0.2) 0%, rgba(184,150,46,0.12) 100%)",color:"#E6D2A0",border:"1px solid rgba(212,175,55,0.4)",boxShadow:"0 0 14px rgba(212,175,55,0.2)"},children:[e.jsx(Zl,{size:11,style:{color:"#D4AF37"}}),"Super-Admin · Sovereign"]}),(s||r)&&e.jsxs("div",{className:"flex items-center gap-2 pl-3 pr-4 py-1.5 rounded-full",style:{background:"rgba(212,175,55,0.08)",border:"1px solid rgba(212,175,55,0.2)"},children:[e.jsx("div",{className:"w-7 h-7 rounded-full flex items-center justify-center text-[10px] font-bold",style:{background:"linear-gradient(135deg, #E6D2A0 0%, #D4AF37 100%)",color:"#3B0A11"},children:u.split(" ").map(h=>h[0]).join("").slice(0,2)}),e.jsx("span",{className:"text-[11px] font-semibold",style:{color:"#E6D2A0"},children:u})]})]})]})]}),e.jsxs("main",{className:"max-w-[1600px] mx-auto px-6 py-8",children:[e.jsxs("div",{className:"mb-6",children:[e.jsxs("p",{className:"text-[11px] font-bold uppercase tracking-[0.2em] mb-1.5",style:{color:"#D4AF37"},children:[e.jsx(Qe,{size:11,className:"inline mr-1.5 -mt-0.5"}),"Z-LMS · Student Information System · Sovereign OS"]}),e.jsxs("h2",{className:"text-3xl font-bold",style:{color:"#F0E4C4",fontFamily:"Playfair Display, serif"},children:["Welcome back, ",u.split(" ")[0]]}),e.jsx("p",{className:"text-sm mt-1",style:{color:"rgba(230,210,160,0.65)"},children:"Secure clinical-luxury learning environment · Cima + Google Classroom + 12-week roadmap"})]}),e.jsxs("div",{className:"grid lg:grid-cols-3 gap-6",children:[e.jsxs("div",{className:"lg:col-span-2 space-y-6",children:[e.jsx(QX,{studentName:u,studentEmail:p,campus:m,program:x}),e.jsxs("section",{className:"rounded-2xl overflow-hidden",style:{background:"linear-gradient(155deg, #3B0A11 0%, #2A
12290810 100%)",border:"1.5px solid rgba(212,175,55,0.3)",boxShadow:"0 10px 28px rgba(59,10,17,0.35)"},children:[e.jsxs("div",{className:"px-6 py-4 border-b flex items-center justify-between",style:{background:"rgba(212,175,55,0.05)",borderColor:"rgba(212,175,55,0.2)"},children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"w-10 h-10 rounded-xl flex items-center justify-center",style:{background:"linear-gradient(135deg, #E6D2A0 0%, #D4AF37 50%, #B8962E 100%)"},children:e.jsx(Ym,{size:17,style:{color:"#3B0A11"}})}),e.jsxs("div",{children:[e.jsx("p",{className:"text-[10px] font-bold uppercase tracking-[0.18em]",style:{color:"#D4AF37"},children:"Clinical Roadmap · Auto-Tracked"}),e.jsx("h3",{className:"text-lg font-bold",style:{color:"#F0E4C4",fontFamily:"Playfair Display, serif"},children:"12-Week Program Tracker"})]})]}),e.jsxs("span",{className:"px-3 py-1.5 rounded-full text-[10px] font-bold uppercase tracking-wider",style:{background:"rgba(212,175,55,0.15)",color:"#D4AF37",border:"1px solid rgba(212,175,55,0.3)"},children:["Week ",i," of 12"]})]}),e.jsx("div",{className:"p-5 space-y-2",children:lee.map((h,y)=>{const v=h.pct===100,g=h.week===i,N=h.pct===0&&!g,b=cee[h.category]||"#D4AF37";return e.jsxs("div",{onClick:()=>!N&&o(h.week),className:`relative flex items-center gap-3 px-4 py-3 rounded-xl transition-all cursor-pointer ${g?"scale-[1.01]":""}`,style:{background:g?"linear-gradient(90deg, rgba(212,175,55,0.18) 0%, rgba(212,175,55,0.04) 100%)":v?"rgba(34,197,94,0.05)":"rgba(212,175,55,0.03)",border:`1px solid ${g?"rgba(212,175,55,0.5)":v?"rgba(34,197,94,0.2)":"rgba(212,175,55,0.1)"}`,opacity:N?.55:1},children:[e.jsx("div",{className:"flex-shrink-0",children:v?e.jsx(Ue,{size:20,style:{color:"#34D399"}}):g?e.jsx("div",{className:"w-5 h-5 rounded-full flex items-center justify-center",style:{background:"linear-gradient(135deg, #E6D2A0 0%, #D4AF37 100%)",boxShadow:"0 0 10px rgba(212,175,55,0.6)"},children:e.jsx("span",{className:"w-2 h-2 rounded-full bg-institute-plum"})}):e.jsx(zb,{size:20,style:{color:"rgba(212,175,55,0.3)"}})}),e.jsxs("div",{className:"flex-shrink-0 text-[10px] font-bold uppercase tracking-wider w-14",style:{color:"rgba(230,210,160,0.5)"},children:["Week ",h.week]}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"text-sm font-bold truncate",style:{color:"#F0E4C4"},children:h.title}),e.jsx("span",{className:"inline-block text-[9px] font-bold uppercase tracking-wider mt-0.5 px-1.5 py-0.5 rounded",style:{background:`${b}15`,color:b,border:`1px solid ${b}30`},children:h.category})]}),e.jsxs("div",{className:"flex-shrink-0 flex items-center gap-3 w-32",children:[e.jsx("div",{className:"flex-1 h-1.5 rounded-full overflow-hidden",style:{background:"rgba(212,175,55,0.1)"},children:e.jsx("div",{className:"h-full rounded-full transition-all duration-700",style:{width:`${h.pct}%`,background:v?"linear-gradient(90deg, #10B981 0%, #34D399 100%)":"linear-gradient(90deg, #D4AF37 0%, #E6D2A0 100%)"}})}),e.jsxs("span",{className:"text-[10px] font-bold w-8 text-right",style:{color:"#D4AF37"},children:[h.pct,"%"]})]})]},y)})})]}),n&&e.jsx("section",{className:"rounded-2xl overflow-hidden",style:{background:"linear-gradient(155deg, #3B0A11 0%, #2A0810 100%)",border:"1.5px solid rgba(212,175,55,0.3)",boxShadow:"0 10px 28px rgba(59,10,17,0.35)"},children:e.jsx("div",{className:"p-6",children:e.jsx(eee,{limit:8,showFilters:!0})})}),n&&e.jsx(nee,{})]}),e.jsxs("aside",{className:"space-y-6",children:[n&&e.jsx(ree,{onOpenWizard:()=>c(!0)}),e.jsx(tee,{studentHours:r?450:0,totalHoursRequired:750,eligibleForProv:!1}),e.jsxs("div",{className:"rounded-2xl overflow-hidden",style:{background:"linear-gradient(135deg, #3B0A11 0%, #2A0810 100%)",border:"1.5px solid rgba(212,175,55,0.3)"},children:[e.jsx("div",{className:"px-5 py-3 border-b",style:{background:"rgba(212,175,55,0.06)",borderColor:"rgba(212,175,55,0.2)"},children:e.jsxs("div",{className:"flex items-center gap-2.5",children:[e.jsx(Na,{size:15,style:{color:"#D4AF37"}}),e.jsx("p",{className:"text-sm font-bold",style:{color:"#F0E4C4",fontFamily:"Playfair Display, serif"},children:"Resource Library"})]})}),e.jsx("div",{className:"p-3 space-y-1",children:[{icon:e.jsx(Is,{size:13}),label:"State Board Exam Prep Kits"},{icon:e.jsx(At,{size:13}),label:"Tour Renton Campus · Coming Aug 2026"},{icon:e.jsx(Na,{size:13}),label:"Milady Cima Help Center"},{icon:e.jsx(Ie,{size:13}),label:"SAP Appeal Portal"}].map((h,y)=>e.jsxs("button",{className:"flex items-center gap-2.5 w-full px-3 py-2 rounded-lg transition-all text-left",style:{color:"#E6D2A0",background:"transparent"},onMouseEnter:v=>{v.currentTarget.style.background="rgba(212,175,55,0.08)"},onMouseLeave:v=>{v.currentTarget.style.background="transparent"},children:[e.jsx("span",{style:{color:"#D4AF37"},children:h.icon}),e.jsx("span",{className:"text-[11px] font-semibold",children:h.label})]},y))})]}),!s&&!r&&e.jsxs("div",{className:"rounded-2xl p-5 text-center",style:{background:"linear-gradient(135deg, rgba(212,175,55,0.08) 0%, rgba(184,150,46,0.04) 100%)",border:"1px solid rgba(212,175,55,0.25)"},children:[e.jsx($o,{size:24,className:"mx-auto mb-2",style:{color:"#D4AF37"}}),e.jsx("p",{className:"text-sm font-bold mb-1",style:{color:"#F0E4C4"},children:"Sign In Required"}),e.jsx("p",{className:"text-[11px] mb-3",style:{color:"rgba(230,210,160,0.6)"},children:"Use your @zorganicsinstitute.edu credentials"}),e.jsx(be,{to:"/",className:"inline-block px-4 py-2 rounded-lg text-[11px] font-bold uppercase tracking-widest transition-all hover:scale-105",style:{background:"linear-gradient(135deg, #E6D2A0 0%, #D4AF37 50%, #B8962E 100%)",color:"#3B0A11"},children:"Return to Main Site"})]})]})]}),e.jsxs("footer",{className:"mt-10 pt-6 border-t",style:{borderColor:"rgba(212,175,55,0.15)",color:"rgba(230,210,160,0.55)"},children:[e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3 text-[10px]",children:[e.jsxs("div",{className:"flex items-center gap-4 flex-wrap",children:[e.jsx("span",{children:"© 2026 Zorganics Institute · Sovereign Multi-Site OS"}),e.jsx("span",{style:{color:"rgba(212,175,55,0.3)"},children:"·"}),e.jsx("span",{children:"FERPA Compliant · HIPAA Vaulted"}),e.jsx("span",{style:{color:"rgba(212,175,55,0.3)"},children:"·"}),e.jsx("span",{style:{color:"#B8962E"},children:"Active Campus: 410 W Bakerview Rd, Bellingham"}),e.jsx("span",{style:{color:"rgba(212,175,55,0.3)"},children:"·"}),e.jsx("span",{style:{color:"#B8962E"},children:"Renton Campus · Coming August 2026"})]}),e.jsxs("div",{className:"flex items-center gap-3 flex-wrap",children:[e.jsxs("span",{className:"inline-flex items-center gap-1.5 px-2 py-1 rounded-full",style:{background:"rgba(34,197,94,0.12)",color:"#34D399",border:"1px solid rgba(34,197,94,0.3)"},children:[e.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-[#34D399] animate-pulse"}),"Elastic · Multi-Region"]}),e.jsx("span",{className:"inline-flex items-center gap-1.5 px-2 py-1 rounded-full",style:{background:"rgba(212,175,55,0.1)",color:"#D4AF37",border:"1px solid rgba(212,175,55,0.3)"},children:"100K Concurrent Capacity"}),e.jsx("span",{style:{color:"rgba(212,175,55,0.3)"},children:"·"}),e.jsx("span",{children:"v26.4 · Clinical Luxury"})]})]}),e.jsx("p",{className:"text-[9px] mt-3 text-center",style:{color:"rgba(230,210,160,0.35)"}
1229,children:"Infrastructure: Auto-scaling cloud clusters · EIN-tagged financial routing (Institute / Cosmetics / Foundation) · Executive Identity Cards render live from sis_students · Raw data lists hidden by Clinical Luxury UI policy"})]})]}),n&&e.jsx(oee,{isOpen:l,onClose:()=>c(!1)})]})},GA=()=>(sn(),e.jsx(vI,{children:e.jsx(np,{children:e.jsx(uI,{children:e.jsx(hI,{children:e.jsx(dee,{})})})})}));function VA(t,s){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(t);s&&(a=a.filter(function(r){return Object.getOwnPropertyDescriptor(t,r).enumerable})),n.push.apply(n,a)}return n}function Gy(t){for(var s=1;s<arguments.length;s++){var n=arguments[s]!=null?arguments[s]:{};s%2?VA(Object(n),!0).forEach(function(a){WI(t,a,n[a])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):VA(Object(n)).forEach(function(a){Object.defineProperty(t,a,Object.getOwnPropertyDescriptor(n,a))})}return t}function WI(t,s,n){return s in t?Object.defineProperty(t,s,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[s]=n,t}function Uv(t,s){return uee(t)||mee(t,s)||pee(t,s)||hee()}function uee(t){if(Array.isArray(t))return t}function mee(t,s){var n=t==null?null:typeof Symbol<"u"&&t[Symbol.iterator]||t["@@iterator"];if(n!=null){var a=[],r=!0,i=!1,o,l;try{for(n=n.call(t);!(r=(o=n.next()).done)&&(a.push(o.value),!(s&&a.length===s));r=!0);}catch(c){i=!0,l=c}finally{try{!r&&n.return!=null&&n.return()}finally{if(i)throw l}}return a}}function pee(t,s){if(t){if(typeof t=="string")return ZA(t,s);var n=Object.prototype.toString.call(t).slice(8,-1);if(n==="Object"&&t.constructor&&(n=t.constructor.name),n==="Map"||n==="Set")return Array.from(t);if(n==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return ZA(t,s)}}function ZA(t,s){(s==null||s>t.length)&&(s=t.length);for(var n=0,a=new Array(s);n<s;n++)a[n]=t[n];return a}function hee(){throw new TypeError(`Invalid attempt to destructure non-iterable instance. 1230In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}var Vy=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function HI(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}function GI(t,s){return s={exports:{}},t(s,s.exports),s.exports}var Zy=GI(function(t,s){var n=Vy&&Vy.__rest||function(o,l){var c={};for(var u in o)Object.prototype.hasOwnProperty.call(o,u)&&l.indexOf(u)<0&&(c[u]=o[u]);if(o!=null&&typeof Object.getOwnPropertySymbols=="function")for(var p=0,u=Object.getOwnPropertySymbols(o);p<u.length;p++)l.indexOf(u[p])<0&&Object.prototype.propertyIsEnumerable.call(o,u[p])&&(c[u[p]]=o[u[p]]);return c};Object.defineProperty(s,"__esModule",{value:!0}),s.scripts=void 0,s.scripts={};var a=function(o){var l=document.querySelector('script[src="'+o+'"]');if(l)return s.scripts[o]={loading:!1,error:null,scriptEl:l}};function r(o){var l=o.src,c=o.checkForExisting,u=c===void 0?!1:c,p=n(o,["src","checkForExisting"]),m=l?s.scripts[l]:void 0;!m&&u&&l&&i&&(m=a(l));var x=(0,re.useState)(m?m.loading:!!l),h=x[0],y=x[1],v=(0,re.useState)(m?m.error:null),g=v[0],N=v[1],b=(0,re.useState)(!1),f=b[0],j=b[1];return(0,re.useEffect)(function(){if(!(!i||!l||f||g)){m=s.scripts[l],!m&&u&&(m=a(l));var S;m?S=m.scriptEl:(S=document.createElement("script"),S.src=l,Object.keys(p).forEach(function(C){S[C]===void 0?S.setAttribute(C,p[C]):S[C]=p[C]}),m=s.scripts[l]={loading:!0,error:null,scriptEl:S});var w=function(){m&&(m.loading=!1),y(!1),j(!0)},_=function(C){m&&(m.error=C),N(C)};return S.addEventListener("load",w),S.addEventListener("error",_),document.body.appendChild(S),function(){S.removeEventListener("load",w),S.removeEventListener("error",_),m&&m.loading&&(S.remove(),delete s.scripts[l])}}},[l]),[h,g]}s.default=r;var i=typeof window<"u"&&typeof window.document<"u"});HI(Zy);Zy.scripts;var VI=GI(function(t,s){var n=Vy&&Vy.__importDefault||function(a){return a&&a.__esModule?a:{default:a}};Object.defineProperty(s,"__esModule",{value:!0}),s.scripts=s.default=void 0,Object.defineProperty(s,"default",{enumerable:!0,get:function(){return n(Zy).default}}),Object.defineProperty(s,"scripts",{enumerable:!0,get:function(){return Zy.scripts}})}),xee=HI(VI);VI.scripts;var fee=function(s,n,a){var r={};return delete Object.assign(r,s,WI({},a,s[n]))[n],r},gee=function(s,n){var a={plaid:null,open:!1,onExitCallback:null};if(typeof window>"u"||!window.Plaid)throw new Error("Plaid not loaded");a.plaid=n(Gy(Gy({},s),{},{onExit:function(u,p){a.open=!1,s.onExit&&s.onExit(u,p),a.onExitCallback&&a.onExitCallback()}}));var r=function(){a.plaid&&(a.open=!0,a.onExitCallback=null,a.plaid.open())},i=function(u){a.plaid&&a.plaid.submit(u)},o=function(u,p){if(!a.open||!a.plaid){p&&p();return}a.onExitCallback=p,a.plaid.exit(u),u&&u.force&&(a.open=!1)},l=function(){a.plaid&&(a.plaid.destroy(),a.plaid=null)};return{open:r,submit:i,exit:o,destroy:l}},yee=function(s,n){var a=fee(s,"publicKey","key");return gee(a,n)},bee="https://cdn.plaid.com/link/v2/stable/link-initialize.js",YA=function(){},ZI=function(s){var n=xee({src:bee,checkForExisting:!0}
1230),a=Uv(n,2),r=a[0],i=a[1],o=d.useState(null),l=Uv(o,2),c=l[0],u=l[1],p=d.useState(!1),m=Uv(p,2),x=m[0],h=m[1],y=(s.product||[]).slice().sort().join(",");d.useEffect(function(){if(!r&&!(!s.token&&!s.publicKey&&!s.receivedRedirectUri)){if(i||!window.Plaid){console.error("Error loading Plaid",i);return}c!=null&&c.exit({force:!0},function(){return c.destroy()});var N=yee(Gy(Gy({},s),{},{onLoad:function(){h(!0),s.onLoad&&s.onLoad()}}),window.Plaid.create);return u(N),function(){return N.exit({force:!0},function(){return N.destroy()})}}},[r,i,s.publicKey,s.token,y]);var v=c!=null&&(!r||x),g=function(){s.token||console.warn("react-plaid-link: You cannot call open() without a valid token supplied to usePlaidLink. This is a no-op.")};return{error:i,ready:v,submit:c?c.submit:YA,exit:c?c.exit:YA,open:c?c.open:g}},KA;(function(t){t.OPEN="OPEN",t.EXIT="EXIT",t.HANDOFF="HANDOFF",t.SELECT_INSTITUTION="SELECT_INSTITUTION",t.ERROR="ERROR",t.BANK_INCOME_INSIGHTS_COMPLETED="BANK_INCOME_INSIGHTS_COMPLETED",t.IDENTITY_VERIFICATION_PASS_SESSION="IDENTITY_VERIFICATION_PASS_SESSION",t.IDENTITY_VERIFICATION_FAIL_SESSION="IDENTITY_VERIFICATION_FAIL_SESSION"})(KA||(KA={}));const vee=()=>{const[t,s]=d.useState(""),[n,a]=d.useState(!1),[r,i]=d.useState(!1),[o,l]=d.useState(""),c=async u=>{if(u.preventDefault(),!t.trim()||!t.includes("@")){l("Please enter a valid email address");return}a(!0),l("");try{const{data:p,error:m}=await O.functions.invoke("send-donor-magic-link",{body:{email:t.trim().toLowerCase(),returnUrl:window.location.origin}});if(m)throw new Error(m.message);if(p!=null&&p.error)throw new Error(p.error);i(!0)}catch(p){l(p.message||"Unable to send sign-in link. Please try again.")}finally{a(!1)}};return e.jsx("div",{className:"min-h-screen bg-gradient-to-br from-foundation-sage-light via-white to-foundation-sage flex items-center justify-center px-4 py-16",children:e.jsxs("div",{className:"w-full max-w-xl",children:[e.jsxs("div",{className:"text-center mb-8",children:[e.jsxs("div",{className:"inline-flex items-center gap-2 px-4 py-1.5 rounded-full bg-foundation-burgundy-deep/5 border border-foundation-burgundy-deep/10 mb-6",children:[e.jsx(On,{className:"w-3.5 h-3.5 text-foundation-burgundy"}),e.jsx("span",{className:"text-[10px] tracking-[0.3em] font-semibold text-foundation-burgundy-deep",children:"ZORGANICS FOUNDATION"})]}),e.jsx("h1",{className:"font-serif text-4xl md:text-5xl text-foundation-burgundy-deep mb-3",children:"Donor Sanctuary"}),e.jsx("p",{className:"text-foundation-text-muted text-base leading-relaxed",children:"Secure access to your giving history, recurring gifts, and tax receipts."})]}),e.jsxs("div",{className:"bg-white border border-foundation-sage-border rounded-2xl shadow-[0_20px_60px_-20px_rgba(46,10,42,0.18)] overflow-hidden",children:[e.jsxs("div",{className:"bg-gradient-to-r from-foundation-burgundy-deep to-foundation-burgundy px-8 py-6 flex items-center gap-4",children:[e.jsx("div",{className:"w-12 h-12 rounded-full bg-foundation-gold flex items-center justify-center",children:e.jsx(Tt,{className:"w-6 h-6 text-foundation-burgundy-deep"})}),e.jsxs("div",{children:[e.jsx("div",{className:"text-foundation-gold text-[10px] tracking-[0.25em] font-semibold mb-0.5",children:"IRC § 170(c)(2) · EIN 87-4273317"}),e.jsx("div",{className:"text-white font-serif text-lg",children:"Secure Magic-Link Sign-In"})]})]}),e.jsx("div",{className:"p-8",children:r?e.jsxs("div",{className:"text-center py-8",children:[e.jsx("div",{className:"w-16 h-16 rounded-full bg-foundation-sage mx-auto mb-5 flex items-center justify-center",children:e.jsx(Ue,{className:"w-8 h-8 text-foundation-burgundy"})}),e.jsx("h2",{className:"font-serif text-2xl text-foundation-burgundy-deep mb-2",children:"Check your inbox"}),e.jsxs("p",{className:"text-foundation-text-muted leading-relaxed mb-1",children:["If ",e.jsx("span",{className:"font-semibold text-foundation-burgundy-deep",children:t})," is on file, we sent a secure sign-in link that expires in 30 minutes."]}),e.jsxs("p",{className:"text-xs text-foundation-text-soft mt-6",children:["Didn't receive it?"," ",e.jsx("button",{onClick:()=>{i(!1),l("")},className:"text-foundation-burgundy underline font-medium hover:text-foundation-burgundy-deep",children:"Try a different email"})]})]}):e.jsxs("form",{onSubmit:c,className:"space-y-5",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-[11px] tracking-[0.2em] font-semibold text-foundation-burgundy-deep mb-2",children:"EMAIL ADDRESS ON FILE"}),e.jsxs("div",{className:"relative",children:[e.jsx(Ye,{className:"w-5 h-5 text-foundation-text-soft absolute left-4 top-1/2 -translate-y-1/2"}),e.jsx("input",{type:"email",autoFocus:!0,value:t,onChange:u=>s(u.target.value),placeholder:"[email protected]",className:"w-full pl-12 pr-4 py-4 bg-foundation-sage-light border border-foundation-sage-border rounded-lg text-foundation-burgundy-deep placeholder-[#B5A8B8] focus:outline-none focus:border-foundation-burgundy focus:bg-white transition font-serif text-base"})]})]}),o&&e.jsx("div",{className:"bg-red-50 border border-red-200 rounded-lg px-4 py-3 text-sm text-red-800",children:o}),e.jsx("button",{type:"submit",disabled:n||!t,className:"w-full bg-foundation-burgundy hover:bg-foundation-burgundy-deep disabled:opacity-50 disabled:cursor-not-allowed text-white font-semibold tracking-wider text-sm py-4 rounded-lg flex items-center justify-center gap-2 transition-all",children:n?e.jsxs(e.Fragment,{children:[e.jsx(de,{className:"w-4 h-4 animate-spin"})," SENDING SECURE LINKâ¦"]}):e.jsxs(e.Fragment,{children:["SEND SIGN-IN LINK ",e.jsx(Vt,{className:"w-4 h-4"})]})}),e.jsxs("div",{className:"flex items-start gap-3 pt-4 border-t border-foundation-sage-border",children:[e.jsx(Xe,{className:"w-4 h-4 text-foundation-text-soft flex-shrink-0 mt-0.5"}),e.jsx("p",{className:"text-xs text-foundation-text-muted leading-relaxed",children:"We never store passwords. Each sign-in uses a one-time magic link delivered to your email on file. Links expire in 30 minutes and cannot be reused."})]})]})}),e.jsx("div",{className:"bg-foundation-sage-light border-t border-foundation-sage-border px-8 py-4 text-center",children:e.jsx("div",{className:"text-[10px] tracking-[0.3em] text-foundation-text-soft font-semibold",children:"BANK-LEVEL 256-BIT ENCRYPTION · PLAID VERIFIED · SOC 2 TYPE II"})})]}),e.jsxs("p",{className:"text-center text-xs text-foundation-text-soft mt-6",children:["Never donated before? ",e.jsx("a",{href:"#/foundation",className:"text-foundation-burgundy font-medium underline hover:text-foundation-burgundy-deep",children:"Return to donation page â"})]})]})})},jee=t=>
1230`$${(t/100).toLocaleString("en-US",{minimumFractionDigits:2,maximumFractionDigits:2})}`,QA=t=>{try{return new Date(t).toLocaleDateString("en-US",{year:"numeric",month:"long",day:"numeric"})}catch{return t}},wee=({donation:t,onClose:s})=>{var a;const n=()=>window.print();return e.jsxs("div",{className:"fixed inset-0 bg-black/70 backdrop-blur-sm z-50 overflow-y-auto",children:[e.jsxs("div",{className:"print:hidden sticky top-0 bg-foundation-burgundy-deep text-white px-6 py-4 flex items-center justify-between shadow-lg",children:[e.jsxs("div",{className:"text-sm tracking-widest font-semibold",children:["TAX RECEIPT · ",t.receipt_number]}),e.jsxs("div",{className:"flex gap-3",children:[e.jsx("button",{onClick:n,className:"bg-foundation-gold hover:bg-foundation-gold-hover text-foundation-burgundy-deep font-semibold px-5 py-2 rounded text-sm tracking-wider",children:"DOWNLOAD / PRINT PDF"}),e.jsx("button",{onClick:s,className:"border border-white/40 hover:bg-white/10 px-4 py-2 rounded text-sm",children:"Close"})]})]}),e.jsx("div",{className:"receipt-page max-w-[8.5in] mx-auto my-8 bg-white shadow-2xl print:shadow-none print:my-0",style:{minHeight:"11in"},children:e.jsxs("div",{className:"p-12 print:p-10",children:[e.jsx("div",{className:"border-b-2 border-foundation-burgundy-deep pb-6 mb-8",children:e.jsxs("div",{className:"flex justify-between items-start",children:[e.jsxs("div",{children:[e.jsx("div",{className:"text-[10px] tracking-[0.4em] text-foundation-gold font-bold mb-2",children:"ZORGANICS FOUNDATION"}),e.jsxs("h1",{className:"font-serif text-3xl text-foundation-burgundy-deep leading-tight",children:["Official Tax-Deductible",e.jsx("br",{}),"Contribution Receipt"]}),e.jsxs("div",{className:"text-xs text-gray-600 mt-3 leading-relaxed",children:["A 501(c)(3) Non-Profit Organization · EIN 87-4273317",e.jsx("br",{}),"1234 Botanical Way · Seattle, WA 98101 · [email protected]"]})]}),e.jsxs("div",{className:"text-right",children:[e.jsxs("div",{className:"border border-foundation-gold rounded px-4 py-3 bg-foundation-sage-light",children:[e.jsx("div",{className:"text-[9px] tracking-[0.3em] text-foundation-text-soft font-semibold",children:"RECEIPT â"}),e.jsx("div",{className:"font-serif text-xl text-foundation-burgundy-deep font-bold mt-1",children:t.receipt_number})]}),e.jsx("div",{className:"text-[10px] text-gray-500 mt-2",children:QA(t.created_at)})]})]})}),e.jsxs("div",{className:"grid grid-cols-2 gap-8 mb-8",children:[e.jsxs("div",{children:[e.jsx("div",{className:"text-[10px] tracking-[0.25em] font-bold text-foundation-burgundy-deep mb-2",children:"DONOR"}),e.jsx("div",{className:"font-serif text-xl text-foundation-burgundy-deep",children:t.donor_name||"Valued Supporter"}),e.jsx("div",{className:"text-sm text-gray-600 mt-1",children:t.donor_email})]}),e.jsxs("div",{children:[e.jsx("div",{className:"text-[10px] tracking-[0.25em] font-bold text-foundation-burgundy-deep mb-2",children:"GIFT DETAILS"}),e.jsxs("div",{className:"text-sm text-gray-700 space-y-0.5",children:[e.jsxs("div",{children:[e.jsx("span",{className:"font-semibold",children:"Frequency:"})," ",((a=t.frequency)==null?void 0:a.toUpperCase())||"ONE-TIME"]}),e.jsxs("div",{children:[e.jsx("span",{className:"font-semibold",children:"Status:"})," ",e.jsx("span",{className:"uppercase",children:t.status})]}),t.ach_trace_number&&e.jsxs("div",{children:[e.jsx("span",{className:"font-semibold",children:"ACH Trace:"})," ",e.jsx("span",{className:"font-mono",children:t.ach_trace_number})]})]})]})]}),e.jsxs("div",{className:"bg-gradient-to-br from-foundation-burgundy-deep to-foundation-burgundy rounded-lg p-10 text-center mb-8 print:bg-foundation-burgundy-deep",children:[e.jsx("div",{className:"text-foundation-gold text-[10px] tracking-[0.4em] font-semibold mb-2",children:"CHARITABLE CONTRIBUTION AMOUNT"}),e.jsx("div",{className:"font-serif text-6xl text-white font-light",children:jee(t.amount_cents)}),e.jsx("div",{className:"text-foundation-sage text-sm mt-3 italic",children:t.purpose||"General Scholarship Fund"})]}),e.jsxs("div",{className:"bg-foundation-sage-light border-l-4 border-foundation-gold p-6 mb-8",children:[e.jsx("div",{className:"text-[10px] tracking-[0.25em] font-bold text-foundation-burgundy-deep mb-3",children:"IRS STATEMENT · IRC § 170(c)(2)"}),e.jsx("p",{className:"text-sm text-gray-700 leading-relaxed mb-3",children:"The Zorganics Foundation is a qualified 501(c)(3) non-profit organization. Your contribution is tax-deductible to the fullest extent allowed by law."}),e.jsxs("p",{className:"text-sm text-gray-700 leading-relaxed",children:[e.jsx("strong",{children:"No goods or services were provided in exchange for this contribution."})," ","Please retain this receipt for your tax records."]})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-8 mt-12",children:[e.jsxs("div",{children:[e.jsx("div",{className:"font-serif text-2xl text-foundation-burgundy-deep italic",style:{fontFamily:"Brush Script MT, cursive"},children:"Dr. Zohra Benefsha"}),e.jsxs("div",{className:"border-t border-gray-400 mt-1 pt-1",children:[e.jsx("div",{className:"text-xs text-gray-600",children:"Founder & Executive Director"}),e.jsx("div",{className:"text-xs text-gray-500",children:"Zorganics Foundation"})]})]}),e.jsxs("div",{className:"text-right",children:[e.jsx("div",{className:"text-[9px] tracking-[0.3em] text-foundation-text-soft font-semibold mb-2",children:"AUTHENTICATED DIGITAL SEAL"}),e.jsxs("div",{className:"inline-block border-2 border-foundation-gold rounded-full w-20 h-20 flex flex-col items-center justify-center bg-foundation-sage-light",children:[e.jsx("div",{className:"text-[8px] tracking-widest text-foundation-burgundy-deep font-bold",children:"ZORGANICS"}),e.jsx("div",{className:"text-[7px] text-foundation-gold",children:"FOUNDATION"}),e.jsx("div",{className:"text-[6px] text-foundation-text-soft mt-0.5",children:"EIN 87-4273317"})]})]})]}),e.jsx("div",{className:"mt-12 pt-4 border-t border-gray-200 text-center",children:e.jsxs("div",{className:"text-[9px] tracking-[0.3em] text-gray-400",children:["GENERATED ",QA(new Date().toISOString())," · THIS IS AN OFFICIAL TAX-DEDUCTIBLE RECEIPT"]})})]})}),e.jsx("style",{children:` 1231 @media print { 1232 body { background: white; } 1233 .receipt-page { box-shadow: none !important; margin: 0 !important; } 1234 } 1235 `})]})},Cp=t=>
1235`$${(t/100).toLocaleString("en-US",{minimumFractionDigits:2,maximumFractionDigits:2})}`,JA=t=>{try{return new Date(t).toLocaleDateString("en-US",{month:"short",day:"2-digit",year:"numeric"})}catch{return t}},Nee=({donations:t,year:s,donorName:n,donorEmail:a,onClose:r})=>{const i=d.useMemo(()=>t.filter(p=>new Date(p.processed_at||p.created_at).getFullYear()===s&&p.status!=="cancelled"&&p.status!=="failed").sort((p,m)=>new Date(p.created_at).getTime()-new Date(m.created_at).getTime()),[t,s]),o=i.reduce((p,m)=>p+m.amount_cents,0),l=i.length,c=i.reduce((p,m)=>m.amount_cents>p?m.amount_cents:p,0),u=()=>window.print();return e.jsxs("div",{className:"fixed inset-0 bg-black/70 backdrop-blur-sm z-50 overflow-y-auto",children:[e.jsxs("div",{className:"print:hidden sticky top-0 bg-foundation-burgundy-deep text-white px-6 py-4 flex items-center justify-between shadow-lg z-10",children:[e.jsxs("div",{className:"text-sm tracking-widest font-semibold",children:[s," ANNUAL GIVING STATEMENT"]}),e.jsxs("div",{className:"flex gap-3",children:[e.jsx("button",{onClick:u,className:"bg-foundation-gold hover:bg-foundation-gold-hover text-foundation-burgundy-deep font-semibold px-5 py-2 rounded text-sm tracking-wider",children:"DOWNLOAD / PRINT STATEMENT"}),e.jsx("button",{onClick:r,className:"border border-white/40 hover:bg-white/10 px-4 py-2 rounded text-sm",children:"Close"})]})]}),e.jsx("div",{className:"statement-page max-w-[8.5in] mx-auto my-8 bg-white shadow-2xl print:shadow-none print:my-0",style:{minHeight:"11in"},children:e.jsxs("div",{className:"p-12 print:p-10",children:[e.jsx("div",{className:"border-b-4 border-double border-foundation-burgundy-deep pb-6 mb-8",children:e.jsxs("div",{className:"flex justify-between items-end",children:[e.jsxs("div",{children:[e.jsx("div",{className:"text-[10px] tracking-[0.4em] text-foundation-gold font-bold mb-2",children:"ZORGANICS FOUNDATION · 501(c)(3)"}),e.jsx("h1",{className:"font-serif text-4xl text-foundation-burgundy-deep leading-tight",children:"Annual Giving Statement"}),e.jsxs("div",{className:"text-lg text-foundation-burgundy font-serif mt-1",children:["Tax Year ",s]})]}),e.jsxs("div",{className:"text-right",children:[e.jsx("div",{className:"text-[10px] tracking-[0.3em] font-semibold text-foundation-text-soft",children:"IRS FORM TYPE"}),e.jsx("div",{className:"font-serif text-xl text-foundation-burgundy-deep",children:"1098-C EQUIVALENT"}),e.jsx("div",{className:"text-[10px] text-gray-500 mt-1",children:"EIN 87-4273317"})]})]})}),e.jsxs("div",{className:"grid grid-cols-2 gap-6 mb-8",children:[e.jsxs("div",{className:"border border-foundation-sage-border rounded p-4",children:[e.jsx("div",{className:"text-[10px] tracking-[0.25em] font-bold text-foundation-burgundy-deep mb-2",children:"DONOR OF RECORD"}),e.jsx("div",{className:"font-serif text-xl text-foundation-burgundy-deep",children:n||"Valued Supporter"}),e.jsx("div",{className:"text-sm text-gray-600 mt-1",children:a})]}),e.jsxs("div",{className:"border border-foundation-sage-border rounded p-4",children:[e.jsx("div",{className:"text-[10px] tracking-[0.25em] font-bold text-foundation-burgundy-deep mb-2",children:"ORGANIZATION"}),e.jsx("div",{className:"font-serif text-xl text-foundation-burgundy-deep",children:"Zorganics Foundation"}),e.jsx("div",{className:"text-sm text-gray-600 mt-1",children:"EIN 87-4273317 · Qualified 501(c)(3)"})]})]}),e.jsxs("div",{className:"bg-gradient-to-br from-foundation-burgundy-deep to-foundation-burgundy rounded-lg p-8 mb-8 print:bg-foundation-burgundy-deep",children:[e.jsxs("div",{className:"text-foundation-gold text-[10px] tracking-[0.4em] font-semibold mb-3 text-center",children:["TOTAL TAX-DEDUCTIBLE CONTRIBUTIONS · ",s]}),e.jsx("div",{className:"text-center",children:e.jsx("div",{className:"font-serif text-6xl text-white font-light",children:Cp(o)})}),e.jsxs("div",{className:"grid grid-cols-3 gap-4 mt-6 pt-6 border-t border-white/20",children:[e.jsxs("div",{className:"text-center",children:[e.jsx("div",{className:"text-foundation-sage text-[10px] tracking-widest",children:"GIFTS RECEIVED"}),e.jsx("div",{className:"font-serif text-2xl text-white mt-1",children:l})]}),e.jsxs("div",{className:"text-center",children:[e.jsx("div",{className:"text-foundation-sage text-[10px] tracking-widest",children:"LARGEST GIFT"}),e.jsx("div",{className:"font-serif text-2xl text-white mt-1",children:Cp(c)})]}),e.jsxs("div",{className:"text-center",children:[e.jsx("div",{className:"text-foundation-sage text-[10px] tracking-widest",children:"AVERAGE"}),e.jsx("div",{className:"font-serif text-2xl text-white mt-1",children:l>0?Cp(Math.round(o/l)):"$0"})]})]})]}),e.jsxs("div",{className:"mb-8",children:[e.jsx("div",{className:"text-[10px] tracking-[0.25em] font-bold text-foundation-burgundy-deep mb-3",children:"ITEMIZED CONTRIBUTIONS · IRC § 170(c)(2)"}),i.length===0?e.jsxs("div",{className:"text-center py-8 text-gray-500 text-sm italic",children:["No contributions on record for ",s,"."]}):e.jsxs("table",{className:"w-full text-sm border-collapse",children:[e.jsx("thead",{children:e.jsxs("tr",{className:"border-b-2 border-foundation-burgundy-deep",children:[e.jsx("th",{className:"text-left py-2 px-2 text-[10px] tracking-widest font-bold text-foundation-burgundy-deep",children:"DATE"}),e.jsx("th",{className:"text-left py-2 px-2 text-[10px] tracking-widest font-bold text-foundation-burgundy-deep",children:"RECEIPT â"}),e.jsx("th",{className:"text-left py-2 px-2 text-[10px] tracking-widest font-bold text-foundation-burgundy-deep",children:"DESIGNATION"}),e.jsx("th",{className:"text-left py-2 px-2 text-[10px] tracking-widest font-bold text-foundation-burgundy-deep",children:"FREQ."}),e.jsx("th",{className:"text-right py-2 px-2 text-[10px] tracking-widest font-bold text-foundation-burgundy-deep",children:"AMOUNT"})]})}),e.jsxs("tbody",{children:[i.map((p,m)=>e.jsxs("tr",{className:m%2===0?"bg-foundation-sage-light":"",children:[e.jsx("td",{className:"py-2 px-2 text-gray-700",children:JA(p.processed_at||p.created_at)}),e.jsx("td",{className:"py-2 px-2 font-mono text-xs text-gray-700",children:p.receipt_number}),e.jsx("td",{className:"py-2 px-2 text-gray-700",children:p.purpose||"General Fund"}),e.jsx("td",{className:"py-2 px-2 text-gray-600 text-xs uppercase",children:p.frequency}),e.jsx("td",{className:"py-2 px-2 text-right font-semibold text-foundation-burgundy-deep",children:Cp(p.amount_cents)})]}
1235,p.id)),e.jsxs("tr",{className:"border-t-2 border-foundation-burgundy-deep bg-foundation-burgundy-deep text-white",children:[e.jsx("td",{colSpan:4,className:"py-3 px-2 text-[11px] tracking-widest font-bold",children:"TOTAL TAX-DEDUCTIBLE"}),e.jsx("td",{className:"py-3 px-2 text-right font-serif text-xl font-bold text-foundation-gold",children:Cp(o)})]})]})]})]}),e.jsxs("div",{className:"bg-foundation-sage-light border-l-4 border-foundation-gold p-5 mb-6",children:[e.jsx("div",{className:"text-[10px] tracking-[0.25em] font-bold text-foundation-burgundy-deep mb-2",children:"IRS COMPLIANCE STATEMENT"}),e.jsxs("p",{className:"text-xs text-gray-700 leading-relaxed mb-2",children:["The Zorganics Foundation is a qualified 501(c)(3) non-profit organization (EIN 87-4273317). This statement summarizes all tax-deductible contributions received during the ",s," calendar year pursuant to IRC § 170(c)(2)."]}),e.jsxs("p",{className:"text-xs text-gray-700 leading-relaxed",children:[e.jsx("strong",{children:"No goods or services were provided in exchange for these contributions."})," ","Retain this statement with your tax records. Consult your tax professional for deductibility limits under IRC § 170(b)."]})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-8 mt-8",children:[e.jsxs("div",{children:[e.jsx("div",{className:"font-serif text-2xl text-foundation-burgundy-deep italic",style:{fontFamily:"Brush Script MT, cursive"},children:"Dr. Zohra Benefsha"}),e.jsxs("div",{className:"border-t border-gray-400 mt-1 pt-1",children:[e.jsx("div",{className:"text-xs text-gray-600",children:"Dr. Zohra Benefsha, Founder"}),e.jsx("div",{className:"text-xs text-gray-500",children:"Zorganics Foundation"})]})]}),e.jsx("div",{className:"text-right",children:e.jsxs("div",{className:"inline-block border-2 border-foundation-gold rounded-full w-24 h-24 flex flex-col items-center justify-center bg-foundation-sage-light",children:[e.jsx("div",{className:"text-[9px] tracking-widest text-foundation-burgundy-deep font-bold",children:"ZORGANICS"}),e.jsx("div",{className:"text-[8px] text-foundation-gold",children:"FOUNDATION"}),e.jsx("div",{className:"text-[7px] text-foundation-text-soft mt-1",children:"TAX YEAR"}),e.jsx("div",{className:"text-[10px] text-foundation-burgundy-deep font-bold",children:s})]})})]}),e.jsx("div",{className:"mt-10 pt-4 border-t border-gray-200 text-center",children:e.jsxs("div",{className:"text-[9px] tracking-[0.3em] text-gray-400",children:["GENERATED ",JA(new Date().toISOString())," · ZORGANICS FOUNDATION · CONFIDENTIAL"]})})]})}),e.jsx("style",{children:` 1236 @media print { 1237 body { background: white; } 1238 .statement-page { box-shadow: none !important; margin: 0 !important; } 1239 } 1240 `})]})},Ap="zog_donor_session",au=t=>`$${(t/100).toLocaleString("en-US",{minimumFractionDigits:2,maximumFractionDigits:2})}`,Ep=t=>{if(!t)return"â";try{return new Date(t).toLocaleDateString("en-US",{month:"short",day:"2-digit",year:"numeric"})}catch{return t}},qv=t=>{const n={succeeded:{bg:"bg-emerald-100",text:"text-emerald-800",label:"Succeeded"},posted:{bg:"bg-emerald-100",text:"text-emerald-800",label:"Posted"},authorized:{bg:"bg-blue-100",text:"text-blue-800",label:"Authorized"},pending:{bg:"bg-amber-100",text:"text-amber-800",label:"Processing"},failed:{bg:"bg-red-100",text:"text-red-800",label:"Failed"},cancelled:{bg:"bg-gray-100",text:"text-gray-700",label:"Cancelled"},active:{bg:"bg-emerald-100",text:"text-emerald-800",label:"Active"},paused:{bg:"bg-amber-100",text:"text-amber-800",label:"Paused"},removed:{bg:"bg-gray-100",text:"text-gray-700",label:"Removed"}}[t]||{bg:"bg-gray-100",text:"text-gray-700",label:t};return e.jsx("span",{className:`inline-flex px-2 py-0.5 rounded-full text-[10px] font-semibold tracking-wider uppercase ${n.bg} ${n.text}`,children:n.label})},_ee=({linkToken:t,accessToken:s,donorEmail:n,sessionToken:a,onDone:r,onCancel:i})=>{const[o,l]=d.useState("ready"),{open:c,ready:u}=ZI({token:t,onSuccess:async(p,m)=>{var x;l("exchanging");try{await O.functions.invoke("plaid-exchange-token",{body:{public_token:p,mode:"donor",donor_email:n,institution_name:(x=m.institution)==null?void 0:x.name,accounts:m.accounts}}),l("done"),r()}catch(h){console.error(h),i()}},onExit:()=>i()});return d.useEffect(()=>{u&&c()},[u,c]),e.jsx("div",{className:"fixed inset-0 bg-black/50 z-50 flex items-center justify-center",children:e.jsxs("div",{className:"bg-white rounded-2xl p-8 max-w-sm text-center",children:[e.jsx(de,{className:"w-10 h-10 animate-spin text-foundation-burgundy mx-auto mb-4"}),e.jsx("div",{className:"font-serif text-lg text-foundation-burgundy-deep mb-1",children:o==="ready"?"Launching Plaidâ¦":o==="exchanging"?"Updating bankâ¦":"Complete"}),e.jsx("div",{className:"text-xs text-gray-600",children:"Secure bank update in progress"})]})})},kee=({linkToken:t,donorEmail:s,onDone:n,onCancel:a})=>
1240{const[r,i]=d.useState("ready"),{open:o,ready:l}=ZI({token:t,onSuccess:async(c,u)=>{var p;i("exchanging");try{await O.functions.invoke("plaid-exchange-token",{body:{public_token:c,mode:"donor",donor_email:s,institution_name:(p=u.institution)==null?void 0:p.name,accounts:u.accounts}}),n()}catch(m){console.error(m),a()}},onExit:()=>a()});return d.useEffect(()=>{l&&o()},[l,o]),e.jsx("div",{className:"fixed inset-0 bg-black/50 z-50 flex items-center justify-center",children:e.jsxs("div",{className:"bg-white rounded-2xl p-8 max-w-sm text-center",children:[e.jsx(de,{className:"w-10 h-10 animate-spin text-foundation-burgundy mx-auto mb-4"}),e.jsx("div",{className:"font-serif text-lg text-foundation-burgundy-deep mb-1",children:r==="ready"?"Launching Plaidâ¦":"Saving new bankâ¦"})]})})},See=()=>{var H,G;sn(),Ho({title:"Donor Portal | The Zorganics Foundation",description:"Secure self-service portal for Zorganics Foundation donors."});const[t,s]=cc(),n=Za(),[a,r]=d.useState(null),[i,o]=d.useState(!1),[l,c]=d.useState(""),[u,p]=d.useState(!1),[m,x]=d.useState([]),[h,y]=d.useState([]),[v,g]=d.useState([]),[N,b]=d.useState("overview"),[f,j]=d.useState(null),[S,w]=d.useState(null),[_,C]=d.useState(null),[E,P]=d.useState(null),[F,I]=d.useState(null),[D,L]=d.useState(null);d.useEffect(()=>{const W=t.get("token"),X=sessionStorage.getItem(Ap);if(W)o(!0),(async()=>{try{const{data:Q,error:K}=await O.functions.invoke("verify-donor-magic-link",{body:{token:W}});if(K)throw new Error(K.message);if(Q!=null&&Q.error)throw new Error(Q.error);const se={donor_email:Q.donor_email,session_token:Q.session_token,expires_at:Q.expires_at};sessionStorage.setItem(Ap,JSON.stringify(se)),r(se),s({})}catch(Q){c(Q.message||"Invalid or expired link")}finally{o(!1)}})();else if(X)try{const Q=JSON.parse(X);new Date(Q.expires_at)>new Date?r(Q):sessionStorage.removeItem(Ap)}catch{sessionStorage.removeItem(Ap)}},[]);const V=d.useCallback(async()=>{if(a){p(!0);try{const W=a.donor_email,[X,Q,K]=await Promise.all([O.from("z_foundation_donations").select("*").eq("donor_email",W).order("created_at",{ascending:!1}),O.from("z_donor_bank_accounts").select("*").eq("donor_email",W).neq("status","removed").order("created_at",{ascending:!1}),O.from("z_donor_subscriptions").select("*").eq("donor_email",W).order("created_at",{ascending:!1})]);x(X.data||[]),y(Q.data||[]),g(K.data||[])}finally{p(!1)}}},[a]);d.useEffect(()=>{a&&V()},[a,V]);const B=d.useMemo(()=>{const W=m.filter(se=>se.status==="succeeded"||se.status==="posted"||se.status==="authorized"),X=W.reduce((se,Y)=>se+Y.amount_cents,0),Q=W.filter(se=>new Date(se.processed_at||se.created_at).getFullYear()===new Date().getFullYear()).reduce((se,Y)=>se+Y.amount_cents,0),K=Array.from(new Set(W.map(se=>new Date(se.processed_at||se.created_at).getFullYear()))).sort((se,Y)=>Y-se);return{lifetime:X,thisYear:Q,count:W.length,availableYears:K}},[m]),A=((H=m[0])==null?void 0:H.donor_name)||((G=h[0])==null?void 0:G.donor_name)||"",z=()=>{sessionStorage.removeItem(Ap),r(null),n("/foundation/donor")},M=async(W,X)=>
1240{if(a&&!(X==="cancel"&&!confirm("Are you sure you want to cancel this recurring gift? This cannot be undone."))){C(`sub-${W}`);try{const{data:Q,error:K}=await O.functions.invoke("donor-manage-subscription",{body:{sessionToken:a.session_token,subscriptionId:W,action:X}});if(K||Q!=null&&Q.error)throw new Error((Q==null?void 0:Q.error)||(K==null?void 0:K.message));await V()}catch(Q){alert(Q.message||"Action failed")}finally{C(null)}}},R=async W=>{if(a){C(`default-${W}`);try{const{data:X,error:Q}=await O.functions.invoke("donor-set-default-bank",{body:{sessionToken:a.session_token,bankAccountId:W,action:"set_default"}});if(Q||X!=null&&X.error)throw new Error((X==null?void 0:X.error)||(Q==null?void 0:Q.message));await V()}catch(X){alert(X.message||"Action failed")}finally{C(null)}}},T=async W=>{if(a&&confirm("Remove this bank account? You can re-link it anytime.")){C(`remove-${W}`);try{await O.functions.invoke("donor-set-default-bank",{body:{sessionToken:a.session_token,bankAccountId:W,action:"remove"}}),await V()}catch(X){alert(X.message)}finally{C(null)}}},U=async W=>{C(`update-${W.id}`);try{const{data:X,error:Q}=await O.functions.invoke("plaid-link-token",{body:{mode:"update",access_token:W.plaid_access_token,donor_email:a.donor_email}});if(Q||X!=null&&X.error)throw new Error((X==null?void 0:X.error)||(Q==null?void 0:Q.message));I(W.plaid_access_token),P(X.link_token)}catch(X){alert(X.message)}finally{C(null)}},q=async()=>{C("add-bank");try{const{data:W,error:X}=await O.functions.invoke("plaid-link-token",{body:{mode:"donor",donor_email:a.donor_email}});if(X||W!=null&&W.error)throw new Error((W==null?void 0:W.error)||(X==null?void 0:X.message));L(W.link_token)}catch(W){alert(W.message)}finally{C(null)}};return i?e.jsx("div",{className:"min-h-screen flex items-center justify-center bg-gradient-to-br from-foundation-sage-light to-white",children:e.jsxs("div",{className:"text-center",children:[e.jsx(de,{className:"w-10 h-10 animate-spin text-foundation-burgundy mx-auto mb-4"}),e.jsx("div",{className:"font-serif text-xl text-foundation-burgundy-deep",children:"Verifying secure linkâ¦"}),e.jsx("div",{className:"text-xs text-gray-500 mt-2",children:"One moment please"})]})}):l?e.jsx("div",{className:"min-h-screen flex items-center justify-center bg-gradient-to-br from-foundation-sage-light to-white px-4",children:e.jsxs("div",{className:"bg-white rounded-2xl shadow-xl p-10 max-w-md text-center border border-red-200",children:[e.jsx(kt,{className:"w-12 h-12 text-red-500 mx-auto mb-4"}),e.jsx("h2",{className:"font-serif text-2xl text-foundation-burgundy-deep mb-2",children:"Link Invalid or Expired"}),e.jsx("p",{className:"text-sm text-gray-600 mb-6",children:l}),e.jsx("button",{onClick:()=>{c(""),n("/foundation/donor",{replace:!0})},className:"bg-foundation-burgundy hover:bg-foundation-burgundy-deep text-white font-semibold px-6 py-3 rounded-lg tracking-wider text-sm",children:"REQUEST NEW SIGN-IN LINK"})]})}):a?e.jsxs("div",{className:"min-h-screen bg-foundation-sage-light",children:[e.jsx("header",{className:"bg-gradient-to-r from-foundation-burgundy-deep to-foundation-burgundy border-b-4 border-foundation-gold",children:e.jsxs("div",{className:"max-w-7xl mx-auto px-6 py-5 flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx("div",{className:"w-11 h-11 rounded-full bg-foundation-gold flex items-center justify-center",children:e.jsx(On,{className:"w-5 h-5 text-foundation-burgundy-deep"})}),e.jsxs("div",{children:[e.jsx("div",{className:"text-foundation-gold text-[9px] tracking-[0.3em] font-bold",children:"ZORGANICS FOUNDATION · DONOR PORTAL"}),e.jsx("div",{className:"text-white font-serif text-xl",children:"Donor Sanctuary"})]})]}),e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsxs("div",{className:"hidden md:block text-right",children:[e.jsx("div",{className:"text-[10px] text-foundation-sage tracking-widest",children:"SIGNED IN AS"}),e.jsx("div",{className:"text-white text-sm font-medium",children:a.donor_email})]}),e.jsxs("button",{onClick:z,className:"flex items-center gap-2 bg-white/10 hover:bg-white/20 text-white px-4 py-2 rounded-lg text-sm transition border border-white/20",children:[e.jsx(bo,{className:"w-4 h-4"})," Sign Out"]})]})]})}),e.jsx("nav",{className:"bg-white border-b border-foundation-sage-border sticky top-0 z-20 shadow-sm",children:e.jsx("div",{className:"max-w-7xl mx-auto px-6 flex overflow-x-auto",children:[{id:"overview",label:"Overview",icon:si},{id:"history",label:"Giving History",icon:Kt},{id:"banks",label:"Linked Banks",icon:Ws},{id:"subscriptions",label:"Recurring Gifts",icon:Bu},{id:"tax",label:"Tax Documents",icon:Is}].map(W=>e.jsxs("button",{onClick:()=>b(W.id),className:`flex items-center gap-2 px-5 py-4 text-sm font-medium tracking-wider border-b-2 transition whitespace-nowrap ${N===W.id?"border-foundation-gold text-foundation-burgundy-deep":"border-transparent text-gray-500 hover:text-foundation-burgundy-deep"}`,children:[e.jsx(W.icon,{className:"w-4 h-4"})," ",W.label.toUpperCase()]},W.id))})}),e.jsxs("main",{className:"max-w-7xl mx-auto px-6 py-8",children:[u&&e.jsxs("div",{className:"text-center py-12",children:[e.jsx(de,{className:"w-8 h-8 animate-spin text-foundation-burgundy mx-auto mb-3"}),e.jsx("div",{className:"text-sm text-gray-500",children:"Loading your donor recordsâ¦"})]}),!u&&N==="overview"&&e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-5",children:[e.jsxs("div",{className:"bg-gradient-to-br from-foundation-burgundy-deep to-foundation-burgundy rounded-2xl p-6 text-white shadow-lg",children:[e.jsxs("div",{className:"flex items-center justify-between mb-3",children:[e.jsx(ta,{className:"w-6 h-6 text-foundation-gold"}),e.jsx("span",{className:"text-[10px] tracking-widest text-foundation-sage",children:"LIFETIME IMPACT"})]}),e.jsx("div",{className:"font-serif text-4xl",children:au(B.lifetime)}),e.jsxs("div",{className:"text-xs text-foundation-sage mt-2",children:["Across ",B.count," tax-deductible gifts"]})]}),e.jsxs("div",{className:"bg-white rounded-2xl p-6 border border-foundation-sage-border shadow-sm",children:[e.jsxs("div",{className:"flex items-center justify-between mb-3",children:[e.jsx(At,{className:"w-6 h-6 text-foundation-burgundy"}),e.jsxs("span",{className:"text-[10px] tracking-widest text-gray-500",children:[new Date().getFullYear()," GIVING"]})]}),e.jsx("div",{className:"font-serif text-4xl text-foundation-burgundy-deep",children:au(B.thisYear)}),e.jsx("div",{className:"text-xs text-gray-500 mt-2",children:"Tax-deductible this calendar year"})]}),e.jsxs("div",{className:"bg-white rounded-2xl p-6 border border-foundation-sage-border shadow-sm",children:[e.jsxs("div",{className:"flex items-center justify-between mb-3",children:[e.jsx(Bu,{className:"w-6 h-6 text-foundation-gold"}),e.jsx("span",{className:"text-[10px] tracking-widest text-gray-500",children:"RECURRING"})]}),e.jsx("div",{className:"font-serif text-4xl text-foundation-burgundy-deep",children:v.filter(W=>W.status==="active").length}),e.jsx("div",{className:"text-xs text-gray-500 mt-2",children:"Active monthly commitments"})]})]}),e.jsxs("div",{className:"bg-white rounded-2xl border border-foundation-sage-border overflow-hidden",children:[e.jsxs("div",{className:"px-6 py-4 border-b border-foundation-sage-border flex items-center justify-between",children:[e.jsx("h3",{className:"font-serif text-lg text-foundation-burgundy-deep",children:"Recent Activity"}),e.jsx("button",{onClick:()=>b("history"),className:"text-xs text-foundation-burgundy font-semibold tracking-wider hover:text-foundation-burgundy-deep",children:"VIEW ALL â"})]}),m.length===0?e.jsxs("div",{className:"p-12 text-center text-gray-500",children:[e.jsx(ta,{className:"w-10 h-10 text-gray-300 mx-auto mb-3"}),e.jsx("div",{className:"text-sm",children:"No donations on record yet."})]}):e.jsx("div",{className:"divide-y divide-foundation-sage-border",children:m.slice(0,5).map(W=>e.jsxs("div",{className:"px-6 py-4 flex items-center justify-between hover:bg-foundation-sage-light",children:[e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx("div",{className:"w-10 h-10 rounded-full bg-foundation-sage flex items-center justify-center",children:e.jsx(Ro,{className:"w-4 h-4 text-foundation-burgundy"})}),e.jsxs("div",{children:[e.jsxs("div",{className:"font-medium text-foundation-burgundy-deep",children:[au(W.amount_cents)," · ",W.purpose||"General Fund"]}
1240),e.jsxs("div",{className:"text-xs text-gray-500 mt-0.5",children:[Ep(W.processed_at||W.created_at)," · Receipt ",W.receipt_number]})]})]}),e.jsxs("div",{className:"flex items-center gap-3",children:[qv(W.status),e.jsxs("button",{onClick:()=>j(W),className:"text-foundation-burgundy hover:text-foundation-burgundy-deep text-xs font-semibold tracking-wider flex items-center gap-1",children:[e.jsx(Kt,{className:"w-3.5 h-3.5"})," RECEIPT"]})]})]},W.id))})]})]}),!u&&N==="history"&&e.jsxs("div",{className:"bg-white rounded-2xl border border-foundation-sage-border overflow-hidden",children:[e.jsx("div",{className:"px-6 py-4 border-b border-foundation-sage-border flex items-center justify-between",children:e.jsxs("div",{children:[e.jsx("h3",{className:"font-serif text-xl text-foundation-burgundy-deep",children:"Complete Giving History"}),e.jsxs("div",{className:"text-xs text-gray-500 mt-0.5",children:[m.length," transaction",m.length!==1?"s":""," on record"]})]})}),m.length===0?e.jsx("div",{className:"p-12 text-center text-gray-500 text-sm",children:"No donations yet."}):e.jsxs("table",{className:"w-full text-sm",children:[e.jsx("thead",{className:"bg-foundation-sage-light text-[10px] tracking-widest text-foundation-burgundy-deep font-bold",children:e.jsxs("tr",{children:[e.jsx("th",{className:"text-left px-6 py-3",children:"DATE"}),e.jsx("th",{className:"text-left px-6 py-3",children:"RECEIPT"}),e.jsx("th",{className:"text-left px-6 py-3",children:"PURPOSE"}),e.jsx("th",{className:"text-left px-6 py-3",children:"STATUS"}),e.jsx("th",{className:"text-right px-6 py-3",children:"AMOUNT"}),e.jsx("th",{className:"text-right px-6 py-3",children:"ACTION"})]})}),e.jsx("tbody",{className:"divide-y divide-foundation-sage-border",children:m.map(W=>e.jsxs("tr",{className:"hover:bg-foundation-sage-light",children:[e.jsx("td",{className:"px-6 py-4 text-gray-700",children:Ep(W.processed_at||W.created_at)}),e.jsx("td",{className:"px-6 py-4 font-mono text-xs text-gray-600",children:W.receipt_number}),e.jsx("td",{className:"px-6 py-4 text-gray-700",children:W.purpose||"General Fund"}),e.jsx("td",{className:"px-6 py-4",children:qv(W.status)}),e.jsx("td",{className:"px-6 py-4 text-right font-semibold text-foundation-burgundy-deep",children:au(W.amount_cents)}),e.jsx("td",{className:"px-6 py-4 text-right",children:e.jsxs("button",{onClick:()=>j(W),className:"inline-flex items-center gap-1 bg-foundation-burgundy hover:bg-foundation-burgundy-deep text-white text-xs font-semibold tracking-wider px-3 py-1.5 rounded",children:[e.jsx(us,{className:"w-3 h-3"})," PDF"]})})]},W.id))})]})]}),!u&&N==="banks"&&e.jsxs("div",{className:"space-y-5",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"font-serif text-2xl text-foundation-burgundy-deep",children:"Linked Bank Accounts"}),e.jsx("div",{className:"text-sm text-gray-500 mt-1",children:"Manage the accounts used for your tax-deductible gifts"})]}),e.jsxs("button",{onClick:q,disabled:_==="add-bank",className:"bg-foundation-burgundy hover:bg-foundation-burgundy-deep text-white font-semibold text-sm px-5 py-2.5 rounded-lg tracking-wider flex items-center gap-2 disabled:opacity-50",children:[_==="add-bank"?e.jsx(de,{className:"w-4 h-4 animate-spin"}):e.jsx(tn,{className:"w-4 h-4"}),"LINK NEW BANK"]})]}),h.length===0?e.jsxs("div",{className:"bg-white rounded-2xl border border-dashed border-foundation-sage-border p-12 text-center",children:[e.jsx(Ws,{className:"w-10 h-10 text-gray-300 mx-auto mb-3"}),e.jsx("div",{className:"text-sm text-gray-500",children:"No bank accounts linked yet."})]}):e.jsx("div",{className:"grid gap-4",children:h.map(W=>e.jsx("div",{className:`bg-white rounded-2xl border-2 p-6 ${W.is_default?"border-foundation-gold shadow-lg":"border-foundation-sage-border"}`,children:e.jsxs("div",{className:"flex items-start justify-between flex-wrap gap-4",children:[e.jsxs("div",{className:"flex items-start gap-4",children:[e.jsx("div",{className:"w-12 h-12 rounded-xl bg-gradient-to-br from-foundation-burgundy-deep to-foundation-burgundy flex items-center justify-center",children:e.jsx(Do,{
1240className:"w-6 h-6 text-foundation-gold"})}),e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[e.jsx("div",{className:"font-serif text-lg text-foundation-burgundy-deep",children:W.institution_name||"Bank"}),W.is_default&&e.jsx("span",{className:"bg-foundation-gold text-foundation-burgundy-deep text-[9px] font-bold tracking-widest px-2 py-0.5 rounded",children:"DEFAULT"})]}),e.jsxs("div",{className:"text-sm text-gray-600 font-mono",children:[W.account_subtype||W.account_type||"Account"," ···· ",W.account_mask]}),e.jsxs("div",{className:"text-xs text-gray-400 mt-1",children:["Linked ",Ep(W.created_at)]})]})]}),e.jsxs("div",{className:"flex gap-2 flex-wrap",children:[!W.is_default&&e.jsxs("button",{onClick:()=>R(W.id),disabled:_===`default-${W.id}`,className:"flex items-center gap-1.5 border border-foundation-burgundy-deep text-foundation-burgundy-deep hover:bg-foundation-burgundy-deep hover:text-white text-xs font-semibold tracking-wider px-3 py-2 rounded transition disabled:opacity-50",children:[_===`default-${W.id}`?e.jsx(de,{className:"w-3 h-3 animate-spin"}):e.jsx(zo,{className:"w-3 h-3"}),"SET DEFAULT"]}),e.jsxs("button",{onClick:()=>U(W),disabled:_===`update-${W.id}`,className:"flex items-center gap-1.5 border border-foundation-burgundy text-foundation-burgundy hover:bg-foundation-burgundy hover:text-white text-xs font-semibold tracking-wider px-3 py-2 rounded transition disabled:opacity-50",children:[_===`update-${W.id}`?e.jsx(de,{className:"w-3 h-3 animate-spin"}):e.jsx(Be,{className:"w-3 h-3"}),"UPDATE"]}),e.jsxs("button",{onClick:()=>T(W.id),disabled:_===`remove-${W.id}`,className:"flex items-center gap-1.5 border border-red-300 text-red-600 hover:bg-red-50 text-xs font-semibold tracking-wider px-3 py-2 rounded transition disabled:opacity-50",children:[_===`remove-${W.id}`?e.jsx(de,{className:"w-3 h-3 animate-spin"}):e.jsx(Ke,{className:"w-3 h-3"}),"REMOVE"]})]})]})},W.id))}),e.jsxs("div",{className:"bg-foundation-sage-light border-l-4 border-foundation-gold p-4 text-xs text-gray-600 rounded",children:[e.jsx("strong",{className:"text-foundation-burgundy-deep",children:"UPDATE MODE"})," re-authenticates your bank connection with Plaid without creating a new account record. Use this if your bank requires re-verification or you've changed your login credentials."]})]}),!u&&N==="subscriptions"&&e.jsxs("div",{className:"space-y-5",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"font-serif text-2xl text-foundation-burgundy-deep",children:"Recurring Gifts"}),e.jsx("div",{className:"text-sm text-gray-500 mt-1",children:"Pause, resume, or cancel your monthly commitments"})]}),v.length===0?e.jsxs("div",{className:"bg-white rounded-2xl border border-dashed border-foundation-sage-border p-12 text-center",children:[e.jsx(Bu,{className:"w-10 h-10 text-gray-300 mx-auto mb-3"}),e.jsx("div",{className:"text-sm text-gray-500 mb-3",children:"You have no recurring gifts at this time."}),e.jsxs("a",{href:"#/foundation",className:"inline-flex items-center gap-2 bg-foundation-burgundy hover:bg-foundation-burgundy-deep text-white font-semibold text-sm px-5 py-2.5 rounded-lg tracking-wider",children:[e.jsx(ta,{className:"w-4 h-4"})," START MONTHLY GIVING"]})]}):e.jsx("div",{className:"grid gap-4",children:v.map(W=>{const X=h.find(Q=>Q.id===W.donor_bank_account_id);return e.jsx("div",{className:"bg-white rounded-2xl border border-foundation-sage-border p-6",children:e.jsxs("div",{className:"flex items-start justify-between flex-wrap gap-4",children:[e.jsxs("div",{className:"flex items-start gap-4",children:[e.jsx("div",{className:"w-12 h-12 rounded-xl bg-foundation-sage flex items-center justify-center",children:e.jsx(Bu,{className:"w-6 h-6 text-foundation-burgundy"})}),e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[e.jsx("div",{className:"font-serif text-2xl text-foundation-burgundy-deep",children:au(W.amount_cents)}),e.jsxs("span",{className:"text-sm text-gray-500",children:["/ ",W.frequency]}),qv(W.status)]}),e.jsx("div",{className:"text-sm text-gray-600 mt-1",children:W.purpose||"General Scholarship Fund"}),e.jsxs("div",{className:"text-xs text-gray-400 mt-2 space-y-0.5",children:[e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx(At,{className:"w-3 h-3"})," Started ",Ep(W.created_at)]}),W.next_charge_date&&W.status==="active"&&e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx(dt,{className:"w-3 h-3"})," Next charge ",Ep(W.next_charge_date)]}),X&&e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx(Do,{
1240className:"w-3 h-3"})," ",X.institution_name," ···· ",X.account_mask]})]})]})]}),e.jsxs("div",{className:"flex gap-2 flex-wrap",children:[W.status==="active"&&e.jsxs("button",{onClick:()=>M(W.id,"pause"),disabled:_===`sub-${W.id}`,className:"flex items-center gap-1.5 border border-amber-500 text-amber-700 hover:bg-amber-50 text-xs font-semibold tracking-wider px-3 py-2 rounded disabled:opacity-50",children:[_===`sub-${W.id}`?e.jsx(de,{className:"w-3 h-3 animate-spin"}):e.jsx(HP,{className:"w-3 h-3"})," PAUSE"]}),W.status==="paused"&&e.jsxs("button",{onClick:()=>M(W.id,"resume"),disabled:_===`sub-${W.id}`,className:"flex items-center gap-1.5 border border-emerald-500 text-emerald-700 hover:bg-emerald-50 text-xs font-semibold tracking-wider px-3 py-2 rounded disabled:opacity-50",children:[_===`sub-${W.id}`?e.jsx(de,{className:"w-3 h-3 animate-spin"}):e.jsx(Xx,{className:"w-3 h-3"})," RESUME"]}),W.status!=="cancelled"&&e.jsxs("button",{onClick:()=>M(W.id,"cancel"),disabled:_===`sub-${W.id}`,className:"flex items-center gap-1.5 border border-red-300 text-red-600 hover:bg-red-50 text-xs font-semibold tracking-wider px-3 py-2 rounded disabled:opacity-50",children:[_===`sub-${W.id}`?e.jsx(de,{className:"w-3 h-3 animate-spin"}):e.jsx(Ke,{className:"w-3 h-3"})," CANCEL"]})]})]})},W.id)})})]}),!u&&N==="tax"&&e.jsxs("div",{className:"space-y-5",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"font-serif text-2xl text-foundation-burgundy-deep",children:"Tax Documents"}),e.jsx("div",{className:"text-sm text-gray-500 mt-1",children:"Official IRS-ready giving statements · 501(c)(3) · EIN 87-4273317"})]}),e.jsxs("div",{className:"bg-gradient-to-br from-foundation-burgundy-deep to-foundation-burgundy rounded-2xl p-8 text-white",children:[e.jsxs("div",{className:"flex items-center gap-3 mb-2",children:[e.jsx(Is,{className:"w-6 h-6 text-foundation-gold"}),e.jsx("div",{className:"text-[10px] tracking-[0.3em] text-foundation-gold font-bold",children:"IRC § 170(c)(2) · TAX-DEDUCTIBLE CONTRIBUTIONS"})]}),e.jsx("div",{className:"font-serif text-3xl mb-2",children:"Download your year-end giving statement"}),e.jsx("div",{className:"text-sm text-foundation-sage max-w-2xl",children:"Your annual statement summarizes all qualified charitable contributions for the tax year. Download, print, or save as PDF to include with your IRS filing."})]}),e.jsx("div",{className:"grid md:grid-cols-2 lg:grid-cols-3 gap-4",children:B.availableYears.length===0?e.jsxs("div",{className:"md:col-span-2 lg:col-span-3 bg-white rounded-2xl border border-dashed border-foundation-sage-border p-8 text-center",children:[e.jsx(Kt,{className:"w-10 h-10 text-gray-300 mx-auto mb-3"}),e.jsx("div",{className:"text-sm text-gray-500",children:"No tax year data available yet."})]}):B.availableYears.map(W=>{const X=m.filter(Q=>(Q.status==="succeeded"||Q.status==="posted"||Q.status==="authorized")&&new Date(Q.processed_at||Q.created_at).getFullYear()===W).reduce((Q,K)=>Q+K.amount_cents,0);return e.jsxs("button",{onClick:()=>w(W),className:"bg-white rounded-2xl border border-foundation-sage-border p-6 text-left hover:border-foundation-gold hover:shadow-lg transition group",children:[e.jsxs("div",{className:"flex items-center justify-between mb-4",children:[e.jsx("div",{className:"w-10 h-10 rounded-lg bg-foundation-sage-light flex items-center justify-center group-hover:bg-foundation-gold",children:e.jsx(Kt,{className:"w-5 h-5 text-foundation-burgundy-deep"})}),e.jsx("span",{className:"text-[9px] tracking-widest text-foundation-gold font-bold",children:"1098-C STYLE"})]}),e.jsx("div",{className:"font-serif text-3xl text-foundation-burgundy-deep",children:W}),e.jsx("div",{className:"text-sm text-gray-500 mt-1",children:"Annual Giving Statement"}),e.jsxs("div",{className:"pt-3 mt-3 border-t border-foundation-sage-border",children:[e.jsx("div",{className:"text-[10px] tracking-widest text-gray-500",children:"TOTAL DEDUCTIBLE"}),e.jsx("div",{className:"font-serif text-xl text-foundation-burgundy mt-0.5",children:au(X)})]}),e.jsxs("div",{className:"mt-4 inline-flex items-center gap-1.5 text-xs font-semibold tracking-wider text-foundation-burgundy group-hover:text-foundation-burgundy-deep",children:[e.jsx(us,{className:"w-3.5 h-3.5"})," DOWNLOAD STATEMENT"]})]},W)})}),e.jsxs("div",{className:"bg-foundation-sage-light border-l-4 border-foundation-gold p-5 text-sm text-gray-700 rounded",children:[e.jsx("div",{className:"text-[10px] tracking-widest font-bold text-foundation-burgundy-deep mb-2",children:"IRS FILING NOTES"}),e.jsx("p",{className:"leading-relaxed",children:"The Zorganics Foundation is a qualified 501(c)(3) non-profit (EIN 87-4273317). Your contributions are deductible to the fullest extent allowed by law under IRC § 170(c)(2). No goods or services were exchanged. Consult your tax professional regarding deductibility limits."})]})]})]}),f&&e.jsx(wee,{donation:f,onClose:()=>j(null)}),S!==null&&e.jsx(Nee,{donations:m,year:S,donorName:A||a.donor_email.split("@")[0],donorEmail:a.donor_email,onClose:()=>w(null)}),E&&F&&e.jsx(_ee,{linkToken:E,accessToken:F,donorEmail:a.donor_email,sessionToken:a.session_token,onDone:()=>{P(null),I(null),V()},onCancel:()=>{P(null),I(null)}}),D&&e.jsx(kee,{linkToken:D,donorEmail:a.donor_email,onDone:()=>{L(null),V()},onCancel:()=>L(null)}),e.jsxs("footer",{className:"bg-foundation-burgundy-deep text-center py-6 mt-12 border-t-2 border-foundation-gold",children:[e.jsx("div",{className:"text-[9px] tracking-[0.3em] text-foundation-gold font-bold",children:"ZORGANICS FOUNDATION · 501(c)(3) · EIN 87-4273317"}),e.jsx("div",{className:"text-[10px] text-foundation-sage mt-2",children:"Bank-level encryption · SOC 2 Type II · Plaid Verified"})]})]}):e.jsx(vee,{})},Cee=["sparkles","flower","scissors","leaf"],XA=t=>({category_id:(t==null?void 0:t.category_id)||"",category_title:(t==null?void 0:t.category_title)||"",category_color:(t==null?void 0:t.category_color)||"#800020",category_icon:(t==null?void 0:t.category_icon)||"sparkles",category_description:(t==null?void 0:t.category_description)||"",name:"",duration:"60 min",price_cents:0,price_suffix:"",condition:"",description:"",pillar:"",position:0,is_active:!0}),Aee=()=>
1240{const[t,s]=d.useState([]),[n,a]=d.useState(!0),[r,i]=d.useState(!1),[o,l]=d.useState(null),[c,u]=d.useState(null),[p,m]=d.useState(null),x=async()=>{a(!0);const{data:f,error:j}=await O.from("z_salon_services").select("*").order("category_id",{ascending:!0}).order("position",{ascending:!0});!j&&f&&s(f),a(!1)};d.useEffect(()=>{x()},[]);const h=d.useMemo(()=>{const f=[],j={};return t.forEach(S=>{j[S.category_id]||(f.push(S.category_id),j[S.category_id]=[]),j[S.category_id].push(S)}),f.map(S=>{var w,_;return{id:S,title:((w=j[S][0])==null?void 0:w.category_title)||S,color:(_=j[S][0])==null?void 0:_.category_color,items:j[S]}})},[t]),y=d.useMemo(()=>{const f={};return t.forEach(j=>{f[j.category_id]||(f[j.category_id]=j)}),Object.values(f)},[t]),v=(f,j)=>{u({type:f,text:j}),setTimeout(()=>u(null),4e3)},g=async()=>{var S,w,_;if(!o)return;if(!((S=o.name)!=null&&S.trim())){v("error","Service name is required");return}if(!((w=o.category_id)!=null&&w.trim())||!((_=o.category_title)!=null&&_.trim())){v("error","Category id & title required");return}i(!0);const f={category_id:o.category_id.trim(),category_title:o.category_title.trim(),category_color:o.category_color||"#800020",category_icon:o.category_icon||"sparkles",category_description:o.category_description||"",name:o.name.trim(),duration:o.duration||null,price_cents:Math.round(Number(o.price_cents)||0),price_suffix:o.price_suffix||"",condition:o.condition||"",description:o.description||"",pillar:o.pillar||null,position:Math.round(Number(o.position)||0),is_active:o.is_active!==!1,updated_at:new Date().toISOString()};let j;if(o.id?{error:j}=await O.from("z_salon_services").update(f).eq("id",o.id):{error:j}=await O.from("z_salon_services").insert(f),i(!1),j){v("error",`Save failed: ${j.message}`);return}v("success",o.id?"Service updated":"Service added to menu"),l(null),x()},N=async f=>{const{error:j}=await O.from("z_salon_services").update({is_active:!f.is_active,updated_at:new Date().toISOString()}).eq("id",f.id);if(j){v("error",j.message);return}x()},b=async()=>{if(!p)return;const{error:f}=await O.from("z_salon_services").delete().eq("id",p);if(m(null),f){v("error",f.message);return}v("success","Service removed"),x()};return e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center justify-between mb-6",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"font-display text-xl font-bold text-gray-900",children:"Edit Service Menu"}),e.jsx("p",{className:"text-xs text-gray-500 mt-0.5",children:"Live, database-driven menu (z_salon_services) â changes appear instantly on the salon page"})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("button",{onClick:x,className:"inline-flex items-center gap-2 px-3 py-2 bg-stone-100 hover:bg-stone-200 rounded-lg text-xs font-semibold text-gray-700",children:[e.jsx(Be,{size:13})," Refresh"]}),e.jsxs("button",{onClick:()=>l(XA()),className:"inline-flex items-center gap-2 px-4 py-2 bg-burgundy text-white hover:bg-burgundy-dark rounded-lg text-xs font-bold",children:[e.jsx(tn,{size:14})," Add Service"]})]})]}),c&&e.jsxs("div",{className:`mb-4 rounded-lg p-3 border flex items-center gap-2 text-xs font-medium ${c.type==="success"?"bg-emerald-50 border-emerald-200 text-emerald-800":"bg-red-50 border-red-200 text-red-800"}`,children:[c.type==="success"?e.jsx(pt,{size:14}):e.jsx(kt,{size:14})," ",c.text]}),n?e.jsx("div",{className:"p-16 text-center",children:e.jsx(de,{size:26,className:"mx-auto text-burgundy animate-spin"})}):h.length===0?e.jsxs("div",{className:"p-12 text-center bg-white rounded-xl border border-stone-200",children:[e.jsx(sf,{size:28,className:"mx-auto text-stone-300 mb-3"}),e.jsx("p",{className:"text-sm text-gray-500",children:'No services yet. Click "Add Service" to build your menu.'})]}):e.jsx("div",{className:"space-y-6",children:h.map(f=>e.jsxs("div",{className:"bg-white rounded-xl border border-stone-200/70 shadow-sm overflow-hidden",children:[e.jsxs("div",{className:"px-5 py-3 flex items-center gap-2 border-b border-stone-100",style:{background:`${f.color}10`},children:[e.jsx("span",{className:"w-3 h-3 rounded-full",style:{background:f.color||"#800020"}}),e.jsx("h3",{className:"font-bold text-sm text-gray-900",children:f.title}),e.jsxs("span",{className:"text-[10px] text-gray-400 uppercase tracking-wider ml-1",children:[f.items.length," services"]}),e.jsxs("button",{onClick:()=>l(XA(f.items[0])),className:"ml-auto text-[11px] font-semibold text-burgundy hover:underline inline-flex items-center gap-1",children:[e.jsx(tn,{size:11})," Add to category"]})]}),e.jsx("div",{className:"divide-y divide-stone-50",children:f.items.map(j=>e.jsxs("div",{className:`px-5 py-3 flex items-center gap-3 ${j.is_active?"":"opacity-50"}`,children:[e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"text-sm font-semibold text-gray-900 truncate",children:j.name}),e.jsxs("div",{className:"flex items-center gap-3 text-[11px] text-gray-400 mt-0.5",children:[e.jsxs("span",{className:"inline-flex items-center gap-1",children:[e.jsx(dt,{size:10})," ",j.duration||"â"]}
1240),j.condition&&e.jsx("span",{className:"truncate",children:j.condition})]})]}),e.jsxs("span",{className:"font-mono font-bold text-sm text-burgundy whitespace-nowrap",children:["$",(j.price_cents/100).toFixed(0),j.price_suffix||""]}),e.jsx("button",{onClick:()=>N(j),title:j.is_active?"Hide":"Show",className:"p-1.5 rounded-lg hover:bg-stone-100 text-gray-500",children:j.is_active?e.jsx(ms,{size:14}):e.jsx(Md,{size:14})}),e.jsx("button",{onClick:()=>l(j),className:"p-1.5 rounded-lg hover:bg-blue-50 text-blue-600",children:e.jsx(GP,{size:14})}),e.jsx("button",{onClick:()=>m(j.id),className:"p-1.5 rounded-lg hover:bg-red-50 text-red-500",children:e.jsx(va,{size:14})})]},j.id))})]},f.id))}),o&&e.jsx("div",{className:"fixed inset-0 z-[60] flex items-center justify-center p-4 bg-black/40 backdrop-blur-sm",onClick:()=>!r&&l(null),children:e.jsxs("div",{className:"bg-white rounded-2xl w-full max-w-lg max-h-[90vh] overflow-y-auto shadow-2xl",onClick:f=>f.stopPropagation(),children:[e.jsxs("div",{className:"px-6 py-4 border-b border-stone-100 flex items-center justify-between sticky top-0 bg-white",children:[e.jsx("h3",{className:"font-bold text-gray-900",children:o.id?"Edit Service":"Add Service"}),e.jsx("button",{onClick:()=>l(null),className:"p-1.5 hover:bg-stone-100 rounded-lg",children:e.jsx(Ke,{size:16})})]}),e.jsxs("div",{className:"p-6 space-y-4",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs(Ka,{label:"Category ID",children:[e.jsx("input",{list:"cat-ids",value:o.category_id||"",onChange:f=>{const j=f.target.value,S=y.find(w=>w.category_id===j);l({...o,category_id:j,...S?{category_title:S.category_title,category_color:S.category_color,category_icon:S.category_icon,category_description:S.category_description}:{}})},className:Cr,placeholder:"hairscalp"}),e.jsx("datalist",{id:"cat-ids",children:y.map(f=>e.jsx("option",{value:f.category_id},f.category_id))})]}),e.jsx(Ka,{label:"Category Title",children:e.jsx("input",{value:o.category_title||"",onChange:f=>l({...o,category_title:f.target.value}),className:Cr,placeholder:"Holistic Hair & Scalp Care"})})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsx(Ka,{label:"Category Color",children:e.jsx("input",{type:"color",value:o.category_color||"#800020",onChange:f=>l({...o,category_color:f.target.value}),className:"w-full h-9 rounded-lg border border-stone-200"})}),e.jsx(Ka,{label:"Category Icon",children:e.jsx("select",{value:o.category_icon||"sparkles",onChange:f=>l({...o,category_icon:f.target.value}),className:Cr,children:Cee.map(f=>e.jsx("option",{value:f,children:f},f))})})]}),e.jsx(Ka,{label:"Service Name",children:e.jsx("input",{value:o.name||"",onChange:f=>l({...o,name:f.target.value}),className:Cr,placeholder:"The Signature Cut & Style"})}),e.jsxs("div",{className:"grid grid-cols-3 gap-3",children:[e.jsx(Ka,{label:"Duration",children:e.jsx("input",{value:o.duration||"",onChange:f=>l({...o,duration:f.target.value}),className:Cr,placeholder:"45 min"})}),e.jsx(Ka,{label:"Price ($)",children:e.jsx("input",{type:"number",step:"0.01",value:o.price_cents!=null?(o.price_cents/100).toString():"",onChange:f=>l({...o,price_cents:Math.round((parseFloat(f.target.value)||0)*100)}),className:Cr,placeholder:"25"})}),e.jsx(Ka,{label:"Price Suffix",children:e.jsx("input",{value:o.price_suffix||"",onChange:f=>l({...o,price_suffix:f.target.value}),className:Cr,placeholder:"+"})})]}),e.jsx(Ka,{label:"Condition / Tagline",children:e.jsx("input",{value:o.condition||"",onChange:f=>l({...o,condition:f.target.value}),className:Cr,placeholder:"Precision Haircutting & Styling"})}),e.jsx(Ka,{label:"Description",children:e.jsx("textarea",{value:o.description||"",onChange:f=>l({...o,description:f.target.value}),rows:2,className:Cr+" resize-none"})}),e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsx(Ka,{label:"Pillar (optional)",children:e.jsx("input",{value:o.pillar||"",onChange:f=>l({...o,pillar:f.target.value}),className:Cr,placeholder:"systems / braiding / lifita / color"})}),e.jsx(Ka,{label:"Position",children:e.jsx("input",{type:"number",value:o.position??0,onChange:f=>l({...o,position:parseInt(f.target.value)||0}),className:Cr})})]}),e.jsxs("label",{className:"flex items-center gap-2 cursor-pointer",children:[e.jsx("input",{type:"checkbox",checked:o.is_active!==!1,onChange:f=>l({...o,is_active:f.target.checked}),style:{accentColor:"#800020"}}),e.jsx("span",{className:"text-sm text-gray-700",children:"Active (visible on salon page)"})]})]}),e.jsxs("div",{className:"px-6 py-4 border-t border-stone-100 flex gap-3 sticky bottom-0 bg-white",children:[e.jsx("button",{onClick:()=>l(null),disabled:r,className:"flex-1 py-2.5 border border-stone-200 text-gray-700 rounded-lg text-sm font-semibold hover:bg-stone-50 disabled:opacity-50",children:"Cancel"}),e.jsxs("button",{onClick:g,disabled:r,className:"flex-1 py-2.5 bg-burgundy text-white rounded-lg text-sm font-bold hover:bg-burgundy-dark disabled:opacity-50 flex items-center justify-center gap-2",children:[r?e.jsx(de,{size:14,className:"animate-spin"}):e.jsx(ti,{size:14})," Save Service"]})]})]})}),p&&e.jsx("div",{className:"fixed inset-0 z-[60] flex items-center justify-center p-4 bg-black/40",onClick:()=>m(null),children:e.jsxs("div",{className:"bg-white rounded-2xl w-full max-w-sm p-6 shadow-2xl",onClick:f=>f.stopPropagation(),children:[e.jsxs("div",{className:"flex items-start gap-3 mb-4",children:[e.jsx(ve,{size:20,className:"text-red-600 flex-shrink-0 mt-0.5"}),e.jsxs("div",{children:[e.jsx("p",{className:"font-bold text-gray-900",children:"Delete this service?"}),e.jsx("p",{className:"text-xs text-gray-500 mt-1",children:"This permanently removes it from the menu. This cannot be undone."})]})]}),e.jsxs("div",{className:"flex gap-3",children:[e.jsx("button",{onClick:()=>m(null),className:"flex-1 py-2.5 border border-stone-200 rounded-lg text-sm font-semibold hover:bg-stone-50",children:"Cancel"}),e.jsxs("button",{onClick:b,className:"flex-1 py-2.5 bg-red-600 text-white rounded-lg text-sm font-bold hover:bg-red-700 flex items-center justify-center gap-2",children:[e.jsx(va,{size:14})," Delete"]})]})]})})]})},Cr="w-full px-3 py-2 border border-stone-200 rounded-lg text-sm text-gray-800 focus:outline-none focus:ring-2 focus:ring-burgundy/30",K
1240a=({label:t,children:s})=>e.jsxs("div",{children:[e.jsx("label",{className:"block text-[11px] font-bold uppercase tracking-wider mb-1.5 text-gray-500",children:t}),s]}),Eee=["Bellingham","Seattle","Renton"],Fee={Bellingham:{days:[3,4,5],times:["1:00 PM","2:00 PM","3:00 PM","4:00 PM","5:00 PM"],label:"WedâFri · 1pmâ6pm"},Seattle:{days:[1,2,3,4,5,6],times:["9:00 AM","10:30 AM","12:00 PM","1:30 PM","3:00 PM","4:30 PM"],label:"MonâSat"},Renton:{days:[1,2,3,4,5,6],times:["9:00 AM","10:30 AM","12:00 PM","1:30 PM","3:00 PM","4:30 PM"],label:"MonâSat"}},eE=t=>Fee[t]||{days:[1,2,3,4,5,6],times:["9:00 AM","10:30 AM","12:00 PM","1:30 PM","3:00 PM","4:30 PM"],label:"MonâSat"},tE=t=>{const s=/(\d{1,2}):(\d{2})\s*(AM|PM)/i.exec(t||"");if(!s)return 9999;let n=parseInt(s[1],10)%12;return s[3].toUpperCase()==="PM"&&(n+=12),n*60+parseInt(s[2],10)},Tee=()=>{const[t,s]=d.useState([]),[n,a]=d.useState(!0),[r,i]=d.useState("Bellingham"),[o,l]=d.useState(null),[c,u]=d.useState(!1),p=eE(r),[m,x]=d.useState(""),[h,y]=d.useState(eE("Bellingham").times[0]),[v,g]=d.useState(""),[N,b]=d.useState(7);d.useEffect(()=>{p.times.includes(h)||y(p.times[0])},[r]);const f=(F,I)=>{l({type:F,text:I}),setTimeout(()=>l(null),4e3)},j=async()=>{a(!0);const F=new Date().toISOString().split("T")[0],{data:I,error:D}=await O.from("z_salon_slots").select("*").eq("campus",r).gte("slot_date",F).order("slot_date",{ascending:!0});!D&&I&&s(I),a(!1)};d.useEffect(()=>{j()},[r]);const S=d.useMemo(()=>{const F=new Map;return t.forEach(I=>{F.has(I.slot_date)||F.set(I.slot_date,[]),F.get(I.slot_date).push(I)}),Array.from(F.entries()).map(([I,D])=>({date:I,items:D.sort((L,V)=>tE(L.slot_time)-tE(V.slot_time))}))},[t]),w=async()=>{if(!m){f("error","Pick a date");return}u(!0);const{error:F}=await O.from("z_salon_slots").insert({campus:r,slot_date:m,slot_time:h,is_booked:!1});if(u(!1),F){f("error",F.message.includes("duplicate")?"That slot already exists":F.message);return}f("success",`Added ${h} on ${m}`),j()},_=async()=>{if(!v){f("error","Pick a start date");return}u(!0);const F=[],I=new Date(v+"T00:00:00");for(let L=0;L<N;L++){const V=new Date(I);V.setDate(I.getDate()+L);const B=V.getDay();if(!p.days.includes(B))continue;const A=V.toISOString().split("T")[0];p.times.forEach(z=>F.push({campus:r,slot_date:A,slot_time:z,is_booked:!1}))}if(F.length===0){u(!1),f("error",`No open days for ${r} (${p.label}) in that range`);return}const{error:D}=await O.from("z_salon_slots").upsert(F,{onConflict:"campus,slot_date,slot_time",ignoreDuplicates:!0});if(u(!1),D){f("error",D.message);return}f("success",`Generated availability for ${r} (${N} days, ${p.label})`),j()},C=async F=>{if(F.is_booked&&F.booking_reference){f("error","Slot has a real booking â refund/cancel it first");return}const{error:I}=await O.from("z_salon_slots").update({is_booked:!F.is_booked,updated_at:new Date().toISOString()}).eq("id",F.id);if(I){f("error",I.message);return}j()},E=async F=>{if(F.is_booked&&F.booking_reference){f("error","Cannot delete a booked slot");return}const{error:I}=await O.from("z_salon_slots").delete().eq("id",F.id);if(I){f("error",I.message);return}j()},P=F=>new Date(F+"T00:00:00").toLocaleDateString(void 0,{weekday:"short",month:"short",day:"numeric"});return e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center justify-between mb-6",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"font-display text-xl font-bold text-gray-900",children:"Slot Manager"}),e.jsx("p",{className:"text-xs text-gray-500 mt-0.5",children:"Manage real-time availability (z_salon_slots) â double-booking is prevented at the database level"})]}),e.jsxs("button",{onClick:j,className:"inline-flex items-center gap-2 px-3 py-2 bg-stone-100 hover:bg-stone-200 rounded-lg text-xs font-semibold text-gray-700",children:[e.jsx(Be,{size:13})," Refresh"]})]}),e.jsxs("div",{className:"flex items-center gap-2 mb-5",children:[e.jsx(zt,{size:15,className:"text-gray-400"}),Eee.map(F=>e.jsx("button",{onClick:()=>i(F),className:`px-4 py-1.5 rounded-full text-xs font-bold transition-all ${r===F?"bg-burgundy text-white shadow-sm":"bg-stone-100 text-gray-600 hover:bg-stone-200"}`,children:F},F))]}),o&&e.jsxs("div",{className:`mb-4 rounded-lg p-3 border flex items-center gap-2 text-xs font-medium ${o.type==="success"?"bg-emerald-50 border-emerald-200 text-emerald-800":"bg-red-50 border-red-200 text-red-800"}`,children:[o.type==="success"?e.jsx(pt,{size:14}):e.jsx(kt,{size:14})," ",o.text]}),e.jsxs("div",{className:"grid md:grid-cols-2 gap-4 mb-6",children:[e.jsxs("div",{className:"bg-white rounded-xl border border-stone-200/70 shadow-sm p-4",children:[e.jsxs("h3",{className:"text-xs font-bold uppercase tracking-wider text-gray-500 mb-3 flex items-center gap-2",children:[e.jsx(tn,{size:13})," Add Single Slot"]}),e.jsxs("div",{className:"flex items-end gap-2",children:[e.jsxs("div",{className:"flex-1",children:[e.jsx("label",{className:"block text-[10px] text-gray-400 mb-1",children:"Date"}),e.jsx("input",{type:"date",value:m,min:new Date().toISOString().split("T")[0],onChange:F=>x(F.target.value),className:"w-full px-3 py-2 border border-stone-200 rounded-lg text-sm"})]}),e.jsxs("div",{className:"flex-1",children:[e.jsx("label",{className:"block text-[10px] text-gray-400 mb-1",children:"Time"}),e.jsx("select",{value:h,onChange:F=>y(F.target.value),className:"w-full px-3 py-2 border border-stone-200 rounded-lg text-sm",children:p.times.map(F=>e.jsx("option",{children:F},F))})]}
1240),e.jsx("button",{onClick:w,disabled:c,className:"px-4 py-2 bg-burgundy text-white rounded-lg text-xs font-bold hover:bg-burgundy-dark disabled:opacity-50",children:"Add"})]})]}),e.jsxs("div",{className:"bg-white rounded-xl border border-stone-200/70 shadow-sm p-4",children:[e.jsxs("h3",{className:"text-xs font-bold uppercase tracking-wider text-gray-500 mb-3 flex items-center gap-2",children:[e.jsx(ux,{size:13})," Bulk Generate (",p.label,")"]}),e.jsxs("div",{className:"flex items-end gap-2",children:[e.jsxs("div",{className:"flex-1",children:[e.jsx("label",{className:"block text-[10px] text-gray-400 mb-1",children:"Start Date"}),e.jsx("input",{type:"date",value:v,min:new Date().toISOString().split("T")[0],onChange:F=>g(F.target.value),className:"w-full px-3 py-2 border border-stone-200 rounded-lg text-sm"})]}),e.jsxs("div",{className:"w-24",children:[e.jsx("label",{className:"block text-[10px] text-gray-400 mb-1",children:"# Days"}),e.jsx("input",{type:"number",min:1,max:60,value:N,onChange:F=>b(Math.min(60,Math.max(1,parseInt(F.target.value)||1))),className:"w-full px-3 py-2 border border-stone-200 rounded-lg text-sm"})]}),e.jsx("button",{onClick:_,disabled:c,className:"px-4 py-2 bg-gold-dark text-white rounded-lg text-xs font-bold hover:opacity-90 disabled:opacity-50",children:"Generate"})]})]})]}),n?e.jsx("div",{className:"p-16 text-center",children:e.jsx(de,{size:26,className:"mx-auto text-burgundy animate-spin"})}):S.length===0?e.jsxs("div",{className:"p-12 text-center bg-white rounded-xl border border-stone-200",children:[e.jsx(At,{size:28,className:"mx-auto text-stone-300 mb-3"}),e.jsxs("p",{className:"text-sm text-gray-500",children:["No upcoming slots for ",r,'. Use "Bulk Generate" to create availability.']})]}):e.jsx("div",{className:"space-y-3",children:S.map(F=>e.jsxs("div",{className:"bg-white rounded-xl border border-stone-200/70 shadow-sm p-4",children:[e.jsxs("div",{className:"flex items-center justify-between mb-3",children:[e.jsx("p",{className:"font-bold text-sm text-gray-900",children:P(F.date)}),e.jsxs("p",{className:"text-[10px] text-gray-400 uppercase tracking-wider",children:[F.items.filter(I=>!I.is_booked).length," open · ",F.items.filter(I=>I.is_booked).length," blocked/booked"]})]}),e.jsx("div",{className:"flex flex-wrap gap-2",children:F.items.map(I=>e.jsxs("div",{className:"inline-flex items-center gap-1.5 pl-2.5 pr-1.5 py-1.5 rounded-lg border text-xs font-semibold",style:{background:I.is_booked?I.booking_reference?"#FEF2F2":"#FFFBEB":"#ECFDF5",borderColor:I.is_booked?I.booking_reference?"#FECACA":"#FDE68A":"#A7F3D0",color:I.is_booked?I.booking_reference?"#B91C1C":"#B45309":"#047857"},children:[e.jsx("span",{children:I.slot_time}),I.booking_reference&&e.jsx("span",{className:"font-mono text-[9px] opacity-70",children:I.booking_reference}),e.jsx("button",{onClick:()=>C(I),title:I.is_booked?"Unblock":"Block",className:"p-1 rounded hover:bg-black/5",children:I.is_booked?e.jsx(Xe,{size:11}):e.jsx(J_,{size:11})}),e.jsx("button",{onClick:()=>E(I),title:"Delete",className:"p-1 rounded hover:bg-black/5",children:e.jsx(va,{size:11})})]},I.id))})]},F.date))}),e.jsxs("div",{className:"mt-5 flex items-start gap-2 text-[11px] text-gray-400",children:[e.jsx(ve,{size:13,className:"flex-shrink-0 mt-0.5"}),e.jsx("p",{children:"Green = open · Amber = manually blocked · Red = real client booking (shows the booking reference and cannot be deleted until refunded/cancelled)."})]})]})},C0=["Bellingham","Seattle","Renton"],ig=t=>!!t&&C0.includes(t),eN={waiting:{label:"Waiting",bg:"bg-blue-50",text:"text-blue-700",border:"border-blue-200",icon:e.jsx(RO,{size:11})},notified:{label:"Notified",bg:"bg-emerald-50",text:"text-emerald-700",border:"border-emerald-200",icon:e.jsx(Di,{size:11})},expired:{label:"Expired",bg:"bg-amber-50",text:"text-amber-700",border:"border-amber-200",icon:e.jsx(ve,{size:11})},booked:{label:"Booked",bg:"bg-purple-50",text:"text-purple-700",border:"border-purple-200",icon:e.jsx(pt,{size:11})},cancelled:{label:"Removed",bg:"bg-gray-100",text:"text-gray-600",border:"border-gray-200",icon:e.jsx(Ke,{size:11})}},Pee=({status:t})=>{const s=eN[t]||eN.waiting;return e.jsxs("span",{className:`inline-flex items-center gap-1 px-2.5 py-1 rounded-full text-xs font-semibold border ${s.bg} ${s.text} ${s.border}`,children:[s.icon," ",s.label]})},Dee=()=>
1240{const[t,s]=d.useState([]),[n,a]=d.useState(!0),[r,i]=d.useState("all"),[o,l]=d.useState("all"),[c,u]=d.useState("all"),[p,m]=d.useState(""),[x,h]=d.useState(null);d.useEffect(()=>{y()},[]);const y=async()=>{a(!0);const{data:w,error:_}=await O.from("z_salon_waitlist").select("*").order("created_at",{ascending:!0});!_&&w&&s(w),a(!1)},v=d.useMemo(()=>{const w=new Map;t.filter(C=>C.status==="waiting").forEach(C=>{const E=`${C.campus||"â"}::${C.service_type||"default"}`;w.has(E)||w.set(E,[]),w.get(E).push(C)});const _=new Map;return w.forEach(C=>{C.sort((E,P)=>new Date(E.created_at).getTime()-new Date(P.created_at).getTime()),C.forEach((E,P)=>_.set(E.id,{pos:P+1,total:C.length}))}),_},[t]),g=d.useMemo(()=>{const w=new Set;return t.forEach(_=>{_.service_type&&w.add(_.service_type)}),["all",...Array.from(w).sort()]},[t]),N=d.useMemo(()=>t.filter(w=>{if(r==="Other"){if(ig(w.campus))return!1}else if(r!=="all"&&w.campus!==r)return!1;if(o!=="all"&&w.status!==o||c!=="all"&&w.service_type!==c)return!1;if(p){const _=p.toLowerCase();if(!`${w.email} ${w.name||""} ${w.service_name||""} ${w.service_type||""}`.toLowerCase().includes(_))return!1}return!0}),[t,r,o,c,p]),b=d.useMemo(()=>{const w={};return C0.forEach(_=>{w[_]={waiting:0,notified:0,total:0}}),t.forEach(_=>{ig(_.campus)&&(w[_.campus].total+=1,_.status==="waiting"&&(w[_.campus].waiting+=1),_.status==="notified"&&(w[_.campus].notified+=1))}),w},[t]),f=async w=>{h(w.id);const{error:_}=await O.from("z_salon_waitlist").update({status:"cancelled"}).eq("id",w.id);_||s(C=>C.map(E=>E.id===w.id?{...E,status:"cancelled"}:E)),h(null)},j=()=>{const w=["Campus","Service","Service Type","Name","Email","Status","Position In Line","Notified At","Offered Slot","Joined At"],_=N.map(I=>{const D=v.get(I.id);return[I.campus||"",I.service_name||"",I.service_type||"",I.name||"",I.email,I.status,D?`${D.pos} of ${D.total}`:"",I.notified_at?new Date(I.notified_at).toISOString():"",I.notified_slot_date?`${I.notified_slot_date} ${I.notified_slot_time||""}`.trim():"",new Date(I.created_at).toISOString()]}),C=[w,..._].map(I=>I.map(D=>`"${String(D).replace(/"/g,'""')}"`).join(",")).join(` 1241`),E=new Blob([C],{type:"text/csv;charset=utf-8;"}),P=URL.createObjectURL(E),F=document.createElement("a");F.href=P,F.download=`zorganics-salon-waitlist-${new Date().toISOString().split("T")[0]}.csv`,F.click(),URL.revokeObjectURL(P)},S=w=>w?new Date(w).toLocaleString():"â";return e.jsxs("div",{children:[e.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-3 gap-4 mb-6",children:C0.map(w=>e.jsxs("button",{onClick:()=>i(_=>_===w?"all":w),className:`text-left bg-white rounded-xl border p-5 shadow-sm transition-all ${r===w?"border-burgundy ring-2 ring-burgundy/20":"border-stone-200/70 hover:border-burgundy/40"}`,children:[e.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[e.jsx("div",{className:"w-8 h-8 rounded-lg bg-burgundy/10 flex items-center justify-center",children:e.jsx(zt,{size:16,className:"text-burgundy"})}),e.jsx("span",{className:"text-xs text-gray-400 uppercase tracking-wider font-semibold",children:w})]}),e.jsx("p",{className:"font-mono text-2xl font-bold text-gray-900",children:b[w].waiting}),e.jsxs("p",{className:"text-xs text-gray-400 mt-1",children:["waiting · ",b[w].notified," notified · ",b[w].total," all-time"]})]},w))}),e.jsxs("div",{className:"bg-white rounded-xl border border-stone-200/70 shadow-sm p-5 mb-6",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-3 mb-4",children:[e.jsx(zt,{size:16,className:"text-gray-400"}),e.jsx("span",{className:"text-xs font-semibold text-gray-500 uppercase tracking-wider mr-1",children:"Campus"}),["all",...C0,"Other"].map(w=>{const _=r===w,C=w==="all"?t.length:w==="Other"?t.filter(E=>!ig(E.campus)).length:t.filter(E=>E.campus===w).length;return w==="Other"&&C===0?null:e.jsxs("button",{onClick:()=>i(w),className:`px-3 py-1.5 rounded-full text-xs font-semibold transition-all ${_?"bg-burgundy text-white shadow-sm":"bg-stone-100 text-gray-600 hover:bg-stone-200"}`,children:[w==="all"?"All Campuses":w,e.jsx("span",{className:`ml-1.5 ${_?"text-white/70":"text-gray-400"}`,children:C})]},w)})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-3 pt-3 border-t border-stone-100",children:[e.jsx("span",{className:"text-xs font-semibold text-gray-500 uppercase tracking-wider",children:"Status"}),["all","waiting","notified","expired","booked","cancelled"].map(w=>{var C;const _=o===w;return e.jsx("button",{onClick:()=>l(w),className:`px-3 py-1.5 rounded-full text-xs font-semibold transition-all ${_?"bg-burgundy text-white shadow-sm":"bg-stone-100 text-gray-600 hover:bg-stone-200"}`,children:w==="all"?"All":((C=eN[w])==null?void 0:C.label)||w},w)}),e.jsx("select",{value:c,onChange:w=>u(w.target.value),className:"px-3 py-1.5 border border-stone-200 rounded-lg text-xs font-semibold text-gray-700 focus:outline-none focus:ring-2 focus:ring-burgundy/30",children:g.map(w=>e.jsx("option",{value:w,children:w==="all"?"All Services":w},w))}),e.jsxs("div",{className:"flex-1 min-w-[200px] relative",children:[e.jsx(Bt,{size:14,className:"absolute left-3 top-1/2 -translate-y-1/2 text-gray-400"}),e.jsx("input",{type:"text",value:p,onChange:w=>m(w.target.value),placeholder:"Search by name, email, or service...",className:"w-full pl-9 pr-4 py-1.5 border border-stone-200 rounded-lg text-xs text-gray-700 focus:outline-none focus:ring-2 focus:ring-burgundy/30"})]}),e.jsxs("button",{onClick:j,className:"inline-flex items-center gap-1.5 px-3 py-1.5 bg-stone-100 hover:bg-stone-200 rounded-lg text-xs font-semibold text-gray-700",children:[e.jsx(us,{size:13})," Export"]}),e.jsxs("button",{onClick:y,className:"inline-flex items-center gap-1.5 px-3 py-1.5 bg-burgundy text-white hover:bg-burgundy-dark rounded-lg text-xs font-semibold",children:[e.jsx(Be,{size:13})," Refresh"]})]})]}),e.jsx("div",{className:"bg-white rounded-xl border border-stone-200/70 shadow-sm overflow-hidden",children:n?e.jsxs("div",{className:"p-16 text-center",children:[e.jsx(de,{size:28,className:"mx-auto text-burgundy animate-spin"}),e.jsx("p",{className:"text-sm text-gray-400 mt-3",children:"Loading waitlistâ¦"})]}):N.length===0?e.jsxs("div",{className:"p-16 text-center",children:[e.jsx(Di,{size:32,className:"mx-auto text-stone-300 mb-3"}),e.jsx("p",{className:"text-sm text-gray-500 font-medium",children:"No waitlist entr
1241ies match your filters"}),e.jsx("p",{className:"text-xs text-gray-400 mt-1",children:"Guests join the waitlist when a service has no eligible open slots"})]}):e.jsx("div",{className:"overflow-x-auto",children:e.jsxs("table",{className:"w-full",children:[e.jsx("thead",{children:e.jsxs("tr",{className:"border-b border-stone-100 bg-stone-50/50",children:[e.jsx("th",{className:"text-left px-5 py-3 text-xs font-semibold text-gray-500 uppercase tracking-wider",children:"In Line"}),e.jsx("th",{className:"text-left px-3 py-3 text-xs font-semibold text-gray-500 uppercase tracking-wider",children:"Guest"}),e.jsx("th",{className:"text-left px-3 py-3 text-xs font-semibold text-gray-500 uppercase tracking-wider",children:"Campus / Service"}),e.jsx("th",{className:"text-left px-3 py-3 text-xs font-semibold text-gray-500 uppercase tracking-wider",children:"Status / Offer"}),e.jsx("th",{className:"text-left px-3 py-3 text-xs font-semibold text-gray-500 uppercase tracking-wider",children:"Joined"}),e.jsx("th",{className:"text-right px-5 py-3 text-xs font-semibold text-gray-500 uppercase tracking-wider"})]})}),e.jsx("tbody",{className:"divide-y divide-stone-50",children:N.map(w=>{const _=v.get(w.id);return e.jsxs("tr",{className:"hover:bg-rose-50/30 transition-colors",children:[e.jsx("td",{className:"px-5 py-4",children:w.status==="waiting"&&_?e.jsxs("span",{className:"inline-flex items-center gap-1.5 px-2.5 py-1 rounded-full text-xs font-bold bg-blue-50 text-blue-700 border border-blue-200",children:[e.jsx(BP,{size:11})," #",_.pos," ",e.jsxs("span",{className:"text-blue-400 font-normal",children:["/ ",_.total]})]}):e.jsx("span",{className:"text-xs text-gray-300",children:"â"})}),e.jsxs("td",{className:"px-3 py-4",children:[e.jsx("p",{className:"text-sm font-semibold text-gray-900",children:w.name||"Guest"}),e.jsxs("p",{className:"text-xs text-gray-400 flex items-center gap-1",children:[e.jsx(Ye,{size:10})," ",w.email]})]}),e.jsxs("td",{className:"px-3 py-4",children:[e.jsxs("p",{className:"text-sm text-gray-900 flex items-center gap-1",children:[e.jsx(zt,{size:11,className:ig(w.campus)?"text-burgundy":"text-amber-500"}),w.campus||"â"]}),e.jsx("p",{className:"text-[11px] text-gray-400 mt-0.5",children:w.service_name||w.service_type||"Any service"})]}),e.jsxs("td",{className:"px-3 py-4",children:[e.jsx(Pee,{status:w.status}),w.status==="notified"&&w.notified_slot_date&&e.jsxs("p",{className:"text-[11px] text-emerald-700 mt-1 flex items-center gap-1",children:[e.jsx(dt,{size:10}),new Date(w.notified_slot_date+"T00:00:00").toLocaleDateString(void 0,{month:"short",day:"numeric"}),w.notified_slot_time?` · ${w.notified_slot_time}`:""]})]}),e.jsxs("td",{className:"px-3 py-4",children:[e.jsx("p",{className:"text-xs text-gray-600",children:S(w.created_at)}),w.notified_at&&e.jsxs("p",{className:"text-[10px] text-gray-400 mt-0.5",children:["Notified ",S(w.notified_at)]})]}),e.jsx("td",{className:"px-5 py-4 text-right",children:(w.status==="waiting"||w.status==="notified")&&e.jsxs("button",{onClick:()=>f(w),disabled:x===w.id,title:"Remove from waitlist",className:"inline-flex items-center gap-1 px-2.5 py-1.5 text-xs font-semibold text-red-600 hover:bg-red-50 rounded-lg transition-colors disabled:opacity-40",children:[x===w.id?e.jsx(de,{size:12,className:"animate-spin"}):e.jsx(va,{size:12}),"Remove"]})})]},w.id)})})]})})}),e.jsxs("p",{className:"text-[11px] text-gray-400 mt-4 flex items-center gap-1.5",children:[e.jsx(ts,{size:12}),"Position in line is calculated per campus + service among guests still waiting (oldest request = #1). When a matching slot frees up, the #1 guest is auto-notified and given a time-limited hold."]})]})},tN={paid:{label:"Paid",bg:"bg-emerald-50",text:"text-emerald-700",border:"border-emerald-200",icon:e.jsx(pt,{size:11})},scheduled:{label:"Scheduled",bg:"bg-blue-50",text:"text-blue-700",border:"border-blue-200",icon:e.jsx(At,{size:11})},completed:{label:"Completed",bg:"bg-purple-50",text:"text-purple-700",border:"border-purple-200",icon:e.jsx(Qe,{size:11})},cancelled:{label:"Cancelled",bg:"bg-gray-100",text:"text-gray-600",border:"border-gray-200",icon:e.jsx(Ke,{size:11})},refunded:{label:"Refunded",bg:"bg-red-50",text:"text-red-700",border:"border-red-200",icon:e.jsx(zi,{size:11})},no_show:{label:"No Show",bg:"bg-amber-50",text:"text-amber-700",border:"border-amber-200",icon:e.jsx(ve,{size:11})}},sE=({status:t})=>{const s=tN[t]||tN.paid;return e.jsxs("span",{className:`inline-flex items-center gap-1 px-2.5 py-1 rounded-full text-xs font-semibold border ${s.bg} ${s.text} ${s.border}`,children:[s.icon," ",s.label]})},Ree=()=>
1241{const[t,s]=d.useState("bookings"),[n,a]=d.useState([]),[r,i]=d.useState(!0),[o,l]=d.useState("all"),[c,u]=d.useState("all"),[p,m]=d.useState(""),[x,h]=d.useState(""),[y,v]=d.useState(""),[g,N]=d.useState(null),[b,f]=d.useState(!1),[j,S]=d.useState(null),[w,_]=d.useState(!1),[C,E]=d.useState("");d.useEffect(()=>{P()},[]);const P=async()=>{i(!0);const{data:T,error:U}=await O.from("z_salon_bookings").select("*").order("created_at",{ascending:!1});!U&&T&&a(T),i(!1)},F=d.useMemo(()=>{const T=new Set;return n.forEach(U=>{U.service_category&&T.add(U.service_category)}),["all",...Array.from(T).sort()]},[n]),I=d.useMemo(()=>n.filter(T=>{if(o!=="all"&&T.status!==o||c!=="all"&&T.service_category!==c||p&&new Date(T.created_at).toISOString().split("T")[0]<p||x&&new Date(T.created_at).toISOString().split("T")[0]>x)return!1;if(y){const U=y.toLowerCase();if(!`${T.client_name} ${T.client_email} ${T.booking_reference} ${T.service_name}`.toLowerCase().includes(U))return!1}return!0}),[n,o,c,p,x,y]),D=d.useMemo(()=>{const T=new Date().toISOString().split("T")[0],U=n.filter(W=>new Date(W.created_at).toISOString().split("T")[0]===T),q=U.filter(W=>W.status!=="refunded"&&W.status!=="cancelled").reduce((W,X)=>W+(X.service_price_cents||0),0)/100,H=I.filter(W=>W.status!=="refunded"&&W.status!=="cancelled").reduce((W,X)=>W+(X.service_price_cents||0),0)/100,G=n.filter(W=>{if(!W.preferred_date)return!1;const X=new Date(W.preferred_date);X.setHours(0,0,0,0);const Q=new Date;return Q.setHours(0,0,0,0),X>=Q&&(W.status==="paid"||W.status==="scheduled")}).length;return{todayCount:U.length,todayRevenue:q,filteredCount:I.length,filteredRevenue:H,totalCount:n.length,upcomingCount:G}},[n,I]),L=async T=>{const U={is_booked:!1,booking_id:null,booking_reference:null,stylist_id:null,updated_at:new Date().toISOString()};T.slot_id?await O.from("z_salon_slots").update(U).eq("id",T.slot_id):T.booking_reference&&await O.from("z_salon_slots").update(U).eq("booking_reference",T.booking_reference);const q=T.campus;q&&T.preferred_date&&T.preferred_time&&O.functions.invoke("notify-salon-waitlist",{body:{campus:q,slot_date:T.preferred_date,slot_time:T.preferred_time,appOrigin:window.location.origin}}).catch(()=>{})},V=async(T,U="cancelled")=>{O.functions.invoke("send-salon-cancellation",{body:{kind:U,bookingReference:T.booking_reference,clientName:T.client_name,clientEmail:T.client_email,serviceName:T.service_name,preferredDate:T.preferred_date,preferredTime:T.preferred_time,campus:T.campus}}).catch(()=>{})},B=async T=>{if(!g)return;f(!0),S(null);const{error:U}=await O.from("z_salon_bookings").update({status:T,updated_at:new Date().toISOString()}).eq("id",g.id);if(f(!1),U){S({type:"error",text:`Failed: ${U.message}`});return}T==="cancelled"?(await L(g),V(g,"cancelled"),S({type:"success",text:"Booking cancelled â slot released & client emailed."})):S({type:"success",text:`Marked as ${T.replace("_"," ")}`}),N({...g,status:T}),P()},A=async()=>{if(!g||!g.famouspay_payment_intent_id){S({type:"error",text:"No FamousPay payment intent on this booking"});return}f(!0),S(null);try{const{data:T,error:U}=await O.functions.invoke("create-refund",{body:{payment_intent:g.famouspay_payment_intent_id,reason:"requested_by_customer",metadata:{booking_id:g.id,booking_reference:g.booking_reference,client_name:g.client_name,refund_reason:C||"Salon booking refund"}}});await O.from("z_salon_bookings").update({status:"refunded",updated_at:new Date().toISOString()}).eq("id",g.id),await L(g),S({type:"success",text:`Refund of $${(g.service_price_cents/100).toFixed(2)} processed via FamousPay`}),N({...g,status:"refunded"}),_(!1),E(""),P()}catch(T){S({type:"error",text:T.message||"Refund failed"})}finally{f(!1)}},z=async()=>{if(g){f(!0),S(null);try{const{data:T,error:U}=await O.functions.invoke("send-salon-booking-confirmation",{body:{booking_reference:g.booking_reference,client_name:g.client_name,client_email:g.client_email,client_phone:g.client_phone,service_name:g.service_name,service_category:g.service_category,service_duration:g.service_duration,service_price_cents:g.service_price_cents,preferred_date:g.preferred_date,preferred_time:g.preferred_time,notes:g.notes}});if(U)throw new Error(U.message);if(T!=null&&T.error)throw new Error(T.error);await O.from("z_salon_bookings").update({confirmation_email_sent:!0,updated_at:new Date().toISOString()}).eq("id",g.id),S({type:"success",text:`Confirmation email re-sent to ${g.client_email}`}),N({...g,confirmation_email_sent:!0}),P()}catch(T){S({type:"error",text:T.message||"Failed to resend email"})}finally{f(!1)}}},M=()=>{const T=["Booking Reference","Status","Client Name","Email","Phone","Service","Category","Duration (min)","Price","Preferred Date","Preferred Time","Notes","Constitution Accepted","Email Sent","FamousPay Payment Intent","Created At"],U=I.map(Q=>{var K;return[Q.booking_reference,Q.status,Q.client_name,Q.client_email,Q.client_phone||"",Q.service_name,Q.service_category||"",((K=Q.service_duration)==null?void 0:K.toString())||"",`$${(Q.service_price_cents/100).toFixed(2)}`,Q.preferred_date||"",Q.preferred_time||"",(Q.notes||"").replace(/"/g,'""').replace(/\n/g," "),Q.constitution_accepted?"Yes":"No",Q.confirmation_email_sent?"Yes":"No",Q.famouspay_payment_intent_id||"",new Date(Q.created_at).toISOString()]}),q=[T,...U].map(Q=>Q.map(K=>`"${String(K).replace(/"/g,'""')}"`).join(",")).join(` 1242`),H=new Blob([q],{type:"text/csv;charset=utf-8;"}),G=URL.createObjectURL(H),W=document.createElement("a");W.href=G;const X=new Date().toISOString().split("T")[0];W.download=`zorganics-salon-bookings-${X}.csv`,W.click(),URL.revokeObjectURL(G)},R=()=>{N(null),_(!1),E(""),S(null)};return e.jsxs("div",{className:"min-h-screen bg-gradient-to-br from-stone-50 via-white to-rose-50/30",children:[e.jsxs("div",{className:"bg-gradient-to-r from-burgundy via-burgundy-dark to-burgundy text-white border-b border-burgundy-dark/40",children:[e.jsx("div",{className:"max-w-7xl mx-auto px-6 py-6",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsxs(be,{to:"/",className:"inline-flex items-center gap-2 text-white/70 hover:text-white text-xs mb-2 transition-colors",children:[e.jsx(Je,{size:14})," Back to Site"]}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"w-10 h-10 rounded-xl bg-white/15 backdrop-blur-sm border border-white/20 flex items-center justify-center font-display font-bold",children:"Z"}),e.jsxs("div",{children:[e.jsx("h1",{className:"font-display text-2xl font-bold tracking-tight",children:"Salon Booking Operations"}),e.jsx("p",{className:"text-xs text-white/60 mt-0.5 tracking-wider up
1242percase",children:"Zora's Styling Salon · Admin Panel"})]})]})]}),t==="bookings"&&e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsxs("button",{onClick:M,className:"inline-flex items-center gap-2 px-4 py-2 bg-white/10 hover:bg-white/20 backdrop-blur-sm border border-white/20 rounded-lg text-sm font-semibold transition-colors",children:[e.jsx(us,{size:14})," Export CSV"]}),e.jsxs("button",{onClick:P,className:"inline-flex items-center gap-2 px-4 py-2 bg-white text-burgundy hover:bg-stone-100 rounded-lg text-sm font-semibold transition-colors",children:[e.jsx(Be,{size:14})," Refresh"]})]})]})}),e.jsx("div",{className:"max-w-7xl mx-auto px-6",children:e.jsx("div",{className:"flex items-center gap-1",children:[{id:"bookings",label:"Bookings",icon:e.jsx(At,{size:14})},{id:"waitlist",label:"Waitlist",icon:e.jsx(Di,{size:14})},{id:"menu",label:"Edit Service Menu",icon:e.jsx(Ss,{size:14})},{id:"slots",label:"Slot Manager",icon:e.jsx(zO,{size:14})}].map(T=>e.jsxs("button",{onClick:()=>s(T.id),className:`inline-flex items-center gap-2 px-4 py-2.5 text-sm font-semibold rounded-t-lg transition-colors ${t===T.id?"bg-gradient-to-br from-stone-50 to-white text-burgundy":"text-white/70 hover:text-white hover:bg-white/10"}`,children:[T.icon," ",T.label]},T.id))})})]}),t==="menu"&&e.jsx("div",{className:"max-w-7xl mx-auto px-6 py-8",children:e.jsx(Aee,{})}),t==="slots"&&e.jsx("div",{className:"max-w-7xl mx-auto px-6 py-8",children:e.jsx(Tee,{})}),t==="waitlist"&&e.jsx("div",{className:"max-w-7xl mx-auto px-6 py-8",children:e.jsx(Dee,{})}),t==="bookings"&&e.jsxs("div",{className:"max-w-7xl mx-auto px-6 py-8",children:[e.jsxs("div",{className:"grid grid-cols-2 lg:grid-cols-4 gap-4 mb-8",children:[e.jsxs("div",{className:"bg-white rounded-xl border border-stone-200/70 p-5 shadow-sm",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[e.jsx("div",{className:"w-8 h-8 rounded-lg bg-emerald-50 flex items-center justify-center",children:e.jsx(Ro,{size:16,className:"text-emerald-600"})}),e.jsx("span",{className:"text-xs text-gray-400 uppercase tracking-wider font-semibold",children:"Today's Revenue"})]}),e.jsxs("p",{className:"font-mono text-2xl font-bold text-gray-900",children:["$",D.todayRevenue.toFixed(2)]}),e.jsxs("p",{className:"text-xs text-gray-400 mt-1",children:[D.todayCount," bookings today"]})]}),e.jsxs("div",{className:"bg-white rounded-xl border border-stone-200/70 p-5 shadow-sm",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[e.jsx("div",{className:"w-8 h-8 rounded-lg bg-blue-50 flex items-center justify-center",children:e.jsx(At,{size:16,className:"text-blue-600"})}),e.jsx("span",{className:"text-xs text-gray-400 uppercase tracking-wider font-semibold",children:"Upcoming"})]}),e.jsx("p",{className:"font-mono text-2xl font-bold text-gray-900",children:D.upcomingCount}),e.jsx("p",{className:"text-xs text-gray-400 mt-1",children:"scheduled appointments"})]}),e.jsxs("div",{className:"bg-white rounded-xl border border-stone-200/70 p-5 shadow-sm",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[e.jsx("div",{className:"w-8 h-8 rounded-lg bg-burgundy/10 flex items-center justify-center",children:e.jsx(si,{size:16,className:"text-burgundy"})}),e.jsx("span",{className:"text-xs text-gray-400 uppercase tracking-wider font-semibold",children:"Filtered Revenue"})]}),e.jsxs("p",{className:"font-mono text-2xl font-bold text-burgundy",children:["$",D.filteredRevenue.toFixed(2)]}),e.jsxs("p",{className:"text-xs text-gray-400 mt-1",children:[D.filteredCount," bookings"]})]}),e.jsxs("div",{className:"bg-white rounded-xl border border-stone-200/70 p-5 shadow-sm",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[e.jsx("div",{className:"w-8 h-8 rounded-lg bg-gold/10 flex items-center justify-center",children:e.jsx(ts,{size:16,className:"text-gold-dark"})}),e.jsx("span",{className:"text-xs text-gray-400 uppercase tracking-wider font-semibold",children:"All Time"})]}),e.jsx("p",{className:"font-mono text-2xl font-bold text-gray-900",children:D.totalCount}),e.jsx("p",{className:"text-xs text-gray-400 mt-1",children:"total bookings"})]})]}),e.jsxs("div",{className:"bg-white rounded-xl border border-stone-200/70 shadow-sm p-5 mb-6",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-3 mb-4",children:[e.jsx(ei,{size:16,className:"text-gray-400"}),e.jsx("span",{className:"text-xs font-semibold text-gray-500 uppercase tracking-wider mr-1",children:"Status"}),["all","paid","scheduled","completed","cancelled","refunded","no_show"].map(T=>{var H;const U=o===T,q=T==="all"?n.length:n.filter(G=>G.status===T).length;return e.jsxs("button",{onClick:()=>l(T),className:`px-3 py-1.5 rounded-full text-xs font-semibold transition-all ${U?"bg-burgundy text-white shadow-sm":"bg-stone-100 text-gray-600 hover:bg-stone-200"}`,children:[T==="all"?"All":((H=tN[T])==null?void 0:H.label)||T,e.jsx("span",{className:`ml-1.5 ${U?"text-white/70":"text-gray-400"}`,children:q})]},T)})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-3 pt-3 border-t border-stone-100",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(sf,{size:14,className:"text-gray-400"}),e.jsx("select",{value:c,onChange:T=>u(T.target.value),className:"px-3 py-1.5 border border-stone-200 rounded-lg text-xs font-semibold text-gray-700 focus:outline-none focus:ring-2 focus:ring-burgundy/30",children:F.map(T=>e.jsx("option",{value:T,children:T==="all"?"All Categories":T},T))})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(At,{size:14,className:"text-gray-400"}),e.jsx("input",{type:"date",value:p,onChange:T=>m(T.target.value),className:"px-3 py-1.5 border border-stone-200 rounded-lg text-xs text-gray-700 focus:outline-none focus:ring-2 focus:ring-burgundy/30"}),e.jsx("span",{className:"text-xs text-gray-400",children:"to"}),e.jsx("input",{type:"date",value:x,onChange:T=>h(T.target.value),className:"px-3 py-1.5 border border-stone-200 rounded-lg text-xs text-gray-700 focus:outline-none focus:ring-2 focus:ring-burgundy/30"})]}),e.jsxs("div",{className:"flex-1 min-w-[200px] relative",children:[e.jsx(Bt,{size:14,className:"absolute left-3 top-1/2 -translate-y-1/2 text-gray-400"}),e.jsx("input",{type:"text",value:y,onChange:T=>v(T.target.value),placeholder:"Search by name, email, or booking reference...",className:"w-full pl-9 pr-4 py-1.5 border border-stone-200 rounded-lg text-xs text-gray-700 focus:outline-none focus:ring-2 focus:ring-burgundy/30"})]}),(o!=="all"||c!=="all"||p||x||y)&&e.jsxs("button",{onClick:()=>{l("all"),u("all"),m(""),h(""),v("")},className:"text-xs text-burgundy hover:text-burgundy-dark font-semibold flex items-center gap-1",children:[e.jsx(Ke,{size:12})," Clear"]})]})]}),e.jsx("div",{className:"bg-white rounded-xl border border-stone-200/70 shadow-sm overflow-hidden",children:r?e.jsxs("div",{className:"p-16 text-center",children:[e.jsx(de,{size:28,className:"mx-auto text-burgundy animate-spin"}),e.jsx("p",{className:"text-sm text-gray-400 mt-3",children:"Loading bookings..."})]}):I.length===0?e.jsxs("div",{className:"p-16 text-center",children:[e.jsx(At,{size:32,className:"mx-auto text-stone-300 mb-3"}),e.jsx("p",{className:"text-sm text-gray-500 font-medium",children:"No bookings match your filters"}),e.jsx("p",{className:"text-xs text-gray-400 mt-1",children:"Try adjusting the filter criteria above"})]}):e.jsx("div",{className:"overflow-x-auto",children:e.jsxs("table",{className:"w-full",children:[e.jsx("thead",{children:e.jsxs("tr",{className:"border-b border-stone-100 bg-stone-50/50",children:[e.jsx("th",{className:"text-left px-5 py-3 text-xs font-semibold text-gray-500 uppercase tracking-wider",children:"Reference"}),e.jsx("th",{className:"text-left px-3 py-3 text-xs font-semibold text-gray-500 uppercase tracking-wider",children:"Client"}),e.jsx("th",{className:"text-left px-3 py-3 text-xs font-semibold text-gray-500 uppercase tracking-wider",children:"Service"}),e.jsx("th",{className:"text-left px-3 py-3 text-xs font-semibold text-gray-500 uppercase tracking-wider",children:"Preferred"}),e.jsx("th",{className:"text-right px-3 py-3 text-xs font-semibold text-gray-500 uppercase tracking-wider",children:"Amount"}),e.jsx("th",{className:"text-center px-3 py-3 text-xs font-semibold text-gray-500 uppercase tracking-wider",children:"Status"}),e.jsx("th",{className:"text-right px-5 py-3 text-xs font-semibold text-gray-500 uppercase tracking-wider"})]})}),e.jsx("tbody",{className:"divide-y divide-stone-50",children:I.map(T=>e.jsxs("tr",{onClick:()=>N(T),className:"hover:bg-rose-50/30 cursor-pointer transition-colors",children:[e.jsxs("td",{className:"px-5 py-4",children:[e.jsx("p",{className:"font-mono text-xs font-bold text-burgundy",children:T.booking_reference}),e.jsx("p",{className:"text-[10px] text-gray-400 mt-0.5",children:new Date(T.created_at).toLocaleDateString()})]}),e.jsxs("td",{className:"px-3 py-4",children:[e.jsx("p",{className:"text-sm font-semibold text-gray-900",children:T.client_name}),e.jsx("p",{className:"text-xs text-gray-400",children:T.client_email})]}),e.jsxs("td",{className:"px-3 py-4",children:[e.jsx("p",{className:"text-sm text-gray-900",children:T.service_name}),T.service_category&&e.jsxs("p",{className:"text-[10px] text-gray-400 mt-0.5",children:[T.service_category," · ",T.service_duration,"min"]})]}),e.jsx("td",{className:"px-3 py-4",children:T.preferred_date?e.jsxs(e.Fragment,{children:[e.jsx("p",{className:"text-sm text-gray-700",children:new Date(T.preferred_date).toLocaleDateString()}),T.preferred_time&&e.jsx("p",{className:"text-xs text-gray-400",children:T.preferred_time})]}):e.jsx("span",{className:"text-xs text-gray-300",children:"â"})}),e.jsx("td",{className:"px-3 py-4 text-right",children:e.jsxs("p",{className:`font-mono text-sm font-bold ${T.status==="refunded"?"text-gray-400 line-through":"text-gray-900"}`,children:["$",(T.service_price_cents/100).toFixed(2)]})}),e.jsx("td",{className:"px-3 py-4 text-center",children:e.jsx(sE,{status:T.status})}),e.jsx("td",{className:"px-5 py-4 text-right",children:e.jsx(Nr,{size:16,className:"text-gray-300 inline"})})]},T.id))})]})})})]}),g&&e.jsxs("div",{className:"fixed inset-0 z-50 flex justify-end",children:[e.jsx("div",{className:"absolute inset-0 bg-black/30 backdrop-blur-sm",onClick:()=>!b&&R()}),e.jsxs("div",{className:"relative w-full max-w-xl bg-white shadow-2xl overflow-y-auto",children:[e.jsxs("div",{className:"bg-gradient-to-br from-burgundy via-burgundy-dark to-burgundy text-white p-6 sticky top-0 z-10",children:[e.jsxs("div",{className:"flex items-start justify-between mb-4",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-[10px] uppercase tracking-[0.2em] text-white/60 mb-1",children:"Booking Reference"}),e.jsx("p",{className:"font-mono text-xl font-bold",children:g.booking_reference})]}),e.jsx("button",{onClick:R,disabled:b,className:"p-2 hover:bg-white/10 rounded-lg transition-colors disabled:opacity-50",children:e.jsx(Ke,{size:18})})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(sE,{status:g.status}),e.jsxs("p",{className:"font-mono text-2xl font-bold",children:["$",(g.service_price_cents/100).toFixed(2)]})]})]}),e.jsxs("div",{className:"p-6 space-y-6",children:[j&&e.jsx("div",{className:`rounded-lg p-3 border ${j.type==="success"?"bg-emerald-50 border-emerald-200 text-emerald-800":"bg-red-50 border-red-200 text-red-800"}`,children:e.jsxs("div",{className:"flex items-start gap-2",children:[j.type==="success"?e.jsx(pt,{size:14,className:"mt-0.5 flex-shrink-0"}):e.jsx(kt,{size:14,className:"mt-0.5 flex-shrink-0"}),e.jsx("p",{className:"text-xs font-medium",children:j.text})]})}),e.jsxs("div",{children:[e.jsxs("h3",{className:"text-xs font-semibold text-gray-400 uppercase tracking-wider mb-3 flex items-center gap-2",children:[e.jsx(ts,{size:12})," Client"]}),e.jsxs("div",{className:"space-y-2 bg-stone-50/50 rounded-lg p-4",children:[e.jsx("p",{className:"text-sm font-bold text-gray-900",children:g.client_name}),e.jsxs("div",{className:"flex items-center gap-2 text-sm text-gray-600",children:[e.jsx(Ye,{size:12,className:"text-gray-400"})," ",g.client_email]}),g.client_phone&&e.jsxs("div",{className:"flex items-center gap-2 text-sm text-gray-600",children:[e.jsx(Qt,{size:12,className:"text-gray-400"})," ",g.client_phone]})]})]}),e.jsxs("div",{children:[e.jsxs("h3",{className:"text-xs font-semibold text-gray-400 uppercase tracking-wider mb-3 flex items-center gap-2",children:[e.jsx(Qe,{size:12})," Service"]}),e.jsxs("div",{className:"space-y-3 bg-stone-50/50 rounded-lg p-4",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-bold text-gray-900",children:g.service_name}),g.service_category&&e.jsx("p",{className:"text-xs text-gray-500 mt-0.5",children:g.service_category})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-3 text-xs",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-gray-400",children:"Duration"}),e.jsx("p",{className:"font-semibold text-gray-700",children:g.service_duration?`${g.service_duration} min`:"â"})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-gray-400",children:"Price"}),e.jsxs("p",{className:"font-mono font-bold text-burgundy",children:["$",(g.service_price_cents/100).toFixed(2)]})]})]})]})]}),e.jsxs("div",{children:[e.jsxs("h3",{className:"text-xs font-semibold text-gray-400 uppercase tracking-wider mb-3 flex items-center gap-2",children:[e.jsx(At,{size:12})," Preferred Schedule"]}),e.jsxs("div",{className:"bg-stone-50/50 rounded-lg p-4 grid grid-cols-2 gap-3",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-xs text-gray-400",children:"Date"}),e.jsx("p",{className:"text-sm font-semibold text-gray-700",children:g.preferred_date?new Date(g.preferred_date).toLocaleDateString(void 0,{weekday:"short",month:"short",day:"numeric",year:"numeric"}):"â"})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-xs text-gray-400",children:"Time"}),e.jsx("p",{className:"text-sm font-semibold text-gray-700",children:g.preferred_time||"â"})]})]})]}),g.notes&&e.jsxs("div",{children:[e.jsxs("h3",{className:"text-xs font-semibold text-gray-400 uppercase tracking-wider mb-3 flex items-center gap-2",children:[e.jsx(Kt,{size:12})," Notes"]}),e.jsx("p",{className:"text-sm text-gray-700 bg-stone-50/50 rounded-lg p-4 whitespace-pre-wrap",children:g.notes})]}),e.jsxs("div",{children:[e.jsxs("h3",{className:"text-xs font-semibold text-gray-400 uppercase tracking-wider mb-3 flex items-center gap-2",children:[e.jsx(Tt,{size:12})," Payment & Audit"]}),e.jsxs("div",{className:"bg-stone-50/50 rounded-lg p-4 space-y-2 text-xs",children:[e.jsxs("div",{className:"flex justify-between",children:[e.jsx("span",{className:"text-gray-400",children:"Constitution Accepted"}),e.jsx("span",{className:g.constitution_accepted?"text-emerald-600 font-semibold":"text-red-500 font-semibold",children:g.constitution_accepted?"Yes":"No"})]}),e.jsxs("div",{className:"flex justify-between",children:[e.jsx("span",{className:"text-gray-400",children:"Confirmation Email"}),e.jsx("span",{className:g.confirmation_email_sent?"text-emerald-600 font-semibold":"text-amber-600 font-semibold",children:g.confirmation_email_sent?"Sent":"Not sent"})]}),e.jsxs("div",{className:"flex justify-between",children:[e.jsx("span",{className:"text-gray-400",children:"FamousPay PI"}),e.jsx("span",{className:"font-mono text-[10px] text-gray-600",children:g.famouspay_payment_intent_id?`${g.famouspay_payment_intent_id.slice(0,24)}...`:"â"})]}),e.jsxs("div",{className:"flex justify-between",children:[e.jsx("span",{className:"text-gray-400",children:"Created"}),e.jsx("span",{className:"text-gray-600",children:new Date(g.created_at).toLocaleStr
1242ing()})]})]})]}),w&&e.jsxs("div",{className:"bg-red-50 border border-red-200 rounded-lg p-4",children:[e.jsxs("div",{className:"flex items-start gap-2 mb-3",children:[e.jsx(ve,{size:16,className:"text-red-600 flex-shrink-0 mt-0.5"}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-bold text-red-900",children:"Confirm Refund"}),e.jsxs("p",{className:"text-xs text-red-700 mt-1",children:["$",(g.service_price_cents/100).toFixed(2)," will be returned to the client's card via FamousPay. This cannot be undone."]})]})]}),e.jsx("textarea",{value:C,onChange:T=>E(T.target.value),placeholder:"Reason for refund (optional)...",rows:2,className:"w-full px-3 py-2 border border-red-200 rounded-lg text-xs focus:outline-none focus:ring-2 focus:ring-red-300 resize-none mb-3"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx("button",{onClick:()=>{_(!1),E("")},disabled:b,className:"flex-1 py-2 border border-gray-200 text-gray-700 rounded-lg text-xs font-semibold hover:bg-gray-50 disabled:opacity-50",children:"Cancel"}),e.jsxs("button",{onClick:A,disabled:b,className:"flex-1 py-2 bg-red-600 hover:bg-red-700 text-white rounded-lg text-xs font-bold disabled:opacity-50 flex items-center justify-center gap-1.5",children:[b?e.jsx(de,{size:12,className:"animate-spin"}):e.jsx(zi,{size:12}),"Confirm Refund"]})]})]}),!w&&e.jsxs("div",{children:[e.jsx("h3",{className:"text-xs font-semibold text-gray-400 uppercase tracking-wider mb-3",children:"Actions"}),e.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[e.jsxs("button",{onClick:()=>B("completed"),disabled:b||g.status==="completed"||g.status==="refunded",className:"flex items-center justify-center gap-2 px-3 py-2.5 bg-purple-50 hover:bg-purple-100 text-purple-700 border border-purple-200 rounded-lg text-xs font-semibold transition-colors disabled:opacity-40 disabled:cursor-not-allowed",children:[e.jsx(Qe,{size:12})," Mark Completed"]}),e.jsxs("button",{onClick:()=>B("no_show"),disabled:b||g.status==="no_show"||g.status==="refunded",className:"flex items-center justify-center gap-2 px-3 py-2.5 bg-amber-50 hover:bg-amber-100 text-amber-700 border border-amber-200 rounded-lg text-xs font-semibold transition-colors disabled:opacity-40 disabled:cursor-not-allowed",children:[e.jsx(ve,{size:12})," Mark No-Show"]}),e.jsxs("button",{onClick:z,disabled:b,className:"flex items-center justify-center gap-2 px-3 py-2.5 bg-blue-50 hover:bg-blue-100 text-blue-700 border border-blue-200 rounded-lg text-xs font-semibold transition-colors disabled:opacity-40",children:[b?e.jsx(de,{size:12,className:"animate-spin"}):e.jsx(Ye,{size:12}),"Resend Email"]}),e.jsxs("button",{onClick:()=>B("cancelled"),disabled:b||g.status==="cancelled"||g.status==="refunded",className:"flex items-center justify-center gap-2 px-3 py-2.5 bg-gray-50 hover:bg-gray-100 text-gray-700 border border-gray-200 rounded-lg text-xs font-semibold transition-colors disabled:opacity-40 disabled:cursor-not-allowed",children:[e.jsx(Ke,{size:12})," Cancel & Notify"]}),e.jsxs("button",{onClick:()=>_(!0),disabled:b||g.status==="refunded"||!g.famouspay_payment_intent_id,className:"flex items-center justify-center gap-2 px-3 py-2.5 bg-red-50 hover:bg-red-100 text-red-700 border border-red-200 rounded-lg text-xs font-semibold transition-colors disabled:opacity-40 disabled:cursor-not-allowed",children:[e.jsx(zi,{size:12})," Issue Refund"]})]}),g.status==="refunded"&&e.jsx("p",{className:"text-[10px] text-gray-400 mt-2 text-center italic",children:"This booking has already been refunded"}),!g.famouspay_payment_intent_id&&e.jsx("p",{className:"text-[10px] text-amber-600 mt-2 text-center italic",children:"No payment intent â refund unavailable"})]})]})]})]})]})},nE=({data:t,height:s=200,maxValue:n,showValues:a=!0,valueFormatter:r=c=>c.toFixed(1),onBarClick:i,selectedIndex:o,emptyMessage:l="No data available"})=>{if(!t.length)return e.jsx("div",{className:"flex items-center justify-center text-gray-400 text-sm",style:{height:s},children:l});const c=n||Math.max(...t.map(x=>x.value),1),u=Math.min(60,Math.max(20,600/t.length-12)),p=t.length*(u+12)+40,m=s-40;return e.jsx("div",{className:"w-full overflow-x-auto",children:e.jsxs("svg",{width:Math.max(p,300),height:s,className:"mx-auto",children:[[0,.25,.5,.75,1].map((x,h)=>e.jsxs("g",{children:[e.jsx("line",{x1:"35",y1:10+m*(1-x),x2:p-5,y2:10+m*(1-x),stroke:"#f0f0f0",strokeWidth:"1"}),e.jsx("text",{x:"30",y:14+m*(1-x),textAnchor:"end",className:"fill-gray-400",fontSize:"9",fontFamily:"monospace",children:r(c*x)})]},h)),t.map((x,h)=>{const y=Math.max(2,x.value/c*m),v=40+h*(u+12),g=10+m-y,N=o===h,b=x.color||"#6366F1";return e.jsxs("g",{onClick:()=>i==null?void 0:i(x,h),className:i?"cursor-pointer":"",children:[e.jsx("rect",{x:v,y:g,width:u,height:y,rx:"4",ry:"4",fill:b,opacity:o!=null&&!N?.35:.85,className:"transition-all duration-200 hover:opacity-100"}),N&&e.jsx("rect",{x:v-2,y:g-2,width:u+4,height:y+4,rx:"5",ry:"5",fill:"none",stroke:b,strokeWidth:"2",strokeDasharray:"4 2"}),a&&x.value>0&&e.jsx("text",{x:v+u/2,y:g-5,textAnchor:"middle",className:"fill-gray-700",fontSize:"10",fontWeight:"600",fontFamily:"monospace",children:r(x.value)}),x.count!=null&&e.jsxs("text",{x:v+u/2,y:g-16,textAnchor:"middle",className:"fill-gray-400",fontSize:"8",children:["n=",x.count]}),e.jsx("text",{x:v+u/2,y:s-8,textAnchor:"middle",className:"fill-gray-600",fontSize:"9",fontWeight:"500",children:x.label.length>10?x.label.slice(0,9)+"â¦":x.label})]},h)})]})})},aE=({data:t,maxValue:s,valueFormatter:n=l=>l.toFixed(1)+"%",onBarClick:a,selectedIndex:r,barHeight:i=32,showRank:o=!1})=>{if(!t.length)return e.jsx("div",{className:"text-gray-400 text-sm text-center py-8",children:"No data available"});const l=s||Math.max(...t.map(c=>c.value),1);return e.jsx("div",{className:"space-y-2",children:t.map((c,u)=>{const p=c.value/l*100,m=r===u,x=c.color||(c.value>=90?"#059669":c.value>=80?"#2563EB":c.value>=70?"#D97706":c.value>=60?"#EA580C":"#DC2626");return e.jsx("div",{onClick:()=>a==null?void 0:a(c,u),className:`group relative rounded-lg transition-all ${a?"cursor-pointer hover:bg-gray-50":""} ${m?"ring-2 ring-indigo-400 bg-indigo-50/50":""}`,children:e.jsxs("div",{className:"flex items-center gap-3 px-3",style:{height:i},children:[o&&e.jsxs("span",{className:`w-6 text-center font-mono text-xs font-bold shrink-0 ${u<3?"text-amber-600":"text-gray-400"}`,children:["#",u+1]}),e.jsx("span",{className:"text-xs font-medium text-gray-800 w-36 truncate shrink-0",title:c.label,children:c.label}),e.jsx("div",{className:"flex-1 h-5 bg-gray-100 rounded-full overflow-hidden relative",children:e.jsx("div",{className:"h-full rounded-full transition-all duration-500",style:{width:`${Math.max(2,p)}%`,backgroundColor:x,opacity:r!=null&&!m?.35:.85}})}),e.jsx("span",{className:"font-mono text-xs font-bold w-16 text-right shrink-0",style:{color:x},children:n(c.value)}),c.count!=null&&e.jsxs("span",{className:"text-[10px] text-gray-400 font-mono w-10 text-right shrink-0",children:["n=",c.count]})]})},u)})})},sxe=({series:t,height:s=220,maxValue:n,minValue:a,valueFormatter:r=c=>c.toFixed(1),showDots:i=!0,showArea:o=!0,onPointClick:l})=>
1242{if(!t.length||!t[0].data.length)return e.jsx("div",{className:"flex items-center justify-center text-gray-400 text-sm",style:{height:s},children:"No trend data available"});const c=t.flatMap(j=>j.data.map(S=>S.value)),u=n??Math.max(...c,1),p=a??Math.min(...c,0),m=u-p||1,x=t[0].data.map(j=>j.label),h=Math.max(x.length*80+80,400),y=s-50,v=45,g=15,N=h-v-g,b=j=>v+j/Math.max(x.length-1,1)*N,f=j=>15+y-(j-p)/m*y;return e.jsxs("div",{className:"w-full overflow-x-auto",children:[e.jsxs("svg",{width:h,height:s,className:"mx-auto",children:[[0,.25,.5,.75,1].map((j,S)=>{const w=p+m*j,_=f(w);return e.jsxs("g",{children:[e.jsx("line",{x1:v,y1:_,x2:h-g,y2:_,stroke:"#f0f0f0",strokeWidth:"1"}),e.jsx("text",{x:v-5,y:_+3,textAnchor:"end",className:"fill-gray-400",fontSize:"9",fontFamily:"monospace",children:r(w)})]},S)}),x.map((j,S)=>e.jsx("text",{x:b(S),y:s-5,textAnchor:"middle",className:"fill-gray-500",fontSize:"9",fontWeight:"500",children:j.length>8?j.slice(0,7)+"â¦":j},S)),t.map((j,S)=>{const _=j.data.map((E,P)=>`${b(P)},${f(E.value)}`).map((E,P)=>`${P===0?"M":"L"}${E}`).join(" "),C=o?`${_} L${b(j.data.length-1)},${f(p)} L${b(0)},${f(p)} Z`:"";return e.jsxs("g",{children:[o&&e.jsx("path",{d:C,fill:j.color,opacity:"0.08"}),e.jsx("path",{d:_,fill:"none",stroke:j.color,strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round"}),i&&j.data.map((E,P)=>e.jsxs("g",{onClick:()=>l==null?void 0:l(j,E,P),className:l?"cursor-pointer":"",children:[e.jsx("circle",{cx:b(P),cy:f(E.value),r:"5",fill:"white",stroke:j.color,strokeWidth:"2.5",className:"transition-all hover:r-[7]"}),e.jsx("text",{x:b(P),y:f(E.value)-10,textAnchor:"middle",className:"fill-gray-600",fontSize:"9",fontWeight:"600",fontFamily:"monospace",children:r(E.value)})]},P))]},S)})]}),t.length>1&&e.jsx("div",{className:"flex items-center justify-center gap-4 mt-2",children:t.map((j,S)=>e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("div",{className:"w-3 h-3 rounded-full",style:{backgroundColor:j.color}}),e.jsx("span",{className:"text-[10px] font-medium text-gray-600",children:j.name})]},S))})]})},Iee=({segments:t,size:s=160,strokeWidth:n=24,centerLabel:a,centerValue:r})=>{const i=t.reduce((u,p)=>u+p.value,0);if(i===0)return e.jsx("div",{className:"flex items-center justify-center text-gray-400 text-sm",style:{width:s,height:s},children:"No data"});const o=(s-n)/2,l=2*Math.PI*o;let c=0;return e.jsxs("div",{className:"relative inline-flex items-center justify-center",style:{width:s,height:s},children:[e.jsx("svg",{width:s,height:s,className:"transform -rotate-90",children:t.map((u,p)=>{const x=u.value/i*l,h=-c;return c+=x,e.jsx("circle",{cx:s/2,cy:s/2,r:o,fill:"none",stroke:u.color,strokeWidth:n,strokeDasharray:`${x} ${l-x}`,strokeDashoffset:h,strokeLinecap:"round",className:"transition-all duration-500"},p)})}),(a||r)&&e.jsxs("div",{className:"absolute inset-0 flex flex-col items-center justify-center",children:[r&&e.jsx("span",{className:"font-mono text-xl font-bold text-gray-900",children:r}),a&&e.jsx("span",{className:"text-[10px] text-gray-500 font-medium",children:a})]})]})},og=({label:t,value:s,sublabel:n,icon:a,color:r,bgColor:i,trend:o,onClick:l})=>e.jsxs("div",{onClick:l,className:`p-4 rounded-xl border border-gray-100 bg-white hover:shadow-md transition-all ${l?"cursor-pointer hover:border-gray-200":""}`,children:[e.jsxs("div",{className:"flex items-start justify-between mb-2",children:[e.jsx("div",{className:`w-9 h-9 rounded-lg flex items-center justify-center ${i}`,children:e.jsx("span",{className:r,children:a})}),o&&e.jsxs("span",{className:`text-[10px] font-bold px-1.5 py-0.5 rounded-full ${o.value>=0?"bg-emerald-50 text-emerald-700":"bg-red-50 text-red-700"}`,children:[o.value>=0?"+":"",o.value.toFixed(1),"% ",o.label]})]}),e.jsx("p",{className:"font-mono text-2xl font-bold text-gray-900",children:s}),e.jsx("p",{className:"text-xs text-gray-500 mt-0.5",children:t}),n&&e.jsx("p",{className:"text-[10px] text-gray-400 mt-0.5",children:n})]}),Pa="#B8962E",Wv=t=>t.enrolled_at!=null,Hv=t=>["scheduled","completed","no-show"].includes(t.status)||!!t.scheduled_at,rE=t=>t.status==="completed";function $ee({rows:t}){var w;const s=d.useMemo(()=>{const _=t.length,C=t.filter(Hv).length,E=t.filter(rE).length,P=t.filter(Wv).length;return{submitted:_,scheduled:C,completed:E,enrolled:P}},[t]),n=d.useMemo(()=>{const _=t.filter(F=>F.scheduled_at&&F.created_at);return _.length===0?null:_.reduce((F,I)=>{const D=new Date(I.scheduled_at).getTime()-new Date(I.created_at).getTime();return F+Math.max(0,D)}
1242,0)/_.length/(1e3*60*60)},[t]),a=d.useMemo(()=>{const _=new Map;return t.forEach(C=>{if(!Hv(C))return;const E=C.campus_slug,P=_.get(E)||{campus:C.campus_name,scheduled:0,noShow:0};P.scheduled++,C.status==="no-show"&&P.noShow++,_.set(E,P)}),Array.from(_.values()).map(C=>({label:C.campus,value:C.scheduled>0?C.noShow/C.scheduled*100:0,count:C.scheduled,color:C.scheduled>0&&C.noShow/C.scheduled>.2?"#DC2626":"#F59E0B"})).sort((C,E)=>E.value-C.value)},[t]),r=d.useMemo(()=>{const _=new Map;return t.forEach(C=>{if(!C.assigned_advisor)return;const E=_.get(C.assigned_advisor)||{advisor:C.assigned_advisor,total:0,completed:0,enrolled:0};E.total++,rE(C)&&E.completed++,Wv(C)&&E.enrolled++,_.set(C.assigned_advisor,E)}),Array.from(_.values()).map(C=>({label:C.advisor.replace(/\s*\([^)]*\)/,""),value:C.completed>0?C.enrolled/C.completed*100:0,count:C.completed,sublabel:`${C.total} assigned · ${C.completed} completed · ${C.enrolled} enrolled`})).sort((C,E)=>(E.count||0)-(C.count||0)).slice(0,10)},[t]),i=d.useMemo(()=>{const _=new Array(24).fill(0);return t.forEach(C=>{const E=new Date(C.created_at).getHours();_[E]++}),_.map((C,E)=>({label:E===0?"12a":E<12?`${E}a`:E===12?"12p":`${E-12}p`,value:C,color:C>0?Pa:"#E5E7EB"}))},[t]),o=d.useMemo(()=>{const _=["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],C=new Array(7).fill(0);return t.forEach(E=>{const P=new Date(E.created_at).getDay();C[P]++}),C.map((E,P)=>({label:_[P],value:E,color:k}))},[t]),l=d.useMemo(()=>{const _=t.filter(Hv),C=_.filter(D=>D.sms_opt_in&&(D.sms_reminder_sent_at||D.day_of_sms_sent_at)),E=_.filter(D=>!D.sms_opt_in||!D.sms_reminder_sent_at&&!D.day_of_sms_sent_at),P=D=>{const L=D.filter(B=>B.status==="completed"||B.status==="no-show");return L.length===0?{rate:0,count:0}:{rate:L.filter(B=>B.status==="completed").length/L.length*100,count:L.length}},F=P(C),I=P(E);return{sms:F,email:I}},[t]),c=d.useMemo(()=>{const _={};t.forEach(E=>{_[E.status]=(_[E.status]||0)+1});const C={new:"#3B82F6",contacted:"#F59E0B",scheduled:"#10B981",completed:"#6B7280","no-show":"#DC2626",cancelled:"#9CA3AF"};return Object.entries(_).map(([E,P])=>({label:E,value:P,color:C[E]||"#999"}))},[t]),u=d.useMemo(()=>{const _=t.filter(Wv),C=_.length,E=se=>!se.enrollment_email_sent_at||se.enrollment_email_status==="failed",P=se=>!!se.enrollment_email_sent_at&&se.enrollment_email_status!=="failed"&&se.enrollment_email_status!=="bounced",F=_.filter(E),I=_.filter(se=>se.enrollment_email_status==="failed"),D=_.filter(se=>!se.enrollment_email_sent_at),L=_.filter(se=>!!se.enrollment_email_sent_at&&se.enrollment_email_status!=="failed"),V=Date.now()-30*60*1e3,B=F.filter(se=>se.enrolled_at?new Date(se.enrolled_at).getTime()<=V:!1),A=F.length-B.length,z=F.slice().sort((se,Y)=>new Date(se.enrolled_at).getTime()-new Date(Y.enrolled_at).getTime())[0]||null,M=z?(Date.now()-new Date(z.enrolled_at).getTime())/(1e3*60*60):null,R=_.reduce((se,Y)=>se+(Y.enrollment_email_open_count||0),0),T=_.reduce((se,Y)=>se+(Y.enrollment_email_click_count||0),0),U=_.filter(se=>!!se.enrollment_email_opened_at).length,q=_.filter(se=>!!se.enrollment_email_clicked_at).length,H=_.filter(P).length,G=H>0?U/H*100:0,W=H>0?q/H*100:0,X=new Map;_.forEach(se=>{const Y=se.campus_slug,J=X.get(Y)||{campus:se.campus_name||se.campus_slug,pending:0,failed:0,total:0,sent:0,uniqueOpened:0,uniqueClicked:0,totalOpens:0,totalClicks:0};J.total++,E(se)&&J.pending++,se.enrollment_email_status==="failed"&&J.failed++,P(se)&&J.sent++,se.enrollment_email_opened_at&&J.uniqueOpened++,se.enrollment_email_clicked_at&&J.uniqueClicked++,J.totalOpens+=se.enrollment_email_open_count||0,J.totalClicks+=se.enrollment_email_click_count||0,X.set(Y,J)});const Q=Array.from(X.values()).sort((se,Y)=>Y.pending-se.pending||Y.total-se.total),K=C>0?L.length/C*100:0;return{enrolledTotal:C,pending:F.length,failed:I.length,neverSent:D.length,sent:L.length,eligibleNow:B.length,inGrace:A,oldestPendingAgeHours:M,byCampus:Q,deliveryRate:K,successfullySent:H,uniqueOpened:U,uniqueClicked:q,totalOpens:R,totalClicks:T,openRate:G,clickRate:W}},[t]),[p,m]=cc(),x=p.get("cohort_campus")||"",h=_=>{const C=new URLSearchParams(p);_?C.set("cohort_campus",_):C.delete("cohort_campus"),m(C,{replace:!0})},y=d.useMemo(()=>{const _=new Map;return t.forEach(C=>{!C.enrolled_at||!C.campus_slug||_.has(C.campus_slug)||_.set(C.campus_slug,C.campus_name||C.campus_slug)}),Array.from(_.entries()).map(([C,E])=>({slug:C,name:E})).sort((C,E)=>C.name.localeCompare(E.name))},[t]),v=d.useMemo(()=>x&&y.some(_=>_.slug===x)?x:"",[x,y]),g=v?((w=y.find(_=>_.slug===v))==null?void 0:w.name)||v:null,N=d.useMemo(()=>{const _=R=>{const T=new Date(R);T.setHours(0,0,0,0);const U=T.getDay(),q=U===0?-6:1-U;
1242return T.setDate(T.getDate()+q),T},C=R=>{const T=new Map;return R.forEach(U=>{if(U.enrolled_at==null)return;const q=new Date(U.enrolled_at);if(isNaN(q.getTime()))return;const H=_(q),G=new Date(H);G.setDate(G.getDate()+6);const W=H.toISOString().slice(0,10),X=T.get(W)||{weekStart:H,weekEnd:G,weekKey:W,cohortSize:0,sent:0,uniqueOpened:0,uniqueClicked:0,totalOpens:0,totalClicks:0,bounced:0,failed:0};X.cohortSize++,!!U.enrollment_email_sent_at&&U.enrollment_email_status!=="failed"&&U.enrollment_email_status!=="bounced"&&X.sent++,U.enrollment_email_opened_at&&X.uniqueOpened++,U.enrollment_email_clicked_at&&X.uniqueClicked++,(U.enrollment_email_status==="bounced"||U.enrollment_email_bounced_at)&&X.bounced++,U.enrollment_email_status==="failed"&&X.failed++,X.totalOpens+=U.enrollment_email_open_count||0,X.totalClicks+=U.enrollment_email_click_count||0,T.set(W,X)}),T},E=t.filter(R=>R.enrolled_at!=null&&!isNaN(new Date(R.enrolled_at).getTime()));if(E.length===0)return{weeks:[],hasData:!1,totalCohorts:0,flaggedWeeks:0,comparisonWeeks:null,filteredEnrolled:0,allEnrolled:0,campusCount:0};const P=v?E.filter(R=>R.campus_slug===v):E;if(P.length===0)return{weeks:[],hasData:!1,totalCohorts:0,flaggedWeeks:0,comparisonWeeks:null,filteredEnrolled:0,allEnrolled:E.length,campusCount:y.length};const F=C(P),I=Array.from(F.values()).sort((R,T)=>R.weekStart.getTime()-T.weekStart.getTime()),D=I.slice(-12);let L=null,V=null;const B=D.map(R=>{const T=R.sent>0?R.uniqueOpened/R.sent*100:null,U=R.sent>0?R.uniqueClicked/R.sent*100:null,q=T!=null&&L!=null?T-L:null,H=U!=null&&V!=null?U-V:null,G=q!=null&&q<-15&&R.sent>=3,W={...R,openRate:T,clickRate:U,openRateDelta:q,clickRateDelta:H,flagSpamDrop:G};return T!=null&&(L=T),U!=null&&(V=U),W}),A=B.filter(R=>R.flagSpamDrop).length;let z=null;function M(){if(!v)return null;const R=C(E),T=Math.max(1,y.length);return B.map(U=>{const q=R.get(U.weekKey),H=q&&q.sent>0?q.uniqueOpened/q.sent*100:null,G=q&&q.sent>0?q.uniqueClicked/q.sent*100:null;return{weekKey:U.weekKey,openRate:H,clickRate:G,cohortSize:(q==null?void 0:q.cohortSize)||0,sent:(q==null?void 0:q.sent)||0,uniqueOpened:(q==null?void 0:q.uniqueOpened)||0,uniqueClicked:(q==null?void 0:q.uniqueClicked)||0,perCampusAvgCohortSize:((q==null?void 0:q.cohortSize)||0)/T}})}return z=M(),{weeks:B,hasData:B.length>0,totalCohorts:I.length,flaggedWeeks:A,comparisonWeeks:z,filteredEnrolled:P.length,allEnrolled:E.length,campusCount:y.length}},[t,v,y]),b=s.submitted>0?s.scheduled/s.submitted*100:0,f=s.scheduled>0?s.completed/s.scheduled*100:0,j=s.completed>0?s.enrolled/s.completed*100:0,S=s.submitted>0?s.enrolled/s.submitted*100:0;return t.length===0?e.jsxs("div",{className:"rounded-xl bg-white p-12 text-center",style:{border:`1px solid ${k}15`},children:[e.jsx(Ma,{size:36,className:"mx-auto mb-3",style:{color:Pa,opacity:.4}}),e.jsx("p",{className:"text-sm font-semibold",style:{color:k},children:"No tour data yet for analytics."}),e.jsx("p",{className:"text-xs mt-1 text-gray-500",children:"Charts will populate as visitors submit tour requests."})]}):e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-3",children:[e.jsx(og,{label:"Submit â Schedule",value:`${b.toFixed(1)}%`,sublabel:`${s.scheduled} of ${s.submitted}`,icon:e.jsx(At,{size:16}),color:"text-blue-700",bgColor:"bg-blue-50"}),e.jsx(og,{label:"Schedule â Complete",value:`${f.toFixed(1)}%`,sublabel:`${s.completed} of ${s.scheduled}`,icon:e.jsx(si,{size:16}),color:"text-emerald-700",bgColor:"bg-emerald-50"}),e.jsx(og,{label:"Complete â Enroll",value:`${j.toFixed(1)}%`,sublabel:`${s.enrolled} of ${s.completed}`,icon:e.jsx(Is,{size:16}),color:"text-amber-700",bgColor:"bg-amber-50"}),e.jsx(og,{label:"Avg Time-to-Schedule",value:n!=null?n>=24?`${(n/24).toFixed(1)}d`:`${n.toFixed(1)}h`:"â",sublabel:"Submit â Confirmed",icon:e.jsx(dt,{size:16}),color:"text-purple-700",bgColor:"bg-purple-50"})]}),e.jsx(Gi,{title:"Conversion Funnel",subtitle:`Overall enrollment rate: ${S.toFixed(1)}% · Enrolled count uses verified enrolled_at timestamps`,children:e.jsxs("div",{className:"space-y-2.5",children:[e.jsx(lg,{label:"Submitted",value:s.submitted,max:s.submitted,color:"#3B82F6"}),e.jsx(Gv,{value:`${b.toFixed(1)}%`}),e.jsx(lg,{label:"Scheduled",value:s.scheduled,max:s.submitted,color:"#10B981"}),e.jsx(Gv,{value:`${f.toFixed(1)}%`}),e.jsx(lg,{label:"Completed",value:s.completed,max:s.submitted,color:Pa}),e.jsx(Gv,{value:`${j.toFixed(1)}%`}),e.jsx(lg,{label:"Enrolled",value:s.enrolled,max:s.submitted,color:k})]})}),u.enrolledTotal>
12420&&e.jsx(Gi,{title:"Welcome Email Auto-Retry Queue",subtitle:u.pending===0?`All ${u.enrolledTotal} enrolled visitor${u.enrolledTotal===1?" has":"s have"} received their welcome email.`:`${u.pending} of ${u.enrolledTotal} enrolled row${u.enrolledTotal===1?"":"s"} awaiting welcome email · cron-enrollment-welcome-retries sweeps every hour`,children:u.pending===0?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"rounded-lg p-5 flex items-center gap-3",style:{background:"#ECFDF5",border:"1px solid #10B98133"},children:[e.jsx(Ue,{size:22,style:{color:"#059669",flexShrink:0}}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-bold",style:{color:"#065F46"},children:"Queue is clear â every enrolled visitor has been welcomed."}),e.jsxs("p",{className:"text-[11px] mt-0.5 text-emerald-700",children:["Delivery rate: ",u.deliveryRate.toFixed(1),"% · Sent: ",u.sent," · Failed (currently retrying): 0"]})]})]}),u.successfullySent>0&&e.jsx(oE,{rows:u.byCampus,totalOpenRate:u.openRate,totalClickRate:u.clickRate,totalOpens:u.totalOpens,totalClicks:u.totalClicks,uniqueOpened:u.uniqueOpened,uniqueClicked:u.uniqueClicked,successfullySent:u.successfullySent})]}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"grid grid-cols-2 sm:grid-cols-4 gap-3 mb-4",children:[e.jsx(cg,{label:"Total Pending",value:u.pending,sublabel:"Awaiting send",accent:k,bg:"#FFF8E5",border:`${$}55`,icon:e.jsx(LO,{size:16})}),e.jsx(cg,{label:"Eligible Now",value:u.eligibleNow,sublabel:"Cron will retry next sweep",accent:Pa,bg:"#FEF3C7",border:"#D4AF3755",icon:e.jsx(Be,{size:16})}),e.jsx(cg,{label:"In 30-min Grace",value:u.inGrace,sublabel:"Inline send still landing",accent:"#1E40AF",bg:"#DBEAFE",border:"#1E40AF33",icon:e.jsx(dt,{size:16})}),e.jsx(cg,{label:"Failed",value:u.failed,sublabel:"Prior attempt errored",accent:u.failed>0?"#991B1B":"#6B7280",bg:u.failed>0?"#FEE2E2":"#F3F4F6",border:u.failed>0?"#DC262633":"#E5E7EB",icon:e.jsx(ve,{size:16})})]}),u.byCampus.length>0&&e.jsx(oE,{rows:u.byCampus,totalOpenRate:u.openRate,totalClickRate:u.clickRate,totalOpens:u.totalOpens,totalClicks:u.totalClicks,uniqueOpened:u.uniqueOpened,uniqueClicked:u.uniqueClicked,successfullySent:u.successfullySent}),u.oldestPendingAgeHours!=null&&u.oldestPendingAgeHours>6&&e.jsxs("div",{className:"rounded-lg p-3 flex items-start gap-2.5 text-[12px] mt-3",style:{background:"#FEF2F2",border:"1px solid #DC262633",color:"#991B1B"},children:[e.jsx(ve,{size:14,style:{color:"#DC2626",flexShrink:0,marginTop:2}}),e.jsxs("span",{children:[e.jsx("strong",{children:"Stale row alert:"})," The oldest pending welcome email has been waiting for"," ",e.jsx("strong",{children:u.oldestPendingAgeHours>=24?`${(u.oldestPendingAgeHours/24).toFixed(1)} day${u.oldestPendingAgeHours>=48?"s":""}`:`${u.oldestPendingAgeHours.toFixed(1)} hours`}),'. The cron retries hourly â if this number keeps climbing, check the row in the Requests tab and use the "Resend Welcome" button manually.']})]}),e.jsxs("p",{className:"text-[11px] mt-3 text-gray-500 leading-relaxed",children:["The ",e.jsx("code",{className:"px-1 py-0.5 rounded bg-gray-100 font-mono text-[10px]",children:"cron-enrollment-welcome-retries"})," sweeper scans for enrolled rows where the welcome email is missing or marked failed, then re-invokes"," ",e.jsx("code",{className:"px-1 py-0.5 rounded bg-gray-100 font-mono text-[10px]",children:"send-enrollment-welcome"}),". The 30-minute grace window prevents racing the inline send fired from the Mark-as-Enrolled button. Engagement (opens / clicks) streams in from Mailgun via the"," ",e.jsx("code",{className:"px-1 py-0.5 rounded bg-gray-100 font-mono text-[10px]",children:"mailgun-webhook"})," handler and is logged per-event in the ",e.jsx("code",{className:"px-1 py-0.5 rounded bg-gray-100 font-mono text-[10px]",children:"enrollment_email_events"})," table. Per-row delivery state and the full event timeline are visible in the Detail Drawer."]})]})}),(N.hasData||N.allEnrolled>0)&&e.jsxs(Gi,{title:"Welcome Email Engagement Cohort Report",subtitle:N.hasData?g?`${g} only · ${N.filteredEnrolled} of ${N.allEnrolled} enrolled · ${N.flaggedWeeks>0?`${N.flaggedWeeks} cohort${N.flaggedWeeks===1?"":"s"} flagged · `:""}showing last ${N.weeks.length} of ${N.totalCohorts} weeks`:N.flaggedWeeks>0?`${N.flaggedWeeks} cohort${N.flaggedWeeks===1?"":"s"} flagged with > 15 pp open-rate drop · showing last ${N.weeks.length} of ${N.totalCohorts} weeks`:`Week-over-week open and click trends · showing last ${N.weeks.length} of ${N.totalCohorts} weeks`:g?`No enrollments for ${g} yet â change the filter to see cohort data.`:"Cohort data will appear here as enrolled visitors are welcomed.",children:[e.jsx(Oee,{campuses:y,selected:v,onChange:h,filteredCount:N.filteredEnrolled,totalCount:N.allEnrolled}),N.hasData?e.jsx(Lee,{weeks:N.weeks,flaggedWeeks:N.flaggedWeeks,comparisonWeeks:N.comparisonWeeks,selectedCampusName:g,campusCount:N.campusCount}):e.jsxs("div",{className:"rounded-lg p-6 text-center",style:{background:"#FAFAFA",border:"1px dashed #E5E7EB"},children:[e.jsx(Ws,{size:28,className:"mx-auto mb-2",style:{color:Pa,opacity:.4}}),e.jsx("p",{className:"text-sm font-semibold",style:{color:k},children:g?`No enrolled visitors yet for ${g}.`:"No enrolled visitors yet."}),g&&e.jsx("button",{type:"button",onClick:()=>h(""),className:"text-[11px] mt-2 underline hover:no-underline",style:{color:Pa},children:"Clear filter to see all campuses"})]})]}),e.jsxs("div",{className:"grid lg:grid-cols-2 gap-5",children:[e.jsx(Gi,{title:"No-Show Rate by Campus",subtitle:"% of scheduled tours where visitor did not arrive",children:e.jsx(aE,{data:a,valueFormatter:_=>`${_.toFixed(1)}%`,barHeight:36})}),e.jsx(Gi,{title:"Status Breakdown",subtitle:`${t.length} total requests across pipeline`,children:e.jsxs("div",{className:"flex items-center justify-center gap-6 py-2",children:[e.jsx(Iee,{segments:c,size:170,centerValue:String(t.length),centerLabel:"Requests"}),e.jsx("div",{className:"space-y-1.5",children:c.map(_=>e.jsxs("div",{className:"flex items-center gap-2 text-xs",children:[e.jsx("div",{className:"w-3 h-3 rounded-full",style:{background:_.color}}),e.jsx("span",{className:"font-semibold capitalize text-gray-800 w-20",children:_.label}),e.jsx("span",{className:"font-mono text-gray-500",children:_.value})]},_.label))})]})})]}),e.jsx(Gi,{title:"Advisor Performance Leaderboard",subtitle:"Ranked by tours completed · % shows enrollment conversion rate",children:r.length===0?e.jsx("p",{className:"text-sm text-gray-400 text-center py-8",children:"No advisors assigned yet. Assign advisors in the Requests tab to populate this leaderboard."}):e.jsxs(e.Fragment,{children:[e.jsx(aE,{data:r,valueFormatter:_=>`${_.toFixed(1)}%`,barHeight:38,showRank:!0}),e.jsx("div",{className:"mt-3 space-y-1 pt-3",style:{borderTop:`1px solid ${k}10`},children:r.slice(0,5).map((_,C)=>e.jsxs("div",{className:"text-[11px] text-gray-500 px-3",children:[e.jsxs("span",{className:"font-bold text-gray-700",children:["#",C+1," ",_.label,":"]}
1242)," ",_.sublabel]},C))})]})}),e.jsxs("div",{className:"grid lg:grid-cols-2 gap-5",children:[e.jsx(Gi,{title:"Peak Booking Hours",subtitle:"Submissions by hour-of-day (visitor local time)",children:e.jsx(nE,{data:i,height:180,valueFormatter:_=>_.toFixed(0),showValues:!1})}),e.jsx(Gi,{title:"Peak Booking Days",subtitle:"Submissions by day-of-week",children:e.jsx(nE,{data:o,height:180,valueFormatter:_=>_.toFixed(0)})})]}),e.jsxs(Gi,{title:"SMS Reminders vs Email-Only Show-Up Rate",subtitle:"Comparing reminder channels among visitors who reached completion or no-show",children:[e.jsxs("div",{className:"grid sm:grid-cols-2 gap-4",children:[e.jsx(iE,{icon:e.jsx(jr,{size:20}),channel:"SMS + Email",rate:l.sms.rate,sample:l.sms.count,accent:"#1E40AF",bg:"#DBEAFE"}),e.jsx(iE,{icon:e.jsx(Ye,{size:20}),channel:"Email Only",rate:l.email.rate,sample:l.email.count,accent:"#92400E",bg:"#FEF3C7"})]}),l.sms.count>0&&l.email.count>0&&e.jsxs("div",{className:"mt-4 rounded-lg p-3 flex items-start gap-2.5 text-[12px]",style:{background:"#FFF8E5",border:`1px solid ${$}55`,color:k},children:[e.jsx(si,{size:14,style:{color:Pa,flexShrink:0,marginTop:2}}),e.jsxs("span",{children:[e.jsx("strong",{children:"Lift:"})," SMS+Email shows up"," ",e.jsxs("strong",{style:{color:Pa},children:[(l.sms.rate-l.email.rate).toFixed(1)," pts"]})," ",l.sms.rate>=l.email.rate?"higher":"lower"," than email-only. Sample sizes: SMS n=",l.sms.count,", Email-only n=",l.email.count,"."]})]})]})]})}const Gi=({title:t,subtitle:s,children:n})=>e.jsxs("div",{className:"rounded-xl p-5",style:{background:"#fff",border:`1px solid ${k}15`,boxShadow:`0 2px 12px ${k}08`},children:[e.jsxs("div",{className:"mb-4",children:[e.jsx("h3",{className:"text-sm font-bold",style:{color:k,fontFamily:"'Playfair Display', Georgia, serif"},children:t}),s&&e.jsx("p",{className:"text-[11px] mt-0.5 text-gray-500",children:s})]}),n]}),lg=({label:t,value:s,max:n,color:a})=>{const r=n>
12420?s/n*100:0;return e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("span",{className:"text-xs font-semibold text-gray-700 w-24 shrink-0",children:t}),e.jsx("div",{className:"flex-1 h-9 bg-gray-100 rounded-lg overflow-hidden relative",children:e.jsx("div",{className:"h-full rounded-lg transition-all duration-700 flex items-center px-3",style:{width:`${Math.max(2,r)}%`,background:`linear-gradient(90deg, ${a}, ${a}dd)`},children:e.jsx("span",{className:"text-xs font-bold text-white",children:s})})}),e.jsxs("span",{className:"font-mono text-xs font-bold w-14 text-right shrink-0",style:{color:a},children:[r.toFixed(1),"%"]})]})},Gv=({value:t})=>e.jsxs("div",{className:"flex items-center gap-2 pl-24 ml-3 text-[11px]",style:{color:Pa},children:[e.jsx(Vt,{size:11}),e.jsxs("span",{className:"font-mono font-bold",children:[t," conversion"]})]}),iE=({icon:t,channel:s,rate:n,sample:a,accent:r,bg:i})=>e.jsxs("div",{className:"rounded-xl p-4",style:{background:i,border:`1.5px solid ${r}33`},children:[e.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[e.jsx("div",{className:"w-8 h-8 rounded-lg flex items-center justify-center",style:{background:r,color:"#fff"},children:t}),e.jsx("span",{className:"text-xs font-bold uppercase tracking-wider",style:{color:r},children:s})]}),e.jsx("p",{className:"font-mono text-3xl font-bold",style:{color:r},children:a>0?`${n.toFixed(1)}%`:"â"}),e.jsxs("p",{className:"text-[11px] text-gray-600 mt-1",children:["Show-up rate · n=",a]})]}),cg=({label:t,value:s,sublabel:n,accent:a,bg:r,border:i,icon:o})=>e.jsxs("div",{className:"rounded-xl p-3.5",style:{background:r,border:`1.5px solid ${i}`},children:[e.jsxs("div",{className:"flex items-center gap-2 mb-1.5",children:[e.jsx("div",{className:"w-7 h-7 rounded-lg flex items-center justify-center",style:{background:a,color:"#fff"},children:o}),e.jsx("span",{className:"text-[10px] font-bold uppercase tracking-wider",style:{color:a},children:t})]}),e.jsx("p",{className:"font-mono text-2xl font-bold leading-none",style:{color:a},children:s}),e.jsx("p",{className:"text-[10px] text-gray-600 mt-1.5 leading-tight",children:n})]}),oE=({rows:t,totalOpenRate:s,totalClickRate:n,totalOpens:a,totalClicks:r,uniqueOpened:i,uniqueClicked:o,successfullySent:l})=>t.length===0?null:e.jsxs("div",{className:"rounded-lg overflow-hidden",style:{background:"#FAFAFA",border:"1px solid #E5E7EB"},children:[e.jsxs("div",{className:"px-3 py-2.5 flex items-center justify-between gap-3 flex-wrap",style:{background:"#fff",borderBottom:"1px solid #E5E7EB"},children:[e.jsx("p",{className:"text-[10px] font-bold uppercase tracking-wider",style:{color:k},children:"Per-Campus Breakdown · Engagement"}),e.jsxs("div",{className:"flex items-center gap-3 text-[10px] font-mono",children:[e.jsxs("span",{className:"flex items-center gap-1",style:{color:"#1E40AF"},children:[e.jsxs("span",{className:"font-bold",children:[s.toFixed(1),"%"]}),e.jsx("span",{style:{color:"#666"},children:"open rate"})]}),e.jsx("span",{className:"text-gray-300",children:"·"}),e.jsxs("span",{className:"flex items-center gap-1",style:{color:"#7C3AED"},children:[e.jsxs("span",{className:"font-bold",children:[n.toFixed(1),"%"]}),e.jsx("span",{style:{color:"#666"},children:"click rate"})]}),e.jsx("span",{className:"text-gray-300",children:"·"}),e.jsxs("span",{style:{color:"#666"},children:[i,"/",l," opened, ",o,"/",l," clicked",a>i||r>o?e.jsxs("span",{className:"text-gray-400",children:[" (",a," total opens, ",r," total clicks)"]}):null]})]})]}),e.jsxs("div",{className:"grid gap-2 px-3 py-1.5 text-[9px] font-bold uppercase tracking-wider",style:{background:"#F4F4F5",color:"#6B7280",gridTemplateColumns:"2fr 1fr 1fr 1.4fr"},children:[e.jsx("span",{children:"Campus"}),e.jsx("span",{className:"text-center",children:"Pending"}),e.jsx("span",{className:"text-center",children:"Sent"}),e.jsx("span",{className:"text-right",children:"Engagement"})]}),e.jsx("div",{className:"divide-y",style:{borderColor:"#E5E7EB"},children:t.map(c=>{const u=c.sent>0?c.uniqueOpened/c.sent*100:0,p=c.sent>0?c.uniqueClicked/c.sent*100:0,m=c.uniqueOpened>0||c.uniqueClicked>0;return e.jsxs("div",{className:"grid gap-2 px-3 py-2 text-xs items-center",style:{gridTemplateColumns:"2fr 1fr 1fr 1.4fr"},children:[e.jsx("span",{className:"font-semibold text-gray-800 truncate",title:c.campus,children:c.campus}),e.jsx("span",{className:"text-center font-mono",children:c.pending>0?e.jsxs("span",{className:"inline-flex items-center gap-1.5",children:[e.jsx("span",{style:{color:k},className:"font-bold",children:c.pending}),c.failed>0&&e.jsxs("span",{className:"px-1 py-0.5 rounded text-[9px] font-bold",style:{background:"#FEE2E2",color:"#991B1B"},title:`${c.failed} send attempt${c.failed===1?"":"s"} errored`,children:[c.failed," fail"]})]}):e.jsx("span",{className:"text-gray-400",children:"â"})}),e.jsxs("span",{className:"text-center font-mono",children:[e.jsx("span",{style:{color:c.sent>0?"#065F46":"#9CA3AF"},className:"font-semibold",children:c.sent}),e.jsxs("span",{className:"text-gray-400",children:[" / ",c.total]})]}),e.jsx("div",{className:"flex items-center justify-end gap-2 font-mono text-[11px]",children:m?e.jsxs(e.Fragment,{children:[e.jsxs("span",{className:"inline-flex items-baseline gap-1 px-1.5 py-0.5 rounded",style:{background:"#EFF6FF",color:"#1E40AF"},title:`${c.uniqueOpened} of ${c.sent}
1242 successfully-sent emails opened (${c.totalOpens} total opens)`,children:[e.jsxs("span",{className:"font-bold",children:[u.toFixed(0),"%"]}),e.jsx("span",{className:"text-[9px]",style:{color:"#1E40AF99"},children:"open"})]}),e.jsxs("span",{className:"inline-flex items-baseline gap-1 px-1.5 py-0.5 rounded",style:{background:"#F5F3FF",color:"#7C3AED"},title:`${c.uniqueClicked} of ${c.sent} successfully-sent emails clicked (${c.totalClicks} total clicks)`,children:[e.jsxs("span",{className:"font-bold",children:[p.toFixed(0),"%"]}),e.jsx("span",{className:"text-[9px]",style:{color:"#7C3AED99"},children:"click"})]})]}):c.sent>0?e.jsx("span",{className:"text-gray-400 text-[10px]",children:"awaiting events"}):e.jsx("span",{className:"text-gray-300 text-[10px]",children:"â"})})]},c.campus)})})]}),Gu=(t,s)=>{const n=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],a=t.getMonth()===s.getMonth(),r=t.getFullYear()===s.getFullYear();return a?`${n[t.getMonth()]} ${t.getDate()}â${s.getDate()}`:r?`${n[t.getMonth()]} ${t.getDate()} â ${n[s.getMonth()]} ${s.getDate()}`:`${n[t.getMonth()]} ${t.getDate()}, ${t.getFullYear()} â ${n[s.getMonth()]} ${s.getDate()}, ${s.getFullYear()}`},lE=t=>`${["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"][t.getMonth()]} ${t.getDate()}`,sN=({delta:t,suffix:s="pp"})=>{if(t==null)return e.jsxs("span",{className:"inline-flex items-center gap-0.5 text-[10px] text-gray-400 font-mono",children:[e.jsx(Ml,{size:10}),e.jsx("span",{children:"â"})]});if(Math.abs(t)<.1)return e.jsxs("span",{className:"inline-flex items-center gap-0.5 text-[10px] text-gray-500 font-mono",children:[e.jsx(Ml,{size:10}),e.jsx("span",{children:"flat"})]});const n=t>0,a=t<-15,r=a?"#991B1B":n?"#047857":"#92400E",i=a?"#FEE2E2":n?"#D1FAE5":"#FEF3C7";return e.jsxs("span",{className:"inline-flex items-center gap-0.5 px-1.5 py-0.5 rounded font-mono text-[10px] font-bold",style:{background:i,color:r},children:[n?e.jsx("span",{"aria-hidden":"true",children:"â²"}):e.jsx("span",{"aria-hidden":"true",children:"â¼"}),e.jsxs("span",{children:[Math.abs(t).toFixed(1),s]})]})},zee=({weeks:t,comparisonWeeks:s,selectedCampusName:n})=>{if(t.length<2)return e.jsxs("div",{className:"rounded-lg p-6 text-center text-[11px] text-gray-500",style:{background:"#FAFAFA",border:"1px dashed #E5E7EB"},children:["Need at least 2 weeks of cohort data to plot a trend line. Currently showing ",t.length," week",t.length===1?"":"s","."]});const a=720,r=220,i={top:16,right:16,bottom:36,left:40},o=a-i.left-i.right,l=r-i.top-i.bottom,c=100,u=0,p=t.length>1?o/(t.length-1):0,m=_=>i.left+_*p,x=_=>i.top+l-(_-u)/(c-u)*l,h=(_,C)=>{const E=[];let P=!1;return _.forEach((F,I)=>{const D=F[C];if(D==null){P=!1;return}const L=P?"L":"M";E.push(`${L}${m(I).toFixed(1)},${x(D).toFixed(1)}`),P=!0}),E.join(" ")},y=h(t,"openRate"),v=h(t,"clickRate"),g=!!s&&s.length===t.length,N=g?h(s,"openRate"):"",b=g?h(s,"clickRate"):"",f=[0,25,50,75,100],j=t.length>8?2:1,S="#475569",w="#94A3B8";return e.jsxs("div",{className:"rounded-lg p-3",style:{background:"#FAFAFA",border:"1px solid #E5E7EB"},children:[e.jsxs("div",{className:"flex items-center gap-x-4 gap-y-1 mb-2 px-2 text-[11px] flex-wrap",children:[e.jsxs("span",{className:"inline-flex items-center gap-1.5 font-semibold",style:{color:"#1E40AF"},children:[e.jsx("span",{className:"inline-block w-3 h-0.5",style:{background:"#1E40AF"}}),e.jsx("span",{className:"inline-block w-1.5 h-1.5 rounded-full",style:{background:"#1E40AF"}}),g?`${n||"Campus"} · Open`:"Open Rate"]}),e.jsxs("span",{className:"inline-flex items-center gap-1.5 font-semibold",style:{color:"#7C3AED"},children:[e.jsx("span",{className:"inline-block w-3 h-0.5",style:{background:"#7C3AED"}}),e.jsx("span",{className:"inline-block w-1.5 h-1.5 rounded-full",style:{background:"#7C3AED"}}),g?`${n||"Campus"} · Click`:"Click Rate"]}),g&&e.jsxs(e.Fragment,{children:[e.jsxs("span",{className:"inline-flex items-center gap-1.5 font-semibold",style:{color:S},children:[e.jsx("svg",{width:"14",height:"3","aria-hidden":"true",children:e.jsx("line",{x1:"0",y1:"1.5",x2:"14",y2:"1.5",stroke:S,strokeWidth:"1.75",strokeDasharray:"3,2"})}),"All Campuses · Open"]}),e.jsxs("span",{className:"inline-flex items-center gap-1.5 font-semibold",style:{color:w},children:[e.jsx("svg",{width:"14",height:"3","aria-hidden":"true",children:e.jsx("line",{x1:"0",y1:"1.5",x2:"14",y2:"1.5",stroke:w,strokeWidth:"1.5",strokeDasharray:"2,2"})}),"All Campuses · Click"]})]}),e.jsx("span",{className:"text-gray-400 ml-auto text-[10px]",children:"% of successfully-sent welcome emails per cohort week"})]}),e.jsxs("svg",{viewBox:`0 0 ${a} ${r}`,width:"100%",style:{display:"block",overflow:"visible"},children:[f.map(_=>e.jsxs("g",{children:[e.jsx("line",{x1:i.left,y1:x(_),x2:i.left+o,y2:x(_),stroke:"#E5E7EB",strokeDasharray:_===0?"":"2,3",strokeWidth:_===0?1:.75}),e.jsxs("text",{x:i.left-6,y:x(_)+3,textAnchor:"end",fontSize:"9",fill:"#9CA3AF",fontFamily:"ui-monospace, monospace",children:[_,"%"]})]},_)),t.map((_,C)=>
1242{if(!_.flagSpamDrop)return null;const E=m(C),P=p/2;return e.jsx("rect",{x:Math.max(i.left,E-P),y:i.top,width:Math.min(p,o),height:l,fill:"#DC262611"},`flag-${_.weekKey}`)}),g&&e.jsxs(e.Fragment,{children:[e.jsx("path",{d:b,fill:"none",stroke:w,strokeWidth:"1.5",strokeDasharray:"2,2",strokeLinecap:"round",strokeLinejoin:"round",opacity:.85}),e.jsx("path",{d:N,fill:"none",stroke:S,strokeWidth:"1.75",strokeDasharray:"3,2",strokeLinecap:"round",strokeLinejoin:"round",opacity:.95}),s.map((_,C)=>_.openRate!=null?e.jsx("circle",{cx:m(C),cy:x(_.openRate),r:2.25,fill:"#FAFAFA",stroke:S,strokeWidth:"1.25",children:e.jsxs("title",{children:["All campuses â ",lE(t[C].weekStart),": open rate ",_.openRate.toFixed(1),"% (",_.uniqueOpened,"/",_.sent,"), ",_.cohortSize," enrolled across ",_.cohortSize>0?Math.max(1,Math.round(_.cohortSize/Math.max(1,_.perCampusAvgCohortSize))):0," campus",_.cohortSize===1?"":"es"]})},`co-${_.weekKey}`):null)]}),e.jsx("path",{d:v,fill:"none",stroke:"#7C3AED",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"}),e.jsx("path",{d:y,fill:"none",stroke:"#1E40AF",strokeWidth:"2.25",strokeLinecap:"round",strokeLinejoin:"round"}),t.map((_,C)=>_.clickRate!=null?e.jsx("circle",{cx:m(C),cy:x(_.clickRate),r:3,fill:"#fff",stroke:"#7C3AED",strokeWidth:"2",children:e.jsxs("title",{children:[Gu(_.weekStart,_.weekEnd)," â Click rate: ",_.clickRate.toFixed(1),"% (",_.uniqueClicked,"/",_.sent,")"]})},`c-${_.weekKey}`):null),t.map((_,C)=>_.openRate!=null?e.jsx("circle",{cx:m(C),cy:x(_.openRate),r:_.flagSpamDrop?4.5:3.5,fill:_.flagSpamDrop?"#DC2626":"#fff",stroke:_.flagSpamDrop?"#991B1B":"#1E40AF",strokeWidth:_.flagSpamDrop?2.5:2,children:e.jsxs("title",{children:[Gu(_.weekStart,_.weekEnd)," â Open rate: ",_.openRate.toFixed(1),"% (",_.uniqueOpened,"/",_.sent,")",_.flagSpamDrop?" â FLAGGED: drop > 15pp vs previous week":"",g&&s[C].openRate!=null?` · all-campus avg ${s[C].openRate.toFixed(1)}%`:""]})},`o-${_.weekKey}`):null),t.map((_,C)=>C%j!==0&&C!==t.length-1?null:e.jsx("text",{x:m(C),y:r-i.bottom+14,textAnchor:"middle",fontSize:"9",fill:"#6B7280",fontFamily:"ui-monospace, monospace",children:lE(_.weekStart)},`x-${_.weekKey}`))]})]})},Lee=({weeks:t,flaggedWeeks:s,comparisonWeeks:n,selectedCampusName:a,campusCount:r})=>{if(t.length===0)return e.jsx("p",{className:"text-sm text-gray-400 text-center py-6",children:"No cohort data yet â enrolled visitors will appear here grouped by their enrollment week."});const i=t[t.length-1],o=t.length>=2?t[t.length-2]:null,l=n&&n.length===t.length?n[n.length-1]:null,c=!!n&&n.length===t.length,u=c?(()=>{const p=t.reduce((w,_)=>w+_.cohortSize,0),m=n.reduce((w,_)=>w+_.cohortSize,0),x=Math.max(1,r||1),h=m/x,y=m>0?p/m*100:0,v=x>0?100/x:0;let g=0,N=0,b=0,f=0;t.forEach((w,_)=>{const C=n[_];w.openRate!=null&&C.openRate!=null&&(g+=w.openRate-C.openRate,N++),w.clickRate!=null&&C.clickRate!=null&&(b+=w.clickRate-C.clickRate,f++)});const j=N>0?g/N:null,S=f>0?b/f:null;return{campusEnrolled:p,allEnrolled:m,avgPerCampus:h,sharePct:y,expectedPct:v,avgOpenGap:j,avgClickGap:S,denom:x}})():null;return e.jsxs("div",{className:"space-y-4",children:[s>0&&e.jsxs("div",{className:"rounded-lg p-3 flex items-start gap-2.5 text-[12px]",style:{background:"#FEF2F2",border:"1px solid #DC262633",color:"#991B1B"},children:[e.jsx(ve,{size:16,style:{color:"#DC2626",flexShrink:0,marginTop:1}}),e.jsxs("span",{children:[e.jsxs("strong",{children:[s," cohort",s===1?"":"s"]})," in this view saw an open-rate drop of more than ",e.jsx("strong",{children:"15 percentage points"})," vs the prior week. This is the typical fingerprint of a welcome email landing in spam, a broken portal link in the template, or a deliverability event at a major mailbox provider. Review the flagged week",s===1?"":"s"," below and spot-check a few rows in the Detail Drawer to confirm."]})]}),e.jsxs("div",{className:"grid grid-cols-2 sm:grid-cols-4 gap-3",children:[e.jsx(dg,{label:"Latest Cohort",value:`${i.cohortSize}`,sublabel:c&&l?`${Gu(i.weekStart,i.weekEnd)} · avg per campus ${l.perCampusAvgCohortSize.toFixed(1)}`:Gu(i.weekStart,i.weekEnd),accent:k,bg:"#FFF8E5",border:`${$}55`,icon:e.jsx(At,{size:14})}),e.jsx(dg,{label:"Open Rate",value:i.openRate!=null?`${i.openRate.toFixed(1)}%`:"â",sublabel:c&&(l==null?void 0:l.openRate)!=null&&i.openRate!=null?`${i.uniqueOpened}/${i.sent} · all-campus ${l.openRate.toFixed(1)}%`:i.openRate!=null?`${i.uniqueOpened}/${i.sent} opened`:"No sent emails yet",accent:"#1E40AF",bg:"#DBEAFE",border:"#1E40AF33",icon:e.jsx(Ye,{size:14}),delta:i.openRateDelta,flagSpamDrop:i.flagSpamDrop}),e.jsx(dg,{label:"Click Rate",value:i.clickRate!=null?`${i.clickRate.toFixed(1)}%`:"â",sublabel:c&&(l==null?void 0:l.clickRate)!=null&&i.clickRate!=null?`${i.uniqueClicked}/${i.sent} · all-campus ${l.clickRate.toFixed(1)}%`:i.clickRate!=null?`${i.uniqueClicked}/${i.sent} clicked`:"â",accent:"#7C3AED",bg:"#F5F3FF",border:"#7C3AED33",icon:e.jsx(si,{size:14}),delta:i.clickRateDelta}),e.jsx(dg,{label:"vs Prior Week",value:o&&i.openRateDelta!=null?`${i.openRateDelta>=0?"+":""}${i.openRateDelta.toFixed(1)} pp`:"â",sublabel:o?`Open rate · prior week ${o.openRate!=null?o.openRate.toFixed(1)+"%":"â"}`:"Need 2+ weeks of data",accent:i.flagSpamDrop?"#991B1B":i.openRateDelta!=null&&i.openRateDelta<0?"#92400E":i.openRateDelta!=null&&i.openRateDelta>0?"#047857":"#6B7280",bg:i.flagSpamDrop?"#FEE2E2":i.openRateDelta!=null&&i.openRateDelta<0?"#FEF3C7":i.openRateDelta!=null&&i.openRateDelta>0?"#D1FAE5":"#F3F4F6",border:i.flagSpamDrop?"#DC262633":"#E5E7EB",icon:i.flagSpamDrop||i.openRateDelta!=null&&i.openRateDelta<0?e.jsx(t5,{size:14}):e.jsx(si,{size:14})})]}),e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[e.jsx(bO,{size:14,style:{color:k}}),e.jsxs("p",{className:"text-[11px] font-bold uppercase tracking-wider",style:{color:k},children:["Week-over-Week Trend",c&&a&&e.jsxs("span",{className:"ml-2 text-[10px] font-normal text-gray-500 normal-case tracking-normal",children:[a," vs all-campuses average"]})]})]}),e.jsx(zee,{weeks:t,comparisonWeeks:n,selectedCampusName:a})]}),c&&u&&a&&e.jsxs("div",{className:"rounded-lg p-3.5",style:{background:"#F8FAFC",border:"1px solid #CBD5E1"},children:[e.jsxs("div",{className:"flex items-center gap-2 mb-2.5",children:[e.jsx(Ws,{size:13,style:{color:"#475569"}}),e.jsxs("p",{className:"text-[11px] font-bold uppercase tracking-wider",style:{color:"#334155"},children:[a," vs Network â Last ",t.length," Week",t.length===1?"":"s"]})]}),e.jsxs("div",{className:"grid sm:grid-cols-3 gap-3 text-[11px]",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-[9px] uppercase tracking-wider font-bold text-gray-500 mb-0.5",children:"Enrollment Count"}),e.jsxs("p",{className:"font-mono",children:[e.jsx("span",{className:"font-bold text-base",style:{color:k},children:u.campusEnrolled}),e.jsx("span",{className:"text-gray-400",children:" · network avg per campus "}),e.jsx("span",{className:"font-semibold text-gray-700",children:u.avgPerCampus.toFixed(1)})]}),e.jsxs("p",{className:"text-[10px] text-gray-500 mt-0.5",children:[u.sharePct.toFixed(1),"% of ",u.allEnrolled," network-wide ·"," ",u.sharePct>=u.expectedPct?"above":"below"," fair share (",u.expectedPct.toFixed(1),"% across ",u.denom," campuses)"]}
1242)]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-[9px] uppercase tracking-wider font-bold text-gray-500 mb-0.5",children:"Open Rate Gap"}),u.avgOpenGap!=null?e.jsxs(e.Fragment,{children:[e.jsx("p",{className:"font-mono",children:e.jsxs("span",{className:"font-bold text-base",style:{color:u.avgOpenGap>=0?"#047857":u.avgOpenGap<-5?"#991B1B":"#92400E"},children:[u.avgOpenGap>=0?"+":"",u.avgOpenGap.toFixed(1)," pp"]})}),e.jsx("p",{className:"text-[10px] text-gray-500 mt-0.5",children:u.avgOpenGap>=0?"Above network â opens this campus's deliverability is healthy.":u.avgOpenGap<-5?"Below network â possible spam / IP-reputation issue specific to this campus.":"Slightly below network â within normal variance."})]}):e.jsx("p",{className:"text-gray-400 text-[10px]",children:"Not enough overlapping data."})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-[9px] uppercase tracking-wider font-bold text-gray-500 mb-0.5",children:"Click Rate Gap"}),u.avgClickGap!=null?e.jsxs(e.Fragment,{children:[e.jsx("p",{className:"font-mono",children:e.jsxs("span",{className:"font-bold text-base",style:{color:u.avgClickGap>=0?"#047857":u.avgClickGap<-5?"#991B1B":"#92400E"},children:[u.avgClickGap>=0?"+":"",u.avgClickGap.toFixed(1)," pp"]})}),e.jsx("p",{className:"text-[10px] text-gray-500 mt-0.5",children:u.avgClickGap>=0?"Engagement holding up â portal links working for this campus.":u.avgClickGap<-5?"Below network â check the welcome email template's portal link for this campus.":"Slightly behind network click-through."})]}):e.jsx("p",{className:"text-gray-400 text-[10px]",children:"Not enough overlapping data."})]})]})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-[11px] font-bold uppercase tracking-wider mb-2",style:{color:k},children:"Cohort Breakdown"}),e.jsxs("div",{className:"rounded-lg overflow-hidden",style:{background:"#fff",border:"1px solid #E5E7EB"},children:[e.jsxs("div",{className:"grid gap-2 px-3 py-1.5 text-[9px] font-bold uppercase tracking-wider",style:{background:"#F4F4F5",color:"#6B7280",gridTemplateColumns:c?"1.5fr 0.7fr 0.7fr 1.5fr 1.4fr 1.0fr 0.55fr":"1.6fr 0.7fr 0.7fr 1.4fr 1.4fr 0.6fr"},children:[e.jsx("span",{children:"Week (MonâSun)"}),e.jsx("span",{className:"text-center",children:"Cohort"}),e.jsx("span",{className:"text-center",children:"Sent"}),e.jsx("span",{className:"text-right",children:"Open Rate · Î"}),e.jsx("span",{className:"text-right",children:"Click Rate · Î"}),c&&e.jsx("span",{className:"text-right",children:"vs All"}),e.jsx("span",{className:"text-right",children:"Flag"})]}),e.jsx("div",{className:"divide-y",style:{borderColor:"#F1F5F9"},children:t.slice().reverse().map((p,m)=>{const x=t.length-1-m,h=c?n[x]:null;return e.jsxs("div",{className:"grid gap-2 px-3 py-2 text-xs items-center",style:{gridTemplateColumns:c?"1.5fr 0.7fr 0.7fr 1.5fr 1.4fr 1.0fr 0.55fr":"1.6fr 0.7fr 0.7fr 1.4fr 1.4fr 0.6fr",background:p.flagSpamDrop?"#FEF2F2":"transparent"},children:[e.jsx("span",{className:"font-semibold text-gray-800 truncate",title:Gu(p.weekStart,p.weekEnd),children:Gu(p.weekStart,p.weekEnd)}),e.jsxs("span",{className:"text-center font-mono",children:[e.jsx("span",{className:"text-gray-700",children:p.cohortSize}),c&&h&&h.perCampusAvgCohortSize>0&&e.jsxs("span",{className:"block text-[9px] text-gray-400",title:`Network avg per campus this week: ${h.perCampusAvgCohortSize.toFixed(1)}`,children:["avg ",h.perCampusAvgCohortSize.toFixed(1)]})]}),e.jsxs("span",{className:"text-center font-mono",children:[e.jsx("span",{style:{color:p.sent>0?"#065F46":"#9CA3AF"},className:"font-semibold",children:p.sent}),(p.failed>0||p.bounced>0)&&e.jsxs("span",{className:"ml-1 px-1 py-0.5 rounded text-[9px] font-bold",style:{background:"#FEE2E2",color:"#991B1B"},title:`${p.failed} failed, ${p.bounced} bounced`,children:[p.failed+p.bounced,"â¯"]})]}),e.jsxs("span",{className:"text-right font-mono inline-flex items-center justify-end gap-1.5",children:[e.jsx("span",{className:"font-bold",style:{color:"#1E40AF"},children:p.openRate!=null?`${p.openRate.toFixed(1)}%`:"â"}),e.jsx(sN,{delta:p.openRateDelta})]}),e.jsxs("span",{className:"text-right font-mono inline-flex items-center justify-end gap-1.5",children:[e.jsx("span",{className:"font-bold",style:{color:"#7C3AED"},children:p.clickRate!=null?`${p.clickRate.toFixed(1)}%`:"â"}),e.jsx(sN,{delta:p.clickRateDelta})]}),c&&e.jsx("span",{className:"text-right font-mono",children:h&&h.openRate!=null&&p.openRate!=null?e.jsxs("span",{className:"inline-flex items-center gap-0.5 px-1.5 py-0.5 rounded text-[10px] font-bold",style:{background:p.openRate-h.openRate>=0?"#D1FAE5":p.openRate-h.openRate<-5?"#FEE2E2":"#FEF3C7",color:p.openRate-h.openRate>=0?"#047857":p.openRate-h.openRate<-5?"#991B1B":"#92400E"},title:`This campus open rate ${p.openRate.toFixed(1)}% vs network ${h.openRate.toFixed(1)}%`,children:[p.openRate-h.openRate>=0?"+":"",(p.openRate-h.openRate).toFixed(1),"pp"]}):e.jsx("span",{className:"text-gray-300 text-[10px]",children:"â"})}),e.jsx("span",{className:"text-right",children:p.flagSpamDrop?e.jsxs("span",{className:"inline-flex items-center gap-1 px-1.5 py-0.5 rounded text-[9px] font-bold",style:{background:"#FEE2E2",color:"#991B1B"},title:"Open rate dropped > 15 pp vs the previous week â likely deliverability or broken-link issue",children:[e.jsx(ve,{size:10}),"SPAM?"]}):e.jsx("span",{className:"text-gray-300 text-[10px]",children:"â"})})]},p.weekKey)})})]})]}),e.jsxs("p",{className:"text-[11px] text-gray-500 leading-relaxed",children:["Cohorts are bucketed by ISO week (MonâSun) of the visitor's ",e.jsx("code",{className:"px-1 py-0.5 rounded bg-gray-100 font-mono text-[10px]",children:"enrolled_at"})," ","timestamp. Open / click rates use the ",e.jsx("em",{children:"successfully-sent"})," denominator (excludes ",e.jsx("code",{className:"px-1 py-0.5 rounded bg-gray-100 font-mono text-[10px]",children:"failed"})," and"," ",e.jsx("code",{className:"px-1 py-0.5 rounded bg-gray-100 font-mono text-[10px]",children:"bounced"})," rows). Engagement events flow in via"," ",e.jsx("code",{className:"px-1 py-0.5 rounded bg-gray-100 font-mono text-[10px]",children:"mailgun-webhook â enrollment_email_events"}),". A cohort is flagged when its open rate drops more than ",e.jsx("strong",{children:"15 pp"})," vs the immediately preceding week (with sent ⥠3 to suppress small-sample noise) â a common signal that the welcome email landed in spam or a portal link broke for that week's enrollees.",c&&e.jsxs(e.Fragment,{children:[" The campus filter recomputes the buckets from rows where ",e.jsx("code",{className:"px-1 py-0.5 rounded bg-gray-100 font-mono text-[10px]",children:"campus_slug"})," matches; the dashed reference line shows the network-wide cohort rate for the same week so a campus-specific dip is easy to distinguish from a network-wide event."]})]})]})},dg=({label:t,value:s,sublabel:n,accent:a,bg:r,border:i,icon:o,delta:l,flagSpamDrop:c})=>e.jsxs("div",{className:"rounded-xl p-3.5 relative",style:{background:c?"#FEE2E2":r,border:c?"1.5px solid #DC262655":`1.5px solid ${i}`},children:[c&&e.jsxs("span",{className:"absolute top-1.5 right-1.5 px-1.5 py-0.5 rounded text-[8px] font-bold flex items-center gap-0.5",style:{background:"#DC2626",color:"#fff"},children:[e.jsx(ve,{size:8}),"FLAGGED"]}),e.jsxs("div",{className:"flex items-center gap-2 mb-1.5",children:[e.jsx("div",{className:"w-7 h-7 rounded-lg flex items-center justify-center",style:{background:c?"#991B1B":a,color:"#fff"},children:o}),e.jsx("span",{className:"text-[10px] font-bold uppercase tracking-wider",style:{color:c?"#991B1B":a},children:t})]}),e.jsxs("div",{className:"flex items-baseline gap-1.5",children:[e.jsx("p",{className:"font-mono text-2xl font-bold leading-none",style:{color:c?"#991B1B":a},children:s}),l!=null&&e.jsx(sN,{delta:l})]}),e.jsx("p",{className:"text-[10px] text-gray-600 mt-1.5 leading-tight",children:n})]}),Oee=({campuses:t,selected:s,onChange:n,filteredCount:a,totalCount:r})=>{if(t.length<=1)return null;const i=s?t.find(l=>l.slug===s):null,o=!!s&&!!i;return e.jsxs("div",{className:"rounded-lg p-3 mb-4 flex flex-wrap items-center gap-3",style:{background:o?"#FFF8E5":"#FAFAFA",border:`1px solid ${o?`${$}55`:"#E5E7EB"}`},children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(ei,{size:13,style:{color:o?Pa:"#6B7280"}}
1242),e.jsx("label",{htmlFor:"cohort-campus-filter",className:"text-[10px] font-bold uppercase tracking-wider",style:{color:o?k:"#6B7280"},children:"Campus Filter"})]}),e.jsxs("div",{className:"relative flex-1 min-w-[200px] max-w-[320px]",children:[e.jsxs("select",{id:"cohort-campus-filter",value:s,onChange:l=>n(l.target.value),className:"w-full appearance-none rounded-md text-xs font-semibold pl-8 pr-8 py-1.5 cursor-pointer transition-colors focus:outline-none focus:ring-2",style:{background:"#fff",border:`1px solid ${o?`${Pa}`:"#D1D5DB"}`,color:o?k:"#374151",boxShadow:o?`0 0 0 1px ${$}33`:void 0},"aria-label":"Filter cohort report by campus",children:[e.jsxs("option",{value:"",children:["All campuses (",r,")"]}),t.map(l=>e.jsx("option",{value:l.slug,children:l.name},l.slug))]}),e.jsx(Ws,{size:13,"aria-hidden":"true",className:"absolute left-2.5 top-1/2 -translate-y-1/2 pointer-events-none",style:{color:o?Pa:"#9CA3AF"}}),e.jsx("svg",{"aria-hidden":"true",className:"absolute right-2 top-1/2 -translate-y-1/2 pointer-events-none",width:"10",height:"10",viewBox:"0 0 10 10",fill:"none",children:e.jsx("path",{d:"M2 4l3 3 3-3",stroke:"#6B7280",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})})]}),o&&i?e.jsxs("div",{className:"flex items-center gap-2 ml-auto",children:[e.jsxs("span",{className:"inline-flex items-center gap-1.5 px-2 py-1 rounded-full font-mono text-[10px]",style:{background:"#fff",border:`1px solid ${$}55`,color:k},children:[e.jsx("span",{className:"font-bold",children:a}),e.jsxs("span",{style:{color:"#6B7280"},children:["of ",r," enrolled"]}),e.jsx("span",{style:{color:"#9CA3AF"},children:"·"}),e.jsx("span",{className:"font-semibold",children:i.name})]}),e.jsxs("button",{type:"button",onClick:()=>n(""),className:"inline-flex items-center gap-1 px-2 py-1 rounded text-[10px] font-bold uppercase tracking-wider transition-colors hover:bg-white",style:{color:Pa,border:`1px solid ${$}55`,background:"transparent"},"aria-label":"Clear campus filter",title:"Clear filter â show all campuses",children:[e.jsx(Ke,{size:11}),"Clear"]})]}):e.jsxs("span",{className:"ml-auto text-[10px] text-gray-500 font-mono",children:["Showing all ",r," enrolled across ",t.length," campuses · select one to compare vs network"]})]})},Vv="#B8962E",Mee={accepted:{label:"Accepted by Mailgun",color:"#0F766E",bg:"#F0FDFA",border:"#0F766E33",icon:QS},delivered:{label:"Delivered",color:"#065F46",bg:"#ECFDF5",border:"#10B98133",icon:gd},opened:{label:"Opened",color:"#1E40AF",bg:"#EFF6FF",border:"#1E40AF33",icon:ms},clicked:{label:"Link Clicked",color:"#7C3AED",bg:"#F5F3FF",border:"#7C3AED33",icon:e5},permanent_fail:{label:"Hard Bounce",color:"#991B1B",bg:"#FEF2F2",border:"#DC262633",icon:Mt},temporary_fail:{label:"Soft Bounce",color:"#92400E",bg:"#FFFBEB",border:"#F59E0B33",icon:ve},complained:{label:"Spam Complaint",color:"#991B1B",bg:"#FEF2F2",border:"#DC262633",icon:Mt},unsubscribed:{label:"Unsubscribed",color:"#6B7280",bg:"#F3F4F6",border:"#9CA3AF33",icon:QO},rejected:{label:"Rejected",color:"#991B1B",bg:"#FEF2F2",border:"#DC262633",icon:Mt},stored:{label:"Stored",color:"#6B7280",bg:"#F3F4F6",border:"#9CA3AF33",icon:QS}},Bee={label:"Event",color:k,bg:"#FAFAFA",border:"#E5E7EB",icon:dt},Uee=t=>new Date(t).toLocaleString([],{month:"short",day:"numeric",hour:"numeric",minute:"2-digit"}),qee=t=>{const s=Date.now()-new Date(t).getTime(),n=Math.floor(s/6e4);if(n<1)return"just now";if(n<60)return`${n} minute${n===1?"":"s"} ago`;const a=Math.floor(n/60);if(a<24)return`${a} hour${a===1?"":"s"} ago`;const r=Math.floor(a/24);return`${r} day${r===1?"":"s"} ago`},Wee=({tourId:t,openCount:s,clickCount:n,openedAt:a,clickedAt:r,deliveredAt:i})=>{const[o,l]=d.useState([]),[c,u]=d.useState(!0),[p,m]=d.useState(null);d.useEffect(()=>{let h=!0;const y=async()=>{u(!0);const{data:g,error:N}=await O.from("enrollment_email_events").select("*").eq("tour_id",t).order("event_timestamp",{ascending:!1}).limit(100);h&&(N?m(N.message):(l(g||[]),m(null)),u(!1))};y();const v=O.channel(`enrollment-email-events-${t}`).on("postgres_changes",{event:"INSERT",schema:"public",table:"enrollment_email_events",filter:`tour_id=eq.${t}`},()=>y()).subscribe();return()=>{h=!1,O.removeChannel(v)}},[t]);const x=d.useMemo(()=>{const h=s??o.filter(b=>b.event_type==="opened").length,y=n??o.filter(b=>b.event_type==="clicked").length,v=o.filter(b=>b.event_type==="permanent_fail"||b.event_type==="temporary_fail").length,g=o.filter(b=>b.event_type==="complained").length,N=o[0]||null;return{opens:h,clicks:y,bounces:v,complaints:g,lastEvent:N}
1242},[o,s,n]);return c?e.jsxs("div",{className:"rounded-lg p-4 flex items-center justify-center gap-2",style:{background:"#fff",border:`1px solid ${k}15`},children:[e.jsx(de,{size:14,className:"animate-spin",style:{color:Vv}}),e.jsx("span",{className:"text-xs",style:{color:"#666"},children:"Loading engagement timelineâ¦"})]}):p?e.jsxs("div",{className:"rounded-lg p-3 text-xs",style:{background:"#FEF2F2",border:"1px solid #DC262633",color:"#991B1B"},children:["Could not load engagement events: ",p]}):o.length===0?e.jsxs("div",{className:"rounded-lg p-4",style:{background:"#fff",border:`1px solid ${k}15`},children:[e.jsxs("div",{className:"flex items-center gap-2 mb-1.5",children:[e.jsx(Ma,{size:13,style:{color:Vv}}),e.jsx("p",{className:"text-[11px] font-bold uppercase tracking-wider",style:{color:k},children:"Engagement Timeline"})]}),e.jsx("p",{className:"text-[12px]",style:{color:"#888"},children:"No Mailgun events yet. Delivery, open, and click events stream in here automatically once the welcome email lands and the recipient interacts with it."})]}):e.jsxs("div",{className:"rounded-lg p-4 space-y-3",style:{background:"#fff",border:`1px solid ${k}15`},children:[e.jsxs("div",{className:"flex items-start justify-between gap-3 flex-wrap",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Ma,{size:13,style:{color:Vv}}),e.jsx("p",{className:"text-[11px] font-bold uppercase tracking-wider",style:{color:k},children:"Engagement Timeline"})]}),x.lastEvent&&e.jsxs("p",{className:"text-[10px]",style:{color:"#888"},children:["Last activity ",qee(x.lastEvent.event_timestamp)]})]}),e.jsxs("div",{className:"grid grid-cols-4 gap-2",children:[e.jsx(ug,{label:"Delivered",value:i?"â":(x.lastEvent,"â"),color:i?"#065F46":"#9CA3AF",bg:i?"#ECFDF5":"#F3F4F6"}),e.jsx(ug,{label:"Opens",value:x.opens,color:x.opens>0?"#1E40AF":"#9CA3AF",bg:x.opens>0?"#EFF6FF":"#F3F4F6"}),e.jsx(ug,{label:"Clicks",value:x.clicks,color:x.clicks>0?"#7C3AED":"#9CA3AF",bg:x.clicks>0?"#F5F3FF":"#F3F4F6"}),e.jsx(ug,{label:x.complaints>0?"Complaints":"Bounces",value:x.complaints>0?x.complaints:x.bounces,color:x.bounces>0||x.complaints>0?"#991B1B":"#9CA3AF",bg:x.bounces>0||x.complaints>0?"#FEF2F2":"#F3F4F6"})]}),e.jsx("ol",{className:"relative pl-5 space-y-2 mt-1",style:{borderLeft:`2px solid ${$}33`},children:o.map(h=>{var b,f,j,S;const y=Mee[h.event_type]||Bee,v=y.icon,g=((b=h.client_info)==null?void 0:b["client-name"])||((f=h.client_info)==null?void 0:f.client_name),N=((j=h.client_info)==null?void 0:j["client-os"])||((S=h.client_info)==null?void 0:S.client_os);return e.jsxs("li",{className:"relative",children:[e.jsx("span",{className:"absolute -left-[27px] top-1.5 w-4 h-4 rounded-full flex items-center justify-center",style:{background:y.color,color:"#fff"},children:e.jsx(v,{size:9})}),e.jsxs("div",{className:"rounded-md p-2.5 text-[12px]",style:{background:y.bg,border:`1px solid ${y.border}`},children:[e.jsxs("div",{className:"flex items-center justify-between gap-2 flex-wrap",children:[e.jsx("span",{className:"font-bold uppercase tracking-wider text-[10px]",style:{color:y.color},children:y.label}),e.jsx("span",{className:"font-mono text-[10px]",style:{color:"#666"},children:Uee(h.event_timestamp)})]}),h.event_type==="clicked"&&h.click_url&&e.jsxs("a",{href:h.click_url,target:"_blank",rel:"noopener noreferrer",className:"block mt-1.5 text-[11px] truncate hover:underline",style:{color:y.color},title:h.click_url,children:["â ",h.click_url]}),h.event_type==="opened"&&(g||N)&&e.jsxs("p",{className:"mt-1.5 text-[11px]",style:{color:"#555"},children:[[g,N].filter(Boolean).join(" · "),h.ip_address&&e.jsxs("span",{className:"ml-1.5 font-mono text-[10px]",style:{color:"#888"},children:["IP ",h.ip_address]})]}),(h.event_type==="permanent_fail"||h.event_type==="temporary_fail"||h.event_type==="complained")&&h.bounce_reason&&e.jsx("p",{className:"mt-1.5 text-[11px] leading-relaxed",style:{color:"#7F1D1D"},children:h.bounce_reason}),!(h.event_type==="clicked"||h.event_type==="opened"||h.event_type==="permanent_fail"||h.event_type==="temporary_fail"||h.event_type==="complained")&&h.status_detail&&e.jsx("p",{className:"mt-1.5 text-[11px]",style:{color:"#555"},children:h.status_detail})]})]}
1242,h.id)})}),e.jsxs("p",{className:"text-[10px] pt-1",style:{color:"#999"},children:[o.length," event",o.length===1?"":"s"," · streaming live from Mailgun via ",e.jsx("code",{className:"px-1 rounded bg-gray-100 font-mono text-[9px]",children:"mailgun-webhook"}),". Most recent first."]})]})},ug=({label:t,value:s,color:n,bg:a})=>e.jsxs("div",{className:"rounded-md px-2 py-1.5 text-center",style:{background:a,border:`1px solid ${n}33`},children:[e.jsx("p",{className:"font-mono text-base font-bold leading-none",style:{color:n},children:s}),e.jsx("p",{className:"text-[9px] mt-1 uppercase tracking-wider",style:{color:n},children:t})]}),Ph="#E6D2A0",cs="#B8962E",Yy="#2A0810",nN="#FAF6ED",Hee=[{slug:"all",label:"All Campuses"},{slug:"bellingham",label:"Bellingham"},{slug:"renton",label:"Renton"},{slug:"seattle",label:"Seattle"}],Ky=[{value:"all",label:"All Statuses",color:k,bg:"#EEE6D8"},{value:"new",label:"New",color:"#1E40AF",bg:"#DBEAFE"},{value:"contacted",label:"Contacted",color:"#92400E",bg:"#FEF3C7"},{value:"scheduled",label:"Scheduled",color:"#065F46",bg:"#D1FAE5"},{value:"completed",label:"Completed",color:"#374151",bg:"#E5E7EB"},{value:"no-show",label:"No-Show",color:"#991B1B",bg:"#FEE2E2"},{value:"cancelled",label:"Cancelled",color:"#6B7280",bg:"#F3F4F6"}],Gee=["Unassigned","Maria Lopez (Bellingham)","James Carter (Renton)","Aiyana Tate (Seattle)","Director â Sondra Z."],YI=t=>Ky.find(s=>s.value===t)||Ky[0];function Vee(t){const s=["ID","Campus","First Name","Last Name","Email","Phone","Program of Interest","Preferred Date","Status","Scheduled At","Assigned Advisor","Confirmation Email Sent At","Reminder Email Sent At","SMS Opt-In","SMS Reminder Sent At","SMS Reminder Status","Day-Of SMS Sent At","Day-Of SMS Status","Enrolled","Enrolled At","Enrollment Program","Enrollment Start Date","Welcome Email Sent At","Welcome Email Status","Notes","Internal Notes","Submitted At"],n=r=>{if(r==null)return"";const i=String(r).replace(/"/g,'""');return/[",\n]/.test(i)?`"${i}"`:i},a=[s.join(",")];for(const r of t)a.push([r.id,r.campus_name,r.first_name,r.last_name,r.email,r.phone,r.program_interest,r.preferred_date,r.status,r.scheduled_at,r.assigned_advisor,r.confirmation_sent_at||"",r.reminder_sent_at||"",r.sms_opt_in?"yes":"no",r.sms_reminder_sent_at||"",r.sms_reminder_status||"",r.day_of_sms_sent_at||"",r.day_of_sms_status||"",r.enrolled_at?"yes":"no",r.enrolled_at||"",r.enrollment_program||"",r.enrollment_start_date||"",r.enrollment_email_sent_at||"",r.enrollment_email_status||"",r.notes,r.internal_notes,r.created_at].map(n).join(","));return a.join(` 1243`)}const Zee=t=>{const s=Vee(t),n=new Blob([s],{type:"text/csv;charset=utf-8;"}),a=URL.createObjectURL(n),r=document.createElement("a");r.href=a,r.download=`campus-tour-requests-${new Date().toISOString().split("T")[0]}.csv`,document.body.appendChild(r),r.click(),document.body.removeChild(r),URL.revokeObjectURL(a)};function Yee(){const[t,s]=d.useState([]),[n,a]=d.useState(!0),[r,i]=d.useState(!1),[o,l]=d.useState(null),[c,u]=d.useState("all"),[p,m]=d.useState("all"),[x,h]=d.useState("all"),[y,v]=d.useState(""),[g,N]=d.useState(null),[b,f]=d.useState([]),[j,S]=d.useState("requests"),w=B=>{const A=Date.now()+Math.random();f(z=>[...z,{...B,id:A}]),setTimeout(()=>f(z=>z.filter(M=>M.id!==A)),6e3)},_=B=>f(A=>A.filter(z=>z.id!==B)),C=async()=>{l(null);const{data:B,error:A}=await O.from("campus_tour_requests").select("*").order("created_at",{ascending:!1});A&&l(A.message),s(B||[]),a(!1),i(!1)};d.useEffect(()=>{C();const B=O.channel("campus-tour-requests-admin").on("postgres_changes",{event:"*",schema:"public",table:"campus_tour_requests"},()=>C()).subscribe();return()=>{O.removeChannel(B)}},[]);const E=d.useMemo(()=>{const B=y.trim().toLowerCase();return t.filter(A=>{if(c!=="all"&&A.campus_slug!==c)return!1;if(p==="enrolled"){if(!A.enrolled_at)return!1}else if(p!=="all"&&A.status!==p)return!1;return!(p==="enrolled"&&x!=="all"&&(A.enrollment_program||"")!==x||B&&!`${A.first_name} ${A.last_name} ${A.email} ${A.phone||""} ${A.program_interest||""} ${A.enrollment_program||""}`.toLowerCase().includes(B))})},[t,c,p,x,y]),P=d.useMemo(()=>{const B={total:t.length,new:0,scheduled:0,completed:0,noShow:0,enrolled:0};for(const A of t)A.status==="new"?B.new++:A.status==="scheduled"?B.scheduled++:A.status==="completed"?B.completed++:A.status==="no-show"&&B.noSh
1243ow++,A.enrolled_at&&B.enrolled++;return B},[t]),F=d.useMemo(()=>{const B=new Map;for(const A of t)A.enrolled_at&&A.enrollment_program&&B.set(A.enrollment_program,(B.get(A.enrollment_program)||0)+1);return Array.from(B.entries()).sort((A,z)=>z[1]-A[1]||A[0].localeCompare(z[0])).map(([A,z])=>({program:A,count:z}))},[t]);d.useEffect(()=>{p!=="enrolled"&&x!=="all"&&h("all")},[p,x]);const I=t.find(B=>B.id===g)||null,D=async(B,A)=>{const{error:z}=await O.from("campus_tour_requests").update({...A,updated_at:new Date().toISOString()}).eq("id",B);return z?(w({kind:"error",title:"Update failed",body:z.message}),!1):(s(M=>M.map(R=>R.id===B?{...R,...A}:R)),!0)},L=async(B,A,z)=>{try{const{data:M,error:R}=await O.functions.invoke("send-campus-tour-confirmation",{body:{tourId:B.id,campusSlug:B.campus_slug,campusName:B.campus_name,visitorEmail:B.email,visitorName:`${B.first_name} ${B.last_name}`.trim(),visitorPhone:B.phone,programInterest:B.program_interest,scheduledAt:A,assignedAdvisor:z||null,visitorNotes:B.notes}});if(R)throw new Error(R.message);if(M&&M.success===!1)throw new Error(M.error||"Email send failed");const T=new Date().toISOString();return await D(B.id,{confirmation_sent_at:T,confirmation_email_status:"sent"}),w({kind:"success",title:"Confirmation email sent",body:`${B.first_name} ${B.last_name} has been notified at ${B.email} with a calendar invite.`}),!0}catch(M){return console.error("Tour confirmation email failed:",M),await D(B.id,{confirmation_email_status:"failed"}),w({kind:"error",title:"Email could not be sent",body:(M==null?void 0:M.message)||"Please try again or contact the visitor manually."}),!1}},V=async(B,A)=>{const z=(A==null?void 0:A.enrollmentProgram)??B.enrollment_program??B.program_interest??"",M=(A==null?void 0:A.enrollmentStartDate)??B.enrollment_start_date??null,R=(A==null?void 0:A.assignedAdvisor)??B.assigned_advisor??null;if(!z)return w({kind:"error",title:"Welcome email not sent",body:"No enrollment program is set on this record."}),!1;try{const{data:T,error:U}=await O.functions.invoke("send-enrollment-welcome",{body:{tourId:B.id,campusSlug:B.campus_slug,campusName:B.campus_name,visitorEmail:B.email,visitorName:`${B.first_name} ${B.last_name}`.trim(),enrollmentProgram:z,enrollmentStartDate:M,assignedAdvisor:R}});if(U)throw new Error(U.message);if(T&&T.success===!1)throw new Error(T.error||"Email send failed");const q=new Date().toISOString();return await D(B.id,{enrollment_email_sent_at:q,enrollment_email_status:"sent"}),w({kind:"success",title:"Welcome email sent",body:`${B.first_name} ${B.last_name} has been welcomed to ${z} at ${B.email}.`}),!0}catch(T){return console.error("Enrollment welcome email failed:",T),await D(B.id,{enrollment_email_status:"failed"}),w({kind:"error",title:"Welcome email could not be sent",body:(T==null?void 0:T.message)||"Please try again â the enrollment record was saved."}),!1}};return e.jsxs("div",{className:"min-h-screen",style:{background:nN},children:[e.jsx("header",{className:"sticky top-0 z-30 border-b",style:{background:`linear-gradient(180deg, ${k} 0%, ${Yy} 100%)`,borderColor:`${$}33`,color:nN},children:e.jsxs("div",{className:"max-w-[1400px] mx-auto px-4 lg:px-8 py-4 flex items-center gap-4",children:[e.jsxs(be,{to:"/",className:"flex items-center gap-2 text-xs font-semibold opacity-80 hover:opacity-100 transition-opacity",style:{color:Ph},children:[e.jsx(Je,{size:14})," Back to site"]}),e.jsx("div",{className:"h-6 w-px",style:{background:`${$}55`}}),e.jsxs("div",{className:"flex-1",children:[e.jsx("p",{className:"text-[10px] uppercase tracking-[0.4em] font-semibold",style:{color:Ph},children:"Zorganics Admin"}),e.jsx("h1",{className:"text-xl lg:text-2xl font-bold leading-tight",style:{color:$,fontFamily:"'Playfair Display', Georgia, serif"},children:"Campus Tour Requests"})]}),e.jsxs("button",{onClick:()=>{i(!0),C()},disabled:r,className:"hidden sm:inline-flex items-center gap-1.5 px-3 py-1.5 rounded-lg text-xs font-semibold transition-all disabled:opacity-50",style:{background:`${$}1A`,color:Ph,border:`1px solid ${$}55`},children:[e.jsx(Be,{size:12,className:r?"animate-spin":""})," Refresh"]}),e.jsxs("button",{onClick:()=>Zee(E),className:"inline-flex items-center gap-1.5 px-3 py-1.5 rounded-lg text-xs font-bold transition-all hover:-translate-y-0.5",style:{background:`linear-gradient(135deg, ${$}, ${cs})`,color:k},children:[e.jsx(us,{size:12})," Export CSV",e.jsx("span",{className:"ml-1 px-1.5 py-0.5 rounded text-[10px]",style:{background:`${k}22`},children:E.length})]})]})}),e.jsxs("div",{className:"max-w-[1400px] mx-auto px-4 lg:px-8 py-6 lg:py-8",children:[e.jsxs("div",{className:"grid grid-cols-2 lg:grid-cols-6 gap-3 mb-6",children:[e.jsx(ru,{label:"Total Requests",value:P.total,icon:mn,accent:k}),e.jsx(ru,{label:"New / Pending",value:P.new,icon:Mt,accent:"#1E40AF"}),e.jsx(ru,{label:"Scheduled",value:P.scheduled,icon:Ii,accent:"#065F46"}),e.jsx(ru,{label:"Completed",value:P.completed,icon:Ue,accent:"#374151"}),e.jsx(ru,{label:"No-Show",value:P.noShow,icon:Ke,accent:"#991B1B"}),e.jsx(ru,{label:"Enrolled",value:P.enrolled,icon:Is,accent:cs})]}),e.jsx("div",{className:"flex items-center gap-1 mb-5 p-1 rounded-xl",style:{background:"#fff",border:`1px solid ${k}15`,boxShadow:`0 2px 12px ${k}08`,width:"fit-content"},children:[{key:"requests",label:"Requests",icon:mn},{key:"analytics",label:"Analytics",icon:La}].map(B=>{const A=j===B.key,z=B.icon;return e.jsxs("button",{onClick:()=>S(B.key),className:"inline-flex items-center gap-2 px-4 py-2 rounded-lg text-xs font-bold uppercase tracking-[0.15em] transition-all",style:{background:A?`linear-gradient(135deg, ${k}, ${Yy})`:"transparent",color:A?$:k,boxShadow:A?`0 4px 12px ${k}33`:"none"},children:[e.jsx(z,{size:13}),B.label]},B.key)})}),j==="requests"&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"rounded-xl p-4 lg:p-5 mb-5 space-y-4",style:{background:"#fff",border:`1px solid ${k}15`,boxShadow:`0 2px 12px ${k}08`},children:[e.jsxs("div",{children:[e.jsxs("p",{className:"text-[10px] uppercase tracking-[0.3em] font-semibold mb-2 flex items-center gap-1.5",style:{color:cs},children:[e.jsx(zt,{size:11})," Campus"]}
1243),e.jsx("div",{className:"flex flex-wrap gap-2",children:Hee.map(B=>{const A=c===B.slug,z=B.slug==="all"?t.length:t.filter(M=>M.campus_slug===B.slug).length;return e.jsxs("button",{onClick:()=>u(B.slug),className:"inline-flex items-center gap-1.5 px-3 py-1.5 rounded-full text-xs font-semibold transition-all",style:{background:A?k:"#fff",color:A?$:k,border:`1px solid ${A?k:k+"22"}`,boxShadow:A?`0 2px 8px ${k}33`:"none"},children:[B.label,e.jsx("span",{className:"px-1.5 py-0.5 rounded text-[10px] font-bold",style:{background:A?`${$}33`:`${k}10`,color:A?$:k},children:z})]},B.slug)})})]}),e.jsxs("div",{children:[e.jsxs("p",{className:"text-[10px] uppercase tracking-[0.3em] font-semibold mb-2 flex items-center gap-1.5",style:{color:cs},children:[e.jsx(ei,{size:11})," Status"]}),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[Ky.map(B=>{const A=p===B.value,z=B.value==="all"?t.length:t.filter(M=>M.status===B.value).length;return e.jsxs("button",{onClick:()=>m(B.value),className:"inline-flex items-center gap-1.5 px-3 py-1.5 rounded-full text-xs font-semibold transition-all",style:{background:A?B.color:B.bg,color:A?"#fff":B.color,border:`1px solid ${A?B.color:B.color+"33"}`},children:[B.label,e.jsx("span",{className:"px-1.5 py-0.5 rounded text-[10px] font-bold",style:{background:A?"#ffffff33":"#ffffff",color:A?"#fff":B.color},children:z})]},B.value)}),(()=>{const B=p==="enrolled",A=P.enrolled;return e.jsxs("button",{onClick:()=>m(B?"all":"enrolled"),className:"inline-flex items-center gap-1.5 px-3 py-1.5 rounded-full text-xs font-semibold transition-all",style:{background:B?`linear-gradient(135deg, ${$}, ${cs})`:`${$}18`,color:B?k:cs,border:`1px solid ${B?cs:$+"88"}`,boxShadow:B?`0 2px 8px ${$}55`:"none"},title:"Filter to verified enrollments (enrolled_at IS NOT NULL)",children:[e.jsx(Is,{size:11}),"Enrolled",e.jsx("span",{className:"px-1.5 py-0.5 rounded text-[10px] font-bold",style:{background:B?`${k}22`:"#fff",color:B?k:cs},children:A})]})})()]}),p==="enrolled"&&F.length>0&&e.jsxs("div",{className:"mt-3 rounded-lg p-3 flex flex-col sm:flex-row sm:items-center gap-2",style:{background:`${$}10`,border:`1px solid ${$}55`},children:[e.jsxs("label",{htmlFor:"enrollment-program-filter",className:"text-[10px] uppercase tracking-[0.25em] font-bold flex items-center gap-1.5 shrink-0",style:{color:cs},children:[e.jsx(_t,{size:11})," Filter by Program"]}),e.jsxs("select",{id:"enrollment-program-filter",value:x,onChange:B=>h(B.target.value),className:"flex-1 px-3 py-1.5 rounded-md text-xs font-semibold focus:outline-none focus:ring-2 bg-white",style:{border:`1px solid ${$}88`,color:k},children:[e.jsxs("option",{value:"all",children:["All programs (",P.enrolled,")"]}),F.map(({program:B,count:A})=>e.jsxs("option",{value:B,children:[B," (",A,")"]},B))]}),x!=="all"&&e.jsxs("button",{onClick:()=>h("all"),className:"inline-flex items-center gap-1 px-2 py-1 rounded-md text-[10px] font-bold uppercase tracking-wider transition-all hover:bg-white",style:{color:cs,border:`1px solid ${$}66`},children:[e.jsx(Ke,{size:10})," Clear"]})]}),p==="enrolled"&&F.length===0&&e.jsx("p",{className:"text-[11px] mt-2 italic",style:{color:"#888"},children:"No verified enrollments yet â mark a student as enrolled from the detail drawer to populate this list."})]}),e.jsxs("div",{className:"relative",children:[e.jsx(Bt,{size:14,className:"absolute left-3 top-1/2 -translate-y-1/2",style:{color:"#999"}}),e.jsx("input",{value:y,onChange:B=>v(B.target.value),placeholder:"Search by name, email, phone, or programâ¦",className:"w-full pl-9 pr-3 py-2.5 rounded-lg text-sm focus:outline-none focus:ring-2",style:{border:`1px solid ${k}22`,color:k}})]})]}),e.jsx("div",{className:"rounded-xl overflow-hidden",style:{background:"#fff",border:`1px solid ${k}15`,boxShadow:`0 2px 12px ${k}08`},children:n?e.jsx("div",{className:"py-20 flex items-center justify-center",children:e.jsx(de,{size:28,className:"animate-spin",style:{color:cs}})}):o?e.jsxs("div",{className:"py-12 text-center",children:[e.jsx(Mt,{size:32,className:"mx-auto mb-2",style:{color:"#B91C1C"}}),e.jsxs("p",{className:"text-sm font-semibold",style:{color:"#B91C1C"},children:["Failed to load: ",o]})]}):E.length===0?e.jsxs("div",{className:"py-20 text-center",children:[e.jsx(mn,{size:36,className:"mx-auto mb-3",style:{color:cs,opacity:.4}}),e.jsx("p",{className:"text-sm font-semibold",style:{color:k},children:"No tour requests match these filters."}),e.jsx("p",{className:"text-xs mt-1",style:{color:"#666"},children:"Try clearing filters or refresh to load new submissions."})]}):e.jsx("div",{className:"overflow-x-auto",children:e.jsxs("table",{className:"w-full text-sm",children:[e.jsx("thead",{children:e.jsxs("tr",{style:{background:`${k}06`,borderBottom:`1px solid ${k}15`},children:[e.jsx(el,{children:"Campus"}),e.jsx(el,{children:"Name"}),e.jsx(el,{children:"Contact"}),e.jsx(el,{children:"Program"}),e.jsx(el,{children:"Preferred"}),e.jsx(el,{children:"Status"}),e.jsx(el,{children:"Submitted"}),e.jsx(el,{})]})}),e.jsx("tbody",{children:E.map(B=>{const A=YI(B.status);return e.jsxs("tr",{className:"cursor-pointer transition-colors hover:bg-amber-50/40",style:{borderBottom:`1px solid ${k}10`},onClick:()=>N(B.id),children:[e.jsx(tl,{children:e.jsxs("span",{className:"inline-flex items-center gap-1 px-2 py-0.5 rounded-full text-[10px] font-bold uppercase tracking-wider",style:{background:`${k}10`,color:k},children:[e.jsx(zt,{size:9})," ",B.campus_name]})}),e.jsxs(tl,{children:[e.jsxs("div",{className:"font-semibold",style:{color:k},children:[B.first_name," ",B.last_name]}),B.assigned_advisor&&e.jsxs("div",{className:"text-[11px]",style:{color:"#888"}
1243,children:[e.jsx(yr,{size:10,className:"inline mr-0.5 -mt-0.5"})," ",B.assigned_advisor]})]}),e.jsxs(tl,{children:[e.jsx("div",{className:"text-xs",style:{color:k},children:B.email}),B.phone&&e.jsxs("div",{className:"text-[11px] flex items-center gap-1",style:{color:"#777"},children:[B.phone,B.sms_opt_in&&e.jsxs("span",{className:"inline-flex items-center gap-0.5 px-1 py-0.5 rounded text-[8px] font-bold uppercase tracking-wider",style:{background:"#DBEAFE",color:"#1E40AF"},title:"Visitor opted in to SMS reminders",children:[e.jsx(jr,{size:8})," SMS OK"]})]})]}),e.jsx(tl,{children:e.jsx("span",{className:"text-xs",style:{color:"#444"},children:B.program_interest||e.jsx("span",{style:{color:"#aaa"},children:"â"})})}),e.jsxs(tl,{children:[B.preferred_date?e.jsxs("span",{className:"text-xs",style:{color:k},children:[e.jsx(Ii,{size:11,className:"inline mr-1 -mt-0.5"}),new Date(B.preferred_date).toLocaleDateString()]}):e.jsx("span",{style:{color:"#aaa"},children:"â"}),B.scheduled_at&&e.jsxs("div",{className:"text-[10px] mt-0.5 font-semibold",style:{color:"#065F46"},children:["â ",new Date(B.scheduled_at).toLocaleString([],{month:"short",day:"numeric",hour:"numeric",minute:"2-digit"})]}),(B.confirmation_sent_at||B.reminder_sent_at||B.sms_reminder_sent_at||B.day_of_sms_sent_at)&&e.jsxs("div",{className:"flex flex-wrap gap-1 mt-1",children:[B.confirmation_sent_at&&e.jsxs("span",{className:"inline-flex items-center gap-1 px-1.5 py-0.5 rounded text-[9px] font-bold uppercase tracking-wider",style:{background:"#D1FAE5",color:"#065F46"},title:`Confirmation email sent ${new Date(B.confirmation_sent_at).toLocaleString()}`,children:[e.jsx(gd,{size:9})," Email Sent"]}),B.reminder_sent_at&&e.jsxs("span",{className:"inline-flex items-center gap-1 px-1.5 py-0.5 rounded text-[9px] font-bold uppercase tracking-wider",style:{background:"#FEF3C7",color:"#92400E"},title:`24h reminder sent ${new Date(B.reminder_sent_at).toLocaleString()}`,children:[e.jsx(Di,{size:9})," Reminder Sent"]}),B.sms_reminder_sent_at&&e.jsxs("span",{className:"inline-flex items-center gap-1 px-1.5 py-0.5 rounded text-[9px] font-bold uppercase tracking-wider",style:{background:"#DBEAFE",color:"#1E40AF"},title:`24h SMS reminder sent ${new Date(B.sms_reminder_sent_at).toLocaleString()}`,children:[e.jsx(jr,{size:9})," SMS Sent"]}),B.day_of_sms_sent_at&&e.jsxs("span",{className:"inline-flex items-center gap-1 px-1.5 py-0.5 rounded text-[9px] font-bold uppercase tracking-wider",style:{background:"#CCFBF1",color:"#0F766E"},title:`2-hour day-of SMS sent ${new Date(B.day_of_sms_sent_at).toLocaleString()}`,children:[e.jsx(dt,{size:9})," Day-Of SMS"]})]})]}),e.jsxs(tl,{children:[e.jsx("span",{className:"inline-block px-2 py-0.5 rounded-full text-[10px] font-bold uppercase tracking-wider",style:{background:A.bg,color:A.color},children:A.label}),B.enrolled_at&&e.jsx("div",{className:"mt-1",children:e.jsxs("span",{className:"inline-flex items-center gap-1 px-1.5 py-0.5 rounded text-[9px] font-bold uppercase tracking-wider",style:{background:`${$}22`,color:cs,border:`1px solid ${$}66`},title:`Enrolled ${new Date(B.enrolled_at).toLocaleString()}${B.enrollment_program?" · "+B.enrollment_program:""}`,children:[e.jsx(Is,{size:9})," Enrolled"]})})]}),e.jsx(tl,{children:e.jsxs("span",{className:"text-[11px]",style:{color:"#777"},children:[new Date(B.created_at).toLocaleDateString(),e.jsx("br",{}),e.jsx("span",{style:{color:"#aaa"},children:new Date(B.created_at).toLocaleTimeString([],{hour:"numeric",minute:"2-digit"})})]})}),e.jsx(tl,{children:e.jsx(Nr,{size:16,style:{color:cs}})})]},B.id)})})]})})}),e.jsxs("p",{className:"text-center text-[11px] mt-4",style:{color:"#888"},children:["Showing ",e.jsx("strong",{children:E.length})," of ",t.length," total tour requests · realtime"]})]}),j==="analytics"&&(n?e.jsx("div",{className:"rounded-xl py-20 flex items-center justify-center",style:{background:"#fff",border:`1px solid ${k}15`},children:e.jsx(de,{size:28,className:"animate-spin",style:{color:cs}})}):e.jsx($ee,{rows:t}))]}),I&&e.jsx(Kee,{row:I,onClose:()=>N(null),onUpdate:B=>D(I.id,B),onSendConfirmation:L,onSendEnrollmentWelcome:V}),e.jsx(Qee,{toasts:b,onDismiss:_})]})}const el=({children:t})=>e.jsx("th",{className:"text-left px-4 py-3 text-[10px] uppercase tracking-[0.18em] font-bold",style:{color:cs},children:t}),tl=({children:t})=>e.jsx("td",{className:"px-4 py-3 align-top",children:t}),ru=({label:t,value:s,icon:n,accent:a})=>e.jsxs("div",{className:"rounded-xl p-4 transition-all hover:-translate-y-0.5",style:{background:"#fff",border:`1px solid ${k}15`,boxShadow:`0 2px 12px ${k}08`},children:[e.jsxs("div",{className:"flex items-center justify-between mb-1.5",children:[e.jsx("p",{className:"text-[10px] uppercase tracking-[0.25em] font-semibold",style:{color:"#777"},children:t}),e.jsx("div",{className:"w-7 h-7 rounded-full flex items-center justify-center",style:{background:`${a}15`,color:a},children:e.jsx(n,{size:13})})]}),e.jsx("p",{className:"text-2xl font-bold",style:{color:k,fontFamily:"'Playfair Display', Georgia, serif"},children:s})]}),Kee=({row:t,onClose:s,onUpdate:n,onSendConfirmation:a,onSendEnrollmentWelcome:r})=>{const i=t.scheduled_at?t.scheduled_at.slice(0,16):t.preferred_date?`${t.preferred_date}T10:00`:"",[o,l]=d.useState(i),[c,u]=d.useState(t.assigned_advisor||""),[p,m]=d.useState(t.internal_notes||""),[x,h]=d.useState(t.enrollment_program||t.program_interest||""),[y,v]=d.useState(t.enrollment_start_date||""),[g,N]=d.use
1243State(!1),[b,f]=d.useState(!1),[j,S]=d.useState(!1),[w,_]=d.useState(!1),C=YI(t.status),E=L=>{n({status:L})},P=async()=>{N(!0);const L=!!o,V=o?new Date(o).toISOString():null,B=await n({scheduled_at:V,assigned_advisor:c||null,internal_notes:p||null,status:L?"scheduled":t.status});if(N(!1),B&&L&&V){f(!0);const A={...t,scheduled_at:V,assigned_advisor:c||null,internal_notes:p||null,status:"scheduled"};await a(A,V,c),f(!1)}},F=async()=>{if(!o)return;f(!0);const L=new Date(o).toISOString();await a(t,L,c),f(!1)},I=!!t.confirmation_sent_at,D=g?"Savingâ¦":b?"Sending emailâ¦":o?"Mark as Scheduled & Save":"Save Changes";return e.jsx("div",{className:"fixed inset-0 z-50 flex justify-end",style:{background:"rgba(15, 5, 8, 0.55)"},onClick:s,role:"dialog","aria-modal":"true",children:e.jsxs("div",{className:"w-full max-w-xl h-full overflow-y-auto",style:{background:"#fff",boxShadow:`-12px 0 40px ${Yy}55`},onClick:L=>L.stopPropagation(),children:[e.jsxs("div",{className:"sticky top-0 z-10 px-6 py-5 flex items-start justify-between gap-3",style:{background:`linear-gradient(180deg, ${k} 0%, ${Yy} 100%)`,color:nN,borderBottom:`1px solid ${$}33`},children:[e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("p",{className:"text-[10px] uppercase tracking-[0.3em] font-semibold",style:{color:Ph},children:["Tour Request · ",t.campus_name]}),e.jsxs("h2",{className:"text-xl font-bold mt-1 leading-tight",style:{color:$,fontFamily:"'Playfair Display', Georgia, serif"},children:[t.first_name," ",t.last_name]}),e.jsx("span",{className:"inline-block mt-2 px-2 py-0.5 rounded-full text-[10px] font-bold uppercase tracking-wider",style:{background:C.bg,color:C.color},children:C.label})]}),e.jsx("button",{onClick:s,className:"w-9 h-9 rounded-full flex items-center justify-center",style:{background:`${$}22`,color:Ph,border:`1px solid ${$}55`},"aria-label":"Close drawer",children:e.jsx(Ke,{size:16})})]}),e.jsxs("div",{className:"p-6 space-y-6",children:[e.jsxs(mg,{title:"Contact",children:[e.jsx(iu,{icon:Ye,label:"Email",children:e.jsx("a",{href:`mailto:${t.email}`,className:"text-sm font-semibold hover:underline",style:{color:k},children:t.email})}),t.phone&&e.jsx(iu,{icon:Qt,label:"Phone",children:e.jsx("a",{href:`tel:${t.phone}`,className:"text-sm font-semibold hover:underline",style:{color:k},children:t.phone})}),e.jsx(iu,{icon:_t,label:"Program of Interest",children:e.jsx("span",{className:"text-sm",style:{color:k},children:t.program_interest||e.jsx("em",{style:{color:"#aaa"},children:"Not specified"})})}),e.jsx(iu,{icon:Ii,label:"Preferred Date",children:e.jsx("span",{className:"text-sm",style:{color:k},children:t.preferred_date?new Date(t.preferred_date).toLocaleDateString(void 0,{weekday:"long",month:"long",day:"numeric",year:"numeric"}):e.jsx("em",{style:{color:"#aaa"},children:"Flexible"})})}),e.jsx(iu,{icon:dt,label:"Submitted",children:e.jsx("span",{className:"text-sm",style:{color:k},children:new Date(t.created_at).toLocaleString()})}),t.notes&&e.jsx(iu,{icon:mn,label:"Visitor Notes",children:e.jsx("p",{className:"text-sm whitespace-pre-wrap",style:{color:"#444"},children:t.notes})})]}),e.jsxs(mg,{title:"Schedule & Assign",children:[e.jsxs("div",{className:"grid sm:grid-cols-2 gap-3",children:[e.jsx(Fp,{label:"Confirmed Date & Time",children:e.jsx("input",{type:"datetime-local",value:o,onChange:L=>l(L.target.value),className:"w-full px-3 py-2 rounded-lg text-sm focus:outline-none focus:ring-2",style:{border:`1px solid ${k}22`,color:k}})}),e.jsx(Fp,{label:"Assigned Advisor",children:e.jsxs("select",{value:c,onChange:L=>u(L.target.value),className:"w-full px-3 py-2 rounded-lg text-sm focus:outline-none focus:ring-2 bg-white",style:{border:`1px solid ${k}22`,color:k},children:[e.jsx("option",{value:"",children:"â Select advisor â"}),Gee.map(L=>e.jsx("option",{value:L==="Unassigned"?"":L,children:L},L))]})})]}),e.jsx(Fp,{label:"Internal Notes (admin-only)",children:e.jsx("textarea",{value:p,onChange:L=>m(L.target.value),rows:3,placeholder:"Add advisor notes, follow-up reminders, scholarship interest, etc.",className:"w-full px-3 py-2 rounded-lg text-sm focus:outline-none focus:ring-2 resize-none",style:{border:`1px solid ${k}22`,color:k}})}),o&&e.jsxs("div",{className:"rounded-lg p-3 flex items-start gap-2.5",style:{background:"#FFF8E5",border:`1px solid ${$}55`},children:[e.jsx(gd,{size:16,style:{color:cs,flexShrink:0,marginTop:2}}),e.jsxs("div",{className:"text-[12px] leading-relaxed",style:{color:k},children:[e.jsx("strong",{children:"Saving will email the visitor."})," A confirmation email with the full address, Google Maps link, parking instructions, advisor name, and a calendar",e.jsx("code",{className:"px-1 mx-0.5 rounded",style:{background:`${k}10`},children:".ics"}),"attachment will be sent to ",e.jsx("strong",{children:t.email}),"."]})]}),e.jsxs("button",{onClick:P,disabled:g||b,className:"w-full py-3 rounded-lg font-bold text-sm uppercase tracking-[0.15em] transition-all hover:-translate-y-0.5 disabled:opacity-60 inline-flex items-center justify-center gap-2",style:{background:`linear-gradient(135deg, ${$}, ${cs})`,color:k,boxShadow:`0 6px 20px ${$}33`},children:[(g||b)&&e.jsx(de,{size:14,className:"animate-spin"}),D]}),o&&(I||t.confirmation_email_status==="failed")&&e.jsxs("div",{className:"flex items-center justify-between gap-3 pt-2 mt-1 border-t",style:{borderColor:`${k}15`},children:[e.jsx("div",{className:"text-[11px]",style:{color:"#666"},children:I?e.jsxs("span",{className:"inline-flex items-center gap-1.5",children:[e.jsx(gd,{size:12,style:{color:"#065F46"}}),"Confirmation sent ",new Date(t.confirmation_sent_at).toLocaleStr
1243ing([],{month:"short",day:"numeric",hour:"numeric",minute:"2-digit"})]}):e.jsx("span",{style:{color:"#991B1B"},children:"Last email attempt failed"})}),e.jsxs("button",{onClick:F,disabled:b,className:"inline-flex items-center gap-1.5 px-3 py-1.5 rounded-md text-xs font-semibold transition-all hover:bg-amber-50 disabled:opacity-50",style:{border:`1px solid ${$}88`,color:k,background:"#fff"},children:[b?e.jsx(de,{size:12,className:"animate-spin"}):e.jsx(Hs,{size:12}),"Resend Email"]})]})]}),e.jsx(mg,{title:"Enrollment Tracking",children:t.enrolled_at?e.jsxs("div",{className:"rounded-lg p-4 space-y-3",style:{background:`linear-gradient(135deg, ${$}18, ${$}08)`,border:`1.5px solid ${$}66`},children:[e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx("div",{className:"w-10 h-10 rounded-full flex items-center justify-center shrink-0",style:{background:`linear-gradient(135deg, ${$}, ${cs})`,color:k},children:e.jsx(Is,{size:18})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"text-sm font-bold leading-tight",style:{color:k},children:"Verified Enrolled"}),e.jsxs("p",{className:"text-[12px] mt-0.5",style:{color:"#555"},children:["Recorded ",new Date(t.enrolled_at).toLocaleString([],{month:"short",day:"numeric",year:"numeric",hour:"numeric",minute:"2-digit"})]}),t.enrollment_program&&e.jsxs("p",{className:"text-[12px] mt-1",style:{color:k},children:[e.jsx("span",{className:"font-semibold",children:"Program:"})," ",t.enrollment_program]}),t.enrollment_start_date&&e.jsxs("p",{className:"text-[12px] mt-1",style:{color:k},children:[e.jsx("span",{className:"font-semibold",children:"Expected Start:"})," ",new Date(`${t.enrollment_start_date}T12:00:00`).toLocaleDateString(void 0,{weekday:"long",month:"long",day:"numeric",year:"numeric"})]})]})]}),e.jsxs("div",{className:"rounded-md p-2.5 flex items-center justify-between gap-2 flex-wrap",style:{background:"#fff",border:`1px solid ${$}44`},children:[e.jsx("div",{className:"text-[11px] flex items-center gap-1.5 min-w-0",style:{color:"#555"},children:t.enrollment_email_sent_at?e.jsxs(e.Fragment,{children:[e.jsx(gd,{size:12,style:{color:"#065F46",flexShrink:0}}),e.jsx("span",{style:{color:"#065F46"},className:"font-semibold",children:"Welcome email sent"}),e.jsxs("span",{style:{color:"#888"},className:"truncate",children:["· ",new Date(t.enrollment_email_sent_at).toLocaleString([],{month:"short",day:"numeric",hour:"numeric",minute:"2-digit"})]})]}):t.enrollment_email_status==="failed"?e.jsxs(e.Fragment,{children:[e.jsx(Mt,{size:12,style:{color:"#991B1B",flexShrink:0}}),e.jsx("span",{style:{color:"#991B1B"},className:"font-semibold",children:"Welcome email failed"}),e.jsx("span",{style:{color:"#888"},children:"· retry recommended"})]}):e.jsxs(e.Fragment,{children:[e.jsx(dt,{size:12,style:{color:cs,flexShrink:0}}),e.jsx("span",{style:{color:cs},className:"font-semibold",children:"Welcome email pending"})]})}),e.jsxs("button",{onClick:async()=>{_(!0),await r(t),_(!1)},disabled:w,className:"inline-flex items-center gap-1.5 px-3 py-1.5 rounded-md text-xs font-semibold transition-all hover:bg-amber-50 disabled:opacity-50 shrink-0",style:{border:`1px solid ${$}88`,color:k,background:"#fff"},children:[w?e.jsx(de,{size:12,className:"animate-spin"}):t.enrollment_email_sent_at?e.jsx(Hs,{size:12}):e.jsx(Ye,{size:12}),t.enrollment_email_sent_at?"Resend Welcome":"Send Welcome"]})]}),e.jsx(Wee,{tourId:t.id,openCount:t.enrollment_email_open_count,clickCount:t.enrollment_email_click_count,openedAt:t.enrollment_email_opened_at,clickedAt:t.enrollment_email_clicked_at,deliveredAt:t.enrollment_email_delivered_at}),e.jsxs("button",{onClick:async()=>{confirm("Remove enrollment record? This will reset enrolled_at, enrollment_program, enrollment_start_date, and the welcome email status to null.")&&(S(!0),await n({enrolled_at:null,enrollment_program:null,enrollment_start_date:null,enrollment_email_sent_at:null,enrollment_email_status:null}),S(!1))},disabled:j||w,className:"w-full inline-flex items-center justify-center gap-1.5 px-3 py-2 rounded-md text-xs font-semibold transition-all hover:bg-white disabled:opacity-50",style:{border:`1px solid ${k}33`,color:k,background:"#fff"},children:[j?e.jsx(de,{size:12,className:"animate-spin"}):e.jsx(Ey,{size:12}),"Undo Enrollment"]})]}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"grid sm:grid-cols-2 gap-3",children:[e.jsx(Fp,{label:"Enrolled Program",children:e.jsx("input",{type:"text",value:x,onChange:L=>h(L.target.value),placeholder:t.program_interest||"e.g., Master Esthetics, Cosmetologyâ¦",className:"w-full px-3 py-2 rounded-lg text-sm focus:outline-none focus:ring-2",style:{border:`1px solid ${k}22`,color:k}})}),e.jsx(Fp,{label:"Expected Start Date",children:e.jsx("input",{type:"date",value:y,onChange:L=>v(L.target.value),className:"w-full px-3 py-2 rounded-lg text-sm focus:outline-none focus:ring-2",style:{border:`1px solid ${k}22`,color:k}})})]}),e.jsxs("div",{className:"rounded-lg p-3 flex items-start gap-2.5",style:{background:"#FFF8E5",border:`1px solid ${$}55`},children:[e.jsx(Ye,{size:16,style:{color:cs,flexShrink:0,marginTop:2}}),e.jsxs("div",{className:"text-[12px] leading-relaxed",style:{color:k},children:[e.jsx("strong",{children:"Marking as enrolled will send a welcome email."})," A branded enrollment-welcome email â with the program name, expected start date, advisor contact, a next-steps checklist (financial aid, orientation, supply kit), and a student portal link â will be dispatched to"," ",e.jsx("strong",{children:t.email}),"."]})]}),e.jsxs("button",{onClick:async()=>
1243{if(!x.trim()){alert("Please enter the program the student enrolled in.");return}S(!0);const L=x.trim(),V=y||null,B=await n({enrolled_at:new Date().toISOString(),enrollment_program:L,enrollment_start_date:V,status:t.status==="no-show"||t.status==="cancelled"?t.status:"completed"});if(S(!1),!B){alert("Could not save enrollment. Please try again.");return}_(!0),await r({...t,enrollment_program:L,enrollment_start_date:V,enrolled_at:new Date().toISOString()},{enrollmentProgram:L,enrollmentStartDate:V,assignedAdvisor:t.assigned_advisor}),_(!1)},disabled:j||w||!x.trim(),className:"w-full py-3 rounded-lg font-bold text-sm uppercase tracking-[0.15em] transition-all hover:-translate-y-0.5 disabled:opacity-50 inline-flex items-center justify-center gap-2",style:{background:`linear-gradient(135deg, ${$}, ${cs})`,color:k,boxShadow:`0 6px 20px ${$}33`},children:[j||w?e.jsx(de,{size:14,className:"animate-spin"}):e.jsx(Is,{size:14}),j?"Recordingâ¦":w?"Sending welcome emailâ¦":"Mark as Enrolled & Send Welcome Email"]}),e.jsx("p",{className:"text-[11px] mt-1",style:{color:"#888"},children:"Records a verified enrollment timestamp, dispatches the branded welcome email, and powers the conversion funnel and advisor leaderboard in the Analytics tab."})]})}),e.jsxs(mg,{title:"Status Pipeline",children:[e.jsx("div",{className:"grid grid-cols-2 sm:grid-cols-3 gap-2",children:Ky.filter(L=>L.value!=="all").map(L=>{const V=t.status===L.value;return e.jsx("button",{onClick:()=>E(L.value),className:"px-3 py-2 rounded-lg text-xs font-bold uppercase tracking-wider transition-all",style:{background:V?L.color:L.bg,color:V?"#fff":L.color,border:`1px solid ${V?L.color:L.color+"33"}`},children:L.label},L.value)})}),e.jsx("p",{className:"text-[11px] mt-2",style:{color:"#888"},children:"Click any status to update the pipeline immediately."})]})]})]})})},mg=({title:t,children:s})=>e.jsxs("section",{children:[e.jsx("p",{className:"text-[10px] uppercase tracking-[0.3em] font-bold mb-3",style:{color:cs},children:t}),e.jsx("div",{className:"space-y-3",children:s})]}),iu=({icon:t,label:s,children:n})=>e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx("div",{className:"w-7 h-7 rounded-full flex items-center justify-center shrink-0 mt-0.5",style:{background:`${k}10`,color:k},children:e.jsx(t,{size:13})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"text-[10px] uppercase tracking-wider font-semibold mb-0.5",style:{color:"#888"},children:s}),n]})]}),Fp=({label:t,children:s})=>e.jsxs("div",{children:[e.jsx("label",{className:"block text-[11px] font-semibold uppercase tracking-wider mb-1",style:{color:cs},children:t}),s]}),Qee=({toasts:t,onDismiss:s})=>t.length===0?null:e.jsx("div",{className:"fixed bottom-6 right-6 z-[60] flex flex-col gap-3 max-w-sm w-[calc(100%-3rem)] sm:w-96 pointer-events-none",children:t.map(n=>{const a=n.kind==="success"?{bg:"linear-gradient(135deg, #ECFDF5, #D1FAE5)",border:"#10B981",iconBg:"#10B981",iconColor:"#fff",titleColor:"#065F46",bodyColor:"#047857",Icon:Ue}:n.kind==="error"?{bg:"linear-gradient(135deg, #FEF2F2, #FEE2E2)",border:"#EF4444",iconBg:"#EF4444",iconColor:"#fff",titleColor:"#991B1B",bodyColor:"#B91C1C",Icon:Mt}:{bg:"#fff",border:k,iconBg:k,iconColor:$,titleColor:k,bodyColor:"#444",Icon:gd},r=a.Icon;return e.jsxs("div",{role:"status","aria-live":"polite",className:"pointer-events-auto rounded-xl shadow-2xl p-4 flex items-start gap-3 animate-in slide-in-from-right",style:{background:a.bg,border:`1.5px solid ${a.border}55`,boxShadow:`0 10px 30px ${a.border}33, 0 4px 12px ${k}11`},children:[e.jsx("div",{className:"w-9 h-9 rounded-full flex items-center justify-center shrink-0",style:{background:a.iconBg,color:a.iconColor},children:e.jsx(r,{size:18})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"font-bold text-sm leading-tight",style:{color:a.titleColor},children:n.title}),n.body&&e.jsx("p",{className:"text-xs mt-1 leading-relaxed",style:{color:a.bodyColor},children:n.body})]}),e.jsx("button",{onClick:()=>s(n.id),className:"w-6 h-6 rounded-full flex items-center justify-center shrink-0 transition-colors hover:bg-black/5",style:{color:a.titleColor},"aria-label":"Dismiss",children:e.jsx(Ke,{size:14})})]},n.id)})}),bc="#E6D2A0",vn="#B8962E",Zv="#2A0810",Jee="#5A1A24",ou="#FAF6ED",Qy=`${vn}33`,os="'Playfair Display', Georgia, serif",Xee=({size:t=120})=>
1243e.jsxs("svg",{width:t,height:t,viewBox:"0 0 64 64",fill:"none","aria-hidden":"true",children:[e.jsx("defs",{children:e.jsxs("linearGradient",{id:"silhouette-detail",x1:"0",y1:"0",x2:"0",y2:"1",children:[e.jsx("stop",{offset:"0%",stopColor:"#F4F4F5"}),e.jsx("stop",{offset:"100%",stopColor:"#E4E4E7"})]})}),e.jsx("circle",{cx:"32",cy:"32",r:"31",fill:"url(#silhouette-detail)",stroke:"#D4D4D8",strokeWidth:"1"}),e.jsx("circle",{cx:"32",cy:"25",r:"9",fill:"#A1A1AA"}),e.jsx("path",{d:"M14 56 C 14 44, 22 38, 32 38 C 42 38, 50 44, 50 56 Z",fill:"#A1A1AA"})]}),vc=({eyebrow:t,icon:s,title:n})=>e.jsxs("header",{className:"mb-8 lg:mb-10",children:[e.jsxs("div",{className:"flex items-center gap-3 mb-3",children:[e.jsx("div",{className:"h-[1px] w-10",style:{background:`linear-gradient(90deg, ${vn}, transparent)`}}),e.jsxs("span",{className:"text-[10px] tracking-[0.4em] uppercase font-semibold flex items-center gap-1.5",style:{color:vn},children:[s,t]})]}),e.jsx("h2",{className:"font-bold leading-tight",style:{color:k,fontFamily:os,fontSize:"clamp(1.5rem, 2.6vw, 2rem)",letterSpacing:"-0.01em"},children:n})]}),jc=()=>e.jsxs("div",{className:"my-14 lg:my-20 flex items-center gap-4","aria-hidden":"true",children:[e.jsx("div",{className:"flex-1 h-[1px]",style:{background:Qy}}),e.jsx("div",{className:"w-1.5 h-1.5 rotate-45",style:{background:vn,opacity:.6}}),e.jsx("div",{className:"flex-1 h-[1px]",style:{background:Qy}})]}),ete=()=>{const{slug:t}=Wo(),[s,n]=d.useState(null),[a,r]=d.useState(!0),[i,o]=d.useState(null);if(d.useEffect(()=>{let y=!1;return(async()=>{if(!t){o("No faculty slug provided."),r(!1);return}r(!0),o(null);const{data:g,error:N}=await O.from("faculty_profiles").select("*").eq("slug",t).maybeSingle();y||(N?o(N.message):g?n(g):o("Faculty profile not found."),r(!1))})(),()=>{y=!0}},[t]),a)return e.jsx("div",{className:"min-h-screen flex items-center justify-center",style:{background:ou},children:e.jsxs("div",{className:"flex items-center gap-3",style:{color:k},children:[e.jsx(de,{className:"animate-spin",size:20}),e.jsx("span",{style:{fontFamily:os},className:"italic",children:"Loading faculty profileâ¦"})]})});if(i||!s)return e.jsxs("div",{className:"min-h-screen flex flex-col items-center justify-center p-8 text-center",style:{background:ou},children:[e.jsx("h1",{className:"text-3xl font-bold mb-3",style:{color:k,fontFamily:os},children:"Faculty Profile Not Found"}),e.jsx("p",{className:"text-sm mb-6",style:{color:"#666"},children:i??"We could not locate this faculty member."}),e.jsxs(be,{to:"/",className:"inline-flex items-center gap-2 px-5 py-2.5 rounded-lg text-sm font-semibold",style:{background:`linear-gradient(135deg, ${$}, ${vn})`,color:k},children:[e.jsx(Je,{size:14})," Return Home"]})]});const l=s.is_placeholder,c=s.education_history??[],u=s.publications??[],p=s.areas_of_practice??[],m=s.certifications??[],x=s.awards??[],h=s.gallery??[];return e.jsxs("div",{style:{background:ou,minHeight:"100vh"},children:[e.jsx("div",{className:"border-b",style:{borderColor:Qy,background:"#fff"},children:e.jsxs("div",{className:"max-w-[1100px] mx-auto px-4 lg:px-8 py-4 flex items-center justify-between",children:[e.jsxs(be,{to:"/",className:"inline-flex items-center gap-2 text-xs font-semibold tracking-[0.2em] uppercase hover:opacity-70 transition-opacity",style:{color:vn},children:[e.jsx(Je,{size:14})," Zorganics Institute"]}),e.jsx("span",{className:"text-[10px] tracking-[0.4em] uppercase",style:{color:"#999",fontFamily:os},children:"Faculty Profile"})]})}),e.jsxs("section",{className:"relative overflow-hidden",style:{background:`linear-gradient(165deg, ${k} 0%, ${Zv} 100%)`,color:ou},children:[e.jsx("div",{className:"absolute -top-32 -right-32 w-[28rem] h-[28rem] rounded-full blur-3xl op
1243acity-20",style:{background:$},"aria-hidden":"true"}),e.jsx("div",{className:"absolute -bottom-32 -left-32 w-[24rem] h-[24rem] rounded-full blur-3xl opacity-10",style:{background:$},"aria-hidden":"true"}),e.jsxs("div",{className:"relative max-w-[1100px] mx-auto px-4 lg:px-8 py-20 lg:py-28",children:[e.jsxs("div",{className:"flex items-center gap-3 mb-6",children:[e.jsx("div",{className:"h-[1px] w-12",style:{background:`linear-gradient(90deg, ${$}, transparent)`}}),e.jsx("span",{className:"text-[10px] sm:text-[11px] tracking-[0.5em] uppercase font-semibold",style:{color:bc},children:l?s.position_status_label??"Position Reserved":"Active Faculty Profile"})]}),e.jsx("div",{className:"mb-10",children:l?e.jsx("div",{className:"w-28 h-28 rounded-full flex items-center justify-center",style:{background:"#fff",border:"1.5px dashed #D4D4D8"},children:e.jsx(Xee,{size:88})}):e.jsx("div",{className:"w-28 h-28 rounded-full flex items-center justify-center",style:{background:`linear-gradient(135deg, ${Jee}, ${Zv})`,border:`2px solid ${$}`,boxShadow:`0 0 0 6px ${$}1A, 0 12px 28px ${Zv}AA`},children:e.jsx("span",{style:{color:$,fontFamily:os,fontSize:"2.4rem",fontWeight:700,letterSpacing:"0.05em"},children:s.monogram??s.name.split(" ").map(y=>y[0]).filter(Boolean).slice(0,2).join("").toUpperCase()})})}),e.jsxs("h1",{className:"font-bold leading-[1.05] mb-4",style:{color:$,fontFamily:os,fontSize:"clamp(2.4rem, 5vw, 4rem)",letterSpacing:"-0.015em"},children:[s.name,s.post_nominals&&e.jsx("span",{className:"ml-3 align-baseline",style:{color:bc,fontFamily:os,fontStyle:"italic",fontWeight:400,fontSize:"0.45em",letterSpacing:"0.02em"},children:s.post_nominals})]}),s.title&&e.jsx("p",{className:"italic mb-8",style:{color:bc,fontFamily:os,fontSize:"clamp(1.05rem, 1.6vw, 1.3rem)",letterSpacing:"0.04em"},children:s.title}),e.jsx("div",{className:"h-[1px] w-24 mb-8",style:{background:`linear-gradient(90deg, ${$}, transparent)`}}),s.hero_quote&&e.jsxs("blockquote",{className:"max-w-3xl pl-6 lg:pl-8",style:{borderLeft:`2px solid ${$}`,color:ou,opacity:.95},children:[e.jsx(WO,{size:20,style:{color:$,opacity:.7,marginBottom:8}}),e.jsxs("p",{style:{fontFamily:os,fontStyle:"italic",fontSize:"clamp(1.05rem, 1.6vw, 1.4rem)",lineHeight:1.55,fontWeight:400},children:["â",s.hero_quote,"â"]})]}),e.jsxs("div",{className:"mt-10 flex flex-wrap gap-2.5",children:[s.years_experience!=null&&e.jsxs("span",{className:"px-3 py-1.5 rounded-full text-[11px] font-semibold tracking-[0.15em] uppercase flex items-center gap-1.5",style:{background:`${$}1A`,color:bc,border:`1px solid ${$}55`},children:[e.jsx(Qe,{size:11})," ",s.years_experience,"+ Years"]}),s.campus&&e.jsx("span",{className:"px-3 py-1.5 rounded-full text-[11px] font-semibold tracking-[0.15em] uppercase",style:{background:`${$}1A`,color:bc,border:`1px solid ${$}55`},children:s.campus}),s.established_year&&!l&&e.jsxs("span",{className:"px-3 py-1.5 rounded-full text-[11px] font-semibold tracking-[0.15em] uppercase",style:{background:`${$}1A`,color:bc,border:`1px solid ${$}55`},children:["Est. ",s.established_year]}),l&&s.discipline&&e.jsx("span",{className:"px-3 py-1.5 rounded-full text-[11px] font-semibold tracking-[0.15em] uppercase italic",style:{background:"#FFFFFF1A",color:bc,border:`1px dashed ${$}55`,fontFamily:os},children:s.discipline})]})]})]}),e.jsxs("article",{className:"max-w-[820px] mx-auto px-4 lg:px-0 py-16 lg:py-24",children:[e.jsxs("section",{"aria-labelledby":"biography",children:[e.jsx(vc,{eyebrow:"Biography",icon:e.jsx(tm,{size:11}),title:l?"About This Appointment":"A Biographical Sketch"}),e.jsxs("div",{className:"space-y-5",style:{color:"#2a2a2a",fontFamily:os,fontSize:"clamp(15px, 1.15vw, 17px)",lineHeight:1.9},children:[e.jsx("p",{children:s.bio_long??s.bio_short??"â"}),s.specialty&&!l&&e.jsxs("p",{style:{fontStyle:"italic",color:"#444"},children:[e.jsx("span",{className:"text-[10px] not-italic tracking-[0.3em] uppercase font-semibold mr-2",style:{color:vn,fontFamily:"inherit"},children:"Areas of Specialty â"}),s.specialty]})]})]}),e.jsx(jc,{}),(s.credentials||x.length>0)&&e.jsxs(e.Fragment,{children:[e.jsxs("section",{"aria-labelledby":"
1243credentials",children:[e.jsx(vc,{eyebrow:"Credentials & Honors",icon:e.jsx(Is,{size:11}),title:"Licensure, Awards & Recognition"}),s.credentials&&e.jsx("p",{className:"mb-8",style:{color:"#3a3a3a",fontFamily:os,fontSize:"15.5px",lineHeight:1.85,fontStyle:"italic"},children:s.credentials}),x.length>0&&e.jsx("ul",{className:"space-y-4",children:x.map(y=>e.jsxs("li",{className:"flex items-start gap-4 pb-4",style:{borderBottom:`1px solid ${k}10`},children:[e.jsx("div",{className:"shrink-0 w-9 h-9 rounded-full flex items-center justify-center mt-0.5",style:{background:`linear-gradient(135deg, ${$}33, ${vn}22)`,border:`1px solid ${$}55`,color:vn},children:e.jsx(Is,{size:15})}),e.jsx("p",{className:"leading-relaxed pt-1",style:{color:"#2a2a2a",fontFamily:os,fontSize:"15.5px"},children:y})]},y))}),x.length===0&&l&&e.jsx("p",{className:"italic",style:{color:"#888",fontFamily:os,fontSize:"14px"},children:"Honors and recognition will be listed upon faculty appointment."})]}),e.jsx(jc,{})]}),p.length>0&&e.jsxs(e.Fragment,{children:[e.jsxs("section",{"aria-labelledby":"practice",children:[e.jsx(vc,{eyebrow:"Areas of Practice",icon:e.jsx(Sa,{size:11}),title:"Clinical & Pedagogical Focus"}),e.jsx("ul",{className:"grid sm:grid-cols-2 gap-x-8 gap-y-4",style:{color:"#2a2a2a"},children:p.map(y=>e.jsxs("li",{className:"flex items-start gap-3 pb-3",style:{borderBottom:`1px solid ${k}10`},children:[e.jsx("div",{className:"shrink-0 mt-1.5 w-1.5 h-1.5 rotate-45",style:{background:vn},"aria-hidden":"true"}),e.jsx("span",{style:{fontFamily:os,fontSize:"15px",lineHeight:1.6},children:y})]},y))})]}),e.jsx(jc,{})]}),c.length>0&&e.jsxs(e.Fragment,{children:[e.jsxs("section",{"aria-labelledby":"education",children:[e.jsx(vc,{eyebrow:"Education & Training",icon:e.jsx(_t,{size:11}),title:"A Lifelong Curriculum"}),e.jsxs("ol",{className:"relative",children:[e.jsx("div",{className:"absolute top-2 bottom-2 left-[7px] w-[1px]",style:{background:`${vn}55`},"aria-hidden":"true"}),c.map((y,v)=>e.jsxs("li",{className:"relative pl-10 pb-10 last:pb-0",children:[e.jsx("div",{className:"absolute left-0 top-1 w-[15px] h-[15px] rounded-full",style:{background:"#fff",border:`2px solid ${vn}`,boxShadow:`0 0 0 3px ${ou}`},"aria-hidden":"true"}),e.jsx("div",{className:"text-[10px] tracking-[0.3em] uppercase font-semibold mb-1.5",style:{color:vn},children:y.year}),e.jsx("h3",{className:"font-bold leading-tight mb-1",style:{color:k,fontFamily:os,fontSize:"17px"},children:y.credential}),e.jsx("p",{className:"italic mb-2",style:{color:"#666",fontFamily:os,fontSize:"13.5px"},children:y.institution}),y.detail&&e.jsx("p",{style:{color:"#3a3a3a",fontFamily:os,fontSize:"14.5px",lineHeight:1.7},children:y.detail})]},`${y.year}-${v}`))]})]}),e.jsx(jc,{})]}),u.length>0&&e.jsxs(e.Fragment,{children:[e.jsxs("section",{"aria-labelledby":"publications",children:[e.jsx(vc,{eyebrow:"Publications & Lectures",icon:e.jsx(Na,{size:11}),title:"Curriculum Authorship & Speaking"}),e.jsx("ul",{className:"space-y-6",children:u.map((y,v)=>e.jsxs("li",{className:"pb-6",style:{borderBottom:`1px solid ${k}10`},children:[e.jsxs("div",{className:"flex items-baseline gap-3 mb-1.5 flex-wrap",children:[e.jsx("span",{className:"text-[10px] tracking-[0.3em] uppercase font-semibold",style:{color:vn},children:y.year}),e.jsxs("span",{className:"text-[10px] tracking-[0.2em] uppercase italic",style:{color:"#888",fontFamily:os},children:["· ",y.type]})]}),e.jsx("h3",{className:"font-bold leading-snug mb-1",style:{color:k,fontFamily:os,fontSize:"17px"},children:y.title}),e.jsx("p",{className:"italic",style:{color:"#555",fontFamily:os,fontSize:"14px"},children:y.venue})]},`${y.title}-${v}`))})]}),e.jsx(jc,{})]}),m.length>0&&e.jsxs(e.Fragment,{children:[e.jsxs("section",{"aria-labelledby":"certifications",children:[e.jsx(vc,{eyebrow:"Certifications",icon:e.jsx(Ie,{size:11}),title:"Professional Certifications & Licensure"}),e.jsx("ul",{className:"grid sm:grid-cols-2 gap-x-8 gap-y-3",children:m.map(y=>e.jsxs("li",{className:"flex items-start gap-3",children:[e.jsx(Ue,{size:15,className:"shrink-0 mt-1",style:{color:vn}}),e.jsx("span",{style:{color:"#2a2a2a",fontFamily:os,fontSize:"14.5px",lineHeight:1.65},children:y})]},y))})]}),e.jsx(jc,{})]}),h.length>0&&e.jsxs(e.Fragment,{children:[e.jsxs("section",{"aria-labelledby":"gallery",children:[e.jsx(vc,{eyebrow:"Photo Gallery",icon:e.jsx(Qe,{size:11}),title:"In Practice"}),e.jsx("div",{className:"grid grid-cols-2 lg:grid-cols-3 gap-3",children:h.map((y,v)=>e.jsxs("figure",{className:"rounded-lg overflow-hidden",style:{border:`1px solid ${k}15`},children:[e.jsx("img",{src:y.url,alt:y.caption??`${s.name} â photo ${v+1}`,className:"w-full aspect-[4/3] object-cover",loading:"lazy"}),y.caption&&e.jsx("figcaption",{className:"p-2.5 text-[11px] italic text-center",style:{background:"#fff",color:"#666",fontFamily:os},children:y.caption})]},`${y.url}-${v}`))})]}),e.jsx(jc,{})]}),e.jsx("footer",{className:"text-center pt-4",children:l?e.jsxs(e.Fragment,{children:[e.jsx("p",{className:"italic mb-5 max-w-xl mx-auto",style:{color:"#666",fontFamily:os,fontSize:"14.5px",lineHeight:1.75},children:"This faculty seat is reserved within the Zorganics Clinical Faculty Cabinet. Credentialed inquiries are warmly received and reviewed personally by the Founder."}),e.jsxs("a",{href:"mailto:[email protected]",className:"inline-flex items-center gap-2 px-5 py-2.5 rounded-lg text-xs font-semibold tracking-[0.2em] uppercase transition-all hover:-translate-y-0.5",style:{background:`linear-gradient(135deg, ${$}, ${vn})`,color:k},children:[e.jsx(Ye,{size:13})," Submit a Faculty Inquiry"]})]}):e.jsx("p",{className:"italic max-w-xl mx-auto",style:{color:"#777",fontFamily:os,fontSize:"13.5px",lineHeight:1.7},children:"Profile compiled from institutional records of Zorganics Institute. Last revised in the academic year of public posting."})})]}),e.jsx("div",{className:"border-t py-10 text-center",style:{borderColor:Qy,background:"#fff"},children:e.jsxs(be,{to:"/",className:"inline-flex items-center gap-2 text-xs font-semibold tracking-[0.3em] uppercase hover:opacity-70 transition-opacity",style:{color:vn},children:[e.jsx(Je,{size:13})," Return to Zorganics Institute"]})})]})}
1243,Tp="#E6D2A0",A0="#FAF6EE";function Yv(t){const s=(t||"").toLowerCase();return s.includes("seattle")&&s.includes("renton")?"Seattle · Fall 2025 · Renton · Spring 2026":s.includes("seattle")?"Fall 2025":s.includes("renton")?"Spring 2026":"Fall 2025"}const cE=({open:t,target:s,targets:n,onClose:a,onSent:r,onBatchComplete:i})=>{const o=d.useMemo(()=>n&&n.length>0?n:s?[s]:[],[s,n]),l=o.length>1,c=o[0]||null,[u,p]=d.useState(""),[m,x]=d.useState("The Zorganics Admissions Team"),[h,y]=d.useState(""),[v,g]=d.useState(""),[N,b]=d.useState(!1),[f,j]=d.useState(null),[S,w]=d.useState(!1),[_,C]=d.useState(null),[E,P]=d.useState([]),[F,I]=d.useState(!1),[D,L]=d.useState(!1),V=d.useRef(!1);if(d.useEffect(()=>{t&&o.length!==0&&(p(Yv(o[0].campus)),x("The Zorganics Admissions Team"),j(null),C(null),y(""),g(""),P(o.map(T=>({target:T,status:"pending"}))),I(!1),L(!1),V.current=!1)},[t,o.map(T=>T.id).join("|")]),d.useEffect(()=>{if(!t||!c)return;let T=!1;const q=setTimeout(async()=>{b(!0),j(null);try{const{data:H,error:G}=await O.functions.invoke("send-vip-invite-email",{body:{entry_id:c.id,name:c.name,email:c.email,campus:c.campus,opening_target:u,advisor_name:m,preview_only:!0}});if(T)return;G?j(G.message):H!=null&&H.html?(y(H.html),g(H.subject||"")):H!=null&&H.error&&j(H.error)}catch(H){T||j((H==null?void 0:H.message)||"Preview failed")}finally{T||b(!1)}},250);return()=>{T=!0,clearTimeout(q)}},[t,c==null?void 0:c.id,u,m]),!t||o.length===0)return null;const B=async()=>{if(c){w(!0),j(null);try{const{data:T,error:U}=await O.functions.invoke("send-vip-invite-email",{body:{entry_id:c.id,name:c.name,email:c.email,campus:c.campus,opening_target:u,advisor_name:m}});if(U)throw new Error(U.message);if(!(T!=null&&T.success))throw new Error((T==null?void 0:T.error)||"Send failed");C({message_id:T.message_id}),r({entry_id:c.id,message_id:T.message_id,opening_target:T.opening_target||u,advisor_name:m,subject:T.subject||v})}catch(T){j((T==null?void 0:T.message)||"Failed to send invite")}finally{w(!1)}}},A=async()=>{if(F||D)return;I(!0),j(null),V.current=!1;const T=[];for(let U=0;U<o.length&&!V.current;U++){const q=o[U],H=Yv(o[0].campus),G=u&&u!==H?u:Yv(q.campus);P(W=>W.map(X=>X.target.id===q.id?{...X,status:"sending"}:X));try{const{data:W,error:X}=await O.functions.invoke("send-vip-invite-email",{body:{entry_id:q.id,name:q.name,email:q.email,campus:q.campus,opening_target:G,advisor_name:m}});if(X)throw new Error(X.message);if(!(W!=null&&W.success))throw new Error((W==null?void 0:W.error)||"Send failed");const Q={target:q,status:"sent",message_id:W.message_id};T.push(Q),P(K=>K.map(se=>se.target.id===q.id?Q:se)),r({entry_id:q.id,message_id:W.message_id,opening_target:W.opening_target||G,advisor_name:m,subject:W.subject||v})}catch(W){const X={target:q,status:"failed",error:(W==null?void 0:W.message)||"Unknown error"};T.push(X),P(Q=>Q.map(K=>K.target.id===q.id?X:K))}await new Promise(W=>setTimeout(W,250))}I(!1),L(!0),i&&i({total:o.length,succeeded:T.filter(U=>U.status==="sent").length,failed:T.filter(U=>U.status==="failed").length,results:T.map(U=>({entry_id:U.target.id,email:U.target.email,name:U.target.name,status:U.status==="sent"?"sent":"failed",message_id:U.message_id,error:U.error}))})},z=()=>{V.current=!0},M=d.useMemo(()=>{const T=E.filter(X=>X.status==="sent").length,U=E.filter(X=>X.status==="failed").length,q=E.filter(X=>X.status==="sending").length,H=E.filter(X=>X.status==="pending").length,G=T+U,W=o.length?Math.round(G/o.length*100):0;return{sent:T,failed:U,sending:q,pending:H,completed:G,pct:W}},[E,o.length]),R=S||F;return e.jsx("div",{className:"fixed inset-0 z-[100] flex items-center justify-center p-4",style:{background:"rgba(20,4,8,0.72)"},onClick:T=>{T.target===T.currentTarget&&!R&&a()},children:e.jsxs("div",{className:"relative w-full max-w-5xl max-h-[92vh] flex flex-col rounded-sm overflow-hidden shadow-2xl",style:{background:"#fff",border:`1px solid ${$}`},children:[e.jsxs("div",{className:"flex items-center justify-between px-6 py-4 border-b",style:{background:k,borderColor:$},children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"w-9 h-9 rounded-full flex items-center justify-center",style:{background:$},children:l?e.jsx(ts,{size:16,style:{color:k}}):e.jsx(Ye,{size:16,style:{color:k}})}),e.jsxs("div",{children:[e.jsx("div",{className:"text-[10px] uppercase tracking-[0.28em]",style:{color:$},children:l?`Batch VIP Invitation · ${o.length} recipients`:"VIP Invitation"}),e.jsx("div",{className:"text-sm font-bold",style:{color:A0},children:l?e.jsxs(e.Fragment,{children:["Send branded invitation to ",o.length," selected contacts"]}):e.jsxs(e.Fragment,{children:["Send to ",(c==null?void 0:c.name)||(c==null?void 0:c.email),e.jsxs("span",{className:"ml-2 opacity-60 text-xs",children:["· ",c==null?void 0:c.campus," Campus"]}
1243)]})})]})]}),e.jsx("button",{onClick:a,disabled:R,className:"p-2 rounded-sm hover:bg-white/10 transition-colors disabled:opacity-40","aria-label":"Close",children:e.jsx(Ke,{size:16,style:{color:A0}})})]}),e.jsxs("div",{className:"flex-1 overflow-y-auto grid lg:grid-cols-5",children:[e.jsxs("div",{className:"lg:col-span-2 p-6 border-r flex flex-col",style:{background:A0,borderColor:Tp},children:[e.jsx("div",{className:"text-[10px] uppercase tracking-[0.2em] font-bold mb-3",style:{color:$},children:l?"Batch Personalization":"Personalization"}),e.jsx("h3",{className:"text-lg font-bold mb-4",style:{color:k},children:l?"Confirm Batch & Preview":"Confirm & Preview"}),!l&&c&&e.jsx(pg,{label:"Recipient",children:e.jsxs("div",{className:"text-sm",style:{color:k},children:[e.jsx("div",{className:"font-semibold",children:c.name||e.jsx("em",{className:"opacity-70",children:"No name"})}),e.jsx("div",{className:"opacity-80",children:c.email})]})}),!l&&c&&e.jsx(pg,{label:"Campus",children:e.jsx("div",{className:"text-sm font-semibold",style:{color:k},children:c.campus})}),e.jsxs(pg,{label:l?"Opening Target (applied to all)":"Opening Target",children:[e.jsx("input",{type:"text",value:u,onChange:T=>p(T.target.value),disabled:R||D,placeholder:"Fall 2025",className:"w-full px-3 py-2 rounded-sm border text-sm focus:outline-none focus:border-[#3B0A11] bg-white disabled:opacity-60",style:{borderColor:"rgba(59,10,17,0.2)"}}),e.jsx("p",{className:"mt-1 text-[10px] text-gray-500",children:l?"If left at the default, each recipient gets a campus-appropriate opening term (Seattle â Fall 2025, Renton â Spring 2026). Edit to override for the entire batch.":"Appears in subject line, hero banner, and confirmation copy."})]}),e.jsxs(pg,{label:"From / Advisor Name",children:[e.jsx("input",{type:"text",value:m,onChange:T=>x(T.target.value),disabled:R||D,placeholder:"The Zorganics Admissions Team",className:"w-full px-3 py-2 rounded-sm border text-sm focus:outline-none focus:border-[#3B0A11] bg-white disabled:opacity-60",style:{borderColor:"rgba(59,10,17,0.2)"}}),e.jsx("p",{className:"mt-1 text-[10px] text-gray-500",children:"Signs every email and is recorded in metadata."})]}),v&&e.jsxs("div",{className:"mt-2 p-3 rounded-sm",style:{background:"#fff",border:`1px solid ${Tp}`},children:[e.jsxs("div",{className:"text-[10px] uppercase tracking-[0.18em] font-bold",style:{color:$},children:["Subject Line ",l&&"(first recipient · personalized per-row)"]}),e.jsx("div",{className:"mt-1 text-xs",style:{color:k},children:v})]}),l&&e.jsxs("div",{className:"mt-5 flex-1 min-h-[180px] flex flex-col",children:[e.jsxs("div",{className:"text-[10px] uppercase tracking-[0.18em] font-bold mb-2",style:{color:$},children:["Recipients (",o.length,")"]}),e.jsx("div",{className:"rounded-sm overflow-y-auto bg-white flex-1",style:{border:`1px solid ${Tp}`,maxHeight:280},children:e.jsx("ul",{className:"divide-y",style:{borderColor:"rgba(59,10,17,0.06)"},children:E.map(T=>e.jsxs("li",{className:"px-3 py-2 flex items-center justify-between gap-2",children:[e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("div",{className:"text-xs font-semibold truncate",style:{color:k},children:T.target.name||e.jsx("em",{className:"opacity-70",children:"No name"})}),e.jsxs("div",{className:"text-[10px] text-gray-500 truncate",children:[T.target.email," · ",T.target.campus]}),T.status==="failed"&&T.error&&e.jsx("div",{className:"text-[10px] text-red-700 mt-0.5 truncate",title:T.error,children:T.error}),T.status==="sent"&&T.message_id&&e.jsxs("div",{className:"text-[10px] text-gray-400 mt-0.5 truncate",title:T.message_id,children:["id: ",T.message_id.slice(0,22),T.message_id.length>22?"â¦":""]})]}),e.jsx(tte,{status:T.status})]},T.target.id))})}),(F||D)&&e.jsxs("div",{className:"mt-3",children:[e.jsx("div",{className:"h-1.5 w-full rounded-sm overflow-hidden",style:{background:"rgba(59,10,17,0.08)"},children:e.jsx("div",{className:"h-full transition-all",style:{width:`${M.pct}%`,background:$}})}),e.jsxs("div",{className:"mt-1.5 flex items-center justify-between text-[10px]",style:{color:k},children:[e.jsxs("span",{children:[M.completed," / ",o.length," processed"]}),e.jsxs("span",{className:"font-semibold",children:[e.jsxs("span",{style:{color:"#15803d"},children:[M.sent," sent"]}),M.failed>0&&e.jsxs(e.Fragment,{children:[" · ",e.jsxs("span",{style:{color:"#b91c1c"},children:[M.failed," failed"]})]})]})]})]})]}),f&&!F&&e.jsxs("div",{className:"mt-4 p-3 rounded-sm flex items-start gap-2",style:{background:"#fff",border:`1px solid ${k}`},children:[e.jsx(ve,{size:14,style:{color:k},className:"mt-0.5 shrink-0"}),e.jsx("div",{className:"text-xs",style:{color:k},children:f})]}),!l&&_&&e.jsxs("div",{className:"mt-4 p-3 rounded-sm flex items-start gap-2",style:{background:"#fff",border:`1px solid ${$}`},children:[e.jsx(Ue,{size:14,style:{color:$},className:"mt-0.5 shrink-0"}),e.jsxs("div",{className:"text-xs",style:{color:k},children:[e.jsx("div",{className:"font-bold",children:"Invitation sent"}),e.jsxs("div",{className:"opacity-80 break-all mt-0.5",children:["id: ",_.message_id||"â"]}
1243)]})]}),l&&D&&e.jsxs("div",{className:"mt-4 p-3 rounded-sm",style:{background:"#fff",border:`1px solid ${M.failed>0?"#fcd34d":$}`},children:[e.jsxs("div",{className:"flex items-center gap-2",children:[M.failed>0?e.jsx(ve,{size:14,style:{color:"#b45309"}}):e.jsx(Ue,{size:14,style:{color:$}}),e.jsx("div",{className:"text-xs font-bold",style:{color:k},children:"Batch complete"})]}),e.jsxs("div",{className:"mt-1 text-[11px] leading-relaxed",style:{color:k},children:[e.jsxs("div",{children:[e.jsx("strong",{children:M.sent})," of ",e.jsx("strong",{children:o.length})," invitations sent successfully."]}),M.failed>0&&e.jsxs("div",{className:"mt-0.5",children:[e.jsx("strong",{style:{color:"#b91c1c"},children:M.failed})," failed â see per-recipient detail above. Cancel and retry individually from the table."]})]})]})]}),e.jsxs("div",{className:"lg:col-span-3 p-6 bg-gray-100",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[e.jsx(ms,{size:12,style:{color:k}}),e.jsxs("span",{className:"text-[10px] uppercase tracking-[0.2em] font-bold",style:{color:k},children:["Email Preview ",l&&`· based on ${(c==null?void 0:c.name)||(c==null?void 0:c.email)}`]}),N&&e.jsx(de,{size:12,className:"animate-spin",style:{color:k}})]}),e.jsx("div",{className:"rounded-sm overflow-hidden bg-white",style:{border:`1px solid ${Tp}`,minHeight:420},children:h?e.jsx("iframe",{title:"VIP Invite Preview",srcDoc:h,className:"w-full",style:{height:560,border:0,background:"#fff"},sandbox:""}):e.jsx("div",{className:"flex items-center justify-center",style:{height:420},children:N?e.jsxs("div",{className:"text-center",children:[e.jsx(de,{size:20,className:"animate-spin mx-auto",style:{color:k}}),e.jsx("p",{className:"text-xs text-gray-500 mt-2",children:"Rendering previewâ¦"})]}):e.jsx("p",{className:"text-xs text-gray-400",children:"Preview will appear here."})})}),l&&e.jsx("p",{className:"mt-3 text-[10px] text-gray-500 leading-relaxed",children:"Each recipient receives a personalized copy â the recipient name, campus, and (if left at default) opening term are merged server-side per row."})]})]}),e.jsxs("div",{className:"flex items-center justify-between gap-3 px-6 py-4 border-t",style:{background:"#fff",borderColor:Tp},children:[e.jsxs("div",{className:"text-[10px] text-gray-500 tracking-wide",children:["Sends via Famous Email Gateway · ",e.jsx("code",{children:"t.ecom-email.com"}),". Logged to"," ",e.jsx("code",{children:"metadata.invite_history"})," with message_id."]}),e.jsxs("div",{className:"flex items-center gap-2",children:[l&&F?e.jsx("button",{onClick:z,className:"px-4 py-2 rounded-sm text-xs font-bold tracking-wide transition-all",style:{background:"#fff",color:k,border:`1px solid ${k}`},children:"Stop after current"}):e.jsx("button",{onClick:a,disabled:R,className:"px-4 py-2 rounded-sm text-xs font-bold tracking-wide transition-all disabled:opacity-40",style:{background:"#fff",color:k,border:`1px solid ${k}`},children:_||D?"Close":"Cancel"}),!l&&!_&&e.jsxs("button",{onClick:B,disabled:S||N||!h,className:"inline-flex items-center gap-2 px-5 py-2 rounded-sm text-xs font-bold tracking-wide transition-all disabled:opacity-50",style:{background:$,color:k,border:`1px solid ${k}`},children:[S?e.jsx(de,{size:12,className:"animate-spin"}):e.jsx(Hs,{size:12}),S?"Sendingâ¦":"Confirm & Send Invitation"]}),l&&!D&&e.jsxs("button",{onClick:A,disabled:F||N||!h,className:"inline-flex items-center gap-2 px-5 py-2 rounded-sm text-xs font-bold tracking-wide transition-all disabled:opacity-50",style:{background:$,color:k,border:`1px solid ${k}`},children:[F?e.jsx(de,{size:12,className:"animate-spin"}):e.jsx(Hs,{size:12}),F?`Sending ${M.completed+1} of ${o.length}â¦`:`Confirm & Send to ${o.length} Recipients`]})]})]})]})})},pg=({label:t,children:s})=>e.jsxs("div",{className:"mb-4",children:[e.jsx("label",{className:"block text-[10px] uppercase tracking-[0.2em] font-bold mb-1.5 text-gray-600",children:t}),s]}),tte=({status:t})=>t==="pending"?e.jsx("span",{className:"text-[9px] uppercase tracking-wide font-bold px-1.5 py-0.5 rounded-sm",style:{color:"#6b7280",background:"#f3f4f6"},children:"Queued"}):t==="sending"?e.jsxs("span",{className:"inline-flex items-center gap-1 text-[9px] uppercase tracking-wide font-bold px-1.5 py-0.5 rounded-sm",style:{color:k,background:A0,border:`1px solid ${$}`},children:[e.jsx(de,{size:9,className:"animate-spin"}),"Sending"]}):t==="sent"?e.jsxs("span",{className:"inline-flex items-center gap-1 text-[9px] uppercase tracking-wide font-bold px-1.5 py-0.5 rounded-sm",style:{color:$,background:k},children:[e.jsx(Ue,{size:9}),"Sent"]}):e.jsxs("span",{className:"inline-flex items-center gap-1 text-[9px] uppercase tracking-wide font-bold px-1.5 py-0.5 rounded-sm",style:{color:"#991b1b",background:"#fef2f2",border:"1px solid #fecaca"},children:[e.jsx(ve,{size:9}),"Failed"]}),ste="#800020",lm="#E6D2A0",vi="#FAF6EE",dE=["Seattle","Renton","Both"];function nte(t){try{return new Date(t).toLocaleDateString("en-US",{year:"numeric",month:"short",day:"numeric"})}catch{return t}}function Hc(t){if(!t)return"â";
1243try{return new Date(t).toLocaleString("en-US",{year:"numeric",month:"short",day:"numeric",hour:"numeric",minute:"2-digit"})}catch{return t}}function di(t){if(t==null)return"";const s=String(t);return/[",\n\r]/.test(s)?`"${s.replace(/"/g,'""')}"`:s}function uE(t,s){const a=[["id","name","email","campus","status","source","tags","created_at","invited_at","invited_by"].join(",")];s.forEach(l=>{a.push([di(l.id),di(l.name||""),di(l.email),di(l.campus),di(l.status),di(l.source||""),di((l.tags||[]).join("|")),di(l.created_at),di(l.invited_at||""),di(l.invited_by||"")].join(","))});const r=new Blob([a.join(` 1244`)],{type:"text/csv;charset=utf-8;"}),i=URL.createObjectURL(r),o=document.createElement("a");o.href=i,o.download=t,document.body.appendChild(o),o.click(),document.body.removeChild(o),URL.revokeObjectURL(i)}const ate=()=>{var G,W,X;const[t,s]=d.useState([]),[n,a]=d.useState(!0),[r,i]=d.useState(!1),[o,l]=d.useState(null),[c,u]=d.useState(""),[p,m]=d.useState("all"),[x,h]=d.useState(null),[y,v]=d.useState(null),[g,N]=d.useState(!1),[b,f]=d.useState(null),[j,S]=d.useState(new Set),w=Q=>{s(K=>K.map(se=>{var te;if(se.id!==Q.entry_id)return se;const Y=new Date().toISOString(),J=Array.isArray((te=se.metadata)==null?void 0:te.invite_history)?se.metadata.invite_history:[];return{...se,status:"invited",invited_at:se.invited_at||Y,invited_by:se.invited_by||Q.advisor_name,updated_at:Y,metadata:{...se.metadata||{},invite_history:[...J,{event:"invite_email_sent",status:"invited",at:Y,by:Q.advisor_name,channel:"email",message_id:Q.message_id,subject:Q.subject,opening_target:Q.opening_target,campus:se.campus}],last_invite_message_id:Q.message_id,last_invite_at:Y,last_opening_target:Q.opening_target}}}))},_=async()=>{l(null);const{data:Q,error:K}=await O.from("vip_waitlist_entries").select("*").contains("tags",["vip-waitlist"]).order("created_at",{ascending:!1});K?(console.error("Failed to fetch VIP waitlist:",K),l(K.message),s([])):s(Q||[]),a(!1),i(!1)};d.useEffect(()=>{_()},[]);const C=async Q=>{var pe;h(Q.id);const K=Q.status==="invited"?"pending":"invited",se=new Date().toISOString(),Y={...Q.metadata||{},invite_history:[...((pe=Q.metadata)==null?void 0:pe.invite_history)||[],{status:K,at:se,by:"admin-console"}]},{data:J,error:te}=await O.from("vip_waitlist_entries").update({status:K,invited_at:K==="invited"?se:null,invited_by:K==="invited"?"admin-console":null,metadata:Y,updated_at:se}).eq("id",Q.id).select().single();te?(console.error("Failed to update entry:",te),l(te.message)):J&&s(Fe=>Fe.map(ke=>ke.id===Q.id?J:ke)),h(null)},E=d.useMemo(()=>{const Q=c.trim().toLowerCase();return t.filter(K=>p!=="all"&&K.status!==p?!1:Q?(K.name||"").toLowerCase().includes(Q)||K.email.toLowerCase().includes(Q)||K.campus.toLowerCase().includes(Q):!0)},[t,c,p]),P=d.useMemo(()=>{const Q=new Map;return E.forEach(se=>{const Y=se.campus||"Unspecified";Q.has(Y)||Q.set(Y,[]),Q.get(Y).push(se)}),Array.from(Q.keys()).sort((se,Y)=>{const J=dE.indexOf(se),te=dE.indexOf(Y);return J===-1&&te===-1?se.localeCompare(Y):J===-1?1:te===-1?-1:J-te}).map(se=>({campus:se,rows:Q.get(se)}))},[E]),F=d.useMemo(()=>{const Q=t.length,K=t.filter(J=>J.status==="pending").length,se=t.filter(J=>J.status==="invited").length,Y=t.reduce((J,te)=>(J[te.campus]=(J[te.campus]||0)+1,J),{});return{total:Q,pending:K,invited:se,byCampus:Y}},[t]),I=d.useMemo(()=>new Set(E.map(Q=>Q.id)),[E]);d.useEffect(()=>{S(Q=>{let K=!1;const se=new Set;return Q.forEach(Y=>{I.has(Y)?se.add(Y):K=!0}),K?se:Q})},[I]);const D=j.size,L=E.length>0&&E.every(Q=>j.has(Q.id)),V=D>0&&!L,B=Q=>{S(K=>{const se=new Set(K);return se.has(Q)?se.delete(Q):se.add(Q),se})},A=Q=>{S(K=>{const se=new Set(K);return Q.every(J=>se.has(J.id))?Q.forEach(J=>se.delete(J.id)):Q.forEach(J=>se.add(J.id)),se})},z=()=>{S(Q=>{if(L)return new Set;const K=new Set(Q);return E.forEach(se=>K.add(se.id)),K})},M=()=>S(new Set),R=d.useMemo(()=>E.filter(Q=>j.has(Q.id)),[E,j]),T=d.useMemo(()=>R.map(Q=>({id:Q.id,name:Q.name,email:Q.email,campus:Q.campus})),[R]),U=()=>{D!==0&&(f(null),N(!0))},q=()=>{N(!1)},H=Q=>{f(Q),S(K=>{const se=new Set(K);
1244return Q.results.forEach(Y=>{Y.status==="sent"&&se.delete(Y.entry_id)}),se})};return e.jsxs("div",{className:"min-h-screen font-sans",style:{background:vi},children:[e.jsx("div",{style:{background:k,color:vi},children:e.jsxs("div",{className:"max-w-[1400px] mx-auto px-6 lg:px-10 py-6 flex flex-wrap items-center justify-between gap-4",children:[e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsxs(be,{to:"/",className:"inline-flex items-center gap-2 text-xs uppercase tracking-[0.2em] opacity-80 hover:opacity-100",children:[e.jsx(Je,{size:14})," Back to site"]}),e.jsx("span",{className:"hidden md:inline-block h-4 w-px",style:{background:"rgba(212,175,55,0.4)"}}),e.jsxs("div",{className:"hidden md:flex items-center gap-2",children:[e.jsx(Zl,{size:16,style:{color:$}}),e.jsx("span",{className:"text-[11px] uppercase tracking-[0.25em]",style:{color:$},children:"Admin · Enrollment Console"})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("button",{onClick:()=>{i(!0),_()},disabled:r,className:"inline-flex items-center gap-2 px-4 py-2 rounded-sm text-xs font-bold tracking-wide transition-all disabled:opacity-60",style:{background:"rgba(255,255,255,0.08)",color:vi,border:"1px solid rgba(212,175,55,0.3)"},children:[r?e.jsx(de,{size:14,className:"animate-spin"}):e.jsx(Be,{size:14}),"Refresh"]}),e.jsxs("button",{onClick:()=>uE(`vip-waitlist-${new Date().toISOString().slice(0,10)}.csv`,E),className:"inline-flex items-center gap-2 px-4 py-2 rounded-sm text-xs font-bold tracking-wide transition-all hover:shadow-md",style:{background:$,color:k},children:[e.jsx(us,{size:14}),"Export CSV (",E.length,")"]})]})]})}),e.jsxs("header",{className:"max-w-[1400px] mx-auto px-6 lg:px-10 pt-10 pb-6",children:[e.jsx("div",{className:"flex items-start justify-between flex-wrap gap-6",children:e.jsxs("div",{children:[e.jsx("div",{className:"text-[11px] tracking-[0.3em] uppercase font-semibold",style:{color:$},children:"VIP Waitlist · Expansion Campuses"}),e.jsx("h1",{className:"mt-2 text-3xl lg:text-4xl font-bold leading-tight",style:{color:k},children:"Renton & Seattle Founder Cohort Pipeline"}),e.jsxs("p",{className:"mt-3 text-sm text-gray-600 max-w-2xl leading-relaxed",children:["Every contact below was tagged ",e.jsx("code",{className:"px-1.5 py-0.5 rounded bg-white border text-[11px]",style:{borderColor:lm,color:k},children:"vip-waitlist"})," ","by the expansion-campus form on the Premium Landing template. Mark contacts as ",e.jsx("strong",{children:"Invited"})," when an enrollment advisor has personally reached out, then export the segment to push qualified VIPs into Mailchimp or Salesforce."]})]})}),e.jsxs("div",{className:"mt-8 grid sm:grid-cols-2 lg:grid-cols-4 gap-4",children:[e.jsx(hg,{label:"Total VIPs",value:F.total,icon:ts,accent:k,bg:"#fff"}),e.jsx(hg,{label:"Pending Outreach",value:F.pending,icon:zb,accent:ste,bg:"#fff"}),e.jsx(hg,{label:"Invited",value:F.invited,icon:Ue,accent:$,bg:"#fff"}),e.jsx(hg,{label:"Top Campus",value:((G=Object.entries(F.byCampus).sort((Q,K)=>K[1]-Q[1])[0])==null?void 0:G[0])||"â",sub:(X=(W=Object.entries(F.byCampus).sort((Q,K)=>K[1]-Q[1])[0])==null?void 0:W[1])==null?void 0:X.toString(),icon:zt,accent:k,bg:"#fff"})]})]}),e.jsx("div",{className:"max-w-[1400px] mx-auto px-6 lg:px-10 pb-6",children:e.jsxs("div",{className:"flex flex-wrap items-center gap-3 p-4 rounded-sm bg-white",style:{border:`1px solid ${lm}`},children:[e.jsxs("div",{className:"relative flex-1 min-w-[240px]",children:[e.jsx(Bt,{size:14,className:"absolute left-3 top-1/2 -translate-y-1/2 text-gray-400"}),e.jsx("input",{type:"text",placeholder:"Search name, email, or campusâ¦",value:c,onChange:Q=>u(Q.target.value),className:"w-full pl-9 pr-3 py-2.5 rounded-sm border text-sm focus:outline-none focus:border-[#3B0A11]",style:{borderColor:"rgba(59,10,17,0.15)"}})]}),e.jsxs("button",{onClick:z,className:"inline-flex items-center gap-2 px-3 py-2 rounded-sm text-[11px] font-bold tracking-wide transition-all",style:{background:L?k:"#fff",color:L?$:k,border:`1px solid ${k}`},title:L?"Clear selection":"Select all visible",children:[L?e.jsx(vo,{size:12}):e.jsx(Uu,{size:12}),L?"Deselect all visible":`Select all visible (${E.length})`]}),e.jsxs("div",{className:"flex items-center gap-1",style:{background:vi,padding:4,borderRadius:2},children:[e.jsx(ei,{size:12,className:"ml-2",style:{color:k}}),[{key:"all",label:"All"},{key:"pending",label:"Pending"},{key:"invited",label:"Invited"}].map(({key:Q,label:K})=>{const se=p===Q;return e.jsx("button",{onClick:()=>m(Q),className:"px-3 py-1.5 rounded-sm text-xs font-bold tracking-wide transition-all",style:{background:se?k:"transparent",color:se?vi:k},children:K},Q)})]})]})}),D>0&&e.jsxs("div",{className:"sticky top-0 z-20 max-w-[1400px] mx-auto px-6 lg:px-10 pb-4",children:[e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3 px-5 py-3 rounded-sm shadow-lg",style:{background:k,border:`1px solid ${$}`},children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"w-8 h-8 rounded-full flex items-center justify-center",style:{background:$},children:e.jsx(vo,{size:14,style:{color:k}})}),e.jsxs("div",{className:"text-sm font-bold",style:{color:vi},children:[D," contact",D===1?"":"s"," selected",V&&e.jsxs("span",{className:"ml-2 text-[10px] uppercase tracking-[0.18em] opacity-70 font-normal",children:["of ",E.length," visible"]})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("button",{onClick:M,className:"inline-flex items-center gap-1.5 px-3 py-2 rounded-sm text-[11px] font-bold tracking-wide transition-all",style:{background:"rgba(255,255,255,0.08)",color:vi,border:"1px solid rgba(212,175,55,0.3)"},children:[e.jsx(Ke,{size:12}),"Clear"]}),e.jsxs("button",{onClick:U,className:"inline-flex items-center gap-2 px-5 py-2 rounded-sm text-xs font-bold tracking-wide transition-all hover:shadow-md",style:{background:$,color:k},children:[e.jsx(Hs,{size:12}),"Send Invites to ",D," selected"]})]})]}),b&&e.jsxs("div",{className:"mt-2 px-4 py-2.5 rounded-sm text-[11px] flex items-center justify-between gap-3",style:{background:"#fff",border:`1px solid ${b.failed>0?"#fcd34d":$}`,color:k},children:[e.jsxs("div",{className:"flex items-center gap-2",children:[b.failed>0?e.jsx(ve,{size:12,style:{color:"#b45309"}}):e.jsx(Ue,{size:12,style:{color:$}}),"Last batch: ",e.jsx("strong",{children:b.succeeded})," sent",b.failed>0&&e.jsxs(e.Fragment,{children:[" · ",e.jsxs("strong",{style:{color:"#b91c1c"},children:[b.failed," failed"]})]})," ","of ",b.total]}),e.jsx("button",{onClick:()=>f(null),className:"text-[10px] uppercase tracking-wide opacity-60 hover:opacity-100",children:"Dismiss"})]})]}),e.jsxs("main",{className:"max-w-[1400px] mx-auto px-6 lg:px-10 pb-20",children:[n?e.jsxs("div",{className:"text-center py-20",children:[e.jsx(de,{size:28,className:"animate-spin mx-auto",style:{color:k}}),e.jsx("p",{className:"mt-4 text-sm text-gray-500",children:"Loading VIP waitlistâ¦"})]}):o?e.jsxs("div",{className:"p-6 rounded-sm bg-white",style:{border:`1px solid ${k}`},children:[e.jsx("p",{className:"text-sm font-semibold",style:{color:k},children:"Couldn't load waitlist"}),e.jsx("p",{className:"text-xs text-gray-600 mt-1",children:o})]}):P.length===0?e.jsxs("div",{className:"text-center py-20 rounded-sm bg-white",style:{border:`1px dashed ${$}`},children:[e.jsx(Qe,{size:28,className:"mx-auto",style:{color:$}}),e.jsx("p",{className:"mt-4 text-lg font-bold",style:{color:k},children:"No VIP contacts yet"}),e.jsx("p",{className:"mt-1 text-sm text-gray-500 max-w-md mx-auto",children:"When prospective students submit the Renton/Seattle VIP Waitlist form on the Premium Landing, they will appear here, grouped by campus."})]}):e.jsx("div",{className:"space-y-10",children:P.map(({campus:Q,rows:K}
1244)=>e.jsx(rte,{campus:Q,rows:K,updatingId:x,selectedIds:j,onToggleOne:B,onToggleGroup:()=>A(K),onToggle:C,onInvite:se=>v({id:se.id,name:se.name,email:se.email,campus:se.campus}),onExport:()=>uE(`vip-waitlist-${Q.toLowerCase()}-${new Date().toISOString().slice(0,10)}.csv`,K)},Q))}),e.jsxs("div",{className:"mt-12 p-5 rounded-sm text-xs text-gray-600 leading-relaxed",style:{background:"#fff",border:`1px solid ${lm}`},children:[e.jsx("div",{className:"font-bold uppercase tracking-[0.15em] mb-1",style:{color:k},children:"Downstream Sync"}),"The CSV export above mirrors the canonical Famous CRM record for every ",e.jsx("code",{children:"vip-waitlist"}),"-tagged contact. Upload directly into Mailchimp (Audience â Import Contacts) or Salesforce (Data Import Wizard â Leads) â column headers (",e.jsx("code",{children:"email, name, campus, status, tags"}),") map cleanly to both systems."]})]}),e.jsx(cE,{open:y!==null,target:y,onClose:()=>v(null),onSent:w}),e.jsx(cE,{open:g,targets:T,onClose:q,onSent:w,onBatchComplete:H})]})},hg=({label:t,value:s,sub:n,icon:a,accent:r,bg:i})=>e.jsxs("div",{className:"p-5 rounded-sm flex items-center justify-between",style:{background:i,border:`1px solid ${lm}`},children:[e.jsxs("div",{children:[e.jsx("div",{className:"text-[10px] uppercase tracking-[0.2em] text-gray-500 font-semibold",children:t}),e.jsxs("div",{className:"mt-1 text-2xl font-bold",style:{color:k},children:[s," ",n&&e.jsxs("span",{className:"text-sm font-normal text-gray-500",children:["(",n,")"]})]})]}),e.jsx("div",{className:"w-10 h-10 rounded-full flex items-center justify-center",style:{background:vi,border:`1px solid ${r}`},children:e.jsx(a,{size:16,style:{color:r}})})]}),rte=({campus:t,rows:s,updatingId:n,selectedIds:a,onToggleOne:r,onToggleGroup:i,onToggle:o,onInvite:l,onExport:c})=>{const u=s.filter(y=>y.status==="pending").length,p=s.filter(y=>y.status==="invited").length,m=s.reduce((y,v)=>y+(a.has(v.id)?1:0),0),x=s.length>0&&m===s.length,h=m>0&&!x;return e.jsxs("section",{className:"bg-white rounded-sm overflow-hidden",style:{border:`1px solid ${lm}`},children:[e.jsxs("div",{className:"px-6 py-5 flex flex-wrap items-center justify-between gap-3 border-b",style:{background:vi,borderColor:"rgba(59,10,17,0.08)"},children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"w-10 h-10 rounded-full flex items-center justify-center",style:{background:k},children:e.jsx(zt,{size:18,style:{color:$}})}),e.jsxs("div",{children:[e.jsxs("div",{className:"text-xl font-bold",style:{color:k},children:[t," Campus"]}),e.jsxs("div",{className:"text-[11px] uppercase tracking-[0.18em] text-gray-500 mt-0.5",children:[s.length," contact",s.length===1?"":"s"," · ",u," pending · ",p," invited",m>0&&e.jsxs(e.Fragment,{children:[" · ",e.jsxs("span",{style:{color:k},children:[m," selected"]})]})]})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("button",{onClick:i,title:x?`Deselect all ${t} contacts`:`Select all ${t} contacts`,className:"inline-flex items-center gap-2 px-3 py-2 rounded-sm text-[11px] font-bold tracking-wide transition-all",style:{background:x?k:"#fff",color:x?$:k,border:`1px solid ${k}`},children:[x?e.jsx(vo,{size:12}):h?e.jsx(ite,{}):e.jsx(Uu,{size:12}),x?"Deselect all":"Select all"]}),e.jsxs("button",{onClick:c,className:"inline-flex items-center gap-2 px-3 py-2 rounded-sm text-[11px] font-bold tracking-wide transition-all",style:{background:"#fff",color:k,border:`1px solid ${$}`},children:[e.jsx(us,{size:12}),"Export ",t," CSV"]})]})]}),e.jsx("div",{className:"overflow-x-auto",children:e.jsxs("table",{className:"w-full text-sm",children:[e.jsx("thead",{style:{background:"#fff"},children:e.jsxs("tr",{className:"text-left text-[10px] uppercase tracking-[0.15em] text-gray-500 border-b",style:{borderColor:"rgba(59,10,17,0.08)"},children:[e.jsx("th",{className:"px-4 py-3 font-bold w-10",children:e.jsx("button",{onClick:i,"aria-label":x?`Deselect all ${t} contacts`:`Select all ${t} contacts`,className:"inline-flex items-center justify-center w-5 h-5 rounded-sm transition-all",style:{background:x?k:"#fff",border:`1px solid ${x||h?k:"rgba(59,10,17,0.3)"}`},children:x?e.jsx(vo,{size:12,style:{color:$}}):h?e.jsx("span",{style:{display:"inline-block",width:8,height:2,background:k,borderRadius:1}}):null})}),e.jsx("th",{className:"px-6 py-3 font-bold",children:"Date Joined"}),e.jsx("th",{className:"px-6 py-3 font-bold",children:"Name"}),e.jsx("th",{className:"px-6 py-3 font-bold",children:"Email"}),e.jsx("th",{className:"px-6 py-3 font-bold",children:"Tags"}),e.jsx("th",{className:"px-6 py-3 font-bold",children:"Invite Engagement"}),e.jsx("th",{className:"px-6 py-3 font-bold",children:"Invited At"}),e.jsx("th",{className:"px-6 py-3 font-bold text-right",children:"Status"}),e.jsx("th",{className:"px-6 py-3 font-bold text-right",children:"Actions"})]})}),e.jsx("tbody",{children:s.map(y=>{var f;const v=y.status==="invited",g=n===y.id,N=(f=y.metadata)==null?void 0:f.last_invite_message_id,b=a.has(y.id);return e.jsxs("tr",{className:"border-b last:border-0 transition-colors",style:{borderColor:"rgba(59,10,17,0.05)",background:b?"rgba(212,175,55,0.08)":void 0},children:[e.jsx("td",{className:"px-4 py-4",children:e.jsx("button",{onClick:()=>r(y.id),"aria-label":b?`Deselect ${y.email}`:`Select ${y.email}`,className:"inline-flex items-center justify-center w-5 h-5 rounded-sm transition-all",style:{background:b?k:"#fff",border:`1px solid ${b?k:"rgba(59,10,17,0.3)"}`},children:b&&e.jsx(vo,{size:12,style:{color:$}})})}),e.jsx("td",{className:"px-6 py-4 whitespace-nowrap",children:e.jsxs("div",{className:"flex items-center gap-2 text-xs text-gray-700",children:[e.jsx(At,{size:12,style:{color:$}}),nte(y.created_at)]})}),e.jsx("td",{className:"px-6 py-4",children:e.jsx("div",{className:"font-semibold",style:{color:k},children:y.name||e.jsx("span",{className:"text-gray-400 italic",children:"No name"})})}),e.jsx("td",{className:"px-6 py-4",children:e.jsxs("a",{href:`mailto:${y.email}`,className:"inline-flex items-center gap-1.5 text-xs text-gray-700 hover:underline",children:[e.jsx(Ye,{size:12,style:{color:$}}),y.email]})}),e.jsx("td",{className:"px-6 py-4",children:e.jsx("div",{className:"flex flex-wrap gap-1",children:(y.tags||[]).slice(0,3).map(j=>e.jsx("span",{className:"px-2 py-0.5 rounded-sm text-[10px] font-semibold uppercase tracking-wide",style:{background:j==="vip-waitlist"?$:vi,color:k,border:j==="vip-waitlist"?"none":`1px solid ${lm}`},children:j},j))})}),e.jsx("td",{className:"px-6 py-4",children:e.jsx(ote,{metadata:y.metadata,hasBeenSent:!!N||v})}),e.jsxs("td",{className:"px-6 py-4 whitespace-nowrap text-xs text-gray-600",children:[e.jsx("div",{children:Hc(y.invited_at)}),N&&e.jsxs("div",{className:"text-[10px] text-gray-400 mt-0.5 truncate max-w-[180px]",title:N,children:["id: ",N.slice(0,22),N.length>22?"â¦":""]})]}),e.jsx("td",{className:"px-6 py-4 text-right",children:e.jsx("button",{onClick:()=>o(y),disabled:g,title:v?"Click to mark as pending":"Click to mark as invited",className:"inline-flex items-center gap-2 px-3 py-1.5 rounded-sm text-[11px] font-bold tracking-wide transition-all disabled:opacity-60",style:{background:v?k:"#fff",color:v?$:k,border:v?`1px solid ${k}`:`1px solid ${$}`,minWidth:140,justifyContent:"center"},children:g?e.jsx(de,{size:12,className:"animate-spin"}):v?e.jsxs(e.Fragment,{children:[e.jsx(Ue,{size:12})," Invited"]}):e.jsxs(e.Fragment,{children:[e.jsx(zb,{size:12})," Mark Invited"]})})}),e.jsx("td",{className:"px-6 py-4 text-right",children:e.jsxs("button",{onClick:()=>l(y),title:v?"Re-send invitation email":"Preview and send invitation email",className:"inline-flex items-center gap-2 px-3 py-1.5 rounded-sm text-[11px] font-bold tracking-wide transition-all hover:shadow-sm",style:{background:v?"#fff":$,color:k,border:`1px solid ${k}`,minWidth:160,justifyContent:"center"},children:[e.jsx(Hs,{size:12}),v?"Re-send Invite":"Send Invite Email"]})})]},y.id)})})]})})]})},ite=()=>e.jsx("span",{className:"inline-flex items-center justify-center",style:{width:12,height:12},children:e.jsx("span",{style:{display:"inline-block",width:8,height:2,background:k,borderRadius:1}})}),ote=({metadata:t,hasBeenSent:s})=>{const n=t||{},a=n.delivered_at,r=n.opened_at,i=n.clicked_at,o=n.bounced_at,l=n.complained_at,c=n.unsubscribed_at,u=typeof n.open_count=="number"?n.open_count:0,p=typeof n.click_count=="number"?n.click_count:0;return o?e.jsx(lu,{icon:ve,label:"Bounced",tone:"danger",tooltip:`Bounced ${Hc(o)} â ${n.bounce_reason||"no reason"}`}):l?e.jsx(lu,{icon:ve,label:"Spam Complaint",tone:"danger",tooltip:`Complained ${Hc(l)}`}):c?e.jsx(lu,{icon:ve,label:"Unsubscribed",tone:"warning",tooltip:`Unsubscribed ${Hc(c)}`}):s?e.jsxs("div",{className:"flex flex-wrap gap-1.5",children:[e.jsx(lu,{icon:gd,label:"Delivered",tone:a?"active":"inactive",tooltip:a?`Delivered ${Hc(a)}`:"Awaiting delivery confirmation"}),e.jsx(lu,{icon:ms,label:r?`Opened${u>1?` Ã${u}`:""}`:"Opened",tone:r?"active":"inactive",tooltip:r?`First opened ${Hc(r)} (${u} ${u===1?"open":"opens"})`:"Not yet opened"}),e.jsx(lu,{icon:e5,label:i?`Clicked${p>1?` Ã${p}`:""}`:"Clicked",tone:i?"active":"inactive",tooltip:i?`First click ${Hc(i)} (${p} ${p===1?"click":"clicks"})${n.last_clicked_url?` â ${n.last_clicked_url}`:""}`:"No link clicks yet"})]}):e.jsx("span",{className:"text-[10px] text-gray-400 italic",children:"Not yet sent"})},lu=({icon:t,label:s,tone:n,tooltip:a})=>{const r={active:{background:k,color:$,border:`1px solid ${k}`},inactive:{background:"#fff",color:"#9ca3af",border:"1px dashed rgba(59,10,17,0.18)"},danger:{background:"#fef2f2",color:"#991b1b",border:"1px solid #fecaca"},warning:{background:"#fffbeb",color:"#92400e",border:"1px solid #fcd34d"}};return e.jsxs("span",{title:a,className:"inline-flex items-center gap-1 px-2 py-0.5 rounded-sm text-[10px] font-bold uppercase tracking-wide whitespace-nowrap",style:r[n],children:[e.jsx(t,{size:10}),s]})}
1244,xg="#E6D2A0",wc="#FAF6EE",Aa={legalName:"Zorganics Foundation",dbaLine:"A Washington 501(c)(3) Nonprofit Organization",ein:"87-4273317",address1:"2200 James Street",address2:"Bellingham, WA 98225",phone:"(360) 555-0142",email:"[email protected]",signatory:"Office of the Executive Director"},mE=(t,s="usd")=>new Intl.NumberFormat("en-US",{style:"currency",currency:(s||"usd").toUpperCase(),minimumFractionDigits:2}).format((t||0)/100),lte=t=>{try{return new Date(t).toLocaleDateString("en-US",{year:"numeric",month:"long",day:"numeric"})}catch{return t}},cte=t=>{try{return new Date(t).toLocaleString("en-US",{year:"numeric",month:"short",day:"numeric",hour:"numeric",minute:"2-digit"})}catch{return t}},dte=()=>{var w;sn();const{paymentIntentId:t=""}=Wo(),[s,n]=d.useState(!0),[a,r]=d.useState(""),[i,o]=d.useState(null),l=3,c=30,u=`zf_resend_${t}`,[p,m]=d.useState(!1),[x,h]=d.useState(()=>{if(typeof window>"u"||!t)return 0;try{const _=window.sessionStorage.getItem(`zf_resend_${t}`);if(!_)return 0;const C=JSON.parse(_);return Number((C==null?void 0:C.count)||0)}catch{return 0}}),[y,v]=d.useState(()=>{if(typeof window>"u"||!t)return 0;try{const _=window.sessionStorage.getItem(`zf_resend_${t}`);if(!_)return 0;const C=JSON.parse(_),E=Number((C==null?void 0:C.lastAt)||0);if(!E)return 0;const P=Math.floor((Date.now()-E)/1e3);return Math.max(0,c-P)}catch{return 0}});d.useEffect(()=>{(async()=>{if(n(!0),r(""),!t||t.length<8){r("Missing payment reference. Please use the link from your confirmation email."),n(!1);return}try{const{data:C,error:E}=await O.from("foundation_donations").select("*").eq("payment_intent_id",t).order("created_at",{ascending:!1}).limit(1).maybeSingle();if(E)throw new Error(E.message||"Unable to load donation record.");if(!C){r("No donation record matches this reference yet. If you just completed your booking, please refresh in a moment â receipts can take a few seconds to appear."),n(!1);return}o(C)}catch(C){console.error("Receipt lookup error:",C),r((C==null?void 0:C.message)||"Unable to load receipt.")}finally{n(!1)}})()},[t]);const g=()=>{window.print()};d.useEffect(()=>{if(y<=0)return;const _=window.setInterval(()=>{v(C=>C<=1?0:C-1)},1e3);return()=>window.clearInterval(_)},[y]);const N=async()=>{if(!p){if(y>0){Ct.info(`Please wait ${y}s before re-sending.`);return}if(x>=l){Ct.error(`You've reached the limit of ${l} resends for this receipt. Email [email protected] if you still need help.`);return}m(!0);try{const _=typeof window<"u"?window.location.origin:"",{data:C,error:E}=await O.functions.invoke("resend-clinic-receipt-email",{body:{paymentIntentId:t,receiptOrigin:_}});if(E)throw new Error(E.message||"Unable to resend receipt.");if(!(C!=null&&C.success))throw new Error((C==null?void 0:C.error)||"Unable to resend receipt.");const P=(C==null?void 0:C.deliveredTo)||(i==null?void 0:i.donor_email)||"",F=x+1;try{window.sessionStorage.setItem(u,JSON.stringify({count:F,lastAt:Date.now()}))}catch{}h(F),v(c);const I=Math.max(0,l-F);Ct.success(`Receipt re-sent to ${P}`,{description:I>0?`${I} resend${I===1?"":"s"} remaining in this session.`:"You've used all your resends for this session."})}catch(_){console.error("Resend receipt failed:",_),Ct.error((_==null?void 0:_.message)||"Unable to resend receipt. Please try again later.")}finally{m(!1)}}};if(s)return e.jsx("div",{style:{background:wc},className:"min-h-screen flex items-center justify-center px-6",children:e.jsxs("div",{className:"text-center",children:[e.jsx(de,{size:36,className:"animate-spin mx-auto mb-4",style:{color:k}}),e.jsx("p",{className:"text-sm font-semibold",style:{color:k},children:"Loading your receiptâ¦"}),e.jsxs("p",{className:"text-xs text-gray-500 mt-2 font-mono",children:["Ref: ",t.slice(0,24),"â¦"]})]})});if(a||!i)return e.jsx("div",{style:{background:wc},className:"min-h-screen px-6 py-16",children:e.jsxs("div",{className:"max-w-xl mx-auto bg-white rounded-sm p-10 shadow-sm",style:{border:`1px solid ${xg}`},children:[e.jsxs("div",{className:"flex items-start gap-3 mb-5",children:[e.jsx(ve,{size:22,className:"shrink-0 text-amber-600 mt-0.5"}),e.jsxs("div",{children:[e.jsx("h1",{className:"text-xl font-bold",style:{color:k},children:"Receipt Not Available"}),e.jsx("p",{className:"mt-2 text-sm text-gray-700 leading-relaxed",children:a}),t&&e.jsxs("p",{className:"mt-3 text-[11px] text-gray-400 font-mono",children:["Reference: ",t]})]})]}),e.jsxs("div",{className:"flex flex-wrap gap-3 mt-6",children:[e.jsxs(be,{to:"/",className:"inline-flex items-center gap-2 px-5 py-2.5 rounded-sm text-sm font-semibold",style:{background:k,color:wc},children:[e.jsx(Je,{size:14})," Back to Zorganics"]}),e.jsx("a",{href:`mailto:${Aa.email}?subject=Receipt%20question%20${encodeURIComponent(t)}`,className:"inline-flex items-center gap-2 px-5 py-2.5 rounded-sm text-sm font-semibold border",style:{borderColor:k,color:k},children:"Email Foundation Office"})]})]})});const b=((w=i.donor_name)==null?void 0:w.trim())||"Valued Donor",f=mE(i.amount_cents,i.currency),j=`ZF-${i.id.slice(0,8).toUpperCase()}`,S=i.created_at||new Date().toISOString();return e.jsxs("div",{style:{background:wc},className:"min-h-screen",children:[e.jsx("style",{children:` 1245 @media print { 1246 .no-print { display: none !important; } 1247 body, html { background: white !important; } 1248 .receipt-paper { 1249 box-shadow: none !important; 1250 border: none !important; 1251 margin: 0 !important; 1252 max-width: 100% !important; 1253 } 1254 @page { size: letter; margin: 0.5in; } 1255 } 1256 `}),e.jsxs("div",{className:"no-print sticky top-0 z-20 border-b",style:{background:"#fff",borderColor:"rgba(59,10,17,0.1)"},children:[e.jsxs("div",{className:"max-w-3xl mx-auto px-6 py-3 flex items-center justify-between gap-3",children:[e.jsxs(be,{to:"/",className:"inline-flex items-center gap-2 text-sm font-semibold hover:underline",style:{color:k},children:[e.jsx(Je,{size:14})," Back to Zorganics"]}),e.jsxs("div",{className:"flex items-center gap-2 flex-wrap justify-end",children:[e.jsx("button",{type:"button",onClick:N,disabled:p||y>0||x>=l,className:"inline-flex items-center gap-2 px-4 py-2 rounded-sm text-sm font-semibold border transition-all hover:bg-gray-50 disabled:opacity-50 disabled:cursor-not-allowed",style:{borderColor:k,color:k},title:x>=l?`Resend limit reached (${l}/${l})`:y>0?`Cooldown · ${y}s`:`Re-send the receipt email to ${i.donor_email}`,children:p?e.jsxs(e.Fragment,{children:[e.jsx(de,{size:14,className:"animate-spin"})," Sendingâ¦"]}):y>0?e.jsxs(e.Fragment,{children:[e.jsx(Ye,{size:14})," Resend · ",y,"s"]}):e.jsxs(e.Fragment,{children:[e.jsx(Ye,{size:14})," Resend Email"]})}),e.jsxs("button",{type:"button",onClick:g,className:"inline-flex items-center gap-2 px-4 py-2 rounded-sm text-sm font-semibold border transition-all hover:bg-gray-50",style:{borderColor:k,color:k},children:[e.jsx(ef,{size:14})," Print"]}),e.jsxs("button",{type:"button",onClick:g,className:"inline-flex items-center gap-2 px-4 py-2 rounded-sm text-sm font-bold tracking-wide transition-all",style:{background:$,color:k,boxShadow:"0 4px 14px rgba(212,175,55,0.35)"},title:"Open the print dialog and choose 'Save as PDF' to download",children:[e.jsx(us,{size:14})," Download as PDF"]})]})]}),x>0&&e.jsx("div",{className:"max-w-3xl mx-auto px-6 pb-2 -mt-1 text-right",children:e.jsxs("span",{className:"text-[11px] text-gray-500",children:["Receipt re-sent ",x,"/",l," this session"]})})]}),e.jsxs("div",{className:"max-w-3xl mx-auto px-6 py-10 print:p-0",children:[e.jsxs("div",{className:"receipt-paper bg-white rounded-sm shadow-md overflow-hidden",style:{border:`1px solid ${xg}`},children:[e.jsx("div",{className:"px-10 pt-10 pb-6",style:{background:"#fff",borderBottom:`2px solid ${$}`},children:e.jsxs("div",{className:"flex items-start justify-between gap-6",children:[e.jsxs("div",{children:[e.jsxs("div",{className:"inline-flex items-center gap-2 mb-3",children:[e.jsx(Qe,{size:16,style:{color:$}}),e.jsx("span",{className:"text-[10px] tracking-[0.3em] uppercase font-bold",style:{color:$},children:"Official Tax-Deductible Receipt"})]}),e.jsx("h1",{className:"text-2xl font-bold leading-tight",style:{color:k,fontFamily:"'Inter', sans-serif"},children:Aa.legalName}),e.jsx("p",{className:"text-xs text-gray-600 mt-1",children:Aa.dbaLine}),e.jsxs("p",{className:"text-xs text-gray-600 mt-0.5",children:[Aa.address1," · ",Aa.address2]}),e.jsxs("p",{className:"text-xs text-gray-600 mt-0.5",children:[Aa.phone," · ",Aa.email]})]}),e.jsxs("div",{className:"text-right shrink-0",children:[e.jsx("div",{className:"inline-flex items-center justify-center w-16 h-16 rounded-full",style:{background:wc,border:`2px solid ${$}`},children:e.jsx(ta,{size:26,style:{color:k}})}),e.jsx("div",{className:"mt-2 text-[9px] tracking-[0.25em] font-bold uppercase",style:{color:k},children:"Z · Foundation"})]})]})}),e.jsxs("div",{className:"px-10 py-6 grid grid-cols-1 sm:grid-cols-3 gap-4 text-xs",style:{background:wc,borderBottom:"1px solid rgba(59,10,17,0.08)"},children:[e.jsxs("div",{children:[e.jsx("div",{className:"text-[10px] uppercase tracking-[0.18em] text-gray-500 font-semibold mb-1",children:"Receipt No."}),e.jsx("div",{className:"font-mono font-semibold",style:{color:k},children:j})]}),e.jsxs("div",{children:[e.jsx("div",{className:"text-[10px] uppercase tracking-[0.18em] text-gray-500 font-semibold mb-1",children:"Date of Contribution"}),e.jsx("div",{className:"font-semibold",style:{color:k},children:lte(S)})]}),e.jsxs("div",{children:[e.jsx("div",{className:"text-[10px] uppercase tracking-[0.18em] text-gray-500 font-semibold mb-1",children:"Federal Tax ID (EIN)"}),e.jsx("div",{className:"font-mono font-semibold",style:{color:k},children:Aa.ein})]})]}),e.jsxs("div",{className:"px-10 py-8",children:[e.jsx("div",{className:"text-[10px] tracking-[0.22em] uppercase text-gray-500 font-semibold mb-2",children:"Donor"}),e.jsx("div",{className:"text-lg font-bold",style:{color:k},children:b}),e.jsx("div",{className:"text-sm text-gray-700 mt-0.5",children:i.donor_email}),e.jsxs("div",{className:"mt-7 p-7 rounded-sm flex flex-col sm:flex-row sm:items-center sm:justify-between gap-4",style:{background:"#fff",border:`2px solid ${$}`},children:[e.jsxs("div",{children:[e.jsx("div",{className:"text-[10px] tracking-[0.22em] uppercase font-bold",style:{color:$},children:"Charitable Contribution"}),e.jsxs("div",{className:"text-xs text-gray-600 mt-1",children:["Foundation gift received at student-clinic checkout",i.campus?` · ${i.campus} campus`:"","."]})]}),e.jsxs("div",{className:"text-right",children:[e.jsx("div",{className:"text-3xl sm:text-4xl font-bold tracking-tight",style:{color:k},children:f}),e.jsxs("div",{className:"text-[10px] uppercase tracking-[0.2em] text-gray-500 font-semibold mt-1",children:[(i.currency||"usd").toUpperCase()," · Received"]})]})]}),e.jsx("div",{className:"mt-7 p-5 rounded-sm text-xs leading-relaxed text-gray-700",style:{background:wc,border:`1px solid ${xg}`},children:e.jsxs("div",{className:"flex items-start gap-2",children:[e.jsx(Ie,{size:14,style:{color:$},className:"mt-0.5 shrink-0"}),e.jsxs("div",{children:[e.jsxs("p",{children:[e.jsx("strong",{style:{color:k},children:"No goods or services were provided"})," by the ",Aa.legalName," ","in exchange for this contribution. Your gift is tax-deductible to the fullest extent allowed by law under Section 170 of the Internal Revenue Code. Please retain this receipt for your records; the ",Aa.legalName," does not provide tax advice and recommends consulting your tax professional."]}),i.service_total_cents!=null&&i.service_total_cents>0&&e.jsxs("p",{className:"mt-2 text-[11px] text-gray-600",children:["Note: This receipt reflects only the charitable portion of your transaction. The separate student-clinic service charge of"," ",e.jsx("span",{className:"font-semibold",style:{color:k},children:mE(i.service_total_cents,i.currency)})," ","is not deductible and is not included in the amount above."]})]})]})}),e.jsxs("div",{className:"mt-6 pt-5 border-t grid grid-cols-1 sm:grid-cols-2 gap-4 text-[11px]",style:{borderColor:"rgba(59,10,17,0.08)"},children:[e.jsxs("div",{children:[e.jsx("div",{className:"uppercase tracking-[0.18em] text-gray-500 font-semibold mb-1",children:"Payment Reference"}),e.jsx("div",{className:"font-mono text-gray-700 break-all",children:i.payment_intent_id||"â"})]}),e.jsxs("div",{children:[e.jsx("div",{className:"uppercase tracking-[0.18em] text-gray-500 font-semibold mb-1",children:"Issued"}),e.jsx("div",{className:"text-gray-700",children:cte(S)})]})]}),e.jsxs("div",{className:"mt-10 grid grid-cols-1 sm:grid-cols-2 gap-6 items-end",children:[e.jsxs("div",{children:[e.jsx("div",{className:"border-b mb-2 pb-1",style:{borderColor:k},children:e.jsx("span",{className:"text-base italic",style:{color:k,fontFamily:"'Georgia', serif"},children:"Zorganics Foundation"})}),e.jsxs("div",{className:"text-[10px] uppercase tracking-[0.18em] text-gray-500 font-semibold",children:["Authorized Signature · ",Aa.signatory]})]}),e.jsx("div",{className:"text-right text-xs text-gray-600",children:e.jsx("p",{className:"italic leading-relaxed",children:"Thank y
1256ou for investing in the next generation of clinical skin scientists."})})]})]}),e.jsxs("div",{className:"px-10 py-4 text-center text-[10px] uppercase tracking-[0.22em]",style:{background:k,color:xg},children:[Aa.legalName," · EIN ",Aa.ein," · 501(c)(3) Public Charity"]})]}),e.jsxs("div",{className:"no-print mt-6 text-center text-[11px] text-gray-500 leading-relaxed",children:["To save a PDF copy: tap ",e.jsx("span",{className:"font-semibold",style:{color:k},children:"Download as PDF"})," and select ",e.jsx("em",{children:"âSave as PDFâ"})," as the destination in your browser's print dialog."]})]})]})},fg="#E6D2A0",Nc="#FAF6EE",Qa={legalName:"Zorganics Foundation",dbaLine:"A Washington 501(c)(3) Nonprofit Organization",ein:"87-4273317",address1:"2200 James Street",address2:"Bellingham, WA 98225",phone:"(360) 555-0142",email:"[email protected]",signatory:"Office of the Executive Director"},ute=(t,s="usd")=>new Intl.NumberFormat("en-US",{style:"currency",currency:(s||"usd").toUpperCase(),minimumFractionDigits:2}).format((t||0)/100),mte=t=>{try{return new Date(t).toLocaleDateString("en-US",{year:"numeric",month:"long",day:"numeric"})}catch{return t}},pte=t=>{try{return new Date(t).toLocaleString("en-US",{year:"numeric",month:"short",day:"numeric",hour:"numeric",minute:"2-digit"})}catch{return t}},hte=()=>{var w;sn();const[t]=cc(),s=t.get("session_id")||"",n=t.get("donation")||"",[a,r]=d.useState(!0),[i,o]=d.useState(""),[l,c]=d.useState(null),[u,p]=d.useState(!1),m=d.useRef(0),x=d.useCallback(async()=>{let _=O.from("z_foundation_donations").select("*").limit(1);if(n)_=_.eq("id",n);else if(s)_=_.eq("stripe_checkout_session_id",s);else return null;const{data:C}=await _.maybeSingle();return C||null},[n,s]);d.useEffect(()=>{let _=!1;const C=async()=>{if(!n&&!s){o("Missing donation reference. Please use the link from your confirmation email."),r(!1);return}try{try{await O.functions.invoke("donation-webhook-sync",{body:{session_id:s||void 0,donation_id:n||void 0}})}catch{}const E=await x();if(_)return;if(!E){o("No donation record matches this reference yet. If you just completed payment, please refresh in a moment â receipts can take a few seconds to appear."),r(!1);return}c(E),r(!1),E.status!=="completed"&&m.current<5&&(m.current+=1,setTimeout(C,3e3))}catch(E){if(_)return;o((E==null?void 0:E.message)||"Unable to load receipt."),r(!1)}};return C(),()=>{_=!0}},[n,s]);const h=()=>window.print(),y=async()=>{if(!(u||!l)){p(!0);try{const _=typeof window<"u"?window.location.origin:"",{data:C,error:E}=await O.functions.invoke("send-donation-receipt",{body:{donation_id:l.id,force:!0,receiptOrigin:_}});if(E)throw new Error(E.message);if(!(C!=null&&C.success))throw new Error((C==null?void 0:C.error)||"Unable to resend receipt.");Ct.success(`Receipt re-sent to ${C.deliveredTo||l.donor_email}`)}catch(_){Ct.error((_==null?void 0:_.message)||"Unable to resend receipt.")}finally{p(!1)}}};if(a)return e.jsx("div",{style:{background:Nc},className:"min-h-screen flex items-center justify-center px-6",children:e.jsxs("div",{className:"text-center",children:[e.jsx(de,{size:36,className:"animate-spin mx-auto mb-4",style:{color:k}}),e.jsx("p",{className:"text-sm font-semibold",style:{color:k},children:"Confirming your giftâ¦"}),e.jsx("p",{className:"text-xs text-gray-500 mt-2",children:"Securing your tax-deductible receipt."})]})});if(i||!l)return e.jsx("div",{style:{background:Nc},className:"min-h-screen px-6 py-16",children:e.jsxs("div",{className:"max-w-xl mx-auto bg-white rounded-sm p-10 shadow-sm",style:{border:`1px solid ${fg}`},children:[e.jsxs("div",{className:"flex items-start gap-3 mb-5",children:[e.jsx(ve,{size:22,className:"shrink-0 text-amber-600 mt-0.5"}),e.jsxs("div",{children:[e.jsx("h1",{className:"text-xl font-bold",style:{color:k},children:"Receipt Not Available Yet"}),e.jsx("p",{className:"mt-2 text-sm text-gray-700 leading-relaxed",children:i})]})]}),e.jsxs("div",{className:"flex flex-wrap gap-3 mt-6",children:[e.jsx("button",{onClick:()=>window.location.reload(),className:"inline-flex items-center gap-2 px-5 py-2.5 rounded-sm text-sm font-semibold",style:{background:k,color:Nc},children:"Refresh"}),e.jsxs(be,{to:"/",className:"inline-flex items-center gap-2 px-5 py-2.5 rounded-sm text-sm font-semibold border",style:{borderColor:k,color:k},children:[e.jsx(Je,{size:14})," Back to Zorganics"]})]})]})});const v=((w=l.donor_name)==null?void 0:w.trim())||"Valued Donor",g=ute(l.amount_cents,l.currency||"usd"),N=l.receipt_number||`ZF-${l.id.slice(0,8).toUpperCase()}`,b=l.processed_at||l.created_at||new Date().toISOString(),f=l.status==="completed",j=l.frequency&&l.frequency!=="one-time",S=l.stripe_payment_intent_id||l.stripe_checkout_session_id||"â";return e.jsxs("div",{style:{background:Nc},className:"min-h-screen",children:[e.jsx("style",{children:` 1257 @media print { 1258 .no-print { display: none !important; } 1259 body, html { background: white !important; } 1260 .receipt-paper { box-shadow: none !important; border: none !important; margin: 0 !important; max-width: 100% !important; } 1261 @page { size: letter; margin: 0.5in; } 1262 } 1263 `}),e.jsx("div",{className:"no-print sticky top-0 z-20 border-b",style:{background:"#fff",borderColor:"rgba(59,10,17,0.1)"},children:e.jsxs("div",{className:"max-w-3xl mx-auto px-6 py-3 flex items-center justify-between gap-3",children:[e.jsxs(be,{to:"/",className:"inline-flex items-center gap-2 text-sm font-semibold hover:underline",style:{color:k},children:[e.jsx(Je,{size:14})," Back to Zorganics"]}),e.jsxs("div",{className:"flex items-center gap-2 flex-wrap justify-end",children:[e.jsx("button",{type:"button",onClick:y,disabled:u||!l.donor_email,className:"inline-flex items-center gap-2 px-4 py-2 rounded-sm text-sm font-semibold border transition-all hover:bg-gray-50 disabled:opacity-50 disabled:cursor-not-allowed",style:{borderColor:k,color:k},title:l.donor_email?`Re-send the receipt email to ${l.donor_email}`:"No email on file",children:u?e.jsxs(e.Fragment,{children:[e.jsx(de,{size:14,className:"animate-spin"})," Sendingâ¦"]}):e.jsxs(e.Fragment,{children:[e.jsx(Ye,{size:14})," Email Receipt"]})}),e.jsxs("button",{type:"button",onClick:h,className:"inline-flex items-center gap-2 px-4 py-2 rounded-sm text-sm font-semibold border transition-all hover:bg-gray-50",style:{borderColor:k,color:k},children:[e.jsx(ef,{size:14})," Print"]}),e.jsxs("button",{type:"button",onClick:h,className:"inline-flex items-center gap-2 px-4 py-2 rounded-sm text-sm font-bold tracking-wide transition-all",style:{background:$,color:k,boxShadow:"0 4px 14px rgba(212,175,55,0.35)"},title:"Open the print dialog and choose 'Save as PDF' to download",children:[e.jsx(us,{size:14})," Download as PDF"]})]})]})}),e.jsx("div",{className:"no-print max-w-3xl mx-auto px-6 pt-6",children:f?e.jsxs("div",{className:"flex items-center gap-3 px-5 py-3 rounded-sm text-sm font-semibold",style:{background:"#0f5132",color:"#d1f7e2"},children:[e.jsx(Ue,{size:18}
1263)," Payment confirmed â thank you for your generous gift!"]}):e.jsxs("div",{className:"flex items-center gap-3 px-5 py-3 rounded-sm text-sm font-semibold",style:{background:"#fff7e6",color:k,border:`1px solid ${$}`},children:[e.jsx(dt,{size:18})," Your gift is being confirmed. This page will update automatically in a few seconds."]})}),e.jsxs("div",{className:"max-w-3xl mx-auto px-6 py-8 print:p-0",children:[e.jsxs("div",{className:"receipt-paper bg-white rounded-sm shadow-md overflow-hidden",style:{border:`1px solid ${fg}`},children:[e.jsx("div",{className:"px-10 pt-10 pb-6",style:{background:"#fff",borderBottom:`2px solid ${$}`},children:e.jsxs("div",{className:"flex items-start justify-between gap-6",children:[e.jsxs("div",{children:[e.jsxs("div",{className:"inline-flex items-center gap-2 mb-3",children:[e.jsx(Qe,{size:16,style:{color:$}}),e.jsx("span",{className:"text-[10px] tracking-[0.3em] uppercase font-bold",style:{color:$},children:"Official Tax-Deductible Receipt"})]}),e.jsx("h1",{className:"text-2xl font-bold leading-tight",style:{color:k},children:Qa.legalName}),e.jsx("p",{className:"text-xs text-gray-600 mt-1",children:Qa.dbaLine}),e.jsxs("p",{className:"text-xs text-gray-600 mt-0.5",children:[Qa.address1," · ",Qa.address2]}),e.jsxs("p",{className:"text-xs text-gray-600 mt-0.5",children:[Qa.phone," · ",Qa.email]})]}),e.jsxs("div",{className:"text-right shrink-0",children:[e.jsx("div",{className:"inline-flex items-center justify-center w-16 h-16 rounded-full",style:{background:Nc,border:`2px solid ${$}`},children:e.jsx(ta,{size:26,style:{color:k}})}),e.jsx("div",{className:"mt-2 text-[9px] tracking-[0.25em] font-bold uppercase",style:{color:k},children:"Z · Foundation"})]})]})}),e.jsxs("div",{className:"px-10 py-6 grid grid-cols-1 sm:grid-cols-3 gap-4 text-xs",style:{background:Nc,borderBottom:"1px solid rgba(59,10,17,0.08)"},children:[e.jsxs("div",{children:[e.jsx("div",{className:"text-[10px] uppercase tracking-[0.18em] text-gray-500 font-semibold mb-1",children:"Receipt No."}),e.jsx("div",{className:"font-mono font-semibold",style:{color:k},children:N})]}),e.jsxs("div",{children:[e.jsx("div",{className:"text-[10px] uppercase tracking-[0.18em] text-gray-500 font-semibold mb-1",children:"Date of Contribution"}),e.jsx("div",{className:"font-semibold",style:{color:k},children:mte(b)})]}),e.jsxs("div",{children:[e.jsx("div",{className:"text-[10px] uppercase tracking-[0.18em] text-gray-500 font-semibold mb-1",children:"Federal Tax ID (EIN)"}),e.jsx("div",{className:"font-mono font-semibold",style:{color:k},children:Qa.ein})]})]}),e.jsxs("div",{className:"px-10 py-8",children:[e.jsx("div",{className:"text-[10px] tracking-[0.22em] uppercase text-gray-500 font-semibold mb-2",children:"Donor"}),e.jsx("div",{className:"text-lg font-bold",style:{color:k},children:v}),l.donor_email&&e.jsx("div",{className:"text-sm text-gray-700 mt-0.5",children:l.donor_email}),e.jsxs("div",{className:"mt-7 p-7 rounded-sm flex flex-col sm:flex-row sm:items-center sm:justify-between gap-4",style:{background:"#fff",border:`2px solid ${$}`},children:[e.jsxs("div",{children:[e.jsx("div",{className:"text-[10px] tracking-[0.22em] uppercase font-bold",style:{color:$},children:"Charitable Contribution"}),e.jsxs("div",{className:"text-xs text-gray-600 mt-1",children:[j?"Recurring":"One-time"," gift",l.purpose?` · ${l.purpose}`:"","."]})]}),e.jsxs("div",{className:"text-right",children:[e.jsx("div",{className:"text-3xl sm:text-4xl font-bold tracking-tight",style:{color:k},children:g}),e.jsxs("div",{className:"text-[10px] uppercase tracking-[0.2em] text-gray-500 font-semibold mt-1",children:[(l.currency||"usd").toUpperCase()," · ",f?"Received":"Processing"]})]})]}),e.jsx("div",{className:"mt-7 p-5 rounded-sm text-xs leading-relaxed text-gray-700",style:{background:Nc,border:`1px solid ${fg}`},children:e.jsxs("div",{className:"flex items-start gap-2",children:[e.jsx(Ie,{size:14,style:{color:$},className:"mt-0.5 shrink-0"}),e.jsxs("p",{children:[e.jsx("strong",{style:{color:k},children:"No goods or services were provided"})," by the ",Qa.legalName," ","in exchange for this contribution. Your gift is tax-deductible to the fullest extent allowed by law under Section 170 of the Internal Revenue Code. Please retain this receipt for your records; the"," ",Qa.legalName," does not provide tax advice and recommends consulting your tax professional."]})]})}),e.jsxs("div",{className:"mt-6 pt-5 border-t grid grid-cols-1 sm:grid-cols-2 gap-4 text-[11px]",style:{borderColor:"rgba(59,10,17,0.08)"},children:[e.jsxs("div",{children:[e.jsx("div",{className:"uppercase tracking-[0.18em] text-gray-500 font-semibold mb-1",children:"Payment Reference"}),e.jsx("div",{className:"font-mono text-gray-700 break-all",children:S})]}),e.jsxs("div",{children:[e.jsx("div",{className:"uppercase tracking-[0.18em] text-gray-500 font-semibold mb-1",children:"Issued"}),e.jsx("div",{className:"text-gray-700",children:pte(b)})]})]}),e.jsxs("div",{className:"mt-10 grid grid-cols-1 sm:grid-cols-2 gap-6 items-end",children:[e.jsxs("div",{children:[e.jsx("div",{className:"border-b mb-2 pb-1",style:{borderColor:k},children:e.jsx("span",{className:"text-base italic",style:{color:k,fontFamily:"'Georgia', serif"},children:"Zorganics Foundation"})}),e.jsxs("div",{className:"text-[10px] uppercase tracking-[0.18em] text-gray-500 font-semibold",children:["Authorized Signature · ",Qa.signatory]})]}),e.jsx("div",{className:"text-right text-xs text-gray-600",children:e.jsx("p",{className:"italic leading-relaxed",children:"Thank y
1263ou for investing in the next generation of clinical skin scientists."})})]})]}),e.jsxs("div",{className:"px-10 py-4 text-center text-[10px] uppercase tracking-[0.22em]",style:{background:k,color:fg},children:[Qa.legalName," · EIN ",Qa.ein," · 501(c)(3) Public Charity"]})]}),e.jsxs("div",{className:"no-print mt-6 text-center text-[11px] text-gray-500 leading-relaxed",children:["A copy of this receipt ",l.donor_email?`was emailed to ${l.donor_email}`:"is available here",". To save a PDF: tap ",e.jsx("span",{className:"font-semibold",style:{color:k},children:"Download as PDF"})," and select"," ",e.jsx("em",{children:"âSave as PDFâ"})," as the destination in your browser's print dialog."]})]})]})};class KI extends Error{constructor(n,a){super(`Query "${n}" exceeded ${a}ms timeout`);cp(this,"label");cp(this,"elapsedMs");this.name="QueryTimeoutError",this.label=n,this.elapsedMs=a}}function xte(t,s,n="query"){let a=null;const r=new Promise((i,o)=>{a=setTimeout(()=>o(new KI(n,s)),s)});return Promise.race([t.then(i=>(a&&clearTimeout(a),i),i=>{throw a&&clearTimeout(a),i}),r])}async function cm(t,s,n=12e3){const a=new Date().toISOString(),r=performance.now();try{const i=await xte(Promise.resolve(s),n,t),o=Math.round(performance.now()-r);return{label:t,data:(i==null?void 0:i.data)??null,error:(i==null?void 0:i.error)??null,durationMs:o,startedAt:a,finishedAt:new Date().toISOString(),timedOut:!1}}catch(i){const o=Math.round(performance.now()-r),l=i instanceof KI;return{label:t,data:null,error:l?{message:i.message,code:"TIMEOUT"}:i!=null&&i.message?{message:i.message}:i,durationMs:o,startedAt:a,finishedAt:new Date().toISOString(),timedOut:l}}}function dm(t){return t<1e3?`${Math.round(t)}ms`:`${(t/1e3).toFixed(1)}s`}const gg=1e4;function fte(){sn();const[t,s]=d.useState([]),[n,a]=d.useState(!1),[r,i]=d.useState(null),[o,l]=d.useState(null),[c,u]=d.useState(null),[p,m]=d.useState(""),[x,h]=d.useState(0),y=async()=>{var _,C,E;a(!0),s([]),i(null);const f=performance.now();try{const P=await Promise.race([O.auth.getSession(),new Promise(I=>setTimeout(()=>I({data:{session:null}}),5e3))]),F=((_=P==null?void 0:P.data)==null?void 0:_.session)??null;l(((C=F==null?void 0:F.user)==null?void 0:C.email)??null),u(((E=F==null?void 0:F.user)==null?void 0:E.role)??(F?"authenticated":"anon"))}catch{u("anon")}try{const P=(O==null?void 0:O.restUrl)||(O==null?void 0:O.supabaseUrl)||"";m(String(P).replace("/rest/v1",""))}catch{}const j=[["z_entity_accounts",O.from("z_entity_accounts").select("id,entity_key,account_name",{count:"exact",head:!1}).limit(50)],["z_entity_ledger",O.from("z_entity_ledger").select("id",{count:"exact",head:!0})],["z_entity_api_connections",O.from("z_entity_api_connections").select("id",{count:"exact",head:!0})],["ecom_collections",O.from("ecom_collections").select("id,title,handle,is_visible").limit(50)],["ecom_products (active)",O.from("ecom_products").select("id,name,status").eq("status","active").limit(50)],["ecom_product_collections",O.from("ecom_product_collections").select("id",{count:"exact",head:!0})],["ecom_product_variants",O.from("ecom_product_variants").select("id",{count:"exact",head:!0})]],w=(await Promise.all(j.map(([P,F])=>cm(P,F,gg)))).map(P=>({...P,rowCount:Array.isArray(P.data)?P.data.length:null}));s(w),i(Math.round(performance.now()-f)),h(P=>P+1),a(!1)};d.useEffect(()=>{y()},[]);const v=f=>f.timedOut?{label:"TIMEOUT",tone:"bg-red-100 text-red-800 border-red-300"}:f.error?{label:"ERROR",tone:"bg-amber-100 text-amber-800 border-amber-300"}:f.rowCount===0?{label:"EMPTY",tone:"bg-yellow-50 text-yellow-800 border-yellow-300"}:{label:"OK",tone:"bg-emerald-100 text-emerald-800 border-emerald-300"},g=t.filter(f=>f.error||f.timedOut).length,N=t.filter(f=>f.timedOut).length,b=t.filter(f=>!f.timedOut&&f.durationMs>2e3).length;return e.jsxs("div",{className:"min-h-screen bg-stone-50",children:[e.jsx("header",{className:"bg-gradient-to-r from-[#3b1f2b] to-[#5a2a3f] text-white border-b-4 border-amber-400",children:e.jsxs("div",{className:"max-w-6xl mx-auto px-6 py-6 flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-amber-300 text-xs tracking-widest uppercase mb-1",children:"Internal Tooling"}),e.jsx("h1",{className:"text-2xl font-serif",children:"Loading Diagnostics"}),e.jsxs("p",{className:"text-stone-300 text-sm mt-1",children:["Runs every critical canonical query with per-call timeouts so we can identify",e.jsx("em",{children:" exactly "})," which request is hung, failing, or empty."]})]}),e.jsx(be,{to:"/",className:"text-amber-300 text-sm hover:text-amber-200 underline underline-offset-4",children:"â Back to site"})]})}),e.jsxs("main",{className:"max-w-6xl mx-auto px-6 py-8 space-y-6",children:[e.jsxs("section",{className:"grid grid-cols-2 md:grid-cols-4 gap-4",children:[e.jsx(yg,{label:"Queries",value:t.length||"â",sub:n?"runningâ¦":`run #${x}`,tone:"bg-white"}),e.jsx(yg,{label:"Total elapsed",value:r==null?"â":dm(r),sub:`cap ${gg/1e3}s/query`,tone:"bg-white"}),e.jsx(yg,{label:"Errors / Timeouts",value:`${g} / ${N}`,sub:g?"investigate below":"all clean",tone:g?"bg-red-50":"bg-emerald-50"}),e.jsx(yg,{label:"Slow (>2s)",value:b,sub:b?"check network tab":"snappy",tone:b?"bg-amber-50":"bg-emerald-50"})]}),e.jsxs("section",{className:"bg-white border border-stone-200 rounded-lg p-5 shadow-sm",children:[e.jsx("h2",{className:"font-serif text-lg text-stone-900 mb
1263-3",children:"Environment"}),e.jsxs("dl",{className:"grid grid-cols-1 md:grid-cols-3 gap-3 text-sm",children:[e.jsx(cu,{label:"Supabase URL",value:p||"â",mono:!0}),e.jsx(cu,{label:"Auth email",value:o||"(anonymous)"}),e.jsx(cu,{label:"Role",value:c||"â"}),e.jsx(cu,{label:"User agent",value:typeof navigator<"u"?navigator.userAgent:"â",mono:!0,small:!0}),e.jsx(cu,{label:"Online",value:typeof navigator<"u"&&navigator.onLine?"yes":"no"}),e.jsx(cu,{label:"Timestamp",value:new Date().toLocaleString()})]})]}),e.jsxs("section",{className:"bg-white border border-stone-200 rounded-lg shadow-sm overflow-hidden",children:[e.jsxs("div",{className:"px-5 py-4 border-b border-stone-200 flex items-center justify-between",children:[e.jsx("h2",{className:"font-serif text-lg text-stone-900",children:"Per-query results"}),e.jsx("button",{onClick:y,disabled:n,className:"px-4 py-2 bg-[#3b1f2b] text-white rounded-md text-sm font-medium hover:bg-[#5a2a3f] disabled:opacity-50 transition",children:n?"Runningâ¦":"Re-run diagnostics"})]}),e.jsx("div",{className:"overflow-x-auto",children:e.jsxs("table",{className:"w-full text-sm",children:[e.jsx("thead",{className:"bg-stone-100 text-stone-700 text-xs uppercase tracking-wide",children:e.jsxs("tr",{children:[e.jsx("th",{className:"text-left px-5 py-3",children:"Query"}),e.jsx("th",{className:"text-left px-5 py-3",children:"Status"}),e.jsx("th",{className:"text-right px-5 py-3",children:"Duration"}),e.jsx("th",{className:"text-right px-5 py-3",children:"Rows"}),e.jsx("th",{className:"text-left px-5 py-3",children:"Detail"})]})}),e.jsxs("tbody",{children:[n&&t.length===0&&e.jsx("tr",{children:e.jsx("td",{colSpan:5,className:"px-5 py-8 text-center text-stone-500",children:"Running queriesâ¦"})}),t.map(f=>{var S;const j=v(f);return e.jsxs("tr",{className:"border-t border-stone-200 hover:bg-stone-50",children:[e.jsx("td",{className:"px-5 py-3 font-mono text-xs text-stone-800",children:f.label}),e.jsx("td",{className:"px-5 py-3",children:e.jsx("span",{className:`inline-block px-2 py-0.5 text-xs font-semibold rounded border ${j.tone}`,children:j.label})}),e.jsx("td",{className:"px-5 py-3 text-right font-mono text-xs text-stone-700",children:dm(f.durationMs)}),e.jsx("td",{className:"px-5 py-3 text-right font-mono text-xs text-stone-700",children:f.rowCount??"â"}),e.jsx("td",{className:"px-5 py-3 text-xs text-stone-600 max-w-md",children:f.timedOut?e.jsxs("span",{className:"text-red-700",children:["Hung > ",gg/1e3,"s â likely network / RLS recursion / CORS. Check DevTools â Network for the matching ",e.jsxs("code",{className:"bg-stone-100 px-1 rounded",children:["rest/v1/",f.label.split(" ")[0]]})," request."]}):f.error?e.jsx("code",{className:"block break-words text-amber-800",children:typeof f.error=="string"?f.error:((S=f.error)==null?void 0:S.message)||JSON.stringify(f.error)}):f.rowCount===0?e.jsx("span",{className:"text-yellow-700",children:"Query returned 0 rows. Table may be empty or filtered by RLS."}):e.jsxs("span",{className:"text-emerald-700",children:["Returned ",f.rowCount," row(s) in ",dm(f.durationMs),"."]})})]},f.label)})]})]})})]}),e.jsxs("section",{className:"bg-white border border-stone-200 rounded-lg p-5 shadow-sm text-sm text-stone-700 space-y-2",children:[e.jsx("h2",{className:"font-serif text-lg text-stone-900 mb-2",children:"How to read this"}),e.jsxs("p",{children:[e.jsx("strong",{className:"text-red-700",children:"TIMEOUT"})," â the request never returned within ",gg/1e3,'s. This is the classic "stuck on loading" cause: TLS stall, ad-blocker, captive portal, or a recursive RLS policy. Open DevTools â Network and find the pending request.']}),e.jsxs("p",{children:[e.jsx("strong",{className:"text-amber-700",children:"ERROR"})," â request returned an error response. Usually RLS denial (",e.jsx("code",{children:"42501"}),") or a JWT issue. Check the detail column."]}),e.jsxs("p",{children:[e.jsx("strong",{className:"text-yellow-700",children:"EMPTY"})," â query succeeded but returned 0 rows. Not a loading bug â a data/visibility issue."]}),e.jsxs("p",{children:[e.jsx("strong",{className:"text-emerald-700",children:"OK"})," â query returned rows. If the parent page is still stuck, the bug is in the component, not the query."]})]})]})]})}function yg({label:t,value:s,sub:n,tone:a}){return e.jsxs("div",{className:`${a} border border-stone-200 rounded-lg p-4 shadow-sm`,children:[e.jsx("p",{className:"text-xs uppercase tracking-wide text-stone-500",children:t}),e.jsx("p",{className:"text-2xl font-serif text-stone-900 mt-1",children:s}),e.jsx("p",{className:"text-xs text-stone-500 mt-1",children:n})]})}function cu({label:t,value:s,mono:n,small:a}){return e.jsxs("div",{children:[e.jsx("dt",{className:"text-xs uppercase tracking-wide text-stone-500",children:t}),e.jsx("dd",{className:`${n?"font-mono":""} ${a?"text-xs":"text-sm"} text-stone-800 break-all`,children:s})]})}const Jr=d.forwardRef(({className:t,type:s,...n},a)=>e.jsx("input",{type:s,className:et("flex h-10 w-full rounded-md border border-border/60 bg-background px-3 py-2 text-sm r
1263ing-offset-background file:border-0 file:bg-transparent file:text-sm file:font-medium placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50",t),ref:a,...n}));Jr.displayName="Input";const B5=d.forwardRef(({className:t,...s},n)=>e.jsx("textarea",{className:et("flex min-h-[80px] w-full rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background placeholder:text-muted-foreground/60 focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-primary focus-visible:border-primary/50 disabled:cursor-not-allowed disabled:opacity-50 transition-colors resize-none",t),ref:n,...s}));B5.displayName="Textarea";var gte=Object.defineProperty,yte=(t,s)=>gte(t,"name",{value:s,configurable:!0}),bte=d.forwardRef(yte(function(s,n){return e.jsx(yt.label,{...s,ref:n,onMouseDown:a=>{var i;a.target.closest("button, input, select, textarea")||((i=s.onMouseDown)==null||i.call(s,a),!a.defaultPrevented&&a.detail>1&&a.preventDefault())}})},"Label")),QI=bte;const vte=Ib("text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70",{variants:{variant:{default:"text-foreground",muted:"text-muted-foreground",accent:"text-primary"},size:{default:"text-sm",xs:"text-xs",sm:"text-sm",lg:"text-base"}},defaultVariants:{variant:"default",size:"default"}}),Gc=d.forwardRef(({className:t,variant:s,size:n,...a},r)=>e.jsx(QI,{ref:r,className:et(vte({variant:s,size:n}),t),...a}));Gc.displayName=QI.displayName;var jte=Object.defineProperty,Xl=(t,s)=>jte(t,"name",{value:s,configurable:!0}),U5="Switch",[wte,nxe]=Va(U5),[Nte,q5]=wte(U5);function JI(t){const{__scopeSwitch:s,checked:n,children:a,defaultChecked:r,disabled:i,form:o,name:l,onCheckedChange:c,required:u,value:p="on",internal_do_not_use_render:m}=t,[x,h]=Po({prop:n,defaultProp:r??!1,onChange:c,caller:U5}),[y,v]=d.useState(null),[g,N]=d.useState(null),b=d.useRef(!1),[f,j]=d.useReducer(_=>_+1,0),S=y?!!o||!!y.closest("form"):!0,w={checked:x,setChecked:h,disabled:i,control:y,setControl:v,name:l,form:o,value:p,hasConsumerStoppedPropagationRef:b,userInteractionCount:f,onUserInteraction:j,required:u,defaultChecked:r,isFormControl:S,bubbleInput:g,setBubbleInput:N};return e.jsx(Nte,{scope:s,...w,children:e8(m)?m(w):a})}Xl(JI,"SwitchProvider");var _te="SwitchTrigger",kte=d.forwardRef(Xl(function({__scopeSwitch:s,onClick:n,...a},r){const{control:i,form:o,value:l,disabled:c,checked:u,required:p,setControl:m,setChecked:x,hasConsumerStoppedPropagationRef:h,onUserInteraction:y,isFormControl:v,bubbleInput:g}=q5(_te,s),N=It(r,m),b=d.useRef(u);return d.useEffect(()=>{const f=o?i==null?void 0:i.ownerDocument.getElementById(o):i==null?void 0:i.form;if(f instanceof HTMLFormElement){const j=Xl(()=>x(b.current),"reset");return f.addEventListener("reset",j),()=>f.removeEventListener("reset",j)}},[i,o,x]),e.jsx(yt.button,{type:"button",role:"switch","aria-checked":u,"aria-required":p,"data-state":W5(u),"data-disabled":c?"":void 0,disabled:c,value:l,...a,ref:N,onClick:at(n,f=>{y(),x(j=>!j),g&&v&&(h.current=f.isPropagationStopped(),h.current||f.stopPropagation())})})},"SwitchTrigger")),XI=d.forwardRef(Xl(function(s,n){const{__scopeSwitch:a,name:r,checked:i,defaultChecked:o,required:l,disabled:c,value:u,onCheckedChange:p,form:m,...x}=s;return e.jsx(JI,{__scopeSwitch:a,checked:i,defaultChecked:o,disabled:c,required:l,onCheckedChange:p,name:r,form:m,value:u,internal_do_not_use_render:({isFormControl:h})=>e.jsxs(e.Fragment,{children:[e.jsx(kte,{...x,ref:n,__scopeSwitch:a}),h&&e.jsx(Ete,{__scopeSwitch:a})]})})},"Switch")),Ste="SwitchThumb",Cte=d.forwardRef(Xl(function(s,n){const{__scopeSwitch:a,...r}=s,i=q5(Ste,a);return e.jsx(yt.span,{"data-state":W5(i.checked),"data-disabled":i.disabled?"":void 0,...r,ref:n})},"SwitchThumb")),Ate="SwitchBubbleInput",Ete=d.forwardRef(Xl(function({__scopeSwitch:s,onClick:n,...a},r){const{control:i,hasConsumerStoppedPropagationRef:o,userInteractionCount:l,checked:c,defaultChecked:u,required:p,disabled:m,name:x,value:h,form:y,bubbleInput:v,setBubbleInput:g}=q5(Ate,s),N=It(r,g),b=Wb(i),f=d.useRef(!1),j=d.useRef(c),S=d.useRef(l);d.useEffect(()=>{const _=v;if(!_)return;const C=window.HTMLInputElement.prototype,P=Object.getOwnPropertyDescriptor(C,"checked").set,F=l!==S.current;S.current=l;const I=j.current!==c;j.current=c;const D=!(F&&o.current);if(I&&P){f.current=!F;const L=new Event("click",{bubbles:D});P.call(_,c),_.dispatchEvent(L),f.current=!1}},[v,c,o,l]);const w=d.useRef(c);return e.jsx(yt.input,{type:"checkbox","aria-hidden":!0,defaultChecked:u??w.current,required:p,disabled:m,name:x,value:h,form:y,...a,tabIndex:-1,ref:N,onClick:at(n,_=>{f.current&&_.stopPropagation()}),style:{...a.style,...b,position:"absolute",pointerEvents:"none",opacity:0,margin:0,transform:"translateX(-100%)"}})}
1263,"SwitchBubbleInput"));function e8(t){return typeof t=="function"}Xl(e8,"isFunction");function W5(t){return t?"checked":"unchecked"}Xl(W5,"getState");const Jy=d.forwardRef(({className:t,...s},n)=>e.jsx(XI,{className:et("peer inline-flex h-5 w-10 shrink-0 cursor-pointer items-center rounded-full border border-transparent transition-all focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary focus-visible:ring-offset-2 focus-visible:ring-offset-background disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:bg-primary data-[state=unchecked]:bg-input",t),...s,ref:n,children:e.jsx(Cte,{className:et("pointer-events-none block h-4 w-4 rounded-full bg-background shadow-md ring-0 transition-transform duration-200 ease-in-out data-[state=checked]:translate-x-5 data-[state=unchecked]:translate-x-0.5 data-[state=checked]:bg-white")})}));Jy.displayName=XI.displayName;var Fte=Object.defineProperty,Tte=(t,s)=>Fte(t,"name",{value:s,configurable:!0});function aN(t,[s,n]){return Math.min(n,Math.max(s,t))}Tte(aN,"clamp");var Pte=Object.defineProperty,Dte=(t,s)=>Pte(t,"name",{value:s,configurable:!0}),Rte=d.createContext(void 0);function i1(t){const s=d.useContext(Rte);return t||s||"ltr"}Dte(i1,"useDirection");var Ite=Object.defineProperty,$te=(t,s)=>Ite(t,"name",{value:s,configurable:!0});function t8(t){const s=d.useRef({value:t,previous:t});return d.useMemo(()=>(s.current.value!==t&&(s.current.previous=s.current.value,s.current.value=t),s.current.previous),[t])}$te(t8,"usePrevious");var zte=Object.defineProperty,Rt=(t,s)=>zte(t,"name",{value:s,configurable:!0}),Lte=[" ","Enter","ArrowUp","ArrowDown"],Ote=[" ","Enter"],$m="Select",[o1,l1,Mte]=Tb($m),[Ud,axe]=Va($m,[Mte,Hb]),H5=Hb(),[Bte,uc]=Ud($m),[Ute,qte]=Ud($m);function s8(t){const{__scopeSelect:s,children:n,open:a,defaultOpen:r,onOpenChange:i,value:o,defaultValue:l,onValueChange:c,dir:u,name:p,autoComplete:m,disabled:x,required:h,form:y,internal_do_not_use_render:v}=t,g=H5(s),[N,b]=d.useState(null),[f,j]=d.useState(null),[S,w]=d.useState(!1),_=i1(u),[C,E]=Po({prop:a,defaultProp:r??!1,onChange:i,caller:$m}),[P,F]=Po({prop:o,defaultProp:l,onChange:c,caller:$m}),I=d.useRef(null),D=d.useRef(P);d.useEffect(()=>{const U=y?N==null?void 0:N.ownerDocument.getElementById(y):N==null?void 0:N.form;if(U instanceof HTMLFormElement){const q=Rt(()=>F(D.current),"reset");return U.addEventListener("reset",q),()=>U.removeEventListener("reset",q)}}
1263,[y,N,F]);const L=N?!!y||!!N.closest("form"):!0,[V,B]=d.useState(new Set),A=Bl(),z=Array.from(V).map(U=>U.props.value).join(";"),M=d.useCallback(U=>{B(q=>new Set(q).add(U))},[]),R=d.useCallback(U=>{B(q=>{const H=new Set(q);return H.delete(U),H})},[]),T={required:h,trigger:N,onTriggerChange:b,valueNode:f,onValueNodeChange:j,valueNodeHasChildren:S,onValueNodeHasChildrenChange:w,contentId:A,value:P,onValueChange:F,open:C,onOpenChange:E,dir:_,triggerPointerDownPosRef:I,disabled:x,name:p,autoComplete:m,form:y,nativeOptions:V,nativeSelectKey:z,isFormControl:L};return e.jsx(DU,{...g,children:e.jsx(Bte,{scope:s,...T,children:e.jsx(o1.Provider,{scope:s,children:e.jsx(Ute,{scope:s,onNativeOptionAdd:M,onNativeOptionRemove:R,children:p8(v)?v(T):n})})})})}Rt(s8,"SelectProvider");var Wte=Rt(t=>{const{__scopeSelect:s,children:n,...a}=t;return e.jsx(s8,{__scopeSelect:s,...a,internal_do_not_use_render:({isFormControl:r})=>e.jsxs(e.Fragment,{children:[n,r?e.jsx(pse,{__scopeSelect:s}):null]})})},"Select"),Hte="SelectTrigger",n8=d.forwardRef(Rt(function(s,n){const{__scopeSelect:a,disabled:r=!1,...i}=s,o=H5(a),l=uc(Hte,a),c=l.disabled||r,u=It(n,l.onTriggerChange),p=l1(a),m=d.useRef("touch"),[x,h,y]=V5(g=>{const N=p().filter(j=>!j.disabled),b=N.find(j=>j.value===l.value),f=Z5(N,g,b);f!==void 0&&l.onValueChange(f.value)}),v=Rt(g=>{c||(l.onOpenChange(!0),y()),g&&(l.triggerPointerDownPosRef.current={x:Math.round(g.pageX),y:Math.round(g.pageY)})},"handleOpen");return e.jsx(RU,{asChild:!0,...o,children:e.jsx(yt.button,{type:"button",role:"combobox","aria-controls":l.open?l.contentId:void 0,"aria-expanded":l.open,"aria-required":l.required,"aria-autocomplete":"none",dir:l.dir,"data-state":l.open?"open":"closed",disabled:c,"data-disabled":c?"":void 0,"data-placeholder":lf(l.value)?"":void 0,...i,ref:u,onClick:at(i.onClick,g=>{g.currentTarget.focus(),m.current!=="mouse"&&v(g)}),onPointerDown:at(i.onPointerDown,g=>{m.current=g.pointerType;const N=g.target;N.hasPointerCapture(g.pointerId)&&N.releasePointerCapture(g.pointerId),g.button===0&&g.ctrlKey===!1&&g.pointerType==="mouse"&&(v(g),g.preventDefault())}),onKeyDown:at(i.onKeyDown,g=>{const N=x.current!=="";!(g.ctrlKey||g.altKey||g.metaKey)&&g.key.length===1&&h(g.key),!(N&&g.key===" ")&&Lte.includes(g.key)&&(v(),g.preventDefault())})})})},"SelectTrigger")),Gte="SelectValue",Vte=d.forwardRef(Rt(function(s,n){const{__scopeSelect:a,className:r,style:i,children:o,placeholder:l="",...c}=s,u=uc(Gte,a),{onValueNodeHasChildrenChange:p}=u,m=o!==void 0,x=It(n,u.onValueNodeChange);vs(()=>{p(m)},[p,m]);const h=lf(u.value);return e.jsx(yt.span,{...c,asChild:h?!1:c.asChild,ref:x,style:{pointerEvents:"none"},children:e.jsx(d.Fragment,{children:h?l:o},h?"placeholder":"value")})},"SelectValue")),Zte=d.forwardRef(Rt(function(s,n){const{__scopeSelect:a,children:r,...i}=s;return e.jsx(yt.span,{"aria-hidden":!0,...i,ref:n,children:r||"â¼"})},"SelectIcon")),Yte="SelectPortal",[Kte,Qte]=Ud(Yte,{forceMount:void 0}),Jte=Rt(t=>{const{__scopeSelect:s,forceMount:n,...a}=t;return e.jsx(Kte,{scope:t.__scopeSelect,forceMount:n,children:e.jsx(q_,{asChild:!0,...a})})},"SelectPortal"),Td="SelectContent",a8=d.forwardRef(Rt(function(s,n){const a=Qte(Td,s.__scopeSelect),{forceMount:r=a.forceMount,...i}=s,o=uc(Td,s.__scopeSelect),[l,c]=d.useState();return vs(()=>{c(new DocumentFragment)},[]),e.jsx(ic,{present:r||o.open,children:({present:u})=>u?e.jsx(tse,{...i,ref:n}):e.jsx(Xte,{...i,fragment:l})})},"SelectContent")),Xte=d.forwardRef(Rt(function(s,n){const{__scopeSelect:a,children:r,fragment:i}=s;return i?rc.createPortal(e.jsx(r8,{scope:a,children:e.jsx(o1.Slot,{scope:a,children:e.jsx("div",{ref:n,children:r})})}),i):null},"SelectContentFragment")),Lr=10,[r8,qd]=Ud(Td),ese=Fo("SelectContent.RemoveScroll"),tse=d.forwardRef(Rt(function(s,n){const{__scopeSelect:a}=s,{position:r="item-aligned",onCloseAutoFocus:i,onEscapeKeyDown:o,onPointerDownOutside:l,side:c,sideOffset:u,align:p,alignOffset:m,arrowPadding:x,collisionBoundary:h,collisionPadding:y,sticky:v,hideWhenDetached:g,avoidCollisions:N,...b}=s,f=uc(Td,a),[j,S]=d.useState(null),[w,_]=d.useState(null),C=It(n,S),[E,P]=d.useState(null),[F,I]=d.useState(null),D=l1(a),[L,V]=d.use
vendor: 9,900 bytes, line 1263
1263State(!1),B=d.useRef(!1);d.useEffect(()=>{if(j)return YR(j)},[j]),Xb();const A=d.useCallback(Q=>{const[K,...se]=D().map(te=>te.ref.current),[Y]=se.slice(-1),J=document.activeElement;for(const te of Q)if(te===J||(te==null||te.scrollIntoView({block:"nearest"}),te===K&&w&&(w.scrollTop=0),te===Y&&w&&(w.scrollTop=w.scrollHeight),te==null||te.focus(),document.activeElement!==J))return},[D,w]),z=d.useCallback(()=>A([E,j]),[A,E,j]);d.useEffect(()=>{L&&z()},[L,z]);const{onOpenChange:M,triggerPointerDownPosRef:R}=f;d.useEffect(()=>{if(j){let Q={x:0,y:0};const K=Rt(Y=>{var J,te;Q={x:Math.abs(Math.round(Y.pageX)-(((J=R.current)==null?void 0:J.x)??0)),y:Math.abs(Math.round(Y.pageY)-(((te=R.current)==null?void 0:te.y)??0))}},"handlePointerMove"),se=Rt(Y=>{Q.x<=10&&Q.y<=10?Y.preventDefault():Y.composedPath().includes(j)||M(!1),document.removeEventListener("pointermove",K),R.current=null},"handlePointerUp");return R.current!==null&&(document.addEventListener("pointermove",K),document.addEventListener("pointerup",se,{capture:!0,once:!0})),()=>{document.removeEventListener("pointermove",K),document.removeEventListener("pointerup",se,{capture:!0})}}},[j,M,R]),d.useEffect(()=>{const Q=Rt(()=>M(!1),"close");return window.addEventListener("blur",Q),window.addEventListener("resize",Q),()=>{window.removeEventListener("blur",Q),window.removeEventListener("resize",Q)}},[M]);const[T,U]=V5(Q=>{const K=D().filter(J=>!J.disabled),se=K.find(J=>J.ref.current===document.activeElement),Y=Z5(K,Q,se);Y&&setTimeout(()=>{var J;return(J=Y.ref.current)==null?void 0:J.focus()})}),q=d.useCallback((Q,K,se)=>{const Y=!B.current&&!se;(f.value!==void 0&&f.value===K||Y)&&(P(Q),Y&&(B.current=!0))},[f.value]),H=d.useCallback(()=>j==null?void 0:j.focus(),[j]),G=d.useCallback((Q,K,se)=>{const Y=!B.current&&!se;(f.value!==void 0&&f.value===K||Y)&&I(Q)},[f.value]),W=r==="popper"?pE:sse,X=W===pE?{side:c,sideOffset:u,align:p,alignOffset:m,arrowPadding:x,collisionBoundary:h,collisionPadding:y,sticky:v,hideWhenDetached:g,avoidCollisions:N}:{};return e.jsx(r8,{scope:a,content:j,viewport:w,onViewportChange:_,itemRefCallback:q,selectedItem:E,onItemLeave:H,itemTextRefCallback:G,focusSelectedItem:z,selectedItemText:F,position:r,isPositioned:L,searchRef:T,children:e.jsx(w5,{as:ese,allowPinchZoom:!0,children:e.jsx(IR,{asChild:!0,trapped:f.open,onMountAutoFocus:Q=>{Q.preventDefault()},onUnmountAutoFocus:at(i,Q=>{var K;(K=f.trigger)==null||K.focus({preventScroll:!0}),Q.preventDefault()}),children:e.jsx(Pb,{asChild:!0,disableOutsidePointerEvents:!0,onEscapeKeyDown:o,onPointerDownOutside:l,onFocusOutside:Q=>Q.preventDefault(),onDismiss:()=>f.onOpenChange(!1),children:e.jsx(W,{role:"listbox",id:f.contentId,"data-state":f.open?"open":"closed",dir:f.dir,onContextMenu:Q=>Q.preventDefault(),...b,...X,onPlaced:()=>V(!0),ref:C,style:{display:"flex",flexDirection:"column",outline:"none",...b.style},onKeyDown:at(b.onKeyDown,Q=>{const K=Q.ctrlKey||Q.altKey||Q.metaKey;if(Q.key==="Tab"&&Q.preventDefault(),!K&&Q.key.length===1&&U(Q.key),["ArrowUp","ArrowDown","Home","End"].includes(Q.key)){let Y=D().filter(J=>!J.disabled).map(J=>J.ref.current);if(["ArrowUp","End"].includes(Q.key)&&(Y=Y.slice().reverse()),["ArrowUp","ArrowDown"].includes(Q.key)){const J=Q.target,te=Y.indexOf(J);Y=Y.slice(te+1)}setTimeout(()=>A(Y)),Q.preventDefault()}})})})})})})},"SelectContentImpl")),sse=d.forwardRef(Rt(function(s,n){const{__scopeSelect:a,onPlaced:r,...i}=s,o=uc(Td,a),l=qd(Td,a),[c,u]=d.useState(null),[p,m]=d.useState(null),x=It(n,m),h=l1(a),y=d.useRef(!1),v=d.useRef(!0),{viewport:g,selectedItem:N,selectedItemText:b,focusSelectedItem:f}=l,j=d.useCallback(()=>{if(o.trigger&&o.valueNode&&c&&p&&g&&N&&b){const C=o.trigger.getBoundingClientRect(),E=p.getBoundingClientRect(),P=o.valueNode.getBoundingClientRect(),F=b.getBoundingClientRect();if(o.dir!=="rtl"){const J=F.left-E.left,te=P.left-J,pe=C.left-te,Fe=C.width+pe,ke=Math.max(Fe,E.width),Oe=window.innerWidth-Lr,ue=aN(te,[Lr,Math.max(Lr,Oe-ke)]);c.style.minWidth=Fe+"px",c.style.left=ue+"px"}else{const J=E.right-F.right,te=window.innerWidth-P.right-J,pe=window.innerWidth-C.right-te,Fe=C.width+pe,ke=Math.max(Fe,E.width),Oe=window.innerWidth-Lr,ue=aN(te,[Lr,Math.max(Lr,Oe-ke)]);c.style.minWidth=Fe+"px",c.style.right=ue+"px"}const I=h(),D=window.innerHeight-Lr*2,L=g.scrollHeight,V=window.getComputedStyle(p),B=parseInt(V.borderTopWidth,10),A=parseInt(V.paddingTop,10),z=parseInt(V.borderBottomWidth,10),M=parseInt(V.paddingBottom,10),R=B+A+L+M+z,T=Math.min(N.offsetHeight*5,R),U=window.getComputedStyle(g),q=parseInt(U.paddingTop,10),H=parseInt(U.paddingBottom,10),G=C.top+C.height/2-Lr,W=D-G,X=N.offsetHeight/2,Q=N.offsetTop+X,K=B+A+Q,se=R-K;if(K<=G){const J=I.length>0&&N===I[I.length-1].ref.current;c.style.bottom="0px";const te=p.clientHeight-g.offsetTop-g.offsetHeight,pe=Math.max(W,X+(J?H:0)+te+z),Fe=K+pe;c.style.height=Fe+"px"}else{const J=I.length>0&&N===I[0].ref.current;c.style.top="0px";const pe=Math.max(G,B+g.offsetTop+(J?q:0)+X)+se;c.style.height=pe+"px",g.scrollTop=K-G+g.offsetTop}c.style.margin=`${Lr}px 0`,c.style.minHeight=T+"px",c.style.maxHeight=D+"px",r==null||r(),requestAnimationFrame(()=>y.current=!0)}},[h,o.trigger,o.valueNode,c,p,g,N,b,o.dir,r]);vs(()=>j(),[j]);const[S,w]=d.useState();vs(()=>{p&&w(window.getComputedStyle(p).zIndex)},[p]);const _=d.useCallback(C=>{C&&v.current===!0&&(j(),f==null||f(),v.current=!1)},[j,f]);return e.jsx(nse,{scope:a,contentWrapper:c,shouldExpandOnScrollRef:y,onScrollButtonChange:_,children:e.jsx("div",{ref:u,style:{display:"flex",flexDirection:"column",position:"fixed",zIndex:S},children:e.jsx(yt.div,{...i,ref:x,style:{boxSizing:"border-box",maxHeight:"100%",...i.style}})})})},"SelectItemAlignedPosition")),pE=d.forwardRef(Rt(function(s,n){const{__scopeSelect:a,align:r="start",collisionPadding:i=Lr,...o}=s,l=H5(a);return e.jsx(AD,{...l,...o,ref:n,align:r,collisionPadding:i,style:{boxSizing:"border-box",...o.style,"--radix-select-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-select-content-available-width":"var(--radix-popper-available-width)","--radix-select-content-available-height":"var(--radix-popper-available-height)","--radix-select-trigger-width":"var(--radix-popper-anchor-width)","--radix-select-trigger-height":"var(--radix-popper-anchor-height)"}})},"SelectPopperPosition")),[nse,G5]=Ud(Td,{}),hE="SelectViewport",ase=d.forwardRef(Rt(function(s,n){const{__scopeSelect:a,nonce:r,...i}=s,o=qd(hE,a),l=G5(hE,a),c=It(n,o.onViewportChange),u=d.useRef(0);return e.jsxs(e.Fragment,{children:[e.jsx("style",{dangerouslySetInnerHTML:{__html:"[data-radix-select-viewport]{scrollbar-width:none;-ms-overflow-style:none;-webkit-overflow-scrolling:touch;}[data-radix-select-viewport]::-webkit-scrollbar{display:none}"},nonce:r}),e.jsx(o1.Slot,{scope:a,children:e.jsx(yt.div,{"data-radix-select-viewport":"",role:"presentation",...i,ref:c,style:{position:"relative",flex:1,overflow:"hidden auto",...i.style},onScroll:at(i.onScroll,p=>{const m=p.currentTarget,{contentWrapper:x,shouldExpandOnScrollRef:h}=l;if(h!=null&&h.current&&x){const y=Math.abs(u.current-m.scrollTop);if(y>0){const v=window.innerHeight-Lr*2,g=parseFloat(x.style.minHeight),N=parseFloat(x.style.height),b=Math.max(g,N);if(b<v){const f=b+y,j=Math.min(v,f),S=f-j;x.style.height=j+"px",x.style.bottom==="0px"&&(m.scrollTop=S>0?S:0,x.style.justifyContent="flex-end")}}}u.current=m.scrollTop})})})]})},"SelectViewport")),rse="SelectGroup",[rxe,ise]=Ud(rse),ose="SelectLabel",i8=d.forwardRef(Rt(function(s,n){const{__scopeSelect:a,...r}=s,i=ise(ose,a);return e.jsx(yt.div,{id:i.id,...r,ref:n})},"SelectLabel")),rN="SelectItem",[lse,o8]=Ud(rN),l8=d.forwardRef(Rt(function(s,n){const{__scopeSelect:a,value:r,disabled:i=!1,textValue:o,...l}=s,c=uc(rN,a),u=qd(rN,a),p=c.value===r,[m,x]=d.useState(o??""),[h,y]=d.useState(!1),v=sa(j=>{var S;return(S=u.itemRefCallback)==null?void 0:S.call(u,j,r,i)}),g=It(n,v),N=Bl(),b=d.useRef("touch"),f=Rt(()=>{i||(c.onValueChange(r),c.onOpenChange(!1))},"handleSelect");return e.jsx(lse,{scope:a,value:r,disabled:i,textId:N,isSelected:p,onItemTextChange:d.useCallback(j=>{x(S=>S||((j==null?void 0:j.textContent)??"").trim())},[]),children:e.jsx(o1.ItemSlot,{scope:a,value:r,disabled:i,textValue:m,children:e.jsx(yt.div,{role:"option","aria-labelledby":N,"data-highlighted":h?"":void 0,"aria-selected":p&&h,"data-state":p?"checked":"unchecked","aria-disabled":i||void 0,"data-disabled":i?"":void 0,tabIndex:i?void 0:-1,...l,ref:g,onFocus:at(l.onFocus,()=>y(!0)),onBlur:at(l.onBlur,()=>y(!1)),onClick:at(l.onClick,()=>{b.current!=="mouse"&&f()}),onPointerUp:at(l.onPointerUp,()=>{b.current==="mouse"&&f()}),onPointerDown:at(l.onPointerDown,j=>{b.current=j.pointerType}),onPointerMove:at(l.onPointerMove,j=>{var S;b.current=j.pointerType,i?(S=u.onItemLeave)==null||S.call(u):b.current==="mouse"&&j.currentTarget.focus({preventScroll:!0})}),onPointerLeave:at(l.onPointerLeave,j=>{var S;j.currentTarget===document.activeElement&&((S=u.onItemLeave)==null||S.call(u))}),onKeyDown:at(l.onKeyDown,j=>{var w;i||j.target!==j.currentTarget||((w=u.searchRef)==null?void 0:w.current)!==""&&j.key===" "||(Ote.includes(j.key)&&f(),j.key===" "&&j.preventDefault())})})})})},"SelectItem")),bg="SelectItemText",cse=d.forwardRef(Rt(function(s,n){const{__scopeSelect:a,className:r,style:i,...o}=s,l=uc(bg,a),c=qd(bg,a),u=o8(bg,a),p=qte(bg,a),[m,x]=d.useState(null),h=sa(f=>{var j;return(j=c.itemTextRefCallback)==null?void 0:j.call(c,f,u.value,u.disabled)}),y=It(n,x,u.onItemTextChange,h),v=m==null?void 0:m.textContent,g=d.useMemo(()=>e.jsx("option",{value:u.value,disabled:u.disabled,children:v},u.value),[u.disabled,u.value,v]),{onNativeOptionAdd:N,onNativeOptionRemove:b}=p;return vs(()=>(N(g),()=>b(g)),[N,b,g]),e.jsxs(e.Fragment,{children:[e.jsx(yt.span,{id:u.textId,...o,ref:y}),u.isSelected&&l.valueNode&&!l.valueNodeHasChildren&&!lf(l.value)?rc.createPortal(o.children,l.valueNode):null]})}
1263,"SelectItemText")),dse="SelectItemIndicator",use=d.forwardRef(Rt(function(s,n){const{__scopeSelect:a,...r}=s;return o8(dse,a).isSelected?e.jsx(yt.span,{"aria-hidden":!0,...r,ref:n}):null},"SelectItemIndicator")),xE="SelectScrollUpButton",c8=d.forwardRef(Rt(function(s,n){const a=qd(xE,s.__scopeSelect),r=G5(xE,s.__scopeSelect),[i,o]=d.useState(!1),l=It(n,r.onScrollButtonChange);return vs(()=>{if(a.viewport&&a.isPositioned){let c=function(){const p=u.scrollTop>0;o(p)};Rt(c,"handleScroll");const u=a.viewport;return c(),u.addEventListener("scroll",c),()=>u.removeEventListener("scroll",c)}},[a.viewport,a.isPositioned]),i?e.jsx(u8,{...s,ref:l,onAutoScroll:()=>{const{viewport:c,selectedItem:u}=a;c&&u&&(c.scrollTop=c.scrollTop-u.offsetHeight)}}):null},"SelectScrollUpButton")),fE="SelectScrollDownButton",d8=d.forwardRef(Rt(function(s,n){const a=qd(fE,s.__scopeSelect),r=G5(fE,s.__scopeSelect),[i,o]=d.useState(!1),l=It(n,r.onScrollButtonChange);return vs(()=>{if(a.viewport&&a.isPositioned){let c=function(){const p=u.scrollHeight-u.clientHeight,m=Math.ceil(u.scrollTop)<p;o(m)};Rt(c,"handleScroll");const u=a.viewport;return c(),u.addEventListener("scroll",c),()=>u.removeEventListener("scroll",c)}},[a.viewport,a.isPositioned]),i?e.jsx(u8,{...s,ref:l,onAutoScroll:()=>{const{viewport:c,selectedItem:u}=a;c&&u&&(c.scrollTop=c.scrollTop+u.offsetHeight)}}):null},"SelectScrollDownButton")),u8=d.forwardRef(Rt(function(s,n){const{__scopeSelect:a,onAutoScroll:r,...i}=s,o=qd("SelectScrollButton",a),l=d.useRef(null),c=l1(a),u=d.useCallback(()=>{l.current!==null&&(window.clearInterval(l.current),l.current=null)},[]);return d.useEffect(()=>()=>u(),[u]),vs(()=>{var m;const p=c().find(x=>x.ref.current===document.activeElement);(m=p==null?void 0:p.ref.current)==null||m.scrollIntoView({block:"nearest"})},[c]),e.jsx(yt.div,{"aria-hidden":!0,...i,ref:n,style:{flexShrink:0,...i.style},onPointerDown:at(i.onPointerDown,()=>{l.current===null&&(l.current=window.setInterval(r,50))}),onPointerMove:at(i.onPointerMove,()=>{var p;(p=o.onItemLeave)==null||p.call(o),l.current===null&&(l.current=window.setInterval(r,50))}),onPointerLeave:at(i.onPointerLeave,()=>{u()})})},"SelectScrollButtonImpl")),m8=d.forwardRef(Rt(function(s,n){const{__scopeSelect:a,...r}=s;return e.jsx(yt.div,{"aria-hidden":!0,...r,ref:n})},"SelectSeparator")),mse="SelectBubbleInput",pse=d.forwardRef(Rt(function({__scopeSelect:s,...n},a){const r=uc(mse,s),{value:i,onValueChange:o,required:l,disabled:c,name:u,autoComplete:p,form:m}=r,{nativeOptions:x,nativeSelectKey:h}=r,y=d.useRef(null),v=It(a,y),g=i??"",N=t8(g),b=Array.from(x).some(f=>(f.props.value??"")==="");return d.useEffect(()=>{const f=y.current;if(!f)return;const j=window.HTMLSelectElement.prototype,w=Object.getOwnPropertyDescriptor(j,"value").set;if(N!==g&&w){const _=new Event("change",{bubbles:!0});w.call(f,g),f.dispatchEvent(_)}},[N,g]),e.jsxs(yt.select,{"aria-hidden":!0,required:l,tabIndex:-1,name:u,autoComplete:p,disabled:c,form:m,onChange:f=>o(f.target.value),...n,style:{...fP,...n.style},ref:v,defaultValue:g,children:[lf(i)&&!b?e.jsx("option",{value:""}):null,Array.from(x)]},h)},"SelectBubbleInput"));function p8(t){return typeof t=="function"}Rt(p8,"isFunction");function lf(t){return t===""||t===void 0}Rt(lf,"shouldShowPlaceholder");function V5(t){const s=sa(t),n=d.useRef(""),a=d.useRef(0),r=d.useCallback(o=>{const l=n.current+o;s(l),Rt(function c(u){n.current=u,window.clearTimeout(a.current),u!==""&&(a.current=window.setTimeout(()=>c(""),1e3))},"updateSearch")(l)},[s]),i=d.useCallback(()=>{n.current="",window.clearTimeout(a.current)},[]);return d.useEffect(()=>()=>window.clearTimeout(a.current),[]),[n,r,i]}Rt(V5,"useTypeaheadSearch");function Z5(t,s,n){const r=s.length>1&&Array.from(s).every(u=>u===s[0])?s[0]:s,i=n?t.indexOf(n):-1;let o=h8(t,Math.max(i,0));r.length===1&&(o=o.filter(u=>u!==n));const c=o.find(u=>u.textValue.toLowerCase().startsWith(r.toLowerCase()));return c!==n?c:void 0}Rt(Z5,"findNextItem");function h8(t,s){return t.map((n,a)=>t[(s+a)%t.length])}Rt(h8,"wrapArray");const Tx=Wte,Px=Vte,zm=d.forwardRef(({className:t,children:s,...n},a)=>e.jsxs(n8,{ref:a,className:et("flex h-10 w-full items-center justify-between rounded-md border border-input bg-background px-3 py-2 text-sm r
1263ing-offset-background placeholder:text-muted-foreground/60 focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-primary focus-visible:border-primary/50 disabled:cursor-not-allowed disabled:opacity-50 [&>span]:line-clamp-1 transition-colors",t),...n,children:[s,e.jsx(Zte,{asChild:!0,children:e.jsx(Gt,{className:"h-4 w-4 opacity-50 transition-transform duration-200 ease-in-out group-data-[state=open]:rotate-180"})})]}));zm.displayName=n8.displayName;const x8=d.forwardRef(({className:t,...s},n)=>e.jsx(c8,{ref:n,className:et("flex cursor-default items-center justify-center py-1 text-muted-foreground",t),...s,children:e.jsx(Od,{className:"h-4 w-4"})}));x8.displayName=c8.displayName;const f8=d.forwardRef(({className:t,...s},n)=>e.jsx(d8,{ref:n,className:et("flex cursor-default items-center justify-center py-1 text-muted-foreground",t),...s,children:e.jsx(Gt,{className:"h-4 w-4"})}));f8.displayName=d8.displayName;const Lm=d.forwardRef(({className:t,children:s,position:n="popper",...a},r)=>e.jsx(Jte,{children:e.jsxs(a8,{ref:r,className:et("relative z-50 max-h-96 min-w-[8rem] overflow-hidden rounded-md border border-border/40 bg-popover text-popover-foreground shadow-md data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 duration-200",n==="popper"&&"data-[side=bottom]:translate-y-1 data-[side=left]:-translate-x-1 data-[side=right]:translate-x-1 data-[side=top]:-translate-y-1",t),position:n,...a,children:[e.jsx(x8,{}),e.jsx(ase,{className:et("p-1",n==="popper"&&"h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)]"),children:s}),e.jsx(f8,{})]})}));Lm.displayName=a8.displayName;const hse=d.forwardRef(({className:t,...s},n)=>e.jsx(i8,{ref:n,className:et("py-1.5 pl-8 pr-2 text-sm font-medium text-muted-foreground",t),...s}));hse.displayName=i8.displayName;const ec=d.forwardRef(({className:t,children:s,...n},a)=>e.jsxs(l8,{ref:a,className:et("relative flex w-full cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none focus:bg-accent/50 focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50 transition-colors",t),...n,children:[e.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:e.jsx(use,{children:e.jsx(xt,{className:"h-4 w-4 text-primary"})})}),e.jsx(cse,{children:s})]}));ec.displayName=l8.displayName;const xse=d.forwardRef(({className:t,...s},n)=>e.jsx(m8,{ref:n,className:et("-mx-1 my-1 h-px bg-muted",t),...s}));xse.displayName=m8.displayName;function fse({open:t,collectionId:s,collectionTitle:n,onClose:a,onChanged:r}){const[i,o]=d.useState([]),[l,c]=d.useState([]),[u,p]=d.useState(!1),[m,x]=d.useState(null),[h,y]=d.useState(null),[v,g]=d.useState(""),[N,b]=d.useState(""),[f,j]=d.useState(new Set),[S,w]=d.useState(new Set),[_,C]=d.useState(null),[E,P]=d.useState(null),[F,I]=d.useState(null),D=d.useRef(null),L=d.useRef(new Map),V=d.useRef(null),B=d.useRef({interval:null,direction:0,speed:0}),A=d.useCallback(()=>{B.current.interval!=null&&window.clearInterval(B.current.interval),B.current={interval:null,direction:0,speed:0}},[]),z=d.useCallback(ee=>{const me=V.current;if(!me)return;const Z=me.getBoundingClientRect(),xe=48,Pe=12;let De=0,ne=0;const oe=ee-Z.top,ie=Z.bottom-ee;oe<xe&&oe>=0?(De=-1,ne=Math.max(2,Math.round((xe-oe)/xe*Pe))):ie<xe&&ie>=0&&(De=1,ne=Math.max(2,Math.round((xe-ie)/xe*Pe))),B.current.direction=De,B.current.speed=ne,De!==0&&B.current.interval==null?B.current.interval=window.setInterval(()=>{const{direction:fe,speed:Re}=B.current,Me=V.current;!Me||fe===0||(Me.scrollTop+=fe*Re,fe<0&&Me.scrollTop<=0||fe>0&&Me.scrollTop+Me.clientHeight>=Me.scrollHeight)},16):De===0&&B.current.interval!=null&&A()},[A]);d.useEffect(()=>A,[A]);const[M,R]=d.useState(!1),[T,U]=d.useState([]),[q,H]=d.useState(!1),[G,W]=d.useState(null),[X,Q]=d.useState(null);d.useEffect(()=>{t&&(async()=>{var ee,me;try{const{data:Z}=await O.auth.getUser();W(((ee=Z==null?void 0:Z.user)==null?void 0:ee.email)??null),Q(((me=Z==null?void 0:Z.user)==null?void 0:me.id)??null)}catch{}})()},[t]);const K=d.useCallback(async()=>
1263{if(!s)return;H(!0);const ee=await cm("brand_line_picker_audit",O.from("brand_line_picker_audit").select("id, collection_id, collection_title, product_id, product_name, action, details, actor_email, created_at").eq("collection_id",s).order("created_at",{ascending:!1}).limit(50),1e4);!ee.timedOut&&!ee.error?U(ee.data??[]):U([]),H(!1)},[s]),se=d.useCallback((ee,me,Z)=>{s&&O.from("brand_line_picker_audit").insert({collection_id:s,collection_title:n,product_id:(me==null?void 0:me.id)??null,product_name:(me==null?void 0:me.name)??null,action:ee,details:Z,actor_id:X,actor_email:G}).then(xe=>{xe.error?console.warn("[picker-audit] insert failed",xe.error.message):M&&K()})},[s,n,X,G,M,K]);d.useEffect(()=>{t&&M&&s&&K()},[t,M,s,K]);const[Y,J]=d.useState(null),[te,pe]=d.useState(null);d.useCallback(ee=>{J(l.map(me=>({...me}))),pe(ee)},[l]);const Fe=d.useCallback(async()=>{var Me;if(!s||!Y)return;const ee=Y,me=l,Z=new Map(ee.filter(Te=>!Te.id.startsWith("temp-")).map(Te=>[Te.id,Te])),xe=new Map(me.filter(Te=>!Te.id.startsWith("temp-")).map(Te=>[Te.id,Te])),Pe=[];for(const[Te,Pt]of Z)xe.has(Te)||Pe.push(Pt);const De=[];for(const[Te,Pt]of xe)Z.has(Te)||De.push(Pt);const ne=[];for(const[Te,Pt]of Z){const Yt=xe.get(Te);Yt&&Yt.position!==Pt.position&&ne.push({id:Te,newPos:Pt.position})}if(Pe.length===0&&De.length===0&&ne.length===0){J(null),pe(null);return}y("__bulk__");const oe=[];for(const Te of Pe)oe.push(O.from("ecom_product_collections").insert({product_id:Te.product_id,collection_id:Te.collection_id,position:Te.position}).then(Pt=>({error:Pt.error})));for(const Te of De)oe.push(O.from("ecom_product_collections").delete().eq("id",Te.id).then(Pt=>({error:Pt.error})));for(const Te of ne)oe.push(O.from("ecom_product_collections").update({position:Te.newPos}).eq("id",Te.id).then(Pt=>({error:Pt.error})));const fe=(Me=(await Promise.all(oe)).find(Te=>Te.error))==null?void 0:Me.error;if(fe){Wt({title:"Undo failed",description:fe.message||"The database rejected one or more undo operations. The snapshot is kept so you can retry.",variant:"destructive"}),y(null);return}J(null);const Re=te;pe(null),y(null),await Oe(),se("undo",null,{reverted_action:Re,reinserted:Pe.length,deleted:De.length,repositioned:ne.length}),Wt({title:"Undone",description:`Reverted: ${Re}`}),r==null||r()},[s,Y,te,l,se,r]),ke=d.useCallback(()=>{if(T.length===0){Wt({title:"Nothing to export",description:"The audit log is empty for this brand line."});return}const ee=ie=>ie==null?'""':`"${(typeof ie=="string"?ie:JSON.stringify(ie)).replace(/"/g,'""').replace(/\r?\n/g," ")}"`,me=["timestamp","actor_email","action","product_id","product_name","details"].join(","),Z=T.map(ie=>[ie.created_at,ie.actor_email,ie.action,ie.product_id,ie.product_name,ie.details].map(ee).join(",")),xe=[me,...Z].join(` 1264`),Pe=new Blob([xe],{type:"text/csv;charset=utf-8"}),De=URL.createObjectURL(Pe),ne=document.createElement("a");ne.href=De;const oe=n.replace(/[^a-z0-9_-]+/gi,"-").slice(0,40)||"brand-line";ne.download=`picker-audit_${oe}_${new Date().toISOString().slice(0,10)}.csv`,document.body.appendChild(ne),ne.click(),document.body.removeChild(ne),URL.revokeObjectURL(De),Wt({title:"Audit log exported",description:`${T.length} row${T.length===1?"":"s"} downloaded as CSV.`})},[T,n]),Oe=async()=>{var ee,me;if(s){p(!0),x(null);try{const[Z,xe]=await Promise.all([cm("ecom_products",O.from("ecom_products").select("id, name, handle, price, status, product_type, images").eq("status","active").order("name"),12e3),cm("ecom_product_collections",O.from("ecom_product_collections").select("id, product_id, collection_id, position").eq("collection_id",s).order("position"),12e3)]);if(Z.timedOut||Z.error){x(Z.timedOut?`Loading ecom_products timed out after ${dm(Z.durationMs)}.`:`Failed to load products: ${((ee=Z.error)==null?void 0:ee.message)||JSON.stringify(Z.error)}`);return}if(xe.timedOut||xe.error){x(xe.timedOut?`Loading ecom_product_collections timed out after ${dm(xe.durationMs)}.`:`Failed to load assignments: ${((me=xe.error)==null?void 0:me.message)||JSON.stringify(xe.error)}`);return}o(Z.data??[]),c(xe.data??[])}catch(Z){x((Z==null?void 0:Z.message)||"Unknown error loading product picker")}finally{p(!1)}}};d.useEffect(()=>{t&&s&&(o([]),c([]),g(""),b(""),j(new Set),w(new Set),C(null),P(null),I(null),D.current=null,R(!1),U([]),J(null),pe(null),Oe())},[t,s]);const ue=d.useMemo(()=>new Set(l.map(ee=>ee.product_id)),[l]),je=d.useMemo(()=>{const ee=new Map;
1264for(const me of l)ee.set(me.product_id,me);return ee},[l]),le=d.useMemo(()=>[...l].sort((me,Z)=>(me.position??0)-(Z.position??0)).map(me=>i.find(Z=>Z.id===me.product_id)).filter(me=>!!me),[i,l]),ye=d.useMemo(()=>{const ee=v.trim().toLowerCase();return ee?le.filter(me=>me.name.toLowerCase().includes(ee)||me.handle.toLowerCase().includes(ee)):le},[le,v]),we=d.useMemo(()=>{const ee=N.trim().toLowerCase();return i.filter(me=>!ue.has(me.id)).filter(me=>!ee||me.name.toLowerCase().includes(ee)||me.handle.toLowerCase().includes(ee))},[i,ue,N]),He=ee=>{j(me=>{const Z=new Set(me);return Z.has(ee)?Z.delete(ee):Z.add(ee),Z})},Lt=ee=>{w(me=>{const Z=new Set(me);return Z.has(ee)?Z.delete(ee):Z.add(ee),Z})},ut=ye.length>0&&ye.every(ee=>f.has(ee.id)),ge=we.length>0&&we.every(ee=>S.has(ee.id)),Ne=()=>{j(ee=>{const me=new Set(ee);if(ut)for(const Z of ye)me.delete(Z.id);else for(const Z of ye)me.add(Z.id);return me})},lt=()=>{w(ee=>{const me=new Set(ee);if(ge)for(const Z of we)me.delete(Z.id);else for(const Z of we)me.add(Z.id);return me})},mt=async ee=>{if(!s)return;const me=l.map(ne=>({...ne}));y(ee.id);const Z=l.length===0?0:Math.max(...l.map(ne=>ne.position??0))+1,xe={id:`temp-${crypto.randomUUID()}`,product_id:ee.id,collection_id:s,position:Z};c(ne=>[...ne,xe]);const{data:Pe,error:De}=await O.from("ecom_product_collections").insert({product_id:ee.id,collection_id:s,position:Z}).select("id, product_id, collection_id, position").single();De?(c(ne=>ne.filter(oe=>oe.id!==xe.id)),Wt({title:"Could not add product",description:De.message||"The database rejected the insert. Check RLS policies.",variant:"destructive"})):Pe&&(c(ne=>ne.map(oe=>oe.id===xe.id?Pe:oe)),se("add",ee,{position:Z}),J(me),pe(`add "${ee.name}"`),r==null||r()),y(null)},ae=async ee=>{if(!s)return;const me=je.get(ee.id);if(!me)return;const Z=l.map(Pe=>({...Pe}));y(ee.id),c(Pe=>Pe.filter(De=>De.id!==me.id));const{error:xe}=await O.from("ecom_product_collections").delete().eq("id",me.id);xe?(c(Pe=>[...Pe,me]),Wt({title:"Could not remove product",description:xe.message||"The database rejected the delete.",variant:"destructive"})):(j(Pe=>{const De=new Set(Pe);return De.delete(ee.id),De}),se("remove",ee,{position:me.position}),J(Z),pe(`remove "${ee.name}"`),r==null||r()),y(null)},qe=async()=>{var oe;if(!s)return;const ee=we.filter(ie=>S.has(ie.id));if(ee.length===0)return;const me=l.map(ie=>({...ie}));y("__bulk__");const Z=l.length===0?0:Math.max(...l.map(ie=>ie.position??0))+1,xe=ee.map((ie,fe)=>({id:`temp-${crypto.randomUUID()}`,product_id:ie.id,collection_id:s,position:Z+fe}));c(ie=>[...ie,...xe]);const Pe=ee.map((ie,fe)=>O.from("ecom_product_collections").insert({product_id:ie.id,collection_id:s,position:Z+fe}).select("id, product_id, collection_id, position").single()),De=await Promise.all(Pe),ne=(oe=De.find(ie=>ie.error))==null?void 0:oe.error;if(ne){const ie=new Set(xe.map(fe=>fe.id));c(fe=>fe.filter(Re=>!ie.has(Re.id))),Wt({title:"Bulk add failed",description:ne.message||"The database rejected one or more inserts. Nothing was added.",variant:"destructive"})}else c(ie=>{const fe=new Set(xe.map(Te=>Te.id)),Re=ie.filter(Te=>!fe.has(Te.id)),Me=De.map(Te=>Te.data);return[...Re,...Me]}),w(new Set),se("bulk_add",null,{count:ee.length,product_ids:ee.map(ie=>ie.id),product_names:ee.map(ie=>ie.name),start_position:Z}),J(me),pe(`bulk add (${ee.length})`),Wt({title:"Products added",description:`${ee.length} product${ee.length===1?"":"s"} added to ${n}.`}),r==null||r();y(null)},bt=async()=>{if(!s)return;const ee=ye.filter(De=>f.has(De.id));if(ee.length===0)return;const me=l.map(De=>({...De}));y("__bulk__");const Z=ee.map(De=>je.get(De.id)).filter(De=>!!De),xe=new Set(Z.map(De=>De.id));c(De=>De.filter(ne=>!xe.has(ne.id)));const{error:Pe}=await O.from("ecom_product_collections").delete().in("id",Z.map(De=>De.id));Pe?(c(De=>
1264[...De,...Z]),Wt({title:"Bulk remove failed",description:Pe.message||"The database rejected the delete. Nothing was removed.",variant:"destructive"})):(j(new Set),se("bulk_remove",null,{count:ee.length,product_ids:ee.map(De=>De.id),product_names:ee.map(De=>De.name)}),J(me),pe(`bulk remove (${ee.length})`),Wt({title:"Products removed",description:`${ee.length} product${ee.length===1?"":"s"} removed from ${n}.`}),r==null||r()),y(null)},ht=async(ee,me)=>{var Pt,Yt;if(!s)return;const Z=le.findIndex(Os=>Os.id===ee.id);if(Z===-1)return;const xe=me==="up"?Z-1:Z+1;if(xe<0||xe>=le.length)return;const Pe=je.get(ee.id),De=je.get(le[xe].id);if(!Pe||!De)return;const ne=Pe.position??Z,oe=De.position??xe,ie=ne!==oe?oe:xe,fe=ne!==oe?ne:Z,Re=l.map(Os=>({...Os}));y(ee.id),c(Os=>Os.map(Gs=>Gs.id===Pe.id?{...Gs,position:ie}:Gs.id===De.id?{...Gs,position:fe}:Gs));const[Me,Te]=await Promise.all([O.from("ecom_product_collections").update({position:ie}).eq("id",Pe.id),O.from("ecom_product_collections").update({position:fe}).eq("id",De.id)]);Me.error||Te.error?(c(Os=>Os.map(Gs=>Gs.id===Pe.id?{...Gs,position:ne}:Gs.id===De.id?{...Gs,position:oe}:Gs)),Wt({title:"Could not save new order",description:(((Pt=Me.error)==null?void 0:Pt.message)||((Yt=Te.error)==null?void 0:Yt.message))??"The database rejected the position update.",variant:"destructive"})):(se("reorder",ee,{direction:me,from:{product:ee.id,position:ne},to:{product:le[xe].id,position:oe}}),J(Re),pe(`move "${ee.name}" ${me}`),r==null||r()),y(null)},Ht=d.useCallback(async(ee,me,Z={})=>{var fe;if(!s)return;const xe=ee.map((Re,Me)=>({row:je.get(Re.id),newPos:Me})).filter(Re=>Re.row),Pe=l,De=l.map(Re=>({...Re}));c(Re=>Re.map(Me=>{const Te=xe.find(Pt=>Pt.row.id===Me.id);return Te?{...Me,position:Te.newPos}:Me}));const ne=xe.filter(Re=>(Re.row.position??-1)!==Re.newPos);if(ne.length===0)return;y("__bulk__");const ie=(fe=(await Promise.all(ne.map(Re=>O.from("ecom_product_collections").update({position:Re.newPos}).eq("id",Re.row.id)))).find(Re=>Re.error))==null?void 0:fe.error;ie?(c(Pe),Wt({title:"Could not save new order",description:ie.message||"The database rejected one or more position updates. Reverted.",variant:"destructive"})):(se(me,null,{changed_count:ne.length,changes:ne.map(Re=>({product_id:Re.row.product_id,old_position:Re.row.position,new_position:Re.newPos})),...Z}),J(De),pe(me==="drag_drop"?`drag-reorder (${ne.length})`:`keyboard-reorder (${ne.length})`),r==null||r()),y(null)},[s,je,l,se]),wt=async ee=>{const me=_;if(C(null),P(null),!me||me===ee)return;const Z=le.findIndex(ne=>ne.id===me),xe=le.findIndex(ne=>ne.id===ee);if(Z===-1||xe===-1)return;const Pe=[...le],[De]=Pe.splice(Z,1);Pe.splice(xe,0,De),await Ht(Pe,"drag_drop",{from_index:Z,to_index:xe})},_e=async()=>{var De;if(!s||l.length===0)return;const ee=l.map(ne=>({...ne}));y("__normalise__");const me=le.map((ne,oe)=>({row:je.get(ne.id),newPos:oe})),Z=l;c(ne=>ne.map(oe=>{const ie=me.find(fe=>fe.row.id===oe.id);return ie?{...oe,position:ie.newPos}:oe}));const Pe=(De=(await Promise.all(me.filter(ne=>(ne.row.position??-1)!==ne.newPos).map(ne=>O.from("ecom_product_collections").update({position:ne.newPos}).eq("id",ne.row.id)))).find(ne=>ne.error))==null?void 0:De.error;Pe?(c(Z),Wt({title:"Could not normalise order",description:Pe.message,variant:"destructive"})):(se("normalise",null,{total:me.length}),J(ee),pe("normalise positions"),Wt({title:"Order saved",description:`Positions renumbered 0â¦${me.length-1}.`}),r==null||r()),y(null)},Se=ee=>{h===null&&(D.current=l,I(ee))},We=()=>{D.current&&c(D.current),D.current=null,I(null)},Ut=ee=>{if(!F)return;const me=[...l].sort((oe,ie)=>(oe.position??0)-(ie.position??0)),Z=me.findIndex(oe=>oe.product_id===F);if(Z===-1)return;const xe=Math.max(0,Math.min(me.length-1,Z+ee));if(xe===Z)return;const[Pe]=me.splice(Z,1);me.splice(xe,0,Pe);const De=me.map((oe,ie)=>({...oe,position:ie})),ne=new Map(De.map(oe=>[oe.id,oe]));c(oe=>oe.map(ie=>ne.get(ie.id)??ie))},$t=ee=>{if(!F)return;const me=[...l].sort((xe,Pe)=>(xe.position??0)-(Pe.position??0)),Z=me.findIndex(xe=>xe.product_id===F);Z!==-1&&Ut(ee==="top"?-Z:me.length-1-Z)},Nt=async()=>{var oe;if(!F||!s)return;const ee=D.current,Z=[...l].sort((ie,fe)=>(ie.position??0)-(fe.position??0)),xe=new Map;if(ee)for(const ie of ee)xe.set(ie.id,ie.position);const Pe=Z.map((ie,fe)=>({row:ie,newPos:fe,oldPos:xe.get(ie.id)??null})).filter(ie=>ie.oldPos!==ie.newPos);if(I(null),D.current=null,Pe.length===0)return;y("__bulk__");const ne=(oe=(await Promise.all(Pe.map(ie=>O.from("ecom_product_collections").update({position:ie.newPos}).eq("id",ie.row.id)))).find(ie=>ie.error))==null?void 0:oe.error;ne?(ee&&c(ee),Wt({title:"Could not save keyboard reorder",description:ne.message||"The database rejected one or more position updates. Reverted.",variant:"destructive"})):(se("keyboard_drop",null,{changed_count:Pe.length,changes:Pe.map(ie=>({product_id:ie.row.product_id,old_position:ie.oldPos,new_position:ie.newPos}))}),ee&&(J(ee.map(ie=>({...ie}))),pe(`keyboard-reorder (${Pe.length})`)),r==null||r()),y(null)};d.useEffect(()=>{if(F){const ee=L.current.get(F);ee&&ee.focus()}},[F,l]);const ps=(ee,me)=>{if(F===me){if(ee.key==="ArrowUp"){ee.preventDefault(),ee.stopPropagation(),Ut(-1);return}if(ee.key==="ArrowDown"){ee.preventDefault(),ee.stopPropagation(),Ut(1);return}if(ee.key==="Home"){ee.preventDefault(),ee.stopPropagation(),$t("top");return}if(ee.key==="End"){ee.preventDefault(),ee.stopPropagation(),$t("bottom");return}if(ee.key==="Enter"||ee.key===" "){ee.preventDefault(),ee.stopPropagation(),Nt();return}if(ee.key==="Escape"){ee.preventDefault(),ee.stopPropagation(),We();return}return}(ee.key===" "||ee.key==="Enter")&&(ee.preventDefault(),Se(me))},ft=h!==null,Ca=ee=>{var xe,Pe,De,ne,oe,ie,fe,Re,Me,Te;
1264const me=new Date(ee.created_at).toLocaleString(),Z=ee.actor_email||"anonymous";switch(ee.action){case"add":return`${me} · ${Z} added ${ee.product_name||((xe=ee.product_id)==null?void 0:xe.slice(0,8))}`;case"remove":return`${me} · ${Z} removed ${ee.product_name||((Pe=ee.product_id)==null?void 0:Pe.slice(0,8))}`;case"reorder":return`${me} · ${Z} moved ${ee.product_name||((De=ee.product_id)==null?void 0:De.slice(0,8))} ${((ne=ee.details)==null?void 0:ne.direction)||""}`;case"bulk_add":return`${me} · ${Z} bulk-added ${((oe=ee.details)==null?void 0:oe.count)??"?"} products`;case"bulk_remove":return`${me} · ${Z} bulk-removed ${((ie=ee.details)==null?void 0:ie.count)??"?"} products`;case"normalise":return`${me} · ${Z} normalised positions (${((fe=ee.details)==null?void 0:fe.total)??"?"} rows)`;case"drag_drop":return`${me} · ${Z} drag-reordered ${((Re=ee.details)==null?void 0:Re.changed_count)??"?"} positions`;case"keyboard_drop":return`${me} · ${Z} keyboard-reordered ${((Me=ee.details)==null?void 0:Me.changed_count)??"?"} positions`;case"undo":return`${me} · ${Z} undid: ${((Te=ee.details)==null?void 0:Te.reverted_action)||"previous action"}`;default:return`${me} · ${Z} · ${ee.action}`}};return e.jsx(s1,{open:t,onOpenChange:ee=>{ee||a()},children:e.jsxs(af,{className:"max-w-6xl max-h-[88vh] flex flex-col",onPointerDownOutside:ee=>ee.preventDefault(),onInteractOutside:ee=>ee.preventDefault(),onEscapeKeyDown:ee=>ee.preventDefault(),children:[e.jsx(rf,{children:e.jsxs("div",{className:"flex items-start justify-between gap-2",children:[e.jsxs("div",{children:[e.jsxs(of,{className:"font-serif text-stone-900",children:["Manage products in ",e.jsx("span",{className:"text-amber-700",children:n})]}),e.jsxs("p",{className:"text-xs text-stone-500 mt-1",children:["Drag · use arrows · or focus a row and press ",e.jsx("kbd",{className:"px-1 py-0.5 rounded bg-stone-100 border border-stone-300 text-[10px]",children:"Space"})," then â/â to reorder by keyboard. Changes save instantly."]})]}),e.jsxs("div",{className:"flex items-center gap-1.5 flex-shrink-0",children:[Y&&e.jsxs(gt,{size:"sm",variant:"outline",onClick:()=>void Fe(),disabled:ft||F!==null,className:"h-7 px-2 text-[10px] border-amber-400 text-amber-800 hover:bg-amber-100",title:`Undo: ${te}`,children:[e.jsx(Ey,{className:"h-3 w-3 mr-1"}),"Undo ",te&&te.length>22?`${te.slice(0,20)}â¦`:te]}),e.jsxs(gt,{size:"sm",variant:M?"default":"outline",onClick:()=>R(ee=>!ee),className:"h-7 px-2 text-[10px]",title:"Show/hide audit log",children:[e.jsx(en,{className:"h-3 w-3 mr-1"}),M?"Hide audit":"Audit log"]})]})]})}),m&&e.jsx("div",{className:"bg-red-50 border border-red-200 text-red-900 rounded-md p-3 mt-2",children:e.jsxs("div",{className:"flex items-start gap-2",children:[e.jsx(ve,{className:"h-4 w-4 mt-0.5 flex-shrink-0"}),e.jsxs("div",{className:"flex-1",children:[e.jsx("p",{className:"text-sm font-semibold",children:"Could not load product picker"}),e.jsx("p",{className:"text-xs font-mono break-words mt-1",children:m}),e.jsx(gt,{size:"sm",variant:"outline",className:"mt-2",onClick:Oe,children:"Retry"})]})]})}),u&&!m&&e.jsx("div",{className:"text-center text-stone-500 text-sm py-10",children:"Loading products and assignmentsâ¦"}),!u&&!m&&e.jsxs("div",{className:`grid grid-cols-1 ${M?"lg:grid-cols-[1fr_1fr_300px]":"lg:grid-cols-2"} gap-4 flex-1 min-h-0 mt-2`,children:[e.jsxs("div",{className:"flex flex-col border border-amber-200 bg-amber-50/30 rounded-lg overflow-hidden",children:[e.jsxs("div",{className:"px-3 py-2 bg-amber-100/60 border-b border-amber-200 flex items-center justify-between gap-2 flex-wrap",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("button",{type:"button",onClick:Ne,disabled:ft||ye.length===0,className:"text-amber-900 hover:text-amber-700 disabled:opacity-40",title:"Select all visible",children:ut?e.jsx(vo,{className:"h-4 w-4"}):e.jsx(Uu,{className:"h-4 w-4"})}),e.jsxs("p",{className:"text-xs font-semibold uppercase tracking-wide text-amber-900",children:["In this brand line (",le.length,")"]})]}),e.jsxs("div",{className:"flex items-center gap-1",children:[f.size>0&&e.jsxs(gt,{size:"sm",variant:"outline",onClick:bt,disabled:ft,className:"h-6 px-2 text-[10px] border-red-300 text-red-700 hover:bg-red-50",children:[e.jsx(Ml,{className:"h-3 w-3 mr-1"}),h==="__bulk__"?"Removingâ¦":`Remove ${f.size}`]}),e.jsx(gt,{size:"sm",variant:"outline",onClick:_e,disabled:ft||le.length===0,className:"h-6 px-2 text-[10px] border-amber-300 text-amber-800 hover:bg-amber-100",title:"Renumber positions 0â¦N-1 based on the current visible order",children:h==="__normalise__"?"Savingâ¦":"Save order"})]})]}),e.jsx("div",{className:"p-2 border-b border-amber-200 bg-white",children:e.jsxs("div",{className:"relative",children:[e.jsx(Bt,{className:"absolute left-2 top-1/2 -translate-y-1/2 h-3.5 w-3.5 text-stone-400"}
1264),e.jsx(Jr,{placeholder:"Filter assignedâ¦",value:v,onChange:ee=>g(ee.target.value),className:`pl-8 h-8 text-sm ${v?"pr-8":""}`,"aria-label":"Filter assigned products"}),v&&e.jsx("button",{type:"button",onMouseDown:ee=>ee.preventDefault(),onClick:()=>g(""),className:"absolute right-2 top-1/2 -translate-y-1/2 p-0.5 rounded hover:bg-stone-100 text-stone-400 hover:text-stone-700 transition-colors",title:"Clear filter","aria-label":"Clear assigned filter",children:e.jsx(Ke,{className:"h-3.5 w-3.5"})})]})}),e.jsx("ul",{ref:V,className:"flex-1 overflow-y-auto divide-y divide-amber-100",role:"list","aria-label":"Assigned products (focus a row and press Space to start keyboard reorder)",onDragOver:ee=>{_&&z(ee.clientY)},onDragLeave:ee=>{const me=ee.currentTarget.getBoundingClientRect();(ee.clientX<me.left||ee.clientX>me.right||ee.clientY<me.top||ee.clientY>me.bottom)&&A()},onDrop:()=>A(),children:ye.length===0?e.jsx("li",{className:"p-6 text-center text-xs text-stone-500",children:l.length===0?"No products yet. Add some from the right column â":"No assigned products match your filter."}):ye.map(ee=>{var ie;const me=le.findIndex(fe=>fe.id===ee.id),Z=me===0,xe=me===le.length-1,Pe=f.has(ee.id),De=_===ee.id,ne=E===ee.id&&_!==ee.id,oe=F===ee.id;return e.jsxs("li",{ref:fe=>{fe?L.current.set(ee.id,fe):L.current.delete(ee.id)},tabIndex:0,role:"listitem","aria-grabbed":oe,"aria-label":`${ee.name}, position ${me+1} of ${le.length}${oe?" (grabbed for reorder â use arrow keys, Enter to drop, Escape to cancel)":""}`,onKeyDown:fe=>ps(fe,ee.id),draggable:!ft&&!oe,onDragStart:fe=>{if(!(ft||oe)){C(ee.id),fe.dataTransfer.effectAllowed="move";try{fe.dataTransfer.setData("text/plain",ee.id)}catch{}}},onDragOver:fe=>{!_||_===ee.id||(fe.preventDefault(),fe.dataTransfer.dropEffect="move",E!==ee.id&&P(ee.id))},onDragLeave:()=>{E===ee.id&&P(null)},onDrop:fe=>{fe.preventDefault(),A(),wt(ee.id)},onDragEnd:()=>{C(null),P(null),A()},className:"px-3 py-2 flex items-center gap-2 transition-colors outline-none focus-visible:ring-2 focus-visible:ring-amber-500 focus-visible:bg-amber-50 "+(De?"opacity-40 ":"")+(ne?"bg-amber-100 border-t-2 border-amber-500 ":"")+(oe?"ring-2 ring-amber-500 bg-amber-100 ":"hover:bg-amber-50 "),children:[e.jsx("span",{className:"text-amber-700/50 hover:text-amber-700 cursor-grab active:cursor-grabbing",title:"Drag to reorder (or press Space to grab with keyboard)",children:e.jsx(TO,{className:"h-4 w-4"})}),e.jsx("button",{type:"button",onClick:()=>He(ee.id),disabled:ft,className:"text-amber-900 hover:text-amber-700 disabled:opacity-40",children:Pe?e.jsx(vo,{className:"h-4 w-4"}):e.jsx(Uu,{className:"h-4 w-4"})}),e.jsxs("span",{className:"text-[10px] font-mono text-amber-700 w-5 text-right tabular-nums",children:[me+1,"."]}),e.jsxs("div",{className:"flex flex-col gap-0.5",children:[e.jsx("button",{type:"button",onClick:()=>ht(ee,"up"),disabled:Z||ft||oe,className:"h-4 w-4 flex items-center justify-center rounded hover:bg-amber-200 disabled:opacity-30 disabled:cursor-not-allowed",title:"Move up (or press Space then â for keyboard grab)",children:e.jsx(Od,{className:"h-3 w-3 text-amber-900"})}),e.jsx("button",{type:"button",onClick:()=>ht(ee,"down"),disabled:xe||ft||oe,className:"h-4 w-4 flex items-center justify-center rounded hover:bg-amber-200 disabled:opacity-30 disabled:cursor-not-allowed",title:"Move down",children:e.jsx(Gt,{className:"h-3 w-3 text-amber-900"})})]}),e.jsx("div",{className:"w-8 h-8 rounded bg-stone-100 border border-stone-200 overflow-hidden flex-shrink-0",children:(ie=ee.images)!=null&&ie[0]?e.jsx("img",{src:ee.images[0],alt:"",className:"w-full h-full object-cover"}):null}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"text-sm font-medium text-stone-900 truncate",children:ee.name}),e.jsxs("p",{className:"text-[10px] text-stone-500 font-mono truncate",children:["/",ee.handle,ee.price!=null&&e.jsxs("span",{className:"ml-2 text-stone-700",children:["$",(ee.price/100).toFixed(2)]}),ee.product_type&&e.jsx("span",{className:"ml-2 text-amber-700",children:ee.product_type})]})]}),oe&&e.jsxs("span",{className:"inline-flex items-center gap-1 px-1.5 py-0.5 rounded bg-amber-500 text-white text-[9px] font-bold",children:[e.jsx(MO,{className:"h-2.5 w-2.5"})," Moving â ââ Enter Esc"]}),e.jsxs(gt,{size:"sm",variant:"outline",onClick:()=>ae(ee),disabled:ft||oe,className:"h-7 px-2 text-xs border-red-300 text-red-700 hover:bg-red-50",children:[e.jsx(Ml,{className:"h-3 w-3 mr-1"}),h===ee.id?"â¦":"Remove"]})]},ee.id)})})]}),e.jsxs("div",{className:"flex flex-col border border-stone-200 rounded-lg overflow-hidden",children:[e.jsxs("div",{className:"px-3 py-2 bg-stone-100 border-b border-stone-200 flex items-center justify-between gap-2 flex-wrap",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("button",{type:"button",onClick:lt,disabled:ft||we.length===0,className:"text-stone-700 hover:text-stone-900 disabled:opacity-40",title:"Select all visible",children:ge?e.jsx(vo,{className:"h-4 w-4"}):e.jsx(Uu,{className:"h-4 w-4"})}),e.jsxs("p",{className:"text-xs font-semibold uppercase tracking-wide text-stone-700",children:["Available products (",we.length,")"]})]}),S.size>0&&e.jsxs(gt,{size:"sm",onClick:qe,disabled:ft,className:"h-6 px-2 text-[10px] bg-[#3b1f2b] hover:bg-[#5a2a3f] text-white",children:[e.jsx(tn,{className:"h-3 w-3 mr-1"}),h==="__bulk__"?"Addingâ¦":`Add ${S.size}`]})]}),e.jsx("div",{className:"p-2 border-b border-stone-200 bg-white",children:e.jsxs("div",{className:"relative",children:[e.jsx(Bt,{className:"absolute left-2 top-1/2 -translate-y-1/2 h-3.5 w-3.5 text-stone-400"}),e.jsx(Jr,{placeholder:"Search by name or handleâ¦",value:N,onChange:ee=>b(ee.target.value),className:`pl-8 h-8 text-sm ${N?"pr-8":""}`,"aria-label":"Search available products"}),N&&e.jsx("button",{type:"button",onMouseDown:ee=>ee.preventDefault(),onClick:()=>b(""),className:"absolute right-2 top-1/2 -translate-y-1/2 p-0.5 rounded hover:bg-stone-100 text-stone-400 hover:text-stone-700 transition-colors",title:"Clear search","aria-label":"Clear available search",children:e.jsx(Ke,{className:"h-3.5 w-3.5"})})]})}),e.jsx("ul",{className:"flex-1 overflow-y-auto divide-y divide-stone-100",children:we.length===0?e.jsx("li",{className:"p-6 text-center text-xs text-stone-500",children:i.length===0?"N
1264o active products in the catalog yet.":ue.size===i.length?"All products are already in this brand line.":"No available products match your filter."}):we.map(ee=>{var Z;const me=S.has(ee.id);return e.jsxs("li",{className:"px-3 py-2 flex items-center gap-2 hover:bg-stone-50",children:[e.jsx("button",{type:"button",onClick:()=>Lt(ee.id),disabled:ft,className:"text-stone-700 hover:text-stone-900 disabled:opacity-40",children:me?e.jsx(vo,{className:"h-4 w-4"}):e.jsx(Uu,{className:"h-4 w-4"})}),e.jsx("div",{className:"w-8 h-8 rounded bg-stone-100 border border-stone-200 overflow-hidden flex-shrink-0",children:(Z=ee.images)!=null&&Z[0]?e.jsx("img",{src:ee.images[0],alt:"",className:"w-full h-full object-cover"}):null}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"text-sm font-medium text-stone-900 truncate",children:ee.name}),e.jsxs("p",{className:"text-[10px] text-stone-500 font-mono truncate",children:["/",ee.handle,ee.price!=null&&e.jsxs("span",{className:"ml-2 text-stone-700",children:["$",(ee.price/100).toFixed(2)]}),ee.product_type&&e.jsx("span",{className:"ml-2 text-amber-700",children:ee.product_type})]})]}),e.jsxs(gt,{size:"sm",onClick:()=>mt(ee),disabled:ft,className:"h-7 px-2 text-xs bg-[#3b1f2b] hover:bg-[#5a2a3f] text-white",children:[e.jsx(tn,{className:"h-3 w-3 mr-1"}),h===ee.id?"Addingâ¦":"Add"]})]},ee.id)})})]}),M&&e.jsxs("div",{className:"flex flex-col border border-stone-200 bg-stone-50 rounded-lg overflow-hidden",children:[e.jsxs("div",{className:"px-3 py-2 bg-stone-200/60 border-b border-stone-200 flex items-center justify-between gap-2",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(en,{className:"h-3.5 w-3.5 text-stone-700"}),e.jsxs("p",{className:"text-xs font-semibold uppercase tracking-wide text-stone-700",children:["Audit (",T.length,")"]})]}),e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsxs("button",{type:"button",onClick:ke,disabled:T.length===0,className:"flex items-center gap-0.5 text-[10px] text-stone-600 hover:text-stone-900 disabled:opacity-40 disabled:cursor-not-allowed",title:"Download audit log as CSV",children:[e.jsx(us,{className:"h-3 w-3"})," CSV"]}),e.jsx("button",{type:"button",onClick:()=>void K(),disabled:q,className:"text-[10px] text-stone-600 hover:text-stone-900 disabled:opacity-50 underline ml-1",title:"Refresh audit log",children:q?"â¦":"Refresh"}),e.jsx("button",{type:"button",onClick:()=>R(!1),className:"text-stone-600 hover:text-stone-900 ml-1",title:"Hide",children:e.jsx(Ke,{className:"h-3.5 w-3.5"})})]})]}),e.jsx("ul",{className:"flex-1 overflow-y-auto divide-y divide-stone-200",children:q?e.jsx("li",{className:"p-4 text-center text-xs text-stone-500",children:"Loading audit logâ¦"}):T.length===0?e.jsx("li",{className:"p-4 text-center text-xs text-stone-500",children:"No audit entries yet for this brand line. Mutations from this dialog will appear here."}):T.map(ee=>e.jsx("li",{className:"px-3 py-2 text-[11px] font-mono text-stone-700 leading-tight",children:e.jsxs("div",{className:"flex items-start gap-2",children:[e.jsx("span",{className:"inline-block w-1.5 h-1.5 rounded-full mt-1 flex-shrink-0 "+(ee.action==="add"||ee.action==="bulk_add"?"bg-emerald-500":ee.action==="remove"||ee.action==="bulk_remove"?"bg-red-500":ee.action==="undo"?"bg-blue-500":"bg-amber-500")}),e.jsx("span",{className:"break-words",children:Ca(ee)})]})},ee.id))})]})]}),e.jsxs("div",{className:"flex items-center justify-between pt-3 border-t border-stone-200 mt-2",children:[e.jsxs("p",{className:"text-xs text-stone-500",children:[l.length," product",l.length===1?"":"s"," in ",e.jsx("strong",{children:n})," ·"," ",i.length," active in catalog ·",F?e.jsx("span",{className:"text-amber-700 font-semibold ml-1",children:"Keyboard grab active â â/â to move, Enter to drop, Esc to cancel"}):e.jsx("span",{className:"text-amber-700 ml-1",children:"Drag · arrows · or Space to grab"})]}),e.jsx(gt,{variant:"outline",onClick:a,disabled:h==="__bulk__"||F!==null,children:"Done"})]})]})})}const gse=[{value:"manual",label:"Manual"},{value:"best-selling",label:"Best selling"},{value:"alpha-asc",label:"Alphabetical AâZ"},{value:"alpha-desc",label:"Alphabetical ZâA"},{value:"price-asc",label:"Price low â high"},{value:"price-desc",label:"Price high â low"},{value:"created-asc",label:"Oldest first"},{value:"created-desc",label:"Newest first"}],E0=t=>t.toLowerCase().normalize("NFKD").replace(/[\u0300-\u036f]/g,"").replace(/â¢|®|©/g,"").replace(/[^a-z0-9]+/g,"-").replace(/(^-|-$)/g,"");
1264function yse(){const[t,s]=d.useState([]),[n,a]=d.useState(!0),[r,i]=d.useState(null),[o,l]=d.useState(null),[c,u]=d.useState(!1),[p,m]=d.useState(!1),[x,h]=d.useState(""),[y,v]=d.useState(!0),[g,N]=d.useState(null),b=async()=>{var w;a(!0),i(null);try{const[_,C]=await Promise.all([cm("ecom_collections",O.from("ecom_collections").select("*").order("title"),12e3),cm("ecom_product_collections",O.from("ecom_product_collections").select("collection_id"),12e3)]);if(_.timedOut||_.error){const F=_.timedOut?`Loading ecom_collections timed out after ${dm(_.durationMs)}. The database request never returned.`:`Failed to load brand lines: ${((w=_.error)==null?void 0:w.message)||JSON.stringify(_.error)}`;i(F),a(!1);return}const E=new Map;if(!C.timedOut&&!C.error&&Array.isArray(C.data))for(const F of C.data)E.set(F.collection_id,(E.get(F.collection_id)??0)+1);const P=(_.data??[]).map(F=>({...F,product_count:E.get(F.id)??0}));s(P)}catch(_){i((_==null?void 0:_.message)||"Unknown error")}finally{a(!1)}};d.useEffect(()=>{b()},[]);const f=async(w,_)=>{var P,F,I,D;if(!((P=w.title)!=null&&P.trim())){Wt({title:"Title required",description:"Brand line title cannot be empty.",variant:"destructive"});return}m(!0);const C=(((F=w.handle)==null?void 0:F.trim())||E0(w.title)).trim(),E={title:w.title.trim(),handle:C,description:((I=w.description)==null?void 0:I.trim())||null,image_url:((D=w.image_url)==null?void 0:D.trim())||null,sort_order:w.sort_order||"manual",is_visible:w.is_visible??!0};try{if(_){const{error:L}=await O.from("ecom_collections").insert(E);if(L)throw L;Wt({title:"Brand line created",description:`${E.title} added.`})}else{const{error:L}=await O.from("ecom_collections").update({...E,updated_at:new Date().toISOString()}).eq("id",w.id);if(L)throw L;Wt({title:"Brand line updated",description:`${E.title} saved.`})}l(null),u(!1),await b()}catch(L){Wt({title:"Save failed",description:(L==null?void 0:L.message)||"The database rejected the change. Common cause: handle collision (must be unique).",variant:"destructive"})}finally{m(!1)}},j=async w=>{const _=!w.is_visible;s(E=>E.map(P=>P.id===w.id?{...P,is_visible:_}:P));const{error:C}=await O.from("ecom_collections").update({is_visible:_,updated_at:new Date().toISOString()}).eq("id",w.id);C&&(s(E=>E.map(P=>P.id===w.id?{...P,is_visible:!_}:P)),Wt({title:"Could not change visibility",description:C.message,variant:"destructive"}))},S=t.filter(w=>{if(!y&&!w.is_visible)return!1;if(!x.trim())return!0;const _=x.toLowerCase();return w.title.toLowerCase().includes(_)||w.handle.toLowerCase().includes(_)});return e.jsxs("div",{className:"min-h-screen bg-stone-50",children:[e.jsx("header",{className:"bg-gradient-to-r from-[#3b1f2b] to-[#5a2a3f] text-white border-b-4 border-amber-400",children:e.jsxs("div",{className:"max-w-6xl mx-auto px-6 py-6 flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-amber-300 text-xs tracking-widest uppercase mb-1",children:"Internal · Admin"}),e.jsx("h1",{className:"text-2xl font-serif",children:"Brand Line Admin"}),e.jsx("p",{className:"text-stone-300 text-sm mt-1",children:"Manage the canonical brand lines (Lifitaâ¢, Malouwaâ¢, Linamissaâ¢, Recovery, Signature Pigment, etc.) that drive storefront navigation and shop sections."})]}),e.jsxs("div",{className:"flex flex-col items-end gap-1",children:[e.jsx(be,{to:"/",className:"text-amber-300 text-sm hover:text-amber-200 underline underline-offset-4",children:"â Back to site"}),e.jsx(be,{to:"/loading-diagnostics",className:"text-stone-300 text-xs hover:text-amber-200",children:"Loading diagnostics"})]})]})}),e.jsxs("main",{className:"max-w-6xl mx-auto px-6 py-8 space-y-6",children:[e.jsxs("section",{className:"flex flex-col md:flex-row md:items-center md:justify-between gap-3",children:[e.jsxs("div",{className:"flex flex-1 gap-3 items-center",children:[e.jsx(Jr,{placeholder:"Filter by title or handleâ¦",value:x,onChange:w=>h(w.target.value),className:"max-w-sm"}),e.jsxs("label",{className:"flex items-center gap-2 text-sm text-stone-700",children:[e.jsx(Jy,{checked:y,onCheckedChange:v}),"Show hidden"]})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(gt,{variant:"outline",onClick:b,disabled:n,children:n?"Refreshingâ¦":"Refresh"}),e.jsx(gt,{onClick:()=>u(!0),className:"bg-[#3b1f2b] hover:bg-[#5a2a3f] text-white",children:"+ New brand line"})]})]}),r&&e.jsxs("div",{className:"bg-red-50 border border-red-200 text-red-900 rounded-lg p-5",children:[e.jsx("p",{className:"font-semibold mb-1",children:"Could not load brand lines"}),e.jsx("p",{className:"text-sm mb-3 font-mono break-words",children:r}),e.jsxs("div",{className:"flex gap-3",children:[e.jsx(gt,{size:"sm",variant:"outline",onClick:b,children:"Retry"}),e.jsx(be,{to:"/loading-diagnostics",className:"text-sm underline self-center",children:"Run diagnostics â"})]})]}),n&&!r&&e.jsx("div",{className:"bg-white border border-stone-200 rounded-lg p-10 text-center text-stone-500",children:"Loading brand linesâ¦"}),!n&&!r&&e.jsxs("section",{className:"bg-white border border-stone-200 rounded-lg shadow-sm overflow-hidden",children:[e.jsxs("div",{className:"px-5 py-3 border-b border-stone-200 bg-stone-50 text-xs uppercase tracking-wide text-stone-600 flex items-center justify-between",children:[e.jsxs("span",{children:[S.length," of ",t.length," brand line",t.length===1?"":"s"]}),e.jsxs("span",{children:[t.filter(w=>!w.is_visible).length," hidden"]})]}),S.length===0?e.jsx("div",{className:"p-10 text-center text-stone-500 text-sm",children:t.length===0?'No brand lines yet. Click "+ New brand line" to create the first one.':"No brand lines match your filter."}):e.jsx("ul",{className:"divide-y divide-stone-200",children:S.map(w=>e.jsxs("li",{className:"px-5 py-4 flex items-center gap-4 hover:bg-stone-50",children:[e.jsx("div",{className:"w-12 h-12 rounded-md bg-stone-100 border border-stone-200 overflow-hidden flex-shrink-0",children:w.image_url?e.jsx("img",{src:w.image_url,alt:"",className:"w-full h-full object-cover"}):e.jsx("div",{className:"w-full h-full flex items-center justify-center text-stone-400 text-xs",children:"No img"})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[e.jsx("p",{className:"font-serif text-stone-900 truncate",children:w.title}),!w.is_visible&&e.jsx("span",{className:"text-xs px-2 py-0.5 bg-stone-200 text-stone-700 rounded",children:"Hidden"})]}),e.jsxs("p",{className:"text-xs text-stone-500 truncate font-mono",children:["/",w.handle]}),w.description&&e.jsx("p",{className:"text-xs text-stone-600 truncate mt-0.5",children:w.description})]}),e.jsxs("div",{className:"text-right text-xs text-stone-500 hidden sm:block",children:[e.jsx("p",{className:"font-mono text-base text-stone-900",children:w.product_count??0}),e.jsx("p",{children:"products"})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Jy,{
1264checked:w.is_visible,onCheckedChange:()=>j(w)}),e.jsx(gt,{size:"sm",variant:"outline",onClick:()=>N(w),className:"border-amber-300 text-amber-800 hover:bg-amber-50",title:"Add or remove products in this brand line",children:"Manage products"}),e.jsx(gt,{size:"sm",variant:"outline",onClick:()=>l(w),children:"Edit"})]})]},w.id))})]})]}),e.jsx(bse,{open:!!o||c,initial:o,saving:p,onClose:()=>{l(null),u(!1)},onSave:w=>f(w,!o)}),e.jsx(fse,{open:!!g,collectionId:(g==null?void 0:g.id)??null,collectionTitle:(g==null?void 0:g.title)??"",onClose:()=>N(null),onChanged:b})]})}function bse({open:t,initial:s,saving:n,onClose:a,onSave:r}){const[i,o]=d.useState({});d.useEffect(()=>{t&&o(s??{title:"",handle:"",description:"",image_url:"",sort_order:"manual",is_visible:!0})},[t,s]);const l=(c,u)=>o(p=>({...p,[c]:u}));return e.jsx(s1,{open:t,onOpenChange:c=>{c||a()},children:e.jsxs(af,{className:"max-w-2xl",children:[e.jsx(rf,{children:e.jsx(of,{className:"font-serif",children:s?`Edit: ${s.title}`:"New brand line"})}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4 py-2",children:[e.jsxs("div",{className:"md:col-span-2",children:[e.jsx(Gc,{htmlFor:"bl-title",children:"Title *"}),e.jsx(Jr,{id:"bl-title",value:i.title??"",onChange:c=>{const u=c.target.value;l("title",u),(!i.handle||i.handle===E0((s==null?void 0:s.title)||"")||i.handle===E0(i.title||""))&&l("handle",E0(u))},placeholder:"e.g. Lifita⢠Haircare"})]}),e.jsxs("div",{className:"md:col-span-2",children:[e.jsx(Gc,{htmlFor:"bl-handle",children:"Handle (URL slug) *"}),e.jsx(Jr,{id:"bl-handle",value:i.handle??"",onChange:c=>l("handle",c.target.value),placeholder:"lifita-haircare",className:"font-mono"}),e.jsxs("p",{className:"text-xs text-stone-500 mt-1",children:["Used in URLs: ",e.jsxs("code",{children:["/collections/",i.handle||"handle"]}),". Must be unique."]})]}),e.jsxs("div",{className:"md:col-span-2",children:[e.jsx(Gc,{htmlFor:"bl-desc",children:"Description"}),e.jsx(B5,{id:"bl-desc",rows:3,value:i.description??"",onChange:c=>l("description",c.target.value),placeholder:"Brand line description shown on the collection pageâ¦"})]}),e.jsxs("div",{className:"md:col-span-2",children:[e.jsx(Gc,{htmlFor:"bl-img",children:"Image URL"}),e.jsx(Jr,{id:"bl-img",value:i.image_url??"",onChange:c=>l("image_url",c.target.value),placeholder:"https://â¦",className:"font-mono text-xs"})]}),e.jsxs("div",{children:[e.jsx(Gc,{htmlFor:"bl-sort",children:"Product sort order"}),e.jsxs(Tx,{value:i.sort_order??"manual",onValueChange:c=>l("sort_order",c),children:[e.jsx(zm,{id:"bl-sort",children:e.jsx(Px,{})}),e.jsx(Lm,{children:gse.map(c=>e.jsx(ec,{value:c.value,children:c.label},c.value))})]})]}),e.jsx("div",{className:"flex items-end gap-3",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Jy,{id:"bl-visible",checked:i.is_visible??!0,onCheckedChange:c=>l("is_visible",c)}),e.jsx(Gc,{htmlFor:"bl-visible",className:"cursor-pointer",children:"Visible on storefront"})]})})]}),e.jsxs(n1,{children:[e.jsx(gt,{variant:"outline",onClick:a,disabled:n,children:"Cancel"}),e.jsx(gt,{className:"bg-[#3b1f2b] hover:bg-[#5a2a3f] text-white",onClick:()=>r(i),disabled:n,children:n?"Savingâ¦":s?"Save changes":"Create brand line"})]})]})})}function vse(t){try{const[s,n]=t.split("."),a=r=>JSON.parse(atob(r.replace(/-/g,"+").replace(/_/g,"/")));return{header:a(s),payload:a(n)}}catch{return null}}const Kv=["z_entity_accounts","z_entity_ledger","z_entity_api_connections","ecom_collections","ecom_products","ecom_product_variants"];function jse(){var _,C,E,P;sn();const[t,s]=d.useState(null),[n,a]=d.useState(null),[r,i]=d.useState(null),[o,l]=d.useState([]),[c,u]=d.useState(null),[p,m]=d.useState(null),[x,h]=d.useState(Kv.map(F=>({table:F,status:"pending",rowCount:null,error:null,httpHint:null,ms:null}))),[y,v]=d.useState(Date.now());d.useEffect(()=>{const F=window.setInterval(()=>v(Date.now()),1e3);return()=>window.clearInterval(F)},[]);const g=d.useCallback(async()=>{const{data:F,error:I}=await O.auth.getSession();s((F==null?void 0:F.session)??null),a((I==null?void 0:I.message)??null);const{data:D}=await O.auth.getUser();i((D==null?void 0:D.user)??null)},[]),N=d.useCallback(async()=>{try{const{data:F,error:I}=await O.rpc("whoami");I?(u(null),m(`${I.code??""} ${I.message}`.trim())):(u(F),m(null))}catch(F){u(null),m((F==null?void 0:F.message)??String(F))}},[]),b=d.useCallback(async()=>{h(Kv.map(I=>({table:I,status:"pending",rowCount:null,error:null,httpHint:null,ms:null})));const F=await Promise.all(Kv.map(async I=>{const D=performance.now(),{count:L,error:V,status:B}=await O.from(I).select("*",{count:"exact",head:!0}),A=Math.round(performance.now()-D);return V?{table:I,status:"error",rowCount:null,error:`${V.code??""} ${V.message}`.trim(),httpHint:typeof B=="number"?String(B):null,ms:A}:{table:I,status:(L??0)>0?"ok":"empty",rowCount:L??0,error:null,httpHint:typeof B=="number"?String(B):null,ms:A}}));h(F)},[]);d.useEffect(()=>{g(),N(),b();const{data:F}=O.auth.onAuthStateChange((I,D)=>
1264{l(L=>[{event:I,at:new Date().toISOString()},...L].slice(0,20)),s(D),N(),b()});return()=>{F.subscription.unsubscribe()}},[g,N,b]);const f=(t==null?void 0:t.access_token)??null,j=f?vse(f):null,S=(_=j==null?void 0:j.payload)!=null&&_.exp&&typeof j.payload.exp=="number"?j.payload.exp*1e3:null,w=S?Math.floor((S-y)/1e3):null;return e.jsx("div",{className:"min-h-screen bg-slate-950 text-slate-100 font-mono text-sm",children:e.jsxs("div",{className:"max-w-5xl mx-auto px-6 py-10 space-y-10",children:[e.jsxs("header",{className:"border-b border-slate-800 pb-4",children:[e.jsx("h1",{className:"text-2xl font-bold tracking-tight text-white",children:"Auth Debug Panel"}),e.jsxs("p",{className:"mt-1 text-slate-400",children:["Route: ",e.jsx("code",{children:"/auth-debug"})," · Project schema:"," ",e.jsx("code",{children:"prj_9tt4lFhisXSi"})]}),e.jsx("button",{onClick:()=>{g(),N(),b()},className:"mt-4 px-3 py-1.5 bg-slate-800 hover:bg-slate-700 border border-slate-700 rounded text-slate-100",children:"Refresh All"})]}),e.jsxs("section",{children:[e.jsx("h2",{className:"text-lg font-semibold text-amber-300 mb-3",children:"1. Client-side truth (what supabase-js holds in memory)"}),e.jsxs("dl",{className:"grid grid-cols-[200px_1fr] gap-y-2 gap-x-4",children:[e.jsx("dt",{className:"text-slate-400",children:"session present"}),e.jsx("dd",{children:t?"yes":"no"}),e.jsx("dt",{className:"text-slate-400",children:"user.id"}),e.jsx("dd",{children:(r==null?void 0:r.id)??e.jsx("em",{className:"text-slate-500",children:"null"})}),e.jsx("dt",{className:"text-slate-400",children:"user.email"}),e.jsx("dd",{children:(r==null?void 0:r.email)??e.jsx("em",{className:"text-slate-500",children:"null"})}),e.jsx("dt",{className:"text-slate-400",children:"getSession() error"}),e.jsx("dd",{children:n??e.jsx("em",{className:"text-slate-500",children:"none"})}),e.jsx("dt",{className:"text-slate-400",children:"access_token (first 32)"}),e.jsx("dd",{className:"break-all",children:f?f.slice(0,32)+"â¦":e.jsx("em",{className:"text-slate-500",children:"null"})}),e.jsx("dt",{className:"text-slate-400",children:"jwt.payload.role"}),e.jsx("dd",{children:((C=j==null?void 0:j.payload)==null?void 0:C.role)??e.jsx("em",{className:"text-slate-500",children:"null"})}),e.jsx("dt",{className:"text-slate-400",children:"jwt.payload.aud"}),e.jsx("dd",{children:((E=j==null?void 0:j.payload)==null?void 0:E.aud)??e.jsx("em",{className:"text-slate-500",children:"null"})}),e.jsx("dt",{className:"text-slate-400",children:"jwt.payload.iss"}),e.jsx("dd",{children:((P=j==null?void 0:j.payload)==null?void 0:P.iss)??e.jsx("em",{className:"text-slate-500",children:"null"})}),e.jsx("dt",{className:"text-slate-400",children:"jwt.exp"}),e.jsx("dd",{children:S?new Date(S).toISOString():e.jsx("em",{className:"text-slate-500",children:"null"})}),e.jsx("dt",{className:"text-slate-400",children:"expires in"}),e.jsx("dd",{children:w===null?e.jsx("em",{className:"text-slate-500",children:"n/a"}):w<=0?e.jsxs("span",{className:"text-red-400",children:["EXPIRED (",w,"s)"]}):w<300?e.jsxs("span",{className:"text-amber-400",children:[w,"s (less than 5 min)"]}):e.jsxs("span",{className:"text-emerald-400",children:[w,"s"]})})]})]}),e.jsxs("section",{children:[e.jsx("h2",{className:"text-lg font-semibold text-amber-300 mb-3",children:"2. Server-side truth (what Postgres sees when this client calls it)"}),p?e.jsxs("pre",{className:"bg-slate-900 border border-red-900 text-red-300 p-3 rounded whitespace-pre-wrap",children:["whoami() RPC error: ",p,` 1265 1266`,`(If this says "function whoami() does not exist", the diagnostic RPC was never installed on this project. That's fine â the JWT decode above already shows what role the server WILL resolve.)`]}):c?e.jsx("pre",{className:"bg-slate-900 border border-slate-800 p-3 rounded overflow-auto",children:JSON.stringify(c,null,2)}):e.jsx("p",{className:"text-slate-500 italic",children:"loadingâ¦"})]}),e.jsxs("section",{children:[e.jsx("h2",{className:"text-lg font-semibold text-amber-300 mb-3",children:"3. Per-table probes (HEAD count, no rows fetched)"}),e.jsxs("table",{className:"w-full border-collapse",children:[e.jsx("thead",{children:e.jsxs("tr",{className:"text-left text-slate-400 border-b border-slate-800",children:[e.jsx("th",{className:"py-2 pr-4",children:"table"}),e.jsx("th",{className:"py-2 pr-4",children:"status"}),e.jsx("th",{className:"py-2 pr-4",children:"rows visible"}),e.jsx("th",{className:"py-2 pr-4",children:"http"}),e.jsx("th",{className:"py-2 pr-4",children:"ms"}),e.jsx("th",{className:"py-2",children:"error"})]})}),e.jsx("tbody",{children:x.map(F=>e.jsxs("tr",{className:"border-b border-slate-900",children:[e.jsx("td",{className:"py-2 pr-4 text-slate-200",children:F.table}),e.jsxs("td",{className:"py-2 pr-4",children:[F.status==="ok"&&e.jsx("span",{className:"text-emerald-400",children:"OK"}),F.status==="empty"&&e.jsx("span",{className:"text-amber-400",children:"EMPTY"}),F.status==="error"&&e.jsx("span",{className:"text-red-400",children:"ERROR"}),F.status==="pending"&&e.jsx("span",{className:"text-slate-500",children:"â¦"})]}),e.jsx("td",{className:"py-2 pr-4",children:F.rowCount===null?e.jsx("em",{className:"text-slate-500",children:"n/a"}):F.rowCount}),e.jsx("td",{className:"py-2 pr-4",children:F.httpHint??e.jsx("em",{className:"text-slate-500",children:"â"})}),e.jsx("td",{className:"py-2 pr-4",children:F.ms===null?e.jsx("em",{className:"text-slate-500",children:"â"}):`${F.ms}`}),e.jsx("td",{className:"py-2 text-red-300",children:F.error??e.jsx("em",{className:"text-slate-500",children:"â"})})]},F.table))})]}),e.jsx("p",{className:"mt-3 text-slate-500",children:"EMPTY = query succeeded but 0 rows are visible to this JWT (most likely an RLS filter, or the table really is empty). ERROR = the database refused the request â error text shown verbatim."})]}),e.jsxs("section",{children:[e.jsx("h2",{className:"text-lg font-semibold text-amber-300 mb-3",children:"4. onAuthStateChange event log (last 20)"}),o.length===0?e.jsx("p",{className:"text-slate-500 italic",children:"No auth events yet since this page mounted. (INITIAL_SESSION fires once on mount on most builds â if you don't see it within a few seconds, the auth client never finished hydrating from storage.)"}):e.jsx("ul",{className:"space-y-1",children:o.map((F,I)=>e.jsxs("li",{className:"text-slate-300",children:[e.jsx("span",{className:"text-slate-500",children:F.at})," ",e.jsx("span",{className:"text-emerald-300",children:F.event})]},I))})]})]})})}const wse=()=>{var v;sn();const{signIn:t,isAuthenticated:s,loading:n}=kn(),a=Za(),i=((v=ai().state)==null?void 0:v.from)||"/",[o,l]=d.useState(""),[c,u]=d.useState(""),[p,m]=d.useState(!1),[x,h]=d.useState(null);d.useEffect(()=>{!n&&s&&a(i,{replace:!0})},[n,s,a,i]);const y=async g=>{if(g.preventDefault(),h(null),!o.trim()||!c){h("Email and password are required.");return}m(!0);const N=await t(o.trim(),c);if(m(!1),!N.success){h(N.error||"Sign-in failed. Please check your credentials.");return}a(i,{replace:!0})};return e.jsx("div",{className:"min-h-screen bg-gradient-to-br from-stone-50 via-white to-rose-50/30 flex items-center justify-center px-4 py-12",children:e.jsxs("div",{className:"w-full max-w-md",children:[e.jsxs(be,{to:"/",className:"inline-flex items-center gap-1.5 text-xs font-medium text-gray-500 hover:text-burgundy transition-colors mb-6",children:[e.jsx(Je,{size:12})," Back to public site"]}),e.jsxs("div",{className:"bg-white rounded-2xl border border-stone-200/70 shadow-xl shadow-burgundy/5 overflow-hidden",children:[e.jsxs("div",{className:"bg-gradient-to-br from-burgundy via-burgundy-dark to-burgundy text-white px-8 py-7 relative",children:[e.jsxs("div",{className:"flex items-center gap-3 mb-4",children:[e.jsx("div",{className:"w-11 h-11 rounded-xl bg-white/15 backdrop-blur-sm border border-white/20 flex items-center justify-center",children:e.jsx(Ie,{size:20})}),e.jsxs("div",{children:[e.jsx("p",{className:"text-[10px] uppercase tracking-[0.25em] text-white/60 font-semibold",children:"Zorganics · Sovereign Console"}),e.jsx("h1",{className:"font-display text-xl font-bold tracking-tight mt-0.5",children:"Admin Sign-In"})]})]}),e.jsx("p",{className:"text-xs text-white/70 leading-relaxed",children:"Authenticate to unlock administrative tooling. Your session is bound to this browser only â credentials are never stored in the app bundle."})]}),e.jsxs("form",{onSubmit:y,className:"px-8 py-7 space-y-5",children:[x&&e.jsxs("div",{className:"flex items-start gap-2 px-3.5 py-3 bg-red-50 border border-red-200 rounded-lg",children:[e.jsx(Mt,{size:14,className:"text-red-600 mt-0.5 flex-shrink-0"}),e.jsx("p",{className:"text-xs text-red-700 font-medium leading-relaxed",children:x})]}),e.jsxs("div",{children:[e.jsx("label",{htmlFor:"admin-email",className:"block text-[11px] font-semibold text-gray-500 uppercase tracking-wider mb-1.5",children:"Email Address"}),e.jsxs("div",{className:"relative",children:[e.jsx(Ye,{size:14,className:"absolute left-3.5 to
1266p-1/2 -translate-y-1/2 text-gray-400"}),e.jsx("input",{id:"admin-email",type:"email",autoComplete:"email",autoFocus:!0,required:!0,disabled:p,value:o,onChange:g=>l(g.target.value),placeholder:"[email protected]",className:"w-full pl-10 pr-3.5 py-2.5 bg-stone-50 border border-stone-200 rounded-lg text-sm text-gray-900 placeholder-gray-400 focus:outline-none focus:ring-2 focus:ring-burgundy/30 focus:border-burgundy/40 focus:bg-white transition-all disabled:opacity-50"})]})]}),e.jsxs("div",{children:[e.jsx("label",{htmlFor:"admin-password",className:"block text-[11px] font-semibold text-gray-500 uppercase tracking-wider mb-1.5",children:"Password"}),e.jsxs("div",{className:"relative",children:[e.jsx(Xe,{size:14,className:"absolute left-3.5 top-1/2 -translate-y-1/2 text-gray-400"}),e.jsx("input",{id:"admin-password",type:"password",autoComplete:"current-password",required:!0,disabled:p,value:c,onChange:g=>u(g.target.value),placeholder:"â¢â¢â¢â¢â¢â¢â¢â¢",className:"w-full pl-10 pr-3.5 py-2.5 bg-stone-50 border border-stone-200 rounded-lg text-sm text-gray-900 placeholder-gray-400 focus:outline-none focus:ring-2 focus:ring-burgundy/30 focus:border-burgundy/40 focus:bg-white transition-all disabled:opacity-50"})]})]}),e.jsx("button",{type:"submit",disabled:p||n,className:"w-full flex items-center justify-center gap-2 px-4 py-3 bg-gradient-to-r from-burgundy via-burgundy-dark to-burgundy hover:brightness-110 text-white rounded-lg text-sm font-bold tracking-wide shadow-md shadow-burgundy/20 transition-all disabled:opacity-50 disabled:cursor-not-allowed",children:p?e.jsxs(e.Fragment,{children:[e.jsx(de,{size:14,className:"animate-spin"})," Authenticatingâ¦"]}):e.jsxs(e.Fragment,{children:[e.jsx(ka,{size:14})," Sign In to Admin Console"]})}),e.jsx("div",{className:"pt-2 border-t border-stone-100",children:e.jsx("p",{className:"text-[10px] text-gray-400 leading-relaxed text-center",children:"Sessions persist on this device until you sign out. Credentials are transmitted only to the authentication endpoint â never embedded in the deployed bundle."})})]})]}),e.jsx("p",{className:"text-center text-[10px] text-gray-400 mt-6 tracking-wider uppercase",children:"Zorganics Institute · Authenticated Operations"})]})})},Nse=()=>e.jsx(np,{children:e.jsx(wse,{})}),Gn=d.forwardRef(({className:t,...s},n)=>e.jsx("div",{ref:n,className:et("rounded-lg border border-border/40 bg-background shadow-sm",t),...s}));Gn.displayName="Card";const Su=d.forwardRef(({className:t,...s},n)=>e.jsx("div",{ref:n,className:et("flex flex-col space-y-1.5 p-6",t),...s}));Su.displayName="CardHeader";const Cu=d.forwardRef(({className:t,...s},n)=>e.jsx("h3",{ref:n,className:et("text-2xl font-semibold leading-none tracking-tight text-foreground",t),...s}));Cu.displayName="CardTitle";const _se=d.forwardRef(({className:t,...s},n)=>e.jsx("p",{ref:n,className:et("text-sm text-muted-foreground",t),...s}));_se.displayName="CardDescription";const Au=d.forwardRef(({className:t,...s},n)=>e.jsx("div",{ref:n,className:et("p-6 pt-0",t),...s}));Au.displayName="CardContent";const kse=d.forwardRef(({className:t,...s},n)=>e.jsx("div",{ref:n,className:et("flex items-center p-6 pt-0",t),...s}));kse.displayName="CardFooter";const Sse=Ib("inline-flex items-center rounded-full border px-2.5 py-0.5 text-xs font-semibold transition-all focus:outline-none focus:ring-2 focus:ring-primary focus:ring-offset-2",{variants:{variant:{default:"border-transparent bg-primary text-primary-foreground hover:bg-primary/80",secondary:"border-transparent bg-secondary text-secondary-foreground hover:bg-secondary/80",destructive:"border-transparent bg-destructive text-destructive-foreground hover:bg-destructive/80",outline:"text-foreground border-border",success:"border-transparent bg-green-500/20 text-green-700 dark:text-green-300 border-green-500/30",warning:"border-transparent bg-yellow-500/20 text-yellow-700 dark:text-yellow-300 border-yellow-500/30",info:"border-transparent bg-primary/10 text-primary border-primary/30"},size:{default:"px-2.5 py-0.5 text-xs",sm:"px-2 py-0.5 text-[10px]",lg:"px-3 py-0.5 text-sm"}},defaultVariants:{variant:"default",size:"default"}});function wn({className:t,variant:s,size:n,...a}){return e.jsx("div",{className:et(Sse({variant:s,size:n}),t),...a})}const lh=d.forwardRef(({className:t,...s},n)=>e.jsx("div",{className:"relative w-full overflow-auto",children:e.jsx("table",{ref:n,className:et("w-full caption-bottom text-sm",t),...s})}));lh.displayName="Table";const ch=d.forwardRef(({className:t,...s},n)=>e.jsx("thead",{ref:n,className:et("[&_tr]:border-b",t),...s}));ch.displayName="TableHeader";const dh=d.forwardRef(({className:t,...s},n)=>e.jsx("tbody",{ref:n,className:et("[&_tr:last-child]:border-0",t),...s}));dh.displayName="TableBody";const Cse=d.forwardRef(({className:t,...s},n)=>e.jsx("tfoot",{ref:n,className:et("border-t bg-muted/50 font-medium [&>tr]:last:border-b-0",t),...s}));Cse.displayName="TableFooter";const fi=d.forwardRef(({className:t,...s},n)=>e.jsx("tr",{ref:n,className:et("border-b transition-colors hover:bg-muted/50 data-[state=selected]:bg-muted",t),...s}));fi.displayName="TableRow";const gs=d.forwardRef(({className:t,...s},n)=>e.jsx("th",{ref:n,className:et("h-12 px-4 text-left align-middle font-medium text-muted-foreground [&:has([role=checkbox])]:pr-0",t),...s}));gs.displayName="TableHead";const Xt=d.forwardRef(({className:t,...s},n)=>e.jsx("td",{ref:n,className:et("p-4 align-middle [&:has([role=checkbox])]:pr-0",t),...s}));Xt.displayName="TableCell";const Ase=d.forwardRef(({className:t,...s},n)=>e.jsx("caption",{ref:n,className:et("mt-4 text-sm text-muted-foreground",t),...s}));Ase.displayName="TableCaption";var Ese=Object.defineProperty,Y5=(t,s)=>Ese(t,"name",{value:s,configurable:!0}),Qv=!1;
1266function g8(){const[t,s]=d.useState(Qv);return d.useEffect(()=>{Qv||(Qv=!0,s(!0))},[]),t}Y5(g8,"useIsHydrated");var y8=$d[" useSyncExternalStore ".trim().toString()];function b8(){return()=>{}}Y5(b8,"subscribe");function v8(){return y8(b8,()=>!0,()=>!1)}Y5(v8,"useIsHydratedModern");var Fse=typeof y8=="function"?v8:g8,Tse=Object.defineProperty,Wd=(t,s)=>Tse(t,"name",{value:s,configurable:!0}),Jv="rovingFocusGroup.onEntryFocus",Pse={bubbles:!1,cancelable:!0},c1="RovingFocusGroup",[iN,j8,Dse]=Tb(c1),[Rse,w8]=Va(c1,[Dse]),[Ise,$se]=Rse(c1),zse=d.forwardRef(Wd(function(s,n){return e.jsx(iN.Provider,{scope:s.__scopeRovingFocusGroup,children:e.jsx(iN.Slot,{scope:s.__scopeRovingFocusGroup,children:e.jsx(Lse,{...s,ref:n})})})},"RovingFocusGroup")),Lse=d.forwardRef(Wd(function(s,n){const{__scopeRovingFocusGroup:a,orientation:r,loop:i=!1,dir:o,currentTabStopId:l,defaultCurrentTabStopId:c,onCurrentTabStopIdChange:u,onEntryFocus:p,preventScrollOnEntryFocus:m=!1,...x}=s,h=d.useRef(null),y=It(n,h),v=i1(o),[g,N]=Po({prop:l,defaultProp:c??null,onChange:u,caller:c1}),[b,f]=d.useState(!1),j=sa(p),S=j8(a),w=d.useRef(!1),[_,C]=d.useState(0);return d.useEffect(()=>{const E=h.current;if(E)return E.addEventListener(Jv,j),()=>E.removeEventListener(Jv,j)},[j]),e.jsx(Ise,{scope:a,orientation:r,dir:v,loop:i,currentTabStopId:g,onItemFocus:d.useCallback(E=>N(E),[N]),onItemShiftTab:d.useCallback(()=>f(!0),[]),onFocusableItemAdd:d.useCallback(()=>C(E=>E+1),[]),onFocusableItemRemove:d.useCallback(()=>C(E=>E-1),[]),children:e.jsx(yt.div,{tabIndex:b||_===0?-1:0,"data-orientation":r,...x,ref:y,style:{outline:"none",...s.style},onMouseDown:at(s.onMouseDown,()=>{w.current=!0}),onFocus:at(s.onFocus,E=>{const P=!w.current;if(E.target===E.currentTarget&&P&&!b){const F=new CustomEvent(Jv,Pse);if(E.currentTarget.dispatchEvent(F),!F.defaultPrevented){const I=S().filter(A=>A.focusable),D=I.find(A=>A.active),L=I.find(A=>A.id===g),B=[D,L,...I].filter(Boolean).map(A=>A.ref.current);K5(B,m)}}w.current=!1}),onBlur:at(s.onBlur,()=>f(!1))})})},"RovingFocusGroupImpl")),Ose="RovingFocusGroupItem",Mse=d.forwardRef(Wd(function(s,n){const{__scopeRovingFocusGroup:a,focusable:r=!0,active:i=!1,tabStopId:o,children:l,...c}=s,u=Bl(),p=o||u,m=$se(Ose,a),x=m.currentTabStopId===p,h=j8(a),{onFocusableItemAdd:y,onFocusableItemRemove:v,currentTabStopId:g}=m,N=Fse();return vs(()=>{if(!(!N||!r))return y(),()=>v()},[N,r,y,v]),d.useEffect(()=>{if(!(N||!r))return y(),()=>v()},[N,r,y,v]),e.jsx(iN.ItemSlot,{scope:a,id:p,focusable:r,active:i,children:e.jsx(yt.span,{tabIndex:x?0:-1,"data-orientation":m.orientation,...c,ref:n,onMouseDown:at(s.onMouseDown,b=>{r?m.onItemFocus(p):b.preventDefault()}),onFocus:at(s.onFocus,()=>m.onItemFocus(p)),onKeyDown:at(s.onKeyDown,b=>{if(b.key==="Tab"&&b.shiftKey){m.onItemShiftTab();return}if(b.target!==b.currentTarget)return;const f=_8(b,m.orientation,m.dir);if(f!==void 0){if(b.metaKey||b.ctrlKey||b.altKey||b.shiftKey)return;b.preventDefault();let S=h().filter(w=>w.focusable).map(w=>w.ref.current);if(f==="last")S.reverse();else if(f==="prev"||f==="next"){f==="prev"&&S.reverse();const w=S.indexOf(b.currentTarget);S=m.loop?k8(S,w+1):S.slice(w+1)}setTimeout(()=>K5(S))}}),children:typeof l=="function"?l({isCurrentTabStop:x,hasTabStop:g!=null}):l})})},"RovingFocusGroupItem")),Bse={ArrowLeft:"prev",ArrowUp:"prev",ArrowRight:"next",ArrowDown:"next",PageUp:"first",Home:"first",PageDown:"last",End:"last"};function N8(t,s){return s!=="rtl"?t:t==="ArrowLeft"?"ArrowRight":t==="ArrowRight"?"ArrowLeft":t}Wd(N8,"getDirectionAwareKey");function _8(t,s,n){const a=N8(t.key,n);if(!(s==="vertical"&&["ArrowLeft","ArrowRight"].includes(a))&&!(s==="horizontal"&&["ArrowUp","ArrowDown"].includes(a)))return Bse[a]}Wd(_8,"getFocusIntent");function K5(t,s=!1){const n=document.activeElement;for(const a of t)if(a===n||(a.focus({preventScroll:s}),document.activeElement!==n))return}Wd(K5,"focusFirst");function k8(t,s){return t.map((n,a)=>t[(s+a)%t.length])}Wd(k8,"wrapArray");var Use=zse,qse=Mse,Wse=Object.defineProperty,op=(t,s)=>Wse(t,"name",{value:s,configurable:!0}),Q5="Tabs",[Hse,ixe]=Va(Q5,[w8]),S8=w8(),[Gse,J5]=Hse(Q5),Vse=d.forwardRef(op(function(s,n){const{__scopeTabs:a,value:r,onValueChange:i,defaultValue:o,orientation:l="horizontal",dir:c,activationMode:u="automatic",...p}=s,m=i1(c),[x,h]=Po({prop:r,onChange:i,defaultProp:o??"",caller:Q5});return e.jsx(Gse,{scope:a,baseId:Bl(),value:x,onValueChange:h,orientation:l,dir:m,activationMode:u,children:e.jsx(yt.div,{dir:m,"data-orientation":l,...p,ref:n})})},"Tabs")),Zse="TabsList",Yse=d.forwardRef(op(function(s,n){const{__scopeTabs:a,loop:r=!0,...i}=s,o=J5(Zse,a),l=S8(a);return e.jsx(Use,{asChild:!0,...l,orientation:o.orientation,dir:o.dir,loop:r,children:e.jsx(yt.div,{role:"tablist","aria-orientation":o.orientation,...i,ref:n})})},"TabsList")),Kse="TabsTrigger",Qse=d.forwardRef(op(function(s,n){const{__scopeTabs:a,value:r,disabled:i=!1,...o}=s,l=J5(Kse,a),c=S8(a),u=X5(l.baseId,r),p=ek(l.baseId,r),m=r===l.value;return e.jsx(qse,{asChild:!0,...c,focusable:!i,active:m,children:e.jsx(yt.button,{type:"button",role:"tab","aria-selected":m,"aria-controls":p,"data-state":m?"active":"inactive","data-disabled":i?"":void 0,disabled:i,id:u,...o,ref:n,onMouseDown:at(s.onMouseDown,x=>{!i&&x.button===0&&x.ctrlKey===!1?l.onValueChange(r):x.preventDefault()}),onKeyDown:at(s.onKeyDown,x=>{i||x.target!==x.currentTarget||[" ","Enter"].includes(x.key)&&l.onValueChange(r)}),onFocus:at(s.onFocus,()=>{const x=l.activationMode!=="manual";!m&&!i&&x&&l.onValueChange(r)})})})},"TabsTrigger")),Jse="TabsContent",Xse=d.forwardRef(op(function(s,n){const{__scopeTabs:a,value:r,forceMount:i,children:o,...l}=s,c=J5(Jse,a),u=X5(c.baseId,r),p=ek(c.baseId,r),m=r===c.value,x=d.useRef(m);return d.useEffect(()=>{const h=requestAnimationFrame(()=>x.current=!1);return()=>cancelAnimationFrame(h)},[]),e.jsx(ic,{present:i||m,children:({present:h})=>e.jsx(yt.div,{"data-state":m?"active":"inactive","data-orientation":c.orientation,role:"tabpanel","aria-labelledby":u,hidden:!h,id:p,tabIndex:0,...l,ref:n,style:{...s.style,animationDuration:x.current?"0s":void 0},children:h&&o})})},"TabsContent"));function X5(t,s){return`${t}-trigger-${s}`}op(X5,"makeTriggerId");function ek(t,s){return`${t}-content-${s}`}op(ek,"makeContentId");var ene=Vse,C8=Yse,A8=Qse,E8=Xse;const tne=ene,F8=d.forwardRef(({className:t,...s},n)=>e.jsx(C8,{ref:n,className:et("inline-flex h-10 items-center justify-center rounded-md bg-muted/50 p-1 text-muted-foreground",t),...s}));F8.displayName=C8.displayName;const uh=d.forwardRef(({className:t,...s},n)=>e.jsx(A8,{ref:n,className:et("inline-flex items-center justify-center whitespace-nowrap rounded-sm px-3 py-1.5 text-sm font-medium ring-offset-background transition-all focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 data-[state=active]:bg-background data-[state=active]:text-primary data-[state=active]:shadow-sm hover:text-foreground",t),...s}));uh.displayName=A8.displayName;const mh=d.forwardRef(({className:t,...s},n)=>e.jsx(E8,{ref:n,className:et("mt-2 ring-offset-background focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary focus-visible:ring-offset-2 animate-in fade-in-0 data-[state=inactive]:animate-out data-[state=inactive]:fade-out-0 duration-200",t),...s}));mh.displayName=E8.displayName;var sne=Object.defineProperty,Go=(t,s)=>sne(t,"name",{value:s,configurable:!0}),nne="AlertDialog",[ane,oxe]=Va(nne,[QR]),Vo=QR(),rne=Go(t=>{const{__scopeAlertDialog:s,...n}=t,a=Vo(s);return e.jsx(JR,{...a,...n,modal:!0})},"AlertDialog");d.forwardRef(Go(function(s,n){const{__scopeAlertDialog:a,...r}=s,i=Vo(a);return e.jsx(eY,{...i,...r,ref:n})},"AlertDialogTrigger"));var ine=Go(t=>{const{__scopeAlertDialog:s,...n}=t,a=Vo(s);return e.jsx(tI,{...a,...n})},"AlertDialogPortal"),one=d.forwardRef(Go(function(s,n){const{__scopeAlertDialog:a,...r}=s,i=Vo(a);return e.jsx(_5,{...i,...r,ref:n})},"AlertDialogOverlay")),lne="AlertDialogContent",[cne,dne]=ane(lne),une=d.forwardRef(Go(function(s,n){const{__scopeAlertDialog:a,children:r,...i}=s,o=Vo(a),l=d.useRef(null),c=It(n,l),u=d.useRef(null);return e.jsx(cne,{scope:a,cancelRef:u,children:e.jsx(k5,{role:"alertdialog",...o,...i,ref:c,onOpenAutoFocus:at(i.onOpenAutoFocus,p=>{var m;p.preventDefault(),(m=u.current)==null||m.focus({preventScroll:!0})}),onPointerDownOutside:p=>p.preventDefault(),onInteractOutside:p=>p.preventDefault(),children:r})})},"AlertDialogContent")),mne=d.forwardRef(Go(function(s,n){const{__scopeAlertDialog:a,...r}=s,i=Vo(a);return e.jsx(S5,{...i,...r,ref:n})},"AlertDialogTitle")),pne=d.forwardRef(Go(function(s,n){const{__scopeAlertDialog:a,...r}=s,i=Vo(a);return e.jsx(C5,{...i,...r,ref:n})},"AlertDialogDescription")),hne=d.forwardRef(Go(function(s,n){const{__scopeAlertDialog:a,...r}=s,i=Vo(a);return e.jsx(A5,{...i,...r,ref:n})},"AlertDialogAction")),xne="AlertDialogCancel",fne=d.forwardRef(Go(function(s,n){const{__scopeAlertDialog:a,...r}=s,{cancelRef:i}=dne(xne,a),o=Vo(a),l=It(n,i);return e.jsx(A5,{...o,...r,ref:l})},"AlertDialogCancel")),gne=rne,yne=ine,T8=one,P8=une,D8=hne,R8=fne,I8=mne,$8=pne;const Xv=gne,bne=yne,z8=d.forwardRef(({className:t,...s},n)=>e.jsx(T8,{className:et("fixed inset-0 z-50 bg-background/80 backdrop-blur-sm data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",t),...s,ref:n}));z8.displayName=T8.displayName;const F0=d.forwardRef(({className:t,...s},n)=>e.jsxs(bne,{children:[e.jsx(z8,{}),e.jsx(P8,{ref:n,className:et("fixed left-[50%] top-[50%] z-50 grid w-full max-w-lg translate-x-[-50%] translate-y-[-50%] gap-4 border bg-card p-6 shadow-lg duration-200 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[state=closed]:slide-out-to-left-1/2 data-[state=closed]:slide-out-to-top-[48%] data-[state=open]:slide-in-from-left-1/2 data-[state=open]:slide-in-from-top-[48%] sm:rou
1266nded-lg",t),...s})]}));F0.displayName=P8.displayName;const T0=({className:t,...s})=>e.jsx("div",{className:et("flex flex-col space-y-2 text-center sm:text-left",t),...s});T0.displayName="AlertDialogHeader";const P0=({className:t,...s})=>e.jsx("div",{className:et("flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2 mt-4",t),...s});P0.displayName="AlertDialogFooter";const D0=d.forwardRef(({className:t,...s},n)=>e.jsx(I8,{ref:n,className:et("text-lg font-semibold text-primary/90",t),...s}));D0.displayName=I8.displayName;const R0=d.forwardRef(({className:t,...s},n)=>e.jsx($8,{ref:n,className:et("text-sm text-muted-foreground mt-2",t),...s}));R0.displayName=$8.displayName;const I0=d.forwardRef(({className:t,...s},n)=>e.jsx(D8,{ref:n,className:et(F5(),t),...s}));I0.displayName=D8.displayName;const $0=d.forwardRef(({className:t,...s},n)=>e.jsx(R8,{ref:n,className:et(F5({variant:"outline"}),"mt-2 sm:mt-0",t),...s}));$0.displayName=R8.displayName;const ej=[{value:"1h",label:"1 hour",ms:60*60*1e3},{value:"24h",label:"24 hours",ms:24*60*60*1e3},{value:"7d",label:"7 days",ms:7*24*60*60*1e3},{value:"30d",label:"30 days",ms:30*24*60*60*1e3},{value:"permanent",label:"Permanent (never expires)",ms:null}];function vne(t){if(!t)return"never expires";const s=new Date(t).getTime();if(Number.isNaN(s))return"â";const n=s-Date.now();if(n<=0)return"expired";const a=Math.floor(n/6e4),r=Math.floor(a/(60*24)),i=Math.floor(a%(60*24)/60),o=a%60;return r>0?i>0?`${r}d ${i}h`:`${r}d`:i>0?o>0?`${i}h ${o}m`:`${i}h`:o>0?`${o}m`:"<1m"}const jne=[{value:"all",label:"All events"},{value:"SIGN_IN",label:"Sign in"},{value:"SIGN_OUT",label:"Sign out (any reason)"},{value:"MANUAL_SIGNOUT",label:"Manual sign-out"},{value:"IDLE_WARNING_SHOWN",label:"Idle warning shown"},{value:"IDLE_AUTO_SIGNOUT",label:"Auto sign-out (idle)"},{value:"FORCED_REVOCATION",label:"Forced revocation"}];function wne(t){switch(t){case"SIGN_IN":return{icon:e.jsx($o,{className:"h-4 w-4"}),badgeClass:"bg-emerald-100 text-emerald-900 border-emerald-300",label:"Sign in"};case"SIGN_OUT":return{icon:e.jsx(bo,{className:"h-4 w-4"}),badgeClass:"bg-slate-100 text-slate-900 border-slate-300",label:"Sign out"};case"MANUAL_SIGNOUT":return{icon:e.jsx(JO,{className:"h-4 w-4"}),badgeClass:"bg-blue-100 text-blue-900 border-blue-300",label:"Manual sign-out"};case"IDLE_WARNING_SHOWN":return{icon:e.jsx(ve,{className:"h-4 w-4"}),badgeClass:"bg-amber-100 text-amber-900 border-amber-300",label:"Idle warning"};case"IDLE_AUTO_SIGNOUT":return{icon:e.jsx(dt,{className:"h-4 w-4"}),badgeClass:"bg-rose-100 text-rose-900 border-rose-300",label:"Auto sign-out"};case"FORCED_REVOCATION":return{icon:e.jsx(KP,{className:"h-4 w-4"}),badgeClass:"bg-purple-100 text-purple-900 border-purple-300",label:"Forced revocation"};default:return{icon:e.jsx(Ma,{className:"h-4 w-4"}),badgeClass:"bg-slate-100 text-slate-900 border-slate-300",label:t}}}function tj(t){return t?/edg\//i.test(t)?"Edge":/chrome\//i.test(t)&&!/edg\//i.test(t)?"Chrome":/firefox\//i.test(t)?"Firefox":/safari\//i.test(t)&&!/chrome\//i.test(t)?"Safari":"Browser":"â"}function Vi(t){try{return new Date(t).toLocaleString(void 0,{year:"numeric",month:"short",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit"})}catch{return t}}function sj(t){const s=new Date(t).getTime();if(Number.isNaN(s))return"â";const n=Date.now()-s;if(n<6e4)return"just now";const a=Math.floor(n/6e4);if(a<60)return`${a}m ago`;const r=Math.floor(a/60);return r<24?`${r}h ago`:`${Math.floor(r/24)}d ago`}function ki(t){if(t==null)return"";const s=String(t);return/[",\r\n]/.test(s)?`"${s.replace(/"/g,'""')}"`:s}function Nne(t){const n=[["when","event_type","email","user_id","ip","user_agent"].join(",")];for(const a of t)n.push([ki(a.created_at),ki(a.event_type),ki(a.email),ki(a.user_id),ki(a.ip),ki(a.user_agent)].join(","));return n.join(`\r 1267`)+`\r 1268`}function _ne(t){const n=[["attempted_at","ip","email_attempted","user_agent"].join(",")];for(const a of t)n.push([ki(a.attempted_at),ki(a.ip),ki(a.email_attempted),ki(a.user_agent)].join(","));return n.join(`\r 1269`)+`\r 1270`}const sl=500,kne=new Set(["SIGN_OUT","IDLE_AUTO_SIGNOUT","MANUAL_SIGNOUT","FORCED_REVOCATION"]);function Sne(t){const s=new Map;for(const a of t){const r=a.user_id||a.email;r&&(s.has(r)||s.set(r,a))}const n=[];for(const[a,r]of s.entries())r.event_type==="SIGN_IN"?n.push({key:a,user_id:r.user_id,email:r.email,signed_in_at:r.created_at,ip:r.ip,user_agent:r.user_agent}):!kne.has(String(r.event_type))&&r.event_type==="IDLE_WARNING_SHOWN"&&n.push({key:a,user_id:r.user_id,email:r.email,signed_in_at:r.created_at,ip:r.ip,user_agent:r.user_agent});return n.sort((a,r)=>r.signed_in_at.localeCompare(a.signed_in_at)),n}function Cne(t){const s=[];for(const n of t){const a=s[s.length-1];a&&a.ip===n.ip?(a.rows.push(n),a.oldestAt=n.attempted_at,a.key=`${a.rows[0].id}_${n.id}`):s.push({key:n.id,ip:n.ip,rows:[n],newestAt:n.attempted_at,oldestAt:n.attempted_at})}return s}
1270function gE(t,s){const n=new Date(t).getTime(),a=new Date(s).getTime();if(Number.isNaN(n)||Number.isNaN(a))return"unknown span";const r=Math.abs(n-a);if(r<1e3)return"instantly";const i=Math.round(r/1e3);if(i<60)return`${i} second${i===1?"":"s"}`;const o=Math.round(r/6e4);if(o<60)return`${o} minute${o===1?"":"s"}`;const l=Math.round(r/36e5);if(l<24)return`${l} hour${l===1?"":"s"}`;const c=Math.round(r/864e5);return`${c} day${c===1?"":"s"}`}function Ane(){const{user:t,isSuperAdmin:s,loading:n}=kn(),a=Za(),[r,i]=d.useState([]),[o,l]=d.useState(!0),[c,u]=d.useState(null),[p,m]=d.useState(0),[x,h]=d.useState("all"),[y,v]=d.useState(""),[g,N]=d.useState("events"),[b,f]=d.useState(null),[j,S]=d.useState(!1),[w,_]=d.useState(null),[C,E]=d.useState(""),[P,F]=d.useState("24h"),[I,D]=d.useState(!1),[L,V]=d.useState([]),[B,A]=d.useState(!1),[z,M]=d.useState(null),[R,T]=d.useState(null),[U,q]=d.useState(!1),[H,G]=d.useState(null),[W,X]=d.useState(null),Q=10,K=5,[se,Y]=d.useState([]),[J,te]=d.useState(!1),[pe,Fe]=d.useState(null),[ke,Oe]=d.useState({});d.useEffect(()=>{n||t&&(s||a("/",{replace:!0}))},[t,s,n,a]),d.useEffect(()=>{let ae=!1;return(async()=>{l(!0),u(null);try{let bt=O.from("admin_session_events").select("*").order("created_at",{ascending:!1}).limit(sl);g==="events"&&x!=="all"&&(bt=bt.eq("event_type",x)),g==="events"&&y.trim()&&(bt=bt.ilike("email",`%${y.trim()}%`));const{data:ht,error:Ht}=await bt;if(ae)return;Ht?(u(Ht.message),i([])):i(ht||[])}catch(bt){ae||(u((bt==null?void 0:bt.message)||"Failed to load session events."),i([]))}finally{ae||l(!1)}})(),()=>{ae=!0}},[x,y,p,g]);const ue=d.useCallback(async()=>{A(!0),M(null);try{const{data:ae,error:qe}=await O.from("admin_ip_bans").select("*").order("active",{ascending:!1}).order("created_at",{ascending:!1}).limit(200);qe?(M(qe.message),V([])):V(ae||[])}catch(ae){M((ae==null?void 0:ae.message)||"Failed to load IP bans."),V([])}finally{A(!1)}},[]);d.useEffect(()=>{ue()},[ue,p]),d.useEffect(()=>{let ae=!1;return(async()=>{try{const bt=new Date(Date.now()-Q*60*1e3).toISOString(),[ht,Ht]=await Promise.all([O.from("admin_failed_signins").select("id",{count:"exact",head:!0}).gte("attempted_at",bt),O.from("admin_failed_signins").select("id",{count:"exact",head:!0})]);if(ae)return;G(ht.error?0:ht.count??0),X(Ht.error?0:Ht.count??0)}catch{ae||(G(0),X(0))}})(),()=>{ae=!0}},[p,Q]);const je=d.useCallback(async()=>{te(!0),Fe(null);try{const{data:ae,error:qe}=await O.from("admin_failed_signins").select("id, ip, email_attempted, user_agent, attempted_at").order("attempted_at",{ascending:!1}).limit(sl);qe?(Fe(qe.message),Y([])):Y(ae||[])}catch(ae){Fe((ae==null?void 0:ae.message)||"Failed to load failed sign-in attempts."),Y([])}finally{te(!1)}},[]);d.useEffect(()=>{je()},[je,p]),d.useEffect(()=>{const ae=setInterval(()=>{m(qe=>qe+1)},2e4);return()=>clearInterval(ae)},[]);const le=d.useMemo(()=>{const ae={total:r.length,signIns:0,autoSignOuts:0,manualSignOuts:0,warnings:0,revocations:0};for(const qe of r)qe.event_type==="SIGN_IN"?ae.signIns++:qe.event_type==="IDLE_AUTO_SIGNOUT"?ae.autoSignOuts++:qe.event_type==="MANUAL_SIGNOUT"?ae.manualSignOuts++:qe.event_type==="IDLE_WARNING_SHOWN"?ae.warnings++:qe.event_type==="FORCED_REVOCATION"&&ae.revocations++;return ae},[r]),ye=d.useMemo(()=>{const ae=Sne(r),qe=y.trim().toLowerCase();return qe?ae.filter(bt=>(bt.email||"").toLowerCase().includes(qe)):ae},[r,y]),we=d.useMemo(()=>{const ae=new Set;for(const qe of L)qe.active&&ae.add(qe.ip);return ae},[L]),He=d.useMemo(()=>L.reduce((ae,qe)=>qe.active?ae+1:ae,0),[L]),Lt=d.useMemo(()=>Cne(se),[se]),ut=()=>{if(r.length===0)return;const ae=Nne(r),qe=new Blob(["\uFEFF",ae],{type:"text/csv;charset=utf-8;"}),bt=URL.createObjectURL(qe),ht=new Date().toISOString().replace(/[:.]/g,"-"),Ht=x==="all"?"all":x,wt=y.trim()?`_${y.trim().replace(/[^a-z0-9._-]/gi,"_").slice(0,32)}`:"",_e=`session-audit_${Ht}${wt}_${ht}.csv`,Se=document.createElement("a");Se.href=bt,Se.download=_e,document.body.appendChild(Se),Se.click(),document.body.removeChild(Se),setTimeout(()=>URL.revokeObjectURL(bt),0)},ge=()=>{if(se.length===0)return;const ae=_ne(se),qe=new Blob(["\uFEFF",ae],{type:"text/csv;charset=utf-8;"}),bt=URL.createObjectURL(qe),ht=H??0,Ht=new Date().toISOString().replace(/\.\d{3}Z$/,"Z").replace(/:/g,"-"),wt=`failed-signins_${ht}-recent_${Ht}.csv`,_e=document.createElement("a");_e.href=bt,_e.download=wt,document.body.appendChild(_e),_e.click(),document.body.removeChild(_e),setTimeout(()=>URL.revokeObjectURL(bt),0)},Ne=async()=>
1270{if(b){if(!b.user_id&&!b.email){Ct.error("Cannot revoke â no user_id or email on this session."),f(null);return}S(!0);try{const{error:ae}=await O.from("session_revocations").insert({user_id:b.user_id||b.email,email:b.email,reason:"Revoked from Session Audit Log",active:!0,created_by_user_id:(t==null?void 0:t.id)??null,created_by_email:(t==null?void 0:t.email)??null});ae?Ct.error(`Revoke failed: ${ae.message}`):(Ct.success(`Revocation issued for ${b.email||"user"}. They'll be signed out within 60 seconds.`,{duration:6e3}),setTimeout(()=>m(qe=>qe+1),2e3))}catch(ae){Ct.error((ae==null?void 0:ae.message)||"Unexpected error issuing revocation.")}finally{S(!1),f(null)}}},lt=async()=>{if(!w)return;const ae=C.trim(),qe=ej.find(ht=>ht.value===P),bt=(qe==null?void 0:qe.ms)!=null?new Date(Date.now()+qe.ms).toISOString():null;D(!0);try{const{error:ht}=await O.from("admin_ip_bans").insert({ip:w.ip,reason:ae||null,active:!0,expires_at:bt,created_by_user_id:(t==null?void 0:t.id)??null,created_by_email:(t==null?void 0:t.email)??null});if(ht)Ct.error(`Ban failed: ${ht.message}`);else{const Ht=(qe==null?void 0:qe.label)??"permanent";Ct.success(bt?`IP ${w.ip} banned for ${Ht}. Sign-in attempts will be rejected until ${Vi(bt)}.`:`IP ${w.ip} is now permanently banned. Sign-in attempts from this address will be rejected.`,{duration:6e3}),ue()}}catch(ht){Ct.error((ht==null?void 0:ht.message)||"Unexpected error issuing IP ban.")}finally{D(!1),_(null),E(""),F("24h")}},mt=async()=>{if(R){q(!0);try{const{error:ae}=await O.from("admin_ip_bans").update({active:!1,deactivated_at:new Date().toISOString(),deactivated_by_email:(t==null?void 0:t.email)??null}).eq("id",R.id);ae?Ct.error(`Unban failed: ${ae.message}`):(Ct.success(`IP ${R.ip} unbanned. Sign-in from this address is allowed again.`,{duration:5e3}),ue())}catch(ae){Ct.error((ae==null?void 0:ae.message)||"Unexpected error during unban.")}finally{q(!1),T(null)}}};return n?e.jsx("div",{className:"min-h-screen flex items-center justify-center bg-[#FAF7F2]",children:e.jsx("div",{className:"text-[#3B0A11]/70",children:"Verifying sessionâ¦"})}):s?e.jsxs("div",{className:"min-h-screen bg-[#FAF7F2] py-8 px-4 sm:px-6 lg:px-8",children:[e.jsxs("div",{className:"max-w-7xl mx-auto",children:[e.jsx("header",{className:"mb-6",children:e.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-start sm:justify-between gap-4 mb-2",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"h-10 w-10 rounded-lg bg-gradient-to-br from-[#3B0A11] to-[#5C1320] flex items-center justify-center shadow-md",children:e.jsx(Tt,{className:"h-5 w-5 text-[#D4AF37]"})}),e.jsxs("div",{children:[e.jsx("h1",{className:"text-2xl sm:text-3xl font-serif font-bold text-[#3B0A11]",children:"Session Audit Log"}),e.jsx("p",{className:"text-sm text-[#3B0A11]/60",children:"Super-admin review of admin sign-in / sign-out / idle-timeout activity"})]})]}),e.jsxs(gt,{onClick:ut,disabled:o||r.length===0,className:"bg-gradient-to-br from-[#3B0A11] to-[#5C1320] hover:from-[#5C1320] hover:to-[#3B0A11] text-[#D4AF37] border border-[#D4AF37]/40 shadow-md disabled:opacity-50 disabled:cursor-not-allowed self-start sm:self-auto",title:r.length===0?"No events to export with the current filters":`Download ${r.length} event${r.length===1?"":"s"} as CSV`,children:[e.jsx(us,{className:"h-4 w-4 mr-2"}),"Download CSV",r.length>0&&e.jsxs("span",{className:"ml-2 text-xs font-normal opacity-80",children:["(",r.length.toLocaleString(),")"]})]})]})}),e.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-4 lg:grid-cols-7 gap-3 mb-6",children:[e.jsx(du,{label:"Loaded events",value:le.total,accent:"slate"}),e.jsx(du,{label:"Sign-ins",value:le.signIns,accent:"emerald"}),e.jsx(du,{label:"Warnings shown",value:le.warnings,accent:"amber"}),e.jsxs("div",{className:["rounded-lg border-2 px-4 py-3 shadow-sm transition-colors col-span-2 md:col-span-1",H!=null&&H>=K?"border-rose-500 bg-rose-100 text-rose-900 ring-2 ring-rose-300/60":H!=null&&H>0?"border-amber-400 bg-amber-50 text-amber-900":"border-slate-300 bg-white text-[#3B0A11]"].join(" "),title:`Failed sign-in attempts captured in admin_failed_signins over the past ${Q} minutes. ${K}+ from a single IP trips a 1-hour auto-ban.`,children:[e.jsxs("div",{className:"flex items-center justify-between gap-2",children:[e.jsxs("div",{className:"text-[11px] uppercase tracking-wide opacity-70 flex items-center gap-1",children:[e.jsx(ka,{className:"h-3 w-3"}),"Failed sign-ins (",Q,"m)"]}),H!=null&&H>=K&&e.jsx(ve,{className:"h-3.5 w-3.5 text-rose-600 animate-pulse"})]}),e.jsx("div",{className:"text-2xl font-bold tabular-nums leading-tight",children:H!=null?H.toLocaleStr
1270ing():"â"}),e.jsx("div",{className:"text-[10px] opacity-70 mt-0.5",children:W!=null?`${W.toLocaleString()} total · auto-ban at ${K}+/IP`:`auto-ban at ${K}+/IP`})]}),e.jsx(du,{label:"Auto sign-outs",value:le.autoSignOuts,accent:"rose"}),e.jsx(du,{label:"Manual sign-outs",value:le.manualSignOuts,accent:"blue"}),e.jsx(du,{label:"Revocations",value:le.revocations,accent:"purple"})]}),e.jsxs(tne,{value:g,onValueChange:ae=>N(ae),className:"mb-4",children:[e.jsxs(F8,{className:"bg-white border border-[#D4AF37]/40",children:[e.jsxs(uh,{value:"events",className:"data-[state=active]:bg-[#3B0A11] data-[state=active]:text-[#D4AF37] gap-2",children:[e.jsx(Ma,{className:"h-4 w-4"}),"Event Log"]}),e.jsxs(uh,{value:"active",className:"data-[state=active]:bg-[#3B0A11] data-[state=active]:text-[#D4AF37] gap-2",children:[e.jsx(ts,{className:"h-4 w-4"}),"Active Users",ye.length>0&&e.jsx("span",{className:"ml-1 inline-flex items-center justify-center min-w-[1.25rem] h-5 px-1.5 rounded-full bg-[#D4AF37]/20 text-[#3B0A11] text-[10px] font-semibold",children:ye.length})]}),e.jsxs(uh,{value:"bans",className:"data-[state=active]:bg-[#3B0A11] data-[state=active]:text-[#D4AF37] gap-2",children:[e.jsx(zn,{className:"h-4 w-4"}),"IP Bans",He>0&&e.jsx("span",{className:"ml-1 inline-flex items-center justify-center min-w-[1.25rem] h-5 px-1.5 rounded-full bg-rose-100 text-rose-900 border border-rose-300 text-[10px] font-semibold",children:He})]}),e.jsxs(uh,{value:"failed",className:"data-[state=active]:bg-[#3B0A11] data-[state=active]:text-[#D4AF37] gap-2",children:[e.jsx(ka,{className:"h-4 w-4"}),"Failed Sign-ins",H!=null&&H>0&&e.jsx("span",{className:["ml-1 inline-flex items-center justify-center min-w-[1.25rem] h-5 px-1.5 rounded-full text-[10px] font-semibold border",H>=K?"bg-rose-100 text-rose-900 border-rose-300":"bg-amber-100 text-amber-900 border-amber-300"].join(" "),children:H})]})]}),g!=="bans"&&g!=="failed"&&e.jsxs(Gn,{className:"mt-4 border-[#D4AF37]/40 bg-white shadow-sm",children:[e.jsx(Su,{className:"pb-3",children:e.jsxs(Cu,{className:"text-base font-semibold text-[#3B0A11] flex items-center gap-2",children:[e.jsx(Ma,{className:"h-4 w-4 text-[#D4AF37]"})," Filters"]})}),e.jsxs(Au,{className:"grid gap-3 sm:grid-cols-[1fr_1fr_auto] items-end",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs font-medium text-[#3B0A11]/70 mb-1",children:"Event type"}),e.jsxs(Tx,{value:x,onValueChange:ae=>h(ae),disabled:g==="active",children:[e.jsx(zm,{className:"bg-white border-[#D4AF37]/40",children:e.jsx(Px,{placeholder:"All events"})}),e.jsx(Lm,{children:jne.map(ae=>e.jsx(ec,{value:ae.value,children:ae.label},ae.value))})]}),g==="active"&&e.jsx("p",{className:"mt-1 text-[10px] text-[#3B0A11]/50",children:"Event-type filter is disabled in Active Users â all events are needed to derive open sessions."})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs font-medium text-[#3B0A11]/70 mb-1",children:"User (email contains)"}),e.jsx(Jr,{type:"text",placeholder:"e.g. [email protected]",value:y,onChange:ae=>v(ae.target.value),className:"bg-white border-[#D4AF37]/40"})]}),e.jsxs(gt,{variant:"outline",onClick:()=>m(ae=>ae+1),className:"border-[#D4AF37] text-[#3B0A11] hover:bg-[#D4AF37]/10",children:[e.jsx(Be,{className:`h-4 w-4 mr-2 ${o?"animate-spin":""}`}),"Refresh"]})]})]}),e.jsx(mh,{value:"events",className:"mt-4",children:e.jsxs(Gn,{className:"border-[#D4AF37]/40 bg-white shadow-sm",children:[e.jsx(Su,{className:"pb-3",children:e.jsxs(Cu,{className:"text-base font-semibold text-[#3B0A11]",children:[o?"Loading eventsâ¦":`${r.length.toLocaleString()} event${r.length===1?"":"s"}`,r.length===sl&&e.jsxs("span",{className:"ml-2 text-xs font-normal text-[#3B0A11]/60",children:["(showing most recent ",sl," â narrow your filter to see older)"]})]})}),e.jsx(Au,{className:"p-0",children:c?e.jsxs("div",{className:"p-6 text-sm text-rose-700 bg-rose-50 border-y border-rose-200",children:["Couldn't load session events: ",c]}):r.length===0&&!o?e.jsx("div",{className:"p-10 text-center text-[#3B0A11]/60 text-sm",children:"No session events match the current filters."}):e.jsx("div",{className:"overflow-x-auto",children:e.jsxs(lh,{children:[e.jsx(ch,{children:e.jsxs(fi,{className:"bg-[#3B0A11]/[0.03]",children:[e.jsx(gs,{className:"w-[180px]",children:"When"}),e.jsx(gs,{className:"w-[200px]",children:"Event"}),e.jsx(gs,{children:"User"}),e.jsx(gs,{className:"w-[120px]",children:"Browser"}),e.jsx(gs,{className:"w-[140px]",children:"IP"}),e.jsx(gs,{className:"w-[150px] text-right",children:"Action"})]})}),e.jsx(dh,{children:r.map(ae=>{const qe=wne(ae.event_type),bt=!!ae.ip,ht=!!ae.ip&&we.has(ae.ip);return e.jsxs(fi,{className:"hover:bg-[#FAF7F2]/60",children:[e.jsx(Xt,{className:"font-mono text-xs text-[#3B0A11]/80 whitespace-nowrap",children:Vi(ae.created_at)}),e.jsx(Xt,{children:e.jsxs(wn,{variant:"outline",className:`inline-flex items-center gap-1.5 ${qe.badgeClass} font-medium`,children:[qe.icon,qe.label]})}),e.jsxs(Xt,{className:"text-sm",children:[ae.email?e.jsx("span",{className:"text-[#3B0A11]",children:ae.email}):e.jsx("span",{className:"text-[#3B0A11]/40 italic",children:"unknown"}),ae.user_id&&e.jsxs("div",{className:"text-[10px] font-mono text-[#3B0A11]/40",children:[ae.user_id.slice(0,8),"â¦"]})]}),e.jsx(Xt,{className:"text-xs text-[#3B0A11]/70",children:tj(ae.user_agent)}),e.jsxs(Xt,{className:"text-xs font-mono text-[#3B0A11]/60",children:[ae.ip||"â",ht&&e.jsx("div",{className:"mt-0.5",children:e.jsx(wn,{variant:"outline",className:"bg-rose-50 text-rose-900 border-rose-300 text-[10px]",children:"banned"})})]}),e.jsx(Xt,{className:"text-right",children:bt?e.jsxs(gt,{size:"sm",variant:"outline",disabled:ht,onClick:()=>{E(""),_({ip:ae.ip,email:ae.email,eventId:ae.id})},className:"border-rose-300 text-rose-700 hover:bg-rose-50 hover:text-rose-900 disabled:opacity-50 disabled:cursor-not-allowed disabled:hover:bg-transparent",title:ht?`IP ${ae.ip} is already on the active ban list`:`Ban ${ae.ip} from signing in`,children:[e.jsx(zn,{className:"h-3.5 w-3.5 mr-1.5"}),ht?"Banned":"Ban this IP"]}):e.jsx("span",{className:"text-[10px] text-[#3B0A11]/30 italic",children:"no IP"})})]},ae.id)})})]})})})]})}),e.jsx(mh,{value:"active",className:"mt-4",children:e.jsxs(Gn,{className:"border-[#D4AF37]/40 bg-white shadow-sm",children:[e.jsx(Su,{className:"pb-3",children:e.jsxs(Cu,{className:"text-base font-semibold text-[#3B0A11] flex items-center justify-between",children:[e.jsx("span",{children:o?"Loading active sessionsâ¦":`${ye.length.toLocaleStr
1270ing()} open session${ye.length===1?"":"s"}`}),e.jsxs("span",{className:"text-xs font-normal text-[#3B0A11]/60",children:["Derived from the most recent ",sl," events"]})]})}),e.jsx(Au,{className:"p-0",children:c?e.jsxs("div",{className:"p-6 text-sm text-rose-700 bg-rose-50 border-y border-rose-200",children:["Couldn't load session events: ",c]}):ye.length===0&&!o?e.jsx("div",{className:"p-10 text-center text-[#3B0A11]/60 text-sm",children:"No users currently appear to be signed in."}):e.jsx("div",{className:"overflow-x-auto",children:e.jsxs(lh,{children:[e.jsx(ch,{children:e.jsxs(fi,{className:"bg-[#3B0A11]/[0.03]",children:[e.jsx(gs,{children:"User"}),e.jsx(gs,{className:"w-[180px]",children:"Signed in"}),e.jsx(gs,{className:"w-[120px]",children:"Browser"}),e.jsx(gs,{className:"w-[120px]",children:"IP"}),e.jsx(gs,{className:"w-[140px] text-right",children:"Action"})]})}),e.jsx(dh,{children:ye.map(ae=>{const qe=ae.user_id&&t&&ae.user_id===t.id||ae.email&&(t==null?void 0:t.email)&&ae.email.toLowerCase()===t.email.toLowerCase();return e.jsxs(fi,{className:"hover:bg-[#FAF7F2]/60",children:[e.jsxs(Xt,{className:"text-sm",children:[ae.email?e.jsx("span",{className:"text-[#3B0A11] font-medium",children:ae.email}):e.jsx("span",{className:"text-[#3B0A11]/40 italic",children:"unknown"}),ae.user_id&&e.jsxs("div",{className:"text-[10px] font-mono text-[#3B0A11]/40",children:[ae.user_id.slice(0,8),"â¦"]}),qe&&e.jsx(wn,{variant:"outline",className:"mt-1 bg-amber-50 text-amber-900 border-amber-300 text-[10px]",children:"that's you"})]}),e.jsxs(Xt,{className:"text-xs text-[#3B0A11]/80",children:[e.jsx("div",{className:"font-mono",children:Vi(ae.signed_in_at)}),e.jsx("div",{className:"text-[10px] text-[#3B0A11]/50",children:sj(ae.signed_in_at)})]}),e.jsx(Xt,{className:"text-xs text-[#3B0A11]/70",children:tj(ae.user_agent)}),e.jsx(Xt,{className:"text-xs font-mono text-[#3B0A11]/60",children:ae.ip||"â"}),e.jsx(Xt,{className:"text-right",children:e.jsxs(gt,{size:"sm",variant:"outline",onClick:()=>f(ae),className:"border-rose-300 text-rose-700 hover:bg-rose-50 hover:text-rose-900",title:qe?"You can revoke your own session â you will be signed out within 60 seconds":`Force sign-out ${ae.email||"this user"} across every device`,children:[e.jsx($b,{className:"h-3.5 w-3.5 mr-1.5"}),"Revoke"]})})]},ae.key)})})]})})})]})}),e.jsx(mh,{value:"bans",className:"mt-4",children:e.jsxs(Gn,{className:"border-[#D4AF37]/40 bg-white shadow-sm",children:[e.jsxs(Su,{className:"pb-3 flex flex-row items-center justify-between",children:[e.jsxs(Cu,{className:"text-base font-semibold text-[#3B0A11]",children:[B?"Loading IP bansâ¦":`${He.toLocaleString()} active ban${He===1?"":"s"}`,L.length>He&&e.jsxs("span",{className:"ml-2 text-xs font-normal text-[#3B0A11]/60",children:["(",(L.length-He).toLocaleString()," historic)"]})]}),e.jsxs(gt,{variant:"outline",size:"sm",onClick:ue,className:"border-[#D4AF37] text-[#3B0A11] hover:bg-[#D4AF37]/10",children:[e.jsx(Be,{className:`h-3.5 w-3.5 mr-2 ${B?"animate-spin":""}`}),"Refresh"]})]}),e.jsx(Au,{className:"p-0",children:z?e.jsxs("div",{className:"p-6 text-sm text-rose-700 bg-rose-50 border-y border-rose-200",children:["Couldn't load IP bans: ",z]}):L.length===0&&!B?e.jsx("div",{className:"p-10 text-center text-[#3B0A11]/60 text-sm",children:'No IP bans on record. Use the "Ban this IP" action in the Event Log to add one.'}):e.jsx("div",{className:"overflow-x-auto",children:e.jsxs(lh,{children:[e.jsx(ch,{children:e.jsxs(fi,{className:"bg-[#3B0A11]/[0.03]",children:[e.jsx(gs,{className:"w-[150px]",children:"IP"}),e.jsx(gs,{className:"w-[100px]",children:"Status"}),e.jsx(gs,{children:"Reason"}),e.jsx(gs,{className:"w-[200px]",children:"Banned by"}),e.jsx(gs,{className:"w-[180px]",children:"When"}),e.jsx(gs,{className:"w-[120px] text-right",children:"Action"})]})}),e.jsx(dh,{children:L.map(ae=>e.jsxs(fi,{className:"hover:bg-[#FAF7F2]/60",children:[e.jsx(Xt,{className:"font-mono text-xs text-[#3B0A11]",children:ae.ip}),e.jsx(Xt,{children:ae.active?e.jsxs("div",{className:"space-y-0.5",children:[e.jsxs(wn,{variant:"outline",className:"bg-rose-100 text-rose-900 border-rose-300 inline-flex items-center gap-1 font-medium",children:[e.jsx(zn,{className:"h-3 w-3"}),"active"]}),ae.expires_at?e.jsxs("div",{className:"text-[10px] font-medium text-amber-700 inline-flex items-center gap-1",title:`Expires at ${Vi(ae.expires_at)}`,children:[e.jsx(dt,{className:"h-2.5 w-2.5"}),"expires in ",vne(ae.expires_at)]}):e.jsx("div",{className:"text-[10px] text-slate-500 italic",children:"never expires"})]}):e.jsxs(wn,{variant:"outline",className:"bg-slate-100 text-slate-700 border-slate-300 inline-flex items-center gap-1",children:[e.jsx(Ie,{className:"h-3 w-3"}),"lifted"]})}),e.jsx(Xt,{className:"text-xs text-[#3B0A11]/80 max-w-md",children:ae.reason?e.jsx("span",{className:"whitespace-pre-wrap break-words",children:ae.reason}):e.jsx("span",{className:"text-[#3B0A11]/40 italic",children:"no reason given"})}),e.jsxs(Xt,{className:"text-xs text-[#3B0A11]/80",children:[ae.created_by_email||e.jsx("span",{className:"text-[#3B0A11]/40 italic",children:"unknown"}),!ae.active&&ae.deactivated_by_email&&e.jsxs("div",{className:"text-[10px] text-[#3B0A11]/50 mt-0.5",children:["unbanned by ",ae.deactivated_by_email]})]}),e.jsxs(Xt,{className:"text-xs text-[#3B0A11]/80",children:[e.jsx("div",{className:"font-mono",children:Vi(ae.created_at)}),e.jsx("div",{className:"text-[10px] text-[#3B0A11]/50",children:sj(ae.created_at)}),!ae.active&&ae.deactivated_at&&e.jsxs("div",{className:"text-[10px] text-emerald-700 mt-0.5",children:["lifted ",sj(ae.deactivated_at)]})]}),e.jsx(Xt,{className:"text-right",children:ae.active?e.jsxs(gt,{size:"sm",variant:"outline",onClick:()=>T(ae),className:"border-emerald-300 text-emerald-700 hover:bg-emerald-50 hover:text-emerald-900",title:`Lift the ban on ${ae.ip}`,children:[e.jsx(Ie,{className:"h-3.5 w-3.5 mr-1.5"}),"Unban"]}):e.jsx("span",{className:"text-[10px] text-[#3B0A11]/30 italic",children:"â"})})]},ae.id))})]})})})]})}),e.jsx(mh,{value:"failed",className:"mt-4",children:e.jsxs(Gn,{className:"border-[#D4AF37]/40 bg-white shadow-sm",children:[e.jsxs(Su,{className:"pb-3 flex flex-row items-center justify-between",children:[e.jsxs(Cu,{className:"text-base font-semibold text-[#3B0A11]",children:[J?"Loading failed sign-insâ¦":`${se.length.toLocaleStr
1270ing()} failed attempt${se.length===1?"":"s"}`,se.length===sl&&e.jsxs("span",{className:"ml-2 text-xs font-normal text-[#3B0A11]/60",children:["(showing most recent ",sl,")"]}),Lt.length>0&&Lt.length!==se.length&&e.jsxs("span",{className:"ml-2 text-xs font-normal text-[#3B0A11]/60",children:["· ",Lt.length," cluster",Lt.length===1?"":"s"]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs(gt,{onClick:ge,disabled:J||se.length===0,size:"sm",className:"bg-gradient-to-br from-[#3B0A11] to-[#5C1320] hover:from-[#5C1320] hover:to-[#3B0A11] text-[#D4AF37] border border-[#D4AF37]/40 shadow-sm disabled:opacity-50 disabled:cursor-not-allowed",title:J?"Loading â wait for the fetch to finish before exporting":se.length===0?"No failed sign-in attempts to export":`Download ${se.length} failed sign-in${se.length===1?"":"s"} as CSV`,children:[e.jsx(us,{className:"h-3.5 w-3.5 mr-2"}),"Download CSV",se.length>0&&e.jsxs("span",{className:"ml-2 text-[10px] font-normal opacity-80",children:["(",se.length.toLocaleString(),")"]})]}),e.jsxs(gt,{variant:"outline",size:"sm",onClick:je,className:"border-[#D4AF37] text-[#3B0A11] hover:bg-[#D4AF37]/10",children:[e.jsx(Be,{className:`h-3.5 w-3.5 mr-2 ${J?"animate-spin":""}`}),"Refresh"]})]})]}),e.jsx(Au,{className:"p-0",children:pe?e.jsxs("div",{className:"p-6 text-sm text-rose-700 bg-rose-50 border-y border-rose-200",children:["Couldn't load failed sign-ins: ",pe]}):se.length===0&&!J?e.jsx("div",{className:"p-10 text-center text-[#3B0A11]/60 text-sm",children:"No failed sign-in attempts on record. That's a good thing."}):e.jsx("div",{className:"overflow-x-auto",children:e.jsxs(lh,{children:[e.jsx(ch,{children:e.jsxs(fi,{className:"bg-[#3B0A11]/[0.03]",children:[e.jsx(gs,{className:"w-[180px]",children:"When"}),e.jsx(gs,{className:"w-[140px]",children:"IP"}),e.jsx(gs,{children:"Email attempted"}),e.jsx(gs,{className:"w-[140px]",children:"User agent"}),e.jsx(gs,{className:"w-[140px] text-right",children:"Action"})]})}),e.jsx(dh,{children:Lt.map(ae=>{const qe=ae.rows.length>1,bt=!!ke[ae.key],ht=!!ae.ip&&we.has(ae.ip),Ht=(wt,_e={})=>{const Se=!!wt.ip&&we.has(wt.ip);return e.jsxs(fi,{className:`hover:bg-[#FAF7F2]/60 ${_e.indent?"bg-[#FAF7F2]/30":""}`,children:[e.jsx(Xt,{className:`font-mono text-xs text-[#3B0A11]/80 whitespace-nowrap ${_e.indent?"pl-8":""}`,children:Vi(wt.attempted_at)}),e.jsxs(Xt,{className:"font-mono text-xs text-[#3B0A11]",children:[wt.ip||e.jsx("span",{className:"text-[#3B0A11]/40 italic",children:"unknown"}),Se&&e.jsx("div",{className:"mt-0.5",children:e.jsx(wn,{variant:"outline",className:"bg-rose-50 text-rose-900 border-rose-300 text-[10px]",children:"banned"})})]}),e.jsx(Xt,{className:"text-sm text-[#3B0A11]",children:wt.email_attempted||e.jsx("span",{className:"text-[#3B0A11]/40 italic",children:"empty"})}),e.jsx(Xt,{className:"text-xs text-[#3B0A11]/70 truncate max-w-[140px]",title:wt.user_agent||void 0,children:tj(wt.user_agent)}),e.jsx(Xt,{className:"text-right",children:wt.ip?e.jsxs(gt,{size:"sm",variant:"outline",disabled:Se,onClick:()=>{E(`Manual ban from Failed Sign-ins tab â attempt for ${wt.email_attempted||"unknown email"} at ${Vi(wt.attempted_at)}`),_({ip:wt.ip,email:wt.email_attempted,eventId:wt.id})},className:"border-rose-300 text-rose-700 hover:bg-rose-50 hover:text-rose-900 disabled:opacity-50 disabled:cursor-not-allowed disabled:hover:bg-transparent",title:Se?`IP ${wt.ip} is already on the active ban list`:`Ban ${wt.ip} from signing in`,children:[e.jsx(zn,{className:"h-3.5 w-3.5 mr-1.5"}),Se?"Banned":"Ban this IP"]}):e.jsx("span",{className:"text-[10px] text-[#3B0A11]/30 italic",children:"no IP"})})]},wt.id)};return qe?e.jsxs(d.Fragment,{children:[e.jsxs(fi,{className:"bg-rose-50/50 hover:bg-rose-50 cursor-pointer border-l-4 border-l-rose-400",onClick:()=>Oe(wt=>({...wt,[ae.key]:!wt[ae.key]})),children:[e.jsx(Xt,{className:"font-mono text-xs text-[#3B0A11]/80 whitespace-nowrap",children:e.jsxs("div",{className:"flex items-center gap-1.5",children:[bt?e.jsx(Gt,{className:"h-3.5 w-3.5 text-rose-700"}):e.jsx(Nr,{className:"h-3.5 w-3.5 text-rose-700"}),e.jsxs("div",{children:[e.jsx("div",{children:Vi(ae.newestAt)}),e.jsxs("div",{className:"text-[10px] text-[#3B0A11]/50 ml-5 -mt-0.5",children:["â³ oldest ",Vi(ae.oldestAt)]})]})]})}),e.jsxs(Xt,{className:"font-mono text-xs text-[#3B0A11] font-semibold",children:[ae.ip||e.jsx("span",{className:"text-[#3B0A11]/40 italic",children:"unknown"}),ht&&e.jsx("div",{className:"mt-0.5",children:e.jsx(wn,{variant:"outline",className:"bg-rose-100 text-rose-900 border-rose-300 text-[10px] font-medium",children:"banned"})})]}),e.jsxs(Xt,{colSpan:2,className:"text-sm",children:[e.jsxs("div",{className:"flex items-center gap-2 text-rose-900 font-medium",children:[e.jsx(ve,{className:"h-3.5 w-3.5 text-rose-600 flex-shrink-0"}),e.jsxs("span",{children:[ae.rows.length," attempts in ",gE(ae.newestAt,ae.oldestAt),ae.ip?e.jsxs(e.Fragment,{children:[" from ",e.jsx("span",{className:"font-mono",children:ae.ip})]}):null]})]}),e.jsxs("div",{className:"text-[10px] text-[#3B0A11]/60 ml-5 mt-0.5",children:["Click to ",bt?"collapse":"expand"," individual attempts"]})]}),e.jsx(Xt,{className:"text-right",onClick:wt=>wt.stopPropagation(),children:ae.ip?e.jsxs(gt,{size:"sm",variant:"outline",disabled:ht,onClick:()=>{E(`Brute-force cluster: ${ae.rows.length} attempts in ${gE(ae.newestAt,ae.oldestAt)} from ${ae.ip}`),_({ip:ae.ip,email:ae.rows[0].email_attempted,eventId:ae.rows[0].id})},className:"border-rose-400 text-rose-800 bg-white hover:bg-rose-50 hover:text-rose-900 disabled:opacity-50 disabled:cursor-not-allowed disabled:hover:bg-white",title:ht?`IP ${ae.ip} is already on the active ban list`:`Ban ${ae.ip} from signing in`,children:[e.jsx(zn,{className:"h-3.5 w-3.5 mr-1.5"}),ht?"Banned":"Ban this IP"]}):e.jsx("span",{className:"text-[10px] text-[#3B0A11]/30 italic",children:"no IP"})})]}),bt&&ae.rows.map(wt=>Ht(wt,{indent:!0}))]},ae.key):Ht(ae.rows[0])})})]})})})]})})]}),e.jsxs("p",{className:"mt-4 text-xs text-[#3B0A11]/50 text-center",children:["Auto-refreshes every 20 seconds · Active sessions derived from the most recent ",sl," events"]})]}),e.jsx(Xv,{open:b!==null,onOpenChange:ae=>!ae&&!j&&f(null),children:e.jsxs(F0,{children:[e.jsxs(T0,{children:[e.jsxs(D0,{className:"flex items-center gap-2 text-[#3B0A11]",children:[e.jsx(KP,{className:"h-5 w-5 text-rose-600"}),"Revoke all sessions?"]}),e.jsxs(R0,{className:"space-y-2",children:[e.jsxs("span",{className:"block",children:["This will force-sign-out"," ",e.jsx("strong",{className:"text-[#3B0A11]",children:(b==null?void 0:b.email)||"this user"})," ","on every device they're currently signed in on."]}),e.jsxs("span",{className:"block text-xs text-[#3B0A11]/60",children:[`Every browser tab signed in as this user will be terminated within 60 seconds (the revocation poll interval). They'll see a "Your session was ended by an administrator" toast and be redirected to the admin login page. A `,e.jsx("code",{children:"FORCED_REVOCATION"})," event will be written to the audit log. The user can sign in again immediately afterwards."]})]})]}),e.jsxs(P0,{children:[e.jsx($0,{disabled:j,children:"Cancel"}),e.jsx(I0,{onClick:ae=>{ae.preventDefault(),Ne()},disabled:j,className:"bg-rose-600 hover:bg-rose-700 focus:ring-rose-600",children:j?"Revokingâ¦":"Yes, revoke sessions"})]})]})}),e.jsx(Xv,{open:w!==null,onOpenChange:ae=>{!ae&&!I&&(_(null),E(""),F("24h"))},children:e.jsxs(F0,{children:[e.jsxs(T0,{children:[e.jsxs(D0,{className:"flex items-center gap-2 text-[#3B0A11]",children:[e.jsx(zn,{className:"h-5 w-5 text-rose-600"}),"Ban this IP address?"]}),e.jsx(R0,{asChild:!0,children:e.jsxs("div",{className:"space-y-3",children:[e.jsxs("p",{className:"text-sm text-[#3B0A11]/80",children:["Future sign-in attempts from this address will be rejected by the"," ",e.jsx("code",{className:"text-xs",children:"log-session-event"})," edge function with HTTP 403. Existing sessions from this IP are ",e.jsx("strong",{children:"not"})," automatically terminated â use the Active Users tab to revoke specific sessions if needed."]}),e.jsxs("div",{className:"rounded-md border border-[#D4AF37]/40 bg-[#FAF7F2] p-3 text-sm",children:[e.jsx("div",{className:"text-[11px] uppercase tracking-wide text-[#3B0A11]/50 mb-1",children:"IP address"}),e.jsx("div",{className:"font-mono text-[#3B0A11]",children:(w==null?void 0:w.ip)||"â"}),(w==null?void 0:w.email)&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"text-[11px] uppercase tracking-wide text-[#3B0A11]/50 mt-2 mb-1",children:"Last seen on event for"}),e.jsx("div",{className:"text-[#3B0A11]",children:w.email})]})]}),e.jsxs("div",{children:[e.jsx("label",{htmlFor:"ban-duration",className:"block text-xs font-medium text-[#3B0A11]/70 mb-1",children:"Ban duration"}),e.jsxs(Tx,{value:P,onValueChange:ae=>F(ae),disabled:I,children:[e.jsx(zm,{id:"ban-duration",className:"bg-white border-[#D4AF37]/40",children:e.jsx(Px,{})}),e.jsx(Lm,{children:ej.map(ae=>e.jsx(ec,{value:ae.value,children:ae.label},ae.value))})]}),e.jsx("p",{className:"mt-1 text-[10px] text-[#3B0A11]/50",children:(()=>{const ae=ej.find(bt=>bt.value===P);return!ae||ae.ms==null?"Permanent â never expires. Lift manually from the IP Bans tab.":`Expires ${new Date(Date.now()+ae.ms).toLocaleStr
1270ing()} (auto-lifted by the nightly sweeper)`})()})]}),e.jsxs("div",{children:[e.jsx("label",{htmlFor:"ban-reason",className:"block text-xs font-medium text-[#3B0A11]/70 mb-1",children:"Reason (optional)"}),e.jsx(B5,{id:"ban-reason",placeholder:"e.g. Brute-force attempts from 03:14 UTC, see Cloudflare alert #4421",value:C,onChange:ae=>E(ae.target.value),disabled:I,rows:3,className:"bg-white border-[#D4AF37]/40 text-sm"}),e.jsx("p",{className:"mt-1 text-[10px] text-[#3B0A11]/50",children:"Shown in the IP Bans tab and in the API response that rejects sign-in."})]})]})})]}),e.jsxs(P0,{children:[e.jsx($0,{disabled:I,children:"Cancel"}),e.jsx(I0,{onClick:ae=>{ae.preventDefault(),lt()},disabled:I,className:"bg-rose-600 hover:bg-rose-700 focus:ring-rose-600",children:I?"Banningâ¦":"Yes, ban this IP"})]})]})}),e.jsx(Xv,{open:R!==null,onOpenChange:ae=>!ae&&!U&&T(null),children:e.jsxs(F0,{children:[e.jsxs(T0,{children:[e.jsxs(D0,{className:"flex items-center gap-2 text-[#3B0A11]",children:[e.jsx(Ie,{className:"h-5 w-5 text-emerald-600"}),"Lift this IP ban?"]}),e.jsxs(R0,{className:"space-y-2",children:[e.jsxs("span",{className:"block text-sm text-[#3B0A11]/80",children:["Sign-in attempts from ",e.jsx("code",{className:"font-mono",children:R==null?void 0:R.ip})," ","will be allowed again starting immediately. The ban row is kept in the audit trail with ",e.jsx("code",{children:"active=false"})," and your email stamped as the lifter."]}),(R==null?void 0:R.reason)&&e.jsxs("span",{className:"block text-xs text-[#3B0A11]/60 italic",children:['Original reason: "',R.reason,'"']})]})]}),e.jsxs(P0,{children:[e.jsx($0,{disabled:U,children:"Cancel"}),e.jsx(I0,{onClick:ae=>{ae.preventDefault(),mt()},disabled:U,className:"bg-emerald-600 hover:bg-emerald-700 focus:ring-emerald-600",children:U?"Unbanningâ¦":"Yes, lift the ban"})]})]})})]}):null}function du({label:t,value:s,accent:n}){const a={slate:"border-slate-300 bg-slate-50 text-slate-900",emerald:"border-emerald-300 bg-emerald-50 text-emerald-900",amber:"border-amber-300 bg-amber-50 text-amber-900",rose:"border-rose-300 bg-rose-50 text-rose-900",blue:"border-blue-300 bg-blue-50 text-blue-900",purple:"border-purple-300 bg-purple-50 text-purple-900"};return e.jsxs("div",{className:`rounded-lg border px-4 py-3 shadow-sm ${a[n]}`,children:[e.jsx("div",{className:"text-[11px] uppercase tracking-wide opacity-70",children:t}),e.jsx("div",{className:"text-2xl font-bold tabular-nums",children:s.toLocaleString()})]})}function Ene(t){return{id:t.id,service:"GA4",verified_at:t.verified_at,verified_by:t.verified_by,all_live:!!t.all_live,any_demo_mode:!!t.any_demo_mode,passed:t.entities_verified??0,total:t.entities_total??0,total_rows_returned:t.total_rows_returned??0,duration_ms:t.duration_ms??0,step_advanced_from:t.step_advanced_from,step_advanced_to:t.step_advanced_to,user_agent:t.user_agent,notes:t.notes,per_item_results:Array.isArray(t.per_entity_results)?t.per_entity_results:[],per_item_label:"entities",raw:t}}function Fne(t){return{id:t.id,service:"GSC",verified_at:t.verified_at,verified_by:t.verified_by,all_live:!!t.all_live,any_demo_mode:!!t.any_demo_mode,passed:t.checks_passed??0,total:t.checks_total??0,total_rows_returned:t.total_rows_returned??0,duration_ms:t.duration_ms??0,step_advanced_from:t.step_advanced_from,step_advanced_to:t.step_advanced_to,user_agent:t.user_agent,notes:t.notes,per_item_results:Array.isArray(t.per_check_results)?t.per_check_results:[],per_item_label:"checks",raw:t}}function Dh(t){return!t||t<0?"â":t<1e3?`${t} ms`:t<6e4?`${(t/1e3).toFixed(2)} s`:`${(t/6e4).toFixed(1)} min`}function Rs(t){try{return new Date(t).toLocaleString(void 0,{year:"numeric",month:"short",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit"})}catch{return t}}function L8(t){if(t==null)return"";const s=String(t);return s.includes(",")||s.includes('"')||s.includes(` 1271`)?`"${s.replace(/"/g,'""')}"`:s}function oN(t){if(!t)return null;const s=new Date(t).getTime();if(isNaN(s))return null;const n=Date.now()-s;return Math.floor(n/(24*60*60*1e3))}function wa(t){if(!t)return"never";const s=new Date(t).getTime();if(isNaN(s))return"unknown";const n=Date.now()-s;if(n<0)return"just now";const a=Math.floor(n/6e4);if(a<1)return"just now";if(a<60)return`${a} ${a===1?"minute":"minutes"} ago`;const r=Math.floor(a/60);if(r<24)return`${r} ${r===1?"hour":"hours"} ago`;const i=Math.floor(r/24);if(i<30)return`${i} ${i===1?"day":"days"} ago`;const o=Math.floor(i/30);if(o<12)return`${o} ${o===1?"month":"months"} ago`;const l=Math.floor(i/365);return`${l} ${l===1?"year":"years"} ago`}function Tne(t,s){if(t===null||s===null)return"gray";const n=Math.max(t,s);
1271return n<7?"green":n<=14?"amber":"red"}function O8(t){if(t.cancelled_at)return"cancelled";if(t.recurrence_rule)return"recurring-template";const s=new Date(t.snoozed_until).getTime();return Number.isFinite(s)&&s>Date.now()?"active":"expired"}function Pne(t,s){if(!t||t.length===0)return null;const n=new Date(s).getTime();if(!Number.isFinite(n))return null;let a=null,r=-1/0;for(const i of t){const o=new Date(i.created_at).getTime(),l=new Date(i.snoozed_until).getTime();if(!(!Number.isFinite(o)||!Number.isFinite(l))&&!(o>n)&&!(l<=n)){if(i.cancelled_at){const c=new Date(i.cancelled_at).getTime();if(Number.isFinite(c)&&c<=n)continue}o>r&&(a=i,r=o)}}return a}const Dne="[PRE-FLIGHT STALE â ALERT SNOOZED]";function Rne(){const t=new Date,s=new Date(Date.UTC(t.getUTCFullYear(),t.getUTCMonth(),t.getUTCDate()+1,9,0,0,0)),n=30*6e4;return s.getTime()-t.getTime()<n&&s.setUTCDate(s.getUTCDate()+1),s.toISOString()}const Xy=[{id:"1h",label:"1 hour",description:"Quick suppression for a short maintenance window.",computeUntilIso:()=>new Date(Date.now()+60*6e4).toISOString()},{id:"tomorrow-morning",label:"Tomorrow morning",description:"Until 09:00 UTC tomorrow â covers overnight work and the early cron tick.",computeUntilIso:Rne},{id:"1w",label:"1 week",description:"Suppresses the next ~1 weekly cron tick.",computeUntilIso:()=>new Date(Date.now()+7*864e5).toISOString()},{id:"2w",label:"2 weeks",description:"Suppresses the next ~2 weekly cron ticks.",computeUntilIso:()=>new Date(Date.now()+14*864e5).toISOString()},{id:"1mo",label:"1 month",description:"Suppresses ~4 weekly cron ticks. Good for vacations.",computeUntilIso:()=>new Date(Date.now()+30*864e5).toISOString()}],tk="deployment-audit:snooze:last-reason";function Ine(){if(typeof window>"u")return"";try{const t=window.localStorage.getItem(tk);return typeof t!="string"?"":t.slice(0,200)}catch{return""}}function yE(t){if(typeof window>"u")return;const s=(t||"").trim();if(s)try{window.localStorage.setItem(tk,s.slice(0,200))}catch{}}function $ne(){if(!(typeof window>"u"))try{window.localStorage.removeItem(tk)}catch{}}function M8(t){if(t.preset_id==="custom-duration"){const n=t.custom_duration_ms;return typeof n!="number"||!Number.isFinite(n)||n<=0?null:new Date(Date.now()+n).toISOString()}const s=Xy.find(n=>n.id===t.preset_id);return s?s.computeUntilIso():null}function bE(t){if(t.preset_id==="custom-duration"){const n=t.custom_duration_ms??0;if(n<=0)return"invalid duration";const a=n/36e5;if(a<1){const i=Math.max(1,Math.round(n/6e4));return`${i} minute${i===1?"":"s"}`}if(a<24){const i=Math.round(a*10)/10;return`${i} hour${i===1?"":"s"}`}const r=Math.round(a/24*10)/10;return`${r} day${r===1?"":"s"}`}const s=Xy.find(n=>n.id===t.preset_id);return(s==null?void 0:s.label)??t.preset_id}const zne=[{name:"Maintenance window â 1 hour",preset_id:"1h",custom_duration_ms:null,reason:"Routine maintenance window â suppress staleness alerts while the work is in flight.",position:0},{name:"Holiday â 1 week",preset_id:"1w",custom_duration_ms:null,reason:"Holiday / off-call week. Resume alerts when we return.",position:1}],Lne="deployment-audit:snooze:template-sort-mode";function One(){if(typeof window>"u")return"manual";try{return window.localStorage.getItem(Lne)==="usage"?"usage":"manual"}catch{return"manual"}}function Mne(t,s){return s==="manual"?t:[...t].sort((n,a)=>{if(a.usage_count!==n.usage_count)return a.usage_count-n.usage_count;const r=n.last_applied_at?new Date(n.last_applied_at).getTime():-1/0,i=a.last_applied_at?new Date(a.last_applied_at).getTime():-1/0;return i!==r?i-r:n.position-a.position})}function Bne(t){if(!t.usage_count||t.usage_count<=0)return"never used";const s=`used ${t.usage_count}Ã`;return t.last_applied_at?`${s} · last ${wa(t.last_applied_at)}`:s}function Rh(t){try{const s=new Date(t);if(Number.isNaN(s.getTime()))return"";const n=s.toLocaleString("en-US",{month:"short",timeZone:"UTC"}),a=s.getUTCDate(),r=String(s.getUTCHours()).padStart(2,"0"),i=String(s.getUTCMinutes()).padStart(2,"0"),o=s.getTime()-Date.now();return`${n} ${a}, ${r}:${i} UTC · ${ph(o)}`}catch{return""}}function Une(t){if(!t)return"Recurring schedule";const s=t.match(/^\[Recurring:\s*([^\]]+)\]/);return s&&s[1]?s[1].trim():"Recurring schedule"}function qne(t){if(!t)return null;const s=t.replace(/^\[Recurring:\s*[^\]]+\]\s*/,"").trim();return s.length>0?s:null}
1271function Wne(){const[t,s]=d.useState(!0),[n,a]=d.useState(null),[r,i]=d.useState([]),[o,l]=d.useState(new Set),[c,u]=d.useState(null),[p,m]=d.useState(null),[x,h]=d.useState([]),[y,v]=d.useState(null),g=aR(),[N,b]=d.useState([]),[f,j]=d.useState(null),[S,w]=d.useState(!1),[_,C]=d.useState(!1),[E,P]=d.useState(null),[F,I]=d.useState(null),D=d.useRef(null),L=d.useRef(null),[V,B]=d.useState(null),A=d.useRef(null),[z,M]=d.useState(null),[R,T]=d.useState(null),[U,q]=d.useState(!1),[H,G]=d.useState(""),[W,X]=d.useState(null),[Q,K]=d.useState(null),se=new Date,Y=new Date(se.getTime()-90*24*60*60*1e3),[J,te]=d.useState(Y.toISOString().slice(0,10)),[pe,Fe]=d.useState(se.toISOString().slice(0,10)),[ke,Oe]=d.useState("all"),[ue,je]=d.useState("all"),[le,ye]=d.useState(""),we=async()=>{s(!0),a(null);try{const ne=new Date().toISOString(),[oe,ie,fe,Re,Me]=await Promise.all([O.from("ga4_deployment_audit").select("*").order("verified_at",{ascending:!1}).limit(500),O.from("gsc_deployment_audit").select("*").order("verified_at",{ascending:!1}).limit(500),O.from("stale_compliance_alert_log").select("id, sent_at, recipient, ga4_days_since, gsc_days_since, message_id").order("sent_at",{ascending:!1}).limit(1),O.from("stale_compliance_alert_snoozes").select("id, snoozed_until, reason, snoozed_by, created_at").is("cancelled_at",null).is("recurrence_rule",null).gt("snoozed_until",ne).order("created_at",{ascending:!1}).limit(1),O.from("stale_compliance_alert_snoozes").select("id, snoozed_until, reason, snoozed_by, created_at, cancelled_at, cancelled_by, recurrence_rule, parent_recurrence_id").order("created_at",{ascending:!1}).limit(100)]),Te=(oe.data||[]).map(Ene),Pt=(ie.data||[]).map(Fne),Yt=[...Te,...Pt].sort((Os,Gs)=>Os.verified_at<Gs.verified_at?1:-1);i(Yt),!fe.error&&Array.isArray(fe.data)&&fe.data.length>0?u(fe.data[0]):u(null),!Re.error&&Array.isArray(Re.data)&&Re.data.length>0?m(Re.data[0]):m(null),!Me.error&&Array.isArray(Me.data)?h(Me.data):h([]),oe.error&&ie.error?a(`Failed to load audit logs: ${oe.error.message} / ${ie.error.message}`):oe.error?a(`GA4 audit load warning: ${oe.error.message}`):ie.error&&a(`GSC audit load warning: ${ie.error.message}`)}catch(ne){a((ne==null?void 0:ne.message)||"Failed to load deployment audit logs")}finally{s(!1)}},He=async ne=>{const oe=ne??(p==null?void 0:p.id);if(!oe)return{ok:!1,errorMessage:"No snooze to cancel."};if(y)return{ok:!1,errorMessage:"Another snooze operation is already in flight."};v("cancel");try{const{error:ie}=await O.from("stale_compliance_alert_snoozes").update({cancelled_at:new Date().toISOString(),cancelled_by:"operator-ui"}).eq("id",oe).is("cancelled_at",null);if(ie)throw new Error(ie.message);return await we(),g.show({variant:"success",title:"Snooze cancelled",description:"Stale-compliance alerts are eligible to fire again on the next cron tick."}),{ok:!0,errorMessage:null}}catch(ie){const fe=(ie==null?void 0:ie.message)||"Failed to cancel snooze";return g.show({variant:"error",title:"Failed to cancel snooze",description:fe}),{ok:!1,errorMessage:fe}}finally{v(null)}},Lt=async ne=>{if(!y){v("snooze");try{const oe=new Date(ne.untilIso).getTime();if(!Number.isFinite(oe)||oe<=Date.now())throw new Error("Snooze end time must be in the future.");const ie="operator-ui",{data:fe,error:Re}=await O.from("stale_compliance_alert_snoozes").insert({snoozed_until:new Date(oe).toISOString(),reason:ne.reason.trim()||null,snoozed_by:ie}).select("id").single();if(Re)throw new Error(Re.message);const Me=(fe==null?void 0:fe.id)??null;let Te=null;if(Me)try{const{data:Yt,error:Os}=await O.functions.invoke("send-snooze-confirmation",{body:{snoozeId:Me}});Os?(console.warn("[snooze] Confirmation email failed to send:",Os),Te=`Confirmation email failed to send: ${Os.message||"unknown error"}. Check send-snooze-confirmation logs.`):Yt&&typeof Yt=="object"&&Yt.success===!1&&(console.warn("[snooze] Confirmation email returned non-success payload:",Yt),Te=`Confirmation email returned an error: ${Yt.error||"unknown"}.`)}catch(Yt){console.warn("[snooze] Confirmation email invocation threw:",Yt),Te=`Confirmation email could not be invoked: ${(Yt==null?void 0:Yt.message)||"unknown error"}.`}await we();const Pt=wa(ne.untilIso).replace("ago","from now").replace("just now","
1271shortly");g.show({variant:"success",title:`Alert snoozed for ${ne.presetLabel}`,description:`Suppression ends ${Pt} (${Rs(ne.untilIso)} UTC).`,actions:Me?[{label:"Undo",variant:"primary",onClick:async()=>{const{ok:Yt,errorMessage:Os}=await He(Me);if(!Yt)throw new Error(Os||"Undo failed")}}]:void 0}),Te&&g.show({variant:"warning",title:"Snooze created â confirmation email failed",description:Te})}catch(oe){g.show({variant:"error",title:"Failed to create snooze",description:(oe==null?void 0:oe.message)||"An unknown error occurred while creating the snooze."})}finally{v(null)}}},ut=async ne=>{if(!p||y)return!1;v("extend");try{let oe;if(typeof ne.extendMs=="number"&&Number.isFinite(ne.extendMs)){const Gs=new Date(p.snoozed_until).getTime();oe=(Number.isFinite(Gs)&&Gs>Date.now()?Gs:Date.now())+ne.extendMs}else if(typeof ne.absoluteIso=="string")oe=new Date(ne.absoluteIso).getTime();else throw new Error("Extend handler requires either extendMs or absoluteIso.");if(!Number.isFinite(oe))throw new Error("Computed extension end time is invalid.");if(oe<=Date.now())throw new Error("Extension end time must be in the future.");const ie=new Date(p.snoozed_until).getTime();if(Number.isFinite(ie)&&oe<=ie)throw new Error("Extension must end LATER than the current snooze. Use Cancel to end the snooze early.");const fe=new Date(oe).toISOString(),Re=new Date().toISOString(),Me=(p.reason||"").replace(/\s*\[extended by [^\]]+\]\s*$/,""),Te=`[extended by operator-ui to ${fe} at ${Re}]`,Pt=(Me?`${Me} ${Te}`:Te).slice(0,500),{error:Yt}=await O.from("stale_compliance_alert_snoozes").update({snoozed_until:fe,reason:Pt}).eq("id",p.id).is("cancelled_at",null);if(Yt)throw new Error(Yt.message);await we();
1271const Os=wa(fe).replace("ago","from now").replace("just now","shortly");return g.show({variant:"success",title:`Snooze extended (${ne.presetLabel})`,description:`New expiry: ${Os} (${Rs(fe)} UTC).`}),!0}catch(oe){const ie=(oe==null?void 0:oe.message)||"Failed to extend snooze";return g.show({variant:"error",title:"Failed to extend snooze",description:ie}),!1}finally{v(null)}},ge=async ne=>{if(!y){v("snooze");try{if(!ne.recurrenceRule||ne.recurrenceRule.trim().length<10)throw new Error("Recurrence rule is empty or malformed.");const oe=new Date().toISOString(),ie=`[Recurring: ${ne.humanLabel}]`,fe=ne.reason.trim()?`${ie} ${ne.reason.trim()}`:ie,{error:Re}=await O.from("stale_compliance_alert_snoozes").insert({snoozed_until:oe,reason:fe.slice(0,500),snoozed_by:"operator-ui",recurrence_rule:ne.recurrenceRule});if(Re)throw new Error(Re.message);await we(),g.show({variant:"success",title:"Recurring schedule created",description:`"${ne.humanLabel}" â the activator cron will spawn child snoozes per the rule, starting on the next nightly tick (07:15 UTC).`})}catch(oe){g.show({variant:"error",title:"Failed to create recurring snooze",description:(oe==null?void 0:oe.message)||"An unknown error occurred while creating the recurring schedule."})}finally{v(null)}}},Ne=async()=>{j(null);try{const{data:ne,error:oe}=await O.from("stale_compliance_alert_snooze_templates").select("id, name, preset_id, custom_duration_ms, reason, position, created_at, updated_at, created_by, usage_count, last_applied_at").order("position",{ascending:!0}).order("created_at",{ascending:!0});if(oe)return j(`Could not load templates: ${oe.message}`),b([]),[];const ie=ne||[];return b(ie),ie}catch(ne){return j((ne==null?void 0:ne.message)||"Failed to load templates"),b([]),[]}},lt=async()=>{try{const{count:ne,error:oe}=await O.from("stale_compliance_alert_snooze_templates").select("id",{count:"exact",head:!0});if(oe||(ne??0)>0)return;const ie=zne.map(Re=>({name:Re.name,preset_id:Re.preset_id,custom_duration_ms:Re.custom_duration_ms,reason:Re.reason,position:Re.position,created_by:"operator-ui-seed"})),{error:fe}=await O.from("stale_compliance_alert_snooze_templates").upsert(ie,{onConflict:"name",ignoreDuplicates:!0});fe&&console.warn("[snooze-template-seed] Failed to seed defaults:",fe),await Ne()}catch(ne){console.warn("[snooze-template-seed] Unexpected error:",ne)}},mt=async ne=>{if(S)return!1;w(!0),j(null);try{const oe=(ne.name||"").trim();if(!oe)throw new Error("Template name is required.");if(oe.length>80)throw new Error("Template name is too long (max 80 chars).");if(ne.preset_id==="custom-duration"&&(typeof ne.custom_duration_ms!="number"||ne.custom_duration_ms<=0))throw new Error("Custom-duration templates require a positive duration.");const ie=N.length===0?0:Math.max(...N.map(Re=>Re.position))+1,{error:fe}=await O.from("stale_compliance_alert_snooze_templates").insert({name:oe,preset_id:ne.preset_id,custom_duration_ms:ne.preset_id==="custom-duration"?ne.custom_duration_ms:null,reason:ne.reason.trim()||null,position:ie,created_by:"operator-ui"});if(fe)throw/duplicate key/i.test(fe.message)||fe.code==="23505"?new Error(`A template named "${oe}" already exists. Pick a different name.`):new Error(fe.message);return await Ne(),!0}catch(oe){return j((oe==null?void 0:oe.message)||"Failed to save template"),!1}finally{w(!1)}},ae=async(ne,oe)=>{if(S)return!1;w(!0),j(null);try{const ie=(oe||"").trim();if(!ie)throw new Error("Template name is required.");if(ie.length>80)throw new Error("Template name is too long (max 80 chars).");const{error:fe}=await O.from("stale_compliance_alert_snooze_templates").update({name:ie}).eq("id",ne);if(fe)throw/duplicate key/i.test(fe.message)||fe.code==="23505"?new Error(`A template named "${ie}" already exists.`):new Error(fe.message);return await Ne(),!0}catch(ie){return j((ie==null?void 0:ie.message)||"Failed to rename template"),!1}finally{w(!1)}},qe=async ne=>{if(S)return!1;w(!0),j(null);try{const{error:oe}=await O.from("stale_compliance_alert_snooze_templates").delete().eq("id",ne);if(oe)throw new Error(oe.message);return await Ne(),!0}catch(oe){return j((oe==null?void 0:oe.message)||"Failed to delete template"),!1}finally{w(!1)}},bt=async(ne,oe)=>{if(S)return!1;w(!0),j(null);try{const ie=N.findIndex(Gs=>Gs.id===ne);if(ie===-1)throw new Error("Template not found in local state.");const fe=oe==="up"?ie-1:ie+1;
1271if(fe<0||fe>=N.length)return!0;const Re=N[ie],Me=N[fe],Te=-1-Math.abs(Re.position),Pt=await O.from("stale_compliance_alert_snooze_templates").update({position:Te}).eq("id",Re.id);if(Pt.error)throw new Error(Pt.error.message);const Yt=await O.from("stale_compliance_alert_snooze_templates").update({position:Re.position}).eq("id",Me.id);if(Yt.error)throw new Error(Yt.error.message);const Os=await O.from("stale_compliance_alert_snooze_templates").update({position:Me.position}).eq("id",Re.id);if(Os.error)throw new Error(Os.error.message);return await Ne(),!0}catch(ie){return j((ie==null?void 0:ie.message)||"Failed to reorder template"),!1}finally{w(!1)}},ht=async ne=>{if(S)return!1;if(!Array.isArray(ne)||ne.length===0)return!0;w(!0),j(null);try{const{error:oe}=await O.from("stale_compliance_alert_snooze_templates").delete().in("id",ne);if(oe)throw new Error(oe.message);return await Ne(),!0}catch(oe){return j((oe==null?void 0:oe.message)||"Failed to prune unused templates"),!1}finally{w(!1)}},Ht=async ne=>{if(S)return!1;if(!Array.isArray(ne)||ne.length===0)return!0;w(!0),j(null);try{const oe=ne.map(fe=>({id:fe.id,name:fe.name,preset_id:fe.preset_id,custom_duration_ms:fe.custom_duration_ms??null,reason:fe.reason??null,position:fe.position,created_at:fe.created_at,created_by:fe.created_by??"operator-ui-undo"})),{error:ie}=await O.from("stale_compliance_alert_snooze_templates").insert(oe);if(ie)throw/duplicate key/i.test(ie.message)||ie.code==="23505"?new Error(`Could not restore â a template with one of these names already exists. ${ie.message}`):new Error(ie.message);return await Ne(),!0}catch(oe){return j((oe==null?void 0:oe.message)||"Failed to restore pruned templates"),!1}finally{w(!1)}},wt=async ne=>{const oe=M8(ne);if(!oe){g.show({variant:"error",title:"Could not apply template",description:`Template "${ne.name}" is malformed (unknown preset or invalid duration). Edit the chip in the manage drawer to fix the preset_id / custom_duration_ms.`});return}await Lt({untilIso:oe,reason:ne.reason||"",presetLabel:`template:${ne.name}`});const ie=(ne.usage_count||0)+1,fe=new Date().toISOString();try{const{error:Re}=await O.from("stale_compliance_alert_snooze_templates").update({usage_count:ie,last_applied_at:fe}).eq("id",ne.id);Re?console.warn("[snooze-template] Usage counter update failed:",Re):b(Me=>Me.map(Te=>Te.id===ne.id?{...Te,usage_count:ie,last_applied_at:fe}:Te))}catch(Re){console.warn("[snooze-template] Usage counter update threw:",Re)}};d.useEffect(()=>{(async()=>(await Ne()).length===0&&await lt())()},[]);const _e=async ne=>{T({status:"loading",templateId:ne,template:null,children:[],deletedChildrenCount:0,errorMessage:null});try{const[oe,ie]=await Promise.all([O.from("stale_compliance_alert_snoozes").select("id, snoozed_until, reason, snoozed_by, created_at, cancelled_at, cancelled_by, recurrence_rule, parent_recurrence_id").eq("id",ne).maybeSingle(),O.from("stale_compliance_alert_snoozes").select("id, snoozed_until, reason, snoozed_by, created_at, cancelled_at, cancelled_by, recurrence_rule, parent_recurrence_id").eq("parent_recurrence_id",ne).order("created_at",{ascending:!1})]);if(oe.error)throw new Error(`Failed to load schedule: ${oe.error.message}`);if(!oe.data)throw new Error("Recurring schedule not found (it may have been deleted).");if(ie.error)throw new Error(`Failed to load activations: ${ie.error.message}`);T({status:"ready",templateId:ne,template:oe.data,children:ie.data||[],deletedChildrenCount:0,errorMessage:null})}catch(oe){T(ie=>ie&&{...ie,status:"error",errorMessage:(oe==null?void 0:oe.message)||"Failed to load recurring schedule"})}},Se=async()=>{if(!(!R||!R.template)&&!(R.status==="pausing"||R.status==="deleting-children")){T(ne=>ne&&{...ne,status:"pausing",errorMessage:null});try{const{error:ne}=await O.from("stale_compliance_alert_snoozes").update({cancelled_at:new Date().toISOString(),cancelled_by:"operator-ui"}).eq("id",R.templateId).is("cancelled_at",null);if(ne)throw new Error(ne.message);const{data:oe}=await O.from("stale_compliance_alert_snoozes").select("id, snoozed_until, reason, snoozed_by, created_at, cancelled_at, cancelled_by, recurrence_rule, parent_recurrence_id").eq("id",R.templateId).maybeSingle();T(ie=>ie&&{...ie,status:"paused",template:oe||ie.template,errorMessage:null}),await we()}catch(ne){T(oe=>oe&&{...oe,status:"error",errorMessage:(ne==null?void 0:ne.message)||"Failed to pause schedule"})}}},We=async()=>
1271{if(!(!R||!R.template)&&!(R.status==="pausing"||R.status==="deleting-children")){T(ne=>ne&&{...ne,status:"deleting-children",errorMessage:null});try{const ne=new Date().toISOString(),{data:oe,error:ie}=await O.from("stale_compliance_alert_snoozes").update({cancelled_at:ne,cancelled_by:"operator-ui"}).eq("parent_recurrence_id",R.templateId).is("cancelled_at",null).gt("snoozed_until",ne).select("id");if(ie)throw new Error(ie.message);const fe=Array.isArray(oe)?oe.length:0,{data:Re}=await O.from("stale_compliance_alert_snoozes").select("id, snoozed_until, reason, snoozed_by, created_at, cancelled_at, cancelled_by, recurrence_rule, parent_recurrence_id").eq("parent_recurrence_id",R.templateId).order("created_at",{ascending:!1});T(Me=>Me&&{...Me,status:"children-deleted",children:Re||Me.children,deletedChildrenCount:fe,errorMessage:null}),await we()}catch(ne){T(oe=>oe&&{...oe,status:"error",errorMessage:(ne==null?void 0:ne.message)||"Failed to cancel future occurrences"})}}},Ut=()=>{T(null)},$t=ne=>{L.current!==null&&(window.clearTimeout(L.current),L.current=null),I(null);const oe=Pne(x,ne);if(!oe){I(`No matching snooze found for cron tick at ${Rs(ne)}. It may pre-date the 100-row snooze-history limit.`),C(!0),L.current=window.setTimeout(()=>{I(null),L.current=null},6e3);return}C(!0),P(oe.id),requestAnimationFrame(()=>{var ie;(ie=D.current)==null||ie.scrollIntoView({behavior:"smooth",block:"start"})}),L.current=window.setTimeout(()=>{P(null),L.current=null},4e3)};d.useEffect(()=>()=>{L.current!==null&&window.clearTimeout(L.current)},[]);const Nt=()=>{if(!(typeof window>"u"))try{const ne=new URL(window.location.href);if(!ne.searchParams.has("cancel_snooze"))return;ne.searchParams.delete("cancel_snooze");const oe=ne.searchParams.toString(),ie=`${ne.pathname}${oe?`?${oe}`:""}${ne.hash||""}`;window.history.replaceState(window.history.state,"",ie)}catch(ne){console.warn("[deep-link-cancel] Failed to strip ?cancel_snooze from URL:",ne)}},ps=async()=>{if(!V||V.status==="confirming")return;B({...V,status:"confirming",errorMessage:null});const{ok:ne,errorMessage:oe}=await He(V.snoozeId);ne?(B(ie=>ie&&{...ie,status:"success",errorMessage:null}),Nt(),A.current!==null&&window.clearTimeout(A.current),A.current=window.setTimeout(()=>{B(null),A.current=null},4e3)):B(ie=>ie&&{...ie,status:"error",errorMessage:oe||"Cancellation failed. The snooze may have already been cancelled by another session."})},ft=()=>{A.current!==null&&(window.clearTimeout(A.current),A.current=null),B(null),Nt()};d.useEffect(()=>{if(typeof window>"u")return;let ne=!1;const ie=new URL(window.location.href).searchParams.get("cancel_snooze");if(ie)return B({status:"loading",snoozeId:ie,row:null,errorMessage:null}),(async()=>{try{const{data:fe,error:Re}=await O.from("stale_compliance_alert_snoozes").select("id, snoozed_until, reason, snoozed_by, created_at, cancelled_at, cancelled_by").eq("id",ie).maybeSingle();if(ne)return;if(Re){B({status:"error",snoozeId:ie,row:null,errorMessage:`Failed to look up snooze: ${Re.message}`});return}if(!fe){B({status:"not-found",snoozeId:ie,row:null,errorMessage:null});return}const Me=fe;let Te="found";if(Me.cancelled_at)Te="already-cancelled";else{const Pt=new Date(Me.snoozed_until).getTime();Number.isFinite(Pt)&&Pt<=Date.now()&&(Te="already-expired")}B({status:Te,snoozeId:ie,row:Me,errorMessage:null})}catch(fe){if(ne)return;B({status:"error",snoozeId:ie,row:null,errorMessage:(fe==null?void 0:fe.message)||"Unexpected error looking up snooze"})}})(),()=>{ne=!0}},[]),d.useEffect(()=>()=>{A.current!==null&&window.clearTimeout(A.current)},[]);const Ca=()=>{if(!(typeof window>"u"))try{const ne=new URL(window.location.href);if(!ne.searchParams.has("view_recurring_template"))return;ne.searchParams.delete("view_recurring_template");const oe=ne.searchParams.toString(),ie=`${ne.pathname}${oe?`?${oe}`:""}${ne.hash||""}`;window.history.replaceState(window.history.state,"",ie)}catch(ne){console.warn("[deep-link-view-recurring] Failed to strip ?view_recurring_template from URL:",ne)}};d.useEffect(()=>{if(typeof window>"u")return;const oe=new URL(window.location.href).searchParams.get("view_recurring_template");oe&&M(oe)},[]),d.useEffect(()=>{if(!z||!x)return;const ne=z;M(null),Ca(),_e(ne)},[z,x]),d.useEffect(()=>{we()},[]);const ee=d.useMemo(()=>r.filter(ne=>{const oe=new Date(ne.verified_at).getTime(),ie=new Date(J+"T00:00:00").getTime(),fe=new Date(pe+"T23:59:59").getTime();if(oe<ie||oe>fe||ke!=="all"&&ne.service!==ke||ue==="passed"&&!ne.all_live||ue==="failed"&&ne.all_live)return!1;if(le.trim()){const Re=le.toLowerCase();if(![ne.id,ne.verified_by,ne.notes,ne.user_agent,ne.service].filter(
1271Boolean).join(" ").toLowerCase().includes(Re))return!1}return!0}),[r,J,pe,ke,ue,le]),me=d.useMemo(()=>{let ne=0,oe=0,ie=0,fe=0,Re=0,Me=0;for(const Te of ee)Te.service==="GA4"?ne++:oe++,Te.all_live?ie++:fe++,Re+=Te.total_rows_returned,Me+=Te.duration_ms;return{ga4:ne,gsc:oe,passed:ie,failed:fe,totalRows:Re,totalDuration:Me}},[ee]),Z=d.useMemo(()=>{const ne=r.find(Pt=>Pt.service==="GA4")||null,oe=r.find(Pt=>Pt.service==="GSC")||null,ie=(ne==null?void 0:ne.verified_at)??null,fe=(oe==null?void 0:oe.verified_at)??null,Re=oN(ie),Me=oN(fe),Te=Tne(Re,Me);return{ga4At:ie,gscAt:fe,ga4Days:Re,gscDays:Me,ga4AllLive:(ne==null?void 0:ne.all_live)??null,gscAllLive:(oe==null?void 0:oe.all_live)??null,tone:Te}},[r]),xe=ne=>{l(oe=>{const ie=new Set(oe);return ie.has(ne)?ie.delete(ne):ie.add(ne),ie})},Pe=()=>{const oe=[["audit_id","service","verified_at","verified_by","all_live","any_demo_mode","passed","total","total_rows_returned","duration_ms","step_advanced_from","step_advanced_to","notes","user_agent"].join(",")];for(const Te of ee)oe.push([Te.id,Te.service,Te.verified_at,Te.verified_by,Te.all_live,Te.any_demo_mode,Te.passed,Te.total,Te.total_rows_returned,Te.duration_ms,Te.step_advanced_from,Te.step_advanced_to,Te.notes,Te.user_agent].map(L8).join(","));const ie=oe.join(` 1272`),fe=new Blob([ie],{type:"text/csv;charset=utf-8;"}),Re=URL.createObjectURL(fe),Me=document.createElement("a");Me.href=Re,Me.download=`deployment_audit_log_${new Date().toISOString().slice(0,10)}.csv`,document.body.appendChild(Me),Me.click(),document.body.removeChild(Me),URL.revokeObjectURL(Re)},De=async()=>{if(U)return;q(!0),X(null),K(null),G("Initializing â invoking GA4 + GSC verifiers server-sideâ¦");const ne=[];ne.push(window.setTimeout(()=>G("Verifying GA4 entities (5 entities, realtime metric)â¦"),500)),ne.push(window.setTimeout(()=>G("Verifying GSC properties (5 à 3 = 15 checks)â¦"),6e3)),ne.push(window.setTimeout(()=>G("Writing audit rows to ga4/gsc_deployment_auditâ¦"),2e4));try{const{data:oe,error:ie}=await O.functions.invoke("cron-weekly-deployment-audit",{body:{verified_by:"operator-manual-onclick",notes:"Triggered from Deployment Audit Log â Run Full Audit button."}});if(ne.forEach(Re=>window.clearTimeout(Re)),ie)throw new Error(ie.message||"Edge function invocation failed");const fe=oe||{};if(!fe.success)throw new Error(fe.error||"Audit run failed without a specific error message");X(fe),G("Refreshing timelineâ¦"),await we(),G("")}catch(oe){ne.forEach(ie=>window.clearTimeout(ie)),K((oe==null?void 0:oe.message)||"Failed to run full deployment audit"),G("")}finally{q(!1)}};return e.jsxs("div",{className:"min-h-screen bg-gradient-to-br from-slate-50 via-white to-slate-50",children:[V&&e.jsx("div",{className:"max-w-7xl mx-auto px-6 pt-6",children:e.jsx(tae,{state:V,onConfirm:ps,onDismiss:ft})}),e.jsx("div",{className:"border-b border-slate-200 bg-white",children:e.jsxs("div",{className:"max-w-7xl mx-auto px-6 py-6",children:[e.jsxs("div",{className:"flex items-start justify-between flex-wrap gap-4",children:[e.jsxs("div",{children:[e.jsxs(be,{to:"/",className:"inline-flex items-center gap-1 text-sm text-slate-600 hover:text-slate-900 mb-3",children:[e.jsx(Je,{className:"w-4 h-4"}),"Back to dashboard"]}),e.jsxs("h1",{className:"text-3xl font-bold text-slate-900 flex items-center gap-3",children:[e.jsx("div",{className:"p-2 rounded-lg bg-gradient-to-br from-blue-600 to-emerald-600",children:e.jsx(Ma,{className:"w-6 h-6 text-white"})}),"Deployment Audit Log"]}),e.jsx("p",{className:"text-sm text-slate-600 mt-2 max-w-2xl",children:"Unified compliance timeline of every LIVE-verification run across the Google Analytics 4 and Google Search Console modules. Each row is an immutable audit record written by the verifier on full success or partial failure."})]}),e.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[e.jsxs(gt,{onClick:De,disabled:U,className:"gap-2 bg-gradient-to-r from-amber-500 via-orange-500 to-rose-500 hover:from-amber-600 hover:via-orange-600 hover:to-rose-600 text-white shadow-md",children:[U?e.jsx(de,{className:"w-4 h-4 animate-spin"}):e.jsx(Pm,{className:"w-4 h-4"}),U?"Running auditâ¦":"Run Full Audit (GA4 + GSC)"]}),e.jsxs(gt,{onClick:we,variant:"outline",disabled:t||U,className:"gap-2",children:[e.jsx(Be,{className:`w-4 h-4 ${t?"animate-spin":""}`}),"Refresh"]}),e.jsxs(gt,{onClick:Pe,disabled:ee.length===0||U,className:"gap-2 bg-gradient-to-r from-blue-600 to-emerald-600 hover:from-blue-700 hover:to-emerald-700",children:[e.jsx(us,{className:"w-4 h-4"}),"Export CSV (",ee.length,")"]})]})]}),e.jsx(Zne,{ga4At:Z.ga4At,gscAt:Z.gscAt,ga4Days:Z.ga4Days,gscDays:Z.gscDays,ga4AllLive:Z.ga4AllLive,gscAllLive:Z.gscAllLive,tone:Z.tone,loading:t&&r.length===0,lastAlert:c,activeSnooze:p,onCreateSnooze:Lt,onCreateRecurringSnooze:ge,onCancelSnooze:He,onExtendSnooze:ut,snoozeMutating:y,snoozeTemplates:N,snoozeTemplatesError:f,snoozeTemplateMutating:S,onApplyTemplate:wt,onSaveSnoozeTemplate:mt,onRenameSnoozeTemplate:ae,onDeleteSnoozeTemplate:qe,onReorderSnoozeTemplate:bt,onPruneSnoozeTemplates:ht,onRestoreSnoozeTemplates:Ht,onClearSnoozeTemplatesError:()=>j(null)}),e.jsx(Qne,{history:x,open:_,onOpenChange:C,panelRef:D,highlightedSnoozeId:E,lookupNotice:F,onClearLookupNotice:()=>I(null),onManageRecurring:_e}),R&&e.jsx(sae,{state:R,onClose:Ut,onPause:Se,onDeleteFutureOccurrences:We,onRetry:()=>_e(R.templateId)})]})}),e.jsxs("div",{className:"max-w-7xl mx-auto px-6 py-6 space-y-6",children:[(U||H||W||Q)&&e.jsx(Vne,{running:U,stage:H,result:W,errorMessage:Q,onDismiss:()=>{X(null),K(null)}}),e.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-6 gap-3",children:[e.jsx(uu,{label:"Total runs",value:ee.length,tone:"slate"}),e.jsx(uu,{label:"GA4 runs",value:me.ga4,tone:"blue"}),e.jsx(uu,{label:"GSC runs",value:me.gsc,tone:"green"}),e.jsx(uu,{label:"Passed",value:me.passed,tone:"emerald"}),e.jsx(uu,{label:"Failed / Demo",value:me.failed,tone:"amber"}),e.jsx(uu,{label:"Total API rows",value:me.totalRows.toLocaleStr
1272ing(),tone:"indigo"})]}),e.jsxs("div",{className:"bg-white border border-slate-200 rounded-xl p-5 shadow-sm",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-4",children:[e.jsx(ei,{className:"w-4 h-4 text-slate-600"}),e.jsx("span",{className:"text-sm font-bold text-slate-900",children:"Filters"})]}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-5 gap-3",children:[e.jsxs("div",{children:[e.jsx("label",{className:"text-[11px] uppercase tracking-wider font-bold text-slate-600 mb-1 block",children:"Start date"}),e.jsxs("div",{className:"relative",children:[e.jsx(At,{className:"w-4 h-4 absolute left-3 top-1/2 -translate-y-1/2 text-slate-400 pointer-events-none"}),e.jsx("input",{type:"date",value:J,onChange:ne=>te(ne.target.value),className:"w-full pl-9 pr-3 py-2 border border-slate-300 rounded-md text-sm focus:outline-none focus:ring-2 focus:ring-blue-500"})]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-[11px] uppercase tracking-wider font-bold text-slate-600 mb-1 block",children:"End date"}),e.jsxs("div",{className:"relative",children:[e.jsx(At,{className:"w-4 h-4 absolute left-3 top-1/2 -translate-y-1/2 text-slate-400 pointer-events-none"}),e.jsx("input",{type:"date",value:pe,onChange:ne=>Fe(ne.target.value),className:"w-full pl-9 pr-3 py-2 border border-slate-300 rounded-md text-sm focus:outline-none focus:ring-2 focus:ring-blue-500"})]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-[11px] uppercase tracking-wider font-bold text-slate-600 mb-1 block",children:"Service"}),e.jsxs("select",{value:ke,onChange:ne=>Oe(ne.target.value),className:"w-full px-3 py-2 border border-slate-300 rounded-md text-sm focus:outline-none focus:ring-2 focus:ring-blue-500",children:[e.jsx("option",{value:"all",children:"All services"}),e.jsx("option",{value:"GA4",children:"GA4 only"}),e.jsx("option",{value:"GSC",children:"GSC only"})]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-[11px] uppercase tracking-wider font-bold text-slate-600 mb-1 block",children:"Status"}),e.jsxs("select",{value:ue,onChange:ne=>je(ne.target.value),className:"w-full px-3 py-2 border border-slate-300 rounded-md text-sm focus:outline-none focus:ring-2 focus:ring-blue-500",children:[e.jsx("option",{value:"all",children:"All statuses"}),e.jsx("option",{value:"passed",children:"Passed (all LIVE)"}),e.jsx("option",{value:"failed",children:"Failed / partial"})]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-[11px] uppercase tracking-wider font-bold text-slate-600 mb-1 block",children:"Search"}),e.jsxs("div",{className:"relative",children:[e.jsx(Bt,{className:"w-4 h-4 absolute left-3 top-1/2 -translate-y-1/2 text-slate-400 pointer-events-none"}),e.jsx("input",{type:"text",placeholder:"ID, verifier, notesâ¦",value:le,onChange:ne=>ye(ne.target.value),className:"w-full pl-9 pr-3 py-2 border border-slate-300 rounded-md text-sm focus:outline-none focus:ring-2 focus:ring-blue-500"})]})]})]})]}),n&&e.jsxs("div",{className:"bg-amber-50 border border-amber-200 rounded-xl p-4 flex items-start gap-3",children:[e.jsx(ve,{className:"w-5 h-5 text-amber-600 flex-shrink-0 mt-0.5"}),e.jsx("div",{className:"text-sm text-amber-900",children:n})]}),e.jsxs("div",{className:"bg-white border border-slate-200 rounded-xl shadow-sm overflow-hidden",children:[e.jsxs("div",{className:"px-5 py-3 border-b border-slate-200 bg-slate-50 flex items-center justify-between",children:[e.jsxs("div",{className:"text-sm font-bold text-slate-900 flex items-center gap-2",children:[e.jsx($i,{className:"w-4 h-4 text-slate-600"}),"Chronological verification timeline"]}),e.jsxs("div",{className:"text-xs text-slate-600",children:[ee.length," of ",r.length," runs"]})]}),t?e.jsxs("div",{className:"p-12 text-center",children:[e.jsx(Be,{className:"w-8 h-8 text-slate-400 animate-spin mx-auto mb-3"}),e.jsx("div",{className:"text-sm text-slate-600",children:"Loading audit timelineâ¦"})]}):ee.length===0?e.jsxs("div",{className:"p-12 text-center",children:[e.jsx($i,{className:"w-10 h-10 text-slate-300 mx-auto mb-3"}),e.jsx("div",{className:"text-sm text-slate-600 font-medium",children:"No audit rows match these filters"}),e.jsx("div",{className:"text-xs text-slate-500 mt-1",children:r.length===0?"N
1272o verification runs have been recorded yet. Trigger the GA4 or GSC verifier to create the first audit row.":"Try widening the date range or clearing the service/status filters."})]}):e.jsx("div",{className:"divide-y divide-slate-100",children:ee.map(ne=>e.jsx(Hne,{row:ne,expanded:o.has(ne.id),onToggle:()=>xe(ne.id),onViewSnooze:$t},`${ne.service}-${ne.id}`))})]}),e.jsxs("div",{className:"text-[11px] text-slate-500 text-center pt-2 pb-6",children:["Audit records are written by"," ",e.jsx("code",{className:"bg-slate-100 px-1 rounded",children:"GA4DeploymentChecklist"})," and"," ",e.jsx("code",{className:"bg-slate-100 px-1 rounded",children:"GSCDeploymentVerifier"})," on every LIVE-verification run. Rows are immutable and serve as compliance evidence for the analytics deployment."]})]})]})}function uu({label:t,value:s,tone:n}){const a={slate:"bg-slate-50 border-slate-200 text-slate-900",blue:"bg-blue-50 border-blue-200 text-blue-900",green:"bg-green-50 border-green-200 text-green-900",emerald:"bg-emerald-50 border-emerald-200 text-emerald-900",amber:"bg-amber-50 border-amber-200 text-amber-900",indigo:"bg-indigo-50 border-indigo-200 text-indigo-900"};return e.jsxs("div",{className:`border rounded-lg p-3 ${a[n]}`,children:[e.jsx("div",{className:"text-[10px] uppercase tracking-wider font-bold opacity-70",children:t}),e.jsx("div",{className:"text-2xl font-bold mt-1",children:s})]})}function Hne({row:t,expanded:s,onToggle:n,onViewSnooze:a}){const r=t.all_live,i=t.service==="GA4"?"bg-blue-100 text-blue-800 border-blue-200":"bg-emerald-100 text-emerald-800 border-emerald-200",o=!!t.notes&&t.notes.indexOf(Dne)!==-1;return e.jsxs("div",{className:"hover:bg-slate-50/50 transition-colors",children:[e.jsxs("button",{onClick:n,className:"w-full text-left px-5 py-4 flex items-start gap-4",children:[e.jsx("div",{className:"pt-1",children:s?e.jsx(Gt,{className:"w-4 h-4 text-slate-500"}):e.jsx(Nr,{className:"w-4 h-4 text-slate-500"})}),e.jsx("div",{className:"pt-0.5",children:r?e.jsx("div",{className:"w-9 h-9 rounded-full bg-emerald-100 flex items-center justify-center",children:e.jsx(Ue,{className:"w-5 h-5 text-emerald-600"})}):e.jsx("div",{className:"w-9 h-9 rounded-full bg-rose-100 flex items-center justify-center",children:e.jsx(kt,{className:"w-5 h-5 text-rose-600"})})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[e.jsx("span",{className:`text-[10px] font-bold px-2 py-0.5 rounded border ${i}`,children:t.service}),e.jsx("span",{className:`text-[10px] font-bold px-2 py-0.5 rounded border ${r?"bg-emerald-50 text-emerald-700 border-emerald-200":"bg-rose-50 text-rose-700 border-rose-200"}`,children:r?"ALL LIVE":"PARTIAL / FAILED"}),t.any_demo_mode&&e.jsx("span",{className:"text-[10px] font-bold px-2 py-0.5 rounded border bg-amber-50 text-amber-700 border-amber-200",children:"DEMO MODE"}),o&&e.jsxs("span",{className:"text-[10px] font-bold px-2 py-0.5 rounded border bg-violet-50 text-violet-700 border-violet-200 inline-flex items-center gap-1",title:"A snooze suppressed the stale-compliance email on this cron tick",children:[e.jsx(Zx,{className:"w-3 h-3"}),"SNOOZE-SUPPRESSED"]}),e.jsxs("span",{className:"text-sm font-semibold text-slate-900",children:[t.passed," / ",t.total," ",t.per_item_label," verified"]}),t.step_advanced_to&&t.step_advanced_from&&e.jsxs("span",{className:"text-[11px] text-slate-500",children:["· ",t.step_advanced_from," â ",t.step_advanced_to]})]}),e.jsxs("div",{className:"text-xs text-slate-600 mt-1 flex items-center gap-3 flex-wrap",children:[e.jsx("span",{children:Rs(t.verified_at)}),e.jsx("span",{children:"·"}),e.jsxs("span",{children:["by ",t.verified_by||"unknown"]}),e.jsx("span",{children:"·"}),e.jsxs("span",{children:[t.total_rows_returned.toLocaleString()," API rows"]}),e.jsx("span",{children:"·"}),e.jsx("span",{children:Dh(t.duration_ms)}),o&&a&&e.jsxs(e.Fragment,{children:[e.jsx("span",{children:"·"}),e.jsxs("span",{role:"link",tabIndex:0,onClick:l=>{l.stopPropagation(),l.preventDefault(),a(t.verified_at)},onKeyDown:l=>{(l.key==="Enter"||l.key===" ")&&(l.stopPropagation(),l.preventDefault(),a(t.verified_at))},className:"inline-flex items-center gap-1 text-violet-700 hover:text-violet-900 underline cursor-pointer font-semibold",title:"Scroll to the snooze that was active at this cron tick",children:[e.jsx(Xs,{className:"w-3 h-3"}),"View snooze â"]})]})]}),t.notes&&e.jsx("div",{className:"text-[11px] text-slate-500 mt-1 italic line-clamp-1",children:t.notes})]}),e.jsxs("div",{className:"text-[10px] font-mono text-slate-400 pt-1 hidden sm:block",children:[t.id.slice(0,8),"â¦"]})]}),s&&e.jsx("div",{className:"px-5 pb-5 pl-16",children:e.jsxs("div",{className:"bg-slate-50 border border-slate-200 rounded-lg p-4 space-y-3",children:[e.jsxs("div",{className:"flex items-center justify-between flex-wrap gap-2",children:[e.jsxs("div",{className:"text-[11px] uppercase tracking-wider font-bold text-slate-700",children:["Per-",t.per_item_label.slice(0,-1)," drill-down · ",t.per_item_results.length," ","items"]}),e.jsxs("div",{className:"text-[10px] font-mono text-slate-500",children:["audit_id: ",t.id]})]}),t.per_item_results.length===0?e.jsx("div",{className:"text-xs text-slate-500 italic",children:"No per-item results were recorded for this run."}):e.jsx("div",{className:"space-y-2",children:t.per_item_results.map((l,c)=>e.jsx(Gne,{item:l,service:t.service}
1272,c))}),e.jsxs("details",{className:"mt-3",children:[e.jsx("summary",{className:"text-[11px] font-bold text-slate-600 cursor-pointer hover:text-slate-900",children:"Raw audit row JSON"}),e.jsx("pre",{className:"mt-2 text-[10px] bg-slate-900 text-slate-100 p-3 rounded overflow-x-auto max-h-72",children:JSON.stringify(t.raw,null,2)})]})]})})]})}function Gne({item:t,service:s}){const n=t.entity||t.entityLabel||t.property||t.propertyLabel||t.name||t.label||t.id||"unnamed",a=t.metric||t.check||null,r=t.ok??t.success??(t.status===200&&(t.rowCount??t.rows??0)>0),i=t.status??t.httpStatus??null,o=t.rowCount??t.rows??t.rowsReturned??null,l=t.demoMode??!1,c=t.error||t.errorMessage||null,u=t.durationMs??t.duration_ms??null;return e.jsxs("div",{className:"bg-white border border-slate-200 rounded-md p-3 flex items-start gap-3",children:[e.jsx("div",{className:"pt-0.5",children:r?e.jsx(Ue,{className:"w-4 h-4 text-emerald-600"}):e.jsx(kt,{className:"w-4 h-4 text-rose-600"})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[e.jsx("span",{className:"text-xs font-semibold text-slate-900",children:n}),a&&e.jsx("span",{className:"text-[10px] font-mono bg-slate-100 px-1.5 py-0.5 rounded text-slate-700",children:a}),l&&e.jsx("span",{className:"text-[10px] font-bold px-1.5 py-0.5 rounded bg-amber-100 text-amber-800",children:"DEMO"}),!r&&!l&&e.jsx("span",{className:"text-[10px] font-bold px-1.5 py-0.5 rounded bg-rose-100 text-rose-800",children:"FAILED"}),r&&!l&&e.jsx("span",{className:"text-[10px] font-bold px-1.5 py-0.5 rounded bg-emerald-100 text-emerald-800",children:"LIVE"})]}),e.jsxs("div",{className:"text-[11px] text-slate-600 mt-1 flex items-center gap-3 flex-wrap",children:[i!==null&&e.jsxs("span",{children:["HTTP ",i]}),o!==null&&e.jsxs("span",{children:[o.toLocaleString()," rows"]}),u!==null&&e.jsx("span",{children:Dh(u)}),e.jsxs("span",{className:"text-[10px] text-slate-400",children:["· ",s]})]}),c&&e.jsx("div",{className:"text-[11px] text-rose-700 mt-1 bg-rose-50 border border-rose-200 rounded px-2 py-1",children:c})]})]})}function Vne({running:t,stage:s,result:n,errorMessage:a,onDismiss:r}){if(t)return e.jsx("div",{className:"bg-gradient-to-r from-amber-50 via-orange-50 to-rose-50 border border-amber-300 rounded-xl p-5 shadow-sm",children:e.jsxs("div",{className:"flex items-start gap-4",children:[e.jsx("div",{className:"p-2 rounded-lg bg-gradient-to-br from-amber-500 to-rose-500 flex-shrink-0",children:e.jsx(de,{className:"w-5 h-5 text-white animate-spin"})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("div",{className:"text-sm font-bold text-slate-900",children:"Running full deployment auditâ¦"}),e.jsx("div",{className:"text-xs text-slate-700 mt-1",children:s||"Startingâ¦"}),e.jsxs("div",{className:"text-[11px] text-slate-500 mt-2",children:["The server is sequentially calling"," ",e.jsx("code",{className:"bg-white/60 px-1 rounded",children:"ga4-fetch-metrics"})," (5 entities) and"," ",e.jsx("code",{className:"bg-white/60 px-1 rounded",children:"gsc-fetch-metrics"})," (15 checks). This typically takes 25â45 seconds. Audit rows will appear in the timeline automatically when the run completes."]})]})]})});if(a)return e.jsx("div",{className:"bg-rose-50 border border-rose-300 rounded-xl p-5 shadow-sm",children:e.jsxs("div",{className:"flex items-start gap-4",children:[e.jsx("div",{className:"p-2 rounded-lg bg-rose-600 flex-shrink-0",children:e.jsx(kt,{className:"w-5 h-5 text-white"})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-start justify-between gap-3",children:[e.jsx("div",{className:"text-sm font-bold text-rose-900",children:"Full deployment audit failed"}),e.jsx("button",{onClick:r,className:"text-xs text-rose-700 hover:text-rose-900 underline whitespace-nowrap",children:"Dismiss"})]}),e.jsx("div",{className:"text-xs text-rose-800 mt-1 break-words",children:a}),e.jsxs("div",{className:"text-[11px] text-rose-700 mt-2",children:["No audit rows were written. You can retry, or check the edge function logs for"," ",e.jsx("code",{className:"bg-white/60 px-1 rounded",children:"cron-weekly-deployment-audit"}),"."]})]})]})});if(n){const i=n.ga4,o=n.gsc,l=!!(i!=null&&i.all_live&&(o!=null&&o.all_live)),c=l?"from-emerald-50 via-green-50 to-teal-50 border-emerald-300":"from-
1272amber-50 via-yellow-50 to-orange-50 border-amber-300",u=l?"from-emerald-500 to-teal-600":"from-amber-500 to-orange-600";return e.jsx("div",{className:`bg-gradient-to-r ${c} border rounded-xl p-5 shadow-sm`,children:e.jsxs("div",{className:"flex items-start gap-4",children:[e.jsx("div",{className:`p-2 rounded-lg bg-gradient-to-br ${u} flex-shrink-0`,children:l?e.jsx(Ue,{className:"w-5 h-5 text-white"}):e.jsx(ve,{className:"w-5 h-5 text-white"})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-start justify-between gap-3",children:[e.jsxs("div",{children:[e.jsx("div",{className:"text-sm font-bold text-slate-900",children:l?"Full deployment audit complete â all services LIVE":"Full deployment audit complete â partial results"}),e.jsxs("div",{className:"text-[11px] text-slate-600 mt-0.5",children:["Total duration: ",Dh(n.total_duration_ms||0)," · verified_by ="," ",e.jsx("code",{className:"bg-white/60 px-1 rounded",children:n.verified_by||"operator-manual-onclick"})]})]}),e.jsx("button",{onClick:r,className:"text-xs text-slate-600 hover:text-slate-900 underline whitespace-nowrap",children:"Dismiss"})]}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-3 mt-3",children:[i&&e.jsxs("div",{className:"bg-white/70 border border-blue-200 rounded-lg p-3",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[e.jsx("span",{className:"text-[10px] font-bold px-2 py-0.5 rounded border bg-blue-100 text-blue-800 border-blue-200",children:"GA4"}),e.jsx("span",{className:`text-[10px] font-bold px-2 py-0.5 rounded border ${i.all_live?"bg-emerald-100 text-emerald-800 border-emerald-200":"bg-rose-100 text-rose-800 border-rose-200"}`,children:i.all_live?"ALL LIVE":"PARTIAL"}),i.any_demo_mode&&e.jsx("span",{className:"text-[10px] font-bold px-2 py-0.5 rounded border bg-amber-100 text-amber-800 border-amber-200",children:"DEMO"})]}),e.jsxs("div",{className:"text-sm font-semibold text-slate-900",children:[i.entities_verified," / ",i.entities_total," entities verified"]}),e.jsxs("div",{className:"text-[11px] text-slate-600 mt-1",children:[i.total_rows_returned.toLocaleString()," API rows ·"," ",Dh(i.duration_ms)]}),i.audit_row_id?e.jsxs("div",{className:"text-[10px] font-mono text-slate-500 mt-1",children:["audit_id: ",i.audit_row_id.slice(0,8),"â¦"]}):i.audit_row_error?e.jsxs("div",{className:"text-[10px] text-rose-700 mt-1",children:["audit insert failed: ",i.audit_row_error]}):null]}),o&&e.jsxs("div",{className:"bg-white/70 border border-emerald-200 rounded-lg p-3",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[e.jsx("span",{className:"text-[10px] font-bold px-2 py-0.5 rounded border bg-emerald-100 text-emerald-800 border-emerald-200",children:"GSC"}),e.jsx("span",{className:`text-[10px] font-bold px-2 py-0.5 rounded border ${o.all_live?"bg-emerald-100 text-emerald-800 border-emerald-200":"bg-rose-100 text-rose-800 border-rose-200"}`,children:o.all_live?"ALL LIVE":"PARTIAL"}),o.any_demo_mode&&e.jsx("span",{className:"text-[10px] font-bold px-2 py-0.5 rounded border bg-amber-100 text-amber-800 border-amber-200",children:"DEMO"})]}),e.jsxs("div",{className:"text-sm font-semibold text-slate-900",children:[o.checks_passed," / ",o.checks_total," checks passed ·"," ",o.properties_verified," / ",o.properties_total," properties fully verified"]}),e.jsxs("div",{className:"text-[11px] text-slate-600 mt-1",children:[o.total_rows_returned.toLocaleString()," API rows ·"," ",Dh(o.duration_ms)]}),o.audit_row_id?e.jsxs("div",{className:"text-[10px] font-mono text-slate-500 mt-1",children:["audit_id: ",o.audit_row_id.slice(0,8),"â¦"]}):o.audit_row_error?e.jsxs("div",{className:"text-[10px] text-rose-700 mt-1",children:["audit insert failed: ",o.audit_row_error]}):null]})]}),e.jsxs("div",{className:"text-[11px] text-slate-600 mt-3",children:["Two new audit rows have been written to"," ",e.jsx("code",{className:"bg-white/60 px-1 rounded",children:"ga4_deployment_audit"})," and"," ",e.jsx("code",{className:"bg-white/60 px-1 rounded",children:"gsc_deployment_audit"})," and the timeline below has been refreshed."]})]})]})})}return null}function Zne({ga4At:t,gscAt:s,ga4Days:n,gscDays:a,ga4AllLive:r,gscAllLive:i,tone:o,loading:l,lastAlert:c,activeSnooze:u,onCreateSnooze:p,onCreateRecurringSnooze:m,onCancelSnooze:x,onExtendSnooze:h,snoozeMutating:y,snoozeTemplates:v,snoozeTemplatesError:g,snoozeTemplateMutating:N,onApplyTemplate:b,onSaveSnoozeTemplate:f,onRenameSnoozeTemplate:j,onDeleteSnoozeTemplate:S,onReorderSnoozeTemplate:w,onPruneSnoozeTemplates:_,onRestoreSnoozeTemplates:C,onClearSnoozeTemplatesError:E}){const F={green:{container:"bg-gradient-to-r from-emerald-50 via-green-50 to-teal-50 border-emerald-300",icon:"from-emerald-500 to-teal-600",iconColor:"text-white",badgeText:"COMPLIANT",badgeBg:"bg-emerald-100 text-emerald-800 border-emerald-300",headline:"Deployment c
1272ompliance is fresh",subhead:"Both GA4 and GSC have been verified within the last 7 days."},amber:{container:"bg-gradient-to-r from-amber-50 via-yellow-50 to-orange-50 border-amber-300",icon:"from-amber-500 to-orange-600",iconColor:"text-white",badgeText:"WARNING",badgeBg:"bg-amber-100 text-amber-800 border-amber-300",headline:"Verification is getting stale",subhead:"At least one service was last verified 7â14 days ago. Consider running a fresh audit."},red:{container:"bg-gradient-to-r from-rose-50 via-red-50 to-orange-50 border-rose-300",icon:"from-rose-500 to-red-600",iconColor:"text-white",badgeText:"STALE",badgeBg:"bg-rose-100 text-rose-800 border-rose-300",headline:"Deployment compliance is stale",subhead:"At least one service has not been verified in over 14 days. Run a full audit immediately."},gray:{container:"bg-slate-50 border-slate-300",icon:"from-slate-400 to-slate-600",iconColor:"text-white",badgeText:"NO DATA",badgeBg:"bg-slate-100 text-slate-700 border-slate-300",headline:"No verification runs yet",subhead:"Trigger the GA4 or GSC verifier to create the first audit row."}}[o],I=7,D=c?new Date(c.sent_at).getTime():null,L=D&&Number.isFinite(D)?new Date(D+I*864e5).toISOString():null,V=oN((c==null?void 0:c.sent_at)??null),B=D!==null&&Number.isFinite(D)&&Date.now()-D<I*864e5,A=u?new Date(u.snoozed_until).getTime():null,z=A!==null&&Number.isFinite(A)?A-Date.now():null,M=(()=>{if(z===null||z<=0)return null;const R=z/36e5;if(R<24)return`${R.toFixed(1)} hours remaining`;const T=R/24;return T<1.5?"~1 day remaining":`${Math.round(T)} days remaining`})();return e.jsxs("div",{className:`mt-4 border rounded-xl p-4 shadow-sm ${F.container}`,children:[e.jsxs("div",{className:"flex items-start gap-4 flex-wrap",children:[e.jsxs("div",{className:"flex items-start gap-3 flex-1 min-w-[280px]",children:[e.jsx("div",{className:`p-2 rounded-lg bg-gradient-to-br ${F.icon} flex-shrink-0`,children:e.jsx(dt,{className:`w-5 h-5 ${F.iconColor}`})}),e.jsxs("div",{className:"min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[e.jsx("div",{className:"text-sm font-bold text-slate-900",children:"Last verified"}),e.jsx("span",{className:`text-[10px] font-bold px-2 py-0.5 rounded border ${F.badgeBg}`,children:F.badgeText}),u&&e.jsxs("span",{className:"text-[10px] font-bold px-2 py-0.5 rounded border bg-violet-100 text-violet-800 border-violet-300 inline-flex items-center gap-1",title:`Alerts snoozed until ${Rs(u.snoozed_until)}`,children:[e.jsx(Zx,{className:"w-3 h-3"}),"SNOOZED"]})]}),e.jsx("div",{className:"text-xs font-semibold text-slate-800 mt-1",children:F.headline}),e.jsx("div",{className:"text-[11px] text-slate-600 mt-0.5",children:F.subhead})]})]}),e.jsxs("div",{className:"flex gap-2 flex-wrap items-start",children:[e.jsx(vE,{label:"GA4",badgeColor:"bg-blue-100 text-blue-800 border-blue-300",atIso:t,days:n,allLive:r}),e.jsx(vE,{label:"GSC",badgeColor:"bg-emerald-100 text-emerald-800 border-emerald-300",atIso:s,days:a,allLive:i}),!u&&e.jsx(Yne,{onCreate:p,onCreateRecurring:m,mutating:y==="snooze",templates:v,templatesError:g??null,templateMutating:!!N,onApplyTemplate:b,onSaveTemplate:f,onRenameTemplate:j,onDeleteTemplate:S,onReorderTemplate:w,onPruneTemplates:_,onRestoreTemplates:C})]})]}),u&&e.jsxs("div",{className:"mt-3 pt-3 border-t border-violet-200 bg-violet-50/40 -mx-4 -mb-4 px-4 pb-3 rounded-b-xl",children:[e.jsxs("div",{className:"flex items-start gap-3 flex-wrap text-[11px] text-slate-700",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Gl,{className:"w-3.5 h-3.5 text-violet-600"}),e.jsx("span",{className:"font-bold uppercase tracking-wider text-violet-700 text-[10px]",children:"Stale alerts snoozed"})]}),e.jsxs("div",{className:"flex flex-col",children:[e.jsx("span",{className:"text-[10px] uppercase tracking-wider font-bold text-slate-500",children:"Expires"}),e.jsxs("span",{className:"font-semibold text-slate-900",children:[wa(u.snoozed_until).replace("ago","from now").replace("just now","
1272soon"),M&&e.jsxs("span",{className:"text-slate-500 font-normal",children:[" (",M,")"]})]}),e.jsx("span",{className:"text-[10px] text-slate-500 font-mono",children:Rs(u.snoozed_until)})]}),u.snoozed_by&&e.jsxs("div",{className:"flex flex-col",children:[e.jsx("span",{className:"text-[10px] uppercase tracking-wider font-bold text-slate-500",children:"Snoozed by"}),e.jsx("span",{className:"text-slate-800",children:u.snoozed_by})]}),u.reason&&e.jsxs("div",{className:"flex flex-col min-w-0 max-w-md",children:[e.jsx("span",{className:"text-[10px] uppercase tracking-wider font-bold text-slate-500",children:"Reason"}),e.jsxs("span",{className:"text-slate-800 italic break-words",children:['"',u.reason,'"']})]}),e.jsxs("div",{className:"flex-1 min-w-[120px] flex items-end justify-end gap-3",children:[h&&e.jsx(Kne,{currentUntilIso:u.snoozed_until,onExtend:h,mutating:y==="extend",anyMutating:y!==null}),e.jsxs("button",{onClick:()=>x(),disabled:y!==null,className:"text-[11px] font-semibold text-violet-700 hover:text-violet-900 underline disabled:opacity-50 disabled:cursor-not-allowed inline-flex items-center gap-1",children:[y==="cancel"?e.jsx(de,{className:"w-3 h-3 animate-spin"}):e.jsx(Ke,{className:"w-3 h-3"}),y==="cancel"?"Cancellingâ¦":"Cancel snooze"]})]})]}),e.jsx("div",{className:"mt-2 text-[10px] text-slate-500",children:"The weekly cron tick will still run verification, but no stale-compliance email will be sent while this snooze is active. Cancel to re-enable alerts immediately."})]}),c&&e.jsx(e.Fragment,{children:e.jsxs("div",{className:"mt-3 pt-3 border-t border-white/60 flex items-start gap-3 flex-wrap text-[11px] text-slate-700",children:[e.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[e.jsx("span",{className:"font-bold uppercase tracking-wider text-slate-600 text-[10px]",children:"Last stale alert sent"}),e.jsx("span",{className:`text-[9px] font-bold px-1.5 py-0.5 rounded border ${B?"bg-amber-100 text-amber-800 border-amber-300":"bg-emerald-100 text-emerald-800 border-emerald-300"}`,children:B?"COOLDOWN ACTIVE":"ELIGIBLE"})]}),e.jsxs("div",{className:"flex flex-col",children:[e.jsxs("span",{className:"font-semibold text-slate-900",children:[wa(c.sent_at),V!==null&&e.jsxs("span",{className:"text-slate-500 font-normal",children:[" (",V,"d)"]})]}),e.jsx("span",{className:"text-[10px] text-slate-500 font-mono",children:Rs(c.sent_at)})]}),e.jsxs("div",{className:"flex flex-col",children:[e.jsx("span",{className:"text-[10px] uppercase tracking-wider font-bold text-slate-500",children:"Recipient"}),e.jsx("span",{className:"text-slate-800",children:c.recipient})]}),(c.ga4_days_since!==null||c.gsc_days_since!==null)&&e.jsxs("div",{className:"flex flex-col",children:[e.jsx("span",{className:"text-[10px] uppercase tracking-wider font-bold text-slate-500",children:"At-send age"}),e.jsxs("span",{className:"text-slate-800 font-mono",children:["ga4=",c.ga4_days_since??"n/a","d · gsc=",c.gsc_days_since??"n/a","d"]})]}),L&&e.jsxs("div",{className:"flex flex-col",children:[e.jsx("span",{className:"text-[10px] uppercase tracking-wider font-bold text-slate-500",children:B?"Next eligible":"Cooldown ended"}),e.jsx("span",{className:"text-slate-800 font-mono",children:Rs(L)})]}),c.message_id&&e.jsxs("div",{className:"flex flex-col min-w-0",children:[e.jsx("span",{className:"text-[10px] uppercase tracking-wider font-bold text-slate-500",children:"Mailgun ID"}),e.jsx("span",{className:"text-slate-600 font-mono text-[10px] truncate max-w-[200px]",title:c.message_id,children:c.message_id})]})]})})]})}function Yne({onCreate:t,onCreateRecurring:s,mutating:n,templates:a,templatesError:r,templateMutating:i,onApplyTemplate:o,onSaveTemplate:l,onRenameTemplate:c,onDeleteTemplate:u,onReorderTemplate:p,onPruneTemplates:m,onRestoreTemplates:x,onClearTemplatesError:h}){const[y,v]=d.useState(!1),[g,N]=d.useState(()=>Ine()),[b,f]=d.useState(()=>new Date(Date.now()+14*864e5).toISOString().slice(0,10)),[j,S]=d.useState(!1),[w,_]=d.useState("none"),[C,E]=d.useState(""),[P,F]=d.useState("1w"),[I,D]=d.useState(null),[L,V]=d.useState(""),[B,A]=d.useState(()=>One()),z=Array.isArray(a)?Mne(a,B):[],M=30*864e5,R=(Array.isArray(a)?a:[]).filter(le=>{if((le.usage_count||0)>0)return!1;const ye=new Date(le.created_at).getTime();return Number.isFinite(ye)?ye<Date.now()-M:!1}),T=z.filter(le=>R.some(ye=>ye.id===le.id)),[U,q]=d.useState(!1),H=aR(),G=async()=>
1272{if(!m)return;const le=R.map(ut=>({...ut})),ye=le.map(ut=>ut.id);if(ye.length===0){q(!1);return}if(!await m(ye))return;q(!1);const He=le.map(ut=>({label:ut.name,reason:ut.reason}));if(!x){H.show({variant:"success",title:`Pruned ${le.length} template${le.length===1?"":"s"}`,description:"Deleted templates that had never been clicked and were >30 days old.",durationMs:6e3,expandableChips:He,expandLabel:"View what was pruned"});return}H.show({id:"snooze-prune-undo",variant:"success",title:`Pruned ${le.length} template${le.length===1?"":"s"}`,description:"Undo within 10s to restore with original ids and positions.",durationMs:1e4,expandableChips:He,expandLabel:"View what was pruned",actions:[{label:"Undo prune",variant:"primary",dismissOnSuccess:!0,onClick:async()=>{if(await x(le))H.show({variant:"success",title:`Restored ${le.length} template${le.length===1?"":"s"}`,description:"Pruned templates have been re-inserted with their original ids and positions.",durationMs:6e3,expandableChips:He,expandLabel:"View what was pruned"});else throw H.show({variant:"error",title:"Could not restore pruned templates",description:"See the manage drawer error banner for details. You may need to manually re-save the templates.",expandableChips:He,expandLabel:"View what would have been restored"}),new Error("Restore failed")}}]})},[W,X]=d.useState(()=>Date.now());d.useEffect(()=>{if(!y)return;X(Date.now());const le=window.setInterval(()=>{X(Date.now())},3e4);return()=>window.clearInterval(le)},[y]);const Q=d.useRef(null);d.useEffect(()=>{if(!y)return;const le=ye=>{Q.current&&!Q.current.contains(ye.target)&&(v(!1),S(!1),_("none"),D(null))};return document.addEventListener("mousedown",le),()=>document.removeEventListener("mousedown",le)},[y]);const K=async le=>{const ye=g;await t({untilIso:le.computeUntilIso(),reason:ye,presetLabel:le.label}),yE(ye),v(!1),S(!1),_("none")},se=async()=>{if(!b)return;const le=new Date(`${b}T23:59:59`).toISOString(),ye=g;await t({untilIso:le,reason:ye,presetLabel:`until ${b}`}),yE(ye),v(!1),S(!1),_("none")},Y=()=>{N(""),$ne()},J=async le=>{!o||n||(await o(le),v(!1),_("none"))},te=async()=>{if(!l)return;await l({name:C,preset_id:P,custom_duration_ms:null,reason:g})&&(E(""),_("manage"))},pe=async le=>{if(!c)return;await c(le,L)&&(D(null),V(""))},Fe=le=>Rh(le.computeUntilIso()),ke=(()=>{if(!b)return"";try{const le=new Date(`${b}T23:59:59`).toISOString();return Rh(le)}catch{return""}})(),Oe=le=>{const ye=M8(le);return ye?Rh(ye):""},ue=Array.isArray(a)&&a.length>0,je=!!o||!!l;return e.jsxs("div",{ref:Q,className:"relative",children:[e.jsxs("button",{type:"button",onClick:()=>v(le=>!le),disabled:n,className:"h-full min-w-[180px] bg-white/90 hover:bg-white border border-slate-300 rounded-lg px-3 py-2 text-left flex items-center gap-2 transition-colors disabled:opacity-50 disabled:cursor-not-allowed",children:[n?e.jsx(de,{className:"w-3.5 h-3.5 text-slate-600 animate-spin flex-shrink-0"}):e.jsx(Zx,{className:"w-3.5 h-3.5 text-slate-600 flex-shrink-0"}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("div",{className:"text-[11px] font-bold text-slate-900 leading-tight",children:"Snooze stale alerts"}),e.jsx("div",{className:"text-[10px] text-slate-500 leading-tight",children:n?"Snoozingâ¦":ue?"Templates, presets, or pick a date":"1 hour to 1 month, or pick a date"})]}),e.jsx(Gt,{className:`w-3.5 h-3.5 text-slate-500 flex-shrink-0 transition-transform ${y?"rotate-180":""}`})]}),y&&e.jsxs("div",{className:"absolute right-0 top-full mt-1 w-80 bg-white border border-slate-300 rounded-lg shadow-lg z-20 p-3 max-h-[80vh] overflow-y-auto",children:[je&&ue&&e.jsxs("div",{className:"mb-3 pb-3 border-b border-slate-200",children:[e.jsxs("div",{className:"text-[10px] uppercase tracking-wider font-bold text-slate-500 mb-2 flex items-center justify-between",children:[e.jsx("span",{children:"Saved templates"}),e.jsx("span",{className:"text-[9px] font-semibold text-slate-400 normal-case tracking-normal",children:"one-click apply"})]}),e.jsx("div",{className:"flex flex-wrap gap-1.5",children:z.map(le=>{const ye=Oe(le);return e.jsx("button",{type:"button",onClick:()=>J(le),disabled:n||i,title:(le.reason?`Reason: ${le.reason} 1273`:"")+(ye?`Will snooze ${ye}`:`Duration: ${bE(le)}`),className:"text-[10px] font-semibold px-2 py-1 rounded-full border border-violet-300 bg-vi
1273olet-50 hover:bg-violet-100 hover:border-violet-400 text-violet-800 transition-colors disabled:opacity-50 disabled:cursor-not-allowed max-w-full truncate",children:le.name},le.id)})})]}),je&&r&&e.jsxs("div",{className:"mb-3 bg-rose-50 border border-rose-200 rounded-md px-2 py-1.5 flex items-start justify-between gap-2",children:[e.jsxs("div",{className:"flex items-start gap-1.5 text-[10px] text-rose-800",children:[e.jsx(ve,{className:"w-3 h-3 flex-shrink-0 mt-0.5"}),e.jsx("span",{children:r})]}),h&&e.jsx("button",{type:"button",onClick:h,className:"text-[9px] text-rose-700 hover:text-rose-900 underline whitespace-nowrap",children:"Dismiss"})]}),e.jsx("div",{className:"text-[10px] uppercase tracking-wider font-bold text-slate-500 mb-2",children:"Snooze duration"}),e.jsxs("div",{className:"space-y-1",children:[Xy.map(le=>{const ye=Fe(le);return e.jsxs("button",{onClick:()=>K(le),disabled:n,className:"w-full text-left px-3 py-2 rounded-md hover:bg-violet-50 border border-transparent hover:border-violet-200 transition-colors disabled:opacity-50",children:[e.jsx("div",{className:"text-xs font-semibold text-slate-900",children:le.label}),e.jsx("div",{className:"text-[10px] text-slate-500 leading-snug",children:le.description}),ye&&e.jsxs("div",{className:"text-[10px] text-violet-700 font-mono leading-tight mt-0.5 flex items-center gap-1",children:[e.jsx(dt,{className:"w-2.5 h-2.5 flex-shrink-0","aria-hidden":"true"}),e.jsx("span",{className:"truncate",children:ye})]})]},le.id)}),e.jsxs("button",{onClick:()=>S(le=>!le),disabled:n,className:"w-full text-left px-3 py-2 rounded-md hover:bg-violet-50 border border-transparent hover:border-violet-200 transition-colors disabled:opacity-50",children:[e.jsxs("div",{className:"text-xs font-semibold text-slate-900 flex items-center gap-1",children:["Until specific date",e.jsx(Gt,{className:`w-3 h-3 text-slate-400 transition-transform ${j?"rotate-180":""}`})]}),e.jsx("div",{className:"text-[10px] text-slate-500",children:"Pick an exact end date (e.g. after a credential rotation finishes)."})]}),j&&e.jsxs("div",{className:"px-3 py-2 bg-slate-50 rounded-md border border-slate-200 space-y-2",children:[e.jsx("input",{type:"date",value:b,min:new Date().toISOString().slice(0,10),onChange:le=>f(le.target.value),className:"w-full text-xs px-2 py-1.5 border border-slate-300 rounded focus:outline-none focus:ring-1 focus:ring-violet-500"}),ke&&e.jsxs("div",{className:"text-[10px] text-violet-700 font-mono leading-tight flex items-center gap-1",children:[e.jsx(dt,{className:"w-2.5 h-2.5 flex-shrink-0","aria-hidden":"true"}),e.jsx("span",{className:"truncate",children:ke})]}),e.jsxs("button",{onClick:se,disabled:n||!b,className:"w-full text-xs font-semibold py-1.5 rounded bg-violet-600 hover:bg-violet-700 text-white disabled:opacity-50 disabled:cursor-not-allowed",children:["Snooze until ",b||"â¦"]})]})]}),e.jsxs("div",{className:"mt-3 pt-3 border-t border-slate-200",children:[e.jsxs("div",{className:"flex items-center justify-between mb-1",children:[e.jsx("label",{className:"block text-[10px] uppercase tracking-wider font-bold text-slate-500",children:"Reason (optional)"}),g.length>0&&e.jsx("button",{type:"button",onClick:Y,disabled:n,className:"text-[10px] text-slate-500 hover:text-slate-800 underline disabled:opacity-50",title:"Clear remembered reason",children:"Clear"})]}),e.jsx("input",{type:"text",value:g,onChange:le=>N(le.target.value.slice(0,200)),placeholder:"e.g. Holiday â back Jan 2",className:"w-full text-xs px-2 py-1.5 border border-slate-300 rounded focus:outline-none focus:ring-1 focus:ring-violet-500"}),e.jsx("div",{className:"text-[10px] text-slate-500 mt-1.5 leading-snug",children:"Stored on the snooze row for the audit trail. The most- recent reason is remembered on this device for next time."})]}),je&&e.jsxs("div",{className:"mt-3 pt-3 border-t border-slate-200",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[l&&e.jsxs("button",{type:"button",onClick:()=>_(le=>le==="save"?"none":"save"),disabled:n||i,className:"flex-1 text-[10px] font-semibold px-2 py-1.5 rounded border border-violet-300 bg-white hover:bg-violet-50 text-violet-700 disabled:opacity-50 inline-flex items-center justify-center gap-1",children:[w==="save"?e.jsx(Gt,{className:"w-3 h-3 rotate-180"}):e.jsx(Gl,{className:"w-3 h-3"}),"Save as template"]}),ue&&e.jsxs("button",{type:"button",onClick:()=>_(le=>le==="manage"?"none":"manage"),disabled:n||i,className:"flex-1 text-[10px] font-semibold px-2 py-1.5 rounded border border-slate-300 bg-white hover:bg-slate-50 text-slate-700 disabled:opacity-50 inline-flex items-center justify-center gap-1",children:[w==="manage"?e.jsx(Gt,{className:"w-3 h-3 rotate-180"}):e.jsx(kd,{className:"w-3 h-3"}),"Manage (",a.length,")"]})]}),w==="save"&&l&&e.jsxs("div",{className:"mt-2 px-3 py-2 bg-violet-50/40 border border-violet-200 rounded-md space-y-2",children:[e.jsx("div",{className:"text-[10px] uppercase tracking-wider font-bold text-violet-700",children:"New snooze template"}),e.jsx("input",{type:"text",value:C,onChange:le=>E(le.target.value.slice(0,80)),placeholder:'e.g. "Q3 credential rotation â 1 week"',className:"w-full text-xs px-2 py-1.5 border border-violet-300 rounded focus:outline-none focus:ring-1 focus:ring-violet-500",maxLength:80}),e.jsx("select",{value:P,onChange:le=>F(le.target.value),className:"w-full text-xs px-2 py-1.5 border border-violet-300 rounded bg-white focus:outline-none focus:ring-1 focus:ring-violet-500",children:Xy.map(le=>e.jsxs("option",{value:le.id,children:["Duration: ",le.label]},le.id))}),e.jsxs("div",{className:"text-[10px] text-slate-600 leading-snug",children:["Saves the current Reason (",g?`"${g.slice(0,40)}${g.length>40?"â¦":""}"`:"none",") and the chosen duration. The new chip appears at the end of the row."]}),e.jsxs("button",{type:"button",onClick:te,disabled:i||!C.trim(),className:"w-full text-xs font-semibold py-1.5 rounded bg-vi
1273olet-600 hover:bg-violet-700 text-white disabled:opacity-50 disabled:cursor-not-allowed inline-flex items-center justify-center gap-1",children:[i?e.jsx(de,{className:"w-3 h-3 animate-spin"}):e.jsx(xt,{className:"w-3 h-3"}),i?"Savingâ¦":"Save template"]})]}),w==="manage"&&ue&&e.jsxs("div",{className:"mt-2 px-2 py-2 bg-slate-50 border border-slate-200 rounded-md space-y-1.5",children:[m&&R.length>0&&(U?e.jsxs("div",{className:"bg-rose-50 border border-rose-200 rounded px-2 py-2 space-y-2",children:[e.jsxs("div",{className:"flex items-start gap-1.5 text-[10px] text-rose-900",children:[e.jsx(ve,{className:"w-3 h-3 flex-shrink-0 mt-0.5 text-rose-600"}),e.jsxs("div",{className:"min-w-0",children:[e.jsxs("div",{className:"font-bold",children:["Delete ",R.length," unused template",R.length===1?"":"s","?"]}),e.jsx("div",{className:"text-[9px] text-rose-700 mt-0.5 leading-snug",children:"These chips have never been applied and are >30 days old. This action cannot be undone â recreate by re-saving if needed."})]})]}),e.jsx("div",{className:"flex flex-wrap gap-1 px-0.5",children:T.map(le=>e.jsx("span",{className:"text-[9px] font-medium px-1.5 py-0.5 rounded-full border border-rose-300 bg-rose-100 text-rose-800 max-w-full truncate",title:le.reason?`Reason: ${le.reason}`:le.name,children:le.name},le.id))}),e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsxs("button",{type:"button",onClick:G,disabled:i,className:"flex-1 text-[10px] font-semibold px-2 py-1 rounded bg-rose-600 hover:bg-rose-700 text-white disabled:opacity-50 disabled:cursor-not-allowed inline-flex items-center justify-center gap-1",children:[i?e.jsx(de,{className:"w-3 h-3 animate-spin"}):e.jsx(va,{className:"w-3 h-3"}),i?"Pruningâ¦":`Delete ${R.length} chip${R.length===1?"":"s"}`]}),e.jsx("button",{type:"button",onClick:()=>q(!1),disabled:i,className:"flex-1 text-[10px] font-semibold px-2 py-1 rounded border border-slate-300 bg-white hover:bg-slate-50 text-slate-700 disabled:opacity-50",children:"Cancel"})]})]}):e.jsxs("div",{className:"bg-amber-50 border border-amber-200 rounded px-2 py-2 flex items-center justify-between gap-2 flex-wrap",children:[e.jsxs("div",{className:"flex items-start gap-1.5 text-[10px] text-amber-900 min-w-0",children:[e.jsx(ve,{className:"w-3 h-3 flex-shrink-0 mt-0.5 text-amber-600"}),e.jsxs("span",{children:[e.jsxs("span",{className:"font-bold",children:[R.length," unused template",R.length===1?"":"s"]})," ","can be pruned (never clicked, >30 days old)."]})]}),e.jsxs("button",{type:"button",onClick:()=>q(!0),disabled:i,className:"text-[10px] font-semibold px-2 py-1 rounded border border-amber-400 bg-white hover:bg-amber-100 text-amber-800 disabled:opacity-50 inline-flex items-center gap-1 flex-shrink-0",title:"Review which templates would be deleted before confirming",children:[e.jsx(va,{className:"w-3 h-3"}),"Review & prune"]})]})),e.jsx("div",{className:"text-[10px] uppercase tracking-wider font-bold text-slate-600 px-1 mb-1",children:"Rename / delete / reorder"}),z.map((le,ye)=>{const we=I===le.id,He=ye===0,Lt=ye===z.length-1;return e.jsxs("div",{className:"bg-white border border-slate-200 rounded px-2 py-1.5 flex items-center gap-1.5",children:[e.jsxs("div",{className:"flex flex-col gap-0.5",children:[e.jsx("button",{type:"button",onClick:()=>p==null?void 0:p(le.id,"up"),disabled:He||i||!p,className:"text-slate-400 hover:text-slate-700 disabled:opacity-30 disabled:cursor-not-allowed",title:"Move up","aria-label":"Move up",children:e.jsx(Gt,{className:"w-3 h-3 rotate-180"})}),e.jsx("button",{type:"button",onClick:()=>p==null?void 0:p(le.id,"down"),disabled:Lt||i||!p,className:"text-slate-400 hover:text-slate-700 disabled:opacity-30 disabled:cursor-not-allowed",title:"Move down","aria-label":"Move down",children:e.jsx(Gt,{className:"w-3 h-3"})})]}),e.jsx("div",{className:"flex-1 min-w-0",children:we?e.jsx("input",{type:"text",value:L,onChange:ut=>V(ut.target.value.slice(0,80)),onKeyDown:ut=>{ut.key==="Enter"?(ut.preventDefault(),pe(le.id)):ut.key==="Escape"&&(D(null),V(""))},autoFocus:!0,className:"w-full text-[11px] px-1.5 py-0.5 border border-violet-400 rounded focus:outline-none focus:ring-1 focus:ring-violet-500",maxLength:80}):e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"text-[11px] font-semibold text-slate-900 truncate",title:le.name,children:le.name}),e.jsxs("div",{className:"text-[9px] text-slate-500 truncate",children:[bE(le),le.reason?` · "${le.reason.slice(0,30)}${le.reason.length>30?"â¦":""}"`:""]}),e.jsx("div",{className:"mt-0.5",children:e.jsx("span",{className:"inline-block text-[9px] font-medium px-1.5 py-0.5 rounded bg-slate-100 text-slate-600",title:le.last_applied_at?`Last applied: ${Rs(le.last_applied_at)}`:"This template has never been applied.",children:Bne(le)})})]})}),e.jsx("div",{className:"flex items-center gap-0.5 flex-shrink-0",children:we?e.jsxs(e.Fragment,{children:[e.jsx("button",{type:"button",onClick:()=>pe(le.id),disabled:i||!L.trim(),className:"p-1 text-emerald-600 hover:bg-emerald-50 rounded disabled:opacity-50",title:"Save","aria-label":"Save rename",children:e.jsx(xt,{className:"w-3 h-3"})}),e.jsx("button",{type:"button",onClick:()=>{D(null),V("")},disabled:i,className:"p-1 text-slate-500 hover:bg-slate-100 rounded disabled:opacity-50",title:"Cancel","aria-label":"Cancel rename",children:e.jsx(Ke,{className:"w-3 h-3"})})]}):e.jsxs(e.Fragment,{children:[c&&e.jsx("button",{type:"button",onClick:()=>{D(le.id),V(le.name)},disabled:i,className:"p-1 text-slate-500 hover:text-slate-800 hover:bg-slate-100 rounded disabled:opacity-50",title:"Rename","aria-label":"Rename template",children:e.jsx(kd,{className:"w-3 h-3"})}),u&&e.jsx("button",{type:"button",onClick:()=>{u(le.id)},disabled:i,className:"p-1 text-rose-500 hover:text-rose-700 hover:bg-rose-50 rounded disabled:opacity-50",title:"Delete template","aria-label":"Delete template",children:e.jsx(va,{className:"w-3 h-3"})})]})})]},le.id)}),e.jsx("div",{className:"text-[9px] text-slate-500 px-1 mt-1 leading-snug",children:"Arrows reorder · gear renames · trash deletes (no undo)."})]})]})]})]})}function Kne({currentUntilIso:t,onExtend:s,mutating:n,anyMutating:a}
1273){const[r,i]=d.useState(!1),[o,l]=d.useState(()=>{const N=new Date(t).getTime(),b=Number.isFinite(N)?N:Date.now();return new Date(b+864e5).toISOString().slice(0,10)}),[c,u]=d.useState(()=>Date.now());d.useEffect(()=>{if(!r)return;u(Date.now());const N=window.setInterval(()=>u(Date.now()),3e4);return()=>window.clearInterval(N)},[r]);const p=d.useRef(null);d.useEffect(()=>{if(!r)return;const N=b=>{p.current&&!p.current.contains(b.target)&&i(!1)};return document.addEventListener("mousedown",N),()=>document.removeEventListener("mousedown",N)},[r]);const m=[{id:"+1h",label:"+1 hour",ms:60*6e4,description:"Extend by one hour beyond the current end."},{id:"+1d",label:"+1 day",ms:24*60*6e4,description:"Extend by 24 hours â useful for a delayed migration."},{id:"+1w",label:"+1 week",ms:7*24*60*6e4,description:"Extend by a full week â for vacations or longer freezes."}],x=N=>{const b=new Date(t).getTime(),f=Number.isFinite(b)&&b>Date.now()?b:Date.now(),j=new Date(f+N).toISOString();return Rh(j)},h=(()=>{if(!o)return"";try{const N=new Date(`${o}T23:59:59`).toISOString();return Rh(N)}catch{return""}})(),y=async(N,b)=>{await s({extendMs:N,presetLabel:b})&&i(!1)},v=async()=>{if(!o)return;const N=new Date(`${o}T23:59:59`).toISOString();await s({absoluteIso:N,presetLabel:`until ${o}`})&&i(!1)},g=(()=>{const N=new Date(t).getTime();return Number.isFinite(N)?new Date(N+864e5).toISOString().slice(0,10):new Date().toISOString().slice(0,10)})();return e.jsxs("div",{ref:p,className:"relative inline-block",children:[e.jsxs("button",{type:"button",onClick:()=>i(N=>!N),disabled:a,className:"text-[11px] font-semibold text-indigo-700 hover:text-indigo-900 underline disabled:opacity-50 disabled:cursor-not-allowed inline-flex items-center gap-1",title:"Extend this snooze without creating a new audit row",children:[n?e.jsx(de,{className:"w-3 h-3 animate-spin"}):e.jsx(dt,{className:"w-3 h-3"}),n?"Extendingâ¦":"Extend snooze",e.jsx(Gt,{className:`w-3 h-3 transition-transform ${r?"rotate-180":""}`})]}),r&&e.jsxs("div",{className:"absolute right-0 bottom-full mb-1 w-72 bg-white border border-slate-300 rounded-lg shadow-lg z-30 p-3",children:[e.jsx("div",{className:"text-[10px] uppercase tracking-wider font-bold text-slate-500 mb-2",children:"Stack additional time"}),e.jsx("div",{className:"text-[10px] text-slate-500 leading-snug mb-2",children:"Adds to the CURRENT end time. The original audit row is updated in place â no new snooze is created."}),e.jsxs("div",{className:"space-y-1",children:[m.map(N=>{const b=x(N.ms);return e.jsxs("button",{onClick:()=>y(N.ms,N.label),disabled:a,className:"w-full text-left px-3 py-2 rounded-md hover:bg-indigo-50 border border-transparent hover:border-indigo-200 transition-colors disabled:opacity-50",children:[e.jsx("div",{className:"text-xs font-semibold text-slate-900",children:N.label}),e.jsx("div",{className:"text-[10px] text-slate-500 leading-snug",children:N.description}),b&&e.jsxs("div",{className:"text-[10px] text-indigo-700 font-mono leading-tight mt-0.5 flex items-center gap-1",children:[e.jsx(dt,{className:"w-2.5 h-2.5 flex-shrink-0","aria-hidden":"true"}),e.jsxs("span",{className:"truncate",children:["â ",b]})]})]},N.id)}),e.jsxs("div",{className:"px-3 py-2 bg-slate-50 rounded-md border border-slate-200 space-y-2 mt-1",children:[e.jsx("div",{className:"text-[10px] uppercase tracking-wider font-bold text-slate-500",children:"Or extend until a specific date"}),e.jsx("input",{type:"date",value:o,min:g,onChange:N=>l(N.target.value),className:"w-full text-xs px-2 py-1.5 border border-slate-300 rounded focus:outline-none focus:ring-1 focus:ring-indigo-500"}),h&&e.jsxs("div",{className:"text-[10px] text-indigo-700 font-mono leading-tight flex items-center gap-1",children:[e.jsx(dt,{className:"w-2.5 h-2.5 flex-shrink-0","aria-hidden":"true"}),e.jsxs("span",{className:"truncate",children:["â ",h]})]}),e.jsxs("button",{onClick:v,disabled:a||!o,className:"w-full text-xs font-semibold py-1.5 rounded bg-indigo-600 hover:bg-indigo-700 text-white disabled:opacity-50 disabled:cursor-not-allowed",children:["Extend until ",o||"â¦"]})]})]})]})]})}function vE({label:t,badgeColor:s,atIso:n,days:a,allLive:r}){let i="bg-slate-300";return a!==null&&(a<7?i="bg-emerald-500":a<=14?i="bg-amber-500":i="bg-rose-500"),e.jsxs("div",{className:"bg-white/80 border border-slate-200 rounded-lg px-3 py-2 min-w-[180px]",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[e.jsx("span",{className:`text-[10px] font-bold px-1.5 py-0.5 rounded border ${s}`,children:t}),e.jsx("span",{className:`w-2 h-2 rounded-full ${i}`,"aria-hidden":"true"}),r===!0&&e.jsx("span",{className:"text-[9px] font-bold px-1 py-0.5 rounded bg-emerald-50 text-emerald-700 border border-emerald-200",children:"LIVE"}),r===!1&&e.jsx("span",{className:"text-[9px] font-bold px-1 py-0.5 rounded bg-rose-50 text-rose-700 border border-rose-200",children:"PARTIAL"})]}),e.jsx("div",{className:"text-xs font-semibold text-slate-900",children:wa(n)}),e.jsx("div",{className:"text-[10px] text-slate-500 mt-0.5 font-mono",children:n?Rs(n):"no audit rows yet"})]})}function Qne({history:t,open:s,onOpenChange:n,panelRef:a,highlightedSnoozeId:r,lookupNotice:i,onClearLookupNotice:o,onManageRecurring:l}){if(!t||t.length===0)return null;const c=t.map(j=>({row:j,lifecycle:O8(j)})),u=j=>j==="recurring-template"?0:1,p=[...c].sort((j,S)=>{const w=u(j.lifecycle),_=u(S.lifecycle);if(w!==_)return w-_;const C=new Date(j.row.created_at).getTime(),E=new Date(S.row.created_at).getTime();return!Number.isFinite(C)&&!Number.isFinite(E)?0:Number.isFinite(C)?Number.isFinite(E)?E-C:-1:1}),m=p.filter(j=>j.lifecycle==="active").length,x=p.filter(j=>j.lifecycle==="cancelled").length,h=p.filter(j=>j.lifecycle==="expired").length,y=p.filter(j=>j.lifecycle==="recurring-template").length,v=p.length-y,g=y>0,[N,b]=d.useState(0);d.useEffect(()=>{if(!s||!g)return;let j=null;const S=()=>{j===null&&(j=window.setInterval(()=>{b(C=>C+1)},6e4))},w=()=>{j!==null&&(window.clearInterval(j),j=null)},_=()=>{document.hidden?w():(b(C=>C+1),S())};return document.hidden||S(),document.addEventListener("visibilitychange",_),()=>{document.removeEventListener("visibilitychange",_),w()}},[s,g]);const f=()=>{const S=[["snooze_id","lifecycle_status","created_at","snoozed_until","cancelled_at","snoozed_by","cancelled_by","reason"].join(",")];for(const{row:P,lifecycle:F}of p)S.push([P.id,F,P.created_at,P.snoozed_until,P.cancelled_at,P.snoozed_by,P.cancelled_by,P.reason].map(L8).join(","));const w=S.join(` 1274`),_=new Blob([w],{type:"text/csv;charset=utf-8;"}),C=URL.createObjectURL(_),E=document.createElement("a");E.href=C,E.download=`stale_compliance_alert_snoozes_${new Date().toISOString().slice(0,10)}.csv`,document.body.appendChild(E),E.click(),document.body.removeChild(E),URL.revokeObjectURL(C)};return e.jsxs("div",{ref:a,className:"mt-3 bg-white border border-slate-200 rounded-xl shadow-sm overflow-hidden",children:[e.jsxs("button",{type:"button",onClick:()=>n(!s),className:"w-full px-4 py-3 flex items-center justify-between gap-3 hover:bg-slate-50 transition-colors text-left","aria-expanded":s,children:[e.jsxs("div",{className:"flex items-center gap-3 min-w-0",children:[e.jsx("div",{className:"p-1.5 rounded-md bg-slate-100 flex-shrink-0",children:e.jsx(en,{className:"w-4 h-4 text-slate-600"})}),e.jsxs("div",{className:"min-w-0",children:[e.jsxs("div",{className:"text-sm font-bold text-slate-900 flex items-center gap-2 flex-wrap",children:["Snooze history",e.jsxs("span",{className:"text-[10px] font-bold uppercase tracking-wider text-slate-500",children:[t.length," ",t.length===1?"entry":"entries"]})]}),e.jsxs("div",{className:"text-[11px] text-slate-600 mt-0.5 flex items-center gap-2 flex-wrap",children:[m>0&&e.jsxs("span",{className:"inline-flex items-center gap-1 px-1.5 py-0.5 rounded bg-vi
1274olet-50 border border-violet-200 text-violet-800 font-semibold",children:[e.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-violet-500","aria-hidden":"true"}),m," active"]}),x>0&&e.jsxs("span",{className:"inline-flex items-center gap-1 px-1.5 py-0.5 rounded bg-slate-100 border border-slate-200 text-slate-700 font-semibold",children:[e.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-slate-500","aria-hidden":"true"}),x," cancelled"]}),h>0&&e.jsxs("span",{className:"inline-flex items-center gap-1 px-1.5 py-0.5 rounded bg-emerald-50 border border-emerald-200 text-emerald-800 font-semibold",children:[e.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-emerald-500","aria-hidden":"true"}),h," expired"]}),e.jsx("span",{className:"text-slate-500 hidden sm:inline",children:"· Audit trail of past stale-alert snoozes (post-incident reviews & quarterly compliance)"})]})]})]}),e.jsx(Gt,{className:`w-4 h-4 text-slate-500 flex-shrink-0 transition-transform ${s?"rotate-180":""}`})]}),i&&e.jsxs("div",{className:"mx-4 mb-3 -mt-1 bg-amber-50 border border-amber-200 rounded-md px-3 py-2 flex items-start justify-between gap-2",children:[e.jsxs("div",{className:"flex items-start gap-2 text-[11px] text-amber-900",children:[e.jsx(ve,{className:"w-3.5 h-3.5 flex-shrink-0 mt-0.5 text-amber-600"}),e.jsx("span",{children:i})]}),e.jsx("button",{onClick:o,className:"text-[10px] text-amber-800 hover:text-amber-900 underline whitespace-nowrap",children:"Dismiss"})]}),s&&e.jsxs("div",{className:"border-t border-slate-200",children:[e.jsxs("div",{className:"px-4 py-2 bg-slate-50 border-b border-slate-200 flex items-center justify-between gap-2 flex-wrap",children:[e.jsx("div",{className:"text-[11px] text-slate-600",children:g?e.jsxs(e.Fragment,{children:["Recurring schedules first, then chronological history (newest first by"," ",e.jsx("code",{className:"bg-white px-1 rounded",children:"created_at"}),"). Cancelled rows show who ended the snooze early; expired rows ran to completion."]}):e.jsxs(e.Fragment,{children:["Sorted newest first by ",e.jsx("code",{className:"bg-white px-1 rounded",children:"created_at"}),". Cancelled rows show who ended the snooze early; expired rows ran to completion."]})}),e.jsxs("button",{type:"button",onClick:f,className:"text-[11px] font-semibold text-slate-700 hover:text-slate-900 inline-flex items-center gap-1 px-2 py-1 rounded border border-slate-300 bg-white hover:bg-slate-50 transition-colors",children:[e.jsx(us,{className:"w-3 h-3"}),"Export CSV (",t.length,")"]})]}),e.jsx("div",{className:"overflow-x-auto",children:e.jsxs("table",{className:"w-full text-[11px]",children:[e.jsx("thead",{children:e.jsxs("tr",{className:"bg-slate-50 border-b border-slate-200 text-left text-[10px] uppercase tracking-wider font-bold text-slate-600",children:[e.jsx("th",{className:"px-3 py-2 whitespace-nowrap",children:"Status"}),e.jsx("th",{className:"px-3 py-2 whitespace-nowrap",children:"Created at"}),e.jsx("th",{className:"px-3 py-2 whitespace-nowrap",children:"Snoozed until"}),e.jsx("th",{className:"px-3 py-2 whitespace-nowrap",children:"Cancelled at"}),e.jsx("th",{className:"px-3 py-2 whitespace-nowrap",children:"Snoozed by"}),e.jsx("th",{className:"px-3 py-2 whitespace-nowrap",children:"Cancelled by"}),e.jsx("th",{className:"px-3 py-2",children:"Reason"})]})}),e.jsxs("tbody",{children:[y>0&&e.jsx("tr",{className:"bg-indigo-50 border-y-2 border-indigo-200",children:e.jsx("td",{colSpan:7,className:"px-3 py-1.5 text-[10px] uppercase tracking-wider font-bold text-indigo-700",children:e.jsxs("span",{className:"inline-flex items-center gap-1.5",children:[e.jsx(Bu,{className:"w-3 h-3","aria-hidden":"true"}),"Recurring schedules",e.jsxs("span",{className:"text-indigo-500 font-semibold normal-case tracking-normal",children:["(",y," active template",y===1?"":"s",' â scan the "Next:" labels to see which will fire soonest)']})]})})}),p.slice(0,y).map(({row:j,lifecycle:S})=>e.jsx(jE,{row:j,lifecycle:S,highlighted:j.id===r&&S!=="recurring-template",onManageRecurring:l,tick:N},j.id)),y>0&&v>0&&e.jsx("tr",{className:"bg-slate-100 border-y-2 border-slate-300",children:e.jsx("td",{colSpan:7,className:"px-3 py-1.5 text-[10px] uppercase tracking-wider font-bold text-slate-600",children:e.jsxs("span",{className:"inline-flex items-center gap-1.5",children:[e.jsx(en,{className:"w-3 h-3","aria-hidden":"true"}),"Chronological history",e.jsxs("span",{className:"text-slate-500 font-semibold normal-case tracking-normal",children:["(",v," one-shot row",v===1?"":"s"," ","â newest first)"]})]})})}),p.slice(y).map(({row:j,lifecycle:S})=>e.jsx(jE,{row:j,lifecycle:S,highlighted:j.id===r&&S!=="recurring-template",onManageRecurring:l,tick:N},j.id))]})]})}),e.jsxs("div",{className:"px-4 py-2 bg-slate-50 border-t border-slate-200 text-[10px] text-slate-500",children:["Rows from"," ",e.jsx("code",{className:"bg-white px-1 rounded",children:"stale_compliance_alert_snoozes"}),". Checked on every tick of"," ",e.jsx("code",{className:"bg-white px-1 rounded",children:"cron-weekly-deployment-audit"})," before the cooldown / send decision. Snoozes are never deleted â cancelling sets"," ",e.jsx("code",{className:"bg-white px-1 rounded",children:"cancelled_at = now()"})," so the audit trail remains intact. Rows linked from the verification timeline's"," ",e.jsxs("span",{className:"inline-flex items-center gap-0.5",children:[e.jsx(Xs,{className:"w-2.5 h-2.5 inline"}),"View snooze â"]})," ","affordance briefly ring violet to flag the responsible snooze."]})]})]})}const Jne={SU:0,MO:1,TU:2,WE:3,TH:4,FR:5,SA:6},B8=["Sun","Mon","Tue","Wed","Thu","Fri","Sat"];
1274function _c(t,s){const n=t[s];if(n==null)return null;const a=n.trim();return a.length>0?a:null}function Xne(t){const s={},n=t.split(/[\r\n]+/);for(const a of n){const r=a.trim();if(!r)continue;let i=r;if(/^RRULE:/i.test(i))i=i.slice(6);else if(/^DURATION:/i.test(i))continue;const o=i.split(";");for(const l of o){const c=l.trim();if(!c||/^DURATION=/i.test(c))continue;const u=c.indexOf("=");if(u<=0)continue;const p=c.slice(0,u).trim().toUpperCase(),m=c.slice(u+1).trim();p&&(s[p]=m)}}return s}function ph(t){if(t<=0)return"now";const s=Math.floor(t/6e4);if(s<1)return"in <1 minute";if(s<60)return`in ${s} ${s===1?"minute":"minutes"}`;const n=Math.floor(s/60);if(n<24)return`in ${n} ${n===1?"hour":"hours"}`;const a=Math.floor(n/24);if(a===1)return"tomorrow";if(a<14)return`in ${a} days`;const r=Math.floor(a/7);if(r<8)return`in ${r} ${r===1?"week":"weeks"}`;const i=Math.floor(a/30);if(i<12)return`in ${i} ${i===1?"month":"months"}`;const o=Math.floor(a/365);return`in ${o} ${o===1?"year":"years"}`}function vg(t){const s=B8[t.getUTCDay()],n=String(t.getUTCHours()).padStart(2,"0"),a=String(t.getUTCMinutes()).padStart(2,"0");return`${s} ${n}:${a} UTC`}function eae(t,s){if(!t||typeof t!="string"||t.trim().length===0)return null;const n=Xne(t),a=(_c(n,"FREQ")||"").toUpperCase();if(a!=="WEEKLY"&&a!=="MONTHLY"&&a!=="YEARLY"&&a!=="DAILY")return null;const r=_c(n,"BYHOUR"),i=_c(n,"BYMINUTE"),o=r?parseInt(r.split(",")[0],10):0,l=i?parseInt(i.split(",")[0],10):0;if(!Number.isFinite(o)||o<0||o>23||!Number.isFinite(l)||l<0||l>59)return null;const c=s.getTime();if(a==="WEEKLY"){const u=_c(n,"BYDAY"),p=u?u.split(",").map(x=>x.trim().toUpperCase()).filter(x=>x.length>0):[B8[s.getUTCDay()].slice(0,2).toUpperCase()];let m=null;for(const x of p){const h=Jne[x];if(h===void 0)continue;const y=new Date(Date.UTC(s.getUTCFullYear(),s.getUTCMonth(),s.getUTCDate(),o,l,0,0)),v=y.getUTCDay();let g=(h-v+7)%7;g===0&&y.getTime()<=c&&(g=7),g>0&&y.setUTCDate(y.getUTCDate()+g),!(y.getTime()<=c)&&(m===null||y.getTime()<m.getTime())&&(m=y)}return m?{nextOccurrenceUtc:m,label:`${vg(m)} · ${ph(m.getTime()-c)}`}:null}if(a==="DAILY"){const u=new Date(Date.UTC(s.getUTCFullYear(),s.getUTCMonth(),s.getUTCDate(),o,l,0,0));return u.getTime()<=c&&u.setUTCDate(u.getUTCDate()+1),{nextOccurrenceUtc:u,label:`${vg(u)} · ${ph(u.getTime()-c)}`}}if(a==="MONTHLY"){const u=_c(n,"BYMONTHDAY"),p=u?parseInt(u.split(",")[0],10):1;if(!Number.isFinite(p)||p<1||p>31)return null;const m=(h,y)=>{const v=new Date(Date.UTC(h,y+1,0)).getUTCDate(),g=Math.min(p,v);return new Date(Date.UTC(h,y,g,o,l,0,0))};let x=m(s.getUTCFullYear(),s.getUTCMonth());if(x.getTime()<=c){const h=s.getUTCMonth()+1,y=s.getUTCFullYear()+Math.floor(h/12);x=m(y,h%12)}return x.getTime()<=c?null:{nextOccurrenceUtc:x,label:`${vg(x)} · ${ph(x.getTime()-c)}`}}if(a==="YEARLY"){const u=_c(n,"BYMONTH"),p=_c(n,"BYMONTHDAY"),m=u?parseInt(u.split(",")[0],10):1,x=p?parseInt(p.split(",")[0],10):1;if(!Number.isFinite(m)||m<1||m>12||!Number.isFinite(x)||x<1||x>31)return null;const h=v=>{const g=new Date(Date.UTC(v,m,0)).getUTCDate(),N=Math.min(x,g);return new Date(Date.UTC(v,m-1,N,o,l,0,0))};let y=h(s.getUTCFullYear());return y.getTime()<=c&&(y=h(s.getUTCFullYear()+1)),y.getTime()<=c?null:{nextOccurrenceUtc:y,label:`${vg(y)} · ${ph(y.getTime()-c)}`}}return null}function jE({row:t,lifecycle:s,highlighted:n,onManageRecurring:a,tick:r}){const i=d.useRef(null);d.useEffect(()=>{!n||!i.current||i.current.scrollIntoView({behavior:"smooth",block:"center"})},[n]);const o=d.useMemo(()=>{if(s!=="recurring-template"||!t.recurrence_rule)return null;try{return eae(t.recurrence_rule,new Date)}catch(p){return console.warn("[snooze-history-row] RRULE parse failed:",p,t.recurrence_rule),null}},[t.recurrence_rule,s,r]),c={active:{badge:"bg-violet-100 text-violet-800 border-violet-300",rowBg:"bg-violet-50/30",label:"ACTIVE",dot:"bg-violet-500"},cancelled:{badge:"bg-slate-200 text-slate-700 border-slate-300",rowBg:"",label:"CANCELLED",dot:"bg-slate-500"},expired:{badge:"bg-emerald-100 text-emerald-800 border-emerald-300",rowBg:"",label:"EXPIRED",dot:"bg-emerald-500"},"recurring-template":{badge:"bg-indigo-100 text-indigo-800 border-indigo-300",rowBg:"bg-indigo-50/30",label:"RECURRING",dot:"bg-indigo-500"}}[s]??{badge:"bg-slate-100 text-slate-700 border-slate-300",rowBg:"",label:s.toUpperCase(),dot:"bg-slate-400"}
1274,u=n?"ring-2 ring-violet-500 ring-offset-1 bg-violet-100 animate-pulse":"";return e.jsxs("tr",{ref:i,className:`border-b border-slate-100 last:border-b-0 hover:bg-slate-50/60 transition-colors ${c.rowBg} ${u}`,"data-snooze-row-id":t.id,"data-snooze-highlighted":n?"true":void 0,children:[e.jsxs("td",{className:"px-3 py-2 align-top",children:[e.jsxs("div",{className:"flex items-center gap-1.5 flex-wrap",children:[e.jsxs("span",{className:`inline-flex items-center gap-1 text-[9px] font-bold px-1.5 py-0.5 rounded border ${c.badge}`,children:[e.jsx("span",{className:`w-1.5 h-1.5 rounded-full ${c.dot}`,"aria-hidden":"true"}),c.label]}),s==="recurring-template"&&a&&e.jsxs("button",{type:"button",onClick:()=>a(t.id),className:"inline-flex items-center gap-1 text-[9px] font-bold px-1.5 py-0.5 rounded border bg-indigo-100 hover:bg-indigo-200 text-indigo-800 border-indigo-300 transition-colors",title:"Open the management modal for this recurring schedule","aria-label":"Manage recurring schedule",children:[e.jsx(kd,{className:"w-2.5 h-2.5"}),"Manage"]})]}),s==="recurring-template"&&e.jsxs("div",{className:"mt-1 text-[9px] text-indigo-700 font-medium leading-tight flex items-center gap-1 flex-wrap",title:o?`Next activation: ${Rs(o.nextOccurrenceUtc.toISOString())}`:"Could not parse the recurrence rule â open Manage to inspect.",children:[e.jsx(dt,{className:"w-2.5 h-2.5 text-indigo-500 flex-shrink-0","aria-hidden":"true"}),e.jsx("span",{className:"font-bold uppercase tracking-wider text-[8px] text-indigo-500",children:"Next:"}),o?e.jsx("span",{className:"font-mono normal-case tracking-normal text-indigo-800",children:o.label}):e.jsx("span",{className:"text-slate-400",children:"â"})]})]}),e.jsxs("td",{className:"px-3 py-2 align-top whitespace-nowrap",children:[e.jsx("div",{className:"text-slate-900 font-semibold",children:wa(t.created_at)}),e.jsx("div",{className:"text-[10px] text-slate-500 font-mono",children:Rs(t.created_at)})]}),e.jsxs("td",{className:"px-3 py-2 align-top whitespace-nowrap",children:[e.jsx("div",{className:"text-slate-900 font-semibold",children:wa(t.snoozed_until)}),e.jsx("div",{className:"text-[10px] text-slate-500 font-mono",children:Rs(t.snoozed_until)})]}),e.jsx("td",{className:"px-3 py-2 align-top whitespace-nowrap",children:t.cancelled_at?e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"text-slate-900 font-semibold",children:wa(t.cancelled_at)}),e.jsx("div",{className:"text-[10px] text-slate-500 font-mono",children:Rs(t.cancelled_at)})]}):e.jsx("span",{className:"text-slate-400",children:"â"})}),e.jsx("td",{className:"px-3 py-2 align-top whitespace-nowrap",children:e.jsx("span",{className:"text-slate-800 font-mono text-[10px]",children:t.snoozed_by||"â"})}),e.jsx("td",{className:"px-3 py-2 align-top whitespace-nowrap",children:t.cancelled_by?e.jsx("span",{className:"text-slate-800 font-mono text-[10px]",children:t.cancelled_by}):e.jsx("span",{className:"text-slate-400",children:"â"})}),e.jsx("td",{className:"px-3 py-2 align-top",children:t.reason?e.jsxs("span",{className:"text-slate-700 italic break-words max-w-[280px] inline-block",children:['"',t.reason,'"']}):e.jsx("span",{className:"text-slate-400",children:"â"})})]})}function tae({state:t,onConfirm:s,onDismiss:n}){const r={loading:{container:"bg-gradient-to-r from-slate-50 via-slate-50 to-slate-100 border-slate-300",iconBg:"from-slate-500 to-slate-600",icon:e.jsx(de,{className:"w-5 h-5 text-white animate-spin"}),headline:"Loading snooze detailsâ¦",subhead:`Looking up snooze ${t.snoozeId.slice(0,8)}⦠to verify it's the right one before cancelling.`},found:{container:"bg-gradient-to-r from-violet-50 via-purple-50 to-indigo-50 border-violet-300",iconBg:"from-violet-500 to-indigo-600",icon:e.jsx(Zx,{className:"w-5 h-5 text-white"}),headline:"Confirm snooze cancellation",subhead:'You arrived from a "Cancel snooze" email link. Review the snooze details below, then click Confirm to end it (or Dismiss to keep it active).'},"already-cancelled":{container:"bg-gradient-to-r from-slate-50 via-slate-100 to-slate-50 border-slate-300",iconBg:"from-slate-500 to-slate-600",icon:e.jsx(Ke,{className:"w-5 h-5 text-white"}),headline:"This snooze was already cancelled",subhead:"Someone (possibly you, or another teammate using the same email link) cancelled this snooze before you arrived. No further action is required."},"already-expired":{container:"bg-gradient-to-r from-slate-50 via-slate-100 to-slate-50 border-slate-300",iconBg:"from-slate-500 to-slate-600",icon:e.jsx(dt,{className:"w-5 h-5 text-white"}),headline:"This snooze has already expired",subhead:"The snooze ran to its full duration and is no longer suppressing alerts. Stale-compliance emails are once again eligible to fire."},"not-found":{container:"bg-gradient-to-r from-amber-50 via-yellow-50 to-orange-50 border-amber-300",iconBg:"from-
1274amber-500 to-orange-600",icon:e.jsx(ve,{className:"w-5 h-5 text-white"}),headline:"Snooze not found",subhead:`No snooze with id ${t.snoozeId.slice(0,8)}⦠exists in the database. The email link may be malformed or the row may have been removed.`},confirming:{container:"bg-gradient-to-r from-violet-50 via-purple-50 to-indigo-50 border-violet-300",iconBg:"from-violet-500 to-indigo-600",icon:e.jsx(de,{className:"w-5 h-5 text-white animate-spin"}),headline:"Cancelling snoozeâ¦",subhead:"Writing cancelled_at to stale_compliance_alert_snoozes. Alerts will resume on the next cron tick once this completes."},success:{container:"bg-gradient-to-r from-emerald-50 via-green-50 to-teal-50 border-emerald-300",iconBg:"from-emerald-500 to-teal-600",icon:e.jsx(Ue,{className:"w-5 h-5 text-white"}),headline:"Snooze cancelled",subhead:"Stale-compliance alerts are now eligible to fire again. This banner will close automatically in a few seconds."},error:{container:"bg-rose-50 border-rose-300",iconBg:"from-rose-500 to-red-600",icon:e.jsx(kt,{className:"w-5 h-5 text-white"}),headline:"Cancellation failed",subhead:t.errorMessage||"An unknown error occurred while cancelling the snooze. You can try again."}}[t.status],i=t.status==="found"||t.status==="error",o=t.status==="error"?"Retry cancellation":"Confirm cancellation",l=t.status==="confirming";return e.jsx("div",{className:`border rounded-xl p-5 shadow-md ${r.container}`,children:e.jsxs("div",{className:"flex items-start gap-4",children:[e.jsx("div",{className:`p-2 rounded-lg bg-gradient-to-br ${r.iconBg} flex-shrink-0`,children:r.icon}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-start justify-between gap-3",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("div",{className:"text-sm font-bold text-slate-900",children:r.headline}),e.jsx("div",{className:"text-xs text-slate-700 mt-1",children:r.subhead})]}),e.jsx("button",{type:"button",onClick:n,className:"flex-shrink-0 p-1 rounded hover:bg-white/60 text-slate-500 hover:text-slate-700 transition-colors","aria-label":"Dismiss banner",title:"Dismiss",children:e.jsx(Ke,{className:"w-4 h-4"})})]}),t.row&&e.jsxs("div",{className:"mt-3 pt-3 border-t border-white/60 grid grid-cols-1 sm:grid-cols-2 md:grid-cols-3 gap-3 text-[11px]",children:[e.jsxs("div",{className:"flex flex-col",children:[e.jsx("span",{className:"text-[10px] uppercase tracking-wider font-bold text-slate-500",children:"Snooze ID"}),e.jsx("span",{className:"text-slate-800 font-mono text-[10px] truncate",title:t.row.id,children:t.row.id})]}),e.jsxs("div",{className:"flex flex-col",children:[e.jsx("span",{className:"text-[10px] uppercase tracking-wider font-bold text-slate-500",children:"Created"}),e.jsx("span",{className:"text-slate-800",children:wa(t.row.created_at)}),e.jsx("span",{className:"text-[10px] text-slate-500 font-mono",children:Rs(t.row.created_at)})]}),e.jsxs("div",{className:"flex flex-col",children:[e.jsx("span",{className:"text-[10px] uppercase tracking-wider font-bold text-slate-500",children:"Snoozed until"}),e.jsx("span",{className:"text-slate-800",children:wa(t.row.snoozed_until)}),e.jsx("span",{className:"text-[10px] text-slate-500 font-mono",children:Rs(t.row.snoozed_until)})]}),t.row.snoozed_by&&e.jsxs("div",{className:"flex flex-col",children:[e.jsx("span",{className:"text-[10px] uppercase tracking-wider font-bold text-slate-500",children:"Snoozed by"}),e.jsx("span",{className:"text-slate-800 font-mono text-[10px]",children:t.row.snoozed_by})]}),t.row.cancelled_at&&e.jsxs("div",{className:"flex flex-col",children:[e.jsx("span",{className:"text-[10px] uppercase tracking-wider font-bold text-slate-500",children:"Cancelled at"}),e.jsx("span",{className:"text-slate-800",children:wa(t.row.cancelled_at)}),e.jsx("span",{className:"text-[10px] text-slate-500 font-mono",children:Rs(t.row.cancelled_at)})]}),t.row.cancelled_by&&e.jsxs("div",{className:"flex flex-col",children:[e.jsx("span",{className:"text-[10px] uppercase tracking-wider font-bold text-slate-500",children:"Cancelled by"}),e.jsx("span",{className:"text-slate-800 font-mono text-[10px]",children:t.row.cancelled_by})]}),t.row.reason&&e.jsxs("div",{className:"flex flex-col col-span-1 sm:col-span-2 md:col-span-3 min-w-0",children:[e.jsx("span",{className:"text-[10px] uppercase tracking-wider font-bold text-slate-500",children:"Reason"}),e.jsxs("span",{className:"text-slate-800 italic break-words",children:['"',t.row.reason,'"']}
1274)]})]}),i&&e.jsxs("div",{className:"mt-4 flex items-center gap-2 flex-wrap",children:[e.jsxs("button",{type:"button",onClick:s,disabled:l,className:"inline-flex items-center gap-2 px-4 py-2 rounded-lg bg-violet-600 hover:bg-violet-700 text-white text-sm font-semibold shadow-sm disabled:opacity-50 disabled:cursor-not-allowed transition-colors",children:[l?e.jsx(de,{className:"w-4 h-4 animate-spin"}):e.jsx(Ue,{className:"w-4 h-4"}),l?"Cancellingâ¦":o]}),e.jsx("button",{type:"button",onClick:n,disabled:l,className:"inline-flex items-center gap-2 px-4 py-2 rounded-lg bg-white hover:bg-slate-50 border border-slate-300 text-slate-700 text-sm font-semibold disabled:opacity-50 disabled:cursor-not-allowed transition-colors",children:"Keep snooze active"})]})]})]})})}function sae({state:t,onClose:s,onPause:n,onDeleteFutureOccurrences:a,onRetry:r}){const[i,o]=d.useState(!1),l=t.template,c=l?Une(l.reason):"Recurring schedule",u=l?qne(l.reason):null,p=t.children.map(N=>({child:N,lifecycle:O8(N)})),m=p.filter(N=>N.lifecycle==="active").length,x=t.status==="pausing"||t.status==="deleting-children",h=!!(l!=null&&l.cancelled_at),y=t.status==="loading",v=t.status==="error",g=async()=>{if(l!=null&&l.recurrence_rule)try{await navigator.clipboard.writeText(l.recurrence_rule),o(!0),window.setTimeout(()=>o(!1),2e3)}catch(N){console.warn("[recurring-manage] Clipboard copy failed:",N)}};return e.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-slate-900/60 backdrop-blur-sm p-4",onClick:s,role:"dialog","aria-modal":"true","aria-labelledby":"recurring-manage-title",children:e.jsxs("div",{className:"bg-white rounded-xl shadow-2xl w-full max-w-2xl max-h-[90vh] overflow-y-auto",onClick:N=>N.stopPropagation(),children:[e.jsxs("div",{className:"px-5 py-4 border-b border-slate-200 flex items-start justify-between gap-3 bg-gradient-to-r from-indigo-50 via-violet-50 to-purple-50",children:[e.jsxs("div",{className:"flex items-start gap-3 min-w-0",children:[e.jsx("div",{className:"p-2 rounded-lg bg-gradient-to-br from-indigo-500 to-violet-600 flex-shrink-0",children:e.jsx(Bu,{className:"w-5 h-5 text-white"})}),e.jsxs("div",{className:"min-w-0",children:[e.jsxs("h2",{id:"recurring-manage-title",className:"text-base font-bold text-slate-900 flex items-center gap-2 flex-wrap",children:[y?"Loading scheduleâ¦":c,h&&e.jsx("span",{className:"text-[10px] font-bold px-2 py-0.5 rounded border bg-slate-200 text-slate-700 border-slate-300",children:"PAUSED"})]}),e.jsx("p",{className:"text-[11px] text-slate-600 mt-1",children:"Manage this recurring snooze schedule â pause it to stop spawning new occurrences, or cancel its queued future occurrences."})]})]}),e.jsx("button",{type:"button",onClick:s,className:"flex-shrink-0 p-1 rounded hover:bg-white/60 text-slate-500 hover:text-slate-700 transition-colors","aria-label":"Close modal",title:"Close",children:e.jsx(Ke,{className:"w-5 h-5"})})]}),e.jsxs("div",{className:"px-5 py-4 space-y-4",children:[y&&e.jsxs("div",{className:"py-8 text-center",children:[e.jsx(de,{className:"w-8 h-8 text-indigo-500 animate-spin mx-auto mb-3"}),e.jsx("div",{className:"text-sm text-slate-600",children:"Loading schedule details and activationsâ¦"})]}),v&&e.jsx("div",{className:"bg-rose-50 border border-rose-300 rounded-lg p-4",children:e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx(kt,{className:"w-5 h-5 text-rose-600 flex-shrink-0 mt-0.5"}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("div",{className:"text-sm font-bold text-rose-900",children:t.errorMessage||"Failed to load recurring schedule"}),e.jsxs("button",{type:"button",onClick:r,className:"mt-3 inline-flex items-center gap-1 px-3 py-1.5 rounded bg-rose-600 hover:bg-rose-700 text-white text-xs font-semibold",children:[e.jsx(Be,{className:"w-3 h-3"}),"Retry"]})]})]})}),t.status==="paused"&&e.jsxs("div",{className:"bg-emerald-50 border border-emerald-300 rounded-lg p-4 flex items-start gap-3",children:[e.jsx(Ue,{className:"w-5 h-5 text-emerald-600 flex-shrink-0 mt-0.5"}),e.jsxs("div",{className:"text-sm text-emerald-900",children:[e.jsx("div",{className:"font-bold",children:"Schedule paused"}),e.jsx("div",{className:"text-xs mt-1",children:"The activator cron will skip this template on its next run. Already- spawned child snoozes are unaffected."})]})]}),t.status==="children-deleted"&&e.jsxs("div",{className:"bg-emerald-50 border border-emerald-300 rounded-lg p-4 flex items-start gap-3",children:[e.jsx(Ue,{className:"w-5 h-5 text-emerald-600 flex-shrink-0 mt-0.5"}),e.jsxs("div",{className:"text-sm text-emerald-900",children:[e.jsx("div",{className:"font-bold",children:t.deletedChildrenCount===0?"No future occurrences to cancel":`${t.deletedChildrenCount} future occurrence${t.deletedChildrenCount===1?"":"s"} cancelled`}),e.jsx("div",{className:"text-xs mt-1",children:"The recurring schedule itself is still active â it will continue spawning new occurrences per the RRULE until you also pause it."})]})]}),l&&!v&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-[10px] uppercase tracking-wider font-bold text-slate-500 mb-1",children:"Schedule rule (RRULE + DURATION)"}),e.jsxs("div",{className:"flex items-stretch gap-2",children:[e.jsx("code",{className:"flex-1 min-w-0 bg-slate-50 border border-slate-200 rounded px-2 py-2 text-[11px] font-mono text-slate-800 break-all",children:l.recurrence_rule||"(no rule)"}),e.jsx("button",{type:"button",onClick:g,className:"flex-shrink-0 px-2 py-1 rounded border border-slate-300 bg-white hover:bg-slate-50 text-[11px] font-semibold inline-flex items-center gap-1",title:"Copy RRULE string",children:i?e.jsxs(e.Fragment,{children:[e.jsx(xt,{className:"w-3 h-3 text-emerald-600"}),"Copied"]}):e.jsxs(e.Fragment,{children:[e.jsx(Vm,{className:"w-3 h-3"}),"Copy"]})})]})]}),e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-3 text-[11px]",children:[e.jsxs("div",{children:[e.jsx("div",{className:"text-[10px] uppercase tracking-wider font-bold text-slate-500 mb-0.5",children:"Created"}),e.jsx("div",{className:"text-slate-800",children:wa(l.created_at)}),e.jsx("div",{className:"text-[10px] text-slate-500 font-mono",children:Rs(l.created_at)})]}),e.jsxs("div",{children:[e.jsx("div",{className:"text-[10px] uppercase tracking-wider font-bold text-slate-500 mb-0.5",children:"Created by"}),e.jsx("div",{className:"text-slate-800 font-mono text-[10px]",children:l.snoozed_by||"â"})]}),l.cancelled_at&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{children:[e.jsx("div",{className:"text-[10px] uppercase tracking-wider font-bold text-slate-500 mb-0.5",children:"Paused"}),e.jsx("div",{className:"text-slate-800",children:wa(l.cancelled_at)}),e.jsx("div",{className:"text-[10px] text-slate-500 font-mono",children:Rs(l.cancelled_at)})]}),e.jsxs("div",{children:[e.jsx("div",{className:"text-[10px] uppercase tracking-wider font-bold text-slate-500 mb-0.5",children:"Paused by"}),e.jsx("div",{className:"text-slate-800 font-mono text-[10px]",children:l.cancelled_by||"â"})]})]}),u&&e.jsxs("div",{className:"sm:col-span-2",children:[e.jsx("div",{className:"text-[10px] uppercase tracking-wider font-bold text-slate-500 mb-0.5",children:"Reason"}),e.jsxs("div",{className:"text-slate-700 italic break-words",children:['"',u,'"']})]})]}),e.jsxs("div",{children:[e.jsxs("div",{className:"text-[10px] uppercase tracking-wider font-bold text-slate-500 mb-1.5",children:["Activations (",t.children.length,")",m>0&&e.jsxs("span",{className:"ml-1 text-violet-700",children:["· ",m," active"]})]}),t.children.length===0?e.jsx("div",{className:"text-[11px] text-slate-500 italic bg-slate-50 border border-slate-200 rounded p-3",children:"This schedule hasn't spawned any child snoozes
1274yet. The activator cron runs nightly at 07:15 UTC."}):e.jsx("div",{className:"border border-slate-200 rounded-lg max-h-48 overflow-y-auto divide-y divide-slate-100",children:p.map(({child:N,lifecycle:b})=>{const f=b==="active"?"bg-violet-100 text-violet-800 border-violet-300":b==="cancelled"?"bg-slate-200 text-slate-700 border-slate-300":"bg-emerald-100 text-emerald-800 border-emerald-300";return e.jsx("div",{className:"px-3 py-2 flex items-center justify-between gap-2 text-[11px]",children:e.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[e.jsx("span",{className:`text-[9px] font-bold px-1.5 py-0.5 rounded border ${f}`,children:b.toUpperCase()}),e.jsxs("span",{className:"text-slate-700 truncate",children:[Rs(N.created_at)," â ",Rs(N.snoozed_until)]})]})},N.id)})})]})]})]}),l&&!v&&e.jsxs("div",{className:"px-5 py-3 border-t border-slate-200 bg-slate-50 flex flex-wrap items-center justify-end gap-2",children:[!h&&e.jsxs("button",{type:"button",onClick:n,disabled:x,className:"inline-flex items-center gap-1.5 px-3 py-1.5 rounded border border-amber-300 bg-amber-50 hover:bg-amber-100 text-amber-800 text-xs font-semibold disabled:opacity-50 disabled:cursor-not-allowed",children:[t.status==="pausing"?e.jsx(de,{className:"w-3.5 h-3.5 animate-spin"}):e.jsx(HP,{className:"w-3.5 h-3.5"}),t.status==="pausing"?"Pausingâ¦":"Pause schedule"]}),e.jsxs("button",{type:"button",onClick:a,disabled:x||m===0,className:"inline-flex items-center gap-1.5 px-3 py-1.5 rounded border border-rose-300 bg-rose-50 hover:bg-rose-100 text-rose-800 text-xs font-semibold disabled:opacity-50 disabled:cursor-not-allowed",title:m===0?"No active future occurrences to cancel":`Cancel ${m} active future occurrence(s)`,children:[t.status==="deleting-children"?e.jsx(de,{className:"w-3.5 h-3.5 animate-spin"}):e.jsx(va,{className:"w-3.5 h-3.5"}),t.status==="deleting-children"?"Cancellingâ¦":"Delete future occurrences"]}),e.jsx("button",{type:"button",onClick:s,disabled:x,className:"inline-flex items-center gap-1.5 px-3 py-1.5 rounded border border-slate-300 bg-white hover:bg-slate-50 text-slate-700 text-xs font-semibold disabled:opacity-50",children:"Close"})]})]})})}const nae=d.lazy(()=>Ee(()=>import("./FoundationLandingPage-CKVM2Q9y.js"),__vite__mapDeps([125,62]))),aae=d.lazy(()=>Ee(()=>import("./FoundationDonationModule-CrIMpnso.js"),[])),rae=d.lazy(()=>Ee(()=>import("./FoundationSection-Dlge3iEh.js"),__vite__mapDeps([64,65]))),iae=d.lazy(()=>Ee(()=>import("./GalaFundraiserModule-BMBdR0b1.js"),[])),oae=d.lazy(()=>Ee(()=>import("./FoundationGiftShop-CWLdUTUo.js"),[])),U8=[{id:"foundation-landing",label:"Foundation Landing Page",scope:"foundation"},{id:"foundation-donate",label:"Foundation Donation Module",scope:"foundation"},{id:"foundation-hub",label:"Foundation Hub / Events",scope:"foundation"},{id:"gala-fundraiser",label:"Gala & Fundraiser Module",scope:"foundation"},{id:"foundation-gift-shop",label:"Foundation Gift Shop",scope:"foundation"}],lae=t=>{switch(t){case"foundation-landing":return e.jsx(nae,{});case"foundation-donate":return e.jsx(aae,{});case"foundation-hub":return e.jsx(rae,{});case"gala-fundraiser":return e.jsx(iae,{});case"foundation-gift-shop":return e.jsx(oae,{});default:return e.jsxs("div",{style:{padding:40,fontFamily:"system-ui, sans-serif"},children:[e.jsxs("h2",{style:{color:"#355E3B"},children:["Unknown preview surface: ",e.jsx("code",{children:t})]}),e.jsxs("p",{children:["Valid surfaces: ",U8.map(s=>s.id).join(", ")]})]})}},cae=()=>(re.useEffect(()=>{requestAnimationFrame(()=>requestAnimationFrame(()=>{var t;document.body.setAttribute("data-foundation-preview-ready","true");try{(t=window.parent)==null||t.postMessage({type:"foundation-preview-ready"},"*")}catch{}}))},[]),null),dae=()=>{const[t]=cc(),s=t.get("surface")||"foundation-landing";return e.jsx(np,{children:e.jsx(cR,{children:e.jsx("div",{className:"z-foundation-scope",style:{minHeight:"100vh",backgroundColor:"#FAF6EE"},children:e.jsxs(d.Suspense,{fallback:e.jsxs("div",{style:{padding:40,fontFamily:"system-ui, sans-serif",color:"#355E3B"},children:["Loading ",s,"â¦"]}),children:[lae(s),e.jsx(cae,{})]})})})})},uae=[{hex:"#D4AF37",rgb:[212,175,55],label:"Metallic Gold"},{hex:"#B8962E",rgb:[184,150,46],label:"Gold Dark"},{hex:"#E6D2A0",rgb:[230,210,160],label:"Gold Light"}],q8=28,mae=[{id:"scholar-portal",label:"Scholar Portal (/scholar)",url:"/scholar",scopeSelector:".z-scholarship-scope",type:"scholarship"}],pae={id:"foundation-donor",label:"Donor Portal (/foundation/donor)",url:"/foundation/donor",scopeSelector:".z-foundation-scope, body",type:"foundation"},hae=U8.map(t=>({id:t.id,label:t.label,url:`/admin/foundation-contrast-audit/preview?surface=${t.id}`,scopeSelector:".z-foundation-scope",type:"foundation"})),Vc=[...hae,pae,...mae],lN=t=>{if(!t)return null;const s=t.trim().toLowerCase();if(s==="transparent"||s==="rgba(0, 0, 0, 0)"||s==="rgb(0, 0, 0, 0)")return{r:0,g:0,b:0,a:0};const n=s.match(/rgba?\(\s*([\d.]+)\s*[, ]\s*([\d.]+)\s*[, ]\s*([\d.]+)\s*(?:[,/ ]\s*([\d.]+%?)\s*)?\)/);if(n){let r=1;return n[4]!=null&&(r=n[4].endsWith("%")?parseFloat(n[4])/100:parseFloat(n[4])),{r:+n[1],g:+n[2],b:+n[3],a:r}}const a=s.match(/^#([0-9a-f]{3,8})$/i);if(a){let r=a[1];r.length===3&&(r=r.split("").map(u=>u+u).join("")),r.length===4&&(r=r.split("").map(u=>u+u).join(""));const i=parseInt(r.slice(0,2),16),o=parseInt(r.slice(2,4),16),l=parseInt(r.slice(4,6),16),c=r.length===8?parseInt(r.slice(6,8),16)/255:1;return{r:i,g:o,b:l,a:c}}return null},nj=t=>{const s=t/255;return s<=.03928?s/12.92:Math.pow((s+.055)/1.055,2.4)},wE=t=>
1274.2126*nj(t.r)+.7152*nj(t.g)+.0722*nj(t.b),xae=(t,s)=>{const n=wE(t),a=wE(s),r=Math.max(n,a),i=Math.min(n,a);return(r+.05)/(i+.05)},fae=(t,s)=>{const n=t.r-s[0],a=t.g-s[1],r=t.b-s[2];return Math.sqrt(n*n+a*a+r*r)},gae=t=>{if(t.a<.5)return null;let s=null;for(const n of uae){const a=fae(t,n.rgb);a<=q8&&(s==null||a<s.distance)&&(s={hex:n.hex,label:n.label,distance:a})}return s},z0=t=>{const s=n=>Math.round(n).toString(16).padStart(2,"0");return`#${s(t.r)}${s(t.g)}${s(t.b)}`.toUpperCase()},NE={r:250,g:246,b:238,a:1},yae=(t,s)=>{let n=t;for(;n&&n.nodeType===1;){const a=s.getComputedStyle(n),r=lN(a.backgroundColor);if(r&&r.a>=.5)return{rgb:r,hex:z0(r),source:"opaque",fromTag:n.tagName.toLowerCase()};const i=a.backgroundImage;if(i&&i!=="none"&&/gradient/i.test(i)){const o=i.match(/#([0-9a-fA-F]{3,8})\b/),l=i.match(/rgba?\([^)]+\)/),c=o?`#${o[1]}`:l?l[0]:null;if(c){const u=lN(c);if(u&&u.a>=.5)return{rgb:u,hex:z0(u),source:"gradient",fromTag:n.tagName.toLowerCase(),note:"Approximated from first color stop of CSS gradient"}}}n=n.parentElement}return{rgb:NE,hex:z0(NE),source:"page-default",fromTag:"body",note:"No opaque ancestor found â fell back to Soft Cream page default"}},bae=t=>{const s=[];let n=t,a=0;for(;n&&n.nodeType===1&&a<4;){let r=n.tagName.toLowerCase();if(n.id){r+=`#${n.id}`,s.unshift(r);break}const i=(n.getAttribute("class")||"").split(/\s+/).filter(Boolean).slice(0,2).join(".");i&&(r+=`.${i}`);const o=n.parentElement;if(o){const l=Array.from(o.children).filter(c=>c.tagName===n.tagName);l.length>1&&(r+=`:nth-of-type(${l.indexOf(n)+1})`)}s.unshift(r),n=n.parentElement,a++}return s.join(" > ")},vae=(t,s)=>s?t>=4.5?"AAA":t>=3?"AA":t>=2.5?"WARN":"FAIL":t>=7?"AAA":t>=4.5?"AA":t>=3?"WARN":"FAIL",jae=(t,s,n)=>{const a=t.querySelector(n.scopeSelector)||t.body;if(!a)return[];const r=[],i=t.createTreeWalker(a,NodeFilter.SHOW_TEXT,{acceptNode:c=>{var x;if(!(((x=c.nodeValue)==null?void 0:x.trim())??""))return NodeFilter.FILTER_REJECT;const p=c.parentElement;if(!p)return NodeFilter.FILTER_REJECT;const m=p.tagName;return m==="SCRIPT"||m==="STYLE"||m==="NOSCRIPT"?NodeFilter.FILTER_REJECT:NodeFilter.FILTER_ACCEPT}}),o=new WeakSet;let l=i.nextNode();for(;l;){const c=l.parentElement;if(!o.has(c)){const u=s.getComputedStyle(c),p=lN(u.color);if(p&&p.a>=.5){const m=gae(p);if(m){o.add(c);const x=yae(c,s),h=xae(p,x.rgb),y=parseFloat(u.fontSize)||16,v=parseInt(u.fontWeight,10)||400,g=y>=24||y>=18.66&&v>=700,N=vae(h,g),b=(l.nodeValue||"").trim().replace(/\s+/g," ");r.push({targetId:n.id,selector:bae(c),tag:c.tagName.toLowerCase(),text:b.length>80?b.slice(0,77)+"â¦":b,colorRgb:p,colorHex:z0(p),goldMatch:m.hex,bgHex:x.hex,bgSource:x.source,bgFromTag:x.fromTag,ratio:Math.round(h*100)/100,level:N,note:x.note,fontSizePx:y,fontWeight:v,isLargeText:g}),c.setAttribute("data-fcaudit-id",`${n.id}__${r.length}`)}}}l=i.nextNode()}return r},wae=()=>Vc.map(t=>({target:t,status:"idle",findings:[]})),_E={"wrap-in-sage":"Wrap in deep-sage container","apply-utility-class":"Apply .gold-on-sage-callout utility","bump-weight":"Bump font weight + text shadow","swap-gold-token":"Swap to a darker gold palette token",other:"Custom override"},Nae=({fixKey:t,fixState:s,finding:n,copiedKey:a,onCopy:r,onClose:i,onRetry:o})=>{if(!s)return null;if(s.status==="loading")return e.jsxs("div",{className:"bg-gradient-to-br from-[#355E3B] to-[#2A3D24] px-5 py-4 flex items-center gap-3",children:[e.jsx(de,{size:16,className:"animate-spin text-[#D4AF37]"}),e.jsxs("div",{className:"text-[#E6D2A0] text-xs font-semibold",children:["Asking ",e.jsx("span",{className:"font-mono text-[#D4AF37]",children:"google/gemini-3-flash"})," for the minimal palette-compliant CSS overrideâ¦"]})]});if(s.status==="error")return e.jsxs("div",{className:"bg-red-50 border-l-4 border-red-500 px-5 py-4 flex items-start justify-between gap-3",children:[e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(ve,{size:14,className:"text-red-600"}),e.jsx("p",{className:"text-[11px] font-bold text-red-800",children:"AI fix request failed"})]}),e.jsx("p",{className:"text-[11px] text-red-700 mt-1",children:s.error}),s.rawContent&&e.jsxs("details",{className:"mt-2",children:[e.jsx("summary",{className:"text-[10px] text-red-700 cursor-pointer font-bold",children:"View raw model output"}),e.jsx("pre",{className:"mt-1 text-[10px] bg-red-100/50 border border-red-200 rounded p-2 overflow-auto text-red-900 whitespace-pre-wrap",children:s.rawContent})]})]}),e.jsxs("div",{className:"flex items-center gap-2 shrink-0",children:[e.jsxs("button",{onClick:o,className:"text-[10px] font-bold text-red-800 hover:text-red-900 inline-flex items-center gap-1 px-2 py-1 rounded border border-red-300 hover:border-red-500 bg-white",children:[e.jsx(Be,{size:10})," Retry"]}),e.jsx("button",{onClick:i,"aria-label":"Close",className:"text-red-700 hover:text-red-900 p-1 rounded hover:bg-red-100",children:e.jsx(Ke,{size:12})})]})]});const l=s.fix;if(!l)return null;const c=a===t,u=l.projectedRatio>=(n.isLargeText?3:4.5),p=_E[l.strategy]||_E.other;return e.jsxs("div",{className:"bg-gradient-to-br from-[#355E3B] to-[#2A3D24] border-l-4 border-[#D4AF37] px-5 py-4",children:[e.jsxs("div",{className:"flex items-start justify-between gap-3 mb-3",children:[e.jsxs("div",{className:"flex items-start gap-2.5 min-w-0",children:[e.jsx("div",{className:"w-7 h-7 rounded-lg bg-[#D4AF37]/15 border border-[#D4AF37]/40 flex items-center justify-center shrink-0",children:e.jsx(Qe,{size:13,className:"text-[#D4AF37]"})}),e.jsxs("div",{className:"min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[e.jsx("p",{className:"text-[11px] font-bold uppercase tracking-wider text-[#D4AF37]",children:p}),e.jsx("span",{className:"text-[9px] font-bold uppercase tracking-wider px-1.5 py-0.5 rounded bg-[#D4AF37]/15 text-[#E6D2A0] border border-[#D4AF37]/30",children:"gemini-3-flash"})]}),e.jsx("p",{className:"text-[12px] text-[#E6D2A0] mt-0.5 leading-snug",children:l.summary})]})]}),e.jsx("button",{onClick:i,"aria-label":"Hide fix",className:"text-[#E6D2A0]/60 hover:text-[#D4AF37] p-1 rounded hover:bg-[#D4AF37]/10 shrink-0",children:e.jsx(Ke,{size:12})})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-3 mb-3",children:[e.jsxs("div",{className:"rounded-lg bg-red-500/15 border border-red-500/40 p-2.5",children:[e.jsx("div",{className:"text-[9px] font-bold uppercase tracking-wider text-red-200 mb-1",children:"Before"}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"w-3.5 h-3.5 rounded border border-white/20",style:{backgroundColor:n.bgHex}}),e.jsx("code",{className:"text-[10px] font-mono text-red-100",children:n.bgHex}),e.jsxs("span",{className:"text-[11px] font-bold text-red-100 tabular-nums ml-auto",children:[n.ratio.toFixed(2),":1"]})]}),e.jsx("div",{className:"text-[10px] text-red-200/80 mt-0.5",children:n.level})]}),e.jsxs("div",{className:`rounded-lg p-2.5 border ${u?"bg-emerald-500/15 border-emerald-400/50":"bg-amber-500/15 border-amber-400/50"}`,children:[e.jsx("div",{className:`text-[9px] font-bold uppercase tracking-wider mb-1 ${u?"text-emerald-200":"text-amber-200"}`,children:"Projected"}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"w-3.5 h-3.5 rounded border border-white/20",style:{backgroundColor:l.projectedBgHex}}),e.jsx("code",{className:`text-[10px] font-mono ${u?"text-emerald-100":"text-amber-100"}`,children:l.projectedBgHex}),e.jsxs("span",{className:`text-[11px] font-bold tabular-nums ml-auto ${u?"text-emerald-100":"text-amber-100"}`,children:[l.projectedRatio.toFixed(2),":1"]})]}),e.jsxs("div",{className:`text-[10px] mt-0.5 ${u?"text-emerald-200/80":"text-amber-200/80"}`,children:[l.projectedLevel,u?" · clears WCAG AA":" · still below AA threshold"]})]})]}),e.jsxs("div",{className:"rounded-lg bg-[#1F2C1A] border border-[#D4AF37]/30 overflow-hidden",children:[e.jsxs("div",{className:"flex items-center justify-between px-3 py-1.5 border-b border-[#D4AF37]/20 bg-black/30",children:[e.jsxs("div",{className:"flex items-center gap-1.5 text-[10px] font-bold uppercase tracking-wider text-[#D4AF37]/80",children:[e.jsx("span",{children:"CSS override"}),l.paletteTokensUsed.length>0&&e.jsx("span",{className:"flex items-center gap-1 ml-2",children:l.paletteTokensUsed.slice(0,4).map(m=>e.jsx("span",{title:m,className:"w-3 h-3 rounded border border-white/20",style:{backgroundColor:m.startsWith("#")?m:void 0}},m))})]}),e.jsx("button",{onClick:()=>r(t,l.cssSnippet),className:`text-[10px] font-bold inline-flex items-center gap-1 px-2 py-1 rounded border transition-colors ${c?"bg-emerald-500/20 text-emerald-300 border-emerald-400/60":"bg-[#D4AF37]/10 text-[#D4AF37] border-[#D4AF37]/40 hover:bg-[#D4AF37]/20"}`,children:c?e.jsxs(e.Fragment,{children:[e.jsx(xt,{size:10})," Copied"]}):e.jsxs(e.Fragment,{children:[e.jsx(Vm,{size:10})," Copy snippet"]})})]}),e.jsx("pre",{className:"text-[11px] leading-relaxed text-[#E6D2A0] font-mono px-3 py-2.5 overflow-x-auto whitespace-pre",children:l.cssSnippet||"/* no snippet returned */"})]}),l.htmlHint&&e.jsxs("div",{className:"mt-2 rounded-lg bg-black/25 border border-[#D4AF37]/20 px-3 py-2",children:[e.jsx("div",{className:"text-[9px] font-bold uppercase tracking-wider text-[#D4AF37]/70 mb-1",children:"HTML hint"}),e.jsx("code",{className:"text-[11px] text-[#E6D2A0] font-mono break-all",children:l.htmlHint})]}),l.rationale&&e.jsx("p",{className:"mt-3 text-[11px] text-[#E6D2A0]/85 leading-relaxed italic",children:l.rationale})]})},_ae=()=>{var I;
1274const[t,s]=d.useState(wae),[n,a]=d.useState(Vc[0].id),[r,i]=d.useState("fail-only"),[o,l]=d.useState(""),[c,u]=d.useState(null),[p,m]=d.useState({}),[x,h]=d.useState(null),[y,v]=d.useState(new Set),g=d.useRef(null),N=d.useRef(!1),b=t.find(D=>D.target.id===n)||t[0],f=d.useCallback(async D=>{const L=Vc.findIndex(B=>B.id===D);if(L<0)return[];const V=Vc[L];return s(B=>B.map(A=>A.target.id===D?{...A,status:"loading",error:void 0,findings:[]}:A)),a(D),new Promise(B=>{const A=g.current;if(!A){B([]);return}let z=!1;const M=()=>{A.removeEventListener("load",U),window.removeEventListener("message",T)},R=()=>{try{const q=A.contentDocument,H=A.contentWindow;if(!q||!H)throw new Error("Iframe document unavailable (cross-origin?)");s(G=>G.map(W=>W.target.id===D?{...W,status:"scanning"}:W)),setTimeout(()=>{try{const G=jae(q,H,V);s(W=>W.map(X=>X.target.id===D?{...X,status:"done",findings:G,scannedAt:new Date}:X)),z=!0,M(),B(G)}catch(G){s(W=>W.map(X=>X.target.id===D?{...X,status:"error",error:(G==null?void 0:G.message)||String(G)}:X)),z=!0,M(),B([])}},600)}catch(q){s(H=>H.map(G=>G.target.id===D?{...G,status:"error",error:(q==null?void 0:q.message)||String(q)}:G)),z=!0,M(),B([])}},T=q=>{var H;((H=q==null?void 0:q.data)==null?void 0:H.type)==="foundation-preview-ready"&&!z&&R()},U=()=>{V.url.startsWith("/admin/foundation-contrast-audit/preview")?setTimeout(()=>{z||R()},5e3):setTimeout(()=>{z||R()},1500)};window.addEventListener("message",T),A.addEventListener("load",U),A.src=V.url})},[]),j=d.useCallback(async()=>{N.current=!1;for(const D of Vc){if(N.current)break;await f(D.id)}},[f]),S=(D,L)=>{if(n!==D){a(D);return}const V=g.current,B=V==null?void 0:V.contentDocument;if(!B)return;const A=`[data-fcaudit-id="${D}__${L+1}"]`,z=B.querySelector(A);z&&(B.querySelectorAll("[data-fcaudit-highlight]").forEach(M=>{M.style.outline="",M.style.outlineOffset="",M.removeAttribute("data-fcaudit-highlight")}),z.style.outline="3px solid #DC2626",z.style.outlineOffset="2px",z.setAttribute("data-fcaudit-highlight","true"),z.scrollIntoView({behavior:"smooth",block:"center"}),u(`${D}__${L}`))},w=d.useCallback(async(D,L)=>{v(V=>{const B=new Set(V);return B.add(L),B}),m(V=>({...V,[L]:{status:"loading"}}));try{const{data:V,error:B}=await O.functions.invoke("fix-foundation-contrast",{body:{selector:D.selector,tag:D.tag,text:D.text,colorHex:D.colorHex,goldMatch:D.goldMatch,bgHex:D.bgHex,bgSource:D.bgSource,ratio:D.ratio,level:D.level,fontSizePx:D.fontSizePx,fontWeight:D.fontWeight,isLargeText:D.isLargeText,note:D.note}});if(B){m(A=>({...A,[L]:{status:"error",error:B.message||"Edge function call failed",receivedAt:new Date}}));return}if(!(V!=null&&V.success)){m(A=>({...A,[L]:{status:"error",error:(V==null?void 0:V.error)||"AI did not return a valid fix",rawContent:V==null?void 0:V.rawContent,receivedAt:new Date}}));return}m(A=>({...A,[L]:{status:"done",fix:V.fix,receivedAt:new Date}}))}catch(V){m(B=>({...B,[L]:{status:"error",error:(V==null?void 0:V.message)||String(V),receivedAt:new Date}}))}},[]),_=D=>{v(L=>{const V=new Set(L);return V.has(D)?V.delete(D):V.add(D),V})},C=async(D,L)=>{try{await navigator.clipboard.writeText(L),h(D),setTimeout(()=>h(V=>V===D?null:V),1800)}catch{const V=document.createElement("textarea");V.value=L,document.body.appendChild(V),V.select();try{document.execCommand("copy")}catch{}document.body.removeChild(V),h(D),setTimeout(()=>h(B=>B===D?null:B),1800)}},E=d.useMemo(()=>{const D=t.flatMap(L=>L.findings);return{total:D.length,fail:D.filter(L=>L.level==="FAIL").length,warn:D.filter(L=>L.level==="WARN").length,aa:D.filter(L=>L.level==="AA").length,aaa:D.filter(L=>L.level==="AAA").length,scanned:t.filter(L=>L.status==="done").length}},[t]),P=d.useMemo(()=>b.findings.filter(L=>r==="all"?!0:L.level==="FAIL"||L.level==="WARN").filter(L=>{if(!o.trim())return!0;const V=o.toLowerCase();return L.text.toLowerCase().includes(V)||L.selector.toLowerCase().includes(V)}).sort((L,V)=>L.ratio-V.ratio),[b,r,o]),F=()=>{const D=[["target","selector","tag","text","colorHex","goldMatch","bgHex","bgSource","ratio","level","fontSizePx","fontWeight","isLargeText","note"].join(",")];for(const A of t)for(const z of A.findings){const M=R=>`"${String(R??"").replace(/"/g,'""')}"`;D.push([M(A.target.label),M(z.selector),M(z.tag),M(z.text),M(z.colorHex),M(z.goldMatch),M(z.bgHex),M(z.bgSource),M(z.ratio),M(z.level),M(z.fontSizePx),M(z.fontWeight),M(z.isLargeText),M(z.note||"")].join(","))}const L=new Blob([D.join(` 1275`)],{type:"text/csv;charset=utf-8"}),V=URL.createObjectURL(L),B=document.createElement("a");B.href=V,B.download=`foundation-contrast-audit-${new Date().toISOString().slice(0,19).replace(/[:T]/g,"-")}.csv`,B.click(),URL.revokeObjectURL(V)};return d.useEffect(()=>{const D=g.current,L=Vc.find(V=>V.id===n);!D||!L||D.src!==window.location.origin+L.url&&!D.src.endsWith(L.url)&&(D.src=L.url)},[n]),e.jsxs("div",{className:"min-h-screen bg-slate-50",children:[e.jsx("header",{className:"bg-white border-b border-slate-200 sticky top-0 z-30",children:e.jsxs("div",{className:"max-w-[1600px] mx-auto px-6 py-4 flex items-center justify-between gap-4",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsxs(be,{to:"/",className:"flex items-center gap-2 text-sm text-slate-500 hover:text-slate-700",children:[e.jsx(Je,{size:14})," Home"]}),e.jsx("div",{className:"h-5 w-px bg-slate-200"}),e.jsxs("div",{className:"flex items-center gap-2.5",children:[e.jsx("div",{className:"w-9 h-9 rounded-lg bg-gradient-to-br from-[#355E3B] to-[#2A3D24] flex items-center justify-center",children:e.jsx(Ie,{size:18,className:"text-[#D4AF37]"})}),e.jsxs("div",{children:[e.jsx("h1",{className:"text-base font-bold text-slate-900 tracking-tight",children:"Foundation Contrast Audit"}),e.jsx("p",{className:"text-[11px] text-slate-500",children:"WCAG AA · Metallic-Gold text on Foundation + Scholarship routes"})]})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("button",{onClick:F,disabled:E.total===0,className:"inline-flex items-center gap-2 px-3 py-2 rounded-lg bg-white border border-slate-200 text-xs font-semibold text-slate-700 hover:bg-slate-50 disabled:opacity-50",children:[e.jsx(us,{size:13})," Export CSV"]}),e.jsxs("button",{onClick:j,className:"inline-flex items-center gap-2 px-3 py-2 rounded-lg bg-[#355E3B] text-white text-xs font-bold hover:bg-[#2A3D24] shadow-sm",children:[e.jsx(Xx,{size:13})," Scan All Surfaces"]})]})]})}),e.jsx("div",{className:"max-w-[1600px] mx-auto px-6 pt-6",children:e.jsx("div",{className:"grid grid-cols-2 md:grid-cols-5 ga
1275p-3 mb-6",children:[{label:"Surfaces scanned",value:`${E.scanned} / ${Vc.length}`,icon:e.jsx(Ym,{size:14}),color:"text-slate-700",bg:"bg-white border-slate-200"},{label:"Gold text found",value:E.total,icon:e.jsx(ms,{size:14}),color:"text-slate-700",bg:"bg-white border-slate-200"},{label:"AAA pass (â¥7:1)",value:E.aaa,icon:e.jsx(Ue,{size:14}),color:"text-emerald-700",bg:"bg-emerald-50 border-emerald-200"},{label:"AA pass (4.5â7)",value:E.aa,icon:e.jsx(Ue,{size:14}),color:"text-green-700",bg:"bg-green-50 border-green-200"},{label:"FAIL (<3:1 or 4.5)",value:E.fail+E.warn,icon:e.jsx(ve,{size:14}),color:"text-red-700",bg:"bg-red-50 border-red-200"}].map(D=>e.jsxs("div",{className:`rounded-xl border p-4 ${D.bg}`,children:[e.jsxs("div",{className:`flex items-center gap-1.5 text-[10px] font-bold uppercase tracking-wider ${D.color} opacity-80`,children:[D.icon,D.label]}),e.jsx("p",{className:`text-2xl font-bold mt-1 ${D.color}`,children:D.value})]},D.label))})}),e.jsxs("div",{className:"max-w-[1600px] mx-auto px-6 pb-10 grid grid-cols-12 gap-6",children:[e.jsxs("aside",{className:"col-span-12 lg:col-span-3 space-y-2",children:[e.jsx("div",{className:"text-[10px] font-bold uppercase tracking-wider text-slate-500 mb-2 px-1",children:"Audit Targets"}),t.map(D=>{const L=D.findings.filter(B=>B.level==="FAIL"||B.level==="WARN").length,V=D.target.id===n;return e.jsxs("button",{onClick:()=>a(D.target.id),className:`w-full text-left rounded-lg border p-3 transition-all ${V?"bg-white border-[#355E3B] shadow-md ring-1 ring-[#355E3B]":"bg-white border-slate-200 hover:border-slate-300"}`,children:[e.jsxs("div",{className:"flex items-center justify-between gap-2",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"text-xs font-bold text-slate-800 truncate",children:D.target.label}),e.jsx("p",{className:"text-[10px] text-slate-500 truncate font-mono",children:D.target.url})]}),e.jsx("span",{className:`text-[9px] font-bold uppercase tracking-wider px-1.5 py-0.5 rounded ${D.target.type==="foundation"?"bg-[#355E3B]/10 text-[#355E3B]":"bg-amber-100 text-amber-800"}`,children:D.target.type})]}),e.jsxs("div",{className:"flex items-center justify-between gap-2 mt-2",children:[e.jsxs("div",{className:"flex items-center gap-1.5",children:[D.status==="idle"&&e.jsx("span",{className:"text-[10px] text-slate-400",children:"Not scanned"}),D.status==="loading"&&e.jsxs(e.Fragment,{children:[e.jsx(de,{size:11,className:"animate-spin text-slate-500"}),e.jsx("span",{className:"text-[10px] text-slate-500",children:"Loadingâ¦"})]}),D.status==="scanning"&&e.jsxs(e.Fragment,{children:[e.jsx(de,{size:11,className:"animate-spin text-amber-600"}),e.jsx("span",{className:"text-[10px] text-amber-700",children:"Scanningâ¦"})]}),D.status==="done"&&L===0&&e.jsxs(e.Fragment,{children:[e.jsx(Ue,{size:11,className:"text-emerald-600"}),e.jsx("span",{className:"text-[10px] text-emerald-700 font-bold",children:"All pass"})]}),D.status==="done"&&L>0&&e.jsxs(e.Fragment,{children:[e.jsx(ve,{size:11,className:"text-red-600"}),e.jsxs("span",{className:"text-[10px] text-red-700 font-bold",children:[L," issue",L===1?"":"s"]})]}),D.status==="error"&&e.jsxs(e.Fragment,{children:[e.jsx(em,{size:11,className:"text-red-600"}),e.jsx("span",{className:"text-[10px] text-red-700",children:"Error"})]})]}),e.jsxs("span",{role:"button",tabIndex:0,onClick:B=>{B.stopPropagation(),f(D.target.id)},onKeyDown:B=>{B.key==="Enter"&&(B.stopPropagation(),f(D.target.id))},className:"inline-flex items-center gap-1 text-[10px] font-bold text-[#355E3B] hover:text-[#2A3D24] px-2 py-0.5 rounded border border-[#355E3B]/20 hover:border-[#355E3B]/40 cursor-pointer",children:[e.jsx(Be,{size:9})," Scan"]})]})]},D.target.id)})]}),e.jsxs("section",{className:"col-span-12 lg:col-span-9 space-y-4",children:[e.jsxs("div",{className:"bg-white rounded-xl border border-slate-200 overflow-hidden",children:[e.jsxs("div",{className:"flex items-center justify-between gap-3 px-4 py-2.5 border-b border-slate-200 bg-slate-50",children:[e.jsxs("div",{className:"flex items-center gap-2 text-xs text-slate-600 font-mono truncate",children:[e.jsx(Ua,{size:12,className:"text-slate-400 shrink-0"}),e.jsx("span",{className:"truncate",children:b.target.url})]}),e.jsx("div",{className:"flex items-center gap-2",children:e.jsxs("a",{href:b.target.url,target:"_blank",rel:"noopener noreferrer",className:"text-[10px] font-bold text-slate-500 hover:text-slate-700 inline-flex items-center gap-1",children:["Open in new tab ",e.jsx(Ua,{size:10})]})})]}),e.jsx("iframe",{ref:g,title:"Foundation Contrast Audit Preview",className:"w-full h-[460px] bg-white",sandbox:"allow-same-origin allow-scripts allow-forms"})]}),e.jsxs("div",{className:"bg-white rounded-xl border border-slate-200 p-4",children:[e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3 mb-3",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"text-base font-bold text-slate-900",children:b.target.label}),e.jsx("p",{className:"text-xs text-slate-500",children:b.status==="done"?`${b.findings.length} gold text element${b.findings.length===1?"":"s"} · last scanned ${(I=b.scannedAt)==null?void 0:I.toLocaleTimeString()}`:'Click "Scan" to begin the contrast check'})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("div",{className:"relative",children:[e.jsx(Bt,{size:12,className:"absolute left-2 top-1/2 -translate-y-1/2 text-slate-400"}),e.jsx("input",{value:o,onChange:D=>l(D.target.value),placeholder:"Search text or selectorâ¦",className:"pl-7 pr-2 py-1.5 text-xs rounded-md border border-slate-200 focus:outline-none focus:border-[#355E3B] w-48"})]}),e.jsxs("select",{value:r,onChange:D=>i(D.target.value),className:"text-xs px-2 py-1.5 rounded-md border border-slate-200 focus:outline-none",children:[e.jsx("option",{value:"fail-only",children:"Only failures & warnings"}),e.jsx("option",{value:"all",children:"All gold-text elements"})]}),e.jsxs("button",{onClick:()=>f(b.target.id),className:"inline-flex items-center gap-1.5 px-3 py-1.5 rounded-md bg-[#355E3B] text-white text-xs font-bold hover:bg-[#2A3D24]",children:[e.jsx(Be,{size:11})," Re-scan"]})]})]}),b.status==="error"&&e.jsxs("div",{className:"mb-3 rounded-lg border-l-4 border-red-500 bg-red-50 p-3 text-xs text-red-800",children:[e.jsx("strong",{children:"Audit error:"})," ",b.error]}),b.status==="done"&&P.length===0&&e.jsxs("div",{className:"text-center py-10 rounded-lg border-2 border-dashed border-emerald-300 bg-emerald-50",children:[e.jsx(Ue,{size:28,className:"mx-auto text-emerald-600 mb-2"}),e.jsx("p",{className:"text-sm font-bold text-emerald-800",children:"No contrast issues found"}),e.jsx("p",{className:"text-xs text-emerald-700 mt-1",children:r==="fail-only"?"Every gold-text element on this surface meets the 4.5:1 WCAG AA threshold.":"No gold-text elements were detected inside the scope wrapper."})]}),P.length>0&&e.jsx("div",{className:"overflow-x-auto rounded-lg border border-slate-200",children:e.jsxs("table",{className:"w-full text-xs",children:[e.jsx("thead",{className:"bg-slate-50 text-slate-600",children:e.jsxs("tr",{className:"text-left",children:[e.jsx("th",{className:"px-3 py-2 font-bold uppercase tracking-wider text-[10px]",children:"Level"}),e.jsx("th",{className:"px-3 py-2 font-bold uppercase tracking-wider text-[10px]",children:"Ratio"}),e.jsx("th",{className:"px-3 py-2 font-bold uppercase tracking-wider text-[10px]",children:"Gold ink"}),e.jsx("th",{className:"px-3 py-2 font-bold uppercase tracking-wider text-[10px]",children:"Computed BG"}),e.jsx("th",{className:"px-3 py-2 font-bold uppercase tracking-wider text-[10px]",children:"Element"}),e.jsx("th",{className:"px-3 py-2 font-bold uppercase tracking-wider text-[10px]",children:"Text"}),e.jsx("th",{className:"px-3 py-2 font-bold uppercase tracking-wider text-[10px]",children:"Action"})]})}),e.jsx("tbody",{className:"bg-white",children:P.map((D,L)=>{const V=b.findings.indexOf(D),B=`${D.targetId}__${V}`,A=c===B,z=D.level==="FAIL"||D.level==="WARN",M=p[B],R=y.has(B),T={FAIL:"bg-red-100 text-red-800 border-red-200",WARN:"bg-amber-100 text-amber-800 border-amber-200",AA:"bg-green-100 text-green-800 border-green-200",AAA:"bg-emerald-100 text-emerald-800 border-emerald-200"};return e.jsxs(re.Fragment,{children:[e.jsxs("tr",{className:`border-t border-slate-100 hover:bg-slate-50 ${A?"bg-yellow-50":""}`,children:[e.jsx("td",{className:"px-3 py-2 align-top",children:e.jsx("span",{className:`inline-block text-[10px] font-bold px-2 py-0.5 rounded border ${T[D.level]}`,children:D.level})}),e.jsxs("td",{className:"px-3 py-2 align-top",children:[e.jsxs("span",{className:`text-sm font-bold tabular-nums ${D.level==="FAIL"?"text-red-700":D.level==="WARN"?"text-amber-700":"text-emerald-700"}`,children:[D.ratio.toFixed(2),":1"]}),e.jsxs("div",{className:"text-[10px] text-slate-500",children:[D.isLargeText?"Large text":"Normal text"," · ",D.fontSizePx.toFixed(0),"px ",D.fontWeight]})]}),e.jsxs("td",{className:"px-3 py-2 align-top",children:[e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("span",{className:"w-4 h-4 rounded border border-slate-300",style:{backgroundColor:D.colorHex}}),e.jsx("span",{className:"font-mono text-[10px]",children:D.colorHex})]}),e.jsxs("div",{className:"text-[10px] text-slate-500",children:["target ",D.goldMatch]})]}),e.jsxs("td",{className:"px-3 py-2 align-top",children:[e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("span",{className:"w-4 h-4 rounded border border-slate-300",style:{backgroundColor:D.bgHex}}),e.jsx("span",{className:"font-mono text-[10px]",children:D.bgHex}
1275)]}),e.jsxs("div",{className:"text-[10px] text-slate-500",children:["from <",D.bgFromTag,">",D.bgSource==="gradient"?" · gradient":D.bgSource==="page-default"?" · default":""]})]}),e.jsxs("td",{className:"px-3 py-2 align-top",children:[e.jsx("code",{className:"text-[10px] text-slate-700 break-all",children:D.tag}),e.jsx("div",{className:"text-[10px] text-slate-400 break-all max-w-[220px]",children:D.selector})]}),e.jsxs("td",{className:"px-3 py-2 align-top",children:[e.jsxs("span",{className:"text-[11px] text-slate-700 italic",children:['"',D.text,'"']}),D.note&&e.jsxs("div",{className:"text-[10px] text-amber-700 mt-1",children:["â ",D.note]})]}),e.jsx("td",{className:"px-3 py-2 align-top",children:e.jsxs("div",{className:"flex flex-col gap-1.5 min-w-[120px]",children:[e.jsxs("button",{onClick:()=>S(D.targetId,V),className:"text-[10px] font-bold text-[#355E3B] hover:text-[#2A3D24] inline-flex items-center gap-1 px-2 py-1 rounded border border-[#355E3B]/30 hover:border-[#355E3B]/60",children:[e.jsx(ms,{size:10})," Highlight"]}),z&&e.jsx("button",{onClick:()=>{!M||M.status==="idle"||M.status==="error"?w(D,B):_(B)},disabled:(M==null?void 0:M.status)==="loading",className:"text-[10px] font-bold inline-flex items-center gap-1 px-2 py-1 rounded border bg-gradient-to-r from-[#355E3B] to-[#2A3D24] text-[#D4AF37] border-[#D4AF37]/40 hover:from-[#2A3D24] hover:to-[#1F2C1A] disabled:opacity-60",title:"Ask gemini-3-flash for the minimal CSS override that lifts this above 4.5:1",children:(M==null?void 0:M.status)==="loading"?e.jsxs(e.Fragment,{children:[e.jsx(de,{size:10,className:"animate-spin"})," Thinkingâ¦"]}):(M==null?void 0:M.status)==="done"?e.jsxs(e.Fragment,{children:[e.jsx(Qe,{size:10})," ",R?"Hide fix":"Show fix"]}):e.jsxs(e.Fragment,{children:[e.jsx(Qe,{size:10})," Suggest Fix"]})})]})})]}),z&&R&&e.jsx("tr",{className:"border-t border-slate-100",children:e.jsx("td",{colSpan:7,className:"p-0",children:e.jsx(Nae,{fixKey:B,fixState:M,finding:D,copiedKey:x,onCopy:C,onClose:()=>_(B),onRetry:()=>w(D,B)})})})]},`${D.selector}-${L}`)})})]})})]}),e.jsxs("details",{className:"bg-white rounded-xl border border-slate-200 p-4 text-xs text-slate-600",children:[e.jsx("summary",{className:"cursor-pointer font-bold text-slate-800",children:"How this audit works"}),e.jsxs("div",{className:"mt-3 space-y-2 leading-relaxed",children:[e.jsxs("p",{children:["Each target is loaded into a same-origin ",e.jsx("code",{children:"<iframe>"}),". Foundation surfaces are mounted via the ",e.jsx("code",{children:"/admin/foundation-contrast-audit/preview"})," helper route, which wraps each component in ",e.jsx("code",{children:".z-foundation-scope"}),". The Scholar Portal is loaded directly at ",e.jsx("code",{children:"/scholar"})," (already wrapped in ",e.jsx("code",{children:".z-scholarship-scope"}),")."]}),e.jsxs("p",{children:["After the iframe signals it is ready, a ",e.jsx("code",{children:"TreeWalker(SHOW_TEXT)"})," visits every non-whitespace text node inside the scope wrapper. For each text node, the parent element's computed ",e.jsx("code",{children:"color"})," is matched against ",e.jsx("code",{children:"#D4AF37"}),", ",e.jsx("code",{children:"#B8962E"}),", and ",e.jsx("code",{children:"#E6D2A0"})," (Euclidean RGB tolerance ±",q8,")."]}),e.jsxs("p",{children:["The effective background is resolved by walking up the ancestor chain until the first opaque ",e.jsx("code",{children:"background-color"})," is found. CSS gradients are approximated from their first colour-stop and flagged. If no opaque ancestor exists, the page default",e.jsx("code",{children:" #FAF6EE"})," (Soft Cream) is used."]}),e.jsx("p",{children:"Contrast is computed with the WCAG 2.1 relative-luminance formula. Thresholds: normal text needs â¥4.5:1 for AA, â¥7:1 for AAA. Large text (â¥24px, or â¥18.66px bold) needs â¥3:1 for AA, â¥4.5:1 for AAA. Anything below the AA threshold is flagged."})]})]})]})]})]})},W8=[{hex:"#FAF6EE",rgb:[250,246,238],label:"Soft Cream"},{hex:"#FDFAF3",rgb:[253,250,243],label:"Cream Light"},{hex:"#F5EFE3",rgb:[245,239,227],label:"Cream Warm"},{hex:"#F8F1E4",rgb:[248,241,228],label:"Cream Vintage"}],H8=[{hex:"#5A0018",rgb:[90,0,24],label:"Dark Burgundy"},{hex:"#800020",rgb:[128,0,32],label:"Burgundy"},{hex:"#6B0F1A",rgb:[107,15,26],label:"Burgundy Mid"},{hex:"#3B0A11",rgb:[59,10,17],label:"Blackened Plum"},{hex:"#4A0014",rgb:[74,0,20],label:"Burgundy Deep"}],kae=[{hex:"#E5C76B",rgb:[229,199,107],label:"Arctic Gold"},{hex:"#D4AF37",rgb:[212,175,55],label:"Metallic Gold"},{hex:"#E6D2A0",rgb:[230,210,160],label:"Gold Light"},{hex:"#B8962E",rgb:[184,150,46],label:"Gold Dark"},{hex:"#C4A24A",rgb:[196,162,74],label:"Arctic Gold Edge"},{hex:"#F0DEA3",rgb:[240,222,163],label:"Arctic Gold Cool"}],Sae=22,Cae=45,aj=50,Aae=[{id:"institute-landing",label:"Institute · Premium Landing",section:"premium-landing",family:"institute"},{id:"institute-admissions",label:"Institute · Admissions",section:"admissions",family:"institute"},{id:"institute-story",label:"Institute · Our Story",section:"our-story",family:"institute"},{id:"institute-contact",label:"Institute · Contact Us",section:"contact-us",family:"institute"},{id:"medspa-portal",label:"Med Spa · Portal",section:"med-spa-portal",family:"med-spa"},{id:"medspa-md-referral",label:"Med Spa · MD Referral",section:"md-referral",family:"med-spa"},{id:"salon-services",label:"Salon · Services",section:"salon-services",family:"salon"},{id:"salon-clinic",label:"Salon · Student Clinic",section:"student-clinic",family:"salon"},{id:"salon-zoras",label:"Salon · Zora's Salon",section:"zoras-salon",family:"salon"},{id:"wholesale-shop",label:"Wholesale · B2B Shop",section:"wholesale",family:"wholesale"},{id:"wholesale-shop-z",label:"Wholesale · Z-Shop",section:"shop",fam
1275ily:"wholesale"},{id:"wholesale-pro",label:"Wholesale · Professional Svc",section:"professional-services",family:"wholesale"}],Zc=Aae.map(t=>({...t,url:`/?section=${encodeURIComponent(t.section)}&audit=1`})),kE={institute:{bg:"bg-indigo-100",text:"text-indigo-800",label:"Institute"},"med-spa":{bg:"bg-rose-100",text:"text-rose-800",label:"Med Spa"},salon:{bg:"bg-fuchsia-100",text:"text-fuchsia-800",label:"Salon"},wholesale:{bg:"bg-amber-100",text:"text-amber-800",label:"Wholesale"}},cN=t=>{if(!t)return null;const s=t.trim().toLowerCase();if(s==="transparent"||s==="rgba(0, 0, 0, 0)"||s==="rgb(0, 0, 0, 0)")return{r:0,g:0,b:0,a:0};const n=s.match(/rgba?\(\s*([\d.]+)\s*[, ]\s*([\d.]+)\s*[, ]\s*([\d.]+)\s*(?:[,/ ]\s*([\d.]+%?)\s*)?\)/);if(n){let r=1;return n[4]!=null&&(r=n[4].endsWith("%")?parseFloat(n[4])/100:parseFloat(n[4])),{r:+n[1],g:+n[2],b:+n[3],a:r}}const a=s.match(/^#([0-9a-f]{3,8})$/i);if(a){let r=a[1];r.length===3&&(r=r.split("").map(u=>u+u).join("")),r.length===4&&(r=r.split("").map(u=>u+u).join(""));const i=parseInt(r.slice(0,2),16),o=parseInt(r.slice(2,4),16),l=parseInt(r.slice(4,6),16),c=r.length===8?parseInt(r.slice(6,8),16)/255:1;return{r:i,g:o,b:l,a:c}}return null},rj=t=>{const s=t/255;return s<=.03928?s/12.92:Math.pow((s+.055)/1.055,2.4)},SE=t=>.2126*rj(t.r)+.7152*rj(t.g)+.0722*rj(t.b),Eae=(t,s)=>{const n=SE(t),a=SE(s),r=Math.max(n,a),i=Math.min(n,a);return(r+.05)/(i+.05)},Ih=(t,s)=>{const n=t.r-s[0],a=t.g-s[1],r=t.b-s[2];return Math.sqrt(n*n+a*a+r*r)},L0=t=>{const s=n=>Math.round(n).toString(16).padStart(2,"0");return`#${s(t.r)}${s(t.g)}${s(t.b)}`.toUpperCase()},CE=t=>{if(t.a<.5)return"other";for(const s of W8)if(Ih(t,s.rgb)<=Sae)return"cream";for(const s of H8)if(Ih(t,s.rgb)<=Cae)return"burgundy";return"other"},Fae=t=>{if(t.a<.5)return"other";for(const s of H8)if(Ih(t,s.rgb)<=aj)return"burgundy";for(const s of kae)if(Ih(t,s.rgb)<=aj)return"gold";for(const s of W8)if(Ih(t,s.rgb)<=aj)return"cream";return"other"},Tae={r:255,g:255,b:255,a:1},Pae=(t,s)=>{let n=t;for(;n&&n.nodeType===1;){const a=s.getComputedStyle(n),r=cN(a.backgroundColor);if(r&&r.a>=.5){const o=CE(r);return o==="cream"||o==="burgundy"?{rgb:r,hex:L0(r),family:o,container:n,fromTag:n.tagName.toLowerCase()}:{rgb:r,hex:L0(r),family:"other",container:n,fromTag:n.tagName.toLowerCase()}}const i=a.backgroundImage;if(i&&i!=="none"&&/gradient/i.test(i)){const o=i.match(/#([0-9a-fA-F]{3,8})\b/),l=i.match(/rgba?\([^)]+\)/),c=o?`#${o[1]}`:l?l[0]:null;if(c){const u=cN(c);if(u&&u.a>=.5){const p=CE(u);if(p==="cream"||p==="burgundy")return{rgb:u,hex:L0(u),family:p,container:n,fromTag:n.tagName.toLowerCase()}}}}n=n.parentElement}return{rgb:Tae,hex:"#FFFFFF",family:"other",container:null,fromTag:"body"}},Dae=t=>{const s=[];let n=t,a=0;for(;n&&n.nodeType===1&&a<4;){let r=n.tagName.toLowerCase();if(n.id){r+=`#${n.id}`,s.unshift(r);break}const i=(n.getAttribute("class")||"").split(/\s+/).filter(Boolean).slice(0,2).join(".");i&&(r+=`.${i}`);const o=n.parentElement;if(o){const l=Array.from(o.children).filter(c=>c.tagName===n.tagName);l.length>1&&(r+=`:nth-of-type(${l.indexOf(n)+1})`)}s.unshift(r),n=n.parentElement,a++}return s.join(" > ")},Rae=t=>{if(t.id)return`#${t.id}`;const s=(t.getAttribute("class")||"").split(/\s+/).filter(Boolean).slice(0,3).join(".");return s?`${t.tagName.toLowerCase()}.${s}`:t.tagName.toLowerCase()},O0={"cream-low-contrast":"Rule 1 · Low contrast","cream-wrong-family":"Rule 1 · Wrong colour family","burgundy-low-contrast":"Rule 2 · Low contrast","burgundy-wrong-family":"Rule 2 · Wrong colour family","button-cream-violation":"Rule 1 · Button not burgundy","button-burgundy-violation":"Rule 2 · Button not gold"},Iae=(t,s,n)=>{const a=[],r=t.body;if(!r)return a;const i=new WeakSet,o=u=>{var m;let p=u;for(;p;){const x=(m=p.dataset)==null?void 0:m.surface;if(x==="cream"||x==="burgundy")return!0;const h=p.getAttribute("class")||"";if(/\bsurface-(cream|burgundy)\b/.test(h)||h.includes("z-foundation-scope")||h.includes("z-scholarship-scope"))return!0;p=p.parentElement}return!1},l=t.createTreeWalker(r,NodeFilter.SHOW_TEXT,{acceptNode:u=>{var h;if(!(((h=u.nodeValue)==null?void 0:h.trim())??""))return NodeFilter.FILTER_REJECT;const m=u.parentElement;if(!m)return NodeFilter.FILTER_REJECT;const x=m.tagName;return x==="SCRIPT"||x==="STYLE"||x==="NOSCRIPT"?NodeFilter.FILTER_REJECT:NodeFilter.FILTER_ACCEPT}});let c=l.nextNode();for(;c;){const u=c.parentElement;if(c=l.nextNode(),i.has(u)||o(u))continue;const p=s.getComputedStyle(u);if(p.visibility==="hidden"||p.display==="none")continue;const m=Pae(u,s);
1275if(m.family!=="cream"&&m.family!=="burgundy")continue;const x=cN(p.color);if(!x||x.a<.5)continue;const h=Fae(x),y=Eae(x,m.rgb),v=parseFloat(p.fontSize)||16,g=parseInt(p.fontWeight,10)||400,N=v>=24||v>=18.66&&g>=700,b=N?3:4.5,f=m.family==="cream"?"burgundy":"gold",j=u.tagName==="BUTTON"||u.closest("button")!==null||u.getAttribute("role")==="button";let S=null,w=m.family==="cream"?1:2;if(h!==f?j?S=m.family==="cream"?"button-cream-violation":"button-burgundy-violation":S=m.family==="cream"?"cream-wrong-family":"burgundy-wrong-family":y<b&&(S=m.family==="cream"?"cream-low-contrast":"burgundy-low-contrast"),!S)continue;i.add(u);const _=(u.textContent||"").trim().replace(/\s+/g," ");a.push({targetId:n.id,family:n.family,kind:S,ruleViolated:w,selector:Dae(u),containerSel:m.container?Rae(m.container):"body",containerTag:m.fromTag,tag:u.tagName.toLowerCase(),text:_.length>80?_.slice(0,77)+"â¦":_,isButton:j,bgHex:m.hex,bgFamily:m.family,textHex:L0(x),textFamily:h,ratio:Math.round(y*100)/100,fontSizePx:v,fontWeight:g,isLargeText:N}),u.setAttribute("data-elaudit-id",`${n.id}__${a.length}`)}return a},$ae=()=>Zc.map(t=>({target:t,status:"idle",findings:[]})),zae=t=>{const s=t.bgFamily==="cream"?"cream":"burgundy",n=t.bgFamily==="cream"?"#5A0018 (Burgundy)":"#E5C76B (Arctic Gold)",a=t.containerSel||"body";return[`/* Rule ${t.ruleViolated} violation â ${O0[t.kind]} */`,`/* Offending wrapper: ${a} (background ${t.bgHex})`,` Inner element: ${t.selector}`,` Current text colour: ${t.textHex} â Expected family: ${n}`,` Computed contrast: ${t.ratio.toFixed(2)}:1 (AA needs ${t.isLargeText?"3.0":"4.5"}:1) */`,"","/* Recommended fix â tag the wrapper declaratively: */",`<${t.containerTag} data-surface="${s}" class="â¦">`," â¦",` ${t.tag} { /* now auto-paired to the rule */ }`,`</${t.containerTag}>`,"","/* Equivalent class-based escape hatch (if you can't add the attribute): */",`${a} { /* no change needed â just add the class below */ }`,`${a}.surface-${s} { /* index.css §19.5 takes over */ }`].join(` 1276`)},AE={"add-data-surface":"Add data-surface attribute to wrapper","apply-surface-class":"Apply .surface-cream / .surface-burgundy class","swap-button-variant":"Swap to .btn-burgundy button variant","scoped-css-override":"Scoped CSS override on the element","swap-text-token":"Swap to a palette-compliant text token",other:"Custom override"},Lae=({fixKey:t,fixState:s,finding:n,copiedKey:a,onCopy:r,onClose:i,onRetry:o})=>{if(!s)return null;if(s.status==="loading")return e.jsxs("div",{className:"bg-gradient-to-br from-[#5A0018] to-[#3B0A11] px-5 py-4 flex items-center gap-3 border-l-4 border-[#E5C76B]",children:[e.jsx(de,{size:16,className:"animate-spin text-[#E5C76B]"}),e.jsxs("div",{className:"text-[#F0DEA3] text-xs font-semibold",children:["Asking ",e.jsx("span",{className:"font-mono text-[#E5C76B]",children:"google/gemini-3-flash"})," for the minimal Elegant-Luxury overrideâ¦"]})]});if(s.status==="error")return e.jsxs("div",{className:"bg-red-50 border-l-4 border-red-500 px-5 py-4 flex items-start justify-between gap-3",children:[e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(ve,{size:14,className:"text-red-600"}),e.jsx("p",{className:"text-[11px] font-bold text-red-800",children:"AI fix request failed"})]}),e.jsx("p",{className:"text-[11px] text-red-700 mt-1",children:s.error}),s.rawContent&&e.jsxs("details",{className:"mt-2",children:[e.jsx("summary",{className:"text-[10px] text-red-700 cursor-pointer font-bold",children:"View raw model output"}),e.jsx("pre",{className:"mt-1 text-[10px] bg-red-100/50 border border-red-200 rounded p-2 overflow-auto text-red-900 whitespace-pre-wrap",children:s.rawContent})]})]}),e.jsxs("div",{className:"flex items-center gap-2 shrink-0",children:[e.jsxs("button",{onClick:o,className:"text-[10px] font-bold text-red-800 hover:text-red-900 inline-flex items-center gap-1 px-2 py-1 rounded border border-red-300 hover:border-red-500 bg-white",children:[e.jsx(Be,{size:10})," Retry"]}),e.jsx("button",{onClick:i,"aria-label":"Close",className:"text-red-700 hover:text-red-900 p-1 rounded hover:bg-red-100",children:e.jsx(Ke,{size:12})})]})]});const l=s.fix;if(!l)return null;const c=a===t,u=l.projectedRatio>=(n.isLargeText?3:4.5),p=AE[l.strategy]||AE.other;return e.jsxs("div",{className:"bg-gradient-to-br from-[#5A0018] to-[#3B0A11] border-l-4 border-[#
1276E5C76B] px-5 py-4",children:[e.jsxs("div",{className:"flex items-start justify-between gap-3 mb-3",children:[e.jsxs("div",{className:"flex items-start gap-2.5 min-w-0",children:[e.jsx("div",{className:"w-7 h-7 rounded-lg bg-[#E5C76B]/15 border border-[#E5C76B]/40 flex items-center justify-center shrink-0",children:e.jsx(Qe,{size:13,className:"text-[#E5C76B]"})}),e.jsxs("div",{className:"min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[e.jsxs("p",{className:"text-[11px] font-bold uppercase tracking-wider text-[#E5C76B]",children:["AI Fix · ",p]}),e.jsx("span",{className:"text-[9px] font-bold uppercase tracking-wider px-1.5 py-0.5 rounded bg-[#E5C76B]/15 text-[#F0DEA3] border border-[#E5C76B]/30",children:s.model||"gemini-3-flash"})]}),e.jsx("p",{className:"text-[12px] text-[#F0DEA3] mt-0.5 leading-snug",children:l.summary})]})]}),e.jsx("button",{onClick:i,"aria-label":"Hide AI fix",className:"text-[#F0DEA3]/60 hover:text-[#E5C76B] p-1 rounded hover:bg-[#E5C76B]/10 shrink-0",children:e.jsx(Ke,{size:12})})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-3 mb-3",children:[e.jsxs("div",{className:"rounded-lg bg-red-500/15 border border-red-500/40 p-2.5",children:[e.jsx("div",{className:"text-[9px] font-bold uppercase tracking-wider text-red-200 mb-1",children:"Before"}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"w-3.5 h-3.5 rounded border border-white/20",style:{backgroundColor:n.bgHex}}),e.jsx("code",{className:"text-[10px] font-mono text-red-100",children:n.bgHex}),e.jsxs("span",{className:"text-[11px] font-bold text-red-100 tabular-nums ml-auto",children:[n.ratio.toFixed(2),":1"]})]}),e.jsxs("div",{className:"text-[10px] text-red-200/80 mt-0.5",children:["Rule ",n.ruleViolated," · FAIL"]})]}),e.jsxs("div",{className:`rounded-lg p-2.5 border ${u?"bg-emerald-500/15 border-emerald-400/50":"bg-amber-500/15 border-amber-400/50"}`,children:[e.jsx("div",{className:`text-[9px] font-bold uppercase tracking-wider mb-1 ${u?"text-emerald-200":"text-amber-200"}`,children:"Projected"}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"w-3.5 h-3.5 rounded border border-white/20",style:{backgroundColor:l.projectedBgHex}}),e.jsx("code",{className:`text-[10px] font-mono ${u?"text-emerald-100":"text-amber-100"}`,children:l.projectedBgHex}),e.jsxs("span",{className:`text-[11px] font-bold tabular-nums ml-auto ${u?"text-emerald-100":"text-amber-100"}`,children:[l.projectedRatio.toFixed(2),":1"]})]}),e.jsxs("div",{className:`text-[10px] mt-0.5 ${u?"text-emerald-200/80":"text-amber-200/80"}`,children:[l.projectedLevel,u?" · clears WCAG AA":" · still below AA threshold"]})]})]}),e.jsxs("div",{className:"rounded-lg bg-[#1F0A10] border border-[#E5C76B]/30 overflow-hidden",children:[e.jsxs("div",{className:"flex items-center justify-between px-3 py-1.5 border-b border-[#E5C76B]/20 bg-black/30",children:[e.jsxs("div",{className:"flex items-center gap-1.5 text-[10px] font-bold uppercase tracking-wider text-[#E5C76B]/80",children:[e.jsx("span",{children:"Minimal override"}),l.paletteTokensUsed.length>0&&e.jsx("span",{className:"flex items-center gap-1 ml-2",children:l.paletteTokensUsed.slice(0,4).map(m=>e.jsx("span",{title:m,className:"w-3 h-3 rounded border border-white/20",style:{backgroundColor:m.startsWith("#")?m:void 0}},m))})]}),e.jsx("button",{onClick:()=>r(t,l.cssSnippet),className:`text-[10px] font-bold inline-flex items-center gap-1 px-2 py-1 rounded border transition-colors ${c?"bg-emerald-500/20 text-emerald-300 border-emerald-400/60":"bg-[#E5C76B]/10 text-[#E5C76B] border-[#E5C76B]/40 hover:bg-[#E5C76B]/20"}`,children:c?e.jsxs(e.Fragment,{children:[e.jsx(xt,{size:10})," Copied"]}):e.jsxs(e.Fragment,{children:[e.jsx(Vm,{size:10})," Copy snippet"]})})]}),e.jsx("pre",{className:"text-[11px] leading-relaxed text-[#F0DEA3] font-mono px-3 py-2.5 overflow-x-auto whitespace-pre",children:l.cssSnippet||"/* no snippet returned */"})]}),l.htmlHint&&e.jsxs("div",{className:"mt-2 rounded-lg bg-black/25 border border-[#E5C76B]/20 px-3 py-2",children:[e.jsx("div",{className:"text-[9px] font-bold uppercase tracking-wider text-[#E5C76B]/70 mb-1",children:"HTML hint"}),e.jsx("code",{className:"text-[11px] text-[#F0DEA3] font-mono break-all",children:l.htmlHint})]}),l.rationale&&e.jsx("p",{className:"mt-3 text-[11px] text-[#F0DEA3]/85 leading-relaxed italic",children:l.rationale})]})},Oae=({onRowUpdate:t})=>{const[s,n]=re.useState(null),[a,r]=re.useState(!0),[i,o]=re.useState(!1),[l,c]=re.useState(null),u=re.useCallback(async()=>{r(!0);try{const{data:h,error:y}=await O.from("nightly_elegant_luxury_audit_runs").select("id, ran_at, source, total_violations, rule1_violations, rule2_violations, surfaces_scanned, regressed, email_sent, duration_ms, notes").order("ran_at",{ascending:!1}).limit(1).maybeSingle();y?(c(y.message),t==null||t(null)):(n(h),c(null),t==null||t(h))}catch(h){c((h==null?void 0:h.message)||String(h)),t==null||t(null)}finally{r(!1)}},[t]);re.useEffect(()=>{u()},[u]);const p=async()=>{o(!0),c(null);try{const{data:h,error:y}=await O.functions.invoke("nightly-elegant-luxury-audit",{body:{source:"admin-manual"}});y?c(y.message):(h==null?void 0:h.success)===!1&&c((h==null?void 0:h.error)||"Run failed"),await u()}catch(h){c((h==null?void 0:h.message)||String(h))}finally{o(!1)}},m=h=>{if(!h)return"â";const y=Date.now()-new Date(h).getTime();return y<6e4?"just now":y<36e5?`${Math.floor(y/6e4)}m ago`:y<864e5?`${Math.floor(y/36e5)}h ago`:`${Math.floor(y/864e5)}d ago`},x=!!s&&s.total_violations===0;return e.jsxs("div",{className:`inline-flex items-center gap-2 rounded-lg border px-3 py-1.5 text-[11px] font-semibold transition-colors ${a?"bg-slate-50 border-slate-200 text-slate-500":s?x?"bg-emerald-50 border-emerald-200 text-emerald-800":"bg-red-50 border-red-200 text-red-800":"bg-amber-50 border-amber-200 text-amber-800"}
1276`,title:s?`Last nightly run · ${new Date(s.ran_at).toLocaleString()} · ${s.source}`:"No nightly runs yet",children:[e.jsxs("div",{className:"flex flex-col leading-tight",children:[e.jsx("span",{className:"text-[9px] font-bold uppercase tracking-wider opacity-70",children:"Last nightly scan"}),e.jsx("span",{className:"flex items-center gap-1.5",children:a?e.jsxs(e.Fragment,{children:[e.jsx(de,{size:11,className:"animate-spin"})," loadingâ¦"]}):s?x?e.jsxs(e.Fragment,{children:[e.jsx(Ue,{size:11})," ",m(s.ran_at)," · clean · ",s.surfaces_scanned," surfaces"]}):e.jsxs(e.Fragment,{children:[e.jsx(ve,{size:11})," ",m(s.ran_at)," · ",s.total_violations," issue",s.total_violations===1?"":"s"," (R1:",s.rule1_violations," R2:",s.rule2_violations,")",s.regressed?" · regressed":"",s.email_sent?" · emailed":""]}):e.jsxs(e.Fragment,{children:[e.jsx(em,{size:11})," never run"]})}),l&&e.jsx("span",{className:"text-[9px] text-red-700 mt-0.5 max-w-[260px] truncate",children:l})]}),e.jsx("button",{onClick:p,disabled:i,title:"Trigger the nightly audit edge function now",className:"ml-1 inline-flex items-center gap-1 px-2 py-1 rounded border bg-white/60 hover:bg-white border-current/30 hover:border-current/60 text-[10px] font-bold disabled:opacity-50",children:i?e.jsxs(e.Fragment,{children:[e.jsx(de,{size:10,className:"animate-spin"})," Runningâ¦"]}):e.jsxs(e.Fragment,{children:[e.jsx(Xx,{size:10})," Run now"]})})]})},Mae=({row:t,loading:s})=>s?null:t?t.total_violations>0?e.jsxs("span",{className:"inline-flex items-center gap-1.5 rounded-full border border-red-300 bg-red-50 px-3 py-1.5 text-[11px] font-bold uppercase tracking-wider text-red-800",title:`Section 21 violations detected: ${t.total_violations} issue${t.total_violations===1?"":"s"} across ${t.surfaces_scanned} surfaces`,children:[e.jsx(ve,{size:11}),"Section 21 · ",t.total_violations," violation",t.total_violations===1?"":"s"]}):e.jsxs("span",{className:"inline-flex items-center gap-1.5 rounded-full border-2 border-emerald-400 bg-gradient-to-r from-emerald-50 to-emerald-100 px-3 py-1.5 text-[11px] font-bold uppercase tracking-wider text-emerald-800 shadow-sm",title:`Section 21 (Universal Cream + Burgundy Law) enforced across ${t.surfaces_scanned} surfaces · last verified ${new Date(t.ran_at).toLocaleString()} · ${t.source}`,children:[e.jsx(Ue,{size:12,className:"text-emerald-600"}),"Section 21 active",e.jsxs("span",{className:"ml-1 text-[9px] font-bold opacity-75 normal-case tracking-normal",children:["· ",t.surfaces_scanned," surfaces clean"]})]}):e.jsxs("span",{className:"inline-flex items-center gap-1.5 rounded-full border border-amber-300 bg-amber-50 px-3 py-1.5 text-[11px] font-bold uppercase tracking-wider text-amber-800",title:"Run the nightly audit to verify Section 21 (Universal Cream + Burgundy Law) is enforced",children:[e.jsx(em,{size:11})," Section 21 · awaiting first scan"]}),Bae=()=>{const[t,s]=d.useState($ae),[n,a]=d.useState(Zc[0].id),[r,i]=d.useState("all"),[o,l]=d.useState("all"),[c,u]=d.useState("all"),[p,m]=d.useState(""),[x,h]=d.useState("ratio"),[y,v]=d.useState("asc"),[g,N]=d.useState(new Set),[b,f]=d.useState(new Set),[j,S]=d.useState({}),[w,_]=d.useState(null),[C,E]=d.useState(null),[P,F]=d.useState(null),[I,D]=d.useState(!1),L=d.useCallback(K=>{F(K),D(!0)},[]),V=d.useRef(null),B=d.useRef(!1),A=t.find(K=>K.target.id===n)||t[0],z=d.useCallback(async K=>{const se=Zc.findIndex(J=>J.id===K);if(se<0)return[];const Y=Zc[se];return s(J=>J.map(te=>te.target.id===K?{...te,status:"loading",error:void 0,findings:[]}:te)),a(K),new Promise(J=>{const te=V.current;if(!te){J([]);return}let pe=!1;const Fe=()=>{te.removeEventListener("load",Oe)},ke=()=>{try{const ue=te.contentDocument,je=te.contentWindow;if(!ue||!je)throw new Error("Iframe document unavailable (cross-origin?)");s(le=>le.map(ye=>ye.target.id===K?{...ye,status:"scanning"}:ye)),setTimeout(()=>{try{const le=Iae(ue,je,Y);s(ye=>ye.map(we=>we.target.id===K?{...we,status:"done",findings:le,scannedAt:new Date}:we)),pe=!0,Fe(),J(le)}catch(le){s(ye=>ye.map(we=>we.target.id===K?{...we,status:"error",error:(le==null?void 0:le.message)||String(le)}:we)),pe=!0,Fe(),J([])}},900)}catch(ue){s(je=>je.map(le=>le.target.id===K?{...le,status:"error",error:(ue==null?void 0:ue.message)||String(ue)}:le)),pe=!0,Fe(),J([])}},Oe=()=>{setTimeout(()=>{pe||ke()},1800),setTimeout(()=>{pe||ke()},6e3)};te.addEventListener("load",Oe),te.src=Y.url})},[]),M=d.useCallback(async()=>{B.current=!1;for(const K of Zc){if(B.current)break;await z(K.id)}},[z]),R=(K,se)=>{if(n!==K){a(K);return}
1276const Y=V.current,J=Y==null?void 0:Y.contentDocument;if(!J)return;const te=`[data-elaudit-id="${K}__${se+1}"]`,pe=J.querySelector(te);pe&&(J.querySelectorAll("[data-elaudit-highlight]").forEach(Fe=>{Fe.style.outline="",Fe.style.outlineOffset="",Fe.removeAttribute("data-elaudit-highlight")}),pe.style.outline="3px solid #DC2626",pe.style.outlineOffset="2px",pe.setAttribute("data-elaudit-highlight","true"),pe.scrollIntoView({behavior:"smooth",block:"center"}),E(`${K}__${se}`))},T=d.useMemo(()=>{const K=t.flatMap(se=>se.findings);return{total:K.length,rule1:K.filter(se=>se.ruleViolated===1).length,rule2:K.filter(se=>se.ruleViolated===2).length,buttons:K.filter(se=>se.isButton).length,scanned:t.filter(se=>se.status==="done").length}},[t]),U=d.useMemo(()=>{const se=(c==="active"?A.findings:t.flatMap(J=>J.findings)).filter(J=>{if(r!=="all"&&J.family!==r||o!=="all"&&String(J.ruleViolated)!==o)return!1;if(p.trim()){const te=p.toLowerCase();if(!J.text.toLowerCase().includes(te)&&!J.selector.toLowerCase().includes(te)&&!J.containerSel.toLowerCase().includes(te))return!1}return!0}),Y=y==="asc"?1:-1;return se.sort((J,te)=>{const pe=J[x],Fe=te[x];return typeof pe=="number"&&typeof Fe=="number"?(pe-Fe)*Y:String(pe).localeCompare(String(Fe))*Y})},[t,A,c,r,o,p,x,y]),q=K=>{x===K?v(se=>se==="asc"?"desc":"asc"):(h(K),v("asc"))},H=K=>{N(se=>{const Y=new Set(se);return Y.has(K)?Y.delete(K):Y.add(K),Y})},G=async(K,se)=>{try{await navigator.clipboard.writeText(se)}catch{const Y=document.createElement("textarea");Y.value=se,document.body.appendChild(Y),Y.select();try{document.execCommand("copy")}catch{}document.body.removeChild(Y)}_(K),setTimeout(()=>_(Y=>Y===K?null:Y),1800)},W=d.useCallback(async(K,se)=>{f(Y=>{const J=new Set(Y);return J.add(se),J}),S(Y=>({...Y,[se]:{status:"loading"}}));try{const{data:Y,error:J}=await O.functions.invoke("fix-elegant-luxury-contrast",{body:{selector:K.selector,containerSel:K.containerSel,containerTag:K.containerTag,tag:K.tag,text:K.text,textHex:K.textHex,textFamily:K.textFamily,bgHex:K.bgHex,bgFamily:K.bgFamily,ratio:K.ratio,ruleViolated:K.ruleViolated,isButton:K.isButton,fontSizePx:K.fontSizePx,fontWeight:K.fontWeight,isLargeText:K.isLargeText,kind:O0[K.kind]}});if(J){S(te=>({...te,[se]:{status:"error",error:J.message||"Edge function call failed",receivedAt:new Date}}));return}if(!(Y!=null&&Y.success)){S(te=>({...te,[se]:{status:"error",error:(Y==null?void 0:Y.error)||"AI did not return a valid fix",rawContent:Y==null?void 0:Y.rawContent,model:Y==null?void 0:Y.model,receivedAt:new Date}}));return}S(te=>({...te,[se]:{status:"done",fix:Y.fix,model:Y.model,receivedAt:new Date}}))}catch(Y){S(J=>({...J,[se]:{status:"error",error:(Y==null?void 0:Y.message)||String(Y),receivedAt:new Date}}))}},[]),X=K=>{f(se=>{const Y=new Set(se);return Y.has(K)?Y.delete(K):Y.add(K),Y})},Q=()=>{const se=[["target","family","rule","kind","selector","container_selector","container_tag","tag","text","is_button","bg_hex","bg_family","text_hex","text_family","ratio","font_size_px","font_weight","is_large_text","suggested_data_surface"].join(",")];for(const pe of t)for(const Fe of pe.findings){const ke=Oe=>`"${String(Oe??"").replace(/"/g,'""')}"`;se.push([ke(pe.target.label),ke(Fe.family),ke(Fe.ruleViolated),ke(O0[Fe.kind]),ke(Fe.selector),ke(Fe.containerSel),ke(Fe.containerTag),ke(Fe.tag),ke(Fe.text),ke(Fe.isButton),ke(Fe.bgHex),ke(Fe.bgFamily),ke(Fe.textHex),ke(Fe.textFamily),ke(Fe.ratio),ke(Fe.fontSizePx),ke(Fe.fontWeight),ke(Fe.isLargeText),ke(Fe.bgFamily==="cream"?"cream":"burgundy")].join(","))}const Y=new Blob([se.join(` 1277`)],{type:"text/csv;charset=utf-8"}),J=URL.createObjectURL(Y),te=document.createElement("a");te.href=J,te.download=`elegant-luxury-audit-${new Date().toISOString().slice(0,19).replace(/[:T]/g,"-")}.csv`,te.click(),URL.revokeObjectURL(J)};return d.useEffect(()=>{const K=V.current,se=Zc.find(Y=>Y.id===n);!K||!se||K.src.endsWith(se.url)||(K.src=se.url)},[n]),e.jsxs("div",{className:"min-h-screen bg-slate-50",children:[e.jsx("header",{className:"bg-white border-b border-slate-200 sticky top-0 z-30",children:e.jsxs("div",{className:"max-w-[1600px] mx-auto px-6 py-4 flex items-center justify-between gap-4 flex-wrap",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsxs(be,{to:"/",className:"flex items-center gap-2 text-sm text-slate-500 hover:text-slate-700",children:[e.jsx(Je,{size:14})," Home"]}),e.jsx("div",{className:"h-5 w-px bg-slate-200"}),e.jsxs("div",{className:"flex items-center gap-2.5",children:[e.jsx("div",{className:"w-9 h-9 rounded-lg bg-gradient-to-br from-[#5A0018] to-[#3B0A11] flex items-center justify-center border border-[#
1277E5C76B]/40",children:e.jsx(Ie,{size:18,className:"text-[#E5C76B]"})}),e.jsxs("div",{children:[e.jsx("h1",{className:"text-base font-bold text-slate-900 tracking-tight",children:"Elegant Luxury Contrast Audit"}),e.jsx("p",{className:"text-[11px] text-slate-500",children:"Cream â Burgundy · Burgundy â Gold · Institute / Med Spa / Salon / Wholesale"})]})]})]}),e.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[e.jsx(Mae,{row:P,loading:!I}),e.jsx(Oae,{onRowUpdate:L}),e.jsxs("button",{onClick:Q,disabled:T.total===0,className:"inline-flex items-center gap-2 px-3 py-2 rounded-lg bg-white border border-slate-200 text-xs font-semibold text-slate-700 hover:bg-slate-50 disabled:opacity-50",children:[e.jsx(us,{size:13})," Export CSV"]}),e.jsxs("button",{onClick:M,className:"inline-flex items-center gap-2 px-3 py-2 rounded-lg bg-[#5A0018] text-[#E5C76B] text-xs font-bold hover:bg-[#3B0A11] shadow-sm border border-[#E5C76B]/40",children:[e.jsx(Xx,{size:13})," Scan All Surfaces"]})]})]})}),e.jsx("div",{className:"max-w-[1600px] mx-auto px-6 pt-6",children:e.jsx("div",{className:"grid grid-cols-2 md:grid-cols-5 gap-3 mb-6",children:[{label:"Surfaces scanned",value:`${T.scanned} / ${Zc.length}`,icon:e.jsx(Ym,{size:14}),color:"text-slate-700",bg:"bg-white border-slate-200"},{label:"Total violations",value:T.total,icon:e.jsx(ve,{size:14}),color:"text-red-700",bg:"bg-red-50 border-red-200"},{label:"Rule 1 (creamâburgundy)",value:T.rule1,icon:e.jsx(em,{size:14}),color:"text-amber-700",bg:"bg-amber-50 border-amber-200"},{label:"Rule 2 (burgundyâgold)",value:T.rule2,icon:e.jsx(em,{size:14}),color:"text-rose-700",bg:"bg-rose-50 border-rose-200"},{label:"Button violations",value:T.buttons,icon:e.jsx(ve,{size:14}),color:"text-orange-700",bg:"bg-orange-50 border-orange-200"}].map(K=>e.jsxs("div",{className:`rounded-xl border p-4 ${K.bg}`,children:[e.jsxs("div",{className:`flex items-center gap-1.5 text-[10px] font-bold uppercase tracking-wider ${K.color} opacity-80`,children:[K.icon,K.label]}),e.jsx("p",{className:`text-2xl font-bold mt-1 ${K.color}`,children:K.value})]},K.label))})}),e.jsxs("div",{className:"max-w-[1600px] mx-auto px-6 pb-10 grid grid-cols-12 gap-6",children:[e.jsxs("aside",{className:"col-span-12 lg:col-span-3 space-y-2",children:[e.jsx("div",{className:"text-[10px] font-bold uppercase tracking-wider text-slate-500 mb-2 px-1",children:"Audit Targets"}),t.map(K=>{const se=K.findings.length,Y=K.target.id===n,J=kE[K.target.family];return e.jsxs("button",{onClick:()=>a(K.target.id),className:`w-full text-left rounded-lg border p-3 transition-all ${Y?"bg-white border-[#5A0018] shadow-md ring-1 ring-[#5A0018]":"bg-white border-slate-200 hover:border-slate-300"}`,children:[e.jsxs("div",{className:"flex items-center justify-between gap-2",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"text-xs font-bold text-slate-800 truncate",children:K.target.label}),e.jsx("p",{className:"text-[10px] text-slate-500 truncate font-mono",children:K.target.url})]}),e.jsx("span",{className:`text-[9px] font-bold uppercase tracking-wider px-1.5 py-0.5 rounded ${J.bg} ${J.text}`,children:J.label})]}),e.jsxs("div",{className:"flex items-center justify-between gap-2 mt-2",children:[e.jsxs("div",{className:"flex items-center gap-1.5",children:[K.status==="idle"&&e.jsx("span",{className:"text-[10px] text-slate-400",children:"Not scanned"}),K.status==="loading"&&e.jsxs(e.Fragment,{children:[e.jsx(de,{size:11,className:"animate-spin text-slate-500"}),e.jsx("span",{className:"text-[10px] text-slate-500",children:"Loadingâ¦"})]}),K.status==="scanning"&&e.jsxs(e.Fragment,{children:[e.jsx(de,{size:11,className:"animate-spin text-amber-600"}),e.jsx("span",{className:"text-[10px] text-amber-700",children:"Scanningâ¦"})]}),K.status==="done"&&se===0&&e.jsxs(e.Fragment,{children:[e.jsx(Ue,{size:11,className:"text-emerald-600"}),e.jsx("span",{className:"text-[10px] text-emerald-700 font-bold",children:"Clean"})]}),K.status==="done"&&se>0&&e.jsxs(e.Fragment,{children:[e.jsx(ve,{size:11,className:"text-red-600"}),e.jsxs("span",{className:"text-[10px] text-red-700 font-bold",children:[se," issue",se===1?"":"s"]})]}),K.status==="error"&&e.jsxs(e.Fragment,{children:[e.jsx(em,{size:11,className:"text-red-600"}),e.jsx("span",{className:"text-[10px] text-red-700",children:"Error"})]})]}),e.jsxs("span",{role:"button",tabIndex:0,onClick:te=>{te.stopPropagation(),z(K.target.id)},onKeyDown:te=>{te.key==="Enter"&&(te.stopPropagation(),z(K.target.id))},className:"inline-flex items-center gap-1 text-[10px] font-bold text-[#5A0018] hover:text-[#3B0A11] px-2 py-0.5 rounded border border-[#5A0018]/20 hover:border-[#5A0018]/40 cursor-pointer",children:[e.jsx(Be,{size:9})," Scan"]})]})]},K.target.id)})]}),e.jsxs("section",{className:"col-span-12 lg:col-span-9 space-y-4",children:[e.jsxs("div",{className:"bg-white rounded-xl border border-slate-200 overflow-hidden",children:[e.jsxs("div",{className:"flex items-center justify-between gap-3 px-4 py-2.5 border-b border-slate-200 bg-slate-50",children:[e.jsxs("div",{className:"flex items-center gap-2 text-xs text-slate-600 font-mono truncate",children:[e.jsx(Ua,{size:12,className:"text-slate-400 shrink-0"}),e.jsx("span",{className:"truncate",children:A.target.url})]}),e.jsxs("a",{href:A.target.url,target:"_blank",rel:"noopener noreferrer",className:"text-[10px] font-bold text-slate-500 hover:text-slate-700 inline-flex items-center gap-1",children:["Open in new tab ",e.jsx(Ua,{size:10})]})]}),e.jsx("iframe",{ref:V,title:"Elegant Luxury Audit Preview",className:"w-full h-[460px] bg-white",sandbox:"allow-same-origin allow-scripts allow-forms"})]}),e.jsxs("div",{className:"bg-white rounded-xl border border-slate-200 p-4",children:[e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3 mb-3",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"text-base font-bold text-slate-900",children:c==="active"?A.target.label:"All scanned surfaces"}),e.jsxs("p",{className:"text-xs text-slate-500",children:[U.length," violation",U.length===1?"":"s"," shown",c==="active"&&A.scannedAt&&` · last scanned ${A.scannedAt.toLocaleTimeString()}`]})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsxs("div",{className:"relative",children:[e.jsx(Bt,{size:12,className:"absolute left-2 top-1/2 -translate-y-1/2 text-slate-400"}),e.jsx("input",{value:p,onChange:K=>m(K.target.value),placeholder:"Search text or selectorâ¦",className:"pl-7 pr-2 py-1.5 text-xs rounded-md border border-slate-200 focus:outline-none focus:border-[#5A0018] w-48"})]}),e.jsxs("select",{value:c,onChange:K=>u(K.target.value),className:"text-xs px-2 py-1.5 rounded-md border border-slate-200 focus:outline-none",children:[e.jsx("option",{value:"all",children:"All surfaces"}),e.jsx("option",{value:"active",children:"Active surface only"})]}),e.jsxs("select",{value:r,onChange:K=>i(K.target.value),className:"text-xs px-2 py-1.5 rounded-md border border-slate-200 focus:outline-none",children:[e.jsx("option",{value:"all",children:"All families"}),e.jsx("option",{value:"institute",children:"Institute"}),e.jsx("option",{value:"med-spa",children:"Med Spa"}),e.jsx("option",{value:"salon",children:"Salon"}),e.jsx("option",{value:"wholesale",children:"Wholesale"})]}),e.jsxs("select",{value:o,onChange:K=>l(K.target.value),className:"text-xs px-2 py-1.5 rounded-md border border-slate-200 focus:outline-none",children:[e.jsx("option",{value:"all",children:"Rules 1 & 2"}),e.jsx("option",{value:"1",children:"Rule 1 only (creamâburgundy)"}),e.jsx("option",{value:"2",children:"Rule 2 only (burgundyâgold)"})]}),e.jsxs("button",{onClick:()=>z(A.target.id),className:"inline-flex items-center gap-1.5 px-3 py-1.5 rounded-md bg-[#5A0018] text-[#E5C76B] text-xs font-bold hover:bg-[#3B0A11] border border-[#
1277E5C76B]/40",children:[e.jsx(Be,{size:11})," Re-scan active"]})]})]}),A.status==="error"&&e.jsxs("div",{className:"mb-3 rounded-lg border-l-4 border-red-500 bg-red-50 p-3 text-xs text-red-800",children:[e.jsx("strong",{children:"Audit error:"})," ",A.error]}),U.length===0&&A.status==="done"&&e.jsxs("div",{className:"text-center py-10 rounded-lg border-2 border-dashed border-emerald-300 bg-emerald-50",children:[e.jsx(Ue,{size:28,className:"mx-auto text-emerald-600 mb-2"}),e.jsx("p",{className:"text-sm font-bold text-emerald-800",children:"No Elegant Luxury contrast violations found"}),e.jsx("p",{className:"text-xs text-emerald-700 mt-1",children:"Every cream and burgundy container in scope already pairs to the correct rule."})]}),U.length>0&&e.jsx("div",{className:"overflow-x-auto rounded-lg border border-slate-200",children:e.jsxs("table",{className:"w-full text-xs",children:[e.jsx("thead",{className:"bg-slate-50 text-slate-600",children:e.jsxs("tr",{className:"text-left",children:[[["family","Surface"],["kind","Violation"],["ratio","Ratio"],["textHex","Text"],["bgHex","Background"],["tag","Element"]].map(([K,se])=>e.jsx("th",{className:"px-3 py-2 font-bold uppercase tracking-wider text-[10px] cursor-pointer hover:bg-slate-100",onClick:()=>q(K),children:e.jsxs("span",{className:"inline-flex items-center gap-1",children:[se,e.jsx(hO,{size:9,className:x===K?"text-[#5A0018]":"text-slate-400"})]})},K)),e.jsx("th",{className:"px-3 py-2 font-bold uppercase tracking-wider text-[10px]",children:"Text snippet"}),e.jsx("th",{className:"px-3 py-2 font-bold uppercase tracking-wider text-[10px]",children:"Action"})]})}),e.jsx("tbody",{className:"bg-white",children:U.map((K,se)=>{const Y=t.find(je=>je.target.id===K.targetId),J=Y.findings.indexOf(K),te=`${K.targetId}__${J}`,pe=C===te,Fe=g.has(te),ke=kE[K.family],Oe=zae(K),ue=w===te;return e.jsxs(re.Fragment,{children:[e.jsxs("tr",{className:`border-t border-slate-100 hover:bg-slate-50 ${pe?"bg-yellow-50":""}`,children:[e.jsxs("td",{className:"px-3 py-2 align-top",children:[e.jsx("span",{className:`inline-block text-[10px] font-bold px-2 py-0.5 rounded ${ke.bg} ${ke.text}`,children:ke.label}),e.jsx("div",{className:"text-[10px] text-slate-500 mt-0.5 truncate max-w-[140px]",children:Y.target.label.split("· ")[1]||Y.target.label})]}),e.jsxs("td",{className:"px-3 py-2 align-top",children:[e.jsx("span",{className:`inline-block text-[10px] font-bold px-2 py-0.5 rounded border ${K.ruleViolated===1?"bg-amber-100 text-amber-800 border-amber-200":"bg-rose-100 text-rose-800 border-rose-200"}`,children:O0[K.kind]}),K.isButton&&e.jsx("div",{className:"text-[10px] font-bold text-orange-700 mt-0.5",children:"button element"})]}),e.jsxs("td",{className:"px-3 py-2 align-top",children:[e.jsxs("span",{className:`text-sm font-bold tabular-nums ${K.ratio<3?"text-red-700":"text-amber-700"}`,children:[K.ratio.toFixed(2),":1"]}),e.jsxs("div",{className:"text-[10px] text-slate-500",children:[K.isLargeText?"Large":"Normal"," · ",K.fontSizePx.toFixed(0),"px ",K.fontWeight]})]}),e.jsxs("td",{className:"px-3 py-2 align-top",children:[e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("span",{className:"w-4 h-4 rounded border border-slate-300",style:{backgroundColor:K.textHex}}),e.jsx("span",{className:"font-mono text-[10px]",children:K.textHex})]}),e.jsxs("div",{className:"text-[10px] text-slate-500",children:["family: ",K.textFamily]})]}),e.jsxs("td",{className:"px-3 py-2 align-top",children:[e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("span",{className:"w-4 h-4 rounded border border-slate-300",style:{backgroundColor:K.bgHex}}),e.jsx("span",{className:"font-mono text-[10px]",children:K.bgHex})]}),e.jsxs("div",{className:"text-[10px] text-slate-500",children:[K.bgFamily," · <",K.containerTag,">"]})]}),e.jsxs("td",{className:"px-3 py-2 align-top",children:[e.jsx("code",{className:"text-[10px] text-slate-700 break-all",children:K.tag}),e.jsx("div",{className:"text-[10px] text-slate-400 break-all max-w-[200px]",children:K.containerSel})]}),e.jsx("td",{className:"px-3 py-2 align-top",children:e.jsxs("span",{className:"text-[11px] text-slate-700 italic",children:['"',K.text,'"']})}),e.jsx("td",{className:"px-3 py-2 align-top",children:e.jsxs("div",{className:"flex flex-col gap-1.5 min-w-[120px]",children:[e.jsxs("button",{onClick:()=>{a(K.targetId),setTimeout(()=>R(K.targetId,J),100)},className:"text-[10px] font-bold text-[#5A0018] hover:text-[#3B0A11] inline-flex items-center gap-1 px-2 py-1 rounded border border-[#5A0018]/30 hover:border-[#5A0018]/60",children:[e.jsx(ms,{size:10})," Highlight"]}),e.jsxs("button",{onClick:()=>H(te),className:"text-[10px] font-bold inline-flex items-center gap-1 px-2 py-1 rounded border border-[#5A0018]/40 text-[#5A0018] bg-white hover:bg-[#FAF6EE]",children:[e.jsx(Qe,{size:10})," ",Fe?"Hide fix":"Show fix"]}),(()=>{const je=j[te],le=b.has(te),ye=(je==null?void 0:je.status)==="loading",we=(je==null?void 0:je.status)==="done";return e.jsx("button",{onClick:()=>{!je||je.status==="idle"||je.status==="error"?W(K,te):X(te)},disabled:ye,title:"Ask gemini-3-flash for the minimal Elegant-Luxury override that lifts this above 4.5:1",className:"text-[10px] font-bold inline-flex items-center gap-1 px-2 py-1 rounded border bg-gradient-to-r from-[#5A0018] to-[#3B0A11] text-[#E5C76B] border-[#
1277E5C76B]/40 hover:from-[#3B0A11] hover:to-[#2A0710] disabled:opacity-60",children:ye?e.jsxs(e.Fragment,{children:[e.jsx(de,{size:10,className:"animate-spin"})," Thinkingâ¦"]}):we?e.jsxs(e.Fragment,{children:[e.jsx(Qe,{size:10})," ",le?"Hide AI fix":"Show AI fix"]}):e.jsxs(e.Fragment,{children:[e.jsx(Qe,{size:10})," AI Fix"]})})})()]})})]}),Fe&&e.jsx("tr",{className:"border-t border-slate-100",children:e.jsx("td",{colSpan:8,className:"p-0",children:e.jsxs("div",{className:"bg-gradient-to-br from-[#5A0018] to-[#3B0A11] border-l-4 border-[#E5C76B] px-5 py-4",children:[e.jsxs("div",{className:"flex items-start justify-between gap-3 mb-3",children:[e.jsxs("div",{className:"flex items-start gap-2.5 min-w-0",children:[e.jsx("div",{className:"w-7 h-7 rounded-lg bg-[#E5C76B]/15 border border-[#E5C76B]/40 flex items-center justify-center shrink-0",children:e.jsx(Qe,{size:13,className:"text-[#E5C76B]"})}),e.jsxs("div",{className:"min-w-0",children:[e.jsxs("p",{className:"text-[11px] font-bold uppercase tracking-wider text-[#E5C76B]",children:["Recommended fix · add ",e.jsxs("code",{className:"font-mono",children:['data-surface="',K.bgFamily==="cream"?"cream":"burgundy",'"']})]}),e.jsxs("p",{className:"text-[12px] text-[#F0DEA3] mt-0.5 leading-snug",children:["Tag the offending wrapper ",e.jsx("code",{className:"text-[#E5C76B] font-mono",children:K.containerSel})," so the Elegant Luxury smart-contrast layer (index.css §19.5) auto-paints all descendant text and buttons in the correct palette."]})]})]}),e.jsx("button",{onClick:()=>H(te),"aria-label":"Hide fix",className:"text-[#F0DEA3]/60 hover:text-[#E5C76B] p-1 rounded hover:bg-[#E5C76B]/10 shrink-0",children:e.jsx(Ke,{size:12})})]}),e.jsxs("div",{className:"rounded-lg bg-[#1F0A10] border border-[#E5C76B]/30 overflow-hidden",children:[e.jsxs("div",{className:"flex items-center justify-between px-3 py-1.5 border-b border-[#E5C76B]/20 bg-black/30",children:[e.jsxs("div",{className:"text-[10px] font-bold uppercase tracking-wider text-[#E5C76B]/80",children:["Snippet · Rule ",K.ruleViolated]}),e.jsx("button",{onClick:()=>G(te,Oe),className:`text-[10px] font-bold inline-flex items-center gap-1 px-2 py-1 rounded border transition-colors ${ue?"bg-emerald-500/20 text-emerald-300 border-emerald-400/60":"bg-[#E5C76B]/10 text-[#E5C76B] border-[#E5C76B]/40 hover:bg-[#E5C76B]/20"}`,children:ue?e.jsxs(e.Fragment,{children:[e.jsx(xt,{size:10})," Copied"]}):e.jsxs(e.Fragment,{children:[e.jsx(Vm,{size:10})," Copy snippet"]})})]}),e.jsx("pre",{className:"text-[11px] leading-relaxed text-[#F0DEA3] font-mono px-3 py-2.5 overflow-x-auto whitespace-pre",children:Oe})]})]})})}),b.has(te)&&e.jsx("tr",{className:"border-t border-slate-100",children:e.jsx("td",{colSpan:8,className:"p-0",children:e.jsx(Lae,{fixKey:te,fixState:j[te],finding:K,copiedKey:w,onCopy:G,onClose:()=>X(te),onRetry:()=>W(K,te)})})})]},`${te}-${se}`)})})]})})]}),e.jsxs("details",{className:"bg-white rounded-xl border border-slate-200 p-4 text-xs text-slate-600",children:[e.jsx("summary",{className:"cursor-pointer font-bold text-slate-800",children:"How this audit works"}),e.jsxs("div",{className:"mt-3 space-y-2 leading-relaxed",children:[e.jsxs("p",{children:["Each Institute, Med Spa, Salon, and Wholesale surface is loaded into a same-origin",e.jsx("code",{children:" <iframe>"})," via ",e.jsx("code",{children:"/?section=<id>&audit=1"}),". AppContext bootstraps ",e.jsx("code",{children:"activeSection"})," from that query parameter, so the iframe lands directly on the target surface."]}),e.jsxs("p",{children:["After the iframe load + a 1.8s React/Suspense settle delay, a ",e.jsx("code",{children:"TreeWalker"}),"visits every non-whitespace text node. For each text node the auditor walks ancestors until it finds the first opaque background, classifies it as ",e.jsx("em",{children:"cream"}),", ",e.jsx("em",{children:"burgundy"}),", or ",e.jsx("em",{children:"other"})," using a tolerant palette match (Euclidean RGB distance)."]}),e.jsxs("p",{children:["When the background is cream or burgundy, the auditor checks two things: (1) does the text colour belong to the expected family (burgundy on cream, gold on burgundy)? and (2) does the computed contrast clear WCAG AA (4.5:1 normal / 3.0:1 large)? Any failure on either check is recorded as a violation with the offending wrapper's short selector. The ",e.jsx("strong",{children:"Show fix"}
1277)," button prints a deterministic",e.jsx("code",{children:" data-surface"})," snippet, and the ",e.jsx("strong",{children:"AI Fix"})," button calls the",e.jsx("code",{children:" fix-elegant-luxury-contrast"})," edge function (google/gemini-3-flash via the AI Gateway), which returns the minimal palette-compliant CSS or HTML override and renders it inline as a copy-to-clipboard snippet with projected before/after contrast ratios."]}),e.jsxs("p",{children:["Containers that already declare ",e.jsx("code",{children:'data-surface="cream"'})," /",e.jsx("code",{children:'data-surface="burgundy"'})," (or ",e.jsx("code",{children:".surface-cream"}),"/",e.jsx("code",{children:".surface-burgundy"}),") are excluded â they've already opted into the rule. Foundation + Scholarship scopes are excluded too; they have their own audit at ",e.jsx(be,{to:"/admin/foundation-contrast-audit",className:"text-[#5A0018] underline",children:"/admin/foundation-contrast-audit"}),"."]})]})]})]})]})]})};var Uae=Object.defineProperty,Oo=(t,s)=>Uae(t,"name",{value:s,configurable:!0}),sk="Checkbox",[qae,lxe]=Va(sk),[Wae,nk]=qae(sk);function G8(t){const{__scopeCheckbox:s,checked:n,children:a,defaultChecked:r,disabled:i,form:o,name:l,onCheckedChange:c,required:u,value:p="on",internal_do_not_use_render:m}=t,[x,h]=Po({prop:n,defaultProp:r??!1,onChange:c,caller:sk}),[y,v]=d.useState(null),[g,N]=d.useState(null),b=d.useRef(!1),[f,j]=d.useReducer(_=>_+1,0),S=y?!!o||!!y.closest("form"):!0,w={checked:x,disabled:i,setChecked:h,control:y,setControl:v,name:l,form:o,value:p,hasConsumerStoppedPropagationRef:b,userInteractionCount:f,onUserInteraction:j,required:u,defaultChecked:ko(r)?!1:r,isFormControl:S,bubbleInput:g,setBubbleInput:N};return e.jsx(Wae,{scope:s,...w,children:Z8(m)?m(w):a})}Oo(G8,"CheckboxProvider");var Hae="CheckboxTrigger",Gae=d.forwardRef(Oo(function({__scopeCheckbox:s,onKeyDown:n,onClick:a,...r},i){const{control:o,value:l,disabled:c,checked:u,required:p,setControl:m,setChecked:x,hasConsumerStoppedPropagationRef:h,onUserInteraction:y,isFormControl:v,bubbleInput:g}=nk(Hae,s),N=It(i,m),b=d.useRef(u);return d.useEffect(()=>{const f=o==null?void 0:o.form;if(f){const j=Oo(()=>x(b.current),"reset");return f.addEventListener("reset",j),()=>f.removeEventListener("reset",j)}},[o,x]),e.jsx(yt.button,{type:"button",role:"checkbox","aria-checked":ko(u)?"mixed":u,"aria-required":p,"data-state":ak(u),"data-disabled":c?"":void 0,disabled:c,value:l,...r,ref:N,onKeyDown:at(n,f=>{f.key==="Enter"&&f.preventDefault()}),onClick:at(a,f=>{y(),x(j=>ko(j)?!0:!j),g&&v&&(h.current=f.isPropagationStopped(),h.current||f.stopPropagation())})})},"CheckboxTrigger")),V8=d.forwardRef(Oo(function(s,n){const{__scopeCheckbox:a,name:r,checked:i,defaultChecked:o,required:l,disabled:c,value:u,onCheckedChange:p,form:m,...x}=s;return e.jsx(G8,{__scopeCheckbox:a,checked:i,defaultChecked:o,disabled:c,required:l,onCheckedChange:p,name:r,form:m,value:u,internal_do_not_use_render:({isFormControl:h})=>e.jsxs(e.Fragment,{children:[e.jsx(Gae,{...x,ref:n,__scopeCheckbox:a}),h&&e.jsx(Kae,{__scopeCheckbox:a})]})})},"Checkbox")),Vae="CheckboxIndicator",Zae=d.forwardRef(Oo(function(s,n){const{__scopeCheckbox:a,forceMount:r,...i}=s,o=nk(Vae,a);return e.jsx(ic,{present:r||ko(o.checked)||o.checked===!0,children:e.jsx(yt.span,{"data-state":ak(o.checked),"data-disabled":o.disabled?"":void 0,...i,ref:n,style:{pointerEvents:"none",...s.style}})})},"CheckboxIndicator")),Yae="CheckboxBubbleInput",Kae=d.forwardRef(Oo(function({__scopeCheckbox:s,onClick:n,...a},r){const{control:i,hasConsumerStoppedPropagationRef:o,userInteractionCount:l,checked:c,defaultChecked:u,required:p,disabled:m,name:x,value:h,form:y,bubbleInput:v,setBubbleInput:g}=nk(Yae,s),N=It(r,g),b=Wb(i),f=d.useRef(!1),j=d.useRef(c),S=d.useRef(l);d.useEffect(()=>{const _=v;if(!_)return;const C=window.HTMLInputElement.prototype,P=Object.getOwnPropertyDescriptor(C,"checked").set,F=l!==S.current;S.current=l;const I=j.current!==c;j.current=c;const D=!(F&&o.current);if(I&&P){f.current=!F;const L=new Event("click",{bubbles:D});_.indeterminate=ko(c),P.call(_,ko(c)?!1:c),_.dispatchEvent(L),f.current=!1}},[v,c,o,l]);const w=d.useRef(ko(c)?!1:c);return e.jsx(yt.input,{type:"checkbox","aria-hidden":!0,defaultChecked:u??w.current,required:p,disabled:m,name:x,value:h,form:y,...a,tabIndex:-1,ref:N,onClick:at(n,_=>{f.current&&_.stopPropagation()}),style:{...a.style,...b,position:"absolute",pointerEvents:"none",opacity:0,margin:0,transform:"translateX(-100%)"}})},"CheckboxBubbleInput"));function Z8(t){return typeof t=="function"}Oo(Z8,"isFunction");function ko(t){return t==="indeterminate"}Oo(ko,"isIndeterminate");function ak(t){return ko(t)?"indeterminate":t?"checked":"unchecked"}Oo(ak,"getState");const rk=d.forwardRef(({className:t,...s},n)=>e.jsx(V8,{ref:n,className:et("peer h-4 w-4 shrink-0 rounded-sm border border-primary/60 ring-offset-background focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:bg-primary data-[state=checked]:text-primary-foreground transition-colors duration-200",t),...s,children:e.jsx(Zae,{className:et("flex items-center justify-center text-current"),children:e.jsx(xt,{className:"h-3.5 w-3.5 transition-transform duration-200"})})}));rk.displayName=V8.displayName;const Qae={imported:"bg-emerald-50 text-emerald-900 border-emerald-200",matched:"bg-blue-50 text-blue-900 border-blue-200",no_match:"bg-slate-50 text-slate-600 border-slate-200",error:"bg-red-50 text-red-900 border-red-200"},Jae={imported:"Imported",matched:"Matched (preview)",no_match:"No match",error:"Error"};function Xae({collections:t,onImported:s}){var N;
1277const[n,a]=d.useState(!0),[r,i]=d.useState(""),[o,l]=d.useState("all"),[c,u]=d.useState(!0),[p,m]=d.useState(!1),[x,h]=d.useState(null),[y,v]=d.useState(null),g=async b=>{const f=r.trim();if(!f||!/^https?:\/\//i.test(f)){v("Paste a valid zorganics.com page URL (must start with http:// or https://)");return}v(null),m(!0),h(null);try{const{data:j,error:S}=await O.functions.invoke("scrape-zorganics-product-images",{body:{url:f,dryRun:b,replace:c,collectionHandle:o==="all"?void 0:o}});if(S)throw new Error(S.message);if(j!=null&&j.error)throw new Error(j.error);h(j),!b&&(j!=null&&j.summary)?(Wt({title:`Scrape complete: ${j.summary.imported} imported`,description:`${j.summary.no_match} unmatched, ${j.summary.errors} errors from ${j.candidatesFound} images found`,variant:j.summary.errors>0?"destructive":"default"}),s==null||s()):b&&(j!=null&&j.summary)&&Wt({title:`Preview: ${j.summary.matched} products matched`,description:`${j.candidatesFound} images found on page. Review below, then Import.`})}catch(j){console.error("Scrape failed",j),v((j==null?void 0:j.message)||"Scrape failed")}finally{m(!1)}};return e.jsxs(Gn,{className:"mb-6 border-blue-200",children:[e.jsxs("button",{type:"button",onClick:()=>a(b=>!b),className:"w-full flex items-center justify-between p-4 text-left",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Bo,{className:"h-5 w-5 text-blue-600"}),e.jsxs("div",{children:[e.jsx("h3",{className:"font-semibold text-slate-900",children:"Scrape images from a zorganics.com page"}),e.jsx("p",{className:"text-xs text-slate-500",children:"Paste a product or collection page URL â we extract the official photos and auto-match them to products by name."})]})]}),n?e.jsx(Od,{className:"h-5 w-5 text-slate-400"}):e.jsx(Gt,{className:"h-5 w-5 text-slate-400"})]}),n&&e.jsxs("div",{className:"px-4 pb-4 space-y-3",children:[e.jsxs("div",{className:"flex flex-col sm:flex-row gap-3",children:[e.jsx(Jr,{type:"url",placeholder:"https://www.zorganics.com/zycolics-derm (product or collection page)",value:r,onChange:b=>{i(b.target.value),y&&v(null)},disabled:p,className:"flex-1"}),e.jsxs(Tx,{value:o,onValueChange:l,disabled:p,children:[e.jsx(zm,{className:"sm:w-64",children:e.jsx(Px,{placeholder:"Limit matching to collection"})}),e.jsxs(Lm,{children:[e.jsx(ec,{value:"all",children:"Match against all products"}),t.filter(b=>b.handle).map(b=>e.jsxs(ec,{value:b.handle,children:[b.title," (",b.productIds.length,")"]},b.id))]})]})]}),e.jsxs("label",{className:"flex items-start gap-2 text-sm text-slate-700 cursor-pointer select-none",children:[e.jsx(rk,{checked:c,onCheckedChange:b=>u(!!b),disabled:p,className:"mt-0.5"}),e.jsx("span",{children:"Replace existing images (removes AI placeholders so only the official scraped photo remains)."})]}),y&&e.jsxs("div",{className:"flex items-start gap-2 text-sm text-red-700 bg-red-50 border border-red-200 rounded-lg p-2",children:[e.jsx(Mt,{className:"h-4 w-4 flex-shrink-0 mt-0.5"}),e.jsx("span",{className:"break-words",children:y})]}),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsxs(gt,{variant:"outline",onClick:()=>g(!0),disabled:p||!r.trim(),children:[p?e.jsx(de,{className:"h-4 w-4 mr-2 animate-spin"}):e.jsx(Bt,{className:"h-4 w-4 mr-2"}),"Preview matches"]}),e.jsxs(gt,{onClick:()=>g(!1),disabled:p||!r.trim(),children:[p?e.jsx(de,{className:"h-4 w-4 mr-2 animate-spin"}):e.jsx(us,{className:"h-4 w-4 mr-2"}),"Scrape & import"]})]}),(x==null?void 0:x.success)&&e.jsxs("div",{className:"pt-2",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2 mb-2 text-sm",children:[e.jsxs("span",{className:"text-slate-500",children:[x.candidatesFound," images found · ",x.productsConsidered," products considered"]}),x.summary&&e.jsxs(e.Fragment,{children:[e.jsxs(wn,{className:"bg-emerald-600 hover:bg-emerald-600",children:[x.summary.imported," imported"]}),e.jsxs(wn,{className:"bg-blue-600 hover:bg-blue-600",children:[x.summary.matched," matched"]}),e.jsxs(wn,{variant:"outline",children:[x.summary.no_match," no match"]}),x.summary.errors>0&&e.jsxs(wn,{className:"bg-red-600 hover:bg-red-600",children:[x.summary.errors," errors"]})]})]}),e.jsx("div",{className:"max-h-72 overflow-y-auto space-y-1.5",children:(N=x.report)==null?void 0:N.map(b=>e.jsxs("div",{className:`flex items-start gap-2 text-sm p-2 rounded border ${Qae[b.status]}`,children:[b.status==="imported"?e.jsx(xt,{className:"h-4 w-4 flex-shrink-0 mt-0.5"}):b.status==="error"?e.jsx(Mt,{className:"h-4 w-4 flex-shrink-0 mt-0.5"}):e.jsx("span",{className:"h-4 w-4 flex-shrink-0"}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[e.jsx("span",{className:"font-medium truncate",children:b.productName}),e.jsx(wn,{variant:"outline",className:"text-[10px] px-1 py-0",children:Jae[b.status]}),typeof b.score=="number"&&e.jsxs("span",{className:"text-[10px] opacity-70",children:["match ",(b.score*100).toFixed(0),"%"]})]}),b.matchedName&&e.jsxs("div",{className:"text-xs opacity-75 truncate",children:["â³ page: â",b.matchedName,"â"]}),(b.sourceUrl||b.imageUrl)&&e.jsx("div",{className:"text-[10px] font-mono opacity-60 truncate",children:b.sourceUrl||b.imageUrl}),b.error&&e.jsx("div",{className:"text-xs",children:b.error})]})]},b.productId))})]}),x&&x.success===!1&&e.jsxs("div",{className:"flex items-start gap-2 text-sm text-amber-800 bg-amber-50 border border-amber-200 rounded-lg p-2",children:[e.jsx(Mt,{className:"h-4 w-4 flex-shrink-0 mt-0.5"}),e.jsx("span",{children:x.error||"No product images could be extracted from that page."})]})]})]})}const EE="product-images",nl=t=>t.toLowerCase().replace(/\.[a-z0-9]+$/i,"").replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,""),ij=t=>{var s;return((s=t.metadata)==null?void 0:s.ai_photo)===!0};
1277function ere(){const[t,s]=d.useState([]),[n,a]=d.useState([]),[r,i]=d.useState("all"),[o,l]=d.useState(!0),[c,u]=d.useState(null),[p,m]=d.useState(""),[x,h]=d.useState("all"),[y,v]=d.useState(null),[g,N]=d.useState(!1),[b,f]=d.useState(!1),[j,S]=d.useState(null),[w,_]=d.useState(null),[C,E]=d.useState(null),[P,F]=d.useState(""),[I,D]=d.useState(!1),[L,V]=d.useState(null),[B,A]=d.useState(!0),z=d.useRef({}),M=d.useRef(0),R=async()=>{l(!0);const{data:ue,error:je}=await O.from("ecom_products").select("id, name, handle, price, product_type, images, status, metadata").order("name");je?Wt({title:"Error loading products",description:je.message,variant:"destructive"}):s(ue||[]),l(!1)},T=async()=>{const{data:ue}=await O.from("ecom_collections").select("id, title, handle").order("title"),{data:je}=await O.from("ecom_product_collections").select("collection_id, product_id");if(ue){const le={};(je||[]).forEach(ye=>{var we;(le[we=ye.collection_id]||(le[we]=[])).push(ye.product_id)}),a(ue.map(ye=>({id:ye.id,title:ye.title,handle:ye.handle,productIds:le[ye.id]||[]})))}};d.useEffect(()=>{R(),T()},[]);const U=async(ue,je)=>{const le=je.name.split(".").pop()||"jpg",ye=`${ue.id}/${Date.now()}.${le}`,{error:we}=await O.storage.from(EE).upload(ye,je,{cacheControl:"3600",upsert:!0,contentType:je.type});if(we)throw we;const{data:He}=O.storage.from(EE).getPublicUrl(ye),Lt=He.publicUrl;if(!Lt)throw new Error("Could not generate public URL");const ut=Array.isArray(ue.images)?ue.images:[],ge=[Lt,...ut.filter(mt=>mt&&!mt.includes("/storage/"))],Ne={...ue.metadata||{},ai_photo:!1},{error:lt}=await O.from("ecom_products").update({images:ge,metadata:Ne,updated_at:new Date().toISOString()}).eq("id",ue.id);if(lt)throw lt;return{url:Lt}},q=async(ue,je)=>{if(je){if(!je.type.startsWith("image/")){Wt({title:"Invalid file",description:"Please upload an image file",variant:"destructive"});return}if(je.size>10*1024*1024){Wt({title:"File too large",description:"Maximum file size is 10MB",variant:"destructive"});return}u(ue.id);try{const{url:le}=await U(ue,je);Wt({title:"Image uploaded",description:`${ue.name} updated`});const ye=[le,...(Array.isArray(ue.images)?ue.images:[]).filter(we=>we&&!we.includes("/storage/"))];s(we=>we.map(He=>He.id===ue.id?{...He,images:ye,metadata:{...He.metadata||{},ai_photo:!1}}:He))}catch(le){console.error("Upload error",le),Wt({title:"Upload failed",description:le.message||"Unknown error",variant:"destructive"})}finally{u(null),z.current[ue.id]&&(z.current[ue.id].value="")}}},H=ue=>{var je;(je=z.current[ue])==null||je.click()},G=async()=>{if(!C)return;const ue=P.trim();if(!ue){V("Please paste an image URL");return}if(!/^https?:\/\//i.test(ue)){V("URL must start with http:// or https://");return}V(null),D(!0);try{const{data:je,error:le}=await O.functions.invoke("import-product-image-from-url",{body:{productId:C.id,imageUrl:ue,replace:B}});if(le)throw new Error(le.message);if(je!=null&&je.error)throw new Error(je.error);if(!(je!=null&&je.publicUrl))throw new Error("Edge function did not return a publicUrl");await O.from("ecom_products").update({metadata:{...C.metadata||{},ai_photo:!1}}).eq("id",C.id),s(ye=>ye.map(we=>we.id===C.id?{...we,images:Array.isArray(je.images)?je.images:[je.publicUrl],metadata:{...we.metadata||{},ai_photo:!1}}:we)),Wt({title:"Official image imported",description:`${C.name} now shows the real packaging shot`}),E(null),F("")}catch(je){console.error("URL import failed",je),V((je==null?void 0:je.message)||"Failed to import image")}finally{D(!1)}},W=ue=>{E(ue),F(""),V(null),A(!0)},X=(ue,je)=>{const le=nl(ue);if(!le)return null;let ye=je.find(we=>we.handle&&nl(we.handle)===le);return ye||(ye=je.find(we=>we.handle&&(le.includes(nl(we.handle))||nl(we.handle).includes(le))),ye)||(ye=je.find(we=>nl(we.name)===le),ye)||(ye=je.find(we=>nl(we.name).length>3&&(le.includes(nl(we.name))||nl(we.name).includes(le))),ye)?ye:null},Q=async ue=>{const je=ue.filter(ut=>ut.type.startsWith("image/"));if(je.length===0){Wt({title:"No images",description:"No image files were dropped",variant:"destructive"});return}f(!0),_(null),S({done:0,total:je.length});const le=[];let ye=[...t];for(let ut=0;ut<je.length;ut++){const ge=je[ut],Ne=X(ge.name,ye);if(!Ne)le.push({fileName:ge.name,status:"unmatched",message:"No matching product"});else if(ge.size>10*1024*1024)le.push({fileName:ge.name,productName:Ne.name,status:"error",message:"File exceeds 10MB"});else try{const{url:lt}=await U(Ne,ge),mt=[lt,...(Array.isArray(Ne.images)?Ne.images:[]).filter(ae=>ae&&!ae.includes("/storage/"))];ye=ye.map(ae=>ae.id===Ne.id?{...ae,images:mt,metadata:{...ae.metadata||{},ai_photo:!1}}:ae),le.push({fileName:ge.name,productName:Ne.name,status:"success"})}catch(lt){le.push({fileName:ge.name,productName:Ne.name,status:"error",message:lt.message||"Upload failed"})}S({done:ut+1,total:je.length})}s(ye),_(le),f(!1),S(null);const we=le.filter(ut=>ut.status==="success").length,He=le.filter(ut=>ut.status==="unmatched").length,Lt=le.filter(ut=>ut.status==="error").length;Wt({title:`Batch complete: ${we} uploaded`,description:`${He} unmatched, ${Lt} failed`,variant:Lt>0||He>
12770?"destructive":"default"})},K=(ue,je)=>{ue.preventDefault(),ue.stopPropagation(),v(je)},se=ue=>{ue.preventDefault(),ue.stopPropagation(),v(null)},Y=async(ue,je)=>{ue.preventDefault(),ue.stopPropagation(),v(null),M.current=0,N(!1);const le=Array.from(ue.dataTransfer.files);if(le.length===0)return;const ye=le.find(we=>we.type.startsWith("image/"));if(!ye){Wt({title:"Invalid file",description:"Please drop an image file",variant:"destructive"});return}await q(je,ye)};d.useEffect(()=>{const ue=we=>{var He;(He=we.dataTransfer)!=null&&He.types.includes("Files")&&(we.preventDefault(),M.current+=1,N(!0))},je=we=>{we.preventDefault(),M.current-=1,M.current<=0&&(M.current=0,N(!1))},le=we=>{var He;(He=we.dataTransfer)!=null&&He.types.includes("Files")&&we.preventDefault()},ye=we=>{we.preventDefault(),M.current=0,N(!1)};return window.addEventListener("dragenter",ue),window.addEventListener("dragleave",je),window.addEventListener("dragover",le),window.addEventListener("drop",ye),()=>{window.removeEventListener("dragenter",ue),window.removeEventListener("dragleave",je),window.removeEventListener("dragover",le),window.removeEventListener("drop",ye)}},[]);const J=d.useCallback(async ue=>{if(ue.preventDefault(),ue.stopPropagation(),M.current=0,N(!1),ue.target.closest("[data-product-card]"))return;const le=Array.from(ue.dataTransfer.files);le.length!==0&&await Q(le)},[t]),te=n.find(ue=>ue.id===r),pe=te?new Set(te.productIds):null,Fe=t.filter(ue=>{var le;if(pe&&!pe.has(ue.id)||p&&!ue.name.toLowerCase().includes(p.toLowerCase())&&!((le=ue.handle)!=null&&le.toLowerCase().includes(p.toLowerCase())))return!1;const je=Array.isArray(ue.images)&&ue.images.length>0&&ue.images[0];return!(x==="missing"&&je||x==="has"&&!je||x==="ai"&&!ij(ue))}),ke=pe?t.filter(ue=>pe.has(ue.id)):t,Oe={total:ke.length,withImages:ke.filter(ue=>Array.isArray(ue.images)&&ue.images.length>0&&ue.images[0]).length,missing:ke.filter(ue=>!Array.isArray(ue.images)||ue.images.length===0||!ue.images[0]).length,ai:ke.filter(ue=>ij(ue)).length};return e.jsxs("div",{className:"min-h-screen bg-slate-50 py-8 px-4 relative",onDrop:J,onDragOver:ue=>ue.preventDefault(),children:[g&&!b&&e.jsx("div",{className:"fixed inset-0 z-50 bg-blue-600/30 backdrop-blur-sm flex items-center justify-center pointer-events-none",children:e.jsxs("div",{className:"bg-white rounded-2xl shadow-2xl p-12 border-4 border-dashed border-blue-500 text-center",children:[e.jsx(Ri,{className:"h-16 w-16 text-blue-600 mx-auto mb-4"}),e.jsx("h2",{className:"text-2xl font-bold text-slate-900 mb-2",children:"Drop image files anywhere"}),e.jsxs("p",{className:"text-slate-600 max-w-md",children:["Multiple files will be auto-matched to products by filename",e.jsx("br",{}),"(e.g., ",e.jsx("code",{className:"bg-slate-100 px-1.5 py-0.5 rounded text-sm",children:"facial-cleanser.jpg"})," â product with handle ",e.jsx("code",{className:"bg-slate-100 px-1.5 py-0.5 rounded text-sm",children:"facial-cleanser"}),")"]}),e.jsx("p",{className:"text-slate-500 text-sm mt-3",children:"Or drop on a single product card to update just that product"})]})}),b&&j&&e.jsx("div",{className:"fixed inset-0 z-50 bg-black/60 flex items-center justify-center",children:e.jsxs("div",{className:"bg-white rounded-2xl shadow-2xl p-8 text-center max-w-md",children:[e.jsx(de,{className:"h-12 w-12 text-blue-600 mx-auto mb-4 animate-spin"}),e.jsx("h2",{className:"text-xl font-bold text-slate-900 mb-2",children:"Uploadingâ¦"}),e.jsxs("p",{className:"text-slate-600 mb-4",children:[j.done," of ",j.total," files processed"]}),e.jsx("div",{className:"w-full bg-slate-200 rounded-full h-2 overflow-hidden",children:e.jsx("div",{className:"bg-blue-600 h-2 transition-all",style:{width:`${j.done/j.total*100}%`}})})]})}),e.jsxs("div",{className:"max-w-7xl mx-auto",children:[e.jsxs("div",{className:"mb-8",children:[e.jsx("h1",{className:"text-3xl font-bold text-slate-900 mb-2",children:"Product Image Manager"}),e.jsxs("p",{className:"text-slate-600",children:["Upload, drag-and-drop, or paste an official product image URL. Files go to the"," ",e.jsx("code",{className:"bg-slate-100 px-2 py-0.5 rounded text-sm",children:"product-images"})," bucket and the public URL is saved to"," ",e.jsx("code",{className:"bg-slate-100 px-2 py-0.5 rounded text-sm",children:"ecom_products.images"}),"."]}),e.jsxs("div",{className:"mt-3 inline-flex items-start gap-2 text-sm text-blue-700 bg-blue-50 border border-blue-200 rounded-lg px-3 py-2",children:[e.jsx(Xs,{className:"h-4 w-4 mt-0.5 flex-shrink-0"}),e.jsxs("span",{children:[e.jsx("strong",{children:"Replace AI placeholders:"})," filter to a collection (e.g."," ",e.jsx("em",{children:"Dry, Aging, & Fine Lines"}),"), find products tagged"," ",e.jsxs(wn,{variant:"outline",className:"text-[10px] border-violet-400 text-violet-700 px-1 py-0",children:[e.jsx(Qe,{className:"h-2.5 w-2.5 mr-0.5"}),"AI photo"]})," ","and click ",e.jsx("em",{children:"Paste official image URL"})," to import the real packaging shot from zorganics.com."]})]})]}),e.jsx(Xae,{collections:n,onImported:()=>{R(),T()}}),w&&e.jsxs(Gn,{className:"p-4 mb-6 border-blue-200",children:[e.jsxs("div",{className:"flex items-center justify-between mb-3",children:[e.jsx("h3",{className:"font-semibold text-slate-900",children:"Batch Upload Results"}),e.jsx(gt,{variant:"ghost",size:"sm",onClick:()=>_(null),children:e.jsx(Ke,{className:"h-4 w-4"})})]}),e.jsx("div",{className:"max-h-64 overflow-y-auto space-y-1",children:w.map((ue,je)=>e.jsxs("div",{className:`flex items-start gap-2 text-sm p-2 rounded ${ue.status==="success"?"bg-emerald-50 text-emerald-900":ue.status==="unmatched"?"bg-amber-50 text-amber-900":"bg-red-50 text-red-900"}`,children:[ue.status==="success"?e.jsx(xt,{className:"h-4 w-4 flex-shrink-0 mt-0.5"}):e.jsx(Mt,{className:"h-4 w-4 flex-shrink-0 mt-0.5"}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("div",{className:"font-mono text-xs truncate",children:ue.fileName}),ue.productName&&e.jsxs("div",{className:"text-xs opacity-75",children:["â ",ue.productName]}),ue.message&&e.jsx("div",{className:"text-xs opacity-75",children:ue.message})]})]},je))})]}),e.jsxs("div",{className:"grid grid-cols-2 sm:grid-cols-4 gap-4 mb-6",children:[e.jsxs(Gn,{className:"p-4",children:[e.jsx("div",{className:"text-sm text-slate-500",children:"In Scope"}),e.jsx("div",{className:"text-2xl font-bold text-slate-900",children:Oe.total})]}),e.jsxs(Gn,{className:"p-4",children:[e.jsx("div",{className:"text-sm text-slate-500",children:"With Images"}),e.jsx("div",{className:"text-2xl font-bold text-emerald-700",children:Oe.withImages})]}),e.jsxs(Gn,{className:"p-4",children:[e.jsx("div",{className:"text-sm text-slate-500",children:"Missing Images"}),e.jsx("div",{className:"text-2xl font-bold text-amber-700",children:Oe.missing})]}),e.jsxs(Gn,{className:"p-4",children:[e.jsx("div",{className:"text-sm text-slate-500",children:"AI Placeholders"}),e.jsx("div",{className:"text-2xl font-bold text-violet-700",children:Oe.ai})]})]}),e.jsx(Gn,{className:"p-4 mb-6",children:e.jsxs("div",{className:"flex flex-col gap-3",children:[e.jsxs("div",{className:"flex flex-col sm:flex-row gap-3 items-stretch sm:items-center",children:[e.jsxs("div",{className:"flex-1 relative",children:[e.jsx(Bt,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-slate-400"}),e.jsx(Jr,{placeholder:"Search by product name or handleâ¦",value:p,onChange:ue=>m(ue.target.value),className:"pl-10"})]}),e.jsxs(Tx,{value:r,onValueChange:i,children:[e.jsx(zm,{className:"sm:w-72",children:e.jsx(Px,{placeholder:"Filter by collection"})}),e.jsxs(Lm,{children:[e.jsx(ec,{value:"all",children:"All Collections"}),n.map(ue=>e.jsxs(ec,{value:ue.id,children:[ue.title," (",ue.productIds.length,")"]},ue.id))]})]})]}),e.jsxs("div",{className:"flex gap-2 flex-wrap",children:[e.jsxs(gt,{variant:x==="all"?"default":"outline",size:"sm",onClick:()=>h("all"),children:["All (",Oe.total,")"]}),e.jsxs(gt,{variant:x==="missing"?"default":"outline",size:"sm",onClick:()=>h("missing"),children:["Missing (",Oe.missing,")"]}),e.jsxs(gt,{variant:x==="has"?"default":"outline",size:"sm",onClick:()=>
1277h("has"),children:["Has Image (",Oe.withImages,")"]}),e.jsxs(gt,{variant:x==="ai"?"default":"outline",size:"sm",onClick:()=>h("ai"),className:x==="ai"?"":"border-violet-300 text-violet-700 hover:bg-violet-50",children:[e.jsx(Qe,{className:"h-3.5 w-3.5 mr-1"}),"AI Placeholders (",Oe.ai,")"]})]})]})}),o?e.jsx("div",{className:"flex items-center justify-center py-16",children:e.jsx(de,{className:"h-8 w-8 animate-spin text-slate-400"})}):Fe.length===0?e.jsxs(Gn,{className:"p-12 text-center",children:[e.jsx(KS,{className:"h-12 w-12 mx-auto text-slate-300 mb-3"}),e.jsx("p",{className:"text-slate-500",children:"No products match your filter."})]}):e.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4 gap-4",children:Fe.map(ue=>{const je=Array.isArray(ue.images)&&ue.images[0],le=c===ue.id,ye=y===ue.id,we=ij(ue);return e.jsxs(Gn,{"data-product-card":!0,className:`overflow-hidden flex flex-col transition-all ${ye?"ring-4 ring-blue-500 ring-offset-2 scale-[1.02]":""}`,onDragOver:He=>K(He,ue.id),onDragEnter:He=>K(He,ue.id),onDragLeave:se,onDrop:He=>Y(He,ue),children:[e.jsxs("div",{className:"aspect-square bg-slate-100 relative",children:[je?e.jsx("img",{src:je,alt:ue.name,className:"w-full h-full object-cover",onError:He=>{He.target.style.display="none"}}):e.jsxs("div",{className:"absolute inset-0 flex flex-col items-center justify-center text-slate-400",children:[e.jsx(KS,{className:"h-12 w-12 mb-2"}),e.jsx("span",{className:"text-sm",children:"No image"})]}),le&&e.jsx("div",{className:"absolute inset-0 bg-black/60 flex items-center justify-center",children:e.jsx(de,{className:"h-8 w-8 animate-spin text-white"})}),ye&&!le&&e.jsxs("div",{className:"absolute inset-0 bg-blue-600/70 flex flex-col items-center justify-center text-white",children:[e.jsx(Ri,{className:"h-10 w-10 mb-2"}),e.jsx("span",{className:"font-semibold",children:"Drop to upload"})]}),we&&!le&&!ye&&e.jsxs(wn,{className:"absolute top-2 left-2 bg-violet-600 hover:bg-violet-600",children:[e.jsx(Qe,{className:"h-3 w-3 mr-1"}),"AI photo"]}),je&&!we&&!le&&!ye&&e.jsxs(wn,{className:"absolute top-2 right-2 bg-emerald-600 hover:bg-emerald-600",children:[e.jsx(xt,{className:"h-3 w-3 mr-1"}),"Real photo"]})]}),e.jsxs("div",{className:"p-4 flex-1 flex flex-col",children:[e.jsx("h3",{className:"font-semibold text-slate-900 line-clamp-2 mb-1",children:ue.name}),e.jsx("div",{className:"text-xs text-slate-500 mb-2",children:ue.handle}),e.jsxs("div",{className:"flex items-center gap-2 mb-3 flex-wrap",children:[e.jsxs("span",{className:"text-sm font-medium text-slate-700",children:["$",(ue.price/100).toFixed(2)]}),ue.product_type&&e.jsx(wn,{variant:"outline",className:"text-xs",children:ue.product_type}),e.jsx(wn,{variant:"outline",className:`text-xs ${ue.status==="active"?"border-emerald-500 text-emerald-700":"border-slate-300 text-slate-500"}`,children:ue.status})]}),e.jsx("input",{ref:He=>z.current[ue.id]=He,type:"file",accept:"image/*",className:"hidden",onChange:He=>{var ut;const Lt=(ut=He.target.files)==null?void 0:ut[0];Lt&&q(ue,Lt)}}),e.jsxs("div",{className:"mt-auto flex flex-col gap-2",children:[e.jsxs(gt,{onClick:()=>W(ue),disabled:le,className:"w-full",variant:we?"default":"outline",children:[e.jsx(Xs,{className:"h-4 w-4 mr-2"}),"Paste official image URL"]}),e.jsx(gt,{onClick:()=>H(ue.id),disabled:le,variant:"ghost",size:"sm",className:"w-full text-slate-600 hover:text-slate-900",children:le?e.jsxs(e.Fragment,{children:[e.jsx(de,{className:"h-4 w-4 mr-2 animate-spin"}),"Uploadingâ¦"]}):e.jsxs(e.Fragment,{children:[e.jsx(Ri,{className:"h-4 w-4 mr-2"}),je?"Replace by upload":"Upload or drop image"]})})]})]})]},ue.id)})})]}),e.jsx(s1,{open:!!C,onOpenChange:ue=>{!ue&&!I&&(E(null),F(""),V(null))},children:e.jsxs(af,{className:"sm:max-w-lg",children:[e.jsxs(rf,{children:[e.jsxs(of,{className:"flex items-center gap-2",children:[e.jsx(Xs,{className:"h-5 w-5 text-blue-600"}),"Import official product image"]}),e.jsx(E5,{children:C?e.jsxs(e.Fragment,{children:["Paste the official Zorganics image URL for"," ",e.jsx("strong",{className:"text-slate-900",children:C.name}),". The image will be fetched server-side, uploaded to the"," ",e.jsx("code",{className:"bg-slate-100 px-1 py-0.5 rounded text-xs",children:"product-images"})," bucket, and set as the product's primary image."]}):"Paste a publicly-accessible image URL."})]}),e.jsxs("div",{className:"space-y-3 py-2",children:[e.jsx(Jr,{type:"url",placeholder:"https://static.wixstatic.com/media/...",value:P,onChange:ue=>{F(ue.target.value),L&&V(null)},onKeyDown:ue=>{ue.key==="Enter"&&!I&&(ue.preventDefault(),G())},disabled:I,autoFocus:!0}),P&&/^https?:\/\//i.test(P.trim())&&e.jsxs("div",{className:"border rounded-lg p-2 bg-slate-50",children:[e.jsx("div",{className:"text-xs text-slate-500 mb-1.5",children:"Preview"}),e.jsx("img",{src:P.trim(),alt:"Preview",className:"max-h-40 mx-auto rounded",onError:ue=>{ue.target.style.display="none"}})]}),e.jsxs("label",{className:"flex items-start gap-2 text-sm text-slate-700 cursor-pointer select-none",children:[e.jsx(rk,{checked:B,onCheckedChange:ue=>A(!!ue),disabled:I,className:"mt-0.5"}),e.jsx("span",{children:"Replace existing images (recommended â removes the AI placeholder so only the real packaging shot remains). Uncheck to keep old images and add this one first."})]}),L&&e.jsxs("div",{className:"flex items-start gap-2 text-sm text-red-700 bg-red-50 border border-red-200 rounded-lg p-2",children:[e.jsx(Mt,{className:"h-4 w-4 flex-shrink-0 mt-0.5"}),e.jsx("span",{className:"break-words",children:L})]}),e.jsxs("p",{className:"text-xs text-slate-500",children:["Works with Wix static URLs (e.g."," ",e.jsx("code",{className:"bg-slate-100 px-1 py-0.5 rounded",children:"static.wixstatic.com/media/â¦"}),"), CDN links, or any direct image URL. Max 15 MB. Tip: on the live zorganics.com page, right-click the product photo â ",e.jsx("em",{children:"Copy image address"}),"."]})]}),e.jsxs(n1,{children:[e.jsx(gt,{variant:"outline",onClick:()=>{E(null),F(""),V(null)},disabled:I,children:"Cancel"}),e.jsx(gt,{onClick:G,disabled:I||!P.trim(),children:I?e.jsxs(e.Fragment,{children:[e.jsx(de,{className:"h-4 w-4 mr-2 animate-spin"}),"Importingâ¦"]}):e.jsxs(e.Fragment,{children:[e.jsx(Xs,{className:"h-4 w-4 mr-2"}),"Import image"]})})]})]})})]})}const Yc="#E6D2A0",cr="#FAF6EE",oj={approved:{label:"Approved",color:"#15803d",bg
1277:"#dcfce7",icon:Ue},pending:{label:"Pending",color:"#b45309",bg:"#fef3c7",icon:dt},suspended:{label:"Suspended",color:"#b91c1c",bg:"#fee2e2",icon:V_}},lj={1:"Authorized Retailer",2:"Professional Partner",3:"Exclusive Wellness Center"},FE={email:"",business_name:"",contact_name:"",business_type:"salon",assigned_tier:1,status:"approved",city:"",state:"",notes:""},tre=()=>{const[t,s]=d.useState([]),[n,a]=d.useState(!0),[r,i]=d.useState(!1),[o,l]=d.useState(null),[c,u]=d.useState(""),[p,m]=d.useState("all"),[x,h]=d.useState("all"),[y,v]=d.useState(null),[g,N]=d.useState(null),[b,f]=d.useState(!1),[j,S]=d.useState(null),[w,_]=d.useState({...FE}),[C,E]=d.useState(!1),[P,F]=d.useState(null),I=(H,G)=>{N({kind:H,msg:G}),setTimeout(()=>N(null),3500)},D=d.useCallback(async H=>{const{data:G,error:W}=await O.functions.invoke("manage-wholesale-partner",{body:H});if(W)throw new Error(W.message||"Request failed.");if(G!=null&&G.error)throw new Error(G.error);if((G==null?void 0:G.success)===!1)throw new Error((G==null?void 0:G.error)||"Request failed.");return G},[]),L=d.useCallback(async(H=!1)=>{H?i(!0):a(!0),l(null);try{const G=await D({action:"list"});s(G.partners||[])}catch(G){try{const{data:W,error:X}=await O.from("z_wholesale_partner_accounts").select("*").order("created_at",{ascending:!1});if(X)throw X;s(W||[])}catch(W){l(G.message||W.message||"Failed to load partner accounts.")}}finally{a(!1),i(!1)}},[D]);d.useEffect(()=>{L()},[L]);const V=async(H,G)=>{v(H.id);try{const X=(await D({action:"update",id:H.id,...G})).partner;s(Q=>Q.map(K=>K.id===H.id?{...K,...X||G}:K)),I("ok","Partner updated.")}catch(W){I("err",W.message||"Update failed.")}finally{v(null)}},B=(H,G)=>{H.assigned_tier!==G&&V(H,{assigned_tier:G})},A=(H,G)=>{H.status!==G&&V(H,{status:G})},z=async H=>{if(window.confirm(`Delete wholesale account for "${H.business_name}" (${H.email})? This cannot be undone.`)){v(H.id);try{await D({action:"delete",id:H.id}),s(G=>G.filter(W=>W.id!==H.id)),I("ok","Partner deleted.")}catch(G){I("err",G.message||"Delete failed.")}finally{v(null)}}},M=()=>{S(null),_({...FE}),F(null),f(!0)},R=H=>{S(H),_({email:H.email,business_name:H.business_name,contact_name:H.contact_name||"",business_type:H.business_type||"salon",assigned_tier:H.assigned_tier,status:H.status,city:H.city||"",state:H.state||"",notes:H.notes||""}),F(null),f(!0)},T=async()=>{if(F(null),!w.email.trim()||!w.email.includes("@")){F("A valid email is required.");return}if(!w.business_name.trim()){F("Business name is required.");return}E(!0);try{if(j){const G=(await D({action:"update",id:j.id,...w})).partner;s(W=>W.map(X=>X.id===j.id?{...X,...G||w}:X)),I("ok","Partner saved.")}else{const G=(await D({action:"create",...w})).partner;G?s(W=>[G,...W]):await L(!0),I("ok","Partner created.")}f(!1)}catch(H){F(H.message||"Save failed.")}finally{E(!1)}},U=d.useMemo(()=>{const H=c.trim().toLowerCase();return t.filter(G=>!(p!=="all"&&G.status!==p||x!=="all"&&String(G.assigned_tier)!==x||H&&!`${G.business_name} ${G.email} ${G.contact_name||""} ${G.city||""} ${G.state||""} ${G.business_type||""}`.toLowerCase().includes(H)))},[t,c,p,x]),q=d.useMemo(()=>({total:t.length,approved:t.filter(H=>H.status==="approved").length,pending:t.filter(H=>H.status==="pending").length,suspended:t.filter(H=>H.status==="suspended").length}),[t]);return e.jsxs("div",{className:"min-h-screen font-sans",style:{background:cr},children:[e.jsx("div",{style:{background:k,color:cr},children:e.jsxs("div",{className:"max-w-[1400px] mx-auto px-6 lg:px-10 py-6 flex flex-wrap items-center justify-between gap-4",children:[e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsxs(be,{to:"/",className:"inline-flex items-center gap-2 text-xs uppercase tracking-[0.2em] opacity-80 hover:opacity-100",children:[e.jsx(Je,{size:14})," Back to site"]}),e.jsx("span",{className:"hidden md:inline-block h-4 w-px",style:{background:"rgba(212,175,55,0.4)"}}),e.jsxs("div",{className:"hidden md:flex items-center gap-2",children:[e.jsx(Ie,{size:16,style:{color:$}}),e.jsx("span",{className:"text-[11px] uppercase tracking-[0.25em]",style:{color:$},children:"Admin · Wholesale Access"})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("button",{onClick:()=>L(!0),disabled:r,className:"inline-flex items-center gap-2 px-4 py-2 rounded-sm text-xs font-bold tracking-wide transition-all disabled:opacity-60",style:{background:"rgba(255,255,255,0.08)",color:cr,border:"1px solid rgba(212,175,55,0.3)"},children:[r?e.jsx(de,{size:14,className:"animate-spin"}):e.jsx(Be,{size:14}),"Refresh"]}),e.jsxs("button",{onClick:M,className:"inline-flex items-center gap-2 px-4 py-2 rounded-sm text-xs font-bold tracking-wide transition-all hover:shadow-md",style:{background:$,color:k},children:[e.jsx(tn,{size:14})," New Partner"]})]})]})}),e.jsxs("header",{className:"max-w-[1400px] mx-auto px-6 lg:px-10 pt-10 pb-6",children:[e.jsx("div",{className:"text-[11px] tracking-[0.3em] uppercase font-semibold",style:{color:$},children:"B2B Wholesale Partner Accounts"}),e.jsx("h1",{className:"mt-2 text-3xl lg:text-4xl font-bold leading-tight",style:{color:k},children:"Salon & Spa Wholesale Access Manager"}),e.jsxs("p",{className:"mt-3 text-sm text-gray-600 max-w-2xl leading-relaxed",children:["Create, approve, suspend and re-tier the salon/spa accounts that can log into the gated Wholesale Partner Portal. Only ",e.jsx("strong",{children:"approved"})," accounts unlock back-bar pricing â and only at their assigned tier. All edits write to"," ",e.jsx("code",{className:"px-1.5 py-0.5 rounded bg-white border text-[11px]",style:{borderColor:Yc,color:k},children:"z_wholesale_partner_accounts"})," ","without exposing the isolated pricing on the public retail site."]}),e.jsxs("div",{className:"mt-8 grid sm:grid-cols-2 lg:grid-cols-4 gap-4",children:[e.jsx(jg,{label:"Total Accounts",value:q.total,icon:Ws,accent:k}),e.jsx(jg,{label:"Approved",value:q.approved,icon:Ue,accent:"#15803d"}),e.jsx(jg,{label:"Pending",value:q.pending,icon:dt,accent:"#b45309"}),e.jsx(jg,{label:"Suspended",value:q.suspended,icon:V_,accent:"#b91c1c"})]})]}),e.jsx("div",{className:"max-w-[1400px] mx-auto px-6 lg:px-10 pb-6",children:e.jsxs("div",{className:"flex flex-wrap items-center gap-3 p-4 rounded-sm bg-white",style:{border:`1px solid ${Yc}`},children:[e.jsxs("div",{className:"relative flex-1 min-w-[240px]",children:[e.jsx(Bt,{size:14,className:"absolute left-3 top-1/2 -translate-y-1/2 text-gray-400"}),e.jsx("input",{type:"text",placeholder:"Search business, email, contact, cityâ¦",value:c,onChange:H=>u(H.target.value),className:"w-full pl-9 pr-3 py-2.5 rounded-sm border text-sm focus:outline-none",style:{borderColor:"rgba(59,10,17,0.15)"}})]}),e.jsxs("div",{className:"flex items-center gap-1",style:{background:cr,padding:4,borderRadius:2},children:[e.jsx(ei,{size:12,className:"ml-2",style:{color:k}}),["all","approved","pending","suspended"].map(H=>{const G=p===H;return e.jsx("button",{onClick:()=>m(H),className:"px-3 py-1.5 rounded-sm text-xs font-bold tracking-wide capitalize transition-all",style:{background:G?k:"transparent",color:G?cr:k},children:H},H)})]}),e.jsxs("div",{className:"flex items-center gap-1",style:{background:cr,padding:4,borderRadius:2},children:[e.jsx(Is,{size:12,className:"ml-2",style:{color:k}}),["all","1","2","3"].map(H=>{const G=x===H;return e.jsx("button",{onClick:()=>
1277h(H),className:"px-3 py-1.5 rounded-sm text-xs font-bold tracking-wide transition-all",style:{background:G?k:"transparent",color:G?cr:k},children:H==="all"?"All tiers":`Tier ${H}`},H)})]})]})}),e.jsxs("main",{className:"max-w-[1400px] mx-auto px-6 lg:px-10 pb-20",children:[n?e.jsxs("div",{className:"text-center py-20",children:[e.jsx(de,{size:28,className:"animate-spin mx-auto",style:{color:k}}),e.jsx("p",{className:"mt-4 text-sm text-gray-500",children:"Loading wholesale partner accountsâ¦"})]}):o?e.jsxs("div",{className:"p-6 rounded-sm bg-white",style:{border:`1px solid ${k}`},children:[e.jsx("p",{className:"text-sm font-semibold",style:{color:k},children:"Couldn't load accounts"}),e.jsx("p",{className:"text-xs text-gray-600 mt-1",children:o})]}):U.length===0?e.jsxs("div",{className:"text-center py-20 rounded-sm bg-white",style:{border:`1px dashed ${$}`},children:[e.jsx(Ws,{size:28,className:"mx-auto",style:{color:$}}),e.jsx("p",{className:"mt-4 text-lg font-bold",style:{color:k},children:"No accounts match your filters"}),e.jsx("p",{className:"mt-1 text-sm text-gray-500",children:"Adjust the search/filters above or add a new partner."})]}):e.jsx("section",{className:"bg-white rounded-sm overflow-hidden",style:{border:`1px solid ${Yc}`},children:e.jsx("div",{className:"overflow-x-auto",children:e.jsxs("table",{className:"w-full text-sm",children:[e.jsx("thead",{style:{background:"#fff"},children:e.jsxs("tr",{className:"text-left text-[10px] uppercase tracking-[0.15em] text-gray-500 border-b",style:{borderColor:"rgba(59,10,17,0.08)"},children:[e.jsx("th",{className:"px-6 py-3 font-bold",children:"Business"}),e.jsx("th",{className:"px-6 py-3 font-bold",children:"Contact / Location"}),e.jsx("th",{className:"px-6 py-3 font-bold",children:"Assigned Tier"}),e.jsx("th",{className:"px-6 py-3 font-bold",children:"Status"}),e.jsx("th",{className:"px-6 py-3 font-bold text-right",children:"Actions"})]})}),e.jsx("tbody",{children:U.map(H=>{const G=oj[H.status]||oj.pending,W=y===H.id;return e.jsxs("tr",{className:"border-b last:border-0",style:{borderColor:"rgba(59,10,17,0.05)"},children:[e.jsxs("td",{className:"px-6 py-4",children:[e.jsx("div",{className:"font-semibold",style:{color:k},children:H.business_name}),e.jsxs("a",{href:`mailto:${H.email}`,className:"inline-flex items-center gap-1.5 text-xs text-gray-600 hover:underline mt-0.5",children:[e.jsx(Ye,{size:11,style:{color:$}})," ",H.email]}),e.jsx("div",{className:"mt-1",children:e.jsx("span",{className:"px-2 py-0.5 rounded-sm text-[10px] font-semibold uppercase tracking-wide",style:{background:cr,color:k,border:`1px solid ${Yc}`},children:H.business_type||"salon"})})]}),e.jsxs("td",{className:"px-6 py-4 text-xs text-gray-700",children:[e.jsx("div",{className:"font-medium",children:H.contact_name||e.jsx("span",{className:"text-gray-400 italic",children:"No contact"})}),(H.city||H.state)&&e.jsxs("div",{className:"inline-flex items-center gap-1 mt-0.5 text-gray-500",children:[e.jsx(zt,{size:11,style:{color:$}})," ",[H.city,H.state].filter(Boolean).join(", ")]})]}),e.jsxs("td",{className:"px-6 py-4",children:[e.jsx("div",{className:"flex items-center gap-1.5",children:[1,2,3].map(X=>{const Q=H.assigned_tier===X;return e.jsx("button",{onClick:()=>B(H,X),disabled:W,title:`${lj[X]} â set Tier ${X}`,className:"w-8 h-8 rounded-sm text-xs font-bold transition-all disabled:opacity-50",style:{background:Q?k:"#fff",color:Q?$:k,border:`1px solid ${Q?k:"rgba(59,10,17,0.2)"}`},children:X},X)})}),e.jsx("div",{className:"text-[10px] text-gray-500 mt-1",children:lj[H.assigned_tier]||"â"})]}),e.jsx("td",{className:"px-6 py-4",children:e.jsxs("div",{className:"flex flex-col gap-1.5",children:[e.jsxs("span",{className:"inline-flex items-center gap-1 px-2 py-0.5 rounded-sm text-[10px] font-bold uppercase tracking-wide w-fit",style:{background:G.bg,color:G.color},children:[e.jsx(G.icon,{size:11})," ",G.label]}),e.jsx("div",{className:"flex items-center gap-1",children:["approved","pending","suspended"].map(X=>{const Q=H.status===X,K=oj[X];return e.jsx("button",{onClick:()=>A(H,X),disabled:W||Q,title:`Set ${K.label}`,className:"px-2 py-1 rounded-sm text-[9px] font-bold uppercase tracking-wide transition-all disabled:opacity-100",style:{background:Q?K.color:"#fff",color:Q?"#fff":K.color,border:`1px solid ${K.color}`,cursor:Q?"default":"pointer"},children:K.label},X)})})]})}),e.jsxs("td",{className:"px-6 py-4 text-right whitespace-nowrap",children:[W&&e.jsx(de,{size:14,className:"inline animate-spin mr-2",style:{color:k}}),e.jsx("button",{onClick:()=>R(H),disabled:W,className:"inline-flex items-center gap-1.5 px-3 py-1.5 rounded-sm text-[11px] font-bold tracking-wide transition-all disabled:opacity-50",style:{background:"#fff",color:k,border:`1px solid ${k}`},children:"Edit"}),e.jsx("button",{onClick:()=>z(H),disabled:W,title:"Delete account",className:"inline-flex items-center justify-center ml-2 w-8 h-8 rounded-sm transition-all disabled:opacity-50",style:{background:"#fff",color:"#b91c1c",border:"1px solid #fecaca"},children:e.jsx(va,{size:13})})]})]},H.id)})})]})})}),e.jsxs("div",{className:"mt-12 p-5 rounded-sm text-xs text-gray-600 leading-relaxed",style:{background:"#fff",border:`1px solid ${Yc}`},children:[e.jsx("div",{className:"font-bold uppercase tracking-[0.15em] mb-1",style:{color:k},children:"How access works"}),"A salon/spa signs into the public site with their email. The Wholesale Partner Portal only reveals back-bar pricing when that email matches an ",e.jsx("strong",{children:"approved"})," row here â and shows only the",e.jsx("strong",{children:" assigned tier"})," price. Suspending an account immediately re-locks pricing on their next portal load. Professional pricing is never rendered on the B2C retail front-end."]})]}),b&&e.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center p-4",style:{background:"rgba(59,10,17,0.45)"},children:e.jsxs("div",{className:"w-full max-w-lg rounded-sm bg-white shadow-2xl max-h-[90vh] overflow-y-auto",style:{border:`1px solid ${$}`},children:[e.jsxs("div",{className:"flex items-center justify-between px-6 py-4 border-b",style:{background:k,borderColor:$},children:[e.jsxs("div",{className:"flex items-center gap-2",style:{color:cr},children:[j?e.jsx(ti,{size:16,style:{color:$}}):e.jsx(tn,{size:16,style:{color:$}}),e.jsx("h3",{className:"text-sm font-bold uppercase tracking-[0.18em]",children:j?"Edit Partner Account":"New Partner Account"})]}),e.jsx("button",{onClick:()=>f(!1),className:"opacity-80 hover:opacity-100",style:{color:cr},children:e.jsx(Ke,{size:18})})]}),e.jsxs("div",{className:"p-6 space-y-4",children:[e.jsx(Zi,{label:"Business N
1277ame *",children:e.jsx("input",{value:w.business_name,onChange:H=>_({...w,business_name:H.target.value}),className:al,placeholder:"Luxe Hair & Skin Studio"})}),e.jsxs(Zi,{label:"Login Email *",children:[e.jsx("input",{value:w.email,onChange:H=>_({...w,email:H.target.value}),className:al,placeholder:"[email protected]",type:"email",disabled:!!j}),j&&e.jsx("p",{className:"text-[10px] text-gray-400 mt-1",children:"Email is the login key and cannot be changed after creation."})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsx(Zi,{label:"Contact Name",children:e.jsx("input",{value:w.contact_name,onChange:H=>_({...w,contact_name:H.target.value}),className:al,placeholder:"Amara Bello"})}),e.jsx(Zi,{label:"Business Type",children:e.jsxs("select",{value:w.business_type,onChange:H=>_({...w,business_type:H.target.value}),className:al,children:[e.jsx("option",{value:"salon",children:"Salon"}),e.jsx("option",{value:"spa",children:"Spa"}),e.jsx("option",{value:"medspa",children:"Med-Spa"}),e.jsx("option",{value:"institute",children:"Institute"}),e.jsx("option",{value:"clinic",children:"Clinic"}),e.jsx("option",{value:"other",children:"Other"})]})})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsx(Zi,{label:"City",children:e.jsx("input",{value:w.city,onChange:H=>_({...w,city:H.target.value}),className:al,placeholder:"Seattle"})}),e.jsx(Zi,{label:"State",children:e.jsx("input",{value:w.state,onChange:H=>_({...w,state:H.target.value}),className:al,placeholder:"WA"})})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs(Zi,{label:"Assigned Tier",children:[e.jsx("div",{className:"flex items-center gap-2",children:[1,2,3].map(H=>{const G=Number(w.assigned_tier)===H;return e.jsxs("button",{type:"button",onClick:()=>_({...w,assigned_tier:H}),className:"flex-1 py-2 rounded-sm text-xs font-bold transition-all",style:{background:G?k:"#fff",color:G?$:k,border:`1px solid ${G?k:"rgba(59,10,17,0.2)"}`},children:["Tier ",H]},H)})}),e.jsx("p",{className:"text-[10px] text-gray-500 mt-1",children:lj[Number(w.assigned_tier)]||""})]}),e.jsx(Zi,{label:"Status",children:e.jsxs("select",{value:w.status,onChange:H=>_({...w,status:H.target.value}),className:al,children:[e.jsx("option",{value:"approved",children:"Approved (pricing unlocked)"}),e.jsx("option",{value:"pending",children:"Pending (locked)"}),e.jsx("option",{value:"suspended",children:"Suspended (locked)"})]})})]}),e.jsx(Zi,{label:"Internal Notes",children:e.jsx("textarea",{value:w.notes,onChange:H=>_({...w,notes:H.target.value}),rows:2,className:al,placeholder:"Optional notes for staffâ¦"})}),P&&e.jsxs("div",{className:"flex items-start gap-2 text-xs px-3 py-2 rounded-sm",style:{background:"#fef2f2",color:"#991b1b",border:"1px solid #fecaca"},children:[e.jsx(ve,{size:13,className:"mt-0.5 flex-shrink-0"})," ",P]})]}),e.jsxs("div",{className:"flex items-center justify-end gap-3 px-6 py-4 border-t",style:{borderColor:Yc},children:[e.jsx("button",{onClick:()=>f(!1),className:"px-4 py-2 rounded-sm text-xs font-bold tracking-wide",style:{background:"#fff",color:k,border:`1px solid ${k}`},children:"Cancel"}),e.jsxs("button",{onClick:T,disabled:C,className:"inline-flex items-center gap-2 px-5 py-2 rounded-sm text-xs font-bold tracking-wide transition-all disabled:opacity-60",style:{background:$,color:k},children:[C?e.jsx(de,{size:13,className:"animate-spin"}):e.jsx(ti,{size:13}),j?"Save Changes":"Create Partner"]})]})]})}),g&&e.jsxs("div",{className:"fixed bottom-6 right-6 z-[60] px-5 py-3 rounded-sm shadow-xl flex items-center gap-2 text-sm font-semibold",style:{background:g.kind==="ok"?k:"#7f1d1d",color:cr,border:`1px solid ${g.kind==="ok"?$:"#fecaca"}`},children:[g.kind==="ok"?e.jsx(Ue,{size:15,style:{color:$}}):e.jsx(ve,{size:15}),g.msg]})]})},al="w-full px-3 py-2.5 rounded-sm border text-sm focus:outline-none disabled:bg-gray-50 disabled:text-gray-400",Zi=({label:t,children:s})=>e.jsxs("div",{children:[e.jsx("label",{className:"block text-[10px] uppercase tracking-[0.18em] font-bold mb-1.5",style:{color:k},children:t}),s]}),jg=({label:t,value:s,icon:n,accent:a})=>e.jsxs("div",{className:"p-5 rounded-sm flex items-center justify-between bg-white",style:{border:`1px solid ${Yc}`},children:[e.jsxs("div",{children:[e.jsx("div",{className:"text-[10px] uppercase tracking-[0.2em] text-gray-500 font-semibold",children:t}),e.jsx("div",{className:"mt-1 text-2xl font-bold",style:{color:k},children:s})]}),e.jsx("div",{className:"w-10 h-10 rounded-full flex items-center justify-center",style:{background:cr,border:`1px solid ${a}`},children:e.jsx(n,{size:16,style:{color:a}})})]}),an="#7A3A44",Yi="#E8DDD0",Pp="#FAF7F2",sre="#F5F0E8",nre=[{key:"7",label:"Last 7 days"},{key:"30",label:"Last 30 days"},{key:"90",label:"Last 90 days"},{key:"all",label:"All time"}],are=()=>{var S;
1277const t=Za(),[s,n]=d.useState([]),[a,r]=d.useState(!0),[i,o]=d.useState(null),[l,c]=d.useState("30"),[u,p]=d.useState([]),[m,x]=d.useState(!1),h=async()=>{try{const{data:w}=await O.from("link_monitor_logs").select("*").order("checked_at",{ascending:!1}).limit(200),_=new Map;w==null||w.forEach(C=>{_.has(C.policy_key)||_.set(C.policy_key,C)}),p([..._.values()])}catch{}},y=async()=>{x(!0);try{await O.functions.invoke("compliance-link-monitor",{body:{}}),await h()}catch{}finally{x(!1)}};d.useEffect(()=>{h()},[]);const v=async()=>{r(!0),o(null);try{let w=O.from("policy_click_logs").select("*").order("created_at",{ascending:!1}).limit(5e3);if(l!=="all"){const E=parseInt(l,10),P=new Date(Date.now()-E*24*60*60*1e3).toISOString();w=w.gte("created_at",P)}const{data:_,error:C}=await w;if(C)throw C;n(_||[])}catch(w){o(w.message||"Failed to load policy click logs")}finally{r(!1)}};d.useEffect(()=>{v()},[l]);const g=d.useMemo(()=>{const w=new Map;return s.forEach(_=>{const C=w.get(_.policy_key)||{label:_.policy_label,count:0};C.count+=1,w.set(_.policy_key,C)}),[...w.entries()].map(([_,C])=>({key:_,...C})).sort((_,C)=>C.count-_.count)},[s]),N=d.useMemo(()=>{const w=new Map;return s.forEach(_=>w.set(_.source||"unknown",(w.get(_.source||"unknown")||0)+1)),[...w.entries()].map(([_,C])=>({source:_,count:C})).sort((_,C)=>C.count-_.count)},[s]),b=((S=g[0])==null?void 0:S.count)||1,f=()=>{const w=["Timestamp (UTC)","Policy Key","Policy Label","Source","Destination URL","Page Path","User Agent"],_=D=>`"${(D??"").replace(/"/g,'""')}"`,C=s.map(D=>[new Date(D.created_at).toISOString(),D.policy_key,D.policy_label,D.source||"",D.destination_url||"",D.page_path||"",D.user_agent||""].map(_).join(",")),E=[w.map(_).join(","),...C].join(`\r 1278`),P=new Blob([E],{type:"text/csv;charset=utf-8;"}),F=URL.createObjectURL(P),I=document.createElement("a");I.href=F,I.download=`zorganics-policy-clicks-audit-${new Date().toISOString().slice(0,10)}.csv`,document.body.appendChild(I),I.click(),document.body.removeChild(I),URL.revokeObjectURL(F)},j=({icon:w,label:_,value:C})=>e.jsxs("div",{className:"rounded-2xl p-5",style:{background:"#FFFFFF",border:`1px solid ${Yi}`,boxShadow:"0 2px 12px rgba(59,10,17,0.04)"},children:[e.jsxs("div",{className:"flex items-center gap-3 mb-2",children:[e.jsx("div",{className:"w-9 h-9 rounded-xl flex items-center justify-center",style:{background:"rgba(212,175,55,0.12)",border:"1px solid rgba(212,175,55,0.25)"},children:w}),e.jsx("p",{className:"text-[10px] font-bold uppercase tracking-wider",style:{color:an},children:_})]}),e.jsx("p",{className:"font-display text-3xl font-bold",style:{color:k},children:C})]});return e.jsxs("div",{className:"min-h-screen",style:{background:`linear-gradient(180deg, ${sre} 0%, ${Pp} 100%)`},children:[e.jsx("div",{style:{background:k},children:e.jsxs("div",{className:"max-w-[1400px] mx-auto px-4 lg:px-8 py-6 flex flex-col md:flex-row md:items-center md:justify-between gap-4",children:[e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsxs("button",{onClick:()=>t("/"),className:"flex items-center gap-1.5 text-xs font-semibold transition-colors",style:{color:"rgba(212,175,55,0.85)"},children:[e.jsx(Je,{size:14})," Back to Site"]}),e.jsx("div",{className:"h-6 w-px",style:{background:"rgba(212,175,55,0.3)"}}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"w-10 h-10 rounded-xl flex items-center justify-center",style:{background:"rgba(212,175,55,0.12)",border:"1px solid rgba(212,175,55,0.3)"},children:e.jsx(Ie,{size:20,style:{color:$}})}),e.jsxs("div",{children:[e.jsx("h1",{className:"font-display text-lg font-bold",style:{color:$},children:"Policy Clicks Report"}),e.jsx("p",{className:"text-[10px] uppercase tracking-[0.16em]",style:{color:"rgba(212,175,55,0.6)"},children:"Audit-Ready Compliance Tracking"})]})]})]}),e.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[e.jsxs("button",{onClick:v,className:"flex items-center gap-1.5 px-3 py-2 rounded-lg text-xs font-semibold transition-all hover:-translate-y-0.5",style:{background:"rgba(212,175,55,0.1)",color:$,border:`1px solid ${$}`},children:[e.jsx(Be,{size:13,className:a?"animate-spin":""})," Refresh"]}),e.jsxs("button",{onClick:f,disabled:s.length===0,className:"flex items-center gap-1.5 px-4 py-2 rounded-lg text-xs font-bold uppercase tracking-wider transition-all hover:-translate-y-0.5 disabled:opacity-40 disabled:cursor-not-allowed",style:{background:`linear-gradient(135deg, ${$} 0%, #B8962E 100%)`,color:k},children:[e.jsx(us,{size:14})," Export Audit CSV"]})]})]})}),e.jsxs("div",{className:"max-w-[1400px] mx-auto px-4 lg:px-8 py-8",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-6 flex-wrap",children:[e.jsxs("span",{className:"flex items-center gap-1.5 text-xs font-bold uppercase tracking-wider mr-1",style:{color:an},children:[e.jsx(ei,{size:13,style:{color:$}})," Range"]}),nre.map(w=>e.jsx("button",{onClick:()=>c(w.key),className:"px-3 py-1.5 rounded-lg text-xs font-semibold transition-all",style:{background:l===w.key?`linear-gradient(135deg, ${$} 0%, #B8962E 100%)`:"#FFFFFF",color:l===w.key?k:an,border:`1px solid ${l===w.key?$:Yi}`},children:w.label},w.key))]}),i&&e.jsx("div",{className:"rounded-xl p-4 mb-6 text-sm",style:{background:"rgba(180,40,40,0.06)",border:"1px solid rgba(180,40,40,0.2)",color:"#A03030"},children:i}),e.jsxs("div",{className:"grid sm:grid-cols-3 gap-4 mb-8",children:[e.jsx(j,{icon:e.jsx(e5,{size:17,style:{color:$}}
1278),label:"Total Interactions",value:s.length.toLocaleString()}),e.jsx(j,{icon:e.jsx(La,{size:17,style:{color:$}}),label:"Distinct Policies",value:g.length}),e.jsx(j,{icon:e.jsx(Lb,{size:17,style:{color:$}}),label:"Capture Sources",value:N.length})]}),e.jsxs("div",{className:"rounded-2xl p-6 mb-8",style:{background:"#FFFFFF",border:`1px solid ${Yi}`},children:[e.jsxs("div",{className:"flex items-center justify-between mb-1 flex-wrap gap-3",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Ma,{size:16,style:{color:$}}),e.jsx("h2",{className:"text-sm font-bold uppercase tracking-wider",style:{color:k},children:"Live Compliance Link Monitor"}),u.length>0&&(u.every(w=>w.ok)?e.jsxs("span",{className:"flex items-center gap-1 px-2 py-0.5 rounded-full text-[10px] font-bold uppercase tracking-wider",style:{background:"rgba(40,140,60,0.1)",color:"#2C7A3D",border:"1px solid rgba(40,140,60,0.3)"},children:[e.jsx(Ue,{size:11})," All Healthy"]}):e.jsxs("span",{className:"flex items-center gap-1 px-2 py-0.5 rounded-full text-[10px] font-bold uppercase tracking-wider",style:{background:"rgba(180,40,40,0.1)",color:"#A03030",border:"1px solid rgba(180,40,40,0.3)"},children:[e.jsx(kt,{size:11})," Action Needed"]}))]}),e.jsxs("button",{onClick:y,disabled:m,className:"flex items-center gap-1.5 px-3 py-1.5 rounded-lg text-xs font-semibold transition-all disabled:opacity-50",style:{background:"rgba(212,175,55,0.1)",color:k,border:`1px solid ${$}`},children:[e.jsx(Be,{size:12,className:m?"animate-spin":""})," ",m?"Scanningâ¦":"Scan Now"]})]}),e.jsx("p",{className:"text-[11px] mb-4",style:{color:an},children:"Automated background scan runs every 6 hours against the official zorganicsinstitute.edu URLs to guarantee no compliance link ever returns a 404."}),u.length===0?e.jsxs("p",{className:"text-xs",style:{color:an},children:["No scan results yet â click ",e.jsx("strong",{children:"Scan Now"})," to run the first check."]}):e.jsx("div",{className:"grid sm:grid-cols-2 gap-3",children:u.map(w=>e.jsxs("div",{className:"flex items-start gap-3 rounded-xl p-3",style:{background:Pp,border:`1px solid ${Yi}`},children:[w.ok?e.jsx(Ue,{size:16,className:"mt-0.5 flex-shrink-0",style:{color:"#2C7A3D"}}):e.jsx(kt,{size:16,className:"mt-0.5 flex-shrink-0",style:{color:"#A03030"}}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"text-xs font-semibold truncate",style:{color:k},children:w.label||w.policy_key}),e.jsx("p",{className:"text-[10px] truncate",style:{color:an},children:w.url}),e.jsxs("p",{className:"text-[10px] mt-1",style:{color:w.ok?"#2C7A3D":"#A03030"},children:["HTTP ",w.status_code??"â"," · ",w.response_ms??"â","ms · ",new Date(w.checked_at).toLocaleString()]})]})]},w.policy_key))})]}),e.jsxs("div",{className:"grid lg:grid-cols-2 gap-6 mb-8",children:[e.jsxs("div",{className:"rounded-2xl p-6",style:{background:"#FFFFFF",border:`1px solid ${Yi}`},children:[e.jsx("h2",{className:"text-sm font-bold uppercase tracking-wider mb-4",style:{color:k},children:"Clicks by Policy"}),g.length===0?e.jsx("p",{className:"text-xs",style:{color:an},children:"No data for this range."}):e.jsx("div",{className:"space-y-3",children:g.slice(0,12).map(w=>e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center justify-between mb-1",children:[e.jsx("span",{className:"text-xs font-medium truncate pr-3",style:{color:an},children:w.label}),e.jsx("span",{className:"text-xs font-bold flex-shrink-0",style:{color:k},children:w.count})]}),e.jsx("div",{className:"h-2 rounded-full overflow-hidden",style:{background:Pp},children:e.jsx("div",{className:"h-full rounded-full",style:{width:`${w.count/b*100}%`,background:`linear-gradient(90deg, ${$} 0%, #B8962E 100%)`}})})]},w.key))})]}),e.jsxs("div",{className:"rounded-2xl p-6",style:{background:"#FFFFFF",border:`1px solid ${Yi}`},children:[e.jsx("h2",{className:"text-sm font-bold uppercase tracking-wider mb-4",style:{color:k},children:"Clicks by Source"}),N.length===0?e.jsx("p",{className:"text-xs",style:{color:an},children:"No data for this range."}):e.jsx("div",{className:"flex flex-wrap gap-2",children:N.map(w=>e.jsxs("span",{className:"px-3 py-1.5 rounded-lg text-xs font-semibold",style:{background:"rgba(212,175,55,0.08)",color:k,border:"1px solid rgba(212,175,55,0.25)"},children:[w.source," ",e.jsxs("span",{style:{color:$},children:["· ",w.count]})]},w.source))})]})]}),e.jsxs("div",{className:"rounded-2xl overflow-hidden",style:{background:"#FFFFFF",border:`1px solid ${Yi}`},children:[e.jsxs("div",{className:"px-6 py-4 flex items-center justify-between",style:{borderBottom:`1px solid ${Yi}`},children:[e.jsx("h2",{className:"text-sm font-bold uppercase tracking-wider",style:{color:k},children:"Detailed Interaction Log"}),e.jsxs("span",{className:"text-xs",style:{color:an}
1278,children:[s.length.toLocaleString()," records"]})]}),e.jsx("div",{className:"overflow-x-auto",children:e.jsxs("table",{className:"w-full text-left",children:[e.jsx("thead",{children:e.jsx("tr",{style:{background:Pp},children:["Timestamp (UTC)","Policy","Source","Destination","Page"].map(w=>e.jsx("th",{className:"px-4 py-3 text-[10px] font-bold uppercase tracking-wider",style:{color:an},children:w},w))})}),e.jsx("tbody",{children:a?e.jsx("tr",{children:e.jsx("td",{colSpan:5,className:"px-4 py-10 text-center text-sm",style:{color:an},children:"Loadingâ¦"})}):s.length===0?e.jsx("tr",{children:e.jsx("td",{colSpan:5,className:"px-4 py-10 text-center text-sm",style:{color:an},children:"No compliance link interactions recorded for this range yet."})}):s.slice(0,200).map(w=>e.jsxs("tr",{style:{borderTop:`1px solid ${Pp}`},children:[e.jsx("td",{className:"px-4 py-3 text-xs whitespace-nowrap",style:{color:an},children:new Date(w.created_at).toLocaleString()}),e.jsx("td",{className:"px-4 py-3 text-xs font-medium",style:{color:k},children:w.policy_label}),e.jsx("td",{className:"px-4 py-3 text-xs",style:{color:an},children:w.source||"â"}),e.jsx("td",{className:"px-4 py-3 text-xs max-w-[260px] truncate",style:{color:an},children:w.destination_url||"â"}),e.jsx("td",{className:"px-4 py-3 text-xs",style:{color:an},children:w.page_path||"â"})]},w.id))})]})}),s.length>200&&e.jsx("div",{className:"px-6 py-3 text-center text-[11px]",style:{borderTop:`1px solid ${Yi}`,color:an},children:"Showing first 200 records â export the audit CSV for the full dataset."})]})]})]})},Ki="#3B0A11",oa="#D4AF37",Ja="#7A3A44",rre=t=>{const s=t==null?"":String(t);return/[",\n]/.test(s)?`"${s.replace(/"/g,'""')}"`:s},ire=()=>{var v;const[t,s]=d.useState([]),[n,a]=d.useState(!0),[r,i]=d.useState(null),[o,l]=d.useState(""),[c,u]=d.useState(""),[p,m]=d.useState(""),x=async()=>{a(!0),i(null);let g=O.from("disclosure_acknowledgements").select("*").order("acknowledged_at",{ascending:!1}).limit(5e3);if(c&&(g=g.gte("acknowledged_at",new Date(c).toISOString())),p){const f=new Date(p);f.setHours(23,59,59,999),g=g.lte("acknowledged_at",f.toISOString())}const{data:N,error:b}=await g;b&&i(b.message),s(N||[]),a(!1)};d.useEffect(()=>{x()},[]);const h=d.useMemo(()=>{const g=o.trim().toLowerCase();return g?t.filter(N=>[N.student_name,N.student_email,N.ip_address,N.source,N.page_path].filter(Boolean).some(b=>String(b).toLowerCase().includes(g))):t},[t,o]),y=()=>{const N=[["id","acknowledged_at","student_name","student_email","ip_address","statement_version","statement_text","source","page_path","user_agent"].join(","),...h.map(S=>[S.id,S.acknowledged_at,S.student_name,S.student_email,S.ip_address,S.statement_version,S.statement_text,S.source,S.page_path,S.user_agent].map(rre).join(","))],b=new Blob([N.join(` 1279`)],{type:"text/csv;charset=utf-8;"}),f=URL.createObjectURL(b),j=document.createElement("a");j.href=f,j.download=`disclosure-acknowledgements-${new Date().toISOString().slice(0,10)}.csv`,j.click(),URL.revokeObjectURL(f)};return e.jsx("div",{className:"min-h-screen",style:{background:"linear-gradient(180deg,#FFFFFF,#FAF7F2)"},children:e.jsxs("div",{className:"max-w-7xl mx-auto px-4 lg:px-8 py-10",children:[e.jsxs(be,{to:"/",className:"inline-flex items-center gap-2 text-sm mb-6 hover:underline",style:{color:Ja},children:[e.jsx(Je,{size:16})," Back to Home"]}),e.jsxs("div",{className:"flex flex-wrap items-end justify-between gap-4 mb-8",children:[e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[e.jsx(VS,{size:18,style:{color:oa}}),e.jsx("span",{className:"text-[11px] font-bold uppercase tracking-[0.25em]",style:{color:oa},children:"Compliance · FSA / NACCAS Audit"})]}),e.jsx("h1",{className:"font-display text-3xl lg:text-4xl font-bold",style:{color:Ki},children:"Signed Disclosure Acknowledgements"}),e.jsx("p",{className:"text-sm mt-1.5 max-w-2xl",style:{color:Ja},children:"Formal, timestamped legal records confirming each student was provided access to the School Catalog and Consumer Disclosures. Search and export audit-ready records."})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("button",{onClick:x,className:"inline-flex items-center gap-2 px-4 py-2.5 rounded-lg text-sm font-semibold transition-all hover:-translate-y-0.5",style:{background:"#FFFFFF",color:Ki,border:`1px solid ${oa}55`},children:[e.jsx(Be,{size:15})," Refresh"]}),e.jsxs("button",{onClick:y,disabled:h.length===0,className:"inline-flex items-center gap-2 px-4 py-2.5 rounded-lg text-sm font-bold text-white transition-all hover:-translate-y-0.5 disabled:opacity-50",style:{background:`linear-gradient(135deg, ${Ki}, #5A1A24)`,border:`1px solid ${oa}55`},children:[e.jsx(us,{size:15})," Export Audit CSV"]})]})]}),e.jsx("div",{className:"grid grid-cols-2 md:grid-cols-3 gap-4 mb-6",children:[{label:"Total Records",value:t.length,icon:e.jsx(Ie,{size:18})},{label:"Matching Filter",value:h.length,icon:e.jsx(Bt,{size:18})},{label:"Statement Version",value:((v=t[0])==null?void 0:v.statement_version)||"v1",icon:e.jsx(VS,{size:18})}].map((g,N)=>e.jsxs("div",{className:"p-5 rounded-2xl bg-white",style:{border:`1px solid ${oa}22`,boxShadow:"0 4px 18px rgba(59,10,17,0.06)"},children:[e.jsx("div",{className:"mb-2",style:{color:oa},children:g.icon}),e.jsx("div",{className:"text-2xl font-bold font-mono",style:{color:Ki},children:g.value}),e.jsx("div",{className:"text-xs font-medium",style:{color:Ja},children:g.label})]},N))}),e.jsxs("div",{className:"flex flex-wrap items-end gap-3 mb-5 p-4 rounded-2xl bg-white",style:{border:`1px solid ${oa}22`},children:[e.jsxs("div",{className:"flex-1 min-w-[220px]",children:[e.jsx("label",{className:"block text-[11px] font-bold uppercase tracking-wider mb-1",style:{color:Ja},children:"Search"}),e.jsxs("div",{className:"relative",children:[e.jsx(Bt,{size:15,className:"absolute left-3 top-1/2 -translate-y-1/2",style:{color:oa}}),e.jsx("input",{value:o,onChange:g=>l(g.target.value),placeholder:"Name, email, IP, sourceâ¦",className:"w-full pl-9 pr-3 py-2.5 rounded-lg text-sm focus:outline-none",style:{border:"1px solid #E8DDD0",color:Ki}})]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-[11px] font-bold uppercase tracking-wider mb-1",style:{color:Ja},children:"From"}),e.jsx("input",{type:"date",value:c,onChange:g=>u(g.target.value),className:"px-3 py-2.5 rounded-lg text-sm focus:outline-none",style:{border:"1px solid #E8DDD0",color:Ki}})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-[11px] font-bold uppercase tracking-wider mb-1",style:{color:Ja},children:"To"}),e.jsx("input",{type:"date",value:p,onChange:g=>m(g.target.value),className:"px-3 py-2.5 rounded-lg text-sm focus:outline-none",style:{border:"1px solid #E8DDD0",color:Ki}})]}),e.jsxs("button",{onClick:x,className:"inline-flex items-center gap-2 px-4 py-2.5 rounded-lg text-sm font-semibold",style:{background:`${oa}18`,color:"#9A7B1C",border:`1px solid ${oa}44`},children:[e.jsx(At,{size:15}
1279)," Apply Dates"]})]}),r&&e.jsxs("div",{className:"flex items-center gap-2 p-4 mb-4 rounded-xl text-sm",style:{background:"rgba(220,38,38,0.06)",color:"#B91C1C",border:"1px solid rgba(220,38,38,0.2)"},children:[e.jsx(Mt,{size:16})," ",r]}),e.jsx("div",{className:"rounded-2xl overflow-hidden bg-white",style:{border:`1px solid ${oa}22`,boxShadow:"0 6px 24px rgba(59,10,17,0.06)"},children:e.jsx("div",{className:"overflow-x-auto",children:e.jsxs("table",{className:"w-full text-sm",children:[e.jsx("thead",{children:e.jsx("tr",{style:{background:`linear-gradient(135deg, ${Ki}, #5A1A24)`},children:["Acknowledged","Student Name","Email","IP Address","Source","Version","Page"].map(g=>e.jsx("th",{className:"text-left px-4 py-3.5 text-[11px] font-bold uppercase tracking-wider text-white/90 whitespace-nowrap",children:g},g))})}),e.jsx("tbody",{children:n?e.jsx("tr",{children:e.jsx("td",{colSpan:7,className:"px-4 py-10 text-center",style:{color:Ja},children:"Loading recordsâ¦"})}):h.length===0?e.jsx("tr",{children:e.jsx("td",{colSpan:7,className:"px-4 py-10 text-center",style:{color:Ja},children:"No acknowledgements found."})}):h.map(g=>e.jsxs("tr",{className:"transition-colors hover:bg-[#D4AF37]/5",style:{borderBottom:"1px solid rgba(212,175,55,0.08)"},children:[e.jsx("td",{className:"px-4 py-3 whitespace-nowrap font-mono text-xs",style:{color:"#5A1A24"},children:new Date(g.acknowledged_at).toLocaleString()}),e.jsx("td",{className:"px-4 py-3 font-semibold",style:{color:Ki},children:g.student_name||"â"}),e.jsx("td",{className:"px-4 py-3",style:{color:Ja},children:g.student_email||"â"}),e.jsx("td",{className:"px-4 py-3 font-mono text-xs",style:{color:Ja},children:g.ip_address||"â"}),e.jsx("td",{className:"px-4 py-3",children:e.jsx("span",{className:"px-2 py-0.5 rounded-full text-[10px] font-bold uppercase",style:{background:`${oa}14`,color:"#9A7B1C",border:`1px solid ${oa}33`},children:g.source||"unknown"})}),e.jsx("td",{className:"px-4 py-3 font-mono text-xs",style:{color:Ja},children:g.statement_version}),e.jsx("td",{className:"px-4 py-3 font-mono text-xs",style:{color:Ja},children:g.page_path||"â"})]},g.id))})]})})}),e.jsxs("p",{className:"text-[11px] mt-4 flex items-center gap-1.5",style:{color:"#9CA3AF"},children:[e.jsx(Ie,{size:12,style:{color:oa}}),"Each record stores the exact statement text and version affirmed at the time of acknowledgement â immutable for audit integrity."]})]})})},M0="#5A1A24",cj="#7A3A44",ore="#F2EBE3",TE="#FAF7F2",PE="#E8DDD0",lre="https://d64gsuwffb70l.cloudfront.net/69cae7fb5ea7db794957149e_1775337912224_4cc82887.jfif",cf=({title:t,subtitle:s,eyebrow:n="Official Institutional Disclosure",lastUpdated:a="Effective 2026",children:r})=>(d.useEffect(()=>{window.scrollTo({top:0,behavior:"auto"});const i=document.title;return document.title=`${t} · Zorganics Institute`,()=>{document.title=i}},[t]),e.jsxs("div",{className:"min-h-screen",style:{background:`linear-gradient(180deg, ${ore} 0%, ${TE} 100%)`},children:[e.jsxs("header",{className:"relative",style:{background:k},children:[e.jsx("div",{className:"h-[3px]",style:{background:`linear-gradient(90deg, rgba(212,175,55,0) 0%, ${$} 50%, rgba(212,175,55,0) 100%)`}}),e.jsxs("div",{className:"max-w-[1100px] mx-auto px-4 lg:px-8 py-6 flex items-center justify-between gap-4",children:[e.jsxs(be,{to:"/",className:"flex items-center gap-3 group",children:[e.jsx("div",{className:"w-11 h-11 rounded-xl overflow-hidden flex-shrink-0",style:{boxShadow:`0 0 0 1.5px ${$}`},children:e.jsx("img",{src:lre,alt:"Zorganics Institute",className:"w-full h-full object-cover"})}),e.jsxs("div",{children:[e.jsxs("h2",{className:"font-display text-lg font-bold",style:{color:"#FFFFFF"},children:["Zorganics",e.jsx("span",{style:{color:$},children:" Institute"})]}),e.jsx("p",{className:"text-[10px] tracking-wider uppercase",style:{color:"rgba(212,175,55,0.7)"},children:"A Holistic Approach To Beauty and Wellness through Science and Art"})]})]}),e.jsxs(be,{to:"/",className:"inline-flex items-center gap-2 px-4 py-2 rounded-lg text-xs font-bold uppercase tracking-wider transition-all hover:-translate-y-0.5",style:{background:"rgba(212,175,55,0.12)",color:$,border:"1px solid rgba(212,175,55,0.4)"},children:[e.jsx(Je,{size:14})," Back to Home"]})]})]}),e.jsxs("div",{className:"max-w-[1100px] mx-auto px-4 lg:px-8 pt-12 pb-8",children:[e.jsxs("div",{className:"inline-flex items-center gap-2 px-3 py-1.5 rounded-full text-[10px] font-bold uppercase tracking-wider mb-4",style:{background:"rgba(45,138,78,0.08)",color:"#2D6B3E",border:"1px solid rgba(45,138,78,0.18)"},children:[e.jsx(Ie,{size:12})," ",n]}),e.jsx("h1",{className:"font-display text-3xl lg:text-4xl font-bold leading-tight",style:{color:k},children:t}),s&&e.jsx("p",{className:"mt-3 text-base leading-relaxed max-w-3xl",style:{color:M0},children:s}),e.jsxs("div",{className:"mt-4 flex items-center gap-4 flex-wrap",children:[e.jsx("span",{className:"text-xs font-medium",style:{color:cj},children:a}),e.jsxs("button",{onClick:()=>window.print(),className:"inline-flex items-center gap-1.5 text-xs font-semibold transition-colors hover:text-[#B8962E]",style:{color:$},children:[e.jsx(ef,{size:12})," Print this page"]})]})]}),e.jsxs("main",{className:"max-w-[1100px] mx-auto px-4 lg:px-8 pb-16",children:[e.jsx("article",{className:"rounded-3xl p-6 lg:p-12",style:{background:"#FFFFFF",border:`1px solid ${PE}`,boxShadow:"0 8px 40px rgba(59,10,17,0.05)"},children:r}),e.jsxs("div",{className:"mt-8 rounded-2xl p-6 lg:p-8",style:{background:TE,border:`1px solid ${PE}`},children:[e.jsx("h3",{className:"text-sm font-bold uppercase tracking-wider mb-4",style:{color:k},children:"Questions or Requests?"}),e.jsxs("div",{className:"grid sm:grid-cols-3 gap-4",children:[e.jsxs("a",{href:"tel:+13603928243",className:"flex items-center gap-2 text-sm font-medium",style:{color:M0},children:[e.jsx(Qt,{size:14,style:{color:$}})," (360) 392-8243"]}),e.jsxs("a",{href:"mailto:[email protected]",className:"flex items-center gap-2 text-sm font-medium",style:{color:M0},children:[e.jsx(Ye,{size:14,style:{color:$}})," [email protected]"]}),e.jsxs("div",{className:"flex items-start gap-2 text-sm",style:{color:cj},children:[e.jsx(zt,{size:14,style:{color:$},className:"mt-0.5 flex-shrink-0"}),e.jsx("span",{children:"410 West Bakerview Rd, Ste 112, Bellingham, WA 98226"})]})]})]}),e.jsx("p",{className:"mt-6 text-center text-[11px]",style:{color:cj},children:"© 2026 Zorganics Institute of Beauty & Wellness · NACCAS Accredited · WA State DOL Certified · Title IV / FSA Eligible"})]})]})),ik="#4A2228",vt=({heading:t,children:s,id:n})=>e.jsxs("section",{id:n,className:"mb-10 last:mb-0",children:[e.jsx("h2",{className:"font-display text-xl lg:text-2xl font-bold mb-4 pb-2",style:{color:k,borderBottom:`2px solid ${$}`},children:t}),e.jsx("div",{className:"space-y-4 text-[15px] leading-relaxed",style:{color:ik},children:s})]}),ha=({heading:t,children:s})=>e.jsxs("div",{className:"mt-5",children:[e.jsx("h3",{className:"text-base font-bold mb-2",style:{color:M0},children:t}),e.jsx("div",{className:"space-y-3 text-[15px] leading-relaxed",style:{color:ik},children:s})]}),Zn=({items:t})=>e.jsx("ul",{className:"space-y-2 pl-1",children:t.map((s,n)=>e.jsxs("li",{className:"flex gap-3 text-[15px] leading-relaxed",style:{color:ik},children:[e.jsx("span",{className:"mt-2 w-1.5 h-1.5 rounded-full flex-shrink-0",style:{background:$}}),e.jsx("span",{children:s})]},n))}),cre=()=>e.jsxs(cf,{title:"Annual Security Report & Campus Safety",eyebrow:"Jeanne Clery Act Disclosure",subtitle:"In compliance with the Jeanne Clery Disclosure of Campus Security Policy and Campus Crime Statistics Act (20 U.S.C. § 1092(f)), Zorganics Institute publishes this Annual Security Report (ASR) describing its campus security policies, crime-prevention programs, and three most recent years of campus crime statistics.",lastUpdated:"Annual Security Report â Published October 1, 2026 · Reporting Years 2023â2025",children:[e.jsxs(vt,{heading:"1. Purpose & Distribution",children:[e.jsx("p",{children:"The Annual Security Report is prepared by the Campus Safety Officer in cooperation with local law enforcement and is distributed by October 1 each year to all current students and employees. Prospective students and employees may obtain a copy upon request from the Admissions Office. A paper copy is available free of charge at the front desk of the Bellingham campus, and this online version is maintained permanently on the Institute website."}),e.jsx("p",{children:"Zorganics Institute is a single-campus, non-residential institution. The Institute does not own or operate any on-campus student housing facilities, and therefore does not publish a separate Annual Fire Safety Report."})]}
1279),e.jsxs(vt,{heading:"2. Reporting Crimes & Emergencies",children:[e.jsx("p",{children:"The Institute encourages all students, staff, faculty, and guests to accurately and promptly report all crimes and public-safety-related incidents to the Campus Safety Officer and to the appropriate police agency. Reports may be made in person at the front desk, by phone, or by email."}),e.jsx(ha,{heading:"Emergency Contacts",children:e.jsx(Zn,{items:[e.jsxs(e.Fragment,{children:[e.jsx("strong",{children:"Police · Fire · Medical Emergency:"})," Dial 911"]}),e.jsxs(e.Fragment,{children:[e.jsx("strong",{children:"Bellingham Police Department (non-emergency):"})," (360) 778-8800"]}),e.jsxs(e.Fragment,{children:[e.jsx("strong",{children:"Whatcom County Sheriff (non-emergency):"})," (360) 778-6600"]}),e.jsxs(e.Fragment,{children:[e.jsx("strong",{children:"Campus Safety Officer / Front Desk:"})," (360) 392-8243"]}),e.jsxs(e.Fragment,{children:[e.jsx("strong",{children:"Campus Safety Email:"})," [email protected]"]}),e.jsxs(e.Fragment,{children:[e.jsx("strong",{children:"Title IX Coordinator:"})," [email protected] · (360) 392-8243"]}),e.jsxs(e.Fragment,{children:[e.jsx("strong",{children:"National Suicide & Crisis Lifeline:"})," Dial or text 988"]})]})}),e.jsx("p",{children:"Campus Security Authorities (CSAs) â including administrators, instructors with student-oversight duties, and designated staff â are trained to receive and forward crime reports for inclusion in the annual statistics. Individuals may also report crimes on a voluntary, confidential basis for inclusion in the statistical disclosure."})]}),e.jsxs(vt,{heading:"3. Timely Warnings & Emergency Notification",children:[e.jsxs("p",{children:["If a situation arises, either on or off campus, that in the judgment of the Campus Safety Officer constitutes an ongoing or continuing threat to the campus community, a ",e.jsx("strong",{children:"Timely Warning"})," will be issued. The warning will be distributed via the Instituteâs emergency text/email alert system, posted at campus entrances, and announced verbally in classrooms as appropriate."]}),e.jsxs("p",{children:["Upon confirmation of a significant emergency or dangerous situation involving an immediate threat to the health or safety of students or employees, the Institute will, without delay, issue an ",e.jsx("strong",{children:"Emergency Notification"})," and initiate its emergency-response and evacuation procedures, unless doing so would compromise efforts to contain the emergency. The Institute tests these procedures at least annually and documents each test."]})]}),e.jsx(vt,{heading:"4. Campus Access & Security of Facilities",children:e.jsx("p",{children:"Access to the campus during business hours is open to students, staff, and visitors with legitimate business. During non-business hours, access is restricted to authorized personnel with keys or electronic access. The facility is equipped with exterior lighting, locking mechanisms on all entries, and the premises are monitored during operating hours. Maintenance staff regularly inspect lighting, locks, and walkways and promptly repair any hazards."})}),e.jsx(vt,{heading:"5. Drug & Alcohol Policy",children:e.jsx("p",{children:"The unlawful possession, use, or distribution of illicit drugs and alcohol by students and employees on Institute property or as part of any Institute activity is strictly prohibited. The Institute maintains a drug-free campus and workplace consistent with the Drug-Free Schools and Communities Act. Violations may result in disciplinary action up to and including dismissal and referral for prosecution. Information on counseling, treatment, and rehabilitation programs is available from the Student Services Office."})}),e.jsxs(vt,{heading:"6. Violence Against Women Act (VAWA) â Dating Violence, Domestic Violence, Sexual Assault & Stalking",children:[e.jsx("p",{children:"Zorganics Institute prohibits the crimes of dating violence, domestic violence, sexual assault, and stalking as defined under the Violence Against Women Reauthorization Act (VAWA) and Title IX. The Institute provides primary prevention and awareness programs for all incoming students and new employees, and ongoing awareness campaigns for current members of the community."}),e.jsx(ha,{heading:"If You Are a Victim",children:e.jsx(Zn,{items:["Get to a safe place and contact law enforcement (911) if you are in immediate danger.","Preserve evidence as may be necessary to prove the offense or to obtain a protection order.","Report the incident to the Title IX Coordinator, who will explain your rights and available options.","You may request changes to academic schedules and request assistance with no-contact directives and protective orders, regardless of whether you report to law enforcement."]})}),e.jsx("p",{children:"The Institute will provide a prompt, fair, and impartial investigation and resolution. Both the accuser and the accused are entitled to the same opportunities to have an advisor present and will be simultaneously informed, in writing, of the outcome of any disciplinary proceeding."})]}),e.jsx(vt,{heading:"7. Sex Offender Registry Information",children:e.jsx("p",{children:"In accordance with the Campus Sex Crimes Prevention Act, information concerning registered sex offenders may be obtained from the Washington State Sex Offender Information Center and the Whatcom County Sheriffâs Office."})}),e.jsxs(vt,{heading:"8. Three-Year Campus Crime Statistics (2023â2025)",children:[e.jsx("p",{children:"The following Clery-reportable offenses occurred on campus, on public property immediately adjacent to campus, and in non-campus areas under Institute control during the three most recent calendar years. A value of zero (0) indicates no reported incidents."}),e.jsx("div",{className:"overflow-x-auto mt-4 rounded-xl",style:{border:"1px solid #E8DDD0"},children:e.jsxs("table",{className:"w-full text-sm",children:[e.jsx("thead",{children:e.jsxs("tr",{style:{background:"#FAF7F2"},children:[e.jsx("th",{className:"text-left px-4 py-3 font-bold",style:{color:"#3B0A11"},children:"Offense Category"}),e.jsx("th",{className:"px-4 py-3 font-bold",style:{color:"#3B0A11"},children:"2023"}),e.jsx("th",{className:"px-4 py-3 font-bold",style:{color:"#3B0A11"},children:"2024"}),e.jsx("th",{className:"px-4 py-3 font-bold",style:{color:"#3B0A11"},children:"2025"})]})}),e.jsx("tbody",{style:{color:"#4A2228"},children:["Murder / Non-negligent Manslaughter","Negligent Manslaughter","Rape","Fondling","Robbery","Aggravated Assault","Burglary","Motor Vehicle Theft","Arson","Domestic Violence","Dating Violence","Stalking"].map((t,s)=>e.jsxs("tr",{style:{borderTop:"1px solid #F0E8DD",background:s%2?"#FFFFFF":"#FCFAF6"},children:[e.jsx("td",{className:"px-4 py-2.5",children:t}),e.jsx("td",{className:"px-4 py-2.5 text-center",children:"0"}),e.jsx("td",{className:"px-4 py-2.5 text-center",children:"0"}),e.jsx("td",{className:"px-4 py-2.5 text-center",children:"0"})]},t))})]})}),e.jsx("p",{className:"text-xs mt-3",style:{color:"#7A3A44"},children:"Hate-crime and arrest/referral statistics (liquor-law, drug-abuse, and weapons violations) are maintained in the full statistical appendix, available on request from the Campus Safety Officer. Zorganics Institute reported zero (0) such incidents during the reporting period."})]}),e.jsx(vt,{heading:"9. Annual Disclosure & Recordkeeping",children:e.jsx("p",{children:"This report is reviewed and updated annually. Questions regarding the Annual Security Report, requests for the complete statistical appendix, or requests for accommodations may be directed to the Campus Safety Officer at [email protected] or (360) 392-8243."})})]}),dre=()=>(d.useEffect(()=>{if(window.location.hash!=="#net-price-calculator")return;const t=window.setTimeout(()=>{var s;(s=document.getElementById("net-price-calculator"))==null||s.scrollIntoView({behavior:"smooth",block:"start"})},120);return()=>window.clearTimeout(t)},[]),e.jsxs(cf,{title:"Consumer Information & Student Disclosures",eyebrow:"Higher Education Act · Title IV Consumer Information",subtitle:"Federal regulations require Zorganics Institute to make certain consumer information readily available to enrolled and prospective students. This page summarizes your rights and responsibilities regarding financial aid, student services, academic policies, institutional outcomes, and voter registration. Printed copies and additional detail are available on request from the Financial Aid and Student Services offices.",lastUpdated:"Consumer Information Disclosure â Effective 2026",children:[e.jsxs(vt,{heading:"1. Financial Aid â Rights & Responsibilities",children:[e.jsx(ha,{heading:"Your Rights as a Financial Aid Recipient",children:e.jsx(Zn,{items:["To know what financial assistance is available, including all federal, state, and institutional aid programs.","To know the deadlines for submitting applications and the process used to determine your eligibility.","To know how your financial need was determined, including the cost of attendance and the resources considered.","To know the criteria used to determine satisfactory academic progress (SAP) and the consequences of failing to meet them.","To request an explanation of the various programs in your aid package and to accept or decline any award.","To know the terms of any loan, including interest rates, total repayment amount, and the repayment schedule.","To know the institution’s refund (Return to Title IV / R2T4) policy and how withdrawal affects your aid."]})}),e.jsx(ha,{heading:"Your Responsibilities as a Financial Aid Recipient",children:e.jsx(Zn,{items:["Complete all application forms accurately and submit them on time to the correct location.","Provide correct, truthful information; misreporting information is a violation of law and may be a criminal offense.","Return all additional documentation, verification, corrections, or new information requested by the Financial Aid Office.","Read, understand, and keep copies of all forms you sign.","Repay any student loans according to the terms of your master promissory note.","Notify the school of any change in name, address, or enrollment status.","Understand and comply with the institution’s refund and Satisfactory Academic Progress policies."]})}),e.jsx(ha,{heading:"Federal Student Aid Programs",children:e.jsxs("p",{children:["Zorganics Institute participates in the following federal Title IV programs (where eligible): the Federal Pell Grant, Federal Direct Subsidized and Unsubsidized Loans, and the Federal Direct PLUS Loan. The Institute also accepts Workforce Innovation and Opportunity Act (WIOA) funding, Veterans (GI Bill®) benefits, and Washington state grant programs. Begin the financial-aid process by completing the Free Application for Federal Student Aid (FAFSA) using the Federal School Code ",e.jsx("strong",{children:"043003"}),"."]})})]}),e.jsxs(vt,{heading:"2. Cost of Attendance & Net Price Calculator",id:"net-price-calculator",children:[e.jsx("p",{children:"A full schedule of tuition, fees, kit/supply costs, and estimated cost of attendance for each program is published in the School C
1279atalog. Prospective students should review the School Catalog for the complete, program-by-program tuition and fee schedule."}),e.jsx("p",{children:"Prospective students may also estimate their net price (cost of attendance minus estimated grant and scholarship aid) using the U.S. Department of Educationâs Federal Net Price Calculator Center. Individualized estimates and a written cost breakdown are available on request from the Admissions and Financial Aid offices."}),e.jsxs("div",{className:"mt-5 flex flex-col sm:flex-row gap-3",children:[e.jsxs("a",{href:"/school-catalog",className:"inline-flex items-center justify-center gap-2 px-5 py-3 rounded-xl text-sm font-bold transition-all duration-300 hover:-translate-y-0.5",style:{background:"#3B0A11",color:"#D4AF37",border:"1px solid #3B0A11"},children:["Tuition & Fees in the School Catalog ",e.jsx(tm,{size:14})]}),e.jsxs("a",{href:"https://collegecost.ed.gov/",target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center justify-center gap-2 px-5 py-3 rounded-xl text-sm font-bold transition-all duration-300 hover:-translate-y-0.5",style:{background:"#FFFFFF",color:"#3B0A11",border:"1px solid #E8DDD0"},children:["Federal Net Price Calculator Center ",e.jsx(Ua,{size:14,style:{color:"#D4AF37"}})]})]})]}),e.jsx(vt,{heading:"3. Return to Title IV (R2T4) & Refund Policy",children:e.jsx("p",{children:"A student who withdraws before completing the period of enrollment may be entitled to a refund of a portion of tuition and fees, and may be required to return a portion of federal aid received. The Return to Title IV (R2T4) calculation determines the amount of federal aid the student has earned based on the percentage of the payment period completed. The complete refund and R2T4 policy, including worked examples, is published in the School Catalog and enrollment agreement."})}),e.jsx(vt,{heading:"4. Satisfactory Academic Progress (SAP)",children:e.jsx("p",{children:"To maintain eligibility for financial aid and remain in good standing, students must meet the Instituteâs Satisfactory Academic Progress standards, which measure both a qualitative component (minimum cumulative grade average) and a quantitative component (minimum attendance / clock-hour completion rate and maximum timeframe). SAP is evaluated at defined checkpoints. Students who fail to meet SAP are placed on warning, and â following an approved appeal â may be placed on probation with an academic plan. The complete SAP policy, including appeal procedures, is published in the School Catalog."})}),e.jsx(vt,{heading:"5. Student Services & Support",children:e.jsx(Zn,{items:[e.jsxs(e.Fragment,{children:[e.jsx("strong",{children:"Academic Advising:"})," Personalized progress reviews, clock-hour tracking, and remediation planning."]}),e.jsxs(e.Fragment,{children:[e.jsx("strong",{children:"Career Services:"})," Job-placement assistance, resume and portfolio development, state board licensure preparation, and employer referrals."]}),e.jsxs(e.Fragment,{children:[e.jsx("strong",{children:"Disability Services:"})," Reasonable accommodations under the ADA / Section 504 â contact Student Services to request an accommodation."]}),e.jsxs(e.Fragment,{children:[e.jsx("strong",{children:"Financial Aid Counseling:"})," One-on-one guidance on aid eligibility, entrance/exit counseling, and loan management."]}),e.jsxs(e.Fragment,{children:[e.jsx("strong",{children:"Health & Wellness Referrals:"})," Referrals to community mental-health, crisis (988), and medical resources."]}),e.jsxs(e.Fragment,{children:[e.jsx("strong",{children:"Tutoring & Academic Support:"})," Supplemental instruction and study resources for theory and practical coursework."]})]})}),e.jsxs(vt,{heading:"6. Institutional & Program Outcomes",children:[e.jsx("p",{children:"As a NACCAS-accredited institution, Zorganics Institute publishes annual completion, licensure-examination pass, and job-placement rates for each program. These outcome rates are disclosed in the NACCAS Annual Report and are provided in writing to each prospective student prior to enrollment, with signed acknowledgement. The most recent rates are available on request from the Admissions Office."}),e.jsx("div",{className:"overflow-x-auto mt-4 rounded-xl",style:{border:"1px solid #E8DDD0"},children:e.jsxs("table",{className:"w-full text-sm",children:[e.jsx("thead",{children:e.jsxs("tr",{style:{background:"#FAF7F2"},children:[e.jsx("th",{className:"text-left px-4 py-3 font-bold",style:{color:"#3B0A11"},children:"Outcome Metric"}),e.jsx("th",{className:"px-4 py-3 font-bold",style:{color:"#3B0A11"},children:"Disclosure"})]})}),e.jsx("tbody",{style:{color:"#4A2228"},children:[["Completion Rate","Published annually per NACCAS standards"],["Licensure Examination Pass Rate","Published annually per NACCAS standards"],["Job Placement Rate","Published annually per NACCAS standards"],["Accrediting Body","NACCAS â National Accrediting Commission of Career Arts & Sciences"],["State Licensing Authority","Washington State Department of Licensing (DOL)"]].map((t,s)=>e.jsxs("tr",{style:{borderTop:"1px solid #F0E8DD",background:s%2?"#FFFFFF":"#FCFAF6"},children:[e.jsx("td",{className:"px-4 py-2.5 font-medium",children:t[0]}),e.jsx("td",{className:"px-4 py-2.5",children:t[1]})]},t[0]))})]})})]}),e.jsx(vt,{heading:"7. Family Educational Rights & Privacy Act (FERPA)",children:e.jsx("p",{children:"The Family Educational Rights and Privacy Act (FERPA) affords students certain rights with respect to their education records: the right to inspect and review their records within 45 days of a request; the right to request amendment of records the student believes are inaccurate or misleading; the right to provide written consent before personally identifiable information is disclosed, except to the extent FERPA authorizes disclosure without consent; and the right to file a complaint with the U.S. Department of Education. The Institute may disclose directory information unless the student submits a written request to withhold it."})}),e.jsxs(vt,{heading:"8. Voter Registration",children:[e.jsx("p",{children:"Zorganics Institute encourages all eligible students to register to vote and participate in the democratic process. Washington State offers online, mail, and same-day voter registration."}),e.jsx(Zn,{items:[e.jsxs(e.Fragment,{children:[e.jsx("strong",{children:"Register online (Washington):"})," VoteWA.gov"]}),e.jsxs(e.Fragment,{children:[e.jsx("strong",{children:"National registration resources:"})," vote.gov"]}),"Paper voter-registration forms are available at the front desk of the Bellingham campus.","Contact the Student Services Office for assistance with the registration process."]})]}),e.jsx(vt,{heading:"9. Nondiscrimination & Equal Opportunity",children:e.jsx("p",{children:"Zorganics Institute does not discriminate on the basis of race, color, national origin, sex, disability, age, religion, sexual orientation, gender identity, or any other protected status in its admissions, instruction, or employment practices, in accordance with Title VI, Title IX, Section 504, and the ADA. Inquiries regarding nondiscrimination policies may be directed to the Title IX Coordinator at [email protected]."})}),e.jsx(vt,{heading:"10. How to Request Additional Information",children:e.jsx("p",{children:"Any of the consumer-information items summarized here is available in full, free of charge, upon request. Contact the Financial Aid Office or Student Services at (360) 392-8243 or [email protected], or visit the Bellingham campus at 410 West Bakerview Road, Suite 112, Bellingham, WA 98226."})})]})),ure=()=>e.jsxs(cf,{title:"Privacy Policy",eyebrow:"Institutional Privacy & Data Protection",subtitle:"This Privacy Policy describes how Zorganics Institute and Zorganics Global, LLC (collectively, âZorganics,â âwe,â or âusâ) collect, use, disclose, and protect personal information from website visitors, prospective and enrolled students, salon/spa clients, and customers. It includes our compliance commitments under the Washington My Health My Data Act (MHMDA).",lastUpdated:"Privacy Policy â Last Updated 2026",children:[e.jsxs(vt,{heading:"1. Information We Collect",children:[e.jsx(ha,{heading:"Information You Provide",children:e.jsx(Zn,{items:["Contact and identity information (name, email, phone, mailing address) submitted through forms, enrollment, newsletter signup, or booking.","Enrollment and academic re
1279cords, financial-aid application data, and payment information.","Salon/spa client intake details and service preferences.","Communications you send to us, including inquiries and support requests."]})}),e.jsx(ha,{heading:"Information Collected Automatically",children:e.jsx(Zn,{items:["Device and usage data such as IP address, browser type, pages viewed, and referring URLs.","Cookies and similar technologies used to operate the site, remember preferences, and measure traffic (see Section 7)."]})})]}),e.jsx(vt,{heading:"2. How We Use Your Information",children:e.jsx(Zn,{items:["To process enrollment, administer financial aid, and provide educational and salon/spa services.","To respond to your inquiries and provide customer and student support.","To send transactional messages, appointment confirmations, and â with your consent â marketing communications.","To operate, secure, and improve our website and services.","To comply with legal, accreditation (NACCAS), and regulatory obligations."]})}),e.jsx(vt,{heading:"3. How We Share Information",children:e.jsxs("p",{children:["We do ",e.jsx("strong",{children:"not"})," sell your personal information. We share information only as necessary with: service providers who perform functions on our behalf (payment processing, email delivery, hosting, analytics) under contractual confidentiality obligations; government agencies and accrediting bodies as required by law; and successors in the event of a business transfer. We do not share consumer health data with third parties except as expressly described in Section 5 with your valid authorization."]})}),e.jsx(vt,{heading:"4. Education Records (FERPA)",children:e.jsx("p",{children:"Student education records are additionally protected under the Family Educational Rights and Privacy Act (FERPA). We disclose personally identifiable information from education records only with student consent or as permitted by FERPA. See our Consumer Information page for your full FERPA rights."})}),e.jsxs(vt,{heading:"5. Washington My Health My Data Act (MHMDA) Compliance",children:[e.jsxs("p",{children:["Zorganics is committed to compliance with the Washington My Health My Data Act (RCW 19.373). The MHMDA governs the collection, use, and sharing of ",e.jsx("strong",{children:"âconsumer health dataâ"})," â personal information that is linked or reasonably linkable to a consumer and that identifies the consumerâs past, present, or future physical or mental health status, including data derived from our wellness, esthetics, and skincare services."]}),e.jsx(ha,{heading:"Consumer Health Data We May Collect",children:e.jsx(Zn,{items:["Skin-condition, skincare, and esthetics service intake information.","Wellness and treatment preferences provided during salon/spa or clinical-services consultations.","Any information that could reasonably be associated with a health condition you disclose to us."]})}),e.jsx(ha,{heading:"Our MHMDA Commitments",children:e.jsx(Zn,{items:["We collect consumer health data only with your affirmative consent, or as strictly necessary to provide a service you requested.","We obtain separate, valid authorization before selling any consumer health data â and as a matter of policy, we do not sell consumer health data.","We will not geofence any entity that provides in-person health-care services to identify, track, or collect consumer health data, or to send health-related advertisements.","We restrict access to consumer health data to employees and contractors who require it to provide services, and we maintain administrative, technical, and physical safeguards to protect it.","We retain consumer health data only as long as reasonably necessary for the disclosed purpose or as required by law."]})}),e.jsxs(ha,{heading:"Your MHMDA Rights",children:[e.jsx("p",{children:"Washington consumers have the right to:"}),e.jsx(Zn,{items:["Confirm whether we are collecting, sharing, or selling your consumer health data, and to access that data.","Withdraw consent to the collection and sharing of your consumer health data.","Request deleti
1279on of your consumer health data.","Be free from discrimination for exercising any of these rights."]}),e.jsxs("p",{children:["To exercise these rights, contact our Privacy Officer at ",e.jsx("strong",{children:"[email protected]"})," or (360) 392-8243. We will respond within the timeframe required by the MHMDA. You may appeal a denial by replying to our response; if your appeal is denied, you may contact the Washington State Attorney Generalâs Office."]})]})]}),e.jsx(vt,{heading:"6. Data Security & Retention",children:e.jsx("p",{children:"We implement reasonable administrative, technical, and physical safeguards designed to protect personal information against unauthorized access, disclosure, alteration, and destruction. No method of transmission or storage is 100% secure; however, we continuously review and improve our security practices. We retain personal information for as long as necessary to fulfill the purposes described in this policy and to comply with our legal and accreditation recordkeeping obligations."})}),e.jsx(vt,{heading:"7. Cookies & Tracking Technologies",children:e.jsx("p",{children:"We use cookies and similar technologies to operate the site, remember your preferences, and analyze traffic. You can control cookies through your browser settings; disabling certain cookies may affect site functionality. Where required, we obtain consent via our cookie banner before placing non-essential cookies."})}),e.jsx(vt,{heading:"8. Children's Privacy",children:e.jsx("p",{children:"Our website is not directed to children under 13, and we do not knowingly collect personal information from children under 13. If you believe a child has provided us personal information, please contact our Privacy Officer so we can delete it."})}),e.jsx(vt,{heading:"9. Your Choices",children:e.jsx(Zn,{items:["You may opt out of marketing emails at any time using the unsubscribe link or by contacting us.","You may request access to, correction of, or deletion of your personal information, subject to legal and recordkeeping requirements.","You may set your browser to refuse cookies as described in Section 7."]})}),e.jsx(vt,{heading:"10. Changes to This Policy",children:e.jsx("p",{children:"We may update this Privacy Policy from time to time. Material changes will be posted on this page with an updated âLast Updatedâ date. Your continued use of our website after changes become effective constitutes acceptance of the revised policy."})}),e.jsxs(vt,{heading:"11. SMS / Text Messaging",children:[e.jsx("p",{children:e.jsx("strong",{children:"No mobile information will be shared with third parties/affiliates for marketing/promotional purposes. All the above categories exclude text messaging originator opt-in data and consent; this information will not be shared with any third parties."})}),e.jsx("p",{children:e.jsx("strong",{children:"SMS opt-in data and consent will not be shared with any third parties for any purpose."})}),e.jsx("p",{children:e.jsx("strong",{children:"Mobile phone numbers, SMS opt-in data, and SMS consent information will not be sold, rented, shared, or disclosed to third parties or affiliates for marketing or promotional purposes."})}),e.jsx("p",{children:"Upon messaging opt-in, the end user agrees to receive messages from Zorganics Institute of Beauty & Wellness regarding admissions inquiries, program information, enrollment updates, appointment or tour information, and student-related notifications. End users can opt out by replying STOP or request more information by replying HELP. Message frequency varies. Message and data rates may apply."}),e.jsx("p",{children:"If you need assistance or have questions about our SMS service, reply with âHELPâ to any SMS message you receive, or contact Zorganics Institute of Beauty & Wellness customer support."})]}),e.jsx(vt,{heading:"12. Contact Us",children:e.jsxs("p",{children:["Questions, requests, or complaints regarding this Privacy Policy or your data rights may be directed to our Privacy Officer at ",e.jsx("strong",{children:"[email protected]"}),", by phone at (360) 392-8243, or by mail to Zorganics Institute, Attn: Privacy Officer, 410 West Bakerview Road, Suite 112, Bellingham, WA 98226."]})})]}),mre=()=>e.jsx(cf,{title:"SMS Terms & Conditions",children:e.jsxs("div",{className:"space-y-4 text-[15px] leading-relaxed",style:{color:"#4A2228"},children:[e.jsx("p",{children:"By opting in to receive SMS messages from Zorganics Institute of Beauty & Wellness, you agree to re
1279ceive text messages regarding admissions inquiries, program information, enrollment updates, appointment or tour information, and student-related notifications."}),e.jsx("p",{children:"Message frequency varies. Message and data rates may apply."}),e.jsx("p",{children:"Reply STOP at any time to opt out of receiving SMS messages. Reply HELP for assistance."}),e.jsxs("p",{children:["For additional assistance, contact Zorganics Institute of Beauty & Wellness at"," ",e.jsx("a",{href:"mailto:[email protected]",className:"font-semibold underline",children:"[email protected]"})," ","or ",e.jsx("a",{href:"tel:+13603928243",className:"font-semibold underline",children:"(360) 392-8243"}),"."]}),e.jsxs("p",{children:["View our Privacy Policy at:",e.jsx("br",{}),e.jsx("a",{href:"https://www.zorganicsinstitute.edu/privacy-policy",className:"font-semibold underline break-all",children:"https://www.zorganicsinstitute.edu/privacy-policy"})]})]})}),eb=[{version:"2026.1",effectiveDate:"2026-01-01",title:"School Catalog",status:"current",href:"/school-catalog",summary:"Full migration of all consumer-information disclosures into the native website; the legacy .edu catalog is retired at launch.",changes:["Migrated Catalog, Annual Security Report, Consumer Information & Privacy Policy in-site","Added Washington My Health My Data Act (RCW 19.373) privacy clauses","Updated NACCAS Standard V completion, licensure & placement outcomes for 2026"]},{version:"2025.2",effectiveDate:"2025-08-15",title:"School Catalog",status:"archived",summary:"Mid-year revision: updated R2T4 worked examples and SAP evaluation checkpoints.",changes:["Revised Return to Title IV (R2T4) refund worked examples","Clarified SAP probation academic-plan terms","Updated tuition & kit/supply fee schedule"]},{version:"2025.1",effectiveDate:"2025-01-02",title:"School Catalog",status:"archived",summary:"Annual edition: refreshed academic calendar, faculty roster, and program clock hours.",changes:["New 2025 academic calendar & cohort start dates","Added Master Esthetics Bridge (450 hr) program","Updated faculty qualifications & facilities description"]},{version:"2024.1",effectiveDate:"2024-01-03",title:"School Catalog",status:"archived",summary:"Annual edition establishing the NACCAS-accredited program catalog of record.",changes:["Baseline NACCAS-accredited catalog of record","Initial Title IV consumer-information disclosures","Published licensure & job-placement outcomes"]}];var FF;const dN=((FF=eb.find(t=>t.status==="current"))==null?void 0:FF.version)||eb[0].version,Y8=t=>new Date(t+"T00:00:00").toLocaleDateString("en-US",{year:"numeric",month:"long",day:"numeric"}),pre="#5A1A24",wg="#7A3A44",hre="#4A2228",DE="#E8DDD0",dj="#FAF7F2",xre=({compact:t=!1})=>{const[s,n]=d.useState(eb);return d.useEffect(()=>{let a=!0;return(async()=>{try{const{data:r,error:i}=await O.from("catalog_versions").select("version, effective_date, title, status, summary, changes").order("effective_date",{ascending:!1});if(!a||i||!r||r.length===0)return;n(r.map(o=>({version:o.version,effectiveDate:o.effective_date,title:o.title,status:o.status==="current"?"current":"archived",summary:o.summary||"",changes:Array.isArray(o.changes)?o.changes:[],href:o.status==="current"?"/school-catalog":void 0})))}catch{}})(),()=>{a=!1}},[]),e.jsxs("div",{className:"space-y-4",children:[s.map(a=>{const r=a.status==="current";return e.jsxs("div",{className:"rounded-2xl p-5",style:{background:r?dj:"#FFFFFF",border:`1px solid ${r?$+"66":DE}`,boxShadow:r?"0 4px 18px rgba(59,10,17,0.06)":"none"},children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-3 mb-2",children:[e.jsx("div",{className:"w-9 h-9 rounded-xl flex items-center justify-center flex-shrink-0",style:{background:r?$+"22":dj,color:r?"#9A7B1C":wg},children:r?e.jsx(Ue,{size:18}):e.jsx(RP,{size:18})}),e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[e.jsxs("h4",{className:"text-base font-bold",style:{color:k},children:[a.title," · Edition ",a.version]}),e.jsx("span",{className:"px-2 py-0.5 rounded-full text-[10px] font-bold uppercase tracking-wider",style:r?{background:"rgba(45,138,78,0.1)",color:"#2D6B3E",border:"1px solid rgba(45,138,78,0.25)"}:{background:dj,color:wg,border:`1px solid ${DE}`},children:r?"Current Edition":"Archived"})]}),e.jsxs("p",{className:"text-xs font-medium",style:{color:wg},children:["Effective ",Y8(a.effectiveDate)]})]}),r&&a.href&&e.jsxs("a",{href:a.href,className:"ml-auto inline-flex items-center gap-1.5 px-3 py-1.5 rounded-lg text-xs font-bold transition-all hover:-translate-y-0.5",style:{background:k,color:$,border:`1px solid ${$}44`},children:[e.jsx(Kt,{size:12})," View Current Catalog"]})]}),e.jsx("p",{className:"text-[14px] leading-relaxed mb-3",style:{color:hre},children:a.summary}),!t&&a.changes.length>0&&e.jsx("ul",{className:"space-y-1.5",children:a.changes.map((i,o)=>e.jsxs("li",{className:"flex gap-2.5 text-[13px] leading-relaxed",style:{color:pre},children:[e.jsx("span",{className:"mt-1.5 w-1.5 h-1.5 rounded-full flex-shrink-0",style:{background:$}}),e.jsx("span",{children:i})]},o))})]},a.version)}),e.jsxs("p",{className:"flex items-center gap-1.5 text-[11px] pt-1",style:{color:wg},children:[e.jsx(en,{size:12,style:{color:$}}),"Prior catalog editions of record are retained in-site for NACCAS / FSA audit purposes. A printed copy of any edition is available on request from the Admissions Office."]})]})},fre=()=>
1279e.jsxs(cf,{title:"School Catalog",eyebrow:"Official Institutional Catalog · NACCAS Accredited",subtitle:"The Zorganics Institute School Catalog describes our NACCAS-approved programs, clock-hour requirements, tuition and fee schedules, the academic calendar, and the admissions, attendance, grading, and refund policies that govern enrollment. This catalog is provided to every prospective student prior to enrollment with signed acknowledgement, and is available in print on request from the Admissions Office.",lastUpdated:"Catalog Edition â Effective 2026",children:[e.jsxs(vt,{heading:"1. About the Institute",children:[e.jsx("p",{children:"Zorganics Institute of Beauty & Wellness is a NACCAS-accredited career college licensed by the Washington State Department of Licensing (DOL). The Institute specializes in clean, organic, vegan-forward beauty and wellness education across cosmetology, esthetics, and manicuring (Manicurist). The active campus is located at 410 West Bakerview Road, Suite 112, Bellingham, WA 98226. Renton Campus â Coming Soon · Planned Expansion. Location and opening timeline will be announced once finalized and required approvals are completed."}),e.jsx(ha,{heading:"Mission",children:e.jsx("p",{children:"To deliver elite, clinically grounded, organically inspired beauty and wellness education that prepares graduates for licensure, sustainable careers, and ethical professional practice â while advancing prevention, sustainability, and community impact through the Zorganics Foundation."})})]}),e.jsxs(vt,{heading:"2. Programs of Study & Clock Hours",children:[e.jsx("p",{children:"All programs are measured in clock hours and approved by NACCAS and the Washington State Department of Licensing. Each program prepares students for the corresponding Washington State licensure examination."}),e.jsx("div",{className:"overflow-x-auto mt-4 rounded-xl",style:{border:"1px solid #E8DDD0"},children:e.jsxs("table",{className:"w-full text-sm",children:[e.jsx("thead",{children:e.jsxs("tr",{style:{background:"#FAF7F2"},children:[e.jsx("th",{className:"text-left px-4 py-3 font-bold",style:{color:"#3B0A11"},children:"Program"}),e.jsx("th",{className:"px-4 py-3 font-bold",style:{color:"#3B0A11"},children:"Clock Hours"}),e.jsx("th",{className:"text-left px-4 py-3 font-bold",style:{color:"#3B0A11"},children:"Credential"})]})}),e.jsx("tbody",{style:{color:"#4A2228"},children:[["Cosmetology","1,600 hrs","WA Cosmetology License"],["Master Esthetics","1,200 hrs","WA Master Esthetician License"],["Master Esthetics Bridge","450 hrs","WA Master Esthetician Upgrade"],["Basic Esthetics","750 hrs","WA Esthetician License"],["Manicurist","600 hrs","WA Manicurist License"]].map((t,s)=>e.jsxs("tr",{style:{borderTop:"1px solid #F0E8DD",background:s%2?"#FFFFFF":"#FCFAF6"},children:[e.jsx("td",{className:"px-4 py-2.5 font-medium",children:t[0]}),e.jsx("td",{className:"px-4 py-2.5 text-center",children:t[1]}),e.jsx("td",{className:"px-4 py-2.5",children:t[2]})]},t[0]))})]})})]}),e.jsxs(vt,{heading:"3. Tuition & Fee Schedule",children:[e.jsxs("p",{children:["A complete schedule of tuition, registration fees, kit/supply costs, and the estimated total cost of attendance for each program is maintained by the Admissions and Financial Aid offices and provided in the enrollment agreement before any student signs. Prospective students may estimate their personalized net price (cost of attendance minus estimated grant and scholarship aid) using the institutional Net Price Calculator on this website. The Federal School Code for FAFSA is ",e.jsx("strong",{children:"043003"}),"."]}),e.jsx(Zn,{items:["Tuition is charged per program and disclosed in full in the enrollment agreement.","Kit and supply costs are itemized separately and disclosed prior to enrollment.","Federal Pell Grant, Direct Loans, WIOA, GI Bill®, and WA state aid may apply for eligible students.","No hidden fees â all charges are disclosed in writing with signed acknowledgement before enrollment."]})]}),e.jsx(vt,{heading:"4. Academic Calendar",children:e.jsx("p",{children:"Programs follow a published academic calendar with defined start dates, scheduled breaks, and recognized holidays. Clock-hour programs run on continuous enrollment with periodic cohort start dates throughout the year. The current calendar, including all start dates and holiday closures, is available from the Admissions Office and posted at the campus."})}),e.jsx(vt,{heading:"5. Admissions Requirements",children:e.jsx(Zn,{items:["Be at least 16 years of age (or meet WA state minimums for the chosen program).","Provide proof of high school graduation, GED, or equivalent (or meet ability-to-benefit provisions where applicable).","Complete an enrollment interview and campus tour.","Submit a completed and signed enrollment agreement.","Provide a valid government-issued photo ID and required documentation."]})}),e.jsxs(vt,{heading:"6. Attendance, Grading & Academic Progress",children:[e.jsx(ha,{heading:"Attendance",children:e.jsx("p",{children:"Students must maintain the minimum attendance / clock-hour completion rate defined for their program. Hours are logged daily and reviewed at scheduled checkpoints. Excessive absence may affect Satisfactory Academic Progress and financial aid eligibility."})}),e.jsx(ha,{heading:"Grading",children:e.jsx("p",{children:"Academic performance is evaluated through written theory examinations and graded practical assessments. Students must maintain the minimum cumulative grade average published for their program to remain in good standing."})}),e.jsx(ha,{heading:"Satisfactory Academic Progress (SAP)",children:e.jsx("p",{children:"SAP measures both a qualitative component (minimum cumulative grade average) and a quantitative component (minimum attendance / clock-hour rate and maximum timeframe). Students who fail to meet SAP are placed on warning and â following an approved appeal â may continue on probation with an academic plan. The full SAP policy and appeal procedure are part of this catalog and the enrollment agreement."})})]}),e.jsx(vt,{heading:"7. Refund & Return to Title IV (R2T4) Policy",children:e.jsx("p",{children:"A student who withdraws before completing the peri
1279od of enrollment may be entitled to a refund of a portion of tuition and fees and may be required to return a portion of federal aid received. The Return to Title IV (R2T4) calculation determines the amount of federal aid earned based on the percentage of the payment period completed. The complete refund and R2T4 policy, including worked examples, is published in the enrollment agreement and consumer-information disclosures."})}),e.jsx(vt,{heading:"8. Student Conduct & Rights",children:e.jsx("p",{children:"Students are expected to maintain professional conduct, sanitation, and ethical standards consistent with the beauty and wellness profession. The Institute does not discriminate on the basis of race, color, national origin, sex, disability, age, religion, sexual orientation, or gender identity. Students have the right to a safe learning environment, to grievance procedures, and to privacy of their education records under FERPA."})}),e.jsx(vt,{heading:"9. Licensure & Career Outcomes",children:e.jsx("p",{children:"As a NACCAS-accredited institution, Zorganics Institute publishes annual completion, licensure-examination pass, and job-placement rates for each program. Graduates are prepared to sit for the corresponding Washington State licensure examination and receive job-placement assistance, portfolio development, and employer referrals through Career Services."})}),e.jsxs(vt,{heading:"10. Catalog Acknowledgement & Requests",children:[e.jsx("p",{children:"This catalog is provided to every prospective student prior to enrollment with signed acknowledgement. A printed copy of the complete catalog, enrollment agreement, and all consumer-information disclosures is available free of charge upon request. Contact the Admissions Office at (360) 392-8243 or [email protected], or visit the Bellingham campus at 410 West Bakerview Road, Suite 112, Bellingham, WA 98226."}),e.jsx("div",{className:"flex flex-wrap gap-3 pt-2",children:e.jsxs(be,{to:"/disclosures/print",className:"inline-flex items-center gap-2 px-4 py-2.5 rounded-lg text-sm font-bold transition-all hover:-translate-y-0.5",style:{background:"#3B0A11",color:"#D4AF37",border:"1px solid rgba(212,175,55,0.4)"},children:[e.jsx(ef,{size:15})," Print / Save Full Disclosure Packet (PDF)"]})})]}),e.jsxs(vt,{heading:"11. Catalog Version History",id:"catalog-version-history",children:[e.jsx("div",{id:"catalog-versions"}
1279),e.jsxs("p",{children:["The current catalog of record is ",e.jsxs("strong",{children:["Edition ",dN]}),". Prior editions are retained in-site so that the catalog terms in effect at the time of any student's enrollment can be referenced for NACCAS and Federal Student Aid (FSA) audit purposes. The complete published trail follows."]}),e.jsxs("div",{className:"flex items-center gap-2 pt-1 pb-1 text-xs font-bold uppercase tracking-wider",style:{color:"#9A7B1C"},children:[e.jsx(en,{size:14})," Published Editions of Record"]}),e.jsx(xre,{})]})]}),hh="#3B0A11",K8="#5A1A24",uj="#7A3A44",Q8="#4A2228",Or="#D4AF37",mj="#E8DDD0",gre="#FAF7F2",yre="https://d64gsuwffb70l.cloudfront.net/69cae7fb5ea7db794957149e_1775337912224_4cc82887.jfif",Ng=({n:t,title:s,cite:n,children:a})=>e.jsxs("section",{className:"disclosure-doc",style:{breakBefore:"page"},children:[e.jsxs("div",{className:"mb-4",children:[e.jsxs("span",{className:"text-[11px] font-bold uppercase tracking-[0.2em]",style:{color:Or},children:["Disclosure ",t," · ",n]}),e.jsx("h2",{className:"font-display text-2xl font-bold mt-1 pb-2",style:{color:hh,borderBottom:`2px solid ${Or}`},children:s})]}),e.jsx("div",{className:"space-y-3 text-[14px] leading-relaxed",style:{color:Q8},children:a})]}),ui=({h:t,children:s})=>e.jsxs("div",{className:"mt-4",children:[e.jsx("h3",{className:"text-[15px] font-bold mb-1.5",style:{color:K8},children:t}),e.jsx("div",{className:"space-y-2",children:s})]}),RE=()=>(sn(),d.useEffect(()=>{const t=document.title;return document.title="Consumer Disclosure Packet · Zorganics Institute",window.scrollTo(0,0),()=>{document.title=t}},[]),e.jsxs("div",{className:"min-h-screen",style:{background:gre},children:[e.jsx("style",{children:` 1280 @media print { 1281 .no-print { display: none !important; } 1282 .disclosure-doc { break-before: page; } 1283 .disclosure-doc:first-of-type { break-before: avoid; } 1284 body { background: #fff !important; } 1285 } 1286 @page { margin: 18mm 14mm; } 1287 `}),e.jsx("div",{className:"no-print sticky top-0 z-20",style:{background:hh,borderBottom:`2px solid ${Or}`},children:e.jsxs("div",{className:"max-w-[860px] mx-auto px-4 py-3 flex items-center justify-between gap-3",children:[e.jsxs(be,{to:"/",className:"inline-flex items-center gap-2 text-xs font-semibold",style:{color:Or},children:[e.jsx(Je,{size:14})," Back to Home"]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(be,{to:"/consumerinformation",className:"px-3 py-2 rounded-lg text-xs font-semibold",style:{background:"rgba(212,175,55,0.12)",color:Or,border:`1px solid ${Or}55`},children:"Consumer Information"}),e.jsxs("button",{onClick:()=>window.print(),className:"inline-flex items-center gap-2 px-4 py-2 rounded-lg text-sm font-bold transition-all hover:-translate-y-0.5",style:{background:Or,color:hh},children:[e.jsx(ef,{size:15})," Print / Save as PDF"]})]})]})}),e.jsxs("main",{className:"max-w-[860px] mx-auto px-5 lg:px-10 py-10",children:[e.jsxs("div",{className:"text-center pb-8 mb-8",style:{borderBottom:`1px solid ${mj}`},children:[e.jsx("div",{className:"w-16 h-16 rounded-2xl overflow-hidden mx-auto mb-4",style:{boxShadow:`0 0 0 2px ${Or}`},children:e.jsx("img",{src:yre,alt:"Zorganics Institute",className:"w-full h-full object-cover"})}),e.jsx("p",{className:"text-[11px] font-bold uppercase tracking-[0.25em]",style:{color:Or},children:"Zorganics Institute of Beauty & Wellness"}),e.jsx("h1",{className:"font-display text-3xl lg:text-4xl font-bold mt-2",style:{color:hh},children:"Consumer Information & Disclosure Packet"}),e.jsx("p",{className:"text-sm mt-3 max-w-xl mx-auto",style:{color:K8},children:"The complete set of federal and state consumer-information disclosures required under 34 CFR 668.41, the Clery Act, FERPA, the Washington My Health My Data Act, and NACCAS accreditation standards â compiled for printing or saving as a single PDF."}),e.jsxs("div",{className:"inline-flex flex-wrap items-center justify-center gap-x-5 gap-y-1 mt-4 text-xs font-medium",style:{color:uj},children:[e.jsxs("span",{children:["Catalog Edition ",dN]}),e.jsxs("span",{children:["Effective ",Y8(eb[0].effectiveDate)]}),e.jsxs("span",{children:["Generated ",new Date().toLocaleDateString()]})]}),e.jsxs("div",{className:"no-print inline-flex items-center gap-2 mt-5 px-3 py-1.5 rounded-full text-[11px] font-semibold",style:{background:"#fff",color:"#2D6B3E",border:"1px solid rgba(45,138,78,0.25)"},children:[e.jsx(CO,{size:12})," Tip: choose âSave as PDFâ in your browserâs print dialog"]})]}),e.jsxs("div",{className:"mb-10 p-5 rounded-2xl",style:{background:"#fff",border:`1px solid ${mj}`},children:[e.jsx("h3",{className:"text-sm font-bold uppercase tracking-wider mb-3",style:{color:hh},children:"Contents"}),e.jsx("ol",{className:"space-y-1.5 text-sm",style:{color:Q8}
1287,children:["School Catalog & Program Information","Annual Security Report (Clery Act)","Consumer Information & Student Financial Aid","Institutional Privacy Policy & WA My Health My Data Act"].map((t,s)=>e.jsxs("li",{className:"flex gap-3",children:[e.jsxs("span",{className:"font-bold",style:{color:Or},children:[s+1,"."]}),e.jsx("span",{children:t})]},t))})]}),e.jsxs(Ng,{n:1,cite:"34 CFR 668.43 â Institutional Information",title:"School Catalog & Program Information",children:[e.jsx("p",{children:"Zorganics Institute of Beauty & Wellness is a NACCAS-accredited career college licensed by the Washington State Department of Licensing, located at 410 West Bakerview Road, Suite 112, Bellingham, WA 98226. The Institute offers clock-hour programs in Cosmetology (1,600 hrs), Master Esthetics (1,200 hrs), Master Esthetics Bridge (450 hrs), Basic Esthetics (750 hrs), and Manicurist / Nail Technology (600 hrs), each preparing students for the corresponding Washington State licensure examination."}),e.jsx(ui,{h:"Tuition, Fees & Net Price",children:e.jsx("p",{children:"A complete schedule of tuition, registration fees, and kit/supply costs is provided in the enrollment agreement before any student signs. The Federal School Code for FAFSA is 043003. Prospective students may estimate their personalized net price using the institutional Net Price Calculator."})}),e.jsx(ui,{h:"Admissions, Attendance & Grading",children:e.jsx("p",{children:"Applicants must be at least 16 (or meet WA minimums), provide proof of high-school completion or equivalent, complete an enrollment interview, and sign an enrollment agreement. Students must maintain the published minimum attendance/clock-hour rate and cumulative grade average for their program."})})]}),e.jsxs(Ng,{n:2,cite:"20 USC § 1092(f) â Clery Act",title:"Annual Security Report",children:[e.jsx("p",{children:"In compliance with the Jeanne Clery Disclosure of Campus Security Policy and Campus Crime Statistics Act, the Institute publishes an Annual Security Report describing campus security policies, crime-prevention programs, emergency-response and evacuation procedures, and three years of campus crime statistics."}),e.jsxs(ui,{h:"Emergency Contacts",children:[e.jsxs("p",{children:["For any immediate emergency, call ",e.jsx("strong",{children:"911"})," first. Additional contacts:"]}),e.jsxs("ul",{className:"pl-1 space-y-1",children:[e.jsx("li",{children:"⢠Bellingham Police (non-emergency): (360) 778-8800"}),e.jsx("li",{children:"⢠Campus Director / Title IX Coordinator: [email protected]"}),e.jsx("li",{children:"⢠988 Suicide & Crisis Lifeline"}),e.jsx("li",{children:"⢠Campus front desk: (360) 392-8243"})]})]}),e.jsx(ui,{h:"Timely Warnings & Drug-Free Schools",children:e.jsx("p",{children:"The Institute issues timely warnings and emergency notifications for threats to the campus community, and maintains a Drug & Alcohol Abuse Prevention Program with a biennial review per the Drug-Free Schools and Communities Act (34 CFR Part 86). VAWA provisions cover domestic violence, dating violence, and stalking."})})]}),e.jsxs(Ng,{n:3,cite:"34 CFR 668.41 â Consumer Information",title:"Consumer Information & Student Financial Aid",children:[e.jsx(ui,{h:"Financial Aid Rights & Responsibilities",children:e.jsx("p",{children:"Eligible students may apply for the Federal Pell Grant, Direct Loans, WIOA, GI Bill®, and Washington State aid. Students have the right to know all available aid, eligibility criteria, disbursement procedures, and the terms of any loan, and are responsible for maintaining Satisfactory Academic Progress (SAP) and repaying borrowed funds."})}),e.jsx(ui,{h:"Return of Title IV (R2T4) & Refunds",children:e.jsx("p",{children:"Students who withdraw before completing the payment period may be entitled to a refund and may be required to return a portion of federal aid based on the percentage of the period completed, per 34 CFR 668.22."})}),e.jsx(ui,{h:"Student Services, Outcomes & FERPA",children:e.jsx("p",{children:"The Institute provides academic advising, career-placement assistance, and accessibility accommodations, and publishes NACCAS completion, licensure, and job-placement rates annually. Education records are protected under FERPA (34 CFR Part 99)."})}),e.jsx(ui,{h:"Voter Registration",children:e.jsx("p",{children:"Washington residents may register to vote online at VoteWA.gov. Voter-registration forms are also available from the Admissions Office on request."})})]}),e.jsxs(Ng,{n:4,cite:"RCW 19.373 â WA My Health My Data Act",title:"Institutional Privacy Policy & WA My Health My Data Act",children:[e.jsx("p",{children:"This policy describes how the Institute collects, uses, and protects personal information of prospective students, students, clinic clients, and website visitors, including the information you provide during enrollment, financial aid, and clinic services."}),e.jsx(ui,{h:"Washington My Health My Data Act",children:e.jsx("p",{children:"The Institute complies with the Washington My Health My Data Act (RCW 19.373). We do not collect, use, or share consumer health data beyond what is necessary to provide requested services and education without obtaining your separate, affirmative consent. Consumers have the right to confirm whether we are collecting, sharing, or selling their consumer health data; to access that data; to withdraw consent;
1287 and to request deletion. We do not sell consumer health data."})}),e.jsx(ui,{h:"Your Privacy Rights",children:e.jsx("p",{children:"To exercise any privacy right â access, correction, deletion, or withdrawal of consent â contact us at [email protected] or (360) 392-8243. We respond within the timeframes required by applicable law."})})]}),e.jsxs("div",{className:"mt-10 pt-6",style:{borderTop:`1px solid ${mj}`},children:[e.jsxs("div",{className:"flex items-start gap-2 text-[12px]",style:{color:uj},children:[e.jsx(Ie,{size:16,style:{color:Or},className:"flex-shrink-0 mt-0.5"}),e.jsx("p",{children:"This packet is provided to every prospective student prior to enrollment. The full, formatted text of each disclosure is maintained at /school-catalog, /annual-security-report, /consumerinformation, and /privacy-policy. Request a printed copy free of charge from the Admissions Office, 410 West Bakerview Rd, Ste 112, Bellingham, WA 98226 · (360) 392-8243."})]}),e.jsxs("p",{className:"text-center text-[11px] mt-5",style:{color:uj},children:["© 2026 Zorganics Institute · NACCAS Accredited · WA State DOL Certified · Title IV / FSA Eligible · Catalog Edition ",dN]})]})]})]})),uN="ecom_cart",IE=()=>{try{const t=localStorage.getItem(uN);if(!t)return[];const s=JSON.parse(t);return Array.isArray(s)?s:[]}catch{return[]}},bre=["wixstatic.com","zorganics.com","cloudfront.net","supabase"],J8=t=>{if(!t||typeof t!="string")return!1;const s=t.toLowerCase();return bre.some(n=>s.includes(n))},vre="https://static.wixstatic.com/media/a90cca_a65db4e34ddf4a8f90097fd223cc57db~mv2.png/v1/fill/w_1600,h_700,al_c,q_85,enc_avif,quality_auto/zorganics-shop-banner.png",jre=15,mN=t=>{if(!t)return"";const s=t.match(/\/media\/([^/]+~mv2\.[a-z]+)/i);return s?`wix:${s[1].toLowerCase()}`:t.trim().toLowerCase()},$E=t=>{const s={};t.forEach(a=>{const r=Array.isArray(a.images)?a.images.find(Boolean):void 0;if(!r)return;const i=mN(r);i&&(s[i]=(s[i]||0)+1)});const n=new Set;return Object.entries(s).forEach(([a,r])=>{r>jre&&n.add(a)}),n.add(mN(vre)),n},zE=(t,s)=>(Array.isArray(t)?t:[]).filter(J8).filter(n=>!s.has(mN(n))),wre=[{match:"hair",icon:e.jsx(Ss,{size:30,className:"text-[#8B5A3C]"}),from:"#FBE5C8",to:"#E8C9A0"},{match:"shampoo",icon:e.jsx(Ss,{size:30,className:"text-[#8B5A3C]"}),from:"#FBE5C8",to:"#E8C9A0"},{match:"conditioner",icon:e.jsx(Ss,{size:30,className:"text-[#8B5A3C]"}),from:"#FBE5C8",to:"#E8C9A0"},{match:"styling",icon:e.jsx(Ss,{size:30,className:"text-[#8B5A3C]"}),from:"#FBE5C8",to:"#E8C9A0"},{match:"makeup",icon:e.jsx(lx,{size:30,className:"text-[#800020]"}),from:"#F5D9DD",to:"#E8B8C0"},{match:"foundation",icon:e.jsx(lx,{size:30,className:"text-[#800020]"}),from:"#F5D9DD",to:"#E8B8C0"},{match:"serum",icon:e.jsx(fd,{size:30,className:"text-[#0F6B7B]"}),from:"#D6EEF2",to:"#A8DCE6"},{match:"toner",icon:e.jsx(fd,{size:30,className:"text-[#0F6B7B]"}),from:"#D6EEF2",to:"#A8DCE6"},{match:"mist",icon:e.jsx(fd,{size:30,className:"text-[#0F6B7B]"}),from:"#D6EEF2",to:"#A8DCE6"},{match:"cleanser",icon:e.jsx(Qe,{size:30,className:"text-[#4A7C59]"}),from:"#D9EEDD",to:"#B8DCC0"},{match:"mask",icon:e.jsx(Qe,{size:30,className:"text-[#4A7C59]"}),from:"#D9EEDD",to:"#B8DCC0"},{match:"exfoliant",icon:e.jsx(Qe,{size:30,className:"text-[#4A7C59]"}),from:"#D9EEDD",to:"#B8DCC0"},{match:"scrub",icon:e.jsx(Qe,{size:30,className:"text-[#4A7C59]"}),from:"#D9EEDD",to:"#B8DCC0"},{match:"eye",icon:e.jsx(ms,{size:30,className:"text-[#4A1D5E]"}),from:"#E6DAF0",to:"#CDB8E0"},{match:"moisturizer",icon:e.jsx(On,{size:30,className:"text-[#2F5D43]"}),from:"#DCEFE0",to:"#BCDCC4"},{match:"cream",icon:e.jsx(On,{size:30,className:"text-[#2F5D43]"}),from:"#DCEFE0",to:"#BCDCC4"},{match:"sunscreen",icon:e.jsx(Sd,{size:30,className:"text-[#EA580C]"}),from:"#FEF0D9",to:"#FBD9A8"},{match:"body",icon:e.jsx(tf,{size:30,className:"text-[#2F5D43]"}),from:"#DCEFE0",to:"#BCDCC4"},{match:"kit",icon:e.jsx(_d,{size:30,className:"text-[#800020]"}),from:"#F0E4CC",to:"#E0CDA0"},{match:"shav",icon:e.jsx(Ss,{size:30,className:"text-[#334155]"}
1287),from:"#E2E8F0",to:"#C5CDD8"}],Nre=t=>{const s=(t||"").toLowerCase(),n=wre.find(a=>s.includes(a.match));return n||{match:"",icon:e.jsx(Io,{size:30,className:"text-[#C5A059]"}),from:"#F0E4CC",to:"#E0CDA0"}},_re=({productType:t,iconScale:s=1})=>{const n=Nre(t);return e.jsx("div",{className:"w-full h-full flex items-center justify-center",style:{background:`linear-gradient(135deg, ${n.from} 0%, ${n.to} 100%)`},"aria-hidden":"true",children:e.jsx("div",{style:{transform:`scale(${s})`},children:n.icon})})},kre=()=>{const{handle:t}=Wo(),[s,n]=d.useState(null),[a,r]=d.useState([]),[i,o]=d.useState(!0),[l,c]=d.useState(!1),[u,p]=d.useState(null),[m,x]=d.useState(()=>IE()),[h,y]=d.useState(null);d.useEffect(()=>{localStorage.setItem(uN,JSON.stringify(m))},[m]),d.useEffect(()=>{const j=S=>{S.key===uN&&x(IE())};return window.addEventListener("storage",j),()=>window.removeEventListener("storage",j)},[]);const v=m.reduce((j,S)=>j+S.quantity,0),g=j=>{var w;const S={product_id:j.id,quantity:1,name:j.name,sku:j.sku||j.handle,price:j.price,image:(w=j.images)==null?void 0:w[0]};x(_=>{const C=`${S.product_id}-base`,E=_.findIndex(P=>`${P.product_id}-${P.variant_id||"base"}`===C);return E>=0?_.map((P,F)=>F===E?{...P,quantity:P.quantity+1}:P):[..._,S]}),y(j.id),setTimeout(()=>y(_=>_===j.id?null:_),1800)},N=j=>m.some(S=>S.product_id===j);d.useEffect(()=>{let j=!1;return(async()=>{if(t){o(!0),c(!1),p(null),n(null),r([]);try{const{data:w,error:_}=await O.from("ecom_collections").select("*").eq("handle",t).maybeSingle();if(_)throw _;if(w){if(j)return;n(w);const{data:E}=await O.from("ecom_product_collections").select("product_id, position").eq("collection_id",w.id).order("position"),P=(E||[]).map(L=>L.product_id);if(P.length===0){j||(r([]),o(!1));return}const{data:F}=await O.from("ecom_products").select("*").in("id",P).eq("status","active"),I=F||[];if(I.length>0){const L=$E(I),B=P.map(A=>I.find(z=>z.id===A)).filter(Boolean).map(A=>({...A,images:zE(A.images,L)}));j||(r(B),o(!1));return}const D=b(t);j||(r(D),o(!1));return}const C=q2.find(E=>E.handle===t);if(C){const E=b(t);j||(n(C),r(E),o(!1));return}j||(c(!0),o(!1))}catch(w){console.error("CollectionPage fetch error:",w),j||(p((w==null?void 0:w.message)||"Unable to load this collection right now."),o(!1))}}})(),()=>{j=!0}},[t]),d.useEffect(()=>{if(!s)return;const j=(s.description||"").replace(/\s+/g," ").trim();return qa({title:`${s.title} | Zorganics Cosmetics â Shop the Collection`,description:j||wr.description}),()=>qa(wr)},[s]),d.useEffect(()=>{if(s)return Qn("collection",GQ({title:s.title,handle:s.handle,description:s.description,products:a.map(j=>{var S;return{name:j.name,handle:j.handle,priceCents:j.price,image:((S=j.images)==null?void 0:S[0])||null}})})),Qn("breadcrumb",ip([{name:"Zorganics Cosmetics â Shop",path:"/"},{name:s.title,path:`/collections/${s.handle}`}])),()=>{Jn("collection"),Jn("breadcrumb")}},[s,a]);const b=j=>{const S=q2.find(P=>P.handle===j);if(!S)return[];const w=jY[S.id]||[];
1287if(w.length===0)return[];const _=Eh,C=w.map(P=>_.find(F=>F.id===P)).filter(Boolean),E=$E(C);return C.map(P=>({...P,images:zE(P.images,E)}))},f=d.useMemo(()=>{const j=s==null?void 0:s.image_url;return j&&J8(j)?j:null},[s]);return i?e.jsxs("div",{className:"min-h-screen flex flex-col items-center justify-center bg-[#FAF6EE]",children:[e.jsx(de,{size:40,className:"text-[#C5A059] animate-spin mb-4"}),e.jsx("p",{className:"text-gray-500 font-medium",children:"Loading collectionâ¦"})]}):l?e.jsxs("div",{className:"min-h-screen flex flex-col items-center justify-center bg-[#FAF6EE] px-6 text-center",children:[e.jsx(Io,{size:48,className:"text-[#C5A059] mb-4"}),e.jsx("h1",{className:"font-display text-2xl font-bold mb-2",style:{color:"#800020"},children:"Collection not found"}),e.jsxs("p",{className:"text-gray-500 max-w-md mb-6 text-sm",children:["We couldn't find a collection at ",e.jsxs("span",{className:"font-mono",children:["/collections/",t]}),". It may have been renamed or is not yet published."]}),e.jsxs(be,{to:"/",className:"inline-flex items-center gap-2 px-5 py-3 rounded-xl text-sm font-bold text-white shadow-md hover:opacity-90 transition-all",style:{background:"linear-gradient(135deg, #800020, #600018)"},children:[e.jsx(Je,{size:16})," Back to Zorganics"]})]}):u?e.jsxs("div",{className:"min-h-screen flex flex-col items-center justify-center bg-[#FAF6EE] px-6 text-center",children:[e.jsx(ve,{size:44,className:"text-red-500 mb-4"}),e.jsx("h1",{className:"font-display text-xl font-bold mb-2 text-red-900",children:"Couldn't load this collection"}),e.jsx("p",{className:"text-gray-500 max-w-md mb-6 text-sm",children:u}),e.jsxs(be,{to:"/",className:"inline-flex items-center gap-2 px-5 py-3 rounded-xl text-sm font-bold text-white shadow-md hover:opacity-90 transition-all",style:{background:"linear-gradient(135deg, #800020, #600018)"},children:[e.jsx(Je,{size:16})," Back to Zorganics"]})]}):e.jsxs("div",{className:"min-h-screen bg-[#FAF6EE]",children:[e.jsxs("header",{className:"relative overflow-hidden",children:[e.jsxs("div",{className:"absolute inset-0",children:[f?e.jsx("img",{src:f,alt:s==null?void 0:s.title,className:"w-full h-full object-cover"}):e.jsx("div",{className:"w-full h-full",style:{background:"linear-gradient(135deg, #4A0010, #800020)"}}),e.jsx("div",{className:"absolute inset-0",style:{background:"linear-gradient(135deg, rgba(74,0,16,0.93) 0%, rgba(96,0,24,0.88) 50%, rgba(128,0,32,0.80) 100%)"}})]}),e.jsxs("div",{className:"relative max-w-6xl mx-auto px-6 py-12 lg:py-16 text-white",children:[e.jsxs("div",{className:"flex items-center justify-between gap-3 mb-5",children:[e.jsxs(be,{to:"/",className:"inline-flex items-center gap-2 text-[12px] font-semibold text-white/80 hover:text-white transition-colors",children:[e.jsx(Je,{size:14})," Zorganics Cosmetics"]}),e.jsxs(be,{to:"/",className:"relative inline-flex items-center gap-2 px-4 py-2 rounded-xl text-sm font-bold shadow-lg hover:shadow-xl transition-all backdrop-blur",style:{background:"rgba(197, 160, 89, 0.95)",color:"#4A0010"},"aria-label":`View cart (${v} ${v===1?"item":"items"})`,children:[e.jsx(m2,{size:16})," Cart",v>0&&e.jsx("span",{className:"absolute -top-2 -right-2 min-w-[1.4rem] h-6 px-1.5 text-[11px] font-bold rounded-full flex items-center justify-center text-white shadow-md",style:{backgroundColor:"#800020"},children:v})]})]}),e.jsxs("div",{className:"flex items-center gap-2 mb-3 flex-wrap",children:[e.jsx("div",{className:"w-1 h-5 rounded-full",style:{backgroundColor:"#C5A059"}}),e.jsx("span",{className:"text-[11px] font-semibold uppercase tracking-[0.18em]",style:{color:"#E6D2A0"},children:"Collection"}),e.jsxs("span",{className:"inline-flex items-center gap-1 px-2 py-0.5 bg-white/10 backdrop-blur text-[10px] font-semibold rounded-full border border-white/20",children:[e.jsx(On,{size:10,className:"text-emerald-300"})," 100% Vegan"]}),e.jsxs("span",{className:"inline-flex items-center gap-1 px-2 py-0.5 bg-white/10 backdrop-blur text-[10px] font-semibold rounded-full border border-white/20",children:[e.jsx(Tt,{size:10,className:"text-amber-200"})," Certified Organic"]}),e.jsxs("span",{className:"inline-flex items-center gap-1 px-2 py-0.5 bg-white/10 backdrop-blur text-[10px] font-semibold rounded-full border border-white/20",children:[e.jsx(xt,{size:10,
1287className:"text-blue-200"})," Non-Toxic"]})]}),e.jsx("h1",{className:"font-display text-3xl lg:text-5xl font-bold leading-tight max-w-3xl",style:{background:"linear-gradient(180deg, #FFFFFF 0%, #F5E9CC 60%, #C5A059 100%)",WebkitBackgroundClip:"text",WebkitTextFillColor:"transparent",backgroundClip:"text"},children:s==null?void 0:s.title}),(s==null?void 0:s.description)&&e.jsx("p",{className:"text-white/85 mt-4 text-sm lg:text-base leading-relaxed max-w-2xl",children:s.description}),e.jsxs("div",{className:"flex items-center gap-3 mt-5 text-[12px] text-white/75",children:[e.jsx(Io,{size:14,style:{color:"#C5A059"}}),e.jsxs("span",{children:[a.length," ",a.length===1?"formulation":"formulations"]})]})]})]}),e.jsx("main",{className:"max-w-6xl mx-auto px-6 py-10",children:a.length===0?e.jsxs("div",{className:"text-center py-20",children:[e.jsx(Yl,{size:48,className:"text-gray-300 mx-auto mb-4"}),e.jsx("p",{className:"text-gray-500 font-medium mb-1",children:"No products in this collection yet."}),e.jsx("p",{className:"text-gray-400 text-sm mb-6",children:"Check back soon â new formulations are added regularly."}),e.jsxs(be,{to:"/",className:"inline-flex items-center gap-2 px-5 py-3 rounded-xl text-sm font-bold text-white shadow-md hover:opacity-90 transition-all",style:{background:"linear-gradient(135deg, #800020, #600018)"},children:["Browse the full shop ",e.jsx(Vt,{size:15})]})]}):e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-6",children:a.map(j=>{var _,C;const S=(_=j.images)==null?void 0:_[0],w=((C=j.metadata)==null?void 0:C.certifications)||[];return e.jsxs("div",{className:"group bg-white rounded-2xl border border-gray-100 overflow-hidden hover:shadow-xl hover:border-[#C5A059]/30 transition-all",children:[e.jsx(be,{to:`/products/${j.handle}`,className:"relative h-56 bg-gradient-to-br from-gray-50 to-gray-100 overflow-hidden block",children:S?e.jsx("img",{src:S,alt:j.name,className:"w-full h-full object-cover group-hover:scale-105 transition-transform duration-500",onError:E=>{E.currentTarget.style.display="none"}}):e.jsx(_re,{productType:j.product_type,iconScale:1.2})}),e.jsxs("div",{className:"p-4",children:[j.product_type&&e.jsx("p",{className:"text-[10px] font-bold uppercase tracking-wider mb-1",style:{color:"#800020"},children:j.product_type}),e.jsx(be,{to:`/products/${j.handle}`,className:"block",children:e.jsx("h3",{className:"font-bold mb-1 line-clamp-1 hover:text-[#800020] transition-colors",style:{color:"#3B0A11"},children:j.name})}),e.jsx("p",{className:"text-xs text-gray-500 line-clamp-2 mb-3 min-h-[2rem]",children:j.description}),w.length>0&&e.jsxs("div",{className:"flex flex-wrap gap-1 mb-3",children:[w.includes("100% Vegan")&&e.jsxs("span",{className:"inline-flex items-center gap-1 font-bold rounded-full border px-1.5 py-0.5 text-[9px] bg-green-50 text-green-700 border-green-200",children:[e.jsx(On,{size:8})," Vegan"]}),w.includes("Certified Organic")&&e.jsxs("span",{className:"inline-flex items-center gap-1 font-bold rounded-full border px-1.5 py-0.5 text-[9px] bg-emerald-50 text-emerald-700 border-emerald-200",children:[e.jsx(Tt,{size:8})," Organic"]})]}),e.jsxs("div",{className:"flex items-end justify-between",children:[e.jsxs("div",{children:[e.jsxs("p",{className:"text-lg font-bold text-gray-900",children:["$",(j.price/100).toFixed(2)]}),j.sku&&e.jsxs("p",{className:"text-[10px] text-gray-400 font-mono",children:["SKU: ",j.sku]})]}),e.jsx("button",{type:"button",onClick:()=>g(j),className:`flex items-center gap-1.5 px-3.5 py-2 rounded-lg text-xs font-bold transition-all shadow-md ${h===j.id?"bg-emerald-500 text-white":N(j.id)?"bg-emerald-50 text-emerald-700 border border-emerald-200":"text-white hover:opacity-90"}`,style:h===j.id||N(j.id)?void 0:{backgroundColor:"#C5A059"},children:h===j.id?e.jsxs(e.Fragment,{children:[e.jsx(xt,{size:13})," Added"]}):N(j.id)?e.jsxs(e.Fragment,{children:[e.jsx(xt,{size:13})," In Cart"]}):e.jsxs(e.Fragment,{children:[e.jsx(tn,{size:13})," Add to Cart"]})})]})]})]},j.id)})}),e.jsx("div",{className:"mt-12 text-center",children:e.jsxs(be,{to:"/",className:"inline-flex items-center gap-2 px-6 py-3 rounded-xl text-sm font-bold text-white shadow-md hover:opacity-90 transition-all",style:{background:"linear-gradient(135deg, #800020, #600018)"},children:[e.jsx(Je,{size:15})," Continue shopping the full Zorganics catalog"]})})]})})]})},X8="ecom_review_reported_ids",Sre=()=>{if(typeof window>"u")return new Set;try{const t=localStorage.getItem(X8);if(!t)return new Set;const s=JSON.parse(t);return Array.isArray(s)?new Set(s.filter(n=>typeof n=="string")):new Set}catch{return new Set}},pj=t=>{if(!(typeof window>"u"))try{localStorage.setItem(X8,JSON.stringify(Array.from(t)))}catch{}},LE=[{value:"spam",label:"Spam",description:"Repetitive, promotional, or unrelated content."},{value:"inappropriate",label:"Inappropriate",description:"Offensive language, harassment, or unsafe medical claims."},{value:"off-topic",label:"Off-Topic",description:"Doesn't actually review this product."},{value:"fake",label:"Fake",description:"Looks fabricated, paid, or written without trying the product."},{value:"other",label:"Other",description:"Something else â tell us in the notes below."}],OE="ecom_review_voter_id",Cre=()=>{if(typeof window>"u")return"";try{let t=localStorage.getItem(OE);return t||(t=typeof crypto<"u"&&crypto.randomUUID?crypto.randomUUID():"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,s=>{const n=Math.random()*16|0;return(s==="x"?n:n&3|8).toString(16)}),localStorage.setItem(OE,t)),t}catch{return"anon-"+Math.random().toString(36).slice(2)}};async function cxe(){const{data:t,error:s}=await O.from("ecom_product_reviews").select("product_id, rating").eq("status","published");if(s||!t)return{};const n={};for(const r of t){const i=r.product_id,o=Number(r.rating)||0;n[i]||(n[i]={sum:0,count:0}),n[i].sum+=o,n[i].count+=1}const a={};for(const[r,i]of Object.entries(n))a[r]={avg:i.count>
12870?i.sum/i.count:0,count:i.count};return a}const ok=({value:t,size:s=12,showHalf:n=!0})=>e.jsx("div",{className:"inline-flex items-center gap-0.5",children:[1,2,3,4,5].map(a=>{const r=t>=a,i=n&&!r&&t>=a-.5;return e.jsx(zo,{size:s,strokeWidth:1.5,className:r||i?"text-[#C5A059]":"text-gray-300",fill:r?"#C5A059":i?"url(#halfGold)":"none"},a)})}),dxe=({summary:t})=>!t||t.count===0?e.jsxs("span",{className:"inline-flex items-center gap-1 text-[10px] text-gray-400 font-medium",children:[e.jsx(zo,{size:10,className:"text-gray-300"})," No reviews yet"]}):e.jsxs("span",{className:"inline-flex items-center gap-1.5 text-[11px] font-bold",title:`${t.avg.toFixed(1)} stars from ${t.count} review${t.count===1?"":"s"}`,children:[e.jsx(ok,{value:t.avg,size:11}),e.jsx("span",{style:{color:"#800020"},children:t.avg.toFixed(1)}),e.jsxs("span",{className:"text-gray-400 font-medium",children:["(",t.count,")"]})]}),Are=({value:t,onChange:s})=>{const[n,a]=d.useState(0);return e.jsx("div",{className:"inline-flex items-center gap-1",children:[1,2,3,4,5].map(r=>{const i=(n||t)>=r;return e.jsx("button",{type:"button",onMouseEnter:()=>a(r),onMouseLeave:()=>a(0),onClick:()=>s(r),className:"p-0.5 transition-transform hover:scale-110","aria-label":`${r} star${r===1?"":"s"}`,children:e.jsx(zo,{size:26,strokeWidth:1.5,className:i?"text-[#C5A059]":"text-gray-300",fill:i?"#C5A059":"none"})},r)})})},Ere=({productId:t,productName:s,onSubmitted:n,isAdmin:a=!1})=>{const[r,i]=d.useState([]),[o,l]=d.useState(!0),[c,u]=d.useState(!1),[p,m]=d.useState({}),[x,h]=d.useState(new Set),[y,v]=d.useState(new Set),[g,N]=d.useState(()=>Sre()),[b,f]=d.useState(null),[j,S]=d.useState("spam"),[w,_]=d.useState(""),[C,E]=d.useState(null),[P,F]=d.useState(null),[I,D]=d.useState("recent"),[L,V]=d.useState(0),[B,A]=d.useState(""),[z,M]=d.useState(""),[R,T]=d.useState(""),[U,q]=d.useState(""),[H,G]=d.useState(""),[W,X]=d.useState(""),[Q,K]=d.useState(!1),[se,Y]=d.useState(null),[J,te]=d.useState(!1),pe=d.useMemo(()=>Cre(),[]);d.useEffect(()=>{Fe()},[t]);const Fe=async()=>{l(!0);const{data:ge}=await O.from("ecom_product_reviews").select("*").eq("product_id",t).eq("status","published").order("created_at",{ascending:!1}),Ne=ge||[];i(Ne),Ne.length>0?(await ke(Ne.map(lt=>lt.id)),await Oe(Ne.map(lt=>lt.id))):(m({}),h(new Set)),l(!1)},ke=d.useCallback(async ge=>{if(ge.length===0)return;const{data:Ne,error:lt}=await O.from("ecom_review_votes").select("review_id, voter_fingerprint").in("review_id",ge);if(lt||!Ne){m({}),h(new Set);return}const mt={},ae=new Set;for(const qe of Ne)mt[qe.review_id]=(mt[qe.review_id]||0)+1,qe.voter_fingerprint===pe&&ae.add(qe.review_id);m(mt),h(ae)},[pe]),Oe=d.useCallback(async ge=>{if(!pe||ge.length===0)return;const{data:Ne}=await O.from("ecom_review_flags").select("review_id").eq("reporter_fingerprint",pe).in("review_id",ge),lt=new Set((Ne||[]).map(mt=>mt.review_id));N(mt=>{const ae=new Set([...mt,...lt]);return pj(ae),ae})},[pe]),ue=d.useCallback(async ge=>{if(x.has(ge)||y.has(ge)||!pe)return;v(mt=>{const ae=new Set(mt);return ae.add(ge),ae}),h(mt=>{const ae=new Set(mt);return ae.add(ge),ae}),m(mt=>({...mt,[ge]:(mt[ge]||0)+1}));const{data:Ne,error:lt}=await O.functions.invoke("cosmetics-secure-reads",{body:{action:"vote_review",review_id:ge,fingerprint:pe}});v(mt=>{const ae=new Set(mt);return ae.delete(ge),ae}),(lt||Ne!=null&&Ne.error)&&(console.warn("Helpful vote failed:",lt||(Ne==null?void 0:Ne.error)),h(mt=>{const ae=new Set(mt);return ae.delete(ge),ae}),m(mt=>{const ae={...mt},qe=ae[ge]||0;return qe<=1?delete ae[ge]:ae[ge]=qe-1,ae}))},[pe,x,y]),je=d.useCallback(ge=>{F(null),f(Ne=>Ne===ge?null:ge),S("spam"),_("")},[]),le=d.useCallback(()=>{f(null),F(null),S("spam"),_("")},[]),ye=d.useCallback(async ge=>{if(!pe){F("Could not generate a browser id. Please refresh and try again.");return}if(g.has(ge)){le();return}if(C)return;if(j==="other"&&w.trim().length<4){F("Please add a short note explaining why you're reporting this review.");return}if(w.length>500){F("Notes must be under 500 characters.");return}E(ge),F(null),N(mt=>{const ae=new Set(mt);return ae.add(ge),pj(ae),ae});const{data:Ne,error:lt}=await O.functions.invoke("cosmetics-secure-reads",{body:{action:"flag_review",review_id:ge,fingerprint:pe,reason:j,notes:w.trim()||null}});if(E(null),lt){if((lt==null?void 0:lt.code)==="23505"){le();return}N(ae=>{const qe=new Set(ae);return qe.delete(ge),pj(qe),qe}),F(lt.message||"Could not submit your report. Please try again.");return}le()},[pe,g,C,j,w,le]),we=d.useMemo(()=>r.length===0?{avg:0,count:0}:{avg:r.reduce((Ne,lt)=>Ne+(Number(lt.rating)||0),0)/r.length,count:r.length},[r]),He=d.useMemo(()=>{const ge=[0,0,0,0,0];for(const Ne of r){const lt=Math.max(1,Math.min(5,Math.round(Number(Ne.rating)||0)));ge[5-lt]+=1}return ge},[r]),Lt=d.useMemo(()=>I==="helpful"?[...r].sort((ge,Ne)=>{const lt=p[ge.id]||0,mt=p[Ne.id]||0;return mt!==lt?mt-lt:new Date(Ne.created_at).getTime()-new Date(ge.created_at).getTime()}):r,[r,p,I]),ut=async()=>
1287{if(Y(null),L<1||L>5){Y("Please select a 1â5 star rating.");return}if(!z.trim()||z.trim().length<8){Y("Please share a few sentences about your experience (minimum 8 characters).");return}if(!U.trim()||!/^\S+@\S+\.\S+$/.test(U.trim())){Y("Please enter a valid email so we can verify your purchase.");return}K(!0);try{const{data:ge,error:Ne}=await O.functions.invoke("cosmetics-secure-reads",{body:{action:"submit_review",product_id:t,reviewer_email:U.trim().toLowerCase(),reviewer_name:R.trim()||null,rating:L,title:B.trim()||null,body:z.trim()}});if(Ne||ge!=null&&ge.error)throw new Error((ge==null?void 0:ge.error)||(Ne==null?void 0:Ne.message)||"submit_failed");te(!0),V(0),A(""),M(""),T(""),q(""),G(""),X(""),await Fe(),n&&n(),setTimeout(()=>{u(!1),te(!1)},2500)}catch(ge){console.error("Review submit error:",ge),Y((ge==null?void 0:ge.message)||"Something went wrong. Please try again.")}finally{K(!1)}};return e.jsxs("div",{className:"border-t border-gray-100 pt-5 mt-5",children:[e.jsxs("div",{className:"flex items-center justify-between mb-4 gap-3 flex-wrap",children:[e.jsxs("div",{children:[e.jsxs("h4",{className:"text-sm font-bold uppercase tracking-wider flex items-center gap-1.5",style:{color:"#800020"},children:[e.jsx(jr,{size:14})," Customer Reviews & Clinical Results"]}),e.jsx("p",{className:"text-[11px] text-gray-500 mt-0.5",children:"Real outcomes from verified customers â including before/after photos."})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[r.length>0&&a&&e.jsxs("div",{className:"inline-flex items-center gap-1.5 px-2.5 py-1.5 rounded-lg border border-gray-200 bg-white",children:[e.jsx(pO,{size:12,className:"text-gray-400"}),e.jsx("label",{className:"text-[10px] font-bold uppercase tracking-wider text-gray-500",htmlFor:"review-sort",children:"Sort"}),e.jsxs("select",{id:"review-sort",value:I,onChange:ge=>D(ge.target.value),className:"text-xs font-semibold bg-transparent focus:outline-none cursor-pointer",style:{color:"#800020"},children:[e.jsx("option",{value:"recent",children:"Most Recent"}),e.jsx("option",{value:"helpful",children:"Most Helpful"})]})]}),!c&&e.jsxs("button",{type:"button",onClick:()=>{u(!0),te(!1)},className:"px-3 py-2 rounded-lg text-xs font-bold uppercase tracking-wider text-white shadow-sm hover:opacity-90 transition-all flex items-center gap-1.5",style:{backgroundColor:"#800020"},children:[e.jsx(Qe,{size:12})," Write a Review"]})]})]}),e.jsxs("div",{className:"grid sm:grid-cols-[auto_1fr] gap-5 mb-5 p-4 rounded-xl bg-gradient-to-br from-[#FAF6EE] to-white border border-[#C5A059]/20",children:[e.jsxs("div",{className:"text-center sm:border-r sm:border-[#C5A059]/20 sm:pr-5",children:[e.jsx("p",{className:"text-3xl font-bold",style:{color:"#800020"},children:we.count>0?we.avg.toFixed(1):"â"}),e.jsx(ok,{value:we.avg,size:14}),e.jsx("p",{className:"text-[10px] text-gray-500 mt-1",children:we.count===0?"No reviews yet":`${we.count} review${we.count===1?"":"s"}`})]}),e.jsx("div",{className:"space-y-1",children:He.map((ge,Ne)=>{const lt=5-Ne,mt=we.count>0?ge/we.count*100:0;return e.jsxs("div",{className:"flex items-center gap-2 text-[11px]",children:[e.jsxs("span",{className:"w-8 text-gray-600 font-medium tabular-nums",children:[lt,"â
1287
"]}),e.jsx("div",{className:"flex-1 h-1.5 bg-gray-100 rounded-full overflow-hidden",children:e.jsx("div",{className:"h-full rounded-full transition-all",style:{width:`${mt}%`,background:"linear-gradient(90deg, #C5A059 0%, #800020 100%)"}})}),e.jsx("span",{className:"w-8 text-right text-gray-500 tabular-nums",children:ge})]},lt)})})]}),c&&e.jsxs("div",{className:"mb-5 p-4 rounded-xl border-2 border-[#C5A059]/30 bg-white shadow-sm",children:[e.jsxs("div",{className:"flex items-center justify-between mb-3",children:[e.jsxs("p",{className:"text-xs font-bold uppercase tracking-wider",style:{color:"#800020"},children:["Share your experience with ",s]}),e.jsx("button",{onClick:()=>u(!1),className:"p-1 hover:bg-gray-100 rounded",children:e.jsx(Ke,{size:14,className:"text-gray-400"})})]}),J?e.jsxs("div",{className:"flex items-center gap-2 p-3 rounded-lg bg-emerald-50 border border-emerald-200 text-emerald-700",children:[e.jsx(xt,{size:16}),e.jsx("p",{className:"text-sm font-semibold",children:"Thanks! Your review was published."})]}):e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-[10px] font-bold uppercase tracking-wider text-gray-600 mb-1",children:"Your Rating *"}),e.jsx(Are,{value:L,onChange:V})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-[10px] font-bold uppercase tracking-wider text-gray-600 mb-1",children:"Name (optional)"}),e.jsx("input",{type:"text",value:R,onChange:ge=>T(ge.target.value),placeholder:"Jane D.",maxLength:60,className:"w-full px-2.5 py-1.5 text-sm border border-gray-200 rounded-lg focus:outline-none focus:ring-2 focus:ring-[#C5A059]/30"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-[10px] font-bold uppercase tracking-wider text-gray-600 mb-1",children:"Email *"}),e.jsx("input",{type:"email",value:U,onChange:ge=>q(ge.target.value),placeholder:"for purchase verification",className:"w-full px-2.5 py-1.5 text-sm border border-gray-200 rounded-lg focus:outline-none focus:ring-2 focus:ring-[#C5A059]/30"})]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-[10px] font-bold uppercase tracking-wider text-gray-600 mb-1",children:"Headline (optional)"}),e.jsx("input",{type:"text",value:B,onChange:ge=>A(ge.target.value),placeholder:"e.g. Skin recovered in 3 days post-RF",maxLength:120,className:"w-full px-2.5 py-1.5 text-sm border border-gray-200 rounded-lg focus:outline-none focus:ring-2 focus:ring-[#C5A059]/30"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-[10px] font-bold uppercase tracking-wider text-gray-600 mb-1",children:"Your Review *"}),e.jsx("textarea",{value:z,onChange:ge=>M(ge.target.value),placeholder:"What were your clinical results? How did your skin feel?",rows:4,maxLength:2e3,className:"w-full px-2.5 py-1.5 text-sm border border-gray-200 rounded-lg focus:outline-none focus:ring-2 focus:ring-[#C5A059]/30 resize-none"}),e.jsxs("p",{className:"text-[10px] text-gray-400 mt-0.5",children:[z.length,"/2000 characters"]})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[e.jsxs("div",{children:[e.jsxs("label",{className:"block text-[10px] font-bold uppercase tracking-wider text-gray-600 mb-1 flex items-center gap-1",children:[e.jsx(rx,{size:10})," Before image URL"]}),e.jsx("input",{type:"url",value:H,onChange:ge=>G(ge.target.value),placeholder:"https://...",className:"w-full px-2.5 py-1.5 text-sm border border-gray-200 rounded-lg focus:outline-none focus:ring-2 focus:ring-[#C5A059]/30"})]}),e.jsxs("div",{children:[e.jsxs("label",{className:"block text-[10px] font-bold uppercase tracking-wider text-gray-600 mb-1 flex items-center gap-1",children:[e.jsx(rx,{size:10})," After image URL"]}),e.jsx("input",{type:"url",value:W,onChange:ge=>X(ge.target.value),placeholder:"https://...",className:"w-full px-2.5 py-1.5 text-sm border border-gray-200 rounded-lg focus:outline-none focus:ring-2 focus:ring-[#C5A059]/30"})]})]}),se&&e.jsxs("div",{className:"flex items-start gap-1.5 p-2 rounded-md bg-red-50 border border-red-200",children:[e.jsx(ve,{size:12,className:"text-red-500 shrink-0 mt-0.5"}),e.jsx("p",{className:"text-[11px] text-red-700",children:se})]}),e.jsxs("div",{className:"flex items-center justify-between gap-3 pt-1",children:[e.jsxs("p",{className:"text-[10px] text-gray-500 leading-snug",children:["We'll auto-verify against your purchase history.",e.jsx("br",{}),e.jsx("span",{className:"font-semibold",children:"Verified Purchase"})," badges build trust."]}),e.jsxs("button",{type:"button",onClick:ut,disabled:Q,className:"px-4 py-2 rounded-lg text-xs font-bold uppercase tracking-wider text-white shadow-sm hover:opacity-90 transition-all flex items-center gap-1.5 disabled:opacity-50 disabled:cursor-not-allowed shrink-0",style:{backgroundColor:"#800020"},children:[Q?e.jsx(de,{size:12,className:"animate-spin"}):e.jsx(xt,{size:12}),"Submit Review"]})]})]})]}),o?e.jsx("div",{className:"flex items-center justify-center py-8 text-gray-400",children:e.jsx(de,{size:18,className:"animate-spin"})}):r.length===0?e.jsxs("div",{className:"text-center py-8 px-4 roun
1287ded-xl bg-gray-50 border border-dashed border-gray-200",children:[e.jsx(jr,{size:28,className:"mx-auto text-gray-300 mb-2"}),e.jsx("p",{className:"text-sm font-semibold text-gray-600",children:"No reviews yet"}),e.jsx("p",{className:"text-xs text-gray-400 mt-1",children:"Be the first to share your clinical results."})]}):e.jsx("div",{className:"space-y-4",children:Lt.map(ge=>e.jsx(Fre,{review:ge,helpfulCount:p[ge.id]||0,hasVoted:x.has(ge.id),isVoting:y.has(ge.id),onVote:()=>ue(ge.id),isReported:g.has(ge.id),isReportMenuOpen:b===ge.id,reportReason:j,reportNotes:w,reportSubmitting:C===ge.id,reportError:b===ge.id?P:null,onOpenReport:()=>je(ge.id),onCloseReport:le,onChangeReason:S,onChangeNotes:_,onSubmitReport:()=>ye(ge.id)},ge.id))})]})},Fre=({review:t,helpfulCount:s,hasVoted:n,isVoting:a,onVote:r,isReported:i,isReportMenuOpen:o,reportReason:l,reportNotes:c,reportSubmitting:u,reportError:p,onOpenReport:m,onCloseReport:x,onChangeReason:h,onChangeNotes:y,onSubmitReport:v})=>{const N=new Date(t.created_at).toLocaleDateString("en-US",{year:"numeric",month:"short",day:"numeric"}),b=(t.reviewer_name||t.reviewer_email||"?").trim().charAt(0).toUpperCase(),f=!!(t.before_image_url||t.after_image_url),j=LE.find(S=>S.value===l);return e.jsxs("div",{className:`p-4 rounded-xl border transition-all ${i?"border-amber-200 bg-amber-50/40":"border-gray-100 hover:border-[#C5A059]/30 hover:shadow-sm bg-white"}`,children:[e.jsxs("div",{className:"flex items-start gap-3 mb-2",children:[e.jsx("div",{className:"w-9 h-9 rounded-full flex items-center justify-center text-sm font-bold shrink-0",style:{backgroundColor:"#800020",color:"#E6D2A0"},children:b}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[e.jsx("p",{className:"text-sm font-bold truncate",style:{color:"#3B0A11"},children:t.reviewer_name||"Anonymous"}),t.verified_purchase&&e.jsxs("span",{className:"inline-flex items-center gap-1 px-1.5 py-0.5 rounded-full text-[9px] font-bold border",style:{backgroundColor:"#ECFDF5",color:"#047857",borderColor:"#A7F3D0"},title:"This reviewer purchased this product",children:[e.jsx(Ie,{size:9})," Verified Purchase"]})]}),e.jsxs("div",{className:"flex items-center gap-2 mt-0.5",children:[e.jsx(ok,{value:Number(t.rating),size:11}),e.jsxs("span",{className:"text-[10px] text-gray-400",children:["· ",N]})]})]})]}),i?e.jsxs("div",{className:"mt-2 mb-1 p-3 rounded-lg border-2 border-dashed border-amber-300 bg-amber-50/70 flex items-start gap-2.5",children:[e.jsx("div",{className:"w-7 h-7 rounded-full flex items-center justify-center shrink-0 bg-amber-100",children:e.jsx(yp,{size:13,className:"text-amber-700"})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"text-[11px] font-bold uppercase tracking-wider text-amber-800 flex items-center gap-1.5",children:"Reported â under review"}),e.jsx("p",{className:"text-[11px] text-amber-700 leading-snug mt-0.5",children:"You reported this review. Our moderation team will review it shortly. The content is hidden on this browser only."})]})]}):e.jsxs(e.Fragment,{children:[t.title&&e.jsx("p",{className:"text-sm font-bold mb-1",style:{color:"#3B0A11"},children:t.title}),t.body&&e.jsx("p",{className:"text-sm text-gray-600 leading-relaxed whitespace-pre-line",children:t.body}),f&&e.jsxs("div",{className:"mt-3 grid grid-cols-2 gap-2",children:[t.before_image_url&&e.jsxs("figure",{className:"relative rounded-lg overflow-hidden border border-gray-200 bg-gray-50",children:[e.jsx("img",{src:t.before_image_url,alt:"Before",className:"w-full aspect-square object-cover",onError:S=>{S.currentTarget.style.display="none"}}),e.jsx("figcaption",{className:"absolute top-1.5 left-1.5 px-1.5 py-0.5 rounded-full text-[9px] font-bold uppercase tracking-wider backdrop-blur",style:{backgroundColor:"rgba(255,255,255,0.92)",color:"#800020"},children:"Before"})]}),t.after_image_url&&e.jsxs("figure",{className:"relative rounded-lg overflow-hidden border border-gray-200 bg-gray-50",children:[e.jsx("img",{src:t.after_image_url,alt:"After",className:"w-full aspect-square object-cover",onError:S=>{S.currentTarget.style.display="none"}}),e.jsx("figcaption",{className:"absolute top-1.5 left-1.5 px-1.5 py-0.5 rounded-full text-[9px] font-bold uppercase tracking-wider backdrop-blur",style:{backgroundColor:"rgba(197,160,89,0.95)",color:"#4A0010"},children:"After"})]})]})]}),e.jsxs("div",{className:"mt-3 pt-3 border-t border-gray-100 flex items-center justify-between gap-3 flex-wrap",children:[e.jsxs("div",{className:"flex items-center gap-3 flex-wrap",children:[e.jsx("p",{className:"text-[10px] text-gray-400 font-medium uppercase tracking-wider",children:"Was this helpful?"}),i?e.jsxs("span",{className:"inline-flex items-center gap-1 px-2 py-0.5 rounded-full text-[10px] font-bold border",style:{backgroundColor:"#FEF3C7",color:"#92400E",borderColor:"#FDE68A"},children:[e.jsx(yp,{size:9})," Reported â under review"]}):e.jsxs("button",{type:"button",onClick:m,disabled:u,"aria-expanded":o,"aria-haspopup":"menu",className:`inline-flex items-center gap-1 text-[10px] font-semibold uppercase tracking-wider transition-all ${o?"text-[#800020]":"text-gray-400 hover:text-[#800020]"}`,title:"Flag this review as spam, inappropriate, or fake",children:[e.jsx(yp,{size:10}
1287),"Report this review",e.jsx(Gt,{size:10,className:`transition-transform ${o?"rotate-180":""}`})]})]}),e.jsxs("button",{type:"button",onClick:r,disabled:n||a,"aria-pressed":n,"aria-label":n?`You marked this review helpful â ${s} total`:`Mark this review helpful â ${s} so far`,className:`inline-flex items-center gap-1.5 px-2.5 py-1 rounded-full text-[11px] font-bold border transition-all ${n?"cursor-default":"hover:-translate-y-0.5 hover:shadow-sm cursor-pointer"} ${a?"opacity-60":""}`,style:n?{backgroundColor:"#800020",borderColor:"#800020",color:"#E6D2A0"}:{backgroundColor:"#FFFFFF",borderColor:"#E5E7EB",color:"#4B5563"},children:[a?e.jsx(de,{size:11,className:"animate-spin"}):e.jsx(YO,{size:11,fill:n?"#E6D2A0":"none",strokeWidth:n?2.2:1.8}),e.jsx("span",{children:"Helpful"}),e.jsx("span",{className:"tabular-nums px-1 rounded text-[10px] font-bold",style:n?{backgroundColor:"rgba(230,210,160,0.25)",color:"#E6D2A0"}:{backgroundColor:"#F3F4F6",color:"#6B7280"},children:s})]})]}),o&&!i&&e.jsxs("div",{className:"mt-3 p-3 rounded-xl border-2 border-amber-200 bg-amber-50/40 animate-in fade-in slide-in-from-top-2 duration-200",children:[e.jsxs("div",{className:"flex items-center justify-between mb-2.5",children:[e.jsxs("p",{className:"text-[10px] font-bold uppercase tracking-wider text-amber-900 flex items-center gap-1.5",children:[e.jsx(yp,{size:11})," Why are you reporting this?"]}),e.jsx("button",{type:"button",onClick:x,className:"p-1 hover:bg-amber-100 rounded text-amber-700","aria-label":"Close report menu",children:e.jsx(Ke,{size:12})})]}),e.jsx("div",{className:"grid grid-cols-2 sm:grid-cols-3 gap-1.5 mb-2.5",children:LE.map(S=>{const w=l===S.value;return e.jsx("button",{type:"button",onClick:()=>h(S.value),className:`px-2.5 py-1.5 rounded-lg text-[11px] font-bold uppercase tracking-wider border transition-all ${w?"text-white shadow-sm":"bg-white text-gray-600 border-gray-200 hover:border-amber-300"}`,style:w?{backgroundColor:"#800020",borderColor:"#800020"}:{},children:S.label},S.value)})}),j&&e.jsx("p",{className:"text-[10px] text-amber-700 mb-2 leading-snug italic",children:j.description}),e.jsxs("label",{className:"block text-[10px] font-bold uppercase tracking-wider text-amber-900 mb-1",children:["Notes ",l==="other"?"*":e.jsx("span",{className:"text-amber-600 font-normal",children:"(optional)"})]}),e.jsx("textarea",{value:c,onChange:S=>y(S.target.value),placeholder:l==="other"?"Briefly describe what's wrong with this reviewâ¦":"Add anything our team should know (optional)",rows:2,maxLength:500,className:"w-full px-2.5 py-1.5 text-xs border border-amber-200 bg-white rounded-lg focus:outline-none focus:ring-2 focus:ring-amber-300 resize-none"}),e.jsxs("p",{className:"text-[10px] text-amber-600 mt-0.5 text-right tabular-nums",children:[c.length,"/500"]}),p&&e.jsxs("div",{className:"mt-2 flex items-start gap-1.5 p-2 rounded-md bg-red-50 border border-red-200",children:[e.jsx(ve,{size:12,className:"text-red-500 shrink-0 mt-0.5"}),e.jsx("p",{className:"text-[11px] text-red-700",children:p})]}),e.jsxs("div",{className:"mt-2.5 flex items-center justify-between gap-3",children:[e.jsx("p",{className:"text-[10px] text-amber-700 leading-snug",children:"Reports are anonymous and reviewed by our moderation team."}),e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("button",{type:"button",onClick:x,disabled:u,className:"px-3 py-1.5 rounded-lg text-[11px] font-bold uppercase tracking-wider border border-gray-200 bg-white text-gray-600 hover:bg-gray-50 transition-all disabled:opacity-50",children:"Cancel"}),e.jsxs("button",{type:"button",onClick:v,disabled:u,className:"inline-flex items-center gap-1.5 px-3 py-1.5 rounded-lg text-[11px] font-bold uppercase tracking-wider text-white shadow-sm hover:opacity-90 transition-all disabled:opacity-50 disabled:cursor-not-allowed",style:{backgroundColor:"#800020"},children:[u?e.jsx(de,{size:11,className:"animate-spin"}):e.jsx(yp,{size:11}),"Submit report"]})]})]})]})]})},Tre=({activeHandle:t,size:s="sm",showLabel:n=!1,className:a=""})=>{const r=s==="md"?30:22,i=W2.find(o=>o.handle===t);return e.jsxs("div",{className:a,children:[n&&e.jsxs("div",{className:"flex items-baseline gap-2 mb-2",children:[e.jsx("span",{className:"text-[11px] font-bold uppercase tracking-[0.14em]",style:{color:"#800020"},children:"Shade"}),e.jsx("span",{className:"text-xs font-semibold text-gray-700",children:i?i.name:"8 shades available"})]}),e.jsx("div",{className:"flex flex-wrap items-center gap-1.5",role:"list","aria-label":"Liquid Foundation shades",children:W2.map(o=>{const l=o.handle===t;return e.jsx(be,{to:`/products/${o.handle}`,role:"listitem",title:`${o.name} â view shade`,"aria-label":`${o.name} shade${l?" (current)":""}`,"aria-current":l?"true":void 0,onClick:c=>c.stopPropagation(),className:"group/swatch relative inline-flex items-center justify-center rounded-full transition-transform hover:scale-110 focus:outline-none focus-visible:ring-2 focus-visible:ring-[#C5A059]",style:{width:r,height:r,backgroundColor:o.hex,boxShadow:l?"0 0 0 2px #FFFFFF, 0 0 0 4px #800020":"inset 0 0 0 1px rgba(0,0,0,0.12)"},children:s==="md"&&e.jsx("span",{className:"pointer-events-none absolute -top-7 left-1/2 -translate-x-1/2 whitespace-nowrap rounded-md bg-gray-900 px-2 py-0.5 text-[10px] font-semibold text-white opacity-0 shadow-lg transition-opacity group-hover/swatch:opacity-100 z-10",children:o.name})},o.handle)})})]})},pN="ecom_cart",ME=()=>{try{const t=localStorage.getItem(pN);if(!t)return[];const s=JSON.parse(t);return Array.isArray(s)?s:[]}catch{return[]}},Pre=["wixstatic.com","zorganics.com","cloudfront.net","supabase"],Dre=t=>{if(!t||typeof t!="string")return!1;const s=t.toLowerCase();return Pre.some(n=>s.includes(n))},BE=t=>(Array.isArray(t)?t:[]).filter(Dre),Rre=[{match:"hair",icon:e.jsx(Ss,{size:48,className:"text-[#8B5A3C]"}),from:"#FBE5C8",to:"#E8C9A0"},{match:"shampoo",icon:e.jsx(Ss,{size:48,className:"text-[#8B5A3C]"}),from:"#FBE5C8",to:"#E8C9A0"},{match:"conditioner",icon:e.jsx(Ss,{size:48,className:"text-[#8B5A3C]"}),from:"#FBE5C8",to:"#E8C9A0"},{match:"makeup",icon:e.jsx(lx,{size:48,className:"text-[#800020]"}),from:"#F5D9DD",to:"#E8B8C0"},{match:"foundation",icon:e.jsx(lx,{size:48,className:"text-[#800020]"}),from:"#F5D9DD",to:"#E8B8C0"},{match:"serum",icon:e.jsx(fd,{size:48,className:"text-[#0F6B7B]"}),from:"#D6EEF2",to:"#A8DCE6"},{match:"toner",icon:e.jsx(fd,{size:48,className:"text-[#0F6B7B]"}),from:"#D6EEF2",to:"#A8DCE6"},{match:"cleanser",icon:e.jsx(Qe,{size:48,className:"text-[#4A7C59]"}),from:"#D9EEDD",to:"#B8DCC0"},{match:"mask",icon:e.jsx(Qe,{size:48,className:"text-[#4A7C59]"}),from:"#D9EEDD",to:"#B8DCC0"},{match:"exfoliant",icon:e.jsx(Qe,{size:48,className:"text-[#4A7C59]"}),from:"#D9EEDD",to:"#B8DCC0"},{match:"eye",icon:e.jsx(ms,{size:48,className:"text-[#4A1D5E]"}),from:"#E6DAF0",to:"#CDB8E0"},{match:"moisturizer",icon:e.jsx(On,{size:48,className:"text-[#2F5D43]"}),from:"#DCEFE0",to:"#BCDCC4"},{match:"cream",icon:e.jsx(On,{size:48,className:"text-[#2F5D43]"}),from:"#DCEFE0",to:"#BCDCC4"},{match:"sunscreen",icon:e.jsx(Sd,{size:48,className:"text-[#EA580C]"}),from:"#FEF0D9",to:"#FBD9A8"},{match:"body",icon:e.jsx(tf,{size:48,className:"text-[#2F5D43]"}),from:"#DCEFE0",to:"#BCDCC4"},{match:"kit",icon:e.jsx(_d,{size:48,className:"text-[#800020]"}),from:"#F0E4CC",to:"#E0CDA0"},{match:"shav",icon:e.jsx(Ss,{size:48,className:"text-[#334155]"}
1287),from:"#E2E8F0",to:"#C5CDD8"},{match:"men",icon:e.jsx(Ss,{size:48,className:"text-[#334155]"}),from:"#E2E8F0",to:"#C5CDD8"}],Ire=t=>{const s=(t||"").toLowerCase(),n=Rre.find(a=>s.includes(a.match));return n||{match:"",icon:e.jsx(Io,{size:48,className:"text-[#C5A059]"}),from:"#F0E4CC",to:"#E0CDA0"}},UE=({productType:t})=>{const s=Ire(t);return e.jsx("div",{className:"w-full h-full flex items-center justify-center",style:{background:`linear-gradient(135deg, ${s.from} 0%, ${s.to} 100%)`},"aria-hidden":"true",children:s.icon})},$re=()=>{var z,M;const{handle:t}=Wo(),[s,n]=d.useState(null),[a,r]=d.useState(!0),[i,o]=d.useState(!1),[l,c]=d.useState(null),[u,p]=d.useState(0),[m,x]=d.useState(null),[h,y]=d.useState(""),[v,g]=d.useState(1),[N,b]=d.useState(()=>ME()),[f,j]=d.useState(!1);d.useEffect(()=>{localStorage.setItem(pN,JSON.stringify(N))},[N]),d.useEffect(()=>{const R=T=>{T.key===pN&&b(ME())};return window.addEventListener("storage",R),()=>window.removeEventListener("storage",R)},[]);const S=N.reduce((R,T)=>R+T.quantity,0);d.useEffect(()=>{let R=!1;return(async()=>{if(!t)return;r(!0),o(!1),c(null),n(null),p(0),x(null),y(""),g(1);const U=q=>{const H={...q,images:BE(q.images)},G=(H.variants||[]).slice().sort((W,X)=>(W.position||0)-(X.position||0));if(H.variants=G,!R){if(n(H),G.length>0){const W=G.find(X=>X.inventory_qty==null||X.inventory_qty>0)||G[0];x(W),y((W==null?void 0:W.option1)||(W==null?void 0:W.title)||"")}r(!1)}};try{const{data:q,error:H}=await O.from("ecom_products").select("*, variants:ecom_product_variants(*)").eq("handle",t).maybeSingle();if(H)throw H;if(q){const W=q;if(W.has_variants&&(!W.variants||W.variants.length===0)){const{data:X}=await O.from("ecom_product_variants").select("*").eq("product_id",W.id).order("position");W.variants=X||[]}U(W);return}const G=Eh.find(W=>W.handle===t);if(G){U({...G,variants:[]});return}
1287R||(o(!0),r(!1))}catch(q){console.error("ProductDetailPage fetch error:",q);const H=Eh.find(G=>G.handle===t);if(H){U({...H,variants:[]});return}R||(c((q==null?void 0:q.message)||"Unable to load this product right now."),r(!1))}})(),()=>{R=!0}},[t]),d.useEffect(()=>{if(!s)return;const R=(s.description||"").replace(/\s+/g," ").trim();return qa({title:`${s.name} | Zorganics Cosmetics â Vegan Organic Beauty`,description:R.length>158?`${R.slice(0,158).replace(/\s+\S*$/,"")}â¦`:R||wr.description}),()=>qa(wr)},[s]);const w=d.useMemo(()=>{if(!s)return[];const R=Eh,T=(s.product_type||"").toLowerCase(),U=new Set((s.tags||[]).map(G=>G.toLowerCase()));return R.filter(G=>G.handle!==s.handle&&!F3(G.handle)).map(G=>{let W=0;return T&&(G.product_type||"").toLowerCase()===T&&(W+=3),(G.tags||[]).forEach(X=>{U.has(X.toLowerCase())&&(W+=1)}),{p:G,score:W}}).filter(G=>G.score>0).sort((G,W)=>W.score-G.score).slice(0,4).map(G=>({...G.p,images:BE(G.p.images)}))},[s]);d.useEffect(()=>{if(!s)return;const R=s.inventory_qty==null?!0:s.inventory_qty>0;return Qn("product",HQ({name:s.name,handle:s.handle,description:s.description,priceCents:s.price,sku:s.sku||s.handle,images:s.images,productType:s.product_type,inStock:R,related:w.map(T=>({name:T.name,handle:T.handle}))})),Qn("breadcrumb",ip([{name:"Zorganics Cosmetics â Shop",path:"/"},...s.product_type?[{name:s.product_type}]:[],{name:s.name,path:`/products/${s.handle}`}])),()=>{Jn("product"),Jn("breadcrumb")}},[s,w]);const _=!!(s!=null&&s.has_variants&&(s!=null&&s.variants)&&s.variants.length>0),C=d.useMemo(()=>s!=null&&s.variants?[...new Set(s.variants.map(R=>R.option1||R.title).filter(Boolean))]:[],[s]),E=(m==null?void 0:m.price)||(s==null?void 0:s.price)||0,F=m?m.inventory_qty==null?!0:m.inventory_qty>0:s!=null&&s.variants&&s.variants.length>0?s.variants.some(R=>R.inventory_qty==null||R.inventory_qty>0):s!=null&&s.has_variants||(s==null?void 0:s.inventory_qty)==null?!0:s.inventory_qty>0,I=R=>{var U;y(R);const T=(U=s==null?void 0:s.variants)==null?void 0:U.find(q=>{var H;return q.option1===R||((H=q.title)==null?void 0:H.toLowerCase().includes(R.toLowerCase()))});T&&x(T)},D=()=>{var T;if(!s||_&&!h||!F)return;const R={product_id:s.id,variant_id:(m==null?void 0:m.id)||void 0,quantity:Math.max(1,v),name:s.name,variant_title:(m==null?void 0:m.title)||(_?h:void 0),sku:(m==null?void 0:m.sku)||s.sku||s.handle,price:(m==null?void 0:m.price)||s.price,image:(T=s.images)==null?void 0:T[0]};b(U=>{const q=`${R.product_id}-${R.variant_id||"base"}`,H=U.findIndex(G=>`${G.product_id}-${G.variant_id||"base"}`===q);return H>=0?U.map((G,W)=>W===H?{...G,quantity:G.quantity+R.quantity}:G):[...U,R]}),j(!0),setTimeout(()=>j(!1),2e3)},L=((z=s==null?void 0:s.metadata)==null?void 0:z.certifications)||[],V=(s==null?void 0:s.metadata)||{};if(a)return e.jsxs("div",{className:"min-h-screen flex flex-col items-center justify-center bg-[#FAF6EE]",children:[e.jsx(de,{size:40,className:"text-[#C5A059] animate-spin mb-4"}),e.jsx("p",{className:"text-gray-500 font-medium",children:"Loading productâ¦"})]});if(i)return e.jsxs("div",{className:"min-h-screen flex flex-col items-center justify-center bg-[#FAF6EE] px-6 text-center",children:[e.jsx(Io,{size:48,className:"text-[#C5A059] mb-4"}),e.jsx("h1",{className:"font-display text-2xl font-bold mb-2",style:{color:"#800020"},children:"Product not found"}),e.jsxs("p",{className:"text-gray-500 max-w-md mb-6 text-sm",children:["We couldn't find a product at ",e.jsxs("span",{className:"font-mono",children:["/products/",t]}),". It may have been renamed, archived, or is not yet published."]}),e.jsxs(be,{to:"/",className:"inline-flex items-center gap-2 px-5 py-3 rounded-xl text-sm font-bold text-white shadow-md hover:opacity-90 transition-all",style:{background:"linear-gradient(135deg, #800020, #600018)"},children:[e.jsx(Je,{size:16})," Back to the shop"]})]});if(l||!s)return e.jsxs("div",{className:"min-h-screen flex flex-col items-center justify-center bg-[#FAF6EE] px-6 text-center",children:[e.jsx(ve,{size:44,className:"text-red-500 mb-4"}),e.jsx("h1",{className:"font-display text-xl font-bold mb-2 text-red-900",children:"Couldn't load this product"}),e.jsx("p",{className:"text-gray-500 max-w-md mb-6 text-sm",children:l||"Unknown error."}),e.jsxs(be,{to:"/",className:"inline-flex items-center gap-2 px-5 py-3 rounded-xl text-sm font-bold text-white shadow-md hover:opacity-90 transition-all",style:{background:"linear-gradient(135deg, #800020, #600018)"},children:[e.jsx(Je,{size:16})," Back to the shop"]})]});const B=s.images||[],A=B[u];return e.jsxs("div",{className:"min-h-screen bg-[#FAF6EE]",children:[e.jsx("header",{className:"sticky top-0 z-40 backdrop-blur border-b border-[#C5A059]/20",style:{background:"rgba(74,0,16,0.96)"},children:e.jsxs("div",{className:"max-w-6xl mx-auto px-6 py-3 flex items-center justify-between gap-3 text-white",children:[e.jsxs(be,{to:"/",className:"inline-flex items-center gap-2 text-[12px] font-semibold text-white/85 hover:text-white transition-colors",children:[e.jsx(Je,{size:14})," Zorganics Cosmetics"]}),e.jsxs(be,{to:"/",className:"relative inline-flex items-center gap-2 px-4 py-2 rounded-xl text-sm font-bold shadow-lg hover:shadow-xl transition-all",style:{background:"rgba(197, 160, 89, 0.95)",color:"#4A0010"},"aria-label":`View cart (${S} ${S===1?"item":"items"})`,children:[e.jsx(m2,{size:16})," Cart",S>0&&e.jsx("span",{className:"absolute -top-2 -right-2 min-w-[1.4rem] h-6 px-1.5 text-[11px] font-bold rounded-full flex items-center justify-center text-white shadow-md",style:{backgroundColor:"#800020"},children:S})]})]})}),e.jsxs("main",{className:"max-w-6xl mx-auto px-6 py-8 lg:py-10",children:[e.jsxs("nav",{className:"text-[11px] text-gray-400 mb-6 flex items-center gap-1.5 flex-wrap",children:[e.jsx(be,{to:"/",className:"hover:text-[#800020] font-medium",children:"Shop"}),e.jsx("span",{children:"/"}),s.product_type&&e.jsx("span",{className:"text-gray-500 font-medium",children:s.product_type}),e.jsx("span",{children:"/"}),e.jsx("span",{className:"text-gray-600 font-semibold truncate max-w-[16rem]",children:s.name})]}),e.jsxs("div",{className:"grid lg:grid-cols-2 gap-8 lg:gap-12",children:[e.jsxs("div",{children:[e.jsx("div",{className:"relative aspect-square rounded-3xl overflow-hidden border border-gray-100 bg-gradient-to-br from-gray-50 to-gray-100 shadow-sm",children:A?e.jsx("img",{src:A,alt:s.name,className:"w-full h-full object-cover",onError:R=>{R.currentTarget.style.display="none"}}):e.jsx(UE,{productType:s.product_type})}),B.length>1&&e.jsx("div",{className:"flex gap-2.5 mt-3 flex-wrap",children:B.map((R,T)=>e.jsx("button",{onClick:()=>p(T),className:`w-16 h-16 rounded-xl overflow-hidden border-2 transition-all ${T===u?"border-[#800020]":"border-gray-200 hover:border-[#C5A059]"}`,children:e.jsx("img",{src:R,alt:`${s.name} ${T+1}`,className:"w-full h-full object-cover"})},T))})]}),e.jsxs("div",{children:[s.product_type&&e.jsx("p",{className:"text-[11px] font-bold uppercase tracking-[0.16em] mb
1287-2",style:{color:"#800020"},children:s.product_type}),e.jsx("h1",{className:"font-display text-2xl lg:text-3xl font-bold leading-tight mb-3",style:{color:"#3B0A11"},children:s.name}),e.jsxs("div",{className:"flex flex-wrap gap-1.5 mb-4",children:[L.includes("100% Vegan")&&e.jsxs("span",{className:"inline-flex items-center gap-1 font-bold rounded-full border px-2.5 py-1 text-[11px] bg-green-50 text-green-700 border-green-200",children:[e.jsx(On,{size:11})," 100% Vegan"]}),L.includes("Certified Organic")&&e.jsxs("span",{className:"inline-flex items-center gap-1 font-bold rounded-full border px-2.5 py-1 text-[11px] bg-emerald-50 text-emerald-700 border-emerald-200",children:[e.jsx(Tt,{size:11})," Certified Organic"]}),L.includes("Non-Toxic")&&e.jsxs("span",{className:"inline-flex items-center gap-1 font-bold rounded-full border px-2.5 py-1 text-[11px] bg-blue-50 text-blue-700 border-blue-200",children:[e.jsx(xt,{size:11})," Non-Toxic"]})]}),e.jsxs("p",{className:"text-2xl font-bold text-gray-900 mb-4",children:["$",(E/100).toFixed(2)]}),F3(s.handle)&&e.jsxs("div",{className:"mb-6 p-4 rounded-xl border border-[#C5A059]/25 bg-[#C5A059]/5",children:[e.jsx(Tre,{activeHandle:s.handle,size:"md",showLabel:!0}),e.jsx("p",{className:"mt-2.5 text-[11px] text-gray-500 leading-snug",children:"Tap a swatch to view that shade. Swatch colors are accurate skin-tone approximations to help you choose."})]}),e.jsx("p",{className:"text-sm text-gray-600 leading-relaxed mb-6",children:s.description}),_&&e.jsxs("div",{className:"mb-6",children:[e.jsx("label",{className:"block text-xs font-bold text-gray-700 uppercase tracking-wider mb-2",children:"Select Option"}),e.jsx("div",{className:"flex flex-wrap gap-2",children:C.map(R=>{var H;const T=(H=s.variants)==null?void 0:H.find(G=>G.option1===R||G.title===R),U=T?T.inventory_qty==null||T.inventory_qty>0:!0,q=h===R;return e.jsx("button",{onClick:()=>U&&I(R),disabled:!U,className:`px-4 py-2 rounded-lg text-sm font-semibold border transition-all ${q?"border-[#800020] bg-[#800020]/5 text-[#800020]":U?"border-gray-200 text-gray-700 hover:border-[#C5A059]":"border-gray-100 text-gray-300 cursor-not-allowed line-through"}`,children:R},R)})})]}),e.jsxs("div",{className:"flex items-stretch gap-3 mb-5",children:[e.jsxs("div",{className:"flex items-center border border-gray-200 rounded-xl overflow-hidden bg-white",children:[e.jsx("button",{onClick:()=>g(R=>Math.max(1,R-1)),className:"w-10 h-12 flex items-center justify-center hover:bg-gray-50 text-gray-600","aria-label":"Decrease quantity",children:e.jsx(Ml,{size:15})}),e.jsx("span",{className:"w-10 text-center font-bold text-gray-900",children:v}),e.jsx("button",{onClick:()=>g(R=>R+1),className:"w-10 h-12 flex items-center justify-center hover:bg-gray-50 text-gray-600","aria-label":"Increase quantity",children:e.jsx(tn,{size:15})})]}),e.jsx("button",{onClick:D,disabled:_&&!h||!F,className:`flex-1 py-3 rounded-xl font-bold text-sm hover:opacity-90 transition-all flex items-center justify-center gap-2 disabled:opacity-50 disabled:cursor-not-allowed shadow-md ${f?"bg-emerald-500 text-white":"text-white"}`,style:f?void 0:{backgroundColor:"#C5A059"},children:f?e.jsxs(e.Fragment,{children:[e.jsx(xt,{size:16})," Added to Cart"]}):F?_&&!h?"Select an Option":e.jsxs(e.Fragment,{children:[e.jsx(m2,{size:16})," Add to Cart â $",(E/100).toFixed(2)]}):"Out of Stock"})]}),e.jsxs("p",{className:"text-[11px] text-gray-400 font-mono mb-5",children:["SKU: ",(m==null?void 0:m.sku)||s.sku||s.handle]}),V.key_ingredients&&e.jsxs("div",{className:"mb-4 p-4 bg-green-50 rounded-xl border border-green-200",children:[e.jsxs("p",{className:"text-[11px] font-bold text-green-700 uppercase tracking-wider mb-1.5 flex items-center gap-1.5",children:[e.jsx(Qx,{size:13})," Key Ingredients"]}),e.jsx("p",{className:"text-xs text-green-800 leading-relaxed",children:V.key_ingredients})]}),e.jsxs("div",{className:"space-y-1.5 text-xs text-gray-500 mb-5",children:[V.size&&e.jsxs("p",{children:[e.jsx("span",{className:"font-semibold text-gray-700",children:"Size:"})," ",V.size]}),V.skin_type&&e.jsxs("p",{children:[e.jsx("span",{className:"font-semibold text-gray-700",children:"Skin Type:"})," ",V.skin_type]}),V.hair_type&&e.jsxs("p",{children:[e.jsx("span",{className:"font-semibold text-gray-700",children:"Hair Type:"})," ",V.hair_type]}),V.finish&&e.jsxs("p",{children:[e.jsx("span",{className:"font-semibold text-gray-700",children:"Finish:"})," ",V.finish]}),V.usage&&e.jsxs("p",{children:[e.jsx("span",{className:"font-semibold text-gray-700",children:"Usage:"})," ",V.usage]})]}),s.tags&&s.tags.length>0&&e.jsx("div",{className:"flex flex-wrap gap-1.5 mb-5",children:s.tags.slice(0,6).map(R=>e.jsxs("span",{className:"inline-flex items-center gap-1 px-2 py-0.5 rounded-full text-[10px] font-semibold bg-gray-100 text-gray-500",children:[e.jsx(sf,{size:9})," ",R]},R))}),((M=V.fulfillment)==null?void 0:M.includes("in-store-bellingham"))&&e.jsxs("div",{className:"p-4 bg-[#800020]/5 rounded-xl border border-[#800020]/10",children:[e.jsx("p",{className:"text-[11px] font-bold text-[#800020] uppercase tracking-wider mb-2",children:"Fulfillment Options"}),e.jsx("div",{className:"flex flex-wrap gap-2",children:e.jsxs("span",{className:"inline-flex items-center gap-1 px-2.5 py-1 bg-white rounded-md text-[11px] font-semibold text-[#800020] border border-[#800020]/20",children:[e.jsx(ZO,{size:11})," In-Store Pickup â Bellingham Campus"]}
1287)})]})]})]}),e.jsx("div",{className:"mt-10 bg-white rounded-2xl border border-gray-100 shadow-sm p-5 lg:p-7",children:e.jsx(Ere,{productId:s.id,productName:s.name})}),w.length>0&&e.jsxs("section",{className:"mt-10","aria-labelledby":"related-products-heading",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-5",children:[e.jsx("div",{className:"w-1 h-5 rounded-full",style:{backgroundColor:"#C5A059"}}),e.jsx("h2",{id:"related-products-heading",className:"font-display text-lg font-bold",style:{color:"#3B0A11"},children:"You May Also Love"})]}),e.jsx("div",{className:"grid grid-cols-2 lg:grid-cols-4 gap-4",children:w.map(R=>{var T;return e.jsxs(be,{to:`/products/${R.handle}`,className:"group bg-white rounded-2xl border border-gray-100 overflow-hidden hover:shadow-lg hover:border-[#C5A059]/30 transition-all",children:[e.jsx("div",{className:"relative h-36 bg-gradient-to-br from-gray-50 to-gray-100 overflow-hidden",children:(T=R.images)!=null&&T[0]?e.jsx("img",{src:R.images[0],alt:R.name,loading:"lazy",className:"w-full h-full object-cover group-hover:scale-105 transition-transform duration-500",onError:U=>{U.currentTarget.style.display="none"}}):e.jsx(UE,{productType:R.product_type})}),e.jsxs("div",{className:"p-3",children:[R.product_type&&e.jsx("p",{className:"text-[9px] font-bold uppercase tracking-wider mb-0.5",style:{color:"#800020"},children:R.product_type}),e.jsx("h3",{className:"text-xs font-bold line-clamp-2 mb-1 group-hover:text-[#800020] transition-colors",style:{color:"#3B0A11"},children:R.name}),e.jsxs("p",{className:"text-sm font-bold text-gray-900",children:["$",(R.price/100).toFixed(2)]})]})]},R.handle)})})]}),e.jsxs("section",{className:"mt-10 grid md:grid-cols-2 gap-4","aria-label":"Continue your wellness journey",children:[e.jsxs(be,{to:"/routine-builder",className:"group rounded-2xl p-6 text-white shadow-lg hover:shadow-2xl hover:-translate-y-0.5 transition-all",style:{background:"linear-gradient(135deg, #800020 0%, #5A0018 60%, #C5A059 100%)"},children:[e.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[e.jsx(Qe,{size:16,style:{color:"#E6D2A0"}}),e.jsx("p",{className:"text-[10px] font-bold uppercase tracking-[0.18em]",style:{color:"#E6D2A0"},children:"Continue Your Journey"})]}),e.jsx("h3",{className:"font-display text-lg font-bold leading-tight mb-1.5",children:"Build this into your AM & PM ritual"}),e.jsx("p",{className:"text-xs text-white/85 leading-snug mb-3",children:"Compose a full 5-step regimen around this formulation in the Routine Builder â subscribers save 15% every month."}),e.jsxs("span",{className:"inline-flex items-center gap-1.5 text-xs font-bold uppercase tracking-wider",style:{color:"#E6D2A0"},children:["Open Routine Builder ",e.jsx(Vt,{size:13,className:"transition-transform group-hover:translate-x-1"})]})]}),e.jsxs("div",{className:"rounded-2xl p-6 bg-white border border-[#C5A059]/30 shadow-sm",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[e.jsx(On,{size:16,className:"text-emerald-600"}),e.jsx("p",{className:"text-[10px] font-bold uppercase tracking-[0.18em]",style:{color:"#800020"},children:"The Zorganics Standard"})]}),e.jsx("h3",{className:"font-display text-lg font-bold leading-tight mb-1.5",style:{color:"#3B0A11"},children:"100% vegan · cruelty-free · non-toxic"}),e.jsx("p",{className:"text-xs text-gray-600 leading-snug",children:"Born in the Zorganics Research Garden where botanical science meets clinical rigor â and every purchase supports Zorganics Foundation scholarships and restorative care."})]})]}),e.jsx("div",{className:"mt-10 text-center",children:e.jsxs(be,{to:"/",className:"inline-flex items-center gap-2 px-6 py-3 rounded-xl text-sm font-bold text-white shadow-md hover:opacity-90 transition-all",style:{background:"linear-gradient(135deg, #800020, #600018)"},children:[e.jsx(Je,{size:15})," Continue shopping the full Zorganics catalog"]})})]})]})},Zr={COLOR:"color",FACIALS:"facials",DEFAULT:"default"},lk={Bellingham:{days:[3,4,5],times:["1:00 PM","2:00 PM","3:00 PM","4:00 PM","5:00 PM"],serviceRules:{[Zr.COLOR]:{days:[4],label:"Color â Thursdays only"},[Zr.FACIALS]:{days:[3,4,5],label:"Facials â WedâFri"}}},Seattle:{days:[1,2,3,4,5,6],times:["9:00 AM","10:30 AM","12:00 PM","1:30 PM","3:00 PM","4:30 PM"],serviceRules:{[Zr.COLOR]:{days:[2,4,6],label:"Color â Tue / Thu / Sat"}}},Renton:{days:[1,2,3,4,5,6],times:["9:00 AM","10:30 AM","12:00 PM","1:30 PM","3:00 PM","4:30 PM"],serviceRules:{[Zr.COLOR]:{days:[2,4,6],label:"Color â Tue / Thu / Sat"}}}},ck={days:[1,2,3,4,5,6],times:["9:00 AM","10:30 AM","12:00 PM","1:30 PM","3:00 PM","4:30 PM"]},zre=(t={})=>{const s=(t.pillar||"").toLowerCase(),n=(t.categoryId||"").toLowerCase(),a=(t.name||"").toLowerCase();return s==="color"?Zr.COLOR:n==="skincare"?Zr.FACIALS:/(color|highlight|balayage|retouch|toner|glaze)/.test(a)?Zr.COLOR:/(facial|microderm|oxygen|derm|peel)/.test(a)?Zr.FACIALS:Zr.DEFAULT},qE=(t,s)=>t.filter(n=>s.includes(n)),Lre=(t,s)=>{var r;const n=lk[t]||ck,a=s?(r=n.serviceRules)==null?void 0:r[s]:void 0;return a?{days:a.days?qE(a.days,n.days):[...n.days],times:a.times?qE(a.times,n.times):[...n.times]}:{days:[...n.days],times:[...n.times]}},WE=t=>new Date(t+"T00:00:00").getDay(),HE=(t,s,n,a)=>
1287{if(!s||s===Zr.DEFAULT){const i=lk[t]||ck;return i.days.includes(WE(n))&&i.times.includes(a)}const r=Lre(t,s);return r.days.includes(WE(n))&&r.times.includes(a)},Ore=(t,s)=>{var a,r;return!s||s===Zr.DEFAULT?null:((r=(a=(lk[t]||ck).serviceRules)==null?void 0:a[s])==null?void 0:r.label)||null},hj=t=>{if(!t)return 0;const s=new Date(t).getTime();return isNaN(s)?0:Math.max(0,s-Date.now())},_g=t=>String(t).padStart(2,"0"),Mre=({heldUntil:t,onExpire:s,variant:n="banner",className:a})=>{const[r,i]=d.useState(()=>hj(t)),[o,l]=d.useState(!1);if(d.useEffect(()=>{if(l(!1),i(hj(t)),!t)return;const y=()=>{const g=hj(t);i(g),g<=0&&l(N=>(N||s==null||s(),!0))};y();const v=setInterval(y,1e3);return()=>clearInterval(v)},[t]),!t)return null;const c=Math.floor(r/1e3),u=Math.floor(c/60),p=c%60,m=r<=0,x=!m&&c<=120,h=m?"Hold expired":`${_g(u)}:${_g(p)} left to book`;return n==="pill"?e.jsx("span",{className:`inline-flex items-center gap-1 px-2 py-0.5 rounded-full text-[10px] font-bold tabular-nums ${a||""}`,style:{background:m?"rgba(220,38,38,0.10)":x?"rgba(217,119,6,0.12)":"rgba(45,90,39,0.12)",color:m?"#DC2626":x?"#B45309":"#2D5A27",border:`1px solid ${m?"rgba(220,38,38,0.4)":x?"rgba(217,119,6,0.4)":"rgba(45,90,39,0.4)"}`},"aria-live":"polite",children:m?"Expired":`${_g(u)}:${_g(p)}`}):e.jsxs("span",{className:`inline-flex items-center gap-1.5 font-bold tabular-nums ${a||""}`,style:{color:m?"#DC2626":x?"#B45309":"#2D5A27"},"aria-live":"polite",children:[e.jsx("span",{className:"inline-block w-2 h-2 rounded-full",style:{background:m?"#DC2626":x?"#D97706":"#2D5A27",animation:m?"none":"pulse 1.4s ease-in-out infinite"}}),h]})},Bre="https://famous.ai/api/crm/69caed6904ed6aca7682413a/subscribe",Ure=["Bellingham","Seattle","Renton"],GE=t=>{const s=/(\d{1,2}):(\d{2})\s*(AM|PM)/i.exec(t||"");if(!s)return 9999;let n=parseInt(s[1],10)%12;return s[3].toUpperCase()==="PM"&&(n+=12),n*60+parseInt(s[2],10)},qre=({campus:t,onCampusChange:s,selectedSlot:n,onSlotChange:a,serviceType:r,serviceName:i,holdEmail:o,campuses:l,slotFilter:c,emptyStateNote:u})=>{const[p,m]=d.useState([]),[x,h]=d.useState(!1),[y,v]=d.useState(null),g=(o||"").trim().toLowerCase()||null,N=I=>{if(I.is_booked)return"booked";if(!!I.held_until&&new Date(I.held_until).getTime()>Date.now()){const L=(I.held_for_email||"").trim().toLowerCase();return g&&L===g?"mine":"held"}return"open"},b=I=>{const D=N(I);return D==="open"||D==="mine"},f=d.useCallback(async()=>{h(!0);const I=new Date().toISOString().split("T")[0],{data:D,error:L}=await O.from("z_salon_slots").select("*").eq("campus",t).gte("slot_date",I).order("slot_date",{ascending:!0});L?(console.error("Slot fetch error:",L),m([])):m(D||[]),h(!1)},[t]);d.useEffect(()=>{f()},[f]);const j=d.useMemo(()=>Ore(t,r),[t,r]),S=d.useMemo(()=>p.find(I=>N(I)==="mine")||null,[p,g]),w=d.useMemo(()=>{const I=new Map;return p.forEach(D=>{HE(t,r,D.slot_date,D.slot_time)&&(c&&!c(D)||(I.has(D.slot_date)||I.set(D.slot_date,[]),I.get(D.slot_date).push(D)))}),Array.from(I.entries()).map(([D,L])=>({date:D,slots:L.sort((V,B)=>GE(V.slot_time)-GE(B.slot_time)),openCount:L.filter(V=>b(V)).length})).filter(D=>D.openCount>0).slice(0,14)},[p,t,r,g,c]);d.useEffect(()=>{if(!n)return;const I=p.find(L=>L.id===n.id);HE(t,r,n.slot_date,n.slot_time)&&(!c||c(n))&&(!I||b(I))||a(null)},[t,r,p,g,c]),d.useEffect(()=>{S&&!n&&(v(S.slot_date),a(S))},[S]),d.useEffect(()=>{w.length>0&&!y&&v(w[0].date),y&&!w.find(I=>I.date===y)&&w.length>0&&v(w[0].date)},[w,y]);const _=w.find(I=>I.date===y),C=w.findIndex(I=>I.date===y),E=I=>{const D=new Date(I+"T00:00:00");return{weekday:D.toLocaleDateString(void 0,{weekday:"short"}),month:D.toLocaleDateString(void 0,{month:"short"}),day:D.getDate()}},P=I=>I?new Date(I).toLocaleTimeString(void 0,{hour:"numeric",minute:"2-digit"}):"",F=l&&l.length>0?l:Ure;return e.jsxs("div",{children:[e.jsxs("label",{className:"block text-[11px] font-bold uppercase tracking-wider mb-2",style:{color:"#5A1A24"},children:[e.jsx(zt,{size:12,className:"inline mr-1.5",style:{color:"#D4AF37"}}),"Select Campus"]}),e.jsx("div",{className:`grid gap-2 mb-5 ${F.length===1?"grid-cols-1":F.length===2?"grid-cols-2":"grid-cols-3"}`,children:F.map(I=>{const D=t===I;return e.jsx("button",{type:"button",onClick:()=>{s(I),a(null),v(null)},className:"py-2.5 rounded-lg text-xs font-bold transition-all",style:{background:D?"linear-gradient(135deg, #3B0A11, #5A1A24)":"#FFFFFF",color:D?"#FFFBF2":"#5A1A24",border:`1.5px solid ${D?"#3B0A11":"#E8DDD0"}`,boxShadow:D?"0 4px 12px rgba(59,10,17,0.2)":"none"},children:I},I)})}),S&&e.jsxs("div",{className:"mb-4 rounded-xl px-4 py-3 flex items-start gap-2.5",style:{background:"rgba(45,90,39,0.07)",border:"1px solid rgba(45,90,39,0.3)"},children:[e.jsx(Xe,{size:16,className:"flex-shrink-0 mt-0.5",style:{color:"#2D5A27"}}),e.jsxs("div",{className:"flex-1",children:[e.jsx("p",{className:"text-xs font-bold",style:{color:"#2D5A27"},children:"A spot is reserved just for you"}),e.jsxs("p",{className:"text-[11px] mt-0.5 leading-snug",style:{color:"#3B0A11"},children:[new Date(S.slot_date+"T00:00:00").toLocaleDateString(void 0,{weekday:"long",month:"long",day:"numeric"})," · ",S.slot_time," at ",t,".",S.held_until&&e.jsxs(e.Fragment,{children:[" Reserved until ",e.jsx("strong",{children:P(S.held_until)})," â complete checkout to lock it in."]})]}),S.held_until&&e.jsx("div",{className:"mt-1.5 text-[12px]",children:e.jsx(Mre,{heldUntil:S.held_until,onExpire:()=>{a(null),f()}})})]})]}),e.jsxs("label",{className:"block text-[11px] font-bold uppercase tracking-wider mb-2",style:{color:"#5A1A24"},children:[e.jsx(At,{size:12,className:"inline mr-1.5",style:{color:"#D4AF37"}}),"Choose a Date & Time"]}),j&&e.jsxs("div",{className:"mb-3 rounded-lg px-3 py-2 flex items-center gap-2",style:{background:"rgba(128,0,32,0.05)",border:"1px solid rgba(128,0,32,0.18)"},children:[e.jsx(Bi,{size:13,className:"flex-shrink-0",style:{color:"#800020"}}),e.jsxs("p",{className:"text-[11px] font-semibold leading-snug",style:{color:"#5A1A24"},children:["Limited availability for this service: ",e.jsx("strong",{children:j}),". Only eligible times are shown."]})]}),x?e.jsxs("div",{className:"py-10 flex flex-col items-center justify-center rounded-xl",style:{background:"rgba(212,175,55,0.05)",border:"1px dashed rgba(212,175,55,0.3)"}
1287,children:[e.jsx(de,{size:24,className:"animate-spin mb-2",style:{color:"#800020"}}),e.jsxs("p",{className:"text-xs",style:{color:"#7A3A44"},children:["Loading live availability for ",t,"â¦"]})]}):w.length===0?e.jsxs("div",{className:"rounded-xl p-5",style:{background:"rgba(212,175,55,0.05)",border:"1px dashed rgba(212,175,55,0.35)"},children:[!u&&e.jsxs("div",{className:"text-center mb-4",children:[e.jsxs("p",{className:"text-sm font-semibold mb-1",style:{color:"#5A1A24"},children:["No open ",j?"eligible ":"","times at ",t," right now"]}),e.jsxs("p",{className:"text-xs",style:{color:"#7A3A44"},children:[j?e.jsxs(e.Fragment,{children:["This service is limited to ",e.jsx("strong",{children:j})," and they're currently full. "]}):e.jsx(e.Fragment,{children:"This campus is fully booked for the days ahead. "}),"Join the waitlist and we'll email you the moment a matching spot frees up."]})]}),u&&e.jsx("div",{className:"mb-4",children:u}),e.jsx(Wre,{campus:t,serviceType:r,serviceName:i})]}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex items-center gap-2 mb-4",children:[e.jsx("button",{type:"button",disabled:C<=0,onClick:()=>C>0&&v(w[C-1].date),className:"w-8 h-8 rounded-lg flex items-center justify-center flex-shrink-0 disabled:opacity-30 transition-all",style:{border:"1px solid #E8DDD0",color:"#5A1A24"},children:e.jsx(vO,{size:16})}),e.jsx("div",{className:"flex-1 overflow-x-auto flex gap-2 pb-1",children:w.map(I=>{const D=E(I.date),L=y===I.date;return e.jsxs("button",{type:"button",onClick:()=>v(I.date),className:"flex-shrink-0 w-16 py-2 rounded-xl text-center transition-all",style:{background:L?"linear-gradient(135deg, #D4AF37, #B8962E)":"#FFFFFF",color:L?"#3B0A11":"#5A1A24",border:`1.5px solid ${L?"#D4AF37":"#E8DDD0"}`,boxShadow:L?"0 4px 12px rgba(212,175,55,0.3)":"none"},children:[e.jsx("p",{className:"text-[9px] font-bold uppercase tracking-wider opacity-80",children:D.weekday}),e.jsx("p",{className:"text-lg font-bold leading-none my-0.5",children:D.day}),e.jsx("p",{className:"text-[9px] font-semibold uppercase",children:D.month}),e.jsxs("p",{className:"text-[8px] mt-0.5 font-bold",style:{color:L?"#5A1A24":"#2D5A27"},children:[I.openCount," open"]})]},I.date)})}),e.jsx("button",{type:"button",disabled:C>=w.length-1,onClick:()=>C<w.length-1&&v(w[C+1].date),className:"w-8 h-8 rounded-lg flex items-center justify-center flex-shrink-0 disabled:opacity-30 transition-all",style:{border:"1px solid #E8DDD0",color:"#5A1A24"},children:e.jsx(Nr,{size:16})})]}),_&&e.jsx("div",{className:"grid grid-cols-3 gap-2",children:_.slots.map(I=>{const D=N(I),L=(n==null?void 0:n.id)===I.id,V=D==="open"||D==="mine",B=D==="mine";return e.jsxs("button",{type:"button",disabled:!V,onClick:()=>V&&a(L?null:I),title:D==="held"?"Reserved for another guest":D==="booked"?"Already booked":B?"Reserved for you":void 0,className:"py-2.5 rounded-lg text-xs font-bold transition-all flex items-center justify-center gap-1",style:{background:D==="booked"||D==="held"?"#F5F0EA":L?"linear-gradient(135deg, #800020, #5A0018)":B?"rgba(45,90,39,0.10)":"#FFFFFF",color:D==="booked"||D==="held"?"#C4B8AE":L?"#FFFBF2":B?"#2D5A27":"#3B0A11",border:`1.5px solid ${D==="booked"||D==="held"?"#EFE7DD":L?"#800020":B?"rgba(45,90,39,0.5)":"#E8DDD0"}`,textDecoration:D==="booked"?"line-through":"none",cursor:V?"pointer":"not-allowed"},children:[D==="held"?e.jsx(Xe,{size:11}):L?e.jsx(pt,{size:12}):B?e.jsx(Xe,{size:11}):e.jsx(dt,{size:11}),I.slot_time]},I.id)})}),n&&e.jsxs("div",{className:"mt-4 rounded-lg p-3 flex items-center gap-2",style:{background:"rgba(45,90,39,0.06)",border:"1px solid rgba(45,90,39,0.2)"},children:[e.jsx(pt,{size:14,style:{color:"#2D5A27"}}),e.jsxs("p",{className:"text-xs font-semibold",style:{color:"#3B0A11"},children:[t," · ",new Date(n.slot_date+"T00:00:00").toLocaleDateString(void 0,{weekday:"long",month:"long",day:"numeric"})," · ",n.slot_time]})]})]})]})},Wre=({campus:t,serviceType:s,serviceName:n})=>{const[a,r]=d.useState(""),[i,o]=d.useState(""),[l,c]=d.useState(!1),[u,p]=d.useState(!1),[m,x]=d.useState(""),[h,y]=d.useState(null),v=async g=>{g.preventDefault();const N=i.trim().toLowerCase();if(!/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(N)){x("Please enter a valid email address.");return}x(""),c(!0);try{const{error:b}=await O.from("z_salon_waitlist").insert({campus:t,service_type:s||"default",service_name:n||null,email:N,name:a.trim()||null,status:"waiting"});if(b)throw new Error(b.message);const{count:f}=await O.from("z_salon_waitlist").select("id",{count:"exact",head:!0}).eq("campus",t).eq("service_type",s||"default").eq("status","waiting");y(typeof f=="number"&&f>0?f:1),fetch(Bre,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({email:N,name:a.trim()||void 0,source:"salon-waitlist",tags:["salon-waitlist",`campus-${t.toLowerCase()}`,s?`service-${s}`:"service-any"]})}).catch(()=>{}),p(!0)}catch(b){x(b.message||"Could not join the waitlist. Please try again.")}finally{c(!1)}};return u?e.jsxs("div",{className:"rounded-lg p-4",style:{background:"rgba(45,90,39,0.07)",border:"1px solid rgba(45,90,39,0.25)"},children:[e.jsxs("div",{className:"flex items-start gap-2.5",children:[e.jsx(pt,{size:18,className:"flex-shrink-0 mt-0.5",style:{color:"#2D5A27"}}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-bold",style:{color:"#2D5A27"},children:"You're on the waitlist!"}),e.jsxs("p",{className:"text-xs mt-0.5",style:{color:"#3B0A11"},children:["We'll email ",e.jsx("strong",{children:i.trim().toLowerCase()})," the instant an eligible",n?` ${n}`:""," spot opens at ",t,". Openings are first-come, first-served."]})]})]}),h!==null&&e.jsxs("div",{className:"mt-3 flex items-center gap-2.5 rounded-lg px-3 py-2.5",style:{background:"#FFFFFF",border:"1px solid rgba(212,175,55,0.45)"},children:[e.jsx("div",{className:"w-9 h-9 rounded-full flex items-center justify-center flex-shrink-0",style:{background:"linear-gradient(135deg, #D4AF37, #B8962E)",color:"#3B0A11"},children:e.jsx(BP,{size:16})}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-bold",style:{color:"#5A1A24"},children:h===1?"You're #1 in line â next up!":e.jsxs(e.Fragment,{children:["You're ",e.jsxs("strong",{children:["#",h]})," in line"]})}),e.jsx("p",{className:"text-[11px]",style:{color:"#7A3A44"},children:h===1?"The next matching opening at this campus is yours first.":`${h-1} guest${h-1===1?"":"s"} ahead of you for this service at ${t}.`})]})]})]}):e.jsxs("form",{onSubmit:v,className:"space-y-2.5",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[e.jsx(Di,{size:14,style:{color:"#D4AF37"}}),e.jsx("span",{className:"text-[11px] font-bold uppercase tracking-wider",style:{color:"#800020"},children:"Join the Waitlist"})]}),e.jsx("input",{type:"text",value:a,onChange:g=>r(g.target.value),placeholder:"Your name (optional)",className:"w-full px-3 py-2.5 rounded-lg text-sm focus:outline-none focus:ring-2",style:{border:"1.5px solid #E8DDD0",color:"#3B0A11"}}),e.jsxs("div",{className:"relative",children:[e.jsx(Ye,{size:15,className:"absolute left-3 top-1/2 -translate-y-1/2",style:{color:"#D4AF37"}}),e.jsx("input",{type:"email",value:i,onChange:g=>o(g.target.value),placeholder:"[email protected]",required:!0,className:"w-full pl-9 pr-3 py-2.5 rounded-lg text-sm focus:outline-none focus:ring-2",style:{border:"1.5px solid #E8DDD0",color:"#3B0A11"}})]}),m&&e.jsx("p",{className:"text-xs",style:{color:"#DC2626"},children:m}),e.jsxs("button",{type:"submit",disabled:l,className:"w-full inline-flex items-center justify-center gap-2 py-2.5 rounded-lg text-sm font-bold text-white transition-all hover:shadow-lg disabled:opacity-50",style:{background:"linear-gradient(135deg, #800020, #5A0018)"},children:[l?e.jsx(de,{size:15,className:"animate-spin"}):e.jsx(Hs,{size:14}),"Notify Me When a Spot Opens"]}),e.jsx("p",{className:"text-[10px] text-center",style:{color:"#7A3A44"},children:"We'll only email you about matching openings for this service & campus."})]})},VE={paid:{label:"Confirmed",bg:"rgba(45,90,39,0.10)",text:"#2D5A27",icon:e.jsx(pt,{size:12})},scheduled:{label:"Scheduled",bg:"rgba(212,175,55,0.12)",text:"#9A7B1A",icon:e.jsx(At,{size:12})},completed:{label:"Completed",bg:"rgba(90,26,36,0.10)",text:"#5A1A24",icon:e.jsx(Qe,{size:12})},cancelled:{label:"Cancelled",bg:"rgba(120,120,120,0.12)",text:"#6
1287B7280",icon:e.jsx(Ke,{size:12})},refunded:{label:"Refunded",bg:"rgba(220,38,38,0.08)",text:"#B91C1C",icon:e.jsx(zi,{size:12})},no_show:{label:"No Show",bg:"rgba(217,119,6,0.10)",text:"#B45309",icon:e.jsx(ve,{size:12})}},Hre=t=>`$${(t/100).toFixed(0)}`,B0=t=>t?new Date(t+"T00:00:00").toLocaleDateString(void 0,{weekday:"long",month:"long",day:"numeric",year:"numeric"}):"Date to be confirmed",Gre=()=>{sn(),Ho({title:"My Appointments | Zora's Styling Salon & Zorganics Med Spa",description:"Secure self-service portal for managing your salon and med spa appointments."});const[t,s]=cc(),[n,a]=d.useState(""),[r,i]=d.useState(null),[o,l]=d.useState(!1),[c,u]=d.useState(!1),[p,m]=d.useState(!1),[x,h]=d.useState(""),[y,v]=d.useState([]),[g,N]=d.useState(null),[b,f]=d.useState(!1),[j,S]=d.useState(null),[w,_]=d.useState("Bellingham"),[C,E]=d.useState(null),[P,F]=d.useState(!1),[I,D]=d.useState(null),L=(G,W)=>{D({type:G,text:W}),setTimeout(()=>D(null),6500)};d.useEffect(()=>{const G=t.get("token");!G||r||(m(!0),h(""),O.functions.invoke("verify-salon-magic-link",{body:{token:G}}).then(({data:W,error:X})=>{X||!(W!=null&&W.success)?h((W==null?void 0:W.message)||"This secure link is invalid or has expired. Please request a new one."):(i(W.email),v(W.bookings||[]))}).finally(()=>{m(!1);const W=new URLSearchParams(t);W.delete("token"),s(W,{replace:!0})}))},[]);const V=async G=>{G==null||G.preventDefault();const W=n.trim().toLowerCase();if(!W||!/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(W)){h("Please enter the valid email address you booked with.");return}h(""),u(!0);const{error:X}=await O.functions.invoke("send-salon-magic-link",{body:{email:W,appOrigin:window.location.origin}});if(u(!1),X){h("We could not send your link right now. Please try again, or call (360) 392-8243.");return}l(!0)},B=async()=>{if(!r)return;const{data:G}=await O.from("z_salon_bookings").select("*").eq("client_email",r).order("preferred_date",{ascending:!0,nullsFirst:!1}).order("created_at",{ascending:!1});v(G||[])},A=G=>{if(["cancelled","refunded","completed","no_show"].includes(G.status))return!1;if(!G.preferred_date)return!0;const W=new Date(G.preferred_date+"T00:00:00"),X=new Date;return X.setHours(0,0,0,0),W>=X},z=async G=>{const W={is_booked:!1,booking_id:null,booking_reference:null,stylist_id:null,updated_at:new Date().toISOString()};G.slot_id?await O.from("z_salon_slots").update(W).eq("id",G.slot_id):G.booking_reference&&await O.from("z_salon_slots").update(W).eq("booking_reference",G.booking_reference),G.campus&&G.preferred_date&&G.preferred_time&&O.functions.invoke("notify-salon-waitlist",{body:{campus:G.campus,slot_date:G.preferred_date,slot_time:G.preferred_time,appOrigin:window.location.origin}}).catch(()=>{})},M=async()=>{if(g){f(!0);try{const{error:G}=await O.from("z_salon_bookings").update({status:"cancelled",updated_at:new Date().toISOString()}).eq("id",g.id);if(G)throw new Error(G.message);await z(g),O.functions.invoke("send-salon-cancellation",{body:{kind:"cancelled",bookingReference:g.booking_reference,clientName:g.client_name,clientEmail:g.client_email,serviceName:g.service_name,preferredDate:g.preferred_date,preferredTime:g.preferred_time,campus:g.campus}}).catch(()=>{}),v(W=>W.map(X=>X.id===g.id?{...X,status:"cancelled"}:X)),L("success",`${g.booking_reference} cancelled. A confirmation email is on its way and the slot has been released.`)}catch(G){L("error",G.message||"Could not cancel â please call us at (360) 392-8243.")}finally{f(!1),N(null)}}},R=G=>{S(G),_(G.campus||"Bellingham"),E(null)},T=async()=>{if(!(!j||!C)){F(!0);try{const{data:G,error:W}=await O.from("z_salon_slots").update({is_booked:!0,booking_id:j.id,booking_reference:j.booking_reference,stylist_id:j.stylist_id||null,updated_at:new Date().toISOString()}).eq("id",C.id).eq("is_booked",!1).select("id");if(W)throw new Error(W.message);if(!G||G.length===0)throw new Error("That time was just taken by another guest. Please pick a different slot.");await z(j);const{error:X}=await O.from("z_salon_bookings").update({preferred_date:C.slot_date,preferred_time:C.slot_time,campus:C.campus,slot_id:C.id,updated_at:new Date().toISOString()}).eq("id",j.id);if(X)throw await O.from("z_salon_slots").update({is_booked:!1,booking_id:null,booking_reference:null}).eq("id",C.id),new Error(X.message);O.functions.invoke("send-salon-cancellation",{body:{kind:"rescheduled",bookingReference:j.booking_reference,clientName:j.client_name,clientEmail:j.client_email,serviceName:j.service_name,preferredDate:C.slot_date,preferredTime:C.slot_time,campus:C.campus}}).catch(()=>{}),await B(),L("success",`${j.booking_reference} rescheduled to ${B0(C.slot_date)} at ${C.slot_time}. A confirmation email has been sent.`),S(null),E(null)}catch(G){L("error",G.message||"Could not reschedule. Please try again.")}finally{F(!1)}}},U=y.filter(A),q=y.filter(G=>!A(G)),H=!!r;return e.jsxs("div",{className:"min-h-screen",style:{background:"linear-gradient(135deg, #FFFBF2 0%, #FCEDD9 100%)"},children:[e.jsx("div",{style:{background:"linear-gradient(135deg, #3B0A11, #5A1A24)"},className:"text-white",children:e.jsxs("div",{className:"max-w-4xl mx-auto px-6 py-8",children:[e.jsxs(be,{to:"/",className:"inline-flex items-center gap-2 text-white/70 hover:text-white text-xs mb-4 transition-colors",children:[e.jsx(Je,{size:14})," Back to Zorganics"]}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"w-12 h-12 rounded-xl flex items-center justify-center",style:{background:"linear-gradient(135deg, #D4AF37, #B8962E)"},children:e.jsx(Ss,{size:22,className:"text-white"})}),e.jsxs("div",{children:[e.jsx("h1",{className:"font-display text-2xl font-bold",style:{fontFamily:"'Playfair Display', Georgia, serif"},children:"My Appointments"}),e.jsx("p",{className:"text-xs text-white/60 mt-0.5 tracking-wider up
1287percase",children:"Zora's Styling Salon & Zorganics Med Spa · Manage your bookings"})]})]})]})}),e.jsxs("div",{className:"max-w-4xl mx-auto px-6 py-8",children:[I&&e.jsxs("div",{className:"mb-6 rounded-xl px-4 py-3 flex items-start gap-2 text-sm font-medium",style:{background:I.type==="success"?"rgba(45,90,39,0.08)":"rgba(220,38,38,0.06)",border:`1px solid ${I.type==="success"?"rgba(45,90,39,0.25)":"rgba(220,38,38,0.25)"}`,color:I.type==="success"?"#2D5A27":"#B91C1C"},children:[I.type==="success"?e.jsx(pt,{size:15,className:"mt-0.5 flex-shrink-0"}):e.jsx(kt,{size:15,className:"mt-0.5 flex-shrink-0"}),I.text]}),p&&e.jsxs("div",{className:"bg-white rounded-2xl p-10 text-center",style:{border:"1px solid rgba(212,175,55,0.25)"},children:[e.jsx(de,{size:28,className:"animate-spin mx-auto mb-3",style:{color:"#800020"}}),e.jsx("p",{className:"font-semibold",style:{color:"#3B0A11"},children:"Verifying your secure linkâ¦"})]}),!H&&!p&&e.jsx("div",{className:"bg-white rounded-2xl p-6 mb-8",style:{border:"1px solid rgba(212,175,55,0.25)",boxShadow:"0 8px 30px rgba(59,10,17,0.08)"},children:o?e.jsxs("div",{className:"text-center py-4",children:[e.jsx("div",{className:"w-14 h-14 rounded-full flex items-center justify-center mx-auto mb-4",style:{background:"rgba(45,90,39,0.1)"},children:e.jsx(Ye,{size:24,style:{color:"#2D5A27"}})}),e.jsx("h3",{className:"font-bold text-lg mb-1",style:{color:"#3B0A11"},children:"Check your inbox"}),e.jsxs("p",{className:"text-sm",style:{color:"#7A3A44"},children:["If ",e.jsx("strong",{children:n.trim().toLowerCase()})," has appointments with us, a secure sign-in link is on its way. It expires in 30 minutes."]}),e.jsx("button",{onClick:()=>{l(!1),h("")},className:"mt-4 text-xs font-bold underline",style:{color:"#800020"},children:"Use a different email"})]}):e.jsxs("form",{onSubmit:V,children:[e.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[e.jsx(ka,{size:15,style:{color:"#D4AF37"}}),e.jsx("label",{className:"text-[11px] font-bold uppercase tracking-wider",style:{color:"#5A1A24"},children:"Secure sign-in to manage your appointments"})]}),e.jsx("p",{className:"text-xs mb-4",style:{color:"#7A3A44"},children:"Enter the email you booked with and we'll send you a one-time secure link â no password needed."}),e.jsxs("div",{className:"flex flex-col sm:flex-row gap-3",children:[e.jsxs("div",{className:"flex-1 relative",children:[e.jsx(Ye,{size:16,className:"absolute left-3 top-1/2 -translate-y-1/2",style:{color:"#D4AF37"}}),e.jsx("input",{type:"email",value:n,onChange:G=>a(G.target.value),placeholder:"[email protected]",className:"w-full pl-10 pr-4 py-3 rounded-lg text-sm focus:outline-none focus:ring-2",style:{border:"1.5px solid #E8DDD0",color:"#3B0A11"}})]}),e.jsxs("button",{type:"submit",disabled:c,className:"inline-flex items-center justify-center gap-2 px-6 py-3 rounded-lg text-sm font-bold text-white transition-all hover:shadow-lg disabled:opacity-50",style:{background:"linear-gradient(135deg, #800020, #5A0018)"},children:[c?e.jsx(de,{size:15,className:"animate-spin"}):e.jsx(Hs,{size:15}),"Email Me a Secure Link"]})]}),x&&e.jsx("p",{className:"text-xs mt-2",style:{color:"#DC2626"},children:x}),e.jsxs("p",{className:"text-[11px] mt-3 flex items-center gap-1.5",style:{color:"#7A3A44"},children:[e.jsx(Ie,{size:12,style:{color:"#D4AF37"}}),"Links expire after 30 minutes and can be used once for your security."]})]})}),!H&&!p&&x&&t.get("token")!==null&&e.jsxs("div",{className:"bg-white rounded-2xl p-6 text-center",style:{border:"1px solid rgba(220,38,38,0.25)"},children:[e.jsx(kt,{size:28,className:"mx-auto mb-2",style:{color:"#DC2626"}}),e.jsx("p",{className:"text-sm font-semibold",style:{color:"#B91C1C"},children:x})]}),H&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"flex items-center justify-between mb-4 rounded-xl px-4 py-3",style:{background:"rgba(45,90,39,0.06)",border:"1px solid rgba(45,90,39,0.2)"},children:e.jsxs("p",{className:"text-xs font-semibold flex items-center gap-2",style:{color:"#2D5A27"},children:[e.jsx(Ie,{size:14})," Signed in as ",r]})}),U.length>0&&e.jsxs("div",{className:"mb-6 rounded-xl px-4 py-3",style:{background:"rgba(212,175,55,0.07)",border:"1px solid rgba(212,175,55,0.25)"},children:[e.jsxs("p",{className:"text-xs font-semibold flex items-center gap-2 mb-1",style:{color:"#9A7B1A"},children:[e.jsx(Di,{size:14})," Preparing for your visit"]}),e.jsxs("p",{className:"text-[11px] leading-relaxed",style:{color:"#5A1A24"},children:["We'll email you a friendly reminder the day before each confirmed appointment.",U.some(G=>(G.business_unit||"").toLowerCase()==="med-spa")&&e.jsxs(e.Fragment,{children:[" ","For Med Spa visits, please"," ",e.jsx(be,{to:"/medspa-intake",className:"font-bold underline",style:{color:"#800020"},children:"complete your confidential pre-visit intake"})," ","so your clinical consultation is ready when you arrive."]})]})]}),y.length===0&&e.jsxs("div",{className:"bg-white rounded-2xl p-10 text-center",style:{border:"1px dashed rgba(212,175,55,0.4)"},children:[e.jsx(At,{size:32,className:"mx-auto mb-3",style:{color:"#D4AF37"}}),e.jsx("p",{className:"font-semibold mb-1",style:{color:"#3B0A11"},children:"No appointments found"}),e.jsx("p",{className:"text-sm",style:{color:"#7A3A44"},children:"We couldn't find any bookings for this email yet."}),e.jsxs(be,{to:"/",className:"inline-flex items-center gap-2 mt-4 px-5 py-2.5 rounded-lg text-xs font-bold",style:{background:"linear-gradient(135deg, #D4AF37, #B8962E)",color:"#3B0A11"},children:[e.jsx(Ss,{size:13})," Book an Appointment"]})]}),U.length>0&&e.jsxs("div",{className:"mb-8",children:[e.jsx("h2",{className:"text-[11px] font-bold uppercase tracking-[0.25em] mb-4",style:{color:"#800020"},children:"Upcoming Appointments"}),e.jsx("div",{className:"space-y-4",children:U.map(G=>e.jsx(ZE,{b:G,cancellable:!0,onCancel:()=>N(G),onReschedule:()=>R(G)},G.id))})]}),q.length>0&&e.jsxs("div",{children:[e.jsx("h2",{className:"text-[11px] font-bold uppercase tracking-[0.25em] mb-4",style:{color:"#7A3A44"},children:"Past & Cancelled"}),e.jsx("div",{className:"space-y-4",children:q.map(G=>e.jsx(ZE,{b:G,cancellable:!1,onCancel:()=>{},onReschedule:()=>{}},G.id))})]})]})]}),g&&e.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center p-4",style:{background:"rgba(59,10,17,0.6)",backdropFilter:"blur(4px)"},children:e.jsxs("div",{className:"bg-white rounded-2xl max-w-md w-full p-6",style:{boxShadow:"0 24px 64px rgba(0,0,0,0.3)"},children:[e.jsxs("div",{className:"flex items-start gap-3 mb-4",children:[e.jsx("div",{className:"w-10 h-10 rounded-full flex items-center justify-center flex-shrink-0",style:{background:"rgba(220,38,38,0.1)"},children:e.jsx(ve,{size:18,style:{color:"#DC2626"}})}),e.jsxs("div",{children:[e.jsx("h3",{className:"font-bold text-lg",style:{color:"#3B0A11"},children:"Cancel this appointment?"}),e.jsxs("p",{className:"text-sm mt-1",style:{color:"#7A3A44"},children:[g.service_name," â ",B0(g.preferred_date),g.preferred_time?` at ${g.preferred_time}`:"",". Your time slot will be released and a confirmation email sent."]})]})]}),e.jsx("div",{className:"rounded-lg p-3 mb-5 text-xs",style:{background:"rgba(212,175,55,0.06)",border:"1px solid rgba(212,175,55,0.2)",color:"#5A1A24"},children:"Per our policy, cancellations within 24 hours may incur a fee. For refunds, please contact us at (360) 392-8243."}),e.jsxs("div",{className:"flex gap-3",children:[e.jsx("button",{onClick:()=>N(null),disabled:b,className:"flex-1 py-3 rounded-xl text-sm font-semibold disabled:opacity-50",style:{border:"1px solid #E8DDD0",color:"#7A3A44"},children:"Keep Appointment"}),e.jsxs("button",{onClick:M,disabled:b,className:"flex-1 py-3 rounded-xl text-sm font-bold text-white transition-all disabled:opacity-50 flex items-center justify-center gap-2",style:{background:"#DC2626"},children:[b?e.jsx(de,{size:14,className:"animate-spin"}):e.jsx(Ke,{size:14}),"Cancel It"]})]})]})}),j&&e.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center p-4 overflow-y-auto",style:{background:"rgba(59,10,17,0.6)",backdropFilter:"blur(4px)"},children:e.jsxs("div",{className:"bg-white rounded-2xl max-w-lg w-full p-6 my-8",style:{boxShadow:"0 24px 64px rgba(0,0,0,0.3)"},children:[e.jsxs("div",{className:"flex items-start justify-between mb-4",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"font-bold text-lg",style:{color:"#3B0A11",fontFamily:"'Playfair Display', Georgia, serif"},children:"Reschedule Appointment"}),e.jsxs("p",{className:"text-xs mt-0.5",style:{color:"#7A3A44"},children:[j.service_name," · currently ",B0(j.preferred_date),j.preferred_time?` at ${j.preferred_time}`:""]})]}),e.jsx("button",{onClick:()=>{S(null),E(null)},className:"w-8 h-8 rounded-lg flex items-center justify-center flex-shrink-0",style:{border:"1px solid #E8DDD0",color:"#7A3A44"},children:e.jsx(Ke,{size:16})})]}),e.jsx(qre,{campus:w,onCampusChange:_,selectedSlot:C,onSlotChange:E,serviceName:j.service_name,serviceType:zre({name:j.service_name,categoryId:j.service_category})}),e.jsxs("div",{className:"flex gap-3 mt-6",children:[e.jsx("button",{onClick:()=>{S(null),E(null)},disabled:P,className:"flex-1 py-3 rounded-xl text-sm font-semibold disabled:opacity-50",style:{border:"1px solid #E8DDD0",color:"#7A3A44"},children:"Keep Current Time"}),e.jsxs("button",{onClick:T,disabled:!C||P,className:"flex-1 py-3 rounded-xl text-sm font-bold text-white transition-all disabled:opacity-50 flex items-center justify-center gap-2",style:{background:"linear-gradient(135deg, #800020, #5A0018)"},children:[P?e.jsx(de,{size:14,className:"animate-spin"}):e.jsx(zi,{size:14}),"Confirm New Time"]})]})]})})]})},ZE=({b:t,cancellable:s,onCancel:n,onReschedule:a})=>{const r=VE[t.status]||VE.paid,i=(t.business_unit||"").toLowerCase()==="med-spa";return e.jsxs("div",{className:"bg-white rounded-2xl p-5",style:{border:"1px solid rgba(212,175,55,0.2)",boxShadow:"0 6px 20px rgba(59,10,17,0.06)"},children:[e.jsxs("div",{className:"flex items-start justify-between gap-3 mb-3",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("h3",{className:"font-bold text-lg leading-tight",style:{color:"#3B0A11",fontFamily:"'Playfair Display', Georgia, serif"},children:t.service_name}),e.jsxs("div",{className:"flex items-center gap-2 mt-0.5 flex-wrap",children:[e.jsxs("span",{className:"inline-flex items-center gap-1 px-2 py-0.5 rounded-full text-[10px] font-bold",style:i?{background:"rgba(13,148,136,0.1)",color:"#0F766E",border:"1px solid rgba(13,148,136,0.3)"}:{background:"rgba(212,175,55,0.1)",color:"#9A7B1A",border:"1px solid rgba(212,175,55,0.3)"},children:[i?e.jsx(Sa,{size:10}):e.jsx(Ss,{size:10}),i?"Zorganics Med Spa":"Zora's Styling Salon"]}),t.service_category&&e.jsx("span",{className:"text-[11px]",style:{color:"#7A3A44"},children:t.service_category})]})]}),e.jsxs("span",{className:"inline-flex items-center gap-1 px-2.5 py-1 rounded-full text-[11px] font-bold flex-shrink-0",style:{background:r.bg,color:r.text},children:[r.icon," ",r.label]})]}),i&&s&&e.jsxs(be,{to:"/medspa-intake",className:"mb-3 flex items-center gap-2 rounded-lg px-3 py-2 text-[11px] font-semibold transition-colors hover:bg-teal-50",style:{background:"rgba(13,148,136,0.05)",border:"1px dashed rgba(13,148,136,0.35)",color:"#0F766E"},children:[e.jsx(mn,{size:13}),"Complete your confidential pre-visit intake before your consultation â"]}),e.jsxs("div",{className:"grid sm:grid-cols-2 gap-2.5 mb-3",children:[e.jsxs("div",{className:"flex items-center gap-2 text-xs",style:{color:"#5A1A24"},children:[e.jsx(At,{size:13,style:{color:"#D4AF37"}})," ",B0(t.preferred_date)]}),t.preferred_time&&e.jsxs("div",{className:"flex items-center gap-2 text-xs",style:{color:"#5A1A24"},children:[e.jsx(dt,{size:13,style:{color:"#D4AF37"}})," ",t.preferred_time]}),t.campus&&e.jsxs("div",{className:"flex items-center gap-2 text-xs",style:{color:"#5A1A24"},children:[e.jsx(zt,{size:13,style:{color:"#D4AF37"}})," ",t.campus," Campus"]}
1287),t.stylist_name&&e.jsxs("div",{className:"flex items-center gap-2 text-xs",style:{color:"#5A1A24"},children:[e.jsx(Qe,{size:13,style:{color:"#D4AF37"}})," ",t.stylist_name]})]}),e.jsxs("div",{className:"flex items-center justify-between pt-3 gap-2 flex-wrap",style:{borderTop:"1px solid rgba(212,175,55,0.15)"},children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("span",{className:"font-mono text-xs font-bold",style:{color:"#800020"},children:t.booking_reference}),e.jsx("span",{className:"font-display text-lg font-bold",style:{color:"#3B0A11"},children:Hre(t.service_price_cents)})]}),s&&e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("button",{onClick:a,className:"inline-flex items-center gap-1.5 px-4 py-2 rounded-lg text-xs font-bold transition-all hover:shadow-sm",style:{background:"rgba(212,175,55,0.1)",color:"#9A7B1A",border:"1px solid rgba(212,175,55,0.35)"},children:[e.jsx(zi,{size:12})," Reschedule"]}),e.jsxs("button",{onClick:n,className:"inline-flex items-center gap-1.5 px-4 py-2 rounded-lg text-xs font-bold transition-all hover:shadow-sm",style:{background:"rgba(220,38,38,0.06)",color:"#B91C1C",border:"1px solid rgba(220,38,38,0.25)"},children:[e.jsx(Ke,{size:12})," Cancel"]})]})]})]})},Vre={active:{label:"Active Campus",cls:"bg-emerald-50 text-emerald-700 border-emerald-200",dot:"bg-emerald-500"},coming:{label:"Coming â August 2026",cls:"bg-amber-50 text-amber-700 border-amber-200",dot:"bg-amber-500"},"seo-retained":{label:"Retained for SEO (non-canonical)",cls:"bg-slate-100 text-slate-600 border-slate-300",dot:"bg-slate-400"}},xj=["bellingham","renton"],Zre=new Date().getUTCFullYear();function Yre(t,s){return s?t.openedYear>=Zre&&t.slug!=="bellingham"?"coming":"active":"seo-retained"}function Kre(t){return[t.street,t.suite,`${t.city}, ${t.state} ${t.postalCode}`.trim()].filter(Boolean).join(", ")}const Qre=()=>{const[t,s]=d.useState([]),[n,a]=d.useState(!0),[r,i]=d.useState(null),o=async()=>{a(!0),i(null);try{const{data:m,error:x}=await O.from("z_franchise_tenants").select("code, name, city, is_hq, is_active").order("is_hq",{ascending:!1});if(x)throw x;s(m||[])}catch(m){i((m==null?void 0:m.message)||"Failed to load franchise tenants"),s([])}finally{a(!1)}};d.useEffect(()=>{o()},[]);const l=d.useMemo(()=>Th.map(m=>{const x=xj.includes(m.slug);return{slug:m.slug,city:m.city,status:Yre(m,x),inCanonicalList:x,directoryAddress:Kre(m),openedYear:m.openedYear,openingDate:m.openingDate}}),[]),c=d.useMemo(()=>II(),[]),u=d.useMemo(()=>{const m=[],x=t.find(N=>N.code==="KIR-01"||/kirkland/i.test(N.name||"")||/kirkland/i.test(N.city||""));m.push({ok:!x,label:"Renton tenant code renamed (no KIR-01 / Kirkland)",detail:x?`Found legacy tenant: ${x.code} â ${x.name}`:"Franchise tenants read BEL-HQ · REN-01 · SEA-01."});const h=t.find(N=>N.code==="REN-01");m.push({ok:!n&&!!h,label:"Renton operator tenant present (REN-01)",detail:h?`${h.code} â ${h.name} (${h.city})`:n?"Loading franchise tenantsâ¦":"REN-01 tenant not found in z_franchise_tenants."});const y=c.length===xj.length;m.push({ok:y,label:`Canonical campus count = ${xj.length} (Bellingham + Renton)`,detail:`getCampuses() returns ${BK()} campus card(s): ${c.map(N=>N.name).join(", ")}.`});const v=c.some(N=>/seattle/i.test(N.name));m.push({ok:!v,label:"Seattle excluded from canonical brand copy",detail:v?"Seattle is leaking into the Our Story campus cards â remove it.":"Seattle retained only for the /locations/seattle SEO route + JSON-LD."});const g=Th.some(N=>/1126\s+forest/i.test(N.street||"")||/1126\s+forest/i.test(N.facilityNarrative||""));return m.push({ok:!g,label:"Retired 1126 Forest St flagship scrubbed",detail:g?"A 1126 Forest St reference still exists in the location directory.":"No retired flagship HQ narrative found in the directory."}),m},[t,n,c]),p=u.every(m=>m.ok);return e.jsxs("div",{className:"min-h-screen bg-gradient-to-b from-slate-50 to-white",children:[e.jsx("div",{className:"bg-gradient-to-r from-slate-900 via-slate-800 to-slate-900 text-white",children:e.jsxs("div",{className:"max-w-6xl mx-auto px-4 py-8",children:[e.jsxs(be,{to:"/",className:"inline-flex items-center gap-1.5 text-white/60 hover:text-white text-sm mb-4 transition-colors",children:[e.jsx(Je,{size:14})," Back to site"]}),e.jsxs("div",{className:"flex flex-col lg:flex-row lg:items-center justify-between gap-4",children:[e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[e.jsx(Bo,{size:16,className:"text-amber-400"}),e.jsx("span",{className:"text-xs font-bold text-amber-400 uppercase tracking-widest",children:"Campus Footprint Audit"})]}),e.jsx("h1",{className:"font-display text-2xl lg:text-3xl font-bold",children:"Footprint Realignment Verification"}),e.jsx("p",{className:"text-white/60 text-sm mt-1 max-w-2xl",children:"Reconciles the location directory, the canonical brand list, and the franchise operator tenants into one audit-ready view."})]}),e.jsxs("button",{onClick:o,className:"inline-flex items-center gap-2 px-4 py-2.5 bg-white/10 hover:bg-white/20 border border-white/20 rounded-xl text-sm font-semibold transition-colors self-start",children:[e.jsx(Be,{size:14})," Re-run Audit"]})]})]})}),e.jsxs("div",{className:"max-w-6xl mx-auto px-4 py-8 space-y-8",children:[e.jsxs("div",{className:`rounded-2xl border p-5 flex items-start gap-3 ${p?"bg-emerald-50 border-emerald-200":"bg-amber-50 border-amber-200"}`,children:[p?e.jsx(Ie,{size:22,className:"text-emerald-600 flex-shrink-0 mt-0.5"}):e.jsx(ve,{size:22,className:"text-amber-600 flex-shrink-0 mt-0.5"}),e.jsxs("div",{children:[e.jsx("p",{className:`text-sm font-bold ${p?"text-emerald-900":"text-amber-900"}`,children:p?"Footprint realignment verified â all checks pass.":"Footprint drift detected â review the flagged checks below."}),e.jsx("p",{className:`text-xs mt-0.5 ${p?"text-emerald-700":"text-amber-700"}`,children:"Active footprint: Bellingham HQ (active) · Renton (Coming August 2026) · Seattle (SEO-retained). Internal B2B operator codes: BEL-HQ · REN-01 · SEA-01."})]})]}),e.jsx("div",{className:"grid grid-cols-2 lg:grid-cols-4 gap-4",children:[{label:"Directory Locations",value:Th.length,icon:zt,tint:"text-blue-600 bg-blue-50"},{label:"Canonical Campuses",value:c.length,icon:Zl,tint:"text-amber-600 bg-amber-50"},{label:"Franchise Tenants",value:n?"â":t.length,icon:Ws,tint:"text-purple-600 bg-purple-50"},{label:"Checks Passing",value:`${u.filter(m=>m.ok).length}/${u.length}`,icon:pt,tint:"text-emerald-600 bg-emerald-50"}
1287].map(m=>e.jsxs("div",{className:"bg-white rounded-xl border border-gray-100 p-5",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[e.jsx("div",{className:`w-9 h-9 rounded-lg flex items-center justify-center ${m.tint}`,children:e.jsx(m.icon,{size:18})}),e.jsx("span",{className:"text-xs text-gray-400",children:m.label})]}),e.jsx("p",{className:"font-mono text-2xl font-bold text-gray-900",children:m.value})]},m.label))}),e.jsxs("div",{className:"bg-white rounded-2xl border border-gray-100 overflow-hidden",children:[e.jsxs("div",{className:"p-4 border-b border-gray-100 flex items-center gap-2 bg-gradient-to-r from-gray-50 to-white",children:[e.jsx(Bt,{size:16,className:"text-slate-500"}),e.jsx("h2",{className:"font-semibold text-gray-900",children:"Realignment Checks"})]}),e.jsx("div",{className:"divide-y divide-gray-50",children:u.map((m,x)=>e.jsxs("div",{className:"px-5 py-4 flex items-start gap-3",children:[m.ok?e.jsx(pt,{size:18,className:"text-emerald-500 flex-shrink-0 mt-0.5"}):e.jsx(ve,{size:18,className:"text-amber-500 flex-shrink-0 mt-0.5"}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"text-sm font-semibold text-gray-900",children:m.label}),e.jsx("p",{className:"text-xs text-gray-500 mt-0.5",children:m.detail})]}),e.jsx("span",{className:`px-2 py-0.5 rounded-full text-[10px] font-bold border flex-shrink-0 ${m.ok?"bg-emerald-50 text-emerald-700 border-emerald-200":"bg-amber-50 text-amber-700 border-amber-200"}`,children:m.ok?"PASS":"REVIEW"})]},x))})]}),e.jsxs("div",{className:"bg-white rounded-2xl border border-gray-100 overflow-hidden",children:[e.jsxs("div",{className:"p-4 border-b border-gray-100 flex items-center gap-2 bg-gradient-to-r from-gray-50 to-white",children:[e.jsx(zt,{size:16,className:"text-blue-500"}),e.jsx("h2",{className:"font-semibold text-gray-900",children:"Location Directory"}),e.jsx("span",{className:"ml-auto text-xs text-gray-400",children:"src/data/locations.ts · /locations/[slug]"})]}),e.jsx("div",{className:"overflow-x-auto",children:e.jsxs("table",{className:"w-full",children:[e.jsx("thead",{children:e.jsxs("tr",{className:"bg-gray-50",children:[e.jsx("th",{className:"text-left px-4 py-3 text-[10px] font-bold text-gray-500 uppercase",children:"City"}),e.jsx("th",{className:"text-left px-4 py-3 text-[10px] font-bold text-gray-500 uppercase",children:"Slug"}),e.jsx("th",{className:"text-left px-4 py-3 text-[10px] font-bold text-gray-500 uppercase",children:"Address"}),e.jsx("th",{className:"text-left px-4 py-3 text-[10px] font-bold text-gray-500 uppercase",children:"Canonical"}),e.jsx("th",{className:"text-left px-4 py-3 text-[10px] font-bold text-gray-500 uppercase",children:"Status"})]})}),e.jsx("tbody",{className:"divide-y divide-gray-50",children:l.map(m=>{const x=Vre[m.status];return e.jsxs("tr",{className:"hover:bg-gray-50/50",children:[e.jsx("td",{className:"px-4 py-3",children:e.jsx(be,{to:`/locations/${m.slug}`,className:"text-sm font-semibold text-gray-900 hover:text-blue-600",children:m.city})}),e.jsx("td",{className:"px-4 py-3 font-mono text-xs text-gray-500",children:m.slug}),e.jsx("td",{className:"px-4 py-3 text-xs text-gray-600 max-w-xs truncate",children:m.directoryAddress}),e.jsx("td",{className:"px-4 py-3",children:m.inCanonicalList?e.jsx("span",{className:"text-[10px] font-bold text-emerald-700 bg-emerald-50 px-2 py-0.5 rounded-full border border-emerald-200",children:"In Brand Copy"}):e.jsx("span",{className:"text-[10px] font-bold text-slate-600 bg-slate-100 px-2 py-0.5 rounded-full border border-slate-300",children:"SEO Only"})}),e.jsx("td",{className:"px-4 py-3",children:e.jsxs("span",{className:`inline-flex items-center gap-1.5 px-2 py-0.5 rounded-full text-[10px] font-bold border ${x.cls}`,children:[e.jsx("span",{className:`w-1.5 h-1.5 rounded-full ${x.dot}`}),x.label]})})]},m.slug)})})]})})]}),e.jsxs("div",{className:"bg-white rounded-2xl border border-gray-100 overflow-hidden",children:[e.jsxs("div",{className:"p-4 border-b border-gray-100 flex items-center gap-2 bg-gradient-to-r from-gray-50 to-white",children:[e.jsx($i,{size:16,className:"text-purple-500"}),e.jsx("h2",{className:"font-semibold text-gray-900",children:"Franchise Operator Tenants"}),e.jsx("span",{className:"ml-auto text-xs text-gray-400",children:"z_franchise_tenants"})]}),n?e.jsx("div",{className:"flex items-center justify-center py-12",children:e.jsx(de,{size:24,className:"text-purple-500 animate-spin"})}):r?e.jsx("div",{className:"p-6 text-center text-sm text-red-600",children:r}):t.length===0?e.jsx("div",{className:"p-6 text-center text-sm text-gray-400",children:"No tenants found."}):e.jsx("div",{className:"overflow-x-auto",children:e.jsxs("table",{className:"w-full",children:[e.jsx("thead",{children:e.jsxs("tr",{className:"bg-gray-50",children:[e.jsx("th",{className:"text-left px-4 py-3 text-[10px] font-bold text-gray-500 uppercase",children:"Code"}),e.jsx("th",{className:"text-left px-4 py-3 text-[10px] font-bold text-gray-500 uppercase",children:"Name"}),e.jsx("th",{className:"text-left px-4 py-3 text-[10px] font-bold text-gray-500 uppercase",children:"City"}),e.jsx("th",{className:"text-left px-4 py-3 text-[10px] font-bold text-gray-500 uppercase",children:"Role"})]})}),e.jsx("tbody",{className:"divide-y divide-gray-50",children:t.map(m=>{const x=m.code==="KIR-01"||/kirkland/i.test(m.name||"");return e.jsxs("tr",{className:x?"bg-red-50/50":"hover:bg-gray-50/50",children:[e.jsx("td",{className:"px-4 py-3 font-mono text-xs font-bold text-gray-900",children:m.code}),e.jsx("td",{className:"px-4 py-3 text-sm text-gray-700",children:m.name}),e.jsx("td",{className:"px-4 py-3 text-sm text-gray-600",children:m.city}),e.jsxs("td",{className:"px-4 py-3",children:[m.is_hq?e.jsxs("span",{className:"inline-flex items-center gap-1 text-[10px] font-bold text-amber-700 bg-amber-50 px-2 py-0.5 rounded-full border border-amber-200",children:[e.jsx(Zl,{size:10})," HQ"]}):e.jsx("span",{className:"text-[10px] font-bold text-blue-700 bg-blue-50 px-2 py-0.5 rounded-full border border-blue-200",children:"Branch"}),x&&e.jsx("span",{className:"ml-2 text-[10px] font-bold text-red-700 bg-red-50 px-2 py-0.5 rounded-full border border-red-200",children:"LEGACY"})]})]},m.code)})})]})})]})]})]})},YE={dashboard_load:"Dashboard Load",view_student_detail:"Viewed Student Detail"},Jre=()=>{const t=Za(),{user:s}
1287=kn(),[n,a]=d.useState([]),[r,i]=d.useState({}),[o,l]=d.useState(!0),[c,u]=d.useState(""),[p,m]=d.useState(!1),[x,h]=d.useState(""),[y,v]=d.useState("all"),g=d.useCallback(async()=>{if(l(!0),u(""),m(!1),!s){m(!0),l(!1);return}try{const{data:w,error:_}=await O.functions.invoke("ferpa-audit-log",{body:{userId:s.id,email:s.email}});if(_){const C=_==null?void 0:_.context,E=C==null?void 0:C.status;if(E===401||E===403){m(!0),l(!1);return}throw _}if(w!=null&&w.error){if(w.error==="FORBIDDEN"||w.error==="UNAUTHORIZED"){m(!0),l(!1);return}throw new Error(w.message||"Failed to load access log.")}a((w==null?void 0:w.logs)||[]),i((w==null?void 0:w.counselors)||{})}catch(w){u((w==null?void 0:w.message)||"Failed to load access log.")}l(!1)},[s]);d.useEffect(()=>{g()},[g]);const N=w=>{var _;return w&&((_=r[w])==null?void 0:_.name)||(w?`Counselor ${w.slice(0,8)}`:"Unknown")},b=w=>{var _;return w&&((_=r[w])==null?void 0:_.institution_name)||"â"},f=d.useMemo(()=>n.filter(w=>{if(y!=="all"&&w.action!==y)return!1;if(!x.trim())return!0;const _=x.toLowerCase();return N(w.counselor_id).toLowerCase().includes(_)||b(w.counselor_id).toLowerCase().includes(_)||(w.student_id||"").toLowerCase().includes(_)||(w.ip||"").toLowerCase().includes(_)||w.action.toLowerCase().includes(_)}),[n,x,y,r]),j=d.useMemo(()=>{const w=n.filter(E=>E.action==="view_student_detail").length,_=n.filter(E=>E.action==="dashboard_load").length,C=new Set(n.map(E=>E.counselor_id).filter(Boolean)).size;return{total:n.length,detail:w,loads:_,counselorCount:C}},[n]),S=()=>{const w=["Timestamp (UTC)","Counselor","Institution","Counselor ID","Action","Student ID","IP Address"],_=D=>`"${String(D??"").replace(/"/g,'""')}"`,C=f.map(D=>[new Date(D.timestamp).toISOString(),N(D.counselor_id),b(D.counselor_id),D.counselor_id||"",YE[D.action]||D.action,D.student_id||"",D.ip||""].map(_).join(",")),E=[w.map(_).join(","),...C].join(`\r 1288`),P=new Blob([E],{type:"text/csv;charset=utf-8;"}),F=URL.createObjectURL(P),I=document.createElement("a");I.href=F,I.download=`ferpa-access-log-${new Date().toISOString().slice(0,10)}.csv`,document.body.appendChild(I),I.click(),document.body.removeChild(I),URL.revokeObjectURL(F)};return p?e.jsx("div",{className:"min-h-screen bg-gray-50 flex items-center justify-center px-4",children:e.jsxs("div",{className:"max-w-md w-full bg-white rounded-2xl border border-gray-100 shadow-sm p-8 text-center",children:[e.jsx("div",{className:"w-16 h-16 rounded-2xl bg-red-50 flex items-center justify-center mx-auto mb-4",children:e.jsx(Xe,{size:28,className:"text-red-400"})}),e.jsx("h2",{className:"text-lg font-bold text-gray-900 mb-1",children:"Reviewer Access Required"}),e.jsx("p",{className:"text-sm text-gray-500 mb-6",children:"Your account does not hold an admin or reviewer role. FERPA access records are restricted and are never delivered to unauthorized clients."}),e.jsxs("button",{onClick:()=>t("/"),className:"inline-flex items-center gap-2 px-5 py-2.5 bg-gray-900 text-white rounded-xl text-sm font-semibold hover:bg-gray-800",children:[e.jsx(Je,{size:16})," Back to site"]})]})}):e.jsx("div",{className:"min-h-screen bg-gray-50",children:e.jsxs("div",{className:"max-w-6xl mx-auto px-4 py-8",children:[e.jsxs("div",{className:"flex flex-col md:flex-row md:items-center justify-between gap-4 mb-6",children:[e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx("button",{onClick:()=>t("/"),className:"p-2 rounded-lg border border-gray-200 bg-white text-gray-500 hover:bg-gray-100",title:"Back to site",children:e.jsx(Je,{size:18})}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"w-12 h-12 rounded-2xl bg-gradient-to-br from-indigo-500 to-indigo-700 flex items-center justify-center text-white shadow-lg",children:e.jsx(Ie,{size:24})}),e.jsxs("div",{children:[e.jsx("h1",{className:"text-2xl font-bold text-gray-900",children:"FERPA Access Audit Log"}),e.jsx("p",{className:"text-sm text-gray-500",children:"Record of counselor disclosures of student PII (34 CFR 99.32)"})]})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("button",{onClick:g,className:"flex items-center gap-2 px-4 py-2.5 bg-white border border-gray-200 text-gray-600 rounded-xl text-sm font-medium hover:bg-gray-50",children:[e.jsx(Be,{size:16,className:o?"animate-spin":""})," Refresh"]}),e.jsxs("button",{onClick:S,disabled:f.length===0,className:"flex items-center gap-2 px-4 py-2.5 bg-indigo-600 text-white rounded-xl text-sm font-semibold shadow hover:bg-indigo-700 disabled:opacity-50",children:[e.jsx(us,{size:16})," Export CSV"]})]})]}),e.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-4 mb-6",children:[e.jsxs("div",{className:"bg-white rounded-xl border border-gray-100 p-4 shadow-sm",children:[e.jsx("p",{className:"text-[10px] uppercase tracking-wider text-gray-400 mb-1",children:"Total Events"}),e.jsx("p",{className:"font-mono text-2xl font-bold text-gray-900",children:j.total})]}),e.jsxs("div",{className:"bg-white rounded-xl border border-gray-100 p-4 shadow-sm",children:[e.jsxs("p",{className:"text-[10px] uppercase tracking-wider text-gray-400 mb-1 flex items-center gap-1",children:[e.jsx(ms,{size:11})," Detail Views"]}),e.jsx("p",{className:"font-mono text-2xl font-bold text-indigo-600",children:j.detail})]}),e.jsxs("div",{className:"bg-white rounded-xl border border-gray-100 p-4 shadow-sm",children:[e.jsxs("p",{className:"text-[10px] uppercase tracking-wider text-gray-400 mb-1 flex items-center gap-1",children:[e.jsx(Q_,{size:11})," Dashboard Loads"]}),e.jsx("p",{className:"font-mono text-2xl font-bold text-teal-600",children:j.loads})]}),e.jsxs("div",{className:"bg-white rounded-xl border border-gray-100 p-4 shadow-sm",children:[e.jsx("p",{className:"text-[10px] uppercase tracking-wider text-gray-400 mb-1",children:"Distinct Counselors"}),e.jsx("p",{className:"font-mono text-2xl font-bold text-gray-900",children:j.counselorCount})]})]}),e.jsxs("div",{className:"flex flex-col sm:flex-row gap-3 mb-4",children:[e.jsxs("div",{className:"relative flex-1",children:[e.jsx(Bt,{size:16,className:"absolute left-3 top-1/2 -translate-y-1/2 text-gray-400"}),e.jsx("input",{type:"text",value:x,onChange:w=>h(w.target.value),placeholder:"Search by counselor, institution, student ID, or IP...",className:"w-full pl-10 pr-4 py-2.5 bg-white border border-gray-200 rounded-xl text-sm focus:outline-none focus:ring-2 focus:ring-indigo-500/30 focus:border-indigo-500"})]}),e.jsxs("div",{className:"relative",children:[e.jsx(ei,{size:15,className:"absolute left-3 top-1/2 -translate-y-1/2 text-gray-400 pointer-events-none"}),e.jsxs("select",{value:y,onChange:w=>v(w.target.value),className:"pl-9 pr-8 py-2.5 bg-white border border-gray-200 rounded-xl text-sm focus:outline-none focus:ring-2 focus:ring-indigo-500/30 focus:border-indigo-500 appearance-none",children:[e.jsx("option",{value:"all",children:"All Actions"}),e.jsx("option",{value:"view_student_detail",children:"Student Detail Views"}),e.jsx("option",{value:"dashboard_load",children:"Dashboard Loads"})]})]})]}),e.jsxs("div",{className:"bg-white rounded-2xl border border-gray-100 shadow-sm overflow-hidden",children:[c&&e.jsx("div",{className:"p-4 bg-red-50 border-b border-red-100 text-sm text-red-700",children:c}),e.jsx("div",{className:"overflow-x-auto",children:e.jsxs("table",{className:"w-full",children:[e.jsx("thead",{children:e.jsxs("tr",{className:"bg-gray-50 border-b border-gray-100",children:[e.jsx("th",{className:"text-left px-5 py-3 text-[10px] font-semibold text-gray-500 uppercase tracking-wider",children:"Timestamp (UTC)"}),e.jsx("th",{className:"text-left px-3 py-3 text-[10px] font-semibold text-gray-500 uppercase tracking-wider",children:"Counselor"}),e.jsx("th",{className:"text-left px-3 py-3 text-[10px] font-semibold text-gray-500 uppercase tracking-wider",children:"Action"}),e.jsx("th",{className:"text-left px-3 py-3 text-[10px] font-semibold text-gray-500 uppercase tracking-wider",children:"Student ID"}),e.jsx("th",{className:"text-left px-3 py-3 text-[10px] font-semibold text-gray-500 uppercase tracking-wider",children:"IP"})]})}),e.jsx("tbody",{className:"divide-y divide-gray-50",children:o?e.jsx("tr",{children:e.jsx("td",{colSpan:5,className:"px-5 py-12 text-center text-sm text-gray-400",children:"Loading audit logâ¦"})}):f.length===0?e.jsx("tr",{children:e.jsx("td",{colSpan:5,className:"px-5 py-12 text-center text-sm text-gray-400",children:"No access events match your filters."})}):f.map(w=>e.jsxs("tr",{className:"hover:bg-gray-50/50",children:[e.jsx("td",{className:"px-5 py-3 font-mono text-xs text-gray-600 whitespace-nowrap",children:new Date(w.timestamp).toLocaleStr
1288ing("en-US",{timeZone:"UTC"})}),e.jsxs("td",{className:"px-3 py-3",children:[e.jsx("p",{className:"text-sm font-medium text-gray-900",children:N(w.counselor_id)}),e.jsx("p",{className:"text-[10px] text-gray-400",children:b(w.counselor_id)})]}),e.jsx("td",{className:"px-3 py-3",children:e.jsx("span",{className:`px-2 py-0.5 rounded-full text-[10px] font-bold ${w.action==="view_student_detail"?"bg-indigo-100 text-indigo-700":"bg-teal-100 text-teal-700"}`,children:YE[w.action]||w.action})}),e.jsx("td",{className:"px-3 py-3 font-mono text-xs text-gray-600",children:w.student_id||"â"}),e.jsx("td",{className:"px-3 py-3 font-mono text-xs text-gray-500",children:w.ip||"â"})]},w.id))})]})})]}),e.jsxs("p",{className:"mt-4 text-[11px] text-gray-400",children:["Showing ",f.length," of ",n.length," recorded events. Records are immutable and retained for FERPA audit purposes."]})]})})},U0=["Bellingham Campus","Lynnwood Campus","Renton Campus"],q0=["Master Esthetics","Cosmetology","Esthetics","Manicurist"],fj=["FAFSA","Cash Pay","DVR","WRT","Scholarship"],Ve="#3B0A11",Dx="#FBF6EE",Ft="#C9A24B",gj=t=>`$${((t||0)/100).toLocaleString("en-US",{minimumFractionDigits:2,maximumFractionDigits:2})}`,Xre=t=>{const n={FAFSA:"#2563EB","Cash Pay":"#15803D",DVR:"#7C3AED",WRT:"#B45309",Scholarship:Ft}[t]||Ve;return{backgroundColor:`${n}1A`,color:n,border:`1px solid ${n}55`}},KE=t=>{switch(t){case"Active":return"#15803D";case"Graduated":return Ft;case"Withdrawn":return"#B91C1C";case"Leave of Absence":return"#B45309";default:return Ve}},eie=({students:t,attendanceByStudent:s,gradeAvgByStudent:n={},loading:a})=>{const r=d.useMemo(()=>{const i=t.filter(o=>o.student_status==="Active").length;return{count:t.length,active:i}},[t]);return e.jsxs("section",{className:"rounded-2xl shadow-sm overflow-hidden",style:{backgroundColor:"#FFFDF8",border:`1px solid ${Ft}44`},children:[e.jsxs("header",{className:"px-6 py-4 flex items-center justify-between",style:{background:`linear-gradient(135deg, ${Ve} 0%, #5A1320 100%)`},children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-[11px] font-semibold tracking-[0.18em] uppercase",style:{color:Ft},children:"Zone 1 · Active Roster"}),e.jsx("h2",{className:"text-lg font-bold text-white",children:"Enrolled Student Directory"})]}),e.jsxs("div",{className:"text-right text-white/90 text-sm",children:[e.jsxs("p",{className:"font-semibold",children:[r.count," records"]}),e.jsxs("p",{className:"text-xs text-white/70",children:[r.active," active"]})]})]}),e.jsx("div",{className:"overflow-x-auto",children:e.jsxs("table",{className:"w-full text-sm",children:[e.jsx("thead",{children:e.jsxs("tr",{className:"text-left",style:{color:Ve,borderBottom:`2px solid ${Ft}33`},children:[e.jsx("th",{className:"px-6 py-3 font-semibold",children:"Student Name"}),e.jsx("th",{className:"px-4 py-3 font-semibold",children:"Program"}),e.jsx("th",{className:"px-4 py-3 font-semibold",children:"Funding"}),e.jsx("th",{className:"px-4 py-3 font-semibold",children:"Status"}),e.jsx("th",{className:"px-4 py-3 font-semibold text-right",children:"Attendance"}),e.jsx("th",{className:"px-6 py-3 font-semibold text-right",children:"SAP Standing"})]})}),e.jsx("tbody",{children:a?e.jsx("tr",{children:e.jsx("td",{colSpan:6,className:"px-6 py-10 text-center",style:{color:Ve},children:"Loading rosterâ¦"})}):t.length===0?e.jsx("tr",{children:e.jsx("td",{colSpan:6,className:"px-6 py-10 text-center",style:{color:`${Ve}99`},children:"No students for this campus filter."})}):t.map(i=>{const o=s[i.student_id]??0,l=o>=(i.minimum_attendance_requirement||90),c=n[i.student_id]!=null,u=n[i.student_id]??0,p=!c||u>=(i.minimum_grade_requirement||76),m=l&&p,x=[];return l||x.push("Att <90%"),p||x.push("Grade <76%"),e.jsxs("tr",{className:"transition-colors hover:bg-[#FBF6EE]",style:{borderBottom:"1px solid #00000010"},children:[e.jsxs("td",{className:"px-6 py-3 font-medium",style:{color:Ve},children:[i.student_first_name," ",i.student_last_name,e.jsxs("span",{className:"block text-[11px]",style:{color:`${Ve}80`},children:[i.campus_location," · Cohort ",i.cohort_year??"â"]})]}),e.jsx("td",{className:"px-4 py-3",style:{color:Ve},children:i.program_title}),e.jsx("td",{className:"px-4 py-3",children:e.jsx("span",{className:"inline-block px-2.5 py-1 rounded-full text-[11px] font-semibold",style:Xre(i.funding_type),children:i.funding_type})}),e.jsx("td",{className:"px-4 py-3",children:e.jsxs("span",{className:"inline-flex items-center gap-1.5 text-[12px] font-semibold",style:{color:KE(i.student_status)},children:[e.jsx("span",{className:"w-1.5 h-1.5 rounded-full",style:{backgroundColor:KE(i.student_status)}}),i.student_status]})}),e.jsxs("td",{className:"px-4 py-3 text-right font-medium",style:{color:l?Ve:"#B91C1C"},children:[o.toFixed(0),"%"]}),e.jsx("td",{className:"px-6 py-3 text-right",children:e.jsx("span",{className:"inline-block px-3 py-1 rounded-full text-[12px] font-bold",style:{backgroundColor:m?"#15803D1A":"#B91C1C1A",color:m?"#15803D":"#B91C1C",border:`1px solid ${m?"#15803D55":"#B91C1C55"}`},children:m?`SAP OK${c?` · ${u.toFixed(0)}%`:""}`:`SAP ALERT · ${x.join(" + ")}`})})]},i.student_id)})})]})}),e.jsx("p",{className:"px-6 py-3 text-[11px]",style:{color:`${Ve}80`,borderTop:`1px solid ${Ft}22`},children:"A red SAP ALERT fires the moment a student's cumulative grade average drops below 76.0% or attendance drops below 90.0%."})]})},tie=({open:t,onClose:s,onCreated:n})=>
1288{const[a,r]=d.useState(""),[i,o]=d.useState(""),[l,c]=d.useState(U0[0]),[u,p]=d.useState(q0[0]),[m,x]=d.useState(new Date().toISOString().slice(0,10)),[h,y]=d.useState(fj[0]),[v,g]=d.useState(!1),[N,b]=d.useState(!1),[f,j]=d.useState(null);if(!t)return null;const S=()=>{r(""),o(""),c(U0[0]),p(q0[0]),x(new Date().toISOString().slice(0,10)),y(fj[0]),g(!1),j(null),b(!1)},w=()=>{S(),s()},_=async()=>{if(j(null),!a.trim()||!i.trim()){j("First and last name are required.");return}if(!m){j("Start date is required.");return}if(!v){j("COMPLIANCE HOLD: You must confirm High School Diploma / GED has been physically verified before registering.");return}b(!0);try{const{error:P}=await O.from("core_student_data").insert({campus_location:l,program_title:u,student_first_name:a.trim(),student_last_name:i.trim(),start_date:m,funding_type:h,student_status:"Active"});if(P)throw P;n(),w()}catch(P){j(P.message||"Could not register student."),b(!1)}},C="w-full rounded-lg px-3 py-2 text-sm outline-none",E={border:`1.5px solid ${Ve}30`,color:Ve,backgroundColor:Dx};return e.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center p-4",style:{backgroundColor:"#00000066"},onClick:w,children:e.jsxs("div",{className:"w-full max-w-lg rounded-2xl shadow-2xl overflow-hidden",style:{backgroundColor:"#FFFDF8"},onClick:P=>P.stopPropagation(),children:[e.jsxs("header",{className:"px-6 py-4 flex items-center justify-between",style:{background:`linear-gradient(135deg, ${Ve} 0%, #5A1320 100%)`},children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-[11px] font-semibold tracking-[0.18em] uppercase",style:{color:Ft},children:"Manual Registration"}),e.jsx("h3",{className:"text-lg font-bold text-white",children:"Add New Student"})]}),e.jsx("button",{onClick:w,className:"text-white/70 hover:text-white text-xl leading-none",children:"Ã"})]}),e.jsxs("div",{className:"p-6 space-y-4",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-[12px] font-semibold mb-1",style:{color:Ve},children:"First Name"}),e.jsx("input",{className:C,style:E,value:a,onChange:P=>r(P.target.value)})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-[12px] font-semibold mb-1",style:{color:Ve},children:"Last Name"}),e.jsx("input",{className:C,style:E,value:i,onChange:P=>o(P.target.value)})]})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-[12px] font-semibold mb-1",style:{color:Ve},children:"Campus Location"}),e.jsx("select",{className:C,style:E,value:l,onChange:P=>c(P.target.value),children:U0.map(P=>e.jsx("option",{value:P,children:P},P))})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-[12px] font-semibold mb-1",style:{color:Ve},children:"Program Title"}),e.jsx("select",{className:C,style:E,value:u,onChange:P=>p(P.target.value),children:q0.map(P=>e.jsx("option",{value:P,children:P},P))})]})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-[12px] font-semibold mb-1",style:{color:Ve},children:"Start Date"}),e.jsx("input",{type:"date",className:C,style:E,value:m,onChange:P=>x(P.target.value)})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-[12px] font-semibold mb-1",style:{color:Ve},children:"Funding Type"}),e.jsx("select",{className:C,style:E,value:h,onChange:P=>y(P.target.value),children:fj.map(P=>e.jsx("option",{value:P,children:P},P))})]})]}),e.jsxs("label",{className:"flex items-start gap-3 cursor-pointer rounded-xl p-3",style:{backgroundColor:v?"#16A34A0F":"#B4530910",border:`1px solid ${v?"#16A34A55":"#B4530944"}`},children:[e.jsx("input",{type:"checkbox",checked:v,onChange:P=>{g(P.target.checked),j(null)},className:"mt-0.5 w-4 h-4 accent-[#16A34A]"}),e.jsxs("span",{className:"text-[13px]",style:{color:Ve},children:["I confirm that ",e.jsx("strong",{children:"Proof of High School Diploma / GED has been physically verified."})]})]}),f&&e.jsx("p",{className:"text-[12px] rounded-lg px-3 py-2",style:{backgroundColor:"#B91C1C14",color:"#B91C1C"},children:f}),e.jsxs("div",{className:"flex gap-3 pt-1",children:[e.jsx("button",{onClick:w,className:"flex-1 py-2.5 rounded-xl font-semibold text-sm",style:{border:`1.5px solid ${Ve}33`,color:Ve},children:"Cancel"}),e.jsx("button",{onClick:_,disabled:N||!v,className:"flex-1 py-2.5 rounded-xl font-bold text-sm transition-all",style:{backgroundColor:v?"#16A34A":"#16A34A33",color:v?"#fff":"#ffffff80",cursor:v?"pointer":"not-allowed"},children:N?"Registeringâ¦":"Register Student"})]})]})]})})},sie=({leads:t,loading:s,onChanged:n})=>
1288{const[a,r]=d.useState(null),[i,o]=d.useState(!1),[l,c]=d.useState(!1),[u,p]=d.useState(!1),[m,x]=d.useState(null),[h,y]=d.useState(!1),v=t.filter(j=>j.lead_status==="New Inquiry"||j.lead_status==="Interviewing"),g=v.find(j=>j.lead_id===a)||null,N=j=>{r(j.lead_id),o(j.high_school_diploma_verified),c(j.enrollment_agreement_signed),x(null)},b=!!g&&i&&l&&!u,f=async()=>{if(!(!g||!b)){p(!0),x(null);try{await O.from("prospective_leads").update({high_school_diploma_verified:!0,enrollment_agreement_signed:!0,lead_status:"Promoted"}).eq("lead_id",g.lead_id);const j=g.program_of_interest&&q0.includes(g.program_of_interest)?g.program_of_interest:"Esthetics",{error:S}=await O.from("core_student_data").insert({campus_location:g.campus_location_preference||"Bellingham Campus",program_title:j,student_first_name:g.student_first_name,student_last_name:g.student_last_name,start_date:new Date().toISOString().slice(0,10),funding_type:"Cash Pay",student_status:"Active"});if(S)throw S;x(`${g.student_first_name} ${g.student_last_name} promoted to Active Student.`),r(null),o(!1),c(!1),n()}catch(j){x(`Error: ${j.message||"Could not promote lead."}`)}finally{p(!1)}}};return e.jsxs("section",{className:"grid lg:grid-cols-3 gap-4",children:[e.jsxs("div",{className:"lg:col-span-2 rounded-2xl shadow-sm overflow-hidden",style:{backgroundColor:"#FFFDF8",border:`1px solid ${Ft}44`},children:[e.jsxs("header",{className:"px-6 py-4 flex items-center justify-between",style:{background:`linear-gradient(135deg, ${Ve} 0%, #5A1320 100%)`},children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-[11px] font-semibold tracking-[0.18em] uppercase",style:{color:Ft},children:"Zone 2 · Admissions Holding Queue"}),e.jsxs("h2",{className:"text-lg font-bold text-white",children:["Prospective Leads (",v.length,")"]})]}),e.jsx("button",{onClick:()=>y(!0),className:"px-3 py-2 rounded-lg text-[12px] font-bold",style:{backgroundColor:Ft,color:Ve},children:"+ Add New Student"})]}),e.jsx("div",{className:"divide-y",style:{borderColor:"#00000010"},children:s?e.jsx("p",{className:"px-6 py-10 text-center",style:{color:Ve},children:"Loading queueâ¦"}):v.length===0?e.jsx("p",{className:"px-6 py-10 text-center",style:{color:`${Ve}99`},children:"No pending inquiries."}):v.map(j=>{const S=j.lead_id===a;return e.jsx("button",{onClick:()=>N(j),className:"w-full text-left px-6 py-4 transition-colors",style:{backgroundColor:S?"#FBF6EE":"transparent"},children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsxs("p",{className:"font-semibold",style:{color:Ve},children:[j.student_first_name," ",j.student_last_name]}),e.jsxs("p",{className:"text-[12px]",style:{color:`${Ve}90`},children:[j.program_of_interest||"Undecided"," · ",j.campus_location_preference]}),e.jsxs("p",{className:"text-[11px]",style:{color:`${Ve}70`},children:[j.email_address," · ",j.phone_number]})]}),e.jsx("span",{className:"text-[11px] font-semibold px-2.5 py-1 rounded-full",style:{backgroundColor:`${Ft}22`,color:Ve,border:`1px solid ${Ft}66`},children:j.lead_status})]})},j.lead_id)})})]}),e.jsxs("aside",{className:"rounded-2xl shadow-sm p-6",style:{backgroundColor:Ve,border:`1px solid ${Ft}55`},children:[e.jsx("p",{className:"text-[11px] font-semibold tracking-[0.18em] uppercase mb-1",style:{color:Ft},children:"Compliance Checklist"}),g?e.jsxs(e.Fragment,{children:[e.jsxs("h3",{className:"text-white font-bold text-base mb-4",children:[g.student_first_name," ",g.student_last_name]}),e.jsxs("label",{className:"flex items-start gap-3 mb-3 cursor-pointer",children:[e.jsx("input",{type:"checkbox",checked:i,onChange:j=>o(j.target.checked),className:"mt-1 w-4 h-4 accent-[#C9A24B]"}),e.jsx("span",{className:"text-sm text-white/90",children:"Verify High School Diploma / GED on file"})]}),e.jsxs("label",{className:"flex items-start gap-3 mb-5 cursor-pointer",children:[e.jsx("input",{type:"checkbox",checked:l,onChange:j=>c(j.target.checked),className:"mt-1 w-4 h-4 accent-[#C9A24B]"}),e.jsx("span",{className:"text-sm text-white/90",children:"Enrollment Agreement signed"})]}),e.jsx("button",{onClick:f,disabled:!b,className:"w-full py-3 rounded-xl font-bold text-sm transition-all",style:{backgroundColor:b?"#16A34A":"#16A34A33",color:b?"#FFFFFF":"#FFFFFF80",cursor:b?"pointer":"not-allowed"},children:u?"Promotingâ¦":"Promote to Active Student"}),!i||!l?e.jsx("p",{className:"text-[11px] text-white/60 mt-2 text-center",children:"Both compliance items must be verified to unlock onboarding."}):null]}):e.jsx("p",{className:"text-white/70 text-sm mt-4",children:"Select a lead from the queue to begin verification."}),m&&e.jsx("p",{className:"mt-4 text-[12px] rounded-lg px-3 py-2",style:{backgroundColor:"#FFFFFF14",color:Ft},children:m})]}),e.jsx(tie,{open:h,onClose:()=>y(!1),onCreated:n})]})},nie=t=>{const n={"Deposited to Chase":"#15803D","Paid in Full":"#15803D","Processing ACH":Ft,Invoiced:Ft,Unpaid:"#6B7280",Pending:"#6B7280","Partially Paid":"#B45309","Past Due":"#B91C1C"}[t]||"#6B7280";return{backgroundColor:`${n}1A`,color:n,border:`1px solid ${n}55`}},aie=({students:t,loading:s,onChanged:n})=>{const[a,r]=d.useState(null),[i,o]=d.useState({}
1288),[l,c]=d.useState(null),u=t.filter(m=>(m.tuition_total_cents||0)>0),p=async m=>{const x=(m.tuition_total_cents||0)-(m.tuition_paid_cents||0);if(!(x<=0)){r(m.student_id),c(null);try{const{data:h,error:y}=await O.functions.invoke("sis-generate-invoice",{body:{amount:x,studentName:`${m.student_first_name} ${m.student_last_name}`,studentId:m.student_id}});if(y||h!=null&&h.error||!(h!=null&&h.invoiceId))throw new Error((h==null?void 0:h.error)||(y==null?void 0:y.message)||"Invoice failed");await O.from("core_student_data").update({last_invoice_id:h.invoiceId,payment_status:"Invoiced"}).eq("student_id",m.student_id),o(v=>({...v,[m.student_id]:h.invoiceId})),n()}catch{c(m.student_id)}finally{r(null)}}};return e.jsxs("section",{className:"rounded-2xl shadow-sm overflow-hidden",style:{backgroundColor:"#FFFDF8",border:`1px solid ${Ft}44`},children:[e.jsxs("header",{className:"px-6 py-4",style:{background:`linear-gradient(135deg, ${Ve} 0%, #5A1320 100%)`},children:[e.jsx("p",{className:"text-[11px] font-semibold tracking-[0.18em] uppercase",style:{color:Ft},children:"Zone 3 · Stripe Billing Monitor"}),e.jsx("h2",{className:"text-lg font-bold text-white",children:"Tuition Balances & Secure Invoicing"})]}),e.jsx("div",{className:"overflow-x-auto",children:e.jsxs("table",{className:"w-full text-sm",children:[e.jsx("thead",{children:e.jsxs("tr",{className:"text-left",style:{color:Ve,borderBottom:`2px solid ${Ft}33`},children:[e.jsx("th",{className:"px-6 py-3 font-semibold",children:"Student"}),e.jsx("th",{className:"px-4 py-3 font-semibold text-right",children:"Tuition"}),e.jsx("th",{className:"px-4 py-3 font-semibold text-right",children:"Paid"}),e.jsx("th",{className:"px-4 py-3 font-semibold text-right",children:"Remaining"}),e.jsx("th",{className:"px-4 py-3 font-semibold",children:"Status"}),e.jsx("th",{className:"px-6 py-3 font-semibold text-right",children:"Action"})]})}),e.jsx("tbody",{children:s?e.jsx("tr",{children:e.jsx("td",{colSpan:6,className:"px-6 py-10 text-center",style:{color:Ve},children:"Loading billingâ¦"})}):u.length===0?e.jsx("tr",{children:e.jsx("td",{colSpan:6,className:"px-6 py-10 text-center",style:{color:`${Ve}99`},children:"No tuition records for this filter."})}):u.map(m=>{const x=(m.tuition_total_cents||0)-(m.tuition_paid_cents||0),h=x<=0,y=i[m.student_id]||m.last_invoice_id;return e.jsxs("tr",{style:{borderBottom:"1px solid #00000010"},children:[e.jsxs("td",{className:"px-6 py-3 font-medium",style:{color:Ve},children:[m.student_first_name," ",m.student_last_name,e.jsx("span",{className:"block text-[11px]",style:{color:`${Ve}80`},children:m.program_title})]}),e.jsx("td",{className:"px-4 py-3 text-right",style:{color:Ve},children:gj(m.tuition_total_cents)}),e.jsx("td",{className:"px-4 py-3 text-right",style:{color:"#15803D"},children:gj(m.tuition_paid_cents)}),e.jsx("td",{className:"px-4 py-3 text-right font-bold",style:{color:h?"#15803D":"#B91C1C"},children:gj(Math.max(x,0))}),e.jsx("td",{className:"px-4 py-3",children:(()=>{const g=["Processing ACH","Deposited to Chase","Paid in Full","Unpaid"].includes(m.payment_status)?m.payment_status:y&&!h?"Invoiced":m.payment_status||"Unpaid";return e.jsx("span",{className:"inline-block px-2.5 py-1 rounded-full text-[11px] font-semibold",style:nie(g),children:g})})()}),e.jsxs("td",{className:"px-6 py-3 text-right",children:[h?e.jsx("span",{className:"text-[12px] font-semibold",style:{color:"#15803D"},children:"Settled"}):e.jsx("button",{onClick:()=>p(m),disabled:a===m.student_id,className:"px-3 py-1.5 rounded-lg text-[12px] font-semibold transition-all",style:{backgroundColor:Ve,color:Ft,opacity:a===m.student_id?.6:1},children:a===m.student_id?"Generatingâ¦":"Generate Invoice Link"}),l===m.student_id&&e.jsx("p",{className:"text-[11px] mt-1",style:{color:"#B91C1C"},children:"Stripe not connected yet."}),y&&!h&&l!==m.student_id&&e.jsx("p",{className:"text-[10px] mt-1 font-mono break-all",style:{color:`${Ve}90`},children:y})]})]},m.student_id)})})]})}),e.jsxs("div",{className:"px-6 py-3 flex flex-wrap items-center gap-4 text-[11px]",style:{color:`${Ve}80`,borderTop:`1px solid ${Ft}22`},children:[e.jsxs("span",{className:"inline-flex items-center gap-1.5",children:[e.jsx("span",{className:"w-2.5 h-2.5 rounded-full",style:{backgroundColor:"#6B7280"}}),"Unpaid"]}),e.jsxs("span",{className:"inline-flex items-center gap-1.5",children:[e.jsx("span",{className:"w-2.5 h-2.5 rounded-full",style:{backgroundColor:Ft}}),"Processing ACH"]}),e.jsxs("span",{className:"inline-flex items-center gap-1.5",children:[e.jsx("span",{className:"w-2.5 h-2.5 rounded-full",style:{backgroundColor:"#15803D"}}),"Deposited to Chase"]}),e.jsx("span",{className:"ml-auto",children:"Successful deposits auto-decrement the remaining balance via the sis-payment-webhook."})]})]})},rie=()=>new Date().toISOString().slice(0,10),iie=({students:t})=>
1288{const[s,n]=d.useState("login"),[a,r]=d.useState(""),[i,o]=d.useState(!1),[l,c]=d.useState(null),[u,p]=d.useState(null),m=d.useRef(null);d.useEffect(()=>()=>{m.current&&clearTimeout(m.current)},[]);const x=g=>{const N=g.trim().toLowerCase();return N&&(t.find(b=>b.student_id.toLowerCase()===N)||t.find(b=>b.student_id.toLowerCase().startsWith(N)&&N.length>=6)||t.find(b=>b.student_last_name.toLowerCase()===N)||t.find(b=>`${b.student_first_name} ${b.student_last_name}`.toLowerCase()===N))||null},h=()=>{n("login"),r(""),p(null),c(null),o(!1)},y=(g,N,b)=>{p({name:g,action:N,hours:b}),n("confirm"),m.current&&clearTimeout(m.current),m.current=setTimeout(h,5e3)},v=async g=>{c(null);const N=x(a);if(!N){c("No matching student. Enter a valid Student ID or last name.");return}o(!0);try{const b=rie(),f=new Date().toISOString(),{data:j}=await O.from("clock_hour_ledgers").select("*").eq("student_id",N.student_id).eq("date_logged",b).order("check_in_timestamp",{ascending:!1}).limit(1),S=j&&j[0];if(g==="in"){if(S&&S.check_in_timestamp&&!S.check_out_timestamp){c("Already checked in for this shift. Please check out first."),o(!1);return}const{error:w}=await O.from("clock_hour_ledgers").insert({student_id:N.student_id,date_logged:b,check_in_timestamp:f,daily_accumulated_hours:0});if(w)throw w;y(`${N.student_first_name} ${N.student_last_name}`,"Checked In for Shift")}else{if(!S||!S.check_in_timestamp||S.check_out_timestamp){c("No open shift found. Please check in first."),o(!1);return}const w=new Date(S.check_in_timestamp).getTime(),_=Date.now(),C=Math.round((_-w)/36e5*100)/100,{error:E}=await O.from("clock_hour_ledgers").update({check_out_timestamp:f,daily_accumulated_hours:C}).eq("ledger_id",S.ledger_id);if(E)throw E;y(`${N.student_first_name} ${N.student_last_name}`,"Checked Out for Shift",C)}}catch(b){c(b.message||"Terminal error. Try again."),o(!1)}};return e.jsxs("section",{className:"rounded-2xl shadow-sm overflow-hidden",style:{backgroundColor:"#FFFDF8",border:`1px solid ${Ft}44`},children:[e.jsxs("header",{className:"px-6 py-4",style:{background:`linear-gradient(135deg, ${Ve} 0%, #5A1320 100%)`},children:[e.jsx("p",{className:"text-[11px] font-semibold tracking-[0.18em] uppercase",style:{color:Ft},children:"Front-Desk Terminal · Log Daily Clock Hours"}),e.jsx("h2",{className:"text-lg font-bold text-white",children:"Attendance Clock-In / Clock-Out"}),e.jsx("p",{className:"text-white/70 text-[12px] mt-0.5",children:"NACCAS 90% attendance benchmark · secure 5-second auto-clear"})]}),e.jsx("div",{className:"p-6",children:s==="confirm"&&u?e.jsxs("div",{className:"flex flex-col items-center justify-center py-10 text-center",style:{backgroundColor:"#16A34A0D",borderRadius:16,border:"1px solid #16A34A44"},children:[e.jsx("div",{className:"w-14 h-14 rounded-full flex items-center justify-center mb-3",style:{backgroundColor:"#16A34A"},children:e.jsx("svg",{width:"28",height:"28",viewBox:"0 0 24 24",fill:"none",stroke:"white",strokeWidth:"3",children:e.jsx("path",{d:"M20 6L9 17l-5-5",strokeLinecap:"round",strokeLinejoin:"round"})})}),e.jsx("p",{className:"text-lg font-bold",style:{color:"#15803D"},children:u.action}),e.jsx("p",{className:"text-sm mt-1",style:{color:Ve},children:u.name}),typeof u.hours=="number"&&e.jsxs("p",{className:"text-[13px] mt-2",style:{color:`${Ve}99`},children:["Shift logged: ",e.jsxs("strong",{children:[u.hours.toFixed(2)," hrs"]})]}),e.jsx("p",{className:"text-[11px] mt-4",style:{color:`${Ve}70`},children:"Screen clears automatically for the next studentâ¦"})]}):e.jsxs("div",{className:"max-w-sm mx-auto",children:[e.jsx("label",{className:"block text-sm font-semibold mb-2",style:{color:Ve},children:"Student PIN / ID"}),e.jsx("input",{type:"text",value:a,autoFocus:!0,onChange:g=>{r(g.target.value),c(null)},placeholder:"Enter Student ID or last name",className:"w-full rounded-xl px-4 py-3 text-sm outline-none mb-4",style:{border:`1.5px solid ${Ve}33`,color:Ve,backgroundColor:Dx}}),l&&e.jsx("p",{className:"text-[12px] mb-3 rounded-lg px-3 py-2",style:{backgroundColor:"#B91C1C14",color:"#B91C1C"},children:l}),e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsx("button",{onClick:()=>v("in"),disabled:i||!a.trim(),className:"py-3 rounded-xl font-bold text-sm transition-all",style:{backgroundColor:"#16A34A",color:"#fff",opacity:i||!a.trim()?.5:1},children:i?"â¦":"Check In for Shift"}),e.jsx("button",{onClick:()=>v("out"),disabled:i||!a.trim(),className:"py-3 rounded-xl font-bold text-sm transition-all",style:{backgroundColor:Ve,color:Ft,o
1288pacity:i||!a.trim()?.5:1},children:i?"â¦":"Check Out for Shift"})]})]})})]})},mi="All",oie=({students:t,attendanceByStudent:s})=>{const[n,a]=d.useState(mi),[r,i]=d.useState(mi),o=d.useMemo(()=>{const b=new Set;return t.forEach(f=>{f.cohort_year&&b.add(f.cohort_year)}),Array.from(b).sort((f,j)=>j-f)},[t]),l=d.useMemo(()=>{const b=new Set;return t.forEach(f=>b.add(f.campus_location)),Array.from(b).sort()},[t]),c=d.useMemo(()=>t.filter(b=>(n===mi||String(b.cohort_year)===n)&&(r===mi||b.campus_location===r)),[t,n,r]),u=b=>(s[b.student_id]??0)>=(b.minimum_attendance_requirement||90)?"Satisfactory":"Not Meeting SAP",p=b=>{const f={};return c.forEach(j=>{const S=b(j)||"Unspecified";f[S]=(f[S]||0)+1}),Object.entries(f).sort((j,S)=>S[1]-j[1])},m=p(b=>b.race_category||"Unspecified"),x=p(b=>b.gender_category||"Unspecified"),h=p(b=>b.funding_type),y=p(b=>u(b)),v=()=>{const b=["Student ID","First Name","Last Name","Campus","Program","Cohort Year","Hispanic/Latino","Race Category","Gender","Disability","Veteran","Prior Education","Funding Track","Status","Attendance %","SAP Status"],f=c.map(E=>[E.student_id,E.student_first_name,E.student_last_name,E.campus_location,E.program_title,E.cohort_year??"",E.is_hispanic?"Yes":"No",E.race_category||"",E.gender_category||"",E.has_disability?"Yes":"No",E.is_veteran?"Yes":"No",E.prior_education_level||"",E.funding_type,E.student_status,s[E.student_id]??"",u(E)]),j=E=>`"${String(E).replace(/"/g,'""')}"`,S=[b,...f].map(E=>E.map(j).join(",")).join(`\r 1289`),w=new Blob([S],{type:"text/csv;charset=utf-8;"}),_=URL.createObjectURL(w),C=document.createElement("a");C.href=_,C.download=`IPEDS_NACCAS_${r===mi?"AllCampuses":r.replace(/\s+/g,"")}_${n===mi?"AllCohorts":n}.csv`,C.click(),URL.revokeObjectURL(_)},g=({title:b,data:f})=>e.jsxs("div",{className:"rounded-xl p-4",style:{backgroundColor:Dx,border:`1px solid ${Ft}33`},children:[e.jsx("p",{className:"text-[11px] font-semibold tracking-[0.14em] uppercase mb-2",style:{color:Ft},children:b}),f.length===0?e.jsx("p",{className:"text-[12px]",style:{color:`${Ve}80`},children:"No data"}):f.map(([j,S])=>e.jsxs("div",{className:"flex justify-between text-[13px] py-0.5",style:{color:Ve},children:[e.jsx("span",{children:j}),e.jsx("span",{className:"font-bold",children:S})]},j))]}),N=b=>({backgroundColor:b?Ve:"transparent",color:b?Ft:Ve,border:`1.5px solid ${b?Ve:`${Ve}33`}`});return e.jsxs("section",{className:"rounded-2xl shadow-sm overflow-hidden",style:{backgroundColor:"#FFFDF8",border:`1px solid ${Ft}44`},children:[e.jsxs("header",{className:"px-6 py-4",style:{background:`linear-gradient(135deg, ${Ve} 0%, #5A1320 100%)`},children:[e.jsx("p",{className:"text-[11px] font-semibold tracking-[0.18em] uppercase",style:{color:Ft},children:"Federal Compliance Export · IPEDS / NACCAS"}),e.jsx("h2",{className:"text-lg font-bold text-white",children:"One-Click Audit Controls"})]}),e.jsxs("div",{className:"p-6 space-y-5",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-[12px] font-semibold mb-2",style:{color:Ve},children:"Cohort Year"}),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsx("button",{onClick:()=>a(mi),className:"px-3 py-1.5 rounded-lg text-[12px] font-semibold",style:N(n===mi),children:"All Cohorts"}),o.map(b=>e.jsx("button",{onClick:()=>a(String(b)),className:"px-3 py-1.5 rounded-lg text-[12px] font-semibold",style:N(n===String(b)),children:b},b))]})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-[12px] font-semibold mb-2",style:{color:Ve},children:"Campus Location"}),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsx("button",{onClick:()=>i(mi),className:"px-3 py-1.5 rounded-lg text-[12px] font-semibold",style:N(r===mi),children:"All Campuses"}),l.map(b=>e.jsx("button",{onClick:()=>i(b),className:"px-3 py-1.5 rounded-lg text-[12px] font-semibold",style:N(r===b),children:b},b))]})]}),e.jsxs("div",{className:"grid sm:grid-cols-2 lg:grid-cols-4 gap-3",children:[e.jsx(g,{title:`Race (${c.length} students)`,data:m}),e.jsx(g,{title:"Gender",data:x}),e.jsx(g,{title:"Financial Tracks",data:h}),e.jsx(g,{title:"SAP Status",data:y})]}),e.jsxs("button",{onClick:v,disabled:c.length===0,className:"w-full py-3 rounded-xl font-bold text-sm transition-all flex items-center justify-center gap-2",style:{backgroundColor:Ve,color:Ft,o
1289pacity:c.length===0?.5:1},children:[e.jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:Ft,strokeWidth:"2",children:e.jsx("path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4M7 10l5 5 5-5M12 15V3",strokeLinecap:"round",strokeLinejoin:"round"})}),"Export IPEDS/NACCAS Spreadsheet (",c.length," records)"]})]})]})},lie="https://d64gsuwffb70l.cloudfront.net/69caed6904ed6aca7682413a_1782856594179_1c8c20fd.jpg",cie=t=>{switch(t){case"Active":return 94;case"Graduated":return 97;case"Leave of Absence":return 71;case"Withdrawn":return 58;default:return 90}},die=()=>{const[t,s]=d.useState("All Campuses"),[n,a]=d.useState([]),[r,i]=d.useState([]),[o,l]=d.useState({}),[c,u]=d.useState({}),[p,m]=d.useState(!0),x=async()=>{m(!0);const[{data:y},{data:v},{data:g}]=await Promise.all([O.from("core_student_data").select("*").order("created_at",{ascending:!1}),O.from("prospective_leads").select("*").order("created_at",{ascending:!1}),O.from("clock_hour_ledgers").select("student_id, daily_accumulated_hours, date_logged")]),N=y||[];a(N),i(v||[]);const b={};(g||[]).forEach(j=>{b[j.student_id]=(b[j.student_id]||0)+1});const f={};N.forEach(j=>{b[j.student_id]?f[j.student_id]=Math.min(100,Math.round(b[j.student_id]/20*100)):f[j.student_id]=cie(j.student_status)}),l(f),m(!1)};d.useEffect(()=>{x()},[]);const h=d.useMemo(()=>t==="All Campuses"?n:n.filter(y=>y.campus_location===t),[n,t]);return e.jsxs("div",{className:"min-h-screen",style:{backgroundColor:Dx},children:[e.jsxs("div",{className:"relative h-44 md:h-56 overflow-hidden",children:[e.jsx("img",{src:lie,alt:"Zorganics Institute administration",className:"w-full h-full object-cover"}),e.jsx("div",{className:"absolute inset-0",style:{background:`linear-gradient(90deg, ${Ve}E6 0%, ${Ve}99 60%, transparent 100%)`}}),e.jsxs("div",{className:"absolute inset-0 flex flex-col justify-center px-6 md:px-12",children:[e.jsx("p",{className:"text-[11px] font-semibold tracking-[0.22em] uppercase mb-1",style:{color:Ft},children:"Zorganics Institute of Excellence · Secure SIS"}),e.jsx("h1",{className:"text-2xl md:text-3xl font-bold text-white",children:"Lilly's Administrative Dashboard"}),e.jsx("p",{className:"text-white/80 text-sm mt-1 max-w-xl",children:"Master compliance roster, admissions holding queue, and tuition billing â one unified control surface."})]})]}),e.jsxs("div",{className:"max-w-6xl mx-auto px-4 md:px-6 py-8 space-y-6",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-3 rounded-2xl px-5 py-4 shadow-sm",style:{backgroundColor:"#FFFDF8",border:`1px solid ${Ft}44`},children:[e.jsx("label",{className:"text-sm font-semibold",style:{color:Ve},children:"Global Campus Filter"}),e.jsxs("select",{value:t,onChange:y=>s(y.target.value),className:"rounded-lg px-4 py-2 text-sm font-medium outline-none",style:{border:`1.5px solid ${Ve}40`,color:Ve,backgroundColor:Dx},children:[e.jsx("option",{children:"All Campuses"}),U0.map(y=>e.jsx("option",{value:y,children:y},y))]}),e.jsxs("span",{className:"ml-auto text-[12px]",style:{color:`${Ve}99`},children:["Showing ",h.length," student record(s)"]}),e.jsx(be,{to:"/admin-login",className:"text-[12px] font-semibold underline",style:{color:Ft},children:"Switch account"})]}),e.jsx(iie,{students:n}),e.jsx(eie,{students:h,attendanceByStudent:o,loading:p}),e.jsx(sie,{leads:r,loading:p,onChanged:x}),e.jsx(aie,{students:h,loading:p,onChanged:x}),e.jsx(oie,{students:h,attendanceByStudent:o})]})]})},Jt="#3B0A11",rl="#D4AF37",kg="#FDF8EE";function uie(){sn();const[t]=cc(),s=t.get("token")||"",[n,a]=d.useState(s?"checking":"none"),[r,i]=d.useState(""),[o,l]=d.useState(""),[c,u]=d.useState(""),[p,m]=d.useState(!1),[x,h]=d.useState(""),[y,v]=d.useState(""),[g,N]=d.useState(!1),[b,f]=d.useState(!1),[j,S]=d.useState(!1),[w,_]=d.useState("");d.useEffect(()=>{if(!s)return;let F=!1;return(async()=>{try{const{data:I,error:D}=await O.functions.invoke("student-password-reset",{body:{action:"verify",token:s}});if(F)return;if(D||!(I!=null&&I.success)){a("invalid"),i("invalid_token");return}I.valid?(a("valid"),l(I.studentIdMasked||"")):(a("invalid"),i(I.reason||"invalid_token"))}catch{F||(a("invalid"),i("invalid_token"))}})(),()=>{F=!0}},[s]);const C=async F=>{F.preventDefault(),_("");const I=c.trim();if(I.length<3){_("Please enter your Z-Student ID or the email address on your account.");return}S(!0);try{const{data:D,error:L}=await O.functions.invoke("student-password-reset",{body:{action:"request",identifier:I,origin:window.location.origin}});L?_("Too many reset requests or a temporary issue occurred. Please wait a few minutes and try again."):D!=null&&D.success?m(!0):_((D==null?void 0:D.error)||"Something went wrong. Please try again shortly.")}catch{_("Something went wrong. Please try again shortly.")}finally{S(!1)}},E=async F=>{if(F.preventDefault(),_(""),x.length<6){_("Password must be at least 6 characters.");return}if(x!==y){_("Passwords do not match.");return}S(!0);try{const{data:I,error:D}=await O.functions.invoke("student-password-reset",{body:{action:"complete",token:s,newPassword:x}});
1289D?_("This reset link could not be used. It may have expired â please request a new one."):I!=null&&I.success?f(!0):(_((I==null?void 0:I.error)||"This reset link could not be used. Please request a new one."),((I==null?void 0:I.reason)==="expired"||(I==null?void 0:I.reason)==="already_used"||(I==null?void 0:I.reason)==="invalid_token")&&(a("invalid"),i(I.reason)))}catch{_("Something went wrong. Please try again shortly.")}finally{S(!1)}},P="w-full rounded-xl border border-[#D4AF37]/40 bg-white px-4 py-3 text-sm text-[#3B0A11] placeholder:text-[#3B0A11]/40 focus:outline-none focus:ring-2 focus:ring-[#D4AF37]/60";return e.jsx("div",{className:"min-h-screen flex flex-col",style:{background:`linear-gradient(160deg, ${Jt} 0%, #5A1A24 55%, #2A070C 100%)`},children:e.jsx("div",{className:"flex-1 flex items-center justify-center px-4 py-12",children:e.jsxs("div",{className:"w-full max-w-md",children:[e.jsxs("div",{className:"text-center mb-6",children:[e.jsx("div",{className:"inline-flex items-center justify-center w-14 h-14 rounded-2xl mb-4",style:{background:"rgba(212,175,55,0.15)",border:`1px solid ${rl}55`},children:e.jsx(Ie,{className:"w-7 h-7",style:{color:rl}})}),e.jsx("h1",{className:"text-2xl font-bold",style:{color:kg},children:"Zorganics Student Portal"}),e.jsx("p",{className:"text-sm mt-1",style:{color:`${kg}99`},children:"Secure Password Recovery"})]}),e.jsxs("div",{className:"rounded-2xl shadow-2xl p-6 sm:p-8",style:{background:kg,border:`1px solid ${rl}66`},children:[n==="none"&&!p&&e.jsxs("form",{onSubmit:C,children:[e.jsx("h2",{className:"text-lg font-bold mb-1",style:{color:Jt},children:"Reset your password"}),e.jsx("p",{className:"text-sm mb-5",style:{color:`${Jt}B3`},children:"Enter your Z-Student ID or the email address on your account. If a matching account exists, we'll email a secure reset link to the address on file."}),e.jsx("label",{className:"block text-xs font-semibold uppercase tracking-wide mb-1.5",style:{color:`${Jt}CC`},children:"Z-Student ID or Email"}),e.jsxs("div",{className:"relative mb-4",children:[e.jsx(Ye,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4",style:{color:`${Jt}66`}}),e.jsx("input",{type:"text",value:c,onChange:F=>u(F.target.value),placeholder:"e.g. ZI-2026-001 or [email protected]",className:`${P} pl-10`,autoComplete:"username"})]}),w&&e.jsxs("div",{className:"flex items-start gap-2 rounded-lg px-3 py-2.5 mb-4 text-sm",style:{background:"rgba(180,30,30,0.08)",color:"#8B1A1A",border:"1px solid rgba(180,30,30,0.25)"},children:[e.jsx(ve,{className:"w-4 h-4 mt-0.5 flex-shrink-0"}),e.jsx("span",{children:w})]}),e.jsxs("button",{type:"submit",disabled:j,className:"w-full flex items-center justify-center gap-2 rounded-xl py-3 text-sm font-bold transition-all disabled:opacity-60",style:{background:`linear-gradient(135deg, ${Jt}, #5A1A24)`,color:"#E6D2A0",border:`1px solid ${rl}`},children:[j?e.jsx(de,{className:"w-4 h-4 animate-spin"}):e.jsx(ka,{className:"w-4 h-4"}),j?"Sendingâ¦":"Email Me a Reset Link"]}),e.jsx("p",{className:"text-[11px] mt-4 text-center",style:{color:`${Jt}80`},children:"For security, reset links expire after 30 minutes and can only be used once. Requests are limited to 3 per half hour."})]}),n==="none"&&p&&e.jsxs("div",{className:"text-center py-4",children:[e.jsx(Ue,{className:"w-12 h-12 mx-auto mb-3",style:{color:"#2E7D32"}}),e.jsx("h2",{className:"text-lg font-bold mb-2",style:{color:Jt},children:"Check your email"}),e.jsxs("p",{className:"text-sm",style:{color:`${Jt}B3`},children:["If an account matches ",e.jsx("span",{className:"font-semibold",children:c.trim()}),", a secure reset link has been sent to the email address on file. The link expires in 30 minutes."]}),e.jsx("p",{className:"text-xs mt-4",style:{color:`${Jt}80`},children:"Didn't receive it? Check your spam folder, or contact Student Services if your account has no email on file."})]}),n==="checking"&&e.jsxs("div",{className:"text-center py-8",children:[e.jsx(de,{className:"w-8 h-8 mx-auto animate-spin mb-3",style:{color:rl}}),e.jsx("p",{className:"text-sm",style:{color:`${Jt}B3`},children:"Verifying your reset linkâ¦"})]}),n==="invalid"&&e.jsxs("div",{className:"text-center py-4",children:[e.jsx(ve,{className:"w-12 h-12 mx-auto mb-3",style:{color:"#B45309"}}),e.jsx("h2",{className:"text-lg font-bold mb-2",style:{color:Jt},children:r==="expired"?"This link has expired":r==="already_used"?"This link was already used":"Invalid reset link"}),e.jsx("p",{className:"text-sm mb-5",style:{color:`${Jt}B3`},children:"For your security, reset links are single-use and expire after 30 minutes. Please request a fresh link below."}),e.jsxs(be,{to:"/reset-password",onClick:()=>{a("none"),m(!1),_("")},className:"inline-flex items-center gap-2 rounded-xl px-5 py-2.5 text-sm font-bold",style:{background:`linear-gradient(135deg, ${Jt}, #5A1A24)`,color:"#E6D2A0",border:`1px solid ${rl}`}
1289,children:[e.jsx(ka,{className:"w-4 h-4"})," Request a New Link"]})]}),n==="valid"&&!b&&e.jsxs("form",{onSubmit:E,children:[e.jsx("h2",{className:"text-lg font-bold mb-1",style:{color:Jt},children:"Choose a new password"}),e.jsxs("p",{className:"text-sm mb-5",style:{color:`${Jt}B3`},children:["Resetting the password for Z-Student ID"," ",e.jsx("span",{className:"font-mono font-semibold",children:o||"â¢â¢â¢"}),"."]}),e.jsx("label",{className:"block text-xs font-semibold uppercase tracking-wide mb-1.5",style:{color:`${Jt}CC`},children:"New Password"}),e.jsxs("div",{className:"relative mb-4",children:[e.jsx(Xe,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4",style:{color:`${Jt}66`}}),e.jsx("input",{type:g?"text":"password",value:x,onChange:F=>h(F.target.value),placeholder:"At least 6 characters",className:`${P} pl-10 pr-10`,autoComplete:"new-password"}),e.jsx("button",{type:"button",onClick:()=>N(F=>!F),className:"absolute right-3 top-1/2 -translate-y-1/2","aria-label":g?"Hide password":"Show password",children:g?e.jsx(Md,{className:"w-4 h-4",style:{color:`${Jt}66`}}):e.jsx(ms,{className:"w-4 h-4",style:{color:`${Jt}66`}})})]}),e.jsx("label",{className:"block text-xs font-semibold uppercase tracking-wide mb-1.5",style:{color:`${Jt}CC`},children:"Confirm New Password"}),e.jsxs("div",{className:"relative mb-4",children:[e.jsx(Xe,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4",style:{color:`${Jt}66`}}),e.jsx("input",{type:g?"text":"password",value:y,onChange:F=>v(F.target.value),placeholder:"Re-enter your new password",className:`${P} pl-10`,autoComplete:"new-password"})]}),w&&e.jsxs("div",{className:"flex items-start gap-2 rounded-lg px-3 py-2.5 mb-4 text-sm",style:{background:"rgba(180,30,30,0.08)",color:"#8B1A1A",border:"1px solid rgba(180,30,30,0.25)"},children:[e.jsx(ve,{className:"w-4 h-4 mt-0.5 flex-shrink-0"}),e.jsx("span",{children:w})]}),e.jsxs("button",{type:"submit",disabled:j,className:"w-full flex items-center justify-center gap-2 rounded-xl py-3 text-sm font-bold transition-all disabled:opacity-60",style:{background:`linear-gradient(135deg, ${Jt}, #5A1A24)`,color:"#E6D2A0",border:`1px solid ${rl}`},children:[j?e.jsx(de,{className:"w-4 h-4 animate-spin"}):e.jsx(Ie,{className:"w-4 h-4"}),j?"Updatingâ¦":"Set New Password"]}),e.jsx("p",{className:"text-[11px] mt-4 text-center",style:{color:`${Jt}80`},children:"Your password is protected with bcrypt hashing â it is never stored or transmitted in plain text."})]}),n==="valid"&&b&&e.jsxs("div",{className:"text-center py-4",children:[e.jsx(Ue,{className:"w-12 h-12 mx-auto mb-3",style:{color:"#2E7D32"}}),e.jsx("h2",{className:"text-lg font-bold mb-2",style:{color:Jt},children:"Password updated"}),e.jsx("p",{className:"text-sm mb-5",style:{color:`${Jt}B3`},children:"Your password has been changed successfully. A confirmation email was sent to the address on file. You can now sign in with your new password."}),e.jsxs("a",{href:"/?section=student-portal",className:"inline-flex items-center gap-2 rounded-xl px-5 py-2.5 text-sm font-bold",style:{background:`linear-gradient(135deg, ${Jt}, #5A1A24)`,color:"#E6D2A0",border:`1px solid ${rl}`},children:[e.jsx(Xe,{className:"w-4 h-4"})," Go to Student Portal Sign-In"]})]})]}),e.jsx("div",{className:"text-center mt-6",children:e.jsxs("a",{href:"/",className:"inline-flex items-center gap-1.5 text-sm font-medium hover:underline",style:{color:`${kg}B3`},children:[e.jsx(Je,{className:"w-4 h-4"})," Back to Zorganics Institute"]})})]})})})}const yj=10;function mie(){sn();const[t,s]=d.useState("checking"),[n,a]=d.useState(""),[r,i]=d.useState(""),[o,l]=d.useState(""),[c,u]=d.useState(!1),[p,m]=d.useState(""),[x,h]=d.useState(""),[y,v]=d.useState(!1),[g,N]=d.useState(!1),[b,f]=d.useState(!1),[j,S]=d.useState("");d.useEffect(()=>{let F=!1;const D=(new URLSearchParams(typeof window<"u"?window.location.search.replace(/^\?/,""):"").get("token")||"").trim();return D?(i(D),(async()=>{try{const{data:L,error:V}=await O.functions.invoke("staff-password-reset",{body:{action:"verify",token:D}});if(F)return;
1289if(V||!(L!=null&&L.valid)){a((L==null?void 0:L.reason)==="expired"?"expired":"invalid"),s("invalid");return}s("recovery")}catch{F||(a("invalid"),s("invalid"))}})(),()=>{F=!0}):(s("request"),()=>{F=!0})},[]);const w=d.useCallback(async F=>{F.preventDefault(),S("");const I=o.trim();if(!I||!I.includes("@")){S("Please enter the email address on your Zorganics staff account.");return}f(!0);try{await O.functions.invoke("staff-password-reset",{body:{action:"request",email:I,origin:window.location.origin}})}catch{}finally{f(!1),u(!0)}},[o]),_=d.useCallback(async F=>{if(F.preventDefault(),S(""),p.length<yj){S(`Password must be at least ${yj} characters.`);return}if(p!==x){S("Passwords do not match.");return}f(!0);try{const{data:I,error:D}=await O.functions.invoke("staff-password-reset",{body:{action:"complete",token:r,newPassword:p}});if(D||!(I!=null&&I.success)){S((I==null?void 0:I.error)||"This reset link could not be used. It may have expired â please request a new one."),f(!1);return}m(""),h(""),N(!0)}catch{S("Something went wrong. Please try again shortly.")}finally{f(!1)}},[p,x,r]),C="w-full rounded-xl border bg-white px-4 py-3 text-sm text-gray-900 placeholder:text-gray-400 focus:outline-none focus:ring-2",E={borderColor:`${$}66`},P={background:`linear-gradient(135deg, ${k}, #5A1A24)`,color:Jc,border:`1px solid ${$}`};return e.jsx("div",{className:"min-h-screen flex flex-col",style:{background:`linear-gradient(160deg, ${k} 0%, #5A1A24 55%, #2A070C 100%)`},children:e.jsx("div",{className:"flex-1 flex items-center justify-center px-4 py-12",children:e.jsxs("div",{className:"w-full max-w-md",children:[e.jsxs("div",{className:"text-center mb-6",children:[e.jsx("div",{className:"inline-flex items-center justify-center w-14 h-14 rounded-2xl mb-4",style:{background:"rgba(212,175,55,0.15)",border:`1px solid ${$}55`},children:e.jsx(Ie,{className:"w-7 h-7",style:{color:$}})}),e.jsx("h1",{className:"text-2xl font-bold",style:{color:rd},children:"Zorganics OS â Staff & Administration"}),e.jsx("p",{className:"text-sm mt-1",style:{color:`${rd}B3`},children:"Secure Password Reset"})]}),e.jsxs("div",{className:"rounded-2xl shadow-2xl p-6 sm:p-8",style:{background:rd,border:`1px solid ${$}66`},children:[t==="checking"&&e.jsxs("div",{className:"text-center py-8",children:[e.jsx(de,{className:"w-8 h-8 mx-auto animate-spin mb-3",style:{color:$}}),e.jsx("p",{className:"text-sm text-gray-700",children:"Checking your reset linkâ¦"})]}),t==="request"&&!c&&e.jsxs("form",{onSubmit:w,children:[e.jsx("h2",{className:"text-lg font-bold mb-1",style:{color:k},children:"Reset your password"}),e.jsx("p",{className:"text-sm mb-5 text-gray-700",children:"Enter the email address on your authorized Zorganics staff or administrator account. If it matches an existing account, a secure reset link will be emailed to that address."}),e.jsx("label",{htmlFor:"zos-staff-reset-email",className:"block text-xs font-semibold uppercase tracking-wide mb-1.5 text-gray-700",children:"Email Address"}),e.jsxs("div",{className:"relative mb-4",children:[e.jsx(Ye,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-gray-400"}),e.jsx("input",{id:"zos-staff-reset-email",type:"email",value:o,onChange:F=>l(F.target.value),placeholder:"[email protected]",className:`${C} pl-10`,style:E,autoComplete:"username",disabled:b})]}),j&&e.jsxs("div",{className:"flex items-start gap-2 rounded-lg px-3 py-2.5 mb-4 text-sm",style:{background:"rgba(180,30,30,0.08)",color:"#8B1A1A",border:"1px solid rgba(180,30,30,0.25)"},children:[e.jsx(ve,{className:"w-4 h-4 mt-0.5 flex-shrink-0"}),e.jsx("span",{children:j})]}),e.jsxs("button",{type:"submit",disabled:b,className:"w-full flex items-center justify-center gap-2 rounded-xl py-3 text-sm font-bold transition-all disabled:opacity-60",style:P,children:[b?e.jsx(de,{className:"w-4 h-4 animate-spin"}):e.jsx(ka,{className:"w-4 h-4"}),b?"Sendingâ¦":"Email Me a Reset Link"]}),e.jsx("p",{className:"text-[11px] mt-4 text-center text-gray-500",children:"Reset links are time-limited and single-use. This form never creates an account and is limited to accounts that already exist."})]}),t==="request"&&c&&e.jsxs("div",{className:"text-center py-4",children:[e.jsx(Ue,{className:"w-12 h-12 mx-auto mb-3",style:{color:"#2E7D32"}}),e.jsx("h2",{className:"text-lg font-bold mb-2",style:{color:k},children:"Check your email"}),e.jsx("p",{className:"text-sm text-gray-700",children:"If an authorized Zorganics staff account exists for that address, a secure reset link has been sent to it. Open the link to choose a new password."}),e.jsx("p",{className:"text-xs mt-4 text-gray-500",children:"Didn't receive it? Check your spam folder, or contact a Zorganics administrator."})]}),t==="invalid"&&e.jsxs("div",{className:"text-center py-4",children:[e.jsx(ve,{className:"w-12 h-12 mx-auto mb-3",style:{color:"#B45309"}}),e.jsx("h2",{className:"text-lg font-bold mb-2",style:{color:k},children:n==="expired"?"This link has expired":"Invalid reset link"}),e.jsx("p",{className:"text-sm mb-5 text-gray-700",children:"For security, reset links are single-use and expire shortly after they are issued. Please request a fresh link."}),e.jsxs("button",{type:"button",onClick:()=>{s("request"),u(!1),S(""),a(""),typeof window<"u"&&window.history.replaceState(null,"","/staff/reset-password")},className:"inline-flex items-center gap-2 rounded-xl px-5 py-2.5 text-sm font-bold",style:P,children:[e.jsx(ka,{className:"w-4 h-4"})," Request a New Link"]})]}),t==="recovery"&&!g&&e.jsxs("form",{onSubmit:_,children:[e.jsx("h2",{className:"text-lg font-bold mb-1",style:{color:k},children:"Choose a new password"}),e.jsx("p",{className:"text-sm mb-5 text-gray-700",children:"Set the password for your Zorganics staff account. It is stored only by the authentication provider and is never shown or emailed to anyone."}),e.jsx("label",{htmlFor:"zos-staff-new-password",className:"block text-xs font-semibold uppercase tracking-wide mb-1.5 text-gray-700",children:"New Password"}),e.jsxs("div",{className:"relative mb-4",children:[e.jsx(Xe,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-gray-400"}),e.jsx("input",{id:"zos-staff-new-password",type:y?"text":"password",value:p,onChange:F=>m(F.target.value),placeholder:`At least ${yj} characters`,className:`${C} pl-10 pr-10`,style:E,autoComplete:"new-password",disabled:b}),e.jsx("button",{type:"button",onClick:()=>v(F=>!F),className:"absolute right-3 top-1/2 -translate-y-1/2 text-gray-400 hover:text-gray-700","aria-label":y?"Hide password":"Show password",children:y?e.jsx(Md,{className:"w-4 h-4"}):e.jsx(ms,{className:"w-4 h-4"})})]}),e.jsx("label",{htmlFor:"zos-staff-confirm-password",className:"block text-xs font-semibold uppercase tracking-wide mb-1.5 text-gray-700",children:"Confirm New Password"}),e.jsxs("div",{className:"relative mb-4",children:[e.jsx(Xe,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-gray-400"}),e.jsx("input",{id:"zos-staff-confirm-password",type:y?"text":"password",value:x,onChange:F=>h(F.target.value),placeholder:"Re-enter your new password",className:`${C} pl-10`,style:E,autoComplete:"new-password",disabled:b})]}),j&&e.jsxs("div",{className:"flex items-start gap-2 rounded-lg px-3 py-2.5 mb-4 text-sm",style:{background:"rgba(180,30,30,0.08)",color:"#8B1A1A",border:"1px solid rgba(180,30,30,0.25)"},children:[e.jsx(ve,{className:"w-4 h-4 mt-0.5 flex-shrink-0"}),e.jsx("span",{children:j})]}),e.jsxs("button",{type:"submit",disabled:b,className:"w-full flex items-center justify-center gap-2 rounded-xl py-3 text-sm font-bold transition-all disabled:opacity-60",style:P,children:[b?e.jsx(de,{className:"w-4 h-4 animate-spin"}):e.jsx(Ie,{className:"w-4 h-4"}),b?"Updatingâ¦":"Set New Password"]})]}),t==="recovery"&&g&&e.jsxs("div",{className:"text-center py-4",children:[e.jsx(Ue,{className:"w-12 h-12 mx-auto mb-3",style:{color:"#2E7D32"}}),e.jsx("h2",{className:"text-lg font-bold mb-2",style:{color:k},children:"Password updated"}),e.jsx("p",{className:"text-sm mb-5 text-gray-700",children:"Your password has been changed and this reset link is now used up. Sign in through the staff and administrator login
1289with your new password."}),e.jsxs("a",{href:"/admin-login",className:"inline-flex items-center gap-2 rounded-xl px-5 py-2.5 text-sm font-bold",style:P,children:[e.jsx(Xe,{className:"w-4 h-4"})," Go to Staff Sign-In"]})]})]}),e.jsx("div",{className:"text-center mt-6",children:e.jsxs("a",{href:"/",className:"inline-flex items-center gap-1.5 text-sm font-medium hover:underline",style:{color:`${rd}B3`},children:[e.jsx(Je,{className:"w-4 h-4"})," Back to Zorganics Institute"]})})]})})})}const pie=["Institute","Programs","Admissions & Financial Aid","Contact & Resources"],hie=["Salon & Med Spa","Cosmetics & Shopping","Foundation"],xie=[{id:"bellingham-campus",title:"Bellingham Campus",description:"Our active campus â 410 West Bakerview Rd, Ste 112, Bellingham, WA",href:"/locations/bellingham"},{id:"student-clinic-institute",title:"Student Salon & Clinic",description:"Supervised student services at student pricing, under licensed-instructor supervision",href:"/student-clinic"}],fie={Institute:"The Zorganics Institute of Beauty & Wellness",Programs:"NACCAS-accredited licensed training programs","Admissions & Financial Aid":"Enrollment, tours, applications & required disclosures","Contact & Resources":"Get in touch & public educational resources","Salon & Med Spa":"Guest services â Zoraâs Salon & Zorganics Med Spa","Cosmetics & Shopping":"Vegan clinical beauty products & loyalty",Foundation:"The Zorganics Foundation â 501(c)(3) public charity"},gie=()=>{Ho({title:"Site Map | Zorganics Institute â Programs, Admissions & Resources",description:"Browse the Zorganics Institute site â programs, admissions, apply now, campus tours, financial aid, school catalog, consumer information, the Bellingham campus, the Student Salon & Clinic, and contact."});const t=(n,a)=>a.length===0?null:e.jsxs("section",{className:"rounded-2xl overflow-hidden shadow-sm",style:{background:"#FFFFFF",border:"1px solid rgba(212,175,55,0.25)"},"aria-labelledby":`sitemap-${n.replace(/\W+/g,"-")}`,children:[e.jsxs("div",{className:"px-5 py-3.5",style:{background:"rgba(245,235,208,0.55)",borderBottom:"1px solid rgba(212,175,55,0.2)"},children:[e.jsx("h2",{id:`sitemap-${n.replace(/\W+/g,"-")}`,className:"text-sm font-bold flex items-center gap-1.5",style:{color:"#3B0A11"},children:n}),e.jsx("p",{className:"text-[10px] mt-0.5",style:{color:"#7A3A44"},children:fie[n]})]}),e.jsx("ul",{className:"py-2",children:a.map(r=>e.jsx("li",{children:e.jsxs(be,{to:r.to,className:"flex items-start gap-2.5 px-5 py-2 group transition-colors hover:bg-[rgba(212,175,55,0.07)]",children:[e.jsx(Vt,{size:12,className:"mt-1 flex-shrink-0 transition-transform group-hover:translate-x-0.5",style:{color:"#B8962E"}}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"text-[13px] font-semibold leading-tight transition-colors group-hover:text-[#800020]",style:{color:"#3B0A11"},children:r.title}),e.jsx("p",{className:"text-[10px] mt-0.5 leading-snug text-gray-500",children:r.description})]})]})},r.id))})]},n),s=n=>xI.filter(a=>a.category===n&&a.id!=="student-clinic").map(a=>({id:a.id,title:a.title,description:a.description,to:PY(a)}));return e.jsxs("div",{className:"min-h-screen",style:{backgroundColor:"#FAF6EE"},children:[e.jsx("header",{style:{background:"linear-gradient(135deg, #3B0A11 0%, #5A1A24 100%)",borderBottom:"3px solid #D4AF37"},children:e.jsxs("div",{className:"max-w-6xl mx-auto px-4 lg:px-8 py-10",children:[e.jsxs(be,{to:"/",className:"inline-flex items-center gap-1.5 text-xs font-semibold mb-6 transition-colors hover:text-[#FFF0C2]",style:{color:"#F5D87A"},children:[e.jsx(Je,{size:14})," Back to Zorganics Institute"]}),e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx("div",{className:"w-14 h-14 rounded-2xl flex items-center justify-center flex-shrink-0",style:{background:"rgba(212,175,55,0.15)",border:"1px solid rgba(212,175,55,0.4)"},children:e.jsx(qP,{size:26,style:{color:"#D4AF37"}})}),e.jsxs("div",{children:[e.jsx("h1",{className:"font-display text-3xl lg:text-4xl font-bold",style:{color:"#F7E7CE"},children:"Site Map"}),e.jsx("p",{className:"text-sm mt-1",style:{color:"#E6D2A0"},children:"Programs, admissions, financial aid and campus resources at Zorganics Institute of Beauty & Wellness."})]})]})]})}),e.jsxs("main",{className:"max-w-6xl mx-auto px-4 lg:px-8 py-10",children:[e.jsx("div",{className:"grid sm:grid-cols-2 lg:grid-cols-3 gap-6",children:pie.map(n=>{const a=s(n),r=n==="Institute"?[...a,...xie.map(i=>({...i,to:i.href}))]:a;return t(n,r)})}),e.jsxs("div",{className:"mt-12",children:[e.jsx("h2",{className:"text-sm font-bold uppercase tracking-[0.16em]",style:{color:"#3B0A11"},children:"Related Zorganics Organizations & Services"}),e.jsx("p",{className:"text-xs mt-1 mb-5 leading-relaxed",style:{color:"#7A3A44"},children:"Separate Zorganics businesses and the Zorganics Foundation â distinct from the Instituteâs accredited academic programs."}),e.jsx("div",{className:"grid sm:grid-cols-2 lg:grid-cols-3 gap-6",children:hie.map(n=>t(n,s(n)))})]}),e.jsxs("div",{className:"mt-10 rounded-2xl p-5 flex items-start gap-3",style:{background:"rgba(59,10,17,0.04)",border:"1px solid rgba(212,175,55,0.3)"},children:[e.jsx(Tt,{size:18,className:"flex-shrink-0 mt-0.5",style:{color:"#800020"}}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-bold",style:{color:"#3B0A11"},children:"About secure systems"}),e.jsx("p",{className:"text-xs mt-1 leading-relaxed text-gray-600",children:"This site map lists the public Zorganics Institute experience only. Authenticated systems â the ZLP Student Portal, Z-LMS, Student Information System, Employer Workspace, and Foundation partner tools â require verified credentials and are reached from their own sign-in pages, linked in the site footer. Internal operational and administrative tools are not part of the public website."})]})]})]})]})},yie=["Bellingham","Seattle","Renton"],bie=["Laser & IPL","Radiofrequency (RF)","LED Light Therapy","Micro-current","Oncology Esthetics","Not sure â I
1289would like a consultation"],vie=["Normal","Dry","Oily","Combination","Sensitive","Mature","Acne-prone","Not sure"],jie=[{id:"pregnant-nursing",label:"Currently pregnant or nursing"},{id:"photosensitizing-meds",label:"Taking photosensitizing medications (e.g., retinoids, certain antibiotics)"},{id:"active-skin-condition",label:"Active skin condition in the treatment area (eczema, psoriasis, open lesions)"},{id:"recent-procedures",label:"Cosmetic procedure or deep peel within the last 90 days"},{id:"pacemaker-implants",label:"Pacemaker, defibrillator, or metal implants"},{id:"keloid-scarring",label:"History of keloid scarring"},{id:"cancer-treatment",label:"Currently undergoing (or recently completed) cancer treatment"}],il="#0D9488",gi="#0F172A",fn="#475569",Xa={border:"1.5px solid #E2E8F0",color:gi},er="w-full px-4 py-3 rounded-lg text-sm focus:outline-none focus:ring-2 focus:ring-teal-500 bg-white",Ar="block text-[11px] font-bold uppercase tracking-wider mb-1.5",wie=()=>{sn(),Ho({title:"Med Spa Pre-Visit Intake | Zorganics Med Spa",description:"Confidential pre-visit intake for Zorganics Med Spa clients."});const[t,s]=d.useState({name:"",email:"",phone:"",campus:"Bellingham",bookingReference:"",appointmentDate:"",treatmentInterest:"",skinType:"",goals:"",medications:"",allergies:"",oncologyNotes:""}),[n,a]=d.useState([]),[r,i]=d.useState(!1),[o,l]=d.useState(!1),[c,u]=d.useState(!1),[p,m]=d.useState(!0),[x,h]=d.useState(!1),[y,v]=d.useState(!1),[g,N]=d.useState(""),b=w=>_=>s(C=>({...C,[w]:_.target.value})),f=w=>a(_=>_.includes(w)?_.filter(C=>C!==w):[..._,w]),j=n.includes("cancer-treatment")||t.treatmentInterest==="Oncology Esthetics",S=async w=>{w.preventDefault(),N("");const _=t.email.trim().toLowerCase();if(!t.name.trim()){N("Please enter your full name.");return}if(!/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(_)){N("Please enter a valid email address.");return}if(!t.treatmentInterest){N("Please select the treatment area you are interested in.");return}if(!r||!o||!c){N("Please review and check all three acknowledgments before submitting.");return}h(!0);try{const{error:C}=await O.from("z_medspa_intake").insert({client_name:t.name.trim(),client_email:_,client_phone:t.phone.trim()||null,campus:t.campus,booking_reference:t.bookingReference.trim()||null,treatment_interest:t.treatmentInterest,appointment_date:t.appointmentDate||null,skin_type:t.skinType||null,treatment_goals:t.goals.trim()||null,health_flags:n,medications:t.medications.trim()||null,allergies:t.allergies.trim()||null,oncology_care:j,oncology_notes:t.oncologyNotes.trim()||null,consent_accurate:r,consent_consultation:o,consent_privacy:c,sms_opt_in:p,status:"submitted"});if(C)throw new Error(C.message);fetch("https://famous.ai/api/crm/69caed6904ed6aca7682413a/subscribe",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({email:_,name:t.name.trim()||void 0,phone:t.phone.trim()||void 0,sms_opt_in:p===!0,source:"medspa-intake",tags:["client","med-spa"]})}).catch(()=>{}),v(!0),window.scrollTo({top:0,behavior:"smooth"})}catch(C){N(C.message||"We could not save your intake right now. Please try again or call (360) 392-8243.")}finally{h(!1)}};return e.jsxs("div",{className:"min-h-screen",style:{background:"linear-gradient(135deg, #F8FAFC 0%, #F0FDFA 100%)"},children:[e.jsx("div",{style:{background:"linear-gradient(135deg, #0F172A, #134E4A)"},className:"text-white",children:e.jsxs("div",{className:"max-w-3xl mx-auto px-6 py-8",children:[e.jsxs(be,{to:"/",className:"inline-flex items-center gap-2 text-white/70 hover:text-white text-xs mb-4 transition-colors",children:[e.jsx(Je,{size:14})," Back to Zorganics"]}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"w-12 h-12 rounded-xl flex items-center justify-center",style:{background:"linear-gradient(135deg, #0D9488, #0F766E)"},children:e.jsx(Sa,{size:22,className:"text-white"})}),e.jsxs("div",{children:[e.jsx("h1",{className:"text-2xl font-bold tracking-tight",style:{fontFamily:"'Inter', 'Helvetica Neue', sans-serif"},children:"Med Spa Pre-Visit Intake"}),e.jsx("p",{className:"text-xs text-white/60 mt-0.5 tracking-wider up
1289percase",children:"Zorganics Med Spa · Confidential Clinical Preparation"})]})]})]})}),e.jsx("div",{className:"max-w-3xl mx-auto px-6 py-8",children:y?e.jsxs("div",{className:"bg-white rounded-2xl p-10 text-center",style:{border:"1px solid rgba(13,148,136,0.25)",boxShadow:"0 8px 30px rgba(15,23,42,0.08)"},children:[e.jsx("div",{className:"w-16 h-16 rounded-full flex items-center justify-center mx-auto mb-4",style:{background:"rgba(13,148,136,0.1)"},children:e.jsx(pt,{size:30,style:{color:il}})}),e.jsx("h2",{className:"text-xl font-bold mb-2",style:{color:gi},children:"Intake received â thank you"}),e.jsx("p",{className:"text-sm max-w-md mx-auto leading-relaxed",style:{color:fn},children:"Your confidential intake has been securely delivered to the Zorganics Med Spa clinical team. Frida and our ARNP will review it before your consultation. If anything needs clarifying, we'll reach out using the contact details you provided."}),e.jsxs("div",{className:"flex flex-col sm:flex-row items-center justify-center gap-3 mt-6",children:[e.jsxs(be,{to:"/my-appointments",className:"inline-flex items-center gap-2 px-5 py-2.5 rounded-lg text-xs font-bold text-white",style:{background:"linear-gradient(135deg, #0D9488, #0F766E)"},children:[e.jsx(Ii,{size:13})," View My Appointments"]}),e.jsx(be,{to:"/",className:"inline-flex items-center gap-2 px-5 py-2.5 rounded-lg text-xs font-bold",style:{border:"1px solid #E2E8F0",color:fn},children:"Return Home"})]})]}):e.jsxs("form",{onSubmit:S,className:"space-y-6",children:[e.jsxs("div",{className:"rounded-xl p-4 flex items-start gap-3",style:{background:"rgba(13,148,136,0.06)",border:"1px solid rgba(13,148,136,0.25)"},children:[e.jsx(Xe,{size:18,className:"shrink-0 mt-0.5",style:{color:il}}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-bold",style:{color:"#134E4A"},children:"Your privacy is protected"}),e.jsx("p",{className:"text-xs mt-1 leading-relaxed",style:{color:"#0F766E"},children:"This intake is reviewed only by the Zorganics Med Spa clinical team (Spa Director + ARNP). It is stored separately from all student, academic, and administrative systems and is never shared beyond your care team."})]})]}),e.jsxs("div",{className:"bg-white rounded-2xl p-6",style:{border:"1px solid #E2E8F0",boxShadow:"0 6px 20px rgba(15,23,42,0.05)"},children:[e.jsxs("div",{className:"flex items-center gap-2 mb-5",children:[e.jsx(yr,{size:15,style:{color:il}}),e.jsx("h2",{className:"text-sm font-bold uppercase tracking-wider",style:{color:gi},children:"1 · Your Information"})]}),e.jsxs("div",{className:"grid sm:grid-cols-2 gap-4",children:[e.jsxs("div",{className:"sm:col-span-2",children:[e.jsx("label",{className:Ar,style:{color:fn},children:"Full Name *"}),e.jsx("input",{className:er,style:Xa,value:t.name,onChange:b("name"),placeholder:"Your full name"})]}),e.jsxs("div",{children:[e.jsx("label",{className:Ar,style:{color:fn},children:"Email *"}),e.jsx("input",{type:"email",className:er,style:Xa,value:t.email,onChange:b("email"),placeholder:"[email protected]"})]}),e.jsxs("div",{children:[e.jsx("label",{className:Ar,style:{color:fn},children:"Phone number (optional)"}),e.jsx("input",{type:"tel",className:er,style:Xa,value:t.phone,onChange:b("phone"),placeholder:"(360) 555-0123"})]}),e.jsxs("div",{children:[e.jsx("label",{className:Ar,style:{color:fn},children:"Campus"}),e.jsx("select",{className:er,style:Xa,value:t.campus,onChange:b("campus"),children:yie.map(w=>e.jsx("option",{value:w,children:w},w))})]}),e.jsxs("div",{children:[e.jsx("label",{className:Ar,style:{color:fn},children:"Appointment date (if booked)"}),e.jsx("input",{type:"date",className:er,style:Xa,value:t.appointmentDate,onChange:b("appointmentDate")})]}),e.jsxs("div",{className:"sm:col-span-2",children:[e.jsx("label",{className:Ar,style:{color:fn},children:"Booking reference (optional)"}),e.jsx("input",{className:er,style:Xa,value:t.bookingReference,onChange:b("bookingReference"),placeholder:"e.g., ZM-2026-XXXXXX â from your confirmation email"})]})]})]}),e.jsxs("div",{className:"bg-white rounded-2xl p-6",style:{border:"1px solid #E2E8F0",boxShadow:"0 6px 20px rgba(15,23,42,0.05)"},children:[e.jsxs("div",{className:"flex items-center gap-2 mb-5",children:[e.jsx(Qe,{size:15,style:{color:il}}),e.jsx("h2",{className:"text-sm font-bold uppercase tracking-wider",style:{color:gi},children:"2 · Treatment Interest & Goals"})]}),e.jsxs("div",{className:"grid sm:grid-cols-2 gap-4",children:[e.jsxs("div",{children:[e.jsx("label",{className:Ar,style:{color:fn},children:"Treatment area *"}),e.jsxs("select",{className:er,style:Xa,value:t.treatmentInterest,onChange:b("treatmentInterest"),children:[e.jsx("option",{value:"",children:"Select a treatment areaâ¦"}),bie.map(w=>e.jsx("option",{value:w,children:w}
1289,w))]})]}),e.jsxs("div",{children:[e.jsx("label",{className:Ar,style:{color:fn},children:"Skin type"}),e.jsxs("select",{className:er,style:Xa,value:t.skinType,onChange:b("skinType"),children:[e.jsx("option",{value:"",children:"Select (optional)â¦"}),vie.map(w=>e.jsx("option",{value:w,children:w},w))]})]}),e.jsxs("div",{className:"sm:col-span-2",children:[e.jsx("label",{className:Ar,style:{color:fn},children:"What would you like to achieve?"}),e.jsx("textarea",{className:er,style:{...Xa,minHeight:90},value:t.goals,onChange:b("goals"),placeholder:"Tell us about your skin goals, concerns, or anything you'd like your consultation to focus onâ¦"})]})]}),e.jsxs("p",{className:"text-[11px] mt-3 flex items-center gap-1.5",style:{color:fn},children:[e.jsx(Sa,{size:12,style:{color:il}}),"Every Med Spa protocol begins with a consultation â your clinical team confirms the right treatment plan before any device protocol."]})]}),e.jsxs("div",{className:"bg-white rounded-2xl p-6",style:{border:"1px solid #E2E8F0",boxShadow:"0 6px 20px rgba(15,23,42,0.05)"},children:[e.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[e.jsx(Y_,{size:15,style:{color:il}}),e.jsx("h2",{className:"text-sm font-bold uppercase tracking-wider",style:{color:gi},children:"3 · Health Screening"})]}),e.jsx("p",{className:"text-xs mb-4",style:{color:fn},children:"Check any that apply. These help our ARNP screen for contraindications with energy-based devices â they do not disqualify you from care."}),e.jsx("div",{className:"space-y-2.5",children:jie.map(w=>e.jsxs("label",{className:"flex items-start gap-3 p-3 rounded-lg cursor-pointer transition-colors hover:bg-slate-50",style:{border:"1px solid #F1F5F9"},children:[e.jsx("input",{type:"checkbox",checked:n.includes(w.id),onChange:()=>f(w.id),className:"mt-0.5 accent-teal-600"}),e.jsx("span",{className:"text-sm leading-snug",style:{color:gi},children:w.label})]},w.id))}),e.jsxs("div",{className:"grid sm:grid-cols-2 gap-4 mt-4",children:[e.jsxs("div",{children:[e.jsx("label",{className:Ar,style:{color:fn},children:"Current medications (optional)"}),e.jsx("input",{className:er,style:Xa,value:t.medications,onChange:b("medications"),placeholder:"List any current medications"})]}),e.jsxs("div",{children:[e.jsx("label",{className:Ar,style:{color:fn},children:"Allergies / sensitivities (optional)"}),e.jsx("input",{className:er,style:Xa,value:t.allergies,onChange:b("allergies"),placeholder:"e.g., latex, fragrances, botanicals"})]})]}),j&&e.jsxs("div",{className:"mt-4 rounded-xl p-4",style:{background:"rgba(190,24,93,0.04)",border:"1px solid rgba(190,24,93,0.2)"},children:[e.jsx("p",{className:"text-xs font-bold mb-2",style:{color:"#9D174D"},children:"Oncology Compassionate Care"}),e.jsx("p",{className:"text-[11px] mb-3 leading-relaxed",style:{color:"#9D174D"},children:"Our oncology esthetics protocols are designed for comfort and safety during and after treatment. Anything you share below helps us prepare a gentle, appropriate session."}),e.jsx("textarea",{className:er,style:{...Xa,minHeight:70},value:t.oncologyNotes,onChange:b("oncologyNotes"),placeholder:"Optional: treatment stage, physician guidance, comfort preferencesâ¦"})]})]}),e.jsxs("div",{className:"bg-white rounded-2xl p-6",style:{border:"1px solid #E2E8F0",boxShadow:"0 6px 20px rgba(15,23,42,0.05)"},children:[e.jsxs("div",{className:"flex items-center gap-2 mb-4",children:[e.jsx(mn,{size:15,style:{color:il}}),e.jsx("h2",{className:"text-sm font-bold uppercase tracking-wider",style:{color:gi},children:"4 · Client Acknowledgments"})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsxs("label",{className:"flex items-start gap-3 cursor-pointer",children:[e.jsx("input",{type:"checkbox",checked:r,onChange:w=>i(w.target.checked),className:"mt-0.5 accent-teal-600"}),e.jsx("span",{className:"text-sm leading-snug",style:{color:gi},children:"The information I've provided is accurate and complete to the best of my knowledge. *"})]}),e.jsxs("label",{className:"flex items-start gap-3 cursor-pointer",children:[e.jsx("input",{type:"checkbox",checked:o,onChange:w=>l(w.target.checked),className:"mt-0.5 accent-teal-600"}),e.jsx("span",{className:"text-sm leading-snug",style:{color:gi},children:"I understand my visit begins with a consultation, and my final treatment plan will be confirmed by the clinical team under ARNP oversight before any protocol is performed. *"})]}),e.jsxs("label",{className:"flex items-start gap-3 cursor-pointer",children:[e.jsx("input",{type:"checkbox",checked:c,onChange:w=>u(w.target.checked),className:"mt-0.5 accent-teal-600"}),e.jsx("span",{className:"text-sm leading-snug",style:{color:gi},children:"I consent to the Zorganics Med Spa clinical team securely storing and reviewing this intake for the purpose of preparing my care. *"})]}),e.jsxs("label",{className:"flex items-start gap-3 cursor-pointer pt-2",style:{borderTop:"1px solid #F1F5F9"},children:[e.jsx("input",{type:"checkbox",checked:p,onChange:w=>m(w.target.checked),className:"mt-0.5 accent-teal-600"}),e.jsx("span",{className:"text-xs leading-snug",style:{color:fn},children:"Text me appointment updates and visit reminders. Msg & data rates may apply. Reply STOP to unsubscribe."})]})]})]}),g&&e.jsx("div",{className:"rounded-xl px-4 py-3 text-sm font-medium",style:{background:"rgba(220,38,38,0.06)",border:"1px solid rgba(220,38,38,0.25)",color:"#B91C1C"},children:g}),e.jsxs("button",{type:"submit",disabled:x,className:"w-full py-4 rounded-xl text-sm font-bold text-white transition-all hover:shadow-lg disabled:opacity-50 flex items-center justify-center gap-2",style:{background:"linear-gradient(135deg, #0D9488, #0F766E)"},children:[x?e.jsx(de,{size:16,className:"animate-spin"}):e.jsx(Ie,{size:16}),x?"Securely Submittingâ¦":"Submit Confidential Intake"]}),e.jsxs("p",{className:"text-[11px] text-center flex items-center justify-center gap-1.5",style:{color:fn},children:[e.jsx(Xe,{size:11,style:{color:il}}),"Transmitted securely · Reviewed only by your Med Spa care team · Never linked to student or academic re
1289cords"]})]})})]})},Ys=t=>`$${(t/100).toFixed(2)}`,Nie=()=>{const[t,s]=d.useState([]),[n,a]=d.useState(!0),r=d.useCallback(async()=>{a(!0);const{data:o}=await O.from("cosmetics_recon_runs").select("*").order("ran_at",{ascending:!1}).limit(8);s(o||[]),a(!1)},[]);d.useEffect(()=>{r()},[r]);const i=t[0];return e.jsxs("section",{className:"bg-white rounded-2xl border border-gray-200",children:[e.jsxs("div",{className:"px-6 py-4 border-b border-gray-100 flex items-center justify-between gap-3",children:[e.jsxs("div",{children:[e.jsxs("h2",{className:"font-semibold text-gray-900 flex items-center gap-2",children:[e.jsx(_a,{className:"h-4 w-4 text-gray-500"}),"Nightly reconciliation cron"]}),e.jsxs("p",{className:"text-xs text-gray-500 mt-0.5",children:["Scheduled ",e.jsx("span",{className:"font-mono",children:"45 6 * * *"})," (06:45 UTC daily) â runs the full two-way recon server-side and persists each run to"," ",e.jsx("span",{className:"font-mono",children:"cosmetics_recon_runs"}),". Runs that find issues, orphans, or fail outright automatically email an alert to the operator inbox; clean runs never alert."]})]}),e.jsxs("button",{onClick:r,disabled:n,className:"inline-flex items-center gap-2 px-3 py-2 rounded-lg border border-gray-300 bg-white text-gray-800 text-sm font-semibold hover:bg-gray-50 disabled:opacity-50 transition-colors shrink-0",children:[e.jsx(Be,{className:`h-4 w-4 ${n?"animate-spin":""}`}),"Refresh"]})]}),n&&t.length===0?e.jsx("div",{className:"px-6 py-5 text-sm text-gray-500",children:"Loading run historyâ¦"}):t.length===0?e.jsx("div",{className:"px-6 py-5 text-sm text-gray-500",children:"No persisted runs yet. The first nightly run lands at 06:45 UTC; manual runs from the reconciliation section above are not persisted unless triggered by the cron."}):e.jsxs(e.Fragment,{children:[i&&e.jsxs("div",{className:"px-6 py-3 flex flex-wrap items-center gap-2 text-sm border-b border-gray-50",children:[i.ok&&i.issue_count===0&&i.orphan_count===0?e.jsxs("span",{className:"inline-flex items-center gap-1 text-xs font-semibold px-2 py-0.5 rounded-full bg-emerald-100 text-emerald-700",children:[e.jsx(Ue,{className:"h-3.5 w-3.5"})," Latest run clean"]}):e.jsxs("span",{className:"inline-flex items-center gap-1 text-xs font-semibold px-2 py-0.5 rounded-full bg-red-100 text-red-700",children:[e.jsx(ve,{className:"h-3.5 w-3.5"}),i.ok?`${i.issue_count} issue(s) / ${i.orphan_count} orphan(s)`:i.error||"Run failed"]}),e.jsxs("span",{className:"text-xs text-gray-500",children:[new Date(i.ran_at).toLocaleString()," · ",i.trigger_source]})]}),e.jsx("div",{className:"overflow-x-auto",children:e.jsxs("table",{className:"w-full text-sm",children:[e.jsx("thead",{children:e.jsxs("tr",{className:"text-left text-xs text-gray-500 border-b border-gray-100",children:[e.jsx("th",{className:"px-6 py-2 font-medium",children:"Ran at"}),e.jsx("th",{className:"px-3 py-2 font-medium",children:"Source"}),e.jsx("th",{className:"px-3 py-2 font-medium",children:"Orders"}),e.jsx("th",{className:"px-3 py-2 font-medium",children:"Settled"}),e.jsx("th",{className:"px-3 py-2 font-medium",children:"Pending"}),e.jsx("th",{className:"px-3 py-2 font-medium",children:"Issues"}),e.jsx("th",{className:"px-3 py-2 font-medium",children:"Orphans"}),e.jsx("th",{className:"px-3 py-2 font-medium",children:"Alert"}),e.jsx("th",{className:"px-3 py-2 font-medium",children:"Result"})]})}),e.jsx("tbody",{className:"divide-y divide-gray-50",children:t.map(o=>e.jsxs("tr",{children:[e.jsx("td",{className:"px-6 py-2 text-gray-700 whitespace-nowrap",children:new Date(o.ran_at).toLocaleString()}),e.jsx("td",{className:"px-3 py-2 text-xs text-gray-500",children:o.trigger_source}),e.jsx("td",{className:"px-3 py-2 text-gray-700",children:o.orders_checked}),e.jsx("td",{className:"px-3 py-2 text-gray-700",children:Ys(o.settled_cents)}),e.jsx("td",{className:"px-3 py-2 text-gray-700",children:Ys(o.pending_cents)}),e.jsx("td",{className:`px-3 py-2 font-semibold ${o.issue_count>0?"text-red-700":"text-gray-700"}`,children:o.issue_count}),e.jsx("td",{className:`px-3 py-2 font-semibold ${o.orphan_count>0?"text-red-700":"text-gray-700"}`,children:o.orphan_count}),e.jsx("td",{className:"px-3 py-2",children:!o.ok||o.issue_count>0||o.orphan_count>0?o.alert_sent?e.jsxs("span",{className:"inline-flex items-center gap-1 text-[11px] font-semibold px-2 py-0.5 rounded-full bg-emerald-100 text-emerald-700",title:o.alert_recipient?`Sent to ${o.alert_recipient}`:void 0,children:[e.jsx(Ue,{className:"h-3 w-3"})," sent"]}):e.jsxs("span",{className:"inline-flex items-center gap-1 text-[11px] font-semibold px-2 py-0.5 rounded-full bg-red-100 text-red-700",title:o.alert_error||"Alert email was not delivered",children:[e.jsx(ve,{className:"h-3 w-3"})," not sent"]}):e.jsx("span",{className:"text-xs text-gray-400",children:"â"})}),e.jsx("td",{className:"px-3 py-2",children:o.ok?e.jsx(Ue,{className:"h-4 w-4 text-emerald-600"}):e.jsx(kt,{className:"h-4 w-4 text-red-600"})})]},o.id))})]})})]})]})},_ie=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i,kie=({order:t,onUpdated:s})=>
1289{const[n,a]=d.useState(""),[r,i]=d.useState(""),[o,l]=d.useState(""),[c,u]=d.useState(!1),[p,m]=d.useState(""),[x,h]=d.useState(""),y=t.status==="paid"?"shipped":t.status==="shipped"?"delivered":null,v=async()=>{if(!y)return;const g=y==="shipped"?"SHIPPED":"DELIVERED";if(window.confirm(`Mark order ${t.id.slice(0,8)}⦠as ${g} and email the customer a status update?`)){u(!0),h(""),m("");try{const{data:N,error:b}=await O.functions.invoke("cosmetics-order-status-email",{body:{order_id:t.id,status:y,...y==="shipped"&&n.trim()?{tracking_number:n.trim()}:{},...y==="shipped"&&r.trim()?{carrier:r.trim()}:{},...y==="shipped"&&o.trim()?{tracking_url:o.trim()}:{}}});b||(N==null?void 0:N.ok)!==!0?h((N==null?void 0:N.error)||(b==null?void 0:b.message)||"Status update failed."):(s({status:N.status}),m(N.emailSent?`Order marked ${N.status} â status email sent to ${N.recipient}.`:`Order marked ${N.status}, but the customer email was not sent${N.emailError?`: ${N.emailError}`:"."}`),a(""),i(""),l(""))}catch(N){h((N==null?void 0:N.message)||"Status update failed.")}finally{u(!1)}}};return e.jsxs("div",{className:"rounded-xl border border-gray-200 p-4",children:[e.jsxs("p",{className:"text-sm font-semibold text-gray-900 flex items-center gap-2",children:[e.jsx(Ay,{className:"h-4 w-4 text-gray-500"})," Fulfillment & customer emails"]}),p&&e.jsxs("div",{className:"mt-2 rounded-lg border border-emerald-200 bg-emerald-50 p-3 text-sm text-emerald-800 flex items-start gap-2",children:[e.jsx(Ue,{className:"h-4 w-4 mt-0.5 shrink-0"})," ",p]}),x&&e.jsxs("div",{className:"mt-2 rounded-lg border border-red-200 bg-red-50 p-3 text-sm text-red-800 flex items-start gap-2",children:[e.jsx(kt,{className:"h-4 w-4 mt-0.5 shrink-0"})," ",x]}),y?e.jsxs(e.Fragment,{children:[y==="shipped"&&e.jsxs("div",{className:"mt-3 grid sm:grid-cols-3 gap-2",children:[e.jsx("input",{value:n,onChange:g=>a(g.target.value),placeholder:"Tracking number (optional)",className:"border border-gray-300 rounded-lg px-3 py-2 text-sm focus:outline-none focus:ring-2 focus:ring-gray-900"}),e.jsx("input",{value:r,onChange:g=>i(g.target.value),placeholder:"Carrier, e.g. USPS (optional)",className:"border border-gray-300 rounded-lg px-3 py-2 text-sm focus:outline-none focus:ring-2 focus:ring-gray-900"}),e.jsx("input",{value:o,onChange:g=>l(g.target.value),placeholder:"Tracking URL (optional)",className:"border border-gray-300 rounded-lg px-3 py-2 text-sm focus:outline-none focus:ring-2 focus:ring-gray-900"})]}),e.jsxs("button",{onClick:v,disabled:c,className:"mt-3 inline-flex items-center gap-2 px-4 py-2 rounded-lg bg-gray-900 text-white text-sm font-semibold hover:bg-gray-800 disabled:opacity-50 transition-colors",children:[c?e.jsx(Be,{className:"h-4 w-4 animate-spin"}):e.jsx(Ay,{className:"h-4 w-4"}),c?"Updating & emailingâ¦":y==="shipped"?"Mark shipped & email customer":"Mark delivered & email customer"]}),e.jsxs("p",{className:"mt-2 text-xs text-gray-400",children:["Updates the order status server-side and sends the customer a branded"," ",y==="shipped"?"shipping confirmation (with tracking, if provided)":"delivery confirmation",". The email delivery outcome is appended to the order notes."]})]}):e.jsx("p",{className:"mt-2 text-sm text-gray-500",children:t.status==="delivered"?"Order is delivered â fulfillment is complete.":t.status==="pending"?"Order is still pending payment â it can be shipped once it is paid.":`Order is ${t.status} â shipping emails are not applicable.`})]})},Sie=()=>{const[t,s]=d.useState(""),[n,a]=d.useState(!1),[r,i]=d.useState(""),[o,l]=d.useState([]),[c,u]=d.useState({}),[p,m]=d.useState(null),[x,h]=d.useState([]),[y,v]=d.useState(null),[g,N]=d.useState(!1),[b,f]=d.useState("full"),[j,S]=d.useState(""),[w,_]=d.useState(!1),[C,E]=d.useState(""),[P,F]=d.useState(""),I=d.useCallback(async R=>{const T=[...new Set(R.map(q=>q.customer_id).filter(Boolean))];if(T.length===0)return;const{data:U}=await O.from("ecom_customers").select("id, email").in("id",T);if(U){const q={};for(const H of U)q[H.id]=H.email;u(H=>({...H,...q}))}},[]),D=d.useCallback(async R=>{R==null||R.preventDefault();const T=t.trim();if(T){a(!0),i(""),l([]),m(null),v(null),E(""),F("");try{let U=[];const q=O.from("ecom_orders").select("id, status, subtotal, tax, shipping, total, stripe_payment_intent_id, shipping_address, notes, created_at, customer_id");if(T.startsWith("pi_")){const{data:H,error:G}=await q.eq("stripe_payment_intent_id",T).limit(10);if(G)throw G;U=H||[]}else if(_ie.test(T)){const{data:H,error:G}=await q.eq("id",T).limit(1);if(G)throw G;U=H||[]}else{const{data:H,error:G}=await O.from("ecom_customers").select("id, email").ilike("email",`%${T}%`).limit(10);if(G)throw G;const W=(H||[]).map(X=>X.id);if(W.length>0){const{data:X,error:Q}=await q.in("customer_id",W).order("created_at",{ascending:!1}).limit(20);if(Q)throw Q;U=X||[]}}l(U),U.length===0?i("No orders matched. Search by full order ID, PaymentIntent id (pi_â¦), or customer email."):(I(U),U.length===1&&V(U[0]))}catch(U){i((U==null?void 0:U.message)||"Search failed.")}finally{a(!1)}}},[t,I]),L=d.useCallback(async R=>{N(!0),v(null);try{const{data:T,error:U}=await O.functions.invoke("cosmetics-reconciliation-report",{body:{action:"order-lookup",payment_intent:R}});v(U?{ok:!1,error:"Live Stripe lookup failed â the Cosmetics key may not be configured."}:T)}catch(T){v({ok:!1,error:(T==null?void 0:T.message)||"Live Stripe lookup failed."})}finally{N(!1)}},[]),V=d.useCallback(async R=>{m(R),h([]),v(null),E(""),F(""),f("full"),S("");const{data:T}=await O.from("ecom_order_items").select("id, product_name, variant_title, sku, quantity, unit_price, total").eq("order_id",R.id);h(T||[]),R.stripe_payment_intent_id&&L(R.stripe_payment_intent_id)},[L]),B=d.useCallback(async()=>
1289{if(!(p!=null&&p.stripe_payment_intent_id)||!(y!=null&&y.ok))return;const R=y.refundable_cents??0;let T;if(b==="partial"){const q=Math.round(parseFloat(j)*100);if(!q||q<=0){E("Enter a valid partial refund amount in dollars.");return}if(q>R){E(`Partial amount exceeds the refundable balance of ${Ys(R)}.`);return}T=q}const U=b==="full"?`the FULL refundable balance of ${Ys(R)}`:`${Ys(T)}`;if(window.confirm(`Issue a LIVE refund of ${U} for order ${p.id.slice(0,8)}â¦? 1290 1291This returns real money to the customer's card via the dedicated Cosmetics account and cannot be undone.`)){_(!0),E(""),F("");try{const{data:q,error:H}=await O.functions.invoke("create-cosmetics-refund",{body:{payment_intent:p.stripe_payment_intent_id,...T?{amount:T}:{},reason:"requested_by_customer",metadata:{order_id:p.id,issued_from:"admin-payment-health"}}});if(H||(q==null?void 0:q.success)!==!0)E((q==null?void 0:q.error)||(H==null?void 0:H.message)||"Refund failed.");else{if(F(`Refund ${q.refundId} ${q.status} â ${Ys(q.amount)} returned via the Cosmetics rail.`),b==="full"||(T??0)>=R){const{error:W}=await O.from("ecom_orders").update({status:"refunded"}).eq("id",p.id);W||m({...p,status:"refunded"})}else{const W=`[${new Date().toISOString()}] Partial refund ${Ys(T)} (${q.refundId}) via admin panel`,{error:X}=await O.from("ecom_orders").update({notes:p.notes?`${p.notes} 1292${W}`:W}).eq("id",p.id);X||m({...p,notes:p.notes?`${p.notes} 1293${W}`:W})}L(p.stripe_payment_intent_id)}}catch(q){E((q==null?void 0:q.message)||"Refund failed.")}finally{_(!1)}}},[p,y,b,j,L]),A=y==null?void 0:y.payment_intent,z=(y==null?void 0:y.refundable_cents)??0,M=(y==null?void 0:y.ok)===!0&&z>0&&!(A!=null&&A.diagnostic);return e.jsxs("section",{className:"bg-white rounded-2xl border border-gray-200",children:[e.jsxs("div",{className:"px-6 py-4 border-b border-gray-100",children:[e.jsxs("h2",{className:"font-semibold text-gray-900 flex items-center gap-2",children:[e.jsx(_d,{className:"h-4 w-4 text-gray-500"}),"Cosmetics order lookup & refunds"]}),e.jsxs("p",{className:"text-xs text-gray-500 mt-0.5",children:["Search by order ID, PaymentIntent (",e.jsx("span",{className:"font-mono",children:"pi_â¦"}),"), or customer email. Live Stripe status is read from the dedicated Cosmetics account; refunds go through the isolated ",e.jsx("span",{className:"font-mono",children:"create-cosmetics-refund"})," rail only â shared-rail payments are rejected by design."]}),e.jsxs("form",{onSubmit:D,className:"mt-3 flex gap-2",children:[e.jsxs("div",{className:"relative flex-1",children:[e.jsx(Bt,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-gray-400"}),e.jsx("input",{value:t,onChange:R=>s(R.target.value),placeholder:"Order UUID, pi_â¦, or customer email",className:"w-full pl-9 pr-3 py-2 border border-gray-300 rounded-lg text-sm focus:outline-none focus:ring-2 focus:ring-gray-900"})]}),e.jsxs("button",{type:"submit",disabled:n||!t.trim(),className:"inline-flex items-center gap-2 px-4 py-2 rounded-lg bg-gray-900 text-white text-sm font-semibold hover:bg-gray-800 disabled:opacity-50 transition-colors",children:[n?e.jsx(Be,{className:"h-4 w-4 animate-spin"}):e.jsx(Bt,{className:"h-4 w-4"}),"Search"]})]})]}),r&&e.jsx("div",{className:"mx-6 mt-4 rounded-xl border border-amber-200 bg-amber-50 p-3 text-sm text-amber-800",children:r}),o.length>1&&e.jsxs("div",{className:"px-6 pt-4",children:[e.jsxs("p",{className:"text-xs font-semibold text-gray-500 uppercase tracking-wide mb-2",children:[o.length," matching orders"]}),e.jsx("div",{className:"space-y-1.5",children:o.map(R=>e.jsxs("button",{onClick:()=>V(R),className:`w-full text-left px-3 py-2 rounded-lg border text-sm flex flex-wrap items-center gap-x-3 gap-y-1 transition-colors ${(p==null?void 0:p.id)===R.id?"border-gray-900 bg-gray-50":"border-gray-200 hover:border-gray-400"}`,children:[e.jsxs("span",{className:"font-mono text-xs text-gray-600",children:[R.id.slice(0,8),"â¦"]}),e.jsx("span",{className:"font-semibold text-gray-900",children:Ys(R.total)}),e.jsx("span",{className:"text-xs text-gray-500",children:R.status}),R.customer_id&&c[R.customer_id]&&e.jsx("span",{className:"text-xs text-gray-500",children:c[R.customer_id]}),e.jsx("span",{className:"text-xs text-gray-400 ml-auto",children:new Date(R.created_at).toLocaleDateString()})]},R.id))})]}),p&&e.jsxs("div",{className:"px-6 py-4 space-y-4",children:[e.jsxs("div",{className:"rounded-xl border border-gray-200 p-4",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-x-4 gap-y-1",children:[e.jsx("span",{className:"font-mono text-xs text-gray-500",children:p.id}),e.jsx("span",{className:`inline-flex text-[11px] font-semibold px-2 py-0.5 rounded-full ${p.status==="refunded"?"bg-purple-100 text-purple-700":p.status==="paid"?"bg-emerald-100 text-emerald-700":"bg-gray-100 text-gray-600"}`,children:p.status}),e.jsx("span",{className:"text-xs text-gray-500",children:new Date(p.created_at).toLocaleStr
1293ing()}),p.customer_id&&c[p.customer_id]&&e.jsx("span",{className:"text-xs text-gray-500",children:c[p.customer_id]})]}),e.jsxs("div",{className:"mt-3 grid grid-cols-2 sm:grid-cols-4 gap-3 text-sm",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-xs text-gray-500",children:"Subtotal"}),e.jsx("p",{className:"font-semibold text-gray-900",children:Ys(p.subtotal)})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-xs text-gray-500",children:"Shipping"}),e.jsx("p",{className:"font-semibold text-gray-900",children:Ys(p.shipping)})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-xs text-gray-500",children:"Tax"}),e.jsx("p",{className:"font-semibold text-gray-900",children:Ys(p.tax)})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-xs text-gray-500",children:"Total"}),e.jsx("p",{className:"font-bold text-gray-900",children:Ys(p.total)})]})]}),x.length>0&&e.jsx("ul",{className:"mt-3 border-t border-gray-100 pt-3 space-y-1 text-sm text-gray-700",children:x.map(R=>e.jsxs("li",{className:"flex justify-between gap-2",children:[e.jsxs("span",{children:[R.product_name,R.variant_title?` â ${R.variant_title}`:"",R.sku?e.jsxs("span",{className:"text-xs text-gray-400",children:[" (",R.sku,")"]}):null," ","à ",R.quantity]}),e.jsx("span",{className:"font-medium",children:Ys(R.total)})]},R.id))}),p.notes&&e.jsx("p",{className:"mt-3 text-xs text-gray-500 whitespace-pre-line border-t border-gray-100 pt-2",children:p.notes})]}),e.jsx(kie,{order:p,onUpdated:R=>m(T=>T&&{...T,...R})}),e.jsxs("div",{className:"rounded-xl border border-gray-200 p-4",children:[e.jsxs("div",{className:"flex items-center justify-between gap-2",children:[e.jsx("p",{className:"text-sm font-semibold text-gray-900",children:"Live Stripe status (Cosmetics account)"}),p.stripe_payment_intent_id&&e.jsxs("button",{onClick:()=>L(p.stripe_payment_intent_id),disabled:g,className:"inline-flex items-center gap-1.5 text-xs font-semibold text-gray-600 hover:text-gray-900 disabled:opacity-50",children:[e.jsx(Be,{className:`h-3.5 w-3.5 ${g?"animate-spin":""}`}),"Refresh"]})]}),p.stripe_payment_intent_id?g?e.jsx("p",{className:"mt-2 text-sm text-gray-500",children:"Fetching live statusâ¦"}):y&&!y.ok?e.jsx("p",{className:"mt-2 text-sm text-red-700",children:y.error}):A?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"mt-2 flex flex-wrap items-center gap-x-4 gap-y-1 text-sm",children:[e.jsx("span",{className:"font-mono text-xs text-gray-500",children:A.id}),e.jsxs("span",{className:"text-gray-700",children:["status: ",e.jsx("strong",{children:A.status})]}),e.jsxs("span",{className:"text-gray-700",children:["received: ",e.jsx("strong",{children:Ys(A.amount_received_cents)})]}),e.jsxs("span",{className:"text-gray-700",children:["refunded: ",e.jsx("strong",{children:Ys((y==null?void 0:y.refunded_cents)??0)})]}),e.jsxs("span",{className:"text-gray-700",children:["refundable: ",e.jsx("strong",{children:Ys(z)})]}),e.jsx("span",{className:`inline-flex text-[10px] font-bold uppercase px-2 py-0.5 rounded-full ${A.livemode?"bg-emerald-100 text-emerald-700":"bg-amber-100 text-amber-700"}`,children:A.livemode?"LIVE":"TEST"})]}),(y==null?void 0:y.refunds)&&y.refunds.length>0&&e.jsx("ul",{className:"mt-2 space-y-1 text-xs text-gray-600 border-t border-gray-100 pt-2",children:y.refunds.map(R=>e.jsxs("li",{children:[e.jsx("span",{className:"font-mono",children:R.id})," â ",Ys(R.amount_cents)," · ",R.status," ·"," ",new Date(R.created).toLocaleString()]},R.id))})]}):e.jsx("p",{className:"mt-2 text-sm text-gray-500",children:"Live status not loaded yet."}):e.jsx("p",{className:"mt-2 text-sm text-gray-500",children:"No PaymentIntent recorded on this order â nothing to refund."})]}),p.stripe_payment_intent_id&&e.jsxs("div",{className:"rounded-xl border border-gray-200 p-4",children:[e.jsxs("p",{className:"text-sm font-semibold text-gray-900 flex items-center gap-2",children:[e.jsx(Ey,{className:"h-4 w-4 text-gray-500"})," Issue refund"]}),P&&e.jsxs("div",{className:"mt-2 rounded-lg border border-emerald-200 bg-emerald-50 p-3 text-sm text-emerald-800 flex items-start gap-2",children:[e.jsx(Ue,{className:"h-4 w-4 mt-0.5 shrink-0"})," ",P]}),C&&e.jsxs("div",{className:"mt-2 rounded-lg border border-red-200 bg-red-50 p-3 text-sm text-red-800 flex items-start gap-2",children:[e.jsx(kt,{className:"h-4 w-4 mt-0.5 shrink-0"})," ",C]}),M?e.jsxs("div",{className:"mt-3 flex flex-col sm:flex-row sm:items-end gap-3",children:[e.jsxs("div",{className:"flex items-center gap-4 text-sm",children:[e.jsxs("label",{className:"inline-flex items-center gap-1.5",children:[e.jsx("input",{type:"radio",checked:b==="full",onCh
1293ange:()=>f("full")}),"Full (",Ys(z),")"]}),e.jsxs("label",{className:"inline-flex items-center gap-1.5",children:[e.jsx("input",{type:"radio",checked:b==="partial",onChange:()=>f("partial")}),"Partial"]})]}),b==="partial"&&e.jsxs("div",{className:"relative",children:[e.jsx("span",{className:"absolute left-3 top-1/2 -translate-y-1/2 text-gray-400 text-sm",children:"$"}),e.jsx("input",{type:"number",min:"0.01",step:"0.01",max:(z/100).toFixed(2),value:j,onChange:R=>S(R.target.value),placeholder:"0.00",className:"pl-7 pr-3 py-2 w-32 border border-gray-300 rounded-lg text-sm focus:outline-none focus:ring-2 focus:ring-gray-900"})]}),e.jsxs("button",{onClick:B,disabled:w||b==="partial"&&!j,className:"inline-flex items-center gap-2 px-4 py-2 rounded-lg bg-red-600 text-white text-sm font-semibold hover:bg-red-700 disabled:opacity-50 transition-colors",children:[w?e.jsx(Be,{className:"h-4 w-4 animate-spin"}):e.jsx(Ey,{className:"h-4 w-4"}),w?"Refundingâ¦":b==="full"?`Refund ${Ys(z)}`:"Refund partial amount"]})]}):e.jsx("p",{className:"mt-2 text-sm text-gray-500",children:y!=null&&y.ok?A!=null&&A.diagnostic?"This is a diagnostic payment â refunds are not applicable.":"No refundable balance remains on this payment.":"Refunds are unavailable until the live Stripe status loads successfully."}),e.jsxs("p",{className:"mt-2 text-xs text-gray-400",children:["Refunds are issued exclusively via the isolated Cosmetics account. A full refund marks the order ",e.jsx("span",{className:"font-mono",children:"refunded"}),"; partial refunds are appended to the order notes."]})]})]}),!p&&o.length===0&&!r&&e.jsx("div",{className:"px-6 py-5 text-sm text-gray-500",children:"Search for a Cosmetics order to view its live settlement status and issue refunds."})]})},hN=t=>t==null?"â":`$${(t/100).toFixed(2)}`,Cie=(t,s)=>s?{marked_paid:"bg-emerald-100 text-emerald-700",rematched_and_promoted_to_paid:"bg-emerald-100 text-emerald-700",rematched:"bg-emerald-100 text-emerald-700",marked_refunded:"bg-purple-100 text-purple-700",partial_refund_noted:"bg-purple-100 text-purple-700",already_reconciled:"bg-gray-100 text-gray-600",already_refunded:"bg-gray-100 text-gray-600",ignored_diagnostic:"bg-gray-100 text-gray-500"}[t||""]||"bg-gray-100 text-gray-600":"bg-amber-100 text-amber-700",Aie=()=>{const[t,s]=d.useState([]),[n,a]=d.useState(!0),r=d.useCallback(async()=>{a(!0);const{data:o}=await O.from("cosmetics_webhook_events").select("*").order("received_at",{ascending:!1}).limit(15);s(o||[]),a(!1)},[]);d.useEffect(()=>{r()},[r]);const i=t.filter(o=>!o.matched&&o.event_type==="payment_intent.succeeded").length;return e.jsxs("section",{className:"bg-white rounded-2xl border border-gray-200",children:[e.jsxs("div",{className:"px-6 py-4 border-b border-gray-100 flex items-center justify-between gap-3",children:[e.jsxs("div",{children:[e.jsxs("h2",{className:"font-semibold text-gray-900 flex items-center gap-2",children:[e.jsx(sM,{className:"h-4 w-4 text-gray-500"}),"Webhook event log & order sync"]}),e.jsxs("p",{className:"text-xs text-gray-500 mt-0.5",children:["Every signature-verified event from the Cosmetics account is persisted
1293with event-id idempotency (replays never double-apply). Events that arrive before the order row exists are queued and re-matched by the recon sync sweep â pending orders confirmed paid by a signed webhook are promoted to"," ",e.jsx("span",{className:"font-mono",children:"paid"})," automatically."]})]}),e.jsxs("button",{onClick:r,disabled:n,className:"inline-flex items-center gap-2 px-3 py-2 rounded-lg border border-gray-300 bg-white text-gray-800 text-sm font-semibold hover:bg-gray-50 disabled:opacity-50 transition-colors shrink-0",children:[e.jsx(Be,{className:`h-4 w-4 ${n?"animate-spin":""}`}),"Refresh"]})]}),i>0&&e.jsxs("div",{className:"mx-6 mt-4 rounded-xl border border-amber-200 bg-amber-50 p-3 text-sm text-amber-800 flex items-start gap-2",children:[e.jsx(dt,{className:"h-4 w-4 mt-0.5 shrink-0"}),i," webhook-confirmed payment(s) awaiting order sync â the next reconciliation run (manual or nightly) will re-match them."]}),n&&t.length===0?e.jsx("div",{className:"px-6 py-5 text-sm text-gray-500",children:"Loading webhook eventsâ¦"}):t.length===0?e.jsxs("div",{className:"px-6 py-5 text-sm text-gray-500",children:["No webhook events received yet. Once Stripe delivers"," ",e.jsx("span",{className:"font-mono",children:"payment_intent.succeeded"})," or"," ",e.jsx("span",{className:"font-mono",children:"charge.refunded"})," events to"," ",e.jsx("span",{className:"font-mono",children:"cosmetics-payment-webhook"}),", each verified delivery appears here with its order-sync outcome."]}):e.jsx("div",{className:"overflow-x-auto",children:e.jsxs("table",{className:"w-full text-sm",children:[e.jsx("thead",{children:e.jsxs("tr",{className:"text-left text-xs text-gray-500 border-b border-gray-100",children:[e.jsx("th",{className:"px-6 py-2 font-medium",children:"Received"}),e.jsx("th",{className:"px-3 py-2 font-medium",children:"Event"}),e.jsx("th",{className:"px-3 py-2 font-medium",children:"PaymentIntent"}),e.jsx("th",{className:"px-3 py-2 font-medium",children:"Amount"}),e.jsx("th",{className:"px-3 py-2 font-medium",children:"Order"}),e.jsx("th",{className:"px-3 py-2 font-medium",children:"Sync outcome"})]})}),e.jsx("tbody",{className:"divide-y divide-gray-50",children:t.map(o=>e.jsxs("tr",{children:[e.jsx("td",{className:"px-6 py-2 text-gray-700 whitespace-nowrap",children:new Date(o.received_at).toLocaleString()}),e.jsx("td",{className:"px-3 py-2 text-xs text-gray-600 font-mono whitespace-nowrap",children:o.event_type.replace("payment_intent.","pi.").replace("charge.","ch.")}),e.jsx("td",{className:"px-3 py-2 font-mono text-xs text-gray-500",children:o.payment_intent_id?`${o.payment_intent_id.slice(0,14)}â¦`:"â"}),e.jsx("td",{className:"px-3 py-2 text-gray-700",children:hN(o.amount_cents)}),e.jsx("td",{className:"px-3 py-2 font-mono text-xs text-gray-500",children:o.order_id?`${o.order_id.slice(0,8)}â¦`:"â"}),e.jsx("td",{className:"px-3 py-2",children:e.jsx("span",{className:`inline-flex text-[11px] font-semibold px-2 py-0.5 rounded-full ${Cie(o.action,o.matched)}`,title:o.sync_note||void 0,children:o.matched?(o.action||"matched").replace(/_/g," "):"awaiting sync"})})]},o.id))})]})})]})},Eie=()=>{const[t,s]=d.useState([]),[n,a]=d.useState(!0),r=d.useCallback(async()=>{a(!0);const{data:i}=await O.from("cosmetics_refund_audit").select("*").order("created_at",{ascending:!1}).limit(15);s(i||[]),a(!1)},[]);return d.useEffect(()=>{r()},[r]),e.jsxs("section",{className:"bg-white rounded-2xl border border-gray-200",children:[e.jsxs("div",{className:"px-6 py-4 border-b border-gray-100 flex items-center justify-between gap-3",children:[e.jsxs("div",{children:[e.jsxs("h2",{className:"font-semibold text-gray-900 flex items-center gap-2",children:[e.jsx(tm,{className:"h-4 w-4 text-gray-500"}),"Refund audit log"]}),e.jsxs("p",{className:"text-xs text-gray-500 mt-0.5",children:["Immutable server-side record of ",e.jsx("strong",{children:"every"})," refund attempt on the isolated Cosmetics rail â successful and failed alike â written by"," ",e.jsx("span",{className:"font-mono",children:"create-cosmetics-refund"})," before the response is returned. The browser can only read this table."]})]}),e.jsxs("button",{onClick:r,disabled:n,className:"inline-flex items-center gap-2 px-3 py-2 rounded-lg border border-gray-300 bg-white text-gray-800 text-sm font-semibold hover:bg-gray-50 disabled:opacity-50 transition-colors shrink-0",children:[e.jsx(Be,{className:`h-4 w-4 ${n?"animate-spin":""}`}),"Refresh"]})]}),n&&t.length===0?e.jsx("div",{className:"px-6 py-5 text-sm text-gray-500",children:"Loading refund auditâ¦"}):t.length===0?e.jsx("div",{className:"px-6 py-5 text-sm text-gray-500",children:"No refund attempts recorded yet. Every refund issued from the order lookup tool above (and any failed attempt)
1293will appear here permanently."}):e.jsx("div",{className:"overflow-x-auto",children:e.jsxs("table",{className:"w-full text-sm",children:[e.jsx("thead",{children:e.jsxs("tr",{className:"text-left text-xs text-gray-500 border-b border-gray-100",children:[e.jsx("th",{className:"px-6 py-2 font-medium",children:"When"}),e.jsx("th",{className:"px-3 py-2 font-medium",children:"PaymentIntent"}),e.jsx("th",{className:"px-3 py-2 font-medium",children:"Order"}),e.jsx("th",{className:"px-3 py-2 font-medium",children:"Type"}),e.jsx("th",{className:"px-3 py-2 font-medium",children:"Amount"}),e.jsx("th",{className:"px-3 py-2 font-medium",children:"Origin"}),e.jsx("th",{className:"px-3 py-2 font-medium",children:"Result"})]})}),e.jsx("tbody",{className:"divide-y divide-gray-50",children:t.map(i=>e.jsxs("tr",{children:[e.jsx("td",{className:"px-6 py-2 text-gray-700 whitespace-nowrap",children:new Date(i.created_at).toLocaleString()}),e.jsx("td",{className:"px-3 py-2 font-mono text-xs text-gray-500",children:i.payment_intent_id.startsWith("pi_")?`${i.payment_intent_id.slice(0,14)}â¦`:i.payment_intent_id}),e.jsx("td",{className:"px-3 py-2 font-mono text-xs text-gray-500",children:i.order_id?`${i.order_id.slice(0,8)}â¦`:"â"}),e.jsx("td",{className:"px-3 py-2",children:e.jsx("span",{className:`inline-flex text-[11px] font-semibold px-2 py-0.5 rounded-full ${i.refund_type==="partial"?"bg-blue-100 text-blue-700":"bg-purple-100 text-purple-700"}`,children:i.refund_type})}),e.jsx("td",{className:"px-3 py-2 text-gray-700",children:i.success?hN(i.refunded_amount_cents):hN(i.requested_amount_cents)}),e.jsx("td",{className:"px-3 py-2 text-xs text-gray-500",children:i.issued_from||"â"}),e.jsx("td",{className:"px-3 py-2",children:i.success?e.jsxs("span",{className:"inline-flex items-center gap-1 text-[11px] font-semibold px-2 py-0.5 rounded-full bg-emerald-100 text-emerald-700",title:i.refund_id?`${i.refund_id} · ${i.stripe_status||""}`:void 0,children:[e.jsx(Ue,{className:"h-3 w-3"}),i.stripe_status||"succeeded"]}):e.jsxs("span",{className:"inline-flex items-center gap-1 text-[11px] font-semibold px-2 py-0.5 rounded-full bg-red-100 text-red-700",title:i.error||void 0,children:[e.jsx(kt,{className:"h-3 w-3"}),"failed"]})})]},i.id))})]})})]})},Qi=t=>`$${((t||0)/100).toFixed(2)}`,Fie=()=>{const[t,s]=d.useState([]),[n,a]=d.useState(!0),[r,i]=d.useState(!1),[o,l]=d.useState(""),[c,u]=d.useState(""),p=d.useCallback(async()=>{a(!0);const{data:h}=await O.from("cosmetics_sales_reports").select("*").order("ran_at",{ascending:!1}).limit(8);s(h||[]),a(!1)},[]);d.useEffect(()=>{p()},[p]);const m=d.useCallback(async()=>{var h,y;if(window.confirm("Generate a 7-day sales report now and email it to the operator inbox?")){i(!0),l(""),u("");try{const{data:v,error:g}=await O.functions.invoke("cosmetics-weekly-sales-report",{body:{trigger_source:"manual-admin",days:7,persist:!0,send_email:!0}});g||(v==null?void 0:v.ok)!==!0?u((v==null?void 0:v.error)||(g==null?void 0:g.message)||"Report run failed."):(l(v.emailSent?`Report generated â ${Qi(((h=v.summary)==null?void 0:h.revenue_cents)||0)} across ${((y=v.summary)==null?void 0:y.order_count)||0} order(s); emailed to ${v.emailRecipient}.`:`Report generated, but the email was not sent${v.emailError?`: ${v.emailError}`:"."}`),p())}catch(v){u((v==null?void 0:v.message)||"Report run failed.")}finally{i(!1)}}},[p]),x=t[0];return e.jsxs("section",{className:"bg-white rounded-2xl border border-gray-200",children:[e.jsxs("div",{className:"px-6 py-4 border-b border-gray-100 flex items-center justify-between gap-3",children:[e.jsxs("div",{children:[e.jsxs("h2",{className:"font-semibold text-gray-900 flex items-center gap-2",children:[e.jsx(La,{className:"h-4 w-4 text-gray-500"}),"Weekly sales report"]}),e.jsxs("p",{className:"text-xs text-gray-500 mt-0.5",children:["Cron ",e.jsx("span",{className:"font-mono",children:"0 7 * * 1"})," (Mondays 07:00 UTC) â aggregates the trailing 7 days of orders, refunds, and top products, emails the digest to the operator inbox, and persists each run to"," ",e.jsx("span",{className:"font-mono",children:"cosmetics_sales_reports"}),"."]})]}),e.jsxs("div",{className:"flex gap-2 shrink-0",children:[e.jsxs("button",{onClick:p,disabled:n,className:"inline-flex items-center gap-2 px-3 py-2 rounded-lg border border-gray-300 bg-white text-gray-800 text-sm font-semibold hover:bg-gray-50 disabled:opacity-50 transition-colors",children:[e.jsx(Be,{className:`h-4 w-4 ${n?"animate-spin":""}`}),"Refresh"]}),e.jsxs("button",{onClick:m,disabled:r,className:"inline-flex items-center gap-2 px-3 py-2 rounded-lg bg-gray-900 text-white text-sm font-semibold hover:bg-gray-800 disabled:opacity-50 transition-colors",children:[e.jsx(_y,{className:`h-4 w-4 ${r?"animate-pulse":""}`}),r?"Generatingâ¦":"Generate & email now"]})]})]}),o&&e.jsxs("div",{className:"mx-6 mt-4 rounded-xl border border-emerald-200 bg-emerald-50 p-3 text-sm text-emerald-800 flex items-start gap-2",children:[e.jsx(Ue,{className:"h-4 w-4 mt-0.5 shrink-0"})," ",o]}),c&&e.jsxs("div",{className:"mx-6 mt-4 rounded-xl border border-red-200 bg-red-50 p-3 text-sm text-red-800 flex items-start gap-2",children:[e.jsx(kt,{className:"h-4 w-4 mt-0.5 shrink-0"})," ",c]}),n&&t.length===0?e.jsx("div",{className:"px-6 py-5 text-sm text-gray-500",children:"Loading report historyâ¦"}):t.length===0?e.jsx("div",{className:"px-6 py-5 text-sm text-gray-500",children:"No reports yet. The first scheduled digest lands Monday 07:00 UTC, or generate one now."}):e.jsxs(e.Fragment,{children:[x&&e.jsxs("div",{className:"px-6 py-4 grid grid-cols-2 sm:grid-cols-4 gap-4",children:[e.jsxs("div",{className:"rounded-xl bg-emerald-50 border border-emerald-100 p-3",children:[e.jsx("p",{className:"text-xs text-emerald-700",children:"Latest revenue (7d)"}),e.jsx("p",{className:"text-xl font-bold text-emerald-800",children:Qi(x.revenue_cents)})]}),e.jsxs("div",{className:"rounded-xl bg-gray-50 border border-gray-100 p-3",children:[e.jsx("p",{className:"text-xs text-gray-500",children:"Orders / AOV"}),e.jsxs("p",{className:"text-xl font-bold text-gray-900",children:[x.order_count," · ",Qi(x.aov_cents)]})]}),e.jsxs("div",{className:`rounded-xl border p-3 ${x.refunded_cents>0?"bg-red-50 border-red-100":"bg-gray-50 border-gray-100"}`,children:[e.jsx("p",{className:`text-xs ${x.refunded_cents>0?"text-red-700":"text-gray-500"}`,children:"Refunded"}),e.jsx("p",{className:`text-xl font-bold ${x.refunded_cents>0?"text-red-800":"text-gray-900"}`,children:Qi(x.refunded_cents)})]}),e.jsxs("div",{className:"rounded-xl bg-gray-50 border border-gray-100 p-3",children:[e.jsx("p",{className:"text-xs text-gray-500",children:"Net after refunds"}),e.jsx("p",{className:"text-xl font-bold text-gray-900",children:Qi(x.revenue_cents-x.refunded_cents)})]})]}),(x==null?void 0:x.top_products)&&x.top_products.length>0&&e.jsxs("div",{className:"px-6 pb-3",children:[e.jsx("p",{className:"text-xs font-semibold text-gray-500 uppercase tracking-wide mb-1.5",children:"Top products (latest report)"}),e.jsx("ul",{className:"text-sm text-gray-700 space-y-0.5",children:x.top_products.map((h,y)=>e.jsxs("li",{className:"flex justify-between gap-2",children:[e.jsxs("span",{children:[y+1,". ",h.product_name,h.variant_title?` â ${h.variant_title}`:""]}),e.jsxs("span",{className:"text-gray-500",children:[h.units," units · ",Qi(h.revenue_cents)]})]},`${h.product_name}-${y}`))})]}),e.jsx("div",{className:"border-t border-gray-100 overflow-x-auto",children:e.jsxs("table",{className:"w-full text-sm",children:[e.jsx("thead",{children:e.jsxs("tr",{className:"text-left text-xs text-gray-500 border-b border-gray-100",children:[e.jsx("th",{className:"px-6 py-2 font-medium",children:"Ran at"}),e.jsx("th",{className:"px-3 py-2 font-medium",children:"Source"}),e.jsx("th",{className:"px-3 py-2 font-medium",children:"Period"}),e.jsx("th",{className:"px-3 py-2 font-medium",children:"Orders"}),e.jsx("th",{className:"px-3 py-2 font-medium",children:"Revenue"}),e.jsx("th",{className:"px-3 py-2 font-medium",children:"Refunded"}),e.jsx("th",{className:"px-3 py-2 font-medium",children:"AOV"}),e.jsx("th",{className:"px-3 py-2 font-medium",children:"Email"})]})}),e.jsx("tbody",{className:"divide-y divide-gray-50",children:t.map(h=>e.jsxs("tr",{children:[e.jsx("td",{className:"px-6 py-2 text-gray-700 whitespace-nowrap",children:new Date(h.ran_at).toLocaleStr
1293ing()}),e.jsx("td",{className:"px-3 py-2 text-xs text-gray-500",children:h.trigger_source}),e.jsxs("td",{className:"px-3 py-2 text-xs text-gray-500 whitespace-nowrap",children:[new Date(h.period_start).toLocaleDateString()," â"," ",new Date(h.period_end).toLocaleDateString()]}),e.jsx("td",{className:"px-3 py-2 text-gray-700",children:h.order_count}),e.jsx("td",{className:"px-3 py-2 font-semibold text-gray-900",children:Qi(h.revenue_cents)}),e.jsx("td",{className:`px-3 py-2 ${h.refunded_cents>0?"text-red-700 font-semibold":"text-gray-700"}`,children:Qi(h.refunded_cents)}),e.jsx("td",{className:"px-3 py-2 text-gray-700",children:Qi(h.aov_cents)}),e.jsx("td",{className:"px-3 py-2",children:h.email_sent?e.jsxs("span",{className:"inline-flex items-center gap-1 text-[11px] font-semibold px-2 py-0.5 rounded-full bg-emerald-100 text-emerald-700",title:h.email_recipient?`Sent to ${h.email_recipient}`:void 0,children:[e.jsx(Ye,{className:"h-3 w-3"})," sent"]}):e.jsxs("span",{className:"inline-flex items-center gap-1 text-[11px] font-semibold px-2 py-0.5 rounded-full bg-red-100 text-red-700",title:h.email_error||"Digest email was not delivered",children:[e.jsx(ve,{className:"h-3 w-3"})," not sent"]})})]},h.id))})]})})]})]})},Tie=()=>{const[t,s]=d.useState("5"),[n,a]=d.useState([]),[r,i]=d.useState(null),[o,l]=d.useState(!1),[c,u]=d.useState(""),[p,m]=d.useState([]),[x,h]=d.useState(!0),[y,v]=d.useState(!1),[g,N]=d.useState(""),[b,f]=d.useState(""),j=()=>{const C=parseInt(t,10);return Number.isFinite(C)&&C>=0?Math.min(C,100):5},S=d.useCallback(async()=>{l(!0),u("");try{const{data:C,error:E}=await O.functions.invoke("cosmetics-low-stock-alert",{body:{action:"check",threshold:j()}});E||(C==null?void 0:C.ok)!==!0?u((C==null?void 0:C.error)||(E==null?void 0:E.message)||"Stock check failed."):(a(C.items||[]),i(C.summary))}catch(C){u((C==null?void 0:C.message)||"Stock check failed.")}finally{l(!1)}},[t]),w=d.useCallback(async()=>{h(!0);const{data:C}=await O.from("cosmetics_stock_alert_runs").select("id, ran_at, trigger_source, threshold, low_stock_count, out_of_stock_count, alert_sent, alert_recipient, alert_error").order("ran_at",{ascending:!1}).limit(6);m(C||[]),h(!1)},[]);d.useEffect(()=>{S(),w()},[]);const _=d.useCallback(async()=>{var C,E,P;if(window.confirm("Run the low-stock alert now? If any items are at/below the threshold, an alert email is sent to the operator inbox.")){v(!0),N(""),f("");try{const{data:F,error:I}=await O.functions.invoke("cosmetics-low-stock-alert",{body:{action:"alert",threshold:j(),trigger_source:"manual-admin"}});I||(F==null?void 0:F.ok)!==!0?f((F==null?void 0:F.error)||(I==null?void 0:I.message)||"Alert run failed."):(C=F.alert)!=null&&C.needed?N(F.alert.sent?`${(E=F.summary)==null?void 0:E.low_stock_count} low-stock item(s) found â alert emailed to ${F.alert.recipient}.`:`${(P=F.summary)==null?void 0:P.low_stock_count} low-stock item(s) found, but the alert email failed${F.alert.error?`: ${F.alert.error}`:"."}`):N("All tracked inventory is above the threshold â no alert needed."),w()}catch(F){f((F==null?void 0:F.message)||"Alert run failed.")}finally{v(!1)}}},[t,w]);return e.jsxs("section",{className:"bg-white rounded-2xl border border-gray-200",children:[e.jsxs("div",{className:"px-6 py-4 border-b border-gray-100 flex flex-col sm:flex-row sm:items-center justify-between gap-3",children:[e.jsxs("div",{children:[e.jsxs("h2",{className:"font-semibold text-gray-900 flex items-center gap-2",children:[e.jsx(gO,{className:"h-4 w-4 text-gray-500"}),"Low stock alerts"]}),e.jsxs("p",{className:"text-xs text-gray-500 mt-0.5",children:["Cron ",e.jsx("span",{className:"font-mono",children:"15 7 * * *"})," (07:15 UTC daily) â scans every active product and variant; anything at/below the threshold emails the operator and is logged to ",e.jsx("span",{className:"font-mono",children:"cosmetics_stock_alert_runs"}),". Untracked (blank) inventory is never flagged."]})]}),e.jsxs("div",{className:"flex items-center gap-2 shrink-0",children:[e.jsx("label",{className:"text-xs text-gray-500",children:"Threshold"}),e.jsx("input",{type:"number",min:"0",max:"100",value:t,onChange:C=>s(C.target.value),className:"w-16 border border-gray-300 rounded-lg px-2 py-2 text-sm focus:outline-none focus:ring-2 focus:ring-gray-900"}),e.jsxs("button",{onClick:S,disabled:o,className:"inline-flex items-center gap-2 px-3 py-2 rounded-lg border border-gray-300 bg-white text-gray-800 text-sm font-semibold hover:bg-gray-50 disabled:opacity-50 transition-colors",children:[e.jsx(Be,{className:`h-4 w-4 ${o?"animate-spin":""}`}),"Re-scan"]}),e.jsxs("button",{onClick:_,disabled:y,className:"inline-flex items-center gap-2 px-3 py-2 rounded-lg bg-gray-900 text-white text-sm font-semibold hover:bg-gray-800 disabled:opacity-50 transition-colors",children:[e.jsx(Ye,{className:`h-4 w-4 ${y?"animate-pulse":""}`}),y?"Runningâ¦":"Run alert now"]})]})]}),(g||b||c)&&e.jsxs("div",{className:"mx-6 mt-4 space-y-2",children:[g&&e.jsxs("div",{className:"rounded-xl border border-emerald-200 bg-emerald-50 p-3 text-sm text-emerald-800 flex items-start gap-2",children:[e.jsx(Ue,{className:"h-4 w-4 mt-0.5 shrink-0"})," ",g]}),(b||c)&&e.jsxs("div",{className:"rounded-xl border border-red-200 bg-red-50 p-3 text-sm text-red-800 flex items-start gap-2",children:[e.jsx(kt,{className:"h-4 w-4 mt-0.5 shrink-0"})," ",b||c]})]}),r&&e.jsxs("div",{className:"px-6 py-4 grid grid-cols-3 gap-4",children:[e.jsxs("div",{className:"rounded-xl bg-gray-50 border border-gray-100 p-3",children:[e.jsx("p",{className:"text-xs text-gray-500",children:"Products scanned"}),e.jsx("p",{className:"text-xl font-bold text-gray-900",children:r.scanned_products})]}),e.jsxs("div",{className:`rounded-xl border p-3 ${r.low_stock_count>0?"bg-amber-50 border-amber-100":"bg-emerald-50 border-emerald-100"}`,children:[e.jsxs("p",{className:`text-xs ${r.low_stock_count>0?"text-amber-700":"text-emerald-700"}`,children:["Low stock (⤠",r.threshold,")"]}),e.jsx("p",{className:`text-xl font-bold ${r.low_stock_count>0?"text-amber-800":"text-emerald-800"}`,children:r.low_stock_count})]}),e.jsxs("div",{className:`rounded-xl border p-3 ${r.out_of_stock_count>0?"bg-red-50 border-red-100":"bg-gray-50 border-gray-100"}`,children:[e.jsx("p",{className:`text-xs ${r.out_of_stock_count>0?"text-red-700":"text-gray-500"}`,children:"Out of stock"}),e.jsx("p",{className:`text-xl font-bold ${r.out_of_stock_count>0?"text-red-800":"text-gray-900"}`,children:r.out_of_stock_count})]})]}),o&&n.length===0&&!r?e.jsx("div",{className:"px-6 pb-5 text-sm text-gray-500",children:"Scanning inventoryâ¦"}):n.length>0?e.jsxs("div",{className:"border-t border-gray-100 overflow-x-auto",children:[e.jsxs("table",{className:"w-full text-sm",children:[e.jsx("thead",{children:e.jsxs("tr",{className:"text-left text-xs text-gray-500 border-b border-gray-100",children:[e.jsx("th",{className:"px-6 py-2 font-medium",children:"Item"}),e.jsx("th",{className:"px-3 py-2 font-medium",children:"SKU"}),e.jsx("th",{className:"px-3 py-2 font-medium",children:"Type"}),e.jsx("th",{className:"px-3 py-2 font-medium",children:"Remaining"})]})}),e.jsx("tbody",{className:"divide-y divide-gray-50",children:n.slice(0,25).map(C=>e.jsxs("tr",{children:[e.jsxs("td",{className:"px-6 py-2 text-gray-800",children:[C.product_name,C.variant_title?e.jsxs("span",{className:"text-gray-500",children:[" â ",C.variant_title]}):null]}),e.jsx("td",{className:"px-3 py-2 font-mono text-xs text-gray-500",children:C.sku||"â"}),e.jsx("td",{className:"px-3 py-2 text-xs text-gray-500",children:C.kind}),e.jsx("td",{className:"px-3 py-2",children:e.jsx("span",{className:`inline-flex text-[11px] font-semibold px-2 py-0.5 rounded-full ${C.inventory_qty<=0?"bg-red-100 text-red-700":"bg-amber-100 text-amber-700"}`,children:C.inventory_qty<=0?"OUT OF STOCK":`${C.inventory_qty} left`})})]},C.variant_id||C.product_id))})]}),n.length>25&&e.jsxs("p",{className:"px-6 py-2 text-xs text-gray-400",children:["â¦and ",n.length-25," more."]})]}):r?e.jsx("div",{className:"px-6 pb-5 text-sm text-gray-500",children:"All tracked inventory is above the threshold."}):null,e.jsxs("div",{className:"border-t border-gray-100",children:[e.jsx("p",{className:"px-6 pt-3 text-xs font-semibold text-gray-500 uppercase tracking-wide",children:"Alert run history"}),x&&p.length===0?e.jsx("div",{className:"px-6 py-4 text-sm text-gray-500",children:"Loading run historyâ¦"}):p.length===0?e.jsx("div",{className:"px-6 py-4 text-sm text-gray-500",children:"No alert runs yet. The first daily scan lands at 07:15 UTC, or run one now."}):e.jsx("div",{className:"overflow-x-auto pb-1",children:e.jsxs("table",{className:"w-full text-sm",children:[e.jsx("thead",{children:e.jsxs("tr",{className:"text-left text-xs text-gray-500 border-b border-gray-100",children:[e.jsx("th",{className:"px-6 py-2 font-medium",children:"Ran at"}),e.jsx("th",{className:"px-3 py-2 font-medium",children:"Source"}),e.jsx("th",{className:"px-3 py-2 font-medium",children:"Threshold"}),e.jsx("th",{className:"px-3 py-2 font-medium",children:"Low"}),e.jsx("th",{className:"px-3 py-2 font-medium",children:"Out"}),e.jsx("th",{className:"px-3 py-2 font-medium",children:"Alert"})]})}),e.jsx("tbody",{className:"divide-y divide-gray-50",children:p.map(C=>e.jsxs("tr",{children:[e.jsx("td",{className:"px-6 py-2 text-gray-700 whitespace-nowrap",children:new Date(C.ran_at).toLocaleStr
1293ing()}),e.jsx("td",{className:"px-3 py-2 text-xs text-gray-500",children:C.trigger_source}),e.jsxs("td",{className:"px-3 py-2 text-gray-700",children:["⤠",C.threshold]}),e.jsx("td",{className:`px-3 py-2 font-semibold ${C.low_stock_count>0?"text-amber-700":"text-gray-700"}`,children:C.low_stock_count}),e.jsx("td",{className:`px-3 py-2 font-semibold ${C.out_of_stock_count>0?"text-red-700":"text-gray-700"}`,children:C.out_of_stock_count}),e.jsx("td",{className:"px-3 py-2",children:C.low_stock_count>0?C.alert_sent?e.jsxs("span",{className:"inline-flex items-center gap-1 text-[11px] font-semibold px-2 py-0.5 rounded-full bg-emerald-100 text-emerald-700",title:C.alert_recipient?`Sent to ${C.alert_recipient}`:void 0,children:[e.jsx(Ye,{className:"h-3 w-3"})," sent"]}):e.jsxs("span",{className:"inline-flex items-center gap-1 text-[11px] font-semibold px-2 py-0.5 rounded-full bg-red-100 text-red-700",title:C.alert_error||"Alert email was not delivered",children:[e.jsx(ve,{className:"h-3 w-3"})," not sent"]}):e.jsx("span",{className:"text-xs text-gray-400",children:"â clean"})})]},C.id))})]})})]})]})},Vu=({status:t})=>t==="pass"?e.jsx(Ue,{className:"h-5 w-5 text-emerald-600 shrink-0"}):t==="fail"?e.jsx(kt,{className:"h-5 w-5 text-red-600 shrink-0"}):e.jsx(jO,{className:"h-5 w-5 text-gray-400 shrink-0"}),xN=({ok:t,passLabel:s,failLabel:n})=>e.jsxs("span",{className:`inline-flex items-center gap-1 text-xs font-semibold px-2 py-0.5 rounded-full ${t?"bg-emerald-100 text-emerald-700":"bg-red-100 text-red-700"}`,children:[t?e.jsx(Ue,{className:"h-3.5 w-3.5"}):e.jsx(kt,{className:"h-3.5 w-3.5"}),t?s:n]}),Pie=()=>{const[t,s]=d.useState(null),[n,a]=d.useState(!1),[r,i]=d.useState(""),[o,l]=d.useState(null),c=d.useCallback(async()=>{a(!0),i("");try{const{data:p,error:m}=await O.functions.invoke("create-cosmetics-payment-intent",{body:{action:"health"}});m?(s({ok:!1,code:"cosmetics_key_not_configured"}),i("Dedicated Cosmetics key not configured or health check unreachable. The checkout stays on the shared rail until the vault pair is present.")):p?(s(p),p.ok===!1&&p.error&&i(p.error)):i("Unexpected response from the Cosmetics health check."),l(new Date)}catch(p){i((p==null?void 0:p.message)||"Cosmetics health check failed.")}finally{a(!1)}},[]);d.useEffect(()=>{c()},[c]);const u=(t==null?void 0:t.ok)===!0;return e.jsxs("section",{className:"bg-white rounded-2xl border border-gray-200",children:[e.jsxs("div",{className:"px-6 py-4 border-b border-gray-100 flex items-center justify-between gap-3",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"font-semibold text-gray-900",children:"Cosmetics rail (dedicated account)"}),e.jsxs("p",{className:"text-xs text-gray-500 mt-0.5",children:["Read-only ",e.jsx("span",{className:"font-mono",children:"health"})," action of"," ",e.jsx("span",{className:"font-mono",children:"create-cosmetics-payment-intent"})," â verifies the isolated Cosmetics key without touching the shared or Institute rails.",o&&e.jsxs(e.Fragment,{children:[" Last checked ",o.toLocaleString(),"."]})]})]}),e.jsxs("button",{onClick:c,disabled:n,className:"inline-flex items-center gap-2 px-3 py-2 rounded-lg border border-gray-300 bg-white text-gray-800 text-sm font-semibold hover:bg-gray-50 disabled:opacity-50 transition-colors shrink-0",children:[e.jsx(Be,{className:`h-4 w-4 ${n?"animate-spin":""}`}),"Re-check"]})]}),n&&!t?e.jsx("div",{className:"px-6 py-6 text-sm text-gray-500",children:"Running Cosmetics health checkâ¦"}):e.jsxs(e.Fragment,{children:[r&&e.jsx("div",{className:"mx-6 mt-4 rounded-xl border border-red-200 bg-red-50 p-3 text-sm text-red-800",children:r}),t&&e.jsxs("div",{className:"px-6 py-4 grid sm:grid-cols-2 gap-x-6 gap-y-4",children:[e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx(Vu,{status:u?"pass":"fail"}),e.jsxs("div",{children:[e.jsx("p",{className:"font-medium text-gray-900 text-sm",children:"Connected account"}),e.jsx("p",{className:"text-sm text-gray-600 mt-1",children:u?e.jsxs(e.Fragment,{children:[t.businessName||"Unnamed account"," ",e.jsxs("span",{className:"font-mono text-xs",children:["(",t.accountId,")"]}),t.chargesEnabled!=null&&e.jsxs(e.Fragment,{children:[" · charges ",t.chargesEnabled?"enabled":"disabled"]})]}):"Dedicated Cosmetics secret key did not authenticate."})]})]}),e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx(Vu,{status:u?"pass":"skipped"}),e.jsxs("div",{children:[e.jsx("p",{className:"font-medium text-gray-900 text-sm",children:"Key mode"}),e.jsx("p",{className:"text-sm text-gray-600 mt-1",children:u?e.jsx("span",{className:`inline-flex text-xs font-bold uppercase tracking-wide px-2 py-0.5 rounded-full ${t.mode==="live"?"bg-emerald-100 text-emerald-700":"bg-amber-100 text-amber-700"}`,children:t.mode==="live"?"LIVE mode":"TEST mode"}):"Unavailable until the key authenticates."})]})]}),e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx(Vu,{status:t.matchedPair?"pass":u?"fail":"skipped"}),e.jsxs("div",{children:[e.jsx("p",{className:"font-medium text-gray-900 text-sm",children:"Matched key pair"}),e.jsx("div",{className:"text-sm text-gray-600 mt-1",children:u?e.jsx(xN,{ok:!!t.matchedPair,passLabel:"Publishable key matches this account",failLabel:t.publishableKeyConfigured?"Publishable key does not match this account":"Publishable key missing"}):"Unavailable until the key authenticates."})]})]}),e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx(Vu,{status:t.webhookSecretConfigured?"pass":"fail"}),e.jsxs("div",{children:[e.jsx("p",{className:"font-medium text-gray-900 text-sm",children:"Webhook signing secret"}),e.jsxs("div",{className:"text-sm text-gray-600 mt-1",children:[e.jsx(xN,{ok:!!t.webhookSecretConfigured,passLabel:"Present in vault",failLabel:"Not configured"}),t.webhookSecretConfigured&&t.webhookSecretName&&e.jsx("span",{className:"ml-2 font-mono text-xs",children:t.webhookSecretName}),!t.webhookSecretConfigured&&e.jsxs("p",{className:"mt-1 text-xs text-gray-500",children:["Paste the ",e.jsx("span",{className:"font-mono",children:"whsec_â¦"})," signing secret as"," ",e.jsx("span",{className:"font-mono",children:"COSMETICS_FAMOUSPAY_WEBHOOK_SECRET"}
1293)," to enable webhook reconciliation."]})]})]})]})]})]})]})},Die=()=>{const[t,s]=d.useState(null),[n,a]=d.useState(!1),[r,i]=d.useState(""),o=d.useCallback(async()=>{a(!0),i("");try{const{data:l,error:c}=await O.functions.invoke("cosmetics-reconciliation-report",{body:{action:"controlled-test"}});c?i("Controlled test request failed. The Cosmetics key may not be configured."):l?(s(l),l.ok===!1&&l.error&&i(l.error)):i("Unexpected response from the controlled test.")}catch(l){i((l==null?void 0:l.message)||"Controlled test failed.")}finally{a(!1)}},[]);return e.jsxs("section",{className:"bg-white rounded-2xl border border-gray-200",children:[e.jsxs("div",{className:"px-6 py-4 border-b border-gray-100 flex items-center justify-between gap-3",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"font-semibold text-gray-900",children:"Controlled Cosmetics test"}),e.jsxs("p",{className:"text-xs text-gray-500 mt-0.5",children:["Creates a $1.00 PaymentIntent stamped"," ",e.jsx("span",{className:"font-mono",children:"diagnostic=true"})," on the dedicated Cosmetics account, verifies the isolation stamp and live/test mode, then cancels it in the same request â ",e.jsx("strong",{children:"nothing is ever charged"}),"."]})]}),e.jsxs("button",{onClick:o,disabled:n,className:"inline-flex items-center gap-2 px-3 py-2 rounded-lg bg-gray-900 text-white text-sm font-semibold hover:bg-gray-800 disabled:opacity-50 transition-colors shrink-0",children:[e.jsx(Qx,{className:`h-4 w-4 ${n?"animate-pulse":""}`}),n?"Runningâ¦":"Run controlled test"]})]}),r&&e.jsx("div",{className:"mx-6 mt-4 rounded-xl border border-red-200 bg-red-50 p-3 text-sm text-red-800",children:r}),t!=null&&t.steps?e.jsxs("div",{className:"divide-y divide-gray-100",children:[e.jsxs("div",{className:"px-6 py-3 flex flex-wrap items-center gap-2 text-sm",children:[e.jsx(xN,{ok:t.ok,passLabel:"All steps passed",failLabel:"One or more steps failed"}),t.paymentIntentId&&e.jsx("span",{className:"font-mono text-xs text-gray-500",children:t.paymentIntentId}),t.finalStatus&&e.jsxs("span",{className:"text-xs text-gray-500",children:["final status: ",t.finalStatus]}),t.checkedAt&&e.jsx("span",{className:"text-xs text-gray-400",children:new Date(t.checkedAt).toLocaleString()})]}),t.steps.map(l=>e.jsxs("div",{className:"px-6 py-3 flex items-start gap-3",children:[e.jsx(Vu,{status:l.ok?"pass":"fail"}),e.jsxs("div",{children:[e.jsx("p",{className:"font-medium text-gray-900 text-sm capitalize",children:l.step.replace(/-/g," ")}),e.jsx("p",{className:"text-sm text-gray-600 mt-0.5",children:l.detail})]})]},l.step))]}):!r&&e.jsxs("div",{className:"px-6 py-5 text-sm text-gray-500",children:["No test run yet. Click ",e.jsx("strong",{children:"Run controlled test"})," to verify the Cosmetics rail end-to-end (create â verify stamp â cancel)."]})]})},Rie=t=>({settled:"bg-emerald-100 text-emerald-700",pending_settlement:"bg-amber-100 text-amber-700",refunded:"bg-purple-100 text-purple-700",unsettled:"bg-gray-100 text-gray-600",not_found:"bg-red-100 text-red-700",mismatch:"bg-red-100 text-red-700",no_payment_intent:"bg-gray-100 text-gray-500",unverified:"bg-gray-100 text-gray-500"})[t]||"bg-gray-100 text-gray-600",Iie=()=>{const[t,s]=d.useState(null),[n,a]=d.useState(!1),[r,i]=d.useState(""),o=d.useCallback(async()=>{a(!0),i("");try{const{data:c,error:u}=await O.functions.invoke("cosmetics-reconciliation-report",{body:{action:"report",limit:50}});u?i("Reconciliation request failed. The Cosmetics key may not be configured."):c?(s(c),c.ok===!1&&c.error&&i(c.error)):i("Unexpected response from the reconciliation report.")}catch(c){i((c==null?void 0:c.message)||"Reconciliation report failed.")}finally{a(!1)}},[]),l=t==null?void 0:t.summary;return e.jsxs("section",{className:"bg-white rounded-2xl border border-gray-200",children:[e.jsxs("div",{className:"px-6 py-4 border-b border-gray-100 flex items-center justify-between gap-3",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"font-semibold text-gray-900",children:"Cosmetics reconciliation report"}),e.jsx("p",{className:"text-xs text-gray-500 mt-0.5",children:"Read-only two-way cross-check: every Cosmetics order is verified against the dedicated Stripe account (settlement status), and every succeeded payment on the account is checked for a matching order (orphan sweep). No data is modified."})]}),e.jsxs("button",{onClick:o,disabled:n,className:"inline-flex items-center gap-2 px-3 py-2 rounded-lg border border-gray-300 bg-white text-gray-800 text-sm font-semibold hover:bg-gray-50 disabled:opacity-50 transition-colors shrink-0",children:[e.jsx(Be,{className:`h-4 w-4 ${n?"animate-spin":""}`}),n?"Reconcilingâ¦":"Run reconciliation"]})]}),r&&e.jsx("div",{className:"mx-6 mt-4 rounded-xl border border-red-200 bg-red-50 p-3 text-sm text-red-800",children:r}),l?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"px-6 py-4 grid grid-cols-2 sm:grid-cols-4 gap-4",children:[e.jsxs("div",{className:"rounded-xl bg-gray-50 border border-gray-100 p-3",children:[e.jsx("p",{className:"text-xs text-gray-500",children:"Orders checked"}),e.jsx("p",{className:"text-xl font-bold text-gray-900",children:l.ordersChecked})]}),e.jsxs("div",{className:"rounded-xl bg-emerald-50 border border-emerald-100 p-3",children:[e.jsx("p",{className:"text-xs text-emerald-700",children:"Settled"}),e.jsxs("p",{className:"text-xl font-bold text-emerald-800",children:["$",(l.settledCents/100).toFixed(2)]})]}),e.jsxs("div",{className:"rounded-xl bg-amber-50 border border-amber-100 p-3",children:[e.jsx("p",{className:"text-xs text-amber-700",children:"Pending settlement"}),e.jsxs("p",{className:"text-xl font-bold text-amber-800",children:["$",(l.pendingSettlementCents/100).toFixed(2)]})]}),e.jsxs("div",{className:`rounded-xl border p-3 ${l.issueCount>0||l.orphanPayments>0?"bg-red-50 border-red-100":"bg-gray-50 border-gray-100"}`,children:[e.jsx("p",{className:`text-xs ${l.issueCount>0||l.orphanPayments>0?"text-red-700":"text-gray-500"}`,children:"Issues / orphans"}),e.jsxs("p",{className:`text-xl font-bold ${l.issueCount>0||l.orphanPayments>0?"text-red-800":"text-gray-900"}`,children:[l.issueCount," / ",l.orphanPayments]})]})]}),e.jsxs("div",{className:"px-6 pb-3 flex flex-wrap gap-x-4 gap-y-1 text-xs text-gray-500",children:[e.jsxs("span",{children:["Stripe cosmetics PIs
1293scanned: ",e.jsx("strong",{className:"text-gray-700",children:l.stripeCosmeticsPiCount})]}),e.jsxs("span",{children:["Diagnostic / health-check PIs: ",e.jsx("strong",{className:"text-gray-700",children:l.diagnosticPiCount})]}),e.jsxs("span",{children:["Abandoned / incomplete attempts: ",e.jsx("strong",{className:"text-gray-700",children:l.incompletePiCount})]}),e.jsxs("span",{children:["Checked ",new Date(l.checkedAt).toLocaleString()]})]}),(t==null?void 0:t.orphans)&&t.orphans.length>0&&e.jsxs("div",{className:"mx-6 mb-4 rounded-xl border border-red-200 bg-red-50 p-4",children:[e.jsx("p",{className:"text-sm font-semibold text-red-800",children:"Orphan payments â money received with no matching order"}),e.jsx("ul",{className:"mt-2 space-y-1 text-sm text-red-800",children:t.orphans.map(c=>e.jsxs("li",{children:[e.jsx("span",{className:"font-mono text-xs",children:c.payment_intent_id})," â $",(c.amount_cents/100).toFixed(2)," ·"," ",new Date(c.created).toLocaleString()]},c.payment_intent_id))})]}),t!=null&&t.orders&&t.orders.length>0?e.jsx("div",{className:"border-t border-gray-100 overflow-x-auto",children:e.jsxs("table",{className:"w-full text-sm",children:[e.jsx("thead",{children:e.jsxs("tr",{className:"text-left text-xs text-gray-500 border-b border-gray-100",children:[e.jsx("th",{className:"px-6 py-2 font-medium",children:"Order"}),e.jsx("th",{className:"px-3 py-2 font-medium",children:"Total"}),e.jsx("th",{className:"px-3 py-2 font-medium",children:"Order status"}),e.jsx("th",{className:"px-3 py-2 font-medium",children:"Stripe status"}),e.jsx("th",{className:"px-3 py-2 font-medium",children:"Settlement"}),e.jsx("th",{className:"px-3 py-2 font-medium",children:"Notes"})]})}),e.jsx("tbody",{className:"divide-y divide-gray-50",children:t.orders.map(c=>e.jsxs("tr",{children:[e.jsxs("td",{className:"px-6 py-2 font-mono text-xs text-gray-600",children:[c.order_id.slice(0,8),"â¦"]}),e.jsxs("td",{className:"px-3 py-2 text-gray-900",children:["$",(c.total_cents/100).toFixed(2)]}),e.jsx("td",{className:"px-3 py-2 text-gray-600",children:c.order_status}),e.jsx("td",{className:"px-3 py-2 text-gray-600",children:c.stripe_status||"â"}),e.jsx("td",{className:"px-3 py-2",children:e.jsx("span",{className:`inline-flex text-[11px] font-semibold px-2 py-0.5 rounded-full ${Rie(c.settlement_status)}`,children:c.settlement_status.replace(/_/g," ")})}),e.jsx("td",{className:"px-3 py-2 text-xs text-gray-500",children:c.notes.length?c.notes.join(" · "):"â"})]},c.order_id))})]})}):e.jsx("div",{className:"px-6 pb-5 text-sm text-gray-500",children:"No Cosmetics orders recorded yet â the orphan sweep above still verifies that no unmatched payments exist on the dedicated account."})]}):!r&&e.jsxs("div",{className:"px-6 py-5 text-sm text-gray-500",children:["Click ",e.jsx("strong",{children:"Run reconciliation"})," to cross-check Cosmetics orders against the dedicated FamousPay account."]})]})},$ie=()=>{var p,m;sn(),d.useEffect(()=>{document.title="Payment Configuration Health â Admin"},[]);const[t,s]=d.useState(null),[n,a]=d.useState(!1),[r,i]=d.useState(!1),[o,l]=d.useState(""),c=d.useCallback(async x=>{const h=x==="test_intent";h?i(!0):a(!0),l("");try{const{data:y,error:v}=await O.functions.invoke("payment-config-health",{body:{action:x}});v?l("Verification request failed. Confirm you are signed in with an admin session and try again."):y!=null&&y.error?l(y.error):y!=null&&y.checks?s(y):l("Unexpected response from the health check service.")}catch(y){l((y==null?void 0:y.message)||"Verification request failed.")}finally{h?i(!1):a(!1)}},[]);d.useEffect(()=>{c("status")},[c]);const u=(t==null?void 0:t.paymentReady)===!0;return e.jsxs("div",{className:"min-h-screen bg-gray-50",children:[e.jsx("header",{className:"bg-white border-b border-gray-200",children:e.jsxs("div",{className:"max-w-4xl mx-auto px-4 sm:px-6 py-5 flex items-center justify-between gap-4",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"h-10 w-10 rounded-xl bg-gray-900 flex items-center justify-center",children:e.jsx(ka,{className:"h-5 w-5 text-amber-400"})}),e.jsxs("div",{children:[e.jsx("h1",{className:"text-lg sm:text-xl font-bold text-gray-900",children:"Payment Configuration Health"}),e.jsxs("p",{className:"text-xs text-gray-500 flex items-center gap-1",children:[e.jsx(Xe,{className:"h-3 w-3"})," Admin-only · Secret values are never displayed"]})]})]}),e.jsxs(be,{to:"/",className:"inline-flex items-center gap-1.5 text-sm text-gray-600 hover:text-gray-900 font-medium",children:[e.jsx(Je,{className:"h-4 w-4"})," Site"]})]})}),e.jsxs("main",{className:"max-w-4xl mx-auto px-4 sm:px-6 py-8 space-y-6",children:[e.jsxs("section",{className:`rounded-2xl border p-6 sm:p-8 flex flex-col sm:flex-row sm:items-center gap-5 ${t?u?"bg-emerald-50 border-emerald-200":"bg-red-50 border-red-200":"bg-white border-gray-200"}`,children:[e.jsx("div",{className:`h-16 w-16 rounded-2xl flex items-center justify-center shrink-0 ${t?u?"bg-emerald-600":"bg-red-600":"bg-gray-300"}`,children:t?u?e.jsx(Ie,{className:"h-9 w-9 text-white"}):e.jsx(zn,{className:"h-9 w-9 text-white"}):e.jsx(Be,{className:`h-8 w-8 text-white ${n?"animate-spin":""}`})}),e.jsxs("div",{className:"flex-1",children:[e.jsx("p",{className:`text-2xl font-bold ${t?u?"text-emerald-800":"text-red-800":"text-gray-700"}`,children:n&&!t?"Running verificationâ¦":u?"PAYMENT READY â Launch blocker cleared":t?"NOT READY â Configuration issue detected":"Awaiting verification"}),t&&e.jsxs("p",{className:"text-sm text-gray-600 mt-1",children:["Last verified ",new Date(t.checkedAt).toLocaleStr
1293ing()," by ",t.checkedBy," · ","Key: ",e.jsx("span",{className:"font-mono",children:t.keyInfo.prefixClass}),t.keyInfo.configured&&e.jsxs(e.Fragment,{children:[" ","(",t.keyInfo.mode==="live"?"LIVE mode":t.keyInfo.mode==="test"?"TEST mode":"unknown mode",","," ","length ",t.keyInfo.length,")"]})]})]}),e.jsxs("div",{className:"flex flex-col sm:items-end gap-2",children:[e.jsxs("button",{onClick:()=>c("status"),disabled:n||r,className:"inline-flex items-center justify-center gap-2 px-4 py-2 rounded-lg bg-gray-900 text-white text-sm font-semibold hover:bg-gray-800 disabled:opacity-50 transition-colors",children:[e.jsx(Be,{className:`h-4 w-4 ${n?"animate-spin":""}`}),"Re-run verification"]}),e.jsxs("button",{onClick:()=>c("test_intent"),disabled:n||r||!((p=t==null?void 0:t.keyInfo)!=null&&p.configured),title:(m=t==null?void 0:t.keyInfo)!=null&&m.configured?"Creates a $1.00 payment intent tagged as a health check, then cancels it immediately â nothing is charged":"Configure the vault secret first",className:"inline-flex items-center justify-center gap-2 px-4 py-2 rounded-lg border border-gray-300 bg-white text-gray-800 text-sm font-semibold hover:bg-gray-50 disabled:opacity-50 transition-colors",children:[e.jsx(Qx,{className:`h-4 w-4 ${r?"animate-pulse":""}`}),r?"Running controlled testâ¦":"Run controlled test intent"]})]})]}),o&&e.jsx("div",{className:"rounded-xl border border-red-200 bg-red-50 p-4 text-sm text-red-800",children:o}),t&&e.jsxs("section",{className:"bg-white rounded-2xl border border-gray-200 divide-y divide-gray-100",children:[e.jsxs("div",{className:"px-6 py-4",children:[e.jsx("h2",{className:"font-semibold text-gray-900",children:"Verification checks"}),e.jsx("p",{className:"text-xs text-gray-500 mt-0.5",children:"All checks run server-side inside the secure edge runtime. The secret key value never leaves the vault."})]}),t.checks.map(x=>e.jsxs("div",{className:"px-6 py-4 flex items-start gap-3",children:[e.jsx(Vu,{status:x.status}),e.jsxs("div",{className:"min-w-0",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx("p",{className:"font-medium text-gray-900 text-sm",children:x.label}),e.jsx("span",{className:`text-[10px] font-bold uppercase tracking-wide px-2 py-0.5 rounded-full ${x.status==="pass"?"bg-emerald-100 text-emerald-700":x.status==="fail"?"bg-red-100 text-red-700":"bg-gray-100 text-gray-500"}`,children:x.status})]}),e.jsx("p",{className:"text-sm text-gray-600 mt-1",children:x.detail})]})]},x.id))]}),(t==null?void 0:t.remediation)&&e.jsxs("section",{className:"rounded-2xl border border-amber-200 bg-amber-50 p-6",children:[e.jsxs("h2",{className:"font-semibold text-amber-900 flex items-center gap-2",children:[e.jsx(zn,{className:"h-5 w-5"})," Operator action required"]}),e.jsx("p",{className:"text-sm text-amber-900 mt-2",children:t.remediation}),e.jsxs("ol",{className:"mt-3 text-sm text-amber-900 list-decimal list-inside space-y-1",children:[e.jsx("li",{children:"Open the Stripe dashboard â Developers â API keys"}),e.jsxs("li",{children:["Reveal and copy the full ",e.jsx("span",{className:"font-mono",children:"sk_live_â¦"})," secret key (not the ",e.jsx("span",{className:"font-mono",children:"pk_â¦"})," publishable key)"]}),e.jsxs("li",{children:["Re-save it in Project Settings â Secrets under the exact name ",e.jsx("span",{className:"font-mono",children:"FAMOUSPAY_SECRET_KEY"})]}),e.jsxs("li",{children:["Return here and click ",e.jsx("strong",{children:"Re-run verification"}),", then ",e.jsx("strong",{children:"Run controlled test intent"})]})]})]}),e.jsx(Pie,{}),e.jsx(Die,{}),e.jsx(Iie,{}),e.jsx(Nie,{}),e.jsx(Aie,{}),e.jsx(Sie,{}),e.jsx(Eie,{}),e.jsx(Fie,{}),e.jsx(Tie,{}),e.jsxs("section",{className:"rounded-2xl border border-gray-200 bg-white p-6",children:[e.jsx("h2",{className:"font-semibold text-gray-900",children:"About the controlled test"}),e.jsxs("ul",{className:"mt-2 text-sm text-gray-600 space-y-1.5 list-disc list-inside",children:[e.jsxs("li",{children:["Creates a $1.00 payment intent tagged ",e.jsx("span",{className:"font-mono",children:"health_check=true"}),", then cancels it in the same request â ",e.jsx("strong",{children:"nothing is ever charged"}),"."]}),e.jsx("li",{children:"Read-only connectivity verification uses the Stripe balance endpoint â no data is created or modified."}),e.jsx("li",{children:"No secret material is transmitted to the browser; only pass/fail statuses, key mode class, and length."}),e.jsx("li",{children:"Existing booking, client payment, donation, and checkout workflows are untouched by this panel."})]})]})]})]})},e$="z_institute_payments",zie="institute-reconciliation-report",uxe=t=>{const s="ZI-CLINIC",n=Math.random().toString(36).slice(2,8).toUpperCase();return`${s}-${new Date().getFullYear()}-${n}`},mxe=async t=>{try{const{error:s}=await O.from(e$).insert({receipt_number:t.receiptNumber,student_ref:t.studentRef||null,sis_student_id:null,
1293student_name:t.studentName||null,student_email:t.studentEmail||null,program:t.program||null,payment_type:t.paymentType,amount_cents:t.amountCents,currency:"usd",status:"paid",stripe_payment_intent_id:t.stripePaymentIntentId||null,payment_rail:"institute-isolated",financial_record_id:t.financialRecordId||null,clinic_audit_id:t.clinicAuditId||null,clinic_audit_reference:t.clinicAuditReference||null,balance_after_cents:t.balanceAfterCents??null,metadata:t.metadata||{},paid_at:new Date().toISOString()});return s?(console.warn("Institute pay monitor insert failed:",s.message),{ok:!1}):{ok:!0}}catch(s){return console.warn("Institute pay monitor insert threw:",s),{ok:!1}}},mu=t=>t==null?"â":`$${(Math.abs(t)/100).toFixed(2)}`,Lie=!0,QE="pk_live_51TU3r91mz9T3Ao4lbYviFZ2gZP3B6IGG8AJ8xnKA7sbesalstjRKVPrxser3QGHcVQu8AqivJuwOsUT5fRUr8IV600CbNxJfxK",t$="create-institute-payment-intent",Oie="create-institute-clinic-intent",pxe=()=>Oie,Om="z_institute_funding_sources",fN="z_institute_tuition_accounts",Tl={scholarship:"Scholarship",grant:"Grant",loan:"Loan / Financial Aid"},Mie={scholarship:"scholarship",grant:"financial_aid",loan:"financial_aid"},gN=t=>Math.max(0,(t.approved_amount_cents||0)-(t.applied_to_tuition_cents||0)),yN=(t,s)=>{const n=s.filter(x=>x.status!=="cancelled"),a=(x,h)=>n.filter(y=>y.funding_kind===x).reduce((y,v)=>y+(v[h]||0),0),r=a("scholarship","applied_to_tuition_cents"),i=a("grant","applied_to_tuition_cents"),o=a("loan","applied_to_tuition_cents"),l=a("scholarship","approved_amount_cents"),c=a("grant","approved_amount_cents"),u=a("loan","approved_amount_cents"),p=r+i+o,m=l+c+u;return{totalTuitionCents:t,scholarshipsAppliedCents:r,grantsAppliedCents:i,loansAppliedCents:o,totalFundingAppliedCents:p,scholarshipsApprovedCents:l,grantsApprovedCents:c,loansApprovedCents:u,totalFundingApprovedCents:m,remainingResponsibilityCents:t-p,projectedResponsibilityCents:t-m}},Bie=()=>`ZI-FUND-${new Date().getFullYear()}-${Math.random().toString(36).slice(2,8).toUpperCase()}`,Wn=t=>t==null?"â":`${t<0?"-":""}$${(Math.abs(t)/100).toLocaleString("en-US",{minimumFractionDigits:2,maximumFractionDigits:2})}`,Uie=async(t,s)=>{const{data:n}=await O.from(Om).select("*").eq("student_ref",t).order("created_at",{ascending:!1});if(n&&n.length>0)return n;if(s){const{data:a}=await O.from(Om).select("*").ilike("student_name",s).order("created_at",{ascending:!1});return a||[]}return[]},qie=async t=>{const{data:s}=await O.from(fN).select("*").eq("student_ref",t).maybeSingle();return s||null},Wie=async(t,s,n="admin")=>{try{if(s<=0)return{ok:!1,error:"Amount must be greater than zero."};const a=gN(t);if(s>a)return{ok:!1,error:`Amount exceeds remaining ${Tl[t.funding_kind].toLowerCase()} balance (${Wn(a)}).`};const r=Bie(),i=new Date().toISOString(),o=i.slice(0,10),l=Tl[t.funding_kind],{error:c}=await O.from("z_student_financial_records").insert({student_id:t.student_ref,record_type:Mie[t.funding_kind],description:`${l}: ${t.name}${t.source?` (${t.source})`:""} â applied to tuition`,amount_cents:s,balance_cents:0,paid_date:o,payment_method:`${l} Credit`,reference_number:r,status:"applied",notes:`Funding source ${t.id} · ${l} "${t.name}" · applied ${Wn(s)} to tuition by ${n} · Institute funding structure (no payment rail charge)`,verification_status:"verified"});if(c)return{ok:!1,error:`Ledger write failed: ${c.message}`};const u=(t.applied_to_tuition_cents||0)+s,p=[...t.disbursement_schedule||[],{date:o,amount_cents:s,status:"disbursed",ledger_reference:r,disbursed_at:i}],m=u>=(t.approved_amount_cents||0),{error:x}=await O.from(Om).update({applied_to_tuition_cents:u,disbursement_schedule:p,status:m?"exhausted":t.status==="exhausted"?"active":t.status,updated_at:i}).eq("id",t.id);return x?{ok:!1,error:`Funding update failed (ledger row ${r} was written): ${x.message}`}:{ok:!0,reference:r}}catch(a){return{ok:!1,error:(a==null?void 0:a.message)||"Failed to apply funding."}}},Hie=async t=>{const s=[];if(t.forEach(r=>(r.disbursement_schedule||[]).forEach(i=>{i.status==="disbursed"&&i.ledger_reference&&s.push({reference:i.ledger_reference,amount_cents:i.amount_cents,fundingName:r.name})})),s.length===0)return[];const{data:n}=await O.from("z_student_financial_records").select("reference_number").in("reference_number",s.map(r=>r.reference)),a=new Set((n||[]).map(r=>r.reference_number));return s.map(r=>({...r,linked:a.has(r.reference)}))},kc="#800020",Gie={scholarship:e.jsx(_t,{size:16}),grant:e.jsx(Zm,{size:16}),loan:e.jsx(Do,{size:16})},JE=t=>t?(t/100).toFixed(2):"",Vie=({studentRef:t,studentName:s,program:n,existing:a,onClose:r,onSaved:i})=>{const[o,l]=d.useState((a==null?void 0:a.funding_kind)||"scholarship"),[c,u]=d.useState({name:(a==null?void 0:a.name)||"",source:(a==null?void 0:a.source)||"",approvedAmount:JE(a==null?void 0:a.approved_amount_cents),appliedAmount:JE(a==null?void 0:a.applied_to_tuition_cents)||"0.00",awardDate:(a==null?void 0:a.award_date)||"",periodStart:(a==null?void 0:a.award_period_start)||"",periodEnd:(a==null?void 0:a.award_period_end)||"",eligibility:(a==null?void 0:a.eligibility_criteria)||"",status:(a==null?void 0:a.status)||"active",notes:(a==null?void 0:a.notes)||""}
1293),[p,m]=d.useState(((a==null?void 0:a.disbursement_schedule)||[]).filter(_=>_.status==="scheduled")),x=((a==null?void 0:a.disbursement_schedule)||[]).filter(_=>_.status==="disbursed"),[h,y]=d.useState({date:"",amount:""}),[v,g]=d.useState(!1),[N,b]=d.useState(""),f=_=>C=>u(E=>({...E,[_]:C.target.value})),j=()=>{const _=Math.round(parseFloat(h.amount)*100);!h.date||isNaN(_)||_<=0||(m(C=>[...C,{date:h.date,amount_cents:_,status:"scheduled"}]),y({date:"",amount:""}))},S=async()=>{b("");const _=Math.round(parseFloat(c.approvedAmount||"0")*100),C=Math.round(parseFloat(c.appliedAmount||"0")*100);if(!c.name.trim()){b(`${Tl[o]} name is required.`);return}if(isNaN(_)||_<=0){b("Approved/award amount must be greater than zero.");return}if(isNaN(C)||C<0){b("Applied amount cannot be negative.");return}if(C>_){b("Amount applied to tuition cannot exceed the approved amount.");return}g(!0);const E={student_ref:t,sis_student_id:(a==null?void 0:a.sis_student_id)||null,student_name:s,program:n||null,funding_kind:o,name:c.name.trim(),source:c.source.trim()||null,approved_amount_cents:_,applied_to_tuition_cents:C,award_date:c.awardDate||null,award_period_start:c.periodStart||null,award_period_end:c.periodEnd||null,eligibility_criteria:c.eligibility.trim()||null,disbursement_schedule:[...x,...p],status:C>=_?"exhausted":c.status,notes:c.notes.trim()||null,updated_at:new Date().toISOString()},{error:P}=a?await O.from(Om).update(E).eq("id",a.id):await O.from(Om).insert(E);if(g(!1),P){b(P.message);return}i(),r()},w=o==="grant"||o==="loan";return e.jsxs("div",{className:"fixed inset-0 z-50 flex items-center justify-center p-4",onClick:()=>!v&&r(),children:[e.jsx("div",{className:"absolute inset-0 bg-black/40 backdrop-blur-sm"}),e.jsxs("div",{className:"relative bg-white rounded-2xl shadow-2xl w-full max-w-xl overflow-hidden",onClick:_=>_.stopPropagation(),children:[e.jsx("div",{className:"h-1.5",style:{background:`linear-gradient(90deg, ${kc}, #D4AF37, ${kc})`}}),e.jsxs("div",{className:"px-6 pt-5 pb-4 border-b border-gray-100 flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsxs("h3",{className:"text-lg font-bold text-gray-900",children:[a?"Edit":"Add"," Funding Source"]}),e.jsxs("p",{className:"text-xs text-gray-500",children:[s," · ",e.jsx("span",{className:"font-mono",children:t}),n?` · ${n}`:""]})]}),e.jsx("button",{onClick:r,disabled:v,className:"p-2 rounded-lg hover:bg-gray-100 text-gray-400",children:e.jsx(Ke,{size:18})})]}),e.jsxs("div",{className:"px-6 py-5 space-y-4 max-h-[65vh] overflow-y-auto",children:[e.jsx("div",{className:"grid grid-cols-3 gap-2",children:Object.keys(Tl).map(_=>e.jsxs("button",{onClick:()=>!a&&l(_),disabled:!!a,className:`flex items-center justify-center gap-2 p-3 rounded-xl border-2 text-xs font-bold transition-all ${o===_?"text-white":"text-gray-600 border-gray-200 hover:border-gray-300"} ${a&&o!==_?"opacity-40":""}`,style:o===_?{background:kc,borderColor:kc}:{},children:[Gie[_]," ",Tl[_]]},_))}),e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{className:"col-span-2",children:[e.jsxs("label",{className:"text-xs font-semibold text-gray-700 mb-1 block",children:[o==="scholarship"?"Scholarship Name":o==="grant"?"Grant Name":"Loan Type"," *"]}),e.jsx("input",{value:c.name,onChange:f("name"),placeholder:o==="scholarship"?"e.g. Zorganics Excellence Scholarship":o==="grant"?"e.g. WIOA Workforce Grant":"e.g. Z Bank Institutional Loan / Direct Subsidized",className:"w-full px-3 py-2.5 border border-gray-200 rounded-lg text-sm"})]}),w&&e.jsxs("div",{className:"col-span-2",children:[e.jsx("label",{className:"text-xs font-semibold text-gray-700 mb-1 block",children:o==="grant"?"Grant Source":"Funding Source"}),e.jsx("input",{value:c.source,onChange:f("source"),placeholder:o==="grant"?"e.g. WA Workforce Board":"e.g. Z Bank / Federal Direct",className:"w-full px-3 py-2.5 border border-gray-200 rounded-lg text-sm"})]}),e.jsxs("div",{children:[e.jsxs("label",{className:"text-xs font-semibold text-gray-700 mb-1 block",children:[o==="scholarship"?"Award Amount ($)":"Approved Amount ($)"," *"]}),e.jsx("input",{type:"number",min:"0",step:"0.01",value:c.approvedAmount,onChange:f("approvedAmount"),className:"w-full px-3 py-2.5 border border-gray-200 rounded-lg text-sm font-mono"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-xs font-semibold text-gray-700 mb-1 block",children:"Applied to Tuition ($)"}),e.jsx("input",{type:"number",min:"0",step:"0.01",value:c.appliedAmount,onChange:f("appliedAmount"),className:"w-full px-3 py-2.5 border border-gray-200 rounded-lg text-sm font-mono"}),e.jsx("p",{className:"text-[9px] text-gray-400 mt-0.5",children:'Use "Apply to Tuition" on the card to al
1293so write a ledger entry.'})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-xs font-semibold text-gray-700 mb-1 block",children:"Award Date"}),e.jsx("input",{type:"date",value:c.awardDate,onChange:f("awardDate"),className:"w-full px-3 py-2.5 border border-gray-200 rounded-lg text-sm"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-xs font-semibold text-gray-700 mb-1 block",children:"Status"}),e.jsxs("select",{value:c.status,onChange:f("status"),className:"w-full px-3 py-2.5 border border-gray-200 rounded-lg text-sm",children:[e.jsx("option",{value:"active",children:"Active"}),e.jsx("option",{value:"exhausted",children:"Exhausted"}),e.jsx("option",{value:"cancelled",children:"Cancelled"})]})]}),w&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{children:[e.jsx("label",{className:"text-xs font-semibold text-gray-700 mb-1 block",children:"Award Period Start"}),e.jsx("input",{type:"date",value:c.periodStart,onChange:f("periodStart"),className:"w-full px-3 py-2.5 border border-gray-200 rounded-lg text-sm"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-xs font-semibold text-gray-700 mb-1 block",children:"Award Period End"}),e.jsx("input",{type:"date",value:c.periodEnd,onChange:f("periodEnd"),className:"w-full px-3 py-2.5 border border-gray-200 rounded-lg text-sm"})]})]}),o==="scholarship"&&e.jsxs("div",{className:"col-span-2",children:[e.jsx("label",{className:"text-xs font-semibold text-gray-700 mb-1 block",children:"Eligibility Criteria"}),e.jsx("textarea",{value:c.eligibility,onChange:f("eligibility"),rows:2,placeholder:"e.g. 3.0+ GPA, 90% attendance, enrolled in Cosmetology program",className:"w-full px-3 py-2.5 border border-gray-200 rounded-lg text-sm"})]}),e.jsxs("div",{className:"col-span-2",children:[e.jsx("label",{className:"text-xs font-semibold text-gray-700 mb-1 block",children:"Notes"}),e.jsx("textarea",{value:c.notes,onChange:f("notes"),rows:2,className:"w-full px-3 py-2.5 border border-gray-200 rounded-lg text-sm"})]})]}),w&&e.jsxs("div",{className:"p-4 rounded-xl border bg-gray-50 space-y-3",children:[e.jsx("p",{className:"text-xs font-bold text-gray-700",children:"Disbursement Schedule"}),x.length>0&&e.jsx("div",{className:"space-y-1",children:x.map((_,C)=>e.jsxs("div",{className:"flex items-center justify-between text-xs p-2 rounded-lg bg-emerald-50 border border-emerald-100",children:[e.jsxs("span",{className:"text-gray-600",children:[new Date(_.date+"T00:00:00").toLocaleDateString()," · ",e.jsx("span",{className:"font-mono text-[10px]",children:_.ledger_reference||"disbursed"})]}),e.jsxs("span",{className:"font-mono font-bold text-emerald-700",children:["$",(_.amount_cents/100).toFixed(2)," â DISBURSED"]})]},C))}),p.map((_,C)=>e.jsxs("div",{className:"flex items-center justify-between text-xs p-2 rounded-lg bg-white border border-gray-200",children:[e.jsxs("span",{className:"text-gray-600",children:[new Date(_.date+"T00:00:00").toLocaleDateString()," â scheduled"]}),e.jsxs("span",{className:"flex items-center gap-2",children:[e.jsxs("span",{className:"font-mono font-bold text-gray-900",children:["$",(_.amount_cents/100).toFixed(2)]}),e.jsx("button",{onClick:()=>m(E=>E.filter((P,F)=>F!==C)),className:"text-red-400 hover:text-red-600",children:e.jsx(va,{size:12})})]})]},C)),e.jsxs("div",{className:"flex gap-2",children:[e.jsx("input",{type:"date",value:h.date,onChange:_=>y(C=>({...C,date:_.target.value})),className:"flex-1 px-2 py-2 border border-gray-200 rounded-lg text-xs"}),e.jsx("input",{type:"number",min:"0",step:"0.01",placeholder:"Amount ($)",value:h.amount,onChange:_=>y(C=>({...C,amount:_.target.value})),className:"w-28 px-2 py-2 border border-gray-200 rounded-lg text-xs font-mono"}),e.jsxs("button",{onClick:j,className:"flex items-center gap-1 px-3 py-2 rounded-lg text-xs font-bold text-white",style:{background:kc},children:[e.jsx(tn,{size:12})," Add"]})]})]}),N&&e.jsx("div",{className:"p-3 rounded-xl bg-red-50 text-red-700 text-xs",children:N})]}),e.jsxs("div",{className:"px-6 py-4 border-t border-gray-100 bg-gray-50/50 flex justify-end gap-3",children:[e.jsx("button",{onClick:r,disabled:v,className:"px-4 py-2 border border-gray-200 rounded-lg text-sm font-medium text-gray-600 hover:bg-gray-100",children:"Cancel"}),e.jsxs("button",{onClick:S,disabled:v,className:"flex items-center gap-2 px-5 py-2 rounded-lg text-sm font-bold text-white disabled:opacity-50",style:{background:`linear-gradient(135deg, ${kc}, ${kc}DD)`},children:[v?e.jsx(de,{size:14,className:"animate-spin"}):e.jsx(ti,{size:14}),v?"Savingâ¦":a?"Save Changes":`Add ${Tl[o]}`]})]})]})]})},Sg="#800020",Zie="#D4AF37",Yie=({studentRef:t,studentName:s,totals:n,compact:a})=>
1293{const[r,i]=d.useState(n||null),[o,l]=d.useState(!n);if(d.useEffect(()=>{if(n){i(n),l(!1);return}let p=!1;return(async()=>{l(!0);const[m,x]=await Promise.all([Uie(t,s),qie(t)]);p||(i(yN((x==null?void 0:x.total_tuition_cents)||0,m)),l(!1))})(),()=>{p=!0}},[t,s,n]),o)return e.jsxs("div",{className:"p-3 rounded-xl border bg-gray-50 flex items-center gap-2 text-xs text-gray-400",children:[e.jsx(de,{size:12,className:"animate-spin"})," Loading funding structureâ¦"]});if(!r)return null;if(!(r.totalTuitionCents>0||r.totalFundingApprovedCents>0))return e.jsx("div",{className:"p-3 rounded-xl border border-dashed bg-gray-50 text-[11px] text-gray-400",children:"No Institute tuition/funding structure on file for this student yet â set Total Tuition and add scholarships, grants, or loans in the Funding Sources module."});const u=[{label:"Total Tuition",value:r.totalTuitionCents,icon:e.jsx(cx,{size:12}),color:Sg,op:null},{label:"Scholarships",value:r.scholarshipsAppliedCents,icon:e.jsx(_t,{size:12}),color:Zie,op:e.jsx(Ml,{size:12,className:"text-gray-300"})},{label:"Grants",value:r.grantsAppliedCents,icon:e.jsx(Zm,{size:12}),color:"#3B82F6",op:e.jsx(Ml,{size:12,className:"text-gray-300"})},{label:"Loans",value:r.loansAppliedCents,icon:e.jsx(Do,{size:12}),color:"#8B5CF6",op:e.jsx(Ml,{size:12,className:"text-gray-300"})}];return e.jsxs("div",{className:`rounded-xl border-2 bg-white overflow-hidden ${a?"":"shadow-sm"}`,style:{borderColor:`${Sg}20`},children:[e.jsxs("div",{className:"px-3 py-1.5 text-[9px] font-bold uppercase tracking-wider text-white flex items-center justify-between",style:{background:`linear-gradient(90deg, ${Sg}, ${Sg}CC)`},children:[e.jsx("span",{children:"Institute Funding Structure â Auto-Calculated"}),r.totalFundingApprovedCents>r.totalFundingAppliedCents&&e.jsxs("span",{className:"font-mono normal-case",children:["Approved (unapplied): ",Wn(r.totalFundingApprovedCents-r.totalFundingAppliedCents)]})]}),e.jsxs("div",{className:"p-3 flex flex-wrap items-center gap-2",children:[u.map((p,m)=>e.jsxs(re.Fragment,{children:[p.op,e.jsxs("div",{className:"flex-1 min-w-[100px] p-2 rounded-lg bg-gray-50 border border-gray-100",children:[e.jsxs("div",{className:"flex items-center gap-1 text-[9px] uppercase tracking-wider font-semibold",style:{color:p.color},children:[p.icon," ",p.label]}),e.jsx("p",{className:"font-mono text-sm font-bold text-gray-900",children:Wn(p.value)})]})]},p.label)),e.jsx(SO,{size:14,className:"text-gray-400"}),e.jsxs("div",{className:"flex-1 min-w-[130px] p-2 rounded-lg border-2",style:{borderColor:r.remainingResponsibilityCents>0?"#FCA5A5":"#6EE7B7",background:r.remainingResponsibilityCents>0?"#FEF2F2":"#ECFDF5"},children:[e.jsx("div",{className:"text-[9px] uppercase tracking-wider font-bold",style:{color:r.remainingResponsibilityCents>0?"#DC2626":"#059669"},children:"Student Remaining Responsibility"}),e.jsx("p",{className:"font-mono text-base font-bold",style:{color:r.remainingResponsibilityCents>0?"#DC2626":"#059669"},children:Wn(r.remainingResponsibilityCents)})]})]})]})},An="#800020",bN="#D4AF37",Kie={scholarship:{icon:e.jsx(_t,{size:14}),color:"#8B7D2E",bg:`${bN}15`},grant:{icon:e.jsx(Zm,{size:14}),color:"#1D4ED8",bg:"#EFF6FF"},loan:{icon:e.jsx(Do,{size:14}),color:"#7C3AED",bg:"#F5F3FF"}},Qie=()=>{const[t,s]=d.useState([]),[n,a]=d.useState([]),[r,i]=d.useState([]),[o,l]=d.useState(!0),[c,u]=d.useState(""),[p,m]=d.useState(null),[x,h]=d.useState(""),[y,v]=d.useState(""),[g,N]=d.useState(!1),[b,f]=d.useState(""),[j,S]=d.useState(!1),[w,_]=d.useState(null),[C,E]=d.useState(null),[P,F]=d.useState(""),[I,D]=d.useState(!1),[L,V]=d.useState(null),[B,A]=d.useState(null),[z,M]=d.useState(!1),R=d.useCallback(async()=>{l(!0);const[Y,J,te]=await Promise.all([O.from("z_student_accounts").select("student_id, full_name, email, program").order("full_name"),O.from(Om).select("*").order("created_at",{ascending:!1}),O.from(fN).select("*")]);s(Y.data||[]),a(J.data||[]),i(te.data||[]),l(!1)},[]);d.useEffect(()=>{R()},[R]);const T=d.useCallback(Y=>r.find(J=>J.student_ref===Y)||null,[r]),U=d.useCallback(Y=>n.filter(J=>J.student_ref===Y),[n]),q=d.useMemo(()=>t.find(Y=>Y.student_id===p)||null,[t,p]),H=p?U(p):[],G=p?T(p):null,W=p?yN((G==null?void 0:G.total_tuition_cents)||0,H):null;d.useEffect(()=>{if(!p)return;const Y=T(p);h(Y?(Y.total_tuition_cents/100).toFixed(2):""),v((Y==null?void 0:Y.notes)||""),f(""),V(null),A(null)},[p,T]);const X=d.useMemo(()=>{const Y=c.trim().toLowerCase();return Y?t.filter(J=>J.full_name.toLowerCase().includes(Y)||J.student_id.toLowerCase().includes(Y)||(J.program||"").toLowerCase().includes(Y)):t},[t,c]),Q=async()=>
1293{if(!p||!q)return;const Y=Math.round(parseFloat(x||"0")*100);if(isNaN(Y)||Y<0){f("Enter a valid tuition amount.");return}N(!0),f("");const{error:J}=await O.from(fN).upsert({student_ref:p,sis_student_id:(G==null?void 0:G.sis_student_id)||null,student_name:q.full_name,program:q.program,total_tuition_cents:Y,notes:y.trim()||null,updated_at:new Date().toISOString()},{onConflict:"student_ref"});if(N(!1),J){f(`Save failed: ${J.message}`);return}f("Total Tuition saved."),R()},K=async()=>{if(!C)return;const Y=Math.round(parseFloat(P||"0")*100);D(!0),V(null);const J=await Wie(C,Y);D(!1),J.ok?(V({ok:!0,text:`${Wn(Y)} applied to tuition · ledger reference ${J.reference} written to the student financial record.`}),E(null),F(""),R()):V({ok:!1,text:J.error||"Failed to apply funding."})},se=async()=>{M(!0);const Y=await Hie(H);A(Y),M(!1)};return o?e.jsx("div",{className:"flex items-center justify-center py-16",children:e.jsx(de,{size:28,className:"animate-spin",style:{color:An}})}):!p||!q?e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-3",children:[e.jsxs("div",{className:"relative flex-1 min-w-[240px]",children:[e.jsx(Bt,{size:14,className:"absolute left-3 top-1/2 -translate-y-1/2 text-gray-400"}),e.jsx("input",{value:c,onChange:Y=>u(Y.target.value),placeholder:"Search students by name, ID, or programâ¦",className:"w-full pl-9 pr-3 py-2.5 rounded-xl border border-gray-200 text-sm bg-white focus:outline-none focus:border-[#800020]"})]}),e.jsxs("button",{onClick:R,className:"flex items-center gap-1.5 px-3 py-2.5 rounded-xl border bg-white text-xs font-semibold text-gray-600 hover:bg-gray-50",children:[e.jsx(Be,{size:13})," Refresh"]})]}),e.jsxs("div",{className:"p-3 rounded-xl border text-[11px] text-gray-600 flex items-start gap-2 bg-white",style:{borderColor:`${An}20`},children:[e.jsx(nh,{size:14,className:"shrink-0 mt-0.5",style:{color:An}}),e.jsxs("span",{children:[e.jsx("strong",{style:{color:An},children:"Funding structure:"})," Total Tuition â Scholarships â Grants â Loans = Student Remaining Responsibility. Applying funding writes a credit to the student financial record â Z Bank and card payments remain the payment method layer only. All fields are administrator-editable. SIS Student IDs backfill into the reserved ",e.jsx("span",{className:"font-mono",children:"sis_student_id"})," column later â no restructuring."]})]}),X.length===0?e.jsxs("div",{className:"text-center py-14 text-gray-400 bg-white rounded-xl border",children:[e.jsx(_t,{size:36,className:"mx-auto mb-2 opacity-30"}),e.jsx("p",{className:"text-sm",children:"No students found."})]}):e.jsx("div",{className:"space-y-2",children:X.map(Y=>{const J=T(Y.student_id),te=U(Y.student_id),pe=yN((J==null?void 0:J.total_tuition_cents)||0,te),Fe=pe.totalTuitionCents>0||te.length>0;return e.jsxs("button",{onClick:()=>m(Y.student_id),className:"w-full p-4 rounded-xl border bg-white hover:border-gray-300 hover:shadow-sm transition-all text-left flex flex-wrap items-center gap-4",children:[e.jsx("div",{className:"w-10 h-10 rounded-xl flex items-center justify-center text-white text-sm font-bold shrink-0",style:{background:`linear-gradient(135deg, ${An}, ${An}CC)`},children:Y.full_name.split(" ").map(ke=>ke[0]).join("").slice(0,2)}),e.jsxs("div",{className:"min-w-[160px]",children:[e.jsx("p",{className:"text-sm font-bold text-gray-900",children:Y.full_name}),e.jsxs("p",{className:"text-[10px] text-gray-400 font-mono",children:["ID: ",Y.student_id,Y.program?` · ${Y.program}`:""]})]}),Fe?e.jsxs("div",{className:"flex flex-wrap items-center gap-3 ml-auto text-right",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-[9px] uppercase tracking-wider text-gray-400",children:"Tuition"}),e.jsx("p",{className:"font-mono text-xs font-bold text-gray-900",children:Wn(pe.totalTuitionCents)})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-[9px] uppercase tracking-wider text-gray-400",children:"Funding Applied"}),e.jsx("p",{className:"font-mono text-xs font-bold",style:{color:bN},children:Wn(pe.totalFundingAppliedCents)})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-[9px] uppercase tracking-wider text-gray-400",children:"Remaining Resp."}),e.jsx("p",{className:`font-mono text-xs font-bold ${pe.remainingResponsibilityCents>0?"text-red-600":"text-emerald-600"}`,children:Wn(pe.remainingResponsibilityCents)})]}),e.jsxs("span",{className:"px-2 py-0.5 rounded-full text-[9px] font-bold bg-gray-100 text-gray-500",children:[te.length," source",te.length!==1?"s":""]})]}):e.jsx("span",{className:"ml-auto px-2 py-1 rounded-full text-[9px] font-bold bg-gray-100 text-gray-400",children:"NO FUNDING STRUCTURE YET"})]},Y.student_id)})})]}):e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3",children:[e.jsxs("button",{onClick:()=>m(null),className:"flex items-center gap-1.5 px-3 py-2 rounded-xl border bg-white text-xs font-semibold text-gray-600 hover:bg-gray-50",children:[e.jsx(Je,{size:13})," All Students"]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("button",{onClick:se,disabled:z||H.length===0,className:"flex items-center gap-1.5 px-3 py-2 rounded-xl border bg-white text-xs font-semibold text-gray-600 hover:bg-gray-50 disabled:opacity-40",children:[z?e.jsx(de,{size:13,className:"animate-spin"}):e.jsx(u0,{size:13})," Verify Ledger Links"]}),e.jsxs("button",{onClick:()=>{_(null),S(!0)},className:"flex items-center gap-1.5 px-4 py-2 rounded-xl text-xs font-bold text-white",style:{background:`linear-gradient(135deg, ${An}, ${An}DD)`},children:[e.jsx(tn,{size:13})," Add Funding Source"]})]})]}),e.jsxs("div",{className:"p-4 rounded-xl border bg-white flex flex-wrap items-center gap-4",children:[e.jsx("div",{className:"w-12 h-12 rounded-xl flex items-center justify-center text-white text-base font-bold",style:{background:`linear-gradient(135deg, ${An}, ${An}CC)`},children:q.full_name.split(" ").map(Y=>Y[0]).join("").slice(0,2)}),e.jsxs("div",{children:[e.jsx("p",{className:"text-base font-bold text-gray-900",children:q.full_name}),e.jsxs("p",{className:"text-[10px] text-gray-400 font-mono",children:["Student Record ID: ",q.student_id,q.program?` · ${q.program}`:""," · ","SIS ID: ",(G==null?void 0:G.sis_student_id)||"pending SIS rollout"]})]})]}),W&&e.jsx(Yie,{studentRef:p,totals:W}),e.jsxs("div",{className:"p-4 rounded-xl border bg-white space-y-3",children:[e.jsxs("p",{className:"text-xs font-bold text-gray-700 flex items-center gap-2",children:[e.jsx(u2,{size:13,style:{color:An}})," Total Tuition (administrator-editable)"]}),e.jsxs("div",{className:"flex flex-wrap items-end gap-3",children:[e.jsxs("div",{children:[e.jsx("label",{className:"text-[10px] font-semibold text-gray-500 mb-1 block",children:"Total Tuition ($)"}),e.jsxs("div",{className:"relative",children:[e.jsx("span",{className:"absolute left-3 top-1/2 -translate-y-1/2 text-gray-400 font-mono text-sm",children:"$"}),e.jsx("input",{type:"number",min:"0",step:"0.01",value:x,onChange:Y=>h(Y.target.value),className:"w-40 pl-7 pr-3 py-2.5 rounded-xl border border-gray-200 text-sm font-mono focus:outline-none focus:border-[#800020]"})]})]}),e.jsxs("div",{className:"flex-1 min-w-[200px]",children:[e.jsx("label",{className:"text-[10px] font-semibold text-gray-500 mb-1 block",children:"Notes (e.g. program, kit fees included)"}),e.jsx("input",{value:y,onChange:Y=>v(Y.target.value),className:"w-full px-3 py-2.5 rounded-xl border border-gray-200 text-sm"})]}),e.jsxs("button",{onClick:Q,disabled:g,className:"flex items-center gap-1.5 px-4 py-2.5 rounded-xl text-xs font-bold text-white disabled:opacity-50",style:{background:An},children:[g?e.jsx(de,{size:13,className:"animate-spin"}):e.jsx(ti,{size:13})," Save Tuition"]})]}),b&&e.jsx("p",{className:`text-xs ${b.includes("saved")||b.includes("Saved")?"text-emerald-600":"text-red-600"}`,children:b})]}),L&&e.jsxs("div",{className:`p-3 rounded-xl text-xs flex items-start gap-2 ${L.ok?"bg-emerald-50 text-emerald-700":"bg-red-50 text-red-700"}`,children:[L.ok?e.jsx(pt,{size:14,className:"shrink-0 mt-0.5"}):e.jsx(ve,{size:14,className:"shrink-0 mt-0.5"}),L.text]}),B!==null&&e.jsxs("div",{className:"p-4 rounded-xl border bg-white space-y-2",children:[e.jsxs("p",{className:"text-xs font-bold text-gray-700 flex items-center gap-2",children:[e.jsx(Ie,{size:13,style:{color:An}})," Funding â Student Financial Record Reconciliation"]}),B.length===0?e.jsx("p",{className:"text-[11px] text-gray-400",children:"No disbursed funding applications to verify yet."}):e.jsx("div",{className:"space-y-1",children:B.map((Y,J)=>e.jsxs("div",{className:`flex items-center justify-between p-2 rounded-lg text-xs border ${Y.linked?"bg-emerald-50 border-emerald-100":"bg-red-50 border-red-200"}`,children:[e.jsxs("span",{className:"flex items-center gap-2",children:[Y.linked?e.jsx(Xs,{size:12,className:"text-emerald-600"}):e.jsx(ve,{size:12,className:"text-red-600"}),e.jsx("span",{className:"font-mono text-[10px]",children:Y.reference}),e.jsx("span",{className:"text-gray-500",children:Y.fundingName})]}),e.jsxs("span",{className:`font-mono font-bold ${Y.linked?"text-emerald-700":"text-red-700"}`,children:[Wn(Y.amount_cents)," â ",Y.linked?"LEDGER LINKED":"MISSING LEDGER ROW"]})]},J))})]}),["scholarship","grant","loan"].map(Y=>{const J=H.filter(pe=>pe.funding_kind===Y);if(J.length===0)return null;const te=Kie[Y];return e.jsxs("div",{className:"space-y-2",children:[e.jsxs("p",{className:"text-xs font-bold uppercase tracking-wider flex items-center gap-1.5",style:{color:te.color},children:[te.icon," ",Tl[Y],"s"]}),J.map(pe=>{const Fe=gN(pe),ke=pe.approved_amount_cents>0?Math.min(100,Math.round(pe.applied_to_tuition_cents/pe.approved_amount_cents*100)):0;return e.jsxs("div",{className:"p-4 rounded-xl border bg-white space-y-3",children:[e.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-3",children:[e.jsxs("div",{children:[e.jsxs("p",{className:"text-sm font-bold text-gray-900 flex items-center gap-2",children:[pe.name,e.jsx("span",{className:`px-2 py-0.5 rounded-full text-[9px] font-bold ${pe.status==="active"?"bg-emerald-100 text-emerald-700":pe.status==="exhausted"?"bg-gray-100 text-gray-500":"bg-red-100 text-red-600"}`,children:pe.status.toUpperCase()})]}),e.jsxs("p",{className:"text-[10px] text-gray-400",children:[pe.source?`Source: ${pe.s
1293ource} · `:"",pe.award_date?`Awarded ${new Date(pe.award_date+"T00:00:00").toLocaleDateString()}`:"No award date",pe.award_period_start?` · Period ${new Date(pe.award_period_start+"T00:00:00").toLocaleDateString()} â ${pe.award_period_end?new Date(pe.award_period_end+"T00:00:00").toLocaleDateString():"ongoing"}`:""]}),pe.eligibility_criteria&&e.jsxs("p",{className:"text-[10px] text-gray-500 mt-1",children:[e.jsx("strong",{children:"Eligibility:"})," ",pe.eligibility_criteria]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("button",{onClick:()=>{_(pe),S(!0)},className:"flex items-center gap-1 px-2.5 py-1.5 rounded-lg border text-[10px] font-bold text-gray-600 hover:bg-gray-50",children:[e.jsx(u2,{size:11})," Edit"]}),pe.status!=="cancelled"&&Fe>0&&e.jsxs("button",{onClick:()=>{E(pe),F((Fe/100).toFixed(2)),V(null)},className:"flex items-center gap-1 px-2.5 py-1.5 rounded-lg text-[10px] font-bold text-white",style:{background:`linear-gradient(135deg, ${bN}, #A68B5B)`},children:[e.jsx(nh,{size:11})," Apply to Tuition"]})]})]}),e.jsxs("div",{className:"grid grid-cols-3 gap-2",children:[e.jsxs("div",{className:"p-2 rounded-lg bg-gray-50 text-center",children:[e.jsx("p",{className:"text-[9px] uppercase tracking-wider text-gray-400",children:Y==="scholarship"?"Award Amount":"Approved Amount"}),e.jsx("p",{className:"font-mono text-sm font-bold text-gray-900",children:Wn(pe.approved_amount_cents)})]}),e.jsxs("div",{className:"p-2 rounded-lg bg-gray-50 text-center",children:[e.jsx("p",{className:"text-[9px] uppercase tracking-wider text-gray-400",children:"Applied to Tuition"}),e.jsx("p",{className:"font-mono text-sm font-bold",style:{color:te.color},children:Wn(pe.applied_to_tuition_cents)})]}),e.jsxs("div",{className:"p-2 rounded-lg bg-gray-50 text-center",children:[e.jsx("p",{className:"text-[9px] uppercase tracking-wider text-gray-400",children:"Remaining Balance"}),e.jsx("p",{className:`font-mono text-sm font-bold ${Fe>0?"text-gray-900":"text-emerald-600"}`,children:Wn(Fe)})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"flex-1 h-1.5 bg-gray-100 rounded-full overflow-hidden",children:e.jsx("div",{className:"h-full rounded-full transition-all",style:{width:`${ke}%`,backgroundColor:ke>=100?"#059669":te.color}})}),e.jsxs("span",{className:"font-mono text-[10px] text-gray-400",children:[ke,"% applied"]})]}),(pe.disbursement_schedule||[]).length>0&&e.jsxs("div",{className:"space-y-1",children:[e.jsxs("p",{className:"text-[10px] font-bold text-gray-500 uppercase tracking-wider flex items-center gap-1",children:[e.jsx(Ii,{size:10})," Disbursements"]}),pe.disbursement_schedule.map((Oe,ue)=>e.jsxs("div",{className:`flex items-center justify-between text-[11px] p-2 rounded-lg border ${Oe.status==="disbursed"?"bg-emerald-50/50 border-emerald-100":"bg-gray-50 border-gray-100"}`,children:[e.jsxs("span",{className:"text-gray-600",children:[new Date(Oe.date+"T00:00:00").toLocaleDateString(),Oe.ledger_reference&&e.jsx("span",{className:"ml-2 font-mono text-[9px] text-gray-400",children:Oe.ledger_reference})]}),e.jsxs("span",{className:`font-mono font-bold ${Oe.status==="disbursed"?"text-emerald-700":"text-gray-500"}`,children:[Wn(Oe.amount_cents)," · ",Oe.status.toUpperCase()]})]},ue))]})]},pe.id)})]},Y)}),H.length===0&&e.jsxs("div",{className:"text-center py-10 text-gray-400 bg-white rounded-xl border",children:[e.jsx(nh,{size:32,className:"mx-auto mb-2 opacity-30"}),e.jsx("p",{className:"text-sm",children:"No scholarships, grants, or loans on file yet."}),e.jsx("p",{className:"text-xs mt-1",children:"Add a funding source to build this student's funding structure."})]}),C&&e.jsxs("div",{className:"fixed inset-0 z-50 flex items-center justify-center p-4",onClick:()=>!I&&E(null),children:[e.jsx("div",{className:"absolute inset-0 bg-black/40 backdrop-blur-sm"}),e.jsxs("div",{className:"relative bg-white rounded-2xl shadow-2xl w-full max-w-md p-6 space-y-4",onClick:Y=>Y.stopPropagation(),children:[e.jsxs("h3",{className:"text-base font-bold text-gray-900 flex items-center gap-2",children:[e.jsx(nh,{size:16,style:{color:An}}
1293)," Apply Funding to Tuition"]}),e.jsxs("p",{className:"text-xs text-gray-500",children:[e.jsx("strong",{children:C.name})," (",Tl[C.funding_kind],") â remaining balance"," ",e.jsx("span",{className:"font-mono font-bold",children:Wn(gN(C))}),". This writes a credit to the student financial record (reference ZI-FUND-â¦) and reduces the student's Balance Due and receipt remaining balance. No card/Stripe charge is created."]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-[10px] font-semibold text-gray-500 mb-1 block",children:"Amount to Apply ($)"}),e.jsxs("div",{className:"relative",children:[e.jsx("span",{className:"absolute left-3 top-1/2 -translate-y-1/2 text-gray-400 font-mono text-sm",children:"$"}),e.jsx("input",{type:"number",min:"0",step:"0.01",value:P,onChange:Y=>F(Y.target.value),className:"w-full pl-7 pr-3 py-2.5 rounded-xl border border-gray-200 text-sm font-mono focus:outline-none focus:border-[#800020]"})]})]}),L&&!L.ok&&e.jsx("div",{className:"p-3 rounded-xl bg-red-50 text-red-700 text-xs",children:L.text}),e.jsxs("div",{className:"flex gap-3",children:[e.jsx("button",{onClick:()=>E(null),disabled:I,className:"flex-1 px-4 py-2.5 border border-gray-200 rounded-xl text-sm font-medium text-gray-600 hover:bg-gray-50",children:"Cancel"}),e.jsxs("button",{onClick:K,disabled:I||!(parseFloat(P)>0),className:"flex-1 flex items-center justify-center gap-2 px-4 py-2.5 rounded-xl text-sm font-bold text-white disabled:opacity-50",style:{background:`linear-gradient(135deg, ${An}, ${An}DD)`},children:[I?e.jsx(de,{size:14,className:"animate-spin"}):e.jsx(pt,{size:14}),I?"Applyingâ¦":"Apply & Write Ledger Entry"]})]})]})]}),j&&e.jsx(Vie,{studentRef:p,studentName:q.full_name,program:q.program||void 0,existing:w,onClose:()=>{S(!1),_(null)},onSaved:R})]})},s$="z_sis_student_registry",Jie=[{table:"z_institute_payments",refColumn:"student_ref",label:"Payment History & Receipts"},{table:"z_institute_tuition_accounts",refColumn:"student_ref",label:"Tuition Accounts"},{table:"z_institute_funding_sources",refColumn:"student_ref",label:"Scholarships / Grants / Loans"},{table:"z_student_financial_records",refColumn:"student_id",label:"Student Financial Records"},{table:"z_bank_loans",refColumn:"student_id",label:"Payment Plans"}],Xie=async()=>{const{data:t}=await O.from(s$).select("*").order("sis_student_id",{ascending:!0});return t||[]},eoe=async(t,s,n,a,r="admin")=>{const{data:i,error:o}=await O.rpc("zi_assign_sis_student_id",{p_student_ref:t,p_name:s||null,p_program:n||null,p_email:a||null,p_assigned_by:r});return o?null:i||null},toe=async()=>{const t=[];for(const s of Jie){const[{count:n},{count:a}]=await Promise.all([O.from(s.table).select("id",{count:"exact",head:!0}),O.from(s.table).select("id",{count:"exact",head:!0}).not("sis_student_id","is",null)]);t.push({table:s.table,label:s.label,total:n||0,withSisId:a||0})}return t},soe=async()=>{const[{data:t},{data:s}]=await Promise.all([O.from("z_student_accounts").select("student_id, full_name, program, email"),O.from(s$).select("student_ref")]),n=new Set((s||[]).map(a=>a.student_ref));return(t||[]).filter(a=>!n.has(a.student_id))},la="#800020",XE="#D4AF37",noe={active:"bg-emerald-100 text-emerald-700",graduated:"bg-blue-100 text-blue-700",withdrawn:"bg-amber-100 text-amber-700",archived:"bg-gray-100 text-gray-500"},aoe=()=>{const[t,s]=d.useState([]),[n,a]=d.useState([]),[r,i]=d.useState([]),[o,l]=d.useState(!0),[c,u]=d.useState(!1),[p,m]=d.useState(""),[x,h]=d.useState(""),y=d.useCallback(async()=>{l(!0);const[b,f,j]=await Promise.all([Xie(),toe(),soe()]);s(b),a(f),i(j),l(!1)},[]);d.useEffect(()=>{y()},[y]);const v=d.useMemo(()=>{if(!x.trim())return t;const b=x.trim().toLowerCase();return t.filter(f=>f.sis_student_id.toLowerCase().includes(b)||f.student_ref.toLowerCase().includes(b)||(f.student_name||"").toLowerCase().includes(b)||(f.program||"").toLowerCase().includes(b))},[t,x]),g=async()=>{if(r.length===0)return;u(!0),m("");let b=0;for(const f of r)await eoe(f.student_id,f.full_name,f.program,f.email,"admin:registry")&&b++;m(`Assigned ${b} of ${r.length} permanent SIS Student ID${r.length===1?"":"s"}.`),u(!1),y()},N=()=>{const b=["SIS Student ID","Student Record Ref","Student Name","Program","Status","Assigned By","Assigned At"],f=v.map(_=>[_.sis_student_id,_.student_ref,_.student_name||"",_.program||"",_.status,_.assigned_by,new Date(_.assigned_at).toISOString()].map(C=>`"${String(C).replace(/"/g,'""')}"`).join(",")),j=new Blob([[b.join(","),...f].join(` 1294`)],{type:"text/csv"}),S=URL.createObjectURL(j),w=document.createElement("a");
1294w.href=S,w.download=`sis-student-ids-${new Date().toISOString().slice(0,10)}.csv`,w.click(),URL.revokeObjectURL(S)};return e.jsxs("div",{className:"space-y-5",children:[e.jsx("div",{className:"p-5 rounded-xl border-2 bg-white",style:{borderColor:`${la}25`},children:e.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-4",children:[e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx("div",{className:"w-10 h-10 rounded-xl flex items-center justify-center text-white shrink-0",style:{background:`linear-gradient(135deg, ${la}, #5c0017)`},children:e.jsx(EO,{size:20})}),e.jsxs("div",{children:[e.jsx("h3",{className:"text-sm font-bold text-gray-900",children:"Permanent SIS Student IDs"}),e.jsxs("p",{className:"text-xs text-gray-500 mt-1 max-w-2xl leading-relaxed",children:["System-generated ",e.jsx("span",{className:"font-mono font-semibold",style:{color:la},children:"ZI-YYYY-NNNNNN"})," identifiers containing ",e.jsx("strong",{children:"no SSN or personal data"}),". Database triggers make each ID immutable and undeletable for the full student lifecycle, auto-assign IDs when new student profiles are created, and auto-stamp the ID onto every new tuition, funding, ledger, payment-plan, and payment row."]})]})]}),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsxs("span",{className:"inline-flex items-center gap-1.5 px-3 py-1.5 rounded-full text-[10px] font-bold bg-emerald-50 text-emerald-700 border border-emerald-200",children:[e.jsx(Xe,{size:11})," IMMUTABLE"]}),e.jsxs("span",{className:"inline-flex items-center gap-1.5 px-3 py-1.5 rounded-full text-[10px] font-bold border",style:{background:`${XE}15`,color:"#8a6d1a",borderColor:`${XE}50`},children:[e.jsx(Ie,{size:11})," NO PII IN ID"]})]})]})}),r.length>0&&e.jsxs("div",{className:"p-4 rounded-xl border-2 border-amber-200 bg-amber-50 flex flex-wrap items-center justify-between gap-3",children:[e.jsxs("div",{className:"flex items-center gap-2 text-xs text-amber-800",children:[e.jsx(ve,{size:14}),e.jsxs("span",{children:[e.jsx("strong",{children:r.length})," student record",r.length===1?"":"s"," without a permanent SIS Student ID."]})]}),e.jsxs("button",{onClick:g,disabled:c,className:"flex items-center gap-1.5 px-4 py-2 rounded-xl text-xs font-bold text-white disabled:opacity-50",style:{background:la},children:[c?e.jsx(Be,{size:13,className:"animate-spin"}):e.jsx(Cd,{size:13}),c?"Assigningâ¦":"Assign Missing IDs"]})]}),p&&e.jsxs("div",{className:"p-3 rounded-xl bg-emerald-50 border border-emerald-200 text-xs text-emerald-700 flex items-center gap-2",children:[e.jsx(pt,{size:13})," ",p]}),e.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-3 lg:grid-cols-6 gap-3",children:[e.jsxs("div",{className:"p-4 rounded-xl border bg-white",children:[e.jsxs("div",{className:"flex items-center gap-1.5 mb-1 text-[10px] uppercase tracking-wider",style:{color:la},children:[e.jsx(Sy,{size:14})," IDs Issued"]}),e.jsx("p",{className:"font-mono text-xl font-bold text-gray-900",children:t.length})]}),n.map(b=>e.jsxs("div",{className:"p-4 rounded-xl border bg-white",children:[e.jsxs("div",{className:"flex items-center gap-1.5 mb-1 text-[10px] uppercase tracking-wider text-gray-500",children:[e.jsx(Xs,{size:12})," ",b.label]}),e.jsxs("p",{className:"font-mono text-xl font-bold",style:{color:b.total>0&&b.withSisId<b.total?"#D97706":"#059669"},children:[b.withSisId,"/",b.total]}),e.jsx("p",{className:"text-[9px] text-gray-400",children:"rows linked to SIS ID"})]},b.table))]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-3",children:[e.jsxs("div",{className:"relative flex-1 min-w-[240px]",children:[e.jsx(Bt,{size:14,className:"absolute left-3 top-1/2 -translate-y-1/2 text-gray-400"}),e.jsx("input",{value:x,onChange:b=>h(b.target.value),placeholder:"Search SIS ID, student record ref, name, programâ¦",className:"w-full pl-9 pr-3 py-2.5 rounded-xl border border-gray-200 text-sm bg-white focus:outline-none focus:border-[#800020]"})]}),e.jsxs("button",{onClick:y,className:"flex items-center gap-1.5 px-3 py-2.5 rounded-xl border bg-white text-xs font-semibold text-gray-600 hover:bg-gray-50",children:[e.jsx(Be,{size:13})," Refresh"]}),e.jsxs("button",{onClick:N,disabled:v.length===0,className:"flex items-center gap-1.5 px-3 py-2.5 rounded-xl text-xs font-bold text-white disabled:opacity-40",style:{background:la},children:[e.jsx(us,{size:13})," Export CSV"]})]}),o?e.jsx("div",{className:"flex items-center justify-center py-20",children:e.jsx("div",{className:"w-8 h-8 border-4 rounded-full animate-spin",style:{borderColor:`${la}30`,borderTopColor:la}})}):v.length===0?e.jsxs("div",{className:"text-center py-16 text-gray-400 bg-white rounded-xl border",children:[e.jsx(Sy,{size:40,className:"mx-auto mb-3 opacity-30"}),e.jsx("p",{className:"text-sm",children:"No SIS Student IDs match your search."})]}):e.jsx("div",{className:"bg-white rounded-xl border overflow-x-auto",children:e.jsxs("table",{className:"w-full text-sm min-w-[900px]",children:[e.jsx("thead",{children:e.jsx("tr",{className:"border-b",style:{background:`${la}05`},children:["SIS Student ID","Student Record Ref","Student Name","Program","Status","Assigned","Assigned By"].map(b=>e.jsx("th",{className:"text-left px-4 py-3 text-[10px] uppercase tracking-wider text-gray-500 whitespace-nowrap",children:b},b))})}),e.jsx("tbody",{className:"divide-y divide-gray-50",children:v.map(b=>e.jsxs("tr",{className:"hover:bg-gray-50",children:[e.jsx("td",{className:"px-4 py-3",children:e.jsxs("span",{className:"inline-flex items-center gap-1.5 font-mono text-xs font-bold",style:{color:la}
1294,children:[e.jsx(Xe,{size:10,className:"opacity-50"})," ",b.sis_student_id]})}),e.jsx("td",{className:"px-4 py-3 text-[11px] font-mono text-gray-500",children:b.student_ref}),e.jsx("td",{className:"px-4 py-3 text-xs font-medium text-gray-900",children:b.student_name||"â"}),e.jsx("td",{className:"px-4 py-3 text-xs text-gray-600 capitalize",children:b.program||"â"}),e.jsx("td",{className:"px-4 py-3",children:e.jsx("span",{className:`px-2 py-0.5 rounded-full text-[10px] font-bold ${noe[b.status]||"bg-gray-100 text-gray-500"}`,children:b.status.toUpperCase()})}),e.jsx("td",{className:"px-4 py-3 text-xs text-gray-500 whitespace-nowrap",children:new Date(b.assigned_at).toLocaleString()}),e.jsx("td",{className:"px-4 py-3 text-[10px] font-mono text-gray-400",children:b.assigned_by})]},b.id))})]})}),e.jsxs("div",{className:"p-4 rounded-xl border-2",style:{borderColor:`${la}20`,background:`${la}05`},children:[e.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[e.jsx(Ie,{size:14,style:{color:la}}),e.jsx("span",{className:"text-xs font-bold",style:{color:la},children:"Privacy & Lifecycle Controls"})]}),e.jsx("p",{className:"text-[10px] text-gray-600 leading-relaxed",children:"IDs are generated from an internal atomic counter â never from SSNs or other sensitive personal identifiers. Row Level Security is enabled on the registry, registry rows cannot be deleted (permanence enforced by database trigger), and SIS IDs appear only inside admin-guarded dashboards â never on public pages. Status changes (active â graduated / withdrawn / archived) never alter the ID itself. The registry's metadata column is reserved for future SIS modules: admissions, attendance, clock hours, grades, and graduation tracking."})]})]})},Pd="z_sis_import_batches",d1="z_sis_import_rows",u1=[{key:"student_id",label:"Existing Record ID",required:!1,hint:"Legacy ID (e.g. ZSI-2025-001). Blank = system generates one.",aliases:["studentid","recordid","id","studentnumber","studentno","zsiid","legacyid"]},{key:"full_name",label:"Full Name",required:!0,hint:"Student legal or preferred full name.",aliases:["fullname","name","studentname","legalname"]},{key:"email",label:"Email",required:!1,hint:"Used for duplicate matching and receipts.",aliases:["email","emailaddress","studentemail","mail"]},{key:"phone",label:"Phone",required:!1,hint:"Contact number (optional).",aliases:["phone","phonenumber","cell","mobile","telephone"]},{key:"program",label:"Program",required:!1,hint:"e.g. Cosmetology, Esthetics, Master Esthetics, Nails.",aliases:["program","course","programname","enrolledprogram","major"]},{key:"enrollment_status",label:"Enrollment Status",required:!1,hint:"active | graduated | withdrawn | suspended (default: active).",aliases:["enrollmentstatus","status","studentstatus"]},{key:"enrollment_date",label:"Enrollment Date",required:!1,hint:"YYYY-MM-DD (other common formats auto-converted).",aliases:["enrollmentdate","startdate","enrolldate","dateenrolled","admissiondate"]},{key:"notes",label:"Notes",required:!1,hint:"Free-text notes stored in the student metadata.",aliases:["notes","note","comments","remarks"]}],roe=[/ssn/i,/social\s*_?-?\s*sec/i,/tax\s*_?-?\s*id/i,/\bitin\b/i,/\bein\b/i,/date\s*_?-?\s*of\s*_?-?\s*birth/i,/\bdob\b/i,/birth\s*_?-?\s*date/i,/driver'?s?\s*_?-?\s*lic/i,/passport/i,/\bpassword\b/i],e4=t=>roe.some(s=>s.test(t)),ioe=()=>{const t=u1.map(a=>a.key).join(","),s=["ZSI-2025-001","Jane Example","[email protected]","(555) 201-0001","Cosmetology","active","2025-09-02","Transferred from legacy sheet"].map(a=>`"${a}"`).join(","),n=["","Marcus Sample","[email protected]","","Esthetics","active","2026-01-15","No legacy ID â system will generate one"].map(a=>`"${a}"`).join(",");return[t,s,n].join(` 1295`)},ooe=()=>{const t=new Blob([ioe()],{type:"text/csv"}),s=URL.createObjectURL(t),n=document.createElement("a");n.href=s,n.download="zorganics-institute-sis-student-import-template.csv",n.click(),URL.revokeObjectURL(s)},t4=t=>{const s=[];let n="",a=!1;for(let r=0;r<t.length;r++){const i=t[r];a?i==='"'?t[r+1]==='"'?(n+='"',r++):a=!1:n+=i:i==='"'?a=!0:i===","?(s.push(n),n=""):n+=i}return s.push(n),s},n$=t=>{const s=t.replace(/\r\n?/g,` 1296`).split(` 1297`).filter(l=>l.trim().length>0);if(s.length===0)return{headers:[],rows:[],blockedColumns:[]};const n=t4(s[0]).map(l=>l.trim()),a=n.filter(e4),r=[],i=[];
1297n.forEach((l,c)=>{!e4(l)&&l.length>0&&(r.push(c),i.push(l))});const o=s.slice(1).map(l=>{const c=t4(l),u={};return r.forEach((p,m)=>{u[i[m]]=(c[p]||"").trim()}),u}).filter(l=>Object.values(l).some(c=>c.length>0));return{headers:i,rows:o,blockedColumns:a}},loe=t=>t.toLowerCase().replace(/[^a-z0-9]/g,""),coe=t=>{const s={},n=new Set;return t.forEach(a=>{const r=loe(a),i=u1.find(o=>!n.has(o.key)&&(o.key.replace(/_/g,"")===r||o.aliases.includes(r)));i?(s[a]=i.key,n.add(i.key)):s[a]=""}),s},doe=t=>{const s=t.trim();if(!s)return null;if(/^\d{4}-\d{2}-\d{2}$/.test(s))return s;const n=s.match(/^(\d{1,2})[/\-.](\d{1,2})[/\-.](\d{2,4})$/);if(n)return`${n[3].length===2?`20${n[3]}`:n[3]}-${n[1].padStart(2,"0")}-${n[2].padStart(2,"0")}`;const a=new Date(s);return isNaN(a.getTime())?null:a.toISOString().slice(0,10)},uoe=/^[^\s@]+@[^\s@]+\.[^\s@]+$/,moe=["active","graduated","withdrawn","suspended"],a$=async()=>{const{data:t}=await O.from("z_student_accounts").select("student_id, full_name, email"),s=new Map,n=new Map;return(t||[]).forEach(a=>{s.set(String(a.student_id).toLowerCase(),a),a.email&&n.set(String(a.email).toLowerCase(),a)}),{byId:s,byEmail:n}},r$=(t,s,n)=>{const a=new Map,r=new Map;return t.map((i,o)=>{const l={};Object.entries(s).forEach(([y,v])=>{v&&i[y]!==void 0&&(l[v]=i[y].trim())});const c=[],u=[];if(l.full_name||c.push("Full Name is required"),l.email&&!uoe.test(l.email)&&c.push(`Invalid email format: "${l.email}"`),l.enrollment_status){const y=l.enrollment_status.toLowerCase();moe.includes(y)?l.enrollment_status=y:(u.push(`Status "${l.enrollment_status}" not recognized â will default to "active"`),l.enrollment_status="active")}if(l.enrollment_date){const y=doe(l.enrollment_date);y?l.enrollment_date=y:(u.push(`Unparseable date "${l.enrollment_date}" â will be left blank`),l.enrollment_date="")}const p=(l.student_id||"").toLowerCase(),m=(l.email||"").toLowerCase();p&&(a.has(p)?c.push(`Duplicate Record ID in file (also on row ${a.get(p)})`):a.set(p,o+1)),m&&(r.has(m)?c.push(`Duplicate email in file (also on row ${r.get(m)})`):r.set(m,o+1));let x="new",h;return p&&n.byId.has(p)?h=n.byId.get(p):m&&n.byEmail.has(m)&&(h=n.byEmail.get(m)),h&&(x="existing",u.push(`Matches existing student ${h.student_id} (${h.full_name}) â will LINK, not duplicate. Permanent SIS ID is kept.`)),c.length>0&&(x="error"),{row_number:o+1,raw:i,mapped:l,disposition:x,match_student_id:(h==null?void 0:h.student_id)||null,errors:c,warnings:u}})},poe=async(t,s,n,a,r="admin")=>{const i={new_count:a.filter(c=>c.disposition==="new").length,existing_count:a.filter(c=>c.disposition==="existing").length,error_count:a.filter(c=>c.disposition==="error").length},{data:o,error:l}=await O.from(Pd).insert({filename:t,uploaded_by:r,status:"validated",column_mapping:s,blocked_columns:n,total_rows:a.length,...i}).select("id").single();if(l||!o)return null;for(let c=0;c<a.length;c+=200){const u=a.slice(c,c+200).map(m=>({batch_id:o.id,row_number:m.row_number,raw:m.raw,mapped:m.mapped,disposition:m.disposition,match_student_id:m.match_student_id,errors:m.errors,warnings:m.warnings})),{error:p}=await O.from(d1).insert(u);if(p)return await O.from(Pd).update({status:"cancelled",notes:"Row staging failed"}).eq("id",o.id),null}return o.id},hoe=async(t,s)=>{const{data:n,error:a}=await O.rpc("zi_finalize_sis_import",{p_batch_id:t,p_approved_by:s});return a?{error:a.message}:n},xoe=async t=>{await O.from(Pd).update({status:"cancelled",updated_at:new Date().toISOString()}).eq("id",t).neq("status","imported")},foe=async t=>{const{data:s}=await O.from(d1).select("row_number, disposition, match_student_id, sis_student_id, mapped, errors, warnings").eq("batch_id",t).order("row_number");return s||[]},Zs="#800020",s4="#D4AF37",n4=["Upload File","Map Columns","Validate","Preview","Approve & Import"],bj={new:{cls:"bg-emerald-100 text-emerald-700",label:"NEW",icon:e.jsx(Cd,{size:10})},existing:{cls:"bg-blue-100 text-blue-700",label:"EXISTING â LINK",icon:e.jsx(Xs,{size:10})},error:{cls:"bg-red-100 text-red-700",label:"ERROR â SKIPPED",icon:e.jsx(kt,{size:10})},imported:{cls:"bg-emerald-100 text-emerald-700",label:"IMPORTED",icon:e.jsx(pt,{size:10})},linked:{cls:"bg-blue-100 text-blue-700",label:"LINKED",icon:e.jsx(Xs,{size:10})},skipped:{cls:"bg-gray-100 text-gray-500",label:"SKIPPED",icon:e.jsx(kt,{size:10})}},goe=()=>
1297{const[t,s]=d.useState(1),[n,a]=d.useState(""),[r,i]=d.useState([]),[o,l]=d.useState([]),[c,u]=d.useState([]),[p,m]=d.useState({}),[x,h]=d.useState([]),[y,v]=d.useState(null),[g,N]=d.useState(!1),[b,f]=d.useState(""),[j,S]=d.useState(""),[w,_]=d.useState(!1),[C,E]=d.useState(null),[P,F]=d.useState([]),I=d.useRef(null),D=d.useMemo(()=>({total:x.length,newer:x.filter(q=>q.disposition==="new").length,existing:x.filter(q=>q.disposition==="existing").length,errors:x.filter(q=>q.disposition==="error").length,warnings:x.reduce((q,H)=>q+H.warnings.length,0)}),[x]),L=d.useMemo(()=>Object.values(p).filter(Boolean),[p]),V=L.includes("full_name"),B=L.includes("student_id")||L.includes("email"),A=()=>{s(1),a(""),i([]),l([]),u([]),m({}),h([]),v(null),f(""),S(""),_(!1),E(null),F([]),I.current&&(I.current.value="")},z=q=>{if(f(""),!/\.(csv|txt)$/i.test(q.name)){f("Invalid file format. Please upload a CSV file (.csv). If your sheet is in Excel or Google Sheets, use File â Download â CSV first.");return}if(q.size>5*1024*1024){f("File is larger than 5 MB. Please split the sheet into smaller files.");return}const H=new FileReader;H.onload=()=>{const G=String(H.result||""),W=n$(G);if(W.headers.length===0||W.rows.length===0){f("The file appears to be empty or has no header row. The first row must contain column names.");return}a(q.name),i(W.headers),l(W.rows),u(W.blockedColumns),m(coe(W.headers)),s(2)},H.onerror=()=>f("Could not read the file. Please try again."),H.readAsText(q)},M=async()=>{N(!0),f("");try{const q=await a$(),H=r$(o,p,q);h(H),s(3)}catch{f("Validation failed â could not reach the student database.")}finally{N(!1)}},R=async()=>{N(!0),f("");try{const q=await poe(n,p,c,x);if(!q)throw new Error("staging failed");v(q),s(5)}catch{f("Could not stage the batch. Nothing was imported. Please try again.")}finally{N(!1)}},T=async()=>{if(!y||!w||j.trim().length<2)return;N(!0),f("");const q=await hoe(y,j.trim());"error"in q?f(q.error):(E(q),F(await foe(y))),N(!1)},U=async()=>{y&&await xoe(y),A()};return e.jsxs("div",{className:"space-y-5",children:[e.jsxs("div",{className:"p-5 rounded-xl border-2 bg-white",style:{borderColor:`${Zs}25`},children:[e.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-4",children:[e.jsxs("div",{children:[e.jsxs("h3",{className:"text-sm font-bold text-gray-900 flex items-center gap-2",children:[e.jsx(Lb,{size:16,style:{color:Zs}})," Secure Student Import â Existing Data Sheet"]}),e.jsxs("p",{className:"text-xs text-gray-500 mt-1 max-w-2xl leading-relaxed",children:["Staged, approval-gated import. Your file is validated, mapped, and checked for duplicates",e.jsx("strong",{children:" before anything is imported"}),". New students receive a permanent SIS Student ID (ZI-YYYY-NNNNNN) automatically at creation; students already in the system are ",e.jsx("strong",{children:"linked, never duplicated"})," â their existing permanent SIS ID is kept (or minted if missing)."]})]}),e.jsxs("button",{onClick:ooe,className:"flex items-center gap-1.5 px-3 py-2.5 rounded-xl text-xs font-bold text-white shrink-0",style:{background:Zs},children:[e.jsx(us,{size:13})," Download CSV Template"]})]}),e.jsxs("div",{className:"mt-3 p-3 rounded-xl flex items-start gap-2 text-[11px]",style:{background:`${s4}12`,color:"#7a5c00"},children:[e.jsx(Xe,{size:13,className:"mt-0.5 shrink-0"}),e.jsxs("span",{children:[e.jsx("strong",{children:"PII protection:"})," columns whose headers look like SSN, tax ID, date of birth, driver's license, passport, or password are automatically stripped at upload and never stored. Sensitive identifiers are never part of a SIS Student ID."]})]})]}),e.jsx("div",{className:"flex items-center gap-1 flex-wrap",children:n4.map((q,H)=>{const G=H+1,W=t===G,X=t>G||C!==null;return e.jsxs(re.Fragment,{children:[e.jsxs("div",{className:`flex items-center gap-1.5 px-3 py-1.5 rounded-full text-[11px] font-bold ${W?"text-white":X?"bg-emerald-100 text-emerald-700":"bg-gray-100 text-gray-400"}`,style:W?{background:Zs}:{},children:[X&&!W?e.jsx(pt,{size:11}):e.jsx("span",{children:G})," ",q]}),H<n4.length-1&&e.jsx(Vt,{size:12,className:"text-gray-300"})]},q)}
1297)}),b&&e.jsxs("div",{className:"p-3 rounded-xl bg-red-50 text-red-700 text-xs flex items-center gap-2",children:[e.jsx(ve,{size:14,className:"shrink-0"})," ",b]}),t===1&&e.jsx("div",{className:"bg-white rounded-xl border p-8",children:e.jsxs("div",{onDragOver:q=>q.preventDefault(),onDrop:q=>{var G;q.preventDefault();const H=(G=q.dataTransfer.files)==null?void 0:G[0];H&&z(H)},className:"border-2 border-dashed rounded-2xl p-10 text-center cursor-pointer hover:bg-gray-50 transition-colors",style:{borderColor:`${Zs}40`},onClick:()=>{var q;return(q=I.current)==null?void 0:q.click()},children:[e.jsx(Ri,{size:36,className:"mx-auto mb-3",style:{color:Zs}}),e.jsx("p",{className:"text-sm font-semibold text-gray-800",children:"Drop your Institute student data sheet here, or click to browse"}),e.jsx("p",{className:"text-xs text-gray-500 mt-1",children:"CSV format · max 5 MB · first row must be column headers"}),e.jsx("p",{className:"text-[10px] text-gray-400 mt-3",children:"Format is validated on upload. No data is imported at this step â the file goes to a review pipeline only."}),e.jsx("input",{ref:I,type:"file",accept:".csv,.txt",className:"hidden",onChange:q=>{var G;const H=(G=q.target.files)==null?void 0:G[0];H&&z(H)}})]})}),t===2&&e.jsxs("div",{className:"bg-white rounded-xl border p-6 space-y-4",children:[e.jsx("div",{className:"flex flex-wrap items-center justify-between gap-3",children:e.jsxs("div",{children:[e.jsx("h4",{className:"text-sm font-bold text-gray-900",children:"Map your columns to SIS fields"}),e.jsxs("p",{className:"text-xs text-gray-500 mt-0.5",children:[e.jsx("span",{className:"font-mono",children:n})," · ",o.length," data rows · ",r.length," columns. Suggested mappings are pre-filled â review and adjust each one."]})]})}),c.length>0&&e.jsxs("div",{className:"p-3 rounded-xl bg-amber-50 text-amber-800 text-xs flex items-start gap-2",children:[e.jsx(zn,{size:14,className:"mt-0.5 shrink-0"}),e.jsxs("span",{children:[e.jsxs("strong",{children:[c.length," sensitive column",c.length>1?"s":""," stripped for privacy:"]})," ",c.map(q=>e.jsx("code",{className:"px-1 bg-amber-100 rounded mx-0.5",children:q},q)),"â these were removed at upload and will not be stored anywhere."]})]}),e.jsx("div",{className:"overflow-x-auto",children:e.jsxs("table",{className:"w-full text-sm",children:[e.jsx("thead",{children:e.jsx("tr",{className:"border-b",style:{background:`${Zs}05`},children:["Your Column","Sample Values","Maps To SIS Field"].map(q=>e.jsx("th",{className:"text-left px-4 py-2.5 text-[10px] uppercase tracking-wider text-gray-500",children:q},q))})}),e.jsx("tbody",{className:"divide-y divide-gray-50",children:r.map(q=>e.jsxs("tr",{children:[e.jsx("td",{className:"px-4 py-2.5 font-mono text-xs font-semibold text-gray-800",children:q}),e.jsx("td",{className:"px-4 py-2.5 text-[11px] text-gray-400 max-w-[260px] truncate",children:o.slice(0,3).map(H=>H[q]).filter(Boolean).join(" · ")||"â"}),e.jsx("td",{className:"px-4 py-2.5",children:e.jsxs("select",{value:p[q]||"",onChange:H=>m(G=>({...G,[q]:H.target.value})),className:"border rounded-lg px-2 py-1.5 text-xs bg-white focus:outline-none focus:border-[#800020] min-w-[220px]",children:[e.jsx("option",{value:"",children:"â Do not import â"}),u1.map(H=>e.jsxs("option",{value:H.key,disabled:L.includes(H.key)&&p[q]!==H.key,children:[H.label,H.required?" (required)":""," â ",H.hint]},H.key))]})})]},q))})]})}),!V&&e.jsxs("div",{className:"p-3 rounded-xl bg-red-50 text-red-700 text-xs flex items-center gap-2",children:[e.jsx(kt,{size:14})," A column must be mapped to ",e.jsx("strong",{children:"Full Name"})," (required) before validation can run."]}),V&&!B&&e.jsxs("div",{className:"p-3 rounded-xl bg-amber-50 text-amber-800 text-xs flex items-center gap-2",children:[e.jsx(ve,{size:14})," No ",e.jsx("strong",{children:"Record ID"})," or ",e.jsx("strong",{children:"Email"})," column is mapped â duplicate matching against existing students will be limited. Recommended: map at least one."]}),e.jsxs("div",{className:"flex items-center justify-between pt-2",children:[e.jsxs("button",{onClick:A,className:"flex items-center gap-1.5 px-4 py-2.5 rounded-xl border text-xs font-semibold text-gray-600 hover:bg-gray-50",children:[e.jsx(Je,{size:13})," Start Over"]}),e.jsxs("button",{onClick:M,disabled:!V||g,className:"flex items-center gap-1.5 px-5 py-2.5 rounded-xl text-xs font-bold text-white disabled:opacity-40",style:{background:Zs},children:[g?e.jsx(Be,{size:13,className:"animate-spin"}):e.jsx(Ie,{size:13}),g?"Validatingâ¦":"Run Validation & Duplicate Check"]})]})]}),t===3&&e.jsxs("div",{className:"bg-white rounded-xl border p-6 space-y-4",children:[e.jsx("h4",{className:"text-sm font-bold text-gray-900",children:"Validation & duplicate check results"}),e.jsx("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-3",children:[{label:"Total Rows",value:D.total,color:Zs,icon:e.jsx(ts,{size:13})},{label:"New Students",value:D.newer,color:"#10B981",icon:e.jsx(Cd,{size:13})},{label:"Existing â Will Link",value:D.existing,color:"#3B82F6",icon:e.jsx(Xs,{size:13})},{label:"Rows With Errors",value:D.errors,color:D.errors>0?"#EF4444":"#9CA3AF",icon:e.jsx(kt,{size:13})}].map((q,H)=>e.jsxs("div",{className:"p-3 rounded-xl border bg-gray-50",children:[e.jsxs("div",{className:"flex items-center gap-1.5 text-[10px] uppercase tracking-wider",style:{color:q.color},children:[q.icon," ",q.label]}),e.jsx("p",{className:"font-mono text-xl font-bold mt-0.5",style:{color:q.color},children:q.value})]},H))}),e.jsxs("div",{className:"p-3 rounded-xl text-xs leading-relaxed",style:{background:`${Zs}06`,color:"#4b5563"},children:[e.jsx("strong",{style:{color:Zs},children:"How SIS Student IDs will be assigned:"})," ",D.newer," new student",D.newer!==1?"s":""," will each receive a brand-new permanent",e.jsx("span",{className:"font-mono",children:" ZI-YYYY-NNNNNN"})," ID automatically at creation (database trigger)."," ",D.existing," matched student",D.existing!==1?"s":""," will keep their existing permanent SIS ID â the import links to the current record and never creates a duplicate or changes an ID.",D.errors>0&&e.jsxs(e.Fragment,{children:[" Rows with errors will be ",e.jsx("strong",{children:"skipped"})," â fix them in your sheet and re-import later if needed."]})]}),(D.errors>0||D.warnings>0)&&e.jsx("div",{className:"max-h-56 overflow-y-auto border rounded-xl divide-y divide-gray-50",children:x.filter(q=>q.errors.length>0||q.warnings.length>0).map(q=>e.jsxs("div",{className:"px-4 py-2 text-[11px]",children:[e.jsxs("span",{className:"font-mono font-bold text-gray-700 mr-2",children:["Row ",q.row_number]}),e.jsx("span",{className:"text-gray-500",children:q.mapped.full_name||"(no name)"}),q.errors.map((H,G)=>e.jsxs("p",{className:"text-red-600 mt-0.5 flex items-center gap-1",children:[e.jsx(kt,{size:10})," ",H]},`e${G}`)),q.warnings.map((H,G)=>e.jsxs("p",{className:"text-amber-600 mt-0.5 flex items-center gap-1",children:[e.jsx(ve,{size:10})," ",H]},`w${G}`))]},q.row_number))}),e.jsxs("div",{className:"flex items-center justify-between pt-2",children:[e.jsxs("button",{onClick:()=>s(2),className:"flex items-center gap-1.5 px-4 py-2.5 rounded-xl border text-xs font-semibold text-gray-600 hover:bg-gray-50",children:[e.jsx(Je,{size:13})," Back to Mapping"]}),e.jsxs("button",{onClick:()=>s(4),className:"flex items-center gap-1.5 px-5 py-2.5 rounded-xl text-xs font-bold text-white",style:{background:Zs},children:[e.jsx(ms,{size:13})," View Import Preview"]})]})]}),t===4&&e.jsxs("div",{className:"bg-white rounded-xl border p-6 space-y-4",children:[e.jsxs("div",{children:[e.jsx("h4",{className:"text-sm font-bold text-gray-900",children:"Import preview â nothing has been imported yet"}),e.jsx("p",{className:"text-xs text-gray-500 mt-0.5",children:"Exactly what will happen to each row when (and only when) you approve on the next step."})]}),e.jsx("div",{className:"border rounded-xl overflow-x-auto max-h-[420px] overflow-y-auto",children:e.jsxs("table",{className:"w-full text-sm min-w-[800px]",children:[e.jsx("thead",{className:"sticky top-0",children:e.jsx("tr",{className:"border-b bg-white",style:{boxShadow:`inset 0 -1px 0 ${Zs}20`},children:["#","Action","Full Name","Record ID","Email","Program","Status","SIS Student ID"].map(q=>e.jsx("th",{className:"text-left px-3 py-2.5 text-[10px] uppercase tracking-wider text-gray-500 whitespace-nowrap",children:q},q))})}),e.jsx("tbody",{className:"divide-y divide-gray-50",children:x.map(q=>{const H=bj[q.disposition];return e.jsxs("tr",{className:q.disposition==="error"?"bg-red-50/50":"hover:bg-gray-50",children:[e.jsx("td",{className:"px-3 py-2 font-mono text-[10px] text-gray-400",children:q.row_number}),e.jsx("td",{className:"px-3 py-2",children:e.jsxs("span",{className:`inline-flex items-center gap-1 px-2 py-0.5 rounded-full text-[9px] font-bold ${H.cls}`,children:[H.icon," ",H.label]})}),e.jsx("td",{className:"px-3 py-2 text-xs font-medium text-gray-900",children:q.mapped.full_name||"â"}),e.jsx("td",{className:"px-3 py-2 font-mono text-[10px] text-gray-600",children:q.dis
1297position==="existing"?q.match_student_id:q.mapped.student_id||e.jsx("span",{className:"text-gray-400 italic",children:"auto-generate"})}),e.jsx("td",{className:"px-3 py-2 text-[11px] text-gray-600",children:q.mapped.email||"â"}),e.jsx("td",{className:"px-3 py-2 text-[11px] text-gray-600",children:q.mapped.program||"â"}),e.jsx("td",{className:"px-3 py-2 text-[10px] text-gray-500",children:q.mapped.enrollment_status||"active"}),e.jsx("td",{className:"px-3 py-2 font-mono text-[10px]",style:{color:Zs},children:q.disposition==="existing"?"keeps existing ID":q.disposition==="new"?"new ZI-2026-⦠on import":"â"})]},q.row_number)})})]})}),e.jsxs("div",{className:"flex items-center justify-between pt-2",children:[e.jsxs("button",{onClick:()=>s(3),className:"flex items-center gap-1.5 px-4 py-2.5 rounded-xl border text-xs font-semibold text-gray-600 hover:bg-gray-50",children:[e.jsx(Je,{size:13})," Back to Validation"]}),e.jsxs("button",{onClick:R,disabled:g||D.newer+D.existing===0,className:"flex items-center gap-1.5 px-5 py-2.5 rounded-xl text-xs font-bold text-white disabled:opacity-40",style:{background:Zs},children:[g?e.jsx(Be,{size:13,className:"animate-spin"}):e.jsx(Ie,{size:13}),g?"Stagingâ¦":"Stage Batch â Go to Approval"]})]})]}),t===5&&!C&&e.jsxs("div",{className:"bg-white rounded-xl border-2 p-6 space-y-4",style:{borderColor:`${s4}60`},children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Xe,{size:16,style:{color:Zs}}),e.jsx("h4",{className:"text-sm font-bold text-gray-900",children:"Final approval required"})]}),e.jsxs("p",{className:"text-xs text-gray-600 leading-relaxed max-w-2xl",children:["The batch is staged and locked in the review pipeline. ",e.jsx("strong",{children:"No student records have been created or modified."})," Approving will import ",e.jsxs("strong",{children:[D.newer," new student",D.newer!==1?"s":""]})," (each receiving a permanent SIS Student ID), link ",e.jsxs("strong",{children:[D.existing," existing student",D.existing!==1?"s":""]})," to their current permanent IDs, and skip ",e.jsxs("strong",{children:[D.errors," error row",D.errors!==1?"s":""]}),". This action is recorded with your name and a timestamp."]}),e.jsxs("div",{className:"max-w-md space-y-3",children:[e.jsxs("div",{children:[e.jsx("label",{className:"text-[10px] uppercase tracking-wider text-gray-500 font-bold",children:"Approver name (required)"}),e.jsx("input",{value:j,onChange:q=>S(q.target.value),placeholder:"e.g. Z. Harris â Registrar",className:"w-full mt-1 border rounded-xl px-3 py-2.5 text-sm focus:outline-none focus:border-[#800020]"})]}),e.jsxs("label",{className:"flex items-start gap-2 text-xs text-gray-700 cursor-pointer",children:[e.jsx("input",{type:"checkbox",checked:w,onChange:q=>_(q.target.checked),className:"mt-0.5"}),e.jsx("span",{children:"I have reviewed the column mapping, validation results, and import preview, and I approve this import."})]})]}),e.jsxs("div",{className:"flex items-center justify-between pt-2",children:[e.jsxs("button",{onClick:U,className:"flex items-center gap-1.5 px-4 py-2.5 rounded-xl border text-xs font-semibold text-red-600 hover:bg-red-50",children:[e.jsx(kt,{size:13})," Cancel Batch (imports nothing)"]}),e.jsxs("button",{onClick:T,disabled:g||!w||j.trim().length<2,className:"flex items-center gap-1.5 px-6 py-3 rounded-xl text-sm font-bold text-white shadow-md disabled:opacity-40",style:{background:`linear-gradient(135deg, ${Zs}, #5c0017)`},children:[g?e.jsx(Be,{size:14,className:"animate-spin"}):e.jsx(pt,{size:14}),g?"Importingâ¦":"Approve & Import Now"]})]})]}),C&&e.jsxs("div",{className:"bg-white rounded-xl border-2 p-6 space-y-4",style:{borderColor:"#10B98150"},children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(pt,{size:18,className:"text-emerald-600"}),e.jsx("h4",{className:"text-sm font-bold text-gray-900",children:"Import complete"})]}),e.jsx("div",{className:"grid grid-cols-3 gap-3 max-w-lg",children:[{label:"Imported (new SIS IDs)",value:C.imported,color:"#10B981"},{label:"Linked (existing IDs kept)",value:C.linked,color:"#3B82F6"},{label:"Skipped (errors)",value:C.skipped,color:C.skipped>0?"#EF4444":"#9CA3AF"}].map((q,H)=>e.jsxs("div",{className:"p-3 rounded-xl border bg-gray-50",children:[e.jsx("p",{className:"text-[10px] uppercase tracking-wider text-gray-400",children:q.label}),e.jsx("p",{className:"font-mono text-xl font-bold",style:{color:q.color},children:q.value})]},H))}),P.length>0&&e.jsx("div",{className:"border rounded-xl overflow-x-auto max-h-[320px] overflow-y-auto",children:e.jsxs("table",{className:"w-full text-sm min-w-[600px]",children:[e.jsx("thead",{className:"sticky top-0 bg-white",children:e.jsx("tr",{className:"border-b",children:["#","Student","Result","Record ID","SIS Student ID"].map(q=>e.jsx("th",{className:"text-left px-3 py-2 text-[10px] uppercase tracking-wider text-gray-500",children:q},q))})}),e.jsx("tbody",{className:"divide-y divide-gray-50",children:P.map(q=>{var G;const H=bj[q.disposition]||bj.skipped;return e.jsxs("tr",{children:[e.jsx("td",{className:"px-3 py-2 font-mono text-[10px] text-gray-400",children:q.row_number}),e.jsx("td",{className:"px-3 py-2 text-xs text-gray-900",children:((G=q.mapped)==null?void 0:G.full_name)||"â"}),e.jsx("td",{className:"px-3 py-2",children:e.jsxs("span",{className:`inline-flex items-center gap-1 px-2 py-0.5 rounded-full text-[9px] font-bold ${H.cls}`,children:[H.icon," ",H.label]})}),e.jsx("td",{className:"px-3 py-2 font-mono text-[10px] text-gray-600",children:q.match_student_id||"â"}),e.jsx("td",{className:"px-3 py-2 font-mono text-[10px] font-bold",style:{color:Zs},children:q.sis_student_id||"â"})]},q.row_number)})})]})}),e.jsxs("button",{onClick:A,className:"flex items-center gap-1.5 px-4 py-2.5 rounded-xl text-xs font-bold text-white",style:{background:Zs},children:[e.jsx(Ri,{size:13})," Import Another File"]})]})]})},Ce=(t,s,n,a,r,i)=>({key:t,label:s,required:n,type:a,hint:r,aliases:i}),vj=u1.map(t=>({...t,type:t.key==="enrollment_date"?"date":"text"})),Ji=Ce("student_ref","Student Record ID",!0,"text","Legacy/record ID (e.g. ZSI-2025-001). Used to link to the permanent SIS Student ID.",["studentid","recordid","id","studentnumber","studentno","studentref","legacyid","zsiid"]),vN=[{key:"current_roster",label:"Current Student Roster",description:"Active students. New records get a permanent SIS ID automatically; matches to existing records link (never duplicate).",targetTable:"z_student_accounts",studentPipeline:!0,defaultStatus:"active",fields:vj,example:["ZSI-2025-010","Ava Current","[email protected]","(555) 201-0100","Cosmetology","active","2026-01-06","Current cohort"]},{key:"historical_students",label:"Historical Students",description:"Former/withdrawn students. Imported with withdrawn status; permanent SIS IDs still assigned for records linkage.",targetTable:"z_student_accounts",studentPipeline:!0,defaultStatus:"withdrawn",fields:vj,example:["ZSI-2023-042","Noah Historical","[email protected]","","Esthetics","withdrawn","2023-03-15","Withdrew 2023"]},{key:"graduates",label:"Graduates",description:"Completed students. Imported with graduated status; SIS IDs anchor transcript and outcome reporting.",targetTable:"z_student_accounts",studentPipeline:!0,defaultStatus:"graduated",fields:vj,example:["ZSI-2024-007","Grace Graduate","[email protected]","","Master Esthetics","graduated","2024-09-02","Class of 2025"]},{key:"student_ledgers",label:"Student Ledgers",description:"Charges, payments, and adjustments per student. SIS IDs auto-stamped by the ledger trigger.",targetTable:"z_student_financial_records",studentPipeline:!1,fields:[Ji,Ce("record_type","Record Type",!1,"text","charge | payment | adjustment | fee (default: charge)",["recordtype","type","entrytype","transactiontype"]),Ce("description","Description",!1,"text","Ledger line description.",["description","item","detail","memo"]),Ce("amount_cents","Amount (USD)",!0,"currency","Dollar amount, e.g. 1250.00 â converted to cents.",["amount","amountusd","debit","charge","payment"]),Ce("balance_cents","Balance (USD)",!1,"currency","Running balance after this entry (optional).",["balance","runningbalance","balanceafter"]),Ce("due_date","Due Date",!1,"date","YYYY-MM-DD.",["duedate","datedue"]),Ce("paid_date","Paid Date",!1,"date","YYYY-MM-DD.",["paiddate","datepaid","paymentdate"]),Ce("status","Status",!1,"text","posted | paid | outstanding (default: posted)",["status","state"]),Ce("semester","Term / Period",!1,"text","Semester or billing period.",["semester","term","billingperiod"]),Ce("notes","Notes",!1,"text","Free text.",["notes","note","comments"])],example:["ZSI-2025-010","charge","Tuition installment 1","1250.00","8750.00","2026-02-01","202
12976-01-28","paid","Winter 2026",""]},{key:"tuition_accounts",label:"Tuition Accounts (per Student)",description:"Total contracted tuition per student. SIS IDs auto-stamped by the tuition-account trigger.",targetTable:"z_institute_tuition_accounts",studentPipeline:!1,fields:[Ji,Ce("student_name","Student Name",!1,"text","For snapshot display.",["studentname","fullname","name"]),Ce("program","Program",!1,"text","Enrolled program.",["program","course"]),Ce("total_tuition_cents","Total Tuition (USD)",!0,"currency","Contracted total, e.g. 12500.00.",["totaltuition","tuition","tuitionamount","contractamount"]),Ce("notes","Notes",!1,"text","Free text.",["notes","note"])],example:["ZSI-2025-010","Ava Current","Cosmetology","12500.00","Standard contract"]},{key:"program_fees",label:"Tuition & Fees by Program",description:"Program-level fee schedule: tuition, registration, kit, other fees, and total hours.",targetTable:"z_sis_program_fees",studentPipeline:!1,fields:[Ce("program","Program",!0,"text","Program name, e.g. Cosmetology.",["program","programname","course"]),Ce("tuition_cents","Tuition (USD)",!0,"currency","Base tuition.",["tuition","tuitionamount"]),Ce("registration_fee_cents","Registration Fee (USD)",!1,"currency","One-time registration fee.",["registrationfee","regfee","enrollmentfee"]),Ce("kit_fee_cents","Kit / Books Fee (USD)",!1,"currency","Kit, books, and supplies.",["kitfee","kitcost","books","bookskit","supplies"]),Ce("other_fees_cents","Other Fees (USD)",!1,"currency","Any additional fees.",["otherfees","fees","misc","miscfees"]),Ce("total_hours","Program Hours",!1,"number","Total clock hours, e.g. 1600.",["totalhours","hours","programhours","clockhours"]),Ce("effective_date","Effective Date",!1,"date","When this fee schedule takes effect.",["effectivedate","startdate"]),Ce("notes","Notes",!1,"text","Free text.",["notes","note"])],example:["Cosmetology","12500.00","100.00","1850.00","0","1600","2026-01-01","WA 1600-hour program"]},{key:"clock_hours",label:"Student Hours / Clock Hours",description:"Theory + practical hour logs per student. Students are matched (or created) and anchored to their SIS ID.",targetTable:"sis_clock_hours",studentPipeline:!1,fields:[Ji,Ce("full_name","Student Name",!1,"text","Used if the record ID is new.",["fullname","name","studentname"]),Ce("email","Email",!1,"text","Secondary match key.",["email","emailaddress"]),Ce("program","Program",!1,"text","Enrolled program.",["program","course"]),Ce("date","Date",!0,"date","Date the hours were earned.",["date","logdate","attendancedate","hoursdate"]),Ce("theory_hours","Theory Hours",!1,"number","e.g. 3.5",["theoryhours","theory","classroomhours"]),Ce("practical_hours","Practical Hours",!1,"number","e.g. 4.0",["practicalhours","practical","clinichours","labhours"]),Ce("category","Category",!1,"text","Optional category/topic.",["category","topic","subject"]),Ce("notes","Notes",!1,"text","Free text.",["notes","note"])],example:["ZSI-2025-010","Ava Current","[email protected]","Cosmetology","2026-03-04","3.5","4.0","Hair cutting",""]},{key:"schedules",label:"Schedules",description:"Class/cohort schedules by program (optionally per student).",targetTable:"z_sis_schedules",studentPipeline:!1,fields:[Ce("program","Program",!0,"text","Program the schedule belongs to.",["program","programname","course"]),{...Ji,required:!1,hint:"Optional â for student-specific schedules."},Ce("cohort","Cohort / Class",!1,"text","e.g. Jan 2026 Day Cohort.",["cohort","class","group","section"]),Ce("days","Days",!1,"text","e.g. Mon-Fri or Tue/Thu.",["days","dayofweek","schedule","meetingdays"]),Ce("start_time","Start Time",!1,"text","e.g. 9:00 AM.",["starttime","begins"]),Ce("end_time","End Time",!1,"text","e.g. 4:30 PM.",["endtime","ends"]),Ce("room","Room",!1,"text","Room or lab.",["room","location","classroom"]),Ce("instructor","Instructor",!1,"text","Assigned instructor.",["instructor","teacher","educator"]),Ce("start_date","Start Date",!1,"date","Cohort start.",["startdate","begindate"]),Ce("end_date","End Date",!1,"date","Cohort end.",["enddate","finishdate"]),Ce("notes","Notes",!1,"text","Free text.",["notes","note"])],example:["Cosmetology","","Jan 2026 Day","Mon-Fri","9:00 AM","4:30 PM","Studio A","Z. Reese","2026-01-06","202
12976-12-18",""]},{key:"curriculum",label:"Curriculum",description:"Courses/units per program with theory + practical hour breakdown.",targetTable:"z_sis_curriculum",studentPipeline:!1,fields:[Ce("program","Program",!0,"text","Program the course belongs to.",["program","programname"]),Ce("course_code","Course Code",!1,"text","e.g. COS-101.",["coursecode","code","unitcode"]),Ce("course_title","Course Title",!0,"text","e.g. Hair Cutting Fundamentals.",["coursetitle","title","course","unit","coursename"]),Ce("phase","Phase",!1,"text","Program phase, e.g. Phase 1.",["phase","level","stage"]),Ce("theory_hours","Theory Hours",!1,"number","Classroom hours.",["theoryhours","theory"]),Ce("practical_hours","Practical Hours",!1,"number","Hands-on hours.",["practicalhours","practical"]),Ce("total_hours","Total Hours",!1,"number","Defaults to theory + practical.",["totalhours","hours"]),Ce("description","Description",!1,"text","Course description.",["description","summary"])],example:["Cosmetology","COS-101","Hair Cutting Fundamentals","Phase 1","40","80","120","Foundations of cutting"]},{key:"sap_reports",label:"SAP Reports by Period",description:"Satisfactory Academic Progress checkpoints per evaluation period. Students matched and anchored to SIS IDs.",targetTable:"sis_sap_checkpoints",studentPipeline:!1,fields:[Ji,Ce("full_name","Student Name",!1,"text","Used if the record ID is new.",["fullname","name","studentname"]),Ce("email","Email",!1,"text","Secondary match key.",["email"]),Ce("program","Program",!1,"text","Enrolled program.",["program"]),Ce("checkpoint_date","Checkpoint Date",!0,"date","Evaluation date.",["checkpointdate","evaluationdate","date","sapdate"]),Ce("period","Evaluation Period",!1,"text","e.g. 450-hour checkpoint / Q1 2026.",["period","evaluationperiod","sapperiod","term"]),Ce("gpa","GPA / Grade Avg",!1,"number","e.g. 3.4 or 88.",["gpa","gradeaverage","grade"]),Ce("attendance_pct","Attendance %",!1,"number","e.g. 92.5.",["attendance","attendancepct","attendancepercent"]),Ce("hours_completed","Hours Completed",!1,"number","Cumulative clock hours.",["hourscompleted","completedhours"]),Ce("hours_required","Hours Required",!1,"number","Required at this checkpoint.",["hoursrequired","requiredhours"]),Ce("sap_status","SAP Status",!1,"text","satisfactory | warning | probation (default: satisfactory)",["sapstatus","standing","status"]),Ce("evaluator_name","Evaluator",!1,"text","Who performed the evaluation.",["evaluator","evaluatorname","reviewedby"]),Ce("notes","Notes",!1,"text","Free text.",["notes","note"])],example:["ZSI-2025-010","Ava Current","","Cosmetology","2026-04-15","450-hour checkpoint","3.6","94","452","450","satisfactory","D. Admin",""]},{key:"enrollment_records",label:"Enrollment Records",description:"Enrollment contracts/history per student. Mints/links the permanent SIS ID for every record.",targetTable:"z_sis_enrollment_records",studentPipeline:!1,fields:[Ji,Ce("full_name","Student Name",!1,"text","Snapshot for the record.",["fullname","name","studentname"]),Ce("email","Email",!1,"text","Contact email.",["email"]),Ce("program","Program",!1,"text","Enrolled program.",["program"]),Ce("enrollment_date","Enrollment Date",!1,"date","Contract/enrollment date.",["enrollmentdate","startdate","enrolldate"]),Ce("expected_graduation","Expected Graduation",!1,"date","Projected completion.",["expectedgraduation","graduationdate","expectedgrad","completiondate"]),Ce("enrollment_type","Enrollment Type",!1,"text","full-time | part-time | transfer | re-entry.",["enrollmenttype","type"]),Ce("contract_number","Contract #",!1,"text","Enrollment agreement number.",["contractnumber","contractno","agreementnumber"]),Ce("status","Status",!1,"text","active | completed | withdrawn (default: active)",["status"]),Ce("notes","Notes",!1,"text","Free text.",["notes","note"])],example:["ZSI-2025-010","Ava Current","[email protected]","Cosmetology","2026-01-06","2026-12-18","full-time","EA-2026-0110","active",""]},{key:"student_documents",label:"Student Documents",description:"Document metadata per student (IDs, diplomas, contracts). Upload files to the student-documents bucket; reference URLs here.",targetTable:"z_student_documents",studentPipeline:!1,fields:[Ji,Ce("document_type","Document Type",!1,"text","diploma | government-id | enrollment-agreement | transcript | other.",["documenttype","doctype","type"]),Ce("file_name","File Name",!0,"text","Original file name.",["filename","document","docname","file"]),Ce("file_url","File URL",!1,"text","Storage URL (student-documents bucket) if already uploaded.",["fileurl","url","link"]),Ce("status","Status",!1,"text","pending | verified | rejected (default: pending)",["status"]),Ce("notes","Notes",!1,"text","Free text.",["notes","note"])],example:["ZSI-2025-010","diploma","hs-diploma-ava.pdf","","verified","Verified at enrollment"]}
1297,{key:"financial_aid",label:"Financial Aid Records",description:"Aid awards and disbursements per student. Students matched and anchored to SIS IDs.",targetTable:"sis_financial_aid",studentPipeline:!1,fields:[Ji,Ce("full_name","Student Name",!1,"text","Used if the record ID is new.",["fullname","name","studentname"]),Ce("email","Email",!1,"text","Secondary match key.",["email"]),Ce("program","Program",!1,"text","Enrolled program.",["program"]),Ce("aid_type","Aid Type",!1,"text","wioa | va | scholarship | payment-plan | other.",["aidtype","type","fundingtype"]),Ce("amount_cents","Amount (USD)",!0,"currency","Award/disbursement amount.",["amount","awardamount","disbursement"]),Ce("disbursement_date","Disbursement Date",!1,"date","When funds applied.",["disbursementdate","datedisbursed","date"]),Ce("period","Period",!1,"text","Award period/term.",["period","term","awardperiod"]),Ce("status","Status",!1,"text","awarded | disbursed | pending (default: awarded)",["status"]),Ce("notes","Notes",!1,"text","Free text.",["notes","note"])],example:["ZSI-2025-010","Ava Current","","Cosmetology","wioa","4000.00","2026-01-15","Winter 2026","disbursed","WIOA voucher"]},{key:"funding_awards",label:"Scholarships / Grants / Loans",description:"Funding sources per student (Institute funding structure). SIS IDs auto-stamped by the funding trigger.",targetTable:"z_institute_funding_sources",studentPipeline:!1,fields:[Ji,Ce("student_name","Student Name",!1,"text","Snapshot for the award.",["studentname","fullname","student"]),Ce("program","Program",!1,"text","Enrolled program.",["program"]),Ce("funding_kind","Funding Kind",!1,"text","scholarship | grant | loan (default: scholarship)",["fundingkind","kind","fundingtype","category"]),Ce("name","Award Name",!1,"text","e.g. Zorganics Foundation Scholarship.",["awardname","scholarshipname","grantname","name","award"]),Ce("source","Source / Provider",!1,"text","Funding source or agency.",["source","provider","agency","funder"]),Ce("approved_amount_cents","Approved Amount (USD)",!0,"currency","Total approved.",["approvedamount","amount","awardamount"]),Ce("award_date","Award Date",!1,"date","Date awarded.",["awarddate","dateawarded"]),Ce("applied_to_tuition_cents","Applied to Tuition (USD)",!1,"currency","Portion already applied.",["appliedtotuition","applied","appliedamount"]),Ce("status","Status",!1,"text","approved | pending | disbursed (default: approved)",["status"]),Ce("notes","Notes",!1,"text","Free text.",["notes","note"])],example:["ZSI-2025-010","Ava Current","Cosmetology","scholarship","Foundation Scholarship","Zorganics Foundation","2500.00","2026-01-10","2500.00","approved",""]}],yoe=t=>vN.find(s=>s.key===t),boe=t=>{const s=t.fields.map(a=>a.key).join(","),n=t.example.map(a=>`"${a}"`).join(",");return[s,n].join(` 1298`)},i$=t=>{const s=new Blob([boe(t)],{type:"text/csv"}),n=URL.createObjectURL(s),a=document.createElement("a");a.href=n,a.download=`zorganics-institute-sis-${t.key.replace(/_/g,"-")}-template.csv`,a.click(),URL.revokeObjectURL(n)},jj=t=>t.toLowerCase().replace(/[^a-z0-9]/g,""),voe=(t,s)=>{const n={},a=new Set;return s.forEach(r=>{const i=jj(r),o=t.fields.find(l=>!a.has(l.key)&&(jj(l.key)===i||l.aliases.map(jj).includes(i)));o?(n[r]=o.key,a.add(o.key)):n[r]=""}),n},joe=t=>{const s=t.trim();if(!s)return null;if(/^\d{4}-\d{2}-\d{2}$/.test(s))return s;const n=s.match(/^(\d{1,2})[/\-.](\d{1,2})[/\-.](\d{2,4})$/);if(n)return`${n[3].length===2?`20${n[3]}`:n[3]}-${n[1].padStart(2,"0")}-${n[2].padStart(2,"0")}`;const a=new Date(s);return isNaN(a.getTime())?null:a.toISOString().slice(0,10)},woe=t=>{const s=t.replace(/[$,\s]/g,"").trim();if(!s)return null;const n=parseFloat(s);return isNaN(n)?null:String(Math.round(n*100))},Noe=t=>{const s=t.replace(/[,\s%]/g,"").trim();if(!s)return null;const n=parseFloat(s);return isNaN(n)?null:String(n)},_oe=async()=>{const t=new Set,s=new Map,[{data:n},{data:a}]=await Promise.all([O.from("z_sis_student_registry").select("student_ref, sis_student_id"),O.from("z_student_accounts").select("student_id")]);return(n||[]).forEach(r=>{r.student_ref&&(t.add(String(r.student_ref).toLowerCase()),s.set(String(r.student_ref).toLowerCase(),r.sis_student_id))}
1298),(a||[]).forEach(r=>t.add(String(r.student_id).toLowerCase())),{refs:t,sisByRef:s}},koe=(t,s,n,a)=>{const r=new Map;return s.map((i,o)=>{const l={};Object.entries(n).forEach(([v,g])=>{g&&i[v]!==void 0&&(l[g]=i[v].trim())});const c=[],u=[];t.fields.forEach(v=>{const g=l[v.key]||"";if(v.required&&!g&&c.push(`${v.label} is required`),!!g){if(v.type==="currency"){const N=woe(g);N===null?c.push(`${v.label}: cannot parse amount "${g}"`):l[v.key]=N}else if(v.type==="date"){const N=joe(g);N?l[v.key]=N:(u.push(`${v.label}: unparseable date "${g}" â left blank`),l[v.key]="")}else if(v.type==="number"){const N=Noe(g);N===null?(u.push(`${v.label}: cannot parse number "${g}" â left blank`),l[v.key]=""):l[v.key]=N}}});let p=null;const m=(l.student_ref||"").toLowerCase();m&&(a.refs.has(m)?(p=a.sisByRef.get(m)||null,u.push(p?`Linked to permanent SIS ID ${p}`:"Record ID matches an existing student â SIS ID will link on import")):u.push("Record ID not found in the student registry â a new student anchor + SIS ID will be created on import. Import the student roster first if this is unexpected."));const x=t.fields.map(v=>(l[v.key]||"").toLowerCase()).join("|");x.replace(/\|/g,"").length>0&&(r.has(x)?c.push(`Exact duplicate of row ${r.get(x)}`):r.set(x,o+1));const h=t.fields.filter(v=>!v.required&&!l[v.key]).length;h>0&&c.length===0&&u.push(`${h} optional field${h===1?"":"s"} blank`);const y=c.length>0?"error":p?"existing":"new";return{row_number:o+1,raw:i,mapped:l,disposition:y,match_student_id:p,errors:c,warnings:u}})},Soe=async(t,s,n,a,r,i="admin")=>{const{data:o,error:l}=await O.from(Pd).insert({filename:s,dataset_type:t.key,uploaded_by:i,status:"validated",column_mapping:n,blocked_columns:a,total_rows:r.length,new_count:r.filter(c=>c.disposition==="new").length,existing_count:r.filter(c=>c.disposition==="existing").length,error_count:r.filter(c=>c.disposition==="error").length}).select("id").single();if(l||!o)return null;for(let c=0;c<r.length;c+=200){const u=r.slice(c,c+200).map(m=>({batch_id:o.id,row_number:m.row_number,raw:m.raw,mapped:m.mapped,disposition:m.disposition,match_student_id:m.match_student_id,errors:m.errors,warnings:m.warnings})),{error:p}=await O.from(d1).insert(u);if(p)return await O.from(Pd).update({status:"cancelled",notes:"Row staging failed"}).eq("id",o.id),null}return o.id},o$=async(t,s)=>{const{data:n,error:a}=await O.rpc("zi_finalize_sis_dataset_import",{p_batch_id:t,p_approved_by:s});return a?{error:a.message}:n!=null&&n.error?{error:n.error}:n},Coe=async()=>{const{data:t}=await O.from("z_sis_cleanup_log").select("*").order("created_at",{ascending:!0});return t||[]},Ea="#800020",Aoe="#D4AF37",Eoe={new:{cls:"bg-emerald-100 text-emerald-700",label:"NEW"},existing:{cls:"bg-blue-100 text-blue-700",label:"LINKED"},error:{cls:"bg-red-100 text-red-700",label:"ERROR â SKIPPED"}},Foe=({dataset:t,onExit:s})=>{const[n,a]=d.useState("upload"),[r,i]=d.useState(""),[o,l]=d.useState(null),[c,u]=d.useState({}),[p,m]=d.useState([]),[x,h]=d.useState(null),[y,v]=d.useState(""),[g,N]=d.useState(!1),[b,f]=d.useState(!1),[j,S]=d.useState(""),[w,_]=d.useState(null),[C,E]=d.useState(""),P=d.useRef(null),F=A=>{if(S(""),!A.name.toLowerCase().endsWith(".csv")){S("Only .csv files are accepted. Export your sheet as CSV first (Excel/Google Sheets â File â Download â CSV).");return}if(A.size>5*1024*1024){S("File exceeds the 5 MB limit. Split the sheet into smaller files.");return}const z=new FileReader;z.onload=()=>{const M=n$(String(z.result||""));if(M.headers.length===0||M.rows.length===0){S("The file appears to be empty or missing a header row.");return}i(A.name),l(M),u(voe(t,M.headers)),a("map")},z.readAsText(A)},I=async()=>{if(o){f(!0);try{let A;if(t.studentPipeline){const z=await a$();A=r$(o.rows,c,z),t.defaultStatus&&(A=A.map(M=>({...M,mapped:{...M.mapped,enrollment_status:M.mapped.enrollment_status||t.defaultStatus}})))}else{const z=await _oe();A=koe(t,o.rows,c,z)}m(A),a("preview")}finally{f(!1)}}},D=async()=>{if(o){f(!0);try{const A=await Soe(t,r,c,o.blockedColumns,p);if(!A){E("Failed to stage the batch. Please retry.");return}h(A),a("approve")}finally{f(!1)}}},L=async()=>
1298{if(!(!x||!y.trim()||!g)){f(!0),E("");try{const A=await o$(x,y.trim());if("error"in A){E(A.error);return}_(A),a("done")}finally{f(!1)}}},V={ok:p.filter(A=>A.disposition!=="error").length,linked:p.filter(A=>A.disposition==="existing").length,errors:p.filter(A=>A.disposition==="error").length},B=["upload","map","preview","approve","done"].indexOf(n);return e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3",children:[e.jsxs("div",{children:[e.jsxs("button",{onClick:s,className:"inline-flex items-center gap-1 text-xs text-gray-500 hover:text-gray-800 mb-1",children:[e.jsx(Je,{size:12})," Back to migration datasets"]}),e.jsxs("h3",{className:"text-lg font-bold text-gray-900",children:[t.label," â Import"]}),e.jsxs("p",{className:"text-xs text-gray-500",children:["Target: ",e.jsx("span",{className:"font-mono",children:t.targetTable})," · ",t.description]})]}),e.jsxs("button",{onClick:()=>i$(t),className:"flex items-center gap-1.5 px-3 py-2 rounded-xl border bg-white text-xs font-semibold text-gray-600 hover:bg-gray-50",children:[e.jsx(us,{size:13})," Download CSV Template"]})]}),e.jsx("div",{className:"flex items-center gap-1 text-[10px] font-bold uppercase tracking-wider",children:["Upload & Validate Format","Map Columns","Validation & Preview","Approval Gate","Imported"].map((A,z)=>e.jsxs(re.Fragment,{children:[e.jsxs("span",{className:`px-2.5 py-1 rounded-full ${z===B?"text-white":z<B?"bg-emerald-100 text-emerald-700":"bg-gray-100 text-gray-400"}`,style:z===B?{background:Ea}:{},children:[z+1,". ",A]}),z<4&&e.jsx(Vt,{size:11,className:"text-gray-300 shrink-0"})]},A))}),n==="upload"&&e.jsxs("div",{className:"bg-white rounded-xl border p-6 space-y-4",children:[e.jsxs("div",{onClick:()=>{var A;return(A=P.current)==null?void 0:A.click()},onDragOver:A=>A.preventDefault(),onDrop:A=>{var M;A.preventDefault();const z=(M=A.dataTransfer.files)==null?void 0:M[0];z&&F(z)},className:"border-2 border-dashed rounded-xl p-10 text-center cursor-pointer hover:bg-gray-50 transition-colors",style:{borderColor:`${Ea}40`},children:[e.jsx(Ri,{size:32,className:"mx-auto mb-3",style:{color:Ea}}),e.jsx("p",{className:"text-sm font-semibold text-gray-800",children:"Drop your CSV here, or click to browse"}),e.jsx("p",{className:"text-xs text-gray-500 mt-1",children:".csv only · header row required · max 5 MB"}),e.jsx("input",{ref:P,type:"file",accept:".csv",className:"hidden",onChange:A=>{var M;const z=(M=A.target.files)==null?void 0:M[0];z&&F(z),A.target.value=""}})]}),j&&e.jsxs("div",{className:"p-3 rounded-xl bg-red-50 text-red-700 text-xs flex items-center gap-2",children:[e.jsx(kt,{size:13})," ",j]}),e.jsxs("div",{className:"p-3 rounded-xl text-[11px] text-gray-600 flex items-start gap-2",style:{background:`${Aoe}15`},children:[e.jsx(Ie,{size:14,className:"shrink-0 mt-0.5",style:{color:Ea}}),e.jsxs("span",{children:[e.jsx("strong",{children:"PII protection:"})," columns whose headers look like SSN, tax ID, date of birth, driver's license, passport, or password are ",e.jsx("strong",{children:"stripped in your browser"})," at parse time and never stored anywhere. Nothing is imported until you approve the final step."]})]})]}),n==="map"&&o&&e.jsxs("div",{className:"bg-white rounded-xl border p-6 space-y-4",children:[e.jsxs("div",{className:"flex items-center gap-2 text-xs text-gray-600",children:[e.jsx(Kt,{size:14,style:{color:Ea}}),e.jsx("span",{className:"font-semibold",children:r})," · ",o.rows.length," data rows · ",o.headers.length," columns"]}),o.blockedColumns.length>0&&e.jsxs("div",{className:"p-3 rounded-xl bg-amber-50 text-amber-800 text-xs flex items-start gap-2",children:[e.jsx($b,{size:14,className:"shrink-0 mt-0.5"}),e.jsxs("span",{children:[e.jsxs("strong",{children:[o.blockedColumns.length," PII column",o.blockedColumns.length===1?"":"s"," stripped and never stored:"]})," ",o.blockedColumns.join(", ")]})]}),e.jsx("div",{className:"overflow-x-auto",children:e.jsxs("table",{className:"w-full text-sm",children:[e.jsx("thead",{children:e.jsx("tr",{className:"border-b",style:{background:`${Ea}05`},children:["Your Column","Sample Value","Maps to SIS Field"].map(A=>e.jsx("th",{className:"text-left px-3 py-2 text-[10px] uppercase tracking-wider text-gray-500",children:A},A))})}),e.jsx("tbody",{className:"divide-y divide-gray-50",children:o.headers.map(A=>{var z;return e.jsxs("tr",{children:[e.jsx("td",{className:"px-3 py-2 font-mono text-xs text-gray-800",children:A}),e.jsx("td",{className:"px-3 py-2 text-xs text-gray-400 max-w-[180px] truncate",children:((z=o.rows[0])==null?void 0:z[A])||"â"}),e.jsx("td",{className:"px-3 py-2",children:e.jsxs("select",{value:c[A]||"",onChange:M=>u({...c,[A]:M.target.value}),className:"border rounded-lg px-2 py-1.5 text-xs bg-white focus:outline-none focus:border-[#800020]",children:[e.jsx("option",{value:"",children:"â skip this column â"}),t.fields.map(M=>e.jsxs("option",{value:M.key,disabled:Object.entries(c).some(([R,T])=>T===M.key&&R!==A),children:[M.label,M.required?" *":""]},M.key))]})})]},A)})})]})}),t.fields.filter(A=>A.required&&!Object.values(c).includes(A.key)).map(A=>e.jsxs("div",{className:"p-2.5 rounded-lg bg-red-50 text-red-700 text-xs flex items-center gap-2",children:[e.jsx(ve,{size:12})," Required field ",e.jsx("strong",{children:A.label}
1298)," is not mapped â map a column or the import cannot proceed."]},A.key)),e.jsxs("div",{className:"flex justify-between",children:[e.jsx("button",{onClick:()=>a("upload"),className:"px-4 py-2 rounded-xl border text-xs font-semibold text-gray-600 hover:bg-gray-50",children:"Back"}),e.jsxs("button",{onClick:I,disabled:b||t.fields.some(A=>A.required&&!Object.values(c).includes(A.key)),className:"flex items-center gap-2 px-5 py-2.5 rounded-xl text-xs font-bold text-white disabled:opacity-40",style:{background:Ea},children:[b?e.jsx(Be,{size:13,className:"animate-spin"}):e.jsx(Ie,{size:13}),"Run Validation & Duplicate Check"]})]})]}),n==="preview"&&e.jsxs("div",{className:"bg-white rounded-xl border p-6 space-y-4",children:[e.jsx("div",{className:"grid grid-cols-3 gap-3",children:[{label:"Rows Ready to Import",value:V.ok,color:"#10B981"},{label:"Linked to Existing SIS IDs",value:V.linked,color:"#3B82F6"},{label:"Errors (will be skipped)",value:V.errors,color:V.errors>0?"#EF4444":"#9CA3AF"}].map(A=>e.jsxs("div",{className:"p-3 rounded-xl border bg-gray-50",children:[e.jsx("p",{className:"text-[10px] uppercase tracking-wider text-gray-400",children:A.label}),e.jsx("p",{className:"font-mono text-xl font-bold",style:{color:A.color},children:A.value})]},A.label))}),e.jsx("div",{className:"overflow-x-auto max-h-[420px] overflow-y-auto border rounded-xl",children:e.jsxs("table",{className:"w-full text-sm min-w-[760px]",children:[e.jsx("thead",{className:"sticky top-0 bg-white",children:e.jsx("tr",{className:"border-b",style:{background:`${Ea}05`},children:["Row","Disposition","Record ID / Key","Mapped Data","Validation Notes"].map(A=>e.jsx("th",{className:"text-left px-3 py-2 text-[10px] uppercase tracking-wider text-gray-500",children:A},A))})}),e.jsx("tbody",{className:"divide-y divide-gray-50",children:p.map(A=>{const z=Eoe[A.disposition];return e.jsxs("tr",{className:A.disposition==="error"?"bg-red-50/40":"",children:[e.jsx("td",{className:"px-3 py-2 text-xs text-gray-400 font-mono",children:A.row_number}),e.jsx("td",{className:"px-3 py-2",children:e.jsx("span",{className:`px-2 py-0.5 rounded-full text-[9px] font-bold ${z.cls}`,children:z.label})}),e.jsxs("td",{className:"px-3 py-2 text-xs font-mono text-gray-700",children:[A.mapped.student_ref||A.mapped.student_id||A.mapped.program||"â",A.match_student_id&&e.jsxs("span",{className:"block text-[9px] text-blue-600",children:[e.jsx(Xs,{size:9,className:"inline"})," ",A.match_student_id]})]}),e.jsx("td",{className:"px-3 py-2 text-[10px] text-gray-500 max-w-[280px] truncate",title:Object.entries(A.mapped).map(([M,R])=>`${M}: ${R}`).join(" · "),children:Object.entries(A.mapped).filter(([,M])=>M).map(([M,R])=>`${M}=${R}`).join(" · ")||"â"}),e.jsxs("td",{className:"px-3 py-2 text-[10px] max-w-[260px]",children:[A.errors.map((M,R)=>e.jsxs("p",{className:"text-red-600 flex items-start gap-1",children:[e.jsx(kt,{size:9,className:"shrink-0 mt-0.5"})," ",M]},R)),A.warnings.map((M,R)=>e.jsxs("p",{className:"text-amber-600 flex items-start gap-1",children:[e.jsx(ve,{size:9,className:"shrink-0 mt-0.5"})," ",M]},R)),A.errors.length===0&&A.warnings.length===0&&e.jsxs("span",{className:"text-emerald-600 flex items-center gap-1",children:[e.jsx(pt,{size:9})," Clean"]})]})]},A.row_number)})})]})}),C&&e.jsx("div",{className:"p-3 rounded-xl bg-red-50 text-red-700 text-xs",children:C}),e.jsxs("div",{className:"flex justify-between",children:[e.jsx("button",{onClick:()=>a("map"),className:"px-4 py-2 rounded-xl border text-xs font-semibold text-gray-600 hover:bg-gray-50",children:"Back to Mapping"}),e.jsxs("button",{onClick:D,disabled:b||V.ok===0,className:"flex items-center gap-2 px-5 py-2.5 rounded-xl text-xs font-bold text-white disabled:opacity-40",style:{background:Ea},children:[b?e.jsx(Be,{size:13,className:"animate-spin"}):e.jsx(Vt,{size:13}),"Stage Batch & Continue to Approval"]})]})]}),n==="approve"&&e.jsxs("div",{className:"bg-white rounded-xl border-2 p-6 space-y-4",style:{borderColor:`${Ea}30`},children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Ie,{size:18,style:{color:Ea}}),e.jsx("h4",{className:"text-sm font-bold text-gray-900",children:"Final Approval Gate â nothing has been imported yet"})]}),e.jsxs("p",{className:"text-xs text-gray-600",children:["The batch is staged (batch ",e.jsxs("span",{className:"font-mono",children:[x==null?void 0:x.slice(0,8),"â¦"]}),") with",e.jsxs("strong",{children:[" ",V.ok," rows ready"]}),", ",V.linked," linked to existing SIS IDs, and ",V.errors," error rows that will be skipped. Approving runs the gated",e.jsx("span",{className:"font-mono",children:" zi_finalize_sis_dataset_import"})," RPC, which refuses any batch not in ",e.jsx("span",{className:"font-mono",children:"val
1298idated"})," status and records the approver and timestamp."]}),e.jsxs("label",{className:"flex items-start gap-2 text-xs text-gray-700",children:[e.jsx("input",{type:"checkbox",checked:g,onChange:A=>N(A.target.checked),className:"mt-0.5"}),e.jsxs("span",{children:["I reviewed the column mapping, validation results, and import preview for ",e.jsx("strong",{children:t.label})," and approve this import."]})]}),e.jsx("input",{value:y,onChange:A=>v(A.target.value),placeholder:"Type your name to approve (required)",className:"w-full max-w-sm border rounded-xl px-3 py-2.5 text-sm focus:outline-none focus:border-[#800020]"}),C&&e.jsx("div",{className:"p-3 rounded-xl bg-red-50 text-red-700 text-xs",children:C}),e.jsxs("div",{className:"flex gap-3",children:[e.jsx("button",{onClick:s,className:"px-4 py-2.5 rounded-xl border text-xs font-semibold text-gray-600 hover:bg-gray-50",children:"Cancel â import nothing"}),e.jsxs("button",{onClick:L,disabled:b||!y.trim()||!g,className:"flex items-center gap-2 px-6 py-2.5 rounded-xl text-xs font-bold text-white disabled:opacity-40",style:{background:`linear-gradient(135deg, ${Ea}, #5c0017)`},children:[b?e.jsx(Be,{size:13,className:"animate-spin"}):e.jsx(pt,{size:13}),"Approve & Import ",V.ok," Rows"]})]})]}),n==="done"&&w&&e.jsxs("div",{className:"bg-white rounded-xl border p-8 text-center space-y-3",children:[e.jsx(pt,{size:40,className:"mx-auto text-emerald-500"}),e.jsxs("h4",{className:"text-lg font-bold text-gray-900",children:[t.label," imported"]}),e.jsxs("p",{className:"text-sm text-gray-600",children:[e.jsx("strong",{children:w.imported})," rows imported",w.linked>0&&e.jsxs(e.Fragment,{children:[" · ",e.jsx("strong",{children:w.linked})," linked to existing records"]}),w.skipped>0&&e.jsxs(e.Fragment,{children:[" · ",e.jsx("strong",{children:w.skipped})," skipped (errors)"]})]}),e.jsx("p",{className:"text-xs text-gray-400",children:"SIS Student IDs were assigned/linked automatically. Approval recorded on the batch."}),e.jsx("button",{onClick:s,className:"px-5 py-2.5 rounded-xl text-xs font-bold text-white",style:{background:Ea},children:"Back to Migration Hub"})]})]})},wj="#800020",Toe="#D4AF37",Poe=({onImported:t})=>{const[s,n]=d.useState([]),[a,r]=d.useState(!0),[i,o]=d.useState(null),[l,c]=d.useState({}),[u,p]=d.useState(""),[m,x]=d.useState(null),[h,y]=d.useState({}),v=d.useCallback(async()=>{r(!0);const{data:f}=await O.from(Pd).select("id, filename, dataset_type, status, total_rows, new_count, existing_count, error_count, notes, created_at").eq("status","validated").order("created_at",{ascending:!0});n(f||[]),r(!1)},[]);d.useEffect(()=>{v()},[v]);const g=async f=>{if(i===f){o(null);return}if(o(f),!l[f]){const{data:j}=await O.from(d1).select("row_number, mapped, disposition, warnings").eq("batch_id",f).order("row_number");c(S=>({...S,[f]:j||[]}))}},N=async f=>{if(!u.trim()){y(S=>({...S,[f]:"Enter the approver name first."}));return}x(f),y(S=>({...S,[f]:""}));const j=await o$(f,u.trim());"error"in j?y(S=>({...S,[f]:`Import refused: ${j.error}`})):(y(S=>({...S,[f]:`Imported ${j.imported} records (${j.skipped} skipped).`})),await v(),t==null||t()),x(null)},b=async f=>{x(f),await O.from(Pd).update({status:"cancelled",notes:"Rejected before import â staged rows retained for audit."}).eq("id",f),await v(),x(null)};return a?e.jsxs("div",{className:"p-4 rounded-xl border bg-white flex items-center gap-2 text-xs text-gray-500",children:[e.jsx(de,{size:13,className:"animate-spin"})," Loading approval queueâ¦"]}):s.length===0?null:e.jsxs("div",{className:"p-4 rounded-xl border-2 bg-white",style:{borderColor:`${Toe}60`},children:[e.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[e.jsx(Ie,{size:15,style:{color:wj}}),e.jsx("h3",{className:"text-sm font-bold text-gray-900",children:"Staged Batches â Pending Your Approval"}),e.jsxs("span",{className:"px-2 py-0.5 rounded-full text-[9px] font-bold bg-amber-100 text-amber-700",children:[s.length," AWAITING APPROVAL · NOTHING IMPORTS UNTIL APPROVED"]})]}),e.jsx("p",{className:"text-[11px] text-gray-500 mb-3",children:"Review the full record preview and per-row validation warnings, then approve or reject each batch. Approval runs the gated production import and links SIS Student IDs where applicable."}),e.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[e.jsx("label",{className:"text-[10px] font-semibold text-gray-600 whitespace-nowrap",children:"Approver name:"}),e.jsx("input",{value:u,onChange:f=>p(f.target.value),placeholder:"e.g. D. Admin",className:"border rounded-lg px-3 py-1.5 text-xs w-56"})]}),e.jsx("div",{className:"space-y-3",children:s.map(f=>{const j=yoe(f.dataset_type),S=l[f.id]||[],w=S.length>0?Object.keys(S[0].mapped):[];return e.jsxs("div",{className:"border rounded-xl overflow-hidden",children:[e.jsxs("div",{className:"flex items-center justify-between gap-2 px-4 py-3 bg-gray-50",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"text-xs font-bold text-gray-900",children:(j==null?void 0:j.label)||f.dataset_type}),e.jsx("p",{className:"text-[10px] text-gray-500 font-mono truncate",children:f.filename}),e.jsxs("p",{className:"text-[10px] text-gray-500",children:[f.total_rows," rows · ",f.new_count," new · ",f.existing_count," linked · ",f.error_count," errors"]})]}),e.jsxs("div",{className:"flex items-center gap-2 shrink-0",children:[e.jsxs("button",{onClick:()=>g(f.id),className:"flex items-center gap-1 px-3 py-1.5 rounded-lg border text-[10px] font-semibold text-gray-600 hover:bg-white",children:[i===f.id?e.jsx(Od,{size:11}):e.jsx(Gt,{size:11})," Preview"]}),e.jsxs("button",{onClick:()=>b(f.id),disabled:m===f.id,className:"flex items-center gap-1 px-3 py-1.5 rounded-lg border border-red-200 text-[10px] font-semibold text-red-600 hover:bg-red-50 disabled:opacity-50",children:[e.jsx(kt,{size:11})," Reject"]}),e.jsxs("button",{onClick:()=>N(f.id),disabled:m===f.id,className:"flex items-center gap-1 px-3 py-1.5 rounded-lg text-[10px] font-bold text-white disabled:opacity-50",style:{background:wj},children:[m===f.id?e.jsx(de,{size:11,className:"animate-spin"}):e.jsx(pt,{size:11})," Approve & Import"]})]})]}),h[f.id]&&e.jsx("p",{className:`px-4 py-2 text-[10px] font-semibold ${h[f.id].startsWith("Imported")?"text-emerald-700 bg-emerald-50":"text-red-600 bg-red-50"}`,children:h[f.id]}),f.notes&&e.jsx("p",{className:"px-4 py-2 text-[10px] text-gray-500 border-t bg-white",children:f.notes}),i===f.id&&e.jsx("div",{className:"border-t overflow-x-auto max-h-80 overflow-y-auto",children:e.jsxs("table",{className:"w-full text-[10px] min-w-[760px]",children:[e.jsx("thead",{className:"sticky top-0 bg-white",children:e.jsxs("tr",{className:"border-b",style:{background:`${wj}05`},children:[e.jsx("th",{className:"text-left px-2 py-1.5 text-gray-500",children:"#"}),w.map(_=>e.jsx("th",{className:"text-left px-2 py-1.5 text-gray-500 uppercase tracking-wider whitespace-nowrap",children:_.replace(/_/g," ")},_)),e.jsx("th",{className:"text-left px-2 py-1.5 text-gray-500",children:"Warnings"})]})}),e.jsx("tbody",{className:"divide-y divide-gray-50",children:S.map(_=>e.jsxs("tr",{className:"hover:bg-gray-50 align-top",children:[e.jsx("td",{className:"px-2 py-1.5 font-mono text-gray-400",children:_.row_number}),w.map(C=>e.jsx("td",{className:"px-2 py-1.5 text-gray-700 max-w-[200px]",children:_.mapped[C]||e.jsx("span",{className:"text-gray-300",children:"â"})},C)),e.jsx("td",{className:"px-2 py-1.5 max-w-[240px]",children:(_.warnings||[]).map((C,E)=>e.jsxs("p",{className:"flex items-start gap-1 text-amber-700",children:[e.jsx(ve,{size:9,className:"shrink-0 mt-0.5"})," ",C]},E))})]},_.row_number))})]})})]},f.id)})})]})},Cg="#800020",Doe="#D4AF37",Roe={sis_core:"SIS Core",financial:"Financial",academic:"Academic",compliance:"Compliance",reporting:"Reporting",cleanup:"Cleanup"},Ioe=()=>
1298{const[t,s]=d.useState(null),[n,a]=d.useState([]),[r,i]=d.useState(!1),[o,l]=d.useState(""),[c,u]=d.useState(!0),p=async()=>{const{data:x}=await O.from("z_sis_workflow_test_runs").select("*").order("started_at",{ascending:!1}).limit(1),h=(x==null?void 0:x[0])??null;if(s(h),h){const{data:y}=await O.from("z_sis_workflow_test_results").select("*").eq("run_id",h.id).order("seq");a(y||[])}};d.useEffect(()=>{p()},[]);const m=async()=>{i(!0),l("");try{const{error:x}=await O.rpc("zi_run_workflow_test",{p_triggered_by:"admin-console"});x&&l(x.message),await p()}catch(x){l((x==null?void 0:x.message)||"Run failed")}finally{i(!1)}};return e.jsxs("div",{className:"bg-white rounded-xl border",children:[e.jsxs("div",{className:"flex items-center justify-between px-5 py-4",children:[e.jsxs("button",{onClick:()=>u(!c),className:"flex items-center gap-2 text-left",children:[e.jsx(Qx,{size:15,style:{color:Cg}}),e.jsx("span",{className:"text-sm font-bold text-gray-900",children:"Pre-Production Workflow Test Console"}),t&&e.jsxs("span",{className:`px-2 py-0.5 rounded-full text-[9px] font-bold ${t.failed===0?"bg-emerald-100 text-emerald-700":"bg-red-100 text-red-700"}`,children:["LAST RUN: ",t.passed,"/",t.total_checks," PASSED",t.residue_ok?" · ZERO RESIDUE":""]})]}),e.jsxs("button",{onClick:m,disabled:r,className:"flex items-center gap-1.5 px-4 py-2 rounded-lg text-[11px] font-bold text-white disabled:opacity-60",style:{background:Cg},children:[r?e.jsx(de,{size:13,className:"animate-spin"}):e.jsx(_y,{size:13}),r?"Running E2E Suiteâ¦":"Run Workflow Test Suite"]})]}),c&&e.jsxs("div",{className:"px-5 pb-5 space-y-3",children:[e.jsxs("p",{className:"text-[11px] text-gray-500",children:["Executes the full operational chain with a single controlled test record (",e.jsx("span",{className:"font-mono",children:"UAT-WF-001"}),"): SIS ID minting â roster/enrollment â ledger/payments/awards (SIS auto-stamping) â attendance/clock hours/grades/SAP â compliance documents + review â RLS/audit enforcement â reporting reconciliation â import approval gate. Every test row is archived (restorable) and purged in the same transaction â dashboards stay at the production baseline. No production imports run; Tier-1 staged batches remain approval-gated."]}),o&&e.jsx("p",{className:"text-[11px] text-red-600 font-semibold",children:o}),n.length>0&&e.jsx("div",{className:"overflow-x-auto border rounded-xl",children:e.jsxs("table",{className:"w-full text-sm min-w-[760px]",children:[e.jsx("thead",{children:e.jsx("tr",{className:"border-b",style:{background:`${Cg}05`},children:["#","System","Check","Result","Detail"].map(x=>e.jsx("th",{className:"text-left px-3 py-2 text-[10px] uppercase tracking-wider text-gray-500 whitespace-nowrap",children:x},x))})}),e.jsx("tbody",{className:"divide-y divide-gray-50",children:n.map(x=>e.jsxs("tr",{className:"hover:bg-gray-50",children:[e.jsx("td",{className:"px-3 py-2 font-mono text-[10px] text-gray-400",children:x.seq}),e.jsx("td",{className:"px-3 py-2",children:e.jsx("span",{className:"px-2 py-0.5 rounded-full text-[9px] font-bold",style:{background:`${Doe}20`,color:Cg},children:Roe[x.system]||x.system})}),e.jsx("td",{className:"px-3 py-2 text-[11px] font-semibold text-gray-800",children:x.check_label}),e.jsx("td",{className:"px-3 py-2",children:x.status==="pass"?e.jsxs("span",{className:"inline-flex items-center gap-1 text-[10px] font-bold text-emerald-600",children:[e.jsx(pt,{size:12})," PASS"]}):e.jsxs("span",{className:"inline-flex items-center gap-1 text-[10px] font-bold text-red-600",children:[e.jsx(kt,{size:12})," FAIL"]})}),e.jsx("td",{className:"px-3 py-2 text-[10px] text-gray-500 max-w-[320px]",children:x.detail})]},x.id))})]})}),e.jsxs("p",{className:"flex items-center gap-1.5 text-[10px] text-gray-500",children:[e.jsx(Ie,{size:11,className:"text-emerald-600"}),"Controlled test records only â self-cleaning, fully audit-logged in z_sis_cleanup_log, payment rails untouched."]})]})]})},tr="#800020",a4="#D4AF37",r4={confirmed_test:{cls:"bg-purple-100 text-purple-700",label:"CONFIRMED TEST"},demo_seed:{cls:"bg-amber-100 text-amber-700",label:"DEMO SEED"},preserved_production:{cls:"bg-emerald-100 text-emerald-700",label:"PRODUCTION"},preserved_dependency:{cls:"bg-blue-100 text-blue-700",label:"DEPENDENCY"}},i4={quarantined_deleted:{cls:"text-red-600",icon:e.jsx(va,{size:11}),label:"Quarantined + removed (restorable)"},archived:{cls:"text-amber-600",icon:e.jsx(RP,{size:11}),label:"Archived (ID retired)"},preserved:{cls:"text-emerald-600",icon:e.jsx(Xe,{size:11}),label:"Preserved"},reported:{cls:"text-gray-500",icon:e.jsx(mn,{size:11}),label:"Reported"}},$oe=()=>
1298{const[t,s]=d.useState("hub"),[n,a]=d.useState(null),[r,i]=d.useState([]),[o,l]=d.useState(!0);if(d.useEffect(()=>{Coe().then(i)},[t]),t==="wizard"&&n)return e.jsx(Foe,{dataset:n,onExit:()=>{s("hub"),a(null)}});const c=r.filter(p=>p.action==="quarantined_deleted").reduce((p,m)=>p+m.row_count,0),u=r.filter(p=>p.action==="preserved").reduce((p,m)=>p+m.row_count,0);return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"p-5 rounded-xl text-white",style:{background:`linear-gradient(135deg, ${tr}, #5c0017)`},children:[e.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[e.jsx($i,{size:16,style:{color:a4}}),e.jsx("h3",{className:"text-sm font-bold",children:"SIS Production Activation â Secure Migration"})]}),e.jsx("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-3 mt-3",children:[{label:"Phase 1 · Cleanup",status:"COMPLETE",detail:`${c} test rows quarantined · ${u} production rows preserved`},{label:"Phase 2 · Templates",status:"READY",detail:`${vN.length} secure CSV templates`},{label:"Phase 3 · Validation",status:"GATED",detail:"Runs per upload before preview"},{label:"Phase 4 · Import",status:"APPROVAL-GATED",detail:"Refused until you approve"}].map(p=>e.jsxs("div",{className:"p-3 rounded-lg bg-white/10 border border-white/15",children:[e.jsx("p",{className:"text-[9px] uppercase tracking-wider text-white/60",children:p.label}),e.jsx("p",{className:"text-xs font-bold",style:{color:a4},children:p.status}),e.jsx("p",{className:"text-[9px] text-white/70 mt-0.5",children:p.detail})]},p.label))})]}),e.jsxs("div",{className:"bg-white rounded-xl border",children:[e.jsxs("button",{onClick:()=>l(!o),className:"w-full flex items-center justify-between px-5 py-4",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(mn,{size:15,style:{color:tr}}),e.jsx("span",{className:"text-sm font-bold text-gray-900",children:"Phase 1 â System Cleanup Report"}),e.jsxs("span",{className:"px-2 py-0.5 rounded-full text-[9px] font-bold bg-emerald-100 text-emerald-700",children:[r.length," DECISIONS LOGGED · APPEND-ONLY"]})]}),e.jsx("span",{className:"text-xs text-gray-400",children:o?"Hide":"Show"})]}),o&&e.jsxs("div",{className:"px-5 pb-5 space-y-3",children:[e.jsxs("p",{className:"text-[11px] text-gray-500",children:["Every identified record and the action taken. Removed rows were snapshotted to",e.jsx("span",{className:"font-mono",children:" z_sis_demo_archive"})," first (fully restorable). Registry SIS IDs are permanent â diagnostic entries were archived, never deleted, and their IDs are retired."]}),e.jsx("div",{className:"overflow-x-auto border rounded-xl",children:e.jsxs("table",{className:"w-full text-sm min-w-[860px]",children:[e.jsx("thead",{children:e.jsx("tr",{className:"border-b",style:{background:`${tr}05`},children:["Table","Record(s)","Rows","Classification","Action","Reason"].map(p=>e.jsx("th",{className:"text-left px-3 py-2 text-[10px] uppercase tracking-wider text-gray-500 whitespace-nowrap",children:p},p))})}),e.jsx("tbody",{className:"divide-y divide-gray-50",children:r.map(p=>{const m=r4[p.classification]||r4.preserved_production,x=i4[p.action]||i4.reported;return e.jsxs("tr",{className:"hover:bg-gray-50",children:[e.jsx("td",{className:"px-3 py-2 font-mono text-[10px] text-gray-600",children:p.table_name}),e.jsxs("td",{className:"px-3 py-2 text-xs",children:[e.jsx("p",{className:"font-mono text-[10px]",style:{color:tr},children:p.record_ref||"â"}),e.jsx("p",{className:"text-[10px] text-gray-500",children:p.record_label})]}),e.jsx("td",{className:"px-3 py-2 font-mono text-xs text-gray-700",children:p.row_count}),e.jsx("td",{className:"px-3 py-2",children:e.jsx("span",{className:`px-2 py-0.5 rounded-full text-[9px] font-bold ${m.cls}`,children:m.label})}),e.jsx("td",{className:"px-3 py-2",children:e.jsxs("span",{className:`inline-flex items-center gap-1 text-[10px] font-semibold ${x.cls}`,children:[x.icon," ",x.label]})}),e.jsx("td",{className:"px-3 py-2 text-[10px] text-gray-500 max-w-[280px]",children:p.reason})]},p.id)})})]})})]})]}),e.jsx(Ioe,{}),e.jsx(Poe,{}),e.jsxs("div",{className:"p-4 rounded-xl border bg-white",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[e.jsx(mn,{size:15,style:{color:tr}}),e.jsx("h3",{className:"text-sm font-bold text-gray-900",children:"Recommended Migration Sequence"}),e.jsx("span",{className:"px-2 py-0.5 rounded-full text-[9px] font-bold bg-blue-100 text-blue-700",children:"IMPORT IN THIS ORDER"})]}),e.jsx("ol",{className:"text-[11px] text-gray-600 space-y-1.5 list-none",children:[["1 · Foundation Data","Tuition & Fees by Program â Curriculum â Schedules (programs, codes, fee schedules, academic calendar/cohort dates). No student dependency."],["2 · Student Records","Current Roster â Historical Students â Graduates â
1298 Enrollment Records. Creates/links every permanent SIS Student ID â all later tiers depend on this."],["3 · Financial Records","Student Ledgers â Tuition Accounts (incl. payment-plan contracts) â Scholarships/Grants/Loans â Financial Aid. SIS IDs auto-stamped by triggers."],["4 · Academic Records","Clock Hours (attendance + hours) â SAP Reports by Period. Rows resolve to SIS-anchored student records."],["5 · Compliance Documents","Student Documents â use Document Type for applications, enrollment agreements, authorization/acknowledgment forms, ISIR, loan counseling, award documents, and student files. Upload files to the private student-documents bucket; import metadata here."],["6 · Professional Records","Graduation/alumni via Graduates dataset; externships, events, conferences, awards, and community recognition via Enrollment Records (type + notes) or Student Documents until dedicated tables are provisioned."]].map(([p,m])=>e.jsxs("li",{className:"flex items-start gap-2",children:[e.jsx("span",{className:"font-bold whitespace-nowrap",style:{color:tr},children:p}),e.jsx("span",{children:m})]},p))}),e.jsxs("p",{className:"text-[10px] text-gray-500 mt-2 border-t pt-2",children:["For every dataset the wizard reports: upload status â validation result â duplicate report â missing-information report â full record preview â ",e.jsx("strong",{children:"explicit approval required"})," â final import confirmation. Nothing imports until you approve mapping + validation for that dataset."]})]}),e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[e.jsx(Lb,{size:15,style:{color:tr}}),e.jsx("h3",{className:"text-sm font-bold text-gray-900",children:"Phase 2 â Secure Import Templates & Mapping"})]}),e.jsx("p",{className:"text-[11px] text-gray-500 mb-4",children:"Dashboard production reset complete (Jul 21 2026): all demo/test rows are quarantined out of dashboard calculations (restorable), dashboards are unchanged and admin-only, and every metric now computes from a verified zero production baseline. Each upload runs Phase 3 validation (format, required fields, duplicates, missing data, SIS ID mapping) and shows a full preview; Phase 4 import only runs after your explicit approval."}),e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-3",children:vN.map((p,m)=>e.jsxs("div",{className:"p-4 rounded-xl border bg-white flex flex-col",children:[e.jsxs("div",{className:"flex items-start justify-between gap-2",children:[e.jsxs("div",{children:[e.jsxs("p",{className:"text-[9px] font-bold uppercase tracking-wider text-gray-400",children:["Dataset ",m+1]}),e.jsx("h4",{className:"text-sm font-bold text-gray-900",children:p.label})]}),p.studentPipeline&&e.jsx("span",{className:"px-2 py-0.5 rounded-full text-[8px] font-bold bg-blue-100 text-blue-700 whitespace-nowrap",children:"SIS ID SOURCE"})]}),e.jsx("p",{className:"text-[10px] text-gray-500 mt-1 flex-1",children:p.description}),e.jsxs("p",{className:"text-[9px] font-mono text-gray-400 mt-2",children:["â ",p.targetTable]}),e.jsxs("div",{className:"flex gap-2 mt-3",children:[e.jsxs("button",{onClick:()=>i$(p),className:"flex items-center gap-1 px-3 py-2 rounded-lg border text-[10px] font-semibold text-gray-600 hover:bg-gray-50",children:[e.jsx(us,{size:11})," Template"]}),e.jsxs("button",{onClick:()=>{a(p),s("wizard")},className:"flex items-center gap-1 px-3 py-2 rounded-lg text-[10px] font-bold text-white flex-1 justify-center",style:{background:tr},children:[e.jsx(Ri,{size:11})," Start Gated Import"]})]})]},p.key))})]}),e.jsxs("div",{className:"p-4 rounded-xl border-2",style:{borderColor:`${tr}20`,background:`${tr}05`},children:[e.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[e.jsx(Ie,{size:14,style:{color:tr}}),e.jsx("span",{className:"text-xs font-bold",style:{color:tr},children:"Privacy & Scope"})]}),e.jsxs("ul",{className:"text-[10px] text-gray-600 leading-relaxed space-y-1",children:[e.jsxs("li",{className:"flex items-start gap-1.5",children:[e.jsx(pt,{size:11,className:"text-emerald-600 shrink-0 mt-0.5"}),"All student, financial aid, and compliance records land in RLS-protected tables rendered only inside admin-guarded dashboards (AdminRouteGuard). Nothing appears on public pages."]}),e.jsxs("li",{className:"flex items-start gap-1.5",children:[e.jsx(pt,{size:11,className:"text-emerald-600 shrink-0 mt-0.5"}),"SSN / DOB / tax-ID / license columns are stripped client-side at parse time and never stored;
1298 SIS Student IDs are derived from an internal counter, never from PII."]}),e.jsxs("li",{className:"flex items-start gap-1.5",children:[e.jsx(pt,{size:11,className:"text-emerald-600 shrink-0 mt-0.5"}),"Payment rails untouched: Cosmetics, Zora's Salon, Med Spa, Foundation, and POS are unmodified; imports are additive rows on the isolated Institute tables only."]}),e.jsxs("li",{className:"flex items-start gap-1.5",children:[e.jsx(ve,{size:11,className:"text-amber-500 shrink-0 mt-0.5"}),"Cleanup is reversible: every removed demo row is snapshotted in",e.jsx("span",{className:"font-mono",children:" z_sis_demo_archive"}),"; the report log is append-only."]})]})]})]})},id="z_financial_aid_cases",l$="z_financial_aid_case_events",tb=[{key:"new_interest",label:"New Aid Interest",admissionsSummary:"Interested",color:"#0369A1",bg:"#E0F2FE",description:"Interest signalled (inquiry / checkbox). No aid process has begun."},{key:"intake_started",label:"Intake Started",admissionsSummary:"In Progress",color:"#7C3AED",bg:"#EDE9FE",description:"Staff opened the case and began collecting intake information."},{key:"fafsa_process",label:"FAFSA / Funding Process",admissionsSummary:"In Progress",color:"#4F46E5",bg:"#E0E7FF",description:"FAFSA or alternative funding application underway."},{key:"documents_needed",label:"Documents Needed",admissionsSummary:"Waiting on Student",color:"#B45309",bg:"#FEF3C7",description:"Outstanding documents or tasks required from the student.",waitingOnStudent:!0},{key:"awaiting_student",label:"Awaiting Student",admissionsSummary:"Waiting on Student",color:"#92400E",bg:"#FEF3C7",description:"Waiting on a student response, signature or appointment.",waitingOnStudent:!0},{key:"staff_review",label:"Staff Review",admissionsSummary:"Staff Review",color:"#BE185D",bg:"#FCE7F3",description:"Sitting with Financial Aid staff for review or determination."},{key:"scholarship_pending",label:"Scholarship Pending",admissionsSummary:"Staff Review",color:"#A16207",bg:"#FEF9C3",description:"Foundation or institutional scholarship awaiting staff verification."},{key:"funding_plan_ready",label:"Funding Plan Ready",admissionsSummary:"In Progress",color:"#047857",bg:"#D1FAE5",description:"Funding plan drafted â not yet cleared for enrollment."},{key:"financially_ready",label:"Financially Ready",admissionsSummary:"Financially Ready",color:"#065F46",bg:"#A7F3D0",description:"Financial clearance confirmed by staff."},{key:"blocked",label:"Blocked / Needs Attention",admissionsSummary:"Needs Attention",color:"#B91C1C",bg:"#FEE2E2",description:"Something is preventing progress and needs staff attention."},{key:"closed",label:"Closed",admissionsSummary:"Closed",color:"#4B5563",bg:"#F3F4F6",description:"Case closed â no further aid work expected.",terminal:!0}],sb=t=>tb.find(s=>s.key===t)||tb[0],zoe=t=>t?sb(t).admissionsSummary:"Not Started",Loe={prospect:"Prospect",applicant:"Applicant",enrolled:"Enrolled Student",historical:"Historical"},Ooe=async()=>{const{data:t}=await O.from(id).select("*").order("status_updated_at",{ascending:!1});return t||[]},Moe=async t=>{const{data:s}=await O.from(l$).select("*").eq("case_id",t).order("created_at",{ascending:!1}).limit(50);return s||[]},m1=async t=>{await O.from(l$).insert({case_id:t.caseId,event_type:t.eventType||"status_change",from_status:t.fromStatus??null,to_status:t.toStatus??null,detail:t.detail??null,actor_email:t.actorEmail??null,actor_name:t.actorName??null,is_system:t.isSystem??!1})},Boe=async(t,s,n,a)=>{if(s===t.status)return{ok:!0};const{error:r}=await O.from(id).update({status:s,status_updated_at:new Date().toISOString(),updated_at:new Date().toISOString(),...s==="blocked"?{}:{blocked_reason:null}}).eq("id",t.id);return r?{ok:!1,error:r.message}:(await m1({caseId:t.id,fromStatus:t.status,toStatus:s,detail:`${sb(t.status).label} â ${sb(s).label}`,actorEmail:n.email,actorName:n.name}),{ok:!0})},Uoe=t=>(t||"").trim().toLowerCase()||null,c$=async t=>{var i,o,l;const s=Uoe(t.email);let n=null;if(t.personId){const{data:c}=await O.from(id).select("id").eq("person_id",t.personId).maybeSingle();n=c}if(!n&&s){const{data:c}=await O.from(id).select("id").ilike("email",s).maybeSingle();n=c}if(n!=null&&n.id){const c={};return t.personId&&(c.person_id=t.personId),t.sisStudentId&&(c.sis_student_id=t.sisStudentId),t.studentRef&&(c.student_ref=t.studentRef),t.scholarshipApplicationId&&(c.scholarship_application_id=t.scholarshipApplicationId),Object.keys(c).length&&(c.updated_at=new Date().toISOString(),await O.from(id).update(c).eq("id",n.id)),{caseId:n.id,created:!1}}const{data:a,error:r}=await O.from(id).insert({person_id:t.personId||null,display_name:t.displayName,email:s,phone:t.phone||null,program:t.program||null,campus:t.campus||null,lifecycle:t.lifecycle||"prospect",status:t.initialStatus||"new_interest",interest_signal:t.interestSignal||null,origin:t.origin||"manual",source_table:t.sourceTable||null,source_record_id:t.sourceRecordId||null,sis_student_id:t.sisStudentId||null,student_ref:t.studentRef||null,scholarship_application_id:t.scholarshipApplicationId||null}).select("id").single();return r||!a?{caseId:null,created:!1,error:r==null?void 0:r.message}:(await m1({caseId:a.id,eventType:"case_opened",toStatus:t.initialStatus||"new_interest",detail:`Case opened from ${t.origin||"manual"}${t.interestSignal?` · ${t.interestSignal}`:""}. Interest signal only â no aid processing implied.`,actorEmail:(i=t.actor)==null?void 0:i.email,actorName:(o=t.actor)==null?void 0:o.name,isSystem:!((l=t.actor)!=null&&l.email)}),{caseId:a.id,created:!0})},qoe=async()=>{const{data:t}=await O.from("z_scholarship_applications").select("id, applicant_name, applicant_email, program_interest, status, award_amount_cents, created_at").in("status",["approved","awarded"]).order("created_at",{ascending:!1});return t||[]},Woe=async(t,s)=>{const n=await c$({displayName:t.applicant_name,email:t.applicant_email,program:t.program_interest,initialStatus:"scholarship_pending",interestSignal:"Foundation scholarship approved",origin:"foundation_handoff",sourceTable:"z_scholarship_applications",sourceRecordId:t.id,scholarshipApplicationId:t.id,actor:s});return n.caseId?(await m1({caseId:n.caseId,eventType:"foundation_handoff",detail:"Foundation a
1298pproval received. Awaiting authorized Institute staff verification. No tuition credit and no Institute funding source created by this handoff.",actorEmail:s.email,actorName:s.name}),{ok:!0,caseId:n.caseId}):{ok:!1,error:n.error}},Hoe=async(t,s)=>{const{error:n}=await O.from(id).update({scholarship_verified:!0,scholarship_verified_by:s.email||s.name||"staff",scholarship_verified_at:new Date().toISOString(),status:"staff_review",status_updated_at:new Date().toISOString(),updated_at:new Date().toISOString()}).eq("id",t.id);return n?{ok:!1,error:n.message}:(await m1({caseId:t.id,eventType:"scholarship_verified",fromStatus:t.status,toStatus:"staff_review",detail:"Foundation award verified by authorized staff. Cleared for manual funding-source entry in the Institute Funding Manager â amounts remain human-entered.",actorEmail:s.email,actorName:s.name}),{ok:!0})},dk=t=>!!t.follow_up_at&&new Date(t.follow_up_at)<new Date,Nj=[{key:"all",label:"All Cases",hint:"Every financial-aid case, newest activity first.",match:()=>!0},{key:"new",label:"New Interest",hint:"Aid interest signalled â no process started yet.",match:t=>t.status==="new_interest"},{key:"fafsa",label:"FAFSA / Funding",hint:"Intake or FAFSA/alternative funding underway.",match:t=>t.status==="intake_started"||t.status==="fafsa_process"},{key:"documents",label:"Documents Needed",hint:"Outstanding documents or tasks.",match:t=>t.status==="documents_needed"},{key:"awaiting",label:"Awaiting Student",hint:"Ball is with the student.",match:t=>t.status==="awaiting_student"},{key:"review",label:"Staff Review",hint:"Requires a Financial Aid staff decision.",match:t=>t.status==="staff_review"},{key:"scholarship",label:"Scholarship Pending",hint:"Foundation/institutional award awaiting verification.",match:t=>t.status==="scholarship_pending"},{key:"ready",label:"Financially Ready",hint:"Financial clearance confirmed.",match:t=>t.status==="financially_ready"||t.status==="funding_plan_ready"},{key:"blocked",label:"Blocked / Overdue",hint:"Blocked cases plus anything past its follow-up date.",match:t=>t.status==="blocked"||dk(t)},{key:"historical",label:"Historical",hint:"Inactive/closed cases retained for reporting.",match:t=>t.lifecycle==="historical"||t.status==="closed"}],Goe=t=>{const s={};return tb.forEach(n=>{s[n.key]=0}),t.forEach(n=>{s[n.status]=(s[n.status]||0)+1}),{total:t.length,newInterest:s.new_interest||0,documentsOutstanding:s.documents_needed||0,awaitingStudent:s.awaiting_student||0,staffReview:s.staff_review||0,scholarshipPending:s.scholarship_pending||0,financiallyReady:(s.financially_ready||0)+(s.funding_plan_ready||0),blockedOrOverdue:t.filter(n=>n.status==="blocked"||dk(n)).length,byStatus:s}},Voe=dk,_j="#800020",Zoe=({aidCase:t,actor:s,onChanged:n})=>{var y;const[a,r]=d.useState(!1),[i,o]=d.useState(!1),[l,c]=d.useState(null),u=sb(t.status),p=Voe(t),m=async()=>{const v=!a;r(v),v&&l===null&&c(await Moe(t.id))},x=async v=>{v!==t.status&&(o(!0),await Boe(t,v,s),o(!1),c(null),n())},h=async()=>{o(!0),await Hoe(t,s),o(!1),c(null),n()};return e.jsxs("div",{className:"rounded-xl border bg-white overflow-hidden",style:{borderColor:p?"#FCA5A5":"#E5E7EB"},children:[e.jsxs("div",{className:"p-4 flex flex-wrap items-start gap-3",children:[e.jsx("div",{className:"w-10 h-10 rounded-xl flex items-center justify-center shrink-0",style:{background:`${_j}10`,color:_j},children:e.jsx(yr,{size:18})}),e.jsxs("div",{className:"flex-1 min-w-[200px]",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx("p",{className:"font-semibold text-gray-900",children:t.display_name}),e.jsx("span",{className:"px-2 py-0.5 rounded-full text-[10px] font-bold",style:{background:u.bg,color:u.color},children:u.label}),e.jsx("span",{className:"px-2 py-0.5 rounded-full text-[10px] font-medium bg-gray-100 text-gray-600",children:Loe[t.lifecycle]}),t.scholarship_verified&&e.jsxs("span",{className:"px-2 py-0.5 rounded-full text-[10px] font-bold bg-emerald-100 text-emerald-700 flex items-center gap-1",children:[e.jsx(Ie,{size:10})," Award Verified"]}),p&&e.jsxs("span",{className:"px-2 py-0.5 rounded-full text-[10px] font-bold bg-red-100 text-red-700 flex items-center gap-1",children:[e.jsx(ve,{size:10})," Overdue"]})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-3 text-[11px] text-gray-500 mt-1",children:[t.email&&e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(Ye,{size:11}),t.email]}),t.phone&&e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(Qt,{size:11}),t.phone]}),t.program&&e.jsx("span",{children:t.program}),t.sis_student_id&&e.jsxs("span",{className:"font-mono",children:["SIS ",t.sis_student_id]}),t.follow_up_at&&e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(At,{size:11}),new Date(t.follow_up_at).toLocaleDateString()]})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("select",{value:t.status,disabled:i,onChange:v=>x(v.target.value),className:"text-xs border rounded-lg px-2 py-1.5 bg-white text-gray-700 focus:outline-none",children:tb.map(v=>e.jsx("option",{value:v.key,children:v.label},v.key))}),e.jsx("button",{onClick:m,className:"p-1.5 rounded-lg hover:bg-gray-100 text-gray-500",children:i?e.jsx(de,{size:16,className:"animate-spin"}):a?e.jsx(Od,{size:16}):e.jsx(Gt,{size:16})})]})]}),a&&e.jsxs("div",{className:"border-t bg-gray-50 p-4 space-y-3",children:[e.jsx("p",{className:"text-[11px] text-gray-600",children:u.description}),e.jsxs("p",{className:"text-[11px] text-gray-500",children:["Admissions sees only: ",e.jsx("span",{className:"font-semibold text-gray-700",children:zoe(t.status)})," â no amounts or records are exposed to the Admissions CRM."]}),((y=t.documents_outstanding)==null?void 0:y.length)>0&&e.jsxs("div",{className:"text-[11px] text-gray-600",children:[e.jsxs("p",{className:"font-semibold flex items-center gap-1 mb-1",children:[e.jsx(Kt,{size:11})," Outstanding"]}),e.jsx("ul",{className:"list-disc ml-5",children:t.documents_outstanding.map((v,g)=>e.jsx("li",{children:v},g))})]}),t.blocked_reason&&e.jsxs("p",{className:"text-[11px] text-red-600",children:[e.jsx(ve,{size:11,className:"inline mr-1"}),t.blocked_reason]}),t.scholarship_application_id&&!t.scholarship_verified&&e.jsxs("div",{className:"p-3 rounded-lg bg-amber-50 border border-amber-200",children:[e.jsxs("p",{className:"text-[11px] text-amber-800 mb-2",children:["Foundation award pending Institute verification. Verifying does ",e.jsx("strong",{children:"not"})," post any tuition credit â a funding source must still be entered by hand in the Institute Funding Manager."]}),e.jsx("button",{onClick:h,disabled:i,className:"px-3 py-1.5 rounded-lg text-[11px] font-bold text-white disabled:opacity-50",style:{background:_j},children:"Verify Award (no money moves)"})]}),e.jsxs("div",{children:[e.jsxs("p",{className:"text-[11px] font-semibold text-gray-600 flex items-center gap-1 mb-1",children:[e.jsx(en,{size:11})," Audit Trail"]}),l===null?e.jsx("p",{className:"text-[11px] text-gray-400",children:"Loadingâ¦"}):l.length===0?e.jsx("p",{className:"text-[11px] text-gray-400",children:"No recorded events."}):e.jsx("ul",{className:"space-y-1",children:l.map(v=>e.jsxs("li",{className:"text-[11px] text-gray-600 flex gap-2",children:[e.jsx(dt,{size:11,className:"mt-0.5 shrink-0 text-gray-400"}),e.jsxs("span",{children:[e.jsx("span",{className:"text-gray-400",children:new Date(v.created_at).toLocaleStr
1298ing()})," â ",v.detail||`${v.from_status||"â"} â ${v.to_status||"â"}`,v.actor_email?` · ${v.actor_email}`:v.is_system?" · system":""]})]},v.id))})]})]})]})},sr="#800020",kj="#D4AF37",Yoe=({actorEmail:t,actorName:s})=>{const[n,a]=d.useState([]),[r,i]=d.useState([]),[o,l]=d.useState(!0),[c,u]=d.useState("all"),[p,m]=d.useState(""),[x,h]=d.useState(null),[y,v]=d.useState(!1),[g,N]=d.useState({name:"",email:"",phone:"",program:""}),[b,f]=d.useState(!1),j={email:t,name:s},S=async()=>{l(!0);const[D,L]=await Promise.all([Ooe(),qoe()]);a(D),i(L),l(!1)};d.useEffect(()=>{S()},[]);const w=d.useMemo(()=>Goe(n),[n]),_=Nj.find(D=>D.key===c)||Nj[0],C=d.useMemo(()=>{const D=p.trim().toLowerCase();return n.filter(L=>_.match(L)?D?L.display_name.toLowerCase().includes(D)||(L.email||"").toLowerCase().includes(D)||(L.program||"").toLowerCase().includes(D)||(L.sis_student_id||"").toLowerCase().includes(D):!0:!1)},[n,_,p]),E=d.useMemo(()=>{const D=new Set(n.map(L=>L.scholarship_application_id).filter(Boolean));return r.filter(L=>!D.has(L.id))},[r,n]),P=async D=>{h(D.id),await Woe(D,j),h(null),S()},F=async()=>{g.name.trim()&&(f(!0),await c$({displayName:g.name.trim(),email:g.email.trim()||null,phone:g.phone.trim()||null,program:g.program.trim()||null,origin:"staff_manual",interestSignal:"Opened manually by Financial Aid staff",actor:j}),f(!1),N({name:"",email:"",phone:"",program:""}),v(!1),S())},I=[{label:"Total Cases",value:w.total,color:sr},{label:"New Interest",value:w.newInterest,color:"#0369A1"},{label:"Documents Needed",value:w.documentsOutstanding,color:"#B45309"},{label:"Awaiting Student",value:w.awaitingStudent,color:"#92400E"},{label:"Staff Review",value:w.staffReview,color:"#BE185D"},{label:"Scholarship Pending",value:w.scholarshipPending,color:"#A16207"},{label:"Financially Ready",value:w.financiallyReady,color:"#065F46"},{label:"Blocked / Overdue",value:w.blockedOrOverdue,color:"#B91C1C"}];return e.jsxs("div",{className:"space-y-5",children:[e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"w-10 h-10 rounded-xl flex items-center justify-center",style:{background:`linear-gradient(135deg, ${sr}, ${sr}CC)`},children:e.jsx(wo,{size:20,className:"text-white"})}),e.jsxs("div",{children:[e.jsx("h3",{className:"text-lg font-bold",style:{color:sr,fontFamily:"Georgia, serif"},children:"Financial Aid Workspace"}),e.jsx("p",{className:"text-xs text-gray-500",children:"Person-level cases · controlled status model · fully auditable"})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("button",{onClick:()=>v(D=>!D),className:"flex items-center gap-1.5 px-3 py-2 rounded-xl text-xs font-bold text-white",style:{background:sr},children:[e.jsx(tn,{size:14})," New Case"]}),e.jsxs("button",{onClick:S,className:"flex items-center gap-1.5 px-3 py-2 rounded-xl text-xs font-semibold border text-gray-600",children:[e.jsx(Be,{size:14})," Refresh"]})]})]}),e.jsxs("div",{className:"p-3 rounded-xl border flex items-start gap-2",style:{background:`${sr}05`,borderColor:`${sr}20`},children:[e.jsx(Tt,{size:14,style:{color:sr},className:"mt-0.5 shrink-0"}),e.jsxs("p",{className:"text-[11px] text-gray-600",children:[e.jsx("strong",{children:"Interest is not process."})," A financial-aid inquiry or checkbox only ever opens a case at âNew Aid Interestâ â it never implies FAFSA started, eligibility determined, an award made, or financial clearance. Award amounts, eligibility determinations and tuition credits remain entirely human-controlled and are entered in the Institute Funding Manager. Summary views show counts only, never amounts."]})]}),y&&e.jsxs("div",{className:"p-4 rounded-xl border bg-white grid grid-cols-1 md:grid-cols-4 gap-3",children:[["name","email","phone","program"].map(D=>e.jsx("input",{value:g[D],onChange:L=>N(V=>({...V,[D]:L.target.value})),placeholder:D==="name"?"Full name (required)":D==="email"?"Email":D==="phone"?"Phone (optional)":"Program",className:"px-3 py-2 rounded-lg border text-sm focus:outline-none"},D)),e.jsxs("div",{className:"md:col-span-4 flex items-center gap-2",children:[e.jsx("button",{onClick:F,disabled:b||!g.name.trim(),className:"px-4 py-2 rounded-lg text-xs font-bold text-white disabled:opacity-40",style:{background:sr},children:b?"Openingâ¦":"Open Case at New Aid Interest"}),e.jsx("span",{className:"text-[10px] text-gray-400",children:"Idempotent â re-opening an existing person reuses their case."})]})]}),e.jsx("div",{className:"grid grid-cols-2 md:grid-cols-4 lg:grid-cols-8 gap-2",children:I.map(D=>e.jsxs("div",{className:"p-3 rounded-xl border bg-white",children:[e.jsx("p",{className:"text-[9px] uppercase tracking-wider text-gray-400",children:D.label}),e.jsx("p",{className:"text-xl font-bold",style:{color:D.color},children:D.value})]},D.label))}),E.length>0&&e.jsxs("div",{className:"p-4 rounded-xl border-2",style:{borderColor:`${kj}50`,background:`${kj}08`},children:[e.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[e.jsx(MP,{size:16,style:{color:kj}}),e.jsx("p",{className:"text-sm font-bold text-gray-800",children:"Foundation Scholarship Handoff"})]}),e.jsxs("p",{className:"text-[11px] text-gray-600 mb-3",children:["Approved Foundation a
1298pplications not yet linked to an Institute case. Handoff creates a",e.jsx("strong",{children:" Scholarship Pending"})," case only â no tuition credit and no funding source are created."]}),e.jsx("div",{className:"space-y-2",children:E.slice(0,8).map(D=>e.jsxs("div",{className:"flex flex-wrap items-center gap-2 justify-between bg-white rounded-lg border p-2.5",children:[e.jsxs("div",{className:"text-xs",children:[e.jsx("p",{className:"font-semibold text-gray-800",children:D.applicant_name}),e.jsxs("p",{className:"text-[10px] text-gray-500",children:[D.applicant_email,D.program_interest?` · ${D.program_interest}`:""]})]}),e.jsx("button",{onClick:()=>P(D),disabled:x===D.id,className:"px-3 py-1.5 rounded-lg text-[11px] font-bold text-white disabled:opacity-50",style:{background:sr},children:x===D.id?e.jsx(de,{size:12,className:"animate-spin"}):"Hand off to Institute"})]},D.id))})]}),e.jsx("div",{className:"flex flex-wrap gap-1.5",children:Nj.map(D=>{const L=n.filter(D.match).length;return e.jsxs("button",{onClick:()=>u(D.key),className:`px-3 py-1.5 rounded-lg text-xs font-semibold border transition-all ${c===D.key?"text-white":"text-gray-600 bg-white"}`,style:c===D.key?{background:sr,borderColor:sr}:{},children:[D.label," ",e.jsxs("span",{className:"opacity-60",children:["(",L,")"]})]},D.key)})}),e.jsxs("div",{className:"flex items-center gap-2 text-[11px] text-gray-500",children:[e.jsx(Bi,{size:12})," ",_.hint]}),e.jsxs("div",{className:"relative max-w-md",children:[e.jsx(Bt,{size:14,className:"absolute left-3 top-1/2 -translate-y-1/2 text-gray-400"}),e.jsx("input",{value:p,onChange:D=>m(D.target.value),placeholder:"Search name, email, program or SIS IDâ¦",className:"w-full pl-9 pr-3 py-2 rounded-xl border text-sm focus:outline-none"})]}),o?e.jsxs("div",{className:"flex items-center justify-center py-16 text-gray-400",children:[e.jsx(de,{size:20,className:"animate-spin mr-2"})," Loading casesâ¦"]}):C.length===0?e.jsxs("div",{className:"text-center py-14 border-2 border-dashed rounded-xl text-gray-400",children:[e.jsx(wo,{size:36,className:"mx-auto mb-3 opacity-30"}),e.jsxs("p",{className:"text-sm font-medium text-gray-500",children:["No cases in â",_.label,"â."]}),e.jsx("p",{className:"text-[11px] mt-1 max-w-md mx-auto",children:"Financial Aid case management is newly activated. Cases appear as staff open them, or as approved Foundation awards are handed off. Historical ledger records are untouched and remain in the Institute Funding Manager."})]}):e.jsx("div",{className:"space-y-2",children:C.map(D=>e.jsx(Zoe,{aidCase:D,actor:j,onChanged:S},D.id))})]})},As="#800020",o4="#D4AF37",l4={paid:"bg-emerald-100 text-emerald-700",pending:"bg-amber-100 text-amber-700",failed:"bg-red-100 text-red-700",refunded:"bg-blue-100 text-blue-700",cancelled:"bg-gray-100 text-gray-500",diagnostic:"bg-purple-100 text-purple-600"},Ag={settled:{cls:"bg-emerald-100 text-emerald-700",label:"SETTLED"},pending_settlement:{cls:"bg-amber-100 text-amber-700",label:"PENDING SETTLEMENT"},unsettled:{cls:"bg-gray-100 text-gray-500",label:"UNSETTLED"},mismatch:{cls:"bg-red-100 text-red-700",label:"MISMATCH"},not_found:{cls:"bg-red-100 text-red-700",label:"NOT FOUND"},unverified:{cls:"bg-gray-100 text-gray-400",label:"UNVERIFIED"}},Koe=()=>{const[t,s]=d.useState("monitor"),[n,a]=d.useState([]),[r,i]=d.useState(!0),[o,l]=d.useState(""),[c,u]=d.useState("all"),[p,m]=d.useState(null),[x,h]=d.useState([]),[y,v]=d.useState(null),[g,N]=d.useState(!1),[b,f]=d.useState(""),j=d.useCallback(async()=>{i(!0);const{data:E}=await O.from(e$).select("*").order("created_at",{ascending:!1}).limit(200);a(E||[]),i(!1)},[]);d.useEffect(()=>{j(),O.functions.invoke(t$,{body:{action:"health"}}).then(({data:E})=>{E&&m(E)}).catch(()=>m({ok:!1}))},[j]);const S=d.useMemo(()=>{let E=n;if(c!=="all"&&(E=E.filter(P=>P.payment_type===c)),o.trim()){const P=o.trim().toLowerCase();E=E.filter(F=>(F.student_ref||"").toLowerCase().includes(P)||(F.student_name||"").toLowerCase().includes(P)||(F.student_email||"").toLowerCase().includes(P)||(F.receipt_number||"").toLowerCase().includes(P)||(F.stripe_payment_intent_id||"").toLowerCase().includes(P)||(F.program||"").toLowerCase().includes(P))}return E},[n,c,o]),w=d.useMemo(()=>{const E=n.filter(P=>P.status==="paid");return{collectedCents:E.reduce((P,F)=>P+F.amount_cents,0),tuitionCount:E.filter(P=>P.payment_type==="tuition").length,clinicCount:E.filter(P=>P.payment_type==="clinic").length,receiptsSent:n.filter(P=>P.receipt_email_status==="sent").length,settledCents:E.filter(P=>P.settlement_status==="settled").reduce((P,F)=>P+F.amount_cents,0)}},[n]),_=async()=>{N(!0),f("");try{const{data:E,error:P}=await O.functions.invoke(zie,{body:{limit:200}});if(P)throw new Error(P.message||"Reconciliation function failed");if(!(E!=null&&E.ok))throw new Error((E==null?void 0:E.error)||"Reconciliation failed");h(E.rows||[]),v(E.summary||null),j()}catch(E){f((E==null?void 0:E.message)||"Reconciliation failed.")}finally{N(!1)}},C=()=>{const E=["Receipt Number","Student Ref","SIS Student ID","Student Name","Program","Type","Amount (USD)","Status","Date/Time","PaymentIntent ID","Settlement","Receipt Email"],P=S.map(L=>[L.receipt_number,L.student_ref||"",L.sis_student_id||"",L.student_name||"",L.program||"",L.payment_type,(L.amount_cents/100).toFixed(2),L.status,new Date(L.paid_at).toISOString(),L.stripe_payment_intent_id||"",L.settlement_status,L.receipt_email_status].map(V=>`"${String(V).replace(/"/g,'""')}"`).join(",")),F=new Blob([[E.join(","),...P].join(` 1299`)],{type:"text/csv"}),I=URL.createObjectURL(F),D=document.createElement("a");D.href=I,D.download=`institute-payments-${new Date().toISOString().slice(0,10)}.csv`,D.click(),URL.revokeObjectURL(I)};return e.jsxs("div",{className:"min-h-screen bg-gray-50",children:[e.jsx("div",{className:"text-white",style:{background:`linear-gradient(135deg, ${As}, #5c0017)`},children:e.jsxs("div",{className:"max-w-7xl mx-auto px-6 py-8",children:[e.jsxs(be,{to:"/",className:"inline-flex items-center gap-1 text-xs text-white/70 hover:text-white mb-4",children:[e.jsx(Je,{size:12})," Back to site"]}),e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-4",children:[e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx("div",{className:"w-12 h-12 rounded-xl bg-white/15 flex items-center justify-center border border-white/20",children:e.jsx(wo,{size:24})}),e.jsxs("div",{children:[e.jsx("h1",{className:"text-2xl font-bold",style:{fontFamily:'"Georgia", serif'},children:"Institute Pay Monitor"}),e.jsx("p",{className:"text-xs text-white/70",children:"Tuition & Student Salon Clinic · Isolated Rail (INSTITUTE_SECRET_KEY)"})]})]}),e.jsx("div",{className:`flex items-center gap-2 px-4 py-2 rounded-xl text-xs font-bold border ${p!=null&&p.ok?"bg-emerald-500/20 border-emerald-300/40":"bg-white/10 border-white/20"}`,children:p===null?e.jsxs(e.Fragment,{children:[e.jsx(Be,{size:13,className:"animate-spin"})," Checking railâ¦"]}):p.ok?e.jsxs(e.Fragment,{children:[e.jsx(Ie,{size:13,style:{color:o4}})," RAIL LIVE · ",p.accountId||"acct_1TU3r91mz9T3Ao4l",p.businessName?` · ${p.businessName}`:""]}):e.jsxs(e.Fragment,{children:[e.jsx(ve,{size:13,className:"text-amber-300"})," Rail health check unavailable"]})})]})]})}),e.jsxs("div",{className:"max-w-7xl mx-auto px-6 py-8 space-y-6",children:[e.jsx("div",{className:"grid grid-cols-2 md:grid-cols-5 ga
1299p-3",children:[{label:"Total Collected",value:mu(w.collectedCents),icon:e.jsx(Do,{size:14}),color:As},{label:"Tuition Payments",value:String(w.tuitionCount),icon:e.jsx(_t,{size:14}),color:"#3B82F6"},{label:"Clinic Payments",value:String(w.clinicCount),icon:e.jsx(Sa,{size:14}),color:"#8B5CF6"},{label:"Receipts Emailed",value:String(w.receiptsSent),icon:e.jsx(Ye,{size:14}),color:"#10B981"},{label:"Verified Settled",value:mu(w.settledCents),icon:e.jsx(Ie,{size:14}),color:o4}].map((E,P)=>e.jsxs("div",{className:"p-4 rounded-xl border bg-white",children:[e.jsxs("div",{className:"flex items-center gap-1.5 mb-1 text-[10px] uppercase tracking-wider",style:{color:E.color},children:[E.icon," ",E.label]}),e.jsx("p",{className:"font-mono text-xl font-bold text-gray-900",children:E.value})]},P))}),e.jsx("div",{className:"flex flex-wrap gap-1 bg-gray-100 rounded-xl p-1 max-w-5xl",children:[{id:"monitor",label:"Payment Monitor",icon:e.jsx(wo,{size:14})},{id:"reconciliation",label:"Reconciliation",icon:e.jsx(u0,{size:14})},{id:"aid",label:"Financial Aid Cases",icon:e.jsx(nh,{size:14})},{id:"funding",label:"Funding & Aid",icon:e.jsx(Do,{size:14})},{id:"sis",label:"SIS Student IDs",icon:e.jsx(Ie,{size:14})},{id:"import",label:"Student Import",icon:e.jsx(Ri,{size:14})},{id:"migration",label:"Production Migration",icon:e.jsx($i,{size:14})}].map(E=>e.jsxs("button",{onClick:()=>s(E.id),className:`flex items-center justify-center gap-2 flex-1 px-4 py-2.5 rounded-lg text-sm font-medium transition-all ${t===E.id?"text-white shadow-md":"text-gray-500 hover:text-gray-700"}`,style:t===E.id?{background:`linear-gradient(135deg, ${As}, ${As}DD)`}:{},children:[E.icon," ",E.label]},E.id))}),t==="aid"&&e.jsx(Yoe,{actorEmail:null,actorName:"Financial Aid Staff"}),t==="funding"&&e.jsx(Qie,{}),t==="sis"&&e.jsx(aoe,{}),t==="import"&&e.jsx(goe,{}),t==="migration"&&e.jsx($oe,{}),t==="monitor"&&e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-3",children:[e.jsxs("div",{className:"relative flex-1 min-w-[240px]",children:[e.jsx(Bt,{size:14,className:"absolute left-3 top-1/2 -translate-y-1/2 text-gray-400"}),e.jsx("input",{value:o,onChange:E=>l(E.target.value),placeholder:"Search student ID, name, receipt #, PaymentIntent IDâ¦",className:"w-full pl-9 pr-3 py-2.5 rounded-xl border border-gray-200 text-sm bg-white focus:outline-none focus:border-[#800020]"})]}),e.jsx("div",{className:"flex gap-1 bg-white border rounded-xl p-1",children:["all","tuition","clinic"].map(E=>e.jsx("button",{onClick:()=>u(E),className:`px-3 py-1.5 rounded-lg text-xs font-semibold transition-all ${c===E?"text-white":"text-gray-500 hover:text-gray-700"}`,style:c===E?{background:As}:{},children:E==="all"?"All":E==="tuition"?"Tuition":"Clinic"},E))}),e.jsxs("button",{onClick:j,className:"flex items-center gap-1.5 px-3 py-2.5 rounded-xl border bg-white text-xs font-semibold text-gray-600 hover:bg-gray-50",children:[e.jsx(Be,{size:13})," Refresh"]}),e.jsxs("button",{onClick:C,disabled:S.length===0,className:"flex items-center gap-1.5 px-3 py-2.5 rounded-xl text-xs font-bold text-white disabled:opacity-40",style:{background:As},children:[e.jsx(us,{size:13})," Export CSV"]})]}),r?e.jsx("div",{className:"flex items-center justify-center py-20",children:e.jsx("div",{className:"w-8 h-8 border-4 rounded-full animate-spin",style:{borderColor:`${As}30`,borderTopColor:As}})}):S.length===0?e.jsxs("div",{className:"text-center py-16 text-gray-400 bg-white rounded-xl border",children:[e.jsx(wo,{size:40,className:"mx-auto mb-3 opacity-30"}),e.jsx("p",{className:"text-sm",children:"No Institute payments recorded yet."}),e.jsx("p",{className:"text-xs mt-1",children:"Tuition and Student Salon Clinic payments will appear here automatically after checkout."})]}):e.jsx("div",{className:"bg-white rounded-xl border overflow-x-auto",children:e.jsxs("table",{className:"w-full text-sm min-w-[1100px]",children:[e.jsx("thead",{children:e.jsx("tr",{className:"border-b",style:{background:`${As}05`},children:["Student","Program","Type","Amount","Status","Date / Time","PaymentIntent ID","Receipt #","Settlement","Email"].map(E=>e.jsx("th",{className:"text-left px-4 py-3 text-[10px] uppercase tracking-wider text-gray-500 whitespace-nowrap",children:E},E))})}),e.jsx("tbody",{className:"divide-y divide-gray-50",children:S.map(E=>{const P=Ag[E.settlement_status]||Ag.unverified;return e.jsxs("tr",{className:"hover:bg-gray-50",children:[e.jsxs("td",{className:"px-4 py-3",children:[e.jsx("p",{className:"font-medium text-gray-900",children:E.student_name||"â"}),e.jsxs("p",{className:"text-[10px] text-gray-400 font-mono",children:[E.student_ref?`ID: ${E.student_ref}`:E.payment_type==="clinic"?"Clinic client":"No ID",E.sis_student_id?` · SIS: ${E.sis_student_id}`:""]})]}),e.jsx("td",{className:"px-4 py-3 text-gray-600 text-xs",children:E.program||"â"}),e.jsx("td",{className:"px-4 py-3",children:e.jsxs("span",{className:`inline-flex items-center gap-1 px-2 py-0.5 rounded-full text-[10px] font-bold ${E.payment_type==="tuition"?"bg-blue-100 text-blue-700":"bg-purple-100 text-purple-700"}`,children:[E.payment_type==="tuition"?e.jsx(_t,{size:10}):e.jsx(Sa,{size:10}),E.payment_type==="tuition"?"TUITION":"CLINIC"]})}),e.jsx("td",{className:"px-4 py-3 font-mono font-bold text-gray-900",children:mu(E.amount_cents)}),e.jsx("td",{className:"px-4 py-3",children:e.jsx("span",{className:`px-2 py-0.5 rounded-full text-[10px] font-bold ${l4[E.status]||"bg-gray-100 text-gray-500"}`,children:E.status.toUpperCase()})}),e.jsx("td",{className:"px-4 py-3 text-xs text-gray-500 whitespace-nowrap",children:new Date(E.paid_at).toLocaleStr
1299ing()}),e.jsx("td",{className:"px-4 py-3 text-[10px] font-mono text-gray-500 max-w-[160px] truncate",title:E.stripe_payment_intent_id||"",children:E.stripe_payment_intent_id||"â"}),e.jsx("td",{className:"px-4 py-3 text-[10px] font-mono font-semibold",style:{color:As},children:E.receipt_number}),e.jsx("td",{className:"px-4 py-3",children:e.jsx("span",{className:`px-2 py-0.5 rounded-full text-[9px] font-bold ${P.cls}`,children:P.label})}),e.jsx("td",{className:"px-4 py-3",children:E.receipt_email_status==="sent"?e.jsxs("span",{className:"inline-flex items-center gap-1 text-[10px] text-emerald-600 font-semibold",children:[e.jsx(pt,{size:11})," Sent"]}):E.receipt_email_status==="failed"?e.jsxs("span",{className:"inline-flex items-center gap-1 text-[10px] text-red-500 font-semibold",children:[e.jsx(kt,{size:11})," Failed"]}):e.jsxs("span",{className:"inline-flex items-center gap-1 text-[10px] text-gray-400",children:[e.jsx(dt,{size:11})," â"]})})]},E.id)})})]})}),e.jsxs("p",{className:"text-[10px] text-gray-400",children:["SIS-READY: student identifiers currently use the student record ID (z_student_accounts.student_id). The registry includes a reserved ",e.jsx("span",{className:"font-mono",children:"sis_student_id"})," column so permanent SIS Student IDs can be backfilled later with no restructuring."]})]}),t==="reconciliation"&&e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"p-5 rounded-xl border-2 bg-white",style:{borderColor:`${As}25`},children:[e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-4",children:[e.jsxs("div",{children:[e.jsxs("h3",{className:"text-sm font-bold text-gray-900 flex items-center gap-2",children:[e.jsx(u0,{size:16,style:{color:As}})," Institute Reconciliation"]}),e.jsx("p",{className:"text-xs text-gray-500 mt-1 max-w-xl",children:"Cross-references every registry payment against Stripe (read-only, INSTITUTE_SECRET_KEY), the student financial ledger, and the clinic audit log â verifying PaymentIntent status, amounts, and Chase-bound settlement. No charges are ever created."})]}),e.jsxs("button",{onClick:_,disabled:g,className:"flex items-center gap-2 px-5 py-3 rounded-xl text-sm font-bold text-white shadow-md disabled:opacity-50",style:{background:`linear-gradient(135deg, ${As}, ${As}DD)`},children:[g?e.jsx(Be,{size:15,className:"animate-spin"}):e.jsx(Ie,{size:15}),g?"Reconcilingâ¦":"Run Reconciliation"]})]}),b&&e.jsxs("div",{className:"mt-3 p-3 rounded-xl bg-red-50 text-red-700 text-xs flex items-center gap-2",children:[e.jsx(ve,{size:13})," ",b]}),y&&e.jsx("div",{className:"mt-4 grid grid-cols-2 md:grid-cols-5 gap-3",children:[{label:"Rows Checked",value:String(y.totalRows)},{label:"Tuition / Clinic",value:`${y.tuitionCount} / ${y.clinicCount}`},{label:"Settled to Chase",value:mu(y.settledCents)},{label:"Pending Settlement",value:mu(y.pendingSettlementCents)},{label:"Issues Flagged",value:String(y.issueCount)}].map((E,P)=>e.jsxs("div",{className:"p-3 rounded-xl border bg-gray-50",children:[e.jsx("p",{className:"text-[10px] uppercase tracking-wider text-gray-400",children:E.label}),e.jsx("p",{className:"font-mono text-lg font-bold",style:{color:P===4&&y.issueCount>0?"#EF4444":As},children:E.value})]},P))}),y&&e.jsxs("p",{className:"text-[10px] text-gray-400 mt-2",children:["Verified against Stripe account ",e.jsx("span",{className:"font-mono",children:y.account})," at ",new Date(y.checkedAt).toLocaleString(),`. "Settled" = funds available in the Stripe balance bound for the Institute's linked Chase account.`]})]}),x.length===0&&!g?e.jsxs("div",{className:"text-center py-16 text-gray-400 bg-white rounded-xl border",children:[e.jsx(u0,{size:40,className:"mx-auto mb-3 opacity-30"}),e.jsx("p",{className:"text-sm",children:"Run reconciliation to generate the linkage report."})]}):x.length>0&&e.jsx("div",{className:"bg-white rounded-xl border overflow-x-auto",children:e.jsxs("table",{className:"w-full text-sm min-w-[1100px]",children:[e.jsx("thead",{children:e.jsx("tr",{className:"border-b",style:{background:`${As}05`},children:["Receipt #","Student","Type","Amount","Registry Status","Stripe Status","Settlement","Ledger Link","PaymentIntent","Notes"].map(E=>e.jsx("th",{className:"text-left px-4 py-3 text-[10px] uppercase tracking-wider text-gray-500 whitespace-nowrap",children:E},E))})}),e.jsx("tbody",{className:"divide-y divide-gray-50",children:x.map(E=>{const P=Ag[E.settlement_status]||Ag.unverified,F=E.payment_type==="tuition"?E.financial_record_linked:E.clinic_audit_linked;return e.jsxs("tr",{className:"hover:bg-gray-50",children:[e.jsx("td",{className:"px-4 py-3 text-[10px] font-mono font-semibold",style:{color:As},children:E.receipt_number}),e.jsxs("td",{className:"px-4 py-3",children:[e.jsx("p",{className:"text-xs font-medium text-gray-900",children:E.student_name||"â"}),e.jsx("p",{className:"text-[10px] text-gray-400 font-mono",children:E.student_ref||(E.payment_type==="clinic"?"clinic client":"â")})]}),e.jsx("td",{className:"px-4 py-3 text-[10px] font-bold text-gray-600 uppercase",children:E.payment_type}),e.jsx("td",{className:"px-4 py-3 font-mono font-bold text-gray-900",children:mu(E.amount_cents)}),e.jsx("td",{className:"px-4 py-3",children:e.jsx("span",{className:`px-2 py-0.5 rounded-full text-[10px] font-bold ${l4[E.status]||"bg-gray-100 text-gray-500"}`,children:E.status.toUpperCase()})}),e.jsx("td",{className:"px-4 py-3 text-[10px] font-mono text-gray-600",children:E.stripe_status||"â"}),e.jsx("td",{className:"px-4 py-3",children:e.jsx("span",{className:`px-2 py-0.5 rounded-full text-[9px] font-bold ${P.cls}`,children:P.label})}),e.jsx("td",{className:"px-4 py-3",children:F?e.jsxs("span",{className:"inline-flex items-center gap-1 text-[10px] text-emerald-600 font-semibold",children:[e.jsx(Xs,{size:11})," Linked"]}):e.jsxs("span",{className:"inline-flex items-center gap-1 text-[10px] text-amber-600 font-semibold",children:[e.jsx(ve,{size:11})," Unlinked"]})}),e.jsx("td",{className:"px-4 py-3 text-[10px] font-mono text-gray-500 max-w-[140px] truncate",title:E.stripe_payment_intent_id||"",children:E.stripe_payment_intent_id||"â"}),e.jsx("td",{className:"px-4 py-3 text-[10px] text-gray-500 max-w-[220px]",children:E.notes.length?E.notes.join(" · "):"â"})]},E.id)})})]})})]}),e.jsxs("div",{className:"p-4 rounded-xl border-2",style:{borderColor:`${As}20`,background:`${As}05`},children:[e.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[e.jsx(Ie,{size:14,style:{color:As}}),e.jsx("span",{className:"text-xs font-bold",style:{color:As},children:"Isolated Institute Rail â Scope"})]}),e.jsx("p",{className:"text-[10px] text-gray-600 leading-relaxed",children:"This monitor covers ONLY Institute revenue: student tuition and Student Salon Clinic payments processed on the isolated INSTITUTE_SECRET_KEY rail (Stripe acct_1TU3r91mz9T3Ao4l â Institute Chase account). Cosmetics, Zora's Salon, Zorganics Med Spa, Foundation donations, and POS run on their own untouched rails and never appear here. Rollback: INSTITUTE_ISOLATION_ENABLED in src/lib/institutePayConfig.ts."})]})]})]})},Dp=t=>`$${((t||0)/100).toFixed(2)}`,Sj=["paid","shipped","delivered"],Qoe=t=>({paid:"bg-emerald-100 text-emerald-700",pending:"bg-amber-100 text-amber-700",shipped:"bg-blue-100 text-blue-700",delivered:"bg-emerald-100 text-emerald-800",refunded:"bg-purple-100 text-purple-700",cancelled:"bg-gray-200 text-gray-600"})[t]||"bg-gray-100 text-gray-600",Joe=()=>{d.useEffect(()=>{document.title="Track Your Order â Zorganics Cosmetics"},[]);
1299const[t,s]=d.useState(""),[n,a]=d.useState(""),[r,i]=d.useState(!1),[o,l]=d.useState(""),[c,u]=d.useState(""),[p,m]=d.useState(null),x=async h=>{if(h==null||h.preventDefault(),!!t.trim()){i(!0),l(""),u(""),m(null);try{const{data:y,error:v}=await O.functions.invoke("cosmetics-order-tracking",{body:{email:t.trim(),order_ref:n.trim()||void 0}});v||(y==null?void 0:y.ok)!==!0?l((y==null?void 0:y.error)||"We could not look up your order right now. Please try again in a moment."):(m(y.orders||[]),y.message&&u(y.message))}catch(y){l((y==null?void 0:y.message)||"Order lookup failed.")}finally{i(!1)}}};return e.jsxs("div",{className:"min-h-screen",style:{background:"#FAF6EE"},children:[e.jsx("header",{className:"text-white",style:{background:"linear-gradient(135deg, #800020 0%, #600018 60%, #4A0010 100%)"},children:e.jsxs("div",{className:"max-w-3xl mx-auto px-4 sm:px-6 py-8",children:[e.jsxs(be,{to:"/",className:"inline-flex items-center gap-1.5 text-xs font-semibold mb-4 hover:underline",style:{color:"#E6D2A0"},children:[e.jsx(Je,{size:14})," Back to the shop"]}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"w-12 h-12 rounded-2xl flex items-center justify-center",style:{background:"rgba(197,160,89,0.95)",color:"#4A0010"},children:e.jsx(_d,{size:24})}),e.jsxs("div",{children:[e.jsx("h1",{className:"font-display text-2xl sm:text-3xl font-bold",children:"Track Your Order"}),e.jsx("p",{className:"text-sm text-white/75",children:"Enter the email you used at checkout to see your Zorganics Cosmetics order status."})]})]})]})}),e.jsxs("main",{className:"max-w-3xl mx-auto px-4 sm:px-6 py-8 space-y-6",children:[e.jsxs("form",{onSubmit:x,className:"bg-white rounded-2xl border border-[#C5A059]/25 shadow-sm p-6 space-y-4",children:[e.jsxs("div",{className:"grid sm:grid-cols-2 gap-4",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs font-bold uppercase tracking-wider mb-1.5",style:{color:"#800020"},children:"Email address"}),e.jsx("input",{type:"email",required:!0,value:t,onChange:h=>s(h.target.value),placeholder:"[email protected]",className:"w-full px-3 py-2.5 border border-gray-200 rounded-lg text-sm focus:outline-none focus:ring-2 focus:ring-[#C5A059]/40 focu
1299s:border-[#C5A059]"})]}),e.jsxs("div",{children:[e.jsxs("label",{className:"block text-xs font-bold uppercase tracking-wider mb-1.5",style:{color:"#800020"},children:["Order reference ",e.jsx("span",{className:"text-gray-400 normal-case font-medium",children:"(optional)"})]}),e.jsx("input",{type:"text",value:n,onChange:h=>a(h.target.value),placeholder:"e.g. 6BA96B7A",className:"w-full px-3 py-2.5 border border-gray-200 rounded-lg text-sm font-mono uppercase focus:outline-none focus:ring-2 focus:ring-[#C5A059]/40 focus:border-[#C5A059]"})]})]}),e.jsxs("button",{type:"submit",disabled:r||!t.trim(),className:"w-full sm:w-auto inline-flex items-center justify-center gap-2 px-6 py-3 rounded-xl text-sm font-bold text-white hover:opacity-90 transition-all disabled:opacity-50",style:{background:"linear-gradient(135deg, #800020, #600018)"},children:[r?e.jsx(de,{size:15,className:"animate-spin"}):e.jsx(Bt,{size:15}),r?"Looking upâ¦":"Track my order"]}),e.jsx("p",{className:"text-[11px] text-gray-400",children:"The order reference is the 8-character code in your confirmation email. Leaving it blank shows your most recent orders."})]}),o&&e.jsxs("div",{className:"rounded-xl border border-red-200 bg-red-50 p-4 text-sm text-red-800 flex items-start gap-2",children:[e.jsx(ve,{size:16,className:"shrink-0 mt-0.5"})," ",o]}),p!==null&&p.length===0&&!o&&e.jsxs("div",{className:"bg-white rounded-2xl border border-gray-200 p-8 text-center",children:[e.jsx(_d,{size:36,className:"text-gray-300 mx-auto mb-3"}),e.jsx("p",{className:"text-sm font-semibold text-gray-700",children:c||"No orders found for that email."}),e.jsxs("p",{className:"text-xs text-gray-500 mt-1",children:["Double-check the email you used at checkout, or contact us at"," ",e.jsx("a",{href:"mailto:[email protected]",className:"font-semibold hover:underline",style:{color:"#800020"},children:"[email protected]"}),"."]})]}),p&&p.map(h=>{const y=Sj.indexOf(h.status),v=h.status==="refunded"||h.status==="cancelled";return e.jsxs("div",{className:"bg-white rounded-2xl border border-[#C5A059]/25 shadow-sm overflow-hidden",children:[e.jsxs("div",{className:"px-6 py-4 border-b border-gray-100 flex flex-wrap items-center justify-between gap-2",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-[10px] font-bold uppercase tracking-wider text-gray-400",children:"Order reference"}),e.jsxs("p",{className:"font-mono font-bold text-gray-900",children:["#",h.reference]})]}),e.jsxs("div",{className:"text-right",children:[e.jsx("span",{className:`inline-flex text-[11px] font-bold uppercase px-2.5 py-1 rounded-full ${Qoe(h.status)}`,children:h.status}),e.jsxs("p",{className:"text-[11px] text-gray-400 mt-1",children:["Placed ",new Date(h.placed_at).toLocaleDateString()]})]})]}),!v&&e.jsxs("div",{className:"px-6 py-5",children:[e.jsx("div",{className:"flex items-center",children:Sj.map((g,N)=>{const b=y>=N||h.status==="pending"&&N===-1,f=[e.jsx(Yx,{size:15},"p"),e.jsx(Ay,{size:15},"s"),e.jsx(K_,{size:15},"d")];return e.jsxs(re.Fragment,{children:[e.jsxs("div",{className:"flex flex-col items-center",children:[e.jsx("div",{className:`w-9 h-9 rounded-full flex items-center justify-center border-2 ${b?"text-white border-transparent":"bg-white text-gray-300 border-gray-200"}`,style:b?{background:"linear-gradient(135deg, #800020, #600018)"}:{},children:b?e.jsx(Ue,{size:16}):f[N]}),e.jsx("span",{className:`mt-1.5 text-[10px] font-bold uppercase tracking-wider ${b?"text-[#800020]":"text-gray-400"}`,children:g})]}),N<Sj.length-1&&e.jsx("div",{className:`flex-1 h-0.5 mx-2 mb-5 ${y>N?"bg-[#800020]":"bg-gray-200"}`})]},g)})}),h.status==="pending"&&e.jsxs("p",{className:"mt-3 text-xs text-amber-700 flex items-center gap-1.5",children:[e.jsx(dt,{size:12})," Payment is being confirmed â this usually takes just a few minutes."]})]}),(h.tracking_number||h.carrier)&&e.jsxs("div",{className:"mx-6 mb-4 rounded-xl border border-emerald-200 bg-emerald-50 p-4",children:[e.jsxs("p",{className:"text-xs font-bold text-emerald-800 flex items-center gap-1.5",children:[e.jsx(Ay,{size:13})," Tracking information"]}),e.jsxs("p",{className:"text-sm text-emerald-800 mt-1",children:[h.carrier&&e.jsxs(e.Fragment,{children:["Carrier: ",e.jsx("strong",{children:h.carrier}),h.tracking_number?" · ":""]}),h.tracking_number&&e.jsxs(e.Fragment,{children:["Tracking #: ",e.jsx("strong",{className:"font-mono",children:h.tracking_number})]})]})]}),e.jsxs("div",{className:"px-6 pb-5",children:[e.jsx("div",{className:"divide-y divide-gray-50 border-t border-gray-100",children:h.items.map((g,N)=>e.jsxs("div",{className:"py-2.5 flex items-center justify-between text-sm",children:[e.jsxs("span",{className:"text-gray-800",children:[g.product_name,g.variant_title?e.jsxs("span",{className:"text-gray-500",children:[" â ",g.variant_title]}):null,e.jsxs("span",{className:"text-gray-400 text-xs",children:[" à ",g.quantity]})]}),e.jsx("span",{className:"font-semibold text-gray-900",children:Dp(g.total)})]},N))}),e.jsxs("div",{className:"mt-3 space-y-1 text-xs text-gray-500",children:[e.jsxs("div",{className:"flex justify-between",children:[e.jsx("span",{children:"Subtotal"}),e.jsx("span",{className:"font-mono",children:Dp(h.subtotal)})]}),e.jsxs("div",{className:"flex justify-between",children:[e.jsx("span",{children:"Shipping"}),e.jsx("span",{className:"font-mono",children:h.shipping>0?Dp(h.shipping):"Free"})]}),e.jsxs("div",{className:"flex justify-between",children:[e.jsx("span",{children:"Tax"}),e.jsx("span",{className:"font-mono",children:Dp(h.tax)})]}),e.jsxs("div",{className:"flex justify-between text-sm font-bold text-gray-900 pt-1.5 border-t border-gray-100",children:[e.jsx("span",{children:"Total"}),e.jsx("span",{className:"font-mono",children:Dp(h.total)})]})]})]})]},h.reference)}),e.jsxs("p",{className:"text-center text-[11px] text-gray-400 pb-8",children:["Questions about an order? Email"," ",e.jsx("a",{href:"mailto:[email protected]",className:"font-semibold hover:underline",style:{color:"#800020"},children:"[email protected]"})," ","with your order reference."]})]})]})},c4="create-cosmetics-payment-intent",Cj="",Aj={ready:!1,publishableKey:void 0,paymentFunction:void 0},Xoe=async()=>{try{const{data:t,error:s}=await O.functions.invoke(c4,{body:{action:"config"}}
1299);if(s||!t)return Aj;const n=(Cj&&Cj.startsWith("pk_")?Cj:void 0)||(typeof t.publishableKey=="string"&&t.publishableKey.startsWith("pk_")?t.publishableKey:void 0);return t.secretConfigured===!0&&n?{ready:!0,publishableKey:n,paymentFunction:c4}:Aj}catch(t){return console.warn("Cosmetics pay config fetch failed (falling back to shared rail):",t),Aj}},Rx=[{id:"institute",label:"Zorganics Institute",short:"Institute",badgeClass:"bg-burgundy/10 text-burgundy border border-burgundy/20",activeClass:"bg-burgundy text-white border-burgundy shadow-lg shadow-burgundy/20",accent:"#800020",railName:"Institute Isolated Rail"},{id:"cosmetics",label:"Zorganics Cosmetics",short:"Cosmetics",badgeClass:"bg-pink-50 text-pink-700 border border-pink-200",activeClass:"bg-pink-600 text-white border-pink-600 shadow-lg shadow-pink-500/20",accent:"#db2777",railName:"Cosmetics Isolated Rail"},{id:"salon",label:"Zora's Salon & Spa",short:"Salon & Spa",badgeClass:"bg-violet-50 text-violet-700 border border-violet-200",activeClass:"bg-violet-600 text-white border-violet-600 shadow-lg shadow-violet-500/20",accent:"#7c3aed",railName:"Shared FamousPay Rail (Salon)"},{id:"medspa",label:"Zorganics Med Spa",short:"Med Spa",badgeClass:"bg-cyan-50 text-cyan-700 border border-cyan-200",activeClass:"bg-cyan-600 text-white border-cyan-600 shadow-lg shadow-cyan-500/20",accent:"#0891b2",railName:"Shared FamousPay Rail (Med Spa)"},{id:"foundation",label:"Zorganics Foundation",short:"Foundation",badgeClass:"bg-emerald-50 text-emerald-700 border border-emerald-200",activeClass:"bg-emerald-600 text-white border-emerald-600 shadow-lg shadow-emerald-500/20",accent:"#059669",railName:"Shared FamousPay Rail (Foundation)"}];Rx.map(t=>t.id);const W0=t=>Rx.find(s=>s.id===t)||Rx[0],Ej=t=>({paymentFunction:void 0,publishableKey:void 0,isolated:!1,railName:W0(t).railName}),hxe=async t=>{try{if(t==="cosmetics"){const s=await Xoe();return s.ready&&s.paymentFunction&&s.publishableKey?{paymentFunction:s.paymentFunction,publishableKey:s.publishableKey,isolated:!0,railName:"Cosmetics Isolated Rail"}:{...Ej("cosmetics"),railName:"Shared FamousPay Rail (Cosmetics fallback)"}}return t==="institute"&&Lie?{paymentFunction:t$,publishableKey:QE.startsWith("pk_")?QE:void 0,isolated:!0,railName:"Institute Isolated Rail"}:Ej(t)}catch{return Ej(t)}},En=t=>`$${t.toLocaleString(void 0,{minimumFractionDigits:2,maximumFractionDigits:2})}`,ele=()=>{const[t,s]=d.useState("overview"),[n,a]=d.useState("all"),[r,i]=d.useState(!0),[o,l]=d.useState([]),[c,u]=d.useState([]),[p,m]=d.useState([]),[x,h]=d.useState([]),[y,v]=d.useState([]);d.useEffect(()=>{const _=document.createElement("meta");return _.name="robots",_.content="noindex,nofollow",document.head.appendChild(_),()=>{document.head.removeChild(_)}},[]);const g=async()=>{i(!0);const[_,C,E,P,F]=await Promise.all([O.from("pos_transactions").select("*").order("created_at",{ascending:!1}).limit(500),O.from("pos_inventory").select("*").order("business_unit").order("name"),O.from("pos_inventory_movements").select("*").order("created_at",{ascending:!1}).limit(300),O.from("financial_records").select("*").order("created_at",{ascending:!1}).limit(500),O.from("pos_transaction_payments").select("*").order("created_at",{ascending:!1}).limit(1e3)]);l(_.data||[]),u(C.data||[]),m(E.data||[]),h(P.data||[]),v(F.data||[]),i(!1)};d.useEffect(()=>{g()},[]);const N=d.useMemo(()=>Rx.map(_=>{const C=o.filter(Q=>(Q.business_unit||"institute")===_.id),E=C.filter(Q=>Q.status==="completed"),P=C.filter(Q=>Q.status==="refunded"),F=E.reduce((Q,K)=>Q+Number(K.total||0),0),I=P.reduce((Q,K)=>Q+Number(K.total||0),0),D=E.reduce((Q,K)=>Q+Number(K.tax||0),0),L=new Set(E.map(Q=>Q.id)),V=y.filter(Q=>L.has(Q.transaction_id)),B=new Set(V.map(Q=>Q.transaction_id)),A=Q=>V.filter(K=>K.method===Q).reduce((K,se)=>K+Number(se.amount||0),0)+E.filter(K=>!B.has(K.id)&&K.payment_method===Q).reduce((K,se)=>K+Number(se.total||0),0),z=E.filter(Q=>(Q.payment_method==="card"||Q.payment_method==="split")&&Q.stripe_payment_intent_id),M=A("card"),R=A("gift_card"),T=A("cash")+A("check"),U=c.filter(Q=>(Q.business_unit||"institute")===_.id),q=U.reduce((Q,K)=>Q+Number(K.price||0)*(K.stock_level||0),0),H=U.filter(Q=>Q.stock_level>0&&Q.stock_level<=(Q.reorder_point||0)).length,G=x.filter(Q=>(Q.business_unit||"institute")===_.id),W=G.reduce((Q,K)=>Q+Number(K.amount||0),0),X=p.filter(Q=>Q.business_unit===_.id);return{bu:_,txs:C,completed:E,refunded:P,revenue:F,refundTotal:I,tax:D,cardTxs:z,cardRevenue:M,giftCardRevenue:R,cashCheckRevenue:T,inv:U,invValue:q,lowStock:H,fins:G,finNet:W,movs:X}}),[o,c,x,p,y]),b=n==="all"?N:N.filter(_=>_.bu.id===n),f=n==="all"?o:o.filter(_=>(_.business_unit||"institute")===n),j=n==="all"?c:c.filter(_=>(_.business_unit||"institute")===n),S=n==="all"?p:p.filter(_=>_.business_unit===n),w=[{id:"overview",label:"Entity Sales",icon:e.jsx(si,{size:16})},{id:"transactions",label:"Transactions",icon:e.jsx(cx,{size:16})},{id:"inventory",label:"Inventory",icon:e.jsx(_d,{size:16})},{id:"movements",label:"Movement History",icon:e.jsx(en,{size:16})},{id:"reconciliation",label:"Reconciliation",icon:e.jsx(HO,{size:16})}];return e.jsx("div",{className:"min-h-screen bg-gray-50",children:e.jsxs("div",{className:"max-w-7xl mx-auto px-4 py-8",children:[e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-4 mb-8",children:[e.jsxs("div",{children:[e.jsxs(be,{to:"/",className:"inline-flex items-center gap-1.5 text-xs text-gray-400 hover:text-gray-600 mb-2",children:[e.jsx(Je,{size:12})," Back to site"]}),e.jsxs("h1",{className:"text-2xl font-bold text-gray-900 flex items-center gap-3",children:[e.jsx("span",{className:"w-10 h-10 rounded-xl bg-gray-900 text-white flex items-center justify-center",children:e.jsx(cx,{size:20})}),"Multi-Entity POS Dashboard"]}),e.jsx("p",{className:"text-sm text-gray-400 mt-1",children:"Revenue, inventory, movements & reconciliation â separated per Zorganics business entity"})]}),e.jsxs("button",{onClick:g,className:"flex items-center gap-2 px-4 py-2 bg-white border border-gray-200 rounded-lg text-sm font-medium text-gray-600 hover:border-gray-400 transition-colors",children:[e.jsx(Be,{size:14,className:r?"animate-spin":""})," Refresh"]})]}),e.jsxs("div",{className:"flex flex-wrap gap-2 mb-6",children:[e.jsx("button",{onClick:()=>a("all"),className:`px-3 py-1.5 rounded-lg text-xs font-semibold transition-all ${n==="all"?"bg-gray-900 text-white":"bg-white border border-gray-200 text-gray-500 hover:border-gray-400"}`,children:"All Entities"}),Rx.map(_=>e.jsx("button",{onClick:()=>a(_.id),className:`px-3 py-1.5 rounded-lg text-xs font-semibold border transition-all ${n===_.id?_.activeClass:"bg-white border-gray-200 text-gray-500 hover:border-gray-400"}`,children:_.short},_.id))]}),e.jsx("div",{className:"flex items-center gap-1 mb-8 border-b border-gray-200 overflow-x-auto",children:w.map(_=>e.jsxs("button",{onClick:()=>s(_.id),className:`flex items-center gap-2 px-4 py-3 text-sm font-semibold border-b-2 whitespace-nowrap transition-all ${t===_.id?"border-gray-900 text-gray-900":"border-transparent text-gray-400 hover:text-gray-600"}`,children:[_.icon," ",_.label]},_.id))}),r?e.jsxs("div",{className:"py-24 text-center text-gray-400",children:[e.jsx(de,{size:32,className:"mx-auto animate-spin mb
1299-3"})," Loading entity dataâ¦"]}):e.jsxs(e.Fragment,{children:[t==="overview"&&e.jsx("div",{className:"grid md:grid-cols-2 xl:grid-cols-3 gap-5",children:b.map(_=>e.jsxs("div",{className:"bg-white rounded-2xl border border-gray-100 shadow-sm overflow-hidden",children:[e.jsxs("div",{className:"px-5 py-4 border-b border-gray-100 flex items-center justify-between",style:{borderTop:`3px solid ${_.bu.accent}`},children:[e.jsxs("div",{children:[e.jsx("p",{className:"font-bold text-gray-900",children:_.bu.label}),e.jsxs("p",{className:"text-[11px] text-gray-400 flex items-center gap-1 mt-0.5",children:[e.jsx(Tt,{size:10})," ",_.bu.railName]})]}),e.jsxs("span",{className:`px-2 py-1 rounded-md text-xs font-semibold ${_.bu.badgeClass}`,children:[_.txs.length," txns"]})]}),e.jsxs("div",{className:"p-5 grid grid-cols-2 gap-4",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-[11px] text-gray-400 uppercase tracking-wider",children:"Revenue"}),e.jsx("p",{className:"font-mono text-xl font-bold",style:{color:_.bu.accent},children:En(_.revenue)})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-[11px] text-gray-400 uppercase tracking-wider",children:"Refunds"}),e.jsxs("p",{className:"font-mono text-xl font-bold text-red-500",children:["-",En(_.refundTotal)]})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-[11px] text-gray-400 uppercase tracking-wider",children:"Card / FamousPay"}),e.jsx("p",{className:"font-mono text-sm font-semibold text-gray-700",children:En(_.cardRevenue)})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-[11px] text-gray-400 uppercase tracking-wider",children:"Cash + Check"}),e.jsx("p",{className:"font-mono text-sm font-semibold text-gray-700",children:En(_.cashCheckRevenue)})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-[11px] text-gray-400 uppercase tracking-wider",children:"Gift Card Tender"}),e.jsx("p",{className:"font-mono text-sm font-semibold text-gray-700",children:En(_.giftCardRevenue)})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-[11px] text-gray-400 uppercase tracking-wider",children:"Tax Collected"}),e.jsx("p",{className:"font-mono text-sm font-semibold text-gray-700",children:En(_.tax)})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-[11px] text-gray-400 uppercase tracking-wider",children:"Financial Records"}),e.jsxs("p",{className:"font-mono text-sm font-semibold text-gray-700",children:[_.fins.length," ",e.jsxs("span",{className:"text-gray-400",children:["(",En(_.finNet),")"]})]})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-[11px] text-gray-400 uppercase tracking-wider",children:"Inventory SKUs"}),e.jsxs("p",{className:"font-mono text-sm font-semibold text-gray-700",children:[_.inv.length," ",e.jsxs("span",{className:"text-gray-400",children:["(",En(_.invValue),")"]})]})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-[11px] text-gray-400 uppercase tracking-wider",children:"Low Stock"}),e.jsx("p",{className:`font-mono text-sm font-semibold ${_.lowStock>0?"text-amber-600":"text-gray-700"}`,children:_.lowStock})]})]})]},_.bu.id))}),t==="transactions"&&e.jsx("div",{className:"bg-white rounded-xl border border-gray-100 shadow-sm overflow-hidden",children:e.jsx("div",{className:"overflow-x-auto",children:e.jsxs("table",{className:"w-full",children:[e.jsx("thead",{children:e.jsx("tr",{className:"border-b border-gray-100 bg-gray-50/50",children:["ID","Date","Entity","Client","Type","Payment","Status","Total"].map(_=>e.jsx("th",{className:"text-left px-4 py-3 text-xs font-semibold text-gray-500 uppercase tracking-wider",children:_},_))})}),e.jsx("tbody",{className:"divide-y divide-gray-50",children:f.length===0?e.jsx("tr",{children:e.jsx("td",{colSpan:8,className:"px-6 py-12 text-center text-gray-400 text-sm",children:"No transactions for this entity yet."})}):f.map(_=>{const C=W0(_.business_unit);return e.jsxs("tr",{className:_.status==="refunded"?"bg-red-50/30":"hover:bg-gray-50/50",children:[e.jsx("td",{className:"px-4 py-3 font-mono text-xs text-gray-500",children:_.id}),e.jsx("td",{className:"px-4 py-3 text-sm text-gray-600",children:new Date(_.created_at).toLocaleStr
1299ing()}),e.jsx("td",{className:"px-4 py-3",children:e.jsx("span",{className:`inline-flex px-2 py-0.5 rounded text-xs font-semibold ${C.badgeClass}`,children:C.short})}),e.jsx("td",{className:"px-4 py-3 text-sm text-gray-900",children:_.client_name}),e.jsx("td",{className:"px-4 py-3 text-xs capitalize text-gray-500",children:_.transaction_type}),e.jsx("td",{className:"px-4 py-3 text-xs capitalize text-gray-500",children:_.stripe_payment_intent_id?"FamousPay":_.payment_method}),e.jsx("td",{className:"px-4 py-3",children:_.status==="refunded"?e.jsxs("span",{className:"inline-flex items-center gap-1 text-xs text-red-600 font-semibold",children:[e.jsx(zi,{size:10})," Refunded"]}):e.jsxs("span",{className:"inline-flex items-center gap-1 text-xs text-emerald-600 font-semibold",children:[e.jsx(pt,{size:10})," Completed"]})}),e.jsx("td",{className:"px-4 py-3 font-mono text-sm font-bold text-gray-900",children:En(Number(_.total))})]},_.id)})})]})})}),t==="inventory"&&e.jsx("div",{className:"bg-white rounded-xl border border-gray-100 shadow-sm overflow-hidden",children:e.jsx("div",{className:"overflow-x-auto",children:e.jsxs("table",{className:"w-full",children:[e.jsx("thead",{children:e.jsx("tr",{className:"border-b border-gray-100 bg-gray-50/50",children:["Product","SKU","Entity","Category","Price","Stock","Reorder Pt","Status"].map(_=>e.jsx("th",{className:"text-left px-4 py-3 text-xs font-semibold text-gray-500 uppercase tracking-wider",children:_},_))})}),e.jsx("tbody",{className:"divide-y divide-gray-50",children:j.map(_=>{const C=W0(_.business_unit),E=_.stock_level>0&&_.stock_level<=(_.reorder_point||0),P=_.stock_level===0;return e.jsxs("tr",{className:"hover:bg-gray-50/50",children:[e.jsx("td",{className:"px-4 py-3 text-sm font-medium text-gray-900",children:_.name}),e.jsx("td",{className:"px-4 py-3 font-mono text-xs text-gray-500",children:_.sku}),e.jsx("td",{className:"px-4 py-3",children:e.jsx("span",{className:`inline-flex px-2 py-0.5 rounded text-xs font-semibold ${C.badgeClass}`,children:C.short})}),e.jsx("td",{className:"px-4 py-3 text-xs text-gray-500",children:_.category}),e.jsx("td",{className:"px-4 py-3 font-mono text-sm text-gray-900",children:En(Number(_.price))}),e.jsx("td",{className:`px-4 py-3 font-mono text-sm font-bold ${P?"text-red-600":E?"text-amber-600":"text-gray-900"}`,children:_.stock_level}),e.jsx("td",{className:"px-4 py-3 font-mono text-xs text-gray-400",children:_.reorder_point}),e.jsx("td",{className:"px-4 py-3 text-xs font-semibold",children:P?e.jsx("span",{className:"text-red-600",children:"Out of stock"}):E?e.jsxs("span",{className:"text-amber-600 inline-flex items-center gap-1",children:[e.jsx(ve,{size:10})," Low"]}):e.jsx("span",{className:"text-emerald-600",children:"In stock"})})]},_.id)})})]})})}),t==="movements"&&e.jsxs("div",{className:"bg-white rounded-xl border border-gray-100 shadow-sm overflow-hidden",children:[e.jsx("div",{className:"px-5 py-3 border-b border-gray-100 text-xs text-gray-400",children:"Append-only audit â rows can never be edited or deleted (RLS enforced)"}),e.jsx("div",{className:"overflow-x-auto",children:e.jsxs("table",{className:"w-full",children:[e.jsx("thead",{children:e.jsx("tr",{className:"border-b border-gray-100 bg-gray-50/50",children:["When","Entity","Item","Movement","Change","Before â After","Reference","By"].map(_=>e.jsx("th",{className:"text-left px-4 py-3 text-xs font-semibold text-gray-500 uppercase tracking-wider",children:_},_))})}),e.jsx("tbody",{className:"divide-y divide-gray-50",children:S.length===0?e.jsx("tr",{children:e.jsx("td",{colSpan:8,className:"px-6 py-12 text-center text-gray-400 text-sm",children:"No inventory movements recorded for this entity yet."})}):S.map(_=>{const C=W0(_.business_unit);return e.jsxs("tr",{className:"hover:bg-gray-50/50",children:[e.jsx("td",{className:"px-4 py-3 text-xs text-gray-500",children:new Date(_.created_at).toLocaleString()}),e.jsx("td",{className:"px-4 py-3",children:e.jsx("span",{className:`inline-flex px-2 py-0.5 rounded text-xs font-semibold ${C.badgeClass}`,children:C.short})}),e.jsx("td",{className:"px-4 py-3 text-sm text-gray-900",children:_.item_name||_.inventory_id}),e.jsx("td",{className:"px-4 py-3",children:e.jsx("span",{className:`inline-flex px-2 py-0.5 rounded text-xs font-semibold ${_.movement_type==="sale"?"bg-blue-50 text-blue-700":_.movement_type==="refund_restock"?"bg-red-50 text-red-700":_.movement_type==="restock"?"bg-emerald-50 text-emerald-700":"bg-gray-100 text-gray-600"}`,children:_.movement_type})}),e.jsxs("td",{className:`px-4 py-3 font-mono text-sm font-bold ${_.quantity_change<0?"text-red-600":"text-emerald-600"}`,children:[_.quantity_change>0?"+":"",_.quantity_change]}),e.jsxs("td",{className:"px-4 py-3 font-mono text-xs text-gray-500",children:[_.stock_before," â ",_.stock_after]}),e.jsx("td",{className:"px-4 py-3 font-mono text-xs text-gray-400",children:_.reference_id}),e.jsx("td",{className:"px-4 py-3 text-xs text-gray-400",children:_.performed_by})]},_.id)})})]})})]}),t==="reconciliation"&&e.jsx("div",{className:"space-y-5",children:b.map(_=>{const C=_.fins.filter(L=>Number(L.amount)>0).reduce((L,V)=>L+Number(V.amount),0),E=_.fins.filter(L=>Number(L.amount)<0).reduce((L,V)=>L+Number(V.amount),0),P=_.revenue-_.refundTotal,F=C+E,I=Math.abs(P-F),D=I<.01||_.txs.length===0;return e.jsxs("div",{className:"bg-white rounded-2xl border border-gray-100 shadow-sm p-5",children:[e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3 mb-4",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("span",{className:`px-2.5 py-1 rounded-lg text-xs font-semibold ${_.bu.badgeClass}`,children:_.bu.label}),e.jsxs("span",{className:"text-[11px] text-gray-400 flex items-center gap-1",children:[e.jsx(Tt,{size:10})," ",_.bu.railName]})]}),D?e.jsxs("span",{className:"inline-flex items-center gap-1.5 px-3 py-1 bg-emerald-50 text-emerald-700 border border-emerald-200 rounded-full text-xs font-bold",children:[e.jsx(pt,{size:12})," Balanced"]}):e.jsxs("span",{className:"inline-flex items-center gap-1.5 px-3 py-1 bg-amber-50 text-amber-700 border border-amber-200 rounded-full text-xs font-bold",children:[e.jsx(ve,{size:12})," Î ",En(I)]})]}
1299),e.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-5 gap-4",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-[11px] text-gray-400 uppercase",children:"POS Revenue"}),e.jsx("p",{className:"font-mono text-sm font-bold text-gray-900",children:En(_.revenue)})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-[11px] text-gray-400 uppercase",children:"Refunded"}),e.jsxs("p",{className:"font-mono text-sm font-bold text-red-500",children:["-",En(_.refundTotal)]})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-[11px] text-gray-400 uppercase",children:"Net Expected"}),e.jsx("p",{className:"font-mono text-sm font-bold text-gray-900",children:En(P)})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-[11px] text-gray-400 uppercase",children:"Financial Engine Net"}),e.jsx("p",{className:"font-mono text-sm font-bold text-gray-900",children:En(F)})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-[11px] text-gray-400 uppercase",children:"Card PaymentIntents"}),e.jsxs("p",{className:"font-mono text-sm font-bold text-gray-900",children:[_.cardTxs.length," ",e.jsxs("span",{className:"text-gray-400",children:["(",En(_.cardRevenue),")"]})]})]})]}),e.jsxs("p",{className:"text-[11px] text-gray-400 mt-3",children:["Card charges carry ",e.jsxs("span",{className:"font-mono",children:["business_unit=",_.bu.id]})," metadata on their Stripe PaymentIntents for account-level reconciliation.",_.bu.id==="cosmetics"&&" Cosmetics card sales settle to the dedicated Cosmetics Stripe account (nightly cosmetics-reconciliation-report also monitors that account).",_.bu.id==="institute"&&" Institute card sales settle via the isolated Institute rail (INSTITUTE_SECRET_KEY)."]})]},_.bu.id)})})]}),e.jsxs("div",{className:"mt-8 flex items-center gap-2 text-xs text-gray-400",children:[e.jsx(Ro,{size:12}),"Entity separation is enforced at the database level: pos_transactions, financial_records, pos_inventory, pos_services and pos_inventory_movements all carry a CHECK-constrained business_unit column."]})]})})},xxe="#0F172A",fxe="#DAA520",gxe="#0D9488",p1={name:"Personalized Skin & Wellness Consultation",shortName:"Consultation",ctaLabel:"Schedule Your Consultation",feeCents:9500,durationMinutes:60,withWhom:"Spa Director & ARNP clinical oversight",philosophy:"Every person's skin and wellness journey is unique. At Zorganics Med Spa, we begin with understanding your concerns, goals, lifestyle, and skin needs. Our specialists create a personalized treatment plan designed specifically for you.",paidModelMessage:"Your consultation is the first step in creating your personalized Zorganics treatment plan. A consultation fee is required to reserve your appointment. If you choose to proceed with your recommended treatment plan, your consultation fee will be applied as a credit toward your services.",inclusions:["A private, unhurried conversation about your concerns and goals","Professional skin health assessment and lifestyle review","Health history and contraindication review under ARNP oversight","A written personalized treatment plan prepared for you","Professional botanical skincare guidance for home care"]},yxe=`$${(p1.feeCents/100).toFixed(0)}`,bxe="https://d64gsuwffb70l.cloudfront.net/69caed6904ed6aca7682413a_1786429170840_ac6813c8.webp",vxe="Zorganics Med Spa â Personalized Skin & Wellness Care Begins With a Consultation. A specialist reviewing a personalized care plan on a tablet with a client in the Mind · Body · Skin restoration suite.",jxe={title:"Zorganics Med Spa",subtitle:"Personalized Skin & Wellness Care Begins With a Consultation",eyebrow:"Mind · Body · Skin · Restoration",intro:["Zorganics Med Spa brings together advanced esthetic technology, professional skin analysis, botanical skincare, and a holistic approach to beauty and wellness.","Rather than asking you to select a treatment before we understand your skin, every new client begins with a personalized consultation. We discuss your concerns, goals, lifestyle, current skincare routine, and treatment history, then evaluate your skin and develop recommendations designed specifically for you."],approachHeading:"Our Approach",approach:[{name:"Advanced Skin Analysis",description:"A professional evaluation helps us understand your skin before recommending services or home care."},{name:"Customized Treatment Planning",description:"Your recommendations may incorporate appropriate professional esthetic technologies and treatment approaches based on your individual goals and suitability."},{name:"Botanical Home Care",description:"Professional Zorganics skincare may be incorporated into your personalized home-care recommendations to support continuity between appointments."},{name:"Inside-Out Wellness Philosophy",description:"We consider the relationship between skin, lifestyle, self-care, and overall wellness as part of the consultation experience."}],planHeading:"Your Personalized Care Plan",planSteps:["Consult","Analyze","Recommend","Plan","Begin"],planBody:["Following your consultation, you receive recommendations for professional care and home care based on your individual needs. Treatment frequency, services, and pricing are established as part of your personalized care plan."],ctaLabel:"Book Your Med Spa Consultation",ctaFootnote:"Your consultation is the one appointment you book yourself. Everything that follows is scheduled with your specialist as part of your personalized care plan."},tle=[{id:"face",label:"Face Concerns",eyebrow:"Facial Rejuvenation & Skin Health",intro:"Tell us what you see in the mirror. Your specialist translates your concerns into a plan â never the other way around.",concerns:[{title:"Non-surgical facial rejuvenation",note:"A restorative, progressive approach to a refreshed, natural appearance â without surgery."},{title:"Fine lines and wrinkles",note:"Softening expression lines and early etching while supporting the skinâs own collagen."},{title:"Skin tightening and firmness",note:"Improving laxity along the jawline, cheeks, neck, and eye area."},{title:"Pigmentation and uneven skin tone",note:"Sun damage, melasma, and post-inflammatory discoloration addressed safely for every skin tone."},{title:"Acne and acne scarring",note:"Calming active breakouts, then remodeling the texture and marks they leave behind."},{title:"Skin texture and pores",note:"Smoothing rough texture, congestion, and enlarged pores for a refined finish."},{title:"Redness and sensitive skin",note:"Barrier-first care for reactive, rosacea-prone, and compromised skin."}]},{id:"body",label:"Body Concerns",eyebrow:"Contour, Firmness & Skin Quality",intro:"Body goals are personal and rarely one-dimensional. We assess the area, the skin quality, and your history together.",concerns:[{title:"Abdomen",note:"Firmness, skin quality, and contour concerns across the midsection."},{title:"Back",note:"Texture, congestion, and skin quality on hard-to-reach areas."},{title:"Thighs",note:"Smoothness, firmness, and contour refinement."},{title:"Arms",note:"Upper-arm laxity, tone, and skin texture."},{title:"Body tightening",note:"Progressive firming for areas where skin has lost elasticity."},{title:"Body contouring",note:"Shaping and refinement goals discussed realistically and honestly."}
1299,{title:"Skin texture improvement",note:"Softness, evenness, and overall skin quality head to toe."},{title:"Cellulite concerns",note:"An honest conversation about what can and cannot be improved."},{title:"Post-weight-loss skin changes",note:"Supportive planning for skin that has changed with your body."}]},{id:"wellness",label:"Wellness Concerns",eyebrow:"Education, Guidance & Lifestyle",intro:"Results are built between visits. Your plan always includes the education and home care that protect it.",concerns:[{title:"Skin health education",note:"Understanding your skin â how it behaves, why, and what it needs."},{title:"Professional skincare guidance",note:"A simple, sustainable regimen built around your real routine."},{title:"Botanical skincare recommendations",note:"100% vegan, non-toxic formulations from our Level 5 Organic Lab."},{title:"Lifestyle wellness support",note:"Sleep, stress, sun, hydration, and habits â the quiet drivers of skin health."}]}],sle=[{step:1,title:"Consultation",body:"Your paid consultation is reserved online. This is the only appointment you book yourself.",status:"live"},{step:2,title:"Assessment",body:"A professional skin and wellness assessment with health history review under ARNP oversight.",status:"in-visit"},{step:3,title:"Personalized Treatment Plan",body:"Your specialist prepares a written plan â sequenced, prioritized, and specific to you.",status:"in-visit"},{step:4,title:"Invoice",body:"Your plan is quoted transparently, with your consultation fee applied as a credit.",status:"prepared"},{step:5,title:"Treatment Scheduling",body:"Your specialist schedules your plan with you â never selected from an online menu.",status:"prepared"}],wxe=[{name:"Frida Emalange",title:"Spa Director",level:"director",focus:["Consultation & Assessment","Treatment Planning","Client Care"],credentials:["Licensed Esthetician â Washington","Spa Operations Leadership"]},{name:"Gert James, ARNP",title:"Advanced Registered Nurse Practitioner",level:"arnp",focus:["Clinical Oversight","Health Screening","Plan Approval"],credentials:["ARNP â Washington State","Registered Nurse â Washington"]}],Nxe=[{title:"Personalized, Never Prescriptive",body:"No two plans are alike. Your plan is written for your skin, your history, and your life â not pulled from a menu."},{title:"Wellness-Focused",body:"We treat skin as an organ of wellness. Sleep, stress, nutrition, and barrier health are part of every conversation."},{title:"Expert-Guided",body:"Every plan is prepared by our Spa Director and reviewed under ARNP clinical oversight before a single treatment is scheduled."},{title:"Botanical Integrity",body:"100% vegan, non-toxic, wild-harvested formulations from the Zorganics Level 5 Organic Lab support every plan."}],jN=[{name:"IPL Photofacial",description:"Intense pulsed light therapy for sun damage, rosacea, and uneven skin tone.",price_cents:35e3,duration_minutes:60,category:"laser",deviceType:"IPL Device",internalOnly:!0},{name:"Laser Hair Removal (Full Face)",description:"Diode laser technology for permanent hair reduction. Safe for all skin types.",price_cents:28e3,duration_minutes:45,category:"laser",deviceType:"Diode Laser",internalOnly:!0},{name:"Laser Skin Resurfacing",description:"Fractional CO2 laser for fine lines, wrinkles, and texture improvement.",price_cents:45e3,duration_minutes:75,category:"laser",deviceType:"Fractional CO2 Laser",internalOnly:!0},{name:"Laser Pigment Correction",description:"Targeted laser treatment for age spots, melasma, and hyperpigmentation.",price_cents:32e3,duration_minutes:45,category:"laser",deviceType:"Q-Switch Laser",internalOnly:!0},{name:"RF Skin Tightening â Face",description:"Radiofrequency energy for non-surgical face lifting and collagen stimulation.",price_cents:38e3,duration_minutes:60,category:"rf",deviceType:"RF Device",internalOnly:!0},{name:"RF Body Contouring",description:"Non-invasive radiofrequency body sculpting for stubborn areas and loose skin.",price_cents:55e3,duration_minutes:90,category:"rf",deviceType:"RF Body Device",internalOnly:!0},{name:"Micro-Needling with RF",description:"Fractional RF micro-needling for deep collagen induction, scars, pores, and laxity.",price_cents:48e3,duration_minutes:75,category:"rf",deviceType:"RF Micro-Needling",internalOnly:!0},{name:"LED Red Light Therapy",description:"Red wavelength (630-660nm) for anti-aging, collagen support, and healing.",price_cents:8500,duration_minutes:30,category:"led",deviceType:"LED Panel",internalOnly:!0},{name:"LED Blue Light Acne Treatment",description:"Blue wavelength (415nm) targeting acne-causing bacteria and inflammation.",price_cents:8500,duration_minutes:30,category:"led",deviceType:"LED Panel",internalOnly:!0},{name:"LED Full-Spectrum Facial",description:"Multi-wavelength LED session â red, blue, and near-infrared.",price_cents:12e3,duration_minutes:45,category:"led",deviceType:"LED Full-Spectrum",internalOnly:!0},{name:"Micro-current Facial Lift",description:"Low-level currents that stimulate facial muscles for a natural lift effect.",price_cents:18e3,duration_minutes:60,category:"microcurrent",deviceType:"Micro-current Device",internalOnly:!0},{name:"Micro-current Eye Contour",description:"Targeted micro-current for the under-eye area â puffiness and fine lines.",price_cents:12e3,duration_minutes:30,category:"microcurrent",deviceType:"Micro-current Device",internalOnly:!0},{name:"Micro-current Body Toning",description:"Muscle toning and body contouring using micro-current technology.",price_cents:25e3,duration_minutes:60,category:"microcurrent",deviceType:"Micro-current Body",internalOnly:!0},{name:"Dermaplaning + Organic Mask",description:"Medical-grade exfoliation with a Zorganics organic enzyme mask.",price_cents:15e3,duration_minutes:60,category:"facial",deviceType:"Manual + Organic",internalOnly:!0}
1299,{name:"Oncology Supportive Facial",description:"Gentle specialized facial for clients in or recovering from cancer treatment.",price_cents:15e3,duration_minutes:75,category:"oncology",deviceType:"Manual + Organic",internalOnly:!0},{name:"Oncology Scalp Treatment",description:"Soothing scalp care during treatment-related hair loss.",price_cents:12e3,duration_minutes:45,category:"oncology",deviceType:"Manual + Organic",internalOnly:!0},{name:"Oncology LED Recovery Session",description:"Low-dose LED calibrated for post-treatment skin recovery.",price_cents:1e4,duration_minutes:30,category:"oncology",deviceType:"LED (Low-Dose)",internalOnly:!0},{name:"Oncology Wellness Package (4 Sessions)",description:"Four-session oncology esthetics package â facial, scalp, LED, aromatherapy.",price_cents:42e3,duration_minutes:240,category:"oncology",deviceType:"Multi-Modality",internalOnly:!0}],Mm=[{id:"new_consultation",label:"New Consultation",short:"New",phase:"intake",hint:"Consultation reserved. Awaiting intake and specialist assignment.",color:"#1D4ED8",bg:"rgba(29,78,216,0.08)"},{id:"intake_received",label:"Intake Received",short:"Intake",phase:"intake",hint:"Confidential pre-visit intake submitted and ready for review.",color:"#0D9488",bg:"rgba(13,148,136,0.08)"},{id:"assessment_scheduled",label:"Assessment Scheduled",short:"Scheduled",phase:"assessment",hint:"Consultation date and time confirmed with the client.",color:"#7C3AED",bg:"rgba(124,58,237,0.08)"},{id:"assessment_completed",label:"Assessment Completed",short:"Assessed",phase:"assessment",hint:"Skin & wellness assessment complete. Notes recorded.",color:"#0369A1",bg:"rgba(3,105,161,0.08)"},{id:"plan_in_progress",label:"Treatment Plan In Progress",short:"Drafting",phase:"planning",hint:"Specialist is preparing the personalized treatment plan.",color:"#B45309",bg:"rgba(180,83,9,0.08)"},{id:"plan_sent",label:"Treatment Plan Sent",short:"Plan Sent",phase:"planning",hint:"Plan delivered to the client. Awaiting their decision.",color:"#DAA520",bg:"rgba(218,165,32,0.12)"},{id:"client_approved",label:"Client Approved",short:"Approved",phase:"scheduling",hint:"Client approved the plan. Ready for invoicing and scheduling.",color:"#15803D",bg:"rgba(21,128,61,0.08)"},{id:"treatment_scheduled",label:"Treatment Scheduled",short:"Booked",phase:"scheduling",hint:"Treatment series scheduled with the client by their specialist.",color:"#0F766E",bg:"rgba(15,118,110,0.08)"},{id:"completed",label:"Completed",short:"Completed",phase:"closed",hint:"Consultation journey complete.",color:"#334155",bg:"rgba(51,65,85,0.07)"},{id:"follow_up_required",label:"Follow-Up Required",short:"Follow-Up",phase:"closed",hint:"Needs outreach â no decision yet, or client asked for time.",color:"#BE123C",bg:"rgba(190,18,60,0.08)"}],jl=t=>Mm.find(s=>s.id===t)||Mm[0],Dd=tle.map(t=>({id:t.id,label:t.label.replace(" Concerns","").toUpperCase(),concerns:t.concerns.map(s=>s.title)}));Dd.flatMap(t=>t.concerns);const d$=t=>{var s;return((s=Dd.find(n=>n.concerns.includes(t)))==null?void 0:s.id)??null},u$=["Frida Emalange â Spa Director","Gert James, ARNP â Clinical Oversight","Unassigned"],nle=t=>({...t,concerns:Array.isArray(t.concerns)?t.concerns:[],intake_responses:t.intake_responses&&typeof t.intake_responses=="object"?t.intake_responses:{}});async function m$(){const{data:t,error:s}=await O.from("z_medspa_consultations").select("*").order("created_at",{ascending:!1});if(s)throw new Error(s.message);return(t||[]).map(nle)}async function ale(t){const{data:s,error:n}=await O.from("z_medspa_consultation_notes").select("*").eq("consultation_id",t).order("created_at",{ascending:!1});if(n)throw new Error(n.message);return s||[]}async function rle(t){const{data:s,error:n}=await O.from("z_medspa_consultation_status_log").select("*").eq("consultation_id",t).order("created_at",{ascending:!1});if(n)throw new Error(n.message);return s||[]}async function ile(t,s,n,a){const r={status:s,updated_at:new Date().toISOString()};s==="intake_received"&&(r.intake_received=!0);const{error:i}=await O.from("z_medspa_consultations").update(r).eq("id",t.id);if(i)throw new Error(i.message);await O.from("z_medspa_consultation_status_log").insert({consultation_id:t.
1299id,from_status:t.status,to_status:s,changed_by:n,changed_by_role:"med-spa-staff",reason:a||null})}async function ole(t,s,n,a){const{error:r}=await O.from("z_medspa_consultation_notes").insert({consultation_id:t,note_type:n,body:s.trim(),author:a,author_role:"med-spa-staff"});if(r)throw new Error(r.message)}async function lle(t,s){const{error:n}=await O.from("z_medspa_consultations").update({...s,updated_at:new Date().toISOString()}).eq("id",t);if(n)throw new Error(n.message)}async function cle(){const t={fromBookings:0,fromIntake:0,linkedIntake:0},s=await m$(),n=new Set(s.map(c=>c.source_booking_id).filter(Boolean)),a=new Set(s.map(c=>c.source_intake_id).filter(Boolean)),r=new Map(s.map(c=>[c.client_email.toLowerCase(),c])),{data:i}=await O.from("z_salon_bookings").select("id, booking_reference, service_name, service_price_cents, client_name, client_email, client_phone, campus, preferred_date, notes, status, business_unit, paid_at, created_at").eq("business_unit","med-spa").order("created_at",{ascending:!1}).limit(500),o=(i||[]).filter(c=>!n.has(c.id)).filter(c=>!String(c.client_email||"").startsWith("pending+"));if(o.length){const c=o.map(p=>({source_booking_id:p.id,booking_reference:p.booking_reference,client_name:p.client_name,client_email:String(p.client_email).toLowerCase(),client_phone:p.client_phone||null,campus:p.campus||null,consultation_date:p.preferred_date||null,consultation_fee_cents:p.service_price_cents??p1.feeCents,fee_paid:p.status==="paid"||p.status==="confirmed"||!!p.paid_at,summary_note:p.notes||null,status:"new_consultation"})),{error:u}=await O.from("z_medspa_consultations").insert(c);u||(t.fromBookings=c.length)}const{data:l}=await O.from("z_medspa_intake").select("*").order("created_at",{ascending:!1}).limit(500);for(const c of l||[]){if(a.has(c.id))continue;const u=String(c.client_email||"").toLowerCase(),p={treatment_interest:c.treatment_interest,skin_type:c.skin_type,treatment_goals:c.treatment_goals,health_flags:c.health_flags,medications:c.medications,allergies:c.allergies,oncology_care:c.oncology_care,oncology_notes:c.oncology_notes,sms_opt_in:c.sms_opt_in,submitted_at:c.created_at},m=r.get(u);if(m){const{error:h}=await O.from("z_medspa_consultations").update({source_intake_id:c.id,intake_responses:p,intake_received:!0,client_phone:m.client_phone||c.client_phone||null,campus:m.campus||c.campus||null,status:m.status==="new_consultation"?"intake_received":m.status,updated_at:new Date().toISOString()}).eq("id",m.id);h||(t.linkedIntake+=1);continue}const{error:x}=await O.from("z_medspa_consultations").insert({source_intake_id:c.id,booking_reference:c.booking_reference||null,client_name:c.client_name,client_email:u,client_phone:c.client_phone||null,campus:c.campus||null,consultation_date:c.appointment_date||null,intake_responses:p,intake_received:!0,status:"intake_received",summary_note:c.treatment_goals||null});x||(t.fromIntake+=1)}return t}function dle(t){const s={};Mm.forEach(r=>{s[r.id]=0}),t.forEach(r=>{s[r.status]=(s[r.status]||0)+1});const n=new Map;t.forEach(r=>r.concerns.forEach(i=>n.set(i,(n.get(i)||0)+1)));const a=new Set(["completed"]);return{total:t.length,active:t.filter(r=>!a.has(r.status)).length,awaitingIntake:t.filter(r=>!r.intake_received).length,planningStage:t.filter(r=>["plan_in_progress","plan_sent"].includes(r.status)).length,followUp:t.filter(r=>r.status==="follow_up_required").length,feeCreditCents:t.filter(r=>r.fee_paid&&!["completed"].includes(r.status)).reduce((r,i)=>r+(i.consultation_fee_cents||0),0),byStatus:s,topConcerns:[...n.entries()].map(([r,i])=>({concern:r,count:i,category:d$(r)||"other"})).sort((r,i)=>i.count-r.count).slice(0,8)}}const co=t=>`$${(t/100).toFixed(2)}`,Ix=[{id:"draft",label:"Draft",hint:"In preparation by the specialist. Not visible to the client.",color:"#475569",bg:"rgba(71,85,105,0.08)",editable:!0},{id:"under_review",label:"Under Review",hint:"Submitted for internal review under ARNP clinical oversight.",color:"#B45309",bg:"rgba(180,83,9,0.08)",editable:!0},{id:"ready_for_client",label:"Ready for Client",hint:"Reviewed and approved internally. Ready to present to the client.",color:"#DAA520",bg:"rgba(218,165,32,0.12)",editable:!1},{id:"client_approved",label:"Client Approved",hint:"Client approved the plan. Invoicing and scheduling follow (next phase).",color:"#15803D",bg:"rgba(21,128,61,0.08)",editable:!1},{id:"client_declined",label:"Client Declined",hint:"Client declined or asked for time. Record the context for follow-up.",color:"#BE123C",bg:"rgba(190,18,60,0.08)",editable:!1},{id:"completed",label:"Completed",hint:"Plan fully delivered. Retained for the client record.",color:"#0F766E",bg:"rgba(15,118,110,0.08)",editable:!1}],fo=t=>Ix.find(s=>s.id===t)||Ix[0],Eg=t=>Array.isArray(t)?t:[],uk=t=>({...t,goal_skin_concerns:Eg(t.goal_skin_concerns),goal_wellness:Eg(t.goal_wellness),wellness_products:Eg(t.wellness_products),pathway:Eg(t.pathway).map(s=>({treatment:s.treatment||"",category:s.category||"facial",sessions:Number(s.sessions)||1,frequency:s.frequency||"",timeline:s.timeline||"",provider_notes:s.provider_notes||"",unit_price_cents:Number(s.unit_price_cents)||0,duration_minutes:Number(s.duration_minutes)||0}))}),d4={laser:"Light & Laser",rf:"Radiofrequency & Micro-Needling",led:"LED Therapy",microcurrent:"Micro-current",facial:"Advanced Facial",oncology:"Oncology Supp
1299ortive Care",combination:"Combination Protocol"},u4=[...new Set(jN.map(t=>t.category))],ule=["Every 2 weeks","Every 3 weeks","Every 4 weeks","Every 6 weeks","Every 8 weeks","Monthly maintenance","As advised by specialist"],mle=["4 weeks","8 weeks","3 months","4 months","6 months","12 months","Ongoing maintenance"],ple=["Gentle botanical cleanser â morning and evening","Barrier-supporting botanical moisturizer","Daily broad-spectrum sun protection","Antioxidant botanical serum","Weekly organic enzyme mask","Hydration and sleep routine support","Seasonal skincare regimen review","Zorganics botanical body care"],hle=Dd.filter(t=>t.id!=="wellness").flatMap(t=>t.concerns);var TF;const p$=((TF=Dd.find(t=>t.id==="wellness"))==null?void 0:TF.concerns)??[],Rd=t=>t.reduce((s,n)=>s+(n.unit_price_cents||0)*(n.sessions||1),0),tt=t=>`$${((t||0)/100).toFixed(2)}`;async function xle(){const{data:t,error:s}=await O.from("z_medspa_treatment_plans").select("*").order("updated_at",{ascending:!1});if(s)throw new Error(s.message);return(t||[]).map(uk)}async function fle(t){const{data:s,error:n}=await O.from("z_medspa_treatment_plans").select("*").eq("consultation_id",t).order("created_at",{ascending:!1});if(n)throw new Error(n.message);return(s||[]).map(uk)}async function gle(t){const{data:s,error:n}=await O.from("z_medspa_plan_versions").select("*").eq("plan_id",t).order("version",{ascending:!1});if(n)throw new Error(n.message);return s||[]}async function yle(t){const{data:s,error:n}=await O.from("z_medspa_plan_audit").select("*").eq("plan_id",t).order("created_at",{ascending:!1});if(n)throw new Error(n.message);return s||[]}async function h1(t,s,n,a={}){await O.from("z_medspa_plan_audit").insert({plan_id:t,event:s,from_status:a.from??null,to_status:a.to??null,actor:n,actor_role:"med-spa-staff",detail:a.detail??null})}async function ble(t,s){const n=new Set(p$),a=t.concerns.filter(c=>!n.has(c)),r=t.concerns.filter(c=>n.has(c)),{data:i,error:o}=await O.from("z_medspa_treatment_plans").insert({consultation_id:t.id,client_name:t.client_name,client_email:t.client_email,provider:t.assigned_specialist,status:"draft",version:1,goal_skin_concerns:a,goal_wellness:r,assessment_consultation_notes:t.summary_note,consultation_credit_cents:t.fee_paid?t.consultation_fee_cents||p1.feeCents:0,created_by:s}).select("*").single();if(o)throw new Error(o.message);const l=uk(i);return await h1(l.id,"plan_created",s,{to:"draft",detail:`Draft created from consultation record · ${a.length+r.length} concern(s) carried forward`}),l}async function Fj(t,s,n){const{error:a}=await O.from("z_medspa_treatment_plans").update({...s,estimated_total_cents:Rd(s.pathway),updated_at:new Date().toISOString()}).eq("id",t);if(a)throw new Error(a.message);await h1(t,"plan_edited",n,{detail:`${s.pathway.length} treatment step(s) · estimate ${tt(Rd(s.pathway))}`})}async function vle(t,s,n,a){const r=(t.version||1)+1,{error:i}=await O.from("z_medspa_plan_versions").insert({plan_id:t.id,version:t.version||1,snapshot:{...s,estimated_total_cents:Rd(s.pathway),status:t.status},saved_by:n,note:a||null});if(i)throw new Error(i.message);const{error:o}=await O.from("z_medspa_treatment_plans").update({version:r,updated_at:new Date().toISOString()}).eq("id",t.id);if(o)throw new Error(o.message);return await h1(t.id,"version_saved",n,{detail:`Version ${t.version} archived${a?` â ${a}`:""}`}),r}async function jle(t,s,n,a){const r={status:s,updated_at:new Date().toISOString()};(s==="under_review"||s==="ready_for_client")&&(r.submitted_at=new Date().toISOString()),(s==="client_approved"||s==="client_declined")&&(r.decision_at=new Date().toISOString());const{error:i}=await O.from("z_medspa_treatment_plans").update(r).eq("id",t.id);if(i)throw new Error(i.message);await h1(t.id,"status_changed",n,{from:t.status,to:s,detail:a||null})}function wle(t){return{total:t.length,drafts:t.filter(s=>s.status==="draft").length,awaitingReview:t.filter(s=>s.status==="under_review").length,readyForClient:t.filter(s=>s.status==="ready_for_client").length,approved:t.filter(s=>s.status==="client_approved").length,declined:t.filter(s=>s.status==="client_declined").length,plannedValueCents:t.filter(s=>!["client_declined"].includes(s.status)).reduce((s,n)=>s+(n.estimated_total_cents||0),0)}}const h$=[{id:"approved",label:"Approved",hint:"Client approved the plan as presented.",color:"#15803D",bg:"rgba(21,128,61,0.08)"},{id:"discussion_requested",label:"Discussion Requested",hint:"Client would like to talk through the plan first.",color:"#B45309",bg:"rgba(180,83,9,0.08)"},{id:"declined",label:"Declined",hint:"Client declined for now â keep for follow-up outreach.",color:"#BE123C",bg:"rgba(190,18,60,0.08)"}],nb=t=>h$.find(s=>
1299s.id===t)||null,Nle=()=>{const t=new Uint8Array(24);return(globalThis.crypto||window.crypto).getRandomValues(t),Array.from(t).map(s=>s.toString(16).padStart(2,"0")).join("")},_le=t=>`/med-spa/plan/${t}`,Tj=t=>`${typeof window<"u"?window.location.origin:""}${_le(t)}`;async function kle(t,s){const n=t.share_token||Nle(),a=new Date().toISOString(),{error:r}=await O.from("z_medspa_treatment_plans").update({share_token:n,shared_at:a,status:"ready_for_client",submitted_at:t.submitted_at||a,updated_at:a}).eq("id",t.id);if(r)throw new Error(r.message);return await O.from("z_medspa_plan_audit").insert({plan_id:t.id,event:"plan_sent_for_client_review",from_status:t.status,to_status:"ready_for_client",actor:s,actor_role:"med-spa-staff",detail:`Secure client review link issued for plan v${t.version}`}),n}async function Sle(t,s){const{error:n}=await O.from("z_medspa_treatment_plans").update({share_token:null,updated_at:new Date().toISOString()}).eq("id",t.id);if(n)throw new Error(n.message);await O.from("z_medspa_plan_audit").insert({plan_id:t.id,event:"client_link_revoked",actor:s,actor_role:"med-spa-staff",detail:"Client review link revoked â plan returned to internal review"})}async function Cle(t,s,n,a={}){var l,c;const r=new Date().toISOString(),i={client_decision:s,client_decision_at:r,client_confirmation_name:((l=a.confirmationName)==null?void 0:l.trim())||t.client_name,client_decision_note:((c=a.note)==null?void 0:c.trim())||null,updated_at:r};s==="approved"&&(i.status="client_approved",i.decision_at=r,i.approved_version=t.version),s==="declined"&&(i.status="client_declined",i.decision_at=r);const{error:o}=await O.from("z_medspa_treatment_plans").update(i).eq("id",t.id);if(o)throw new Error(o.message);await O.from("z_medspa_plan_audit").insert({plan_id:t.id,event:`client_${s}`,from_status:t.status,to_status:i.status||t.status,actor:n,actor_role:"med-spa-staff",detail:`Recorded on the client's behalf${a.note?` â ${a.note}`:""}`})}const wN=[{id:"prepared",label:"Prepared",color:"#475569",bg:"rgba(71,85,105,0.08)",hint:"Approved plan converted into an internal investment summary."},{id:"ready_for_invoice",label:"Ready for Invoice",color:"#DAA520",bg:"rgba(218,165,32,0.12)",hint:"Reviewed and cleared for the future invoicing phase."},{id:"handed_off",label:"Handed Off",color:"#0F766E",bg:"rgba(15,118,110,0.08)",hint:"Passed to the business office. No payment taken here."},{id:"void",label:"Void",color:"#BE123C",bg:"rgba(190,18,60,0.08)",hint:"Superseded or cancelled. Retained for audit."}],$x=t=>wN.find(s=>s.id===t)||wN[0],x$=t=>t.map(s=>({description:`${s.treatment}${s.frequency?` · ${s.frequency}`:""}`,sessions:s.sessions||1,unit_price_cents:s.unit_price_cents||0,total_cents:(s.unit_price_cents||0)*(s.sessions||1)}));async function Ale(){const{data:t,error:s}=await O.from("z_medspa_plan_invoice_prep").select("*").order("created_at",{ascending:!1});if(s)throw new Error(s.message);return(t||[]).map(n=>({...n,line_items:Array.isArray(n.line_items)?n.line_items:[]}))}async function Ele(t){const{data:s,error:n}=await O.from("z_medspa_plan_invoice_prep").select("*").eq("plan_id",t).order("created_at",{ascending:!1}).limit(1).maybeSingle();if(n)throw new Error(n.message);return s?{...s,line_items:Array.isArray(s.line_items)?s.line_items:[]}:null}async function Fle(t,s,n){const a=x$(t.pathway),r=Rd(t.pathway),i=t.consultation_credit_cents||0,{data:o,error:l}=await O.from("z_medspa_plan_invoice_prep").insert({plan_id:t.id,consultation_id:t.consultation_id,client_name:t.client_name,client_email:t.client_email,client_phone:null,provider:t.provider,line_items:a,subtotal_cents:r,consultation_credit_cents:i,total_due_cents:Math.max(0,r-i),approved_version:t.approved_version||t.version,approval_recorded_at:t.client_decision_at||t.decision_at,client_confirmation_name:t.client_confirmation_name||null,status:"prepared",prepared_by:s}).select("*").single();if(l)throw new Error(l.message);return await O.from("z_medspa_plan_audit").insert({plan_id:t.id,event:"invoice_prepared",actor:s,actor_role:"med-spa-staff",detail:`Investment summary prepared · ${a.length} line item(s) · ${tt(Math.max(0,r-i))} due (no payment processed)`}),{...o,line_items:Array.isArray(o.line_items)?o.line_items:[]}}async function Tle(t,s,n,a,r){const{error:i}=await O.from("z_medspa_plan_invoice_prep").update({status:n,handoff_note:(r==null?void 0:r.trim())||t.handoff_note,updated_at:new Date().toISOString()}).eq("id",t.id);if(i)throw new Error(i.message);await O.from("z_medspa_plan_audit").insert({plan_id:s,event:"invoice_prep_status_changed",actor:a,actor_role:"med-spa-staff",detail:`Invoice preparation â ${$x(n).label}${r?` â ${r}`:""}`})}const NN=[{id:"to_schedule",label:"To Schedule",color:"#B45309",bg:"rgba(180,83,9,0.08)",hint:"Approved and waiting to be booked with the client."},{id:"scheduled",label:"Scheduled",color:"#0D9488",bg:"rgba(13,148,136,0.08)",hint:"Appointment agreed. Booking stays in the existing booking system."},{id:"completed",label:"Completed",color:"#15803D",bg:"rgba(21,128,61,0.08)",hint:"Session delivered â forms the client treatment history."},{id:"follow_up",label:"Follow-Up",color:"#DAA520",bg:"rgba(218,165,32,0.12)",hint:"Post-treatment follow-up care outstanding."},{id:"cancelled",label:"Cancelled",color:"#BE123C",bg:"rgba(190,18,60,0.08)",hint:"Session cancelled. Retained for the client record."}],f$=t=>NN.find(s=>s.id===t)||NN[0];async function Ple(t){const{data:s,error:n}=await O.from("z_medspa_plan_treatments").select("*").eq("plan_id",t).order("created_at",{ascending:!0});if(n)throw new Error(n.message);return s||[]}async function Dle(){const{data:t,error:s}=await O.from("z_medspa_plan_treatments").select("*").order("created_at",{ascending:!1});if(s)throw new Error(s.message);return t||[]}async function Rle(t,s){const n=[];if(t.pathway.forEach(r=>{const i=Math.max(1,r.sessions||1);for(let o=1;o<=i;o++)n.push({plan_id:t.id,consultation_id:t.consultation_id,client_name:t.client_name,treatment:r.treatment,category:r.category||null,session_number:o,total_sessions:i,recommended_frequency:r.frequency||null,target_window:r.timeline||null,duration_minutes:r.duration_minutes||0,provider:t.provider,status:"to_schedule",notes:r.provider_notes||null})}),n.length===0)return 0;const{error:a}=await O.from("z_medspa_plan_treatments").insert(n);if(a)throw new Error(a.message);return await O.from("z_medspa_plan_audit").insert({plan_id:t.id,event:"treatment_queue_generated",actor:s,actor_role:"med-spa-staff",detail:`${n.length} session(s) queued for scheduling (no appointments created)`}),n.length}async function m4(t,s,n){const a={...s,updated_at:new Date().toISOString()};s.status==="completed"&&!t.completed_at&&(a.completed_at=new Date().toISOString());const{error:r}=await O.from("z_medspa_plan_treatments").update(a).eq("id",t.id);if(r)throw new Error(r.message);s.status&&s.status!==t.status&&await O.from("z_medspa_plan_audit").insert({plan_id:t.plan_id,event:"treatment_session_updated",actor:n,actor_role:"med-spa-staff",detail:`${t.treatment} session ${t.session_number}/${t.total_sessions} â ${f$(s.status).label}`})}function Ile(t,s,n){const a=t;return{awaitingClient:t.filter(r=>r.status==="ready_for_client"&&!r.client_decision).length,clientViewed:a.filter(r=>r.client_viewed_at&&!r.client_decision).length,approved:a.filter(r=>r.client_decision==="approved").length,discussionRequested:a.filter(r=>r.client_decision==="discussion_requested").length,declined:a.filter(r=>r.client_decision==="declined").length,invoicesPrepared:s.filter(r=>r.status!=="void").length,readyToInvoice:s.filter(r=>r.status==="ready_for_invoice").length,sessionsToSchedule:n.filter(r=>r.status==="to_schedule").length,sessionsScheduled:n.filter(r=>r.status==="scheduled").length,sessionsCompleted:n.filter(r=>r.status==="completed").length,approvedValueCents:s.filter(r=>r.status!=="void").reduce((r,i)=>r+(i.total_due_cents||0),0)}}async function $le(t){const{data:s,error:n}=await O.functions.invoke("medspa-plan-review",{body:{action:"get",token:t}});if(n&&!s)throw new Error("Unable to load your plan. Please check your link or contact your specialist.");if(!(s!=null&&s.success))throw new Error((s==null?void 0:s.error)||"Unable to load your plan.");return s.plan}async function zle(t,s,n,a){const{data:r,error:i}=await O.functions.invoke("medspa-plan-review",{body:{action:"decide",token:t,decision:s,confirmation_name:n,note:a}});
1299if(i&&!r)throw new Error("Unable to record your response. Please try again.");if(!(r!=null&&r.success))throw new Error((r==null?void 0:r.error)||"Unable to record your response.");return{message:r.message,plan:r.plan}}const p4=[{id:"not_sent",label:"Not Sent",color:"#64748B",bg:"rgba(100,116,139,0.08)"},{id:"sent",label:"Plan Sent",color:"#DAA520",bg:"rgba(218,165,32,0.12)"},{id:"viewed",label:"Opened by Client",color:"#0D9488",bg:"rgba(13,148,136,0.08)"},{id:"responded",label:"Client Responded",color:"#15803D",bg:"rgba(21,128,61,0.08)"}],g$=t=>p4.find(s=>s.id===t)||p4[0];function y$(t){const s=t;return s.client_decision?"responded":s.client_viewed_at?"viewed":s.last_emailed_at||s.communication_status==="sent"?"sent":"not_sent"}async function Lle(t){const{data:s,error:n}=await O.from("z_medspa_plan_communications").select("*").eq("plan_id",t).order("created_at",{ascending:!1});if(n)throw new Error(n.message);return s||[]}async function Ole(t,s,n={}){const{data:a,error:r}=await O.functions.invoke("medspa-send-plan-email",{body:{plan_id:t.id,recipient:n.recipient||t.client_email,message_note:n.note||"",sent_by:s,site_url:typeof window<"u"?window.location.origin:void 0}});if(r&&!a)throw new Error("Unable to send the plan email. Please try again.");if(!(a!=null&&a.success))throw new Error((a==null?void 0:a.error)||"Unable to send the plan email.");return{recipient:a.recipient,sent_at:a.sent_at}}const ab=[{id:"issued",label:"Invoice Generated",color:"#475569",bg:"rgba(71,85,105,0.08)",hint:"Generated from the approved plan. Pricing locked to the approved version."},{id:"sent",label:"Sent to Client",color:"#DAA520",bg:"rgba(218,165,32,0.12)",hint:"Secure payment link issued on the existing Zorganics payment rail."},{id:"partially_paid",label:"Partially Paid",color:"#B45309",bg:"rgba(180,83,9,0.08)",hint:"A deposit or partial payment has been recorded."},{id:"paid",label:"Payment Completed",color:"#15803D",bg:"rgba(21,128,61,0.08)",hint:"Paid in full â treatment scheduling is ready."},{id:"void",label:"Void",color:"#BE123C",bg:"rgba(190,18,60,0.08)",hint:"Superseded or cancelled. Retained for audit."}],zx=t=>ab.find(s=>s.id===t)||ab[0],x1=t=>({...t,line_items:Array.isArray(t.line_items)?t.line_items:[]});async function Mle(){const{data:t,error:s}=await O.from("z_medspa_plan_invoices").select("*").order("created_at",{ascending:!1});if(s)throw new Error(s.message);return(t||[]).map(x1)}async function Ble(t){const{data:s,error:n}=await O.from("z_medspa_plan_invoices").select("*").eq("plan_id",t).neq("status","void").order("created_at",{ascending:!1}).limit(1).maybeSingle();if(n)throw new Error(n.message);return s?x1(s):null}const Ule=()=>`ZMS-${new Date().getFullYear()}-${Math.random().toString(36).slice(2,7).toUpperCase()}`;async function qle(t,s,n){var p;const a=t;if(a.client_decision!=="approved"&&t.status!=="client_approved")throw new Error("An invoice can only be generated from a client-approved plan.");const r=(p=s==null?void 0:s.line_items)!=null&&p.length?s.line_items:x$(t.pathway),i=(s==null?void 0:s.subtotal_cents)??Rd(t.pathway),o=(s==null?void 0:s.consultation_credit_cents)??(t.consultation_credit_cents||0),l=(s==null?void 0:s.total_due_cents)??Math.max(0,i-o),{data:c,error:u}=await O.from("z_medspa_plan_invoices").insert({plan_id:t.id,prep_id:(s==null?void 0:s.id)||null,consultation_id:t.consultation_id,invoice_number:Ule(),client_name:t.client_name,client_email:t.client_email,client_phone:(s==null?void 0:s.client_phone)||null,provider:t.provider,line_items:r,subtotal_cents:i,consultation_credit_cents:o,total_due_cents:l,amount_paid_cents:0,approved_version:a.approved_version||t.version,approval_recorded_at:a.client_decision_at||t.decision_at,client_confirmation_name:a.client_confirmation_name||null,status:"issued",issued_by:n}).select("*").single();if(u)throw new Error(u.message);return await O.from("z_medspa_plan_audit").insert({plan_id:t.id,event:"invoice_generated",actor:n,actor_role:"med-spa-staff",detail:`Invoice ${c.invoice_number} generated from approved plan v${a.approved_version||t.version} · ${tt(l)} due`}),x1(c)}async function Wle(t,s){const n=Math.max(0,t.total_due_cents-(t.amount_paid_cents||0));if(n<100)throw new Error("Outstanding balance is below the minimum charge amount.");const{data:a,error:r}=await O.functions.invoke("create-medspa-checkout",{body:{serviceName:`Personalized Skin & Wellness Plan â Invoice ${t.invoice_number}`,priceCents:n,category:"treatment-plan",businessUnit:"med-spa",clientName:t.client_name,clientEmail:t.client_email||"",clientPhone:t.client_phone||""}});if(r&&!a)throw new Error("Unable to reach the payment rail. Please try again.");if(!(a!=null&&a.success)||!(a!=null&&a.checkout_url))throw new Error((a==null?void 0:a.error)||"Unable to create the payment link.");const{data:i,error:o}=await O.from("z_medspa_plan_invoices").update({status:"sent",payment_rail:"zorganics-medspa-stripe",checkout_url:a.checkout_url,payment_reference:a.checkout_session_id||null,booking_reference:a.booking_reference||null,updated_at:new Date().toISOString()}).eq("id",t.id).select("*").single();if(o)throw new Error(o.message);return await O.from("z_medspa_plan_audit").insert({plan_id:t.plan_id,event:"invoice_payment_link_issued",actor:s,actor_role:"med-spa-staff",detail:`Secure payment link issued on the existing Med Spa payment rail · ${tt(n)} · ref ${a.booking_reference||a.checkout_session_id||"â"}`}),x1(i)}async function Hle(t,s,n,a={}){var c,u,p;const r=Math.max(0,(t.amount_paid_cents||0)+Math.max(0,Math.round(s))),i=r>=t.total_due_cents,o=new Date().toISOString(),{error:l}=await O.from("z_medspa_plan_invoices").update({amount_paid_cents:r,status:i?"paid":"partially_paid",paid_at:i?o:t.paid_at,payment_reference:((c=a.reference)==null?void 0:c.trim())||t.payment_reference,payment_rail:((u=a.rail)==null?void 0:u.trim())||t.payment_rail||"zorganics-medspa-stripe",notes:((p=a.note)==null?void 0:p.trim())||t.notes,updated_at:o}).eq("id",t.id);if(l)throw new Error(l.message);await O.from("z_medspa_plan_audit").insert({plan_id:t.plan_id,event:i?"invoice_paid":"invoice_partial_payment",actor:n,actor_role:"med-spa-staff",detail:`${tt(s)} recorded on invoice ${t.invoice_number}${a.reference?` · ref ${a.reference}`:""} · ${tt(r)} of ${tt(t.total_due_cents)}${i?" â treatment scheduling ready":""}`})}async function Gle(t,s,n,a){const{error:r}=await O.from("z_medspa_plan_invoices").update({status:s,notes:t.notes,updated_at:new Date().toISOString()}).eq("id",t.id);if(r)throw new Error(r.message);await O.from("z_medspa_plan_audit").insert({plan_id:t.plan_id,event:"invoice_status_changed",actor:n,actor_role:"med-spa-staff",detail:`Invoice ${t.invoice_number} â ${zx(s).label}`})}async function Vle(t,s,n){const{error:a}=await O.from("z_medspa_plan_treatments").update({progress_notes:s.progress_notes??t.progress_notes??null,follow_up_recommendation:s.follow_up_recommendation??t.follow_up_recommendation??null,home_care_note:s.home_care_note??t.home_care_note??null,follow_up_due:s.follow_up_due||t.follow_up_due||null,provider:s.provider??t.provider,recorded_by:n,updated_at:new Date().toISOString()}).eq("id",t.id);if(a)throw new Error(a.message);await O.from("z_medspa_plan_audit").insert({plan_id:t.plan_id,event:"treatment_note_recorded",actor:n,actor_role:"med-spa-staff",detail:`Progress note recorded for ${t.treatment} session ${t.session_number}/${t.total_sessions}`})}function Zle(t,s,n,a){const r=t,i=a.find(c=>c.status==="sent"),o=n.filter(c=>c.status==="completed"),l=n.filter(c=>c.status==="follow_up"||c.follow_up_recommendation);return[{key:"consultation",label:"Consultation & Assessment",detail:t.provider?`With ${String(t.provider).split("â")[0].trim()}`:"Personalized assessment completed",at:t.created_at,complete:!0}
1299,{key:"plan",label:"Personalized Skin & Wellness Plan",detail:`${t.pathway.length} recommended step(s) · v${t.version}`,at:t.submitted_at||t.updated_at,complete:t.pathway.length>0},{key:"communication",label:"Plan Communication",detail:i?`Emailed to ${i.recipient}${r.client_viewed_at?" · opened by client":" · not yet opened"}`:r.share_token?"Private link issued (not emailed)":"Not yet sent",at:r.last_emailed_at||r.shared_at||null,complete:!!(r.last_emailed_at||r.shared_at)},{key:"approval",label:"Client Approval",detail:r.client_decision==="approved"?`Approved v${r.approved_version||t.version}${r.client_confirmation_name?` by ${r.client_confirmation_name}`:""}`:r.client_decision==="discussion_requested"?"Discussion requested":r.client_decision==="declined"?"Declined for now":"Awaiting client response",at:r.client_decision_at||null,complete:r.client_decision==="approved"},{key:"invoice",label:"Invoice & Payment",detail:s?`${s.invoice_number} · ${tt(s.amount_paid_cents)} of ${tt(s.total_due_cents)} · ${zx(s.status).label}`:"Not yet generated",at:(s==null?void 0:s.paid_at)||(s==null?void 0:s.created_at)||null,complete:(s==null?void 0:s.status)==="paid"}
1299,{key:"treatment",label:"Treatment Delivery",detail:n.length?`${o.length} of ${n.length} session(s) completed`:"No sessions queued yet",at:o.length?o[o.length-1].completed_at:null,complete:n.length>0&&o.length===n.length},{key:"follow_up",label:"Follow-Up Care",detail:l.length?`${l.length} follow-up recommendation(s) on record`:"No follow-up care recorded yet",at:l.length?l[0].updated_at:null,complete:l.length>0}]}function Yle(t,s,n){const a=s.filter(r=>r.status!=="void");return{plansEmailed:t.filter(r=>r.last_emailed_at).length,openedByClient:t.filter(r=>r.client_viewed_at).length,invoicesGenerated:a.length,awaitingPayment:a.filter(r=>r.status==="issued"||r.status==="sent"||r.status==="partially_paid").length,paidInFull:a.filter(r=>r.status==="paid").length,collectedCents:a.reduce((r,i)=>r+(i.amount_paid_cents||0),0),outstandingCents:a.reduce((r,i)=>r+Math.max(0,(i.total_due_cents||0)-(i.amount_paid_cents||0)),0),sessionsCompleted:n.filter(r=>r.status==="completed").length,followUpsDue:n.filter(r=>r.status==="follow_up").length}}const Kle="#0F172A",Pj="#64748B",Qle=({records:t,onOpen:s})=>e.jsx("div",{className:"flex gap-4 overflow-x-auto pb-4",children:Mm.map(n=>{const a=t.filter(r=>r.status===n.id);return e.jsxs("div",{className:"min-w-[260px] w-[260px] shrink-0",children:[e.jsxs("div",{className:"rounded-t-xl px-3.5 py-2.5 flex items-center justify-between",style:{background:n.bg,borderTop:`2px solid ${n.color}`},children:[e.jsx("p",{className:"text-[10.5px] font-bold uppercase tracking-[0.12em]",style:{color:n.color},children:n.label}),e.jsx("span",{className:"text-[10px] font-bold px-1.5 py-0.5 rounded-full",style:{background:n.color,color:"#fff"},children:a.length})]}),e.jsx("div",{className:"rounded-b-xl p-2 space-y-2 min-h-[140px]",style:{background:"#F8FAFC",border:"1px solid #EEF2F7",borderTop:"none"},children:a.length===0?e.jsx("p",{className:"text-[11px] px-2 py-4 text-center",style:{color:"#94A3B8"},children:"No clients in this stage"}):a.map(r=>e.jsxs("button",{onClick:()=>s(r),className:"w-full text-left rounded-lg p-3 bg-white transition-all hover:shadow-md",style:{border:"1px solid #E7EDF3"},children:[e.jsxs("div",{className:"flex items-start justify-between gap-2",children:[e.jsx("p",{className:"text-[13px] font-bold leading-snug",style:{color:Kle},children:r.client_name}),e.jsx(Nr,{size:13,style:{color:"#CBD5E1"}})]}),e.jsxs("p",{className:"text-[10.5px] mt-1 flex items-center gap-1 truncate",style:{color:Pj},children:[e.jsx(Ye,{size:9})," ",r.client_email]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-x-2.5 gap-y-1 mt-2",children:[r.campus&&e.jsxs("span",{className:"text-[10px] flex items-center gap-1",style:{color:Pj},children:[e.jsx(zt,{size:9})," ",r.campus]}),r.consultation_date&&e.jsxs("span",{className:"text-[10px] flex items-center gap-1",style:{color:Pj},children:[e.jsx(Ii,{size:9})," ",new Date(r.consultation_date+"T00:00:00").toLocaleDateString()]}),r.fee_paid&&e.jsxs("span",{className:"text-[10px] flex items-center gap-1 font-semibold",style:{color:"#15803D"},children:[e.jsx(Vl,{size:9})," ",co(r.consultation_fee_cents)]}),r.intake_received&&e.jsxs("span",{className:"text-[10px] flex items-center gap-1 font-semibold",style:{color:"#0F766E"},children:[e.jsx(Kt,{size:9})," Intake"]})]}),r.concerns.length>0&&e.jsxs("div",{className:"flex flex-wrap gap-1 mt-2",children:[r.concerns.slice(0,2).map(i=>e.jsx("span",{className:"text-[9.5px] px-1.5 py-0.5 rounded-full",style:{background:"#F1F5F9",color:"#475569"},children:i.length>22?`${i.slice(0,22)}â¦`:i},i)),r.concerns.length>2&&e.jsxs("span",{className:"text-[9.5px] px-1.5 py-0.5 rounded-full",style:{background:"#F1F5F9",color:"#475569"},children:["+",r.concerns.length-2]})]}),r.assigned_specialist&&e.jsx("p",{className:"text-[10px] mt-2 font-semibold",style:{color:jl(r.status).color},children:r.assigned_specialist.split("â")[0].trim()})]},r.id))})]},n.id)})}),Tn="#0F172A",hs="#64748B",Xi="#0D9488",Jle={"pregnant-nursing":"Pregnant or nursing","photosensitizing-meds":"Photosensitizing medications","active-skin-condition":"Active skin condition in area","recent-procedures":"Procedure/peel within 90 days","pacemaker-implants":"Pacemaker / implants","keloid-scarring":"History of keloid scarring","cancer-treatment":"Cancer treatment (current/recent)"}
1299,pu="block text-[10px] font-bold uppercase tracking-[0.16em] mb-1.5",Sc="w-full px-3 py-2.5 rounded-lg text-sm bg-white focus:outline-none focus:ring-2 focus:ring-teal-500/30",Cc={border:"1px solid #E2E8F0",color:Tn},Xle=({record:t,actor:s,onClose:n,onSaved:a,onOpenPlan:r,planRefreshKey:i=0})=>{const[o,l]=d.useState([]),[c,u]=d.useState([]),[p,m]=d.useState([]),[x,h]=d.useState(!0),[y,v]=d.useState(!1),[g,N]=d.useState(null),[b,f]=d.useState(null),[j,S]=d.useState(t.concerns),[w,_]=d.useState(t.assigned_specialist||"Unassigned"),[C,E]=d.useState(t.consultation_date||""),[P,F]=d.useState(t.follow_up_on||""),[I,D]=d.useState(t.summary_note||""),[L,V]=d.useState(""),[B,A]=d.useState("assessment"),[z,M]=d.useState(""),R=t.intake_responses||{},T=Array.isArray(R.health_flags)?R.health_flags:[],U=async()=>{h(!0);try{const[Y,J,te]=await Promise.all([ale(t.id),rle(t.id),fle(t.id)]);l(Y),u(J),m(te)}catch(Y){f(Y.message)}h(!1)};d.useEffect(()=>{U()},[t.id,i]);const q=Y=>S(J=>J.includes(Y)?J.filter(te=>te!==Y):[...J,Y]),H=Y=>{N(Y),f(null),window.setTimeout(()=>N(null),3200)},G=async()=>{v(!0),f(null);try{const Y=new Set(j.map(J=>{var te;return(te=Dd.find(pe=>pe.concerns.includes(J)))==null?void 0:te.id}).filter(Boolean));await lle(t.id,{concerns:j,assigned_specialist:w==="Unassigned"?null:w,consultation_date:C||null,follow_up_on:P||null,summary_note:I.trim()||null,focus_group:Y.size===0?null:Y.size>1?"multiple":[...Y][0]}),H("Consultation record saved."),a()}catch(Y){f(Y.message)}v(!1)},W=async()=>{if(L.trim().length<3){f("Please write a note before saving.");return}v(!0),f(null);try{await ole(t.id,L,B,s),V(""),H("Assessment note added."),await U()}catch(Y){f(Y.message)}v(!1)},X=async Y=>{if(Y!==t.status){v(!0),f(null);try{await ile(t,Y,s,z.trim()||void 0),M(""),H(`Status updated to ${jl(Y).label}.`),a(),await U()}catch(J){f(J.message)}v(!1)}},Q=async()=>{v(!0),f(null);try{const Y=await ble({...t,concerns:j,assigned_specialist:w==="Unassigned"?null:w,summary_note:I||t.summary_note},s);await U(),a(),r(Y)}catch(Y){f(Y.message)}v(!1)},K=jl(t.status),se=["assessment_completed","plan_in_progress","plan_sent","client_approved","treatment_scheduled","completed"].includes(t.status);return e.jsxs("div",{className:"fixed inset-0 z-50 flex",role:"dialog","aria-modal":"true","aria-label":"Consultation record",children:[e.jsx("button",{className:"flex-1 bg-black/45 backdrop-blur-sm",onClick:n,"aria-label":"Close panel"}),e.jsxs("div",{className:"w-full max-w-2xl h-full overflow-y-auto bg-white shadow-2xl",children:[e.jsxs("div",{className:"sticky top-0 z-10 px-6 py-5 text-white",style:{background:"linear-gradient(135deg, #0F172A, #134E4A)"},children:[e.jsxs("div",{className:"flex items-start justify-between gap-4",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-[10px] font-bold uppercase tracking-[0.28em] text-white/55 mb-1.5",children:"Med Spa Consultation Record"}),e.jsx("h2",{className:"text-xl font-bold tracking-tight",children:t.client_name}),e.jsxs("p",{className:"text-[11px] text-white/60 mt-1",children:[t.booking_reference||"No booking reference"," · ",t.campus||"Campus TBD"]})]}),e.jsx("button",{onClick:n,className:"p-2 rounded-lg hover:bg-white/10","aria-label":"Close",children:e.jsx(Ke,{size:18})})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2 mt-4",children:[e.jsx("span",{className:"px-2.5 py-1 rounded-full text-[10px] font-bold uppercase tracking-wider bg-white/12",children:K.label}),e.jsx("span",{className:"px-2.5 py-1 rounded-full text-[10px] font-bold uppercase tracking-wider",style:{background:t.fee_paid?"rgba(34,197,94,0.22)":"rgba(255,255,255,0.12)"},children:t.fee_paid?`Fee Paid · ${co(t.consultation_fee_cents)} credit`:"Fee Pending"}),e.jsx("span",{className:"px-2.5 py-1 rounded-full text-[10px] font-bold uppercase tracking-wider",style:{background:t.intake_received?"rgba(13,148,136,0.3)":"rgba(255,255,255,0.12)"},children:t.intake_received?"Intake Received":"Intake Pending"})]})]}),e.jsxs("div",{className:"px-6 py-6 space-y-6",children:[g&&e.jsxs("div",{className:"rounded-xl px-4 py-3 text-xs font-semibold flex items-center gap-2",style:{background:"rgba(13,148,136,0.08)",border:"1px solid rgba(13,148,136,0.25)",color:"#0F766E"},children:[e.jsx(xt,{size:14})," ",g]}),b&&e.jsx("div",{className:"rounded-xl px-4 py-3 text-xs font-semibold",style:{background:"rgba(220,38,38,0.06)",border:"1px solid rgba(220,38,38,0.25)",color:"#B91C1C"},children:b}),e.jsxs("section",{className:"rounded-2xl p-5",style:{border:"1px solid #E2E8F0"},children:[e.jsxs("h3",{className:"text-[11px] font-bold uppercase tracking-[0.18em] mb-4 flex items-center gap-2",style:{color:Tn},children:[e.jsx(yr,{size:13,style:{color:Xi}})," Client & Contact"]}),e.jsxs("div",{className:"grid sm:grid-cols-2 gap-3 text-sm",style:{color:Tn},children:[e.jsxs("p",{className:"flex items-center gap-2",children:[e.jsx(Ye,{size:13,style:{color:hs}})," ",t.client_email]}),e.jsxs("p",{className:"flex items-center gap-2",children:[e.jsx(Qt,{size:13,style:{color:hs}})," ",t.client_phone||"â"]}),e.jsxs("p",{className:"flex items-center gap-2",children:[e.jsx(zt,{size:13,style:{color:hs}})," ",t.campus||"â"]}
1299),e.jsxs("p",{className:"flex items-center gap-2",children:[e.jsx(Ii,{size:13,style:{color:hs}})," Received ",new Date(t.created_at).toLocaleDateString()]})]}),e.jsxs("div",{className:"grid sm:grid-cols-2 gap-4 mt-4",children:[e.jsxs("div",{children:[e.jsx("label",{className:pu,style:{color:hs},children:"Assigned Specialist"}),e.jsx("select",{className:Sc,style:Cc,value:w,onChange:Y=>_(Y.target.value),children:u$.map(Y=>e.jsx("option",{value:Y,children:Y},Y))})]}),e.jsxs("div",{children:[e.jsx("label",{className:pu,style:{color:hs},children:"Consultation Date"}),e.jsx("input",{type:"date",className:Sc,style:Cc,value:C,onChange:Y=>E(Y.target.value)})]}),e.jsxs("div",{children:[e.jsx("label",{className:pu,style:{color:hs},children:"Follow-Up On"}),e.jsx("input",{type:"date",className:Sc,style:Cc,value:P,onChange:Y=>F(Y.target.value)})]}),e.jsxs("div",{children:[e.jsx("label",{className:pu,style:{color:hs},children:"Focus Areas Selected"}),e.jsx("p",{className:"px-3 py-2.5 rounded-lg text-sm",style:{background:"#F8FAFC",color:Tn},children:t.focus_group?t.focus_group.toUpperCase():"To be identified"})]})]})]}),e.jsxs("section",{className:"rounded-2xl p-5",style:{border:"1px solid #E2E8F0"},children:[e.jsxs("h3",{className:"text-[11px] font-bold uppercase tracking-[0.18em] mb-1 flex items-center gap-2",style:{color:Tn},children:[e.jsx(mn,{size:13,style:{color:Xi}})," Concern Tracking"]}),e.jsx("p",{className:"text-[11px] mb-4",style:{color:hs},children:"Record every concern raised in consultation. These carry forward into the future treatment-plan builder."}),e.jsx("div",{className:"space-y-4",children:Dd.map(Y=>e.jsxs("div",{children:[e.jsx("p",{className:"text-[10px] font-bold uppercase tracking-[0.2em] mb-2",style:{color:Xi},children:Y.label}),e.jsx("div",{className:"flex flex-wrap gap-2",children:Y.concerns.map(J=>{const te=j.includes(J);return e.jsxs("button",{type:"button",onClick:()=>q(J),className:"px-3 py-1.5 rounded-full text-[11px] font-semibold transition-all",style:te?{background:Tn,color:"#fff",border:`1px solid ${Tn}`}:{background:"#fff",color:"#475569",border:"1px solid #E2E8F0"},children:[te&&e.jsx(xt,{size:10,className:"inline mr-1",strokeWidth:3}),J]},J)})})]},Y.id))}),e.jsxs("div",{className:"mt-4",children:[e.jsx("label",{className:pu,style:{color:hs},children:"Consultation Summary"}),e.jsx("textarea",{className:`${Sc} h-24 resize-none`,style:Cc,value:I,onChange:Y=>D(Y.target.value),placeholder:"Goals in the client's own words, lifestyle context, prioritiesâ¦"})]}),e.jsxs("button",{onClick:G,disabled:y,className:"mt-4 inline-flex items-center gap-2 px-5 py-2.5 rounded-lg text-xs font-bold text-white disabled:opacity-50",style:{background:"linear-gradient(135deg, #0D9488, #0F766E)"},children:[y?e.jsx(de,{size:13,className:"animate-spin"}):e.jsx(ti,{size:13})," Save Record"]})]}),e.jsxs("section",{className:"rounded-2xl p-5",style:{border:"1px solid #E2E8F0"},children:[e.jsxs("h3",{className:"text-[11px] font-bold uppercase tracking-[0.18em] mb-4 flex items-center gap-2",style:{color:Tn},children:[e.jsx(Y_,{size:13,style:{color:Xi}})," Intake Responses"]}),t.intake_received?e.jsxs("div",{className:"space-y-3 text-sm",style:{color:Tn},children:[[["Area of interest",R.treatment_interest],["Skin type",R.skin_type],["Client goals",R.treatment_goals],["Medications",R.medications],["Allergies / sensitivities",R.allergies],["Oncology notes",R.oncology_notes]].filter(([,Y])=>Y).map(([Y,J])=>e.jsxs("div",{children:[e.jsx("p",{className:"text-[10px] font-bold uppercase tracking-[0.16em]",style:{color:hs},children:Y}),e.jsx("p",{className:"leading-relaxed",children:String(J)})]},String(Y))),T.length>0&&e.jsxs("div",{children:[e.jsx("p",{className:"text-[10px] font-bold uppercase tracking-[0.16em] mb-1.5",style:{color:hs},children:"Health screening flags"}),e.jsx("div",{className:"flex flex-wrap gap-2",children:T.map(Y=>e.jsx("span",{className:"px-2.5 py-1 rounded-full text-[10.5px] font-semibold",style:{background:"rgba(190,18,60,0.07)",color:"#9F1239",border:"1px solid rgba(190,18,60,0.2)"},children:Jle[Y]||Y},Y))})]}),R.oncology_care&&e.jsx("p",{className:"text-[11px] font-bold",style:{color:"#9D174D"},children:"Oncology compassionate care pathway flagged."}),e.jsxs("p",{className:"text-[10px] flex items-center gap-1.5 pt-2",style:{color:hs,borderTop:"1px solid #F1F5F9"},children:[e.jsx(Ie,{size:11,style:{color:Xi}})," Confidential â Med Spa clinical team only. Never linked to student or academic re
1299cords."]})]}):e.jsx("p",{className:"text-xs",style:{color:hs},children:"No intake on file yet. The client's confidential pre-visit intake will attach automatically once received."})]}),e.jsxs("section",{className:"rounded-2xl p-5",style:{border:"1px solid #E2E8F0"},children:[e.jsxs("h3",{className:"text-[11px] font-bold uppercase tracking-[0.18em] mb-4 flex items-center gap-2",style:{color:Tn},children:[e.jsx(VO,{size:13,style:{color:Xi}})," Assessment Notes"]}),e.jsxs("div",{className:"grid sm:grid-cols-[1fr,auto] gap-3 items-end mb-3",children:[e.jsxs("div",{children:[e.jsx("label",{className:pu,style:{color:hs},children:"New note"}),e.jsx("textarea",{className:`${Sc} h-20 resize-none`,style:Cc,value:L,onChange:Y=>V(Y.target.value),placeholder:"Skin analysis findings, contraindications discussed, plan directionâ¦"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs("select",{className:Sc,style:Cc,value:B,onChange:Y=>A(Y.target.value),children:[e.jsx("option",{value:"assessment",children:"Assessment"}),e.jsx("option",{value:"consultation",children:"Consultation"}),e.jsx("option",{value:"wellness",children:"Wellness"}),e.jsx("option",{value:"plan-prep",children:"Plan Prep"}),e.jsx("option",{value:"follow-up",children:"Follow-Up"}),e.jsx("option",{value:"internal",children:"Internal"})]}),e.jsx("button",{onClick:W,disabled:y,className:"w-full px-4 py-2.5 rounded-lg text-xs font-bold text-white disabled:opacity-50",style:{background:Tn},children:"Add Note"})]})]}),x?e.jsx(de,{size:16,className:"animate-spin",style:{color:Xi}}):o.length===0?e.jsx("p",{className:"text-xs",style:{color:hs},children:"No notes recorded yet."}):e.jsx("ul",{className:"space-y-2.5",children:o.map(Y=>e.jsxs("li",{className:"rounded-xl p-3.5",style:{background:"#F8FAFC",border:"1px solid #EEF2F7"},children:[e.jsxs("div",{className:"flex items-center justify-between gap-3 mb-1.5",children:[e.jsx("span",{className:"text-[10px] font-bold uppercase tracking-wider px-2 py-0.5 rounded-full",style:{background:"rgba(13,148,136,0.1)",color:"#0F766E"},children:Y.note_type}),e.jsxs("span",{className:"text-[10px]",style:{color:hs},children:[Y.author," · ",new Date(Y.created_at).toLocaleString()]})]}),e.jsx("p",{className:"text-[13px] leading-relaxed",style:{color:Tn},children:Y.body})]},Y.id))})]}),e.jsxs("section",{className:"rounded-2xl p-5",style:{border:"1px solid #E2E8F0"},children:[e.jsxs("h3",{className:"text-[11px] font-bold uppercase tracking-[0.18em] mb-1 flex items-center gap-2",style:{color:Tn},children:[e.jsx(Kt,{size:13,style:{color:Xi}})," Personalized Treatment Plans"]}),e.jsxs("p",{className:"text-[11px] mb-4 leading-relaxed",style:{color:hs},children:["Internal document prepared after the assessment. Concerns tracked above are carried into the plan automatically. ",e.jsxs("span",{className:"inline-flex items-center gap-1",children:[e.jsx(Xe,{size:10})," Never published to the public Med Spa site."]})]}),!se&&p.length===0&&e.jsxs("div",{className:"rounded-xl px-4 py-3 mb-3 text-[11.5px] leading-relaxed",style:{background:"rgba(218,165,32,0.07)",border:"1px solid rgba(218,165,32,0.28)",color:"#7A5600"},children:["Best practice: move this consultation to ",e.jsx("strong",{children:"Assessment Completed"})," before building the plan. You can still start a draft now if the assessment is already documented."]}),p.length>0&&e.jsx("ul",{className:"space-y-2 mb-4",children:p.map(Y=>{const J=fo(Y.status);return e.jsxs("li",{className:"rounded-xl p-3.5 flex flex-wrap items-center justify-between gap-3",style:{background:"#F8FAFC",border:"1px solid #EEF2F7"},children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-[12.5px] font-bold",style:{color:Tn},children:Y.plan_title}),e.jsxs("p",{className:"text-[10.5px] mt-0.5",style:{color:hs},children:["v",Y.version," · ",Y.pathway.length," step",Y.pathway.length===1?"":"s"," · estimate ",tt(Y.estimated_total_cents)," · updated ",new Date(Y.updated_at).toLocaleDateString()]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"px-2.5 py-1 rounded-full text-[10px] font-bold",style:{background:J.bg,color:J.color},children:J.label}),e.jsx("button",{onClick:()=>r(Y),className:"px-3 py-1.5 rounded-lg text-[11px] font-bold text-white",style:{background:Tn},children:"Open Builder"})]})]},Y.id)})}),e.jsxs("button",{onClick:Q,disabled:y,className:"inline-flex items-center gap-2 px-5 py-2.5 rounded-lg text-xs font-bold text-white disabled:opacity-50",style:{background:"linear-gradient(135deg, #0F172A, #134E4A)"},children:[y?e.jsx(de,{size:13,className:"animate-spin"}):e.jsx(tn,{size:13}),p.length===0?"Build Treatment Plan":"Start Additional Plan"]})]}),e.jsxs("section",{className:"rounded-2xl p-5",style:{border:"1px solid #E2E8F0"},children:[e.jsxs("h3",{className:"text-[11px] font-bold uppercase tracking-[0.18em] mb-1 flex items-center gap-2",style:{color:Tn},children:[e.jsx(Vt,{size:13,style:{color:Xi}})," Update Consultation Status"]}),e.jsx("p",{className:"text-[11px] mb-4",style:{color:hs},children:K.hint}),e.jsx("input",{className:`${Sc} mb-3`,style:Cc,value:z,onChange:Y=>M(Y.target.value),placeholder:"Reason / context for this change (optional â recorded in the audit trail)"}),e.jsx("div",{className:"flex flex-wrap gap-2",children:Mm.map(Y=>e.jsx("button",{onClick:()=>X(Y.id),disabled:y||Y.id===t.status,className:"px-3 py-1.5 rounded-full text-[11px] font-bold transition-all disabled:opacity-45",style:Y.id===t.status?{background:Y.color,color:"#fff",border:`1px solid ${Y.color}`}:{background:Y.bg,color:Y.color,border:`1px solid ${Y.color}33`},children:Y.label},Y.id))}),e.jsxs("div",{className:"mt-5 pt-4",style:{borderTop:"1px solid #F1F5F9"},children:[e.jsxs("p",{className:"text-[10px] font-bold uppercase tracking-[0.18em] mb-2.5 flex items-center gap-1.5",style:{color:hs},children:[e.jsx(en,{size:11})," Status Audit Trail"]}),c.length===0?e.jsx("p",{className:"text-xs",style:{color:hs},children:"No transitions recorded yet."}):e.jsx("ul",{className:"space-y-1.5",children:c.map(Y=>e.jsxs("li",{className:"text-[11.5px] flex flex-wrap items-center gap-1.5",style:{color:"#475569"},children:[e.jsx("span",{className:"font-semibold",children:Y.from_status?jl(Y.from_status).short:"â"}),e.jsx(Vt,{size:10}),e.jsx("span",{className:"font-semibold",style:{color:jl(Y.to_status).color},children:jl(Y.to_status).short}),e.jsxs("span",{style:{color:hs},children:["· ",Y.changed_by," · ",new Date(Y.created_at).toLocaleStr
1299ing()]}),Y.reason&&e.jsxs("span",{className:"italic",style:{color:hs},children:["â ",Y.reason]})]},Y.id))})]})]})]})]})]})},hu="#0F172A",Fg="#64748B",ece=({plans:t,onOpen:s,onOpenCompletion:n})=>t.length===0?e.jsxs("div",{className:"rounded-2xl p-10 text-center bg-white",style:{border:"1px dashed #CBD5E1"},children:[e.jsx(Kt,{size:26,className:"mx-auto mb-3",style:{color:"#94A3B8"}}),e.jsx("p",{className:"text-sm font-bold",style:{color:hu},children:"No treatment plans yet"}),e.jsxs("p",{className:"text-xs mt-1.5 max-w-md mx-auto leading-relaxed",style:{color:Fg},children:["Open a client consultation record and choose ",e.jsx("strong",{children:"Build Treatment Plan"})," once the assessment is complete. Plans are internal documents and are never published publicly."]})]}):e.jsx("div",{className:"rounded-2xl overflow-hidden bg-white",style:{border:"1px solid #E7EDF3"},children:e.jsx("div",{className:"overflow-x-auto",children:e.jsxs("table",{className:"w-full text-left",children:[e.jsx("thead",{children:e.jsx("tr",{style:{background:"#F8FAFC"},children:["Client","Plan","Provider","Pathway","Estimate","Status",""].map(a=>e.jsx("th",{className:"px-4 py-3 text-[10px] font-bold uppercase tracking-[0.14em]",style:{color:Fg},children:a},a))})}),e.jsx("tbody",{children:t.map(a=>{var o;const r=fo(a.status),i=a.pathway.reduce((l,c)=>l+(c.sessions||0),0);return e.jsxs("tr",{className:"hover:bg-slate-50 transition-colors",style:{borderTop:"1px solid #F1F5F9"},children:[e.jsxs("td",{className:"px-4 py-3",children:[e.jsx("p",{className:"text-[13px] font-bold",style:{color:hu},children:a.client_name}),e.jsx("p",{className:"text-[10px]",style:{color:Fg},children:a.client_email||"â"})]}),e.jsxs("td",{className:"px-4 py-3 text-[11.5px]",style:{color:"#475569"},children:[a.plan_title,e.jsx("br",{}),e.jsxs("span",{style:{color:Fg},children:["v",a.version," · ",new Date(a.updated_at).toLocaleDateString()]})]}),e.jsx("td",{className:"px-4 py-3 text-[11.5px]",style:{color:"#475569"},children:((o=a.provider)==null?void 0:o.split("â")[0].trim())||"Unassigned"}),e.jsx("td",{className:"px-4 py-3 text-[11.5px]",style:{color:"#475569"},children:e.jsxs("span",{className:"inline-flex items-center gap-1.5",children:[e.jsx(Jx,{size:11,style:{color:"#94A3B8"}}),a.pathway.length," step",a.pathway.length===1?"":"s"," · ",i," session",i===1?"":"s"]})}),e.jsxs("td",{className:"px-4 py-3 text-[11.5px] font-semibold",style:{color:hu},children:[tt(a.estimated_total_cents),a.consultation_credit_cents>0&&e.jsxs(e.Fragment,{children:[e.jsx("br",{}),e.jsxs("span",{className:"text-[10px] font-normal",style:{color:"#15803D"},children:["â",tt(a.consultation_credit_cents)," credit"]})]})]}),e.jsx("td",{className:"px-4 py-3",children:e.jsx("span",{className:"px-2.5 py-1 rounded-full text-[10px] font-bold whitespace-nowrap",style:{background:r.bg,color:r.color},children:r.label})}),e.jsx("td",{className:"px-4 py-3",children:e.jsxs("div",{className:"flex flex-wrap items-center gap-1.5",children:[e.jsx("button",{onClick:()=>s(a),className:"px-3 py-1.5 rounded-lg text-[11px] font-bold text-white whitespace-nowrap",style:{background:hu},children:"Open Plan"}),n&&e.jsxs("button",{onClick:()=>n(a),className:"inline-flex items-center gap-1.5 px-3 py-1.5 rounded-lg text-[11px] font-bold whitespace-nowrap",style:{background:"#fff",color:hu,border:`1px solid ${hu}`},title:"Send for client review, record approval, prepare invoice, queue scheduling",children:[e.jsx(Nd,{size:11})," Client Review"]})]})})]},a.id)})})]})})}),xh="#0F172A",Er="#64748B",Dj="#0D9488",xu="w-full px-2.5 py-2 rounded-lg text-[12.5px] bg-white focus:outline-none focus:ring-2 focus:ring-teal-500/30",fu={border:"1px solid #E2E8F0",color:xh},tce=({pathway:t,readOnly:s,onChange:n})=>{const[a,r]=d.useState(u4[0]||"laser"),[i,o]=d.useState(""),l=d.useMemo(()=>{const m=i.trim().toLowerCase();return jN.filter(x=>m?x.name.toLowerCase().includes(m)||x.description.toLowerCase().includes(m):x.category===a)},[a,i]),c=m=>{const x=jN.find(h=>h.name===m);x&&(t.some(h=>h.treatment===x.name)||n([...t,{treatment:x.name,category:x.category,sessions:1,frequency:"Every 4 weeks",timeline:"3 months",provider_notes:"",unit_price_cents:x.price_cents,duration_minutes:x.duration_minutes}]))},u=(m,x)=>n(t.map((h,y)=>y===m?{...h,...x}:h)),p=m=>n(t.filter((x,h)=>h!==m));return e.jsxs("div",{children:[!s&&e.jsxs("div",{className:"rounded-xl p-4 mb-4",style:{background:"#F8FAFC",border:"1px solid #E7EDF3"},children:[e.jsxs("p",{className:"text-[10px] font-bold uppercase tracking-[0.18em] mb-2.5 flex items-center gap-1.5",style:{color:Er},children:[e.jsx(Xe,{size:11,style:{color:Dj}})," Internal Treatment Library â not shown to clients online"]}),e.jsxs("div",{className:"flex flex-wrap gap-2 mb-3",children:[e.jsx("input",{value:i,onChange:m=>o(m.target.value),placeholder:"Search all internal treatmentsâ¦",className:xu,style:{...fu,maxWidth:260}}),e.jsx("select",{value:a,onChange:m=>{r(m.target.value),o("")},className:xu,style:{...fu,maxWidth:240},children:u4.map(m=>e.jsx("option",{value:m,children:d4[m]||m},m))})]}),e.jsxs("div",{className:"grid sm:grid-cols-2 gap-2 max-h-56 overflow-y-auto pr-1",children:[l.map(m=>{const x=t.some(h=>h.treatment===m.name);return e.jsxs("button",{type:"button",onClick:()=>c(m.name),disabled:x,className:"text-left rounded-lg p-2.5 transition-all disabled:opacity-45",style:{background:"#fff",border:"1px solid #E2E8F0"},children:[e.jsx("p",{className:"text-[12px] font-bold leading-snug",style:{color:xh},children:m.name}),e.jsxs("p",{className:"text-[10.5px] mt-0.5 leading-snug",style:{color:Er},children:[m.duration_minutes," min · ",tt(m.price_cents)," · ",m.deviceType]}),e.jsxs("span",{className:"inline-flex items-center gap-1 text-[10px] font-bold mt-1.5",style:{color:x?Er:Dj},children:[e.jsx(tn,{size:10})," ",x?"Already in plan":"Add to pathway"]})]},m.name)}),l.length===0&&e.jsx("p",{className:"text-[11.5px] py-3",style:{color:Er},children:"No treatments match that search."})]})]}),t.length===0?e.jsx("p",{className:"text-[12px] rounded-xl p-4",style:{color:Er,background:"#F8FAFC",border:"1px dashed #CBD5E1"},children:"No treatment steps yet. Select from the internal library above to build the recommended pathway."}):e.jsx("ul",{className:"space-y-3",children:t.map((m,x)=>e.jsxs("li",{className:"rounded-xl p-4",style:{background:"#fff",border:"1px solid #E2E8F0"},children:[e.jsxs("div",{className:"flex items-start justify-between gap-3 mb-3",children:[e.jsxs("div",{children:[e.jsxs("p",{className:"text-[13px] font-bold leading-snug",style:{color:xh},children:[e.jsx("span",{className:"inline-flex items-center justify-center w-5 h-5 rounded-full text-[10px] font-bold mr-2 align-middle",style:{background:Dj,color:"#fff"},children:x+1}),m.treatment]}),e.jsxs("p",{className:"text-[10.5px] mt-1",style:{color:Er},children:[d4[m.category]||m.category," · ",m.duration_minutes," min per session · ",tt(m.unit_price_cents)," each"]})]}),!s&&e.jsx("button",{type:"button",onClick:()=>p(x),className:"p-1.5 rounded-lg hover:bg-red-50","aria-label":"Remove step",children:e.jsx(va,{size:13,style:{color:"#BE123C"}})})]}),e.jsxs("div",{className:"grid sm:grid-cols-3 gap-2.5",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-[9.5px] font-bold uppercase tracking-[0.14em] mb-1",style:{color:Er},children:"Sessions"}),e.jsx("input",{type:"number",min:1,max:24,disabled:s,value:m.sessions,onChange:h=>u(x,{sessions:Math.max(1,Number(h.target.value)||1)}),className:xu,style:fu})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-[9.5px] font-bold uppercase tracking-[0.14em] mb-1",style:{color:Er},children:"Frequency"}),e.jsx("select",{disabled:s,value:m.frequency,onChange:h=>u(x,{frequency:h.target.value}),className:xu,style:fu,children:ule.map(h=>e.jsx("option",{value:h,children:h},h))})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-[9.5px] font-bold uppercase tracking-[0.14em] mb-1",style:{color:Er},children:"Timeline"}),e.jsx("select",{disabled:s,value:m.timeline,onChange:h=>u(x,{timeline:h.target.value}),className:xu,style:fu,children:mle.map(h=>e.jsx("option",{value:h,children:h},h))})]}),e.jsxs("div",{className:"sm:col-span-3",children:[e.jsx("label",{className:"block text-[9.5px] font-bold uppercase tracking-[0.14em] mb-1",style:{color:Er},children:"Provider Notes"}),e.jsx("textarea",{disabled:s,value:m.provider_notes,onChange:h=>u(x,{provider_notes:h.target.value}),placeholder:"Settings, sequencing, precautions, expected progressionâ¦",className:`${xu} h-16 resize-none`,style:fu})]})]}),e.jsxs("p",{className:"text-[11px] font-bold mt-2.5",style:{color:xh},children:["Step estimate: ",tt(m.unit_price_cents*m.sessions),e.jsxs("span",{className:"font-normal",style:{color:Er},children:[" · ",m.sessions," session",m.sessions===1?"":"s"]})]})]},`${m.treatment}-${x}`))}),t.length>0&&e.jsxs("div",{className:"mt-3 rounded-xl px-4 py-3 flex items-center justify-between",style:{background:"rgba(13,148,136,0.06)",border:"1px solid rgba(13,148,136,0.22)"},children:[e.jsxs("span",{className:"text-[11px] font-bold uppercase tracking-[0.14em] flex items-center gap-1.5",style:{color:"#0F766E"},children:[e.jsx(Jx,{size:12})," Planning Estimate"]}),e.jsx("span",{className:"text-[15px] font-bold",style:{color:xh},children:tt(Rd(t))})]})]})},bn="#0F172A",rs="#64748B",nr="#0D9488",sce="#DAA520",Fr="block text-[10px] font-bold uppercase tracking-[0.16em] mb
1299-1.5",ar="w-full px-3 py-2.5 rounded-lg text-sm bg-white focus:outline-none focus:ring-2 focus:ring-teal-500/30",rr={border:"1px solid #E2E8F0",color:bn},Rj=({options:t,selected:s,readOnly:n,onToggle:a})=>e.jsx("div",{className:"flex flex-wrap gap-2",children:t.map(r=>{const i=s.includes(r);return e.jsxs("button",{type:"button",disabled:n,onClick:()=>a(r),className:"px-3 py-1.5 rounded-full text-[11px] font-semibold transition-all disabled:opacity-70",style:i?{background:bn,color:"#fff",border:`1px solid ${bn}`}:{background:"#fff",color:"#475569",border:"1px solid #E2E8F0"},children:[i&&e.jsx(xt,{size:10,className:"inline mr-1",strokeWidth:3}),r]},r)})}),nce=({plan:t,actor:s,onClose:n,onSaved:a})=>{const r=fo(t.status),i=!r.editable,[o,l]=d.useState({plan_title:t.plan_title,provider:t.provider,goal_skin_concerns:t.goal_skin_concerns,goal_wellness:t.goal_wellness,desired_outcomes:t.desired_outcomes,assessment_observations:t.assessment_observations,assessment_consultation_notes:t.assessment_consultation_notes,recommended_approach:t.recommended_approach,pathway:t.pathway,wellness_home_care:t.wellness_home_care,wellness_products:t.wellness_products,wellness_botanical:t.wellness_botanical,wellness_lifestyle:t.wellness_lifestyle,provider_notes:t.provider_notes}),[c,u]=d.useState([]),[p,m]=d.useState([]),[x,h]=d.useState(!0),[y,v]=d.useState(!1),[g,N]=d.useState(null),[b,f]=d.useState(null),[j,S]=d.useState(""),[w,_]=d.useState(""),C=(A,z)=>l(M=>({...M,[A]:z})),E=(A,z)=>l(M=>({...M,[A]:M[A].includes(z)?M[A].filter(R=>R!==z):[...M[A],z]})),P=async()=>{h(!0);try{const[A,z]=await Promise.all([gle(t.id),yle(t.id)]);u(A),m(z)}catch(A){f(A.message)}h(!1)};d.useEffect(()=>{P()},[t.id]);const F=A=>{N(A),f(null),window.setTimeout(()=>N(null),3200)},I=async()=>{v(!0),f(null);try{await Fj(t.id,o,s),F("Plan draft saved."),a(),await P()}catch(A){f(A.message)}v(!1)},D=async()=>{v(!0),f(null);try{await Fj(t.id,o,s);const A=await vle(t,o,s,j.trim()||void 0);S(""),F(`Version archived. Now working on v${A}.`),a(),await P()}catch(A){f(A.message)}v(!1)},L=async A=>{if(A!==t.status){v(!0),f(null);try{r.editable&&await Fj(t.id,o,s),await jle(t,A,s,w.trim()||void 0),_(""),F(`Plan status updated to ${fo(A).label}.`),a(),await P()}catch(z){f(z.message)}v(!1)}},V=Rd(o.pathway),B=Math.max(0,V-(t.consultation_credit_cents||0));return e.jsxs("div",{className:"fixed inset-0 z-[60] flex",role:"dialog","aria-modal":"true","aria-label":"Treatment plan builder",children:[e.jsx("button",{className:"flex-1 bg-black/50 backdrop-blur-sm",onClick:n,"aria-label":"Close builder"}),e.jsxs("div",{className:"w-full max-w-3xl h-full overflow-y-auto bg-white shadow-2xl",children:[e.jsxs("div",{className:"sticky top-0 z-10 px-6 py-5 text-white",style:{background:"linear-gradient(135deg, #0F172A, #134E4A)"},children:[e.jsxs("div",{className:"flex items-start justify-between gap-4",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-[10px] font-bold uppercase tracking-[0.28em] text-white/55 mb-1.5",children:"Personalized Treatment Plan Builder · Internal"}),e.jsx("h2",{className:"text-xl font-bold tracking-tight",children:t.client_name}),e.jsxs("p",{className:"text-[11px] text-white/60 mt-1",children:[t.plan_title," · v",t.version," · Created ",new Date(t.created_at).toLocaleDateString()]})]}),e.jsx("button",{onClick:n,className:"p-2 rounded-lg hover:bg-white/10","aria-label":"Close",children:e.jsx(Ke,{size:18})})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2 mt-4",children:[e.jsx("span",{className:"px-2.5 py-1 rounded-full text-[10px] font-bold uppercase tracking-wider bg-white/12",children:r.label}),t.consultation_credit_cents>0&&e.jsxs("span",{className:"px-2.5 py-1 rounded-full text-[10px] font-bold uppercase tracking-wider",style:{background:"rgba(34,197,94,0.22)"},children:["Consultation credit ",tt(t.consultation_credit_cents)]}),e.jsxs("span",{className:"px-2.5 py-1 rounded-full text-[10px] font-bold uppercase tracking-wider",style:{background:"rgba(218,165,32,0.25)"},children:["Estimate ",tt(V)]})]}),e.jsxs("p",{className:"text-[10.5px] text-white/55 mt-3 flex items-center gap-1.5",children:[e.jsx(Xe,{size:10,style:{color:sce}})," Internal document. Not published to the public Med Spa site."]})]}),e.jsxs("div",{className:"px-6 py-6 space-y-6",children:[g&&e.jsxs("div",{className:"rounded-xl px-4 py-3 text-xs font-semibold flex items-center gap-2",style:{background:"rgba(13,148,136,0.08)",border:"1px solid rgba(13,148,136,0.25)",color:"#0F766E"},children:[e.jsx(xt,{size:14})," ",g]}),b&&e.jsx("div",{className:"rounded-xl px-4 py-3 text-xs font-semibold",style:{background:"rgba(220,38,38,0.06)",border:"1px solid rgba(220,38,38,0.25)",color:"#B91C1C"},children:b}),i&&e.jsxs("div",{className:"rounded-xl px-4 py-3 text-[11.5px] leading-relaxed flex items-start gap-2",style:{background:"rgba(218,165,32,0.07)",border:"1px solid rgba(218,165,32,0.28)",color:"#7A5600"},children:[e.jsx(Ie,{size:14,className:"shrink-0 mt-0.5"}),"This plan is locked for editing at the ",e.jsx("strong",{children:r.label})," stage to preserve what the client was shown. Return it to ",e.jsx("strong",{children:"Under Review"})," below if a revision is required â the change is recorded in the audit trail."]}),e.jsxs("section",{className:"rounded-2xl p-5",style:{border:"1px solid #E2E8F0"},children:[e.jsxs("h3",{className:"text-[11px] font-bold uppercase tracking-[0.18em] mb-4 flex items-center gap-2",style:{color:bn},children:[e.jsx(Kt,{size:13,style:{color:nr}})," Plan Record"]}),e.jsxs("div",{className:"grid sm:grid-cols-2 gap-4",children:[e.jsxs("div",{children:[e.jsx("label",{className:Fr,style:{color:rs},children:"Plan Title"}),e.jsx("input",{disabled:i,className:ar,style:rr,value:o.plan_title,onChange:A=>C("plan_title",A.target.value)})]}),e.jsxs("div",{children:[e.jsx("label",{className:Fr,style:{color:rs},children:"Provider / Specialist"}),e.jsx("select",{disabled:i,className:ar,style:rr,value:o.provider||"Unassigned",onChange:A=>C("provider",A.target.value==="Unassigned"?null:A.target.value),children:u$.map(A=>e.jsx("option",{value:A,children:A},A))})]})]}),e.jsxs("p",{className:"text-[10.5px] mt-3",style:{color:rs},children:["Linked consultation record: ",e.jsx("span",{className:"font-semibold",style:{color:bn},children:t.client_email||t.client_name})," · Created by ",t.created_by||"staff"]})]}),e.jsxs("section",{className:"rounded-2xl p-5",style:{border:"1px solid #E2E8F0"},children:[e.jsxs("h3",{className:"text-[11px] font-bold uppercase tracking-[0.18em] mb-1 flex items-center gap-2",style:{color:bn},children:[e.jsx(Ym,{size:13,style:{color:nr}})," Client Goals"]}),e.jsx("p",{className:"text-[11px] mb-4",style:{color:rs},children:"Carried forward from the consultation record. Adjust to reflect what the client prioritized
1299in person."}),e.jsx("p",{className:"text-[10px] font-bold uppercase tracking-[0.2em] mb-2",style:{color:nr},children:"Skin Concerns"}),e.jsx(Rj,{options:hle,selected:o.goal_skin_concerns,readOnly:i,onToggle:A=>E("goal_skin_concerns",A)}),e.jsx("p",{className:"text-[10px] font-bold uppercase tracking-[0.2em] mt-4 mb-2",style:{color:nr},children:"Wellness Goals"}),e.jsx(Rj,{options:p$,selected:o.goal_wellness,readOnly:i,onToggle:A=>E("goal_wellness",A)}),e.jsxs("div",{className:"mt-4",children:[e.jsx("label",{className:Fr,style:{color:rs},children:"Desired Outcomes"}),e.jsx("textarea",{disabled:i,className:`${ar} h-20 resize-none`,style:rr,value:o.desired_outcomes||"",onChange:A=>C("desired_outcomes",A.target.value),placeholder:"What the client wants to see and feel, in their own wordsâ¦"})]})]}),e.jsxs("section",{className:"rounded-2xl p-5",style:{border:"1px solid #E2E8F0"},children:[e.jsxs("h3",{className:"text-[11px] font-bold uppercase tracking-[0.18em] mb-4 flex items-center gap-2",style:{color:bn},children:[e.jsx(Sa,{size:13,style:{color:nr}})," Assessment Summary"]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx("label",{className:Fr,style:{color:rs},children:"Professional Observations"}),e.jsx("textarea",{disabled:i,className:`${ar} h-24 resize-none`,style:rr,value:o.assessment_observations||"",onChange:A=>C("assessment_observations",A.target.value),placeholder:"Skin condition, texture, tone, barrier status, laxity, sensitivityâ¦"})]}),e.jsxs("div",{children:[e.jsx("label",{className:Fr,style:{color:rs},children:"Consultation Notes"}),e.jsx("textarea",{disabled:i,className:`${ar} h-20 resize-none`,style:rr,value:o.assessment_consultation_notes||"",onChange:A=>C("assessment_consultation_notes",A.target.value),placeholder:"Lifestyle context, history, contraindications discussedâ¦"})]}),e.jsxs("div",{children:[e.jsx("label",{className:Fr,style:{color:rs},children:"Recommended Approach"}),e.jsx("textarea",{disabled:i,className:`${ar} h-20 resize-none`,style:rr,value:o.recommended_approach||"",onChange:A=>C("recommended_approach",A.target.value),placeholder:"How the plan is sequenced and why â phased, progressive, barrier-firstâ¦"})]})]})]}),e.jsxs("section",{className:"rounded-2xl p-5",style:{border:"1px solid #E2E8F0"},children:[e.jsxs("h3",{className:"text-[11px] font-bold uppercase tracking-[0.18em] mb-1 flex items-center gap-2",style:{color:bn},children:[e.jsx(Vt,{size:13,style:{color:nr}})," Recommended Treatment Pathway"]}),e.jsx("p",{className:"text-[11px] mb-4",style:{color:rs},children:"Selected from the preserved internal treatment library. Sessions, frequency and timeline are set per client."}),e.jsx(tce,{pathway:o.pathway,readOnly:i,onChange:A=>C("pathway",A)}),V>0&&e.jsxs("div",{className:"mt-3 rounded-xl p-4 text-[11.5px] leading-relaxed",style:{background:"#F8FAFC",border:"1px solid #E7EDF3",color:"#475569"},children:["Planning estimate ",e.jsx("strong",{style:{color:bn},children:tt(V)}),t.consultation_credit_cents>0&&e.jsxs(e.Fragment,{children:[" · less consultation credit ",tt(t.consultation_credit_cents)," · net ",e.jsx("strong",{style:{color:bn},children:tt(B)})]}),". Estimate only â invoicing is a future phase and no payment is processed here."]})]}),e.jsxs("section",{className:"rounded-2xl p-5",style:{border:"1px solid #E2E8F0"},children:[e.jsxs("h3",{className:"text-[11px] font-bold uppercase tracking-[0.18em] mb-1 flex items-center gap-2",style:{color:bn},children:[e.jsx(On,{size:13,style:{color:nr}})," Wellness Recommendations ",e.jsx("span",{className:"font-medium normal-case tracking-normal",style:{color:rs},children:"(optional)"})]}),e.jsx("p",{className:"text-[11px] mb-4",style:{color:rs},children:"Educational guidance only â supportive language, never a diagnosis or medical claim."}),e.jsx("p",{className:"text-[10px] font-bold uppercase tracking-[0.2em] mb-2",style:{color:nr},children:"Zorganics Product & Home-Care Suggestions"}),e.jsx(Rj,{options:ple,selected:o.wellness_products,readOnly:i,onToggle:A=>E("wellness_products",A)}),e.jsxs("div",{className:"grid sm:grid-cols-2 gap-4 mt-4",children:[e.jsxs("div",{className:"sm:col-span-2",children:[e.jsx("label",{className:Fr,style:{color:rs},children:"Home-Care Guidance"}),e.jsx("textarea",{disabled:i,className:`${ar} h-20 resize-none`,style:rr,value:o.wellness_home_care||"",onChange:A=>C("wellness_home_care",A.target.value),placeholder:"A simple, sustainable routine the client can actually keepâ¦"})]}),e.jsxs("div",{children:[e.jsx("label",{className:Fr,style:{color:rs},children:"Botanical Wellness Support"}),e.jsx("textarea",{disabled:i,className:`${ar} h-20 resize-none`,style:rr,value:o.wellness_botanical||"",onChange:A=>C("wellness_botanical",A.target.value),placeholder:"Botanical formulations that support the planâ¦"})]}),e.jsxs("div",{children:[e.jsx("label",{className:Fr,style:{color:rs},children:"Lifestyle Education"}),e.jsx("textarea",{disabled:i,className:`${ar} h-20 resize-none`,style:rr,value:o.wellness_lifestyle||"",onChange:A=>C("wellness_lifestyle",A.target.value),placeholder:"Sleep, hydration, sun habits, stress â educational onlyâ¦"})]})]}),e.jsxs("div",{className:"mt-4",children:[e.jsx("label",{className:Fr,style:{color:rs},children:"Internal Provider Notes"}),e.jsx("textarea",{disabled:i,className:`${ar} h-20 resize-none`,style:rr,value:o.provider_notes||"",onChange:A=>C("provider_notes",A.target.value),placeholder:"Internal only â never shown to the client."})]})]}),!i&&e.jsxs("section",{className:"rounded-2xl p-5",style:{border:"1px solid #E2E8F0"},children:[e.jsxs("h3",{className:"text-[11px] font-bold uppercase tracking-[0.18em] mb-4 flex items-center gap-2",style:{color:bn},children:[e.jsx(ZS,{size:13,style:{color:nr}})," Save & Version"]}),e.jsxs("div",{className:"flex flex-wrap items-end gap-3",children:[e.jsxs("button",{onClick:I,disabled:y,className:"inline-flex items-center gap-2 px-5 py-2.5 rounded-lg text-xs font-bold text-white disabled:opacity-50",style:{background:"linear-gradient(135deg, #0D9488, #0F766E)"},children:[y?e.jsx(de,{size:13,className:"animate-spin"}):e.jsx(ti,{size:13})," Save Draft"]}),e.jsxs("div",{className:"flex-1 min-w-[200px]",children:[e.jsx("label",{className:Fr,style:{color:rs},children:"Version note (optional)"}),e.jsx("input",{className:ar,style:rr,value:j,onChange:A=>S(A.target.value),placeholder:"What changed in this revision?"})]}),e.jsxs("button",{onClick:D,disabled:y,className:"inline-flex items-center gap-2 px-5 py-2.5 rounded-lg text-xs font-bold disabled:opacity-50",style:{background:"#fff",color:bn,border:`1px solid ${bn}`},children:[e.jsx(ZS,{size:13})," Archive Version"]})]})]}),e.jsxs("section",{className:"rounded-2xl p-5",style:{border:"1px solid #E2E8F0"},children:[e.jsxs("h3",{className:"text-[11px] font-bold uppercase tracking-[0.18em] mb-1 flex items-center gap-2",style:{color:bn},children:[e.jsx(Hs,{size:13,style:{color:nr}})," Plan Status"]}),e.jsx("p",{className:"text-[11px] mb-4",style:{color:rs},children:r.hint}),e.jsx("input",{className:`${ar} mb-3`,style:rr,value:w,onChange:A=>_(A.target.value),placeholder:"Context for this change (optional â recorded in the audit history)"}),e.jsx("div",{className:"flex flex-wrap gap-2",children:Ix.map(A=>e.jsx("button",{onClick:()=>L(A.id),disabled:y||A.id===t.status,className:"px-3 py-1.5 rounded-full text-[11px] font-bold transition-all disabled:opacity-45",style:A.id===t.status?{background:A.color,color:"#fff",border:`1px solid ${A.color}`}:{background:A.bg,color:A.color,border:`1px solid ${A.color}33`},children:A.label},A.id))}),e.jsxs("p",{className:"text-[10.5px] mt-3 leading-relaxed",style:{color:rs},children:["Next phase (not yet built): ",e.jsx("strong",{children:"Ready for Client â Client Reviews Plan â Client Approval â Invoice Generation â Appointment Scheduling"}),". Approving a plan here records the decision only â no invoice or payment is generated."]})]}),e.jsxs("section",{className:"rounded-2xl p-5",style:{border:"1px solid #E2E8F0"},children:[e.jsxs("h3",{className:"text-[11px] font-bold uppercase tracking-[0.18em] mb-4 flex items-center gap-2",style:{color:bn},children:[e.jsx(en,{size:13,style:{color:nr}})," Plan History"]}),x?e.jsx(de,{size:16,className:"animate-spin",style:{color:nr}}):e.jsxs(e.Fragment,{children:[e.jsx("p",{className:"text-[10px] font-bold uppercase tracking-[0.18em] mb-2",style:{color:rs},children:"Archived Versions"}),c.length===0?e.jsxs("p",{className:"text-xs mb-4",style:{color:rs},children:["No archived versions yet â currently v",t.version,"."]}):e.jsx("ul",{className:"space-y-1.5 mb-4",children:c.map(A=>e.jsxs("li",{className:"text-[11.5px] flex flex-wrap items-center gap-1.5",style:{color:"#475569"},children:[e.jsxs("span",{className:"px-2 py-0.5 rounded-full text-[10px] font-bold",style:{background:"rgba(13,148,136,0.1)",color:"#0F766E"},children:["v",A.version]}),e.jsxs("span",{children:[A.saved_by," · ",new Date(A.created_at).toLocaleStr
1299ing()]}),A.note&&e.jsxs("span",{className:"italic",style:{color:rs},children:["â ",A.note]})]},A.id))}),e.jsx("p",{className:"text-[10px] font-bold uppercase tracking-[0.18em] mb-2 pt-3",style:{color:rs,borderTop:"1px solid #F1F5F9"},children:"Audit Trail"}),p.length===0?e.jsx("p",{className:"text-xs",style:{color:rs},children:"No activity recorded yet."}):e.jsx("ul",{className:"space-y-1.5",children:p.map(A=>e.jsxs("li",{className:"text-[11.5px] flex flex-wrap items-center gap-1.5",style:{color:"#475569"},children:[e.jsx("span",{className:"font-semibold",style:{color:bn},children:A.event.replace(/_/g," ")}),A.from_status&&A.to_status&&e.jsxs("span",{className:"inline-flex items-center gap-1",children:[e.jsx("span",{children:fo(A.from_status).label}),e.jsx(Vt,{size:10}),e.jsx("span",{style:{color:fo(A.to_status).color,fontWeight:700},children:fo(A.to_status).label})]}),e.jsxs("span",{style:{color:rs},children:["· ",A.actor," · ",new Date(A.created_at).toLocaleString()]}),A.detail&&e.jsxs("span",{className:"italic",style:{color:rs},children:["â ",A.detail]})]},A.id))})]})]})]})]})]})},Rp="#0F172A",ol="#64748B",ace="#0D9488",rce=({plans:t,preps:s,sessions:n,invoices:a=[],onOpen:r})=>t.length===0?e.jsxs("div",{className:"rounded-2xl p-10 text-center bg-white",style:{border:"1px dashed #CBD5E1"},children:[e.jsx(Nd,{size:26,className:"mx-auto mb-3",style:{color:"#94A3B8"}}),e.jsx("p",{className:"text-sm font-bold",style:{color:Rp},children:"No plans have reached a client yet"}),e.jsxs("p",{className:"text-xs mt-1.5 max-w-lg mx-auto leading-relaxed",style:{color:ol},children:["Open a plan in the ",e.jsx("strong",{children:"Treatment Plans"})," tab and choose ",e.jsx("strong",{children:"Client Review"})," to issue a private review link. Approval, invoice preparation and scheduling then appear here."]})]}):e.jsx("div",{className:"rounded-2xl overflow-hidden bg-white",style:{border:"1px solid #E7EDF3"},children:e.jsx("div",{className:"overflow-x-auto",children:e.jsxs("table",{className:"w-full text-left",children:[e.jsx("thead",{children:e.jsx("tr",{style:{background:"#F8FAFC"},children:["Client","Communication","Client Response","Invoice & Payment","Treatment",""].map(i=>e.jsx("th",{className:"px-4 py-3 text-[10px] font-bold uppercase tracking-[0.14em]",style:{color:ol},children:i},i))})}),e.jsx("tbody",{children:t.map(i=>{const o=i,l=fo(i.status),c=nb(o.client_decision),u=s.find(g=>g.plan_id===i.id&&g.status!=="void"),p=a.find(g=>g.plan_id===i.id&&g.status!=="void"),m=g$(y$(i)),x=n.filter(g=>g.plan_id===i.id),h=x.filter(g=>g.status==="scheduled").length,y=x.filter(g=>g.status==="completed").length,v=x.filter(g=>g.status==="follow_up").length;return e.jsxs("tr",{className:"hover:bg-slate-50 transition-colors",style:{borderTop:"1px solid #F1F5F9"},children:[e.jsxs("td",{className:"px-4 py-3",children:[e.jsx("p",{className:"text-[13px] font-bold",style:{color:Rp},children:i.client_name}),e.jsxs("p",{className:"text-[10px]",style:{color:ol},children:[i.plan_title," · v",i.version]}),e.jsx("span",{className:"inline-block mt-1 px-2 py-0.5 rounded-full text-[9.5px] font-bold",style:{background:l.bg,color:l.color},children:l.label})]}),e.jsxs("td",{className:"px-4 py-3 text-[11.5px]",style:{color:"#475569"},children:[e.jsxs("span",{className:"inline-flex items-center gap-1.5 px-2.5 py-1 rounded-full text-[10px] font-bold whitespace-nowrap",style:{background:m.bg,color:m.color},children:[e.jsx(Ye,{size:10})," ",m.label]}),o.last_emailed_at&&e.jsxs(e.Fragment,{children:[e.jsx("br",{}),e.jsxs("span",{className:"text-[10px]",style:{color:ol},children:[new Date(o.last_emailed_at).toLocaleDateString(),o.email_send_count>1?` · ${o.email_send_count}x`:""]})]})]}),e.jsx("td",{className:"px-4 py-3 text-[11.5px]",style:{color:"#475569"},children:c?e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"px-2.5 py-1 rounded-full text-[10px] font-bold whitespace-nowrap",style:{background:c.bg,color:c.color},children:c.label}),o.client_decision_at&&e.jsxs(e.Fragment,{children:[e.jsx("br",{}),e.jsx("span",{className:"text-[10px]",style:{color:ol},children:new Date(o.client_decision_at).toLocaleDateString()})]})]}):o.client_viewed_at?e.jsxs("span",{className:"inline-flex items-center gap-1.5 text-[11px]",style:{color:ace},children:[e.jsx(ms,{size:11})," Viewed, awaiting response"]}):o.share_token?e.jsx("span",{className:"text-[11px]",style:{color:"#B45309"},children:"Link sent · not opened"}):e.jsx("span",{className:"text-[11px]",style:{color:ol},children:"Not sent"})}),e.jsx("td",{className:"px-4 py-3 text-[11.5px]",style:{color:"#475569"},children:p?e.jsxs(e.Fragment,{children:[e.jsxs("span",{className:"inline-flex items-center gap-1.5 font-semibold",style:{color:Rp},children:[e.jsx(Vl,{size:11,style:{color:"#94A3B8"}}),tt(p.amount_paid_cents)," / ",tt(p.total_due_cents)]}),e.jsx("br",{}),e.jsxs("span",{className:"text-[10px] font-bold",style:{color:zx(p.status).color},children:[p.invoice_number," · ",zx(p.status).label]})]}):u?e.jsxs(e.Fragment,{children:[e.jsxs("span",{className:"inline-flex items-center gap-1.5 font-semibold",style:{color:Rp},children:[e.jsx(Vl,{size:11,style:{color:"#94A3B8"}})," ",tt(u.total_due_cents)]}),e.jsx("br",{}),e.jsxs("span",{className:"text-[10px] font-bold",style:{color:$x(u.status).color},children:["Prep · ",$x(u.status).label]})]}):e.jsx("span",{className:"text-[11px]",style:{color:ol},children:"â"})}),e.jsx("td",{className:"px-4 py-3 text-[11.5px]",style:{color:"#475569"},children:x.length===0?e.jsx("span",{className:"text-[11px]",style:{color:ol},children:"â"}):e.jsxs(e.Fragment,{children:[e.jsxs("span",{className:"inline-flex items-center gap-1.5",children:[e.jsx(_a,{size:11,style:{color:"#94A3B8"}}),y,"/",x.length," done · ",h," booked"]}),v>0&&e.jsxs(e.Fragment,{children:[e.jsx("br",{}),e.jsxs("span",{className:"text-[10px] font-bold",style:{color:"#DAA520"},children:[v," follow-up"]})]})]})}),e.jsx("td",{className:"px-4 py-3",children:e.jsxs("button",{onClick:()=>r(i),className:"inline-flex items-center gap-1.5 px-3 py-1.5 rounded-lg text-[11px] font-bold text-white whitespace-nowrap",style:{background:Rp},children:["Manage ",e.jsx(Vt,{size:11})]})})]},i.id)})})]})})}),Xc="#0F172A",ml="#64748B",_N="#0D9488",b$="#DAA520",Ip=({icon:t,title:s,kicker:n,children:a})=>e.jsxs("section",{className:"rounded-2xl p-6 bg-white",style:{border:"1px solid #E7EDF3"},children:[n&&e.jsx("p",{className:"text-[10px] font-bold uppercase tracking-[0.24em] mb-1.5",style:{color:b$},children:n}),e.jsxs("h3",{className:"text-[15px] font-bold mb-4 flex items-center gap-2 tracking-tight",style:{color:Xc},children:[e.jsx(t,{size:15,style:{color:_N}})," ",s]}),a]}),Ij=({items:t})=>e.jsx("div",{className:"flex flex-wrap gap-2",children:t.map(s=>e.jsx("span",{className:"px-3 py-1.5 rounded-full text-[11.5px] font-semibold",style:{background:"#F8FAFC",color:Xc,border:"1px solid #E2E8F0"},children:s},s))}),Ac=({label:t,body:s})=>s?e.jsxs("div",{className:"mb-4 last:mb-0",children:[e.jsx("p",{className:"text-[10px] font-bold uppercase tracking-[0.18em] mb-1.5",style:{color:ml},children:t}),e.jsx("p",{className:"text-[13.5px] leading-relaxed whitespace-pre-line",style:{color:"#334155"},children:s})]}):null,v$=({plan:t,preview:s})=>{const n=t.pathway.reduce((i,o)=>i+(o.sessions||1),0),a=Math.max(0,(t.estimated_total_cents||0)-(t.consultation_credit_cents||0)),r=!!(t.wellness_home_care||t.wellness_botanical||t.wellness_lifestyle||t.wellness_products.length);return e.jsxs("div",{className:"space-y-5",children:[s&&e.jsx("div",{className:"rounded-xl px-4 py-3 text-[11.5px] font-semibold",style:{background:"rgba(13,148,136,0.07)",border:"1px solid rgba(13,148,136,0.25)",color:"#0F766E"},children:"Internal preview â this is exactly what your client sees. Internal provider notes are never included."}),e.jsxs("div",{className:"rounded-2xl p-7 text-white",style:{background:"linear-gradient(135deg, #0F172A, #134E4A)"},children:[e.jsx("p",{className:"text-[10px] font-bold uppercase tracking-[0.3em] text-white/55 mb-2",children:"Zorganics Med Spa · Prepared exclusively for you"}),e.jsx("h1",{className:"text-2xl sm:text-3xl font-bold tracking-tight",children:t.plan_title||"Personalized Skin & Wellness Plan"}),e.jsx("p",{className:"text-sm text-white/75 mt-2",children:t.client_name}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2 mt-5",children:[t.provider&&e.jsx("span",{className:"px-3 py-1.5 rounded-full text-[10.5px] font-bold uppercase tracking-wider bg-white/12",children:t.provider}),e.jsxs("span",{className:"px-3 py-1.5 rounded-full text-[10.5px] font-bold uppercase tracking-wider",style:{background:"rgba(218,165,32,0.25)"},children:["Plan v",t.version]}),t.shared_at&&e.jsxs("span",{className:"px-3 py-1.5 rounded-full text-[10.5px] font-bold uppercase tracking-wider bg-white/12",children:["Prepared ",new Date(t.shared_at).toLocaleDateString()]})]}),e.jsx("p",{className:"text-[11.5px] text-white/60 mt-5 leading-relaxed max-w-2xl",children:"Your plan was created after your Personalized Skin & Wellness Consultation and professional assessment. Every recommendation below was chosen by your specialist for your skin, your goals and your lifestyle â there is nothing for you to choose from a menu."})]}),(t.goal_skin_concerns.length>0||t.goal_wellness.length>0||t.desired_outcomes)&&e.jsxs(Ip,{icon:Ym,title:"Your Goals",kicker:"What you told us matters most",children:[t.goal_skin_concerns.length>0&&e.jsxs(e.Fragment,{children:[e.jsx("p",{className:"text-[10px] font-bold uppercase tracking-[0.18em] mb-2",style:{color:ml},children:"Skin Focus"}),e.jsx(Ij,{items:t.goal_skin_concerns})]}),t.goal_wellness.length>0&&e.jsxs(e.Fragment,{children:[e.jsx("p",{className:"text-[10px] font-bold uppercase tracking-[0.18em] mt-4 mb-2",style:{color:ml},children:"Wellness Goals"}),e.jsx(Ij,{items:t.goal_wellness})]}),t.desired_outcomes&&e.jsx("div",{className:"mt-4",children:e.jsx(Ac,{label:"Desired Outcomes",body:t.desired_outcomes})})]}),(t.assessment_observations||t.assessment_consultation_notes||t.recommended_approach)&&e.jsxs(Ip,{icon:Sa,title:"Professional Assessment Summary",kicker:"What your specialist observed",children:[e.jsx(Ac,{label:"Observations",body:t.asse
1299ssment_observations}),e.jsx(Ac,{label:"Consultation Summary",body:t.assessment_consultation_notes}),e.jsx(Ac,{label:"Recommended Approach",body:t.recommended_approach})]}),t.pathway.length>0&&e.jsxs(Ip,{icon:ZP,title:"Your Recommended Care Pathway",kicker:"Personalized recommendation",children:[e.jsx("ol",{className:"space-y-3",children:t.pathway.map((i,o)=>e.jsx("li",{className:"rounded-xl p-4",style:{background:"#F8FAFC",border:"1px solid #EEF2F7"},children:e.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-3",children:[e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx("span",{className:"w-6 h-6 rounded-full flex items-center justify-center text-[10px] font-bold shrink-0 text-white",style:{background:_N},children:o+1}),e.jsxs("div",{children:[e.jsx("p",{className:"text-[14px] font-bold",style:{color:Xc},children:i.treatment}),e.jsxs("p",{className:"text-[11.5px] mt-1",style:{color:ml},children:[i.sessions," session",i.sessions===1?"":"s",i.frequency?` · ${i.frequency}`:"",i.timeline?` · over ${i.timeline}`:"",i.duration_minutes?` · approx. ${i.duration_minutes} min each`:""]}),i.provider_notes&&e.jsx("p",{className:"text-[12.5px] mt-2 leading-relaxed",style:{color:"#334155"},children:i.provider_notes})]})]}),i.unit_price_cents>0&&e.jsx("p",{className:"text-[12.5px] font-bold whitespace-nowrap",style:{color:Xc},children:tt(i.unit_price_cents*(i.sessions||1))})]})},`${i.treatment}-${o}`))}),e.jsxs("p",{className:"text-[11.5px] mt-4 flex items-center gap-1.5",style:{color:ml},children:[e.jsx(dt,{size:12,style:{color:_N}}),n," session",n===1?"":"s"," in total. Your specialist will pace your plan around how your skin responds â timing can always be adjusted with you."]})]}),e.jsxs(Ip,{icon:Vl,title:"Your Investment Summary",kicker:"Transparent, no obligation",children:[e.jsxs("div",{className:"space-y-2 text-[13.5px]",style:{color:"#334155"},children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{children:"Recommended care pathway"}),e.jsx("span",{className:"font-semibold",style:{color:Xc},children:tt(t.estimated_total_cents)})]}),t.consultation_credit_cents>0&&e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{children:"Consultation credit applied"}),e.jsxs("span",{className:"font-semibold",style:{color:"#15803D"},children:["â",tt(t.consultation_credit_cents)]})]}),e.jsxs("div",{className:"flex items-center justify-between pt-2.5 mt-1",style:{borderTop:"1px solid #E7EDF3"},children:[e.jsx("span",{className:"font-bold",style:{color:Xc},children:"Your plan investment"}),e.jsx("span",{className:"text-lg font-bold",style:{color:Xc},children:tt(a)})]})]}),e.jsx("p",{className:"text-[11.5px] mt-4 leading-relaxed",style:{color:ml},children:"This summary is provided for your review only â no payment is requested or collected on this page. If you approve your plan, your specialist will follow up with your invoice and scheduling."})]}),r&&e.jsxs(Ip,{icon:On,title:"Home Care & Wellness Education",kicker:"Supporting your results at home",children:[t.wellness_products.length>0&&e.jsxs(e.Fragment,{children:[e.jsx("p",{className:"text-[10px] font-bold uppercase tracking-[0.18em] mb-2",style:{color:ml},children:"Suggested Zorganics Home Care"}),e.jsx(Ij,{items:t.wellness_products}),e.jsx("div",{className:"h-4"})]}),e.jsx(Ac,{label:"Home-Care Guidance",body:t.wellness_home_care}),e.jsx(Ac,{label:"Botanical Wellness Support",body:t.wellness_botanical}),e.jsx(Ac,{label:"Lifestyle Education",body:t.wellness_lifestyle}),e.jsxs("p",{className:"text-[11px] mt-4 leading-relaxed flex items-start gap-1.5",style:{color:ml},children:[e.jsx(Qe,{size:12,className:"shrink-0 mt-0.5",style:{color:b$}}),"Educational guidance only. Zorganics does not diagnose, treat or make medical claims â please speak with your healthcare provider about any medical concern."]})]})]})},j$="#0F172A",$p="#64748B",h4="w-full px-3 py-2.5 rounded-lg text-sm bg-white focus:outline-none focus:ring-2 focus:ring-teal-500/30",x4={border:"1px solid #E2E8F0",color:j$}
1299,$j="block text-[10px] font-bold uppercase tracking-[0.16em] mb-1.5",ice=({plan:t,comms:s,actor:n,hasToken:a,onSent:r})=>{const i=t,[o,l]=d.useState(t.client_email||""),[c,u]=d.useState(""),[p,m]=d.useState(!1),[x,h]=d.useState(null),[y,v]=d.useState(null),g=y$(t),N=g$(g),b=async()=>{m(!0),v(null),h(null);try{const f=await Ole(t,n,{recipient:o,note:c});h(`Plan emailed to ${f.recipient}.`),u(""),r()}catch(f){v(f.message)}m(!1)};return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2 mb-3",children:[e.jsx("span",{className:"px-2.5 py-1 rounded-full text-[10px] font-bold uppercase tracking-wider",style:{background:N.bg,color:N.color},children:N.label}),i.last_emailed_at&&e.jsxs("span",{className:"text-[10.5px]",style:{color:$p},children:["Sent ",new Date(i.last_emailed_at).toLocaleString()," · ",i.email_send_count||1,"Ã"]}),i.client_viewed_at&&e.jsxs("span",{className:"inline-flex items-center gap-1 text-[10.5px]",style:{color:"#0F766E"},children:[e.jsx(ms,{size:11})," Viewed ",new Date(i.client_viewed_at).toLocaleDateString()]})]}),a?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"grid sm:grid-cols-2 gap-3 mb-3",children:[e.jsxs("div",{children:[e.jsx("label",{className:$j,style:{color:$p},children:"Send to"}),e.jsx("input",{className:h4,style:x4,value:o,onChange:f=>l(f.target.value),placeholder:"[email protected]"})]}),e.jsxs("div",{children:[e.jsx("label",{className:$j,style:{color:$p},children:"Personal note (optional)"}),e.jsx("input",{className:h4,style:x4,value:c,onChange:f=>u(f.target.value),placeholder:"It was a pleasure meeting youâ¦"})]})]}),e.jsxs("button",{onClick:b,disabled:p||!o.includes("@"),className:"inline-flex items-center gap-2 px-5 py-2.5 rounded-lg text-xs font-bold text-white disabled:opacity-50",style:{background:"linear-gradient(135deg, #0D9488, #0F766E)"},children:[p?e.jsx(de,{size:13,className:"animate-spin"}):e.jsx(Hs,{size:13}),i.last_emailed_at?"Resend Plan Email":"Email Plan to Client"]}),e.jsx("p",{className:"text-[10.5px] mt-2.5 leading-relaxed",style:{color:$p},children:"The email contains a personalized summary and a private link only â never internal notes, the internal treatment library, or a technology/device menu."})]}):e.jsx("p",{className:"text-[11.5px] leading-relaxed",style:{color:"#B45309"},children:"Issue the private client review link in Step 1 first â the email links to that page."}),x&&e.jsxs("p",{className:"mt-3 text-[11.5px] font-semibold inline-flex items-center gap-1.5",style:{color:"#0F766E"},children:[e.jsx(xt,{size:12})," ",x]}),y&&e.jsxs("p",{className:"mt-3 text-[11.5px] font-semibold inline-flex items-center gap-1.5",style:{color:"#B91C1C"},children:[e.jsx(Mt,{size:12})," ",y]}),s.length>0&&e.jsxs("div",{className:"mt-4",children:[e.jsx("p",{className:$j,style:{color:$p},children:"Communication history"}),e.jsx("ul",{className:"space-y-1.5",children:s.slice(0,6).map(f=>e.jsxs("li",{className:"flex items-start gap-2 text-[11px]",style:{color:"#475569"},children:[e.jsx(Ye,{size:11,className:"shrink-0 mt-0.5",style:{color:f.status==="failed"?"#BE123C":"#94A3B8"}}),e.jsxs("span",{children:[e.jsx("strong",{style:{color:j$},children:f.recipient})," · ",f.sent_at?new Date(f.sent_at).toLocaleString():"â"," · ",e.jsx("span",{style:{color:f.status==="failed"?"#BE123C":"#0F766E"},children:f.status}),f.sent_by?` · ${f.sent_by}`:""]})]},f.id))})]})]})},Ir="#0F172A",Ec="#64748B",f4="w-full px-3 py-2.5 rounded-lg text-sm bg-white focus:outline-none focus:ring-2 focus:ring-teal-500/30",g4={border:"1px solid #E2E8F0",color:Ir},oce="block text-[10px] font-bold uppercase tracking-[0.16em] mb-1.5",lce=({plan:t,prep:s,invoice:n,approved:a,actor:r,onChanged:i})=>{const[o,l]=d.useState(!1),[c,u]=d.useState(null),[p,m]=d.useState(null),[x,h]=d.useState(""),[y,v]=d.useState(""),[g,N]=d.useState(!1),b=async S=>{l(!0),u(null),m(null);try{await S()}catch(w){u(w.message)}l(!1)};if(!a)return e.jsx("p",{className:"text-[11.5px] leading-relaxed",style:{color:Ec},children:"Invoicing unlocks once the client approves their plan. Pricing is then locked to the approved plan version so the investment the client agreed to is exactly what is invoiced."});if(!n)return e.jsxs(e.Fragment,{children:[e.jsxs("p",{className:"text-[11.5px] mb-4 leading-relaxed",style:{color:Ec},children:["Generates a real invoice from the approved plan",s?" and its prepared investment summary":"",". Line items, the consultation credit and the total carry over exactly â nothing is re-priced."]}),e.jsxs("button",{onClick:()=>b(async()=>{await qle(t,s,r),m("Invoice generated."),i()}),disabled:o,className:"inline-flex items-center gap-2 px-5 py-2.5 rounded-lg text-xs font-bold text-white disabled:opacity-50",style:{background:"linear-gradient(135deg, #0F172A, #134E4A)"},children:[o?e.jsx(de,{size:13,className:"animate-spin"}):e.jsx(Kt,{size:13})," Generate Invoice"]}),c&&e.jsxs("p",{className:"mt-3 text-[11.5px] font-semibold inline-flex items-center gap-1.5",style:{color:"#B91C1C"},children:[e.jsx(Mt,{size:12})," ",c]})]});const f=zx(n.status),j=Math.max(0,n.total_due_cents-(n.amount_paid_cents||0));return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2 mb-3",children:[e.jsx("span",{className:"px-2.5 py-1 rounded-full text-[10px] font-bold uppercase tracking-wider",style:{background:f.bg,color:f.color},children:f.label}),e.jsx("span",{className:"text-[11px] font-bold",style:{color:Ir},children:n.invoice_number}),e.jsxs("span",{className:"text-[10.5px]",style:{color:Ec},children:["Approved v",n.approved_version??t.version,n.approval_recorded_at?` · ${new Date(n.approval_recorded_at).toLocaleDateString()}`:""]})]}),e.jsx("div",{className:"rounded-xl overflow-hidden mb-3",style:{border:"1px solid #EEF2F7"},children:e.jsxs("table",{className:"w-full text-left text-[11.5px]",children:[e.jsx("thead",{children:e.jsx("tr",{style:{background:"#F8FAFC"},children:["Recommended service","Sessions","Each","Total"].map(S=>e.jsx("th",{className:"px-3 py-2 text-[9.5px] font-bold uppercase tracking-[0.14em]",style:{color:Ec},children:S},S))})}),e.jsx("tbody",{children:n.line_items.map((S,w)=>e.jsxs("tr",{style:{borderTop:"1px solid #F1F5F9"},children:[e.jsx("td",{className:"px-3 py-2",style:{color:Ir},children:S.description}),e.jsx("td",{className:"px-3 py-2",style:{color:"#475569"},children:S.sessions}),e.jsx("td",{className:"px-3 py-2",style:{color:"#475569"},children:tt(S.unit_price_cents)}),e.jsx("td",{className:"px-3 py-2 font-semibold",style:{color:Ir},children:tt(S.total_cents)})]},`${S.description}-${w}`))})]})}),e.jsxs("div",{className:"text-[12px] space-y-1 mb-4",style:{color:"#475569"},children:[e.jsxs("p",{children:["Subtotal ",e.jsx("strong",{style:{color:Ir},children:tt(n.subtotal_cents)})]}),n.consultation_credit_cents>0&&e.jsxs("p",{children:["Consultation credit applied â",tt(n.consultation_credit_cents)]}),e.jsxs("p",{className:"text-[13px]",children:["Invoice total ",e.jsx("strong",{style:{color:Ir},children:tt(n.total_due_cents)})]}),e.jsxs("p",{children:["Paid to date ",e.jsx("strong",{style:{color:"#15803D"},children:tt(n.amount_paid_cents)})," · Outstanding ",e.jsx("strong",{style:{color:j>0?"#B45309":"#15803D"},children:tt(j)})]})]}),n.checkout_url&&e.jsxs("div",{className:"flex flex-wrap items-center gap-2 mb-3",children:[e.jsx("code",{className:"flex-1 min-w-[200px] px-3 py-2 rounded-lg text-[10.5px] break-all",style:{background:"#F8FAFC",border:"1px solid #E2E8F0",color:Ir},children:n.checkout_url}),e.jsxs("button",{onClick:async()=>{try{await navigator.clipboard.writeText(n.checkout_url),N(!0),window.setTimeout(()=>N(!1),2e3)}catch{u("Copy failed.")}},className:"inline-flex items-center gap-1.5 px-3.5 py-2 rounded-lg text-[11px] font-bold",style:{background:Ir,color:"#fff"},children:[g?e.jsx(xt,{size:12}):e.jsx(Vm,{size:12})," ",g?"Copied":"Copy"]}),e.jsxs("a",{href:n.checkout_url,target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center gap-1.5 px-3.5 py-2 rounded-lg text-[11px] font-bold",style:{background:"#fff",color:Ir,border:`1px solid ${Ir}`},children:[e.jsx(Ua,{size:12})," Open"]})]}),e.jsxs("div",{className:"flex flex-wrap gap-2 mb-4",children:[j>=100&&e.jsxs("button",{onClick:()=>b(async()=>{await Wle(n,r),m("Secure payment link issued on the existing Med Spa payment rail."),i()}),disabled:o,className:"inline-flex items-center gap-2 px-4 py-2.5 rounded-lg text-xs font-bold text-white disabled:opacity-50",style:{background:"linear-gradient(135deg, #0D9488, #0F766E)"},children:[o?e.jsx(de,{size:13,className:"animate-spin"}):e.jsx(Xs,{size:13}),n.checkout_url?"Reissue Payment Link":"Issue Secure Payment Link"]}),ab.filter(S=>S.id==="void").map(S=>e.jsx("button",{onClick:()=>b(async()=>{await Gle(n,S.id,r),m("Invoice voided."),i()}),disabled:o||n.status===S.id,className:"px-3.5 py-2.5 rounded-lg text-[11px] font-bold disabled:opacity-45",style:{background:S.bg,color:S.color,border:`1px solid ${S.color}33`},children:"Void Invoice"},S.id))]}),j>0&&e.jsxs("div",{className:"rounded-xl p-3.5",style:{background:"#F8FAFC",border:"1px solid #EEF2F7"},children:[e.jsx("p",{className:oce,style:{color:Ec},children:"Record a settled payment (existing rail / POS terminal)"}),e.jsxs("div",{className:"grid sm:grid-cols-3 gap-2",children:[e.jsx("input",{className:f4,style:g4,value:x,onChange:S=>h(S.target.value),placeholder:"Amount e.g. 350.00",inputMode:"decimal"}),e.jsx("input",{className:f4,style:g4,value:y,onChange:S=>v(S.target.value),placeholder:"Payment reference"}),e.jsxs("button",{onClick:()=>b(async()=>{const S=Math.round(parseFloat(x||"0")*100);if(!S||S<=0)throw new Error("Enter a valid payment amount.");await Hle(n,S,r,{reference:y}),h(""),v(""),m("Payment recorded. Treatment scheduling is ready."),i()}),disabled:o,className:"inline-flex items-center justify-center gap-2 px-4 py-2.5 rounded-lg text-xs font-bold text-white disabled:opacity-50",style:{background:Ir},children:[o?e.jsx(de,{size:13,className:"animate-spin"}):e.jsx(Yx,{size:13})," Record Payment"]})]}),e.jsx("p",{className:"text-[10.5px] mt-2 leading-relaxed",style:{color:Ec},children:"Records a payment that has already settled on an existing Zorganics rail. No card is charged here and the POS / payment architecture is not modified."})]}),p&&e.jsxs("p",{className:"mt-3 text-[11.5px] font-semibold inline-flex items-center gap-1.5",style:{color:"#0F766E"},children:[e.jsx(xt,{size:12})," ",p]}),c&&e.jsxs("p",{className:"mt-3 text-[11.5px] font-semibold inline-flex items-center gap-1.5",style:{color:"#B91C1C"},children:[e.jsx(Mt,{size:12})," ",c]}),e.jsx("p",{className:"text-[10.5px] mt-3 leading-relaxed",style:{color:Ec},children:f.hint})]})},H0="#0F172A",Kc="#64748B",cce="#0D9488",Tg="w-full px-3 py-2 rounded-lg text-[12px] bg-white focus:outline-none focus:ring-2 focus:ring-teal-500/30",Pg={border:"1px solid #E2E8F0",color:H0},Dg="block text-[9.5px] font-bold uppercase tracking-[0.16em] mb
1299-1",dce=({row:t,actor:s,busy:n,onChange:a})=>{const r=t,[i,o]=d.useState(!1),[l,c]=d.useState(r.progress_notes||""),[u,p]=d.useState(r.follow_up_recommendation||""),[m,x]=d.useState(r.home_care_note||""),[h,y]=d.useState(r.follow_up_due||""),v=f$(t.status);return e.jsxs("li",{className:"rounded-xl p-3.5",style:{background:"#F8FAFC",border:"1px solid #EEF2F7"},children:[e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[e.jsxs("div",{children:[e.jsxs("p",{className:"text-[12.5px] font-bold",style:{color:H0},children:[t.treatment," ",e.jsxs("span",{className:"font-normal",style:{color:Kc},children:["· session ",t.session_number,"/",t.total_sessions]})]}),e.jsxs("p",{className:"text-[10.5px] mt-0.5",style:{color:Kc},children:[t.scheduled_for?`Scheduled ${new Date(t.scheduled_for).toLocaleDateString()}`:t.recommended_frequency||"Frequency per specialist",t.completed_at?` · completed ${new Date(t.completed_at).toLocaleDateString()}`:"",r.follow_up_due?` · follow-up due ${new Date(r.follow_up_due+"T00:00:00").toLocaleDateString()}`:""]})]}),e.jsx("span",{className:"px-2.5 py-1 rounded-full text-[10px] font-bold",style:{background:v.bg,color:v.color},children:v.label})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2 mt-2.5",children:[e.jsx("input",{type:"date",className:"px-2.5 py-1.5 rounded-lg text-[11px] bg-white",style:{border:"1px solid #E2E8F0",color:H0},value:t.scheduled_for?t.scheduled_for.slice(0,10):"",onChange:g=>a(async()=>{await m4(t,{scheduled_for:g.target.value?new Date(g.target.value).toISOString():null,status:g.target.value?"scheduled":t.status},s)})}),NN.map(g=>e.jsx("button",{onClick:()=>a(async()=>{await m4(t,{status:g.id},s)}),disabled:n||g.id===t.status,className:"px-2.5 py-1.5 rounded-full text-[10px] font-bold disabled:opacity-40",style:{background:g.bg,color:g.color,border:`1px solid ${g.color}33`},children:g.label},g.id)),e.jsxs("button",{onClick:()=>o(g=>!g),className:"inline-flex items-center gap-1.5 px-2.5 py-1.5 rounded-full text-[10px] font-bold",style:{background:"#fff",color:H0,border:"1px solid #E2E8F0"},children:[e.jsx(BO,{size:10})," ",i?"Hide notes":"Care notes"]})]}),(r.progress_notes||r.follow_up_recommendation||r.home_care_note)&&!i&&e.jsxs("p",{className:"text-[11px] mt-2 leading-relaxed",style:{color:"#475569"},children:[r.progress_notes&&e.jsxs(e.Fragment,{children:[r.progress_notes,e.jsx("br",{})]}),r.follow_up_recommendation&&e.jsxs("span",{style:{color:cce},children:["Follow-up: ",r.follow_up_recommendation]})]}),i&&e.jsxs("div",{className:"mt-3 grid sm:grid-cols-2 gap-2.5",children:[e.jsxs("div",{className:"sm:col-span-2",children:[e.jsx("label",{className:Dg,style:{color:Kc},children:"Progress notes"}),e.jsx("textarea",{rows:2,className:Tg,style:Pg,value:l,onChange:g=>c(g.target.value),placeholder:"Response to treatment, tolerance, observed progressâ¦"})]}),e.jsxs("div",{children:[e.jsx("label",{className:Dg,style:{color:Kc},children:"Follow-up recommendation"}),e.jsx("textarea",{rows:2,className:Tg,style:Pg,value:u,onChange:g=>p(g.target.value),placeholder:"Recheck in 4 weeksâ¦"})]}),e.jsxs("div",{children:[e.jsx("label",{className:Dg,style:{color:Kc},children:"Home-care recommendation"}),e.jsx("textarea",{rows:2,className:Tg,style:Pg,value:m,onChange:g=>x(g.target.value),placeholder:"Barrier-supporting botanical moisturizerâ¦"})]}),e.jsxs("div",{children:[e.jsx("label",{className:Dg,style:{color:Kc},children:"Follow-up due"}),e.jsx("input",{type:"date",className:Tg,style:Pg,value:h||"",onChange:g=>y(g.target.value)})]}),e.jsx("div",{className:"flex items-end",children:e.jsxs("button",{onClick:()=>a(async()=>{await Vle(t,{progress_notes:l,follow_up_recommendation:u,home_care_note:m,follow_up_due:h||null},s),o(!1)}),disabled:n,className:"inline-flex items-center gap-1.5 px-4 py-2 rounded-lg text-[11px] font-bold text-white disabled:opacity-50",style:{background:"linear-gradient(135deg, #0D9488, #0F766E)"},children:[n?e.jsx(de,{size:12,className:"animate-spin"}):e.jsx(xt,{size:12})," Save Care Notes"]})})]})]})},uce=({sessions:t,actor:s,busy:n,onChange:a})=>t.length===0?e.jsxs("p",{className:"text-[11.5px] leading-relaxed inline-flex items-start gap-1.5",style:{color:Kc},children:[e.jsx(_a,{size:12,className:"shrink-0 mt-0.5",style:{color:"#94A3B8"}}),"Generate the scheduling queue above to begin the client's treatment history."]}):e.jsx("ul",{className:"space-y-2",children:t.map(r=>e.jsx(dce,{row:r,actor:s,busy:n,onChange:a},r.id))}
1299),mce="#0F172A",pce="#64748B",zj="#0D9488",hce=({stages:t})=>e.jsxs("div",{children:[e.jsxs("p",{className:"text-[10px] font-bold uppercase tracking-[0.2em] mb-3 flex items-center gap-1.5",style:{color:zj},children:[e.jsx(ZP,{size:12})," Complete Client Journey"]}),e.jsxs("ol",{className:"relative pl-6",children:[e.jsx("span",{className:"absolute left-[7px] top-1 bottom-1 w-px",style:{background:"#E2E8F0"},"aria-hidden":!0}),t.map(s=>e.jsxs("li",{className:"relative pb-4 last:pb-0",children:[e.jsx("span",{className:"absolute -left-6 top-0.5 w-[15px] h-[15px] rounded-full flex items-center justify-center",style:{background:s.complete?zj:"#fff",border:`1.5px solid ${s.complete?zj:"#CBD5E1"}`},children:s.complete?e.jsx(xt,{size:9,color:"#fff"}):e.jsx(zb,{size:5,color:"#CBD5E1"})}),e.jsx("p",{className:"text-[12.5px] font-bold leading-snug",style:{color:s.complete?mce:"#475569"},children:s.label}),e.jsxs("p",{className:"text-[11px] mt-0.5 leading-relaxed",style:{color:pce},children:[s.detail,s.at&&e.jsxs("span",{className:"ml-1.5",style:{color:"#94A3B8"},children:["· ",new Date(s.at).toLocaleDateString()]})]})]},s.key))]})]}),uo="#0F172A",pi="#64748B",fh="#0D9488",w$="#DAA520",Lj="w-full px-3 py-2.5 rounded-lg text-sm bg-white focus:outline-none focus:ring-2 focus:ring-teal-500/30",Oj={border:"1px solid #E2E8F0",color:uo},Mj="block text-[10px] font-bold uppercase tracking-[0.16em] mb-1.5",Fc=({icon:t,title:s,step:n,children:a})=>e.jsxs("section",{className:"rounded-2xl p-5",style:{border:"1px solid #E2E8F0"},children:[e.jsx("p",{className:"text-[9.5px] font-bold uppercase tracking-[0.22em] mb-1",style:{color:w$},children:n}),e.jsxs("h3",{className:"text-[11.5px] font-bold uppercase tracking-[0.16em] mb-4 flex items-center gap-2",style:{color:uo},children:[e.jsx(t,{size:13,style:{color:fh}})," ",s]}),a]}),xce=({plan:t,actor:s,onClose:n,onSaved:a})=>{const r=t,[i,o]=d.useState(null),[l,c]=d.useState(null),[u,p]=d.useState([]),[m,x]=d.useState([]),[h,y]=d.useState(!0),[v,g]=d.useState(!1),[N,b]=d.useState(null),[f,j]=d.useState(null),[S,w]=d.useState(!1),[_,C]=d.useState(""),[E,P]=d.useState(t.client_name||""),[F,I]=d.useState(""),[D,L]=d.useState(!1),V=r.share_token||null,B=r.client_decision||null,A=nb(B),z=B==="approved"||t.status==="client_approved",M=fo(t.status),R=d.useCallback(async()=>{y(!0);try{const[te,pe,Fe,ke]=await Promise.all([Ele(t.id),Ple(t.id),Ble(t.id),Lle(t.id)]);o(te),x(pe),c(Fe),p(ke)}catch(te){j(te.message)}y(!1)},[t.id]);d.useEffect(()=>{R()},[R]);const T=te=>{b(te),j(null),window.setTimeout(()=>b(null),3500)},U=async te=>{g(!0),j(null);try{await te()}catch(pe){j(pe.message)}g(!1)},q=()=>U(async()=>{await kle(t,s),T("Client review link issued. You can now email it to your client."),a()}),H=()=>U(async()=>{await Sle(t,s),T("Client link revoked. The plan is back with the internal team."),a()}),G=te=>U(async()=>{var pe;await Cle(t,te,s,{confirmationName:E,note:_}),C(""),T(`Recorded: ${(pe=nb(te))==null?void 0:pe.label}.`),a()}),W=()=>U(async()=>{const te=await Fle(t,s);o(te),T("Investment summary prepared. You can now generate the invoice."),a()}),X=te=>U(async()=>{i&&(await Tle(i,t.id,te,s,F),I(""),T(`Invoice preparation â ${$x(te).label}.`),await R(),a())}),Q=()=>U(async()=>{const te=await Rle(t,s);T(te===0?"This plan has no pathway steps to queue yet.":`${te} session(s) added to the scheduling queue.`),await R(),a()}),K=te=>U(async()=>{await te(),await R(),a()}),se=async()=>{if(V)try{await navigator.clipboard.writeText(Tj(V)),w(!0),window.setTimeout(()=>w(!1),2200)}catch{j("Copy failed â select the link text manually.")}},Y={id:t.id,plan_title:t.plan_title,client_name:t.client_name,provider:t.provider,status:t.status,version:t.version,goal_skin_concerns:t.goal_skin_concerns,goal_wellness:t.goal_wellness,desired_outcomes:t.desired_outcomes,assessment_observations:t.assessment_observations,assessment_consultation_notes:t.assessment_consultation_notes,recommended_approach:t.recommended_approach,pathway:t.pathway.map(te=>({treatment:te.treatment,sessions:te.sessions,frequency:te.frequency,timeline:te.timeline,provider_notes:te.provider_notes,unit_price_cents:te.unit_price_cents,duration_minutes:te.duration_minutes})),wellness_home_care:t.wellness_home_care,wellness_products:t.wellness_products,wellness_botanical:t.wellness_botanical,wellness_lifestyle:t.wellness_lifestyle,estimated_total_cents:t.estimated_total_cents,consultation_credit_cents:t.consultation_credit_cents,shared_at:r.shared_at||null,client_decision:B,client_decision_at:r.client_decision_at||null,client_confirmation_name:r.client_confirmation_name||null,client_decision_note:r.client_decision_note||null,approved_version:r.approved_version||null},J=Zle(t,l,m,u);return e.jsxs("div",{className:"fixed inset-0 z-[70] flex",role:"dialog","aria-modal":"true","aria-label":"Client plan completion",children:[e.jsx("button",{className:"flex-1 bg-black/50 backdrop-blur-sm",onClick:n,"aria-label":"Close panel"}),e.jsxs("div",{className:"w-full max-w-3xl h-full overflow-y-auto bg-white shadow-2xl",children:[e.jsxs("div",{className:"sticky top-0 z-10 px-6 py-5 text-white",style:{background:"linear-gradient(135deg, #0F172A, #134E4A)"},children:[e.jsxs("div",{className:"flex items-start justify-between gap-4",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-[10px] font-bold uppercase tracking-[0.28em] text-white/55 mb-1.5",children:"Client Plan Completion · Internal"}),e.jsx("h2",{className:"text-xl font-bold tracking-tight",children:t.client_name}),e.jsxs("p",{className:"text-[11px] text-white/60 mt-1",children:[t.plan_title," · v",t.version]})]}),e.jsx("button",{onClick:n,className:"p-2 rounded-lg hover:bg-white/10","aria-label":"Close",children:e.jsx(Ke,{size:18})})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2 mt-4",children:[e.jsx("span",{className:"px-2.5 py-1 rounded-full text-[10px] font-bold uppercase tracking-wider bg-white/12",children:M.label}),A&&e.jsxs("span",{className:"px-2.5 py-1 rounded-full text-[10px] font-bold uppercase tracking-wider",style:{background:"rgba(255,255,255,0.16)"},children:["Client: ",A.label]}),r.client_viewed_at&&e.jsxs("span",{className:"px-2.5 py-1 rounded-full text-[10px] font-bold uppercase tracking-wider bg-white/12",children:["Viewed ",new Date(r.client_viewed_at).toLocaleDateString()]}),l&&e.jsx("span",{className:"px-2.5 py-1 rounded-full text-[10px] font-bold uppercase tracking-wider bg-white/12",children:l.invoice_number})]}),e.jsxs("p",{className:"text-[10.5px] text-white/55 mt-3 flex items-center gap-1.5",children:[e.jsx(Xe,{size:10,style:{color:w$}})," Communication â approval â invoice on the existing payment rail â treatment history."]})]}),e.jsxs("div",{className:"px-6 py-6 space-y-5",children:[N&&e.jsxs("div",{className:"rounded-xl px-4 py-3 text-xs font-semibold flex items-center gap-2",style:{background:"rgba(13,148,136,0.08)",border:"1px solid rgba(13,148,136,0.25)",color:"#0F766E"},children:[e.jsx(xt,{size:14})," ",N]}),f&&e.jsx("div",{className:"rounded-xl px-4 py-3 text-xs font-semibold",style:{background:"rgba(220,38,38,0.06)",border:"1px solid rgba(220,38,38,0.25)",color:"#B91C1C"},children:f}),e.jsx(Fc,{icon:Hs,title:"Send Plan for Client Review",step:"Step 1",children:V?e.jsxs(e.Fragment,{children:[e.jsx("p",{className:Mj,style:{color:pi},children:"Private client link"}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx("code",{className:"flex-1 min-w-[220px] px-3 py-2.5 rounded-lg text-[11px] break-all",style:{background:"#F8FAFC",border:"1px solid #E2E8F0",color:uo}
1299,children:Tj(V)}),e.jsxs("button",{onClick:se,className:"inline-flex items-center gap-1.5 px-4 py-2.5 rounded-lg text-[11px] font-bold",style:{background:uo,color:"#fff"},children:[S?e.jsx(xt,{size:12}):e.jsx(Vm,{size:12})," ",S?"Copied":"Copy"]}),e.jsxs("a",{href:Tj(V),target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center gap-1.5 px-4 py-2.5 rounded-lg text-[11px] font-bold",style:{background:"#fff",color:uo,border:`1px solid ${uo}`},children:[e.jsx(Xs,{size:12})," Open"]})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2 mt-3",children:[e.jsxs("button",{onClick:()=>L(te=>!te),className:"inline-flex items-center gap-1.5 px-4 py-2 rounded-lg text-[11px] font-bold",style:{background:"#F8FAFC",color:uo,border:"1px solid #E2E8F0"},children:[e.jsx(ms,{size:12})," ",D?"Hide":"Preview"," what the client sees"]}),!z&&e.jsxs("button",{onClick:H,disabled:v,className:"inline-flex items-center gap-1.5 px-4 py-2 rounded-lg text-[11px] font-bold disabled:opacity-50",style:{background:"#fff",color:"#BE123C",border:"1px solid rgba(190,18,60,0.3)"},children:[e.jsx(zi,{size:12})," Revoke link"]})]}),D&&e.jsx("div",{className:"mt-4 rounded-xl p-3",style:{background:"#F8FAFC",border:"1px solid #EEF2F7"},children:e.jsx(v$,{plan:Y,preview:!0})})]}):e.jsxs(e.Fragment,{children:[e.jsxs("p",{className:"text-[11.5px] mb-4 leading-relaxed",style:{color:pi},children:["Issues a private, single-plan link and moves the plan to ",e.jsx("strong",{children:"Ready for Client"})," using the existing plan status field. The client sees their goals, assessment summary, personalized recommendations, timeline, investment summary and home-care guidance â never a treatment menu."]}),e.jsxs("button",{onClick:q,disabled:v||t.pathway.length===0,className:"inline-flex items-center gap-2 px-5 py-2.5 rounded-lg text-xs font-bold text-white disabled:opacity-50",style:{background:"linear-gradient(135deg, #0D9488, #0F766E)"},children:[v?e.jsx(de,{size:13,className:"animate-spin"}):e.jsx(Hs,{size:13})," Send for Client Review"]}),t.pathway.length===0&&e.jsx("p",{className:"text-[11px] mt-2",style:{color:"#B45309"},children:"Add at least one recommended step in the Treatment Plan Builder first."})]})}),e.jsx(Fc,{icon:Ye,title:"Email the Personalized Plan",step:"Step 2",children:e.jsx(ice,{plan:t,comms:u,actor:s,hasToken:!!V,onSent:async()=>{await R(),a()}})}),e.jsxs(Fc,{icon:Ie,title:"Client Approval Record",step:"Step 3",children:[A?e.jsxs("div",{className:"rounded-xl px-4 py-3.5 text-[12px] leading-relaxed mb-4",style:{background:A.bg,border:`1px solid ${A.color}33`,color:A.color},children:[e.jsx("strong",{children:A.label}),r.client_decision_at&&e.jsxs(e.Fragment,{children:[" · ",new Date(r.client_decision_at).toLocaleString()]}),r.approved_version&&e.jsxs(e.Fragment,{children:[" · approved plan v",r.approved_version]}),r.client_confirmation_name&&e.jsxs(e.Fragment,{children:[" · confirmed by ",r.client_confirmation_name]}),r.client_decision_note&&e.jsxs("div",{className:"mt-1 italic",children:['"',r.client_decision_note,'"']})]}):e.jsx("p",{className:"text-[11.5px] mb-4 leading-relaxed",style:{color:pi},children:"The client can respond on their own private link. If they respond in person or by phone, record it here â the audit trail is identical either way."}),!z&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"grid sm:grid-cols-2 gap-3 mb-3",children:[e.jsxs("div",{children:[e.jsx("label",{className:Mj,style:{color:pi},children:"Client confirmation name"}),e.jsx("input",{className:Lj,style:Oj,value:E,onChange:te=>P(te.target.value)})]}),e.jsxs("div",{children:[e.jsx("label",{className:Mj,style:{color:pi},children:"Context (optional)"}),e.jsx("input",{className:Lj,style:Oj,value:_,onChange:te=>C(te.target.value),placeholder:"Confirmed by phone, wants to start in Mayâ¦"})]})]}),e.jsx("div",{className:"flex flex-wrap gap-2",children:h$.map(te=>e.jsxs("button",{onClick:()=>G(te.id),disabled:v,className:"inline-flex items-center gap-1.5 px-3.5 py-2 rounded-full text-[11px] font-bold disabled:opacity-50",style:{background:te.bg,color:te.color,border:`1px solid ${te.color}33`},children:[te.id==="approved"?e.jsx(xt,{size:11}):te.id==="declined"?e.jsx(kt,{size:11}):e.jsx(X_,{size:11}),te.label]},te.id))})]})]}),e.jsx(Fc,{icon:Vl,title:"Invoice Preparation",step:"Step 4",children:z?h?e.jsx(de,{size:16,className:"animate-spin",style:{color:fh}}):i?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"text-[12px] space-y-1",style:{color:"#475569"},children:[e.jsxs("p",{children:["Subtotal ",e.jsx("strong",{style:{color:uo},children:tt(i.subtotal_cents)})]}),i.consultation_credit_cents>0&&e.jsxs("p",{children:["Consultation credit â",tt(i.consultation_credit_cents)]}),e.jsxs("p",{className:"text-[13px]",children:["Total due at invoicing ",e.jsx("strong",{style:{color:uo},children:tt(i.total_due_cents)})]}),e.jsxs("p",{className:"text-[10.5px] pt-1",style:{color:pi},children:[i.line_items.length," line item(s) · approved v",i.approved_version??t.version,i.approval_recorded_at?` · ${new Date(i.approval_recorded_at).toLocaleStr
1299ing()}`:""]})]}),e.jsxs("div",{className:"mt-4",children:[e.jsx("input",{className:`${Lj} mb-2`,style:Oj,value:F,onChange:te=>I(te.target.value),placeholder:"Hand-off note for the business office (optional)"}),e.jsx("div",{className:"flex flex-wrap gap-2",children:wN.map(te=>e.jsx("button",{onClick:()=>X(te.id),disabled:v||te.id===i.status,className:"px-3 py-1.5 rounded-full text-[11px] font-bold disabled:opacity-45",style:te.id===i.status?{background:te.color,color:"#fff",border:`1px solid ${te.color}`}:{background:te.bg,color:te.color,border:`1px solid ${te.color}33`},children:te.label},te.id))}),e.jsx("p",{className:"text-[10.5px] mt-2.5 leading-relaxed",style:{color:pi},children:$x(i.status).hint})]})]}):e.jsxs("button",{onClick:W,disabled:v,className:"inline-flex items-center gap-2 px-5 py-2.5 rounded-lg text-xs font-bold text-white disabled:opacity-50",style:{background:"linear-gradient(135deg, #0F172A, #134E4A)"},children:[v?e.jsx(de,{size:13,className:"animate-spin"}):e.jsx(Lb,{size:13})," Prepare Investment Summary"]}):e.jsx("p",{className:"text-[11.5px] leading-relaxed",style:{color:pi},children:"Available once the client approves their plan. Converts the approved plan into an internal investment summary the invoice is then generated from."})}),e.jsx(Fc,{icon:cx,title:"Invoice & Payment",step:"Step 5",children:h?e.jsx(de,{size:16,className:"animate-spin",style:{color:fh}}):e.jsx(lce,{plan:t,prep:i,invoice:l,approved:z,actor:s,onChanged:async()=>{await R(),a()}})}),e.jsx(Fc,{icon:_a,title:"Treatment Scheduling, History & Follow-Up Care",step:"Step 6",children:z?h?e.jsx(de,{size:16,className:"animate-spin",style:{color:fh}}):m.length===0?e.jsxs("button",{onClick:Q,disabled:v,className:"inline-flex items-center gap-2 px-5 py-2.5 rounded-lg text-xs font-bold text-white disabled:opacity-50",style:{background:"linear-gradient(135deg, #0D9488, #0F766E)"},children:[v?e.jsx(de,{size:13,className:"animate-spin"}):e.jsx(_a,{size:13})," Generate Scheduling Queue"]}):e.jsxs(e.Fragment,{children:[(l==null?void 0:l.status)!=="paid"&&e.jsx("p",{className:"text-[11px] mb-3 rounded-lg px-3 py-2",style:{background:"rgba(218,165,32,0.08)",border:"1px solid rgba(218,165,32,0.28)",color:"#7A5600"},children:"Invoice not yet settled â sessions can be planned, and scheduling is fully ready once payment completes."}),e.jsx(uce,{sessions:m,actor:s,busy:v,onChange:K}),e.jsxs("p",{className:"text-[10.5px] mt-3 leading-relaxed flex items-start gap-1.5",style:{color:pi},children:[e.jsx(Vt,{size:11,className:"shrink-0 mt-0.5",style:{color:fh}}),"Approved Plan â Invoice â Scheduled Treatments â Treatment History â Follow-Up Care."]})]}):e.jsx("p",{className:"text-[11.5px] leading-relaxed",style:{color:pi},children:"Available after approval. Expands the approved pathway into one row per session, then records progress, home-care and follow-up notes as each session is delivered. The existing booking system continues to own appointments."})}),e.jsx(Fc,{icon:Y_,title:"Client Relationship Record",step:"Overview",children:e.jsx(hce,{stages:J})})]})]})]})},N$=[{id:"today",label:"Today"},{id:"week",label:"This Week"},{id:"month",label:"This Month"},{id:"quarter",label:"This Quarter"},{id:"year",label:"This Year"},{id:"all",label:"All Time"},{id:"custom",label:"Custom Range"}],Bj=t=>new Date(t.getFullYear(),t.getMonth(),t.getDate()),Tc=t=>new Date(t.getFullYear(),t.getMonth(),t.getDate(),23,59,59,999);function fce(t,s,n){var i;const a=new Date,r=((i=N$.find(o=>o.id===t))==null?void 0:i.label)||"All Time";if(t==="all")return{key:t,label:r,from:null,to:null};if(t==="custom"){const o=s?Bj(new Date(`${s}T00:00:00`)):null,l=Tc(n?new Date(`${n}T00:00:00`):a);return{key:t,label:o?`${o.toLocaleDateString()} â ${(l||a).toLocaleDateString()}`:"Custom Range",from:o,to:l}}if(t==="today")return{key:t,label:r,from:Bj(a),to:Tc(a)};if(t==="week"){const o=a.getDay(),l=new Date(a);return l.setDate(a.getDate()-(o+6)%7),{key:t,label:r,from:Bj(l),to:Tc(a)}}if(t==="month")return{key:t,label:r,from:new Date(a.getFullYear(),a.getMonth(),1),to:Tc(a)};if(t==="quarter"){const o=Math.floor(a.getMonth()/3)*3;return{key:t,label:r,from:new Date(a.getFullYear(),o,1),to:Tc(a)}}return{key:t,label:r,from:new Date(a.getFullYear(),0,1),to:Tc(a)}}const Rg=(t,s)=>{if(!s.from&&!s.to)return!0;
1299if(!t)return!1;const n=new Date(t).getTime();return!(Number.isNaN(n)||s.from&&n<s.from.getTime()||s.to&&n>s.to.getTime())};function gce(t,s,n,a,r){return{range:t,consultations:s.filter(i=>Rg(i.created_at,t)),plans:n.filter(i=>Rg(i.created_at,t)),invoices:a.filter(i=>Rg(i.created_at,t)),sessions:r.filter(i=>Rg(i.created_at,t))}}const mk=t=>t.filter(s=>s.status!=="void"),_$=t=>{const s=t;return!!(s.last_emailed_at||s.shared_at||s.client_viewed_at||s.client_decision)||["ready_for_client","client_approved","client_declined","completed"].includes(t.status)},pk=t=>t.client_decision==="approved"||t.status==="client_approved"||t.status==="completed";function yce(t){const s=mk(t.invoices),n=t.consultations.filter(r=>r.fee_paid).reduce((r,i)=>r+(i.consultation_fee_cents||0),0),a=s.reduce((r,i)=>r+(i.amount_paid_cents||0),0);return{consultationRevenueCents:n,consultationCount:t.consultations.length,consultationsPaid:t.consultations.filter(r=>r.fee_paid).length,plansCreated:t.plans.length,plansSent:t.plans.filter(_$).length,plansApproved:t.plans.filter(pk).length,invoicesGenerated:s.length,paymentsCollectedCents:a,outstandingCents:s.reduce((r,i)=>r+Math.max(0,(i.total_due_cents||0)-(i.amount_paid_cents||0)),0),treatmentsCompleted:t.sessions.filter(r=>r.status==="completed").length,totalRevenueCents:n+a}}const bce=["assessment_completed","plan_in_progress","plan_sent","client_approved","treatment_scheduled","completed"];function vce(t){const s=mk(t.invoices),n=t.consultations.length,a=t.consultations.filter(x=>bce.includes(x.status)).length,r=t.plans.length,i=t.plans.filter(_$).length,o=t.plans.filter(pk).length,l=s.length,c=s.filter(x=>(x.amount_paid_cents||0)>0).length,u=new Set(t.sessions.filter(x=>x.status==="completed").map(x=>x.plan_id)).size,p=new Set(t.sessions.filter(x=>x.status==="follow_up"||x.follow_up_recommendation||x.follow_up_due).map(x=>x.plan_id)).size,m=[{key:"requested",label:"Consultation Requested",value:n,hint:"Consultation records in the pipeline for this period."},{key:"completed",label:"Consultation Completed",value:a,hint:"Assessment completed or beyond."},{key:"plan",label:"Treatment Plan Created",value:r,hint:"Personalized Skin & Wellness Plans drafted."},{key:"sent",label:"Plan Sent to Client",value:i,hint:"Private plan link issued or emailed."},{key:"approved",label:"Plan Approved",value:o,hint:"Client approved the recommendation."},{key:"invoice",label:"Invoice Generated",value:l,hint:"Approved plan converted into an invoice."},{key:"paid",label:"Payment Collected",value:c,hint:"Payment recorded on the existing Zorganics rail."},{key:"treated",label:"Treatment Completed",value:u,hint:"Clients with at least one delivered session."},{key:"follow_up",label:"Follow-Up Required",value:p,hint:"Clients with outstanding follow-up care."}];return m.map((x,h)=>{const y=h===0?null:m[h-1].value;return{...x,rate:y===null?null:y===0?0:Math.round(x.value/y*1e3)/10}})}function jce(t,s){const n=mk(t.invoices),a=n.reduce((h,y)=>h+(y.amount_paid_cents||0),0),r=n.reduce((h,y)=>h+Math.max(0,(y.total_due_cents||0)-(y.amount_paid_cents||0)),0),i=t.plans.filter(pk),o=i.reduce((h,y)=>h+(y.estimated_total_cents||0),0),l=t.consultations.filter(h=>h.fee_paid).reduce((h,y)=>h+(y.consultation_fee_cents||0),0),c=new Set;t.consultations.forEach(h=>c.add(h.client_email.toLowerCase())),t.plans.forEach(h=>h.client_email&&c.add(h.client_email.toLowerCase()));const u=t.plans.filter(h=>!["client_declined","completed"].includes(h.status)).length,p=t.sessions.filter(h=>h.status==="follow_up"||h.follow_up_recommendation).length,m=s.map(h=>({label:h.label,color:h.color,count:t.invoices.filter(y=>y.status===h.id).length})),x=n.reduce((h,y)=>h+(y.total_due_cents||0),0);return{collectedCents:a,pendingCents:r,averageApprovedPlanCents:i.length?Math.round(o/i.length):0,averageClientValueCents:c.size?Math.round((a+l)/c.size):0,activeTreatmentPlans:u,followUpOpportunities:p,collectionRate:x?Math.round(a/x*1e3)/10:0,invoiceStatusMix:m}}const Ig=t=>(t||"").toLowerCase().trim();function wce(t,s){const n=new Map;s.consultations.forEach(v=>{const g=Ig(v.client_email);g&&n.set(g,(n.get(g)||0)+1)});const a=new Map;s.plans.forEach(v=>{const g=Ig(v.client_email);g&&a.set(g,(a.get(g)||0)+1)});const r=new Set;t.consultations.forEach(v=>r.add(Ig(v.client_email))),t.plans.forEach(v=>{const g=Ig(v.client_email);g&&r.add(g)}),r.delete("");const i=[...r].filter(v=>(n.get(v)||0)>1||(a.get(v)||0)>1).length,o=new Map;s.sessions.forEach(v=>{const g=o.get(v.plan_id)||[];g.push(v),o.set(v.plan_id,g)});const l=new Set(s.invoices.filter(v=>
1299v.status==="paid").map(v=>v.plan_id));let c=0,u=0,p=0;t.plans.forEach(v=>{const g=o.get(v.id)||[];if(!g.length)return;u+=1,g.filter(f=>f.status==="completed").length>1&&(p+=1),g.every(f=>f.status==="completed"||f.status==="cancelled")&&(l.has(v.id)||!s.invoices.some(f=>f.plan_id===v.id))&&(c+=1)});const m=Date.now()-30*24*60*60*1e3,x=s.sessions.filter(v=>{const g=new Date(v.updated_at||v.created_at).getTime();return!Number.isNaN(g)&&g>=m&&(v.status==="completed"||!!v.progress_notes||!!v.follow_up_recommendation)}).length,h=new Date().toISOString().slice(0,10),y=s.sessions.filter(v=>{const g=v.follow_up_due;return v.status==="follow_up"||!!g&&g<=h}).length;return{totalClients:r.size,returningClients:i,returnRate:r.size?Math.round(i/r.size*1e3)/10:0,completedJourneys:c,followUpsDue:y,careActivityLast30:x,planCompletionRate:u?Math.round(c/u*1e3)/10:0,multiSessionClients:p}}const zp=(t,s,n=8)=>[...t.entries()].map(([a,r])=>({label:a,count:r,pct:s?Math.round(r/s*100):0})).sort((a,r)=>r.count-a.count).slice(0,n);function Nce(t){const s=t.consultations.length,n=new Map;t.consultations.forEach(m=>{const x=m.source_booking_id&&m.source_intake_id?"Booked Consultation + Intake":m.source_booking_id?"Paid Consultation Booking":m.source_intake_id?"Pre-Visit Intake Form":"Added by Staff";n.set(x,(n.get(x)||0)+1)});const a=new Map;t.consultations.forEach(m=>{const x=m.campus||"Not specified";a.set(x,(a.get(x)||0)+1)});const r=new Map;t.consultations.forEach(m=>{const x=new Date(m.created_at);if(Number.isNaN(x.getTime()))return;const h=`${x.getFullYear()}-${String(x.getMonth()+1).padStart(2,"0")}`;r.set(h,(r.get(h)||0)+1)});const i=new Map,o=new Map;t.consultations.forEach(m=>m.concerns.forEach(x=>{o.set(x,(o.get(x)||0)+1);const h=d$(x)||"other",y=h==="face"?"Facial Concerns":h==="body"?"Body Concerns":h==="wellness"?"Wellness Goals":"Other";i.set(y,(i.get(y)||0)+1)}));const l=new Map;t.plans.forEach(m=>m.pathway.forEach(x=>{x.treatment&&l.set(x.treatment,(l.get(x.treatment)||0)+1)}));const c=[...o.values()].reduce((m,x)=>m+x,0),u=[...l.values()].reduce((m,x)=>m+x,0),p=[...i.values()].reduce((m,x)=>m+x,0);return{sources:zp(n,s,6),campuses:zp(a,s,6),newClientsByMonth:[...r.entries()].sort((m,x)=>m[0].localeCompare(x[0])).slice(-12).map(([m,x])=>({month:new Date(`${m}-01T00:00:00`).toLocaleDateString(void 0,{month:"short",year:"2-digit"}),count:x})),concernCategories:zp(i,p,4),topConcerns:zp(o,c,8),topPathways:zp(l,u,8)}}function _ce(t,s,n,a,r,i){return[["Zorganics Med Spa â Internal Revenue Report"],["Reporting period",t.range.label],["Generated",new Date().toLocaleString()],[],["REVENUE OVERVIEW"],["Consultation revenue",tt(s.consultationRevenueCents)],["Consultation count",s.consultationCount],["Plans created",s.plansCreated],["Plans sent to clients",s.plansSent],["Plans approved",s.plansApproved],["Invoices generated",s.invoicesGenerated],["Payments collected",tt(s.paymentsCollectedCents)],["Outstanding balances",tt(s.outstandingCents)],["Completed treatments",s.treatmentsCompleted],["Total revenue",tt(s.totalRevenueCents)],[],["CONVERSION FUNNEL","Count","Conversion from previous"],...n.map(l=>[l.label,l.value,l.rate===null?"â":`${l.rate}%`]),[],["FINANCIAL INSIGHTS"],["Revenue collected",tt(a.collectedCents)],["Pending revenue",tt(a.pendingCents)],["Average approved plan value",tt(a.averageApprovedPlanCents)],["Average client value",tt(a.averageClientValueCents)],["Active treatment plans",a.activeTreatmentPlans],["Follow-up opportunities",a.followUpOpportunities],["Collection rate",`${a.collectionRate}%`],[],["RETENTION INSIGHTS"],["Clients in period",r.totalClients],["Returning clients",r.returningClients],["Return rate",`${r.returnRate}%`],["Completed treatment journeys",r.completedJourneys],["Plan completion rate",`${r.planCompletionRate}%`],["Follow-ups due",r.followUpsDue],["Care activity (last 30 days)",r.careActivityLast30],[],["CONSULTATION SOURCES","Count","Share"],...i.sources.map(l=>[l.label,l.count,`${l.pct}%`]),[],["POPULAR CONCERNS","Count","Share"],...i.topConcerns.map(l=>[l.label,l.count,`${l.pct}%`]),[],["MOST REQUESTED CARE PATHWAYS","Count","Share"],...i.topPathways.map(l=>[l.label,l.count,`${l.pct}
1299%`])].map(l=>l.map(c=>`"${String(c??"").replace(/"/g,'""')}"`).join(",")).join(` 1300`)}const y4="#0F172A",kN="#64748B",b4="#0D9488",kce=t=>t===null?kN:t>=70?"#15803D":t>=40?"#B45309":"#BE123C",Sce=({stages:t})=>{var n;const s=Math.max(1,((n=t[0])==null?void 0:n.value)||1);return e.jsxs("div",{className:"rounded-2xl p-6 bg-white",style:{border:"1px solid #E7EDF3"},children:[e.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[e.jsx(ts,{size:14,style:{color:b4}}),e.jsx("p",{className:"text-[10px] font-bold uppercase tracking-[0.22em]",style:{color:b4},children:"Client Conversion Funnel"})]}),e.jsx("p",{className:"text-[11.5px] mb-5 leading-relaxed",style:{color:kN},children:"Consultation Requested â Consultation Completed â Plan Created â Plan Sent â Plan Approved â Invoice Generated â Payment Collected â Treatment Completed â Follow-Up Required."}),e.jsx("div",{className:"space-y-2.5",children:t.map((a,r)=>{const i=Math.max(3,Math.round(a.value/s*100));return e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center justify-between gap-3 mb-1",children:[e.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[e.jsx("span",{className:"w-5 h-5 rounded-full flex items-center justify-center text-[9.5px] font-bold shrink-0",style:{background:"#F1F5F9",color:kN},children:r+1}),e.jsx("span",{className:"text-[12.5px] font-semibold truncate",style:{color:y4},children:a.label})]}),e.jsxs("div",{className:"flex items-center gap-3 shrink-0",children:[a.rate!==null&&e.jsxs("span",{className:"inline-flex items-center gap-1 text-[10.5px] font-bold",style:{color:kce(a.rate)},title:"Conversion from the previous stage",children:[e.jsx(t5,{size:10})," ",a.rate,"%"]}),e.jsx("span",{className:"text-[13px] font-bold tabular-nums",style:{color:y4},children:a.value})]})]}),e.jsx("div",{className:"h-2 rounded-full overflow-hidden",style:{background:"#F1F5F9"},children:e.jsx("div",{className:"h-2 rounded-full transition-all",style:{width:`${i}%`,background:`linear-gradient(90deg, #0D9488 0%, #DAA520 ${Math.min(100,i+30)}%)`}})}),e.jsx("p",{className:"text-[10px] mt-1",style:{color:"#94A3B8"},children:a.hint})]},a.key)})})]})},f1="#0F172A",$h="#64748B",um="#0D9488",rb="#DAA520",zh=({title:t,icon:s,accent:n,children:a,note:r})=>e.jsxs("div",{className:"rounded-2xl p-5 bg-white",style:{border:"1px solid #E7EDF3"},children:[e.jsxs("div",{className:"flex items-center gap-2 mb-4",children:[e.jsx(s,{size:14,style:{color:n}}),e.jsx("p",{className:"text-[10px] font-bold uppercase tracking-[0.22em]",style:{color:n},children:t})]}),a,r&&e.jsx("p",{className:"text-[10px] mt-3.5 leading-relaxed",style:{color:"#94A3B8"},children:r})]}),Vn=({label:t,value:s,color:n})=>e.jsxs("div",{className:"flex items-center justify-between gap-3 py-1.5",style:{borderBottom:"1px solid #F4F7FA"},children:[e.jsx("span",{className:"text-[12px]",style:{color:$h},children:t}),e.jsx("span",{className:"text-[13px] font-bold tabular-nums",style:{color:n||f1},children:s})]}),Lp=({items:t,accent:s,empty:n})=>{if(!t.length)return e.jsx("p",{className:"text-[11.5px]",style:{color:"#94A3B8"},children:n});const a=Math.max(...t.map(r=>r.count),1);return e.jsx("ul",{className:"space-y-2.5",children:t.map(r=>e.jsxs("li",{children:[e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsx("span",{className:"text-[12px] truncate",style:{color:f1},children:r.label}),e.jsxs("span",{className:"text-[11px] font-bold shrink-0 tabular-nums",style:{color:s},children:[r.count," · ",r.pct,"%"]})]}),e.jsx("div",{className:"h-1.5 rounded-full mt-1",style:{background:"#F1F5F9"},children:e.jsx("div",{className:"h-1.5 rounded-full",style:{width:`${Math.round(r.count/a*100)}%`,background:s}})})]},r.label))})},Cce=({data:t})=>e.jsxs(zh,{title:"Financial Insights",icon:Vl,accent:"#15803D",note:"Collected and pending figures are read from invoices settled on the existing Zorganics Med Spa payment rail. No payment is initiated from this report.",children:[e.jsx(Vn,{label:"Revenue collected",value:tt(t.collectedCents),color:"#15803D"}),e.jsx(Vn,{label:"Pending revenue",value:tt(t.pendingCents),color:"#B45309"}),e.jsx(Vn,{label:"Average approved plan value",value:tt(t.averageApprovedPlanCents)}),e.jsx(Vn,{label:"Average client value",value:tt(t.averageClientValueCents)}),e.jsx(Vn,{label:"Active treatment plans",value:t.activeTreatmentPlans,color:um}),e.jsx(Vn,{label:"Follow-up opportunities",value:t.followUpOpportunities,color:rb}),e.jsx(Vn,{label:"Collection rate",value:`${t.collectionRate}%`,color:f1}),e.jsxs("div",{className:"mt-4",children:[e.jsx("p",{className:"text-[10px] font-bold uppercase tracking-[0.16em] mb
1300-2",style:{color:$h},children:"Invoice Status Mix"}),e.jsx("div",{className:"flex flex-wrap gap-1.5",children:t.invoiceStatusMix.map(s=>e.jsxs("span",{className:"px-2.5 py-1 rounded-full text-[10.5px] font-bold",style:{background:`${s.color}14`,color:s.color},children:[s.label," · ",s.count]},s.label))})]})]}),Ace=({data:t})=>e.jsxs(zh,{title:"Client Retention",icon:MP,accent:um,note:"Retention is derived from existing consultation, plan and treatment-session records. Clients are matched on the email already stored on those records.",children:[e.jsx(Vn,{label:"Clients in period",value:t.totalClients}),e.jsx(Vn,{label:"Returning clients",value:t.returningClients,color:um}),e.jsx(Vn,{label:"Return rate",value:`${t.returnRate}%`,color:um}),e.jsx(Vn,{label:"Completed treatment journeys",value:t.completedJourneys,color:"#15803D"}),e.jsx(Vn,{label:"Plan completion rate",value:`${t.planCompletionRate}%`}),e.jsx(Vn,{label:"Clients with multiple sessions",value:t.multiSessionClients}),e.jsx(Vn,{label:"Follow-ups due",value:t.followUpsDue,color:"#BE123C"}),e.jsx(Vn,{label:"Care activity (last 30 days)",value:t.careActivityLast30,color:rb})]}),Ece=({data:t})=>{const s=Math.max(...t.newClientsByMonth.map(n=>n.count),1);return e.jsxs("div",{className:"grid lg:grid-cols-3 gap-5",children:[e.jsxs(zh,{title:"Consultation Sources",icon:ix,accent:"#7C3AED",note:"Inferred from existing ingestion provenance (paid booking vs. pre-visit intake). Reporting only â no marketing automation is created in this phase.",children:[e.jsx(Lp,{items:t.sources,accent:"#7C3AED",empty:"No consultation records in this period."}),e.jsxs("div",{className:"mt-4",children:[e.jsx("p",{className:"text-[10px] font-bold uppercase tracking-[0.16em] mb-2",style:{color:$h},children:"By Campus"}),e.jsx(Lp,{items:t.campuses,accent:"#0369A1",empty:"No campus data recorded."})]})]}),e.jsxs(zh,{title:"Popular Concern Categories",icon:Qe,accent:rb,note:"Concerns come from the single shared concern taxonomy used by the public consultation pathway â no duplicated lists.",children:[e.jsx(Lp,{items:t.concernCategories,accent:rb,empty:"No concerns recorded yet."}),e.jsxs("div",{className:"mt-4",children:[e.jsx("p",{className:"text-[10px] font-bold uppercase tracking-[0.16em] mb-2",style:{color:$h},children:"Most Requested Concerns"}),e.jsx(Lp,{items:t.topConcerns,accent:"#B45309",empty:"No concerns recorded yet."})]})]}),e.jsxs(zh,{title:"New Client Trend & Care Pathways",icon:ix,accent:um,note:"Care pathway counts are internal planning data and are never surfaced publicly â clients only ever receive a personalized recommendation.",children:[t.newClientsByMonth.length===0?e.jsx("p",{className:"text-[11.5px]",style:{color:"#94A3B8"},children:"No consultations in this period."}):e.jsx("div",{className:"flex items-end gap-1.5 h-24 mb-2",children:t.newClientsByMonth.map(n=>e.jsxs("div",{className:"flex-1 flex flex-col items-center justify-end gap-1",title:`${n.count} new`,children:[e.jsx("span",{className:"text-[9.5px] font-bold",style:{color:f1},children:n.count}),e.jsx("div",{className:"w-full rounded-t",style:{height:`${Math.max(6,n.count/s*72)}px`,background:"linear-gradient(180deg, #0D9488, #0F766E)"}}),e.jsx("span",{className:"text-[8.5px]",style:{color:"#94A3B8"},children:n.month})]},n.month))}),e.jsxs("div",{className:"mt-4",children:[e.jsx("p",{className:"text-[10px] font-bold uppercase tracking-[0.16em] mb-2",style:{color:$h},children:"Most Requested Care Pathways"}),e.jsx(Lp,{items:t.topPathways,accent:um,empty:"No plan pathways recorded yet."})]})]})]})},gu="#0F172A",$g="#64748B",v4="#0D9488",Fce="#DAA520",Tce=({consultations:t,plans:s,invoices:n,sessions:a})=>{const[r,i]=d.useState("month"),[o,l]=d.useState(""),[c,u]=d.useState(""),p=d.useMemo(()=>fce(r,o,c),[r,o,c]),m=d.useMemo(()=>gce(p,t,s,n,a),[p,t,s,n,a]),x=d.useMemo(()=>yce(m),[m]),h=d.useMemo(()=>vce(m),[m]),y=d.useMemo(()=>jce(m,ab),[m]),v=d.useMemo(()=>wce(m,{consultations:t,plans:s,sessions:a,invoices:n}),[m,t,s,a,n]),g=d.useMemo(()=>Nce(m),[m]),N=()=>{const f=_ce(m,x,h,y,v,g),j=URL.createObjectURL(new Blob([f],{type:"text/csv"})),S=document.createElement("a");S.href=j,S.download=`medspa-revenue-report-${new Date().toISOString().slice(0,10)}.csv`,S.click(),URL.revokeObjectURL(j)},b=[{label:"Consultation Revenue",value:tt(x.consultationRevenueCents),icon:Sa,color:"#15803D"},{label:"Consultations",value:x.consultationCount,icon:c2,color:gu},{label:"Plans Created",value:x.plansCreated,icon:Kt,color:"#475569"},{label:"Plans Sent",value:x.plansSent,icon:Hs,color:Fce},{label:"Plans Approved",value:x.plansApproved,icon:Ue,color:"#0F766E"},{label:"Invoices Generated",value:x.invoicesGenerated,icon:cx,color:"#7C3AED"},{label:"Payments Collected",value:tt(x.paymentsCollectedCents),icon:wo,color:"#15803D"},{label:"Outstanding Balances",value:tt(x.outstandingCents),icon:Vl,color:"#B45309"},{label:"Treatments Completed",value:x.treatmentsCompleted,icon:Qe,color:v4},{label:"Total Med Spa Revenue",value:tt(x.totalRevenueCents),icon:La,color:"#0F172A"}];return e.jsxs("div",{children:[e.jsxs("div",{className:"rounded-2xl p-4 mb-5 bg-white flex flex-wrap items-center gap-2.5",style:{border:"1px solid #E7EDF3"},children:[e.jsxs("div",{className:"flex items-center gap-2 mr-1",children:[e.jsx(c2,{size:14,style:{color:v4}}),e.jsx("span",{className:"text-[10px] font-bold uppercase tracking-[0.16em]",style:{color:$g}
1300,children:"Reporting Period"})]}),N$.map(f=>e.jsx("button",{onClick:()=>i(f.id),className:"px-3.5 py-2 rounded-full text-[11.5px] font-bold transition-all",style:r===f.id?{background:gu,color:"#fff"}:{background:"#F8FAFC",color:"#475569",border:"1px solid #E2E8F0"},children:f.label},f.id)),r==="custom"&&e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("input",{type:"date",value:o,onChange:f=>l(f.target.value),className:"px-2.5 py-1.5 rounded-lg text-[11.5px]",style:{border:"1px solid #E2E8F0",color:gu}}),e.jsx("span",{className:"text-[11px]",style:{color:$g},children:"to"}),e.jsx("input",{type:"date",value:c,onChange:f=>u(f.target.value),className:"px-2.5 py-1.5 rounded-lg text-[11.5px]",style:{border:"1px solid #E2E8F0",color:gu}})]}),e.jsx("div",{className:"flex-1"}),e.jsxs("span",{className:"text-[11px] font-semibold",style:{color:$g},children:["Showing: ",e.jsx("strong",{style:{color:gu},children:p.label})]}),e.jsxs("button",{onClick:N,className:"inline-flex items-center gap-2 px-4 py-2 rounded-lg text-[11.5px] font-bold text-white",style:{background:"linear-gradient(135deg, #0D9488, #0F766E)"},children:[e.jsx(d2,{size:13})," Export Report"]})]}),e.jsx("div",{className:"grid grid-cols-2 lg:grid-cols-5 gap-3 mb-5",children:b.map(f=>e.jsxs("div",{className:"rounded-2xl p-4 bg-white",style:{border:"1px solid #E7EDF3",boxShadow:"0 4px 16px rgba(15,23,42,0.03)"},children:[e.jsx(f.icon,{size:14,style:{color:f.color}}),e.jsx("p",{className:"text-[19px] font-bold mt-2 tracking-tight tabular-nums",style:{color:f.color},children:f.value}),e.jsx("p",{className:"text-[9.5px] font-bold uppercase tracking-[0.12em] mt-0.5",style:{color:$g},children:f.label})]},f.label))}),e.jsxs("div",{className:"rounded-2xl p-4 mb-5 flex items-start gap-3",style:{background:"rgba(15,23,42,0.03)",border:"1px solid #E2E8F0"},children:[e.jsx(Xe,{size:14,className:"shrink-0 mt-0.5",style:{color:gu}}),e.jsxs("p",{className:"text-[11.5px] leading-relaxed",style:{color:"#334155"},children:[e.jsx("strong",{children:"Internal leadership reporting only."})," Every figure is derived from existing Med Spa records â consultations, treatment plans, invoices and treatment sessions. This report creates no new tables, writes no data, and never initiates a payment. Client-identifying detail stays in the Consultation Dashboard and the client record; nothing here is published publicly."]})]}),e.jsxs("div",{className:"grid lg:grid-cols-3 gap-5 mb-5",children:[e.jsx("div",{className:"lg:col-span-1",children:e.jsx(Sce,{stages:h})}),e.jsx(Cce,{data:y}),e.jsx(Ace,{data:v})]}),e.jsx(Ece,{data:g}),e.jsxs("div",{className:"rounded-2xl p-4 mt-5 flex items-start gap-3",style:{background:"rgba(13,148,136,0.05)",border:"1px solid rgba(13,148,136,0.22)"},children:[e.jsx(Ie,{size:15,className:"shrink-0 mt-0.5",style:{color:"#0F766E"}}),e.jsxs("p",{className:"text-[11.5px] leading-relaxed",style:{color:"#0F766E"},children:["Data sources: ",e.jsx("strong",{children:"z_medspa_consultations"}),", ",e.jsx("strong",{children:"z_medspa_treatment_plans"}),","," ",e.jsx("strong",{children:"z_medspa_plan_invoices"})," and ",e.jsx("strong",{children:"z_medspa_plan_treatments"})," â all existing tables, read through the dashboard's existing fetchers. The consultation pathway, Treatment Plan Builder, Client Plan Review, invoice workflow, treatment history, treatment library, POS and payment rails are unchanged."]})]})]})},gn="#0F172A",ir="#64748B",Tr="#0D9488",Pc="#DAA520",Pce=[{id:"pipeline",label:"Pipeline",icon:$O},{id:"records",label:"Client Records",icon:Cy},{id:"plans",label:"Treatment Plans",icon:Kt},{id:"completion",label:"Client Approval & Scheduling",icon:Nd},{id:"revenue",label:"Revenue Report",icon:La},{id:"concerns",label:"Concern Analytics",icon:mn},{id:"workflow",label:"Plan Workflow",icon:XP}],Dce=()=>{sn(),Ho({title:"Med Spa Consultation Dashboard | Zorganics Internal",description:"Internal Zorganics Med Spa consultation management dashboard."});const{user:t}=kn(),s=(t==null?void 0:t.email)||"med-spa-staff",[n,a]=d.useState([]),[r,i]=d.useState([]),[o,l]=d.useState("pipeline"),[c,u]=d.useState(!0),[p,m]=d.useState(!1),[x,h]=d.useState(null),[y,v]=d.useState(null),[g,N]=d.use
1300State(""),[b,f]=d.useState("all"),[j,S]=d.useState("all"),[w,_]=d.useState(null),[C,E]=d.useState(null),[P,F]=d.useState(null),[I,D]=d.useState([]),[L,V]=d.useState([]),[B,A]=d.useState([]),[z,M]=d.useState(0),R=d.useCallback(async()=>{u(!0);try{const[J,te,pe,Fe,ke]=await Promise.all([m$(),xle(),Ale(),Dle(),Mle()]);a(J),i(te),D(pe),V(Fe),A(ke),_(Oe=>Oe&&J.find(ue=>ue.id===Oe.id)||null),E(Oe=>Oe&&te.find(ue=>ue.id===Oe.id)||null),F(Oe=>Oe&&te.find(ue=>ue.id===Oe.id)||null),h(null)}catch(J){h(J.message||"Unable to load consultations.")}u(!1)},[]);d.useEffect(()=>{R()},[R]);const T=d.useCallback(async()=>{M(J=>J+1),await R()},[R]),U=async()=>{m(!0),h(null);try{const J=await cle(),te=J.fromBookings+J.fromIntake+J.linkedIntake;v(te===0?"No new consultation submissions to import.":`Imported ${J.fromBookings} booked consultation(s), ${J.fromIntake} new intake record(s), and linked ${J.linkedIntake} intake(s) to existing clients.`),await R(),window.setTimeout(()=>v(null),6e3)}catch(J){h(J.message||"Import failed.")}m(!1)},q=d.useMemo(()=>dle(n),[n]),H=d.useMemo(()=>wle(r),[r]),G=d.useMemo(()=>Ile(r,I,L),[r,I,L]),W=d.useMemo(()=>Yle(r,B,L),[r,B,L]),X=d.useMemo(()=>{const J=g.trim().toLowerCase();return r.filter(te=>{const pe=te;return!!pe.share_token||!!pe.client_decision||["ready_for_client","client_approved","client_declined","completed"].includes(te.status)?J?[te.client_name,te.client_email,te.plan_title,te.provider].filter(Boolean).join(" ").toLowerCase().includes(J):!0:!1})},[r,g]),Q=d.useMemo(()=>{const J=g.trim().toLowerCase();return r.filter(te=>j!=="all"&&te.status!==j?!1:J?[te.client_name,te.client_email,te.plan_title,te.provider].filter(Boolean).join(" ").toLowerCase().includes(J):!0)},[r,g,j]),K=d.useMemo(()=>{const J=g.trim().toLowerCase();return n.filter(te=>b!=="all"&&te.status!==b?!1:J?[te.client_name,te.client_email,te.booking_reference,te.campus,te.assigned_specialist,...te.concerns].filter(Boolean).join(" ").toLowerCase().includes(J):!0)},[n,g,b]),se=()=>{const J=["Client","Email","Phone","Campus","Consultation Date","Status","Specialist","Fee Paid","Intake","Concerns"],te=K.map(Oe=>[Oe.client_name,Oe.client_email,Oe.client_phone||"",Oe.campus||"",Oe.consultation_date||"",jl(Oe.status).label,Oe.assigned_specialist||"Unassigned",Oe.fee_paid?co(Oe.consultation_fee_cents):"Pending",Oe.intake_received?"Received":"Pending",Oe.concerns.join("; ")]),pe=[J,...te].map(Oe=>Oe.map(ue=>`"${String(ue).replace(/"/g,'""')}"`).join(",")).join(` 1301`),Fe=URL.createObjectURL(new Blob([pe],{type:"text/csv"})),ke=document.createElement("a");ke.href=Fe,ke.download=`medspa-consultations-${new Date().toISOString().slice(0,10)}.csv`,ke.click(),URL.revokeObjectURL(Fe)},Y=[{label:"Total Consultations",value:q.total,icon:ts,color:gn},{label:"Active in Pipeline",value:q.active,icon:XP,color:Tr},{label:"Awaiting Intake",value:q.awaitingIntake,icon:mn,color:"#B45309"},{label:"Plans In Progress / Sent",value:q.planningStage,icon:Sa,color:Pc},{label:"Follow-Up Required",value:q.followUp,icon:Di,color:"#BE123C"},{label:"Consultation Credits Held",value:co(q.feeCreditCents),icon:Vl,color:"#15803D"}];return e.jsxs("div",{className:"min-h-screen",style:{background:"linear-gradient(160deg, #F8FAFC 0%, #F0FDFA 100%)"},children:[e.jsx("div",{className:"text-white",style:{background:"linear-gradient(135deg, #0F172A, #134E4A)"},children:e.jsxs("div",{className:"max-w-[1400px] mx-auto px-6 py-8",children:[e.jsxs(be,{to:"/",className:"inline-flex items-center gap-2 text-white/60 hover:text-white text-xs mb-4 transition-colors",children:[e.jsx(Je,{size:14})," Back to Zorganics"]}),e.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-4",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"w-12 h-12 rounded-xl flex items-center justify-center",style:{background:"linear-gradient(135deg, #0D9488, #0F766E)"},children:e.jsx(Sa,{size:22})}),e.jsxs("div",{children:[e.jsx("h1",{className:"text-2xl font-bold tracking-tight",children:"Med Spa Consultation Dashboard"}),e.jsx("p",{className:"text-[11px] text-white/60 mt-0.5 uppercase tracking-[0.18em]",children:"Personalized Skin & Wellness Consultation · Internal Clinical Operations"})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("button",{onClick:U,disabled:p,className:"inline-flex items-center gap-2 px-4 py-2.5 rounded-lg text-xs font-bold disabled:opacity-50",style:{background:"rgba(255,255,255,0.12)",border:"1px solid rgba(255,255,255,0.2)"},children:[p?e.jsx(de,{size:13,className:"animate-spin"}):e.jsx(d2,{size:13}),"Import New Submissions"]}),e.jsxs("button",{onClick:R,className:"inline-flex items-center gap-2 px-4 py-2.5 rounded-lg text-xs font-bold",style:{background:"#DAA520",color:"#0F172A"},children:[e.jsx(Be,{size:13})," Refresh"]})]})]}),e.jsxs("p",{className:"text-[11px] text-white/55 mt-5 flex items-center gap-1.5 max-w-3xl leading-relaxed",children:[e.jsx(Xe,{size:11,style:{color:Pc}}),"Confidential. Reads the existing public consultation pathway (paid bookings + pre-visit intake) without modifying it. Treatment library, pricing, POS, payment rail
1301s and all other Zorganics entities are untouched."]})]})}),e.jsxs("div",{className:"max-w-[1400px] mx-auto px-6 py-8",children:[y&&e.jsxs("div",{className:"mb-5 rounded-xl px-4 py-3 text-xs font-semibold flex items-center gap-2",style:{background:"rgba(13,148,136,0.08)",border:"1px solid rgba(13,148,136,0.25)",color:"#0F766E"},children:[e.jsx(Ie,{size:14})," ",y]}),x&&e.jsxs("div",{className:"mb-5 rounded-xl px-4 py-3 text-xs font-semibold flex items-center gap-2",style:{background:"rgba(220,38,38,0.06)",border:"1px solid rgba(220,38,38,0.25)",color:"#B91C1C"},children:[e.jsx(Mt,{size:14})," ",x]}),e.jsx("div",{className:"grid grid-cols-2 lg:grid-cols-6 gap-3 mb-7",children:Y.map(J=>e.jsxs("div",{className:"rounded-2xl p-4 bg-white",style:{border:"1px solid #E7EDF3",boxShadow:"0 4px 16px rgba(15,23,42,0.04)"},children:[e.jsx(J.icon,{size:15,style:{color:J.color}}),e.jsx("p",{className:"text-2xl font-bold mt-2 tracking-tight",style:{color:gn},children:J.value}),e.jsx("p",{className:"text-[10px] font-bold uppercase tracking-[0.12em] mt-0.5",style:{color:ir},children:J.label})]},J.label))}),e.jsx("div",{className:"flex flex-wrap gap-2 mb-6",children:Pce.map(J=>e.jsxs("button",{onClick:()=>l(J.id),className:"inline-flex items-center gap-2 px-4 py-2.5 rounded-full text-xs font-bold transition-all",style:o===J.id?{background:gn,color:"#fff"}:{background:"#fff",color:"#475569",border:"1px solid #E2E8F0"},children:[e.jsx(J.icon,{size:13})," ",J.label]},J.id))}),c?e.jsxs("div",{className:"py-24 text-center",children:[e.jsx(de,{size:26,className:"animate-spin mx-auto",style:{color:Tr}}),e.jsx("p",{className:"text-xs mt-3",style:{color:ir},children:"Loading consultation recordsâ¦"})]}):e.jsxs(e.Fragment,{children:[(o==="pipeline"||o==="records"||o==="plans")&&e.jsxs("div",{className:"flex flex-wrap items-center gap-3 mb-5",children:[e.jsxs("div",{className:"relative flex-1 min-w-[240px]",children:[e.jsx(Bt,{size:14,className:"absolute left-3 top-1/2 -translate-y-1/2",style:{color:"#94A3B8"}}),e.jsx("input",{value:g,onChange:J=>N(J.target.value),placeholder:"Search client, email, reference, concern, specialistâ¦",className:"w-full pl-9 pr-3 py-2.5 rounded-lg text-sm bg-white focus:outline-none focus:ring-2 focus:ring-teal-500/30",style:{border:"1px solid #E2E8F0",color:gn}})]}),o==="plans"?e.jsxs("select",{value:j,onChange:J=>S(J.target.value),className:"px-3 py-2.5 rounded-lg text-sm bg-white",style:{border:"1px solid #E2E8F0",color:gn},children:[e.jsx("option",{value:"all",children:"All plan statuses"}),Ix.map(J=>e.jsx("option",{value:J.id,children:J.label},J.id))]}):e.jsxs("select",{value:b,onChange:J=>f(J.target.value),className:"px-3 py-2.5 rounded-lg text-sm bg-white",style:{border:"1px solid #E2E8F0",color:gn},children:[e.jsx("option",{value:"all",children:"All statuses"}),Mm.map(J=>e.jsx("option",{value:J.id,children:J.label},J.id))]}),o!=="plans"&&e.jsxs("button",{onClick:se,className:"inline-flex items-center gap-2 px-4 py-2.5 rounded-lg text-xs font-bold text-white",style:{background:"linear-gradient(135deg, #0D9488, #0F766E)"},children:[e.jsx(d2,{size:13})," Export CSV"]})]}),n.length===0&&o!=="plans"&&o!=="workflow"&&o!=="concerns"&&o!=="revenue"&&e.jsxs("div",{className:"rounded-2xl p-10 text-center bg-white",style:{border:"1px dashed #CBD5E1"},children:[e.jsx(mn,{size:26,className:"mx-auto mb-3",style:{color:"#94A3B8"}}),e.jsx("p",{className:"text-sm font-bold",style:{color:gn},children:"No consultations in the pipeline yet"}),e.jsxs("p",{className:"text-xs mt-1.5 max-w-md mx-auto leading-relaxed",style:{color:ir},children:["Use ",e.jsx("strong",{children:"Import New Submissions"})," to pull in clients who have reserved the"," ",p1.name," or submitted a confidential pre-visit intake."]})]}),o==="revenue"&&e.jsx(Tce,{consultations:n,plans:r,invoices:B,sessions:L}),o==="plans"&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"grid grid-cols-2 lg:grid-cols-6 gap-3 mb-5",children:[{label:"Total Plans",value:H.total,color:gn},{label:"Drafts",value:H.drafts,color:"#475569"},{label:"Under Review",value:H.awaitingReview,color:"#B45309"},{label:"Ready for Client",value:H.readyForClient,color:Pc},{label:"Client Approved",value:H.approved,color:"#15803D"},{label:"Planned Value",value:co(H.plannedValueCents),color:Tr}].map(J=>e.jsxs("div",{className:"rounded-2xl p-4 bg-white",style:{border:"1px solid #E7EDF3"},children:[e.jsx("p",{className:"text-xl font-bold tracking-tight",style:{color:J.color},children:J.value}),e.jsx("p",{className:"text-[10px] font-bold uppercase tracking-[0.12em] mt-0.5",style:{color:ir},children:J.label})]},J.label))}),e.jsx(ece,{plans:Q,onOpen:E,onOpenCompletion:F})]}),o==="completion"&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"grid grid-cols-2 lg:grid-cols-6 gap-3 mb-3",children:[{label:"Awaiting Client",value:G.awaitingClient,color:Pc},{label:"Viewed, No Answer",value:G.clientViewed,color:"#B45309"},{label:"Client Approved",value:G.approved,color:"#15803D"},{label:"Ready for Invoice",value:G.readyToInvoice,color:Tr},{label:"Sessions to Schedule",value:G.sessionsToSchedule,color:gn}
1301,{label:"Approved Value",value:co(G.approvedValueCents),color:"#0F766E"}].map(J=>e.jsxs("div",{className:"rounded-2xl p-4 bg-white",style:{border:"1px solid #E7EDF3"},children:[e.jsx("p",{className:"text-xl font-bold tracking-tight",style:{color:J.color},children:J.value}),e.jsx("p",{className:"text-[10px] font-bold uppercase tracking-[0.12em] mt-0.5",style:{color:ir},children:J.label})]},J.label))}),e.jsx("div",{className:"grid grid-cols-2 lg:grid-cols-6 gap-3 mb-5",children:[{label:"Plans Emailed",value:W.plansEmailed,color:Pc},{label:"Opened by Client",value:W.openedByClient,color:Tr},{label:"Invoices Generated",value:W.invoicesGenerated,color:gn},{label:"Awaiting Payment",value:W.awaitingPayment,color:"#B45309"},{label:"Collected",value:co(W.collectedCents),color:"#15803D"},{label:"Follow-Ups Due",value:W.followUpsDue,color:"#BE123C"}].map(J=>e.jsxs("div",{className:"rounded-2xl p-4 bg-white",style:{border:"1px solid #E7EDF3"},children:[e.jsx("p",{className:"text-xl font-bold tracking-tight",style:{color:J.color},children:J.value}),e.jsx("p",{className:"text-[10px] font-bold uppercase tracking-[0.12em] mt-0.5",style:{color:ir},children:J.label})]},J.label))}),e.jsxs("div",{className:"rounded-2xl p-4 mb-5 flex items-start gap-3",style:{background:"rgba(13,148,136,0.05)",border:"1px solid rgba(13,148,136,0.22)"},children:[e.jsx(Ie,{size:15,className:"shrink-0 mt-0.5",style:{color:"#0F766E"}}),e.jsxs("p",{className:"text-[11.5px] leading-relaxed",style:{color:"#0F766E"},children:[e.jsx("strong",{children:"Plan Emailed â Client Reviews â Client Approval â Invoice â Payment â Treatment Scheduling â Treatment History â Follow-Up Care."})," ","Clients receive a personalized recommendation on a private, single-plan link â never a technology or device menu. Invoices are settled on the EXISTING Zorganics Med Spa payment rail; no new payment system was created, and the existing booking system continues to own appointments."]})]}),e.jsx(rce,{plans:X,preps:I,sessions:L,invoices:B,onOpen:F})]}),o==="pipeline"&&n.length>0&&e.jsx(Qle,{records:K,onOpen:_}),o==="records"&&n.length>0&&e.jsx("div",{className:"rounded-2xl overflow-hidden bg-white",style:{border:"1px solid #E7EDF3"},children:e.jsx("div",{className:"overflow-x-auto",children:e.jsxs("table",{className:"w-full text-left",children:[e.jsx("thead",{children:e.jsx("tr",{style:{background:"#F8FAFC"},children:["Client","Contact","Campus","Consultation","Concerns","Specialist","Status",""].map(J=>e.jsx("th",{className:"px-4 py-3 text-[10px] font-bold uppercase tracking-[0.14em]",style:{color:ir},children:J},J))})}),e.jsx("tbody",{children:K.map(J=>{var pe;const te=jl(J.status);return e.jsxs("tr",{className:"hover:bg-slate-50 transition-colors",style:{borderTop:"1px solid #F1F5F9"},children:[e.jsxs("td",{className:"px-4 py-3",children:[e.jsx("p",{className:"text-[13px] font-bold",style:{color:gn},children:J.client_name}),e.jsx("p",{className:"text-[10px]",style:{color:ir},children:J.booking_reference||"â"})]}),e.jsxs("td",{className:"px-4 py-3 text-[11.5px]",style:{color:"#475569"},children:[J.client_email,e.jsx("br",{}),J.client_phone||"â"]}),e.jsx("td",{className:"px-4 py-3 text-[11.5px]",style:{color:"#475569"},children:J.campus||"â"}),e.jsxs("td",{className:"px-4 py-3 text-[11.5px]",style:{color:"#475569"},children:[J.consultation_date?new Date(J.consultation_date+"T00:00:00").toLocaleDateString():"TBD",e.jsx("br",{}),e.jsx("span",{style:{color:J.fee_paid?"#15803D":"#B45309"},children:J.fee_paid?`${co(J.consultation_fee_cents)} credit`:"Fee pending"})]}),e.jsx("td",{className:"px-4 py-3 text-[11px]",style:{color:"#475569"},children:J.concerns.length?`${J.concerns.length} tracked`:"â"}),e.jsx("td",{className:"px-4 py-3 text-[11px]",style:{color:"#475569"},children:((pe=J.assigned_specialist)==null?void 0:pe.split("â")[0].trim())||"Unassigned"}),e.jsx("td",{className:"px-4 py-3",children:e.jsx("span",{className:"px-2.5 py-1 rounded-full text-[10px] font-bold whitespace-nowrap",style:{background:te.bg,color:te.color},children:te.label})}),e.jsx("td",{className:"px-4 py-3",children:e.jsx("button",{onClick:()=>_(J),className:"px-3 py-1.5 rounded-lg text-[11px] font-bold text-white whitespace-nowrap",style:{background:gn},children:"Review"})})]},J.id)})})]})})}),o==="concerns"&&e.jsxs("div",{className:"grid lg:grid-cols-3 gap-5",children:[Dd.map(J=>e.jsxs("div",{className:"rounded-2xl p-5 bg-white",style:{border:"1px solid #E7EDF3"},children:[e.jsx("p",{className:"text-[10px] font-bold uppercase tracking-[0.22em] mb-4",style:{color:Tr},children:J.label}),e.jsx("ul",{className:"space-y-2",children:J.concerns.map(te=>{const pe=n.filter(ke=>ke.concerns.includes(te)).length,Fe=n.length?Math.round(pe/n.length*100):0;return e.jsxs("li",{children:[e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsx("span",{className:"text-[12px]",style:{color:gn},children:te}),e.jsx("span",{className:"text-[11px] font-bold",style:{color:pe?gn:"#CBD5E1"},children:pe})]}),e.jsx("div",{className:"h-1 rounded-full mt-1",style:{background:"#F1F5F9"},children:e.jsx("div",{className:"h-1 rounded-full",style:{width:`${Fe}%`,background:Tr}})})]},te)})})]},J.id)),e.jsxs("div",{className:"lg:col-span-3 rounded-2xl p-5 bg-white",style:{border:"1px solid #E7EDF3"},children:[e.jsx("p",{className:"text-[10px] font-bold uppercase tracking-[0.22em] mb-4",style:{color:Pc},children:"Most Requested Across All Consultations"}),q.topConcerns.length===0?e.jsx("p",{className:"text-xs",style:{color:ir},children:"No concerns recorded yet."}):e.jsx("div",{className:"flex flex-wrap gap-2",children:q.topConcerns.map(J=>e.jsxs("span",{className:"px-3 py-1.5 rounded-full text-[11.5px] font-semibold",style:{background:"#F8FAFC",color:gn,border:"1px solid #E2E8F0"},children:[J.concern," ",e.jsxs("span",{style:{color:Tr},children:["· ",J.count]})]},J.concern))})]})]}),o==="workflow"&&e.jsxs("div",{className:"rounded-2xl p-7 bg-white",style:{border:"1px solid #E7EDF3"},children:[e.jsx("p",{className:"text-[10px] font-bold uppercase tracking-[0.24em] mb-2",style:{color:Pc},children:"Client Journey Architecture"}),e.jsx("h2",{className:"text-xl font-bold mb-2 tracking-tight",style:{color:gn},children:"Consultation â Assessment â Personalized Plan â Client Review â Approval â Invoice â Treatment â Follow-Up"}),e.jsx("p",{className:"text-xs mb-6 max-w-2xl leading-relaxed",style:{color:ir},children:"The full client journey is now managed in this dashboard: the internal Personalized Treatment Plan Builder, the private client review & approval link, plan communication by email, real invoicing settled on the existing Zorganics payment rail, and the ongoing treatment history and follow-up care record."}
1301),e.jsx("div",{className:"grid md:grid-cols-5 gap-3",children:sle.map(J=>e.jsxs("div",{className:"rounded-xl p-4",style:{background:"rgba(13,148,136,0.05)",border:"1px solid rgba(13,148,136,0.25)"},children:[e.jsx("div",{className:"w-6 h-6 rounded-full flex items-center justify-center text-[10px] font-bold mb-2",style:{background:Tr,color:"#fff"},children:J.step}),e.jsx("p",{className:"text-[12.5px] font-bold leading-snug",style:{color:gn},children:J.title}),e.jsx("p",{className:"text-[10.5px] mt-1.5 leading-relaxed",style:{color:ir},children:J.body}),e.jsx("p",{className:"text-[9.5px] font-bold uppercase tracking-[0.14em] mt-2.5",style:{color:Tr},children:"Managed here"})]},J.step))}),e.jsxs("div",{className:"mt-7",children:[e.jsx("p",{className:"text-[10px] font-bold uppercase tracking-[0.22em] mb-3",style:{color:Tr},children:"Internal Plan Lifecycle"}),e.jsx("div",{className:"flex flex-wrap gap-2",children:Ix.map(J=>e.jsxs("div",{className:"rounded-xl px-3.5 py-2.5",style:{background:J.bg,border:`1px solid ${J.color}33`,maxWidth:230},children:[e.jsx("p",{className:"text-[11.5px] font-bold",style:{color:J.color},children:J.label}),e.jsx("p",{className:"text-[10px] mt-0.5 leading-snug",style:{color:ir},children:J.hint})]},J.id))})]}),e.jsxs("div",{className:"mt-6 rounded-xl p-4 flex items-start gap-3",style:{background:"rgba(218,165,32,0.06)",border:"1px solid rgba(218,165,32,0.28)"},children:[e.jsx(Ie,{size:16,className:"shrink-0 mt-0.5",style:{color:"#8A6100"}}),e.jsxs("p",{className:"text-[11.5px] leading-relaxed",style:{color:"#7A5600"},children:["Paid consultation fees are tracked as client credits (",co(q.feeCreditCents)," currently held across active consultations) and carried onto each treatment plan, so invoicing applies them automatically toward the approved plan. Invoices are settled on the existing Zorganics Med Spa payment rail â no new payment system was created and the POS/payment architecture is unchanged."]})]})]})]})]}),w&&e.jsx(Xle,{record:w,actor:s,onClose:()=>_(null),onSaved:R,onOpenPlan:E,planRefreshKey:z}),C&&e.jsx(nce,{plan:C,actor:s,onClose:()=>E(null),onSaved:T}),P&&e.jsx(xce,{plan:P,actor:s,onClose:()=>F(null),onSaved:T})]})},k$={"new-needs-review":"New / Needs Review",tour:"Tour",application:"Application","financial-aid":"Financial Aid",enrollment:"Enrollment","employer-partner":"Employer / Partner","possible-duplicate":"Possible Duplicate"},hk=["new-needs-review","tour","application","financial-aid","enrollment","employer-partner","possible-duplicate"];function S$(t){if(typeof t!="string")return null;const s=t.trim().toLowerCase();if(!s||!s.includes("@"))return null;const[n,a]=s.split("@");if(!n||!a)return null;let r=n.split("+")[0];const i=a.replace(/\.$/,"");return(i==="gmail.com"||i==="googlemail.com")&&(r=r.replace(/\./g,"")),r?`${r}@${i}`:null}function C$(t){if(typeof t!="string")return null;const s=t.replace(/\D/g,"");return s.length<10?null:s.slice(-10)}function A$(t,s){const n=(t||"").trim();if(n){const r=n.split(/\s+/).filter(Boolean);return r.length===1?r[0].slice(0,2).toUpperCase():`${r[0][0]}${r[r.length-1][0]}`.toUpperCase()}const a=(s||"").trim();return a?a.slice(0,2).toUpperCase():"â"}function g1(t){if(!t)return"â";const[s,n]=t.split("@");return n?`${s.slice(0,1)}${"â¢".repeat(Math.max(2,Math.min(6,s.length-1)))}@${n}`:"â¢â¢â¢"}function y1(t){if(!t)return"â";const s=t.replace(/\D/g,"");return s.length<4?"â¢â¢â¢":`(â¢â¢â¢) â¢â¢â¢-${s.slice(-4)}`}const $e=t=>{if(typeof t!="string")return null;const s=t.trim();return s||null},pl=(...t)=>{let s=null;for(const n of t)n&&(!s||new Date(n).getTime()>new Date(s).getTime())&&(s=n);return s},mm=[{key:"sis_leads",label:"Website Leads (sis_leads)",table:"sis_leads",initialStatuses:["new"],hasAttribution:!0,map:t=>{const s=[$e(t.first_name),$e(t.last_name)].filter(Boolean).join(" "),n=[$e(t.utm_source),$e(t.utm_medium),$e(t.utm_campaign)].filter(Boolean).join(" / ")||null;return{recordId:t.id,name:s,email:$e(t.email),phone:$e(t.phone),program:$e(t.program_interest),status:$e(t.status),formType:$e(t.form_type),leadSource:$e(t.source),utm:n,campus:$e(t.preferred_campus),createdAt:t.created_at??null,lastActivityAt:pl(t.updated_at,t.created_at),lastActivityLabel:t.updated_at&&t.updated_at!==t.created_at?"Record updated":"Submitted",isApplication:t.form_type==="apply_now",isTour:t.form_type==="book_tour",isPendingTour:t.form_type==="book_tour"&&!["enrolled","archived"].includes(t.status||""),isFinancialAid:t.form_type==="funding_inquiry",isEmployerPartner:!1,isEnrollment:t.status==="enrolled",organization:null,notes:$e(t.message),detail:{tourOutcome:t.form_type==="book_tour"?"requested":null,tourBookingSource:t.form_type==="book_tour"?"Website tour form":null,applicationSubmittedAt:t.form_type==="apply_now"?t.created_at??null:null,financialAidInterest:t.form_type==="funding_inquiry"}}}},{key:"admissions_applicants",label:"Admissions Applications",table:"admissions_applicants",initialStatuses:["new_applicant","new","submitted"],hasAttribution:!1,map:t=>({recordId:t.id,name:$e(t.full_name)||"",email:$e(t.email),phone:$e(t.phone),program:$e(t.program_of_interest),status:$e(t.status),formType:"application",leadSource:"apply-now",utm:null,campus:null,createdAt:t.created_at??null,lastActivityAt:pl(t.updated_at,t.created_at),lastActivityLabel:t.admin_notes?"Admin notes on file":t.updated_at&&t.updated_at!==t.created_at?"Record updated":"Submitted",isApplication:!0,isTour:!!t.preferred_tour_date,isPendingTour:!!t.preferred_tour_date&&!["enrolled","withdrawn","denied"].includes(t.status||""),isFinancialAid:t.financial_aid_interest===!0,isEmployerPartner:!1,isEnrollment:t.status==="enrolled",organization:null,notes:$e(t.career_goals)||$e(t.educational_background),detail:{tourRequestedFor:t.preferred_tour_date??null,tourOutcome:t.preferred_tour_date?"requested":null,tourBookingSource:t.preferred_tour_date?"Apply-now form (preferred date)":null,applicationSubmittedAt:t.created_at??null,financialAidInterest:t.financial_aid_interest===!0,applicationTable:"admissions_applicants"}})},{key:"activation_tour_bookings",label:"Tour Bookings (activation)",table:"activation_tour_bookings",initialStatuses:["confirmed","pending","new"],hasAttribution:!1,map:t=>({recordId:t.id,name:$e(t.name)||"",email:$e(t.email),phone:$e(t.phone),program:null,status:$e(t.status),formType:$e(t.tour_type)||"campus-tour",leadSource:"activation-tour-slot",utm:null,campus:null,createdAt:t.created_at??null,lastActivityAt:t.created_at??null,lastActivityLabel:t.reminder_24_sent||t.reminder_1_sent?"Reminder sent":"Booked",isApplication:!1,isTour:!0,isPendingTour:!["completed","cancelled","no-show","no_show"].includes(t.status||""),isFinancialAid:!1,isEmployerPartner:!1,isEnrollment:!1,organization:null,notes:null,detail
1301:{tourConfirmedAt:t.starts_at??t.slot_starts_at??t.scheduled_at??null,tourBookingSource:"Activation tour scheduler",tourOutcome:["completed","attended"].includes(t.status||"")?"completed":t.status==="cancelled"?"cancelled":["no-show","no_show"].includes(t.status||"")?"no_show":"scheduled"}})},{key:"campus_tour_requests",label:"Campus Tour Requests",table:"campus_tour_requests",initialStatuses:["new"],hasAttribution:!1,map:t=>{const s=[$e(t.first_name),$e(t.last_name)].filter(Boolean).join(" ");return{recordId:t.id,name:s,email:$e(t.email),phone:$e(t.phone),program:$e(t.program_interest)||$e(t.enrollment_program),status:$e(t.status),formType:"campus_tour_request",leadSource:`campus-tour-${$e(t.campus_slug)||"unknown"}`,utm:null,campus:$e(t.campus_name)||$e(t.campus_slug),createdAt:t.created_at??null,lastActivityAt:pl(t.enrolled_at,t.day_of_sms_sent_at,t.sms_reminder_sent_at,t.reminder_sent_at,t.confirmation_sent_at,t.scheduled_at,t.updated_at,t.created_at),lastActivityLabel:t.enrolled_at?"Enrolled":t.reminder_sent_at||t.sms_reminder_sent_at||t.day_of_sms_sent_at?"Reminder sent":t.confirmation_sent_at?"Confirmation sent":t.scheduled_at?"Tour scheduled":"Submitted",isApplication:!1,isTour:!0,isPendingTour:["new","contacted","scheduled"].includes(t.status||""),isFinancialAid:!1,isEmployerPartner:!1,isEnrollment:!!t.enrolled_at,organization:null,notes:$e(t.notes),detail:{tourRequestedFor:t.preferred_date??null,tourConfirmedAt:t.scheduled_at??null,tourBookingSource:"Campus tour calendar",tourOutcome:t.status==="completed"?"completed":t.status==="cancelled"?"cancelled":["no-show","no_show"].includes(t.status||"")?"no_show":t.scheduled_at||t.status==="scheduled"?"scheduled":"requested",startDate:t.enrollment_start_date??null}}}},{key:"z_scholarship_applications",label:"Scholarship Applications",table:"z_scholarship_applications",initialStatuses:["submitted","new","pending"],hasAttribution:!1,map:t=>({recordId:t.id,name:$e(t.applicant_name)||"",email:$e(t.applicant_email),phone:$e(t.applicant_phone),program:$e(t.program_interest),status:$e(t.status),formType:"scholarship_application",leadSource:"foundation-scholarship",utm:null,campus:null,createdAt:t.created_at??null,lastActivityAt:pl(t.updated_at,t.created_at),lastActivityLabel:t.reviewer_notes?"Reviewer notes on file":"Submitted",isApplication:!0,isTour:!1,isPendingTour:!1,isFinancialAid:!0,isEmployerPartner:!1,isEnrollment:!1,organization:null,notes:$e(t.current_situation)})},{key:"zip_partner_applications",label:"ZIP Partner Applications",table:"zip_partner_applications",initialStatuses:["pending","new"],hasAttribution:!1,map:t=>({recordId:t.id,name:$e(t.contact_name)||"",email:$e(t.contact_email),phone:$e(t.contact_phone),program:$e(t.business_type),status:$e(t.status),formType:"zip_partner_application",leadSource:"zip-partner",utm:null,campus:$e(t.city),createdAt:t.created_at??null,lastActivityAt:t.created_at??null,lastActivityLabel:"Submitted",isApplication:!1,isTour:!1,isPendingTour:!1,isFinancialAid:!1,isEmployerPartner:!0,isEnrollment:!1,organization:$e(t.business_name),notes:$e(t.message)})},{key:"zip_employer_accounts",label:"ZIP Employer Accounts",table:"zip_employer_accounts",initialStatuses:["pending","new"],hasAttribution:!1,map:t=>({recordId:t.id,name:$e(t.contact_person)||"",email:$e(t.email),phone:$e(t.phone),program:$e(t.org_type),status:$e(t.status),formType:"zip_employer_account",leadSource:"zip-employer",utm:null,campus:null,createdAt:t.created_at??null,lastActivityAt:pl(t.last_login_at,t.activated_at,t.created_at),lastActivityLabel:t.last_login_at?"Workspace sign-in":t.activated_at?"Account activated":"Registered",isApplication:!1,isTour:!1,isPendingTour:!1,isFinancialAid:!1,isEmployerPartner:!0,isEnrollment:!1,organization:$e(t.business_name),notes:$e(t.admin_notes)})},{key:"vip_waitlist_entries",label:"VIP Waitlist",table:"vip_waitlist_entries",initialStatuses:["pending","new"],hasAttribution:!0,map:t=>({recordId:t.id,name:$e(t.name)||"",email:$e(t.email),phone:null,program:null,status:$e(t.status),formType:"vip_waitlist",leadSource:$e(t.source),utm:Array.isArray(t.tags)&&t.tags.length?t.tags.join(", "):null,campus:$e(t.campus),createdAt:t.created_at??null,lastActivityAt:pl(t.invited_at,t.updated_at,t.created_at),lastActivityLabel:t.invited_at?"VIP invite sent":"Joined waitlist",isApplication:!1,isTour:!1,isPendingTour:!1,isFinancialAid:!1,isEmployerPartner:!1,isEnrollment:!1,organization:null,notes:null})},{key:"recruitment_contacts",label:"Recruitment Contacts",table:"recruitment_contacts",initialStatuses:["active"],hasAttribution:!0,map:t=>({recordId:t.id,name:$e(t.name)||"",email:$e(t.email),phone:$e(t.phone),program:$e(t.institution_type),status:$e(t.status),formType:"recruitment_contact",leadSource:$e(t.institution_type),utm:Array.isArray(t.tags)&&t.tags.length?t.tags.join(", "):null,campus:$e(t.city),createdAt:t.created_at??null,lastActivityAt:pl(t.last_contacted_at,t.updated_at,t.created_at),lastActivityLabel:t.last_contacted_at?`Contacted (${t.contact_count||0}x)`:"Added to list",isApplication:!1,isTour:!1,isPendingTour:!1,isFinancialAid:!1,isEmployerPartner:!0,isEnrollment:!1,organization:$e(t.institution_name),notes:$e(t.notes)})},{key:"z_foundation_partner_inquiries",label:"Foundation Partner Inquiries",table:"z_foundation_partner_inquiries",initialStatuses:["new","pending"],hasAttribution:!1,map:t=>({recordId:t.id,name:$e(t.contact_name)||"",email:$e(t.contact_email),phone:$e(t.contact_phone),program:$e(t.partner_track),status:$e(t.status),formType:"foundation_partner_inquiry",leadSource:"foundation-partner",utm:null,campus:null,createdAt:t.created_at??null,lastActivityAt:t.created_at??null,lastActivityLabel:"Submitted",isApplication:!1,isTour:!1,isPendingTour:!1,isFinancialAid:!1,isEmployerPartner:!0,isEnrollment:!1,organization:$e(t.organization),notes:$e(t.message)})}];mm.reduce((t,s)=>(t[s.key]=s.label,t),{});const pm=t=>{const s=new Date;return s.setDate(s.getDate()-t),s},Lh=t=>{const s=new Map;for(const n of t){const a=n&&n.trim()?n.trim():"(not set)";s.set(a,(s.get(a)||0)+1)}return Array.from(s.entries()).sort((n,a)=>a[1]-n[1]||n[0].localeCompare(a[0])).map(([n,a])=>({label:n,count:a}))};function xk(t){if(!t)return null;const s=new Date(t).getTime();return Number.isNaN(s)?null:Math.floor((Date.now()-s)/864e5)}const E$=7;function tc(t){if(!t.isInitialStatus)return!1;const s=xk(t.createdAt);return s!==null&&s>E$}function fk(t,s){const n=[];return t.isInitialStatus&&n.push("new-needs-review"),t.isTour&&n.push("tour"),t.isApplication&&n.push("application"),t.isFinancialAid&&n.push("financial-aid"),t.isEnrollment&&n.push("enrollment"),t.isEmployerPartner&&n.push("employer-partner"),s&&n.push("possible-duplicate"),n}function j4(t){var o;const s=new Map,n=l=>{let c=l;for(;s.get(c)&&s.get(c)!==c;)c=s.get(c);return s.set(l,c),c},a=(l,c)=>{const u=n(l),p=n(c);u!==p&&s.set(u,p)};for(const l of t){const c=`rec:${l.key}`;if(s.has(c)||s.set(c,c),l.emailNorm){const u=`email:${l.emailNorm}`;s.has(u)||s.set(u,u),a(c,u)}if(l.phoneNorm){const u=`phone:${l.phoneNorm}`;s.has(u)||s.set(u,u),a(c,u)}}const r=new Map;for(const l of t){const c=n(`rec:${l.key}`),u=r.get(c)||[];u.push(l),r.set(c,u)}const i=[];for(const[l,c]of r.entries()){const u=Array.from(new Set(c.map(N=>
1301N.emailNorm).filter(Boolean))),p=Array.from(new Set(c.map(N=>N.phoneNorm).filter(Boolean))),m=[...c].sort((N,b)=>{const f=N.createdAt?new Date(N.createdAt).getTime():0;return(b.createdAt?new Date(b.createdAt).getTime():0)-f}),x=m.find(N=>N.name&&N.name.trim()),h=((o=x==null?void 0:x.name)==null?void 0:o.trim())||"(no name on record)",y=c.length>1,v=new Set;for(const N of c)fk(N,y).forEach(b=>v.add(b));const g=c.reduce((N,b)=>b.createdAt&&(!N||new Date(b.createdAt)<new Date(N))?b.createdAt:N,null);i.push({id:l,matchedOn:u.length&&p.length?"both":u.length?"email":p.length?"phone":"none",displayName:h,initials:A$(h,u[0]),emails:u,phones:p,records:m,sourceKeys:Array.from(new Set(c.map(N=>N.sourceKey))),categories:hk.filter(N=>v.has(N)),isDuplicate:y,firstSeen:g,lastActivityAt:pl(...c.map(N=>N.lastActivityAt)),staleCount:c.filter(tc).length})}return i.sort((l,c)=>{const u=l.lastActivityAt?new Date(l.lastActivityAt).getTime():0;return(c.lastActivityAt?new Date(c.lastActivityAt).getTime():0)-u})}async function Rce(){const t=pm(7).getTime(),s=pm(30).getTime(),n=pm(90).getTime(),a=await Promise.all(mm.map(async r=>{const i={sourceKey:r.key,sourceLabel:r.label,table:r.table,rowCount:0,error:null,earliest:null,latest:null,statusCounts:[],programCounts:[],formTypeCounts:[],last7:0,last30:0,last90:0,hasAttribution:r.hasAttribution},{data:o,error:l}=await O.from(r.table).select("*").order("created_at",{ascending:!1}).limit(2e3);if(l)return{summary:{...i,error:l.message},records:[]};const u=(o||[]).map((m,x)=>{const h=r.map(m),y=S$(h.email),v=C$(h.phone),g=(h.status||"").toLowerCase();return{...h,key:`${r.key}:${h.recordId??x}`,sourceKey:r.key,sourceLabel:r.label,table:r.table,ref:`${r.key.split("_").map(N=>N[0]).join("").toUpperCase()}-${String(h.recordId||x).slice(0,8)}`,initials:A$(h.name,h.email),emailNorm:y,phoneNorm:v,isInitialStatus:!g||r.initialStatuses.includes(g)}}),p=u.map(m=>m.createdAt?new Date(m.createdAt).getTime():NaN).filter(m=>!Number.isNaN(m));return{summary:{...i,rowCount:u.length,earliest:p.length?new Date(Math.min(...p)).toISOString():null,latest:p.length?new Date(Math.max(...p)).toISOString():null,statusCounts:Lh(u.map(m=>m.status)),programCounts:Lh(u.map(m=>m.program)).filter(m=>m.label!=="(not set)"||u.every(x=>!x.program)),formTypeCounts:Lh(u.map(m=>m.formType)),last7:p.filter(m=>m>=t).length,last30:p.filter(m=>m>=s).length,last90:p.filter(m=>m>=n).length},records:u}}));return{records:a.flatMap(r=>r.records),sources:a.map(r=>r.summary),loadedAt:new Date().toISOString()}}function Ice(t,s){const n=pm(7).getTime(),a=pm(30).getTime(),r=hk.reduce((o,l)=>(o[l]=0,o),{});for(const o of s)for(const l of o.categories)r[l]+=1;const i=o=>o?new Date(o).getTime():NaN;return{totalRecords:t.length,uniquePeople:s.length,new7:t.filter(o=>i(o.createdAt)>=n).length,new30:t.filter(o=>i(o.createdAt)>=a).length,applications:t.filter(o=>o.isApplication).length,pendingTours:t.filter(o=>o.isPendingTour).length,financialAid:t.filter(o=>o.isFinancialAid).length,employerPartner:t.filter(o=>o.isEmployerPartner).length,possibleDuplicates:s.filter(o=>o.isDuplicate).length,stale:t.filter(tc).length,enrollments:t.filter(o=>o.isEnrollment).length,categoryCounts:r}}const w4={dateRange:"all",sourceKey:"all",program:"all",status:"all",category:"all",onlyStale:!1,search:""},$ce=[{value:"all",label:"All time"},{value:"7",label:"Last 7 days"},{value:"30",label:"Last 30 days"},{value:"90",label:"Last 90 days"},{value:"365",label:"Last 12 months"}];function zce(t,s){const n=s.dateRange==="all"?null:pm(Number(s.dateRange)).getTime(),a=s.search.trim().toLowerCase();return t.filter(r=>{if(n!==null){const i=r.createdAt?new Date(r.createdAt).getTime():NaN;if(Number.isNaN(i)||i<n)return!1}return!(s.sourceKey!=="all"&&r.sourceKey!==s.sourceKey||s.program!=="all"&&(r.program||"(not set)")!==s.program||s.status!=="all"&&(r.status||"(not set)")!==s.status||s.onlyStale&&!tc(r)||s.category!=="all"&&s.category!=="possible-duplicate"&&!fk(r,!1).includes(s.category)||a&&![r.name,r.email,r.phone,r.program,r.status,r.organization,r.leadSource,r.utm,r.campus,r.sourceLabel,r.ref].filter(
1301Boolean).join(" ").toLowerCase().includes(a))})}function Lce(t){const s=Lh(t.map(a=>a.program)).filter(a=>a.label!=="(not set)"),n=Lh(t.map(a=>a.status));return{programs:s,statuses:n}}const SN={admissions:"Admissions Prospect",partner:"Employer / Partner / Foundation",community:"Community / Marketing List"},Oce={sis_leads:"admissions",admissions_applicants:"admissions",activation_tour_bookings:"admissions",campus_tour_requests:"admissions",z_scholarship_applications:"admissions",zip_partner_applications:"partner",zip_employer_accounts:"partner",recruitment_contacts:"partner",z_foundation_partner_inquiries:"partner",vip_waitlist_entries:"community"},Oh=t=>Oce[t]??"community",F$=t=>Oh(t.sourceKey)==="admissions",gk=90,Mce={"review-identity":"Hold â identity review"},Yr={high:{bg:"#DCFCE7",fg:"#166534",label:"High intent"},medium:{bg:"#FEF3C7",fg:"#92400E",label:"Medium intent"},low:{bg:"#F1F5F9",fg:"#475569",label:"Low / early"}},Bce=t=>(t||"").toLowerCase().trim(),Uce=["enrolled","registered","started"],qce=["accepted","approved","admitted"],Wce=["completed","attended","complete","toured","showed"],Hce=["scheduled","confirmed","booked","pending"];function T$(t){const s={enrolled:!1,accepted:!1,application:!1,financialAid:!1,tourCompleted:!1,tourScheduled:!1,touches:t.length};for(const n of t){const a=Bce(n.status);(n.isEnrollment||Uce.includes(a))&&(s.enrolled=!0),n.isApplication&&(s.application=!0,qce.includes(a)&&(s.accepted=!0)),n.isFinancialAid&&(s.financialAid=!0),n.isTour&&(Wce.includes(a)?s.tourCompleted=!0:(n.isPendingTour||Hce.includes(a))&&(s.tourScheduled=!0))}return s}function Gce(t){const s=T$(t),n=[];return s.enrolled?(n.push("Enrollment recorded on a source record"),{stage:"enrolled",reasons:n}):s.accepted?(n.push("Application marked accepted/approved"),{stage:"accepted",reasons:n}):s.application&&s.financialAid?(n.push("Application on file"),n.push("Financial-aid activity documented"),{stage:"financial_aid",reasons:n}):s.application?(n.push("Application on file"),{stage:"application",reasons:n}):s.tourCompleted?(n.push("Tour recorded as completed/attended"),{stage:"tour_completed",reasons:n}):s.tourScheduled?(n.push("Tour scheduled and not yet completed"),{stage:"tour_scheduled",reasons:n}):(n.push("Inquiry only â no tour, application or enrollment evidence"),s.financialAid&&n.push("Financial-aid interest noted (not enough for a later stage)"),{stage:"new",reasons:n})}function Vce(t,s){const n=T$(t),a=[];n.enrolled&&a.push({label:"Already enrolled",points:0}),n.accepted&&a.push({label:"Accepted â enrollment paperwork next",points:45}),n.application&&a.push({label:"Application submitted",points:40}),n.tourCompleted?a.push({label:"Completed a campus tour",points:25}):n.tourScheduled&&a.push({label:"Tour scheduled",points:15}),n.financialAid&&a.push({label:"Asked about funding / financial aid",points:20}),n.touches>1&&a.push({label:`${n.touches} separate admissions touches`,points:10}),s!==null&&(s<=30?a.push({label:"Activity in the last 30 days",points:20}):s<=gk?a.push({label:`Last activity ${s} days ago`,points:10}):a.push({label:`No activity for ${s} days`,points:0}));const r=Math.min(100,a.reduce((o,l)=>o+l.points,0)),i=r>=60?"high":r>=30?"medium":"low";return{score:r,level:i,signals:a}}function yk(t,s){const n=t.records.filter(F$),a=n.length>0,r=t.records.some(N=>Oh(N.sourceKey)==="partner"),i=a?"admissions":r?"partner":"community";let o="strong",l="Single verified email address across every matched record";t.emails.length===0?(o="weak",l="No email on file â matched by phone number only"):t.emails.length>1?(o="weak",l=`${t.emails.length} different email addresses were merged by a shared phone number`):t.records.some(N=>!N.emailNorm&&N.phoneNorm)&&(o="weak",l="One or more records joined by phone number only");const c=a?n:t.records,u=c.reduce((N,b)=>{const f=b.lastActivityAt||b.createdAt;return f&&(!N||new Date(f).getTime()>new Date(N).getTime())?f:N},null),p=xk(u),m=p!==null&&p<=gk?"active":"historical",x=m==="active"?`Source activity ${p} day${p===1?"":"s"} ago`:p===null?"No dated activity on any source record":`No source activity for ${p} days â historical record`,{stage:h,reasons:y}=Gce(c),v=Vce(c,p),g=s?"already-in-crm":a?o==="weak"?"review-identity":"eligible":"not-admissions";return{groupId:t.id,audience:i,isAdmissions:a,admissionsRecords:n,identity:o,identityReason:l,lifecycle:m,lifecycleReason:x,derivedStage:h,stageReasons:y,readiness:v,eligibility:g,untouched:c.some(tc),daysSinceActivity:p}}function Zce(t,s){const n=s.filter(r=>r.isAdmissions),a=(r,i)=>i.includes(r.derivedStage);return{admissionsPeople:n.length,activePeople:n.filter(r=>r.lifecycle==="active").length,historicalPeople:n.filter(r=>r.lifecycle==="historical").length,reviewPeople:n.filter(r=>r.identity==="weak").length,untouchedPeople:n.filter(r=>r.untouched).length,applicationPeople:n.filter(r=>a(r,["application","financial_aid","accepted"])).length,tourPeople:n.filter(r=>a(r,["tour_scheduled","tour_completed"])).length,financialAidPeople:n.filter(r=>r.admissionsRecords.some(i=>i.isFinancialAid)).length,enrolledPeople:n.filter(r=>r.derivedStage==="enrolled").length,highReadinessPeople:n.filter(r=>r.readiness.level==="high").length,admissionsRecords:t.filter(r=>Oh(r.sourceKey)==="admissions").length,partnerRecords:t.filter(r=>Oh(r.sourceKey)==="partner").length,communityRecords:t.filter(r=>Oh(r.sourceKey)==="community").length,untouchedRecords:t.filter(r=>F$(r)&&tc(r)).length,partnerPeople:s.filter(r=>r.audience==="partner").length,communityPeople:s.filter(r=>r.audience==="community").length}}function Yce(t){const s={};for(const n of t)s[n.derivedStage]=(s[n.derivedStage]||0)+1;return s}const G0="#B8962E",Kce=t=>[{key:"admissionsPeople",label:"Admissions People",value:t.admissionsPeople,icon:ts,accent:"#1E40AF",hint:"Unique prospective students (grouped identities, not rows)"},{key:"activePeople",label:"Active Prospects",value:t.activePeople,icon:Qe,accent:"#0F766E",hint:`People with source activity in the last ${gk} days`},{key:"historicalPeople",label:"Historical People",value:t.historicalPeople,icon:en,accent:"#475569",hint:"Kept for reporting & future re-engagement â not hot leads"},{key:"reviewPeople",label:"Identity Review",value:t.reviewPeople,icon:zn,accent:"#92400E",hint:"Weak match (shared phone / no email) â human confirms before CRM"},{key:"highReadinessPeople",label:"High Readiness",value:t.highReadinessPeople,icon:_t,accent:"#166534",hint:"Strong documented intent â application, tour or aid activity"},{key:"applicationPeople",label:"Applications (People)",value:t.applicationPeople,icon:mn,accent:"#7C2D12",hint:"People with an application, aid or accepted stage on evidence"},{key:"tourPeople",label:"Tours (People)",value:t.tourPeople,icon:_a,accent:"#92400E",hint:"People with a scheduled or completed tour"},{key:"financialAidPeople",label:"Financial Aid (People)",value:t.financialAidPeople,icon:wo,accent:"#5B21B6",hint:"People with documented funding / aid activity"},{key:"enrolledPeople",label:"Enrolled (People)",value:t.enrolledPeople,icon:dx,accent:"#065F46",hint:"Enrollment recorded on a source record"},{key:"untouchedRecords",label:"Untouched Records > 7 Days",value:t.untouchedRecords,icon:$i,accent:"#991B1B",hint:"SOURCE ROWS still in an initial status â rows, not people"}],Qce=(t,s)=>[{key:"admissionsRecords",label:"Admissions Records",value:t.admissionsRecords,icon:Jx,accent:k,hint:"Source rows in the 5 admissions tables"},{key:"partnerPeople",label:"Employer / Partner People",value:t.partnerPeople,icon:Ws,accent:"#0E7490",hint:`${t.partnerRecords} rows â excluded from admissions KPIs`},{key:"communityPeople",label:"Community List People",value:t.communityPeople,icon:ts,accent:"#7C3AED",hint:`${t.communityRecords} rows (VIP/brand interest) â not student inquiries`},{key:"totalRecords",label:"All Source Records",value:s.totalRecords,icon:$i,accent:"#4B5563",hint:"Every row across all 10 source tables"},{key:"possibleDuplicates",label:"Multi-Record People",value:s.possibleDuplicates,icon:Z_,accent:"#B45309",hint:"One person represented by 2+ source rows (normal, not an error)"}],N4=({card:t,loading:s})=>{const n=t.icon;return e.jsxs("div",{className:"rounded-xl p-4 transition-all hover:-translate-y-0.5",style:{background:"#fff",border:`1px solid ${k}15`,boxShadow:`0 2px 12px ${k}08`},title:t.hint,children:[e.jsxs("div",{className:"flex items-start justify-between gap-2 mb-1.5",children:[e.jsx("p",{className:"text-[9px] uppercase tracking-[0.2em] font-bold leading-tight",style:{color:"#777"},children:t.label}),e.jsx("div",{className:"w-7 h-7 rounded-full flex items-center justify-center shrink-0",style:{background:`${t.accent}15`,color:t.accent},children:e.jsx(n,{size:13})})]}),e.jsx("p",{className:"text-2xl font-bold",style:{color:k,fontFamily:"'Playfair Display', Georgia, serif"}
1301,children:s?"â":t.value.toLocaleString()}),e.jsx("p",{className:"text-[10px] mt-1 leading-snug",style:{color:"#999"},children:t.hint})]})},Jce=({summary:t,metrics:s,loading:n})=>e.jsxs("div",{className:"mb-6",children:[e.jsxs("div",{className:"rounded-xl p-3.5 mb-4 flex items-start gap-3",style:{background:`${k}06`,border:`1px solid ${k}18`},children:[e.jsx("div",{className:"w-8 h-8 rounded-full flex items-center justify-center shrink-0",style:{background:`linear-gradient(135deg, ${$}, ${G0})`,color:k},children:e.jsx(Jx,{size:15})}),e.jsxs("div",{className:"text-[11.5px] leading-relaxed",style:{color:"#555"},children:[e.jsx("strong",{style:{color:k},children:"Two layers, one truth."})," ",e.jsx("strong",{children:"Source Inventory"})," is the permanent historical system of record â every original row from all 10 tables, never edited or deleted here. ",e.jsx("strong",{children:"CRM Pipeline"})," is the active admissions working layer where a person gets an owner, a stage, a next action and an activity history. A prospect appears in the inventory the moment they submit a form, and appears in the CRM once admissions activates them â so âpeople in inventoryâ is always ⥠âpeople in CRMâ."]})]}),e.jsx("p",{className:"text-[9px] uppercase tracking-[0.3em] font-bold mb-2",style:{color:G0},children:"Admissions KPIs · people, admissions sources only"}),e.jsx("div",{className:"grid grid-cols-2 md:grid-cols-3 xl:grid-cols-5 gap-3",children:Kce(s).map(a=>e.jsx(N4,{card:a,loading:n},a.key))}),e.jsx("p",{className:"text-[9px] uppercase tracking-[0.3em] font-bold mt-5 mb-2",style:{color:G0},children:"Context · other audiences & raw record volume (never counted as admissions)"}),e.jsx("div",{className:"grid grid-cols-2 md:grid-cols-3 xl:grid-cols-5 gap-3",children:Qce(s,t).map(a=>e.jsx(N4,{card:a,loading:n},a.key))})]}),Xce=()=>e.jsxs("div",{className:"rounded-xl p-4 mb-6 flex items-start gap-3",style:{background:`${$}12`,border:`1px solid ${$}55`},children:[e.jsx("div",{className:"w-8 h-8 rounded-full flex items-center justify-center shrink-0",style:{background:`linear-gradient(135deg, ${$}, ${G0})`,color:k},children:e.jsx($i,{size:15})}),e.jsxs("div",{className:"text-[12px] leading-relaxed",style:{color:k},children:[e.jsx("strong",{children:"Read-only inventory."})," This dashboard performs SELECT queries only. Nothing here merges, deduplicates, edits, archives, deletes, emails or texts any record â every source row stays exactly as it is in its own table. Email and phone values are normalized ",e.jsx("em",{children:"for display and grouping only"})," and are never written back."]})]}),Op="#B8962E",Mp="text-[10px] uppercase tracking-[0.28em] font-bold mb-1.5 flex items-center gap-1.5",zg="w-full px-3 py-2 rounded-lg text-xs font-semibold focus:outline-none focus:ring-2 bg-white",ede=({filters:t,onChange:s,onReset:n,programs:a,statuses:r,sourceCounts:i,categoryCounts:o,staleCount:l})=>{const c={border:`1px solid ${k}22`,color:k};return e.jsxs("div",{className:"rounded-xl p-4 lg:p-5 mb-5 space-y-4",style:{background:"#fff",border:`1px solid ${k}15`,boxShadow:`0 2px 12px ${k}08`},children:[e.jsxs("div",{children:[e.jsxs("p",{className:Mp,style:{color:Op},children:[e.jsx(Jx,{size:11})," Category"]}),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsx("button",{onClick:()=>s({category:"all"}),className:"inline-flex items-center gap-1.5 px-3 py-1.5 rounded-full text-xs font-semibold transition-all",style:{background:t.category==="all"?k:"#fff",color:t.category==="all"?$:k,border:`1px solid ${t.category==="all"?k:k+"22"}`},children:"All Categories"}),hk.map(u=>{const p=t.category===u;return e.jsxs("button",{onClick:()=>s({category:p?"all":u}),className:"inline-flex items-center gap-1.5 px-3 py-1.5 rounded-full text-xs font-semibold transition-all",style:{background:p?k:`${k}08`,color:p?$:k,border:`1px solid ${p?k:k+"22"}`},children:[k$[u],e.jsx("span",{className:"px-1.5 py-0.5 rounded text-[10px] font-bold",style:{background:p?`${$}33`:"#fff",color:p?$:k},children:o[u]??0})]},u)})]})]}),e.jsxs("div",{className:"grid sm:grid-cols-2 lg:grid-cols-4 gap-3",children:[e.jsxs("div",{children:[e.jsxs("p",{className:Mp,style:{color:Op},children:[e.jsx(ei,{size:11})," Date Range"]}),e.jsx("select",{value:t.dateRange,onChange:u=>s({dateRange:u.target.value}),className:zg,style:c,children:$ce.map(u=>e.jsx("option",{value:u.value,children:u.label},u.value))})]}),e.jsxs("div",{children:[e.jsxs("p",{className:Mp,style:{color:Op},children:[e.jsx(zt,{size:11})," Source"]}),e.jsxs("select",{value:t.sourceKey,onChange:u=>s({sourceKey:u.target.value}),className:zg,style:c,children:[e.jsx("option",{value:"all",children:"All sources"}),mm.map(u=>e.jsxs("option",{value:u.key,children:[u.label," (",i[u.key]??0,")"]},u.key))]})]}),e.jsxs("div",{children:[e.jsxs("p",{className:Mp,style:{color:Op},children:[e.jsx(_t,{size:11})," Program / Interest"]}),e.jsxs("select",{value:t.program,onChange:u=>s({program:u.target.value}),className:zg,style:c,children:[e.jsx("option",{value:"all",children:"All programs"}),a.map(u=>e.jsxs("option",{value:u.label,children:[u.label," (",u.count,")"]},u.label))]})]}),e.jsxs("div",{children:[e.jsxs("p",{className:Mp,style:{color:Op},children:[e.jsx(ei,{size:11})," Status"]}),e.jsxs("select",{value:t.status,onChange:u=>s({status:u.target.value}),className:zg,style:c,children:[e.jsx("option",{value:"all",children:"All statuses"}),r.map(u=>e.jsxs("option",{value:u.label,children:[u.label," (",u.count,")"]},u.label))]})]})]}),e.jsxs("div",{className:"flex flex-col lg:flex-row gap-3",children:[e.jsxs("div",{className:"relative flex-1",children:[e.jsx(Bt,{size:14,className:"absolute left-3 top-1/2 -translate-y-1/2",style:{color:"#999"}}),e.jsx("input",{value:t.search,onChange:u=>s({search:u.target.value}),placeholder:"Search name, email, phone, organization, program, source, record refâ¦",className:"w-full pl-9 pr-3 py-2.5 rounded-lg text-sm focus:outline-none focus:ring-2",style:{border:`1px solid ${k}22`,color:k}})]}),e.jsxs("button",{onClick:()=>s({onlyStale:!t.onlyStale}),className:"inline-flex items-center justify-center gap-1.5 px-4 py-2.5 rounded-lg text-xs font-bold uppercase tracking-[0.12em] transition-all",style:{background:t.onlyStale?"#991B1B":"#FEE2E2",color:t.onlyStale?"#fff":"#991B1B",border:`1px solid ${t.onlyStale?"#991B1B":"#991B1B33"}`},title:"Show only records still in an initial/new status for more than 7 days",children:[e.jsx(ve,{size:12})," Needs Attention (",l,")"]}),e.jsxs("button",{onClick:n,className:"inline-flex items-center justify-center gap-1.5 px-4 py-2.5 rounded-lg text-xs font-semibold transition-all hover:bg-amber-50",style:{border:`1px solid ${$}88`,color:k,background:"#fff"},children:[e.jsx(Ke,{size:12})," Clear Filters"]})]})]})},ib="#B8962E",tde={"new-needs-review":{bg:"#DBEAFE",fg:"#1E40AF"},tour:{bg:"#FEF3C7",fg:"#92400E"}
1301,application:{bg:"#FFE4D5",fg:"#7C2D12"},"financial-aid":{bg:"#EDE9FE",fg:"#5B21B6"},enrollment:{bg:"#D1FAE5",fg:"#065F46"},"employer-partner":{bg:"#CCFBF1",fg:"#0E7490"},"possible-duplicate":{bg:"#FDE68A",fg:"#92400E"}},P$=t=>t?new Date(t).toLocaleDateString(void 0,{month:"short",day:"numeric",year:"numeric"}):"â",D$=t=>t?new Date(t).toLocaleString([],{month:"short",day:"numeric",year:"numeric",hour:"numeric",minute:"2-digit"}):"â",R$=({cat:t})=>{const s=tde[t];return e.jsx("span",{className:"inline-flex items-center px-2 py-0.5 rounded-full text-[9px] font-bold uppercase tracking-wider",style:{background:s.bg,color:s.fg},children:k$[t]})},sde=({rec:t,showRaw:s})=>{const n=tc(t),a=xk(t.createdAt);return e.jsxs("div",{className:"rounded-lg p-3 grid gap-2 lg:grid-cols-12 items-start",style:{background:n?"#FEF2F2":"#FAFAFA",border:`1px solid ${n?"#FCA5A5":k+"12"}`},children:[e.jsxs("div",{className:"lg:col-span-3 min-w-0",children:[e.jsx("p",{className:"text-[10px] uppercase tracking-wider font-bold",style:{color:ib},children:t.sourceLabel}),e.jsx("p",{className:"text-[10px] font-mono mt-0.5",style:{color:"#999"},children:t.ref}),e.jsxs("p",{className:"text-[10px] mt-0.5",style:{color:"#888"},children:[e.jsx(Ii,{size:9,className:"inline mr-1 -mt-0.5"}),P$(t.createdAt),a!==null&&e.jsxs("span",{style:{color:"#aaa"},children:[" · ",a,"d old"]})]})]}),e.jsxs("div",{className:"lg:col-span-3 min-w-0",children:[e.jsx("p",{className:"text-xs font-semibold truncate",style:{color:k},children:t.name||e.jsx("em",{style:{color:"#aaa"},children:"no name"})}),e.jsxs("p",{className:"text-[11px] truncate",style:{color:"#666"},children:[e.jsx(Ye,{size:9,className:"inline mr-1 -mt-0.5"}),s?t.email||"â":g1(t.email)]}),t.phone&&e.jsxs("p",{className:"text-[11px]",style:{color:"#666"},children:[e.jsx(Qt,{size:9,className:"inline mr-1 -mt-0.5"}),s?t.phone:y1(t.phone)]}),t.organization&&e.jsxs("p",{className:"text-[11px] truncate",style:{color:"#666"},children:[e.jsx(Ws,{size:9,className:"inline mr-1 -mt-0.5"})," ",t.organization]})]}),e.jsxs("div",{className:"lg:col-span-2 min-w-0",children:[e.jsx("p",{className:"text-[11px]",style:{color:"#444"},children:t.program||e.jsx("span",{style:{color:"#bbb"},children:"No program noted"})}),t.campus&&e.jsx("p",{className:"text-[10px]",style:{color:"#999"},children:t.campus})]}),e.jsxs("div",{className:"lg:col-span-2 min-w-0",children:[e.jsx("span",{className:"inline-block px-2 py-0.5 rounded-full text-[10px] font-bold uppercase tracking-wider",style:{background:t.isInitialStatus?"#DBEAFE":`${k}0F`,color:t.isInitialStatus?"#1E40AF":k},children:t.status||"no status"}),n&&e.jsxs("p",{className:"text-[10px] mt-1 font-semibold flex items-center gap-1",style:{color:"#991B1B"},children:[e.jsx(ve,{size:9})," Untouched ",a,"d"]}),e.jsxs("p",{className:"text-[10px] mt-1",style:{color:"#999"},children:[e.jsx(Ma,{size:9,className:"inline mr-1 -mt-0.5"}),t.lastActivityLabel||"â"," · ",D$(t.lastActivityAt)]})]}),e.jsxs("div",{className:"lg:col-span-2 min-w-0",children:[(t.leadSource||t.utm||t.formType)&&e.jsxs("p",{className:"text-[10px] leading-relaxed",style:{color:"#777"},children:[e.jsx(sf,{size:9,className:"inline mr-1 -mt-0.5"}),[t.formType,t.leadSource].filter(Boolean).join(" · ")||"â",t.utm&&e.jsxs(e.Fragment,{children:[e.jsx("br",{}),e.jsxs("span",{style:{color:ib},children:["UTM/tags: ",t.utm]})]})]}),e.jsx("div",{className:"flex flex-wrap gap-1 mt-1.5",children:fk(t,!1).map(r=>e.jsx(R$,{cat:r},r))})]})]})},nde=({group:t,showRaw:s})=>{const[n,a]=d.useState(t.isDuplicate);return e.jsxs("div",{className:"rounded-xl overflow-hidden",style:{background:"#fff",border:`1px solid ${t.isDuplicate?$+"88":k+"15"}`,boxShadow:`0 2px 10px ${k}08`},children:[e.jsxs("button",{onClick:()=>a(r=>!r),className:"w-full text-left px-4 py-3 flex items-start gap-3 transition-colors hover:bg-amber-50/40",children:[e.jsx("div",{className:"w-9 h-9 rounded-full flex items-center justify-center shrink-0 text-xs font-bold",style:{background:`linear-gradient(135deg, ${k}, #2A0810)`,color:$},children:t.initials}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[e.jsx("p",{className:"text-sm font-bold truncate",style:{color:k},children:s?t.displayName:`${t.initials} · ${t.records.length===1?t.records[0].ref:"grouped"}`}
1301),t.isDuplicate&&e.jsxs("span",{className:"inline-flex items-center gap-1 px-2 py-0.5 rounded-full text-[9px] font-bold uppercase tracking-wider",style:{background:"#FDE68A",color:"#92400E"},children:[e.jsx(Z_,{size:9})," ",t.records.length," source records"]}),t.staleCount>0&&e.jsxs("span",{className:"inline-flex items-center gap-1 px-2 py-0.5 rounded-full text-[9px] font-bold uppercase tracking-wider",style:{background:"#FEE2E2",color:"#991B1B"},children:[e.jsx(ve,{size:9})," ",t.staleCount," untouched > ",E$,"d"]})]}),e.jsxs("p",{className:"text-[11px] mt-0.5 truncate",style:{color:"#666"},children:[t.emails.length>0?s?t.emails.join(", "):t.emails.map(g1).join(", "):"no email on record",t.phones.length>0&&e.jsxs(e.Fragment,{children:[" · ",s?t.phones.join(", "):t.phones.map(y1).join(", ")]})]}),e.jsx("div",{className:"flex flex-wrap gap-1 mt-1.5",children:t.categories.map(r=>e.jsx(R$,{cat:r},r))}),e.jsxs("p",{className:"text-[10px] mt-1.5",style:{color:"#999"},children:["First seen ",P$(t.firstSeen)," · Last activity ",D$(t.lastActivityAt)," · Matched on ",t.matchedOn," · ",t.sourceKeys.length," source table",t.sourceKeys.length===1?"":"s"]})]}),e.jsx("div",{className:"shrink-0 mt-1",style:{color:ib},children:n?e.jsx(Gt,{size:16}):e.jsx(Nr,{size:16})})]}),n&&e.jsxs("div",{className:"px-4 pb-4 space-y-2",style:{borderTop:`1px solid ${k}0F`},children:[e.jsxs("p",{className:"text-[10px] uppercase tracking-[0.25em] font-bold pt-3",style:{color:ib},children:["Source records (",t.records.length,") â all preserved, nothing merged"]}),t.records.map(r=>e.jsx(sde,{rec:r,showRaw:s},r.key))]})]})},Wa=[{value:"new",label:"New",bg:"#DBEAFE",fg:"#1E40AF"},{value:"contacted",label:"Contacted",bg:"#E0F2FE",fg:"#075985"},{value:"qualified",label:"Qualified",bg:"#CCFBF1",fg:"#0E7490"},{value:"tour_scheduled",label:"Tour Scheduled",bg:"#FEF3C7",fg:"#92400E"},{value:"tour_completed",label:"Tour Completed",bg:"#FDE68A",fg:"#78350F"},{value:"application",label:"Application Started/Received",bg:"#FFE4D5",fg:"#7C2D12"},{value:"financial_aid",label:"Financial Aid",bg:"#EDE9FE",fg:"#5B21B6"},{value:"accepted",label:"Accepted",bg:"#DCFCE7",fg:"#166534"},{value:"enrolled",label:"Enrolled",bg:"#D1FAE5",fg:"#065F46"},{value:"not_moving_forward",label:"Not Moving Forward",bg:"#F3F4F6",fg:"#4B5563"}],ob=Wa.reduce((t,s)=>(t[s.value]=s.label,t),{}),hm=t=>Wa.find(s=>s.value===t)??Wa[0],ade=["enrolled","not_moving_forward"],rde=[{value:"call",label:"Call"},{value:"text",label:"Text"},{value:"email",label:"Email"},{value:"note",label:"Note"},{value:"tour",label:"Tour"},{value:"application",label:"Application"},{value:"financial_aid",label:"Financial Aid"},{value:"other",label:"Other"}],ide={call:"Call",text:"Text",email:"Email",note:"Note",tour:"Tour",application:"Application",financial_aid:"Financial Aid",other:"Other",system:"System"},I$=[{value:"spoke_with_prospect",label:"Spoke with Prospect"},{value:"voicemail_left",label:"Voicemail Left"},{value:"no_answer",label:"No Answer"},{value:"wrong_or_invalid_number",label:"Wrong / Invalid Number"},{value:"call_disconnected",label:"Call Disconnected"},{value:"unable_to_leave_voicemail",label:"Unable to Leave Voicemail"},{value:"information_requested",label:"Information Requested"},{value:"follow_up_required",label:"Follow-Up Required"}],ode=I$.reduce((t,s)=>(t[s.value]=s.label,t),{}),b1={people:[],peopleById:new Map,identityIndex:new Map,linkIndex:new Map,activitiesByPerson:new Map,attributionByPerson:new Map,attributionByEmail:new Map,attributionByPhone:new Map,attributionBySourceRecord:new Map,attributionCount:0,error:null},Bp=(t,s,n)=>{const a=t.get(s)||[];a.push(n),t.set(s,a)};async function df(){var g,N,b,f,j;const[t,s,n,a,r]=await Promise.all([O.from("crm_people").select("*").order("updated_at",{ascending:!1}).limit(4e3),O.from("crm_person_identities").select("*").limit(12e3),O.from("crm_person_source_links").select("*").limit(12e3),O.from("crm_activities").select("*").order("occurred_at",{ascending:!1}).limit(6e3),O.from("crm_attribution_events").select("*").order("captured_at",{ascending:!0}).limit(12e3)]),i=((g=t.error)==null?void 0:g.message)||((N=s.error)==null?void 0:N.message)||((b=n.error)==null?void 0:b.message)||((f=a.error)==null?void 0:f.message)||((j=r.error)==null?void 0:j.message)||null,o=t.data||[],l=new Map;o.forEach(S=>l.set(S.id,S));const c=new Map;
1301(s.data||[]).forEach(S=>{c.set(`${S.identity_type}:${S.identity_value}`,S.person_id)});const u=new Map;(n.data||[]).forEach(S=>{u.set(`${S.source_table}:${S.source_record_id}`,S.person_id)});const p=new Map;(a.data||[]).forEach(S=>Bp(p,S.person_id,S));const m=new Map,x=new Map,h=new Map,y=new Map,v=r.data||[];return v.forEach(S=>{S.person_id&&Bp(m,S.person_id,S),S.identity_email&&Bp(x,S.identity_email,S),S.identity_phone&&Bp(h,S.identity_phone,S),S.source_table&&S.source_record_id&&Bp(y,`${S.source_table}:${S.source_record_id}`,S)}),{people:o,peopleById:l,identityIndex:c,linkIndex:u,activitiesByPerson:p,attributionByPerson:m,attributionByEmail:x,attributionByPhone:h,attributionBySourceRecord:y,attributionCount:v.length,error:i}}function v1(t,s){return t.map(n=>{let a;for(const c of n.records){const u=s.linkIndex.get(`${c.table}:${c.recordId}`);if(u){a=u;break}}if(!a)for(const c of n.emails){const u=s.identityIndex.get(`email:${c}`);if(u){a=u;break}}if(!a)for(const c of n.phones){const u=s.identityIndex.get(`phone:${c}`);if(u){a=u;break}}const r=a?s.peopleById.get(a)??null:null,i=new Set,o=[],l=c=>{(c||[]).forEach(u=>{i.has(u.id)||(i.add(u.id),o.push(u))})};return r&&l(s.attributionByPerson.get(r.id)),n.emails.forEach(c=>l(s.attributionByEmail.get(c))),n.phones.forEach(c=>l(s.attributionByPhone.get(c))),n.records.forEach(c=>l(s.attributionBySourceRecord.get(`${c.table}:${c.recordId}`))),o.sort((c,u)=>new Date(c.captured_at).getTime()-new Date(u.captured_at).getTime()),{groupId:n.id,group:n,person:r,activities:r?s.activitiesByPerson.get(r.id)||[]:[],attribution:o}})}const lde=t=>t.find(s=>s.has_attribution&&s.touch_kind==="first_touch")||t.find(s=>s.has_attribution)||null,cde=t=>{const s=t.filter(n=>n.has_attribution);return s.length?s[s.length-1]:null},dde=t=>t?t.utm_source?[t.utm_source,t.utm_medium,t.utm_campaign].filter(Boolean).join(" / "):t.gclid?"google-ads (gclid)":t.fbclid?"meta (fbclid)":t.msclkid?"microsoft-ads (msclkid)":t.campaign_tag?`tag: ${t.campaign_tag}`:t.referrer_domain?`referral: ${t.referrer_domain}`:null:null,bk=t=>!!t&&ade.includes(t.stage);function lp(t){return!t||!t.follow_up_at||bk(t)?!1:new Date(t.follow_up_at).getTime()<Date.now()}function vk(t){if(!t||!t.follow_up_at||bk(t))return!1;const s=new Date(t.follow_up_at),n=new Date;return s.getFullYear()===n.getFullYear()&&s.getMonth()===n.getMonth()&&s.getDate()===n.getDate()}function ude(t){return!lp(t)||!(t!=null&&t.follow_up_at)?0:Math.floor((Date.now()-new Date(t.follow_up_at).getTime())/864e5)}const Lx=[{value:"all",label:"All Prospects",hint:"Every admissions person in the current scope"},{value:"my",label:"My Leads",hint:"People assigned to you as owner"},{value:"unassigned",label:"Unassigned",hint:"No admissions owner yet"},{value:"new",label:"New",hint:"CRM stage is still New (or not yet activated)"},{value:"needs-first-contact",label:"Needs First Contact",hint:"In the CRM with no logged call, text, email or note yet"},{value:"due-today",label:"Follow Up Today",hint:"Follow-up date lands on today"},{value:"overdue",label:"Overdue",hint:"Follow-up date has passed and the person is still workable"},{value:"tours",label:"Tours",hint:"Tour scheduled or completed"},{value:"applications",label:"Applications",hint:"Application on file"},{value:"financial-aid",label:"Financial Aid",hint:"Financial-aid stage or documented aid activity"},{value:"enrollment-ready",label:"Enrollment Ready",hint:"Accepted or through financial aid â ready to enroll"},{value:"enrolled",label:"Enrolled",hint:"Enrollment recorded"},{value:"historical",label:"Historical",hint:"No source activity inside the active window â do not treat as a hot lead"},{value:"not-in-crm",label:"Not Yet in CRM",hint:"Grouped prospect with no CRM person yet"}];Lx.reduce((t,s)=>(t[s.value]=s.label,t),{});const mde=["tour_scheduled","tour_completed"],pde=["application","financial_aid","accepted"],hde=["financial_aid","accepted"],$$=t=>t.activities.some(s=>!s.is_system&&s.activity_type!=="system");function z$(t,s,n,a){var i;const r=t.person;switch(s){case"all":return!0;case"my":return!!r&&!!n&&r.owner_user_id===n;case"unassigned":return!r||!r.owner_user_id;case"new":return!r||r.stage==="new";case"needs-first-contact":return!bk(r)&&!$$(t);case"due-today":return vk(r);case"overdue":return lp(r);case"tours":return!!r&&mde.includes(r.stage)||t.group.records.some(o=>o.isTour);case"applications":return!!r&&pde.includes(r.stage)||t.group.records.some(o=>o.isApplication);case"financial-aid":return!!r&&r.stage==="financial_aid"||t.group.records.some(o=>o.isFinancialAid);case"enrollment-ready":return!!r&&hde.includes(r.stage);case"enrolled":return!!r&&r.stage==="enrolled"||t.group.records.some(o=>o.isEnrollment);case"historical":return!!((i=a==null?void 0:a.historicalIds)!=null&&i.has(t.groupId));case"not-in-crm":return!r;default:return!0}}function xde(t,s,n){const a=Wa.reduce((i,o)=>(i[o.value]=0,i),{}),r=Lx.reduce((i,o)=>(i[o.value]=0,i),{});for(const i of t){i.person&&(a[i.person.stage]=(a[i.person.stage]||0)+1);for(const o of Lx)z$(i,o.value,s,n)&&(r[o.value]+=1)}return{total:t.length,inCrm:t.filter(i=>!!i.person).length,notInCrm:t.filter(i=>!i.person).length,mine:r.my,unassigned:r.unassigned,dueToday:r["due-today"],overdue:r.overdue,highPriority:t.filter(i=>{var o;return((o=i.person)==null?void 0:o.priority)==="high"}).length,byStage:a,viewCounts:r}}const fde="Historical initialization";async function Mh(t,s,n,a){var r,i;try{let o=n||null,l=!1;if(!o){const h=[...t.emails.map(y=>({t:"email",v:y}
1301)),...t.phones.map(y=>({t:"phone",v:y}))];if(h.length){const{data:y}=await O.from("crm_person_identities").select("person_id, identity_type, identity_value").in("identity_value",h.map(g=>g.v)),v=y==null?void 0:y.find(g=>h.some(N=>N.t===g.identity_type&&N.v===g.identity_value));v&&(o=v.person_id)}}if(!o){const{data:h}=await O.from("crm_person_source_links").select("person_id, source_table, source_record_id").in("source_record_id",t.records.map(v=>v.recordId).filter(Boolean)),y=h==null?void 0:h.find(v=>t.records.some(g=>g.table===v.source_table&&g.recordId===v.source_record_id));y&&(o=y.person_id)}if(!o){const h=t.emails[0]||S$((r=t.records.find(N=>N.email))==null?void 0:r.email)||null,y=t.phones[0]||C$((i=t.records.find(N=>N.phone))==null?void 0:i.phone)||null,{data:v,error:g}=await O.from("crm_people").insert({display_name:t.displayName==="(no name on record)"?null:t.displayName,primary_email:h,primary_phone:y,stage:(a==null?void 0:a.initialStage)||"new",priority:"normal",created_by_user_id:s.id,created_by_name:s.name}).select("*").single();if(g||!v)return{ok:!1,error:(g==null?void 0:g.message)||"Could not create CRM person."};o=v.id,l=!0,a!=null&&a.initializationNote&&await j1(o,s,"system",`${fde}: ${a.initializationNote}`,{system:!0})}const c=[...t.emails.map(h=>({person_id:o,identity_type:"email",identity_value:h})),...t.phones.map(h=>({person_id:o,identity_type:"phone",identity_value:h}))];c.length&&await O.from("crm_person_identities").upsert(c,{onConflict:"identity_type,identity_value",ignoreDuplicates:!0});const u=t.records.filter(h=>h.recordId).map(h=>({person_id:o,source_key:h.sourceKey,source_table:h.table,source_record_id:String(h.recordId)}));u.length&&await O.from("crm_person_source_links").upsert(u,{onConflict:"source_table,source_record_id",ignoreDuplicates:!0}),[...t.emails,...t.phones].length&&(t.emails.length&&await O.from("crm_attribution_events").update({person_id:o}).is("person_id",null).in("identity_email",t.emails),t.phones.length&&await O.from("crm_attribution_events").update({person_id:o}).is("person_id",null).in("identity_phone",t.phones));const{data:m,error:x}=await O.from("crm_people").select("*").eq("id",o).single();return x||!m?{ok:!1,error:(x==null?void 0:x.message)||"Person not readable."}:{ok:!0,data:m,created:l}}catch(o){return{ok:!1,error:(o==null?void 0:o.message)||"Unexpected error."}}}async function j1(t,s,n,a,r){const i=(r==null?void 0:r.occurredAt)||new Date().toISOString(),{error:o}=await O.from("crm_activities").insert({person_id:t,activity_type:n,notes:a.trim()||null,call_outcome:n==="call"&&(r==null?void 0:r.callOutcome)||null,occurred_at:i,staff_user_id:s.id,staff_name:s.name,staff_email:s.email,is_system:!!(r!=null&&r.system)});return o?{ok:!1,error:o.message}:(r!=null&&r.system||await O.from("crm_people").update({last_activity_at:i,last_activity_type:n,updated_at:new Date().toISOString()}).eq("id",t),{ok:!0})}async function gde(t){var s;try{const{data:n,error:a}=await O.functions.invoke("crm-send-email",{body:{person_id:t.personId,subject:t.subject,message:t.message,request_id:t.requestId}}),r=n||null;if(r&&typeof r=="object"&&"success"in r)return r.success?{ok:!0,duplicate:!!r.duplicate,alreadySent:!!r.already_sent,messageId:r.message_id??null,recipient:r.recipient??null,activityLogged:r.activity_logged!==!1}:{ok:!1,error:r.error||"The email was not sent.",duplicate:!!r.duplicate};if(a){const i=(s=a==null?void 0:a.context)==null?void 0:s.body;return i&&typeof i=="object"&&i.error?{ok:!1,error:String(i.error),duplicate:!!i.duplicate}:{ok:!1,error:a.message||"The email was not sent."}}return{ok:!1,error:"The email was not sent â no result was returned."}}catch(n){return{ok:!1,error:(n==null?void 0:n.message)||"The email was not sent."}}}async function L$(t,s,n){const a={...s,updated_at:new Date().toISOString()},r=[];s.stage&&s.stage!==t.stage&&(a.stage_updated_at=new Date().toISOString(),r.push(`Stage: ${ob[t.stage]} â ${ob[s.stage]}`)),s.owner_user_id!==void 0&&s.owner_user_id!==t.owner_user_id&&(a.owner_assigned_at=new Date().toISOString(),r.push(`Owner: ${t.owner_name||"Unassigned"} â ${s.owner_name||"Unassigned"}`)),s.follow_up_at!==void 0&&s.follow_up_at!==t.follow_up_at&&r.push(s.follow_up_at?`Follow-up set for ${new Date(s.follow_up_at).toLocaleStr
1301ing()}`:"Follow-up cleared"),s.next_action!==void 0&&(s.next_action||"")!==(t.next_action||"")&&r.push(s.next_action?`Next action: ${s.next_action}`:"Next action cleared"),s.priority&&s.priority!==t.priority&&r.push(`Priority: ${t.priority} â ${s.priority}`);const{data:i,error:o}=await O.from("crm_people").update(a).eq("id",t.id).select("*").single();return o||!i?{ok:!1,error:(o==null?void 0:o.message)||"Update failed."}:(r.length&&await j1(t.id,n,"system",r.join(" · "),{system:!0}),{ok:!0,data:i})}async function O$(){const{data:t,error:s}=await O.from("user_profiles").select("id, full_name, email, role").in("role",["super-admin","admin"]).order("full_name");return s||!t?[]:t.map(n=>({id:n.id,name:n.full_name||n.email,email:n.email,role:n.role}))}const Ln=t=>t?new Date(t).toLocaleString([],{month:"short",day:"numeric",year:"numeric",hour:"numeric",minute:"2-digit"}):"â",Xn=t=>t?new Date(t).toLocaleDateString(void 0,{month:"short",day:"numeric",year:"numeric"}):"â",lb=t=>{if(!t)return"";const s=new Date(t);if(Number.isNaN(s.getTime()))return"";const n=a=>String(a).padStart(2,"0");return`${s.getFullYear()}-${n(s.getMonth()+1)}-${n(s.getDate())}T${n(s.getHours())}:${n(s.getMinutes())}`},yde=["super-admin","admin","staff"],bde=(t,s)=>(s==null?void 0:s.isSuperAdmin)===!0||!!t&&yde.includes(t),M$=(t,s)=>t?s?t:g1(t):"",CN=(t,s)=>t?s?t:y1(t):"",B$=t=>{if(!t)return null;const s=t.replace(/\D/g,"");return s.length>=10?`+1${s.slice(-10)}`:null},Id={none:"No tour",requested:"Tour Requested / Booking Not Verified",scheduled:"Tour Scheduled",booked_unverified:"Tour Booked / Time Not Verified",completed:"Tour Completed",cancelled:"Tour Cancelled",no_show:"Tour No-Show"},jk={none:{bg:"#F3F4F6",fg:"#6B7280"},requested:{bg:"#FEF3C7",fg:"#92400E"},scheduled:{bg:"#DCFCE7",fg:"#166534"},booked_unverified:{bg:"#FEF3C7",fg:"#92400E"},completed:{bg:"#D1FAE5",fg:"#065F46"},cancelled:{bg:"#FEE2E2",fg:"#991B1B"},no_show:{bg:"#FEE2E2",fg:"#991B1B"}},_4={none:0,cancelled:1,no_show:2,requested:3,booked_unverified:4,scheduled:5,completed:6};function vde(t){var n;let s={status:"none",confirmedAt:null,requestedFor:null,calendar:null,basis:"No tour record on any source"};for(const a of t){if(!a.isTour&&!((n=a.detail)!=null&&n.tourOutcome))continue;const r=a.detail||{},i=r.tourConfirmedAt||null,o=r.tourOutcome||(a.isTour?"requested":null);if(!o)continue;let l,c;o==="completed"?(l="completed",c=`${a.sourceLabel} marks the tour completed`):o==="cancelled"?(l="cancelled",c=`${a.sourceLabel} marks the tour cancelled`):o==="no_show"?(l="no_show",c=`${a.sourceLabel} marks the tour a no-show`):o==="scheduled"?i?(l="scheduled",c=`Confirmed booking time on ${r.tourBookingSource||a.sourceLabel}`):(l="booked_unverified",c=`Booking row on ${r.tourBookingSource||a.sourceLabel} carries no confirmed time`):(l="requested",c=`Request only on ${r.tourBookingSource||a.sourceLabel} â no confirmed booking`),_4[l]>=_4[s.status]?s={status:l,confirmedAt:i,requestedFor:r.tourRequestedFor||s.requestedFor,calendar:r.tourBookingSource||a.sourceLabel,basis:c}:!s.requestedFor&&r.tourRequestedFor&&(s={...s,requestedFor:r.tourRequestedFor})}return s}function jde(t){var r;const s=t.filter(i=>i.isApplication);if(!s.length)return{status:"none",label:"No application",submittedAt:null,sourceStatus:null,record:null};const n=s.find(i=>{var o;return(o=i.detail)==null?void 0:o.applicationTable})||s[0],a=((r=n.detail)==null?void 0:r.applicationSubmittedAt)||n.createdAt;return{status:a?"submitted":"started",label:a?"Application submitted":"Application started",submittedAt:a,sourceStatus:n.status,record:n}}function wde(t,s){const n=t.filter(a=>{var r;return a.isFinancialAid||((r=a.detail)==null?void 0:r.financialAidInterest)});return s==="financial_aid"?{interested:!0,label:"In financial aid",detail:n.length?`CRM stage + ${n.length} aid record${n.length===1?"":"s"}`:"CRM stage set by admissions"}:n.length?{interested:!0,label:"Aid interest on file",detail:n.map(a=>a.sourceLabel).join(", ")}:{interested:!1,label:"Not indicated",detail:null}}function Nde(t){let s=null,n=null,a=null;for(const r of t){const i=r.detail;i&&(!s&&i.startTimeframe&&(s=i.startTimeframe,a=r.sourceLabel),!n&&i.startDate&&(n=i.startDate,a=r.sourceLabel))}return{timeframe:s,date:n,basis:a}}function _de(t,s,n,a,r){const i=new Set;for(const o of t.group.records){o.program&&i.add(o.program.trim());const l=(o.leadSource||"").toLowerCase();(l.includes("meta")||l.includes("facebook")||(o.utm||"").toLowerCase().includes("meta"))&&i.add("Meta Lead"),(l.includes("google")||(o.utm||"").toLowerCase().includes("google"))&&i.add("Google Lead"),(l.includes("career")||l.includes("fair"))&&i.add("Career Fair Lead")}return(n.status==="requested"||n.status==="booked_unverified")&&i.add("Tour Requested"),n.status==="scheduled"&&i.add("Tour Scheduled"),n.status==="completed"&&i.add("Tour Completed"),r.interested&&i.add("Financial Aid Interested"),a.status!=="none"&&i.add("Application On File"),(s==null?void 0:s.readiness.level)==="high"&&i.add("High Intent"),lp(t.person)&&i.add("Needs Follow-Up"),!$$(t)&&t.person&&i.add("Never Contacted"),(s==null?void 0:s.lifecycle)==="historical"&&i.add("Historical"),Array.from(i)}function kde(t){if(!t.person)return{label:"Not in CRM",tone:"none"};const s=t.activities.filter(a=>!a.is_system&&a.activity_type!=="system");return s.length?{label:`${s[0].activity_type} logged`,tone:"ok"}:{label:"No contact logged",tone:"warn"}}const Up=(t,s)=>{for(const n of t){const a=s(n);if(a&&a.trim())return a.trim()}return null};function Sde(t,s){var c,u,p,m,x,h,y,v;const n=t.group.records,a=((c=t.person)==null?void 0:c.stage)??null,r=vde(n),i=jde(n),o=wde(n,a),l=Nde(n);return{id:t.groupId,row:t,profile:s,name:((u=t.person)==null?void 0:u.display_name)||t.group.displayName,email:((p=t.person)==null?void 0:p.primary_email)||Up(n,g=>g.email),phone:((m=t.person)==null?void 0:m.primary_phone)||Up(n,g=>g.phone),program:Up(n,g=>g.program),campus:Up(n,g=>g.campus),leadSource:Up(n,g=>g.leadSource),stage:a,stageLabel:a?ob[a]:"Not in CRM",readinessLabel:s?Yr[s.readiness.level].label:"â",readinessScore:s?s.readiness.score:null,tour:r,application:i,aid:o,start:l,owner:((x=t.person)==null?void 0:x.owner_name)||null,lastContactAt:((h=t.person)==null?void 0:h.last_activity_at)||t.group.lastActivityAt,nextAction:((y=t.person)==null?void 0:y.next_action)||null,followUpAt:((v=t.person)==null?void 0:v.follow_up_at)||null,overdue:lp(t.person),dueToday:vk(t.person),communication:kde(t),labels:_de(t,s,r,i,o),recordStatus:t.person?(s==null?void 0:s.lifecycle)==="historical"?"In CRM · historical":"In CRM · active":"Source only",sourceRefs:n.map(g=>g.ref)}}const k4={search:"",program:"all",campus:"all",source:"all",stage:"all",readiness:"all",owner:"all",tour:"all",application:"all",aid:"all",label:"all",timing:"all"},Uj=(t,s)=>s==="all"||(t||"(not set)")===s;function Cde(t,s){const n=s.search.trim().toLowerCase();return t.filter(a=>{var r;if(!Uj(a.program,s.program)||!Uj(a.campus,s.campus)||!Uj(a.leadSource,s.source)||s.stage!=="all"&&(a.stage||"not-in-crm")!==s.stage||s.readiness!=="all"&&(((r=a.profile)==null?void 0:r.readiness.level)||"none")!==s.readiness||s.owner!=="all"&&(a.owner||"Unassigned")!==s.owner||s.tour!=="all"&&a.tour.status!==s.tour||s.application!=="all"&&a.application.status!==s.application||s.aid!=="all"&&String(a.aid.interested)!==s.aid||s.label!=="all"&&!a.labels.includes(s.label)||s.timing==="due-today"&&!a.dueToday||s.timing==="overdue"&&!a.overdue||s.timing==="unassigned"&&a.owner||s.timing==="untouched"&&a.communication.label!=="No contact logged")return!1;if(n){const i=[a.name,a.email,a.phone,a.program,a.campus,a.leadSource,a.owner,a.stageLabel,a.nextAction,...a.labels,...a.sourceRefs].filter(
1301Boolean).join(" ").toLowerCase(),o=n.replace(/\D/g,"");if(!i.includes(n)&&!(o.length>=4&&(a.phone||"").replace(/\D/g,"").includes(o)))return!1}return!0})}function Ade(t){const s=n=>Array.from(new Set(n.map(a=>a&&a.trim()?a.trim():"(not set)"))).sort();return{programs:s(t.map(n=>n.program)),campuses:s(t.map(n=>n.campus)),sources:s(t.map(n=>n.leadSource)),owners:Array.from(new Set(t.map(n=>n.owner||"Unassigned"))).sort(),labels:Array.from(new Set(t.flatMap(n=>n.labels))).sort()}}function Ede(t){return[...t].sort((s,n)=>{const a=u=>{var p;return u.overdue?0:u.dueToday?1:((p=u.profile)==null?void 0:p.readiness.level)==="high"?2:3},r=a(s)-a(n);if(r!==0)return r;const i=s.followUpAt?new Date(s.followUpAt).getTime():1/0,o=n.followUpAt?new Date(n.followUpAt).getTime():1/0;if(i!==o)return i-o;const l=s.lastContactAt?new Date(s.lastContactAt).getTime():0;return(n.lastContactAt?new Date(n.lastContactAt).getTime():0)-l})}const S4="#B8962E",Fde=["Prospect","Phone","Email","Program","Campus","Source","Stage","Readiness","Start timeframe","Start date","Tour","Tour date / time","Application","Financial aid","Owner","Last contact","Next action","Follow-up due","Communication","Labels","Record"],Es=({children:t,title:s,nowrap:n})=>e.jsx("td",{className:`px-2.5 py-2 align-top text-[11px] ${n?"whitespace-nowrap":""}`,style:{color:"#444",borderBottom:`1px solid ${k}0D`},title:s,children:t}),Bn=()=>e.jsx("span",{style:{color:"#ccc"},children:"â"}),Tde=({rows:t,canRevealPII:s,onOpen:n})=>e.jsxs("div",{className:"rounded-xl overflow-hidden",style:{background:"#fff",border:`1px solid ${k}15`},children:[e.jsx("div",{className:"overflow-x-auto",children:e.jsxs("table",{className:"min-w-full border-collapse",children:[e.jsx("thead",{children:e.jsx("tr",{style:{background:`${k}08`},children:Fde.map(a=>e.jsx("th",{className:"px-2.5 py-2 text-left text-[9px] uppercase tracking-[0.14em] font-bold whitespace-nowrap",style:{color:S4,borderBottom:`1px solid ${k}18`},children:a},a))})}),e.jsx("tbody",{children:t.map(a=>{var l,c;const r=a.stage?hm(a.stage):null,i=jk[a.tour.status],o=B$(a.phone);return e.jsxs("tr",{className:"hover:bg-[#FCFAF5] transition-colors",style:a.overdue?{background:"#FEF6F6"}:void 0,children:[e.jsxs(Es,{nowrap:!0,children:[e.jsx("button",{onClick:()=>n(a),className:"font-bold text-left hover:underline",style:{color:k},children:a.name}),e.jsxs("div",{className:"flex items-center gap-1 mt-0.5",children:[a.overdue&&e.jsxs("span",{className:"inline-flex items-center gap-0.5 text-[9px] font-bold",style:{color:"#991B1B"},children:[e.jsx(ve,{size:9})," Overdue"]}),!a.overdue&&a.dueToday&&e.jsxs("span",{className:"inline-flex items-center gap-0.5 text-[9px] font-bold",style:{color:"#92400E"},children:[e.jsx(_a,{size:9})," Due today"]}),((l=a.profile)==null?void 0:l.readiness.level)==="high"&&e.jsxs("span",{className:"inline-flex items-center gap-0.5 text-[9px] font-bold",style:{color:"#166534"},children:[e.jsx(Kx,{size:9})," High intent"]})]})]}),e.jsx(Es,{nowrap:!0,children:a.phone?s&&o?e.jsxs("a",{href:`tel:${o}`,className:"inline-flex items-center gap-1 hover:underline",style:{color:k},children:[e.jsx(Qt,{size:9})," ",CN(a.phone,!0)]}):e.jsx("span",{children:CN(a.phone,s)}):e.jsx(Bn,{})}),e.jsx(Es,{children:a.email?s?e.jsxs("a",{href:`mailto:${a.email}`,className:"inline-flex items-center gap-1 hover:underline",style:{color:k},children:[e.jsx(Ye,{size:9})," ",a.email]}):e.jsx("span",{children:M$(a.email,!1)}):e.jsx(Bn,{})}),e.jsx(Es,{children:a.program||e.jsx(Bn,{})}),e.jsx(Es,{children:a.campus||e.jsx(Bn,{})}),e.jsx(Es,{children:a.leadSource||e.jsx(Bn,{})}),e.jsx(Es,{nowrap:!0,children:r?e.jsx("span",{className:"px-1.5 py-0.5 rounded text-[9px] font-bold uppercase tracking-wider",style:{background:r.bg,color:r.fg},children:r.label}):e.jsx("span",{className:"px-1.5 py-0.5 rounded text-[9px] font-bold uppercase",style:{background:"#F3F4F6",color:"#4B5563"},children:"Not in CRM"})}),e.jsx(Es,{nowrap:!0,title:(c=a.profile)==null?void 0:c.readiness.signals.map(u=>u.label).join(" · "),children:a.profile?e.jsxs("span",{className:"px-1.5 py-0.5 rounded text-[9px] font-bold uppercase tracking-wider",style:{background:Yr[a.profile.readiness.level].bg,color:Yr[a.profile.readiness.level].fg},children:[a.readinessLabel," ",a.readinessScore]}):e.jsx(Bn,{})}),e.jsx(Es,{children:a.start.timeframe||e.jsx(Bn,{})}),e.jsx(Es,{nowrap:!0,children:a.start.date?Xn(a.start.date):e.jsx(Bn,{})}),e.jsx(Es,{nowrap:!0,title:a.tour.basis,children:a.tour.status==="none"?e.jsx(Bn,{}):e.jsx("span",{className:"px-1.5 py-0.5 rounded text-[9px] font-bold uppercase tracking-wider",style:{background:i.bg,color:i.fg},children:Id[a.tour.status]})}),e.jsx(Es,{nowrap:!0,children:a.tour.confirmedAt?Ln(a.tour.confirmedAt):a.tour.requestedFor?e.jsxs("span",{style:{color:"#92400E"},children:["requested ",Xn(a.tour.requestedFor)]}):e.jsx(Bn,{})}),e.jsx(Es,{children:a.application.status==="none"?e.jsx(Bn,{}):a.application.label}),e.jsx(Es,{title:a.aid.detail||void 0,children:a.aid.interested?a.aid.label:e.jsx(Bn,{})}),e.jsx(Es,{nowrap:!0,children:a.owner||e.jsx("span",{style:{color:"#B45309"},children:"Unassigned"})}),e.jsx(Es,{nowrap:!0,children:a.lastContactAt?Xn(a.lastContactAt):e.jsx(Bn,{})}),e.jsx(Es,{children:a.nextAction||e.jsx(Bn,{})}),e.jsx(Es,{nowrap:!0,children:a.followUpAt?e.jsx("span",{style:{color:a.overdue?"#991B1B":"#444"},children:Ln(a.followUpAt)}):e.jsx(Bn,{})}),e.jsx(Es,{nowrap:!0,children:e.jsx("span",{style:{color:a.communication.tone==="warn"?"#92400E":"#444"},children:a.communication.label})}),e.jsx(Es,{children:e.jsxs("span",{className:"flex flex-wrap gap-1",children:[a.labels.slice(0,4).map(u=>e.jsx("span",{className:"px-1.5 py-0.5 rounded text-[9px] font-semibold",style:{background:`${$}1F`,color:S4},children:u},u)),a.labels.length>4&&e.jsxs("span",{className:"text-[9px]",style:{color:"#999"},children:["+",a.labels.length-4]})]})}),e.jsx(Es,{nowrap:!0,children:a.recordStatus})]},a.id)})})]})}),t.length===0&&e.jsx("p",{className:"text-center text-[12px] py-10",style:{color:"#888"},children:"No prospects match the current filters."})]}),Pde=({rows:t,onOpen:s})=>{const n=t.filter(a=>!a.stage);return e.jsx("div",{className:"overflow-x-auto pb-2",children:e.jsxs("div",{className:"flex gap-3 min-w-max",children:[Wa.map(a=>{const r=t.filter(i=>i.stage===a.value);return e.jsxs("div",{className:"w-[240px] rounded-xl p-2.5",style:{background:"#fff",border:`1px solid ${k}15`},children:[e.jsxs("div",{className:"px-2 py-1 rounded-lg mb-2 flex items-center justify-between",style:{background:a.bg},children:[e.jsx("span",{className:"text-[9px] font-bold uppercase tracking-wider",style:{color:a.fg},children:a.label}),e.jsx("span",{className:"text-[10px] font-bold",style:{color:a.fg},children:r.length})]}),e.jsxs("div",{className:"space-y-1.5 max-h-[520px] overflow-y-auto pr-0.5",children:[r.slice(0,60).map(i=>{var o;return e.jsxs("button",{onClick:()=>s(i),className:"w-full text-left rounded-lg px-2 py-1.5",style:{background:i.overdue?"#FEF6F6":"#FAFAFA",border:`1px solid ${i.overdue?"#FCA5A5":k+"10"}`},children:[e.jsx("p",{className:"text-[11px] font-bold truncate",style:{color:k},children:i.name}),e.jsx("p",{className:"text-[10px] truncate",style:{color:"#777"},children:i.program||"Program not set"}),e.jsxs("p",{className:"text-[9px] mt-0.5 truncate",style:{color:"#999"},children:[i.owner||"Unassigned",i.followUpAt&&e.jsxs(e.Fragment,{children:[" · due ",Xn(i.followUpAt)]})]}),i.tour.status!=="none"&&e.jsx("p",{className:"text-[9px] mt-0.5 truncate",style:{color:"#92400E"},children:Id[i.tour.status]}),e.jsxs("div",{className:"flex items-center gap-1 mt-0.5",children:[i.overdue&&e.jsx(ve,{size:9,style:{color:"#991B1B"}}),!i.overdue&&i.dueToday&&e.jsx(_a,{size:9,style:{color:"#92400E"}}),((o=i.profile)==null?void 0:o.readiness.level)==="high"&&e.jsx(Kx,{size:9,style:{color:"#166534"}})]})]},i.id)}),r.length===0&&e.jsx("p",{className:"text-[10px] text-center py-4",style:{color:"#bbb"},children:"Empty"}),r.length>60&&e.jsxs("p",{className:"text-[9px] text-center py-1",style:{color:"#999"},children:["+",r.length-60," more â narrow the filters"]})]})]},a.value)}),e.jsxs("div",{className:"w-[240px] rounded-xl p-2.5",style:{background:"#fff",border:`1px dashed ${k}25`},children:[e.jsxs("div",{className:"px-2 py-1 rounded-lg mb-2 flex items-center justify-between",style:{background:"#F3F4F6"},children:[e.jsx("span",{className:"text-[9px] font-bold uppercase tracking-wider",style:{color:"#4B5563"},children:"Not yet in CRM"}),e.jsx("span",{className:"text-[10px] font-bold",style:{color:"#4B5563"},children:n.length})]}),e.jsxs("div",{className:"space-y-1.5 max-h-[520px] overflow-y-auto pr-0.5",children:[n.slice(0,60).map(a=>e.jsxs("button",{onClick:()=>s(a),className:"w-full text-left rounded-lg px-2 py-1.5",style:{background:"#FAFAFA",border:`1px solid ${k}10`},children:[e.jsx("p",{className:"text-[11px] font-bold truncate",style:{color:k},children:a.name}),e.jsx("p",{className:"text-[10px] truncate",style:{color:"#777"},children:a.program||"Program not set"})]},a.id)),n.length===0&&e.jsx("p",{className:"text-[10px] text-center py-4",style:{color:"#bbb"},children:"Empty"})]})]})]})})},Lg="#B8962E",C4={call:{bg:"#DBEAFE",fg:"#1E40AF"},text:{bg:"#CCFBF1",fg:"#0E7490"},email:{bg:"#EDE9FE",fg:"#5B21B6"},note:{bg:"#F3F4F6",fg:"#374151"},tour:{bg:"#FEF3C7",fg:"#92400E"}
1301,application:{bg:"#FFE4D5",fg:"#7C2D12"},financial_aid:{bg:"#E0E7FF",fg:"#3730A3"},other:{bg:"#F5F5F4",fg:"#57534E"},system:{bg:"#FAFAF9",fg:"#78716C"}},U$=({activities:t,personId:s,busy:n,onLog:a})=>{const[r,i]=d.useState("call"),[o,l]=d.useState(""),[c,u]=d.useState(""),[p,m]=d.useState(""),[x,h]=d.useState(!1),y=x?t:t.filter(g=>!g.is_system&&g.activity_type!=="system"),v=async g=>{g.preventDefault(),!(!s||n)&&(await a(r,c,p?new Date(p).toISOString():null,r==="call"&&o||null),u(""),m(""),l(""))};return e.jsxs("div",{className:"grid lg:grid-cols-2 gap-4",children:[e.jsxs("form",{onSubmit:v,className:"rounded-lg p-3",style:{background:"#FCFAF5",border:`1px solid ${$}44`},children:[e.jsx("p",{className:"text-[10px] uppercase tracking-[0.25em] font-bold mb-2",style:{color:Lg},children:"Log activity"}),e.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[e.jsxs("label",{className:"block",children:[e.jsx("span",{className:"text-[10px] font-semibold",style:{color:"#666"},children:"Type"}),e.jsx("select",{value:r,onChange:g=>i(g.target.value),className:"w-full mt-0.5 px-2 py-1.5 rounded-md text-xs bg-white",style:{border:`1px solid ${k}22`,color:k},children:rde.map(g=>e.jsx("option",{value:g.value,children:g.label},g.value))})]}),e.jsxs("label",{className:"block",children:[e.jsx("span",{className:"text-[10px] font-semibold",style:{color:"#666"},children:"When (optional)"}),e.jsx("input",{type:"datetime-local",value:p,onChange:g=>m(g.target.value),className:"w-full mt-0.5 px-2 py-1.5 rounded-md text-xs bg-white",style:{border:`1px solid ${k}22`,color:k}})]})]}),r==="call"&&e.jsxs("label",{className:"block mt-2",children:[e.jsx("span",{className:"text-[10px] font-semibold",style:{color:"#666"},children:"Call outcome"}),e.jsxs("select",{value:o,onChange:g=>l(g.target.value),className:"w-full mt-0.5 px-2 py-1.5 rounded-md text-xs bg-white",style:{border:`1px solid ${k}22`,color:k},children:[e.jsx("option",{value:"",children:"Select an outcome (recommended)"}),I$.map(g=>e.jsx("option",{value:g.value,children:g.label},g.value))]}),e.jsx("span",{className:"text-[9px]",style:{color:"#aaa"},children:"Recorded as a structured value so outcomes can be reported on later."})]}),e.jsxs("label",{className:"block mt-2",children:[e.jsx("span",{className:"text-[10px] font-semibold",style:{color:"#666"},children:"Notes"}),e.jsx("textarea",{value:c,onChange:g=>u(g.target.value),rows:3,placeholder:"What happened? e.g. Left voicemail about September cohort.",className:"w-full mt-0.5 px-2 py-1.5 rounded-md text-xs bg-white resize-y",style:{border:`1px solid ${k}22`,color:k}})]}),e.jsxs("button",{type:"submit",disabled:!s||n,className:"mt-2 w-full inline-flex items-center justify-center gap-1.5 px-3 py-2 rounded-lg text-xs font-bold disabled:opacity-50",style:{background:`linear-gradient(135deg, ${$}, ${Lg})`,color:k},children:[n?e.jsx(de,{size:12,className:"animate-spin"}):e.jsx(tn,{size:12}),"Save to history"]}),e.jsx("p",{className:"text-[9px] mt-1.5 leading-relaxed",style:{color:"#999"},children:"Records the contact only â no email or SMS is sent from this form."})]}),e.jsxs("div",{className:"rounded-lg p-3",style:{background:"#FAFAFA",border:`1px solid ${k}12`},children:[e.jsxs("div",{className:"flex items-center justify-between mb-2",children:[e.jsxs("p",{className:"text-[10px] uppercase tracking-[0.25em] font-bold flex items-center gap-1",style:{color:Lg},children:[e.jsx(en,{size:11})," History (",y.length,")"]}),e.jsxs("button",{type:"button",onClick:()=>h(g=>!g),className:"inline-flex items-center gap-1 text-[10px] font-semibold",style:{color:x?k:"#999"},title:"Show automatic stage / owner / follow-up change entries",children:[e.jsx(YP,{size:10})," ",x?"Hide":"Show"," system entries"]})]}),y.length===0?e.jsx("p",{className:"text-[11px] py-6 text-center",style:{color:"#aaa"},children:s?"No activity logged yet.":"Add this prospect to the CRM to start logging activity."}):e.jsx("div",{className:"space-y-2 max-h-72 overflow-y-auto pr-1",children:y.slice(0,60).map(g=>{const N=C4[g.activity_type]||C4.other,b=g.call_outcome?ode[g.call_outcome]:null;return e.jsxs("div",{className:"rounded-md p-2 bg-white",style:{border:`1px solid ${k}0F`},children:[e.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[e.jsx("span",{className:"px-1.5 py-0.5 rounded-full text-[9px] font-bold uppercase tracking-wider",style:{background:N.bg,color:N.fg},children:ide[g.activity_type]}),b&&e.jsx("span",{className:"px-1.5 py-0.5 rounded-full text-[9px] font-bold",style:{background:"#FCFAF5",color:Lg,border:`1px solid ${$}66`},children:b}),e.jsx("span",{className:"text-[10px]",style:{color:"#888"},children:Ln(g.occurred_at)}),e.jsx("span",{className:"text-[10px] font-semibold",style:{color:k},children:g.staff_name||g.staff_email||"Unknown staff"})]}),g.notes&&e.jsx("p",{className:"text-[11px] mt-1 leading-relaxed whitespace-pre-wrap",style:{color:"#555"},children:g.notes})]},g.id)})})]})]})},Dde="#B8962E",Rde="[email protected]",Ide=({personId:t,personName:s,recipientEmail:n,onClose:a,onSent:r})=>{const i=d.useMemo(()=>{var b;return(b=globalThis.crypto)!=null&&b.randomUUID?globalThis.crypto.randomUUID():""},[]),[o,l]=d.useState(""),[c,u]=d.useState(""),[p,m]=d.useState(!1),[x,h]=d.useState(null),[y,v]=d.useState(null),g=!!o.trim()&&!!c.trim()&&!p&&!y&&!!i,N=async b=>{if(b.preventDefault(),!g)return;m(!0),h(null);const f=await gde({personId:t,subject:o.trim(),message:c.trim(),requestId:i});if(!f.ok){h(f.error||"The email was not sent."),m(!1);return}v({messageId:f.messageId??null,alreadySent:!!f.alreadySent}),m(!1),await r()};return e.jsx("div",{className:"fixed inset-0 z-[60] flex items-center justify-center p-4",style:{background:"rgba(20,6,10,0.55)"},children:e.jsxs("div",{className:"w-full max-w-lg rounded-2xl overflow-hidden",style:{background:"#fff"},children:[e.jsxs("div",{className:"px-5 py-3.5 flex items-start gap-3",style:{background:`linear-gradient(135deg, ${k}, #2A0810)`},children:[e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"text-[9px] uppercase tracking-[0.3em] font-bold",style:{color:"#E6D2A0"},children:"One-to-one admissions email"}),e.jsx("h3",{className:"text-base font-bold truncate",style:{color:$},children:s})]}),e.jsx("button",{onClick:a,"aria-label":"Close compose",style:{color:$},children:e.jsx(Ke,{size:17})})]}),e.jsxs("form",{onSubmit:N,className:"p-5 space-y-3",children:[e.jsxs("div",{className:"rounded-lg p-2.5 space-y-0.5",style:{background:"#FAFAFA",border:`1px solid ${k}12`},children:[e.jsxs("p",{className:"text-[11px]",style:{color:"#555"},children:[e.jsx("span",{style:{color:"#999"},children:"To: "}),e.jsx("span",{className:"font-semibold",style:{color:k},children:n})]}),e.jsxs("p",{className:"text-[11px]",style:{color:"#555"},children:[e.jsx("span",{style:{color:"#999"},children:"From / Reply-To: "}),e.jsx("span",{className:"font-semibold",style:{color:k},children:Rde})]}),e.jsx("p",{className:"text-[9px] leading-relaxed",style:{color:"#999"},children:"The recipient is re-read from this prospect's CRM record when you press Send, and replies come back to the Institute admissions inbox."})]}),e.jsxs("label",{className:"block",children:[e.jsx("span",{className:"text-[10px] font-semibold",style:{color:"#666"},children:"Subject"}),e.jsx("input",{type:"text",value:o,maxLength:200,disabled:p||!!y,onChange:b=>l(b.target.value),placeholder:"e.g. Your Master Esthetics questions",className:"w-full mt-0.5 px-2.5 py-2 rounded-md text-xs bg-white",style:{border:`1px solid ${k}22`,color:k}})]}),e.jsxs("label",{className:"block",children:[e.jsx("span",{className:"text-[10px] font-semibold",style:{color:"#666"},children:"Message"}),e.jsx("textarea",{value:c,rows:9,maxLength:8e3,disabled:p||!!y,onChange:b=>u(b.target.value),placeholder:`Hi ${s.split(" ")[0]||"there"}, 1302 1303`,className:"w-full mt-0.5 px-2.5 py-2 rounded-md text-xs bg-white resize-y",style:{border:`1px solid ${k}22`,color:k}}),e.jsx("span",{className:"text-[9px]",style:{color:"#aaa"},children:"Your name and the Institute admissions signature are added automatically."})]}),x&&e.jsxs("div",{className:"rounded-lg p-2.5 flex items-start gap-2",style:{background:"#FEF2F2",border:"1px solid #FCA5A5"},children:[e.jsx(ve,{size:14,style:{color:"#991B1B",marginTop:1}}),e.jsx("p",{className:"text-[11px] leading-relaxed",style:{color:"#991B1B"},children:x})]}),y&&e.jsxs("div",{className:"rounded-lg p-2.5 flex items-start gap-2",style:{background:"#F0FDF4",border:"1px solid #86EFAC"},children:[e.jsx(Ue,{size:14,style:{color:"#166534",marginTop:1}}),e.jsxs("p",{className:"text-[11px] leading-relaxed",style:{color:"#166534"},children:[y.alreadySent?"This exact email was already sent â a duplicate was prevented.":"Sent and recorded on this prospect.",y.messageId&&e.jsxs(e.Fragment,{children:[" Provider id ",e.jsx("span",{className:"font-mono",children:y.messageId}),"."]})]})]}),e.jsxs("div",{className:"flex gap-2 pt-1",children:[e.jsx("button",{type:"button",onClick:a,className:"flex-1 px-3 py-2 rounded-lg text-[11px] font-bold",style:{background:"transparent",color:k,border:`1px solid ${k}22`},children:y?"Close":"Cancel"}),!y&&e.jsxs("button",{type:"submit",disabled:!g,className:"flex-1 inline-flex items-center justify-center gap-1.5 px-3 py-2 rounded-lg text-[11px] font-bold disabled:opacity-50 disabled:cursor-not-allowed",style:{background:`linear-gradient(135deg, ${$}, ${Dde})`,color:k},children:[p?e.jsx(de,{size:12,className:"animate-spin"}):e.jsx(Ye,{size:12}),p?"Sendingâ¦":"Send email"]})]}),e.jsx("p",{className:"text-[9px] leading-relaxed",style:{color:"#999"},children:"One email, to this one prospect, sent only when you press Send. No campaign, nurture, sequence or automated follow-up is created, and a retry of the same draft cannot send twice."})]})]})})},q$="#B8962E",$de=new Set(["id","created_at","updated_at"]),zde=/(ssn|social_security|password|token|hash|secret|api_key|access_code|salt)/i,Lde=new Set(["full_name","email","phone","program_of_interest","preferred_tour_date","educational_background","career_goals","financial_aid_interest","consent","status","admin_notes"]),W$=t=>t.replace(/_/g," ").replace(/\b\w/g,s=>s.toUpperCase()).replace(/\bId\b/g,"ID").replace(/\bUrl\b/g,"URL"),Ode=t=>{if(t==null||t==="")return e.jsx("em",{style:{color:"#bbb"},children:"Not provided"});if(typeof t=="boolean")return t?"Yes":"No";if(Array.isArray(t))return t.length?t.join(", "):e.jsx("em",{style:{color:"#bbb"},children:"Not provided"});if(typeof t=="object"){const s=Object.entries(t).filter(([,n])=>n!==null&&n!=="");return s.length?e.jsx("span",{children:s.map(([n,a])=>`${W$(n)}: ${String(a)}`).join(" · ")}):e.jsx("em",{style:{color:"#bbb"},children:"Not provided"})}return String(t)},ca=({label:t,value:s})=>e.jsxs("div",{className:"py-1.5 grid sm:grid-cols-3 gap-1 border-b last:border-b-0",style:{borderColor:`${k}0D`},children:[e.jsx("span",{className:"text-[10px] uppercase tracking-wider font-semibold",style:{color:"#999"},children:t}),e.jsx("span",{className:"sm:col-span-2 text-[12px] leading-relaxed",style:{color:"#444"},children:Ode(s)})]}),Dc=({title:t,children:s})=>e.jsxs("div",{className:"rounded-lg p-3.5 mb-3",style:{background:"#FAFAFA",border:`1px solid ${k}0F`},children:[e.jsx("p",{className:"text-[9px] uppercase tracking-[0.2em] font-bold mb-1.5",style:{color:q$},children:t}),s]}),H$=({applicantIds:t,personName:s,onClose:n})=>
1303{const[a,r]=d.useState([]),[i,o]=d.useState(!0),[l,c]=d.useState(null),[u,p]=d.useState(0);d.useEffect(()=>{let h=!1;const y=async()=>{o(!0),c(null);const{data:v,error:g}=await O.from("admissions_applicants").select("*").in("id",t);if(!h){if(g)c(g.message),r([]);else{const N=[...v||[]].sort((b,f)=>{const j=b.created_at?new Date(b.created_at).getTime():0,S=f.created_at?new Date(f.created_at).getTime():0;return j-S});r(N),p(0)}o(!1)}};return t.length?y():(r([]),o(!1)),()=>{h=!0}},[t.join(",")]);const m=a[u],x=m?Object.entries(m).filter(([h])=>!Lde.has(h)&&!$de.has(h)&&!zde.test(h)):[];return e.jsx("div",{className:"fixed inset-0 z-[60] flex justify-center items-start overflow-y-auto py-6 px-3",style:{background:"rgba(20,6,10,0.6)"},children:e.jsxs("div",{className:"w-full max-w-3xl rounded-xl overflow-hidden",style:{background:"#fff"},children:[e.jsxs("div",{className:"px-5 py-4 flex items-start gap-3",style:{background:`linear-gradient(135deg, ${k}, #2A0810)`},children:[e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"text-[9px] uppercase tracking-[0.3em] font-bold",style:{color:"#E6D2A0"},children:"Completed admissions application"}),e.jsx("h2",{className:"text-lg font-bold truncate",style:{color:$},children:s}),e.jsx("p",{className:"text-[11px] mt-0.5",style:{color:"#E6D2A0"},children:"Submitted values exactly as stored â read only"})]}),e.jsx("button",{onClick:n,"aria-label":"Close application",style:{color:$},children:e.jsx(Ke,{size:18})})]}),e.jsxs("div",{className:"p-5",children:[i&&e.jsxs("p",{className:"flex items-center gap-2 text-[12px]",style:{color:"#777"},children:[e.jsx(de,{size:13,className:"animate-spin"})," Loading applicationâ¦"]}),!i&&l&&e.jsxs("p",{className:"flex items-start gap-2 text-[12px] rounded-lg p-3",style:{background:"#FEF2F2",color:"#991B1B"},children:[e.jsx(Mt,{size:13,className:"mt-0.5"})," Could not load the application: ",l]}),!i&&!l&&!a.length&&e.jsx("p",{className:"text-[12px]",style:{color:"#777"},children:"No admissions application record was found for this prospect."}),!i&&!l&&a.length>0&&m&&e.jsxs(e.Fragment,{children:[a.length>1&&e.jsxs("div",{className:"mb-4",children:[e.jsxs("p",{className:"text-[10px] uppercase tracking-wider font-bold mb-1.5",style:{color:q$},children:[a.length," applications on file"]}),e.jsx("div",{className:"flex flex-wrap gap-2",children:a.map((h,y)=>e.jsxs("button",{onClick:()=>p(y),className:"px-3 py-1.5 rounded-lg text-[11px] font-semibold",style:y===u?{background:k,color:$}:{background:`${k}0C`,color:k,border:`1px solid ${k}22`},children:["Application ",y+1," â submitted ",h.created_at?Xn(h.created_at):"date not recorded"]},h.id))})]}),e.jsxs(Dc,{title:"Applicant information",children:[e.jsx(ca,{label:"Full name",value:m.full_name}),e.jsx(ca,{label:"Email",value:m.email}),e.jsx(ca,{label:"Phone",value:m.phone})]}),e.jsxs(Dc,{title:"Program & start information",children:[e.jsx(ca,{label:"Program selected",value:m.program_of_interest}),e.jsx(ca,{label:"Preferred tour date",value:m.preferred_tour_date?Xn(m.preferred_tour_date):null})]}),e.jsxs(Dc,{title:"Education / admissions information",children:[e.jsx(ca,{label:"Educational background",value:m.educational_background}),e.jsx(ca,{label:"Career goals",value:m.career_goals})]}),e.jsx(Dc,{title:"Funding / financial aid",children:e.jsx(ca,{label:"Interested in financial aid",value:m.financial_aid_interest})}),x.length>0&&e.jsx(Dc,{title:"Additional questions",children:x.map(([h,y])=>e.jsx(ca,{label:W$(h),value:y},h))}),e.jsx(Dc,{title:"Acknowledgements",children:e.jsx(ca,{label:"Consent acknowledged on submission",value:m.consent})}),e.jsxs(Dc,{title:"Submission information",children:[e.jsx(ca,{label:"Submitted",value:m.created_at?Ln(m.created_at):null}),e.jsx(ca,{label:"Last updated",value:m.updated_at?Ln(m.updated_at):null}),e.jsx(ca,{label:"Application status",value:m.status}),e.jsx(ca,{label:"Admin notes",value:m.admin_notes})]}),e.jsxs("p",{className:"text-[9px] font-mono mt-2",style:{color:"#c9c9c9"},children:["admissions_applicants · record ",String(m.id)]})]}),e.jsx("div",{className:"mt-4 flex justify-end",children:e.jsx("button",{onClick:n,className:"px-4 py-2 rounded-lg text-[11px] font-bold",style:{background:k,color:$},children:"Back to prospect"})})]})]})})},AN="#B8962E",eo=({title:t,icon:s,children:n})=>e.jsxs("div",{className:"rounded-lg p-3",style:{background:"#FAFAFA",border:`1px solid ${k}0F`},children:[e.jsxs("p",{className:"text-[9px] uppercase tracking-[0.2em] font-bold mb-2 flex items-center gap-1",style:{color:AN},children:[s," ",t]}),n]}),Fs=({label:t,value:s})=>e.jsxs("p",{className:"text-[11px] leading-relaxed",style:{color:"#555"},children:[e.jsxs("span",{style:{color:"#999"},children:[t,": "]}
1303),s==null||s===""?e.jsx("em",{style:{color:"#bbb"},children:"not set"}):s]}),Mde=({item:t,staff:s,canRevealPII:n,canOpenApplication:a,busy:r,onClose:i,onPatch:o,onLogActivity:l,onRefresh:c})=>{const u=a??n,{row:p,profile:m}=t,x=p.person,h=((x==null?void 0:x.primary_email)||t.email||"").trim(),[y,v]=d.useState((x==null?void 0:x.next_action)||""),[g,N]=d.useState(lb((x==null?void 0:x.follow_up_at)||null)),[b,f]=d.useState(!1),[j,S]=d.useState(!1),w=p.group.records.filter(D=>D.sourceKey==="admissions_applicants"&&D.recordId).map(D=>String(D.recordId)),_=`${(x==null?void 0:x.id)||"none"}:${(x==null?void 0:x.updated_at)||""}`,[C,E]=d.useState(_);C!==_&&(E(_),v((x==null?void 0:x.next_action)||""),N(lb((x==null?void 0:x.follow_up_at)||null)));const P=()=>{if(!x)return;const D={};(y||"")!==(x.next_action||"")&&(D.next_action=y.trim()||null);const L=g?new Date(g).toISOString():null;L!==(x.follow_up_at||null)&&(D.follow_up_at=L),Object.keys(D).length&&o(p,D)},F=B$(t.phone),I=jk[t.tour.status];return e.jsxs("div",{className:"fixed inset-0 z-50 flex justify-end",style:{background:"rgba(20,6,10,0.45)"},children:[e.jsxs("div",{className:"w-full max-w-2xl h-full overflow-y-auto",style:{background:"#fff"},children:[e.jsxs("div",{className:"sticky top-0 z-10 px-5 py-4 flex items-start gap-3",style:{background:`linear-gradient(135deg, ${k}, #2A0810)`},children:[e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"text-[9px] uppercase tracking-[0.3em] font-bold",style:{color:"#E6D2A0"},children:"Admissions prospect"}),e.jsx("h2",{className:"text-lg font-bold truncate",style:{color:$},children:t.name}),e.jsxs("p",{className:"text-[11px] mt-0.5",style:{color:"#E6D2A0"},children:[t.stageLabel,t.readinessScore!==null&&e.jsxs(e.Fragment,{children:[" · ",t.readinessLabel," ",t.readinessScore]})," · ",t.recordStatus]})]}),e.jsx("button",{onClick:i,"aria-label":"Close prospect",style:{color:$},children:e.jsx(Ke,{size:18})})]}),e.jsxs("div",{className:"p-5 space-y-4",children:[e.jsxs(eo,{title:"Contact â manual actions only",icon:e.jsx(Qt,{size:11}),children:[e.jsxs("div",{className:"grid sm:grid-cols-2 gap-2",children:[e.jsx(Fs,{label:"Phone",value:CN(t.phone,n)||void 0}),e.jsx(Fs,{label:"Email",value:M$(t.email,n)||void 0}),e.jsx(Fs,{label:"Program interest",value:t.program}),e.jsx(Fs,{label:"Campus",value:t.campus}),e.jsx(Fs,{label:"Lead source",value:t.leadSource}),e.jsx(Fs,{label:"Owner",value:t.owner})]}),e.jsxs("div",{className:"flex flex-wrap gap-2 mt-3",children:[n&&F?e.jsxs(e.Fragment,{children:[e.jsxs("a",{href:`tel:${F}`,className:"inline-flex items-center gap-1.5 px-3 py-1.5 rounded-lg text-[11px] font-bold",style:{background:`${k}0C`,color:k,border:`1px solid ${k}22`},children:[e.jsx(Qt,{size:11})," Call"]}),e.jsxs("a",{href:`sms:${F}`,className:"inline-flex items-center gap-1.5 px-3 py-1.5 rounded-lg text-[11px] font-bold",style:{background:`${k}0C`,color:k,border:`1px solid ${k}22`},children:[e.jsx(jr,{size:11})," Text"]})]}):e.jsx("span",{className:"text-[10px] px-2 py-1 rounded",style:{background:"#F3F4F6",color:"#6B7280"},children:n?"No phone on file â call/text unavailable":"Contact actions require an authorized admissions role"}),n&&h?x?e.jsxs("button",{type:"button",onClick:()=>S(!0),className:"inline-flex items-center gap-1.5 px-3 py-1.5 rounded-lg text-[11px] font-bold",style:{background:`${k}0C`,color:k,border:`1px solid ${k}22`},children:[e.jsx(Ye,{size:11})," Email"]}):e.jsx("span",{className:"text-[10px] px-2 py-1 rounded",style:{background:"#FFFBEB",color:"#92400E"},children:"Log an activity first to add this prospect to the CRM, then email from here"}):null]}),e.jsx("p",{className:"text-[9px] mt-2 leading-relaxed",style:{color:"#999"},children:"Call and Text open your own phone. Email is composed and sent from inside the CRM as a single message to this prospect, from [email protected], and is recorded in the communication history below. Automated nurture, campaigns and bulk messaging remain switched off."})]}),e.jsx(eo,{title:"Pipeline â staff decision",icon:e.jsx(OP,{size:11}),children:x?e.jsxs("div",{className:"grid sm:grid-cols-3 gap-2",children:[e.jsxs("label",{className:"block",children:[e.jsx("span",{className:"text-[10px] font-semibold",style:{color:"#666"},children:"CRM stage"}),e.jsx("select",{value:x.stage,disabled:r,onChange:D=>void o(p,{stage:D.target.value}),className:"w-full mt-0.5 px-2 py-1.5 rounded-md text-xs bg-white",style:{border:`1px solid ${k}22`,color:k},children:Wa.map(D=>e.jsx("option",{value:D.value,children:D.label},D.value))}),e.jsx("span",{className:"text-[9px]",style:{color:"#aaa"}
1303,children:"Any stage can be selected directly â a ready prospect never has to walk every step."})]}),e.jsxs("label",{className:"block",children:[e.jsx("span",{className:"text-[10px] font-semibold",style:{color:"#666"},children:"Owner"}),e.jsxs("select",{value:x.owner_user_id||"",disabled:r,onChange:D=>{const L=D.target.value||null,V=s.find(B=>B.id===L);o(p,{owner_user_id:L,owner_name:(V==null?void 0:V.name)||null})},className:"w-full mt-0.5 px-2 py-1.5 rounded-md text-xs bg-white",style:{border:`1px solid ${k}22`,color:k},children:[e.jsx("option",{value:"",children:"Unassigned"}),s.map(D=>e.jsx("option",{value:D.id,children:D.name},D.id))]})]}),e.jsxs("label",{className:"block",children:[e.jsx("span",{className:"text-[10px] font-semibold",style:{color:"#666"},children:"Priority"}),e.jsxs("select",{value:x.priority,disabled:r,onChange:D=>void o(p,{priority:D.target.value}),className:"w-full mt-0.5 px-2 py-1.5 rounded-md text-xs bg-white",style:{border:`1px solid ${k}22`,color:k},children:[e.jsx("option",{value:"normal",children:"Normal"}),e.jsx("option",{value:"high",children:"High"})]})]}),e.jsxs("label",{className:"block sm:col-span-2",children:[e.jsx("span",{className:"text-[10px] font-semibold",style:{color:"#666"},children:"Next action"}),e.jsx("input",{type:"text",value:y,disabled:r,maxLength:160,placeholder:"e.g. Call back to confirm financial aid appointment",onChange:D=>v(D.target.value),onBlur:P,className:"w-full mt-0.5 px-2 py-1.5 rounded-md text-xs bg-white",style:{border:`1px solid ${k}22`,color:k}})]}),e.jsxs("label",{className:"block",children:[e.jsx("span",{className:"text-[10px] font-semibold",style:{color:"#666"},children:"Follow-up due"}),e.jsx("input",{type:"datetime-local",value:g,disabled:r,onChange:D=>N(D.target.value),onBlur:P,className:"w-full mt-0.5 px-2 py-1.5 rounded-md text-xs bg-white",style:{border:`1px solid ${k}22`,color:k}})]}),e.jsx("div",{className:"sm:col-span-3",children:e.jsxs("button",{type:"button",onClick:P,disabled:r,className:"inline-flex items-center gap-1.5 px-3 py-1.5 rounded-md text-[11px] font-bold disabled:opacity-50",style:{background:k,color:$},children:[r?e.jsx(de,{size:11,className:"animate-spin"}):null," Save next action & follow-up"]})})]}):e.jsx("p",{className:"text-[11px]",style:{color:"#777"},children:"This prospect is not in the CRM yet. Logging an activity or setting a next action from here creates the coordination record â the original source rows are left untouched."})}),e.jsxs(eo,{title:"Tour",icon:e.jsx(_a,{size:11}),children:[e.jsx("span",{className:"inline-block px-2 py-0.5 rounded-full text-[9px] font-bold uppercase tracking-wider",style:{background:I.bg,color:I.fg},children:Id[t.tour.status]}),e.jsxs("div",{className:"mt-2 space-y-0.5",children:[e.jsx(Fs,{label:"Requested date / time",value:t.tour.requestedFor?Xn(t.tour.requestedFor):void 0}),e.jsx(Fs,{label:"Confirmed appointment",value:t.tour.confirmedAt?Ln(t.tour.confirmedAt):e.jsx("span",{style:{color:"#92400E",fontWeight:600},children:"Tour confirmation not available"})}),e.jsx(Fs,{label:"Status",value:Id[t.tour.status]}),e.jsx(Fs,{label:"Source / calendar",value:t.tour.calendar}),e.jsx(Fs,{label:"Basis",value:t.tour.basis})]})]}),e.jsxs("div",{className:"grid sm:grid-cols-2 gap-3",children:[e.jsxs(eo,{title:"Application",icon:e.jsx(Kt,{size:11}),children:[e.jsx(Fs,{label:"Status",value:t.application.label}),e.jsx(Fs,{label:"Submitted",value:t.application.submittedAt?Xn(t.application.submittedAt):void 0}),e.jsx(Fs,{label:"Source status",value:t.application.sourceStatus}),w.length>0&&u&&e.jsxs("button",{type:"button",onClick:()=>f(!0),className:"inline-flex items-center gap-1.5 mt-2 px-3 py-2 rounded-lg text-[11px] font-bold uppercase tracking-wider w-full justify-center",style:{background:`linear-gradient(135deg, ${$}, ${AN})`,color:k},children:[e.jsx(Kt,{size:12})," View completed application",w.length>1?` (${w.length})`:""]}),w.length>0&&!u&&e.jsx("p",{className:"text-[9px] mt-2",style:{color:"#999"},children:"Viewing the completed application requires an authorized admissions role."}),t.application.record&&e.jsxs("a",{href:`/admin/lead-inventory?record=${encodeURIComponent(t.application.record.key)}`,target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center gap-1.5 mt-2 px-3 py-1.5 rounded-lg text-[11px] font-bold",style:{background:`${k}0C`,color:k,border:`1px solid ${k}22`},children:[e.jsx(Ua,{size:11})," Open source record"]})]}),e.jsxs(eo,{title:"Financial aid â visibility only",icon:e.jsx(wo,{size:11}),children:[e.jsx(Fs,{label:"Status",value:t.aid.label}),e.jsx(Fs,{label:"Evidence",value:t.aid.detail}),e.jsx("p",{className:"text-[9px] mt-2 leading-relaxed",style:{color:"#999"},children:"Eligibility, packaging and awards stay with the Financial Aid Administrator. Nothing here calculates or changes aid."})]})]}),e.jsxs(eo,{title:"Start date / cohort",icon:e.jsx(_a,{size:11}),children:[e.jsx(Fs,{label:"Desired timeframe",value:t.start.timeframe}),e.jsx(Fs,{label:"Target / confirmed start",value:t.start.date?Xn(t.start.date):void 0}),e.jsx(Fs,{label:"Source",value:t.start.basis})]}),m&&e.jsxs(eo,{title:"Readiness & identity",icon:e.jsx(zn,{size:11}),children:[e.jsxs("p",{className:"text-[11px] font-semibold mb-1",style:{color:Yr[m.readiness.level].fg},children:[Yr[m.readiness.level].label," · ",m.readiness.score,"/100"]}),e.jsxs("ul",{className:"space-y-0.5 mb-2",children:[m.readiness.signals.map((D,L)=>e.jsxs("li",{className:"text-[10px]",style:{color:"#555"},children:["· ",D.label]},L)),!m.readiness.signals.length&&e.jsx("li",{className:"text-[10px]",style:{color:"#999"},children:"No intent signals recorded yet."})]}),e.jsx(Fs,{label:"Identity",value:m.identityReason}),e.jsx(Fs,{label:"Lifecycle",value:m.lifecycleReason})]}),e.jsx(eo,{title:"Communication history",icon:e.jsx(en,{size:11}),children:e.jsx(U$,{activities:p.activities,personId:(x==null?void 0:x.id)||null,busy:r,onLog:(D,L,V,B)=>l(p,D,L,V,B)})}),e.jsx(eo,{title:`Linked source records (${p.group.records.length}) â unchanged`,icon:e.jsx(Xs,{size:11}),children:e.jsx("div",{className:"space-y-1.5",children:p.group.records.map(D=>e.jsxs("div",{className:"rounded-md px-2.5 py-1.5 flex flex-wrap items-center gap-x-3 gap-y-1 bg-white",style:{border:`1px solid ${k}0F`},children:[e.jsx("span",{className:"text-[10px] font-bold uppercase tracking-wider",style:{color:AN},children:D.sourceLabel}),e.jsx("span",{className:"text-[10px] font-mono",style:{color:"#bbb"},children:D.ref}),e.jsx("span",{className:"text-[10px]",style:{color:"#777"},children:Xn(D.createdAt)}),e.jsxs("span",{className:"text-[10px]",style:{color:"#777"},children:["status: ",D.status||"none"]}),D.program&&e.jsx("span",{className:"text-[10px]",style:{color:"#777"},children:D.program})]},D.key))})})]})]}),b&&e.jsx(H$,{applicantIds:w,personName:t.name,onClose:()=>f(!1)}),j&&x&&h&&e.jsx(Ide,{personId:x.id,personName:t.name,recipientEmail:h,onClose:()=>S(!1),onSent:()=>c==null?void 0:c()})]})},Bde=["not_required","not_requested","requested","submitted","under_review","accepted","needs_correction","rejected","waived"],A4={not_required:"Not Applicable",not_requested:"Not Requested",requested:"Requested",submitted:"Submitted",under_review:"Under Review",accepted:"Accepted",needs_correction:"Needs Correction",rejected:"Rejected",waived:"Waived"},E4={not_required:{bg:"#F3F4F6",fg:"#6B7280"},not_requested:{bg:"#F3F4F6",fg:"#4B5563"},requested:{bg:"#DBEAFE",fg:"#1E40AF"},submitted:{bg:"#E0E7FF",fg:"#3730A3"},under_review:{bg:"#FEF9C3",fg:"#854D0E"},accepted:{bg:"#DCFCE7",fg:"#166534"},needs_correction:{bg:"#FEF3C7",fg:"#92400E"},rejected:{bg:"#FEE2E2",fg:"#991B1B"},waived:{bg:"#EDE9FE",fg:"#5B21B6"}},Ude=["accepted","waived","not_required"],Bm=t=>Ude.includes(t),G$={photo_id:"Photo ID",proof_of_education:"Proof of Education (Diploma / GED)",transcript:"Transcript",letter_of_intent:"Letter of Intent",other_admissions_document:"Other Admissions Document"},F4=["application/pdf","image/jpeg","image/jpg","image/png","image/heic","image/webp"],qde=10*1024*1024,Wde=[{key:"application",label:"Admissions Application",category:"application",applicantUploadable:!1,defaultRequired:!0,helper:"Submitted through Apply Now. Marked accepted once Admissions confirms the application is complete."},{key:"photo_id",label:"Photo ID",category:"document",documentType:"photo_id",applicantUploadable:!0,defaultRequired:!0,helper:"A clear photo or scan of a government-issued ID."},{key:"proof_of_education",label:"Proof of Education (Diploma / GED)",category:"document",documentType:"proof_of_education",applicantUploadable:!0,defaultRequired:!0,helper:"High school diploma, GED certificate, or equivalent."},{key:"transcript",label:"Transcript (if applicable)",category:"document",documentType:"transcript",applicantUploadable:!0,defaultRequired:!1,helper:"Only required when transfer hours or prior training are being evaluated."},{key:"letter_of_intent",label:"Letter of Intent",category:"document",documentType:"letter_of_intent",applicantUploadable:!0,defaultRequired:!1,helper:"A short statement of goals. Requested at the discretion of Admissions."},{key:"admissions_interview",label:"Admissions Interview",category:"interview",applicantUploadable:!1,defaultRequired:!0,futurePhase:!0,helper:"Tracked here now; the structured interview form arrives in a later phase."},{key:"financial_plan",label:"Financial Plan",category:"financial",applicantUploadable:!1,defaultRequired:!0,futurePhase:!0,helper:"Tracked here now; the financial plan workflow arrives in a later phase."},{key:"enrollment_agreement",label:"Enrollment Agreement",category:"agreement",applicantUploadable:!1,defaultRequired:!0,futurePhase:!0,helper:"Tracked here now; generation and e-signature arrive in a later phase."}],EN=t=>
1303Wde.find(s=>s.key===t),V$={pending:"Awaiting Review",under_review:"Under Review",approved:"Accepted",needs_correction:"Needs Correction",rejected:"Rejected",superseded:"Replaced"};function Hde(t){const s=t.filter(i=>i.status!=="not_required"),n=s.filter(i=>Bm(i.status)),a=s.filter(i=>!Bm(i.status)),r=s.length;return{total:r,complete:n.length,outstanding:a,pctComplete:r?Math.round(n.length/r*100):0,label:`${n.length} of ${r} Complete`}}async function qp(t){const{data:s,error:n}=await O.from("admissions_requirements").select("*").eq("applicant_id",t).order("position",{ascending:!0});if(n)throw n;return s||[]}async function T4(t){const{data:s,error:n}=await O.from("admissions_documents").select("*").eq("applicant_id",t).order("uploaded_at",{ascending:!1});if(n)throw n;return s||[]}async function Gde(t,s,n,a){const r=new Date().toISOString(),i={status:s,updated_at:r,decision_reason:a||null};s==="requested"&&(i.requested_at=r),s==="submitted"&&(i.submitted_at=r),["accepted","needs_correction","rejected","under_review"].includes(s)&&(i.reviewed_at=r,i.reviewed_by=n),s==="waived"&&(i.waived_at=r,i.waived_by=n);const{error:o}=await O.from("admissions_requirements").update(i).eq("id",t.id);if(o)throw o}async function Vde(t,s,n,a){const r=new Date().toISOString(),{error:i}=await O.from("admissions_documents").update({status:s,reviewed_by:n,reviewed_at:r,review_reason:a||null,updated_at:r}).eq("id",t.id);if(i)throw i;if(t.requirement_id){const o=s==="approved"?"accepted":s==="rejected"?"rejected":"needs_correction";await O.from("admissions_requirements").update({status:o,reviewed_at:r,reviewed_by:n,decision_reason:a||null,updated_at:r}).eq("id",t.requirement_id)}}async function Zde(t){const{data:s,error:n}=await O.functions.invoke("applicant-portal",{body:{action:"staff-doc-url",documentId:t}});if(n)throw n;if(!(s!=null&&s.success))throw new Error((s==null?void 0:s.error)||"Unable to open document");return s.url}async function Yde(t){const{data:s,error:n}=await O.functions.invoke("applicant-portal",{body:{action:"staff-issue-access",applicantId:t}});if(n)throw n;if(!(s!=null&&s.success))throw new Error((s==null?void 0:s.error)||"Unable to issue applicant access");return{code:s.code,email:s.email,expiresAt:s.expiresAt}}const P4={required:"Required",not_required:"Not Applicable",waived:"Waived",needs_configuration:"Needs Staff Configuration"},D4={required:{bg:"#E0E7FF",fg:"#3730A3"},not_required:{bg:"#F3F4F6",fg:"#6B7280"},waived:{bg:"#EDE9FE",fg:"#5B21B6"},needs_configuration:{bg:"#FEF3C7",fg:"#92400E"}},Kde=["required","not_required","waived","needs_configuration"],cb="_default",Qde=[{key:"master-esthetics-bridge",test:/bridge/i},{key:"master-esthetics",test:/master/i},{key:"instructor-training",test:/instructor/i},{key:"cosmetology",test:/cosmet/i},{key:"manicuring",test:/manicur|nail/i},{key:"esthetics",test:/esthet/i}];function wk(t){const s=String(t||"").trim();if(!s)return cb;const n=Qde.find(a=>a.test.test(s));return n?n.key:cb}async function Z$(t){const{data:s,error:n}=await O.from("admissions_requirement_templates").select("*").eq("program_key",t).eq("is_active",!0).order("position",{ascending:!0});if(n)throw n;return s&&s.length?s:t===cb?[]:Z$(cb)}const Jde=t=>t.applicability==="not_required"?"not_required":t.applicability==="waived"?"waived":"not_requested";async function Xde(t,s){const n=wk(s),a=await Z$(n);if(!a.length)return;const{data:r}=await O.from("admissions_requirements").select("id,requirement_key,applicability").eq("applicant_id",t),i=new Map((r||[]).map(l=>[l.requirement_key,l])),o=a.filter(l=>!i.has(l.requirement_key)).map(l=>({applicant_id:t,requirement_key:l.requirement_key,requirement_label:l.requirement_label,category:["application","document","interview","financial","agreement"].includes(l.category)?l.category:"other",position:l.position,is_required:l.applicability==="required",applicability:l.applicability,program_key:n,template_id:l.id,helper:l.helper,status:Jde(l)}));o.length&&await O.from("admissions_requirements").insert(o);for(const l of a){const c=i.get(l.requirement_key);c&&await O.from("admissions_requirements").update({requirement_label:l.requirement_label,helper:l.helper,position:l.position,program_key:n,template_id:l.id,updated_at:new Date().toISOString()}).eq("id",c.id)}await O.from("admissions_applicants").update({requirements_seeded_at:new Date().toISOString()}).eq("id",t)}async function eue(t,s,n){const a=new Date().toISOString(),r={applicability:s,is_required:s==="required",updated_at:a};s==="not_required"&&(r.status="not_required"),s==="waived"&&(r.status="waived",r.waived_at=a,r.waived_by=n);const{error:i}=await O.from("admissions_requirements").update(r).eq("id",t);if(i)throw i}async function tue(t,s,n){const a=new Date().toISOString();await O.from("admissions_requirements").update({status:"accepted",satisfied_source:"admissions_applicants",external_reference:t,submitted_at:s.submitted_at||a,reviewed_at:a,reviewed_by:n,decision_reason:null,updated_at:a}).eq("id",s.id)}async function sue(t){const s=String(t||"").toLowerCase().trim();if(!s)return null;const{data:n}=await O.from("disclosure_acknowledgements").select("acknowledged_at,
1303statement_version").ilike("student_email",s).order("acknowledged_at",{ascending:!1}).limit(1);if(n&&n.length)return{source:"disclosure_acknowledgements",acknowledgedAt:n[0].acknowledged_at,version:n[0].statement_version||null};const{data:a}=await O.from("compliance_acknowledgements").select("signature_date").ilike("student_email",s).order("signature_date",{ascending:!1}).limit(1);return a&&a.length?{source:"compliance_acknowledgements",acknowledgedAt:a[0].signature_date}:null}async function nue(t,s,n){const a=new Date().toISOString();await O.from("admissions_requirements").update({status:"accepted",satisfied_source:s.source,external_reference:s.acknowledgedAt,submitted_at:s.acknowledgedAt,reviewed_at:a,reviewed_by:n,updated_at:a}).eq("id",t.id)}const Y$=[{key:"goals",label:"Why are you pursuing this program?",helper:"Tell us in your own words what drew you to this profession.",minLength:80,rows:5},{key:"career_vision",label:"What do you want your professional life to look like after licensure?",helper:"The setting, the clients or the specialty you picture yourself in.",minLength:60,rows:4},{key:"preparation",label:"How will you prepare for the attendance and academic expectations of the program?",helper:"Schedule, transportation, support system, study plan.",minLength:60,rows:4},{key:"anything_else",label:"Anything else Admissions should know? (optional)",rows:3}];async function aue(t){const{data:s,error:n}=await O.from("admissions_letters_of_intent").select("*").eq("applicant_id",t).maybeSingle();if(n)throw n;return s||null}async function rue(t,s,n,a){const r=new Date().toISOString();if(await O.from("admissions_letters_of_intent").update({status:s,reviewed_at:r,reviewed_by:n,review_reason:a||null,updated_at:r}).eq("id",t.id),t.requirement_id){const i=s==="accepted"?"accepted":s==="rejected"?"rejected":s==="needs_correction"?"needs_correction":"under_review";await O.from("admissions_requirements").update({status:i,satisfied_source:"admissions_letters_of_intent",external_reference:t.id,reviewed_at:r,reviewed_by:n,decision_reason:a||null,updated_at:r}).eq("id",t.requirement_id)}}const K$=[{key:"availability",label:"Which days and times generally work best for you?",rows:2},{key:"motivation",label:"What are you hoping to get out of your admissions interview?",rows:3},{key:"questions",label:"What questions do you have for the Admissions team?",rows:3},{key:"support_needs",label:"Is there anything we should know to support you during the interview? (optional)",rows:2}],iue=[{key:"goals_understanding",label:"Understanding of the profession and program expectations",rows:3},{key:"attendance_readiness",label:"Attendance, schedule and transportation readiness",rows:3},{key:"financial_awareness",label:"Awareness of tuition obligations and the funding conversation still to come",rows:3},{key:"professionalism",label:"Professionalism, communication and clinic-floor readiness",rows:3}],oue=["scheduled","completed","follow_up_required","complete"],R4={scheduled:"Scheduled",completed:"Completed",follow_up_required:"Follow-up Required",complete:"Complete"},lue=["in_person","phone","video","other"],cue={in_person:"In person",phone:"Phone",video:"Video",other:"Other"};async function due(t){const{data:s,error:n}=await O.from("admissions_interviews").select("*").eq("applicant_id",t).maybeSingle();if(n)throw n;return s||null}async function uue(t,s,n,a){const r=new Date().toISOString(),i=n.outcome==="complete"||n.outcome==="completed",o={applicant_id:t,requirement_id:n.requirementId||(s==null?void 0:s.requirement_id)||null,scheduled_at:n.scheduled_at||null,interviewer:n.interviewer||a,interview_method:n.interview_method||null,staff_responses:n.staff_responses||{},staff_notes:n.staff_notes||null,outcome:n.outcome,recommendation:n.recommendation||null,follow_up_required:n.outcome==="follow_up_required"?!0:!!n.follow_up_required,follow_up_note:n.follow_up_note||null,completed_at:i?(s==null?void 0:s.completed_at)||r:null,recorded_by:a,updated_at:r};let l;if(s){const{data:u,error:p}=await O.from("admissions_interviews").update(o).eq("id",s.id).select("*").single();if(p)throw p;l=u}else{const{data:u,error:p}=await O.from("admissions_interviews").insert(o).select("*").single();if(p)throw p;l=u}const c=o.requirement_id;if(c){const u=n.outcome==="complete"?"accepted":n.outcome==="completed"?"under_review":n.outcome==="follow_up_required"?"needs_correction":"requested";await O.from("admissions_requirements").update({status:u,satisfied_source:"admissions_interviews",external_reference:l.id,requested_at:n.scheduled_at||r,submitted_at:i?r:null,reviewed_at:i?r:null,reviewed_by:a,decision_reason:n.outcome==="follow_up_required"?n.follow_up_note||"Follow-up required":null,updated_at:r}).eq("id",c)}return l}function Q$(t){const s=t.map(l=>({row:l,applicability:l.applicability||(l.is_required?"required":"not_required")})),n=s.filter(l=>l.applicability==="required"),a=n.filter(l=>Bm(l.row.status)),r=n.filter(l=>!Bm(l.row.status)).map(l=>l.row),i=s.filter(l=>l.applicability==="needs_configuration").map(l=>l.row),o=n.length>0&&r.length===0&&i.length===0;return{requiredTotal:n.length,requiredSatisfied:a.length,outstanding:r,needsConfiguration:i,complete:o,label:`${a.length} of ${n.length} Complete`}}const mue={complete:"Complete",action_needed:"Action Needed",under_review:"Submitted / Under Review",needs_correction:"Needs Correction",not_available:"Not Yet Available"},pue={complete:{bg:"#DCFCE7",fg:"#166534"},action_needed:{bg:"#FEF9C3",fg:"#854D0E"},under_review:{bg:"#E0E7FF",fg:"#3730A3"},needs_correction:{bg:"#FEF3C7",fg:"#92400E"},not_available:{bg:"#F3F4F6",fg:"#6B7280"}};function hue(t,s){return Bm(t.status)?"complete":t.status==="needs_correction"||t.status==="rejected"?"needs_correction":t.status==="submitted"||t.status==="under_review"?"under_review":s.applicantActionable?"action_needed":"not_available"}const Rc="#B8962E",Wp=t=>
1303t?new Date(t).toLocaleString(void 0,{dateStyle:"medium",timeStyle:"short"}):"â",xue=t=>{if(!t)return"";const s=new Date(t),n=a=>String(a).padStart(2,"0");return`${s.getFullYear()}-${n(s.getMonth()+1)}-${n(s.getDate())}T${n(s.getHours())}:${n(s.getMinutes())}`},fue=({applicantId:t,requirements:s,actor:n,onRequirementsChanged:a})=>{const[r,i]=d.useState(null),[o,l]=d.useState(null),[c,u]=d.useState(!0),[p,m]=d.useState(null),[x,h]=d.useState(null),[y,v]=d.useState(""),[g,N]=d.useState(""),[b,f]=d.useState("in_person"),[j,S]=d.useState({}),[w,_]=d.useState(""),[C,E]=d.useState(""),[P,F]=d.useState("scheduled"),[I,D]=d.useState(""),L=s.find(T=>T.requirement_key==="letter_of_intent"),V=s.find(T=>T.requirement_key==="admissions_interview"),B=d.useCallback(async()=>{u(!0),h(null);try{const[T,U]=await Promise.all([aue(t),due(t)]);i(T),l(U),U&&(v(xue(U.scheduled_at)),N(U.interviewer||""),f(U.interview_method||"in_person"),S(U.staff_responses||{}),_(U.staff_notes||""),E(U.recommendation||""),F(U.outcome),D(U.follow_up_note||""))}catch(T){h(T.message)}finally{u(!1)}},[t]);d.useEffect(()=>{B()},[B]);const A=async T=>{if(r){m("letter"),h(null);try{let U;if(T!=="accepted"&&(U=window.prompt("Correction / rejection reason returned to the applicant:")||void 0,!U)){m(null);return}await rue({...r,requirement_id:r.requirement_id||(L==null?void 0:L.id)||null},T,n,U),await B(),a()}catch(U){h(U.message)}finally{m(null)}}},z=async()=>{m("interview"),h(null);try{const T=await uue(t,o,{requirementId:(V==null?void 0:V.id)||null,scheduled_at:y?new Date(y).toISOString():null,interviewer:g.trim()||n,interview_method:b,staff_responses:j,staff_notes:w.trim()||null,outcome:P,recommendation:C.trim()||null,follow_up_note:I.trim()||null},n);l(T),a()}catch(T){h(T.message)}finally{m(null)}},M="w-full px-2 py-1.5 rounded-md text-[10.5px] bg-white",R={border:`1px solid ${k}22`,color:k};return e.jsxs("div",{className:"space-y-3",children:[x&&e.jsx("p",{className:"text-[11px] px-2 py-1.5 rounded",style:{background:"#FEF2F2",color:"#991B1B"},children:x}),e.jsxs("div",{className:"rounded-lg p-2.5",style:{background:"#fff",border:`1px solid ${k}12`},children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2 mb-1.5",children:[e.jsx(Tm,{size:13,style:{color:Rc}}),e.jsx("span",{className:"text-[10.5px] font-bold uppercase tracking-[0.16em]",style:{color:k},children:"Letter of Intent"}),e.jsx("span",{className:"px-1.5 py-0.5 rounded text-[9px] font-bold uppercase",style:{background:`${k}0D`,color:k},children:c?"Loadingâ¦":r?r.status.replace(/_/g," "):"Not started"})]}),!c&&!r&&e.jsx("p",{className:"text-[10px]",style:{color:"#8a8a8a"},children:"The applicant has not opened the electronic Letter of Intent yet. It becomes available in their portal as soon as the requirement is requested."}),r&&e.jsxs(e.Fragment,{children:[e.jsxs("p",{className:"text-[9.5px] mb-1.5",style:{color:"#999"},children:["Saved ",Wp(r.saved_at)," · Submitted ",Wp(r.submitted_at),r.reviewed_at?` · Reviewed ${Wp(r.reviewed_at)} by ${r.reviewed_by||"â"}`:"",r.review_reason?` · Reason: ${r.review_reason}`:""]}),e.jsx("div",{className:"space-y-1.5",children:Y$.map(T=>{var U;return e.jsxs("div",{className:"px-2 py-1.5 rounded",style:{background:`${k}05`},children:[e.jsx("p",{className:"text-[9.5px] font-bold",style:{color:Rc},children:T.label}),e.jsx("p",{className:"text-[10.5px] whitespace-pre-wrap",style:{color:k},children:((U=r.responses)==null?void 0:U[T.key])||e.jsx("span",{style:{color:"#aaa"},children:"â not answered â"})})]},T.key)})}),r.status!=="draft"&&e.jsxs("div",{className:"flex flex-wrap gap-1.5 mt-2",children:[e.jsx("button",{onClick:()=>void A("accepted"),disabled:p==="letter",className:"px-2 py-0.5 rounded text-[9.5px] font-bold disabled:opacity-50",style:{background:"#DCFCE7",color:"#166534"},children:"Accept"}),e.jsx("button",{onClick:()=>void A("needs_correction"),disabled:p==="letter",className:"px-2 py-0.5 rounded text-[9.5px] font-bold disabled:opacity-50",style:{background:"#FEF3C7",color:"#92400E"},children:"Needs correction"}),e.jsx("button",{onClick:()=>void A("rejected"),disabled:p==="letter",className:"px-2 py-0.5 rounded text-[9.5px] font-bold disabled:opacity-50",style:{background:"#FEE2E2",color:"#991B1B"},children:"Reject"})]})]})]}),e.jsxs("div",{className:"rounded-lg p-2.5",style:{background:"#fff",border:`1px solid ${k}12`},children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2 mb-2",children:[e.jsx(jr,{size:13,style:{color:Rc}}),e.jsx("span",{className:"text-[10.5px] font-bold uppercase tracking-[0.16em]",style:{color:k},children:"Admissions Interview"}),e.jsx("span",{className:"px-1.5 py-0.5 rounded text-[9px] font-bold uppercase",style:{background:`${k}0D`,color:k},children:R4[(o==null?void 0:o.outcome)||"scheduled"]})]}),(o==null?void 0:o.prep_submitted_at)&&e.jsxs("div",{className:"rounded px-2 py-1.5 mb-2",style:{background:`${$}14`},children:[e.jsxs("p",{className:"text-[9.5px] font-bold mb-1",style:{color:Rc},children:["Applicant preparation · submitted ",Wp(o.prep_submitted_at)]}),K$.map(T=>{var U;return e.jsxs("p",{className:"text-[10px] mb-0.5",style:{color:k},children:[e.jsx("strong",{children:T.label})," ",((U=o.prep_responses)==null?void 0:U[T.key])||"â"]}
1303,T.key)})]}),e.jsxs("div",{className:"grid sm:grid-cols-3 gap-1.5 mb-2",children:[e.jsxs("label",{className:"block",children:[e.jsx("span",{className:"text-[9px] uppercase font-bold",style:{color:"#999"},children:"Date & time"}),e.jsx("input",{type:"datetime-local",value:y,onChange:T=>v(T.target.value),className:M,style:R})]}),e.jsxs("label",{className:"block",children:[e.jsx("span",{className:"text-[9px] uppercase font-bold",style:{color:"#999"},children:"Interviewer"}),e.jsx("input",{value:g,onChange:T=>N(T.target.value),placeholder:n,className:M,style:R})]}),e.jsxs("label",{className:"block",children:[e.jsx("span",{className:"text-[9px] uppercase font-bold",style:{color:"#999"},children:"Method"}),e.jsx("select",{value:b,onChange:T=>f(T.target.value),className:M,style:R,children:lue.map(T=>e.jsx("option",{value:T,children:cue[T]},T))})]})]}),e.jsxs("div",{className:"space-y-1.5 mb-2",children:[iue.map(T=>e.jsxs("label",{className:"block",children:[e.jsx("span",{className:"text-[9.5px] font-bold",style:{color:Rc},children:T.label}),e.jsx("textarea",{rows:T.rows||2,value:j[T.key]||"",onChange:U=>S(q=>({...q,[T.key]:U.target.value})),className:M,style:R})]},T.key)),e.jsxs("label",{className:"block",children:[e.jsx("span",{className:"text-[9.5px] font-bold",style:{color:Rc},children:"Staff notes"}),e.jsx("textarea",{rows:2,value:w,onChange:T=>_(T.target.value),className:M,style:R})]}),e.jsxs("label",{className:"block",children:[e.jsx("span",{className:"text-[9.5px] font-bold",style:{color:Rc},children:"Recommendation (operational, not a decision)"}),e.jsx("textarea",{rows:2,value:C,onChange:T=>E(T.target.value),className:M,style:R})]})]}),e.jsxs("div",{className:"flex flex-wrap items-end gap-1.5",children:[e.jsxs("label",{className:"block",children:[e.jsx("span",{className:"text-[9px] uppercase font-bold",style:{color:"#999"},children:"Outcome"}),e.jsx("select",{value:P,onChange:T=>F(T.target.value),className:"px-2 py-1.5 rounded-md text-[10.5px] bg-white",style:R,children:oue.map(T=>e.jsx("option",{value:T,children:R4[T]},T))})]}),P==="follow_up_required"&&e.jsx("input",{value:I,onChange:T=>D(T.target.value),placeholder:"What follow-up is needed? (shown to the applicant)",className:"flex-1 min-w-[180px] px-2 py-1.5 rounded-md text-[10.5px] bg-white",style:R}),e.jsxs("button",{onClick:()=>void z(),disabled:p==="interview",className:"inline-flex items-center gap-1.5 px-3 py-1.5 rounded-md text-[10.5px] font-bold disabled:opacity-50",style:{background:k,color:$},children:[p==="interview"?e.jsx(de,{size:10,className:"animate-spin"}):e.jsx(ti,{size:10}),"Save interview record"]})]}),e.jsxs("p",{className:"text-[9px] mt-1.5 flex items-start gap-1",style:{color:"#999"},children:[e.jsx(_a,{size:9,style:{marginTop:2}}),"Stored on ",e.jsx("span",{className:"font-mono",children:"admissions_interviews"})," for this application. Marking the outcome Complete satisfies the interview requirement â it never accepts or enrols the applicant.",o!=null&&o.completed_at?` Completed ${Wp(o.completed_at)} by ${o.recorded_by||"â"}.`:""]})]})]})},gue="enrollment-agreement",I4={draft:"Draft",prepared:"Ready to Issue",issued:"Issued",applicant_signed:"Institutional Signature Pending",institution_signed:"Institution Signed",fully_executed:"Fully Executed",voided:"Voided",superseded:"Superseded"},yue={draft:{bg:"#F3F4F6",fg:"#6B7280"},prepared:{bg:"#E0E7FF",fg:"#3730A3"},issued:{bg:"#FEF9C3",fg:"#854D0E"},applicant_signed:{bg:"#DBEAFE",fg:"#1E40AF"},institution_signed:{bg:"#DBEAFE",fg:"#1E40AF"},fully_executed:{bg:"#DCFCE7",fg:"#166534"},voided:{bg:"#FEE2E2",fg:"#991B1B"},superseded:{bg:"#FEE2E2",fg:"#991B1B"}},bue="REQUIRES INSTITUTIONAL CONFIGURATION",FN=t=>String(t??"").toUpperCase().includes(bue),J$={program_clock_hours:"Program clock hours",campus:"Campus",prior_licensure_verification:"Prior licensure verification",scheduled_start_date:"Scheduled start date",expected_completion_date:"Expected completion date",tuition:"Tuition",registration_charge:"Registration / application charge",books_supplies_kit:"Books, supplies and kit",other_institutional_charges:"Other approved institutional charges",total_program_cost:"Total program cost",payment_funding_arrangement_reference:"Payment / funding arrangement",cancellation_refund_policy_reference:"Cancellation & refund policy",attendance_policy_reference:"Attendance policy",sap_policy_reference:"Satisfactory academic progress policy"};async function mc(t){const{data:s,error:n}=await O.functions.invoke(gue,{body:t});if(n&&!s)throw new Error(n.message||"Agreement service unavailable");if(!(s!=null&&s.success))throw new Error((s==null?void 0:s.error)||"Agreement request failed");return s}async function vue(t){const{data:s,error:n}=await O.from("admissions_enrollment_agreements").select("*").eq("applicant_id",t).order("created_at",{ascending:!1}).limit(1);if(n)throw n;return s&&s[0]||null}async function jue(t){const{data:s,error:n}=await O.from("admissions_agreement_events").select("id,event_type,from_state,to_state,actor_type,actor_ref,actor_role,detail,created_at").eq("agreement_id",t).order("created_at",{ascending:!1});if(n)throw n;return s||[]}async function wue(t){let s=O.from("admissions_agreement_templates").select("id,program_key,program_label,campus,version_number,version_label,effective_date,status,configuration_gaps").eq("status","active").order("version_number",{ascending:!1});t&&(s=s.eq("program_key",t));const{data:n,error:a}=await s;if(a)throw a;return n||[]}async function Nue(){const{data:t,error:s}=await O.from("admissions_agreement_signers").select("email,full_name,signer_role").eq("is_active",!0);if(s)throw s;return t||[]}const _ue=(t,s)=>mc({action:"staff-prepare",applicantId:t,...s}),kue=t=>mc({action:"staff-issue",agreementId:t}),Sue=t=>mc({action:"staff-countersign",agreementId:t}),$4=(t,s,n=!1)=>mc({action:"staff-void",agreementId:t,reason:s,supersede:n}),Cue=(t,s)=>mc({action:"render",agreementId:t,...s?{token:s}:{}}),X$=(t,s)=>mc({action:"document-url",agreementId:t,...s?{token:s}:{}});async function ez(t,s){const{html:n}=await Cue(t,s),a=window.open("","_blank","noopener,noreferrer,width=900,height=1000");if(!a)throw new Error("Allow pop-ups to open the agreement record.");a.document.open(),a.document.write(n),a.document.close()}const Aue=t=>mc({action:"applicant-agreement",token:t}),Eue=(t,s,n,a)=>mc({action:"applicant-sign",token:t,agreementId:s,signatureName:n,intent:!0,acknowledgements:a});function Fue(t){switch(t){case"issued":return"Issued â applicant action needed.";case"applicant_signed":case"institution_signed":return"Applicant signed â institutional signature pending.";case"fully_executed":return"Fully executed â requirement complete.";case"voided":return"Voided â no valid agreement on this application.";case"superseded":return"Superseded â prepare the replacement version.";case"prepared":case"draft":return"Prepared â not yet issued to the applicant.";default:return"Not prepared."}}const z4="#B8962E",ll=t=>
1303t?new Date(t).toLocaleString(void 0,{dateStyle:"medium",timeStyle:"short"}):"â",Tue=({applicantId:t,program:s,onChanged:n})=>{var P;const[a,r]=d.useState(null),[i,o]=d.useState([]),[l,c]=d.useState([]),[u,p]=d.useState([]),[m,x]=d.useState(""),[h,y]=d.useState(null),[v,g]=d.useState(null),[N,b]=d.useState(null),f=wk(s),j=d.useCallback(async()=>{var F;y("load"),g(null);try{const[I,D,L]=await Promise.all([vue(t),wue(f),Nue().catch(()=>[])]);r(I),c(D),p(L),x(((F=D[0])==null?void 0:F.id)||""),o(I?await jue(I.id):[])}catch(I){g(I.message)}finally{y(null)}},[t,f]);d.useEffect(()=>{j()},[j]);const S=async(F,I,D)=>{y(F),g(null),b(null);try{await I(),b(D),await j(),n==null||n()}catch(L){g(L.message)}finally{y(null)}},w=a==null?void 0:a.state,_=w?yue[w]:{bg:"#F3F4F6",fg:"#6B7280"},C=((P=a==null?void 0:a.snapshot)==null?void 0:P.structured_fields)||{},E=(a==null?void 0:a.configuration_gaps)||[];return e.jsxs("div",{className:"rounded-lg p-2.5",style:{background:"#fff",border:`1px solid ${k}14`},children:[e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2 mb-2",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Tm,{size:14,style:{color:z4}}),e.jsx("h5",{className:"text-[11px] font-bold uppercase tracking-[0.16em]",style:{color:k},children:"Enrollment Agreement"}),e.jsx("span",{className:"px-2 py-0.5 rounded text-[9.5px] font-bold uppercase tracking-wider",style:{background:_.bg,color:_.fg},children:w?I4[w]:"Not Prepared"})]}),e.jsxs("button",{onClick:()=>void j(),className:"inline-flex items-center gap-1 px-2 py-1 rounded-md text-[10px] font-bold",style:{color:k,border:`1px solid ${k}22`},children:[e.jsx(Be,{size:10})," Refresh"]})]}),v&&e.jsx("p",{className:"text-[10.5px] mb-2 px-2 py-1.5 rounded",style:{background:"#FEF2F2",color:"#991B1B"},children:v}),N&&e.jsx("p",{className:"text-[10.5px] mb-2 px-2 py-1.5 rounded",style:{background:"#ECFDF5",color:"#065F46"},children:N}),!a&&e.jsxs("div",{className:"flex flex-wrap items-end gap-2",children:[e.jsxs("div",{className:"flex-1 min-w-[200px]",children:[e.jsx("label",{className:"block text-[9.5px] font-bold uppercase tracking-wider mb-1",style:{color:"#8a8a8a"},children:"Agreement version (program template)"}),e.jsxs("select",{value:m,onChange:F=>x(F.target.value),className:"w-full px-2 py-1 rounded-md text-[10.5px] bg-white",style:{border:`1px solid ${k}22`,color:k},children:[l.length===0&&e.jsxs("option",{value:"",children:["No active version for ",f]}),l.map(F=>e.jsxs("option",{value:F.id,children:[F.version_label," · v",F.version_number," · ",F.program_label," · ",F.campus," · effective ",F.effective_date]},F.id))]})]}),e.jsxs("button",{onClick:()=>void S("prepare",()=>_ue(t,m?{templateId:m}:{programKey:f}),"Agreement prepared against an immutable version snapshot."),disabled:h==="prepare"||l.length===0,className:"inline-flex items-center gap-1.5 px-3 py-1.5 rounded-md text-[10.5px] font-bold disabled:opacity-50",style:{background:k,color:$},children:[h==="prepare"?e.jsx(de,{size:10,className:"animate-spin"}):e.jsx(Tm,{size:10})," Prepare"]})]}),a&&e.jsxs(e.Fragment,{children:[e.jsxs("p",{className:"text-[9.5px] mb-1.5",style:{color:"#8a8a8a"},children:["Version ",e.jsx("strong",{children:a.template_version_label})," (v",a.template_version_number,") ·"," ",a.program_label," · ",a.campus," · prepared ",ll(a.prepared_at),a.issued_at?` · issued ${ll(a.issued_at)}`:"",a.applicant_signed_at?` · applicant signed ${ll(a.applicant_signed_at)}`:"",a.executed_at?` · executed ${ll(a.executed_at)}`:""]}),e.jsxs("p",{className:"text-[9.5px] mb-2",style:{color:"#8a8a8a"},children:["Requirement: ",Fue(a.state),a.snapshot_hash?` · snapshot digest ${a.snapshot_hash.slice(0,12)}â¦`:""]}),e.jsxs("div",{className:"rounded-md px-2 py-1.5 mb-2",style:{background:`${k}05`},children:[Object.keys(C).map(F=>e.jsxs("p",{className:"text-[10px]",style:{color:FN(C[F])?"#92400E":k},children:[e.jsxs("span",{style:{color:"#8a8a8a"},children:[J$[F]||F,":"]})," ",e.jsx("strong",{children:String(C[F]??"â")})]},F)),E.length>0&&e.jsxs("p",{className:"text-[9.5px] mt-1",style:{color:"#92400E"},children:[E.length," field(s) require institutional configuration. Values were deliberately not guessed."]})]}),a.applicant_signature_name&&e.jsxs("p",{className:"text-[10px] mb-2 px-2 py-1.5 rounded",style:{background:"#F8FAFC",color:k},children:["Applicant signature: ",e.jsx("strong",{children:a.applicant_signature_name}
1303)," · intent acknowledged ·"," ",ll(a.applicant_signed_at),a.institution_signer_name?` · Institutional signer: ${a.institution_signer_name} (${a.institution_signer_role}) · ${ll(a.institution_signed_at)}`:""]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-1.5",children:[(a.state==="prepared"||a.state==="draft")&&e.jsx("button",{onClick:()=>void S("issue",()=>kue(a.id),"Issued to the applicant portal. No message was sent."),disabled:h==="issue",className:"px-2.5 py-1 rounded text-[10px] font-bold disabled:opacity-50",style:{background:k,color:$},children:h==="issue"?"Issuingâ¦":"Issue to applicant"}),e.jsx("button",{onClick:()=>void S("view",()=>ez(a.id),"Agreement record opened."),disabled:h==="view",className:"px-2.5 py-1 rounded text-[10px] font-bold disabled:opacity-50",style:{background:"#E0E7FF",color:"#3730A3"},children:"View / print record"}),a.state==="applicant_signed"&&e.jsxs("button",{onClick:()=>void S("sign",()=>Sue(a.id),"Institutional signature recorded â agreement fully executed. No enrollment, provisioning, aid or payment action was taken."),disabled:h==="sign",className:"inline-flex items-center gap-1 px-2.5 py-1 rounded text-[10px] font-bold disabled:opacity-50",style:{background:"#DCFCE7",color:"#166534"},children:[e.jsx(Ie,{size:10})," ",h==="sign"?"Signingâ¦":"Countersign (authorized signatory)"]}),a.state==="fully_executed"&&e.jsxs("button",{onClick:()=>void S("doc",async()=>{const{url:F}=await X$(a.id);window.open(F,"_blank","noopener,noreferrer")},"Short-lived signed URL issued (120 seconds)."),disabled:h==="doc",className:"inline-flex items-center gap-1 px-2.5 py-1 rounded text-[10px] font-bold disabled:opacity-50",style:{background:`${$}22`,color:z4},children:[e.jsx(Xe,{size:10})," Open executed record securely"]}),!["voided","superseded"].includes(a.state)&&e.jsxs(e.Fragment,{children:[e.jsx("button",{onClick:()=>{const F=window.prompt("Reason for voiding this agreement (kept in audit history):")||"";F.trim()&&S("void",()=>$4(a.id,F.trim(),!1),"Agreement voided; audit history preserved.")},disabled:h==="void",className:"px-2.5 py-1 rounded text-[10px] font-bold disabled:opacity-50",style:{background:"#FEE2E2",color:"#991B1B"},children:"Void"}),e.jsx("button",{onClick:()=>{const F=window.prompt("Reason for superseding this agreement (a new version must then be prepared):")||"";F.trim()&&S("sup",()=>$4(a.id,F.trim(),!0),"Agreement superseded; audit history preserved.")},disabled:h==="sup",className:"px-2.5 py-1 rounded text-[10px] font-bold disabled:opacity-50",style:{background:"#FEF3C7",color:"#92400E"},children:"Supersede"})]})]}),a.void_reason&&e.jsxs("p",{className:"text-[9.5px] mt-1.5",style:{color:"#991B1B"},children:[I4[a.state]," · ",a.void_reason," · ",a.voided_by," · ",ll(a.voided_at)]}),i.length>0&&e.jsx("div",{className:"mt-2 space-y-0.5",children:i.slice(0,5).map(F=>e.jsxs("p",{className:"text-[9px]",style:{color:"#888"},children:[ll(F.created_at)," · ",F.event_type,F.from_state?` · ${F.from_state} â ${F.to_state}`:""," · ",F.actor_type,F.actor_type==="staff"&&F.actor_ref?` ${F.actor_ref}`:""]},F.id))})]}),e.jsxs("p",{className:"text-[9px] mt-2",style:{color:"#9CA3AF"},children:[u.length===0?"Countersignature REQUIRES INSTITUTIONAL CONFIGURATION â no authorized institutional signatory is configured yet, and it is deliberately not granted to general staff roles.":`${u.length} authorized institutional signatory configured. Ordinary staff cannot countersign.`," ","Financial Plan remains a separate, not-yet-built requirement. LEGAL/COMPLIANCE SUFFICIENCY REQUIRES VALIDATION."]})]})},Pue="financial-plan",Due="PROGRAM COST REQUIRES RECONCILIATION",Rue={draft:"In Preparation",waiting_on_funding:"Waiting on Funding",issued:"Ready for Applicant Review",acknowledged:"Applicant Acknowledged",revision_required:"Revision Required",complete:"Complete"},Iue={draft:{bg:"#F3F4F6",fg:"#6B7280"},waiting_on_funding:{bg:"#FEF3C7",fg:"#92400E"},issued:{bg:"#FEF9C3",fg:"#854D0E"},acknowledged:{bg:"#DBEAFE",fg:"#1E40AF"},revision_required:{bg:"#FEE2E2",fg:"#991B1B"},complete:{bg:"#DCFCE7",fg:"#166534"}},$ue={draft:"Financial Plan in Preparation",waiting_on_funding:"Financial Plan in Preparation",issued:"Review Financial Plan",acknowledged:"Acknowledged â Institute Review",revision_required:"Action Needed",complete:"Complete"},TN=[{key:"federal_grant",label:"Federal Grant",note:"Displayed from the Financial Aid workflow only â never calculated here."},{key:"federal_loan",label:"Federal Student Loan",note:"Displayed only â no eligibility, packaging or origination happens here."},{key:"parent_plus",label:"Parent PLUS",note:"Never assumed approved. Status must come from the Financial Aid workflow."},{key:"va_benefits",label:"VA Education Benefits"}
1303,{key:"workforce_funding",label:"Workforce Funding"},{key:"foundation_scholarship",label:"Zorganics Foundation Scholarship",note:"Never auto-awarded â human approval required."},{key:"other_scholarship",label:"Other Scholarship"},{key:"institutional_payment_plan",label:"Institutional Payment Plan",note:"Planning record only â no charges, no installments invented."},{key:"student_family_payment",label:"Student / Family Payment"},{key:"other_approved",label:"Other Approved Funding Source"}],zue=t=>{var s;return((s=TN.find(n=>n.key===t))==null?void 0:s.label)||t},Lue=["exploring","application_needed","applied","pending","estimated","confirmed","declined","not_applicable"],PN={exploring:"Exploring",application_needed:"Application Required",applied:"Applied",pending:"Pending",estimated:"Estimated",confirmed:"Confirmed",declined:"Declined",not_applicable:"Not Applicable"},db={exploring:{bg:"#F3F4F6",fg:"#6B7280"},application_needed:{bg:"#FEF3C7",fg:"#92400E"},applied:{bg:"#E0E7FF",fg:"#3730A3"},pending:{bg:"#FEF9C3",fg:"#854D0E"},estimated:{bg:"#EDE9FE",fg:"#5B21B6"},confirmed:{bg:"#DCFCE7",fg:"#166534"},declined:{bg:"#FEE2E2",fg:"#991B1B"},not_applicable:{bg:"#F3F4F6",fg:"#9CA3AF"}},tz=t=>t==="confirmed",L4=t=>["exploring","application_needed","applied","pending","estimated"].includes(t),sz=(t,s)=>{const n=(s||[]).filter(o=>o.status!=="declined"&&o.status!=="not_applicable"),a=n.filter(o=>tz(o.status)).reduce((o,l)=>o+(Number(l.amount_cents)||0),0),r=n.filter(o=>L4(o.status)).reduce((o,l)=>o+(Number(l.amount_cents)||0),0),i=typeof t=="number"?t:null;return{totalProgramCostCents:i,confirmedFundingCents:a,potentialFundingCents:r,currentConfirmedResponsibilityCents:i===null?null:i-a,projectedResponsibilityCents:i===null?null:i-a-r,hasPending:r>0||n.some(o=>L4(o.status))}},Ia=t=>t==null?"â":`${t<0?"-":""}$${(Math.abs(t)/100).toLocaleString("en-US",{minimumFractionDigits:2,maximumFractionDigits:2})}`;function Oue(t){switch(t){case"draft":return"In preparation â not yet released to the applicant.";case"waiting_on_funding":return"Waiting on funding information before it can be issued.";case"issued":return"Issued â applicant review and acknowledgement needed.";case"acknowledged":return"Applicant acknowledged â staff completion still required.";case"revision_required":return"Revision required â a new plan version must be issued.";case"complete":return"Complete â requirement satisfied through the authoritative workflow.";default:return"Not started."}}async function Hd(t){const{data:s,error:n}=await O.functions.invoke(Pue,{body:t});if(n&&!s)throw new Error(n.message||"Financial plan service unavailable");if(!(s!=null&&s.success))throw new Error((s==null?void 0:s.error)||"Financial plan request failed");return s}async function Mue(t){const{data:s,error:n}=await O.from("admissions_financial_plans").select("*").eq("applicant_id",t).maybeSingle();if(n)throw n;return s||null}async function Bue(t){const{data:s,error:n}=await O.from("admissions_financial_plan_versions").select("id,version,state_at_snapshot,snapshot_hash,acknowledgement_version_label,acknowledged_name,acknowledged_at,reason,created_by,created_at").eq("plan_id",t).order("version",{ascending:!1});if(n)throw n;return s||[]}async function Uue(){const{data:t,error:s}=await O.from("admissions_financial_ack_versions").select("id,version_label,version_number,title,statements,requires_policy_review,policy_note").eq("status","active").order("version_number",{ascending:!1}).limit(1);if(s)throw s;return t&&t[0]||null}const que=t=>Hd({action:"staff-prepare",applicantId:t}),O4=(t,s)=>Hd({action:"staff-save",planId:t,patch:s}),Wue=t=>Hd({action:"staff-issue",planId:t}),Hue=(t,s)=>Hd({action:"staff-revise",planId:t,reason:s}),Gue=t=>Hd({action:"staff-complete",planId:t}),Vue=t=>Hd({action:"applicant-plan",token:t}),Zue=(t,s,n,a)=>Hd({action:"applicant-acknowledge",token:t,planId:s,signatureName:n,intent:!0,statements:a}),qj="#B8962E",Hp=t=>t?new Date(t).toLocaleString(void 0,{dateStyle:"medium",timeStyle:"short"}):"â",Wj=[{key:"tuition_cents",label:"Tuition"},{key:"books_cents",label:"Books"},{key:"materials_cents",label:"Materials / Supplies / Lab"},{key:"fees_cents",label:"Approved fees"},{key:"other_charges_cents",label:"Other approved charges"}],yu=t=>t==null?"":(t/100).toFixed(2),cl=t=>t.trim()===""?null:Math.round(Number(t)*100),Yue=({applicantId:t,onChanged:s})=>
1303{const[n,a]=d.useState(null),[r,i]=d.useState([]),[o,l]=d.useState(null),[c,u]=d.useState({}),[p,m]=d.useState([]),[x,h]=d.useState(""),[y,v]=d.useState("federal_grant"),[g,N]=d.useState(null),[b,f]=d.useState(null),[j,S]=d.useState(null),w=L=>{a(L),m((L==null?void 0:L.funding_sources)||[]),h((L==null?void 0:L.applicant_summary_note)||""),u({tuition_cents:yu(L==null?void 0:L.tuition_cents),books_cents:yu(L==null?void 0:L.books_cents),materials_cents:yu(L==null?void 0:L.materials_cents),fees_cents:yu(L==null?void 0:L.fees_cents),other_charges_cents:yu(L==null?void 0:L.other_charges_cents)})},_=d.useCallback(async()=>{N("load"),f(null);try{const L=await Mue(t);w(L),l(await Uue().catch(()=>null)),i(L?await Bue(L.id):[])}catch(L){f(L.message)}finally{N(null)}},[t]);d.useEffect(()=>{_()},[_]);const C=async(L,V,B)=>{N(L),f(null),S(null);try{await V(),S(B),await _(),s==null||s()}catch(A){f(A.message)}finally{N(null)}},E=!!(n&&["draft","waiting_on_funding","revision_required"].includes(n.state)),P=n?Iue[n.state]:{bg:"#F3F4F6",fg:"#6B7280"},F=Wj.map(L=>cl(c[L.key]??"")).some(L=>L!==null)?Wj.reduce((L,V)=>L+(cl(c[V.key]??"")||0),0):null,I=sz(E?F:(n==null?void 0:n.total_program_cost_cents)??null,p),D=()=>C("save",()=>O4(n.id,{tuition_cents:cl(c.tuition_cents??""),books_cents:cl(c.books_cents??""),materials_cents:cl(c.materials_cents??""),fees_cents:cl(c.fees_cents??""),other_charges_cents:cl(c.other_charges_cents??""),funding_sources:p,applicant_summary_note:x}),"Draft saved. No aid, payment or enrollment action was taken.");return e.jsxs("div",{className:"rounded-lg p-2.5",style:{background:"#fff",border:`1px solid ${k}14`},children:[e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2 mb-2",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(ky,{size:14,style:{color:qj}}),e.jsx("h5",{className:"text-[11px] font-bold uppercase tracking-[0.16em]",style:{color:k},children:"Financial Plan"}),e.jsx("span",{className:"px-2 py-0.5 rounded text-[9.5px] font-bold uppercase tracking-wider",style:{background:P.bg,color:P.fg},children:n?Rue[n.state]:"Not Started"})]}),e.jsxs("button",{onClick:()=>void _(),className:"inline-flex items-center gap-1 px-2 py-1 rounded-md text-[10px] font-bold",style:{color:k,border:`1px solid ${k}22`},children:[e.jsx(Be,{size:10})," Refresh"]})]}),b&&e.jsx("p",{className:"text-[10.5px] mb-2 px-2 py-1.5 rounded",style:{background:"#FEF2F2",color:"#991B1B"},children:b}),j&&e.jsx("p",{className:"text-[10.5px] mb-2 px-2 py-1.5 rounded",style:{background:"#ECFDF5",color:"#065F46"},children:j}),!n&&e.jsxs("button",{onClick:()=>void C("prepare",()=>que(t),"Financial Plan prepared from authoritative program-cost sources only."),disabled:g==="prepare",className:"inline-flex items-center gap-1.5 px-3 py-1.5 rounded-md text-[10.5px] font-bold disabled:opacity-50",style:{background:k,color:$},children:[g==="prepare"?e.jsx(de,{size:10,className:"animate-spin"}):e.jsx(ky,{size:10})," Prepare Financial Plan"]}),n&&e.jsxs(e.Fragment,{children:[e.jsxs("p",{className:"text-[9.5px] mb-2",style:{color:"#8a8a8a"},children:["Version ",n.version," · prepared ",Hp(n.prepared_at),n.issued_at?` · issued ${Hp(n.issued_at)}`:"",n.acknowledged_at?` · acknowledged ${Hp(n.acknowledged_at)} by ${n.acknowledged_name} (${n.acknowledgement_version_label})`:"",n.completed_at?` · completed ${Hp(n.completed_at)}`:""," · ","Requirement: ",Oue(n.state)]}),n.cost_conflicts.length>0&&e.jsxs("p",{className:"text-[10px] mb-2 px-2 py-1.5 rounded",style:{background:"#FFFBEB",color:"#92400E"},children:[e.jsx("strong",{children:Due})," â ",n.cost_conflicts.join(" ")," Conflicts are staff-only and are never shown in the applicant view."]}),e.jsxs("div",{className:"rounded-md px-2 py-2 mb-2",style:{background:`${k}05`},children:[e.jsx("p",{className:"text-[9.5px] font-bold uppercase tracking-wider mb-1",style:{color:qj},children:"Program cost"}),e.jsx("div",{className:"grid grid-cols-2 md:grid-cols-5 gap-1.5",children:Wj.map(L=>e.jsxs("label",{className:"block",children:[e.jsx("span",{className:"text-[9px]",style:{color:"#8a8a8a"},children:L.label}),e.jsx("input",{value:c[L.key]??"",onChange:V=>u(B=>({...B,[L.key]:V.target.value})),disabled:!E,inputMode:"decimal",placeholder:"â",className:"w-full px-2 py-1 rounded text-[10.5px] bg-white disabled:opacity-60",style:{border:`1px solid ${k}22`,color:k}})]},L.key))}),e.jsxs("p",{className:"text-[10.5px] mt-1.5 font-bold",style:{color:k},children:["TOTAL PROGRAM COST: ",Ia(E?F:n.total_program_cost_cents)]}
1303),e.jsxs("p",{className:"text-[9px]",style:{color:"#9CA3AF"},children:["Sources consulted: ",(n.cost_sources||[]).map(L=>L.label||L.source).join(" · ")||"â"," · values are never guessed."]})]}),e.jsxs("div",{className:"rounded-md px-2 py-2 mb-2",style:{background:`${k}05`},children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-1.5 mb-1.5",children:[e.jsx("p",{className:"text-[9.5px] font-bold uppercase tracking-wider flex-1",style:{color:qj},children:"Funding sources (applicable only)"}),E&&e.jsxs(e.Fragment,{children:[e.jsx("select",{value:y,onChange:L=>v(L.target.value),className:"px-2 py-1 rounded text-[10px] bg-white",style:{border:`1px solid ${k}22`,color:k},children:TN.map(L=>e.jsx("option",{value:L.key,children:L.label},L.key))}),e.jsx("button",{onClick:()=>m(L=>[...L,{key:`${y}_${L.length}_${Date.now().toString(36)}`,kind:y,status:"exploring",amount_cents:null}]),className:"px-2 py-1 rounded text-[10px] font-bold",style:{background:k,color:$},children:"Add"})]})]}),p.length===0&&e.jsx("p",{className:"text-[10px]",style:{color:"#9CA3AF"},children:"No funding source added yet. Only sources that actually apply to this applicant should be added."}),p.map((L,V)=>{const B=TN.find(z=>z.key===L.kind),A=db[L.status]||db.exploring;return e.jsxs("div",{className:"flex flex-wrap items-center gap-1.5 py-1",style:{borderTop:`1px solid ${k}0D`},children:[e.jsx("span",{className:"text-[10.5px] font-semibold flex-1 min-w-[150px]",style:{color:k},children:(B==null?void 0:B.label)||L.kind}),e.jsx("span",{className:"px-1.5 py-0.5 rounded text-[9px] font-bold uppercase tracking-wider",style:{background:A.bg,color:A.fg},children:PN[L.status]}),e.jsx("select",{value:L.status,disabled:!E,onChange:z=>m(M=>M.map((R,T)=>T===V?{...R,status:z.target.value}:R)),className:"px-2 py-1 rounded text-[10px] bg-white disabled:opacity-60",style:{border:`1px solid ${k}22`,color:k},children:Lue.map(z=>e.jsx("option",{value:z,children:PN[z]},z))}),e.jsx("input",{value:yu(L.amount_cents),disabled:!E,inputMode:"decimal",placeholder:"Amount",onChange:z=>m(M=>M.map((R,T)=>T===V?{...R,amount_cents:cl(z.target.value)}:R)),className:"w-[92px] px-2 py-1 rounded text-[10px] bg-white disabled:opacity-60",style:{border:`1px solid ${k}22`,color:k}}),e.jsx("input",{value:L.source_note||"",disabled:!E,maxLength:200,placeholder:"Source note (optional)",onChange:z=>m(M=>M.map((R,T)=>T===V?{...R,source_note:z.target.value}:R)),className:"flex-1 min-w-[140px] px-2 py-1 rounded text-[10px] bg-white disabled:opacity-60",style:{border:`1px solid ${k}22`,color:k}}),E&&e.jsx("button",{onClick:()=>m(z=>z.filter((M,R)=>R!==V)),className:"px-2 py-1 rounded text-[10px] font-bold",style:{background:"#FEE2E2",color:"#991B1B"},children:"Remove"}),(B==null?void 0:B.note)&&e.jsx("p",{className:"w-full text-[9px]",style:{color:"#9CA3AF"},children:B.note})]},L.key)})]}),e.jsxs("div",{className:"rounded-md px-2 py-2 mb-2",style:{background:"#F8FAFC",border:"1px solid #E2E8F0"},children:[e.jsxs("p",{className:"text-[10px]",style:{color:k},children:["Total program cost ",e.jsx("strong",{children:Ia(I.totalProgramCostCents)})," â confirmed funding"," ",e.jsx("strong",{style:{color:"#166534"},children:Ia(I.confirmedFundingCents)})," ="," ",e.jsxs("strong",{children:["CURRENT CONFIRMED STUDENT RESPONSIBILITY ",Ia(I.currentConfirmedResponsibilityCents)]})]}),e.jsxs("p",{className:"text-[10px] mt-0.5",style:{color:"#92400E"},children:["Potential / pending funding (NOT guaranteed): ",Ia(I.potentialFundingCents)," · projected responsibility if pending funding is approved: ",Ia(I.projectedResponsibilityCents)]})]}),e.jsxs("label",{className:"block mb-2",children:[e.jsx("span",{className:"text-[9px] font-bold uppercase tracking-wider",style:{color:"#8a8a8a"},children:"Note shown to the applicant (optional â no internal aid notes)"}),e.jsx("textarea",{value:x,disabled:!E,maxLength:2e3,rows:2,onChange:L=>h(L.target.value),className:"w-full mt-1 px-2 py-1.5 rounded text-[10.5px] bg-white disabled:opacity-60",style:{border:`1px solid ${k}22`,color:k}})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-1.5",children:[E&&e.jsxs(e.Fragment,{children:[e.jsx("button",{onClick:()=>void D(),disabled:g==="save",className:"px-2.5 py-1 rounded text-[10px] font-bold disabled:opacity-50",style:{background:k,color:$},children:g==="save"?"Savingâ¦":"Save draft"}),e.jsx("button",{onClick:()=>void C("wait",()=>O4(n.id,{state:"waiting_on_funding"}),"Marked waiting on funding."),disabled:g==="wait",className:"px-2.5 py-1 rounded text-[10px] font-bold disabled:opacity-50",style:{background:"#FEF3C7",color:"#92400E"},children:"Waiting on funding"}),e.jsx("button",{onClick:()=>void C("issue",()=>Wue(n.id),"Issued for applicant review. No message was sent."),disabled:g==="issue",className:"px-2.5 py-1 rounded text-[10px] font-bold disabled:opacity-50",style:{background:"#E0E7FF",color:"#3730A3"},children:g==="issue"?"Issuingâ¦":"Issue for applicant review"})]}),n.state==="acknowledged"&&e.jsxs("button",{onClick:()=>void C("complete",()=>Gue(n.id),"Financial Plan requirement completed. No aid awarded, no payment posted, nobody enrolled."),disabled:g==="complete",className:"inline-flex items-center gap-1 px-2.5 py-1 rounded text-[10px] font-bold disabled:opacity-50",style:{background:"#DCFCE7",color:"#166534"},children:[e.jsx(Ie,{size:10})," ",g==="complete"?"Completingâ¦":"Complete requirement"]}),!E&&e.jsx("button",{onClick:()=>{const L=window.prompt("Reason for revising this Financial Plan (previous version is preserved):")||"";L.trim()&&C("revise",()=>
1303Hue(n.id,L.trim()),"Revision opened â prior version preserved. ENROLLMENT AGREEMENT REVIEW REQUIRED was flagged; no executed agreement was changed.")},disabled:g==="revise",className:"px-2.5 py-1 rounded text-[10px] font-bold disabled:opacity-50",style:{background:"#FEF3C7",color:"#92400E"},children:"Revise plan"})]}),n.enrollment_agreement_review_required&&e.jsx("p",{className:"text-[9.5px] mt-1.5 px-2 py-1 rounded",style:{background:"#FFFBEB",color:"#92400E"},children:"ENROLLMENT AGREEMENT REVIEW REQUIRED â a financial change was recorded. The executed Enrollment Agreement was not regenerated or re-signed; review it manually."}),r.length>0&&e.jsx("div",{className:"mt-2 space-y-0.5",children:r.slice(0,5).map(L=>e.jsxs("p",{className:"text-[9px]",style:{color:"#888"},children:["v",L.version," · ",L.state_at_snapshot," · ",Hp(L.created_at),L.acknowledged_name?` · acknowledged by ${L.acknowledged_name}`:"",L.reason?` · ${L.reason}`:""]},L.id))})]}),e.jsxs("p",{className:"text-[9px] mt-2",style:{color:"#9CA3AF"},children:["Planning document only. Title IV eligibility, packaging, awards, disbursements, verification, SAP and R2T4 stay in the Financial Aid workspace and are never changed here. Scholarships and Parent PLUS are never auto-approved.",o?` Acknowledgement version ${o.version_label}.`:" No acknowledgement version configured.",o!=null&&o.requires_policy_review?" REQUIRES ZORGANICS POLICY/LEGAL REVIEW.":""," ","No SSN, Social Security card, FAFSA/ISIR, tax document or bank information is collected here."]})]})},Kue="enrollment-handoff",Que={not_ready:"Not Ready",requirements_outstanding:"Requirements Outstanding",ready_for_admissions_decision:"Ready for Admissions Decision",approved_for_enrollment:"Approved for Enrollment",enrollment_completed:"Enrollment Completed"},Jue={not_ready:{bg:"#F3F4F6",fg:"#6B7280"},requirements_outstanding:{bg:"#FEF3C7",fg:"#92400E"},ready_for_admissions_decision:{bg:"#DBEAFE",fg:"#1E40AF"},approved_for_enrollment:{bg:"#EDE9FE",fg:"#5B21B6"},enrollment_completed:{bg:"#DCFCE7",fg:"#166534"}},Xue={not_ready:"Admissions requirements are not configured or resolved yet.",requirements_outstanding:"One or more applicable required items are still open.",ready_for_admissions_decision:"Every applicable required Admissions requirement is complete. This is NOT an acceptance â a staff decision is still required.",approved_for_enrollment:"Approved by authorized staff. Approval does not enrol anybody â COMPLETE ENROLLMENT is a separate confirmed action.",enrollment_completed:"Enrollment completed and the student identity is linked."},M4={pending:"No Decision Recorded",approved_for_enrollment:"Approved for Enrollment",not_moving_forward:"Not Moving Forward",returned_for_follow_up:"Returned for Follow-up"},eme={pending:{bg:"#F3F4F6",fg:"#6B7280"},approved_for_enrollment:{bg:"#DCFCE7",fg:"#166534"},not_moving_forward:{bg:"#FEE2E2",fg:"#991B1B"},returned_for_follow_up:{bg:"#FEF3C7",fg:"#92400E"}},tme={complete:"Complete",action_needed:"Action Needed",under_review:"Under Review",needs_correction:"Needs Correction",not_required:"Not Required",waived:"Waived",not_available:"Not Yet Available"},sme={complete:{bg:"#DCFCE7",fg:"#166534"},action_needed:{bg:"#FEF9C3",fg:"#854D0E"},under_review:{bg:"#E0E7FF",fg:"#3730A3"},needs_correction:{bg:"#FEF3C7",fg:"#92400E"},not_required:{bg:"#F3F4F6",fg:"#6B7280"},waived:{bg:"#EDE9FE",fg:"#5B21B6"},not_available:{bg:"#F3F4F6",fg:"#9CA3AF"}};function nme(t){return t.applicability==="not_required"||t.status==="not_required"?"not_required":t.applicability==="waived"||t.status==="waived"?"waived":t.applicability==="needs_configuration"?"not_available":t.status==="accepted"?"complete":t.status==="needs_correction"||t.status==="rejected"?"needs_correction":t.status==="submitted"||t.status==="under_review"?"under_review":t.status==="not_requested"?"not_available":"action_needed"}async function w1(t){const{data:s,error:n}=await O.functions.invoke(Kue,{body:t});if(n&&!s)throw new Error(n.message||"Enrollment handoff service unavailable");if(!(s!=null&&s.success))throw new Error((s==null?void 0:s.error)||"Enrollment handoff request failed");return s}const ame=t=>w1({action:"staff-context",applicantId:t}),Hj=t=>
1303w1({action:"staff-events",applicantId:t}),rme=(t,s,n)=>w1({action:"staff-decision",applicantId:t,decision:s,note:n||null}),ime=(t,s={})=>w1({action:"staff-enroll",applicantId:t,confirm:!0,allowCreate:s.allowCreate===!0,studentId:s.studentId||null}),Gj=t=>t?new Date(t).toLocaleString(void 0,{dateStyle:"medium",timeStyle:"short"}):"â",ome=t=>t==null?"Not resolved":`$${(t/100).toLocaleString("en-US",{minimumFractionDigits:2,maximumFractionDigits:2})}`,Vj="#B8962E",rn=({label:t,value:s})=>e.jsxs("p",{className:"text-[11px] leading-relaxed",style:{color:"#555"},children:[e.jsxs("span",{style:{color:"#999"},children:[t,": "]}),s==null||s===""?e.jsx("em",{style:{color:"#bbb"},children:"not set"}):s]}),lme=({applicantId:t,applicantName:s,onChanged:n})=>{var A,z,M,R,T,U,q,H;const[a,r]=d.useState(null),[i,o]=d.useState([]),[l,c]=d.useState(!0),[u,p]=d.useState(null),[m,x]=d.useState(null),[h,y]=d.useState(null),[v,g]=d.useState(""),[N,b]=d.useState(!1),[f,j]=d.useState(!1),[S,w]=d.useState(""),_=d.useCallback(async()=>{c(!0),x(null);try{const G=await ame(t);r(G);const W=await Hj(t);o(W.events||[])}catch(G){x(G.message),r(null)}finally{c(!1)}},[t]);d.useEffect(()=>{_()},[_]);const C=async G=>{p(G),x(null),y(null);try{const W=await rme(t,G,v.trim()||void 0);r(W),g(""),y(G==="approved_for_enrollment"?"Approved for enrollment. Nobody is enrolled yet â COMPLETE ENROLLMENT is a separate confirmed action.":"Decision recorded. No message was sent."),o((await Hj(t)).events||[]),n==null||n()}catch(W){x(W.message)}finally{p(null)}},E=async()=>{var G;p("enroll"),x(null),y(null);try{const W=await ime(t,{allowCreate:f&&S.trim().length>0,studentId:S.trim()||void 0});r(W),b(!1),j(!1),y(W.alreadyEnrolled?"Already enrolled â the existing student identity was returned. No duplicate was created.":`Enrollment completed. Student ID ${((G=W.decision)==null?void 0:G.sisStudentId)||"â"}.`),o((await Hj(t)).events||[]),n==null||n()}catch(W){const X=W.message;x(X),/Student ID/i.test(X)&&j(!0)}finally{p(null)}},P=(a==null?void 0:a.readiness)||"not_ready",F=Jue[P],I=((A=a==null?void 0:a.decision)==null?void 0:A.decision)||"pending",D=eme[I],L=((z=a==null?void 0:a.decision)==null?void 0:z.enrollmentState)==="enrollment_completed",V=I==="approved_for_enrollment"&&!L,B=(a==null?void 0:a.blockers)||[];return e.jsxs("div",{className:"rounded-xl p-3.5",style:{background:"#fff",border:`1px solid ${k}18`},children:[e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2 mb-3",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Nd,{size:15,style:{color:Vj}}),e.jsx("h4",{className:"text-[12px] font-bold uppercase tracking-[0.16em]",style:{color:k},children:"Admissions Completion"}),e.jsx("span",{className:"px-2 py-0.5 rounded text-[9.5px] font-bold uppercase tracking-wider",style:{background:F.bg,color:F.fg},children:Que[P]}),e.jsx("span",{className:"px-2 py-0.5 rounded text-[9.5px] font-bold uppercase tracking-wider",style:{background:D.bg,color:D.fg},children:M4[I]})]}),e.jsxs("button",{onClick:()=>void _(),className:"inline-flex items-center gap-1 px-2 py-1 rounded-md text-[10px] font-bold",style:{background:"transparent",color:k,border:`1px solid ${k}22`},children:[e.jsx(Be,{size:10,className:l?"animate-spin":""})," Refresh"]})]}),m&&e.jsx("p",{className:"text-[11px] mb-2 px-2 py-1.5 rounded",style:{background:"#FEF2F2",color:"#991B1B"},children:m}),h&&e.jsx("p",{className:"text-[11px] mb-2 px-2 py-1.5 rounded",style:{background:"#ECFDF5",color:"#065F46"},children:h}),l&&!a&&e.jsxs("p",{className:"flex items-center gap-2 text-[11px]",style:{color:"#777"},children:[e.jsx(de,{size:12,className:"animate-spin"})," Loading admissions completionâ¦"]}),a&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"rounded-lg overflow-hidden mb-3",style:{border:`1px solid ${k}12`},children:[a.requirements.map(G=>{const W=nme(G),X=sme[W];return e.jsxs("div",{className:"px-2.5 py-1.5 flex flex-wrap items-center gap-2",style:{borderBottom:`1px solid ${k}0D`},children:[W==="complete"?e.jsx(Ue,{size:12,style:{color:"#166534"}}):e.jsx("span",{className:"inline-block w-[12px] h-[12px] rounded-full",style:{border:`1.5px solid ${k}44`}}),e.jsx("span",{className:"text-[11px] font-semibold flex-1 min-w-[150px]",style:{color:k},children:G.label}),e.jsx("span",{className:"px-1.5 py-0.5 rounded text-[9px] font-bold uppercase tracking-wider",style:{background:X.bg,color:X.fg},children:tme[W]}),G.reason&&e.jsx("span",{className:"text-[9px] w-full",style:{color:"#9A3412"},children:G.reason})]},G.id)}),a.requirements.length===0&&e.jsx("p",{className:"text-[11px] text-center py-3",style:{color:"#999"},children:"No requirements are configured on this application yet."})]}),e.jsxs("p",{className:"text-[10px] mb-3",style:{color:"#888"},children:[a.progress.requiredSatisfied," of ",a.progress.requiredTotal," applicable required items complete ·"," ",Xue[P]]}),B.length>0&&!L&&e.jsxs("div",{className:"rounded-lg px-2.5 py-2 mb-3",style:{background:"#FFFBEB",border:"1px solid #FDE68A"},children:[e.jsxs("p",{className:"text-[10px] font-bold uppercase tracking-wider mb-1 flex items-center gap-1",style:{color:"#92400E"},children:[e.jsx(ve,{size:11})," Blockers (",B.length,") â never bypassed automatically"]}),e.jsx("ul",{className:"space-y-0.5",children:B.map((G,W)=>e.jsxs("li",{className:"text-[10px]",style:{color:"#92400E"},children:["· ",G.label]},`${G.code}-${W}`))})]}),!L&&e.jsxs("div",{className:"rounded-lg p-2.5 mb-3",style:{background:`${k}05`,border:`1px solid ${k}12`},children:[e.jsx("p",{className:"text-[10px] font-bold uppercase tracking-[0.16em] mb
1303-1.5",style:{color:Vj},children:"Admissions decision â authorized staff only"}),e.jsx("input",{value:v,onChange:G=>g(G.target.value),maxLength:400,placeholder:"Optional institutional note recorded with the decision",className:"w-full px-2 py-1 rounded-md text-[10.5px] bg-white mb-2",style:{border:`1px solid ${k}22`,color:k}}),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsxs("button",{onClick:()=>void C("approved_for_enrollment"),disabled:!!u||B.length>0,title:B.length>0?"Resolve every blocker before approving":void 0,className:"inline-flex items-center gap-1.5 px-3 py-1.5 rounded-md text-[10.5px] font-bold disabled:opacity-40",style:{background:"#DCFCE7",color:"#166534"},children:[u==="approved_for_enrollment"?e.jsx(de,{size:10,className:"animate-spin"}):e.jsx(dx,{size:11}),"Approve for enrollment"]}),e.jsxs("button",{onClick:()=>void C("returned_for_follow_up"),disabled:!!u,className:"inline-flex items-center gap-1.5 px-3 py-1.5 rounded-md text-[10.5px] font-bold disabled:opacity-40",style:{background:"#FEF3C7",color:"#92400E"},children:[e.jsx(Be,{size:11})," Return for follow-up"]}),e.jsxs("button",{onClick:()=>void C("not_moving_forward"),disabled:!!u,className:"inline-flex items-center gap-1.5 px-3 py-1.5 rounded-md text-[10.5px] font-bold disabled:opacity-40",style:{background:"#FEE2E2",color:"#991B1B"},children:[e.jsx(kt,{size:11})," Not moving forward"]})]}),e.jsx("p",{className:"text-[9px] mt-1.5",style:{color:"#999"},children:"Readiness never accepts anybody and a decision never enrols anybody. Decisions are recorded with the decision-maker, timestamp, application and person â and are never inferred from CRM activity. No email or SMS is sent."}),((M=a.decision)==null?void 0:M.decisionAt)&&e.jsxs("p",{className:"text-[9.5px] mt-1",style:{color:"#777"},children:["Last decision: ",M4[I]," · ",a.decision.decisionBy||"staff"," ·"," ",Gj(a.decision.decisionAt),a.decision.decisionNote?` · ${a.decision.decisionNote}`:""]})]}),V&&e.jsxs("div",{className:"rounded-lg p-2.5 mb-3",style:{background:"#F5F3FF",border:"1px solid #DDD6FE"},children:[e.jsx("p",{className:"text-[10px] font-bold uppercase tracking-[0.16em] mb-1.5",style:{color:"#5B21B6"},children:"Approved for enrollment â confirm to complete"}),e.jsxs("div",{className:"grid sm:grid-cols-2 gap-x-4 gap-y-0.5 mb-2",children:[e.jsx(rn,{label:"Applicant",value:a.applicant.name||s}),e.jsx(rn,{label:"Program",value:a.scheduling.programLabel}),e.jsx(rn,{label:"Campus",value:a.scheduling.campus}),e.jsx(rn,{label:"Start date / cohort",value:[a.scheduling.startDate,a.scheduling.cohort].filter(Boolean).join(" · ")||null}),e.jsx(rn,{label:"Program hours",value:a.scheduling.programHours}),e.jsx(rn,{label:"Authoritative program cost",value:a.pricing?`${ome(a.pricing.totalProgramCostCents)} · ${a.pricing.pricingVersion||"â"}`:null}),e.jsx(rn,{label:"Financial Plan",value:a.financialPlan?`${a.financialPlan.state} (v${a.financialPlan.version})`:null}),e.jsx(rn,{label:"Enrollment Agreement",value:a.agreement?`${a.agreement.state}${a.agreement.versionLabel?` · ${a.agreement.versionLabel}`:""}`:null}),e.jsx(rn,{label:"Admissions requirements",value:`${a.progress.requiredSatisfied} of ${a.progress.requiredTotal} complete`}),e.jsx(rn,{label:"Existing student identity",value:a.identity.sisStudentId?`${a.identity.sisStudentId} â reused, never duplicated`:a.identity.emailMatchStudentId?`Candidate match ${a.identity.emailMatchStudentId}`:"None linked yet"})]}),f&&e.jsxs("div",{className:"flex flex-wrap gap-2 mb-2",children:[e.jsx("input",{value:S,onChange:G=>w(G.target.value.toUpperCase()),placeholder:"Student ID (existing immutable format, e.g. ZI-2026-000123)",className:"flex-1 min-w-[220px] px-2 py-1 rounded-md text-[10.5px] font-mono bg-white",style:{border:`1px solid ${k}22`,color:k}}),e.jsx("span",{className:"text-[9px] self-center",style:{color:"#92400E"},children:"Creating a student identity requires this explicit staff approval."})]}),N?e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsxs("span",{className:"text-[10.5px] font-bold",style:{color:"#5B21B6"},children:["Confirm: enrol ",a.applicant.name||s," into ",a.scheduling.programLabel||"this program","?"]}),e.jsxs("button",{onClick:()=>void E(),disabled:!!u,className:"inline-flex items-center gap-1.5 px-3 py-1.5 rounded-md text-[10.5px] font-bold disabled:opacity-50",style:{background:k,color:$}
1303,children:[u==="enroll"?e.jsx(de,{size:10,className:"animate-spin"}):e.jsx(Ie,{size:11}),"Yes â complete enrollment"]}),e.jsx("button",{onClick:()=>b(!1),className:"px-3 py-1.5 rounded-md text-[10.5px] font-bold",style:{background:"transparent",color:k,border:`1px solid ${k}22`},children:"Cancel"})]}):e.jsxs("button",{onClick:()=>b(!0),disabled:!!u||B.length>0,className:"inline-flex items-center gap-1.5 px-3 py-2 rounded-md text-[11px] font-bold uppercase tracking-wider disabled:opacity-40",style:{background:k,color:$},children:[e.jsx(_t,{size:12})," Complete enrollment"]}),e.jsx("p",{className:"text-[9px] mt-1.5",style:{color:"#999"},children:"Enrollment reuses the existing identity chain and is idempotent â running it twice can never create a second student. It awards no aid, creates no payment, changes no ledger and sends no message."})]}),L&&e.jsxs("div",{className:"rounded-lg p-2.5 mb-3",style:{background:"#ECFDF5",border:"1px solid #A7F3D0"},children:[e.jsx("p",{className:"text-[10.5px] font-bold uppercase tracking-[0.16em] mb-1",style:{color:"#065F46"},children:"Enrollment completed"}),e.jsxs("p",{className:"text-[13px] font-bold font-mono mb-1",style:{color:k},children:["Student ID: ",((R=a.decision)==null?void 0:R.sisStudentId)||a.identity.sisStudentId||"â"]}),e.jsxs("div",{className:"grid sm:grid-cols-2 gap-x-4 gap-y-0.5",children:[e.jsx(rn,{label:"Enrolled by",value:(T=a.decision)==null?void 0:T.enrolledBy}),e.jsx(rn,{label:"Enrolled at",value:Gj((U=a.decision)==null?void 0:U.enrolledAt)}),e.jsx(rn,{label:"Program",value:a.scheduling.programLabel}),e.jsx(rn,{label:"Campus",value:a.scheduling.campus}),e.jsx(rn,{label:"Start date / cohort",value:[a.scheduling.startDate,a.scheduling.cohort].filter(Boolean).join(" · ")||null}),e.jsx(rn,{label:"Provisioning result",value:(q=a.decision)==null?void 0:q.provisioningResult}),e.jsx(rn,{label:"Admissions documents linked",value:(H=a.decision)==null?void 0:H.documentsLinked}),e.jsx(rn,{label:"CRM lifecycle",value:a.identity.personStage})]}),a.portal&&e.jsxs("p",{className:"text-[9.5px] mt-1.5",style:{color:"#065F46"},children:["Student Portal: ",a.portal.mechanism,". ",a.portal.staffSetupRequired]}),e.jsxs("a",{href:"/admin/student-provisioning",className:"inline-flex items-center gap-1.5 mt-2 px-3 py-1.5 rounded-md text-[10.5px] font-bold",style:{background:k,color:$},children:[e.jsx(dx,{size:11})," Open student record"]})]}),e.jsxs("div",{className:"rounded-lg p-2.5",style:{background:"#F8FAFC",border:"1px solid #E2E8F0"},children:[e.jsxs("p",{className:"text-[10px] font-bold uppercase tracking-[0.16em] mb-1.5 flex items-center gap-1",style:{color:Vj},children:[e.jsx(en,{size:11})," Enrollment handoff audit trail"]}),i.length===0?e.jsx("p",{className:"text-[10px]",style:{color:"#94A3B8"},children:"No decision or enrollment events recorded yet."}):e.jsx("div",{className:"space-y-1 max-h-48 overflow-y-auto",children:i.map(G=>e.jsxs("div",{children:[e.jsxs("p",{className:"text-[10px] font-semibold",style:{color:k},children:[G.event_type,G.to_state?` â ${G.to_state}`:""," · ",G.actor_ref||"staff"]}),e.jsxs("p",{className:"text-[9px]",style:{color:"#94A3B8"},children:[Gj(G.created_at),G.detail?` · ${G.detail}`:""]})]},G.id))}),e.jsx("p",{className:"text-[9px] mt-1.5",style:{color:"#94A3B8"},children:"Append-only. Records readiness, decision, decision-maker, approval, enrollment action, enrolling staff member, resulting student account and SIS ID. No SSN, Social Security card, FAFSA/ISIR, tax document or other restricted identity information is written here."})]})]})]})},Nk=["not_reviewed","under_review","needs_follow_up","missing_information","financial_aid_follow_up","ready_for_decision","review_complete"],DN={not_reviewed:"Not Reviewed",under_review:"Under Review",needs_follow_up:"Needs Follow-Up",missing_information:"Missing Information",financial_aid_follow_up:"Financial Aid Follow-Up",ready_for_decision:"Ready for Decision",review_complete:"Review Complete"},nz={not_reviewed:{bg:"#DBEAFE",fg:"#1E40AF"},under_review:{bg:"#E0E7FF",fg:"#3730A3"},needs_follow_up:{bg:"#FEF3C7",fg:"#92400E"},missing_information:{bg:"#FFEDD5",fg:"#9A3412"},financial_aid_follow_up:{bg:"#FCE7F3",fg:"#9D174D"},ready_for_decision:{bg:"#FEF9C3",fg:"#854D0E"},review_complete:{bg:"#DCFCE7",fg:"#166534"}},RN=t=>{const s=String(t||"").trim();return Nk.includes(s)?s:"not_reviewed"};async function cme(t){const s=Array.from(new Set(t.filter(Boolean)));if(!s.length)return{};const{data:n,error:a}=await O.from("admissions_applicants").select("id, review_status, review_status_updated_at, review_status_updated_by, review_status_note").in("id",s);if(a)throw a;const r={};for(const i of n||[])r[i.id]={applicantId:i.id,status:RN(i.review_status),updatedAt:i.review_status_updated_at||null,updatedBy:i.review_status_updated_by||null,note:i.review_status_note||null};return r}async function dme(t,s,n,a){const{data:r}=await O.from("admissions_applicants").select("review_status").eq("id",t).maybeSingle(),i=new Date().toISOString(),{error:o}=await O.from("admissions_applicants").update({review_status:s,review_status_updated_at:i,review_status_updated_by:n.email||n.name,review_status_note:a||null,updated_at:i}).eq("id",t);if(o)throw o;await O.from("admissions_application_review_events").insert({applicant_id:t,from_status:(r==null?void 0:r.review_status)||null,to_status:s,note:a||null,actor_email:n.email||null,actor_name:n.name||null})}async function B4(t){const{data:s,error:n}=await O.from("admissions_application_review_events").select("*").eq("applicant_id",t).order("created_at",{ascending:!1}).limit(20);if(n)throw n;return s||[]}const bu="#B8962E",Og=t=>
1303t?new Date(t).toLocaleString(void 0,{dateStyle:"medium",timeStyle:"short"}):"â",ume=({applicantId:t,applicantName:s,reviewStatus:n,onReviewStatusChanged:a})=>{const[r,i]=d.useState([]),[o,l]=d.useState([]),[c,u]=d.useState([]),[p,m]=d.useState({email:"",name:"Staff"}),[x,h]=d.useState(null),[y,v]=d.useState(!0),[g,N]=d.useState(null),[b,f]=d.useState(null),[j,S]=d.useState(""),[w,_]=d.useState(RN(n)),[C,E]=d.useState(null),P=d.useCallback(async()=>{v(!0),f(null);try{const{data:R}=await O.from("admissions_applicants").select("program_of_interest,email").eq("id",t).maybeSingle();h((R==null?void 0:R.program_of_interest)||null),await Xde(t,R==null?void 0:R.program_of_interest);const T=await qp(t),U=T.find(X=>X.requirement_key==="application");U&&!["accepted","waived","not_required"].includes(U.status)&&await tue(t,U,p.email||"system");const q=T.find(X=>X.requirement_key==="consumer_disclosures");if(q&&!["accepted","waived","not_required"].includes(q.status)){const X=await sue(R==null?void 0:R.email);X&&await nue(q,X,p.email||"system")}const[H,G,W]=await Promise.all([T4(t),B4(t),qp(t)]);i(W),l(H),u(G)}catch(R){f(R.message)}finally{v(!1)}},[t,p.email]);d.useEffect(()=>{P()},[P]),d.useEffect(()=>{_(RN(n))},[n]),d.useEffect(()=>{(async()=>{var q;const{data:R}=await O.auth.getUser(),T=((q=R==null?void 0:R.user)==null?void 0:q.email)||"";if(!T)return;const{data:U}=await O.from("user_profiles").select("full_name,email").eq("email",T).maybeSingle();m({email:T,name:(U==null?void 0:U.full_name)||T})})()},[]);const F=Hde(r),I=Q$(r),D=async(R,T)=>{N(R.id),f(null);try{let U;(T==="needs_correction"||T==="rejected")&&(U=window.prompt(`Reason returned to ${s} for "${R.requirement_label}":`)||void 0),await Gde(R,T,p.email||p.name,U),i(await qp(t))}catch(U){f(U.message)}finally{N(null)}},L=async(R,T)=>{N(R.id),f(null);try{await eue(R.id,T,p.email||p.name),i(await qp(t))}catch(U){f(U.message)}finally{N(null)}},V=async(R,T)=>{N(R.id),f(null);try{let U;if(T!=="approved"&&(U=window.prompt("Correction / rejection reason shown to the applicant:")||void 0,!U)){N(null);return}await Vde(R,T,p.email||p.name,U);const[q,H]=await Promise.all([T4(t),qp(t)]);l(q),i(H)}catch(U){f(U.message)}finally{N(null)}},B=async R=>{N(R.id),f(null);try{const T=await Zde(R.id);window.open(T,"_blank","noopener,noreferrer")}catch(T){f(T.message)}finally{N(null)}},A=async()=>{N("review"),f(null);try{await dme(t,w,p,j.trim()||void 0),S(""),u(await B4(t)),a==null||a(w)}catch(R){f(R.message)}finally{N(null)}},z=async()=>{N("access"),f(null);try{E(await Yde(t))}catch(R){f(R.message)}finally{N(null)}},M=nz[w];return e.jsxs("div",{className:"rounded-xl p-3.5",style:{background:"#fff",border:`1px solid ${k}18`},children:[e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2 mb-3",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(mn,{size:15,style:{color:bu}}),e.jsx("h4",{className:"text-[12px] font-bold uppercase tracking-[0.16em]",style:{color:k},children:"Admissions Requirements"}),e.jsx("span",{className:"px-2 py-0.5 rounded text-[10px] font-bold",style:{background:`${$}22`,color:bu},children:y?"Loadingâ¦":F.label})]}),e.jsxs("button",{onClick:()=>void P(),className:"inline-flex items-center gap-1 px-2 py-1 rounded-md text-[10px] font-bold",style:{background:"transparent",color:k,border:`1px solid ${k}22`},children:[e.jsx(Be,{size:10})," Refresh"]})]}),b&&e.jsx("p",{className:"text-[11px] mb-2 px-2 py-1.5 rounded",style:{background:"#FEF2F2",color:"#991B1B"},children:b}),e.jsxs("div",{className:"rounded-lg overflow-hidden mb-3",style:{border:`1px solid ${k}12`},children:[r.map(R=>{const T=E4[R.status]||E4.not_requested,U=EN(R.requirement_key),q=o.filter(H=>H.requirement_id===R.id&&H.status!=="superseded");return e.jsxs("div",{className:"px-2.5 py-2",style:{borderBottom:`1px solid ${k}0D`},children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[R.status==="accepted"||R.status==="waived"?e.jsx(Ue,{size:13,style:{color:"#166534"}}):e.jsx("span",{className:"inline-block w-[13px] h-[13px] rounded-full",style:{border:`1.5px solid ${k}44`}}),e.jsxs("span",{className:"text-[11.5px] font-semibold flex-1 min-w-[150px]",style:{color:k},children:[R.requirement_label,(U==null?void 0:U.futurePhase)&&e.jsx("span",{className:"ml-1.5 text-[9px] font-bold uppercase",style:{color:"#9A3412"},children:"later phase"})]}),e.jsx("span",{className:"px-1.5 py-0.5 rounded text-[9px] font-bold uppercase tracking-wider",style:{background:T.bg,color:T.fg},children:A4[R.status]}),e.jsx("span",{className:"px-1.5 py-0.5 rounded text-[9px] font-bold uppercase tracking-wider",style:{background:D4[R.applicability||"required"].bg,color:D4[R.applicability||"required"].fg},children:P4[R.applicability||"required"]}),e.jsx("select",{value:R.applicability||"required",disabled:g===R.id,onChange:H=>void L(R,H.target.value),className:"px-2 py-1 rounded-md text-[10px] bg-white",style:{border:`1px solid ${k}22`,color:k},children:Kde.map(H=>e.jsx("option",{value:H,children:P4[H]},H))}),e.jsx("select",{value:R.status,disabled:g===R.id,onChange:H=>void D(R,H.target.value),className:"px-2 py-1 rounded-md text-[10px] bg-white",style:{border:`1px solid ${k}22`,color:k},children:Bde.map(H=>e.jsx("option",{value:H,children:A4[H]},H))})]}),e.jsxs("p",{className:"text-[9.5px] mt-1",style:{color:"#8a8a8a"},children:[R.helper||(U==null?void 0:U.helper),R.satisfied_source?` · Source: ${R.satisfied_source}`:"",R.reviewed_at?` · Reviewed ${Og(R.reviewed_at)}${R.reviewed_by?` by ${R.reviewed_by}`:""}`:"",R.decision_reason?` · Reason: ${R.decision_reason}`:""]}),q.map(H=>e.jsxs("div",{className:"mt-1.5 flex flex-wrap items-center gap-1.5 px-2 py-1.5 rounded",style:{background:`${k}06`},children:[e.jsx(Xe,{size:10,style:{color:bu}}),e.jsxs("span",{className:"text-[10px] font-semibold",style:{color:k},children:[G$[H.document_type]," · v",H.version]}),e.jsxs("span",{className:"text-[9.5px]",style:{color:"#888"},children:[H.file_name," · uploaded ",Og(H.uploaded_at)," · ",V$[H.status]||H.status]}),e.jsxs("button",{onClick:()=>void B(H),disabled:g===H.id,className:"inline-flex items-center gap-1 px-2 py-0.5 rounded text-[9.5px] font-bold disabled:opacity-50",style:{background:k,color:$},children:[g===H.id?e.jsx(de,{size:9,className:"animate-spin"}):e.jsx(Kt,{size:9})," Open securely"]}),e.jsx("button",{onClick:()=>void V(H,"approved"),disabled:g===H.id,className:"px-2 py-0.5 rounded text-[9.5px] font-bold",style:{background:"#DCFCE7",color:"#166534"},children:"Accept"}),e.jsx("button",{onClick:()=>void V(H,"needs_correction"),disabled:g===H.id,className:"px-2 py-0.5 rounded text-[9.5px] font-bold",style:{background:"#FEF3C7",color:"#92400E"},children:"Needs correction"}),e.jsx("button",{onClick:()=>void V(H,"rejected"),disabled:g===H.id,className:"px-2 py-0.5 rounded text-[9.5px] font-bold",style:{background:"#FEE2E2",color:"#991B1B"},children:"Reject"})]},H.id))]},R.id)}),!y&&r.length===0&&e.jsx("p",{className:"text-[11px] text-center py-4",style:{color:"#999"},children:"No requirements on this application yet."})]}),!y&&F.outstanding.length>0&&e.jsxs("p",{className:"text-[10.5px] mb-2 px-2 py-1.5 rounded",style:{background:"#FFFBEB",color:"#92400E"},children:[e.jsx("strong",{children:"Outstanding:"})," ",F.outstanding.map(R=>R.requirement_label).join(" · ")]}),e.jsxs("div",{className:"rounded-lg px-2.5 py-2 mb-3",style:{background:I.complete?"#ECFDF5":`${k}05`,border:`1px solid ${I.complete?"#A7F3D0":`${k}12`}`},children:[e.jsx("p",{className:"text-[10.5px] font-bold",style:{color:I.complete?"#065F46":k},children:I.complete?"ADMISSIONS REQUIREMENTS COMPLETE":`Admissions requirements: ${I.label}`}),e.jsxs("p",{className:"text-[9px] mt-0.5",style:{color:"#888"},children:["Program template: ",wk(x),x?` · ${x}`:""," · readiness indicator only â human approval is still required for acceptance, enrollment, SIS provisioning and any funding decision.",I.needsConfiguration.length>0?` Needs staff configuration: ${I.needsConfiguration.map(R=>R.requirement_label).join(" · ")}.`:""]})]}),e.jsx("div",{className:"mb-3",children:e.jsx(fue,{applicantId:t,requirements:r,actor:p.email||p.name,onRequirementsC
1303hanged:()=>{P()}})}),e.jsx("div",{className:"mb-3",children:e.jsx(Tue,{applicantId:t,program:x,onChanged:()=>{P()}})}),e.jsx("div",{className:"mb-3",children:e.jsx(Yue,{applicantId:t,onChanged:()=>{P()}})}),e.jsx("div",{className:"mb-3",children:e.jsx(lme,{applicantId:t,applicantName:s,onChanged:()=>{P()}})}),e.jsxs("div",{className:"rounded-lg p-2.5 mb-3",style:{background:`${k}05`,border:`1px solid ${k}12`},children:[e.jsx("p",{className:"text-[10px] font-bold uppercase tracking-[0.16em] mb-1.5",style:{color:bu},children:"Application review status (this application only)"}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx("span",{className:"px-2 py-0.5 rounded text-[9.5px] font-bold uppercase tracking-wider",style:{background:M.bg,color:M.fg},children:DN[w]}),e.jsx("select",{value:w,onChange:R=>_(R.target.value),className:"px-2 py-1 rounded-md text-[10.5px] bg-white",style:{border:`1px solid ${k}22`,color:k},children:Nk.map(R=>e.jsx("option",{value:R,children:DN[R]},R))}),e.jsx("input",{value:j,onChange:R=>S(R.target.value),maxLength:400,placeholder:"Optional note saved with the status change",className:"flex-1 min-w-[190px] px-2 py-1 rounded-md text-[10.5px] bg-white",style:{border:`1px solid ${k}22`,color:k}}),e.jsxs("button",{onClick:()=>void A(),disabled:g==="review",className:"inline-flex items-center gap-1.5 px-3 py-1.5 rounded-md text-[10.5px] font-bold disabled:opacity-50",style:{background:k,color:$},children:[g==="review"?e.jsx(de,{size:10,className:"animate-spin"}):e.jsx(Ie,{size:10})," Save review status"]})]}),e.jsxs("p",{className:"text-[9px] mt-1.5",style:{color:"#999"},children:["Persisted on ",e.jsx("span",{className:"font-mono",children:"admissions_applicants.review_status"}),' with a full audit trail. Acceptance, enrollment and "not moving forward" remain CRM lifecycle decisions and are never set here.']}),c.length>0&&e.jsx("div",{className:"mt-2 space-y-0.5",children:c.slice(0,4).map(R=>e.jsxs("p",{className:"text-[9.5px]",style:{color:"#777"},children:[Og(R.created_at)," · ",R.from_status?`${R.from_status} â `:"",R.to_status,R.actor_name?` · ${R.actor_name}`:"",R.note?` · ${R.note}`:""]},R.id))})]}),e.jsxs("div",{className:"rounded-lg p-2.5",style:{background:"#F8FAFC",border:"1px solid #E2E8F0"},children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx(ka,{size:13,style:{color:bu}}),e.jsx("span",{className:"text-[10.5px] font-bold",style:{color:k},children:"Secure applicant access"}),e.jsxs("button",{onClick:()=>void z(),disabled:g==="access",className:"inline-flex items-center gap-1.5 px-2.5 py-1 rounded-md text-[10px] font-bold disabled:opacity-50",style:{background:`linear-gradient(135deg, ${$}, ${bu})`,color:k},children:[g==="access"?e.jsx(de,{size:10,className:"animate-spin"}):e.jsx(ka,{size:10}),"Issue one-time access code"]})]}),C&&e.jsxs("p",{className:"text-[10.5px] mt-1.5 px-2 py-1.5 rounded font-mono",style:{background:"#ECFDF5",color:"#065F46"},children:["Code ",e.jsx("strong",{children:C.code})," for ",C.email," · valid until ",Og(C.expiresAt)," · portal: /applicant"]}),e.jsxs("p",{className:"text-[9px] mt-1.5",style:{color:"#94A3B8"},children:["The code is shown once and stored only as a SHA-256 digest. Nothing is emailed or texted â hand it to the applicant through your normal verified channel. They sign in at ",e.jsx("span",{className:"font-mono",children:"/applicant"})," ","to view requirements and upload allowed documents. Social Security documentation is not collected in this phase."]})]})]})},IN=DN,mme=nz,pme=Nk,ub=t=>t?new Date(t).getTime():0;function hme(t,s={}){const n=[];for(const a of t){const r=a.row.group.records.filter(o=>o.sourceKey==="admissions_applicants"&&o.recordId).sort((o,l)=>ub(o.createdAt)-ub(l.createdAt));if(!r.length)continue;const i=r.map(o=>String(o.recordId));r.forEach((o,l)=>{var x,h;const c=String(o.recordId),u=s[c],p=u?u.status:"not_reviewed",m=u!=null&&u.updatedAt?{at:u.updatedAt,by:u.updatedBy,notes:u.note}:null;n.push({id:`${a.id}::${c}`,person:a,record:o,applicantId:c,siblingIds:i,applicationIndex:l+1,applicationCount:r.length,submittedAt:((x=o.detail)==null?void 0:x.applicationSubmittedAt)||o.createdAt,sourceStatus:o.status,program:o.program||a.program,campus:o.campus||a.campus,reviewStatus:p,reviewBasis:m?`Set by ${m.by||"staff"} on ${new Date(m.at).toLocaleDateString()}`:"Staff-controlled review state on this application (not set yet)",lastReview:m,aidInterestOnApplication:((h=o.detail)==null?void 0:h.financialAidInterest)===!0,personStage:a.stage})})}return n}const Zj={search:"",program:"all",campus:"all",review:"all",sourceStatus:"all",stage:"all",aid:"all",tour:"all",readiness:"all",owner:"all",followUp:"all",submitted:"all"},az=(t,s)=>{if(!t)return!1;const n=new Date(t).getTime();return Number.isNaN(n)?!1:n>=Date.now()-s*864e5};function xme(t,s){const n=s.search.trim().toLowerCase(),a=n.replace(/\D/g,"");return t.filter(r=>{var i;if(s.program!=="all"&&(r.program||"(not set)")!==s.program||s.campus!=="all"&&(r.campus||"(not set)")!==s.campus||s.review!=="all"&&r.reviewStatus!==s.review||s.sourceStatus!=="all"&&(r.sourceStatus||"(not set)")!==s.sourceStatus||s.stage!=="all"&&(r.person.stage||"not-in-crm")!==s.stage)return!1;if(s.aid!=="all"){const o=r.aidInterestOnApplication||r.person.aid.interested;if(String(o)!==s.aid)return!1}if(s.tour!=="all"&&r.person.tour.status!==s.tour||s.readiness!=="all"&&(((i=r.person.profile)==null?void 0:i.readiness.level)||"none")!==s.readiness||s.owner!=="all"&&(r.person.owner||"Unassigned")!==s.owner||s.followUp==="due-today"&&!r.person.dueToday||s.followUp==="overdue"&&!r.person.overdue||s.followUp==="no-follow-up"&&r.person.followUpAt||s.followUp==="unassigned"&&r.person.owner||s.submitted!=="all"&&!az(r.submittedAt,Number(s.submitted)))return!1;if(n){const o=[r.person.name,r.person.email,r.person.phone,r.program,r.campus,r.sourceStatus,r.person.owner,r.person.stageLabel,IN[r.reviewStatus],r.person.nextAction,r.record.ref].filter(
1303Boolean).join(" ").toLowerCase(),l=a.length>=4&&(r.person.phone||"").replace(/\D/g,"").includes(a);if(!o.includes(n)&&!l)return!1}return!0})}function fme(t){return[...t].sort((s,n)=>{const a=i=>{var o;return i.person.overdue?0:i.reviewStatus==="not_reviewed"?1:i.reviewStatus==="missing_information"?2:i.person.dueToday?3:((o=i.person.profile)==null?void 0:o.readiness.level)==="high"?4:5},r=a(s)-a(n);return r!==0?r:ub(n.submittedAt)-ub(s.submittedAt)})}function gme(t){const s=n=>Array.from(new Set(n.map(a=>a&&a.trim()?a.trim():"(not set)"))).sort();return{programs:s(t.map(n=>n.program)),campuses:s(t.map(n=>n.campus)),sourceStatuses:s(t.map(n=>n.sourceStatus)),owners:Array.from(new Set(t.map(n=>n.person.owner||"Unassigned"))).sort()}}function yme(t){return{total:t.length,newApplications:t.filter(s=>az(s.submittedAt,7)).length,unreviewed:t.filter(s=>s.reviewStatus==="not_reviewed").length,needsFollowUp:t.filter(s=>s.reviewStatus==="needs_follow_up").length,missingInformation:t.filter(s=>s.reviewStatus==="missing_information").length,aidInterested:t.filter(s=>s.aidInterestOnApplication||s.person.aid.interested).length,tourRequested:t.filter(s=>s.person.tour.status==="requested"||s.person.tour.status==="booked_unverified").length,tourScheduled:t.filter(s=>s.person.tour.status==="scheduled").length,highIntent:t.filter(s=>{var n;return((n=s.person.profile)==null?void 0:n.readiness.level)==="high"}).length,overdue:t.filter(s=>s.person.overdue).length,readyForReview:t.filter(s=>s.reviewStatus==="ready_for_decision").length,reviewComplete:t.filter(s=>s.reviewStatus==="review_complete").length}}const Gp="#B8962E",Ic=({label:t,value:s,tone:n="plain",active:a,onClick:r})=>{const i=n==="alert"?{bg:"#FEF2F2",border:"#FCA5A5",fg:"#991B1B"}:n==="warn"?{bg:"#FFFBEB",border:"#FDE68A",fg:"#92400E"}:n==="good"?{bg:"#F0FDF4",border:"#BBF7D0",fg:"#166534"}:{bg:"#fff",border:`${k}15`,fg:k};return e.jsxs("button",{onClick:r,className:"rounded-xl px-3 py-2.5 text-left",style:{background:i.bg,border:`1px solid ${a?k:i.border}`,boxShadow:a?`0 0 0 2px ${$}55`:void 0},children:[e.jsx("p",{className:"text-[9px] uppercase tracking-[0.18em] font-bold",style:{color:"#888"},children:t}),e.jsx("p",{className:"text-xl font-bold leading-tight",style:{color:i.fg},children:s})]})},Pr=({label:t,value:s,options:n,onChange:a})=>e.jsxs("label",{className:"block",children:[e.jsx("span",{className:"text-[9px] uppercase tracking-wider font-bold",style:{color:"#999"},children:t}),e.jsx("select",{value:s,onChange:r=>a(r.target.value),className:"w-full mt-0.5 px-2 py-1.5 rounded-md text-[11px] bg-white",style:{border:`1px solid ${k}22`,color:k},children:n.map(r=>e.jsx("option",{value:r.value,children:r.label},r.value))})]}),Fn=({children:t,title:s,nowrap:n})=>e.jsx("td",{className:`px-2.5 py-2 align-top text-[11px] ${n?"whitespace-nowrap":""}`,style:{color:"#444",borderBottom:`1px solid ${k}0D`},title:s,children:t}),hi=()=>e.jsx("span",{style:{color:"#ccc"},children:"â"}),U4=["Applicant","Program","Campus","Submitted","Application status","Review status","CRM stage","Readiness","Tour","Financial aid","Owner","Last contact","Next action","Follow-up due","Record","Actions"],bme=({people:t,canRevealPII:s,busyPersonId:n,onOpenPerson:a,onViewApplication:r,onLogReview:i})=>{const[o,l]=d.useState(Zj),[c,u]=d.useState(null),[p,m]=d.useState(""),[x,h]=d.useState({}),y=d.useMemo(()=>t.flatMap(w=>w.row.group.records.filter(_=>_.sourceKey==="admissions_applicants"&&_.recordId).map(_=>String(_.recordId))),[t]),v=d.useCallback(async()=>{if(y.length)try{h(await cme(y))}catch{}},[y.join("|")]);d.useEffect(()=>{v()},[v]);const g=d.useMemo(()=>hme(t,x),[t,x]),N=d.useMemo(()=>gme(g),[g]),b=d.useMemo(()=>yme(g),[g]),f=d.useMemo(()=>fme(xme(g,o)),[g,o]),j=w=>l(_=>({..._,...w})),S=async w=>{const _=p.trim()||"Application reviewed.";await i(w,_),u(null),m("")};return e.jsxs("div",{children:[e.jsxs("div",{className:"rounded-xl p-3 mb-4 flex items-start gap-2.5",style:{background:"#F0FDF4",border:"1px solid #86EFAC"},children:[e.jsx(Ie,{size:15,style:{color:"#166534",marginTop:1}}),e.jsxs("p",{className:"text-[11px] leading-relaxed",style:{color:"#166534"},children:[e.jsx("strong",{children:"Application queue â one row per submitted application."})," Rows read the existing"," ",e.jsx("span",{className:"font-mono",children:"admissions_applicants"})," records already linked to a person; owner, next action, follow-up and stage remain the same"," ",e.jsx("span",{className:"font-mono",children:"crm_people"})," records used everywhere else. Review status is the AUTHORITATIVE staff-controlled ",e.jsx("span",{className:"font-mono",children:"review_status"})," on each application â acceptance / enrollment stay CRM lifecycle decisions, and no email or SMS is sent from this screen."]})]}),e.jsxs("div",{className:"grid grid-cols-2 sm:grid-cols-4 lg:grid-cols-7 gap-2.5 mb-4",children:[e.jsx(Ic,{label:"Applications",value:b.total,active:o.review==="all"&&o.followUp==="all"&&o.submitted==="all",onClick:()=>l(Zj)}),e.jsx(Ic,{label:"New (7 days)",value:b.newApplications,active:o.submitted==="7",onClick:()=>j({submitted:o.submitted==="7"?"all":"7"})}),e.jsx(Ic,{label:"Not reviewed",value:b.unreviewed,tone:"warn",active:o.review==="not_reviewed",onClick:()=>j({review:o.review==="not_reviewed"?"all":"not_reviewed"})}),e.jsx(Ic,{label:"Needs follow-up",value:b.needsFollowUp,tone:"warn",active:o.review==="needs_follow_up",onClick:()=>j({review:o.review==="needs_follow_up"?"all":"needs_follow_up"})}),e.jsx(Ic,{label:"Aid interested",value:b.aidInterested,active:o.aid==="true",onClick:()=>j({aid:o.aid==="true"?"all":"true"})}),e.jsx(Ic,{label:"Overdue",value:b.overdue,tone:"alert",active:o.followUp==="overdue",onClick:()=>j({followUp:o.followUp==="overdue"?"all":"overdue"})}),e.jsx(Ic,{label:"Ready for decision",value:b.readyForReview,tone:"good",active:o.review==="ready_for_decision",onClick:()=>j({review:o.review==="ready_for_decision"?"all":"ready_for_decision"})})]}),e.jsxs("div",{className:"rounded-xl p-3 mb-4",style:{background:"#fff",border:`1px solid ${k}15`},children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsxs("div",{className:"relative flex-1 min-w-[240px]",children:[e.jsx(Bt,{size:13,className:"absolute left-2.5 top-1/2 -translate-y-1/2",style:{color:"#aaa"}}),e.jsx("input",{value:o.search,onChange:w=>j({search:w.target.value}),placeholder:"Search applicant name, phone, email, program, owner, stageâ¦",className:"w-full pl-8 pr-3 py-1.5 rounded-lg text-xs",style:{border:`1px solid ${k}22`,color:k}})]}),e.jsx("button",{onClick:()=>l(Zj),className:"px-3 py-1.5 rounded-lg text-[11px] font-bold",style:{background:"transparent",color:Gp,border:`1px solid ${$}55`},children:"Clear filters"})]}),e.jsxs("div",{className:"grid grid-cols-2 sm:grid-cols-3 lg:grid-cols-6 gap-2 mt-3",children:[e.jsx(Pr,{label:"Program",value:o.program,onChange:w=>j({program:w}),options:[{value:"all",label:"All programs"},...N.programs.map(w=>({value:w,label:w}))]}),e.jsx(Pr,{label:"Campus",value:o.campus,onChange:w=>j({campus:w}),options:[{value:"all",label:"All campuses"},...N.campuses.map(w=>({value:w,label:w}))]}),e.jsx(Pr,{label:"Application status",value:o.sourceStatus,onChange:w=>j({sourceStatus:w}),options:[{value:"all",label:"Any application status"},...N.sourceStatuses.map(w=>({value:w,label:w}))]}),e.jsx(Pr,{label:"Review status",value:o.review,onChange:w=>j({review:w}),options:[{value:"all",label:"Any review status"},...pme.map(w=>({value:w,label:IN[w]}))]}),e.jsx(Pr,{label:"CRM stage",value:o.stage,onChange:w=>j({stage:w}),options:[{value:"all",label:"All stages"},...Wa.map(w=>({value:w.value,label:w.label})),{value:"not-in-crm",label:"Not yet in CRM"}]}),e.jsx(Pr,{label:"Financial aid",value:o.aid,onChange:w=>j({aid:w}),options:[{value:"all",label:"Any aid status"},{value:"true",label:"Aid interest on file"},{value:"false",label:"Not indicated"}]}),e.jsx(Pr,{label:"Tour",value:o.tour,onChange:w=>j({tour:w}),options:[{value:"all",label:"Any tour status"},...["requested","booked_unverified","scheduled","completed","cancelled","no_show","none"].map(w=>({value:w,label:Id[w]}))]}),e.jsx(Pr,{label:"Readiness",value:o.readiness,onChange:w=>j({readiness:w}),options:[{value:"all",label:"Any readiness"},{value:"high",label:"High intent"},{value:"medium",label:"Medium intent"},{value:"low",label:"Low / early"}]}),e.jsx(Pr,{label:"Owner",value:o.owner,onChange:w=>j({owner:w}),options:[{value:"all",label:"All owners"},...N.owners.map(w=>({value:w,label:w}))]}),e.jsx(Pr,{label:"Follow-up",value:o.followUp,onChange:w=>j({followUp:w}),options:[{value:"all",label:"Everyone"},{value:"due-today",label:"Due today"},{value:"overdue",label:"Overdue"},{value:"no-follow-up",label:"No follow-up set"},{value:"unassigned",label:"Unassigned"}]}),e.jsx(Pr,{label:"Submitted",value:o.submitted,onChange:w=>j({submitted:w}),options:[{value:"all",label:"All time"},{value:"7",label:"Last 7 days"},{value:"30",label:"Last 30 days"},{value:"90",label:"Last 90 days"}]})]}),e.jsxs("p",{className:"text-[10px] mt-2",style:{color:"#888"},children:["Showing ",e.jsx("strong",{children:f.length})," of ",g.length," submitted applications.",!s&&" Opening the completed application requires an authorized admissions role."]})]}),e.jsxs("div",{className:"rounded-xl overflow-hidden",style:{background:"#fff",border:`1px solid ${k}15`},children:[e.jsx("div",{className:"overflow-x-auto",children:e.jsxs("table",{className:"min-w-full border-collapse",children:[e.jsx("thead",{children:e.jsx("tr",{style:{background:`${k}08`},children:U4.map(w=>e.jsx("th",{className:"px-2.5 py-2 text-left text-[9px] uppercase tracking-[0.14em] font-bold whitespace-nowrap",style:{color:Gp,borderBottom:`1px solid ${k}18`},children:w}
1303,w))})}),e.jsx("tbody",{children:f.slice(0,300).map(w=>{var I;const _=w.person,C=_.stage?hm(_.stage):null,E=jk[_.tour.status],P=mme[w.reviewStatus],F=n===_.id;return e.jsxs(re.Fragment,{children:[e.jsxs("tr",{className:"hover:bg-[#FCFAF5] transition-colors",style:_.overdue?{background:"#FEF6F6"}:void 0,children:[e.jsxs(Fn,{nowrap:!0,children:[e.jsx("button",{onClick:()=>a(_),className:"font-bold text-left hover:underline",style:{color:k},children:_.name}),e.jsxs("div",{className:"flex items-center gap-1.5 mt-0.5",children:[w.applicationCount>1&&e.jsxs("span",{className:"text-[9px] font-semibold",style:{color:Gp},children:["Application ",w.applicationIndex," of ",w.applicationCount]}),_.overdue&&e.jsxs("span",{className:"inline-flex items-center gap-0.5 text-[9px] font-bold",style:{color:"#991B1B"},children:[e.jsx(ve,{size:9})," Overdue"]}),!_.overdue&&_.dueToday&&e.jsxs("span",{className:"inline-flex items-center gap-0.5 text-[9px] font-bold",style:{color:"#92400E"},children:[e.jsx(_a,{size:9})," Due today"]}),((I=_.profile)==null?void 0:I.readiness.level)==="high"&&e.jsxs("span",{className:"inline-flex items-center gap-0.5 text-[9px] font-bold",style:{color:"#166534"},children:[e.jsx(Kx,{size:9})," High intent"]})]})]}),e.jsx(Fn,{children:w.program||e.jsx(hi,{})}),e.jsx(Fn,{children:w.campus||e.jsx(hi,{})}),e.jsx(Fn,{nowrap:!0,children:w.submittedAt?Xn(w.submittedAt):e.jsx(hi,{})}),e.jsx(Fn,{nowrap:!0,children:w.sourceStatus||e.jsx(hi,{})}),e.jsxs(Fn,{nowrap:!0,title:w.reviewBasis,children:[e.jsx("span",{className:"px-1.5 py-0.5 rounded text-[9px] font-bold uppercase tracking-wider",style:{background:P.bg,color:P.fg},children:IN[w.reviewStatus]}),w.lastReview&&e.jsxs("div",{className:"text-[9px] mt-0.5",style:{color:"#888"},children:[Xn(w.lastReview.at),w.lastReview.by?` · ${w.lastReview.by}`:""]})]}),e.jsx(Fn,{nowrap:!0,children:C?e.jsx("span",{className:"px-1.5 py-0.5 rounded text-[9px] font-bold uppercase tracking-wider",style:{background:C.bg,color:C.fg},children:C.label}):e.jsx("span",{className:"px-1.5 py-0.5 rounded text-[9px] font-bold uppercase",style:{background:"#F3F4F6",color:"#4B5563"},children:"Not in CRM"})}),e.jsx(Fn,{nowrap:!0,children:_.profile?e.jsxs("span",{className:"px-1.5 py-0.5 rounded text-[9px] font-bold uppercase tracking-wider",style:{background:Yr[_.profile.readiness.level].bg,color:Yr[_.profile.readiness.level].fg},children:[_.readinessLabel," ",_.readinessScore]}):e.jsx(hi,{})}),e.jsxs(Fn,{nowrap:!0,title:_.tour.basis,children:[_.tour.status==="none"?e.jsx(hi,{}):e.jsx("span",{className:"px-1.5 py-0.5 rounded text-[9px] font-bold uppercase tracking-wider",style:{background:E.bg,color:E.fg},children:Id[_.tour.status]}),_.tour.confirmedAt&&e.jsx("div",{className:"text-[9px] mt-0.5",style:{color:"#555"},children:Ln(_.tour.confirmedAt)})]}),e.jsx(Fn,{title:_.aid.detail||void 0,children:w.aidInterestOnApplication?e.jsx("span",{style:{color:"#9D174D"},children:"Indicated on application"}):_.aid.interested?_.aid.label:e.jsx(hi,{})}),e.jsx(Fn,{nowrap:!0,children:_.owner||e.jsx("span",{style:{color:"#B45309"},children:"Unassigned"})}),e.jsx(Fn,{nowrap:!0,children:_.lastContactAt?Xn(_.lastContactAt):e.jsx(hi,{})}),e.jsx(Fn,{children:_.nextAction||e.jsx(hi,{})}),e.jsx(Fn,{nowrap:!0,children:_.followUpAt?e.jsx("span",{style:{color:_.overdue?"#991B1B":"#444"},children:Ln(_.followUpAt)}):e.jsx(hi,{})}),e.jsx(Fn,{nowrap:!0,children:_.recordStatus}),e.jsx(Fn,{nowrap:!0,children:e.jsxs("div",{className:"flex flex-wrap items-center gap-1.5",children:[s?e.jsxs("button",{onClick:()=>r(w),className:"inline-flex items-center gap-1 px-2 py-1 rounded-md text-[10px] font-bold uppercase tracking-wider",style:{background:`linear-gradient(135deg, ${$}, ${Gp})`,color:k},children:[e.jsx(Kt,{size:10})," View completed application"]}):e.jsx("span",{className:"text-[9px]",style:{color:"#999"},children:"Authorized role required"}),e.jsxs("button",{onClick:()=>{u(c===w.id?null:w.id),m("")},className:"inline-flex items-center gap-1 px-2 py-1 rounded-md text-[10px] font-bold",style:{background:`${k}0C`,color:k,border:`1px solid ${k}22`},children:[e.jsx(Nd,{size:10})," Log review"]}),e.jsx("button",{onClick:()=>a(_),className:"px-2 py-1 rounded-md text-[10px] font-bold",style:{background:"transparent",color:k,border:`1px solid ${k}22`},children:"Open applicant"})]})})]}),c===w.id&&e.jsx("tr",{style:{background:"#FCFAF5"},children:e.jsxs("td",{colSpan:U4.length,className:"px-3 py-3",style:{borderBottom:`1px solid ${k}0D`},children:[e.jsx("div",{className:"mb-3",children:e.jsx(ume,{applicantId:w.applicantId,applicantName:_.n
1303ame,reviewStatus:w.reviewStatus,onReviewStatusChanged:D=>h(L=>({...L,[w.applicantId]:{applicantId:w.applicantId,status:D,updatedAt:new Date().toISOString(),updatedBy:"you",note:null}}))})}),e.jsx("p",{className:"text-[10px] font-bold uppercase tracking-wider mb-1.5",style:{color:Gp},children:"Log an application review â saved to this person's activity history"}),e.jsxs("div",{className:"flex flex-wrap items-start gap-2",children:[e.jsx("textarea",{value:p,onChange:D=>m(D.target.value),rows:2,maxLength:600,placeholder:"e.g. Reviewed application â education history complete, needs proof of HS diploma before decision.",className:"flex-1 min-w-[260px] px-2 py-1.5 rounded-md text-[11px] bg-white",style:{border:`1px solid ${k}22`,color:k}}),e.jsxs("button",{onClick:()=>void S(w),disabled:F,className:"inline-flex items-center gap-1.5 px-3 py-2 rounded-md text-[11px] font-bold disabled:opacity-50",style:{background:k,color:$},children:[F?e.jsx(de,{size:11,className:"animate-spin"}):e.jsx(Nd,{size:11}),"Save application review"]}),e.jsx("button",{onClick:()=>{u(null),m("")},className:"px-3 py-2 rounded-md text-[11px] font-bold",style:{background:"transparent",color:k,border:`1px solid ${k}22`},children:"Cancel"})]}),e.jsxs("p",{className:"text-[9px] mt-1.5",style:{color:"#999"},children:["Recorded as an ",e.jsx("span",{className:"font-mono",children:"application"})," activity on"," ",e.jsx("span",{className:"font-mono",children:"crm_activities"}),". Nothing is emailed or texted. Set the next action, follow-up date, owner or pipeline stage from"," ",e.jsx("button",{onClick:()=>a(_),className:"underline font-semibold",style:{color:k},children:"the applicant record"}),"."]})]})})]},w.id)})})]})}),f.length===0&&e.jsx("p",{className:"text-center text-[12px] py-10",style:{color:"#888"},children:"No submitted applications match the current filters."})]}),f.length>300&&e.jsxs("p",{className:"text-center text-[11px] py-3",style:{color:"#888"},children:["Showing the first 300 of ",f.length," â narrow the filters or search."]})]})},q4="#B8962E",Vp=({label:t,value:s,tone:n="plain",onClick:a,active:r})=>{const i=n==="alert"?{bg:"#FEF2F2",border:"#FCA5A5",fg:"#991B1B"}:n==="warn"?{bg:"#FFFBEB",border:"#FDE68A",fg:"#92400E"}:{bg:"#fff",border:`${k}15`,fg:k};return e.jsxs("button",{onClick:a,className:"rounded-xl px-3 py-2.5 text-left",style:{background:i.bg,border:`1px solid ${r?k:i.border}`,boxShadow:r?`0 0 0 2px ${$}55`:void 0},children:[e.jsx("p",{className:"text-[9px] uppercase tracking-[0.18em] font-bold",style:{color:"#888"},children:t}),e.jsx("p",{className:"text-xl font-bold leading-tight",style:{color:i.fg},children:s})]})},Dr=({label:t,value:s,options:n,onChange:a})=>e.jsxs("label",{className:"block",children:[e.jsx("span",{className:"text-[9px] uppercase tracking-wider font-bold",style:{color:"#999"},children:t}),e.jsx("select",{value:s,onChange:r=>a(r.target.value),className:"w-full mt-0.5 px-2 py-1.5 rounded-md text-[11px] bg-white",style:{border:`1px solid ${k}22`,color:k},children:n.map(r=>e.jsx("option",{value:r.value,children:r.label},r.value))})]}),vme=({groups:t})=>{const{user:s,isSuperAdmin:n}=kn(),a=s?{id:s.id,name:s.fullName||s.email,email:s.email}:null,r=bde(s==null?void 0:s.role,{isSuperAdmin:n}),[i,o]=d.useState(!0),l=r&&i,[c,u]=d.useState(b1),[p,m]=d.useState([]),[x,h]=d.useState(!0),[y,v]=d.useState(null),[g,N]=d.useState("table"),[b,f]=d.useState(k4),[j,S]=d.useState(null),[w,_]=d.useState(null),C=d.useCallback(async()=>{const T=await df();u(T),h(!1)},[]);d.useEffect(()=>{C(),O$().then(m)},[C]);const E=d.useMemo(()=>v1(t,c),[t,c]),P=d.useMemo(()=>{const T=new Map;for(const U of E)T.set(U.groupId,yk(U.group,!!U.person));return T},[E]),F=d.useMemo(()=>E.filter(T=>{var U;return((U=P.get(T.groupId))==null?void 0:U.audience)==="admissions"}).map(T=>Sde(T,P.get(T.groupId))),[E,P]),I=d.useMemo(()=>Ade(F),[F]),D=d.useMemo(()=>Ede(Cde(F,b)),[F,b]),L=d.useMemo(()=>({total:F.length,dueToday:F.filter(T=>T.dueToday).length,overdue:F.filter(T=>T.overdue).length,untouched:F.filter(T=>T.communication.label==="No contact logged").length,unassigned:F.filter(T=>!T.owner).length}),[F]),V=T=>f(U=>({...U,...T})),B=()=>a||(Ct.error("Your admissions session could not be identified â sign in again."),null),A=async(T,U)=>{if(T.person)return T.person;const q=P.get(T.groupId),H=await Mh(T.group,U,null,{initialStage:q==null?void 0:q.derivedStage,initializationNote:q?q.stageReasons.join("; "):void 0});return!H.ok||!H.data?(Ct.error(H.error||"Could not create the CRM record."),null):H.data},z=async(T,U)=>{const q=B();if(!q)return;v(T.groupId);const H=await A(T,q);if(H){const G=await L$(H,U,q);G.ok?Ct.success("Saved."):Ct.error(G.error||"Update failed.")}
1303await C(),v(null)},M=async(T,U,q,H,G)=>{const W=B();if(!W)return;if(!q.trim()&&!(U==="call"&&G)){Ct.error("Add a short note describing what happened.");return}v(T.groupId);const X=await A(T,W);if(X){const Q=await j1(X.id,W,U,q,{occurredAt:H||void 0,callOutcome:G||null});Q.ok?Ct.success("Activity logged â nothing was sent."):Ct.error(Q.error||"Could not save the activity.")}await C(),v(null)},R=j&&(D.find(T=>T.id===j)||F.find(T=>T.id===j))||null;return e.jsxs("div",{children:[e.jsxs("div",{className:"rounded-xl p-3 mb-4 flex items-start gap-2.5",style:{background:"#F0FDF4",border:"1px solid #86EFAC"},children:[e.jsx(Ie,{size:15,style:{color:"#166534",marginTop:1}}),e.jsxs("p",{className:"text-[11px] leading-relaxed",style:{color:"#166534"},children:[e.jsx("strong",{children:"Admissions Worklist â one row per person."})," Stage, owner, next action, follow-up and activity are the same ",e.jsx("span",{className:"font-mono",children:"crm_people"})," / ",e.jsx("span",{className:"font-mono",children:"crm_activities"})," ","records used by the pipeline board, the application queue and the CRM Pipeline tab. The ten source tables stay read-only systems of record, and no email, SMS, campaign or nurture is sent from this screen."]})]}),c.error&&e.jsxs("div",{className:"rounded-xl p-3 mb-4 flex items-start gap-2.5",style:{background:"#FEF2F2",border:"1px solid #FCA5A5"},children:[e.jsx(Mt,{size:15,style:{color:"#991B1B",marginTop:1}}),e.jsxs("p",{className:"text-[11px]",style:{color:"#991B1B"},children:["CRM layer could not be read: ",c.error]})]}),g!=="applications"&&e.jsxs("div",{className:"grid grid-cols-2 sm:grid-cols-3 lg:grid-cols-5 gap-2.5 mb-4",children:[e.jsx(Vp,{label:"Admissions people",value:L.total,active:b.timing==="all",onClick:()=>V({timing:"all"})}),e.jsx(Vp,{label:"Follow up today",value:L.dueToday,tone:"warn",active:b.timing==="due-today",onClick:()=>V({timing:"due-today"})}),e.jsx(Vp,{label:"Overdue",value:L.overdue,tone:"alert",active:b.timing==="overdue",onClick:()=>V({timing:"overdue"})}),e.jsx(Vp,{label:"Needs first contact",value:L.untouched,tone:"warn",active:b.timing==="untouched",onClick:()=>V({timing:"untouched"})}),e.jsx(Vp,{label:"Unassigned",value:L.unassigned,active:b.timing==="unassigned",onClick:()=>V({timing:"unassigned"})})]}),e.jsxs("div",{className:"rounded-xl p-3 mb-4",style:{background:"#fff",border:`1px solid ${k}15`},children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[g!=="applications"&&e.jsxs("div",{className:"relative flex-1 min-w-[240px]",children:[e.jsx(Bt,{size:13,className:"absolute left-2.5 top-1/2 -translate-y-1/2",style:{color:"#aaa"}}),e.jsx("input",{value:b.search,onChange:T=>V({search:T.target.value}),placeholder:"Search name, phone, email, program, source, owner, stageâ¦",className:"w-full pl-8 pr-3 py-1.5 rounded-lg text-xs",style:{border:`1px solid ${k}22`,color:k}})]}),e.jsx("div",{className:"flex items-center gap-1 p-1 rounded-lg",style:{background:`${k}08`},children:[{key:"table",label:"Worklist",icon:Cy},{key:"board",label:"Pipeline",icon:NO},{key:"applications",label:"Applications",icon:mn}].map(T=>{const U=g===T.key,q=T.icon;return e.jsxs("button",{onClick:()=>N(T.key),className:"inline-flex items-center gap-1.5 px-3 py-1.5 rounded-md text-[11px] font-bold uppercase tracking-wider",style:{background:U?k:"transparent",color:U?$:k},children:[e.jsx(q,{size:11})," ",T.label]},T.key)})}),e.jsxs("button",{onClick:()=>r&&o(T=>!T),disabled:!r,className:"inline-flex items-center gap-1.5 px-3 py-1.5 rounded-lg text-[11px] font-bold disabled:opacity-60 disabled:cursor-not-allowed",style:{background:`${k}0C`,color:k,border:`1px solid ${k}22`},title:r?"Authorized admissions roles may reveal full phone and email for calling":"Your role is not authorized to reveal full contact details",children:[l?e.jsx(Md,{size:11}):e.jsx(ms,{size:11}),r?l?"Mask contact details":"Reveal full contact details":"Contact details restricted for your role"]}),e.jsxs("button",{onClick:()=>{h(!0),C()},className:"inline-flex items-center gap-1.5 px-3 py-1.5 rounded-lg text-[11px] font-bold",style:{background:`${k}0C`,color:k,border:`1px solid ${k}22`},children:[e.jsx(Be,{size:11,className:x?"animate-spin":""})," Reload"]}),g!=="applications"&&e.jsx("button",{onClick:()=>f(k4),className:"px-3 py-1.5 rounded-lg text-[11px] font-bold",style:{background:"transparent",color:q4,border:`1px solid ${$}55`},children:"Clear filters"})]}),g!=="applications"&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"grid grid-cols-2 sm:grid-cols-3 lg:grid-cols-6 gap-2 mt-3",children:[e.jsx(Dr,{label:"Program",value:b.program,onChange:T=>V({program:T}),options:[{value:"all",label:"All programs"},...I.programs.map(T=>({value:T,label:T}))]}),e.jsx(Dr,{label:"Campus",value:b.campus,onChange:T=>V({campus:T}),options:[{value:"all",label:"All campuses"},...I.campuses.map(T=>({value:T,label:T}))]}
1303),e.jsx(Dr,{label:"Source",value:b.source,onChange:T=>V({source:T}),options:[{value:"all",label:"All sources"},...I.sources.map(T=>({value:T,label:T}))]}),e.jsx(Dr,{label:"Stage",value:b.stage,onChange:T=>V({stage:T}),options:[{value:"all",label:"All stages"},...Wa.map(T=>({value:T.value,label:T.label})),{value:"not-in-crm",label:"Not yet in CRM"}]}),e.jsx(Dr,{label:"Readiness",value:b.readiness,onChange:T=>V({readiness:T}),options:[{value:"all",label:"Any readiness"},{value:"high",label:"High intent"},{value:"medium",label:"Medium intent"},{value:"low",label:"Low / early"}]}),e.jsx(Dr,{label:"Owner",value:b.owner,onChange:T=>V({owner:T}),options:[{value:"all",label:"All owners"},...I.owners.map(T=>({value:T,label:T}))]}),e.jsx(Dr,{label:"Tour",value:b.tour,onChange:T=>V({tour:T}),options:[{value:"all",label:"Any tour status"},...["requested","booked_unverified","scheduled","completed","cancelled","no_show","none"].map(T=>({value:T,label:Id[T]}))]}),e.jsx(Dr,{label:"Application",value:b.application,onChange:T=>V({application:T}),options:[{value:"all",label:"Any application"},{value:"submitted",label:"Application submitted"},{value:"started",label:"Application started"},{value:"none",label:"No application"}]}),e.jsx(Dr,{label:"Financial aid",value:b.aid,onChange:T=>V({aid:T}),options:[{value:"all",label:"Any aid status"},{value:"true",label:"Aid interest on file"},{value:"false",label:"Not indicated"}]}),e.jsx(Dr,{label:"Label",value:b.label,onChange:T=>V({label:T}),options:[{value:"all",label:"All labels"},...I.labels.map(T=>({value:T,label:T}))]}),e.jsx(Dr,{label:"Work queue",value:b.timing,onChange:T=>V({timing:T}),options:[{value:"all",label:"Everyone"},{value:"due-today",label:"Follow up today"},{value:"overdue",label:"Overdue"},{value:"untouched",label:"Needs first contact"},{value:"unassigned",label:"Unassigned"}]})]}),e.jsxs("p",{className:"text-[10px] mt-2",style:{color:"#888"},children:["Showing ",e.jsx("strong",{children:D.length})," of ",F.length," admissions people.",!r&&" Your role sees masked contact details only."]})]}),g==="applications"&&e.jsx("p",{className:"text-[10px] mt-2",style:{color:"#888"},children:"Working submitted applications. Use the queue filters below â your person-level worklist filters stay exactly as you left them."})]}),x?e.jsxs("div",{className:"rounded-xl py-20 flex flex-col items-center gap-3",style:{background:"#fff",border:`1px solid ${k}15`},children:[e.jsx(de,{size:26,className:"animate-spin",style:{color:q4}}),e.jsx("p",{className:"text-xs font-semibold",style:{color:k},children:"Loading the admissions worklistâ¦"})]}):g==="table"?e.jsx(Tde,{rows:D.slice(0,300),canRevealPII:l,onOpen:T=>S(T.id)}):g==="board"?e.jsx(Pde,{rows:D,onOpen:T=>S(T.id)}):e.jsx(bme,{people:F,canRevealPII:l,busyPersonId:y,onOpenPerson:T=>S(T.id),onViewApplication:T=>_({ids:[T.applicantId],name:T.person.name}),onLogReview:(T,U)=>M(T.person.row,"application",U,null)}),g==="table"&&D.length>300&&e.jsxs("p",{className:"text-center text-[11px] py-3",style:{color:"#888"},children:["Showing the first 300 of ",D.length," â narrow the filters or search."]}),R&&e.jsx(Mde,{item:R,staff:p,canRevealPII:l,canOpenApplication:r,busy:y===R.id,onClose:()=>S(null),onPatch:z,onLogActivity:M,onRefresh:C}),w&&r&&e.jsx(H$,{applicantIds:w.ids,personName:w.name,onClose:()=>_(null)})]})},$c="#B8962E",Rr=({bg:t,fg:s,children:n,title:a})=>e.jsx("span",{className:"inline-flex items-center gap-1 px-2 py-0.5 rounded-full text-[9px] font-bold uppercase tracking-wider",style:{background:t,color:s},title:a,children:n}),jme=({row:t,profile:s,staff:n,actorId:a,showRaw:r,busy:i,onAddToCrm:o,onPatch:l,onLogActivity:c})=>{var P;const[u,p]=d.useState(!1),{group:m,person:x}=t,[h,y]=d.useState((x==null?void 0:x.next_action)||""),[v,g]=d.useState(lb((x==null?void 0:x.follow_up_at)||null)),N=`${(x==null?void 0:x.id)||"none"}:${(x==null?void 0:x.updated_at)||""}`,[b,f]=d.useState(N);b!==N&&(f(N),y((x==null?void 0:x.next_action)||""),g(lb((x==null?void 0:x.follow_up_at)||null)));const j=lp(x),S=vk(x),w=x?hm(x.stage):null,_=!!(x!=null&&x.owner_user_id
1303)&&x.owner_user_id===a,C=j?"#FCA5A5":(x==null?void 0:x.priority)==="high"?$+"99":k+"15",E=()=>{if(!x)return;const F={};(h||"")!==(x.next_action||"")&&(F.next_action=h.trim()||null);const I=v?new Date(v).toISOString():null;I!==(x.follow_up_at||null)&&(F.follow_up_at=I),Object.keys(F).length!==0&&l(t,F)};return e.jsxs("div",{className:"rounded-xl overflow-hidden",style:{background:"#fff",border:`1px solid ${C}`,boxShadow:`0 2px 10px ${k}08`},children:[e.jsxs("div",{className:"px-4 py-3 flex items-start gap-3",children:[e.jsx("button",{onClick:()=>p(F=>!F),className:"w-9 h-9 rounded-full flex items-center justify-center shrink-0 text-xs font-bold",style:{background:`linear-gradient(135deg, ${k}, #2A0810)`,color:$},"aria-label":"Toggle details",children:m.initials}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[e.jsx("button",{onClick:()=>p(F=>!F),className:"text-sm font-bold truncate text-left",style:{color:k},children:r?(x==null?void 0:x.display_name)||m.displayName:`${m.initials} · ${((P=m.records[0])==null?void 0:P.ref)||"prospect"}`}),w&&e.jsx(Rr,{bg:w.bg,fg:w.fg,children:w.label}),!x&&e.jsx(Rr,{bg:"#F3F4F6",fg:"#4B5563",children:"Not yet in CRM"}),(x==null?void 0:x.priority)==="high"&&e.jsxs(Rr,{bg:"#FEE2E2",fg:"#991B1B",children:[e.jsx(Kx,{size:9})," High"]}),j&&e.jsxs(Rr,{bg:"#FEE2E2",fg:"#991B1B",children:[e.jsx(ve,{size:9})," Overdue ",ude(x),"d"]}),!j&&S&&e.jsxs(Rr,{bg:"#FEF3C7",fg:"#92400E",children:[e.jsx(_a,{size:9})," Due today"]}),m.isDuplicate&&e.jsxs(Rr,{bg:"#FDE68A",fg:"#92400E",children:[e.jsx(Z_,{size:9})," ",m.records.length," source records"]}),_&&e.jsx(Rr,{bg:"#D1FAE5",fg:"#065F46",children:"Mine"}),s&&e.jsxs(Rr,{bg:Yr[s.readiness.level].bg,fg:Yr[s.readiness.level].fg,title:s.readiness.signals.map(F=>F.label).join(" · ")||"No intent signals yet",children:[e.jsx(OP,{size:9})," ",Yr[s.readiness.level].label," ",s.readiness.score]}),(s==null?void 0:s.identity)==="weak"&&e.jsxs(Rr,{bg:"#FEF3C7",fg:"#92400E",title:s.identityReason,children:[e.jsx(zn,{size:9})," Review identity"]}),(s==null?void 0:s.lifecycle)==="historical"&&e.jsxs(Rr,{bg:"#F1F5F9",fg:"#475569",title:s.lifecycleReason,children:[e.jsx(en,{size:9})," Historical"]}),s&&s.audience!=="admissions"&&e.jsx(Rr,{bg:"#E0F2FE",fg:"#075985",title:SN[s.audience],children:s.audience==="partner"?"Employer / Partner":"Community list"})]}),e.jsxs("p",{className:"text-[11px] mt-1 truncate",style:{color:"#666"},children:[e.jsx(Ye,{size:9,className:"inline mr-1 -mt-0.5"}),m.emails.length?r?m.emails.join(", "):m.emails.map(g1).join(", "):"no email",m.phones.length>0&&e.jsxs(e.Fragment,{children:[" · ",e.jsx(Qt,{size:9,className:"inline mr-1 -mt-0.5"}),r?m.phones.join(", "):m.phones.map(y1).join(", ")]})]}),e.jsxs("p",{className:"text-[10px] mt-1",style:{color:"#999"},children:["Owner: ",e.jsx("strong",{style:{color:x!=null&&x.owner_name?k:"#B45309"},children:(x==null?void 0:x.owner_name)||"Unassigned"})," · ","Next: ",(x==null?void 0:x.next_action)||e.jsx("em",{style:{color:"#bbb"},children:"none set"}),(x==null?void 0:x.follow_up_at)&&e.jsxs(e.Fragment,{children:[" · Due ",Ln(x.follow_up_at)]})," · ","Last activity ",x!=null&&x.last_activity_at?Ln(x.last_activity_at):Xn(m.lastActivityAt)]})]}),e.jsxs("div",{className:"shrink-0 flex items-center gap-2",children:[!x&&e.jsxs("button",{onClick:()=>o(t),disabled:i,className:"inline-flex items-center gap-1.5 px-3 py-1.5 rounded-lg text-[11px] font-bold disabled:opacity-50",style:{background:`linear-gradient(135deg, ${$}, ${$c})`,color:k},children:[i?e.jsx(de,{size:11,className:"animate-spin"}):e.jsx(Cd,{size:11})," Add to CRM"]}),e.jsx("button",{onClick:()=>p(F=>!F),style:{color:$c},"aria-label":"Expand",children:u?e.jsx(Gt,{size:16}):e.jsx(Nr,{size:16})})]})]}),u&&e.jsxs("div",{className:"px-4 pb-4 space-y-4",style:{borderTop:`1px solid ${k}0F`},children:[x?e.jsxs("div",{className:"grid md:grid-cols-4 gap-3 pt-3",children:[e.jsxs("label",{className:"block",children:[e.jsx("span",{className:"text-[10px] font-semibold",style:{color:"#666"},children:"Owner"}),e.jsxs("select",{value:x.owner_user_id||"",disabled:i,onChange:F=>{const I=F.target.value||null,D=n.find(L=>L.id===I);l(t,{owner_user_id:I,owner_name:(D==null?void 0:D.name)||null})},className:"w-full mt-0.5 px-2 py-1.5 rounded-md text-xs bg-white",style:{border:`1px solid ${k}22`,color:k},children:[e.jsx("option",{value:"",children:"Unassigned"}),n.map(F=>e.jsx("option",{value:F.id,children:F.name},F.id))]})]}),e.jsxs("label",{className:"block",children:[e.jsx("span",{className:"text-[10px] font-semibold",style:{color:"#666"},children:"CRM stage"}),e.jsx("select",{value:x.stage,disabled:i,onChange:F=>void l(t,{stage:F.target.value}),className:"w-full mt-0.5 px-2 py-1.5 rounded-md text-xs bg-white",style:{border:`1px solid ${k}22`,color:k},children:Wa.map(F=>e.jsx("option",{value:F.value,children:F.label},F.value))}),e.jsx("span",{className:"text-[9px]",style:{color:"#aaa"},children:"Source statuses stay untouched"})]}),e.jsxs("label",{className:"block",children:[e.jsx("span",{className:"text-[10px] font-semibold",style:{color:"#666"},children:"Follow-up due"}),e.jsx("input",{type:"datetime-local",value:v,disabled:i,onChange:F=>g(F.target.value),onBlur:E,className:"w-full mt-0.5 px-2 py-1.5 rounded-md text-xs bg-white",style:{border:`1px solid ${k}22`,color:k}})]}),e.jsxs("label",{className:"block",children:[e.jsx("span",{className:"text-[10px] font-semibold",style:{color:"#666"},children:"Priority"}),e.jsxs("select",{value:x.priority,disabled:i,onChange:F=>void l(t,{priority:F.target.value}),className:"w-full mt-0.5 px-2 py-1.5 rounded-md text-xs bg-white",style:{border:`1px solid ${k}22`,color:k},children:[e.jsx("option",{value:"normal",children:"Normal"}),e.jsx("option",{value:"high",children:"High"})]})]}),e.jsxs("label",{className:"block md:col-span-4",children:[e.jsx("span",{className:"text-[10px] font-semibold",style:{color:"#666"},children:"Next action"}),e.jsxs("div",{className:"flex gap-2 mt-0.5",children:[e.jsx("input",{type:"text",value:h,disabled:i,maxLength:160,placeholder:"e.g. Call back about financial aid appointment",onChange:F=>y(F.target.value),onBlur:E,className:"flex-1 px-2 py-1.5 rounded-md text-xs bg-white",style:{border:`1px solid ${k}22`,color:k}}),e.jsx("button",{type:"button",onClick:E,disabled:i,className:"px-3 py-1.5 rounded-md text-[11px] font-bold disabled:opacity-50",style:{background:`${k}`,color:$},children:"Save"})]})]})]}):e.jsxs("p",{className:"text-[11px] pt-3",style:{color:"#777"},children:["This prospect exists in the source tables but has no CRM record yet. Use",e.jsx("strong",{children:" Add to CRM"})," to create the coordination record â the original rows are not modified."]}),s&&e.jsxs("div",{className:"grid md:grid-cols-3 gap-3",children:[e.jsxs("div",{className:"rounded-lg px-3 py-2.5",style:{background:"#FAFAFA",border:`1px solid ${k}0F`},children:[e.jsxs("p",{className:"text-[9px] uppercase tracking-[0.2em] font-bold mb-1.5",style:{color:$c},children:["Lead readiness â ",Yr[s.readiness.level].label," (",s.readiness.score,"/100)"]}),e.jsxs("ul",{className:"space-y-0.5",children:[s.readiness.signals.map((F,I)=>e.jsxs("li",{className:"text-[10px] flex items-start justify-between gap-2",style:{color:"#555"},children:[e.jsxs("span",{children:["· ",F.label]}),e.jsxs("span",{className:"font-mono shrink-0",style:{color:"#999"},children:["+",F.points]})]},I)),!s.readiness.signals.length&&e.jsx("li",{className:"text-[10px]",style:{color:"#999"},children:"No intent signals recorded yet."})]}),e.jsx("p",{className:"text-[9px] mt-1.5",style:{color:"#aaa"},children:"Built only from verified source evidence. Readiness never triggers contact by itself."})]}),e.jsxs("div",{className:"rounded-lg px-3 py-2.5",style:{background:"#FAFAFA",border:`1px solid ${k}0F`},children:[e.jsx("p",{className:"text-[9px] uppercase tracking-[0.2em] font-bold mb-1.5",style:{color:$c},children:"Evidence-derived starting stage"}),e.jsx("p",{className:"text-[11px] font-bold mb-1",style:{color:k},children:hm(s.derivedStage).label}),e.jsx("ul",{className:"space-y-0.5",children:s.stageReasons.map((F,I)=>e.jsxs("li",{className:"text-[10px]",style:{color:"#555"},children:["· ",F]},I))}),x&&x.stage!==s.derivedStage&&e.jsxs("p",{className:"text-[9px] mt-1.5",style:{color:"#B45309"},children:["The CRM stage has since been set to â",hm(x.stage).label,"â by the admissions team â that decision wins and is never overwritten."]})]}),e.jsxs("div",{className:"rounded-lg px-3 py-2.5",style:{background:"#FAFAFA",border:`1px solid ${k}0F`},children:[e.jsx("p",{className:"text-[9px] uppercase tracking-[0.2em] font-bold mb-1.5",style:{color:$c},children:"Identity & lifecycle"}),e.jsxs("p",{className:"text-[10px] leading-relaxed",style:{color:"#555"},children:[e.jsx("strong",{style:{color:s.identity==="weak"?"#92400E":"#166534"},children:s.identity==="weak"?"Weak match â review":"Strong match"})," ","· ",s.identityReason]}),e.jsxs("p",{className:"text-[10px] leading-relaxed mt-1.5",style:{color:"#555"},children:[e.jsx("strong",{style:{color:s.lifecycle==="active"?"#166534":"#4B5563"},children:s.lifecycle==="active"?"Active prospect":"Historical record"})," ","· ",s.lifecycleReason]}),e.jsxs("p",{className:"text-[10px] leading-relaxed mt-1.5",style:{color:"#777"},children:["Audience: ",SN[s.audience]]}),s.identity==="weak"&&e.jsx("p",{className:"text-[9px] mt-1.5",style:{color:"#92400E"},children:"Held out of automatic activation. Confirm this is one person before adding to the CRM."})]})]}),e.jsx(U$,{activities:t.activities,personId:(x==null?void 0:x.id)||null,busy:i,onLog:(F,I,D)=>c(t,F,I,D)}),e.jsxs("div",{children:[e.jsxs("p",{className:"text-[10px] uppercase tracking-[0.25em] font-bold mb-2 flex items-center gap-1",style:{color:$c},children:[e.jsx(Xs,{size:11}
1303)," Linked source records (",m.records.length,") â systems of record, unchanged"]}),e.jsx("div",{className:"space-y-1.5",children:m.records.map(F=>e.jsxs("div",{className:"rounded-md px-3 py-2 flex flex-wrap items-center gap-x-3 gap-y-1",style:{background:"#FAFAFA",border:`1px solid ${k}0F`},children:[e.jsx("span",{className:"text-[10px] font-bold uppercase tracking-wider",style:{color:$c},children:F.sourceLabel}),e.jsx("span",{className:"text-[10px] font-mono",style:{color:"#999"},children:F.ref}),e.jsx("span",{className:"text-[10px]",style:{color:"#777"},children:Xn(F.createdAt)}),e.jsxs("span",{className:"px-1.5 py-0.5 rounded text-[9px] font-bold uppercase",style:{background:`${k}0C`,color:k},children:["source status: ",F.status||"none"]}),F.program&&e.jsx("span",{className:"text-[10px]",style:{color:"#777"},children:F.program}),F.leadSource&&e.jsx("span",{className:"text-[10px]",style:{color:"#999"},children:F.leadSource})]},F.key))})]})]})]})},Mg=({icon:t,label:s,value:n,tone:a,hint:r})=>e.jsxs("div",{className:"rounded-lg px-3 py-2.5",style:{background:"#fff",border:`1px solid ${a}33`},title:r,children:[e.jsxs("div",{className:"flex items-center gap-1.5 mb-0.5",children:[e.jsx(t,{size:12,style:{color:a}}),e.jsx("p",{className:"text-[9px] uppercase tracking-[0.16em] font-bold",style:{color:"#888"},children:s})]}),e.jsx("p",{className:"text-xl font-bold leading-tight",style:{color:a},children:n}),e.jsx("p",{className:"text-[10px] leading-snug mt-0.5",style:{color:"#999"},children:r})]}),wme=({rows:t,profiles:s,actor:n,onFinished:a})=>{const[r,i]=d.useState(!1),[o,l]=d.useState(null),[c,u]=d.useState(null),[p,m]=d.useState(!0),x=d.useMemo(()=>{const b=[],f=[],j=[],S=[];for(const w of t){const _=s.get(w.groupId);_&&(_.eligibility==="already-in-crm"?S.push(w):_.eligibility==="not-admissions"?j.push(w):_.eligibility==="review-identity"?f.push(w):b.push(w))}return{eligible:b,review:f,notAdmissions:j,already:S}},[t,s]),h=d.useMemo(()=>x.eligible.filter(b=>{var f;return p||((f=s.get(b.groupId))==null?void 0:f.lifecycle)==="active"}),[x.eligible,s,p]),y=d.useMemo(()=>Yce(h.map(b=>s.get(b.groupId)).filter(Boolean)),[h,s]),v=x.eligible.filter(b=>{var f;return((f=s.get(b.groupId))==null?void 0:f.lifecycle)==="active"}).length,g=x.eligible.length-v,N=async()=>{if(!n){Ct.error("Your admissions session could not be identified â sign in again.");return}if(!h.length){Ct.info("Nothing to activate â every eligible prospect is already in the CRM.");return}i(!0),u(null);let b=0,f=0,j=0;for(let S=0;S<h.length;S++){const w=h[S],_=s.get(w.groupId);l({done:S,total:h.length});const C=_?`${ob[_.derivedStage]} · ${_.stageReasons.join("; ")} · ${_.lifecycleReason}`:void 0,E=await Mh(w.group,n,null,{initialStage:_==null?void 0:_.derivedStage,initializationNote:C});E.ok?E.created?b+=1:f+=1:j+=1}l(null),i(!1),u({created:b,reused:f,failed:j}),Ct.success(`Activation complete â ${b} created, ${f} already existed, ${j} failed.`),await a()};return e.jsxs("div",{className:"rounded-xl p-4 mb-4",style:{background:"#fff",border:`1px solid ${k}1F`},children:[e.jsx("div",{className:"flex flex-wrap items-start justify-between gap-3 mb-3",children:e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"text-[10px] uppercase tracking-[0.28em] font-bold",style:{color:"#B8962E"},children:"Step 1 · Activate the pipeline"}),e.jsx("h3",{className:"text-base font-bold",style:{color:k},children:"Bring existing admissions prospects into the CRM"}),e.jsx("p",{className:"text-[11px] mt-1 leading-relaxed",style:{color:"#666",maxWidth:640},children:"Creates one CRM person per admissions prospect, links every original source row to it, and sets the starting stage from evidence that already exists in those rows. Employer/partner and community records are excluded. Weak identity matches are held for review. Safe to re-run â existing people are reused, never duplicated, and no email or SMS is sent."})]})}),e.jsxs("div",{className:"grid grid-cols-2 lg:grid-cols-4 gap-2.5 mb-3",children:[e.jsx(Mg,{icon:Qe,label:"Ready to activate",value:x.eligible.length,tone:"#166534",hint:"Admissions prospects with a single verified email identity"}),e.jsx(Mg,{icon:zn,label:"Held for review",value:x.review.length,tone:"#92400E",hint:"Ambiguous identity â a person must confirm before CRM entry"}),e.jsx(Mg,{icon:Ws,label:"Excluded (partner)",value:x.notAdmissions.length,tone:"#0E7490",hint:"Employer, partner, foundation or community records"}),e.jsx(Mg,{icon:dx,label:"Already in CRM",value:x.already.length,tone:k,hint:"A CRM person already resolves for these prospects"})]}),e.jsxs("label",{className:"flex items-start gap-2 rounded-lg px-3 py-2 mb-3 cursor-pointer",style:{background:`${k}06`,border:`1px solid ${k}15`},children:[e.jsx("input",{type:"checkbox",checked:p,onChange:b=>m(b.target.checked),className:"mt-0.5",disabled:r}),e.jsxs("span",{className:"text-[11px] leading-relaxed",style:{color:"#555"},children:[e.jsx("strong",{style:{color:k},children:"Include historical prospects"})," (",g," of"," ",x.eligible.length,"). Historical people are imported for reporting and future re-engagement and are clearly tagged ",e.jsx("em",{children:"Historical"})," â they are never treated as new hot leads and nothing is sent to them. Uncheck to activate only the ",v," with recent source activity."]})]}),h.length>0&&e.jsxs("div",{className:"flex flex-wrap gap-1 mb-3",children:[e.jsx("span",{className:"text-[10px] font-semibold self-center mr-1",style:{color:"#888"},children:"Starting stages for this run:"}),Wa.filter(b=>y[b.value]).map(b=>e.jsxs("span",{className:"px-1.5 py-0.5 rounded text-[9px] font-bold uppercase tracking-wider",style:{background:b.bg,color:b.fg},children:[b.label,": ",y[b.value]]},b.value))]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-3",children:[e.jsxs("button",{onClick:N,disabled:r||!h.length||!n,className:"inline-flex items-center gap-2 px-4 py-2 rounded-lg text-xs font-bold disabled:opacity-50",style:{background:`linear-gradient(135deg, ${k}, #2A0810)`,color:"#E6D2A0"},children:[r?e.jsx(de,{size:13,className:"animate-spin"}):e.jsx(Ue,{size:13}),r?`Activating ${o?`${o.done+1}/${o.total}`:""}â¦`:`Activate ${h.length} admissions ${h.length===1?"prospect":"prospects"}`]}),x.review.length>0&&e.jsxs("span",{className:"inline-flex items-center gap-1.5 text-[11px] font-semibold",style:{color:"#92400E"},children:[e.jsx(zn,{size:12}),x.review.length," held â open the â",Mce["review-identity"],"â cards below to decide manually"]})]}),c&&e.jsxs("div",{className:"rounded-lg px-3 py-2 mt-3 flex items-start gap-2",style:{background:"#F0FDF4",border:"1px solid #86EFAC"},children:[e.jsx(en,{size:13,style:{color:"#166534",marginTop:1}}),e.jsxs("p",{className:"text-[11px] leading-relaxed",style:{color:"#166534"},children:[e.jsxs("strong",{children:[c.created," new CRM ",c.created===1?"person":"people"," created"]}),c.reused>0&&e.jsxs(e.Fragment,{children:[" · ",c.reused," already existed and were reused (no duplicates)"]}),c.failed>0&&e.jsxs(e.Fragment,{children:[" · ",e.jsxs("span",{style:{color:"#991B1B"},children:[c.failed," failed"]})]}),". Each new person carries a system activity naming the evidence behind its starting stage."]})]})]})},Yj="#B8962E",vu=({label:t,value:s,tone:n="plain",hint:a})=>{const r=n==="alert"?{bg:"#FEF2F2",border:"#FCA5A5",fg:"#991B1B"}:n==="warn"?{bg:"#FFFBEB",border:"#FDE68A",fg:"#92400E"}:{bg:"#fff",border:`${k}15`,fg:k};return e.jsxs("div",{className:"rounded-xl px-3 py-2.5",style:{background:r.bg,border:`1px solid ${r.border}`},title:a,children:[e.jsx("p",{className:"text-[9px] uppercase tracking-[0.18em] font-bold",style:{color:"#888"},children:t}),e.jsx("p",{className:"text-xl font-bold leading-tight",style:{color:r.fg},children:s})]})},Nme=[{value:"admissions",label:"Admissions"},{value:"partner",label:"Employer / Partner"},{value:"community",label:"Community List"},{value:"all",label:"Everyone"}],_me=({groups:t,showRaw:s})=>{var B;const{user:n}=kn(),a=n?{id:n.id,name:n.fullName||n.email,email:n.email}
1303:null,[r,i]=d.useState(b1),[o,l]=d.useState([]),[c,u]=d.useState(!0),[p,m]=d.useState(null),[x,h]=d.useState("all"),[y,v]=d.useState(""),[g,N]=d.useState("admissions"),b=d.useCallback(async()=>{const A=await df();i(A),u(!1)},[]);d.useEffect(()=>{b(),O$().then(l)},[b]);const f=d.useMemo(()=>v1(t,r),[t,r]),j=d.useMemo(()=>{const A=new Map;for(const z of f)A.set(z.groupId,yk(z.group,!!z.person));return A},[f]),S=d.useMemo(()=>{var z;const A={admissions:0,partner:0,community:0,all:f.length};for(const M of f){const R=((z=j.get(M.groupId))==null?void 0:z.audience)||"community";A[R]=(A[R]||0)+1}return A},[f,j]),w=d.useMemo(()=>g==="all"?f:f.filter(A=>{var z;return((z=j.get(A.groupId))==null?void 0:z.audience)===g}),[f,j,g]),_=d.useMemo(()=>({historicalIds:new Set(w.filter(A=>{var z;return((z=j.get(A.groupId))==null?void 0:z.lifecycle)==="historical"}).map(A=>A.groupId))}),[w,j]),C=d.useMemo(()=>xde(w,(a==null?void 0:a.id)||null,_),[w,a==null?void 0:a.id,_]),E=d.useMemo(()=>{const A=y.trim().toLowerCase(),z=M=>{var T;const R=(T=j.get(M.groupId))==null?void 0:T.readiness.level;return R==="high"?0:R==="medium"?1:2};return w.filter(M=>z$(M,x,(a==null?void 0:a.id)||null,_)).filter(M=>{var T,U,q;return A?[(T=M.person)==null?void 0:T.display_name,(U=M.person)==null?void 0:U.next_action,(q=M.person)==null?void 0:q.owner_name,M.group.displayName,...M.group.emails,...M.group.phones,...M.group.records.map(H=>`${H.name} ${H.program||""} ${H.leadSource||""} ${H.ref}`)].filter(Boolean).join(" ").toLowerCase().includes(A):!0}).sort((M,R)=>{var Q,K;const T=se=>{var Y;return(lp(se.person)?0:2)-(((Y=se.person)==null?void 0:Y.priority)==="high"?1:0)},U=T(M)-T(R);if(U!==0)return U;const q=z(M)-z(R);if(q!==0)return q;const H=(Q=M.person)!=null&&Q.follow_up_at?new Date(M.person.follow_up_at).getTime():1/0,G=(K=R.person)!=null&&K.follow_up_at?new Date(R.person.follow_up_at).getTime():1/0;if(H!==G)return H-G;const W=M.group.lastActivityAt?new Date(M.group.lastActivityAt).getTime():0;return(R.group.lastActivityAt?new Date(R.group.lastActivityAt).getTime():0)-W})},[w,x,y,a==null?void 0:a.id,_,j]),P=()=>a||(Ct.error("Your admissions session could not be identified â sign in again."),null),F=async A=>{const z=P();if(!z)return;m(A.groupId);const M=j.get(A.groupId),R=await Mh(A.group,z,null,{initialStage:M==null?void 0:M.derivedStage,initializationNote:M?`${M.stageReasons.join("; ")} · ${M.lifecycleReason}`:void 0});R.ok?Ct.success("Added to the admissions CRM."):Ct.error(R.error||"Could not add prospect to the CRM."),await b(),m(null)},I=async(A,z)=>{const M=P();if(!M)return;m(A.groupId);let R=A.person;if(!R){const U=j.get(A.groupId),q=await Mh(A.group,M,null,{initialStage:U==null?void 0:U.derivedStage,initializationNote:U?U.stageReasons.join("; "):void 0});if(!q.ok||!q.data){Ct.error(q.error||"Could not create the CRM record."),m(null);return}R=q.data}const T=await L$(R,z,M);T.ok||Ct.error(T.error||"Update failed."),await b(),m(null)},D=async(A,z,M,R)=>{const T=P();if(!T)return;if(!M.trim()){Ct.error("Add a short note describing what happened.");return}m(A.groupId);let U=A.person;if(!U){const H=j.get(A.groupId),G=await Mh(A.group,T,null,{initialStage:H==null?void 0:H.derivedStage,initializationNote:H?H.stageReasons.join("; "):void 0});if(!G.ok||!G.data){Ct.error(G.error||"Could not create the CRM record."),m(null);return}U=G.data}const q=await j1(U.id,T,z,M,{occurredAt:R||void 0});q.ok?Ct.success("Activity logged."):Ct.error(q.error||"Could not save the activity."),await b(),m(null)},L=w.filter(A=>{var z;return((z=j.get(A.groupId))==null?void 0:z.lifecycle)==="active"}).length,V=w.filter(A=>{var z;return((z=j.get(A.groupId))==null?void 0:z.identity)==="weak"}).length;return e.jsxs("div",{children:[e.jsxs("div",{className:"rounded-xl p-3 mb-4 flex items-start gap-2.5",style:{background:"#F0FDF4",border:"1px solid #86EFAC"},children:[e.jsx(Ie,{size:15,style:{color:"#166534",marginTop:1}}),e.jsxs("p",{className:"text-[11px] leading-relaxed",style:{color:"#166534"},children:[e.jsx("strong",{children:"CRM Pipeline is the active admissions working layer."})," Source Inventory remains the historical system of record. Ownership, stage, follow-up and activity live in the separate"," ",e.jsx("span",{className:"font-mono",children:"crm_*"})," tables â nothing here merges, dedupes, edits a source status, deletes, or sends email/SMS."]})]}),r.error&&e.jsxs("div",{className:"rounded-xl p-3 mb-4 flex items-start gap-2.5",style:{background:"#FEF2F2",border:"1px solid #FCA5A5"},children:[e.jsx(Mt,{size:15,style:{color:"#991B1B",marginTop:1}}),e.jsxs("p",{className:"text-[11px]",style:{color:"#991B1B"},children:["CRM layer could not be read: ",r.error]})]}),e.jsxs("div",{className:"rounded-xl p-3 mb-4",style:{background:"#fff",border:`1px solid ${k}15`},children:[e.jsx("p",{className:"text-[9px] uppercase tracking-[0.22em] font-bold mb-2",style:{color:Yj},children:"Audience scope"}),e.jsx("div",{className:"flex flex-wrap gap-1.5",children:Nme.map(A=>{const z=g===A.value;return e.jsxs("button",{onClick:()=>N(A.value),title:A.value==="all"?"Every grouped person across all 10 sources":SN[A.value],className:"px-3 py-1.5 rounded-full text-[10px] font-bold uppercase tracking-wider transition-all",style:{background:z?`linear-gradient(135deg, ${k}, #2A0810)`:`${k}0A`,color:z?$:k,border:`1px solid ${z?k:k+"18"}`},children:[A.label," ",e.jsxs("span",{style:{opacity:.65},children:["(",S[A.value]??0,")"]})]},A.value)})}),e.jsx("p",{className:"text-[10px] mt-2 leading-relaxed",style:{color:"#888"},children:"Admissions is the default scope. Employer, partner, foundation and community-list people stay fully visible here and in Source Inventory, but they never count toward admissions KPIs."})]}),g==="admissions"&&e.jsx(wme,{rows:w,profiles:j,actor:a,onFinished:b}),e.jsxs("div",{className:"grid grid-cols-2 sm:grid-cols-3 lg:grid-cols-6 gap-2.5 mb-4",children:[e.jsx(vu,{label:"People in scope",value:C.total,hint:"Grouped identities, not source rows"}),e.jsx(vu,{label:"In CRM",value:C.inCrm,hint:"Have a crm_people record"}),e.jsx(vu,{label:"Active",value:L,hint:"Source activity inside the 90-day active window"}),e.jsx(vu,{label:"Needs 1st contact",value:C.viewCounts["needs-first-contact"],tone:"warn",hint:"In the CRM with no human activity logged yet"}),e.jsx(vu,{label:"Due today",value:C.dueToday,tone:"warn",hint:"Follow-up scheduled for today"}),e.jsx(vu,{label:"Overdue",value:C.overdue,tone:"alert",hint:"Follow-up date has passed"})]}),e.jsxs("div",{className:"rounded-xl p-3 mb-4",style:{background:"#fff",border:`1px solid ${k}15`},children:[e.jsx("div",{className:"flex flex-wrap gap-1.5",children:Lx.map(A=>{const z=x===A.value;return e.jsxs("button",{onClick:()=>h(A.value),title:A.hint,className:"px-2.5 py-1 rounded-full text-[10px] font-bold uppercase tracking-wider transition-all",style:{background:z?`linear-gradient(135deg, ${k}, #2A0810)`:`${k}0A`,color:z?$:k,border:`1px solid ${z?k:k+"18"}`},children:[A.label," ",e.jsxs("span",{style:{opacity:.65},children:["(",C.viewCounts[A.value],")"]})]},A.value)})}),e.jsxs("p",{className:"text-[10px] mt-2",style:{color:"#888"},children:[(B=Lx.find(A=>A.value===x))==null?void 0:B.hint,V>0&&e.jsxs(e.Fragment,{children:[" · ",e.jsxs("span",{style:{color:"#92400E",fontWeight:700},children:[V," in this scope need identity review before activation"]})]})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2 mt-3",children:[e.jsxs("div",{className:"relative flex-1 min-w-[220px]",children:[e.jsx(Bt,{size:13,className:"absolute left-2.5 top-1/2 -translate-y-1/2",style:{color:"#aaa"}}),e.jsx("input",{value:y,onChange:A=>v(A.target.value),placeholder:"Search name, email, phone, program, next actionâ¦",className:"w-full pl-8 pr-3 py-1.5 rounded-lg text-xs",style:{border:`1px solid ${k}22`,color:k}})]}),e.jsxs("button",{onClick:()=>{u(!0),b()},className:"inline-flex items-center gap-1.5 px-3 py-1.5 rounded-lg text-[11px] font-bold",style:{background:`${k}0C`,color:k,border:`1px solid ${k}22`},children:[e.jsx(Be,{size:11,className:c?"animate-spin":""})," Reload CRM"]})]}),e.jsx("div",{className:"flex flex-wrap gap-1 mt-3",children:Wa.filter(A=>C.byStage[A.value]>0).map(A=>e.jsxs("span",{className:"px-1.5 py-0.5 rounded text-[9px] font-bold uppercase tracking-wider",style:{background:A.bg,color:A.fg},children:[A.label,": ",C.byStage[A.value]]},A.value))})]}),c?e.jsxs("div",{className:"rounded-xl py-20 flex flex-col items-center gap-3",style:{background:"#fff",border:`1px solid ${k}15`},children:[e.jsx(de,{size:26,className:"animate-spin",style:{color:Yj}}),e.jsx("p",{className:"text-xs font-semibold",style:{color:k},children:"Loading CRM coordination layerâ¦"})]}):E.length===0?e.jsxs("div",{className:"rounded-xl py-16 text-center",style:{background:"#fff",border:`1px solid ${k}15`},children:[e.jsx(ts,{size:30,className:"mx-auto mb-3",style:{color:Yj,opacity:.4}}),e.jsx("p",{className:"text-sm font-semibold",style:{color:k},children:"Nothing in this view."}),e.jsx("p",{className:"text-xs mt-1",style:{color:"#666"},children:"Switch views, change the audience scope, or clear the search."})]}):e.jsxs("div",{className:"space-y-2.5",children:[E.slice(0,200).map(A=>e.jsx(jme,{row:A,profile:j.get(A.groupId),staff:o,actorId:(a==null?void 0:a.id)||null,showRaw:s,busy:p===A.groupId,onAddToCrm:F,onPatch:I,onLogActivity:D},A.groupId)),E.length>200&&e.jsxs("p",{className:"text-center text-[11px] py-3",style:{color:"#888"},children:["Showing the first 200 of ",E.length," â narrow the view or search."]})]})]})},rz=["new","contacted","qualified","tour_scheduled","tour_completed","application","financial_aid","accepted","enrolled"],kme=rz.reduce((t,s,n)=>(t[s]=n,t),{}),W4=Wa.reduce((t,s)=>(t[s.label]=s.value,t),{}),Sme=/Stage:\s*(.+?)\s*â\s*([^·]+)/;function Cme(t){if(t.activity_type!=="system"||!t.notes)return null;const s=t.notes.match(Sme);return s?{from:W4[s[1].trim()]??null,to:W4[s[2].trim()]??null}:null}const Mr=t=>{if(!t)return null;const s=new Date(t).getTime();return Number.isNaN(s)?null:s},to=(...t)=>{let s=null;for(const n of t)n!==null&&(s===null||n<s)&&(s=n);return s},iz=864e5,N1="Unattributed / Unknown",_k="Unknown / Not stated";function Ame(t){var n;const s=t.group.records.find(a=>a.program&&a.program.trim());return((n=s==null?void 0:s.program)==null?void 0:n.trim())||_k}function Eme(t){const s=[...t.group.records].sort((n,a)=>{const r=Mr(n.createdAt)??0,i=Mr(a.createdAt)??0;return r-i});for(const n of s)if(n.leadSource&&n.leadSource.trim())return{label:n.leadSource.trim(),detail:n.utm||n.formType||null,attributed:!0}
1303;for(const n of s)if(n.utm&&n.utm.trim())return{label:n.utm.trim(),detail:n.formType,attributed:!0};for(const n of s)if(n.formType&&n.formType.trim())return{label:`form: ${n.formType.trim()}`,detail:n.sourceLabel,attributed:!0};return{label:N1,detail:null,attributed:!1}}function H4(t){const s=dde(t),n=[t.utm_content?`content: ${t.utm_content}`:null,t.utm_term?`term: ${t.utm_term}`:null,t.landing_path?`landing: ${t.landing_path}`:null,t.form_type?`form: ${t.form_type}`:null,t.channel?`channel: ${t.channel}`:null].filter(Boolean);return{label:s||N1,detail:n.length?n.join(" · "):null,attributed:!!s}}function Fme(t){const s=lde(t.attribution),n=cde(t.attribution);if(s||n){const r=s?H4(s):null,i=n?H4(n):null;if(r!=null&&r.attributed||i!=null&&i.attributed)return{first:r!=null&&r.attributed?r:i,latest:i!=null&&i.attributed?i:r,basis:"crm"}}const a=Eme(t);return{first:a,latest:a,basis:a.attributed?"legacy":"none"}}function Tme(t,s=Date.now()){var E;const n=t.person,a=(n==null?void 0:n.stage)??"new",r=t.activities,i=new Map;for(const P of r){const F=Cme(P);if(!(F!=null&&F.to))continue;const I=Mr(P.occurred_at);if(I===null)continue;const D=i.get(F.to);(D===void 0||I<D)&&i.set(F.to,I)}const o=P=>to(...t.group.records.filter(P).map(F=>Mr(F.createdAt))),l=to(Mr(t.group.firstSeen),...t.group.records.map(P=>Mr(P.createdAt)),Mr((n==null?void 0:n.created_at)??null)),c=to(...r.filter(P=>!P.is_system&&["call","text","email"].includes(P.activity_type)).map(P=>Mr(P.occurred_at))),u=i.get("new")??l,p=to(i.get("contacted")??null,c),m=to(i.get("tour_scheduled")??null,i.get("tour_completed")??null,o(P=>P.isTour)),x=to(i.get("application")??null,o(P=>P.isApplication)),h=to(i.get("financial_aid")??null,o(P=>P.isFinancialAid)),y=i.get("accepted")??null,v=to(i.get("enrolled")??null,o(P=>P.isEnrollment)),g=new Set(["new"]);i.forEach((P,F)=>g.add(F));const N=kme[a];if(N!==void 0)for(let P=0;P<=N;P+=1)g.add(rz[P]);m!==null&&g.add("tour_scheduled"),x!==null&&g.add("application"),h!==null&&g.add("financial_aid"),y!==null&&g.add("accepted"),v!==null&&g.add("enrolled"),p!==null&&g.add("contacted"),a==="not_moving_forward"&&g.add("not_moving_forward");const b=to(i.get(a)??null,Mr((n==null?void 0:n.stage_updated_at)??null),Mr((n==null?void 0:n.created_at)??null),l),f=Mr((n==null?void 0:n.follow_up_at)??null),j=a==="enrolled"||a==="not_moving_forward",S=new Date(s);S.setHours(0,0,0,0);const w=new Date(s);w.setHours(23,59,59,999);const _=r.filter(P=>!P.is_system&&P.activity_type!=="system"),C=Fme(t);return{row:t,stage:a,inCrm:!!n,newAt:u,contactedAt:p,tourAt:m,applicationAt:x,financialAidAt:h,acceptedAt:y,enrolledAt:v,reached:g,daysInStage:b===null?null:Math.max(0,(s-b)/iz),program:Ame(t),source:C.first.label,sourceDetail:C.first.detail,latestSource:C.latest.label,latestSourceDetail:C.latest.detail,attributed:C.first.attributed||C.latest.attributed,attributionBasis:C.basis,attributionEventCount:t.attribution.length,ownerId:(n==null?void 0:n.owner_user_id)??null,ownerName:((E=n==null?void 0:n.owner_name)==null?void 0:E.trim())||"Unassigned",loggedActivityCount:_.length,hasLoggedActivity:_.length>0,overdue:!j&&f!==null&&f<s,dueToday:!j&&f!==null&&f>=S.getTime()&&f<=w.getTime(),highPriority:(n==null?void 0:n.priority)==="high",notMovingForward:a==="not_moving_forward"}}const Pme=[{value:"7",label:"Last 7 days"},{value:"30",label:"Last 30 days"},{value:"90",label:"Last 90 days"},{value:"ytd",label:"Year to date"},{value:"all",label:"All time"},{value:"custom",label:"Custom range"}],Dme={range:"90",from:"",to:""};function Rme(t,s=Date.now()){const n=new Date(s);switch(n.setHours(0,0,0,0),t.range){case"7":case"30":case"90":{const a=Number(t.range),r=new Date(n);return r.setDate(r.getDate()-(a-1)),{from:r.getTime(),to:null,label:`Last ${a} days`}}case"ytd":{const a=new Date(new Date(s).getFullYear(),0,1);return{from:a.getTime(),to:null,label:`Year to date (${a.getFullYear()})`}}case"custom":{const a=t.from?new Date(`${t.from}T00:00:00`).getTime():null,r=t.to?new Date(`${t.to}T23:59:59`).getTime():null;return{from:Number.isNaN(a)?null:a,to:Number.isNaN(r)?null:r,label:`${t.from||"start"} â ${t.to||"today"}`}}default:return{from:null,to:null,label:"All time"}}}function Ime(t,s){const n=t.newAt;return n===null?s.from===null&&s.to===null:!(s.from!==null&&n<s.from||s.to!==null&&n>s.to)}const G4=t=>t.length?t.reduce((s,n)=>s+n,0)/t.length:null,$me=t=>{if(!t.length)return null;const s=[...t].sort((a,r)=>a-r),n=Math.floor(s.length/2);return s.length%2?s[n]:(s[n-1]+s[n])/2},hl=(t,s)=>s>0?t/s*100:null,zme=(t,s)=>{if(t===null||s===null)return null;const n=(s-t)/iz;return n>=0?n:null};function V4(t,s,n,a){const r=n.filter(l=>l.reached.has("tour_scheduled")).length,i=n.filter(l=>l.reached.has("application")).length,o=n.filter(l=>l.reached.has("enrolled")).length;
1303return{label:t,detail:s,people:n.length,tours:r,applications:i,enrollments:o,conversion:hl(o,n.length),attributed:a}}function Lme(t,s){const n=b=>t.filter(f=>f.reached.has(b)).length,a=t.filter(b=>b.reached.has("tour_scheduled")||b.reached.has("tour_completed")).length,r=Wa.map(b=>{const f=t.filter(S=>S.stage===b.value),j=f.map(S=>S.daysInStage).filter(S=>S!==null);return{stage:b.value,label:b.label,current:f.length,reached:b.value==="not_moving_forward"?t.filter(S=>S.notMovingForward).length:n(b.value),avgDaysInStage:G4(j),avgSample:j.length}}),i=t.length,o=[{key:"new-contacted",label:"New â Contacted",numeratorLabel:"reached Contacted",denominatorLabel:"all prospects in range",numerator:n("contacted"),denominator:i,rate:hl(n("contacted"),i),formula:"people who ever reached Contacted ÷ all prospects created in range à 100"},{key:"contacted-tour",label:"Contacted â Tour",numeratorLabel:"reached a Tour stage",denominatorLabel:"reached Contacted",numerator:a,denominator:n("contacted"),rate:hl(a,n("contacted")),formula:"people who reached Tour Scheduled or Tour Completed ÷ people who reached Contacted à 100"},{key:"tour-application",label:"Tour â Application",numeratorLabel:"reached Application",denominatorLabel:"reached a Tour stage",numerator:n("application"),denominator:a,rate:hl(n("application"),a),formula:"people who reached Application ÷ people who reached a Tour stage à 100"},{key:"application-accepted",label:"Application â Accepted",numeratorLabel:"reached Accepted",denominatorLabel:"reached Application",numerator:n("accepted"),denominator:n("application"),rate:hl(n("accepted"),n("application")),formula:"people who reached Accepted ÷ people who reached Application à 100"},{key:"accepted-enrolled",label:"Accepted â Enrolled",numeratorLabel:"reached Enrolled",denominatorLabel:"reached Accepted",numerator:n("enrolled"),denominator:n("accepted"),rate:hl(n("enrolled"),n("accepted")),formula:"people who reached Enrolled ÷ people who reached Accepted à 100"},{key:"lead-enrolled",label:"Overall Lead â Enrolled",numeratorLabel:"reached Enrolled",denominatorLabel:"all prospects in range",numerator:n("enrolled"),denominator:i,rate:hl(n("enrolled"),i),formula:"people who reached Enrolled ÷ all prospects created in range à 100"}],l=(b,f)=>t.map(j=>zme(b(j),f(j))).filter(j=>j!==null),u=[{key:"new-contacted",label:"New â Contacted",values:l(b=>b.newAt,b=>b.contactedAt),basis:"first-seen date â first Contacted transition or first logged call/text/email"},{key:"new-tour",label:"New â Tour",values:l(b=>b.newAt,b=>b.tourAt),basis:"first-seen date â first Tour stage transition or linked tour record date"},{key:"tour-application",label:"Tour â Application",values:l(b=>b.tourAt,b=>b.applicationAt),basis:"tour date â Application transition or linked application record date"},{key:"application-enrolled",label:"Application â Enrolled",values:l(b=>b.applicationAt,b=>b.enrolledAt),basis:"application date â Enrolled transition or linked enrollment record date"}].map(b=>({key:b.key,label:b.label,avgDays:G4(b.values),medianDays:$me(b.values),sample:b.values.length,basis:b.basis})),p=new Map;for(const b of t){const f=p.get(b.program)||[];f.push(b),p.set(b.program,f)}const m=Array.from(p.entries()).map(([b,f])=>V4(b,null,f,b!==_k)).sort((b,f)=>f.people-b.people||b.label.localeCompare(f.label)),x=(b,f)=>{const j=new Map;for(const S of t){const w=b(S),_=j.get(w)||[];_.push(S),j.set(w,_)}return Array.from(j.entries()).map(([S,w])=>V4(S,w.map(f).find(Boolean)??null,w,S!==N1)).sort((S,w)=>w.people-S.people||S.label.localeCompare(w.label))},h=x(b=>b.source,b=>b.sourceDetail),y=x(b=>b.latestSource,b=>b.latestSourceDetail),v=new Map;for(const b of t){const f=b.ownerId||"unassigned",j=v.get(f)||[];j.push(b),v.set(f,j)}const g=Array.from(v.entries()).map(([b,f])=>({ownerId:b==="unassigned"?null:b,ownerName:b==="unassigned"?"Unassigned":f[0].ownerName||"Unknown user",total:f.length,overdue:f.filter(j=>j.overdue).length,dueToday:f.filter(j=>j.dueToday).length,highPriority:f.filter(j=>j.highPriority).length,noActivity:f.filter(j=>!j.hasLoggedActivity).length,active:f.filter(j=>!j.notMovingForward&&j.stage!=="enrolled").length,enrolled:f.filter(j=>j.stage==="enrolled").length})).sort((b,f)=>!b.ownerId&&f.ownerId?-1:b.ownerId&&!f.ownerId?1:f.total-b.total||b.ownerName.localeCompare(f.ownerName)),N=t.filter(b=>b.attributed).length;return{rangeLabel:s,people:i,inCrm:t.filter(b=>b.inCrm).length,notInCrm:t.filter(b=>
1303!b.inCrm).length,stageMetrics:r,notMovingForward:t.filter(b=>b.notMovingForward).length,conversions:o,timeMetrics:u,programs:m,sources:h,sourcesLatest:y,workload:g,unassigned:t.filter(b=>!b.ownerId).length,overdue:t.filter(b=>b.overdue).length,dueToday:t.filter(b=>b.dueToday).length,highPriority:t.filter(b=>b.highPriority).length,noActivity:t.filter(b=>!b.hasLoggedActivity).length,attributedPeople:N,unattributedPeople:i-N,crmAttributedPeople:t.filter(b=>b.attributionBasis==="crm").length,legacyAttributedPeople:t.filter(b=>b.attributionBasis==="legacy").length,coveragePct:hl(N,i)}}const mb=t=>t===null?"n/a":`${t.toFixed(1)}%`,Kj=t=>t===null?"n/a":t<1?`${Math.round(t*24)}h`:`${t.toFixed(1)}d`,Ome=N1,Mme=_k,V0="#B8962E",Qj=({title:t,subtitle:s,icon:n,children:a})=>e.jsxs("div",{className:"rounded-xl p-4 mb-4",style:{background:"#fff",border:`1px solid ${k}15`},children:[e.jsxs("div",{className:"flex items-start gap-2 mb-3",children:[e.jsx("span",{style:{color:V0,marginTop:2},children:n}),e.jsxs("div",{children:[e.jsx("h3",{className:"text-sm font-bold",style:{color:k},children:t}),s&&e.jsx("p",{className:"text-[10px] mt-0.5",style:{color:"#888"},children:s})]})]}),a]}),Bme=({report:t})=>{const s=Math.max(1,...t.stageMetrics.map(n=>n.reached));return e.jsxs(e.Fragment,{children:[e.jsx(Qj,{title:"Core funnel",subtitle:"âCurrentâ = people whose CRM stage is exactly this. âReachedâ = people who have ever been at this stage (stage history, current stage, or a linked source record proving it).",icon:e.jsx(si,{size:15}),children:e.jsx("div",{className:"space-y-1.5",children:t.stageMetrics.map(n=>{const a=hm(n.stage),r=Math.round(n.reached/s*100);return e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"w-[190px] shrink-0",children:e.jsx("span",{className:"px-1.5 py-0.5 rounded text-[9px] font-bold uppercase tracking-wider",style:{background:a.bg,color:a.fg},children:n.label})}),e.jsxs("div",{className:"flex-1 h-6 rounded-md relative overflow-hidden",style:{background:`${k}08`},children:[e.jsx("div",{className:"h-full rounded-md transition-all",style:{width:`${r}%`,background:`linear-gradient(90deg, ${k}, ${k}AA)`}}),e.jsxs("span",{className:"absolute inset-y-0 left-2 flex items-center text-[10px] font-bold",style:{color:r>25?$:k},children:["reached ",n.reached]})]}),e.jsxs("div",{className:"w-[80px] text-right shrink-0",children:[e.jsx("p",{className:"text-sm font-bold leading-none",style:{color:k},children:n.current}),e.jsx("p",{className:"text-[9px]",style:{color:"#999"},children:"currently"})]}),e.jsxs("div",{className:"w-[96px] text-right shrink-0",children:[e.jsx("p",{className:"text-[11px] font-bold leading-none",style:{color:n.avgDaysInStage===null?"#bbb":V0},children:Kj(n.avgDaysInStage)}),e.jsxs("p",{className:"text-[9px]",style:{color:"#999"},children:["avg in stage ",n.avgSample?`(n=${n.avgSample})`:""]})]})]},n.stage)})})}),e.jsx(Qj,{title:"Conversion metrics",subtitle:"Cohort-based: the denominator is the population that reached the earlier step, not the whole database. A dash means the denominator is 0 â no rate is invented.",icon:e.jsx(Vt,{size:15}),children:e.jsx("div",{className:"grid sm:grid-cols-2 lg:grid-cols-3 gap-2.5",children:t.conversions.map(n=>e.jsxs("div",{className:"rounded-lg p-3",style:{background:`${k}06`,border:`1px solid ${k}12`},children:[e.jsx("p",{className:"text-[10px] font-bold uppercase tracking-[0.15em]",style:{color:V0},children:n.label}),e.jsx("p",{className:"text-2xl font-bold leading-tight mt-0.5",style:{color:n.rate===null?"#bbb":k},children:mb(n.rate)}),e.jsxs("p",{className:"text-[10px] mt-0.5",style:{color:"#666"},children:[n.numerator," ",n.numeratorLabel," ÷ ",n.denominator," ",n.denominatorLabel]}),e.jsx("p",{className:"text-[9px] mt-1.5 leading-snug",style:{color:"#999"},children:n.formula})]},n.key))})}),e.jsx(Qj,{title:"Time metrics",subtitle:"Averages only include people where BOTH endpoints could be resolved; the sample size is shown so small-n figures are not over-read.",icon:e.jsx(dt,{size:15}),children:e.jsx("div",{className:"grid sm:grid-cols-2 lg:grid-cols-4 gap-2.5",children:t.timeMetrics.map(n=>e.jsxs("div",{className:"rounded-lg p-3",style:{background:"#FFFDF7",border:`1px solid ${$}33`},children:[e.jsx("p",{className:"text-[10px] font-bold uppercase tracking-[0.15em]",style:{color:V0},children:n.label}),e.jsx("p",{className:"text-2xl font-bold leading-tight mt-0.5",style:{color:n.avgDays===null?"#bbb":k},children:Kj(n.avgDays)}),e.jsxs("p",{className:"text-[10px]",style:{color:"#666"},children:["median ",Kj(n.medianDays)," · n=",n.sample]}),e.jsx("p",{className:"text-[9px] mt-1.5 leading-snug",style:{color:"#999"},children:n.basis})]},n.key))})})]})},pb="#B8962E",Jj=({title:t,subtitle:s,icon:n,children:a})=>e.jsxs("div",{className:"rounded-xl p-4 mb-4",style:{background:"#fff",border:`1px solid ${k}15`},children:[e.jsxs("div",{className:"flex items-start gap-2 mb-3",children:[e.jsx("span",{style:{color:pb,marginTop:2},children:n}),e.jsxs("div",{children:[e.jsx("h3",{className:"text-sm font-bold",style:{color:k},children:t}),s&&e.jsx("p",{className:"text-[10px] mt-0.5",style:{color:"#888"},children:s})]})]}),a]}),ua=({children:t,right:s})=>e.jsx("th",{className:`py-1.5 px-2 text-[9px] uppercase tracking-[0.18em] font-bold ${s?"text-right":"text-left"}`,style:{color:"#999"},children:t}),Z4=({rows:t,firstLabel:s})=>t.length?e.jsx("div",{className:"overflow-x-auto",children:e.jsxs("table",{className:"w-full text-[11px]",children:[e.jsx("thead",{children:e.jsxs("tr",{style:{borderBottom:`1px solid ${k}12`},children:[e.jsx(ua,{children:s}),e.jsx(ua,{right:!0,children:"People"}),e.jsx(ua,{right:!0,children:"Tours"}),e.jsx(ua,{right:!0,children:"Applications"}),e.jsx(ua,{right:!0,children:"Enrollments"}),e.jsx(ua,{right:!0,children:"Lead â Enrolled"})]})}),e.jsx("tbody",{children:t.map(n=>{const a=!n.attributed;return e.jsxs("tr",{style:{borderBottom:`1px solid ${k}08`},children:[e.jsxs("td",{className:"py-1.5 px-2",children:[e.jsx("span",{className:"font-semibold",style:{color:a?"#9A3412":k},children:n.label}),a&&e.jsx("span",{className:"ml-1.5 px-1 py-0.5 rounded text-[8px] font-bold uppercase tracking-wider",style:{background:"#FEF3C7",color:"#92400E"},children:"no attribution stored"}),n.detail&&e.jsx("span",{className:"block text-[9px] font-mono",style:{color:"#aaa"},children:n.detail})]}),e.jsx("td",{className:"py-1.5 px-2 text-right font-bold",style:{color:k},children:n.people}),e.jsx("td",{className:"py-1.5 px-2 text-right",style:{color:"#555"},children:n.tours}),e.jsx("td",{className:"py-1.5 px-2 text-right",style:{color:"#555"},children:n.applications}),e.jsx("td",{className:"py-1.5 px-2 text-right",style:{color:"#555"},children:n.enrollments}),e.jsx("td",{className:"py-1.5 px-2 text-right font-bold",style:{color:n.conversion===null?"#bbb":pb},children:mb(n.conversion)})]},n.label)})})]})}):e.jsx("p",{className:"text-[11px] py-4 text-center",style:{color:"#999"},children:"No prospects in this range."}),Ume=({report:t})=>{const[s,n]=re.useState("first"),a=s==="first"?t.sources:t.sourcesLatest;return e.jsxs(e.Fragment,{children:[e.jsx(Jj,{title:"Program reporting",subt
1303itle:`Program interest is read from the linked source records only. Prospects whose forms never named a program appear as â${Mme}â.`,icon:e.jsx(_t,{size:15}),children:e.jsx(Z4,{rows:t.programs,firstLabel:"Program interest"})}),e.jsxs(Jj,{title:"Source / attribution reporting",subtitle:`Reads the CRM attribution layer (UTM · landing page · referrer · ad click ids) captured by the secure-form gateway, and falls back to legacy source / UTM / form fields for older records. Nothing is inferred â records with no stored signal appear as â${Ome}â.`,icon:e.jsx(VP,{size:15}),children:[e.jsx("div",{className:"grid grid-cols-2 sm:grid-cols-4 gap-2 mb-3",children:[{label:"Attribution coverage",value:mb(t.coveragePct),tone:pb,bg:"#fff",border:`${k}18`},{label:"CRM attribution layer",value:String(t.crmAttributedPeople),tone:k,bg:"#fff",border:`${k}18`},{label:"Legacy source fields",value:String(t.legacyAttributedPeople),tone:k,bg:"#fff",border:`${k}18`},{label:"Unattributed",value:String(t.unattributedPeople),tone:"#92400E",bg:"#FFFBEB",border:"#FDE68A"}].map(r=>e.jsxs("div",{className:"rounded-lg px-2.5 py-2",style:{background:r.bg,border:`1px solid ${r.border}`},children:[e.jsx("p",{className:"text-[9px] uppercase tracking-[0.15em] font-bold",style:{color:"#888"},children:r.label}),e.jsx("p",{className:"text-lg font-bold leading-tight",style:{color:r.tone},children:r.value})]},r.label))}),e.jsxs("div",{className:"rounded-lg px-3 py-2 mb-3 flex items-center gap-2 flex-wrap text-[10px]",style:{background:"#FFFBEB",border:"1px solid #FDE68A",color:"#92400E"},children:[e.jsx(ve,{size:12}),e.jsxs("span",{children:[e.jsx("strong",{children:t.attributedPeople})," of ",t.people," prospects carry usable attribution (",mb(t.coveragePct),") · ",e.jsx("strong",{children:t.unattributedPeople})," are unattributed. Coverage = prospects with usable attribution ÷ total prospects à 100. Only first-party data is stored â ad-platform API integrations remain out of scope."]})]}),e.jsxs("div",{className:"flex items-center gap-1.5 mb-3 flex-wrap",children:[[{key:"first",label:"First Touch"},{key:"latest",label:"Latest Touch"}].map(r=>{const i=s===r.key;return e.jsx("button",{type:"button",onClick:()=>n(r.key),className:"px-3 py-1.5 rounded-full text-[10px] font-bold uppercase tracking-[0.12em] transition-colors",style:{background:i?k:"#fff",color:i?"#fff":k,border:`1px solid ${i?k:`${k}25`}`},children:r.label},r.key)}),e.jsx("span",{className:"text-[9px] ml-1",style:{color:"#999"},children:s==="first"?"Where each prospect first discovered Zorganics â never overwritten by later submissions.":"The most recent attributable interaction stored for each prospect."})]}),e.jsx(Z4,{rows:a,firstLabel:s==="first"?"First-touch source":"Latest-touch source"})]}),e.jsxs(Jj,{title:"Admissions workload",subtitle:"Ownership, follow-up pressure and coverage gaps by admissions user. Read-only â nothing here reassigns or notifies anyone.",icon:e.jsx(XO,{size:15}),children:[e.jsx("div",{className:"grid grid-cols-2 sm:grid-cols-5 gap-2 mb-3",children:[{label:"Unassigned",value:t.unassigned,tone:"#92400E",bg:"#FFFBEB",border:"#FDE68A"},{label:"Overdue follow-ups",value:t.overdue,tone:"#991B1B",bg:"#FEF2F2",border:"#FCA5A5"},{label:"Due today",value:t.dueToday,tone:"#92400E",bg:"#FFFBEB",border:"#FDE68A"},{label:"High priority",value:t.highPriority,tone:k,bg:"#fff",border:`${k}18`},{label:"No activity logged",value:t.noActivity,tone:k,bg:"#fff",border:`${k}18`}].map(r=>e.jsxs("div",{className:"rounded-lg px-2.5 py-2",style:{background:r.bg,border:`1px solid ${r.border}`},children:[e.jsx("p",{className:"text-[9px] uppercase tracking-[0.15em] font-bold",style:{color:"#888"},children:r.label}),e.jsx("p",{className:"text-lg font-bold leading-tight",style:{color:r.tone},children:r.value})]},r.label))}),t.workload.length===0?e.jsx("p",{className:"text-[11px] py-4 text-center",style:{color:"#999"},children:"No prospects in this range."}):e.jsx("div",{className:"overflow-x-auto",children:e.jsxs("table",{className:"w-full text-[11px]",children:[e.jsx("thead",{children:e.jsxs("tr",{style:{borderBottom:`1px solid ${k}12`},children:[e.jsx(ua,{children:"Owner"}),e.jsx(ua,{right:!0,children:"Leads"}),e.jsx(ua,{right:!0,children:"Active"}),e.jsx(ua,{right:!0,children:"Overdue"}),e.jsx(ua,{right:!0,children:"Due today"}),e.jsx(ua,{right:!0,children:"High priority"}),e.jsx(ua,{right:!0,children:"No activity"}),e.jsx(ua,{right:!0,children:"Enrolled"})]})}),e.jsx("tbody",{children:t.workload.map(r=>e.jsxs("tr",{style:{borderBottom:`1px solid ${k}08`},children:[e.jsx("td",{className:"py-1.5 px-2 font-semibold",style:{color:r.ownerId?k:"#92400E"},children:r.ownerName}),e.jsx("td",{className:"py-1.5 px-2 text-right font-bold",style:{color:k},children:r.total}),e.jsx("td",{className:"py-1.5 px-2 text-right",style:{color:"#555"},children:r.active}),e.jsx("td",{className:"py-1.5 px-2 text-right font-bold",style:{color:r.overdue?"#991B1B":"#bbb"},children:r.overdue}),e.jsx("td",{className:"py-1.5 px-2 text-right",style:{color:r.dueToday?"#92400E":"#bbb"},children:r.dueToday}),e.jsx("td",{className:"py-1.5 px-2 text-right",style:{color:"#555"},children:r.highPriority}),e.jsx("td",{className:"py-1.5 px-2 text-right",style:{color:"#555"},children:r.noActivity}),e.jsx("td",{className:"py-1.5 px-2 text-right font-bold",style:{color:pb},children:r.enrolled})]},r.ownerId||"unassigned"))})]})})]})]})},Xj="#B8962E",qme=({groups:t})=>{var m,x;
1303const[s,n]=d.useState(b1),[a,r]=d.useState(!0),[i,o]=d.useState(Dme),l=async()=>{r(!0);const h=await df();n(h),r(!1)};d.useEffect(()=>{l()},[]);const c=d.useMemo(()=>v1(t,s).map(h=>Tme(h)),[t,s]),u=d.useMemo(()=>Rme(i),[i]),p=d.useMemo(()=>{const h=i.range==="all"?c:c.filter(y=>Ime(y,u));return Lme(h,u.label)},[c,u,i.range]);return e.jsxs("div",{children:[e.jsxs("div",{className:"rounded-xl p-3 mb-4 flex items-start gap-2.5",style:{background:"#F0FDF4",border:"1px solid #86EFAC"},children:[e.jsx(Ie,{size:15,style:{color:"#166534",marginTop:1}}),e.jsxs("p",{className:"text-[11px] leading-relaxed",style:{color:"#166534"},children:[e.jsx("strong",{children:"Read-only management reporting."})," Every figure is computed from the"," ",e.jsx("span",{className:"font-mono",children:"crm_*"})," coordination layer plus the linked source records. No source table is modified, no stage changes automatically, no email/SMS is sent, and no attribution field, nurture sequence or CSV export is added in this phase."]})]}),s.error&&e.jsxs("div",{className:"rounded-xl p-3 mb-4 flex items-start gap-2.5",style:{background:"#FEF2F2",border:"1px solid #FCA5A5"},children:[e.jsx(Mt,{size:15,style:{color:"#991B1B",marginTop:1}}),e.jsxs("p",{className:"text-[11px]",style:{color:"#991B1B"},children:["CRM layer could not be read: ",s.error]})]}),e.jsxs("div",{className:"rounded-xl p-3 mb-4",style:{background:"#fff",border:`1px solid ${k}15`},children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsxs("span",{className:"inline-flex items-center gap-1.5 text-[10px] font-bold uppercase tracking-[0.18em]",style:{color:Xj},children:[e.jsx(c2,{size:12})," Reporting window"]}),Pme.map(h=>{const y=i.range===h.value;return e.jsx("button",{onClick:()=>o(v=>({...v,range:h.value})),className:"px-2.5 py-1 rounded-full text-[10px] font-bold uppercase tracking-wider transition-all",style:{background:y?`linear-gradient(135deg, ${k}, #2A0810)`:`${k}0A`,color:y?$:k,border:`1px solid ${y?k:k+"18"}`},children:h.label},h.value)}),e.jsxs("button",{onClick:()=>void l(),className:"ml-auto inline-flex items-center gap-1.5 px-3 py-1.5 rounded-lg text-[11px] font-bold",style:{background:`${k}0C`,color:k,border:`1px solid ${k}22`},children:[e.jsx(Be,{size:11,className:a?"animate-spin":""})," Reload"]})]}),i.range==="custom"&&e.jsxs("div",{className:"flex flex-wrap items-center gap-2 mt-3",children:[e.jsx("label",{className:"text-[10px] font-semibold",style:{color:"#777"},children:"From"}),e.jsx("input",{type:"date",value:i.from,onChange:h=>o(y=>({...y,from:h.target.value})),className:"px-2 py-1 rounded-lg text-[11px]",style:{border:`1px solid ${k}22`,color:k}}),e.jsx("label",{className:"text-[10px] font-semibold",style:{color:"#777"},children:"To"}),e.jsx("input",{type:"date",value:i.to,onChange:h=>o(y=>({...y,to:h.target.value})),className:"px-2 py-1 rounded-lg text-[11px]",style:{border:`1px solid ${k}22`,color:k}})]}),e.jsxs("p",{className:"text-[10px] mt-2.5",style:{color:"#888"},children:["Cohort window: ",e.jsx("strong",{children:p.rangeLabel})," â a prospect is included when their first-seen date (earliest linked source record) falls inside the window, so conversion rates follow the cohort rather than later activity."]})]}),e.jsx("div",{className:"grid grid-cols-2 sm:grid-cols-3 lg:grid-cols-6 gap-2.5 mb-4",children:[{label:"Prospects in range",value:p.people},{label:"Tracked in CRM",value:p.inCrm},{label:"Not yet in CRM",value:p.notInCrm},{label:"Applications reached",value:((m=p.stageMetrics.find(h=>h.stage==="application"))==null?void 0:m.reached)??0},{label:"Enrolled",value:((x=p.stageMetrics.find(h=>h.stage==="enrolled"))==null?void 0:x.reached)??0},{label:"Not moving forward",value:p.notMovingForward}].map(h=>e.jsxs("div",{className:"rounded-xl px-3 py-2.5",style:{background:"#fff",border:`1px solid ${k}15`},children:[e.jsx("p",{className:"text-[9px] uppercase tracking-[0.18em] font-bold",style:{color:"#888"},children:h.label}),e.jsx("p",{className:"text-xl font-bold leading-tight",style:{color:k},children:h.value})]},h.label))}),a?e.jsxs("div",{className:"rounded-xl py-20 flex flex-col items-center gap-3",style:{background:"#fff",border:`1px solid ${k}15`},children:[e.jsx(de,{size:26,className:"animate-spin",style:{color:Xj}}),e.jsx("p",{className:"text-xs font-semibold",style:{color:k},children:"Building pipeline reportâ¦"})]}):p.people===0?e.jsxs("div",{className:"rounded-xl py-16 text-center",style:{background:"#fff",border:`1px solid ${k}15`},children:[e.jsx(La,{size:30,className:"mx-auto mb-3",style:{color:Xj,opacity:.4}}),e.jsx("p",{className:"text-sm font-semibold",style:{color:k},children:"No prospects in this window."}),e.jsx("p",{className:"text-xs mt-1",style:{color:"#666"},children:"Widen the reporting window to see historical performance."})]}):e.jsxs(e.Fragment,{children:[e.jsx(Bme,{report:p}),e.jsx(Ume,{report:p}),e.jsx("p",{className:"text-center text-[10px] pb-2",style:{color:"#999"},children:"Stage dates are reconstructed from the CRM stage-change history plus linked source-record dates â see the basis note on each metric. Unresolvable values are excluded from averages, never zero-filled."})]})]})},Y4={email:{perDay:1,perWeek:3},sms:{perDay:1,perWeek:2}},_1=[{key:"new_inquiry_no_response",label:"New inquiry â no staff response",purpose:"One gentle admissions follow-up when a new inquiry w
1303as never touched by a human.",trigger:"CRM stage is New AND no staff activity has ever been logged AND the grace period has elapsed.",stepKey:"gentle_followup_1",stepVersion:1,channel:"email",graceHours:48,maxAgeDays:30},{key:"application_incomplete",label:"Application received / incomplete follow-up",purpose:"Nudges only when a legitimate admissions step is still outstanding on the application.",trigger:"Application evidence on a linked source record (or CRM stage Application) with the step still open.",stepKey:"incomplete_nudge_1",stepVersion:1,channel:"email",graceHours:72,maxAgeDays:60},{key:"financial_aid_interest",label:"Financial Aid interest follow-up",purpose:"Points the prospect at the official financial-aid process. Never contains financial detail.",trigger:"Financial-aid / funding interest recorded on a linked source record or the CRM stage.",stepKey:"funding_next_step_1",stepVersion:1,channel:"email",graceHours:48,maxAgeDays:60}],Z0=_1.reduce((t,s)=>(t[s.key]=s.label,t),{}),oz="global",lz=t=>`workflow:${t}`,hb={unsubscribe:"Unsubscribed",sms_opt_out:"SMS opt-out",do_not_contact:"Do not contact",enrolled:"Enrolled",not_moving_forward:"Not moving forward",manual_admin:"Manual admin suppression",manual_pause:"Paused by admin",invalid_email:"Invalid email",bounced_email:"Bounced email",invalid_phone:"Invalid phone"},K4={ok:!1,mode:"preview",automation:{global_enabled:!1,workflows:[]},totals:{candidates:0,eligible:0,sent:0,skipped:0,suppressed:0,cancelled:0,failed:0,waiting:0},candidates:[],cancelled:[],people_scanned:0},Wme={globalEnabled:!1,settings:[],workflowEnabled:{},suppressions:[],suppressionByPerson:new Map,emailUnsubByPerson:new Map,messages:[],messagesByPerson:new Map,schedule:[],scheduleByPerson:new Map,runs:[],error:null};async function Hme(){var v,g,N,b,f,j;const[t,s,n,a,r]=await Promise.all([O.from("crm_nurture_settings").select("*").order("setting_key"),O.from("crm_nurture_suppressions").select("*").order("created_at",{ascending:!1}).limit(2e3),O.from("crm_nurture_messages").select("*").order("created_at",{ascending:!1}).limit(2e3),O.from("crm_nurture_schedule").select("*").order("run_at",{ascending:!0}).limit(2e3),O.from("crm_nurture_runs").select("*").order("started_at",{ascending:!1}).limit(20)]),i=((v=t.error)==null?void 0:v.message)||((g=s.error)==null?void 0:g.message)||((N=n.error)==null?void 0:N.message)||((b=a.error)==null?void 0:b.message)||((f=r.error)==null?void 0:f.message)||null,o=t.data||[],l={};_1.forEach(S=>{var w;l[S.key]=((w=o.find(_=>_.setting_key===lz(S.key)))==null?void 0:w.enabled)===!0});const c=s.data||[],u=new Map,p=new Map;c.filter(S=>S.active).forEach(S=>{S.person_id&&(u.has(S.person_id)||u.set(S.person_id,S),S.reason==="unsubscribe"&&(S.channel==="email"||S.channel==="all")&&!p.has(S.person_id)&&p.set(S.person_id,S))});const m=n.data||[],x=new Map;m.forEach(S=>{if(!S.person_id)return;const w=x.get(S.person_id)||[];w.push(S),x.set(S.person_id,w)});const h=a.data||[],y=new Map;return h.forEach(S=>{if(!S.person_id)return;const w=y.get(S.person_id)||[];w.push(S),y.set(S.person_id,w)}),{globalEnabled:((j=o.find(S=>S.setting_key===oz))==null?void 0:j.enabled)===!0,settings:o,workflowEnabled:l,suppressions:c,suppressionByPerson:u,emailUnsubByPerson:p,messages:m,messagesByPerson:x,schedule:h,scheduleByPerson:y,runs:r.data||[],error:i}}const Q4=864e5;function Gme(t,s){var v;const n={status:"idle",statusLabel:"No nurture activity",activeWorkflow:null,nextScheduled:null,lastAutomated:null,sentLast7d:0,sentLast24h:0,suppression:null,emailUnsubscribed:!1,emailUnsubscribedAt:null};if(!t)return n;const a=s.messagesByPerson.get(t.id)||[],r=a.filter(g=>g.status==="sent"&&g.sent_at),i=Date.now(),o=r.filter(g=>i-new Date(g.sent_at).getTime()<Q4).length,l=r.filter(g=>i-new Date(g.sent_at).getTime()<7*Q4).length,c=r[0]||a[0]||null,p=(s.scheduleByPerson.get(t.id)||[]).filter(g=>g.status==="scheduled").sort((g,N)=>new Date(g.run_at).getTime()-new Date(N.run_at).getTime())[0]||null,m=s.emailUnsubByPerson.get(t.id)||null;let x=m||s.suppressionByPerson.get(t.id)||null;!x&&(t.stage==="enrolled"||t.stage==="not_moving_forward")&&(x={id:"derived",person_id:t.
1303id,identity_email:null,identity_phone:null,channel:"all",reason:t.stage==="enrolled"?"enrolled":"not_moving_forward",active:!0,note:"Derived from the CRM stage â automation always stops here.",created_by_email:null,created_at:t.stage_updated_at||t.created_at||"",released_at:null});let h="idle",y="No nurture activity";if(m)h="suppressed",y="Email unsubscribed by recipient";else if(x){const g=x.reason==="manual_pause";h=g?"paused":"suppressed",y=g?"Paused for this person":`Suppressed â ${hb[x.reason]||x.reason}`}else s.globalEnabled?p?(h="scheduled",y=`Next: ${Z0[p.workflow_key]||p.workflow_key}`):r.length&&(h="active",y="Nurture has run for this prospect"):(h="off",y="Automation OFF (global switch)");return{status:h,statusLabel:y,activeWorkflow:(p==null?void 0:p.workflow_key)||(((v=r[0])==null?void 0:v.workflow_key)??null),nextScheduled:p,lastAutomated:c,sentLast7d:l,sentLast24h:o,suppression:x,emailUnsubscribed:!!m,emailUnsubscribedAt:(m==null?void 0:m.created_at)||null}}async function Vme(t,s){const{error:n}=await O.from("crm_nurture_settings").update({enabled:t,updated_at:new Date().toISOString(),updated_by_email:(s==null?void 0:s.email)||null,updated_by_name:(s==null?void 0:s.name)||null}).eq("setting_key",oz);return n?{ok:!1,error:n.message}:{ok:!0}
1303}async function Zme(t,s,n){const{error:a}=await O.from("crm_nurture_settings").update({enabled:s,updated_at:new Date().toISOString(),updated_by_email:(n==null?void 0:n.email)||null,updated_by_name:(n==null?void 0:n.name)||null}).eq("setting_key",lz(t));return a?{ok:!1,error:a.message}:{ok:!0}}async function Yme(t,s,n,a){const{error:r}=await O.from("crm_nurture_suppressions").insert({person_id:t.id,identity_email:t.primary_email,identity_phone:t.primary_phone,channel:(a==null?void 0:a.channel)||"all",reason:s,active:!0,note:(a==null?void 0:a.note)||null,created_by_email:(n==null?void 0:n.email)||null,created_by_name:(n==null?void 0:n.name)||null});return r?{ok:!1,error:r.message}:(await O.from("crm_activities").insert({person_id:t.id,activity_type:"system",notes:`[AUTOMATION] Nurture suppressed â ${hb[s]}${a!=null&&a.note?`: ${a.note}`:""}`,staff_user_id:(n==null?void 0:n.id)||null,staff_name:(n==null?void 0:n.name)||"Admin",staff_email:(n==null?void 0:n.email)||null,is_system:!0}),{ok:!0})}async function Kme(t,s,n){if(t==="derived")return{ok:!1,error:"This suppression comes from the CRM stage and cannot be released by automation."};const{error:a}=await O.from("crm_nurture_suppressions").update({active:!1,released_at:new Date().toISOString(),released_by_email:(n==null?void 0:n.email)||null}).eq("id",t);return a?{ok:!1,error:a.message}:(s&&await O.from("crm_activities").insert({person_id:s.id,activity_type:"system",notes:"[AUTOMATION] Nurture resumed â suppression released by admin",staff_user_id:(n==null?void 0:n.id)||null,staff_name:(n==null?void 0:n.name)||"Admin",staff_email:(n==null?void 0:n.email)||null,is_system:!0}),{ok:!0})}async function Qme(t,s){var r;const{data:n,error:a}=await O.functions.invoke("crm-nurture-run",{body:{mode:t,workflow:(s==null?void 0:s.workflow)||void 0,limit:(s==null?void 0:s.limit)||200,triggered_by_email:((r=s==null?void 0:s.actor)==null?void 0:r.email)||void 0}});return a?{...K4,mode:t,error:a.message}:!n||n.ok!==!0?{...K4,mode:t,error:(n==null?void 0:n.error)||"Run failed."}:n}const J4={would_send:{bg:"#DCFCE7",fg:"#166534",label:"Would send"},sent:{bg:"#D1FAE5",fg:"#065F46",label:"Sent"},sending:{bg:"#DCFCE7",fg:"#166534",label:"Sending"},waiting:{bg:"#FEF3C7",fg:"#92400E",label:"Waiting (grace)"},skipped:{bg:"#F3F4F6",fg:"#4B5563",label:"Skipped"},suppressed:{bg:"#FEE2E2",fg:"#991B1B",label:"Suppressed"},failed:{bg:"#FEE2E2",fg:"#991B1B",label:"Failed"}},Jme="#B8962E",X4=({on:t,busy:s,onClick:n,labelOn:a="ON",labelOff:r="OFF"})=>e.jsxs("button",{onClick:n,disabled:s,className:"inline-flex items-center gap-2 px-3 py-1.5 rounded-lg text-[11px] font-bold uppercase tracking-[0.12em] disabled:opacity-50",style:{background:t?"#DCFCE7":"#F3F4F6",color:t?"#166534":"#4B5563",border:`1px solid ${t?"#86EFAC":"#D1D5DB"}`},children:[s?e.jsx(de,{size:11,className:"animate-spin"}):e.jsx(qO,{size:11}),t?a:r]}),Xme=({globalEnabled:t,workflowEnabled:s,busyKey:n,onToggleGlobal:a,onToggleWorkflow:r})=>e.jsxs("div",{className:"space-y-4",children:[e.jsx("div",{className:"rounded-xl p-4",style:{background:t?"#F0FDF4":"#fff",border:`1px solid ${t?"#86EFAC":k+"15"}`},children:e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"text-sm font-bold",style:{color:k},children:"Nurture Automation â master switch"}),e.jsx("p",{className:"text-[11px] mt-1 leading-relaxed",style:{color:"#666"},children:t?"Live runs are permitted. Each workflow still needs its own switch, and every send passes the safety guard.":"All automated sending is disabled. Preview mode still works so you can inspect who would qualify."})]}),e.jsx(X4,{on:t,busy:n==="global",onClick:()=>a(!t),labelOn:"Automation ON",labelOff:"Automation OFF"})]})}),e.jsx("div",{className:"grid gap-3 lg:grid-cols-3",children:_1.map(i=>{const o=s[i.key]===!0,l=i.channel==="sms"?jr:Ye;return e.jsxs("div",{className:"rounded-xl p-4 flex flex-col gap-3",style:{background:"#fff",border:`1px solid ${o?"#86EFAC":k+"15"}`},children:[e.jsxs("div",{className:"flex items-start justify-between gap-2",children:[e.jsx("p",{className:"text-[13px] font-bold leading-snug",style:{color:k},children:i.label}),e.jsxs("span",{className:"shrink-0 inline-flex items-center gap-1 px-1.5 py-0.5 rounded text-[9px] font-bold uppercase",style:{background:`${$}1A`,color:Jme},children:[e.jsx(l,{size:9})," ",i.channel]})]}),e.jsx("p",{className:"text-[11px] leading-relaxed",style:{color:"#555"},children:i.purpose}),e.jsxs("div",{className:"text-[10px] space-y-1",style:{color:"#777"},children:[e.jsxs("p",{children:[e.jsx("strong",{style:{color:k},children:"Trigger:"})," ",i.trigger]}),e.jsxs("p",{className:"flex items-center gap-1",children:[e.jsx(dt,{size:9}
1303),i.graceHours,"h human grace period · step ",i.stepKey," v",i.stepVersion," · max age ",i.maxAgeDays,"d"]}),e.jsxs("p",{children:["Caps: ",Y4[i.channel].perDay,"/24h · ",Y4[i.channel].perWeek,"/7d"," ","(all nurture workflows combined, enforced server-side)"]})]}),e.jsx("div",{className:"mt-auto pt-1",children:e.jsx(X4,{on:o,busy:n===i.key,onClick:()=>r(i.key,!o)})})]},i.key)})}),e.jsxs("div",{className:"rounded-xl p-3 flex items-start gap-2",style:{background:"#FFFBEB",border:"1px solid #FDE68A"},children:[e.jsx(zn,{size:14,style:{color:"#92400E",marginTop:1}}),e.jsxs("p",{className:"text-[11px] leading-relaxed",style:{color:"#92400E"},children:["New workflows always ship ",e.jsx("strong",{children:"OFF"}),". Suppression, consent, frequency caps and idempotency are enforced in the edge function, not in this screen â turning a switch on never bypasses a guard check. Transactional tour confirmations and reminders are a separate system and are not affected by these switches."]})]})]}),dl="#B8962E",zc=({label:t,value:s,tone:n})=>e.jsxs("div",{className:"px-3 py-2 rounded-lg text-center",style:{background:`${k}08`},children:[e.jsx("p",{className:"text-[9px] uppercase tracking-[0.18em] font-bold",style:{color:"#888"},children:t}),e.jsx("p",{className:"text-lg font-bold leading-tight",style:{color:n||k},children:s})]}),epe=({result:t,running:s,globalEnabled:n,workflow:a,onWorkflowChange:r,onPreview:i,onLiveRun:o})=>{const[l,c]=d.useState(null),[u,p]=d.useState("all"),m=((t==null?void 0:t.candidates)||[]).filter(x=>u==="all"?!0:u==="would_send"?x.decision==="would_send"||x.decision==="sent":x.decision===u);return e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"rounded-xl p-4",style:{background:"#fff",border:`1px solid ${k}15`},children:[e.jsxs("div",{className:"flex flex-wrap items-end gap-3",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-[9px] uppercase tracking-[0.2em] font-bold mb-1",style:{color:dl},children:"Workflow"}),e.jsxs("select",{value:a||"",onChange:x=>r(x.target.value||null),className:"px-3 py-2 rounded-lg text-xs font-semibold",style:{border:`1px solid ${k}25`,color:k,background:"#fff"},children:[e.jsx("option",{value:"",children:"All workflows"}),_1.map(x=>e.jsx("option",{value:x.key,children:x.label},x.key))]})]}),e.jsxs("button",{onClick:i,disabled:s,className:"inline-flex items-center gap-2 px-4 py-2 rounded-lg text-xs font-bold disabled:opacity-50",style:{background:`linear-gradient(135deg, ${$}, ${dl})`,color:k},children:[s?e.jsx(de,{size:13,className:"animate-spin"}):e.jsx(ms,{size:13}),"Run preview (no messages sent)"]}),e.jsxs("button",{onClick:o,disabled:s||!n,title:n?"Executes enabled workflows. Every send still passes the safety guard.":"Blocked: the master switch is OFF.",className:"inline-flex items-center gap-2 px-4 py-2 rounded-lg text-xs font-bold disabled:opacity-40",style:{background:n?"#166534":"#E5E7EB",color:n?"#fff":"#6B7280"},children:[e.jsx(Xx,{size:13})," Live run"]})]}),e.jsx("p",{className:"text-[11px] mt-3 leading-relaxed",style:{color:"#666"},children:"Preview evaluates every CRM prospect against every workflow guard and returns the decision without contacting anybody. A live run is additionally gated by the master switch and each workflow switch, so with the shipped configuration it sends nothing."})]}),(t==null?void 0:t.error)&&e.jsxs("div",{className:"rounded-xl p-3 flex items-start gap-2",style:{background:"#FEF2F2",border:"1px solid #FCA5A5"},children:[e.jsx(ve,{size:14,style:{color:"#991B1B",marginTop:1}}),e.jsx("p",{className:"text-[11px]",style:{color:"#991B1B"},children:t.error})]}),(t==null?void 0:t.ok)&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"grid grid-cols-2 sm:grid-cols-4 lg:grid-cols-7 gap-2",children:[e.jsx(zc,{label:"Scanned",value:t.people_scanned}),e.jsx(zc,{label:"Candidates",value:t.totals.candidates}),e.jsx(zc,{label:t.mode==="live"?"Sent":"Would send",value:t.mode==="live"?t.totals.sent:t.totals.eligible,tone:"#166534"}),e.jsx(zc,{label:"Waiting",value:t.totals.waiting,tone:"#92400E"}),e.jsx(zc,{label:"Skipped",value:t.totals.skipped}),e.jsx(zc,{label:"Suppressed",value:t.totals.suppressed,tone:"#991B1B"}),e.jsx(zc,{label:"Cancelled",value:t.totals.cancelled,tone:"#991B1B"})]}),e.jsx("p",{className:"text-[11px] px-1",style:{color:t.mode==="preview"?"#166534":"#92400E"},children:t.note}),e.jsx("div",{className:"flex flex-wrap gap-1.5",children:[["all","All decisions"],["would_send","Would receive a message"],["waiting","Waiting on human grace"],["skipped","Skipped"],["suppressed","Suppressed"]].map(([x,h])=>e.jsx("button",{onClick:()=>p(x),className:"px-3 py-1.5 rounded-lg text-[11px] font-bold",style:{background:u===x?k:"#fff",color:u===x?$:k,border:`1px solid ${k}20`},children:h},x))}),m.length===0?e.jsxs("div",{className:"rounded-xl py-12 text-center",style:{background:"#fff",border:`1px solid ${k}15`},children:[e.jsx(Ue,{size:26,className:"mx-auto mb-2",style:{color:dl,opacity:.5}}),e.jsx("p",{className:"text-sm font-semibold",style:{color:k},children:"No prospects in this bucket."}),e.jsx("p",{className:"text-[11px] mt-1",style:{color:"#777"},children:"Nobody currently matches a workflow trigger with this filter."})]}):e.jsx("div",{className:"space-y-2",children:m.map(x=>
1303{const h=J4[x.decision]||J4.skipped,y=l===x.idempotency_key;return e.jsxs("div",{className:"rounded-xl overflow-hidden",style:{background:"#fff",border:`1px solid ${k}15`},children:[e.jsxs("button",{onClick:()=>c(y?null:x.idempotency_key),className:"w-full text-left p-3 flex flex-wrap items-center gap-3",children:[y?e.jsx(Gt,{size:14,style:{color:dl}}):e.jsx(Nr,{size:14,style:{color:dl}}),e.jsx("span",{className:"px-2 py-0.5 rounded text-[10px] font-bold uppercase tracking-wider",style:{background:h.bg,color:h.fg},children:h.label}),e.jsx("span",{className:"text-[13px] font-bold",style:{color:k},children:x.name}),e.jsx("span",{className:"text-[11px]",style:{color:"#777"},children:x.email_masked||"no email"}),e.jsx("span",{className:"text-[11px] font-semibold",style:{color:dl},children:x.workflow_label}),e.jsxs("span",{className:"text-[10px] ml-auto",style:{color:"#888"},children:[x.channel," · ",x.would_send_at?new Date(x.would_send_at).toLocaleString():"no send time"]})]}),y&&e.jsxs("div",{className:"px-4 pb-4 pt-1 grid md:grid-cols-2 gap-4",style:{borderTop:`1px solid ${k}10`},children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-[9px] uppercase tracking-[0.2em] font-bold mb-1",style:{color:dl},children:"Why they qualify"}),x.why_qualified.length===0?e.jsx("p",{className:"text-[11px]",style:{color:"#888"},children:"No qualifying conditions met."}):e.jsx("ul",{className:"space-y-1",children:x.why_qualified.map((v,g)=>e.jsxs("li",{className:"text-[11px] flex items-start gap-1.5",style:{color:"#444"},children:[e.jsx(Ue,{size:10,style:{color:"#166534",marginTop:3}})," ",v]},g))})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-[9px] uppercase tracking-[0.2em] font-bold mb-1",style:{color:dl},children:"Guard decision"}),e.jsxs("p",{className:"text-[11px] flex items-start gap-1.5",style:{color:"#444"},children:[x.decision==="suppressed"?e.jsx($b,{size:10,style:{color:"#991B1B",marginTop:3}}):x.decision==="waiting"?e.jsx(dt,{size:10,style:{color:"#92400E",marginTop:3}}):x.decision==="would_send"||x.decision==="sent"?e.jsx(Ue,{size:10,style:{color:"#166534",marginTop:3}}):e.jsx(kt,{size:10,style:{color:"#4B5563",marginTop:3}}),x.reason_label,x.reason_detail?` (${x.reason_detail})`:""]})]}),e.jsxs("div",{className:"text-[10px] space-y-0.5",style:{color:"#666"},children:[e.jsxs("p",{children:[e.jsx("strong",{style:{color:k},children:"Stage:"})," ",x.stage," · ",e.jsx("strong",{style:{color:k},children:"Owner:"})," ",x.owner||"Unassigned"]}),e.jsxs("p",{children:[e.jsx("strong",{style:{color:k},children:"Step:"})," ",x.step_key," v",x.step_version]}),e.jsxs("p",{children:[e.jsx("strong",{style:{color:k},children:"Subject:"})," ",x.subject]}),e.jsxs("p",{children:[e.jsx("strong",{style:{color:k},children:"Caps:"})," ",x.caps.sent_24h,"/",x.caps.cap_24h," in 24h ·"," ",x.caps.sent_7d,"/",x.caps.cap_7d," in 7d"]}),e.jsx("p",{className:"font-mono break-all",style:{color:"#999"},children:x.idempotency_key})]})]})]})]},x.idempotency_key)})}),t.cancelled.length>0&&e.jsxs("div",{className:"rounded-xl p-4",style:{background:"#fff",border:`1px solid ${k}15`},children:[e.jsx("p",{className:"text-[11px] font-bold mb-2",style:{color:k},children:"Scheduled steps cancelled by human contact or a stop condition"}),e.jsx("ul",{className:"space-y-1",children:t.cancelled.map((x,h)=>e.jsxs("li",{className:"text-[11px]",style:{color:"#555"},children:[e.jsx("strong",{style:{color:k},children:x.name||"Prospect"})," â ",x.workflow_label,": ",x.reason_label]},h))})]})]})]})},eF="#B8962E",tpe=({groups:t})=>{const{user:s}=kn(),n=s?{id:s.id,name:s.fullName||s.email,email:s.email}:null,[a,r]=d.useState(b1),[i,o]=d.useState(Wme),[l,c]=d.useState(!0),[u,p]=d.useState(null),[m,x]=d.useState("controls"),[h,y]=d.useState(null),[v,g]=d.useState(null),[N,b]=d.useState(!1),[f,j]=d.useState(null),S=async()=>{const[A,z]=await Promise.all([df(),Hme()]);r(A),o(z),c(!1)};d.useEffect(()=>{S()},[]);const w=d.useMemo(()=>v1(t,a),[t,a]),_=d.useMemo(()=>w.map(A=>A.person).filter(A=>!!A),[w]),C=d.useMemo(()=>_.map(A=>({person:A,summary:Gme(A,i)})),[_,i]),E=C.filter(A=>A.summary.suppression).length,P=C.filter(A=>A.summary.nextScheduled).length,F=i.messages.filter(A=>A.status==="sent"&&A.sent_at&&Date.now()-new Date(A.sent_at).getTime()<7*864e5).length,I=async A=>{p("global");const z=await Vme(A,n);j(z.ok?`Master switch turned ${A?"ON":"OFF"}.`:z.error||"Could not update the switch."),await S(),p(null)},D=async(A,z)=>{p(A);const M=await Zme(A,z,n);j(M.ok?`${Z0[A]||A} turned ${z?"ON":"OFF"}.`:M.error||"Could not update the workflow."),await S(),p(null)},L=async A=>{b(!0),j(null);const z=await Qme(A,{workflow:h,actor:n});g(z),b(!1),A==="live"&&await S()},V=async A=>{p(A.id);const z=await Yme(A,"manual_pause",n,{note:"Paused from the nurture console"});j(z.ok?"Nurture paused for this prospect.":z.error||"Could not pause."),await S(),p(null)},B=async(A,z)=>{p(A.id);const M=await Kme(z,A,n);j(M.ok?"Nurture resumed for this prospect.":M.error||"Could not resume."),await S(),p(null)};return l?e.jsxs("div",{className:"rounded-xl py-20 flex flex-col items-center gap-3",style:{background:"#fff",border:`1px solid ${k}15`},children:[e.jsx(de,{size:24,className:"animate-spin",style:{color:eF}}),e.jsx("p",{className:"text-xs font-semibold",style:{color:k},children:"Reading the nurture layerâ¦"})]}):e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"rounded-xl p-4 flex items-start gap-3",style:{background:"#F5F3FF",border:"1px solid #C4B5FD"},children:[e.jsx(Ie,{size:16,style:{color:"#5B21B6",marginTop:2}}),e.jsxs("div",{className:"text-[12px] leading-relaxed",style:{color:"#4C1D95"},children:[e.jsx("strong",{children:"Phase 4 â safe nurture automation."})," Every automated message passes one central guard (legitimate prospect · valid contact · consent · not opted out · not enrolled · not Not-Moving-Forward · not suppressed · staff has not already followed up · not already sent · within frequency caps · no duplicate transactional message). Caps, consent, idempotency and suppression are enforced server-side. Automation never changes a CRM stage, never writes a source table and never alters attribution."]})]}),(i.error||a.error)&&e.jsxs("div",{className:"rounded-xl p-3 flex items-start gap-2",style:{background:"#FEF2F2",border:"1px solid #FCA5A5"},children:[e.jsx(Mt,{size:14,style:{color:"#991B1B",marginTop:1}}),e.jsx("p",{className:"text-[11px]",style:{color:"#991B1B"},children:i.error||a.error})]}),f&&e.jsx("div",{className:"rounded-xl p-3",style:{background:"#F0FDF4",border:"1px solid #86EFAC"},children:e.jsx("p",{className:"text-[11px] font-semibold",style:{color:"#166534"},children:f})}
1303),e.jsx("div",{className:"grid grid-cols-2 sm:grid-cols-5 gap-2",children:[{label:"Automation",value:i.globalEnabled?"ON":"OFF",tone:i.globalEnabled?"#166534":"#991B1B"},{label:"Workflows on",value:`${Object.values(i.workflowEnabled).filter(Boolean).length}/3`},{label:"Scheduled",value:P},{label:"Suppressed",value:E,tone:"#991B1B"},{label:"Sent (7d)",value:F}].map(A=>e.jsxs("div",{className:"px-3 py-2 rounded-lg text-center",style:{background:"#fff",border:`1px solid ${k}15`},children:[e.jsx("p",{className:"text-[9px] uppercase tracking-[0.18em] font-bold",style:{color:"#888"},children:A.label}),e.jsx("p",{className:"text-lg font-bold leading-tight",style:{color:A.tone||k},children:A.value})]},A.label))}),e.jsx("div",{className:"flex flex-wrap items-center gap-1 p-1 rounded-xl",style:{background:"#fff",border:`1px solid ${k}15`,width:"fit-content"},children:[["controls","Admin Controls",Ie],["preview","Preview / Test Mode",_y],["people","Per-Prospect Status",ts],["log","Automation Log",en]].map(([A,z,M])=>{const R=m===A;return e.jsxs("button",{onClick:()=>x(A),className:"inline-flex items-center gap-2 px-3 py-2 rounded-lg text-[11px] font-bold uppercase tracking-[0.12em]",style:{background:R?k:"transparent",color:R?$:k},children:[e.jsx(M,{size:12})," ",z]},A)})}),m==="controls"&&e.jsx(Xme,{globalEnabled:i.globalEnabled,workflowEnabled:i.workflowEnabled,busyKey:u,onToggleGlobal:I,onToggleWorkflow:D}),m==="preview"&&e.jsx(epe,{result:v,running:N,globalEnabled:i.globalEnabled,workflow:h,onWorkflowChange:y,onPreview:()=>L("preview"),onLiveRun:()=>L("live")}),m==="people"&&e.jsxs("div",{className:"space-y-2",children:[e.jsxs("p",{className:"text-[11px] px-1",style:{color:"#666"},children:[C.length," CRM prospects · nurture status, active workflow, next scheduled action, last automated message, 7-day volume and suppression state."]}),C.slice(0,200).map(({person:A,summary:z})=>e.jsxs("div",{className:"rounded-xl p-3",style:{background:"#fff",border:`1px solid ${k}15`},children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-3",children:[e.jsx("span",{className:"text-[13px] font-bold",style:{color:k},children:A.display_name||"(no name on record)"}),e.jsx("span",{className:"px-2 py-0.5 rounded text-[10px] font-bold uppercase tracking-wider",style:{background:z.suppression?"#FEE2E2":z.status==="scheduled"?"#FEF3C7":"#F3F4F6",color:z.suppression?"#991B1B":z.status==="scheduled"?"#92400E":"#4B5563"},children:z.statusLabel}),e.jsxs("span",{className:"text-[10px]",style:{color:"#888"},children:["stage ",A.stage," · ",z.sentLast7d," nurture msg in 7d"]}),e.jsx("div",{className:"ml-auto flex items-center gap-2",children:z.suppression?e.jsxs("button",{onClick:()=>B(A,z.suppression.id),disabled:u===A.id||z.suppression.id==="derived",title:z.suppression.id==="derived"?"Derived from the CRM stage â change the stage instead.":"Release the suppression and resume nurture",className:"inline-flex items-center gap-1 px-2.5 py-1 rounded-lg text-[10px] font-bold disabled:opacity-40",style:{background:"#DCFCE7",color:"#166534",border:"1px solid #86EFAC"},children:[e.jsx(_y,{size:11})," Resume"]}):e.jsxs("button",{onClick:()=>V(A),disabled:u===A.id,className:"inline-flex items-center gap-1 px-2.5 py-1 rounded-lg text-[10px] font-bold disabled:opacity-40",style:{background:"#FEF3C7",color:"#92400E",border:"1px solid #FDE68A"},children:[e.jsx(V_,{size:11})," Pause nurture"]})})]}),e.jsxs("div",{className:"grid sm:grid-cols-3 gap-2 mt-2 text-[10px]",style:{color:"#666"},children:[e.jsxs("p",{children:[e.jsx("strong",{style:{color:k},children:"Active workflow:"})," ",z.activeWorkflow?Z0[z.activeWorkflow]||z.activeWorkflow:"none"]}),e.jsxs("p",{children:[e.jsx("strong",{style:{color:k},children:"Next scheduled:"})," ",z.nextScheduled?Ln(z.nextScheduled.run_at):"â"]}),e.jsxs("p",{children:[e.jsx("strong",{style:{color:k},children:"Last automated:"})," ",z.lastAutomated?`${z.lastAutomated.status} · ${Ln(z.lastAutomated.sent_at||z.lastAutomated.created_at)}`:"â"]})]}),z.emailUnsubscribed&&e.jsxs("p",{className:"text-[10px] mt-1.5 flex items-center gap-1",style:{color:"#991B1B"},children:[e.jsx(UP,{size:10}),"Email unsubscribed by the recipient",z.emailUnsubscribedAt?` on ${Ln(z.emailUnsubscribedAt)}`:""," â every nurture email is blocked server-side, including when the global switch is ON. Re-enabling requires an authorised admin release (audited); there is no public resubscribe. The unsubscribe token itself is never visible to staff."]}),z.suppression&&e.jsxs("p",{className:"text-[10px] mt-1.5 flex items-center gap-1",style:{color:"#991B1B"},children:[e.jsx($b,{size:10}),"Suppression: ",hb[z.suppression.reason]||z.suppression.reason," ","(",z.suppression.channel,")",z.suppression.note?` â ${z.suppression.note}
1303`:""," ","(overrides every workflow)"]})]},A.id)),C.length>200&&e.jsx("p",{className:"text-center text-[11px] py-2",style:{color:"#888"},children:"Showing the first 200 CRM prospects."})]}),m==="log"&&e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"rounded-xl p-4",style:{background:"#fff",border:`1px solid ${k}15`},children:[e.jsx("p",{className:"text-[11px] font-bold mb-2",style:{color:k},children:"Recent runs"}),i.runs.length===0?e.jsx("p",{className:"text-[11px]",style:{color:"#888"},children:"No runs recorded yet."}):e.jsx("div",{className:"space-y-1",children:i.runs.map(A=>e.jsxs("p",{className:"text-[11px]",style:{color:"#555"},children:[e.jsx("span",{className:"px-1.5 py-0.5 rounded text-[9px] font-bold uppercase mr-2",style:{background:A.mode==="live"?"#DCFCE7":`${$}1A`,color:A.mode==="live"?"#166534":eF},children:A.mode}),Ln(A.started_at)," · ",A.candidates," candidates · ",A.eligible," eligible ·"," ",A.sent," sent · ",A.skipped," skipped · ",A.suppressed," suppressed · ",A.cancelled," cancelled",A.failed?` · ${A.failed} failed`:"",A.triggered_by_email?` · by ${A.triggered_by_email}`:""]},A.id))})]}),e.jsxs("div",{className:"rounded-xl p-4",style:{background:"#fff",border:`1px solid ${k}15`},children:[e.jsx("p",{className:"text-[11px] font-bold mb-2",style:{color:k},children:"Automated message log (sent · skipped · suppressed · cancelled · failed)"}),i.messages.length===0?e.jsx("p",{className:"text-[11px]",style:{color:"#888"},children:"No automated messages have been produced. Every workflow is OFF."}):e.jsx("div",{className:"space-y-1",children:i.messages.slice(0,100).map(A=>e.jsxs("p",{className:"text-[11px]",style:{color:"#555"},children:[e.jsx("strong",{style:{color:k},children:A.status})," ·"," ",Z0[A.workflow_key]||A.workflow_key," · ",A.step_key," v",A.step_version," ·"," ",A.channel," · ",Ln(A.sent_at||A.created_at),A.reason_code?` · ${A.reason_code}`:""]},A.id))})]}),e.jsxs("div",{className:"rounded-xl p-4",style:{background:"#fff",border:`1px solid ${k}15`},children:[e.jsx("p",{className:"text-[11px] font-bold mb-2",style:{color:k},children:"Suppression list"}),i.suppressions.length===0?e.jsx("p",{className:"text-[11px]",style:{color:"#888"},children:"No stored suppressions. Enrolled and Not-Moving-Forward prospects are suppressed automatically from their CRM stage."}):e.jsx("div",{className:"space-y-1",children:i.suppressions.slice(0,100).map(A=>e.jsxs("p",{className:"text-[11px]",style:{color:A.active?"#991B1B":"#888"},children:[hb[A.reason]||A.reason," · ",A.channel," ·"," ",A.active?"active":`released ${Ln(A.released_at)}`,A.created_by_email?` · by ${A.created_by_email}`:""]},A.id))})]})]})]})},ew="#E6D2A0",Lc="#B8962E",tF="#2A0810",sF="#FAF6ED";function spe(){sn();const[t,s]=d.useState(null),[n,a]=d.useState(!0),[r,i]=d.useState(!1),[o,l]=d.useState(w4),[c,u]=d.useState(!1),[p,m]=d.useState("worklist");d.useEffect(()=>{document.title="Lead Inventory â Admin"},[]);const x=async()=>{const P=await Rce();s(P),a(!1),i(!1)};d.useEffect(()=>{x()},[]);const h=(t==null?void 0:t.records)??[],y=d.useMemo(()=>j4(h),[h]),v=d.useMemo(()=>Ice(h,y),[h,y]),g=d.useMemo(()=>y.map(P=>yk(P,!1)),[y]),N=d.useMemo(()=>Zce(h,g),[h,g]),[b,f]=d.useState({inCrm:0,humanWorked:0});d.useEffect(()=>{let P=!1;return(async()=>{const F=await df();if(P)return;let I=0;F.activitiesByPerson.forEach(D=>{D.some(L=>!L.is_system&&L.activity_type!=="system")&&(I+=1)}),f({inCrm:F.people.length,humanWorked:I})})(),()=>{P=!0}},[t]);const j=d.useMemo(()=>zce(h,o),[h,o]),S=d.useMemo(()=>{const P=j4(j);return o.category==="possible-duplicate"?P.filter(F=>F.isDuplicate):P},[j,o.category]),w=d.useMemo(()=>Lce(h),[h]),_=d.useMemo(()=>{const P={};for(const F of mm)P[F.key]=0;for(const F of h)P[F.sourceKey]=(P[F.sourceKey]||0)+1;return P},[h]),C=((t==null?void 0:t.sources)??[]).filter(P=>P.error),E=P=>l(F=>({...F,...P}));return e.jsxs("div",{className:"min-h-screen",style:{background:sF},children:[e.jsx("header",{className:"sticky top-0 z-30 border-b",style:{background:`linear-gradient(180deg, ${k} 0%, ${tF} 100%)`,borderColor:`${$}33`,color:sF},children:e.jsxs("div",{className:"max-w-[1500px] mx-auto px-4 lg:px-8 py-4 flex items-center gap-4",children:[e.jsxs(be,{to:"/",className:"flex items-center gap-2 text-xs font-semibold opacity-80 hover:opacity-100",style:{color:ew},children:[e.jsx(Je,{size:14})," Back to site"]}),e.jsx("div",{className:"h-6 w-px",style:{background:`${$}55`}}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"text-[10px] uppercase tracking-[0.4em] font-semibold",style:{color:ew},children:"Zorganics Admin · Admissions CRM"}),e.jsx("h1",{className:"text-xl lg:text-2xl font-bold leading-tight",style:{color:$,fontFamily:"'Playfair Display', Georgia, serif"},children:"Unified Lead Inventory & CRM"})]}),e.jsxs("button",{onClick:()=>u(P=>!P),className:"hidden sm:inline-flex items-center gap-1.5 px-3 py-1.5 rounded-lg text-xs font-semibold",style:{background:`${$}1A`,color:ew,border:`1px solid ${$}55`},title:c?"Hide full contact details":"Reveal full contact details for verification",children:[c?e.jsx(Md,{size:12}):e.jsx(ms,{size:12}),c?"Mask PII":"Reveal PII"]}),e.jsxs("button",{onClick:()=>{i(!0),x()},disabled:r,className:"inline-flex items-center gap-1.5 px-3 py-1.5 rounded-lg text-xs font-bold disabled:opacity-50",style:{background:`linear-gradient(135deg, ${$}, ${Lc})`,color:k},children:[e.jsx(Be,{size:12,className:r?"animate-spin":""})," Refresh"]})]})}),e.jsxs("div",{className:"max-w-[1500px] mx-auto px-4 lg:px-8 py-6 lg:py-8",children:[p!=="worklist"&&p!=="crm"&&p!=="reports"&&p!=="nurture"&&e.jsx(Xce,{}),n?e.jsxs("div",{className:"rounded-xl py-24 flex flex-col items-center justify-center gap-3",style:{background:"#fff",border:`1px solid ${k}15`},children:[e.jsx(de,{size:28,className:"animate-spin",style:{color:Lc}}),e.jsxs("p",{className:"text-xs font-semibold",style:{color:k},children:["Reading ",mm.length," lead sourcesâ¦"]})]}):e.jsxs(e.Fragment,{children:[e.jsx(Jce,{summary:v,metrics:N}),C.length>0&&e.jsxs("div",{className:"rounded-xl p-4 mb-5 flex items-start gap-3",style:{background:"#FEF2F2",border:"1px solid #FCA5A5"},children:[e.jsx(Mt,{size:16,style:{color:"#991B1B",marginTop:2}}),e.jsxs("div",{className:"text-[12px] leading-relaxed",style:{color:"#991B1B"},children:[e.jsxs("strong",{children:[C.length," source could not be read."]})," ",C.map(P=>P.table).join(", ")," â the current session's row-level security policy blocked the SELECT. The
1303se sources are excluded from every count above."]})]}),e.jsx("div",{className:"flex items-center gap-1 mb-2 p-1 rounded-xl flex-wrap",style:{background:"#fff",border:`1px solid ${k}15`,width:"fit-content"},children:[{key:"worklist",label:"Admissions Worklist",icon:Cy},{key:"reports",label:"Pipeline Reports",icon:La},{key:"nurture",label:"Nurture Automation",icon:Hs},{key:"crm",label:"CRM Pipeline (diagnostic)",icon:mn},{key:"people",label:"Grouped People (technical)",icon:ts},{key:"sources",label:"Source Inventory (technical)",icon:Cy}].map(P=>{const F=p===P.key,I=P.icon;return e.jsxs("button",{onClick:()=>m(P.key),className:"inline-flex items-center gap-2 px-4 py-2 rounded-lg text-xs font-bold uppercase tracking-[0.15em] transition-all",style:{background:F?`linear-gradient(135deg, ${k}, ${tF})`:"transparent",color:F?$:k},children:[e.jsx(I,{size:13})," ",P.label]},P.key)})}),e.jsxs("p",{className:"text-[10px] mb-5",style:{color:"#888"},children:[e.jsx("strong",{style:{color:k},children:"Admissions Worklist"})," is the everyday admissions surface â full contact details, tour request vs confirmed booking, and the completed application all open from one prospect record. The other tabs are reporting and diagnostic tools over the same records."]}),p==="worklist"&&e.jsx(vme,{groups:y}),p==="crm"&&e.jsx(_me,{groups:y,showRaw:c}),p==="reports"&&e.jsxs(e.Fragment,{children:[b.inCrm===0?e.jsxs("div",{className:"rounded-xl p-4 mb-5 flex items-start gap-3",style:{background:"#FFFBEB",border:"1px solid #FDE68A"},children:[e.jsx(La,{size:16,style:{color:"#92400E",marginTop:2}}),e.jsxs("div",{className:"text-[12px] leading-relaxed",style:{color:"#92400E"},children:[e.jsx("strong",{children:"Not enough CRM data for conversion reporting yet."})," No prospect has been activated into the CRM, so funnel, conversion-rate and time-in-stage figures below have nothing real to measure. Activate admissions prospects on the ",e.jsx("strong",{children:"CRM Pipeline"})," ","tab first, then work them day to day â reporting becomes meaningful once genuine stage transitions start accumulating."]})]}):b.humanWorked===0?e.jsxs("div",{className:"rounded-xl p-4 mb-5 flex items-start gap-3",style:{background:"#EFF6FF",border:"1px solid #BFDBFE"},children:[e.jsx(La,{size:16,style:{color:"#1E40AF",marginTop:2}}),e.jsxs("div",{className:"text-[12px] leading-relaxed",style:{color:"#1E40AF"},children:[e.jsx("strong",{children:"Early adoption â read these numbers as a
1303starting baseline."})," ",b.inCrm," ",b.inCrm===1?"person is":"people are"," in the CRM, but every stage so far came from ",e.jsx("em",{children:"historical initialization"})," (derived from existing source evidence), not from admissions-team conversion. Each imported person carries a system activity recording that. Conversion and velocity metrics become real once staff start logging calls, texts, notes and manual stage moves."]})]}):null,e.jsx(qme,{groups:y})]}),p==="nurture"&&e.jsx(tpe,{groups:y}),p==="people"&&e.jsxs(e.Fragment,{children:[e.jsx(ede,{filters:o,onChange:E,onReset:()=>l(w4),programs:w.programs,statuses:w.statuses,sourceCounts:_,categoryCounts:v.categoryCounts,staleCount:v.stale}),e.jsxs("p",{className:"text-[11px] mb-3",style:{color:"#777"},children:["Showing ",e.jsx("strong",{children:S.length})," grouped ",S.length===1?"person":"people"," across"," ",e.jsx("strong",{children:j.length})," source records",j.filter(tc).length>0&&e.jsxs(e.Fragment,{children:[" · ",e.jsxs("span",{style:{color:"#991B1B",fontWeight:700},children:[j.filter(tc).length," still untouched"]})]})]}),S.length===0?e.jsxs("div",{className:"rounded-xl py-20 text-center",style:{background:"#fff",border:`1px solid ${k}15`},children:[e.jsx($i,{size:34,className:"mx-auto mb-3",style:{color:Lc,opacity:.4}}),e.jsx("p",{className:"text-sm font-semibold",style:{color:k},children:"No records match these filters."}),e.jsx("p",{className:"text-xs mt-1",style:{color:"#666"},children:"Clear the filters to see the whole inventory."})]}):e.jsxs("div",{className:"space-y-3",children:[S.slice(0,300).map(P=>e.jsx(nde,{group:P,showRaw:c},P.id)),S.length>300&&e.jsx("p",{className:"text-center text-[11px] py-3",style:{color:"#888"},children:"Showing the first 300 groups â narrow the filters to see the rest."})]})]}),p==="sources"&&e.jsx("div",{className:"space-y-3",children:((t==null?void 0:t.sources)??[]).map(P=>e.jsxs("div",{className:"rounded-xl p-4",style:{background:"#fff",border:`1px solid ${P.error?"#FCA5A5":k+"15"}`},children:[e.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-3",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"text-sm font-bold",style:{color:k},children:P.sourceLabel}),e.jsx("p",{className:"text-[10px] font-mono",style:{color:"#999"},children:P.table})]}),e.jsx("div",{className:"flex flex-wrap gap-2",children:[{label:"Rows",value:P.rowCount},{label:"7d",value:P.last7},{label:"30d",value:P.last30},{label:"90d",value:P.last90}].map(F=>e.jsxs("div",{className:"px-3 py-1.5 rounded-lg text-center",style:{background:`${k}08`},children:[e.jsx("p",{className:"text-[9px] uppercase tracking-wider font-bold",style:{color:"#888"},children:F.label}),e.jsx("p",{className:"text-sm font-bold",style:{color:k},children:F.value})]},F.label))})]}),P.error?e.jsxs("p",{className:"text-[11px] mt-3 font-semibold",style:{color:"#991B1B"},children:["Not readable in this session: ",P.error]}):e.jsxs("div",{className:"grid md:grid-cols-3 gap-4 mt-4",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-[9px] uppercase tracking-[0.25em] font-bold mb-1",style:{color:Lc},children:"Date range"}),e.jsxs("p",{className:"text-[11px]",style:{color:"#555"},children:[P.earliest?new Date(P.earliest).toLocaleDateString():"â"," â"," ",P.latest?new Date(P.latest).toLocaleDateString():"â"]}),e.jsxs("p",{className:"text-[10px] mt-2 flex items-center gap-1",style:{color:P.hasAttribution?"#065F46":"#999"},children:[e.jsx(Ie,{size:10}),P.hasAttribution?"Carries source/UTM/tag attribution":"No attribution columns"]})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-[9px] uppercase tracking-[0.25em] font-bold mb-1",style:{color:Lc},children:"By status"}),e.jsx("div",{className:"flex flex-wrap gap-1",children:P.statusCounts.slice(0,8).map(F=>e.jsxs("span",{className:"px-1.5 py-0.5 rounded text-[10px] font-semibold",style:{background:`${k}0C`,color:k},children:[F.label,": ",F.count]},F.label))})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-[9px] uppercase tracking-[0.25em] font-bold mb-1",style:{color:Lc},children:"By program / form type"}),e.jsx("div",{className:"flex flex-wrap gap-1",children:[...P.programCounts.slice(0,5),...P.formTypeCounts.slice(0,4)].map((F,I)=>e.jsxs("span",{className:"px-1.5 py-0.5 rounded text-[10px] font-semibold",style:{background:`${$}18`,color:Lc},children:[F.label,": ",F.count]},`${F.label}-${I}`))})]})]})]},P.sourceKey))}),e.jsxs("p",{className:"text-center text-[11px] mt-6",style:{color:"#888"}
1303,children:["Snapshot read ",t?new Date(t.loadedAt).toLocaleString():"â"," ·"," ",mm.length," source tables · SELECT-only, no records modified"]})]})]})]})}const ju="#800020",nF="#D4AF37",npe=t=>t.linked_account_id&&t.account_last_login_at?{label:"Portal Active",tone:"#047857"}:t.linked_account_id?{label:"Student Linked",tone:"#1D4ED8"}:t.email_match_student_id?{label:"Ready to Provision",tone:"#B45309"}:{label:"Accepted",tone:"#6B7280"},ape=t=>t.linked_account_id?{label:"Linked",tone:"#047857"}:t.email_match_student_id?{label:"High â email match",tone:"#B45309"}:t.name_match_count>0?{label:"Possible â name match",tone:"#92400E"}:{label:"No match",tone:"#6B7280"},rpe=()=>{const[t,s]=d.useState([]),[n,a]=d.useState(!0),[r,i]=d.useState(!0),[o,l]=d.useState(null),[c,u]=d.useState([]),[p,m]=d.useState(""),[x,h]=d.useState([]),[y,v]=d.useState(""),[g,N]=d.useState(""),[b,f]=d.useState(!1),[j,S]=d.useState(null),w=d.useCallback(async()=>{a(!0);const{data:F,error:I}=await O.rpc("z_staff_provisioning_board",{p_limit:200});I||!(F!=null&&F.ok)?(i(!(F&&F.reason==="not_authorized")),s([])):(i(!0),s(F.rows||[])),a(!1)},[]),_=d.useCallback(async F=>{const{data:I}=await O.rpc("z_staff_provisioning_history",{p_person_id:F||null,p_limit:50});h(I!=null&&I.ok?I.rows||[]:[])},[]),C=d.useCallback(async F=>{const{data:I}=await O.rpc("z_staff_student_account_search",{p_q:F||null,p_limit:25});u(I!=null&&I.ok?I.rows:[])},[]);d.useEffect(()=>{w(),_()},[w,_]);const E=async F=>{l(F),S(null),N(F.email_match_student_id||""),await Promise.all([C(F.display_name||""),_(F.person_id)])},P=async(F,I)=>{if(!o)return;if(!y.trim()){S({kind:"err",text:"Enter your staff name first â every link is recorded in the audit trail."});return}f(!0),S(null);const{data:D,error:L}=await O.rpc("z_provision_student_identity",{p_person_id:o.person_id,p_actor:y.trim(),p_allow_create:F,p_student_id:(I||g||"").trim()||null});if(f(!1),L){S({kind:"err",text:L.message.includes("not_authorized")?"Not authorized. Sign in with a staff account that has provisioning rights.":L.message});return}const V=(D==null?void 0:D.reason)||(D==null?void 0:D.result);(D==null?void 0:D.ok)===!1||V==="no_match_requires_approval"?S({kind:"err",text:'No existing student account matched. Enter the Student ID and use "Approve account creation" if this person should get a new account.'}):(S({kind:"ok",text:V==="already_linked"?"Already linked â no duplicate was created.":"Linked successfully. Admissions nurture is now suppressed for this person."}),await w(),await _(o.person_id))};return r?e.jsxs("div",{className:"max-w-7xl mx-auto px-4 py-8 space-y-6",children:[e.jsxs("header",{className:"rounded-2xl p-5",style:{background:`linear-gradient(135deg, ${ju}, #5C0018)`},children:[e.jsx("p",{className:"text-[11px] uppercase tracking-[0.2em]",style:{color:nF},children:"Admissions â Student handoff"}),e.jsx("h1",{className:"text-2xl font-bold text-white mt-1",style:{fontFamily:'"Georgia", serif'},children:"Student Identity & Provisioning"}),e.jsx("p",{className:"text-xs mt-1",style:{color:"#F7E7CE"},children:"Accepted â Ready to Provision â Student Linked â Portal Active. Links are idempotent and audited; new accounts require explicit staff approval."})]}),e.jsxs("div",{className:"flex flex-col sm:flex-row gap-3",children:[e.jsx("input",{value:y,onChange:F=>v(F.target.value),placeholder:"Your staff name (recorded in the audit trail)",className:"flex-1 px-4 py-2.5 rounded-xl border text-sm"}),e.jsxs("button",{onClick:w,className:"flex items-center justify-center gap-2 px-4 py-2.5 rounded-xl text-sm font-bold text-white",style:{background:ju},children:[e.jsx(Be,{size:14})," Refresh"]})]}),e.jsxs("div",{className:"grid lg:grid-cols-2 gap-5",children:[e.jsxs("section",{className:"bg-white rounded-2xl border shadow-sm overflow-hidden",children:[e.jsxs("div",{className:"px-4 py-3 border-b flex items-center gap-2",children:[e.jsx(dx,{size:16,style:{color:ju}}),e.jsxs("h2",{className:"text-sm font-bold text-gray-900",children:["Enrolled & accepted people (",t.length,")"]})]}),e.jsx("div",{className:"max-h-[520px] overflow-y-auto divide-y",children:n?e.jsx("div",{className:"p-8 flex justify-center",children:e.jsx(de,{className:"animate-spin text-gray-400"})}):t.length===0?e.jsx("p",{className:"p-6 text-xs text-gray-500",children:"No accepted or enrolled CRM people to provision right now."}):t.map(F=>{const I=npe(F),D=ape(F);return e.jsxs("button",{onClick:()=>E(F),className:`w-full text-left p-4 hover:bg-gray-50 transition-colors ${(o==null?void 0:o.person_id)===F.person_id?"bg-gray-50":""}`,children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx("span",{className:"text-sm font-bold text-gray-900",children:F.display_name||"Unnamed person"}),e.jsx("span",{className:"px-2 py-0.5 rounded-full text-[9px] font-bold text-white",style:{background:I.tone},children:I.label}),e.jsx("span",{className:"px-2 py-0.5 rounded-full text-[9px] font-bold",style:{background:"#F3F4F6",color:D.tone},children:D.label})]}),e.jsxs("p",{className:"text-[11px] text-gray-500 mt-1",children:[F.email||"no email"," · stage ",F.stage||"â"]}),F.linked_account_id&&e.jsxs("p",{className:"text-[11px] text-emerald-700 font-semibold mt-1 flex items-center gap-1",children:[e.jsx(Xs,{size:11})," ",F.account_student_id," â ",F.account_full_name]})]},F.person_id)})})]}),e.jsxs("section",{className:"space-y-4",children:[o?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"bg-white rounded-2xl border p-5 shadow-sm",children:[e.jsx("h3",{className:"text-sm font-bold text-gray-900",children:o.display_name}),e.jsx("p",{className:"text-[11px] text-gray-500",children:o.email||"no email on file"}),o.linked_account_id?e.jsxs("div",{className:"mt-3 p-3 rounded-xl flex items-start gap-2",style:{background:"#ECFDF5"},children:[e.jsx(pt,{size:15,className:"text-emerald-600 mt-0.5 shrink-0"}),e.jsxs("div",{className:"text-xs text-emerald-800",children:["Already linked to ",e.jsx("strong",{children:o.account_student_id})," (",o.account_full_name,") via"," ",o.link_method||"staff link",o.linked_by?` by ${o.linked_by}
1303`:"",". Re-running provisioning will return this same link â it can never create a duplicate."]})]}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"mt-3 flex gap-2",children:[e.jsx("input",{value:g,onChange:F=>N(F.target.value.toUpperCase()),placeholder:"Student ID (e.g. Z-2026-001)",className:"flex-1 px-3 py-2 rounded-lg border text-sm font-mono"}),e.jsx("button",{disabled:b,onClick:()=>P(!1),className:"px-4 py-2 rounded-lg text-xs font-bold text-white disabled:opacity-50",style:{background:ju},children:e.jsxs("span",{className:"flex items-center gap-1.5",children:[e.jsx(Xs,{size:13})," Link existing"]})})]}),e.jsx("button",{disabled:b,onClick:()=>P(!0),className:"mt-2 w-full px-4 py-2 rounded-lg text-xs font-bold border disabled:opacity-50",style:{borderColor:nF,color:"#92400E",background:"#FFFBEB"},children:e.jsxs("span",{className:"flex items-center justify-center gap-1.5",children:[e.jsx(Cd,{size:13})," Approve account creation for this Student ID"]})}),e.jsxs("p",{className:"text-[10px] text-gray-400 mt-2 flex items-start gap-1",children:[e.jsx(ve,{size:11,className:"mt-0.5 shrink-0"}),"Creation is never automatic. Link first whenever a student account already exists."]})]}),j&&e.jsx("p",{className:`mt-3 text-xs font-semibold ${j.kind==="ok"?"text-emerald-700":"text-red-700"}`,children:j.text})]}),e.jsxs("div",{className:"bg-white rounded-2xl border p-5 shadow-sm",children:[e.jsx("h4",{className:"text-xs font-bold text-gray-700 uppercase tracking-wide mb-2",children:"Search student accounts"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsxs("div",{className:"relative flex-1",children:[e.jsx(Bt,{size:14,className:"absolute left-3 top-1/2 -translate-y-1/2 text-gray-400"}),e.jsx("input",{value:p,onChange:F=>m(F.target.value),placeholder:"Name, Student ID or email",className:"w-full pl-9 pr-3 py-2 rounded-lg border text-sm"})]}),e.jsx("button",{onClick:()=>C(p),className:"px-3 py-2 rounded-lg text-xs font-bold text-white",style:{background:ju},children:"Search"})]}),e.jsxs("div",{className:"mt-3 max-h-48 overflow-y-auto divide-y",children:[c.map(F=>e.jsxs("div",{className:"py-2 flex items-center gap-2",children:[e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("p",{className:"text-xs font-semibold text-gray-800 truncate",children:[F.full_name," · ",e.jsx("span",{className:"font-mono",children:F.student_id})]}),e.jsxs("p",{className:"text-[10px] text-gray-500 truncate",children:[F.email||"no email"," · ",F.program||"â"," · ",F.enrollment_status]})]}),F.already_linked_person_id?e.jsx("span",{className:"text-[9px] font-bold text-gray-400",children:"LINKED"}):e.jsx("button",{disabled:b||!o,onClick:()=>{N(F.student_id),P(!1,F.student_id)},className:"px-2.5 py-1 rounded-md text-[10px] font-bold text-white disabled:opacity-40",style:{background:ju},children:"Link"})]},F.account_id)),c.length===0&&e.jsx("p",{className:"text-[11px] text-gray-400 py-2",children:"No accounts found."})]})]})]}):e.jsx("div",{className:"bg-white rounded-2xl border p-6 text-xs text-gray-500 shadow-sm",children:"Select a person to review match confidence, link an existing student account, or approve creating one."}),e.jsxs("div",{className:"bg-white rounded-2xl border p-5 shadow-sm",children:[e.jsxs("h4",{className:"text-xs font-bold text-gray-700 uppercase tracking-wide mb-2 flex items-center gap-1.5",children:[e.jsx(en,{size:13})," Provisioning audit trail"]}),e.jsx("div",{className:"max-h-56 overflow-y-auto divide-y",children:x.length===0?e.jsx("p",{className:"text-[11px] text-gray-400 py-2",children:"No provisioning events recorded yet."}):x.map(F=>e.jsxs("div",{className:"py-2",children:[e.jsxs("p",{className:"text-xs text-gray-800",children:[e.jsx("span",{className:"font-bold",children:F.event_type}),F.person_name?` · ${F.person_name}`:"",F.account_student_id?` â ${F.account_student_id}`:""]}),e.jsxs("p",{className:"text-[10px] text-gray-500",children:[F.actor||"system"," · ",F.created_at?new Date(F.created_at).toLocaleString():"",F.detail?` · ${F.detail}`:""]})]},F.id))})]})]})]})]}):e.jsxs("div",{className:"max-w-3xl mx-auto my-10 p-6 rounded-2xl border-2",style:{borderColor:"#FCD34D",background:"#FFFBEB"},children:[e.jsxs("h2",{className:"text-lg font-bold text-amber-900 flex items-center gap-2",children:[e.jsx(Ie,{size:18})," Staff authentication required"]}),e.jsx("p",{className:"text-sm text-amber-800 mt-2",children:"Student provisioning reads and writes education-record identity data, so it is restricted to authenticated staff. Sign in with a staff account and reload this page."})]})},ipe="#B8962E",ope=t=>
1303t?new Date(t).toLocaleString(void 0,{dateStyle:"medium",timeStyle:"short"}):"â",lpe=({kind:t,state:s,busy:n,onSave:a,onSubmit:r})=>{const i=t==="letter_of_intent"?Y$:K$,[o,l]=d.useState((s==null?void 0:s.responses)||{}),[c,u]=d.useState(!1);d.useEffect(()=>{l((s==null?void 0:s.responses)||{})},[s]);const p=["submitted","under_review","accepted"].includes(String((s==null?void 0:s.status)||"")),m=t==="letter_of_intent"?"Letter of Intent":"Interview Preparation",x=t==="letter_of_intent"?Tm:jr,h=i.some(y=>y.minLength&&(o[y.key]||"").trim().length<y.minLength);return c?e.jsxs("div",{className:"mt-2 rounded-xl p-3",style:{background:`${k}04`,border:`1px solid ${k}14`},children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2 mb-1.5",children:[e.jsx(x,{size:13,style:{color:ipe}}),e.jsx("span",{className:"text-[11px] font-bold uppercase tracking-[0.14em]",style:{color:k},children:m}),(s==null?void 0:s.submittedAt)&&e.jsxs("span",{className:"inline-flex items-center gap-1 text-[9.5px] font-bold",style:{color:"#166534"},children:[e.jsx(Ue,{size:10})," Submitted ",ope(s.submittedAt)]}),e.jsx("button",{onClick:()=>u(!1),className:"ml-auto text-[10px] font-bold",style:{color:"#999"},children:"Close"})]}),(s==null?void 0:s.reviewReason)&&e.jsxs("p",{className:"text-[10.5px] mb-2 px-2 py-1.5 rounded",style:{background:"#FFFBEB",color:"#92400E"},children:[e.jsx("strong",{children:"Admissions asked for a correction:"})," ",s.reviewReason]}),e.jsx("div",{className:"space-y-2",children:i.map(y=>e.jsxs("label",{className:"block",children:[e.jsx("span",{className:"text-[10.5px] font-semibold",style:{color:k},children:y.label}),y.helper&&e.jsx("span",{className:"block text-[9.5px]",style:{color:"#999"},children:y.helper}),e.jsx("textarea",{rows:y.rows||3,disabled:p||n,value:o[y.key]||"",onChange:v=>l(g=>({...g,[y.key]:v.target.value})),className:"w-full mt-1 px-2.5 py-2 rounded-lg text-[11.5px] bg-white disabled:opacity-70",style:{border:`1px solid ${k}22`,color:k}}),y.minLength&&!p&&e.jsxs("span",{className:"text-[9px]",style:{color:(o[y.key]||"").trim().length>=y.minLength?"#166534":"#B45309"},children:[(o[y.key]||"").trim().length,"/",y.minLength," characters minimum"]})]},y.key))}),!p&&e.jsxs("div",{className:"flex flex-wrap items-center gap-2 mt-2.5",children:[e.jsxs("button",{onClick:()=>void a(o),disabled:n,className:"inline-flex items-center gap-1.5 px-3 py-1.5 rounded-lg text-[11px] font-bold disabled:opacity-50",style:{background:"transparent",color:k,border:`1px solid ${k}26`},children:[n?e.jsx(de,{size:10,className:"animate-spin"}):e.jsx(ti,{size:10})," Save draft"]}),e.jsxs("button",{onClick:()=>void r(o),disabled:n||h,className:"inline-flex items-center gap-1.5 px-3 py-1.5 rounded-lg text-[11px] font-bold disabled:opacity-50",style:{background:k,color:$},children:[n?e.jsx(de,{size:10,className:"animate-spin"}):e.jsx(Hs,{size:10})," Submit to Admissions"]}),e.jsx("span",{className:"text-[9.5px]",style:{color:"#999"},children:h?"Add a little more detail before submitting.":"Your answers are saved securely â you can finish later."})]})]}):e.jsxs("button",{onClick:()=>u(!0),className:"mt-2 inline-flex items-center gap-1.5 px-3 py-1.5 rounded-lg text-[11px] font-bold",style:{background:p?"transparent":k,color:p?k:$,border:`1px solid ${k}22`},children:[e.jsx(x,{size:11}),p?`Review your ${m.toLowerCase()}`:s!=null&&s.savedAt?`Continue ${m.toLowerCase()}`:`Complete ${m.toLowerCase()}`]})},aF="#B8962E",cpe=({token:t,agreement:s,onSigned:n,onError:a,onNotice:r})=>{const[i,o]=d.useState([]),[l,c]=d.useState(""),[u,p]=d.useState(!1),[m,x]=d.useState(null),h=s.snapshot||{},y=h.structured_fields||{},v=h.required_acknowledgements||[],g=s.state==="issued",N=g&&l.trim().length>=3&&u&&v.every(w=>i.includes(w.key)),b=w=>o(_=>_.includes(w)?_.filter(C=>C!==w):[..._,w]),f=async()=>{x("view");try{await ez(s.id,t)}catch(w){a(w.message)}finally{x(null)}},j=async()=>{x("doc");try{const{url:w}=await X$(s.id,t);window.open(w,"_blank","noopener,noreferrer")}catch(w){a(w.message)}finally{x(null)}},S=async()=>{x("sign");try{const{agreement:w}=await Eue(t,s.id,l.trim(),i);n(w),r("Your signature has been recorded. The agreement now goes to the Institute for its signature.")}catch(w){a(w.message)}finally{x(null)}};return e.jsxs("div",{className:"mt-2 rounded-xl px-3 py-2.5",style:{background:`${k}04`,border:`1px solid ${k}14`},children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2 mb-1.5",children:[e.jsx(Tm,{size:13,style:{color:aF}}),e.jsxs("span",{className:"text-[11.5px] font-bold",style:{color:k},children:[h.title||"Enrollment Agreement"," · ",s.programLabel]}),e.jsxs("span",{className:"text-[10px]",style:{color:"#8a8a8a"},children:["Version ",s.versionLabel]}),e.jsx("button",{onClick:()=>void f(),disabled:m==="view",className:"px-2 py-0.5 rounded text-[10px] font-bold disabled:opacity-50",style:{background:"#E0E7FF",color:"#3730A3"},children:m==="view"?"Openingâ¦":"Read the full agreement"}),s.state==="fully_executed"&&s.hasArtifact&&e.jsxs("button",{onClick:()=>void j(),disabled:m==="doc",className:"inline-flex items-center gap-1 px-2 py-0.5 rounded text-[10px] font-bold disabled:opacity-50",style:{background:`${$}22`,color:aF},children:[e.jsx(Xe,{size:9})," View signed copy"]})]}),e.jsx("div",{className:"rounded-md px-2 py-1.5 mb-2",style:{background:"#fff"},children:Object.keys(y).map(w=>e.jsxs("p",{className:"text-[10.5px]",style:{color:FN(y[w])?"#92400E":k},children:[e.jsxs("span",{style:{color:"#8a8a8a"},children:[J$[w]||w,":"]})," ",e.jsx("strong",{children:FN(y[w])?"To be confirmed by the Institute":String(y[w]??"â")})]},w))}),g?e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"space-y-1 mb-2",children:v.map(w=>e.jsxs("label",{className:"flex items-start gap-2 text-[10.5px]",style:{color:k},children:[e.jsx("input",{type:"checkbox",checked:i.includes(w.key),onChange:()=>b(w.key),className:"mt-0.5"}),e.jsx("span",{children:w.label})]},w.key))}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx("input",{value:l,onCh
1303ange:w=>c(w.target.value),maxLength:160,placeholder:"Type your full legal name to sign",className:"flex-1 min-w-[210px] px-2.5 py-1.5 rounded-lg text-[12px]",style:{border:`1px solid ${k}22`,color:k}}),e.jsxs("label",{className:"flex items-start gap-2 text-[10.5px]",style:{color:k},children:[e.jsx("input",{type:"checkbox",checked:u,onChange:w=>p(w.target.checked),className:"mt-0.5"}),e.jsx("span",{children:"I intend this typed name to be my electronic signature on this agreement."})]}),e.jsxs("button",{onClick:()=>void S(),disabled:!N||m==="sign",className:"inline-flex items-center gap-1.5 px-3 py-1.5 rounded-lg text-[11px] font-bold disabled:opacity-50",style:{background:k,color:$},children:[m==="sign"?e.jsx(de,{size:11,className:"animate-spin"}):e.jsx(Tm,{size:11}),"Sign agreement"]})]}),e.jsx("p",{className:"text-[9.5px] mt-1.5",style:{color:"#9CA3AF"},children:"You are signing this exact agreement version. The terms above are set by the Institute and cannot be edited here."})]}):e.jsx("p",{className:"text-[10.5px]",style:{color:"#666"},children:s.state==="fully_executed"?`Signed by you on ${s.applicantSignedAt?new Date(s.applicantSignedAt).toLocaleDateString():"â"} and countersigned by the Institute. A copy is saved to your admissions file.`:`Signed by you on ${s.applicantSignedAt?new Date(s.applicantSignedAt).toLocaleDateString():"â"}. The Institute's signature is pending â nothing further is needed from you right now.`})]})},Bg="#B8962E",dpe=({token:t,plan:s,onAcknowledged:n,onError:a,onNotice:r})=>{var f,j,S,w;const[i,o]=d.useState([]),[l,c]=d.useState(""),[u,p]=d.useState(!1),[m,x]=d.useState(!1),h=((f=s.acknowledgement)==null?void 0:f.statements)||[],y=s.state==="issued",v=sz(s.cost.total_program_cost_cents,s.funding),g=y&&l.trim().length>=3&&u&&h.every(_=>i.includes(_.key)),N=_=>o(C=>C.includes(_)?C.filter(E=>E!==_):[...C,_]),b=async()=>{x(!0);try{const{plan:_}=await Zue(t,s.id,l.trim(),i);n(_),r("Your Financial Responsibility Acknowledgement has been recorded. Admissions will confirm the next step with you.")}catch(_){a(_.message)}finally{x(!1)}};return e.jsxs("div",{className:"mt-2 rounded-xl px-3 py-2.5",style:{background:`${k}04`,border:`1px solid ${k}14`},children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2 mb-1.5",children:[e.jsx(ky,{size:13,style:{color:Bg}}),e.jsxs("span",{className:"text-[11.5px] font-bold",style:{color:k},children:["Your Financial Plan",s.programLabel?` · ${s.programLabel}`:""]}),e.jsxs("span",{className:"text-[10px]",style:{color:"#8a8a8a"},children:["Plan version ",s.version]})]}),s.revisionReason&&e.jsxs("p",{className:"text-[10.5px] mb-2 px-2 py-1.5 rounded",style:{background:"#FFFBEB",color:"#92400E"},children:[e.jsx("strong",{children:"Admissions is updating your plan:"})," ",s.revisionReason]}),e.jsxs("div",{className:"rounded-md px-2 py-1.5 mb-2",style:{background:"#fff"},children:[e.jsx("p",{className:"text-[9.5px] font-bold uppercase tracking-wider mb-1",style:{color:Bg},children:"Program cost"}),[["Tuition",s.cost.tuition_cents],["Books",s.cost.books_cents],["Materials / supplies / lab",s.cost.materials_cents],["Approved fees",s.cost.fees_cents],["Other approved charges",s.cost.other_charges_cents]].map(([_,C])=>e.jsxs("p",{className:"text-[10.5px]",style:{color:k},children:[e.jsxs("span",{style:{color:"#8a8a8a"},children:[_,":"]})," ",e.jsx("strong",{children:Ia(C)})]},String(_))),e.jsx("p",{className:"text-[11px] mt-1",style:{color:k},children:e.jsxs("strong",{children:["TOTAL PROGRAM COST: ",Ia(s.cost.total_program_cost_cents)]})}),s.cost.pendingReconciliation&&e.jsx("p",{className:"text-[10px] mt-0.5",style:{color:"#92400E"},children:"Some amounts are still being confirmed by the Institute."})]}),e.jsxs("div",{className:"rounded-md px-2 py-1.5 mb-2",style:{background:"#fff"},children:[e.jsx("p",{className:"text-[9.5px] font-bold uppercase tracking-wider mb-1",style:{color:Bg},children:"Your funding"}),s.funding.length===0&&e.jsx("p",{className:"text-[10.5px]",style:{color:"#9CA3AF"},children:"No funding sources have been added to your plan yet."}),s.funding.map(_=>{const C=db[_.status]||db.exploring;return e.jsxs("div",{className:"flex flex-wrap items-center gap-1.5 py-0.5",children:[e.jsx("span",{className:"text-[10.5px] flex-1 min-w-[150px]",style:{color:k},children:_.label||zue(_.kind)}),e.jsx("span",{className:"px-1.5 py-0.5 rounded text-[9px] font-bold uppercase tracking-wider",style:{background:C.bg,color:C.fg},children:PN[_.status]}),e.jsx("span",{className:"text-[10.5px] font-semibold",style:{color:tz(_.status)?"#166534":"#92400E"},children:Ia(_.amount_cents)})]},_.key)}),e.jsxs("p",{className:"text-[10.5px] mt-1.5",style:{color:k},children:["Confirmed funding: ",e.jsx("strong",{style:{color:"#166534"},children:Ia(v.confirmedFundingCents)})]}),e.jsx("p",{className:"text-[11px]",style:{color:k},children:e.jsxs("strong",{children:["Current expected responsibility: ",Ia(v.currentConfirmedResponsibilityCents)]})}),v.potentialFundingCents>0&&e.jsxs("p",{className:"text-[10px] mt-0.5",style:{color:"#92400E"},children:["Pending / estimated funding of ",Ia(v.potentialFundingCents)," is ",e.jsx("strong",{children:"not guaranteed"}),". If it is all approved, your responsibility would be about ",Ia(v.projectedResponsibilityCents),"."]}),((j=s.paymentPlan)==null?void 0:j.selected)&&e.jsxs("p",{className:"text-[10px] mt-1",style:{color:"#8a8a8a"},children:["Institutional payment plan: ",s.paymentPlan.requires_staff_configuration?"the Institute will confirm your payment schedule with you â no installment amounts or dates have been set yet.":s.paymentPlan.note||"See the note from Admissions below."]})]}),s.summaryNote&&e.jsx("p",{className:"text-[10.5px] mb-2 px-2 py-1.5 rounded",style:{background:"#F8FAFC",color:"#475569"},children:s.summaryNote}),y?e.jsxs(e.Fragment,{children:[e.jsxs("p",{className:"text-[9.5px] font-bold uppercase tracking-wider mb-1",style:{color:Bg},children:[((S=s.acknowledgement)==null?void 0:S.title)||"Financial Responsibility Acknowledgement",(w=s.acknowledgement)!=null&&w.version_label?` · ${s.acknowledgement.version_label}`:""]}),e.jsx("div",{className:"space-y-1 mb-2",children:h.map(_=>e.jsxs("label",{className:"flex items-start gap-2 text-[10.5px]",style:{color:k},children:[e.jsx("input",{type:"checkbox",checked:i.includes(_.ke
1303y),onChange:()=>N(_.key),className:"mt-0.5"}),e.jsx("span",{children:_.label})]},_.key))}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx("input",{value:l,onChange:_=>c(_.target.value),maxLength:160,placeholder:"Type your full legal name",className:"flex-1 min-w-[210px] px-2.5 py-1.5 rounded-lg text-[12px]",style:{border:`1px solid ${k}22`,color:k}}),e.jsxs("label",{className:"flex items-start gap-2 text-[10.5px]",style:{color:k},children:[e.jsx("input",{type:"checkbox",checked:u,onChange:_=>p(_.target.checked),className:"mt-0.5"}),e.jsx("span",{children:"I acknowledge this Financial Plan electronically."})]}),e.jsxs("button",{onClick:()=>void b(),disabled:!g||m,className:"inline-flex items-center gap-1.5 px-3 py-1.5 rounded-lg text-[11px] font-bold disabled:opacity-50",style:{background:k,color:$},children:[m?e.jsx(de,{size:11,className:"animate-spin"}):e.jsx(ky,{size:11})," Acknowledge plan"]})]}),e.jsx("p",{className:"text-[9.5px] mt-1.5",style:{color:"#9CA3AF"},children:"You are acknowledging this exact plan version. Acknowledging does not award funding and does not enrol you."})]}):e.jsx("p",{className:"text-[10.5px]",style:{color:"#666"},children:s.state==="complete"?`Acknowledged on ${s.acknowledgedAt?new Date(s.acknowledgedAt).toLocaleDateString():"â"} â this step is complete.`:s.state==="acknowledged"?`Acknowledged on ${s.acknowledgedAt?new Date(s.acknowledgedAt).toLocaleDateString():"â"}. Admissions is finishing its review â nothing further is needed from you right now.`:"Admissions is preparing an updated plan for you."})]})},Oc="#B8962E",Ug="zorganics_applicant_token",rF=t=>t?new Date(t).toLocaleString(void 0,{dateStyle:"medium",timeStyle:"short"}):"â",Zp=async t=>{const{data:s,error:n}=await O.functions.invoke("applicant-portal",{body:t});if(n)throw new Error(n.message||"Network error");if(!(s!=null&&s.success))throw new Error((s==null?void 0:s.error)||"Request failed");return s},upe=()=>{const[t,s]=d.useState(()=>localStorage.getItem(Ug)),[n,a]=d.useState(""),[r,i]=d.useState(""),[o,l]=d.useState(null),[c,u]=d.useState([]),[p,m]=d.useState([]),[x,h]=d.useState(null),[y,v]=d.useState(null),[g,N]=d.useState(null),[b,f]=d.useState(null),[j,S]=d.useState(!1),[w,_]=d.useState(null),[C,E]=d.useState(null),[P,F]=d.useState(null),I=d.useRef({}),D=U=>{u(U.requirements||[]),m(U.documents||[]),h(U.letter||null),v(U.interview||null)},L=d.useCallback(async U=>{S(!0),E(null);try{const q=await Zp({action:"session",token:U});l(q.applicant),D(q);try{const H=await Aue(U);N(H.agreement||null)}catch{N(null)}try{const H=await Vue(U);f(H.plan||null)}catch{f(null)}}catch(q){localStorage.removeItem(Ug),s(null),E(q.message)}finally{S(!1)}},[]);d.useEffect(()=>{t&&L(t)},[t,L]);const V=async U=>{U.preventDefault(),_("signin"),E(null);try{const q=await Zp({action:"signin",email:n.trim(),code:r.trim()});localStorage.setItem(Ug,String(q.token)),s(String(q.token)),i("")}catch(q){E(q.message)}finally{_(null)}},B=()=>{localStorage.removeItem(Ug),s(null),l(null),u([]),m([]),h(null),v(null),N(null),f(null)},A=async(U,q,H)=>{_(U),E(null),F(null);try{const W=await Zp({action:U==="letter_of_intent"?H?"loi-submit":"loi-save":H?"interview-prep-submit":"interview-prep-save",token:t,responses:q});D(W),F(H?"Submitted to Admissions. You will see the status update here once it has been reviewed.":"Draft saved â you can close this page and finish later.")}catch(G){E(G.message)}finally{_(null)}},z=async(U,q)=>{const H=EN(U.requirement_key),G=(H==null?void 0:H.documentType)||"other_admissions_document";if(_(U.id),E(null),F(null),!F4.includes(q.type)){E("Please upload a PDF, JPG, PNG, HEIC or WEBP file."),_(null);return}if(q.size>qde){E("That file is larger than the 10 MB limit."),_(null);return}try{const W=await new Promise((Q,K)=>{const se=new FileReader;se.onload=()=>Q(String(se.result||"")),se.onerror=()=>K(new Error("Could not read that file")),se.readAsDataURL(q)}),X=await Zp({action:"upload",token:t,requirementId:U.id,documentType:G,fileName:q.name,mimeType:q.type,fileBase64:W});u(X.requirements||[]),m(X.documents||[]),F(`${U.requirement_label} uploaded securely and sent to Admissions for review.`)}catch(W){E(W.message)}finally{_(null);const W=I.current[U.id];W&&(W.value="")}},M=async U=>{_(U.id),E(null);try{const q=await Zp({action:"doc-url",token:t,documentId:U.id});window.open(String(q.url),"_blank","noopener,noreferrer")}catch(q){E(q.message)}finally{_(null)}};if(!t)return e.jsx("div",{className:"min-h-screen flex items-center justify-center px-4 py-12",style:{background:"#FBF9F5"},children:e.jsxs("div",{className:"w-full max-w-md rounded-2xl p-6",style:{background:"#fff",border:`1px solid ${k}18`},children:[e.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[e.jsx(Xe,{size:16,style:{color:Oc}}),e.jsx("h1",{className:"text-[15px] font-bold uppercase tracking-[0.18em]",style:{color:k},children:"Applicant Access"})]}),e.jsx("p",{className:"text-[11.5px] mb-4",style:{color:"#777"},children:"Sign in with the email on your admissions application and the one-time access code Admissions gave you."}),C&&e.jsx("p",{className:"text-[11px] mb-3 px-2.5 py-2 rounded",style:{background:"#FEF2F2",color:"#991B1B"},children:C}),e.jsxs("form",{onSubmit:V,className:"space-y-3",children:[e.jsxs("label",{className:"block",children:[e.jsx("span",{className:"text-[9.5px] uppercase tracking-wider font-bold",style:{color:"#999"},children:"Email"}),e.jsx("input",{type:"email",required:!0,value:n,onChange:U=>a(U.target.value),className:"w-full mt-1 px-3 py-2 rounded-lg text-[12.5px]",style:{border:`1px solid ${k}22`,color:k},placeholder:"[email protected]"})]}),e.jsxs("label",{className:"block",children:[e.jsx("span",{className:"text-[9.5px] uppercase tracking-wider font-bold",style:{color:"#999"},children:"Access code"}),e.jsx("input",{required:!0,value:r,onChange:U=>i(U.target.value),maxLength:16,className:"w-full mt-1 px-3 py-2 rounded-lg text-[14px] font-mono tracking-[0.2em] uppercase",style:{border:`1px solid ${k}22`,color:k},placeholder:"XXXXX-XXXXX"})]}),e.jsxs("button",{type:"submit",disabled:w==="signin",className:"w-full inline-flex items-center justify-center gap-2 px-4 py-2.5 rounded-lg text-[12px] font-bold disabled:opacity-50",style:{background:k,color:$},children:[w==="signin"?e.jsx(de,{size:12,className:"animate-spin"}):e.jsx(Ie,{size:12}),"Sign in securely"]})]}),e.jsx("p",{className:"text-[9.5px] mt-4 leading-relaxed",style:{color:"#A0A0A0"},children:"Your documents are stored privately and are visible only to you and authorized Admissions staff. We never ask for Social Security documentation through this portal. If you do not have a code, contact the Admissions office."})]})});const R=Q$(c),T=c.filter(U=>U.status!=="not_required");return e.jsx("div",{className:"min-h-screen px-4 py-8",style:{background:"#FBF9F5"},children:e.jsxs("div",{className:"max-w-4xl mx-auto",children:[e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3 mb-5",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-[9.5px] uppercase tracking-[0.2em] font-bold",style:{color:Oc},children:"Zorganics Institute · Admissions"}),e.jsx("h1",{className:"text-[20px] font-bold",style:{color:k},children:(o==null?void 0:o.fullName)||"Your application"}),e.jsxs("p",{className:"text-[11.5px]",style:{color:"#777"},children:[o!=null&&o.program?`${o.program} · `:"","Application submitted ",rF(o==null?void 0:o.submittedAt)]})]}),e.jsxs("button",{onClick:B,className:"inline-flex items-center gap-1.5 px-3 py-1.5 rounded-lg text-[11px] font-bold",style:{background:"transparent",color:k,border:`1px solid ${k}22`},children:[e.jsx(bo,{size:11})," Sign out"]})]}),C&&e.jsxs("p",{className:"text-[11.5px] mb-3 px-3 py-2 rounded flex items-start gap-2",style:{background:"#FEF2F2",color:"#991B1B"},children:[e.jsx(ve,{size:13,style:{marginTop:1}})," ",C]}),P&&e.jsxs("p",{className:"text-[11.5px] mb-3 px-3 py-2 rounded flex items-start gap-2",style:{background:"#ECFDF5",color:"#065F46"},children:[e.jsx(Ue,{size:13,style:{marginTop:1}})," ",P]}),e.jsxs("div",{className:"rounded-2xl p-4",style:{background:"#fff",border:`1px solid ${k}18`},children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2 mb-1",children:[e.jsx(mn,{size:15,style:{color:Oc}}),e.jsx("h2",{className:"text-[12.5px] font-bold uppercase tracking-[0.16em]",style:{color:k},children:"Admissions Checklist"}),e.jsx("span",{className:"px-2 py-0.5 rounded text-[10.5px] font-bold",style:{background:`${$}22`,color:Oc},children:j?"Loadingâ¦":R.label})]}),e.jsx("p",{className:"text-[10.5px] mb-2.5",style:{color:"#999"},children:"Admissions Progress"}),e.jsx("div",{className:"h-1.5 rounded-full mb-4 overflow-hidden",style:{background:`${k}12`},children:e.jsx("div",{className:"h-full rounded-full",style:{width:`${R.requiredTotal?Math.round(R.requiredSatisfied/R.requiredTotal*100):0}
1303%`,background:`linear-gradient(90deg, ${$}, ${Oc})`}})}),e.jsx("div",{className:"space-y-2",children:T.map(U=>{const q=EN(U.requirement_key),H=U.requirement_key==="letter_of_intent"||U.requirement_key==="admissions_interview",G=U.requirement_key==="enrollment_agreement",W=U.requirement_key==="financial_plan",X=!!(q!=null&&q.documentType)&&!H&&!G&&!W,Q=G?g?g.state==="fully_executed"?"complete":g.state==="issued"?"action_needed":"under_review":"not_available":W?b?b.state==="complete"?"complete":b.state==="issued"?"action_needed":b.state==="revision_required"?"not_available":"under_review":"not_available":hue(U,{applicantActionable:X||H}),K=pue[Q],se=p.filter(te=>te.requirement_id===U.id&&te.status!=="superseded"),Y=X&&!Bm(U.status),J=U.requirement_key==="letter_of_intent"?x?{responses:x.responses||{},status:x.status,savedAt:x.saved_at,submittedAt:x.submitted_at,reviewReason:U.status==="needs_correction"||U.status==="rejected"?x.review_reason||U.decision_reason:null}:{responses:{},status:"draft"}:U.requirement_key==="admissions_interview"?y?{responses:y.prep_responses||{},status:y.prep_status==="submitted"?"submitted":"draft",savedAt:y.prep_saved_at,submittedAt:y.prep_submitted_at,reviewReason:y.follow_up_required?y.follow_up_note:null}:{responses:{},status:"draft"}:null;return e.jsxs("div",{className:"rounded-xl px-3 py-2.5",style:{border:`1px solid ${k}12`},children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[Q==="complete"?e.jsx(Ue,{size:14,style:{color:"#166534"}}):e.jsx("span",{className:"inline-block w-[14px] h-[14px] rounded-full",style:{border:`1.5px solid ${k}44`}}),e.jsx("span",{className:"text-[12.5px] font-semibold flex-1 min-w-[150px]",style:{color:k},children:U.requirement_label}),e.jsx("span",{className:"px-1.5 py-0.5 rounded text-[9px] font-bold uppercase tracking-wider",style:{background:K.bg,color:K.fg},children:mue[Q]})]}),e.jsx("p",{className:"text-[10.5px] mt-1",style:{color:"#888"},children:W&&b?$ue[b.state]:Q==="not_available"?"Admissions will complete this step with you â nothing for you to do here yet.":U.helper||(q==null?void 0:q.helper)||""}),U.decision_reason&&(U.status==="needs_correction"||U.status==="rejected")&&e.jsxs("p",{className:"text-[11px] mt-1.5 px-2 py-1.5 rounded",style:{background:"#FFFBEB",color:"#92400E"},children:[e.jsx("strong",{children:"Admissions asked for a correction:"})," ",U.decision_reason]}),se.map(te=>e.jsxs("div",{className:"mt-1.5 flex flex-wrap items-center gap-2 px-2 py-1.5 rounded",style:{background:`${k}06`},children:[e.jsx(Xe,{size:10,style:{color:Oc}}),e.jsxs("span",{className:"text-[10.5px]",style:{color:k},children:[G$[te.document_type]," · ",te.file_name]}),e.jsxs("span",{className:"text-[10px]",style:{color:"#888"},children:[V$[te.status]||te.status," · ",rF(te.uploaded_at)]}),e.jsxs("button",{onClick:()=>void M(te),disabled:w===te.id,className:"inline-flex items-center gap-1 px-2 py-0.5 rounded text-[10px] font-bold disabled:opacity-50",style:{background:k,color:$},children:[w===te.id?e.jsx(de,{size:9,className:"animate-spin"}):e.jsx(Kt,{size:9})," View"]})]},te.id)),H&&J&&e.jsx(lpe,{kind:U.requirement_key==="letter_of_intent"?"letter_of_intent":"admissions_interview",state:J,busy:w===U.requirement_key,onSave:te=>A(U.requirement_key==="letter_of_intent"?"letter_of_intent":"admissions_interview",te,!1),onSubmit:te=>A(U.requirement_key==="letter_of_intent"?"letter_of_intent":"admissions_interview",te,!0)}),G&&g&&t&&e.jsx(cpe,{token:t,agreement:g,onSigned:te=>{N(te),t&&L(t)},onError:E,onNotice:F}),W&&b&&t&&e.jsx(dpe,{token:t,plan:b,onAcknowledged:te=>{f(te),t&&L(t)},onError:E,onNotice:F}),Y&&e.jsxs("div",{className:"mt-2 flex flex-wrap items-center gap-2",children:[e.jsx("input",{ref:te=>{I.current[U.id]=te},type:"file",accept:F4.join(","),onChange:te=>{var Fe;const pe=(Fe=te.target.files)==null?void 0:Fe[0];pe&&z(U,pe)},className:"text-[10.5px]",style:{color:"#666"}}),w===U.id&&e.jsxs("span",{className:"inline-flex items-center gap-1 text-[10.5px]",style:{color:Oc},children:[e.jsx(de,{size:10,className:"animate-spin"})," Uploading securelyâ¦"]})]})]},U.id)})}),!j&&c.length===0&&e.jsx("p",{className:"text-[12px] text-center py-6",style:{color:"#999"},children:"Admissions has not published your requirements yet. Check back soon."})]}),e.jsxs("div",{className:"rounded-xl p-3 mt-4 flex items-start gap-2",style:{background:"#F8FAFC",border:"1px solid #E2E8F0"},children:[e.jsx(Ri,{size:13,style:{color:"#64748B",marginTop:1}}),e.jsx("p",{className:"text-[10.5px] leading-relaxed",style:{color:"#64748B"},children:"PDF, JPG, PNG, HEIC or WEBP up to 10 MB. Uploads are private, versioned and reviewed by Admissions â your progress is saved, so you can close this page and return later with the same code-issued session. We do not collect Social Security documentation or financial-aid verification documents here."})]})]})})},mpe=["Press","Institute News","Community","Student Success","Campus Update"],ur="/news",Ai="News & Press";function od(t){return`${ur}/${t}`}const ppe="https://d64gsuwffb70l.cloudfront.net/69caed6904ed6aca7682413a_1789516020719_900d9dd4.webp",hpe="Frida Emalange, Founder of Zorganics Institute of Beauty & Wellness",kk=[{slug:"ein-presswire-career-pathways-esthetics-wellness-washington",headline:"ZORGANICS® Institute Expands Career Pathways with Professional Esthetics & Wellness Training in Washington",source:"EIN Presswire",date:"2026-09-07",category:"Press",summary:"EIN Presswire featured Zorganics Institute of Beauty & Wellness and its licensed career pathways in professional esthetics and wellness training in Washington State. Read our summary of the coverage, then continue to the original feature on EIN Presswire.",image:ppe,imageAlt:hpe,externalUrl:"https://www.einpresswire.com/article/940386929/zorganics-institute-ex
1303pands-career-pathways-with-professional-esthetics-wellness-training-in-washington",externalLabel:"Read the Full EIN Presswire Feature",seoTitle:"EIN Presswire Features Zorganics Institute Career Pathways | News & Press",seoDescription:"EIN Presswire featured Zorganics Institute of Beauty & Wellness and its professional esthetics and wellness career pathways in Washington State. Read the Institute summary and link to the original feature.",body:["On September 7, 2026, EIN Presswire published a feature on Zorganics Institute of Beauty & Wellness and the career pathways the Institute offers in professional esthetics and wellness training in Washington State.",{heading:"Why this coverage matters"},"Choosing a licensed beauty and wellness program is a significant decision. Independent coverage helps prospective students, families and community partners see how a school presents its programs publicly â and gives them a starting point for asking better questions about hours, licensure preparation and campus experience.","For the Bellingham community, the feature is also a reminder that licensed career training in esthetics, cosmetology, manicuring and instructor preparation is available locally, taught on a working campus with a supervised Student Salon & Clinic.",{heading:"What prospective students should do next"},"The most reliable information about any Zorganics Institute program is always the program page itself and the School Catalog: clock hours, curriculum, admissions requirements and published tuition are documented there. Prospective students are encouraged to review the program pages, schedule a campus tour, and speak with Admissions before making a decision.","Financial aid is available to those who qualify. Questions about eligibility, costs and start dates should be directed to the Admissions office.",{heading:"About the original article"},"The full feature is published by EIN Presswire. Zorganics Institute has summarized the coverage above in its own words; the complete article remains on the publisherâs website and can be read using the button on this page."],relatedLinks:[{label:"Explore our licensed programs",path:"/programs"},{label:"Admissions requirements & start dates",path:"/admissions"},{label:"Schedule a campus tour",path:"/book-online"},{label:"Contact the Institute",path:"/contact"}]}];function $N(){return[...kk].sort((t,s)=>t.date<s.date?1:-1)}function xpe(t){if(!t)return;const s=t.trim().toLowerCase();return kk.find(n=>n.slug===s)}function fpe(){const t=new Set(kk.map(s=>s.category));return mpe.filter(s=>t.has(s))}function zN(t){const[s,n,a]=t.split("-").map(Number);return!s||!n||!a?t:new Date(Date.UTC(s,n-1,a)).toLocaleDateString("en-US",{year:"numeric",month:"long",day:"numeric",timeZone:"UTC"})}const Y0="#5A1A24",K0="#7A3A44",gpe="#F2EBE3",LN="#FAF7F2",cz="#E8DDD0",ype="https://d64gsuwffb70l.cloudfront.net/69cae7fb5ea7db794957149e_1775337912224_4cc82887.jfif",nt={plum:k,plumMedium:Y0,plumLight:K0,gold:$,cream:LN,tan:cz,body:"#4A2228"},ON=({eyebrow:t=Ai,title:s,subtitle:n,meta:a,crumbs:r,backTo:i="/",backLabel:o="Back to Home",children:l})=>(d.useEffect(()=>{window.scrollTo({top:0,behavior:"auto"})},[s]),e.jsxs("div",{className:"min-h-screen",style:{background:`linear-gradient(180deg, ${gpe} 0%, ${LN} 100%)`},children:[e.jsxs("header",{className:"relative",style:{background:k},children:[e.jsx("div",{className:"h-[3px]",style:{background:`linear-gradient(90deg, rgba(212,175,55,0) 0%, ${$} 50%, rgba(212,175,55,0) 100%)`}}),e.jsxs("div",{className:"max-w-[1100px] mx-auto px-4 lg:px-8 py-6 flex items-center justify-between gap-4",children:[e.jsxs(be,{to:"/",className:"flex items-center gap-3 group",children:[e.jsx("div",{className:"w-11 h-11 rounded-xl overflow-hidden flex-shrink-0",style:{boxShadow:`0 0 0 1.5px ${$}`},children:e.jsx("img",{src:ype,alt:"Zorganics Institute",className:"w-full h-full object-cover"})}),e.jsxs("div",{children:[e.jsxs("h2",{className:"font-display text-lg font-bold",style:{color:"#FFFFFF"},children:["Zorganics",e.jsx("span",{style:{color:$},children:" Institute"})]}
1303),e.jsx("p",{className:"text-[10px] tracking-wider uppercase",style:{color:"rgba(212,175,55,0.7)"},children:"A Holistic Approach To Beauty and Wellness through Science and Art"})]})]}),e.jsxs(be,{to:i,className:"inline-flex items-center gap-2 px-4 py-2 rounded-lg text-xs font-bold uppercase tracking-wider transition-all hover:-translate-y-0.5",style:{background:"rgba(212,175,55,0.12)",color:$,border:"1px solid rgba(212,175,55,0.4)"},children:[e.jsx(Je,{size:14})," ",o]})]})]}),e.jsxs("div",{className:"max-w-[1100px] mx-auto px-4 lg:px-8 pt-10 pb-8",children:[r&&r.length>0&&e.jsx("nav",{"aria-label":"Breadcrumb",className:"mb-4 text-[11px]",style:{color:K0},children:e.jsx("ol",{className:"flex items-center gap-2 flex-wrap",children:r.map((c,u)=>e.jsxs("li",{className:"flex items-center gap-2",children:[c.path?e.jsx(be,{to:c.path,className:"hover:underline font-medium",children:c.label}):e.jsx("span",{"aria-current":"page",className:"font-semibold",style:{color:Y0},children:c.label}),u<r.length-1&&e.jsx("span",{"aria-hidden":"true",children:"/"})]},`${c.label}-${u}`))})}),e.jsxs("div",{className:"inline-flex items-center gap-2 px-3 py-1.5 rounded-full text-[10px] font-bold uppercase tracking-wider mb-4",style:{background:"rgba(212,175,55,0.10)",color:"#8A6D1E",border:"1px solid rgba(212,175,55,0.30)"},children:[e.jsx(WP,{size:12})," ",t]}),e.jsx("h1",{className:"font-display text-3xl lg:text-[2.6rem] font-bold leading-tight max-w-4xl",style:{color:k},children:s}),a&&e.jsx("div",{className:"mt-4",children:a}),n&&e.jsx("p",{className:"mt-4 text-base leading-relaxed max-w-3xl",style:{color:Y0},children:n})]}),e.jsx("main",{className:"max-w-[1100px] mx-auto px-4 lg:px-8 pb-16",children:l}),e.jsxs("div",{className:"max-w-[1100px] mx-auto px-4 lg:px-8 pb-14",children:[e.jsxs("div",{className:"rounded-2xl p-6 lg:p-7 flex flex-col sm:flex-row sm:items-center sm:justify-between gap-4",style:{background:LN,border:`1px solid ${cz}`},children:[e.jsxs("div",{children:[e.jsx("h3",{className:"text-sm font-bold uppercase tracking-wider",style:{color:k},children:"Media & Press Inquiries"}),e.jsx("p",{className:"text-sm mt-1",style:{color:K0},children:"Members of the media may contact the Institute for interviews, campus visits and program information."})]}),e.jsx(be,{to:"/contact",className:"inline-flex items-center justify-center gap-2 px-5 py-2.5 rounded-lg text-xs font-bold uppercase tracking-wider transition-all hover:-translate-y-0.5 whitespace-nowrap",style:{background:k,color:$,border:`1px solid ${$}`},children:"Contact the Institute"})]}),e.jsxs("p",{className:"mt-6 text-center text-[11px]",style:{color:K0},children:[e.jsx(be,{to:ur,className:"font-semibold hover:underline",style:{color:Y0},children:Ai})," · ","© 2026 Zorganics Institute of Beauty & Wellness · NACCAS Accredited · WA State DOL Certified"]})]})]})),qg={title:"News & Press | Zorganics Institute â Bellingham WA",description:"News & Press from Zorganics Institute of Beauty & Wellness â institute news, media coverage, community initiatives, student success and campus updates from our Bellingham, Washington campus."},bpe=()=>{const[t,s]=d.useState("All"),n=d.useMemo(()=>$N(),[]),a=d.useMemo(()=>fpe(),[]),r=d.useMemo(()=>t==="All"?n:n.filter(i=>i.category===t),[n,t]);return Ho(qg),d.useEffect(()=>(qa(qg),Jl(`${Mi}${ur}`),Qn("page",M5({type:"CollectionPage",name:qg.title,description:qg.description,path:ur})),Qn("page-breadcrumb",ip([{name:"Home",path:"/"},{name:Ai,path:ur}])),Qn("news-list",QQ(n.map(i=>({headline:i.headline,path:od(i.slug),datePublished:i.date})))),()=>{Jn("page"),Jn("page-breadcrumb"),Jn("news-list"),Jl(`${Mi}/`),qa(wr)}),[n]),e.jsxs(ON,{title:Ai,subtitle:"Announcements from Zorganics Institute of Beauty & Wellness and media coverage of our programs, campus and community. Outside coverage is summarized here in our own words, with a link to the original publisher.",crumbs:[{label:"Home",path:"/"},{label:Ai}],children:[a.length>1&&e.jsx("div",{className:"flex flex-wrap items-center gap-2 mb-8",children:["All",...a].map(i=>{const o=t===i;return e.jsx("button",{type:"button",onClick:()=>s(i),className:"px-4 py-2 rounded-full text-[11px] font-bold uppercase tracking-wider transition-all",style:{background:o?nt.plum:"#FFFFFF",color:o?nt.gold:nt.plumMedium,border:`1px solid ${o?nt.plum:nt.tan}`},children:i},i)})}),r.length===0?e.jsx("div",{className:"rounded-3xl p-10 text-center",style:{background:"#FFFFFF",border:`1px solid ${nt.tan}`},children:e.jsx("p",{className:"text-sm",style:{color:nt.plumLight},children:"No items in this category yet. Please check back soon."})}):e.jsx("div",{className:"grid gap-6 md:grid-cols-2",children:r.map(i=>e.jsxs("article",{className:"rounded-3xl overflow-hidden flex flex-col transition-all hover:-translate-y-0.5",style:{background:"#FFFFFF",border:`1px solid ${nt.tan}`,boxShadow:"0 8px 40px rgba(59,10,17,0.05)"},children:[i.image&&e.jsx(be,{to:od(i.slug),className:"w-full flex items-center justify-center overflow-hidden",style:{background:nt.cream,borderBottom:`1px solid ${nt.tan}`},children:e.jsx("img",{src:i.image,alt:i.imageAlt||i.headline,className:"w-full h-auto max-h-56 sm:max-h-64 lg:max-h-72 object-contain",loading:"lazy",decoding:"async"})}),e.jsxs("div",{className:"p-6 lg:p-7 flex flex-col flex-1",children:[e.jsxs("div",{className:"flex items-center gap-2 flex-wrap mb-3",children:[e.jsx("span",{className:"px-2.5 py-1 rounded-full text-[10px] font-bold uppercase tracking-wider",style:{background:"rgba(212,175,55,0.12)",color:"#8A6D1E",border:"1px solid rgba(212,175,55,0.30)"},children:i.category}),e.jsxs("span",{className:"inline-flex items-center gap-1.5 text-[11px] font-medium",style:{color:nt.plumLight},children:[e.jsx(Ii,{size:12,style:{color:nt.gold}}),e.jsx("time",{dateTime:i.date,children:zN(i.date)})]})]}),e.jsx("h2",{className:"font-display text-xl font-bold leading-snug",style:{color:nt.plum},children:e.jsx(be,{to:od(i.slug),className:"hover:underline",children:i.headline})}),e.jsxs("p",{className:"text-[11px] font-semibold uppercase tracking-wider mt-2",style:{color:nt.plumLight},children:["Source: ",i.source]}),e.jsx("p",{className:"mt-3 text-[15px] leading-relaxed flex-1",style:{color:nt.body},children:i.summary}),e.jsxs("div",{className:"mt-5 flex items-center gap-4 flex-wrap",children:[e.jsxs(be,{to:od(i.slug),className:"inline-flex items-center gap-2 px-5 py-2.5 rounded-lg text-xs font-bold uppercase tracking-wider transition-all hover:-translate-y-0.5",style:{background:nt.plum,color:nt.gold,border:`1px solid ${nt.gold}`},children:["Read More ",e.jsx(xO,{size:14})]}),i.externalUrl&&e.jsxs("a",{href:i.externalUrl,target:"_blank",rel:"noopener noreferrer nofollow",className:"inline-flex items-center gap-1.5 text-xs font-semibold hover:underline",style:{color:nt.plumMedium},children:[e.jsx(Ua,{size:13,style:{color:nt.gold}})," ",i.source]})]})]})]},i.slug))}),e.jsxs("div",{className:"mt-10 rounded-2xl p-6 lg:p-7",style:{background:"#FFFFFF",border:`1px solid ${nt.tan}`},children:[e.jsx("h3",{className:"text-sm font-bold uppercase tracking-wider mb-3",style:{color:nt.plum},children:"Explore the Institute"}),e.jsx("div",{className:"flex flex-wrap gap-x-6 gap-y-2",children:[{label:"Licensed Programs",path:"/programs"},{label:"Admissions",path:"/admissions"},{label:"Schedule a Tour",path:"/book-online"},{label:"Student Salon & Clinic",path:"/student-clinic"}
1303,{label:"School Catalog",path:"/school-catalog"},{label:"Contact",path:"/contact"}].map(i=>e.jsx(be,{to:i.path,className:"text-sm font-medium hover:underline",style:{color:nt.plumMedium},children:i.label},i.path))})]})]})},vpe=()=>{const{slug:t}=Wo(),s=xpe(t),n=s?{title:s.seoTitle,description:s.seoDescription}:{title:"News & Press | Zorganics Institute â Bellingham WA",description:"News & Press from Zorganics Institute of Beauty & Wellness in Bellingham, Washington."};if(Ho(n),d.useEffect(()=>{qa(n);const r=s?od(s.slug):ur;return Jl(`${Mi}${r}`),s&&(Qn("page",KQ({headline:s.headline,description:s.summary,datePublished:s.date,path:r,source:s.source,externalUrl:s.externalUrl,image:s.image,category:s.category})),Qn("page-breadcrumb",ip([{name:"Home",path:"/"},{name:Ai,path:ur},{name:s.headline}]))),()=>{Jn("page"),Jn("page-breadcrumb"),Jl(`${Mi}/`),qa(wr)}},[s==null?void 0:s.slug]),!s){const r=$N();return e.jsx(ON,{title:"Item Not Found",subtitle:"This News & Press item is not available. Browse the current announcements and coverage below.",crumbs:[{label:"Home",path:"/"},{label:Ai,path:ur},{label:"Not Found"}],backTo:ur,backLabel:"All News & Press",children:e.jsxs("div",{className:"rounded-3xl p-6 lg:p-8",style:{background:"#FFFFFF",border:`1px solid ${nt.tan}`},children:[e.jsx("ul",{className:"space-y-3",children:r.map(i=>e.jsx("li",{children:e.jsx(be,{to:od(i.slug),className:"text-[15px] font-semibold hover:underline",style:{color:nt.plumMedium},children:i.headline})},i.slug))}),e.jsxs(be,{to:ur,className:"inline-flex items-center gap-2 mt-6 px-5 py-2.5 rounded-lg text-xs font-bold uppercase tracking-wider",style:{background:nt.plum,color:nt.gold,border:`1px solid ${nt.gold}`},children:[e.jsx(Je,{size:14})," All ",Ai]})]})})}const a=$N().filter(r=>r.slug!==s.slug).slice(0,3);return e.jsxs(ON,{title:s.headline,crumbs:[{label:"Home",path:"/"},{label:Ai,path:ur},{label:s.category}],backTo:ur,backLabel:"All News & Press",meta:e.jsxs("div",{className:"flex items-center gap-3 flex-wrap",children:[e.jsx("span",{className:"px-2.5 py-1 rounded-full text-[10px] font-bold uppercase tracking-wider",style:{background:"rgba(212,175,55,0.12)",color:"#8A6D1E",border:"1px solid rgba(212,175,55,0.30)"},children:s.category}),e.jsxs("span",{className:"inline-flex items-center gap-1.5 text-[12px] font-medium",style:{color:nt.plumLight},children:[e.jsx(Ii,{size:13,style:{color:nt.gold}}),e.jsx("time",{dateTime:s.date,children:zN(s.date)})]}),e.jsxs("span",{className:"inline-flex items-center gap-1.5 text-[12px] font-semibold",style:{color:nt.plumMedium},children:[e.jsx(WP,{size:13,style:{color:nt.gold}})," Source: ",s.source]})]}),children:[e.jsxs("article",{className:"rounded-3xl p-6 lg:p-12",style:{background:"#FFFFFF",border:`1px solid ${nt.tan}`,boxShadow:"0 8px 40px rgba(59,10,17,0.05)"},children:[s.image&&e.jsx("figure",{className:"w-full rounded-2xl overflow-hidden mb-8 flex items-center justify-center",style:{background:nt.cream,border:`1px solid ${nt.tan}`},children:e.jsx("img",{src:s.image,alt:s.imageAlt||s.headline,className:"w-full h-auto max-h-[380px] sm:max-h-[480px] lg:max-h-[560px] object-contain",decoding:"async"})}),e.jsx("p",{className:"text-[17px] leading-relaxed font-medium pb-6 mb-8",style:{color:nt.plumMedium,borderBottom:`2px solid ${nt.gold}`},children:s.summary}),e.jsx("div",{className:"space-y-5",children:s.body.map((r,i)=>typeof r=="string"?e.jsx("p",{className:"text-[15px] leading-relaxed",style:{color:nt.body},children:r},i):e.jsx("h2",{className:"font-display text-xl lg:text-2xl font-bold pt-3",style:{color:nt.plum},children:r.heading},i))}),s.externalUrl&&e.jsxs("div",{className:"mt-10 rounded-2xl p-6",style:{background:nt.cream,border:`1px solid ${nt.tan}`},children:[e.jsxs("p",{className:"text-sm leading-relaxed mb-4",style:{color:nt.plumMedium},children:["The complete feature is published by ",e.jsx("strong",{children:s.source}),". Continue to the original article on the publisherâs website:"]}),e.jsxs("a",{href:s.externalUrl,target:"_blank",rel:"noopener noreferrer nofollow",className:"inline-flex items-center gap-2 px-6 py-3 rounded-lg text-xs font-bold uppercase tracking-wider transition-all hover:-translate-y-0.5",style:{background:nt.plum,color:nt.gold,border:`1px solid ${nt.gold}`},children:[e.jsx(Ua,{size:14}),s.externalLabel||`Read the Full ${s.source} Feature`]})]}),s.relatedLinks&&s.relatedLinks.length>0&&e.jsxs("div",{className:"mt-10 pt-6",style:{borderTop:`1px solid ${nt.tan}`},children:[e.jsx("h3",{className:"text-sm font-bold uppercase tracking-wider mb-3",style:{color:nt.plum},children:"Learn More"}),e.jsx("div",{className:"flex flex-wrap gap-x-6 gap-y-2",children:s.relatedLinks.map(r=>e.jsx(be,{to:r.path,className:"text-sm font-medium hover:underline",style:{color:nt.plumMedium},children:r.label},r.path))})]})]}),a.length>0&&e.jsxs("div",{className:"mt-8",children:[e.jsxs("h3",{className:"text-sm font-bold uppercase tracking-wider mb-4",style:{color:nt.plum},children:["More ",Ai]}),e.jsx("div",{className:"grid gap-4 md:grid-cols-3",children:a.map(r=>e.jsxs(be,{to:od(r.slug),className:"rounded-2xl p-5 transition-all hover:-translate-y-0.5",style:{background:"#FFFFFF",border:`1px solid ${nt.tan}`},children:[e.jsxs("p",{className:"text-[10px] font-bold uppercase tracking-wider",style:{color:nt.plumLight},children:[r.category," · ",zN(r.date)]}),e.jsx("p",{className:"mt-2 text-sm font-semibold leading-snug",style:{color:nt.plum},children:r.headline})]},r.slug))})]})]})},gh="#0F172A",Mc="#64748B",Wg="#0D9488",iF="w-full px-3.5 py-3 rounded-lg text-sm bg-white focus:outline-none focus:ring-2 focus:ring-teal-500/30",oF={border:"1px solid #E2E8F0",color:gh},jpe=()=>{const{token:t=""}=Wo();sn(),Ho({title:"Your Personalized Skin & Wellness Plan | Zorganics Med Spa",description:"Private review of your personalized Zorganics Med Spa plan."});
1303const[s,n]=d.useState(null),[a,r]=d.useState(!0),[i,o]=d.useState(null),[l,c]=d.useState(null),[u,p]=d.useState(null),[m,x]=d.useState(""),[h,y]=d.useState(""),v=d.useCallback(async()=>{r(!0);try{const f=await $le(t);n(f),x(f.client_confirmation_name||f.client_name||""),o(null)}catch(f){o(f.message||"Unable to load your plan.")}r(!1)},[t]);d.useEffect(()=>{v()},[v]);const g=async f=>{if(f==="approved"&&m.trim().length<2){o("Please type your full name to confirm your approval.");return}c(f),o(null);try{const j=await zle(t,f,m.trim()||(s==null?void 0:s.client_name)||"",h.trim()||void 0);n(j.plan),p(j.message)}catch(j){o(j.message||"Unable to record your response.")}c(null)},N=nb(s==null?void 0:s.client_decision),b=(s==null?void 0:s.client_decision)==="approved";return e.jsx("div",{className:"min-h-screen",style:{background:"linear-gradient(160deg, #F8FAFC 0%, #F0FDFA 100%)"},children:e.jsx("div",{className:"max-w-3xl mx-auto px-5 py-10",children:a?e.jsxs("div",{className:"py-28 text-center",children:[e.jsx(de,{size:26,className:"animate-spin mx-auto",style:{color:Wg}}),e.jsx("p",{className:"text-xs mt-3",style:{color:Mc},children:"Loading your personalized planâ¦"})]}):s?e.jsxs(e.Fragment,{children:[e.jsx(v$,{plan:s}),e.jsxs("section",{className:"mt-5 rounded-2xl p-7 bg-white",style:{border:"1px solid #E7EDF3"},children:[e.jsx("p",{className:"text-[10px] font-bold uppercase tracking-[0.24em] mb-1.5",style:{color:"#DAA520"},children:"Your Response"}),e.jsx("h3",{className:"text-[15px] font-bold mb-2 tracking-tight",style:{color:gh},children:"How would you like to move forward?"}),u&&e.jsxs("div",{className:"rounded-xl px-4 py-3.5 text-[12.5px] font-semibold leading-relaxed flex items-start gap-2 mb-4",style:{background:"rgba(13,148,136,0.08)",border:"1px solid rgba(13,148,136,0.25)",color:"#0F766E"},children:[e.jsx(xt,{size:15,className:"shrink-0 mt-0.5"})," ",u]}),N&&!u&&e.jsxs("div",{className:"rounded-xl px-4 py-3.5 text-[12.5px] leading-relaxed mb-4",style:{background:N.bg,border:`1px solid ${N.color}33`,color:N.color},children:[e.jsx("strong",{children:N.label}),s.client_decision_at&&e.jsxs(e.Fragment,{children:[" · ",new Date(s.client_decision_at).toLocaleString()]}),s.client_confirmation_name&&e.jsxs(e.Fragment,{children:[" · confirmed by ",s.client_confirmation_name]}),s.client_decision_note&&e.jsxs("div",{className:"mt-1 italic",children:['"',s.client_decision_note,'"']})]}),i&&e.jsx("div",{className:"rounded-xl px-4 py-3 text-xs font-semibold mb-4",style:{background:"rgba(220,38,38,0.06)",border:"1px solid rgba(220,38,38,0.25)",color:"#B91C1C"},children:i}),b?e.jsx("p",{className:"text-[12.5px] leading-relaxed",style:{color:Mc},children:"Your plan is approved and your specialist has been notified. They will follow up with your invoice and appointment scheduling. If anything needs to change, simply reply to your specialist directly."}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"grid sm:grid-cols-2 gap-4 mb-4",children:[e.jsxs("div",{className:"sm:col-span-2",children:[e.jsx("label",{className:"block text-[10px] font-bold uppercase tracking-[0.16em] mb-1.5",style:{color:Mc},children:"Type your full name to confirm"}),e.jsx("input",{className:iF,style:oF,value:m,onChange:f=>x(f.target.value),placeholder:"Your full name"})]}),e.jsxs("div",{className:"sm:col-span-2",children:[e.jsx("label",{className:"block text-[10px] font-bold uppercase tracking-[0.16em] mb-1.5",style:{color:Mc},children:"Anything you'd like your specialist to know? (optional)"}),e.jsx("textarea",{className:`${iF} h-24 resize-none`,style:oF,value:h,onChange:f=>y(f.target.value),placeholder:"Questions, timing preferences, or what you'd like to discussâ¦"})]})]}),e.jsxs("div",{className:"grid sm:grid-cols-3 gap-3",children:[e.jsxs("button",{onClick:()=>g("approved"),disabled:!!l,className:"inline-flex items-center justify-center gap-2 px-5 py-3.5 rounded-lg text-[12.5px] font-bold text-white disabled:opacity-50",style:{background:"linear-gradient(135deg, #0D9488, #0F766E)"},children:[l==="approved"?e.jsx(de,{size:14,className:"animate-spin"}):e.jsx(xt,{size:14})," Approve My Plan"]}),e.jsxs("button",{onClick:()=>g("discussion_requested"),disabled:!!l,className:"inline-flex items-center justify-center gap-2 px-5 py-3.5 rounded-lg text-[12.5px] font-bold disabled:opacity-50",style:{background:"#fff",color:gh,border:`1px solid ${gh}`},children:[l==="discussion_requested"?e.jsx(de,{size:14,className:"animate-spin"}):e.jsx(X_,{size:14})," Request a Discussion"]}),e.jsxs("button",{onClick:()=>g("declined"),disabled:!!l,className:"inline-flex items-center justify-center gap-2 px-5 py-3.5 rounded-lg text-[12.5px] font-bold disabled:opacity-50",style:{background:"#fff",color:"#BE123C",border:"1px solid rgba(190,18,60,0.35)"},children:[l==="declined"?e.jsx(de,{size:14,className:"animate-spin"}):e.jsx(kt,{size:14})," Not Right Now"]})]})]}),e.jsxs("p",{className:"text-[10.5px] mt-6 leading-relaxed flex items-start gap-1.5 pt-4",style:{color:Mc,borderTop:"1px solid #F1F5F9"},children:[e.jsx(Xe,{size:11,className:"shrink-0 mt-0.5",style:{color:Wg}}),"This link is private to you. No payment is collected on this page â approving simply lets your specialist prepare your invoice and scheduling."]}),e.jsxs("p",{className:"text-[10.5px] mt-2 leading-relaxed flex items-start gap-1.5",style:{color:Mc},children:[e.jsx(Ie,{size:11,className:"shrink-0 mt-0.5",style:{color:Wg}}),"Confidential â Zorganics Med Spa clinical team only. Never linked to student or academic re
1303cords."]})]})]}):e.jsxs("div",{className:"rounded-2xl p-10 text-center bg-white",style:{border:"1px solid #E7EDF3"},children:[e.jsx(Mt,{size:26,className:"mx-auto mb-3",style:{color:"#BE123C"}}),e.jsx("p",{className:"text-sm font-bold",style:{color:gh},children:"We couldn't open this plan"}),e.jsx("p",{className:"text-xs mt-2 max-w-md mx-auto leading-relaxed",style:{color:Mc},children:i}),e.jsxs(be,{to:"/",className:"inline-flex items-center gap-2 mt-6 text-xs font-bold",style:{color:Wg},children:[e.jsx(Je,{size:13})," Return to Zorganics"]})]})})})},tw=[{id:"cosmetology",name:"Cosmetology",hours:1600,tuitionCents:2331e3,labFeesCents:294287,materialsSuppliesCents:465e3,booksCents:8e4,applicationFeeCents:1e4,processingFeeCents:7800,enrollmentFeeCents:15e3,orientationFeeCents:3e4,tangiblePersonalPropertyCents:545e3,applicableTaxCents:53955,totalCents:3287042},{id:"esthetician",name:"Esthetician",hours:750,tuitionCents:135e4,labFeesCents:196500,materialsSuppliesCents:1e5,booksCents:8e4,applicationFeeCents:1e4,processingFeeCents:7800,enrollmentFeeCents:15e3,orientationFeeCents:3e4,tangiblePersonalPropertyCents:276500,applicableTaxCents:27374,totalCents:1816674},{id:"master-esthetician-combined",name:"Master Esthetician Combined",hours:1200,tuitionCents:2020260,labFeesCents:259566,materialsSuppliesCents:15e4,booksCents:8e4,applicationFeeCents:1e4,processingFeeCents:7800,enrollmentFeeCents:15e3,orientationFeeCents:3e4,tangiblePersonalPropertyCents:276500,applicableTaxCents:27374,totalCents:26e5},{id:"master-esthetician-bridge",name:"Master Esthetician Bridge",hours:450,tuitionCents:889e3,labFeesCents:199500,materialsSuppliesCents:121600,booksCents:8e4,applicationFeeCents:1e4,processingFeeCents:7800,enrollmentFeeCents:15e3,orientationFeeCents:3e4,tangiblePersonalPropertyCents:279500,applicableTaxCents:27670,totalCents:1380570},{id:"manicurist",name:"Manicurist",hours:600,tuitionCents:887450,labFeesCents:196500,materialsSuppliesCents:106106,booksCents:8e4,applicationFeeCents:1e4,processingFeeCents:7800,enrollmentFeeCents:15e3,orientationFeeCents:3e4,tangiblePersonalPropertyCents:276500,applicableTaxCents:27374,totalCents:1360230},{id:"instructor-training",name:"Instructor Training",hours:600,tuitionCents:105e4,labFeesCents:0,materialsSuppliesCents:8e4,booksCents:4e4,applicationFeeCents:1e4,processingFeeCents:7800,enrollmentFeeCents:15e3,orientationFeeCents:3e4,tangiblePersonalPropertyCents:12e4,applicableTaxCents:11880,totalCents:1244680}],Fa=t=>(t/100).toLocaleString("en-US",{style:"currency",currency:"USD",minimumFractionDigits:2,maximumFractionDigits:2}),Un="#2A060C",lF="#E6D2A0",cF="#FAF6EE",xi="#7A3A44",sw={cosmetology:{months:12,maxInstallments:11},esthetician:{months:7,maxInstallments:6},"master-esthetician-combined":{months:9,maxInstallments:8},"master-esthetician-bridge":{months:4,maxInstallments:3},manicurist:{months:6,maxInstallments:5},"instructor-training":{months:5,maxInstallments:4}},Hg=35,nw=100,wpe=()=>{const[t,s]=d.useState("cosmetology"),[n,a]=d.useState(Hg),[r,i]=d.useState(sw.cosmetology.maxInstallments),[o,l]=d.useState(""),[c,u]=d.useState(""),[p,m]=d.useState(!1),[x,h]=d.useState(!1),[y,v]=d.useState(""),g=d.useMemo(()=>tw.find(w=>w.id===t)||tw[0],[t]),N=sw[g.id]||sw.cosmetology;d.useEffect(()=>{i(N.maxInstallments)},[g.id,N.maxInstallments]);const b=n>=100,f=d.useMemo(()=>{const w=g.totalCents,_=b?g.totalCents:Math.round(w*n/100),C=Math.max(w-_,0),E=b?0:Math.min(Math.max(r,1),N.maxInstallments),P=E>0?Math.floor(C/E):0,F=E>0?C-P*(E-1):0,I=E>1&&F!==P;return{totalCents:w,downCents:_,remainingCents:C,n:E,monthlyCents:P,finalCents:F,finalDiffers:I}},[g,n,r,N.maxInstallments,b]),j=/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(o.trim()),S=async()=>{if(v(""),!j){v("Please enter a valid email address.");return}m(!0);const w=new Date().toISOString(),_={first_name:c.trim()||void 0,email:o.trim(),program_label:g.name,hours:g.hours,tuition:f.totalCents/100,months:f.n,down_pct:n,down:f.downCents/100,aid_offset:0,cash_discount:!1,financed:f.remainingCents/100,monthly:f.monthlyCents/100};try{try{await fetch("https://famous.ai/api/crm/69caed6904ed6aca7682413a/subscribe",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({email:o.trim(),name:c.trim()||void 0,source:"payment-estimate",tags:["payment-estimate","z-bank-plan",g.id],metadata:{form_type:"zbank_payment_plan_planner",record_type:"student_planning_estimate",is_official_award:!1,is_finalized_payment_schedule:!1,submitted_at:w,program_id:g.id,program_label:g.name,program_hours:g.hours,program_duration_months:N.months,down_payment_pct:n,down_payment_usd:f.downCents/100,remaining_balance_usd:f.remainingCents/100,monthly_installments:f.n,estimated_monthly_payment_usd:f.monthlyCents/100,final_installment_usd:f.finalCents/100,interest_rate_pct:0,latest_tuition_estimate_summary:`${g.name} · ${n}% down (${Fa(f.downCents)}) · ${f.n} monthly installments · ${Fa(f.monthlyCents)}/mo · final payment due one month before projected graduation (planning estimate only)`,disclaimer:"This planning estimate is not a financial-aid award, credit approval or enrollment agreement. Final program costs, payment terms, start dates and graduation dates are confirmed by Zorganics Institute Admissions before enrollment."}})})}catch{}await O.functions.invoke("send-payment-estimate",{body:_}),h(!0)}catch{h(!0)}finally{m(!1)}};return e.jsxs("div",{className:"rounded-2xl overflow-hidden",style:{border:`1px solid ${$}55`,background:"#fff",boxShadow:`0 8px 28px ${k}12`},children:[e.jsxs("div",{className:"px-6 py-5 flex items-center gap-3",style:{background:`linear-gradient(135deg, ${k} 0%, ${Un} 100%)`},children:[e.jsx("div",{className:"w-11 h-11 rounded-xl flex items-center justify-center flex-shrink-0",style:{background:`${$}1F`,border:`1px solid ${$}55`},children:e.jsx($P,{size:20,style:{color:$}})}),e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Do,{size:13,style:{color:$}}),e.jsx("span",{className:"text-[10px] font-bold uppercase tracking-[0.26em]",style:{color:$},children:"Institutional Payment Plan"})]}),e.jsx("h3",{className:"font-display text-lg font-bold text-white leading-tight",style:{fontFamily:"'Playfair Display', Georgia, serif"},children:"ZBank Payment Plan Planner"})]})]}),e.jsxs("div",{className:"p-6 space-y-6",children:[e.jsx("p",{className:"text-[13px] leading-relaxed",style:{color:xi},children:"Explore an estimated institutional payment plan based on your selected program. A minimum 35% down payment is required, and the remaining balance must be paid in full no later than one month before the projected graduation date."}),e.jsxs("div",{className:"grid sm:grid-cols-2 gap-5",children:[e.jsxs("div",{className:"sm:col-span-2",children:[e.jsx("label",{className:"block text-xs font-semibold mb-1.5",style:{color:Un},children:"Program"}),e.jsxs("div",{className:"relative",children:[e.jsx("select",{value:t,onChange:w=>{s(w.target.value),h(!1)},className:"w-full appearance-none px-4 py-2.5 pr-10 rounded-xl text-sm focus:outline-none focus:ring-2",style:{border:"1px solid rgba(0,0,0,0.12)",color:Un,background:"#fff"},children:tw.map(w=>e.jsx("option",{value:w.id,children:w.name},w.id))}),e.jsx(Gt,{size:16,className:"absolute right-3 top-1/2 -translate-y-1/2 pointer-events-none",style:{color:xi}})]}),e.jsxs("div",{className:"mt-2 flex flex-wrap items-center gap-2 text-[11px]",style:{color:xi},children:[e.jsxs("span",{className:"inline-flex items-center gap-1 px-2 py-0.5 rounded-full",style:{background:`${$}14`,border:`1px solid ${$}33`,color:Un},children:[e.jsx(dt,{size:11,style:{color:$}})," ",N.months,"-month program"]}),e.jsx("span",{children:"Plan completes one month before projected graduation"})]})]}),e.jsxs("div",{children:[e.jsxs("label",{className:"block text-xs font-semibold mb-1.5",style:{color:Un},children:[e.jsx(UO,{size:12,className:"inline mr-1",style:{color:$}})," Down Payment â ",n,"%"]}),e.jsx("input",{type:"range",min:Hg,max:nw,step:5,value:n,onChange:w=>{const _=Math.max(Hg,Math.min(nw,Number(w.target.value)));a(_),h(!1)},className:"w-full",style:{accentColor:k},"aria-label":"Down payment percentage â minimum 35%"}),e.jsxs("div",{className:"flex justify-between text-[10px] mt-1",style:{color:xi},children:[e.jsxs("span",{children:[Hg,"% minimum"]}),e.jsxs("span",{children:[Fa(f.downCents)," down"]}),e.jsxs("span",{children:[nw,"%"]})]})]}),!b&&e.jsxs("div",{children:[e.jsxs("label",{className:"block text-xs font-semibold mb-1.5",style:{color:Un},children:[e.jsx(At,{size:12,className:"inline mr-1",style:{color:$}})," Total Monthly Installments â ",f.n]}),e.jsx("div",{className:"flex flex-wrap gap-2",children:Array.from({length:N.maxInstallments},(w,_)=>_+1).map(w=>{const _=f.n===w;return e.jsx("button",{type:"button",onClick:()=>{i(w),h(!1)},className:"px-3 py-1.5 rounded-lg text-xs font-semibold transition-all",style:{background:_?k:"#fff",color:_?$:Un,border:`1px solid ${_?k:"rgba(0,0,0,0.12)"}`},children:w},w)})}),e.jsxs("p",{className:"mt-1.5 text-[10px]",style:{color:xi},children:["The number you select is the TOTAL number of monthly installments. Maximum"," ",N.maxInstallments," for this program."]})]})]}),e.jsx("div",{className:"rounded-2xl px-6 py-6 text-center",style:{background:`linear-gradient(135deg, ${k} 0%, ${Un} 100%)`,border:`1px solid ${$}55`},children:b?e.jsxs(e.Fragment,{children:[e.jsx("p",{className:"text-[10px] font-bold uppercase tracking-[0.26em] mb-1",style:{color:$},children:"Payment Plan"}),e.jsx("p",{className:"font-display text-4xl font-bold text-white leading-none mb-1",style:{fontFamily:"'Playfair Display', Georgia, serif"},children:"Paid in full"}),e.jsx("p",{className:"text-[12px]",style:{color:lF},children:"No remaining balance · no monthly installments"})]}):e.jsxs(e.Fragment,{children:[e.jsx("p",{className:"text-[10px] font-bold uppercase tracking-[0.26em] mb-1",style:{color:$},children:"Estimated Monthly Payment"}),e.jsx("p",{className:"font-display text-4xl font-bold text-white leading-none mb-1",style:{fontFamily:"'Playfair Display', Georgia, serif"},children:Fa(f.monthlyCents)}),e.jsxs("p",{className:"text-[12px]",style:{color:lF},children:[f.n," total ",f.n===1?"installment":"installments"," · 0% interest"]})]})}),e.jsxs("div",{className:"rounded-xl overflow-hidden",style:{border:`1px solid ${$}33`},children:[e.jsx("div",{className:"px-4 py-2 text-[10px] font-bold uppercase tracking-wider",style:{background:`${$}14`,color:Un},children:"Your Estimated Plan"}),e.jsx("div",{className:"divide-y",style:{borderColor:`${$}22`},children:(b?[{label:"Selected program",value:g.name},{label:`Down payment (${n}%)`,value:Fa(f.downCents)},{label:"Estimated remaining balance",value:Fa(0)},{label:"Payment plan",value:"Paid in full"}]:[{label:"Selected program",value:g.name},{label:`Down payment (${n}%)`,value:Fa(f.downCents)},{label:"Estimated remaining balance",value:Fa(f.remainingCents)},{label:"Total monthly installments",value:String(f.n)},{label:"Estimated monthly payment",value:Fa(f.monthlyCents)},...f.finalDiffers?[{label:"Final installment (adjusted)",value:Fa(f.finalCents)}]:[]]).map(w=>e.jsxs("div",{className:"flex items-center justify-between gap-3 px-4 py-2.5 text-[13px]",children:[e.jsx("span",{style:{color:xi},children:w.label}),e.jsx("span",{className:"font-mono font-semibold text-right",style:{color:Un},children:w.value})]},w.label))}),e.jsx("div",{className:"px-4 py-3",style:{background:cF},children:b?e.jsx("p",{className:"text-[11px] leading-relaxed",style:{color:xi},children:"Your program cost is paid in full at the start of the program, so there is no remaining balance and no monthly installments."}):e.jsxs(e.Fragment,{children:[e.jsx("p",{className:"text-[11px] leading-relaxed font-semibold",style:{color:Un},children:f.finalDiffers?`${f.n-1} regular monthly installments of ${Fa(f.monthlyCents)}, followed by one final installment of ${Fa(f.finalCents)}.`:`${f.n} monthly ${f.n===1?"installment":"installments"} of ${Fa(f.monthlyCents)}.`}),e.jsx("p",{className:"text-[11px] leading-relaxed mt-1",style:{color:xi},children:"The final installment is due one month before your projected graduation date."})]})})]}),e.jsx("div",{className:"rounded-xl px-4 py-4",style:{background:cF,border:`1px solid ${$}44`},children:x?e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("span",{className:"w-9 h-9 rounded-full flex items-center justify-center flex-shrink-0",style:{background:`${$}1A`,border:`1px solid ${$}55`},children:e.jsx(xt,{size:18,style:{color:k}})}),e.jsxs("div",{children:[e.jsx("p",{className:"text-[13px] font-bold",style:{color:Un},children:"Estimate on its way!"}),e.jsxs("p",{className:"text-[11px]",style:{color:xi},children:["We emailed your planning estimate to ",o,". Check your inbox (and spam folder)."]})]})]}):e.jsxs(e.Fragment,{children:[e.jsxs("label",{className:"flex items-center gap-2 text-xs font-semibold mb-2",style:{color:Un},children:[e.jsx(Ye,{size:14,style:{color:$}})," Email My Estimate"]}),e.jsxs("div",{className:"grid sm:grid-cols-2 gap-2 mb-2",children:[e.jsx("input",{type:"text",value:c,onChange:w=>u(w.target.value),placeholder:"First name (optional)",className:"w-full px-3 py-2 rounded-lg text-sm focus:outline-none focus:ring-2",style:{border:"1px solid rgba(0,0,0,0.12)",color:Un,background:"#fff"}}),e.jsx("input",{type:"email",value:o,onChange:w=>{l(w.target.value),v("")},placeholder:"[email protected]",className:"w-full px-3 py-2 rounded-lg text-sm focus:outline-none focus:ring-2",style:{border:`1px solid ${y?"#C0392B":"rgba(0,0,0,0.12)"}`,color:Un,background:"#fff"}})]}),y&&e.jsx("p",{className:"text-[11px] mb-2",style:{color:"#C0392B"},children:y}),e.jsxs("button",{type:"button",onClick:S,disabled:p,className:"w-full flex items-center justify-center gap-2 px-4 py-2.5 rounded-xl text-sm font-bold transition-all disabled:opacity-60",style:{background:k,color:$,border:`1px solid ${k}`},children:[p?e.jsx(de,{size:16,className:"animate-spin"}):e.jsx(Ye,{size:16}),p?"Sendingâ¦":"Email My Estimate"]})]})}),e.jsxs("div",{className:"flex items-start gap-2 px-4 py-3 rounded-xl",style:{background:`${$}10`,border:`1px solid ${$}33`},children:[e.jsx(Bi,{size:14,className:"mt-0.5 flex-shrink-0",style:{color:$}}),e.jsx("p",{className:"text-[11px] leading-relaxed",style:{color:xi},children:"This planning estimate is not a financial-aid award, credit approval or enrollment agreement. Final program costs, payment terms, start dates and graduation dates are confirmed by Zorganics Institute Admissions before enrollment."})]})]})]})},aw="#5A1A24",Bc="#7A3A44",Gg="#4A2228",Npe="#F2EBE3",dF="#FAF7F2",Yp="#E8DDD0",_pe="https://d64gsuwffb70l.cloudfront.net/69cae7fb5ea7db794957149e_1775337912224_4cc82887.jfif",rw={title:"Financial Aid & Scholarships | Zorganics Institute â FAFSA, Foundation Scholarships & Veterans Benefits",description:"Explore financial-aid and educational funding resources for Zorganics Institute students â federal Title IV aid and the FAFSA, Zorganics Foundation scholarships, Washington state & workforce funding, and veterans education benefits. Eligibility varies by program and funding source."},kpe=[{key:"federal",icon:e.jsx(Zm,{size:22}),title:"Federal Financial Aid",body:e.jsxs(e.Fragment,{children:[e.jsx("p",{children:"Zorganics Institute participates in the federal Title IV student aid programs for eligible students â the Federal Pell Grant, Federal Direct Subsidized and Unsubsidized Loans, and the Federal Direct PLUS Loan."}),e.jsxs("p",{children:["The process begins with the Free Application for Federal Student Aid (FAFSA), using the Instituteâs Federal School Code ",e.jsx("strong",{children:"043003"}),". Your rights and responsibilities as a financial-aid recipient are published in full in the Consumer Information hub."]})]}),ctaLabel:"Explore Federal Financial Aid",ctaTo:"/consumerinformation"},{key:"scholarships",icon:e.jsx(_t,{size:22}),title:"Zorganics Foundation Scholarships",body:e.jsxs(e.Fragment,{children:[e.jsx("p",{children:"The Zorganics Foundation is a 501(c)(3) public charity whose scholarship program supports students pursuing beauty, wellness and skin-science careers."}),e.jsx("p",{children:"Current scholarship information and the scholarship application are maintained on the Foundation page. Award criteria and decisions are determined by the Foun
1303dation."})]}),ctaLabel:"Explore Scholarships",ctaTo:"/foundation"},{key:"state-workforce",icon:e.jsx(zt,{size:22}),title:"Washington State & Workforce Resources",body:e.jsxs(e.Fragment,{children:[e.jsx("p",{children:"The Institute accepts Workforce Innovation and Opportunity Act (WIOA) funding and Washington state grant programs, and works with students using WASFA and the Washington College Grant."}),e.jsx("p",{children:"Eligibility and funding decisions are determined by the applicable program or agency â not by Zorganics Institute. Our admissions team can help you understand which resources may apply to your program."})]}),ctaLabel:"Explore Additional Funding Resources",ctaTo:"/admissions",secondary:{label:"WIOA & state grant programs in Consumer Information",to:"/consumerinformation"}},{key:"veterans",icon:e.jsx(Ie,{size:22}),title:"Veterans Education Benefits",body:e.jsxs(e.Fragment,{children:[e.jsxs("p",{children:["Zorganics Institute accepts Veterans (GI Bill",e.jsx("sup",{children:"®"}),") education benefits for eligible veterans, service members and dependents."]}),e.jsx("p",{children:"Benefit eligibility, entitlement and payment amounts are determined by the U.S. Department of Veterans Affairs. Our team can walk you through how your approved benefit applies to your program of interest."})]}),ctaLabel:"Explore Veterans Education Benefits",ctaTo:"/admissions",secondary:{label:"Veterans benefits in Consumer Information",to:"/consumerinformation"}},{key:"other-resources",icon:e.jsx(Qe,{size:22}),title:"Other Funding & Scholarship Resources",body:e.jsxs(e.Fragment,{children:[e.jsx("p",{children:"Students also fund their education through employer sponsorship and professional-development funding, and through the payment-plan and paid-in-full options offered by the admissions office."}),e.jsx("p",{children:"Outside scholarships from community organizations and industry groups may also be available. Eligibility, amounts and decisions for any outside award are set by that sponsoring organization."})]}),ctaLabel:"Explore Payment & Funding Options",ctaTo:"/admissions",secondary:{label:"Cost of attendance & Net Price Calculator",to:"/consumerinformation"}}],Spe=[{q:"Who may apply for a Zorganics Foundation scholarship?",a:"The Foundationâs scholarship program supports students pursuing beauty, wellness and skin-science careers at Zorganics Institute. Current criteria are published with the scholarship information on the Foundation page, and award decisions are made by the Foundation."},{q:"How do I apply?",a:"The scholarship application is hosted on the Foundation page â use the Explore Scholarships pathway above. Federal aid is applied for separately through the FAFSA using Federal School Code 043003."},{q:"How are scholarship funds applied?",a:"Foundation scholarship awards are applied toward the cost of your Zorganics Institute program. Your admissions or financial-aid contact will confirm how an award is reflected on your account."},{q:"Can I receive a scholarship and financial aid?",a:"A Foundation scholarship is separate from federal Title IV aid, state and workforce funding, and veterans education benefits. Each source has its own application and its own eligibility determination â ask our team how the resources you are pursuing work together."},{q:"When should I apply?",a:"Start early. Because funding sources are administered by different agencies and organizations, applying while you are exploring programs gives you the most time to complete each step before your start date."},{q:"Where can I ask questions?",a:"Use the Contact Financial Aid pathway above, or reach the Institute by phone or email. Please do not send sensitive financial information (FAFSA data, SSNs, tax documents, FSA ID credentials or account numbers) through the website."}],Cpe=()=>(Ho(rw),d.useEffect(()=>(window.scrollTo({top:0,behavior:"auto"}),Jl(`${Mi}/financial-aid`),()=>{Jl(`${Mi}/`),qa(wr)}),[]),d.useEffect(()=>(Qn("page",M5({name:rw.title,description:rw.description,path:"/financial-aid"})),Qn("page-breadcrumb",ip([{name:"Home",path:"/"},{name:"Financial Aid & Scholarships",path:"/financial-aid"}])),()=>{Jn("page"),Jn("page-breadcrumb")}),[]),e.jsxs("div",{className:"min-h-screen",style:{background:`linear-gradient(180deg, ${Npe} 0%, ${dF} 100%)`},children:[e.jsxs("header",{className:"relative",style:{background:k},children:[e.jsx("div",{className:"h-[3px]",style:{background:`linear-gradient(90deg, rgba(212,175,55,0) 0%, ${$} 50%, rgba(212,175,55,0) 100%)`}}),e.jsxs("div",{className:"max-w-[1100px] mx-auto px-4 lg:px-8 py-6 flex items-center justify-between gap-4",children:[e.jsxs(be,{to:"/",className:"flex items-center gap-3 group",children:[e.jsx("div",{className:"w-11 h-11 rounded-xl overflow-hidden flex-shrink-0",style:{boxShadow:`0 0 0 1.5px ${$}`},children:e.jsx("img",{src:_pe,alt:"Zorganics Institute",className:"w-full h-full object-cover"})}),e.jsxs("div",{children:[e.jsxs("h2",{className:"font-display text-lg font-bold",style:{color:"#FFFFFF"},children:["Zorganics",e.jsx("span",{style:{color:$},children:" Institute"})]}
1303),e.jsx("p",{className:"text-[10px] tracking-wider uppercase",style:{color:"rgba(212,175,55,0.7)"},children:"A Holistic Approach To Beauty and Wellness through Science and Art"})]})]}),e.jsxs(be,{to:"/",className:"inline-flex items-center gap-2 px-4 py-2 rounded-lg text-xs font-bold uppercase tracking-wider transition-all hover:-translate-y-0.5",style:{background:"rgba(212,175,55,0.12)",color:$,border:"1px solid rgba(212,175,55,0.4)"},children:[e.jsx(Je,{size:14})," Back to Home"]})]})]}),e.jsxs("div",{className:"max-w-[1100px] mx-auto px-4 lg:px-8 pt-12 pb-8",children:[e.jsxs("div",{className:"inline-flex items-center gap-2 px-3 py-1.5 rounded-full text-[10px] font-bold uppercase tracking-wider mb-4",style:{background:`${$}1A`,color:aw,border:`1px solid ${$}55`},children:[e.jsx(_t,{size:12})," Student Resources"]}),e.jsx("h1",{className:"font-display text-3xl lg:text-[2.6rem] font-bold leading-tight",style:{color:k},children:"Financial Aid & Scholarships"}),e.jsx("p",{className:"mt-3 text-lg leading-relaxed max-w-3xl font-medium",style:{color:aw},children:"Explore resources that may help make your Zorganics education more accessible."}),e.jsx("p",{className:"mt-3 text-[15px] leading-relaxed max-w-3xl",style:{color:Gg},children:"Zorganics Institute provides information and assistance to help eligible students understand available financial-aid and educational funding options. Eligibility varies by program and funding source."})]}),e.jsxs("main",{className:"max-w-[1100px] mx-auto px-4 lg:px-8 pb-16",children:[e.jsx("div",{className:"grid md:grid-cols-2 gap-5",children:kpe.map(t=>e.jsxs("section",{className:"rounded-3xl p-6 lg:p-8 flex flex-col",style:{background:"#FFFFFF",border:`1px solid ${Yp}`,boxShadow:"0 8px 32px rgba(59,10,17,0.05)"},children:[e.jsxs("div",{className:"flex items-center gap-3 mb-4",children:[e.jsx("div",{className:"w-11 h-11 rounded-xl flex items-center justify-center flex-shrink-0",style:{background:`${$}1F`,border:`1px solid ${$}55`,color:k},children:t.icon}),e.jsx("h2",{className:"font-display text-xl font-bold leading-snug",style:{color:k},children:t.title})]}),e.jsx("div",{className:"space-y-3 text-[15px] leading-relaxed flex-1",style:{color:Gg},children:t.body}),e.jsxs("div",{className:"mt-6",children:[e.jsxs(be,{to:t.ctaTo,className:"inline-flex items-center gap-2 px-5 py-3 rounded-xl text-sm font-bold transition-all hover:-translate-y-0.5",style:{background:k,color:$,border:`1px solid ${$}`},children:[t.ctaLabel," ",e.jsx(Vt,{size:15})]}),t.secondary&&e.jsx("p",{className:"mt-3",children:e.jsxs(be,{to:t.secondary.to,className:"inline-flex items-center gap-1.5 text-[12px] font-semibold hover:underline",style:{color:Bc},children:[e.jsx(Bi,{size:12,style:{color:$}})," ",t.secondary.label]})})]})]},t.key))}),e.jsx("section",{className:"mt-8",children:e.jsx(wpe,{})}),e.jsxs("section",{className:"mt-8 rounded-3xl p-6 lg:p-10",style:{background:`linear-gradient(150deg, ${k} 0%, #2A060C 100%)`},children:[e.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[e.jsx(Ny,{size:16,style:{color:$}}),e.jsx("span",{className:"text-[11px] font-bold uppercase tracking-[0.28em]",style:{color:$},children:"Weâre Here to Help"})]}),e.jsx("h2",{className:"font-display text-2xl lg:text-3xl font-bold text-white mb-3",children:"Need Help Understanding Your Options?"}),e.jsx("p",{className:"text-[15px] leading-relaxed max-w-2xl mb-6",style:{color:"rgba(255,255,255,0.82)"},children:"Our Financial Aid team can help you understand the application process, what documentation is needed, and which resources may be available for your program. Reach out â there is no cost to ask a question."}),e.jsxs("div",{className:"flex flex-wrap items-center gap-3",children:[e.jsxs(be,{to:"/contact?dept=financial-aid",className:"inline-flex items-center gap-2 px-6 py-3 rounded-xl text-sm font-bold transition-all hover:-translate-y-0.5",style:{background:$,color:k,border:`1px solid ${$}`},children:["Contact Financial Aid ",e.jsx(Vt,{size:15})]}),e.jsxs("a",{href:`tel:${Fx}`,className:"inline-flex items-center gap-2 px-5 py-3 rounded-xl text-sm font-semibold transition-all hover:-translate-y-0.5",style:{background:"rgba(255,255,255,0.08)",color:"#FFFFFF",border:"1px solid rgba(212,175,55,0.45)"},children:[e.jsx(Qt,{size:14,style:{color:$}})," ",Fi]}),e.jsxs("a",{href:`mailto:${In}`,className:"inline-flex items-center gap-2 px-5 py-3 rounded-xl text-sm font-semibold transition-all hover:-translate-y-0.5",style:{background:"rgba(255,255,255,0.08)",color:"#FFFFFF",border:"1px solid rgba(212,175,55,0.45)"},children:[e.jsx(Ye,{size:14,style:{color:$}})," ",In]})]}),e.jsxs("p",{className:"mt-5 flex items-start gap-2 text-[12px] leading-relaxed",style:{color:"rgba(255,255,255,0.62)"},children:[e.jsx(zt,{size:13,style:{color:$},className:"mt-0.5 flex-shrink-0"}),e.jsx("span",{children:dQ})]})]}),e.jsxs("section",{className:"mt-8 rounded-3xl p-6 lg:p-8",style:{background:"#FFFFFF",border:`1px solid ${Yp}`,boxShadow:"0 8px 32px rgba(59,10,17,0.05)"},children:[e.jsxs("div",{className:"flex items-center gap-3 mb-5",children:[e.jsx("div",{className:"w-11 h-11 rounded-xl flex items-center justify-center flex-shrink-0",style:{background:`${$}1F`,border:`1px solid ${$}55`,color:k},children:e.jsx(Ny,{size:20})}),e.jsx("h2",{className:"font-display text-xl font-bold",style:{color:k},children:"Scholarship & Financial Aid Questions"})]}),e.jsx("div",{className:"grid md:grid-cols-2 gap-x-8 gap-y-5",children:Spe.map(t=>e.jsxs("div",{children:[e.jsx("h3",{className:"font-semibold text-[14px] mb-1.5",style:{color:aw},children:t.q}),e.jsx("p",{className:"text-[13px] leading-relaxed",style:{color:Gg},children:t.a})]},t.q))}),e.jsx("p",{className:"mt-6 pt-5 text-[12px] leading-relaxed",style:{borderTop:`1px solid ${Yp}`,color:Bc},children:"Have a question that isnât answered here? Use the Contact Financial Aid pathway above â our team will walk
1303you through it. Please do not send FAFSA data, Social Security numbers, tax documents, FSA ID credentials or financial-account information through the website."})]}),e.jsxs("section",{className:"mt-8 rounded-3xl p-6 lg:p-8",style:{background:dF,border:`1px solid ${Yp}`},children:[e.jsxs("div",{className:"flex items-start gap-4 flex-wrap lg:flex-nowrap",children:[e.jsx("div",{className:"w-11 h-11 rounded-xl flex items-center justify-center flex-shrink-0",style:{background:`${$}1F`,border:`1px solid ${$}55`,color:k},children:e.jsx(Kt,{size:20})}),e.jsxs("div",{className:"flex-1 min-w-[260px]",children:[e.jsx("h2",{className:"font-display text-xl font-bold mb-2",style:{color:k},children:"Financial Aid Policies & Consumer Information"}),e.jsx("p",{className:"text-[15px] leading-relaxed",style:{color:Gg},children:"Students looking for official institutional policies and disclosures â including Satisfactory Academic Progress (SAP), Return to Title IV (R2T4) and refunds, FERPA, cost of attendance and institutional outcomes â can access the Consumer Information hub."})]}),e.jsx("div",{className:"w-full lg:w-auto",children:e.jsxs(be,{to:"/consumerinformation",className:"inline-flex items-center gap-2 px-5 py-3 rounded-xl text-sm font-bold transition-all hover:-translate-y-0.5",style:{background:k,color:$,border:`1px solid ${$}`},children:["View Consumer Information ",e.jsx(Vt,{size:15})]})})]}),e.jsxs("div",{className:"mt-5 pt-5 flex flex-wrap gap-x-6 gap-y-2",style:{borderTop:`1px solid ${Yp}`},children:[e.jsx(be,{to:"/school-catalog",className:"text-[13px] font-semibold hover:underline",style:{color:Bc},children:"School Catalog & Admissions Policies"}),e.jsx(be,{to:"/programs",className:"text-[13px] font-semibold hover:underline",style:{color:Bc},children:"Academic Programs"}),e.jsx(be,{to:"/admissions",className:"text-[13px] font-semibold hover:underline",style:{color:Bc},children:"Admissions"}),e.jsx(be,{to:"/apply-now",className:"text-[13px] font-semibold hover:underline",style:{color:Bc},children:"Apply Now"})]})]}),e.jsxs("p",{className:"mt-8 text-center text-[11px] leading-relaxed",style:{color:Bc},children:["Financial aid is available for those who qualify. Eligibility, awards and funding decisions are determined by the applicable federal, state, agency or program authority.",e.jsx("br",{}),"© 2026 Zorganics Institute of Beauty & Wellness · NACCAS Accredited · WA State DOL Certified · Title IV / FSA Eligible"]})]})]})),Ape=["super-admin","admin"],ws=({children:t})=>e.jsx(np,{children:e.jsx(lr,{redirectTo:"/admin-login",requiredRoles:Ape,children:t})});var dz="basil",Epe=function(s){return s===3?"v3":s},uz="https://js.stripe.com",Fpe="".concat(uz,"/").concat(dz,"/stripe.js"),Tpe=/^https:\/\/js\.stripe\.com\/v3\/?(\?.*)?$/,Ppe=/^https:\/\/js\.stripe\.com\/(v3|[a-z]+)\/stripe\.js(\?.*)?$/;var Dpe=function(s){return Tpe.test(s)||Ppe.test(s)},Rpe=function(){for(var s=document.querySelectorAll('script[src^="'.concat(uz,'"]')),n=0;n<s.length;n++){var a=s[n];if(Dpe(a.src))return a}return null},uF=function(s){var n="",a=document.createElement("script");a.src="".concat(Fpe).concat(n);var r=document.head||document.body;if(!r)throw new Error("Expected document.body not to be null. Stripe.js requires a <body> element.");return r.appendChild(a),a},Ipe=function(s,n){!s||!s._registerWrapper||s._registerWrapper({name:"stripe-js",version:"7.9.0",startTime:n})},Kp=null,Vg=null,Zg=null,$pe=function(s){return function(n){s(new Error("Failed to load Stripe.js",{cause:n}))}},zpe=function(s,n){return function(){window.Stripe?s(window.Stripe):n(new Error("Stripe.js not available"))}},Lpe=function(s){return Kp!==null?Kp:(Kp=new Promise(function(n,a){if(typeof window>"u"||typeof document>"u"){n(null);return}if(window.Stripe){n(window.Stripe);return}try{var r=Rpe();if(!(r&&s)){if(!r)r=uF(s);else if(r&&Zg!==null&&Vg!==null){var i;r.removeEventListener("load",Zg),r.removeEventListener("error",Vg),(i=r.parentNode)===null||i===void 0||i.removeChild(r),r=uF(s)}}Zg=zpe(n,a),Vg=$pe(a),r.addEventListener("load",Zg),r.addEventListener("error",Vg)}catch(o){a(o);return}}),Kp.catch(function(n){return Kp=null,Promise.reject(n)}))},Ope=function(s,n,a){if(s===null)return null;var r=n[0],i=r.match(/^pk_test/),o=Epe(s.version),l=dz;i&&o!==l&&console.warn("Stripe.js@".concat(o," was loaded on the page, but @stripe/stripe-js@").concat("7.9.0"," expected Stripe.js@").concat(l,". This may result in unexpected behavior. For more information, see https://docs.stripe.com/sdks/stripejs-versioning"));var c=s.apply(void 0,n);return Ipe(c,a),c}
vendor: 8,147 bytes, lines 1303-1304
1303,Qp,mz=!1,pz=function(){return Qp||(Qp=Lpe(null).catch(function(s){return Qp=null,Promise.reject(s)}),Qp)};Promise.resolve().then(function(){return pz()}).catch(function(t){mz||console.warn(t)});var Mpe=function(){for(var s=arguments.length,n=new Array(s),a=0;a<s;a++)n[a]=arguments[a];mz=!0;var r=Date.now();return pz().then(function(i){return Ope(i,n,r)})},hz={exports:{}},Bpe="SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED",Upe=Bpe,qpe=Upe;function xz(){}function fz(){}fz.resetWarningCache=xz;var Wpe=function(){function t(a,r,i,o,l,c){if(c!==qpe){var u=new Error("Calling PropTypes validators directly is not supported by the `prop-types` package. Use PropTypes.checkPropTypes() to call them. Read more at http://fb.me/use-check-prop-types");throw u.name="Invariant Violation",u}}t.isRequired=t;function s(){return t}var n={array:t,bigint:t,bool:t,func:t,number:t,object:t,string:t,symbol:t,any:t,arrayOf:s,element:t,elementType:t,instanceOf:s,node:t,objectOf:s,oneOf:s,oneOfType:s,shape:s,exact:s,checkPropTypes:fz,resetWarningCache:xz};return n.PropTypes=n,n};hz.exports=Wpe();var Hpe=hz.exports;const ls=qN(Hpe);function mF(t,s){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(t);s&&(a=a.filter(function(r){return Object.getOwnPropertyDescriptor(t,r).enumerable})),n.push.apply(n,a)}return n}function pF(t){for(var s=1;s<arguments.length;s++){var n=arguments[s]!=null?arguments[s]:{};s%2?mF(Object(n),!0).forEach(function(a){gz(t,a,n[a])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):mF(Object(n)).forEach(function(a){Object.defineProperty(t,a,Object.getOwnPropertyDescriptor(n,a))})}return t}function Q0(t){"@babel/helpers - typeof";return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?Q0=function(s){return typeof s}:Q0=function(s){return s&&typeof Symbol=="function"&&s.constructor===Symbol&&s!==Symbol.prototype?"symbol":typeof s},Q0(t)}function gz(t,s,n){return s in t?Object.defineProperty(t,s,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[s]=n,t}function Gpe(t,s){if(t==null)return{};var n={},a=Object.keys(t),r,i;for(i=0;i<a.length;i++)r=a[i],!(s.indexOf(r)>=0)&&(n[r]=t[r]);return n}function Vpe(t,s){if(t==null)return{};var n=Gpe(t,s),a,r;if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(t);for(r=0;r<i.length;r++)a=i[r],!(s.indexOf(a)>=0)&&Object.prototype.propertyIsEnumerable.call(t,a)&&(n[a]=t[a])}return n}function yz(t,s){return Zpe(t)||Ype(t,s)||Kpe(t,s)||Qpe()}function Zpe(t){if(Array.isArray(t))return t}function Ype(t,s){var n=t&&(typeof Symbol<"u"&&t[Symbol.iterator]||t["@@iterator"]);if(n!=null){var a=[],r=!0,i=!1,o,l;try{for(n=n.call(t);!(r=(o=n.next()).done)&&(a.push(o.value),!(s&&a.length===s));r=!0);}catch(c){i=!0,l=c}finally{try{!r&&n.return!=null&&n.return()}finally{if(i)throw l}}return a}}function Kpe(t,s){if(t){if(typeof t=="string")return hF(t,s);var n=Object.prototype.toString.call(t).slice(8,-1);if(n==="Object"&&t.constructor&&(n=t.constructor.name),n==="Map"||n==="Set")return Array.from(t);if(n==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return hF(t,s)}}function hF(t,s){(s==null||s>t.length)&&(s=t.length);for(var n=0,a=new Array(s);n<s;n++)a[n]=t[n];return a}function Qpe(){throw new TypeError(`Invalid attempt to destructure non-iterable instance. 1304In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}var qn=function(s,n,a){var r=!!a,i=re.useRef(a);re.useEffect(function(){i.current=a},[a]),re.useEffect(function(){if(!r||!s)return function(){};var o=function(){i.current&&i.current.apply(i,arguments)};return s.on(n,o),function(){s.off(n,o)}},[r,n,s,i])},MN=function(s){var n=re.useRef(s);return re.useEffect(function(){n.current=s},[s]),n.current},Um=function(s){return s!==null&&Q0(s)==="object"},Jpe=function(s){return Um(s)&&typeof s.then=="function"},Xpe=function(s){return Um(s)&&typeof s.elements=="function"&&typeof s.createToken=="function"&&typeof s.createPaymentMethod=="function"&&typeof s.confirmCardPayment=="function"},xF="[object Object]",ehe=function t(s,n){if(!Um(s)||!Um(n))return s===n;var a=Array.isArray(s),r=Array.isArray(n);if(a!==r)return!1;var i=Object.prototype.toString.call(s)===xF,o=Object.prototype.toString.call(n)===xF;if(i!==o)return!1;if(!i&&!a)return s===n;var l=Object.keys(s),c=Object.keys(n);if(l.length!==c.length)return!1;for(var u={},p=0;p<l.length;p+=1)u[l[p]]=!0;for(var m=0;m<c.length;m+=1)u[c[m]]=!0;var x=Object.keys(u);if(x.length!==l.length)return!1;var h=s,y=n,v=function(N){return t(h[N],y[N])};return x.every(v)},bz=function(s,n,a){return Um(s)?Object.keys(s).reduce(function(r,i){var o=!Um(n)||!ehe(s[i],n[i]);return a.includes(i)?(o&&console.warn("Unsupported prop change: options.".concat(i," is not a mutable property.")),r):o?pF(pF({},r||{}),{},gz({},i,s[i])):r},null):null},vz="Invalid prop `stripe` supplied to `Elements`. We recommend using the `loadStripe` utility from `@stripe/stripe-js`. See https://stripe.com/docs/stripe-js/react#elements-props-stripe for details.",fF=function(s){var n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:vz;if(s===null||Xpe(s))return s;throw new Error(n)},the=function(s){var n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:vz;if(Jpe(s))return{tag:"async",stripePromise:Promise.resolve(s).then(function(r){return fF(r,n)})};var a=fF(s,n);return a===null?{tag:"empty"}:{tag:"sync",stripe:a}},she=function(s){!s||!s._registerWrapper||!s.registerAppInfo||(s._registerWrapper({name:"react-stripe-js",version:"3.10.0"}),s.registerAppInfo({name:"react-stripe-js",version:"3.10.0",url:"https://stripe.com/docs/stripe-js/react"}))},k1=re.createContext(null);k1.displayName="ElementsContext";var jz=function(s,n){if(!s)throw new Error("Could not find Elements context; You need to wrap the part of your app that ".concat(n," in an <Elements> provider."));return s},wz=function(s){var n=s.stripe,a=s.options,r=s.children,i=re.useMemo(function(){return the(n)},[n]),o=re.useState(function(){return{stripe:i.tag==="sync"?i.stripe:null,elements:i.tag==="sync"?i.stripe.elements(a):null}}),l=yz(o,2),c=l[0],u=l[1];re.useEffect(function(){var x=!0,h=function(v){u(function(g){return g.stripe?g:{stripe:v,elements:v.elements(a)}})};return i.tag==="async"&&!c.stripe?i.stripePromise.then(function(y){y&&x&&h(y)}):i.tag==="sync"&&!c.stripe&&h(i.stripe),function(){x=!1}},[i,c,a]);var p=MN(n);re.useEffect(function(){p!==null&&p!==n&&console.warn("Unsupported prop change on Elements: You cannot change the `stripe` prop after setting it.")},[p,n]);var m=MN(a);return re.useEffect(function(){if(c.elements){var x=bz(a,m,["clientSecret","fonts"]);x&&c.elements.update(x)}},[a,m,c.elements]),re.useEffect(function(){she(c.stripe)},[c.stripe]),re.createElement(k1.Provider,{value:c},r)};wz.propTypes={stripe:ls.any,options:ls.object};var nhe=function(s){var n=re.useContext(k1);return jz(n,s)},ahe=function(){var s=nhe("calls useElements()"),n=s.elements;return n};ls.func.isRequired;var Nz=re.createContext(null);Nz.displayName="CheckoutSdkContext";var rhe=function(s,n){if(!s)throw new Error("Could not find CheckoutProvider context; You need to wrap the part of your app that ".concat(n," in an <CheckoutProvider> provider."));return s},ihe=re.createContext(null);ihe.displayName="CheckoutContext";ls.any,ls.shape({fetchClientSecret:ls.func.isRequired,elementsOptions:ls.object}).isRequired;var BN=function(s){var n=re.useContext(Nz),a=re.useContext(k1);if(n&&a)throw new Error("You cannot wrap the part of your app that ".concat(s," in both <CheckoutProvider> and <Elements> providers."));return n?rhe(n,s):jz(a,s)},ohe=["mode"],lhe=function(s){return s.charAt(0).toUpperCase()+s.slice(1)},zs=function(s,n){var a="".concat(lhe(s),"Element"),r=function(c){var u=c.id,p=c.className,m=c.options,x=m===void 0?{}:m,h=c.onBlur,y=c.onFocus,v=c.onReady,g=c.onChange,N=c.onEscape,b=c.onClick,f=c.onLoadError,j=c.onLoaderStart,S=c.onNetworksChange,w=c.onConfirm,_=c.onCancel,C=c.onShippingAddressChange,E=c.onShippingRateChange,P=c.onSavedPaymentMethodRemove,F=c.onSavedPaymentMethodUpdate,I=BN("mounts <".concat(a,">
1304")),D="elements"in I?I.elements:null,L="checkoutSdk"in I?I.checkoutSdk:null,V=re.useState(null),B=yz(V,2),A=B[0],z=B[1],M=re.useRef(null),R=re.useRef(null);qn(A,"blur",h),qn(A,"focus",y),qn(A,"escape",N),qn(A,"click",b),qn(A,"loaderror",f),qn(A,"loaderstart",j),qn(A,"networkschange",S),qn(A,"confirm",w),qn(A,"cancel",_),qn(A,"shippingaddresschange",C),qn(A,"shippingratechange",E),qn(A,"savedpaymentmethodremove",P),qn(A,"savedpaymentmethodupdate",F),qn(A,"change",g);var T;v&&(s==="expressCheckout"?T=v:T=function(){v(A)}),qn(A,"ready",T),re.useLayoutEffect(function(){if(M.current===null&&R.current!==null&&(D||L)){var q=null;if(L)switch(s){case"payment":q=L.createPaymentElement(x);break;case"address":if("mode"in x){var H=x.mode,G=Vpe(x,ohe);if(H==="shipping")q=L.createShippingAddressElement(G);else if(H==="billing")q=L.createBillingAddressElement(G);else throw new Error("Invalid options.mode. mode must be 'billing' or 'shipping'.")}else throw new Error("You must supply options.mode. mode must be 'billing' or 'shipping'.");break;case"expressCheckout":q=L.createExpressCheckoutElement(x);break;case"currencySelector":q=L.createCurrencySelectorElement();break;case"taxId":q=L.createTaxIdElement(x);break;default:throw new Error("Invalid Element type ".concat(a,". You must use either the <PaymentElement />, <AddressElement options={{mode: 'shipping'}} />, <AddressElement options={{mode: 'billing'}} />, or <ExpressCheckoutElement />."))}else D&&(q=D.create(s,x));M.current=q,z(q),q&&q.mount(R.current)}},[D,L,x]);var U=MN(x);return re.useEffect(function(){if(M.current){var q=bz(x,U,["paymentRequest"]);q&&"update"in M.current&&M.current.update(q)}},[x,U]),re.useLayoutEffect(function(){return function(){if(M.current&&typeof M.current.destroy=="function")try{M.current.destroy(),M.current=null}catch{}}},[]),re.createElement("div",{id:u,className:p,ref:R})},i=function(c){BN("mounts <".concat(a,">"));var u=c.id,p=c.className;return re.createElement("div",{id:u,className:p})},o=n?i:r;return o.propTypes={id:ls.string,className:ls.string,onChange:ls.func,onBlur:ls.func,onFocus:ls.func,onReady:ls.func,onEscape:ls.func,onClick:ls.func,onLoadError:ls.func,onLoaderStart:ls.func,onNetworksChange:ls.func,onConfirm:ls.func,onCancel:ls.func,onShippingAddressChange:ls.func,onShippingRateChange:ls.func,onSavedPaymentMethodRemove:ls.func,onSavedPaymentMethodUpdate:ls.func,options:ls.object},o.displayName=a,o.__elementType=s,o},Ls=typeof window>"u",che=re.createContext(null);che.displayName="EmbeddedCheckoutProviderContext";var dhe=function(){var s=BN("calls useStripe()"),n=s.stripe;return n};zs("auBankAccount",Ls);zs("card",Ls);zs("cardNumber",Ls);zs("cardExpiry",Ls);zs("cardCvc",Ls);zs("fpxBank",Ls);zs("iban",Ls);zs("idealBank",Ls);zs("p24Bank",Ls);zs("epsBank",Ls);var uhe=zs("payment",Ls);zs("expressCheckout",Ls);zs("currencySelector",Ls);zs("paymentRequestButton",Ls);zs("linkAuthentication",Ls);zs("address",Ls);zs("shippingAddress",Ls);zs("paymentMethodMessaging",Ls);zs("affirmMessage",Ls);zs("afterpayClearpayMessage",Ls);zs("taxId",Ls);const mhe="acct_1TGuERH6rHf7wvZP",phe=Mpe("pk_live_51OJhJBHdGQpsHqInIzu7c6PzGPSH0yImD4xfpofvxvFZs0VFhPRXZCyEgYkkhOtBOXFWvssYASs851mflwQvjnrl00T6DbUwWZ",{stripeAccount:mhe}),J0=[{key:"cleanser",order:1,label:"Cleanser",caption:"Wash away the day · lift impurities",icon:e.jsx(fd,{size:18}),matches:t=>{const s=(t.product_type||"").toLowerCase(),n=(t.tags||[]).map(r=>r.toLowerCase()),a=(t.name||"").toLowerCase();return s.includes("cleanser")||n.includes("cleanser")||a.includes("cleanser")&&!a.includes("mask")}},{key:"toner",order:2,label:"Toner",caption:"Rebalance pH · prep for absorption",icon:e.jsx(tf,{size:18}),matches:t=>{const s=(t.product_type||"").toLowerCase(),n=(t.tags||[]).map(r=>r.toLowerCase()),a=(t.name||"").toLowerCase();return s.includes("toner")||n.includes("toner")||a.includes("toner")}},{key:"serum",order:3,label:"Serum",caption:"Concentrated actives · target concerns",icon:e.jsx(Qx,{size:18}),matches:t=>{const s=(t.product_type||"").toLowerCase(),n=(t.tags||[]).map(r=>r.toLowerCase()),a=(t.name||"").toLowerCase();return a.includes("eye")||n.includes("eye-treatment")?!1:s.includes("serum")||n.includes("serum")||a.includes("serum")||n.includes("fluid")||a.includes("fluid")}},{key:"moisturizer",order:4,label:"Moisturizer",caption:"Seal hydration · protect the barrier",icon:e.jsx(Qe,{size:18}),matches:t=>{const s=(t.product_type||"").toLowerCase(),n=(t.tags||[]).map(r=>r.toLowerCase()),a=(t.name||"").toLowerCase();return a.includes("eye")||n.includes("eye-treatment")||a.includes("cleanser")||a.includes("toner")||a.includes("serum")||a.includes("mask")||a.includes("scrub")||a.includes("kit")?!1:s.includes("moisturizer")||s.includes("lotion")||s.includes("cream")||n.includes("moisturizer")||n.includes("lotion")||n.includes("cream")||a.includes("moisturizer")||a.includes("lotion")||a.includes("cream")||a.includes("crème")||a.includes("creme")}},{key:"eye",order:5,label:"Eye Treatment",caption:"Targeted care · brighten + de-puff",icon:e.jsx(ms,{size:18}),matches:t=>{const s=(t.product_type||"").toLowerCase(),n=(t.tags||[]).map(r=>r.toLowerCase()),a=(t.name||"").toLowerCase();return s.includes("eye")||n.includes("eye-treatment")||a.includes("eye")&&!a.includes("shadow")}}],gF=Object.fromEntries(J0.map(t=>[t.key,t])),iw={cleanser:null,toner:null,serum:null,moisturizer:null,eye:null},hhe=15,yF=[{key:"anti-aging",title:"Anti-Aging Ritual",concern:"Fine Lines · Firmness · Renewal",tagline:"Peptides + phyto-actives for visible age reversal.",bestFor:"Mature, dry, or fine-line-prone skin",accent:{from:"#800020",to:"#4A0010",ink:"#FFD98A"},icon:e.jsx(Qe,{size:16}),hints:{cleanser:["extreme age defying phyto-peptide","extreme age defying","zycolics derm cleanser","anti-aging","phyto-peptide"],toner:["extreme age defying cellular","extreme age defying","zycolic derm","anti-aging","cellular"],serum:["extreme age defying high-potency","extreme age defying phyto-peptide","phyto-peptide","anti-aging","longal age reversal"],moisturizer:["extreme age defying bio-active","extreme age defying","zycolics derm stem cell","longal high potency retinol","anti-aging"],eye:["extreme age defying targeted peptide","extreme age defying","zycolics derm multi conditioning","longal o² peptide","anti-aging"]}},{key:"brightening",title:"Brightening Glow",concern:"Dullness · Hyperpigmentation · Radiance",tagline:"Vitamin C + botanicals for luminous, even tone.",bestFor:"Dull, uneven, or sun-stressed skin",accent:{from:"#C5A059",to:"#A88A4A",ink:"#FFFFFF"},icon:e.jsx(Sd,{size:16}),hints:{cleanser:["wotani bright skin antioxidant","wotani bright skin botanical","evouma vitamin c facial cleanser","brightening","vitamin-c"],toner:["evouma vitamin c toner","wotani bright skin facial toner","brightening","vitamin-c"],serum:["evouma vitamin c facial serum","wotani bright skin brightening facial serum","brightening","vitamin-c"],moisturizer:["wotani bright skin facial lotion","evouma vitamin c lotion","brightening","illuminating"],eye:["evouma vitamin c eye gel","wotani bright skin eye treatment","brightening","vitamin-c"]}},{key:"sensitive",title:"Sensitive & Calm",concern:"Dryness · Sensitivity · Barrier Support",tagline:"pH-balanced hydration with aloe + lavender.",bestFor:"Dry, sensitive, or reactive skin",accent:{from:"#5A0018",to:"#2E000B",ink:"#F5E9CC"},icon:e.jsx(fd,{size:16}),hints:{cleanser:["malouwa hydration ph balancing facial cleanser","malouwa","hydration","gentle","sensitive"],toner:["malouwa hydration ph balancing facial toner","malouwa","ph-balancing","sensitive"],serum:["malouwa hydration ph balancing hyaluronic","malouwa","hyaluronic-acid","hydration"],moisturizer:["malouwa hydration ph balancing facial lotion","malouwa","hydration","bio-available"],eye:["malouwa hydration moisturizing eye treatment","malouwa","hydration","sensitive"]}},{key:"oil-control",title:"Oil-Control & Clarity",concern:"Oiliness · Breakouts · Pore Care",tagline:"Botanical balancing for oily + combination skin.",bestFor:"Oily, combination, or breakout-prone skin",accent:{from:"#1F4D3A",to:"#0F2A20",ink:"#C8E6D0"},icon:e.jsx(tf,{size:16}),hints:{cleanser:["wealei gentle feel clarifying","wealei","clarifying","oily-skin"],toner:["wealei gentle feel balancing toner","wealei","oil-free","balancing"],serum:["wealei gentle feel gentle hydration","wealei","cucumber","hyaluronic-acid"],moisturizer:["wealei","oil-free","lotion","combination"],eye:["wealei gentle feel daytime eye crème","
1304wealei","eye","daytime"]}}],xhe=(t,s)=>{const n=((t.name||"")+" "+(t.product_type||"")+" "+(t.tags||[]).join(" ")).toLowerCase();let a=0;return s.forEach((r,i)=>{n.includes(r.toLowerCase())&&(a+=Math.round(100/(i+1)))}),a},Bh=[{id:"skin_type",prompt:"How would you describe your skin?",helper:"Pick the description that fits most days.",options:[{value:"dry",label:"Dry · Tight · Flaky",weights:{sensitive:4,"anti-aging":2}},{value:"oily",label:"Oily · Shiny · Enlarged pores",weights:{"oil-control":5,brightening:1}},{value:"combination",label:"Combination · Oily T-zone",weights:{"oil-control":3,brightening:2}},{value:"normal",label:"Normal · Balanced",weights:{brightening:3,"anti-aging":1,"oil-control":1}}]},{id:"top_concern",prompt:"What is your #1 skin concern?",helper:"Choose the result you most want to see.",options:[{value:"aging",label:"Fine lines · Firmness · Anti-aging",weights:{"anti-aging":6}},{value:"dullness",label:"Dullness · Dark spots · Uneven tone",weights:{brightening:6}},{value:"sensitivity",label:"Redness · Sensitivity · Dryness",weights:{sensitive:6}},{value:"breakouts",label:"Breakouts · Oiliness · Large pores",weights:{"oil-control":6}}]},{id:"age_range",prompt:"Which age range are you in?",helper:"Helps us match potency to your skin's renewal stage.",options:[{value:"under-25",label:"Under 25",weights:{"oil-control":3,brightening:2}},{value:"25-34",label:"25 â 34",weights:{brightening:3,"anti-aging":1,"oil-control":1}},{value:"35-44",label:"35 â 44",weights:{"anti-aging":3,brightening:2}},{value:"45-plus",label:"45+",weights:{"anti-aging":5,sensitive:1}}]},{id:"sensitivity",prompt:"Does your skin react easily to new products?",helper:"Stinging, redness, or breakouts when you try new actives.",options:[{value:"very",label:"Very â I avoid actives",weights:{sensitive:6}},{value:"somewhat",label:"Somewhat â I patch test",weights:{sensitive:3,brightening:1}},{value:"rarely",label:"Rarely â I tolerate most",weights:{"anti-aging":2,brightening:1,"oil-control":1}},{value:"never",label:"Never â bring on the actives",weights:{"anti-aging":3,"oil-control":2}}]}],bF={skin_type:null,top_concern:null,age_range:null,sensitivity:null},_z="zorganics_routine_email",vF="zorganics_routine_welcomeback_dismissed",ow=t=>{if(!(typeof document>"u"))try{document.cookie=`${_z}=${encodeURIComponent(t)}; path=/; max-age=15552000; samesite=lax`}catch{}},fhe=()=>{if(typeof document>"u")return null;try{const t=document.cookie.match(new RegExp(`(?:^|; )${_z}=([^;]*)`));return t?decodeURIComponent(t[1]):null}catch{return null}},ghe=t=>{const s={"anti-aging":0,brightening:0,sensitive:0,"oil-control":0};return Bh.forEach(a=>{const r=t[a.id];if(!r)return;const i=a.options.find(o=>o.value===r);i&&Object.entries(i.weights).forEach(([o,l])=>{s[o]+=l})}),Object.entries(s).sort((a,r)=>r[1]-a[1])[0][0]},yhe=()=>{const{user:t}=kn(),[s,n]=d.useState(!1),[a,r]=d.useState(bF),[i,o]=d.useState(""),[l,c]=d.useState(""),[u,p]=d.useState(!1),[m,x]=d.useState(null),[h,y]=d.useState(null),[v,g]=d.useState(null),[N,b]=d.useState(()=>{if(typeof sessionStorage>"u")return!1;try{return sessionStorage.getItem(vF)==="1"}catch{return!1}}),[f,j]=d.useState([]),[S,w]=d.useState(!0),[_,C]=d.useState(null),[E,P]=d.useState("am"),[F,I]=d.useState(iw),[D,L]=d.useState(iw),[V,B]=d.useState(null),[A,z]=d.useState((t==null?void 0:t.email)||""),[M,R]=d.useState((t==null?void 0:t.fullName)||""),[T,U]=d.useState(null),[q,H]=d.useState(!1),[G,W]=d.useState(null),[X,Q]=d.useState("idle"),[K,se]=d.useState(null),[Y,J]=d.useState(null),[te,pe]=d.useState(null),[Fe,ke]=d.useState(!1);d.useEffect(()=>{let _e=!1;return(async()=>{try{w(!0);const{data:Se,error:We}=await O.from("ecom_products").select("id, name, handle, description, price, sku, images, status, product_type, tags, metadata, vendor").eq("status","active").order("price",{ascending:!1});if(_e)return;if(We)throw We;j(Se||[])}catch(Se){_e||C(Se.message||String(Se))}finally{_e||w(!1)}})(),()=>{_e=!0}},[]),d.useEffect(()=>{t!=null&&t.email&&z(t.email),t!=null&&t.fullName&&R(t.fullName)},[t]);const Oe=d.useMemo(()=>
1304{if(!V)return[];const _e=gF[V];return f.filter(_e.matches)},[V,f]),ue=d.useMemo(()=>{const _e=new Map;return f.forEach(Se=>_e.set(Se.id,Se)),_e},[f]),je=d.useMemo(()=>f.length===0?[]:yF.map(_e=>{const Se={...iw},We={};J0.forEach($t=>{const Nt=f.filter($t.matches);let ps=null,ft=0;Nt.forEach(Ca=>{const ee=xhe(Ca,_e.hints[$t.key]);ee>ft&&(ft=ee,ps=Ca)}),!ps&&Nt.length>0&&(ps=[...Nt].sort((Ca,ee)=>(Ca.price||0)-(ee.price||0))[0]),ps&&(Se[$t.key]=ps.id,We[$t.key]=ps)});const Ut=Object.values(We).reduce(($t,Nt)=>$t+((Nt==null?void 0:Nt.price)||0),0);return{template:_e,selections:Se,productsByStep:We,total:Ut,dailyCost:Math.round(Ut/30)}}),[f]);d.useEffect(()=>{if(S||je.length===0||v||N)return;const _e=((t==null?void 0:t.email)||fhe()||"").trim().toLowerCase();if(!_e||!_e.includes("@"))return;let Se=!1;return(async()=>{try{const{data:We,error:Ut}=await O.from("routine_quiz_responses").select("recommended_template_key, recommended_template_title, customer_routine_id, name, created_at, email").ilike("email",_e).order("created_at",{ascending:!1}).limit(1).maybeSingle();if(Se||Ut||!We||!We.recommended_template_key)return;const $t=je.find(Nt=>Nt.template.key===We.recommended_template_key);if(!$t)return;g({templateKey:We.recommended_template_key,templateTitle:We.recommended_template_title||$t.template.title,createdAt:We.created_at,customerRoutineId:We.customer_routine_id||null,recognizedEmail:We.email||_e,recognizedName:We.name||null}),y(We.recommended_template_key),I($t.selections),L($t.selections),A||z(We.email||_e),!M&&We.name&&R(We.name),t!=null&&t.email||ow(_e)}catch(We){console.warn("Welcome-back lookup failed:",We)}})(),()=>{Se=!0}},[S,je.length,t==null?void 0:t.email]);const le=_e=>{I(_e.selections),L(_e.selections),U(null),setTimeout(()=>{const Se=document.getElementById("routine-steps-section");Se&&Se.scrollIntoView({behavior:"smooth",block:"start"})},100)},ye=async()=>{if(x(null),!Bh.every(We=>a[We.id])){x("Please answer all four questions to get your recommendation.");return}const Se=(i||A).trim();if(!Se||!Se.includes("@")){x("Please enter a valid email so we can send your personalized routine.");return}p(!0);try{const We=ghe(a),Ut=yF.find(ft=>ft.key===We),$t=je.find(ft=>ft.template.key===We),Nt=await AI({formType:"quiz_lead",payload:{email:Se,name:l||M||null,skin_type:a.skin_type,top_concern:a.top_concern,age_range:a.age_range,sensitivity:a.sensitivity,recommended_template_key:We,recommended_template_title:(Ut==null?void 0:Ut.title)||null,raw_answers:a},crm:{source:"routine-builder-quiz",name:l||M||void 0,tags:["cosmetics","routine-builder","find-my-routine-quiz",`concern-${a.top_concern}`,`age-${a.age_range}`,`recommended-${We}`]}}),ps=["turnstile_failed","honeypot_triggered","rate_limited","too_fast","invalid_request","not_verified"];if(!Nt.ok&&ps.includes(Nt.reason||"")){x(Nt.message||I5(Nt.reason)),p(!1);return}Nt.ok||console.warn("Quiz response not stored:",Nt.reason),ow(Se),$t&&le($t),A||z(Se),!M&&l&&R(l),y(We),n(!1),setTimeout(()=>{const ft=document.getElementById(`template-card-${We}`);ft&&ft.scrollIntoView({behavior:"smooth",block:"center"})},150),setTimeout(()=>y(null),6500)}catch(We){console.error("Quiz submit error:",We),x(We.message||"Could not save your quiz. Please try again.")}finally{p(!1)}},we=d.useMemo(()=>{const _e=new Set;return Object.values(F).forEach(Se=>Se&&_e.add(Se)),Object.values(D).forEach(Se=>Se&&_e.add(Se)),_e},[F,D]),He=d.useMemo(()=>{let _e=0;return we.forEach(Se=>{var We;_e+=((We=ue.get(Se))==null?void 0:We.price)||0}),_e},[we,ue]),Lt=d.useMemo(()=>Math.round(He/30),[He]),ut=d.useMemo(()=>Math.round(He*(hhe/100)),[He]),ge=He-ut,Ne=Math.round(ge/30),lt=we.size>0,mt=lt&&A.length>3&&A.includes("@"),ae=_e=>{V&&(E==="am"?I(Se=>({...Se,[V]:_e})):L(Se=>({...Se,[V]:_e})),B(null),U(null))},qe=_e=>{E==="am"?I(Se=>({...Se,[_e]:null})):L(Se=>({...Se,[_e]:null})),U(null)},bt=()=>{L({...F}),U(null)},ht=async()=>{if(!A||!A.includes("@"))return W("Please enter a valid email to save your routine."),null;if(!lt)return W("Add at least one product to your routine before saving."),null;H(!0),W(null);try{const{data:_e}=await O.from("ecom_customers").upsert({email:A,name:M||null},{onConflict:"email"}).select("id").maybeSingle(),Se=(()=>{const $t=Object.values(F).some(Boolean),Nt=Object.values(D).some(Boolean);return $t&&Nt?"both":Nt?"pm":"am"})(),{data:We,error:Ut}=await O.from("customer_routines").insert({customer_id:(_e==null?void 0:_e.id)||null,email:A,name:M||null,routine_peri
1304od:Se,am_steps:F,pm_steps:D,estimated_cost_per_day_cents:Lt}).select("id").single();if(Ut)throw Ut;try{const{data:$t}=await O.from("routine_quiz_responses").select("id, customer_routine_id").ilike("email",A).order("created_at",{ascending:!1}).limit(1).maybeSingle();$t&&!$t.customer_routine_id&&await O.from("routine_quiz_responses").update({customer_routine_id:We.id,updated_at:new Date().toISOString()}).eq("id",$t.id)}catch($t){console.warn("Could not link quiz response to routine:",$t)}ow(A);try{await fetch("https://famous.ai/api/crm/69caed6904ed6aca7682413a/subscribe",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({email:A,name:M||void 0,source:"routine-builder",tags:["cosmetics","routine-builder","skincare"]})})}catch{}return U(We.id),We.id}catch(_e){return W(_e.message||"Failed to save your routine."),null}finally{H(!1)}},Ht=async()=>{if(pe(null),!mt){pe("Add at least one product and enter your email to subscribe.");return}ke(!0);try{let _e=T;if(_e||(_e=await ht()),!_e){pe("Could not save your routine. Please try again."),ke(!1);return}const{data:Se,error:We}=await O.functions.invoke("create-routine-subscription",{body:{action:"create-setup-intent",email:A,name:M||A.split("@")[0]}});if(We)throw We;if(!(Se!=null&&Se.clientSecret))throw new Error("Payment system did not return a setup token.");se(Se.clientSecret),J(Se.customerId),Q("setup-payment")}catch(_e){console.error("beginSubscribe error:",_e),pe(_e.message||"Unable to start subscription. Please try again.")}finally{ke(!1)}},wt=E==="am"?F:D;return S?e.jsx("div",{className:"min-h-screen flex items-center justify-center bg-gradient-to-br from-[#FAF6EE] to-white",children:e.jsxs("div",{className:"text-center",children:[e.jsx(de,{size:36,className:"text-[#C5A059] animate-spin mx-auto mb-3"}),e.jsx("p",{className:"text-sm font-semibold text-gray-600",children:"Loading your luxury skincare catalogâ¦"})]})}):_?e.jsx("div",{className:"min-h-screen flex items-center justify-center bg-gradient-to-br from-[#FAF6EE] to-white p-6",children:e.jsxs("div",{className:"max-w-md bg-white border-2 border-red-200 rounded-2xl p-6 shadow-lg",children:[e.jsx(ve,{className:"text-red-500 mb-3",size:32}),e.jsx("h2",{className:"font-display text-xl font-bold text-red-900 mb-2",children:"Catalog unavailable"}),e.jsx("p",{className:"text-sm text-red-700",children:_})]})}):e.jsxs("div",{className:"min-h-screen bg-gradient-to-br from-[#FAF6EE] via-white to-[#FAF6EE]/40",children:[e.jsxs("header",{className:"relative overflow-hidden border-b border-[#C5A059]/30",style:{background:"linear-gradient(135deg, #FAF6EE 0%, #FFFFFF 45%, #F5EBD0 100%)"},children:[e.jsx("div",{className:"absolute inset-0 opacity-10 pointer-events-none",style:{backgroundImage:"radial-gradient(circle at 20% 30%, rgba(197,160,89,0.4) 0%, transparent 50%), radial-gradient(circle at 80% 70%, rgba(197,160,89,0.3) 0%, transparent 50%)"}}),e.jsxs("div",{className:"relative max-w-6xl mx-auto px-5 lg:px-10 py-10 lg:py-14",style:{color:"#3B0A11"},children:[e.jsxs(be,{to:"/",className:"inline-flex items-center gap-1.5 text-[11px] font-semibold uppercase tracking-[0.18em] hover:underline mb-4",style:{color:"#3B0A11"},children:[e.jsx(Je,{size:12})," Back to Zorganics"]}),e.jsxs("div",{className:"flex items-center gap-2 mb-3 flex-wrap",children:[e.jsx("div",{className:"w-1.5 h-5 rounded-full",style:{backgroundColor:"#800020"}}),e.jsx("span",{className:"text-xs font-extrabold uppercase tracking-[0.18em]",style:{color:"#3B0A11"},children:"Zorganics Routine Builder · Personalize · Save · Subscribe"})]}),e.jsx("h1",{className:"font-display text-3xl lg:text-5xl font-bold leading-tight mb-3",style:{color:"#3B0A11"},children:"Build Your AM & PM Skincare Ritual"}),e.jsxs("p",{className:"text-sm lg:text-base max-w-2xl leading-relaxed font-medium",style:{color:"#5A1A24"},children:["Compose a five-step regimen â ",e.jsx("em",{className:"font-semibold not-italic underline decoration-[#C5A059]/60 underline-offset-2",style:{color:"#3B0A11"},children:"Cleanser, Toner, Serum, Moisturizer, Eye Treatment"})," â from our certified-organic luxury lines. Save it to your account, see your daily ritual cost, and subscribe monthly to save ",e.jsx("span",{className:"font-bold",style:{color:"#800020"},children:"15%"})," automatically."]}),e.jsxs("div",{className:"flex items-center gap-3 mt-5 text-xs font-semibold flex-wrap",style:{color:"#5A1A24"},children:[e.jsxs("span",{className:"inline-flex items-center gap-1.5",children:[e.jsx(Tt,{size:13,style:{color:"#800020"}})," Certified Organic"]}),e.jsx("span",{style:{color:"#C5A059"},children:"·"}),e.jsxs("span",{className:"inline-flex items-center gap-1.5",children:[e.jsx(tf,{size:13,style:{color:"#800020"}})," 100% Vegan"]}),e.jsx("span",{style:{color:"#C5A059"},children:"·"}),e.jsxs("span",{className:"inline-flex items-center gap-1.5",children:[e.jsx(At,{size:13,style:{color:"#800020"}})," Cancel Anytime"]})]}),e.jsxs("div",{className:"mt-7 flex flex-col sm:flex-row items-stretch sm:items-center gap-3",children:[e.jsxs("button",{onClick:()=>{x(null),n(!0)},className:"group inline-flex items-center justify-center gap-2 px-6 py-3.5 rounded-xl font-bold text-sm uppercase tracking-wider shadow-2xl hover:shadow-[0_0_40px_rgba(255,217,138,0.4)] transition-all border-2",style:{background:"linear-gradient(135deg, #FFFFFF 0%, #FFF4D6 50%, #FFD98A 100%)",color:"#4A0010",borderColor:"#FFD98A"},children:[e.jsx(ux,{size:16,className:"group-hover:rotate-12 transition-transform"}),"Find My Routine",e.jsx("span",{className:"text-[10px] font-bold px-1.5 py-0.5 rounded-md ml-1",style:{backgroundColor:"#800020",color:"#FFD98A"},children:"60s Quiz"})]}),e.jsx("p",{className:"text-[12px] leading-snug max-w-sm font-medium",style:{color:"#5A1A24"},children:"Not sure where to start? Take our 4-question skin quiz and we'll auto-build a routine tailored to your skin."})]})]})]}),je.length>0&&e.jsx("section",{className:"border-b border-[#C5A059]/15 bg-gradient-to-b from-white via-[#FAF6EE]/40 to-transparent",children:e.jsxs("div",{className:"max-w-6xl mx-auto px-5 lg:px-10 py-8 lg:py-12",children:[e.jsxs("div",{className:"text-center mb-7",children:[e.jsxs("div",{className:"inline-flex items-center gap-2 px-3 py-1 rounded-full mb-3 border",style:{borderColor:"#C5A05933",backgroundColor:"#FAF6EE"},children:[e.jsx(zo,{size:11,style:{color:"#C5A059"},fill:"#C5A059"}),e.jsx("span",{className:"text-[10px] font-bold uppercase tracking-[0.18em]",style:{color:"#800020"},children:"Start in one click · Curated by our formulators"})]}),e.jsx("h2",{className:"font-display text-2xl lg:text-3xl font-bold leading-tight mb-2",style:{color:"#4A0010"},children:"Pre-Made Routines"}),e.jsx("p",{className:"text-sm text-gray-600 max-w-2xl mx-auto leading-relaxed",children:"Skip the guesswork â pick a routine built for your skin concern. We'll auto-fill all five steps for both AM & PM. You can swap any product after."})]}),v&&!N&&e.jsxs("div",{className:"relative mb-6 rounded-2xl border-2 shadow-lg overflow-hidden",style:{background:"linear-gradient(135deg, #FAF6EE 0%, #FFF4D6 50%, #FFE9B8 100%)",borderColor:"#C5A059"},children:[e.jsx("div",{className:"absolute inset-0 opacity-10 pointer-events-none",style:{backgroundImage:"radial-gradient(circle at 15% 50%, rgba(128,0,32,0.5) 0%, transparent 50%), radial-gradient(circle at 85% 50%, rgba(197,160,89,0.45) 0%, transparent 55%)"}}),e.jsxs("div",{className:"relative px-4 sm:px-6 py-4 flex flex-col sm:flex-row sm:items-center gap-3 sm:gap-4",children:[e.jsx("div",{className:"w-11 h-11 rounded-full flex items-center justify-center shrink-0 shadow-md self-start sm:self-ce
1304nter",style:{background:"linear-gradient(135deg, #800020 0%, #5A0018 100%)"},children:e.jsx(en,{size:20,style:{color:"#FFD98A"}})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2 flex-wrap mb-0.5",children:[e.jsx("span",{className:"text-[9px] font-bold uppercase tracking-[0.18em] px-2 py-0.5 rounded-full",style:{backgroundColor:"#800020",color:"#FFD98A"},children:"Welcome back"}),v.customerRoutineId&&e.jsxs("span",{className:"text-[9px] font-bold uppercase tracking-[0.14em] inline-flex items-center gap-1",style:{color:"#4A6A3A"},children:[e.jsx(Ue,{size:10})," Routine on file"]})]}),e.jsxs("p",{className:"font-display text-sm sm:text-base font-bold leading-snug",style:{color:"#4A0010"},children:[v.recognizedName?`Welcome back, ${v.recognizedName.split(" ")[0]}`:"Welcome back",e.jsxs("span",{className:"font-normal text-gray-700",children:[" ","â here's the routine we picked for you last time."]})]}),e.jsxs("p",{className:"text-[11px] text-gray-600 leading-relaxed mt-0.5",children:["Your ",e.jsx("span",{className:"font-semibold",style:{color:"#800020"},children:v.templateTitle})," ","is already applied to AM & PM below."," ",e.jsx("button",{type:"button",onClick:()=>{r(bF),x(null),n(!0)},className:"underline font-semibold hover:no-underline",style:{color:"#800020"},children:"Retake the quiz"})," ","to update your match."]})]}),e.jsx("button",{type:"button",onClick:()=>{b(!0),y(null);try{sessionStorage.setItem(vF,"1")}catch{}},className:"absolute top-2 right-2 sm:static p-1.5 rounded-lg hover:bg-white/60 transition-colors shrink-0",title:"Dismiss","aria-label":"Dismiss welcome back banner",children:e.jsx(Ke,{size:14,style:{color:"#800020"}})})]})]}),e.jsx("div",{className:"grid sm:grid-cols-2 lg:grid-cols-4 gap-4",children:je.map(_e=>{const{template:Se,productsByStep:We,total:Ut,dailyCost:$t}=_e,Nt=Object.values(We).filter(Boolean).length;return e.jsxs("div",{id:`template-card-${Se.key}`,className:`group relative bg-white rounded-2xl border-2 shadow-sm hover:shadow-2xl transition-all overflow-hidden flex flex-col hover:-translate-y-1 ${h===Se.key?"ring-4 ring-offset-2 ring-[#C5A059] animate-pulse":""}`,style:{borderColor:h===Se.key?"#800020":"#E6D2A044",boxShadow:h===Se.key?"0 0 0 4px rgba(197,160,89,0.3), 0 25px 50px -12px rgba(128,0,32,0.4)":void 0},children:[h===Se.key&&e.jsxs("div",{className:"absolute top-2 right-2 z-10 px-2.5 py-1 rounded-full text-[9px] font-bold uppercase tracking-wider shadow-lg flex items-center gap-1 animate-bounce",style:{background:"linear-gradient(135deg, #FFD98A 0%, #C5A059 100%)",color:"#4A0010"},children:[e.jsx(ux,{size:10})," Picked for You"]}),e.jsxs("div",{className:"px-4 py-4 text-white relative overflow-hidden",style:{background:`linear-gradient(135deg, ${Se.accent.from} 0%, ${Se.accent.to} 100%)`},children:[e.jsx("div",{className:"absolute inset-0 opacity-15 pointer-events-none",style:{backgroundImage:"radial-gradient(circle at 80% 20%, rgba(255,255,255,0.4) 0%, transparent 60%)"}}),e.jsxs("div",{className:"relative",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-1.5",children:[e.jsx("div",{className:"w-8 h-8 rounded-lg flex items-center justify-center",style:{backgroundColor:"rgba(255,255,255,0.18)",color:Se.accent.ink},children:Se.icon}),e.jsxs("span",{className:"text-[9px] font-bold uppercase tracking-[0.16em]",style:{color:Se.accent.ink},children:[Nt," of 5 steps"]})]}),e.jsx("h3",{className:"font-display text-base lg:text-lg font-bold leading-tight",children:Se.title}),e.jsx("p",{className:"text-[10px] font-semibold uppercase tracking-wider mt-0.5",style:{color:Se.accent.ink},children:Se.concern})]})]}),e.jsxs("div",{className:"p-4 flex-1 flex flex-col",children:[e.jsxs("p",{className:"text-xs text-gray-700 leading-relaxed mb-2 italic",children:['"',Se.tagline,'"']}),e.jsxs("p",{className:"text-[10px] font-semibold uppercase tracking-wider mb-3",style:{color:"#A88A4A"},children:["Best for: ",e.jsx("span",{className:"font-normal normal-case text-gray-600 tracking-normal",children:Se.bestFor})]}),e.jsx("ul",{className:"space-y-1.5 mb-4 flex-1",children:J0.map(ps=>
1304{const ft=We[ps.key];return ft?e.jsxs("li",{className:"flex items-start gap-2 text-[11px]",children:[e.jsx("span",{className:"inline-flex items-center justify-center w-4 h-4 rounded-full text-[8px] font-bold shrink-0 mt-0.5",style:{backgroundColor:"#FAF6EE",color:"#800020",border:"1px solid #C5A05955"},children:ps.order}),e.jsxs("span",{className:"text-gray-700 leading-snug",children:[e.jsxs("span",{className:"font-semibold text-gray-900",children:[ps.label,":"]})," ",e.jsx("span",{title:ft.name,children:ft.name.replace(/â¢/g,"⢠").replace(/\s+/g," ").trim()})]})]},ps.key):null})}),e.jsxs("div",{className:"pt-3 border-t border-gray-100 mb-3",children:[e.jsxs("div",{className:"flex items-baseline justify-between mb-0.5",children:[e.jsx("span",{className:"text-[10px] font-bold uppercase tracking-wider text-gray-500",children:"Cost / Day"}),e.jsxs("span",{className:"font-display text-2xl font-bold",style:{color:"#800020"},children:["$",($t/100).toFixed(2)]})]}),e.jsxs("p",{className:"text-[10px] text-gray-500 text-right",children:["$",(Ut/100).toFixed(2)," / month · $",(Math.round(Ut*.85)/100).toFixed(2)," as Subscriber"]})]}),e.jsxs("button",{onClick:()=>le(_e),className:"w-full py-2.5 rounded-lg text-xs font-bold uppercase tracking-wider transition-all hover:shadow-lg flex items-center justify-center gap-1.5 text-white",style:{background:`linear-gradient(135deg, ${Se.accent.from} 0%, ${Se.accent.to} 100%)`},children:["Use This Routine",e.jsx(Vt,{size:12})]})]})]},Se.key)})}),e.jsxs("div",{className:"flex items-center justify-center gap-3 mt-8",children:[e.jsx("div",{className:"flex-1 h-px max-w-[120px]",style:{background:"linear-gradient(to right, transparent, #C5A05955)"}}),e.jsx("span",{className:"text-[10px] font-bold uppercase tracking-[0.18em]",style:{color:"#A88A4A"},children:"or build your own below"}),e.jsx("div",{className:"flex-1 h-px max-w-[120px]",style:{background:"linear-gradient(to left, transparent, #C5A05955)"}})]})]})}),e.jsxs("main",{className:"max-w-6xl mx-auto px-5 lg:px-10 py-8 lg:py-12 grid lg:grid-cols-[1.6fr_1fr] gap-6 lg:gap-10",children:[e.jsxs("section",{id:"routine-steps-section",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-5",children:[e.jsxs("button",{onClick:()=>P("am"),className:`flex items-center gap-2 px-5 py-3 rounded-xl text-sm font-bold transition-all border-2 ${E==="am"?"text-white shadow-lg border-[#C5A059]":"bg-white text-gray-500 border-gray-200 hover:border-[#C5A059]/40 hover:text-[#800020]"}`,style:E==="am"?{background:"linear-gradient(135deg, #C5A059, #A88A4A)"}:{},children:[e.jsx(Sd,{size:16})," AM Ritual"]}),e.jsxs("button",{onClick:()=>P("pm"),className:`flex items-center gap-2 px-5 py-3 rounded-xl text-sm font-bold transition-all border-2 ${E==="pm"?"text-white shadow-lg border-[#C5A059]":"bg-white text-gray-500 border-gray-200 hover:border-[#C5A059]/40 hover:text-[#800020]"}`,style:E==="pm"?{background:"linear-gradient(135deg, #4A0010, #800020)"}:{},children:[e.jsx(ox,{size:16})," PM Ritual"]}),E==="pm"&&Object.values(F).some(Boolean)&&e.jsx("button",{onClick:bt,className:"ml-auto text-[11px] font-bold uppercase tracking-wider hover:underline",style:{color:"#800020"},title:"Copy your AM routine to PM",children:"â» Mirror AM â PM"})]}),e.jsx("div",{className:"space-y-4",children:J0.map(_e=>{var Ut;const Se=wt[_e.key],We=Se?ue.get(Se):null;return e.jsx("div",{className:"bg-white rounded-2xl border-2 border-gray-200 overflow-hidden shadow-sm hover:shadow-lg transition-all hover:border-[#C5A059]/60",children:e.jsxs("div",{className:"flex items-stretch",children:[e.jsxs("div",{className:"w-20 lg:w-24 flex-shrink-0 flex flex-col items-center justify-center text-white py-4",style:{background:We?"linear-gradient(180deg, #800020 0%, #5A0018 100%)":"linear-gradient(180deg, #C5A059 0%, #A88A4A 100%)"},children:[e.jsx("span",{className:"text-[10px] font-bold uppercase tracking-[0.18em] opacity-95",children:"Step"}),e.jsx("span",{className:"font-display text-3xl lg:text-4xl font-bold leading-none mt-0.5",children:_e.order}),e.jsx("div",{className:"mt-2 opacity-95",children:_e.icon})]}),e.jsxs("div",{className:"flex-1 min-w-0 p-4 lg:p-5 flex flex-col sm:flex-row items-start sm:items-center gap-3 sm:gap-4",children:[e.jsxs("div",{className:"flex-1 min-w-0
1304w-full",children:[e.jsx("h3",{className:"font-display text-lg lg:text-xl font-bold text-gray-900 leading-tight",children:_e.label}),e.jsx("p",{className:"text-xs lg:text-sm text-gray-600 leading-snug mt-0.5 mb-3",children:_e.caption}),We?e.jsxs("div",{className:"flex items-center gap-3 p-2.5 rounded-lg bg-gradient-to-r from-[#FAF6EE] to-white border border-[#C5A059]/30",children:[e.jsx("div",{className:"w-14 h-14 rounded-lg overflow-hidden shrink-0 border border-gray-200 bg-gradient-to-br from-[#FAF6EE] to-[#EFE4CC]",children:(Ut=We.images)!=null&&Ut[0]?e.jsx("img",{src:We.images[0],alt:We.name,className:"w-full h-full object-cover"}):e.jsx("div",{className:"w-full h-full flex items-center justify-center",children:e.jsx(Io,{size:18,className:"text-[#C5A059]"})})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"text-sm font-bold text-gray-900 truncate",title:We.name,children:We.name}),e.jsxs("p",{className:"text-xs text-gray-700 font-semibold mt-0.5",children:["$",(We.price/100).toFixed(2),We.product_type&&e.jsxs("span",{className:"text-gray-500 font-normal",children:[" · ",We.product_type]})]})]})]}):e.jsxs("div",{className:"flex items-center gap-2 px-3 py-2.5 rounded-lg border-2 border-dashed",style:{borderColor:"#C5A059",backgroundColor:"#FAF6EE"},children:[e.jsx(tn,{size:14,style:{color:"#800020"}}),e.jsxs("p",{className:"text-xs lg:text-sm font-semibold",style:{color:"#800020"},children:["Choose your ",_e.label.toLowerCase()," â"]})]})]}),e.jsxs("div",{className:"flex sm:flex-col gap-2 shrink-0 w-full sm:w-auto",children:[e.jsx("button",{onClick:()=>B(_e.key),className:"flex-1 sm:flex-none px-4 py-2.5 rounded-lg text-xs font-bold uppercase tracking-wider transition-all hover:shadow-lg flex items-center justify-center gap-1.5 text-white",style:{background:"linear-gradient(135deg, #800020 0%, #5A0018 100%)"},children:We?e.jsxs(e.Fragment,{children:["Swap ",e.jsx(Vt,{size:12})]}):e.jsxs(e.Fragment,{children:[e.jsx(tn,{size:12})," Add Product"]})}),We&&e.jsx("button",{onClick:()=>qe(_e.key),className:"px-3 py-2 rounded-lg text-[11px] font-semibold text-gray-600 hover:text-red-600 hover:bg-red-50 transition-all border border-gray-200",children:"Remove"})]})]})]})},_e.key)})})]}),e.jsx("aside",{children:e.jsxs("div",{className:"sticky top-6 space-y-4",children:[e.jsxs("div",{className:"rounded-2xl border-2 shadow-lg overflow-hidden bg-white",children:[e.jsxs("div",{className:"px-5 py-4",style:{background:"linear-gradient(135deg, #800020 0%, #5A0018 100%)"},children:[e.jsx("p",{className:"text-[10px] font-bold uppercase tracking-[0.18em]",style:{color:"#E6D2A0"},children:"Your Routine · Live Summary"}),e.jsxs("p",{className:"text-white/90 text-xs mt-1",children:[we.size," of 5 steps selected · ",E==="am"?"AM":"PM"," active"]})]}),e.jsxs("div",{className:"p-5 space-y-3",children:[e.jsxs("div",{className:"text-center py-3",children:[e.jsx("p",{className:"text-[10px] font-bold uppercase tracking-wider text-gray-500",children:"Estimated Cost / Day"}),e.jsxs("p",{className:"font-display text-4xl font-bold mt-1",style:{color:"#800020"},children:["$",(Lt/100).toFixed(2)]}),e.jsx("p",{className:"text-[10px] text-gray-400 mt-0.5",children:"based on a 30-day replenishment cycle"})]}),e.jsxs("div",{className:"space-y-1.5 pt-2 border-t border-gray-100",children:[e.jsxs("div",{className:"flex justify-between text-xs",children:[e.jsx("span",{className:"text-gray-500",children:"Routine Total (monthly)"}),e.jsxs("span",{className:"font-mono font-semibold text-gray-900",children:["$",(He/100).toFixed(2)]})]}),lt&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex justify-between text-xs",style:{color:"#800020"},children:[e.jsx("span",{className:"font-semibold",children:"Subscriber Discount (â15%)"}),e.jsxs("span",{className:"font-mono font-bold",children:["â$",(ut/100).toFixed(2)]})]}),e.jsxs("div",{className:"flex justify-between text-sm font-bold pt-2 border-t border-gray-100",children:[e.jsx("span",{children:"Subscriber Total / Month"}),e.jsxs("span",{className:"font-mono",style:{color:"#800020"},children:["$",(ge/100).toFixed(2)]})]}),e.jsxs("div",{className:"flex items-center gap-1.5 text-[10px] mt-1",style:{color:"#C5A059"},children:[e.jsx(t5,{size:11})," That's $",(Ne/100).toFixed(2)," / day as a Subscriber"]})]})]})]})]}),e.jsxs("div",{className:"bg-white rounded-2xl border-2 border-gray-100 shadow-sm p-5",children:[e.jsx("p",{className:"text-[10px] font-bold uppercase tracking-wider mb-2",style:{color:"#800020"},children:"Save to your account"}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("input",{type:"text",value:M,onChange:_e=>{R(_e.target.value),U(null)},placeholder:"Your name",className:"w-full px-3 py-2 text-sm border border-gray-200 rounded-lg focus:outline-none focus:ring-2 focus:ring-[#C5A059]/40 focu
1304s:border-[#C5A059]"}),e.jsx("input",{type:"email",value:A,onChange:_e=>{z(_e.target.value),U(null)},placeholder:"[email protected]",className:"w-full px-3 py-2 text-sm border border-gray-200 rounded-lg focus:outline-none focus:ring-2 focus:ring-[#C5A059]/40 focus:border-[#C5A059]"})]}),G&&e.jsxs("div",{className:"mt-2 flex items-start gap-1.5 px-2.5 py-1.5 rounded-md bg-red-50 border border-red-200",children:[e.jsx(ve,{size:11,className:"text-red-500 shrink-0 mt-0.5"}),e.jsx("p",{className:"text-[10px] text-red-700 leading-snug",children:G})]}),e.jsxs("button",{onClick:()=>ht(),disabled:q||!lt,className:"w-full mt-3 px-4 py-2.5 rounded-lg text-xs font-bold uppercase tracking-wider transition-all flex items-center justify-center gap-1.5 disabled:opacity-50 disabled:cursor-not-allowed border-2",style:{borderColor:"#C5A059",color:"#800020",backgroundColor:"white"},children:[q?e.jsx(de,{size:13,className:"animate-spin"}):T?e.jsx(Ue,{size:13}):e.jsx(ti,{size:13}),T?"Routine Saved":"Save Routine"]}),T&&e.jsxs("p",{className:"mt-2 text-[10px] text-emerald-700 leading-snug flex items-center gap-1",children:[e.jsx(xt,{size:10})," Your routine is saved under ",e.jsx("span",{className:"font-mono font-semibold",children:A}),"."]})]}),e.jsx("div",{className:"rounded-2xl shadow-xl overflow-hidden border-2",style:{background:"linear-gradient(135deg, #C5A059 0%, #A88A4A 50%, #800020 100%)",borderColor:"#E6D2A0"},children:e.jsxs("div",{className:"p-5 text-white",children:[e.jsxs("div",{className:"flex items-center gap-1.5 mb-2",children:[e.jsx(zo,{size:12,style:{color:"#FFFFFF"},fill:"#FFFFFF"}),e.jsx("span",{className:"text-[10px] font-bold uppercase tracking-[0.18em]",children:"Subscriber Tier · Save 15%"})]}),e.jsx("h3",{className:"font-display text-xl font-bold mb-2 leading-tight",children:"Subscribe & Save 15%"}),e.jsxs("p",{className:"text-[12px] text-white/90 leading-relaxed mb-4",children:["Get your full routine delivered every month for"," ",e.jsxs("span",{className:"font-bold text-white",children:["$",(ge/100).toFixed(2)]})," ","â that's"," ",e.jsxs("span",{className:"font-bold text-white",children:["$",(Ne/100).toFixed(2)," / day"]}),". Cancel or modify anytime."]}),te&&e.jsx("div",{className:"mb-3 px-2.5 py-1.5 rounded-md border border-red-300/40",style:{background:"rgba(220,38,38,0.18)"},children:e.jsxs("p",{className:"text-[10px] text-red-100 leading-snug font-semibold flex items-start gap-1.5",children:[e.jsx(ve,{size:11,className:"shrink-0 mt-0.5"}),te]})}),e.jsxs("button",{onClick:Ht,disabled:!mt||Fe,className:"w-full px-4 py-3 rounded-xl text-sm font-bold uppercase tracking-wider transition-all flex items-center justify-center gap-2 disabled:opacity-50 disabled:cursor-not-allowed shadow-lg hover:shadow-2xl",style:{background:"linear-gradient(135deg, #FFFFFF 0%, #F5E9CC 100%)",color:"#800020"},children:[Fe?e.jsx(de,{size:14,className:"animate-spin"}):e.jsx(Yx,{size:14}),"Subscribe & Save 15%",e.jsx(Vt,{size:14})]}),e.jsxs("p",{className:"text-center text-[10px] text-white/70 mt-2 flex items-center justify-center gap-1",children:[e.jsx(Xe,{size:9})," Secured by FamousPay · Stripe-powered"]})]})}),e.jsx("div",{className:"bg-white/60 backdrop-blur rounded-xl border border-gray-200 p-3",children:e.jsxs("p",{className:"text-[10px] text-gray-500 leading-relaxed",children:[e.jsx("span",{className:"font-bold",style:{color:"#800020"},children:"How it works:"})," ","Pick one product per step for your AM and PM rituals. We'll save it to your account so you can return anytime â and Subscribers save 15% on monthly auto-delivery of the full set."]})})]})})]}),V&&e.jsx(bhe,{step:gF[V],candidates:Oe,onSelect:ae,onClose:()=>B(null),currentSelectionId:wt[V],period:E}),X==="setup-payment"&&K&&Y&&e.jsx(vhe,{clientSecret:K,customerId:Y,email:A,routineId:T,discountedAmountCents:ge,originalAmountCents:He,productNames:Array.from(we).map(_e=>{var Se;return(Se=ue.get(_e))==null?void 0:Se.name}).filter(Boolean),onClose:()=>{Q("idle"),se(null)},onSuccess:async _e=>{try{T&&await O.from("customer_routines").update({subscription_status:"active",stripe_subscription_id:_e,stripe_customer_id:Y,updated_at:new Date().toISOString()}).eq("id",T)}
1304catch(Se){console.error("Failed to stamp subscription onto routine:",Se)}Q("success")}}),X==="success"&&e.jsx(whe,{email:A,monthlyTotalCents:ge,dailyCostCents:Ne,onClose:()=>{Q("idle"),se(null)}}),s&&e.jsx(Nhe,{answers:a,setAnswers:r,email:i||A,setEmail:o,name:l||M,setName:c,submitting:u,error:m,onSubmit:ye,onClose:()=>n(!1)})]})},bhe=({step:t,candidates:s,currentSelectionId:n,period:a,onSelect:r,onClose:i})=>e.jsxs("div",{className:"fixed inset-0 z-50 flex items-center justify-center p-4 animate-in fade-in duration-200",children:[e.jsx("div",{className:"absolute inset-0 bg-black/60 backdrop-blur-sm",onClick:i}),e.jsxs("div",{className:"relative bg-white rounded-2xl shadow-2xl max-w-3xl w-full max-h-[85vh] flex flex-col overflow-hidden",children:[e.jsxs("div",{className:"px-5 py-4 flex items-center gap-3 border-b border-gray-100",style:{background:"linear-gradient(135deg, #800020 0%, #5A0018 100%)"},children:[e.jsx("div",{className:"w-10 h-10 rounded-xl flex items-center justify-center",style:{backgroundColor:"rgba(197,160,89,0.95)",color:"#4A0010"},children:t.icon}),e.jsxs("div",{className:"flex-1 text-white",children:[e.jsxs("p",{className:"text-[10px] font-bold uppercase tracking-wider",style:{color:"#E6D2A0"},children:["Step ",t.order," · ",a==="am"?"AM":"PM"," Ritual"]}),e.jsxs("h3",{className:"font-display text-lg font-bold leading-tight",children:["Choose Your ",t.label]})]}),e.jsx("button",{onClick:i,className:"p-2 hover:bg-white/10 rounded-lg text-white",children:e.jsx(Ke,{size:18})})]}),e.jsx("div",{className:"flex-1 overflow-y-auto p-5",children:s.length===0?e.jsxs("div",{className:"text-center py-12 text-gray-500",children:[e.jsx(Yl,{size:36,className:"mx-auto mb-3 text-gray-300"}),e.jsx("p",{className:"text-sm font-semibold",children:"No products available for this step."}),e.jsx("p",{className:"text-xs mt-1",children:"Check back soon â our catalog updates weekly."})]}):e.jsx("div",{className:"grid sm:grid-cols-2 gap-3",children:s.map(o=>{var c;const l=o.id===n;return e.jsx("button",{onClick:()=>r(o.id),className:`text-left bg-white border-2 rounded-xl p-3 transition-all hover:shadow-md hover:-translate-y-0.5 ${l?"border-[#800020] ring-2 ring-[#C5A059]/30":"border-gray-100 hover:border-[#C5A059]/50"}`,children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"w-16 h-16 rounded-lg overflow-hidden shrink-0 border border-gray-200 bg-gradient-to-br from-[#FAF6EE] to-[#EFE4CC]",children:(c=o.images)!=null&&c[0]?e.jsx("img",{src:o.images[0],alt:o.name,className:"w-full h-full object-cover"}):e.jsx("div",{className:"w-full h-full flex items-center justify-center",children:e.jsx(Io,{size:22,className:"text-[#C5A059]"})})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"text-[9px] font-bold uppercase tracking-wider",style:{color:"#800020"},children:o.product_type}),e.jsx("p",{className:"text-sm font-semibold text-gray-900 line-clamp-2 leading-snug",children:o.name}),e.jsxs("div",{className:"flex items-center justify-between mt-1",children:[e.jsxs("p",{className:"text-sm font-bold text-gray-900",children:["$",(o.price/100).toFixed(2)]}),l&&e.jsxs("span",{className:"inline-flex items-center gap-1 px-2 py-0.5 rounded-full text-[9px] font-bold",style:{backgroundColor:"#800020",color:"#E6D2A0"},children:[e.jsx(xt,{size:9})," Selected"]})]})]})]})},o.id)})})})]})]}),vhe=t=>e.jsxs("div",{className:"fixed inset-0 z-50 flex items-center justify-center p-4 animate-in fade-in duration-200",children:[e.jsx("div",{className:"absolute inset-0 bg-black/70 backdrop-blur-sm",onClick:t.onClose}),e.jsxs("div",{className:"relative bg-white rounded-2xl shadow-2xl max-w-md w-full overflow-hidden",children:[e.jsxs("div",{className:"px-5 py-4 flex items-center gap-3",style:{background:"linear-gradient(135deg, #800020 0%, #5A0018 100%)"},children:[e.jsx(Yx,{className:"text-white",size:20}),e.jsxs("div",{className:"flex-1 text-white",children:[e.jsx("p",{className:"text-[10px] font-bold uppercase tracking-wider",style:{color:"#E6D2A0"},children:"Subscriber Tier · 15% Off"}),e.jsx("h3",{className:"font-display text-base font-bold",children:"Confirm Your Subscription"})]}),e.jsx("button",{onClick:t.onClose,className:"p-2 hover:bg-white/10 rounded-lg text-white",children:e.jsx(Ke,{size:18})})]}),e.jsxs("div",{className:"p-5",children:[e.jsxs("div",{className:"bg-[#FAF6EE] rounded-lg p-3 mb-4 space-y-1",children:[e.jsxs("div",{className:"flex justify-between text-xs",children:[e.jsx("span",{className:"text-gray-500",children:"Routine Total"}),e.jsxs("span",{className:"font-mono line-through text-gray-400",children:["$",(t.originalAmountCents/100).toFixed(2)]})]}),e.jsxs("div",{className:"flex justify-between text-xs",style:{color:"#800020"},children:[e.jsx("span",{className:"font-semibold",children:"Subscriber Discount"}),e.jsxs("span",{className:"font-mono font-bold",children:["â$",((t.originalAmountCents-t.discountedAmountCents)/100).toFixed(2)]})]}),e.jsxs("div",{className:"flex justify-between text-sm font-bold pt-1 border-t border-gray-200",children:[e.jsx("span",{children:"Charged Monthly"}),e.jsxs("span",{className:"font-mono",style:{color:"#800020"},children:["$",(t.discountedAmountCents/100).toFixed(2)]})]})]}),e.jsx(wz,{stripe:phe,options:{clientSecret:t.clientSecret,appearance:{theme:"stripe",variables:{colorPrimary:"#800020"}}},children:e.jsx(jhe,{...t})}),e.jsxs("p",{className:"text-[10px] text-gray-400 text-center mt-3 flex items-center justify-center gap-1",children:[e.jsx(Xe,{size:9})," Encrypted by Stripe · You can cancel anytime from your account"]})]})]})]}),jhe=({customerId:t,email:s,routineId:n,discountedAmountCents:a,originalAmountCents:r,productNames:i,onSuccess:o})=>{const l=dhe(),c=ahe(),[u,p]=d.useState(!1),[m,x]=d.useState(null),h=async y=>{if(y.preventDefault(),!l||!c)return;p(!0),x(null);const{error:v,setupIntent:g}=await l.confirmSetup({elements:c,confirmParams:{return_url:window.location.origin+"/routine-builder"},redirect:"if_required"});if(v){x(v.message||"Could not save your card. Please try a different payment method."),p(!1);return}if((g==null?void 0:g.status)!=="succeeded"){x("Card setup did not complete. Please try again."),p(!1);return}try{const{data:N,error:b}=await O.functions.invoke("create-routine-subscription",{body:{action:"activate-subscription",customerId:t,paymentMethodId:g.payment_method,discountedAmountCents:a,originalAmountCents:r,email:s,routineId:n,productNames:i}});if(b||N!=null&&N.error){x((N==null?void 0:N.error)||(b==null?void 0:b.message)||"Failed to activate subscription."),p(!1);return}o(N.subscriptionId)}catch(N){x(N.message||"Could not create subscription.")}finally{p(!1)}};return e.jsxs("form",{onSubmit:h,children:[e.jsx(uhe,{options:{layout:"tabs"}}),m&&e.jsxs("div",{className:"mt-3 flex items-start gap-1.5 px-3 py-2 rounded-lg bg-red-50 border border-red-200",children:[e.jsx(ve,{size:12,className:"text-red-500 shrink-0 mt-0.5"}),e.jsx("p",{className:"text-[11px] text-red-700 leading-snug font-semibold",children:m})]}),e.jsxs("button",{type:"submit",disabled:!l||u,className:"w-full mt-4 py-3 rounded-xl font-bold text-sm flex items-center justify-center gap-2 shadow-lg disabled:opacity-50 disabled:cursor-not-allowed text-white",style:{background:"linear-gradient(135deg, #800020 0%, #5A0018 100%)"},children:[u?e.jsx(de,{size:14,className:"animate-spin"}):e.jsx(xt,{size:14}),u?"Activating subscriptionâ¦":`Start Subscription · $${(a/100).toFixed(2)}/mo`]})]})},whe=({email:t,monthlyTotalCents:s,dailyCostCents:n,onClose:a})=>e.jsxs("div",{className:"fixed inset-0 z-50 flex items-center justify-center p-4 animate-in fade-in duration-200",children:[e.jsx("div",{className:"absolute inset-0 bg-black/70 backdrop-blur-sm",onClick:a}),e.jsxs("div",{className:"relative bg-white rounded-2xl shadow-2xl max-w-md w-full overflow-hidden",children:[e.jsxs("div",{className:"px-5 py-6 text-center text-white",style:{background:"linear-gradient(135deg, #C5A059 0%, #A88A4A 50%, #800020 100%)"},children:[e.jsx("div",{className:"w-16 h-16 rounded-full bg-white/20 backdrop-blur flex items-center justify-center mx-auto mb-3 border-2 border-white/40",children:e.jsx(Ue,{size:32,className:"text-white"})}),e.jsx("h3",{className:"font-display text-2xl font-bold mb-1",children:"Welcome, Subscriber!"}),e.jsx("p",{className:"text-[12px] text-white/85 leading-relaxed",children:"Your monthly Zorganics routine subscription is active."})]}),e.jsxs("div",{className:"p-5 space-y-3",children:[e.jsxs("div",{className:"bg-[#FAF6EE] rounded-lg p-4 space-y-2 text-sm",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Ye,{size:14,className:"text-[#800020]"}),e.jsx("span",{className:"text-xs text-gray-500",children:"Confirmation sent to"}),e.jsx("span",{className:"font-mono font-semibold text-gray-900 truncate",children:t})]}),e.jsxs("div",{className:"flex justify-between pt-2 border-t border-gray-200",children:[e.jsx("span",{className:"text-xs text-gray-500",children:"Billed Monthly"}),e.jsxs("span",{className:"font-mono font-bold",style:{color:"#800020"},children:["$",(s/100).toFixed(2)]})]}),e.jsxs("div",{className:"flex justify-between text-xs",children:[e.jsx("span",{className:"text-gray-500",children:"Effective Daily Cost"}),e.jsxs("span",{className:"font-mono font-semibold",style:{color:"#C5A059"},children:["$",(n/100).toFixed(2),"/day"]})]})]}),e.jsxs("p",{className:"text-[11px] text-gray-500 leading-relaxed text-center",children:["You can pause, modify, or cancel your subscription anytime by emailing"," ",e.jsx("a",{href:"mailto:[email protected]",className:"font-semibold underline",style:{color:"#800020"},children:"[email protected]"}),"."]}),e.jsx("button",{onClick:a,className:"w-full py-3 rounded-xl text-white font-bold text-sm shadow-lg",style:{background:"linear-gradient(135deg, #800020 0%, #5A0018 100%)"},children:"Continue Shopping"})]})]})]}),Nhe=({answers:t,setAnswers:s,email:n,setEmail:a,name:r,setName:i,submitting:o,error:l,onSubmit:c,onClose:u})=>{const p=Bh.filter(x=>t[x.id]).length,m=Math.round(p/Bh.length*100);return e.jsxs("div",{className:"fixed inset-0 z-[60] flex items-center justify-center p-4 animate-in fade-in duration-200",children:[e.jsx("div",{className:"absolute inset-0 bg-black/70 backdrop-blur-sm",onClick:u}),e.jsxs("div",{className:"relative bg-white rounded-2xl shadow-2xl max-w-2xl w-full max-h-[90vh] flex flex-col overflow-hidden",children:[e.jsxs("div",{className:"px-5 py-4 flex items-center gap-3 text-white relative overflow-hidden",style:{background:"linear-gradient(135deg, #800020 0%, #5A0018 50%, #4A0010 100%)"},children:[e.jsx("div",{className:"absolute inset-0 opacity-15 pointer-events-none",style:{backgroundImage:"radial-gradient(circle at 20% 30%, rgba(255,217,138,0.5) 0%, transparent 50%)"}}),e.jsx("div",{className:"relative w-10 h-10 rounded-xl flex items-center justify-center shrink-0",style:{background:"linear-gradient(135deg, #FFD98A 0%, #C5A059 100%)",color:"#4A0010"},children:e.jsx(ux,{size:18})}),e.jsxs("div",{className:"relative flex-1",children:[e.jsx("p",{className:"text-[10px] font-bold uppercase tracking-[0.18em]",style:{color:"#FFD98A"},children:"Find My Routine · 60-second skin quiz"}),e.jsx("h3",{className:"font-display text-lg lg:text-xl font-bold leading-tight",children:"Your Personalized Zorganics Ritual"})]}),e.jsx("button",{onClick:u,className:"relative p-2 hover:bg-white/10 rounded-lg text-white",children:e.jsx(Ke,{size:18})})]}),e.jsx("div",{className:"h-1.5 bg-gray-100 relative overflow-hidden",children:e.jsx("div",{className:"absolute inset-y-0 left-0 transition-all duration-300",style:{width:`${m}%`,background:"linear-gradient(90deg, #C5A059 0%, #800020 100%)"}})}),e.jsxs("div",{className:"flex-1 overflow-y-auto p-5 lg:p-6 space-y-5",children:[Bh.map((x,h)=>e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-baseline gap-2 mb-1",children:[e.jsx("span",{className:"inline-flex items-center justify-center w-6 h-6 rounded-full text-[10px] font-bold shrink-0",style:{backgroundColor:"#FAF6EE",color:"#800020",border:"1.5px solid #C5A059"},children:h+1}),e.jsx("h4",{className:"font-display text-sm lg:text-base font-bold text-gray-900 leading-tight",children:x.prompt})]}),e.jsx("p",{className:"text-[11px] text-gray-500 ml-8 mb-2",children:x.helper}),e.jsx("div",{className:"grid sm:grid-cols-2 gap-2 ml-8",children:x.options.map(y=>{const v=t[x.id]===y.value;return e.jsx("button",{type:"button",onClick:()=>s(g=>({...g,[x.id]:y.value})),className:`text-left px-3 py-2.5 rounded-lg border-2 text-xs font-semibold transition-all ${v?"shadow-md":"border-gray-200 hover:border-[#C5A059]/60 text-gray-700 bg-white"}`,style:v?{background:"linear-gradient(135deg, #FAF6EE 0%, #F5E9CC 100%)",borderColor:"#800020",color:"#4A0010"}:{},children:e.jsxs("span",{className:"flex items-center gap-2",children:[e.jsx("span",{className:`w-3.5 h-3.5 rounded-full border-2 shrink-0 transition-all ${v?"border-[#800020]":"border-gray-300"}`,style:v?{backgroundColor:"#800020",boxShadow:"inset 0 0 0 2px white"}:{}}),e.jsx("span",{className:"leading-tight",children:y.label})]})},y.value)})})]},x.id)),e.jsxs("div",{className:"pt-4 border-t border-gray-100",children:[e.jsxs("div",{className:"flex items-baseline gap-2 mb-2",children:[e.jsx("span",{className:"inline-flex items-center justify-center w-6 h-6 rounded-full text-[10px] font-bold shrink-0",style:{backgroundColor:"#FAF6EE",color:"#800020",border:"1.5px solid #C5A059"},children:e.jsx(Ye,{size:11})}),e.jsx("h4",{className:"font-display text-sm lg:text-base font-bold text-gray-900",children:"Where should we send your routine?"})]}),e.jsx("p",{className:"text-[11px] text-gray-500 ml-8 mb-2",children:"We'll save it to your account and email you skincare tips for your skin type."}),e.jsxs("div",{className:"ml-8 grid sm:grid-cols-2 gap-2",children:[e.jsx("input",{type:"text",value:r,onChange:x=>i(x.target.value),placeholder:"Your name (optional)",className:"px-3 py-2 text-sm border border-gray-200 rounded-lg focus:outline-none focus:ring-2 focus:ring-[#C5A059]/40 focu
1304s:border-[#C5A059]"}),e.jsx("input",{type:"email",value:n,onChange:x=>a(x.target.value),placeholder:"[email protected]",className:"px-3 py-2 text-sm border border-gray-200 rounded-lg focus:outline-none focus:ring-2 focus:ring-[#C5A059]/40 focus:border-[#C5A059]",required:!0})]})]})]}),e.jsxs("div",{className:"border-t border-gray-100 p-5 bg-gradient-to-b from-white to-[#FAF6EE]/50",children:[l&&e.jsxs("div",{className:"mb-3 flex items-start gap-1.5 px-3 py-2 rounded-lg bg-red-50 border border-red-200",children:[e.jsx(ve,{size:12,className:"text-red-500 shrink-0 mt-0.5"}),e.jsx("p",{className:"text-[11px] text-red-700 leading-snug font-semibold",children:l})]}),e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsxs("p",{className:"text-[10px] text-gray-500 leading-tight hidden sm:block",children:[e.jsx(Xe,{size:9,className:"inline mr-0.5"}),"We'll never share your email. Unsubscribe anytime."]}),e.jsxs("button",{type:"button",onClick:c,disabled:o||p<4||!n||!n.includes("@"),className:"px-6 py-3 rounded-xl font-bold text-sm shadow-lg flex items-center gap-2 text-white disabled:opacity-50 disabled:cursor-not-allowed hover:shadow-xl transition-all",style:{background:"linear-gradient(135deg, #800020 0%, #5A0018 100%)"},children:[o?e.jsx(de,{size:14,className:"animate-spin"}):e.jsx(ux,{size:14}),o?"Finding your matchâ¦":"Get My Routine",e.jsx(Vt,{size:14})]})]})]})]})]})},_he=new kq,khe=()=>{const{handle:t=""}=Wo();return e.jsx(sR,{to:t?`/products/${t}`:"/?section=shop",replace:!0})},She=()=>e.jsx(mB,{defaultTheme:"light",children:e.jsx(DW,{children:e.jsx(Cq,{client:_he,children:e.jsxs(YU,{children:[e.jsx(LM,{}),e.jsx(pB,{}),e.jsx(kW,{children:e.jsxs(gW,{children:[e.jsx(ze,{path:"/",element:e.jsx(nn,{})}),e.jsx(ze,{path:"/about-us",element:e.jsx(nn,{})}),e.jsx(ze,{path:"/programs",element:e.jsx(nn,{})}),e.jsx(ze,{path:"/programs/:slug",element:e.jsx(nn,{})}),e.jsx(ze,{path:"/admissions",element:e.jsx(nn,{})}),e.jsx(ze,{path:"/esthetics-program",element:e.jsx(nn,{})}),e.jsx(ze,{path:"/cosmetology-program",element:e.jsx(nn,{})}),e.jsx(ze,{path:"/master-esthetics",element:e.jsx(nn,{})}),e.jsx(ze,{path:"/book-online",element:e.jsx(nn,{})}),e.jsx(ze,{path:"/apply-now",element:e.jsx(nn,{})}),GW.map(t=>e.jsx(ze,{path:t,element:e.jsx(sR,{to:oR[t],replace:!0})},t)),e.jsx(ze,{path:"/student-clinic",element:e.jsx(nn,{})}),e.jsx(ze,{path:"/contact",element:e.jsx(nn,{})}),e.jsx(ze,{path:"/financial-aid",element:e.jsx(Cpe,{})}),e.jsx(ze,{path:"/salon",element:e.jsx(nn,{})}),e.jsx(ze,{path:"/medspa",element:e.jsx(nn,{})}),e.jsx(ze,{path:"/cosmetics",element:e.jsx(nn,{})}),e.jsx(ze,{path:"/wholesale",element:e.jsx(nn,{})}),e.jsx(ze,{path:"/foundation",element:e.jsx(nn,{})}),e.jsx(ze,{path:"/gift-shop",element:e.jsx(nn,{})}),e.jsx(ze,{path:"/scholar",element:e.jsx(GA,{})}),e.jsx(ze,{path:"/scholar/*",element:e.jsx(GA,{})}),e.jsx(ze,{path:"/locations/:slug",element:e.jsx(KX,{})}),e.jsx(ze,{path:"/foundation/donor",element:e.jsx(See,{})}),e.jsx(ze,{path:"/foundation/receipt",element:e.jsx(hte,{})}),e.jsx(ze,{path:"/foundation/receipts/:paymentIntentId",element:e.jsx(dte,{})}),e.jsx(ze,{path:"/wioa-survey/:token",element:e.jsx(DX,{})}),e.jsx(ze,{path:"/verify-transcript",element:e.jsx(RX,{})}),e.jsx(ze,{path:"/faculty/:slug",element:e.jsx(ete,{})}),e.jsx(ze,{path:"/loading-diagnostics",element:e.jsx(fte,{})}),e.jsx(ze,{path:"/auth-debug",element:e.jsx(jse,{})}),e.jsx(ze,{path:"/reset-password",element:e.jsx(uie,{})}),e.jsx(ze,{path:"/staff/reset-password",element:e.jsx(mie,{})}),e.jsx(ze,{path:"/sitemap",element:e.jsx(gie,{})}),e.jsx(ze,{path:"/news",element:e.jsx(bpe,{})}),e.jsx(ze,{path:"/news/:slug",element:e.jsx(vpe,{})}),e.jsx(ze,{path:"/collections/:handle",element:e.jsx(kre,{})}),e.jsx(ze,{path:"/products/:handle",element:e.jsx($re,{})}),e.jsx(ze,{path:"/track-order",element:e.jsx(Joe,{})}),e.jsx(ze,{path:"/product-page/:handle",element:e.jsx(khe,{})}),e.jsx(ze,{path:"/routine-builder",element:e.jsx(np,{children:e.jsx(yhe,{})})}),e.jsx(ze,{path:"/admin-login",element:e.jsx(Nse,{})}),e.jsx(ze,{path:"/admin/salon-bookings",element:e.jsx(ws,{children:e.jsx(Ree,{})})}),e.jsx(ze,{path:"/admin/campus-tours",element:e.jsx(ws,{children:e.jsx(Yee,{})})}),e.jsx(ze,{path:"/admin/vip-waitlist",element:e.jsx(ws,{children:e.jsx(ate,{})})}),e.jsx(ze,{path:"/admin/brand-lines",element:e.jsx(ws,{children:e.jsx(yse,{})})}),e.jsx(ze,{path:"/admin/session-audit",element:e.jsx(ws,{children:e.jsx(Ane,{})})}),e.jsx(ze,{path:"/admin/deployment-audit",element:e.jsx(ws,{children:e.jsx(Wne,{})})}),e.jsx(ze,{path:"/admin/foundation-contrast-audit",element:e.jsx(ws,{children:e.jsx(_ae,{})})}),e.jsx(ze,{path:"/admin/foundation-contrast-audit/preview",element:e.jsx(ws,{children:e.jsx(dae,{})})}),e.jsx(ze,{path:"/admin/elegant-luxury-audit",element:e.jsx(ws,{children:e.jsx(Bae,{})})}),e.jsx(ze,{path:"/admin/product-images",element:e.jsx(ws,{children:e.jsx(ere,{})})}),e.jsx(ze,{path:"/admin/wholesale-partners",element:e.jsx(ws,{children:e.jsx(tre,{})})}),e.jsx(ze,{path:"/admin/policy-clicks-report",element:e.jsx(ws,{children:e.jsx(are,{})})}),e.jsx(ze,{path:"/admin/disclosure-acknowledgements",element:e.jsx(ws,{children:e.jsx(ire,{})})}),e.jsx(ze,{path:"/annual-security-report",element:e.jsx(cre,{})}),e.jsx(ze,{path:"/consumerinformation",element:e.jsx(dre,{})}),e.jsx(ze,{path:"/privacy-policy",element:e.jsx(ure,{})}),e.jsx(ze,{path:"/sms-terms",element:e.jsx(mre,{})}),e.jsx(ze,{path:"/school-catalog",element:e.jsx(fre,{})}),e.jsx(ze,{path:"/disclosures/print",element:e.jsx(RE,{})}),e.jsx(ze,{path:"/disclosures/pdf",element:e.jsx(RE,{})}),e.jsx(ze,{path:"/my-appointments",element:e.jsx(Gre,{})}),e.jsx(ze,{path:"/medspa-intake",element:e.jsx(wie,{})}),e.jsx(ze,{path:"/applicant",element:e.jsx(upe,{})}),e.jsx(ze,{path:"/med-spa/plan/:token",element:e.jsx(jpe,{})}),e.jsx(ze,{path:"/admin/footprint-audit",element:e.jsx(ws,{children:e.jsx(Qre,{})})}),e.jsx(ze,{path:"/admin/ferpa-access-audit",element:e.jsx(ws,{children:e.jsx(Jre,{})})}),e.jsx(ze,{path:"/admin/sis-dashboard",element:e.jsx(ws,{children:e.jsx(die,{})})}),e.jsx(ze,{path:"/admin/payment-health",element:e.jsx(ws,{children:e.jsx($ie,{})})}),e.jsx(ze,{path:"/admin/institute-pay-monitor",element:e.jsx(ws,{children:e.jsx(Koe,{})})}),e.jsx(ze,{path:"/admin/pos-entities",element:e.jsx(ws,{children:e.jsx(ele,{})})}),e.jsx(ze,{path:"/admin/medspa-consultations",element:e.jsx(ws,{children:e.jsx(Dce,{})})}),e.jsx(ze,{path:"/admin/lead-inventory",element:e.jsx(ws,{children:e.jsx(spe,{})})}),e.jsx(ze,{path:"/admin/student-provisioning",element:e.jsx(ws,{children:e.jsx(rpe,{})})}),e.jsx(ze,{path:"*",element:e.jsx(UI,{})})]})})]})})})});WT(document.getElementById("root")).render(e.jsx(She,{}));export{xte as $,Vt as A,oh as B,Ue as C,Yx as D,Do as E,Kt as F,Wy as G,ta as H,YY as I,wz as J,zo as K,de as L,m0 as M,Nr as N,Mpe as O,dhe as P,ahe as Q,cx as R,WY as S,uhe as T,yr as U,UY as V,Je as W,
1304Ke as X,pt as Y,FO as Z,Ee as _,P5 as a,HP as a$,iQ as a0,On as a1,Ma as a2,ms as a3,zt as a4,UK as a5,At as a6,QP as a7,Bo as a8,a9,Di as aA,ti as aB,tn as aC,Ri as aD,va as aE,mn as aF,en as aG,Be as aH,ei as aI,GP as aJ,La as aK,og as aL,Ym as aM,Kx as aN,nE as aO,aE as aP,sxe as aQ,Iee as aR,t5 as aS,xO as aT,Ml as aU,Jx as aV,RP as aW,_a as aX,Hs as aY,gd as aZ,UP as a_,zI as aa,Ss as ab,Xx as ac,Qt as ad,J3 as ae,lx as af,Io as ag,$ as ah,k as ai,Hy as aj,be as ak,kn as al,zK as am,Gt as an,Pm as ao,Zm as ap,_d as aq,Bt as ar,K_ as as,ce as at,kt as au,ve as av,ef as aw,si as ax,Nd as ay,us as az,Jc as b,eu as b$,Vm as b0,Od as b1,QS as b2,KO as b3,Gl as b4,Md as b5,YP as b6,sf as b7,KS as b8,Ey as b9,X_ as bA,YO as bB,wO as bC,Ny as bD,ap as bE,eM as bF,tM as bG,zi as bH,ZO as bI,$O as bJ,fd as bK,vo as bL,XO as bM,XS as bN,qP as bO,IQ as bP,re as bQ,Yie as bR,c2 as bS,Ii as bT,GO as bU,VP as bV,JO as bW,nh as bX,Qie as bY,Xs as bZ,J_ as b_,Ua as ba,e5 as bb,Qx as bc,JP as bd,Uu as be,$b as bf,zn as bg,Zx as bh,hO as bi,DO as bj,vO as bk,IP as bl,Ro as bm,dx as bn,kd as bo,V_ as bp,Bu as bq,tK as br,$i as bs,Cd as bt,LP as bu,yp as bv,$o as bw,Ex as bx,Lb as by,jr as bz,Ye as c,Hhe as c$,em as c0,HO as c1,fO as c2,qO as c3,u0 as c4,OP as c5,u2 as c6,EO as c7,KP as c8,ix as c9,LO as cA,ka as cB,Y_ as cC,sM as cD,Jr as cE,gt as cF,wn as cG,JS as cH,Vhe as cI,rc as cJ,Zhe as cK,JY as cL,_O as cM,Aj as cN,Xoe as cO,Ghe as cP,Eh as cQ,q2 as cR,jY as cS,cxe as cT,tf as cU,Sd as cV,dxe as cW,F3 as cX,Tre as cY,Ere as cZ,KI as c_,zP as ca,W0 as cb,jO as cc,m2 as cd,hxe as ce,Rx as cf,Yl as cg,Zl as ch,wo as ci,Ay as cj,lr as ck,$P as cl,$he as cm,Hi as cn,Sy as co,zhe as cp,Jf as cq,QY as cr,qhe as cs,h0 as ct,Qn as cu,Yhe as cv,ip as cw,Jn as cx,k2 as cy,bo as cz,Ie as d,Xhe as d$,XY as d0,gc as d1,eC as d2,Za as d3,pK as d4,AO as d5,rx as d6,Ehe as d7,qN as d8,PP as d9,ox as dA,GS as dB,zO as dC,ZI as dD,XK as dE,UO as dF,fxe as dG,vxe as dH,bxe as dI,jxe as dJ,xxe as dK,gxe as dL,qre as dM,zre as dN,Whe as dO,_Q as dP,bO as dQ,Ct as dR,_y as dS,uxe as dT,mxe as dU,pxe as dV,QE as dW,_p as dX,Khe as dY,Qhe as dZ,Jhe as d_,ls as da,Mhe as db,II as dc,r1 as dd,WO as de,PI as df,Ohe as dg,Bhe as dh,FK as di,Fx as dj,Fi as dk,In as dl,TK as dm,Uhe as dn,L5 as dp,mQ as dq,tle as dr,p1 as ds,yxe as dt,MY as du,Nxe as dv,sle as dw,wxe as dx,Cy as dy,eK as dz,Ws as e,exe as e0,txe as e1,IO as e2,VO as e3,ZS as e4,Tm as e5,gI as e6,IY as e7,$Y as e8,Lhe as e9,Ihe as ea,EK as eb,dt as f,Mt as g,YS as h,BY as i,e as j,Bi as k,Xe as l,ts as m,_t as n,Qe as o,Sa as p,KY as q,d as r,O as s,qY as t,dc as u,Na as v,Is as w,MK as x,xt as y,Tt as z};
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.