sanity-plugin-taxonomy-manager 4.7.0 → 4.7.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/lib/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("sanity"),t=require("sanity/structure"),n=require("react/jsx-runtime"),i=require("@sanity/icons"),s=require("@sanity/ui"),r=require("react"),o=require("nanoid"),c=require("@sanity/id-utils"),a=require("styled-components"),d=require("react-fast-compare"),l=require("rxjs/operators"),p=require("sanity/router"),h=require("react-icons/ai");function u(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var m=/* @__PURE__ */u(d);function x(e){const t=e?.pattern||"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz",n=e?.length||6;return(e?.prefix||"")+o.customAlphabet(t,n)()}const f=t=>{const{onChange:o,ident:c}=t,a=s.useToast(),d=r.useCallback(()=>{const t=x(c);o(e.set(t)),a.push({status:"success",title:"Identifier created.",closable:!0})},[o,a,c]);/* @__PURE__ */
2
- return n.jsx(s.Stack,{space:2,children:/* @__PURE__ */n.jsx(s.Button,{icon:i.GenerateIcon,mode:"ghost",width:"fill",onClick:d,text:"Generate identifier"})})};f.defaultProps={ident:void 0};var g=Object.defineProperty,b=Object.getOwnPropertySymbols,y=Object.prototype.hasOwnProperty,j=Object.prototype.propertyIsEnumerable,C=(e,t,n)=>t in e?g(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,w=(e,t)=>{for(var n in t||(t={}))y.call(t,n)&&C(e,n,t[n]);if(b)for(var n of b(t))j.call(t,n)&&C(e,n,t[n]);return e};const I={tone:"primary"};function v(e){const{title:t,description:i,icon:r,tone:o,children:c}=w(w({},I),e);/* @__PURE__ */
2
+ return n.jsx(s.Stack,{space:2,children:/* @__PURE__ */n.jsx(s.Button,{icon:i.GenerateIcon,mode:"ghost",width:"fill",onClick:d,text:"Generate identifier"})})};f.defaultProps={ident:void 0};var g=Object.defineProperty,b=Object.getOwnPropertySymbols,y=Object.prototype.hasOwnProperty,j=Object.prototype.propertyIsEnumerable,C=(e,t,n)=>t in e?g(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,I=(e,t)=>{for(var n in t||(t={}))y.call(t,n)&&C(e,n,t[n]);if(b)for(var n of b(t))j.call(t,n)&&C(e,n,t[n]);return e};const w={tone:"primary"};function v(e){const{title:t,description:i,icon:r,tone:o,children:c}=I(I({},w),e);/* @__PURE__ */
3
3
  return n.jsx(s.Card,{tone:o,padding:4,radius:3,border:!0,children:/* @__PURE__ */n.jsxs(s.Flex,{children:[r?"display icon":null,c||/* @__PURE__ */n.jsx(s.Box,{flex:1,children:/* @__PURE__ */n.jsxs(s.Stack,{space:4,children:[t?/* @__PURE__ */n.jsx(s.Text,{weight:"semibold",children:t}):null,i?/* @__PURE__ */n.jsx(s.Text,{size:2,children:i}):null]})})]})})}var k=Object.defineProperty,_=Object.getOwnPropertySymbols,T=Object.prototype.hasOwnProperty,S=Object.prototype.propertyIsEnumerable,V=(e,t,n)=>t in e?k(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,B=(e,t)=>{for(var n in t||(t={}))T.call(t,n)&&V(e,n,t[n]);if(_)for(var n of _(t))S.call(t,n)&&V(e,n,t[n]);return e};a.styled((e={})=>/* @__PURE__ */n.jsx(s.Card,B({as:"table"},e)))(()=>a.css`
4
4
  display: table;
5
5
  width: 100%;
@@ -21,28 +21,28 @@ return n.jsx(s.Card,{tone:o,padding:4,radius:3,border:!0,children:/* @__PURE__ *
21
21
  &:not([hidden]) {
22
22
  display: table-cell;
23
23
  }
24
- `);const N={},E={apiVersion:"v2023-05-01"};function F(e){const t=r.useMemo(()=>JSON.stringify(e||{}),[e]);return r.useMemo(()=>JSON.parse(t),[t])}function P(t,{params:n=N,options:i=E,initialValue:s=null}){const[o,c]=r.useState(!0),[a,d]=r.useState(!1),[p,h]=r.useState(s),u=F(n),x=F(i),f=r.useRef(null),g=e.useDocumentStore();return r.useEffect(()=>{if(t&&!a&&!f.current)try{f.current=g.listenQuery(t,u,x).pipe(l.distinctUntilChanged(m.default),l.catchError(e=>(console.error(e),d(e),c(!1),h(null),e))).subscribe(e=>{h(t=>m.default(t,e)?t:e),c(!1),d(!1)})}catch(e){console.error(e),c(!1),d(e)}return a&&f.current&&f.current.unsubscribe(),()=>{var e;f.current&&(null==(e=f?.current)||e.unsubscribe(),f.current=null)}},[t,a,u,x,g]),{data:p,loading:o,error:a}}const L=r.createContext(null),z=r.createContext({editControls:!1}),O=r.createContext(void 0),H=(e=1)=>{let t="^.^.concepts[]._ref",n=1;for(;e>n;)t=`^.${t}`,n++;return e>6?"":`"childConcepts": *[_id in ${t} && ^._id in broader[]._ref]|order(prefLabel)\n {\n "id": _id,\n "level": ${e},\n _originalId,\n prefLabel,\n definition,\n example,\n scopeNote,\n ${H(e+1)||""}\n }`};var D,M=new Uint8Array(16);function $(){if(!D&&!(D=typeof crypto<"u"&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto)||typeof msCrypto<"u"&&"function"==typeof msCrypto.getRandomValues&&msCrypto.getRandomValues.bind(msCrypto)))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return D(M)}for(var R=/^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000)$/i,A=[],q=0;q<256;++q)A.push((q+256).toString(16).substr(1));function U(e,t,n){var i=(e=e||{}).random||(e.rng||$)();return i[6]=15&i[6]|64,i[8]=63&i[8]|128,function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,n=(A[e[t+0]]+A[e[t+1]]+A[e[t+2]]+A[e[t+3]]+"-"+A[e[t+4]]+A[e[t+5]]+"-"+A[e[t+6]]+A[e[t+7]]+"-"+A[e[t+8]]+A[e[t+9]]+"-"+A[e[t+10]]+A[e[t+11]]+A[e[t+12]]+A[e[t+13]]+A[e[t+14]]+A[e[t+15]]).toLowerCase();if(!function(e){return"string"==typeof e&&R.test(e)}(n))throw TypeError("Stringified UUID is invalid");return n}(i)}let Z;function G(n){const i=s.useToast(),o=e.useClient({apiVersion:"2025-02-19"}),a=function(){const e=r.useContext(p.RouterContext),{routerPanesState:n,groupIndex:i}=t.usePaneRouter();return r.useCallback(t=>{if(!e||!t)return;const s=[...n];s.splice(i+1,i+1,[{id:t,params:{type:"skosConcept"}}]);const r=e.resolvePathFromState({panes:s});e.navigateUrl({path:r})},[e,n,i])}(),d=Z?.ident,l=n.displayed.baseIri;return r.useCallback((t,s)=>{const{id:r,_originalId:p=""}=s||{},h=c.isVersionId(n.displayed._id),u=h?c.getVersionNameFromId(n.displayed._id):void 0,m=h?c.getVersionId(c.DocumentId(n.displayed._id),u):c.getDraftId(c.DocumentId(n.displayed._id)),f=h?c.getVersionId(c.DocumentId(U()),u):c.getDraftId(c.DocumentId(U())),g={_id:f,_type:"skosConcept",conceptId:x(d),prefLabel:"",baseIri:l,broader:[],related:[]};if(r){const t=e.isPublishedId(c.DocumentId(p));g.broader=[{_key:U(),_ref:c.getPublishedId(c.DocumentId(r)),_type:"reference",_weak:!t,_strengthenOnPublish:t?void 0:{type:"skosConcept",template:{id:"skosConcept"}}}]}const b={_ref:c.getPublishedId(f),_type:"reference",_key:U(),_strengthenOnPublish:{type:"skosConcept",template:{id:"skosConcept"}},_weak:!0};o.transaction().createIfNotExists({...n.displayed,_id:m}).create(g).patch(m,e=>"topConcept"===t?e.setIfMissing({topConcepts:[]}).append("topConcepts",[b]):e.setIfMissing({concepts:[]}).append("concepts",[b])).commit({autoGenerateArrayKeys:!0}).then(e=>{i.push({closable:!0,status:"success",title:"Created new concept"}),a(f)}).catch(e=>{i.push({closable:!0,status:"error",title:"Error creating concept",description:e instanceof Error?e.message:"Unknown error occurred"})})},[n.displayed,d,l,o,i,a])}function K(t){const n=s.useToast(),i=e.useClient({apiVersion:"2025-02-19"});return r.useCallback((e,s,r)=>{const o="topConcept"==s?"topConcepts":"concepts",a=c.isVersionId(t.displayed._id),d=a?c.getVersionNameFromId(t.displayed._id):void 0,l=a?c.getVersionId(c.DocumentId(t.displayed._id),d):c.getDraftId(c.DocumentId(t.displayed._id));i.transaction().createIfNotExists({...t.displayed,_id:l}).patch(l,t=>t.unset([`${o}[_ref=="${e}"]`])).commit().then(e=>{n.push({closable:!0,status:"success",title:(r?`"${r}"`:"Concept")+" removed from scheme"})}).catch(e=>{n.push({closable:!0,status:"error",title:"Error removing concept",description:e instanceof Error?e.message:"Unknown error occurred"})})},[i,t.displayed,n])}function W(t){const n=e.useClient({apiVersion:"vX"}),i=e.useDataset(),s=e.useGetFormValue(),[o,c]=r.useState([]),[a,d]=r.useState(null),l=r.useCallback(e=>{const t=[],n=e.map(e=>{const n=s([e]);return"string"==typeof n&&""!==n.trim()?n:(t.push(e),"")});if(1===t.length)throw new Error(`Please fill out the ${t[0]} field to enable match scores.`);if(t.length>1)throw new Error(`The following fields must be filled out to enable match scores: ${t.join(", ")}`);return n.filter(Boolean).join(" ")},[s]),p=r.useCallback(async(e,t,s)=>{const r=await n.request({url:`/embeddings-index/query/${i}/${t}`,method:"POST",body:{query:e,maxResults:s}});c(r)},[n,i]);return{conceptRecs:o,recsError:a,triggerEmbeddingsSearch:r.useCallback(()=>{if(d(null),!t)return;const{indexName:e,fieldReferences:n,maxResults:i=3}=t;try{const t=l(n);p(t,e,i).catch(e=>console.error("Error with embeddings index fetch: ",e))}catch(e){const t=e instanceof Error?e.message:"One or more required fields are empty";d(t)}},[l,t,p])}}const Y=({title:e,message:t})=>/* @__PURE__ */n.jsxs(s.Stack,{space:2,children:[
24
+ `);const F={},N={apiVersion:"v2023-05-01"};function E(e){const t=r.useMemo(()=>JSON.stringify(e||{}),[e]);return r.useMemo(()=>JSON.parse(t),[t])}function P(t,{params:n=F,options:i=N,initialValue:s=null}){const[o,c]=r.useState(!0),[a,d]=r.useState(!1),[p,h]=r.useState(s),u=E(n),x=E(i),f=r.useRef(null),g=e.useDocumentStore();return r.useEffect(()=>{if(t&&!a&&!f.current)try{f.current=g.listenQuery(t,u,x).pipe(l.distinctUntilChanged(m.default),l.catchError(e=>(console.error(e),d(e),c(!1),h(null),e))).subscribe(e=>{h(t=>m.default(t,e)?t:e),c(!1),d(!1)})}catch(e){console.error(e),c(!1),d(e)}return a&&f.current&&f.current.unsubscribe(),()=>{var e;f.current&&(null==(e=f?.current)||e.unsubscribe(),f.current=null)}},[t,a,u,x,g]),{data:p,loading:o,error:a}}const L=r.createContext(null),O=r.createContext({editControls:!1}),z=r.createContext(void 0),H=(e=1)=>{let t="^.^.concepts[]._ref",n=1;for(;e>n;)t=`^.${t}`,n++;return e>6?"":`"childConcepts": *[_id in ${t} && ^._id in broader[]._ref]|order(prefLabel)\n {\n "id": _id,\n "level": ${e},\n _originalId,\n prefLabel,\n definition,\n example,\n scopeNote,\n ${H(e+1)||""}\n }`};var D,M=new Uint8Array(16);function $(){if(!D&&!(D=typeof crypto<"u"&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto)||typeof msCrypto<"u"&&"function"==typeof msCrypto.getRandomValues&&msCrypto.getRandomValues.bind(msCrypto)))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return D(M)}for(var R=/^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000)$/i,A=[],q=0;q<256;++q)A.push((q+256).toString(16).substr(1));function U(e,t,n){var i=(e=e||{}).random||(e.rng||$)();return i[6]=15&i[6]|64,i[8]=63&i[8]|128,function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,n=(A[e[t+0]]+A[e[t+1]]+A[e[t+2]]+A[e[t+3]]+"-"+A[e[t+4]]+A[e[t+5]]+"-"+A[e[t+6]]+A[e[t+7]]+"-"+A[e[t+8]]+A[e[t+9]]+"-"+A[e[t+10]]+A[e[t+11]]+A[e[t+12]]+A[e[t+13]]+A[e[t+14]]+A[e[t+15]]).toLowerCase();if(!function(e){return"string"==typeof e&&R.test(e)}(n))throw TypeError("Stringified UUID is invalid");return n}(i)}let Z;function G(n){const i=s.useToast(),o=e.useClient({apiVersion:"2025-02-19"}),a=function(){const e=r.useContext(p.RouterContext),{routerPanesState:n,groupIndex:i}=t.usePaneRouter();return r.useCallback(t=>{if(!e||!t)return;const s=[...n];s.splice(i+1,i+1,[{id:t,params:{type:"skosConcept"}}]);const r=e.resolvePathFromState({panes:s});e.navigateUrl({path:r})},[e,n,i])}(),d=Z?.ident,l=n.displayed.baseIri;return r.useCallback((t,s)=>{const{id:r,_originalId:p=""}=s||{},h=c.isVersionId(n.displayed._id),u=h?c.getVersionNameFromId(n.displayed._id):void 0,m=h?c.getVersionId(c.DocumentId(n.displayed._id),u):c.getDraftId(c.DocumentId(n.displayed._id)),f=h?c.getVersionId(c.DocumentId(U()),u):c.getDraftId(c.DocumentId(U())),g={_id:f,_type:"skosConcept",conceptId:x(d),prefLabel:"",baseIri:l,broader:[],related:[]};if(r){const t=e.isPublishedId(c.DocumentId(p));g.broader=[{_key:U(),_ref:c.getPublishedId(c.DocumentId(r)),_type:"reference",_weak:!t,_strengthenOnPublish:t?void 0:{type:"skosConcept",template:{id:"skosConcept"}}}]}const b={_ref:c.getPublishedId(f),_type:"reference",_key:U(),_strengthenOnPublish:{type:"skosConcept",template:{id:"skosConcept"}},_weak:!0};o.transaction().createIfNotExists({...n.displayed,_id:m}).create(g).patch(m,e=>"topConcept"===t?e.setIfMissing({topConcepts:[]}).append("topConcepts",[b]):e.setIfMissing({concepts:[]}).append("concepts",[b])).commit({autoGenerateArrayKeys:!0}).then(e=>{i.push({closable:!0,status:"success",title:"Created new concept"}),a(f)}).catch(e=>{i.push({closable:!0,status:"error",title:"Error creating concept",description:e instanceof Error?e.message:"Unknown error occurred"})})},[n.displayed,d,l,o,i,a])}function K(t){const n=s.useToast(),i=e.useClient({apiVersion:"2025-02-19"});return r.useCallback((e,s,r)=>{const o="topConcept"==s?"topConcepts":"concepts",a=c.isVersionId(t.displayed._id),d=a?c.getVersionNameFromId(t.displayed._id):void 0,l=a?c.getVersionId(c.DocumentId(t.displayed._id),d):c.getDraftId(c.DocumentId(t.displayed._id));i.transaction().createIfNotExists({...t.displayed,_id:l}).patch(l,t=>t.unset([`${o}[_ref=="${e}"]`])).commit().then(e=>{n.push({closable:!0,status:"success",title:(r?`"${r}"`:"Concept")+" removed from scheme"})}).catch(e=>{n.push({closable:!0,status:"error",title:"Error removing concept",description:e instanceof Error?e.message:"Unknown error occurred"})})},[i,t.displayed,n])}function W(t){const n=e.useClient({apiVersion:"vX"}),i=e.useDataset(),s=e.useGetFormValue(),[o,c]=r.useState([]),[a,d]=r.useState(null),l=r.useCallback(e=>{const t=[],n=e.map(e=>{const n=s([e]);return"string"==typeof n&&""!==n.trim()?n:(t.push(e),"")});if(1===t.length)throw new Error(`Please fill out the ${t[0]} field to enable match scores.`);if(t.length>1)throw new Error(`The following fields must be filled out to enable match scores: ${t.join(", ")}`);return n.filter(Boolean).join(" ")},[s]),p=r.useCallback(async(e,t,s)=>{const r=await n.request({url:`/embeddings-index/query/${i}/${t}`,method:"POST",body:{query:e,maxResults:s}});c(r)},[n,i]);return{conceptRecs:o,recsError:a,triggerEmbeddingsSearch:r.useCallback(()=>{if(d(null),!t)return;const{indexName:e,fieldReferences:n,maxResults:i=3}=t;try{const t=l(n);p(t,e,i).catch(e=>console.error("Error with embeddings index fetch: ",e))}catch(e){const t=e instanceof Error?e.message:"One or more required fields are empty";d(t)}},[l,t,p])}}const Q=({title:e,message:t})=>/* @__PURE__ */n.jsxs(s.Stack,{space:2,children:[
25
25
  /* @__PURE__ */n.jsx(s.Label,{size:1,children:e}),
26
- /* @__PURE__ */n.jsx(s.Text,{size:2,muted:!0,style:{whiteSpace:"pre-wrap"},children:t})]}),Q=({concept:e})=>{const[t,o]=r.useState(!1),c=r.useCallback(()=>o(!1),[]),a=r.useCallback(()=>o(!0),[]);return e&&(e.definition||e.example||e.scopeNote)?/* @__PURE__ */n.jsxs(n.Fragment,{children:[
27
- /* @__PURE__ */n.jsx(s.Tooltip,{delay:{open:750},content:/* @__PURE__ */n.jsx(s.Box,{padding:1,sizing:"content",children:/* @__PURE__ */n.jsx(s.Text,{muted:!0,size:1,children:"View concept details"})}),fallbackPlacements:["right","left"],placement:"top",portal:!0,children:/* @__PURE__ */n.jsx(s.Button,{icon:i.InfoOutlineIcon,mode:"bleed",onClick:a,tone:"default"})}),t&&/* @__PURE__ */n.jsx(s.Dialog,{header:e.prefLabel,id:"dialog-example",onClose:c,zOffset:1e3,width:1,children:/* @__PURE__ */n.jsx(s.Box,{padding:4,paddingTop:2,paddingBottom:5,children:/* @__PURE__ */n.jsxs(s.Stack,{space:4,children:[e.definition&&/* @__PURE__ */n.jsx(Y,{title:"Definition",message:e.definition}),e.example&&/* @__PURE__ */n.jsx(Y,{title:"Examples",message:e.example}),e.scopeNote&&/* @__PURE__ */n.jsx(Y,{title:"Scope Notes",message:e.scopeNote})]})})})]}):null};function X({concept:e,topConcept:i=!1,orphan:o=!1}){const c=r.useContext(p.RouterContext),{routerPanesState:a,groupIndex:d}=t.usePaneRouter(),{id:l,prefLabel:h}=e??{},u=h||"[new concept]",m=r.useCallback(()=>{if(!c||!l)return;const e=[...a];e.splice(d+1,d+1,[{id:l,params:{type:"skosConcept"}}]);const t=c.resolvePathFromState({panes:e});c.navigateUrl({path:t})},[l,c,a,d]);/* @__PURE__ */
26
+ /* @__PURE__ */n.jsx(s.Text,{size:2,muted:!0,style:{whiteSpace:"pre-wrap"},children:t})]}),Y=({concept:e})=>{const[t,o]=r.useState(!1),c=r.useCallback(()=>o(!1),[]),a=r.useCallback(()=>o(!0),[]);return e&&(e.definition||e.example||e.scopeNote)?/* @__PURE__ */n.jsxs(n.Fragment,{children:[
27
+ /* @__PURE__ */n.jsx(s.Tooltip,{delay:{open:750},content:/* @__PURE__ */n.jsx(s.Box,{padding:1,sizing:"content",children:/* @__PURE__ */n.jsx(s.Text,{muted:!0,size:1,children:"View concept details"})}),fallbackPlacements:["right","left"],placement:"top",portal:!0,children:/* @__PURE__ */n.jsx(s.Button,{icon:i.InfoOutlineIcon,mode:"bleed",onClick:a,tone:"default"})}),t&&/* @__PURE__ */n.jsx(s.Dialog,{header:e.prefLabel,id:"dialog-example",onClose:c,zOffset:1e3,width:1,children:/* @__PURE__ */n.jsx(s.Box,{padding:4,paddingTop:2,paddingBottom:5,children:/* @__PURE__ */n.jsxs(s.Stack,{space:4,children:[e.definition&&/* @__PURE__ */n.jsx(Q,{title:"Definition",message:e.definition}),e.example&&/* @__PURE__ */n.jsx(Q,{title:"Examples",message:e.example}),e.scopeNote&&/* @__PURE__ */n.jsx(Q,{title:"Scope Notes",message:e.scopeNote})]})})})]}):null};function X({concept:e,topConcept:i=!1,orphan:o=!1}){const c=r.useContext(p.RouterContext),{routerPanesState:a,groupIndex:d}=t.usePaneRouter(),{id:l,prefLabel:h}=e??{},u=h||"[new concept]",m=r.useCallback(()=>{if(!c||!l)return;const e=[...a];e.splice(d+1,d+1,[{id:l,params:{type:"skosConcept"}}]);const t=c.resolvePathFromState({panes:e});c.navigateUrl({path:t})},[l,c,a,d]);/* @__PURE__ */
28
28
  return n.jsx(s.Tooltip,{delay:{open:750},content:/* @__PURE__ */n.jsx(s.Box,{padding:1,sizing:"content",children:/* @__PURE__ */n.jsx(s.Text,{muted:!0,size:1,children:`View "${h}"`})}),fallbackPlacements:["right","left"],placement:"top",children:/* @__PURE__ */n.jsx(s.Button,{mode:"bleed",paddingLeft:0,onClick:m,width:"fill",justify:"flex-start",children:/* @__PURE__ */n.jsxs(s.Text,{size:2,weight:i?"bold":"regular",textOverflow:"ellipsis",children:[u,(i||o)&&/* @__PURE__ */n.jsx(s.Badge,{fontSize:0,marginLeft:3,style:{verticalAlign:"middle"},children:i?"top concept":"orphan"})]})})})}const J=({action:e,handler:t})=>{const r={add:{message:"Add a child concept below this concept",icon:i.AddCircleIcon,tone:"positive"},remove:{message:"Remove this concept from this scheme",icon:i.TrashIcon,tone:"critical"}};/* @__PURE__ */
29
29
  return n.jsx(s.Tooltip,{delay:{open:750},content:/* @__PURE__ */n.jsx(s.Box,{padding:1,sizing:"content",children:/* @__PURE__ */n.jsx(s.Text,{muted:!0,size:1,children:r[e].message})}),fallbackPlacements:["right","left"],placement:"top",children:/* @__PURE__ */n.jsx(s.Button,{icon:r[e].icon,mode:"bleed",onClick:t,tone:r[e].tone,"aria-label":"Remove this concept from this scheme"})})};function ee({concept:e,topConcept:t=!1,orphan:i=!1,selectConcept:o}){const{prefLabel:c,id:a,_originalId:d,score:l}=e??{},p=c||"[new concept]",h=r.useCallback(()=>{o&&o({_ref:a,_type:"reference",_originalId:d})},[a,d,o]);/* @__PURE__ */
30
30
  return n.jsx(n.Fragment,{children:o&&/* @__PURE__ */n.jsx(s.Tooltip,{delay:{open:750},content:/* @__PURE__ */n.jsx(s.Box,{padding:1,sizing:"content",children:/* @__PURE__ */n.jsxs(s.Text,{muted:!0,size:1,children:[`Select "${c}"`,l&&` (${(100*l).toFixed(1)}% resource match)`]})}),fallbackPlacements:["right","left","bottom"],placement:"top",portal:!0,children:/* @__PURE__ */n.jsx(s.Button,{mode:"bleed",paddingLeft:0,onClick:h,width:"fill",justify:"flex-start",children:/* @__PURE__ */n.jsxs(s.Text,{size:2,weight:t?"bold":"regular",textOverflow:"ellipsis",children:[p,(t||i)&&/* @__PURE__ */n.jsx(s.Badge,{fontSize:0,marginLeft:3,style:{verticalAlign:"middle"},children:t?"top concept":"orphan"}),l&&/* @__PURE__ */n.jsx(s.Badge,{fontSize:0,marginLeft:3,style:{verticalAlign:"middle"},children:`${(100*l).toFixed(1)}%`})]})})})})}const te=({message:e,title:t,type:o})=>{const[c,a]=r.useState(!1),d=r.useCallback(()=>a(!1),[]),l=r.useCallback(()=>a(!0),[]);/* @__PURE__ */
31
31
  return n.jsxs(n.Fragment,{children:[
32
32
  /* @__PURE__ */n.jsx(s.Tooltip,{delay:{open:750},content:/* @__PURE__ */n.jsx(s.Box,{padding:1,sizing:"content",children:/* @__PURE__ */n.jsx(s.Text,{muted:!0,size:1,children:t})}),fallbackPlacements:["right","left"],placement:"top",portal:!0,children:/* @__PURE__ */n.jsx(s.Button,{icon:"error"==o?i.ErrorOutlineIcon:i.InfoOutlineIcon,mode:"bleed",onClick:l,tone:{info:"default",warn:"caution",error:"critical"}[o]})}),c&&/* @__PURE__ */n.jsx(s.Dialog,{header:t,id:"dialog-example",onClose:d,zOffset:1e3,width:1,children:/* @__PURE__ */n.jsx(s.Box,{padding:4,paddingBottom:5,children:/* @__PURE__ */n.jsx(s.Text,{children:e})})})]})};function ne(e,t){void 0===t&&(t={});var n=t.insertAt;if(e&&!(typeof document>"u")){var i=document.head||document.getElementsByTagName("head")[0],s=document.createElement("style");s.type="text/css","top"===n&&i.firstChild?i.insertBefore(s,i.firstChild):i.appendChild(s),s.styleSheet?s.styleSheet.cssText=e:s.appendChild(document.createTextNode(e))}}function ie({handler:e,visibility:t}){/* @__PURE__ */
33
- return n.jsx(s.Button,{icon:i.ToggleArrowRightIcon,mode:"bleed","aria-expanded":"open"==t,onClick:e,className:"ToggleButton-module_toggleButton__4X-Gs"})}ne(".ToggleButton-module_toggleButton__4X-Gs[aria-expanded='true'] svg {\n rotate: 90deg;\n}\n");const se=({concept:e,selectConcept:t,inputComponent:i=!1})=>{const o=r.useContext(L)||{},c=r.useContext(O),{globalVisibility:{treeVisibility:a}={treeVisibility:"open"}}=r.useContext(z)||{},d=G(o),l=K(o),p=r.useCallback(()=>{d("concept",e)},[e,d]),h=r.useCallback(()=>{l(e.id,"concept",e?.prefLabel)},[e.id,e?.prefLabel,l]),[u,m]=r.useState("closed"===a&&e.hasMatchingDescendant?"open":a||"open"),x=r.useCallback(()=>{"open"==u?m("closed"):"closed"==u&&m("open")},[u]);/* @__PURE__ */
33
+ return n.jsx(s.Button,{icon:i.ToggleArrowRightIcon,mode:"bleed","aria-expanded":"open"==t,onClick:e,className:"ToggleButton-module_toggleButton__4X-Gs"})}ne(".ToggleButton-module_toggleButton__4X-Gs[aria-expanded='true'] svg {\n rotate: 90deg;\n}\n");const se=({concept:e,selectConcept:t,inputComponent:i=!1})=>{const o=r.useContext(L)||{},c=r.useContext(z),{globalVisibility:{treeVisibility:a}={treeVisibility:"open"}}=r.useContext(O)||{},d=G(o),l=K(o),p=r.useCallback(()=>{d("concept",e)},[e,d]),h=r.useCallback(()=>{l(e.id,"concept",e?.prefLabel)},[e.id,e?.prefLabel,l]),[u,m]=r.useState("closed"===a&&e.hasMatchingDescendant?"open":a||"open"),x=r.useCallback(()=>{"open"==u?m("closed"):"closed"==u&&m("open")},[u]);/* @__PURE__ */
34
34
  return n.jsxs(s.Box,{className:u,children:[
35
35
  /* @__PURE__ */n.jsxs(s.Flex,{align:"center",justify:"space-between",wrap:"nowrap",children:[
36
- /* @__PURE__ */n.jsxs(s.Flex,{align:"center",gap:0,flex:1,style:{minWidth:0},children:[e?.childConcepts&&e.childConcepts.length>0&&/* @__PURE__ */n.jsx(ie,{handler:x,visibility:u}),!e?.prefLabel&&/* @__PURE__ */n.jsx(s.Box,{flex:1,marginLeft:e?.childConcepts&&0!=e.childConcepts.length?0:5,children:/* @__PURE__ */n.jsx(X,{concept:e})}),e?.prefLabel&&/* @__PURE__ */n.jsx(s.Box,{flex:1,marginLeft:e?.childConcepts&&0!=e.childConcepts.length?0:5,children:i?/* @__PURE__ */n.jsx(ee,{concept:e,selectConcept:t}):/* @__PURE__ */n.jsx(X,{concept:e})})]}),i&&/* @__PURE__ */n.jsx(Q,{concept:e}),!i&&"published"!==c&&e?.level&&e.level<5&&/* @__PURE__ */n.jsxs(s.Inline,{children:[
36
+ /* @__PURE__ */n.jsxs(s.Flex,{align:"center",gap:0,flex:1,style:{minWidth:0},children:[e?.childConcepts&&e.childConcepts.length>0&&/* @__PURE__ */n.jsx(ie,{handler:x,visibility:u}),!e?.prefLabel&&/* @__PURE__ */n.jsx(s.Box,{flex:1,marginLeft:e?.childConcepts&&0!=e.childConcepts.length?0:5,children:/* @__PURE__ */n.jsx(X,{concept:e})}),e?.prefLabel&&/* @__PURE__ */n.jsx(s.Box,{flex:1,marginLeft:e?.childConcepts&&0!=e.childConcepts.length?0:5,children:i?/* @__PURE__ */n.jsx(ee,{concept:e,selectConcept:t}):/* @__PURE__ */n.jsx(X,{concept:e})})]}),i&&/* @__PURE__ */n.jsx(Y,{concept:e}),!i&&"published"!==c&&e?.level&&e.level<5&&/* @__PURE__ */n.jsxs(s.Inline,{children:[
37
37
  /* @__PURE__ */n.jsx(J,{action:"add",handler:p}),
38
38
  /* @__PURE__ */n.jsx(J,{action:"remove",handler:h})]}),!i&&"published"!==c&&0==e.childConcepts?.length&&5==e.level&&/* @__PURE__ */n.jsxs(s.Inline,{children:[
39
39
  /* @__PURE__ */n.jsx(te,{type:"warn",title:"Taxonomy Manager structure notice",message:"This concept is at the maximum Taxonomy Manager hierarchy depth of 5 levels. Additional child terms are not shown in the hierarchy tree."}),
40
40
  /* @__PURE__ */n.jsx(J,{action:"remove",handler:h})]}),e?.childConcepts&&e?.childConcepts?.length>0&&5==e.level&&/* @__PURE__ */n.jsxs(s.Inline,{children:[
41
41
  /* @__PURE__ */n.jsx(te,{type:"error",title:"Taxonomy Manager structure warning",message:"This concept has unlisted child concepts. The maximum validated hierarchy depth is 5 levels."}),!i&&"published"!==c&&/* @__PURE__ */n.jsx(J,{action:"remove",handler:h})]})]}),e?.childConcepts&&e.childConcepts.length>0&&e?.level&&e.level<5&&/* @__PURE__ */n.jsx(re,{concepts:e.childConcepts,selectConcept:t,inputComponent:i,childVisibility:u})]})},re=({concepts:e,inputComponent:t=!1,selectConcept:i,childVisibility:r})=>
42
- /* @__PURE__ */n.jsx(s.Box,{marginLeft:4,marginTop:2,display:"closed"==r?"none":"block",children:/* @__PURE__ */n.jsx(s.Stack,{space:3,children:e.map(e=>/* @__PURE__ */n.jsx(se,{concept:e,selectConcept:i,inputComponent:t},e.id))})}),oe=({concept:e,treeVisibility:t,inputComponent:i,selectConcept:o})=>{const c=r.useContext(L)||{},a=r.useContext(O),d=!!c.displayed?.topConcepts?.length&&!i,l=G(c),p=K(c),[h,u]=r.useState("closed"===t&&e.hasMatchingDescendant?"open":t),m=r.useCallback(()=>{"open"==h?u("closed"):"closed"==h&&u("open")},[h]),x=r.useCallback(()=>{l("concept",e)},[e,l]),f=r.useCallback(()=>{p(e.id,"concept",e?.prefLabel)},[e.id,e?.prefLabel,p]);/* @__PURE__ */
42
+ /* @__PURE__ */n.jsx(s.Box,{marginLeft:4,marginTop:2,display:"closed"==r?"none":"block",children:/* @__PURE__ */n.jsx(s.Stack,{space:3,children:e.map(e=>/* @__PURE__ */n.jsx(se,{concept:e,selectConcept:i,inputComponent:t},e.id))})}),oe=({concept:e,treeVisibility:t,inputComponent:i,selectConcept:o})=>{const c=r.useContext(L)||{},a=r.useContext(z),d=!!c.displayed?.topConcepts?.length&&!i,l=G(c),p=K(c),[h,u]=r.useState("closed"===t&&e.hasMatchingDescendant?"open":t),m=r.useCallback(()=>{"open"==h?u("closed"):"closed"==h&&u("open")},[h]),x=r.useCallback(()=>{l("concept",e)},[e,l]),f=r.useCallback(()=>{p(e.id,"concept",e?.prefLabel)},[e.id,e?.prefLabel,p]);/* @__PURE__ */
43
43
  return n.jsxs(s.Box,{className:h,children:[
44
44
  /* @__PURE__ */n.jsxs(s.Flex,{align:"center",justify:"space-between",wrap:"nowrap",children:[
45
- /* @__PURE__ */n.jsxs(s.Flex,{align:"center",gap:0,flex:1,style:{minWidth:0},children:[e?.childConcepts&&e.childConcepts.length>0&&/* @__PURE__ */n.jsx(ie,{handler:m,visibility:h}),!e?.prefLabel&&/* @__PURE__ */n.jsx(s.Box,{flex:1,marginLeft:e?.childConcepts&&0!=e.childConcepts.length?0:5,children:/* @__PURE__ */n.jsx(X,{concept:e,orphan:d})}),e?.prefLabel&&/* @__PURE__ */n.jsx(s.Box,{flex:1,marginLeft:e?.childConcepts&&0!=e.childConcepts.length?0:5,children:i?/* @__PURE__ */n.jsx(ee,{concept:e,selectConcept:o,orphan:d}):/* @__PURE__ */n.jsx(X,{concept:e,orphan:d})})]}),i&&/* @__PURE__ */n.jsx(Q,{concept:e}),!i&&"published"!==a&&/* @__PURE__ */n.jsxs(s.Inline,{children:[
45
+ /* @__PURE__ */n.jsxs(s.Flex,{align:"center",gap:0,flex:1,style:{minWidth:0},children:[e?.childConcepts&&e.childConcepts.length>0&&/* @__PURE__ */n.jsx(ie,{handler:m,visibility:h}),!e?.prefLabel&&/* @__PURE__ */n.jsx(s.Box,{flex:1,marginLeft:e?.childConcepts&&0!=e.childConcepts.length?0:5,children:/* @__PURE__ */n.jsx(X,{concept:e,orphan:d})}),e?.prefLabel&&/* @__PURE__ */n.jsx(s.Box,{flex:1,marginLeft:e?.childConcepts&&0!=e.childConcepts.length?0:5,children:i?/* @__PURE__ */n.jsx(ee,{concept:e,selectConcept:o,orphan:d}):/* @__PURE__ */n.jsx(X,{concept:e,orphan:d})})]}),i&&/* @__PURE__ */n.jsx(Y,{concept:e}),!i&&"published"!==a&&/* @__PURE__ */n.jsxs(s.Inline,{children:[
46
46
  /* @__PURE__ */n.jsx(J,{action:"add",handler:x}),
47
47
  /* @__PURE__ */n.jsx(J,{action:"remove",handler:f})]})]}),e?.childConcepts&&e.childConcepts.length>0&&/* @__PURE__ */n.jsx(re,{concepts:e.childConcepts,selectConcept:o,inputComponent:i,childVisibility:h})]})},ce=({document:t})=>{const[o,c]=r.useState(!1),[a,d]=r.useState(""),[l,p]=r.useState(""),h=r.useCallback(()=>c(!1),[]),u=r.useCallback(()=>c(!0),[]),m=r.useCallback(e=>{d(e.currentTarget.value)},[]),x=r.useCallback(e=>{p(e.currentTarget.value)},[]),f=function(){const t=s.useToast(),n=e.useClient({apiVersion:"2021-10-21"});return r.useCallback((e,i,s)=>{const r=e.displayed?._id,o=e.displayed?.baseIri,c=e.displayed?.schemeId,a={_id:`drafts.${r}`,_type:"skosConceptScheme",schemeId:c,baseIri:o,title:i,description:s||""};n.createIfNotExists(a).then(e=>s?t.push({closable:!0,status:"success",title:"Title and Description added."}):t.push({closable:!0,status:"success",title:"Title added."})).catch(e=>{t.push({closable:!0,status:"error",title:"There has been an error",description:e.message})})},[n,t])}(),g=r.useCallback(()=>{f(t,a,l)},[f,l,t,a]);/* @__PURE__ */
48
48
  return n.jsxs("div",{style:{marginTop:"2rem"},children:[
@@ -61,18 +61,18 @@ return n.jsxs("div",{style:{marginTop:"2rem"},children:[
61
61
  /* @__PURE__ */n.jsx(s.TextArea,{fontSize:2,onChange:x,padding:3,placeholder:"",value:l,rows:3}),
62
62
  /* @__PURE__ */n.jsx(s.Button,{tone:"primary",fontSize:2,onClick:g,text:"Save"})]})})})]})},ae=()=>/* @__PURE__ */n.jsx("div",{style:{marginTop:"2rem"},children:/* @__PURE__ */n.jsx(s.Card,{padding:[3,3,4],radius:2,shadow:1,tone:"primary",children:/* @__PURE__ */n.jsxs(s.Stack,{space:4,children:[
63
63
  /* @__PURE__ */n.jsx(s.Label,{size:4,children:"No Concepts"}),
64
- /* @__PURE__ */n.jsx(s.Text,{size:2,children:"There are not yet any concepts assigned to this scheme. To create a multi-level hierarchy with specific entry points, create Top Concepts first, then add child concepts to them. To create a flat list of concepts, create Concepts directly."})]})})}),de=({concept:e,treeVisibility:t,inputComponent:i,selectConcept:o})=>{const c=r.useContext(L)||{},a=r.useContext(O),d=G(c),l=K(c),[p,h]=r.useState("closed"===t&&e.hasMatchingDescendant?"open":t),u=r.useCallback(()=>{"open"==p?h("closed"):"closed"==p&&h("open")},[p]),m=r.useCallback(()=>{d("concept",e)},[e,d]),x=r.useCallback(()=>{l(e?.id,"topConcept",e?.prefLabel)},[e?.id,e?.prefLabel,l]);/* @__PURE__ */
64
+ /* @__PURE__ */n.jsx(s.Text,{size:2,children:"There are not yet any concepts assigned to this scheme. To create a multi-level hierarchy with specific entry points, create Top Concepts first, then add child concepts to them. To create a flat list of concepts, create Concepts directly."})]})})}),de=({concept:e,treeVisibility:t,inputComponent:i,selectConcept:o})=>{const c=r.useContext(L)||{},a=r.useContext(z),d=G(c),l=K(c),[p,h]=r.useState("closed"===t&&e.hasMatchingDescendant?"open":t),u=r.useCallback(()=>{"open"==p?h("closed"):"closed"==p&&h("open")},[p]),m=r.useCallback(()=>{d("concept",e)},[e,d]),x=r.useCallback(()=>{l(e?.id,"topConcept",e?.prefLabel)},[e?.id,e?.prefLabel,l]);/* @__PURE__ */
65
65
  return n.jsxs(s.Box,{className:p,children:[
66
66
  /* @__PURE__ */n.jsxs(s.Flex,{align:"center",justify:"space-between",wrap:"nowrap",children:[
67
- /* @__PURE__ */n.jsxs(s.Flex,{align:"center",gap:0,flex:1,style:{minWidth:0},children:[e?.childConcepts&&e.childConcepts.length>0&&/* @__PURE__ */n.jsx(ie,{handler:u,visibility:p}),!e?.prefLabel&&/* @__PURE__ */n.jsx(s.Box,{flex:1,marginLeft:e?.childConcepts&&0!=e.childConcepts.length?0:5,children:/* @__PURE__ */n.jsx(X,{concept:e,topConcept:!0})}),e?.prefLabel&&/* @__PURE__ */n.jsx(s.Box,{flex:1,marginLeft:e?.childConcepts&&0!=e.childConcepts.length?0:5,children:i?/* @__PURE__ */n.jsx(ee,{concept:e,selectConcept:o,topConcept:!0}):/* @__PURE__ */n.jsx(X,{concept:e,topConcept:!0})})]}),i&&/* @__PURE__ */n.jsx(Q,{concept:e}),!i&&"published"!==a&&/* @__PURE__ */n.jsxs(s.Inline,{children:[
67
+ /* @__PURE__ */n.jsxs(s.Flex,{align:"center",gap:0,flex:1,style:{minWidth:0},children:[e?.childConcepts&&e.childConcepts.length>0&&/* @__PURE__ */n.jsx(ie,{handler:u,visibility:p}),!e?.prefLabel&&/* @__PURE__ */n.jsx(s.Box,{flex:1,marginLeft:e?.childConcepts&&0!=e.childConcepts.length?0:5,children:/* @__PURE__ */n.jsx(X,{concept:e,topConcept:!0})}),e?.prefLabel&&/* @__PURE__ */n.jsx(s.Box,{flex:1,marginLeft:e?.childConcepts&&0!=e.childConcepts.length?0:5,children:i?/* @__PURE__ */n.jsx(ee,{concept:e,selectConcept:o,topConcept:!0}):/* @__PURE__ */n.jsx(X,{concept:e,topConcept:!0})})]}),i&&/* @__PURE__ */n.jsx(Y,{concept:e}),!i&&"published"!==a&&/* @__PURE__ */n.jsxs(s.Inline,{children:[
68
68
  /* @__PURE__ */n.jsx(J,{action:"add",handler:m}),
69
- /* @__PURE__ */n.jsx(J,{action:"remove",handler:x})]})]}),e?.childConcepts&&e.childConcepts.length>0&&/* @__PURE__ */n.jsx(re,{concepts:e.childConcepts,selectConcept:o,inputComponent:i,childVisibility:p})]})},le=({concepts:e,inputComponent:t,selectConcept:i})=>{const{globalVisibility:{treeId:o,treeVisibility:c}={treeId:"default",treeVisibility:"open"}}=r.useContext(z)||{};return e?.topConcepts?.length||e?.concepts?.length?/* @__PURE__ */n.jsx(s.Box,{paddingTop:4,children:/* @__PURE__ */n.jsxs(s.Stack,{space:3,style:{listStyle:"none",paddingLeft:"0",marginBlockStart:"0"},children:[e.topConcepts?.map(e=>/* @__PURE__ */n.jsx(de,{concept:e,treeVisibility:c,inputComponent:t,selectConcept:i},`${e?.id}+${o}`)),e.concepts?.filter(e=>e?.isOrphan).map(e=>/* @__PURE__ */n.jsx(oe,{concept:e,treeVisibility:c,inputComponent:t,selectConcept:i},`${e.id}+${o}`))]})}):/* @__PURE__ */n.jsx(ae,{})},pe=({branchId:e="",selectConcept:t,inputComponent:i,expanded:a,conceptRecs:d,recsError:l})=>{const p=r.useContext(L)||{},h=c.getPublishedId(p.displayed?._id),u=r.useContext(O),m=a?"open":"closed",{data:x,loading:f,error:g}=P({fetch:`\n select($branchId != null => \n *[_id == $id][0] {\n _updatedAt,\n "concepts": concepts[$branchId in @->broader[]->.conceptId]->|order(prefLabel) {\n "id": _id,\n "level": 0,\n "isOrphan": true,\n _originalId,\n prefLabel,\n definition,\n example,\n scopeNote,\n ${H()||""}\n }\n },\n *[_id == $id][0] {\n _updatedAt,\n "topConcepts":topConcepts[]->|order(prefLabel){\n "id": _id,\n "level": 0,\n _originalId,\n prefLabel,\n definition,\n example,\n scopeNote,\n ${H()||""}\n }, \n "concepts": concepts[]->|order(prefLabel){\n "id": _id,\n "level": 0,\n "isOrphan": \n coalesce(\n !array::intersects(\n broader[]._ref, (\n coalesce(^.concepts[]._ref, []) + coalesce(^.topConcepts[]._ref, [])\n )\n ), \n true),\n _originalId,\n prefLabel,\n definition,\n example,\n scopeNote,\n ${H()||""}\n }\n }\n )`,listen:'*[_type == "skosConcept" || _id == $id]'},{params:{id:h,branchId:e},options:{perspective:void 0===u?"drafts":[u]}}),b=r.useMemo(()=>{const e=/* @__PURE__ */new Map;if(Array.isArray(d))for(const t of d)e.set(t.value.documentId,t.score);return e},[d]),y=r.useMemo(()=>o.nanoid(6),[b]),j=r.useCallback(function e(t,n){const i=c.getPublishedId(t.id),s=n.get(i),r=t.childConcepts?.map(t=>e(t,n)),o=r?.some(e=>void 0!==e.score||e.hasMatchingDescendant)??!1;return{...t,...void 0===s?{}:{score:s},...o?{hasMatchingDescendant:!0}:{},...r?{childConcepts:r}:{}}},[]),C=r.useMemo(()=>!x||0===b.size||l?x:{topConcepts:x.topConcepts?.map(e=>j(e,b)),concepts:x.concepts?.map(e=>j(e,b))},[j,x,b,l]);return f?/* @__PURE__ */n.jsx(s.Box,{padding:5,children:/* @__PURE__ */n.jsxs(s.Flex,{align:"center",direction:"column",gap:5,height:"fill",justify:"center",style:{paddingTop:"1rem"},children:[
69
+ /* @__PURE__ */n.jsx(J,{action:"remove",handler:x})]})]}),e?.childConcepts&&e.childConcepts.length>0&&/* @__PURE__ */n.jsx(re,{concepts:e.childConcepts,selectConcept:o,inputComponent:i,childVisibility:p})]})},le=({concepts:e,inputComponent:t,selectConcept:i})=>{const{globalVisibility:{treeId:o,treeVisibility:c}={treeId:"default",treeVisibility:"open"}}=r.useContext(O)||{};return e?.topConcepts?.length||e?.concepts?.length?/* @__PURE__ */n.jsx(s.Box,{paddingTop:4,children:/* @__PURE__ */n.jsxs(s.Stack,{space:3,style:{listStyle:"none",paddingLeft:"0",marginBlockStart:"0"},children:[e.topConcepts?.map(e=>/* @__PURE__ */n.jsx(de,{concept:e,treeVisibility:c,inputComponent:t,selectConcept:i},`${e?.id}+${o}`)),e.concepts?.filter(e=>e?.isOrphan).map(e=>/* @__PURE__ */n.jsx(oe,{concept:e,treeVisibility:c,inputComponent:t,selectConcept:i},`${e.id}+${o}`))]})}):/* @__PURE__ */n.jsx(ae,{})},pe=({branchId:e="",selectConcept:t,inputComponent:i,expanded:a,conceptRecs:d,recsError:l})=>{const p=r.useContext(L)||{},h=c.getPublishedId(p.displayed?._id),u=r.useContext(z),m=a?"open":"closed",{data:x,loading:f,error:g}=P({fetch:`\n select($branchId != null => \n *[_id == $id][0] {\n _updatedAt,\n "concepts": concepts[$branchId in @->broader[]->.conceptId]->|order(prefLabel) {\n "id": _id,\n "level": 0,\n "isOrphan": true,\n _originalId,\n prefLabel,\n definition,\n example,\n scopeNote,\n ${H()||""}\n }\n },\n *[_id == $id][0] {\n _updatedAt,\n "topConcepts":topConcepts[]->|order(prefLabel){\n "id": _id,\n "level": 0,\n _originalId,\n prefLabel,\n definition,\n example,\n scopeNote,\n ${H()||""}\n }, \n "concepts": concepts[]->|order(prefLabel){\n "id": _id,\n "level": 0,\n "isOrphan": \n coalesce(\n !array::intersects(\n broader[]._ref, (\n coalesce(^.concepts[]._ref, []) + coalesce(^.topConcepts[]._ref, [])\n )\n ), \n true),\n _originalId,\n prefLabel,\n definition,\n example,\n scopeNote,\n ${H()||""}\n }\n }\n )`,listen:'*[_type == "skosConcept" || _id == $id]'},{params:{id:h,branchId:e},options:{perspective:void 0===u?"drafts":[u]}}),b=r.useMemo(()=>{const e=/* @__PURE__ */new Map;if(Array.isArray(d))for(const t of d)e.set(t.value.documentId,t.score);return e},[d]),y=r.useMemo(()=>o.nanoid(6),[b]),j=r.useCallback(function e(t,n){const i=c.getPublishedId(t.id),s=n.get(i),r=t.childConcepts?.map(t=>e(t,n)),o=r?.some(e=>void 0!==e.score||e.hasMatchingDescendant)??!1;return{...t,...void 0===s?{}:{score:s},...o?{hasMatchingDescendant:!0}:{},...r?{childConcepts:r}:{}}},[]),C=r.useMemo(()=>!x||0===b.size||l?x:{topConcepts:x.topConcepts?.map(e=>j(e,b)),concepts:x.concepts?.map(e=>j(e,b))},[j,x,b,l]);return f?/* @__PURE__ */n.jsx(s.Box,{padding:5,children:/* @__PURE__ */n.jsxs(s.Flex,{align:"center",direction:"column",gap:5,height:"fill",justify:"center",style:{paddingTop:"1rem"},children:[
70
70
  /* @__PURE__ */n.jsx(s.Spinner,{muted:!0}),
71
- /* @__PURE__ */n.jsx(s.Text,{muted:!0,size:1,children:"Loading hierarchy…"})]})}):g?(console.warn(g),/* @__PURE__ */n.jsx(s.Box,{padding:4,children:/* @__PURE__ */n.jsx(s.Card,{padding:[3],radius:2,shadow:1,tone:"caution",children:/* @__PURE__ */n.jsx(s.Text,{size:1,children:"There was a problem loading terms. Please check the scheme configuration and try again."})})})):x?/* @__PURE__ */n.jsx(z.Provider,{value:{globalVisibility:{treeId:y,treeVisibility:m}},children:/* @__PURE__ */n.jsxs(s.Box,{padding:4,paddingTop:0,children:[l&&/* @__PURE__ */n.jsx(s.Card,{marginTop:2,padding:3,radius:2,shadow:1,tone:"caution",children:/* @__PURE__ */n.jsx(s.Text,{size:2,children:l})}),
71
+ /* @__PURE__ */n.jsx(s.Text,{muted:!0,size:1,children:"Loading hierarchy…"})]})}):g?(console.warn(g),/* @__PURE__ */n.jsx(s.Box,{padding:4,children:/* @__PURE__ */n.jsx(s.Card,{padding:[3],radius:2,shadow:1,tone:"caution",children:/* @__PURE__ */n.jsx(s.Text,{size:1,children:"There was a problem loading terms. Please check the scheme configuration and try again."})})})):x?/* @__PURE__ */n.jsx(O.Provider,{value:{globalVisibility:{treeId:y,treeVisibility:m}},children:/* @__PURE__ */n.jsxs(s.Box,{padding:4,paddingTop:0,children:[l&&/* @__PURE__ */n.jsx(s.Card,{marginTop:2,padding:3,radius:2,shadow:1,tone:"caution",children:/* @__PURE__ */n.jsx(s.Text,{size:2,children:l})}),
72
72
  /* @__PURE__ */n.jsx(le,{concepts:C,inputComponent:i||!1,selectConcept:t||(()=>{})})]})}):/* @__PURE__ */n.jsx(s.Box,{padding:4,children:/* @__PURE__ */n.jsx(s.Card,{padding:[3],radius:2,shadow:1,tone:"caution",children:/* @__PURE__ */n.jsx(s.Text,{size:1,children:"This configuration does not have any terms associated with it. Please check the scheme and branch supplied and try again."})})})};function he(){/* @__PURE__ */
73
- return n.jsx("svg",{"data-sanity-icon":!0,width:"25",height:"25",viewBox:"0 0 25 25",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:/* @__PURE__ */n.jsx("path",{d:"M5.5 6.5V5.9H4.9V6.5H5.5ZM11.5 6.5H12.1V5.9H11.5V6.5ZM5.5 9H4.9V9.6H5.5V9ZM11.5 9V9.6H12.1V9H11.5ZM13.5 11V10.4H12.9V11H13.5ZM19.5 11H20.1V10.4H19.5V11ZM13.5 13.5H12.9V14.1H13.5V13.5ZM19.5 13.5V14.1H20.1V13.5H19.5ZM13.5 16V15.4H12.9V16H13.5ZM19.5 16H20.1V15.4H19.5V16ZM13.5 18.5H12.9V19.1H13.5V18.5ZM19.5 18.5V19.1H20.1V18.5H19.5ZM5.5 7.1H11.5V5.9H5.5V7.1ZM6.1 9V6.5H4.9V9H6.1ZM11.5 8.4H5.5V9.6H11.5V8.4ZM10.9 6.5V9H12.1V6.5H10.9ZM13.5 11.6H19.5V10.4H13.5V11.6ZM14.1 13.5V11H12.9V13.5H14.1ZM19.5 12.9H13.5V14.1H19.5V12.9ZM18.9 11V13.5H20.1V11H18.9ZM13.5 16.6H19.5V15.4H13.5V16.6ZM14.1 18.5V16H12.9V18.5H14.1ZM19.5 17.9H13.5V19.1H19.5V17.9ZM18.9 16V18.5H20.1V16H18.9ZM8 17.85H13.5V16.65H8V17.85ZM8 12.85H13.5V11.65H8V12.85ZM7.9 9.5V17.85H9.1V9.5H7.9Z",fill:"currentColor"})})}const ue=({inputComponent:e=!1,selectConcept:t})=>{const a=r.useContext(L)||{},d=c.getPublishedId(a.displayed?._id),l=r.useContext(O),p=G(a),h=r.useCallback(()=>{p("topConcept")},[p]),u=r.useCallback(()=>{p("concept")},[p]),[m,x]=r.useState({treeId:o.nanoid(6),treeVisibility:"open"}),f=r.useCallback(()=>{x({treeId:o.nanoid(6),treeVisibility:"open"})},[]),g=r.useCallback(()=>{x({treeId:o.nanoid(6),treeVisibility:"closed"})},[]),{data:b,loading:y,error:j}=P({fetch:`*[_id == $id][0] {\n _updatedAt,\n "topConcepts": topConcepts[]->|order(prefLabel) {\n "id": _id,\n "level": 0,\n _originalId,\n prefLabel,\n definition,\n example,\n scopeNote,\n ${H()||""}\n },\n "concepts": concepts[]->|order(prefLabel) {\n "id": _id,\n "level": 0,\n "isOrphan": \n coalesce(\n !array::intersects(\n broader[]._ref, (\n coalesce(^.concepts[]._ref, []) + coalesce(^.topConcepts[]._ref, [])\n )\n ),\n true),\n _originalId,\n prefLabel,\n definition,\n example,\n scopeNote,\n ${H()||""}\n }\n }`,listen:'*[_type == "skosConcept" || _type == "skosConceptScheme" ]'},{params:{id:d},options:{perspective:void 0===l?"drafts":[l]}});return y?/* @__PURE__ */n.jsx(s.Box,{padding:4,paddingTop:6,children:/* @__PURE__ */n.jsxs(s.Flex,{align:"center",direction:"column",gap:5,height:"fill",justify:"center",children:[
73
+ return n.jsx("svg",{"data-sanity-icon":!0,width:"25",height:"25",viewBox:"0 0 25 25",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:/* @__PURE__ */n.jsx("path",{d:"M5.5 6.5V5.9H4.9V6.5H5.5ZM11.5 6.5H12.1V5.9H11.5V6.5ZM5.5 9H4.9V9.6H5.5V9ZM11.5 9V9.6H12.1V9H11.5ZM13.5 11V10.4H12.9V11H13.5ZM19.5 11H20.1V10.4H19.5V11ZM13.5 13.5H12.9V14.1H13.5V13.5ZM19.5 13.5V14.1H20.1V13.5H19.5ZM13.5 16V15.4H12.9V16H13.5ZM19.5 16H20.1V15.4H19.5V16ZM13.5 18.5H12.9V19.1H13.5V18.5ZM19.5 18.5V19.1H20.1V18.5H19.5ZM5.5 7.1H11.5V5.9H5.5V7.1ZM6.1 9V6.5H4.9V9H6.1ZM11.5 8.4H5.5V9.6H11.5V8.4ZM10.9 6.5V9H12.1V6.5H10.9ZM13.5 11.6H19.5V10.4H13.5V11.6ZM14.1 13.5V11H12.9V13.5H14.1ZM19.5 12.9H13.5V14.1H19.5V12.9ZM18.9 11V13.5H20.1V11H18.9ZM13.5 16.6H19.5V15.4H13.5V16.6ZM14.1 18.5V16H12.9V18.5H14.1ZM19.5 17.9H13.5V19.1H19.5V17.9ZM18.9 16V18.5H20.1V16H18.9ZM8 17.85H13.5V16.65H8V17.85ZM8 12.85H13.5V11.65H8V12.85ZM7.9 9.5V17.85H9.1V9.5H7.9Z",fill:"currentColor"})})}const ue=({inputComponent:e=!1,selectConcept:t})=>{const a=r.useContext(L)||{},d=c.getPublishedId(a.displayed?._id),l=r.useContext(z),p=G(a),h=r.useCallback(()=>{p("topConcept")},[p]),u=r.useCallback(()=>{p("concept")},[p]),[m,x]=r.useState({treeId:o.nanoid(6),treeVisibility:"open"}),f=r.useCallback(()=>{x({treeId:o.nanoid(6),treeVisibility:"open"})},[]),g=r.useCallback(()=>{x({treeId:o.nanoid(6),treeVisibility:"closed"})},[]),{data:b,loading:y,error:j}=P({fetch:`*[_id == $id][0] {\n _updatedAt,\n "topConcepts": topConcepts[]->|order(prefLabel) {\n "id": _id,\n "level": 0,\n _originalId,\n prefLabel,\n definition,\n example,\n scopeNote,\n ${H()||""}\n },\n "concepts": concepts[]->|order(prefLabel) {\n "id": _id,\n "level": 0,\n "isOrphan": \n coalesce(\n !array::intersects(\n broader[]._ref, (\n coalesce(^.concepts[]._ref, []) + coalesce(^.topConcepts[]._ref, [])\n )\n ),\n true),\n _originalId,\n prefLabel,\n definition,\n example,\n scopeNote,\n ${H()||""}\n }\n }`,listen:'*[_type == "skosConcept" || _type == "skosConceptScheme" ]'},{params:{id:d},options:{perspective:void 0===l?"drafts":[l]}});return y?/* @__PURE__ */n.jsx(s.Box,{padding:4,paddingTop:6,children:/* @__PURE__ */n.jsxs(s.Flex,{align:"center",direction:"column",gap:5,height:"fill",justify:"center",children:[
74
74
  /* @__PURE__ */n.jsx(s.Spinner,{muted:!0}),
75
- /* @__PURE__ */n.jsx(s.Text,{muted:!0,size:1,children:"Loading hierarchy…"})]})}):j?(console.error(j),/* @__PURE__ */n.jsx("div",{children:"Error here"})):b?/* @__PURE__ */n.jsx(z.Provider,{value:{globalVisibility:m},children:/* @__PURE__ */n.jsx(s.Box,{padding:4,children:/* @__PURE__ */n.jsxs(n.Fragment,{children:[
75
+ /* @__PURE__ */n.jsx(s.Text,{muted:!0,size:1,children:"Loading hierarchy…"})]})}):j?(console.error(j),/* @__PURE__ */n.jsx("div",{children:"Error here"})):b?/* @__PURE__ */n.jsx(O.Provider,{value:{globalVisibility:m},children:/* @__PURE__ */n.jsx(s.Box,{padding:4,children:/* @__PURE__ */n.jsxs(n.Fragment,{children:[
76
76
  /* @__PURE__ */n.jsx(s.Stack,{space:4,children:/* @__PURE__ */n.jsx(s.Card,{borderBottom:!0,paddingBottom:1,display:"flex",flex:1,children:/* @__PURE__ */n.jsxs(s.Flex,{justify:"space-between",flex:1,children:[
77
77
  /* @__PURE__ */n.jsx(s.Card,{children:(b.topConcepts?.filter(e=>(e?.childConcepts?.length??0)>0).length>0||b.concepts?.filter(e=>(e?.childConcepts?.length??0)>0).length>0)&&/* @__PURE__ */n.jsxs(s.Inline,{space:1,children:[
78
78
  /* @__PURE__ */n.jsx(s.Button,{text:"Collapse",paddingY:2,mode:"bleed",onClick:g}),
@@ -82,7 +82,7 @@ return n.jsx("svg",{"data-sanity-icon":!0,width:"25",height:"25",viewBox:"0 0 25
82
82
  /* @__PURE__ */n.jsx(s.Button,{text:"Add Top Concept",icon:i.AddCircleIcon,mode:"bleed",tone:"positive",paddingY:2,onClick:h}),
83
83
  /* @__PURE__ */n.jsx(s.Button,{text:"Add Concept",icon:i.AddCircleIcon,mode:"bleed",tone:"positive",paddingY:2,onClick:u})]})})]})})}),
84
84
  /* @__PURE__ */n.jsx(le,{concepts:b,inputComponent:e,selectConcept:t||(()=>{})})]})})}):/* @__PURE__ */n.jsx(ce,{document:a})},me=({document:t,branchId:i,inputComponent:r=!1,selectConcept:o,expanded:c,conceptRecs:a,recsError:d})=>{const{selectedPerspectiveName:l}=e.usePerspective();/* @__PURE__ */
85
- return n.jsx(L.Provider,{value:t||{},children:/* @__PURE__ */n.jsx(O.Provider,{value:l,children:r?/* @__PURE__ */n.jsx(pe,{inputComponent:r,branchId:i,selectConcept:o,expanded:c,conceptRecs:a,recsError:d}):/* @__PURE__ */n.jsxs(s.Container,{width:1,children:[t?.displayed?.description&&/* @__PURE__ */n.jsx(s.Box,{padding:4,paddingTop:6,children:/* @__PURE__ */n.jsx(s.Stack,{space:4,children:/* @__PURE__ */n.jsxs(s.Stack,{space:2,children:[
85
+ return n.jsx(L.Provider,{value:t||{},children:/* @__PURE__ */n.jsx(z.Provider,{value:l,children:r?/* @__PURE__ */n.jsx(pe,{inputComponent:r,branchId:i,selectConcept:o,expanded:c,conceptRecs:a,recsError:d}):/* @__PURE__ */n.jsxs(s.Container,{width:1,children:[t?.displayed?.description&&/* @__PURE__ */n.jsx(s.Box,{padding:4,paddingTop:6,children:/* @__PURE__ */n.jsx(s.Stack,{space:4,children:/* @__PURE__ */n.jsxs(s.Stack,{space:2,children:[
86
86
  /* @__PURE__ */n.jsx(s.Text,{size:1,weight:"semibold",children:"Description"}),
87
87
  /* @__PURE__ */n.jsx(s.Text,{size:2,muted:!0,children:t?.displayed.description})]})})}),
88
88
  /* @__PURE__ */n.jsx(ue,{inputComponent:r,branchId:i})]})})})},xe=t=>{const{onChange:i}=t,o=s.useToast(),c=r.useCallback(()=>{i(e.unset()),o.push({status:"success",title:"Value removed.",duration:2500,closable:!0})},[i,o]);/* @__PURE__ */
@@ -144,11 +144,11 @@ return n.jsxs(s.Stack,{space:2,children:[t.renderDefault(t),
144
144
  /* @__PURE__ */n.jsxs("kbd",{children:["Example: tomato",
145
145
  /* @__PURE__ */n.jsx("br",{}),"Change Note: \"Moved from under 'fruits' to under 'vegetables' by Horace Gray\""]}),
146
146
  /* @__PURE__ */n.jsxs("p",{children:["For more information on the recommended usage of the SKOS documentation properties, see",
147
- /* @__PURE__ */n.jsxs("a",{href:"https://www.w3.org/TR/2009/NOTE-skos-primer-20090818/#secdocumentation",target:"_blank",rel:"noreferrer",children:[" ","W3C SKOS Primer: 2.4 Documentary Notes"]})]})]})]}),rows:3})],orderings:[{title:"Top Concepts",name:"topConcept",by:[{field:"topConcept",direction:"desc"},{field:"prefLabel",direction:"asc"}]},{title:"Preferred Label",name:"prefLabel",by:[{field:"prefLabel",direction:"asc"}]}],preview:{select:{title:"prefLabel"},prepare:({title:e})=>({title:e,media:h.AiOutlineTag})}})}function je(t,i=[],s){return e.defineType({name:"skosConceptScheme",title:"Concept Scheme",type:"document",icon:he,initialValue:async(e,n)=>{if(t)return{baseIri:t};const{getClient:i}=n;return{baseIri:await i({apiVersion:"2021-03-25"}).fetch("\n *[(_type == 'skosConcept' || _type == 'skosConceptScheme') && defined(baseIri)]| order(_createdAt desc)[0].baseIri\n ")??void 0}},fields:[e.defineField({name:"title",title:"Title",type:"string",description:"Taxonomy schemes group concepts into defined sets, such as thesauri, classification schemes, or facets. Concepts may belong to many (or no) concept schemes, and you may create as many (or few) concept schemes as you like"}),e.defineField({name:"description",title:"Description",type:"text",rows:5,description:"Describe the intended use of this scheme."}),e.defineField({name:"controls",title:"Concept Management Controls",deprecated:{reason:"This field was used for a previous version of the plugin and is no longer needed. Remove the value to hide this field."},type:"boolean",readOnly:!0,hidden:({document:e})=>void 0===e?.controls,components:{input:xe}}),...fe,e.defineField({name:"schemeId",title:"Identifier",description:"Generate or re-generate the identifier for this scheme according to parameters set in Taxonomy Manager plugin options. Note that this changes the scheme's URI, which is not advisable if the scheme already is use in production. Use with caution.",type:"string",initialValue:x(s),hidden:({document:e})=>!!e?.schemeId&&!s?.regenUi,readOnly:({document:e})=>!!e?.schemeId,components:{input:e=>/* @__PURE__ */n.jsx(f,{...e,ident:s})}}),e.defineField({name:"topConcepts",title:"Top Concepts",type:"array",validation:e=>e.unique(),of:[e.defineArrayMember({type:"reference",to:[{type:"skosConcept"}]})],options:{sortable:!1}}),e.defineField({name:"concepts",title:"Concepts",type:"array",validation:e=>e.unique(),of:[e.defineArrayMember({type:"reference",to:[{type:"skosConcept"}]})],options:{sortable:!1}}),...i],preview:{select:{title:"title"},prepare:({title:e})=>({title:e,media:he})}})}const Ce=/_key\s*==\s*['"](.*)['"]/,we=/^\d*:\d*$/,Ie=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,ve=/_key\s*==\s*['"](.*)['"]/;function ke(e){if("string"!=typeof e)throw new Error("Path is not a string");const t=e.match(Ie);if(!t)throw new Error("Invalid path string");return t.map(_e)}function _e(e){return function(e){return"number"==typeof e||"string"==typeof e&&/^\[\d+\]$/.test(e)}(e)?function(e){return Number(e.replace(/[^\d]/g,""))}(e):function(e){return"string"==typeof e?Ce.test(e.trim()):"object"==typeof e&&"_key"in e}(e)?function(e){return{_key:e.match(ve)[1]}}(e):function(e){if("string"==typeof e&&we.test(e))return!0;if(!Array.isArray(e)||2!==e.length)return!1;const[t,n]=e;return!("number"!=typeof t&&""!==t||"number"!=typeof n&&""!==n)}(e)?function(e){const[t,n]=e.split(":").map(e=>""===e?e:Number(e));return[t,n]}(e):e}const Te=({document:i})=>{const{selectedPerspectiveName:o}=e.usePerspective(),{routerPanesState:c,groupIndex:a,handleEditReference:d}=t.usePaneRouter(),l=e.useSchema(),p=e.getPublishedId(i.displayed?._id??""),h=r.useCallback((e,t)=>{const n=c[a+1]?.[0].params||{},{parentRefPath:i}=n;d({id:e,type:t,parentRefPath:i?ke(i):[""],template:{id:e}})},[c,a,d]),{data:u,loading:m,error:x}=P('*[!(_type in ["skosConcept","skosConceptScheme"]) && references($refId)]{_id,_type,title}',{params:{refId:p},options:{perspective:o?[o]:"drafts"}});return m?/* @__PURE__ */n.jsx(s.Box,{padding:5,children:/* @__PURE__ */n.jsxs(s.Flex,{align:"center",direction:"column",gap:5,height:"fill",justify:"center",style:{paddingTop:"1rem"},children:[
147
+ /* @__PURE__ */n.jsxs("a",{href:"https://www.w3.org/TR/2009/NOTE-skos-primer-20090818/#secdocumentation",target:"_blank",rel:"noreferrer",children:[" ","W3C SKOS Primer: 2.4 Documentary Notes"]})]})]})]}),rows:3})],orderings:[{title:"Top Concepts",name:"topConcept",by:[{field:"topConcept",direction:"desc"},{field:"prefLabel",direction:"asc"}]},{title:"Preferred Label",name:"prefLabel",by:[{field:"prefLabel",direction:"asc"}]}],preview:{select:{title:"prefLabel"},prepare:({title:e})=>({title:e,media:h.AiOutlineTag})}})}function je(t,i=[],s){return e.defineType({name:"skosConceptScheme",title:"Concept Scheme",type:"document",icon:he,initialValue:async(e,n)=>{if(t)return{baseIri:t};const{getClient:i}=n;return{baseIri:await i({apiVersion:"2021-03-25"}).fetch("\n *[(_type == 'skosConcept' || _type == 'skosConceptScheme') && defined(baseIri)]| order(_createdAt desc)[0].baseIri\n ")??void 0}},fields:[e.defineField({name:"title",title:"Title",type:"string",description:"Taxonomy schemes group concepts into defined sets, such as thesauri, classification schemes, or facets. Concepts may belong to many (or no) concept schemes, and you may create as many (or few) concept schemes as you like"}),e.defineField({name:"description",title:"Description",type:"text",rows:5,description:"Describe the intended use of this scheme."}),e.defineField({name:"controls",title:"Concept Management Controls",deprecated:{reason:"This field was used for a previous version of the plugin and is no longer needed. Remove the value to hide this field."},type:"boolean",readOnly:!0,hidden:({document:e})=>void 0===e?.controls,components:{input:xe}}),...fe,e.defineField({name:"schemeId",title:"Identifier",description:"Generate or re-generate the identifier for this scheme according to parameters set in Taxonomy Manager plugin options. Note that this changes the scheme's URI, which is not advisable if the scheme already is use in production. Use with caution.",type:"string",initialValue:x(s),hidden:({document:e})=>!!e?.schemeId&&!s?.regenUi,readOnly:({document:e})=>!!e?.schemeId,components:{input:e=>/* @__PURE__ */n.jsx(f,{...e,ident:s})}}),e.defineField({name:"topConcepts",title:"Top Concepts",type:"array",validation:e=>e.unique(),of:[e.defineArrayMember({type:"reference",to:[{type:"skosConcept"}]})],options:{sortable:!1}}),e.defineField({name:"concepts",title:"Concepts",type:"array",validation:e=>e.unique(),of:[e.defineArrayMember({type:"reference",to:[{type:"skosConcept"}]})],options:{sortable:!1}}),...i],preview:{select:{title:"title"},prepare:({title:e})=>({title:e,media:he})}})}const Ce=/_key\s*==\s*['"](.*)['"]/,Ie=/^\d*:\d*$/,we=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,ve=/_key\s*==\s*['"](.*)['"]/;function ke(e){if("string"!=typeof e)throw new Error("Path is not a string");const t=e.match(we);if(!t)throw new Error("Invalid path string");return t.map(_e)}function _e(e){return function(e){return"number"==typeof e||"string"==typeof e&&/^\[\d+\]$/.test(e)}(e)?function(e){return Number(e.replace(/[^\d]/g,""))}(e):function(e){return"string"==typeof e?Ce.test(e.trim()):"object"==typeof e&&"_key"in e}(e)?function(e){return{_key:e.match(ve)[1]}}(e):function(e){if("string"==typeof e&&Ie.test(e))return!0;if(!Array.isArray(e)||2!==e.length)return!1;const[t,n]=e;return!("number"!=typeof t&&""!==t||"number"!=typeof n&&""!==n)}(e)?function(e){const[t,n]=e.split(":").map(e=>""===e?e:Number(e));return[t,n]}(e):e}const Te=({document:i})=>{const{selectedPerspectiveName:o}=e.usePerspective(),{routerPanesState:c,groupIndex:a,handleEditReference:d}=t.usePaneRouter(),l=e.useSchema(),p=e.getPublishedId(i.displayed?._id??""),h=r.useCallback((e,t)=>{const n=c[a+1]?.[0].params||{},{parentRefPath:i}=n;d({id:e,type:t,parentRefPath:i?ke(i):[""],template:{id:e}})},[c,a,d]),{data:u,loading:m,error:x}=P('*[!(_type in ["skosConcept","skosConceptScheme"]) && references($refId)]{_id,_type,title}',{params:{refId:p},options:{perspective:o?[o]:"drafts"}});return m?/* @__PURE__ */n.jsx(s.Box,{padding:5,children:/* @__PURE__ */n.jsxs(s.Flex,{align:"center",direction:"column",gap:5,height:"fill",justify:"center",style:{paddingTop:"1rem"},children:[
148
148
  /* @__PURE__ */n.jsx(s.Spinner,{muted:!0}),
149
149
  /* @__PURE__ */n.jsx(s.Text,{muted:!0,size:1,children:"Loading usage…"})]})}):x?/* @__PURE__ */n.jsx(s.Stack,{padding:4,space:5,children:/* @__PURE__ */n.jsx(v,{tone:"caution",children:"There was en error fetching use data"})}):u?.length?/* @__PURE__ */n.jsx(s.Box,{padding:4,paddingTop:4,children:/* @__PURE__ */n.jsxs(s.Stack,{space:2,children:[
150
150
  /* @__PURE__ */n.jsx(s.Card,{borderBottom:!0,paddingTop:3,paddingBottom:3,children:/* @__PURE__ */n.jsx(s.Inline,{paddingTop:1,children:/* @__PURE__ */n.jsxs(s.Text,{weight:"semibold",muted:!0,size:1,children:["Resource count (all schemes): ",u.length]})})}),
151
- /* @__PURE__ */n.jsx(s.Stack,{space:1,children:u?.map(t=>{const i=l.get(t._type);return i&&/* @__PURE__ */n.jsx(s.Button,{onClick:()=>h(t._id,t._type),padding:2,mode:"bleed",children:/* @__PURE__ */n.jsx(e.Preview,{value:t,schemaType:i,layout:"block"})},t._id)})})]})}):/* @__PURE__ */n.jsx(s.Stack,{padding:4,space:5,children:/* @__PURE__ */n.jsx(v,{children:"This concept is not currently in use"})})},Se=e=>e.list().title("Taxonomy Manager").items([e.documentTypeListItem("skosConceptScheme").title("Concept Schemes"),e.documentTypeListItem("skosConcept").title("Concepts")]),Ve=(e,{schemaType:t})=>{switch(t){case"skosConceptScheme":return e.document().views([e.view.component(me).title("Tree View").icon(he),e.view.form().icon(i.EditIcon)]);case"skosConcept":return e.document().views([e.view.form().icon(i.EditIcon),e.view.component(Te).title("Tagged Resources").icon(i.DocumentsIcon)]);default:return e.document().views([e.view.form().icon(i.EditIcon)])}},Be=e.definePlugin(e=>{const{baseUri:n,customConceptFields:i,customSchemeFields:s,ident:r}=e||{};return Z=e,{name:"taxonomyManager",options:e,schema:{types:[ye(n,i,r),je(n,s,r)]},plugins:[t.structureTool({name:"taxonomy",title:"Taxonomy",structure:Se,defaultDocumentNode:Ve,icon:he})]}});exports.ArrayHierarchyInput=function(t){const i=e.useClient({apiVersion:"2025-02-19"}),o=e.useFormValue(["_id"]),{name:c,title:a,value:d=[],embeddingsIndex:l}=t,p=e.isVersionId(o),h=e.isDraftId(o),{selectedPerspectiveName:u}=e.usePerspective(),[m,x]=r.useState(!0),[f,g]=r.useState(!0),[b,y]=r.useState(!1),[j,C]=r.useState({}),[w,I]=r.useState(),{schemeId:v,branchId:k=null}=w?.params||{},{filter:_}=t.schemaType.of[0].options,{conceptRecs:T,recsError:S,triggerEmbeddingsSearch:V}=W(l),B=s.useToast();r.useEffect(()=>{(async function(){try{const e=await _({getClient:()=>i});I(e),g(!1)}catch(e){console.error("Error fetching filter values: ",e)}})().catch(e=>console.error("Error fetching filter values: ",e))},[_,i]),r.useEffect(()=>{v&&i.fetch(`{"displayed": *[schemeId == "${v}"][0]}`).then(e=>{e?.displayed&&(C(e),x(!1))}).catch(e=>console.warn(e))},[i,v]);const N=r.useCallback(()=>{y(!0),V()},[V]),E=r.useCallback(()=>{y(!1)},[]),F=r.useCallback(t=>{if((e.isDraftId(t?._originalId)||e.isVersionId(t?._originalId))&&(t._strengthenOnPublish={type:"skosConcept",template:{id:"skosConcept"}},t._weak=!0),delete t._originalId,d?.map(e=>e._ref).includes(t._ref))return y(!1),void B.push({status:"warning",title:"Taxonomy Term Not Added",description:"The selected concept is already included in this field.",duration:5e3,closable:!0});h||p?i.patch(o).setIfMissing({[c]:[]}).append(c,[t]).commit({autoGenerateArrayKeys:!0}).then(()=>y(!1)).catch(e=>console.error(e)):i.fetch(`*[_id == "${o}"][0]`).then(e=>{e._id=`drafts.${e._id}`,i.create(e).catch(e=>console.error("Error creating draft: ",e))}).then(()=>{i.patch(`drafts.${o}`).setIfMissing({[c]:[]}).append(c,[t]).commit({autoGenerateArrayKeys:!0}).then(()=>y(!1)).catch(e=>console.error(e))}).catch(e=>console.error(e))},[d,h,p,i,o,B,c]);if(!t.schemaType.of[0].options?.filter)/* @__PURE__ */return n.jsxs(s.Stack,{space:3,children:[t.renderDefault(t),
151
+ /* @__PURE__ */n.jsx(s.Stack,{space:1,children:u?.map(t=>{const i=l.get(t._type);return i&&/* @__PURE__ */n.jsx(s.Button,{onClick:()=>h(t._id,t._type),padding:2,mode:"bleed",children:/* @__PURE__ */n.jsx(e.Preview,{value:t,schemaType:i,layout:"block"})},t._id)})})]})}):/* @__PURE__ */n.jsx(s.Stack,{padding:4,space:5,children:/* @__PURE__ */n.jsx(v,{children:"This concept is not currently in use"})})},Se=e=>e.list().title("Taxonomy Manager").items([e.documentTypeListItem("skosConceptScheme").title("Concept Schemes"),e.documentTypeListItem("skosConcept").title("Concepts")]),Ve=(e,{schemaType:t})=>{switch(t){case"skosConceptScheme":return e.document().views([e.view.component(me).title("Tree View").icon(he),e.view.form().icon(i.EditIcon)]);case"skosConcept":return e.document().views([e.view.form().icon(i.EditIcon),e.view.component(Te).title("Tagged Resources").icon(i.DocumentsIcon)]);default:return e.document().views([e.view.form().icon(i.EditIcon)])}},Be=e.definePlugin(e=>{const{baseUri:n,customConceptFields:i,customSchemeFields:s,ident:r}=e||{};return Z=e,{name:"taxonomyManager",options:e,schema:{types:[ye(n,i,r),je(n,s,r)]},plugins:[t.structureTool({name:"taxonomy",title:"Taxonomy",structure:Se,defaultDocumentNode:Ve,icon:he})]}});exports.ArrayHierarchyInput=function(t){const i=e.useClient({apiVersion:"2025-02-19"}),o=e.useFormValue(["_id"]),{name:c,title:a,value:d=[],embeddingsIndex:l}=t,p=e.isVersionId(o),h=e.isDraftId(o),{selectedPerspectiveName:u}=e.usePerspective(),[m,x]=r.useState(!0),[f,g]=r.useState(!0),[b,y]=r.useState(!1),[j,C]=r.useState({}),[I,w]=r.useState(),{schemeId:v,branchId:k=null}=I?.params||{},{filter:_}=t.schemaType.of[0].options,{conceptRecs:T,recsError:S,triggerEmbeddingsSearch:V}=W(l),B=s.useToast();r.useEffect(()=>{(async function(){try{const e=await _({getClient:()=>i});w(e),g(!1)}catch(e){console.error("Error fetching filter values: ",e)}})().catch(e=>console.error("Error fetching filter values: ",e))},[_,i]),r.useEffect(()=>{v&&i.fetch(`{"displayed": *[schemeId == "${v}"][0]}`).then(e=>{e?.displayed&&(C(e),x(!1))}).catch(e=>console.warn(e))},[i,v]);const F=r.useCallback(()=>{y(!0),V()},[V]),N=r.useCallback(()=>{y(!1)},[]),E=r.useCallback(t=>{if((e.isDraftId(t?._originalId)||e.isVersionId(t?._originalId))&&(t._strengthenOnPublish={type:"skosConcept",template:{id:"skosConcept"}},t._weak=!0),delete t._originalId,d?.map(e=>e._ref).includes(t._ref))return y(!1),void B.push({status:"warning",title:"Taxonomy Term Not Added",description:"The selected concept is already included in this field.",duration:5e3,closable:!0});h||p?i.patch(o).setIfMissing({[c]:[]}).append(c,[t]).commit({autoGenerateArrayKeys:!0}).then(()=>y(!1)).catch(e=>console.error(e)):i.fetch(`*[_id == "${o}"][0]`).then(e=>{e._id=`drafts.${e._id}`,i.create(e).catch(e=>console.error("Error creating draft: ",e))}).then(()=>{i.patch(`drafts.${o}`).setIfMissing({[c]:[]}).append(c,[t]).commit({autoGenerateArrayKeys:!0}).then(()=>y(!1)).catch(e=>console.error(e))}).catch(e=>console.error(e))},[d,h,p,i,o,B,c]);if(!t.schemaType.of[0].options?.filter)/* @__PURE__ */return n.jsxs(s.Stack,{space:3,children:[t.renderDefault(t),
152
152
  /* @__PURE__ */n.jsx(s.Box,{padding:4,children:/* @__PURE__ */n.jsx(s.Card,{padding:[3],radius:2,shadow:1,tone:"caution",children:/* @__PURE__ */n.jsxs(s.Text,{size:1,children:["The ",
153
153
  /* @__PURE__ */n.jsx("code",{children:"ArrayHierarchyInput()"})," component must be used with an accompanying"," ",
154
154
  /* @__PURE__ */n.jsx("code",{children:"schemeFilter()"})," or ",
@@ -165,10 +165,8 @@ return n.jsxs(s.Stack,{space:3,children:[t.renderDefault(t),
165
165
  return n.jsx(s.Box,{padding:5,children:/* @__PURE__ */n.jsxs(s.Flex,{align:"center",direction:"column",gap:5,height:"fill",justify:"center",style:{paddingTop:"1rem"},children:[
166
166
  /* @__PURE__ */n.jsx(s.Spinner,{muted:!0}),
167
167
  /* @__PURE__ */n.jsx(s.Text,{muted:!0,size:1,children:"Loading input component…"})]})});const P="published"===u;/* @__PURE__ */
168
- return n.jsxs(s.Stack,{space:3,children:[w?.browseOnly?d.length>0?t.renderDefault(t):/* @__PURE__ */n.jsxs(s.Stack,{space:2,children:[
169
- /* @__PURE__ */n.jsx(s.Box,{paddingY:3,children:/* @__PURE__ */n.jsx(s.Text,{size:1,weight:"medium",children:a})}),
170
- /* @__PURE__ */n.jsx(s.Card,{padding:3,radius:2,border:!0,children:/* @__PURE__ */n.jsx(s.Text,{muted:!0,align:"center",size:1,children:"No items"})})]}):t.renderDefault(t),
171
- /* @__PURE__ */n.jsx(s.Grid,{columns:1,gap:3,children:/* @__PURE__ */n.jsx(s.Button,{disabled:P,icon:he,text:"Browse taxonomy tree",mode:"ghost",onClick:N})}),b&&/* @__PURE__ */n.jsx(s.Dialog,{header:a,id:"concept-select-dialog",onClose:E,zOffset:900,width:1,children:/* @__PURE__ */n.jsx(s.Box,{children:/* @__PURE__ */n.jsx(me,{document:j,branchId:k,inputComponent:!0,selectConcept:F,expanded:w?.expanded,conceptRecs:T,recsError:S})})})]})},exports.ReferenceHierarchyInput=function(t){const i=e.useClient({apiVersion:"vX"}),o=e.useFormValue(["_id"]),{name:a,title:d,value:l,embeddingsIndex:p}=t,{conceptRecs:h,recsError:u,triggerEmbeddingsSearch:m}=W(p),x=c.isVersionId(o),f=e.isDraftId(o),{selectedPerspectiveName:g}=e.usePerspective(),[b,y]=r.useState(!0),[j,C]=r.useState(!0),[w,I]=r.useState(!1),[v,k]=r.useState(void 0),[_,T]=r.useState(),{schemeId:S,branchId:V=null}=_?.params||{},{filter:B}=t.schemaType.options;r.useEffect(()=>{(async function(){try{const e=await B({getClient:()=>i});T(e),C(!1)}catch(e){console.error("Error fetching filter values: ",e)}})().catch(e=>console.error("Error fetching filter values: ",e))},[B,i]),r.useEffect(()=>{S&&i.fetch('{"displayed": *[schemeId == $schemeId][0]}',{schemeId:S}).then(e=>{e?.displayed&&(k(e),y(!1))}).catch(e=>console.warn(e))},[i,S]);const N=r.useCallback(()=>{I(!0),m()},[m]),E=r.useCallback(()=>{I(!1)},[]),F=r.useCallback(t=>{(e.isDraftId(t?._originalId)||c.isVersionId(t?._originalId))&&(t._strengthenOnPublish={type:"skosConcept",template:{id:"skosConcept"}},t._weak=!0),delete t._originalId,f||x?i.patch(o).set({[a]:t}).commit().then(()=>I(!1)).catch(e=>console.error(e)):i.fetch("*[_id == $id][0]",{id:o}).then(e=>{e._id=`drafts.${e._id}`,e[a]=t,i.create(e).catch(e=>console.error("Error creating draft: ",e))}).then(()=>I(!1)).catch(e=>console.error(e))},[i,o,f,x,a]);if(!t.schemaType.options?.filter)/* @__PURE__ */return n.jsxs(s.Stack,{space:3,children:[t.renderDefault(t),
168
+ return n.jsxs(s.Stack,{space:3,children:[I?.browseOnly?d.length>0?t.renderDefault(t):/* @__PURE__ */n.jsx(e.FormField,{title:a,description:t.description,level:t.level,validation:t.validation,__unstable_presence:t.presence,children:/* @__PURE__ */n.jsx(s.Card,{padding:3,radius:2,border:!0,children:/* @__PURE__ */n.jsx(s.Text,{muted:!0,align:"center",size:1,children:"No items"})})}):t.renderDefault(t),
169
+ /* @__PURE__ */n.jsx(s.Grid,{columns:1,gap:3,children:/* @__PURE__ */n.jsx(s.Button,{disabled:P,icon:he,text:"Browse taxonomy tree",mode:"ghost",onClick:F})}),b&&/* @__PURE__ */n.jsx(s.Dialog,{header:a,id:"concept-select-dialog",onClose:N,zOffset:900,width:1,children:/* @__PURE__ */n.jsx(s.Box,{children:/* @__PURE__ */n.jsx(me,{document:j,branchId:k,inputComponent:!0,selectConcept:E,expanded:I?.expanded,conceptRecs:T,recsError:S})})})]})},exports.ReferenceHierarchyInput=function(t){const i=e.useClient({apiVersion:"vX"}),o=e.useFormValue(["_id"]),{name:a,title:d,value:l,embeddingsIndex:p}=t,{conceptRecs:h,recsError:u,triggerEmbeddingsSearch:m}=W(p),x=c.isVersionId(o),f=e.isDraftId(o),{selectedPerspectiveName:g}=e.usePerspective(),[b,y]=r.useState(!0),[j,C]=r.useState(!0),[I,w]=r.useState(!1),[v,k]=r.useState(void 0),[_,T]=r.useState(),{schemeId:S,branchId:V=null}=_?.params||{},{filter:B}=t.schemaType.options;r.useEffect(()=>{(async function(){try{const e=await B({getClient:()=>i});T(e),C(!1)}catch(e){console.error("Error fetching filter values: ",e)}})().catch(e=>console.error("Error fetching filter values: ",e))},[B,i]),r.useEffect(()=>{S&&i.fetch('{"displayed": *[schemeId == $schemeId][0]}',{schemeId:S}).then(e=>{e?.displayed&&(k(e),y(!1))}).catch(e=>console.warn(e))},[i,S]);const F=r.useCallback(()=>{w(!0),m()},[m]),N=r.useCallback(()=>{w(!1)},[]),E=r.useCallback(t=>{(e.isDraftId(t?._originalId)||c.isVersionId(t?._originalId))&&(t._strengthenOnPublish={type:"skosConcept",template:{id:"skosConcept"}},t._weak=!0),delete t._originalId,f||x?i.patch(o).set({[a]:t}).commit().then(()=>w(!1)).catch(e=>console.error(e)):i.fetch("*[_id == $id][0]",{id:o}).then(e=>{e._id=`drafts.${e._id}`,e[a]=t,i.create(e).catch(e=>console.error("Error creating draft: ",e))}).then(()=>w(!1)).catch(e=>console.error(e))},[i,o,f,x,a]);if(!t.schemaType.options?.filter)/* @__PURE__ */return n.jsxs(s.Stack,{space:3,children:[t.renderDefault(t),
172
170
  /* @__PURE__ */n.jsx(s.Box,{padding:4,children:/* @__PURE__ */n.jsx(s.Card,{padding:[3],radius:2,shadow:1,tone:"caution",children:/* @__PURE__ */n.jsxs(s.Text,{size:1,children:["The ",
173
171
  /* @__PURE__ */n.jsx("code",{children:"ReferenceHierarchyInput()"})," component must be used with an accompanying"," ",
174
172
  /* @__PURE__ */n.jsx("code",{children:"schemeFilter()"})," or ",
@@ -180,7 +178,5 @@ return n.jsxs(s.Stack,{space:3,children:[t.renderDefault(t),
180
178
  return n.jsx(s.Box,{padding:5,children:/* @__PURE__ */n.jsxs(s.Flex,{align:"center",direction:"column",gap:5,height:"fill",justify:"center",style:{paddingTop:"1rem"},children:[
181
179
  /* @__PURE__ */n.jsx(s.Spinner,{muted:!0}),
182
180
  /* @__PURE__ */n.jsx(s.Text,{muted:!0,size:1,children:"Loading input component…"})]})});const P="published"===g;/* @__PURE__ */
183
- return n.jsxs(s.Stack,{space:4,children:[_?.browseOnly?l?t.renderDefault(t):/* @__PURE__ */n.jsxs(s.Stack,{space:2,children:[
184
- /* @__PURE__ */n.jsx(s.Box,{paddingY:3,children:/* @__PURE__ */n.jsx(s.Text,{size:1,weight:"medium",children:d})}),
185
- /* @__PURE__ */n.jsx(s.Card,{padding:3,radius:2,border:!0,children:/* @__PURE__ */n.jsx(s.Text,{muted:!0,align:"center",size:1,children:"No items"})})]}):t.renderDefault(t),
186
- /* @__PURE__ */n.jsx(s.Grid,{columns:1,gap:3,children:/* @__PURE__ */n.jsx(s.Button,{disabled:P,icon:he,text:"Browse taxonomy tree",mode:"ghost",onClick:N})}),w&&v&&/* @__PURE__ */n.jsx(s.Dialog,{header:d,id:"concept-select-dialog",onClose:E,zOffset:900,width:1,children:/* @__PURE__ */n.jsx(s.Box,{padding:10,children:/* @__PURE__ */n.jsx(me,{document:v,branchId:V,inputComponent:!0,selectConcept:F,expanded:_?.expanded,conceptRecs:h,recsError:u})})})]})},exports.TreeView=me,exports.branchFilter=e=>{const{schemeId:t,branchId:n=null}=e||{};if(!t||"string"!=typeof t)throw new Error("Invalid or missing schemeId: scheme Id must be a string");if(!n||"string"!=typeof n)throw new Error("Invalid or missing branchId: branch Id must be a string");return async i=>{const s=i?.getClient({apiVersion:"2023-01-01"});if(!s)throw new Error("Client not available");const{concepts:r}=await s.fetch('{ \n "concepts": *[\n _id in *[_type=="skosConceptScheme" && schemeId == $schemeId].concepts[]._ref\n && ($branchId in broader[]->conceptId\n || $branchId in broader[]->broader[]->conceptId\n || $branchId in broader[]->broader[]->broader[]->conceptId\n || $branchId in broader[]->broader[]->broader[]->broader[]->conceptId\n || $branchId in broader[]->broader[]->broader[]->broader[]->broader[]->conceptId)\n ]._id\n }',{schemeId:t,branchId:n});return{filter:"_id in $concepts",params:{concepts:r,schemeId:t,branchId:n},expanded:e?.expanded,browseOnly:e?.browseOnly}}},exports.schemeFilter=e=>{const{schemeId:t}=e||{};if(!t||"string"!=typeof t)throw new Error("Invalid or missing schemeId: scheme Id must be a string");return async n=>{const i=n?.getClient({apiVersion:"2025-02-19"});if(!i)throw new Error("Client not available");const{concepts:s,topConcepts:r}=await i.fetch(`{\n "concepts": *[_type=="skosConceptScheme" && schemeId == "${t}"].concepts[]._ref,\n "topConcepts": *[_type=="skosConceptScheme" && schemeId == "${t}"].topConcepts[]._ref\n }`);return{filter:"(_id in $concepts\n || _id in $topConcepts)",params:{concepts:s,topConcepts:r,schemeId:t},expanded:e?.expanded,browseOnly:e?.browseOnly}}},exports.taxonomyManager=Be;//# sourceMappingURL=index.js.map
181
+ return n.jsxs(s.Stack,{space:4,children:[_?.browseOnly?l?t.renderDefault(t):/* @__PURE__ */n.jsx(e.FormField,{title:d,description:t.description,level:t.level,validation:t.validation,__unstable_presence:t.presence,children:/* @__PURE__ */n.jsx(s.Card,{padding:3,radius:2,border:!0,children:/* @__PURE__ */n.jsx(s.Text,{muted:!0,align:"center",size:1,children:"No items"})})}):t.renderDefault(t),
182
+ /* @__PURE__ */n.jsx(s.Grid,{columns:1,gap:3,children:/* @__PURE__ */n.jsx(s.Button,{disabled:P,icon:he,text:"Browse taxonomy tree",mode:"ghost",onClick:F})}),I&&v&&/* @__PURE__ */n.jsx(s.Dialog,{header:d,id:"concept-select-dialog",onClose:N,zOffset:900,width:1,children:/* @__PURE__ */n.jsx(s.Box,{padding:10,children:/* @__PURE__ */n.jsx(me,{document:v,branchId:V,inputComponent:!0,selectConcept:E,expanded:_?.expanded,conceptRecs:h,recsError:u})})})]})},exports.TreeView=me,exports.branchFilter=e=>{const{schemeId:t,branchId:n=null}=e||{};if(!t||"string"!=typeof t)throw new Error("Invalid or missing schemeId: scheme Id must be a string");if(!n||"string"!=typeof n)throw new Error("Invalid or missing branchId: branch Id must be a string");return async i=>{const s=i?.getClient({apiVersion:"2023-01-01"});if(!s)throw new Error("Client not available");const{concepts:r}=await s.fetch('{ \n "concepts": *[\n _id in *[_type=="skosConceptScheme" && schemeId == $schemeId].concepts[]._ref\n && ($branchId in broader[]->conceptId\n || $branchId in broader[]->broader[]->conceptId\n || $branchId in broader[]->broader[]->broader[]->conceptId\n || $branchId in broader[]->broader[]->broader[]->broader[]->conceptId\n || $branchId in broader[]->broader[]->broader[]->broader[]->broader[]->conceptId)\n ]._id\n }',{schemeId:t,branchId:n});return{filter:"_id in $concepts",params:{concepts:r,schemeId:t,branchId:n},expanded:e?.expanded,browseOnly:e?.browseOnly}}},exports.schemeFilter=e=>{const{schemeId:t}=e||{};if(!t||"string"!=typeof t)throw new Error("Invalid or missing schemeId: scheme Id must be a string");return async n=>{const i=n?.getClient({apiVersion:"2025-02-19"});if(!i)throw new Error("Client not available");const{concepts:s,topConcepts:r}=await i.fetch(`{\n "concepts": *[_type=="skosConceptScheme" && schemeId == "${t}"].concepts[]._ref,\n "topConcepts": *[_type=="skosConceptScheme" && schemeId == "${t}"].topConcepts[]._ref\n }`);return{filter:"(_id in $concepts\n || _id in $topConcepts)",params:{concepts:s,topConcepts:r,schemeId:t},expanded:e?.expanded,browseOnly:e?.browseOnly}}},exports.taxonomyManager=Be;//# sourceMappingURL=index.js.map