@tracktor/shared-module 2.11.0 → 2.11.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +2 -2
- package/dist/main.js +1 -1
- package/dist/main.umd.cjs +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
package/dist/main.js
CHANGED
|
@@ -874,7 +874,7 @@ const k = ht({}), Lt = ({ children: t, apiURL: n, libraries: o, localStorageKeys
|
|
|
874
874
|
};
|
|
875
875
|
}, Ct = ({ library: t, date: n, format: o = "ll" }) => t(n).format(o), bt = (t, n) => {
|
|
876
876
|
const { fractionDigits: o = 0, metric: i = "km" } = n || {}, a = Number(t);
|
|
877
|
-
return Number.isNaN(a) ? `0
|
|
877
|
+
return Number.isNaN(a) ? `0${i}` : `${a.toFixed(o)}${i}`;
|
|
878
878
|
}, Pt = (t) => !t || typeof t != "string" ? "" : t.replace(/_/g, " ").toLowerCase().split(" ").map((o) => o.length > 0 ? o.charAt(0).toUpperCase() + o.slice(1) : o).join(" "), jt = (t) => t != null && t.startsWith("/") ? t != null && t.startsWith("/files") ? t : `/files${t}` : t != null && t.startsWith("files") ? `/${t}` : `/files/${t}`, Ot = ({ path: t, size: n, apiURL: o }) => {
|
|
879
879
|
if (!t)
|
|
880
880
|
return "";
|
package/dist/main.umd.cjs
CHANGED
|
@@ -22,4 +22,4 @@
|
|
|
22
22
|
|
|
23
23
|
Check the render method of \``+e+"`."}return""}}function Nt(e){return""}var Ne={};function Yt(e){{var r=Le();if(!r){var c=typeof e=="string"?e:e.displayName||e.name;c&&(r=`
|
|
24
24
|
|
|
25
|
-
Check the top-level render call using <`+c+">.")}return r}}function Ye(e,r){{if(!e._store||e._store.validated||e.key!=null)return;e._store.validated=!0;var c=Yt(r);if(Ne[c])return;Ne[c]=!0;var v="";e&&e._owner&&e._owner!==ue.current&&(v=" It was passed a child from "+z(e._owner.type)+"."),U(e),_('Each child in a list should have a unique "key" prop.%s%s See https://reactjs.org/link/warning-keys for more information.',c,v),U(null)}}function We(e,r){{if(typeof e!="object")return;if(ce(e))for(var c=0;c<e.length;c++){var v=e[c];fe(v)&&Ye(v,r)}else if(fe(e))e._store&&(e._store.validated=!0);else if(e){var w=T(e);if(typeof w=="function"&&w!==e.entries)for(var S=w.call(e),R;!(R=S.next()).done;)fe(R.value)&&Ye(R.value,r)}}}function Wt(e){{var r=e.type;if(r==null||typeof r=="string")return;var c;if(typeof r=="function")c=r.propTypes;else if(typeof r=="object"&&(r.$$typeof===u||r.$$typeof===P))c=r.propTypes;else return;if(c){var v=z(r);bt(c,e.props,"prop",v,e)}else if(r.PropTypes!==void 0&&!le){le=!0;var w=z(r);_("Component %s declared `PropTypes` instead of `propTypes`. Did you misspell the property assignment?",w||"Unknown")}typeof r.getDefaultProps=="function"&&!r.getDefaultProps.isReactClassApproved&&_("getDefaultProps is only used on classic React.createClass definitions. Use a static property named `defaultProps` instead.")}}function zt(e){{for(var r=Object.keys(e.props),c=0;c<r.length;c++){var v=r[c];if(v!=="children"&&v!=="key"){U(e),_("Invalid prop `%s` supplied to `React.Fragment`. React.Fragment can only have `key` and `children` props.",v),U(null);break}}e.ref!==null&&(U(e),_("Invalid attribute `ref` supplied to `React.Fragment`."),U(null))}}function ze(e,r,c,v,w,S){{var R=X(e);if(!R){var m="";(e===void 0||typeof e=="object"&&e!==null&&Object.keys(e).length===0)&&(m+=" You likely forgot to export your component from the file it's defined in, or you might have mixed up default and named imports.");var I=Nt();I?m+=I:m+=Le();var O;e===null?O="null":ce(e)?O="array":e!==void 0&&e.$$typeof===n?(O="<"+(z(e.type)||"Unknown")+" />",m=" Did you accidentally export a JSX literal instead of a component?"):O=typeof e,_("React.jsx: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: %s.%s",O,m)}var A=Lt(e,r,c,w,S);if(A==null)return A;if(R){var F=r.children;if(F!==void 0)if(v)if(ce(F)){for(var G=0;G<F.length;G++)We(F[G],e);Object.freeze&&Object.freeze(F)}else _("React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead.");else We(F,e)}return e===i?zt(A):Wt(A),A}}function Vt(e,r,c){return ze(e,r,c,!0)}function Mt(e,r,c){return ze(e,r,c,!1)}var Ut=Mt,Gt=Vt;K.Fragment=i,K.jsx=Ut,K.jsxs=Gt}()),K}process.env.NODE_ENV==="production"?re.exports=Me():re.exports=Ue();var W=re.exports;const D=h.createContext({}),Ge=({children:t,apiURL:n,libraries:a,localStorageKeys:i})=>{const o=h.useMemo(()=>({apiURL:n,libraries:a,localStorageKeys:i}),[n,a,i]);return W.jsx(D.Provider,{value:o,children:t})},Je="user",Ke=({Fallback:t,isLogged:n,loginPath:a="/login",redirect401Path:i="/login",...o})=>{var k,L,N,Y;const{libraries:l,localStorageKeys:f}=h.useContext(D),d=(o==null?void 0:o.reactRouter)||(l==null?void 0:l.reactRouter),u=(o==null?void 0:o.axios)||(l==null?void 0:l.axios),E=(o==null?void 0:o.localStorageKey)||(f==null?void 0:f.user)||Je;if(!d)throw new Error("React Router is not provided. You can provide it with InjectDependenciesProvider or directly in props.");const[g,P]=h.useState(null),{useLocation:j,Navigate:s,Outlet:b}=d,C=j(),T=h.useRef(!1),y=typeof n=="function"?n():!!n,_=typeof y=="boolean"?y:y==null?void 0:y.isLogged;return h.useEffect(()=>{T.current||(T.current=!0,u.interceptors.response.use(x=>x,async x=>{var X;return typeof x=="object"&&x&&"response"in x&&x.response&&typeof x.response=="object"&&"status"in x.response&&x.response&&typeof x.response=="object"&&"status"in x.response&&((X=x==null?void 0:x.response)==null?void 0:X.status)===401&&(u.defaults.headers.common.Authorization=null,typeof window<"u"&&window.localStorage&&localStorage.removeItem(E),P(i)),Promise.reject(x)}))},[u.defaults.headers.common,u.interceptors.response,E,i]),_&&!g?W.jsx(h.Suspense,{fallback:t,children:(L=(k=C.state)==null?void 0:k.from)!=null&&L.state&&((Y=(N=C.state)==null?void 0:N.from)==null?void 0:Y.pathname)===a?W.jsx(s,{to:C.state.from.state.from.pathname+C.state.from.state.from.search,replace:!0}):W.jsx(b,{})}):W.jsx(s,{to:a+C.search,state:{from:C},replace:!0})},Qe=({data:t,...n})=>{const{libraries:a}=h.useContext(D),i=(n==null?void 0:n.reactRouter)||(a==null?void 0:a.reactRouter),o=(n==null?void 0:n.gtm)||(a==null?void 0:a.gtm);if(!i)throw new Error("React Router is not provided. You can provide it with InjectDependenciesProvider or directly in props of GTMSendPageView.");if(!o)throw new Error("GTM is not provided. You can provide it with InjectDependenciesProvider or directly in props of GTMSendPageView.");const{useGoogleTagManager:l}=o,{useLocation:f,Outlet:d}=i,{pathname:u}=f(),{sendEvent:E}=l();return h.useEffect(()=>{E({event:"pageView",pathname:u,...t})},[t,u,E]),W.jsx(d,{})},Be="user",He=({tokenTypeKey:t="tokenType",tokenKey:n="accessToken",postContentType:a="application/json",...i})=>{const{apiURL:o=i.apiURL,libraries:l,localStorageKeys:f}=h.useContext(D),d=(i==null?void 0:i.userLocalStorageKey)||(f==null?void 0:f.user)||Be,u=(i==null?void 0:i.axios)||(l==null?void 0:l.axios);if(!u)throw new Error("Axios is not provided. You can provide it with InjectDependenciesProvider or directly in props.");if(!(u!=null&&u.defaults))return null;if(typeof window<"u"&&window.localStorage){const E=localStorage.getItem(d),g=E?JSON.parse(E):null,P=g!=null&&g[t]?g[t]:null,j=g!=null&&g[n]?g[n]:null,s=E?`${P} ${j}`:null;s&&(u.defaults.headers.common.Authorization=s)}return u.defaults.baseURL=o,u.defaults.headers.post["Content-Type"]=a,null},Xe=({debug:t,resources:n,...a})=>{const{libraries:i}=h.useContext(D),o=(a==null?void 0:a.i18)||(i==null?void 0:i.i18),{i18next:l,initReactI18next:f,languageDetector:d}=o||{};if(!o)throw new Error("i18 is not provided. You can provide it with InjectDependenciesProvider or directly in props.");return l!=null&&l.isInitialized||(l.use(d).use(f).init({debug:t,fallbackLng:"en",interpolation:{escapeValue:!1},load:"languageOnly",react:{bindI18n:"languageChanged loaded",useSuspense:!0},resources:n,returnNull:!1}).then(()=>{document.documentElement.lang!==l.resolvedLanguage&&l.resolvedLanguage&&document.documentElement.setAttribute("lang",l.resolvedLanguage)}),l.on("languageChanged",u=>{document.documentElement.setAttribute("lang",u)})),null},Ze=({dsn:t,integrations:n,tracesSampleRate:a,replaysSessionSampleRate:i,replaysOnErrorSampleRate:o,tracePropagationTargets:l,ignoreErrors:f,debug:d,environment:u,release:E,...g})=>{const{libraries:P}=h.useContext(D),j=(g==null?void 0:g.sentry)||(P==null?void 0:P.sentry),s=(g==null?void 0:g.reactRouter)||(P==null?void 0:P.reactRouter);if(!j)throw new Error("Sentry is not provided. You can provide it with InjectDependenciesProvider or directly in props.");if(!s)throw new Error("React Router is not provided. You can provide it with InjectDependenciesProvider or directly in props.");if(j.isInitialized())return null;const{createRoutesFromChildren:b,matchRoutes:C,useLocation:T,useNavigationType:y}=s;return(d||process.env.NODE_ENV==="prod"||process.env.NODE_ENV==="production")&&j.init({debug:d,dsn:t,environment:u||"production",ignoreErrors:[...f||[],/dynamically imported module/,/Cannot read properties of undefined \(reading 'default'\)/,/Loading chunk \d+ failed/,/ChunkLoadError/,/Failed to fetch dynamically imported module/,/vite:preloadError/],integrations:[j.reactRouterV6BrowserTracingIntegration({createRoutesFromChildren:b,matchRoutes:C,useEffect:h.useEffect,useLocation:T,useNavigationType:y}),...n||[]],release:E,replaysOnErrorSampleRate:o||1,replaysSessionSampleRate:i||.1,tracePropagationTargets:l,tracesSampleRate:a||1}),null},$e=({IMaskMixin:t,...n})=>{const a=h.useMemo(()=>t(({TextField:i,...o})=>W.jsx(i,{...o})),[t]);return W.jsx(a,{...n})},qe=({language:t,...n})=>{const{libraries:a}=h.useContext(D),i=(n==null?void 0:n.dayjs)||(a==null?void 0:a.dayjs),o=(n==null?void 0:n.plugin)||(a==null?void 0:a.dayjsPlugin);if(!i)throw new Error("Dayjs is not provided. You can provide it with InjectDependenciesProvider or directly in props of InitializeDaysJSConfig.");return h.useEffect(()=>{(async()=>{var d;const f=t||((d=navigator.language)==null?void 0:d.slice(0,2))||"en";o&&o.forEach(u=>{u&&i.extend(u)}),await import("dayjs/locale/en"),await import("dayjs/locale/fr"),i.locale(f)})().then()},[i,o,t]),null},et=()=>(h.useEffect(()=>{const t=n=>{try{n.preventDefault(),n.stopPropagation(),n.stopImmediatePropagation(),window.location.reload()}catch{}};return window.addEventListener("vite:preloadError",t),()=>{window.removeEventListener("vite:preloadError",t)}},[]),null),tt=t=>t&&typeof t=="function",rt=t=>t&&typeof t=="function",nt=({children:t,defaultQueriesOptions:n,defaultMutationsOptions:a,...i})=>{var u,E;const{libraries:o}=h.useContext(D),l=(i==null?void 0:i.QueryClient)||((u=o==null?void 0:o.reactQuery)==null?void 0:u.QueryClient),f=(i==null?void 0:i.QueryClientProvider)||((E=o==null?void 0:o.reactQuery)==null?void 0:E.QueryClientProvider);if(!l)throw new Error("QueryClient is not provided. You can provide it with InjectDependenciesProvider or directly in props.");if(!f)throw new Error("QueryClientProvider is not provided. You can provide it with InjectDependenciesProvider or directly in props.");if(!tt(f))throw new Error("Provided QueryClientProvider dependencies are not valid.");if(!rt(l))throw new Error("Provided QueryClient dependencies are not valid.");const d=new l({defaultOptions:{mutations:{...a},queries:{getNextPageParam:(g,P,j)=>g.length+(j||0),refetchOnWindowFocus:!1,retry:3,...n}}});return W.jsx(f,{client:d,children:t})},at=t=>{var E,g,P;const{libraries:n}=h.useContext(D),a=(t==null?void 0:t.i18)||(n==null?void 0:n.i18),i=((E=t==null?void 0:t.i18)==null?void 0:E.translateFunction)||((g=n==null?void 0:n.i18)==null?void 0:g.translateFunction),o=((P=a==null?void 0:a.i18next)==null?void 0:P.t)||i||(j=>j),{unknownErrorTranslationKey:l="error.unknownError"}=t||{},f=o(l),d=h.useCallback(j=>{var b,C,T,y,_,k,L,N,Y;const{response:s}=j||{};return s!=null&&s.reason?String(s.reason):(b=s==null?void 0:s.data)!=null&&b.reason?String(s.data.reason):(C=s==null?void 0:s.data)!=null&&C.message?String(s.data.message):(y=(T=s==null?void 0:s.data)==null?void 0:T.detail)!=null&&y.length&&Array.isArray((_=s==null?void 0:s.data)==null?void 0:_.detail)&&((L=(k=s==null?void 0:s.data)==null?void 0:k.detail[0])!=null&&L.msg)&&typeof((Y=(N=s==null?void 0:s.data)==null?void 0:N.detail[0])==null?void 0:Y.msg)=="string"?String(s.data.detail[0].msg):f},[f]);return{getErrorCode:h.useCallback(j=>{var b,C,T;const{response:s}=j||{};return s!=null&&s.error_code?String(s==null?void 0:s.error_code):(b=s==null?void 0:s.data)!=null&&b.error_code?String((C=s==null?void 0:s.data)==null?void 0:C.error_code):s!=null&&s.error_code?String(s==null?void 0:s.error_code):(T=s==null?void 0:s.data)!=null&&T.error_code?String(s.data.error_code):"unknown_error_code"},[]),printError:d}},ot=({data:t,fetchNextPage:n,isFetchingNextPage:a,isInitialLoading:i,isLoading:o,enabled:l=!0})=>{const f=h.useCallback(async u=>{a||!l||await n({pageParam:(u==null?void 0:u.pageParam)||u.visibleRowsCount})},[l,n,a]),d=h.useMemo(()=>{if(t)return t.pages.reduce((u,E)=>[...u,...E],[])},[t]);return{fetchNextPageOnRowsScrollEnd:f,isLoading:a||o,loadingVariant:i?"skeleton":"linear",rows:d}},it=t=>{const{libraries:n}=h.useContext(D),a=(t==null?void 0:t.axios)||(n==null?void 0:n.axios),i=(t==null?void 0:t.localStorageKey)||"user";if(!a)throw new Error("Axios is not provided. You can provide it with InjectDependenciesProvider or directly in params of useAuth.");const o=h.useCallback(({tokenType:f,accessToken:d})=>{a.defaults.headers.common.Authorization=`${f} ${d}`},[a.defaults.headers.common]),l=()=>{a.defaults.headers.common.Authorization=null};return h.useEffect(()=>{const f=({newValue:d,key:u})=>{if(u===i&&d)try{const{accessToken:E,tokenType:g}=JSON.parse(d);o({accessToken:E,tokenType:g})}catch(E){console.error("Failed to parse newValue from localStorage:",E)}};return window.addEventListener("storage",f),()=>{window.removeEventListener("storage",f)}},[i,o]),{clearAuthenticationToken:l,setAuthenticationToken:o}},ge=({library:t,date:n,format:a="ll"})=>t(n).format(a),he=(t,n)=>{const{fractionDigits:a=0,metric:i="km"}=n||{},o=Number(t);return Number.isNaN(o)?`0 ${i}`:`${o.toFixed(a)} ${i}`},ye=t=>!t||typeof t!="string"?"":t.replace(/_/g," ").toLowerCase().split(" ").map(a=>a.length>0?a.charAt(0).toUpperCase()+a.slice(1):a).join(" "),ct=t=>t!=null&&t.startsWith("/")?t!=null&&t.startsWith("/files")?t:`/files${t}`:t!=null&&t.startsWith("files")?`/${t}`:`/files/${t}`,st=({path:t,size:n,apiURL:a})=>{if(!t)return"";const i=ct(t),o=`${a}${i}`,l=o.match(/\.(jpeg|jpg|png|gif|bmp|webp|svg|avif)$/)!==null;return typeof n=="number"&&l?`${o.replace("/files",`/thumbs/${n}`)}`:o},ut=t=>{const{apiURL:n,libraries:a}=h.useContext(D),i=(t==null?void 0:t.dayjs)||(a==null?void 0:a.dayjs);return{dateAdapter:(f,d)=>{if(!i)throw new Error("Dayjs is not provided. You can provide it with InjectDependenciesProvider or directly in props.");return ge({date:f,format:d,library:i})},distanceAdapter:he,filePathAdapter:(f,d)=>{if(!n)throw new Error("API URL is not provided. You can provide it with InjectDependenciesProvider or directly in props to filePathAdapter.");return st({apiURL:n,path:f,size:d})},worksiteNameAdapter:ye}},H=(t,n)=>n==="short"?t.split("-")[0]:t,lt=(t,n="full")=>{const[a,i]=h.useState(()=>{const o=(t==null?void 0:t.language)||navigator.language;return t&&"isInitialized"in t&&t.isInitialized,H(o,n)});return h.useEffect(()=>{var l;t&&"isInitialized"in t&&t.isInitialized&&t.language&&i(H(t.language,n));const o=f=>{i(H(f,n))};return(l=t==null?void 0:t.on)==null||l.call(t,"languageChanged",o),()=>{var f;(f=t==null?void 0:t.off)==null||f.call(t,"languageChanged",o)}},[t,n]),a},ft="tracktor.filter",me=(t,n,a)=>`${a}_${t}=>${n}`,dt=t=>{const{libraries:n,localStorageKeys:a}=h.useContext(D),i=(t==null?void 0:t.reactRouter)||(n==null?void 0:n.reactRouter),{useLocation:o,useSearchParams:l}=i,{pathname:f}=o(),[d,u]=l(),E=(a==null?void 0:a.filter)||ft;if(!i)throw new Error("React Router is not provided. You can provide it with InjectDependenciesProvider or directly in props of GTMSendPageView.");const g=(b,C,T=!0)=>{const y=me(b,(t==null?void 0:t.pathname)||f,E);if(!C||Array.isArray(C)&&!C.length){d.delete(b),u(d),localStorage.removeItem(y);return}T&&C&&localStorage.setItem(y,JSON.stringify({...d,[b]:C})),C&&(d.set(b,JSON.stringify(C)),u(d))};return{getFilter:(b,C)=>{const T=d.get(b);if(T)try{return JSON.parse(T)}catch{return T}const y=me(b,(t==null?void 0:t.pathname)||f,E),_=localStorage.getItem(y);if(_)try{return JSON.parse(_)[b]}catch{}return C},getFilters:()=>{const b=Object.fromEntries(d.entries()),T=Object.keys(localStorage).filter(y=>y.startsWith(E)&&y.endsWith((t==null?void 0:t.pathname)||f)).reduce((y,_)=>{var L,N;const k=localStorage.getItem(_);if(k){const Y=JSON.parse(k),x=(L=Object.keys(Y))==null?void 0:L[0];y[x]=(N=Object.values(Y))==null?void 0:N[0]}return y},{});return{...b,...T}},handleFilter:(b,C)=>(T,y)=>{if(y||Array.isArray(y)&&y.length===0){const _=C||"value",k=typeof y=="object"&&_ in y?y[_||"value"]:y;g(b,k);return}g(b,void 0)},setFilter:g}},vt=t=>t.charAt(0).toUpperCase()+t.slice(1).toLowerCase(),gt=t=>{const i=t.split("/").filter(o=>o.length>0).map(o=>o.replace(/\${([^}]*)}/g,"$1").split(/[_-]/).map(u=>u.charAt(0).toUpperCase()+u.slice(1)).join("")).join("");return i.charAt(0).toLowerCase()+i.slice(1)},ht=t=>(t.split("/").pop()||t).replace(/\.json$/,"").replace(/^openapi\./,""),yt=(t,n,a)=>{const i=gt(n),o=vt(a);return`${i}${o}`},mt=t=>{if(t)return(t==null?void 0:t.reduce((n,a)=>(n[a]={query:{useInfinite:!0,useInfiniteQueryParam:"offset",useQuery:!0}},n),{}))||{}},Et=t=>(Array.isArray(t)?t:[t]).reduce((a,i)=>{const{output:o,operationsToGenerateInfiniteQueryHook:l,input:f="./openapi.json"}=i||{},d=ht(f);return{...a,[d]:{hooks:{afterAllFilesWrite:"prettier src/api/ --write"},input:f,output:{baseUrl:o==null?void 0:o.baseUrl,client:"react-query",mode:"tags-split",override:{...(l==null?void 0:l.length)&&{operations:mt(l)},header:u=>["Generated by orval 🍺",...u.title?[u.title]:[],...u.description?[u.description]:[]],mutator:{name:"axiosCustomInstance",path:`${__dirname}/axiosCustomInstance.ts`},operationName:yt,query:{useQuery:!0}},schemas:(o==null?void 0:o.schemas)||`src/api/${d}/model`,target:(o==null?void 0:o.target)||`src/api/${d}/services/api.ts`,...o}}}},{});p.GTMSendPageView=Qe,p.InitializeAxiosConfig=He,p.InitializeDaysJSConfig=qe,p.InitializeI18nConfig=Xe,p.InitializeSentryConfig=Ze,p.InjectDependenciesContext=D,p.InjectDependenciesProvider=Ge,p.MaskTextField=$e,p.PreloadErrorHandler=et,p.QueryClientProviderWithConfig=nt,p.RequireAuth=Ke,p.dateAdapter=ge,p.distanceAdapter=he,p.getOrvalConfig=Et,p.useAdapter=ut,p.useAuth=it,p.useCurrentLanguage=lt,p.useFilters=dt,p.useInfiniteDataGrid=ot,p.useResponseError=at,p.worksiteNameAdapter=ye,Object.defineProperty(p,Symbol.toStringTag,{value:"Module"})});
|
|
25
|
+
Check the top-level render call using <`+c+">.")}return r}}function Ye(e,r){{if(!e._store||e._store.validated||e.key!=null)return;e._store.validated=!0;var c=Yt(r);if(Ne[c])return;Ne[c]=!0;var v="";e&&e._owner&&e._owner!==ue.current&&(v=" It was passed a child from "+z(e._owner.type)+"."),U(e),_('Each child in a list should have a unique "key" prop.%s%s See https://reactjs.org/link/warning-keys for more information.',c,v),U(null)}}function We(e,r){{if(typeof e!="object")return;if(ce(e))for(var c=0;c<e.length;c++){var v=e[c];fe(v)&&Ye(v,r)}else if(fe(e))e._store&&(e._store.validated=!0);else if(e){var w=T(e);if(typeof w=="function"&&w!==e.entries)for(var S=w.call(e),R;!(R=S.next()).done;)fe(R.value)&&Ye(R.value,r)}}}function Wt(e){{var r=e.type;if(r==null||typeof r=="string")return;var c;if(typeof r=="function")c=r.propTypes;else if(typeof r=="object"&&(r.$$typeof===u||r.$$typeof===P))c=r.propTypes;else return;if(c){var v=z(r);bt(c,e.props,"prop",v,e)}else if(r.PropTypes!==void 0&&!le){le=!0;var w=z(r);_("Component %s declared `PropTypes` instead of `propTypes`. Did you misspell the property assignment?",w||"Unknown")}typeof r.getDefaultProps=="function"&&!r.getDefaultProps.isReactClassApproved&&_("getDefaultProps is only used on classic React.createClass definitions. Use a static property named `defaultProps` instead.")}}function zt(e){{for(var r=Object.keys(e.props),c=0;c<r.length;c++){var v=r[c];if(v!=="children"&&v!=="key"){U(e),_("Invalid prop `%s` supplied to `React.Fragment`. React.Fragment can only have `key` and `children` props.",v),U(null);break}}e.ref!==null&&(U(e),_("Invalid attribute `ref` supplied to `React.Fragment`."),U(null))}}function ze(e,r,c,v,w,S){{var R=X(e);if(!R){var m="";(e===void 0||typeof e=="object"&&e!==null&&Object.keys(e).length===0)&&(m+=" You likely forgot to export your component from the file it's defined in, or you might have mixed up default and named imports.");var I=Nt();I?m+=I:m+=Le();var O;e===null?O="null":ce(e)?O="array":e!==void 0&&e.$$typeof===n?(O="<"+(z(e.type)||"Unknown")+" />",m=" Did you accidentally export a JSX literal instead of a component?"):O=typeof e,_("React.jsx: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: %s.%s",O,m)}var A=Lt(e,r,c,w,S);if(A==null)return A;if(R){var F=r.children;if(F!==void 0)if(v)if(ce(F)){for(var G=0;G<F.length;G++)We(F[G],e);Object.freeze&&Object.freeze(F)}else _("React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead.");else We(F,e)}return e===i?zt(A):Wt(A),A}}function Vt(e,r,c){return ze(e,r,c,!0)}function Mt(e,r,c){return ze(e,r,c,!1)}var Ut=Mt,Gt=Vt;K.Fragment=i,K.jsx=Ut,K.jsxs=Gt}()),K}process.env.NODE_ENV==="production"?re.exports=Me():re.exports=Ue();var W=re.exports;const D=h.createContext({}),Ge=({children:t,apiURL:n,libraries:a,localStorageKeys:i})=>{const o=h.useMemo(()=>({apiURL:n,libraries:a,localStorageKeys:i}),[n,a,i]);return W.jsx(D.Provider,{value:o,children:t})},Je="user",Ke=({Fallback:t,isLogged:n,loginPath:a="/login",redirect401Path:i="/login",...o})=>{var k,L,N,Y;const{libraries:l,localStorageKeys:f}=h.useContext(D),d=(o==null?void 0:o.reactRouter)||(l==null?void 0:l.reactRouter),u=(o==null?void 0:o.axios)||(l==null?void 0:l.axios),E=(o==null?void 0:o.localStorageKey)||(f==null?void 0:f.user)||Je;if(!d)throw new Error("React Router is not provided. You can provide it with InjectDependenciesProvider or directly in props.");const[g,P]=h.useState(null),{useLocation:j,Navigate:s,Outlet:b}=d,C=j(),T=h.useRef(!1),y=typeof n=="function"?n():!!n,_=typeof y=="boolean"?y:y==null?void 0:y.isLogged;return h.useEffect(()=>{T.current||(T.current=!0,u.interceptors.response.use(x=>x,async x=>{var X;return typeof x=="object"&&x&&"response"in x&&x.response&&typeof x.response=="object"&&"status"in x.response&&x.response&&typeof x.response=="object"&&"status"in x.response&&((X=x==null?void 0:x.response)==null?void 0:X.status)===401&&(u.defaults.headers.common.Authorization=null,typeof window<"u"&&window.localStorage&&localStorage.removeItem(E),P(i)),Promise.reject(x)}))},[u.defaults.headers.common,u.interceptors.response,E,i]),_&&!g?W.jsx(h.Suspense,{fallback:t,children:(L=(k=C.state)==null?void 0:k.from)!=null&&L.state&&((Y=(N=C.state)==null?void 0:N.from)==null?void 0:Y.pathname)===a?W.jsx(s,{to:C.state.from.state.from.pathname+C.state.from.state.from.search,replace:!0}):W.jsx(b,{})}):W.jsx(s,{to:a+C.search,state:{from:C},replace:!0})},Qe=({data:t,...n})=>{const{libraries:a}=h.useContext(D),i=(n==null?void 0:n.reactRouter)||(a==null?void 0:a.reactRouter),o=(n==null?void 0:n.gtm)||(a==null?void 0:a.gtm);if(!i)throw new Error("React Router is not provided. You can provide it with InjectDependenciesProvider or directly in props of GTMSendPageView.");if(!o)throw new Error("GTM is not provided. You can provide it with InjectDependenciesProvider or directly in props of GTMSendPageView.");const{useGoogleTagManager:l}=o,{useLocation:f,Outlet:d}=i,{pathname:u}=f(),{sendEvent:E}=l();return h.useEffect(()=>{E({event:"pageView",pathname:u,...t})},[t,u,E]),W.jsx(d,{})},Be="user",He=({tokenTypeKey:t="tokenType",tokenKey:n="accessToken",postContentType:a="application/json",...i})=>{const{apiURL:o=i.apiURL,libraries:l,localStorageKeys:f}=h.useContext(D),d=(i==null?void 0:i.userLocalStorageKey)||(f==null?void 0:f.user)||Be,u=(i==null?void 0:i.axios)||(l==null?void 0:l.axios);if(!u)throw new Error("Axios is not provided. You can provide it with InjectDependenciesProvider or directly in props.");if(!(u!=null&&u.defaults))return null;if(typeof window<"u"&&window.localStorage){const E=localStorage.getItem(d),g=E?JSON.parse(E):null,P=g!=null&&g[t]?g[t]:null,j=g!=null&&g[n]?g[n]:null,s=E?`${P} ${j}`:null;s&&(u.defaults.headers.common.Authorization=s)}return u.defaults.baseURL=o,u.defaults.headers.post["Content-Type"]=a,null},Xe=({debug:t,resources:n,...a})=>{const{libraries:i}=h.useContext(D),o=(a==null?void 0:a.i18)||(i==null?void 0:i.i18),{i18next:l,initReactI18next:f,languageDetector:d}=o||{};if(!o)throw new Error("i18 is not provided. You can provide it with InjectDependenciesProvider or directly in props.");return l!=null&&l.isInitialized||(l.use(d).use(f).init({debug:t,fallbackLng:"en",interpolation:{escapeValue:!1},load:"languageOnly",react:{bindI18n:"languageChanged loaded",useSuspense:!0},resources:n,returnNull:!1}).then(()=>{document.documentElement.lang!==l.resolvedLanguage&&l.resolvedLanguage&&document.documentElement.setAttribute("lang",l.resolvedLanguage)}),l.on("languageChanged",u=>{document.documentElement.setAttribute("lang",u)})),null},Ze=({dsn:t,integrations:n,tracesSampleRate:a,replaysSessionSampleRate:i,replaysOnErrorSampleRate:o,tracePropagationTargets:l,ignoreErrors:f,debug:d,environment:u,release:E,...g})=>{const{libraries:P}=h.useContext(D),j=(g==null?void 0:g.sentry)||(P==null?void 0:P.sentry),s=(g==null?void 0:g.reactRouter)||(P==null?void 0:P.reactRouter);if(!j)throw new Error("Sentry is not provided. You can provide it with InjectDependenciesProvider or directly in props.");if(!s)throw new Error("React Router is not provided. You can provide it with InjectDependenciesProvider or directly in props.");if(j.isInitialized())return null;const{createRoutesFromChildren:b,matchRoutes:C,useLocation:T,useNavigationType:y}=s;return(d||process.env.NODE_ENV==="prod"||process.env.NODE_ENV==="production")&&j.init({debug:d,dsn:t,environment:u||"production",ignoreErrors:[...f||[],/dynamically imported module/,/Cannot read properties of undefined \(reading 'default'\)/,/Loading chunk \d+ failed/,/ChunkLoadError/,/Failed to fetch dynamically imported module/,/vite:preloadError/],integrations:[j.reactRouterV6BrowserTracingIntegration({createRoutesFromChildren:b,matchRoutes:C,useEffect:h.useEffect,useLocation:T,useNavigationType:y}),...n||[]],release:E,replaysOnErrorSampleRate:o||1,replaysSessionSampleRate:i||.1,tracePropagationTargets:l,tracesSampleRate:a||1}),null},$e=({IMaskMixin:t,...n})=>{const a=h.useMemo(()=>t(({TextField:i,...o})=>W.jsx(i,{...o})),[t]);return W.jsx(a,{...n})},qe=({language:t,...n})=>{const{libraries:a}=h.useContext(D),i=(n==null?void 0:n.dayjs)||(a==null?void 0:a.dayjs),o=(n==null?void 0:n.plugin)||(a==null?void 0:a.dayjsPlugin);if(!i)throw new Error("Dayjs is not provided. You can provide it with InjectDependenciesProvider or directly in props of InitializeDaysJSConfig.");return h.useEffect(()=>{(async()=>{var d;const f=t||((d=navigator.language)==null?void 0:d.slice(0,2))||"en";o&&o.forEach(u=>{u&&i.extend(u)}),await import("dayjs/locale/en"),await import("dayjs/locale/fr"),i.locale(f)})().then()},[i,o,t]),null},et=()=>(h.useEffect(()=>{const t=n=>{try{n.preventDefault(),n.stopPropagation(),n.stopImmediatePropagation(),window.location.reload()}catch{}};return window.addEventListener("vite:preloadError",t),()=>{window.removeEventListener("vite:preloadError",t)}},[]),null),tt=t=>t&&typeof t=="function",rt=t=>t&&typeof t=="function",nt=({children:t,defaultQueriesOptions:n,defaultMutationsOptions:a,...i})=>{var u,E;const{libraries:o}=h.useContext(D),l=(i==null?void 0:i.QueryClient)||((u=o==null?void 0:o.reactQuery)==null?void 0:u.QueryClient),f=(i==null?void 0:i.QueryClientProvider)||((E=o==null?void 0:o.reactQuery)==null?void 0:E.QueryClientProvider);if(!l)throw new Error("QueryClient is not provided. You can provide it with InjectDependenciesProvider or directly in props.");if(!f)throw new Error("QueryClientProvider is not provided. You can provide it with InjectDependenciesProvider or directly in props.");if(!tt(f))throw new Error("Provided QueryClientProvider dependencies are not valid.");if(!rt(l))throw new Error("Provided QueryClient dependencies are not valid.");const d=new l({defaultOptions:{mutations:{...a},queries:{getNextPageParam:(g,P,j)=>g.length+(j||0),refetchOnWindowFocus:!1,retry:3,...n}}});return W.jsx(f,{client:d,children:t})},at=t=>{var E,g,P;const{libraries:n}=h.useContext(D),a=(t==null?void 0:t.i18)||(n==null?void 0:n.i18),i=((E=t==null?void 0:t.i18)==null?void 0:E.translateFunction)||((g=n==null?void 0:n.i18)==null?void 0:g.translateFunction),o=((P=a==null?void 0:a.i18next)==null?void 0:P.t)||i||(j=>j),{unknownErrorTranslationKey:l="error.unknownError"}=t||{},f=o(l),d=h.useCallback(j=>{var b,C,T,y,_,k,L,N,Y;const{response:s}=j||{};return s!=null&&s.reason?String(s.reason):(b=s==null?void 0:s.data)!=null&&b.reason?String(s.data.reason):(C=s==null?void 0:s.data)!=null&&C.message?String(s.data.message):(y=(T=s==null?void 0:s.data)==null?void 0:T.detail)!=null&&y.length&&Array.isArray((_=s==null?void 0:s.data)==null?void 0:_.detail)&&((L=(k=s==null?void 0:s.data)==null?void 0:k.detail[0])!=null&&L.msg)&&typeof((Y=(N=s==null?void 0:s.data)==null?void 0:N.detail[0])==null?void 0:Y.msg)=="string"?String(s.data.detail[0].msg):f},[f]);return{getErrorCode:h.useCallback(j=>{var b,C,T;const{response:s}=j||{};return s!=null&&s.error_code?String(s==null?void 0:s.error_code):(b=s==null?void 0:s.data)!=null&&b.error_code?String((C=s==null?void 0:s.data)==null?void 0:C.error_code):s!=null&&s.error_code?String(s==null?void 0:s.error_code):(T=s==null?void 0:s.data)!=null&&T.error_code?String(s.data.error_code):"unknown_error_code"},[]),printError:d}},ot=({data:t,fetchNextPage:n,isFetchingNextPage:a,isInitialLoading:i,isLoading:o,enabled:l=!0})=>{const f=h.useCallback(async u=>{a||!l||await n({pageParam:(u==null?void 0:u.pageParam)||u.visibleRowsCount})},[l,n,a]),d=h.useMemo(()=>{if(t)return t.pages.reduce((u,E)=>[...u,...E],[])},[t]);return{fetchNextPageOnRowsScrollEnd:f,isLoading:a||o,loadingVariant:i?"skeleton":"linear",rows:d}},it=t=>{const{libraries:n}=h.useContext(D),a=(t==null?void 0:t.axios)||(n==null?void 0:n.axios),i=(t==null?void 0:t.localStorageKey)||"user";if(!a)throw new Error("Axios is not provided. You can provide it with InjectDependenciesProvider or directly in params of useAuth.");const o=h.useCallback(({tokenType:f,accessToken:d})=>{a.defaults.headers.common.Authorization=`${f} ${d}`},[a.defaults.headers.common]),l=()=>{a.defaults.headers.common.Authorization=null};return h.useEffect(()=>{const f=({newValue:d,key:u})=>{if(u===i&&d)try{const{accessToken:E,tokenType:g}=JSON.parse(d);o({accessToken:E,tokenType:g})}catch(E){console.error("Failed to parse newValue from localStorage:",E)}};return window.addEventListener("storage",f),()=>{window.removeEventListener("storage",f)}},[i,o]),{clearAuthenticationToken:l,setAuthenticationToken:o}},ge=({library:t,date:n,format:a="ll"})=>t(n).format(a),he=(t,n)=>{const{fractionDigits:a=0,metric:i="km"}=n||{},o=Number(t);return Number.isNaN(o)?`0${i}`:`${o.toFixed(a)}${i}`},ye=t=>!t||typeof t!="string"?"":t.replace(/_/g," ").toLowerCase().split(" ").map(a=>a.length>0?a.charAt(0).toUpperCase()+a.slice(1):a).join(" "),ct=t=>t!=null&&t.startsWith("/")?t!=null&&t.startsWith("/files")?t:`/files${t}`:t!=null&&t.startsWith("files")?`/${t}`:`/files/${t}`,st=({path:t,size:n,apiURL:a})=>{if(!t)return"";const i=ct(t),o=`${a}${i}`,l=o.match(/\.(jpeg|jpg|png|gif|bmp|webp|svg|avif)$/)!==null;return typeof n=="number"&&l?`${o.replace("/files",`/thumbs/${n}`)}`:o},ut=t=>{const{apiURL:n,libraries:a}=h.useContext(D),i=(t==null?void 0:t.dayjs)||(a==null?void 0:a.dayjs);return{dateAdapter:(f,d)=>{if(!i)throw new Error("Dayjs is not provided. You can provide it with InjectDependenciesProvider or directly in props.");return ge({date:f,format:d,library:i})},distanceAdapter:he,filePathAdapter:(f,d)=>{if(!n)throw new Error("API URL is not provided. You can provide it with InjectDependenciesProvider or directly in props to filePathAdapter.");return st({apiURL:n,path:f,size:d})},worksiteNameAdapter:ye}},H=(t,n)=>n==="short"?t.split("-")[0]:t,lt=(t,n="full")=>{const[a,i]=h.useState(()=>{const o=(t==null?void 0:t.language)||navigator.language;return t&&"isInitialized"in t&&t.isInitialized,H(o,n)});return h.useEffect(()=>{var l;t&&"isInitialized"in t&&t.isInitialized&&t.language&&i(H(t.language,n));const o=f=>{i(H(f,n))};return(l=t==null?void 0:t.on)==null||l.call(t,"languageChanged",o),()=>{var f;(f=t==null?void 0:t.off)==null||f.call(t,"languageChanged",o)}},[t,n]),a},ft="tracktor.filter",me=(t,n,a)=>`${a}_${t}=>${n}`,dt=t=>{const{libraries:n,localStorageKeys:a}=h.useContext(D),i=(t==null?void 0:t.reactRouter)||(n==null?void 0:n.reactRouter),{useLocation:o,useSearchParams:l}=i,{pathname:f}=o(),[d,u]=l(),E=(a==null?void 0:a.filter)||ft;if(!i)throw new Error("React Router is not provided. You can provide it with InjectDependenciesProvider or directly in props of GTMSendPageView.");const g=(b,C,T=!0)=>{const y=me(b,(t==null?void 0:t.pathname)||f,E);if(!C||Array.isArray(C)&&!C.length){d.delete(b),u(d),localStorage.removeItem(y);return}T&&C&&localStorage.setItem(y,JSON.stringify({...d,[b]:C})),C&&(d.set(b,JSON.stringify(C)),u(d))};return{getFilter:(b,C)=>{const T=d.get(b);if(T)try{return JSON.parse(T)}catch{return T}const y=me(b,(t==null?void 0:t.pathname)||f,E),_=localStorage.getItem(y);if(_)try{return JSON.parse(_)[b]}catch{}return C},getFilters:()=>{const b=Object.fromEntries(d.entries()),T=Object.keys(localStorage).filter(y=>y.startsWith(E)&&y.endsWith((t==null?void 0:t.pathname)||f)).reduce((y,_)=>{var L,N;const k=localStorage.getItem(_);if(k){const Y=JSON.parse(k),x=(L=Object.keys(Y))==null?void 0:L[0];y[x]=(N=Object.values(Y))==null?void 0:N[0]}return y},{});return{...b,...T}},handleFilter:(b,C)=>(T,y)=>{if(y||Array.isArray(y)&&y.length===0){const _=C||"value",k=typeof y=="object"&&_ in y?y[_||"value"]:y;g(b,k);return}g(b,void 0)},setFilter:g}},vt=t=>t.charAt(0).toUpperCase()+t.slice(1).toLowerCase(),gt=t=>{const i=t.split("/").filter(o=>o.length>0).map(o=>o.replace(/\${([^}]*)}/g,"$1").split(/[_-]/).map(u=>u.charAt(0).toUpperCase()+u.slice(1)).join("")).join("");return i.charAt(0).toLowerCase()+i.slice(1)},ht=t=>(t.split("/").pop()||t).replace(/\.json$/,"").replace(/^openapi\./,""),yt=(t,n,a)=>{const i=gt(n),o=vt(a);return`${i}${o}`},mt=t=>{if(t)return(t==null?void 0:t.reduce((n,a)=>(n[a]={query:{useInfinite:!0,useInfiniteQueryParam:"offset",useQuery:!0}},n),{}))||{}},Et=t=>(Array.isArray(t)?t:[t]).reduce((a,i)=>{const{output:o,operationsToGenerateInfiniteQueryHook:l,input:f="./openapi.json"}=i||{},d=ht(f);return{...a,[d]:{hooks:{afterAllFilesWrite:"prettier src/api/ --write"},input:f,output:{baseUrl:o==null?void 0:o.baseUrl,client:"react-query",mode:"tags-split",override:{...(l==null?void 0:l.length)&&{operations:mt(l)},header:u=>["Generated by orval 🍺",...u.title?[u.title]:[],...u.description?[u.description]:[]],mutator:{name:"axiosCustomInstance",path:`${__dirname}/axiosCustomInstance.ts`},operationName:yt,query:{useQuery:!0}},schemas:(o==null?void 0:o.schemas)||`src/api/${d}/model`,target:(o==null?void 0:o.target)||`src/api/${d}/services/api.ts`,...o}}}},{});p.GTMSendPageView=Qe,p.InitializeAxiosConfig=He,p.InitializeDaysJSConfig=qe,p.InitializeI18nConfig=Xe,p.InitializeSentryConfig=Ze,p.InjectDependenciesContext=D,p.InjectDependenciesProvider=Ge,p.MaskTextField=$e,p.PreloadErrorHandler=et,p.QueryClientProviderWithConfig=nt,p.RequireAuth=Ke,p.dateAdapter=ge,p.distanceAdapter=he,p.getOrvalConfig=Et,p.useAdapter=ut,p.useAuth=it,p.useCurrentLanguage=lt,p.useFilters=dt,p.useInfiniteDataGrid=ot,p.useResponseError=at,p.worksiteNameAdapter=ye,Object.defineProperty(p,Symbol.toStringTag,{value:"Module"})});
|