PageSourceSearch

https://fossilsketch.org/_next/static/chunks/7394.3c9fbe443854ef04.js

js fossilsketch.org collected 2026-10-09 00:42:27 UTC 13,580 bytes, 1 lines download raw bytes

1"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[7394],{888:function(e,t,n){var r=n(2322),o=n(2784),a=n(3232),i=n(2589);t.Z=function(e){var t=e.id,n=e.enable,s=e.classroomName,l=e.selectType,c=e.onUpdateSubmodules,u=e.module_id,d=e.readOnly,f=void 0!==d&&d,p=(0,o.useState)(n),h=p[0],m=p[1];(0,o.useEffect)((function(){m(n)}),[n]);var g=i.S.useMutation(["classroom.enableFossils"]).mutate;return(0,r.jsx)(a.r,{checked:h,onChange:function(e){if(!f){var n=e.currentTarget.checked;m(n),"modules"===l&&c&&c(t,n),g({classroomId:s,enabled_id:t,newEnabled:e.currentTarget.checked,selectType:l,module_id:u})}},disabled:f})}},7394:function(e,t,n){n.r(t),n.d(t,{default:function(){return L}});var r=n(865),o=n(6670),a=n(6383),i=n(930),s=n(2322),l=n(2784),c=n(888),u=n(7973),d=n(1552),f=n.n(d),p=n(9834),h=n(2870),m=n(7564),g=n(5117),v=n(50),y=n(61),x=n(8654),b=n(8855),w=n(1232),j=n(7841),N=n(8078),S=n(966),_=n(5078),C=n(9759),Z=n(5413),T=n(6930),E=[{label:"Location",options:["Not Selected","A-Z","Z-A"]},{label:"Age",options:["Not Selected","A-Z","Z-A"]},{label:"Ecology",options:["Not Selected","A-Z","Z-A"]}],k=n(2589),A=n(9454),L=function(e){var t,n=e.fossilType,d=e.readOnly,L=void 0!==d&&d,P=(0,l.useContext)(u.Z),F=(0,l.useState)([]),O=F[0],I=F[1],M=(0,l.useState)({location:[],age:[],ecology:[],imageType:[]}),z=M[0],D=M[1],U=(0,l.useState)(""),W=U[0],J=U[1],K=(0,a.Z)((0,C.c)(W,700),1)[0],R=(0,l.useState)(!1),Y=R[0],X=R[1],q=(0,l.useState)("name"),B=q[0],G=q[1],H=(0,l.useState)((function(){return new Array(4).fill("Not Selected")})),Q=H[0],V=H[1],$=(0,l.useState)(new Array(3).fill("Not Selected")),ee=$[0],te=$[1],ne=(0,l.useState)(!1),re=ne[0],oe=ne[1],ae=n===T.mv?["name","morphotype","location","age","ecology","imageType"]:n===T.zf?["name","location","age","ecology"]:["name","location","age","ecology","imageType"],ie=n===T.zf?["location","age","ecology"]:["location","age","ecology","imageType"],se=k.S.useQuery(["classroom.getContent",{classroomId:null!==(t=P.currentClass)&&void 0!==t?t:"",contentType:n}],{onSuccess:function(e){I(null===e||void 0===e?void 0:e.sortedFossilData),D(null===e||void 0===e?void 0:e.fossilFilterOptions)}}),le=se.isLoading,ce=se.refetch,ue=k.S.useMutation(["classroom.toggleFossilFavorite"]),de=ue.mutate,fe=ue.isLoading,pe=k.S.useMutation(["classroom.deselectAllFossils"],{onSuccess:function(){I((function(e){return e.map((function(e){return(0,o.Z)((0,r.Z)({},e),{enabled:!1})}))})),ce()}}),he=pe.mutate,me=pe.isLoading,ge=k.S.useMutation(["classroom.selectAllFossils"],{onSuccess:function(){I((function(e){return e.map((function(e){return(0,o.Z)((0,r.Z)({},e),{enabled:!0})}))})),ce()}}),ve=ge.mutate,ye=ge.isLoading,xe=me||ye,be=function(e){var t=e.favorited;I((function(n){return n.map((function(n){return n.id===e.id?(0,o.Z)((0,r.Z)({},n),{favorited:!t}):n}))})),de({fossilId:e.id,fossilType:n},{onError:function(){I((function(n){return n.map((function(n){return n.id===e.id?(0,o.Z)((0,r.Z)({},n),{favorited:t}):n}))}))}})},we=(0,l.useMemo)((function(){var e,t=function(e,t){var n=(0,a.Z)(t,3),r=n[0],o=n[1],i=n[2];return"Not Selected"===r&&"Not Selected"===o&&"Not Selected"===i?e:e.slice().sort((function(e,t){if("Not Selected"!==r){if(e.location<t.location)return"A-Z"===r?-1:1;if(e.location>t.location)return"A-Z"===r?1:-1}if("Not Selected"!==o){if(e.age<t.age)return"A-Z"===o?-1:1;if(e.age>t.age)return"A-Z"===o?1:-1}if("Not Selected"!==i){if(e.ecology<t.ecology)return"A-Z"===i?-1:1;if(e.ecology>t.ecology)return"A-Z"===i?1:-1}return 0}))}(O,ee);return e=Q,t=function(e,t,n){return e.filter((function(e){return e[n].toLowerCase().trim().includes(t.toLowerCase().trim())}))}(t=t.filter((function(t){return ie.map((function(n,r){var o,a,i=null!==(o=e[r])&&void 0!==o?o:"Not Selected";return"Not Selected"===i||(null!==(a=t[n])&&void 0!==a?a:"").toLowerCase().trim()===i})).every(Boolean)})),K,B),re&&(t=t.filter((function(e){return e.favorited}))),X(!1),t}),[O,ee,Q,K,B,re]);return(0,l.useEffect)((function(){V(new Array(ie.length).fill("Not Selected"))}),[n]),(0,l.useEffect)((function(){X(le||K!==W)}),[le,K,Q,ee,W]),(0,s.jsxs)(v.r,{className:f().grid,children:[(0,s.jsx)(v.r.Col,{span:3,children:(0,s.jsxs)("div",{className:f().search_filter_container,children:[(0,s.jsxs)("div",{className:f().search_container,children:[(0,s.jsx)(g.x,{className:f().search_filter_label,children:"Search"}),(0,s.jsx)(y.o,{value:W,onChange:function(e){return J(e.currentTarget.value)}}),(0,s.jsx)(x.Y.Group,{defaultChecked:!0,defaultValue:"name",onChange:function(e){return G(e)},children:ae.map((function(e){return(0,s.jsx)(x.Y,{classNames:{label:f().radio_select_label},value:e,label:e},e)}))})]}),(0,s.jsxs)("div",{className:f().filter_container,children:[(0,s.jsx)(g.x,{className:f().search_filter_label,children:"Filter"}),ie.map((function(e,t){var n;return(0,s.jsx)(b.Ph,{label:"imageType"===e?"image type":e,data:(null===(n=z[e])||void 0===n?void 0:n.length)?z[e]:["Not Selected"],value:Q[t],onChange:function(e){!function(e,t){var n=(0,i.Z)(Q);n[e]=t,V(n)}(t,e)},classNames:{label:f().radio_select_label}},e)})),(0,s.jsxs)(w.Z,{grow:!0,mt:"lg",children:[(0,s.jsx)(j.z,{className:f().bulk_select_button,onClick:function(){P.currentClass&&!L&&ve({classroomId:P.currentClass,contentType:n})},disabled:L||!P.currentClass||xe,loading:ye,children:"Select all"}),(0,s.jsx)(j.z,{className:f().deselect_all_button,onClick:function(){P.currentClass&&!L&&he({classroomId:P.currentClass,contentType:n})},disabled:L||!P.currentClass||xe,loading:me,children:"Deselect all"})]}),(0,s.jsx)(N.X,{mt:"md",label:"Favorites only",checked:re,onChange:function(e){return oe(e.currentTarget.checked)},classNames:{label:f().radio_select_label}})]})]})}),(0,s.jsx)(v.r.Col,{span:9,children:(0,s.jsxs)(m.K,{children:[(0,s.jsxs)(v.r,{children:[(0,s.jsx)(v.r.Col,{span:3,children:(0,s.jsx)("div",{className:f().sort_label,children:(0,s.jsx)(g.x,{children:"SORT BY"})})}),E.map((function(e,t){return(0,s.jsx)(v.r.Col,{span:3,children:(0,s.jsxs)("div",{children:[(0,s.jsxs)(g.x,{style:{color:"white"},children:[e.label,": "]}),(0,s.jsx)(b.Ph,{data:e.options,value:ee[t],onChange:function(e){return function(e,t){var n=(0,i.Z)(ee);n[e]=t,te(n)}(t,e)}})]})},t)}))]}),(0,s.jsx)("div",{className:f().table_container,children:Y?(0,s.jsx)("div",{className:f().loader_container,children:(0,s.jsx)(S.a,{})}):(0,s.jsx)(_.i,{className:f().table,children:(0,s.jsx)("tbody",{children:function(e){var t;return e.map((function(e,r){return(0,s.jsxs)("tr",{style:{height:"120px",backgroundColor:"rgba(0, 0, 0, 0.2)"},children:[(0,s.jsx)("td",{style:{width:"60px"},children:(0,s.jsx)("div",{className:f().select_component_switch,children:(0,s.jsx)(c.Z,{enable:e.enabled,id:e.id,classroomName:P.currentClass,selectType:n,readOnly:L})})}),(0,s.jsx)("td",{style:{width:"48px",textAlign:"center"},children:(0,s.jsx)(p.A,{variant:"transparent",title:e.favorited?"Remove from favorites":"Add to favorites",onClick:function(){return be(e)},disabled:fe,className:f().favorite_button,children:(0,s.jsx)(Z.Z,{size:22,fill:e.favorited?"#f5c518":"transparent",color:e.favorited?"#f5c518":"#c8f7f7"})})}),(0,s.jsx)("td",{style:{width:"160px"},children:(0,s.jsx)(h.E,{width:140,height:80,src:null!==(t=(0,A.Kk)(e.imagePath,n))&&void 0!==t?t:"",alt:e.imagePath})}),n===T.mv&&(0,s.jsx)("td",{style:{fontSize:"large",textAlign:"left"},children:e.morphotype}),(0,s.jsx)("td",{style:{fontSize:"large",textAlign:"left"},children:"".concat(e.name).trim()}),(0,s.jsx)("td",{style:{fontSize:"medium",textAlign:"left"},children:(0,s.jsx)(m.K,{children:ie.map((function(t){var n,r=null!==(n=e[t])&&void 0!==n?n:"",o="imageType"===t?"IMAGE TYPE":t.toUpperCase();return(0,s.jsxs)(g.x,{children:[(0,s.jsxs)("span",{style:{color:"#33bbbb"},children:[o,": "]})," ",(0,s.jsx)("span",{style:{color:r?"":"yellow"},children:r?r.length<28?r:r.slice(0,28).concat(".."):"----"})]},t)}))})})]},r)}))}(we)})})})]})})]})}},9454:function(e,t,n){n.d(t,{DE:function(){return v},Ix:function(){return l},JF:function(){return p},Kk:function(){return y},NO:function(){return d},a9:function(){return g},ao:function(){return h},h0:function(){return i},yk:function(){return x}});var r=n(8788),o=n(2838),a=n(2970);function i(e,t,n){return s.apply(this,arguments)}function s(){return(s=(0,r.Z)((function(e,t,n){return(0,a.__generator)(this,(function(r){return(0,o.Z)(e,File)?[2,new Promise((function(r,o){var a=new FormData;a.append("image",e),a.append("fossilType",t);var i=new XMLHttpRequest;i.upload.addEventListener("progress",(function(e){if(e.lengthComputable){var t=Math.round(e.loaded/e.total*100);n({percentage:t,status:"uploading"})}})),i.addEventListener("load",(function(){if(i.status>=200&&i.status<300)try{var e=JSON.parse(i.responseText);e.imagePath?(n({percentage:100,status:"success"}),r(e.imagePath)):(n({percentage:100,status:"error",error:"No image path in response"}),o(new Error("No image path in response")))}catch(t){n({percentage:100,status:"error",error:"Failed to parse response"}),o(new Error("Failed to parse response"))}else n({percentage:100,status:"error",error:"Upload failed: ".concat(i.status)}),o(new Error("Upload failed with status ".concat(i.status)))})),i.addEventListener("error",(function(){n({percentage:0,status:"error",error:"Network error"}),o(new Error("Network error"))})),i.open("POST","/api/uploadImage"),i.send(a)}))]:[2]}))}))).apply(this,arguments)}function l(e,t){return c.apply(this,arguments)}function c(){return(c=(0,r.Z)((function(e,t){var n,r,i,s;return(0,a.__generator)(this,(function(a){switch(a.label){case 0:return(0,o.Z)(e,File)?((n=new FormData).append("image",e),n.append("fossilType",t),i={},[4,fetch("/api/uploadImage",(i.method="POST",i.body=n,i))]):[2];case 1:return[4,(r=a.sent()).json().catch((function(){return{}}))];case 2:if(s=a.sent(),!r.ok)throw new Error("string"===typeof s.error?s.error:"Upload failed (".concat(r.status,")"));if(s.imagePath)return[2,s.imagePath];throw new Error("Server did not return an image path")}}))}))).apply(this,arguments)}function u(){var e=window.location,t=e.hostname,n=e.protocol;return"localhost"===t||"127.0.0.1"===t?"".concat(n,"//").concat(t,":8000/api/uploadImage"):"/api/uploadImage"}function d(e,t){return f.apply(this,arguments)}function f(){return(f=(0,r.Z)((function(e,t){return(0,a.__generator)(this,(function(n){if(!(0,o.Z)(e,File))throw new Error("Invalid file");return[2,new Promise((function(n,r){var o=new FormData;o.append("image",e),o.append("fossilType","3D_models");var a=new XMLHttpRequest;a.withCredentials=!0,a.upload.addEventListener("progress",(function(e){if(e.lengthComputable){var n=Math.min(99,Math.round(e.loaded/e.total*100));null===t||void 0===t||t({percentage:n,status:"uploading"})}})),a.addEventListener("load",(function(){var e={};try{e=JSON.parse(a.responseText||"{}")}catch(i){}if(a.status>=200&&a.status<300&&e.imagePath)return null===t||void 0===t||t({percentage:100,status:"success"}),void n(e.imagePath);var o="string"===typeof e.error?e.error:"Upload failed (".concat(a.status||"network",")");null===t||void 0===t||t({percentage:0,status:"error",error:o}),r(new Error(o))})),a.addEventListener("error",(function(){null===t||void 0===t||t({percentage:0,status:"error",error:"Network error"}),r(new Error("Network error during model upload"))})),a.addEventListener("timeout",(function(){r(new Error("Upload timed out"))})),a.open("POST",u()),a.timeout=6e5,null===t||void 0===t||t({percentage:0,status:"uploading"}),a.send(o)}))]}))}))).apply(this,arguments)}function p(e,t){if(!(null===e||void 0===e?void 0:e.trim()))return null;
1var n=e.trim(),r=n.startsWith("{")||/sketchfab\.com/i.test(n);if(!r&&/\.(glb|gltf)$/i.test(n))return/^https?:\/\//i.test(n)||n.startsWith("/")?n:g(n.startsWith("/")?n.slice(1):n);if(null===t||void 0===t?void 0:t.trim()){var o=t.toLowerCase().replace(/^fossil\s+/,"").trim(),a="trifarina"===o?"trifarina_angulosa":o.replace(/ /g,"_");return"https://storage.googleapis.com/fossilsketch/3D_models/".concat(a,".glb")}return null}function h(e,t){return m.apply(this,arguments)}function m(){return(m=(0,r.Z)((function(e,t){var n;return(0,a.__generator)(this,(function(r){switch(r.label){case 0:return""===e?[3,2]:(n={},[4,fetch("/api/deleteImage",(n.method="POST",n.headers={"Content-Type":"application/json"},n.body=JSON.stringify({fileName:e,fossilType:t.toLowerCase()}),n)).then((function(e){return e.json()}))]);case 1:r.sent(),r.label=2;case 2:return[2]}}))}))).apply(this,arguments)}function g(e){if(e.startsWith("http"))return e;return"https://storage.googleapis.com/".concat("fossilsketch","/").concat(e.startsWith("/")?e.substring(1):e)}function v(e){var t=e.toLowerCase();return"foraminifera"===t||"forams"===t||"morphotype"===t||"morphotypes"===t?"foraminifera":"ostracoda"===t?"ostracoda":t}function y(e,t){if(!(null===e||void 0===e?void 0:e.trim()))return null;var n=e.trim();if(/^https?:\/\//i.test(n))return n;if(n.startsWith("/api/uploads/"))return n;var r=v(t),o=n.replaceAll(" ","");return o.includes("/")||(o="".concat(r,"/").concat(o)),"localhost"===window.location.hostname||"127.0.0.1"===window.location.hostname?"/api/uploads/".concat(o):g(o)}function x(e){return b.apply(this,arguments)}function b(){return(b=(0,r.Z)((function(e){var t,n;return(0,a.__generator)(this,(function(r){switch(r.label){case 0:return""===e?[3,2]:(n={},[4,fetch("/api/fetchImageNames",(n.method="POST",n.headers={"Content-Type":"application/json"},n.body=JSON.stringify({folderName:e}),n)).then((function(e){return e.json()}))]);case 1:return(t=r.sent()).imagePaths?[2,t.imagePaths]:[2,[]];case 2:return[2]}}
1))}))).apply(this,arguments)}}}]);

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